LibreOffice Module sfx2 (master) 1
objsh.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19#ifndef INCLUDED_SFX2_OBJSH_HXX
20#define INCLUDED_SFX2_OBJSH_HXX
21
22#include <sal/config.h>
23#include <sfx2/dllapi.h>
25#include <sal/types.h>
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>
31
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>
37
38#include <sfx2/shell.hxx>
40#include <memory>
41#include <set>
42#include <string_view>
43
45#include <functional>
47
48namespace weld {class Button; }
49class SbxValue;
50class SbxArray;
51class BasicManager;
52class SfxMedium;
56class StarBASIC;
57class Printer;
59class SfxBaseModel;
60class SfxModule;
61class SfxProgress;
62class GDIMetaFile;
63class INetURLObject;
64class IndexBitSet;
65class JobSetup;
66class OutputDevice;
67class Color;
68class Fraction;
69class SvGlobalName;
70class InfobarData;
71class VirtualDevice;
72
73enum class SfxModelFlags;
74enum class SfxEventHintId;
75enum class InfobarType;
76
77// These values presumably must match exactly the corresponding
78// css::embed::Aspects ones (in offapi/com/sun/star/embed/Aspects.idl)
79// and the DVASPECT_* ones in the Win32 API.
80
81#define ASPECT_CONTENT 1
82#define ASPECT_THUMBNAIL 2 /* 120 * 120, 6 Colors DIB in MetaFile */
83#define ASPECT_ICON 4
84#define ASPECT_DOCPRINT 8
85
86namespace sfx2
87{
88 class SvLinkSource;
89 class StyleManager;
90}
91
92namespace com::sun::star::awt { class XWindow; }
93namespace com::sun::star::beans { struct PropertyValue; }
94namespace com::sun::star::document { struct CmisVersion; }
95namespace com::sun::star::document { class XDocumentProperties; }
96namespace com::sun::star::embed { class XStorage; }
97namespace com::sun::star::frame { class XModel; }
98namespace com::sun::star::graphic { class XGraphic; }
99namespace com::sun::star::io { class XStream; }
100namespace com::sun::star::script { class XLibraryContainer; }
101namespace com::sun::star::security { class XCertificate; }
102namespace com::sun::star::security { class XDocumentDigitalSignatures; }
103namespace com::sun::star::security { struct DocumentSignatureInformation; }
104namespace com::sun::star::task { class XInteractionHandler; }
105namespace com::sun::star::lang { class XComponent; }
106namespace com::sun::star::text { class XTextRange; }
107
108namespace sfx2 { class IXmlIdRegistry; }
109
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 // this gives the limits on length
119
121{
122 NONE = 0,
123 MAINDOCUMENT = 1,
124 IMAGES = 2,
126};
127namespace o3tl
128{
129 template<> struct typed_flags<SfxLoadedFlags> : is_typed_flags<SfxLoadedFlags, 0x03> {};
130}
131
133{
134 NONE = 0x0000,
135 RECORDEDCHANGES = 0x0001,
136 NOTES = 0x0002,
137 DOCUMENTVERSIONS = 0x0004
138};
139namespace o3tl
140{
141 template<> struct typed_flags<HiddenInformation> : is_typed_flags<HiddenInformation, 0x07> {};
142}
143
144namespace weld { class Window; }
145
147{
148 WhenSaving = 0,
152};
153
155{
156 EMBEDDED,
157 STANDARD,
158 ORGANIZER,
160};
161
162/*
163 The class SfxObjectShell is the base class for SFx-objects, ie documents
164 and parts of documents that can be integrated as separate objects
165 into foreign objects.
166 There can be multiple edit windows (SfxViewShell) for one SfxObjectShell.
167*/
168
170template<class T> bool checkSfxObjectShell(const SfxObjectShell* pShell)
171{
172 return dynamic_cast<const T*>(pShell) != nullptr;
173}
174
176 public SfxShell, virtual public SotObject,
178{
179friend struct ModifyBlocker_Impl;
181
182private:
183 std::unique_ptr<struct SfxObjectShell_Impl> pImpl; // internal data
184
185 SfxMedium * pMedium; // Description of the file for example
186 // storage that contains the object
187 SfxObjectCreateMode eCreateMode; // Purpose of the object
188 bool bHasName :1; // sal_True := existing object,
189 // sal_False := new object
190 bool bIsInGenerateThumbnail; //optimize thumbnail generate and store procedure to improve odt saving performance, i120030
192
193 enum TriState {undefined, yes, no};
194 TriState mbContinueImportOnFilterExceptions = undefined; // try to import as much as possible
195
196 bool CloseInternal();
197
198 SAL_DLLPRIVATE void UpdateTime_Impl(const css::uno::Reference<
199 css::document::XDocumentProperties> & i_xDocProps);
200
201 SAL_DLLPRIVATE bool SaveTo_Impl(SfxMedium &rMedium, const SfxItemSet* pSet );
202
203protected:
205 SfxObjectShell(SfxModelFlags); // see sfxmodelfactory.hxx
206 virtual ~SfxObjectShell() override;
207
208 void ModifyChanged();
209 virtual bool Close() override;
210
212 virtual void DoFlushDocInfo();
213
214 // helper method
215 void AddToRecentlyUsedList();
216
217 // Parent class for actual guard objects that would do useful work
219 {
220 public:
222 };
223
224public:
226
227private:
229 static void InitInterface_Impl();
230
231public:
232 static const css::uno::Sequence<sal_Int8>& getUnoTunnelId();
233 /* Stampit disable/enable cancel button for print jobs
234 default = true = enable! */
235 void Stamp_SetPrintCancelState(bool bState);
236 bool Stamp_GetPrintCancelState() const;
237
238 static OUString CreateShellID( const SfxObjectShell* pShell );
239
240 // Document-Shell Iterator
241 SAL_WARN_UNUSED_RESULT static SfxObjectShell* GetFirst( const std::function<bool ( const SfxObjectShell* )>& isObjectShell = nullptr,
242 bool bOnlyVisible = true );
243 SAL_WARN_UNUSED_RESULT static SfxObjectShell* GetNext( const SfxObjectShell& rPrev,
244 const std::function<bool ( const SfxObjectShell* )>& isObjectShell = nullptr,
245 bool bOnlyVisible = true );
246 SAL_WARN_UNUSED_RESULT static SfxObjectShell* Current();
247 static css::uno::Reference< css::uno::XInterface >
248 GetCurrentComponent();
249 static void SetCurrentComponent( const css::uno::Reference< css::uno::XInterface >& _rxComponent );
250
251 virtual void Invalidate(sal_uInt16 nId = 0) override;
252
253 SfxModule* GetModule() const;
254
255 virtual SfxObjectFactory& GetFactory() const=0;
256 SfxMedium * GetMedium() const { return pMedium; }
257 css::uno::Reference< css::document::XDocumentProperties >
258 getDocProperties() const;
259 void UpdateDocInfoForSave( );
260 void FlushDocInfo();
261 bool HasName() const { return bHasName; }
262 OUString GetAPIName() const;
263 void SetReadOnly();
264 bool IsReadOnly() const;
265 bool IsReadOnlyMedium() const;
266 bool IsOriginallyReadOnlyMedium() const;
267 bool IsOriginallyLoadedReadOnlyMedium() const;
268 void SetReadOnlyUI( bool bReadOnly = true );
269 bool IsReadOnlyUI() const;
270 void SetNoName();
271 bool IsInModalMode() const;
272 bool IsInPrepareClose() const;
273 bool AcceptStateUpdate() const;
274 bool IsHelpDocument() const;
275
276 bool IsDocShared() const;
277 OUString GetSharedFileURL() const;
278 bool SwitchToShared( bool bShared, bool bSave );
279 SAL_DLLPRIVATE void FreeSharedFile( const OUString& aTempFileURL );
280 SAL_DLLPRIVATE void DoNotCleanShareControlFile();
281 void SetSharedXMLFlag( bool bFlag ) const;
283
284 SAL_DLLPRIVATE void SetModalMode_Impl(bool bModal);
285 SAL_DLLPRIVATE void SetMacroMode_Impl(bool bModal=true);
286
287 void ResetError();
288 ErrCode GetError() const;
289 ErrCode GetErrorCode() const;
290 void SetError(ErrCode rErr);
291
297 void DoInitUnitTest();
298 bool DoInitNew();
299 bool DoLoad( SfxMedium* pMedium );
300 bool DoLoadExternal( SfxMedium* pMed );
301 bool DoSave();
302 bool DoSaveAs( SfxMedium &rNewStor );
303 bool DoSaveObjectAs( SfxMedium &rNewStor, bool bCommit );
304
305 // TODO/LATER: currently only overridden in Calc, should be made non-virtual
306 virtual bool DoSaveCompleted( SfxMedium* pNewStor=nullptr, bool bRegisterRecent=true );
308 virtual void TerminateEditing() {}
309
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 );
315 virtual bool Load( SfxMedium &rMedium );
316 virtual bool LoadFrom( SfxMedium& rMedium );
317 virtual bool Save();
318 virtual bool SaveAs( 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 );
322 virtual void UpdateLinks();
323 virtual bool LoadExternal( SfxMedium& rMedium );
324 bool IsConfigOptionsChecked() const;
325 void SetConfigOptionsChecked( bool bChecked );
326
327 // called for a few slots like SID_SAVE[AS]DOC, SID_PRINTDOC[DIRECT], derived classes may abort the action
328 virtual bool QuerySlotExecutable( sal_uInt16 nSlotId );
329
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();
336
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);
343 bool ExportTo( SfxMedium &rMedium );
344
346 bool PrepareForSigning(weld::Window* pDialogParent);
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;
351 SignatureState GetDocumentSignatureState();
352 void SignDocumentContent(weld::Window* pDialogParent);
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>());
357
358 bool SignDocumentContentUsingCertificate(const css::uno::Reference<css::security::XCertificate>& xCertificate);
359
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);
365 SignatureState GetScriptingSignatureState();
366 void SignScriptingContent(weld::Window* pDialogParent);
367 DECL_DLLPRIVATE_LINK(SignDocumentHandler, weld::Button&, void);
368
369 virtual std::shared_ptr<SfxDocumentInfoDialog> CreateDocumentInfoDialog(weld::Window* pParent, const SfxItemSet& rItemSet);
370
371 ErrCode CallBasic( std::u16string_view rMacro, std::u16string_view rBasicName,
372 SbxArray* pArgs, SbxValue* pRet = nullptr );
373
374 ErrCode CallXScript(
375 const OUString& rScriptURL,
376 const css::uno::Sequence< css::uno::Any >& aParams,
377 css::uno::Any& aRet,
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 );
382
384 const css::uno::Reference< css::uno::XInterface >& _rxScriptContext,
385 const OUString& rScriptURL,
386 const css::uno::Sequence< css::uno::Any >& aParams,
387 css::uno::Any& aRet,
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
392 );
393
401 bool AdjustMacroMode();
402
403 static bool UnTrustedScript(const OUString& rScriptURL);
404
405 static bool isScriptAccessAllowed(const css::uno::Reference<css::uno::XInterface>& rScriptContext);
406
407 SvKeyValueIterator* GetHeaderAttributes();
408 void ClearHeaderAttributesForSourceViewHack();
409 void SetHeaderAttributesForSourceViewHack();
410
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 );
422
423 // TODO/LATER: the following two methods should be replaced by Get/SetModifPasswordInfo in future
424 sal_uInt32 GetModifyPasswordHash() const;
425 bool SetModifyPasswordHash( sal_uInt32 nHash );
426
427 void SetMacroCallsSeenWhileLoading();
428 bool GetMacroCallsSeenWhileLoading() const;
429
430 const css::uno::Sequence< css::beans::PropertyValue >& GetModifyPasswordInfo() const;
431 bool SetModifyPasswordInfo( const css::uno::Sequence< css::beans::PropertyValue >& aInfo );
432
433 static ErrCode HandleFilter( SfxMedium* pMedium, SfxObjectShell const * pDoc );
434
435 virtual bool PrepareClose(bool bUI = true);
436 virtual HiddenInformation GetHiddenInformationState( HiddenInformation nStates );
437 sal_Int16 QueryHiddenInformation( HiddenWarningFact eFact, weld::Window* pParent );
438 bool IsSecurityOptOpenReadOnly() const;
439 void SetSecurityOptOpenReadOnly( bool bOpenReadOnly );
440
441 Size GetFirstPageSize() const;
442 bool DoClose();
443 std::shared_ptr<GDIMetaFile> GetPreviewMetaFile( bool bFullContent = false ) const;
444 BitmapEx GetPreviewBitmap() const;
445 virtual void CancelTransfers();
446
447 bool GenerateAndStoreThumbnail(
448 bool bEncrypted,
449 const css::uno::Reference< css::embed::XStorage >& xStor );
450
451 bool WriteThumbnail(
452 bool bEncrypted,
453 const css::uno::Reference< css::io::XStream >& xStream );
454
455 bool IsInGenerateAndStoreThumbnail() const {return bIsInGenerateThumbnail;}//optimize thumbnail generate and store procedure to improve odt saving performance, i120030
456
458 bool IsAvoidRecentDocs() const { return mbAvoidRecentDocs; }
459
461 void AvoidRecentDocs(bool bAvoid) { mbAvoidRecentDocs = bAvoid; }
462
464 bool IsContinueImportOnFilterExceptions(std::u16string_view aErrMessage);
465
466 // Transfer IFace
467 bool IsAbortingImport() const;
468 void FinishedLoading( SfxLoadedFlags nWhich = SfxLoadedFlags::ALL );
469
470 void TemplateDisconnectionAfterLoad();
471 void SetLoading(SfxLoadedFlags nFlags);
472 bool IsLoading() const;
473 bool IsLoadingFinished() const;
474 void SetAutoLoad( const INetURLObject&, sal_uInt32 nTime, bool bReload );
475 bool IsAutoLoadLocked() const;
476
477 // Misc
478 bool IsPreview() const;
479 SfxObjectCreateMode GetCreateMode() const { return eCreateMode; }
480 SfxProgress* GetProgress() const;
481 void SetWaitCursor( bool bSet ) const;
482
483 // Naming Interface
484 void SetTitle( const OUString& rTitle );
485 /* Small non-zero values of nMaxLen don't mean length, but have a magic meaning:
486 0 (default)
487 the title itself, as it is
488
489 1 (==SFX_TITLE_FILENAME)
490 provides the logical file name without path
491 (under WNT depending on the system settings
492 without extension)
493
494 2 (==SFX_TITLE_FULLNAME)
495 provides the logical file names with full path
496 (remote =>:: com:: sun:: star:: util:: URL)
497
498 3 (==SFX_TITLE_APINAME)
499 provides the logical filename without path
500 and extension
501
502 4 (==SFX_TITLE_DETECT)
503 provides the complete title, if not set yet
504 it will be created from DocInfo or the name of
505 the medium.
506
507 5 (==SFX_TITLE_CAPTION)
508 provides the Title just like MB now in the
509 CaptionBar view
510
511 6 (==SFX_TITLE_PICKLIST)
512 returns the Title, just like MB now would
513 display it in the PickList
514
515 7 (==SFX_TITLE_HISTORY)
516 returns the Title just like MB now would
517 display it in the History
518
519 10 bis USHRT_MAX
520 provides the 'nMaxLength' of the logical
521 file name including the path
522 (remote => css::util::URL)
523 */
524 OUString GetTitle( sal_uInt16 nMaxLen = 0 ) const;
525 void InvalidateName(); // Re-set to unnamed
526
527#if defined(_WIN32)
528 // DDE-Interface
529 bool DdeExecute( const OUString& rCmd );
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 );
536#endif
537 virtual ::sfx2::SvLinkSource* DdeCreateLinkSource( const OUString& rItem );
538 virtual void ReconnectDdeLink(SfxObjectShell& rServer);
539
540 static void ReconnectDdeLinks(SfxObjectShell& rServer);
541
542 // Contents
543 virtual SfxStyleSheetBasePool* GetStyleSheetPool();
544
545 virtual void LoadStyles(SfxObjectShell &rSource);
546
547 virtual sfx2::StyleManager* GetStyleManager();
548
549 // Determine the position of the "Automatic" filter in the stylist
550 void SetAutoStyleFilterIndex(sal_uInt16 nSet);
551 sal_uInt16 GetAutoStyleFilterIndex() const;
552 bool HasBasic() const;
553 BasicManager* GetBasicManager() const;
554 css::uno::Reference< css::script::XLibraryContainer >
555 GetBasicContainer();
556 css::uno::Reference< css::script::XLibraryContainer >
557 GetDialogContainer();
558 StarBASIC* GetBasic() const;
559
560 virtual std::set<Color> GetDocColors();
561 virtual std::vector<Color> GetThemeColors();
562
563 // Accessibility Check
564 virtual sfx::AccessibilityIssueCollection runAccessibilityCheck();
565
566 // Documents, for which to format the view size
567
568 virtual SfxObjectShell* GetObjectShell() override;
569
570 css::uno::Reference< css::frame::XModel3 >
571 GetModel() const;
572 // Only temporarily for the applications!
573 void SetBaseModel( SfxBaseModel* pModel );
574 css::uno::Reference< css::frame::XModel3 > GetBaseModel() const;
575 // Only temporarily for the applications!
576
577 virtual css::uno::Sequence< OUString > GetEventNames();
578
579 css::uno::Reference<css::awt::XWindow> GetDialogParent(SfxMedium const* pMedium = nullptr);
580 static SfxObjectShell* CreateObject( const OUString& rServiceName, SfxObjectCreateMode = SfxObjectCreateMode::STANDARD );
581 static SfxObjectShell* CreateObjectByFactoryName( const OUString& rURL, SfxObjectCreateMode = SfxObjectCreateMode::STANDARD );
582 static css::uno::Reference< css::lang::XComponent >
583 CreateAndLoadComponent( const SfxItemSet& rSet );
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;
589
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>());
594
595 bool isEditDocLocked() const;
596 bool isContentExtractionLocked() const;
597 bool isExportLocked() const;
598 bool isPrintLocked() const;
599 bool isSaveLocked() const;
600
601 // The functions from SvPersist
602 void EnableSetModified( bool bEnable = true );
603 bool IsEnableSetModified() const;
604 virtual void SetModified( bool bModified = true );
605 bool IsModified() const;
606
610 void SetupStorage(
611 const css::uno::Reference< css::embed::XStorage >& xStorage,
612 sal_Int32 nVersion, bool bTemplate ) const;
613
614 css::uno::Reference< css::embed::XStorage > const & GetStorage();
615
616 SvGlobalName const & GetClassName() const;
617
618 // comphelper::IEmbeddedHelper
619 virtual css::uno::Reference< css::task::XInteractionHandler > getInteractionHandler() const override;
620 virtual css::uno::Reference < css::embed::XStorage > getStorage() const override
621 {
622 return const_cast<SfxObjectShell*>(this)->GetStorage();
623 }
625 {
626 return GetEmbeddedObjectContainer();
627 }
628 bool isEnableSetModified() const override
629 {
630 return IsEnableSetModified();
631 }
632 virtual OUString getDocumentBaseURL() const override;
633
634 comphelper::EmbeddedObjectContainer& GetEmbeddedObjectContainer() const;
635 void ClearEmbeddedObjects();
636
637 // The functions from SvEmbeddedObject
638 virtual Printer * GetDocumentPrinter();
639 virtual OutputDevice* GetDocumentRefDev();
640 virtual void OnDocumentPrinterChanged( Printer * pNewPrinter );
641 virtual tools::Rectangle GetVisArea( sal_uInt16 nAspect ) const;
642 virtual void SetVisArea( const tools::Rectangle & rVisArea );
643 const tools::Rectangle & GetVisArea() const;
644 void SetVisAreaSize( const Size & rVisSize );
645
646 MapUnit GetMapUnit() const;
647 void SetMapUnit( MapUnit nMUnit );
648
649 void FillTransferableObjectDescriptor( TransferableObjectDescriptor& rDesc ) const;
650 void DoDraw( OutputDevice *, const Point & rObjPos,
651 const Size & rSize,
652 const JobSetup & rSetup,
653 sal_uInt16 nAspect = ASPECT_CONTENT,
654 bool bOutputForScreen = false );
655 virtual void Draw( OutputDevice *, const JobSetup & rSetup,
656 sal_uInt16 nAspect, bool bOutputForScreen ) = 0;
657
658
659 virtual void FillClass( SvGlobalName * pClassName,
660 SotClipboardFormatId * pFormat,
661 OUString * pFullTypeName,
662 sal_Int32 nVersion,
663 bool bTemplate = false) const = 0;
664
665 // change recording and respective passwword protection for Writer and Calc
666 // slots available for Writer: FN_REDLINE_ON, FN_REDLINE_ON
667 // slots used for Calc: FID_CHG_RECORD, SID_CHG_PROTECT
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( /*out*/ css::uno::Sequence< sal_Int8 > &rPasswordHash );
673
674 static bool IsOwnStorageFormat(const SfxMedium &);
675
678 void AppendInfoBarWhenReady(const OUString& sId, const OUString& sPrimaryMessage,
679 const OUString& sSecondaryMessage, InfobarType aInfobarType,
680 bool bShowCloseButton = true);
681 std::vector<InfobarData>& getPendingInfobars();
682
683 SAL_DLLPRIVATE bool CreatePreview_Impl(bool bFullContent, VirtualDevice* pDevice, GDIMetaFile* pFile) const;
684
685 SAL_DLLPRIVATE static bool IsPackageStorageFormat_Impl(const SfxMedium &);
686
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 );
689
690 SAL_DLLPRIVATE bool PutURLContentsToVersionStream_Impl(
691 const OUString& aURL,
692 const css::uno::Reference< css::embed::XStorage >& xDocStorage,
693 const OUString& aStreamName );
694
695 SAL_DLLPRIVATE OUString CreateTempCopyOfStorage_Impl(
696 const css::uno::Reference< css::embed::XStorage >& xStorage );
697
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;
705
706 SAL_DLLPRIVATE void InitBasicManager_Impl();
707 SAL_DLLPRIVATE SfxObjectShell_Impl* Get_Impl() { return pImpl.get(); }
708
709 SAL_DLLPRIVATE static bool UseInteractionToHandleError(
710 const css::uno::Reference< css::task::XInteractionHandler >& xHandler,
711 ErrCode nError );
712 SAL_DLLPRIVATE const SfxObjectShell_Impl* Get_Impl() const { return pImpl.get(); }
713
714 SAL_DLLPRIVATE void SetCreateMode_Impl( SfxObjectCreateMode nMode );
715
716 SAL_DLLPRIVATE void DoDraw_Impl( OutputDevice* pDev,
717 const Point & rViewPos,
718 const Fraction & rScaleX,
719 const Fraction & rScaleY,
720 const JobSetup & rSetup,
721 sal_uInt16 nAspect,
722 bool bOutputForScreen );
723
724 // Shell Interface
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 &);
733
734 // Load/Save public internals
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 );
743 SAL_DLLPRIVATE bool
744 PreDoSaveAs_Impl(const OUString& rFileName, const OUString& rFiltName,
745 SfxItemSet const& rItemSet,
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);
749 SAL_DLLPRIVATE bool
750 CommonSaveAs_Impl(const INetURLObject& aURL, const OUString& aFilterName, SfxItemSet& rItemSet,
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 );
757
758 // public-internals
759 SAL_DLLPRIVATE IndexBitSet& GetNoSet_Impl();
760 SAL_DLLPRIVATE void SetProgress_Impl( SfxProgress *pProgress );
761 SAL_DLLPRIVATE void PostActivateEvent_Impl( SfxViewFrame const * );
762 SAL_DLLPRIVATE void SetActivateEvent_Impl(SfxEventHintId );
763
764 // configuration items
765 SAL_DLLPRIVATE SignatureState ImplGetSignatureState( bool bScriptingContent = false );
766
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);
771
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;
776
778 virtual const sfx2::IXmlIdRegistry* GetXmlIdRegistry() const { return nullptr; }
779
781 bool IsSignPDF() const;
782
784 css::uno::Reference<css::security::XCertificate> GetSignPDFCertificate() const;
785
787 css::uno::Sequence< css::beans::PropertyValue > GetDocumentProtectionFromGrabBag() const;
788
789 // Lock all unlocked views, and returns a guard object which unlocks those views when destructed
790 virtual std::unique_ptr<LockAllViewsGuard> LockAllViews()
791 {
792 return std::make_unique<LockAllViewsGuard>();
793 }
794
795};
796
797#define SFX_GLOBAL_CLASSID \
798 0x9eaba5c3, 0xb232, 0x4309, \
799 0x84, 0x5f, 0x5f, 0x15, 0xea, 0x50, 0xd0, 0x74
800
802 {
803 private:
806 public:
807 ModifyBlocker_Impl( SfxObjectShell* pPersistP ) : pPersist( pPersistP )
808 {
809 bWasEnabled = pPersistP->IsEnableSetModified();
810 if ( bWasEnabled )
811 pPersistP->EnableSetModified( false );
812 }
814 {
815 if ( bWasEnabled )
817 }
818 };
819
820
822
824{
826public:
827 SfxObjectShellLock() { pObj = nullptr; }
828 inline SfxObjectShellLock( const SfxObjectShellLock & rObj );
829 inline SfxObjectShellLock( SfxObjectShellLock && rObj ) noexcept;
830 inline SfxObjectShellLock( SfxObjectShell * pObjP );
831 inline void Clear();
832 inline ~SfxObjectShellLock();
833 inline SfxObjectShellLock & operator = ( const SfxObjectShellLock & rObj );
836 bool Is() const { return pObj != nullptr; }
837 SfxObjectShell * operator & () const { return pObj; }
838 SfxObjectShell * operator -> () const { return pObj; }
839 SfxObjectShell & operator * () const { return *pObj; }
840 operator SfxObjectShell * () const { return pObj; }
841};
843{
844 pObj = rObj.pObj;
845 if( pObj )
846 pObj->OwnerLock( true );
847}
849{
850 pObj = rObj.pObj;
851 rObj.pObj = nullptr;
852}
854{
855 pObj = pObjP;
856 if( pObj )
857 pObj->OwnerLock( true );
858}
860{
861 if( pObj )
862 {
863 SfxObjectShell* const pRefObj = pObj;
864 pObj = nullptr;
865 pRefObj->OwnerLock( false );
866 }
867}
869{
870 if( pObj )
871 pObj->OwnerLock( false );
872}
874{
875 if( rObj.pObj )
876 rObj.pObj->OwnerLock( true );
877 SfxObjectShell* const pRefObj = pObj;
878 pObj = rObj.pObj;
879 if( pRefObj )
880 pRefObj->OwnerLock( false );
881 return *this;
882}
884{
885 if (pObj)
886 pObj->OwnerLock( false );
887 pObj = rObj.pObj;
888 rObj.pObj = nullptr;
889 return *this;
890}
892{
893 *this = SfxObjectShellLock( pObjP );
894 return *this;
895}
896
898{
900
901public:
902 static SfxPoolItem* CreateDefault();
903
905 SfxPoolItem( 0 ),
906 pObjSh( nullptr )
907 {}
908 SfxObjectShellItem( sal_uInt16 nWhichId,
909 SfxObjectShell *pObjShell ):
910 SfxPoolItem( nWhichId ),
911 pObjSh( pObjShell )
912 {}
913
914 virtual bool operator==( const SfxPoolItem& ) const override;
915 virtual SfxObjectShellItem* Clone( SfxItemPool *pPool = nullptr ) const override;
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;
918};
919
920#endif
921
922/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const sal_uInt16 nVersion
Definition: childwin.cxx:43
SfxObjectShell * pObjSh
Definition: objsh.hxx:899
SfxObjectShellItem(sal_uInt16 nWhichId, SfxObjectShell *pObjShell)
Definition: objsh.hxx:908
SfxObjectShell * operator->() const
Definition: objsh.hxx:838
bool Is() const
Definition: objsh.hxx:836
SfxObjectShell * pObj
Definition: objsh.hxx:825
SfxObjectShellLock & operator=(const SfxObjectShellLock &rObj)
Definition: objsh.hxx:873
SfxObjectShell * operator&() const
Definition: objsh.hxx:837
SfxObjectShell & operator*() const
Definition: objsh.hxx:839
bool IsInGenerateAndStoreThumbnail() const
Definition: objsh.hxx:455
SAL_DLLPRIVATE const SfxObjectShell_Impl * Get_Impl() const
Definition: objsh.hxx:712
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
Definition: objsh.hxx:620
bool IsAvoidRecentDocs() const
Don't add to the recent documents - it's an expensive operation, sometimes it is not wanted.
Definition: objsh.hxx:458
bool HasName() const
Definition: objsh.hxx:261
bool IsEnableSetModified() const
Definition: objmisc.cxx:248
SfxObjectCreateMode eCreateMode
Definition: objsh.hxx:187
void SetSharedXMLFlag(bool bFlag) const
virtual SfxObjectFactory & GetFactory() const =0
virtual std::unique_ptr< LockAllViewsGuard > LockAllViews()
Definition: objsh.hxx:790
bool isEnableSetModified() const override
Definition: objsh.hxx:628
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)
SfxMedium * pMedium
Definition: objsh.hxx:185
SAL_DLLPRIVATE SfxObjectShell_Impl * Get_Impl()
Definition: objsh.hxx:707
SfxMedium * GetMedium() const
Definition: objsh.hxx:256
bool HasSharedXMLFlagSet() const
virtual const sfx2::IXmlIdRegistry * GetXmlIdRegistry() const
override this if you have a XmlIdRegistry.
Definition: objsh.hxx:778
std::unique_ptr< struct SfxObjectShell_Impl > pImpl
Definition: objsh.hxx:183
void EnableSetModified(bool bEnable=true)
Definition: objmisc.cxx:241
bool mbAvoidRecentDocs
Avoid adding to the recent documents list, if not necessary.
Definition: objsh.hxx:191
virtual void FillClass(SvGlobalName *pClassName, SotClipboardFormatId *pFormat, OUString *pFullTypeName, sal_Int32 nVersion, bool bTemplate=false) const =0
SfxObjectCreateMode GetCreateMode() const
Definition: objsh.hxx:479
virtual comphelper::EmbeddedObjectContainer & getEmbeddedObjectContainer() const override
Definition: objsh.hxx:624
bool bIsInGenerateThumbnail
Definition: objsh.hxx:190
virtual void TerminateEditing()
Terminate any in-flight editing. Used before saving, primarily by Calc to commit cell changes.
Definition: objsh.hxx:308
void AvoidRecentDocs(bool bAvoid)
Don't add to the recent documents - it's an expensive operation, sometimes it is not wanted.
Definition: objsh.hxx:461
SAL_DLLPRIVATE void DoNotCleanShareControlFile()
DECL_DLLPRIVATE_LINK(SignDocumentHandler, weld::Button &, void)
bool bHasName
Definition: objsh.hxx:188
The class SfxShell is the base class for all classes, which provide the functionality of the form <Sl...
Definition: shell.hxx:128
virtual void Invalidate(sal_uInt16 nId=0)
With this method can the slots of the subclasses be invalidated through the slot Id or alternatively ...
Definition: shell.cxx:235
virtual SfxObjectShell * GetObjectShell()
Definition: shell.cxx:649
void OwnerLock(bool bLock)
virtual bool Close()
bool DoClose()
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
#define SFX2_DLLPUBLIC
Definition: dllapi.h:29
SfxEventHintId
Definition: event.hxx:116
constexpr OUStringLiteral IsReadOnly(u"IsReadOnly")
SotClipboardFormatId
InfobarType
Definition: infobar.hxx:22
UpdateLinks
MapUnit
MapUnit GetMapUnit()
NONE
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)
HiddenInformation
Definition: objsh.hxx:133
#define ASPECT_CONTENT
Definition: objsh.hxx:81
SfxObjectCreateMode
Definition: objsh.hxx:155
tools::SvRef< SfxObjectShell > SfxObjectShellRef
Definition: objsh.hxx:821
bool checkSfxObjectShell(const SfxObjectShell *pShell)
Definition: objsh.hxx:170
HiddenWarningFact
Definition: objsh.hxx:147
SfxLoadedFlags
Definition: objsh.hxx:121
SfxModelFlags
static SfxItemSet & rSet
Definition: shell.cxx:534
#define SFX_DECL_INTERFACE(nId)
Definition: shell.hxx:532
constexpr auto SFX_INTERFACE_SFXDOCSH
Definition: shell.hxx:62
SignatureState
ModifyBlocker_Impl(SfxObjectShell *pPersistP)
Definition: objsh.hxx:807
SfxObjectShell * pPersist
Definition: objsh.hxx:804
unsigned char sal_uInt8
#define SAL_WARN_UNUSED_RESULT
bool operator==(const XclFontData &rLeft, const XclFontData &rRight)
int SetError()
int GetError()