LibreOffice Module xmloff (master) 1
XMLChartStyleContext.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
21#include <xmloff/xmltoken.hxx>
23#include <xmloff/xmlnumfi.hxx>
24#include <xmloff/families.hxx>
25#include <xmloff/xmltypes.hxx>
26#include <xmloff/xmlimp.hxx>
27#include <xmloff/xmlimppr.hxx>
28
29#include <com/sun/star/beans/XPropertySet.hpp>
31
33
34using namespace com::sun::star;
41
42
44 sal_Int32 nElement,
45 const OUString& rValue )
46{
47 switch (nElement & TOKEN_MASK)
48 {
50 msDataStyleName = rValue;
51 break;
54 break;
55 default:
56 XMLShapeStyleContext::SetAttribute( nElement, rValue );
57 }
58}
59
61 SvXMLImport& rImport,
62 SvXMLStylesContext& rStyles, XmlStyleFamily nFamily ) :
63 XMLShapeStyleContext( rImport, rStyles, nFamily ),
64 mrStyles( rStyles )
65{}
66
68{}
69
70namespace
71{
72
73void lcl_NumberFormatStyleToProperty( const OUString& rStyleName, const OUString& rPropertyName,
74 const SvXMLStylesContext& rStylesContext,
75 const uno::Reference< beans::XPropertySet >& rPropSet )
76{
77 if( !rStyleName.isEmpty())
78 {
79 const SvXMLNumFormatContext* pStyle = static_cast<const SvXMLNumFormatContext *>(rStylesContext.FindStyleChildContext(
80 XmlStyleFamily::DATA_STYLE, rStyleName, true ));
81 if( pStyle )
82 {
83 sal_Int32 nNumberFormat = const_cast<SvXMLNumFormatContext*>(pStyle)->GetKey();
84 rPropSet->setPropertyValue( rPropertyName, uno::Any(nNumberFormat) );
85 }
86 }
87}
88
89}
90
92 const uno::Reference< beans::XPropertySet > & rPropSet )
93{
94 try
95 {
97 }
98 catch( beans::UnknownPropertyException& )
99 {
100 TOOLS_WARN_EXCEPTION( "xmloff", "unknown property exception -> shape style not completely imported for chart style" );
101 }
102
103 lcl_NumberFormatStyleToProperty( msDataStyleName, "NumberFormat", mrStyles, rPropSet );
104 lcl_NumberFormatStyleToProperty( msPercentageDataStyleName, "PercentageNumberFormat", mrStyles, rPropSet );
105}
106
107css::uno::Reference< css::xml::sax::XFastContextHandler > XMLChartStyleContext::createFastChildContext(
108 sal_Int32 nElement,
109 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
110{
113 {
114 sal_Int32 nLocalName = nElement & TOKEN_MASK;
115 sal_uInt32 nFamily = 0;
116 if( nLocalName == XML_TEXT_PROPERTIES )
117 nFamily = XML_TYPE_PROP_TEXT;
118 else if( nLocalName == XML_PARAGRAPH_PROPERTIES )
119 nFamily = XML_TYPE_PROP_PARAGRAPH;
120 else if( nLocalName == XML_GRAPHIC_PROPERTIES )
121 nFamily = XML_TYPE_PROP_GRAPHIC;
122 else if( nLocalName == XML_CHART_PROPERTIES )
123 nFamily = XML_TYPE_PROP_CHART;
124 if( nFamily )
125 {
128 if( xImpPrMap.is() )
129 return new XMLChartPropertyContext(
130 GetImport(), nElement, xAttrList, nFamily,
131 GetProperties(), xImpPrMap );
132 }
133 }
134
135 return XMLShapeStyleContext::createFastChildContext( nElement, xAttrList );
136}
137
138/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:60
XmlStyleFamily GetFamily() const
Definition: xmlstyle.hxx:85
const SvXMLStyleContext * FindStyleChildContext(XmlStyleFamily nFamily, const OUString &rName, bool bCreateIndex=false) const
Definition: xmlstyle.cxx:783
virtual rtl::Reference< SvXMLImportPropertyMapper > GetImportPropertyMapper(XmlStyleFamily nFamily) const
Definition: xmlstyle.cxx:522
SvXMLStylesContext & mrStyles
XMLChartStyleContext(SvXMLImport &rImport, SvXMLStylesContext &rStyles, XmlStyleFamily nFamily)
void FillPropertySet(const css::uno::Reference< css::beans::XPropertySet > &rPropSet) override
is called after all styles have been read to apply styles
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
necessary for property context (element-property symbol-image)
virtual ~XMLChartStyleContext() override
virtual void SetAttribute(sal_Int32 nElement, const OUString &rValue) override
is called when an attribute at the (auto)style element is found
::std::vector< XMLPropertyState > & GetProperties()
Definition: prstylei.hxx:79
SvXMLStylesContext * GetStyles()
Definition: prstylei.hxx:78
virtual void FillPropertySet(const css::uno::Reference< css::beans::XPropertySet > &rPropSet) override
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
virtual void SetAttribute(sal_Int32 nElement, const OUString &rValue) override
#define TOOLS_WARN_EXCEPTION(area, stream)
XmlStyleFamily
Definition: families.hxx:50
@ XML_PERCENTAGE_DATA_STYLE_NAME
Definition: xmltoken.hxx:3240
@ XML_PARAGRAPH_PROPERTIES
Definition: xmltoken.hxx:2634
@ XML_GRAPHIC_PROPERTIES
Definition: xmltoken.hxx:2629
constexpr bool IsTokenInNamespace(sal_Int32 nToken, sal_uInt16 nNamespacePrefix)
Definition: xmlimp.hxx:104
constexpr sal_Int32 TOKEN_MASK
Definition: xmlimp.hxx:94
constexpr sal_uInt16 XML_NAMESPACE_LO_EXT
constexpr sal_uInt16 XML_NAMESPACE_STYLE
#define XML_TYPE_PROP_GRAPHIC
Definition: xmltypes.hxx:94
#define XML_TYPE_PROP_CHART
Definition: xmltypes.hxx:107
#define XML_TYPE_PROP_PARAGRAPH
Definition: xmltypes.hxx:99
#define XML_TYPE_PROP_TEXT
Definition: xmltypes.hxx:98