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
95 namespace sfx
{ class IDocumentModelAccessor
; }
97 namespace com::sun::star::awt
{ class XWindow
; }
98 namespace com::sun::star::beans
{ struct PropertyValue
; }
99 namespace com::sun::star::document
{ struct CmisVersion
; }
100 namespace com::sun::star::document
{ class XDocumentProperties
; }
101 namespace com::sun::star::embed
{ class XStorage
; }
102 namespace com::sun::star::frame
{ class XModel
; }
103 namespace com::sun::star::graphic
{ class XGraphic
; }
104 namespace com::sun::star::io
{ class XStream
; }
105 namespace com::sun::star::script
{ class XLibraryContainer
; }
106 namespace com::sun::star::security
{ class XCertificate
; }
107 namespace com::sun::star::security
{ class XDocumentDigitalSignatures
; }
108 namespace com::sun::star::security
{ struct DocumentSignatureInformation
; }
109 namespace com::sun::star::task
{ class XInteractionHandler
; }
110 namespace com::sun::star::lang
{ class XComponent
; }
111 namespace com::sun::star::text
{ class XTextRange
; }
113 #define SFX_TITLE_TITLE 0
114 #define SFX_TITLE_FILENAME 1
115 #define SFX_TITLE_FULLNAME 2
116 #define SFX_TITLE_APINAME 3
117 #define SFX_TITLE_DETECT 4
118 #define SFX_TITLE_CAPTION 5
119 #define SFX_TITLE_PICKLIST 6
120 #define SFX_TITLE_HISTORY 7
121 #define SFX_TITLE_MAXLEN 10 // this gives the limits on length
123 enum class SfxLoadedFlags
128 ALL
= MAINDOCUMENT
| IMAGES
132 template<> struct typed_flags
<SfxLoadedFlags
> : is_typed_flags
<SfxLoadedFlags
, 0x03> {};
135 enum class HiddenInformation
138 RECORDEDCHANGES
= 0x0001,
140 DOCUMENTVERSIONS
= 0x0004
144 template<> struct typed_flags
<HiddenInformation
> : is_typed_flags
<HiddenInformation
, 0x07> {};
147 namespace weld
{ class Window
; }
149 enum class HiddenWarningFact
157 enum class SfxObjectCreateMode
166 The class SfxObjectShell is the base class for SFx-objects, ie documents
167 and parts of documents that can be integrated as separate objects
168 into foreign objects.
169 There can be multiple edit windows (SfxViewShell) for one SfxObjectShell.
172 struct TransferableObjectDescriptor
;
173 template<class T
> bool checkSfxObjectShell(const SfxObjectShell
* pShell
)
175 return dynamic_cast<const T
*>(pShell
) != nullptr;
178 class SFX2_DLLPUBLIC SfxObjectShell
:
179 public SfxShell
, virtual public SotObject
,
180 public ::comphelper::IEmbeddedHelper
182 friend struct ModifyBlocker_Impl
;
183 friend class SfxObjectShellLock
;
186 std::unique_ptr
<struct SfxObjectShell_Impl
> pImpl
; // internal data
188 SfxMedium
* pMedium
; // Description of the file for example
189 // storage that contains the object
190 SfxObjectCreateMode eCreateMode
; // Purpose of the object
191 bool bHasName
:1; // sal_True := existing object,
192 // sal_False := new object
193 bool bIsInGenerateThumbnail
; //optimize thumbnail generate and store procedure to improve odt saving performance, i120030
194 bool mbAvoidRecentDocs
; ///< Avoid adding to the recent documents list, if not necessary.
195 bool bRememberSignature
; // Do we want to remember the signature.
197 enum TriState
{undefined
, yes
, no
};
198 TriState mbContinueImportOnFilterExceptions
= undefined
; // try to import as much as possible
200 bool CloseInternal();
202 SAL_DLLPRIVATE
void UpdateTime_Impl(const css::uno::Reference
<
203 css::document::XDocumentProperties
> & i_xDocProps
);
205 css::uno::Sequence
< css::security::DocumentSignatureInformation
> rSignatureInfosRemembered
;
207 SAL_DLLPRIVATE
bool SaveTo_Impl(SfxMedium
&rMedium
, const SfxItemSet
* pSet
);
209 // true if the document had macros (or similar) on load to trigger warning user
210 SAL_DLLPRIVATE
bool GetHadCheckedMacrosOnLoad() const;
213 SfxObjectShell(SfxObjectCreateMode
);
214 SfxObjectShell(SfxModelFlags
); // see sfxmodelfactory.hxx
215 virtual ~SfxObjectShell() override
;
217 void ModifyChanged();
218 virtual bool Close() override
;
220 /// template method, called by FlushDocInfo; this implementation is empty
221 virtual void DoFlushDocInfo();
224 void AddToRecentlyUsedList();
226 // Parent class for actual guard objects that would do useful work
227 class LockAllViewsGuard
230 virtual ~LockAllViewsGuard() {}
234 SFX_DECL_INTERFACE(SFX_INTERFACE_SFXDOCSH
)
237 /// SfxInterface initializer.
238 static void InitInterface_Impl();
241 static const css::uno::Sequence
<sal_Int8
>& getUnoTunnelId();
243 /* Stampit disable/enable cancel button for print jobs
244 default = true = enable! */
245 void Stamp_SetPrintCancelState(bool bState
);
246 bool Stamp_GetPrintCancelState() const;
248 static OUString
CreateShellID( const SfxObjectShell
* pShell
);
250 // Document-Shell Iterator
251 SAL_WARN_UNUSED_RESULT
static SfxObjectShell
* GetFirst( const std::function
<bool ( const SfxObjectShell
* )>& isObjectShell
= nullptr,
252 bool bOnlyVisible
= true );
253 SAL_WARN_UNUSED_RESULT
static SfxObjectShell
* GetNext( const SfxObjectShell
& rPrev
,
254 const std::function
<bool ( const SfxObjectShell
* )>& isObjectShell
= nullptr,
255 bool bOnlyVisible
= true );
256 SAL_WARN_UNUSED_RESULT
static SfxObjectShell
* Current();
257 static css::uno::Reference
< css::uno::XInterface
>
258 GetCurrentComponent();
259 static void SetCurrentComponent( const css::uno::Reference
< css::uno::XInterface
>& _rxComponent
);
261 virtual void Invalidate(sal_uInt16 nId
= 0) override
;
263 SfxModule
* GetModule() const;
265 virtual SfxObjectFactory
& GetFactory() const=0;
266 SfxMedium
* GetMedium() const { return pMedium
; }
267 css::uno::Reference
< css::document::XDocumentProperties
>
268 getDocProperties() const;
269 void UpdateDocInfoForSave( );
271 bool HasName() const { return bHasName
; }
272 OUString
GetAPIName() const;
274 bool IsReadOnly() const;
275 bool IsReadOnlyMedium() const;
276 bool IsOriginallyReadOnlyMedium() const;
277 bool IsOriginallyLoadedReadOnlyMedium() const;
278 void SetReadOnlyUI( bool bReadOnly
= true );
279 bool IsReadOnlyUI() const;
281 bool IsInModalMode() const;
282 bool IsInPrepareClose() const;
283 bool AcceptStateUpdate() const;
284 bool IsHelpDocument() const;
286 bool IsDocShared() const;
287 OUString
GetSharedFileURL() const;
288 bool SwitchToShared( bool bShared
, bool bSave
);
289 SAL_DLLPRIVATE
void FreeSharedFile( const OUString
& aTempFileURL
);
290 SAL_DLLPRIVATE
void DoNotCleanShareControlFile();
291 void SetSharedXMLFlag( bool bFlag
) const;
292 bool HasSharedXMLFlagSet() const;
294 SAL_DLLPRIVATE
void SetModalMode_Impl(bool bModal
);
295 SAL_DLLPRIVATE
void SetMacroMode_Impl(bool bModal
=true);
298 ErrCodeMsg
GetErrorIgnoreWarning() const;
299 ErrCodeMsg
GetErrorCode() const;
300 void SetError(const ErrCodeMsg
& rErr
);
303 * Initialize bare minimum just enough for unit test runs.
305 * @return true if the initialization is successful, false otherwise.
307 void DoInitUnitTest();
309 bool DoLoad( SfxMedium
* pMedium
);
310 bool DoLoadExternal( SfxMedium
* pMed
);
312 bool DoSaveAs( SfxMedium
&rNewStor
);
313 bool DoSaveObjectAs( SfxMedium
&rNewStor
, bool bCommit
);
315 // TODO/LATER: currently only overridden in Calc, should be made non-virtual
316 virtual bool DoSaveCompleted( SfxMedium
* pNewStor
=nullptr, bool bRegisterRecent
=true );
317 /// Terminate any in-flight editing. Used before saving, primarily by Calc to commit cell changes.
318 virtual void TerminateEditing() {}
320 bool LoadOwnFormat( SfxMedium
& pMedium
);
321 virtual bool SaveAsOwnFormat( SfxMedium
& pMedium
);
322 virtual bool ConvertFrom( SfxMedium
&rMedium
);
323 virtual bool ConvertTo( SfxMedium
&rMedium
);
324 virtual bool InitNew( const css::uno::Reference
< css::embed::XStorage
>& xStorage
);
325 virtual bool Load( SfxMedium
&rMedium
);
326 virtual bool LoadFrom( SfxMedium
& rMedium
);
328 virtual bool SaveAs( SfxMedium
&rMedium
);
329 virtual bool SaveCompleted( const css::uno::Reference
< css::embed::XStorage
>& xStorage
);
330 bool SwitchPersistence(
331 const css::uno::Reference
< css::embed::XStorage
>& xStorage
);
332 virtual void UpdateLinks();
333 virtual bool LoadExternal( SfxMedium
& rMedium
);
334 bool IsConfigOptionsChecked() const;
335 void SetConfigOptionsChecked( bool bChecked
);
337 // called for a few slots like SID_SAVE[AS]DOC, SID_PRINTDOC[DIRECT], derived classes may abort the action
338 virtual bool QuerySlotExecutable( sal_uInt16 nSlotId
);
340 void SaveChildren(bool bObjectsOnly
=false);
341 bool SaveAsChildren( SfxMedium
&rMedium
);
342 bool SwitchChildrenPersistence(
343 const css::uno::Reference
< css::embed::XStorage
>& xStorage
,
344 bool bForceNonModified
= false );
345 bool SaveCompletedChildren();
347 /** a very special case to insert at a position in Writer from UNO,
348 via OwnSubFilterService */
349 virtual bool InsertGeneratedStream(SfxMedium
& rMedium
,
350 css::uno::Reference
<css::text::XTextRange
> const& xInsertPosition
);
351 virtual bool ImportFrom( SfxMedium
&rMedium
,
352 css::uno::Reference
<css::text::XTextRange
> const& xInsertPosition
);
353 bool ExportTo( SfxMedium
&rMedium
);
355 /** Returns true if preparing was successful, else false. */
356 bool PrepareForSigning(weld::Window
* pDialogParent
);
357 bool CheckIsReadonly(bool bSignScriptingContent
, weld::Window
* pDialogParent
= nullptr);
358 void RecheckSignature(bool bAlsoRecheckScriptingSignature
);
359 void AfterSigning(bool bSignSuccess
, bool bSignScriptingContent
);
360 bool HasValidSignatures() const;
361 SignatureState
GetDocumentSignatureState();
362 bool SignDocumentContent(weld::Window
* pDialogParent
);
363 css::uno::Sequence
<css::security::DocumentSignatureInformation
> GetDocumentSignatureInformation(
364 bool bScriptingContent
,
365 const css::uno::Reference
<css::security::XDocumentDigitalSignatures
>& xSigner
366 = css::uno::Reference
<css::security::XDocumentDigitalSignatures
>());
368 bool SignDocumentContentUsingCertificate(const css::uno::Reference
<css::security::XCertificate
>& xCertificate
);
369 bool ResignDocument(css::uno::Sequence
< css::security::DocumentSignatureInformation
>& rSignaturesInfo
);
371 void SignSignatureLine(weld::Window
* pDialogParent
, const OUString
& aSignatureLineId
,
372 const css::uno::Reference
<css::security::XCertificate
>& xCert
,
373 const css::uno::Reference
<css::graphic::XGraphic
>& xValidGraphic
,
374 const css::uno::Reference
<css::graphic::XGraphic
>& xInvalidGraphic
,
375 const OUString
& aComment
);
376 SignatureState
GetScriptingSignatureState();
377 bool SignScriptingContent(weld::Window
* pDialogParent
);
378 DECL_DLLPRIVATE_LINK(SignDocumentHandler
, weld::Button
&, void);
380 virtual std::shared_ptr
<SfxDocumentInfoDialog
> CreateDocumentInfoDialog(weld::Window
* pParent
, const SfxItemSet
& rItemSet
);
382 ErrCode
CallBasic( std::u16string_view rMacro
, std::u16string_view rBasicName
,
383 SbxArray
* pArgs
, SbxValue
* pRet
= nullptr );
386 const OUString
& rScriptURL
,
387 const css::uno::Sequence
< css::uno::Any
>& aParams
,
389 css::uno::Sequence
< sal_Int16
>& aOutParamIndex
,
390 css::uno::Sequence
< css::uno::Any
>& aOutParam
,
391 bool bRaiseError
= true,
392 const css::uno::Any
* aCaller
= nullptr );
394 static ErrCode
CallXScript(
395 const css::uno::Reference
< css::uno::XInterface
>& _rxScriptContext
,
396 const OUString
& rScriptURL
,
397 const css::uno::Sequence
< css::uno::Any
>& aParams
,
399 css::uno::Sequence
< sal_Int16
>& aOutParamIndex
,
400 css::uno::Sequence
< css::uno::Any
>& aOutParam
,
401 bool bRaiseError
= true,
402 const css::uno::Any
* aCaller
= nullptr
405 /** adjusts the internal macro mode, according to the current security settings
407 Finally, the macro mode is either NEVER_EXECUTE or ALWAYS_EXECUTE_NO_WARN.
410 whether macros from this document should be executed
412 bool AdjustMacroMode();
414 static bool UnTrustedScript(const OUString
& rScriptURL
);
416 static bool isScriptAccessAllowed(const css::uno::Reference
<css::uno::XInterface
>& rScriptContext
);
418 SvKeyValueIterator
* GetHeaderAttributes();
419 void ClearHeaderAttributesForSourceViewHack();
420 void SetHeaderAttributesForSourceViewHack();
422 bool IsQueryLoadTemplate() const;
423 bool IsUseUserData() const;
424 bool IsUseThumbnailSave() const;
425 bool IsLoadReadonly() const;
426 bool IsSaveVersionOnClose() const;
427 void SetQueryLoadTemplate( bool b
);
428 void SetUseUserData( bool bNew
);
429 void SetUseThumbnailSave( bool _bNew
);
430 void SetLoadReadonly( bool _bReadonly
);
431 void SetSaveVersionOnClose( bool bSet
);
432 void ResetFromTemplate( const OUString
& rTemplateName
, std::u16string_view rFileName
);
434 // TODO/LATER: the following two methods should be replaced by Get/SetModifPasswordInfo in future
435 sal_uInt32
GetModifyPasswordHash() const;
436 bool SetModifyPasswordHash( sal_uInt32 nHash
);
438 void SetMacroCallsSeenWhileLoading();
439 bool GetMacroCallsSeenWhileLoading() const;
441 // true if this type of link, from a document, is allowed by the user to be passed to uno:OpenDoc
442 static bool AllowedLinkProtocolFromDocument(const OUString
& rUrl
, SfxObjectShell
* pObjShell
, weld::Window
* pDialogParent
);
444 const css::uno::Sequence
< css::beans::PropertyValue
>& GetModifyPasswordInfo() const;
445 bool SetModifyPasswordInfo( const css::uno::Sequence
< css::beans::PropertyValue
>& aInfo
);
447 static ErrCode
HandleFilter( SfxMedium
* pMedium
, SfxObjectShell
const * pDoc
);
449 virtual bool PrepareClose(bool bUI
= true);
450 virtual HiddenInformation
GetHiddenInformationState( HiddenInformation nStates
);
451 void QueryHiddenInformation( HiddenWarningFact eFact
);
452 bool IsSecurityOptOpenReadOnly() const;
453 void SetSecurityOptOpenReadOnly( bool bOpenReadOnly
);
455 Size
GetFirstPageSize() const;
457 std::shared_ptr
<GDIMetaFile
> GetPreviewMetaFile( bool bFullContent
= false ) const;
458 BitmapEx
GetPreviewBitmap() const;
459 virtual void CancelTransfers();
461 bool GenerateAndStoreThumbnail(
463 const css::uno::Reference
< css::embed::XStorage
>& xStor
);
467 const css::uno::Reference
< css::io::XStream
>& xStream
);
469 bool IsInGenerateAndStoreThumbnail() const {return bIsInGenerateThumbnail
;}//optimize thumbnail generate and store procedure to improve odt saving performance, i120030
471 /// Don't add to the recent documents - it's an expensive operation, sometimes it is not wanted.
472 bool IsAvoidRecentDocs() const { return mbAvoidRecentDocs
; }
474 bool IsRememberingSignature() const { return bRememberSignature
; }
476 /// Don't add to the recent documents - it's an expensive operation, sometimes it is not wanted.
477 void AvoidRecentDocs(bool bAvoid
) { mbAvoidRecentDocs
= bAvoid
; }
479 /// On first error ask user if import should continue; return saved answer.
480 bool IsContinueImportOnFilterExceptions();
483 bool IsAbortingImport() const;
484 void FinishedLoading( SfxLoadedFlags nWhich
= SfxLoadedFlags::ALL
);
486 void TemplateDisconnectionAfterLoad();
487 void SetLoading(SfxLoadedFlags nFlags
);
488 bool IsLoading() const;
489 bool IsLoadingFinished() const;
490 void SetAutoLoad( const INetURLObject
&, sal_uInt32 nTime
, bool bReload
);
491 bool IsAutoLoadLocked() const;
494 bool IsPreview() const;
495 SfxObjectCreateMode
GetCreateMode() const { return eCreateMode
; }
496 SfxProgress
* GetProgress() const;
497 void SetWaitCursor( bool bSet
) const;
500 void SetTitle( const OUString
& rTitle
);
501 /* Small non-zero values of nMaxLen don't mean length, but have a magic meaning:
503 the title itself, as it is
505 1 (==SFX_TITLE_FILENAME)
506 provides the logical file name without path
507 (under WNT depending on the system settings
510 2 (==SFX_TITLE_FULLNAME)
511 provides the logical file names with full path
512 (remote =>:: com:: sun:: star:: util:: URL)
514 3 (==SFX_TITLE_APINAME)
515 provides the logical filename without path
518 4 (==SFX_TITLE_DETECT)
519 provides the complete title, if not set yet
520 it will be created from DocInfo or the name of
523 5 (==SFX_TITLE_CAPTION)
524 provides the Title just like MB now in the
527 6 (==SFX_TITLE_PICKLIST)
528 returns the Title, just like MB now would
529 display it in the PickList
531 7 (==SFX_TITLE_HISTORY)
532 returns the Title just like MB now would
533 display it in the History
536 provides the 'nMaxLength' of the logical
537 file name including the path
538 (remote => css::util::URL)
540 OUString
GetTitle( sal_uInt16 nMaxLen
= 0 ) const;
541 void InvalidateName(); // Re-set to unnamed
545 bool DdeExecute( const OUString
& rCmd
);
546 virtual bool DdeGetData( const OUString
& rItem
,
547 const OUString
& rMimeType
,
548 css::uno::Any
& rValue
);
549 virtual bool DdeSetData( const OUString
& rItem
,
550 const OUString
& rMimeType
,
551 const css::uno::Any
& rValue
);
553 virtual ::sfx2::SvLinkSource
* DdeCreateLinkSource( const OUString
& rItem
);
554 virtual void ReconnectDdeLink(SfxObjectShell
& rServer
);
556 static void ReconnectDdeLinks(SfxObjectShell
& rServer
);
559 virtual SfxStyleSheetBasePool
* GetStyleSheetPool();
561 virtual void LoadStyles(SfxObjectShell
&rSource
);
563 virtual sfx2::StyleManager
* GetStyleManager();
565 // Determine the position of the "Automatic" filter in the stylist
566 void SetAutoStyleFilterIndex(sal_uInt16 nSet
);
567 sal_uInt16
GetAutoStyleFilterIndex() const;
568 bool HasBasic() const;
569 BasicManager
* GetBasicManager() const;
570 css::uno::Reference
< css::script::XLibraryContainer
>
572 css::uno::Reference
< css::script::XLibraryContainer
>
573 GetDialogContainer();
574 StarBASIC
* GetBasic() const;
576 std::optional
<NamedColor
> GetRecentColor(sal_uInt16 nSlotId
);
577 void SetRecentColor(sal_uInt16 nSlotId
, const NamedColor
& rColor
);
579 virtual std::shared_ptr
<sfx::IDocumentModelAccessor
> GetDocumentModelAccessor() const;
580 virtual std::set
<Color
> GetDocColors();
581 virtual std::shared_ptr
<model::ColorSet
> GetThemeColors();
583 // Accessibility Check
584 virtual sfx::AccessibilityIssueCollection
runAccessibilityCheck();
586 // Documents, for which to format the view size
588 virtual SfxObjectShell
* GetObjectShell() override
;
590 css::uno::Reference
< css::frame::XModel3
>
592 // Only temporarily for the applications!
593 void SetBaseModel( SfxBaseModel
* pModel
);
594 css::uno::Reference
< css::frame::XModel3
> GetBaseModel() const;
595 // Only temporarily for the applications!
597 virtual css::uno::Sequence
< OUString
> GetEventNames();
599 css::uno::Reference
<css::awt::XWindow
> GetDialogParent(SfxMedium
const* pMedium
= nullptr);
600 static SfxObjectShell
* CreateObject( const OUString
& rServiceName
, SfxObjectCreateMode
= SfxObjectCreateMode::STANDARD
);
601 static SfxObjectShell
* CreateObjectByFactoryName( const OUString
& rURL
, SfxObjectCreateMode
= SfxObjectCreateMode::STANDARD
);
602 static css::uno::Reference
< css::lang::XComponent
>
603 CreateAndLoadComponent( const SfxItemSet
& rSet
);
604 static SfxObjectShell
* GetShellFromComponent(const css::uno::Reference
< css::uno::XInterface
>& xComp
);
605 static SfxObjectShell
* GetParentShell(const css::uno::Reference
<css::uno::XInterface
>& xChild
);
606 static OUString
GetServiceNameFromFactory( const OUString
& rFact
);
607 bool IsInPlaceActive() const;
608 bool IsUIActive() const;
610 static bool CopyStoragesOfUnknownMediaType(
611 const css::uno::Reference
< css::embed::XStorage
>& xSource
,
612 const css::uno::Reference
<css::embed::XStorage
>& xTarget
,
613 const css::uno::Sequence
<OUString
>& rExceptions
= css::uno::Sequence
<OUString
>());
615 bool isEditDocLocked() const;
616 bool isContentExtractionLocked() const;
617 bool isExportLocked() const;
618 bool isPrintLocked() const;
619 bool isSaveLocked() const;
621 // The functions from SvPersist
622 void EnableSetModified( bool bEnable
= true );
623 bool IsEnableSetModified() const;
624 virtual void SetModified( bool bModified
= true );
625 bool IsModified() const;
628 * @param bChart true if the file is a chart doc and FillClass should not be called
631 const css::uno::Reference
< css::embed::XStorage
>& xStorage
,
632 sal_Int32 nVersion
, bool bTemplate
) const;
634 css::uno::Reference
< css::embed::XStorage
> const & GetStorage();
636 SvGlobalName
const & GetClassName() const;
638 // comphelper::IEmbeddedHelper
639 virtual css::uno::Reference
< css::task::XInteractionHandler
> getInteractionHandler() const override
;
640 virtual css::uno::Reference
< css::embed::XStorage
> getStorage() const override
642 return const_cast<SfxObjectShell
*>(this)->GetStorage();
644 virtual comphelper::EmbeddedObjectContainer
& getEmbeddedObjectContainer() const override
646 return GetEmbeddedObjectContainer();
648 bool isEnableSetModified() const override
650 return IsEnableSetModified();
652 virtual OUString
getDocumentBaseURL() const override
;
654 comphelper::EmbeddedObjectContainer
& GetEmbeddedObjectContainer() const;
655 void ClearEmbeddedObjects();
657 // The functions from SvEmbeddedObject
658 virtual Printer
* GetDocumentPrinter();
659 virtual OutputDevice
* GetDocumentRefDev();
660 virtual void OnDocumentPrinterChanged( Printer
* pNewPrinter
);
661 virtual tools::Rectangle
GetVisArea( sal_uInt16 nAspect
) const;
662 virtual void SetVisArea( const tools::Rectangle
& rVisArea
);
663 const tools::Rectangle
& GetVisArea() const;
664 void SetVisAreaSize( const Size
& rVisSize
);
666 MapUnit
GetMapUnit() const;
667 void SetMapUnit( MapUnit nMUnit
);
669 void FillTransferableObjectDescriptor( TransferableObjectDescriptor
& rDesc
) const;
670 void DoDraw( OutputDevice
*, const Point
& rObjPos
,
672 const JobSetup
& rSetup
,
673 sal_uInt16 nAspect
= ASPECT_CONTENT
,
674 bool bOutputForScreen
= false );
675 virtual void Draw( OutputDevice
*, const JobSetup
& rSetup
,
676 sal_uInt16 nAspect
, bool bOutputForScreen
) = 0;
679 virtual void FillClass( SvGlobalName
* pClassName
,
680 SotClipboardFormatId
* pFormat
,
681 OUString
* pFullTypeName
,
683 bool bTemplate
= false) const = 0;
685 // change recording and respective passwword protection for Writer and Calc
686 // slots available for Writer: FN_REDLINE_ON, FN_REDLINE_ON
687 // slots used for Calc: FID_CHG_RECORD, SID_CHG_PROTECT
688 virtual bool IsChangeRecording() const;
689 virtual bool HasChangeRecordProtection() const;
690 virtual void SetChangeRecording( bool bActivate
, bool bLockAllViews
= false );
691 virtual void SetProtectionPassword( const OUString
&rPassword
);
692 virtual bool GetProtectionHash( /*out*/ css::uno::Sequence
< sal_Int8
> &rPasswordHash
);
694 static bool IsOwnStorageFormat(const SfxMedium
&);
696 /** Append Infobar once the frame is ready.
697 Useful when you want to register an Infobar before the doc/frame is fully loaded. */
698 void AppendInfoBarWhenReady(const OUString
& sId
, const OUString
& sPrimaryMessage
,
699 const OUString
& sSecondaryMessage
, InfobarType aInfobarType
,
700 bool bShowCloseButton
= true);
701 std::vector
<InfobarData
>& getPendingInfobars();
703 // Destruction of storages and streams
704 void InternalCloseAndRemoveFiles();
706 SAL_DLLPRIVATE
bool CreatePreview_Impl(bool bFullContent
, VirtualDevice
* pDevice
, GDIMetaFile
* pFile
) const;
708 SAL_DLLPRIVATE
static bool IsPackageStorageFormat_Impl(const SfxMedium
&);
710 SAL_DLLPRIVATE
bool ConnectTmpStorage_Impl( const css::uno::Reference
< css::embed::XStorage
>& xStorage
, SfxMedium
* pMedium
);
711 SAL_DLLPRIVATE
bool DisconnectStorage_Impl( SfxMedium
& rSrcMedium
, SfxMedium
& rTargetMedium
);
713 SAL_DLLPRIVATE
bool PutURLContentsToVersionStream_Impl(
714 const OUString
& aURL
,
715 const css::uno::Reference
< css::embed::XStorage
>& xDocStorage
,
716 const OUString
& aStreamName
);
718 SAL_DLLPRIVATE OUString
CreateTempCopyOfStorage_Impl(
719 const css::uno::Reference
< css::embed::XStorage
>& xStorage
);
721 SAL_DLLPRIVATE
void InitOwnModel_Impl();
722 SAL_DLLPRIVATE
void BreakMacroSign_Impl( bool bBreakMacroSing
);
723 SAL_DLLPRIVATE
void CheckSecurityOnLoading_Impl();
724 SAL_DLLPRIVATE
void CheckForBrokenDocSignatures_Impl();
725 SAL_DLLPRIVATE
void CheckEncryption_Impl( const css::uno::Reference
< css::task::XInteractionHandler
>& xHandler
);
726 SAL_DLLPRIVATE
void SetModifyPasswordEntered( bool bEntered
= true );
727 SAL_DLLPRIVATE
bool IsModifyPasswordEntered() const;
729 SAL_DLLPRIVATE
void InitBasicManager_Impl();
730 SAL_DLLPRIVATE SfxObjectShell_Impl
* Get_Impl() { return pImpl
.get(); }
732 SAL_DLLPRIVATE
static bool UseInteractionToHandleError(
733 const css::uno::Reference
< css::task::XInteractionHandler
>& xHandler
,
734 const ErrCodeMsg
& nError
);
735 SAL_DLLPRIVATE
const SfxObjectShell_Impl
* Get_Impl() const { return pImpl
.get(); }
737 SAL_DLLPRIVATE
void SetCreateMode_Impl( SfxObjectCreateMode nMode
);
739 SAL_DLLPRIVATE
void DoDraw_Impl( OutputDevice
* pDev
,
740 const Point
& rViewPos
,
741 const Fraction
& rScaleX
,
742 const Fraction
& rScaleY
,
743 const JobSetup
& rSetup
,
745 bool bOutputForScreen
);
748 SAL_DLLPRIVATE
void ExecFile_Impl(SfxRequest
&);
749 SAL_DLLPRIVATE
void GetState_Impl(SfxItemSet
&);
750 SAL_DLLPRIVATE
void PrintExec_Impl(SfxRequest
&);
751 SAL_DLLPRIVATE
void PrintState_Impl(SfxItemSet
&);
752 SAL_DLLPRIVATE
void ExecProps_Impl(SfxRequest
&);
753 SAL_DLLPRIVATE
void StateProps_Impl(SfxItemSet
&);
754 SAL_DLLPRIVATE
void ExecView_Impl(SfxRequest
&);
755 SAL_DLLPRIVATE
static void StateView_Impl(SfxItemSet
&);
757 // Load/Save public internals
758 SAL_DLLPRIVATE
bool ImportFromGeneratedStream_Impl(
759 const css::uno::Reference
< css::io::XStream
>& xStream
,
760 const css::uno::Sequence
< css::beans::PropertyValue
>& aMediaDescr
);
761 SAL_DLLPRIVATE
void UpdateFromTemplate_Impl();
762 SAL_DLLPRIVATE
bool CanReload_Impl();
763 SAL_DLLPRIVATE
void SetNamedVisibility_Impl();
764 SAL_DLLPRIVATE
bool DoSave_Impl( const SfxItemSet
* pSet
);
765 SAL_DLLPRIVATE
bool Save_Impl( const SfxItemSet
* pSet
);
767 PreDoSaveAs_Impl(const OUString
& rFileName
, const OUString
& rFiltName
,
768 SfxItemSet
const& rItemSet
,
769 const css::uno::Sequence
<css::beans::PropertyValue
>& rArgs
);
770 SAL_DLLPRIVATE
bool APISaveAs_Impl(std::u16string_view aFileName
, SfxItemSet
& rItemSet
,
771 const css::uno::Sequence
<css::beans::PropertyValue
>& rArgs
);
773 CommonSaveAs_Impl(const INetURLObject
& aURL
, const OUString
& aFilterName
, SfxItemSet
& rItemSet
,
774 const css::uno::Sequence
<css::beans::PropertyValue
>& rArgs
);
775 SAL_DLLPRIVATE
bool GeneralInit_Impl(
776 const css::uno::Reference
< css::embed::XStorage
>& xStorage
,
777 bool bTypeMustBeSetAlready
);
778 SAL_DLLPRIVATE
void PrepareSecondTryLoad_Impl();
779 SAL_DLLPRIVATE
void SetInitialized_Impl( const bool i_fromInitNew
);
782 SAL_DLLPRIVATE IndexBitSet
& GetNoSet_Impl();
783 SAL_DLLPRIVATE
void SetProgress_Impl( SfxProgress
*pProgress
);
784 SAL_DLLPRIVATE
void PostActivateEvent_Impl( SfxViewFrame
const * );
785 SAL_DLLPRIVATE
void SetActivateEvent_Impl(SfxEventHintId
);
787 // configuration items
788 SAL_DLLPRIVATE SignatureState
ImplGetSignatureState( bool bScriptingContent
= false );
790 SAL_DLLPRIVATE
bool QuerySaveSizeExceededModules_Impl( const css::uno::Reference
< css::task::XInteractionHandler
>& xHandler
);
791 SAL_DLLPRIVATE
static bool QueryAllowExoticFormat_Impl( const css::uno::Reference
< css::task::XInteractionHandler
>& xHandler
,
792 const OUString
& rURL
,
793 const OUString
& rFilterUIName
);
795 SAL_DLLPRIVATE
void CheckOut( );
796 SAL_DLLPRIVATE
void CancelCheckOut( );
797 SAL_DLLPRIVATE
void CheckIn( );
798 SAL_DLLPRIVATE
css::uno::Sequence
< css::document::CmisVersion
> GetCmisVersions() const;
800 /** override this if you have a XmlIdRegistry. */
801 virtual const sfx2::IXmlIdRegistry
* GetXmlIdRegistry() const { return nullptr; }
803 /// Is this read-only object shell opened via .uno:SignPDF?
804 bool IsSignPDF() const;
806 /// Gets the certificate that is already picked by the user but not yet used for signing.
807 css::uno::Reference
<css::security::XCertificate
> GetSignPDFCertificate() const;
809 /// Gets grab-bagged password info to unprotect change tracking with verification
810 css::uno::Sequence
< css::beans::PropertyValue
> GetDocumentProtectionFromGrabBag() const;
812 // Lock all unlocked views, and returns a guard object which unlocks those views when destructed
813 virtual std::unique_ptr
<LockAllViewsGuard
> LockAllViews()
815 return std::make_unique
<LockAllViewsGuard
>();
820 #define SFX_GLOBAL_CLASSID \
821 0x9eaba5c3, 0xb232, 0x4309, \
822 0x84, 0x5f, 0x5f, 0x15, 0xea, 0x50, 0xd0, 0x74
824 struct ModifyBlocker_Impl
827 SfxObjectShell
* pPersist
;
830 ModifyBlocker_Impl( SfxObjectShell
* pPersistP
) : pPersist( pPersistP
)
832 bWasEnabled
= pPersistP
->IsEnableSetModified();
834 pPersistP
->EnableSetModified( false );
836 ~ModifyBlocker_Impl()
839 pPersist
->EnableSetModified( bWasEnabled
);
844 typedef tools::SvRef
<SfxObjectShell
> SfxObjectShellRef
;
846 class SfxObjectShellLock
848 SfxObjectShell
* pObj
;
850 SfxObjectShellLock() { pObj
= nullptr; }
851 inline SfxObjectShellLock( const SfxObjectShellLock
& rObj
);
852 inline SfxObjectShellLock( SfxObjectShellLock
&& rObj
) noexcept
;
853 inline SfxObjectShellLock( SfxObjectShell
* pObjP
);
855 inline ~SfxObjectShellLock();
856 inline SfxObjectShellLock
& operator = ( const SfxObjectShellLock
& rObj
);
857 inline SfxObjectShellLock
& operator = ( SfxObjectShellLock
&& rObj
);
858 inline SfxObjectShellLock
& operator = ( SfxObjectShell
* pObj
);
859 bool Is() const { return pObj
!= nullptr; }
860 SfxObjectShell
* operator & () const { return pObj
; }
861 SfxObjectShell
* operator -> () const { return pObj
; }
862 SfxObjectShell
& operator * () const { return *pObj
; }
863 operator SfxObjectShell
* () const { return pObj
; }
865 inline SfxObjectShellLock::SfxObjectShellLock( const SfxObjectShellLock
& rObj
)
869 pObj
->OwnerLock( true );
871 inline SfxObjectShellLock::SfxObjectShellLock( SfxObjectShellLock
&& rObj
) noexcept
876 inline SfxObjectShellLock::SfxObjectShellLock( SfxObjectShell
* pObjP
)
880 pObj
->OwnerLock( true );
882 inline void SfxObjectShellLock::Clear()
886 SfxObjectShell
* const pRefObj
= pObj
;
888 pRefObj
->OwnerLock( false );
891 inline SfxObjectShellLock::~SfxObjectShellLock()
894 pObj
->OwnerLock( false );
896 inline SfxObjectShellLock
& SfxObjectShellLock::operator=( const SfxObjectShellLock
& rObj
)
899 rObj
.pObj
->OwnerLock( true );
900 SfxObjectShell
* const pRefObj
= pObj
;
903 pRefObj
->OwnerLock( false );
906 inline SfxObjectShellLock
& SfxObjectShellLock::operator=( SfxObjectShellLock
&& rObj
)
909 pObj
->OwnerLock( false );
914 inline SfxObjectShellLock
& SfxObjectShellLock::operator=( SfxObjectShell
* pObjP
)
916 *this = SfxObjectShellLock( pObjP
);
920 class SFX2_DLLPUBLIC SfxObjectShellItem final
: public SfxPoolItem
922 SfxObjectShell
* pObjSh
;
925 static SfxPoolItem
* CreateDefault();
927 SfxObjectShellItem() :
931 SfxObjectShellItem( sal_uInt16 nWhichId
,
932 SfxObjectShell
*pObjShell
):
933 SfxPoolItem( nWhichId
),
937 virtual bool operator==( const SfxPoolItem
& ) const override
;
938 virtual SfxObjectShellItem
* Clone( SfxItemPool
*pPool
= nullptr ) const override
;
939 virtual bool QueryValue( css::uno::Any
& rVal
, sal_uInt8 nMemberId
= 0 ) const override
;
940 virtual bool PutValue( const css::uno::Any
& rVal
, sal_uInt8 nMemberId
) override
;
945 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */