xref: /trunk/main/sw/inc/shellio.hxx (revision 3889ad56cf56600b438207a3bbd5c17d99696d8f)
11d2dbeb0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
31d2dbeb0SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
41d2dbeb0SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
51d2dbeb0SAndrew Rist  * distributed with this work for additional information
61d2dbeb0SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
71d2dbeb0SAndrew Rist  * to you under the Apache License, Version 2.0 (the
81d2dbeb0SAndrew Rist  * "License"); you may not use this file except in compliance
91d2dbeb0SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
111d2dbeb0SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
131d2dbeb0SAndrew Rist  * Unless required by applicable law or agreed to in writing,
141d2dbeb0SAndrew Rist  * software distributed under the License is distributed on an
151d2dbeb0SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
161d2dbeb0SAndrew Rist  * KIND, either express or implied.  See the License for the
171d2dbeb0SAndrew Rist  * specific language governing permissions and limitations
181d2dbeb0SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
201d2dbeb0SAndrew Rist  *************************************************************/
211d2dbeb0SAndrew Rist 
221d2dbeb0SAndrew Rist 
23cdf0e10cSrcweir #ifndef SW_SHELLIO_HXX
24cdf0e10cSrcweir #define SW_SHELLIO_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <memory>
27cdf0e10cSrcweir #include <boost/utility.hpp>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <com/sun/star/uno/Reference.h>
30cdf0e10cSrcweir #include <com/sun/star/embed/XStorage.hpp>
31cdf0e10cSrcweir #include <sfx2/docfile.hxx>
32cdf0e10cSrcweir #include <sfx2/fcontnr.hxx>
33cdf0e10cSrcweir #include <sot/formats.hxx>
34cdf0e10cSrcweir #include <sot/storage.hxx>
35cdf0e10cSrcweir #include <svtools/parhtml.hxx>
36cdf0e10cSrcweir #include <tools/string.hxx>
37cdf0e10cSrcweir #include <tools/date.hxx>
38cdf0e10cSrcweir #include <tools/time.hxx>
39cdf0e10cSrcweir #include <tools/datetime.hxx>
40cdf0e10cSrcweir #include <tools/ref.hxx>
41cdf0e10cSrcweir #include <tools/urlobj.hxx>
42cdf0e10cSrcweir #include <swdllapi.h>
43cdf0e10cSrcweir #include <swtypes.hxx>
44cdf0e10cSrcweir #include <docfac.hxx>   // SwDocFac
45cdf0e10cSrcweir #include <errhdl.hxx>
46cdf0e10cSrcweir #include <iodetect.hxx>
47cdf0e10cSrcweir 
48521ca9a9SPeter Kovacs // some forward declarations
49cdf0e10cSrcweir class SfxFilterContainer;
50cdf0e10cSrcweir class SfxFilter;
51cdf0e10cSrcweir class SfxItemPool;
52cdf0e10cSrcweir class SfxItemSet;
53cdf0e10cSrcweir class SfxMedium;
54cdf0e10cSrcweir class SvPtrarr;
55cdf0e10cSrcweir class SvStream;
56cdf0e10cSrcweir class SvStrings;
57cdf0e10cSrcweir class SvxFontItem;
58cdf0e10cSrcweir class SvxMacroTableDtor;
59cdf0e10cSrcweir //class Sw3Io;
60cdf0e10cSrcweir class SwCntntNode;
61cdf0e10cSrcweir class SwCrsrShell;
62cdf0e10cSrcweir class SwDoc;
63cdf0e10cSrcweir class SwPaM;
64cdf0e10cSrcweir class SwTextBlocks;
65cdf0e10cSrcweir struct SwPosition;
66cdf0e10cSrcweir struct Writer_Impl;
67cdf0e10cSrcweir 
6841ba7188SPeter Kovacs //defines the amount of maximal characters in a paragraph.
6941ba7188SPeter Kovacs //The force wrap is done by ASCII/W4W-reader. Must be greater than 200
70cdf0e10cSrcweir #define MAX_ASCII_PARA 10000
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 
73cdf0e10cSrcweir class SW_DLLPUBLIC SwAsciiOptions
74cdf0e10cSrcweir {
75cdf0e10cSrcweir     String sFont;
76cdf0e10cSrcweir     rtl_TextEncoding eCharSet;
77cdf0e10cSrcweir     sal_uInt16 nLanguage;
78cdf0e10cSrcweir     LineEnd eCRLF_Flag;
79cdf0e10cSrcweir 
80cdf0e10cSrcweir public:
81cdf0e10cSrcweir 
GetFontName() const82cdf0e10cSrcweir     const String& GetFontName() const { return sFont; }
SetFontName(const String & rFont)83cdf0e10cSrcweir     void SetFontName( const String& rFont ) { sFont = rFont; }
84cdf0e10cSrcweir 
GetCharSet() const85cdf0e10cSrcweir     rtl_TextEncoding GetCharSet() const { return eCharSet; }
SetCharSet(rtl_TextEncoding nVal)86cdf0e10cSrcweir     void SetCharSet( rtl_TextEncoding nVal ) { eCharSet = nVal; }
87cdf0e10cSrcweir 
GetLanguage() const88cdf0e10cSrcweir     sal_uInt16 GetLanguage() const { return nLanguage; }
SetLanguage(sal_uInt16 nVal)89cdf0e10cSrcweir     void SetLanguage( sal_uInt16 nVal ) { nLanguage = nVal; }
90cdf0e10cSrcweir 
GetParaFlags() const91cdf0e10cSrcweir     LineEnd GetParaFlags() const { return eCRLF_Flag; }
SetParaFlags(LineEnd eVal)92cdf0e10cSrcweir     void SetParaFlags( LineEnd eVal ) { eCRLF_Flag = eVal; }
93cdf0e10cSrcweir 
Reset()94cdf0e10cSrcweir     void Reset()
95cdf0e10cSrcweir     {
96cdf0e10cSrcweir         sFont.Erase();
97cdf0e10cSrcweir         eCRLF_Flag = GetSystemLineEnd();
98cdf0e10cSrcweir         eCharSet = ::gsl_getSystemTextEncoding();
99cdf0e10cSrcweir         nLanguage = 0;
100cdf0e10cSrcweir     }
101cdf0e10cSrcweir     // for the automatic conversion (mail/news/...)
102cdf0e10cSrcweir     void ReadUserData( const String& );
103cdf0e10cSrcweir     void WriteUserData( String& );
104cdf0e10cSrcweir 
SwAsciiOptions()105cdf0e10cSrcweir     SwAsciiOptions() { Reset(); }
106cdf0e10cSrcweir };
107cdf0e10cSrcweir 
108cdf0e10cSrcweir /**************** SwReader/Reader ************************/
109483981eeSLordofNoob // base class for different specialized readers
110cdf0e10cSrcweir class Reader;
111521ca9a9SPeter Kovacs //  calls the reader with its options, document, cursor etc.
112cdf0e10cSrcweir class SwReader;
113483981eeSLordofNoob // SwRead is a pointer on the read options of the base class
114cdf0e10cSrcweir typedef Reader *SwRead;
115cdf0e10cSrcweir 
116cdf0e10cSrcweir class SwgReaderOption
117cdf0e10cSrcweir {
118cdf0e10cSrcweir     SwAsciiOptions aASCIIOpts;
119cdf0e10cSrcweir     union
120cdf0e10cSrcweir     {
121cdf0e10cSrcweir         sal_Bool bFmtsOnly;
122cdf0e10cSrcweir         struct
123cdf0e10cSrcweir         {
124cdf0e10cSrcweir             sal_Bool bFrmFmts: 1;
125cdf0e10cSrcweir             sal_Bool bPageDescs: 1;
126cdf0e10cSrcweir             sal_Bool bTxtFmts: 1;
127cdf0e10cSrcweir             sal_Bool bNumRules: 1;
128cdf0e10cSrcweir             sal_Bool bMerge:1;
129cdf0e10cSrcweir         }  Fmts;
130cdf0e10cSrcweir     } What;
131cdf0e10cSrcweir 
132cdf0e10cSrcweir public:
ResetAllFmtsOnly()133cdf0e10cSrcweir     void ResetAllFmtsOnly() { What.bFmtsOnly = 0; }
IsFmtsOnly() const134cdf0e10cSrcweir     sal_Bool IsFmtsOnly() const { return What.bFmtsOnly; }
135cdf0e10cSrcweir 
IsFrmFmts() const136cdf0e10cSrcweir     sal_Bool IsFrmFmts() const { return What.Fmts.bFrmFmts; }
SetFrmFmts(const sal_Bool bNew)137cdf0e10cSrcweir     void SetFrmFmts( const sal_Bool bNew) { What.Fmts.bFrmFmts = bNew; }
138cdf0e10cSrcweir 
IsPageDescs() const139cdf0e10cSrcweir     sal_Bool IsPageDescs() const { return What.Fmts.bPageDescs; }
SetPageDescs(const sal_Bool bNew)140cdf0e10cSrcweir     void SetPageDescs( const sal_Bool bNew) { What.Fmts.bPageDescs = bNew; }
141cdf0e10cSrcweir 
IsTxtFmts() const142cdf0e10cSrcweir     sal_Bool IsTxtFmts() const { return What.Fmts.bTxtFmts; }
SetTxtFmts(const sal_Bool bNew)143cdf0e10cSrcweir     void SetTxtFmts( const sal_Bool bNew) { What.Fmts.bTxtFmts = bNew; }
144cdf0e10cSrcweir 
IsNumRules() const145cdf0e10cSrcweir     sal_Bool IsNumRules() const { return What.Fmts.bNumRules; }
SetNumRules(const sal_Bool bNew)146cdf0e10cSrcweir     void SetNumRules( const sal_Bool bNew) { What.Fmts.bNumRules = bNew; }
147cdf0e10cSrcweir 
IsMerge() const148cdf0e10cSrcweir     sal_Bool IsMerge() const { return What.Fmts.bMerge; }
SetMerge(const sal_Bool bNew)149cdf0e10cSrcweir     void SetMerge( const sal_Bool bNew ) { What.Fmts.bMerge = bNew; }
150cdf0e10cSrcweir 
GetASCIIOpts() const151cdf0e10cSrcweir     const SwAsciiOptions& GetASCIIOpts() const { return aASCIIOpts; }
SetASCIIOpts(const SwAsciiOptions & rOpts)152cdf0e10cSrcweir     void SetASCIIOpts( const SwAsciiOptions& rOpts ) { aASCIIOpts = rOpts; }
ResetASCIIOpts()153cdf0e10cSrcweir     void ResetASCIIOpts() { aASCIIOpts.Reset(); }
154cdf0e10cSrcweir 
SwgReaderOption()155cdf0e10cSrcweir     SwgReaderOption()
156cdf0e10cSrcweir     {   ResetAllFmtsOnly(); aASCIIOpts.Reset(); }
157cdf0e10cSrcweir };
158cdf0e10cSrcweir 
159cdf0e10cSrcweir class SwReader: public SwDocFac
160cdf0e10cSrcweir {
161cdf0e10cSrcweir     SvStream* pStrm;
162cdf0e10cSrcweir     SotStorageRef pStg;
163cdf0e10cSrcweir     com::sun::star::uno::Reference < com::sun::star::embed::XStorage > xStg;
164483981eeSLordofNoob     SfxMedium* pMedium;     // describes file or storage (W4W)
165cdf0e10cSrcweir 
166cdf0e10cSrcweir     SwPaM* pCrsr;
167cdf0e10cSrcweir     String aFileName;
168cdf0e10cSrcweir     String sBaseURL;
169cdf0e10cSrcweir 
170cdf0e10cSrcweir public:
171cdf0e10cSrcweir     /*
17241ba7188SPeter Kovacs      * Initial read. Document is created when function Read(...) is called
173483981eeSLordofNoob      * JP 25.04.95: or if it has been passed in that one.
174483981eeSLordofNoob      *              special case if loaded with Sw3Reader
175cdf0e10cSrcweir      */
176cdf0e10cSrcweir     //SwReader( SotStorage&, const String& rFilename, SwDoc *pDoc = 0 );
177cdf0e10cSrcweir     //SwReader( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >&, const String& rFilename, SwDoc *pDoc = 0 );
178cdf0e10cSrcweir     SwReader( SfxMedium&, const String& rFilename, SwDoc *pDoc = 0 );
179cdf0e10cSrcweir     /*
18041ba7188SPeter Kovacs      * read into an existing document. Document and
181483981eeSLordofNoob      * position within the document are taken from SwPaM.
182cdf0e10cSrcweir      */
183cdf0e10cSrcweir     SwReader( SvStream&, const String& rFilename, const String& rBaseURL, SwPaM& );
184cdf0e10cSrcweir     //SwReader( SotStorage&, const String& rFilename, SwPaM& );
185cdf0e10cSrcweir     SwReader( SfxMedium&, const String& rFilename, SwPaM& );
186cdf0e10cSrcweir     SwReader( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >&, const String& rFilename, SwPaM& );
187cdf0e10cSrcweir 
188cdf0e10cSrcweir     /*
189483981eeSLordofNoob     * only SwReader::Read(...) is the Export-Interface!!!
190cdf0e10cSrcweir     */
191cdf0e10cSrcweir     sal_Bool NeedsPasswd( const Reader& );
192cdf0e10cSrcweir     sal_Bool CheckPasswd( const String&, const Reader& );
193cdf0e10cSrcweir     sal_uLong Read( const Reader& );
194cdf0e10cSrcweir 
195cdf0e10cSrcweir     // ask for glossaries
196cdf0e10cSrcweir     sal_Bool HasGlossaries( const Reader& );
197cdf0e10cSrcweir     sal_Bool ReadGlossaries( const Reader&, SwTextBlocks&, sal_Bool bSaveRelFiles );
198cdf0e10cSrcweir 
GetBaseURL() const199cdf0e10cSrcweir     const String&       GetBaseURL() const { return sBaseURL;}
200cdf0e10cSrcweir 
201cdf0e10cSrcweir protected:
SetBaseURL(const String & rURL)202cdf0e10cSrcweir     void                SetBaseURL( const String& rURL ) { sBaseURL = rURL; }
203cdf0e10cSrcweir };
204cdf0e10cSrcweir 
205cdf0e10cSrcweir 
206cdf0e10cSrcweir 
207cdf0e10cSrcweir /* */
20841ba7188SPeter Kovacs /****************  SPECIAL Readers ************************/
209cdf0e10cSrcweir 
210483981eeSLordofNoob // special - Reader can be both!! (Excel, W4W, .. )
211cdf0e10cSrcweir #define SW_STREAM_READER    1
212cdf0e10cSrcweir #define SW_STORAGE_READER   2
213cdf0e10cSrcweir 
214cdf0e10cSrcweir class SW_DLLPUBLIC Reader
215cdf0e10cSrcweir {
216cdf0e10cSrcweir     friend class SwReader;
217cdf0e10cSrcweir     SwDoc* pTemplate;
218cdf0e10cSrcweir     String aTemplateNm;
219cdf0e10cSrcweir     //String sBaseURL;
220cdf0e10cSrcweir 
221cdf0e10cSrcweir     Date aDStamp;
222cdf0e10cSrcweir     Time aTStamp;
223cdf0e10cSrcweir     DateTime aChkDateTime;
224cdf0e10cSrcweir 
225cdf0e10cSrcweir protected:
226cdf0e10cSrcweir     SvStream* pStrm;
227cdf0e10cSrcweir     SotStorageRef pStg;
228cdf0e10cSrcweir     com::sun::star::uno::Reference < com::sun::star::embed::XStorage > xStg;
229483981eeSLordofNoob     SfxMedium* pMedium;     // describes file or storage  (W4W)
230cdf0e10cSrcweir 
231cdf0e10cSrcweir     SwgReaderOption aOpt;
232cdf0e10cSrcweir     sal_Bool bInsertMode : 1;
233cdf0e10cSrcweir     sal_Bool bTmplBrowseMode : 1;
234521ca9a9SPeter Kovacs     sal_Bool bReadUTF8: 1;      // interpreted stream as UTF-8
235cdf0e10cSrcweir     sal_Bool bBlockMode: 1;
236cdf0e10cSrcweir     sal_Bool bOrganizerMode : 1;
237cdf0e10cSrcweir     sal_Bool bHasAskTemplateName : 1;
238cdf0e10cSrcweir     sal_Bool bIgnoreHTMLComments : 1;
239cdf0e10cSrcweir 
240cdf0e10cSrcweir     virtual String GetTemplateName() const;
241cdf0e10cSrcweir 
242cdf0e10cSrcweir public:
243cdf0e10cSrcweir     Reader();
244cdf0e10cSrcweir     virtual ~Reader();
245cdf0e10cSrcweir 
246cdf0e10cSrcweir     virtual int GetReaderType();
GetReaderOpt()247cdf0e10cSrcweir     SwgReaderOption& GetReaderOpt() { return aOpt; }
248cdf0e10cSrcweir 
249cdf0e10cSrcweir     virtual void SetFltName( const String& rFltNm );
250cdf0e10cSrcweir     static void SetNoOutlineNum( SwDoc& rDoc );
251cdf0e10cSrcweir 
252483981eeSLordofNoob     // fit the item-set of a Frm-Formats to the old Format
253cdf0e10cSrcweir     static void ResetFrmFmtAttrs( SfxItemSet &rFrmSet );
254cdf0e10cSrcweir 
25541ba7188SPeter Kovacs     // convert frame /graphic-/OLE-Templates to old Format (without border etc.)
256cdf0e10cSrcweir     static void ResetFrmFmts( SwDoc& rDoc );
257cdf0e10cSrcweir 
25841ba7188SPeter Kovacs     // load filter-template, position it and then set it free again
259cdf0e10cSrcweir     SwDoc* GetTemplateDoc();
260cdf0e10cSrcweir     sal_Bool SetTemplate( SwDoc& rDoc );
261cdf0e10cSrcweir     void ClearTemplate();
262cdf0e10cSrcweir     void SetTemplateName( const String& rDir );
263cdf0e10cSrcweir     void MakeHTMLDummyTemplateDoc();
264cdf0e10cSrcweir 
IsReadUTF8() const265cdf0e10cSrcweir     sal_Bool IsReadUTF8() const { return bReadUTF8; }
SetReadUTF8(sal_Bool bSet)266cdf0e10cSrcweir     void SetReadUTF8( sal_Bool bSet ) { bReadUTF8 = bSet; }
267cdf0e10cSrcweir 
IsBlockMode() const268cdf0e10cSrcweir     sal_Bool IsBlockMode() const { return bBlockMode; }
SetBlockMode(sal_Bool bSet)269cdf0e10cSrcweir     void SetBlockMode( sal_Bool bSet ) { bBlockMode = bSet; }
270cdf0e10cSrcweir 
IsOrganizerMode() const271cdf0e10cSrcweir     sal_Bool IsOrganizerMode() const { return bOrganizerMode; }
SetOrganizerMode(sal_Bool bSet)272cdf0e10cSrcweir     void SetOrganizerMode( sal_Bool bSet ) { bOrganizerMode = bSet; }
273cdf0e10cSrcweir 
SetIgnoreHTMLComments(sal_Bool bSet)274cdf0e10cSrcweir     void SetIgnoreHTMLComments( sal_Bool bSet ) { bIgnoreHTMLComments = bSet; }
275cdf0e10cSrcweir 
276cdf0e10cSrcweir     virtual sal_Bool HasGlossaries() const;
277cdf0e10cSrcweir     virtual sal_Bool ReadGlossaries( SwTextBlocks&, sal_Bool bSaveRelFiles ) const;
278cdf0e10cSrcweir 
279cdf0e10cSrcweir     // read the sections of the document, which is equal to the medium.
280cdf0e10cSrcweir     // returns the count of it
281cdf0e10cSrcweir     virtual sal_uInt16 GetSectionList( SfxMedium& rMedium,
282cdf0e10cSrcweir                                     SvStrings& rStrings ) const;
283cdf0e10cSrcweir 
getSotStorageRef()284cdf0e10cSrcweir     SotStorageRef getSotStorageRef() { return pStg; };
setSotStorageRef(SotStorageRef pStgRef)285cdf0e10cSrcweir     void setSotStorageRef(SotStorageRef pStgRef) { pStg = pStgRef; };
286cdf0e10cSrcweir 
287cdf0e10cSrcweir private:
288cdf0e10cSrcweir     virtual sal_uLong Read(SwDoc &, const String& rBaseURL, SwPaM &,const String &)=0;
289cdf0e10cSrcweir 
29041ba7188SPeter Kovacs     // all streams / storages that do need to open it must overload the method
291483981eeSLordofNoob     // (W4W!!)
292cdf0e10cSrcweir     virtual int SetStrmStgPtr();
293cdf0e10cSrcweir };
294cdf0e10cSrcweir 
295cdf0e10cSrcweir class AsciiReader: public Reader
296cdf0e10cSrcweir {
297cdf0e10cSrcweir     friend class SwReader;
298cdf0e10cSrcweir     virtual sal_uLong Read( SwDoc &, const String& rBaseURL, SwPaM &,const String &);
299cdf0e10cSrcweir public:
AsciiReader()300cdf0e10cSrcweir     AsciiReader(): Reader() {}
301cdf0e10cSrcweir };
302cdf0e10cSrcweir 
303cdf0e10cSrcweir /*class SwgReader: public Reader
304cdf0e10cSrcweir {
305cdf0e10cSrcweir     virtual sal_uLong Read( SwDoc &, const String& rBaseURL, SwPaM &,const String &);
306cdf0e10cSrcweir };
307cdf0e10cSrcweir */
308cdf0e10cSrcweir class SW_DLLPUBLIC StgReader : public Reader
309cdf0e10cSrcweir {
310cdf0e10cSrcweir     String aFltName;
311cdf0e10cSrcweir 
312cdf0e10cSrcweir protected:
313cdf0e10cSrcweir     sal_uLong OpenMainStream( SotStorageStreamRef& rRef, sal_uInt16& rBuffSize );
314cdf0e10cSrcweir 
315cdf0e10cSrcweir public:
316cdf0e10cSrcweir     virtual int GetReaderType();
GetFltName()317cdf0e10cSrcweir     const String& GetFltName() { return aFltName; }
318cdf0e10cSrcweir     virtual void SetFltName( const String& r );
319cdf0e10cSrcweir };
320cdf0e10cSrcweir 
321cdf0e10cSrcweir 
322cdf0e10cSrcweir /*class Sw3Reader : public StgReader
323cdf0e10cSrcweir {
324cdf0e10cSrcweir     Sw3Io* pIO;
325cdf0e10cSrcweir     virtual sal_uLong Read( SwDoc &, const String& rBaseURL, SwPaM &,const String &);
326cdf0e10cSrcweir public:
327cdf0e10cSrcweir     Sw3Reader() : pIO( 0 ) {}
328cdf0e10cSrcweir 
329cdf0e10cSrcweir     void   SetSw3Io( Sw3Io* pIo )     { pIO = pIo; }
330cdf0e10cSrcweir 
331cdf0e10cSrcweir     // read the sections of the document, which is equal to the medium.
332cdf0e10cSrcweir     // returns the count of it
333cdf0e10cSrcweir     virtual sal_uInt16 GetSectionList( SfxMedium& rMedium,
334cdf0e10cSrcweir                                 SvStrings& rStrings ) const;
335cdf0e10cSrcweir };*/
336cdf0e10cSrcweir 
337cdf0e10cSrcweir /* */
338cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////
339483981eeSLordofNoob // The passed stream has to be dynamic created and before deletion of the
34041ba7188SPeter Kovacs // instance per Stream() requested and deleted!
341cdf0e10cSrcweir 
342cdf0e10cSrcweir class SwImpBlocks;
343cdf0e10cSrcweir 
344cdf0e10cSrcweir class SW_DLLPUBLIC SwTextBlocks
345cdf0e10cSrcweir {
346cdf0e10cSrcweir //  friend class Sw2TextBlocks;
347cdf0e10cSrcweir //  friend class Sw3IoImp;
348cdf0e10cSrcweir     SwImpBlocks* pImp;
349cdf0e10cSrcweir     sal_uLong        nErr;
350cdf0e10cSrcweir 
351cdf0e10cSrcweir public:
352cdf0e10cSrcweir     SwTextBlocks( const String& );
353cdf0e10cSrcweir     ~SwTextBlocks();
354cdf0e10cSrcweir 
Flush()355cdf0e10cSrcweir     void Flush(){}
356cdf0e10cSrcweir 
357cdf0e10cSrcweir     SwDoc* GetDoc();
358483981eeSLordofNoob     void   ClearDoc();                  // delete doc content
359cdf0e10cSrcweir     const  String& GetName();
360cdf0e10cSrcweir     void   SetName( const String& );
GetError() const361cdf0e10cSrcweir     sal_uLong GetError() const { return nErr; }
362cdf0e10cSrcweir 
363cdf0e10cSrcweir     String GetBaseURL() const;
364cdf0e10cSrcweir     void   SetBaseURL( const String& rURL );
365cdf0e10cSrcweir 
366cdf0e10cSrcweir     sal_Bool   IsOld() const;
367483981eeSLordofNoob     sal_uLong  ConvertToNew();              // convert AutoText entries (ger: Textbausteine)
368cdf0e10cSrcweir 
369483981eeSLordofNoob     sal_uInt16 GetCount() const;                        // return amount of AutoText entries
3701a58a4ddSPeter Kovacs     sal_uInt16 GetIndex( const String& ) const;         // return Index-Number of short names
371*0f07801eSPeter Kovacs     sal_uInt16 GetLongIndex( const String& ) const;     //return Index-Number of long names
372483981eeSLordofNoob     const  String& GetShortName( sal_uInt16 ) const;    // return a short name of an index
373483981eeSLordofNoob     const  String& GetLongName( sal_uInt16 ) const;     // return long name of an index
374cdf0e10cSrcweir 
375483981eeSLordofNoob     sal_Bool   Delete( sal_uInt16 );            // delete
376483981eeSLordofNoob     sal_uInt16 Rename( sal_uInt16, const String*, const String* ); // rename
377cdf0e10cSrcweir     sal_uLong  CopyBlock( SwTextBlocks& rSource, String& rSrcShort,
378483981eeSLordofNoob                                     const String& rLong ); // copy block
379cdf0e10cSrcweir 
380483981eeSLordofNoob     sal_Bool   BeginGetDoc( sal_uInt16 );           // read AutoText entry
381483981eeSLordofNoob     void   EndGetDoc();                     // release AutoText entry
382cdf0e10cSrcweir 
383483981eeSLordofNoob     sal_Bool   BeginPutDoc( const String&, const String& ); // start save
384483981eeSLordofNoob     sal_uInt16 PutDoc();                                // End save
385cdf0e10cSrcweir 
386521ca9a9SPeter Kovacs     sal_uInt16 PutText( const String&, const String&, const String& ); // save (shortname, Text)
387cdf0e10cSrcweir 
388cdf0e10cSrcweir     sal_Bool IsOnlyTextBlock( sal_uInt16 ) const;
389cdf0e10cSrcweir     sal_Bool IsOnlyTextBlock( const String& rShort ) const;
390cdf0e10cSrcweir 
391483981eeSLordofNoob     const String& GetFileName() const;      // filename of pImp
392483981eeSLordofNoob     sal_Bool IsReadOnly() const;                // ReadOnly-Flag of pImp
393cdf0e10cSrcweir 
394cdf0e10cSrcweir     sal_Bool GetMacroTable( sal_uInt16 nIdx, SvxMacroTableDtor& rMacroTbl );
395cdf0e10cSrcweir     sal_Bool SetMacroTable( sal_uInt16 nIdx, const SvxMacroTableDtor& rMacroTbl );
396cdf0e10cSrcweir 
397cdf0e10cSrcweir     sal_Bool StartPutMuchBlockEntries();
398cdf0e10cSrcweir     void EndPutMuchBlockEntries();
399cdf0e10cSrcweir };
400cdf0e10cSrcweir 
401cdf0e10cSrcweir // BEGIN source/filter/basflt/fltini.cxx
402cdf0e10cSrcweir 
403cdf0e10cSrcweir extern void _InitFilter();
404cdf0e10cSrcweir extern void _FinitFilter();
405cdf0e10cSrcweir 
406cdf0e10cSrcweir extern SwRead ReadAscii, /*ReadSwg, ReadSw3, */ReadHTML, ReadXML;
407cdf0e10cSrcweir 
408cdf0e10cSrcweir //SW_DLLPUBLIC SwRead SwGetReaderSw3();
409cdf0e10cSrcweir SW_DLLPUBLIC SwRead SwGetReaderXML();
410cdf0e10cSrcweir 
411cdf0e10cSrcweir // END source/filter/basflt/fltini.cxx
412cdf0e10cSrcweir 
413cdf0e10cSrcweir 
4141a58a4ddSPeter Kovacs extern sal_Bool SetHTMLTemplate( SwDoc &rDoc ); // load templates from HTML.vor (see shellio.cxx)
415cdf0e10cSrcweir 
416cdf0e10cSrcweir 
417cdf0e10cSrcweir /* */
418cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////
419cdf0e10cSrcweir 
420cdf0e10cSrcweir /*
421483981eeSLordofNoob  * write, Writer
422cdf0e10cSrcweir  */
423cdf0e10cSrcweir 
424cdf0e10cSrcweir 
425483981eeSLordofNoob /* base class of all Writer */
426cdf0e10cSrcweir 
427cdf0e10cSrcweir class IDocumentSettingAccess;
428cdf0e10cSrcweir class IDocumentStylePoolAccess;
429cdf0e10cSrcweir 
430cdf0e10cSrcweir class SW_DLLPUBLIC Writer
431cdf0e10cSrcweir     : public SvRefBase
432cdf0e10cSrcweir     , private ::boost::noncopyable
433cdf0e10cSrcweir {
434cdf0e10cSrcweir     SwAsciiOptions aAscOpts;
435cdf0e10cSrcweir     String          sBaseURL;
436cdf0e10cSrcweir 
437cdf0e10cSrcweir     void _AddFontItem( SfxItemPool& rPool, const SvxFontItem& rFont );
438cdf0e10cSrcweir     void _AddFontItems( SfxItemPool& rPool, sal_uInt16 nWhichId );
439cdf0e10cSrcweir 
440cdf0e10cSrcweir     ::std::auto_ptr<Writer_Impl> m_pImpl;
441cdf0e10cSrcweir 
442cdf0e10cSrcweir protected:
443cdf0e10cSrcweir 
444483981eeSLordofNoob     SwPaM* pOrigPam;            // last Pam to work on
445cdf0e10cSrcweir     const String* pOrigFileName;
446cdf0e10cSrcweir 
447cdf0e10cSrcweir     void ResetWriter();
448cdf0e10cSrcweir     sal_Bool CopyNextPam( SwPaM ** );
449cdf0e10cSrcweir 
450cdf0e10cSrcweir     void PutNumFmtFontsInAttrPool();
451cdf0e10cSrcweir     void PutEditEngFontsInAttrPool( sal_Bool bIncl_CJK_CTL = sal_True );
452cdf0e10cSrcweir     void PutCJKandCTLFontsInAttrPool();
453cdf0e10cSrcweir 
454cdf0e10cSrcweir     virtual sal_uLong WriteStream() = 0;
SetBaseURL(const String & rURL)455cdf0e10cSrcweir     void                SetBaseURL( const String& rURL ) { sBaseURL = rURL; }
456cdf0e10cSrcweir 
457cdf0e10cSrcweir     IDocumentSettingAccess* getIDocumentSettingAccess();
458cdf0e10cSrcweir     const IDocumentSettingAccess* getIDocumentSettingAccess() const;
459cdf0e10cSrcweir 
460cdf0e10cSrcweir     IDocumentStylePoolAccess* getIDocumentStylePoolAccess();
461cdf0e10cSrcweir     const IDocumentStylePoolAccess* getIDocumentStylePoolAccess() const;
462cdf0e10cSrcweir 
463cdf0e10cSrcweir public:
464cdf0e10cSrcweir     SwDoc* pDoc;
465cdf0e10cSrcweir     SwPaM* pCurPam;
466cdf0e10cSrcweir     sal_Bool bWriteAll : 1;
467cdf0e10cSrcweir     sal_Bool bShowProgress : 1;
468cdf0e10cSrcweir     sal_Bool bWriteClipboardDoc : 1;
469cdf0e10cSrcweir     sal_Bool bWriteOnlyFirstTable : 1;
470cdf0e10cSrcweir     sal_Bool bASCII_ParaAsCR : 1;
471cdf0e10cSrcweir     sal_Bool bASCII_ParaAsBlanc : 1;
472cdf0e10cSrcweir     sal_Bool bASCII_NoLastLineEnd : 1;
473cdf0e10cSrcweir     sal_Bool bUCS2_WithStartChar : 1;
474cdf0e10cSrcweir     sal_Bool bExportPargraphNumbering : 1;
475cdf0e10cSrcweir 
476cdf0e10cSrcweir     sal_Bool bBlock : 1;
477cdf0e10cSrcweir     sal_Bool bOrganizerMode : 1;
478cdf0e10cSrcweir 
479cdf0e10cSrcweir     Writer();
480cdf0e10cSrcweir     virtual ~Writer();
481cdf0e10cSrcweir 
482cdf0e10cSrcweir     virtual sal_uLong Write( SwPaM&, SfxMedium&, const String* = 0 );
483cdf0e10cSrcweir             sal_uLong Write( SwPaM&, SvStream&,  const String* = 0 );
484cdf0e10cSrcweir     virtual sal_uLong Write( SwPaM&, const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >&, const String* = 0, SfxMedium* = 0 );
485cdf0e10cSrcweir     virtual sal_uLong Write( SwPaM&, SotStorage&, const String* = 0 );
486cdf0e10cSrcweir 
487cdf0e10cSrcweir     virtual void SetPasswd( const String& );
488cdf0e10cSrcweir     virtual void SetVersion( const String&, long );
489cdf0e10cSrcweir     virtual sal_Bool IsStgWriter() const;
490cdf0e10cSrcweir //  virtual sal_Bool IsSw3Writer() const;
491cdf0e10cSrcweir 
SetShowProgress(sal_Bool bFlag=sal_False)492cdf0e10cSrcweir     void SetShowProgress( sal_Bool bFlag = sal_False )  { bShowProgress = bFlag; }
493cdf0e10cSrcweir 
GetOrigFileName() const494cdf0e10cSrcweir     const String* GetOrigFileName() const       { return pOrigFileName; }
495cdf0e10cSrcweir 
GetAsciiOptions() const496cdf0e10cSrcweir     const SwAsciiOptions& GetAsciiOptions() const { return aAscOpts; }
SetAsciiOptions(const SwAsciiOptions & rOpt)497cdf0e10cSrcweir     void SetAsciiOptions( const SwAsciiOptions& rOpt ) { aAscOpts = rOpt; }
498cdf0e10cSrcweir 
GetBaseURL() const499cdf0e10cSrcweir     const String&       GetBaseURL() const { return sBaseURL;}
500cdf0e10cSrcweir 
501483981eeSLordofNoob     // search next bookmark position from the bookmark table
502cdf0e10cSrcweir     sal_Int32 FindPos_Bkmk( const SwPosition& rPos ) const;
50341ba7188SPeter Kovacs     // build a bookmark table, which is sorted by the node position. The
504cdf0e10cSrcweir     // OtherPos of the bookmarks also inserted.
505cdf0e10cSrcweir     void CreateBookmarkTbl();
506483981eeSLordofNoob     // search all bookmarks in the range and return it in the Array
507cdf0e10cSrcweir     sal_uInt16 GetBookmarks( const SwCntntNode& rNd,
508cdf0e10cSrcweir                         xub_StrLen nStt, xub_StrLen nEnd,
509cdf0e10cSrcweir                         SvPtrarr& rArr );
510cdf0e10cSrcweir 
511483981eeSLordofNoob     // create a new PaM at the position
512cdf0e10cSrcweir     static SwPaM * NewSwPaM(SwDoc & rDoc,
513cdf0e10cSrcweir                             sal_uLong const nStartIdx, sal_uLong const nEndIdx);
514cdf0e10cSrcweir 
51541ba7188SPeter Kovacs     // if applicable, copy a local file into internet / cloud
516cdf0e10cSrcweir     sal_Bool CopyLocalFileToINet( String& rFileNm );
517cdf0e10cSrcweir 
51841ba7188SPeter Kovacs     // Stream-specific routines, DO NOT USE in Storage-Writer!
519cdf0e10cSrcweir 
52041ba7188SPeter Kovacs     // Optimizing output on stream
521cdf0e10cSrcweir     SvStream& OutLong( SvStream& rStrm, long nVal );
522cdf0e10cSrcweir     SvStream& OutULong( SvStream& rStrm, sal_uLong nVal );
523cdf0e10cSrcweir 
52441ba7188SPeter Kovacs     // print hexadecimal number, default is 2-digit number
525cdf0e10cSrcweir     SvStream& OutHex( SvStream& rStrm, sal_uLong nHex, sal_uInt8 nLen = 2 );
526521ca9a9SPeter Kovacs     // print 4-digit hexadecimal number
OutHex4(SvStream & rStrm,sal_uInt16 nHex)527cdf0e10cSrcweir     inline SvStream& OutHex4( SvStream& rStrm, sal_uInt16 nHex )
528cdf0e10cSrcweir         {   return OutHex( rStrm, nHex, 4 ); }
529cdf0e10cSrcweir 
OutHex(sal_uInt16 nHex,sal_uInt8 nLen=2)530cdf0e10cSrcweir     inline SvStream& OutHex( sal_uInt16 nHex, sal_uInt8 nLen = 2 )      { return OutHex( Strm(), nHex, nLen ); }
OutHex4(sal_uInt16 nHex)531cdf0e10cSrcweir     inline SvStream& OutHex4( sal_uInt16 nHex )     { return OutHex( Strm(), nHex, 4 ); }
OutLong(long nVal)532cdf0e10cSrcweir     inline SvStream& OutLong( long nVal )       { return OutLong( Strm(), nVal ); }
OutULong(sal_uLong nVal)533cdf0e10cSrcweir     inline SvStream& OutULong( sal_uLong nVal )     { return OutULong( Strm(), nVal ); }
534cdf0e10cSrcweir 
535cdf0e10cSrcweir     void SetStream(SvStream *const pStream);
536cdf0e10cSrcweir     SvStream& Strm();
537cdf0e10cSrcweir 
SetOrganizerMode(sal_Bool bSet)538cdf0e10cSrcweir     void SetOrganizerMode( sal_Bool bSet ) { bOrganizerMode = bSet; }
539cdf0e10cSrcweir };
540cdf0e10cSrcweir 
541cdf0e10cSrcweir #ifndef SW_DECL_WRITER_DEFINED
542cdf0e10cSrcweir #define SW_DECL_WRITER_DEFINED
543cdf0e10cSrcweir SV_DECL_REF(Writer)
544cdf0e10cSrcweir #endif
545cdf0e10cSrcweir SV_IMPL_REF(Writer)
546cdf0e10cSrcweir 
547483981eeSLordofNoob // baseclass of all Storage-Writer
548cdf0e10cSrcweir class SW_DLLPUBLIC StgWriter : public Writer
549cdf0e10cSrcweir {
550cdf0e10cSrcweir protected:
551cdf0e10cSrcweir     String aFltName;
552cdf0e10cSrcweir     SotStorageRef pStg;
553cdf0e10cSrcweir     com::sun::star::uno::Reference < com::sun::star::embed::XStorage > xStg;
554cdf0e10cSrcweir 
555483981eeSLordofNoob     // create error at call
556cdf0e10cSrcweir     virtual sal_uLong WriteStream();
557cdf0e10cSrcweir     virtual sal_uLong WriteStorage() = 0;
558cdf0e10cSrcweir     virtual sal_uLong WriteMedium( SfxMedium& ) = 0;
559cdf0e10cSrcweir 
560cdf0e10cSrcweir     using Writer::Write;
561cdf0e10cSrcweir 
562cdf0e10cSrcweir public:
StgWriter()563cdf0e10cSrcweir     StgWriter() : Writer() {}
564cdf0e10cSrcweir 
565cdf0e10cSrcweir     virtual sal_Bool IsStgWriter() const;
566cdf0e10cSrcweir 
567cdf0e10cSrcweir     virtual sal_uLong Write( SwPaM&, const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >&, const String* = 0, SfxMedium* = 0 );
568cdf0e10cSrcweir     virtual sal_uLong Write( SwPaM&, SotStorage&, const String* = 0 );
569cdf0e10cSrcweir 
GetStorage() const570cdf0e10cSrcweir     SotStorage& GetStorage() const       { return *pStg; }
571cdf0e10cSrcweir };
572cdf0e10cSrcweir 
573cdf0e10cSrcweir /*class Sw3Writer : public StgWriter
574cdf0e10cSrcweir {
575cdf0e10cSrcweir     Sw3Io* pIO;
576cdf0e10cSrcweir     sal_Bool bSaveAs : 1;
577cdf0e10cSrcweir 
578cdf0e10cSrcweir     virtual sal_uLong WriteStorage();
579cdf0e10cSrcweir     virtual sal_uLong WriteMedium( SfxMedium& );
580cdf0e10cSrcweir 
581cdf0e10cSrcweir public:
582cdf0e10cSrcweir     Sw3Writer() : pIO( 0 ), bSaveAs( sal_False ) {}
583cdf0e10cSrcweir 
584cdf0e10cSrcweir     virtual sal_Bool IsSw3Writer() const;
585cdf0e10cSrcweir };
586cdf0e10cSrcweir 
587cdf0e10cSrcweir */
588cdf0e10cSrcweir 
589521ca9a9SPeter Kovacs // Interface class for a generic access on special writer
590cdf0e10cSrcweir 
591cdf0e10cSrcweir class SwWriter
592cdf0e10cSrcweir {
593cdf0e10cSrcweir     SvStream* pStrm;
594cdf0e10cSrcweir     SotStorageRef pStg;
595cdf0e10cSrcweir     com::sun::star::uno::Reference < com::sun::star::embed::XStorage > xStg;
596cdf0e10cSrcweir     SfxMedium* pMedium;
597cdf0e10cSrcweir 
598cdf0e10cSrcweir     SwPaM* pOutPam;
599cdf0e10cSrcweir     SwCrsrShell *pShell;
600cdf0e10cSrcweir     SwDoc &rDoc;
601cdf0e10cSrcweir 
602cdf0e10cSrcweir     //String sBaseURL;
603cdf0e10cSrcweir 
604cdf0e10cSrcweir     sal_Bool bWriteAll;
605cdf0e10cSrcweir 
606cdf0e10cSrcweir public:
607cdf0e10cSrcweir     sal_uLong Write( WriterRef& rxWriter, const String* = 0);
608cdf0e10cSrcweir 
609cdf0e10cSrcweir     SwWriter( SvStream&, SwCrsrShell &,sal_Bool bWriteAll = sal_False );
610cdf0e10cSrcweir     SwWriter( SvStream&, SwDoc & );
611cdf0e10cSrcweir     SwWriter( SvStream&, SwPaM &, sal_Bool bWriteAll = sal_False );
612cdf0e10cSrcweir 
613cdf0e10cSrcweir //  SwWriter( SotStorage&, SwCrsrShell &,sal_Bool bWriteAll = sal_False );
614cdf0e10cSrcweir     SwWriter( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >&, SwDoc& );
615cdf0e10cSrcweir //  SwWriter( SotStorage&, SwPaM&, sal_Bool bWriteAll = sal_False );
616cdf0e10cSrcweir 
617cdf0e10cSrcweir     SwWriter( SfxMedium&, SwCrsrShell &,sal_Bool bWriteAll = sal_False );
618cdf0e10cSrcweir     SwWriter( SfxMedium&, SwDoc & );
619cdf0e10cSrcweir //  SwWriter( SfxMedium&, SwPaM&, sal_Bool bWriteAll = sal_False );
620cdf0e10cSrcweir 
621cdf0e10cSrcweir     //const String&       GetBaseURL() const { return sBaseURL;}
622cdf0e10cSrcweir };
623cdf0e10cSrcweir 
624cdf0e10cSrcweir 
625cdf0e10cSrcweir /* */
626cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////
627cdf0e10cSrcweir 
628cdf0e10cSrcweir typedef Reader* (*FnGetReader)();
629cdf0e10cSrcweir typedef void (*FnGetWriter)(const String&, const String& rBaseURL, WriterRef&);
630cdf0e10cSrcweir sal_uLong SaveOrDelMSVBAStorage( SfxObjectShell&, SotStorage&, sal_Bool, const String& );
631cdf0e10cSrcweir sal_uLong GetSaveWarningOfMSVBAStorage( SfxObjectShell &rDocS );
632cdf0e10cSrcweir 
633cdf0e10cSrcweir struct SwReaderWriterEntry
634cdf0e10cSrcweir {
635cdf0e10cSrcweir     Reader* pReader;
636cdf0e10cSrcweir     FnGetReader fnGetReader;
637cdf0e10cSrcweir     FnGetWriter fnGetWriter;
638cdf0e10cSrcweir     sal_Bool bDelReader;
639cdf0e10cSrcweir 
SwReaderWriterEntrySwReaderWriterEntry640cdf0e10cSrcweir     SwReaderWriterEntry( const FnGetReader fnReader, const FnGetWriter fnWriter, sal_Bool bDel )
641cdf0e10cSrcweir         : pReader( NULL ), fnGetReader( fnReader ), fnGetWriter( fnWriter ), bDelReader( bDel )
642cdf0e10cSrcweir     {}
643cdf0e10cSrcweir 
644cdf0e10cSrcweir     /// Get access to the reader
645cdf0e10cSrcweir     Reader* GetReader();
646cdf0e10cSrcweir 
647cdf0e10cSrcweir     /// Get access to the writer
648cdf0e10cSrcweir     void GetWriter( const String& rNm, const String& rBaseURL, WriterRef& xWrt ) const;
649cdf0e10cSrcweir };
650cdf0e10cSrcweir 
651cdf0e10cSrcweir namespace SwReaderWriter
652cdf0e10cSrcweir {
653cdf0e10cSrcweir     /// Return reader based on ReaderWriterEnum
654cdf0e10cSrcweir     Reader* GetReader( ReaderWriterEnum eReader );
655cdf0e10cSrcweir 
656cdf0e10cSrcweir     /// Return reader based on the name
657cdf0e10cSrcweir     Reader* GetReader( const String& rFltName );
658cdf0e10cSrcweir 
659cdf0e10cSrcweir     /// Return writer based on the name
660cdf0e10cSrcweir     void GetWriter( const String& rFltName, const String& rBaseURL, WriterRef& xWrt );
661cdf0e10cSrcweir }
662cdf0e10cSrcweir 
663cdf0e10cSrcweir void GetRTFWriter( const String&, const String&, WriterRef& );
664cdf0e10cSrcweir void GetASCWriter( const String&, const String&, WriterRef& );
665cdf0e10cSrcweir //void GetSw3Writer( const String&, const String&, WriterRef& );
666cdf0e10cSrcweir void GetHTMLWriter( const String&, const String&, WriterRef& );
667cdf0e10cSrcweir void GetXMLWriter( const String&, const String&, WriterRef& );
668cdf0e10cSrcweir void GetWW8Writer( const String&, const String&, WriterRef& );
669cdf0e10cSrcweir 
670cdf0e10cSrcweir #endif
671