1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef _SWDOCSH_HXX 28 #define _SWDOCSH_HXX 29 30 #include <rtl/ref.hxx> 31 #include <com/sun/star/frame/XController.hpp> 32 #include <com/sun/star/uno/Sequence.h> 33 #include <vcl/timer.hxx> 34 #include <sfx2/docfac.hxx> 35 #include <sfx2/objsh.hxx> 36 #include "swdllapi.h" 37 #include <swdll.hxx> 38 #include <shellid.hxx> 39 40 #include <svl/lstner.hxx> 41 #include <svtools/embedhlp.hxx> 42 43 class SwDoc; 44 class SfxDocumentInfoDialog; 45 class SfxStyleSheetBasePool; 46 class SfxInPlaceClient; 47 class FontList; 48 class SwView; 49 class SwWrtShell; 50 class SwFEShell; 51 class Reader; 52 class SwReader; 53 class SwCrsrShell; 54 class SwSrcView; 55 class SwPaM; 56 class SwgReaderOption; 57 class SwOLEObj; 58 class IDocumentDeviceAccess; 59 class IDocumentSettingAccess; 60 class IDocumentTimerAccess; 61 class IDocumentChartDataProviderAccess; 62 63 64 class SW_DLLPUBLIC SwDocShell: public SfxObjectShell, public SfxListener 65 { 66 SwDoc* pDoc; // Document 67 rtl::Reference< SfxStyleSheetBasePool > mxBasePool; // Durchreiche fuer Formate 68 FontList* pFontList; // aktuelle FontListe 69 70 // Nix geht ohne die WrtShell (historische Gruende) 71 // RuekwaertsPointer auf die View (historische Gruende) 72 // Dieser gilt solange bis im Activate ein neuer gesetzt wird 73 // oder dieser im Dtor der View geloescht wird 74 // 75 SwView* pView; 76 SwWrtShell* pWrtShell; 77 78 Timer aFinishedTimer; // Timer fuers ueberpriefen der 79 // Grafik-Links. Sind alle da, 80 // dann ist Doc voll. geladen 81 82 //SvPersistRef xOLEChildList; // fuers RemoveOLEObjects 83 comphelper::EmbeddedObjectContainer* pOLEChildList; 84 sal_Int16 nUpdateDocMode; // contains the com::sun::star::document::UpdateDocMode 85 bool bInUpdateFontList; //prevent nested calls of UpdateFontList 86 // Methoden fuer den Zugriff aufs Doc 87 SW_DLLPRIVATE void AddLink(); 88 SW_DLLPRIVATE void RemoveLink(); 89 90 // Hint abfangen fuer DocInfo 91 SW_DLLPRIVATE virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); 92 93 // FileIO 94 SW_DLLPRIVATE virtual sal_Bool InitNew( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage ); 95 SW_DLLPRIVATE virtual sal_Bool Load( SfxMedium& rMedium ); 96 SW_DLLPRIVATE virtual sal_Bool LoadFrom( SfxMedium& rMedium ); 97 SW_DLLPRIVATE virtual sal_Bool ConvertFrom( SfxMedium &rMedium ); 98 SW_DLLPRIVATE virtual sal_Bool ConvertTo( SfxMedium &rMedium ); 99 SW_DLLPRIVATE virtual sal_Bool SaveAs( SfxMedium& rMedium ); 100 SW_DLLPRIVATE virtual sal_Bool SaveCompleted( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage ); 101 102 SW_DLLPRIVATE virtual sal_uInt16 PrepareClose( sal_Bool bUI = sal_True, sal_Bool bForBrowsing = sal_False ); 103 104 // DocInfo dem Doc melden 105 // 106 SW_DLLPRIVATE virtual SfxDocumentInfoDialog* CreateDocumentInfoDialog( 107 Window *pParent, const SfxItemSet &); 108 // OLE-Geraffel 109 SW_DLLPRIVATE virtual void Draw( OutputDevice*, const JobSetup&, sal_uInt16); 110 111 // Methoden fuer StyleSheets 112 SW_DLLPRIVATE sal_uInt16 Edit( const String &rName, const String& rParent, sal_uInt16 nFamily, 113 sal_uInt16 nMask, sal_Bool bNew, 114 sal_Bool bColumn = sal_False, 115 SwWrtShell* pActShell = 0, 116 sal_Bool bBasic = sal_False ); 117 SW_DLLPRIVATE sal_uInt16 Delete(const String &rName, sal_uInt16 nFamily); 118 SW_DLLPRIVATE sal_uInt16 ApplyStyles(const String &rName, sal_uInt16 nFamily, SwWrtShell* pShell = 0, 119 sal_uInt16 nMode = 0 ); 120 SW_DLLPRIVATE sal_uInt16 DoWaterCan( const String &rName, sal_uInt16 nFamily); 121 SW_DLLPRIVATE sal_uInt16 UpdateStyle(const String &rName, sal_uInt16 nFamily, SwWrtShell* pShell = 0); 122 SW_DLLPRIVATE sal_uInt16 MakeByExample(const String &rName, 123 sal_uInt16 nFamily, sal_uInt16 nMask, SwWrtShell* pShell = 0); 124 125 SW_DLLPRIVATE void InitDraw(); 126 SW_DLLPRIVATE void SubInitNew(); // fuer InitNew und HtmlSourceModus 127 128 SW_DLLPRIVATE void RemoveOLEObjects(); 129 SW_DLLPRIVATE void CalcLayoutForOLEObjects(); 130 131 SW_DLLPRIVATE void Init_Impl(); 132 SW_DLLPRIVATE DECL_STATIC_LINK( SwDocShell, IsLoadFinished, void* ); 133 134 135 using SfxObjectShell::GetVisArea; 136 using SfxObjectShell::GetStyleFamilyBitmap; 137 138 protected: 139 /// override to update text fields 140 virtual void DoFlushDocInfo(); 141 142 public: 143 using SotObject::GetInterface; 144 145 // aber selbst implementieren 146 SFX_DECL_INTERFACE(SW_DOCSHELL) 147 SFX_DECL_OBJECTFACTORY() 148 TYPEINFO(); 149 150 static SfxInterface *_GetInterface() { return GetStaticInterface(); } 151 152 static rtl::OUString GetEventName( sal_Int32 nId ); 153 154 //Das Doc wird fuer SO-Datenaustausch benoetigt! 155 SwDocShell( SfxObjectCreateMode eMode = SFX_CREATE_MODE_EMBEDDED ); 156 SwDocShell( const sal_uInt64 i_nSfxCreationFlags ); 157 SwDocShell( SwDoc *pDoc, SfxObjectCreateMode eMode = SFX_CREATE_MODE_STANDARD ); 158 ~SwDocShell(); 159 160 // OLE 2.0-Benachrichtigung 161 DECL_LINK( Ole2ModifiedHdl, void * ); 162 163 // OLE-Geraffel 164 virtual void SetVisArea( const Rectangle &rRect ); 165 virtual Rectangle GetVisArea( sal_uInt16 nAspect ) const; 166 virtual Printer *GetDocumentPrinter(); 167 virtual OutputDevice* GetDocumentRefDev(); 168 virtual void OnDocumentPrinterChanged( Printer * pNewPrinter ); 169 virtual sal_uLong GetMiscStatus() const; 170 171 virtual void PrepareReload(); 172 virtual void SetModified( sal_Bool = sal_True ); 173 174 // Dispatcher 175 void Execute(SfxRequest &); 176 void ExecStyleSheet(SfxRequest&); 177 void ExecDB(SfxRequest&); 178 179 void GetState(SfxItemSet &); 180 void StateAlways(SfxItemSet &); 181 void StateStyleSheet(SfxItemSet&, SwWrtShell* pSh = 0 ); 182 183 // Doc rausreichen aber VORSICHT 184 inline SwDoc* GetDoc() { return pDoc; } 185 inline const SwDoc* GetDoc() const { return pDoc; } 186 IDocumentDeviceAccess* getIDocumentDeviceAccess(); 187 const IDocumentSettingAccess* getIDocumentSettingAccess() const; 188 IDocumentChartDataProviderAccess* getIDocumentChartDataProviderAccess(); 189 190 191 void UpdateFontList(); 192 void UpdateChildWindows(); 193 194 // globaler IO 195 virtual sal_Bool Save(); 196 197 // fuer VorlagenPI 198 virtual SfxStyleSheetBasePool* GetStyleSheetPool(); 199 200 // Fuer Organizer 201 virtual sal_Bool Insert(SfxObjectShell &rSource, 202 sal_uInt16 nSourceIdx1, 203 sal_uInt16 nSourceIdx2, 204 sal_uInt16 nSourceIdx3, 205 sal_uInt16& nIdx1, 206 sal_uInt16& nIdx2, 207 sal_uInt16& nIdx3, 208 sal_uInt16& nRemovedIdx); 209 210 virtual sal_Bool Remove(sal_uInt16 nIdx1, 211 sal_uInt16 nIdx2 = INDEX_IGNORE, 212 sal_uInt16 nIdx3 = INDEX_IGNORE); 213 214 virtual Bitmap GetStyleFamilyBitmap( SfxStyleFamily eFamily, BmpColorMode eColorMode ); 215 216 // View setzen fuer Aktionen ueber Shell 217 void SetView(SwView* pVw); 218 const SwView *GetView() const { return pView; } 219 SwView *GetView() { return pView; } 220 221 // Zugriff auf die zur SwView gehoerige SwWrtShell 222 SwWrtShell *GetWrtShell() { return pWrtShell; } 223 const SwWrtShell *GetWrtShell() const { return pWrtShell; } 224 225 // fuer die Core - die kennt die DocShell aber keine WrtShell! 226 SwFEShell *GetFEShell(); 227 const SwFEShell *GetFEShell() const 228 { return ((SwDocShell*)this)->GetFEShell(); } 229 230 231 // Fuer Einfuegen Dokument 232 Reader* StartConvertFrom(SfxMedium& rMedium, SwReader** ppRdr, 233 SwCrsrShell* pCrsrSh = 0, SwPaM* pPaM = 0); 234 235 virtual long DdeGetData( const String& rItem, const String& rMimeType, 236 ::com::sun::star::uno::Any & rValue ); 237 virtual long DdeSetData( const String& rItem, const String& rMimeType, 238 const ::com::sun::star::uno::Any & rValue ); 239 virtual ::sfx2::SvLinkSource* DdeCreateLinkSource( const String& rItem ); 240 virtual void FillClass( SvGlobalName * pClassName, 241 sal_uInt32 * pClipFormat, 242 String * pAppName, 243 String * pLongUserName, 244 String * pUserName, 245 sal_Int32 nFileFormat, 246 sal_Bool bTemplate = sal_False ) const; 247 248 virtual void LoadStyles( SfxObjectShell& rSource ); 249 250 void _LoadStyles( SfxObjectShell& rSource, sal_Bool bPreserveCurrentDocument ); 251 252 // Seitenvorlagedialog anzeigen, ggf. auf Spaltenpage 253 void FormatPage( const String& rPage, 254 sal_Bool bColumn = sal_False, 255 SwWrtShell* pActShell = 0 ); 256 257 // --> OD 2006-11-07 #i59688# 258 // linked graphics are now loaded on demand. 259 // Thus, loading of linked graphics no longer needed and necessary for 260 // the load of document being finished. 261 // // Timer starten fuers ueberpruefen der Grafik-Links. Sind alle 262 // // vollstaendig geladen, dann ist das Doc fertig 263 // void StartLoadFinishedTimer(); 264 void LoadingFinished(); 265 // <-- 266 267 // eine Uebertragung wird abgebrochen (wird aus dem SFX gerufen) 268 virtual void CancelTransfers(); 269 270 // Doc aus Html-Source neu laden 271 void ReloadFromHtml( const String& rStreamName, SwSrcView* pSrcView ); 272 273 sal_Int16 GetUpdateDocMode() const {return nUpdateDocMode;} 274 275 //Activate wait cursor for all windows of this document 276 //Optionally all dispatcher could be Locked 277 //Usually locking should be done using the class: SwWaitObject! 278 void EnterWait( sal_Bool bLockDispatcher ); 279 void LeaveWait( sal_Bool bLockDispatcher ); 280 281 void ToggleBrowserMode(sal_Bool bOn, SwView* pView); 282 283 sal_uLong LoadStylesFromFile( const String& rURL, SwgReaderOption& rOpt, 284 sal_Bool bUnoCall ); 285 void InvalidateModel(); 286 void ReactivateModel(); 287 288 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > GetEventNames(); 289 290 // --> FME 2004-08-05 #i20883# Digital Signatures and Encryption 291 virtual sal_uInt16 GetHiddenInformationState( sal_uInt16 nStates ); 292 // <-- 293 294 // --> FME 2005-02-25 #i42634# Overwrites SfxObjectShell::UpdateLinks 295 // This new function is necessary to trigger update of links in docs 296 // read by the binary filter: 297 virtual void UpdateLinks(); 298 // <-- 299 300 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > 301 GetController(); 302 303 SfxInPlaceClient* GetIPClient( const ::svt::EmbeddedObjectRef& xObjRef ); 304 305 virtual const ::sfx2::IXmlIdRegistry* GetXmlIdRegistry() const; 306 307 // passwword protection for Writer (derived from SfxObjectShell) 308 // see also: FN_REDLINE_ON, FN_REDLINE_ON 309 virtual bool IsChangeRecording() const; 310 virtual bool HasChangeRecordProtection() const; 311 virtual void SetChangeRecording( bool bActivate ); 312 virtual bool SetProtectionPassword( const String &rPassword ); 313 virtual bool GetProtectionHash( /*out*/ ::com::sun::star::uno::Sequence< sal_Int8 > &rPasswordHash ); 314 }; 315 316 class Graphic; 317 //implemented in source/ui/docvw/romenu.cxx 318 String ExportGraphic( const Graphic &rGraphic, const String &rGrfName ); 319 320 #endif 321