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{
75public:
77
79
80 void Load( SvStream& rStream, sal_uInt16 nVer );
81 void Write(SvStream& rStream, sal_uInt16 fileVersion);
82};
83
86{
87private:
89
90 // number format
92
93public:
97
98 // block assignment operator
100
101 // number format
102 const ScNumFormatAbbrev& GetNumFormat() const { return aNumFormat; }
103
104 // number format
105 void SetNumFormat( const ScNumFormatAbbrev& rNumFormat ) { aNumFormat = rNumFormat; }
106
107 bool Load( SvStream& rStream, const ScAfVersions& rVersions, sal_uInt16 nVer );
108 bool Save( SvStream& rStream, sal_uInt16 fileVersion );
109};
110
112{
113private:
114 OUString aName;
115 sal_uInt16 nStrResId;
116 // common flags of Calc and Writer
117 bool bIncludeFont : 1;
121
122 // Calc specific flags
125
126 // Writer-specific data
128
129 std::array<std::unique_ptr<ScAutoFormatDataField>,16> ppDataField;
130
131 SAL_DLLPRIVATE ScAutoFormatDataField& GetField( sal_uInt16 nIndex );
132 SAL_DLLPRIVATE const ScAutoFormatDataField& GetField( sal_uInt16 nIndex ) const;
133
134public:
136 ScAutoFormatData( const ScAutoFormatData& rData );
138
139 void SetName( const OUString& rName ) { aName = rName; nStrResId = USHRT_MAX; }
140 const OUString& GetName() const { return aName; }
141
142 bool GetIncludeValueFormat() const { return bIncludeValueFormat; }
143 bool GetIncludeFont() const { return bIncludeFont; }
144 bool GetIncludeJustify() const { return bIncludeJustify; }
145 bool GetIncludeFrame() const { return bIncludeFrame; }
146 bool GetIncludeBackground() const { return bIncludeBackground; }
147 bool GetIncludeWidthHeight() const { return bIncludeWidthHeight; }
148
149 void SetIncludeValueFormat( bool bValueFormat ) { bIncludeValueFormat = bValueFormat; }
150 void SetIncludeFont( bool bFont ) { bIncludeFont = bFont; }
151 void SetIncludeJustify( bool bJustify ) { bIncludeJustify = bJustify; }
152 void SetIncludeFrame( bool bFrame ) { bIncludeFrame = bFrame; }
153 void SetIncludeBackground( bool bBackground ) { bIncludeBackground = bBackground; }
154 void SetIncludeWidthHeight( bool bWidthHeight ) { bIncludeWidthHeight = bWidthHeight; }
155
156 const SfxPoolItem* GetItem( sal_uInt16 nIndex, sal_uInt16 nWhich ) const;
157 template<class T> const T* GetItem( sal_uInt16 nIndex, TypedWhichId<T> nWhich ) const
158 {
159 return static_cast<const T*>(GetItem(nIndex, sal_uInt16(nWhich)));
160 }
161 void PutItem( sal_uInt16 nIndex, const SfxPoolItem& rItem );
162 void CopyItem( sal_uInt16 nToIndex, sal_uInt16 nFromIndex, sal_uInt16 nWhich );
163
164 const ScNumFormatAbbrev& GetNumFormat( sal_uInt16 nIndex ) const;
165
166 bool IsEqualData( sal_uInt16 nIndex1, sal_uInt16 nIndex2 ) const;
167
168 void FillToItemSet( sal_uInt16 nIndex, SfxItemSet& rItemSet, const ScDocument& rDoc ) const;
169 void GetFromItemSet( sal_uInt16 nIndex, const SfxItemSet& rItemSet, const ScNumFormatAbbrev& rNumFormat );
170
171 bool Load( SvStream& rStream, const ScAfVersions& rVersions );
172 bool Save( SvStream& rStream, sal_uInt16 fileVersion );
173};
174
176 bool operator() (const OUString& left, const OUString& right) const;
177};
178
180{
181 typedef std::map<OUString, std::unique_ptr<ScAutoFormatData>, DefaultFirstEntry> MapType;
185
186 ScAutoFormat(const ScAutoFormat&) = delete;
187 const ScAutoFormat operator=(const ScAutoFormat&) = delete;
188
189public:
190 typedef MapType::const_iterator const_iterator;
191 typedef MapType::iterator iterator;
192
193 ScAutoFormat();
194 void Load();
195 bool Save();
196
197 void SetSaveLater( bool bSet );
198 bool IsSaveLater() const { return mbSaveLater; }
199
200 const ScAutoFormatData* findByIndex(size_t nIndex) const;
201 ScAutoFormatData* findByIndex(size_t nIndex);
202 iterator find(const OUString& rName);
203
204 iterator insert(std::unique_ptr<ScAutoFormatData> pNew);
205 void erase(const iterator& it);
206
207 size_t size() const;
208 const_iterator begin() const;
209 const_iterator end() const;
210 iterator begin();
211 iterator end();
212};
213
214/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Contains all items for one cell of a table autoformat.
Definition: autoform.hxx:86
AutoFormatSwBlob m_swFields
Definition: autoform.hxx:88
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:102
ScNumFormatAbbrev aNumFormat
Definition: autoform.hxx:91
bool Save(SvStream &rStream, sal_uInt16 fileVersion)
Definition: autoform.cxx:230
void SetNumFormat(const ScNumFormatAbbrev &rNumFormat)
Definition: autoform.hxx:105
void SetIncludeValueFormat(bool bValueFormat)
Definition: autoform.hxx:149
void SetName(const OUString &rName)
Definition: autoform.hxx:139
bool GetIncludeWidthHeight() const
Definition: autoform.hxx:147
bool GetIncludeBackground() const
Definition: autoform.hxx:146
void SetIncludeFont(bool bFont)
Definition: autoform.hxx:150
bool bIncludeWidthHeight
Definition: autoform.hxx:124
void SetIncludeFrame(bool bFrame)
Definition: autoform.hxx:152
void SetIncludeJustify(bool bJustify)
Definition: autoform.hxx:151
std::array< std::unique_ptr< ScAutoFormatDataField >, 16 > ppDataField
Definition: autoform.hxx:129
AutoFormatSwBlob m_swFields
Definition: autoform.hxx:127
bool GetIncludeValueFormat() const
Definition: autoform.hxx:142
sal_uInt16 nStrResId
Definition: autoform.hxx:115
const T * GetItem(sal_uInt16 nIndex, TypedWhichId< T > nWhich) const
Definition: autoform.hxx:157
bool bIncludeValueFormat
Definition: autoform.hxx:123
bool GetIncludeFrame() const
Definition: autoform.hxx:145
const OUString & GetName() const
Definition: autoform.hxx:140
bool GetIncludeJustify() const
Definition: autoform.hxx:144
void SetIncludeWidthHeight(bool bWidthHeight)
Definition: autoform.hxx:154
bool GetIncludeFont() const
Definition: autoform.hxx:143
void SetIncludeBackground(bool bBackground)
Definition: autoform.hxx:153
OUString aName
Definition: autoform.hxx:114
bool bIncludeBackground
Definition: autoform.hxx:120
MapType m_Data
Definition: autoform.hxx:182
ScAfVersions m_aVersions
Definition: autoform.hxx:184
MapType::const_iterator const_iterator
Definition: autoform.hxx:190
ScAutoFormat(const ScAutoFormat &)=delete
bool mbSaveLater
Definition: autoform.hxx:183
std::map< OUString, std::unique_ptr< ScAutoFormatData >, DefaultFirstEntry > MapType
Definition: autoform.hxx:181
const ScAutoFormat operator=(const ScAutoFormat &)=delete
bool IsSaveLater() const
Definition: autoform.hxx:198
MapType::iterator iterator
Definition: autoform.hxx:191
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