1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SW_SOURCE_CORE_INC_SWBLOCKS_HXX
20 #define INCLUDED_SW_SOURCE_CORE_INC_SWBLOCKS_HXX
22 #include <tools/date.hxx>
23 #include <tools/time.hxx>
24 #include <o3tl/sorted_vector.hxx>
25 #include <comphelper/errcode.hxx>
26 #include <rtl/ref.hxx>
30 class SvxMacroTableDtor
;
32 // Name of a text block:
36 friend class SwImpBlocks
;
37 sal_uInt16 m_nHashS
, m_nHashL
; // Hash codes for testing
39 OUString m_aShort
; /// Shortname
40 OUString m_aLong
; /// Longname
41 OUString m_aPackageName
; /// Package name
42 bool m_bIsOnlyTextFlagInit
: 1; /// Is the Flag valid?
43 bool m_bIsOnlyText
: 1; /// Unformatted text
45 SwBlockName( const OUString
& rShort
, const OUString
& rLong
);
46 SwBlockName( const OUString
& rShort
, const OUString
& rLong
, OUString aPackageName
);
48 /// For sorting in the array
49 bool operator< ( const SwBlockName
& r
) const { return m_aShort
< r
.m_aShort
; }
52 class SwBlockNames
: public o3tl::sorted_vector
<std::unique_ptr
<SwBlockName
>, o3tl::less_uniqueptr_to
<SwBlockName
> > {};
56 friend class SwTextBlocks
;
58 OUString m_aFile
; // Physical file name
59 OUString m_aName
; // Logical file name
60 OUString m_aCurrentText
; // Current text
61 OUString m_aShort
, m_aLong
; // Short- and longname (PutDoc)
62 OUString m_sBaseURL
; // Base URL - has to be set at the Readers and Writers
63 SwBlockNames m_aNames
; // List of all Blocks
64 Date m_aDateModified
; // For aligning the Actions
65 tools::Time m_aTimeModified
;
66 rtl::Reference
<SwDoc
> m_xDoc
; // Document to be switched
67 sal_uInt16 m_nCurrentIndex
; // Current Index
69 bool m_bInPutMuchBlocks
: 1; // Put several block entries
70 bool m_bInfoChanged
: 1; // Whether any info of TextBlock changed
72 explicit SwImpBlocks( const OUString
& );
75 NoFile
, // Not present
79 static FileType
GetFileType( const OUString
& );
81 virtual void ClearDoc(); // Delete Doc content
82 std::unique_ptr
<SwPaM
> MakePaM(); // Span PaM over Doc
83 virtual void AddName( const OUString
&, const OUString
&, bool bOnlyText
= false );
84 bool IsFileChanged() const;
88 virtual ~SwImpBlocks();
90 static sal_uInt16
Hash( std::u16string_view
); /// Hashcode for Block names
91 sal_uInt16
GetCount() const; /// Get count of Text Blocks
92 sal_uInt16
GetIndex( const OUString
& ) const; /// Index for shortnames
93 sal_uInt16
GetLongIndex( std::u16string_view
) const; /// Index for longnames
94 OUString
GetShortName( sal_uInt16
) const; /// Return shortname for index
95 OUString
GetLongName( sal_uInt16
) const; /// Return longname for index
96 OUString
GetPackageName( sal_uInt16
) const; /// Return packagename for index
98 const OUString
& GetFileName() const {return m_aFile
;} /// Return physical file name
99 void SetName( const OUString
& rName
) /// Logic name
100 { m_aName
= rName
; m_bInfoChanged
= true; }
101 const OUString
& GetName() const
104 const OUString
& GetBaseURL() const { return m_sBaseURL
;}
105 void SetBaseURL( const OUString
& rURL
) { m_sBaseURL
= rURL
; }
107 virtual ErrCode
Delete( sal_uInt16
) = 0;
108 virtual ErrCode
Rename( sal_uInt16
, const OUString
& ) = 0;
109 virtual ErrCode
CopyBlock( SwImpBlocks
& rImp
, OUString
& rShort
, const OUString
& rLong
) = 0;
110 virtual ErrCode
GetDoc( sal_uInt16
) = 0;
111 virtual ErrCode
BeginPutDoc( const OUString
&, const OUString
& ) = 0;
112 virtual ErrCode
PutDoc() = 0;
113 virtual ErrCode
PutText( const OUString
&, const OUString
&, const OUString
& ) = 0;
114 virtual ErrCode
MakeBlockList() = 0;
116 virtual ErrCode
OpenFile( bool bReadOnly
= true ) = 0;
117 virtual void CloseFile() = 0;
119 virtual bool IsOnlyTextBlock( const OUString
& rShort
) const;
121 virtual ErrCode
GetMacroTable( sal_uInt16 nIdx
, SvxMacroTableDtor
& rMacroTable
);
122 virtual ErrCode
SetMacroTable( sal_uInt16 nIdx
,
123 const SvxMacroTableDtor
& rMacroTable
);
124 virtual bool PutMuchEntries( bool bOn
);
129 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */