Branch libreoffice-5-0-4
[LibreOffice.git] / sw / inc / docsh.hxx
blobaf0aed66a45403ab1e3a0213a7c05585d60fcfae
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_SW_INC_DOCSH_HXX
20 #define INCLUDED_SW_INC_DOCSH_HXX
22 #include <rtl/ref.hxx>
23 #include <com/sun/star/frame/XController.hpp>
24 #include <com/sun/star/uno/Sequence.h>
25 #include <sfx2/docfac.hxx>
26 #include <sfx2/objsh.hxx>
27 #include "swdllapi.h"
28 #include <shellid.hxx>
30 #include <svl/lstner.hxx>
31 #include <svtools/embedhlp.hxx>
32 #define LOK_USE_UNSTABLE_API
33 #include <LibreOfficeKit/LibreOfficeKitTypes.h>
35 #include <sfx2/StyleManager.hxx>
37 class SwDoc;
38 class SfxDocumentInfoDialog;
39 class SfxStyleSheetBasePool;
40 class SfxInPlaceClient;
41 class FontList;
42 class SwEditShell;
43 class SwView;
44 class SwWrtShell;
45 class SwFEShell;
46 class Reader;
47 class SwReader;
48 class SwCrsrShell;
49 class SwSrcView;
50 class SwPaM;
51 class SwgReaderOption;
52 class SwOLEObj;
53 class IDocumentDeviceAccess;
54 class IDocumentSettingAccess;
55 class IDocumentChartDataProviderAccess;
56 class SwDocShell;
57 class SwDrawModel;
59 // initialize DrawModel (in form of a SwDrawModel) and DocShell (in form of a SwDocShell)
60 // as needed, one or both parameters may be zero
61 void SAL_DLLPRIVATE InitDrawModelAndDocShell(SwDocShell* pSwDocShell, SwDrawModel* pSwDrawModel);
63 class SW_DLLPUBLIC SwDocShell
64 : public SfxObjectShell
65 , public SfxListener
67 SwDoc* m_pDoc; ///< Document.
68 rtl::Reference< SfxStyleSheetBasePool > m_xBasePool; ///< Passing through for formats.
69 FontList* m_pFontList; ///< Current Fontlist.
70 bool m_IsInUpdateFontList; ///< prevent nested calls of UpdateFontList
72 std::unique_ptr<sfx2::StyleManager> m_pStyleManager;
74 /** For "historical reasons" nothing can be done without the WrtShell.
75 Back-pointer on View (again "for historical reasons").
76 Back-pointer is valid until in Activate a new one is set
77 or until it is deleted in the View's Dtor. */
79 SwView* m_pView;
80 SwWrtShell* m_pWrtShell;
82 comphelper::EmbeddedObjectContainer* m_pOLEChildList;
83 sal_Int16 m_nUpdateDocMode; ///< contains the com::sun::star::document::UpdateDocMode
84 bool m_IsATemplate; ///< prevent nested calls of UpdateFontList
86 bool m_IsRemovedInvisibleContent;
87 ///< whether SID_MAIL_PREPAREEXPORT removed content that
88 ///< SID_MAIL_EXPORT_FINISHED needs to restore
90 /// Methods for access to doc.
91 SAL_DLLPRIVATE void AddLink();
92 SAL_DLLPRIVATE void RemoveLink();
94 /// Catch hint for DocInfo.
95 SAL_DLLPRIVATE virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) SAL_OVERRIDE;
97 /// FileIO
98 SAL_DLLPRIVATE virtual bool InitNew( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage ) SAL_OVERRIDE;
99 SAL_DLLPRIVATE virtual bool Load( SfxMedium& rMedium ) SAL_OVERRIDE;
100 SAL_DLLPRIVATE virtual bool LoadFrom( SfxMedium& rMedium ) SAL_OVERRIDE;
101 SAL_DLLPRIVATE virtual bool ConvertFrom( SfxMedium &rMedium ) SAL_OVERRIDE;
102 SAL_DLLPRIVATE virtual bool ConvertTo( SfxMedium &rMedium ) SAL_OVERRIDE;
103 SAL_DLLPRIVATE virtual bool SaveAs( SfxMedium& rMedium ) SAL_OVERRIDE;
104 SAL_DLLPRIVATE virtual bool SaveCompleted( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage ) SAL_OVERRIDE;
106 SAL_DLLPRIVATE virtual bool PrepareClose( bool bUI = true ) SAL_OVERRIDE;
108 SAL_DLLPRIVATE virtual bool InsertGeneratedStream(SfxMedium& rMedium,
109 css::uno::Reference<css::text::XTextRange> const& xInsertPosition)
110 SAL_OVERRIDE;
112 /// Make DocInfo known to the Doc.
113 SAL_DLLPRIVATE virtual VclPtr<SfxDocumentInfoDialog> CreateDocumentInfoDialog(
114 vcl::Window *pParent, const SfxItemSet &) SAL_OVERRIDE;
115 /// OLE-stuff
116 SAL_DLLPRIVATE virtual void Draw( OutputDevice*, const JobSetup&, sal_uInt16) SAL_OVERRIDE;
118 /// Methods for StyleSheets
120 /// @param nSlot
121 /// Only used for nFamily == SFX_STYLE_FAMILY_PAGE. Identifies optional Slot by which the edit is triggered.
122 /// Used to activate certain dialog pane
123 SAL_DLLPRIVATE sal_uInt16 Edit(
124 const OUString &rName,
125 const OUString& rParent,
126 const sal_uInt16 nFamily,
127 sal_uInt16 nMask,
128 const bool bNew,
129 const OString& sPageId = OString(),
130 SwWrtShell* pActShell = 0,
131 const bool bBasic = false );
133 SAL_DLLPRIVATE bool Delete(const OUString &rName, sal_uInt16 nFamily);
134 SAL_DLLPRIVATE bool Hide(const OUString &rName, sal_uInt16 nFamily, bool bHidden);
135 SAL_DLLPRIVATE sal_uInt16 ApplyStyles(const OUString &rName,
136 const sal_uInt16 nFamily,
137 SwWrtShell* pShell = 0,
138 sal_uInt16 nMode = 0);
139 SAL_DLLPRIVATE sal_uInt16 DoWaterCan( const OUString &rName, sal_uInt16 nFamily);
140 SAL_DLLPRIVATE sal_uInt16 UpdateStyle(const OUString &rName, sal_uInt16 nFamily, SwWrtShell* pShell = 0);
141 SAL_DLLPRIVATE sal_uInt16 MakeByExample(const OUString &rName,
142 sal_uInt16 nFamily, sal_uInt16 nMask, SwWrtShell* pShell = 0);
144 SAL_DLLPRIVATE void InitDraw();
145 SAL_DLLPRIVATE void SubInitNew(); ///< for InitNew and HtmlSourceMode.
147 SAL_DLLPRIVATE void RemoveOLEObjects();
148 SAL_DLLPRIVATE void CalcLayoutForOLEObjects();
150 SAL_DLLPRIVATE void Init_Impl();
151 DECL_DLLPRIVATE_STATIC_LINK( SwDocShell, IsLoadFinished, void* );
153 using SfxObjectShell::GetVisArea;
155 protected:
156 /// override to update text fields
157 virtual void DoFlushDocInfo() SAL_OVERRIDE;
159 public:
161 /// but we implement this ourselves.
162 SFX_DECL_INTERFACE(SW_DOCSHELL)
163 SFX_DECL_OBJECTFACTORY()
164 TYPEINFO_OVERRIDE();
166 private:
167 /// SfxInterface initializer.
168 static void InitInterface_Impl();
170 public:
171 static SfxInterface *_GetInterface() { return GetStaticInterface(); }
173 static OUString GetEventName( sal_Int32 nId );
175 /// Doc is required for SO data exchange!
176 SwDocShell( SfxObjectCreateMode eMode = SfxObjectCreateMode::EMBEDDED );
177 SwDocShell( SfxModelFlags i_nSfxCreationFlags );
178 SwDocShell( SwDoc *pDoc, SfxObjectCreateMode eMode = SfxObjectCreateMode::STANDARD );
179 virtual ~SwDocShell();
181 /// OLE 2.0-notification.
182 DECL_LINK( Ole2ModifiedHdl, void * );
184 /// OLE-stuff.
185 virtual void SetVisArea( const Rectangle &rRect ) SAL_OVERRIDE;
186 virtual Rectangle GetVisArea( sal_uInt16 nAspect ) const SAL_OVERRIDE;
187 virtual Printer *GetDocumentPrinter() SAL_OVERRIDE;
188 virtual OutputDevice* GetDocumentRefDev() SAL_OVERRIDE;
189 virtual void OnDocumentPrinterChanged( Printer * pNewPrinter ) SAL_OVERRIDE;
190 virtual sal_uLong GetMiscStatus() const SAL_OVERRIDE;
192 virtual void PrepareReload() SAL_OVERRIDE;
193 virtual void SetModified( bool = true ) SAL_OVERRIDE;
195 /// Dispatcher
196 void Execute(SfxRequest &);
197 void ExecStyleSheet(SfxRequest&);
198 void ExecDB(SfxRequest&);
200 void GetState(SfxItemSet &);
201 void StateAlways(SfxItemSet &);
202 void StateStyleSheet(SfxItemSet&, SwWrtShell* pSh = 0 );
204 /// returns Doc. But be careful!
205 inline SwDoc* GetDoc() { return m_pDoc; }
206 inline const SwDoc* GetDoc() const { return m_pDoc; }
207 IDocumentDeviceAccess* getIDocumentDeviceAccess();
208 const IDocumentSettingAccess* getIDocumentSettingAccess() const;
209 IDocumentChartDataProviderAccess* getIDocumentChartDataProviderAccess();
211 void UpdateFontList();
212 void UpdateChildWindows();
214 /// global IO.
215 virtual bool Save() SAL_OVERRIDE;
217 /// For Style PI.
218 virtual SfxStyleSheetBasePool* GetStyleSheetPool() SAL_OVERRIDE;
219 virtual sfx2::StyleManager* GetStyleManager() SAL_OVERRIDE;
221 /// Set View for actions via Shell.
222 void SetView(SwView* pVw);
223 const SwView *GetView() const { return m_pView; }
224 SwView *GetView() { return m_pView; }
226 /// Accress to the SwWrtShell belonging to SwView.
227 SwWrtShell *GetWrtShell() { return m_pWrtShell; }
228 const SwWrtShell *GetWrtShell() const { return m_pWrtShell; }
229 // Same as GetWrtShell, but return pointer to SwEditShell base of
230 // (potentially incomplete) SwWrtShell:
231 SwEditShell * GetEditShell();
233 /// For Core - it knows the DocShell but not the WrtShell!
234 SwFEShell *GetFEShell();
235 const SwFEShell *GetFEShell() const
236 { return const_cast<SwDocShell*>(this)->GetFEShell(); }
238 /// For inserting document.
239 Reader* StartConvertFrom(SfxMedium& rMedium, SwReader** ppRdr,
240 SwCrsrShell* pCrsrSh = 0, SwPaM* pPaM = 0);
242 #if defined WNT
243 virtual bool DdeGetData( const OUString& rItem, const OUString& rMimeType,
244 ::com::sun::star::uno::Any & rValue ) SAL_OVERRIDE;
245 virtual bool DdeSetData( const OUString& rItem, const OUString& rMimeType,
246 const ::com::sun::star::uno::Any & rValue ) SAL_OVERRIDE;
247 #endif
248 virtual ::sfx2::SvLinkSource* DdeCreateLinkSource( const OUString& rItem ) SAL_OVERRIDE;
249 virtual void ReconnectDdeLink(SfxObjectShell& rServer) SAL_OVERRIDE;
251 virtual void FillClass( SvGlobalName * pClassName,
252 SotClipboardFormatId * pClipFormat,
253 OUString * pAppName,
254 OUString * pLongUserName,
255 OUString * pUserName,
256 sal_Int32 nFileFormat,
257 bool bTemplate = false ) const SAL_OVERRIDE;
259 virtual std::set<Color> GetDocColors() SAL_OVERRIDE;
261 virtual void LoadStyles( SfxObjectShell& rSource ) SAL_OVERRIDE;
263 void _LoadStyles( SfxObjectShell& rSource, bool bPreserveCurrentDocument );
265 /// Show page style format dialog
266 /// @param nSlot
267 /// Identifies slot by which the dialog is triggered. Used to activate certain dialog pane
268 void FormatPage(
269 const OUString& rPage,
270 const OString& rPageId,
271 SwWrtShell& rActShell );
273 // #i59688#
274 /** linked graphics are now loaded on demand.
275 Thus, loading of linked graphics no longer needed and necessary for
276 the load of document being finished. */
278 void LoadingFinished();
280 /// Cancel transfer (called from SFX).
281 virtual void CancelTransfers() SAL_OVERRIDE;
283 /// Re-read Doc from Html-source.
284 void ReloadFromHtml( const OUString& rStreamName, SwSrcView* pSrcView );
286 sal_Int16 GetUpdateDocMode() const { return m_nUpdateDocMode; }
288 void ToggleBrowserMode(bool bOn, SwView* pView);
290 sal_uLong LoadStylesFromFile( const OUString& rURL, SwgReaderOption& rOpt,
291 bool bUnoCall );
292 void InvalidateModel();
293 void ReactivateModel();
295 virtual ::com::sun::star::uno::Sequence< OUString > GetEventNames() SAL_OVERRIDE;
297 /// #i20883# Digital Signatures and Encryption
298 virtual HiddenInformation GetHiddenInformationState( HiddenInformation nStates ) SAL_OVERRIDE;
300 /** #i42634# Overwrites SfxObjectShell::UpdateLinks
301 This new function is necessary to trigger update of links in docs
302 read by the binary filter: */
303 virtual void UpdateLinks() SAL_OVERRIDE;
305 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >
306 GetController();
308 SfxInPlaceClient* GetIPClient( const ::svt::EmbeddedObjectRef& xObjRef );
309 SAL_DLLPRIVATE bool IsTemplate() { return m_IsATemplate; }
310 SAL_DLLPRIVATE void SetIsTemplate( bool bValue ) { m_IsATemplate = bValue; }
312 virtual const ::sfx2::IXmlIdRegistry* GetXmlIdRegistry() const SAL_OVERRIDE;
314 /** passwword protection for Writer (derived from SfxObjectShell)
315 see also: FN_REDLINE_ON, FN_REDLINE_ON */
316 virtual bool IsChangeRecording() const SAL_OVERRIDE;
317 virtual bool HasChangeRecordProtection() const SAL_OVERRIDE;
318 virtual void SetChangeRecording( bool bActivate ) SAL_OVERRIDE;
319 virtual bool SetProtectionPassword( const OUString &rPassword ) SAL_OVERRIDE;
320 virtual bool GetProtectionHash( /*out*/ ::com::sun::star::uno::Sequence< sal_Int8 > &rPasswordHash ) SAL_OVERRIDE;
322 virtual void libreOfficeKitCallback(int nType, const char* pPayload) const SAL_OVERRIDE;
323 virtual bool isTiledRendering() const SAL_OVERRIDE;
326 /** Find the right DocShell and create a new one:
327 The return value specifies what should happen to the Shell
328 0 - Error, could not find the DocShell
329 1 - DocShell is an existing Document
330 2 - DocShell was created anew, thus it needs to be closed again
331 (will be assigned to xLockRef additionally)
333 int SwFindDocShell( SfxObjectShellRef& xDocSh,
334 SfxObjectShellLock& xLockRef,
335 const OUString& rFileName,
336 const OUString& rPasswd,
337 const OUString& rFilter,
338 sal_Int16 nVersion,
339 SwDocShell* pDestSh );
341 #endif
343 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */