LibreOffice Module dbaccess (master) 1
databasedocument.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <core_resource.hxx>
21#include <strings.hrc>
22#include "databasedocument.hxx"
24#include <databasecontext.hxx>
25#include "documentcontainer.hxx"
26#include <sdbcoretools.hxx>
27#include <strings.hxx>
29
30#include <officecfg/Office/Common.hxx>
31#include <com/sun/star/beans/PropertyAttribute.hpp>
32#include <com/sun/star/document/XExporter.hpp>
33#include <com/sun/star/document/XFilter.hpp>
34#include <com/sun/star/document/XImporter.hpp>
35#include <com/sun/star/document/XGraphicStorageHandler.hpp>
36#include <com/sun/star/document/GraphicStorageHandler.hpp>
37#include <com/sun/star/frame/Desktop.hpp>
38#include <com/sun/star/frame/ModuleManager.hpp>
39#include <com/sun/star/io/IOException.hpp>
40#include <com/sun/star/io/XSeekable.hpp>
41#include <com/sun/star/io/XOutputStream.hpp>
42#include <com/sun/star/io/XTruncate.hpp>
43#include <com/sun/star/lang/NoSupportException.hpp>
44#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
45#include <com/sun/star/script/provider/theMasterScriptProviderFactory.hpp>
46#include <com/sun/star/sdb/DatabaseContext.hpp>
47#include <com/sun/star/sdb/application/XDatabaseDocumentUI.hpp>
48#include <com/sun/star/task/XStatusIndicator.hpp>
49#include <com/sun/star/ucb/SimpleFileAccess.hpp>
50#include <com/sun/star/ui/UIConfigurationManager.hpp>
51#include <com/sun/star/util/CloseVetoException.hpp>
52#include <com/sun/star/view/XSelectionSupplier.hpp>
53#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
54#include <com/sun/star/xml/sax/Writer.hpp>
55
56#include <com/sun/star/script/XStorageBasedLibraryContainer.hpp>
57#include <com/sun/star/awt/XControl.hpp>
58#include <com/sun/star/awt/DialogProvider.hpp>
59
68#include <comphelper/types.hxx>
69
71
75#include <unotools/saveopt.hxx>
77#include <osl/diagnose.h>
78
79#include <vcl/GraphicObject.hxx>
80#include <tools/urlobj.hxx>
81
82using namespace ::com::sun::star::uno;
83using namespace ::com::sun::star::beans;
84using namespace ::com::sun::star::frame;
85using namespace ::com::sun::star::lang;
86using namespace ::com::sun::star::container;
87using namespace ::com::sun::star::document;
88using namespace ::com::sun::star::io;
89using namespace ::com::sun::star::util;
90using namespace ::com::sun::star::embed;
91using namespace ::com::sun::star::task;
92using namespace ::com::sun::star::view;
93using namespace ::com::sun::star::sdb;
94using namespace ::com::sun::star::sdbc;
95using namespace ::com::sun::star;
96using namespace ::com::sun::star::xml::sax;
97using namespace ::com::sun::star::script;
98using namespace ::com::sun::star::script::provider;
99using namespace ::com::sun::star::ui;
100using namespace ::cppu;
101
102namespace dbaccess
103{
104
105// ViewMonitor
106
107bool ViewMonitor::onControllerConnected( const Reference< XController >& _rxController )
108{
109 bool bFirstControllerEver = !m_bEverHadController;
111
112 m_xLastConnectedController = _rxController;
113 m_bLastIsFirstEverController = bFirstControllerEver;
114
115 return bFirstControllerEver;
116}
117
118bool ViewMonitor::onSetCurrentController( const Reference< XController >& _rxController )
119{
120 // we interpret this as "loading the document (including UI) is finished",
121 // if and only if this is the controller which was last connected, and it was the
122 // first controller ever connected
123 bool bLoadFinished = ( _rxController == m_xLastConnectedController ) && m_bLastIsFirstEverController;
124
125 // notify the respective events
126 if ( bLoadFinished )
128
129 return bLoadFinished;
130}
131
132
133ODatabaseDocument::ODatabaseDocument(const ::rtl::Reference<ODatabaseModelImpl>& _pImpl )
134 :ModelDependentComponent( _pImpl )
136 ,m_aModifyListeners( getMutex() )
137 ,m_aCloseListener( getMutex() )
138 ,m_aStorageListeners( getMutex() )
139 ,m_pEventContainer( new DocumentEvents( *this, getMutex(), _pImpl->getDocumentEvents() ) )
140 ,m_aEventNotifier( *this, getMutex() )
141 ,m_aViewMonitor( m_aEventNotifier )
142 ,m_eInitState( NotInitialized )
143 ,m_bClosing( false )
144 ,m_bAllowDocumentScripting( false )
145 ,m_bHasBeenRecovered( false )
146 ,m_bEmbedded(false)
147{
148 osl_atomic_increment( &m_refCount );
149 {
152 impl_reparent_nothrow( m_pImpl->m_xTableDefinitions );
153 impl_reparent_nothrow( m_pImpl->m_xCommandDefinitions );
154
155 m_pEventExecutor = new DocumentEventExecutor( m_pImpl->m_aContext, this );
156 }
157 osl_atomic_decrement( &m_refCount );
158
159 // if there previously was a document instance for the same Impl which was already initialized,
160 // then consider ourself initialized, too.
161 // #i94840#
162 if ( !m_pImpl->hadInitializedDocument() )
163 return;
164
165 // Note we set our init-state to "Initializing", not "Initialized". We're created from inside the ModelImpl,
166 // which is expected to call attachResource in case there was a previous incarnation of the document,
167 // so we can properly finish our initialization then.
169
170 if ( !m_pImpl->getURL().isEmpty() )
171 {
172 // if the previous incarnation of the DatabaseDocument already had a URL, then creating this incarnation
173 // here is effectively loading the document.
174 // #i105505#
176 }
177}
178
180{
181 if ( !ODatabaseDocument_OfficeDocument::rBHelper.bInDispose && !ODatabaseDocument_OfficeDocument::rBHelper.bDisposed )
182 {
183 acquire();
184 dispose();
185 }
186}
187
189{
190 // strip XEmbeddedScripts and XScriptInvocationContext if we have any form/report
191 // which already contains macros. In this case, the database document itself is not
192 // allowed to contain macros, too.
194 && ( _rType.equals( cppu::UnoType<XEmbeddedScripts>::get() )
196 )
197 )
198 return Any();
199
200 Any aReturn = ODatabaseDocument_OfficeDocument::queryInterface(_rType);
201 if (!aReturn.hasValue())
203 return aReturn;
204}
205
206void SAL_CALL ODatabaseDocument::acquire( ) noexcept
207{
208 ODatabaseDocument_OfficeDocument::acquire();
209}
210
211void SAL_CALL ODatabaseDocument::release( ) noexcept
212{
213 ODatabaseDocument_OfficeDocument::release();
214}
215
216Sequence< Type > SAL_CALL ODatabaseDocument::getTypes( )
217{
218 Sequence< Type > aTypes = ::comphelper::concatSequences(
219 ODatabaseDocument_OfficeDocument::getTypes(),
221 );
222
223 // strip XEmbeddedScripts and XScriptInvocationContext if we have any form/report
224 // which already contains macros. In this case, the database document itself is not
225 // allowed to contain macros, too.
227 {
228 auto [begin, end] = asNonConstRange(aTypes);
229 auto newEnd = std::remove_if( begin, end,
230 [](const Type& t)
233 aTypes.realloc( std::distance(begin, newEnd) );
234 }
235
236 return aTypes;
237}
238
239Sequence< sal_Int8 > SAL_CALL ODatabaseDocument::getImplementationId( )
240{
241 return css::uno::Sequence<sal_Int8>();
242}
243
244// local functions
245namespace
246{
247 Reference< XStatusIndicator > lcl_extractStatusIndicator( const ::comphelper::NamedValueCollection& _rArguments )
248 {
249 Reference< XStatusIndicator > xStatusIndicator;
250 return _rArguments.getOrDefault( "StatusIndicator", xStatusIndicator );
251 }
252
253 void lcl_triggerStatusIndicator_throw( const ::comphelper::NamedValueCollection& _rArguments, DocumentGuard& _rGuard, const bool _bStart )
254 {
255 Reference< XStatusIndicator > xStatusIndicator( lcl_extractStatusIndicator( _rArguments ) );
256 if ( !xStatusIndicator.is() )
257 return;
258
259 _rGuard.clear();
260 try
261 {
262 if ( _bStart )
263 xStatusIndicator->start( OUString(), sal_Int32(1000000) );
264 else
265 xStatusIndicator->end();
266 }
267 catch( const Exception& )
268 {
269 DBG_UNHANDLED_EXCEPTION("dbaccess");
270 }
271 _rGuard.reset();
272 // note that |reset| can throw a DisposedException
273 }
274
275 void lcl_extractStatusIndicator( const ::comphelper::NamedValueCollection& _rArguments, Sequence< Any >& _rCallArgs )
276 {
277 Reference< XStatusIndicator > xStatusIndicator( lcl_extractStatusIndicator( _rArguments ) );
278 if ( !xStatusIndicator.is() )
279 return;
280
281 sal_Int32 nLength = _rCallArgs.getLength();
282 _rCallArgs.realloc( nLength + 1 );
283 _rCallArgs.getArray()[ nLength ] <<= xStatusIndicator;
284 }
285
286 void lcl_extractAndStartStatusIndicator( const ::comphelper::NamedValueCollection& _rArguments, Reference< XStatusIndicator >& _rxStatusIndicator,
287 Sequence< Any >& _rCallArgs )
288 {
289 _rxStatusIndicator = lcl_extractStatusIndicator( _rArguments );
290 if ( !_rxStatusIndicator.is() )
291 return;
292
293 try
294 {
295 _rxStatusIndicator->start( OUString(), sal_Int32(1000000) );
296
297 sal_Int32 nLength = _rCallArgs.getLength();
298 _rCallArgs.realloc( nLength + 1 );
299 _rCallArgs.getArray()[ nLength ] <<= _rxStatusIndicator;
300 }
301 catch( const Exception& )
302 {
303 DBG_UNHANDLED_EXCEPTION("dbaccess");
304 }
305 }
306
307 Sequence< PropertyValue > lcl_appendFileNameToDescriptor( const ::comphelper::NamedValueCollection& _rDescriptor, const OUString& _rURL )
308 {
309 if ( _rURL.isEmpty() )
310 return _rDescriptor.getPropertyValues();
311
312 ::comphelper::NamedValueCollection aMutableDescriptor( _rDescriptor );
313 aMutableDescriptor.put( "FileName", _rURL );
314 aMutableDescriptor.put( "URL", _rURL );
315 return aMutableDescriptor.getPropertyValues();
316 }
317}
318
319constexpr OUStringLiteral sPictures = u"Pictures";
320
321// base documents seem to have a different behaviour to other documents, the
322// root storage contents at least seem to be re-used over different saves, thus if there is a
323// top level Picture directory it is never cleared.
324// If we delete the 'Pictures' directory then the dialog library storage which does store
325// any embed images will not work properly. ( this is due to the fact it will
326// try to load the dialog which will try and access the embed images, if those images are not cached in
327// memory it will try to read them from the Picture directory which is now gone, so... we have to use this
328// inglorious hack below which basically will
329//
330// a) create a temp storage
331//
332// b) introspect any dialogs for any embed graphics and grab the associate URL(s)
333//
334// c) populate the temp storage with the associated embed images ( will be stored in a 'Pictures' folder )
335//
336// d) delete the 'Picture' element from the root storage
337//
338// e) copy the Pictures element of the temp storage to the root storage
339//
340// this assumes that we don't use the Pictures folder in the root of the base
341// document for anything, I believe this is a valid assumption ( as much as
342// I could check anyway )
343
345static void lcl_uglyHackToStoreDialogeEmbedImages( const Reference< XStorageBasedLibraryContainer >& xDlgCont, const Reference< XStorage >& xStorage, const Reference< XModel >& rxModel, const Reference<XComponentContext >& rxContext )
346{
347 const Sequence< OUString > sLibraries = xDlgCont->getElementNames();
348 Reference< XStorage > xTmpPic = xStorage->openStorageElement( "tempPictures", ElementModes::READWRITE );
349
350 std::vector<uno::Reference<graphic::XGraphic>> vxGraphicList;
351 for ( OUString const & sLibrary : sLibraries )
352 {
353 xDlgCont->loadLibrary( sLibrary );
354 Reference< XNameContainer > xLib;
355 xDlgCont->getByName( sLibrary ) >>= xLib;
356 if ( xLib.is() )
357 {
358 Sequence< OUString > sDialogs = xLib->getElementNames();
359 sal_Int32 nDialogs( sDialogs.getLength() );
360 for ( sal_Int32 j=0; j < nDialogs; ++j )
361 {
362 Reference < awt::XDialogProvider > xDlgPrv = awt::DialogProvider::createWithModel(rxContext, rxModel);
363 OUString sDialogUrl =
364 "vnd.sun.star.script:" + sLibrary + "." + sDialogs[j] + "?location=document";
365
366 Reference< css::awt::XControl > xDialog( xDlgPrv->createDialog( sDialogUrl ), UNO_QUERY );
367 Reference< XInterface > xModel( xDialog->getModel() );
369 }
370 }
371 }
372 // if we have any image urls, make sure we copy the associated images into tempPictures
373 if (!vxGraphicList.empty())
374 {
375 // Export the images to the storage
376 uno::Reference<document::XGraphicStorageHandler> xGraphicStorageHandler;
377 xGraphicStorageHandler.set(GraphicStorageHandler::createWithStorage(rxContext, xTmpPic));
378 if (xGraphicStorageHandler.is())
379 {
380 for (uno::Reference<graphic::XGraphic> const & rxGraphic : vxGraphicList)
381 {
382 xGraphicStorageHandler->saveGraphic(rxGraphic);
383 }
384 }
385 // delete old 'Pictures' storage and copy the contents of tempPictures into xStorage
386 xStorage->removeElement( sPictures );
387 xTmpPic->copyElementTo( sPictures, xStorage, sPictures );
388 }
389 else
390 {
391 // clean up an existing Pictures dir
392 if ( xStorage->isStorageElement( sPictures ) )
393 xStorage->removeElement( sPictures );
394 }
395}
396
398{
400
401 // start event notifications
403}
404
406{
407 try
408 {
409 m_pImpl->clearConnections();
410 m_pImpl->disposeStorages();
411 m_pImpl->resetRootStorage();
412
415 clearObjectContainer( m_pImpl->m_xTableDefinitions );
416 clearObjectContainer( m_pImpl->m_xCommandDefinitions );
417
419
420 m_pImpl->reset();
421 }
422 catch(const Exception&)
423 {
424 DBG_UNHANDLED_EXCEPTION("dbaccess");
425 }
426 m_pImpl->m_bDocumentReadOnly = false;
427}
428
429namespace
430{
432 comphelper::PropertyMapEntry const aExportInfoMap[] =
433 {
434 { OUString("BaseURI"), 0, ::cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0 },
435 { OUString("StreamName"), 0, ::cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0 },
436 { OUString("UsePrettyPrinting"), 0, ::cppu::UnoType<sal_Bool>::get(), beans::PropertyAttribute::MAYBEVOID, 0},
437 { OUString("TargetStorage"), 0, cppu::UnoType<embed::XStorage>::get(), beans::PropertyAttribute::MAYBEVOID, 0},
438 { OUString("StreamRelPath"), 0, cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0},
439 };
440}
441
442void ODatabaseDocument::impl_import_nolck_throw( const Reference< XComponentContext >& _rContext, const Reference< XInterface >& _rxTargetComponent,
443 const ::comphelper::NamedValueCollection& _rResource )
444{
445 Sequence< Any > aFilterCreationArgs;
446 Reference< XStatusIndicator > xStatusIndicator;
447 lcl_extractAndStartStatusIndicator( _rResource, xStatusIndicator, aFilterCreationArgs );
448
449 uno::Reference< beans::XPropertySet > xInfoSet( comphelper::GenericPropertySet_CreateInstance( new comphelper::PropertySetInfo( aExportInfoMap ) ) );
450 OUString sBaseURI = _rResource.getOrDefault("BaseURI", OUString());
451 if (sBaseURI.isEmpty())
452 sBaseURI = _rResource.getOrDefault("URL",OUString());
453 assert(!sBaseURI.isEmpty()); // needed for relative URLs
454 xInfoSet->setPropertyValue("BaseURI", uno::Any(sBaseURI));
455 xInfoSet->setPropertyValue("StreamName", uno::Any(OUString("content.xml")));
456
457 const sal_Int32 nCount = aFilterCreationArgs.getLength();
458 aFilterCreationArgs.realloc(nCount + 1);
459 aFilterCreationArgs.getArray()[nCount] <<= xInfoSet;
460
461 Reference< XImporter > xImporter(
462 _rContext->getServiceManager()->createInstanceWithArgumentsAndContext("com.sun.star.comp.sdb.DBFilter", aFilterCreationArgs, _rContext),
463 UNO_QUERY_THROW );
464
465 Reference< XComponent > xComponent( _rxTargetComponent, UNO_QUERY_THROW );
466 xImporter->setTargetDocument( xComponent );
467
468 Reference< XFilter > xFilter( xImporter, UNO_QUERY_THROW );
469 Sequence< PropertyValue > aFilterArgs( ODatabaseModelImpl::stripLoadArguments( _rResource ).getPropertyValues() );
470 xFilter->filter( aFilterArgs );
471
472 if ( xStatusIndicator.is() )
473 xStatusIndicator->end();
474}
475
477{
478 // SYNCHRONIZED ->
480
482
484
485 // create a temporary storage
486 Reference< XStorage > xTempStor( ::comphelper::OStorageHelper::GetTemporaryStorage( m_pImpl->m_aContext ) );
487
488 // store therein
489 impl_storeToStorage_throw( xTempStor, Sequence< PropertyValue >(), aGuard );
490
491 // let the impl know we're now based on this storage
492 m_pImpl->switchToStorage( xTempStor );
493
494 // for the newly created document, allow document-wide scripting
496
498
499 m_aEventNotifier.notifyDocumentEventAsync( "OnTitleChanged" );
500
501 impl_setModified_nothrow( false, aGuard );
502 // <- SYNCHRONIZED
503
505
507}
508
509void SAL_CALL ODatabaseDocument::load( const Sequence< PropertyValue >& Arguments )
510{
511 // SYNCHRONIZED ->
513
515
516 ::comphelper::NamedValueCollection aResource( Arguments );
517 if ( aResource.has( "FileName" ) && !aResource.has( "URL" ) )
518 // FileName is the compatibility name for URL, so we might have clients passing
519 // a FileName only. However, some of our code works with the URL only, so ensure
520 // we have one.
521 aResource.put( "URL", aResource.get( "FileName" ) );
522 if ( aResource.has( "URL" ) && !aResource.has( "FileName" ) )
523 // similar ... just in case there is legacy code which expects a FileName only
524 aResource.put( "FileName", aResource.get( "URL" ) );
525
526 // now that somebody (perhaps) told us a macro execution mode, remember it as
527 // ImposedMacroExecMode
528 m_pImpl->setImposedMacroExecMode(
529 aResource.getOrDefault( "MacroExecutionMode", m_pImpl->getImposedMacroExecMode() ) );
530
532 try
533 {
534 aGuard.clear();
535 impl_import_nolck_throw( m_pImpl->m_aContext, *this, aResource );
536 aGuard.reset();
537 }
538 catch( const Exception& )
539 {
541 throw;
542 }
543 // tell our view monitor that the document has been loaded - this way it will fire the proper
544 // event (OnLoad instead of OnCreate) later on
546
547 // note that we do *not* call impl_setInitialized() here: The initialization is only complete
548 // when the XModel::attachResource has been called, not sooner.
549 // however, in case of embedding, XModel::attachResource is already called.
550 if (m_bEmbedded)
552
553 impl_setModified_nothrow( false, aGuard );
554 // <- SYNCHRONIZED
555}
556
557namespace
558{
559 bool lcl_hasAnyModifiedSubComponent_throw( const Reference< XController >& i_rController )
560 {
561 Reference< css::sdb::application::XDatabaseDocumentUI > xDatabaseUI( i_rController, UNO_QUERY_THROW );
562
563 const Sequence< Reference< XComponent > > aComponents( xDatabaseUI->getSubComponents() );
564
565 bool isAnyModified = false;
566 for ( auto const & xComponent : aComponents )
567 {
568 Reference< XModifiable > xModify( xComponent, UNO_QUERY );
569 if ( xModify.is() )
570 {
571 isAnyModified = xModify->isModified();
572 continue;
573 }
574
575 // TODO: clarify: anything else to care for? Both the sub components with and without model
576 // should support the XModifiable interface, so I think nothing more is needed here.
577 OSL_FAIL( "lcl_hasAnyModifiedSubComponent_throw: anything left to do here?" );
578 }
579
580 return isAnyModified;
581 }
582}
583
585{
587
588 // The implementation here is somewhat sloppy, in that it returns whether *any* part of the whole
589 // database document, including opened sub components, is modified. This is more than what is requested:
590 // We need to return <TRUE/> if the doc itself, or any of the opened sub components, has been modified
591 // since the last call to any of the save* methods, or since the document has been loaded/created.
592 // However, the API definition explicitly allows to be that sloppy ...
593
594 if ( isModified() )
595 return true;
596
597 // auto recovery is an "UI feature", it is to restore the UI the user knows. Thus,
598 // we ask our connected controllers, not simply our existing form/report definitions.
599 // (There is some information which even cannot be obtained without asking the controller.
600 // For instance, newly created, but not yet saved, forms/reports are accessible via the
601 // controller only, but not via the model.)
602
603 try
604 {
605 for (auto const& controller : m_aControllers)
606 {
607 if ( lcl_hasAnyModifiedSubComponent_throw(controller) )
608 return true;
609 }
610 }
611 catch( const Exception& )
612 {
613 DBG_UNHANDLED_EXCEPTION("dbaccess");
614 }
615
616 return false;
617}
618
619void SAL_CALL ODatabaseDocument::storeToRecoveryFile( const OUString& i_TargetLocation, const Sequence< PropertyValue >& i_MediaDescriptor )
620{
622 ModifyLock aLock( *this );
623
624 try
625 {
626 // create a storage for the target location
627 Reference< XStorage > xTargetStorage( impl_createStorageFor_throw( i_TargetLocation ) );
628
629 // first store the document as a whole into this storage
630 impl_storeToStorage_throw( xTargetStorage, i_MediaDescriptor, aGuard );
631
632 // save the sub components which need saving
633 DatabaseDocumentRecovery aDocRecovery( m_pImpl->m_aContext);
634 aDocRecovery.saveModifiedSubComponents( xTargetStorage, m_aControllers );
635
636 // commit the root storage
638 }
639 catch( const IOException& )
640 {
641 throw;
642 }
643 catch( const RuntimeException& )
644 {
645 throw;
646 }
647 catch( const WrappedTargetException& )
648 {
649 throw;
650 }
651 catch( const Exception& )
652 {
653 Any aError = ::cppu::getCaughtException();
654 throw WrappedTargetException( OUString(), *this, aError );
655 }
656}
657
658void SAL_CALL ODatabaseDocument::recoverFromFile( const OUString& i_SourceLocation, const OUString& i_SalvagedFile, const Sequence< PropertyValue >& i_MediaDescriptor )
659{
660 try
661 {
663
664 if ( i_SourceLocation.isEmpty() )
665 throw IllegalArgumentException( OUString(), *this, 1 );
666
667
668 // load the document itself, by simply delegating to our "load" method
669
670 // our load implementation expects the SalvagedFile and URL to be in the media descriptor
671 ::comphelper::NamedValueCollection aMediaDescriptor( i_MediaDescriptor );
672 aMediaDescriptor.put( "SalvagedFile", i_SalvagedFile );
673 aMediaDescriptor.put( "URL", i_SourceLocation );
674
675 aGuard.clear(); // (load has an own guarding scheme)
676 load( aMediaDescriptor.getPropertyValues() );
677 aGuard.reset();
678
679 // Without a controller, we are unable to recover the sub components, as they're always tied to a controller.
680 // So, everything else is done when the first controller is connected.
681 m_bHasBeenRecovered = true;
682
683 // tell the impl that we've been loaded from the given location
684 m_pImpl->setDocFileLocation( i_SourceLocation );
685
686 // by definition (of XDocumentRecovery), we're responsible for delivering a fully-initialized document,
687 // which includes an attachResource call.
688 const OUString sLogicalDocumentURL( i_SalvagedFile.isEmpty() ? i_SourceLocation : i_SalvagedFile );
689 impl_attachResource( sLogicalDocumentURL, aMediaDescriptor.getPropertyValues(), aGuard );
690 // <- SYNCHRONIZED
691 }
692 catch( const IOException& )
693 {
694 throw;
695 }
696 catch( const RuntimeException& )
697 {
698 throw;
699 }
700 catch( const WrappedTargetException& )
701 {
702 throw;
703 }
704 catch( const Exception& )
705 {
706 Any aError = ::cppu::getCaughtException();
707 throw WrappedTargetException( OUString(), *this, aError );
708 }
709}
710
711// XModel
712sal_Bool SAL_CALL ODatabaseDocument::attachResource( const OUString& _rURL, const Sequence< PropertyValue >& _rArguments )
713{
714 if (_rURL.isEmpty() && _rArguments.getLength() == 1 && _rArguments[0].Name == "SetEmbedded")
715 {
716 m_bEmbedded = true;
717 return true;
718 }
719
721 bool bRet = false;
722 try
723 {
724 bRet = impl_attachResource( _rURL, _rArguments, aGuard );
725 }
726 catch( const RuntimeException& )
727 {
728 throw;
729 }
730 catch( const Exception& )
731 {
732 Any aError = ::cppu::getCaughtException();
733 throw WrappedTargetRuntimeException( OUString(), *this, aError );
734 }
735 return bRet;
736}
737
738bool ODatabaseDocument::impl_attachResource( const OUString& i_rLogicalDocumentURL,
739 const Sequence< PropertyValue >& i_rMediaDescriptor, DocumentGuard& _rDocGuard )
740{
741 if (i_rLogicalDocumentURL == getURL())
742 {
743 ::comphelper::NamedValueCollection aArgs(i_rMediaDescriptor);
744
745 // this misuse of attachresource is a hack of the Basic importer code
746 // repurposing existing interfaces for uses it probably wasn't intended
747 // for
748
749 // we do not support macro signatures, so we can ignore that request
750 aArgs.remove("BreakMacroSignature");
751
752 bool bMacroEventRead = false;
753 if ((aArgs.get( "MacroEventRead" ) >>= bMacroEventRead) && bMacroEventRead)
754 m_pImpl->m_bMacroCallsSeenWhileLoading = true;
755 aArgs.remove( "MacroEventRead" );
756
757 if (aArgs.empty())
758 return false;
759 }
760
761 // if no URL has been provided, the caller was lazy enough to not call our getURL - which is not allowed anymore,
762 // now since getURL and getLocation both return the same, so calling one of those should be simple.
763 OUString sDocumentURL( i_rLogicalDocumentURL );
764 OSL_ENSURE( !sDocumentURL.isEmpty(), "ODatabaseDocument::impl_attachResource: invalid URL!" );
765 if ( sDocumentURL.isEmpty() )
766 sDocumentURL = getURL();
767
768 m_pImpl->setResource( sDocumentURL, i_rMediaDescriptor );
769
770 if ( impl_isInitializing() )
771 { // this means we've just been loaded, and this is the attachResource call which follows
772 // the load call.
774
775 // determine whether the document as a whole, or sub documents, have macros. Especially the latter
776 // controls the availability of our XEmbeddedScripts and XScriptInvocationContext interfaces, and we
777 // should know this before anybody actually uses the object.
779
780 _rDocGuard.clear();
781 // <- SYNCHRONIZED
782 m_aEventNotifier.notifyDocumentEvent( "OnLoadFinished" );
783 }
784
785 return true;
786}
787
788OUString SAL_CALL ODatabaseDocument::getURL( )
789{
791 return m_pImpl->getURL();
792}
793
794Sequence< PropertyValue > SAL_CALL ODatabaseDocument::getArgs( )
795{
797 return m_pImpl->getMediaDescriptor().getPropertyValues();
798}
799
800Sequence< PropertyValue > SAL_CALL ODatabaseDocument::getArgs2( const ::css::uno::Sequence< ::rtl::OUString >& requestedArgs )
801{
803 std::vector<PropertyValue> aRet;
804 for (const auto & rArgName : requestedArgs)
805 aRet.push_back(PropertyValue(rArgName, 0, m_pImpl->getMediaDescriptor().get(rArgName), PropertyState_DIRECT_VALUE));
807}
808
809void SAL_CALL ODatabaseDocument::setArgs(const Sequence<beans::PropertyValue>& /* aArgs */)
810{
811 throw NoSupportException();
812}
813
814void SAL_CALL ODatabaseDocument::connectController( const Reference< XController >& _xController )
815{
817
818#if OSL_DEBUG_LEVEL > 0
819 for (auto const& controller : m_aControllers)
820 {
821 OSL_ENSURE( controller != _xController, "ODatabaseDocument::connectController: this controller is already connected!" );
822 }
823#endif
824
825 m_aControllers.push_back( _xController );
826
827 m_aEventNotifier.notifyDocumentEventAsync( "OnViewCreated", Reference< XController2 >( _xController, UNO_QUERY ) );
828
829 bool bFirstControllerEver = m_aViewMonitor.onControllerConnected( _xController );
830 if ( !bFirstControllerEver )
831 return;
832
833 // check/adjust our macro mode.
834 m_pImpl->checkMacrosOnLoading();
835}
836
837void SAL_CALL ODatabaseDocument::disconnectController( const Reference< XController >& _xController )
838{
839 bool bNotifyViewClosed = false;
840 bool bLastControllerGone = false;
841 bool bIsClosing = false;
842
843 // SYNCHRONIZED ->
844 {
846
847 Controllers::iterator pos = std::find( m_aControllers.begin(), m_aControllers.end(), _xController );
848 OSL_ENSURE( pos != m_aControllers.end(), "ODatabaseDocument::disconnectController: don't know this controller!" );
849 if ( pos != m_aControllers.end() )
850 {
851 m_aControllers.erase( pos );
852 bNotifyViewClosed = true;
853 }
854
855 if ( m_xCurrentController == _xController )
856 m_xCurrentController = nullptr;
857
858 bLastControllerGone = m_aControllers.empty();
859 bIsClosing = m_bClosing;
860 }
861 // <- SYNCHRONIZED
862
863 if ( bNotifyViewClosed )
864 m_aEventNotifier.notifyDocumentEvent( "OnViewClosed", Reference< XController2 >( _xController, UNO_QUERY ) );
865
866 if ( !bLastControllerGone || bIsClosing )
867 return;
868
869 // if this was the last view, close the document as a whole
870 // #i51157#
871 try
872 {
873 close( true );
874 }
875 catch( const CloseVetoException& )
876 {
877 // okay, somebody vetoed and took ownership
878 }
879}
880
882{
884
885 ++m_pImpl->m_nControllerLockCount;
886}
887
889{
891
892 --m_pImpl->m_nControllerLockCount;
893}
894
896{
898
899 return m_pImpl->m_nControllerLockCount != 0;
900}
901
902Reference< XController > SAL_CALL ODatabaseDocument::getCurrentController()
903{
905
906 return m_xCurrentController.is() ? m_xCurrentController : ( m_aControllers.empty() ? Reference< XController >() : *m_aControllers.begin() );
907}
908
909void SAL_CALL ODatabaseDocument::setCurrentController( const Reference< XController >& _xController )
910{
912
913 m_xCurrentController = _xController;
914
915 if ( !m_aViewMonitor.onSetCurrentController( _xController ) )
916 return;
917
918 // check if there are sub components to recover from our document storage
919 bool bAttemptRecovery = m_bHasBeenRecovered;
920 if ( !bAttemptRecovery && m_pImpl->getMediaDescriptor().has( "ForceRecovery" ) )
921 // do not use getOrDefault, it will throw for invalid types, which is not desired here
922 m_pImpl->getMediaDescriptor().get( "ForceRecovery" ) >>= bAttemptRecovery;
923
924 if ( !bAttemptRecovery )
925 return;
926
927 try
928 {
929 DatabaseDocumentRecovery aDocRecovery( m_pImpl->m_aContext );
930 aDocRecovery.recoverSubDocuments( m_pImpl->getRootStorage(), _xController );
931 }
932 catch( const Exception& )
933 {
934 DBG_UNHANDLED_EXCEPTION("dbaccess");
935 }
936}
937
938Reference< XInterface > SAL_CALL ODatabaseDocument::getCurrentSelection( )
939{
941
942 Reference< XInterface > xRet;
943 Reference< XSelectionSupplier > xDocView( getCurrentController(), UNO_QUERY );
944 if ( xDocView.is() )
945 xRet.set(xDocView->getSelection(),UNO_QUERY);
946
947 return xRet;
948}
949
950// XStorable
952{
953 return !getLocation().isEmpty();
954}
955
957{
959 return m_pImpl->getURL();
960 // both XStorable::getLocation and XModel::getURL have to return the URL of the document, *not*
961 // the location of the file which the document was possibly recovered from (which would be getDocFileLocation)
962}
963
965{
967 return m_pImpl->m_bDocumentReadOnly;
968}
969
971{
973
974 OUString sDocumentURL( m_pImpl->getURL() );
975 if ( !sDocumentURL.isEmpty() )
976 {
977 if ( m_pImpl->getDocFileLocation() == m_pImpl->getURL() )
978 if ( m_pImpl->m_bDocumentReadOnly )
979 throw IOException();
980
981 impl_storeAs_throw( m_pImpl->getURL(), m_pImpl->getMediaDescriptor(), SAVE, aGuard );
982 return;
983 }
984
985 // if we have no URL, but did survive the DocumentGuard above, then we've been inited via XLoadable::initNew,
986 // i.e. we're based on a temporary storage
987 OSL_ENSURE( m_pImpl->getDocFileLocation().isEmpty(), "ODatabaseDocument::store: unexpected URL inconsistency!" );
988
989 try
990 {
991 impl_storeToStorage_throw( m_pImpl->getRootStorage(), m_pImpl->getMediaDescriptor().getPropertyValues(), aGuard );
992 }
993 catch( const Exception& )
994 {
995 Any aError = ::cppu::getCaughtException();
996 if ( aError.isExtractableTo( ::cppu::UnoType< IOException >::get() )
997 || aError.isExtractableTo( ::cppu::UnoType< RuntimeException >::get() )
998 )
999 {
1000 // allowed to leave
1001 throw;
1002 }
1004 }
1005}
1006
1007void ODatabaseDocument::impl_throwIOExceptionCausedBySave_throw( const Any& i_rError, std::u16string_view i_rTargetURL ) const
1008{
1009 OUString sErrorMessage = extractExceptionMessage( m_pImpl->m_aContext, i_rError );
1010 sErrorMessage = ResourceManager::loadString(
1011 RID_STR_ERROR_WHILE_SAVING,
1012 "$location$", i_rTargetURL,
1013 "$message$", sErrorMessage
1014 );
1015 throw IOException( sErrorMessage, *const_cast< ODatabaseDocument* >( this ) );
1016}
1017
1018void ODatabaseDocument::impl_storeAs_throw( const OUString& _rURL, const ::comphelper::NamedValueCollection& _rArguments,
1019 const StoreType _eType, DocumentGuard& _rGuard )
1020{
1021 OSL_PRECOND( ( _eType == SAVE ) || ( _eType == SAVE_AS ),
1022 "ODatabaseDocument::impl_storeAs_throw: you introduced a new type which cannot be handled here!" );
1023
1024 // if we're in the process of initializing the document (which effectively means it is an implicit
1025 // initialization triggered in storeAsURL), the we do not notify events, since to an observer, the SaveAs
1026 // should not be noticeable
1027 bool bIsInitializationProcess = impl_isInitializing();
1028
1029 if ( !bIsInitializationProcess )
1030 {
1031 _rGuard.clear();
1032 m_aEventNotifier.notifyDocumentEvent( _eType == SAVE ? "OnSave" : "OnSaveAs", nullptr, Any( _rURL ) );
1033 _rGuard.reset();
1034 }
1035
1036 Reference< XStorage > xNewRootStorage;
1037 // will be non-NULL if our storage changed
1038
1039 try
1040 {
1041 ModifyLock aLock( *this );
1042 // ignore all changes of our "modified" state during storing
1043
1044 bool bLocationChanged = ( _rURL != m_pImpl->getDocFileLocation() );
1045 if ( bLocationChanged )
1046 {
1047 // create storage for target URL
1048 uno::Reference<embed::XStorage> xTargetStorage(
1049 impl_GetStorageOrCreateFor_throw(_rArguments, _rURL));
1050
1051 if ( m_pImpl->isEmbeddedDatabase() )
1052 m_pImpl->clearConnections();
1053
1054 // commit everything
1055 m_pImpl->commitEmbeddedStorage();
1056 m_pImpl->commitStorages();
1057
1058 // copy own storage to target storage
1059 Reference< XStorage > xCurrentStorage( m_pImpl->getRootStorage() );
1060 if ( xCurrentStorage.is() )
1061 xCurrentStorage->copyToStorage( xTargetStorage );
1062
1063 m_pImpl->disposeStorages();
1064
1065 // each and every document definition obtained via m_xForms and m_xReports depends
1066 // on the sub storages which we just disposed. So, dispose the forms/reports collections, too.
1067 // This ensures that they're re-created when needed.
1070
1071 xNewRootStorage = m_pImpl->switchToStorage( xTargetStorage );
1072
1073 m_pImpl->m_bDocumentReadOnly = false;
1074 }
1075
1076 // store to current storage
1077 Reference< XStorage > xCurrentStorage( m_pImpl->getOrCreateRootStorage(), UNO_SET_THROW );
1078 Sequence< PropertyValue > aMediaDescriptor( lcl_appendFileNameToDescriptor( _rArguments, _rURL ) );
1079 impl_storeToStorage_throw( xCurrentStorage, aMediaDescriptor, _rGuard );
1080
1081 // success - tell our impl
1082 m_pImpl->setDocFileLocation( _rURL );
1083 m_pImpl->setResource( _rURL, aMediaDescriptor );
1084
1085 // if we are in an initialization process, then this is finished, now that we stored the document
1086 if ( bIsInitializationProcess )
1088 }
1089 catch( const IOException& )
1090 {
1091 if ( !bIsInitializationProcess )
1092 m_aEventNotifier.notifyDocumentEventAsync( _eType == SAVE ? "OnSaveFailed" : "OnSaveAsFailed", nullptr, Any( _rURL ) );
1093 throw;
1094 }
1095 catch( const RuntimeException& )
1096 {
1097 if ( !bIsInitializationProcess )
1098 m_aEventNotifier.notifyDocumentEventAsync( _eType == SAVE ? "OnSaveFailed" : "OnSaveAsFailed", nullptr, Any( _rURL ) );
1099 throw;
1100 }
1101 catch( const Exception& )
1102 {
1103 Any aError = ::cppu::getCaughtException();
1104
1105 // notify the failure
1106 if ( !bIsInitializationProcess )
1107 m_aEventNotifier.notifyDocumentEventAsync( _eType == SAVE ? "OnSaveFailed" : "OnSaveAsFailed", nullptr, Any( _rURL ) );
1108
1110 }
1111
1112 // notify the document event
1113 if ( !bIsInitializationProcess )
1114 m_aEventNotifier.notifyDocumentEventAsync( _eType == SAVE ? "OnSaveDone" : "OnSaveAsDone", nullptr, Any( _rURL ) );
1115
1116 // reset our "modified" flag, and clear the guard
1117 impl_setModified_nothrow( false, _rGuard );
1118 // <- SYNCHRONIZED
1119
1120 // notify storage listeners
1121 if ( xNewRootStorage.is() )
1122 impl_notifyStorageChange_nolck_nothrow( xNewRootStorage );
1123}
1124
1125Reference< XStorage > ODatabaseDocument::impl_createStorageFor_throw( const OUString& _rURL ) const
1126{
1127 Reference< ucb::XSimpleFileAccess3 > xTempAccess(ucb::SimpleFileAccess::create(m_pImpl->m_aContext));
1128 Reference< io::XStream > xStream = xTempAccess->openFileReadWrite( _rURL );
1129 Reference< io::XTruncate > xTruncate(xStream,UNO_QUERY);
1130 if ( xTruncate.is() )
1131 {
1132 xTruncate->truncate();
1133 }
1134 Sequence<Any> aParam{ Any(xStream), Any(ElementModes::READWRITE | ElementModes::TRUNCATE) };
1135
1136 Reference< XSingleServiceFactory > xStorageFactory( m_pImpl->createStorageFactory(), UNO_SET_THROW );
1137 return Reference< XStorage >( xStorageFactory->createInstanceWithArguments( aParam ), UNO_QUERY_THROW );
1138}
1139
1140css::uno::Reference<css::embed::XStorage> ODatabaseDocument::impl_GetStorageOrCreateFor_throw(
1141 const ::comphelper::NamedValueCollection& _rArguments, const OUString& _rURL) const
1142{
1143 // Try to get the storage from arguments, then create storage for target URL
1144 uno::Reference<embed::XStorage> xTargetStorage;
1145 _rArguments.get("TargetStorage") >>= xTargetStorage;
1146 if (!xTargetStorage.is())
1147 xTargetStorage = impl_createStorageFor_throw(_rURL);
1148
1149 // In case we got a StreamRelPath, then xTargetStorage should reference that sub-storage.
1150 OUString sStreamRelPath = _rArguments.getOrDefault("StreamRelPath", OUString());
1151 if (!sStreamRelPath.isEmpty())
1152 xTargetStorage
1153 = xTargetStorage->openStorageElement(sStreamRelPath, embed::ElementModes::READWRITE);
1154
1155 return xTargetStorage;
1156}
1157
1158void SAL_CALL ODatabaseDocument::storeAsURL( const OUString& _rURL, const Sequence< PropertyValue >& _rArguments )
1159{
1160 // SYNCHRONIZED ->
1162
1163 // Normally, a document initialization is done via XLoadable::load or XLoadable::initNew. For convenience
1164 // reasons, and to not break existing API clients, it's allowed to call storeAsURL without having initialized
1165 // the document, in which case the initialization will be done implicitly.
1166 bool bImplicitInitialization = !impl_isInitialized();
1167 // implicit initialization while another initialization is just running is not possible
1168 if ( bImplicitInitialization && impl_isInitializing() )
1169 throw RuntimeException();
1170
1171 if ( bImplicitInitialization )
1173
1174 try
1175 {
1176 impl_storeAs_throw( _rURL, _rArguments, SAVE_AS, aGuard );
1177 // <- SYNCHRONIZED
1178
1179 // impl_storeAs_throw cleared the lock on our mutex, but the below lines need this lock
1180 // SYNCHRONIZED ->
1181 aGuard.reset();
1182
1183 // our title might have changed, potentially at least
1184 // Sadly, we cannot check this: Calling getTitle here and now would not deliver
1185 // an up-to-date result, as the call is delegated to our TitleHelper instance, which itself
1186 // updates its title only if it gets the OnSaveAsDone event (which was sent asynchronously
1187 // by impl_storeAs_throw). So, we simply notify always, and also asynchronously
1188 m_aEventNotifier.notifyDocumentEventAsync( "OnTitleChanged" );
1189 }
1190 catch( const Exception& )
1191 {
1193 throw;
1194 }
1195
1196 if ( bImplicitInitialization )
1198
1199 aGuard.clear();
1200 // <- SYNCHRONIZED
1201
1202 if ( bImplicitInitialization )
1204}
1205
1206void ODatabaseDocument::impl_storeToStorage_throw( const Reference< XStorage >& _rxTargetStorage, const Sequence< PropertyValue >& _rMediaDescriptor,
1207 DocumentGuard& _rDocGuard ) const
1208{
1209 if ( !_rxTargetStorage.is() )
1210 throw IllegalArgumentException( OUString(), *const_cast< ODatabaseDocument* >( this ), 1 );
1211
1212 if ( !m_pImpl.is() )
1213 throw DisposedException( OUString(), *const_cast< ODatabaseDocument* >( this ) );
1214
1215 try
1216 {
1217 // commit everything
1218 m_pImpl->commitEmbeddedStorage();
1219 m_pImpl->commitStorages();
1220
1221 // copy own storage to target storage
1222 if ( impl_isInitialized() )
1223 {
1224 Reference< XStorage > xCurrentStorage = m_pImpl->getOrCreateRootStorage();
1225 // Root storage may be empty in case of embedding.
1226 if ( xCurrentStorage.is() && xCurrentStorage != _rxTargetStorage )
1227 xCurrentStorage->copyToStorage( _rxTargetStorage );
1228 }
1229
1230 // write into target storage
1231 ::comphelper::NamedValueCollection aWriteArgs( _rMediaDescriptor );
1232 lcl_triggerStatusIndicator_throw( aWriteArgs, _rDocGuard, true );
1233 impl_writeStorage_throw( _rxTargetStorage, aWriteArgs );
1234 lcl_triggerStatusIndicator_throw( aWriteArgs, _rDocGuard, false );
1235
1236 // commit target storage
1237 m_pImpl->commitStorageIfWriteable_ignoreErrors(_rxTargetStorage);
1238 }
1239 catch( const IOException& ) { throw; }
1240 catch( const RuntimeException& ) { throw; }
1241 catch ( const Exception& e )
1242 {
1243 throw IOException( e.Message, *const_cast< ODatabaseDocument* >( this ) );
1244 }
1245}
1246
1247void SAL_CALL ODatabaseDocument::storeToURL( const OUString& _rURL, const Sequence< PropertyValue >& _rArguments )
1248{
1250 ModifyLock aLock( *this );
1251
1252 {
1253 aGuard.clear();
1254 m_aEventNotifier.notifyDocumentEvent( "OnSaveTo", nullptr, Any( _rURL ) );
1255 aGuard.reset();
1256 }
1257
1258 try
1259 {
1260 const ::comphelper::NamedValueCollection aArguments(_rArguments);
1261 // create storage for target URL
1262 Reference<XStorage> xTargetStorage(impl_GetStorageOrCreateFor_throw(aArguments, _rURL));
1263
1264 // extend media descriptor with URL
1265 Sequence<PropertyValue> aMediaDescriptor(lcl_appendFileNameToDescriptor(aArguments, _rURL));
1266
1267 // store to this storage
1268 impl_storeToStorage_throw( xTargetStorage, aMediaDescriptor, aGuard );
1269 }
1270 catch( const Exception& )
1271 {
1272 Any aError = ::cppu::getCaughtException();
1273 m_aEventNotifier.notifyDocumentEventAsync( "OnSaveToFailed", nullptr, aError );
1274
1275 if ( aError.isExtractableTo( ::cppu::UnoType< IOException >::get() )
1276 || aError.isExtractableTo( ::cppu::UnoType< RuntimeException >::get() )
1277 )
1278 {
1279 // allowed to leave
1280 throw;
1281 }
1282
1284 }
1285
1286 m_aEventNotifier.notifyDocumentEventAsync( "OnSaveToDone", nullptr, Any( _rURL ) );
1287}
1288
1289// XModifyBroadcaster
1290void SAL_CALL ODatabaseDocument::addModifyListener( const Reference< XModifyListener >& _xListener )
1291{
1293 m_aModifyListeners.addInterface(_xListener);
1294}
1295
1296void SAL_CALL ODatabaseDocument::removeModifyListener( const Reference< XModifyListener >& _xListener )
1297{
1300}
1301
1302// XModifiable
1304{
1306
1307 return m_pImpl->m_bModified;
1308}
1309
1310void SAL_CALL ODatabaseDocument::setModified( sal_Bool _bModified )
1311{
1313 if ( impl_isInitialized() )
1314 impl_setModified_nothrow( _bModified, aGuard );
1315 // it's allowed to call setModified without the document being initialized already. In this case,
1316 // we simply ignore the call - when the initialization is finished, the respective code will set
1317 // a proper "modified" flag
1318}
1319
1321{
1322 // SYNCHRONIZED ->
1323 bool bModifiedChanged = ( m_pImpl->m_bModified != _bModified ) && ( !m_pImpl->isModifyLocked() );
1324
1325 if ( bModifiedChanged )
1326 {
1327 m_pImpl->m_bModified = _bModified;
1328 m_aEventNotifier.notifyDocumentEventAsync( "OnModifyChanged" );
1329 }
1330 _rGuard.clear();
1331 // <- SYNCHRONIZED
1332
1333 if ( bModifiedChanged )
1334 {
1335 lang::EventObject aEvent( *this );
1336 m_aModifyListeners.notifyEach( &XModifyListener::modified, aEvent );
1337 }
1338}
1339
1340// css::document::XEventBroadcaster
1341void SAL_CALL ODatabaseDocument::addEventListener(const uno::Reference< document::XEventListener >& Listener )
1342{
1344}
1345
1346void SAL_CALL ODatabaseDocument::removeEventListener( const uno::Reference< document::XEventListener >& Listener )
1347{
1349}
1350
1351void SAL_CALL ODatabaseDocument::addDocumentEventListener( const Reference< XDocumentEventListener >& Listener )
1352{
1354}
1355
1356void SAL_CALL ODatabaseDocument::removeDocumentEventListener( const Reference< XDocumentEventListener >& Listener )
1357{
1359}
1360
1361void SAL_CALL ODatabaseDocument::notifyDocumentEvent( const OUString& EventName, const Reference< XController2 >& ViewController, const Any& Supplement )
1362{
1363 if ( EventName.isEmpty() )
1364 throw IllegalArgumentException( OUString(), *this, 1 );
1365
1366 // SYNCHRONIZED ->
1368
1370 {
1371 m_aEventNotifier.notifyDocumentEventAsync( EventName, ViewController, Supplement );
1372 return;
1373 }
1374 aGuard.clear();
1375 // <- SYNCHRONIZED
1376
1377 m_aEventNotifier.notifyDocumentEvent( EventName, ViewController, Supplement );
1378}
1379
1380Sequence< PropertyValue > SAL_CALL ODatabaseDocument::getPrinter( )
1381{
1382 OSL_FAIL( "ODatabaseDocument::getPrinter: not supported!" );
1383 return Sequence< PropertyValue >();
1384}
1385
1386void SAL_CALL ODatabaseDocument::setPrinter( const Sequence< PropertyValue >& /*aPrinter*/ )
1387{
1388 OSL_FAIL( "ODatabaseDocument::setPrinter: not supported!" );
1389}
1390
1391void SAL_CALL ODatabaseDocument::print( const Sequence< PropertyValue >& /*xOptions*/ )
1392{
1393 OSL_FAIL( "ODatabaseDocument::print: not supported!" );
1394}
1395
1396void ODatabaseDocument::impl_reparent_nothrow( const WeakReference< XNameAccess >& _rxContainer )
1397{
1398 Reference< XChild > xChild( _rxContainer.get(), UNO_QUERY );
1399 if ( xChild.is() )
1400 xChild->setParent( *this );
1401}
1402
1403void ODatabaseDocument::clearObjectContainer( WeakReference< XNameAccess >& _rxContainer)
1404{
1405 Reference< XNameAccess > xContainer = _rxContainer;
1406 ::comphelper::disposeComponent( xContainer );
1407
1408 Reference< XChild > xChild( _rxContainer.get(),UNO_QUERY );
1409 if ( xChild.is() )
1410 xChild->setParent( nullptr );
1411 _rxContainer.clear();
1412}
1413
1415{
1417 throw IllegalArgumentException();
1418
1419 bool bFormsContainer = _eType == ODatabaseModelImpl::ObjectType::Form;
1420
1421 WeakReference< XNameAccess >& rContainerRef( bFormsContainer ? m_xForms : m_xReports );
1422 Reference< XNameAccess > xContainer = rContainerRef;
1423 if ( !xContainer.is() )
1424 {
1425 Any aValue;
1426 css::uno::Reference< css::uno::XInterface > xMy(*this);
1427 if ( dbtools::getDataSourceSetting(xMy,bFormsContainer ? "Forms" : "Reports",aValue) )
1428 {
1429 OUString sSupportService;
1430 aValue >>= sSupportService;
1431 if ( !sSupportService.isEmpty() )
1432 {
1433 Sequence<Any> aArgs{ Any(NamedValue("DatabaseDocument",Any(xMy))) };
1434 xContainer.set(
1435 m_pImpl->m_aContext->getServiceManager()->createInstanceWithArgumentsAndContext(sSupportService, aArgs, m_pImpl->m_aContext),
1436 UNO_QUERY);
1437 rContainerRef = xContainer;
1438 }
1439 }
1440 if ( !xContainer.is() )
1441 {
1442 TContentPtr& rContainerData( m_pImpl->getObjectContainer( _eType ) );
1443 rContainerRef = xContainer = new ODocumentContainer( m_pImpl->m_aContext, *this, rContainerData, bFormsContainer );
1444 }
1445 impl_reparent_nothrow( xContainer );
1446 }
1447 return xContainer;
1448}
1449
1451{
1453
1454 for (auto const& elem : aCopy)
1455 {
1456 if ( !elem.is() )
1457 continue;
1458
1459 try
1460 {
1461 Reference< XCloseable> xFrame( elem->getFrame(), UNO_QUERY );
1462 if ( xFrame.is() )
1463 xFrame->close( _bDeliverOwnership );
1464 }
1465 catch( const CloseVetoException& ) { throw; }
1466 catch( const Exception& )
1467 {
1468 DBG_UNHANDLED_EXCEPTION("dbaccess");
1469 }
1470 }
1471}
1472
1474{
1475 Controllers aCopy;
1476 aCopy.swap( m_aControllers ); // ensure m_aControllers is empty afterwards
1477 for( const auto& rController : aCopy )
1478 {
1479 try
1480 {
1481 if( rController.is() )
1482 {
1483 Reference< XFrame > xFrame( rController->getFrame() );
1484 ::comphelper::disposeComponent( xFrame );
1485 }
1486 }
1487 catch( const Exception& )
1488 {
1489 DBG_UNHANDLED_EXCEPTION("dbaccess");
1490 }
1491 }
1492}
1493
1494void SAL_CALL ODatabaseDocument::close(sal_Bool bDeliverOwnership)
1495{
1496 // nearly everything below can/must be done without our mutex locked, the below is just for
1497 // the checks for being disposed and the like
1498 // SYNCHRONIZED ->
1499 {
1501 assert (!m_bClosing);
1502 m_bClosing = true;
1503 }
1504 // <- SYNCHRONIZED
1505
1506 try
1507 {
1508 // allow listeners to veto
1509 lang::EventObject aEvent( *this );
1511 [&aEvent, &bDeliverOwnership] (uno::Reference<XCloseListener> const& xListener) {
1512 return xListener->queryClosing(aEvent, bDeliverOwnership);
1513 });
1514
1515 // notify that we're going to unload
1516 m_aEventNotifier.notifyDocumentEvent( "OnPrepareUnload" );
1517
1518 impl_closeControllerFrames_nolck_throw( bDeliverOwnership );
1519
1520 m_aCloseListener.notifyEach( &XCloseListener::notifyClosing, const_cast<const lang::EventObject&>(aEvent) );
1521
1522 dispose();
1523 }
1524 catch ( const Exception& )
1525 {
1527 m_bClosing = false;
1528 throw;
1529 }
1530
1531 // SYNCHRONIZED ->
1533 m_bClosing = false;
1534 // <- SYNCHRONIZED
1535}
1536
1537void SAL_CALL ODatabaseDocument::addCloseListener( const Reference< css::util::XCloseListener >& Listener )
1538{
1541}
1542
1543void SAL_CALL ODatabaseDocument::removeCloseListener( const Reference< css::util::XCloseListener >& Listener )
1544{
1547}
1548
1549Reference< XNameAccess > SAL_CALL ODatabaseDocument::getFormDocuments( )
1550{
1553}
1554
1555Reference< XNameAccess > SAL_CALL ODatabaseDocument::getReportDocuments( )
1556{
1559}
1560
1561void ODatabaseDocument::WriteThroughComponent( const Reference< XComponent >& xComponent, const char* pStreamName,
1562 const char* pServiceName, const Sequence< Any >& _rArguments, const Sequence< PropertyValue >& rMediaDesc,
1563 const Reference<XStorage>& _xStorageToSaveTo ) const
1564{
1565 OSL_ENSURE( pStreamName, "Need stream name!" );
1566 OSL_ENSURE( pServiceName, "Need service name!" );
1567
1568 // open stream
1569 OUString sStreamName = OUString::createFromAscii( pStreamName );
1570 Reference< XStream > xStream = _xStorageToSaveTo->openStreamElement( sStreamName, ElementModes::READWRITE | ElementModes::TRUNCATE );
1571 if ( !xStream.is() )
1572 return;
1573
1574 Reference< XOutputStream > xOutputStream( xStream->getOutputStream() );
1575 OSL_ENSURE( xOutputStream.is(), "Can't create output stream in package!" );
1576 if ( !xOutputStream.is() )
1577 return;
1578
1579 Reference< XSeekable > xSeek( xOutputStream, UNO_QUERY );
1580 if ( xSeek.is() )
1581 xSeek->seek(0);
1582
1583 Reference< XPropertySet > xStreamProp( xOutputStream, UNO_QUERY_THROW );
1584 xStreamProp->setPropertyValue( INFO_MEDIATYPE, Any( OUString( "text/xml" ) ) );
1585 xStreamProp->setPropertyValue( "Compressed", Any( true ) );
1586
1587 // write the stuff
1588 WriteThroughComponent( xOutputStream, xComponent, pServiceName, _rArguments, rMediaDesc );
1589}
1590
1591void ODatabaseDocument::WriteThroughComponent( const Reference< XOutputStream >& xOutputStream,
1592 const Reference< XComponent >& xComponent, const char* pServiceName, const Sequence< Any >& _rArguments,
1593 const Sequence< PropertyValue >& rMediaDesc ) const
1594{
1595 OSL_ENSURE( xOutputStream.is(), "I really need an output stream!" );
1596 OSL_ENSURE( xComponent.is(), "Need component!" );
1597 OSL_ENSURE( nullptr != pServiceName, "Need component name!" );
1598
1599 // get component
1600 Reference< XWriter > xSaxWriter = xml::sax::Writer::create( m_pImpl->m_aContext );
1601
1602 // connect XML writer to output stream
1603 xSaxWriter->setOutputStream( xOutputStream );
1604
1605 // prepare arguments (prepend doc handler to given arguments)
1606 Sequence<Any> aArgs( 1 + _rArguments.getLength() );
1607 auto pArgs = aArgs.getArray();
1608 pArgs[0] <<= xSaxWriter;
1609 for ( sal_Int32 i = 0; i < _rArguments.getLength(); ++i )
1610 pArgs[ i+1 ] = _rArguments[i];
1611
1612 // get filter component
1613 Reference< XExporter > xExporter( m_pImpl->m_aContext->getServiceManager()->createInstanceWithArgumentsAndContext(OUString::createFromAscii(pServiceName), aArgs, m_pImpl->m_aContext), UNO_QUERY_THROW );
1614
1615 // connect model and filter
1616 xExporter->setSourceDocument( xComponent );
1617
1618 // filter
1619 Reference< XFilter > xFilter( xExporter, UNO_QUERY_THROW );
1620 xFilter->filter( rMediaDesc );
1621}
1622
1623void ODatabaseDocument::impl_writeStorage_throw( const Reference< XStorage >& _rxTargetStorage, const ::comphelper::NamedValueCollection& _rMediaDescriptor ) const
1624{
1625 // extract status indicator
1626 Sequence< Any > aDelegatorArguments;
1627 lcl_extractStatusIndicator( _rMediaDescriptor, aDelegatorArguments );
1628
1629 uno::Reference< beans::XPropertySet > xInfoSet( comphelper::GenericPropertySet_CreateInstance( new comphelper::PropertySetInfo( aExportInfoMap ) ) );
1630
1631 xInfoSet->setPropertyValue("UsePrettyPrinting", uno::Any(officecfg::Office::Common::Save::Document::PrettyPrinting::get()));
1632 if ( officecfg::Office::Common::Save::URL::FileSystem::get() )
1633 {
1634 OUString sBaseURI = _rMediaDescriptor.getOrDefault("BaseURI", OUString());
1635 if (sBaseURI.isEmpty())
1636 sBaseURI = _rMediaDescriptor.getOrDefault("URL",OUString());
1637 xInfoSet->setPropertyValue("BaseURI", uno::Any(sBaseURI));
1638 }
1639
1640 // Set TargetStorage, so it doesn't have to be re-constructed based on possibly empty URL.
1641 xInfoSet->setPropertyValue("TargetStorage", uno::Any(m_pImpl->getRootStorage()));
1642
1643 // Set StreamRelPath, in case this document is an embedded one.
1644 OUString sStreamRelPath;
1645 OUString sURL = _rMediaDescriptor.getOrDefault("URL", OUString());
1646 if (sURL.startsWithIgnoreAsciiCase("vnd.sun.star.pkg:"))
1647 {
1648 // In this case the host contains the real path, and the path is the embedded stream name.
1649 INetURLObject aURL(sURL);
1650 sStreamRelPath = aURL.GetURLPath(INetURLObject::DecodeMechanism::WithCharset);
1651 if (sStreamRelPath.startsWith("/"))
1652 sStreamRelPath = sStreamRelPath.copy(1);
1653 }
1654 if (!sStreamRelPath.isEmpty())
1655 xInfoSet->setPropertyValue("StreamRelPath", uno::Any(sStreamRelPath));
1656
1657 sal_Int32 nArgsLen = aDelegatorArguments.getLength();
1658 aDelegatorArguments.realloc(nArgsLen+1);
1659 aDelegatorArguments.getArray()[nArgsLen++] <<= xInfoSet;
1660
1661 Reference< XPropertySet > xProp( _rxTargetStorage, UNO_QUERY_THROW );
1662 xProp->setPropertyValue( INFO_MEDIATYPE, Any( OUString(MIMETYPE_OASIS_OPENDOCUMENT_DATABASE_ASCII) ) );
1663
1664 OUString aVersion;
1665 SvtSaveOptions::ODFSaneDefaultVersion const nDefVersion =
1667 // older versions can not have this property set,
1668 // it exists only starting from ODF1.2
1669 if (nDefVersion >= SvtSaveOptions::ODFSVER_013)
1670 {
1671 aVersion = ODFVER_013_TEXT;
1672 }
1673 else if (nDefVersion >= SvtSaveOptions::ODFSVER_012)
1674 {
1675 aVersion = ODFVER_012_TEXT;
1676 }
1677
1678 if (!aVersion.isEmpty())
1679 {
1680 try
1681 {
1682 xProp->setPropertyValue("Version" , uno::Any(aVersion));
1683 }
1684 catch (const uno::Exception&)
1685 {
1686 TOOLS_WARN_EXCEPTION("dbaccess", "exception setting Version");
1687 }
1688 }
1689
1690 Reference< XComponent > xComponent( *const_cast< ODatabaseDocument* >( this ), UNO_QUERY_THROW );
1691
1692 Sequence< PropertyValue > aMediaDescriptor;
1693 _rMediaDescriptor >>= aMediaDescriptor;
1694
1695 xInfoSet->setPropertyValue("StreamName", uno::Any(OUString("settings.xml")));
1696 WriteThroughComponent( xComponent, "settings.xml", "com.sun.star.comp.sdb.XMLSettingsExporter",
1697 aDelegatorArguments, aMediaDescriptor, _rxTargetStorage );
1698
1699 xInfoSet->setPropertyValue("StreamName", uno::Any(OUString("content.xml")));
1700 WriteThroughComponent( xComponent, "content.xml", "com.sun.star.comp.sdb.DBExportFilter",
1701 aDelegatorArguments, aMediaDescriptor, _rxTargetStorage );
1702
1703 if ( _rxTargetStorage->hasByName ( sPictures ) )
1704 {
1705 try
1706 {
1707 // Delete any previously existing Pictures folder and regenerate
1708 // any needed content if needed
1709 Reference< XStorageBasedLibraryContainer > xDlgs = m_pImpl->getLibraryContainer( false );
1710 if ( xDlgs.is() )
1711 {
1712 Reference< XModel > xModel(const_cast< ODatabaseDocument*>(this));
1713 lcl_uglyHackToStoreDialogeEmbedImages( m_pImpl->getLibraryContainer(false), _rxTargetStorage, xModel, m_pImpl->m_aContext );
1714 }
1715 }
1716 catch ( const Exception& )
1717 {
1718 DBG_UNHANDLED_EXCEPTION("dbaccess");
1719 }
1720 }
1721 m_pImpl->storeLibraryContainersTo( _rxTargetStorage );
1722}
1723
1724Reference< XUIConfigurationManager > SAL_CALL ODatabaseDocument::getUIConfigurationManager( )
1725{
1726 return Reference< XUIConfigurationManager >( getUIConfigurationManager2(), UNO_QUERY_THROW );
1727}
1728
1729Reference< XUIConfigurationManager2 > const & ODatabaseDocument::getUIConfigurationManager2( )
1730{
1732
1733 if ( !m_xUIConfigurationManager.is() )
1734 {
1735 m_xUIConfigurationManager = UIConfigurationManager::create( m_pImpl->m_aContext );
1736
1737 OUString aUIConfigFolderName( "Configurations2" );
1738
1739 // First try to open with READWRITE and then READ
1740 Reference< XStorage > xConfigStorage = getDocumentSubStorage( aUIConfigFolderName, ElementModes::READWRITE );
1741 if ( xConfigStorage.is() )
1742 {
1743 OUString aMediaType;
1744 Reference< XPropertySet > xPropSet( xConfigStorage, UNO_QUERY );
1745 Any a = xPropSet->getPropertyValue( INFO_MEDIATYPE );
1746 if ( !( a >>= aMediaType ) || aMediaType.isEmpty() )
1747 {
1748 a <<= OUString("application/vnd.sun.xml.ui.configuration");
1749 xPropSet->setPropertyValue( INFO_MEDIATYPE, a );
1750 }
1751 }
1752 else
1753 xConfigStorage = getDocumentSubStorage( aUIConfigFolderName, ElementModes::READ );
1754
1755 // initialize ui configuration manager with document substorage
1756 m_xUIConfigurationManager->setStorage( xConfigStorage );
1757 }
1758
1760}
1761
1762Reference< XStorage > SAL_CALL ODatabaseDocument::getDocumentSubStorage( const OUString& aStorageName, sal_Int32 nMode )
1763{
1765
1766 Reference< XDocumentSubStorageSupplier > xStorageAccess( m_pImpl->getDocumentSubStorageSupplier() );
1767 return xStorageAccess->getDocumentSubStorage( aStorageName, nMode );
1768}
1769
1771{
1772 Reference< XDocumentSubStorageSupplier > xStorageAccess( m_pImpl->getDocumentSubStorageSupplier() );
1773 return xStorageAccess->getDocumentSubStoragesNames();
1774}
1775
1776void ODatabaseDocument::impl_notifyStorageChange_nolck_nothrow( const Reference< XStorage >& xNewRootStorage )
1777{
1778 Reference< XInterface > xMe( *this );
1779
1781 [&xMe, &xNewRootStorage] (uno::Reference<XStorageChangeListener> const& xListener) {
1782 return xListener->notifyStorageChange(xMe, xNewRootStorage);
1783 });
1784}
1785
1787{
1788 if ( !m_pImpl.is() )
1789 {
1790 // this means that we're already disposed
1791 OSL_ENSURE( ODatabaseDocument_OfficeDocument::rBHelper.bDisposed, "ODatabaseDocument::disposing: no impl anymore, but not yet disposed!" );
1792 return;
1793 }
1794
1795 if ( impl_isInitialized() )
1797
1798 Reference< XModel > xHoldAlive( this );
1799
1801
1802 lang::EventObject aDisposeEvent(static_cast<XWeak*>(this));
1803 m_aModifyListeners.disposeAndClear( aDisposeEvent );
1804 m_aCloseListener.disposeAndClear( aDisposeEvent );
1805 m_aStorageListeners.disposeAndClear( aDisposeEvent );
1806
1807 // this is the list of objects which we currently hold as member. Upon resetting
1808 // those members, we can (potentially) release the last reference to them, in which
1809 // case they will be deleted - if they're C++ implementations, that is :).
1810 // Some of those implementations are offending enough to require the SolarMutex, which
1811 // means we should not release the last reference while our own mutex is locked ...
1812 std::vector< Reference< XInterface > > aKeepAlive;
1813
1814 // SYNCHRONIZED ->
1815 {
1816 SolarMutexGuard aGuard;
1817
1818 OSL_ENSURE(m_aControllers.empty(),
1819 "ODatabaseDocument::disposing: there still are controllers!");
1820 // normally, nobody should explicitly dispose, but only XCloseable::close
1821 // the document. And upon closing, our controllers are closed, too
1822
1823 {
1824 uno::Reference<uno::XInterface> xUIInterface(m_xUIConfigurationManager);
1825 aKeepAlive.push_back(xUIInterface);
1826 }
1827 m_xUIConfigurationManager = nullptr;
1828
1831
1832 // reset the macro mode: in case the our impl struct stays alive (e.g. because our DataSource
1833 // object still exists), and somebody subsequently re-opens the document, we want to have
1834 // the security warning, again.
1835 m_pImpl->resetMacroExecutionMode();
1836
1837 // similar arguing for our ViewMonitor
1839
1840 // tell our Impl to forget us
1842
1843 // now, at the latest, the controller array should be empty. Controllers are
1844 // expected to listen for our disposal, and disconnect then
1845 OSL_ENSURE(m_aControllers.empty(),
1846 "ODatabaseDocument::disposing: there still are controllers!");
1848
1849 {
1850 uno::Reference<uno::XInterface> xModuleInterface(m_xModuleManager);
1851 aKeepAlive.push_back(xModuleInterface);
1852 }
1853 m_xModuleManager.clear();
1854
1855 {
1856 uno::Reference<uno::XInterface> xTitleInterface(m_xTitleHelper);
1857 aKeepAlive.push_back(xTitleInterface);
1858 }
1859 m_xTitleHelper.clear();
1860
1861 m_pImpl.clear();
1862 }
1863 // <- SYNCHRONIZED
1864
1865 aKeepAlive.clear();
1866}
1867
1868// XComponent
1870{
1871 ::cppu::WeakComponentImplHelperBase::dispose();
1872}
1873
1874void SAL_CALL ODatabaseDocument::addEventListener( const Reference< lang::XEventListener >& _xListener )
1875{
1876 ::cppu::WeakComponentImplHelperBase::addEventListener( _xListener );
1877}
1878
1879void SAL_CALL ODatabaseDocument::removeEventListener( const Reference< lang::XEventListener >& _xListener )
1880{
1881 ::cppu::WeakComponentImplHelperBase::removeEventListener( _xListener );
1882}
1883
1884// XServiceInfo
1886{
1887 return "com.sun.star.comp.dba.ODatabaseDocument";
1888}
1889
1891{
1892 return { "com.sun.star.sdb.OfficeDatabaseDocument", "com.sun.star.document.OfficeDocument" };
1893}
1894
1895sal_Bool ODatabaseDocument::supportsService( const OUString& _rServiceName )
1896{
1897 return cppu::supportsService(this, _rServiceName);
1898}
1899
1900Reference< XDataSource > SAL_CALL ODatabaseDocument::getDataSource()
1901{
1903 return m_pImpl->getOrCreateDataSource();
1904}
1905
1906namespace
1907{
1909comphelper::PropertyMapEntry const aEmbeddedImportInfoMap[] =
1910{
1911 {OUString("StreamRelPath"), 0, cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0},
1912 {OUString("StreamName"), 0, cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0},
1913 {OUString("SourceStorage"), 0, cppu::UnoType<embed::XStorage>::get(), beans::PropertyAttribute::MAYBEVOID, 0},
1914};
1915}
1916
1917void SAL_CALL ODatabaseDocument::loadFromStorage(const Reference<XStorage>& xStorage, const Sequence<PropertyValue>& rMediaDescriptor)
1918{
1920
1921 uno::Reference<beans::XPropertySet> xInfoSet(comphelper::GenericPropertySet_CreateInstance(new comphelper::PropertySetInfo(aEmbeddedImportInfoMap)));
1922 xInfoSet->setPropertyValue("StreamRelPath", uno::Any(comphelper::NamedValueCollection::getOrDefault(rMediaDescriptor, u"HierarchicalDocumentName", OUString())));
1923 xInfoSet->setPropertyValue("StreamName", uno::Any(OUString("content.xml")));
1924 xInfoSet->setPropertyValue("SourceStorage", uno::Any(xStorage));
1925
1926 uno::Sequence<uno::Any> aFilterCreationArgs{ Any(xInfoSet) };
1927
1928 uno::Reference<document::XImporter> xImporter(m_pImpl->m_aContext->getServiceManager()->createInstanceWithArgumentsAndContext("com.sun.star.comp.sdb.DBFilter", aFilterCreationArgs, m_pImpl->m_aContext), uno::UNO_QUERY_THROW);
1929
1930 uno::Reference<lang::XComponent> xComponent(*this, uno::UNO_QUERY_THROW);
1931 xImporter->setTargetDocument(xComponent);
1932
1933 uno::Reference<document::XFilter> xFilter(xImporter, uno::UNO_QUERY_THROW);
1934 uno::Sequence<beans::PropertyValue> aFilterArgs;
1935 xFilter->filter(aFilterArgs);
1936
1937 // In case of embedding, XModel::attachResource is already called.
1938 if (m_bEmbedded)
1940
1941 impl_setModified_nothrow(false, aGuard);
1942}
1943
1944void SAL_CALL ODatabaseDocument::storeToStorage( const Reference< XStorage >& _rxStorage, const Sequence< PropertyValue >& _rMediaDescriptor )
1945{
1947 impl_storeToStorage_throw( _rxStorage, _rMediaDescriptor, aGuard );
1948}
1949
1950void SAL_CALL ODatabaseDocument::switchToStorage( const Reference< XStorage >& _rxNewRootStorage )
1951{
1953
1954 Reference< XStorage > xNewRootStorage( m_pImpl->switchToStorage( _rxNewRootStorage ) );
1955
1956 aGuard.clear();
1957 impl_notifyStorageChange_nolck_nothrow( xNewRootStorage );
1958}
1959
1960Reference< XStorage > SAL_CALL ODatabaseDocument::getDocumentStorage( )
1961{
1963 return m_pImpl->getOrCreateRootStorage();
1964}
1965
1966void SAL_CALL ODatabaseDocument::addStorageChangeListener( const Reference< XStorageChangeListener >& Listener )
1967{
1970}
1971
1972void SAL_CALL ODatabaseDocument::removeStorageChangeListener( const Reference< XStorageChangeListener >& Listener )
1973{
1976}
1977
1978Reference< XStorageBasedLibraryContainer > SAL_CALL ODatabaseDocument::getBasicLibraries()
1979{
1981 return m_pImpl->getLibraryContainer( true );
1982}
1983
1984Reference< XStorageBasedLibraryContainer > SAL_CALL ODatabaseDocument::getDialogLibraries()
1985{
1987 return m_pImpl->getLibraryContainer( false );
1988}
1989
1991{
1993 return m_pImpl->adjustMacroMode_AutoReject();
1994}
1995
1996Reference< XEmbeddedScripts > SAL_CALL ODatabaseDocument::getScriptContainer()
1997{
1998 return this;
1999}
2000
2001Reference< provider::XScriptProvider > SAL_CALL ODatabaseDocument::getScriptProvider( )
2002{
2004
2005 Reference< XScriptProvider > xScriptProvider( m_xScriptProvider );
2006 if ( !xScriptProvider.is() )
2007 {
2008 Reference < XScriptProviderFactory > xFactory =
2009 theMasterScriptProviderFactory::get( m_pImpl->m_aContext );
2010
2011 Any aScriptProviderContext;
2013 aScriptProviderContext <<= Reference< XModel >( this );
2014
2015 xScriptProvider.set( xFactory->createScriptProvider( aScriptProviderContext ), UNO_SET_THROW );
2016 m_xScriptProvider = xScriptProvider;
2017 }
2018
2019 return xScriptProvider;
2020}
2021
2022Reference< XNameReplace > SAL_CALL ODatabaseDocument::getEvents( )
2023{
2025 return m_pEventContainer.get();
2026}
2027
2028Reference< XInterface > ODatabaseDocument::getThis() const
2029{
2030 return *const_cast< ODatabaseDocument* >( this );
2031}
2032
2033namespace {
2034
2035struct CreateAny
2036{
2037 Any operator() (const Reference<XController>& lhs) const
2038 {
2039 return Any(lhs);
2040 }
2041};
2042
2043}
2044
2045// XModel2
2046Reference< XEnumeration > SAL_CALL ODatabaseDocument::getControllers( )
2047{
2049 uno::Sequence< Any> aController( m_aControllers.size() );
2050 std::transform( m_aControllers.begin(), m_aControllers.end(), aController.getArray(), CreateAny() );
2051 return new ::comphelper::OAnyEnumeration(aController);
2052}
2053
2055{
2056 Sequence< OUString > aNames { SERVICE_SDB_APPLICATIONCONTROLLER };
2057 return aNames;
2058}
2059
2060Reference< XController2 > SAL_CALL ODatabaseDocument::createDefaultViewController( const Reference< XFrame >& Frame )
2061{
2062 return createViewController( "Default", Sequence< PropertyValue >(), Frame);
2063}
2064
2065Reference< XController2 > SAL_CALL ODatabaseDocument::createViewController( const OUString& ViewName, const Sequence< PropertyValue >& Arguments, const Reference< XFrame >& Frame )
2066{
2067 if ( ViewName != "Default" && ViewName != "Preview" )
2068 throw IllegalArgumentException( OUString(), *this, 1 );
2069 if ( !Frame.is() )
2070 throw IllegalArgumentException( OUString(), *this, 3 );
2071
2073 aGuard.clear();
2074
2075 Reference< XController2 > xController(
2076 m_pImpl->m_aContext->getServiceManager()->createInstanceWithContext("org.openoffice.comp.dbu.OApplicationController", m_pImpl->m_aContext),
2077 UNO_QUERY_THROW );
2078
2079 ::comphelper::NamedValueCollection aInitArgs( Arguments );
2080 aInitArgs.put( "Frame", Frame );
2081 if ( ViewName == "Preview" )
2082 aInitArgs.put( "Preview", true );
2083 Reference< XInitialization > xInitController( xController, UNO_QUERY_THROW );
2084 xInitController->initialize( aInitArgs.getWrappedPropertyValues() );
2085
2086 return xController;
2087}
2088
2090{
2091 if ( ! m_xTitleHelper.is ())
2092 {
2093 Reference< XUntitledNumbers > xDesktop(Desktop::create(m_pImpl->m_aContext), uno::UNO_QUERY_THROW);
2094 Reference< frame::XModel > xThis (getThis(), uno::UNO_QUERY_THROW);
2095
2096 m_xTitleHelper = new ::framework::TitleHelper(m_pImpl->m_aContext, xThis, xDesktop);
2097 }
2098
2099 return m_xTitleHelper;
2100}
2101
2102uno::Reference< frame::XUntitledNumbers > ODatabaseDocument::impl_getUntitledHelper_throw(const uno::Reference< uno::XInterface >& _xComponent)
2103{
2104 if ( !m_xModuleManager.is() )
2105 m_xModuleManager.set( ModuleManager::create(m_pImpl->m_aContext) );
2106
2107 OUString sModuleId;
2108 if (_xComponent.is())
2109 sModuleId = m_xModuleManager->identify(_xComponent);
2110
2111 uno::Reference< frame::XUntitledNumbers > xNumberedControllers;
2112
2113 TNumberedController::const_iterator aFind = m_aNumberedControllers.find(sModuleId);
2114 if ( aFind == m_aNumberedControllers.end() )
2115 {
2116 rtl::Reference<::comphelper::NumberedCollection> pHelper = new ::comphelper::NumberedCollection();
2117 xNumberedControllers = pHelper;
2118 pHelper->setOwner(uno::Reference< frame::XModel >(this));
2119
2120 m_aNumberedControllers.emplace( sModuleId,xNumberedControllers );
2121 }
2122 else
2123 xNumberedControllers = aFind->second;
2124
2125 return xNumberedControllers;
2126}
2127
2128// css.frame.XTitle
2130{
2131 // SYNCHRONIZED ->
2133 return impl_getTitleHelper_throw()->getTitle();
2134}
2135
2136// css.frame.XTitle
2137void SAL_CALL ODatabaseDocument::setTitle( const OUString& sTitle )
2138{
2139 // SYNCHRONIZED ->
2141 impl_getTitleHelper_throw()->setTitle( sTitle );
2142 m_aEventNotifier.notifyDocumentEventAsync( "OnTitleChanged" );
2143 // <- SYNCHRONIZED
2144}
2145
2146// css.frame.XTitleChangeBroadcaster
2147void SAL_CALL ODatabaseDocument::addTitleChangeListener( const uno::Reference< frame::XTitleChangeListener >& xListener )
2148{
2149 // SYNCHRONIZED ->
2151
2152 uno::Reference< frame::XTitleChangeBroadcaster > xBroadcaster( impl_getTitleHelper_throw(), uno::UNO_QUERY_THROW );
2153 xBroadcaster->addTitleChangeListener( xListener );
2154}
2155
2156// css.frame.XTitleChangeBroadcaster
2157void SAL_CALL ODatabaseDocument::removeTitleChangeListener( const uno::Reference< frame::XTitleChangeListener >& xListener )
2158{
2159 // SYNCHRONIZED ->
2161
2162 uno::Reference< frame::XTitleChangeBroadcaster > xBroadcaster( impl_getTitleHelper_throw(), uno::UNO_QUERY_THROW );
2163 xBroadcaster->removeTitleChangeListener( xListener );
2164}
2165
2166// css.frame.XUntitledNumbers
2167::sal_Int32 SAL_CALL ODatabaseDocument::leaseNumber( const uno::Reference< uno::XInterface >& xComponent )
2168{
2170 return impl_getUntitledHelper_throw(xComponent)->leaseNumber (xComponent);
2171}
2172
2173// css.frame.XUntitledNumbers
2174void SAL_CALL ODatabaseDocument::releaseNumber( ::sal_Int32 nNumber )
2175{
2177 impl_getUntitledHelper_throw()->releaseNumber (nNumber);
2178}
2179
2180// css.frame.XUntitledNumbers
2181void SAL_CALL ODatabaseDocument::releaseNumberForComponent( const uno::Reference< uno::XInterface >& xComponent )
2182{
2184 impl_getUntitledHelper_throw(xComponent)->releaseNumberForComponent (xComponent);
2185}
2186
2187// css.frame.XUntitledNumbers
2189{
2190 return OUString();
2191}
2192
2193} // namespace dbaccess
2194
2195extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
2196com_sun_star_comp_dba_ODatabaseDocument(css::uno::XComponentContext* context,
2197 css::uno::Sequence<css::uno::Any> const &)
2198{
2199 Reference<XInterface> xDBContextTunnel(DatabaseContext::create(context), UNO_QUERY_THROW);
2201 = dynamic_cast<dbaccess::ODatabaseContext*>(xDBContextTunnel.get());
2202 assert(pContext);
2203
2204 rtl::Reference pImpl(
2205 new dbaccess::ODatabaseModelImpl(context, *pContext));
2206 css::uno::Reference<XInterface> inst(pImpl->createNewModel_deliverOwnership());
2207 inst->acquire();
2208 return inst.get();
2209}
2210
2211/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
XPropertyListType t
Reference< XInputStream > xStream
AnyEventRef aEvent
css::uno::Sequence< css::uno::Any > getWrappedPropertyValues() const
bool has(const OUString &_rValueName) const
const css::uno::Any & get(const OUString &_rValueName) const
bool remove(const OUString &_rValueName)
bool put(const OUString &_rValueName, const VALUE_TYPE &_rValue)
css::uno::Sequence< css::beans::PropertyValue > getPropertyValues() const
VALUE_TYPE getOrDefault(const OUString &_rValueName, const VALUE_TYPE &_rDefault) const
sal_Int32 addInterface(const css::uno::Reference< ListenerT > &rxIFace)
void disposeAndClear(const css::lang::EventObject &rEvt)
sal_Int32 removeInterface(const css::uno::Reference< ListenerT > &rxIFace)
void notifyEach(void(SAL_CALL ListenerT::*NotificationMethod)(const EventT &), const EventT &Event)
static css::uno::Reference< css::embed::XStorage > GetTemporaryStorage(const css::uno::Reference< css::uno::XComponentContext > &rxContext=css::uno::Reference< css::uno::XComponentContext >())
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() SAL_OVERRIDE
virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const &rType) SAL_OVERRIDE
css::uno::Type const & get()
void recoverSubDocuments(const css::uno::Reference< css::embed::XStorage > &i_rDocumentStorage, const css::uno::Reference< css::frame::XController > &i_rTargetController)
recovery sub components from the given document storage, if applicable
void saveModifiedSubComponents(const css::uno::Reference< css::embed::XStorage > &i_rTargetStorage, const std::vector< css::uno::Reference< css::frame::XController > > &i_rControllers)
saves the modified sub components of the given controller(s) to the "recovery" sub storage of the doc...
void addDocumentEventListener(const css::uno::Reference< css::document::XDocumentEventListener > &Listener)
void onDocumentInitialized()
tells the instance that its document is completely initialized now.
void disposing()
disposes the instance @precond the mutex is not locked
void addLegacyEventListener(const css::uno::Reference< css::document::XEventListener > &Listener)
void notifyDocumentEvent(const OUString &EventName, const css::uno::Reference< css::frame::XController2 > &_rxViewController, const css::uno::Any &Supplement)
notifies a document event described by the given parameters
void removeDocumentEventListener(const css::uno::Reference< css::document::XDocumentEventListener > &Listener)
void notifyDocumentEventAsync(const OUString &EventName, const css::uno::Reference< css::frame::XController2 > &ViewController, const css::uno::Any &Supplement)
notifies a document event, described by the given parameters, asynchronously
void removeLegacyEventListener(const css::uno::Reference< css::document::XEventListener > &Listener)
static bool needsSynchronousNotification(std::u16string_view _rEventName)
an extended version of the ModelMethodGuard, which also cares for the initialization state of the doc...
a small base class for UNO components whose functionality depends on an ODatabaseModelImpl
Definition: ModelImpl.hxx:452
::rtl::Reference< ODatabaseModelImpl > m_pImpl
Definition: ModelImpl.hxx:454
css::uno::Reference< css::ui::XUIConfigurationManager2 > m_xUIConfigurationManager
void impl_throwIOExceptionCausedBySave_throw(const css::uno::Any &i_rError, std::u16string_view i_rTargetURL) const
throws an IOException with the message as defined in the RID_STR_ERROR_WHILE_SAVING resource,...
virtual ::sal_Int32 SAL_CALL leaseNumber(const css::uno::Reference< css::uno::XInterface > &xComponent) override
virtual void SAL_CALL removeModifyListener(const css::uno::Reference< css::util::XModifyListener > &aListener) override
css::uno::Reference< css::container::XNameAccess > impl_getDocumentContainer_throw(ODatabaseModelImpl::ObjectType _eType)
retrieves the forms or reports contained, creates and initializes it, if necessary
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getCurrentSelection() override
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getArgs() override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
css::uno::WeakReference< css::container::XNameAccess > m_xReports
ODatabaseDocument(const ::rtl::Reference< ODatabaseModelImpl > &_pImpl)
virtual void SAL_CALL addModifyListener(const css::uno::Reference< css::util::XModifyListener > &aListener) override
InitState m_eInitState
true if and only if the DatabaseDocument's "initNew" or "load" have been called (or,...
virtual sal_Bool SAL_CALL getAllowMacroExecution() override
virtual void SAL_CALL notifyDocumentEvent(const OUString &EventName, const css::uno::Reference< css::frame::XController2 > &ViewController, const css::uno::Any &Supplement) override
::comphelper::OInterfaceContainerHelper3< css::util::XCloseListener > m_aCloseListener
::comphelper::OInterfaceContainerHelper3< css::util::XModifyListener > m_aModifyListeners
virtual sal_Bool SAL_CALL wasModifiedSinceLastSave() override
virtual OUString SAL_CALL getLocation() override
virtual void SAL_CALL initNew() override
virtual void SAL_CALL unlockControllers() override
void impl_storeToStorage_throw(const css::uno::Reference< css::embed::XStorage > &_rxTargetStorage, const css::uno::Sequence< css::beans::PropertyValue > &_rMediaDescriptor, DocumentGuard &_rDocGuard) const
stores the document to the given storage
css::uno::Reference< css::frame::XTitle > const & impl_getTitleHelper_throw()
void impl_notifyStorageChange_nolck_nothrow(const css::uno::Reference< css::embed::XStorage > &_rxNewRootStorage)
notifies our storage change listeners that our underlying storage changed
virtual void SAL_CALL lockControllers() override
virtual css::uno::Reference< css::script::XStorageBasedLibraryContainer > SAL_CALL getBasicLibraries() override
css::uno::Reference< css::ui::XUIConfigurationManager2 > const & getUIConfigurationManager2()
virtual void SAL_CALL setTitle(const OUString &sTitle) override
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getReportDocuments() override
virtual void SAL_CALL connectController(const css::uno::Reference< css::frame::XController > &Controller) override
static void clearObjectContainer(css::uno::WeakReference< css::container::XNameAccess > &_rxContainer)
clears the given object container
void impl_closeControllerFrames_nolck_throw(bool _bDeliverOwnership)
closes the frames of all connected controllers
void impl_reparent_nothrow(const css::uno::WeakReference< css::container::XNameAccess > &_rxContainer)
does a reparenting at the given object container to ourself
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL getControllers() override
virtual void SAL_CALL storeToStorage(const css::uno::Reference< css::embed::XStorage > &xStorage, const css::uno::Sequence< css::beans::PropertyValue > &aMediaDescriptor) override
virtual sal_Bool SAL_CALL isReadonly() override
virtual void SAL_CALL removeDocumentEventListener(const css::uno::Reference< css::document::XDocumentEventListener > &Listener) override
DocumentEventNotifier m_aEventNotifier
virtual void SAL_CALL setPrinter(const css::uno::Sequence< css::beans::PropertyValue > &aPrinter) override
css::uno::WeakReference< css::container::XNameAccess > m_xForms
virtual void SAL_CALL storeToURL(const OUString &sURL, const css::uno::Sequence< css::beans::PropertyValue > &lArguments) override
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getFormDocuments() override
virtual void SAL_CALL recoverFromFile(const OUString &i_SourceLocation, const OUString &i_SalvagedFile, const css::uno::Sequence< css::beans::PropertyValue > &i_MediaDescriptor) override
virtual css::uno::Reference< css::embed::XStorage > SAL_CALL getDocumentSubStorage(const OUString &aStorageName, sal_Int32 nMode) override
virtual ::css::uno::Sequence< ::css::beans::PropertyValue > SAL_CALL getArgs2(const ::css::uno::Sequence< ::rtl::OUString > &requestedArgs) override
virtual void SAL_CALL switchToStorage(const css::uno::Reference< css::embed::XStorage > &xStorage) override
css::uno::Reference< css::embed::XStorage > impl_createStorageFor_throw(const OUString &_rURL) const
creates a storage for the given URL, truncating it if a file with this name already exists
virtual css::uno::Sequence< OUString > SAL_CALL getDocumentSubStoragesNames() override
virtual void SAL_CALL setCurrentController(const css::uno::Reference< css::frame::XController > &Controller) override
virtual void SAL_CALL removeStorageChangeListener(const css::uno::Reference< css::document::XStorageChangeListener > &xListener) override
virtual void SAL_CALL setArgs(const css::uno::Sequence< css::beans::PropertyValue > &aArgs) override
::rtl::Reference< DocumentEventExecutor > m_pEventExecutor
virtual void SAL_CALL dispose() override
bool m_bEmbedded
If XModel::attachResource() was called to inform us that the document is embedded into another one.
TNumberedController m_aNumberedControllers
void impl_disposeControllerFrames_nothrow()
disposes the frames of all controllers which are still left in m_aControllers.
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &_rType) override
void impl_storeAs_throw(const OUString &_rURL, const ::comphelper::NamedValueCollection &_rArguments, const StoreType _eType, DocumentGuard &_rGuard)
stores the document to the given URL, rebases it to the respective new storage, if necessary,...
static void impl_import_nolck_throw(const css::uno::Reference< css::uno::XComponentContext > &_rContext, const css::uno::Reference< css::uno::XInterface > &_rxTargetComponent, const ::comphelper::NamedValueCollection &_rResource)
imports the document from the given resource.
void WriteThroughComponent(const css::uno::Reference< css::lang::XComponent > &xComponent, const char *pStreamName, const char *pServiceName, const css::uno::Sequence< css::uno::Any > &rArguments, const css::uno::Sequence< css::beans::PropertyValue > &rMediaDesc, const css::uno::Reference< css::embed::XStorage > &_xStorageToSaveTo) const
write a single XML stream into the package
virtual css::uno::Reference< css::script::provider::XScriptProvider > SAL_CALL getScriptProvider() override
virtual css::uno::Reference< css::frame::XController > SAL_CALL getCurrentController() override
virtual ~ODatabaseDocument() override
virtual void SAL_CALL releaseNumber(::sal_Int32 nNumber) override
css::uno::Reference< css::frame::XModuleManager2 > m_xModuleManager
such module manager is used to classify new opened documents.
void impl_setModified_nothrow(bool _bModified, DocumentGuard &_rGuard)
sets our "modified" flag
virtual void SAL_CALL release() noexcept override
virtual void SAL_CALL addTitleChangeListener(const css::uno::Reference< css::frame::XTitleChangeListener > &xListener) override
virtual void SAL_CALL storeToRecoveryFile(const OUString &i_TargetLocation, const css::uno::Sequence< css::beans::PropertyValue > &i_MediaDescriptor) override
virtual void SAL_CALL print(const css::uno::Sequence< css::beans::PropertyValue > &xOptions) override
virtual void SAL_CALL disposing() override
virtual css::uno::Sequence< OUString > SAL_CALL getAvailableViewControllerNames() override
virtual void SAL_CALL load(const css::uno::Sequence< css::beans::PropertyValue > &lArguments) override
virtual void SAL_CALL acquire() noexcept override
::comphelper::OInterfaceContainerHelper3< css::document::XStorageChangeListener > m_aStorageListeners
virtual void SAL_CALL addCloseListener(const css::uno::Reference< css::util::XCloseListener > &Listener) override
void impl_setInitialized()
tells the model its initialization is done
virtual css::uno::Reference< css::frame::XController2 > SAL_CALL createDefaultViewController(const css::uno::Reference< css::frame::XFrame > &Frame) override
virtual sal_Bool SAL_CALL hasControllersLocked() override
virtual sal_Bool SAL_CALL isModified() override
virtual void SAL_CALL disconnectController(const css::uno::Reference< css::frame::XController > &Controller) override
css::uno::WeakReference< css::script::provider::XScriptProvider > m_xScriptProvider
virtual void SAL_CALL store() override
void impl_writeStorage_throw(const css::uno::Reference< css::embed::XStorage > &_rxTargetStorage, const ::comphelper::NamedValueCollection &_rMediaDescriptor) const
writes the content and settings
bool impl_isInitialized() const
returns whether the model is already initialized, i.e.
virtual void SAL_CALL setModified(sal_Bool bModified) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
void impl_setInitializing()
tells the model it is being initialized now
virtual css::uno::Reference< css::frame::XController2 > SAL_CALL createViewController(const OUString &ViewName, const css::uno::Sequence< css::beans::PropertyValue > &Arguments, const css::uno::Reference< css::frame::XFrame > &Frame) override
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
virtual OUString SAL_CALL getTitle() override
virtual void SAL_CALL loadFromStorage(const css::uno::Reference< css::embed::XStorage > &xStorage, const css::uno::Sequence< css::beans::PropertyValue > &aMediaDescriptor) override
bool impl_isInitializing() const
returns whether the model is currently being initialized
virtual void SAL_CALL addDocumentEventListener(const css::uno::Reference< css::document::XDocumentEventListener > &Listener) override
virtual OUString SAL_CALL getURL() override
virtual void SAL_CALL removeCloseListener(const css::uno::Reference< css::util::XCloseListener > &Listener) override
css::uno::Reference< css::embed::XStorage > impl_GetStorageOrCreateFor_throw(const ::comphelper::NamedValueCollection &_rArguments, const OUString &_rURL) const
Extracts storage from arguments, or creates for the given URL, truncating it if a file with this name...
css::uno::Reference< css::frame::XUntitledNumbers > impl_getUntitledHelper_throw(const css::uno::Reference< css::uno::XInterface > &_xComponent=css::uno::Reference< css::uno::XInterface >())
virtual css::uno::Reference< css::ui::XUIConfigurationManager > SAL_CALL getUIConfigurationManager() override
bool impl_attachResource(const OUString &i_rLogicalDocumentURL, const css::uno::Sequence< css::beans::PropertyValue > &i_rMediaDescriptor, DocumentGuard &_rDocGuard)
impl-version of attachResource
virtual OUString SAL_CALL getImplementationName() override
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
virtual void SAL_CALL addStorageChangeListener(const css::uno::Reference< css::document::XStorageChangeListener > &xListener) override
virtual css::uno::Reference< css::script::XStorageBasedLibraryContainer > SAL_CALL getDialogLibraries() override
virtual sal_Bool SAL_CALL hasLocation() override
virtual OUString SAL_CALL getUntitledPrefix() override
virtual css::uno::Reference< css::document::XEmbeddedScripts > SAL_CALL getScriptContainer() override
css::uno::Reference< css::frame::XTitle > m_xTitleHelper
virtual css::uno::Reference< css::uno::XInterface > getThis() const override
returns the component itself
virtual sal_Bool SAL_CALL attachResource(const OUString &URL, const css::uno::Sequence< css::beans::PropertyValue > &Arguments) override
css::uno::Reference< css::frame::XController > m_xCurrentController
virtual void SAL_CALL storeAsURL(const OUString &sURL, const css::uno::Sequence< css::beans::PropertyValue > &lArguments) override
virtual css::uno::Reference< css::embed::XStorage > SAL_CALL getDocumentStorage() override
virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents() override
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getPrinter() override
void impl_reset_nothrow()
resets everything
virtual css::uno::Reference< css::sdbc::XDataSource > SAL_CALL getDataSource() override
virtual void SAL_CALL removeTitleChangeListener(const css::uno::Reference< css::frame::XTitleChangeListener > &xListener) override
virtual void SAL_CALL releaseNumberForComponent(const css::uno::Reference< css::uno::XInterface > &xComponent) override
virtual void SAL_CALL close(sal_Bool DeliverOwnership) override
std::unique_ptr< DocumentEvents > m_pEventContainer
::comphelper::NamedValueCollection stripLoadArguments(const ::comphelper::NamedValueCollection &_rArguments)
Definition: ModelImpl.cxx:726
static OUString loadString(TranslateId pResId)
loads the string with the specified resource id
bool onControllerConnected(const css::uno::Reference< css::frame::XController > &_rxController)
to be called when a view (aka controller) has been connected to the document
css::uno::Reference< css::frame::XController > m_xLastConnectedController
DocumentEventNotifier & m_rEventNotifier
bool onSetCurrentController(const css::uno::Reference< css::frame::XController > &_rxController)
to be called when a controller is set as current controller
int nCount
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_dba_ODatabaseDocument(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define DBG_UNHANDLED_EXCEPTION(...)
ULONG m_refCount
constexpr OUStringLiteral MIMETYPE_OASIS_OPENDOCUMENT_DATABASE_ASCII
constexpr OUStringLiteral ODFVER_013_TEXT
constexpr OUStringLiteral ODFVER_012_TEXT
float u
Reference< XSingleServiceFactory > xFactory
URL aURL
Definition: intercept.cxx:87
Sequence< PropertyValue > aArguments
Definition: intercept.cxx:88
uno_Any a
@ Exception
COMPHELPER_DLLPUBLIC css::uno::Reference< css::beans::XPropertySet > GenericPropertySet_CreateInstance(PropertySetInfo *pInfo)
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
Type
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
bool commitStorageIfWriteable(const css::uno::Reference< css::embed::XStorage > &_rxStorage)
commits a given storage if it's not readonly
std::shared_ptr< OContentHelper_Impl > TContentPtr
std::vector< css::uno::Reference< css::frame::XController > > Controllers
OUString extractExceptionMessage(const css::uno::Reference< css::uno::XComponentContext > &_rContext, const css::uno::Any &_rError)
retrieves a to-be-displayed string for a given caught exception;
cppu::PartialWeakComponentImplHelper< css::frame::XModel3, css::util::XModifiable, css::frame::XStorable, css::document::XEventBroadcaster, css::document::XDocumentEventBroadcaster, css::view::XPrintable, css::util::XCloseable, css::lang::XServiceInfo, css::sdb::XOfficeDatabaseDocument, css::ui::XUIConfigurationManagerSupplier, css::document::XStorageBasedDocument, css::document::XEmbeddedScripts, css::document::XScriptInvocationContext, css::script::provider::XScriptProviderSupplier, css::document::XEventsSupplier, css::frame::XLoadable, css::document::XDocumentRecovery > ODatabaseDocument_OfficeDocument
static void lcl_uglyHackToStoreDialogeEmbedImages(const Reference< XStorageBasedLibraryContainer > &xDlgCont, const Reference< XStorage > &xStorage, const Reference< XModel > &rxModel, const Reference< XComponentContext > &rxContext)
constexpr OUStringLiteral sPictures
bool getDataSourceSetting(const Reference< XInterface > &_xChild, const OUString &_sAsciiSettingsName, Any &_rSettingsValue)
::osl::Mutex & getMutex()
int i
enumrange< T >::Iterator begin(enumrange< T >)
end
void SearchForGraphics(uno::Reference< uno::XInterface > const &xInterface, std::vector< uno::Reference< css::graphic::XGraphic > > &raGraphicList)
UNOTOOLS_DLLPUBLIC SvtSaveOptions::ODFSaneDefaultVersion GetODFSaneDefaultVersion()
constexpr OUStringLiteral INFO_MEDIATYPE
Definition: strings.hxx:229
constexpr OUStringLiteral SERVICE_SDB_APPLICATIONCONTROLLER
Definition: strings.hxx:203
Reference< XController > xController
the controller of the sub component. Must not be <NULL>
Reference< XFrame > xFrame
the frame which the component resides in. Must not be <NULL>
Reference< XModel > xModel
the model of the sub component. Might be <NULL>
unsigned char sal_Bool
constexpr OUStringLiteral sLibrary
size_t pos
const SvXMLTokenMapEntry aTypes[]
sal_Int32 nLength