1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_xmloff.hxx"
30 #include "SchXMLAutoStylePoolP.hxx"
31 #include "PropertyMap.hxx"
32 #include "SchXMLExport.hxx"
33 #include "XMLChartPropertySetMapper.hxx"
34 #include <xmloff/families.hxx>
35 #include <xmloff/nmspmap.hxx>
36 #include <xmloff/xmltoken.hxx>
37 
38 using ::xmloff::token::GetXMLToken;
39 using ::xmloff::token::XML_CDATA;
40 
41 SchXMLAutoStylePoolP::SchXMLAutoStylePoolP( SchXMLExport& rSchXMLExport ) :
42         SvXMLAutoStylePoolP( rSchXMLExport ),
43 		mrSchXMLExport( rSchXMLExport )
44 {}
45 
46 SchXMLAutoStylePoolP::~SchXMLAutoStylePoolP()
47 {}
48 
49 void SchXMLAutoStylePoolP::exportStyleAttributes(
50 	SvXMLAttributeList& rAttrList,
51 	sal_Int32 nFamily,
52 	const ::std::vector< XMLPropertyState >& rProperties,
53 	const SvXMLExportPropertyMapper& rPropExp
54 	, const SvXMLUnitConverter& rUnitConverter,
55 	const SvXMLNamespaceMap& rNamespaceMap
56     ) const
57 {
58 	const rtl::OUString sCDATA( GetXMLToken( XML_CDATA ));
59 	SvXMLAutoStylePoolP::exportStyleAttributes( rAttrList, nFamily, rProperties,
60 												rPropExp, rUnitConverter, rNamespaceMap );
61 
62 	if( nFamily == XML_STYLE_FAMILY_SCH_CHART_ID )
63 	{
64 		for( ::std::vector< XMLPropertyState >::const_iterator iter = rProperties.begin();
65              (iter != rProperties.end()); iter++ )
66 		{
67 			if( iter->mnIndex == -1 )
68 				continue;
69 
70 			UniReference< XMLPropertySetMapper > aPropMapper =
71 				mrSchXMLExport.GetPropertySetMapper();
72 			sal_Int16 nContextID = aPropMapper->GetEntryContextId( iter->mnIndex );
73 			if( nContextID == XML_SCH_CONTEXT_SPECIAL_NUMBER_FORMAT )
74 			{
75 				sal_Int32 nNumberFormat = -1;
76 				if( ( iter->maValue >>= nNumberFormat ) &&
77                     ( nNumberFormat != -1 ))
78 				{
79 					rtl::OUString sAttrValue = mrSchXMLExport.getDataStyleName( nNumberFormat );
80 					if( sAttrValue.getLength() )
81 					{
82                         mrSchXMLExport.AddAttribute(
83                             aPropMapper->GetEntryNameSpace( iter->mnIndex ),
84 							aPropMapper->GetEntryXMLName( iter->mnIndex ),
85                             sAttrValue );
86 					}
87 				}
88 			}
89 		}
90 	}
91 }
92