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