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