xref: /trunk/main/sw/inc/docsh.hxx (revision 26ea3662)
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 class SwDocShell;
59 class SwDrawModel;
60 
61 // initialize DrawModel (in form of a SwDrawModel) and DocShell (in form of a SwDocShell)
62 // as needed, one or both parameters may be zero
63 void SW_DLLPRIVATE InitDrawModelAndDocShell(SwDocShell* pSwDocShell, SwDrawModel* pSwDrawModel);
64 
65 class SW_DLLPUBLIC SwDocShell: public SfxObjectShell, public SfxListener
66 {
67 	SwDoc*					pDoc;			// Document
68 	rtl::Reference< SfxStyleSheetBasePool >	mxBasePool;		// Durchreiche fuer Formate
69 	FontList*				pFontList;		// aktuelle FontListe
70 
71 	// Nix geht ohne die WrtShell (historische Gruende)
72 	// RuekwaertsPointer auf die View (historische Gruende)
73 	// Dieser gilt solange bis im Activate ein neuer gesetzt wird
74 	// oder dieser im Dtor der View geloescht wird
75 	//
76 	SwView* 				pView;
77 	SwWrtShell* 			pWrtShell;
78 
79 	Timer					aFinishedTimer;	// Timer fuers ueberpriefen der
80 											// Grafik-Links. Sind alle da,
81 											// dann ist Doc voll. geladen
82 
83     //SvPersistRef            xOLEChildList;  // fuers RemoveOLEObjects
84     comphelper::EmbeddedObjectContainer*    pOLEChildList;
85     sal_Int16               nUpdateDocMode; // contains the com::sun::star::document::UpdateDocMode
86     bool                    bInUpdateFontList; //prevent nested calls of UpdateFontList
87 	// Methoden fuer den Zugriff aufs Doc
88 	SW_DLLPRIVATE void					AddLink();
89 	SW_DLLPRIVATE void					RemoveLink();
90 
91 	// Hint abfangen fuer DocInfo
92 	SW_DLLPRIVATE virtual void			Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
93 
94 	// FileIO
95     SW_DLLPRIVATE virtual sal_Bool InitNew( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage );
96     SW_DLLPRIVATE virtual sal_Bool Load( SfxMedium& rMedium );
97     SW_DLLPRIVATE virtual sal_Bool LoadFrom( SfxMedium& rMedium );
98     SW_DLLPRIVATE virtual sal_Bool            ConvertFrom( SfxMedium &rMedium );
99     SW_DLLPRIVATE virtual sal_Bool            ConvertTo( SfxMedium &rMedium );
100     SW_DLLPRIVATE virtual sal_Bool SaveAs( SfxMedium& rMedium );
101     SW_DLLPRIVATE virtual sal_Bool SaveCompleted( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage );
102 
103 	SW_DLLPRIVATE virtual sal_uInt16			PrepareClose( sal_Bool bUI = sal_True, sal_Bool bForBrowsing = sal_False );
104 
105 	// DocInfo dem Doc melden
106 	//
107 	SW_DLLPRIVATE virtual SfxDocumentInfoDialog* CreateDocumentInfoDialog(
108 									Window *pParent, const SfxItemSet &);
109 	// OLE-Geraffel
110 	SW_DLLPRIVATE virtual void			Draw( OutputDevice*, const JobSetup&, sal_uInt16);
111 
112     // Methoden fuer StyleSheets
113 
114     // @param nSlot
115     // Only used for nFamily == SFX_STYLE_FAMILY_PAGE. Identifies optional Slot by which the edit is triggered.
116     // Used to activate certain dialog pane
117     SW_DLLPRIVATE sal_uInt16 Edit(
118         const String &rName,
119         const String& rParent,
120         const sal_uInt16 nFamily,
121         sal_uInt16 nMask,
122         const sal_Bool bNew,
123         const sal_uInt16 nSlot = 0,
124         SwWrtShell* pActShell = 0,
125         const sal_Bool bBasic = sal_False );
126 
127 	SW_DLLPRIVATE sal_uInt16					Delete(const String &rName, sal_uInt16 nFamily);
128 
129     SW_DLLPRIVATE sal_uInt16 ApplyStyles(
130         const String &rName,
131         const sal_uInt16 nFamily,
132         SwWrtShell* pShell = 0,
133         const sal_uInt16 nMode = 0 );
134 
135 	SW_DLLPRIVATE sal_uInt16					DoWaterCan( const String &rName, sal_uInt16 nFamily);
136 	SW_DLLPRIVATE sal_uInt16					UpdateStyle(const String &rName, sal_uInt16 nFamily, SwWrtShell* pShell = 0);
137 	SW_DLLPRIVATE sal_uInt16					MakeByExample(const String &rName,
138 											sal_uInt16 nFamily, sal_uInt16 nMask, SwWrtShell* pShell = 0);
139 
140 	SW_DLLPRIVATE void					SubInitNew();   // fuer InitNew und HtmlSourceModus
141 
142 	SW_DLLPRIVATE void 					RemoveOLEObjects();
143 	SW_DLLPRIVATE void					CalcLayoutForOLEObjects();
144 
145     SW_DLLPRIVATE void                    Init_Impl();
146     SW_DLLPRIVATE DECL_STATIC_LINK( SwDocShell, IsLoadFinished, void* );
147 
148 
149     using SfxObjectShell::GetVisArea;
150     using SfxObjectShell::GetStyleFamilyBitmap;
151 
152 protected:
153     /// override to update text fields
154     virtual void                DoFlushDocInfo();
155 
156 public:
157     using SotObject::GetInterface;
158 
159 	// aber selbst implementieren
160 	SFX_DECL_INTERFACE(SW_DOCSHELL)
161     SFX_DECL_OBJECTFACTORY()
162 	TYPEINFO();
163 
164     static SfxInterface *_GetInterface() { return GetStaticInterface(); }
165 
166 	static rtl::OUString GetEventName( sal_Int32 nId );
167 
168 	//Das Doc wird fuer SO-Datenaustausch benoetigt!
169 	SwDocShell( SfxObjectCreateMode eMode = SFX_CREATE_MODE_EMBEDDED );
170 	SwDocShell( const sal_uInt64 i_nSfxCreationFlags );
171 	SwDocShell( SwDoc *pDoc, SfxObjectCreateMode eMode = SFX_CREATE_MODE_STANDARD );
172 	~SwDocShell();
173 
174 	// OLE 2.0-Benachrichtigung
175 	DECL_LINK( Ole2ModifiedHdl, void * );
176 
177 	// OLE-Geraffel
178 	virtual void	  SetVisArea( const Rectangle &rRect );
179 	virtual Rectangle GetVisArea( sal_uInt16 nAspect ) const;
180 	virtual Printer  *GetDocumentPrinter();
181     virtual OutputDevice* GetDocumentRefDev();
182 	virtual void	  OnDocumentPrinterChanged( Printer * pNewPrinter );
183 	virtual sal_uLong	  GetMiscStatus() const;
184 
185 	virtual void			PrepareReload();
186 	virtual void			SetModified( sal_Bool = sal_True );
187 
188 	// Dispatcher
189 	void					Execute(SfxRequest &);
190 	void					ExecStyleSheet(SfxRequest&);
191 	void					ExecDB(SfxRequest&);
192 
193 	void					GetState(SfxItemSet &);
194 	void					StateAlways(SfxItemSet &);
195 	void					StateStyleSheet(SfxItemSet&, SwWrtShell* pSh = 0 );
196 
197 	// Doc rausreichen aber VORSICHT
198     inline SwDoc*                   GetDoc() { return pDoc; }
199     inline const SwDoc*             GetDoc() const { return pDoc; }
200     IDocumentDeviceAccess*          getIDocumentDeviceAccess();
201     const IDocumentSettingAccess*   getIDocumentSettingAccess() const;
202     IDocumentChartDataProviderAccess*       getIDocumentChartDataProviderAccess();
203 
204 
205     void                    UpdateFontList();
206 	void					UpdateChildWindows();
207 
208 	// globaler IO
209 	virtual sal_Bool			Save();
210 
211 	// fuer VorlagenPI
212 	virtual SfxStyleSheetBasePool*	GetStyleSheetPool();
213 
214 	// Fuer Organizer
215 	virtual sal_Bool Insert(SfxObjectShell &rSource,
216 						sal_uInt16	nSourceIdx1,
217 						sal_uInt16	nSourceIdx2,
218 						sal_uInt16	nSourceIdx3,
219 						sal_uInt16& nIdx1,
220 						sal_uInt16& nIdx2,
221 						sal_uInt16& nIdx3,
222 						sal_uInt16& nRemovedIdx);
223 
224 	virtual sal_Bool Remove(sal_uInt16 nIdx1,
225 						sal_uInt16 nIdx2 = INDEX_IGNORE,
226 						sal_uInt16 nIdx3 = INDEX_IGNORE);
227 
228 	virtual Bitmap 		GetStyleFamilyBitmap( SfxStyleFamily eFamily, BmpColorMode eColorMode );
229 
230 	// View setzen fuer Aktionen ueber Shell
231 	void 		  SetView(SwView* pVw);
232 	const SwView *GetView() const { return pView; }
233     SwView       *GetView()       { return pView; }
234 
235 	// Zugriff auf die zur SwView gehoerige SwWrtShell
236 		  SwWrtShell *GetWrtShell() 	  { return pWrtShell; }
237 	const SwWrtShell *GetWrtShell() const { return pWrtShell; }
238 
239 	// fuer die Core - die kennt die DocShell aber keine WrtShell!
240 		  SwFEShell *GetFEShell();
241 	const SwFEShell *GetFEShell() const
242 				{ return ((SwDocShell*)this)->GetFEShell(); }
243 
244 
245 	// Fuer Einfuegen Dokument
246 	Reader* StartConvertFrom(SfxMedium& rMedium, SwReader** ppRdr,
247 							SwCrsrShell* pCrsrSh = 0, SwPaM* pPaM = 0);
248 
249 	virtual long DdeGetData( const String& rItem, const String& rMimeType,
250 							 ::com::sun::star::uno::Any & rValue );
251 	virtual long DdeSetData( const String& rItem, const String& rMimeType,
252 								const ::com::sun::star::uno::Any & rValue );
253     virtual ::sfx2::SvLinkSource* DdeCreateLinkSource( const String& rItem );
254 	virtual void FillClass( SvGlobalName * pClassName,
255 								   sal_uInt32 * pClipFormat,
256 								   String * pAppName,
257 								   String * pLongUserName,
258                                    String * pUserName,
259                                    sal_Int32 nFileFormat,
260                                    sal_Bool bTemplate = sal_False ) const;
261 
262 	virtual void LoadStyles( SfxObjectShell& rSource );
263 
264     void _LoadStyles( SfxObjectShell& rSource, sal_Bool bPreserveCurrentDocument );
265 
266     // Show page style format dialog
267     // @param nSlot
268     // Identifies slot by which the dialog is triggered. Used to activate certain dialog pane
269     void FormatPage(
270         const String& rPage,
271         const sal_uInt16 nSlot,
272         SwWrtShell& rActShell );
273 
274     // --> OD 2006-11-07 #i59688#
275     // linked graphics are now loaded on demand.
276     // Thus, loading of linked graphics no longer needed and necessary for
277     // the load of document being finished.
278 //    // Timer starten fuers ueberpruefen der Grafik-Links. Sind alle
279 //    // vollstaendig geladen, dann ist das Doc fertig
280 //    void StartLoadFinishedTimer();
281     void LoadingFinished();
282     // <--
283 
284 	// eine Uebertragung wird abgebrochen (wird aus dem SFX gerufen)
285 	virtual void CancelTransfers();
286 
287 	// Doc aus Html-Source neu laden
288 	void	ReloadFromHtml( const String& rStreamName, SwSrcView* pSrcView );
289 
290     sal_Int16   GetUpdateDocMode() const {return nUpdateDocMode;}
291 
292 	void ToggleBrowserMode(sal_Bool bOn, SwView* pView);
293 
294 	sal_uLong LoadStylesFromFile( const String& rURL, SwgReaderOption& rOpt,
295 								sal_Bool bUnoCall );
296 	void InvalidateModel();
297 	void ReactivateModel();
298 
299 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >	GetEventNames();
300 
301     // --> FME 2004-08-05 #i20883# Digital Signatures and Encryption
302     virtual sal_uInt16 GetHiddenInformationState( sal_uInt16 nStates );
303     // <--
304 
305     // --> FME 2005-02-25 #i42634# Overwrites SfxObjectShell::UpdateLinks
306     // This new function is necessary to trigger update of links in docs
307     // read by the binary filter:
308     virtual void UpdateLinks();
309     // <--
310 	virtual void setDocAccTitle( const String& rTitle );
311 	virtual const String getDocAccTitle() const;
312 
313 	void setDocReadOnly( sal_Bool bReadOnly);
314 	sal_Bool getDocReadOnly() const;
315     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >
316                                 GetController();
317 
318     SfxInPlaceClient* GetIPClient( const ::svt::EmbeddedObjectRef& xObjRef );
319 
320     virtual const ::sfx2::IXmlIdRegistry* GetXmlIdRegistry() const;
321 
322     // passwword protection for Writer (derived from SfxObjectShell)
323     // see also:    FN_REDLINE_ON, FN_REDLINE_ON
324     virtual bool    IsChangeRecording() const;
325     virtual bool    HasChangeRecordProtection() const;
326     virtual void    SetChangeRecording( bool bActivate );
327     virtual bool    SetProtectionPassword( const String &rPassword );
328     virtual bool    GetProtectionHash( /*out*/ ::com::sun::star::uno::Sequence< sal_Int8 > &rPasswordHash );
329 };
330 
331 class Graphic;
332 //implemented in source/ui/docvw/romenu.cxx
333 String ExportGraphic( const Graphic &rGraphic, const String &rGrfName );
334 
335 #endif
336