xref: /aoo4110/main/sw/inc/docsh.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _SWDOCSH_HXX
24 #define _SWDOCSH_HXX
25 
26 #include <rtl/ref.hxx>
27 #include <com/sun/star/frame/XController.hpp>
28 #include <com/sun/star/uno/Sequence.h>
29 #include <vcl/timer.hxx>
30 #include <sfx2/docfac.hxx>
31 #include <sfx2/objsh.hxx>
32 #include "swdllapi.h"
33 #include <swdll.hxx>
34 #include <shellid.hxx>
35 
36 #include <svl/lstner.hxx>
37 #include <svtools/embedhlp.hxx>
38 
39 class SwDoc;
40 class SfxDocumentInfoDialog;
41 class SfxStyleSheetBasePool;
42 class SfxInPlaceClient;
43 class FontList;
44 class SwView;
45 class SwWrtShell;
46 class SwFEShell;
47 class Reader;
48 class SwReader;
49 class SwCrsrShell;
50 class SwSrcView;
51 class SwPaM;
52 class SwgReaderOption;
53 class SwOLEObj;
54 class IDocumentDeviceAccess;
55 class IDocumentSettingAccess;
56 class IDocumentTimerAccess;
57 class IDocumentChartDataProviderAccess;
58 
59 
60 class SW_DLLPUBLIC SwDocShell: public SfxObjectShell, public SfxListener
61 {
62     SwDoc* mpDoc; // Document
63 
64     rtl::Reference< SfxStyleSheetBasePool > mxBasePool; // Durchreiche fuer Formate
65 
66     FontList* mpFontList; // aktuelle FontListe
67     bool mbInUpdateFontList; //prevent nested calls of UpdateFontList
68 
69     // Nix geht ohne die WrtShell (historische Gruende)
70     // RuekwaertsPointer auf die View (historische Gruende)
71     // Dieser gilt solange bis im Activate ein neuer gesetzt wird
72     // oder dieser im Dtor der View geloescht wird
73     //
74     SwView* mpView;
75     SwWrtShell* mpWrtShell;
76 
77     Timer aFinishedTimer;	// Timer fuers ueberpriefen der
78                             // Grafik-Links. Sind alle da,
79                             // dann ist Doc voll. geladen
80 
81     comphelper::EmbeddedObjectContainer* mpOLEChildList;
82     sal_Int16 mnUpdateDocMode; // contains the com::sun::star::document::UpdateDocMode
83 
84     // Methoden fuer den Zugriff aufs Doc
85 	SW_DLLPRIVATE void					AddLink();
86 	SW_DLLPRIVATE void					RemoveLink();
87 
88 	// Hint abfangen fuer DocInfo
89 	SW_DLLPRIVATE virtual void			Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
90 
91 	// FileIO
92     SW_DLLPRIVATE virtual sal_Bool InitNew( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage );
93     SW_DLLPRIVATE virtual sal_Bool Load( SfxMedium& rMedium );
94     SW_DLLPRIVATE virtual sal_Bool LoadFrom( SfxMedium& rMedium );
95     SW_DLLPRIVATE virtual sal_Bool ConvertFrom( SfxMedium &rMedium );
96     SW_DLLPRIVATE virtual sal_Bool ConvertTo( SfxMedium &rMedium );
97     SW_DLLPRIVATE virtual sal_Bool SaveAs( SfxMedium& rMedium );
98     SW_DLLPRIVATE virtual sal_Bool SaveCompleted( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage );
99 
100 	SW_DLLPRIVATE virtual sal_uInt16			PrepareClose( sal_Bool bUI = sal_True, sal_Bool bForBrowsing = sal_False );
101 
102 	// DocInfo dem Doc melden
103 	//
104 	SW_DLLPRIVATE virtual SfxDocumentInfoDialog* CreateDocumentInfoDialog(
105 									Window *pParent, const SfxItemSet &);
106 	// OLE-Geraffel
107 	SW_DLLPRIVATE virtual void			Draw( OutputDevice*, const JobSetup&, sal_uInt16);
108 
109     // Methoden fuer StyleSheets
110 
111     // @param nSlot
112     // Only used for nFamily == SFX_STYLE_FAMILY_PAGE. Identifies optional Slot by which the edit is triggered.
113     // Used to activate certain dialog pane
114     SW_DLLPRIVATE sal_uInt16 Edit(
115         const String &rName,
116         const String& rParent,
117         const sal_uInt16 nFamily,
118         sal_uInt16 nMask,
119         const sal_Bool bNew,
120         const sal_uInt16 nSlot = 0,
121         SwWrtShell* pActShell = 0,
122         const sal_Bool bBasic = sal_False );
123 
124 	SW_DLLPRIVATE sal_uInt16					Delete(const String &rName, sal_uInt16 nFamily);
125 	SW_DLLPRIVATE sal_uInt16					ApplyStyles(const String &rName, sal_uInt16 nFamily, SwWrtShell* pShell = 0,
126 										sal_uInt16 nMode = 0 );
127 	SW_DLLPRIVATE sal_uInt16					DoWaterCan( const String &rName, sal_uInt16 nFamily);
128 	SW_DLLPRIVATE sal_uInt16					UpdateStyle(const String &rName, sal_uInt16 nFamily, SwWrtShell* pShell = 0);
129 	SW_DLLPRIVATE sal_uInt16					MakeByExample(const String &rName,
130 											sal_uInt16 nFamily, sal_uInt16 nMask, SwWrtShell* pShell = 0);
131 
132 	SW_DLLPRIVATE void					InitDraw();
133 	SW_DLLPRIVATE void					SubInitNew();   // fuer InitNew und HtmlSourceModus
134 
135 	SW_DLLPRIVATE void 					RemoveOLEObjects();
136 	SW_DLLPRIVATE void					CalcLayoutForOLEObjects();
137 
138     SW_DLLPRIVATE void                    Init_Impl();
139     SW_DLLPRIVATE DECL_STATIC_LINK( SwDocShell, IsLoadFinished, void* );
140 
141 
142     using SfxObjectShell::GetVisArea;
143     using SfxObjectShell::GetStyleFamilyBitmap;
144 
145 protected:
146     /// override to update text fields
147     virtual void                DoFlushDocInfo();
148 
149     // override <SfxObjectShell>'s method which is called in <SfxObjectShell::ImportFrom(..)>.
150     // <SfxObjectShell::ImportFrom(..)> is used by current import of Microsoft Word documents in OOXML file format.
151     virtual void BeforeLoading( SfxMedium&, const ::rtl::OUString &, const ::rtl::OUString & );
152 
153 public:
154     using SotObject::GetInterface;
155 
156 	// aber selbst implementieren
157 	SFX_DECL_INTERFACE(SW_DOCSHELL)
158     SFX_DECL_OBJECTFACTORY()
159 	TYPEINFO();
160 
_GetInterface()161     static SfxInterface *_GetInterface() { return GetStaticInterface(); }
162 
163 	static rtl::OUString GetEventName( sal_Int32 nId );
164 
165 	//Das Doc wird fuer SO-Datenaustausch benoetigt!
166 	SwDocShell( SfxObjectCreateMode eMode = SFX_CREATE_MODE_EMBEDDED );
167 	SwDocShell( const sal_uInt64 i_nSfxCreationFlags );
168 	SwDocShell( SwDoc *pDoc, SfxObjectCreateMode eMode = SFX_CREATE_MODE_STANDARD );
169 	~SwDocShell();
170 
171 	// OLE 2.0-Benachrichtigung
172 	DECL_LINK( Ole2ModifiedHdl, void * );
173 
174 	// OLE-Geraffel
175 	virtual void	  SetVisArea( const Rectangle &rRect );
176 	virtual Rectangle GetVisArea( sal_uInt16 nAspect ) const;
177 	virtual Printer  *GetDocumentPrinter();
178     virtual OutputDevice* GetDocumentRefDev();
179 	virtual void	  OnDocumentPrinterChanged( Printer * pNewPrinter );
180 	virtual sal_uLong	  GetMiscStatus() const;
181 
182 	virtual void			PrepareReload();
183 	virtual void			SetModified( sal_Bool = sal_True );
184 
185 	// Dispatcher
186 	void					Execute(SfxRequest &);
187 	void					ExecStyleSheet(SfxRequest&);
188 	void					ExecDB(SfxRequest&);
189 
190 	void					GetState(SfxItemSet &);
191 	void					StateAlways(SfxItemSet &);
192 	void					StateStyleSheet(SfxItemSet&, SwWrtShell* pSh = 0 );
193 
194 	// Doc rausreichen aber VORSICHT
GetDoc()195     inline SwDoc*                   GetDoc() { return mpDoc; }
GetDoc() const196     inline const SwDoc*             GetDoc() const { return mpDoc; }
197     IDocumentDeviceAccess*          getIDocumentDeviceAccess();
198     const IDocumentSettingAccess*   getIDocumentSettingAccess() const;
199     IDocumentChartDataProviderAccess*       getIDocumentChartDataProviderAccess();
200 
201 
202     void                    UpdateFontList();
203 	void					UpdateChildWindows();
204 
205 	// globaler IO
206 	virtual sal_Bool			Save();
207 
208 	// fuer VorlagenPI
209 	virtual SfxStyleSheetBasePool*	GetStyleSheetPool();
210 
211 	// Fuer Organizer
212 	virtual sal_Bool Insert(SfxObjectShell &rSource,
213 						sal_uInt16	nSourceIdx1,
214 						sal_uInt16	nSourceIdx2,
215 						sal_uInt16	nSourceIdx3,
216 						sal_uInt16& nIdx1,
217 						sal_uInt16& nIdx2,
218 						sal_uInt16& nIdx3,
219 						sal_uInt16& nRemovedIdx);
220 
221 	virtual sal_Bool Remove(sal_uInt16 nIdx1,
222 						sal_uInt16 nIdx2 = INDEX_IGNORE,
223 						sal_uInt16 nIdx3 = INDEX_IGNORE);
224 
225 	virtual Bitmap 		GetStyleFamilyBitmap( SfxStyleFamily eFamily, BmpColorMode eColorMode );
226 
227 	// View setzen fuer Aktionen ueber Shell
228 	void 		  SetView(SwView* pVw);
GetView() const229 	const SwView *GetView() const { return mpView; }
GetView()230     SwView       *GetView()       { return mpView; }
231 
232 	// Zugriff auf die zur SwView gehoerige SwWrtShell
GetWrtShell()233 		  SwWrtShell *GetWrtShell() 	  { return mpWrtShell; }
GetWrtShell() const234 	const SwWrtShell *GetWrtShell() const { return mpWrtShell; }
235 
236 	// fuer die Core - die kennt die DocShell aber keine WrtShell!
237 		  SwFEShell *GetFEShell();
GetFEShell() const238 	const SwFEShell *GetFEShell() const
239 				{ return ((SwDocShell*)this)->GetFEShell(); }
240 
241 
242 	// Fuer Einfuegen Dokument
243 	Reader* StartConvertFrom(SfxMedium& rMedium, SwReader** ppRdr,
244 							SwCrsrShell* pCrsrSh = 0, SwPaM* pPaM = 0);
245 
246 	virtual long DdeGetData( const String& rItem, const String& rMimeType,
247 							 ::com::sun::star::uno::Any & rValue );
248 	virtual long DdeSetData( const String& rItem, const String& rMimeType,
249 								const ::com::sun::star::uno::Any & rValue );
250     virtual ::sfx2::SvLinkSource* DdeCreateLinkSource( const String& rItem );
251 	virtual void FillClass( SvGlobalName * pClassName,
252 								   sal_uInt32 * pClipFormat,
253 								   String * pAppName,
254 								   String * pLongUserName,
255                                    String * pUserName,
256                                    sal_Int32 nFileFormat,
257                                    sal_Bool bTemplate = sal_False ) const;
258 
259 	virtual void LoadStyles( SfxObjectShell& rSource );
260 
261     void _LoadStyles( SfxObjectShell& rSource, sal_Bool bPreserveCurrentDocument );
262 
263     // Show page style format dialog
264     // @param nSlot
265     // Identifies slot by which the dialog is triggered. Used to activate certain dialog pane
266     void FormatPage(
267         const String& rPage,
268         const sal_uInt16 nSlot,
269         SwWrtShell& rActShell );
270 
271     // --> OD 2006-11-07 #i59688#
272     // linked graphics are now loaded on demand.
273     // Thus, loading of linked graphics no longer needed and necessary for
274     // the load of document being finished.
275 //    // Timer starten fuers ueberpruefen der Grafik-Links. Sind alle
276 //    // vollstaendig geladen, dann ist das Doc fertig
277 //    void StartLoadFinishedTimer();
278     void LoadingFinished();
279     // <--
280 
281 	// eine Uebertragung wird abgebrochen (wird aus dem SFX gerufen)
282 	virtual void CancelTransfers();
283 
284 	// Doc aus Html-Source neu laden
285 	void	ReloadFromHtml( const String& rStreamName, SwSrcView* pSrcView );
286 
GetUpdateDocMode() const287     sal_Int16   GetUpdateDocMode() const {return mnUpdateDocMode;}
288 
289 	void ToggleBrowserMode(sal_Bool bOn, SwView* pView);
290 
291 	sal_uLong LoadStylesFromFile( const String& rURL, SwgReaderOption& rOpt,
292 								sal_Bool bUnoCall );
293 	void InvalidateModel();
294 	void ReactivateModel();
295 
296 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >	GetEventNames();
297 
298     // --> FME 2004-08-05 #i20883# Digital Signatures and Encryption
299     virtual sal_uInt16 GetHiddenInformationState( sal_uInt16 nStates );
300     // <--
301 
302     // --> FME 2005-02-25 #i42634# Overwrites SfxObjectShell::UpdateLinks
303     // This new function is necessary to trigger update of links in docs
304     // read by the binary filter:
305     virtual void UpdateLinks();
306     // <--
307 	virtual void setDocAccTitle( const String& rTitle );
308 	virtual const String getDocAccTitle() const;
309 
310 	void setDocReadOnly( sal_Bool bReadOnly);
311 	sal_Bool getDocReadOnly() const;
312     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >
313                                 GetController();
314 
315     SfxInPlaceClient* GetIPClient( const ::svt::EmbeddedObjectRef& xObjRef );
316 
317     virtual const ::sfx2::IXmlIdRegistry* GetXmlIdRegistry() const;
318 
319     // passwword protection for Writer (derived from SfxObjectShell)
320     // see also:    FN_REDLINE_ON, FN_REDLINE_ON
321     virtual bool    IsChangeRecording() const;
322     virtual bool    HasChangeRecordProtection() const;
323     virtual void    SetChangeRecording( bool bActivate );
324     virtual bool    SetProtectionPassword( const String &rPassword );
325     virtual bool    GetProtectionHash( /*out*/ ::com::sun::star::uno::Sequence< sal_Int8 > &rPasswordHash );
326 };
327 
328 class Graphic;
329 //implemented in source/ui/docvw/romenu.cxx
330 String ExportGraphic( const Graphic &rGraphic, const String &rGrfName );
331 
332 #endif
333