LibreOffice Module sc (master) 1
autoform.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
20#pragma once
21
22/*************************************************************************
23!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
24
25 The structure of auto formatting should not be changed. It is used
26 by various code of Writer and Calc. If a change is necessary, the
27 source code of both applications must be changed!
28
29!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
30**************************************************************************/
31
32#include <svl/poolitem.hxx>
34
35#include "scdllapi.h"
36#include "zforauto.hxx"
37
38#include <array>
39#include <memory>
40#include <map>
41#include <climits>
42
43class ScDocument;
44
55{
56 std::unique_ptr<sal_uInt8[]> pData;
57 std::size_t size;
58
60 {
61 }
64
65 void Reset()
66 {
67 pData.reset();
68 size = 0;
69 }
70};
71
74{
75private:
77
78public:
80
81 void Load( SvStream& rStream, sal_uInt16 nVer );
82 void Write(SvStream& rStream, sal_uInt16 fileVersion);
83};
84
87{
88private:
90
91 // number format
93
94public:
98
99 // block assignment operator
101
102 // number format
103 const ScNumFormatAbbrev& GetNumFormat() const { return aNumFormat; }
104
105 // number format
106 void SetNumFormat( const ScNumFormatAbbrev& rNumFormat ) { aNumFormat = rNumFormat; }
107
108 bool Load( SvStream& rStream, const ScAfVersions& rVersions, sal_uInt16 nVer );
109 bool Save( SvStream& rStream, sal_uInt16 fileVersion );
110};
111
113{
114private:
115 OUString aName;
116 sal_uInt16 nStrResId;
117 // common flags of Calc and Writer
118 bool bIncludeFont : 1;
122
123 // Calc specific flags
126
127 // Writer-specific data
129
130 std::array<std::unique_ptr<ScAutoFormatDataField>,16> ppDataField;
131
132 SAL_DLLPRIVATE ScAutoFormatDataField& GetField( sal_uInt16 nIndex );
133 SAL_DLLPRIVATE const ScAutoFormatDataField& GetField( sal_uInt16 nIndex ) const;
134
135public:
137 ScAutoFormatData( const ScAutoFormatData& rData );
139
140 void SetName( const OUString& rName ) { aName = rName; nStrResId = USHRT_MAX; }
141 const OUString& GetName() const { return aName; }
142
143 bool GetIncludeValueFormat() const { return bIncludeValueFormat; }
144 bool GetIncludeFont() const { return bIncludeFont; }
145 bool GetIncludeJustify() const { return bIncludeJustify; }
146 bool GetIncludeFrame() const { return bIncludeFrame; }
147 bool GetIncludeBackground() const { return bIncludeBackground; }
148 bool GetIncludeWidthHeight() const { return bIncludeWidthHeight; }
149
150 void SetIncludeValueFormat( bool bValueFormat ) { bIncludeValueFormat = bValueFormat; }
151 void SetIncludeFont( bool bFont ) { bIncludeFont = bFont; }
152 void SetIncludeJustify( bool bJustify ) { bIncludeJustify = bJustify; }
153 void SetIncludeFrame( bool bFrame ) { bIncludeFrame = bFrame; }
154 void SetIncludeBackground( bool bBackground ) { bIncludeBackground = bBackground; }
155 void SetIncludeWidthHeight( bool bWidthHeight ) { bIncludeWidthHeight = bWidthHeight; }
156
157 const SfxPoolItem* GetItem( sal_uInt16 nIndex, sal_uInt16 nWhich ) const;
158 template<class T> const T* GetItem( sal_uInt16 nIndex, TypedWhichId<T> nWhich ) const
159 {
160 return static_cast<const T*>(GetItem(nIndex, sal_uInt16(nWhich)));
161 }
162 void PutItem( sal_uInt16 nIndex, const SfxPoolItem& rItem );
163 void CopyItem( sal_uInt16 nToIndex, sal_uInt16 nFromIndex, sal_uInt16 nWhich );
164
165 const ScNumFormatAbbrev& GetNumFormat( sal_uInt16 nIndex ) const;
166
167 bool HasSameData( sal_uInt16 nIndex1, sal_uInt16 nIndex2 ) const;
168
169 void FillToItemSet( sal_uInt16 nIndex, SfxItemSet& rItemSet, const ScDocument& rDoc ) const;
170 void GetFromItemSet( sal_uInt16 nIndex, const SfxItemSet& rItemSet, const ScNumFormatAbbrev& rNumFormat );
171
172 bool Load( SvStream& rStream, const ScAfVersions& rVersions );
173 bool Save( SvStream& rStream, sal_uInt16 fileVersion );
174};
175
177 bool operator() (const OUString& left, const OUString& right) const;
178};
179
181{
182 typedef std::map<OUString, std::unique_ptr<ScAutoFormatData>, DefaultFirstEntry> MapType;
186
187 ScAutoFormat(const ScAutoFormat&) = delete;
188 const ScAutoFormat operator=(const ScAutoFormat&) = delete;
189
190public:
191 typedef MapType::const_iterator const_iterator;
192 typedef MapType::iterator iterator;
193
194 ScAutoFormat();
195 void Load();
196 bool Save();
197
198 void SetSaveLater( bool bSet );
199 bool IsSaveLater() const { return mbSaveLater; }
200
201 const ScAutoFormatData* findByIndex(size_t nIndex) const;
202 ScAutoFormatData* findByIndex(size_t nIndex);
203 iterator find(const OUString& rName);
204
205 iterator insert(std::unique_ptr<ScAutoFormatData> pNew);
206 void erase(const iterator& it);
207
208 size_t size() const;
209 const_iterator begin() const;
210 const_iterator end() const;
211 iterator begin();
212 iterator end();
213};
214
215/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Contains all items for one cell of a table autoformat.
Definition: autoform.hxx:87
AutoFormatSwBlob m_swFields
Definition: autoform.hxx:89
bool Load(SvStream &rStream, const ScAfVersions &rVersions, sal_uInt16 nVer)
Definition: autoform.cxx:203
ScAutoFormatDataField & operator=(const ScAutoFormatDataField &rRef)=delete
const ScNumFormatAbbrev & GetNumFormat() const
Definition: autoform.hxx:103
ScNumFormatAbbrev aNumFormat
Definition: autoform.hxx:92
bool Save(SvStream &rStream, sal_uInt16 fileVersion)
Definition: autoform.cxx:230
void SetNumFormat(const ScNumFormatAbbrev &rNumFormat)
Definition: autoform.hxx:106
void SetIncludeValueFormat(bool bValueFormat)
Definition: autoform.hxx:150
void SetName(const OUString &rName)
Definition: autoform.hxx:140
bool GetIncludeWidthHeight() const
Definition: autoform.hxx:148
bool GetIncludeBackground() const
Definition: autoform.hxx:147
void SetIncludeFont(bool bFont)
Definition: autoform.hxx:151
bool bIncludeWidthHeight
Definition: autoform.hxx:125
void SetIncludeFrame(bool bFrame)
Definition: autoform.hxx:153
void SetIncludeJustify(bool bJustify)
Definition: autoform.hxx:152
std::array< std::unique_ptr< ScAutoFormatDataField >, 16 > ppDataField
Definition: autoform.hxx:130
AutoFormatSwBlob m_swFields
Definition: autoform.hxx:128
bool GetIncludeValueFormat() const
Definition: autoform.hxx:143
sal_uInt16 nStrResId
Definition: autoform.hxx:116
const T * GetItem(sal_uInt16 nIndex, TypedWhichId< T > nWhich) const
Definition: autoform.hxx:158
bool bIncludeValueFormat
Definition: autoform.hxx:124
bool GetIncludeFrame() const
Definition: autoform.hxx:146
const OUString & GetName() const
Definition: autoform.hxx:141
bool GetIncludeJustify() const
Definition: autoform.hxx:145
void SetIncludeWidthHeight(bool bWidthHeight)
Definition: autoform.hxx:155
bool GetIncludeFont() const
Definition: autoform.hxx:144
void SetIncludeBackground(bool bBackground)
Definition: autoform.hxx:154
OUString aName
Definition: autoform.hxx:115
bool bIncludeBackground
Definition: autoform.hxx:121
MapType m_Data
Definition: autoform.hxx:183
ScAfVersions m_aVersions
Definition: autoform.hxx:185
MapType::const_iterator const_iterator
Definition: autoform.hxx:191
ScAutoFormat(const ScAutoFormat &)=delete
bool mbSaveLater
Definition: autoform.hxx:184
std::map< OUString, std::unique_ptr< ScAutoFormatData >, DefaultFirstEntry > MapType
Definition: autoform.hxx:182
const ScAutoFormat operator=(const ScAutoFormat &)=delete
bool IsSaveLater() const
Definition: autoform.hxx:199
MapType::iterator iterator
Definition: autoform.hxx:192
OString right
sal_Int32 nIndex
OUString aName
const SfxPoolItem * GetItem(const SwTextAttr &rAttr, sal_uInt16 nWhich)
size
OSQLColumns::const_iterator find(const OSQLColumns::const_iterator &first, const OSQLColumns::const_iterator &last, std::u16string_view _rVal, const ::comphelper::UStringMixEqual &_rCase)
enumrange< T >::Iterator begin(enumrange< T >)
end
#define SC_DLLPUBLIC
Definition: scdllapi.h:27
A binary blob of writer-specific data.
Definition: autoform.hxx:55
AutoFormatSwBlob(const AutoFormatSwBlob &)=delete
const AutoFormatSwBlob & operator=(const AutoFormatSwBlob &)=delete
std::unique_ptr< sal_uInt8[]> pData
Definition: autoform.hxx:56
std::size_t size
Definition: autoform.hxx:57
bool operator()(const OUString &left, const OUString &right) const
Definition: autoform.cxx:745
Struct with version numbers of the Items.
Definition: autoform.hxx:74
void Load(SvStream &rStream, sal_uInt16 nVer)
Definition: autoform.cxx:133
void Write(SvStream &rStream, sal_uInt16 fileVersion)
Definition: autoform.cxx:143
AutoFormatSwBlob swVersions
Definition: autoform.hxx:76
sal_uInt64 left