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 #include <unotools/ucbstreamhelper.hxx>
50 namespace weld
{class Button
; }
51 namespace model
{class ColorSet
; }
57 class SfxObjectFactory
;
58 class SfxDocumentInfoDialog
;
59 class SfxStyleSheetBasePool
;
62 class SvKeyValueIterator
;
77 enum class SfxModelFlags
;
78 enum class SfxEventHintId
;
79 enum class InfobarType
;
81 // These values presumably must match exactly the corresponding
82 // css::embed::Aspects ones (in offapi/com/sun/star/embed/Aspects.idl)
83 // and the DVASPECT_* ones in the Win32 API.
85 #define ASPECT_CONTENT 1
86 #define ASPECT_THUMBNAIL 2 /* 120 * 120, 6 Colors DIB in MetaFile */
88 #define ASPECT_DOCPRINT 8
97 namespace sfx
{ class IDocumentModelAccessor
; }
99 namespace com::sun::star::awt
{ class XWindow
; }
100 namespace com::sun::star::beans
{ struct PropertyValue
; }
101 namespace com::sun::star::document
{ struct CmisVersion
; }
102 namespace com::sun::star::document
{ class XDocumentProperties
; }
103 namespace com::sun::star::embed
{ class XStorage
; }
104 namespace com::sun::star::frame
{ class XModel
; }
105 namespace com::sun::star::graphic
{ class XGraphic
; }
106 namespace com::sun::star::io
{ class XStream
; }
107 namespace com::sun::star::script
{ class XLibraryContainer
; }
108 namespace com::sun::star::security
{ class XCertificate
; }
109 namespace com::sun::star::security
{ class XDocumentDigitalSignatures
; }
110 namespace com::sun::star::security
{ struct DocumentSignatureInformation
; }
111 namespace com::sun::star::task
{ class XInteractionHandler
; }
112 namespace com::sun::star::lang
{ class XComponent
; }
113 namespace com::sun::star::text
{ class XTextRange
; }
115 #define SFX_TITLE_TITLE 0
116 #define SFX_TITLE_FILENAME 1
117 #define SFX_TITLE_FULLNAME 2
118 #define SFX_TITLE_APINAME 3
119 #define SFX_TITLE_DETECT 4
120 #define SFX_TITLE_CAPTION 5
121 #define SFX_TITLE_PICKLIST 6
122 #define SFX_TITLE_HISTORY 7
123 #define SFX_TITLE_MAXLEN 10 // this gives the limits on length
125 enum class SfxLoadedFlags
130 ALL
= MAINDOCUMENT
| IMAGES
134 template<> struct typed_flags
<SfxLoadedFlags
> : is_typed_flags
<SfxLoadedFlags
, 0x03> {};
137 enum class HiddenInformation
140 RECORDEDCHANGES
= 0x0001,
142 DOCUMENTVERSIONS
= 0x0004
146 template<> struct typed_flags
<HiddenInformation
> : is_typed_flags
<HiddenInformation
, 0x07> {};
149 namespace weld
{ class Window
; }
151 enum class HiddenWarningFact
159 enum class SfxObjectCreateMode
168 The class SfxObjectShell is the base class for SFx-objects, ie documents
169 and parts of documents that can be integrated as separate objects
170 into foreign objects.
171 There can be multiple edit windows (SfxViewShell) for one SfxObjectShell.
174 struct TransferableObjectDescriptor
;
175 template<class T
> bool checkSfxObjectShell(const SfxObjectShell
* pShell
)
177 return dynamic_cast<const T
*>(pShell
) != nullptr;
180 class SFX2_DLLPUBLIC SfxObjectShell
:
181 public SfxShell
, public SotObject
,
182 public ::comphelper::IEmbeddedHelper
184 friend struct ModifyBlocker_Impl
;
185 friend class SfxObjectShellLock
;
188 std::unique_ptr
<struct SfxObjectShell_Impl
> pImpl
; // internal data
190 SfxMedium
* pMedium
; // Description of the file for example
191 // storage that contains the object
192 SfxObjectCreateMode eCreateMode
; // Purpose of the object
193 bool bHasName
:1; // sal_True := existing object,
194 // sal_False := new object
195 bool bIsInGenerateThumbnail
; //optimize thumbnail generate and store procedure to improve odt saving performance, i120030
196 bool mbAvoidRecentDocs
; ///< Avoid adding to the recent documents list, if not necessary.
197 bool bRememberSignature
; // Do we want to remember the signature.
199 enum TriState
{undefined
, yes
, no
};
200 TriState mbContinueImportOnFilterExceptions
= undefined
; // try to import as much as possible
202 bool CloseInternal();
204 SAL_DLLPRIVATE
void UpdateTime_Impl(const css::uno::Reference
<
205 css::document::XDocumentProperties
> & i_xDocProps
);
207 css::uno::Sequence
< css::security::DocumentSignatureInformation
> rSignatureInfosRemembered
;
209 SAL_DLLPRIVATE
bool SaveTo_Impl(SfxMedium
&rMedium
, const SfxItemSet
* pSet
);
211 // true if the document had macros (or similar) on load to trigger warning user
212 SAL_DLLPRIVATE
bool GetHadCheckedMacrosOnLoad() const;
215 SfxObjectShell(SfxObjectCreateMode
);
216 SfxObjectShell(SfxModelFlags
); // see sfxmodelfactory.hxx
217 virtual ~SfxObjectShell() override
;
219 void ModifyChanged();
220 virtual bool Close() override
;
222 /// template method, called by FlushDocInfo; this implementation is empty
223 virtual void DoFlushDocInfo();
226 void AddToRecentlyUsedList();
228 // Parent class for actual guard objects that would do useful work
229 class LockAllViewsGuard
232 virtual ~LockAllViewsGuard() {}
236 SFX_DECL_INTERFACE(SFX_INTERFACE_SFXDOCSH
)
239 /// SfxInterface initializer.
240 static void InitInterface_Impl();
243 static const css::uno::Sequence
<sal_Int8
>& getUnoTunnelId();
244 /* Stampit disable/enable cancel button for print jobs
245 default = true = enable! */
246 void Stamp_SetPrintCancelState(bool bState
);
247 bool Stamp_GetPrintCancelState() const;
249 static OUString
CreateShellID( const SfxObjectShell
* pShell
);
251 // Document-Shell Iterator
252 SAL_RET_MAYBENULL
static SfxObjectShell
* GetFirst( const std::function
<bool ( const SfxObjectShell
* )>& isObjectShell
= nullptr,
253 bool bOnlyVisible
= true );
254 SAL_RET_MAYBENULL
static SfxObjectShell
* GetNext( const SfxObjectShell
& rPrev
,
255 const std::function
<bool ( const SfxObjectShell
* )>& isObjectShell
= nullptr,
256 bool bOnlyVisible
= true );
257 SAL_RET_MAYBENULL
static SfxObjectShell
* Current();
258 static css::uno::Reference
< css::uno::XInterface
>
259 GetCurrentComponent();
260 static void SetCurrentComponent( const css::uno::Reference
< css::uno::XInterface
>& _rxComponent
);
262 virtual void Invalidate(sal_uInt16 nId
= 0) override
;
264 SfxModule
* GetModule() const;
266 virtual SfxObjectFactory
& GetFactory() const=0;
267 SfxMedium
* GetMedium() const { return pMedium
; }
268 css::uno::Reference
< css::document::XDocumentProperties
>
269 getDocProperties() const;
270 void UpdateDocInfoForSave( );
272 bool HasName() const { return bHasName
; }
273 OUString
GetAPIName() const;
275 bool IsReadOnly() const;
276 bool IsReadOnlyMedium() const;
277 bool IsOriginallyReadOnlyMedium() const;
278 bool IsOriginallyLoadedReadOnlyMedium() const;
279 void SetReadOnlyUI( bool bReadOnly
= true );
280 bool IsReadOnlyUI() const;
282 bool IsInModalMode() const;
283 bool IsInPrepareClose() const;
284 bool AcceptStateUpdate() const;
285 bool IsHelpDocument() const;
287 bool IsDocShared() const;
288 OUString
GetSharedFileURL() const;
289 bool SwitchToShared( bool bShared
, bool bSave
);
290 SAL_DLLPRIVATE
void FreeSharedFile( const OUString
& aTempFileURL
);
291 SAL_DLLPRIVATE
void DoNotCleanShareControlFile();
292 void SetSharedXMLFlag( bool bFlag
) const;
293 bool HasSharedXMLFlagSet() const;
295 SAL_DLLPRIVATE
void SetModalMode_Impl(bool bModal
);
296 SAL_DLLPRIVATE
void SetMacroMode_Impl(bool bModal
=true);
299 ErrCodeMsg
GetErrorIgnoreWarning() const;
300 ErrCodeMsg
GetErrorCode() const;
301 void SetError(const ErrCodeMsg
& rErr
);
304 * Initialize bare minimum just enough for unit test runs.
306 * @return true if the initialization is successful, false otherwise.
308 void DoInitUnitTest();
310 bool DoLoad( SfxMedium
* pMedium
);
311 bool DoLoadExternal( SfxMedium
* pMed
);
313 bool DoSaveAs( SfxMedium
&rNewStor
);
314 bool DoSaveObjectAs( SfxMedium
&rNewStor
, bool bCommit
);
316 // TODO/LATER: currently only overridden in Calc, should be made non-virtual
317 virtual bool DoSaveCompleted( SfxMedium
* pNewStor
=nullptr, bool bRegisterRecent
=true );
318 /// Terminate any in-flight editing. Used before saving, primarily by Calc to commit cell changes.
319 virtual void TerminateEditing() {}
321 bool LoadOwnFormat( SfxMedium
& pMedium
);
322 virtual bool SaveAsOwnFormat( SfxMedium
& pMedium
);
323 virtual bool ConvertFrom( SfxMedium
&rMedium
);
324 virtual bool ConvertTo( SfxMedium
&rMedium
);
325 virtual bool InitNew( const css::uno::Reference
< css::embed::XStorage
>& xStorage
);
326 virtual bool Load( SfxMedium
&rMedium
);
327 virtual bool LoadFrom( SfxMedium
& rMedium
);
329 virtual bool SaveAs( SfxMedium
&rMedium
);
330 virtual bool SaveCompleted( const css::uno::Reference
< css::embed::XStorage
>& xStorage
);
331 bool SwitchPersistence(
332 const css::uno::Reference
< css::embed::XStorage
>& xStorage
);
333 virtual void UpdateLinks();
334 virtual bool LoadExternal( SfxMedium
& rMedium
);
335 bool IsConfigOptionsChecked() const;
336 void SetConfigOptionsChecked( bool bChecked
);
338 // called for a few slots like SID_SAVE[AS]DOC, SID_PRINTDOC[DIRECT], derived classes may abort the action
339 virtual bool QuerySlotExecutable( sal_uInt16 nSlotId
);
341 void SaveChildren(bool bObjectsOnly
=false);
342 bool SaveAsChildren( SfxMedium
&rMedium
);
343 bool SwitchChildrenPersistence(
344 const css::uno::Reference
< css::embed::XStorage
>& xStorage
,
345 bool bForceNonModified
= false );
346 bool SaveCompletedChildren();
348 /** a very special case to insert at a position in Writer from UNO,
349 via OwnSubFilterService */
350 virtual bool InsertGeneratedStream(SfxMedium
& rMedium
,
351 css::uno::Reference
<css::text::XTextRange
> const& xInsertPosition
);
352 virtual bool ImportFrom( SfxMedium
&rMedium
,
353 css::uno::Reference
<css::text::XTextRange
> const& xInsertPosition
);
354 bool ExportTo( SfxMedium
&rMedium
);
356 /** Returns true if preparing was successful, else false. */
357 bool PrepareForSigning(weld::Window
* pDialogParent
);
358 bool CheckIsReadonly(bool bSignScriptingContent
, weld::Window
* pDialogParent
= nullptr);
359 void RecheckSignature(bool bAlsoRecheckScriptingSignature
);
360 void AfterSigning(bool bSignSuccess
, bool bSignScriptingContent
);
361 bool HasValidSignatures() const;
362 SignatureState
GetDocumentSignatureState();
363 bool SignDocumentContent(weld::Window
* pDialogParent
);
364 css::uno::Sequence
<css::security::DocumentSignatureInformation
> GetDocumentSignatureInformation(
365 bool bScriptingContent
,
366 const css::uno::Reference
<css::security::XDocumentDigitalSignatures
>& xSigner
367 = css::uno::Reference
<css::security::XDocumentDigitalSignatures
>());
369 bool SignDocumentContentUsingCertificate(const css::uno::Reference
<css::security::XCertificate
>& xCertificate
);
370 bool ResignDocument(css::uno::Sequence
< css::security::DocumentSignatureInformation
>& rSignaturesInfo
);
372 void SignSignatureLine(weld::Window
* pDialogParent
, const OUString
& aSignatureLineId
,
373 const css::uno::Reference
<css::security::XCertificate
>& xCert
,
374 const css::uno::Reference
<css::graphic::XGraphic
>& xValidGraphic
,
375 const css::uno::Reference
<css::graphic::XGraphic
>& xInvalidGraphic
,
376 const OUString
& aComment
);
377 SignatureState
GetScriptingSignatureState();
378 bool SignScriptingContent(weld::Window
* pDialogParent
);
379 DECL_DLLPRIVATE_LINK(SignDocumentHandler
, weld::Button
&, void);
381 virtual std::shared_ptr
<SfxDocumentInfoDialog
> CreateDocumentInfoDialog(weld::Window
* pParent
, const SfxItemSet
& rItemSet
);
383 ErrCode
CallBasic( std::u16string_view rMacro
, std::u16string_view rBasicName
,
384 SbxArray
* pArgs
, SbxValue
* pRet
= nullptr );
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 );
395 static ErrCode
CallXScript(
396 const css::uno::Reference
< css::uno::XInterface
>& _rxScriptContext
,
397 const OUString
& rScriptURL
,
398 const css::uno::Sequence
< css::uno::Any
>& aParams
,
400 css::uno::Sequence
< sal_Int16
>& aOutParamIndex
,
401 css::uno::Sequence
< css::uno::Any
>& aOutParam
,
402 bool bRaiseError
= true,
403 const css::uno::Any
* aCaller
= nullptr
406 /** adjusts the internal macro mode, according to the current security settings
408 Finally, the macro mode is either NEVER_EXECUTE or ALWAYS_EXECUTE_NO_WARN.
411 whether macros from this document should be executed
413 bool AdjustMacroMode();
415 static bool UnTrustedScript(const OUString
& rScriptURL
);
417 static bool isScriptAccessAllowed(const css::uno::Reference
<css::uno::XInterface
>& rScriptContext
);
419 SvKeyValueIterator
* GetHeaderAttributes();
420 void ClearHeaderAttributesForSourceViewHack();
421 void SetHeaderAttributesForSourceViewHack();
423 bool IsQueryLoadTemplate() const;
424 bool IsUseUserData() const;
425 bool IsUseThumbnailSave() const;
426 bool IsLoadReadonly() const;
427 bool IsSaveVersionOnClose() const;
428 void SetQueryLoadTemplate( bool b
);
429 void SetUseUserData( bool bNew
);
430 void SetUseThumbnailSave( bool _bNew
);
431 void SetLoadReadonly( bool _bReadonly
);
432 void SetSaveVersionOnClose( bool bSet
);
433 void ResetFromTemplate( const OUString
& rTemplateName
, std::u16string_view rFileName
);
435 // TODO/LATER: the following two methods should be replaced by Get/SetModifPasswordInfo in future
436 sal_uInt32
GetModifyPasswordHash() const;
437 bool SetModifyPasswordHash( sal_uInt32 nHash
);
439 void SetMacroCallsSeenWhileLoading();
440 bool GetMacroCallsSeenWhileLoading() const;
442 // true if this type of link, from a document, is allowed by the user to be passed to uno:OpenDoc
443 static bool AllowedLinkProtocolFromDocument(const OUString
& rUrl
, SfxObjectShell
* pObjShell
, weld::Window
* pDialogParent
);
445 const css::uno::Sequence
< css::beans::PropertyValue
>& GetModifyPasswordInfo() const;
446 bool SetModifyPasswordInfo( const css::uno::Sequence
< css::beans::PropertyValue
>& aInfo
);
448 static void DetectCharSet(SvStream
& stream
, rtl_TextEncoding
& eCharSet
, SvStreamEndian
& endian
);
449 static void DetectCsvSeparators(SvStream
& stream
, rtl_TextEncoding
& eCharSet
, OUString
& separators
, sal_Unicode cStringDelimiter
);
450 static void DetectCsvFilterOptions(SvStream
& stream
, OUString
& aFilterOptions
);
451 static void DetectFilterOptions(SfxMedium
* pMedium
);
452 static ErrCode
HandleFilter( SfxMedium
* pMedium
, SfxObjectShell
const * pDoc
);
454 virtual bool PrepareClose(bool bUI
= true);
455 virtual HiddenInformation
GetHiddenInformationState( HiddenInformation nStates
);
456 void QueryHiddenInformation( HiddenWarningFact eFact
);
457 bool IsSecurityOptOpenReadOnly() const;
458 void SetSecurityOptOpenReadOnly( bool bOpenReadOnly
);
460 Size
GetFirstPageSize() const;
462 std::shared_ptr
<GDIMetaFile
> GetPreviewMetaFile( bool bFullContent
= false ) const;
463 BitmapEx
GetPreviewBitmap() const;
464 virtual void CancelTransfers();
466 bool GenerateAndStoreThumbnail(
468 const css::uno::Reference
< css::embed::XStorage
>& xStor
);
472 const css::uno::Reference
< css::io::XStream
>& xStream
);
474 bool IsInGenerateAndStoreThumbnail() const {return bIsInGenerateThumbnail
;}//optimize thumbnail generate and store procedure to improve odt saving performance, i120030
476 /// Don't add to the recent documents - it's an expensive operation, sometimes it is not wanted.
477 bool IsAvoidRecentDocs() const { return mbAvoidRecentDocs
; }
479 bool IsRememberingSignature() const { return bRememberSignature
; }
481 /// Don't add to the recent documents - it's an expensive operation, sometimes it is not wanted.
482 void AvoidRecentDocs(bool bAvoid
) { mbAvoidRecentDocs
= bAvoid
; }
484 /// On first error ask user if import should continue; return saved answer.
485 bool IsContinueImportOnFilterExceptions();
488 bool IsAbortingImport() const;
489 void FinishedLoading( SfxLoadedFlags nWhich
= SfxLoadedFlags::ALL
);
491 void TemplateDisconnectionAfterLoad();
492 void SetLoading(SfxLoadedFlags nFlags
);
493 bool IsLoading() const;
494 bool IsLoadingFinished() const;
495 void SetAutoLoad( const INetURLObject
&, sal_uInt32 nTime
, bool bReload
);
496 bool IsAutoLoadLocked() const;
499 bool IsPreview() const;
500 SfxObjectCreateMode
GetCreateMode() const { return eCreateMode
; }
501 SfxProgress
* GetProgress() const;
502 void SetWaitCursor( bool bSet
) const;
505 void SetTitle( const OUString
& rTitle
);
506 /* Small non-zero values of nMaxLen don't mean length, but have a magic meaning:
508 the title itself, as it is
510 1 (==SFX_TITLE_FILENAME)
511 provides the logical file name without path
512 (under WNT depending on the system settings
515 2 (==SFX_TITLE_FULLNAME)
516 provides the logical file names with full path
517 (remote =>:: com:: sun:: star:: util:: URL)
519 3 (==SFX_TITLE_APINAME)
520 provides the logical filename without path
523 4 (==SFX_TITLE_DETECT)
524 provides the complete title, if not set yet
525 it will be created from DocInfo or the name of
528 5 (==SFX_TITLE_CAPTION)
529 provides the Title just like MB now in the
532 6 (==SFX_TITLE_PICKLIST)
533 returns the Title, just like MB now would
534 display it in the PickList
536 7 (==SFX_TITLE_HISTORY)
537 returns the Title just like MB now would
538 display it in the History
541 provides the 'nMaxLength' of the logical
542 file name including the path
543 (remote => css::util::URL)
545 OUString
GetTitle( sal_uInt16 nMaxLen
= 0 ) const;
546 void InvalidateName(); // Re-set to unnamed
550 bool DdeExecute( const OUString
& rCmd
);
551 virtual bool DdeGetData( const OUString
& rItem
,
552 const OUString
& rMimeType
,
553 css::uno::Any
& rValue
);
554 virtual bool DdeSetData( const OUString
& rItem
,
555 const OUString
& rMimeType
,
556 const css::uno::Any
& rValue
);
558 virtual ::sfx2::SvLinkSource
* DdeCreateLinkSource( const OUString
& rItem
);
559 virtual void ReconnectDdeLink(SfxObjectShell
& rServer
);
561 static void ReconnectDdeLinks(SfxObjectShell
& rServer
);
564 virtual SfxStyleSheetBasePool
* GetStyleSheetPool();
566 virtual void LoadStyles(SfxObjectShell
&rSource
);
568 virtual sfx2::StyleManager
* GetStyleManager();
570 // Determine the position of the "Automatic" filter in the stylist
571 void SetAutoStyleFilterIndex(sal_uInt16 nSet
);
572 sal_uInt16
GetAutoStyleFilterIndex() const;
573 bool HasBasic() const;
574 BasicManager
* GetBasicManager() const;
575 css::uno::Reference
< css::script::XLibraryContainer
>
577 css::uno::Reference
< css::script::XLibraryContainer
>
578 GetDialogContainer();
579 StarBASIC
* GetBasic() const;
581 std::optional
<NamedColor
> GetRecentColor(sal_uInt16 nSlotId
);
582 void SetRecentColor(sal_uInt16 nSlotId
, const NamedColor
& rColor
);
584 virtual std::shared_ptr
<sfx::IDocumentModelAccessor
> GetDocumentModelAccessor() const;
585 virtual std::set
<Color
> GetDocColors();
586 virtual std::shared_ptr
<model::ColorSet
> GetThemeColors();
588 // Accessibility Check
589 virtual sfx::AccessibilityIssueCollection
runAccessibilityCheck();
591 // Documents, for which to format the view size
593 virtual SfxObjectShell
* GetObjectShell() override
;
595 css::uno::Reference
< css::frame::XModel3
>
597 // Only temporarily for the applications!
598 void SetBaseModel( SfxBaseModel
* pModel
);
599 css::uno::Reference
< css::frame::XModel3
> GetBaseModel() const;
600 // Only temporarily for the applications!
602 virtual css::uno::Sequence
< OUString
> GetEventNames();
604 css::uno::Reference
<css::awt::XWindow
> GetDialogParent(SfxMedium
const* pMedium
= nullptr);
605 static SfxObjectShell
* CreateObject( const OUString
& rServiceName
, SfxObjectCreateMode
= SfxObjectCreateMode::STANDARD
);
606 static SfxObjectShell
* CreateObjectByFactoryName( const OUString
& rURL
, SfxObjectCreateMode
= SfxObjectCreateMode::STANDARD
);
607 static css::uno::Reference
< css::lang::XComponent
>
608 CreateAndLoadComponent( const SfxItemSet
& rSet
);
609 static SfxObjectShell
* GetShellFromComponent(const css::uno::Reference
< css::uno::XInterface
>& xComp
);
610 static SfxObjectShell
* GetParentShell(const css::uno::Reference
<css::uno::XInterface
>& xChild
);
611 static OUString
GetServiceNameFromFactory( const OUString
& rFact
);
612 bool IsInPlaceActive() const;
613 bool IsUIActive() const;
615 static bool CopyStoragesOfUnknownMediaType(
616 const css::uno::Reference
< css::embed::XStorage
>& xSource
,
617 const css::uno::Reference
<css::embed::XStorage
>& xTarget
,
618 const css::uno::Sequence
<OUString
>& rExceptions
= css::uno::Sequence
<OUString
>());
620 bool isEditDocLocked() const;
621 bool isContentExtractionLocked() const;
622 bool isExportLocked() const;
623 bool isPrintLocked() const;
624 bool isSaveLocked() const;
626 // The functions from SvPersist
627 void EnableSetModified( bool bEnable
= true );
628 bool IsEnableSetModified() const;
629 virtual void SetModified( bool bModified
= true );
630 bool IsModified() const;
633 * @param bChart true if the file is a chart doc and FillClass should not be called
636 const css::uno::Reference
< css::embed::XStorage
>& xStorage
,
637 sal_Int32 nVersion
, bool bTemplate
) const;
639 css::uno::Reference
< css::embed::XStorage
> const & GetStorage();
641 SvGlobalName
const & GetClassName() const;
643 // comphelper::IEmbeddedHelper
644 virtual css::uno::Reference
< css::task::XInteractionHandler
> getInteractionHandler() const override
;
645 virtual css::uno::Reference
< css::embed::XStorage
> getStorage() const override
647 return const_cast<SfxObjectShell
*>(this)->GetStorage();
649 virtual comphelper::EmbeddedObjectContainer
& getEmbeddedObjectContainer() const override
651 return GetEmbeddedObjectContainer();
653 bool isEnableSetModified() const override
655 return IsEnableSetModified();
657 virtual OUString
getDocumentBaseURL() const override
;
659 comphelper::EmbeddedObjectContainer
& GetEmbeddedObjectContainer() const;
660 void ClearEmbeddedObjects();
662 // The functions from SvEmbeddedObject
663 virtual Printer
* GetDocumentPrinter();
664 virtual OutputDevice
* GetDocumentRefDev();
665 virtual void OnDocumentPrinterChanged( Printer
* pNewPrinter
);
666 virtual tools::Rectangle
GetVisArea( sal_uInt16 nAspect
) const;
667 virtual void SetVisArea( const tools::Rectangle
& rVisArea
);
668 const tools::Rectangle
& GetVisArea() const;
669 void SetVisAreaSize( const Size
& rVisSize
);
671 MapUnit
GetMapUnit() const;
672 void SetMapUnit( MapUnit nMUnit
);
674 void FillTransferableObjectDescriptor( TransferableObjectDescriptor
& rDesc
) const;
675 void DoDraw( OutputDevice
*, const Point
& rObjPos
,
677 const JobSetup
& rSetup
,
678 sal_uInt16 nAspect
= ASPECT_CONTENT
,
679 bool bOutputForScreen
= false );
680 virtual void Draw( OutputDevice
*, const JobSetup
& rSetup
,
681 sal_uInt16 nAspect
, bool bOutputForScreen
) = 0;
684 virtual void FillClass( SvGlobalName
* pClassName
,
685 SotClipboardFormatId
* pFormat
,
686 OUString
* pFullTypeName
,
688 bool bTemplate
= false) const = 0;
690 // change recording and respective passwword protection for Writer and Calc
691 // slots available for Writer: FN_REDLINE_ON, FN_REDLINE_ON
692 // slots used for Calc: FID_CHG_RECORD, SID_CHG_PROTECT
693 virtual bool IsChangeRecording() const;
694 virtual bool HasChangeRecordProtection() const;
695 virtual void SetChangeRecording( bool bActivate
, bool bLockAllViews
= false );
696 virtual void SetProtectionPassword( const OUString
&rPassword
);
697 virtual bool GetProtectionHash( /*out*/ css::uno::Sequence
< sal_Int8
> &rPasswordHash
);
699 static bool IsOwnStorageFormat(const SfxMedium
&);
701 /** Append Infobar once the frame is ready.
702 Useful when you want to register an Infobar before the doc/frame is fully loaded. */
703 void AppendInfoBarWhenReady(const OUString
& sId
, const OUString
& sPrimaryMessage
,
704 const OUString
& sSecondaryMessage
, InfobarType aInfobarType
,
705 bool bShowCloseButton
= true);
706 std::vector
<InfobarData
>& getPendingInfobars();
708 SAL_DLLPRIVATE
bool CreatePreview_Impl(bool bFullContent
, VirtualDevice
* pDevice
, GDIMetaFile
* pFile
) const;
710 SAL_DLLPRIVATE
static bool IsPackageStorageFormat_Impl(const SfxMedium
&);
712 SAL_DLLPRIVATE
bool ConnectTmpStorage_Impl( const css::uno::Reference
< css::embed::XStorage
>& xStorage
, SfxMedium
* pMedium
);
713 SAL_DLLPRIVATE
bool DisconnectStorage_Impl( SfxMedium
& rSrcMedium
, SfxMedium
& rTargetMedium
);
715 SAL_DLLPRIVATE
bool PutURLContentsToVersionStream_Impl(
716 const OUString
& aURL
,
717 const css::uno::Reference
< css::embed::XStorage
>& xDocStorage
,
718 const OUString
& aStreamName
);
720 SAL_DLLPRIVATE OUString
CreateTempCopyOfStorage_Impl(
721 const css::uno::Reference
< css::embed::XStorage
>& xStorage
);
723 SAL_DLLPRIVATE
void InitOwnModel_Impl();
724 SAL_DLLPRIVATE
void BreakMacroSign_Impl( bool bBreakMacroSing
);
725 SAL_DLLPRIVATE
void CheckSecurityOnLoading_Impl();
726 SAL_DLLPRIVATE
void CheckForBrokenDocSignatures_Impl();
727 SAL_DLLPRIVATE
void CheckEncryption_Impl( const css::uno::Reference
< css::task::XInteractionHandler
>& xHandler
);
728 SAL_DLLPRIVATE
void SetModifyPasswordEntered( bool bEntered
= true );
729 SAL_DLLPRIVATE
bool IsModifyPasswordEntered() const;
731 SAL_DLLPRIVATE
void InitBasicManager_Impl();
732 SAL_DLLPRIVATE SfxObjectShell_Impl
* Get_Impl() { return pImpl
.get(); }
734 SAL_DLLPRIVATE
static bool UseInteractionToHandleError(
735 const css::uno::Reference
< css::task::XInteractionHandler
>& xHandler
,
736 const ErrCodeMsg
& nError
);
737 SAL_DLLPRIVATE
const SfxObjectShell_Impl
* Get_Impl() const { return pImpl
.get(); }
739 SAL_DLLPRIVATE
void SetCreateMode_Impl( SfxObjectCreateMode nMode
);
741 SAL_DLLPRIVATE
void DoDraw_Impl( OutputDevice
* pDev
,
742 const Point
& rViewPos
,
743 const Fraction
& rScaleX
,
744 const Fraction
& rScaleY
,
745 const JobSetup
& rSetup
,
747 bool bOutputForScreen
);
750 SAL_DLLPRIVATE
void ExecFile_Impl(SfxRequest
&);
751 SAL_DLLPRIVATE
void GetState_Impl(SfxItemSet
&);
752 SAL_DLLPRIVATE
void PrintExec_Impl(SfxRequest
&);
753 SAL_DLLPRIVATE
void PrintState_Impl(SfxItemSet
&);
754 SAL_DLLPRIVATE
void ExecProps_Impl(SfxRequest
&);
755 SAL_DLLPRIVATE
void StateProps_Impl(SfxItemSet
&);
756 SAL_DLLPRIVATE
void ExecView_Impl(SfxRequest
&);
757 SAL_DLLPRIVATE
static void StateView_Impl(SfxItemSet
&);
759 // Load/Save public internals
760 SAL_DLLPRIVATE
bool ImportFromGeneratedStream_Impl(
761 const css::uno::Reference
< css::io::XStream
>& xStream
,
762 const css::uno::Sequence
< css::beans::PropertyValue
>& aMediaDescr
);
763 SAL_DLLPRIVATE
void UpdateFromTemplate_Impl();
764 SAL_DLLPRIVATE
bool CanReload_Impl();
765 SAL_DLLPRIVATE
void SetNamedVisibility_Impl();
766 SAL_DLLPRIVATE
bool DoSave_Impl( const SfxItemSet
* pSet
);
767 SAL_DLLPRIVATE
bool Save_Impl( const SfxItemSet
* pSet
);
769 PreDoSaveAs_Impl(const OUString
& rFileName
, const OUString
& rFiltName
,
770 SfxItemSet
const& rItemSet
,
771 const css::uno::Sequence
<css::beans::PropertyValue
>& rArgs
);
772 SAL_DLLPRIVATE
bool APISaveAs_Impl(std::u16string_view aFileName
, SfxItemSet
& rItemSet
,
773 const css::uno::Sequence
<css::beans::PropertyValue
>& rArgs
);
775 CommonSaveAs_Impl(const INetURLObject
& aURL
, const OUString
& aFilterName
, SfxItemSet
& rItemSet
,
776 const css::uno::Sequence
<css::beans::PropertyValue
>& rArgs
);
777 SAL_DLLPRIVATE
bool GeneralInit_Impl(
778 const css::uno::Reference
< css::embed::XStorage
>& xStorage
,
779 bool bTypeMustBeSetAlready
);
780 SAL_DLLPRIVATE
void PrepareSecondTryLoad_Impl();
781 SAL_DLLPRIVATE
void SetInitialized_Impl( const bool i_fromInitNew
);
784 SAL_DLLPRIVATE IndexBitSet
& GetNoSet_Impl();
785 SAL_DLLPRIVATE
void SetProgress_Impl( SfxProgress
*pProgress
);
786 SAL_DLLPRIVATE
void PostActivateEvent_Impl( SfxViewFrame
const * );
787 SAL_DLLPRIVATE
void SetActivateEvent_Impl(SfxEventHintId
);
789 // configuration items
790 SAL_DLLPRIVATE SignatureState
ImplGetSignatureState( bool bScriptingContent
= false );
792 SAL_DLLPRIVATE
bool QuerySaveSizeExceededModules_Impl( const css::uno::Reference
< css::task::XInteractionHandler
>& xHandler
);
793 SAL_DLLPRIVATE
static bool QueryAllowExoticFormat_Impl( const css::uno::Reference
< css::task::XInteractionHandler
>& xHandler
,
794 const OUString
& rURL
,
795 const OUString
& rFilterUIName
);
797 SAL_DLLPRIVATE
void CheckOut( );
798 SAL_DLLPRIVATE
void CancelCheckOut( );
799 SAL_DLLPRIVATE
void CheckIn( );
800 SAL_DLLPRIVATE
css::uno::Sequence
< css::document::CmisVersion
> GetCmisVersions() const;
802 /** override this if you have a XmlIdRegistry. */
803 virtual const sfx2::IXmlIdRegistry
* GetXmlIdRegistry() const { return nullptr; }
805 /// Is this read-only object shell opened via .uno:SignPDF?
806 bool IsSignPDF() const;
808 /// Gets the certificate that is already picked by the user but not yet used for signing.
809 css::uno::Reference
<css::security::XCertificate
> GetSignPDFCertificate() const;
811 /// Gets grab-bagged password info to unprotect change tracking with verification
812 css::uno::Sequence
< css::beans::PropertyValue
> GetDocumentProtectionFromGrabBag() const;
814 // Lock all unlocked views, and returns a guard object which unlocks those views when destructed
815 virtual std::unique_ptr
<LockAllViewsGuard
> LockAllViews()
817 return std::make_unique
<LockAllViewsGuard
>();
822 #define SFX_GLOBAL_CLASSID \
823 0x9eaba5c3, 0xb232, 0x4309, \
824 0x84, 0x5f, 0x5f, 0x15, 0xea, 0x50, 0xd0, 0x74
826 struct ModifyBlocker_Impl
829 SfxObjectShell
* pPersist
;
832 ModifyBlocker_Impl( SfxObjectShell
* pPersistP
) : pPersist( pPersistP
)
834 bWasEnabled
= pPersistP
->IsEnableSetModified();
836 pPersistP
->EnableSetModified( false );
838 ~ModifyBlocker_Impl()
841 pPersist
->EnableSetModified( bWasEnabled
);
845 class SfxCloseVetoLock
848 SfxCloseVetoLock(const SfxObjectShell
& rDocShell
);
852 const SfxObjectShell
& m_rDocShell
;
855 typedef rtl::Reference
<SfxObjectShell
> SfxObjectShellRef
;
857 class SfxObjectShellLock
859 SfxObjectShell
* pObj
;
861 SfxObjectShellLock() { pObj
= nullptr; }
862 inline SfxObjectShellLock( const SfxObjectShellLock
& rObj
);
863 inline SfxObjectShellLock( SfxObjectShellLock
&& rObj
) noexcept
;
864 inline SfxObjectShellLock( SfxObjectShell
* pObjP
);
866 inline ~SfxObjectShellLock();
867 inline SfxObjectShellLock
& operator = ( const SfxObjectShellLock
& rObj
);
868 inline SfxObjectShellLock
& operator = ( SfxObjectShellLock
&& rObj
);
869 inline SfxObjectShellLock
& operator = ( SfxObjectShell
* pObj
);
870 bool Is() const { return pObj
!= nullptr; }
871 SfxObjectShell
* operator & () const { return pObj
; }
872 SfxObjectShell
* operator -> () const { return pObj
; }
873 SfxObjectShell
& operator * () const { return *pObj
; }
874 operator SfxObjectShell
* () const { return pObj
; }
876 inline SfxObjectShellLock::SfxObjectShellLock( const SfxObjectShellLock
& rObj
)
880 pObj
->OwnerLock( true );
882 inline SfxObjectShellLock::SfxObjectShellLock( SfxObjectShellLock
&& rObj
) noexcept
887 inline SfxObjectShellLock::SfxObjectShellLock( SfxObjectShell
* pObjP
)
891 pObj
->OwnerLock( true );
893 inline void SfxObjectShellLock::Clear()
897 SfxObjectShell
* const pRefObj
= pObj
;
899 pRefObj
->OwnerLock( false );
902 inline SfxObjectShellLock::~SfxObjectShellLock()
905 pObj
->OwnerLock( false );
907 inline SfxObjectShellLock
& SfxObjectShellLock::operator=( const SfxObjectShellLock
& rObj
)
910 rObj
.pObj
->OwnerLock( true );
911 SfxObjectShell
* const pRefObj
= pObj
;
914 pRefObj
->OwnerLock( false );
917 inline SfxObjectShellLock
& SfxObjectShellLock::operator=( SfxObjectShellLock
&& rObj
)
920 pObj
->OwnerLock( false );
925 inline SfxObjectShellLock
& SfxObjectShellLock::operator=( SfxObjectShell
* pObjP
)
927 *this = SfxObjectShellLock( pObjP
);
931 class SFX2_DLLPUBLIC SfxObjectShellItem final
: public SfxPoolItem
933 SfxObjectShell
* pObjSh
;
936 static SfxPoolItem
* CreateDefault();
938 SfxObjectShellItem() :
942 SfxObjectShellItem( sal_uInt16 nWhichId
,
943 SfxObjectShell
*pObjShell
):
944 SfxPoolItem( nWhichId
),
948 virtual bool operator==( const SfxPoolItem
& ) const override
;
949 virtual SfxObjectShellItem
* Clone( SfxItemPool
*pPool
= nullptr ) const override
;
950 virtual bool QueryValue( css::uno::Any
& rVal
, sal_uInt8 nMemberId
= 0 ) const override
;
951 virtual bool PutValue( const css::uno::Any
& rVal
, sal_uInt8 nMemberId
) override
;
956 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */