Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #ifndef _SWBLOCKS_HXX
20 : #define _SWBLOCKS_HXX
21 :
22 : #include <tools/string.hxx>
23 :
24 : #include <tools/datetime.hxx>
25 : #include <o3tl/sorted_vector.hxx>
26 :
27 :
28 : class SwPaM;
29 : class SwDoc;
30 : class SvxMacroTableDtor;
31 :
32 : // Name eines Textblocks:
33 :
34 0 : class SwBlockName
35 : {
36 : friend class SwImpBlocks;
37 : sal_uInt16 nHashS, nHashL; // Hash-Codes zum Checken
38 : public:
39 : String aShort; // Short name
40 : String aLong; // Long name
41 : rtl::OUString aPackageName; // Package name
42 : sal_Bool bIsOnlyTxtFlagInit : 1; // ist das Flag gueltig?
43 : sal_Bool bIsOnlyTxt : 1; // unformatted text
44 : sal_Bool bInPutMuchBlocks : 1; // put serveral block entries
45 :
46 : SwBlockName( const String& rShort, const String& rLong );
47 : SwBlockName( const String& rShort, const String& rLong, const String& rPackageName );
48 :
49 : // fuer das Einsortieren in das Array
50 : bool operator==( const SwBlockName& r ) const { return aShort == r.aShort; }
51 0 : bool operator< ( const SwBlockName& r ) const { return aShort < r.aShort; }
52 : };
53 :
54 0 : class SwBlockNames : public o3tl::sorted_vector<SwBlockName*, o3tl::less_ptr_to<SwBlockName> > {};
55 :
56 :
57 : class SwImpBlocks
58 : {
59 : friend class SwTextBlocks;
60 : protected:
61 : String aFile; // physikalischer Dateiname
62 : String aName; // logischer Name der Datei
63 : String aCur; // aktueller Text
64 : String aShort, aLong; // Kurz- und Langname (PutDoc)
65 : String sBaseURL; // base URL - has to be set at the Readers and Writers
66 : SwBlockNames aNames; // Liste aller Bausteine
67 : Date aDateModified; // fuers abgleichen bei den Aktionen
68 : Time aTimeModified;
69 : SwDoc* pDoc; // Austauschdokument
70 : sal_uInt16 nCur; // aktueller Index
71 : sal_Bool bReadOnly : 1;
72 : sal_Bool bInPutMuchBlocks : 1; // put serveral block entries
73 : sal_Bool bInfoChanged : 1; // any Info of TextBlock is changed
74 :
75 : SwImpBlocks( const String&, sal_Bool = sal_False );
76 : virtual ~SwImpBlocks();
77 :
78 : static short GetFileType( const String& );
79 : virtual short GetFileType() const = 0;
80 : #define SWBLK_NO_FILE 0 // nicht da
81 : #define SWBLK_NONE 1 // keine TB-Datei
82 : #define SWBLK_SW2 2 // SW2-Datei
83 : #define SWBLK_SW3 3 // SW3-Datei
84 : #define SWBLK_XML 4 // XML Block List
85 :
86 : virtual void ClearDoc(); // Doc-Inhalt loeschen
87 : SwPaM* MakePaM(); // PaM ueber Doc aufspannen
88 : virtual void AddName( const String&, const String&, sal_Bool bOnlyTxt = sal_False );
89 : sal_Bool IsFileChanged() const;
90 : void Touch();
91 :
92 : public:
93 : static sal_uInt16 Hash( const String& ); // Hashcode fuer Blocknamen
94 : sal_uInt16 GetCount() const; // Anzahl Textbausteine ermitteln
95 : sal_uInt16 GetIndex( const String& ) const; // Index fuer Kurznamen ermitteln
96 : sal_uInt16 GetLongIndex( const String& ) const; //Index fuer Langnamen ermitteln
97 : const String& GetShortName( sal_uInt16 ) const; // Kurzname fuer Index zurueck
98 : const String& GetLongName( sal_uInt16 ) const; // Langname fuer Index zurueck
99 : rtl::OUString GetPackageName( sal_uInt16 ) const; // Langname fuer Index zurueck
100 :
101 0 : const String& GetFileName() const {return aFile;} // phys. Dateinamen liefern
102 0 : void SetName( const String& rName ) // logic name
103 0 : { aName = rName; bInfoChanged = sal_True; }
104 0 : const String & GetName( void )
105 0 : { return aName; }
106 :
107 0 : const String& GetBaseURL() const { return sBaseURL;}
108 0 : void SetBaseURL( const String& rURL ) { sBaseURL = rURL; }
109 :
110 : virtual sal_uLong Delete( sal_uInt16 ) = 0;
111 : virtual sal_uLong Rename( sal_uInt16, const String&, const String& ) = 0;
112 : virtual sal_uLong CopyBlock( SwImpBlocks& rImp, String& rShort, const String& rLong) = 0;
113 : virtual sal_uLong GetDoc( sal_uInt16 ) = 0;
114 : virtual sal_uLong GetDocForConversion( sal_uInt16 );
115 : virtual sal_uLong BeginPutDoc( const String&, const String& ) = 0;
116 : virtual sal_uLong PutDoc() = 0;
117 : virtual sal_uLong GetText( sal_uInt16, String& ) = 0;
118 : virtual sal_uLong PutText( const String&, const String&, const String& ) = 0;
119 : virtual sal_uLong MakeBlockList() = 0;
120 :
121 : virtual sal_uLong OpenFile( sal_Bool bReadOnly = sal_True ) = 0;
122 : virtual void CloseFile() = 0;
123 :
124 : virtual sal_Bool IsOnlyTextBlock( const String& rShort ) const;
125 :
126 : virtual sal_uLong GetMacroTable( sal_uInt16 nIdx, SvxMacroTableDtor& rMacroTbl,
127 : sal_Bool bFileAlreadyOpen = sal_False );
128 : virtual sal_uLong SetMacroTable( sal_uInt16 nIdx,
129 : const SvxMacroTableDtor& rMacroTbl,
130 : sal_Bool bFileAlreadyOpen = sal_False );
131 : virtual sal_Bool PutMuchEntries( sal_Bool bOn );
132 : };
133 :
134 : #endif
135 :
136 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|