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