19#ifndef INCLUDED_SFX2_OBJSH_HXX
20#define INCLUDED_SFX2_OBJSH_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>
81#define ASPECT_CONTENT 1
82#define ASPECT_THUMBNAIL 2
84#define ASPECT_DOCPRINT 8
108namespace sfx2 {
class IXmlIdRegistry; }
110#define SFX_TITLE_TITLE 0
111#define SFX_TITLE_FILENAME 1
112#define SFX_TITLE_FULLNAME 2
113#define SFX_TITLE_APINAME 3
114#define SFX_TITLE_DETECT 4
115#define SFX_TITLE_CAPTION 5
116#define SFX_TITLE_PICKLIST 6
117#define SFX_TITLE_HISTORY 7
118#define SFX_TITLE_MAXLEN 10
172 return dynamic_cast<const T*
>(pShell) !=
nullptr;
183 std::unique_ptr<struct SfxObjectShell_Impl>
pImpl;
194 TriState mbContinueImportOnFilterExceptions = undefined;
196 bool CloseInternal();
198 SAL_DLLPRIVATE
void UpdateTime_Impl(
const css::uno::Reference<
199 css::document::XDocumentProperties> & i_xDocProps);
209 virtual bool Close()
override;
212 virtual void DoFlushDocInfo();
215 void AddToRecentlyUsedList();
229 static void InitInterface_Impl();
232 static const css::uno::Sequence<sal_Int8>& getUnoTunnelId();
235 void Stamp_SetPrintCancelState(
bool bState);
236 bool Stamp_GetPrintCancelState()
const;
242 bool bOnlyVisible =
true );
244 const std::function<
bool (
const SfxObjectShell* )>& isObjectShell =
nullptr,
245 bool bOnlyVisible =
true );
247 static css::uno::Reference< css::uno::XInterface >
248 GetCurrentComponent();
249 static void SetCurrentComponent(
const css::uno::Reference< css::uno::XInterface >& _rxComponent );
251 virtual void Invalidate(sal_uInt16 nId = 0)
override;
257 css::uno::Reference< css::document::XDocumentProperties >
258 getDocProperties()
const;
259 void UpdateDocInfoForSave( );
262 OUString GetAPIName()
const;
265 bool IsReadOnlyMedium()
const;
266 bool IsOriginallyReadOnlyMedium()
const;
267 bool IsOriginallyLoadedReadOnlyMedium()
const;
268 void SetReadOnlyUI(
bool bReadOnly =
true );
269 bool IsReadOnlyUI()
const;
271 bool IsInModalMode()
const;
272 bool IsInPrepareClose()
const;
273 bool AcceptStateUpdate()
const;
274 bool IsHelpDocument()
const;
276 bool IsDocShared()
const;
277 OUString GetSharedFileURL()
const;
284 SAL_DLLPRIVATE
void SetModalMode_Impl(
bool bModal);
285 SAL_DLLPRIVATE
void SetMacroMode_Impl(
bool bModal=
true);
297 void DoInitUnitTest();
303 bool DoSaveObjectAs(
SfxMedium &rNewStor,
bool bCommit );
306 virtual bool DoSaveCompleted(
SfxMedium* pNewStor=
nullptr,
bool bRegisterRecent=
true );
310 bool LoadOwnFormat(
SfxMedium& pMedium );
311 virtual bool SaveAsOwnFormat(
SfxMedium& pMedium );
312 virtual bool ConvertFrom(
SfxMedium &rMedium );
313 virtual bool ConvertTo(
SfxMedium &rMedium );
314 virtual bool InitNew(
const css::uno::Reference< css::embed::XStorage >& xStorage );
316 virtual bool LoadFrom(
SfxMedium& rMedium );
319 virtual bool SaveCompleted(
const css::uno::Reference< css::embed::XStorage >& xStorage );
320 bool SwitchPersistence(
321 const css::uno::Reference< css::embed::XStorage >& xStorage );
323 virtual bool LoadExternal(
SfxMedium& rMedium );
324 bool IsConfigOptionsChecked()
const;
325 void SetConfigOptionsChecked(
bool bChecked );
328 virtual bool QuerySlotExecutable( sal_uInt16 nSlotId );
330 void SaveChildren(
bool bObjectsOnly=
false);
331 bool SaveAsChildren(
SfxMedium &rMedium );
332 bool SwitchChildrenPersistence(
333 const css::uno::Reference< css::embed::XStorage >& xStorage,
334 bool bForceNonModified =
false );
335 bool SaveCompletedChildren();
339 virtual bool InsertGeneratedStream(
SfxMedium& rMedium,
340 css::uno::Reference<css::text::XTextRange>
const& xInsertPosition);
341 virtual bool ImportFrom(
SfxMedium &rMedium,
342 css::uno::Reference<css::text::XTextRange>
const& xInsertPosition);
347 bool CheckIsReadonly(
bool bSignScriptingContent,
weld::Window* pDialogParent =
nullptr);
348 void RecheckSignature(
bool bAlsoRecheckScriptingSignature);
349 void AfterSigning(
bool bSignSuccess,
bool bSignScriptingContent);
350 bool HasValidSignatures()
const;
353 css::uno::Sequence<css::security::DocumentSignatureInformation> GetDocumentSignatureInformation(
354 bool bScriptingContent,
355 const css::uno::Reference<css::security::XDocumentDigitalSignatures>& xSigner
356 = css::uno::Reference<css::security::XDocumentDigitalSignatures>());
358 bool SignDocumentContentUsingCertificate(
const css::uno::Reference<css::security::XCertificate>& xCertificate);
360 void SignSignatureLine(
weld::Window* pDialogParent,
const OUString& aSignatureLineId,
361 const css::uno::Reference<css::security::XCertificate>& xCert,
362 const css::uno::Reference<css::graphic::XGraphic>& xValidGraphic,
363 const css::uno::Reference<css::graphic::XGraphic>& xInvalidGraphic,
364 const OUString& aComment);
369 virtual std::shared_ptr<SfxDocumentInfoDialog> CreateDocumentInfoDialog(
weld::Window* pParent,
const SfxItemSet& rItemSet);
371 ErrCode CallBasic( std::u16string_view rMacro, std::u16string_view rBasicName,
375 const OUString& rScriptURL,
376 const css::uno::Sequence< css::uno::Any >& aParams,
378 css::uno::Sequence< sal_Int16 >& aOutParamIndex,
379 css::uno::Sequence< css::uno::Any >& aOutParam,
380 bool bRaiseError =
true,
381 const css::uno::Any* aCaller =
nullptr );
384 const css::uno::Reference< css::uno::XInterface >& _rxScriptContext,
385 const OUString& rScriptURL,
386 const css::uno::Sequence< css::uno::Any >& aParams,
388 css::uno::Sequence< sal_Int16 >& aOutParamIndex,
389 css::uno::Sequence< css::uno::Any >& aOutParam,
390 bool bRaiseError =
true,
391 const css::uno::Any* aCaller =
nullptr
401 bool AdjustMacroMode();
403 static bool UnTrustedScript(
const OUString& rScriptURL);
405 static bool isScriptAccessAllowed(
const css::uno::Reference<css::uno::XInterface>& rScriptContext);
408 void ClearHeaderAttributesForSourceViewHack();
409 void SetHeaderAttributesForSourceViewHack();
411 bool IsQueryLoadTemplate()
const;
412 bool IsUseUserData()
const;
413 bool IsUseThumbnailSave()
const;
414 bool IsLoadReadonly()
const;
415 bool IsSaveVersionOnClose()
const;
416 void SetQueryLoadTemplate(
bool b );
417 void SetUseUserData(
bool bNew );
418 void SetUseThumbnailSave(
bool _bNew );
419 void SetLoadReadonly(
bool _bReadonly );
420 void SetSaveVersionOnClose(
bool bSet );
421 void ResetFromTemplate(
const OUString& rTemplateName, std::u16string_view rFileName );
424 sal_uInt32 GetModifyPasswordHash()
const;
425 bool SetModifyPasswordHash( sal_uInt32 nHash );
427 void SetMacroCallsSeenWhileLoading();
428 bool GetMacroCallsSeenWhileLoading()
const;
430 const css::uno::Sequence< css::beans::PropertyValue >& GetModifyPasswordInfo()
const;
431 bool SetModifyPasswordInfo(
const css::uno::Sequence< css::beans::PropertyValue >& aInfo );
435 virtual bool PrepareClose(
bool bUI =
true);
438 bool IsSecurityOptOpenReadOnly()
const;
439 void SetSecurityOptOpenReadOnly(
bool bOpenReadOnly );
441 Size GetFirstPageSize()
const;
443 std::shared_ptr<GDIMetaFile> GetPreviewMetaFile(
bool bFullContent =
false )
const;
445 virtual void CancelTransfers();
447 bool GenerateAndStoreThumbnail(
449 const css::uno::Reference< css::embed::XStorage >& xStor );
453 const css::uno::Reference< css::io::XStream >& xStream );
464 bool IsContinueImportOnFilterExceptions(std::u16string_view aErrMessage);
467 bool IsAbortingImport()
const;
470 void TemplateDisconnectionAfterLoad();
472 bool IsLoading()
const;
473 bool IsLoadingFinished()
const;
474 void SetAutoLoad(
const INetURLObject&, sal_uInt32 nTime,
bool bReload );
475 bool IsAutoLoadLocked()
const;
478 bool IsPreview()
const;
481 void SetWaitCursor(
bool bSet )
const;
484 void SetTitle(
const OUString& rTitle );
524 OUString
GetTitle( sal_uInt16 nMaxLen = 0 )
const;
525 void InvalidateName();
530 virtual bool DdeGetData(
const OUString& rItem,
531 const OUString& rMimeType,
532 css::uno::Any & rValue );
533 virtual bool DdeSetData(
const OUString& rItem,
534 const OUString& rMimeType,
535 const css::uno::Any & rValue );
537 virtual ::sfx2::SvLinkSource* DdeCreateLinkSource(
const OUString& rItem );
550 void SetAutoStyleFilterIndex(sal_uInt16 nSet);
551 sal_uInt16 GetAutoStyleFilterIndex()
const;
552 bool HasBasic()
const;
554 css::uno::Reference< css::script::XLibraryContainer >
556 css::uno::Reference< css::script::XLibraryContainer >
557 GetDialogContainer();
560 virtual std::set<Color> GetDocColors();
561 virtual std::vector<Color> GetThemeColors();
570 css::uno::Reference< css::frame::XModel3 >
574 css::uno::Reference< css::frame::XModel3 > GetBaseModel()
const;
577 virtual css::uno::Sequence< OUString > GetEventNames();
579 css::uno::Reference<css::awt::XWindow> GetDialogParent(
SfxMedium const* pMedium =
nullptr);
582 static css::uno::Reference< css::lang::XComponent >
584 static SfxObjectShell* GetShellFromComponent(
const css::uno::Reference< css::uno::XInterface >& xComp);
585 static SfxObjectShell* GetParentShell(
const css::uno::Reference<css::uno::XInterface>& xChild);
586 static OUString GetServiceNameFromFactory(
const OUString& rFact );
587 bool IsInPlaceActive()
const;
588 bool IsUIActive()
const;
590 static bool CopyStoragesOfUnknownMediaType(
591 const css::uno::Reference< css::embed::XStorage >& xSource,
592 const css::uno::Reference<css::embed::XStorage>& xTarget,
593 const css::uno::Sequence<OUString>& rExceptions = css::uno::Sequence<OUString>());
595 bool isEditDocLocked()
const;
596 bool isContentExtractionLocked()
const;
597 bool isExportLocked()
const;
598 bool isPrintLocked()
const;
599 bool isSaveLocked()
const;
602 void EnableSetModified(
bool bEnable =
true );
603 bool IsEnableSetModified()
const;
604 virtual void SetModified(
bool bModified =
true );
605 bool IsModified()
const;
611 const css::uno::Reference< css::embed::XStorage >& xStorage,
612 sal_Int32
nVersion,
bool bTemplate )
const;
614 css::uno::Reference< css::embed::XStorage >
const & GetStorage();
619 virtual css::uno::Reference< css::task::XInteractionHandler >
getInteractionHandler()
const override;
620 virtual css::uno::Reference < css::embed::XStorage >
getStorage()
const override
626 return GetEmbeddedObjectContainer();
630 return IsEnableSetModified();
635 void ClearEmbeddedObjects();
638 virtual Printer * GetDocumentPrinter();
640 virtual void OnDocumentPrinterChanged(
Printer * pNewPrinter );
644 void SetVisAreaSize(
const Size & rVisSize );
647 void SetMapUnit(
MapUnit nMUnit );
654 bool bOutputForScreen =
false );
656 sal_uInt16 nAspect,
bool bOutputForScreen ) = 0;
661 OUString * pFullTypeName,
663 bool bTemplate =
false)
const = 0;
668 virtual bool IsChangeRecording()
const;
669 virtual bool HasChangeRecordProtection()
const;
670 virtual void SetChangeRecording(
bool bActivate,
bool bLockAllViews =
false );
671 virtual void SetProtectionPassword(
const OUString &rPassword );
672 virtual bool GetProtectionHash( css::uno::Sequence< sal_Int8 > &rPasswordHash );
674 static bool IsOwnStorageFormat(
const SfxMedium &);
678 void AppendInfoBarWhenReady(
const OUString& sId,
const OUString& sPrimaryMessage,
679 const OUString& sSecondaryMessage,
InfobarType aInfobarType,
680 bool bShowCloseButton =
true);
681 std::vector<InfobarData>& getPendingInfobars();
685 SAL_DLLPRIVATE
static bool IsPackageStorageFormat_Impl(
const SfxMedium &);
687 SAL_DLLPRIVATE
bool ConnectTmpStorage_Impl(
const css::uno::Reference< css::embed::XStorage >& xStorage,
SfxMedium* pMedium );
688 SAL_DLLPRIVATE
bool DisconnectStorage_Impl(
SfxMedium& rSrcMedium,
SfxMedium& rTargetMedium );
690 SAL_DLLPRIVATE
bool PutURLContentsToVersionStream_Impl(
691 const OUString& aURL,
692 const css::uno::Reference< css::embed::XStorage >& xDocStorage,
693 const OUString& aStreamName );
695 SAL_DLLPRIVATE OUString CreateTempCopyOfStorage_Impl(
696 const css::uno::Reference< css::embed::XStorage >& xStorage );
698 SAL_DLLPRIVATE
void InitOwnModel_Impl();
699 SAL_DLLPRIVATE
void BreakMacroSign_Impl(
bool bBreakMacroSing );
700 SAL_DLLPRIVATE
void CheckSecurityOnLoading_Impl();
701 SAL_DLLPRIVATE
void CheckForBrokenDocSignatures_Impl();
702 SAL_DLLPRIVATE
void CheckEncryption_Impl(
const css::uno::Reference< css::task::XInteractionHandler >& xHandler );
703 SAL_DLLPRIVATE
void SetModifyPasswordEntered(
bool bEntered =
true );
704 SAL_DLLPRIVATE
bool IsModifyPasswordEntered()
const;
706 SAL_DLLPRIVATE
void InitBasicManager_Impl();
709 SAL_DLLPRIVATE
static bool UseInteractionToHandleError(
710 const css::uno::Reference< css::task::XInteractionHandler >& xHandler,
717 const Point & rViewPos,
722 bool bOutputForScreen );
725 SAL_DLLPRIVATE
void ExecFile_Impl(
SfxRequest &);
726 SAL_DLLPRIVATE
void GetState_Impl(
SfxItemSet&);
727 SAL_DLLPRIVATE
void PrintExec_Impl(
SfxRequest &);
728 SAL_DLLPRIVATE
void PrintState_Impl(
SfxItemSet&);
729 SAL_DLLPRIVATE
void ExecProps_Impl(
SfxRequest &);
730 SAL_DLLPRIVATE
void StateProps_Impl(
SfxItemSet &);
731 SAL_DLLPRIVATE
void ExecView_Impl(
SfxRequest &);
732 SAL_DLLPRIVATE
static void StateView_Impl(
SfxItemSet &);
735 SAL_DLLPRIVATE
bool ImportFromGeneratedStream_Impl(
736 const css::uno::Reference< css::io::XStream >& xStream,
737 const css::uno::Sequence< css::beans::PropertyValue >& aMediaDescr );
738 SAL_DLLPRIVATE
void UpdateFromTemplate_Impl();
739 SAL_DLLPRIVATE
bool CanReload_Impl();
740 SAL_DLLPRIVATE
void SetNamedVisibility_Impl();
741 SAL_DLLPRIVATE
bool DoSave_Impl(
const SfxItemSet* pSet );
742 SAL_DLLPRIVATE
bool Save_Impl(
const SfxItemSet* pSet );
744 PreDoSaveAs_Impl(
const OUString& rFileName,
const OUString& rFiltName,
746 const css::uno::Sequence<css::beans::PropertyValue>& rArgs);
747 SAL_DLLPRIVATE
bool APISaveAs_Impl(std::u16string_view aFileName,
SfxItemSet& rItemSet,
748 const css::uno::Sequence<css::beans::PropertyValue>& rArgs);
751 const css::uno::Sequence<css::beans::PropertyValue>& rArgs);
752 SAL_DLLPRIVATE
bool GeneralInit_Impl(
753 const css::uno::Reference< css::embed::XStorage >& xStorage,
754 bool bTypeMustBeSetAlready );
755 SAL_DLLPRIVATE
void PrepareSecondTryLoad_Impl();
756 SAL_DLLPRIVATE
void SetInitialized_Impl(
const bool i_fromInitNew );
760 SAL_DLLPRIVATE
void SetProgress_Impl(
SfxProgress *pProgress );
761 SAL_DLLPRIVATE
void PostActivateEvent_Impl(
SfxViewFrame const * );
765 SAL_DLLPRIVATE
SignatureState ImplGetSignatureState(
bool bScriptingContent =
false );
767 SAL_DLLPRIVATE
bool QuerySaveSizeExceededModules_Impl(
const css::uno::Reference< css::task::XInteractionHandler >& xHandler );
768 SAL_DLLPRIVATE
static bool QueryAllowExoticFormat_Impl(
const css::uno::Reference< css::task::XInteractionHandler >& xHandler,
769 const OUString& rURL,
770 const OUString& rFilterUIName);
772 SAL_DLLPRIVATE
void CheckOut( );
773 SAL_DLLPRIVATE
void CancelCheckOut( );
774 SAL_DLLPRIVATE
void CheckIn( );
775 SAL_DLLPRIVATE css::uno::Sequence< css::document::CmisVersion > GetCmisVersions()
const;
781 bool IsSignPDF()
const;
784 css::uno::Reference<css::security::XCertificate> GetSignPDFCertificate()
const;
787 css::uno::Sequence< css::beans::PropertyValue > GetDocumentProtectionFromGrabBag()
const;
792 return std::make_unique<LockAllViewsGuard>();
797#define SFX_GLOBAL_CLASSID \
798 0x9eaba5c3, 0xb232, 0x4309, \
799 0x84, 0x5f, 0x5f, 0x15, 0xea, 0x50, 0xd0, 0x74
836 bool Is()
const {
return pObj !=
nullptr; }
916 virtual bool QueryValue( css::uno::Any& rVal,
sal_uInt8 nMemberId = 0 )
const override;
917 virtual bool PutValue(
const css::uno::Any& rVal,
sal_uInt8 nMemberId )
override;
const sal_uInt16 nVersion
SfxObjectShellItem(sal_uInt16 nWhichId, SfxObjectShell *pObjShell)
SfxObjectShell * operator->() const
SfxObjectShellLock & operator=(const SfxObjectShellLock &rObj)
SfxObjectShell * operator&() const
SfxObjectShell & operator*() const
virtual ~LockAllViewsGuard()
bool IsInGenerateAndStoreThumbnail() const
SAL_DLLPRIVATE const SfxObjectShell_Impl * Get_Impl() const
static ErrCode CallXScript(const css::uno::Reference< css::uno::XInterface > &_rxScriptContext, const OUString &rScriptURL, const css::uno::Sequence< css::uno::Any > &aParams, css::uno::Any &aRet, css::uno::Sequence< sal_Int16 > &aOutParamIndex, css::uno::Sequence< css::uno::Any > &aOutParam, bool bRaiseError=true, const css::uno::Any *aCaller=nullptr)
virtual css::uno::Reference< css::embed::XStorage > getStorage() const override
bool IsAvoidRecentDocs() const
Don't add to the recent documents - it's an expensive operation, sometimes it is not wanted.
bool IsEnableSetModified() const
SfxObjectCreateMode eCreateMode
void SetSharedXMLFlag(bool bFlag) const
virtual SfxObjectFactory & GetFactory() const =0
virtual std::unique_ptr< LockAllViewsGuard > LockAllViews()
bool isEnableSetModified() const override
bool SwitchToShared(bool bShared, bool bSave)
virtual void Draw(OutputDevice *, const JobSetup &rSetup, sal_uInt16 nAspect, bool bOutputForScreen)=0
SAL_DLLPRIVATE void FreeSharedFile(const OUString &aTempFileURL)
SAL_DLLPRIVATE SfxObjectShell_Impl * Get_Impl()
SfxMedium * GetMedium() const
bool HasSharedXMLFlagSet() const
virtual const sfx2::IXmlIdRegistry * GetXmlIdRegistry() const
override this if you have a XmlIdRegistry.
std::unique_ptr< struct SfxObjectShell_Impl > pImpl
void EnableSetModified(bool bEnable=true)
bool mbAvoidRecentDocs
Avoid adding to the recent documents list, if not necessary.
virtual void FillClass(SvGlobalName *pClassName, SotClipboardFormatId *pFormat, OUString *pFullTypeName, sal_Int32 nVersion, bool bTemplate=false) const =0
SfxObjectCreateMode GetCreateMode() const
virtual comphelper::EmbeddedObjectContainer & getEmbeddedObjectContainer() const override
bool bIsInGenerateThumbnail
virtual void TerminateEditing()
Terminate any in-flight editing. Used before saving, primarily by Calc to commit cell changes.
void AvoidRecentDocs(bool bAvoid)
Don't add to the recent documents - it's an expensive operation, sometimes it is not wanted.
SAL_DLLPRIVATE void DoNotCleanShareControlFile()
DECL_DLLPRIVATE_LINK(SignDocumentHandler, weld::Button &, void)
The class SfxShell is the base class for all classes, which provide the functionality of the form <Sl...
virtual void Invalidate(sal_uInt16 nId=0)
With this method can the slots of the subclasses be invalidated through the slot Id or alternatively ...
virtual SfxObjectShell * GetObjectShell()
void OwnerLock(bool bLock)
virtual css::uno::Reference< css::task::XInteractionHandler > getInteractionHandler() const=0
virtual OUString getDocumentBaseURL() const=0
interface for getElementByMetadataReference; for use by sfx2::DocumentMetadataAccess
virtual void SetTitle(const OUString &rNewTitle) override
constexpr OUStringLiteral IsReadOnly(u"IsReadOnly")
Implementation of the interface com.sun.star.rdf.XDocumentMetadataAccess.
css::uno::Reference< css::animations::XAnimationNode > Clone(const css::uno::Reference< css::animations::XAnimationNode > &xSourceNode, const SdPage *pSource=nullptr, const SdPage *pTarget=nullptr)
UNOTOOLS_DLLPUBLIC bool GetTitle(OUString const &url, OUString *title)
tools::SvRef< SfxObjectShell > SfxObjectShellRef
bool checkSfxObjectShell(const SfxObjectShell *pShell)
#define SFX_DECL_INTERFACE(nId)
constexpr auto SFX_INTERFACE_SFXDOCSH
ModifyBlocker_Impl(SfxObjectShell *pPersistP)
SfxObjectShell * pPersist
#define SAL_WARN_UNUSED_RESULT
bool operator==(const XclFontData &rLeft, const XclFontData &rRight)