1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_DBACCESS_SOURCE_CORE_DATAACCESS_DATABASEDOCUMENT_HXX
#define INCLUDED_DBACCESS_SOURCE_CORE_DATAACCESS_DATABASEDOCUMENT_HXX
#include <sal/config.h>
#include <map>
#include "ModelImpl.hxx"
#include "documenteventnotifier.hxx"
#include <com/sun/star/document/XDocumentSubStorageSupplier.hpp>
#include <com/sun/star/frame/XModel2.hpp>
#include <com/sun/star/frame/XTitle.hpp>
#include <com/sun/star/frame/XTitleChangeBroadcaster.hpp>
#include <com/sun/star/frame/XUntitledNumbers.hpp>
#include <com/sun/star/frame/XStorable.hpp>
#include <com/sun/star/sdb/XReportDocumentsSupplier.hpp>
#include <com/sun/star/sdb/XFormDocumentsSupplier.hpp>
#include <com/sun/star/view/XPrintable.hpp>
#include <com/sun/star/frame/XModuleManager2.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
#include <com/sun/star/embed/XTransactionListener.hpp>
#include <com/sun/star/document/XStorageBasedDocument.hpp>
#include <com/sun/star/document/XEmbeddedScripts.hpp>
#include <com/sun/star/document/XEventsSupplier.hpp>
#include <com/sun/star/document/XScriptInvocationContext.hpp>
#include <com/sun/star/script/XStorageBasedLibraryContainer.hpp>
#include <com/sun/star/script/provider/XScriptProviderSupplier.hpp>
#include <com/sun/star/frame/XLoadable.hpp>
#include <com/sun/star/document/XEventBroadcaster.hpp>
#include <com/sun/star/document/XDocumentEventBroadcaster.hpp>
#include <com/sun/star/document/XDocumentRecovery.hpp>
#include <com/sun/star/ui/XUIConfigurationManager2.hpp>
#include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
#include <com/sun/star/util/XCloseable.hpp>
#include <com/sun/star/util/XModifiable.hpp>
#ifndef INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_17
#define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_17
#define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 17
#include <comphelper/implbase_var.hxx>
#endif
#include <cppuhelper/compbase10.hxx>
#include <cppuhelper/implbase3.hxx>
#include <rtl/ref.hxx>
#include <boost/shared_ptr.hpp>
#include <boost/noncopyable.hpp>
namespace comphelper {
class NamedValueCollection;
}
namespace dbaccess
{
class DocumentEvents;
class DocumentEventExecutor;
class DocumentGuard;
typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > > Controllers;
// ViewMonitor
/** helper class monitoring the views of a document, and firing appropriate events
when views are attached / detached
*/
class ViewMonitor : public boost::noncopyable
{
public:
ViewMonitor( DocumentEventNotifier& _rEventNotifier )
:m_rEventNotifier( _rEventNotifier )
,m_bIsNewDocument( true )
,m_bEverHadController( false )
,m_bLastIsFirstEverController( false )
,m_xLastConnectedController()
{
}
void reset()
{
m_bEverHadController = false;
m_bLastIsFirstEverController = false;
m_xLastConnectedController.clear();
}
/** to be called when a view (aka controller) has been connected to the document
@return
<TRUE/> if and only if this was the first-ever controller connected to the document
*/
bool onControllerConnected(
const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& _rxController
);
/** to be called when a controller is set as current controller
@return <TRUE/>
if and only if the controller connection indicates that loading the document is finished. This
is the case if the given controller has previously been connected, and it was the first controller
ever for which this happened.
*/
bool onSetCurrentController(
const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& _rxController
);
void onLoadedDocument() { m_bIsNewDocument = false; }
private:
DocumentEventNotifier& m_rEventNotifier;
bool m_bIsNewDocument;
bool m_bEverHadController;
bool m_bLastIsFirstEverController;
::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >
m_xLastConnectedController;
};
// ODatabaseDocument
typedef ::comphelper::PartialWeakComponentImplHelper17 < ::com::sun::star::frame::XModel2
, ::com::sun::star::util::XModifiable
, ::com::sun::star::frame::XStorable
, ::com::sun::star::document::XEventBroadcaster
, ::com::sun::star::document::XDocumentEventBroadcaster
, ::com::sun::star::view::XPrintable
, ::com::sun::star::util::XCloseable
, ::com::sun::star::lang::XServiceInfo
, ::com::sun::star::sdb::XOfficeDatabaseDocument
, ::com::sun::star::ui::XUIConfigurationManagerSupplier
, ::com::sun::star::document::XStorageBasedDocument
, ::com::sun::star::document::XEmbeddedScripts
, ::com::sun::star::document::XScriptInvocationContext
, ::com::sun::star::script::provider::XScriptProviderSupplier
, ::com::sun::star::document::XEventsSupplier
, ::com::sun::star::frame::XLoadable
, ::com::sun::star::document::XDocumentRecovery
> ODatabaseDocument_OfficeDocument;
typedef ::cppu::ImplHelper3< ::com::sun::star::frame::XTitle
, ::com::sun::star::frame::XTitleChangeBroadcaster
, ::com::sun::star::frame::XUntitledNumbers
> ODatabaseDocument_Title;
class ODatabaseDocument :public ModelDependentComponent // ModelDependentComponent must be first!
,public ODatabaseDocument_OfficeDocument
,public ODatabaseDocument_Title
{
enum InitState
{
NotInitialized,
Initializing,
Initialized
};
typedef std::map< OUString, ::com::sun::star::uno::Reference< ::com::sun::star::frame::XUntitledNumbers > > TNumberedController;
::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager2> m_xUIConfigurationManager;
::cppu::OInterfaceContainerHelper m_aModifyListeners;
::cppu::OInterfaceContainerHelper m_aCloseListener;
::cppu::OInterfaceContainerHelper m_aStorageListeners;
DocumentEvents* m_pEventContainer;
::rtl::Reference< DocumentEventExecutor > m_pEventExecutor;
DocumentEventNotifier m_aEventNotifier;
::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > m_xCurrentController;
Controllers m_aControllers;
ViewMonitor m_aViewMonitor;
::com::sun::star::uno::WeakReference< ::com::sun::star::container::XNameAccess > m_xForms;
::com::sun::star::uno::WeakReference< ::com::sun::star::container::XNameAccess > m_xReports;
::com::sun::star::uno::WeakReference< ::com::sun::star::script::provider::XScriptProvider > m_xScriptProvider;
/** @short such module manager is used to classify new opened documents. */
::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager2 > m_xModuleManager;
::com::sun::star::uno::Reference< ::com::sun::star::frame::XTitle > m_xTitleHelper;
TNumberedController m_aNumberedControllers;
/** true if and only if the DatabaseDocument's "initNew" or "load" have been called (or, well,
the document has be initialized implicitly - see storeAsURL
*/
InitState m_eInitState;
bool m_bClosing;
bool m_bAllowDocumentScripting;
bool m_bHasBeenRecovered;
enum StoreType { SAVE, SAVE_AS };
/** stores the document to the given URL, rebases it to the respective new storage, if necessary, resets
the modified flag, and notifies any listeners as required
@param _rURL
the URL to store the document to
@param _rArguments
arguments for storing the document (MediaDescriptor)
@param _eType
the type of the store process (Save or SaveAs). The method will automatically
notify the proper events for this type.
@param _rGuard
the instance lock to be released before doing synchronous notifications
*/
void impl_storeAs_throw(
const OUString& _rURL,
const ::comphelper::NamedValueCollection& _rArguments,
const StoreType _eType,
DocumentGuard& _rGuard
)
throw ( ::com::sun::star::io::IOException
, ::com::sun::star::uno::RuntimeException );
/** notifies our storage change listeners that our underlying storage changed
@param _rxNewRootStorage
the new root storage to be notified. If <NULL/>, it is assumed that no storage change actually
happened, and the listeners are not notified.
*/
void impl_notifyStorageChange_nolck_nothrow(
const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxNewRootStorage
);
/// write a single XML stream into the package
void WriteThroughComponent(
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > & xComponent, /// the component we export
const sal_Char* pStreamName, /// the stream name
const sal_Char* pServiceName, /// service name of the component
const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any> & rArguments, /// the argument (XInitialization)
const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue> & rMediaDesc,/// output descriptor
const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _xStorageToSaveTo
) const;
/// write a single output stream
/// (to be called either directly or by WriteThroughComponent(...))
void WriteThroughComponent(
const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutputStream,
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xComponent,
const sal_Char* pServiceName,
const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rArguments,
const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue> & rMediaDesc
) const;
/** writes the content and settings
@param sURL
The URL
@param lArguments
The media descriptor
@param _xStorageToSaveTo
The storage which should be used for saving
*/
void impl_writeStorage_throw(
const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxTargetStorage,
const ::comphelper::NamedValueCollection& _rMediaDescriptor
) const;
// ModelDependentComponent overridables
virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getThis() const SAL_OVERRIDE;
::com::sun::star::uno::Reference< ::com::sun::star::frame::XTitle > impl_getTitleHelper_throw();
::com::sun::star::uno::Reference< ::com::sun::star::frame::XUntitledNumbers > impl_getUntitledHelper_throw(
const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xComponent = ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >());
private:
ODatabaseDocument(const ::rtl::Reference<ODatabaseModelImpl>& _pImpl);
// Do NOT create those documents directly, always use ODatabaseModelImpl::getModel. Reason is that
// ODatabaseDocument requires clear ownership, and in turn lifetime synchronisation with the ModelImpl.
// If you create a ODatabaseDocument directly, you might easily create a leak.
// #i50905#
protected:
virtual void SAL_CALL disposing() SAL_OVERRIDE;
virtual ~ODatabaseDocument();
public:
struct FactoryAccess { friend class ODatabaseModelImpl; private: FactoryAccess() { } };
static ODatabaseDocument* createDatabaseDocument( const ::rtl::Reference<ODatabaseModelImpl>& _pImpl, FactoryAccess /*accessControl*/ )
{
return new ODatabaseDocument( _pImpl );
}
// XServiceInfo
virtual OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
// ::com::sun::star::lang::XServiceInfo - static methods
static ::com::sun::star::uno::Sequence< OUString > getSupportedServiceNames_static(void) throw( ::com::sun::star::uno::RuntimeException );
static OUString getImplementationName_static(void) throw( ::com::sun::star::uno::RuntimeException );
static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
SAL_CALL Create(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&);
// XInterface
virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(const ::com::sun::star::uno::Type& _rType) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual void SAL_CALL acquire( ) throw () SAL_OVERRIDE;
virtual void SAL_CALL release( ) throw () SAL_OVERRIDE;
// XTypeProvider
virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
// XEventListener
virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
// XComponent
virtual void SAL_CALL dispose( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
// XModel
virtual sal_Bool SAL_CALL attachResource( const OUString& URL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Arguments ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
virtual OUString SAL_CALL getURL( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getArgs( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
virtual void SAL_CALL connectController( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& Controller ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
virtual void SAL_CALL disconnectController( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& Controller ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
virtual void SAL_CALL lockControllers( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
virtual void SAL_CALL unlockControllers( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
virtual sal_Bool SAL_CALL hasControllersLocked( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > SAL_CALL getCurrentController( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
virtual void SAL_CALL setCurrentController( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& Controller ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getCurrentSelection( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
// XModel2
virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL getControllers( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getAvailableViewControllerNames( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController2 > SAL_CALL createDefaultViewController( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& Frame ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController2 > SAL_CALL createViewController( const OUString& ViewName, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Arguments, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& Frame ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
// XStorable
virtual sal_Bool SAL_CALL hasLocation( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
virtual OUString SAL_CALL getLocation( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
virtual sal_Bool SAL_CALL isReadonly( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
virtual void SAL_CALL store( ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
virtual void SAL_CALL storeAsURL( const OUString& sURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& lArguments ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
virtual void SAL_CALL storeToURL( const OUString& sURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& lArguments ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
// XModifyBroadcaster
virtual void SAL_CALL addModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual void SAL_CALL removeModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
// ::com::sun::star::util::XModifiable
virtual sal_Bool SAL_CALL isModified( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
virtual void SAL_CALL setModified( sal_Bool bModified ) throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
// XEventBroadcaster
virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
// XDocumentEventBroadcaster
virtual void SAL_CALL addDocumentEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentEventListener >& _Listener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual void SAL_CALL removeDocumentEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentEventListener >& _Listener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual void SAL_CALL notifyDocumentEvent( const OUString& _EventName, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController2 >& _ViewController, const ::com::sun::star::uno::Any& _Supplement ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
// XPrintable
virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getPrinter( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
virtual void SAL_CALL setPrinter( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aPrinter ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
virtual void SAL_CALL print( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& xOptions ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
// XFormDocumentsSupplier
virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getFormDocuments( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
// XReportDocumentsSupplier
virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getReportDocuments( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
// XCloseable
virtual void SAL_CALL close( sal_Bool DeliverOwnership ) throw (::com::sun::star::util::CloseVetoException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual void SAL_CALL addCloseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseListener >& Listener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual void SAL_CALL removeCloseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseListener >& Listener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
// XUIConfigurationManagerSupplier
virtual ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager > SAL_CALL getUIConfigurationManager( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
// XDocumentSubStorageSupplier
virtual ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > SAL_CALL getDocumentSubStorage( const OUString& aStorageName, sal_Int32 nMode ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getDocumentSubStoragesNames( ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
// XOfficeDatabaseDocument
virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource > SAL_CALL getDataSource() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
// XStorageBasedDocument
virtual void SAL_CALL loadFromStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aMediaDescriptor ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::frame::DoubleInitializationException, ::com::sun::star::io::IOException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual void SAL_CALL storeToStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aMediaDescriptor ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual void SAL_CALL switchToStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > SAL_CALL getDocumentStorage( ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual void SAL_CALL addStorageChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XStorageChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual void SAL_CALL removeStorageChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XStorageChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
// XEmbeddedScripts
virtual ::com::sun::star::uno::Reference< ::com::sun::star::script::XStorageBasedLibraryContainer > SAL_CALL getBasicLibraries() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual ::com::sun::star::uno::Reference< ::com::sun::star::script::XStorageBasedLibraryContainer > SAL_CALL getDialogLibraries() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual sal_Bool SAL_CALL getAllowMacroExecution() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
// XScriptInvocationContext
virtual ::com::sun::star::uno::Reference< ::com::sun::star::document::XEmbeddedScripts > SAL_CALL getScriptContainer() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
// XScriptProviderSupplier
virtual ::com::sun::star::uno::Reference< ::com::sun::star::script::provider::XScriptProvider > SAL_CALL getScriptProvider( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
// XEventsSupplier
virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace > SAL_CALL getEvents( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
// XLoadable
virtual void SAL_CALL initNew( ) throw (::com::sun::star::frame::DoubleInitializationException, ::com::sun::star::io::IOException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual void SAL_CALL load( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& lArguments ) throw (::com::sun::star::frame::DoubleInitializationException, ::com::sun::star::io::IOException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
// css.document.XDocumentRecovery
virtual sal_Bool SAL_CALL wasModifiedSinceLastSave() throw ( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
virtual void SAL_CALL storeToRecoveryFile( const OUString& i_TargetLocation, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& i_MediaDescriptor ) throw ( ::com::sun::star::uno::RuntimeException, ::com::sun::star::io::IOException, ::com::sun::star::lang::WrappedTargetException, std::exception ) SAL_OVERRIDE;
virtual void SAL_CALL recoverFromFile( const OUString& i_SourceLocation, const OUString& i_SalvagedFile, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& i_MediaDescriptor ) throw ( ::com::sun::star::uno::RuntimeException, ::com::sun::star::io::IOException, ::com::sun::star::lang::WrappedTargetException, std::exception ) SAL_OVERRIDE;
// XTitle
virtual OUString SAL_CALL getTitle( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual void SAL_CALL setTitle( const OUString& sTitle ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
// XTitleChangeBroadcaster
virtual void SAL_CALL addTitleChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XTitleChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual void SAL_CALL removeTitleChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XTitleChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
// XUntitledNumbers
virtual ::sal_Int32 SAL_CALL leaseNumber( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xComponent ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual void SAL_CALL releaseNumber( ::sal_Int32 nNumber ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual void SAL_CALL releaseNumberForComponent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xComponent ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual OUString SAL_CALL getUntitledPrefix( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
/** clears the given object container
Clearing is done via disposal - the method calls XComponent::dispose at the given object,
which must be one of our impl's or our object containers (m_xForms, m_xReports,
m_xTableDefinitions, m_xCommandDefinitions)
@param _rxContainer
the container to clear
*/
static void clearObjectContainer(
::com::sun::star::uno::WeakReference< ::com::sun::star::container::XNameAccess >& _rxContainer);
/** checks whether the component is already initialized, throws a NotInitializedException if not
*/
inline void checkInitialized() const
{
if ( !impl_isInitialized() )
throw ::com::sun::star::lang::NotInitializedException( OUString(), getThis() );
}
/** checks the document is currently in the initialization phase, or already initialized.
Throws NotInitializedException if not so.
*/
inline void checkNotUninitilized() const
{
if ( impl_isInitialized() || impl_isInitializing() )
// fine
return;
throw ::com::sun::star::lang::NotInitializedException( OUString(), getThis() );
}
/** checks whether the document is currently being initialized, or already initialized,
throws a DoubleInitializationException if so
*/
inline void checkNotInitialized() const
{
if ( impl_isInitializing() || impl_isInitialized() )
throw ::com::sun::star::frame::DoubleInitializationException( OUString(), getThis() );
}
private:
::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager2 > getUIConfigurationManager2() throw (::com::sun::star::uno::RuntimeException);
/** returns whether the model is currently being initialized
*/
bool impl_isInitializing() const { return m_eInitState == Initializing; }
/** returns whether the model is already initialized, i.e. the XModel's "initNew" or "load" methods have been called
*/
bool impl_isInitialized() const { return m_eInitState == Initialized; }
/// tells the model it is being initialized now
void impl_setInitializing() { m_eInitState = Initializing; }
/// tells the model its initialization is done
void impl_setInitialized();
/** closes the frames of all connected controllers
@param _bDeliverOwnership
determines if the ownership should be transferred to the component which
possibly vetos the closing
@raises ::com::sun::star::util::CloseVetoException
if the closing was vetoed by any instance
*/
void impl_closeControllerFrames_nolck_throw( bool _bDeliverOwnership );
/** disposes the frames of all controllers which are still left in m_aControllers.
*/
void impl_disposeControllerFrames_nothrow();
/** does a reparenting at the given object container to ourself
Calls XChild::setParent at the given object, which must be one of our impl's or our
object containers (m_xForms, m_xReports, m_xTableDefinitions, m_xCommandDefinitions)
*/
void impl_reparent_nothrow( const ::com::sun::star::uno::WeakReference< ::com::sun::star::container::XNameAccess >& _rxContainer );
/** retrieves the forms or reports contained, creates and initializes it, if necessary
@raises DisposedException
if the instance is already disposed
@raises IllegalArgumentException
if <arg>_eType</arg> is not ODatabaseModelImpl::E_FORM and not ODatabaseModelImpl::E_REPORT
*/
::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
impl_getDocumentContainer_throw( ODatabaseModelImpl::ObjectType _eType );
/** resets everything
@precond
m_pImpl is not <NULLL/>
*/
void
impl_reset_nothrow();
/** imports the document from the given resource.
*/
static void
impl_import_nolck_throw(
const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rContext,
const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxTargetComponent,
const ::comphelper::NamedValueCollection& _rResource
);
/** creates a storage for the given URL, truncating it if a file with this name already exists
@throws Exception
if creating the storage failed
@return
the newly created storage for the file at the given URL
*/
::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
impl_createStorageFor_throw(
const OUString& _rURL
) const;
/** sets our "modified" flag
will notify all our respective listeners, if the "modified" state actually changed
@param _bModified
the (new) flag indicating whether the document is currently modified or not
@param _rGuard
the guard for our instance. At method entry, the guard must hold the lock. At the moment
of method leave, the lock will be released.
@precond
our mutex is locked
@postcond
our mutex is not locked
*/
void impl_setModified_nothrow( bool _bModified, DocumentGuard& _rGuard );
/** stores the document to the given storage
Note that the document is actually not rebased to this storage, it just stores a copy of itself
to the given target storage.
@param _rxTargetStorage
denotes the storage to store the document into
@param _rMediaDescriptor
contains additional parameters for storing the document
@param _rDocGuard
a guard which holds the (only) lock to the document, and which will be temporarily
released where necessary (e.g. for notifications, or calling into other components)
@throws ::com::sun::star::uno::IllegalArgumentException
if the given storage is <NULL/>.
@throws ::com::sun::star::uno::RuntimeException
when any of the used operations throws it
@throws ::com::sun::star::io::IOException
when any of the used operations throws it, or any other exception occurs which is no
RuntimeException and no IOException
*/
void impl_storeToStorage_throw(
const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxTargetStorage,
const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rMediaDescriptor,
DocumentGuard& _rDocGuard
) const;
/** impl-version of attachResource
@param i_rLogicalDocumentURL
denotes the logical URL of the document, to be reported by getURL/getLocation
@param i_rMediaDescriptor
denotes additional document parameters
@param _rDocGuard
is the guard which currently protects the document instance
*/
bool impl_attachResource(
const OUString& i_rLogicalDocumentURL,
const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& i_rMediaDescriptor,
DocumentGuard& _rDocGuard
);
/** throws an IOException with the message as defined in the RID_STR_ERROR_WHILE_SAVING resource, wrapping
the given caught non-IOException error
*/
void impl_throwIOExceptionCausedBySave_throw(
const ::com::sun::star::uno::Any& i_rError,
const OUString& i_rTargetURL
) const;
};
/** an extended version of the ModelMethodGuard, which also cares for the initialization state
of the document
*/
class DocumentGuard : private ModelMethodGuard
{
public:
enum MethodType
{
// a method which is to initialize the document
InitMethod,
// a default method
DefaultMethod,
// a method which is used (externally) during the initialization phase
MethodUsedDuringInit,
// a method which does not need initialization - use with care!
MethodWithoutInit
};
/** constructs the guard
@param _document
the ODatabaseDocument instance
@throws ::com::sun::star::lang::DisposedException
If the given component is already disposed
@throws ::com::sun::star::frame::DoubleInitializationException
if _eType is InitMethod, and the given component is already initialized, or currently being initialized.
@throws ::com::sun::star::lang::NotInitializedException
if _eType is DefaultMethod, and the given component is not yet initialized; or if _eType
is MethodUsedDuringInit, and the component is still uninitialized, and not in the initialization
phase currently.
*/
DocumentGuard( const ODatabaseDocument& _document, MethodType _eType = DefaultMethod )
:ModelMethodGuard( _document )
,m_document( _document )
{
switch ( _eType )
{
case InitMethod: m_document.checkNotInitialized(); break;
case DefaultMethod: m_document.checkInitialized(); break;
case MethodUsedDuringInit: m_document.checkNotUninitilized(); break;
case MethodWithoutInit: break;
}
}
~DocumentGuard()
{
}
void clear()
{
ModelMethodGuard::clear();
}
void reset()
{
ModelMethodGuard::reset();
m_document.checkDisposed();
}
private:
const ODatabaseDocument& m_document;
};
} // namespace dbaccess
#endif // INCLUDED_DBACCESS_SOURCE_CORE_DATAACCESS_DATABASEDOCUMENT_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|