Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / include / sfx2 / objsh.hxx
blob24b1d82862f9fc1d66587dbadb93f08122d29922
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <tools/errcode.hxx>
27 #include <com/sun/star/frame/XFrame.hpp>
28 #include <com/sun/star/uno/Reference.h>
29 #include <com/sun/star/uno/Sequence.hxx>
30 #include <com/sun/star/script/XLibraryContainer.hpp>
31 #include <com/sun/star/script/provider/XScriptProviderSupplier.hpp>
32 #include <com/sun/star/embed/XStorage.hpp>
33 #include <com/sun/star/beans/PropertyValue.hpp>
34 #include <com/sun/star/security/DocumentSignatureInformation.hpp>
35 #include <com/sun/star/security/XDocumentDigitalSignatures.hpp>
36 #include <com/sun/star/task/XInteractionHandler.hpp>
37 #include <com/sun/star/beans/XPropertySet.hpp>
38 #include <com/sun/star/document/CmisVersion.hpp>
40 #include <vcl/vclptr.hxx>
41 #include <svl/poolitem.hxx>
42 #include <vcl/bitmap.hxx>
43 #include <sot/formats.hxx>
44 #include <sot/object.hxx>
45 #include <rsc/rscsfx.hxx>
47 #include <sfx2/XmlIdRegistry.hxx>
48 #include <sfx2/shell.hxx>
49 #include <comphelper/embeddedobjectcontainer.hxx>
50 #include <com/sun/star/frame/XModel.hpp>
51 #include <memory>
52 #include <set>
53 #include <o3tl/typed_flags_set.hxx>
54 #include <functional>
56 #include <LibreOfficeKit/LibreOfficeKitTypes.h>
58 class SbxValue;
59 class SvxMacro;
60 class SbxArray;
61 class BasicManager;
62 class SfxMedium;
63 class SfxObjectFactory;
64 class SfxDocumentInfoDialog;
65 class SfxStyleSheetBasePool;
66 class INote;
67 class SfxStyleSheetPool;
68 class SfxFrame;
69 class SbMethod;
70 class StarBASIC;
71 class Printer;
72 class SvKeyValueIterator;
73 class SfxBaseModel;
74 class SfxModule;
75 class SvData;
76 class SfxProgress;
77 class GDIMetaFile;
78 class Bitmap;
79 class INetURLObject;
80 class IndexBitSet;
81 class JobSetup;
82 class Size;
83 class Point;
84 enum class SfxModelFlags;
86 // These values presumably must match exactly the corresponding
87 // css::embed::Aspects ones (in offapi/com/sun/star/embed/Aspects.idl)
88 // and the DVASPECT_* ones in the Win32 API.
90 #define ASPECT_CONTENT 1
91 #define ASPECT_THUMBNAIL 2 /* 120 * 120, 6 Colors DIB in MetaFile */
92 #define ASPECT_ICON 4
93 #define ASPECT_DOCPRINT 8
95 // must be the same as in OLE2
96 #define SVOBJ_MISCSTATUS_NOTRESIZEABLE 512
97 #define SVOBJ_MISCSTATUS_RESIZEONPRINTERCHANGE 2048
99 namespace sfx2
101 class SvLinkSource;
102 class StyleManager;
105 namespace com { namespace sun { namespace star { namespace datatransfer { class XTransferable; } } } }
107 namespace com { namespace sun { namespace star {
108 namespace document {
109 class XDocumentProperties;
111 namespace lang {
112 class XComponent;
114 namespace text {
115 class XTextRange;
117 } } }
119 enum class SfxObjectShellFlags
121 HASOPENDOC = 0x01L,
122 HASMENU = 0x04L,
123 DONTLOADFILTERS = 0x08L,
124 DONTCLOSE = 0x10L,
125 NODOCINFO = 0x20L,
126 STD_NORMAL = HASOPENDOC,
127 STD_SPECIAL = DONTLOADFILTERS,
128 UNDEFINED = 0xf000000
130 namespace o3tl
132 template<> struct typed_flags<SfxObjectShellFlags> : is_typed_flags<SfxObjectShellFlags, 0xf00003d> {};
135 #define SFX_TITLE_TITLE 0
136 #define SFX_TITLE_FILENAME 1
137 #define SFX_TITLE_FULLNAME 2
138 #define SFX_TITLE_APINAME 3
139 #define SFX_TITLE_DETECT 4
140 #define SFX_TITLE_CAPTION 5
141 #define SFX_TITLE_PICKLIST 6
142 #define SFX_TITLE_HISTORY 7
143 #define SFX_TITLE_MAXLEN 10 // this gives the limits on length
145 enum class SfxLoadedFlags
147 NONE = 0,
148 MAINDOCUMENT = 1,
149 IMAGES = 2,
150 ALL = MAINDOCUMENT | IMAGES
152 namespace o3tl
154 template<> struct typed_flags<SfxLoadedFlags> : is_typed_flags<SfxLoadedFlags, 0x03> {};
157 enum class HiddenInformation
159 NONE = 0x0000,
160 RECORDEDCHANGES = 0x0001,
161 NOTES = 0x0002,
162 DOCUMENTVERSIONS = 0x0004
164 namespace o3tl
166 template<> struct typed_flags<HiddenInformation> : is_typed_flags<HiddenInformation, 0x07> {};
169 enum class HiddenWarningFact
171 WhenSaving = 0,
172 WhenPrinting,
173 WhenSigning,
174 WhenCreatingPDF
177 enum class SfxObjectCreateMode
179 EMBEDDED,
180 STANDARD,
181 PREVIEW,
182 ORGANIZER,
183 PLUGIN,
184 INTERNAL
188 The class SfxObjectShell is the base class for SFx-objects, ie documents
189 and parts of documents that can be integrated as separate objects
190 into foreign objects.
193 class SfxToolBoxConfig;
194 struct TransferableObjectDescriptor;
195 template<class T> bool checkSfxObjectShell(const SfxObjectShell* pShell)
197 return dynamic_cast<const T*>(pShell) != nullptr;
200 class SFX2_DLLPUBLIC SfxObjectShell :
201 public SfxShell, virtual public SotObject,
202 public ::comphelper::IEmbeddedHelper, public ::sfx2::IXmlIdRegistrySupplier
204 friend struct ModifyBlocker_Impl;
205 friend class SfxObjectShellLock;
207 private:
208 struct SfxObjectShell_Impl* pImp; // internal data
210 SfxMedium * pMedium; // Description of the file for example
211 // storage that contains the object
212 SfxObjectCreateMode eCreateMode; // Purpose of the object
213 bool bHasName :1; // sal_True := existing object,
214 // sal_False := new object
215 bool bIsInGenerateThumbnail; //optimize thumbnail generate and store procedure to improve odt saving performance, i120030
216 bool mbAvoidRecentDocs; ///< Avoid adding to the recent documents list, if not necessary.
218 bool CloseInternal();
219 private:
220 SAL_DLLPRIVATE void UpdateTime_Impl(const css::uno::Reference<
221 css::document::XDocumentProperties> & i_xDocProps);
223 SAL_DLLPRIVATE bool SaveTo_Impl(SfxMedium &rMedium, const SfxItemSet* pSet );
225 protected:
226 SfxObjectShell(SfxObjectCreateMode);
227 SfxObjectShell(SfxModelFlags); // see sfxmodelfactory.hxx
228 virtual ~SfxObjectShell();
230 void ModifyChanged();
231 virtual bool Close() override;
233 /** declares the document to have capabilities to contain basic/dialog libraries
235 void SetHasNoBasic();
237 /// template method, called by FlushDocInfo; this implementation is empty
238 virtual void DoFlushDocInfo();
240 // helper method
241 void AddToRecentlyUsedList();
243 public:
244 SFX_DECL_INTERFACE(SFX_INTERFACE_SFXDOCSH)
246 private:
247 /// SfxInterface initializer.
248 static void InitInterface_Impl();
250 public:
251 static const css::uno::Sequence<sal_Int8>& getUnoTunnelId();
252 /* Stampit disable/enable cancel button for print jobs
253 default = true = enable! */
254 void Stamp_SetPrintCancelState(bool bState);
255 bool Stamp_GetPrintCancelState() const;
257 static OUString CreateShellID( const SfxObjectShell* pShell );
259 // Document-Shell Iterator
260 static SfxObjectShell* GetFirst( const std::function<bool ( const SfxObjectShell* )>& isObjectShell = nullptr,
261 bool bOnlyVisible = true );
262 static SfxObjectShell* GetNext( const SfxObjectShell& rPrev,
263 const std::function<bool ( const SfxObjectShell* )>& isObjectShell = nullptr,
264 bool bOnlyVisible = true );
265 static SfxObjectShell* Current();
266 static css::uno::Reference< css::uno::XInterface >
267 GetCurrentComponent();
268 static void SetCurrentComponent( const css::uno::Reference< css::uno::XInterface >& _rxComponent );
270 virtual void Invalidate(sal_uInt16 nId = 0) override;
272 SfxObjectShellFlags GetFlags( ) const;
274 SfxModule* GetModule() const;
276 virtual SfxObjectFactory& GetFactory() const=0;
277 SfxMedium * GetMedium() const { return pMedium; }
278 css::uno::Reference< css::document::XDocumentProperties >
279 getDocProperties();
280 void UpdateDocInfoForSave( );
281 void FlushDocInfo();
282 bool HasName() const { return bHasName; }
283 OUString GetAPIName() const;
284 void SetReadOnly();
285 bool IsReadOnly() const;
286 bool IsReadOnlyMedium() const;
287 bool IsOriginallyReadOnlyMedium() const;
288 void SetReadOnlyUI( bool bReadOnly = true );
289 bool IsReadOnlyUI() const;
290 void SetNoName();
291 bool IsInModalMode() const;
292 bool IsInPrepareClose() const;
293 bool AcceptStateUpdate() const;
294 bool IsHelpDocument() const;
296 bool IsDocShared() const;
297 OUString GetSharedFileURL() const;
298 bool SwitchToShared( bool bShared, bool bSave );
299 SAL_DLLPRIVATE void FreeSharedFile();
300 SAL_DLLPRIVATE void FreeSharedFile( const OUString& aTempFileURL );
301 SAL_DLLPRIVATE void DoNotCleanShareControlFile();
302 void SetSharedXMLFlag( bool bFlag ) const;
303 bool HasSharedXMLFlagSet() const;
305 SAL_DLLPRIVATE void SetModalMode_Impl(bool bModal=true);
306 SAL_DLLPRIVATE void SetMacroMode_Impl(bool bModal=true);
308 void ResetError();
309 sal_uInt32 GetError() const;
310 sal_uInt32 GetErrorCode() const;
311 void SetError( sal_uInt32 rErr, const OUString& aLogMessage );
313 void AddLog( const OUString& aMessage );
314 void StoreLog();
317 * Initialize bare minimum just enough for unit test runs.
319 * @return true if the initialization is successful, false otherwise.
321 void DoInitUnitTest();
322 bool DoInitNew( SfxMedium* pMedium=nullptr );
323 bool DoLoad( SfxMedium* pMedium );
324 bool DoLoadExternal( SfxMedium* pMed );
325 bool DoSave();
326 bool DoSaveAs( SfxMedium &rNewStor );
327 bool DoSaveObjectAs( SfxMedium &rNewStor, bool bCommit );
329 // TODO/LATER: currently only overridden in Calc, should be made non-virtual
330 virtual bool DoSaveCompleted( SfxMedium* pNewStor=nullptr, bool bRegisterRecent=true );
332 bool LoadOwnFormat( SfxMedium& pMedium );
333 virtual bool SaveAsOwnFormat( SfxMedium& pMedium );
334 virtual bool ConvertFrom( SfxMedium &rMedium );
335 virtual bool ConvertTo( SfxMedium &rMedium );
336 virtual bool InitNew( const css::uno::Reference< css::embed::XStorage >& xStorage );
337 virtual bool Load( SfxMedium &rMedium );
338 virtual bool LoadFrom( SfxMedium& rMedium );
339 virtual bool Save();
340 virtual bool SaveAs( SfxMedium &rMedium );
341 virtual bool SaveCompleted( const css::uno::Reference< css::embed::XStorage >& xStorage );
342 bool SwitchPersistance(
343 const css::uno::Reference< css::embed::XStorage >& xStorage );
344 virtual void UpdateLinks();
345 virtual bool LoadExternal( SfxMedium& rMedium );
347 * Called when the Options dialog is dismissed with the OK button, to
348 * handle potentially conflicting option settings.
350 virtual void CheckConfigOptions();
351 bool IsConfigOptionsChecked() const;
352 void SetConfigOptionsChecked( bool bChecked );
354 // called for a few slots like SID_SAVE[AS]DOC, SID_PRINTDOC[DIRECT], derived classes may abort the action
355 virtual bool QuerySlotExecutable( sal_uInt16 nSlotId );
357 bool SaveChildren(bool bObjectsOnly=false);
358 bool SaveAsChildren( SfxMedium &rMedium );
359 bool SwitchChildrenPersistance(
360 const css::uno::Reference< css::embed::XStorage >& xStorage,
361 bool bForceNonModified = false );
362 bool SaveCompletedChildren();
364 /** a very special case to insert at a position in Writer from UNO,
365 via OwnSubFilterService */
366 virtual bool InsertGeneratedStream(SfxMedium& rMedium,
367 css::uno::Reference<css::text::XTextRange> const& xInsertPosition);
368 virtual bool ImportFrom( SfxMedium &rMedium,
369 css::uno::Reference<css::text::XTextRange> const& xInsertPosition);
370 bool ExportTo( SfxMedium &rMedium );
372 // xmlsec05, check with SFX team
373 SignatureState GetDocumentSignatureState();
374 void SignDocumentContent();
375 SignatureState GetScriptingSignatureState();
376 void SignScriptingContent();
378 virtual VclPtr<SfxDocumentInfoDialog> CreateDocumentInfoDialog( const SfxItemSet& );
380 ErrCode CallBasic( const OUString& rMacro, const OUString& rBasicName,
381 SbxArray* pArgs = nullptr, SbxValue* pRet = nullptr );
383 ErrCode CallXScript(
384 const OUString& rScriptURL,
385 const css::uno::Sequence< css::uno::Any >& aParams,
386 css::uno::Any& aRet,
387 css::uno::Sequence< sal_Int16 >& aOutParamIndex,
388 css::uno::Sequence< css::uno::Any >& aOutParam,
389 bool bRaiseError = true,
390 const css::uno::Any* aCaller = nullptr );
392 static ErrCode CallXScript(
393 const css::uno::Reference< css::uno::XInterface >& _rxScriptContext,
394 const OUString& rScriptURL,
395 const css::uno::Sequence< css::uno::Any >& aParams,
396 css::uno::Any& aRet,
397 css::uno::Sequence< sal_Int16 >& aOutParamIndex,
398 css::uno::Sequence< css::uno::Any >& aOutParam,
399 bool bRaiseError = true,
400 const css::uno::Any* aCaller = nullptr
403 /** adjusts the internal macro mode, according to the current security settings
405 Finally, the macro mode is either NEVER_EXECUTE or ALWAYS_EXECUTE_NO_WARN.
407 @return
408 whether macros from this document should be executed
410 bool AdjustMacroMode();
412 SvKeyValueIterator* GetHeaderAttributes();
413 void ClearHeaderAttributesForSourceViewHack();
414 void SetHeaderAttributesForSourceViewHack();
416 bool IsTemplate() const;
418 bool IsQueryLoadTemplate() const;
419 bool IsUseUserData() const;
420 bool IsUseThumbnailSave() const;
421 bool IsLoadReadonly() const;
422 bool IsSaveVersionOnClose() const;
423 void SetQueryLoadTemplate( bool b );
424 void SetUseUserData( bool bNew );
425 void SetUseThumbnailSave( bool _bNew );
426 void SetLoadReadonly( bool _bReadonly );
427 void SetSaveVersionOnClose( bool bSet );
428 void ResetFromTemplate( const OUString& rTemplateName, const OUString& rFileName );
430 // TODO/LATER: the following two methods should be replaced by Get/SetModifPasswordInfo in future
431 sal_uInt32 GetModifyPasswordHash() const;
432 bool SetModifyPasswordHash( sal_uInt32 nHash );
434 const css::uno::Sequence< css::beans::PropertyValue >& GetModifyPasswordInfo() const;
435 bool SetModifyPasswordInfo( const css::uno::Sequence< css::beans::PropertyValue >& aInfo );
437 static sal_uInt32 HandleFilter( SfxMedium* pMedium, SfxObjectShell* pDoc );
439 virtual bool PrepareClose(bool bUI = true);
440 virtual bool IsInformationLost();
441 virtual HiddenInformation GetHiddenInformationState( HiddenInformation nStates );
442 sal_Int16 QueryHiddenInformation( HiddenWarningFact eFact, vcl::Window* pParent );
443 bool IsSecurityOptOpenReadOnly() const;
444 void SetSecurityOptOpenReadOnly( bool bOpenReadOnly = true );
446 virtual Size GetFirstPageSize();
447 bool DoClose();
448 virtual void PrepareReload();
449 std::shared_ptr<GDIMetaFile> GetPreviewMetaFile( bool bFullContent = false ) const;
450 virtual void CancelTransfers();
452 bool GenerateAndStoreThumbnail(
453 bool bEncrypted,
454 bool bIsTemplate,
455 const css::uno::Reference< css::embed::XStorage >& xStor );
457 bool WriteThumbnail(
458 bool bEncrypted,
459 bool bIsTemplate,
460 const css::uno::Reference< css::io::XStream >& xStream );
462 bool IsInGenerateAndStoreThumbnail() const {return bIsInGenerateThumbnail;}//optimize thumbnail generate and store procedure to improve odt saving performance, i120030
464 /// Don't add to the recent documents - it's an expensive operation, sometimes it is not wanted.
465 bool IsAvoidRecentDocs() const { return mbAvoidRecentDocs; }
467 /// Don't add to the recent documents - it's an expensive operation, sometimes it is not wanted.
468 void AvoidRecentDocs(bool bAvoid = true) { mbAvoidRecentDocs = bAvoid; }
470 // Transfer IFace
471 void AbortImport();
472 bool IsAbortingImport() const;
473 void FinishedLoading( SfxLoadedFlags nWhich = SfxLoadedFlags::ALL );
474 void TemplateDisconnectionAfterLoad();
475 bool IsLoading() const;
476 bool IsLoadingFinished() const;
477 void SetAutoLoad( const INetURLObject&, sal_uInt32 nTime, bool bReload = true );
478 bool IsAutoLoadLocked() const;
480 // Misc
481 bool IsPreview() const;
482 SfxObjectCreateMode GetCreateMode() const { return eCreateMode; }
483 SfxProgress* GetProgress() const;
484 void SetWaitCursor( bool bSet ) const;
486 // Naming Interface
487 void SetTitle( const OUString& rTitle );
488 OUString GetTitle( sal_uInt16 nMaxLen = 0 ) const;
489 void InvalidateName(); // Re-set to unnamed
491 #if defined(_WIN32)
492 // DDE-Interface
493 long DdeExecute( const OUString& rCmd );
494 virtual bool DdeGetData( const OUString& rItem,
495 const OUString& rMimeType,
496 css::uno::Any & rValue );
497 virtual bool DdeSetData( const OUString& rItem,
498 const OUString& rMimeType,
499 const css::uno::Any & rValue );
500 #endif
501 virtual ::sfx2::SvLinkSource* DdeCreateLinkSource( const OUString& rItem );
502 virtual void ReconnectDdeLink(SfxObjectShell& rServer);
504 static void ReconnectDdeLinks(SfxObjectShell& rServer);
506 // Contents
507 virtual SfxStyleSheetBasePool* GetStyleSheetPool();
509 virtual void LoadStyles(SfxObjectShell &rSource);
511 virtual sfx2::StyleManager* GetStyleManager();
513 // Determine the position of the "Automatic" filter in the stylist
514 void SetAutoStyleFilterIndex(sal_uInt16 nSet);
515 sal_uInt16 GetAutoStyleFilterIndex();
516 bool HasBasic() const;
517 BasicManager* GetBasicManager() const;
518 css::uno::Reference< css::script::XLibraryContainer >
519 GetBasicContainer();
520 css::uno::Reference< css::script::XLibraryContainer >
521 GetDialogContainer();
522 StarBASIC* GetBasic() const;
524 virtual std::set<Color> GetDocColors();
526 // Documents, for which to format the view size
528 virtual SfxObjectShell* GetObjectShell() override;
530 css::uno::Reference< css::frame::XModel >
531 GetModel() const;
532 // Only temporarily for the applications!
533 void SetBaseModel( SfxBaseModel* pModel );
534 css::uno::Reference< css::frame::XModel > GetBaseModel() const;
535 // Only temporarily for the applications!
537 virtual css::uno::Sequence< OUString > GetEventNames();
539 vcl::Window* GetDialogParent( SfxMedium* pMedium=nullptr );
540 static SfxObjectShell* CreateObject( const OUString& rServiceName, SfxObjectCreateMode = SfxObjectCreateMode::STANDARD );
541 static SfxObjectShell* CreateObjectByFactoryName( const OUString& rURL, SfxObjectCreateMode = SfxObjectCreateMode::STANDARD );
542 static css::uno::Reference< css::lang::XComponent >
543 CreateAndLoadComponent( const SfxItemSet& rSet );
544 static SfxObjectShell* GetShellFromComponent( const css::uno::Reference< css::lang::XComponent >& xComp );
545 static OUString GetServiceNameFromFactory( const OUString& rFact );
546 bool IsInPlaceActive();
547 bool IsUIActive();
548 virtual void InPlaceActivate( bool );
550 static bool CopyStoragesOfUnknownMediaType(
551 const css::uno::Reference< css::embed::XStorage >& xSource,
552 const css::uno::Reference< css::embed::XStorage >& xTarget );
554 // The functions from SvPersist
555 void EnableSetModified( bool bEnable = true );
556 bool IsEnableSetModified() const;
557 virtual void SetModified( bool bModified = true );
558 bool IsModified();
561 * @param bChart true if the file is a chart doc and FillClass should not be called
563 void SetupStorage(
564 const css::uno::Reference< css::embed::XStorage >& xStorage,
565 sal_Int32 nVersion, bool bTemplate, bool bChart = false ) const;
567 css::uno::Reference< css::embed::XStorage > GetStorage();
569 SvGlobalName GetClassName() const;
571 // comphelper::IEmbeddedHelper
572 virtual css::uno::Reference< css::task::XInteractionHandler > getInteractionHandler() const override;
573 virtual css::uno::Reference < css::embed::XStorage > getStorage() const override
575 return const_cast<SfxObjectShell*>(this)->GetStorage();
577 virtual comphelper::EmbeddedObjectContainer& getEmbeddedObjectContainer() const override
579 return GetEmbeddedObjectContainer();
581 bool isEnableSetModified() const override
583 return IsEnableSetModified();
585 virtual OUString getDocumentBaseURL() const override;
587 comphelper::EmbeddedObjectContainer& GetEmbeddedObjectContainer() const;
588 void ClearEmbeddedObjects();
590 // The functions from SvEmbeddedObject
591 virtual Printer * GetDocumentPrinter();
592 virtual OutputDevice* GetDocumentRefDev();
593 virtual void OnDocumentPrinterChanged( Printer * pNewPrinter );
594 virtual Rectangle GetVisArea( sal_uInt16 nAspect ) const;
595 virtual void SetVisArea( const Rectangle & rVisArea );
596 const Rectangle & GetVisArea() const;
597 void SetVisAreaSize( const Size & rVisSize );
598 virtual sal_uIntPtr GetMiscStatus() const;
600 MapUnit GetMapUnit() const;
601 void SetMapUnit( MapUnit nMUnit );
603 void FillTransferableObjectDescriptor( TransferableObjectDescriptor& rDesc ) const;
604 void DoDraw( OutputDevice *, const Point & rObjPos,
605 const Size & rSize,
606 const JobSetup & rSetup,
607 sal_uInt16 nAspect = ASPECT_CONTENT );
608 virtual void Draw( OutputDevice *, const JobSetup & rSetup,
609 sal_uInt16 nAspect = ASPECT_CONTENT ) = 0;
612 virtual void FillClass( SvGlobalName * pClassName,
613 SotClipboardFormatId * pFormat,
614 OUString * pAppName,
615 OUString * pFullTypeName,
616 OUString * pShortTypeName,
617 sal_Int32 nVersion,
618 bool bTemplate = false) const = 0;
620 // change recording and respective passwword protection for Writer and Calc
621 // slots available for Writer: FN_REDLINE_ON, FN_REDLINE_ON
622 // slots used for Calc: FID_CHG_RECORD, SID_CHG_PROTECT
623 virtual bool IsChangeRecording() const;
624 virtual bool HasChangeRecordProtection() const;
625 virtual void SetChangeRecording( bool bActivate );
626 virtual void SetProtectionPassword( const OUString &rPassword );
627 virtual bool GetProtectionHash( /*out*/ css::uno::Sequence< sal_Int8 > &rPasswordHash );
629 SAL_DLLPRIVATE std::shared_ptr<GDIMetaFile> CreatePreviewMetaFile_Impl( bool bFullContent ) const;
631 SAL_DLLPRIVATE bool IsOwnStorageFormat_Impl(const SfxMedium &) const;
633 SAL_DLLPRIVATE bool IsPackageStorageFormat_Impl(const SfxMedium &) const;
635 SAL_DLLPRIVATE bool ConnectTmpStorage_Impl( const css::uno::Reference< css::embed::XStorage >& xStorage, SfxMedium* pMedium );
636 SAL_DLLPRIVATE bool DisconnectStorage_Impl( SfxMedium& rSrcMedium, SfxMedium& rTargetMedium );
638 SAL_DLLPRIVATE bool PutURLContentsToVersionStream_Impl(
639 const OUString& aURL,
640 const css::uno::Reference< css::embed::XStorage >& xDocStorage,
641 const OUString& aStreamName );
643 SAL_DLLPRIVATE OUString CreateTempCopyOfStorage_Impl(
644 const css::uno::Reference< css::embed::XStorage >& xStorage );
646 SAL_DLLPRIVATE void InitOwnModel_Impl();
647 SAL_DLLPRIVATE void BreakMacroSign_Impl( bool bBreakMacroSing );
648 SAL_DLLPRIVATE void CheckSecurityOnLoading_Impl();
649 SAL_DLLPRIVATE void CheckForBrokenDocSignatures_Impl( const css::uno::Reference< css::task::XInteractionHandler >& xHandler );
650 SAL_DLLPRIVATE SignatureState ImplCheckSignaturesInformation(
651 const css::uno::Sequence< css::security::DocumentSignatureInformation >& aInfos );
652 SAL_DLLPRIVATE void CheckEncryption_Impl( const css::uno::Reference< css::task::XInteractionHandler >& xHandler );
653 SAL_DLLPRIVATE void SetModifyPasswordEntered( bool bEntered = true );
654 SAL_DLLPRIVATE bool IsModifyPasswordEntered();
656 SAL_DLLPRIVATE void InitBasicManager_Impl();
657 SAL_DLLPRIVATE SfxObjectShell_Impl* Get_Impl() { return pImp; }
659 SAL_DLLPRIVATE static bool UseInteractionToHandleError(
660 const css::uno::Reference< css::task::XInteractionHandler >& xHandler,
661 sal_uInt32 nError );
662 SAL_DLLPRIVATE const SfxObjectShell_Impl* Get_Impl() const { return pImp; }
664 SAL_DLLPRIVATE void SetCreateMode_Impl( SfxObjectCreateMode nMode );
666 SAL_DLLPRIVATE void DoDraw_Impl( OutputDevice* pDev,
667 const Point & rViewPos,
668 const Fraction & rScaleX,
669 const Fraction & rScaleY,
670 const JobSetup & rSetup,
671 sal_uInt16 nAspect );
673 // Shell Interface
674 SAL_DLLPRIVATE void ExecFile_Impl(SfxRequest &);
675 SAL_DLLPRIVATE void GetState_Impl(SfxItemSet&);
676 SAL_DLLPRIVATE void PrintExec_Impl(SfxRequest &);
677 SAL_DLLPRIVATE void PrintState_Impl(SfxItemSet&);
678 SAL_DLLPRIVATE void ExecProps_Impl(SfxRequest &);
679 SAL_DLLPRIVATE void StateProps_Impl(SfxItemSet &);
680 SAL_DLLPRIVATE void ExecView_Impl(SfxRequest &);
681 SAL_DLLPRIVATE void StateView_Impl(SfxItemSet &);
683 // Load/Save public internals
684 SAL_DLLPRIVATE bool ImportFromGeneratedStream_Impl(
685 const css::uno::Reference< css::io::XStream >& xStream,
686 const css::uno::Sequence< css::beans::PropertyValue >& aMediaDescr );
687 SAL_DLLPRIVATE void PositionView_Impl();
688 SAL_DLLPRIVATE void UpdateFromTemplate_Impl();
689 SAL_DLLPRIVATE bool CanReload_Impl();
690 SAL_DLLPRIVATE void SetNamedVisibility_Impl();
691 SAL_DLLPRIVATE bool DoSave_Impl( const SfxItemSet* pSet=nullptr );
692 SAL_DLLPRIVATE bool Save_Impl( const SfxItemSet* pSet=nullptr );
693 SAL_DLLPRIVATE bool PreDoSaveAs_Impl(const OUString& rFileName, const OUString& rFiltName, SfxItemSet& rItemSet);
694 SAL_DLLPRIVATE bool APISaveAs_Impl(const OUString& aFileName, SfxItemSet& rItemSet);
695 SAL_DLLPRIVATE bool CommonSaveAs_Impl(const INetURLObject& aURL, const OUString& aFilterName, SfxItemSet& rItemSet);
696 SAL_DLLPRIVATE bool GeneralInit_Impl(
697 const css::uno::Reference< css::embed::XStorage >& xStorage,
698 bool bTypeMustBeSetAlready );
699 SAL_DLLPRIVATE void PrepareSecondTryLoad_Impl();
700 SAL_DLLPRIVATE void SetInitialized_Impl( const bool i_fromInitNew );
702 // public-internals
703 SAL_DLLPRIVATE IndexBitSet& GetNoSet_Impl();
704 SAL_DLLPRIVATE void SetProgress_Impl( SfxProgress *pProgress );
705 SAL_DLLPRIVATE void PostActivateEvent_Impl( SfxViewFrame* );
706 SAL_DLLPRIVATE void SetActivateEvent_Impl(sal_uInt16 );
707 SAL_DLLPRIVATE SfxObjectShell* GetParentShellByModel_Impl();
709 // configuration items
710 SAL_DLLPRIVATE SignatureState ImplGetSignatureState( bool bScriptingContent = false );
712 SAL_DLLPRIVATE css::uno::Sequence< css::security::DocumentSignatureInformation >
713 ImplAnalyzeSignature(
714 bool bScriptingContent,
715 const css::uno::Reference< css::security::XDocumentDigitalSignatures >& xSigner
716 = css::uno::Reference< css::security::XDocumentDigitalSignatures >() );
718 SAL_DLLPRIVATE void ImplSign( bool bScriptingContent = false );
719 SAL_DLLPRIVATE bool QuerySaveSizeExceededModules_Impl( const css::uno::Reference< css::task::XInteractionHandler >& xHandler );
721 SAL_DLLPRIVATE void CheckOut( );
722 SAL_DLLPRIVATE void CancelCheckOut( );
723 SAL_DLLPRIVATE void CheckIn( );
724 SAL_DLLPRIVATE css::uno::Sequence< css::document::CmisVersion > GetCmisVersions();
727 * Interface shared by document shell. Allow LOK calls from sfx.
728 * Default behavior doesn't do anything. relevant SfxObjectShells should override
729 * the default behavior and implements LOK calls.
731 virtual void libreOfficeKitCallback(int nType, const char* pPayload) const;
734 #define SFX_GLOBAL_CLASSID \
735 0x9eaba5c3, 0xb232, 0x4309, \
736 0x84, 0x5f, 0x5f, 0x15, 0xea, 0x50, 0xd0, 0x74
738 struct ModifyBlocker_Impl
740 SfxObjectShell* pPersist;
741 bool bWasEnabled;
742 ModifyBlocker_Impl( SfxObjectShell* pPersistP ) : pPersist( pPersistP )
744 bWasEnabled = pPersistP->IsEnableSetModified();
745 if ( bWasEnabled )
746 pPersistP->EnableSetModified( false );
748 ~ModifyBlocker_Impl()
750 if ( bWasEnabled )
751 pPersist->EnableSetModified( bWasEnabled );
756 typedef tools::SvRef<SfxObjectShell> SfxObjectShellRef;
758 class SfxObjectShellLock
760 protected:
761 SfxObjectShell * pObj;
762 public:
763 inline SfxObjectShellLock() { pObj = nullptr; }
764 inline SfxObjectShellLock( const SfxObjectShellLock & rObj );
765 inline SfxObjectShellLock( SfxObjectShell * pObjP );
766 inline void Clear();
767 inline ~SfxObjectShellLock();
768 inline SfxObjectShellLock & operator = ( const SfxObjectShellLock & rObj );
769 inline SfxObjectShellLock & operator = ( SfxObjectShell * pObj );
770 inline bool Is() const { return pObj != nullptr; }
771 inline SfxObjectShell * operator & () const { return pObj; }
772 inline SfxObjectShell * operator -> () const { return pObj; }
773 inline SfxObjectShell & operator * () const { return *pObj; }
774 inline operator SfxObjectShell * () const { return pObj; }
776 inline SfxObjectShellLock::SfxObjectShellLock( const SfxObjectShellLock & rObj )
777 { pObj = rObj.pObj; if( pObj ) { pObj->OwnerLock( true ); } }
778 inline SfxObjectShellLock::SfxObjectShellLock( SfxObjectShell * pObjP )
779 { pObj = pObjP; if( pObj ) { pObj->OwnerLock( true ); } }
780 inline void SfxObjectShellLock::Clear()
782 if( pObj )
784 SfxObjectShell* const pRefObj = pObj;
785 pObj = nullptr;
786 pRefObj->OwnerLock( false );
789 inline SfxObjectShellLock::~SfxObjectShellLock()
790 { if( pObj ) { pObj->OwnerLock( false ); } }
791 inline SfxObjectShellLock & SfxObjectShellLock::
792 operator = ( const SfxObjectShellLock & rObj )
794 if( rObj.pObj ) rObj.pObj->OwnerLock( true );
795 SfxObjectShell* const pRefObj = pObj;
796 pObj = rObj.pObj;
797 if( pRefObj ) { pRefObj->OwnerLock( false ); }
798 return *this;
800 inline SfxObjectShellLock & SfxObjectShellLock::operator = ( SfxObjectShell * pObjP )
801 { return *this = SfxObjectShellLock( pObjP ); }
803 class SFX2_DLLPUBLIC SfxObjectShellItem: public SfxPoolItem
805 SfxObjectShell* pObjSh;
807 public:
808 static SfxPoolItem* CreateDefault();
810 SfxObjectShellItem() :
811 SfxPoolItem( 0 ),
812 pObjSh( nullptr )
814 SfxObjectShellItem( sal_uInt16 nWhichId,
815 SfxObjectShell *pObjShell ):
816 SfxPoolItem( nWhichId ),
817 pObjSh( pObjShell )
820 virtual bool operator==( const SfxPoolItem& ) const override;
821 virtual SfxPoolItem* Clone( SfxItemPool *pPool = nullptr ) const override;
822 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
823 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
826 #endif
828 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */