LibreOffice Module sc (master) 1
patattr.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#include <optional>
23
24#include <svl/setitem.hxx>
25#include <svl/itemset.hxx>
27#include <tools/degree.hxx>
28#include <editeng/svxenum.hxx>
29#include "scdllapi.h"
30#include "fonthelper.hxx"
31
32namespace vcl { class Font; }
33namespace model { class ComplexColor; }
34class OutputDevice;
35class Fraction;
36class ScStyleSheet;
38class ScDocument;
39enum class ScRotateDir : sal_uInt8;
40
42
44{
45 Raw,
46 Print,
47 Display,
51};
52
54{
55 std::optional<OUString> pName;
56 mutable std::optional<sal_uInt32> mxHashCode;
57 mutable std::optional<bool> mxVisible;
59 sal_uInt64 mnKey;
60public:
61 ScPatternAttr(SfxItemSet&& pItemSet, const OUString& rStyleName);
62 ScPatternAttr(SfxItemSet&& pItemSet);
63 ScPatternAttr(SfxItemPool* pItemPool);
64 ScPatternAttr(const ScPatternAttr& rPatternAttr);
65
66 virtual ScPatternAttr* Clone( SfxItemPool *pPool = nullptr ) const override;
67
68 virtual bool operator==(const SfxPoolItem& rCmp) const override;
69 // Class cannot be IsSortable() because it's mutable, implement at least Lookup().
70 virtual bool HasLookup() const override { return true; }
71 virtual lookup_iterator Lookup(lookup_iterator begin, lookup_iterator end ) const override;
72
73 const SfxPoolItem& GetItem( sal_uInt16 nWhichP ) const
74 { return GetItemSet().Get(nWhichP); }
75 template<class T> const T& GetItem( TypedWhichId<T> nWhich ) const
76 { return static_cast<const T&>(GetItem(sal_uInt16(nWhich))); }
77
78 static const SfxPoolItem& GetItem( sal_uInt16 nWhich, const SfxItemSet& rItemSet, const SfxItemSet* pCondSet );
79 template<class T> static const T& GetItem( TypedWhichId<T> nWhich, const SfxItemSet& rItemSet, const SfxItemSet* pCondSet )
80 { return static_cast<const T&>(GetItem(sal_uInt16(nWhich), rItemSet, pCondSet)); }
81
82 const SfxPoolItem& GetItem( sal_uInt16 nWhich, const SfxItemSet* pCondSet ) const;
83 template<class T> const T& GetItem( TypedWhichId<T> nWhich, const SfxItemSet* pCondSet ) const
84 { return static_cast<const T&>(GetItem(sal_uInt16(nWhich), pCondSet)); }
85
87 bool HasItemsSet( const sal_uInt16* pWhich ) const;
88 void ClearItems( const sal_uInt16* pWhich );
89
90 void DeleteUnchanged( const ScPatternAttr* pOldAttrs );
91
92 static SvxCellOrientation GetCellOrientation( const SfxItemSet& rItemSet, const SfxItemSet* pCondSet );
93 SvxCellOrientation GetCellOrientation( const SfxItemSet* pCondSet = nullptr ) const;
94
96 static void fillFontOnly(vcl::Font& rFont, const SfxItemSet& rItemSet,
97 const OutputDevice* pOutDev = nullptr,
98 const Fraction* pScale = nullptr,
99 const SfxItemSet* pCondSet = nullptr,
100 SvtScriptType nScript = SvtScriptType::NONE);
101
102 static void fillFont( vcl::Font& rFont, const SfxItemSet& rItemSet,
103 ScAutoFontColorMode eAutoMode,
104 const OutputDevice* pOutDev = nullptr,
105 const Fraction* pScale = nullptr,
106 const SfxItemSet* pCondSet = nullptr,
107 SvtScriptType nScript = SvtScriptType::NONE, const Color* pBackConfigColor = nullptr,
108 const Color* pTextConfigColor = nullptr);
109
110 static void fillColor(model::ComplexColor& rComplexColor,
111 const SfxItemSet& rItemSet,
112 ScAutoFontColorMode eAutoMode,
113 const SfxItemSet* pCondSet = nullptr,
114 const Color* pBackConfigColor = nullptr,
115 const Color* pTextConfigColor = nullptr);
116
117
118 static ScDxfFont GetDxfFont(const SfxItemSet& rSet, SvtScriptType nScript);
119
120 void fillColor(model::ComplexColor& rComplexColor,
121 ScAutoFontColorMode eAutoMode,
122 const SfxItemSet* pCondSet = nullptr,
123 const Color* pBackConfigColor = nullptr,
124 const Color* pTextConfigColor = nullptr) const
125 {
126 fillColor(rComplexColor, GetItemSet(), eAutoMode, pCondSet, pBackConfigColor, pTextConfigColor);
127 }
128
130 const OutputDevice* pOutDev = nullptr,
131 const Fraction* pScale = nullptr,
132 const SfxItemSet* pCondSet = nullptr,
133 SvtScriptType nScript = SvtScriptType::NONE) const
134 {
135 fillFontOnly(rFont, GetItemSet(), pOutDev, pScale, pCondSet, nScript);
136 }
137
139 void fillFont(vcl::Font& rFont, ScAutoFontColorMode eAutoMode,
140 const OutputDevice* pOutDev = nullptr,
141 const Fraction* pScale = nullptr,
142 const SfxItemSet* pCondSet = nullptr,
143 SvtScriptType nScript = SvtScriptType::NONE,
144 const Color* pBackConfigColor = nullptr,
145 const Color* pTextConfigColor = nullptr) const
146 {
147 fillFont(rFont, GetItemSet(), eAutoMode, pOutDev, pScale, pCondSet, nScript, pBackConfigColor, pTextConfigColor);
148 }
149
151 static void FillToEditItemSet( SfxItemSet& rEditSet, const SfxItemSet& rSrcSet, const SfxItemSet* pCondSet = nullptr );
153 void FillEditItemSet( SfxItemSet* pEditSet, const SfxItemSet* pCondSet = nullptr ) const;
154
156 static void GetFromEditItemSet( SfxItemSet& rDestSet, const SfxItemSet& rEditSet );
158 void GetFromEditItemSet( const SfxItemSet* pEditSet );
159
160 void FillEditParaItems( SfxItemSet* pSet ) const;
161
162 ScPatternAttr* PutInPool( ScDocument* pDestDoc, ScDocument* pSrcDoc ) const;
163
164 void SetStyleSheet(ScStyleSheet* pNewStyle, bool bClearDirectFormat = true);
165 const ScStyleSheet* GetStyleSheet() const { return pStyle; }
166 const OUString* GetStyleName() const;
167 void UpdateStyleSheet(const ScDocument& rDoc);
168 void StyleToName();
169
170 bool IsVisible() const;
171 bool IsVisibleEqual( const ScPatternAttr& rOther ) const;
172
175 bool IsSymbolFont() const;
176
177 sal_uInt32 GetNumberFormat( SvNumberFormatter* ) const;
178 sal_uInt32 GetNumberFormat( SvNumberFormatter* pFormatter,
179 const SfxItemSet* pCondSet ) const;
180
181 Degree100 GetRotateVal( const SfxItemSet* pCondSet ) const;
182 ScRotateDir GetRotateDir( const SfxItemSet* pCondSet ) const;
183
184 void SetKey(sal_uInt64 nKey);
185 sal_uInt64 GetKey() const;
186
187 static std::optional<bool> FastEqualPatternSets( const SfxItemSet& rSet1, const SfxItemSet& rSet2 );
188
189 // TODO: tdf#135215: This is a band-aid to detect changes and invalidate the hash,
190 // a proper way would be probably to override SfxItemSet::Changed(), but 6cb400f41df0dd10
191 // hardcoded SfxSetItem to contain SfxItemSet.
192 SfxItemSet& GetItemSet() { mxHashCode.reset(); mxVisible.reset(); return SfxSetItem::GetItemSet(); }
194
195private:
196 void CalcHashCode() const;
197 bool CalcVisible() const;
198};
199
200/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt64 mnKey
Definition: patattr.hxx:59
const T & GetItem(TypedWhichId< T > nWhich, const SfxItemSet *pCondSet) const
Definition: patattr.hxx:83
std::optional< sal_uInt32 > mxHashCode
Definition: patattr.hxx:56
void fillFont(vcl::Font &rFont, ScAutoFontColorMode eAutoMode, const OutputDevice *pOutDev=nullptr, const Fraction *pScale=nullptr, const SfxItemSet *pCondSet=nullptr, SvtScriptType nScript=SvtScriptType::NONE, const Color *pBackConfigColor=nullptr, const Color *pTextConfigColor=nullptr) const
Fills a font object from the own item set.
Definition: patattr.hxx:139
ScStyleSheet * pStyle
Definition: patattr.hxx:58
std::optional< OUString > pName
Definition: patattr.hxx:55
const ScStyleSheet * GetStyleSheet() const
Definition: patattr.hxx:165
virtual bool HasLookup() const override
Definition: patattr.hxx:70
const T & GetItem(TypedWhichId< T > nWhich) const
Definition: patattr.hxx:75
void fillColor(model::ComplexColor &rComplexColor, ScAutoFontColorMode eAutoMode, const SfxItemSet *pCondSet=nullptr, const Color *pBackConfigColor=nullptr, const Color *pTextConfigColor=nullptr) const
Definition: patattr.hxx:120
void fillFontOnly(vcl::Font &rFont, const OutputDevice *pOutDev=nullptr, const Fraction *pScale=nullptr, const SfxItemSet *pCondSet=nullptr, SvtScriptType nScript=SvtScriptType::NONE) const
Definition: patattr.hxx:129
SfxItemSet & GetItemSet()
Definition: patattr.hxx:192
const SfxPoolItem & GetItem(sal_uInt16 nWhichP) const
Definition: patattr.hxx:73
std::optional< bool > mxVisible
Definition: patattr.hxx:57
static const T & GetItem(TypedWhichId< T > nWhich, const SfxItemSet &rItemSet, const SfxItemSet *pCondSet)
Definition: patattr.hxx:79
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
virtual lookup_iterator Lookup(lookup_iterator, lookup_iterator end) const
virtual bool operator==(const SfxPoolItem &) const override
const SfxItemSet & GetItemSet() const
virtual SfxSetItem * Clone(SfxItemPool *pPool=nullptr) const override=0
ScRotateDir
Definition: fillinfo.hxx:40
SvtScriptType
const SfxPoolItem * GetItem(const SwTextAttr &rAttr, sal_uInt16 nWhich)
Display
ScAutoFontColorMode
how to treat COL_AUTO in GetFont:
Definition: patattr.hxx:44
@ Print
black or white, depending on background
@ IgnoreAll
like DISPLAY, but ignore stored font and background colors
@ Raw
COL_AUTO is returned.
@ IgnoreBack
like DISPLAY, but ignore stored background color (use configured color)
@ IgnoreFont
like DISPLAY, but ignore stored font color (assume COL_AUTO)
#define SC_DLLPUBLIC
Definition: scdllapi.h:27
SvxCellOrientation
unsigned char sal_uInt8