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_xmloff.hxx"
26 #include "SchXMLAutoStylePoolP.hxx"
27 #include "PropertyMap.hxx"
28 #include "SchXMLExport.hxx"
29 #include "XMLChartPropertySetMapper.hxx"
30 #include <xmloff/families.hxx>
31 #include <xmloff/nmspmap.hxx>
32 #include <xmloff/xmltoken.hxx>
33 
34 using ::xmloff::token::GetXMLToken;
35 using ::xmloff::token::XML_CDATA;
36 
SchXMLAutoStylePoolP(SchXMLExport & rSchXMLExport)37 SchXMLAutoStylePoolP::SchXMLAutoStylePoolP( SchXMLExport& rSchXMLExport ) :
38         SvXMLAutoStylePoolP( rSchXMLExport ),
39 		mrSchXMLExport( rSchXMLExport )
40 {}
41 
~SchXMLAutoStylePoolP()42 SchXMLAutoStylePoolP::~SchXMLAutoStylePoolP()
43 {}
44 
exportStyleAttributes(SvXMLAttributeList & rAttrList,sal_Int32 nFamily,const::std::vector<XMLPropertyState> & rProperties,const SvXMLExportPropertyMapper & rPropExp,const SvXMLUnitConverter & rUnitConverter,const SvXMLNamespaceMap & rNamespaceMap) const45 void SchXMLAutoStylePoolP::exportStyleAttributes(
46 	SvXMLAttributeList& rAttrList,
47 	sal_Int32 nFamily,
48 	const ::std::vector< XMLPropertyState >& rProperties,
49 	const SvXMLExportPropertyMapper& rPropExp
50 	, const SvXMLUnitConverter& rUnitConverter,
51 	const SvXMLNamespaceMap& rNamespaceMap
52     ) const
53 {
54 	const rtl::OUString sCDATA( GetXMLToken( XML_CDATA ));
55 	SvXMLAutoStylePoolP::exportStyleAttributes( rAttrList, nFamily, rProperties,
56 												rPropExp, rUnitConverter, rNamespaceMap );
57 
58 	if( nFamily == XML_STYLE_FAMILY_SCH_CHART_ID )
59 	{
60 		for( ::std::vector< XMLPropertyState >::const_iterator iter = rProperties.begin();
61              (iter != rProperties.end()); iter++ )
62 		{
63 			if( iter->mnIndex == -1 )
64 				continue;
65 
66 			UniReference< XMLPropertySetMapper > aPropMapper =
67 				mrSchXMLExport.GetPropertySetMapper();
68 			sal_Int16 nContextID = aPropMapper->GetEntryContextId( iter->mnIndex );
69 			if( nContextID == XML_SCH_CONTEXT_SPECIAL_NUMBER_FORMAT )
70 			{
71 				sal_Int32 nNumberFormat = -1;
72 				if( ( iter->maValue >>= nNumberFormat ) &&
73                     ( nNumberFormat != -1 ))
74 				{
75 					rtl::OUString sAttrValue = mrSchXMLExport.getDataStyleName( nNumberFormat );
76 					if( sAttrValue.getLength() )
77 					{
78                         mrSchXMLExport.AddAttribute(
79                             aPropMapper->GetEntryNameSpace( iter->mnIndex ),
80 							aPropMapper->GetEntryXMLName( iter->mnIndex ),
81                             sAttrValue );
82 					}
83 				}
84 			}
85 		}
86 	}
87 }
88