1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SFX2_OBJSH_HXX
20 #define INCLUDED_SFX2_OBJSH_HXX
22 #include <sal/config.h>
23 #include <sfx2/dllapi.h>
24 #include <sfx2/signaturestate.hxx>
25 #include <sal/types.h>
26 #include <comphelper/errcode.hxx>
27 #include <com/sun/star/uno/Reference.h>
28 #include <com/sun/star/uno/Sequence.hxx>
29 #include <com/sun/star/frame/XModel3.hpp>
30 #include <vcl/bitmapex.hxx>
32 #include <svl/poolitem.hxx>
33 #include <sot/formats.hxx>
34 #include <sot/object.hxx>
35 #include <tools/gen.hxx>
36 #include <tools/link.hxx>
38 #include <sfx2/shell.hxx>
39 #include <comphelper/embeddedobjectcontainer.hxx>
42 #include <string_view>
44 #include <o3tl/typed_flags_set.hxx>
46 #include <sfx2/AccessibilityIssue.hxx>
48 namespace weld
{class Button
; }
49 namespace model
{class ColorSet
; }
55 class SfxObjectFactory
;
56 class SfxDocumentInfoDialog
;
57 class SfxStyleSheetBasePool
;
60 class SvKeyValueIterator
;
75 enum class SfxModelFlags
;
76 enum class SfxEventHintId
;
77 enum class InfobarType
;
79 // These values presumably must match exactly the corresponding
80 // css::embed::Aspects ones (in offapi/com/sun/star/embed/Aspects.idl)
81 // and the DVASPECT_* ones in the Win32 API.
83 #define ASPECT_CONTENT 1
84 #define ASPECT_THUMBNAIL 2 /* 120 * 120, 6 Colors DIB in MetaFile */
86 #define ASPECT_DOCPRINT 8
94 namespace com::sun::star::awt
{ class XWindow
; }
95 namespace com::sun::star::beans
{ struct PropertyValue
; }
96 namespace com::sun::star::document
{ struct CmisVersion
; }
97 namespace com::sun::star::document
{ class XDocumentProperties
; }
98 namespace com::sun::star::embed
{ class XStorage
; }
99 namespace com::sun::star::frame
{ class XModel
; }
100 namespace com::sun::star::graphic
{ class XGraphic
; }
101 namespace com::sun::star::io
{ class XStream
; }
102 namespace com::sun::star::script
{ class XLibraryContainer
; }
103 namespace com::sun::star::security
{ class XCertificate
; }
104 namespace com::sun::star::security
{ class XDocumentDigitalSignatures
; }
105 namespace com::sun::star::security
{ struct DocumentSignatureInformation
; }
106 namespace com::sun::star::task
{ class XInteractionHandler
; }
107 namespace com::sun::star::lang
{ class XComponent
; }
108 namespace com::sun::star::text
{ class XTextRange
; }
110 namespace sfx2
{ class IXmlIdRegistry
; }
112 #define SFX_TITLE_TITLE 0
113 #define SFX_TITLE_FILENAME 1
114 #define SFX_TITLE_FULLNAME 2
115 #define SFX_TITLE_APINAME 3
116 #define SFX_TITLE_DETECT 4
117 #define SFX_TITLE_CAPTION 5
118 #define SFX_TITLE_PICKLIST 6
119 #define SFX_TITLE_HISTORY 7
120 #define SFX_TITLE_MAXLEN 10 // this gives the limits on length
122 enum class SfxLoadedFlags
127 ALL
= MAINDOCUMENT
| IMAGES
131 template<> struct typed_flags
<SfxLoadedFlags
> : is_typed_flags
<SfxLoadedFlags
, 0x03> {};
134 enum class HiddenInformation
137 RECORDEDCHANGES
= 0x0001,
139 DOCUMENTVERSIONS
= 0x0004
143 template<> struct typed_flags
<HiddenInformation
> : is_typed_flags
<HiddenInformation
, 0x07> {};
146 namespace weld
{ class Window
; }
148 enum class HiddenWarningFact
156 enum class SfxObjectCreateMode
165 The class SfxObjectShell is the base class for SFx-objects, ie documents
166 and parts of documents that can be integrated as separate objects
167 into foreign objects.
168 There can be multiple edit windows (SfxViewShell) for one SfxObjectShell.
171 struct TransferableObjectDescriptor
;
172 template<class T
> bool checkSfxObjectShell(const SfxObjectShell
* pShell
)
174 return dynamic_cast<const T
*>(pShell
) != nullptr;
177 class SFX2_DLLPUBLIC SfxObjectShell
:
178 public SfxShell
, virtual public SotObject
,
179 public ::comphelper::IEmbeddedHelper
181 friend struct ModifyBlocker_Impl
;
182 friend class SfxObjectShellLock
;
185 std::unique_ptr
<struct SfxObjectShell_Impl
> pImpl
; // internal data
187 SfxMedium
* pMedium
; // Description of the file for example
188 // storage that contains the object
189 SfxObjectCreateMode eCreateMode
; // Purpose of the object
190 bool bHasName
:1; // sal_True := existing object,
191 // sal_False := new object
192 bool bIsInGenerateThumbnail
; //optimize thumbnail generate and store procedure to improve odt saving performance, i120030
193 bool mbAvoidRecentDocs
; ///< Avoid adding to the recent documents list, if not necessary.
195 enum TriState
{undefined
, yes
, no
};
196 TriState mbContinueImportOnFilterExceptions
= undefined
; // try to import as much as possible
198 bool CloseInternal();
200 SAL_DLLPRIVATE
void UpdateTime_Impl(const css::uno::Reference
<
201 css::document::XDocumentProperties
> & i_xDocProps
);
203 SAL_DLLPRIVATE
bool SaveTo_Impl(SfxMedium
&rMedium
, const SfxItemSet
* pSet
);
206 SfxObjectShell(SfxObjectCreateMode
);
207 SfxObjectShell(SfxModelFlags
); // see sfxmodelfactory.hxx
208 virtual ~SfxObjectShell() override
;
210 void ModifyChanged();
211 virtual bool Close() override
;
213 /// template method, called by FlushDocInfo; this implementation is empty
214 virtual void DoFlushDocInfo();
217 void AddToRecentlyUsedList();
219 // Parent class for actual guard objects that would do useful work
220 class LockAllViewsGuard
223 virtual ~LockAllViewsGuard() {}
227 SFX_DECL_INTERFACE(SFX_INTERFACE_SFXDOCSH
)
230 /// SfxInterface initializer.
231 static void InitInterface_Impl();
234 static const css::uno::Sequence
<sal_Int8
>& getUnoTunnelId();
235 /* Stampit disable/enable cancel button for print jobs
236 default = true = enable! */
237 void Stamp_SetPrintCancelState(bool bState
);
238 bool Stamp_GetPrintCancelState() const;
240 static OUString
CreateShellID( const SfxObjectShell
* pShell
);
242 // Document-Shell Iterator
243 SAL_WARN_UNUSED_RESULT
static SfxObjectShell
* GetFirst( const std::function
<bool ( const SfxObjectShell
* )>& isObjectShell
= nullptr,
244 bool bOnlyVisible
= true );
245 SAL_WARN_UNUSED_RESULT
static SfxObjectShell
* GetNext( const SfxObjectShell
& rPrev
,
246 const std::function
<bool ( const SfxObjectShell
* )>& isObjectShell
= nullptr,
247 bool bOnlyVisible
= true );
248 SAL_WARN_UNUSED_RESULT
static SfxObjectShell
* Current();
249 static css::uno::Reference
< css::uno::XInterface
>
250 GetCurrentComponent();
251 static void SetCurrentComponent( const css::uno::Reference
< css::uno::XInterface
>& _rxComponent
);
253 virtual void Invalidate(sal_uInt16 nId
= 0) override
;
255 SfxModule
* GetModule() const;
257 virtual SfxObjectFactory
& GetFactory() const=0;
258 SfxMedium
* GetMedium() const { return pMedium
; }
259 css::uno::Reference
< css::document::XDocumentProperties
>
260 getDocProperties() const;
261 void UpdateDocInfoForSave( );
263 bool HasName() const { return bHasName
; }
264 OUString
GetAPIName() const;
266 bool IsReadOnly() const;
267 bool IsReadOnlyMedium() const;
268 bool IsOriginallyReadOnlyMedium() const;
269 bool IsOriginallyLoadedReadOnlyMedium() const;
270 void SetReadOnlyUI( bool bReadOnly
= true );
271 bool IsReadOnlyUI() const;
273 bool IsInModalMode() const;
274 bool IsInPrepareClose() const;
275 bool AcceptStateUpdate() const;
276 bool IsHelpDocument() const;
278 bool IsDocShared() const;
279 OUString
GetSharedFileURL() const;
280 bool SwitchToShared( bool bShared
, bool bSave
);
281 SAL_DLLPRIVATE
void FreeSharedFile( const OUString
& aTempFileURL
);
282 SAL_DLLPRIVATE
void DoNotCleanShareControlFile();
283 void SetSharedXMLFlag( bool bFlag
) const;
284 bool HasSharedXMLFlagSet() const;
286 SAL_DLLPRIVATE
void SetModalMode_Impl(bool bModal
);
287 SAL_DLLPRIVATE
void SetMacroMode_Impl(bool bModal
=true);
290 ErrCode
GetError() const;
291 ErrCode
GetErrorCode() const;
292 void SetError(ErrCode rErr
);
295 * Initialize bare minimum just enough for unit test runs.
297 * @return true if the initialization is successful, false otherwise.
299 void DoInitUnitTest();
301 bool DoLoad( SfxMedium
* pMedium
);
302 bool DoLoadExternal( SfxMedium
* pMed
);
304 bool DoSaveAs( SfxMedium
&rNewStor
);
305 bool DoSaveObjectAs( SfxMedium
&rNewStor
, bool bCommit
);
307 // TODO/LATER: currently only overridden in Calc, should be made non-virtual
308 virtual bool DoSaveCompleted( SfxMedium
* pNewStor
=nullptr, bool bRegisterRecent
=true );
309 /// Terminate any in-flight editing. Used before saving, primarily by Calc to commit cell changes.
310 virtual void TerminateEditing() {}
312 bool LoadOwnFormat( SfxMedium
& pMedium
);
313 virtual bool SaveAsOwnFormat( SfxMedium
& pMedium
);
314 virtual bool ConvertFrom( SfxMedium
&rMedium
);
315 virtual bool ConvertTo( SfxMedium
&rMedium
);
316 virtual bool InitNew( const css::uno::Reference
< css::embed::XStorage
>& xStorage
);
317 virtual bool Load( SfxMedium
&rMedium
);
318 virtual bool LoadFrom( SfxMedium
& rMedium
);
320 virtual bool SaveAs( SfxMedium
&rMedium
);
321 virtual bool SaveCompleted( const css::uno::Reference
< css::embed::XStorage
>& xStorage
);
322 bool SwitchPersistence(
323 const css::uno::Reference
< css::embed::XStorage
>& xStorage
);
324 virtual void UpdateLinks();
325 virtual bool LoadExternal( SfxMedium
& rMedium
);
326 bool IsConfigOptionsChecked() const;
327 void SetConfigOptionsChecked( bool bChecked
);
329 // called for a few slots like SID_SAVE[AS]DOC, SID_PRINTDOC[DIRECT], derived classes may abort the action
330 virtual bool QuerySlotExecutable( sal_uInt16 nSlotId
);
332 void SaveChildren(bool bObjectsOnly
=false);
333 bool SaveAsChildren( SfxMedium
&rMedium
);
334 bool SwitchChildrenPersistence(
335 const css::uno::Reference
< css::embed::XStorage
>& xStorage
,
336 bool bForceNonModified
= false );
337 bool SaveCompletedChildren();
339 /** a very special case to insert at a position in Writer from UNO,
340 via OwnSubFilterService */
341 virtual bool InsertGeneratedStream(SfxMedium
& rMedium
,
342 css::uno::Reference
<css::text::XTextRange
> const& xInsertPosition
);
343 virtual bool ImportFrom( SfxMedium
&rMedium
,
344 css::uno::Reference
<css::text::XTextRange
> const& xInsertPosition
);
345 bool ExportTo( SfxMedium
&rMedium
);
347 /** Returns true if preparing was successful, else false. */
348 bool PrepareForSigning(weld::Window
* pDialogParent
);
349 bool CheckIsReadonly(bool bSignScriptingContent
, weld::Window
* pDialogParent
= nullptr);
350 void RecheckSignature(bool bAlsoRecheckScriptingSignature
);
351 void AfterSigning(bool bSignSuccess
, bool bSignScriptingContent
);
352 bool HasValidSignatures() const;
353 SignatureState
GetDocumentSignatureState();
354 void SignDocumentContent(weld::Window
* pDialogParent
);
355 css::uno::Sequence
<css::security::DocumentSignatureInformation
> GetDocumentSignatureInformation(
356 bool bScriptingContent
,
357 const css::uno::Reference
<css::security::XDocumentDigitalSignatures
>& xSigner
358 = css::uno::Reference
<css::security::XDocumentDigitalSignatures
>());
360 bool SignDocumentContentUsingCertificate(const css::uno::Reference
<css::security::XCertificate
>& xCertificate
);
362 void SignSignatureLine(weld::Window
* pDialogParent
, const OUString
& aSignatureLineId
,
363 const css::uno::Reference
<css::security::XCertificate
>& xCert
,
364 const css::uno::Reference
<css::graphic::XGraphic
>& xValidGraphic
,
365 const css::uno::Reference
<css::graphic::XGraphic
>& xInvalidGraphic
,
366 const OUString
& aComment
);
367 SignatureState
GetScriptingSignatureState();
368 void SignScriptingContent(weld::Window
* pDialogParent
);
369 DECL_DLLPRIVATE_LINK(SignDocumentHandler
, weld::Button
&, void);
371 virtual std::shared_ptr
<SfxDocumentInfoDialog
> CreateDocumentInfoDialog(weld::Window
* pParent
, const SfxItemSet
& rItemSet
);
373 ErrCode
CallBasic( std::u16string_view rMacro
, std::u16string_view rBasicName
,
374 SbxArray
* pArgs
, SbxValue
* pRet
= nullptr );
377 const OUString
& rScriptURL
,
378 const css::uno::Sequence
< css::uno::Any
>& aParams
,
380 css::uno::Sequence
< sal_Int16
>& aOutParamIndex
,
381 css::uno::Sequence
< css::uno::Any
>& aOutParam
,
382 bool bRaiseError
= true,
383 const css::uno::Any
* aCaller
= nullptr );
385 static ErrCode
CallXScript(
386 const css::uno::Reference
< css::uno::XInterface
>& _rxScriptContext
,
387 const OUString
& rScriptURL
,
388 const css::uno::Sequence
< css::uno::Any
>& aParams
,
390 css::uno::Sequence
< sal_Int16
>& aOutParamIndex
,
391 css::uno::Sequence
< css::uno::Any
>& aOutParam
,
392 bool bRaiseError
= true,
393 const css::uno::Any
* aCaller
= nullptr
396 /** adjusts the internal macro mode, according to the current security settings
398 Finally, the macro mode is either NEVER_EXECUTE or ALWAYS_EXECUTE_NO_WARN.
401 whether macros from this document should be executed
403 bool AdjustMacroMode();
405 static bool UnTrustedScript(const OUString
& rScriptURL
);
407 static bool isScriptAccessAllowed(const css::uno::Reference
<css::uno::XInterface
>& rScriptContext
);
409 SvKeyValueIterator
* GetHeaderAttributes();
410 void ClearHeaderAttributesForSourceViewHack();
411 void SetHeaderAttributesForSourceViewHack();
413 bool IsQueryLoadTemplate() const;
414 bool IsUseUserData() const;
415 bool IsUseThumbnailSave() const;
416 bool IsLoadReadonly() const;
417 bool IsSaveVersionOnClose() const;
418 void SetQueryLoadTemplate( bool b
);
419 void SetUseUserData( bool bNew
);
420 void SetUseThumbnailSave( bool _bNew
);
421 void SetLoadReadonly( bool _bReadonly
);
422 void SetSaveVersionOnClose( bool bSet
);
423 void ResetFromTemplate( const OUString
& rTemplateName
, std::u16string_view rFileName
);
425 // TODO/LATER: the following two methods should be replaced by Get/SetModifPasswordInfo in future
426 sal_uInt32
GetModifyPasswordHash() const;
427 bool SetModifyPasswordHash( sal_uInt32 nHash
);
429 void SetMacroCallsSeenWhileLoading();
430 bool GetMacroCallsSeenWhileLoading() const;
432 const css::uno::Sequence
< css::beans::PropertyValue
>& GetModifyPasswordInfo() const;
433 bool SetModifyPasswordInfo( const css::uno::Sequence
< css::beans::PropertyValue
>& aInfo
);
435 static ErrCode
HandleFilter( SfxMedium
* pMedium
, SfxObjectShell
const * pDoc
);
437 virtual bool PrepareClose(bool bUI
= true);
438 virtual HiddenInformation
GetHiddenInformationState( HiddenInformation nStates
);
439 sal_Int16
QueryHiddenInformation( HiddenWarningFact eFact
, weld::Window
* pParent
);
440 bool IsSecurityOptOpenReadOnly() const;
441 void SetSecurityOptOpenReadOnly( bool bOpenReadOnly
);
443 Size
GetFirstPageSize() const;
445 std::shared_ptr
<GDIMetaFile
> GetPreviewMetaFile( bool bFullContent
= false ) const;
446 BitmapEx
GetPreviewBitmap() const;
447 virtual void CancelTransfers();
449 bool GenerateAndStoreThumbnail(
451 const css::uno::Reference
< css::embed::XStorage
>& xStor
);
455 const css::uno::Reference
< css::io::XStream
>& xStream
);
457 bool IsInGenerateAndStoreThumbnail() const {return bIsInGenerateThumbnail
;}//optimize thumbnail generate and store procedure to improve odt saving performance, i120030
459 /// Don't add to the recent documents - it's an expensive operation, sometimes it is not wanted.
460 bool IsAvoidRecentDocs() const { return mbAvoidRecentDocs
; }
462 /// Don't add to the recent documents - it's an expensive operation, sometimes it is not wanted.
463 void AvoidRecentDocs(bool bAvoid
) { mbAvoidRecentDocs
= bAvoid
; }
465 /// On first error ask user if import should continue; return saved answer.
466 bool IsContinueImportOnFilterExceptions(std::u16string_view aErrMessage
);
469 bool IsAbortingImport() const;
470 void FinishedLoading( SfxLoadedFlags nWhich
= SfxLoadedFlags::ALL
);
472 void TemplateDisconnectionAfterLoad();
473 void SetLoading(SfxLoadedFlags nFlags
);
474 bool IsLoading() const;
475 bool IsLoadingFinished() const;
476 void SetAutoLoad( const INetURLObject
&, sal_uInt32 nTime
, bool bReload
);
477 bool IsAutoLoadLocked() const;
480 bool IsPreview() const;
481 SfxObjectCreateMode
GetCreateMode() const { return eCreateMode
; }
482 SfxProgress
* GetProgress() const;
483 void SetWaitCursor( bool bSet
) const;
486 void SetTitle( const OUString
& rTitle
);
487 /* Small non-zero values of nMaxLen don't mean length, but have a magic meaning:
489 the title itself, as it is
491 1 (==SFX_TITLE_FILENAME)
492 provides the logical file name without path
493 (under WNT depending on the system settings
496 2 (==SFX_TITLE_FULLNAME)
497 provides the logical file names with full path
498 (remote =>:: com:: sun:: star:: util:: URL)
500 3 (==SFX_TITLE_APINAME)
501 provides the logical filename without path
504 4 (==SFX_TITLE_DETECT)
505 provides the complete title, if not set yet
506 it will be created from DocInfo or the name of
509 5 (==SFX_TITLE_CAPTION)
510 provides the Title just like MB now in the
513 6 (==SFX_TITLE_PICKLIST)
514 returns the Title, just like MB now would
515 display it in the PickList
517 7 (==SFX_TITLE_HISTORY)
518 returns the Title just like MB now would
519 display it in the History
522 provides the 'nMaxLength' of the logical
523 file name including the path
524 (remote => css::util::URL)
526 OUString
GetTitle( sal_uInt16 nMaxLen
= 0 ) const;
527 void InvalidateName(); // Re-set to unnamed
531 bool DdeExecute( const OUString
& rCmd
);
532 virtual bool DdeGetData( const OUString
& rItem
,
533 const OUString
& rMimeType
,
534 css::uno::Any
& rValue
);
535 virtual bool DdeSetData( const OUString
& rItem
,
536 const OUString
& rMimeType
,
537 const css::uno::Any
& rValue
);
539 virtual ::sfx2::SvLinkSource
* DdeCreateLinkSource( const OUString
& rItem
);
540 virtual void ReconnectDdeLink(SfxObjectShell
& rServer
);
542 static void ReconnectDdeLinks(SfxObjectShell
& rServer
);
545 virtual SfxStyleSheetBasePool
* GetStyleSheetPool();
547 virtual void LoadStyles(SfxObjectShell
&rSource
);
549 virtual sfx2::StyleManager
* GetStyleManager();
551 // Determine the position of the "Automatic" filter in the stylist
552 void SetAutoStyleFilterIndex(sal_uInt16 nSet
);
553 sal_uInt16
GetAutoStyleFilterIndex() const;
554 bool HasBasic() const;
555 BasicManager
* GetBasicManager() const;
556 css::uno::Reference
< css::script::XLibraryContainer
>
558 css::uno::Reference
< css::script::XLibraryContainer
>
559 GetDialogContainer();
560 StarBASIC
* GetBasic() const;
562 std::optional
<NamedColor
> GetRecentColor(sal_uInt16 nSlotId
);
563 void SetRecentColor(sal_uInt16 nSlotId
, const NamedColor
& rColor
);
565 virtual std::set
<Color
> GetDocColors();
566 virtual std::shared_ptr
<model::ColorSet
> GetThemeColors();
568 // Accessibility Check
569 virtual sfx::AccessibilityIssueCollection
runAccessibilityCheck();
571 // Documents, for which to format the view size
573 virtual SfxObjectShell
* GetObjectShell() override
;
575 css::uno::Reference
< css::frame::XModel3
>
577 // Only temporarily for the applications!
578 void SetBaseModel( SfxBaseModel
* pModel
);
579 css::uno::Reference
< css::frame::XModel3
> GetBaseModel() const;
580 // Only temporarily for the applications!
582 virtual css::uno::Sequence
< OUString
> GetEventNames();
584 css::uno::Reference
<css::awt::XWindow
> GetDialogParent(SfxMedium
const* pMedium
= nullptr);
585 static SfxObjectShell
* CreateObject( const OUString
& rServiceName
, SfxObjectCreateMode
= SfxObjectCreateMode::STANDARD
);
586 static SfxObjectShell
* CreateObjectByFactoryName( const OUString
& rURL
, SfxObjectCreateMode
= SfxObjectCreateMode::STANDARD
);
587 static css::uno::Reference
< css::lang::XComponent
>
588 CreateAndLoadComponent( const SfxItemSet
& rSet
);
589 static SfxObjectShell
* GetShellFromComponent(const css::uno::Reference
< css::uno::XInterface
>& xComp
);
590 static SfxObjectShell
* GetParentShell(const css::uno::Reference
<css::uno::XInterface
>& xChild
);
591 static OUString
GetServiceNameFromFactory( const OUString
& rFact
);
592 bool IsInPlaceActive() const;
593 bool IsUIActive() const;
595 static bool CopyStoragesOfUnknownMediaType(
596 const css::uno::Reference
< css::embed::XStorage
>& xSource
,
597 const css::uno::Reference
<css::embed::XStorage
>& xTarget
,
598 const css::uno::Sequence
<OUString
>& rExceptions
= css::uno::Sequence
<OUString
>());
600 bool isEditDocLocked() const;
601 bool isContentExtractionLocked() const;
602 bool isExportLocked() const;
603 bool isPrintLocked() const;
604 bool isSaveLocked() const;
606 // The functions from SvPersist
607 void EnableSetModified( bool bEnable
= true );
608 bool IsEnableSetModified() const;
609 virtual void SetModified( bool bModified
= true );
610 bool IsModified() const;
613 * @param bChart true if the file is a chart doc and FillClass should not be called
616 const css::uno::Reference
< css::embed::XStorage
>& xStorage
,
617 sal_Int32 nVersion
, bool bTemplate
) const;
619 css::uno::Reference
< css::embed::XStorage
> const & GetStorage();
621 SvGlobalName
const & GetClassName() const;
623 // comphelper::IEmbeddedHelper
624 virtual css::uno::Reference
< css::task::XInteractionHandler
> getInteractionHandler() const override
;
625 virtual css::uno::Reference
< css::embed::XStorage
> getStorage() const override
627 return const_cast<SfxObjectShell
*>(this)->GetStorage();
629 virtual comphelper::EmbeddedObjectContainer
& getEmbeddedObjectContainer() const override
631 return GetEmbeddedObjectContainer();
633 bool isEnableSetModified() const override
635 return IsEnableSetModified();
637 virtual OUString
getDocumentBaseURL() const override
;
639 comphelper::EmbeddedObjectContainer
& GetEmbeddedObjectContainer() const;
640 void ClearEmbeddedObjects();
642 // The functions from SvEmbeddedObject
643 virtual Printer
* GetDocumentPrinter();
644 virtual OutputDevice
* GetDocumentRefDev();
645 virtual void OnDocumentPrinterChanged( Printer
* pNewPrinter
);
646 virtual tools::Rectangle
GetVisArea( sal_uInt16 nAspect
) const;
647 virtual void SetVisArea( const tools::Rectangle
& rVisArea
);
648 const tools::Rectangle
& GetVisArea() const;
649 void SetVisAreaSize( const Size
& rVisSize
);
651 MapUnit
GetMapUnit() const;
652 void SetMapUnit( MapUnit nMUnit
);
654 void FillTransferableObjectDescriptor( TransferableObjectDescriptor
& rDesc
) const;
655 void DoDraw( OutputDevice
*, const Point
& rObjPos
,
657 const JobSetup
& rSetup
,
658 sal_uInt16 nAspect
= ASPECT_CONTENT
,
659 bool bOutputForScreen
= false );
660 virtual void Draw( OutputDevice
*, const JobSetup
& rSetup
,
661 sal_uInt16 nAspect
, bool bOutputForScreen
) = 0;
664 virtual void FillClass( SvGlobalName
* pClassName
,
665 SotClipboardFormatId
* pFormat
,
666 OUString
* pFullTypeName
,
668 bool bTemplate
= false) const = 0;
670 // change recording and respective passwword protection for Writer and Calc
671 // slots available for Writer: FN_REDLINE_ON, FN_REDLINE_ON
672 // slots used for Calc: FID_CHG_RECORD, SID_CHG_PROTECT
673 virtual bool IsChangeRecording() const;
674 virtual bool HasChangeRecordProtection() const;
675 virtual void SetChangeRecording( bool bActivate
, bool bLockAllViews
= false );
676 virtual void SetProtectionPassword( const OUString
&rPassword
);
677 virtual bool GetProtectionHash( /*out*/ css::uno::Sequence
< sal_Int8
> &rPasswordHash
);
679 static bool IsOwnStorageFormat(const SfxMedium
&);
681 /** Append Infobar once the frame is ready.
682 Useful when you want to register an Infobar before the doc/frame is fully loaded. */
683 void AppendInfoBarWhenReady(const OUString
& sId
, const OUString
& sPrimaryMessage
,
684 const OUString
& sSecondaryMessage
, InfobarType aInfobarType
,
685 bool bShowCloseButton
= true);
686 std::vector
<InfobarData
>& getPendingInfobars();
688 SAL_DLLPRIVATE
bool CreatePreview_Impl(bool bFullContent
, VirtualDevice
* pDevice
, GDIMetaFile
* pFile
) const;
690 SAL_DLLPRIVATE
static bool IsPackageStorageFormat_Impl(const SfxMedium
&);
692 SAL_DLLPRIVATE
bool ConnectTmpStorage_Impl( const css::uno::Reference
< css::embed::XStorage
>& xStorage
, SfxMedium
* pMedium
);
693 SAL_DLLPRIVATE
bool DisconnectStorage_Impl( SfxMedium
& rSrcMedium
, SfxMedium
& rTargetMedium
);
695 SAL_DLLPRIVATE
bool PutURLContentsToVersionStream_Impl(
696 const OUString
& aURL
,
697 const css::uno::Reference
< css::embed::XStorage
>& xDocStorage
,
698 const OUString
& aStreamName
);
700 SAL_DLLPRIVATE OUString
CreateTempCopyOfStorage_Impl(
701 const css::uno::Reference
< css::embed::XStorage
>& xStorage
);
703 SAL_DLLPRIVATE
void InitOwnModel_Impl();
704 SAL_DLLPRIVATE
void BreakMacroSign_Impl( bool bBreakMacroSing
);
705 SAL_DLLPRIVATE
void CheckSecurityOnLoading_Impl();
706 SAL_DLLPRIVATE
void CheckForBrokenDocSignatures_Impl();
707 SAL_DLLPRIVATE
void CheckEncryption_Impl( const css::uno::Reference
< css::task::XInteractionHandler
>& xHandler
);
708 SAL_DLLPRIVATE
void SetModifyPasswordEntered( bool bEntered
= true );
709 SAL_DLLPRIVATE
bool IsModifyPasswordEntered() const;
711 SAL_DLLPRIVATE
void InitBasicManager_Impl();
712 SAL_DLLPRIVATE SfxObjectShell_Impl
* Get_Impl() { return pImpl
.get(); }
714 SAL_DLLPRIVATE
static bool UseInteractionToHandleError(
715 const css::uno::Reference
< css::task::XInteractionHandler
>& xHandler
,
717 SAL_DLLPRIVATE
const SfxObjectShell_Impl
* Get_Impl() const { return pImpl
.get(); }
719 SAL_DLLPRIVATE
void SetCreateMode_Impl( SfxObjectCreateMode nMode
);
721 SAL_DLLPRIVATE
void DoDraw_Impl( OutputDevice
* pDev
,
722 const Point
& rViewPos
,
723 const Fraction
& rScaleX
,
724 const Fraction
& rScaleY
,
725 const JobSetup
& rSetup
,
727 bool bOutputForScreen
);
730 SAL_DLLPRIVATE
void ExecFile_Impl(SfxRequest
&);
731 SAL_DLLPRIVATE
void GetState_Impl(SfxItemSet
&);
732 SAL_DLLPRIVATE
void PrintExec_Impl(SfxRequest
&);
733 SAL_DLLPRIVATE
void PrintState_Impl(SfxItemSet
&);
734 SAL_DLLPRIVATE
void ExecProps_Impl(SfxRequest
&);
735 SAL_DLLPRIVATE
void StateProps_Impl(SfxItemSet
&);
736 SAL_DLLPRIVATE
void ExecView_Impl(SfxRequest
&);
737 SAL_DLLPRIVATE
static void StateView_Impl(SfxItemSet
&);
739 // Load/Save public internals
740 SAL_DLLPRIVATE
bool ImportFromGeneratedStream_Impl(
741 const css::uno::Reference
< css::io::XStream
>& xStream
,
742 const css::uno::Sequence
< css::beans::PropertyValue
>& aMediaDescr
);
743 SAL_DLLPRIVATE
void UpdateFromTemplate_Impl();
744 SAL_DLLPRIVATE
bool CanReload_Impl();
745 SAL_DLLPRIVATE
void SetNamedVisibility_Impl();
746 SAL_DLLPRIVATE
bool DoSave_Impl( const SfxItemSet
* pSet
);
747 SAL_DLLPRIVATE
bool Save_Impl( const SfxItemSet
* pSet
);
749 PreDoSaveAs_Impl(const OUString
& rFileName
, const OUString
& rFiltName
,
750 SfxItemSet
const& rItemSet
,
751 const css::uno::Sequence
<css::beans::PropertyValue
>& rArgs
);
752 SAL_DLLPRIVATE
bool APISaveAs_Impl(std::u16string_view aFileName
, SfxItemSet
& rItemSet
,
753 const css::uno::Sequence
<css::beans::PropertyValue
>& rArgs
);
755 CommonSaveAs_Impl(const INetURLObject
& aURL
, const OUString
& aFilterName
, SfxItemSet
& rItemSet
,
756 const css::uno::Sequence
<css::beans::PropertyValue
>& rArgs
);
757 SAL_DLLPRIVATE
bool GeneralInit_Impl(
758 const css::uno::Reference
< css::embed::XStorage
>& xStorage
,
759 bool bTypeMustBeSetAlready
);
760 SAL_DLLPRIVATE
void PrepareSecondTryLoad_Impl();
761 SAL_DLLPRIVATE
void SetInitialized_Impl( const bool i_fromInitNew
);
764 SAL_DLLPRIVATE IndexBitSet
& GetNoSet_Impl();
765 SAL_DLLPRIVATE
void SetProgress_Impl( SfxProgress
*pProgress
);
766 SAL_DLLPRIVATE
void PostActivateEvent_Impl( SfxViewFrame
const * );
767 SAL_DLLPRIVATE
void SetActivateEvent_Impl(SfxEventHintId
);
769 // configuration items
770 SAL_DLLPRIVATE SignatureState
ImplGetSignatureState( bool bScriptingContent
= false );
772 SAL_DLLPRIVATE
bool QuerySaveSizeExceededModules_Impl( const css::uno::Reference
< css::task::XInteractionHandler
>& xHandler
);
773 SAL_DLLPRIVATE
static bool QueryAllowExoticFormat_Impl( const css::uno::Reference
< css::task::XInteractionHandler
>& xHandler
,
774 const OUString
& rURL
,
775 const OUString
& rFilterUIName
);
777 SAL_DLLPRIVATE
void CheckOut( );
778 SAL_DLLPRIVATE
void CancelCheckOut( );
779 SAL_DLLPRIVATE
void CheckIn( );
780 SAL_DLLPRIVATE
css::uno::Sequence
< css::document::CmisVersion
> GetCmisVersions() const;
782 /** override this if you have a XmlIdRegistry. */
783 virtual const sfx2::IXmlIdRegistry
* GetXmlIdRegistry() const { return nullptr; }
785 /// Is this read-only object shell opened via .uno:SignPDF?
786 bool IsSignPDF() const;
788 /// Gets the certificate that is already picked by the user but not yet used for signing.
789 css::uno::Reference
<css::security::XCertificate
> GetSignPDFCertificate() const;
791 /// Gets grab-bagged password info to unprotect change tracking with verification
792 css::uno::Sequence
< css::beans::PropertyValue
> GetDocumentProtectionFromGrabBag() const;
794 // Lock all unlocked views, and returns a guard object which unlocks those views when destructed
795 virtual std::unique_ptr
<LockAllViewsGuard
> LockAllViews()
797 return std::make_unique
<LockAllViewsGuard
>();
802 #define SFX_GLOBAL_CLASSID \
803 0x9eaba5c3, 0xb232, 0x4309, \
804 0x84, 0x5f, 0x5f, 0x15, 0xea, 0x50, 0xd0, 0x74
806 struct ModifyBlocker_Impl
809 SfxObjectShell
* pPersist
;
812 ModifyBlocker_Impl( SfxObjectShell
* pPersistP
) : pPersist( pPersistP
)
814 bWasEnabled
= pPersistP
->IsEnableSetModified();
816 pPersistP
->EnableSetModified( false );
818 ~ModifyBlocker_Impl()
821 pPersist
->EnableSetModified( bWasEnabled
);
826 typedef tools::SvRef
<SfxObjectShell
> SfxObjectShellRef
;
828 class SfxObjectShellLock
830 SfxObjectShell
* pObj
;
832 SfxObjectShellLock() { pObj
= nullptr; }
833 inline SfxObjectShellLock( const SfxObjectShellLock
& rObj
);
834 inline SfxObjectShellLock( SfxObjectShellLock
&& rObj
) noexcept
;
835 inline SfxObjectShellLock( SfxObjectShell
* pObjP
);
837 inline ~SfxObjectShellLock();
838 inline SfxObjectShellLock
& operator = ( const SfxObjectShellLock
& rObj
);
839 inline SfxObjectShellLock
& operator = ( SfxObjectShellLock
&& rObj
);
840 inline SfxObjectShellLock
& operator = ( SfxObjectShell
* pObj
);
841 bool Is() const { return pObj
!= nullptr; }
842 SfxObjectShell
* operator & () const { return pObj
; }
843 SfxObjectShell
* operator -> () const { return pObj
; }
844 SfxObjectShell
& operator * () const { return *pObj
; }
845 operator SfxObjectShell
* () const { return pObj
; }
847 inline SfxObjectShellLock::SfxObjectShellLock( const SfxObjectShellLock
& rObj
)
851 pObj
->OwnerLock( true );
853 inline SfxObjectShellLock::SfxObjectShellLock( SfxObjectShellLock
&& rObj
) noexcept
858 inline SfxObjectShellLock::SfxObjectShellLock( SfxObjectShell
* pObjP
)
862 pObj
->OwnerLock( true );
864 inline void SfxObjectShellLock::Clear()
868 SfxObjectShell
* const pRefObj
= pObj
;
870 pRefObj
->OwnerLock( false );
873 inline SfxObjectShellLock::~SfxObjectShellLock()
876 pObj
->OwnerLock( false );
878 inline SfxObjectShellLock
& SfxObjectShellLock::operator=( const SfxObjectShellLock
& rObj
)
881 rObj
.pObj
->OwnerLock( true );
882 SfxObjectShell
* const pRefObj
= pObj
;
885 pRefObj
->OwnerLock( false );
888 inline SfxObjectShellLock
& SfxObjectShellLock::operator=( SfxObjectShellLock
&& rObj
)
891 pObj
->OwnerLock( false );
896 inline SfxObjectShellLock
& SfxObjectShellLock::operator=( SfxObjectShell
* pObjP
)
898 *this = SfxObjectShellLock( pObjP
);
902 class SFX2_DLLPUBLIC SfxObjectShellItem final
: public SfxPoolItem
904 SfxObjectShell
* pObjSh
;
907 static SfxPoolItem
* CreateDefault();
909 SfxObjectShellItem() :
913 SfxObjectShellItem( sal_uInt16 nWhichId
,
914 SfxObjectShell
*pObjShell
):
915 SfxPoolItem( nWhichId
),
919 virtual bool operator==( const SfxPoolItem
& ) const override
;
920 virtual SfxObjectShellItem
* Clone( SfxItemPool
*pPool
= nullptr ) const override
;
921 virtual bool QueryValue( css::uno::Any
& rVal
, sal_uInt8 nMemberId
= 0 ) const override
;
922 virtual bool PutValue( const css::uno::Any
& rVal
, sal_uInt8 nMemberId
) override
;
927 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */