Branch data Line data Source code
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 <sfx2/sfxbasemodel.hxx>
21 : :
22 : : #include <com/sun/star/task/XInteractionHandler.hpp>
23 : : #include <com/sun/star/task/ErrorCodeRequest.hpp>
24 : : #include <com/sun/star/view/XSelectionSupplier.hpp>
25 : : #include <com/sun/star/view/XPrintJobListener.hpp>
26 : : #include <com/sun/star/lang/DisposedException.hpp>
27 : : #include <com/sun/star/lang/IllegalArgumentException.hpp>
28 : : #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
29 : : #include <com/sun/star/frame/IllegalArgumentIOException.hpp>
30 : : #include <com/sun/star/frame/XUntitledNumbers.hpp>
31 : : #include <com/sun/star/frame/UntitledNumbersConst.hpp>
32 : : #include <com/sun/star/embed/XTransactionBroadcaster.hpp>
33 : : #include <com/sun/star/embed/XStorage.hpp>
34 : : #include <com/sun/star/embed/EmbedMapUnits.hpp>
35 : : #include <com/sun/star/document/XStorageChangeListener.hpp>
36 : : #include <com/sun/star/document/XActionLockable.hpp>
37 : : #include <com/sun/star/beans/XPropertySet.hpp>
38 : : #include <com/sun/star/beans/XPropertySetInfo.hpp>
39 : : #include <com/sun/star/container/XIndexContainer.hpp>
40 : : #include <com/sun/star/script/provider/XScriptProviderFactory.hpp>
41 : : #include <com/sun/star/script/provider/XScriptProvider.hpp>
42 : : #include <com/sun/star/ui/XUIConfigurationStorage.hpp>
43 : : #include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
44 : : #include <com/sun/star/embed/ElementModes.hpp>
45 : : #include <com/sun/star/embed/Aspects.hpp>
46 : : #include <com/sun/star/document/XDocumentProperties.hpp>
47 : : #include <com/sun/star/frame/XTransientDocumentsDocumentContentFactory.hpp>
48 : : #include <com/sun/star/ucb/XCommandEnvironment.hpp>
49 : : #include <comphelper/enumhelper.hxx> // can be removed when this is a "real" service
50 : :
51 : : #include <cppuhelper/interfacecontainer.hxx>
52 : : #include <cppuhelper/exc_hlp.hxx>
53 : : #include <comphelper/processfactory.hxx> // can be removed when this is a "real" service
54 : : #include <comphelper/componentcontext.hxx>
55 : : #include <comphelper/namedvaluecollection.hxx>
56 : : #include <svl/itemset.hxx>
57 : : #include <svl/stritem.hxx>
58 : : #include <svl/eitem.hxx>
59 : : #include <svl/intitem.hxx>
60 : : #include <basic/sbx.hxx>
61 : : #include <basic/sbuno.hxx>
62 : : #include <tools/urlobj.hxx>
63 : : #include <tools/diagnose_ex.h>
64 : : #include <unotools/tempfile.hxx>
65 : : #include <osl/mutex.hxx>
66 : : #include <vcl/salctype.hxx>
67 : : #include <sot/clsids.hxx>
68 : : #include <sot/storinfo.hxx>
69 : : #include <comphelper/storagehelper.hxx>
70 : : #include <toolkit/helper/vclunohelper.hxx>
71 : : #include <svtools/transfer.hxx>
72 : : #include <svtools/ehdl.hxx>
73 : : #include <svtools/sfxecode.hxx>
74 : : #include <rtl/logfile.hxx>
75 : : #include <rtl/strbuf.hxx>
76 : : #include <framework/configimporter.hxx>
77 : : #include <framework/interaction.hxx>
78 : : #include <framework/titlehelper.hxx>
79 : : #include <comphelper/numberedcollection.hxx>
80 : : #include <unotools/ucbstreamhelper.hxx>
81 : : #include <unotools/ucbhelper.hxx>
82 : :
83 : : #include <sfx2/sfxbasecontroller.hxx>
84 : : #include "sfx2/viewfac.hxx"
85 : : #include "workwin.hxx"
86 : : #include <sfx2/signaturestate.hxx>
87 : : #include <sfx2/sfxuno.hxx>
88 : : #include <objshimp.hxx>
89 : : #include <sfx2/viewfrm.hxx>
90 : : #include <sfx2/viewsh.hxx>
91 : : #include <sfx2/docfile.hxx>
92 : : #include <sfx2/dispatch.hxx>
93 : : #include <sfx2/request.hxx>
94 : : #include <sfx2/objuno.hxx>
95 : : #include <sfx2/printer.hxx>
96 : : #include <sfx2/basmgr.hxx>
97 : : #include <sfx2/event.hxx>
98 : : #include <eventsupplier.hxx>
99 : : #include <sfx2/evntconf.hxx>
100 : : #include <sfx2/sfx.hrc>
101 : : #include <sfx2/app.hxx>
102 : : #include "appdata.hxx"
103 : : #include <sfx2/docfac.hxx>
104 : : #include <sfx2/fcontnr.hxx>
105 : : #include "sfx2/docstoragemodifylistener.hxx"
106 : : #include "sfx2/brokenpackageint.hxx"
107 : : #include "graphhelp.hxx"
108 : : #include "docundomanager.hxx"
109 : : #include <sfx2/msgpool.hxx>
110 : : #include <sfx2/DocumentMetadataAccess.hxx>
111 : :
112 : : #include <sfx2/sfxresid.hxx>
113 : :
114 : : //________________________________________________________________________________________________________
115 : : // namespaces
116 : : //________________________________________________________________________________________________________
117 : :
118 : : namespace css = ::com::sun::star;
119 : : using namespace ::com::sun::star;
120 : : using namespace ::com::sun::star::uno;
121 : : using ::com::sun::star::beans::PropertyValue;
122 : : using ::com::sun::star::frame::XFrame;
123 : : using ::com::sun::star::frame::XController;
124 : : using ::com::sun::star::frame::XController2;
125 : : using ::com::sun::star::lang::IllegalArgumentException;
126 : : using ::com::sun::star::io::IOException;
127 : : using ::com::sun::star::lang::WrappedTargetException;
128 : : using ::com::sun::star::uno::Type;
129 : : using ::com::sun::star::uno::Sequence;
130 : : using ::com::sun::star::document::XDocumentRecovery;
131 : : using ::com::sun::star::document::XUndoManager;
132 : : using ::com::sun::star::document::XUndoAction;
133 : : using ::com::sun::star::document::UndoFailedException;
134 : : using ::com::sun::star::frame::XModel;
135 : :
136 : : /** This Listener is used to get notified when the XDocumentProperties of the
137 : : XModel change.
138 : : */
139 : : class SfxDocInfoListener_Impl : public ::cppu::WeakImplHelper1<
140 : : ::com::sun::star::util::XModifyListener >
141 : : {
142 : :
143 : : public:
144 : : SfxObjectShell& m_rShell;
145 : :
146 : 2420 : SfxDocInfoListener_Impl( SfxObjectShell& i_rDoc )
147 : 2420 : : m_rShell(i_rDoc)
148 : 2420 : { };
149 : :
150 : : ~SfxDocInfoListener_Impl();
151 : :
152 : : virtual void SAL_CALL disposing( const lang::EventObject& )
153 : : throw ( uno::RuntimeException );
154 : : virtual void SAL_CALL modified( const lang::EventObject& )
155 : : throw ( uno::RuntimeException );
156 : : };
157 : 2258 : SfxDocInfoListener_Impl::~SfxDocInfoListener_Impl()
158 : : {
159 [ - + ]: 4516 : }
160 : 6983 : void SAL_CALL SfxDocInfoListener_Impl::modified( const lang::EventObject& )
161 : : throw ( uno::RuntimeException )
162 : : {
163 [ + - ]: 6983 : SolarMutexGuard aSolarGuard;
164 : :
165 : : // notify changes to the SfxObjectShell
166 [ + - ][ + - ]: 6983 : m_rShell.FlushDocInfo();
167 : 6983 : }
168 : :
169 : 2258 : void SAL_CALL SfxDocInfoListener_Impl::disposing( const lang::EventObject& )
170 : : throw ( uno::RuntimeException )
171 : : {
172 : 2258 : }
173 : :
174 : : //________________________________________________________________________________________________________
175 : : // impl. declarations
176 : : //________________________________________________________________________________________________________
177 : :
178 : :
179 : : struct IMPL_SfxBaseModel_DataContainer : public ::sfx2::IModifiableDocument
180 : : {
181 : : // counter for SfxBaseModel instances created.
182 : : static sal_Int64 g_nInstanceCounter ;
183 : : SfxObjectShellRef m_pObjectShell ;
184 : : ::rtl::OUString m_sURL ;
185 : : ::rtl::OUString m_sRuntimeUID ;
186 : : ::rtl::OUString m_aPreusedFilterName;
187 : : ::cppu::OMultiTypeInterfaceContainerHelper m_aInterfaceContainer ;
188 : : uno::Reference< uno::XInterface > m_xParent ;
189 : : uno::Reference< frame::XController > m_xCurrent ;
190 : : uno::Reference< document::XDocumentInfo > m_xDocumentInfo ;
191 : : uno::Reference< document::XDocumentProperties > m_xDocumentProperties;
192 : : uno::Reference< script::XStarBasicAccess > m_xStarBasicAccess ;
193 : : uno::Reference< container::XNameReplace > m_xEvents ;
194 : : uno::Sequence< beans::PropertyValue> m_seqArguments ;
195 : : uno::Sequence< uno::Reference< frame::XController > > m_seqControllers ;
196 : : uno::Reference< container::XIndexAccess > m_contViewData ;
197 : : sal_uInt16 m_nControllerLockCount ;
198 : : sal_Bool m_bClosed ;
199 : : sal_Bool m_bClosing ;
200 : : sal_Bool m_bSaving ;
201 : : sal_Bool m_bSuicide ;
202 : : sal_Bool m_bInitialized ;
203 : : sal_Bool m_bExternalTitle ;
204 : : sal_Bool m_bModifiedSinceLastSave;
205 : : uno::Reference< com::sun::star::view::XPrintable> m_xPrintable ;
206 : : uno::Reference< script::provider::XScriptProvider > m_xScriptProvider;
207 : : uno::Reference< ui::XUIConfigurationManager > m_xUIConfigurationManager;
208 : : ::rtl::Reference< ::sfx2::DocumentStorageModifyListener > m_pStorageModifyListen;
209 : : ::rtl::OUString m_sModuleIdentifier;
210 : : css::uno::Reference< css::frame::XTitle > m_xTitleHelper;
211 : : css::uno::Reference< css::frame::XUntitledNumbers > m_xNumberedControllers;
212 : : uno::Reference< rdf::XDocumentMetadataAccess> m_xDocumentMetadata;
213 : : ::rtl::Reference< ::sfx2::DocumentUndoManager > m_pDocumentUndoManager;
214 : :
215 : :
216 : 3087 : IMPL_SfxBaseModel_DataContainer( ::osl::Mutex& rMutex, SfxObjectShell* pObjectShell )
217 : : : m_pObjectShell ( pObjectShell )
218 : : , m_aInterfaceContainer ( rMutex )
219 : : , m_nControllerLockCount ( 0 )
220 : : , m_bClosed ( sal_False )
221 : : , m_bClosing ( sal_False )
222 : : , m_bSaving ( sal_False )
223 : : , m_bSuicide ( sal_False )
224 : : , m_bInitialized ( sal_False )
225 : : , m_bExternalTitle ( sal_False )
226 : : , m_bModifiedSinceLastSave( sal_False )
227 : : , m_pStorageModifyListen ( NULL )
228 : : , m_xTitleHelper ()
229 : : , m_xNumberedControllers ()
230 : : , m_xDocumentMetadata () // lazy
231 [ + - ][ + - ]: 3087 : , m_pDocumentUndoManager ()
[ + - ]
232 : : {
233 : : // increase global instance counter.
234 : 3087 : ++g_nInstanceCounter;
235 : : // set own Runtime UID
236 : 3087 : m_sRuntimeUID = rtl::OUString::valueOf( g_nInstanceCounter );
237 : 3087 : }
238 : :
239 : 5416 : virtual ~IMPL_SfxBaseModel_DataContainer()
240 [ + - ][ + - ]: 2708 : {
[ + - ][ + - ]
241 [ - + ]: 5416 : }
242 : :
243 : : // ::sfx2::IModifiableDocument
244 : 9 : virtual void storageIsModified()
245 : : {
246 [ + - ][ - + ]: 9 : if ( m_pObjectShell.Is() && !m_pObjectShell->IsModified() )
[ - + ]
247 : 0 : m_pObjectShell->SetModified( sal_True );
248 : 9 : }
249 : :
250 : : void impl_setDocumentProperties(
251 : : const uno::Reference< document::XDocumentProperties >& );
252 : :
253 : 945 : uno::Reference<rdf::XDocumentMetadataAccess> GetDMA()
254 : : {
255 [ + + ]: 945 : if (!m_xDocumentMetadata.is())
256 : : {
257 : : OSL_ENSURE(m_pObjectShell, "GetDMA: no object shell?");
258 [ - + ]: 21 : if (!m_pObjectShell)
259 : : {
260 [ # # ]: 0 : return 0;
261 : : }
262 : :
263 : : const uno::Reference<uno::XComponentContext> xContext(
264 [ + - ]: 21 : ::comphelper::getProcessComponentContext());
265 : 21 : ::rtl::OUString uri;
266 : : const uno::Reference<frame::XModel> xModel(
267 [ + - ]: 21 : m_pObjectShell->GetModel());
268 : : const uno::Reference<lang::XMultiComponentFactory> xMsf(
269 [ + - ][ + - ]: 21 : xContext->getServiceManager());
270 : : const uno::Reference<frame::
271 : : XTransientDocumentsDocumentContentFactory> xTDDCF(
272 [ + - ]: 21 : xMsf->createInstanceWithContext(
273 : : ::rtl::OUString("com.sun.star.frame."
274 : : "TransientDocumentsDocumentContentFactory"),
275 : 21 : xContext),
276 [ + - ][ + + ]: 21 : uno::UNO_QUERY_THROW);
277 : : const uno::Reference<ucb::XContent> xContent(
278 [ + - ][ + - ]: 18 : xTDDCF->createDocumentContent(xModel) );
279 : : OSL_ENSURE(xContent.is(), "GetDMA: cannot create DocumentContent");
280 [ - + ]: 18 : if (!xContent.is())
281 : : {
282 [ # # ]: 0 : return 0;
283 : : }
284 [ + - ][ + - ]: 18 : uri = xContent->getIdentifier()->getContentIdentifier();
[ + - ][ + - ]
285 : : OSL_ENSURE(!uri.isEmpty(), "GetDMA: empty uri?");
286 [ + - ][ + - ]: 18 : if (!uri.isEmpty() && !uri.endsWithAsciiL("/", 1))
[ + - ]
287 : : {
288 : 18 : uri = uri + ::rtl::OUString("/");
289 : : }
290 : :
291 : : m_xDocumentMetadata = new ::sfx2::DocumentMetadataAccess(
292 [ + - ][ + - ]: 21 : xContext, *m_pObjectShell, uri);
[ + - ][ - + ]
[ - + ][ - + ]
[ - + ][ - + ]
[ + - ]
293 : : }
294 : 942 : return m_xDocumentMetadata;
295 : : }
296 : :
297 : 40 : uno::Reference<rdf::XDocumentMetadataAccess> CreateDMAUninitialized()
298 : : {
299 : : return (m_pObjectShell)
300 : : ? new ::sfx2::DocumentMetadataAccess(
301 [ + - ]: 80 : ::comphelper::getProcessComponentContext(), *m_pObjectShell)
302 [ + - ][ + - ]: 120 : : 0;
[ + - ][ + - ]
[ + - ][ # # ]
303 : : }
304 : : };
305 : :
306 : : // static member initialization.
307 : : sal_Int64 IMPL_SfxBaseModel_DataContainer::g_nInstanceCounter = 0;
308 : :
309 : : // =======================================================================================================
310 : :
311 : : // Listener that forwards notifications from the PrintHelper to the "real" listeners
312 [ - + ]: 4752 : class SfxPrintHelperListener_Impl : public ::cppu::WeakImplHelper1< ::com::sun::star::view::XPrintJobListener >
313 : : {
314 : : public:
315 : : IMPL_SfxBaseModel_DataContainer* m_pData;
316 : 2564 : SfxPrintHelperListener_Impl( IMPL_SfxBaseModel_DataContainer* pData )
317 : 2564 : : m_pData( pData )
318 : 2564 : {}
319 : :
320 : : virtual void SAL_CALL disposing( const lang::EventObject& aEvent ) throw ( uno::RuntimeException ) ;
321 : : virtual void SAL_CALL printJobEvent( const view::PrintJobEvent& rEvent ) throw ( uno::RuntimeException);
322 : : };
323 : :
324 : 0 : void SAL_CALL SfxPrintHelperListener_Impl::disposing( const lang::EventObject& ) throw ( uno::RuntimeException )
325 : : {
326 : 0 : m_pData->m_xPrintable = 0;
327 : 0 : }
328 : :
329 : 0 : void SAL_CALL SfxPrintHelperListener_Impl::printJobEvent( const view::PrintJobEvent& rEvent ) throw (uno::RuntimeException)
330 : : {
331 : 0 : ::cppu::OInterfaceContainerHelper* pContainer = m_pData->m_aInterfaceContainer.getContainer( ::getCppuType( ( const uno::Reference< view::XPrintJobListener >*) NULL ) );
332 [ # # ]: 0 : if ( pContainer!=NULL )
333 : : {
334 [ # # ]: 0 : ::cppu::OInterfaceIteratorHelper pIterator(*pContainer);
335 [ # # ]: 0 : while (pIterator.hasMoreElements())
336 [ # # ][ # # ]: 0 : ((view::XPrintJobListener*)pIterator.next())->printJobEvent( rEvent );
[ # # ]
337 : : }
338 : 0 : }
339 : :
340 : : // SfxOwnFramesLocker ====================================================================================
341 : : // allows to lock all the frames related to the provided SfxObjectShell
342 : : class SfxOwnFramesLocker
343 : : {
344 : : uno::Sequence< uno::Reference< frame::XFrame > > m_aLockedFrames;
345 : :
346 : : Window* GetVCLWindow( const uno::Reference< frame::XFrame >& xFrame );
347 : : public:
348 : : SfxOwnFramesLocker( SfxObjectShell* ObjechShell );
349 : : ~SfxOwnFramesLocker();
350 : : void UnlockFrames();
351 : : };
352 : :
353 : 177 : SfxOwnFramesLocker::SfxOwnFramesLocker( SfxObjectShell* pObjectShell )
354 : : {
355 [ - + ]: 177 : if ( !pObjectShell )
356 : 177 : return;
357 : :
358 [ + - ][ + - ]: 346 : for ( SfxViewFrame *pFrame = SfxViewFrame::GetFirst( pObjectShell );
[ + + ]
359 : : pFrame;
360 : : pFrame = SfxViewFrame::GetNext( *pFrame, pObjectShell )
361 : : )
362 : : {
363 [ + - ]: 169 : SfxFrame& rSfxFrame = pFrame->GetFrame();
364 : : try
365 : : {
366 : : // get vcl window related to the frame and lock it if it is still not locked
367 [ + - ]: 169 : uno::Reference< frame::XFrame > xFrame = rSfxFrame.GetFrameInterface();
368 [ + - ]: 169 : Window* pWindow = GetVCLWindow( xFrame );
369 [ - + ]: 169 : if ( !pWindow )
370 [ # # ]: 0 : throw uno::RuntimeException();
371 : :
372 [ + - ][ + - ]: 169 : if ( pWindow->IsEnabled() )
373 : : {
374 [ + - ]: 169 : pWindow->Disable();
375 : :
376 : : try
377 : : {
378 : 169 : sal_Int32 nLen = m_aLockedFrames.getLength();
379 [ + - ]: 169 : m_aLockedFrames.realloc( nLen + 1 );
380 [ + - ][ + - ]: 169 : m_aLockedFrames[nLen] = xFrame;
381 : : }
382 [ # # ]: 0 : catch( uno::Exception& )
383 : : {
384 [ # # ]: 0 : pWindow->Enable();
385 : 0 : throw;
386 : : }
387 [ # # ]: 169 : }
388 : : }
389 [ # # ]: 0 : catch( uno::Exception& )
390 : : {
391 : : OSL_FAIL( "Not possible to lock the frame window!\n" );
392 : : }
393 : : }
394 : : }
395 : :
396 : 177 : SfxOwnFramesLocker::~SfxOwnFramesLocker()
397 : : {
398 [ + - ]: 177 : UnlockFrames();
399 : 177 : }
400 : :
401 : 338 : Window* SfxOwnFramesLocker::GetVCLWindow( const uno::Reference< frame::XFrame >& xFrame )
402 : : {
403 : 338 : Window* pWindow = NULL;
404 : :
405 [ + - ]: 338 : if ( xFrame.is() )
406 : : {
407 [ + - ][ + - ]: 338 : uno::Reference< awt::XWindow > xWindow = xFrame->getContainerWindow();
408 [ + - ]: 338 : if ( xWindow.is() )
409 [ + - ]: 338 : pWindow = VCLUnoHelper::GetWindow( xWindow );
410 : : }
411 : :
412 : 338 : return pWindow;
413 : : }
414 : :
415 : 177 : void SfxOwnFramesLocker::UnlockFrames()
416 : : {
417 [ + + ]: 346 : for ( sal_Int32 nInd = 0; nInd < m_aLockedFrames.getLength(); nInd++ )
418 : : {
419 : : try
420 : : {
421 [ + - ][ + - ]: 169 : if ( m_aLockedFrames[nInd].is() )
422 : : {
423 : : // get vcl window related to the frame and unlock it
424 [ + - ][ + - ]: 169 : Window* pWindow = GetVCLWindow( m_aLockedFrames[nInd] );
425 [ - + ]: 169 : if ( !pWindow )
426 [ # # ]: 0 : throw uno::RuntimeException();
427 : :
428 [ + - ]: 169 : pWindow->Enable();
429 : :
430 [ + - ][ + - ]: 169 : m_aLockedFrames[nInd] = uno::Reference< frame::XFrame >();
[ # # ]
431 : : }
432 : : }
433 : 0 : catch( uno::Exception& )
434 : : {
435 : : OSL_FAIL( "Can't unlock the frame window!\n" );
436 : : }
437 : : }
438 : 177 : }
439 : :
440 : : // SfxSaveGuard ====================================================================================
441 : : class SfxSaveGuard
442 : : {
443 : : private:
444 : : uno::Reference< frame::XModel > m_xModel;
445 : : IMPL_SfxBaseModel_DataContainer* m_pData;
446 : : SfxOwnFramesLocker* m_pFramesLock;
447 : :
448 : : public:
449 : : SfxSaveGuard(const uno::Reference< frame::XModel >& xModel ,
450 : : IMPL_SfxBaseModel_DataContainer* pData ,
451 : : sal_Bool bRejectConcurrentSaveRequest);
452 : : ~SfxSaveGuard();
453 : : };
454 : :
455 : 177 : SfxSaveGuard::SfxSaveGuard(const uno::Reference< frame::XModel >& xModel ,
456 : : IMPL_SfxBaseModel_DataContainer* pData ,
457 : : sal_Bool bRejectConcurrentSaveRequest)
458 : : : m_xModel (xModel)
459 : : , m_pData (pData )
460 : 177 : , m_pFramesLock(0 )
461 : : {
462 [ - + ]: 177 : if ( m_pData->m_bClosed )
463 : : throw ::com::sun::star::lang::DisposedException(
464 : : ::rtl::OUString("Object already disposed."),
465 [ # # ]: 0 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >());
466 : :
467 [ - + ][ # # ]: 177 : if (
468 : : bRejectConcurrentSaveRequest &&
469 : : m_pData->m_bSaving
470 : : )
471 : : throw ::com::sun::star::io::IOException(
472 : : ::rtl::OUString("Concurrent save requests on the same document are not possible."),
473 [ # # ]: 0 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >());
474 : :
475 : 177 : m_pData->m_bSaving = sal_True;
476 [ + - ][ + - ]: 177 : m_pFramesLock = new SfxOwnFramesLocker(m_pData->m_pObjectShell);
477 : 177 : }
478 : :
479 : 177 : SfxSaveGuard::~SfxSaveGuard()
480 : : {
481 : 177 : SfxOwnFramesLocker* pFramesLock = m_pFramesLock;
482 : 177 : m_pFramesLock = 0;
483 [ + - ][ + - ]: 177 : delete pFramesLock;
484 : :
485 : 177 : m_pData->m_bSaving = sal_False;
486 : :
487 : : // m_bSuicide was set e.g. in case somewhere tried to close a document, while it was used for
488 : : // storing at the same time. Further m_bSuicide was set to sal_True only if close(sal_True) was called.
489 : : // So the owner ship was delegated to the place where a veto exception was thrown.
490 : : // Now we have to call close() again and delegate the owner ship to the next one, which
491 : : // cant accept that. Close(sal_False) cant work in this case. Because then the document will may be never closed ...
492 : :
493 [ - + ]: 177 : if ( m_pData->m_bSuicide )
494 : : {
495 : : // Reset this state. In case the new close() request is not accepted by somehwere else ...
496 : : // it's not a good idea to have two "owners" for close .-)
497 : 0 : m_pData->m_bSuicide = sal_False;
498 : : try
499 : : {
500 [ # # ]: 0 : uno::Reference< util::XCloseable > xClose(m_xModel, uno::UNO_QUERY);
501 [ # # ]: 0 : if (xClose.is())
502 [ # # ][ # # ]: 0 : xClose->close(sal_True);
[ # # ]
503 : : }
504 [ # # ]: 0 : catch(const util::CloseVetoException&)
505 : : {}
506 : : }
507 : 177 : }
508 : :
509 : : // =======================================================================================================
510 : :
511 : : //________________________________________________________________________________________________________
512 : : // constructor
513 : : //________________________________________________________________________________________________________
514 : : DBG_NAME(sfx2_SfxBaseModel)
515 : 3087 : SfxBaseModel::SfxBaseModel( SfxObjectShell *pObjectShell )
516 : : : BaseMutex()
517 [ + - ]: 3087 : , m_pData( new IMPL_SfxBaseModel_DataContainer( m_aMutex, pObjectShell ) )
518 : 6062 : , m_bSupportEmbeddedScripts( pObjectShell && pObjectShell->Get_Impl() ? !pObjectShell->Get_Impl()->m_bNoBasicCapabilities : false )
519 [ + - ][ + - ]: 12236 : , m_bSupportDocRecovery( pObjectShell && pObjectShell->Get_Impl() ? pObjectShell->Get_Impl()->m_bDocRecoverySupport : false )
[ + - ][ + +
+ - + + ]
[ + + ][ + - ]
[ + + ]
520 : : {
521 : : DBG_CTOR(sfx2_SfxBaseModel,NULL);
522 [ + + ]: 3087 : if ( pObjectShell != NULL )
523 : : {
524 [ + - ]: 3031 : StartListening( *pObjectShell ) ;
525 : : }
526 : 3087 : }
527 : :
528 : : //________________________________________________________________________________________________________
529 : : // destructor
530 : : //________________________________________________________________________________________________________
531 : :
532 [ + - ][ + - ]: 2098 : SfxBaseModel::~SfxBaseModel()
533 : : {
534 : : DBG_DTOR(sfx2_SfxBaseModel,NULL);
535 [ - + ]: 2098 : }
536 : :
537 : : //________________________________________________________________________________________________________
538 : : // XInterface
539 : : //________________________________________________________________________________________________________
540 : :
541 : 673634 : uno::Any SAL_CALL SfxBaseModel::queryInterface( const UNOTYPE& rType ) throw( uno::RuntimeException )
542 : : {
543 [ + + ][ + - ]: 676218 : if ( ( !m_bSupportEmbeddedScripts && rType.equals( XEMBEDDEDSCRIPTS::static_type() ) )
[ + + - + ]
[ - + ]
544 : 2584 : || ( !m_bSupportDocRecovery && rType.equals( XDocumentRecovery::static_type() ) )
545 : : )
546 : 0 : return Any();
547 : :
548 : 673634 : return SfxBaseModel_Base::queryInterface( rType );
549 : : }
550 : :
551 : : //________________________________________________________________________________________________________
552 : : // XInterface
553 : : //________________________________________________________________________________________________________
554 : :
555 : 2605653 : void SAL_CALL SfxBaseModel::acquire() throw( )
556 : : {
557 : : // Attention:
558 : : // Don't use mutex or guard in this method!!! Is a method of XInterface.
559 : :
560 : : // Forward to baseclass
561 : 2605653 : OWeakObject::acquire() ;
562 : 2605653 : }
563 : :
564 : : //________________________________________________________________________________________________________
565 : : // XInterface
566 : : //________________________________________________________________________________________________________
567 : :
568 : 2417404 : void SAL_CALL SfxBaseModel::release() throw( )
569 : : {
570 : : // Attention:
571 : : // Don't use mutex or guard in this method!!! Is a method of XInterface.
572 : :
573 : : // Forward to baseclass
574 : 2417404 : OWeakObject::release() ;
575 : 2417404 : }
576 : :
577 : : //________________________________________________________________________________________________________
578 : : // XTypeProvider
579 : : //________________________________________________________________________________________________________
580 : :
581 : : namespace
582 : : {
583 : 0 : void lcl_stripType( Sequence< Type >& io_rTypes, const Type& i_rTypeToStrip )
584 : : {
585 [ # # ]: 0 : Sequence< UNOTYPE > aStrippedTypes( io_rTypes.getLength() - 1 );
586 : : ::std::remove_copy_if(
587 : : io_rTypes.getConstArray(),
588 : 0 : io_rTypes.getConstArray() + io_rTypes.getLength(),
589 : : aStrippedTypes.getArray(),
590 : : ::std::bind2nd( ::std::equal_to< Type >(), i_rTypeToStrip )
591 [ # # ]: 0 : );
[ # # # # ]
592 [ # # ][ # # ]: 0 : io_rTypes = aStrippedTypes;
593 : 0 : }
594 : : }
595 : :
596 : 1544 : uno::Sequence< UNOTYPE > SAL_CALL SfxBaseModel::getTypes() throw( uno::RuntimeException )
597 : : {
598 : 1544 : uno::Sequence< UNOTYPE > aTypes( SfxBaseModel_Base::getTypes() );
599 : :
600 [ - + ]: 1544 : if ( !m_bSupportEmbeddedScripts )
601 [ # # ][ # # ]: 0 : lcl_stripType( aTypes, XEMBEDDEDSCRIPTS::static_type() );
602 : :
603 [ - + ]: 1544 : if ( !m_bSupportDocRecovery )
604 [ # # ][ # # ]: 0 : lcl_stripType( aTypes, XDocumentRecovery::static_type() );
605 : :
606 : 1544 : return aTypes;
607 : : }
608 : :
609 : : //________________________________________________________________________________________________________
610 : : // XTypeProvider
611 : : //________________________________________________________________________________________________________
612 : :
613 : 36 : uno::Sequence< sal_Int8 > SAL_CALL SfxBaseModel::getImplementationId() throw( uno::RuntimeException )
614 : : {
615 : : // Create one Id for all instances of this class.
616 : : // Use ethernet address to do this! (sal_True)
617 : :
618 : : // Optimize this method
619 : : // We initialize a static variable only one time. And we don't must use a mutex at every call!
620 : : // For the first call; pID is NULL - for the second call pID is different from NULL!
621 : : static ::cppu::OImplementationId* pID = NULL ;
622 : :
623 [ + + ]: 36 : if ( pID == NULL )
624 : : {
625 : : // Ready for multithreading; get global mutex for first call of this method only! see before
626 [ + - ][ + - ]: 4 : ::osl::MutexGuard aGuard( MUTEX::getGlobalMutex() ) ;
627 : :
628 : : // Control these pointer again ... it can be, that another instance will be faster then these!
629 [ + - ]: 4 : if ( pID == NULL )
630 : : {
631 : : // Create a new static ID ...
632 [ + - ][ + - ]: 4 : static ::cppu::OImplementationId aID( sal_False ) ;
633 : : // ... and set his address to static pointer!
634 : 4 : pID = &aID ;
635 [ + - ]: 4 : }
636 : : }
637 : :
638 : 36 : return pID->getImplementationId() ;
639 : : }
640 : :
641 : : //________________________________________________________________________________________________________
642 : : // XStarBasicAccess
643 : : //________________________________________________________________________________________________________
644 : :
645 : 0 : uno::Reference< script::XStarBasicAccess > implGetStarBasicAccess( SfxObjectShell* pObjectShell )
646 : : {
647 : 0 : uno::Reference< script::XStarBasicAccess > xRet;
648 : :
649 : : #ifdef DISABLE_SCRIPTING
650 : : (void) pObjectShell;
651 : : #else
652 [ # # ]: 0 : if( pObjectShell )
653 : : {
654 [ # # ]: 0 : BasicManager* pMgr = pObjectShell->GetBasicManager();
655 [ # # ][ # # ]: 0 : xRet = getStarBasicAccess( pMgr );
656 : : }
657 : : #endif
658 : 0 : return xRet;
659 : : }
660 : :
661 : 0 : uno::Reference< XNAMECONTAINER > SAL_CALL SfxBaseModel::getLibraryContainer() throw( uno::RuntimeException )
662 : : {
663 : : #ifdef DISABLE_SCRIPTING
664 : : uno::Reference< XNAMECONTAINER > dummy;
665 : :
666 : : return dummy;
667 : : #else
668 [ # # ]: 0 : SfxModelGuard aGuard( *this );
669 : :
670 : 0 : uno::Reference< script::XStarBasicAccess >& rxAccess = m_pData->m_xStarBasicAccess;
671 [ # # ][ # # ]: 0 : if( !rxAccess.is() && m_pData->m_pObjectShell.Is() )
[ # # ]
672 [ # # ][ # # ]: 0 : rxAccess = implGetStarBasicAccess( m_pData->m_pObjectShell );
673 : :
674 : 0 : uno::Reference< XNAMECONTAINER > xRet;
675 [ # # ]: 0 : if( rxAccess.is() )
676 [ # # ][ # # ]: 0 : xRet = rxAccess->getLibraryContainer();
[ # # ]
677 [ # # ]: 0 : return xRet;
678 : : #endif
679 : : }
680 : :
681 : : /**___________________________________________________________________________________________________
682 : : @seealso XStarBasicAccess
683 : : */
684 : 0 : void SAL_CALL SfxBaseModel::createLibrary( const ::rtl::OUString& LibName, const ::rtl::OUString& Password,
685 : : const ::rtl::OUString& ExternalSourceURL, const ::rtl::OUString& LinkTargetURL )
686 : : throw(ELEMENTEXISTEXCEPTION, uno::RuntimeException)
687 : : {
688 : : #ifdef DISABLE_SCRIPTING
689 : : (void) LibName;
690 : : (void) Password;
691 : : (void) ExternalSourceURL;
692 : : (void) LinkTargetURL;
693 : : #else
694 [ # # ]: 0 : SfxModelGuard aGuard( *this );
695 : :
696 : 0 : uno::Reference< script::XStarBasicAccess >& rxAccess = m_pData->m_xStarBasicAccess;
697 [ # # ][ # # ]: 0 : if( !rxAccess.is() && m_pData->m_pObjectShell.Is() )
[ # # ]
698 [ # # ][ # # ]: 0 : rxAccess = implGetStarBasicAccess( m_pData->m_pObjectShell );
699 : :
700 [ # # ]: 0 : if( rxAccess.is() )
701 [ # # ][ # # ]: 0 : rxAccess->createLibrary( LibName, Password, ExternalSourceURL, LinkTargetURL );
[ # # ]
702 : : #endif
703 : 0 : }
704 : :
705 : : /**___________________________________________________________________________________________________
706 : : @seealso XStarBasicAccess
707 : : */
708 : 0 : void SAL_CALL SfxBaseModel::addModule( const ::rtl::OUString& LibraryName, const ::rtl::OUString& ModuleName,
709 : : const ::rtl::OUString& Language, const ::rtl::OUString& Source )
710 : : throw( NOSUCHELEMENTEXCEPTION, uno::RuntimeException)
711 : : {
712 : : #ifdef DISABLE_SCRIPTING
713 : : (void) LibraryName;
714 : : (void) ModuleName;
715 : : (void) Language;
716 : : (void) Source;
717 : : #else
718 [ # # ]: 0 : SfxModelGuard aGuard( *this );
719 : :
720 : 0 : uno::Reference< script::XStarBasicAccess >& rxAccess = m_pData->m_xStarBasicAccess;
721 [ # # ][ # # ]: 0 : if( !rxAccess.is() && m_pData->m_pObjectShell.Is() )
[ # # ]
722 [ # # ][ # # ]: 0 : rxAccess = implGetStarBasicAccess( m_pData->m_pObjectShell );
723 : :
724 [ # # ]: 0 : if( rxAccess.is() )
725 [ # # ][ # # ]: 0 : rxAccess->addModule( LibraryName, ModuleName, Language, Source );
[ # # ]
726 : : #endif
727 : 0 : }
728 : :
729 : : /**___________________________________________________________________________________________________
730 : : @seealso XStarBasicAccess
731 : : */
732 : 0 : void SAL_CALL SfxBaseModel::addDialog( const ::rtl::OUString& LibraryName, const ::rtl::OUString& DialogName,
733 : : const ::com::sun::star::uno::Sequence< sal_Int8 >& Data )
734 : : throw(NOSUCHELEMENTEXCEPTION, uno::RuntimeException)
735 : : {
736 : : #ifdef DISABLE_SCRIPTING
737 : : (void) LibraryName;
738 : : (void) DialogName;
739 : : (void) Data;
740 : : #else
741 [ # # ]: 0 : SfxModelGuard aGuard( *this );
742 : :
743 : 0 : uno::Reference< script::XStarBasicAccess >& rxAccess = m_pData->m_xStarBasicAccess;
744 [ # # ][ # # ]: 0 : if( !rxAccess.is() && m_pData->m_pObjectShell.Is() )
[ # # ]
745 [ # # ][ # # ]: 0 : rxAccess = implGetStarBasicAccess( m_pData->m_pObjectShell );
746 : :
747 [ # # ]: 0 : if( rxAccess.is() )
748 [ # # ][ # # ]: 0 : rxAccess->addDialog( LibraryName, DialogName, Data );
[ # # ]
749 : : #endif
750 : 0 : }
751 : :
752 : :
753 : : //________________________________________________________________________________________________________
754 : : // XChild
755 : : //________________________________________________________________________________________________________
756 : :
757 : 4876 : uno::Reference< uno::XInterface > SAL_CALL SfxBaseModel::getParent() throw( uno::RuntimeException )
758 : : {
759 [ + - ]: 4876 : SfxModelGuard aGuard( *this );
760 : :
761 [ + - ]: 4876 : return m_pData->m_xParent;
762 : : }
763 : :
764 : : //________________________________________________________________________________________________________
765 : : // XChild
766 : : //________________________________________________________________________________________________________
767 : :
768 : 1278 : void SAL_CALL SfxBaseModel::setParent(const uno::Reference< uno::XInterface >& Parent) throw(NOSUPPORTEXCEPTION, uno::RuntimeException)
769 : : {
770 [ + - ]: 1278 : SfxModelGuard aGuard( *this, SfxModelGuard::E_INITIALIZING );
771 [ + - ][ + - ]: 1278 : m_pData->m_xParent = Parent;
772 : 1278 : }
773 : :
774 : : //________________________________________________________________________________________________________
775 : : // XChild
776 : : //________________________________________________________________________________________________________
777 : :
778 : 3548 : void SAL_CALL SfxBaseModel::dispose() throw(::com::sun::star::uno::RuntimeException)
779 : : {
780 [ + - ]: 3548 : SfxModelGuard aGuard( *this, SfxModelGuard::E_INITIALIZING );
781 : :
782 [ + + ]: 3548 : if ( !m_pData->m_bClosed )
783 : : {
784 : : // gracefully accept wrong dispose calls instead of close call
785 : : // and try to make it work (may be really disposed later!)
786 : : try
787 : : {
788 [ + - ]: 840 : close( sal_True );
789 : : }
790 [ # # ]: 0 : catch ( com::sun::star::util::CloseVetoException& )
791 : : {
792 : : }
793 : :
794 [ # # ]: 3548 : return;
795 : : }
796 : :
797 [ + + ]: 2708 : if ( m_pData->m_pStorageModifyListen.is() )
798 : : {
799 [ + - ]: 2028 : m_pData->m_pStorageModifyListen->dispose();
800 [ + - ]: 2028 : m_pData->m_pStorageModifyListen = NULL;
801 : : }
802 : :
803 [ + + ]: 2708 : if ( m_pData->m_pDocumentUndoManager.is() )
804 : : {
805 [ + - ]: 21 : m_pData->m_pDocumentUndoManager->disposing();
806 [ + - ]: 21 : m_pData->m_pDocumentUndoManager = NULL;
807 : : }
808 : :
809 [ + - ][ + - ]: 2708 : lang::EventObject aEvent( (frame::XModel *)this );
810 [ + - ]: 2708 : m_pData->m_aInterfaceContainer.disposeAndClear( aEvent );
811 : :
812 [ + + ]: 2708 : if ( m_pData->m_xDocumentInfo.is() )
813 : : {
814 : : // as long as an SfxObjectShell is assigned to an SfxBaseModel it is still existing here
815 : : // so we can't dispose the shared DocumentInfoObject here
816 [ + - ]: 130 : m_pData->m_xDocumentInfo = 0;
817 : : }
818 : :
819 : 2708 : m_pData->m_xDocumentProperties.clear();
820 : :
821 : 2708 : m_pData->m_xDocumentMetadata.clear();
822 : :
823 [ + - ]: 2708 : EndListening( *m_pData->m_pObjectShell );
824 : :
825 [ + - ]: 2708 : m_pData->m_xCurrent = uno::Reference< frame::XController > ();
826 [ + - ][ + - ]: 2708 : m_pData->m_seqControllers = uno::Sequence< uno::Reference< frame::XController > > () ;
[ + - ]
827 : :
828 : : // m_pData member must be set to zero before 0delete is called to
829 : : // force disposed exception whenever someone tries to access our
830 : : // instance while in the dtor.
831 : 2708 : IMPL_SfxBaseModel_DataContainer* pData = m_pData;
832 : 2708 : m_pData = 0;
833 [ + - ][ + - ]: 3548 : delete pData;
[ + - ][ + - ]
[ + + ]
834 : : }
835 : :
836 : : //________________________________________________________________________________________________________
837 : : // XChild
838 : : //________________________________________________________________________________________________________
839 : :
840 : 4858 : void SAL_CALL SfxBaseModel::addEventListener( const uno::Reference< XEVENTLISTENER >& aListener )
841 : : throw(::com::sun::star::uno::RuntimeException)
842 : : {
843 [ + - ]: 4858 : SfxModelGuard aGuard( *this, SfxModelGuard::E_INITIALIZING );
844 [ + - ][ + - ]: 4858 : m_pData->m_aInterfaceContainer.addInterface( ::getCppuType((const uno::Reference< XEVENTLISTENER >*)0), aListener );
[ + - ]
845 : 4858 : }
846 : :
847 : : //________________________________________________________________________________________________________
848 : : // XChild
849 : : //________________________________________________________________________________________________________
850 : :
851 : 2643 : void SAL_CALL SfxBaseModel::removeEventListener( const uno::Reference< XEVENTLISTENER >& aListener )
852 : : throw(::com::sun::star::uno::RuntimeException)
853 : : {
854 [ + - ]: 2643 : SfxModelGuard aGuard( *this, SfxModelGuard::E_INITIALIZING );
855 [ + - ][ + - ]: 2643 : m_pData->m_aInterfaceContainer.removeInterface( ::getCppuType((const uno::Reference< XEVENTLISTENER >*)0), aListener );
[ + - ]
856 : 2643 : }
857 : :
858 : : //________________________________________________________________________________________________________
859 : : // document::XDocumentInfoSupplier
860 : : //________________________________________________________________________________________________________
861 : :
862 : 142 : uno::Reference< document::XDocumentInfo > SAL_CALL SfxBaseModel::getDocumentInfo() throw(::com::sun::star::uno::RuntimeException)
863 : : {
864 [ + - ]: 142 : SfxModelGuard aGuard( *this, SfxModelGuard::E_INITIALIZING );
865 [ + + ]: 142 : if ( !m_pData->m_xDocumentInfo.is() )
866 : : {
867 : : // WARNING: this will only work if (when loading a document) the
868 : : // document meta-data has already been read and completely written
869 : : // into the XDocumentProperties at this point
870 : : // ==> DO NOT call getDocumentInfo before document info has been read!
871 : : uno::Reference< document::XDocumentInfo > xDocInfo =
872 [ + - ][ + - ]: 133 : new SfxDocumentInfoObject;
[ + - ]
873 : : uno::Reference< document::XDocumentProperties > xDocProps =
874 [ + - ]: 133 : getDocumentProperties();
875 [ + - ]: 133 : uno::Sequence< uno::Any > args(1);
876 [ + - ][ + - ]: 133 : args[0] <<= xDocProps;
877 : : uno::Reference< lang::XInitialization > xInit(
878 [ + - ]: 133 : xDocInfo, uno::UNO_QUERY_THROW);
879 : : try {
880 [ + - ][ + - ]: 133 : xInit->initialize(args);
881 [ + - ]: 133 : ((SfxBaseModel*)this)->m_pData->m_xDocumentInfo = xDocInfo;
882 : 0 : } catch (uno::RuntimeException &) {
883 : 0 : throw;
884 [ # # # ]: 0 : } catch (const uno::Exception & e) {
885 : : throw lang::WrappedTargetRuntimeException(::rtl::OUString(
886 : : "SfxBaseModel::getDocumentInfo: cannot initialize"), *this,
887 [ # # # # : 0 : uno::makeAny(e));
# # ]
888 : : }
889 : : try {
890 : 133 : rtl::OUString aName("MediaType");
891 : : uno::Reference < beans::XPropertySet > xSet(
892 [ + + ][ + - ]: 133 : getDocumentStorage(), uno::UNO_QUERY_THROW );
893 [ + - ][ + - ]: 46 : uno::Any aMediaType = xSet->getPropertyValue( aName );
894 : : uno::Reference < beans::XPropertySet > xDocSet(
895 [ + - ]: 46 : m_pData->m_xDocumentInfo, uno::UNO_QUERY_THROW );
896 [ + - ][ - + ]: 133 : xDocSet->setPropertyValue( aName, aMediaType );
[ - + ]
897 [ + - ]: 133 : } catch (uno::Exception &) {
898 : : //ignore
899 [ + - ]: 133 : }
900 : : }
901 : :
902 [ + - ]: 142 : return m_pData->m_xDocumentInfo;
903 : : }
904 : :
905 : : void
906 : 2420 : IMPL_SfxBaseModel_DataContainer::impl_setDocumentProperties(
907 : : const uno::Reference< document::XDocumentProperties >& rxNewDocProps)
908 : : {
909 [ + - ]: 2420 : m_xDocumentProperties.set(rxNewDocProps, uno::UNO_QUERY_THROW);
910 : : uno::Reference<util::XModifyBroadcaster> const xMB(m_xDocumentProperties,
911 [ + - ]: 2420 : uno::UNO_QUERY_THROW);
912 [ + - ][ + - ]: 2420 : xMB->addModifyListener(new SfxDocInfoListener_Impl(*m_pObjectShell));
[ + - ][ + - ]
[ + - ]
913 : 2420 : }
914 : :
915 : : // document::XDocumentPropertiesSupplier:
916 : : uno::Reference< document::XDocumentProperties > SAL_CALL
917 : 11871 : SfxBaseModel::getDocumentProperties()
918 : : throw(::com::sun::star::uno::RuntimeException)
919 : : {
920 [ + - ]: 11871 : SfxModelGuard aGuard( *this, SfxModelGuard::E_INITIALIZING );
921 [ + + ]: 11871 : if ( !m_pData->m_xDocumentProperties.is() )
922 : : {
923 : : uno::Reference< document::XDocumentProperties > xDocProps(
924 [ + - ][ + - ]: 4840 : ::comphelper::getProcessServiceFactory()->createInstance(
925 : 2420 : DEFINE_CONST_UNICODE("com.sun.star.document.DocumentProperties") ),
926 [ + - ][ + - ]: 2420 : uno::UNO_QUERY_THROW);
[ + - ][ + - ]
[ + - ]
927 [ + - ]: 2420 : m_pData->impl_setDocumentProperties(xDocProps);
928 : : }
929 : :
930 [ + - ]: 11871 : return m_pData->m_xDocumentProperties;
931 : : }
932 : :
933 : :
934 : : //________________________________________________________________________________________________________
935 : : // XEVENTLISTENER
936 : : //________________________________________________________________________________________________________
937 : :
938 : 0 : void SAL_CALL SfxBaseModel::disposing( const lang::EventObject& aObject )
939 : : throw(::com::sun::star::uno::RuntimeException)
940 : : {
941 [ # # ]: 0 : SolarMutexGuard aGuard;
942 [ # # ]: 0 : if ( impl_isDisposed() )
943 : 0 : return;
944 : :
945 [ # # ]: 0 : uno::Reference< XMODIFYLISTENER > xMod( aObject.Source, uno::UNO_QUERY );
946 [ # # ]: 0 : uno::Reference< XEVENTLISTENER > xListener( aObject.Source, uno::UNO_QUERY );
947 [ # # ]: 0 : uno::Reference< XDOCEVENTLISTENER > xDocListener( aObject.Source, uno::UNO_QUERY );
948 : :
949 [ # # ]: 0 : if ( xMod.is() )
950 [ # # ][ # # ]: 0 : m_pData->m_aInterfaceContainer.removeInterface( ::getCppuType((const uno::Reference< XMODIFYLISTENER >*)0), xMod );
951 [ # # ]: 0 : else if ( xListener.is() )
952 [ # # ][ # # ]: 0 : m_pData->m_aInterfaceContainer.removeInterface( ::getCppuType((const uno::Reference< XEVENTLISTENER >*)0), xListener );
953 [ # # ]: 0 : else if ( xDocListener.is() )
954 [ # # ][ # # ]: 0 : m_pData->m_aInterfaceContainer.removeInterface( ::getCppuType((const uno::Reference< XDOCEVENTLISTENER >*)0), xListener );
[ # # ][ # # ]
955 : : }
956 : :
957 : : //________________________________________________________________________________________________________
958 : : // frame::XModel
959 : : //________________________________________________________________________________________________________
960 : :
961 : 5610 : sal_Bool SAL_CALL SfxBaseModel::attachResource( const ::rtl::OUString& rURL ,
962 : : const uno::Sequence< beans::PropertyValue >& rArgs )
963 : : throw(::com::sun::star::uno::RuntimeException)
964 : : {
965 [ + - ]: 5610 : SfxModelGuard aGuard( *this, SfxModelGuard::E_INITIALIZING );
966 [ + + ][ + + ]: 5610 : if ( rURL.isEmpty() && rArgs.getLength() == 1 && rArgs[0].Name == "SetEmbedded" )
[ + + ][ + + ]
967 : : {
968 : : // allows to set a windowless document to EMBEDDED state
969 : : // but _only_ before load() or initNew() methods
970 [ + - ][ + - ]: 426 : if ( m_pData->m_pObjectShell.Is() && !m_pData->m_pObjectShell->GetMedium() )
[ + - ]
971 : : {
972 : 426 : sal_Bool bEmb = sal_Bool();
973 [ + - ][ + - ]: 426 : if ( ( rArgs[0].Value >>= bEmb ) && bEmb )
[ + - ]
974 [ + - ]: 426 : m_pData->m_pObjectShell->SetCreateMode_Impl( SFX_CREATE_MODE_EMBEDDED );
975 : : }
976 : :
977 : 426 : return sal_True;
978 : : }
979 : :
980 [ + - ]: 5184 : if ( m_pData->m_pObjectShell.Is() )
981 : : {
982 : 5184 : m_pData->m_sURL = rURL;
983 : :
984 : 5184 : SfxObjectShell* pObjectShell = m_pData->m_pObjectShell;
985 : :
986 [ + - ]: 5184 : ::comphelper::NamedValueCollection aArgs( rArgs );
987 : :
988 [ + - ]: 5184 : Sequence< sal_Int32 > aWinExtent;
989 [ + - ][ + - ]: 5184 : if ( ( aArgs.get( "WinExtent" ) >>= aWinExtent )&& ( aWinExtent.getLength() == 4 ) )
[ + + ][ + - ]
[ + + ]
990 : : {
991 [ + - ][ + - ]: 49 : Rectangle aVisArea( aWinExtent[0], aWinExtent[1], aWinExtent[2], aWinExtent[3] );
[ + - ][ + - ]
[ + - ]
992 [ + - ][ + - ]: 49 : aVisArea = OutputDevice::LogicToLogic( aVisArea, MAP_100TH_MM, pObjectShell->GetMapUnit() );
[ + - ][ + - ]
[ + - ][ + - ]
993 [ + - ]: 49 : pObjectShell->SetVisArea( aVisArea );
994 : : }
995 : :
996 : 5184 : sal_Bool bBreakMacroSign = sal_False;
997 [ + - ][ - + ]: 5184 : if ( aArgs.get( "BreakMacroSignature" ) >>= bBreakMacroSign )
998 : : {
999 [ # # ]: 0 : pObjectShell->BreakMacroSign_Impl( bBreakMacroSign );
1000 : : }
1001 : :
1002 [ + - ]: 5184 : aArgs.remove( "WinExtent" );
1003 [ + - ]: 5184 : aArgs.remove( "BreakMacroSignature" );
1004 [ + - ]: 5184 : aArgs.remove( "Stream" );
1005 [ + - ]: 5184 : aArgs.remove( "InputStream" );
1006 [ + - ]: 5184 : aArgs.remove( "URL" );
1007 [ + - ]: 5184 : aArgs.remove( "Frame" );
1008 [ + - ]: 5184 : aArgs.remove( "Password" );
1009 [ + - ]: 5184 : aArgs.remove( "EncryptionData" );
1010 : :
1011 : : // TODO/LATER: all the parameters that are accepted by ItemSet of the DocShell must be removed here
1012 : :
1013 [ + - ][ + - ]: 5184 : m_pData->m_seqArguments = aArgs.getPropertyValues();
[ + - ]
1014 : :
1015 : 5184 : SfxMedium* pMedium = pObjectShell->GetMedium();
1016 [ + - ]: 5184 : if ( pMedium )
1017 : : {
1018 [ + - ]: 5184 : SfxAllItemSet aSet( pObjectShell->GetPool() );
1019 [ + - ]: 5184 : TransformParameters( SID_OPENDOC, rArgs, aSet );
1020 : :
1021 : : // the arguments are not allowed to reach the medium
1022 [ + - ]: 5184 : aSet.ClearItem( SID_FILE_NAME );
1023 [ + - ]: 5184 : aSet.ClearItem( SID_FILLFRAME );
1024 : :
1025 [ + - ][ + - ]: 5184 : pMedium->GetItemSet()->Put( aSet );
1026 [ + - ][ + - ]: 5184 : SFX_ITEMSET_ARG( &aSet, pItem, SfxStringItem, SID_FILTER_NAME, sal_False );
1027 [ + + ]: 5184 : if ( pItem )
1028 : : pMedium->SetFilter(
1029 [ + - ][ + - ]: 1912 : pObjectShell->GetFactory().GetFilterContainer()->GetFilter4FilterName( pItem->GetValue() ) );
[ + - ][ + - ]
1030 : :
1031 [ + - ][ + - ]: 5184 : SFX_ITEMSET_ARG( &aSet, pTitleItem, SfxStringItem, SID_DOCINFO_TITLE, sal_False );
1032 [ - + ]: 5184 : if ( pTitleItem )
1033 : : {
1034 [ # # ]: 0 : SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pObjectShell );
1035 [ # # ]: 0 : if ( pFrame )
1036 [ # # ]: 0 : pFrame->UpdateTitle();
1037 [ + - ]: 5184 : }
1038 [ + - ][ + - ]: 5184 : }
1039 : : }
1040 : :
1041 [ + - ]: 5610 : return sal_True ;
1042 : : }
1043 : :
1044 : : //________________________________________________________________________________________________________
1045 : : // frame::XModel
1046 : : //________________________________________________________________________________________________________
1047 : :
1048 : 7065 : ::rtl::OUString SAL_CALL SfxBaseModel::getURL() throw(::com::sun::star::uno::RuntimeException)
1049 : : {
1050 [ + - ]: 7065 : SfxModelGuard aGuard( *this );
1051 [ + - ]: 7065 : return m_pData->m_sURL ;
1052 : : }
1053 : :
1054 : : //________________________________________________________________________________________________________
1055 : : // frame::XModel
1056 : : //________________________________________________________________________________________________________
1057 : :
1058 : 7327 : uno::Sequence< beans::PropertyValue > SAL_CALL SfxBaseModel::getArgs() throw(::com::sun::star::uno::RuntimeException)
1059 : : {
1060 [ + + ]: 7327 : SfxModelGuard aGuard( *this );
1061 [ + - ]: 6815 : if ( m_pData->m_pObjectShell.Is() )
1062 : : {
1063 [ + - ]: 6815 : uno::Sequence< beans::PropertyValue > seqArgsNew;
1064 [ + - ]: 6815 : uno::Sequence< beans::PropertyValue > seqArgsOld;
1065 [ + - ]: 6815 : SfxAllItemSet aSet( m_pData->m_pObjectShell->GetPool() );
1066 : :
1067 : : // we need to know which properties are supported by the transformer
1068 : : // hopefully it is a temporary solution, I guess nonconvertable properties
1069 : : // should not be supported so then there will be only ItemSet from medium
1070 : :
1071 [ + - ][ + - ]: 6815 : TransformItems( SID_OPENDOC, *(m_pData->m_pObjectShell->GetMedium()->GetItemSet()), seqArgsNew );
1072 [ + - ]: 6815 : TransformParameters( SID_OPENDOC, m_pData->m_seqArguments, aSet );
1073 [ + - ]: 6815 : TransformItems( SID_OPENDOC, aSet, seqArgsOld );
1074 : :
1075 : 6815 : sal_Int32 nOrgLength = m_pData->m_seqArguments.getLength();
1076 : 6815 : sal_Int32 nOldLength = seqArgsOld.getLength();
1077 : 6815 : sal_Int32 nNewLength = seqArgsNew.getLength();
1078 : :
1079 : : // "WinExtent" property should be updated always.
1080 : : // We can store it now to overwrite an old value
1081 : : // since it is not from ItemSet
1082 [ + - ]: 6815 : Rectangle aTmpRect = m_pData->m_pObjectShell->GetVisArea( ASPECT_CONTENT );
1083 [ + - ][ + - ]: 6815 : aTmpRect = OutputDevice::LogicToLogic( aTmpRect, m_pData->m_pObjectShell->GetMapUnit(), MAP_100TH_MM );
[ + - ][ + - ]
[ + - ][ + - ]
1084 : :
1085 [ + - ]: 6815 : Sequence< sal_Int32 > aRectSeq(4);
1086 [ + - ]: 6815 : aRectSeq[0] = aTmpRect.Left();
1087 [ + - ]: 6815 : aRectSeq[1] = aTmpRect.Top();
1088 [ + - ]: 6815 : aRectSeq[2] = aTmpRect.Right();
1089 [ + - ]: 6815 : aRectSeq[3] = aTmpRect.Bottom();
1090 : :
1091 [ + - ]: 6815 : seqArgsNew.realloc( ++nNewLength );
1092 [ + - ]: 6815 : seqArgsNew[ nNewLength - 1 ].Name = ::rtl::OUString("WinExtent");
1093 [ + - ][ + - ]: 6815 : seqArgsNew[ nNewLength - 1 ].Value <<= aRectSeq;
1094 : :
1095 [ + + ]: 6815 : if ( !m_pData->m_aPreusedFilterName.isEmpty() )
1096 : : {
1097 [ + - ]: 46 : seqArgsNew.realloc( ++nNewLength );
1098 [ + - ]: 46 : seqArgsNew[ nNewLength - 1 ].Name = ::rtl::OUString("PreusedFilterName");
1099 [ + - ][ + - ]: 46 : seqArgsNew[ nNewLength - 1 ].Value <<= m_pData->m_aPreusedFilterName;
1100 : : }
1101 : :
1102 [ + - ]: 6815 : SfxViewFrame* pFrame = SfxViewFrame::GetFirst( m_pData->m_pObjectShell );
1103 [ + + ]: 6815 : if ( pFrame )
1104 : : {
1105 [ + - ][ + - ]: 1774 : SvBorder aBorder = pFrame->GetBorderPixelImpl( pFrame->GetViewShell() );
1106 : :
1107 [ + - ]: 1774 : Sequence< sal_Int32 > aBorderSeq(4);
1108 [ + - ]: 1774 : aBorderSeq[0] = aBorder.Left();
1109 [ + - ]: 1774 : aBorderSeq[1] = aBorder.Top();
1110 [ + - ]: 1774 : aBorderSeq[2] = aBorder.Right();
1111 [ + - ]: 1774 : aBorderSeq[3] = aBorder.Bottom();
1112 : :
1113 [ + - ]: 1774 : seqArgsNew.realloc( ++nNewLength );
1114 [ + - ]: 1774 : seqArgsNew[ nNewLength - 1 ].Name = ::rtl::OUString("DocumentBorder");
1115 [ + - ][ + - ]: 1774 : seqArgsNew[ nNewLength - 1 ].Value <<= aBorderSeq;
[ + - ]
1116 : : }
1117 : :
1118 : : // only the values that are not supported by the ItemSet must be cached here
1119 [ + - ]: 6815 : uno::Sequence< beans::PropertyValue > aFinalCache;
1120 : 6815 : sal_Int32 nFinalLength = 0;
1121 : :
1122 [ + + ]: 26690 : for ( sal_Int32 nOrg = 0; nOrg < nOrgLength; nOrg++ )
1123 : : {
1124 : 19875 : sal_Int32 nOldInd = 0;
1125 [ + + ]: 62676 : while ( nOldInd < nOldLength )
1126 : : {
1127 [ + - ][ + - ]: 54287 : if ( m_pData->m_seqArguments[nOrg].Name.equals( seqArgsOld[nOldInd].Name ) )
[ + + ]
1128 : 11486 : break;
1129 : 42801 : nOldInd++;
1130 : : }
1131 : :
1132 [ + + ]: 19875 : if ( nOldInd == nOldLength )
1133 : : {
1134 : : // the entity with this name should be new for seqArgsNew
1135 : : // since it is not supported by transformer
1136 : :
1137 [ + - ]: 8389 : seqArgsNew.realloc( ++nNewLength );
1138 [ + - ][ + - ]: 8389 : seqArgsNew[ nNewLength - 1 ] = m_pData->m_seqArguments[nOrg];
1139 : :
1140 [ + - ]: 8389 : aFinalCache.realloc( ++nFinalLength );
1141 [ + - ][ + - ]: 8389 : aFinalCache[ nFinalLength - 1 ] = m_pData->m_seqArguments[nOrg];
1142 : : }
1143 : : }
1144 : :
1145 [ + - ]: 6815 : m_pData->m_seqArguments = aFinalCache;
1146 : :
1147 [ + - ][ + - ]: 6815 : return seqArgsNew;
[ + - ][ + - ]
[ + - ][ + - ]
1148 : : }
1149 : :
1150 [ # # ][ + - ]: 7327 : return m_pData->m_seqArguments;
1151 : : }
1152 : :
1153 : : //________________________________________________________________________________________________________
1154 : : // frame::XModel
1155 : : //________________________________________________________________________________________________________
1156 : :
1157 : 1733 : void SAL_CALL SfxBaseModel::connectController( const uno::Reference< frame::XController >& xController )
1158 : : throw(::com::sun::star::uno::RuntimeException)
1159 : : {
1160 [ + - ]: 1733 : SfxModelGuard aGuard( *this );
1161 : : OSL_PRECOND( xController.is(), "SfxBaseModel::connectController: invalid controller!" );
1162 [ - + ]: 1733 : if ( !xController.is() )
1163 : 1733 : return;
1164 : :
1165 : 1733 : sal_uInt32 nOldCount = m_pData->m_seqControllers.getLength();
1166 [ + - ]: 1733 : uno::Sequence< uno::Reference< frame::XController > > aNewSeq( nOldCount + 1 );
1167 [ + + ]: 1757 : for ( sal_uInt32 n = 0; n < nOldCount; n++ )
1168 [ + - ][ + - ]: 24 : aNewSeq.getArray()[n] = m_pData->m_seqControllers.getConstArray()[n];
1169 [ + - ][ + - ]: 1733 : aNewSeq.getArray()[nOldCount] = xController;
1170 [ + - ]: 1733 : m_pData->m_seqControllers = aNewSeq;
1171 : :
1172 [ + + ]: 1733 : if ( m_pData->m_seqControllers.getLength() == 1 )
1173 : : {
1174 [ + - ][ + - ]: 1709 : SfxViewFrame* pViewFrame = SfxViewFrame::Get( xController, GetObjectShell() );
1175 [ - + ][ # # ]: 1709 : ENSURE_OR_THROW( pViewFrame, "SFX document without SFX view!?" );
[ # # ][ # # ]
1176 [ + - ]: 1709 : bool bOldLock = pViewFrame->GetDispatcher()->IsLocked();
1177 [ + - ]: 1709 : pViewFrame->GetDispatcher()->Lock(sal_True);
1178 [ + - ]: 1709 : pViewFrame->UpdateDocument_Impl();
1179 [ + - ]: 1709 : pViewFrame->GetDispatcher()->Lock(bOldLock);
1180 [ + - ][ + - ]: 1709 : const String sDocumentURL = GetObjectShell()->GetMedium()->GetName();
[ + - ]
1181 [ + + ]: 1709 : if ( sDocumentURL.Len() )
1182 [ + - ][ + - ]: 1709 : SFX_APP()->Broadcast( SfxStringHint( SID_OPENURL, sDocumentURL ) );
[ + - ][ + - ]
[ + - ]
1183 [ + - ][ + - ]: 1733 : }
[ + - ]
1184 : : }
1185 : :
1186 : : //________________________________________________________________________________________________________
1187 : : // frame::XModel
1188 : : //________________________________________________________________________________________________________
1189 : :
1190 : 1639 : void SAL_CALL SfxBaseModel::disconnectController( const uno::Reference< frame::XController >& xController ) throw(::com::sun::star::uno::RuntimeException)
1191 : : {
1192 [ + - ]: 1639 : SfxModelGuard aGuard( *this );
1193 : :
1194 : 1639 : sal_uInt32 nOldCount = m_pData->m_seqControllers.getLength();
1195 [ - + ]: 1639 : if ( !nOldCount )
1196 : 1639 : return;
1197 : :
1198 [ + - ]: 1639 : uno::Sequence< uno::Reference< frame::XController > > aNewSeq( nOldCount - 1 );
1199 [ + + ]: 3302 : for ( sal_uInt32 nOld = 0, nNew = 0; nOld < nOldCount; ++nOld )
1200 : : {
1201 [ + - ][ + + ]: 1663 : if ( xController != m_pData->m_seqControllers.getConstArray()[nOld] )
1202 : : {
1203 [ + - ][ + - ]: 24 : aNewSeq.getArray()[nNew] = m_pData->m_seqControllers.getConstArray()[nOld];
1204 : 24 : ++nNew;
1205 : : }
1206 : : }
1207 : :
1208 [ + - ]: 1639 : m_pData->m_seqControllers = aNewSeq;
1209 : :
1210 [ + - ][ + + ]: 1639 : if ( xController == m_pData->m_xCurrent )
1211 [ + - ][ + - ]: 1639 : m_pData->m_xCurrent = uno::Reference< frame::XController > ();
[ + - ][ + - ]
1212 : : }
1213 : :
1214 : : namespace
1215 : : {
1216 : : typedef ::cppu::WeakImplHelper1< XUndoAction > ControllerLockUndoAction_Base;
1217 [ # # ]: 0 : class ControllerLockUndoAction : public ControllerLockUndoAction_Base
1218 : : {
1219 : : public:
1220 : 0 : ControllerLockUndoAction( const Reference< XModel >& i_model, const bool i_undoIsUnlock )
1221 : : :m_xModel( i_model )
1222 : 0 : ,m_bUndoIsUnlock( i_undoIsUnlock )
1223 : : {
1224 : 0 : }
1225 : :
1226 : : // XUndoAction
1227 : : virtual ::rtl::OUString SAL_CALL getTitle() throw (RuntimeException);
1228 : : virtual void SAL_CALL undo( ) throw (UndoFailedException, RuntimeException);
1229 : : virtual void SAL_CALL redo( ) throw (UndoFailedException, RuntimeException);
1230 : :
1231 : : private:
1232 : : const Reference< XModel > m_xModel;
1233 : : const bool m_bUndoIsUnlock;
1234 : : };
1235 : :
1236 : 0 : ::rtl::OUString SAL_CALL ControllerLockUndoAction::getTitle() throw (RuntimeException)
1237 : : {
1238 : : // this action is intended to be used within an UndoContext only, so nobody will ever see this title ...
1239 : 0 : return ::rtl::OUString();
1240 : : }
1241 : :
1242 : 0 : void SAL_CALL ControllerLockUndoAction::undo( ) throw (UndoFailedException, RuntimeException)
1243 : : {
1244 [ # # ]: 0 : if ( m_bUndoIsUnlock )
1245 : 0 : m_xModel->unlockControllers();
1246 : : else
1247 : 0 : m_xModel->lockControllers();
1248 : 0 : }
1249 : :
1250 : 0 : void SAL_CALL ControllerLockUndoAction::redo( ) throw (UndoFailedException, RuntimeException)
1251 : : {
1252 [ # # ]: 0 : if ( m_bUndoIsUnlock )
1253 : 0 : m_xModel->lockControllers();
1254 : : else
1255 : 0 : m_xModel->unlockControllers();
1256 : 0 : }
1257 : : }
1258 : :
1259 : : //________________________________________________________________________________________________________
1260 : : // frame::XModel
1261 : : //________________________________________________________________________________________________________
1262 : :
1263 : 25 : void SAL_CALL SfxBaseModel::lockControllers() throw(::com::sun::star::uno::RuntimeException)
1264 : : {
1265 [ + - ]: 25 : SfxModelGuard aGuard( *this );
1266 : :
1267 : 25 : ++m_pData->m_nControllerLockCount ;
1268 : :
1269 [ - + ][ # # ]: 25 : if ( m_pData->m_pDocumentUndoManager.is()
[ # # ][ - + ]
1270 [ # # ]: 0 : && m_pData->m_pDocumentUndoManager->isInContext()
1271 [ # # ]: 0 : && !m_pData->m_pDocumentUndoManager->isLocked()
1272 : : )
1273 : : {
1274 [ # # ][ # # ]: 0 : m_pData->m_pDocumentUndoManager->addUndoAction( new ControllerLockUndoAction( this, true ) );
[ # # ][ # # ]
[ # # ]
1275 [ + - ]: 25 : }
1276 : 25 : }
1277 : :
1278 : : //________________________________________________________________________________________________________
1279 : : // frame::XModel
1280 : : //________________________________________________________________________________________________________
1281 : :
1282 : 25 : void SAL_CALL SfxBaseModel::unlockControllers() throw(::com::sun::star::uno::RuntimeException)
1283 : : {
1284 [ + - ]: 25 : SfxModelGuard aGuard( *this );
1285 : :
1286 : 25 : --m_pData->m_nControllerLockCount ;
1287 : :
1288 [ - + ][ # # ]: 25 : if ( m_pData->m_pDocumentUndoManager.is()
[ # # ][ - + ]
1289 [ # # ]: 0 : && m_pData->m_pDocumentUndoManager->isInContext()
1290 [ # # ]: 0 : && !m_pData->m_pDocumentUndoManager->isLocked()
1291 : : )
1292 : : {
1293 [ # # ][ # # ]: 0 : m_pData->m_pDocumentUndoManager->addUndoAction( new ControllerLockUndoAction( this, false ) );
[ # # ][ # # ]
[ # # ]
1294 [ + - ]: 25 : }
1295 : 25 : }
1296 : :
1297 : : //________________________________________________________________________________________________________
1298 : : // frame::XModel
1299 : : //________________________________________________________________________________________________________
1300 : :
1301 : 171 : sal_Bool SAL_CALL SfxBaseModel::hasControllersLocked() throw(::com::sun::star::uno::RuntimeException)
1302 : : {
1303 [ + - ]: 171 : SfxModelGuard aGuard( *this );
1304 [ + - ]: 171 : return ( m_pData->m_nControllerLockCount != 0 ) ;
1305 : : }
1306 : :
1307 : : //________________________________________________________________________________________________________
1308 : : // frame::XModel
1309 : : //________________________________________________________________________________________________________
1310 : :
1311 : 2721 : uno::Reference< frame::XController > SAL_CALL SfxBaseModel::getCurrentController() throw(::com::sun::star::uno::RuntimeException)
1312 : : {
1313 [ + - ]: 2721 : SfxModelGuard aGuard( *this );
1314 : :
1315 : : // get the last active controller of this model
1316 [ + + ]: 2721 : if ( m_pData->m_xCurrent.is() )
1317 : 2274 : return m_pData->m_xCurrent;
1318 : :
1319 : : // get the first controller of this model
1320 [ + + ][ + - ]: 2721 : return m_pData->m_seqControllers.getLength() ? m_pData->m_seqControllers.getConstArray()[0] : m_pData->m_xCurrent;
1321 : : }
1322 : :
1323 : : //________________________________________________________________________________________________________
1324 : : // frame::XModel
1325 : : //________________________________________________________________________________________________________
1326 : :
1327 : 3444 : void SAL_CALL SfxBaseModel::setCurrentController( const uno::Reference< frame::XController >& xCurrentController )
1328 : : throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException)
1329 : : {
1330 [ + - ]: 3444 : SfxModelGuard aGuard( *this );
1331 : :
1332 [ + - ][ + - ]: 3444 : m_pData->m_xCurrent = xCurrentController;
1333 : 3444 : }
1334 : :
1335 : : //________________________________________________________________________________________________________
1336 : : // frame::XModel
1337 : : //________________________________________________________________________________________________________
1338 : :
1339 : 7 : uno::Reference< uno::XInterface > SAL_CALL SfxBaseModel::getCurrentSelection() throw(::com::sun::star::uno::RuntimeException)
1340 : : {
1341 [ + - ]: 7 : SfxModelGuard aGuard( *this );
1342 : :
1343 : 7 : uno::Reference< uno::XInterface > xReturn;
1344 [ + - ]: 7 : uno::Reference< frame::XController > xController = getCurrentController() ;
1345 : :
1346 [ + - ]: 7 : if ( xController.is() )
1347 : : {
1348 [ + - ]: 7 : uno::Reference< view::XSelectionSupplier > xDocView( xController, uno::UNO_QUERY );
1349 [ + - ]: 7 : if ( xDocView.is() )
1350 : : {
1351 [ + - ][ + - ]: 7 : uno::Any xSel = xDocView->getSelection();
1352 [ + - ]: 7 : xSel >>= xReturn ;
1353 : 7 : }
1354 : : }
1355 : :
1356 [ + - ]: 7 : return xReturn ;
1357 : : }
1358 : :
1359 : : //________________________________________________________________________________________________________
1360 : : // XModifiable2
1361 : : //________________________________________________________________________________________________________
1362 : :
1363 : 0 : sal_Bool SAL_CALL SfxBaseModel::disableSetModified() throw (::com::sun::star::uno::RuntimeException)
1364 : : {
1365 [ # # ]: 0 : SfxModelGuard aGuard( *this );
1366 : :
1367 [ # # ]: 0 : if ( !m_pData->m_pObjectShell.Is() )
1368 [ # # ]: 0 : throw uno::RuntimeException();
1369 : :
1370 [ # # ]: 0 : sal_Bool bResult = m_pData->m_pObjectShell->IsEnableSetModified();
1371 [ # # ]: 0 : m_pData->m_pObjectShell->EnableSetModified( sal_False );
1372 : :
1373 [ # # ]: 0 : return bResult;
1374 : : }
1375 : :
1376 : 0 : sal_Bool SAL_CALL SfxBaseModel::enableSetModified() throw (::com::sun::star::uno::RuntimeException)
1377 : : {
1378 [ # # ]: 0 : SfxModelGuard aGuard( *this );
1379 : :
1380 [ # # ]: 0 : if ( !m_pData->m_pObjectShell.Is() )
1381 [ # # ]: 0 : throw uno::RuntimeException();
1382 : :
1383 [ # # ]: 0 : sal_Bool bResult = m_pData->m_pObjectShell->IsEnableSetModified();
1384 [ # # ]: 0 : m_pData->m_pObjectShell->EnableSetModified( sal_True );
1385 : :
1386 [ # # ]: 0 : return bResult;
1387 : : }
1388 : :
1389 : 0 : sal_Bool SAL_CALL SfxBaseModel::isSetModifiedEnabled() throw (::com::sun::star::uno::RuntimeException)
1390 : : {
1391 [ # # ]: 0 : SfxModelGuard aGuard( *this );
1392 : :
1393 [ # # ]: 0 : if ( !m_pData->m_pObjectShell.Is() )
1394 [ # # ]: 0 : throw uno::RuntimeException();
1395 : :
1396 [ # # ][ # # ]: 0 : return m_pData->m_pObjectShell->IsEnableSetModified();
1397 : : }
1398 : :
1399 : : //________________________________________________________________________________________________________
1400 : : // XModifiable
1401 : : //________________________________________________________________________________________________________
1402 : :
1403 : 114687 : sal_Bool SAL_CALL SfxBaseModel::isModified() throw(::com::sun::star::uno::RuntimeException)
1404 : : {
1405 [ + - ]: 114687 : SfxModelGuard aGuard( *this );
1406 : :
1407 [ + - ][ + - ]: 114687 : return m_pData->m_pObjectShell.Is() ? m_pData->m_pObjectShell->IsModified() : sal_False;
[ + - ]
1408 : : }
1409 : :
1410 : : //________________________________________________________________________________________________________
1411 : : // XModifiable
1412 : : //________________________________________________________________________________________________________
1413 : :
1414 : 2558 : void SAL_CALL SfxBaseModel::setModified( sal_Bool bModified )
1415 : : throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::uno::RuntimeException)
1416 : : {
1417 [ + + ]: 2558 : SfxModelGuard aGuard( *this );
1418 : :
1419 [ + - ]: 2467 : if ( m_pData->m_pObjectShell.Is() )
1420 [ + - ][ + - ]: 2558 : m_pData->m_pObjectShell->SetModified(bModified);
1421 : 2467 : }
1422 : :
1423 : : //________________________________________________________________________________________________________
1424 : : // XModifiable
1425 : : //________________________________________________________________________________________________________
1426 : :
1427 : 2795 : void SAL_CALL SfxBaseModel::addModifyListener(const uno::Reference< XMODIFYLISTENER >& xListener) throw( uno::RuntimeException )
1428 : : {
1429 [ + - ]: 2795 : SfxModelGuard aGuard( *this, SfxModelGuard::E_INITIALIZING );
1430 : :
1431 [ + - ][ + - ]: 2795 : m_pData->m_aInterfaceContainer.addInterface( ::getCppuType((const uno::Reference< XMODIFYLISTENER >*)0),xListener );
[ + - ]
1432 : 2795 : }
1433 : :
1434 : : //________________________________________________________________________________________________________
1435 : : // XModifiable
1436 : : //________________________________________________________________________________________________________
1437 : :
1438 : 3 : void SAL_CALL SfxBaseModel::removeModifyListener(const uno::Reference< XMODIFYLISTENER >& xListener) throw( uno::RuntimeException )
1439 : : {
1440 [ + - ]: 3 : SfxModelGuard aGuard( *this );
1441 : :
1442 [ + - ][ + - ]: 3 : m_pData->m_aInterfaceContainer.removeInterface( ::getCppuType((const uno::Reference< XMODIFYLISTENER >*)0), xListener );
[ + - ]
1443 : 3 : }
1444 : :
1445 : : //____________________________________________________________________________________________________
1446 : : // XCloseable
1447 : : //____________________________________________________________________________________________________
1448 : :
1449 : 5039 : void SAL_CALL SfxBaseModel::close( sal_Bool bDeliverOwnership ) throw (util::CloseVetoException, uno::RuntimeException)
1450 : : {
1451 [ + - ]: 5039 : SolarMutexGuard aGuard;
1452 [ + + ][ + + ]: 5039 : if ( impl_isDisposed() || m_pData->m_bClosed || m_pData->m_bClosing )
[ + + ][ + + ]
1453 : 5039 : return;
1454 : :
1455 [ + - ]: 2708 : uno::Reference< uno::XInterface > xSelfHold( static_cast< ::cppu::OWeakObject* >(this) );
1456 [ + - ][ + - ]: 2708 : lang::EventObject aSource (static_cast< ::cppu::OWeakObject*>(this));
1457 [ + - ][ + - ]: 2708 : ::cppu::OInterfaceContainerHelper* pContainer = m_pData->m_aInterfaceContainer.getContainer( ::getCppuType( ( const uno::Reference< util::XCloseListener >*) NULL ) );
1458 [ + - ]: 2708 : if (pContainer!=NULL)
1459 : : {
1460 [ + - ]: 2708 : ::cppu::OInterfaceIteratorHelper pIterator(*pContainer);
1461 [ + + ]: 7635 : while (pIterator.hasMoreElements())
1462 : : {
1463 : : try
1464 : : {
1465 [ + - ][ + - ]: 4927 : ((util::XCloseListener*)pIterator.next())->queryClosing( aSource, bDeliverOwnership );
1466 : : }
1467 [ # # # # ]: 0 : catch( uno::RuntimeException& )
1468 : : {
1469 [ # # ]: 0 : pIterator.remove();
1470 : : }
1471 [ + - ]: 2708 : }
1472 : : }
1473 : :
1474 [ - + ]: 2708 : if ( m_pData->m_bSaving )
1475 : : {
1476 [ # # ]: 0 : if (bDeliverOwnership)
1477 : 0 : m_pData->m_bSuicide = sal_True;
1478 : : throw util::CloseVetoException(
1479 : : ::rtl::OUString("Cant close while saving."),
1480 [ # # ][ # # ]: 0 : static_cast< ::com::sun::star::util::XCloseable* >(this));
1481 : : }
1482 : :
1483 : : // no own objections against closing!
1484 : 2708 : m_pData->m_bClosing = sal_True;
1485 [ + - ][ + - ]: 2708 : pContainer = m_pData->m_aInterfaceContainer.getContainer( ::getCppuType( ( const uno::Reference< util::XCloseListener >*) NULL ) );
1486 [ + - ]: 2708 : if (pContainer!=NULL)
1487 : : {
1488 [ + - ]: 2708 : ::cppu::OInterfaceIteratorHelper pCloseIterator(*pContainer);
1489 [ + + ]: 7635 : while (pCloseIterator.hasMoreElements())
1490 : : {
1491 : : try
1492 : : {
1493 [ + - ][ + - ]: 4927 : ((util::XCloseListener*)pCloseIterator.next())->notifyClosing( aSource );
1494 : : }
1495 [ # # # # ]: 0 : catch( uno::RuntimeException& )
1496 : : {
1497 [ # # ]: 0 : pCloseIterator.remove();
1498 : : }
1499 [ + - ]: 2708 : }
1500 : : }
1501 : :
1502 : 2708 : m_pData->m_bClosed = sal_True;
1503 : 2708 : m_pData->m_bClosing = sal_False;
1504 : :
1505 [ + - ][ + - ]: 5039 : dispose();
[ + - ][ + + ]
1506 : : }
1507 : :
1508 : : //____________________________________________________________________________________________________
1509 : : // XCloseBroadcaster
1510 : : //____________________________________________________________________________________________________
1511 : :
1512 : 5455 : void SAL_CALL SfxBaseModel::addCloseListener( const uno::Reference< XCLOSELISTENER >& xListener ) throw (uno::RuntimeException)
1513 : : {
1514 [ + - ]: 5455 : SfxModelGuard aGuard( *this, SfxModelGuard::E_INITIALIZING );
1515 : :
1516 [ + - ][ + - ]: 5455 : m_pData->m_aInterfaceContainer.addInterface( ::getCppuType((const uno::Reference< XCLOSELISTENER >*)0), xListener );
[ + - ]
1517 : 5455 : }
1518 : :
1519 : : //____________________________________________________________________________________________________
1520 : : // XCloseBroadcaster
1521 : : //____________________________________________________________________________________________________
1522 : :
1523 : 1889 : void SAL_CALL SfxBaseModel::removeCloseListener( const uno::Reference< XCLOSELISTENER >& xListener ) throw (uno::RuntimeException)
1524 : : {
1525 [ + - ]: 1889 : SfxModelGuard aGuard( *this );
1526 : :
1527 [ + - ][ + - ]: 1889 : m_pData->m_aInterfaceContainer.removeInterface( ::getCppuType((const uno::Reference< XCLOSELISTENER >*)0), xListener );
[ + - ]
1528 : 1889 : }
1529 : :
1530 : : //________________________________________________________________________________________________________
1531 : : // XPrintable
1532 : : //________________________________________________________________________________________________________
1533 : :
1534 : 0 : uno::Sequence< beans::PropertyValue > SAL_CALL SfxBaseModel::getPrinter() throw(::com::sun::star::uno::RuntimeException)
1535 : : {
1536 [ # # ]: 0 : SfxModelGuard aGuard( *this );
1537 : :
1538 [ # # ][ # # ]: 0 : if ( impl_getPrintHelper() )
1539 [ # # ][ # # ]: 0 : return m_pData->m_xPrintable->getPrinter();
1540 : : else
1541 [ # # ][ # # ]: 0 : return uno::Sequence< beans::PropertyValue >();
1542 : : }
1543 : :
1544 : 0 : void SAL_CALL SfxBaseModel::setPrinter(const uno::Sequence< beans::PropertyValue >& rPrinter)
1545 : : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
1546 : : {
1547 [ # # ]: 0 : SfxModelGuard aGuard( *this );
1548 : :
1549 [ # # ][ # # ]: 0 : if ( impl_getPrintHelper() )
1550 [ # # ][ # # ]: 0 : m_pData->m_xPrintable->setPrinter( rPrinter );
[ # # ]
1551 : 0 : }
1552 : :
1553 : 0 : void SAL_CALL SfxBaseModel::print(const uno::Sequence< beans::PropertyValue >& rOptions)
1554 : : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
1555 : : {
1556 [ # # ]: 0 : SfxModelGuard aGuard( *this );
1557 : :
1558 [ # # ][ # # ]: 0 : if ( impl_getPrintHelper() )
1559 [ # # ][ # # ]: 0 : m_pData->m_xPrintable->print( rOptions );
[ # # ]
1560 : 0 : }
1561 : :
1562 : : //________________________________________________________________________________________________________
1563 : : // XStorable
1564 : : //________________________________________________________________________________________________________
1565 : :
1566 : 0 : sal_Bool SAL_CALL SfxBaseModel::hasLocation() throw(::com::sun::star::uno::RuntimeException)
1567 : : {
1568 [ # # ]: 0 : SfxModelGuard aGuard( *this );
1569 : :
1570 [ # # ][ # # ]: 0 : return m_pData->m_pObjectShell.Is() ? m_pData->m_pObjectShell->HasName() : sal_False;
1571 : : }
1572 : :
1573 : : //________________________________________________________________________________________________________
1574 : : // XStorable
1575 : : //________________________________________________________________________________________________________
1576 : :
1577 : 6118 : ::rtl::OUString SAL_CALL SfxBaseModel::getLocation() throw(::com::sun::star::uno::RuntimeException)
1578 : : {
1579 [ + - ]: 6118 : SfxModelGuard aGuard( *this );
1580 : :
1581 [ + - ]: 6118 : if ( m_pData->m_pObjectShell.Is() )
1582 : : {
1583 : : // TODO/LATER: is it correct that the shared document returns shared file location?
1584 [ + - ][ - + ]: 6118 : if ( m_pData->m_pObjectShell->IsDocShared() )
1585 [ # # ]: 0 : return m_pData->m_pObjectShell->GetSharedFileURL();
1586 : : else
1587 [ + - ]: 6118 : return ::rtl::OUString(m_pData->m_pObjectShell->GetMedium()->GetName());
1588 : : }
1589 : :
1590 [ + - ]: 6118 : return m_pData->m_sURL;
1591 : : }
1592 : :
1593 : : //________________________________________________________________________________________________________
1594 : : // XStorable
1595 : : //________________________________________________________________________________________________________
1596 : :
1597 : 0 : sal_Bool SAL_CALL SfxBaseModel::isReadonly() throw(::com::sun::star::uno::RuntimeException)
1598 : : {
1599 [ # # ]: 0 : SfxModelGuard aGuard( *this );
1600 : :
1601 [ # # ][ # # ]: 0 : return m_pData->m_pObjectShell.Is() ? m_pData->m_pObjectShell->IsReadOnly() : sal_True;
[ # # ]
1602 : : }
1603 : :
1604 : : //________________________________________________________________________________________________________
1605 : : // XStorable2
1606 : : //________________________________________________________________________________________________________
1607 : :
1608 : 0 : void SAL_CALL SfxBaseModel::storeSelf( const uno::Sequence< beans::PropertyValue >& aSeqArgs )
1609 : : throw ( ::com::sun::star::lang::IllegalArgumentException,
1610 : : ::com::sun::star::io::IOException,
1611 : : ::com::sun::star::uno::RuntimeException )
1612 : : {
1613 [ # # ]: 0 : RTL_LOGFILE_PRODUCT_CONTEXT( aPerfLog, "PERFORMANCE - SfxBaseModel::storeSelf" );
1614 : :
1615 [ # # ]: 0 : SfxModelGuard aGuard( *this );
1616 : :
1617 [ # # ]: 0 : if ( m_pData->m_pObjectShell.Is() )
1618 : : {
1619 [ # # ]: 0 : m_pData->m_pObjectShell->AddLog( ::rtl::OUString( OSL_LOG_PREFIX "storeSelf" ) );
1620 [ # # ][ # # ]: 0 : SfxSaveGuard aSaveGuard(this, m_pData, sal_False);
1621 : :
1622 [ # # ]: 0 : for ( sal_Int32 nInd = 0; nInd < aSeqArgs.getLength(); nInd++ )
1623 : : {
1624 : : // check that only acceptable parameters are provided here
1625 [ # # ][ # # : 0 : if ( aSeqArgs[nInd].Name != "VersionComment" && aSeqArgs[nInd].Name != "Author"
# # # # ]
[ # # ]
1626 : 0 : && aSeqArgs[nInd].Name != "InteractionHandler" && aSeqArgs[nInd].Name != "StatusIndicator" )
1627 : : {
1628 [ # # ]: 0 : m_pData->m_pObjectShell->AddLog( ::rtl::OUString( OSL_LOG_PREFIX "unexpected parameter for storeSelf, might be no problem if SaveAs is executed." ) );
1629 [ # # ]: 0 : m_pData->m_pObjectShell->StoreLog();
1630 : :
1631 : 0 : ::rtl::OUString aMessage( "Unexpected MediaDescriptor parameter: " );
1632 : 0 : aMessage += aSeqArgs[nInd].Name;
1633 [ # # ]: 0 : throw lang::IllegalArgumentException( aMessage, uno::Reference< uno::XInterface >(), 1 );
1634 : : }
1635 : : }
1636 : :
1637 [ # # ][ # # ]: 0 : SfxAllItemSet *pParams = new SfxAllItemSet( SFX_APP()->GetPool() );
[ # # ]
1638 [ # # ]: 0 : TransformParameters( SID_SAVEDOC, aSeqArgs, *pParams );
1639 : :
1640 [ # # ][ # # ]: 0 : SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_SAVEDOC, GlobalEventConfig::GetEventName(STR_EVENT_SAVEDOC), m_pData->m_pObjectShell ) );
[ # # ][ # # ]
[ # # ]
1641 : :
1642 : 0 : sal_Bool bRet = sal_False;
1643 : :
1644 : : // TODO/LATER: let the embedded case of saving be handled more careful
1645 [ # # ]: 0 : if ( m_pData->m_pObjectShell->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
1646 : : {
1647 : : // If this is an embedded object that has no URL based location it should be stored to own storage.
1648 : : // An embedded object can have a location based on URL in case it is a link, then it should be
1649 : : // stored in normal way.
1650 [ # # ][ # # ]: 0 : if ( !hasLocation() || getLocation().compareToAscii( "private:", 8 ) == 0 )
[ # # ][ # # ]
[ # # ]
[ # # # # ]
1651 : : {
1652 : : // actually in this very rare case only UI parameters have sence
1653 : : // TODO/LATER: should be done later, after integration of sb19
1654 [ # # ]: 0 : bRet = m_pData->m_pObjectShell->DoSave()
1655 [ # # ][ # # ]: 0 : && m_pData->m_pObjectShell->DoSaveCompleted();
[ # # ]
1656 : : }
1657 : : else
1658 : : {
1659 [ # # ]: 0 : bRet = m_pData->m_pObjectShell->Save_Impl( pParams );
1660 : : }
1661 : : }
1662 : : else
1663 [ # # ]: 0 : bRet = m_pData->m_pObjectShell->Save_Impl( pParams );
1664 : :
1665 [ # # ][ # # ]: 0 : DELETEZ( pParams );
1666 : :
1667 [ # # ]: 0 : sal_uInt32 nErrCode = m_pData->m_pObjectShell->GetError() ? m_pData->m_pObjectShell->GetError()
1668 [ # # # # ]: 0 : : ERRCODE_IO_CANTWRITE;
1669 [ # # ]: 0 : m_pData->m_pObjectShell->ResetError();
1670 : :
1671 [ # # ]: 0 : if ( bRet )
1672 : : {
1673 [ # # ]: 0 : m_pData->m_pObjectShell->AddLog( ::rtl::OUString( OSL_LOG_PREFIX "successful saving." ) );
1674 [ # # ]: 0 : m_pData->m_aPreusedFilterName = GetMediumFilterName_Impl();
1675 : :
1676 [ # # ][ # # ]: 0 : SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_SAVEDOCDONE, GlobalEventConfig::GetEventName(STR_EVENT_SAVEDOCDONE), m_pData->m_pObjectShell ) );
[ # # ][ # # ]
[ # # ]
1677 : : }
1678 : : else
1679 : : {
1680 [ # # ]: 0 : m_pData->m_pObjectShell->AddLog( ::rtl::OUString( OSL_LOG_PREFIX "Storing failed!" ) );
1681 [ # # ]: 0 : m_pData->m_pObjectShell->StoreLog();
1682 : :
1683 : : // write the contents of the logger to the file
1684 [ # # ][ # # ]: 0 : SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_SAVEDOCFAILED, GlobalEventConfig::GetEventName(STR_EVENT_SAVEDOCFAILED), m_pData->m_pObjectShell ) );
[ # # ][ # # ]
[ # # ]
1685 : :
1686 [ # # ]: 0 : throw task::ErrorCodeIOException( ::rtl::OUString(), uno::Reference< uno::XInterface >(), nErrCode );
1687 [ # # ]: 0 : }
1688 [ # # ][ # # ]: 0 : }
1689 : :
1690 : 0 : }
1691 : :
1692 : : //________________________________________________________________________________________________________
1693 : : // XStorable
1694 : : //________________________________________________________________________________________________________
1695 : :
1696 : 0 : void SAL_CALL SfxBaseModel::store() throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
1697 : : {
1698 [ # # ]: 0 : storeSelf( uno::Sequence< beans::PropertyValue >() );
1699 : 0 : }
1700 : :
1701 : : //________________________________________________________________________________________________________
1702 : : // XStorable
1703 : : //________________________________________________________________________________________________________
1704 : :
1705 : 18 : void SAL_CALL SfxBaseModel::storeAsURL( const ::rtl::OUString& rURL ,
1706 : : const uno::Sequence< beans::PropertyValue >& rArgs )
1707 : : throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
1708 : : {
1709 [ + - ]: 18 : RTL_LOGFILE_PRODUCT_CONTEXT( aPerfLog, "PERFORMANCE - SfxBaseModel::storeAsURL" );
1710 : :
1711 [ + - ]: 18 : SfxModelGuard aGuard( *this );
1712 : :
1713 [ + - ]: 18 : if ( m_pData->m_pObjectShell.Is() )
1714 : : {
1715 [ + - ]: 18 : m_pData->m_pObjectShell->AddLog( ::rtl::OUString( OSL_LOG_PREFIX "storeAsURL" ) );
1716 [ + - ][ + - ]: 18 : SfxSaveGuard aSaveGuard(this, m_pData, sal_False);
1717 : :
1718 [ + - ]: 18 : impl_store( rURL, rArgs, sal_False );
1719 : :
1720 [ + - ]: 18 : uno::Sequence< beans::PropertyValue > aSequence ;
1721 [ + - ][ + - ]: 18 : TransformItems( SID_OPENDOC, *m_pData->m_pObjectShell->GetMedium()->GetItemSet(), aSequence );
1722 [ + - ][ + - ]: 18 : attachResource( rURL, aSequence );
[ + - ]
1723 : :
1724 : : #if OSL_DEBUG_LEVEL > 0
1725 : : SFX_ITEMSET_ARG( m_pData->m_pObjectShell->GetMedium()->GetItemSet(), pPasswdItem, SfxStringItem, SID_PASSWORD, sal_False);
1726 : : OSL_ENSURE( !pPasswdItem, "There should be no Password property in the document MediaDescriptor!" );
1727 : : #endif
1728 [ + - ][ + - ]: 18 : }
1729 : 18 : }
1730 : :
1731 : : //________________________________________________________________________________________________________
1732 : : // XUndoManagerSupplier
1733 : : //________________________________________________________________________________________________________
1734 : 61 : Reference< XUndoManager > SAL_CALL SfxBaseModel::getUndoManager( ) throw (RuntimeException)
1735 : : {
1736 [ + - ]: 61 : SfxModelGuard aGuard( *this );
1737 [ + + ]: 61 : if ( !m_pData->m_pDocumentUndoManager.is() )
1738 [ + - ][ + - ]: 21 : m_pData->m_pDocumentUndoManager.set( new ::sfx2::DocumentUndoManager( *this ) );
1739 [ + - ][ + - ]: 61 : return m_pData->m_pDocumentUndoManager.get();
[ + - ]
1740 : : }
1741 : :
1742 : : //________________________________________________________________________________________________________
1743 : : // XStorable
1744 : : //________________________________________________________________________________________________________
1745 : :
1746 : 159 : void SAL_CALL SfxBaseModel::storeToURL( const ::rtl::OUString& rURL ,
1747 : : const uno::Sequence< beans::PropertyValue >& rArgs )
1748 : : throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
1749 : : {
1750 [ + - ]: 159 : SfxModelGuard aGuard( *this );
1751 : :
1752 [ + - ]: 159 : if ( m_pData->m_pObjectShell.Is() )
1753 : : {
1754 [ + - ]: 159 : m_pData->m_pObjectShell->AddLog( ::rtl::OUString( OSL_LOG_PREFIX "storeToURL" ) );
1755 [ + - ][ + - ]: 159 : SfxSaveGuard aSaveGuard(this, m_pData, sal_False);
1756 [ + - ][ + - ]: 159 : impl_store( rURL, rArgs, sal_True );
1757 [ + - ]: 159 : }
1758 : 159 : }
1759 : :
1760 : 0 : ::sal_Bool SAL_CALL SfxBaseModel::wasModifiedSinceLastSave() throw ( RuntimeException )
1761 : : {
1762 [ # # ]: 0 : SfxModelGuard aGuard( *this );
1763 [ # # ]: 0 : return m_pData->m_bModifiedSinceLastSave;
1764 : : }
1765 : :
1766 : 0 : void SAL_CALL SfxBaseModel::storeToRecoveryFile( const ::rtl::OUString& i_TargetLocation, const Sequence< PropertyValue >& i_MediaDescriptor ) throw ( RuntimeException, IOException, WrappedTargetException )
1767 : : {
1768 [ # # ]: 0 : SfxModelGuard aGuard( *this );
1769 : :
1770 : : // delegate
1771 [ # # ][ # # ]: 0 : SfxSaveGuard aSaveGuard( this, m_pData, sal_False );
1772 [ # # ]: 0 : impl_store( i_TargetLocation, i_MediaDescriptor, sal_True );
1773 : :
1774 : : // no need for subsequent calls to storeToRecoveryFile, unless we're modified, again
1775 [ # # ][ # # ]: 0 : m_pData->m_bModifiedSinceLastSave = sal_False;
1776 : 0 : }
1777 : :
1778 : 0 : void SAL_CALL SfxBaseModel::recoverFromFile( const ::rtl::OUString& i_SourceLocation, const ::rtl::OUString& i_SalvagedFile, const Sequence< PropertyValue >& i_MediaDescriptor ) throw ( RuntimeException, IOException, WrappedTargetException )
1779 : : {
1780 [ # # ]: 0 : SfxModelGuard aGuard( *this, SfxModelGuard::E_INITIALIZING );
1781 : :
1782 : : // delegate to our "load" method
1783 [ # # ]: 0 : ::comphelper::NamedValueCollection aMediaDescriptor( i_MediaDescriptor );
1784 : :
1785 : : // our load implementation expects the SalvagedFile to be in the media descriptor
1786 : : OSL_ENSURE( !aMediaDescriptor.has( "SalvagedFile" ) || ( aMediaDescriptor.getOrDefault( "SalvagedFile", ::rtl::OUString() ) == i_SalvagedFile ),
1787 : : "SfxBaseModel::recoverFromFile: inconsistent information!" );
1788 [ # # ]: 0 : aMediaDescriptor.put( "SalvagedFile", i_SalvagedFile );
1789 : :
1790 : : // similar for the to-be-loaded file
1791 : : OSL_ENSURE( !aMediaDescriptor.has( "URL" ) || ( aMediaDescriptor.getOrDefault( "URL", ::rtl::OUString() ) == i_SourceLocation ),
1792 : : "SfxBaseModel::recoverFromFile: inconsistent information!" );
1793 [ # # ]: 0 : aMediaDescriptor.put( "URL", i_SourceLocation );
1794 : :
1795 [ # # ][ # # ]: 0 : load( aMediaDescriptor.getPropertyValues() );
[ # # ][ # # ]
[ # # ]
1796 : :
1797 : : // Note: The XDocumentRecovery interface specification requires us to do an attachResource after loading.
1798 : : // However, we will not do this here, as we know that our load implementation (respectively some method
1799 : : // called from there) already did so.
1800 : : // In particular, the load process might already have modified some elements of the media
1801 : : // descriptor, for instance the MacroExecMode (in case the user was involved to decide about it), and we do
1802 : : // not want to overwrite it with the "old" elements passed to this method here.
1803 : 0 : }
1804 : :
1805 : : //________________________________________________________________________________________________________
1806 : : // XLoadable
1807 : : //________________________________________________________________________________________________________
1808 : :
1809 : 1519 : void SAL_CALL SfxBaseModel::initNew()
1810 : : throw (::com::sun::star::frame::DoubleInitializationException,
1811 : : ::com::sun::star::io::IOException,
1812 : : ::com::sun::star::uno::RuntimeException,
1813 : : ::com::sun::star::uno::Exception)
1814 : : {
1815 [ + - ]: 1519 : SfxModelGuard aGuard( *this, SfxModelGuard::E_INITIALIZING );
1816 [ + - ][ - + ]: 1519 : if ( IsInitialized() )
1817 [ # # ][ # # ]: 0 : throw ::com::sun::star::frame::DoubleInitializationException( ::rtl::OUString(), *this );
1818 : :
1819 : : // the object shell should exist always
1820 : : DBG_ASSERT( m_pData->m_pObjectShell.Is(), "Model is useless without an ObjectShell" );
1821 [ + - ]: 1519 : if ( m_pData->m_pObjectShell.Is() )
1822 : : {
1823 [ - + ]: 1519 : if( m_pData->m_pObjectShell->GetMedium() )
1824 [ # # ]: 0 : throw frame::DoubleInitializationException();
1825 : :
1826 [ + - ]: 1519 : sal_Bool bRes = m_pData->m_pObjectShell->DoInitNew( NULL );
1827 [ + - ]: 1519 : sal_uInt32 nErrCode = m_pData->m_pObjectShell->GetError() ?
1828 [ - + ][ # # ]: 1519 : m_pData->m_pObjectShell->GetError() : ERRCODE_IO_CANTCREATE;
1829 [ + - ]: 1519 : m_pData->m_pObjectShell->ResetError();
1830 : :
1831 [ - + ]: 1519 : if ( !bRes )
1832 [ # # ]: 0 : throw task::ErrorCodeIOException( ::rtl::OUString(), uno::Reference< uno::XInterface >(), nErrCode );
1833 [ + - ]: 1519 : }
1834 : 1519 : }
1835 : :
1836 : : //________________________________________________________________________________________________________
1837 : : // XLoadable
1838 : : //________________________________________________________________________________________________________
1839 : :
1840 : 614 : void SAL_CALL SfxBaseModel::load( const uno::Sequence< beans::PropertyValue >& seqArguments )
1841 : : throw (::com::sun::star::frame::DoubleInitializationException,
1842 : : ::com::sun::star::io::IOException,
1843 : : ::com::sun::star::uno::RuntimeException,
1844 : : ::com::sun::star::uno::Exception)
1845 : : {
1846 [ + - ]: 614 : SfxModelGuard aGuard( *this, SfxModelGuard::E_INITIALIZING );
1847 [ + - ][ - + ]: 614 : if ( IsInitialized() )
1848 [ # # ][ # # ]: 0 : throw ::com::sun::star::frame::DoubleInitializationException( ::rtl::OUString(), *this );
1849 : :
1850 : : // the object shell should exist always
1851 : : DBG_ASSERT( m_pData->m_pObjectShell.Is(), "Model is useless without an ObjectShell" );
1852 : :
1853 [ + - ]: 614 : if ( m_pData->m_pObjectShell.Is() )
1854 : : {
1855 [ - + ]: 614 : if( m_pData->m_pObjectShell->GetMedium() )
1856 : : // if a Medium is present, the document is already initialized
1857 [ # # ]: 0 : throw frame::DoubleInitializationException();
1858 : :
1859 [ + - ][ + - ]: 614 : SfxMedium* pMedium = new SfxMedium( seqArguments );
1860 [ + - ]: 614 : String aFilterName;
1861 [ + - ][ + - ]: 614 : SFX_ITEMSET_ARG( pMedium->GetItemSet(), pFilterNameItem, SfxStringItem, SID_FILTER_NAME, sal_False );
[ + - ]
1862 [ + - ]: 614 : if( pFilterNameItem )
1863 [ + - ]: 614 : aFilterName = pFilterNameItem->GetValue();
1864 [ + - ][ + - ]: 614 : if( !m_pData->m_pObjectShell->GetFactory().GetFilterContainer()->GetFilter4FilterName( aFilterName ) )
[ + - ][ - + ]
1865 : : {
1866 : : // filtername is not valid
1867 [ # # ][ # # ]: 0 : delete pMedium;
1868 [ # # ]: 0 : throw frame::IllegalArgumentIOException();
1869 : : }
1870 : :
1871 [ + - ][ + - ]: 614 : SFX_ITEMSET_ARG( pMedium->GetItemSet(), pSalvageItem, SfxStringItem, SID_DOC_SALVAGE, sal_False );
[ + - ]
1872 [ - + ]: 614 : sal_Bool bSalvage = pSalvageItem ? sal_True : sal_False;
1873 : :
1874 : : // load document
1875 : 614 : sal_uInt32 nError = ERRCODE_NONE;
1876 [ + - ][ - + ]: 614 : if ( !m_pData->m_pObjectShell->DoLoad(pMedium) )
1877 : 0 : nError=ERRCODE_IO_GENERAL;
1878 : :
1879 : : // QUESTION: if the following happens outside of DoLoad, something important is missing there!
1880 [ + - ]: 614 : ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > xHandler = pMedium->GetInteractionHandler();
1881 [ + - ][ + + ]: 614 : if( m_pData->m_pObjectShell->GetErrorCode() )
1882 : : {
1883 [ + - ]: 33 : nError = m_pData->m_pObjectShell->GetErrorCode();
1884 [ - + ][ # # ]: 33 : if ( nError == ERRCODE_IO_BROKENPACKAGE && xHandler.is() )
[ - + ]
1885 : : {
1886 [ # # ][ # # ]: 0 : ::rtl::OUString aDocName = pMedium->GetURLObject().getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET );
1887 [ # # ][ # # ]: 0 : SFX_ITEMSET_ARG( pMedium->GetItemSet(), pRepairItem, SfxBoolItem, SID_REPAIRPACKAGE, sal_False );
[ # # ]
1888 [ # # ][ # # ]: 0 : if ( !pRepairItem || !pRepairItem->GetValue() )
[ # # ]
1889 : : {
1890 [ # # ]: 0 : RequestPackageReparation aRequest( aDocName );
1891 [ # # ][ # # ]: 0 : xHandler->handle( aRequest.GetRequest() );
[ # # ]
1892 [ # # ][ # # ]: 0 : if( aRequest.isApproved() )
1893 : : {
1894 : : // broken package: try second loading and allow repair
1895 [ # # ][ # # ]: 0 : pMedium->GetItemSet()->Put( SfxBoolItem( SID_REPAIRPACKAGE, sal_True ) );
[ # # ][ # # ]
1896 [ # # ][ # # ]: 0 : pMedium->GetItemSet()->Put( SfxBoolItem( SID_TEMPLATE, sal_True ) );
[ # # ][ # # ]
1897 [ # # ][ # # ]: 0 : pMedium->GetItemSet()->Put( SfxStringItem( SID_DOCINFO_TITLE, aDocName ) );
[ # # ][ # # ]
[ # # ][ # # ]
1898 : :
1899 : : // the error must be reset and the storage must be reopened in new mode
1900 [ # # ]: 0 : pMedium->ResetError();
1901 [ # # ]: 0 : pMedium->CloseStorage();
1902 [ # # ]: 0 : m_pData->m_pObjectShell->PrepareSecondTryLoad_Impl();
1903 [ # # ][ # # ]: 0 : if ( !m_pData->m_pObjectShell->DoLoad(pMedium) )
1904 : 0 : nError=ERRCODE_IO_GENERAL;
1905 [ # # ]: 0 : nError = m_pData->m_pObjectShell->GetErrorCode();
1906 [ # # ]: 0 : }
1907 : : }
1908 : :
1909 [ # # ]: 0 : if ( nError == ERRCODE_IO_BROKENPACKAGE )
1910 : : {
1911 : : // repair either not allowed or not successful
1912 [ # # ]: 0 : NotifyBrokenPackage aRequest( aDocName );
1913 [ # # ][ # # ]: 0 : xHandler->handle( aRequest.GetRequest() );
[ # # ][ # # ]
1914 : 0 : }
1915 : : }
1916 : : }
1917 : :
1918 [ + - ][ - + ]: 614 : if( m_pData->m_pObjectShell->IsAbortingImport() )
1919 : 0 : nError = ERRCODE_ABORT;
1920 : :
1921 [ - + ]: 614 : if( bSalvage )
1922 : : {
1923 : : // file recovery: restore original filter
1924 [ # # ][ # # ]: 0 : SFX_ITEMSET_ARG( pMedium->GetItemSet(), pFilterItem, SfxStringItem, SID_FILTER_NAME, sal_False );
[ # # ]
1925 [ # # ][ # # ]: 0 : SfxFilterMatcher& rMatcher = SFX_APP()->GetFilterMatcher();
1926 [ # # ]: 0 : const SfxFilter* pSetFilter = rMatcher.GetFilter4FilterName( pFilterItem->GetValue() );
1927 [ # # ]: 0 : pMedium->SetFilter( pSetFilter );
1928 [ # # ]: 0 : m_pData->m_pObjectShell->SetModified(sal_True);
1929 : : }
1930 : :
1931 : : // TODO/LATER: may be the mode should be retrieved from outside and the preused filter should not be set
1932 [ - + ]: 614 : if ( m_pData->m_pObjectShell->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
1933 : : {
1934 [ # # ][ # # ]: 0 : SFX_ITEMSET_ARG( pMedium->GetItemSet(), pFilterItem, SfxStringItem, SID_FILTER_NAME, sal_False );
[ # # ]
1935 [ # # ]: 0 : if ( pFilterItem )
1936 [ # # ]: 0 : m_pData->m_aPreusedFilterName = pFilterItem->GetValue();
1937 : : }
1938 : :
1939 [ + + ]: 614 : if ( !nError )
1940 [ + - ]: 581 : nError = pMedium->GetError();
1941 : :
1942 [ + - ]: 614 : m_pData->m_pObjectShell->ResetError();
1943 : :
1944 [ + + ]: 614 : if ( nError )
1945 : : {
1946 : 33 : sal_Bool bSilent = sal_False;
1947 [ + - ][ + - ]: 33 : SFX_ITEMSET_ARG( pMedium->GetItemSet(), pSilentItem, SfxBoolItem, SID_SILENT, sal_False);
[ + - ]
1948 [ - + ]: 33 : if( pSilentItem )
1949 : 0 : bSilent = pSilentItem->GetValue();
1950 : :
1951 : 33 : sal_Bool bWarning = ((nError & ERRCODE_WARNING_MASK) == ERRCODE_WARNING_MASK);
1952 [ + - ][ + - ]: 33 : if ( nError != ERRCODE_IO_BROKENPACKAGE && !bSilent )
1953 : : {
1954 : : // broken package was handled already
1955 [ + - ][ - + ]: 33 : if ( SfxObjectShell::UseInteractionToHandleError( xHandler, nError ) && !bWarning )
[ # # ][ - + ]
1956 : : {
1957 : : // abort loading (except for warnings)
1958 : 0 : nError = ERRCODE_IO_ABORT;
1959 : : }
1960 : : }
1961 : :
1962 [ - + ]: 33 : if ( m_pData->m_pObjectShell->GetMedium() != pMedium )
1963 : : {
1964 : : // for whatever reason document now has another medium
1965 : : OSL_FAIL("Document has rejected the medium?!");
1966 [ # # ][ # # ]: 0 : delete pMedium;
1967 : : }
1968 : :
1969 [ - + ]: 33 : if ( !bWarning ) // #i30711# don't abort loading if it's only a warning
1970 : : {
1971 : : throw task::ErrorCodeIOException( ::rtl::OUString(),
1972 : : uno::Reference< uno::XInterface >(),
1973 [ # # ][ # # ]: 0 : nError ? nError : ERRCODE_IO_CANTREAD );
1974 : : }
1975 : : }
1976 : :
1977 : 614 : sal_Bool bHidden = sal_False;
1978 [ + - ][ + - ]: 614 : SFX_ITEMSET_ARG( pMedium->GetItemSet(), pHidItem, SfxBoolItem, SID_HIDDEN, sal_False);
[ + - ]
1979 [ + + ]: 614 : if ( pHidItem )
1980 : 16 : bHidden = pHidItem->GetValue();
1981 : :
1982 : : #if OSL_DEBUG_LEVEL > 0
1983 : : SFX_ITEMSET_ARG( pMedium->GetItemSet(), pPasswdItem, SfxStringItem, SID_PASSWORD, sal_False);
1984 : : OSL_ENSURE( !pPasswdItem, "There should be no Password property in the document MediaDescriptor!" );
1985 : : #endif
1986 : : // !TODO: will be done by Framework!
1987 [ + - ][ + - ]: 614 : pMedium->SetUpdatePickList( !bHidden );
1988 [ + - ]: 614 : }
1989 : 614 : }
1990 : :
1991 : : //________________________________________________________________________________________________________
1992 : : // XTransferable
1993 : : //________________________________________________________________________________________________________
1994 : :
1995 : 6816 : uno::Any SAL_CALL SfxBaseModel::getTransferData( const DATAFLAVOR& aFlavor )
1996 : : throw (::com::sun::star::datatransfer::UnsupportedFlavorException,
1997 : : ::com::sun::star::io::IOException,
1998 : : ::com::sun::star::uno::RuntimeException)
1999 : : {
2000 [ + - ]: 6816 : SfxModelGuard aGuard( *this );
2001 : :
2002 : 6816 : uno::Any aAny;
2003 : :
2004 [ + - ]: 6816 : if ( m_pData->m_pObjectShell.Is() )
2005 : : {
2006 [ - + ]: 6816 : if ( aFlavor.MimeType == "application/x-openoffice-objectdescriptor-xml;windows_formatname=\"Star Object Descriptor (XML)\"" )
2007 : : {
2008 [ # # ][ # # ]: 0 : if ( aFlavor.DataType == getCppuType( (const Sequence< sal_Int8 >*) 0 ) )
2009 : : {
2010 [ # # ]: 0 : TransferableObjectDescriptor aDesc;
2011 : :
2012 [ # # ][ # # ]: 0 : aDesc.maClassName = m_pData->m_pObjectShell->GetClassName();
[ # # ]
2013 [ # # ]: 0 : aDesc.maTypeName = aFlavor.HumanPresentableName;
2014 : :
2015 : : // TODO/LATER: ViewAspect needs to be sal_Int64
2016 : 0 : aDesc.mnViewAspect = sal::static_int_cast< sal_uInt16 >( embed::Aspects::MSOLE_CONTENT );
2017 : :
2018 : : //TODO/LATER: status needs to become sal_Int64
2019 [ # # ]: 0 : aDesc.mnOle2Misc = m_pData->m_pObjectShell->GetMiscStatus();
2020 [ # # ][ # # ]: 0 : Size aSize = m_pData->m_pObjectShell->GetVisArea().GetSize();
2021 : :
2022 [ # # ]: 0 : MapUnit aMapUnit = m_pData->m_pObjectShell->GetMapUnit();
2023 [ # # ][ # # ]: 0 : aDesc.maSize = OutputDevice::LogicToLogic( aSize, aMapUnit, MAP_100TH_MM );
[ # # ][ # # ]
[ # # ]
2024 : 0 : aDesc.maDragStartPos = Point();
2025 [ # # ][ # # ]: 0 : aDesc.maDisplayName = String();
[ # # ]
2026 : 0 : aDesc.mbCanLink = sal_False;
2027 : :
2028 [ # # ]: 0 : SvMemoryStream aMemStm( 1024, 1024 );
2029 [ # # ]: 0 : aMemStm << aDesc;
2030 [ # # ][ # # ]: 0 : aAny <<= Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( aMemStm.GetData() ), aMemStm.Tell() );
[ # # ][ # # ]
[ # # ][ # # ]
2031 : : }
2032 : : else
2033 [ # # ]: 0 : throw datatransfer::UnsupportedFlavorException();
2034 : : }
2035 [ - + ]: 6816 : else if ( aFlavor.MimeType == "application/x-openoffice-embed-source;windows_formatname=\"Star EMBS\"" )
2036 : : {
2037 [ # # ][ # # ]: 0 : if ( aFlavor.DataType == getCppuType( (const Sequence< sal_Int8 >*) 0 ) )
2038 : : {
2039 : : try
2040 : : {
2041 [ # # ]: 0 : utl::TempFile aTmp;
2042 : 0 : aTmp.EnableKillingFile( sal_True );
2043 [ # # ][ # # ]: 0 : storeToURL( aTmp.GetURL(), uno::Sequence < beans::PropertyValue >() );
[ # # ][ # # ]
[ # # ][ # # ]
2044 [ # # ]: 0 : SvStream* pStream = aTmp.GetStream( STREAM_READ );
2045 [ # # ]: 0 : const sal_uInt32 nLen = pStream->Seek( STREAM_SEEK_TO_END );
2046 [ # # ]: 0 : ::com::sun::star::uno::Sequence< sal_Int8 > aSeq( nLen );
2047 [ # # ]: 0 : pStream->Seek( STREAM_SEEK_TO_BEGIN );
2048 [ # # ][ # # ]: 0 : pStream->Read( aSeq.getArray(), nLen );
2049 [ # # ][ # # ]: 0 : delete pStream;
2050 [ # # ]: 0 : if( aSeq.getLength() )
2051 [ # # ][ # # ]: 0 : aAny <<= aSeq;
[ # # ][ # # ]
2052 : : }
2053 [ # # ]: 0 : catch ( uno::Exception& )
2054 : : {
2055 : : }
2056 : : }
2057 : : else
2058 [ # # ]: 0 : throw datatransfer::UnsupportedFlavorException();
2059 : : }
2060 [ + - ]: 6816 : else if ( aFlavor.MimeType == "application/x-openoffice-gdimetafile;windows_formatname=\"GDIMetaFile\"" )
2061 : : {
2062 [ + - ][ + - ]: 6816 : if ( aFlavor.DataType == getCppuType( (const Sequence< sal_Int8 >*) 0 ) )
2063 : : {
2064 : :
2065 : : ::boost::shared_ptr<GDIMetaFile> pMetaFile =
2066 [ + - ]: 6816 : m_pData->m_pObjectShell->GetPreviewMetaFile( sal_True );
2067 : :
2068 [ + - ]: 6816 : if ( pMetaFile )
2069 : : {
2070 [ + - ]: 6816 : SvMemoryStream aMemStm( 65535, 65535 );
2071 : 6816 : aMemStm.SetVersion( SOFFICE_FILEFORMAT_CURRENT );
2072 : :
2073 [ + - ]: 6816 : pMetaFile->Write( aMemStm );
2074 [ + - ]: 6816 : aAny <<= Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( aMemStm.GetData() ),
2075 [ + - ][ + - ]: 13632 : aMemStm.Seek( STREAM_SEEK_TO_END ) );
[ + - ][ + - ]
[ + - ]
2076 [ + - ]: 6816 : }
2077 : : }
2078 : : else
2079 [ # # ]: 0 : throw datatransfer::UnsupportedFlavorException();
2080 : : }
2081 [ # # ]: 0 : else if ( aFlavor.MimeType == "application/x-openoffice-highcontrast-gdimetafile;windows_formatname=\"GDIMetaFile\"" )
2082 : : {
2083 [ # # ][ # # ]: 0 : if ( aFlavor.DataType == getCppuType( (const Sequence< sal_Int8 >*) 0 ) )
2084 : : {
2085 : : ::boost::shared_ptr<GDIMetaFile> pMetaFile =
2086 [ # # ]: 0 : m_pData->m_pObjectShell->CreatePreviewMetaFile_Impl( sal_True );
2087 : :
2088 [ # # ]: 0 : if ( pMetaFile )
2089 : : {
2090 [ # # ]: 0 : SvMemoryStream aMemStm( 65535, 65535 );
2091 : 0 : aMemStm.SetVersion( SOFFICE_FILEFORMAT_CURRENT );
2092 : :
2093 [ # # ]: 0 : pMetaFile->Write( aMemStm );
2094 [ # # ]: 0 : aAny <<= Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( aMemStm.GetData() ),
2095 [ # # ][ # # ]: 0 : aMemStm.Seek( STREAM_SEEK_TO_END ) );
[ # # ][ # # ]
[ # # ]
2096 [ # # ]: 0 : }
2097 : : }
2098 : : else
2099 [ # # ]: 0 : throw datatransfer::UnsupportedFlavorException();
2100 : : }
2101 [ # # ]: 0 : else if ( aFlavor.MimeType == "application/x-openoffice-emf;windows_formatname=\"Image EMF\"" )
2102 : : {
2103 [ # # ][ # # ]: 0 : if ( aFlavor.DataType == getCppuType( (const Sequence< sal_Int8 >*) 0 ) )
2104 : : {
2105 : : ::boost::shared_ptr<GDIMetaFile> pMetaFile =
2106 [ # # ]: 0 : m_pData->m_pObjectShell->GetPreviewMetaFile( sal_True );
2107 : :
2108 [ # # ]: 0 : if ( pMetaFile )
2109 : : {
2110 : : ::boost::shared_ptr<SvMemoryStream> pStream(
2111 : : GraphicHelper::getFormatStrFromGDI_Impl(
2112 [ # # ][ # # ]: 0 : pMetaFile.get(), CVT_EMF ) );
2113 [ # # ]: 0 : if ( pStream )
2114 : : {
2115 : 0 : pStream->SetVersion( SOFFICE_FILEFORMAT_CURRENT );
2116 [ # # ]: 0 : aAny <<= Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( pStream->GetData() ),
2117 [ # # ][ # # ]: 0 : pStream->Seek( STREAM_SEEK_TO_END ) );
[ # # ][ # # ]
2118 [ # # ]: 0 : }
2119 [ # # ]: 0 : }
2120 : : }
2121 [ # # ]: 0 : else if ( GraphicHelper::supportsMetaFileHandle_Impl()
[ # # # # ]
[ # # ]
2122 [ # # ]: 0 : && aFlavor.DataType == getCppuType( (const sal_uInt64*) 0 ) )
2123 : : {
2124 : : ::boost::shared_ptr<GDIMetaFile> pMetaFile =
2125 [ # # ]: 0 : m_pData->m_pObjectShell->GetPreviewMetaFile( sal_True );
2126 : :
2127 [ # # ]: 0 : if ( pMetaFile )
2128 : : {
2129 : : aAny <<= reinterpret_cast< const sal_uInt64 >(
2130 [ # # ][ # # ]: 0 : GraphicHelper::getEnhMetaFileFromGDI_Impl( pMetaFile.get() ) );
2131 [ # # ]: 0 : }
2132 : : }
2133 : : else
2134 [ # # ]: 0 : throw datatransfer::UnsupportedFlavorException();
2135 : : }
2136 [ # # ]: 0 : else if ( aFlavor.MimeType == "application/x-openoffice-wmf;windows_formatname=\"Image WMF\"" )
2137 : : {
2138 [ # # ][ # # ]: 0 : if ( aFlavor.DataType == getCppuType( (const Sequence< sal_Int8 >*) 0 ) )
2139 : : {
2140 : : ::boost::shared_ptr<GDIMetaFile> pMetaFile =
2141 [ # # ]: 0 : m_pData->m_pObjectShell->GetPreviewMetaFile( sal_True );
2142 : :
2143 [ # # ]: 0 : if ( pMetaFile )
2144 : : {
2145 : : ::boost::shared_ptr<SvMemoryStream> pStream(
2146 : : GraphicHelper::getFormatStrFromGDI_Impl(
2147 [ # # ][ # # ]: 0 : pMetaFile.get(), CVT_WMF ) );
2148 : :
2149 [ # # ]: 0 : if ( pStream )
2150 : : {
2151 : 0 : pStream->SetVersion( SOFFICE_FILEFORMAT_CURRENT );
2152 [ # # ]: 0 : aAny <<= Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( pStream->GetData() ),
2153 [ # # ][ # # ]: 0 : pStream->Seek( STREAM_SEEK_TO_END ) );
[ # # ][ # # ]
2154 [ # # ]: 0 : }
2155 [ # # ]: 0 : }
2156 : : }
2157 [ # # ]: 0 : else if ( GraphicHelper::supportsMetaFileHandle_Impl()
[ # # # # ]
[ # # ]
2158 [ # # ]: 0 : && aFlavor.DataType == getCppuType( (const sal_uInt64*) 0 ) )
2159 : : {
2160 : : // means HGLOBAL handler to memory storage containing METAFILEPICT structure
2161 : :
2162 : : ::boost::shared_ptr<GDIMetaFile> pMetaFile =
2163 [ # # ]: 0 : m_pData->m_pObjectShell->GetPreviewMetaFile( sal_True );
2164 : :
2165 [ # # ]: 0 : if ( pMetaFile )
2166 : : {
2167 : 0 : Size aMetaSize = pMetaFile->GetPrefSize();
2168 : : aAny <<= reinterpret_cast< const sal_uInt64 >(
2169 : : GraphicHelper::getWinMetaFileFromGDI_Impl(
2170 [ # # ][ # # ]: 0 : pMetaFile.get(), aMetaSize ) );
2171 [ # # ]: 0 : }
2172 : : }
2173 : : else
2174 [ # # ]: 0 : throw datatransfer::UnsupportedFlavorException();
2175 : : }
2176 [ # # ]: 0 : else if ( aFlavor.MimeType == "application/x-openoffice-bitmap;windows_formatname=\"Bitmap\"" )
2177 : : {
2178 [ # # ][ # # ]: 0 : if ( aFlavor.DataType == getCppuType( (const Sequence< sal_Int8 >*) 0 ) )
2179 : : {
2180 : : ::boost::shared_ptr<GDIMetaFile> pMetaFile =
2181 [ # # ]: 0 : m_pData->m_pObjectShell->GetPreviewMetaFile( sal_True );
2182 : :
2183 [ # # ]: 0 : if ( pMetaFile )
2184 : : {
2185 : : ::boost::shared_ptr<SvMemoryStream> pStream(
2186 : : GraphicHelper::getFormatStrFromGDI_Impl(
2187 [ # # ][ # # ]: 0 : pMetaFile.get(), CVT_BMP ) );
2188 : :
2189 [ # # ]: 0 : if ( pStream )
2190 : : {
2191 : 0 : pStream->SetVersion( SOFFICE_FILEFORMAT_CURRENT );
2192 [ # # ]: 0 : aAny <<= Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( pStream->GetData() ),
2193 [ # # ][ # # ]: 0 : pStream->Seek( STREAM_SEEK_TO_END ) );
[ # # ][ # # ]
2194 [ # # ]: 0 : }
2195 [ # # ]: 0 : }
2196 : : }
2197 : : else
2198 [ # # ]: 0 : throw datatransfer::UnsupportedFlavorException();
2199 : : }
2200 [ # # ]: 0 : else if ( aFlavor.MimeType == "image/png" )
2201 : : {
2202 [ # # ][ # # ]: 0 : if ( aFlavor.DataType == getCppuType( (const Sequence< sal_Int8 >*) 0 ) )
2203 : : {
2204 : : ::boost::shared_ptr<GDIMetaFile> pMetaFile =
2205 [ # # ]: 0 : m_pData->m_pObjectShell->GetPreviewMetaFile( sal_True );
2206 : :
2207 [ # # ]: 0 : if ( pMetaFile )
2208 : : {
2209 : : ::boost::shared_ptr<SvMemoryStream> pStream(
2210 : : GraphicHelper::getFormatStrFromGDI_Impl(
2211 [ # # ][ # # ]: 0 : pMetaFile.get(), CVT_PNG ) );
2212 : :
2213 [ # # ]: 0 : if ( pStream )
2214 : : {
2215 : 0 : pStream->SetVersion( SOFFICE_FILEFORMAT_CURRENT );
2216 [ # # ]: 0 : aAny <<= Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( pStream->GetData() ),
2217 [ # # ][ # # ]: 0 : pStream->Seek( STREAM_SEEK_TO_END ) );
[ # # ][ # # ]
2218 [ # # ]: 0 : }
2219 [ # # ]: 0 : }
2220 : : }
2221 : : else
2222 [ # # ]: 0 : throw datatransfer::UnsupportedFlavorException();
2223 : : }
2224 : : else
2225 [ # # ]: 0 : throw datatransfer::UnsupportedFlavorException();
2226 : : }
2227 : :
2228 [ + - ]: 6816 : return aAny;
2229 : : }
2230 : :
2231 : : //________________________________________________________________________________________________________
2232 : : // XTransferable
2233 : : //________________________________________________________________________________________________________
2234 : :
2235 : :
2236 : 0 : uno::Sequence< DATAFLAVOR > SAL_CALL SfxBaseModel::getTransferDataFlavors()
2237 : : throw (::com::sun::star::uno::RuntimeException)
2238 : : {
2239 [ # # ]: 0 : SfxModelGuard aGuard( *this );
2240 : :
2241 [ # # ][ # # ]: 0 : sal_Int32 nSuppFlavors = GraphicHelper::supportsMetaFileHandle_Impl() ? 10 : 8;
2242 [ # # ]: 0 : uno::Sequence< DATAFLAVOR > aFlavorSeq( nSuppFlavors );
2243 : :
2244 [ # # ]: 0 : aFlavorSeq[0].MimeType =
2245 : 0 : ::rtl::OUString( "application/x-openoffice-gdimetafile;windows_formatname=\"GDIMetaFile\"" );
2246 [ # # ]: 0 : aFlavorSeq[0].HumanPresentableName = ::rtl::OUString( "GDIMetaFile" );
2247 [ # # ][ # # ]: 0 : aFlavorSeq[0].DataType = getCppuType( (const Sequence< sal_Int8 >*) 0 );
2248 : :
2249 [ # # ]: 0 : aFlavorSeq[1].MimeType =
2250 : 0 : ::rtl::OUString( "application/x-openoffice-highcontrast-gdimetafile;windows_formatname=\"GDIMetaFile\"" );
2251 [ # # ]: 0 : aFlavorSeq[1].HumanPresentableName = ::rtl::OUString( "GDIMetaFile" );
2252 [ # # ][ # # ]: 0 : aFlavorSeq[1].DataType = getCppuType( (const Sequence< sal_Int8 >*) 0 );
2253 : :
2254 [ # # ]: 0 : aFlavorSeq[2].MimeType =
2255 : 0 : ::rtl::OUString( "application/x-openoffice-emf;windows_formatname=\"Image EMF\"" );
2256 [ # # ]: 0 : aFlavorSeq[2].HumanPresentableName = ::rtl::OUString( "Enhanced Windows MetaFile" );
2257 [ # # ][ # # ]: 0 : aFlavorSeq[2].DataType = getCppuType( (const Sequence< sal_Int8 >*) 0 );
2258 : :
2259 [ # # ]: 0 : aFlavorSeq[3].MimeType =
2260 : 0 : ::rtl::OUString( "application/x-openoffice-wmf;windows_formatname=\"Image WMF\"" );
2261 [ # # ]: 0 : aFlavorSeq[3].HumanPresentableName = ::rtl::OUString( "Windows MetaFile" );
2262 [ # # ][ # # ]: 0 : aFlavorSeq[3].DataType = getCppuType( (const Sequence< sal_Int8 >*) 0 );
2263 : :
2264 [ # # ]: 0 : aFlavorSeq[4].MimeType =
2265 : 0 : ::rtl::OUString( "application/x-openoffice-objectdescriptor-xml;windows_formatname=\"Star Object Descriptor (XML)\"" );
2266 [ # # ]: 0 : aFlavorSeq[4].HumanPresentableName = ::rtl::OUString( "Star Object Descriptor (XML)" );
2267 [ # # ][ # # ]: 0 : aFlavorSeq[4].DataType = getCppuType( (const Sequence< sal_Int8 >*) 0 );
2268 : :
2269 [ # # ]: 0 : aFlavorSeq[5].MimeType =
2270 : 0 : ::rtl::OUString( "application/x-openoffice-embed-source-xml;windows_formatname=\"Star Embed Source (XML)\"" );
2271 [ # # ]: 0 : aFlavorSeq[5].HumanPresentableName = ::rtl::OUString( "Star Embed Source (XML)" );
2272 [ # # ][ # # ]: 0 : aFlavorSeq[5].DataType = getCppuType( (const Sequence< sal_Int8 >*) 0 );
2273 : :
2274 [ # # ]: 0 : aFlavorSeq[6].MimeType =
2275 : 0 : ::rtl::OUString( "application/x-openoffice-bitmap;windows_formatname=\"Bitmap\"" );
2276 [ # # ]: 0 : aFlavorSeq[6].HumanPresentableName = ::rtl::OUString( "Bitmap" );
2277 [ # # ][ # # ]: 0 : aFlavorSeq[6].DataType = getCppuType( (const Sequence< sal_Int8 >*) 0 );
2278 : :
2279 [ # # ]: 0 : aFlavorSeq[7].MimeType =
2280 : 0 : ::rtl::OUString( "image/png" );
2281 [ # # ]: 0 : aFlavorSeq[7].HumanPresentableName = ::rtl::OUString( "PNG" );
2282 [ # # ][ # # ]: 0 : aFlavorSeq[7].DataType = getCppuType( (const Sequence< sal_Int8 >*) 0 );
2283 : :
2284 [ # # ]: 0 : if ( nSuppFlavors == 10 )
2285 : : {
2286 [ # # ]: 0 : aFlavorSeq[8].MimeType =
2287 : 0 : ::rtl::OUString( "application/x-openoffice-emf;windows_formatname=\"Image EMF\"" );
2288 [ # # ]: 0 : aFlavorSeq[8].HumanPresentableName = ::rtl::OUString( "Enhanced Windows MetaFile" );
2289 [ # # ][ # # ]: 0 : aFlavorSeq[8].DataType = getCppuType( (const sal_uInt64*) 0 );
2290 : :
2291 [ # # ]: 0 : aFlavorSeq[9].MimeType =
2292 : 0 : ::rtl::OUString( "application/x-openoffice-wmf;windows_formatname=\"Image WMF\"" );
2293 [ # # ]: 0 : aFlavorSeq[9].HumanPresentableName = ::rtl::OUString( "Windows MetaFile" );
2294 [ # # ][ # # ]: 0 : aFlavorSeq[9].DataType = getCppuType( (const sal_uInt64*) 0 );
2295 : : }
2296 : :
2297 [ # # ]: 0 : return aFlavorSeq;
2298 : : }
2299 : :
2300 : : //________________________________________________________________________________________________________
2301 : : // XTransferable
2302 : : //________________________________________________________________________________________________________
2303 : :
2304 : :
2305 : 0 : sal_Bool SAL_CALL SfxBaseModel::isDataFlavorSupported( const DATAFLAVOR& aFlavor )
2306 : : throw (::com::sun::star::uno::RuntimeException)
2307 : : {
2308 [ # # ]: 0 : SfxModelGuard aGuard( *this );
2309 : :
2310 [ # # ]: 0 : if ( aFlavor.MimeType == "application/x-openoffice-gdimetafile;windows_formatname=\"GDIMetaFile\"" )
2311 : : {
2312 [ # # ][ # # ]: 0 : if ( aFlavor.DataType == getCppuType( (const Sequence< sal_Int8 >*) 0 ) )
2313 : 0 : return sal_True;
2314 : : }
2315 [ # # ]: 0 : else if ( aFlavor.MimeType == "application/x-openoffice-highcontrast-gdimetafile;windows_formatname=\"GDIMetaFile\"" )
2316 : : {
2317 [ # # ][ # # ]: 0 : if ( aFlavor.DataType == getCppuType( (const Sequence< sal_Int8 >*) 0 ) )
2318 : 0 : return sal_True;
2319 : : }
2320 [ # # ]: 0 : else if ( aFlavor.MimeType == "application/x-openoffice-emf;windows_formatname=\"Image EMF\"" )
2321 : : {
2322 [ # # ][ # # ]: 0 : if ( aFlavor.DataType == getCppuType( (const Sequence< sal_Int8 >*) 0 ) )
2323 : 0 : return sal_True;
2324 [ # # ]: 0 : else if ( GraphicHelper::supportsMetaFileHandle_Impl()
[ # # # # ]
[ # # ]
2325 [ # # ]: 0 : && aFlavor.DataType == getCppuType( (const sal_uInt64*) 0 ) )
2326 : 0 : return sal_True;
2327 : : }
2328 [ # # ]: 0 : else if ( aFlavor.MimeType == "application/x-openoffice-wmf;windows_formatname=\"Image WMF\"" )
2329 : : {
2330 [ # # ][ # # ]: 0 : if ( aFlavor.DataType == getCppuType( (const Sequence< sal_Int8 >*) 0 ) )
2331 : 0 : return sal_True;
2332 [ # # ]: 0 : else if ( GraphicHelper::supportsMetaFileHandle_Impl()
[ # # # # ]
[ # # ]
2333 [ # # ]: 0 : && aFlavor.DataType == getCppuType( (const sal_uInt64*) 0 ) )
2334 : 0 : return sal_True;
2335 : : }
2336 [ # # ]: 0 : else if ( aFlavor.MimeType.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("application/x-openoffice-objectdescriptor-xml;windows_formatname=\"Star Object Descriptor (XML)\"")) )
2337 : : {
2338 [ # # ][ # # ]: 0 : if ( aFlavor.DataType == getCppuType( (const Sequence< sal_Int8 >*) 0 ) )
2339 : 0 : return sal_True;
2340 : : }
2341 [ # # ]: 0 : else if ( aFlavor.MimeType == "application/x-openoffice-embed-source;windows_formatname=\"Star EMBS\"" )
2342 : : {
2343 [ # # ][ # # ]: 0 : if ( aFlavor.DataType == getCppuType( (const Sequence< sal_Int8 >*) 0 ) )
2344 : 0 : return sal_True;
2345 : : }
2346 [ # # ]: 0 : else if ( aFlavor.MimeType == "application/x-openoffice-bitmap;windows_formatname=\"Bitmap\"" )
2347 : : {
2348 [ # # ][ # # ]: 0 : if ( aFlavor.DataType == getCppuType( (const Sequence< sal_Int8 >*) 0 ) )
2349 : 0 : return sal_True;
2350 : : }
2351 [ # # ]: 0 : else if ( aFlavor.MimeType == "image/png" )
2352 : : {
2353 [ # # ][ # # ]: 0 : if ( aFlavor.DataType == getCppuType( (const Sequence< sal_Int8 >*) 0 ) )
2354 : 0 : return sal_True;
2355 : : }
2356 : :
2357 [ # # ]: 0 : return sal_False;
2358 : : }
2359 : :
2360 : :
2361 : : //--------------------------------------------------------------------------------------------------------
2362 : : // XEventsSupplier
2363 : : //--------------------------------------------------------------------------------------------------------
2364 : :
2365 : 44 : uno::Reference< container::XNameReplace > SAL_CALL SfxBaseModel::getEvents() throw( uno::RuntimeException )
2366 : : {
2367 [ + - ]: 44 : SfxModelGuard aGuard( *this );
2368 : :
2369 [ + + ]: 44 : if ( ! m_pData->m_xEvents.is() )
2370 : : {
2371 [ + - ][ + - ]: 34 : m_pData->m_xEvents = new SfxEvents_Impl( m_pData->m_pObjectShell, this );
[ + - ][ + - ]
2372 : : }
2373 : :
2374 [ + - ]: 44 : return m_pData->m_xEvents;
2375 : : }
2376 : :
2377 : : //--------------------------------------------------------------------------------------------------------
2378 : : // XEmbeddedScripts
2379 : : //--------------------------------------------------------------------------------------------------------
2380 : :
2381 : 3368 : uno::Reference< script::XStorageBasedLibraryContainer > SAL_CALL SfxBaseModel::getBasicLibraries() throw (RuntimeException)
2382 : : {
2383 [ + - ]: 3368 : SfxModelGuard aGuard( *this );
2384 : :
2385 : 3368 : uno::Reference< script::XStorageBasedLibraryContainer > xBasicLibraries;
2386 [ + - ]: 3368 : if ( m_pData->m_pObjectShell )
2387 [ + - ][ + + ]: 3368 : xBasicLibraries.set( m_pData->m_pObjectShell->GetBasicContainer(), UNO_QUERY_THROW );
2388 [ + - ]: 3368 : return xBasicLibraries;
2389 : : }
2390 : :
2391 : 65 : uno::Reference< script::XStorageBasedLibraryContainer > SAL_CALL SfxBaseModel::getDialogLibraries() throw (RuntimeException)
2392 : : {
2393 [ + - ]: 65 : SfxModelGuard aGuard( *this );
2394 : :
2395 : 65 : uno::Reference< script::XStorageBasedLibraryContainer > xDialogLibraries;
2396 [ + - ]: 65 : if ( m_pData->m_pObjectShell )
2397 [ + - ][ + - ]: 65 : xDialogLibraries.set( m_pData->m_pObjectShell->GetDialogContainer(), UNO_QUERY_THROW );
2398 [ + - ]: 65 : return xDialogLibraries;
2399 : : }
2400 : :
2401 : 19 : ::sal_Bool SAL_CALL SfxBaseModel::getAllowMacroExecution() throw (RuntimeException)
2402 : : {
2403 [ + - ]: 19 : SfxModelGuard aGuard( *this );
2404 : :
2405 [ + - ]: 19 : if ( m_pData->m_pObjectShell )
2406 [ + - ][ + - ]: 19 : return m_pData->m_pObjectShell->AdjustMacroMode( String(), false );
[ + - ]
2407 [ + - ]: 19 : return sal_False;
2408 : : }
2409 : :
2410 : : //--------------------------------------------------------------------------------------------------------
2411 : : // XScriptInvocationContext
2412 : : //--------------------------------------------------------------------------------------------------------
2413 : :
2414 : 48 : Reference< document::XEmbeddedScripts > SAL_CALL SfxBaseModel::getScriptContainer() throw (RuntimeException)
2415 : : {
2416 [ + + ]: 48 : SfxModelGuard aGuard( *this );
2417 : :
2418 : 27 : Reference< document::XEmbeddedScripts > xDocumentScripts;
2419 : :
2420 : : try
2421 : : {
2422 [ + - ]: 27 : Reference< frame::XModel > xDocument( this );
2423 [ + - ]: 27 : xDocumentScripts.set( xDocument, uno::UNO_QUERY );
2424 [ - + ][ # # ]: 27 : while ( !xDocumentScripts.is() && xDocument.is() )
[ - + ]
2425 : : {
2426 [ # # ]: 0 : Reference< container::XChild > xDocAsChild( xDocument, uno::UNO_QUERY );
2427 [ # # ]: 0 : if ( !xDocAsChild.is() )
2428 : : {
2429 [ # # ]: 0 : xDocument = NULL;
2430 : : break;
2431 : : }
2432 : :
2433 [ # # ][ # # ]: 0 : xDocument.set( xDocAsChild->getParent(), uno::UNO_QUERY );
[ # # ]
2434 [ # # ][ # # ]: 0 : xDocumentScripts.set( xDocument, uno::UNO_QUERY );
2435 : 27 : }
2436 : : }
2437 [ # # # # ]: 0 : catch( const Exception& )
2438 : : {
2439 : : DBG_UNHANDLED_EXCEPTION();
2440 [ # # ]: 0 : xDocumentScripts = NULL;
2441 : : }
2442 : :
2443 [ + - ]: 48 : return xDocumentScripts;
2444 : : }
2445 : :
2446 : : //--------------------------------------------------------------------------------------------------------
2447 : : // XEventBroadcaster
2448 : : //--------------------------------------------------------------------------------------------------------
2449 : :
2450 : 2531 : void SAL_CALL SfxBaseModel::addEventListener( const uno::Reference< XDOCEVENTLISTENER >& aListener ) throw( uno::RuntimeException )
2451 : : {
2452 [ + - ]: 2531 : SfxModelGuard aGuard( *this, SfxModelGuard::E_INITIALIZING );
2453 : :
2454 [ + - ][ + - ]: 2531 : m_pData->m_aInterfaceContainer.addInterface( ::getCppuType((const uno::Reference< XDOCEVENTLISTENER >*)0), aListener );
[ + - ]
2455 : 2531 : }
2456 : :
2457 : : //--------------------------------------------------------------------------------------------------------
2458 : : // XEventBroadcaster
2459 : : //--------------------------------------------------------------------------------------------------------
2460 : :
2461 : 758 : void SAL_CALL SfxBaseModel::removeEventListener( const uno::Reference< XDOCEVENTLISTENER >& aListener ) throw( uno::RuntimeException )
2462 : : {
2463 [ + - ]: 758 : SfxModelGuard aGuard( *this );
2464 : :
2465 [ + - ][ + - ]: 758 : m_pData->m_aInterfaceContainer.removeInterface( ::getCppuType((const uno::Reference< XDOCEVENTLISTENER >*)0), aListener );
[ + - ]
2466 : 758 : }
2467 : :
2468 : : //--------------------------------------------------------------------------------------------------------
2469 : : // XDocumentEventBroadcaster
2470 : : //--------------------------------------------------------------------------------------------------------
2471 : : // ---------------------------------
2472 : 2578 : void SAL_CALL SfxBaseModel::addDocumentEventListener( const uno::Reference< document::XDocumentEventListener >& aListener )
2473 : : throw ( uno::RuntimeException )
2474 : : {
2475 [ + - ]: 2578 : SfxModelGuard aGuard( *this, SfxModelGuard::E_INITIALIZING );
2476 [ + - ][ + - ]: 2578 : m_pData->m_aInterfaceContainer.addInterface( ::getCppuType((const uno::Reference< document::XDocumentEventListener >*)0), aListener );
[ + - ]
2477 : 2578 : }
2478 : :
2479 : : // ---------------------------------
2480 : 0 : void SAL_CALL SfxBaseModel::removeDocumentEventListener( const uno::Reference< document::XDocumentEventListener >& aListener )
2481 : : throw ( uno::RuntimeException )
2482 : : {
2483 [ # # ]: 0 : SfxModelGuard aGuard( *this );
2484 [ # # ][ # # ]: 0 : m_pData->m_aInterfaceContainer.removeInterface( ::getCppuType((const uno::Reference< document::XDocumentEventListener >*)0), aListener );
[ # # ]
2485 : 0 : }
2486 : :
2487 : : // ---------------------------------
2488 : 0 : void SAL_CALL SfxBaseModel::notifyDocumentEvent( const ::rtl::OUString&, const uno::Reference< frame::XController2 >&, const uno::Any& )
2489 : : throw ( lang::IllegalArgumentException, lang::NoSupportException, uno::RuntimeException )
2490 : : {
2491 [ # # ]: 0 : throw lang::NoSupportException( ::rtl::OUString( "SfxBaseModel controlls all the sent notifications itself!" ), uno::Reference< uno::XInterface >() );
2492 : : }
2493 : :
2494 : : //________________________________________________________________________________________________________
2495 : : // SfxListener
2496 : : //________________________________________________________________________________________________________
2497 : :
2498 : 11828 : void addTitle_Impl( Sequence < ::com::sun::star::beans::PropertyValue >& rSeq, const ::rtl::OUString& rTitle )
2499 : : {
2500 : 11828 : sal_Int32 nCount = rSeq.getLength();
2501 : : sal_Int32 nArg;
2502 : :
2503 [ + + ]: 23307 : for ( nArg = 0; nArg < nCount; nArg++ )
2504 : : {
2505 : 19038 : ::com::sun::star::beans::PropertyValue& rProp = rSeq[nArg];
2506 [ + + ]: 19038 : if ( rProp.Name == "Title" )
2507 : : {
2508 : 7559 : rProp.Value <<= rTitle;
2509 : 7559 : break;
2510 : : }
2511 : : }
2512 : :
2513 [ + + ]: 11828 : if ( nArg == nCount )
2514 : : {
2515 : 4269 : rSeq.realloc( nCount+1 );
2516 [ + - ]: 4269 : rSeq[nCount].Name = ::rtl::OUString( "Title" );
2517 : 4269 : rSeq[nCount].Value <<= rTitle;
2518 : : }
2519 : 11828 : }
2520 : :
2521 : 168612 : void SfxBaseModel::Notify( SfxBroadcaster& rBC ,
2522 : : const SfxHint& rHint )
2523 : : {
2524 [ + + ]: 168612 : if ( !m_pData )
2525 : 168612 : return;
2526 : :
2527 [ + + ]: 167917 : if ( &rBC == m_pData->m_pObjectShell )
2528 : : {
2529 [ + - ][ + + ]: 142229 : SfxSimpleHint* pSimpleHint = PTR_CAST( SfxSimpleHint, &rHint );
2530 [ + + ][ + + ]: 142229 : if ( pSimpleHint && pSimpleHint->GetId() == SFX_HINT_DOCCHANGED )
[ + + ]
2531 : 69862 : changing();
2532 : :
2533 [ + - ][ + + ]: 142229 : SfxEventHint* pNamedHint = PTR_CAST( SfxEventHint, &rHint );
2534 [ + + ]: 142229 : if ( pNamedHint )
2535 : : {
2536 : :
2537 [ + + + + : 22265 : switch ( pNamedHint->GetEventId() )
+ + ]
2538 : : {
2539 : : case SFX_EVENT_STORAGECHANGED:
2540 : : {
2541 [ + + + + ]: 2835 : if ( m_pData->m_xUIConfigurationManager.is()
[ + + ]
2542 : 442 : && m_pData->m_pObjectShell->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED )
2543 : : {
2544 : 16 : uno::Reference< XSTORAGE > xConfigStorage;
2545 : 16 : rtl::OUString aUIConfigFolderName( "Configurations2" );
2546 : :
2547 [ + - ][ + - ]: 16 : xConfigStorage = getDocumentSubStorage( aUIConfigFolderName, com::sun::star::embed::ElementModes::READWRITE );
2548 [ - + ]: 16 : if ( !xConfigStorage.is() )
2549 [ # # ][ # # ]: 0 : xConfigStorage = getDocumentSubStorage( aUIConfigFolderName, com::sun::star::embed::ElementModes::READ );
2550 : :
2551 [ - + ][ # # ]: 16 : if ( xConfigStorage.is() || !m_pData->m_pObjectShell->GetStorage()->hasByName( aUIConfigFolderName ) )
[ # # ][ # # ]
[ # # ][ - + ]
[ + - # # ]
2552 : : {
2553 : : // the storage is different, since otherwise it could not be opened, so it must be exchanged
2554 [ + - ]: 16 : Reference< ui::XUIConfigurationStorage > xUIConfigStorage( m_pData->m_xUIConfigurationManager, uno::UNO_QUERY );
2555 [ + - ][ + - ]: 16 : xUIConfigStorage->setStorage( xConfigStorage );
2556 : : }
2557 : : else
2558 : : {
2559 : : OSL_FAIL( "Unexpected scenario!\n" );
2560 : 16 : }
2561 : : }
2562 : :
2563 [ + - ]: 2393 : ListenForStorage_Impl( m_pData->m_pObjectShell->GetStorage() );
2564 : : }
2565 : 2393 : break;
2566 : :
2567 : : case SFX_EVENT_LOADFINISHED:
2568 : : {
2569 : 891 : impl_getPrintHelper();
2570 [ + - ]: 891 : ListenForStorage_Impl( m_pData->m_pObjectShell->GetStorage() );
2571 : 891 : m_pData->m_bModifiedSinceLastSave = sal_False;
2572 : : }
2573 : 891 : break;
2574 : :
2575 : : case SFX_EVENT_SAVEASDOCDONE:
2576 : : {
2577 [ + - ]: 18 : m_pData->m_sURL = m_pData->m_pObjectShell->GetMedium()->GetName();
2578 : :
2579 [ + - ]: 18 : SfxItemSet *pSet = m_pData->m_pObjectShell->GetMedium()->GetItemSet();
2580 [ + - ]: 18 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs;
2581 [ + - ][ + - ]: 18 : ::rtl::OUString aTitle = m_pData->m_pObjectShell->GetTitle();
[ + - ]
2582 [ + - ]: 18 : TransformItems( SID_SAVEASDOC, *pSet, aArgs );
2583 [ + - ]: 18 : addTitle_Impl( aArgs, aTitle );
2584 [ + - ][ + - ]: 18 : attachResource( m_pData->m_pObjectShell->GetMedium()->GetName(), aArgs );
[ + - ]
2585 : : }
2586 : 18 : break;
2587 : :
2588 : : case SFX_EVENT_DOCCREATED:
2589 : : {
2590 : 1675 : impl_getPrintHelper();
2591 : 1675 : m_pData->m_bModifiedSinceLastSave = sal_False;
2592 : : }
2593 : 1675 : break;
2594 : :
2595 : : case SFX_EVENT_MODIFYCHANGED:
2596 : : {
2597 : 4617 : m_pData->m_bModifiedSinceLastSave = isModified();
2598 : : }
2599 : 4617 : break;
2600 : : }
2601 : :
2602 : :
2603 [ + - ][ + + ]: 22265 : SfxViewEventHint* pViewHint = PTR_CAST( SfxViewEventHint, &rHint );
2604 [ + + ][ + - ]: 22265 : postEvent_Impl( pNamedHint->GetEventName(), pViewHint ? pViewHint->GetController() : uno::Reference< frame::XController2 >() );
2605 : : }
2606 : :
2607 [ + + ]: 142229 : if ( pSimpleHint )
2608 : : {
2609 [ + + ]: 92761 : if ( pSimpleHint->GetId() == SFX_HINT_TITLECHANGED )
2610 : : {
2611 [ + - ][ + - ]: 11810 : ::rtl::OUString aTitle = m_pData->m_pObjectShell->GetTitle();
[ + - ]
2612 [ + - ]: 11810 : addTitle_Impl( m_pData->m_seqArguments, aTitle );
2613 [ + - ][ + - ]: 11810 : postEvent_Impl( GlobalEventConfig::GetEventName( STR_EVENT_TITLECHANGED ) );
2614 : : }
2615 [ + + ]: 92761 : if ( pSimpleHint->GetId() == SFX_HINT_MODECHANGED )
2616 : : {
2617 [ + - ][ + - ]: 1145 : postEvent_Impl( GlobalEventConfig::GetEventName( STR_EVENT_MODECHANGED ) );
2618 : : }
2619 : : }
2620 : : }
2621 : : }
2622 : :
2623 : : //________________________________________________________________________________________________________
2624 : : // public impl.
2625 : : //________________________________________________________________________________________________________
2626 : :
2627 : 69860 : void SfxBaseModel::NotifyModifyListeners_Impl() const
2628 : : {
2629 : 69860 : ::cppu::OInterfaceContainerHelper* pIC = m_pData->m_aInterfaceContainer.getContainer( ::getCppuType((const uno::Reference< XMODIFYLISTENER >*)0) );
2630 [ + + ]: 69860 : if ( pIC )
2631 : : {
2632 [ + - ][ + - ]: 42279 : lang::EventObject aEvent( (frame::XModel *)this );
2633 [ + - ][ + - ]: 42279 : pIC->notifyEach( &util::XModifyListener::modified, aEvent );
2634 : : }
2635 : :
2636 : : // this notification here is done too generously, we cannot simply assume that we're really modified
2637 : : // now, but we need to check it ...
2638 : 69860 : m_pData->m_bModifiedSinceLastSave = const_cast< SfxBaseModel* >( this )->isModified();
2639 : 69860 : }
2640 : :
2641 : 69862 : void SfxBaseModel::changing()
2642 : : {
2643 [ + - ]: 69862 : SfxModelGuard aGuard( *this );
2644 : :
2645 : : // the notification should not be sent if the document can not be modified
2646 [ + - ][ + - ]: 69862 : if ( !m_pData->m_pObjectShell.Is() || !m_pData->m_pObjectShell->IsEnableSetModified() )
[ + + ][ + + ]
2647 : 69862 : return;
2648 : :
2649 [ + - ][ + - ]: 69862 : NotifyModifyListeners_Impl();
[ + + ]
2650 : : }
2651 : :
2652 : : //________________________________________________________________________________________________________
2653 : : // public impl.
2654 : : //________________________________________________________________________________________________________
2655 : :
2656 : 157811 : SfxObjectShell* SfxBaseModel::GetObjectShell() const
2657 : : {
2658 [ + - ]: 157811 : return m_pData ? (SfxObjectShell*) m_pData->m_pObjectShell : 0;
2659 : : }
2660 : :
2661 : : //________________________________________________________________________________________________________
2662 : : // public impl.
2663 : : //________________________________________________________________________________________________________
2664 : :
2665 : 511724 : sal_Bool SfxBaseModel::IsInitialized() const
2666 : : {
2667 [ + - ][ - + ]: 511724 : if ( !m_pData || !m_pData->m_pObjectShell )
[ - + ]
2668 : : {
2669 : : OSL_FAIL( "SfxBaseModel::IsInitialized: this should have been caught earlier!" );
2670 : 0 : return sal_False;
2671 : : }
2672 : :
2673 : 511724 : return m_pData->m_pObjectShell->GetMedium() != NULL;
2674 : : }
2675 : :
2676 : 557363 : void SfxBaseModel::MethodEntryCheck( const bool i_mustBeInitialized ) const
2677 : : {
2678 [ + + ]: 557363 : if ( impl_isDisposed() )
2679 [ + - ][ + - ]: 603 : throw ::com::sun::star::lang::DisposedException( ::rtl::OUString(), *const_cast< SfxBaseModel* >( this ) );
2680 [ + + ][ + + ]: 556760 : if ( i_mustBeInitialized && !IsInitialized() )
[ + + ]
2681 [ + - ][ + - ]: 21 : throw ::com::sun::star::lang::NotInitializedException( ::rtl::OUString(), *const_cast< SfxBaseModel* >( this ) );
2682 : 556739 : }
2683 : :
2684 : 608548 : sal_Bool SfxBaseModel::impl_isDisposed() const
2685 : : {
2686 : 608548 : return ( m_pData == NULL ) ;
2687 : : }
2688 : :
2689 : : //________________________________________________________________________________________________________
2690 : : // private impl.
2691 : : //________________________________________________________________________________________________________
2692 : :
2693 : 18 : ::rtl::OUString SfxBaseModel::GetMediumFilterName_Impl()
2694 : : {
2695 : 18 : const SfxFilter* pFilter = NULL;
2696 : 18 : SfxMedium* pMedium = m_pData->m_pObjectShell->GetMedium();
2697 [ + - ]: 18 : if ( pMedium )
2698 : 18 : pFilter = pMedium->GetFilter();
2699 : :
2700 [ + - ]: 18 : if ( pFilter )
2701 : 18 : return pFilter->GetName();
2702 : :
2703 : 18 : return ::rtl::OUString();
2704 : : }
2705 : :
2706 : 177 : void SfxBaseModel::impl_store( const ::rtl::OUString& sURL ,
2707 : : const uno::Sequence< beans::PropertyValue >& seqArguments ,
2708 : : sal_Bool bSaveTo )
2709 : : {
2710 [ - + ]: 177 : if( sURL.isEmpty() )
2711 [ # # ]: 0 : throw frame::IllegalArgumentIOException();
2712 : :
2713 : 177 : sal_Bool bSaved = sal_False;
2714 [ + + ][ + - ]: 390 : if ( !bSaveTo && m_pData->m_pObjectShell && !sURL.isEmpty()
[ + - + - ]
[ - + ][ - + ]
2715 : 18 : && sURL.compareToAscii( "private:stream", 14 ) != COMPARE_EQUAL
2716 [ + - ][ + - ]: 195 : && ::utl::UCBContentHelper::EqualURLs( getLocation(), sURL ) )
[ + + ][ # # ]
2717 : : {
2718 : : // this is the same file URL as the current document location, try to use storeOwn if possible
2719 : :
2720 [ # # ]: 0 : ::comphelper::SequenceAsHashMap aArgHash( seqArguments );
2721 : 0 : ::rtl::OUString aFilterString( "FilterName" );
2722 [ # # ]: 0 : ::rtl::OUString aFilterName = aArgHash.getUnpackedValueOrDefault( aFilterString, ::rtl::OUString() );
2723 [ # # ]: 0 : if ( !aFilterName.isEmpty() )
2724 : : {
2725 : 0 : SfxMedium* pMedium = m_pData->m_pObjectShell->GetMedium();
2726 [ # # ]: 0 : if ( pMedium )
2727 : : {
2728 [ # # ]: 0 : const SfxFilter* pFilter = pMedium->GetFilter();
2729 [ # # ][ # # ]: 0 : if ( pFilter && aFilterName.equals( pFilter->GetFilterName() ) )
[ # # ][ # # ]
[ # # # # ]
2730 : : {
2731 [ # # ]: 0 : aArgHash.erase( aFilterString );
2732 [ # # ]: 0 : aArgHash.erase( ::rtl::OUString( "URL" ) );
2733 : :
2734 : : try
2735 : : {
2736 [ # # ][ # # ]: 0 : storeSelf( aArgHash.getAsConstPropertyValueList() );
[ # # ]
2737 : 0 : bSaved = sal_True;
2738 : : }
2739 [ # # # # ]: 0 : catch( const lang::IllegalArgumentException& )
2740 : : {
2741 : : // some additional arguments do not allow to use saving, SaveAs should be done
2742 : : // but only for normal documents, the shared documents would be overwritten in this case
2743 : : // that would mean an information loss
2744 : : // TODO/LATER: need a new interaction for this case
2745 [ # # # # ]: 0 : if ( m_pData->m_pObjectShell->IsDocShared() )
2746 : : {
2747 [ # # ]: 0 : m_pData->m_pObjectShell->AddLog( ::rtl::OUString( OSL_LOG_PREFIX "Can't store shared document!" ) );
2748 [ # # ]: 0 : m_pData->m_pObjectShell->StoreLog();
2749 : :
2750 [ # # # # : 0 : uno::Sequence< beans::NamedValue > aNewEncryptionData = aArgHash.getUnpackedValueOrDefault( ::rtl::OUString( "EncryptionData" ), uno::Sequence< beans::NamedValue >() );
# # ]
2751 [ # # ]: 0 : if ( !aNewEncryptionData.getLength() )
2752 : : {
2753 [ # # ]: 0 : ::rtl::OUString aNewPassword = aArgHash.getUnpackedValueOrDefault( ::rtl::OUString( "Password" ), ::rtl::OUString() );
2754 [ # # # # : 0 : aNewEncryptionData = ::comphelper::OStorageHelper::CreatePackageEncryptionData( aNewPassword );
# # ]
2755 : : }
2756 : :
2757 [ # # ]: 0 : uno::Sequence< beans::NamedValue > aOldEncryptionData;
2758 [ # # # # ]: 0 : GetEncryptionData_Impl( pMedium->GetItemSet(), aOldEncryptionData );
2759 : :
2760 [ # # # # : 0 : if ( !aOldEncryptionData.getLength() && !aNewEncryptionData.getLength() )
# # ]
2761 : 0 : throw;
2762 : : else
2763 : : {
2764 : : // if the password is changed a special error should be used in case of shared document
2765 [ # # ]: 0 : throw task::ErrorCodeIOException( ::rtl::OUString( "Cant change password for shared document." ), uno::Reference< uno::XInterface >(), ERRCODE_SFX_SHARED_NOPASSWORDCHANGE );
2766 : 0 : }
2767 : : }
2768 : : }
2769 : : }
2770 : : }
2771 [ # # ]: 0 : }
2772 : : }
2773 : :
2774 [ + - ][ + - ]: 177 : if ( !bSaved && m_pData->m_pObjectShell )
[ + - ]
2775 : : {
2776 : : SFX_APP()->NotifyEvent( SfxEventHint( bSaveTo ? SFX_EVENT_SAVETODOC : SFX_EVENT_SAVEASDOC, GlobalEventConfig::GetEventName( bSaveTo ? STR_EVENT_SAVETODOC : STR_EVENT_SAVEASDOC ),
2777 [ + + ][ + - ]: 177 : m_pData->m_pObjectShell ) );
[ + + ][ + - ]
[ + - ][ + - ]
[ + - ]
2778 : :
2779 [ + - ][ + - ]: 177 : SfxAllItemSet *aParams = new SfxAllItemSet( SFX_APP()->GetPool() );
[ + - ]
2780 [ + - ][ + - ]: 177 : aParams->Put( SfxStringItem( SID_FILE_NAME, String(sURL) ) );
[ + - ][ + - ]
[ + - ]
2781 [ + + ]: 177 : if ( bSaveTo )
2782 [ + - ][ + - ]: 159 : aParams->Put( SfxBoolItem( SID_SAVETO, sal_True ) );
[ + - ]
2783 : :
2784 [ + - ]: 177 : TransformParameters( SID_SAVEASDOC, seqArguments, *aParams );
2785 : :
2786 [ + - ][ + - ]: 177 : SFX_ITEMSET_ARG( aParams, pCopyStreamItem, SfxBoolItem, SID_COPY_STREAM_IF_POSSIBLE, sal_False );
2787 : :
2788 [ - + ][ # # ]: 177 : if ( pCopyStreamItem && pCopyStreamItem->GetValue() && !bSaveTo )
[ # # ][ - + ]
2789 : : {
2790 [ # # ]: 0 : m_pData->m_pObjectShell->AddLog( ::rtl::OUString( OSL_LOG_PREFIX "Misuse of CopyStreamIfPossible!" ) );
2791 [ # # ]: 0 : m_pData->m_pObjectShell->StoreLog();
2792 : :
2793 : : throw frame::IllegalArgumentIOException(
2794 : : ::rtl::OUString( "CopyStreamIfPossible parameter is not acceptable for storeAsURL() call!"),
2795 [ # # ]: 0 : uno::Reference< uno::XInterface >() );
2796 : : }
2797 : :
2798 : 177 : sal_uInt32 nModifyPasswordHash = 0;
2799 [ + - ]: 177 : uno::Sequence< beans::PropertyValue > aModifyPasswordInfo;
2800 [ + - ][ + - ]: 177 : SFX_ITEMSET_ARG( aParams, pModifyPasswordInfoItem, SfxUnoAnyItem, SID_MODIFYPASSWORDINFO, sal_False );
2801 [ - + ]: 177 : if ( pModifyPasswordInfoItem )
2802 : : {
2803 : : // it contains either a simple hash or a set of PropertyValues
2804 : : // TODO/LATER: the sequence of PropertyValue should replace the hash completely in future
2805 : 0 : sal_Int32 nMPHTmp = 0;
2806 : 0 : pModifyPasswordInfoItem->GetValue() >>= nMPHTmp;
2807 : 0 : nModifyPasswordHash = (sal_uInt32)nMPHTmp;
2808 [ # # ]: 0 : pModifyPasswordInfoItem->GetValue() >>= aModifyPasswordInfo;
2809 : : }
2810 [ + - ]: 177 : aParams->ClearItem( SID_MODIFYPASSWORDINFO );
2811 [ + - ]: 177 : sal_uInt32 nOldModifyPasswordHash = m_pData->m_pObjectShell->GetModifyPasswordHash();
2812 [ + - ]: 177 : m_pData->m_pObjectShell->SetModifyPasswordHash( nModifyPasswordHash );
2813 [ + - ]: 177 : uno::Sequence< beans::PropertyValue > aOldModifyPasswordInfo = m_pData->m_pObjectShell->GetModifyPasswordInfo();
2814 [ + - ]: 177 : m_pData->m_pObjectShell->SetModifyPasswordInfo( aModifyPasswordInfo );
2815 : :
2816 : : // since saving a document modifies its DocumentInfo, the current
2817 : : // DocumentInfo must be saved on "SaveTo", so it can be restored
2818 : : // after saving
2819 : : sal_Bool bCopyTo = bSaveTo ||
2820 [ + + ][ - + ]: 177 : m_pData->m_pObjectShell->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED;
2821 : 177 : uno::Reference<document::XDocumentProperties> xOldDocProps;
2822 : 177 : uno::Reference<document::XDocumentInfo> xOldDocInfo;
2823 [ + + ]: 177 : if ( bCopyTo )
2824 : : {
2825 [ + - ][ + - ]: 159 : xOldDocProps = getDocumentProperties();
2826 [ + + ]: 159 : if (m_pData->m_xDocumentInfo.is())
2827 : : {
2828 [ + - ][ + - ]: 5 : xOldDocInfo = getDocumentInfo();
2829 : : const Reference<util::XCloneable> xCloneable(xOldDocInfo,
2830 [ + - ]: 5 : UNO_QUERY_THROW);
2831 : : const Reference<document::XDocumentInfo> xNewDocInfo(
2832 [ + - ][ + - ]: 5 : xCloneable->createClone(), UNO_QUERY_THROW);
[ + - ]
2833 : : const Reference<document::XDocumentPropertiesSupplier> xDPS(
2834 [ + - ]: 5 : xNewDocInfo, UNO_QUERY_THROW);
2835 : : const Reference<document::XDocumentProperties> xNewDocProps(
2836 [ + - ][ + - ]: 5 : xDPS->getDocumentProperties());
2837 [ + - ]: 5 : m_pData->m_xDocumentProperties = xNewDocProps;
2838 [ + - ]: 5 : m_pData->m_xDocumentInfo = xNewDocInfo;
2839 : : }
2840 : : else // try not to create DocumentInfo if it does not exist...
2841 : : {
2842 : : const Reference<util::XCloneable> xCloneable(xOldDocProps,
2843 [ + - ]: 154 : UNO_QUERY_THROW);
2844 : : const Reference<document::XDocumentProperties> xNewDocProps(
2845 [ + - ][ + - ]: 154 : xCloneable->createClone(), UNO_QUERY_THROW);
[ + - ]
2846 [ + - ]: 154 : m_pData->m_xDocumentProperties = xNewDocProps;
2847 : : }
2848 : : }
2849 : :
2850 [ + - ][ + - ]: 177 : sal_Bool bRet = m_pData->m_pObjectShell->APISaveAs_Impl( sURL, aParams );
[ + - ]
2851 : :
2852 [ + + ]: 177 : if ( bCopyTo )
2853 : : {
2854 : : // restore DocumentInfo if a copy was created
2855 [ + - ]: 159 : m_pData->m_xDocumentProperties = xOldDocProps;
2856 [ + - ]: 159 : m_pData->m_xDocumentInfo = xOldDocInfo;
2857 : : }
2858 : :
2859 : 177 : uno::Reference < task::XInteractionHandler > xHandler;
2860 [ + - ][ + - ]: 177 : SFX_ITEMSET_ARG( aParams, pItem, SfxUnoAnyItem, SID_INTERACTIONHANDLER, sal_False);
2861 [ - + ]: 177 : if ( pItem )
2862 [ # # ]: 0 : pItem->GetValue() >>= xHandler;
2863 : :
2864 [ + - ][ + - ]: 177 : DELETEZ( aParams );
2865 : :
2866 [ + - ]: 177 : sal_uInt32 nErrCode = m_pData->m_pObjectShell->GetErrorCode();
2867 [ - + ][ # # ]: 177 : if ( !bRet && !nErrCode )
2868 : : {
2869 [ # # ]: 0 : m_pData->m_pObjectShell->AddLog( ::rtl::OUString( OSL_LOG_PREFIX "Storing has failed, no error is set!" ) );
2870 : 0 : nErrCode = ERRCODE_IO_CANTWRITE;
2871 : : }
2872 [ + - ]: 177 : m_pData->m_pObjectShell->ResetError();
2873 : :
2874 [ + - ]: 177 : if ( bRet )
2875 : : {
2876 [ + + ]: 177 : if ( nErrCode )
2877 : : {
2878 : : // must be a warning - use Interactionhandler if possible or abandone
2879 [ - + ]: 3 : if ( xHandler.is() )
2880 : : {
2881 : : // TODO/LATER: a general way to set the error context should be available
2882 [ # # ][ # # ]: 0 : SfxErrorContext aEc( ERRCTX_SFX_SAVEASDOC, m_pData->m_pObjectShell->GetTitle() );
[ # # ]
2883 : :
2884 [ # # ]: 0 : ::com::sun::star::task::ErrorCodeRequest aErrorCode;
2885 : 0 : aErrorCode.ErrCode = nErrCode;
2886 [ # # ][ # # ]: 0 : SfxMedium::CallApproveHandler( xHandler, uno::makeAny( aErrorCode ), sal_False );
[ # # ][ # # ]
2887 : : }
2888 : : }
2889 : :
2890 [ + - ]: 177 : m_pData->m_pObjectShell->AddLog( ::rtl::OUString( OSL_LOG_PREFIX "Storing succeeded!" ) );
2891 [ + + ]: 177 : if ( !bSaveTo )
2892 : : {
2893 [ + - ]: 18 : m_pData->m_aPreusedFilterName = GetMediumFilterName_Impl();
2894 [ + - ]: 18 : m_pData->m_pObjectShell->SetModifyPasswordEntered();
2895 : :
2896 [ + - ][ + - ]: 18 : SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_SAVEASDOCDONE, GlobalEventConfig::GetEventName(STR_EVENT_SAVEASDOCDONE), m_pData->m_pObjectShell ) );
[ + - ][ + - ]
[ + - ]
2897 : : }
2898 : : else
2899 : : {
2900 [ + - ]: 159 : m_pData->m_pObjectShell->SetModifyPasswordHash( nOldModifyPasswordHash );
2901 [ + - ]: 159 : m_pData->m_pObjectShell->SetModifyPasswordInfo( aOldModifyPasswordInfo );
2902 : :
2903 [ + - ][ + - ]: 159 : SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_SAVETODOCDONE, GlobalEventConfig::GetEventName(STR_EVENT_SAVETODOCDONE), m_pData->m_pObjectShell ) );
[ + - ][ + - ]
[ + - ]
2904 : : }
2905 : : }
2906 : : else
2907 : : {
2908 : : // let the logring be stored to the related file
2909 [ # # ]: 0 : m_pData->m_pObjectShell->AddLog( ::rtl::OUString( OSL_LOG_PREFIX "Storing failed!" ) );
2910 [ # # ]: 0 : m_pData->m_pObjectShell->StoreLog();
2911 : :
2912 [ # # ]: 0 : m_pData->m_pObjectShell->SetModifyPasswordHash( nOldModifyPasswordHash );
2913 [ # # ]: 0 : m_pData->m_pObjectShell->SetModifyPasswordInfo( aOldModifyPasswordInfo );
2914 : :
2915 : :
2916 : : SFX_APP()->NotifyEvent( SfxEventHint( bSaveTo ? SFX_EVENT_SAVETODOCFAILED : SFX_EVENT_SAVEASDOCFAILED, GlobalEventConfig::GetEventName( bSaveTo ? STR_EVENT_SAVETODOCFAILED : STR_EVENT_SAVEASDOCFAILED),
2917 [ # # ][ # # ]: 0 : m_pData->m_pObjectShell ) );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
2918 : :
2919 [ # # ]: 0 : throw task::ErrorCodeIOException( ::rtl::OUString(), uno::Reference< uno::XInterface >(), nErrCode );
2920 [ + - ][ + - ]: 177 : }
2921 : : }
2922 : 177 : }
2923 : :
2924 : : //********************************************************************************************************
2925 : : namespace {
2926 : : template< typename ListenerT, typename EventT >
2927 : : class NotifySingleListenerIgnoreRE
2928 : : {
2929 : : private:
2930 : : typedef void ( SAL_CALL ListenerT::*NotificationMethod )( const EventT& );
2931 : : NotificationMethod m_pMethod;
2932 : : const EventT& m_rEvent;
2933 : : public:
2934 : 58395 : NotifySingleListenerIgnoreRE( NotificationMethod method, const EventT& event ) : m_pMethod( method ), m_rEvent( event ) { }
2935 : :
2936 : 60594 : void operator()( const uno::Reference<ListenerT>& listener ) const
2937 : : {
2938 : : try
2939 : : {
2940 [ + - ][ - + ]: 60594 : (listener.get()->*m_pMethod)( m_rEvent );
[ + - ][ + - ]
[ - + ][ + - ]
2941 : : }
2942 : 0 : catch( uno::RuntimeException& )
2943 : : {
2944 : : // this exception is ignored to avoid problems with invalid listeners, the listener should be probably thrown away in future
2945 : : }
2946 [ # # ][ # # ]: 60594 : }
2947 : : };
2948 : : } // anonymous namespace
2949 : :
2950 : 35220 : void SfxBaseModel::postEvent_Impl( const ::rtl::OUString& aName, const uno::Reference< frame::XController2 >& xController )
2951 : : {
2952 : : // object already disposed?
2953 [ - + ]: 35220 : if ( impl_isDisposed() )
2954 : 0 : return;
2955 : :
2956 : : DBG_ASSERT( !aName.isEmpty(), "Empty event name!" );
2957 [ - + ]: 35220 : if (aName.isEmpty())
2958 : 0 : return;
2959 : :
2960 : : ::cppu::OInterfaceContainerHelper* pIC =
2961 : 35220 : m_pData->m_aInterfaceContainer.getContainer( ::getCppuType( (const uno::Reference< document::XDocumentEventListener >*)0 ) );
2962 [ + + ]: 35220 : if ( pIC )
2963 : : {
2964 : : SAL_INFO("sfx2", "SfxDocumentEvent: " + aName);
2965 : :
2966 [ + - ][ + - ]: 31667 : document::DocumentEvent aDocumentEvent( (frame::XModel*)this, aName, xController, uno::Any() );
2967 : :
2968 : : pIC->forEach< document::XDocumentEventListener, NotifySingleListenerIgnoreRE< document::XDocumentEventListener, document::DocumentEvent > >(
2969 : : NotifySingleListenerIgnoreRE< document::XDocumentEventListener, document::DocumentEvent >(
2970 : : &document::XDocumentEventListener::documentEventOccured,
2971 [ + - ][ + - ]: 31667 : aDocumentEvent ) );
2972 : : }
2973 : :
2974 : 35220 : pIC = m_pData->m_aInterfaceContainer.getContainer( ::getCppuType( (const uno::Reference< document::XEventListener >*)0 ) );
2975 [ + + ]: 35220 : if ( pIC )
2976 : : {
2977 : : SAL_INFO("sfx2", "SfxEvent: " + aName);
2978 : :
2979 [ + - ][ + - ]: 26728 : document::EventObject aEvent( (frame::XModel*)this, aName );
2980 : :
2981 : : pIC->forEach< document::XEventListener, NotifySingleListenerIgnoreRE< document::XEventListener, document::EventObject > >(
2982 : : NotifySingleListenerIgnoreRE< document::XEventListener, document::EventObject >(
2983 : : &document::XEventListener::notifyEvent,
2984 [ + - ][ + - ]: 35220 : aEvent ) );
2985 : : }
2986 : :
2987 : : }
2988 : :
2989 : 4462 : uno::Reference < container::XIndexAccess > SAL_CALL SfxBaseModel::getViewData() throw(::com::sun::star::uno::RuntimeException)
2990 : : {
2991 [ + - ]: 4462 : SfxModelGuard aGuard( *this );
2992 : :
2993 [ + - ][ + + ]: 4462 : if ( m_pData->m_pObjectShell.Is() && !m_pData->m_contViewData.is() )
[ + + ]
2994 : : {
2995 [ + - ]: 3653 : SfxViewFrame *pActFrame = SfxViewFrame::Current();
2996 [ + + ][ + - ]: 3653 : if ( !pActFrame || pActFrame->GetObjectShell() != m_pData->m_pObjectShell )
[ + + ][ + + ]
2997 [ + - ]: 2265 : pActFrame = SfxViewFrame::GetFirst( m_pData->m_pObjectShell );
2998 : :
2999 [ + + ][ + - ]: 3653 : if ( !pActFrame || !pActFrame->GetViewShell() )
[ - + ][ + + ]
3000 : : // currently no frame for this document at all or View is under construction
3001 : 2265 : return uno::Reference < container::XIndexAccess >();
3002 : :
3003 : : m_pData->m_contViewData = Reference < container::XIndexAccess >(
3004 [ + - ][ + - ]: 2776 : ::comphelper::getProcessServiceFactory()->createInstance(
3005 : 1388 : DEFINE_CONST_UNICODE("com.sun.star.document.IndexedPropertyValues") ),
3006 [ + - ][ + - ]: 1388 : uno::UNO_QUERY );
[ + - ][ + - ]
[ + - ][ + - ]
3007 : :
3008 [ - + ]: 1388 : if ( !m_pData->m_contViewData.is() )
3009 : : {
3010 : : // error: no container class available!
3011 : 0 : return uno::Reference < container::XIndexAccess >();
3012 : : }
3013 : :
3014 [ + - ]: 1388 : uno::Reference < container::XIndexContainer > xCont( m_pData->m_contViewData, uno::UNO_QUERY );
3015 : 1388 : sal_Int32 nCount = 0;
3016 [ + - ]: 1388 : uno::Sequence < beans::PropertyValue > aSeq;
3017 : 1388 : ::com::sun::star::uno::Any aAny;
3018 [ + - ][ + + ]: 2776 : for ( SfxViewFrame *pFrame = SfxViewFrame::GetFirst( m_pData->m_pObjectShell ); pFrame;
[ + - ]
3019 : 1388 : pFrame = SfxViewFrame::GetNext( *pFrame, m_pData->m_pObjectShell ) )
3020 : : {
3021 : 1388 : sal_Bool bIsActive = ( pFrame == pActFrame );
3022 [ + - ][ + - ]: 1388 : pFrame->GetViewShell()->WriteUserDataSequence( aSeq );
3023 [ + - ]: 1388 : aAny <<= aSeq;
3024 [ + - ][ - + ]: 1388 : xCont->insertByIndex( bIsActive ? 0 : nCount, aAny );
[ + - ]
3025 : 1388 : nCount++;
3026 [ + - ]: 3653 : }
3027 : : }
3028 : :
3029 [ + - ]: 4462 : return m_pData->m_contViewData;
3030 : : }
3031 : :
3032 : 1321 : void SAL_CALL SfxBaseModel::setViewData( const uno::Reference < container::XIndexAccess >& aData ) throw(::com::sun::star::uno::RuntimeException)
3033 : : {
3034 [ + - ]: 1321 : SfxModelGuard aGuard( *this );
3035 : :
3036 [ + - ][ + - ]: 1321 : m_pData->m_contViewData = aData;
3037 : 1321 : }
3038 : :
3039 : : /** calls all XEventListeners */
3040 : 3386 : void SfxBaseModel::notifyEvent( const ::com::sun::star::document::EventObject& aEvent ) const
3041 : : {
3042 : : // object already disposed?
3043 [ - + ]: 3386 : if ( impl_isDisposed() )
3044 : 3386 : return;
3045 : :
3046 : : ::cppu::OInterfaceContainerHelper* pIC = m_pData->m_aInterfaceContainer.getContainer(
3047 : 3386 : ::getCppuType((const uno::Reference< XDOCEVENTLISTENER >*)0) );
3048 [ + - ]: 3386 : if( pIC )
3049 : :
3050 : : {
3051 [ + - ]: 3386 : ::cppu::OInterfaceIteratorHelper aIt( *pIC );
3052 [ + + ]: 8960 : while( aIt.hasMoreElements() )
3053 : : {
3054 : : try
3055 : : {
3056 [ + - ][ + - ]: 5574 : ((XDOCEVENTLISTENER *)aIt.next())->notifyEvent( aEvent );
3057 : : }
3058 [ # # # # ]: 0 : catch( uno::RuntimeException& )
3059 : : {
3060 [ # # ]: 0 : aIt.remove();
3061 : : }
3062 [ + - ]: 3386 : }
3063 : : }
3064 : : }
3065 : :
3066 : : /** returns true if someone added a XEventListener to this XEventBroadcaster */
3067 : 7540 : sal_Bool SfxBaseModel::hasEventListeners() const
3068 : : {
3069 [ + - ][ + + ]: 7540 : return !impl_isDisposed() && (NULL != m_pData->m_aInterfaceContainer.getContainer( ::getCppuType((const uno::Reference< XDOCEVENTLISTENER >*)0) ) );
3070 : : }
3071 : :
3072 : 0 : void SAL_CALL SfxBaseModel::addPrintJobListener( const uno::Reference< view::XPrintJobListener >& xListener ) throw (uno::RuntimeException)
3073 : : {
3074 [ # # ]: 0 : SfxModelGuard aGuard( *this, SfxModelGuard::E_INITIALIZING );
3075 : :
3076 [ # # ][ # # ]: 0 : if ( impl_getPrintHelper() )
3077 : : {
3078 [ # # ]: 0 : uno::Reference < view::XPrintJobBroadcaster > xPJB( m_pData->m_xPrintable, uno::UNO_QUERY );
3079 [ # # ]: 0 : if ( xPJB.is() )
3080 [ # # ][ # # ]: 0 : xPJB->addPrintJobListener( xListener );
3081 [ # # ]: 0 : }
3082 : 0 : }
3083 : :
3084 : 0 : void SAL_CALL SfxBaseModel::removePrintJobListener( const uno::Reference< view::XPrintJobListener >& xListener ) throw (uno::RuntimeException)
3085 : : {
3086 [ # # ]: 0 : SfxModelGuard aGuard( *this );
3087 : :
3088 [ # # ][ # # ]: 0 : if ( impl_getPrintHelper() )
3089 : : {
3090 [ # # ]: 0 : uno::Reference < view::XPrintJobBroadcaster > xPJB( m_pData->m_xPrintable, uno::UNO_QUERY );
3091 [ # # ]: 0 : if ( xPJB.is() )
3092 [ # # ][ # # ]: 0 : xPJB->removePrintJobListener( xListener );
3093 [ # # ]: 0 : }
3094 : 0 : }
3095 : :
3096 : : // simple declaration of class SvObject is enough
3097 : : // the corresponding <so3/iface.hxx> cannon be included because it provides
3098 : : // declaration of class SvBorder that conflicts with ../../inc/viewfrm.hxx
3099 : : class SvObject;
3100 : 89700 : sal_Int64 SAL_CALL SfxBaseModel::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException)
3101 : : {
3102 [ + - ]: 89700 : SvGlobalName aName( aIdentifier );
3103 [ + - ][ + - ]: 269100 : if ((aName == SvGlobalName( SO3_GLOBAL_CLASSID )) ||
[ + - ][ + + ]
[ + - ][ + - ]
[ + + # # ]
3104 [ + - ][ + - ]: 179400 : (aName == SvGlobalName( SFX_GLOBAL_CLASSID )))
[ + - ][ + - ]
[ # # ]
3105 : : {
3106 [ + - ]: 88490 : SolarMutexGuard aGuard;
3107 [ + - ]: 88490 : SfxObjectShell *const pObjectShell(GetObjectShell());
3108 [ + - ]: 88490 : if (pObjectShell)
3109 : : {
3110 : : // SO3_GLOBAL_CLASSID is apparently used by binfilter :(
3111 [ + - ][ + - ]: 88490 : if ( aName == SvGlobalName( SO3_GLOBAL_CLASSID ) )
[ + - ][ - + ]
3112 : 0 : return (sal_Int64)(sal_IntPtr)(SvObject*) pObjectShell;
3113 [ + - ][ + - ]: 88490 : else if ( aName == SvGlobalName( SFX_GLOBAL_CLASSID ) )
[ + - ][ + - ]
3114 : 88490 : return (sal_Int64)(sal_IntPtr)(SfxObjectShell*) pObjectShell;
3115 [ + - ][ - + ]: 88490 : }
3116 : : }
3117 : :
3118 [ + - ]: 89700 : return 0;
3119 : : }
3120 : :
3121 : : //____________________________________________________________________________________________________
3122 : : // XDocumentSubStorageSupplier
3123 : : //____________________________________________________________________________________________________
3124 : :
3125 : 3284 : void SfxBaseModel::ListenForStorage_Impl( const uno::Reference< embed::XStorage >& xStorage )
3126 : : {
3127 [ + - ]: 3284 : uno::Reference< util::XModifiable > xModifiable( xStorage, uno::UNO_QUERY );
3128 [ + + ]: 3284 : if ( xModifiable.is() )
3129 : : {
3130 [ + + ]: 3056 : if ( !m_pData->m_pStorageModifyListen.is() )
3131 : : {
3132 [ + - ][ + - ]: 2186 : m_pData->m_pStorageModifyListen = new ::sfx2::DocumentStorageModifyListener( *m_pData, Application::GetSolarMutex() );
[ + - ]
3133 : : }
3134 : :
3135 : : // no need to deregister the listening for old storage since it should be disposed automatically
3136 [ + - ][ + - ]: 3056 : xModifiable->addModifyListener( m_pData->m_pStorageModifyListen.get() );
[ + - ][ + - ]
3137 : 3284 : }
3138 : 3284 : }
3139 : :
3140 : 4013 : uno::Reference< XSTORAGE > SAL_CALL SfxBaseModel::getDocumentSubStorage( const ::rtl::OUString& aStorageName, sal_Int32 nMode )
3141 : : throw ( uno::RuntimeException)
3142 : : {
3143 [ + - ]: 4013 : SfxModelGuard aGuard( *this );
3144 : :
3145 : 4013 : uno::Reference< XSTORAGE > xResult;
3146 [ + - ]: 4013 : if ( m_pData->m_pObjectShell.Is() )
3147 : : {
3148 [ + - ]: 4013 : uno::Reference< embed::XStorage > xStorage = m_pData->m_pObjectShell->GetStorage();
3149 [ + + ]: 4013 : if ( xStorage.is() )
3150 : : {
3151 : : try
3152 : : {
3153 [ + - ][ + + ]: 3554 : xResult = xStorage->openStorageElement( aStorageName, nMode );
[ + - ][ - + ]
3154 : : }
3155 [ + - ]: 1556 : catch ( uno::Exception& )
3156 : : {
3157 : : }
3158 : 4013 : }
3159 : : }
3160 : :
3161 [ + - ]: 4013 : return xResult;
3162 : : }
3163 : :
3164 : 0 : Sequence< ::rtl::OUString > SAL_CALL SfxBaseModel::getDocumentSubStoragesNames()
3165 : : throw ( io::IOException,
3166 : : RuntimeException )
3167 : : {
3168 [ # # ]: 0 : SfxModelGuard aGuard( *this );
3169 : :
3170 [ # # ]: 0 : Sequence< ::rtl::OUString > aResult;
3171 : 0 : sal_Bool bSuccess = sal_False;
3172 [ # # ]: 0 : if ( m_pData->m_pObjectShell.Is() )
3173 : : {
3174 [ # # ]: 0 : uno::Reference < embed::XStorage > xStorage = m_pData->m_pObjectShell->GetStorage();
3175 [ # # ]: 0 : uno::Reference < container::XNameAccess > xAccess( xStorage, uno::UNO_QUERY );
3176 [ # # ]: 0 : if ( xAccess.is() )
3177 : : {
3178 [ # # ][ # # ]: 0 : Sequence< ::rtl::OUString > aTemp = xAccess->getElementNames();
3179 : 0 : sal_Int32 nResultSize = 0;
3180 [ # # ]: 0 : for ( sal_Int32 n = 0; n < aTemp.getLength(); n++ )
3181 : : {
3182 [ # # ][ # # ]: 0 : if ( xStorage->isStorageElement( aTemp[n] ) )
[ # # ][ # # ]
3183 : : {
3184 [ # # ]: 0 : aResult.realloc( ++nResultSize );
3185 [ # # ][ # # ]: 0 : aResult[ nResultSize - 1 ] = aTemp[n];
3186 : : }
3187 : : }
3188 : :
3189 [ # # ]: 0 : bSuccess = sal_True;
3190 : 0 : }
3191 : : }
3192 : :
3193 [ # # ]: 0 : if ( !bSuccess )
3194 [ # # ]: 0 : throw io::IOException();
3195 : :
3196 [ # # ]: 0 : return aResult;
3197 : : }
3198 : :
3199 : : //____________________________________________________________________________________________________
3200 : : // XScriptProviderSupplier
3201 : : //____________________________________________________________________________________________________
3202 : :
3203 : :
3204 : 19 : uno::Reference< script::provider::XScriptProvider > SAL_CALL SfxBaseModel::getScriptProvider()
3205 : : throw ( uno::RuntimeException )
3206 : : {
3207 [ + - ]: 19 : SfxModelGuard aGuard( *this );
3208 : :
3209 : 19 : uno::Reference< script::provider::XScriptProvider > xScriptProvider;
3210 : :
3211 [ + - ][ + - ]: 19 : ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
3212 : : Reference< script::provider::XScriptProviderFactory > xScriptProviderFactory(
3213 [ + - ][ + - ]: 19 : aContext.getSingleton( "com.sun.star.script.provider.theMasterScriptProviderFactory" ), uno::UNO_QUERY_THROW );
3214 : :
3215 : : try
3216 : : {
3217 [ + - ]: 19 : Reference< XScriptInvocationContext > xScriptContext( this );
3218 [ + - ][ + - ]: 19 : xScriptProvider.set( xScriptProviderFactory->createScriptProvider( makeAny( xScriptContext ) ), uno::UNO_SET_THROW );
[ + - ][ + - ]
3219 : : }
3220 : 0 : catch( const uno::RuntimeException& )
3221 : : {
3222 : 0 : throw;
3223 : : }
3224 [ # # # ]: 0 : catch( const lang::IllegalArgumentException& )
3225 : : {
3226 : : throw lang::WrappedTargetRuntimeException(
3227 : : ::rtl::OUString(),
3228 : : *this,
3229 : : ::cppu::getCaughtException()
3230 [ # # # # : 0 : );
# # ]
3231 : : }
3232 : :
3233 [ + - ][ + - ]: 19 : return xScriptProvider;
3234 : : }
3235 : :
3236 : : //____________________________________________________________________________________________________
3237 : : // XUIConfigurationManagerSupplier
3238 : : //____________________________________________________________________________________________________
3239 : :
3240 : 715 : rtl::OUString SfxBaseModel::getRuntimeUID() const
3241 : : {
3242 : : OSL_ENSURE( !m_pData->m_sRuntimeUID.isEmpty(),
3243 : : "SfxBaseModel::getRuntimeUID - ID is empty!" );
3244 : 715 : return m_pData->m_sRuntimeUID;
3245 : : }
3246 : :
3247 : 0 : sal_Bool SfxBaseModel::hasValidSignatures() const
3248 : : {
3249 [ # # ]: 0 : SolarMutexGuard aGuard;
3250 [ # # ]: 0 : if ( m_pData->m_pObjectShell.Is() )
3251 [ # # ]: 0 : return ( m_pData->m_pObjectShell->ImplGetSignatureState( sal_False ) == SIGNATURESTATE_SIGNATURES_OK );
3252 [ # # ]: 0 : return sal_False;
3253 : : }
3254 : :
3255 : 0 : static void GetCommandFromSequence( rtl::OUString& rCommand, sal_Int32& nIndex, const uno::Sequence< beans::PropertyValue >& rSeqPropValue )
3256 : : {
3257 : 0 : rtl::OUString aCommand;
3258 : 0 : nIndex = -1;
3259 : :
3260 [ # # ]: 0 : for ( sal_Int32 i = 0; i < rSeqPropValue.getLength(); i++ )
3261 : : {
3262 [ # # ]: 0 : if ( rSeqPropValue[i].Name == "Command" )
3263 : : {
3264 : 0 : rSeqPropValue[i].Value >>= rCommand;
3265 : 0 : nIndex = i;
3266 : 0 : return;
3267 : : }
3268 [ # # ]: 0 : }
3269 : : }
3270 : :
3271 : 0 : static void ConvertSlotsToCommands( SfxObjectShell* pDoc, uno::Reference< container::XIndexContainer >& rToolbarDefinition )
3272 : : {
3273 [ # # ]: 0 : if ( pDoc )
3274 : : {
3275 : 0 : Any aAny;
3276 [ # # ][ # # ]: 0 : SfxModule* pModule( pDoc->GetFactory().GetModule() );
3277 : 0 : rtl::OUString aSlotCmd( "slot:" );
3278 : 0 : rtl::OUString aUnoCmd( ".uno:" );
3279 [ # # ]: 0 : uno::Sequence< beans::PropertyValue > aSeqPropValue;
3280 : :
3281 [ # # ][ # # ]: 0 : for ( sal_Int32 i = 0; i < rToolbarDefinition->getCount(); i++ )
[ # # ]
3282 : : {
3283 : 0 : sal_Int32 nIndex( -1 );
3284 : 0 : rtl::OUString aCommand;
3285 : :
3286 [ # # ][ # # ]: 0 : if ( rToolbarDefinition->getByIndex( i ) >>= aSeqPropValue )
[ # # ][ # # ]
3287 : : {
3288 [ # # ]: 0 : GetCommandFromSequence( aCommand, nIndex, aSeqPropValue );
3289 [ # # ][ # # ]: 0 : if ( nIndex >= 0 && ( aCommand.indexOf( aSlotCmd ) == 0 ))
[ # # ]
3290 : : {
3291 : 0 : rtl::OUString aSlot( aCommand.copy( 5 ));
3292 : :
3293 : : // We have to replace the old "slot-Command" with our new ".uno:-Command"
3294 [ # # ][ # # ]: 0 : const SfxSlot* pSlot = pModule->GetSlotPool()->GetSlot( sal_uInt16( aSlot.toInt32() ));
3295 [ # # ]: 0 : if ( pSlot )
3296 : : {
3297 [ # # ]: 0 : rtl::OUStringBuffer aStrBuf( aUnoCmd );
3298 [ # # ]: 0 : aStrBuf.appendAscii( pSlot->GetUnoName() );
3299 : :
3300 [ # # ]: 0 : aCommand = aStrBuf.makeStringAndClear();
3301 [ # # ][ # # ]: 0 : aSeqPropValue[nIndex].Value <<= aCommand;
3302 [ # # ][ # # ]: 0 : rToolbarDefinition->replaceByIndex( i, Any( aSeqPropValue ));
[ # # ]
3303 : 0 : }
3304 : : }
3305 : : }
3306 [ # # ]: 0 : }
3307 : : }
3308 : 0 : }
3309 : :
3310 : 73147 : uno::Reference< ui::XUIConfigurationManager > SAL_CALL SfxBaseModel::getUIConfigurationManager()
3311 : : throw ( uno::RuntimeException )
3312 : : {
3313 [ + - ]: 73147 : SfxModelGuard aGuard( *this );
3314 : :
3315 [ + + ]: 73147 : if ( !m_pData->m_xUIConfigurationManager.is() )
3316 : : {
3317 : : uno::Reference< ui::XUIConfigurationManager > xNewUIConfMan(
3318 [ + - ][ + - ]: 4270 : ::comphelper::getProcessServiceFactory()->createInstance(
3319 : 2135 : ::rtl::OUString("com.sun.star.ui.UIConfigurationManager")),
3320 [ + - ][ + - ]: 2135 : uno::UNO_QUERY );
3321 : :
3322 [ + - ]: 2135 : Reference< ui::XUIConfigurationStorage > xUIConfigStorage( xNewUIConfMan, uno::UNO_QUERY );
3323 [ + - ]: 2135 : if ( xUIConfigStorage.is() )
3324 : : {
3325 : 2135 : uno::Reference< XSTORAGE > xConfigStorage;
3326 : :
3327 : 2135 : rtl::OUString aUIConfigFolderName( "Configurations2" );
3328 : : // First try to open with READWRITE and then READ
3329 [ + - ][ + - ]: 2135 : xConfigStorage = getDocumentSubStorage( aUIConfigFolderName, embed::ElementModes::READWRITE );
3330 [ + + ]: 2135 : if ( xConfigStorage.is() )
3331 : : {
3332 : 1982 : rtl::OUString aMediaTypeProp( "MediaType" );
3333 : : rtl::OUString aUIConfigMediaType(
3334 : 1982 : "application/vnd.sun.xml.ui.configuration" );
3335 : 1982 : rtl::OUString aMediaType;
3336 [ + - ]: 1982 : uno::Reference< beans::XPropertySet > xPropSet( xConfigStorage, uno::UNO_QUERY );
3337 [ + - ][ + - ]: 1982 : Any a = xPropSet->getPropertyValue( aMediaTypeProp );
3338 [ + - ][ + + ]: 1982 : if ( !( a >>= aMediaType ) || aMediaType.isEmpty())
[ + + ]
3339 : : {
3340 [ + - ]: 1885 : a <<= aUIConfigMediaType;
3341 [ + - ][ + - ]: 1885 : xPropSet->setPropertyValue( aMediaTypeProp, a );
3342 : 1982 : }
3343 : : }
3344 : : else
3345 [ + - ][ + - ]: 153 : xConfigStorage = getDocumentSubStorage( aUIConfigFolderName, embed::ElementModes::READ );
3346 : :
3347 : : // initialize ui configuration manager with document substorage
3348 [ + - ][ + - ]: 2135 : xUIConfigStorage->setStorage( xConfigStorage );
3349 : :
3350 : : // embedded objects did not support local configuration data until OOo 3.0, so there's nothing to
3351 : : // migrate
3352 [ + + ]: 2135 : if ( m_pData->m_pObjectShell->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED )
3353 : : {
3354 : : // Import old UI configuration from OOo 1.x
3355 : 1709 : uno::Reference< XSTORAGE > xOOo1ConfigStorage;
3356 : 1709 : rtl::OUString aOOo1UIConfigFolderName( "Configurations" );
3357 : :
3358 : : // Try to open with READ
3359 [ + - ][ + - ]: 1709 : xOOo1ConfigStorage = getDocumentSubStorage( aOOo1UIConfigFolderName, embed::ElementModes::READ );
3360 [ - + ]: 1709 : if ( xOOo1ConfigStorage.is() )
3361 : : {
3362 [ # # ]: 0 : uno::Reference< lang::XMultiServiceFactory > xServiceMgr( ::comphelper::getProcessServiceFactory() );
3363 [ # # ]: 0 : uno::Sequence< uno::Reference< container::XIndexContainer > > rToolbars;
3364 : :
3365 : : sal_Bool bImported = framework::UIConfigurationImporterOOo1x::ImportCustomToolbars(
3366 [ # # ]: 0 : xNewUIConfMan, rToolbars, xServiceMgr, xOOo1ConfigStorage );
3367 [ # # ]: 0 : if ( bImported )
3368 : : {
3369 [ # # ]: 0 : SfxObjectShell* pObjShell = SfxBaseModel::GetObjectShell();
3370 : :
3371 : 0 : rtl::OUString aNum( "private:resource/toolbar/custom_OOo1x_" );
3372 : 0 : rtl::OUString aTitle( "Toolbar " );
3373 [ # # ]: 0 : for ( sal_Int32 i = 0; i < rToolbars.getLength(); i++ )
3374 : : {
3375 : 0 : rtl::OUString aCustomTbxName = aNum + rtl::OUString::valueOf( i + 1 );
3376 : 0 : rtl::OUString aCustomTbxTitle = aTitle + rtl::OUString::valueOf( i + 1 );
3377 : :
3378 [ # # ]: 0 : uno::Reference< container::XIndexContainer > xToolbar = rToolbars[i];
3379 [ # # ]: 0 : ConvertSlotsToCommands( pObjShell, xToolbar );
3380 [ # # ][ # # ]: 0 : if ( !xNewUIConfMan->hasSettings( aCustomTbxName ))
[ # # ]
3381 : : {
3382 : : // Set UIName for the toolbar with container property
3383 [ # # ]: 0 : uno::Reference< beans::XPropertySet > xPropSet( xToolbar, UNO_QUERY );
3384 [ # # ]: 0 : if ( xPropSet.is() )
3385 : : {
3386 : : try
3387 : : {
3388 : 0 : rtl::OUString aPropName( "UIName" );
3389 [ # # ]: 0 : Any aAny( aCustomTbxTitle );
3390 [ # # ][ # # ]: 0 : xPropSet->setPropertyValue( aPropName, aAny );
[ # # ]
3391 : : }
3392 [ # # ]: 0 : catch ( beans::UnknownPropertyException& )
3393 : : {
3394 : : }
3395 : : }
3396 : :
3397 [ # # ]: 0 : uno::Reference< container::XIndexAccess > xToolbarData( xToolbar, uno::UNO_QUERY );
3398 [ # # ][ # # ]: 0 : xNewUIConfMan->insertSettings( aCustomTbxName, xToolbarData );
3399 [ # # ]: 0 : uno::Reference< ui::XUIConfigurationPersistence > xPersist( xNewUIConfMan, uno::UNO_QUERY );
3400 [ # # ][ # # ]: 0 : xPersist->store();
3401 : : }
3402 : 0 : }
3403 [ # # ]: 0 : }
3404 : 1709 : }
3405 : 2135 : }
3406 : : }
3407 : :
3408 [ + - ]: 2135 : m_pData->m_xUIConfigurationManager = xNewUIConfMan;
3409 : : }
3410 : :
3411 [ + - ]: 73147 : return m_pData->m_xUIConfigurationManager;
3412 : : }
3413 : :
3414 : : //____________________________________________________________________________________________________
3415 : : // XVisualObject
3416 : : //____________________________________________________________________________________________________
3417 : :
3418 : 0 : void SAL_CALL SfxBaseModel::setVisualAreaSize( sal_Int64 nAspect, const awt::Size& aSize )
3419 : : throw ( lang::IllegalArgumentException,
3420 : : embed::WrongStateException,
3421 : : uno::Exception,
3422 : : uno::RuntimeException )
3423 : : {
3424 [ # # ]: 0 : SfxModelGuard aGuard( *this );
3425 : :
3426 [ # # ]: 0 : if ( !m_pData->m_pObjectShell.Is() )
3427 [ # # ]: 0 : throw uno::Exception(); // TODO: error handling
3428 : :
3429 [ # # ]: 0 : SfxViewFrame* pViewFrm = SfxViewFrame::GetFirst( m_pData->m_pObjectShell, sal_False );
3430 [ # # ][ # # ]: 0 : if ( pViewFrm && m_pData->m_pObjectShell->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED && !pViewFrm->GetFrame().IsInPlace() )
[ # # ][ # # ]
[ # # ][ # # ]
3431 : : {
3432 [ # # ][ # # ]: 0 : Window* pWindow = VCLUnoHelper::GetWindow( pViewFrm->GetFrame().GetFrameInterface()->getContainerWindow() );
[ # # ][ # # ]
[ # # ]
3433 [ # # ]: 0 : Size aWinSize = pWindow->GetSizePixel();
3434 [ # # ]: 0 : awt::Size aCurrent = getVisualAreaSize( nAspect );
3435 : 0 : Size aDiff( aSize.Width-aCurrent.Width, aSize.Height-aCurrent.Height );
3436 [ # # ][ # # ]: 0 : aDiff = pViewFrm->GetViewShell()->GetWindow()->LogicToPixel( aDiff );
3437 : 0 : aWinSize.Width() += aDiff.Width();
3438 : 0 : aWinSize.Height() += aDiff.Height();
3439 [ # # ]: 0 : pWindow->SetSizePixel( aWinSize );
3440 : : }
3441 : : else
3442 : : {
3443 [ # # ]: 0 : Rectangle aTmpRect = m_pData->m_pObjectShell->GetVisArea( ASPECT_CONTENT );
3444 [ # # ]: 0 : aTmpRect.SetSize( Size( aSize.Width, aSize.Height ) );
3445 [ # # ]: 0 : m_pData->m_pObjectShell->SetVisArea( aTmpRect );
3446 [ # # ]: 0 : }
3447 : 0 : }
3448 : :
3449 : 675 : awt::Size SAL_CALL SfxBaseModel::getVisualAreaSize( sal_Int64 /*nAspect*/ )
3450 : : throw ( lang::IllegalArgumentException,
3451 : : embed::WrongStateException,
3452 : : uno::Exception,
3453 : : uno::RuntimeException)
3454 : : {
3455 [ + - ]: 675 : SfxModelGuard aGuard( *this );
3456 : :
3457 [ - + ]: 675 : if ( !m_pData->m_pObjectShell.Is() )
3458 [ # # ]: 0 : throw uno::Exception(); // TODO: error handling
3459 : :
3460 [ + - ]: 675 : Rectangle aTmpRect = m_pData->m_pObjectShell->GetVisArea( ASPECT_CONTENT );
3461 : :
3462 [ + - ][ + - ]: 675 : return awt::Size( aTmpRect.GetWidth(), aTmpRect.GetHeight() );
[ + - ]
3463 : : }
3464 : :
3465 : :
3466 : 675 : sal_Int32 SAL_CALL SfxBaseModel::getMapUnit( sal_Int64 /*nAspect*/ )
3467 : : throw ( uno::Exception,
3468 : : uno::RuntimeException)
3469 : : {
3470 [ + - ]: 675 : SfxModelGuard aGuard( *this );
3471 : :
3472 [ - + ]: 675 : if ( !m_pData->m_pObjectShell.Is() )
3473 [ # # ]: 0 : throw uno::Exception(); // TODO: error handling
3474 : :
3475 [ + - ][ + - ]: 675 : return VCLUnoHelper::VCL2UnoEmbedMapUnit( m_pData->m_pObjectShell->GetMapUnit() );
[ + - ]
3476 : : }
3477 : :
3478 : 6816 : embed::VisualRepresentation SAL_CALL SfxBaseModel::getPreferredVisualRepresentation( ::sal_Int64 /*nAspect*/ )
3479 : : throw ( lang::IllegalArgumentException,
3480 : : embed::WrongStateException,
3481 : : uno::Exception,
3482 : : uno::RuntimeException )
3483 : : {
3484 [ + - ]: 6816 : SfxModelGuard aGuard( *this );
3485 : :
3486 : : datatransfer::DataFlavor aDataFlavor(
3487 : : ::rtl::OUString("application/x-openoffice-gdimetafile;windows_formatname=\"GDIMetaFile\"" ),
3488 : : ::rtl::OUString("GDIMetaFile"),
3489 [ + - ]: 6816 : ::getCppuType( (const uno::Sequence< sal_Int8 >*) NULL ) );
3490 : :
3491 : 6816 : embed::VisualRepresentation aVisualRepresentation;
3492 [ + - ]: 6816 : aVisualRepresentation.Data = getTransferData( aDataFlavor );
3493 : 6816 : aVisualRepresentation.Flavor = aDataFlavor;
3494 : :
3495 [ + - ]: 6816 : return aVisualRepresentation;
3496 : : }
3497 : :
3498 : : //____________________________________________________________________________________________________
3499 : : // XStorageBasedDocument
3500 : : //____________________________________________________________________________________________________
3501 : :
3502 : 0 : void SAL_CALL SfxBaseModel::loadFromStorage( const uno::Reference< XSTORAGE >& xStorage,
3503 : : const uno::Sequence< beans::PropertyValue >& aMediaDescriptor )
3504 : : throw ( lang::IllegalArgumentException,
3505 : : frame::DoubleInitializationException,
3506 : : IOEXCEPTION,
3507 : : EXCEPTION,
3508 : : uno::RuntimeException )
3509 : : {
3510 [ # # ]: 0 : SfxModelGuard aGuard( *this, SfxModelGuard::E_INITIALIZING );
3511 [ # # ][ # # ]: 0 : if ( IsInitialized() )
3512 [ # # ][ # # ]: 0 : throw ::com::sun::star::frame::DoubleInitializationException( ::rtl::OUString(), *this );
3513 : :
3514 : : // after i36090 is fixed the pool from object shell can be used
3515 : : // SfxAllItemSet aSet( m_pData->m_pObjectShell->GetPool() );
3516 [ # # ][ # # ]: 0 : SfxAllItemSet aSet( SFX_APP()->GetPool() );
3517 : :
3518 : : // the BaseURL is part of the ItemSet
3519 [ # # ][ # # ]: 0 : SfxMedium* pMedium = new SfxMedium( xStorage, String() );
[ # # ][ # # ]
3520 [ # # ]: 0 : TransformParameters( SID_OPENDOC, aMediaDescriptor, aSet );
3521 [ # # ][ # # ]: 0 : pMedium->GetItemSet()->Put( aSet );
3522 : :
3523 : : // allow to use an interactionhandler (if there is one)
3524 [ # # ]: 0 : pMedium->UseInteractionHandler( sal_True );
3525 : :
3526 [ # # ][ # # ]: 0 : SFX_ITEMSET_ARG( &aSet, pTemplateItem, SfxBoolItem, SID_TEMPLATE, sal_False);
3527 [ # # ][ # # ]: 0 : sal_Bool bTemplate = pTemplateItem && pTemplateItem->GetValue();
3528 [ # # ][ # # ]: 0 : m_pData->m_pObjectShell->SetActivateEvent_Impl( bTemplate ? SFX_EVENT_CREATEDOC : SFX_EVENT_OPENDOC );
3529 : 0 : m_pData->m_pObjectShell->Get_Impl()->bOwnsStorage = sal_False;
3530 : :
3531 : : // load document
3532 [ # # ][ # # ]: 0 : if ( !m_pData->m_pObjectShell->DoLoad(pMedium) )
3533 : : {
3534 [ # # ]: 0 : sal_uInt32 nError = m_pData->m_pObjectShell->GetErrorCode();
3535 : : throw task::ErrorCodeIOException( ::rtl::OUString(),
3536 : : uno::Reference< uno::XInterface >(),
3537 [ # # ][ # # ]: 0 : nError ? nError : ERRCODE_IO_CANTREAD );
3538 [ # # ][ # # ]: 0 : }
3539 : 0 : }
3540 : :
3541 : 852 : void SAL_CALL SfxBaseModel::storeToStorage( const uno::Reference< XSTORAGE >& xStorage,
3542 : : const uno::Sequence< beans::PropertyValue >& aMediaDescriptor )
3543 : : throw ( lang::IllegalArgumentException,
3544 : : IOEXCEPTION,
3545 : : EXCEPTION,
3546 : : uno::RuntimeException )
3547 : : {
3548 [ + - ]: 852 : SfxModelGuard aGuard( *this );
3549 : :
3550 : 852 : uno::Reference< XSTORAGE > xResult;
3551 [ - + ]: 852 : if ( !m_pData->m_pObjectShell.Is() )
3552 [ # # ]: 0 : throw IOEXCEPTION(); // TODO:
3553 : :
3554 [ + - ]: 852 : SfxAllItemSet aSet( m_pData->m_pObjectShell->GetPool() );
3555 [ + - ]: 852 : TransformParameters( SID_SAVEASDOC, aMediaDescriptor, aSet );
3556 : :
3557 : : // TODO/LATER: may be a special URL "private:storage" should be used
3558 [ + - ][ + - ]: 852 : SFX_ITEMSET_ARG( &aSet, pItem, SfxStringItem, SID_FILTER_NAME, sal_False );
3559 : 852 : sal_Int32 nVersion = SOFFICE_FILEFORMAT_CURRENT;
3560 [ + - ]: 852 : if( pItem )
3561 : : {
3562 [ + - ]: 852 : String aFilterName = pItem->GetValue();
3563 [ + - ][ + - ]: 852 : const SfxFilter* pFilter = SFX_APP()->GetFilterMatcher().GetFilter4FilterName( aFilterName );
[ + - ]
3564 [ + - ][ + - ]: 852 : if ( pFilter && pFilter->UsesStorage() )
[ + - ]
3565 [ + - ]: 852 : nVersion = pFilter->GetVersion();
3566 : : }
3567 : :
3568 : 852 : sal_Bool bSuccess = sal_False;
3569 [ + - ][ + - ]: 852 : if ( xStorage == m_pData->m_pObjectShell->GetStorage() )
[ - + ]
3570 : : {
3571 : : // storing to the own storage
3572 [ # # ]: 0 : bSuccess = m_pData->m_pObjectShell->DoSave();
3573 : : }
3574 : : else
3575 : : {
3576 : : // TODO/LATER: if the provided storage has some data inside the storing might fail, probably the storage must be truncated
3577 : : // TODO/LATER: is it possible to have a template here?
3578 [ + - ]: 852 : m_pData->m_pObjectShell->SetupStorage( xStorage, nVersion, sal_False );
3579 : :
3580 : : // BaseURL is part of the ItemSet
3581 [ + - ][ + - ]: 852 : SfxMedium aMedium( xStorage, String(), &aSet );
[ + - ]
3582 [ + - ]: 852 : aMedium.CanDisposeStorage_Impl( sal_False );
3583 [ + - ][ + - ]: 852 : if ( aMedium.GetFilter() )
3584 : : {
3585 : : // storing without a valid filter will often crash
3586 [ + - ]: 852 : bSuccess = m_pData->m_pObjectShell->DoSaveObjectAs( aMedium, sal_True );
3587 [ + - ]: 852 : m_pData->m_pObjectShell->DoSaveCompleted( NULL );
3588 [ + - ]: 852 : }
3589 : : }
3590 : :
3591 [ + - ]: 852 : sal_uInt32 nError = m_pData->m_pObjectShell->GetErrorCode();
3592 [ + - ]: 852 : m_pData->m_pObjectShell->ResetError();
3593 : :
3594 : : // the warnings are currently not transported
3595 [ - + ]: 852 : if ( !bSuccess )
3596 : : {
3597 : : throw task::ErrorCodeIOException( ::rtl::OUString(),
3598 : : uno::Reference< uno::XInterface >(),
3599 [ # # ][ # # ]: 0 : nError ? nError : ERRCODE_IO_GENERAL );
3600 [ + - ][ + - ]: 852 : }
3601 : 852 : }
3602 : :
3603 : 852 : void SAL_CALL SfxBaseModel::switchToStorage( const uno::Reference< XSTORAGE >& xStorage )
3604 : : throw ( lang::IllegalArgumentException,
3605 : : IOEXCEPTION,
3606 : : EXCEPTION,
3607 : : uno::RuntimeException )
3608 : : {
3609 [ + - ]: 852 : SfxModelGuard aGuard( *this );
3610 : :
3611 : 852 : uno::Reference< XSTORAGE > xResult;
3612 [ - + ]: 852 : if ( !m_pData->m_pObjectShell.Is() )
3613 [ # # ]: 0 : throw IOEXCEPTION(); // TODO:
3614 : :
3615 : : // the persistence should be switched only if the storage is different
3616 [ + - ][ + - ]: 852 : if ( xStorage != m_pData->m_pObjectShell->GetStorage() )
[ + - ]
3617 : : {
3618 [ + - ][ - + ]: 852 : if ( !m_pData->m_pObjectShell->SwitchPersistance( xStorage ) )
3619 : : {
3620 [ # # ]: 0 : sal_uInt32 nError = m_pData->m_pObjectShell->GetErrorCode();
3621 : : throw task::ErrorCodeIOException( ::rtl::OUString(),
3622 : : uno::Reference< uno::XInterface >(),
3623 [ # # ][ # # ]: 0 : nError ? nError : ERRCODE_IO_GENERAL );
3624 : : }
3625 : : else
3626 : : {
3627 : : // UICfgMgr has a reference to the old storage, update it
3628 [ + - ][ + - ]: 852 : uno::Reference< ui::XUIConfigurationStorage > xUICfgMgrStorage( getUIConfigurationManager(), uno::UNO_QUERY );
3629 [ + - ]: 852 : if ( xUICfgMgrStorage.is() )
3630 [ + - ][ + - ]: 852 : xUICfgMgrStorage->setStorage( xStorage );
3631 : : }
3632 : : }
3633 [ + - ]: 852 : m_pData->m_pObjectShell->Get_Impl()->bOwnsStorage = sal_False;
3634 : 852 : }
3635 : :
3636 : 3104 : uno::Reference< XSTORAGE > SAL_CALL SfxBaseModel::getDocumentStorage()
3637 : : throw ( IOEXCEPTION,
3638 : : EXCEPTION,
3639 : : uno::RuntimeException )
3640 : : {
3641 [ + - ]: 3104 : SfxModelGuard aGuard( *this );
3642 : :
3643 : 3104 : uno::Reference< XSTORAGE > xResult;
3644 [ - + ]: 3104 : if ( !m_pData->m_pObjectShell.Is() )
3645 [ # # ]: 0 : throw IOEXCEPTION(); // TODO
3646 : :
3647 [ + - ][ + - ]: 3104 : return m_pData->m_pObjectShell->GetStorage();
3648 : : }
3649 : :
3650 : 0 : void SAL_CALL SfxBaseModel::addStorageChangeListener(
3651 : : const uno::Reference< document::XStorageChangeListener >& xListener )
3652 : : throw ( uno::RuntimeException )
3653 : : {
3654 [ # # ]: 0 : SfxModelGuard aGuard( *this, SfxModelGuard::E_INITIALIZING );
3655 : :
3656 : : m_pData->m_aInterfaceContainer.addInterface(
3657 [ # # ][ # # ]: 0 : ::getCppuType((const uno::Reference< document::XStorageChangeListener >*)0), xListener );
[ # # ]
3658 : 0 : }
3659 : :
3660 : 0 : void SAL_CALL SfxBaseModel::removeStorageChangeListener(
3661 : : const uno::Reference< document::XStorageChangeListener >& xListener )
3662 : : throw ( uno::RuntimeException )
3663 : : {
3664 [ # # ]: 0 : SfxModelGuard aGuard( *this );
3665 : :
3666 : : m_pData->m_aInterfaceContainer.removeInterface(
3667 [ # # ][ # # ]: 0 : ::getCppuType((const uno::Reference< document::XStorageChangeListener >*)0), xListener );
[ # # ]
3668 : 0 : }
3669 : :
3670 : : #include "printhelper.hxx"
3671 : 2566 : bool SfxBaseModel::impl_getPrintHelper()
3672 : : {
3673 [ + + ]: 2566 : if ( m_pData->m_xPrintable.is() )
3674 : 2 : return true;
3675 [ + - ][ + - ]: 2564 : m_pData->m_xPrintable = new SfxPrintHelper();
[ + - ]
3676 [ + - ]: 2564 : uno::Reference < lang::XInitialization > xInit( m_pData->m_xPrintable, uno::UNO_QUERY );
3677 [ + - ]: 2564 : uno::Sequence < uno::Any > aValues(1);
3678 [ + - ][ + - ]: 2564 : aValues[0] <<= uno::Reference < frame::XModel > (static_cast< frame::XModel* >(this), uno::UNO_QUERY );
[ + - ]
3679 [ + - ][ + - ]: 2564 : xInit->initialize( aValues );
3680 [ + - ]: 2564 : uno::Reference < view::XPrintJobBroadcaster > xBrd( m_pData->m_xPrintable, uno::UNO_QUERY );
3681 [ + - ][ + - ]: 2564 : xBrd->addPrintJobListener( new SfxPrintHelperListener_Impl( m_pData ) );
[ + - ][ + - ]
[ + - ]
3682 [ + - ]: 2566 : return true;
3683 : : }
3684 : :
3685 : : //=============================================================================
3686 : : // css.frame.XModule
3687 : 0 : void SAL_CALL SfxBaseModel::setIdentifier(const ::rtl::OUString& Identifier)
3688 : : throw (css::uno::RuntimeException)
3689 : : {
3690 [ # # ]: 0 : SfxModelGuard aGuard( *this );
3691 [ # # ]: 0 : m_pData->m_sModuleIdentifier = Identifier;
3692 : 0 : }
3693 : :
3694 : : //=============================================================================
3695 : : // css.frame.XModule
3696 : 154447 : ::rtl::OUString SAL_CALL SfxBaseModel::getIdentifier()
3697 : : throw (css::uno::RuntimeException)
3698 : : {
3699 [ + - ]: 154447 : SfxModelGuard aGuard( *this );
3700 [ - + ]: 154447 : if (!m_pData->m_sModuleIdentifier.isEmpty())
3701 : 0 : return m_pData->m_sModuleIdentifier;
3702 [ + - ]: 154447 : if (m_pData->m_pObjectShell)
3703 [ + - ][ + - ]: 154447 : return m_pData->m_pObjectShell->GetFactory().GetDocumentServiceName();
3704 [ + - ]: 154447 : return ::rtl::OUString();
3705 : : }
3706 : :
3707 : : //=============================================================================
3708 : 8485 : css::uno::Reference< css::frame::XTitle > SfxBaseModel::impl_getTitleHelper ()
3709 : : {
3710 [ + - ]: 8485 : SfxModelGuard aGuard( *this );
3711 : :
3712 [ + + ]: 8485 : if ( ! m_pData->m_xTitleHelper.is ())
3713 : : {
3714 [ + - ]: 1722 : css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = ::comphelper::getProcessServiceFactory ();
3715 : 1722 : const ::rtl::OUString SERVICENAME_DESKTOP("com.sun.star.frame.Desktop");
3716 [ + - ][ + - ]: 1722 : css::uno::Reference< css::frame::XUntitledNumbers > xDesktop(xSMGR->createInstance(SERVICENAME_DESKTOP), css::uno::UNO_QUERY_THROW);
[ + - ]
3717 [ + - ]: 1722 : css::uno::Reference< css::frame::XModel > xThis (static_cast< css::frame::XModel* >(this), css::uno::UNO_QUERY_THROW);
3718 : :
3719 [ + - ]: 1722 : ::framework::TitleHelper* pHelper = new ::framework::TitleHelper(xSMGR);
3720 [ + - ][ + - ]: 1722 : m_pData->m_xTitleHelper = css::uno::Reference< css::frame::XTitle >(static_cast< ::cppu::OWeakObject* >(pHelper), css::uno::UNO_QUERY_THROW);
3721 [ + - ]: 1722 : pHelper->setOwner (xThis );
3722 [ + - ]: 1722 : pHelper->connectWithUntitledNumbers (xDesktop);
3723 : : }
3724 : :
3725 [ + - ]: 8485 : return m_pData->m_xTitleHelper;
3726 : : }
3727 : :
3728 : : //=============================================================================
3729 : 1727 : css::uno::Reference< css::frame::XUntitledNumbers > SfxBaseModel::impl_getUntitledHelper ()
3730 : : {
3731 [ + - ]: 1727 : SfxModelGuard aGuard( *this );
3732 : :
3733 [ + + ]: 1727 : if ( ! m_pData->m_xNumberedControllers.is ())
3734 : : {
3735 [ + - ]: 1709 : css::uno::Reference< css::frame::XModel > xThis (static_cast< css::frame::XModel* >(this), css::uno::UNO_QUERY_THROW);
3736 [ + - ]: 1709 : ::comphelper::NumberedCollection* pHelper = new ::comphelper::NumberedCollection();
3737 : :
3738 [ + - ][ + - ]: 1709 : m_pData->m_xNumberedControllers = css::uno::Reference< css::frame::XUntitledNumbers >(static_cast< ::cppu::OWeakObject* >(pHelper), css::uno::UNO_QUERY_THROW);
3739 : :
3740 [ + - ]: 1709 : pHelper->setOwner (xThis);
3741 [ + - ]: 1709 : pHelper->setUntitledPrefix (::rtl::OUString(" : "));
3742 : : }
3743 : :
3744 [ + - ]: 1727 : return m_pData->m_xNumberedControllers;
3745 : : }
3746 : :
3747 : : //=============================================================================
3748 : : // css.frame.XTitle
3749 : 6756 : ::rtl::OUString SAL_CALL SfxBaseModel::getTitle()
3750 : : throw (css::uno::RuntimeException)
3751 : : {
3752 : : // SYNCHRONIZED ->
3753 [ + - ]: 6756 : SfxModelGuard aGuard( *this );
3754 : :
3755 [ + - ][ + - ]: 6756 : ::rtl::OUString aResult = impl_getTitleHelper()->getTitle ();
[ + - ]
3756 [ + - ][ + + ]: 6756 : if ( !m_pData->m_bExternalTitle && m_pData->m_pObjectShell )
[ + + ]
3757 : : {
3758 : 6752 : SfxMedium* pMedium = m_pData->m_pObjectShell->GetMedium();
3759 [ + - ]: 6752 : if ( pMedium )
3760 : : {
3761 : : try {
3762 [ + - ]: 6752 : ::ucbhelper::Content aContent( pMedium->GetName(),
3763 [ + + ]: 13504 : uno::Reference<ucb::XCommandEnvironment>() );
3764 : : const uno::Reference < beans::XPropertySetInfo > xProps
3765 [ + - ]: 1410 : = aContent.getProperties();
3766 [ + - ]: 1410 : if ( xProps.is() )
3767 : : {
3768 : 1410 : ::rtl::OUString aServerTitle( "TitleOnServer" );
3769 [ + - ][ - + ]: 1410 : if ( xProps->hasPropertyByName( aServerTitle ) )
[ + - ]
3770 : : {
3771 [ # # ]: 0 : uno::Any aAny = aContent.getPropertyValue( aServerTitle );
3772 : 0 : aAny >>= aResult;
3773 : 1410 : }
3774 [ + - ]: 6752 : }
[ - + - ]
3775 : : }
3776 [ + - ]: 5342 : catch (const ucb::ContentCreationException &)
3777 : : {
3778 : : }
3779 [ # # ]: 0 : catch (const ucb::CommandAbortedException &)
3780 : : {
3781 : : }
3782 [ + - ][ + - ]: 6752 : SFX_ITEMSET_ARG( pMedium->GetItemSet(), pRepairedDocItem, SfxBoolItem, SID_REPAIRPACKAGE, sal_False );
[ + - ]
3783 [ - + ][ # # ]: 6752 : if ( pRepairedDocItem && pRepairedDocItem->GetValue() )
[ - + ]
3784 [ # # ][ # # ]: 0 : aResult += SfxResId(STR_REPAIREDDOCUMENT).toString();
3785 : : }
3786 : :
3787 [ + - ][ + + ]: 6752 : if ( m_pData->m_pObjectShell->IsReadOnlyUI() || (pMedium && pMedium->IsReadOnly()) )
[ + - ][ + - ]
[ + + ][ + + ]
3788 [ + - ][ + - ]: 15 : aResult += SfxResId(STR_READONLY).toString();
3789 [ + - ][ - + ]: 6737 : else if ( m_pData->m_pObjectShell->IsDocShared() )
3790 [ # # ][ # # ]: 0 : aResult += SfxResId(STR_SHARED).toString();
3791 : :
3792 [ + - ][ - + ]: 6752 : if ( m_pData->m_pObjectShell->GetDocumentSignatureState() == SIGNATURESTATE_SIGNATURES_OK )
3793 [ # # ][ # # ]: 0 : aResult += SfxResId(RID_XMLSEC_DOCUMENTSIGNED).toString();
3794 : : }
3795 : :
3796 [ + - ]: 6756 : return aResult;
3797 : : }
3798 : :
3799 : : //=============================================================================
3800 : : // css.frame.XTitle
3801 : 2 : void SAL_CALL SfxBaseModel::setTitle( const ::rtl::OUString& sTitle )
3802 : : throw (css::uno::RuntimeException)
3803 : : {
3804 : : // SYNCHRONIZED ->
3805 [ + - ]: 2 : SfxModelGuard aGuard( *this );
3806 : :
3807 [ + - ][ + - ]: 2 : impl_getTitleHelper()->setTitle (sTitle);
[ + - ]
3808 [ + - ]: 2 : m_pData->m_bExternalTitle = sal_True;
3809 : 2 : }
3810 : :
3811 : : //=============================================================================
3812 : : // css.frame.XTitleChangeBroadcaster
3813 : 1727 : void SAL_CALL SfxBaseModel::addTitleChangeListener( const css::uno::Reference< css::frame::XTitleChangeListener >& xListener )
3814 : : throw (css::uno::RuntimeException)
3815 : : {
3816 : : // SYNCHRONIZED ->
3817 [ + - ]: 1727 : SfxModelGuard aGuard( *this, SfxModelGuard::E_INITIALIZING );
3818 : :
3819 [ + - ][ + - ]: 1727 : css::uno::Reference< css::frame::XTitleChangeBroadcaster > xBroadcaster(impl_getTitleHelper(), css::uno::UNO_QUERY);
3820 [ + - ]: 1727 : if (xBroadcaster.is ())
3821 [ + - ][ + - ]: 1727 : xBroadcaster->addTitleChangeListener (xListener);
[ + - ]
3822 : 1727 : }
3823 : :
3824 : : //=============================================================================
3825 : : // css.frame.XTitleChangeBroadcaster
3826 : 0 : void SAL_CALL SfxBaseModel::removeTitleChangeListener( const css::uno::Reference< css::frame::XTitleChangeListener >& xListener )
3827 : : throw (css::uno::RuntimeException)
3828 : : {
3829 : : // SYNCHRONIZED ->
3830 [ # # ]: 0 : SfxModelGuard aGuard( *this );
3831 : :
3832 [ # # ][ # # ]: 0 : css::uno::Reference< css::frame::XTitleChangeBroadcaster > xBroadcaster(impl_getTitleHelper(), css::uno::UNO_QUERY);
3833 [ # # ]: 0 : if (xBroadcaster.is ())
3834 [ # # ][ # # ]: 0 : xBroadcaster->removeTitleChangeListener (xListener);
[ # # ]
3835 : 0 : }
3836 : :
3837 : : //=============================================================================
3838 : : // css.frame.XUntitledNumbers
3839 : 1727 : ::sal_Int32 SAL_CALL SfxBaseModel::leaseNumber( const css::uno::Reference< css::uno::XInterface >& xComponent )
3840 : : throw (css::lang::IllegalArgumentException,
3841 : : css::uno::RuntimeException )
3842 : : {
3843 [ + - ]: 1727 : SfxModelGuard aGuard( *this );
3844 : :
3845 [ + - ][ + - ]: 1727 : return impl_getUntitledHelper ()->leaseNumber (xComponent);
[ + - ][ + - ]
3846 : : }
3847 : :
3848 : : //=============================================================================
3849 : : // css.frame.XUntitledNumbers
3850 : 0 : void SAL_CALL SfxBaseModel::releaseNumber( ::sal_Int32 nNumber )
3851 : : throw (css::lang::IllegalArgumentException,
3852 : : css::uno::RuntimeException )
3853 : : {
3854 [ # # ]: 0 : SfxModelGuard aGuard( *this );
3855 [ # # ][ # # ]: 0 : impl_getUntitledHelper ()->releaseNumber (nNumber);
[ # # ][ # # ]
3856 : 0 : }
3857 : :
3858 : : //=============================================================================
3859 : : // css.frame.XUntitledNumbers
3860 : 0 : void SAL_CALL SfxBaseModel::releaseNumberForComponent( const css::uno::Reference< css::uno::XInterface >& xComponent )
3861 : : throw (css::lang::IllegalArgumentException,
3862 : : css::uno::RuntimeException )
3863 : : {
3864 [ # # ]: 0 : SfxModelGuard aGuard( *this );
3865 [ # # ][ # # ]: 0 : impl_getUntitledHelper ()->releaseNumberForComponent (xComponent);
[ # # ][ # # ]
3866 : 0 : }
3867 : :
3868 : : //=============================================================================
3869 : : // css.frame.XUntitledNumbers
3870 : 0 : ::rtl::OUString SAL_CALL SfxBaseModel::getUntitledPrefix()
3871 : : throw (css::uno::RuntimeException)
3872 : : {
3873 [ # # ]: 0 : SfxModelGuard aGuard( *this );
3874 [ # # ][ # # ]: 0 : return impl_getUntitledHelper ()->getUntitledPrefix ();
[ # # ][ # # ]
3875 : : }
3876 : :
3877 : : //=============================================================================
3878 : : // css::frame::XModel2
3879 : 4 : css::uno::Reference< css::container::XEnumeration > SAL_CALL SfxBaseModel::getControllers()
3880 : : throw (css::uno::RuntimeException)
3881 : : {
3882 [ + - ]: 4 : SfxModelGuard aGuard( *this );
3883 : :
3884 : 4 : sal_Int32 c = m_pData->m_seqControllers.getLength();
3885 : 4 : sal_Int32 i = 0;
3886 [ + - ]: 4 : css::uno::Sequence< css::uno::Any > lEnum(c);
3887 [ + + ]: 8 : for (i=0; i<c; ++i)
3888 [ + - ][ + - ]: 4 : lEnum[i] <<= m_pData->m_seqControllers[i];
[ + - ]
3889 : :
3890 [ + - ]: 4 : ::comphelper::OAnyEnumeration* pEnum = new ::comphelper::OAnyEnumeration(lEnum);
3891 [ + - ][ + - ]: 4 : css::uno::Reference< css::container::XEnumeration > xEnum(static_cast< css::container::XEnumeration* >(pEnum), css::uno::UNO_QUERY_THROW);
3892 [ + - ][ + - ]: 4 : return xEnum;
3893 : : }
3894 : :
3895 : : //=============================================================================
3896 : : // css::frame::XModel2
3897 : 0 : css::uno::Sequence< ::rtl::OUString > SAL_CALL SfxBaseModel::getAvailableViewControllerNames()
3898 : : throw (css::uno::RuntimeException)
3899 : : {
3900 [ # # ]: 0 : SfxModelGuard aGuard( *this );
3901 : :
3902 [ # # ][ # # ]: 0 : const SfxObjectFactory& rDocumentFactory = GetObjectShell()->GetFactory();
3903 [ # # ]: 0 : const sal_Int16 nViewFactoryCount = rDocumentFactory.GetViewFactoryCount();
3904 : :
3905 [ # # ]: 0 : Sequence< ::rtl::OUString > aViewNames( nViewFactoryCount );
3906 [ # # ]: 0 : for ( sal_Int16 nViewNo = 0; nViewNo < nViewFactoryCount; ++nViewNo )
3907 [ # # ][ # # ]: 0 : aViewNames[nViewNo] = rDocumentFactory.GetViewFactory( nViewNo ).GetAPIViewName();
[ # # ][ # # ]
[ # # ]
3908 [ # # ]: 0 : return aViewNames;
3909 : : }
3910 : :
3911 : : //=============================================================================
3912 : : // css::frame::XModel2
3913 : 0 : css::uno::Reference< css::frame::XController2 > SAL_CALL SfxBaseModel::createDefaultViewController( const css::uno::Reference< css::frame::XFrame >& i_rFrame )
3914 : : throw (css::uno::RuntimeException ,
3915 : : css::lang::IllegalArgumentException,
3916 : : css::uno::Exception )
3917 : : {
3918 [ # # ]: 0 : SfxModelGuard aGuard( *this );
3919 : :
3920 [ # # ][ # # ]: 0 : const SfxObjectFactory& rDocumentFactory = GetObjectShell()->GetFactory();
3921 [ # # ][ # # ]: 0 : const ::rtl::OUString sDefaultViewName = rDocumentFactory.GetViewFactory( 0 ).GetAPIViewName();
[ # # ][ # # ]
3922 : :
3923 [ # # ]: 0 : aGuard.clear();
3924 : :
3925 [ # # ][ # # ]: 0 : return createViewController( sDefaultViewName, Sequence< PropertyValue >(), i_rFrame );
[ # # ][ # # ]
3926 : : }
3927 : :
3928 : : //=============================================================================
3929 : : namespace sfx { namespace intern {
3930 : :
3931 : : /** a class which, in its dtor, cleans up variuos objects (well, at the moment only the frame) collected during
3932 : : the creation of a document view, unless the creation was successful.
3933 : : */
3934 : : class SAL_DLLPRIVATE ViewCreationGuard
3935 : : {
3936 : : public:
3937 : 1727 : ViewCreationGuard()
3938 : 1727 : :m_bSuccess( false )
3939 : : {
3940 : 1727 : }
3941 : :
3942 : 1727 : ~ViewCreationGuard()
3943 : 1727 : {
3944 [ - + ]: 1727 : if ( !m_bSuccess )
3945 [ # # ]: 0 : impl_closeAll();
3946 : 1727 : }
3947 : :
3948 : 1711 : void takeFrameOwnership( SfxFrame* i_pFrame )
3949 : : {
3950 : : OSL_PRECOND( !m_aWeakFrame, "ViewCreationGuard::takeFrameOwnership: already have a frame!" );
3951 : : OSL_PRECOND( i_pFrame != NULL, "ViewCreationGuard::takeFrameOwnership: invalid frame!" );
3952 : 1711 : m_aWeakFrame = i_pFrame;
3953 : 1711 : }
3954 : :
3955 : 1727 : void releaseAll()
3956 : : {
3957 : 1727 : m_bSuccess = true;
3958 : 1727 : }
3959 : :
3960 : : private:
3961 : 0 : void impl_closeAll()
3962 : : {
3963 [ # # ][ # # ]: 0 : if ( m_aWeakFrame && !m_aWeakFrame->GetCurrentDocument() )
[ # # ]
3964 : : {
3965 [ # # ]: 0 : m_aWeakFrame->SetFrameInterface_Impl( NULL );
3966 : 0 : m_aWeakFrame->DoClose();
3967 : : }
3968 : 0 : }
3969 : :
3970 : : private:
3971 : : bool m_bSuccess;
3972 : : SfxFrameWeak m_aWeakFrame;
3973 : : };
3974 : : } }
3975 : :
3976 : : //=============================================================================
3977 : 1727 : SfxViewFrame* SfxBaseModel::FindOrCreateViewFrame_Impl( const Reference< XFrame >& i_rFrame, ::sfx::intern::ViewCreationGuard& i_rGuard ) const
3978 : : {
3979 : 1727 : SfxViewFrame* pViewFrame = NULL;
3980 [ + + ]: 1729 : for ( pViewFrame = SfxViewFrame::GetFirst( GetObjectShell(), sal_False );
3981 : : pViewFrame;
3982 : 2 : pViewFrame= SfxViewFrame::GetNext( *pViewFrame, GetObjectShell(), sal_False )
3983 : : )
3984 : : {
3985 [ + - ][ + + ]: 18 : if ( pViewFrame->GetFrame().GetFrameInterface() == i_rFrame )
3986 : 16 : break;
3987 : : }
3988 [ + + ]: 1727 : if ( !pViewFrame )
3989 : : {
3990 : : #if OSL_DEBUG_LEVEL > 0
3991 : : for ( SfxFrame* pCheckFrame = SfxFrame::GetFirst();
3992 : : pCheckFrame;
3993 : : pCheckFrame = SfxFrame::GetNext( *pCheckFrame )
3994 : : )
3995 : : {
3996 : : if ( pCheckFrame->GetFrameInterface() == i_rFrame )
3997 : : {
3998 : : if ( ( pCheckFrame->GetCurrentViewFrame() != NULL )
3999 : : || ( pCheckFrame->GetCurrentDocument() != NULL )
4000 : : )
4001 : : // Note that it is perfectly letgitimate that during loading into an XFrame which already contains
4002 : : // a document, there exist two SfxFrame instances bound to this XFrame - the old one, which will be
4003 : : // destroyed later, and the new one, which we're going to create
4004 : : continue;
4005 : :
4006 : : OSL_FAIL( "SfxBaseModel::FindOrCreateViewFrame_Impl: there already is an SfxFrame for the given XFrame, but no view in it!" );
4007 : : // nowadays, we're the only instance allowed to create an SfxFrame for an XFrame, so this case here should not happen
4008 : : break;
4009 : : }
4010 : : }
4011 : : #endif
4012 : :
4013 : 1711 : SfxFrame* pTargetFrame = SfxFrame::Create( i_rFrame );
4014 [ # # ][ # # ]: 1711 : ENSURE_OR_THROW( pTargetFrame, "could not create an SfxFrame" );
[ # # ][ - + ]
4015 : 1711 : i_rGuard.takeFrameOwnership( pTargetFrame );
4016 : :
4017 : : // prepare it
4018 : 1711 : pTargetFrame->PrepareForDoc_Impl( *GetObjectShell() );
4019 : :
4020 : : // create view frame
4021 [ + - ]: 1711 : pViewFrame = new SfxViewFrame( *pTargetFrame, GetObjectShell() );
4022 : : }
4023 : 1727 : return pViewFrame;
4024 : : }
4025 : :
4026 : : //=============================================================================
4027 : : // css::frame::XModel2
4028 : 1727 : css::uno::Reference< css::frame::XController2 > SAL_CALL SfxBaseModel::createViewController(
4029 : : const ::rtl::OUString& i_rViewName, const Sequence< PropertyValue >& i_rArguments, const Reference< XFrame >& i_rFrame )
4030 : : throw (css::uno::RuntimeException ,
4031 : : css::lang::IllegalArgumentException,
4032 : : css::uno::Exception )
4033 : : {
4034 [ + - ]: 1727 : SfxModelGuard aGuard( *this );
4035 : :
4036 [ - + ]: 1727 : if ( !i_rFrame.is() )
4037 [ # # ][ # # ]: 0 : throw css::lang::IllegalArgumentException( ::rtl::OUString(), *this, 3 );
4038 : :
4039 : : // find the proper SFX view factory
4040 [ + - ][ + - ]: 1727 : SfxViewFactory* pViewFactory = GetObjectShell()->GetFactory().GetViewFactoryByViewName( i_rViewName );
[ + - ][ + - ]
[ + - ]
4041 [ - + ]: 1727 : if ( !pViewFactory )
4042 [ # # ][ # # ]: 0 : throw IllegalArgumentException( ::rtl::OUString(), *this, 1 );
4043 : :
4044 : : // determine previous shell (used in some special cases)
4045 [ + - ][ + - ]: 1727 : Reference< XController > xPreviousController( i_rFrame->getController() );
4046 [ + - ]: 1727 : const Reference< XModel > xMe( this );
4047 [ + + ][ - + ]: 3470 : if ( ( xPreviousController.is() )
[ - + ]
4048 [ + - ][ + - ]: 1743 : && ( xMe != xPreviousController->getModel() )
[ + - ][ + + ]
[ # # ]
4049 : : )
4050 : : {
4051 : 0 : xPreviousController.clear();
4052 : : }
4053 [ + - ]: 1727 : SfxViewShell* pOldViewShell = SfxViewShell::Get( xPreviousController );
4054 : : OSL_ENSURE( !xPreviousController.is() || ( pOldViewShell != NULL ),
4055 : : "SfxBaseModel::createViewController: invalid old controller!" );
4056 : :
4057 : : // a guard which will clean up in case of failure
4058 [ + - ]: 1727 : ::sfx::intern::ViewCreationGuard aViewCreationGuard;
4059 : :
4060 : : // determine the ViewFrame belonging to the given XFrame
4061 [ + - ]: 1727 : SfxViewFrame* pViewFrame = FindOrCreateViewFrame_Impl( i_rFrame, aViewCreationGuard );
4062 : : OSL_POSTCOND( pViewFrame, "SfxBaseModel::createViewController: no frame?" );
4063 : :
4064 : : // delegate to SFX' view factory
4065 [ + - ]: 1727 : pViewFrame->GetBindings().ENTERREGISTRATIONS();
4066 [ + - ]: 1727 : SfxViewShell* pViewShell = pViewFactory->CreateInstance( pViewFrame, pOldViewShell );
4067 [ + - ]: 1727 : pViewFrame->GetBindings().LEAVEREGISTRATIONS();
4068 [ - + ][ # # ]: 1727 : ENSURE_OR_THROW( pViewShell, "invalid view shell provided by factory" );
[ # # ][ # # ]
4069 : :
4070 : : // by setting the ViewShell it is prevented that disposing the Controller will destroy this ViewFrame also
4071 [ + - ]: 1727 : pViewFrame->GetDispatcher()->SetDisableFlags( 0 );
4072 [ + - ]: 1727 : pViewFrame->SetViewShell_Impl( pViewShell );
4073 : :
4074 : : // remember ViewID
4075 [ + - ]: 1727 : pViewFrame->SetCurViewId_Impl( pViewFactory->GetOrdinal() );
4076 : :
4077 : : // ensure a default controller, if the view shell did not provide an own implementation
4078 [ + - ][ + + ]: 1727 : if ( !pViewShell->GetController().is() )
4079 [ + - ][ + - ]: 34 : pViewShell->SetController( new SfxBaseController( pViewShell ) );
4080 : :
4081 : : // pass the creation arguments to the controller
4082 [ + - ]: 1727 : SfxBaseController* pBaseController = pViewShell->GetBaseController_Impl();
4083 [ - + ][ # # ]: 1727 : ENSURE_OR_THROW( pBaseController, "invalid controller implementation!" );
[ # # ][ # # ]
4084 [ + - ]: 1727 : pBaseController->SetCreationArguments_Impl( i_rArguments );
4085 : :
4086 : : // some initial view settings, coming from our most recent attachResource call
4087 [ + - ][ + - ]: 1727 : ::comphelper::NamedValueCollection aDocumentLoadArgs( getArgs() );
[ + - ]
4088 [ + - ][ - + ]: 1727 : if ( aDocumentLoadArgs.getOrDefault( "ViewOnly", false ) )
4089 [ # # ][ # # ]: 0 : pViewFrame->GetFrame().SetMenuBarOn_Impl( sal_False );
4090 : :
4091 [ + - ]: 1727 : const sal_Int16 nPluginMode = aDocumentLoadArgs.getOrDefault( "PluginMode", sal_Int16( 0 ) );
4092 [ - + ]: 1727 : if ( nPluginMode == 1 )
4093 : : {
4094 [ # # ]: 0 : pViewFrame->ForceOuterResize_Impl( sal_False );
4095 [ # # ]: 0 : pViewFrame->GetBindings().HidePopups( sal_True );
4096 : :
4097 [ # # ]: 0 : SfxFrame& rFrame = pViewFrame->GetFrame();
4098 : : // MBA: layoutmanager of inplace frame starts locked and invisible
4099 [ # # ][ # # ]: 0 : rFrame.GetWorkWindow_Impl()->MakeVisible_Impl( sal_False );
4100 [ # # ][ # # ]: 0 : rFrame.GetWorkWindow_Impl()->Lock_Impl( sal_True );
4101 : :
4102 [ # # ][ # # ]: 0 : rFrame.GetWindow().SetBorderStyle( WINDOW_BORDER_NOBORDER );
4103 [ # # ][ # # ]: 0 : pViewFrame->GetWindow().SetBorderStyle( WINDOW_BORDER_NOBORDER );
4104 : : }
4105 : :
4106 : : // tell the guard we were successful
4107 : 1727 : aViewCreationGuard.releaseAll();
4108 : :
4109 : : // outta gere
4110 [ + - ][ + - ]: 1727 : return pBaseController;
[ + - ][ + - ]
[ + - ]
4111 : : }
4112 : :
4113 : : //=============================================================================
4114 : : // RDF DocumentMetadataAccess
4115 : :
4116 : : // ::com::sun::star::rdf::XRepositorySupplier:
4117 : : uno::Reference< rdf::XRepository > SAL_CALL
4118 : 190 : SfxBaseModel::getRDFRepository() throw (uno::RuntimeException)
4119 : : {
4120 [ + - ]: 190 : SfxModelGuard aGuard( *this );
4121 : :
4122 [ + - ]: 190 : const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(m_pData->GetDMA());
4123 [ - + ]: 190 : if (!xDMA.is()) {
4124 : : throw uno::RuntimeException( ::rtl::OUString(
4125 [ # # ][ # # ]: 0 : "model has no document metadata"), *this );
4126 : : }
4127 : :
4128 [ + - ][ + - ]: 190 : return xDMA->getRDFRepository();
[ + - ]
4129 : : }
4130 : :
4131 : : // ::com::sun::star::rdf::XNode:
4132 : : ::rtl::OUString SAL_CALL
4133 : 670 : SfxBaseModel::getStringValue() throw (uno::RuntimeException)
4134 : : {
4135 [ + - ]: 670 : SfxModelGuard aGuard( *this );
4136 : :
4137 [ + - ]: 670 : const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(m_pData->GetDMA());
4138 [ - + ]: 670 : if (!xDMA.is()) {
4139 : : throw uno::RuntimeException( ::rtl::OUString(
4140 [ # # ][ # # ]: 0 : "model has no document metadata"), *this );
4141 : : }
4142 : :
4143 [ + - ][ + - ]: 670 : return xDMA->getStringValue();
[ + - ]
4144 : : }
4145 : :
4146 : : // ::com::sun::star::rdf::XURI:
4147 : : ::rtl::OUString SAL_CALL
4148 : 0 : SfxBaseModel::getNamespace() throw (uno::RuntimeException)
4149 : : {
4150 [ # # ]: 0 : SfxModelGuard aGuard( *this );
4151 : :
4152 [ # # ]: 0 : const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(m_pData->GetDMA());
4153 [ # # ]: 0 : if (!xDMA.is()) {
4154 : : throw uno::RuntimeException( ::rtl::OUString(
4155 [ # # ][ # # ]: 0 : "model has no document metadata"), *this );
4156 : : }
4157 : :
4158 [ # # ][ # # ]: 0 : return xDMA->getNamespace();
[ # # ]
4159 : : }
4160 : :
4161 : : ::rtl::OUString SAL_CALL
4162 : 0 : SfxBaseModel::getLocalName() throw (uno::RuntimeException)
4163 : : {
4164 [ # # ]: 0 : SfxModelGuard aGuard( *this );
4165 : :
4166 [ # # ]: 0 : const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(m_pData->GetDMA());
4167 [ # # ]: 0 : if (!xDMA.is()) {
4168 : : throw uno::RuntimeException( ::rtl::OUString(
4169 [ # # ][ # # ]: 0 : "model has no document metadata"), *this );
4170 : : }
4171 : :
4172 [ # # ][ # # ]: 0 : return xDMA->getLocalName();
[ # # ]
4173 : : }
4174 : :
4175 : : // ::com::sun::star::rdf::XDocumentMetadataAccess:
4176 : : uno::Reference< rdf::XMetadatable > SAL_CALL
4177 : 0 : SfxBaseModel::getElementByMetadataReference(
4178 : : const ::com::sun::star::beans::StringPair & i_rReference)
4179 : : throw (uno::RuntimeException)
4180 : : {
4181 [ # # ]: 0 : SfxModelGuard aGuard( *this );
4182 : :
4183 [ # # ]: 0 : const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(m_pData->GetDMA());
4184 [ # # ]: 0 : if (!xDMA.is()) {
4185 : : throw uno::RuntimeException( ::rtl::OUString(
4186 [ # # ][ # # ]: 0 : "model has no document metadata"), *this );
4187 : : }
4188 : :
4189 [ # # ][ # # ]: 0 : return xDMA->getElementByMetadataReference(i_rReference);
[ # # ]
4190 : : }
4191 : :
4192 : : uno::Reference< rdf::XMetadatable > SAL_CALL
4193 : 4 : SfxBaseModel::getElementByURI(const uno::Reference< rdf::XURI > & i_xURI)
4194 : : throw (uno::RuntimeException, lang::IllegalArgumentException)
4195 : : {
4196 [ + - ]: 4 : SfxModelGuard aGuard( *this );
4197 : :
4198 [ + - ]: 4 : const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(m_pData->GetDMA());
4199 [ - + ]: 4 : if (!xDMA.is()) {
4200 : : throw uno::RuntimeException( ::rtl::OUString(
4201 [ # # ][ # # ]: 0 : "model has no document metadata"), *this );
4202 : : }
4203 : :
4204 [ + - ][ + + ]: 4 : return xDMA->getElementByURI(i_xURI);
[ + - ]
4205 : : }
4206 : :
4207 : : uno::Sequence< uno::Reference< rdf::XURI > > SAL_CALL
4208 : 4 : SfxBaseModel::getMetadataGraphsWithType(
4209 : : const uno::Reference<rdf::XURI> & i_xType)
4210 : : throw (uno::RuntimeException, lang::IllegalArgumentException)
4211 : : {
4212 [ + - ]: 4 : SfxModelGuard aGuard( *this );
4213 : :
4214 [ + - ]: 4 : const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(m_pData->GetDMA());
4215 [ - + ]: 4 : if (!xDMA.is()) {
4216 : : throw uno::RuntimeException( ::rtl::OUString(
4217 [ # # ][ # # ]: 0 : "model has no document metadata"), *this );
4218 : : }
4219 : :
4220 [ + - ][ + + ]: 4 : return xDMA->getMetadataGraphsWithType(i_xType);
[ + - ]
4221 : : }
4222 : :
4223 : : uno::Reference<rdf::XURI> SAL_CALL
4224 : 24 : SfxBaseModel::addMetadataFile(const ::rtl::OUString & i_rFileName,
4225 : : const uno::Sequence < uno::Reference< rdf::XURI > > & i_rTypes)
4226 : : throw (uno::RuntimeException, lang::IllegalArgumentException,
4227 : : container::ElementExistException)
4228 : : {
4229 [ + - ]: 24 : SfxModelGuard aGuard( *this );
4230 : :
4231 [ + - ]: 24 : const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(m_pData->GetDMA());
4232 [ - + ]: 24 : if (!xDMA.is()) {
4233 : : throw uno::RuntimeException( ::rtl::OUString(
4234 [ # # ][ # # ]: 0 : "model has no document metadata"), *this );
4235 : : }
4236 : :
4237 [ + - ][ + + ]: 24 : return xDMA->addMetadataFile(i_rFileName, i_rTypes);
[ + - ]
4238 : : }
4239 : :
4240 : : uno::Reference<rdf::XURI> SAL_CALL
4241 : 10 : SfxBaseModel::importMetadataFile(::sal_Int16 i_Format,
4242 : : const uno::Reference< io::XInputStream > & i_xInStream,
4243 : : const ::rtl::OUString & i_rFileName,
4244 : : const uno::Reference< rdf::XURI > & i_xBaseURI,
4245 : : const uno::Sequence < uno::Reference< rdf::XURI > > & i_rTypes)
4246 : : throw (uno::RuntimeException, lang::IllegalArgumentException,
4247 : : datatransfer::UnsupportedFlavorException,
4248 : : container::ElementExistException, rdf::ParseException, io::IOException)
4249 : : {
4250 [ + - ]: 10 : SfxModelGuard aGuard( *this );
4251 : :
4252 [ + - ]: 10 : const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(m_pData->GetDMA());
4253 [ - + ]: 10 : if (!xDMA.is()) {
4254 : : throw uno::RuntimeException( ::rtl::OUString(
4255 [ # # ][ # # ]: 0 : "model has no document metadata"), *this );
4256 : : }
4257 : :
4258 [ + - ]: 10 : return xDMA->importMetadataFile(i_Format,
4259 [ - + ][ # # ]: 10 : i_xInStream, i_rFileName, i_xBaseURI, i_rTypes);
4260 : : }
4261 : :
4262 : : void SAL_CALL
4263 : 4 : SfxBaseModel::removeMetadataFile(
4264 : : const uno::Reference< rdf::XURI > & i_xGraphName)
4265 : : throw (uno::RuntimeException, lang::IllegalArgumentException,
4266 : : container::NoSuchElementException)
4267 : : {
4268 [ + - ]: 4 : SfxModelGuard aGuard( *this );
4269 : :
4270 [ + - ]: 4 : const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(m_pData->GetDMA());
4271 [ - + ]: 4 : if (!xDMA.is()) {
4272 : : throw uno::RuntimeException( ::rtl::OUString(
4273 [ # # ][ # # ]: 0 : "model has no document metadata"), *this );
4274 : : }
4275 : :
4276 [ + - ][ + + ]: 4 : return xDMA->removeMetadataFile(i_xGraphName);
[ + - ]
4277 : : }
4278 : :
4279 : : void SAL_CALL
4280 : 10 : SfxBaseModel::addContentOrStylesFile(const ::rtl::OUString & i_rFileName)
4281 : : throw (uno::RuntimeException, lang::IllegalArgumentException,
4282 : : container::ElementExistException)
4283 : : {
4284 [ + - ]: 10 : SfxModelGuard aGuard( *this );
4285 : :
4286 [ + - ]: 10 : const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(m_pData->GetDMA());
4287 [ - + ]: 10 : if (!xDMA.is()) {
4288 : : throw uno::RuntimeException( ::rtl::OUString(
4289 [ # # ][ # # ]: 0 : "model has no document metadata"), *this );
4290 : : }
4291 : :
4292 [ + - ][ + + ]: 10 : return xDMA->addContentOrStylesFile(i_rFileName);
[ + - ]
4293 : : }
4294 : :
4295 : : void SAL_CALL
4296 : 6 : SfxBaseModel::removeContentOrStylesFile(const ::rtl::OUString & i_rFileName)
4297 : : throw (uno::RuntimeException, lang::IllegalArgumentException,
4298 : : container::NoSuchElementException)
4299 : : {
4300 [ + - ]: 6 : SfxModelGuard aGuard( *this );
4301 : :
4302 [ + - ]: 6 : const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(m_pData->GetDMA());
4303 [ - + ]: 6 : if (!xDMA.is()) {
4304 : : throw uno::RuntimeException( ::rtl::OUString(
4305 [ # # ][ # # ]: 0 : "model has no document metadata"), *this );
4306 : : }
4307 : :
4308 [ + - ][ + + ]: 6 : return xDMA->removeContentOrStylesFile(i_rFileName);
[ + - ]
4309 : : }
4310 : :
4311 : : void SAL_CALL
4312 : 32 : SfxBaseModel::loadMetadataFromStorage(
4313 : : uno::Reference< embed::XStorage > const & i_xStorage,
4314 : : uno::Reference<rdf::XURI> const & i_xBaseURI,
4315 : : uno::Reference<task::XInteractionHandler> const & i_xHandler)
4316 : : throw (uno::RuntimeException, lang::IllegalArgumentException,
4317 : : lang::WrappedTargetException)
4318 : : {
4319 [ + - ]: 32 : SfxModelGuard aGuard( *this );
4320 : :
4321 : : const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(
4322 [ + - ]: 32 : m_pData->CreateDMAUninitialized());
4323 [ - + ]: 32 : if (!xDMA.is()) {
4324 : : throw uno::RuntimeException( ::rtl::OUString(
4325 [ # # ][ # # ]: 0 : "model has no document metadata"), *this );
4326 : : }
4327 : :
4328 : : try {
4329 [ + - ][ + + ]: 32 : xDMA->loadMetadataFromStorage(i_xStorage, i_xBaseURI, i_xHandler);
4330 : 4 : } catch (lang::IllegalArgumentException &) {
4331 : 2 : throw; // not initialized
4332 [ - + - ]: 2 : } catch (uno::Exception &) {
4333 : : // UGLY: if it's a RuntimeException, we can't be sure DMA is initialzed
4334 [ # # ]: 0 : m_pData->m_xDocumentMetadata = xDMA;
4335 : 0 : throw;
4336 : : }
4337 [ + - ][ + - ]: 32 : m_pData->m_xDocumentMetadata = xDMA;
4338 : :
4339 : 30 : }
4340 : :
4341 : : void SAL_CALL
4342 : 19 : SfxBaseModel::storeMetadataToStorage(
4343 : : uno::Reference< embed::XStorage > const & i_xStorage)
4344 : : throw (uno::RuntimeException, lang::IllegalArgumentException,
4345 : : lang::WrappedTargetException)
4346 : : {
4347 [ + - ]: 19 : SfxModelGuard aGuard( *this );
4348 : :
4349 [ + + ]: 19 : const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(m_pData->GetDMA());
4350 [ - + ]: 16 : if (!xDMA.is()) {
4351 : : throw uno::RuntimeException( ::rtl::OUString(
4352 [ # # ][ # # ]: 0 : "model has no document metadata"), *this );
4353 : : }
4354 : :
4355 [ + - ][ + + ]: 19 : return xDMA->storeMetadataToStorage(i_xStorage);
[ + - ]
4356 : : }
4357 : :
4358 : : void SAL_CALL
4359 : 8 : SfxBaseModel::loadMetadataFromMedium(
4360 : : const uno::Sequence< beans::PropertyValue > & i_rMedium)
4361 : : throw (uno::RuntimeException, lang::IllegalArgumentException,
4362 : : lang::WrappedTargetException)
4363 : : {
4364 [ + - ]: 8 : SfxModelGuard aGuard( *this );
4365 : :
4366 : : const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(
4367 [ + - ]: 8 : m_pData->CreateDMAUninitialized());
4368 [ - + ]: 8 : if (!xDMA.is()) {
4369 : : throw uno::RuntimeException( ::rtl::OUString(
4370 [ # # ][ # # ]: 0 : "model has no document metadata"), *this );
4371 : : }
4372 : :
4373 : : try {
4374 [ + - ][ + + ]: 8 : xDMA->loadMetadataFromMedium(i_rMedium);
4375 : 4 : } catch (lang::IllegalArgumentException &) {
4376 : 2 : throw; // not initialized
4377 [ - + - ]: 2 : } catch (uno::Exception &) {
4378 : : // UGLY: if it's a RuntimeException, we can't be sure DMA is initialzed
4379 [ # # ]: 0 : m_pData->m_xDocumentMetadata = xDMA;
4380 : 0 : throw;
4381 : : }
4382 [ + - ][ + - ]: 8 : m_pData->m_xDocumentMetadata = xDMA;
4383 : 6 : }
4384 : :
4385 : : void SAL_CALL
4386 : 4 : SfxBaseModel::storeMetadataToMedium(
4387 : : const uno::Sequence< beans::PropertyValue > & i_rMedium)
4388 : : throw (uno::RuntimeException, lang::IllegalArgumentException,
4389 : : lang::WrappedTargetException)
4390 : : {
4391 [ + - ]: 4 : SfxModelGuard aGuard( *this );
4392 : :
4393 [ + - ]: 4 : const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(m_pData->GetDMA());
4394 [ - + ]: 4 : if (!xDMA.is()) {
4395 : : throw uno::RuntimeException( ::rtl::OUString(
4396 [ # # ][ # # ]: 0 : "model has no document metadata"), *this );
4397 : : }
4398 : :
4399 [ + - ][ + + ]: 4 : return xDMA->storeMetadataToMedium(i_rMedium);
[ + - ]
4400 : : }
4401 : :
4402 : : // =====================================================================================================================
4403 : : // = SfxModelSubComponent
4404 : : // =====================================================================================================================
4405 : :
4406 : 0 : SfxModelSubComponent::~SfxModelSubComponent()
4407 : : {
4408 [ # # ]: 0 : }
4409 : :
4410 : 0 : void SfxModelSubComponent::disposing()
4411 : : {
4412 : : // nothing to do here
4413 : 0 : }
4414 : :
4415 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|