1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
29 #include "swatrset.hxx"
31 enum class MirrorGraph
39 class SW_DLLPUBLIC SwMirrorGrf
: public SfxEnumItem
<MirrorGraph
>
41 bool m_bGrfToggle
; // Flip graphics on even pages.
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
,
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
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
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
);
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
,
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
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
,
124 const IntlWrapper
& rIntl
) const override
;
127 class SW_DLLPUBLIC SwContrastGrf
: public SfxInt16Item
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
,
140 const IntlWrapper
& rIntl
) const override
;
143 class SwChannelGrf
: public SfxInt16Item
146 SwChannelGrf( sal_Int16 nVal
, sal_uInt16 nWhichL
)
147 : SfxInt16Item( nWhichL
, nVal
)
151 // pure virtual methods from SfxInt16Item
152 virtual bool GetPresentation( SfxItemPresentation ePres
,
156 const IntlWrapper
& rIntl
) const override
;
159 class SwChannelRGrf
: public SwChannelGrf
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
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
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
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
,
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
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
,
225 const IntlWrapper
& rIntl
) const override
;
228 class SwTransparencyGrf
: public SfxByteItem
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
,
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
;
249 class SwDrawModeGrf_Base
: public SfxEnumItem
<GraphicDrawMode
> {
251 SwDrawModeGrf_Base(GraphicDrawMode nMode
):
252 SfxEnumItem(RES_GRFATR_DRAWMODE
, nMode
) {}
255 class SW_DLLPUBLIC SwDrawModeGrf
: public SwDrawModeGrf_Base
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
,
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: */