xref: /trunk/main/sw/inc/grfatr.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _GRFATR_HXX
28 #define _GRFATR_HXX
29 
30 #include <hintids.hxx>		// fuer die WhichIds @@@ must be included first @@@
31 #include <tools/gen.hxx>
32 #include <svl/eitem.hxx>
33 #include <svl/intitem.hxx>
34 #include <svx/grfcrop.hxx>
35 #include "swdllapi.h"
36 #include <swatrset.hxx>		// fuer inlines
37 #include <format.hxx>		// fuer inlines
38 
39 /******************************************************************************
40  *	class SwMirrorGrf
41  ******************************************************************************/
42 
43 enum MirrorGraph
44 {
45 RES_MIRROR_GRAPH_BEGIN,
46     RES_MIRROR_GRAPH_DONT = RES_MIRROR_GRAPH_BEGIN,
47     RES_MIRROR_GRAPH_VERT,
48     RES_MIRROR_GRAPH_HOR,
49     RES_MIRROR_GRAPH_BOTH,
50 RES_MIRROR_GRAPH_END
51 };
52 
53 class SW_DLLPUBLIC SwMirrorGrf : public SfxEnumItem
54 {
55 	sal_Bool bGrfToggle; // auf geraden Seiten Grafiken spiegeln
56 
57 public:
58     SwMirrorGrf( MirrorGraph eMiro = RES_MIRROR_GRAPH_DONT )
59         : SfxEnumItem( RES_GRFATR_MIRRORGRF, static_cast< sal_uInt16 >(eMiro) ), bGrfToggle( sal_False )
60 	{}
61 	SwMirrorGrf( const SwMirrorGrf &rMirrorGrf )
62 		: SfxEnumItem( RES_GRFATR_MIRRORGRF, rMirrorGrf.GetValue()),
63 		bGrfToggle( rMirrorGrf.IsGrfToggle() )
64 	{}
65 
66 	// pure virtual-Methoden von SfxPoolItem
67 	virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
68 
69 	// pure virtual-Methiden von SfxEnumItem
70 	virtual sal_uInt16			GetValueCount() const;
71 	virtual int				operator==( const SfxPoolItem& ) const;
72 	virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
73 									SfxMapUnit eCoreMetric,
74 									SfxMapUnit ePresMetric,
75 									String &rText,
76                                     const IntlWrapper*    pIntl = 0 ) const;
77 
78 	virtual	sal_Bool        	 QueryValue( com::sun::star::uno::Any& rVal,
79 										sal_uInt8 nMemberId = 0 ) const;
80 	virtual	sal_Bool			 PutValue( const com::sun::star::uno::Any& rVal,
81 										sal_uInt8 nMemberId = 0 );
82 
83 	inline SwMirrorGrf& operator=( const SwMirrorGrf& rMirrorGrf )
84 		{
85 			SfxEnumItem::SetValue( rMirrorGrf.GetValue() );
86 			bGrfToggle = rMirrorGrf.IsGrfToggle();
87 			return *this;
88 		}
89 
90 	inline sal_Bool IsGrfToggle() const			{ return bGrfToggle; }
91 	inline void SetGrfToggle( sal_Bool bNew )	{ bGrfToggle = bNew; }
92 };
93 
94 
95 /******************************************************************************
96  *	class SwAttrCropGrf
97  ******************************************************************************/
98 
99 class SW_DLLPUBLIC SwCropGrf : public SvxGrfCrop
100 {
101 public:
102 	TYPEINFO();
103 	SwCropGrf();
104 	SwCropGrf(  sal_Int32 nLeft,	sal_Int32 nRight,
105 				sal_Int32 nTop,		sal_Int32 nBottom );
106 
107 	// "pure virtual Methoden" vom SfxPoolItem
108 	virtual SfxPoolItem*		Clone( SfxItemPool *pPool = 0 ) const;
109 };
110 
111 class SwRotationGrf : public SfxUInt16Item
112 {
113 	Size aUnrotatedSize;
114 public:
115 	SwRotationGrf( sal_Int16 nVal = 0 )
116 		: SfxUInt16Item( RES_GRFATR_ROTATION, nVal )
117 	{}
118 	SwRotationGrf( sal_Int16 nVal, const Size& rSz )
119 		: SfxUInt16Item( RES_GRFATR_ROTATION, nVal ), aUnrotatedSize( rSz )
120 	{}
121 
122 	// pure virtual-Methiden from SfxInt16Item
123     virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
124 	virtual int				operator==( const SfxPoolItem& ) const;
125 	virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
126 									SfxMapUnit eCoreMetric,
127 									SfxMapUnit ePresMetric,
128 									String &rText,
129                                     const IntlWrapper* pIntl = 0 ) const;
130 	virtual	sal_Bool        	 QueryValue( com::sun::star::uno::Any& rVal,
131 											sal_uInt8 nMemberId = 0 ) const;
132 	virtual	sal_Bool			 PutValue( const com::sun::star::uno::Any& rVal,
133 											sal_uInt8 nMemberId = 0 );
134 
135 	void SetUnrotatedSize( const Size& rSz ) 		{ aUnrotatedSize = rSz; }
136 	const Size& GetUnrotatedSize() const 			{ return aUnrotatedSize; }
137 };
138 
139 class SW_DLLPUBLIC SwLuminanceGrf : public SfxInt16Item
140 {
141 public:
142 	SwLuminanceGrf( sal_Int16 nVal = 0 )
143 		: SfxInt16Item( RES_GRFATR_LUMINANCE, nVal )
144 	{}
145 
146 	// pure virtual-Methiden from SfxInt16Item
147     virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
148 	virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
149 									SfxMapUnit eCoreMetric,
150 									SfxMapUnit ePresMetric,
151 									String &rText,
152                                     const IntlWrapper* pIntl = 0 ) const;
153 };
154 
155 class SW_DLLPUBLIC SwContrastGrf : public SfxInt16Item
156 {
157 public:
158 	SwContrastGrf( sal_Int16 nVal = 0 )
159 		: SfxInt16Item( RES_GRFATR_CONTRAST, nVal )
160 	{}
161 
162 	// pure virtual-Methiden from SfxInt16Item
163     virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
164 	virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
165 									SfxMapUnit eCoreMetric,
166 									SfxMapUnit ePresMetric,
167 									String &rText,
168                                     const IntlWrapper* pIntl = 0 ) const;
169 };
170 
171 class SwChannelGrf : public SfxInt16Item
172 {
173 protected:
174     SwChannelGrf( sal_Int16 nVal, sal_uInt16 nWhichL )
175         : SfxInt16Item( nWhichL, nVal )
176 	{}
177 
178 public:
179 	// pure virtual-Methiden from SfxInt16Item
180 	virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
181 									SfxMapUnit eCoreMetric,
182 									SfxMapUnit ePresMetric,
183 									String &rText,
184                                     const IntlWrapper* pIntl = 0 ) const;
185 };
186 
187 class SwChannelRGrf : public SwChannelGrf
188 {
189 public:
190     SwChannelRGrf( sal_Int16 nVal = 0 )
191 		: SwChannelGrf( nVal, RES_GRFATR_CHANNELR )
192     {}
193     virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
194 };
195 class SwChannelGGrf : public SwChannelGrf
196 {
197 public:
198     SwChannelGGrf( sal_Int16 nVal = 0 )
199 		: SwChannelGrf( nVal, RES_GRFATR_CHANNELG )
200     {}
201     virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
202 };
203 class SwChannelBGrf : public SwChannelGrf
204 {
205 public:
206     SwChannelBGrf( sal_Int16 nVal = 0 )
207 		: SwChannelGrf( nVal, RES_GRFATR_CHANNELB )
208     {}
209     virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
210 };
211 
212 class SW_DLLPUBLIC SwGammaGrf : public SfxPoolItem
213 {
214 	double nValue;
215 public:
216 	TYPEINFO();
217 	SwGammaGrf() : SfxPoolItem( RES_GRFATR_GAMMA ), nValue( 1.0 )
218 	{}
219 
220 	SwGammaGrf( const double& rVal )
221 		: SfxPoolItem( RES_GRFATR_GAMMA ), nValue( rVal )
222 	{}
223 
224 	inline SwGammaGrf& operator=( const SwGammaGrf& rCopy )
225 		{
226 			SetValue( rCopy.GetValue() );
227 			return *this;
228 		}
229 
230 	// pure virtual-Methiden von SfxEnumItem
231     virtual SfxPoolItem* 	Clone( SfxItemPool *pPool = 0 ) const;
232 	virtual int				operator==( const SfxPoolItem& ) const;
233 	virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
234 									SfxMapUnit eCoreMetric,
235 									SfxMapUnit ePresMetric,
236 									String &rText,
237                                     const IntlWrapper* pIntl = 0 ) const;
238 
239 	virtual	sal_Bool        	 QueryValue( com::sun::star::uno::Any& rVal,
240 											sal_uInt8 nMemberId = 0 ) const;
241 	virtual	sal_Bool			 PutValue( const com::sun::star::uno::Any& rVal,
242 											sal_uInt8 nMemberId = 0 );
243 
244 
245 	const double& GetValue() const				{ return nValue; }
246 	void SetValue( const double& rVal )			{ nValue = rVal; }
247 };
248 
249 class SwInvertGrf: public SfxBoolItem
250 {
251 public:
252 	SwInvertGrf( sal_Bool bVal = sal_False )
253 		: SfxBoolItem( RES_GRFATR_INVERT, bVal )
254 	{}
255 
256 	// pure virtual-Methiden from SfxInt16Item
257     virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
258 	virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
259 									SfxMapUnit eCoreMetric,
260 									SfxMapUnit ePresMetric,
261 									String &rText,
262                                     const IntlWrapper* pIntl = 0 ) const;
263 };
264 
265 class SwTransparencyGrf : public SfxByteItem
266 {
267 public:
268 	SwTransparencyGrf( sal_Int8 nVal = 0 )
269 		: SfxByteItem( RES_GRFATR_TRANSPARENCY, nVal )
270 	{}
271 
272 	// pure virtual-Methiden from SfxInt16Item
273     virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
274 	virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
275 									SfxMapUnit eCoreMetric,
276 									SfxMapUnit ePresMetric,
277 									String &rText,
278                                     const IntlWrapper* pIntl = 0 ) const;
279 	virtual	sal_Bool        	QueryValue( com::sun::star::uno::Any& rVal,
280 										sal_uInt8 nMemberId = 0 ) const;
281 	virtual	sal_Bool			PutValue( const com::sun::star::uno::Any& rVal,
282 										sal_uInt8 nMemberId = 0 );
283 };
284 
285 class SW_DLLPUBLIC SwDrawModeGrf : public SfxEnumItem
286 {
287 public:
288 	SwDrawModeGrf( sal_uInt16 nMode = 0 )
289 		: SfxEnumItem( RES_GRFATR_DRAWMODE, nMode )
290 	{}
291 
292 	// pure virtual-Methoden von SfxPoolItem
293 	virtual SfxPoolItem*	Clone( SfxItemPool *pPool = 0 ) const;
294 
295 	// pure virtual-Methiden von SfxEnumItem
296 	virtual sal_uInt16			GetValueCount() const;
297 	virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
298 									SfxMapUnit eCoreMetric,
299 									SfxMapUnit ePresMetric,
300 									String &rText,
301                                     const IntlWrapper*    pIntl = 0 ) const;
302 
303 	virtual	sal_Bool        	QueryValue( com::sun::star::uno::Any& rVal,
304 										sal_uInt8 nMemberId = 0 ) const;
305 	virtual	sal_Bool			PutValue( const com::sun::star::uno::Any& rVal,
306 										sal_uInt8 nMemberId = 0 );
307 };
308 
309 
310 
311 /******************************************************************************
312  *	Implementierung der GrafikAttribut Methoden vom SwAttrSet
313  ******************************************************************************/
314 
315 inline const SwMirrorGrf &SwAttrSet::GetMirrorGrf(sal_Bool bInP) const
316 	{ return (const SwMirrorGrf&)Get( RES_GRFATR_MIRRORGRF,bInP); }
317 inline const SwCropGrf   &SwAttrSet::GetCropGrf(sal_Bool bInP) const
318 	{ return (const SwCropGrf&)Get( RES_GRFATR_CROPGRF,bInP); }
319 inline const SwRotationGrf &SwAttrSet::GetRotationGrf(sal_Bool bInP) const
320 	{ return (const SwRotationGrf&)Get( RES_GRFATR_ROTATION,bInP); }
321 inline const SwLuminanceGrf &SwAttrSet::GetLuminanceGrf(sal_Bool bInP) const
322 	{ return (const SwLuminanceGrf&)Get( RES_GRFATR_LUMINANCE,bInP); }
323 inline const SwContrastGrf &SwAttrSet::GetContrastGrf(sal_Bool bInP) const
324 	{ return (const SwContrastGrf&)Get( RES_GRFATR_CONTRAST,bInP); }
325 inline const SwChannelRGrf &SwAttrSet::GetChannelRGrf(sal_Bool bInP) const
326 	{ return (const SwChannelRGrf&)Get( RES_GRFATR_CHANNELR,bInP); }
327 inline const SwChannelGGrf &SwAttrSet::GetChannelGGrf(sal_Bool bInP) const
328 	{ return (const SwChannelGGrf&)Get( RES_GRFATR_CHANNELG,bInP); }
329 inline const SwChannelBGrf &SwAttrSet::GetChannelBGrf(sal_Bool bInP) const
330 	{ return (const SwChannelBGrf&)Get( RES_GRFATR_CHANNELB,bInP); }
331 inline const SwGammaGrf &SwAttrSet::GetGammaGrf(sal_Bool bInP) const
332 	{ return (const SwGammaGrf&)Get( RES_GRFATR_GAMMA,bInP); }
333 inline const SwInvertGrf &SwAttrSet::GetInvertGrf(sal_Bool bInP) const
334 	{ return (const SwInvertGrf&)Get( RES_GRFATR_INVERT,bInP); }
335 inline const SwTransparencyGrf &SwAttrSet::GetTransparencyGrf(sal_Bool bInP) const
336 	{ return (const SwTransparencyGrf&)Get( RES_GRFATR_TRANSPARENCY,bInP); }
337 inline const SwDrawModeGrf		&SwAttrSet::GetDrawModeGrf(sal_Bool bInP) const
338 	{ return (const SwDrawModeGrf&)Get( RES_GRFATR_DRAWMODE,bInP); }
339 
340 /******************************************************************************
341  *	Implementierung der GrafikAttribut Methoden vom SwFmt
342  ******************************************************************************/
343 
344 inline const SwMirrorGrf &SwFmt::GetMirrorGrf(sal_Bool bInP) const
345 	{ return aSet.GetMirrorGrf(bInP); }
346 inline const SwCropGrf   &SwFmt::GetCropGrf(sal_Bool bInP) const
347 	{ return aSet.GetCropGrf(bInP); }
348 inline const SwRotationGrf &SwFmt::GetRotationGrf(sal_Bool bInP) const
349 	{ return aSet.GetRotationGrf(bInP); }
350 inline const SwLuminanceGrf &SwFmt::GetLuminanceGrf(sal_Bool bInP) const
351 	{ return aSet.GetLuminanceGrf( bInP); }
352 inline const SwContrastGrf &SwFmt::GetContrastGrf(sal_Bool bInP) const
353 	{ return aSet.GetContrastGrf( bInP); }
354 inline const SwChannelRGrf &SwFmt::GetChannelRGrf(sal_Bool bInP) const
355 	{ return aSet.GetChannelRGrf( bInP); }
356 inline const SwChannelGGrf &SwFmt::GetChannelGGrf(sal_Bool bInP) const
357 	{ return aSet.GetChannelGGrf( bInP); }
358 inline const SwChannelBGrf &SwFmt::GetChannelBGrf(sal_Bool bInP) const
359 	{ return aSet.GetChannelBGrf( bInP); }
360 inline const SwGammaGrf	&SwFmt::GetGammaGrf(sal_Bool bInP) const
361 	{ return aSet.GetGammaGrf( bInP); }
362 inline const SwInvertGrf &SwFmt::GetInvertGrf(sal_Bool bInP) const
363 	{ return aSet.GetInvertGrf( bInP); }
364 inline const SwTransparencyGrf &SwFmt::GetTransparencyGrf(sal_Bool bInP) const
365 	{ return aSet.GetTransparencyGrf( bInP); }
366 inline const SwDrawModeGrf &SwFmt::GetDrawModeGrf(sal_Bool bInP) const
367 	{ return aSet.GetDrawModeGrf(bInP); }
368 
369 
370 #endif  // _GRFATR_HXX
371