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 INCLUDED_SW_SOURCE_CORE_INC_SWBLOCKS_HXX
20 : #define INCLUDED_SW_SOURCE_CORE_INC_SWBLOCKS_HXX
21 :
22 : #include <tools/datetime.hxx>
23 : #include <o3tl/sorted_vector.hxx>
24 :
25 : class SwPaM;
26 : class SwDoc;
27 : class SvxMacroTableDtor;
28 :
29 : // Name eines Textblocks:
30 :
31 82 : class SwBlockName
32 : {
33 : friend class SwImpBlocks;
34 : sal_uInt16 nHashS, nHashL; // Hash codes for testing
35 : public:
36 : OUString aShort; /// Shortname
37 : OUString aLong; /// Longname
38 : OUString aPackageName; /// Package name
39 : bool bIsOnlyTxtFlagInit : 1; /// Is the Flag valid?
40 : bool bIsOnlyTxt : 1; /// Unformatted text
41 : bool bInPutMuchBlocks : 1; /// Put serveral block entries
42 :
43 : SwBlockName( const OUString& rShort, const OUString& rLong );
44 : SwBlockName( const OUString& rShort, const OUString& rLong, const OUString& rPackageName );
45 :
46 : /// For sorting in the array
47 : bool operator==( const SwBlockName& r ) const { return aShort == r.aShort; }
48 12 : bool operator< ( const SwBlockName& r ) const { return aShort < r.aShort; }
49 : };
50 :
51 236 : class SwBlockNames : public o3tl::sorted_vector<SwBlockName*, o3tl::less_ptr_to<SwBlockName> > {};
52 :
53 : class SwImpBlocks
54 : {
55 : friend class SwTextBlocks;
56 : protected:
57 : OUString aFile; // Physical file name
58 : OUString aName; // Logical file name
59 : OUString aCur; // Current text
60 : OUString aShort, aLong; // Short- and longname (PutDoc)
61 : OUString sBaseURL; // Base URL - has to be set at the Readers and Writers
62 : SwBlockNames aNames; // List of all Blocks
63 : Date aDateModified; // For aligning the Actions
64 : tools::Time aTimeModified;
65 : SwDoc* pDoc; // Document to be switched
66 : sal_uInt16 nCur; // Current Index
67 : bool bReadOnly : 1;
68 : bool bInPutMuchBlocks : 1; // Put serveral block entries
69 : bool bInfoChanged : 1; // Whether any info of TextBlock changed
70 :
71 : SwImpBlocks( const OUString&, bool = false );
72 : virtual ~SwImpBlocks();
73 :
74 : static short GetFileType( const OUString& );
75 : virtual short GetFileType() const = 0;
76 : #define SWBLK_NO_FILE 0 // Not present
77 : #define SWBLK_NONE 1 // No TB file
78 : #define SWBLK_SW2 2 // SW2 file
79 : #define SWBLK_SW3 3 // SW3 file
80 : #define SWBLK_XML 4 // XML Block List
81 :
82 : virtual void ClearDoc(); // Delete Doc content
83 : SwPaM* MakePaM(); // Span PaM over Doc
84 : virtual void AddName( const OUString&, const OUString&, bool bOnlyTxt = false );
85 : bool IsFileChanged() const;
86 : void Touch();
87 :
88 : public:
89 : static sal_uInt16 Hash( const OUString& ); /// Hashcode for Block names
90 : sal_uInt16 GetCount() const; /// Get count of Text Blocks
91 : sal_uInt16 GetIndex( const OUString& ) const; /// Index for shortnames
92 : sal_uInt16 GetLongIndex( const OUString& ) const; /// Index for longnames
93 : OUString GetShortName( sal_uInt16 ) const; /// Return shortname for index
94 : OUString GetLongName( sal_uInt16 ) const; /// Return longname for index
95 : OUString GetPackageName( sal_uInt16 ) const; /// Return packagename for index
96 :
97 0 : OUString GetFileName() const {return aFile;} /// Return physical file name
98 122 : void SetName( const OUString& rName ) /// Logic name
99 122 : { aName = rName; bInfoChanged = true; }
100 46 : OUString GetName( void )
101 46 : { return aName; }
102 :
103 2 : OUString GetBaseURL() const { return sBaseURL;}
104 14 : void SetBaseURL( const OUString& rURL ) { sBaseURL = rURL; }
105 :
106 : virtual sal_uLong Delete( sal_uInt16 ) = 0;
107 : virtual sal_uLong Rename( sal_uInt16, const OUString&, const OUString& ) = 0;
108 : virtual sal_uLong CopyBlock( SwImpBlocks& rImp, OUString& rShort, const OUString& rLong) = 0;
109 : virtual sal_uLong GetDoc( sal_uInt16 ) = 0;
110 : virtual sal_uLong BeginPutDoc( const OUString&, const OUString& ) = 0;
111 : virtual sal_uLong PutDoc() = 0;
112 : virtual sal_uLong GetText( sal_uInt16, OUString& ) = 0;
113 : virtual sal_uLong PutText( const OUString&, const OUString&, const OUString& ) = 0;
114 : virtual sal_uLong MakeBlockList() = 0;
115 :
116 : virtual sal_uLong OpenFile( bool bReadOnly = true ) = 0;
117 : virtual void CloseFile() = 0;
118 :
119 : virtual bool IsOnlyTextBlock( const OUString& rShort ) const;
120 :
121 : virtual sal_uLong GetMacroTable( sal_uInt16 nIdx, SvxMacroTableDtor& rMacroTbl,
122 : bool bFileAlreadyOpen = false );
123 : virtual sal_uLong SetMacroTable( sal_uInt16 nIdx,
124 : const SvxMacroTableDtor& rMacroTbl,
125 : bool bFileAlreadyOpen = false );
126 : virtual bool PutMuchEntries( bool bOn );
127 : };
128 :
129 : #endif
130 :
131 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|