LibreOffice Module sw (master)  1
grfatr.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 #ifndef INCLUDED_SW_INC_GRFATR_HXX
20 #define INCLUDED_SW_INC_GRFATR_HXX
21 
22 #include "hintids.hxx"
23 #include <tools/gen.hxx>
24 #include <svl/eitem.hxx>
25 #include <svl/intitem.hxx>
27 #include <svx/grfcrop.hxx>
28 #include "swdllapi.h"
29 #include "swatrset.hxx"
30 
31 enum class MirrorGraph
32 {
33  Dont,
34  Vertical,
35  Horizontal,
36  Both
37 };
38 
39 class SW_DLLPUBLIC SwMirrorGrf : public SfxEnumItem<MirrorGraph>
40 {
41  bool m_bGrfToggle; // Flip graphics on even pages.
42 
43 public:
45  : SfxEnumItem( RES_GRFATR_MIRRORGRF, eMiro ), m_bGrfToggle( false )
46  {}
47 
48  // pure virtual methods of SfxPoolItem
49  virtual SwMirrorGrf* Clone( SfxItemPool *pPool = nullptr ) const override;
50 
51  // pure virtual methods of SfxEnumItem
52  virtual sal_uInt16 GetValueCount() const override;
53  virtual bool operator==( const SfxPoolItem& ) const override;
54  virtual bool GetPresentation( SfxItemPresentation ePres,
55  MapUnit eCoreMetric,
56  MapUnit ePresMetric,
57  OUString &rText,
58  const IntlWrapper& rIntl ) const override;
59 
60  virtual bool QueryValue( css::uno::Any& rVal,
61  sal_uInt8 nMemberId = 0 ) const override;
62  virtual bool PutValue( const css::uno::Any& rVal,
63  sal_uInt8 nMemberId ) override;
64 
65  bool IsGrfToggle() const { return m_bGrfToggle; }
66  void SetGrfToggle( bool bNew ) { m_bGrfToggle = bNew; }
67 };
68 
70 {
71 public:
72  SwCropGrf();
73  SwCropGrf( sal_Int32 nLeft, sal_Int32 nRight,
74  sal_Int32 nTop, sal_Int32 nBottom );
75 
76  // "pure virtual methods" of SfxPoolItem
77  virtual SwCropGrf* Clone( SfxItemPool *pPool = nullptr ) const override;
78 };
79 
80 class SAL_DLLPUBLIC_RTTI SwRotationGrf : public SfxUInt16Item
81 {
82 private:
84 
85  // tdf#115529 check and evtl. correct value, it is in 10th
86  // degrees and *has* to be in the range [0 .. 3600[
87  static Degree10 checkAndCorrectValue(Degree10 nValue);
88 
89 public:
92  {}
93  SwRotationGrf( Degree10 nVal, const Size& rSz );
94 
95  // pure virtual methods from SfxInt16Item
96  virtual SwRotationGrf* Clone( SfxItemPool *pPool = nullptr ) const override;
97  virtual bool operator==( const SfxPoolItem& ) const override;
98  virtual bool GetPresentation( SfxItemPresentation ePres,
99  MapUnit eCoreMetric,
100  MapUnit ePresMetric,
101  OUString &rText,
102  const IntlWrapper& rIntl ) const override;
103  virtual bool QueryValue( css::uno::Any& rVal,
104  sal_uInt8 nMemberId = 0 ) const override;
105  virtual bool PutValue( const css::uno::Any& rVal,
106  sal_uInt8 nMemberId ) override;
107 
108  const Size& GetUnrotatedSize() const { return m_aUnrotatedSize; }
111 };
112 
114 {
115 public:
116  SwLuminanceGrf( sal_Int16 nVal = 0 )
118  {}
119 
120  // pure virtual methods from SfxInt16Item
121  virtual SwLuminanceGrf* Clone( SfxItemPool *pPool = nullptr ) const override;
122  virtual bool GetPresentation( SfxItemPresentation ePres,
123  MapUnit eCoreMetric,
124  MapUnit ePresMetric,
125  OUString &rText,
126  const IntlWrapper& rIntl ) const override;
127 };
128 
130 {
131 public:
132  SwContrastGrf( sal_Int16 nVal = 0 )
134  {}
135 
136  // pure virtual methods from SfxInt16Item
137  virtual SwContrastGrf* Clone( SfxItemPool *pPool = nullptr ) const override;
138  virtual bool GetPresentation( SfxItemPresentation ePres,
139  MapUnit eCoreMetric,
140  MapUnit ePresMetric,
141  OUString &rText,
142  const IntlWrapper& rIntl ) const override;
143 };
144 
146 {
147 protected:
148  SwChannelGrf( sal_Int16 nVal, sal_uInt16 nWhichL )
149  : SfxInt16Item( nWhichL, nVal )
150  {}
151 
152 public:
153  // pure virtual methods from SfxInt16Item
154  virtual bool GetPresentation( SfxItemPresentation ePres,
155  MapUnit eCoreMetric,
156  MapUnit ePresMetric,
157  OUString &rText,
158  const IntlWrapper& rIntl ) const override;
159 };
160 
162 {
163 public:
164  SwChannelRGrf( sal_Int16 nVal = 0 )
166  {}
167  virtual SwChannelRGrf* Clone( SfxItemPool *pPool = nullptr ) const override;
168 };
170 {
171 public:
172  SwChannelGGrf( sal_Int16 nVal = 0 )
174  {}
175  virtual SwChannelGGrf* Clone( SfxItemPool *pPool = nullptr ) const override;
176 };
178 {
179 public:
180  SwChannelBGrf( sal_Int16 nVal = 0 )
182  {}
183  virtual SwChannelBGrf* Clone( SfxItemPool *pPool = nullptr ) const override;
184 };
185 
187 {
188  double m_nValue;
189 public:
190  SwGammaGrf() : SfxPoolItem( RES_GRFATR_GAMMA ), m_nValue( 1.0 )
191  {}
192 
193  SwGammaGrf( const double& rVal )
194  : SfxPoolItem( RES_GRFATR_GAMMA ), m_nValue( rVal )
195  {}
196 
197  // pure virtual methods from SfxEnumItem
198  virtual SwGammaGrf* Clone( SfxItemPool *pPool = nullptr ) const override;
199  virtual bool operator==( const SfxPoolItem& ) const override;
200  virtual bool GetPresentation( SfxItemPresentation ePres,
201  MapUnit eCoreMetric,
202  MapUnit ePresMetric,
203  OUString &rText,
204  const IntlWrapper& rIntl ) const override;
205 
206  virtual bool QueryValue( css::uno::Any& rVal,
207  sal_uInt8 nMemberId = 0 ) const override;
208  virtual bool PutValue( const css::uno::Any& rVal,
209  sal_uInt8 nMemberId ) override;
210 
211  const double& GetValue() const { return m_nValue; }
212 };
213 
215 {
216 public:
217  SwInvertGrf( bool bVal = false )
218  : SfxBoolItem( RES_GRFATR_INVERT, bVal )
219  {}
220 
221  // pure virtual methods from SfxInt16Item
222  virtual SwInvertGrf* Clone( SfxItemPool *pPool = nullptr ) const override;
223  virtual bool GetPresentation( SfxItemPresentation ePres,
224  MapUnit eCoreMetric,
225  MapUnit ePresMetric,
226  OUString &rText,
227  const IntlWrapper& rIntl ) const override;
228 };
229 
231 {
232 public:
235  {}
236 
237  // pure virtual methods from SfxInt16Item
238  virtual SwTransparencyGrf* Clone( SfxItemPool *pPool = nullptr ) const override;
239  virtual bool GetPresentation( SfxItemPresentation ePres,
240  MapUnit eCoreMetric,
241  MapUnit ePresMetric,
242  OUString &rText,
243  const IntlWrapper& rIntl ) const override;
244  virtual bool QueryValue( css::uno::Any& rVal,
245  sal_uInt8 nMemberId = 0 ) const override;
246  virtual bool PutValue( const css::uno::Any& rVal,
247  sal_uInt8 nMemberId ) override;
248 };
249 
250 // MSVC hack:
251 class SwDrawModeGrf_Base: public SfxEnumItem<GraphicDrawMode> {
252 protected:
255 };
256 
258 {
259 public:
260  SwDrawModeGrf( GraphicDrawMode nMode = GraphicDrawMode::Standard )
261  : SwDrawModeGrf_Base( nMode )
262  {}
263 
264  // pure virtual methods of SfxPoolItem
265  virtual SwDrawModeGrf* Clone( SfxItemPool *pPool = nullptr ) const override;
266 
267  // pure virtual methods of SfxEnumItem
268  virtual sal_uInt16 GetValueCount() const override;
269  virtual bool GetPresentation( SfxItemPresentation ePres,
270  MapUnit eCoreMetric,
271  MapUnit ePresMetric,
272  OUString &rText,
273  const IntlWrapper& rIntl ) const override;
274 
275  virtual bool QueryValue( css::uno::Any& rVal,
276  sal_uInt8 nMemberId = 0 ) const override;
277  virtual bool PutValue( const css::uno::Any& rVal,
278  sal_uInt8 nMemberId ) override;
279 };
280 
281 // Implementation of graphics attributes methods of SwAttr
282 inline const SwMirrorGrf &SwAttrSet::GetMirrorGrf(bool bInP) const
283  { return Get( RES_GRFATR_MIRRORGRF,bInP); }
284 inline const SwCropGrf &SwAttrSet::GetCropGrf(bool bInP) const
285  { return Get( RES_GRFATR_CROPGRF,bInP); }
286 inline const SwRotationGrf &SwAttrSet::GetRotationGrf(bool bInP) const
287  { return Get( RES_GRFATR_ROTATION,bInP); }
288 inline const SwLuminanceGrf &SwAttrSet::GetLuminanceGrf(bool bInP) const
289  { return Get( RES_GRFATR_LUMINANCE,bInP); }
290 inline const SwContrastGrf &SwAttrSet::GetContrastGrf(bool bInP) const
291  { return Get( RES_GRFATR_CONTRAST,bInP); }
292 inline const SwChannelRGrf &SwAttrSet::GetChannelRGrf(bool bInP) const
293  { return Get( RES_GRFATR_CHANNELR,bInP); }
294 inline const SwChannelGGrf &SwAttrSet::GetChannelGGrf(bool bInP) const
295  { return Get( RES_GRFATR_CHANNELG,bInP); }
296 inline const SwChannelBGrf &SwAttrSet::GetChannelBGrf(bool bInP) const
297  { return Get( RES_GRFATR_CHANNELB,bInP); }
298 inline const SwGammaGrf &SwAttrSet::GetGammaGrf(bool bInP) const
299  { return Get( RES_GRFATR_GAMMA,bInP); }
300 inline const SwInvertGrf &SwAttrSet::GetInvertGrf(bool bInP) const
301  { return Get( RES_GRFATR_INVERT,bInP); }
302 inline const SwTransparencyGrf &SwAttrSet::GetTransparencyGrf(bool bInP) const
303  { return Get( RES_GRFATR_TRANSPARENCY,bInP); }
304 inline const SwDrawModeGrf &SwAttrSet::GetDrawModeGrf(bool bInP) const
305  { return Get( RES_GRFATR_DRAWMODE,bInP); }
306 
307 #endif // INCLUDED_SW_INC_GRFATR_HXX
308 
309 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual bool GetPresentation(SfxItemPresentation, MapUnit, MapUnit, OUString &rText, const IntlWrapper &) const override
const SwGammaGrf & GetGammaGrf(bool=true) const
Definition: grfatr.hxx:298
virtual SwInvertGrf * Clone(SfxItemPool *pPool=nullptr) const override
Definition: grfatr.cxx:263
const double & GetValue() const
Definition: grfatr.hxx:211
SwChannelGGrf(sal_Int16 nVal=0)
Definition: grfatr.hxx:172
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
Definition: grfatr.cxx:275
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt8) override
virtual bool operator==(const SfxPoolItem &) const =0
void SetGrfToggle(bool bNew)
Definition: grfatr.hxx:66
signed char sal_Int8
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const =0
constexpr TypedWhichId< SwTransparencyGrf > RES_GRFATR_TRANSPARENCY(143)
virtual SwChannelBGrf * Clone(SfxItemPool *pPool=nullptr) const override
Definition: grfatr.cxx:232
SwChannelBGrf(sal_Int16 nVal=0)
Definition: grfatr.hxx:180
constexpr TypedWhichId< SwChannelRGrf > RES_GRFATR_CHANNELR(138)
sal_uInt16 GetValue() const
const SwChannelRGrf & GetChannelRGrf(bool=true) const
Definition: grfatr.hxx:292
MirrorGraph
Definition: grfatr.hxx:31
SwChannelGrf(sal_Int16 nVal, sal_uInt16 nWhichL)
Definition: grfatr.hxx:148
constexpr TypedWhichId< SwContrastGrf > RES_GRFATR_CONTRAST(137)
const Size & GetUnrotatedSize() const
Definition: grfatr.hxx:108
SwContrastGrf(sal_Int16 nVal=0)
Definition: grfatr.hxx:132
void SetValue(sal_uInt16 nTheValue)
constexpr TypedWhichId< SwLuminanceGrf > RES_GRFATR_LUMINANCE(136)
virtual SwChannelGGrf * Clone(SfxItemPool *pPool=nullptr) const override
Definition: grfatr.cxx:227
virtual bool operator==(SfxPoolItem const &other) const override
const SwChannelBGrf & GetChannelBGrf(bool=true) const
Definition: grfatr.hxx:296
SwLuminanceGrf(sal_Int16 nVal=0)
Definition: grfatr.hxx:116
const SwTransparencyGrf & GetTransparencyGrf(bool=true) const
Definition: grfatr.hxx:302
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const
virtual bool GetPresentation(SfxItemPresentation, MapUnit, MapUnit, OUString &rText, const IntlWrapper &) const override
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt8 nMemberId) override
Definition: grfatr.cxx:286
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt8 nMemberId)
const SwCropGrf & GetCropGrf(bool=true) const
Definition: grfatr.hxx:284
bool m_bGrfToggle
Definition: grfatr.hxx:41
constexpr TypedWhichId< SwChannelBGrf > RES_GRFATR_CHANNELB(140)
GraphicDrawMode
constexpr TypedWhichId< SwRotationGrf > RES_GRFATR_ROTATION(135)
SwDrawModeGrf(GraphicDrawMode nMode=GraphicDrawMode::Standard)
Definition: grfatr.hxx:260
UNDERLYING_TYPE get() const
SfxItemPresentation
virtual SfxInt16Item * Clone(SfxItemPool *=nullptr) const override
SwDrawModeGrf_Base(GraphicDrawMode nMode)
Definition: grfatr.hxx:253
double m_nValue
Definition: grfatr.hxx:188
Reference< XAnimationNode > Clone(const Reference< XAnimationNode > &xSourceNode, const SdPage *pSource, const SdPage *pTarget)
virtual bool GetPresentation(SfxItemPresentation ePres, MapUnit eCoreMetric, MapUnit ePresMetric, OUString &rText, const IntlWrapper &rIntl) const override
Definition: attrdesc.cxx:734
constexpr TypedWhichId< SwCropGrf > RES_GRFATR_CROPGRF(134)
virtual bool GetPresentation(SfxItemPresentation, MapUnit, MapUnit, OUString &rText, const IntlWrapper &) const override
const SwRotationGrf & GetRotationGrf(bool=true) const
Definition: grfatr.hxx:286
const SwContrastGrf & GetContrastGrf(bool=true) const
Definition: grfatr.hxx:290
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
virtual SwTransparencyGrf * Clone(SfxItemPool *pPool=nullptr) const override
Definition: grfatr.cxx:268
virtual SwChannelRGrf * Clone(SfxItemPool *pPool=nullptr) const override
Definition: grfatr.cxx:222
SwTransparencyGrf(sal_Int8 nVal=0)
Definition: grfatr.hxx:233
Degree10 GetValue() const
Definition: grfatr.hxx:109
const SwMirrorGrf & GetMirrorGrf(bool=true) const
Definition: grfatr.hxx:282
Size m_aUnrotatedSize
Definition: grfatr.hxx:83
constexpr TypedWhichId< SwMirrorGrf > RES_GRFATR_MIRRORGRF(RES_GRFATR_BEGIN)
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8=0) const override
virtual bool GetPresentation(SfxItemPresentation ePres, MapUnit eCoreMetric, MapUnit ePresMetric, OUString &rText, const IntlWrapper &rIntl) const override
Definition: attrdesc.cxx:786
virtual bool GetPresentation(SfxItemPresentation ePresentation, MapUnit eCoreMetric, MapUnit ePresentationMetric, OUString &rText, const IntlWrapper &rIntlWrapper) const
virtual bool operator==(const SfxPoolItem &rItem) const override
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
unsigned char sal_uInt8
constexpr TypedWhichId< SwChannelGGrf > RES_GRFATR_CHANNELG(139)
constexpr TypedWhichId< SwInvertGrf > RES_GRFATR_INVERT(142)
SwInvertGrf(bool bVal=false)
Definition: grfatr.hxx:217
constexpr TypedWhichId< SwDrawModeGrf > RES_GRFATR_DRAWMODE(144)
virtual sal_uInt16 GetValueCount() const =0
const SwChannelGGrf & GetChannelGGrf(bool=true) const
Definition: grfatr.hxx:294
SwGammaGrf(const double &rVal)
Definition: grfatr.hxx:193
virtual SfxUInt16Item * Clone(SfxItemPool *=nullptr) const override
SwGammaGrf()
Definition: grfatr.hxx:190
const SwDrawModeGrf & GetDrawModeGrf(bool=true) const
Definition: grfatr.hxx:304
MapUnit
const SwInvertGrf & GetInvertGrf(bool=true) const
Definition: grfatr.hxx:300
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
const SwLuminanceGrf & GetLuminanceGrf(bool=true) const
Definition: grfatr.hxx:288
SwMirrorGrf(MirrorGraph eMiro=MirrorGraph::Dont)
Definition: grfatr.hxx:44
void SetValue(Degree10 d)
Definition: grfatr.hxx:110
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt8 nMemberId) override
bool IsGrfToggle() const
Definition: grfatr.hxx:65
SwChannelRGrf(sal_Int16 nVal=0)
Definition: grfatr.hxx:164
virtual bool GetPresentation(SfxItemPresentation ePres, MapUnit eCoreMetric, MapUnit ePresMetric, OUString &rText, const IntlWrapper &rIntl) const override
Definition: attrdesc.cxx:773
constexpr TypedWhichId< SwGammaGrf > RES_GRFATR_GAMMA(141)