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 <config_features.h>
21 :
22 : #include "arrdecl.hxx"
23 : #include <map>
24 :
25 : #include <cppuhelper/implbase1.hxx>
26 :
27 : #include <com/sun/star/util/XCloseable.hpp>
28 : #include <com/sun/star/frame/XComponentLoader.hpp>
29 : #include <com/sun/star/frame/Desktop.hpp>
30 : #include <com/sun/star/util/XCloseBroadcaster.hpp>
31 : #include <com/sun/star/util/XCloseListener.hpp>
32 : #include <com/sun/star/util/XModifyBroadcaster.hpp>
33 : #include <com/sun/star/beans/XPropertySet.hpp>
34 : #include <com/sun/star/frame/XTitle.hpp>
35 : #include <osl/mutex.hxx>
36 : #include <rtl/instance.hxx>
37 : #include <vcl/msgbox.hxx>
38 : #include <vcl/wrkwin.hxx>
39 : #include <vcl/svapp.hxx>
40 : #include <svl/eitem.hxx>
41 : #include <tools/rtti.hxx>
42 : #include <svl/lstner.hxx>
43 : #include <sfx2/sfxhelp.hxx>
44 : #include <basic/sbstar.hxx>
45 : #include <svl/stritem.hxx>
46 : #include <basic/sbx.hxx>
47 : #include <unotools/eventcfg.hxx>
48 :
49 : #include <sfx2/objsh.hxx>
50 : #include <sfx2/signaturestate.hxx>
51 : #include <sfx2/sfxmodelfactory.hxx>
52 :
53 : #include <basic/sbuno.hxx>
54 : #include <svtools/sfxecode.hxx>
55 : #include <svtools/ehdl.hxx>
56 : #include <unotools/printwarningoptions.hxx>
57 : #include <comphelper/processfactory.hxx>
58 : #include <comphelper/string.hxx>
59 :
60 : #include <com/sun/star/document/XStorageBasedDocument.hpp>
61 : #include <com/sun/star/script/DocumentDialogLibraryContainer.hpp>
62 : #include <com/sun/star/script/DocumentScriptLibraryContainer.hpp>
63 : #include <com/sun/star/document/XEmbeddedScripts.hpp>
64 : #include <com/sun/star/document/XScriptInvocationContext.hpp>
65 :
66 : #include <svl/urihelper.hxx>
67 : #include <unotools/pathoptions.hxx>
68 : #include <svl/sharecontrolfile.hxx>
69 : #include <unotools/localfilehelper.hxx>
70 : #include <unotools/ucbhelper.hxx>
71 : #include <svtools/asynclink.hxx>
72 : #include <tools/diagnose_ex.h>
73 : #include <comphelper/classids.hxx>
74 :
75 : #include <sfx2/app.hxx>
76 : #include <sfx2/docfac.hxx>
77 : #include <sfx2/docfile.hxx>
78 : #include <sfx2/event.hxx>
79 : #include <sfx2/dispatch.hxx>
80 : #include <sfx2/viewsh.hxx>
81 : #include <sfx2/viewfrm.hxx>
82 : #include <sfx2/sfxresid.hxx>
83 : #include "objshimp.hxx"
84 : #include "sfxtypes.hxx"
85 : #include <sfx2/evntconf.hxx>
86 : #include <sfx2/request.hxx>
87 : #include "doc.hrc"
88 : #include "sfxlocal.hrc"
89 : #include "appdata.hxx"
90 : #include <sfx2/sfxsids.hrc>
91 : #include <basic/basmgr.hxx>
92 : #include <svtools/svtools.hrc>
93 : #include <sfx2/QuerySaveDocument.hxx>
94 : #include "helpid.hrc"
95 : #include <sfx2/msg.hxx>
96 : #include "appbaslib.hxx"
97 : #include <sfx2/sfxbasemodel.hxx>
98 : #include <shellimpl.hxx>
99 :
100 : #include <basic/basicmanagerrepository.hxx>
101 :
102 : using namespace ::com::sun::star;
103 : using namespace ::com::sun::star::uno;
104 : using namespace ::com::sun::star::script;
105 : using namespace ::com::sun::star::frame;
106 : using namespace ::com::sun::star::document;
107 :
108 : using ::basic::BasicManagerRepository;
109 : #include <uno/mapping.hxx>
110 :
111 : #include "sfxslots.hxx"
112 :
113 : namespace {
114 :
115 : class theCurrentComponent : public rtl::Static< WeakReference< XInterface >, theCurrentComponent > {};
116 :
117 : #if HAVE_FEATURE_SCRIPTING
118 :
119 : // remember all registered components for VBA compatibility, to be able to remove them on disposing the model
120 : typedef ::std::map< XInterface*, OString > VBAConstantNameMap;
121 216 : static VBAConstantNameMap s_aRegisteredVBAConstants;
122 :
123 6279 : OString lclGetVBAGlobalConstName( const Reference< XInterface >& rxComponent )
124 : {
125 : OSL_ENSURE( rxComponent.is(), "lclGetVBAGlobalConstName - missing component" );
126 :
127 6279 : VBAConstantNameMap::iterator aIt = s_aRegisteredVBAConstants.find( rxComponent.get() );
128 6279 : if( aIt != s_aRegisteredVBAConstants.end() )
129 0 : return aIt->second;
130 :
131 6279 : uno::Reference< beans::XPropertySet > xProps( rxComponent, uno::UNO_QUERY );
132 6279 : if( xProps.is() ) try
133 : {
134 6273 : OUString aConstName;
135 6547 : xProps->getPropertyValue("VBAGlobalConstantName") >>= aConstName;
136 6273 : return OUStringToOString( aConstName, RTL_TEXTENCODING_ASCII_US );
137 : }
138 274 : catch (const uno::Exception&) // not supported
139 : {
140 : }
141 280 : return OString();
142 : }
143 :
144 : #endif
145 :
146 : } // namespace
147 :
148 :
149 :
150 9762 : class SfxModelListener_Impl : public ::cppu::WeakImplHelper1< ::com::sun::star::util::XCloseListener >
151 : {
152 : SfxObjectShell* mpDoc;
153 : public:
154 4941 : explicit SfxModelListener_Impl( SfxObjectShell* pDoc ) : mpDoc(pDoc) {};
155 : virtual void SAL_CALL queryClosing( const com::sun::star::lang::EventObject& aEvent, sal_Bool bDeliverOwnership )
156 : throw ( com::sun::star::uno::RuntimeException, com::sun::star::util::CloseVetoException, std::exception) SAL_OVERRIDE ;
157 : virtual void SAL_CALL notifyClosing( const com::sun::star::lang::EventObject& aEvent ) throw ( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE ;
158 : virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& aEvent ) throw ( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE ;
159 :
160 : };
161 :
162 4881 : void SAL_CALL SfxModelListener_Impl::queryClosing( const com::sun::star::lang::EventObject& , sal_Bool )
163 : throw ( com::sun::star::uno::RuntimeException, com::sun::star::util::CloseVetoException, std::exception)
164 : {
165 4881 : }
166 :
167 4881 : void SAL_CALL SfxModelListener_Impl::notifyClosing( const com::sun::star::lang::EventObject& ) throw ( com::sun::star::uno::RuntimeException, std::exception )
168 : {
169 4881 : SolarMutexGuard aSolarGuard;
170 4881 : mpDoc->Broadcast( SfxSimpleHint(SFX_HINT_DEINITIALIZING) );
171 4881 : }
172 :
173 4881 : void SAL_CALL SfxModelListener_Impl::disposing( const com::sun::star::lang::EventObject& _rEvent ) throw ( com::sun::star::uno::RuntimeException, std::exception )
174 : {
175 : // am I ThisComponent in AppBasic?
176 4881 : SolarMutexGuard aSolarGuard;
177 4881 : if ( SfxObjectShell::GetCurrentComponent() == _rEvent.Source )
178 : {
179 : // remove ThisComponent reference from AppBasic
180 3126 : SfxObjectShell::SetCurrentComponent( Reference< XInterface >() );
181 : }
182 :
183 : #if HAVE_FEATURE_SCRIPTING
184 : /* Remove VBA component from AppBasic. As every application registers its
185 : own current component, the disposed component may not be the "current
186 : component" of the SfxObjectShell. */
187 4881 : if ( _rEvent.Source.is() )
188 : {
189 4881 : VBAConstantNameMap::iterator aIt = s_aRegisteredVBAConstants.find( _rEvent.Source.get() );
190 4881 : if ( aIt != s_aRegisteredVBAConstants.end() )
191 : {
192 3005 : if ( BasicManager* pAppMgr = SfxApplication::GetBasicManager() )
193 3005 : pAppMgr->SetGlobalUNOConstant( aIt->second.getStr(), Any( Reference< XInterface >() ) );
194 3005 : s_aRegisteredVBAConstants.erase( aIt );
195 : }
196 : }
197 : #endif
198 :
199 4881 : if ( !mpDoc->Get_Impl()->bClosing )
200 : // GCC crashes when already in the destructor, so first query the Flag
201 909 : mpDoc->DoClose();
202 4881 : }
203 :
204 167334 : TYPEINIT1(SfxObjectShell, SfxShell);
205 :
206 :
207 4941 : SfxObjectShell_Impl::SfxObjectShell_Impl( SfxObjectShell& _rDocShell )
208 : :mpObjectContainer(0)
209 : ,rDocShell( _rDocShell )
210 : ,aMacroMode( *this )
211 : ,pProgress( 0)
212 : ,nTime( DateTime::SYSTEM )
213 : ,nVisualDocumentNumber( USHRT_MAX)
214 : ,nDocumentSignatureState( SignatureState::UNKNOWN )
215 : ,nScriptingSignatureState( SignatureState::UNKNOWN )
216 : ,bInList( false)
217 : ,bClosing( false)
218 : ,bIsSaving( false)
219 : ,bPasswd( false)
220 : ,bIsNamedVisible( false)
221 : ,bIsTemplate(false)
222 : ,bIsAbortingImport ( false)
223 : ,bImportDone ( false)
224 : ,bInPrepareClose( false )
225 : ,bPreparedForClose( false )
226 : ,bForbidReload( false )
227 : ,bBasicInitialized( false )
228 : ,bIsPrintJobCancelable( true )
229 : ,bOwnsStorage( true )
230 : ,bNoBaseURL( false )
231 : ,bInitialized( false )
232 : ,bSignatureErrorIsShown( false )
233 : ,bModelInitialized( false )
234 : ,bPreserveVersions( true )
235 : ,m_bMacroSignBroken( false )
236 : ,m_bNoBasicCapabilities( false )
237 : ,m_bDocRecoverySupport( true )
238 : ,bQueryLoadTemplate( true )
239 : ,bLoadReadonly( false )
240 : ,bUseUserData( true )
241 : ,bSaveVersionOnClose( false )
242 : ,m_bSharedXMLFlag( false )
243 : ,m_bAllowShareControlFileClean( true )
244 : ,m_bConfigOptionsChecked( false )
245 : ,lErr(ERRCODE_NONE)
246 : ,nEventId ( 0)
247 : ,pReloadTimer ( 0)
248 : ,pMarkData( 0 )
249 : ,nLoadedFlags ( SfxLoadedFlags::ALL )
250 : ,nFlagsInProgress( SfxLoadedFlags::NONE )
251 : ,bModalMode( false )
252 : ,bRunningMacro( false )
253 : ,bReloadAvailable( false )
254 : ,nAutoLoadLocks( 0 )
255 : ,pModule( 0 )
256 : ,eFlags( SfxObjectShellFlags::UNDEFINED )
257 : ,bReadOnlyUI( false )
258 : ,nStyleFilter( 0 )
259 : ,bDisposing( false )
260 : ,m_bEnableSetModified( true )
261 : ,m_bIsModified( false )
262 : ,m_nMapUnit( MAP_100TH_MM )
263 : ,m_bCreateTempStor( false )
264 : ,m_bIsInit( false )
265 : ,m_bIncomplEncrWarnShown( false )
266 : ,m_nModifyPasswordHash( 0 )
267 4941 : ,m_bModifyPasswordEntered( false )
268 : {
269 4941 : SfxObjectShell* pDoc = &_rDocShell;
270 4941 : SfxObjectShellArr_Impl &rArr = SfxGetpApp()->GetObjectShells_Impl();
271 4941 : rArr.push_back( pDoc );
272 4941 : bInList = true;
273 4941 : }
274 :
275 :
276 :
277 9762 : SfxObjectShell_Impl::~SfxObjectShell_Impl()
278 : {
279 9762 : }
280 :
281 :
282 :
283 4563 : SfxObjectShell::SfxObjectShell( const SfxModelFlags i_nCreationFlags )
284 4563 : : pImp( new SfxObjectShell_Impl( *this ) )
285 : , pMedium(0)
286 : , pStyleSheetPool(0)
287 : , eCreateMode(SfxObjectCreateMode::STANDARD)
288 : , bHasName( false )
289 9126 : , bIsInGenerateThumbnail ( false )
290 : {
291 4563 : if (i_nCreationFlags & SfxModelFlags::EMBEDDED_OBJECT)
292 823 : eCreateMode = SfxObjectCreateMode::EMBEDDED;
293 3740 : else if (i_nCreationFlags & SfxModelFlags::EXTERNAL_LINK)
294 0 : eCreateMode = SfxObjectCreateMode::INTERNAL;
295 :
296 4563 : const bool bScriptSupport = ( i_nCreationFlags & SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS ) == SfxModelFlags::NONE;
297 4563 : if ( !bScriptSupport )
298 243 : SetHasNoBasic();
299 :
300 4563 : const bool bDocRecovery = ( i_nCreationFlags & SfxModelFlags::DISABLE_DOCUMENT_RECOVERY ) == SfxModelFlags::NONE;
301 4563 : if ( !bDocRecovery )
302 236 : pImp->m_bDocRecoverySupport = false;
303 4563 : }
304 :
305 :
306 :
307 : // initializes a document from a file-description
308 :
309 378 : SfxObjectShell::SfxObjectShell
310 : (
311 : SfxObjectCreateMode eMode /* Purpose, io which the SfxObjectShell
312 : is created:
313 :
314 : SfxObjectCreateMode::EMBEDDED (default)
315 : as SO-Server from within another
316 : Document
317 :
318 : SfxObjectCreateMode::STANDARD,
319 : as a normal Document open stand-alone
320 :
321 : SfxObjectCreateMode::PREVIEW
322 : to enable a Preview, if possible are
323 : only little information is needed
324 :
325 : SfxObjectCreateMode::ORGANIZER
326 : to be displayed in the Organizer, here
327 : notning of the contents is used */
328 : )
329 :
330 : /* [Description]
331 :
332 : Constructor of the class SfxObjectShell.
333 : */
334 :
335 378 : : pImp( new SfxObjectShell_Impl( *this ) ),
336 : pMedium(0),
337 : pStyleSheetPool(0),
338 : eCreateMode(eMode),
339 : bHasName( false ),
340 756 : bIsInGenerateThumbnail ( false )
341 : {
342 378 : }
343 :
344 :
345 :
346 : // virtual destructor of typical base-class SfxObjectShell
347 :
348 9762 : SfxObjectShell::~SfxObjectShell()
349 : {
350 :
351 4881 : if ( IsEnableSetModified() )
352 3848 : EnableSetModified( false );
353 :
354 : // Never call GetInPlaceObject(), the access to the derivative branch
355 : // SfxInternObject is not allowed because of a compiler bug
356 4881 : SfxObjectShell::CloseInternal();
357 4881 : pImp->pBaseModel.set( NULL );
358 :
359 4881 : DELETEX(AutoReloadTimer_Impl, pImp->pReloadTimer );
360 :
361 4881 : SfxApplication *pSfxApp = SfxGetpApp();
362 4881 : if ( USHRT_MAX != pImp->nVisualDocumentNumber )
363 728 : pSfxApp->ReleaseIndex(pImp->nVisualDocumentNumber);
364 :
365 : // Destroy Basic-Manager
366 4881 : pImp->aBasicManager.reset( NULL );
367 :
368 4881 : if ( pSfxApp->GetDdeService() )
369 0 : pSfxApp->RemoveDdeTopic( this );
370 :
371 4881 : pImp->pBaseModel.set( NULL );
372 :
373 : // don't call GetStorage() here, in case of Load Failure it's possible that a storage was never assigned!
374 4881 : if ( pMedium && pMedium->HasStorage_Impl() && pMedium->GetStorage( false ) == pImp->m_xDocStorage )
375 784 : pMedium->CanDisposeStorage_Impl( false );
376 :
377 4881 : if ( pImp->mpObjectContainer )
378 : {
379 2247 : pImp->mpObjectContainer->CloseEmbeddedObjects();
380 2247 : delete pImp->mpObjectContainer;
381 : }
382 :
383 4881 : if ( pImp->bOwnsStorage && pImp->m_xDocStorage.is() )
384 3682 : pImp->m_xDocStorage->dispose();
385 :
386 4881 : if ( pMedium )
387 : {
388 4304 : pMedium->CloseAndReleaseStreams_Impl();
389 :
390 : #if HAVE_FEATURE_MULTIUSER_ENVIRONMENT
391 4304 : if ( IsDocShared() )
392 0 : FreeSharedFile();
393 : #endif
394 4304 : DELETEX( SfxMedium, pMedium );
395 : }
396 :
397 : // The removing of the temporary file must be done as the latest step in the document destruction
398 4881 : if ( !pImp->aTempName.isEmpty() )
399 : {
400 0 : OUString aTmp;
401 0 : ::utl::LocalFileHelper::ConvertPhysicalNameToURL( pImp->aTempName, aTmp );
402 0 : ::utl::UCBContentHelper::Kill( aTmp );
403 : }
404 :
405 4881 : delete pImp;
406 4881 : }
407 :
408 :
409 :
410 449 : void SfxObjectShell::Stamp_SetPrintCancelState(bool bState)
411 : {
412 449 : pImp->bIsPrintJobCancelable = bState;
413 449 : }
414 :
415 :
416 :
417 106 : bool SfxObjectShell::Stamp_GetPrintCancelState() const
418 : {
419 106 : return pImp->bIsPrintJobCancelable;
420 : }
421 :
422 :
423 :
424 : // closes the Object and all its views
425 :
426 5004 : bool SfxObjectShell::Close()
427 : {
428 5004 : SfxObjectShellRef aRef(this);
429 5004 : return CloseInternal();
430 : }
431 :
432 : // variant that does not take a reference to itself, so we can call it during object destruction
433 9885 : bool SfxObjectShell::CloseInternal()
434 : {
435 9885 : if ( !pImp->bClosing )
436 : {
437 : // Do not close if a progress is still running
438 4881 : if ( !pImp->bDisposing && GetProgress() )
439 0 : return false;
440 :
441 4881 : pImp->bClosing = true;
442 4881 : Reference< util::XCloseable > xCloseable( GetBaseModel(), UNO_QUERY );
443 :
444 4881 : if ( xCloseable.is() )
445 : {
446 : try
447 : {
448 4881 : xCloseable->close( sal_True );
449 : }
450 0 : catch (const Exception&)
451 : {
452 0 : pImp->bClosing = false;
453 : }
454 : }
455 :
456 4881 : if ( pImp->bClosing )
457 : {
458 : // remove from Document list
459 : // If there is no App, there is no document to remove
460 : // no need to call GetOrCreate here
461 4881 : SfxApplication *pSfxApp = SfxApplication::Get();
462 4881 : if(pSfxApp)
463 : {
464 4881 : SfxObjectShellArr_Impl &rDocs = pSfxApp->GetObjectShells_Impl();
465 4881 : SfxObjectShellArr_Impl::iterator it = std::find( rDocs.begin(), rDocs.end(), this );
466 4881 : if ( it != rDocs.end() )
467 4881 : rDocs.erase( it );
468 4881 : pImp->bInList = false;
469 : }
470 4881 : }
471 : }
472 :
473 9885 : return true;
474 : }
475 :
476 0 : OUString SfxObjectShell::CreateShellID( const SfxObjectShell* pShell )
477 : {
478 0 : if (!pShell)
479 0 : return OUString();
480 :
481 0 : OUString aShellID;
482 :
483 0 : SfxMedium* pMedium = pShell->GetMedium();
484 0 : if (pMedium)
485 0 : aShellID = pMedium->GetBaseURL();
486 :
487 0 : if (!aShellID.isEmpty())
488 0 : return aShellID;
489 :
490 0 : sal_Int64 nShellID = reinterpret_cast<sal_Int64>(pShell);
491 0 : aShellID = "0x" + OUString::number(nShellID, 16);
492 0 : return aShellID;
493 : }
494 :
495 : // returns a pointer the first SfxDocument of specified type
496 :
497 7398 : SfxObjectShell* SfxObjectShell::GetFirst
498 : (
499 : const TypeId* pType ,
500 : bool bOnlyVisible
501 : )
502 : {
503 7398 : SfxObjectShellArr_Impl &rDocs = SfxGetpApp()->GetObjectShells_Impl();
504 :
505 : // search for a SfxDocument of the specified type
506 7475 : for ( size_t nPos = 0; nPos < rDocs.size(); ++nPos )
507 : {
508 7458 : SfxObjectShell* pSh = rDocs[ nPos ];
509 7458 : if ( bOnlyVisible && pSh->IsPreview() && pSh->IsReadOnly() )
510 0 : continue;
511 :
512 22297 : if ( ( !pType || pSh->IsA(*pType) ) &&
513 8263 : ( !bOnlyVisible || SfxViewFrame::GetFirst( pSh, true )))
514 7381 : return pSh;
515 : }
516 :
517 17 : return 0;
518 : }
519 :
520 :
521 : // returns a pointer to the next SfxDocument of specified type behind *pDoc
522 :
523 6812 : SfxObjectShell* SfxObjectShell::GetNext
524 : (
525 : const SfxObjectShell& rPrev,
526 : const TypeId* pType,
527 : bool bOnlyVisible
528 : )
529 : {
530 6812 : SfxObjectShellArr_Impl &rDocs = SfxGetpApp()->GetObjectShells_Impl();
531 :
532 : // refind the specified predecessor
533 : sal_uInt16 nPos;
534 14292 : for ( nPos = 0; nPos < rDocs.size(); ++nPos )
535 14292 : if ( rDocs[nPos] == &rPrev )
536 6812 : break;
537 :
538 : // search for the next SfxDocument of the specified type
539 6938 : for ( ++nPos; nPos < rDocs.size(); ++nPos )
540 : {
541 2932 : SfxObjectShell* pSh = rDocs[ nPos ];
542 2932 : if ( bOnlyVisible && pSh->IsPreview() && pSh->IsReadOnly() )
543 0 : continue;
544 :
545 8670 : if ( ( !pType || pSh->IsA(*pType) ) &&
546 3066 : ( !bOnlyVisible || SfxViewFrame::GetFirst( pSh, true )))
547 2806 : return pSh;
548 : }
549 4006 : return 0;
550 : }
551 :
552 :
553 :
554 52256 : SfxObjectShell* SfxObjectShell::Current()
555 : {
556 52256 : SfxViewFrame *pFrame = SfxViewFrame::Current();
557 52256 : return pFrame ? pFrame->GetObjectShell() : 0;
558 : }
559 :
560 :
561 :
562 7 : bool SfxObjectShell::IsInPrepareClose() const
563 : {
564 7 : return pImp->bInPrepareClose;
565 : }
566 :
567 :
568 :
569 : struct BoolEnv_Impl
570 : {
571 : SfxObjectShell_Impl* pImp;
572 4 : explicit BoolEnv_Impl( SfxObjectShell_Impl* pImpP) : pImp( pImpP )
573 4 : { pImpP->bInPrepareClose = true; }
574 4 : ~BoolEnv_Impl() { pImp->bInPrepareClose = false; }
575 : };
576 :
577 :
578 7 : bool SfxObjectShell::PrepareClose
579 : (
580 : bool bUI // true: Dialog and so on is allowed
581 : // false: silent-mode
582 : )
583 : {
584 7 : if( pImp->bInPrepareClose || pImp->bPreparedForClose )
585 3 : return true;
586 4 : BoolEnv_Impl aBoolEnv( pImp );
587 :
588 : // DocModalDialog?
589 4 : if ( IsInModalMode() )
590 0 : return false;
591 :
592 4 : SfxViewFrame* pFirst = SfxViewFrame::GetFirst( this );
593 4 : if( pFirst && !pFirst->GetFrame().PrepareClose_Impl( bUI ) )
594 0 : return false;
595 :
596 : // prepare views for closing
597 7 : for ( SfxViewFrame* pFrm = SfxViewFrame::GetFirst( this );
598 : pFrm; pFrm = SfxViewFrame::GetNext( *pFrm, this ) )
599 : {
600 : DBG_ASSERT(pFrm->GetViewShell(),"No Shell");
601 3 : if ( pFrm->GetViewShell() )
602 : {
603 3 : bool nRet = pFrm->GetViewShell()->PrepareClose( bUI );
604 3 : if ( !nRet )
605 0 : return nRet;
606 : }
607 : }
608 :
609 4 : SfxApplication *pSfxApp = SfxGetpApp();
610 4 : pSfxApp->NotifyEvent( SfxEventHint(SFX_EVENT_PREPARECLOSEDOC, GlobalEventConfig::GetEventName(GlobalEventId::PREPARECLOSEDOC), this) );
611 :
612 4 : if( GetCreateMode() == SfxObjectCreateMode::EMBEDDED )
613 : {
614 0 : pImp->bPreparedForClose = true;
615 0 : return true;
616 : }
617 :
618 : // Ask if possible if it should be saved
619 : // only ask for the Document in the visible window
620 4 : SfxViewFrame *pFrame = SfxObjectShell::Current() == this
621 4 : ? SfxViewFrame::Current() : SfxViewFrame::GetFirst( this );
622 :
623 4 : if ( bUI && IsModified() && pFrame )
624 : {
625 : // restore minimized
626 0 : SfxFrame& rTop = pFrame->GetTopFrame();
627 0 : SfxViewFrame::SetViewFrame( rTop.GetCurrentViewFrame() );
628 0 : pFrame->GetFrame().Appear();
629 :
630 : // Ask if to save
631 0 : short nRet = RET_YES;
632 : {
633 0 : const Reference< XTitle > xTitle( *pImp->pBaseModel.get(), UNO_QUERY_THROW );
634 0 : const OUString sTitle = xTitle->getTitle ();
635 0 : nRet = ExecuteQuerySaveDocument(&pFrame->GetWindow(),sTitle);
636 : }
637 : /*HACK for plugin::destroy()*/
638 :
639 0 : if ( RET_YES == nRet )
640 : {
641 : // Save by each Dispatcher
642 : const SfxPoolItem *pPoolItem;
643 0 : if ( IsSaveVersionOnClose() )
644 : {
645 0 : SfxStringItem aItem( SID_DOCINFO_COMMENTS, SfxResId(STR_AUTOMATICVERSION).toString() );
646 0 : SfxBoolItem aWarnItem( SID_FAIL_ON_WARNING, bUI );
647 0 : const SfxPoolItem* ppArgs[] = { &aItem, &aWarnItem, 0 };
648 0 : pPoolItem = pFrame->GetBindings().ExecuteSynchron( SID_SAVEDOC, ppArgs );
649 : }
650 : else
651 : {
652 0 : SfxBoolItem aWarnItem( SID_FAIL_ON_WARNING, bUI );
653 0 : const SfxPoolItem* ppArgs[] = { &aWarnItem, 0 };
654 0 : pPoolItem = pFrame->GetBindings().ExecuteSynchron( IsReadOnlyMedium() ? SID_SAVEASDOC : SID_SAVEDOC, ppArgs );
655 : }
656 :
657 0 : if ( !pPoolItem || pPoolItem->ISA(SfxVoidItem) || ( pPoolItem->ISA(SfxBoolItem) && !static_cast<const SfxBoolItem*>( pPoolItem )->GetValue() ) )
658 0 : return false;
659 : }
660 0 : else if ( RET_CANCEL == nRet )
661 : // Cancelled
662 0 : return false;
663 : }
664 :
665 4 : pImp->bPreparedForClose = true;
666 4 : return true;
667 : }
668 :
669 :
670 : #if HAVE_FEATURE_SCRIPTING
671 : namespace
672 : {
673 42997 : static BasicManager* lcl_getBasicManagerForDocument( const SfxObjectShell& _rDocument )
674 : {
675 42997 : if ( !_rDocument.Get_Impl()->m_bNoBasicCapabilities )
676 : {
677 42978 : if ( !_rDocument.Get_Impl()->bBasicInitialized )
678 1678 : const_cast< SfxObjectShell& >( _rDocument ).InitBasicManager_Impl();
679 42977 : return _rDocument.Get_Impl()->aBasicManager.get();
680 : }
681 :
682 : // assume we do not have Basic ourself, but we can refer to another
683 : // document which does (by our model's XScriptInvocationContext::getScriptContainer).
684 : // In this case, we return the BasicManager of this other document.
685 :
686 : OSL_ENSURE( !Reference< XEmbeddedScripts >( _rDocument.GetModel(), UNO_QUERY ).is(),
687 : "lcl_getBasicManagerForDocument: inconsistency: no Basic, but an XEmbeddedScripts?" );
688 19 : Reference< XModel > xForeignDocument;
689 38 : Reference< XScriptInvocationContext > xContext( _rDocument.GetModel(), UNO_QUERY );
690 19 : if ( xContext.is() )
691 : {
692 19 : xForeignDocument.set( xContext->getScriptContainer(), UNO_QUERY );
693 : OSL_ENSURE( xForeignDocument.is() && xForeignDocument != _rDocument.GetModel(),
694 : "lcl_getBasicManagerForDocument: no Basic, but providing ourself as script container?" );
695 : }
696 :
697 19 : BasicManager* pBasMgr = NULL;
698 19 : if ( xForeignDocument.is() )
699 0 : pBasMgr = ::basic::BasicManagerRepository::getDocumentBasicManager( xForeignDocument );
700 :
701 38 : return pBasMgr;
702 : }
703 : }
704 : #endif
705 :
706 42978 : BasicManager* SfxObjectShell::GetBasicManager() const
707 : {
708 42978 : BasicManager* pBasMgr = NULL;
709 : #if HAVE_FEATURE_SCRIPTING
710 : try
711 : {
712 42978 : pBasMgr = lcl_getBasicManagerForDocument( *this );
713 42977 : if ( !pBasMgr )
714 622 : pBasMgr = SfxApplication::GetBasicManager();
715 : }
716 0 : catch (const css::ucb::ContentCreationException& e)
717 : {
718 : SAL_WARN("sfx.doc", "caught exception " << e.Message);
719 : }
720 : #endif
721 42977 : return pBasMgr;
722 : }
723 :
724 243 : void SfxObjectShell::SetHasNoBasic()
725 : {
726 243 : pImp->m_bNoBasicCapabilities = true;
727 243 : }
728 :
729 789 : bool SfxObjectShell::HasBasic() const
730 : {
731 : #if !HAVE_FEATURE_SCRIPTING
732 : return false;
733 : #else
734 789 : if ( pImp->m_bNoBasicCapabilities )
735 4 : return false;
736 :
737 785 : if ( !pImp->bBasicInitialized )
738 372 : const_cast< SfxObjectShell* >( this )->InitBasicManager_Impl();
739 :
740 785 : return pImp->aBasicManager.isValid();
741 : #endif
742 : }
743 :
744 :
745 : #if HAVE_FEATURE_SCRIPTING
746 : namespace
747 : {
748 : const Reference< XLibraryContainer >&
749 10897 : lcl_getOrCreateLibraryContainer( bool _bScript, Reference< XLibraryContainer >& _rxContainer,
750 : const Reference< XModel >& _rxDocument )
751 : {
752 10897 : if ( !_rxContainer.is() )
753 : {
754 : try
755 : {
756 6182 : Reference< XStorageBasedDocument > xStorageDoc( _rxDocument, UNO_QUERY );
757 : const Reference< XComponentContext > xContext(
758 12364 : ::comphelper::getProcessComponentContext() );
759 : _rxContainer.set ( _bScript
760 : ? DocumentScriptLibraryContainer::create(
761 : xContext, xStorageDoc )
762 : : DocumentDialogLibraryContainer::create(
763 : xContext, xStorageDoc )
764 12364 : , UNO_QUERY_THROW );
765 : }
766 328 : catch (const Exception&)
767 : {
768 : DBG_UNHANDLED_EXCEPTION();
769 : }
770 : }
771 10897 : return _rxContainer;
772 : }
773 : }
774 : #endif
775 :
776 2010 : Reference< XLibraryContainer > SfxObjectShell::GetDialogContainer()
777 : {
778 : #if HAVE_FEATURE_SCRIPTING
779 : try
780 : {
781 2010 : if ( !pImp->m_bNoBasicCapabilities )
782 2010 : return lcl_getOrCreateLibraryContainer( false, pImp->xDialogLibraries, GetModel() );
783 :
784 0 : BasicManager* pBasMgr = lcl_getBasicManagerForDocument( *this );
785 0 : if ( pBasMgr )
786 0 : return pBasMgr->GetDialogLibraryContainer().get();
787 : }
788 0 : catch (const css::ucb::ContentCreationException& e)
789 : {
790 : SAL_WARN("sfx.doc", "caught exception " << e.Message);
791 : }
792 :
793 : SAL_WARN("sfx.doc", "SfxObjectShell::GetDialogContainer: falling back to the application - is this really expected here?");
794 : #endif
795 0 : return SfxGetpApp()->GetDialogContainer();
796 : }
797 :
798 8906 : Reference< XLibraryContainer > SfxObjectShell::GetBasicContainer()
799 : {
800 : #if HAVE_FEATURE_SCRIPTING
801 : try
802 : {
803 8906 : if ( !pImp->m_bNoBasicCapabilities )
804 8887 : return lcl_getOrCreateLibraryContainer( true, pImp->xBasicLibraries, GetModel() );
805 :
806 19 : BasicManager* pBasMgr = lcl_getBasicManagerForDocument( *this );
807 19 : if ( pBasMgr )
808 0 : return pBasMgr->GetScriptLibraryContainer().get();
809 : }
810 0 : catch (const css::ucb::ContentCreationException& e)
811 : {
812 : SAL_WARN("sfx.doc", "caught exception " << e.Message);
813 : }
814 : SAL_WARN("sfx.doc", "SfxObjectShell::GetBasicContainer: falling back to the application - is this really expected here?");
815 : #endif
816 19 : return SfxGetpApp()->GetBasicContainer();
817 : }
818 :
819 1 : StarBASIC* SfxObjectShell::GetBasic() const
820 : {
821 : #if !HAVE_FEATURE_SCRIPTING
822 : return NULL;
823 : #else
824 1 : BasicManager * pMan = GetBasicManager();
825 1 : return pMan ? pMan->GetLib(0) : NULL;
826 : #endif
827 : }
828 :
829 2050 : void SfxObjectShell::InitBasicManager_Impl()
830 : /* [Description]
831 :
832 : Creates a document's BasicManager and loads it, if we are already based on
833 : a storage.
834 :
835 : [Note]
836 :
837 : This method has to be called by implementations of <SvPersist::Load()>
838 : (with its pStor parameter) and by implementations of <SvPersist::InitNew()>
839 : (with pStor = 0).
840 : */
841 :
842 : {
843 : /* #163556# (DR) - Handling of recursive calls while creating the Bacic
844 : manager.
845 :
846 : It is possible that (while creating the Basic manager) the code that
847 : imports the Basic storage wants to access the Basic manager again.
848 : Especially in VBA compatibility mode, there is code that wants to
849 : access the "VBA Globals" object which is stored as global UNO constant
850 : in the Basic manager.
851 :
852 : To achieve correct handling of the recursive calls of this function
853 : from lcl_getBasicManagerForDocument(), the implementation of the
854 : function BasicManagerRepository::getDocumentBasicManager() has been
855 : changed to return the Basic manager currently under construction, when
856 : called repeatedly.
857 :
858 : The variable pImp->bBasicInitialized will be set to sal_True after
859 : construction now, to ensure that the recursive call of the function
860 : lcl_getBasicManagerForDocument() will be routed into this function too.
861 :
862 : Calling BasicManagerHolder::reset() twice is not a big problem, as it
863 : does not take ownership but stores only the raw pointer. Owner of all
864 : Basic managers is the global BasicManagerRepository instance.
865 : */
866 : #if HAVE_FEATURE_SCRIPTING
867 : DBG_ASSERT( !pImp->bBasicInitialized && !pImp->aBasicManager.isValid(), "Lokaler BasicManager bereits vorhanden");
868 : try
869 : {
870 2051 : pImp->aBasicManager.reset( BasicManagerRepository::getDocumentBasicManager( GetModel() ) );
871 : }
872 0 : catch (const css::ucb::ContentCreationException& e)
873 : {
874 : SAL_WARN("sfx.doc", "caught exception " << e.Message);
875 : }
876 : DBG_ASSERT( pImp->aBasicManager.isValid(), "SfxObjectShell::InitBasicManager_Impl: did not get a BasicManager!" );
877 2049 : pImp->bBasicInitialized = true;
878 : #endif
879 2049 : }
880 :
881 :
882 :
883 1805 : bool SfxObjectShell::DoClose()
884 : {
885 1805 : return Close();
886 : }
887 :
888 :
889 :
890 0 : SfxObjectShell* SfxObjectShell::GetObjectShell()
891 : {
892 0 : return this;
893 : }
894 :
895 :
896 :
897 113 : uno::Sequence< OUString > SfxObjectShell::GetEventNames()
898 : {
899 : static uno::Sequence< OUString >* pEventNameContainer = NULL;
900 :
901 113 : if ( !pEventNameContainer )
902 : {
903 24 : SolarMutexGuard aGuard;
904 24 : if ( !pEventNameContainer )
905 : {
906 24 : static uno::Sequence< OUString > aEventNameContainer = GlobalEventConfig().getElementNames();
907 24 : pEventNameContainer = &aEventNameContainer;
908 24 : }
909 : }
910 :
911 113 : return *pEventNameContainer;
912 : }
913 :
914 :
915 :
916 669610 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > SfxObjectShell::GetModel() const
917 : {
918 669610 : return GetBaseModel();
919 : }
920 :
921 4941 : void SfxObjectShell::SetBaseModel( SfxBaseModel* pModel )
922 : {
923 : OSL_ENSURE( !pImp->pBaseModel.is() || pModel == NULL, "Model already set!" );
924 4941 : pImp->pBaseModel.set( pModel );
925 4941 : if ( pImp->pBaseModel.is() )
926 : {
927 4941 : pImp->pBaseModel->addCloseListener( new SfxModelListener_Impl(this) );
928 : }
929 4941 : }
930 :
931 :
932 :
933 734720 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > SfxObjectShell::GetBaseModel() const
934 : {
935 734720 : return pImp->pBaseModel.get();
936 : }
937 :
938 2963 : void SfxObjectShell::SetAutoStyleFilterIndex(sal_uInt16 nSet)
939 : {
940 2963 : pImp->nStyleFilter = nSet;
941 2963 : }
942 :
943 0 : sal_uInt16 SfxObjectShell::GetAutoStyleFilterIndex()
944 : {
945 0 : return pImp->nStyleFilter;
946 : }
947 :
948 :
949 13735 : void SfxObjectShell::SetCurrentComponent( const Reference< XInterface >& _rxComponent )
950 : {
951 13735 : WeakReference< XInterface >& rTheCurrentComponent = theCurrentComponent::get();
952 :
953 13735 : Reference< XInterface > xOldCurrentComp(rTheCurrentComponent);
954 13735 : if ( _rxComponent == xOldCurrentComp )
955 : // nothing to do
956 21191 : return;
957 : // note that "_rxComponent.get() == s_xCurrentComponent.get().get()" is /sufficient/, but not
958 : // /required/ for "_rxComponent == s_xCurrentComponent.get()".
959 : // In other words, it's still possible that we here do something which is not necessary,
960 : // but we should have filtered quite some unnecessary calls already.
961 :
962 : #if HAVE_FEATURE_SCRIPTING
963 6279 : BasicManager* pAppMgr = SfxApplication::GetBasicManager();
964 6279 : rTheCurrentComponent = _rxComponent;
965 6279 : if ( pAppMgr )
966 : {
967 : // set "ThisComponent" for Basic
968 6279 : pAppMgr->SetGlobalUNOConstant( "ThisComponent", Any( _rxComponent ) );
969 :
970 : // set new current component for VBA compatibility
971 6279 : if ( _rxComponent.is() )
972 : {
973 3153 : OString aVBAConstName = lclGetVBAGlobalConstName( _rxComponent );
974 3153 : if ( !aVBAConstName.isEmpty() )
975 : {
976 3010 : pAppMgr->SetGlobalUNOConstant( aVBAConstName.getStr(), Any( _rxComponent ) );
977 3010 : s_aRegisteredVBAConstants[ _rxComponent.get() ] = aVBAConstName;
978 3153 : }
979 : }
980 : // no new component passed -> remove last registered VBA component
981 3126 : else if ( xOldCurrentComp.is() )
982 : {
983 3126 : OString aVBAConstName = lclGetVBAGlobalConstName( xOldCurrentComp );
984 3126 : if ( !aVBAConstName.isEmpty() )
985 : {
986 2989 : pAppMgr->SetGlobalUNOConstant( aVBAConstName.getStr(), Any( Reference< XInterface >() ) );
987 2989 : s_aRegisteredVBAConstants.erase( xOldCurrentComp.get() );
988 3126 : }
989 : }
990 6279 : }
991 : #endif
992 : }
993 :
994 4992 : Reference< XInterface > SfxObjectShell::GetCurrentComponent()
995 : {
996 4992 : return theCurrentComponent::get();
997 : }
998 :
999 :
1000 9204 : OUString SfxObjectShell::GetServiceNameFromFactory( const OUString& rFact )
1001 : {
1002 : //! Remove everything behind name!
1003 9204 : OUString aFact( rFact );
1004 18408 : OUString aPrefix("private:factory/");
1005 9204 : if ( aFact.startsWith( aPrefix ) )
1006 703 : aFact = aFact.copy( aPrefix.getLength() );
1007 9204 : sal_Int32 nPos = aFact.indexOf( '?' );
1008 18408 : OUString aParam;
1009 9204 : if ( nPos != -1 )
1010 : {
1011 0 : aParam = aFact.copy( nPos );
1012 0 : aFact = aFact.copy( 0, nPos );
1013 0 : aParam = aParam.copy(1);
1014 : }
1015 9204 : aFact = comphelper::string::remove(aFact, '4');
1016 9204 : aFact = aFact.toAsciiLowerCase();
1017 :
1018 : // HACK: sometimes a real document service name is given here instead of
1019 : // a factory short name. Set return value directly to this service name as fallback
1020 : // in case next lines of code does nothing ...
1021 : // use rFact instead of normed aFact value !
1022 9204 : OUString aServiceName = rFact;
1023 :
1024 9204 : if ( aFact == "swriter" )
1025 : {
1026 7325 : aServiceName = "com.sun.star.text.TextDocument";
1027 : }
1028 1879 : else if ( aFact == "sweb" || aFact == "swriter/web" )
1029 : {
1030 85 : aServiceName = "com.sun.star.text.WebDocument";
1031 : }
1032 1794 : else if ( aFact == "sglobal" || aFact == "swriter/globaldocument" )
1033 : {
1034 59 : aServiceName = "com.sun.star.text.GlobalDocument";
1035 : }
1036 1735 : else if ( aFact == "scalc" )
1037 : {
1038 1125 : aServiceName = "com.sun.star.sheet.SpreadsheetDocument";
1039 : }
1040 610 : else if ( aFact == "sdraw" )
1041 : {
1042 286 : aServiceName = "com.sun.star.drawing.DrawingDocument";
1043 : }
1044 324 : else if ( aFact == "simpress" )
1045 : {
1046 217 : aServiceName = "com.sun.star.presentation.PresentationDocument";
1047 : }
1048 107 : else if ( aFact == "schart" )
1049 : {
1050 0 : aServiceName = "com.sun.star.chart.ChartDocument";
1051 : }
1052 107 : else if ( aFact == "smath" )
1053 : {
1054 107 : aServiceName = "com.sun.star.formula.FormulaProperties";
1055 : }
1056 : #if HAVE_FEATURE_SCRIPTING
1057 0 : else if ( aFact == "sbasic" )
1058 : {
1059 0 : aServiceName = "com.sun.star.script.BasicIDE";
1060 : }
1061 : #endif
1062 : #if HAVE_FEATURE_DBCONNECTIVITY
1063 0 : else if ( aFact == "sdatabase" )
1064 : {
1065 0 : aServiceName = "com.sun.star.sdb.OfficeDatabaseDocument";
1066 : }
1067 : #endif
1068 :
1069 18408 : return aServiceName;
1070 : }
1071 :
1072 0 : SfxObjectShell* SfxObjectShell::CreateObjectByFactoryName( const OUString& rFact, SfxObjectCreateMode eMode )
1073 : {
1074 0 : return CreateObject( GetServiceNameFromFactory( rFact ), eMode );
1075 : }
1076 :
1077 :
1078 0 : SfxObjectShell* SfxObjectShell::CreateObject( const OUString& rServiceName, SfxObjectCreateMode eCreateMode )
1079 : {
1080 0 : if ( !rServiceName.isEmpty() )
1081 : {
1082 0 : uno::Reference < frame::XModel > xDoc( ::comphelper::getProcessServiceFactory()->createInstance( rServiceName ), UNO_QUERY );
1083 0 : if ( xDoc.is() )
1084 : {
1085 0 : uno::Reference < lang::XUnoTunnel > xObj( xDoc, UNO_QUERY );
1086 0 : uno::Sequence < sal_Int8 > aSeq( SvGlobalName( SFX_GLOBAL_CLASSID ).GetByteSequence() );
1087 0 : sal_Int64 nHandle = xObj->getSomething( aSeq );
1088 0 : if ( nHandle )
1089 : {
1090 0 : SfxObjectShell* pRet = reinterpret_cast< SfxObjectShell* >( sal::static_int_cast< sal_IntPtr >( nHandle ));
1091 0 : pRet->SetCreateMode_Impl( eCreateMode );
1092 0 : return pRet;
1093 0 : }
1094 0 : }
1095 : }
1096 :
1097 0 : return 0;
1098 : }
1099 :
1100 0 : Reference<lang::XComponent> SfxObjectShell::CreateAndLoadComponent( const SfxItemSet& rSet, SfxFrame* pFrame )
1101 : {
1102 0 : uno::Sequence < beans::PropertyValue > aProps;
1103 0 : TransformItems( SID_OPENDOC, rSet, aProps );
1104 0 : SFX_ITEMSET_ARG(&rSet, pFileNameItem, SfxStringItem, SID_FILE_NAME, false);
1105 0 : SFX_ITEMSET_ARG(&rSet, pTargetItem, SfxStringItem, SID_TARGETNAME, false);
1106 0 : OUString aURL;
1107 0 : OUString aTarget("_blank");
1108 0 : if ( pFileNameItem )
1109 0 : aURL = pFileNameItem->GetValue();
1110 0 : if ( pTargetItem )
1111 0 : aTarget = pTargetItem->GetValue();
1112 :
1113 0 : uno::Reference < frame::XComponentLoader > xLoader;
1114 0 : if ( pFrame )
1115 : {
1116 0 : xLoader = uno::Reference < frame::XComponentLoader >( pFrame->GetFrameInterface(), uno::UNO_QUERY );
1117 : }
1118 : else
1119 0 : xLoader = uno::Reference < frame::XComponentLoader >( frame::Desktop::create(comphelper::getProcessComponentContext()), uno::UNO_QUERY );
1120 :
1121 0 : Reference <lang::XComponent> xComp;
1122 : try
1123 : {
1124 0 : xComp = xLoader->loadComponentFromURL(aURL, aTarget, 0, aProps);
1125 : }
1126 0 : catch (const uno::Exception&)
1127 : {
1128 : }
1129 :
1130 0 : return xComp;
1131 : }
1132 :
1133 32 : SfxObjectShell* SfxObjectShell::GetShellFromComponent( const Reference<lang::XComponent>& xComp )
1134 : {
1135 : try
1136 : {
1137 32 : Reference<lang::XUnoTunnel> xTunnel(xComp, UNO_QUERY_THROW);
1138 64 : Sequence <sal_Int8> aSeq( SvGlobalName( SFX_GLOBAL_CLASSID ).GetByteSequence() );
1139 32 : sal_Int64 nHandle = xTunnel->getSomething( aSeq );
1140 32 : if (!nHandle)
1141 0 : return NULL;
1142 :
1143 64 : return reinterpret_cast< SfxObjectShell* >(sal::static_int_cast< sal_IntPtr >( nHandle ));
1144 : }
1145 0 : catch (const Exception&)
1146 : {
1147 : }
1148 :
1149 0 : return NULL;
1150 : }
1151 :
1152 4130 : void SfxObjectShell::SetInitialized_Impl( const bool i_fromInitNew )
1153 : {
1154 4130 : pImp->bInitialized = true;
1155 4130 : if ( i_fromInitNew )
1156 : {
1157 1150 : SetActivateEvent_Impl( SFX_EVENT_CREATEDOC );
1158 1150 : SfxGetpApp()->NotifyEvent( SfxEventHint( SFX_EVENT_DOCCREATED, GlobalEventConfig::GetEventName(GlobalEventId::DOCCREATED), this ) );
1159 : }
1160 : else
1161 : {
1162 2980 : SfxGetpApp()->NotifyEvent( SfxEventHint( SFX_EVENT_LOADFINISHED, GlobalEventConfig::GetEventName(GlobalEventId::LOADFINISHED), this ) );
1163 : }
1164 4130 : }
1165 :
1166 :
1167 0 : bool SfxObjectShell::IsChangeRecording() const
1168 : {
1169 : // currently this function needs to be overwritten by Writer and Calc only
1170 : DBG_ASSERT( false, "function not implemented" );
1171 0 : return false;
1172 : }
1173 :
1174 :
1175 0 : bool SfxObjectShell::HasChangeRecordProtection() const
1176 : {
1177 : // currently this function needs to be overwritten by Writer and Calc only
1178 : DBG_ASSERT( false, "function not implemented" );
1179 0 : return false;
1180 : }
1181 :
1182 :
1183 0 : void SfxObjectShell::SetChangeRecording( bool /*bActivate*/ )
1184 : {
1185 : // currently this function needs to be overwritten by Writer and Calc only
1186 : DBG_ASSERT( false, "function not implemented" );
1187 0 : }
1188 :
1189 :
1190 0 : bool SfxObjectShell::SetProtectionPassword( const OUString & /*rPassword*/ )
1191 : {
1192 : // currently this function needs to be overwritten by Writer and Calc only
1193 : DBG_ASSERT( false, "function not implemented" );
1194 0 : return false;
1195 : }
1196 :
1197 :
1198 0 : bool SfxObjectShell::GetProtectionHash( /*out*/ ::com::sun::star::uno::Sequence< sal_Int8 > & /*rPasswordHash*/ )
1199 : {
1200 : // currently this function needs to be overwritten by Writer and Calc only
1201 : DBG_ASSERT( false, "function not implemented" );
1202 0 : return false;
1203 648 : }
1204 :
1205 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|