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