xref: /aoo42x/main/sw/source/core/inc/swblocks.hxx (revision 1d2dbeb0)
1*1d2dbeb0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*1d2dbeb0SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*1d2dbeb0SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*1d2dbeb0SAndrew Rist  * distributed with this work for additional information
6*1d2dbeb0SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*1d2dbeb0SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*1d2dbeb0SAndrew Rist  * "License"); you may not use this file except in compliance
9*1d2dbeb0SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*1d2dbeb0SAndrew Rist  *
11*1d2dbeb0SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*1d2dbeb0SAndrew Rist  *
13*1d2dbeb0SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*1d2dbeb0SAndrew Rist  * software distributed under the License is distributed on an
15*1d2dbeb0SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*1d2dbeb0SAndrew Rist  * KIND, either express or implied.  See the License for the
17*1d2dbeb0SAndrew Rist  * specific language governing permissions and limitations
18*1d2dbeb0SAndrew Rist  * under the License.
19*1d2dbeb0SAndrew Rist  *
20*1d2dbeb0SAndrew Rist  *************************************************************/
21*1d2dbeb0SAndrew Rist 
22*1d2dbeb0SAndrew Rist 
23cdf0e10cSrcweir #ifndef _SWBLOCKS_HXX
24cdf0e10cSrcweir #define _SWBLOCKS_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <tools/string.hxx>
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #ifndef _DATE_HXX //autogen
29cdf0e10cSrcweir #include <tools/datetime.hxx>
30cdf0e10cSrcweir #endif
31cdf0e10cSrcweir #include <svl/svarray.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir 
34cdf0e10cSrcweir class SfxMedium;
35cdf0e10cSrcweir class SwPaM;
36cdf0e10cSrcweir class SwDoc;
37cdf0e10cSrcweir class SvxMacroTableDtor;
38cdf0e10cSrcweir 
39cdf0e10cSrcweir // Name eines Textblocks:
40cdf0e10cSrcweir 
41cdf0e10cSrcweir class SwBlockName
42cdf0e10cSrcweir {
43cdf0e10cSrcweir 	friend class SwImpBlocks;
44cdf0e10cSrcweir 	friend class Sw2TextBlocks;
45cdf0e10cSrcweir 	sal_uInt16 nHashS, nHashL;				// Hash-Codes zum Checken
46cdf0e10cSrcweir 	long   nPos;						// Dateiposition (SW2-Format)
47cdf0e10cSrcweir public:
48cdf0e10cSrcweir 	String aShort;						// Short name
49cdf0e10cSrcweir 	String aLong;						// Long name
50cdf0e10cSrcweir 	String aPackageName;				// Package name
51cdf0e10cSrcweir 	sal_Bool bIsOnlyTxtFlagInit : 1;		// ist das Flag gueltig?
52cdf0e10cSrcweir 	sal_Bool bIsOnlyTxt : 1;				// unformatted text
53cdf0e10cSrcweir 	sal_Bool bInPutMuchBlocks : 1;			// put serveral block entries
54cdf0e10cSrcweir 
55cdf0e10cSrcweir 	SwBlockName( const String& rShort, const String& rLong, long n );
56cdf0e10cSrcweir 	SwBlockName( const String& rShort, const String& rLong, const String& rPackageName );
57cdf0e10cSrcweir 
58cdf0e10cSrcweir 	// fuer das Einsortieren in das Array
operator ==(const SwBlockName & r)59cdf0e10cSrcweir 	int operator==( const SwBlockName& r ) { return aShort == r.aShort; }
operator <(const SwBlockName & r)60cdf0e10cSrcweir 	int operator< ( const SwBlockName& r ) { return aShort <  r.aShort; }
61cdf0e10cSrcweir };
62cdf0e10cSrcweir 
63cdf0e10cSrcweir SV_DECL_PTRARR_SORT( SwBlockNames, SwBlockName*, 10, 10 )
64cdf0e10cSrcweir 
65cdf0e10cSrcweir 
66cdf0e10cSrcweir class SwImpBlocks
67cdf0e10cSrcweir {
68cdf0e10cSrcweir 	friend class SwTextBlocks;
69cdf0e10cSrcweir protected:
70cdf0e10cSrcweir 	String aFile;						// physikalischer Dateiname
71cdf0e10cSrcweir 	String aName;						// logischer Name der Datei
72cdf0e10cSrcweir 	String aCur;						// aktueller Text
73cdf0e10cSrcweir 	String aShort, aLong;				// Kurz- und Langname (PutDoc)
74cdf0e10cSrcweir     String sBaseURL;                    // base URL - has to be set at the Readers and Writers
75cdf0e10cSrcweir 	SwBlockNames aNames;				// Liste aller Bausteine
76cdf0e10cSrcweir 	Date aDateModified;					// fuers abgleichen bei den Aktionen
77cdf0e10cSrcweir 	Time aTimeModified;
78cdf0e10cSrcweir 	SwDoc* pDoc;						// Austauschdokument
79cdf0e10cSrcweir 	sal_uInt16 nCur;						// aktueller Index
80cdf0e10cSrcweir 	sal_Bool bReadOnly : 1;
81cdf0e10cSrcweir 	sal_Bool bInPutMuchBlocks : 1;			// put serveral block entries
82cdf0e10cSrcweir 	sal_Bool bInfoChanged : 1;				// any Info of TextBlock is changed
83cdf0e10cSrcweir 
84cdf0e10cSrcweir 	SwImpBlocks( const String&, sal_Bool = sal_False );
85cdf0e10cSrcweir 	virtual ~SwImpBlocks();
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 	static short GetFileType( const String& );
88cdf0e10cSrcweir 	virtual short GetFileType() const = 0;
89cdf0e10cSrcweir #define	SWBLK_NO_FILE	0				// nicht da
90cdf0e10cSrcweir #define	SWBLK_NONE		1				// keine TB-Datei
91cdf0e10cSrcweir #define	SWBLK_SW2		2				// SW2-Datei
92cdf0e10cSrcweir #define	SWBLK_SW3		3				// SW3-Datei
93cdf0e10cSrcweir #define	SWBLK_XML		4				// XML Block List
94cdf0e10cSrcweir 
95cdf0e10cSrcweir 	virtual void   ClearDoc();					// Doc-Inhalt loeschen
96cdf0e10cSrcweir 	SwPaM* MakePaM();					// PaM ueber Doc aufspannen
97cdf0e10cSrcweir 	virtual void   AddName( const String&, const String&, sal_Bool bOnlyTxt = sal_False );
98cdf0e10cSrcweir 	sal_Bool   IsFileChanged() const;
99cdf0e10cSrcweir 	void   Touch();
100cdf0e10cSrcweir 
101cdf0e10cSrcweir public:
102cdf0e10cSrcweir 	static sal_uInt16 Hash( const String& );		// Hashcode fuer Blocknamen
103cdf0e10cSrcweir 	sal_uInt16 GetCount() const; 					// Anzahl Textbausteine ermitteln
104cdf0e10cSrcweir 	sal_uInt16 GetIndex( const String& ) const;		// Index fuer Kurznamen ermitteln
105cdf0e10cSrcweir 	sal_uInt16 GetLongIndex( const String& ) const;	//Index fuer Langnamen ermitteln
106cdf0e10cSrcweir 	const String& GetShortName( sal_uInt16 ) const;	// Kurzname fuer Index zurueck
107cdf0e10cSrcweir 	const String& GetLongName( sal_uInt16 ) const; 	// Langname fuer Index zurueck
108cdf0e10cSrcweir 	const String& GetPackageName( sal_uInt16 ) const; 	// Langname fuer Index zurueck
109cdf0e10cSrcweir 
GetFileName() const110cdf0e10cSrcweir 	const String& GetFileName() const {return aFile;} 	// phys. Dateinamen liefern
SetName(const String & rName)111cdf0e10cSrcweir 	void SetName( const String& rName )  				// logic name
112cdf0e10cSrcweir 		{ aName = rName; bInfoChanged = sal_True; }
GetName(void)113cdf0e10cSrcweir 	const String & GetName( void )
114cdf0e10cSrcweir 		{ return aName; }
115cdf0e10cSrcweir 
GetBaseURL() const116cdf0e10cSrcweir     const String&       GetBaseURL() const { return sBaseURL;}
SetBaseURL(const String & rURL)117cdf0e10cSrcweir     void                SetBaseURL( const String& rURL ) { sBaseURL = rURL; }
118cdf0e10cSrcweir 
119cdf0e10cSrcweir     virtual sal_uLong Delete( sal_uInt16 ) = 0;
120cdf0e10cSrcweir 	virtual sal_uLong Rename( sal_uInt16, const String&, const String& ) = 0;
121cdf0e10cSrcweir 	virtual sal_uLong CopyBlock( SwImpBlocks& rImp, String& rShort, const String& rLong) = 0;
122cdf0e10cSrcweir 	virtual sal_uLong GetDoc( sal_uInt16 ) = 0;
123cdf0e10cSrcweir 	virtual sal_uLong GetDocForConversion( sal_uInt16 );
124cdf0e10cSrcweir 	virtual sal_uLong BeginPutDoc( const String&, const String& ) = 0;
125cdf0e10cSrcweir 	virtual sal_uLong PutDoc() = 0;
126cdf0e10cSrcweir 	virtual sal_uLong GetText( sal_uInt16, String& ) = 0;
127cdf0e10cSrcweir 	virtual sal_uLong PutText( const String&, const String&, const String& ) = 0;
128cdf0e10cSrcweir 	virtual sal_uLong MakeBlockList() = 0;
129cdf0e10cSrcweir 
130cdf0e10cSrcweir 	virtual sal_uLong OpenFile( sal_Bool bReadOnly = sal_True ) = 0;
131cdf0e10cSrcweir 	virtual void  CloseFile() = 0;
132cdf0e10cSrcweir 
133cdf0e10cSrcweir 	virtual sal_Bool IsOnlyTextBlock( const String& rShort ) const;
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 	virtual sal_uLong GetMacroTable( sal_uInt16 nIdx, SvxMacroTableDtor& rMacroTbl,
136cdf0e10cSrcweir 								 sal_Bool bFileAlreadyOpen = sal_False );
137cdf0e10cSrcweir 	virtual sal_uLong SetMacroTable( sal_uInt16 nIdx,
138cdf0e10cSrcweir 								 const SvxMacroTableDtor& rMacroTbl,
139cdf0e10cSrcweir 								 sal_Bool bFileAlreadyOpen = sal_False );
140cdf0e10cSrcweir 	virtual sal_Bool PutMuchEntries( sal_Bool bOn );
141cdf0e10cSrcweir };
142cdf0e10cSrcweir 
143cdf0e10cSrcweir /*
144cdf0e10cSrcweir class Sw3Persist : public SvPersist
145cdf0e10cSrcweir {
146cdf0e10cSrcweir 	virtual void FillClass( SvGlobalName * pClassName,
147cdf0e10cSrcweir 							sal_uLong * pClipFormat,
148cdf0e10cSrcweir 							String * pAppName,
149cdf0e10cSrcweir 							String * pLongUserName,
150cdf0e10cSrcweir 							String * pUserName,
151cdf0e10cSrcweir 							sal_Int32 nFileFormat=SOFFICE_FILEFORMAT_CURRENT ) const;
152cdf0e10cSrcweir 	virtual sal_Bool Save();
153cdf0e10cSrcweir 	virtual sal_Bool SaveCompleted( SvStorage * );
154cdf0e10cSrcweir public:
155cdf0e10cSrcweir 	Sw3Persist();
156cdf0e10cSrcweir };
157cdf0e10cSrcweir 
158cdf0e10cSrcweir class SwSwgReader;
159cdf0e10cSrcweir 
160cdf0e10cSrcweir class Sw2TextBlocks : public SwImpBlocks
161cdf0e10cSrcweir {
162cdf0e10cSrcweir 	SvPersistRef refPersist;			// Fuer OLE-Objekte
163cdf0e10cSrcweir 	SwSwgReader* pRdr;					// Lese-Routinen
164cdf0e10cSrcweir 	SfxMedium* pMed;					// der logische Input-Stream
165cdf0e10cSrcweir 	String* pText;						// String fuer GetText()
166cdf0e10cSrcweir 	long   nDocStart;					// Beginn des Doc-Records
167cdf0e10cSrcweir 	long   nDocSize;					// Laenge des Doc-Records
168cdf0e10cSrcweir 	long   nStart;						// Beginn des CONTENTS-Records
169cdf0e10cSrcweir 	long   nSize;						// Laenge des CONTENTS-Records
170cdf0e10cSrcweir 	sal_uInt16 nNamedFmts;					// benannte Formate
171cdf0e10cSrcweir 	sal_uInt16 nColls;						// Text-Collections
172cdf0e10cSrcweir 	sal_uInt16 nBlks;						// Anzahl Elemente im CONTENTS-Record
173cdf0e10cSrcweir public:
174cdf0e10cSrcweir 	Sw2TextBlocks( const String& );
175cdf0e10cSrcweir 	virtual ~Sw2TextBlocks();
176cdf0e10cSrcweir 	virtual sal_uLong Delete( sal_uInt16 );
177cdf0e10cSrcweir 	virtual sal_uLong Rename( sal_uInt16, const String&, const String& );
178cdf0e10cSrcweir 	virtual sal_uLong CopyBlock( SwImpBlocks& rImp, String& rShort, const String& rLong);
179cdf0e10cSrcweir 	virtual sal_uLong GetDoc( sal_uInt16 );
180cdf0e10cSrcweir 	virtual sal_uLong BeginPutDoc( const String&, const String& );
181cdf0e10cSrcweir 	virtual sal_uLong PutDoc();
182cdf0e10cSrcweir 	virtual sal_uLong GetText( sal_uInt16, String& );
183cdf0e10cSrcweir 	virtual sal_uLong PutText( const String&, const String&, const String& );
184cdf0e10cSrcweir 	virtual sal_uLong MakeBlockList();
185cdf0e10cSrcweir 	virtual short GetFileType( ) const;
186cdf0e10cSrcweir 	sal_uLong LoadDoc();
187cdf0e10cSrcweir 
188cdf0e10cSrcweir 	virtual sal_uLong OpenFile( sal_Bool bReadOnly = sal_True );
189cdf0e10cSrcweir 	virtual void  CloseFile();
190cdf0e10cSrcweir 
191cdf0e10cSrcweir 	void StatLineStartPercent();				// zum Anzeigen des Prozessbars
192cdf0e10cSrcweir };
193cdf0e10cSrcweir 
194cdf0e10cSrcweir class Sw3Io;
195cdf0e10cSrcweir class Sw3IoImp;
196cdf0e10cSrcweir 
197cdf0e10cSrcweir class Sw3TextBlocks : public SwImpBlocks
198cdf0e10cSrcweir {
199cdf0e10cSrcweir 	Sw3Io*		 pIo3;
200cdf0e10cSrcweir 	Sw3IoImp*    pImp;
201cdf0e10cSrcweir 	sal_Bool 		 bAutocorrBlock;
202cdf0e10cSrcweir 
203cdf0e10cSrcweir public:
204cdf0e10cSrcweir 	Sw3TextBlocks( const String& );
205cdf0e10cSrcweir 	Sw3TextBlocks( SvStorage& );
206cdf0e10cSrcweir 	virtual ~Sw3TextBlocks();
207cdf0e10cSrcweir 	virtual sal_uLong Delete( sal_uInt16 );
208cdf0e10cSrcweir 	virtual sal_uLong Rename( sal_uInt16, const String&, const String& );
209cdf0e10cSrcweir 	virtual sal_uLong CopyBlock( SwImpBlocks& rImp, String& rShort, const String& rLong);
210cdf0e10cSrcweir 	virtual sal_uLong GetDoc( sal_uInt16 );
211cdf0e10cSrcweir 	virtual sal_uLong GetDocForConversion( sal_uInt16 );
212cdf0e10cSrcweir 	virtual sal_uLong BeginPutDoc( const String&, const String& );
213cdf0e10cSrcweir 	virtual sal_uLong PutDoc();
214cdf0e10cSrcweir 	virtual void SetDoc( SwDoc * pNewDoc);
215cdf0e10cSrcweir 	virtual sal_uLong GetText( sal_uInt16, String& );
216cdf0e10cSrcweir 	virtual sal_uLong PutText( const String&, const String&, const String& );
217cdf0e10cSrcweir 	virtual sal_uLong MakeBlockList();
218cdf0e10cSrcweir 	virtual short GetFileType( ) const;
219cdf0e10cSrcweir 
220cdf0e10cSrcweir 	virtual sal_uLong OpenFile( sal_Bool bReadOnly = sal_True );
221cdf0e10cSrcweir 	virtual void  CloseFile();
222cdf0e10cSrcweir 
223cdf0e10cSrcweir 	// Methoden fuer die neue Autokorrektur
224cdf0e10cSrcweir 	sal_uLong GetText( const String& rShort, String& );
225cdf0e10cSrcweir 	SwDoc* GetDoc() const { return pDoc; }
226cdf0e10cSrcweir 
227cdf0e10cSrcweir 	virtual sal_Bool IsOnlyTextBlock( const String& rShort ) const;
228cdf0e10cSrcweir 
229cdf0e10cSrcweir 	virtual sal_uLong GetMacroTable( sal_uInt16, SvxMacroTableDtor& rMacroTbl,
230cdf0e10cSrcweir 								 sal_Bool bFileAlreadyOpen = sal_False );
231cdf0e10cSrcweir 	virtual sal_uLong SetMacroTable( sal_uInt16 nIdx,
232cdf0e10cSrcweir 								 const SvxMacroTableDtor& rMacroTbl,
233cdf0e10cSrcweir 								 sal_Bool bFileAlreadyOpen = sal_False );
234cdf0e10cSrcweir 
235cdf0e10cSrcweir 	void ReadInfo();
236cdf0e10cSrcweir };
237cdf0e10cSrcweir */
238cdf0e10cSrcweir #endif
239