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>
26 #include <vcl/GraphicObject.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 SfxPoolItem* 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 SfxPoolItem* 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 sal_Int16 checkAndCorrectValue(sal_Int16 nValue);
88 
89 public:
92  {}
93  SwRotationGrf( sal_Int16 nVal, const Size& rSz );
94 
95  // pure virtual methods from SfxInt16Item
96  virtual SfxPoolItem* 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; }
109 };
110 
112 {
113 public:
114  SwLuminanceGrf( sal_Int16 nVal = 0 )
116  {}
117 
118  // pure virtual methods from SfxInt16Item
119  virtual SfxPoolItem* Clone( SfxItemPool *pPool = nullptr ) const override;
120  virtual bool GetPresentation( SfxItemPresentation ePres,
121  MapUnit eCoreMetric,
122  MapUnit ePresMetric,
123  OUString &rText,
124  const IntlWrapper& rIntl ) const override;
125 };
126 
128 {
129 public:
130  SwContrastGrf( sal_Int16 nVal = 0 )
132  {}
133 
134  // pure virtual methods from SfxInt16Item
135  virtual SfxPoolItem* Clone( SfxItemPool *pPool = nullptr ) const override;
136  virtual bool GetPresentation( SfxItemPresentation ePres,
137  MapUnit eCoreMetric,
138  MapUnit ePresMetric,
139  OUString &rText,
140  const IntlWrapper& rIntl ) const override;
141 };
142 
144 {
145 protected:
146  SwChannelGrf( sal_Int16 nVal, sal_uInt16 nWhichL )
147  : SfxInt16Item( nWhichL, nVal )
148  {}
149 
150 public:
151  // pure virtual methods from SfxInt16Item
152  virtual bool GetPresentation( SfxItemPresentation ePres,
153  MapUnit eCoreMetric,
154  MapUnit ePresMetric,
155  OUString &rText,
156  const IntlWrapper& rIntl ) const override;
157 };
158 
160 {
161 public:
162  SwChannelRGrf( sal_Int16 nVal = 0 )
164  {}
165  virtual SfxPoolItem* Clone( SfxItemPool *pPool = nullptr ) const override;
166 };
168 {
169 public:
170  SwChannelGGrf( sal_Int16 nVal = 0 )
172  {}
173  virtual SfxPoolItem* Clone( SfxItemPool *pPool = nullptr ) const override;
174 };
176 {
177 public:
178  SwChannelBGrf( sal_Int16 nVal = 0 )
180  {}
181  virtual SfxPoolItem* Clone( SfxItemPool *pPool = nullptr ) const override;
182 };
183 
185 {
186  double m_nValue;
187 public:
188  SwGammaGrf() : SfxPoolItem( RES_GRFATR_GAMMA ), m_nValue( 1.0 )
189  {}
190 
191  SwGammaGrf( const double& rVal )
192  : SfxPoolItem( RES_GRFATR_GAMMA ), m_nValue( rVal )
193  {}
194 
195  // pure virtual methods from SfxEnumItem
196  virtual SfxPoolItem* Clone( SfxItemPool *pPool = nullptr ) const override;
197  virtual bool operator==( const SfxPoolItem& ) const override;
198  virtual bool GetPresentation( SfxItemPresentation ePres,
199  MapUnit eCoreMetric,
200  MapUnit ePresMetric,
201  OUString &rText,
202  const IntlWrapper& rIntl ) const override;
203 
204  virtual bool QueryValue( css::uno::Any& rVal,
205  sal_uInt8 nMemberId = 0 ) const override;
206  virtual bool PutValue( const css::uno::Any& rVal,
207  sal_uInt8 nMemberId ) override;
208 
209  const double& GetValue() const { return m_nValue; }
210 };
211 
213 {
214 public:
215  SwInvertGrf( bool bVal = false )
216  : SfxBoolItem( RES_GRFATR_INVERT, bVal )
217  {}
218 
219  // pure virtual methods from SfxInt16Item
220  virtual SfxPoolItem* Clone( SfxItemPool *pPool = nullptr ) const override;
221  virtual bool GetPresentation( SfxItemPresentation ePres,
222  MapUnit eCoreMetric,
223  MapUnit ePresMetric,
224  OUString &rText,
225  const IntlWrapper& rIntl ) const override;
226 };
227 
229 {
230 public:
233  {}
234 
235  // pure virtual methods from SfxInt16Item
236  virtual SfxPoolItem* Clone( SfxItemPool *pPool = nullptr ) const override;
237  virtual bool GetPresentation( SfxItemPresentation ePres,
238  MapUnit eCoreMetric,
239  MapUnit ePresMetric,
240  OUString &rText,
241  const IntlWrapper& rIntl ) const override;
242  virtual bool QueryValue( css::uno::Any& rVal,
243  sal_uInt8 nMemberId = 0 ) const override;
244  virtual bool PutValue( const css::uno::Any& rVal,
245  sal_uInt8 nMemberId ) override;
246 };
247 
248 // MSVC hack:
249 class SwDrawModeGrf_Base: public SfxEnumItem<GraphicDrawMode> {
250 protected:
253 };
254 
256 {
257 public:
258  SwDrawModeGrf( GraphicDrawMode nMode = GraphicDrawMode::Standard )
259  : SwDrawModeGrf_Base( nMode )
260  {}
261 
262  // pure virtual methods of SfxPoolItem
263  virtual SfxPoolItem* Clone( SfxItemPool *pPool = nullptr ) const override;
264 
265  // pure virtual methods of SfxEnumItem
266  virtual sal_uInt16 GetValueCount() const override;
267  virtual bool GetPresentation( SfxItemPresentation ePres,
268  MapUnit eCoreMetric,
269  MapUnit ePresMetric,
270  OUString &rText,
271  const IntlWrapper& rIntl ) const override;
272 
273  virtual bool QueryValue( css::uno::Any& rVal,
274  sal_uInt8 nMemberId = 0 ) const override;
275  virtual bool PutValue( const css::uno::Any& rVal,
276  sal_uInt8 nMemberId ) override;
277 };
278 
279 // Implementation of graphics attributes methods of SwAttr
280 inline const SwMirrorGrf &SwAttrSet::GetMirrorGrf(bool bInP) const
281  { return Get( RES_GRFATR_MIRRORGRF,bInP); }
282 inline const SwCropGrf &SwAttrSet::GetCropGrf(bool bInP) const
283  { return Get( RES_GRFATR_CROPGRF,bInP); }
284 inline const SwRotationGrf &SwAttrSet::GetRotationGrf(bool bInP) const
285  { return Get( RES_GRFATR_ROTATION,bInP); }
286 inline const SwLuminanceGrf &SwAttrSet::GetLuminanceGrf(bool bInP) const
287  { return Get( RES_GRFATR_LUMINANCE,bInP); }
288 inline const SwContrastGrf &SwAttrSet::GetContrastGrf(bool bInP) const
289  { return Get( RES_GRFATR_CONTRAST,bInP); }
290 inline const SwChannelRGrf &SwAttrSet::GetChannelRGrf(bool bInP) const
291  { return Get( RES_GRFATR_CHANNELR,bInP); }
292 inline const SwChannelGGrf &SwAttrSet::GetChannelGGrf(bool bInP) const
293  { return Get( RES_GRFATR_CHANNELG,bInP); }
294 inline const SwChannelBGrf &SwAttrSet::GetChannelBGrf(bool bInP) const
295  { return Get( RES_GRFATR_CHANNELB,bInP); }
296 inline const SwGammaGrf &SwAttrSet::GetGammaGrf(bool bInP) const
297  { return Get( RES_GRFATR_GAMMA,bInP); }
298 inline const SwInvertGrf &SwAttrSet::GetInvertGrf(bool bInP) const
299  { return Get( RES_GRFATR_INVERT,bInP); }
300 inline const SwTransparencyGrf &SwAttrSet::GetTransparencyGrf(bool bInP) const
301  { return Get( RES_GRFATR_TRANSPARENCY,bInP); }
302 inline const SwDrawModeGrf &SwAttrSet::GetDrawModeGrf(bool bInP) const
303  { return Get( RES_GRFATR_DRAWMODE,bInP); }
304 
305 #endif // INCLUDED_SW_INC_GRFATR_HXX
306 
307 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Size const m_aUnrotatedSize
Definition: grfatr.hxx:83
virtual bool GetPresentation(SfxItemPresentation, MapUnit, MapUnit, OUString &rText, const IntlWrapper &) const override
const SwGammaGrf & GetGammaGrf(bool=true) const
Definition: grfatr.hxx:296
const double & GetValue() const
Definition: grfatr.hxx:209
SwChannelGGrf(sal_Int16 nVal=0)
Definition: grfatr.hxx:170
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
Definition: grfatr.cxx:277
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
SwChannelBGrf(sal_Int16 nVal=0)
Definition: grfatr.hxx:178
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const override
Definition: grfatr.cxx:229
#define RES_GRFATR_CHANNELB
Definition: hintids.hxx:249
const SwChannelRGrf & GetChannelRGrf(bool=true) const
Definition: grfatr.hxx:290
MirrorGraph
Definition: grfatr.hxx:31
SwChannelGrf(sal_Int16 nVal, sal_uInt16 nWhichL)
Definition: grfatr.hxx:146
const Size & GetUnrotatedSize() const
Definition: grfatr.hxx:108
SwContrastGrf(sal_Int16 nVal=0)
Definition: grfatr.hxx:130
#define RES_GRFATR_MIRRORGRF
Definition: hintids.hxx:241
virtual bool operator==(SfxPoolItem const &other) const override
const SwChannelBGrf & GetChannelBGrf(bool=true) const
Definition: grfatr.hxx:294
SwLuminanceGrf(sal_Int16 nVal=0)
Definition: grfatr.hxx:114
const SwTransparencyGrf & GetTransparencyGrf(bool=true) const
Definition: grfatr.hxx:300
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const
#define RES_GRFATR_LUMINANCE
Definition: hintids.hxx:245
virtual bool GetPresentation(SfxItemPresentation, MapUnit, MapUnit, OUString &rText, const IntlWrapper &) const override
GraphicDrawMode
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt8 nMemberId) override
Definition: grfatr.cxx:287
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt8 nMemberId)
const SwCropGrf & GetCropGrf(bool=true) const
Definition: grfatr.hxx:282
bool m_bGrfToggle
Definition: grfatr.hxx:41
#define RES_GRFATR_CONTRAST
Definition: hintids.hxx:246
#define RES_GRFATR_INVERT
Definition: hintids.hxx:251
SwDrawModeGrf(GraphicDrawMode nMode=GraphicDrawMode::Standard)
Definition: grfatr.hxx:258
#define RES_GRFATR_DRAWMODE
Definition: hintids.hxx:253
SfxItemPresentation
SwDrawModeGrf_Base(GraphicDrawMode nMode)
Definition: grfatr.hxx:251
double m_nValue
Definition: grfatr.hxx:186
#define RES_GRFATR_CHANNELG
Definition: hintids.hxx:248
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:737
#define RES_GRFATR_ROTATION
Definition: hintids.hxx:244
#define RES_GRFATR_GAMMA
Definition: hintids.hxx:250
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const override
Definition: grfatr.cxx:234
virtual SfxPoolItem * Clone(SfxItemPool *=nullptr) const override
virtual SfxPoolItem * Clone(SfxItemPool *=nullptr) const override
virtual bool GetPresentation(SfxItemPresentation, MapUnit, MapUnit, OUString &rText, const IntlWrapper &) const override
const SwRotationGrf & GetRotationGrf(bool=true) const
Definition: grfatr.hxx:284
const SwContrastGrf & GetContrastGrf(bool=true) const
Definition: grfatr.hxx:288
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const override
Definition: grfatr.cxx:270
SwTransparencyGrf(sal_Int8 nVal=0)
Definition: grfatr.hxx:231
const SwMirrorGrf & GetMirrorGrf(bool=true) const
Definition: grfatr.hxx:280
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:789
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
SwInvertGrf(bool bVal=false)
Definition: grfatr.hxx:215
#define RES_GRFATR_CHANNELR
Definition: hintids.hxx:247
virtual sal_uInt16 GetValueCount() const =0
#define RES_GRFATR_CROPGRF
Definition: hintids.hxx:242
const SwChannelGGrf & GetChannelGGrf(bool=true) const
Definition: grfatr.hxx:292
SwGammaGrf(const double &rVal)
Definition: grfatr.hxx:191
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const override
Definition: grfatr.cxx:265
#define RES_GRFATR_TRANSPARENCY
Definition: hintids.hxx:252
SwGammaGrf()
Definition: grfatr.hxx:188
const SwDrawModeGrf & GetDrawModeGrf(bool=true) const
Definition: grfatr.hxx:302
MapUnit
const SwInvertGrf & GetInvertGrf(bool=true) const
Definition: grfatr.hxx:298
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
const SwLuminanceGrf & GetLuminanceGrf(bool=true) const
Definition: grfatr.hxx:286
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const override
Definition: grfatr.cxx:224
SwMirrorGrf(MirrorGraph eMiro=MirrorGraph::Dont)
Definition: grfatr.hxx:44
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:162
virtual bool GetPresentation(SfxItemPresentation ePres, MapUnit eCoreMetric, MapUnit ePresMetric, OUString &rText, const IntlWrapper &rIntl) const override
Definition: attrdesc.cxx:776