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