1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_chart2.hxx"
26 #include "PropertyMapper.hxx"
27 #include "ContainerHelper.hxx"
28 #include "macros.hxx"
29 
30 #include <com/sun/star/beans/XMultiPropertySet.hpp>
31 #include <com/sun/star/drawing/LineStyle.hpp>
32 #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
33 #include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
34 #include <com/sun/star/drawing/LineJoint.hpp>
35 
36 //.............................................................................
37 namespace chart
38 {
39 //.............................................................................
40 using namespace ::com::sun::star;
41 
42 namespace
43 {
44 
lcl_overwriteOrAppendValues(tPropertyNameValueMap & rMap,const tPropertyNameValueMap & rOverwriteMap)45 void lcl_overwriteOrAppendValues(
46     tPropertyNameValueMap &rMap, const tPropertyNameValueMap& rOverwriteMap )
47 {
48     tPropertyNameValueMap::const_iterator aIt( rOverwriteMap.begin() );
49     tPropertyNameValueMap::const_iterator aEnd( rOverwriteMap.end() );
50 
51     for( ; aIt != aEnd; ++aIt )
52         rMap[ aIt->first ] = aIt->second;
53 }
54 
55 } // anonymous namespace
56 
setMappedProperties(const uno::Reference<beans::XPropertySet> & xTarget,const uno::Reference<beans::XPropertySet> & xSource,const tPropertyNameMap & rMap,tPropertyNameValueMap * pOverwriteMap)57 void PropertyMapper::setMappedProperties(
58           const uno::Reference< beans::XPropertySet >& xTarget
59         , const uno::Reference< beans::XPropertySet >& xSource
60         , const tPropertyNameMap& rMap
61         , tPropertyNameValueMap* pOverwriteMap )
62 {
63     if( !xTarget.is() || !xSource.is() )
64         return;
65 
66     tNameSequence aNames;
67     tAnySequence  aValues;
68     getMultiPropertyLists(aNames, aValues, xSource, rMap );
69     if(pOverwriteMap && (aNames.getLength() == aValues.getLength()))
70     {
71         tPropertyNameValueMap aNewMap;
72         for( sal_Int32 nI=0; nI<aNames.getLength(); ++nI )
73             aNewMap[ aNames[nI] ] = aValues[nI];
74         lcl_overwriteOrAppendValues( aNewMap, *pOverwriteMap );
75         aNames = ContainerHelper::MapKeysToSequence( aNewMap );
76         aValues = ContainerHelper::MapValuesToSequence( aNewMap );
77     }
78 
79     PropertyMapper::setMultiProperties( aNames, aValues, xTarget );
80 }
81 
getValueMap(tPropertyNameValueMap & rValueMap,const tPropertyNameMap & rNameMap,const uno::Reference<beans::XPropertySet> & xSourceProp)82 void PropertyMapper::getValueMap(
83                   tPropertyNameValueMap& rValueMap
84                 , const tPropertyNameMap& rNameMap
85                 , const uno::Reference< beans::XPropertySet >& xSourceProp
86                 )
87 {
88     tPropertyNameMap::const_iterator aIt( rNameMap.begin() );
89     tPropertyNameMap::const_iterator aEnd( rNameMap.end() );
90 
91     for( ; aIt != aEnd; ++aIt )
92     {
93         rtl::OUString aTarget = aIt->first;
94         rtl::OUString aSource = aIt->second;
95         try
96         {
97             uno::Any aAny( xSourceProp->getPropertyValue(aSource) );
98             if( aAny.hasValue() )
99                 rValueMap.insert( tPropertyNameValueMap::value_type( aTarget, aAny ) );
100         }
101         catch( uno::Exception& e )
102 	    {
103             ASSERT_EXCEPTION( e );
104         }
105     }
106 }
107 
getMultiPropertyLists(tNameSequence & rNames,tAnySequence & rValues,const uno::Reference<beans::XPropertySet> & xSourceProp,const tPropertyNameMap & rNameMap)108 void PropertyMapper::getMultiPropertyLists(
109                   tNameSequence& rNames
110                 , tAnySequence&  rValues
111                 , const uno::Reference< beans::XPropertySet >& xSourceProp
112                 , const tPropertyNameMap& rNameMap
113                 )
114 {
115     tPropertyNameValueMap aValueMap;
116     getValueMap( aValueMap, rNameMap, xSourceProp );
117     getMultiPropertyListsFromValueMap( rNames, rValues, aValueMap );
118 }
119 
getMultiPropertyListsFromValueMap(tNameSequence & rNames,tAnySequence & rValues,const tPropertyNameValueMap & rValueMap)120 void PropertyMapper::getMultiPropertyListsFromValueMap(
121                   tNameSequence& rNames
122                 , tAnySequence&  rValues
123                 , const tPropertyNameValueMap& rValueMap
124                 )
125 {
126     sal_Int32 nPropertyCount = rValueMap.size();
127     rNames.realloc(nPropertyCount);
128     rValues.realloc(nPropertyCount);
129 
130     //fill sequences
131     tPropertyNameValueMap::const_iterator aValueIt(  rValueMap.begin() );
132     tPropertyNameValueMap::const_iterator aValueEnd( rValueMap.end()   );
133     sal_Int32 nN=0;
134     for( ; aValueIt != aValueEnd; ++aValueIt )
135     {
136         const uno::Any& rAny = aValueIt->second;
137         if( rAny.hasValue() )
138         {
139             //do not set empty anys because of performance (otherwise SdrAttrObj::ItemChange will take much longer)
140             rNames[nN]  = aValueIt->first;
141             rValues[nN] = rAny;
142             ++nN;
143         }
144     }
145     //reduce to real property count
146     rNames.realloc(nN);
147     rValues.realloc(nN);
148 }
149 
getValuePointer(tAnySequence & rPropValues,const tNameSequence & rPropNames,const rtl::OUString & rPropName)150 uno::Any* PropertyMapper::getValuePointer( tAnySequence& rPropValues
151                          , const tNameSequence& rPropNames
152                          , const rtl::OUString& rPropName )
153 {
154     sal_Int32 nCount = rPropNames.getLength();
155     for( sal_Int32 nN = 0; nN < nCount; nN++ )
156     {
157         if(rPropNames[nN].equals(rPropName))
158             return &rPropValues[nN];
159     }
160     return NULL;
161 }
162 
getValuePointerForLimitedSpace(tAnySequence & rPropValues,const tNameSequence & rPropNames,bool bLimitedHeight)163 uno::Any* PropertyMapper::getValuePointerForLimitedSpace( tAnySequence& rPropValues
164                          , const tNameSequence& rPropNames
165                          , bool bLimitedHeight)
166 {
167     return PropertyMapper::getValuePointer( rPropValues, rPropNames
168         , bLimitedHeight ? C2U("TextMaximumFrameHeight") : C2U("TextMaximumFrameWidth") );
169 }
170 
171 /*
172 //set some properties from service style::CharacterProperties:
173 //-------- tabpage: Zeichen -----------
174 //Schriftart z.B. Albany            UNO_NAME_EDIT_CHAR_FONTNAME == UNO_NAME_EDIT_CHAR_FONTSTYLENAME    //UNO_NAME_CHAR_FONT
175 //Schriftschnitt z.B. kursiv        UNO_NAME_EDIT_CHAR_POSTURE    UNO_NAME_CHAR_POSTURE awt::FontSlant NONE OBLIQUE ITALIC DONTKNOW REVERSE_OBLIQUE REVERSE_ITALIC
176 //Schriftgrad (Punktgr�sse z.B. 12) UNO_NAME_EDIT_CHAR_HEIGHT == UNO_NAME_CHAR_HEIGHT
177         //? UNO_NAME_EDIT_CHAR_WEIGHT == UNO_NAME_CHAR_WEIGHT
178 //Sprache                           UNO_NAME_EDIT_CHAR_LOCALE lang::Locale
179 
180 //-------- tabpage: Schrifteffekt -----------
181 //Unterstreichung                   UNO_NAME_CHAR_UNDERLINE sal_Int16 awt::FontUnderline_NONE _SINGLE _DOUBLE _DOTTED _DONTKNOW _DASH ...
182 //Unterstreichung-farbe             ??? 'CharUnderlineColor' + CharUnderlineHasColor
183 //Durchstreichung z.B. doppelt      "CharStrikeout" sal_Int16 awt::FontStrikeout_NONE _SINGLE _DOUBLE ...
184 //wortweise-Durchstreichung ja/nein "CharWordMode" bool
185 //Schriftfarbe                      UNO_NAME_EDIT_CHAR_COLOR sal_Int32      UNO_NAME_CHAR_COLOR
186 //ReliefArt ohne/erhaben/tief       "CharRelief" sal_Int16 text::FontRelief_NONE FontRelief_EMBOSSED FontRelief_ENGRAVED
187 //Kontur                            "CharContoured" bool
188 //Schatten                          UNO_NAME_CHAR_SHADOWED bool
189 */
190 
getPropertyNameMapForCharacterProperties()191 const tMakePropertyNameMap& PropertyMapper::getPropertyNameMapForCharacterProperties()
192 {
193     //shape property -- chart model object property
194     static tMakePropertyNameMap m_aShapePropertyMapForCharacterProperties =
195         tMakePropertyNameMap
196 //      ( C2U( "CharBackColor" ),           C2U("TextBackgroundColor") )
197 //      ( C2U( "CharCaseMap" ),             C2U("CaseMapping") )
198         ( C2U( "CharColor" ),               C2U("CharColor") )
199         ( C2U( "CharContoured" ),           C2U("CharContoured") )
200 /////// ( C2U( "CharCrossedOut" ),          C2U("CharCrossedOut") ) //setting this explicitly somehow conflicts with CharStrikeout
201         ( C2U( "CharEmphasis" ),            C2U("CharEmphasis") )//the service style::CharacterProperties  describes a property called 'CharEmphasize' wich is nowhere implemented
202 //        ( C2U( "CharEscapement" ),          C2U("CharEscapement") ) //#i98344# @future: add these to properties again, if the user interface offers the possibility to change them; then make sure that older wrong files are corrected on import
203 //        ( C2U( "CharEscapementHeight" ),    C2U("CharEscapementHeight") ) //#i98344# @future: add these to properties again, if the user interface offers the possibility to change them; then make sure that older wrong files are corrected on import
204 //      ( C2U( "CharFlash" ),               C2U("Flashing") )
205 
206         ( C2U( "CharFontFamily" ),          C2U("CharFontFamily") )
207         ( C2U( "CharFontFamilyAsian" ),     C2U("CharFontFamilyAsian") )
208         ( C2U( "CharFontFamilyComplex" ),   C2U("CharFontFamilyComplex") )
209         ( C2U( "CharFontCharSet" ),         C2U("CharFontCharSet") )
210         ( C2U( "CharFontCharSetAsian" ),    C2U("CharFontCharSetAsian") )
211         ( C2U( "CharFontCharSetComplex" ),  C2U("CharFontCharSetComplex") )
212         ( C2U( "CharFontName" ),            C2U("CharFontName") )
213         ( C2U( "CharFontNameAsian" ),       C2U("CharFontNameAsian") )
214         ( C2U( "CharFontNameComplex" ),     C2U("CharFontNameComplex") )
215         ( C2U( "CharFontPitch" ),           C2U("CharFontPitch") )
216         ( C2U( "CharFontPitchAsian" ),      C2U("CharFontPitchAsian") )
217         ( C2U( "CharFontPitchComplex" ),    C2U("CharFontPitchComplex") )
218         ( C2U( "CharFontStyleName" ),       C2U("CharFontStyleName") )
219         ( C2U( "CharFontStyleNameAsian" ),  C2U("CharFontStyleNameAsian") )
220         ( C2U( "CharFontStyleNameComplex" ),C2U("CharFontStyleNameComplex") )
221 
222         ( C2U( "CharHeight" ),              C2U("CharHeight") )
223         ( C2U( "CharHeightAsian" ),         C2U("CharHeightAsian") )
224         ( C2U( "CharHeightComplex" ),       C2U("CharHeightComplex") )
225         ( C2U( "CharKerning" ),             C2U("CharKerning") )
226         ( C2U( "CharLocale" ),              C2U("CharLocale") )
227         ( C2U( "CharLocaleAsian" ),         C2U("CharLocaleAsian") )
228         ( C2U( "CharLocaleComplex" ),       C2U("CharLocaleComplex") )
229 //      ( C2U( "CharNoHyphenation" ),       C2U("InhibitHyphenation") )
230         ( C2U( "CharPosture" ),             C2U("CharPosture") )
231         ( C2U( "CharPostureAsian" ),        C2U("CharPostureAsian") )
232         ( C2U( "CharPostureComplex" ),      C2U("CharPostureComplex") )
233         ( C2U( "CharRelief" ),              C2U("CharRelief") )
234 //      ( C2U( "CharRotation" ),            C2U("Rotation") ) --> additional feature ...
235 //      ( C2U( "CharScaleWidth" ),          C2U("CharScaleWidth") )
236         ( C2U( "CharShadowed" ),            C2U("CharShadowed") )
237         ( C2U( "CharStrikeout" ),           C2U("CharStrikeout") )
238         ( C2U( "CharUnderline" ),           C2U("CharUnderline") )
239         ( C2U( "CharUnderlineColor" ),      C2U("CharUnderlineColor") )
240         ( C2U( "CharUnderlineHasColor" ),   C2U("CharUnderlineHasColor") )
241         ( C2U( "CharOverline" ),            C2U("CharOverline") )
242         ( C2U( "CharOverlineColor" ),       C2U("CharOverlineColor") )
243         ( C2U( "CharOverlineHasColor" ),    C2U("CharOverlineHasColor") )
244         ( C2U( "CharWeight" ),              C2U("CharWeight") )
245         ( C2U( "CharWeightAsian" ),         C2U("CharWeightAsian") )
246         ( C2U( "CharWeightComplex" ),       C2U("CharWeightComplex") )
247         ( C2U( "CharWordMode" ),            C2U("CharWordMode") )
248 
249         ( C2U( "WritingMode" ),             C2U("WritingMode") )
250 
251 //      ( C2U( "RubyText" ),                C2U("RubyText") )
252 //      ( C2U( "RubyAdjust" ),              C2U("RubyAdjust") )
253 //      ( C2U( "RubyCharStyleName" ),       C2U("RubyStyleName") )
254 //      ( C2U( "RubyIsAbove" ),             C2U("RubyIsAbove") )
255         ( C2U( "ParaIsCharacterDistance" ), C2U("ParaIsCharacterDistance") )
256         ;
257     return m_aShapePropertyMapForCharacterProperties;
258 }
259 
getPropertyNameMapForParagraphProperties()260 const tMakePropertyNameMap& PropertyMapper::getPropertyNameMapForParagraphProperties()
261 {
262     //shape property -- chart model object property
263     static tMakePropertyNameMap m_aShapePropertyMapForParagraphProperties =
264         tMakePropertyNameMap
265         ( C2U( "ParaAdjust" ),          C2U("ParaAdjust") )
266         ( C2U( "ParaBottomMargin" ),    C2U("ParaBottomMargin") )
267         ( C2U( "ParaIsHyphenation" ),   C2U("ParaIsHyphenation") )
268         ( C2U( "ParaLastLineAdjust" ),  C2U("ParaLastLineAdjust") )
269         ( C2U( "ParaLeftMargin" ),      C2U("ParaLeftMargin") )
270         ( C2U( "ParaRightMargin" ),     C2U("ParaRightMargin") )
271         ( C2U( "ParaTopMargin" ),       C2U("ParaTopMargin") )
272         ;
273     return m_aShapePropertyMapForParagraphProperties;
274 }
275 
getPropertyNameMapForFillProperties()276 const tMakePropertyNameMap& PropertyMapper::getPropertyNameMapForFillProperties()
277 {
278     //shape property -- chart model object property
279     static tMakePropertyNameMap m_aShapePropertyMapForFillProperties =
280         tMakePropertyNameMap
281         ( C2U( "FillBackground" ),        C2U( "FillBackground" ) )
282         ( C2U( "FillBitmapName" ),        C2U( "FillBitmapName" ) )
283         ( C2U( "FillColor" ),             C2U( "FillColor" ) )
284         ( C2U( "FillGradientName" ),      C2U( "FillGradientName" ) )
285         ( C2U( "FillGradientStepCount" ), C2U( "FillGradientStepCount" ) )
286         ( C2U( "FillHatchName" ),         C2U( "FillHatchName" ) )
287         ( C2U( "FillStyle" ),             C2U( "FillStyle" ) )
288         ( C2U( "FillTransparence" ),      C2U( "FillTransparence" ) )
289         ( C2U( "FillTransparenceGradientName" ), C2U("FillTransparenceGradientName") )
290         //bitmap properties
291         ( C2U( "FillBitmapMode" ),        C2U( "FillBitmapMode" ) )
292         ( C2U( "FillBitmapSizeX" ),       C2U( "FillBitmapSizeX" ) )
293         ( C2U( "FillBitmapSizeY" ),       C2U( "FillBitmapSizeY" ) )
294         ( C2U( "FillBitmapLogicalSize" ), C2U( "FillBitmapLogicalSize" ) )
295         ( C2U( "FillBitmapOffsetX" ),     C2U( "FillBitmapOffsetX" ) )
296         ( C2U( "FillBitmapOffsetY" ),     C2U( "FillBitmapOffsetY" ) )
297         ( C2U( "FillBitmapRectanglePoint" ),C2U( "FillBitmapRectanglePoint" ) )
298         ( C2U( "FillBitmapPositionOffsetX" ),C2U( "FillBitmapPositionOffsetX" ) )
299         ( C2U( "FillBitmapPositionOffsetY" ),C2U( "FillBitmapPositionOffsetY" ) )
300         ;
301     return m_aShapePropertyMapForFillProperties;
302 }
303 
getPropertyNameMapForLineProperties()304 const tMakePropertyNameMap& PropertyMapper::getPropertyNameMapForLineProperties()
305 {
306     //shape property -- chart model object property
307     static tMakePropertyNameMap m_aShapePropertyMapForLineProperties =
308         tMakePropertyNameMap
309         ( C2U( "LineColor" ),             C2U( "LineColor" ) )
310         ( C2U( "LineDashName" ),          C2U( "LineDashName" ) )
311         ( C2U( "LineJoint" ),             C2U( "LineJoint" ) )
312         ( C2U( "LineStyle" ),             C2U( "LineStyle" ) )
313         ( C2U( "LineTransparence" ),      C2U( "LineTransparence" ) )
314         ( C2U( "LineWidth" ),             C2U( "LineWidth" ) )
315         ;
316     return m_aShapePropertyMapForLineProperties;
317 }
318 
getPropertyNameMapForFillAndLineProperties()319 const tMakePropertyNameMap& PropertyMapper::getPropertyNameMapForFillAndLineProperties()
320 {
321     static tMakePropertyNameMap m_aShapePropertyMapForFillAndLineProperties =
322         tMakePropertyNameMap
323         ( PropertyMapper::getPropertyNameMapForFillProperties() )
324         ( PropertyMapper::getPropertyNameMapForLineProperties() )
325         ;
326 
327     return m_aShapePropertyMapForFillAndLineProperties;
328 }
329 
getPropertyNameMapForTextShapeProperties()330 const tMakePropertyNameMap& PropertyMapper::getPropertyNameMapForTextShapeProperties()
331 {
332     static tMakePropertyNameMap m_aShapePropertyMapForTextShapeProperties =
333         tMakePropertyNameMap
334         ( PropertyMapper::getPropertyNameMapForCharacterProperties() )
335         ( PropertyMapper::getPropertyNameMapForFillProperties() )
336         ( PropertyMapper::getPropertyNameMapForLineProperties() )
337 //         ( PropertyMapper::getPropertyNameMapForParagraphProperties() )
338         // some text properties
339 //         ( C2U( "TextHorizontalAdjust" ),   C2U( "TextHorizontalAdjust" ) )
340 //         ( C2U( "TextVerticalAdjust" ),     C2U( "TextVerticalAdjust" ) )
341 //         ( C2U( "TextAutoGrowHeight" ),     C2U( "TextAutoGrowHeight" ) )
342 //         ( C2U( "TextAutoGrowWidth" ),      C2U( "TextAutoGrowWidth" ) )
343 //         ( C2U( "TextLeftDistance" ),       C2U( "TextLeftDistance" ) )
344 //         ( C2U( "TextRightDistance" ),      C2U( "TextRightDistance" ) )
345 //         ( C2U( "TextUpperDistance" ),      C2U( "TextUpperDistance" ) )
346 //         ( C2U( "TextLowerDistance" ),      C2U( "TextLowerDistance" ) )
347         ;
348 
349     return m_aShapePropertyMapForTextShapeProperties;
350 }
351 
getPropertyNameMapForLineSeriesProperties()352 const tMakePropertyNameMap& PropertyMapper::getPropertyNameMapForLineSeriesProperties()
353 {
354     //shape property -- chart model object property
355     static tMakePropertyNameMap m_aShapePropertyMapForLineSeriesProperties =
356         tMakePropertyNameMap
357         ( C2U( "LineColor" ),           C2U("Color") )
358         ( C2U( "LineDashName" ),        C2U("LineDashName") )
359 //      ( C2U( "LineJoint" ),           C2U("LineJoint") )
360         ( C2U( "LineStyle" ),           C2U("LineStyle") )
361         ( C2U( "LineTransparence" ),    C2U("Transparency") )
362         ( C2U( "LineWidth" ),           C2U("LineWidth") )
363 
364         ;
365     return m_aShapePropertyMapForLineSeriesProperties;
366 }
367 
getPropertyNameMapForFilledSeriesProperties()368 const tMakePropertyNameMap& PropertyMapper::getPropertyNameMapForFilledSeriesProperties()
369 {
370     //shape property -- chart model object property
371     static tMakePropertyNameMap m_aShapePropertyMapForFilledSeriesProperties =
372         tMakePropertyNameMap
373         ( C2U( "FillBackground"),       C2U("FillBackground") )
374         ( C2U( "FillBitmapName" ),      C2U("FillBitmapName") )
375         ( C2U( "FillColor" ),           C2U("Color") )
376         ( C2U( "FillGradientName" ),    C2U("GradientName") )
377         ( C2U( "FillGradientStepCount" ), C2U( "GradientStepCount" ) )
378         ( C2U( "FillHatchName" ),       C2U("HatchName") )
379         ( C2U( "FillStyle" ),           C2U("FillStyle") )
380         ( C2U( "FillTransparence" ),    C2U("Transparency") )
381         ( C2U( "FillTransparenceGradientName" ), C2U("TransparencyGradientName") )
382         //bitmap properties
383         ( C2U( "FillBitmapMode" ),        C2U( "FillBitmapMode" ) )
384         ( C2U( "FillBitmapSizeX" ),       C2U( "FillBitmapSizeX" ) )
385         ( C2U( "FillBitmapSizeY" ),       C2U( "FillBitmapSizeY" ) )
386         ( C2U( "FillBitmapLogicalSize" ), C2U( "FillBitmapLogicalSize" ) )
387         ( C2U( "FillBitmapOffsetX" ),     C2U( "FillBitmapOffsetX" ) )
388         ( C2U( "FillBitmapOffsetY" ),     C2U( "FillBitmapOffsetY" ) )
389         ( C2U( "FillBitmapRectanglePoint" ),C2U( "FillBitmapRectanglePoint" ) )
390         ( C2U( "FillBitmapPositionOffsetX" ),C2U( "FillBitmapPositionOffsetX" ) )
391         ( C2U( "FillBitmapPositionOffsetY" ),C2U( "FillBitmapPositionOffsetY" ) )
392         //line properties
393         ( C2U( "LineColor" ),           C2U("BorderColor") )
394         ( C2U( "LineDashName" ),        C2U("BorderDashName") )
395 //      ( C2U( "LineJoint" ),           C2U("LineJoint") )
396         ( C2U( "LineStyle" ),           C2U("BorderStyle") )
397         ( C2U( "LineTransparence" ),    C2U("BorderTransparency") )
398         ( C2U( "LineWidth" ),           C2U("BorderWidth") )
399         ;
400     return m_aShapePropertyMapForFilledSeriesProperties;
401 }
402 
setMultiProperties(const tNameSequence & rNames,const tAnySequence & rValues,const::com::sun::star::uno::Reference<::com::sun::star::beans::XPropertySet> & xTarget)403 void PropertyMapper::setMultiProperties(
404                   const tNameSequence& rNames
405                 , const tAnySequence&  rValues
406                 , const ::com::sun::star::uno::Reference<
407                   ::com::sun::star::beans::XPropertySet >& xTarget )
408 {
409     bool bSuccess = false;
410     try
411 	{
412         uno::Reference< beans::XMultiPropertySet > xShapeMultiProp( xTarget, uno::UNO_QUERY );
413         if( xShapeMultiProp.is() )
414 	    {
415             xShapeMultiProp->setPropertyValues( rNames, rValues );
416             bSuccess = true;
417         }
418     }
419     catch( uno::Exception& e )
420     {
421         ASSERT_EXCEPTION( e ); //if this occurs more often think of removing the XMultiPropertySet completly for better performance
422     }
423 
424     if(!bSuccess)
425     try
426 	{
427         sal_Int32 nCount = std::max( rNames.getLength(), rValues.getLength() );
428         rtl::OUString aPropName;
429         uno::Any aValue;
430         for( sal_Int32 nN = 0; nN < nCount; nN++ )
431         {
432             aPropName = rNames[nN];
433             aValue = rValues[nN];
434 
435             try
436 	        {
437                 xTarget->setPropertyValue( aPropName, aValue );
438             }
439             catch( uno::Exception& e )
440             {
441                 ASSERT_EXCEPTION( e );
442             }
443         }
444     }
445     catch( uno::Exception& e )
446     {
447         ASSERT_EXCEPTION( e );
448     }
449 }
450 
getTextLabelMultiPropertyLists(const uno::Reference<beans::XPropertySet> & xSourceProp,tNameSequence & rPropNames,tAnySequence & rPropValues,bool bName,sal_Int32 nLimitedSpace,bool bLimitedHeight)451 void PropertyMapper::getTextLabelMultiPropertyLists(
452     const uno::Reference< beans::XPropertySet >& xSourceProp
453     , tNameSequence& rPropNames, tAnySequence& rPropValues
454     , bool bName
455     , sal_Int32 nLimitedSpace
456     , bool bLimitedHeight )
457 {
458     //fill character properties into the ValueMap
459     tPropertyNameValueMap aValueMap;
460     PropertyMapper::getValueMap( aValueMap
461             , PropertyMapper::getPropertyNameMapForCharacterProperties()
462             , xSourceProp );
463 
464     //some more shape properties apart from character properties, position-matrix and label string
465     aValueMap.insert( tPropertyNameValueMap::value_type( C2U("LineStyle"), uno::makeAny(drawing::LineStyle_NONE) ) ); // drawing::LineStyle
466     aValueMap.insert( tPropertyNameValueMap::value_type( C2U("TextHorizontalAdjust"), uno::makeAny(drawing::TextHorizontalAdjust_CENTER) ) ); // drawing::TextHorizontalAdjust - needs to be overwritten
467     aValueMap.insert( tPropertyNameValueMap::value_type( C2U("TextVerticalAdjust"), uno::makeAny(drawing::TextVerticalAdjust_CENTER) ) ); //drawing::TextVerticalAdjust - needs to be overwritten
468     //aValueMap.insert( tPropertyNameValueMap::value_type( C2U("TextWritingMode"), uno::makeAny(eWritingMode) ) ); //text::WritingMode
469     aValueMap.insert( tPropertyNameValueMap::value_type( C2U("TextAutoGrowHeight"), uno::makeAny(sal_True) ) ); // sal_Bool
470     aValueMap.insert( tPropertyNameValueMap::value_type( C2U("TextAutoGrowWidth"), uno::makeAny(sal_True) ) ); // sal_Bool
471     if( bName )
472         aValueMap.insert( tPropertyNameValueMap::value_type( C2U("Name"), uno::makeAny( rtl::OUString() ) ) ); //CID rtl::OUString - needs to be overwritten for each point
473 
474     if( nLimitedSpace > 0 )
475     {
476         if(bLimitedHeight)
477             aValueMap.insert( tPropertyNameValueMap::value_type( C2U("TextMaximumFrameHeight"), uno::makeAny(nLimitedSpace) ) ); //sal_Int32
478         else
479             aValueMap.insert( tPropertyNameValueMap::value_type( C2U("TextMaximumFrameWidth"), uno::makeAny(nLimitedSpace) ) ); //sal_Int32
480         aValueMap.insert( tPropertyNameValueMap::value_type( C2U("ParaIsHyphenation"), uno::makeAny(sal_True) ) );
481     }
482 
483     /*
484     //@todo ?: add paragraph properties:
485     //(uno::makeAny(eParaAdjust)) //ParaAdjust - style::ParagraphAdjust
486     //(uno::makeAny( (sal_Bool)rAxisLabelProperties.bLineBreakAllowed )) //ParaIsHyphenation - sal_Bool
487     style::ParagraphAdjust eParaAdjust( style::ParagraphAdjust_LEFT );
488     if( eHorizontalAdjust == drawing::TextHorizontalAdjust_RIGHT )
489         eParaAdjust = style::ParagraphAdjust_RIGHT;
490     */
491 
492     PropertyMapper::getMultiPropertyListsFromValueMap( rPropNames, rPropValues, aValueMap );
493 }
494 
getPreparedTextShapePropertyLists(const uno::Reference<beans::XPropertySet> & xSourceProp,tNameSequence & rPropNames,tAnySequence & rPropValues)495 void PropertyMapper::getPreparedTextShapePropertyLists(
496     const uno::Reference< beans::XPropertySet >& xSourceProp
497     , tNameSequence& rPropNames, tAnySequence& rPropValues )
498 {
499     //fill character, line and fill properties into the ValueMap
500     tPropertyNameValueMap aValueMap;
501     PropertyMapper::getValueMap( aValueMap
502             , PropertyMapper::getPropertyNameMapForTextShapeProperties()
503             , xSourceProp );
504 
505     // auto-grow makes sure the shape has the correct size after setting text
506     aValueMap.insert( tPropertyNameValueMap::value_type( C2U("TextHorizontalAdjust"), uno::makeAny( drawing::TextHorizontalAdjust_CENTER )));
507     aValueMap.insert( tPropertyNameValueMap::value_type( C2U("TextVerticalAdjust"), uno::makeAny( drawing::TextVerticalAdjust_CENTER )));
508     aValueMap.insert( tPropertyNameValueMap::value_type( C2U("TextAutoGrowHeight"), uno::makeAny( true )));
509     aValueMap.insert( tPropertyNameValueMap::value_type( C2U("TextAutoGrowWidth"), uno::makeAny( true )));
510 
511     // set some distance to the border, in case it is shown
512     const sal_Int32 nWidthDist  = 250;
513     const sal_Int32 nHeightDist = 125;
514     aValueMap.insert( tPropertyNameValueMap::value_type( C2U("TextLeftDistance"),  uno::makeAny( nWidthDist )));
515     aValueMap.insert( tPropertyNameValueMap::value_type( C2U("TextRightDistance"), uno::makeAny( nWidthDist )));
516     aValueMap.insert( tPropertyNameValueMap::value_type( C2U("TextUpperDistance"), uno::makeAny( nHeightDist )));
517     aValueMap.insert( tPropertyNameValueMap::value_type( C2U("TextLowerDistance"), uno::makeAny( nHeightDist )));
518 
519     // use a line-joint showing the border of thick lines like two rectangles
520     // filled in between.
521     aValueMap[C2U("LineJoint")] <<= drawing::LineJoint_ROUND;
522 
523     PropertyMapper::getMultiPropertyListsFromValueMap( rPropNames, rPropValues, aValueMap );
524 }
525 
526 //.............................................................................
527 } //namespace chart
528 //.............................................................................
529