Update git submodules
[LibreOffice.git] / sw / inc / grfatr.hxx
blob39bdad0c1d1d7bbe31a8127142a119f3902c8cd9
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/GraphicAttributes.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 final : 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, SfxItemType::SwMirrorGrfType, 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 final : 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 final : 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 Degree10 checkAndCorrectValue(Degree10 nValue);
89 public:
90 SwRotationGrf()
91 : SfxUInt16Item( RES_GRFATR_ROTATION, 0, SfxItemType::SwRotationGrfType )
93 SwRotationGrf( Degree10 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; }
109 Degree10 GetValue() const { return Degree10(SfxUInt16Item::GetValue()); }
110 void SetValue(Degree10 d) { SfxUInt16Item::SetValue(d.get()); }
113 class SW_DLLPUBLIC SwLuminanceGrf final : public SfxInt16Item
115 public:
116 SwLuminanceGrf( sal_Int16 nVal = 0 )
117 : SfxInt16Item( RES_GRFATR_LUMINANCE, nVal, SfxItemType::SwLuminanceGrfType )
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;
129 class SW_DLLPUBLIC SwContrastGrf final : public SfxInt16Item
131 public:
132 SwContrastGrf( sal_Int16 nVal = 0 )
133 : SfxInt16Item( RES_GRFATR_CONTRAST, nVal, SfxItemType::SwContrastGrfType )
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;
145 class SwChannelGrf : public SfxInt16Item
147 protected:
148 SwChannelGrf( sal_Int16 nVal, sal_uInt16 nWhichL )
149 : SfxInt16Item( nWhichL, nVal, SfxItemType::SwChannelGrfType )
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;
161 class SwChannelRGrf final : public SwChannelGrf
163 public:
164 SwChannelRGrf( sal_Int16 nVal = 0 )
165 : SwChannelGrf( nVal, RES_GRFATR_CHANNELR )
167 virtual SwChannelRGrf* Clone( SfxItemPool *pPool = nullptr ) const override;
169 class SwChannelGGrf final : public SwChannelGrf
171 public:
172 SwChannelGGrf( sal_Int16 nVal = 0 )
173 : SwChannelGrf( nVal, RES_GRFATR_CHANNELG )
175 virtual SwChannelGGrf* Clone( SfxItemPool *pPool = nullptr ) const override;
177 class SwChannelBGrf final : public SwChannelGrf
179 public:
180 SwChannelBGrf( sal_Int16 nVal = 0 )
181 : SwChannelGrf( nVal, RES_GRFATR_CHANNELB )
183 virtual SwChannelBGrf* Clone( SfxItemPool *pPool = nullptr ) const override;
186 class SW_DLLPUBLIC SwGammaGrf final : public SfxPoolItem
188 double m_nValue;
189 public:
190 SwGammaGrf() : SfxPoolItem( RES_GRFATR_GAMMA, SfxItemType::SwGammaGrfType ), m_nValue( 1.0 )
193 SwGammaGrf( const double& rVal )
194 : SfxPoolItem( RES_GRFATR_GAMMA, SfxItemType::SwGammaGrfType ), m_nValue( rVal )
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 supportsHashCode() const override { return true; }
201 virtual size_t hashCode() const override { return static_cast<size_t>(m_nValue); }
202 virtual bool GetPresentation( SfxItemPresentation ePres,
203 MapUnit eCoreMetric,
204 MapUnit ePresMetric,
205 OUString &rText,
206 const IntlWrapper& rIntl ) const override;
208 virtual bool QueryValue( css::uno::Any& rVal,
209 sal_uInt8 nMemberId = 0 ) const override;
210 virtual bool PutValue( const css::uno::Any& rVal,
211 sal_uInt8 nMemberId ) override;
213 const double& GetValue() const { return m_nValue; }
216 class SwInvertGrf final : public SfxBoolItem
218 public:
219 SwInvertGrf( bool bVal = false )
220 : SfxBoolItem( RES_GRFATR_INVERT, bVal, SfxItemType::SwInvertGrfType )
223 // pure virtual methods from SfxInt16Item
224 virtual SwInvertGrf* Clone( SfxItemPool *pPool = nullptr ) const override;
225 virtual bool GetPresentation( SfxItemPresentation ePres,
226 MapUnit eCoreMetric,
227 MapUnit ePresMetric,
228 OUString &rText,
229 const IntlWrapper& rIntl ) const override;
232 class SwTransparencyGrf final : public SfxByteItem
234 public:
235 SwTransparencyGrf( sal_Int8 nVal = 0 )
236 : SfxByteItem( RES_GRFATR_TRANSPARENCY, nVal, SfxItemType::SwTransparencyGrfType )
239 // pure virtual methods from SfxInt16Item
240 virtual SwTransparencyGrf* Clone( SfxItemPool *pPool = nullptr ) const override;
241 virtual bool GetPresentation( SfxItemPresentation ePres,
242 MapUnit eCoreMetric,
243 MapUnit ePresMetric,
244 OUString &rText,
245 const IntlWrapper& rIntl ) const override;
246 virtual bool QueryValue( css::uno::Any& rVal,
247 sal_uInt8 nMemberId = 0 ) const override;
248 virtual bool PutValue( const css::uno::Any& rVal,
249 sal_uInt8 nMemberId ) override;
252 // MSVC hack:
253 class SwDrawModeGrf_Base: public SfxEnumItem<GraphicDrawMode> {
254 protected:
255 SwDrawModeGrf_Base(GraphicDrawMode nMode):
256 SfxEnumItem(RES_GRFATR_DRAWMODE, SfxItemType::SwDrawModeGrf_BaseType, nMode) {}
259 class SW_DLLPUBLIC SwDrawModeGrf final : public SwDrawModeGrf_Base
261 public:
262 SwDrawModeGrf( GraphicDrawMode nMode = GraphicDrawMode::Standard )
263 : SwDrawModeGrf_Base( nMode )
266 // pure virtual methods of SfxPoolItem
267 virtual SwDrawModeGrf* Clone( SfxItemPool *pPool = nullptr ) const override;
269 // pure virtual methods of SfxEnumItem
270 virtual sal_uInt16 GetValueCount() const override;
271 virtual bool GetPresentation( SfxItemPresentation ePres,
272 MapUnit eCoreMetric,
273 MapUnit ePresMetric,
274 OUString &rText,
275 const IntlWrapper& rIntl ) const override;
277 virtual bool QueryValue( css::uno::Any& rVal,
278 sal_uInt8 nMemberId = 0 ) const override;
279 virtual bool PutValue( const css::uno::Any& rVal,
280 sal_uInt8 nMemberId ) override;
283 // Implementation of graphics attributes methods of SwAttr
284 inline const SwMirrorGrf &SwAttrSet::GetMirrorGrf(bool bInP) const
285 { return Get( RES_GRFATR_MIRRORGRF,bInP); }
286 inline const SwCropGrf &SwAttrSet::GetCropGrf(bool bInP) const
287 { return Get( RES_GRFATR_CROPGRF,bInP); }
288 inline const SwRotationGrf &SwAttrSet::GetRotationGrf(bool bInP) const
289 { return Get( RES_GRFATR_ROTATION,bInP); }
290 inline const SwLuminanceGrf &SwAttrSet::GetLuminanceGrf(bool bInP) const
291 { return Get( RES_GRFATR_LUMINANCE,bInP); }
292 inline const SwContrastGrf &SwAttrSet::GetContrastGrf(bool bInP) const
293 { return Get( RES_GRFATR_CONTRAST,bInP); }
294 inline const SwChannelRGrf &SwAttrSet::GetChannelRGrf(bool bInP) const
295 { return Get( RES_GRFATR_CHANNELR,bInP); }
296 inline const SwChannelGGrf &SwAttrSet::GetChannelGGrf(bool bInP) const
297 { return Get( RES_GRFATR_CHANNELG,bInP); }
298 inline const SwChannelBGrf &SwAttrSet::GetChannelBGrf(bool bInP) const
299 { return Get( RES_GRFATR_CHANNELB,bInP); }
300 inline const SwGammaGrf &SwAttrSet::GetGammaGrf(bool bInP) const
301 { return Get( RES_GRFATR_GAMMA,bInP); }
302 inline const SwInvertGrf &SwAttrSet::GetInvertGrf(bool bInP) const
303 { return Get( RES_GRFATR_INVERT,bInP); }
304 inline const SwTransparencyGrf &SwAttrSet::GetTransparencyGrf(bool bInP) const
305 { return Get( RES_GRFATR_TRANSPARENCY,bInP); }
306 inline const SwDrawModeGrf &SwAttrSet::GetDrawModeGrf(bool bInP) const
307 { return Get( RES_GRFATR_DRAWMODE,bInP); }
309 #endif // INCLUDED_SW_INC_GRFATR_HXX
311 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */