Coverage Report

Created: 2026-03-31 11:00

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