LibreOffice Module sw (master)  1
docsh.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_SW_INC_DOCSH_HXX
20 #define INCLUDED_SW_INC_DOCSH_HXX
21 
22 #include <memory>
23 #include <vector>
24 #include <rtl/ref.hxx>
25 #include <com/sun/star/uno/Sequence.h>
26 #include <sfx2/docfac.hxx>
27 #include <sfx2/objsh.hxx>
28 #include "swdllapi.h"
29 #include "shellid.hxx"
30 
31 #include <svl/lstner.hxx>
32 #include <sfx2/StyleManager.hxx>
33 #include <o3tl/deleter.hxx>
34 
35 class SwDoc;
37 class SfxInPlaceClient;
38 class FontList;
39 class SwEditShell;
40 class SwView;
41 class SwWrtShell;
42 class SwFEShell;
43 class Reader;
44 class SwReader;
45 typedef std::unique_ptr<SwReader, o3tl::default_delete<SwReader>> SwReaderPtr;
46 class SwCursorShell;
47 class SwSrcView;
48 class SwPaM;
49 class SwgReaderOption;
52 class SwDocShell;
53 class SwDrawModel;
54 class SwViewShell;
55 namespace svt
56 {
57 class EmbeddedObjectRef;
58 }
59 namespace com { namespace sun { namespace star { namespace frame { class XController; } } } }
60 namespace ooo { namespace vba { class XSinkCaller; } }
61 namespace ooo { namespace vba { namespace word { class XDocument; } } }
62 
63 // initialize DrawModel (in form of a SwDrawModel) and DocShell (in form of a SwDocShell)
64 // as needed, one or both parameters may be zero
65 void InitDrawModelAndDocShell(SwDocShell* pSwDocShell, SwDrawModel* pSwDrawModel);
66 
68  : public SfxObjectShell
69  , public SfxListener
70 {
73  std::unique_ptr<FontList> m_pFontList;
75 
76  std::unique_ptr<sfx2::StyleManager> m_pStyleManager;
77 
85 
86  std::unique_ptr<comphelper::EmbeddedObjectContainer> m_pOLEChildList;
87  sal_Int16 m_nUpdateDocMode;
89 
93 
94  css::uno::Reference< ooo::vba::XSinkCaller > mxAutomationDocumentEventsCaller;
95  css::uno::Reference< ooo::vba::word::XDocument> mxAutomationDocumentObject;
96 
98  SAL_DLLPRIVATE void AddLink();
99  SAL_DLLPRIVATE void RemoveLink();
100 
102  SAL_DLLPRIVATE virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
103 
105  SAL_DLLPRIVATE virtual bool InitNew( const css::uno::Reference< css::embed::XStorage >& xStorage ) override;
106  SAL_DLLPRIVATE virtual bool Load( SfxMedium& rMedium ) override;
107  SAL_DLLPRIVATE virtual bool LoadFrom( SfxMedium& rMedium ) override;
108  SAL_DLLPRIVATE virtual bool ConvertFrom( SfxMedium &rMedium ) override;
109  SAL_DLLPRIVATE virtual bool ConvertTo( SfxMedium &rMedium ) override;
110  SAL_DLLPRIVATE virtual bool SaveAs( SfxMedium& rMedium ) override;
111  SAL_DLLPRIVATE virtual bool SaveCompleted( const css::uno::Reference< css::embed::XStorage >& xStorage ) override;
112 
113  SAL_DLLPRIVATE virtual bool PrepareClose( bool bUI = true ) override;
114 
115  SAL_DLLPRIVATE virtual bool InsertGeneratedStream(SfxMedium& rMedium,
116  css::uno::Reference<css::text::XTextRange> const& xInsertPosition)
117  override;
118 
120  SAL_DLLPRIVATE virtual VclPtr<SfxDocumentInfoDialog> CreateDocumentInfoDialog(const SfxItemSet &) override;
122  SAL_DLLPRIVATE virtual void Draw( OutputDevice*, const JobSetup&, sal_uInt16 nAspect) override;
123 
125 
129  SAL_DLLPRIVATE void Edit(
130  const OUString &rName,
131  const OUString& rParent,
132  const SfxStyleFamily nFamily,
133  SfxStyleSearchBits nMask,
134  const bool bNew,
135  const OString& sPageId,
136  SwWrtShell* pActShell,
137  SfxRequest* pRequest = nullptr,
138  sal_uInt16 nSlot = 0);
139 
140  SAL_DLLPRIVATE void Delete(const OUString &rName, SfxStyleFamily nFamily);
141  SAL_DLLPRIVATE void Hide(const OUString &rName, SfxStyleFamily nFamily, bool bHidden);
142  SAL_DLLPRIVATE SfxStyleFamily ApplyStyles(const OUString &rName,
143  const SfxStyleFamily nFamily,
144  SwWrtShell* pShell,
145  sal_uInt16 nMode);
146  SAL_DLLPRIVATE SfxStyleFamily DoWaterCan( const OUString &rName, SfxStyleFamily nFamily);
147  SAL_DLLPRIVATE void UpdateStyle(const OUString &rName, SfxStyleFamily nFamily, SwWrtShell* pShell);
148  SAL_DLLPRIVATE void MakeByExample(const OUString &rName,
149  SfxStyleFamily nFamily, SfxStyleSearchBits nMask, SwWrtShell* pShell);
150 
151  SAL_DLLPRIVATE void SubInitNew();
152 
153  SAL_DLLPRIVATE void RemoveOLEObjects();
154  SAL_DLLPRIVATE void CalcLayoutForOLEObjects();
155 
156  SAL_DLLPRIVATE void Init_Impl();
157 
159 
160 protected:
162  virtual void DoFlushDocInfo() override;
163 
164 public:
167  SFX_DECL_OBJECTFACTORY()
168 
169 private:
171  static void InitInterface_Impl();
172 
173 public:
174  static OUString GetEventName( sal_Int32 nId );
175 
178  SwDocShell( SfxModelFlags i_nSfxCreationFlags );
179  SwDocShell( SwDoc *pDoc, SfxObjectCreateMode eMode );
180  virtual ~SwDocShell() override;
181 
183  DECL_LINK( Ole2ModifiedHdl, bool, void );
184 
186  virtual void SetVisArea( const tools::Rectangle &rRect ) override;
187  virtual tools::Rectangle GetVisArea( sal_uInt16 nAspect ) const override;
188  virtual Printer *GetDocumentPrinter() override;
189  virtual OutputDevice* GetDocumentRefDev() override;
190  virtual void OnDocumentPrinterChanged( Printer * pNewPrinter ) override;
191 
192  virtual void SetModified( bool = true ) override;
193 
195  void Execute(SfxRequest &);
196  void ExecStyleSheet(SfxRequest&);
197 
198  void GetState(SfxItemSet &);
199  void StateStyleSheet(SfxItemSet&, SwWrtShell* pSh = nullptr );
200 
202  SwDoc* GetDoc() { return m_xDoc.get(); }
203  const SwDoc* GetDoc() const { return m_xDoc.get(); }
204  IDocumentDeviceAccess& getIDocumentDeviceAccess();
205  IDocumentChartDataProviderAccess& getIDocumentChartDataProviderAccess();
206 
207  void UpdateFontList();
208  void UpdateChildWindows();
209 
211  virtual bool Save() override;
212 
214  virtual SfxStyleSheetBasePool* GetStyleSheetPool() override;
215  virtual sfx2::StyleManager* GetStyleManager() override;
216 
218  void SetView(SwView* pVw);
219  const SwView *GetView() const { return m_pView; }
220  SwView *GetView() { return m_pView; }
221 
223  SwWrtShell *GetWrtShell() { return m_pWrtShell; }
224  const SwWrtShell *GetWrtShell() const { return m_pWrtShell; }
225  // Same as GetWrtShell, but return pointer to SwEditShell base of
226  // (potentially incomplete) SwWrtShell:
227  SwEditShell * GetEditShell();
228 
230  SwFEShell *GetFEShell();
231  const SwFEShell *GetFEShell() const
232  { return const_cast<SwDocShell*>(this)->GetFEShell(); }
233 
235  Reader* StartConvertFrom(SfxMedium& rMedium, SwReaderPtr& rpRdr,
236  SwCursorShell const * pCursorSh = nullptr, SwPaM* pPaM = nullptr);
237 
238 #if defined(_WIN32)
239  virtual bool DdeGetData( const OUString& rItem, const OUString& rMimeType,
240  css::uno::Any & rValue ) override;
241  virtual bool DdeSetData( const OUString& rItem, const OUString& rMimeType,
242  const css::uno::Any & rValue ) override;
243 #endif
244  virtual ::sfx2::SvLinkSource* DdeCreateLinkSource( const OUString& rItem ) override;
245  virtual void ReconnectDdeLink(SfxObjectShell& rServer) override;
246 
247  virtual void FillClass( SvGlobalName * pClassName,
248  SotClipboardFormatId * pClipFormat,
249  OUString * pAppName,
250  OUString * pLongUserName,
251  OUString * pUserName,
252  sal_Int32 nFileFormat,
253  bool bTemplate = false ) const override;
254 
255  virtual std::set<Color> GetDocColors() override;
256 
257  virtual void LoadStyles( SfxObjectShell& rSource ) override;
258 
259  void LoadStyles_( SfxObjectShell& rSource, bool bPreserveCurrentDocument );
260 
264  void FormatPage(
265  const OUString& rPage,
266  const OString& rPageId,
267  SwWrtShell& rActShell,
268  SfxRequest* pRequest = nullptr);
269 
270  // #i59688#
275  void LoadingFinished();
276  virtual void SetFormatSpecificCompatibilityOptions( const OUString& rFilterTypeName ) override;
277 
279  virtual void CancelTransfers() override;
280 
282  void ReloadFromHtml( const OUString& rStreamName, SwSrcView* pSrcView );
283 
284  sal_Int16 GetUpdateDocMode() const { return m_nUpdateDocMode; }
285 
286  void ToggleLayoutMode(SwView* pView);
287 
288  ErrCode LoadStylesFromFile( const OUString& rURL, SwgReaderOption const & rOpt,
289  bool bUnoCall );
290  void InvalidateModel();
291  void ReactivateModel();
292 
293  virtual css::uno::Sequence< OUString > GetEventNames() override;
294 
297 
301  virtual void UpdateLinks() override;
302 
303  css::uno::Reference< css::frame::XController >
304  GetController();
305 
306  SfxInPlaceClient* GetIPClient( const ::svt::EmbeddedObjectRef& xObjRef );
307  SAL_DLLPRIVATE bool IsTemplate() { return m_IsATemplate; }
308  SAL_DLLPRIVATE void SetIsTemplate( bool bValue ) { m_IsATemplate = bValue; }
309 
310  virtual const ::sfx2::IXmlIdRegistry* GetXmlIdRegistry() const override;
311 
314  virtual bool IsChangeRecording() const override;
315  virtual bool HasChangeRecordProtection() const override;
316  virtual void SetChangeRecording( bool bActivate ) override;
317  virtual void SetProtectionPassword( const OUString &rPassword ) override;
318  virtual bool GetProtectionHash( /*out*/ css::uno::Sequence< sal_Int8 > &rPasswordHash ) override;
319 
320  void RegisterAutomationDocumentEventsCaller(css::uno::Reference< ooo::vba::XSinkCaller > const& xCaller);
321  void CallAutomationDocumentEventSinks(const OUString& Method, css::uno::Sequence< css::uno::Any >& Arguments);
322  void RegisterAutomationDocumentObject(css::uno::Reference< ooo::vba::word::XDocument > const& xDocument);
323 
325  {
326  std::vector<SwViewShell*> m_aViewWasUnLocked;
327 
328  public:
329  explicit LockAllViewsGuard(SwViewShell* pViewShell);
331  };
332  // Lock all unlocked views, and returns a guard object which unlocks those views when destructed
333  std::unique_ptr<LockAllViewsGuard> LockAllViews();
334 };
335 
343 int SwFindDocShell( SfxObjectShellRef& xDocSh,
344  SfxObjectShellLock& xLockRef,
345  const OUString& rFileName,
346  const OUString& rPasswd,
347  const OUString& rFilter,
348  sal_Int16 nVersion,
349  SwDocShell* pDestSh );
350 
351 #endif
352 
353 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int16 GetUpdateDocMode() const
Definition: docsh.hxx:284
const SwDoc * GetDoc() const
Definition: docsh.hxx:203
virtual bool Load(SfxMedium &rMedium)
std::unique_ptr< comphelper::EmbeddedObjectContainer > m_pOLEChildList
Definition: docsh.hxx:86
virtual VclPtr< SfxDocumentInfoDialog > CreateDocumentInfoDialog(const SfxItemSet &)
css::uno::Reference< ooo::vba::XSinkCaller > mxAutomationDocumentEventsCaller
Definition: docsh.hxx:94
Definition: doc.hxx:185
virtual bool SaveCompleted(const css::uno::Reference< css::embed::XStorage > &xStorage)
virtual bool SaveAs(SfxMedium &rMedium)
#define SW_DOCSHELL
Definition: shellid.hxx:37
void InitDrawModelAndDocShell(SwDocShell *pSwDocShell, SwDrawModel *pSwDrawModel)
Definition: docshdrw.cxx:36
std::unique_ptr< sfx2::StyleManager > m_pStyleManager
Definition: docsh.hxx:76
virtual sfx2::StyleManager * GetStyleManager()
virtual SfxStyleSheetBasePool * GetStyleSheetPool()
Used by the UI to modify the document model.
Definition: wrtsh.hxx:86
virtual bool PrepareClose(bool bUI=true)
virtual void DoFlushDocInfo()
virtual void CancelTransfers()
virtual bool Save()
UpdateLinks
Definition: linkenum.hxx:22
virtual void SetChangeRecording(bool bActivate)
SfxStyleFamily
SotClipboardFormatId
std::unique_ptr< SwReader, o3tl::default_delete< SwReader > > SwReaderPtr
Definition: docsh.hxx:44
virtual void ReconnectDdeLink(SfxObjectShell &rServer)
virtual bool IsChangeRecording() const
virtual const sfx2::IXmlIdRegistry * GetXmlIdRegistry() const
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
virtual void FillClass(SvGlobalName *pClassName, SotClipboardFormatId *pFormat, OUString *pAppName, OUString *pFullTypeName, OUString *pShortTypeName, sal_Int32 nVersion, bool bTemplate=false) const =0
virtual bool HasChangeRecordProtection() const
int SwFindDocShell(SfxObjectShellRef &xDocSh, SfxObjectShellLock &xLockRef, const OUString &rFileName, const OUString &rPasswd, const OUString &rFilter, sal_Int16 nVersion, SwDocShell *pDestSh)
Find the right DocShell and create a new one: The return value specifies what should happen to the Sh...
Definition: docsh2.cxx:1673
SfxObjectCreateMode
virtual css::uno::Sequence< OUString > GetEventNames()
std::vector< SwViewShell * > m_aViewWasUnLocked
Definition: docsh.hxx:326
virtual bool LoadFrom(SfxMedium &rMedium)
virtual void SetFormatSpecificCompatibilityOptions(const OUString &)
SwWrtShell * GetWrtShell()
Access to the SwWrtShell belonging to SwView.
Definition: docsh.hxx:223
virtual ::sfx2::SvLinkSource * DdeCreateLinkSource(const OUString &rItem)
SwView * GetView()
Definition: docsh.hxx:220
rtl::Reference< SwDoc > m_xDoc
Document.
Definition: docsh.hxx:71
std::unique_ptr< FontList > m_pFontList
Current Fontlist.
Definition: docsh.hxx:73
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
bool m_IsATemplate
prevent nested calls of UpdateFontList
Definition: docsh.hxx:88
const tools::Rectangle & GetVisArea() const
virtual HiddenInformation GetHiddenInformationState(HiddenInformation nStates)
SAL_DLLPRIVATE void SetIsTemplate(bool bValue)
Definition: docsh.hxx:308
virtual bool InitNew(const css::uno::Reference< css::embed::XStorage > &xStorage)
SAL_DLLPRIVATE bool IsTemplate()
Definition: docsh.hxx:307
virtual void LoadStyles(SfxObjectShell &rSource)
bool m_IsRemovedInvisibleContent
whether SID_MAIL_PREPAREEXPORT removed content that SID_MAIL_EXPORT_FINISHED needs to restore ...
Definition: docsh.hxx:90
virtual bool ConvertTo(SfxMedium &rMedium)
rtl::Reference< SfxStyleSheetBasePool > m_xBasePool
Passing through for formats.
Definition: docsh.hxx:72
Provides access to the formatting devices of a document.
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint)
virtual std::set< Color > GetDocColors()
virtual void Draw(OutputDevice *, const JobSetup &rSetup, sal_uInt16 nAspect)=0
SwView * m_pView
For "historical reasons" nothing can be done without the WrtShell.
Definition: docsh.hxx:83
bool m_IsInUpdateFontList
prevent nested calls of UpdateFontList
Definition: docsh.hxx:74
virtual bool GetProtectionHash(css::uno::Sequence< sal_Int8 > &rPasswordHash)
const SwFEShell * GetFEShell() const
Definition: docsh.hxx:231
SfxModelFlags
SwWrtShell * m_pWrtShell
Definition: docsh.hxx:84
virtual void SetProtectionPassword(const OUString &rPassword)
const SwWrtShell * GetWrtShell() const
Definition: docsh.hxx:224
sal_Int16 m_nUpdateDocMode
contains the css::document::UpdateDocMode
Definition: docsh.hxx:87
Give access to the data-provider for chart.
const SwView * GetView() const
Definition: docsh.hxx:219
virtual bool InsertGeneratedStream(SfxMedium &rMedium, css::uno::Reference< css::text::XTextRange > const &xInsertPosition)
HiddenInformation
virtual bool ConvertFrom(SfxMedium &rMedium)
SfxStyleSearchBits
Definition: view.hxx:146
css::uno::Reference< ooo::vba::word::XDocument > mxAutomationDocumentObject
Definition: docsh.hxx:95
#define SFX_DECL_INTERFACE(nId)