163bba73cSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 363bba73cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 463bba73cSAndrew Rist * or more contributor license agreements. See the NOTICE file 563bba73cSAndrew Rist * distributed with this work for additional information 663bba73cSAndrew Rist * regarding copyright ownership. The ASF licenses this file 763bba73cSAndrew Rist * to you under the Apache License, Version 2.0 (the 863bba73cSAndrew Rist * "License"); you may not use this file except in compliance 963bba73cSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 1163bba73cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 1363bba73cSAndrew Rist * Unless required by applicable law or agreed to in writing, 1463bba73cSAndrew Rist * software distributed under the License is distributed on an 1563bba73cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 1663bba73cSAndrew Rist * KIND, either express or implied. See the License for the 1763bba73cSAndrew Rist * specific language governing permissions and limitations 1863bba73cSAndrew Rist * under the License. 19cdf0e10cSrcweir * 2063bba73cSAndrew Rist *************************************************************/ 2163bba73cSAndrew Rist 2263bba73cSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_xmloff.hxx" 26cdf0e10cSrcweir #include "XMLChartStyleContext.hxx" 27cdf0e10cSrcweir #include <xmloff/xmltoken.hxx> 28cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx" 29cdf0e10cSrcweir #include <xmloff/xmlnumfi.hxx> 30cdf0e10cSrcweir #include <xmloff/families.hxx> 31cdf0e10cSrcweir 32cdf0e10cSrcweir #include "XMLChartPropertyContext.hxx" 33cdf0e10cSrcweir 34cdf0e10cSrcweir using namespace com::sun::star; 35cdf0e10cSrcweir using ::xmloff::token::IsXMLToken; 36cdf0e10cSrcweir using ::xmloff::token::XML_DATA_STYLE_NAME; 37cdf0e10cSrcweir using ::xmloff::token::XML_PERCENTAGE_DATA_STYLE_NAME; 38cdf0e10cSrcweir using ::xmloff::token::XML_TEXT_PROPERTIES; 39cdf0e10cSrcweir using ::xmloff::token::XML_PARAGRAPH_PROPERTIES; 40cdf0e10cSrcweir using ::xmloff::token::XML_GRAPHIC_PROPERTIES; 41cdf0e10cSrcweir using ::xmloff::token::XML_CHART_PROPERTIES; 42cdf0e10cSrcweir 43cdf0e10cSrcweir 44cdf0e10cSrcweir TYPEINIT1( XMLChartStyleContext, XMLPropStyleContext ); 45cdf0e10cSrcweir 46cdf0e10cSrcweir // protected 47cdf0e10cSrcweir 48cdf0e10cSrcweir void XMLChartStyleContext::SetAttribute( 49cdf0e10cSrcweir sal_uInt16 nPrefixKey, 50cdf0e10cSrcweir const ::rtl::OUString& rLocalName, 51cdf0e10cSrcweir const ::rtl::OUString& rValue ) 52cdf0e10cSrcweir { 53cdf0e10cSrcweir if( IsXMLToken( rLocalName, XML_DATA_STYLE_NAME ) ) 54cdf0e10cSrcweir { 55cdf0e10cSrcweir msDataStyleName =rValue; 56cdf0e10cSrcweir } 57cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_PERCENTAGE_DATA_STYLE_NAME ) ) 58cdf0e10cSrcweir { 59cdf0e10cSrcweir msPercentageDataStyleName =rValue; 60cdf0e10cSrcweir } 61cdf0e10cSrcweir else 62cdf0e10cSrcweir { 63cdf0e10cSrcweir XMLShapeStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue ); 64cdf0e10cSrcweir } 65cdf0e10cSrcweir } 66cdf0e10cSrcweir 67cdf0e10cSrcweir //public 68cdf0e10cSrcweir 69cdf0e10cSrcweir // CTOR 70cdf0e10cSrcweir XMLChartStyleContext::XMLChartStyleContext( 71cdf0e10cSrcweir SvXMLImport& rImport, sal_uInt16 nPrfx, 72cdf0e10cSrcweir const ::rtl::OUString& rLName, 73cdf0e10cSrcweir const uno::Reference< xml::sax::XAttributeList > & xAttrList, 74cdf0e10cSrcweir SvXMLStylesContext& rStyles, sal_uInt16 nFamily ) : 75cdf0e10cSrcweir 76cdf0e10cSrcweir XMLShapeStyleContext( rImport, nPrfx, rLName, xAttrList, rStyles, nFamily ), 77cdf0e10cSrcweir mrStyles( rStyles ) 78cdf0e10cSrcweir {} 79cdf0e10cSrcweir 80cdf0e10cSrcweir // DTOR 81cdf0e10cSrcweir XMLChartStyleContext::~XMLChartStyleContext() 82cdf0e10cSrcweir {} 83cdf0e10cSrcweir 84cdf0e10cSrcweir namespace 85cdf0e10cSrcweir { 86cdf0e10cSrcweir 87cdf0e10cSrcweir void lcl_NumberFormatStyleToProperty( const ::rtl::OUString& rStyleName, const ::rtl::OUString& rPropertyName, 88cdf0e10cSrcweir const SvXMLStylesContext& rStylesContext, 89cdf0e10cSrcweir const uno::Reference< beans::XPropertySet >& rPropSet ) 90cdf0e10cSrcweir { 91cdf0e10cSrcweir if( rStyleName.getLength()) 92cdf0e10cSrcweir { 93cdf0e10cSrcweir SvXMLNumFormatContext* pStyle = (SvXMLNumFormatContext *)rStylesContext.FindStyleChildContext( 94cdf0e10cSrcweir XML_STYLE_FAMILY_DATA_STYLE, rStyleName, sal_True ); 95cdf0e10cSrcweir if( pStyle ) 96cdf0e10cSrcweir { 97cdf0e10cSrcweir uno::Any aNumberFormat; 98cdf0e10cSrcweir sal_Int32 nNumberFormat = pStyle->GetKey(); 99cdf0e10cSrcweir aNumberFormat <<= nNumberFormat; 100cdf0e10cSrcweir rPropSet->setPropertyValue( rPropertyName, aNumberFormat ); 101cdf0e10cSrcweir } 102cdf0e10cSrcweir } 103cdf0e10cSrcweir } 104cdf0e10cSrcweir 105cdf0e10cSrcweir }// anonymous namespace 106cdf0e10cSrcweir 107cdf0e10cSrcweir void XMLChartStyleContext::FillPropertySet( 108cdf0e10cSrcweir const uno::Reference< beans::XPropertySet > & rPropSet ) 109cdf0e10cSrcweir { 110cdf0e10cSrcweir try 111cdf0e10cSrcweir { 112cdf0e10cSrcweir XMLShapeStyleContext::FillPropertySet( rPropSet ); 113cdf0e10cSrcweir } 114cdf0e10cSrcweir catch( beans::UnknownPropertyException& ) 115cdf0e10cSrcweir { 116*30b58845Smseidel DBG_ASSERT( false, "unknown property exception -> shape style not completely imported for chart style" ); 117cdf0e10cSrcweir } 118cdf0e10cSrcweir 119cdf0e10cSrcweir lcl_NumberFormatStyleToProperty( msDataStyleName, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NumberFormat" )), mrStyles, rPropSet ); 120cdf0e10cSrcweir lcl_NumberFormatStyleToProperty( msPercentageDataStyleName, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PercentageNumberFormat" )), mrStyles, rPropSet ); 121cdf0e10cSrcweir } 122cdf0e10cSrcweir 123cdf0e10cSrcweir SvXMLImportContext *XMLChartStyleContext::CreateChildContext( 124cdf0e10cSrcweir sal_uInt16 nPrefix, 125cdf0e10cSrcweir const ::rtl::OUString& rLocalName, 126cdf0e10cSrcweir const uno::Reference< xml::sax::XAttributeList > & xAttrList ) 127cdf0e10cSrcweir { 128cdf0e10cSrcweir SvXMLImportContext* pContext = NULL; 129cdf0e10cSrcweir 130cdf0e10cSrcweir if( XML_NAMESPACE_STYLE == nPrefix ) 131cdf0e10cSrcweir { 132cdf0e10cSrcweir sal_uInt32 nFamily = 0; 133cdf0e10cSrcweir if( IsXMLToken( rLocalName, XML_TEXT_PROPERTIES ) ) 134cdf0e10cSrcweir nFamily = XML_TYPE_PROP_TEXT; 135cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_PARAGRAPH_PROPERTIES ) ) 136cdf0e10cSrcweir nFamily = XML_TYPE_PROP_PARAGRAPH; 137cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_GRAPHIC_PROPERTIES ) ) 138cdf0e10cSrcweir nFamily = XML_TYPE_PROP_GRAPHIC; 139cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_CHART_PROPERTIES ) ) 140cdf0e10cSrcweir nFamily = XML_TYPE_PROP_CHART; 141cdf0e10cSrcweir if( nFamily ) 142cdf0e10cSrcweir { 143cdf0e10cSrcweir UniReference < SvXMLImportPropertyMapper > xImpPrMap = 144cdf0e10cSrcweir GetStyles()->GetImportPropertyMapper( GetFamily() ); 145cdf0e10cSrcweir if( xImpPrMap.is() ) 146cdf0e10cSrcweir pContext = new XMLChartPropertyContext( 147cdf0e10cSrcweir GetImport(), nPrefix, rLocalName, xAttrList, nFamily, 148cdf0e10cSrcweir GetProperties(), xImpPrMap ); 149cdf0e10cSrcweir } 150cdf0e10cSrcweir } 151cdf0e10cSrcweir 152cdf0e10cSrcweir if( !pContext ) 153cdf0e10cSrcweir pContext = XMLShapeStyleContext::CreateChildContext( nPrefix, rLocalName, 154cdf0e10cSrcweir xAttrList ); 155cdf0e10cSrcweir 156cdf0e10cSrcweir return pContext; 157cdf0e10cSrcweir } 158