Bump version to 21.06.18.1
[LibreOffice.git] / sw / inc / grfatr.hxx
blob55d0f99ddb82e7d491ca2c1c8aa00d2a0e4358f0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SW_INC_GRFATR_HXX
20 #define INCLUDED_SW_INC_GRFATR_HXX
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"
31 enum class MirrorGraph
33 Dont,
34 Vertical,
35 Horizontal,
36 Both
39 class SW_DLLPUBLIC SwMirrorGrf : public SfxEnumItem<MirrorGraph>
41 bool m_bGrfToggle; // Flip graphics on even pages.
43 public:
44 SwMirrorGrf( MirrorGraph eMiro = MirrorGraph::Dont )
45 : SfxEnumItem( RES_GRFATR_MIRRORGRF, eMiro ), m_bGrfToggle( false )
48 // pure virtual methods of SfxPoolItem
49 virtual SwMirrorGrf* Clone( SfxItemPool *pPool = nullptr ) const override;
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;
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;
65 bool IsGrfToggle() const { return m_bGrfToggle; }
66 void SetGrfToggle( bool bNew ) { m_bGrfToggle = bNew; }
69 class SW_DLLPUBLIC SwCropGrf : public SvxGrfCrop
71 public:
72 SwCropGrf();
73 SwCropGrf( sal_Int32 nLeft, sal_Int32 nRight,
74 sal_Int32 nTop, sal_Int32 nBottom );
76 // "pure virtual methods" of SfxPoolItem
77 virtual SwCropGrf* Clone( SfxItemPool *pPool = nullptr ) const override;
80 class SAL_DLLPUBLIC_RTTI SwRotationGrf : public SfxUInt16Item
82 private:
83 Size m_aUnrotatedSize;
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);
89 public:
90 SwRotationGrf()
91 : SfxUInt16Item( RES_GRFATR_ROTATION, 0 )
93 SwRotationGrf( sal_Int16 nVal, const Size& rSz );
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;
108 const Size& GetUnrotatedSize() const { return m_aUnrotatedSize; }
111 class SW_DLLPUBLIC SwLuminanceGrf : public SfxInt16Item
113 public:
114 SwLuminanceGrf( sal_Int16 nVal = 0 )
115 : SfxInt16Item( RES_GRFATR_LUMINANCE, nVal )
118 // pure virtual methods from SfxInt16Item
119 virtual SwLuminanceGrf* 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;
127 class SW_DLLPUBLIC SwContrastGrf : public SfxInt16Item
129 public:
130 SwContrastGrf( sal_Int16 nVal = 0 )
131 : SfxInt16Item( RES_GRFATR_CONTRAST, nVal )
134 // pure virtual methods from SfxInt16Item
135 virtual SwContrastGrf* 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;
143 class SwChannelGrf : public SfxInt16Item
145 protected:
146 SwChannelGrf( sal_Int16 nVal, sal_uInt16 nWhichL )
147 : SfxInt16Item( nWhichL, nVal )
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;
159 class SwChannelRGrf : public SwChannelGrf
161 public:
162 SwChannelRGrf( sal_Int16 nVal = 0 )
163 : SwChannelGrf( nVal, RES_GRFATR_CHANNELR )
165 virtual SwChannelRGrf* Clone( SfxItemPool *pPool = nullptr ) const override;
167 class SwChannelGGrf : public SwChannelGrf
169 public:
170 SwChannelGGrf( sal_Int16 nVal = 0 )
171 : SwChannelGrf( nVal, RES_GRFATR_CHANNELG )
173 virtual SwChannelGGrf* Clone( SfxItemPool *pPool = nullptr ) const override;
175 class SwChannelBGrf : public SwChannelGrf
177 public:
178 SwChannelBGrf( sal_Int16 nVal = 0 )
179 : SwChannelGrf( nVal, RES_GRFATR_CHANNELB )
181 virtual SwChannelBGrf* Clone( SfxItemPool *pPool = nullptr ) const override;
184 class SW_DLLPUBLIC SwGammaGrf : public SfxPoolItem
186 double m_nValue;
187 public:
188 SwGammaGrf() : SfxPoolItem( RES_GRFATR_GAMMA ), m_nValue( 1.0 )
191 SwGammaGrf( const double& rVal )
192 : SfxPoolItem( RES_GRFATR_GAMMA ), m_nValue( rVal )
195 // pure virtual methods from SfxEnumItem
196 virtual SwGammaGrf* 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;
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;
209 const double& GetValue() const { return m_nValue; }
212 class SwInvertGrf: public SfxBoolItem
214 public:
215 SwInvertGrf( bool bVal = false )
216 : SfxBoolItem( RES_GRFATR_INVERT, bVal )
219 // pure virtual methods from SfxInt16Item
220 virtual SwInvertGrf* 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;
228 class SwTransparencyGrf : public SfxByteItem
230 public:
231 SwTransparencyGrf( sal_Int8 nVal = 0 )
232 : SfxByteItem( RES_GRFATR_TRANSPARENCY, nVal )
235 // pure virtual methods from SfxInt16Item
236 virtual SwTransparencyGrf* 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;
248 // MSVC hack:
249 class SwDrawModeGrf_Base: public SfxEnumItem<GraphicDrawMode> {
250 protected:
251 SwDrawModeGrf_Base(GraphicDrawMode nMode):
252 SfxEnumItem(RES_GRFATR_DRAWMODE, nMode) {}
255 class SW_DLLPUBLIC SwDrawModeGrf : public SwDrawModeGrf_Base
257 public:
258 SwDrawModeGrf( GraphicDrawMode nMode = GraphicDrawMode::Standard )
259 : SwDrawModeGrf_Base( nMode )
262 // pure virtual methods of SfxPoolItem
263 virtual SwDrawModeGrf* Clone( SfxItemPool *pPool = nullptr ) const override;
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;
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;
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); }
305 #endif // INCLUDED_SW_INC_GRFATR_HXX
307 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */