xref: /aoo42x/main/sw/inc/shellio.hxx (revision cdf0e10c)
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 SW_SHELLIO_HXX
28 #define SW_SHELLIO_HXX
29 
30 #include <memory>
31 #include <boost/utility.hpp>
32 
33 #include <com/sun/star/uno/Reference.h>
34 #include <com/sun/star/embed/XStorage.hpp>
35 #include <sfx2/docfile.hxx>
36 #include <sfx2/fcontnr.hxx>
37 #include <sot/formats.hxx>
38 #include <sot/storage.hxx>
39 #include <svtools/parhtml.hxx>
40 #include <tools/string.hxx>
41 #include <tools/date.hxx>
42 #include <tools/time.hxx>
43 #include <tools/datetime.hxx>
44 #include <tools/ref.hxx>
45 #include <tools/urlobj.hxx>
46 #include <swdllapi.h>
47 #include <swtypes.hxx>
48 #include <docfac.hxx>	// SwDocFac
49 #include <errhdl.hxx>
50 #include <iodetect.hxx>
51 
52 // einige Forward - Deklarationen
53 class SfxFilterContainer;
54 class SfxFilter;
55 class SfxItemPool;
56 class SfxItemSet;
57 class SfxMedium;
58 class SvPtrarr;
59 class SvStream;
60 class SvStrings;
61 class SvxFontItem;
62 class SvxMacroTableDtor;
63 //class Sw3Io;
64 class SwCntntNode;
65 class SwCrsrShell;
66 class SwDoc;
67 class SwPaM;
68 class SwTextBlocks;
69 struct SwPosition;
70 struct Writer_Impl;
71 
72 // ab so vielen chars wird ein mit einem ASCII/W4W-Reader eingelesener
73 // Absatz zwangsweise umgebrochen. Muss immer groesser als 200 sein !!!
74 #define MAX_ASCII_PARA 10000
75 
76 
77 class SW_DLLPUBLIC SwAsciiOptions
78 {
79 	String sFont;
80 	rtl_TextEncoding eCharSet;
81 	sal_uInt16 nLanguage;
82 	LineEnd eCRLF_Flag;
83 
84 public:
85 
86 	const String& GetFontName() const { return sFont; }
87 	void SetFontName( const String& rFont ) { sFont = rFont; }
88 
89 	rtl_TextEncoding GetCharSet() const { return eCharSet; }
90 	void SetCharSet( rtl_TextEncoding nVal ) { eCharSet = nVal; }
91 
92 	sal_uInt16 GetLanguage() const { return nLanguage; }
93 	void SetLanguage( sal_uInt16 nVal ) { nLanguage = nVal; }
94 
95 	LineEnd GetParaFlags() const { return eCRLF_Flag; }
96 	void SetParaFlags( LineEnd eVal ) { eCRLF_Flag = eVal; }
97 
98 	void Reset()
99 	{
100 		sFont.Erase();
101 		eCRLF_Flag = GetSystemLineEnd();
102 		eCharSet = ::gsl_getSystemTextEncoding();
103 		nLanguage = 0;
104 	}
105 	// for the automatic conversion (mail/news/...)
106 	void ReadUserData( const String& );
107 	void WriteUserData( String& );
108 
109 	SwAsciiOptions() { Reset(); }
110 };
111 
112 /**************** SwReader/Reader ************************/
113 // Basisklasse der moeglichen Optionen fuer einen speziellen Reader
114 class Reader;
115 // Ruft den Reader mit seinen Optionen, Dokument, Cursor etc.
116 class SwReader;
117 // SwRead ist der Pointer auf die Read-Optionen-Basisklasse
118 typedef Reader *SwRead;
119 
120 class SwgReaderOption
121 {
122 	SwAsciiOptions aASCIIOpts;
123 	union
124 	{
125 		sal_Bool bFmtsOnly;
126 		struct
127 		{
128 			sal_Bool bFrmFmts: 1;
129 			sal_Bool bPageDescs: 1;
130 			sal_Bool bTxtFmts: 1;
131 			sal_Bool bNumRules: 1;
132 			sal_Bool bMerge:1;
133 		}  Fmts;
134 	} What;
135 
136 public:
137 	void ResetAllFmtsOnly() { What.bFmtsOnly = 0; }
138     sal_Bool IsFmtsOnly() const { return What.bFmtsOnly; }
139 
140 	sal_Bool IsFrmFmts() const { return What.Fmts.bFrmFmts; }
141 	void SetFrmFmts( const sal_Bool bNew) { What.Fmts.bFrmFmts = bNew; }
142 
143 	sal_Bool IsPageDescs() const { return What.Fmts.bPageDescs; }
144 	void SetPageDescs( const sal_Bool bNew) { What.Fmts.bPageDescs = bNew; }
145 
146 	sal_Bool IsTxtFmts() const { return What.Fmts.bTxtFmts; }
147 	void SetTxtFmts( const sal_Bool bNew) { What.Fmts.bTxtFmts = bNew; }
148 
149 	sal_Bool IsNumRules() const { return What.Fmts.bNumRules; }
150 	void SetNumRules( const sal_Bool bNew) { What.Fmts.bNumRules = bNew; }
151 
152 	sal_Bool IsMerge() const { return What.Fmts.bMerge; }
153 	void SetMerge( const sal_Bool bNew ) { What.Fmts.bMerge = bNew; }
154 
155 	const SwAsciiOptions& GetASCIIOpts() const { return aASCIIOpts; }
156 	void SetASCIIOpts( const SwAsciiOptions& rOpts ) { aASCIIOpts = rOpts; }
157 	void ResetASCIIOpts() { aASCIIOpts.Reset(); }
158 
159 	SwgReaderOption()
160 	{	ResetAllFmtsOnly(); aASCIIOpts.Reset(); }
161 };
162 
163 class SwReader: public SwDocFac
164 {
165 	SvStream* pStrm;
166     SotStorageRef pStg;
167     com::sun::star::uno::Reference < com::sun::star::embed::XStorage > xStg;
168 	SfxMedium* pMedium;		// wer ein Medium haben will (W4W)
169 
170 	SwPaM* pCrsr;
171 	String aFileName;
172     String sBaseURL;
173 
174 public:
175 	/*
176 	 * Initiales Einlesen. Dokument wird erst beim Read(..) angelegt.
177 	 * JP 25.04.95: oder falls es mitgegeben wird, in dieses.
178 	 *				Sonderfall fuer Load mit Sw3Reader
179 	 */
180     //SwReader( SotStorage&, const String& rFilename, SwDoc *pDoc = 0 );
181     //SwReader( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >&, const String& rFilename, SwDoc *pDoc = 0 );
182     SwReader( SfxMedium&, const String& rFilename, SwDoc *pDoc = 0 );
183 	/*
184 	 * In ein existierendes Dokument einlesen, Dokument und
185 	 * Position im Dokument werden aus dem SwPaM uebernommen.
186 	 */
187     SwReader( SvStream&, const String& rFilename, const String& rBaseURL, SwPaM& );
188     //SwReader( SotStorage&, const String& rFilename, SwPaM& );
189 	SwReader( SfxMedium&, const String& rFilename, SwPaM& );
190     SwReader( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >&, const String& rFilename, SwPaM& );
191 
192 	/*
193  	* Nur SwReader::Read(...) ist die Export-Schnittstelle!!!
194  	*/
195 	sal_Bool NeedsPasswd( const Reader& );
196 	sal_Bool CheckPasswd( const String&, const Reader& );
197 	sal_uLong Read( const Reader& );
198 
199 	// ask for glossaries
200 	sal_Bool HasGlossaries( const Reader& );
201 	sal_Bool ReadGlossaries( const Reader&, SwTextBlocks&, sal_Bool bSaveRelFiles );
202 
203     const String&       GetBaseURL() const { return sBaseURL;}
204 
205 protected:
206     void                SetBaseURL( const String& rURL ) { sBaseURL = rURL; }
207 };
208 
209 
210 
211 /*  */
212 /****************  SPEZIELLE Reader ************************/
213 
214 // spezielle - Reader koennen beides sein !! (Excel, W4W, .. )
215 #define SW_STREAM_READER	1
216 #define SW_STORAGE_READER	2
217 
218 class SW_DLLPUBLIC Reader
219 {
220 	friend class SwReader;
221 	SwDoc* pTemplate;
222 	String aTemplateNm;
223     //String sBaseURL;
224 
225     Date aDStamp;
226 	Time aTStamp;
227 	DateTime aChkDateTime;
228 
229 protected:
230 	SvStream* pStrm;
231     SotStorageRef pStg;
232     com::sun::star::uno::Reference < com::sun::star::embed::XStorage > xStg;
233 	SfxMedium* pMedium;		// wer ein Medium haben will (W4W)
234 
235 	SwgReaderOption aOpt;
236 	sal_Bool bInsertMode : 1;
237 	sal_Bool bTmplBrowseMode : 1;
238 	sal_Bool bReadUTF8: 1;		// Stream als UTF-8 interpretieren
239 	sal_Bool bBlockMode: 1;
240 	sal_Bool bOrganizerMode : 1;
241 	sal_Bool bHasAskTemplateName : 1;
242     sal_Bool bIgnoreHTMLComments : 1;
243 
244 	virtual String GetTemplateName() const;
245 
246 public:
247 	Reader();
248 	virtual ~Reader();
249 
250 	virtual int GetReaderType();
251 	SwgReaderOption& GetReaderOpt() { return aOpt; }
252 
253 	virtual void SetFltName( const String& rFltNm );
254 	static void SetNoOutlineNum( SwDoc& rDoc );
255 
256 	// den Item-Set eines Frm-Formats an das alte Format anpassen
257 	static void ResetFrmFmtAttrs( SfxItemSet &rFrmSet );
258 
259 	// die Rahmen-/Grafik-/OLE-Vorlagen an das alte Format (ohne
260 	// Umrandung etc.) anpassen
261 	static void ResetFrmFmts( SwDoc& rDoc );
262 
263 	// Die Filter-Vorlage laden, setzen und wieder freigeben
264 	SwDoc* GetTemplateDoc();
265 	sal_Bool SetTemplate( SwDoc& rDoc );
266 	void ClearTemplate();
267 	void SetTemplateName( const String& rDir );
268 	void MakeHTMLDummyTemplateDoc();
269 
270     sal_Bool IsReadUTF8() const { return bReadUTF8; }
271 	void SetReadUTF8( sal_Bool bSet ) { bReadUTF8 = bSet; }
272 
273     sal_Bool IsBlockMode() const { return bBlockMode; }
274 	void SetBlockMode( sal_Bool bSet ) { bBlockMode = bSet; }
275 
276     sal_Bool IsOrganizerMode() const { return bOrganizerMode; }
277 	void SetOrganizerMode( sal_Bool bSet ) { bOrganizerMode = bSet; }
278 
279     void SetIgnoreHTMLComments( sal_Bool bSet ) { bIgnoreHTMLComments = bSet; }
280 
281 	virtual sal_Bool HasGlossaries() const;
282 	virtual sal_Bool ReadGlossaries( SwTextBlocks&, sal_Bool bSaveRelFiles ) const;
283 
284 	// read the sections of the document, which is equal to the medium.
285 	// returns the count of it
286 	virtual sal_uInt16 GetSectionList( SfxMedium& rMedium,
287 									SvStrings& rStrings ) const;
288 
289 	SotStorageRef getSotStorageRef() { return pStg; };
290     void setSotStorageRef(SotStorageRef pStgRef) { pStg = pStgRef; };
291 
292 private:
293     virtual sal_uLong Read(SwDoc &, const String& rBaseURL, SwPaM &,const String &)=0;
294 
295 	// alle die die Streams / Storages nicht geoeffnet brauchen,
296 	// muessen die Methode ueberladen (W4W!!)
297 	virtual int SetStrmStgPtr();
298 };
299 
300 class AsciiReader: public Reader
301 {
302 	friend class SwReader;
303     virtual sal_uLong Read( SwDoc &, const String& rBaseURL, SwPaM &,const String &);
304 public:
305 	AsciiReader(): Reader() {}
306 };
307 
308 /*class SwgReader: public Reader
309 {
310     virtual sal_uLong Read( SwDoc &, const String& rBaseURL, SwPaM &,const String &);
311 };
312 */
313 class SW_DLLPUBLIC StgReader : public Reader
314 {
315 	String aFltName;
316 
317 protected:
318     sal_uLong OpenMainStream( SotStorageStreamRef& rRef, sal_uInt16& rBuffSize );
319 
320 public:
321 	virtual int GetReaderType();
322     const String& GetFltName() { return aFltName; }
323 	virtual void SetFltName( const String& r );
324 };
325 
326 
327 /*class Sw3Reader : public StgReader
328 {
329 	Sw3Io* pIO;
330     virtual sal_uLong Read( SwDoc &, const String& rBaseURL, SwPaM &,const String &);
331 public:
332 	Sw3Reader() : pIO( 0 ) {}
333 
334     void   SetSw3Io( Sw3Io* pIo )     { pIO = pIo; }
335 
336 	// read the sections of the document, which is equal to the medium.
337 	// returns the count of it
338 	virtual sal_uInt16 GetSectionList( SfxMedium& rMedium,
339 								SvStrings& rStrings ) const;
340 };*/
341 
342 /*  */
343 ////////////////////////////////////////////////////////////////////////////
344 
345 // Der uebergebene Stream muss dynamisch angelegt werden und
346 // vor dem Loeschen der Instanz per Stream() angefordert
347 // und geloescht werden!
348 
349 class SwImpBlocks;
350 
351 class SW_DLLPUBLIC SwTextBlocks
352 {
353 //  friend class Sw2TextBlocks;
354 //  friend class Sw3IoImp;
355 	SwImpBlocks* pImp;
356 	sal_uLong 		 nErr;
357 
358 public:
359 	SwTextBlocks( const String& );
360 	~SwTextBlocks();
361 
362     void Flush(){}
363 
364 	SwDoc* GetDoc();
365 	void   ClearDoc();					// Doc-Inhalt loeschen
366 	const  String& GetName();
367 	void   SetName( const String& );
368 	sal_uLong GetError() const { return nErr; }
369 
370     String GetBaseURL() const;
371     void   SetBaseURL( const String& rURL );
372 
373 	sal_Bool   IsOld() const;
374 	sal_uLong  ConvertToNew();				// Textbausteine konvertieren
375 
376 	sal_uInt16 GetCount() const;						// Anzahl Textbausteine ermitteln
377 	sal_uInt16 GetIndex( const String& ) const;			// Index fuer Kurznamen ermitteln
378 	sal_uInt16 GetLongIndex( const String& ) const;		//Index fuer Langnamen ermitteln
379 	const  String& GetShortName( sal_uInt16 ) const; 	// Kurzname fuer Index zurueck
380 	const  String& GetLongName( sal_uInt16 ) const;  	// Langname fuer Index zurueck
381 
382 	sal_Bool   Delete( sal_uInt16 );			// Loeschen
383 	sal_uInt16 Rename( sal_uInt16, const String*, const String* ); // Umbenennen
384 	sal_uLong  CopyBlock( SwTextBlocks& rSource, String& rSrcShort,
385 									const String& rLong ); // Block kopieren
386 
387 	sal_Bool   BeginGetDoc( sal_uInt16 );			// Textbaustein einlesen
388 	void   EndGetDoc();						// Textbaustein wieder loslassen
389 
390 	sal_Bool   BeginPutDoc( const String&, const String& ); // Speichern Beginn
391 	sal_uInt16 PutDoc(); 								// Speichern Ende
392 
393 	sal_uInt16 PutText( const String&, const String&, const String& ); // Speichern( Kurzn., Text)
394 
395 	sal_Bool IsOnlyTextBlock( sal_uInt16 ) const;
396 	sal_Bool IsOnlyTextBlock( const String& rShort ) const;
397 
398 	const String& GetFileName() const;		// Dateiname von pImp
399 	sal_Bool IsReadOnly() const;  				// ReadOnly-Flag von pImp
400 
401 	sal_Bool GetMacroTable( sal_uInt16 nIdx, SvxMacroTableDtor& rMacroTbl );
402 	sal_Bool SetMacroTable( sal_uInt16 nIdx, const SvxMacroTableDtor& rMacroTbl );
403 
404     sal_Bool StartPutMuchBlockEntries();
405 	void EndPutMuchBlockEntries();
406 };
407 
408 // BEGIN source/filter/basflt/fltini.cxx
409 
410 extern void _InitFilter();
411 extern void _FinitFilter();
412 
413 extern SwRead ReadAscii, /*ReadSwg, ReadSw3, */ReadHTML, ReadXML;
414 
415 //SW_DLLPUBLIC SwRead SwGetReaderSw3();
416 SW_DLLPUBLIC SwRead SwGetReaderXML();
417 
418 // END source/filter/basflt/fltini.cxx
419 
420 
421 extern sal_Bool SetHTMLTemplate( SwDoc &rDoc ); //Fuer Vorlagen aus HTML.vor laden shellio.cxx
422 
423 
424 /*  */
425 /////////////////////////////////////////////////////////////////////////////
426 
427 /*
428  * Schreiben, Writer
429  */
430 
431 
432 /* Basis-Klasse aller Writer */
433 
434 class IDocumentSettingAccess;
435 class IDocumentStylePoolAccess;
436 
437 class SW_DLLPUBLIC Writer
438     : public SvRefBase
439     , private ::boost::noncopyable
440 {
441 	SwAsciiOptions aAscOpts;
442     String          sBaseURL;
443 
444 	void _AddFontItem( SfxItemPool& rPool, const SvxFontItem& rFont );
445 	void _AddFontItems( SfxItemPool& rPool, sal_uInt16 nWhichId );
446 
447     ::std::auto_ptr<Writer_Impl> m_pImpl;
448 
449 protected:
450 
451 	SwPaM* pOrigPam;			// der letze zu bearbeitende Pam
452 	const String* pOrigFileName;
453 
454 	void ResetWriter();
455 	sal_Bool CopyNextPam( SwPaM ** );
456 
457 	void PutNumFmtFontsInAttrPool();
458 	void PutEditEngFontsInAttrPool( sal_Bool bIncl_CJK_CTL = sal_True );
459 	void PutCJKandCTLFontsInAttrPool();
460 
461 	virtual sal_uLong WriteStream() = 0;
462     void                SetBaseURL( const String& rURL ) { sBaseURL = rURL; }
463 
464     IDocumentSettingAccess* getIDocumentSettingAccess();
465     const IDocumentSettingAccess* getIDocumentSettingAccess() const;
466 
467 	IDocumentStylePoolAccess* getIDocumentStylePoolAccess();
468 	const IDocumentStylePoolAccess* getIDocumentStylePoolAccess() const;
469 
470 public:
471 	SwDoc* pDoc;
472 	SwPaM* pCurPam;
473 	sal_Bool bWriteAll : 1;
474 	sal_Bool bShowProgress : 1;
475 	sal_Bool bWriteClipboardDoc : 1;
476 	sal_Bool bWriteOnlyFirstTable : 1;
477 	sal_Bool bASCII_ParaAsCR : 1;
478 	sal_Bool bASCII_ParaAsBlanc : 1;
479 	sal_Bool bASCII_NoLastLineEnd : 1;
480 	sal_Bool bUCS2_WithStartChar : 1;
481 	sal_Bool bExportPargraphNumbering : 1;
482 
483 	sal_Bool bBlock : 1;
484 	sal_Bool bOrganizerMode : 1;
485 
486     Writer();
487 	virtual ~Writer();
488 
489 	virtual sal_uLong Write( SwPaM&, SfxMedium&, const String* = 0 );
490 			sal_uLong Write( SwPaM&, SvStream&,  const String* = 0 );
491     virtual sal_uLong Write( SwPaM&, const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >&, const String* = 0, SfxMedium* = 0 );
492     virtual sal_uLong Write( SwPaM&, SotStorage&, const String* = 0 );
493 
494 	virtual void SetPasswd( const String& );
495 	virtual void SetVersion( const String&, long );
496 	virtual sal_Bool IsStgWriter() const;
497 //  virtual sal_Bool IsSw3Writer() const;
498 
499     void SetShowProgress( sal_Bool bFlag = sal_False )  { bShowProgress = bFlag; }
500 
501 	const String* GetOrigFileName() const 		{ return pOrigFileName; }
502 
503 	const SwAsciiOptions& GetAsciiOptions() const { return aAscOpts; }
504 	void SetAsciiOptions( const SwAsciiOptions& rOpt ) { aAscOpts = rOpt; }
505 
506     const String&       GetBaseURL() const { return sBaseURL;}
507 
508     // suche die naechste Bookmark-Position aus der Bookmark-Tabelle
509 	sal_Int32 FindPos_Bkmk( const SwPosition& rPos ) const;
510 	// build a bookmark table, which is sort by the node position. The
511 	// OtherPos of the bookmarks also inserted.
512 	void CreateBookmarkTbl();
513 	// search alle Bookmarks in the range and return it in the Array
514 	sal_uInt16 GetBookmarks( const SwCntntNode& rNd,
515 						xub_StrLen nStt, xub_StrLen nEnd,
516 						SvPtrarr& rArr );
517 
518 	// lege einen neuen PaM an der Position an
519     static SwPaM * NewSwPaM(SwDoc & rDoc,
520                             sal_uLong const nStartIdx, sal_uLong const nEndIdx);
521 
522 	// kopiere ggfs. eine lokale Datei ins Internet
523 	sal_Bool CopyLocalFileToINet( String& rFileNm );
524 
525 	// Stream-spezifische Routinen, im Storage-Writer NICHT VERWENDEN!
526 
527 	// Optimierung der Ausgabe auf den Stream.
528 	SvStream& OutLong( SvStream& rStrm, long nVal );
529 	SvStream& OutULong( SvStream& rStrm, sal_uLong nVal );
530 
531 	// Hex-Zahl ausgeben, default ist 2.stellige Zahl
532 	SvStream& OutHex( SvStream& rStrm, sal_uLong nHex, sal_uInt8 nLen = 2 );
533 	// 4-st. Hex-Zahl ausgeben
534 	inline SvStream& OutHex4( SvStream& rStrm, sal_uInt16 nHex )
535 		{   return OutHex( rStrm, nHex, 4 ); }
536 
537 	inline SvStream& OutHex( sal_uInt16 nHex, sal_uInt8 nLen = 2 )      { return OutHex( Strm(), nHex, nLen ); }
538 	inline SvStream& OutHex4( sal_uInt16 nHex )     { return OutHex( Strm(), nHex, 4 ); }
539     inline SvStream& OutLong( long nVal )       { return OutLong( Strm(), nVal ); }
540 	inline SvStream& OutULong( sal_uLong nVal )		{ return OutULong( Strm(), nVal ); }
541 
542     void SetStream(SvStream *const pStream);
543 	SvStream& Strm();
544 
545     void SetOrganizerMode( sal_Bool bSet ) { bOrganizerMode = bSet; }
546 };
547 
548 #ifndef SW_DECL_WRITER_DEFINED
549 #define SW_DECL_WRITER_DEFINED
550 SV_DECL_REF(Writer)
551 #endif
552 SV_IMPL_REF(Writer)
553 
554 // Basisklasse fuer alle Storage-Writer
555 class SW_DLLPUBLIC StgWriter : public Writer
556 {
557 protected:
558 	String aFltName;
559     SotStorageRef pStg;
560     com::sun::star::uno::Reference < com::sun::star::embed::XStorage > xStg;
561 
562 	// Fehler beim Aufruf erzeugen
563 	virtual sal_uLong WriteStream();
564 	virtual sal_uLong WriteStorage() = 0;
565 	virtual sal_uLong WriteMedium( SfxMedium& ) = 0;
566 
567     using Writer::Write;
568 
569 public:
570     StgWriter() : Writer() {}
571 
572 	virtual sal_Bool IsStgWriter() const;
573 
574     virtual sal_uLong Write( SwPaM&, const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >&, const String* = 0, SfxMedium* = 0 );
575     virtual sal_uLong Write( SwPaM&, SotStorage&, const String* = 0 );
576 
577     SotStorage& GetStorage() const       { return *pStg; }
578 };
579 
580 /*class Sw3Writer : public StgWriter
581 {
582 	Sw3Io* pIO;
583 	sal_Bool bSaveAs : 1;
584 
585 	virtual sal_uLong WriteStorage();
586 	virtual sal_uLong WriteMedium( SfxMedium& );
587 
588 public:
589 	Sw3Writer() : pIO( 0 ), bSaveAs( sal_False ) {}
590 
591     virtual sal_Bool IsSw3Writer() const;
592 };
593 
594 */
595 
596 // Schnittstellenklasse fuer den allgemeinen Zugriff auf die
597 // speziellen Writer
598 
599 class SwWriter
600 {
601 	SvStream* pStrm;
602     SotStorageRef pStg;
603     com::sun::star::uno::Reference < com::sun::star::embed::XStorage > xStg;
604 	SfxMedium* pMedium;
605 
606 	SwPaM* pOutPam;
607 	SwCrsrShell *pShell;
608 	SwDoc &rDoc;
609 
610     //String sBaseURL;
611 
612     sal_Bool bWriteAll;
613 
614 public:
615 	sal_uLong Write( WriterRef& rxWriter, const String* = 0);
616 
617 	SwWriter( SvStream&, SwCrsrShell &,sal_Bool bWriteAll = sal_False );
618 	SwWriter( SvStream&, SwDoc & );
619 	SwWriter( SvStream&, SwPaM &, sal_Bool bWriteAll = sal_False );
620 
621 //  SwWriter( SotStorage&, SwCrsrShell &,sal_Bool bWriteAll = sal_False );
622     SwWriter( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >&, SwDoc& );
623 //  SwWriter( SotStorage&, SwPaM&, sal_Bool bWriteAll = sal_False );
624 
625 	SwWriter( SfxMedium&, SwCrsrShell &,sal_Bool bWriteAll = sal_False );
626 	SwWriter( SfxMedium&, SwDoc & );
627 //	SwWriter( SfxMedium&, SwPaM&, sal_Bool bWriteAll = sal_False );
628 
629     //const String&       GetBaseURL() const { return sBaseURL;}
630 };
631 
632 
633 /*  */
634 /////////////////////////////////////////////////////////////////////////////
635 
636 typedef Reader* (*FnGetReader)();
637 typedef void (*FnGetWriter)(const String&, const String& rBaseURL, WriterRef&);
638 sal_uLong SaveOrDelMSVBAStorage( SfxObjectShell&, SotStorage&, sal_Bool, const String& );
639 sal_uLong GetSaveWarningOfMSVBAStorage( SfxObjectShell &rDocS );
640 
641 struct SwReaderWriterEntry
642 {
643     Reader* pReader;
644     FnGetReader fnGetReader;
645     FnGetWriter fnGetWriter;
646     sal_Bool bDelReader;
647 
648     SwReaderWriterEntry( const FnGetReader fnReader, const FnGetWriter fnWriter, sal_Bool bDel )
649         : pReader( NULL ), fnGetReader( fnReader ), fnGetWriter( fnWriter ), bDelReader( bDel )
650     {}
651 
652     /// Get access to the reader
653     Reader* GetReader();
654 
655     /// Get access to the writer
656     void GetWriter( const String& rNm, const String& rBaseURL, WriterRef& xWrt ) const;
657 };
658 
659 namespace SwReaderWriter
660 {
661     /// Return reader based on ReaderWriterEnum
662     Reader* GetReader( ReaderWriterEnum eReader );
663 
664     /// Return reader based on the name
665     Reader* GetReader( const String& rFltName );
666 
667     /// Return writer based on the name
668     void GetWriter( const String& rFltName, const String& rBaseURL, WriterRef& xWrt );
669 }
670 
671 void GetRTFWriter( const String&, const String&, WriterRef& );
672 void GetASCWriter( const String&, const String&, WriterRef& );
673 //void GetSw3Writer( const String&, const String&, WriterRef& );
674 void GetHTMLWriter( const String&, const String&, WriterRef& );
675 void GetXMLWriter( const String&, const String&, WriterRef& );
676 void GetWW8Writer( const String&, const String&, WriterRef& );
677 
678 #endif
679