update dev300-m58
[ooovba.git] / xmloff / source / chart / XMLChartStyleContext.cxx
blobc234c0e181c945d8e0bcf2f8d7cff9632babe3c9
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: XMLChartStyleContext.cxx,v $
10 * $Revision: 1.14 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
33 #include "XMLChartStyleContext.hxx"
34 #include <xmloff/xmltoken.hxx>
35 #include "xmlnmspe.hxx"
36 #include <xmloff/xmlnumfi.hxx>
37 #include <xmloff/families.hxx>
39 #include "XMLChartPropertyContext.hxx"
41 using namespace com::sun::star;
42 using ::xmloff::token::IsXMLToken;
43 using ::xmloff::token::XML_DATA_STYLE_NAME;
44 using ::xmloff::token::XML_PERCENTAGE_DATA_STYLE_NAME;
45 using ::xmloff::token::XML_TEXT_PROPERTIES;
46 using ::xmloff::token::XML_PARAGRAPH_PROPERTIES;
47 using ::xmloff::token::XML_GRAPHIC_PROPERTIES;
48 using ::xmloff::token::XML_CHART_PROPERTIES;
51 TYPEINIT1( XMLChartStyleContext, XMLPropStyleContext );
53 // protected
55 void XMLChartStyleContext::SetAttribute(
56 sal_uInt16 nPrefixKey,
57 const ::rtl::OUString& rLocalName,
58 const ::rtl::OUString& rValue )
60 if( IsXMLToken( rLocalName, XML_DATA_STYLE_NAME ) )
62 msDataStyleName =rValue;
64 else if( IsXMLToken( rLocalName, XML_PERCENTAGE_DATA_STYLE_NAME ) )
66 msPercentageDataStyleName =rValue;
68 else
70 XMLShapeStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
74 //public
76 // CTOR
77 XMLChartStyleContext::XMLChartStyleContext(
78 SvXMLImport& rImport, sal_uInt16 nPrfx,
79 const ::rtl::OUString& rLName,
80 const uno::Reference< xml::sax::XAttributeList > & xAttrList,
81 SvXMLStylesContext& rStyles, sal_uInt16 nFamily ) :
83 XMLShapeStyleContext( rImport, nPrfx, rLName, xAttrList, rStyles, nFamily ),
84 mrStyles( rStyles )
87 // DTOR
88 XMLChartStyleContext::~XMLChartStyleContext()
91 namespace
94 void lcl_NumberFormatStyleToProperty( const ::rtl::OUString& rStyleName, const ::rtl::OUString& rPropertyName,
95 const SvXMLStylesContext& rStylesContext,
96 const uno::Reference< beans::XPropertySet >& rPropSet )
98 if( rStyleName.getLength())
100 SvXMLNumFormatContext* pStyle = (SvXMLNumFormatContext *)rStylesContext.FindStyleChildContext(
101 XML_STYLE_FAMILY_DATA_STYLE, rStyleName, sal_True );
102 if( pStyle )
104 uno::Any aNumberFormat;
105 sal_Int32 nNumberFormat = pStyle->GetKey();
106 aNumberFormat <<= nNumberFormat;
107 rPropSet->setPropertyValue( rPropertyName, aNumberFormat );
112 }// anonymous namespace
114 void XMLChartStyleContext::FillPropertySet(
115 const uno::Reference< beans::XPropertySet > & rPropSet )
119 XMLShapeStyleContext::FillPropertySet( rPropSet );
121 catch( beans::UnknownPropertyException& )
123 DBG_ASSERT( false, "unknown property exception -> shape style not completly imported for chart style" );
126 lcl_NumberFormatStyleToProperty( msDataStyleName, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NumberFormat" )), mrStyles, rPropSet );
127 lcl_NumberFormatStyleToProperty( msPercentageDataStyleName, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PercentageNumberFormat" )), mrStyles, rPropSet );
130 SvXMLImportContext *XMLChartStyleContext::CreateChildContext(
131 sal_uInt16 nPrefix,
132 const ::rtl::OUString& rLocalName,
133 const uno::Reference< xml::sax::XAttributeList > & xAttrList )
135 SvXMLImportContext* pContext = NULL;
137 if( XML_NAMESPACE_STYLE == nPrefix )
139 sal_uInt32 nFamily = 0;
140 if( IsXMLToken( rLocalName, XML_TEXT_PROPERTIES ) )
141 nFamily = XML_TYPE_PROP_TEXT;
142 else if( IsXMLToken( rLocalName, XML_PARAGRAPH_PROPERTIES ) )
143 nFamily = XML_TYPE_PROP_PARAGRAPH;
144 else if( IsXMLToken( rLocalName, XML_GRAPHIC_PROPERTIES ) )
145 nFamily = XML_TYPE_PROP_GRAPHIC;
146 else if( IsXMLToken( rLocalName, XML_CHART_PROPERTIES ) )
147 nFamily = XML_TYPE_PROP_CHART;
148 if( nFamily )
150 UniReference < SvXMLImportPropertyMapper > xImpPrMap =
151 GetStyles()->GetImportPropertyMapper( GetFamily() );
152 if( xImpPrMap.is() )
153 pContext = new XMLChartPropertyContext(
154 GetImport(), nPrefix, rLocalName, xAttrList, nFamily,
155 GetProperties(), xImpPrMap );
159 if( !pContext )
160 pContext = XMLShapeStyleContext::CreateChildContext( nPrefix, rLocalName,
161 xAttrList );
163 return pContext;