Branch data Line data Source code
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 : :
20 : : #include "GraphicPropertyItemConverter.hxx"
21 : : #include "SchWhichPairs.hxx"
22 : : #include "macros.hxx"
23 : : #include "ItemPropertyMap.hxx"
24 : : #include "PropertyHelper.hxx"
25 : : #include "CommonConverters.hxx"
26 : : #include <editeng/memberids.hrc>
27 : : #include <svx/xflclit.hxx>
28 : : #include <svx/xlnclit.hxx>
29 : : #include <svx/xflbmtit.hxx>
30 : : #include <svx/xflbstit.hxx>
31 : : #include <svx/xbtmpit.hxx>
32 : : #include <svx/xflftrit.hxx>
33 : : #include <svx/xlndsit.hxx>
34 : : #include <svx/xflhtit.hxx>
35 : : #include <svx/xflgrit.hxx>
36 : : #include <svx/xfltrit.hxx>
37 : : #include <svx/xlntrit.hxx>
38 : : #include <editeng/eeitem.hxx>
39 : : // for SfxBoolItem
40 : : #include <svl/eitem.hxx>
41 : : // for XFillGradientStepCountItem
42 : : #include <svx/xgrscit.hxx>
43 : : #include <com/sun/star/beans/XPropertyState.hpp>
44 : : #include <com/sun/star/chart2/FillBitmap.hpp>
45 : : #include <com/sun/star/awt/Gradient.hpp>
46 : : #include <com/sun/star/container/XNameAccess.hpp>
47 : :
48 : : using namespace ::com::sun::star;
49 : :
50 : : namespace
51 : : {
52 : 0 : ::comphelper::ItemPropertyMapType & lcl_GetDataPointFilledPropertyMap()
53 : : {
54 : : static ::comphelper::ItemPropertyMapType aDataPointPropertyFilledMap(
55 : : ::comphelper::MakeItemPropertyMap
56 : : IPM_MAP_ENTRY( XATTR_FILLSTYLE, "FillStyle", 0 )
57 [ # # ][ # # ]: 0 : IPM_MAP_ENTRY( XATTR_FILLCOLOR, "Color", 0 )
[ # # ][ # # ]
58 [ # # ][ # # ]: 0 : IPM_MAP_ENTRY( XATTR_LINECOLOR, "BorderColor", 0 )
59 [ # # ][ # # ]: 0 : IPM_MAP_ENTRY( XATTR_LINESTYLE, "BorderStyle", 0 )
60 [ # # ][ # # ]: 0 : IPM_MAP_ENTRY( XATTR_LINEWIDTH, "BorderWidth", 0 )
61 [ # # ][ # # ]: 0 : IPM_MAP_ENTRY( XATTR_FILLBACKGROUND, "FillBackground", 0 )
62 [ # # ][ # # ]: 0 : IPM_MAP_ENTRY( XATTR_FILLBMP_POS, "FillBitmapRectanglePoint", 0 )
63 [ # # ][ # # ]: 0 : IPM_MAP_ENTRY( XATTR_FILLBMP_SIZEX, "FillBitmapSizeX", 0 )
64 [ # # ][ # # ]: 0 : IPM_MAP_ENTRY( XATTR_FILLBMP_SIZEY, "FillBitmapSizeY", 0 )
65 [ # # ][ # # ]: 0 : IPM_MAP_ENTRY( XATTR_FILLBMP_SIZELOG, "FillBitmapLogicalSize", 0 )
66 [ # # ][ # # ]: 0 : IPM_MAP_ENTRY( XATTR_FILLBMP_TILEOFFSETX, "FillBitmapOffsetX", 0 )
67 [ # # ][ # # ]: 0 : IPM_MAP_ENTRY( XATTR_FILLBMP_TILEOFFSETY, "FillBitmapOffsetY", 0 )
68 [ # # ][ # # ]: 0 : IPM_MAP_ENTRY( XATTR_FILLBMP_POSOFFSETX, "FillBitmapPositionOffsetX", 0 )
69 [ # # ][ # # ]: 0 : IPM_MAP_ENTRY( XATTR_FILLBMP_POSOFFSETY, "FillBitmapPositionOffsetY", 0 )
70 [ # # ][ # # ]: 0 : );
[ # # ][ # # ]
71 : :
72 : 0 : return aDataPointPropertyFilledMap;
73 : : }
74 : 0 : ::comphelper::ItemPropertyMapType & lcl_GetDataPointLinePropertyMap()
75 : : {
76 : : static ::comphelper::ItemPropertyMapType aDataPointPropertyLineMap(
77 : : ::comphelper::MakeItemPropertyMap
78 : : IPM_MAP_ENTRY( XATTR_LINECOLOR, "Color", 0 )
79 [ # # ][ # # ]: 0 : IPM_MAP_ENTRY( XATTR_LINESTYLE, "LineStyle", 0 )
[ # # ][ # # ]
80 [ # # ][ # # ]: 0 : IPM_MAP_ENTRY( XATTR_LINEWIDTH, "LineWidth", 0 )
81 [ # # ][ # # ]: 0 : );
[ # # ][ # # ]
82 : :
83 : 0 : return aDataPointPropertyLineMap;
84 : : }
85 : 0 : ::comphelper::ItemPropertyMapType & lcl_GetLinePropertyMap()
86 : : {
87 : : static ::comphelper::ItemPropertyMapType aLinePropertyMap(
88 : : ::comphelper::MakeItemPropertyMap
89 : : IPM_MAP_ENTRY( XATTR_LINESTYLE, "LineStyle", 0 )
90 [ # # ][ # # ]: 0 : IPM_MAP_ENTRY( XATTR_LINEWIDTH, "LineWidth", 0 )
[ # # ][ # # ]
91 [ # # ][ # # ]: 0 : IPM_MAP_ENTRY( XATTR_LINECOLOR, "LineColor", 0 )
92 [ # # ][ # # ]: 0 : IPM_MAP_ENTRY( XATTR_LINEJOINT, "LineJoint", 0 )
93 [ # # ][ # # ]: 0 : );
[ # # ][ # # ]
94 : :
95 : 0 : return aLinePropertyMap;
96 : : }
97 : 0 : ::comphelper::ItemPropertyMapType & lcl_GetFillPropertyMap()
98 : : {
99 : : static ::comphelper::ItemPropertyMapType aFillPropertyMap(
100 : : ::comphelper::MakeItemPropertyMap
101 : : IPM_MAP_ENTRY( XATTR_FILLSTYLE, "FillStyle", 0 )
102 [ # # ][ # # ]: 0 : IPM_MAP_ENTRY( XATTR_FILLCOLOR, "FillColor", 0 )
[ # # ][ # # ]
103 [ # # ][ # # ]: 0 : IPM_MAP_ENTRY( XATTR_FILLBACKGROUND, "FillBackground", 0 )
104 [ # # ][ # # ]: 0 : IPM_MAP_ENTRY( XATTR_FILLBMP_POS, "FillBitmapRectanglePoint", 0 )
105 [ # # ][ # # ]: 0 : IPM_MAP_ENTRY( XATTR_FILLBMP_SIZEX, "FillBitmapSizeX", 0 )
106 [ # # ][ # # ]: 0 : IPM_MAP_ENTRY( XATTR_FILLBMP_SIZEY, "FillBitmapSizeY", 0 )
107 [ # # ][ # # ]: 0 : IPM_MAP_ENTRY( XATTR_FILLBMP_SIZELOG, "FillBitmapLogicalSize", 0 )
108 [ # # ][ # # ]: 0 : IPM_MAP_ENTRY( XATTR_FILLBMP_TILEOFFSETX, "FillBitmapOffsetX", 0 )
109 [ # # ][ # # ]: 0 : IPM_MAP_ENTRY( XATTR_FILLBMP_TILEOFFSETY, "FillBitmapOffsetY", 0 )
110 [ # # ][ # # ]: 0 : IPM_MAP_ENTRY( XATTR_FILLBMP_POSOFFSETX, "FillBitmapPositionOffsetX", 0 )
111 [ # # ][ # # ]: 0 : IPM_MAP_ENTRY( XATTR_FILLBMP_POSOFFSETY, "FillBitmapPositionOffsetY", 0 )
112 [ # # ][ # # ]: 0 : );
[ # # ][ # # ]
113 : :
114 : 0 : return aFillPropertyMap;
115 : : }
116 : :
117 : 0 : bool lcl_supportsFillProperties( ::chart::wrapper::GraphicPropertyItemConverter::eGraphicObjectType eType )
118 : : {
119 : : return ( eType == ::chart::wrapper::GraphicPropertyItemConverter::FILLED_DATA_POINT ||
120 : : eType == ::chart::wrapper::GraphicPropertyItemConverter::FILL_PROPERTIES ||
121 [ # # ][ # # ]: 0 : eType == ::chart::wrapper::GraphicPropertyItemConverter::LINE_AND_FILL_PROPERTIES );
[ # # ]
122 : : }
123 : :
124 : 0 : bool lcl_supportsLineProperties( ::chart::wrapper::GraphicPropertyItemConverter::eGraphicObjectType eType )
125 : : {
126 : 0 : return ( eType != ::chart::wrapper::GraphicPropertyItemConverter::FILL_PROPERTIES );
127 : : }
128 : :
129 : 0 : bool lcl_SetContentForNamedProperty(
130 : : const uno::Reference< lang::XMultiServiceFactory > & xFactory,
131 : : const ::rtl::OUString & rTableName,
132 : : NameOrIndex & rItem, sal_uInt8 nMemberId )
133 : : {
134 : 0 : bool bResult = false;
135 [ # # ]: 0 : if( xFactory.is())
136 : : {
137 [ # # ][ # # ]: 0 : ::rtl::OUString aPropertyValue( rItem.GetName());
[ # # ]
138 : : uno::Reference< container::XNameAccess > xNameAcc(
139 [ # # ]: 0 : xFactory->createInstance( rTableName ),
140 [ # # ][ # # ]: 0 : uno::UNO_QUERY );
141 [ # # ][ # # ]: 0 : if( xNameAcc.is() &&
[ # # ]
142 [ # # ][ # # ]: 0 : xNameAcc->hasByName( aPropertyValue ))
143 : : {
144 [ # # ][ # # ]: 0 : rItem.PutValue( xNameAcc->getByName( aPropertyValue ), nMemberId );
[ # # ]
145 : 0 : bResult = true;
146 : 0 : }
147 : : }
148 : 0 : return bResult;
149 : : }
150 : :
151 : : } // anonymous namespace
152 : :
153 : : // ========================================
154 : :
155 : : namespace chart
156 : : {
157 : : namespace wrapper
158 : : {
159 : :
160 : 0 : GraphicPropertyItemConverter::GraphicPropertyItemConverter(
161 : : const uno::Reference<
162 : : beans::XPropertySet > & rPropertySet,
163 : : SfxItemPool& rItemPool,
164 : : SdrModel& rDrawModel,
165 : : const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory,
166 : : eGraphicObjectType eObjectType /* = FILL_PROPERTIES */ ) :
167 : : ItemConverter( rPropertySet, rItemPool ),
168 : : m_eGraphicObjectType( eObjectType ),
169 : : m_rDrawModel( rDrawModel ),
170 : 0 : m_xNamedPropertyTableFactory( xNamedPropertyContainerFactory )
171 : 0 : {}
172 : :
173 : 0 : GraphicPropertyItemConverter::~GraphicPropertyItemConverter()
174 [ # # ]: 0 : {}
175 : :
176 : 0 : const sal_uInt16 * GraphicPropertyItemConverter::GetWhichPairs() const
177 : : {
178 : 0 : const sal_uInt16 * pResult = NULL;
179 : :
180 [ # # # # : 0 : switch( m_eGraphicObjectType )
# ]
181 : : {
182 : : case LINE_DATA_POINT:
183 : : case FILLED_DATA_POINT:
184 : 0 : pResult = nRowWhichPairs; break;
185 : : case LINE_PROPERTIES:
186 : 0 : pResult = nLinePropertyWhichPairs; break;
187 : : case FILL_PROPERTIES:
188 : 0 : pResult = nFillPropertyWhichPairs; break;
189 : : case LINE_AND_FILL_PROPERTIES:
190 : 0 : pResult = nLineAndFillPropertyWhichPairs; break;
191 : : }
192 : :
193 : 0 : return pResult;
194 : : }
195 : :
196 : 0 : bool GraphicPropertyItemConverter::GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const
197 : : {
198 : 0 : ::comphelper::ItemPropertyMapType::const_iterator aEndIt;
199 : 0 : ::comphelper::ItemPropertyMapType::const_iterator aIt;
200 : :
201 [ # # # # : 0 : switch( m_eGraphicObjectType )
# # ]
202 : : {
203 : : case LINE_DATA_POINT:
204 [ # # ]: 0 : aEndIt = lcl_GetDataPointLinePropertyMap().end();
205 [ # # ][ # # ]: 0 : aIt = lcl_GetDataPointLinePropertyMap().find( nWhichId );
206 : 0 : break;
207 : : case FILLED_DATA_POINT:
208 [ # # ]: 0 : aEndIt = lcl_GetDataPointFilledPropertyMap().end();
209 [ # # ][ # # ]: 0 : aIt = lcl_GetDataPointFilledPropertyMap().find( nWhichId );
210 : 0 : break;
211 : : case LINE_PROPERTIES:
212 [ # # ]: 0 : aEndIt = lcl_GetLinePropertyMap().end();
213 [ # # ][ # # ]: 0 : aIt = lcl_GetLinePropertyMap().find( nWhichId );
214 : 0 : break;
215 : :
216 : : case FILL_PROPERTIES:
217 [ # # ]: 0 : aEndIt = lcl_GetFillPropertyMap().end();
218 [ # # ][ # # ]: 0 : aIt = lcl_GetFillPropertyMap().find( nWhichId );
219 : 0 : break;
220 : :
221 : : case LINE_AND_FILL_PROPERTIES:
222 : : // line
223 [ # # ]: 0 : aEndIt = lcl_GetLinePropertyMap().end();
224 [ # # ][ # # ]: 0 : aIt = lcl_GetLinePropertyMap().find( nWhichId );
225 : :
226 : : // not found => try fill
227 [ # # ]: 0 : if( aIt == aEndIt )
228 : : {
229 [ # # ]: 0 : aEndIt = lcl_GetFillPropertyMap().end();
230 [ # # ][ # # ]: 0 : aIt = lcl_GetFillPropertyMap().find( nWhichId );
231 : : }
232 : 0 : break;
233 : : }
234 : :
235 [ # # ]: 0 : if( aIt == aEndIt )
236 : 0 : return false;
237 : :
238 : 0 : rOutProperty =(*aIt).second;
239 : 0 : return true;
240 : : }
241 : :
242 : 0 : void GraphicPropertyItemConverter::FillSpecialItem(
243 : : sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const
244 : : throw( uno::Exception )
245 : : {
246 [ # # # # : 0 : switch( nWhichId )
# # # # #
# ]
247 : : {
248 : : // bitmap property
249 : : case XATTR_FILLBMP_TILE:
250 : : case XATTR_FILLBMP_STRETCH:
251 : : {
252 : 0 : drawing::BitmapMode aMode = drawing::BitmapMode_REPEAT;
253 [ # # ][ # # ]: 0 : if( GetPropertySet()->getPropertyValue( C2U("FillBitmapMode")) >>= aMode )
[ # # ][ # # ]
[ # # ][ # # ]
254 : : {
255 [ # # ][ # # ]: 0 : rOutItemSet.Put( XFillBmpTileItem( aMode == drawing::BitmapMode_REPEAT ));
[ # # ]
256 [ # # ][ # # ]: 0 : rOutItemSet.Put( XFillBmpStretchItem( aMode == drawing::BitmapMode_STRETCH ));
[ # # ]
257 : : }
258 : : }
259 : 0 : break;
260 : :
261 : : case XATTR_FILLFLOATTRANSPARENCE:
262 : : try
263 : : {
264 [ # # ]: 0 : if( lcl_supportsFillProperties( m_eGraphicObjectType ))
265 : : {
266 : : ::rtl::OUString aPropName =
267 : : (m_eGraphicObjectType == FILLED_DATA_POINT)
268 : : ? C2U( "TransparencyGradientName" )
269 [ # # ][ # # ]: 0 : : C2U( "FillTransparenceGradientName" );
[ # # ]
270 : :
271 [ # # ][ # # ]: 0 : uno::Any aValue( GetPropertySet()->getPropertyValue( aPropName ));
[ # # ]
272 [ # # ]: 0 : if( aValue.hasValue())
273 : : {
274 [ # # ]: 0 : XFillFloatTransparenceItem aItem;
275 [ # # ]: 0 : aItem.PutValue( aValue, MID_NAME );
276 : :
277 : : lcl_SetContentForNamedProperty(
278 : : m_xNamedPropertyTableFactory, C2U("com.sun.star.drawing.TransparencyGradientTable"),
279 [ # # ][ # # ]: 0 : aItem, MID_FILLGRADIENT );
280 : :
281 : : // this is important to enable the item
282 : 0 : ::rtl::OUString aName;
283 [ # # ]: 0 : if( (aValue >>= aName) &&
[ # # # # ]
284 : 0 : !aName.isEmpty())
285 : : {
286 : 0 : aItem.SetEnabled( sal_True );
287 [ # # ]: 0 : rOutItemSet.Put( aItem );
288 [ # # ]: 0 : }
289 [ # # ]: 0 : }
290 : : }
291 : : }
292 : 0 : catch( const beans::UnknownPropertyException &ex )
293 : : {
294 : : ASSERT_EXCEPTION( ex );
295 : : }
296 : 0 : break;
297 : :
298 : : case XATTR_GRADIENTSTEPCOUNT:
299 [ # # ]: 0 : if( lcl_supportsFillProperties( m_eGraphicObjectType ))
300 : : {
301 : : ::rtl::OUString aPropName =
302 : : (m_eGraphicObjectType == FILLED_DATA_POINT)
303 : : ? C2U( "GradientStepCount" )
304 [ # # ][ # # ]: 0 : : C2U( "FillGradientStepCount" );
[ # # ]
305 : :
306 [ # # ][ # # ]: 0 : uno::Any aValue( GetPropertySet()->getPropertyValue( aPropName ) );
[ # # ]
307 [ # # ][ # # ]: 0 : if( hasLongOrShortValue(aValue) )
308 : : {
309 [ # # ]: 0 : sal_Int16 nStepCount = getShortForLongAlso(aValue);
310 [ # # ][ # # ]: 0 : rOutItemSet.Put( XGradientStepCountItem( nStepCount ));
[ # # ]
311 : 0 : }
312 : : }
313 : 0 : break;
314 : :
315 : : case XATTR_LINEDASH:
316 [ # # ]: 0 : if( lcl_supportsLineProperties( m_eGraphicObjectType ))
317 : : {
318 : : ::rtl::OUString aPropName =
319 : : (m_eGraphicObjectType == FILLED_DATA_POINT)
320 : : ? C2U( "BorderDashName" )
321 [ # # ][ # # ]: 0 : : C2U( "LineDashName" );
[ # # ]
322 : :
323 [ # # ]: 0 : XLineDashItem aItem;
324 [ # # ][ # # ]: 0 : aItem.PutValue( GetPropertySet()->getPropertyValue( aPropName ), MID_NAME );
[ # # ][ # # ]
325 : :
326 : : lcl_SetContentForNamedProperty(
327 : : m_xNamedPropertyTableFactory, C2U("com.sun.star.drawing.DashTable"),
328 [ # # ][ # # ]: 0 : aItem, MID_LINEDASH );
329 : :
330 : : // translate model name to UI-name for predefined entries, so
331 : : // that the correct entry is chosen in the list of UI-names
332 : 0 : XLineDashItem * pItemToPut = & aItem;
333 [ # # ]: 0 : pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel );
334 : :
335 [ # # ][ # # ]: 0 : rOutItemSet.Put( * pItemToPut );
336 : : }
337 : 0 : break;
338 : :
339 : : case XATTR_FILLGRADIENT:
340 [ # # ]: 0 : if( lcl_supportsFillProperties( m_eGraphicObjectType ))
341 : : {
342 : : ::rtl::OUString aPropName =
343 : : (m_eGraphicObjectType == FILLED_DATA_POINT)
344 : : ? C2U( "GradientName" )
345 [ # # ][ # # ]: 0 : : C2U( "FillGradientName" );
[ # # ]
346 : :
347 [ # # ]: 0 : XFillGradientItem aItem;
348 [ # # ][ # # ]: 0 : aItem.PutValue( GetPropertySet()->getPropertyValue( aPropName ), MID_NAME );
[ # # ][ # # ]
349 : :
350 : : lcl_SetContentForNamedProperty(
351 : : m_xNamedPropertyTableFactory, C2U("com.sun.star.drawing.GradientTable"),
352 [ # # ][ # # ]: 0 : aItem, MID_FILLGRADIENT );
353 : :
354 : : // translate model name to UI-name for predefined entries, so
355 : : // that the correct entry is chosen in the list of UI-names
356 : 0 : XFillGradientItem * pItemToPut = & aItem;
357 [ # # ]: 0 : pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel );
358 : :
359 [ # # ][ # # ]: 0 : rOutItemSet.Put( * pItemToPut );
360 : : }
361 : 0 : break;
362 : :
363 : : case XATTR_FILLHATCH:
364 [ # # ]: 0 : if( lcl_supportsFillProperties( m_eGraphicObjectType ))
365 : : {
366 : : ::rtl::OUString aPropName =
367 : : (m_eGraphicObjectType == FILLED_DATA_POINT)
368 : : ? C2U( "HatchName" )
369 [ # # ][ # # ]: 0 : : C2U( "FillHatchName" );
[ # # ]
370 : :
371 [ # # ]: 0 : XFillHatchItem aItem;
372 [ # # ][ # # ]: 0 : aItem.PutValue( GetPropertySet()->getPropertyValue( aPropName ), MID_NAME );
[ # # ][ # # ]
373 : :
374 : : lcl_SetContentForNamedProperty(
375 : : m_xNamedPropertyTableFactory, C2U("com.sun.star.drawing.HatchTable"),
376 [ # # ][ # # ]: 0 : aItem, MID_FILLHATCH );
377 : :
378 : : // translate model name to UI-name for predefined entries, so
379 : : // that the correct entry is chosen in the list of UI-names
380 : 0 : XFillHatchItem * pItemToPut = & aItem;
381 [ # # ]: 0 : pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel );
382 : :
383 [ # # ][ # # ]: 0 : rOutItemSet.Put( * pItemToPut );
384 : : }
385 : 0 : break;
386 : :
387 : : case XATTR_FILLBITMAP:
388 [ # # ]: 0 : if( lcl_supportsFillProperties( m_eGraphicObjectType ))
389 : : {
390 [ # # ]: 0 : XFillBitmapItem aItem;
391 [ # # ][ # # ]: 0 : aItem.PutValue( GetPropertySet()->getPropertyValue( C2U( "FillBitmapName" ) ), MID_NAME );
[ # # ][ # # ]
[ # # ]
392 : :
393 : : lcl_SetContentForNamedProperty(
394 : : m_xNamedPropertyTableFactory, C2U("com.sun.star.drawing.BitmapTable"),
395 [ # # ][ # # ]: 0 : aItem, MID_GRAFURL );
396 : :
397 : : // translate model name to UI-name for predefined entries, so
398 : : // that the correct entry is chosen in the list of UI-names
399 : 0 : XFillBitmapItem * pItemToPut = & aItem;
400 [ # # ]: 0 : pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel );
401 : :
402 [ # # ][ # # ]: 0 : rOutItemSet.Put( * pItemToPut );
403 : : }
404 : 0 : break;
405 : :
406 : : // hack, because QueryValue of XLineTransparenceItem returns sal_Int32
407 : : // instead of sal_Int16
408 : : case XATTR_LINETRANSPARENCE:
409 [ # # ]: 0 : if( lcl_supportsLineProperties( m_eGraphicObjectType ))
410 : : {
411 : : ::rtl::OUString aPropName =
412 : : (m_eGraphicObjectType == FILLED_DATA_POINT)
413 : : ? C2U( "BorderTransparency" )
414 : : : (m_eGraphicObjectType == LINE_DATA_POINT)
415 : : ? C2U( "Transparency" )
416 [ # # ][ # # ]: 0 : : C2U( "LineTransparence" );
[ # # ][ # # ]
[ # # ]
417 : :
418 [ # # ]: 0 : XLineTransparenceItem aItem;
419 [ # # ][ # # ]: 0 : aItem.PutValue( GetPropertySet()->getPropertyValue( aPropName ) );
[ # # ][ # # ]
420 : :
421 [ # # ][ # # ]: 0 : rOutItemSet.Put( aItem );
422 : : }
423 : 0 : break;
424 : :
425 : : // hack, because QueryValue of XFillTransparenceItem returns sal_Int32
426 : : // instead of sal_Int16
427 : : case XATTR_FILLTRANSPARENCE:
428 [ # # ]: 0 : if( lcl_supportsFillProperties( m_eGraphicObjectType ))
429 : : {
430 : : ::rtl::OUString aPropName =
431 : : (m_eGraphicObjectType == FILLED_DATA_POINT)
432 : : ? C2U( "Transparency" )
433 [ # # ][ # # ]: 0 : : C2U( "FillTransparence" );
[ # # ]
434 : :
435 [ # # ]: 0 : XFillTransparenceItem aItem;
436 [ # # ][ # # ]: 0 : aItem.PutValue( GetPropertySet()->getPropertyValue( aPropName ) );
[ # # ][ # # ]
437 : :
438 [ # # ][ # # ]: 0 : rOutItemSet.Put( aItem );
439 : : }
440 : 0 : break;
441 : : }
442 : 0 : }
443 : :
444 : 0 : bool GraphicPropertyItemConverter::ApplySpecialItem(
445 : : sal_uInt16 nWhichId, const SfxItemSet & rItemSet )
446 : : throw( uno::Exception )
447 : : {
448 : 0 : bool bChanged = false;
449 : 0 : uno::Any aValue;
450 : :
451 [ # # # # : 0 : switch( nWhichId )
# # # # #
# # ]
452 : : {
453 : : // bitmap property
454 : : case XATTR_FILLBMP_STRETCH:
455 [ # # ]: 0 : if( lcl_supportsFillProperties( m_eGraphicObjectType ))
456 : : {
457 [ # # ]: 0 : const ::rtl::OUString aModePropName = C2U("FillBitmapMode");
458 : : bool bStretched = static_cast< const XFillBmpStretchItem & >(
459 [ # # ]: 0 : rItemSet.Get( XATTR_FILLBMP_STRETCH )).GetValue();
460 : : drawing::BitmapMode aMode =
461 [ # # ]: 0 : (bStretched ? drawing::BitmapMode_STRETCH : drawing::BitmapMode_NO_REPEAT);
462 : :
463 [ # # ]: 0 : aValue <<= aMode;
464 [ # # ][ # # ]: 0 : if( aValue != GetPropertySet()->getPropertyValue( aModePropName ))
[ # # ][ # # ]
465 : : {
466 [ # # ][ # # ]: 0 : GetPropertySet()->setPropertyValue( aModePropName, aValue );
[ # # ]
467 : 0 : bChanged = true;
468 : 0 : }
469 : : }
470 : 0 : break;
471 : :
472 : : case XATTR_FILLBMP_TILE:
473 [ # # ]: 0 : if( lcl_supportsFillProperties( m_eGraphicObjectType ))
474 : : {
475 [ # # ]: 0 : const ::rtl::OUString aModePropName = C2U("FillBitmapMode");
476 : : bool bTiled = static_cast< const XFillBmpTileItem & >(
477 [ # # ]: 0 : rItemSet.Get( XATTR_FILLBMP_TILE )).GetValue();
478 : : drawing::BitmapMode aMode =
479 [ # # ]: 0 : (bTiled ? drawing::BitmapMode_REPEAT : drawing::BitmapMode_NO_REPEAT);
480 : :
481 [ # # ]: 0 : aValue <<= aMode;
482 [ # # ][ # # ]: 0 : if( aValue != GetPropertySet()->getPropertyValue( aModePropName ))
[ # # ][ # # ]
483 : : {
484 [ # # ][ # # ]: 0 : GetPropertySet()->setPropertyValue( aModePropName, aValue );
[ # # ]
485 : 0 : bChanged = true;
486 : 0 : }
487 : : }
488 : 0 : break;
489 : :
490 : : case XATTR_FILLFLOATTRANSPARENCE:
491 : : try
492 : : {
493 [ # # ]: 0 : if( lcl_supportsFillProperties( m_eGraphicObjectType ))
494 : : {
495 : : ::rtl::OUString aPropName =
496 : : (m_eGraphicObjectType == FILLED_DATA_POINT)
497 : : ? C2U( "TransparencyGradientName" )
498 [ # # ][ # # ]: 0 : : C2U( "FillTransparenceGradientName" );
[ # # ]
499 : :
500 : : const XFillFloatTransparenceItem & rItem =
501 : : static_cast< const XFillFloatTransparenceItem & >(
502 [ # # ]: 0 : rItemSet.Get( nWhichId ));
503 : :
504 [ # # ][ # # ]: 0 : if( rItem.IsEnabled() &&
[ # # ]
505 [ # # ]: 0 : rItem.QueryValue( aValue, MID_NAME ))
506 : : {
507 : 0 : uno::Any aGradient;
508 [ # # ]: 0 : rItem.QueryValue( aGradient, MID_FILLGRADIENT );
509 : :
510 : : // add TransparencyGradient to list if it does not already exist
511 : 0 : ::rtl::OUString aPreferredName;
512 : 0 : aValue >>= aPreferredName;
513 : : aValue <<= PropertyHelper::addTransparencyGradientUniqueNameToTable(
514 [ # # ][ # # ]: 0 : aGradient, m_xNamedPropertyTableFactory, aPreferredName );
515 : :
516 [ # # ][ # # ]: 0 : if( aValue != GetPropertySet()->getPropertyValue( aPropName ))
[ # # ][ # # ]
517 : : {
518 [ # # ][ # # ]: 0 : GetPropertySet()->setPropertyValue( aPropName, aValue );
[ # # ]
519 : 0 : bChanged = true;
520 : 0 : }
521 : : }
522 : : else
523 : : {
524 : 0 : ::rtl::OUString aName;
525 [ # # ][ # # ]: 0 : if( ( GetPropertySet()->getPropertyValue( aPropName ) >>= aName )
[ # # # # ]
[ # # ][ # # ]
[ # # # #
# # ][ # # ]
526 : 0 : && !aName.isEmpty() )
527 : : {
528 [ # # ][ # # ]: 0 : uno::Reference< beans::XPropertyState > xState( GetPropertySet(), uno::UNO_QUERY );
529 [ # # ]: 0 : if( xState.is())
530 [ # # ][ # # ]: 0 : xState->setPropertyToDefault( aPropName );
531 : 0 : bChanged = true;
532 : 0 : }
533 [ # # ]: 0 : }
534 : : }
535 : : }
536 [ # # ]: 0 : catch( const beans::UnknownPropertyException &ex )
537 : : {
538 : : ASSERT_EXCEPTION( ex );
539 : : }
540 : 0 : break;
541 : :
542 : : case XATTR_GRADIENTSTEPCOUNT:
543 : : {
544 [ # # ]: 0 : if( lcl_supportsFillProperties( m_eGraphicObjectType ))
545 : : {
546 : : ::rtl::OUString aPropName =
547 : : (m_eGraphicObjectType == FILLED_DATA_POINT)
548 : : ? C2U( "GradientStepCount" )
549 [ # # ][ # # ]: 0 : : C2U( "FillGradientStepCount" );
[ # # ]
550 : :
551 : : sal_Int16 nStepCount = ( static_cast< const XGradientStepCountItem & >(
552 [ # # ]: 0 : rItemSet.Get( nWhichId ))).GetValue();
553 : :
554 [ # # ]: 0 : aValue <<= nStepCount;
555 [ # # ][ # # ]: 0 : if( aValue != GetPropertySet()->getPropertyValue( aPropName ))
[ # # ][ # # ]
556 : : {
557 [ # # ][ # # ]: 0 : GetPropertySet()->setPropertyValue( aPropName, aValue );
[ # # ]
558 : 0 : bChanged = true;
559 : 0 : }
560 : : }
561 : : }
562 : 0 : break;
563 : :
564 : : case XATTR_LINEDASH:
565 : : {
566 [ # # ]: 0 : if( lcl_supportsLineProperties( m_eGraphicObjectType ))
567 : : {
568 : :
569 : : ::rtl::OUString aPropName =
570 : : (m_eGraphicObjectType == FILLED_DATA_POINT)
571 : : ? C2U( "BorderDashName" )
572 [ # # ][ # # ]: 0 : : C2U( "LineDashName" );
[ # # ]
573 : :
574 : : const XLineDashItem & rItem =
575 : : static_cast< const XLineDashItem & >(
576 [ # # ]: 0 : rItemSet.Get( nWhichId ));
577 : :
578 [ # # ][ # # ]: 0 : if( rItem.QueryValue( aValue, MID_NAME ))
579 : : {
580 [ # # ][ # # ]: 0 : if( aValue != GetPropertySet()->getPropertyValue( aPropName ))
[ # # ][ # # ]
581 : : {
582 : : // add LineDash to list
583 : 0 : uno::Any aLineDash;
584 [ # # ]: 0 : rItem.QueryValue( aLineDash, MID_LINEDASH );
585 : 0 : ::rtl::OUString aPreferredName;
586 : 0 : aValue >>= aPreferredName;
587 : : aValue <<= PropertyHelper::addLineDashUniqueNameToTable(
588 [ # # ][ # # ]: 0 : aLineDash, m_xNamedPropertyTableFactory, aPreferredName );
589 : :
590 [ # # ][ # # ]: 0 : GetPropertySet()->setPropertyValue( aPropName, aValue );
[ # # ]
591 : 0 : bChanged = true;
592 : : }
593 : 0 : }
594 : : }
595 : : }
596 : 0 : break;
597 : :
598 : : case XATTR_FILLGRADIENT:
599 : : {
600 [ # # ]: 0 : if( lcl_supportsFillProperties( m_eGraphicObjectType ))
601 : : {
602 : : ::rtl::OUString aPropName =
603 : : (m_eGraphicObjectType == FILLED_DATA_POINT)
604 : : ? C2U( "GradientName" )
605 [ # # ][ # # ]: 0 : : C2U( "FillGradientName" );
[ # # ]
606 : :
607 : : const XFillGradientItem & rItem =
608 : : static_cast< const XFillGradientItem & >(
609 [ # # ]: 0 : rItemSet.Get( nWhichId ));
610 : :
611 [ # # ][ # # ]: 0 : if( rItem.QueryValue( aValue, MID_NAME ))
612 : : {
613 [ # # ][ # # ]: 0 : if( aValue != GetPropertySet()->getPropertyValue( aPropName ))
[ # # ][ # # ]
614 : : {
615 : : // add Gradient to list
616 : 0 : uno::Any aGradient;
617 [ # # ]: 0 : rItem.QueryValue( aGradient, MID_FILLGRADIENT );
618 : 0 : ::rtl::OUString aPreferredName;
619 : 0 : aValue >>= aPreferredName;
620 : : aValue <<= PropertyHelper::addGradientUniqueNameToTable(
621 [ # # ][ # # ]: 0 : aGradient, m_xNamedPropertyTableFactory, aPreferredName );
622 : :
623 [ # # ][ # # ]: 0 : GetPropertySet()->setPropertyValue( aPropName, aValue );
[ # # ]
624 : 0 : bChanged = true;
625 : : }
626 : 0 : }
627 : : }
628 : : }
629 : 0 : break;
630 : :
631 : : case XATTR_FILLHATCH:
632 : : {
633 [ # # ]: 0 : if( lcl_supportsFillProperties( m_eGraphicObjectType ))
634 : : {
635 : : ::rtl::OUString aPropName =
636 : : (m_eGraphicObjectType == FILLED_DATA_POINT)
637 : : ? C2U( "HatchName" )
638 [ # # ][ # # ]: 0 : : C2U( "FillHatchName" );
[ # # ]
639 : :
640 : : const XFillHatchItem & rItem =
641 : : static_cast< const XFillHatchItem & >(
642 [ # # ]: 0 : rItemSet.Get( nWhichId ));
643 : :
644 [ # # ][ # # ]: 0 : if( rItem.QueryValue( aValue, MID_NAME ))
645 : : {
646 [ # # ][ # # ]: 0 : if( aValue != GetPropertySet()->getPropertyValue( aPropName ))
[ # # ][ # # ]
647 : : {
648 : : // add Hatch to list
649 : 0 : uno::Any aHatch;
650 [ # # ]: 0 : rItem.QueryValue( aHatch, MID_FILLHATCH );
651 : 0 : ::rtl::OUString aPreferredName;
652 : 0 : aValue >>= aPreferredName;
653 : : aValue <<= PropertyHelper::addHatchUniqueNameToTable(
654 [ # # ][ # # ]: 0 : aHatch, m_xNamedPropertyTableFactory, aPreferredName );
655 : :
656 [ # # ][ # # ]: 0 : GetPropertySet()->setPropertyValue( aPropName, aValue );
[ # # ]
657 : 0 : bChanged = true;
658 : : }
659 : 0 : }
660 : : }
661 : : }
662 : 0 : break;
663 : :
664 : : case XATTR_FILLBITMAP:
665 : : {
666 [ # # ]: 0 : if( lcl_supportsFillProperties( m_eGraphicObjectType ))
667 : : {
668 : : const XFillBitmapItem & rItem =
669 : : static_cast< const XFillBitmapItem & >(
670 [ # # ]: 0 : rItemSet.Get( nWhichId ));
671 : :
672 [ # # ][ # # ]: 0 : if( rItem.QueryValue( aValue, MID_NAME ))
673 : : {
674 [ # # ][ # # ]: 0 : if( aValue != GetPropertySet()->getPropertyValue( C2U( "FillBitmapName" )))
[ # # ][ # # ]
[ # # ]
675 : : {
676 : : // add Bitmap to list
677 : 0 : uno::Any aBitmap;
678 [ # # ]: 0 : rItem.QueryValue( aBitmap, MID_GRAFURL );
679 : 0 : ::rtl::OUString aPreferredName;
680 : 0 : aValue >>= aPreferredName;
681 : : aValue <<= PropertyHelper::addBitmapUniqueNameToTable(
682 [ # # ][ # # ]: 0 : aBitmap, m_xNamedPropertyTableFactory, aPreferredName );
683 : :
684 [ # # ][ # # ]: 0 : GetPropertySet()->setPropertyValue( C2U( "FillBitmapName" ), aValue );
[ # # ][ # # ]
685 : 0 : bChanged = true;
686 : : }
687 : : }
688 : : }
689 : : }
690 : 0 : break;
691 : :
692 : : // hack, because QueryValue of XLineTransparenceItem returns sal_Int32
693 : : // instead of sal_Int16
694 : : case XATTR_LINETRANSPARENCE:
695 [ # # ]: 0 : if( lcl_supportsLineProperties( m_eGraphicObjectType ))
696 : : {
697 : : ::rtl::OUString aPropName =
698 : : (m_eGraphicObjectType == FILLED_DATA_POINT)
699 : : ? C2U( "BorderTransparency" )
700 : : : (m_eGraphicObjectType == LINE_DATA_POINT)
701 : : ? C2U( "Transparency" )
702 [ # # ][ # # ]: 0 : : C2U( "LineTransparence" );
[ # # ][ # # ]
[ # # ]
703 : :
704 : : const XLineTransparenceItem & rItem =
705 : : static_cast< const XLineTransparenceItem & >(
706 [ # # ]: 0 : rItemSet.Get( nWhichId ));
707 : :
708 [ # # ][ # # ]: 0 : if( rItem.QueryValue( aValue ))
709 : : {
710 : : OSL_ENSURE( ! aValue.isExtractableTo(
711 : : ::getCppuType( reinterpret_cast< const sal_Int16 * >(0))),
712 : : "TransparenceItem QueryValue bug is fixed. Remove hack." );
713 : 0 : sal_Int32 nValue = 0;
714 [ # # ]: 0 : if( aValue >>= nValue )
715 : : {
716 : : OSL_ENSURE( nValue < SAL_MAX_INT16, "Transparency value too large" );
717 : 0 : sal_Int16 nValueToSet( static_cast< sal_Int16 >( nValue ));
718 [ # # ]: 0 : aValue <<= nValueToSet;
719 : :
720 [ # # ][ # # ]: 0 : GetPropertySet()->setPropertyValue( aPropName, aValue );
[ # # ]
721 : 0 : bChanged = true;
722 : : }
723 : : else
724 : : {
725 : : OSL_FAIL( "Wrong type in Transparency Any" );
726 : : }
727 : 0 : }
728 : : }
729 : 0 : break;
730 : :
731 : : // hack, because QueryValue of XFillTransparenceItem returns sal_Int32
732 : : // instead of sal_Int16
733 : : case XATTR_FILLTRANSPARENCE:
734 [ # # ]: 0 : if( lcl_supportsFillProperties( m_eGraphicObjectType ))
735 : : {
736 : : ::rtl::OUString aPropName =
737 : : (m_eGraphicObjectType == FILLED_DATA_POINT)
738 : : ? C2U( "Transparency" )
739 [ # # ][ # # ]: 0 : : C2U( "FillTransparence" );
[ # # ]
740 : :
741 : : const XFillTransparenceItem & rItem =
742 : : static_cast< const XFillTransparenceItem & >(
743 [ # # ]: 0 : rItemSet.Get( nWhichId ));
744 : :
745 [ # # ][ # # ]: 0 : if( rItem.QueryValue( aValue ))
746 : : {
747 : : OSL_ENSURE( ! aValue.isExtractableTo(
748 : : ::getCppuType( reinterpret_cast< const sal_Int16 * >(0))),
749 : : "TransparenceItem QueryValue bug is fixed. Remove hack." );
750 : 0 : sal_Int32 nValue = 0;
751 [ # # ]: 0 : if( aValue >>= nValue )
752 : : {
753 : : OSL_ENSURE( nValue < SAL_MAX_INT16, "Transparency value too large" );
754 : 0 : sal_Int16 nValueToSet( static_cast< sal_Int16 >( nValue ));
755 [ # # ]: 0 : aValue <<= nValueToSet;
756 : :
757 [ # # ][ # # ]: 0 : GetPropertySet()->setPropertyValue( aPropName, aValue );
[ # # ]
758 : : // if linear or no transparence is set, delete the gradient
759 : : ::rtl::OUString aTransGradPropName =
760 : : (m_eGraphicObjectType == FILLED_DATA_POINT)
761 : : ? C2U( "TransparencyGradientName" )
762 [ # # ][ # # ]: 0 : : C2U( "FillTransparenceGradientName" );
[ # # ]
763 [ # # ][ # # ]: 0 : GetPropertySet()->setPropertyValue(
764 [ # # ][ # # ]: 0 : aTransGradPropName, uno::makeAny( ::rtl::OUString() ));
765 : :
766 : 0 : bChanged = true;
767 : : }
768 : : else
769 : : {
770 : : OSL_FAIL( "Wrong type in Transparency Any" );
771 : : }
772 : 0 : }
773 : : }
774 : 0 : break;
775 : : }
776 : :
777 : 0 : return bChanged;
778 : : }
779 : :
780 : : } // namespace wrapper
781 : : } // namespace chart
782 : :
783 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|