xref: /aoo41x/main/svx/source/items/drawitem.cxx (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 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_svx.hxx"
30 
31 // include ---------------------------------------------------------------
32 
33 #include <svx/svxids.hrc>
34 
35 
36 #include "svx/drawitem.hxx"
37 #include <svx/xtable.hxx>
38 
39 using namespace ::com::sun::star;
40 
41 // -----------------------------------------------------------------------
42 
43 TYPEINIT1_FACTORY( SvxColorTableItem, SfxPoolItem , new  SvxColorTableItem);
44 TYPEINIT1_FACTORY( SvxGradientListItem, SfxPoolItem , new  SvxGradientListItem);
45 TYPEINIT1_FACTORY( SvxHatchListItem, SfxPoolItem , new  SvxHatchListItem);
46 TYPEINIT1_FACTORY( SvxBitmapListItem, SfxPoolItem , new  SvxBitmapListItem);
47 TYPEINIT1_FACTORY( SvxDashListItem, SfxPoolItem , new  SvxDashListItem);
48 TYPEINIT1_FACTORY( SvxLineEndListItem, SfxPoolItem , new  SvxLineEndListItem);
49 
50 //==================================================================
51 //
52 //	SvxColorTableItem
53 //
54 //==================================================================
55 
56 SvxColorTableItem::SvxColorTableItem()
57 {
58 }
59 
60 // -----------------------------------------------------------------------
61 
62 SvxColorTableItem::SvxColorTableItem( XColorTable* pTable, sal_uInt16 nW ) :
63 	SfxPoolItem( nW ),
64 	pColorTable( pTable )
65 {
66 }
67 
68 // -----------------------------------------------------------------------
69 
70 SvxColorTableItem::SvxColorTableItem( const SvxColorTableItem& rItem ) :
71 	SfxPoolItem( rItem ),
72 	pColorTable( rItem.pColorTable )
73 {
74 }
75 
76 //------------------------------------------------------------------------
77 
78 SfxItemPresentation SvxColorTableItem::GetPresentation
79 (
80     SfxItemPresentation /*ePres*/,
81     SfxMapUnit          /*eCoreUnit*/,
82     SfxMapUnit          /*ePresUnit*/,
83     XubString&          rText, const IntlWrapper *
84 )	const
85 {
86 	rText.Erase();
87 	return SFX_ITEM_PRESENTATION_NONE;
88 }
89 
90 // -----------------------------------------------------------------------
91 
92 int SvxColorTableItem::operator==( const SfxPoolItem& rItem ) const
93 {
94 	DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
95 	return ( ( SvxColorTableItem& ) rItem).pColorTable == pColorTable;
96 }
97 
98 // -----------------------------------------------------------------------
99 
100 SfxPoolItem* SvxColorTableItem::Clone( SfxItemPool * ) const
101 {
102 	return new SvxColorTableItem( *this );
103 }
104 
105 // -----------------------------------------------------------------------
106 
107 sal_Bool SvxColorTableItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
108 {
109     // This is only a quick helper to have UI support for these list items. Don't use
110     // this method to query for a valid UNO representation.
111     // Please ask CD if you want to change this.
112     sal_Int64 aValue = sal_Int64( (sal_uLong)pColorTable );
113     rVal = uno::makeAny( aValue );
114     return sal_True;
115 }
116 
117 // -----------------------------------------------------------------------
118 
119 sal_Bool SvxColorTableItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
120 {
121     // This is only a quick helper to have UI support for these list items. Don't use
122     // this method to query for a valid UNO representation.
123     // Please ask CD if you want to change this.
124     sal_Int64 aValue = 0;
125     if ( rVal >>= aValue )
126     {
127         pColorTable = (XColorTable *)(sal_uLong)aValue;
128         return sal_True;
129     }
130 
131     return sal_False;
132 }
133 
134 //==================================================================
135 //
136 //	SvxGradientListItem
137 //
138 //==================================================================
139 
140 SvxGradientListItem::SvxGradientListItem()
141 {
142 }
143 
144 // -----------------------------------------------------------------------
145 
146 SvxGradientListItem::SvxGradientListItem( XGradientList* pList, sal_uInt16 nW ) :
147 	SfxPoolItem( nW ),
148 	pGradientList( pList )
149 {
150 }
151 
152 // -----------------------------------------------------------------------
153 
154 SvxGradientListItem::SvxGradientListItem( const SvxGradientListItem& rItem ) :
155 	SfxPoolItem( rItem ),
156 	pGradientList( rItem.pGradientList )
157 {
158 }
159 
160 //------------------------------------------------------------------------
161 
162 SfxItemPresentation SvxGradientListItem::GetPresentation
163 (
164     SfxItemPresentation /*ePres*/,
165     SfxMapUnit          /*eCoreUnit*/,
166     SfxMapUnit          /*ePresUnit*/,
167     XubString&          rText, const IntlWrapper *
168 )	const
169 {
170 	rText.Erase();
171 	return SFX_ITEM_PRESENTATION_NONE;
172 }
173 
174 // -----------------------------------------------------------------------
175 
176 int SvxGradientListItem::operator==( const SfxPoolItem& rItem ) const
177 {
178 	DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
179 	return ( ( SvxGradientListItem& ) rItem).pGradientList == pGradientList;
180 }
181 
182 // -----------------------------------------------------------------------
183 
184 SfxPoolItem* SvxGradientListItem::Clone( SfxItemPool * ) const
185 {
186 	return new SvxGradientListItem( *this );
187 }
188 
189 // -----------------------------------------------------------------------
190 
191 sal_Bool SvxGradientListItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
192 {
193     // This is only a quick helper to have UI support for these list items. Don't use
194     // this method to query for a valid UNO representation.
195     // Please ask CD if you want to change this.
196     sal_Int64 aValue = sal_Int64( (sal_uLong)pGradientList );
197     rVal = uno::makeAny( aValue );
198     return sal_True;
199 }
200 
201 // -----------------------------------------------------------------------
202 
203 sal_Bool SvxGradientListItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
204 {
205     // This is only a quick helper to have UI support for these list items. Don't use
206     // this method to query for a valid UNO representation.
207     // Please ask CD if you want to change this.
208     sal_Int64 aValue = 0;
209     if ( rVal >>= aValue )
210     {
211         pGradientList = (XGradientList *)(sal_uLong)aValue;
212         return sal_True;
213     }
214 
215     return sal_False;
216 }
217 
218 //==================================================================
219 //
220 //	SvxHatchListItem
221 //
222 //==================================================================
223 
224 SvxHatchListItem::SvxHatchListItem()
225 {
226 }
227 
228 // -----------------------------------------------------------------------
229 
230 SvxHatchListItem::SvxHatchListItem( XHatchList* pList, sal_uInt16 nW ) :
231 	SfxPoolItem( nW ),
232 	pHatchList( pList )
233 {
234 }
235 
236 // -----------------------------------------------------------------------
237 
238 SvxHatchListItem::SvxHatchListItem( const SvxHatchListItem& rItem ) :
239 	SfxPoolItem( rItem ),
240 	pHatchList( rItem.pHatchList )
241 {
242 }
243 
244 //------------------------------------------------------------------------
245 
246 SfxItemPresentation SvxHatchListItem::GetPresentation
247 (
248     SfxItemPresentation /*ePres*/,
249     SfxMapUnit          /*eCoreUnit*/,
250     SfxMapUnit          /*ePresUnit*/,
251     XubString&          rText, const IntlWrapper *
252 )	const
253 {
254 	rText.Erase();
255 	return SFX_ITEM_PRESENTATION_NONE;
256 }
257 
258 // -----------------------------------------------------------------------
259 
260 int SvxHatchListItem::operator==( const SfxPoolItem& rItem ) const
261 {
262 	DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
263 	return ( ( SvxHatchListItem& ) rItem).pHatchList == pHatchList;
264 }
265 
266 // -----------------------------------------------------------------------
267 
268 SfxPoolItem* SvxHatchListItem::Clone( SfxItemPool * ) const
269 {
270 	return new SvxHatchListItem( *this );
271 }
272 
273 // -----------------------------------------------------------------------
274 
275 sal_Bool SvxHatchListItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
276 {
277     // This is only a quick helper to have UI support for these list items. Don't use
278     // this method to query for a valid UNO representation.
279     // Please ask CD if you want to change this.
280     sal_Int64 aValue = sal_Int64( (sal_uLong)pHatchList );
281     rVal = uno::makeAny( aValue );
282     return sal_True;
283 }
284 
285 // -----------------------------------------------------------------------
286 
287 sal_Bool SvxHatchListItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
288 {
289     // This is only a quick helper to have UI support for these list items. Don't use
290     // this method to query for a valid UNO representation.
291     // Please ask CD if you want to change this.
292     sal_Int64 aValue = 0;
293     if ( rVal >>= aValue )
294     {
295         pHatchList = (XHatchList *)(sal_uLong)aValue;
296         return sal_True;
297     }
298 
299     return sal_False;
300 }
301 
302 //==================================================================
303 //
304 //	SvxBitmapListItem
305 //
306 //==================================================================
307 
308 SvxBitmapListItem::SvxBitmapListItem()
309 {
310 }
311 
312 // -----------------------------------------------------------------------
313 
314 SvxBitmapListItem::SvxBitmapListItem( XBitmapList* pList, sal_uInt16 nW ) :
315 	SfxPoolItem( nW ),
316 	pBitmapList( pList )
317 {
318 }
319 
320 // -----------------------------------------------------------------------
321 
322 SvxBitmapListItem::SvxBitmapListItem( const SvxBitmapListItem& rItem ) :
323 	SfxPoolItem( rItem ),
324 	pBitmapList( rItem.pBitmapList )
325 {
326 }
327 
328 //------------------------------------------------------------------------
329 
330 SfxItemPresentation SvxBitmapListItem::GetPresentation
331 (
332     SfxItemPresentation /*ePres*/,
333     SfxMapUnit          /*eCoreUnit*/,
334     SfxMapUnit          /*ePresUnit*/,
335     XubString&          rText, const IntlWrapper *
336 )	const
337 {
338 	rText.Erase();
339 	return SFX_ITEM_PRESENTATION_NONE;
340 }
341 
342 // -----------------------------------------------------------------------
343 
344 int SvxBitmapListItem::operator==( const SfxPoolItem& rItem ) const
345 {
346 	DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
347 	return ( ( SvxBitmapListItem& ) rItem).pBitmapList == pBitmapList;
348 }
349 
350 // -----------------------------------------------------------------------
351 
352 SfxPoolItem* SvxBitmapListItem::Clone( SfxItemPool * ) const
353 {
354 	return new SvxBitmapListItem( *this );
355 }
356 
357 // -----------------------------------------------------------------------
358 
359 sal_Bool SvxBitmapListItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
360 {
361     // This is only a quick helper to have UI support for these list items. Don't use
362     // this method to query for a valid UNO representation.
363     // Please ask CD if you want to change this.
364     sal_Int64 aValue = sal_Int64( (sal_uLong)pBitmapList );
365     rVal = uno::makeAny( aValue );
366     return sal_True;
367 }
368 
369 // -----------------------------------------------------------------------
370 
371 sal_Bool SvxBitmapListItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
372 {
373     // This is only a quick helper to have UI support for these list items. Don't use
374     // this method to query for a valid UNO representation.
375     // Please ask CD if you want to change this.
376     sal_Int64 aValue = 0;
377     if ( rVal >>= aValue )
378     {
379         pBitmapList = (XBitmapList *)(sal_uLong)aValue;
380         return sal_True;
381     }
382 
383     return sal_False;
384 }
385 
386 
387 //==================================================================
388 //
389 //	SvxDashListItem
390 //
391 //==================================================================
392 
393 SvxDashListItem::SvxDashListItem() :
394     pDashList( 0 )
395 {
396 }
397 
398 // -----------------------------------------------------------------------
399 
400 SvxDashListItem::SvxDashListItem( XDashList* pList, sal_uInt16 nW ) :
401 	SfxPoolItem( nW ),
402 	pDashList( pList )
403 {
404 }
405 
406 // -----------------------------------------------------------------------
407 
408 SvxDashListItem::SvxDashListItem( const SvxDashListItem& rItem ) :
409 	SfxPoolItem( rItem ),
410 	pDashList( rItem.pDashList )
411 {
412 }
413 
414 //------------------------------------------------------------------------
415 
416 SfxItemPresentation SvxDashListItem::GetPresentation
417 (
418     SfxItemPresentation /*ePres*/,
419     SfxMapUnit          /*eCoreUnit*/,
420     SfxMapUnit          /*ePresUnit*/,
421     XubString&          rText, const IntlWrapper *
422 )	const
423 {
424 	rText.Erase();
425 	return SFX_ITEM_PRESENTATION_NONE;
426 }
427 
428 // -----------------------------------------------------------------------
429 
430 int SvxDashListItem::operator==( const SfxPoolItem& rItem ) const
431 {
432 	DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
433 	return ( ( SvxDashListItem& ) rItem).pDashList == pDashList;
434 }
435 
436 // -----------------------------------------------------------------------
437 
438 SfxPoolItem* SvxDashListItem::Clone( SfxItemPool * ) const
439 {
440 	return new SvxDashListItem( *this );
441 }
442 
443 // -----------------------------------------------------------------------
444 
445 sal_Bool SvxDashListItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
446 {
447     // This is only a quick helper to have UI support for these list items. Don't use
448     // this method to query for a valid UNO representation.
449     sal_Int64 aValue = sal_Int64( (sal_uLong)pDashList );
450     rVal = uno::makeAny( aValue );
451     return sal_True;
452 }
453 
454 // -----------------------------------------------------------------------
455 
456 sal_Bool SvxDashListItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
457 {
458     // This is only a quick helper to have UI support for these list items. Don't use
459     // this method to query for a valid UNO representation.
460     sal_Int64 aValue = 0;
461     if ( rVal >>= aValue )
462     {
463         pDashList = (XDashList *)(sal_uLong)aValue;
464         return sal_True;
465     }
466 
467     return sal_False;
468 }
469 
470 // -----------------------------------------------------------------------
471 
472 void SvxDashListItem::SetDashList( XDashList* pList )
473 {
474     pDashList = pList;
475 }
476 
477 //==================================================================
478 //
479 //	SvxLineEndListItem
480 //
481 //==================================================================
482 
483 SvxLineEndListItem::SvxLineEndListItem()
484 {
485 }
486 
487 // -----------------------------------------------------------------------
488 
489 SvxLineEndListItem::SvxLineEndListItem( XLineEndList* pList, sal_uInt16 nW ) :
490 	SfxPoolItem( nW ),
491 	pLineEndList( pList )
492 {
493 }
494 
495 // -----------------------------------------------------------------------
496 
497 SvxLineEndListItem::SvxLineEndListItem( const SvxLineEndListItem& rItem ) :
498 	SfxPoolItem( rItem ),
499 	pLineEndList( rItem.pLineEndList )
500 {
501 }
502 
503 //------------------------------------------------------------------------
504 
505 SfxItemPresentation SvxLineEndListItem::GetPresentation
506 (
507     SfxItemPresentation /*ePres*/,
508     SfxMapUnit          /*eCoreUnit*/,
509     SfxMapUnit          /*ePresUnit*/,
510     XubString&          rText, const IntlWrapper *
511 )	const
512 {
513 	rText.Erase();
514 	return SFX_ITEM_PRESENTATION_NONE;
515 }
516 
517 // -----------------------------------------------------------------------
518 
519 int SvxLineEndListItem::operator==( const SfxPoolItem& rItem ) const
520 {
521 	DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
522 	return ( ( SvxLineEndListItem& ) rItem).pLineEndList == pLineEndList;
523 }
524 
525 // -----------------------------------------------------------------------
526 
527 SfxPoolItem* SvxLineEndListItem::Clone( SfxItemPool * ) const
528 {
529 	return new SvxLineEndListItem( *this );
530 }
531 
532 // -----------------------------------------------------------------------
533 
534 sal_Bool SvxLineEndListItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
535 {
536     // This is only a quick helper to have UI support for these list items. Don't use
537     // this method to query for a valid UNO representation.
538     sal_Int64 aValue = sal_Int64( (sal_uLong)pLineEndList );
539     rVal = uno::makeAny( aValue );
540     return sal_True;
541 }
542 
543 // -----------------------------------------------------------------------
544 
545 sal_Bool SvxLineEndListItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
546 {
547     // This is only a quick helper to have UI support for these list items. Don't use
548     // this method to query for a valid UNO representation.
549     sal_Int64 aValue = 0;
550     if ( rVal >>= aValue )
551     {
552         pLineEndList = (XLineEndList *)(sal_uLong)aValue;
553         return sal_True;
554     }
555 
556     return sal_False;
557 }
558