LibreOffice Module sw (master) 1
swblocks.hxx
Go to the documentation of this file.
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/date.hxx>
23#include <tools/time.hxx>
26#include <rtl/ref.hxx>
27
28class SwPaM;
29class SwDoc;
31
32// Name of a text block:
33
35{
36 friend class SwImpBlocks;
37 sal_uInt16 m_nHashS, m_nHashL; // Hash codes for testing
38public:
39 OUString m_aShort;
40 OUString m_aLong;
41 OUString m_aPackageName;
43 bool m_bIsOnlyText : 1;
44
45 SwBlockName( const OUString& rShort, const OUString& rLong );
46 SwBlockName( const OUString& rShort, const OUString& rLong, OUString aPackageName );
47
49 bool operator< ( const SwBlockName& r ) const { return m_aShort < r.m_aShort; }
50};
51
52class SwBlockNames : public o3tl::sorted_vector<std::unique_ptr<SwBlockName>, o3tl::less_uniqueptr_to<SwBlockName> > {};
53
55{
56 friend class SwTextBlocks;
57protected:
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
66 rtl::Reference<SwDoc> m_xDoc; // Document to be switched
67 sal_uInt16 m_nCurrentIndex; // Current Index
68 bool m_bReadOnly : 1;
69 bool m_bInPutMuchBlocks : 1; // Put several block entries
70 bool m_bInfoChanged : 1; // Whether any info of TextBlock changed
71
72 explicit SwImpBlocks( const OUString& );
73
74 enum class FileType {
75 NoFile, // Not present
76 None, // No TB file
77 XML // XML Block List
78 };
79 static FileType GetFileType( const OUString& );
80
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;
85 void Touch();
86
87public:
88 virtual ~SwImpBlocks();
89
90 static sal_uInt16 Hash( std::u16string_view );
91 sal_uInt16 GetCount() const;
92 sal_uInt16 GetIndex( const OUString& ) const;
93 sal_uInt16 GetLongIndex( std::u16string_view ) const;
94 OUString GetShortName( sal_uInt16 ) const;
95 OUString GetLongName( sal_uInt16 ) const;
96 OUString GetPackageName( sal_uInt16 ) const;
97
98 const OUString& GetFileName() const {return m_aFile;}
99 void SetName( const OUString& rName )
100 { m_aName = rName; m_bInfoChanged = true; }
101 const OUString& GetName() const
102 { return m_aName; }
103
104 const OUString& GetBaseURL() const { return m_sBaseURL;}
105 void SetBaseURL( const OUString& rURL ) { m_sBaseURL = rURL; }
106
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;
115
116 virtual ErrCode OpenFile( bool bReadOnly = true ) = 0;
117 virtual void CloseFile() = 0;
118
119 virtual bool IsOnlyTextBlock( const OUString& rShort ) const;
120
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 );
125};
126
127#endif
128
129/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt16 m_nHashS
Definition: swblocks.hxx:37
SwBlockName(const OUString &rShort, const OUString &rLong)
Unformatted text.
Definition: swblocks.cxx:51
bool m_bIsOnlyTextFlagInit
Package name.
Definition: swblocks.hxx:42
OUString m_aPackageName
Longname.
Definition: swblocks.hxx:41
bool operator<(const SwBlockName &r) const
For sorting in the array.
Definition: swblocks.hxx:49
OUString m_aShort
Definition: swblocks.hxx:39
bool m_bIsOnlyText
Is the Flag valid?
Definition: swblocks.hxx:43
OUString m_aLong
Shortname.
Definition: swblocks.hxx:40
sal_uInt16 m_nHashL
Definition: swblocks.hxx:37
Definition: doc.hxx:195
sal_uInt16 m_nCurrentIndex
Definition: swblocks.hxx:67
OUString m_aName
Definition: swblocks.hxx:59
void Touch()
Definition: swblocks.cxx:199
virtual ErrCode PutText(const OUString &, const OUString &, const OUString &)=0
void SetBaseURL(const OUString &rURL)
Definition: swblocks.hxx:105
virtual void AddName(const OUString &, const OUString &, bool bOnlyText=false)
Definition: swblocks.cxx:176
OUString m_sBaseURL
Definition: swblocks.hxx:62
virtual ErrCode CopyBlock(SwImpBlocks &rImp, OUString &rShort, const OUString &rLong)=0
virtual ErrCode SetMacroTable(sal_uInt16 nIdx, const SvxMacroTableDtor &rMacroTable)
Definition: swblocks.cxx:214
virtual void ClearDoc()
Delete the document's content.
Definition: swblocks.cxx:102
OUString m_aShort
Definition: swblocks.hxx:61
const OUString & GetBaseURL() const
Definition: swblocks.hxx:104
OUString GetLongName(sal_uInt16) const
Return shortname for index.
Definition: swblocks.cxx:162
static sal_uInt16 Hash(std::u16string_view)
Calculate hash code (is not guaranteed to be unique)
Definition: swblocks.cxx:39
virtual ErrCode Rename(sal_uInt16, const OUString &)=0
sal_uInt16 GetCount() const
Hashcode for Block names.
Definition: swblocks.cxx:120
OUString GetPackageName(sal_uInt16) const
Return longname for index.
Definition: swblocks.cxx:169
virtual ~SwImpBlocks()
Definition: swblocks.cxx:95
bool m_bReadOnly
Definition: swblocks.hxx:68
OUString m_aLong
Definition: swblocks.hxx:61
virtual bool IsOnlyTextBlock(const OUString &rShort) const
Definition: swblocks.cxx:204
sal_uInt16 GetIndex(const OUString &) const
Get count of Text Blocks.
Definition: swblocks.cxx:128
SwBlockNames m_aNames
Definition: swblocks.hxx:63
const OUString & GetName() const
Definition: swblocks.hxx:101
virtual ErrCode GetMacroTable(sal_uInt16 nIdx, SvxMacroTableDtor &rMacroTable)
Definition: swblocks.cxx:209
virtual ErrCode OpenFile(bool bReadOnly=true)=0
OUString GetShortName(sal_uInt16) const
Index for longnames.
Definition: swblocks.cxx:155
bool IsFileChanged() const
Definition: swblocks.cxx:190
SwImpBlocks(const OUString &)
Definition: swblocks.cxx:80
std::unique_ptr< SwPaM > MakePaM()
Creating a PaM, that spans the whole document.
Definition: swblocks.cxx:110
bool m_bInPutMuchBlocks
Definition: swblocks.hxx:69
virtual ErrCode Delete(sal_uInt16)=0
sal_uInt16 GetLongIndex(std::u16string_view) const
Index for shortnames.
Definition: swblocks.cxx:142
OUString m_aFile
Definition: swblocks.hxx:58
tools::Time m_aTimeModified
Definition: swblocks.hxx:65
Date m_aDateModified
Definition: swblocks.hxx:64
static FileType GetFileType(const OUString &)
Is the provided file a storage or doesn't it exist?
Definition: swblocks.cxx:70
virtual ErrCode GetDoc(sal_uInt16)=0
virtual ErrCode BeginPutDoc(const OUString &, const OUString &)=0
virtual ErrCode MakeBlockList()=0
void SetName(const OUString &rName)
Return physical file name.
Definition: swblocks.hxx:99
virtual bool PutMuchEntries(bool bOn)
Definition: swblocks.cxx:219
const OUString & GetFileName() const
Return packagename for index.
Definition: swblocks.hxx:98
virtual ErrCode PutDoc()=0
rtl::Reference< SwDoc > m_xDoc
Definition: swblocks.hxx:66
OUString m_aCurrentText
Definition: swblocks.hxx:60
virtual void CloseFile()=0
bool m_bInfoChanged
Definition: swblocks.hxx:70
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:187
None