merge the formfield patch from ooo-build
[ooovba.git] / sw / source / core / inc / swblocks.hxx
bloba48ba1493f8c531c58bcbae539c34cc672b0bb37
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: swblocks.hxx,v $
10 * $Revision: 1.16 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _SWBLOCKS_HXX
31 #define _SWBLOCKS_HXX
33 #include <tools/string.hxx>
35 #ifndef _DATE_HXX //autogen
36 #include <tools/datetime.hxx>
37 #endif
38 #include <svtools/svarray.hxx>
41 class SfxMedium;
42 class SwPaM;
43 class SwDoc;
44 class SvxMacroTableDtor;
46 // Name eines Textblocks:
48 class SwBlockName
50 friend class SwImpBlocks;
51 friend class Sw2TextBlocks;
52 USHORT nHashS, nHashL; // Hash-Codes zum Checken
53 long nPos; // Dateiposition (SW2-Format)
54 public:
55 String aShort; // Short name
56 String aLong; // Long name
57 String aPackageName; // Package name
58 BOOL bIsOnlyTxtFlagInit : 1; // ist das Flag gueltig?
59 BOOL bIsOnlyTxt : 1; // unformatted text
60 BOOL bInPutMuchBlocks : 1; // put serveral block entries
62 SwBlockName( const String& rShort, const String& rLong, long n );
63 SwBlockName( const String& rShort, const String& rLong, const String& rPackageName );
65 // fuer das Einsortieren in das Array
66 int operator==( const SwBlockName& r ) { return aShort == r.aShort; }
67 int operator< ( const SwBlockName& r ) { return aShort < r.aShort; }
70 SV_DECL_PTRARR_SORT( SwBlockNames, SwBlockName*, 10, 10 )
73 class SwImpBlocks
75 friend class SwTextBlocks;
76 protected:
77 String aFile; // physikalischer Dateiname
78 String aName; // logischer Name der Datei
79 String aCur; // aktueller Text
80 String aShort, aLong; // Kurz- und Langname (PutDoc)
81 String sBaseURL; // base URL - has to be set at the Readers and Writers
82 SwBlockNames aNames; // Liste aller Bausteine
83 Date aDateModified; // fuers abgleichen bei den Aktionen
84 Time aTimeModified;
85 SwDoc* pDoc; // Austauschdokument
86 USHORT nCur; // aktueller Index
87 BOOL bReadOnly : 1;
88 BOOL bInPutMuchBlocks : 1; // put serveral block entries
89 BOOL bInfoChanged : 1; // any Info of TextBlock is changed
91 SwImpBlocks( const String&, BOOL = FALSE );
92 virtual ~SwImpBlocks();
94 static short GetFileType( const String& );
95 virtual short GetFileType() const = 0;
96 #define SWBLK_NO_FILE 0 // nicht da
97 #define SWBLK_NONE 1 // keine TB-Datei
98 #define SWBLK_SW2 2 // SW2-Datei
99 #define SWBLK_SW3 3 // SW3-Datei
100 #define SWBLK_XML 4 // XML Block List
102 virtual void ClearDoc(); // Doc-Inhalt loeschen
103 SwPaM* MakePaM(); // PaM ueber Doc aufspannen
104 virtual void AddName( const String&, const String&, BOOL bOnlyTxt = FALSE );
105 BOOL IsFileChanged() const;
106 void Touch();
108 public:
109 static USHORT Hash( const String& ); // Hashcode fuer Blocknamen
110 USHORT GetCount() const; // Anzahl Textbausteine ermitteln
111 USHORT GetIndex( const String& ) const; // Index fuer Kurznamen ermitteln
112 USHORT GetLongIndex( const String& ) const; //Index fuer Langnamen ermitteln
113 const String& GetShortName( USHORT ) const; // Kurzname fuer Index zurueck
114 const String& GetLongName( USHORT ) const; // Langname fuer Index zurueck
115 const String& GetPackageName( USHORT ) const; // Langname fuer Index zurueck
117 const String& GetFileName() const {return aFile;} // phys. Dateinamen liefern
118 void SetName( const String& rName ) // logic name
119 { aName = rName; bInfoChanged = TRUE; }
120 const String & GetName( void )
121 { return aName; }
123 const String& GetBaseURL() const { return sBaseURL;}
124 void SetBaseURL( const String& rURL ) { sBaseURL = rURL; }
126 virtual ULONG Delete( USHORT ) = 0;
127 virtual ULONG Rename( USHORT, const String&, const String& ) = 0;
128 virtual ULONG CopyBlock( SwImpBlocks& rImp, String& rShort, const String& rLong) = 0;
129 virtual ULONG GetDoc( USHORT ) = 0;
130 virtual ULONG GetDocForConversion( USHORT );
131 virtual ULONG BeginPutDoc( const String&, const String& ) = 0;
132 virtual ULONG PutDoc() = 0;
133 virtual ULONG GetText( USHORT, String& ) = 0;
134 virtual ULONG PutText( const String&, const String&, const String& ) = 0;
135 virtual ULONG MakeBlockList() = 0;
137 virtual ULONG OpenFile( BOOL bReadOnly = TRUE ) = 0;
138 virtual void CloseFile() = 0;
140 virtual BOOL IsOnlyTextBlock( const String& rShort ) const;
142 virtual ULONG GetMacroTable( USHORT nIdx, SvxMacroTableDtor& rMacroTbl,
143 sal_Bool bFileAlreadyOpen = sal_False );
144 virtual ULONG SetMacroTable( USHORT nIdx,
145 const SvxMacroTableDtor& rMacroTbl,
146 sal_Bool bFileAlreadyOpen = sal_False );
147 virtual BOOL PutMuchEntries( BOOL bOn );
151 class Sw3Persist : public SvPersist
153 virtual void FillClass( SvGlobalName * pClassName,
154 ULONG * pClipFormat,
155 String * pAppName,
156 String * pLongUserName,
157 String * pUserName,
158 sal_Int32 nFileFormat=SOFFICE_FILEFORMAT_CURRENT ) const;
159 virtual BOOL Save();
160 virtual BOOL SaveCompleted( SvStorage * );
161 public:
162 Sw3Persist();
165 class SwSwgReader;
167 class Sw2TextBlocks : public SwImpBlocks
169 SvPersistRef refPersist; // Fuer OLE-Objekte
170 SwSwgReader* pRdr; // Lese-Routinen
171 SfxMedium* pMed; // der logische Input-Stream
172 String* pText; // String fuer GetText()
173 long nDocStart; // Beginn des Doc-Records
174 long nDocSize; // Laenge des Doc-Records
175 long nStart; // Beginn des CONTENTS-Records
176 long nSize; // Laenge des CONTENTS-Records
177 USHORT nNamedFmts; // benannte Formate
178 USHORT nColls; // Text-Collections
179 USHORT nBlks; // Anzahl Elemente im CONTENTS-Record
180 public:
181 Sw2TextBlocks( const String& );
182 virtual ~Sw2TextBlocks();
183 virtual ULONG Delete( USHORT );
184 virtual ULONG Rename( USHORT, const String&, const String& );
185 virtual ULONG CopyBlock( SwImpBlocks& rImp, String& rShort, const String& rLong);
186 virtual ULONG GetDoc( USHORT );
187 virtual ULONG BeginPutDoc( const String&, const String& );
188 virtual ULONG PutDoc();
189 virtual ULONG GetText( USHORT, String& );
190 virtual ULONG PutText( const String&, const String&, const String& );
191 virtual ULONG MakeBlockList();
192 virtual short GetFileType( ) const;
193 ULONG LoadDoc();
195 virtual ULONG OpenFile( BOOL bReadOnly = TRUE );
196 virtual void CloseFile();
198 void StatLineStartPercent(); // zum Anzeigen des Prozessbars
201 class Sw3Io;
202 class Sw3IoImp;
204 class Sw3TextBlocks : public SwImpBlocks
206 Sw3Io* pIo3;
207 Sw3IoImp* pImp;
208 BOOL bAutocorrBlock;
210 public:
211 Sw3TextBlocks( const String& );
212 Sw3TextBlocks( SvStorage& );
213 virtual ~Sw3TextBlocks();
214 virtual ULONG Delete( USHORT );
215 virtual ULONG Rename( USHORT, const String&, const String& );
216 virtual ULONG CopyBlock( SwImpBlocks& rImp, String& rShort, const String& rLong);
217 virtual ULONG GetDoc( USHORT );
218 virtual ULONG GetDocForConversion( USHORT );
219 virtual ULONG BeginPutDoc( const String&, const String& );
220 virtual ULONG PutDoc();
221 virtual void SetDoc( SwDoc * pNewDoc);
222 virtual ULONG GetText( USHORT, String& );
223 virtual ULONG PutText( const String&, const String&, const String& );
224 virtual ULONG MakeBlockList();
225 virtual short GetFileType( ) const;
227 virtual ULONG OpenFile( BOOL bReadOnly = TRUE );
228 virtual void CloseFile();
230 // Methoden fuer die neue Autokorrektur
231 ULONG GetText( const String& rShort, String& );
232 SwDoc* GetDoc() const { return pDoc; }
234 virtual BOOL IsOnlyTextBlock( const String& rShort ) const;
236 virtual ULONG GetMacroTable( USHORT, SvxMacroTableDtor& rMacroTbl,
237 sal_Bool bFileAlreadyOpen = sal_False );
238 virtual ULONG SetMacroTable( USHORT nIdx,
239 const SvxMacroTableDtor& rMacroTbl,
240 sal_Bool bFileAlreadyOpen = sal_False );
242 void ReadInfo();
245 #endif