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