/src/libreoffice/sw/inc/grfatr.hxx
Line | Count | Source |
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/GraphicAttributes.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 final : public SfxEnumItem<MirrorGraph> |
40 | | { |
41 | | bool m_bGrfToggle; // Flip graphics on even pages. |
42 | | |
43 | | public: |
44 | | DECLARE_ITEM_TYPE_FUNCTION(SwMirrorGrf) |
45 | | SwMirrorGrf( MirrorGraph eMiro = MirrorGraph::Dont ) |
46 | 9 | : SfxEnumItem( RES_GRFATR_MIRRORGRF, eMiro ), m_bGrfToggle( false ) |
47 | 9 | {} |
48 | | |
49 | | // pure virtual methods of SfxPoolItem |
50 | | virtual SwMirrorGrf* Clone( SfxItemPool *pPool = nullptr ) const override; |
51 | | |
52 | | // pure virtual methods of SfxEnumItem |
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 | 501 | bool IsGrfToggle() const { return m_bGrfToggle; } |
66 | 46 | void SetGrfToggle( bool bNew ) { m_bGrfToggle = bNew; } |
67 | | }; |
68 | | |
69 | | class SW_DLLPUBLIC SwCropGrf final : public SvxGrfCrop |
70 | | { |
71 | | public: |
72 | | DECLARE_ITEM_TYPE_FUNCTION(SwCropGrf) |
73 | | SwCropGrf(); |
74 | | SwCropGrf( sal_Int32 nLeft, sal_Int32 nRight, |
75 | | sal_Int32 nTop, sal_Int32 nBottom ); |
76 | | |
77 | | // "pure virtual methods" of SfxPoolItem |
78 | | virtual SwCropGrf* Clone( SfxItemPool *pPool = nullptr ) const override; |
79 | | }; |
80 | | |
81 | | class SAL_DLLPUBLIC_RTTI SwRotationGrf final : public SfxUInt16Item |
82 | | { |
83 | | private: |
84 | | Size m_aUnrotatedSize; |
85 | | |
86 | | // tdf#115529 check and evtl. correct value, it is in 10th |
87 | | // degrees and *has* to be in the range [0 .. 3600[ |
88 | | static Degree10 checkAndCorrectValue(Degree10 nValue); |
89 | | |
90 | | public: |
91 | | DECLARE_ITEM_TYPE_FUNCTION(SwRotationGrf) |
92 | | SwRotationGrf() |
93 | 9 | : SfxUInt16Item( RES_GRFATR_ROTATION, 0 ) |
94 | 9 | {} |
95 | | SwRotationGrf( Degree10 nVal, const Size& rSz ); |
96 | | |
97 | | // pure virtual methods from SfxInt16Item |
98 | | virtual SwRotationGrf* Clone( SfxItemPool *pPool = nullptr ) const override; |
99 | | virtual bool operator==( const SfxPoolItem& ) const override; |
100 | | virtual bool GetPresentation( SfxItemPresentation ePres, |
101 | | MapUnit eCoreMetric, |
102 | | MapUnit ePresMetric, |
103 | | OUString &rText, |
104 | | const IntlWrapper& rIntl ) const override; |
105 | | virtual bool QueryValue( css::uno::Any& rVal, |
106 | | sal_uInt8 nMemberId = 0 ) const override; |
107 | | virtual bool PutValue( const css::uno::Any& rVal, |
108 | | sal_uInt8 nMemberId ) override; |
109 | | |
110 | 90.3k | const Size& GetUnrotatedSize() const { return m_aUnrotatedSize; } |
111 | 1.74k | Degree10 GetValue() const { return Degree10(SfxUInt16Item::GetValue()); } |
112 | 46.0k | void SetValue(Degree10 d) { SfxUInt16Item::SetValue(d.get()); } |
113 | | }; |
114 | | |
115 | | class SW_DLLPUBLIC SwLuminanceGrf final : public SfxInt16Item |
116 | | { |
117 | | public: |
118 | | DECLARE_ITEM_TYPE_FUNCTION(SwLuminanceGrf) |
119 | | SwLuminanceGrf( sal_Int16 nVal = 0 ) |
120 | 9 | : SfxInt16Item( RES_GRFATR_LUMINANCE, nVal ) |
121 | 9 | {} |
122 | | |
123 | | // pure virtual methods from SfxInt16Item |
124 | | virtual SwLuminanceGrf* Clone( SfxItemPool *pPool = nullptr ) const override; |
125 | | virtual bool GetPresentation( SfxItemPresentation ePres, |
126 | | MapUnit eCoreMetric, |
127 | | MapUnit ePresMetric, |
128 | | OUString &rText, |
129 | | const IntlWrapper& rIntl ) const override; |
130 | | }; |
131 | | |
132 | | class SW_DLLPUBLIC SwContrastGrf final : public SfxInt16Item |
133 | | { |
134 | | public: |
135 | | DECLARE_ITEM_TYPE_FUNCTION(SwContrastGrf) |
136 | | SwContrastGrf( sal_Int16 nVal = 0 ) |
137 | 9 | : SfxInt16Item( RES_GRFATR_CONTRAST, nVal ) |
138 | 9 | {} |
139 | | |
140 | | // pure virtual methods from SfxInt16Item |
141 | | virtual SwContrastGrf* Clone( SfxItemPool *pPool = nullptr ) const override; |
142 | | virtual bool GetPresentation( SfxItemPresentation ePres, |
143 | | MapUnit eCoreMetric, |
144 | | MapUnit ePresMetric, |
145 | | OUString &rText, |
146 | | const IntlWrapper& rIntl ) const override; |
147 | | }; |
148 | | |
149 | | class SwChannelGrf : public SfxInt16Item |
150 | | { |
151 | | protected: |
152 | | SwChannelGrf( sal_Int16 nVal, sal_uInt16 nWhichL ) |
153 | 27 | : SfxInt16Item( nWhichL, nVal ) |
154 | 27 | {} |
155 | | |
156 | | virtual SfxItemType ItemType() const override = 0; |
157 | | |
158 | | public: |
159 | | // pure virtual methods from SfxInt16Item |
160 | | virtual bool GetPresentation( SfxItemPresentation ePres, |
161 | | MapUnit eCoreMetric, |
162 | | MapUnit ePresMetric, |
163 | | OUString &rText, |
164 | | const IntlWrapper& rIntl ) const override; |
165 | | }; |
166 | | |
167 | | class SwChannelRGrf final : public SwChannelGrf |
168 | | { |
169 | | public: |
170 | | DECLARE_ITEM_TYPE_FUNCTION(SwChannelRGrf) |
171 | | SwChannelRGrf( sal_Int16 nVal = 0 ) |
172 | 9 | : SwChannelGrf( nVal, RES_GRFATR_CHANNELR ) |
173 | 9 | {} |
174 | | virtual SwChannelRGrf* Clone( SfxItemPool *pPool = nullptr ) const override; |
175 | | }; |
176 | | class SwChannelGGrf final : public SwChannelGrf |
177 | | { |
178 | | public: |
179 | | DECLARE_ITEM_TYPE_FUNCTION(SwChannelGGrf) |
180 | | SwChannelGGrf( sal_Int16 nVal = 0 ) |
181 | 9 | : SwChannelGrf( nVal, RES_GRFATR_CHANNELG ) |
182 | 9 | {} |
183 | | virtual SwChannelGGrf* Clone( SfxItemPool *pPool = nullptr ) const override; |
184 | | }; |
185 | | class SwChannelBGrf final : public SwChannelGrf |
186 | | { |
187 | | public: |
188 | | DECLARE_ITEM_TYPE_FUNCTION(SwChannelBGrf) |
189 | | SwChannelBGrf( sal_Int16 nVal = 0 ) |
190 | 9 | : SwChannelGrf( nVal, RES_GRFATR_CHANNELB ) |
191 | 9 | {} |
192 | | virtual SwChannelBGrf* Clone( SfxItemPool *pPool = nullptr ) const override; |
193 | | }; |
194 | | |
195 | | class SW_DLLPUBLIC SwGammaGrf final : public SfxPoolItem |
196 | | { |
197 | | double m_nValue; |
198 | | public: |
199 | | DECLARE_ITEM_TYPE_FUNCTION(SwGammaGrf) |
200 | 9 | SwGammaGrf() : SfxPoolItem( RES_GRFATR_GAMMA ), m_nValue( 1.0 ) |
201 | 9 | {} |
202 | | |
203 | | SwGammaGrf( const double& rVal ) |
204 | 41 | : SfxPoolItem( RES_GRFATR_GAMMA ), m_nValue( rVal ) |
205 | 41 | {} |
206 | | |
207 | | // pure virtual methods from SfxEnumItem |
208 | | virtual SwGammaGrf* Clone( SfxItemPool *pPool = nullptr ) const override; |
209 | | virtual bool operator==( const SfxPoolItem& ) const override; |
210 | 0 | virtual bool supportsHashCode() const override { return true; } |
211 | 0 | virtual size_t hashCode() const override { return static_cast<size_t>(m_nValue); } |
212 | | virtual bool GetPresentation( SfxItemPresentation ePres, |
213 | | MapUnit eCoreMetric, |
214 | | MapUnit ePresMetric, |
215 | | OUString &rText, |
216 | | const IntlWrapper& rIntl ) const override; |
217 | | |
218 | | virtual bool QueryValue( css::uno::Any& rVal, |
219 | | sal_uInt8 nMemberId = 0 ) const override; |
220 | | virtual bool PutValue( const css::uno::Any& rVal, |
221 | | sal_uInt8 nMemberId ) override; |
222 | | |
223 | 442 | const double& GetValue() const { return m_nValue; } |
224 | | }; |
225 | | |
226 | | class SwInvertGrf final : public SfxBoolItem |
227 | | { |
228 | | public: |
229 | | DECLARE_ITEM_TYPE_FUNCTION(SwInvertGrf) |
230 | | SwInvertGrf( bool bVal = false ) |
231 | 9 | : SfxBoolItem( RES_GRFATR_INVERT, bVal ) |
232 | 9 | {} |
233 | | |
234 | | // pure virtual methods from SfxInt16Item |
235 | | virtual SwInvertGrf* Clone( SfxItemPool *pPool = nullptr ) const override; |
236 | | virtual bool GetPresentation( SfxItemPresentation ePres, |
237 | | MapUnit eCoreMetric, |
238 | | MapUnit ePresMetric, |
239 | | OUString &rText, |
240 | | const IntlWrapper& rIntl ) const override; |
241 | | }; |
242 | | |
243 | | class SwTransparencyGrf final : public SfxByteItem |
244 | | { |
245 | | public: |
246 | | DECLARE_ITEM_TYPE_FUNCTION(SwTransparencyGrf) |
247 | | SwTransparencyGrf( sal_Int8 nVal = 0 ) |
248 | 9 | : SfxByteItem( RES_GRFATR_TRANSPARENCY, nVal ) |
249 | 9 | {} |
250 | | |
251 | | // pure virtual methods from SfxInt16Item |
252 | | virtual SwTransparencyGrf* Clone( SfxItemPool *pPool = nullptr ) const override; |
253 | | virtual bool GetPresentation( SfxItemPresentation ePres, |
254 | | MapUnit eCoreMetric, |
255 | | MapUnit ePresMetric, |
256 | | OUString &rText, |
257 | | const IntlWrapper& rIntl ) const override; |
258 | | virtual bool QueryValue( css::uno::Any& rVal, |
259 | | sal_uInt8 nMemberId = 0 ) const override; |
260 | | virtual bool PutValue( const css::uno::Any& rVal, |
261 | | sal_uInt8 nMemberId ) override; |
262 | | }; |
263 | | |
264 | | class SW_DLLPUBLIC SwDrawModeGrf final : public SfxEnumItem<GraphicDrawMode> |
265 | | { |
266 | | public: |
267 | | DECLARE_ITEM_TYPE_FUNCTION(SwDrawModeGrf) |
268 | | SwDrawModeGrf( GraphicDrawMode nMode = GraphicDrawMode::Standard ) |
269 | 9 | : SfxEnumItem(RES_GRFATR_DRAWMODE, nMode) |
270 | 9 | {} |
271 | | |
272 | | // pure virtual methods of SfxPoolItem |
273 | | virtual SwDrawModeGrf* Clone( SfxItemPool *pPool = nullptr ) const override; |
274 | | |
275 | | // pure virtual methods of SfxEnumItem |
276 | | virtual bool GetPresentation( SfxItemPresentation ePres, |
277 | | MapUnit eCoreMetric, |
278 | | MapUnit ePresMetric, |
279 | | OUString &rText, |
280 | | const IntlWrapper& rIntl ) const override; |
281 | | |
282 | | virtual bool QueryValue( css::uno::Any& rVal, |
283 | | sal_uInt8 nMemberId = 0 ) const override; |
284 | | virtual bool PutValue( const css::uno::Any& rVal, |
285 | | sal_uInt8 nMemberId ) override; |
286 | | }; |
287 | | |
288 | | // Implementation of graphics attributes methods of SwAttr |
289 | | inline const SwMirrorGrf &SwAttrSet::GetMirrorGrf(bool bInP) const |
290 | 444 | { return Get( RES_GRFATR_MIRRORGRF,bInP); } |
291 | | inline const SwCropGrf &SwAttrSet::GetCropGrf(bool bInP) const |
292 | 430 | { return Get( RES_GRFATR_CROPGRF,bInP); } |
293 | | inline const SwRotationGrf &SwAttrSet::GetRotationGrf(bool bInP) const |
294 | 1.74k | { return Get( RES_GRFATR_ROTATION,bInP); } |
295 | | inline const SwLuminanceGrf &SwAttrSet::GetLuminanceGrf(bool bInP) const |
296 | 430 | { return Get( RES_GRFATR_LUMINANCE,bInP); } |
297 | | inline const SwContrastGrf &SwAttrSet::GetContrastGrf(bool bInP) const |
298 | 430 | { return Get( RES_GRFATR_CONTRAST,bInP); } |
299 | | inline const SwChannelRGrf &SwAttrSet::GetChannelRGrf(bool bInP) const |
300 | 430 | { return Get( RES_GRFATR_CHANNELR,bInP); } |
301 | | inline const SwChannelGGrf &SwAttrSet::GetChannelGGrf(bool bInP) const |
302 | 430 | { return Get( RES_GRFATR_CHANNELG,bInP); } |
303 | | inline const SwChannelBGrf &SwAttrSet::GetChannelBGrf(bool bInP) const |
304 | 430 | { return Get( RES_GRFATR_CHANNELB,bInP); } |
305 | | inline const SwGammaGrf &SwAttrSet::GetGammaGrf(bool bInP) const |
306 | 430 | { return Get( RES_GRFATR_GAMMA,bInP); } |
307 | | inline const SwInvertGrf &SwAttrSet::GetInvertGrf(bool bInP) const |
308 | 430 | { return Get( RES_GRFATR_INVERT,bInP); } |
309 | | inline const SwTransparencyGrf &SwAttrSet::GetTransparencyGrf(bool bInP) const |
310 | 442 | { return Get( RES_GRFATR_TRANSPARENCY,bInP); } |
311 | | inline const SwDrawModeGrf &SwAttrSet::GetDrawModeGrf(bool bInP) const |
312 | 430 | { return Get( RES_GRFATR_DRAWMODE,bInP); } |
313 | | |
314 | | #endif // INCLUDED_SW_INC_GRFATR_HXX |
315 | | |
316 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |