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;
42
43
45 sal_Int32 nElement,
46 const OUString& rValue )
47{
48 switch (nElement & TOKEN_MASK)
49 {
51 msDataStyleName = rValue;
52 break;
55 break;
56 default:
57 XMLShapeStyleContext::SetAttribute( nElement, rValue );
58 }
59}
60
62 SvXMLImport& rImport,
63 SvXMLStylesContext& rStyles, XmlStyleFamily nFamily ) :
64 XMLShapeStyleContext( rImport, rStyles, nFamily ),
65 mrStyles( rStyles )
66{}
67
69{}
70
71namespace
72{
73
74void lcl_NumberFormatStyleToProperty( const OUString& rStyleName, const OUString& rPropertyName,
75 const SvXMLStylesContext& rStylesContext,
76 const uno::Reference< beans::XPropertySet >& rPropSet )
77{
78 if( !rStyleName.isEmpty())
79 {
80 const SvXMLNumFormatContext* pStyle = static_cast<const SvXMLNumFormatContext *>(rStylesContext.FindStyleChildContext(
81 XmlStyleFamily::DATA_STYLE, rStyleName, true ));
82 if( pStyle )
83 {
84 sal_Int32 nNumberFormat = const_cast<SvXMLNumFormatContext*>(pStyle)->GetKey();
85 rPropSet->setPropertyValue( rPropertyName, uno::Any(nNumberFormat) );
86 }
87 }
88}
89
90}
91
93 const uno::Reference< beans::XPropertySet > & rPropSet )
94{
95 try
96 {
98 }
99 catch( beans::UnknownPropertyException& )
100 {
101 TOOLS_WARN_EXCEPTION( "xmloff", "unknown property exception -> shape style not completely imported for chart style" );
102 }
103
104 lcl_NumberFormatStyleToProperty( msDataStyleName, "NumberFormat", mrStyles, rPropSet );
105 lcl_NumberFormatStyleToProperty( msPercentageDataStyleName, "PercentageNumberFormat", mrStyles, rPropSet );
106}
107
108css::uno::Reference< css::xml::sax::XFastContextHandler > XMLChartStyleContext::createFastChildContext(
109 sal_Int32 nElement,
110 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
111{
114 {
115 sal_Int32 nLocalName = nElement & TOKEN_MASK;
116 sal_uInt32 nFamily = 0;
117 if( nLocalName == XML_TEXT_PROPERTIES )
118 nFamily = XML_TYPE_PROP_TEXT;
119 else if( nLocalName == XML_PARAGRAPH_PROPERTIES )
120 nFamily = XML_TYPE_PROP_PARAGRAPH;
121 else if( nLocalName == XML_GRAPHIC_PROPERTIES )
122 nFamily = XML_TYPE_PROP_GRAPHIC;
123 else if( nLocalName == XML_CHART_PROPERTIES )
124 nFamily = XML_TYPE_PROP_CHART;
125 if( nFamily )
126 {
129 if( xImpPrMap.is() )
130 return new XMLChartPropertyContext(
131 GetImport(), nElement, xAttrList, nFamily,
132 GetProperties(), xImpPrMap );
133 }
134 }
135
136 return XMLShapeStyleContext::createFastChildContext( nElement, xAttrList );
137}
138
139/* 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:799
virtual rtl::Reference< SvXMLImportPropertyMapper > GetImportPropertyMapper(XmlStyleFamily nFamily) const
Definition: xmlstyle.cxx:518
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:3232
@ XML_PARAGRAPH_PROPERTIES
Definition: xmltoken.hxx:2627
@ XML_GRAPHIC_PROPERTIES
Definition: xmltoken.hxx:2622
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
compare eToken to the string
Definition: xmltoken.cxx:3581
constexpr bool IsTokenInNamespace(sal_Int32 nToken, sal_uInt16 nNamespacePrefix)
Definition: xmlimp.hxx:105
constexpr sal_Int32 TOKEN_MASK
Definition: xmlimp.hxx:95
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