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 #ifndef INCLUDED_SC_INC_PATATTR_HXX
21 #define INCLUDED_SC_INC_PATATTR_HXX
22 
23 #include <svl/poolitem.hxx>
24 #include <svl/itemset.hxx>
25 #include <svl/languageoptions.hxx>
26 #include <editeng/svxenum.hxx>
27 #include "scdllapi.h"
28 #include "fonthelper.hxx"
29 #include <memory>
30 
31 namespace vcl { class Font; }
32 class OutputDevice;
33 class Fraction;
34 class ScStyleSheet;
35 class SvNumberFormatter;
36 class ScDocument;
37 enum class ScRotateDir : sal_uInt8;
38 
40 
42 {
50 };
51 
53 {
54  std::optional<OUString> pName;
55  mutable std::optional<size_t> mxHashCode;
57  sal_uInt64 mnKey;
58 public:
59  ScPatternAttr(std::unique_ptr<SfxItemSet>&& pItemSet, const OUString& rStyleName);
60  ScPatternAttr(std::unique_ptr<SfxItemSet>&& pItemSet);
61  ScPatternAttr(SfxItemPool* pItemPool);
62  ScPatternAttr(const ScPatternAttr& rPatternAttr);
63 
64  virtual ~ScPatternAttr() override;
65 
66  virtual ScPatternAttr* Clone( SfxItemPool *pPool = nullptr ) const override;
67 
68  virtual bool operator==(const SfxPoolItem& rCmp) const override;
69 
70  const SfxPoolItem& GetItem( sal_uInt16 nWhichP ) const
71  { return GetItemSet().Get(nWhichP); }
72  template<class T> const T& GetItem( TypedWhichId<T> nWhich ) const
73  { return static_cast<const T&>(GetItem(sal_uInt16(nWhich))); }
74 
75  static const SfxPoolItem& GetItem( sal_uInt16 nWhich, const SfxItemSet& rItemSet, const SfxItemSet* pCondSet );
76  template<class T> static const T& GetItem( TypedWhichId<T> nWhich, const SfxItemSet& rItemSet, const SfxItemSet* pCondSet )
77  { return static_cast<const T&>(GetItem(sal_uInt16(nWhich), rItemSet, pCondSet)); }
78 
79  const SfxPoolItem& GetItem( sal_uInt16 nWhich, const SfxItemSet* pCondSet ) const;
80  template<class T> const T& GetItem( TypedWhichId<T> nWhich, const SfxItemSet* pCondSet ) const
81  { return static_cast<const T&>(GetItem(sal_uInt16(nWhich), pCondSet)); }
82 
84  bool HasItemsSet( const sal_uInt16* pWhich ) const;
85  void ClearItems( const sal_uInt16* pWhich );
86 
87  void DeleteUnchanged( const ScPatternAttr* pOldAttrs );
88 
89  static SvxCellOrientation GetCellOrientation( const SfxItemSet& rItemSet, const SfxItemSet* pCondSet );
90  SvxCellOrientation GetCellOrientation( const SfxItemSet* pCondSet = nullptr ) const;
91 
93  static void GetFont( vcl::Font& rFont, const SfxItemSet& rItemSet,
94  ScAutoFontColorMode eAutoMode,
95  const OutputDevice* pOutDev = nullptr,
96  const Fraction* pScale = nullptr,
97  const SfxItemSet* pCondSet = nullptr,
98  SvtScriptType nScript = SvtScriptType::NONE, const Color* pBackConfigColor = nullptr,
99  const Color* pTextConfigColor = nullptr );
100 
101  static ScDxfFont GetDxfFont(const SfxItemSet& rSet, SvtScriptType nScript);
103  void GetFont( vcl::Font& rFont, ScAutoFontColorMode eAutoMode,
104  const OutputDevice* pOutDev = nullptr,
105  const Fraction* pScale = nullptr,
106  const SfxItemSet* pCondSet = nullptr,
107  SvtScriptType nScript = SvtScriptType::NONE,
108  const Color* pBackConfigColor = nullptr,
109  const Color* pTextConfigColor = nullptr ) const;
110 
112  static void FillToEditItemSet( SfxItemSet& rEditSet, const SfxItemSet& rSrcSet, const SfxItemSet* pCondSet = nullptr );
114  void FillEditItemSet( SfxItemSet* pEditSet, const SfxItemSet* pCondSet = nullptr ) const;
115 
117  static void GetFromEditItemSet( SfxItemSet& rDestSet, const SfxItemSet& rEditSet );
119  void GetFromEditItemSet( const SfxItemSet* pEditSet );
120 
121  void FillEditParaItems( SfxItemSet* pSet ) const;
122 
123  ScPatternAttr* PutInPool( ScDocument* pDestDoc, ScDocument* pSrcDoc ) const;
124 
125  void SetStyleSheet(ScStyleSheet* pNewStyle, bool bClearDirectFormat = true);
126  const ScStyleSheet* GetStyleSheet() const { return pStyle; }
127  const OUString* GetStyleName() const;
128  void UpdateStyleSheet(const ScDocument& rDoc);
129  void StyleToName();
130 
131  bool IsVisible() const;
132  bool IsVisibleEqual( const ScPatternAttr& rOther ) const;
133 
136  bool IsSymbolFont() const;
137 
138  sal_uInt32 GetNumberFormat( SvNumberFormatter* ) const;
139  sal_uInt32 GetNumberFormat( SvNumberFormatter* pFormatter,
140  const SfxItemSet* pCondSet ) const;
141 
142  tools::Long GetRotateVal( const SfxItemSet* pCondSet ) const;
143  ScRotateDir GetRotateDir( const SfxItemSet* pCondSet ) const;
144 
145  void SetKey(sal_uInt64 nKey);
146  sal_uInt64 GetKey() const;
147 
148 private:
149  void CalcHashCode() const;
150 };
151 
152 #endif
153 
154 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ScRotateDir
Definition: fillinfo.hxx:41
like DISPLAY, but ignore stored font and background colors
const SfxPoolItem * GetItem(const SwTextAttr &rAttr, sal_uInt16 nWhich)
long Long
virtual bool operator==(const SfxPoolItem &) const override
sal_uInt64 mnKey
Definition: patattr.hxx:57
const SfxItemSet & GetItemSet() const
like DISPLAY, but ignore stored background color (use configured color)
like DISPLAY, but ignore stored font color (assume COL_AUTO)
ScStyleSheet * pStyle
Definition: patattr.hxx:56
const SfxPoolItem & GetItem(sal_uInt16 nWhichP) const
Definition: patattr.hxx:70
static const T & GetItem(TypedWhichId< T > nWhich, const SfxItemSet &rItemSet, const SfxItemSet *pCondSet)
Definition: patattr.hxx:76
SvtScriptType
std::optional< size_t > mxHashCode
Definition: patattr.hxx:55
const ScStyleSheet * GetStyleSheet() const
Definition: patattr.hxx:126
virtual SfxSetItem * Clone(SfxItemPool *pPool=nullptr) const override=0
ScAutoFontColorMode
how to treat COL_AUTO in GetFont:
Definition: patattr.hxx:41
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
unsigned char sal_uInt8
black or white, depending on background
std::optional< OUString > pName
Definition: patattr.hxx:54
from style settings, or black/white if needed
const T & GetItem(TypedWhichId< T > nWhich) const
Definition: patattr.hxx:72
SvxCellOrientation
#define SC_DLLPUBLIC
Definition: scdllapi.h:28
const T & GetItem(TypedWhichId< T > nWhich, const SfxItemSet *pCondSet) const
Definition: patattr.hxx:80