1*63bba73cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*63bba73cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*63bba73cSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*63bba73cSAndrew Rist * distributed with this work for additional information
6*63bba73cSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*63bba73cSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*63bba73cSAndrew Rist * "License"); you may not use this file except in compliance
9*63bba73cSAndrew Rist * with the License. You may obtain a copy of the License at
10*63bba73cSAndrew Rist *
11*63bba73cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*63bba73cSAndrew Rist *
13*63bba73cSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*63bba73cSAndrew Rist * software distributed under the License is distributed on an
15*63bba73cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*63bba73cSAndrew Rist * KIND, either express or implied. See the License for the
17*63bba73cSAndrew Rist * specific language governing permissions and limitations
18*63bba73cSAndrew Rist * under the License.
19*63bba73cSAndrew Rist *
20*63bba73cSAndrew Rist *************************************************************/
21*63bba73cSAndrew Rist
22*63bba73cSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_xmloff.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "SchXMLPlotAreaContext.hxx"
28cdf0e10cSrcweir #include "SchXMLImport.hxx"
29cdf0e10cSrcweir #include "SchXMLAxisContext.hxx"
30cdf0e10cSrcweir #include "SchXMLSeries2Context.hxx"
31cdf0e10cSrcweir #include "SchXMLTools.hxx"
32cdf0e10cSrcweir #include <tools/debug.hxx>
33cdf0e10cSrcweir #ifdef DBG_UTIL
34cdf0e10cSrcweir #include <tools/string.hxx>
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir
37cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
38cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx"
39cdf0e10cSrcweir #include <xmloff/xmlement.hxx>
40cdf0e10cSrcweir #include <xmloff/nmspmap.hxx>
41cdf0e10cSrcweir #include <xmloff/xmluconv.hxx>
42cdf0e10cSrcweir #include <xmloff/prstylei.hxx>
43cdf0e10cSrcweir #include <xmloff/xmlstyle.hxx>
44cdf0e10cSrcweir #include "xexptran.hxx"
45cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
46cdf0e10cSrcweir
47cdf0e10cSrcweir #include <com/sun/star/awt/Point.hpp>
48cdf0e10cSrcweir #include <com/sun/star/awt/Size.hpp>
49cdf0e10cSrcweir
50cdf0e10cSrcweir #include <com/sun/star/chart/ChartDataRowSource.hpp>
51cdf0e10cSrcweir #include <com/sun/star/chart/X3DDisplay.hpp>
52cdf0e10cSrcweir #include <com/sun/star/chart/XStatisticDisplay.hpp>
53cdf0e10cSrcweir #include <com/sun/star/chart/XDiagramPositioning.hpp>
54cdf0e10cSrcweir
55cdf0e10cSrcweir #include <com/sun/star/chart2/data/XRangeXMLConversion.hpp>
56cdf0e10cSrcweir #include <com/sun/star/chart2/XChartTypeContainer.hpp>
57cdf0e10cSrcweir #include <com/sun/star/chart2/XDataSeriesContainer.hpp>
58cdf0e10cSrcweir #include <com/sun/star/chart2/RelativePosition.hpp>
59cdf0e10cSrcweir
60cdf0e10cSrcweir #include <com/sun/star/drawing/CameraGeometry.hpp>
61cdf0e10cSrcweir #include <com/sun/star/drawing/FillStyle.hpp>
62cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
63cdf0e10cSrcweir #include <com/sun/star/util/XStringMapping.hpp>
64cdf0e10cSrcweir #include <com/sun/star/xml/sax/XAttributeList.hpp>
65cdf0e10cSrcweir
66cdf0e10cSrcweir using namespace com::sun::star;
67cdf0e10cSrcweir using namespace ::xmloff::token;
68cdf0e10cSrcweir
69cdf0e10cSrcweir using ::rtl::OUString;
70cdf0e10cSrcweir using com::sun::star::uno::Reference;
71cdf0e10cSrcweir
72cdf0e10cSrcweir namespace
73cdf0e10cSrcweir {
74cdf0e10cSrcweir
75cdf0e10cSrcweir struct lcl_AxisHasCategories : public ::std::unary_function< SchXMLAxis, bool >
76cdf0e10cSrcweir {
operator ()__anona483cd000111::lcl_AxisHasCategories77cdf0e10cSrcweir bool operator() ( const SchXMLAxis & rAxis )
78cdf0e10cSrcweir {
79cdf0e10cSrcweir return rAxis.bHasCategories;
80cdf0e10cSrcweir }
81cdf0e10cSrcweir };
82cdf0e10cSrcweir
lcl_ConvertRange(const::rtl::OUString & rRange,const uno::Reference<chart2::XChartDocument> & xDoc)83cdf0e10cSrcweir OUString lcl_ConvertRange( const ::rtl::OUString & rRange, const uno::Reference< chart2::XChartDocument > & xDoc )
84cdf0e10cSrcweir {
85cdf0e10cSrcweir OUString aResult = rRange;
86cdf0e10cSrcweir if(!xDoc.is())
87cdf0e10cSrcweir return aResult;
88cdf0e10cSrcweir uno::Reference< chart2::data::XRangeXMLConversion > xConversion(
89cdf0e10cSrcweir xDoc->getDataProvider(), uno::UNO_QUERY );
90cdf0e10cSrcweir if( xConversion.is())
91cdf0e10cSrcweir aResult = xConversion->convertRangeFromXML( rRange );
92cdf0e10cSrcweir return aResult;
93cdf0e10cSrcweir }
94cdf0e10cSrcweir
95cdf0e10cSrcweir } // anonymous namespace
96cdf0e10cSrcweir
SchXML3DSceneAttributesHelper(SvXMLImport & rImporter)97cdf0e10cSrcweir SchXML3DSceneAttributesHelper::SchXML3DSceneAttributesHelper( SvXMLImport& rImporter )
98cdf0e10cSrcweir : SdXML3DSceneAttributesHelper( rImporter )
99cdf0e10cSrcweir {
100cdf0e10cSrcweir }
101cdf0e10cSrcweir
getCameraDefaultFromDiagram(const uno::Reference<chart::XDiagram> & xDiagram)102cdf0e10cSrcweir void SchXML3DSceneAttributesHelper::getCameraDefaultFromDiagram( const uno::Reference< chart::XDiagram >& xDiagram )
103cdf0e10cSrcweir {
104cdf0e10cSrcweir //different defaults for camera geometry necessary to workaround wrong behaviour in old chart
105cdf0e10cSrcweir //in future make this version dependent if we have versioning (metastream) for ole objects
106cdf0e10cSrcweir
107cdf0e10cSrcweir try
108cdf0e10cSrcweir {
109cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProp( xDiagram, uno::UNO_QUERY );
110cdf0e10cSrcweir if( xProp.is() )
111cdf0e10cSrcweir {
112cdf0e10cSrcweir drawing::CameraGeometry aCamGeo;
113cdf0e10cSrcweir xProp->getPropertyValue( ::rtl::OUString::createFromAscii("D3DCameraGeometry")) >>= aCamGeo;
114cdf0e10cSrcweir maVRP.setX( aCamGeo.vrp.PositionX );
115cdf0e10cSrcweir maVRP.setY( aCamGeo.vrp.PositionY );
116cdf0e10cSrcweir maVRP.setZ( aCamGeo.vrp.PositionZ );
117cdf0e10cSrcweir maVPN.setX( aCamGeo.vpn.DirectionX );
118cdf0e10cSrcweir maVPN.setY( aCamGeo.vpn.DirectionY );
119cdf0e10cSrcweir maVPN.setZ( aCamGeo.vpn.DirectionZ );
120cdf0e10cSrcweir maVUP.setX( aCamGeo.vup.DirectionX );
121cdf0e10cSrcweir maVUP.setY( aCamGeo.vup.DirectionY );
122cdf0e10cSrcweir maVUP.setZ( aCamGeo.vup.DirectionZ );
123cdf0e10cSrcweir }
124cdf0e10cSrcweir }
125cdf0e10cSrcweir catch( uno::Exception & rEx )
126cdf0e10cSrcweir {
127cdf0e10cSrcweir #ifdef DBG_UTIL
128cdf0e10cSrcweir String aStr( rEx.Message );
129cdf0e10cSrcweir ByteString aBStr( aStr, RTL_TEXTENCODING_ASCII_US );
130cdf0e10cSrcweir DBG_ERROR1( "Exception caught for property NumberOfLines: %s", aBStr.GetBuffer());
131cdf0e10cSrcweir #else
132cdf0e10cSrcweir (void)rEx; // avoid warning for pro build
133cdf0e10cSrcweir #endif
134cdf0e10cSrcweir }
135cdf0e10cSrcweir }
136cdf0e10cSrcweir
~SchXML3DSceneAttributesHelper()137cdf0e10cSrcweir SchXML3DSceneAttributesHelper::~SchXML3DSceneAttributesHelper()
138cdf0e10cSrcweir {
139cdf0e10cSrcweir }
140cdf0e10cSrcweir
SchXMLPlotAreaContext(SchXMLImportHelper & rImpHelper,SvXMLImport & rImport,const rtl::OUString & rLocalName,const rtl::OUString & rXLinkHRefAttributeToIndicateDataProvider,uno::Sequence<chart::ChartSeriesAddress> & rSeriesAddresses,::rtl::OUString & rCategoriesAddress,::rtl::OUString & rChartAddress,bool & rbHasRangeAtPlotArea,sal_Bool & rAllRangeAddressesAvailable,sal_Bool & rColHasLabels,sal_Bool & rRowHasLabels,chart::ChartDataRowSource & rDataRowSource,SeriesDefaultsAndStyles & rSeriesDefaultsAndStyles,const::rtl::OUString & aChartTypeServiceName,tSchXMLLSequencesPerIndex & rLSequencesPerIndex,const awt::Size & rChartSize)141cdf0e10cSrcweir SchXMLPlotAreaContext::SchXMLPlotAreaContext(
142cdf0e10cSrcweir SchXMLImportHelper& rImpHelper,
143cdf0e10cSrcweir SvXMLImport& rImport, const rtl::OUString& rLocalName,
144cdf0e10cSrcweir const rtl::OUString& rXLinkHRefAttributeToIndicateDataProvider,
145cdf0e10cSrcweir uno::Sequence< chart::ChartSeriesAddress >& rSeriesAddresses,
146cdf0e10cSrcweir ::rtl::OUString& rCategoriesAddress,
147cdf0e10cSrcweir ::rtl::OUString& rChartAddress,
148cdf0e10cSrcweir bool& rbHasRangeAtPlotArea,
149cdf0e10cSrcweir sal_Bool & rAllRangeAddressesAvailable,
150cdf0e10cSrcweir sal_Bool & rColHasLabels,
151cdf0e10cSrcweir sal_Bool & rRowHasLabels,
152cdf0e10cSrcweir chart::ChartDataRowSource & rDataRowSource,
153cdf0e10cSrcweir SeriesDefaultsAndStyles& rSeriesDefaultsAndStyles,
154cdf0e10cSrcweir const ::rtl::OUString& aChartTypeServiceName,
155cdf0e10cSrcweir tSchXMLLSequencesPerIndex & rLSequencesPerIndex,
156cdf0e10cSrcweir const awt::Size & rChartSize ) :
157cdf0e10cSrcweir SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ),
158cdf0e10cSrcweir mrImportHelper( rImpHelper ),
159cdf0e10cSrcweir mrSeriesAddresses( rSeriesAddresses ),
160cdf0e10cSrcweir mrCategoriesAddress( rCategoriesAddress ),
161cdf0e10cSrcweir mrSeriesDefaultsAndStyles( rSeriesDefaultsAndStyles ),
162cdf0e10cSrcweir mnNumOfLinesProp( 0 ),
163cdf0e10cSrcweir mbStockHasVolume( sal_False ),
164cdf0e10cSrcweir mnSeries( 0 ),
165cdf0e10cSrcweir m_aGlobalSeriesImportInfo( rAllRangeAddressesAvailable ),
166cdf0e10cSrcweir maSceneImportHelper( rImport ),
167cdf0e10cSrcweir m_aOuterPositioning( rImport ),
168cdf0e10cSrcweir m_aInnerPositioning( rImport ),
169cdf0e10cSrcweir mbPercentStacked(false),
170cdf0e10cSrcweir m_bAxisPositionAttributeImported(false),
171cdf0e10cSrcweir m_rXLinkHRefAttributeToIndicateDataProvider(rXLinkHRefAttributeToIndicateDataProvider),
172cdf0e10cSrcweir mrChartAddress( rChartAddress ),
173cdf0e10cSrcweir m_rbHasRangeAtPlotArea( rbHasRangeAtPlotArea ),
174cdf0e10cSrcweir mrColHasLabels( rColHasLabels ),
175cdf0e10cSrcweir mrRowHasLabels( rRowHasLabels ),
176cdf0e10cSrcweir mrDataRowSource( rDataRowSource ),
177cdf0e10cSrcweir maChartTypeServiceName( aChartTypeServiceName ),
178cdf0e10cSrcweir mrLSequencesPerIndex( rLSequencesPerIndex ),
179cdf0e10cSrcweir mbGlobalChartTypeUsedBySeries( false ),
180cdf0e10cSrcweir maChartSize( rChartSize )
181cdf0e10cSrcweir {
182cdf0e10cSrcweir m_rbHasRangeAtPlotArea = false;
183cdf0e10cSrcweir
184cdf0e10cSrcweir // get Diagram
185cdf0e10cSrcweir uno::Reference< chart::XChartDocument > xDoc( rImpHelper.GetChartDocument(), uno::UNO_QUERY );
186cdf0e10cSrcweir if( xDoc.is())
187cdf0e10cSrcweir {
188cdf0e10cSrcweir mxDiagram = xDoc->getDiagram();
189cdf0e10cSrcweir mxNewDoc.set( xDoc, uno::UNO_QUERY );
190cdf0e10cSrcweir
191cdf0e10cSrcweir maSceneImportHelper.getCameraDefaultFromDiagram( mxDiagram );
192cdf0e10cSrcweir }
193cdf0e10cSrcweir DBG_ASSERT( mxDiagram.is(), "Couldn't get XDiagram" );
194cdf0e10cSrcweir
195cdf0e10cSrcweir // turn off all axes initially
196cdf0e10cSrcweir uno::Any aFalseBool;
197cdf0e10cSrcweir aFalseBool <<= (sal_Bool)(sal_False);
198cdf0e10cSrcweir
199cdf0e10cSrcweir uno::Reference< lang::XServiceInfo > xInfo( mxDiagram, uno::UNO_QUERY );
200cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProp( mxDiagram, uno::UNO_QUERY );
201cdf0e10cSrcweir if( xInfo.is() &&
202cdf0e10cSrcweir xProp.is())
203cdf0e10cSrcweir {
204cdf0e10cSrcweir try
205cdf0e10cSrcweir {
206cdf0e10cSrcweir xProp->setPropertyValue(
207cdf0e10cSrcweir rtl::OUString::createFromAscii( "HasXAxis" ), aFalseBool );
208cdf0e10cSrcweir xProp->setPropertyValue(
209cdf0e10cSrcweir rtl::OUString::createFromAscii( "HasXAxisGrid" ), aFalseBool );
210cdf0e10cSrcweir xProp->setPropertyValue(
211cdf0e10cSrcweir rtl::OUString::createFromAscii( "HasXAxisDescription" ), aFalseBool );
212cdf0e10cSrcweir xProp->setPropertyValue(
213cdf0e10cSrcweir rtl::OUString::createFromAscii( "HasSecondaryXAxis" ), aFalseBool );
214cdf0e10cSrcweir xProp->setPropertyValue(
215cdf0e10cSrcweir rtl::OUString::createFromAscii( "HasSecondaryXAxisDescription" ), aFalseBool );
216cdf0e10cSrcweir
217cdf0e10cSrcweir xProp->setPropertyValue(
218cdf0e10cSrcweir rtl::OUString::createFromAscii( "HasYAxis" ), aFalseBool );
219cdf0e10cSrcweir xProp->setPropertyValue(
220cdf0e10cSrcweir rtl::OUString::createFromAscii( "HasYAxisGrid" ), aFalseBool );
221cdf0e10cSrcweir xProp->setPropertyValue(
222cdf0e10cSrcweir rtl::OUString::createFromAscii( "HasYAxisDescription" ), aFalseBool );
223cdf0e10cSrcweir xProp->setPropertyValue(
224cdf0e10cSrcweir rtl::OUString::createFromAscii( "HasSecondaryYAxis" ), aFalseBool );
225cdf0e10cSrcweir xProp->setPropertyValue(
226cdf0e10cSrcweir rtl::OUString::createFromAscii( "HasSecondaryYAxisDescription" ), aFalseBool );
227cdf0e10cSrcweir
228cdf0e10cSrcweir xProp->setPropertyValue(
229cdf0e10cSrcweir rtl::OUString::createFromAscii( "HasZAxis" ), aFalseBool );
230cdf0e10cSrcweir xProp->setPropertyValue(
231cdf0e10cSrcweir rtl::OUString::createFromAscii( "HasZAxisDescription" ), aFalseBool );
232cdf0e10cSrcweir
233cdf0e10cSrcweir uno::Any aAny;
234cdf0e10cSrcweir chart::ChartDataRowSource eSource = chart::ChartDataRowSource_COLUMNS;
235cdf0e10cSrcweir aAny <<= eSource;
236cdf0e10cSrcweir xProp->setPropertyValue( rtl::OUString::createFromAscii( "DataRowSource" ), aAny );
237cdf0e10cSrcweir }
238cdf0e10cSrcweir catch( beans::UnknownPropertyException & )
239cdf0e10cSrcweir {
240cdf0e10cSrcweir DBG_ERROR( "Property required by service not supported" );
241cdf0e10cSrcweir }
242cdf0e10cSrcweir }
243cdf0e10cSrcweir }
244cdf0e10cSrcweir
~SchXMLPlotAreaContext()245cdf0e10cSrcweir SchXMLPlotAreaContext::~SchXMLPlotAreaContext()
246cdf0e10cSrcweir {}
247cdf0e10cSrcweir
StartElement(const uno::Reference<xml::sax::XAttributeList> & xAttrList)248cdf0e10cSrcweir void SchXMLPlotAreaContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
249cdf0e10cSrcweir {
250cdf0e10cSrcweir // parse attributes
251cdf0e10cSrcweir sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
252cdf0e10cSrcweir const SvXMLTokenMap& rAttrTokenMap = mrImportHelper.GetPlotAreaAttrTokenMap();
253cdf0e10cSrcweir uno::Reference< chart2::XChartDocument > xNewDoc( GetImport().GetModel(), uno::UNO_QUERY );
254cdf0e10cSrcweir
255cdf0e10cSrcweir for( sal_Int16 i = 0; i < nAttrCount; i++ )
256cdf0e10cSrcweir {
257cdf0e10cSrcweir rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
258cdf0e10cSrcweir rtl::OUString aLocalName;
259cdf0e10cSrcweir rtl::OUString aValue = xAttrList->getValueByIndex( i );
260cdf0e10cSrcweir sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
261cdf0e10cSrcweir
262cdf0e10cSrcweir switch( rAttrTokenMap.Get( nPrefix, aLocalName ))
263cdf0e10cSrcweir {
264cdf0e10cSrcweir case XML_TOK_PA_X:
265cdf0e10cSrcweir case XML_TOK_PA_Y:
266cdf0e10cSrcweir case XML_TOK_PA_WIDTH:
267cdf0e10cSrcweir case XML_TOK_PA_HEIGHT:
268cdf0e10cSrcweir m_aOuterPositioning.readPositioningAttribute( nPrefix, aLocalName, aValue );
269cdf0e10cSrcweir break;
270cdf0e10cSrcweir case XML_TOK_PA_STYLE_NAME:
271cdf0e10cSrcweir msAutoStyleName = aValue;
272cdf0e10cSrcweir break;
273cdf0e10cSrcweir case XML_TOK_PA_CHART_ADDRESS:
274cdf0e10cSrcweir mrChartAddress = lcl_ConvertRange( aValue, xNewDoc );
275cdf0e10cSrcweir // indicator for getting data from the outside
276cdf0e10cSrcweir m_rbHasRangeAtPlotArea = true;
277cdf0e10cSrcweir break;
278cdf0e10cSrcweir case XML_TOK_PA_DS_HAS_LABELS:
279cdf0e10cSrcweir {
280cdf0e10cSrcweir if( aValue.equals( ::xmloff::token::GetXMLToken( ::xmloff::token::XML_BOTH )))
281cdf0e10cSrcweir mrColHasLabels = mrRowHasLabels = sal_True;
282cdf0e10cSrcweir else if( aValue.equals( ::xmloff::token::GetXMLToken( ::xmloff::token::XML_ROW )))
283cdf0e10cSrcweir mrRowHasLabels = sal_True;
284cdf0e10cSrcweir else if( aValue.equals( ::xmloff::token::GetXMLToken( ::xmloff::token::XML_COLUMN )))
285cdf0e10cSrcweir mrColHasLabels = sal_True;
286cdf0e10cSrcweir }
287cdf0e10cSrcweir break;
288cdf0e10cSrcweir case XML_TOK_PA_TRANSFORM:
289cdf0e10cSrcweir case XML_TOK_PA_VRP:
290cdf0e10cSrcweir case XML_TOK_PA_VPN:
291cdf0e10cSrcweir case XML_TOK_PA_VUP:
292cdf0e10cSrcweir case XML_TOK_PA_PROJECTION:
293cdf0e10cSrcweir case XML_TOK_PA_DISTANCE:
294cdf0e10cSrcweir case XML_TOK_PA_FOCAL_LENGTH:
295cdf0e10cSrcweir case XML_TOK_PA_SHADOW_SLANT:
296cdf0e10cSrcweir case XML_TOK_PA_SHADE_MODE:
297cdf0e10cSrcweir case XML_TOK_PA_AMBIENT_COLOR:
298cdf0e10cSrcweir case XML_TOK_PA_LIGHTING_MODE:
299cdf0e10cSrcweir maSceneImportHelper.processSceneAttribute( nPrefix, aLocalName, aValue );
300cdf0e10cSrcweir break;
301cdf0e10cSrcweir }
302cdf0e10cSrcweir }
303cdf0e10cSrcweir
304cdf0e10cSrcweir if( ! mxNewDoc.is())
305cdf0e10cSrcweir {
306cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xDocProp( mrImportHelper.GetChartDocument(), uno::UNO_QUERY );
307cdf0e10cSrcweir if( xDocProp.is())
308cdf0e10cSrcweir {
309cdf0e10cSrcweir try
310cdf0e10cSrcweir {
311cdf0e10cSrcweir uno::Any aAny;
312cdf0e10cSrcweir aAny <<= (sal_Bool)(mrColHasLabels);
313cdf0e10cSrcweir xDocProp->setPropertyValue(
314cdf0e10cSrcweir ::rtl::OUString::createFromAscii( "DataSourceLabelsInFirstColumn" ),
315cdf0e10cSrcweir aAny );
316cdf0e10cSrcweir
317cdf0e10cSrcweir aAny <<= (sal_Bool)(mrRowHasLabels);
318cdf0e10cSrcweir xDocProp->setPropertyValue(
319cdf0e10cSrcweir ::rtl::OUString::createFromAscii( "DataSourceLabelsInFirstRow" ),
320cdf0e10cSrcweir aAny );
321cdf0e10cSrcweir }
322cdf0e10cSrcweir catch( beans::UnknownPropertyException & )
323cdf0e10cSrcweir {
324cdf0e10cSrcweir DBG_ERRORFILE( "Properties missing" );
325cdf0e10cSrcweir }
326cdf0e10cSrcweir }
327cdf0e10cSrcweir }
328cdf0e10cSrcweir
329cdf0e10cSrcweir // set properties
330cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProp( mxDiagram, uno::UNO_QUERY );
331cdf0e10cSrcweir if( msAutoStyleName.getLength())
332cdf0e10cSrcweir {
333cdf0e10cSrcweir if( xProp.is())
334cdf0e10cSrcweir {
335cdf0e10cSrcweir const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext();
336cdf0e10cSrcweir if( pStylesCtxt )
337cdf0e10cSrcweir {
338cdf0e10cSrcweir const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext(
339cdf0e10cSrcweir mrImportHelper.GetChartFamilyID(), msAutoStyleName );
340cdf0e10cSrcweir
341cdf0e10cSrcweir XMLPropStyleContext* pPropStyleContext =
342cdf0e10cSrcweir const_cast< XMLPropStyleContext * >(
343cdf0e10cSrcweir dynamic_cast< const XMLPropStyleContext * >( pStyle ) );
344cdf0e10cSrcweir if( pPropStyleContext )
345cdf0e10cSrcweir {
346cdf0e10cSrcweir pPropStyleContext->FillPropertySet( xProp );
347cdf0e10cSrcweir
348cdf0e10cSrcweir // get the data row source that was set without having data
349cdf0e10cSrcweir xProp->getPropertyValue( ::rtl::OUString::createFromAscii("DataRowSource"))
350cdf0e10cSrcweir >>= mrDataRowSource;
351cdf0e10cSrcweir
352cdf0e10cSrcweir //lines on/off
353cdf0e10cSrcweir //this old property is not supported fully anymore with the new chart, so we need to get the information a little bit different from similar properties
354cdf0e10cSrcweir mrSeriesDefaultsAndStyles.maLinesOnProperty = SchXMLTools::getPropertyFromContext(
355cdf0e10cSrcweir ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Lines")), pPropStyleContext, pStylesCtxt );
356cdf0e10cSrcweir
357cdf0e10cSrcweir //handle automatic position and size
358cdf0e10cSrcweir m_aOuterPositioning.readAutomaticPositioningProperties( pPropStyleContext, pStylesCtxt );
359cdf0e10cSrcweir
360cdf0e10cSrcweir //correct default starting angle for old 3D pies
361cdf0e10cSrcweir if( SchXMLTools::isDocumentGeneratedWithOpenOfficeOlderThan3_0( GetImport().GetModel() ) )
362cdf0e10cSrcweir {
363cdf0e10cSrcweir bool bIs3d = false;
364cdf0e10cSrcweir if( xProp.is() && ( xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Dim3D"))) >>= bIs3d ) &&
365cdf0e10cSrcweir bIs3d )
366cdf0e10cSrcweir {
367cdf0e10cSrcweir if( maChartTypeServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart2.PieChartType" ))
368cdf0e10cSrcweir || maChartTypeServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart2.DonutChartType" )) )
369cdf0e10cSrcweir {
370cdf0e10cSrcweir ::rtl::OUString aPropName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StartingAngle")) );
371cdf0e10cSrcweir uno::Any aAStartingAngle( SchXMLTools::getPropertyFromContext( aPropName, pPropStyleContext, pStylesCtxt ) );
372cdf0e10cSrcweir if( !aAStartingAngle.hasValue() )
373cdf0e10cSrcweir xProp->setPropertyValue( aPropName, uno::makeAny(sal_Int32(0)) ) ;
374cdf0e10cSrcweir }
375cdf0e10cSrcweir }
376cdf0e10cSrcweir }
377cdf0e10cSrcweir }
378cdf0e10cSrcweir }
379cdf0e10cSrcweir }
380cdf0e10cSrcweir }
381cdf0e10cSrcweir
382cdf0e10cSrcweir //remember default values for dataseries
383cdf0e10cSrcweir if(xProp.is())
384cdf0e10cSrcweir try
385cdf0e10cSrcweir {
386cdf0e10cSrcweir mrSeriesDefaultsAndStyles.maSymbolTypeDefault = xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SymbolType")));
387cdf0e10cSrcweir mrSeriesDefaultsAndStyles.maDataCaptionDefault = xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataCaption")));
388cdf0e10cSrcweir
389cdf0e10cSrcweir mrSeriesDefaultsAndStyles.maErrorIndicatorDefault = xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ErrorIndicator")));
390cdf0e10cSrcweir mrSeriesDefaultsAndStyles.maErrorCategoryDefault = xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ErrorCategory")));
391cdf0e10cSrcweir mrSeriesDefaultsAndStyles.maConstantErrorLowDefault = xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ConstantErrorLow")));
392cdf0e10cSrcweir mrSeriesDefaultsAndStyles.maConstantErrorHighDefault = xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ConstantErrorHigh")));
393cdf0e10cSrcweir mrSeriesDefaultsAndStyles.maPercentageErrorDefault = xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PercentageError")));
394cdf0e10cSrcweir mrSeriesDefaultsAndStyles.maErrorMarginDefault = xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ErrorMargin")));
395cdf0e10cSrcweir
396cdf0e10cSrcweir mrSeriesDefaultsAndStyles.maMeanValueDefault = xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MeanValue")));
397cdf0e10cSrcweir mrSeriesDefaultsAndStyles.maRegressionCurvesDefault = xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RegressionCurves")));
398cdf0e10cSrcweir
399cdf0e10cSrcweir bool bStacked = false;
400cdf0e10cSrcweir mrSeriesDefaultsAndStyles.maStackedDefault = xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Stacked")));
401cdf0e10cSrcweir mrSeriesDefaultsAndStyles.maStackedDefault >>= bStacked;
402cdf0e10cSrcweir mrSeriesDefaultsAndStyles.maPercentDefault = xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Percent")));
403cdf0e10cSrcweir mrSeriesDefaultsAndStyles.maPercentDefault >>= mbPercentStacked;
404cdf0e10cSrcweir mrSeriesDefaultsAndStyles.maStackedBarsConnectedDefault = xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StackedBarsConnected")));
405cdf0e10cSrcweir
406cdf0e10cSrcweir // deep
407cdf0e10cSrcweir uno::Any aDeepProperty( xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Deep"))));
408cdf0e10cSrcweir // #124488# old versions store a 3d area and 3D line deep chart with Deep==false => workaround for this
409cdf0e10cSrcweir if( ! (bStacked || mbPercentStacked ))
410cdf0e10cSrcweir {
411cdf0e10cSrcweir if( SchXMLTools::isDocumentGeneratedWithOpenOfficeOlderThan2_3( GetImport().GetModel() ) )
412cdf0e10cSrcweir {
413cdf0e10cSrcweir bool bIs3d = false;
414cdf0e10cSrcweir if( ( xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Dim3D"))) >>= bIs3d ) &&
415cdf0e10cSrcweir bIs3d )
416cdf0e10cSrcweir {
417cdf0e10cSrcweir if( maChartTypeServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart2.AreaChartType" )) ||
418cdf0e10cSrcweir maChartTypeServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart2.LineChartType" )) )
419cdf0e10cSrcweir {
420cdf0e10cSrcweir aDeepProperty <<= uno::makeAny( true );
421cdf0e10cSrcweir }
422cdf0e10cSrcweir }
423cdf0e10cSrcweir }
424cdf0e10cSrcweir }
425cdf0e10cSrcweir mrSeriesDefaultsAndStyles.maDeepDefault = aDeepProperty;
426cdf0e10cSrcweir
427cdf0e10cSrcweir xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NumberOfLines"))) >>= mnNumOfLinesProp;
428cdf0e10cSrcweir xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Volume"))) >>= mbStockHasVolume;
429cdf0e10cSrcweir }
430cdf0e10cSrcweir catch( uno::Exception & rEx )
431cdf0e10cSrcweir {
432cdf0e10cSrcweir #ifdef DBG_UTIL
433cdf0e10cSrcweir String aStr( rEx.Message );
434cdf0e10cSrcweir ByteString aBStr( aStr, RTL_TEXTENCODING_ASCII_US );
435cdf0e10cSrcweir DBG_ERROR1( "PlotAreaContext:EndElement(): Exception caught: %s", aBStr.GetBuffer());
436cdf0e10cSrcweir #else
437cdf0e10cSrcweir (void)rEx; // avoid warning for pro build
438cdf0e10cSrcweir #endif
439cdf0e10cSrcweir }
440cdf0e10cSrcweir //
441cdf0e10cSrcweir
442cdf0e10cSrcweir bool bCreateInternalDataProvider = false;
443cdf0e10cSrcweir if( m_rXLinkHRefAttributeToIndicateDataProvider.equalsAscii( "." ) ) //data comes from the chart itself
444cdf0e10cSrcweir bCreateInternalDataProvider = true;
445cdf0e10cSrcweir else if( m_rXLinkHRefAttributeToIndicateDataProvider.equalsAscii( ".." ) ) //data comes from the parent application
446cdf0e10cSrcweir bCreateInternalDataProvider = false;
447cdf0e10cSrcweir else if( m_rXLinkHRefAttributeToIndicateDataProvider.getLength() ) //not supported so far to get the data by sibling objects -> fall back to chart itself
448cdf0e10cSrcweir bCreateInternalDataProvider = true;
449cdf0e10cSrcweir else if( !m_rbHasRangeAtPlotArea )
450cdf0e10cSrcweir bCreateInternalDataProvider = true;
451cdf0e10cSrcweir
452cdf0e10cSrcweir if( bCreateInternalDataProvider && mxNewDoc.is() )
453cdf0e10cSrcweir {
454cdf0e10cSrcweir // we have no complete range => we have own data, so switch the data
455cdf0e10cSrcweir // provider to internal. Clone is not necessary, as we don't have any
456cdf0e10cSrcweir // data yet.
457cdf0e10cSrcweir mxNewDoc->createInternalDataProvider( false /* bCloneExistingData */ );
458cdf0e10cSrcweir if( xProp.is() && mrDataRowSource!=chart::ChartDataRowSource_COLUMNS )
459cdf0e10cSrcweir xProp->setPropertyValue( rtl::OUString::createFromAscii( "DataRowSource" ), uno::makeAny(mrDataRowSource) );
460cdf0e10cSrcweir }
461cdf0e10cSrcweir }
462cdf0e10cSrcweir
CreateChildContext(sal_uInt16 nPrefix,const rtl::OUString & rLocalName,const uno::Reference<xml::sax::XAttributeList> & xAttrList)463cdf0e10cSrcweir SvXMLImportContext* SchXMLPlotAreaContext::CreateChildContext(
464cdf0e10cSrcweir sal_uInt16 nPrefix,
465cdf0e10cSrcweir const rtl::OUString& rLocalName,
466cdf0e10cSrcweir const uno::Reference< xml::sax::XAttributeList >& xAttrList )
467cdf0e10cSrcweir {
468cdf0e10cSrcweir SvXMLImportContext* pContext = 0;
469cdf0e10cSrcweir const SvXMLTokenMap& rTokenMap = mrImportHelper.GetPlotAreaElemTokenMap();
470cdf0e10cSrcweir
471cdf0e10cSrcweir switch( rTokenMap.Get( nPrefix, rLocalName ))
472cdf0e10cSrcweir {
473cdf0e10cSrcweir case XML_TOK_PA_COORDINATE_REGION_EXT:
474cdf0e10cSrcweir case XML_TOK_PA_COORDINATE_REGION:
475cdf0e10cSrcweir {
476cdf0e10cSrcweir pContext = new SchXMLCoordinateRegionContext( GetImport(), nPrefix, rLocalName, m_aInnerPositioning );
477cdf0e10cSrcweir }
478cdf0e10cSrcweir break;
479cdf0e10cSrcweir
480cdf0e10cSrcweir case XML_TOK_PA_AXIS:
481cdf0e10cSrcweir {
482cdf0e10cSrcweir bool bAddMissingXAxisForNetCharts = false;
483cdf0e10cSrcweir bool bAdaptWrongPercentScaleValues = false;
484cdf0e10cSrcweir if( SchXMLTools::isDocumentGeneratedWithOpenOfficeOlderThan2_3( GetImport().GetModel() ) )
485cdf0e10cSrcweir {
486cdf0e10cSrcweir //correct errors from older versions
487cdf0e10cSrcweir
488cdf0e10cSrcweir // for NetCharts there were no xAxis exported to older files
489cdf0e10cSrcweir // so we need to add the x axis here for those old NetChart files
490cdf0e10cSrcweir if( maChartTypeServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart2.NetChartType" )) )
491cdf0e10cSrcweir bAddMissingXAxisForNetCharts = true;
492cdf0e10cSrcweir
493cdf0e10cSrcweir //Issue 59288
494cdf0e10cSrcweir if( mbPercentStacked )
495cdf0e10cSrcweir bAdaptWrongPercentScaleValues = true;
496cdf0e10cSrcweir }
497cdf0e10cSrcweir
498cdf0e10cSrcweir bool bAdaptXAxisOrientationForOld2DBarCharts = false;
499cdf0e10cSrcweir if( SchXMLTools::isDocumentGeneratedWithOpenOfficeOlderThan2_4( GetImport().GetModel() ) )
500cdf0e10cSrcweir {
501cdf0e10cSrcweir //issue74660
502cdf0e10cSrcweir if( maChartTypeServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart2.ColumnChartType" )) )
503cdf0e10cSrcweir bAdaptXAxisOrientationForOld2DBarCharts = true;
504cdf0e10cSrcweir }
505cdf0e10cSrcweir
506cdf0e10cSrcweir pContext = new SchXMLAxisContext( mrImportHelper, GetImport(), rLocalName, mxDiagram, maAxes, mrCategoriesAddress,
507cdf0e10cSrcweir bAddMissingXAxisForNetCharts, bAdaptWrongPercentScaleValues, bAdaptXAxisOrientationForOld2DBarCharts, m_bAxisPositionAttributeImported );
508cdf0e10cSrcweir }
509cdf0e10cSrcweir break;
510cdf0e10cSrcweir
511cdf0e10cSrcweir case XML_TOK_PA_SERIES:
512cdf0e10cSrcweir {
513cdf0e10cSrcweir if( mxNewDoc.is())
514cdf0e10cSrcweir {
515cdf0e10cSrcweir pContext = new SchXMLSeries2Context(
516cdf0e10cSrcweir mrImportHelper, GetImport(), rLocalName,
517cdf0e10cSrcweir mxNewDoc, maAxes,
518cdf0e10cSrcweir mrSeriesDefaultsAndStyles.maSeriesStyleList,
519cdf0e10cSrcweir mnSeries,
520cdf0e10cSrcweir mbStockHasVolume,
521cdf0e10cSrcweir m_aGlobalSeriesImportInfo,
522cdf0e10cSrcweir maChartTypeServiceName,
523cdf0e10cSrcweir mrLSequencesPerIndex,
524cdf0e10cSrcweir mbGlobalChartTypeUsedBySeries, maChartSize );
525cdf0e10cSrcweir }
526cdf0e10cSrcweir mnSeries++;
527cdf0e10cSrcweir }
528cdf0e10cSrcweir break;
529cdf0e10cSrcweir
530cdf0e10cSrcweir case XML_TOK_PA_WALL:
531cdf0e10cSrcweir pContext = new SchXMLWallFloorContext( mrImportHelper, GetImport(), nPrefix, rLocalName, mxDiagram,
532cdf0e10cSrcweir SchXMLWallFloorContext::CONTEXT_TYPE_WALL );
533cdf0e10cSrcweir break;
534cdf0e10cSrcweir case XML_TOK_PA_FLOOR:
535cdf0e10cSrcweir pContext = new SchXMLWallFloorContext( mrImportHelper, GetImport(), nPrefix, rLocalName, mxDiagram,
536cdf0e10cSrcweir SchXMLWallFloorContext::CONTEXT_TYPE_FLOOR );
537cdf0e10cSrcweir break;
538cdf0e10cSrcweir
539cdf0e10cSrcweir case XML_TOK_PA_LIGHT_SOURCE:
540cdf0e10cSrcweir pContext = maSceneImportHelper.create3DLightContext( nPrefix, rLocalName, xAttrList );
541cdf0e10cSrcweir break;
542cdf0e10cSrcweir
543cdf0e10cSrcweir // elements for stock charts
544cdf0e10cSrcweir case XML_TOK_PA_STOCK_GAIN:
545cdf0e10cSrcweir pContext = new SchXMLStockContext( mrImportHelper, GetImport(), nPrefix, rLocalName, mxDiagram,
546cdf0e10cSrcweir SchXMLStockContext::CONTEXT_TYPE_GAIN );
547cdf0e10cSrcweir break;
548cdf0e10cSrcweir case XML_TOK_PA_STOCK_LOSS:
549cdf0e10cSrcweir pContext = new SchXMLStockContext( mrImportHelper, GetImport(), nPrefix, rLocalName, mxDiagram,
550cdf0e10cSrcweir SchXMLStockContext::CONTEXT_TYPE_LOSS );
551cdf0e10cSrcweir break;
552cdf0e10cSrcweir case XML_TOK_PA_STOCK_RANGE:
553cdf0e10cSrcweir pContext = new SchXMLStockContext( mrImportHelper, GetImport(), nPrefix, rLocalName, mxDiagram,
554cdf0e10cSrcweir SchXMLStockContext::CONTEXT_TYPE_RANGE );
555cdf0e10cSrcweir break;
556cdf0e10cSrcweir
557cdf0e10cSrcweir default:
558cdf0e10cSrcweir pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
559cdf0e10cSrcweir }
560cdf0e10cSrcweir
561cdf0e10cSrcweir return pContext;
562cdf0e10cSrcweir }
563cdf0e10cSrcweir
EndElement()564cdf0e10cSrcweir void SchXMLPlotAreaContext::EndElement()
565cdf0e10cSrcweir {
566cdf0e10cSrcweir // set categories
567cdf0e10cSrcweir if( mrCategoriesAddress.getLength() && mxNewDoc.is())
568cdf0e10cSrcweir {
569cdf0e10cSrcweir uno::Reference< chart2::data::XDataProvider > xDataProvider(
570cdf0e10cSrcweir mxNewDoc->getDataProvider() );
571cdf0e10cSrcweir // @todo: correct coordinate system index
572cdf0e10cSrcweir sal_Int32 nDimension( 0 );
573cdf0e10cSrcweir ::std::vector< SchXMLAxis >::const_iterator aIt(
574cdf0e10cSrcweir ::std::find_if( maAxes.begin(), maAxes.end(), lcl_AxisHasCategories()));
575cdf0e10cSrcweir if( aIt != maAxes.end())
576cdf0e10cSrcweir nDimension = static_cast< sal_Int32 >( (*aIt).eDimension );
577cdf0e10cSrcweir SchXMLTools::CreateCategories(
578cdf0e10cSrcweir xDataProvider, mxNewDoc, mrCategoriesAddress,
579cdf0e10cSrcweir 0 /* nCooSysIndex */,
580cdf0e10cSrcweir nDimension, &mrLSequencesPerIndex );
581cdf0e10cSrcweir }
582cdf0e10cSrcweir
583cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xDiaProp( mxDiagram, uno::UNO_QUERY );
584cdf0e10cSrcweir if( xDiaProp.is())
585cdf0e10cSrcweir {
586cdf0e10cSrcweir sal_Bool bIsThreeDim = sal_False;
587cdf0e10cSrcweir uno::Any aAny = xDiaProp->getPropertyValue( ::rtl::OUString::createFromAscii( "Dim3D" ));
588cdf0e10cSrcweir aAny >>= bIsThreeDim;
589cdf0e10cSrcweir
590cdf0e10cSrcweir // set 3d scene attributes
591cdf0e10cSrcweir if( bIsThreeDim )
592cdf0e10cSrcweir {
593cdf0e10cSrcweir // set scene attributes at diagram
594cdf0e10cSrcweir maSceneImportHelper.setSceneAttributes( xDiaProp );
595cdf0e10cSrcweir }
596cdf0e10cSrcweir
597cdf0e10cSrcweir // set correct number of lines at series
598cdf0e10cSrcweir if( ! m_aGlobalSeriesImportInfo.rbAllRangeAddressesAvailable &&
599cdf0e10cSrcweir mnNumOfLinesProp > 0 &&
600cdf0e10cSrcweir maChartTypeServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart2.ColumnChartType" )))
601cdf0e10cSrcweir {
602cdf0e10cSrcweir try
603cdf0e10cSrcweir {
604cdf0e10cSrcweir xDiaProp->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NumberOfLines" )),
605cdf0e10cSrcweir uno::makeAny( mnNumOfLinesProp ));
606cdf0e10cSrcweir }
607cdf0e10cSrcweir catch( uno::Exception & rEx )
608cdf0e10cSrcweir {
609cdf0e10cSrcweir #ifdef DBG_UTIL
610cdf0e10cSrcweir String aStr( rEx.Message );
611cdf0e10cSrcweir ByteString aBStr( aStr, RTL_TEXTENCODING_ASCII_US );
612cdf0e10cSrcweir DBG_ERROR1( "Exception caught for property NumberOfLines: %s", aBStr.GetBuffer());
613cdf0e10cSrcweir #else
614cdf0e10cSrcweir (void)rEx; // avoid warning for pro build
615cdf0e10cSrcweir #endif
616cdf0e10cSrcweir }
617cdf0e10cSrcweir }
618cdf0e10cSrcweir
619cdf0e10cSrcweir // #i32366# stock has volume
620cdf0e10cSrcweir if( ( 0 == mxDiagram->getDiagramType().reverseCompareToAsciiL(
621cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart.StockDiagram" ))) &&
622cdf0e10cSrcweir mbStockHasVolume )
623cdf0e10cSrcweir {
624cdf0e10cSrcweir try
625cdf0e10cSrcweir {
626cdf0e10cSrcweir xDiaProp->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Volume" )),
627cdf0e10cSrcweir uno::makeAny( true ));
628cdf0e10cSrcweir }
629cdf0e10cSrcweir catch( uno::Exception & rEx )
630cdf0e10cSrcweir {
631cdf0e10cSrcweir #ifdef DBG_UTIL
632cdf0e10cSrcweir String aStr( rEx.Message );
633cdf0e10cSrcweir ByteString aBStr( aStr, RTL_TEXTENCODING_ASCII_US );
634cdf0e10cSrcweir DBG_ERROR1( "Exception caught for property Volume: %s", aBStr.GetBuffer());
635cdf0e10cSrcweir #else
636cdf0e10cSrcweir (void)rEx; // avoid warning for pro build
637cdf0e10cSrcweir #endif
638cdf0e10cSrcweir }
639cdf0e10cSrcweir }
640cdf0e10cSrcweir }
641cdf0e10cSrcweir
642cdf0e10cSrcweir // set changed size and position after properties (esp. 3d)
643cdf0e10cSrcweir
644cdf0e10cSrcweir uno::Reference< chart::XDiagramPositioning > xDiaPos( mxDiagram, uno::UNO_QUERY );
645cdf0e10cSrcweir if( xDiaPos.is())
646cdf0e10cSrcweir {
647cdf0e10cSrcweir if( !m_aOuterPositioning.isAutomatic() )
648cdf0e10cSrcweir {
649cdf0e10cSrcweir if( m_aInnerPositioning.hasPosSize() )
650cdf0e10cSrcweir xDiaPos->setDiagramPositionExcludingAxes( m_aInnerPositioning.getRectangle() );
651cdf0e10cSrcweir else if( m_aOuterPositioning.hasPosSize() )
652cdf0e10cSrcweir {
653cdf0e10cSrcweir if( SchXMLTools::isDocumentGeneratedWithOpenOfficeOlderThan3_3( GetImport().GetModel() ) ) //old version of OOo did write a wrong rectangle for the diagram size
654cdf0e10cSrcweir xDiaPos->setDiagramPositionIncludingAxesAndAxisTitles( m_aOuterPositioning.getRectangle() );
655cdf0e10cSrcweir else
656cdf0e10cSrcweir xDiaPos->setDiagramPositionIncludingAxes( m_aOuterPositioning.getRectangle() );
657cdf0e10cSrcweir }
658cdf0e10cSrcweir }
659cdf0e10cSrcweir }
660cdf0e10cSrcweir
661cdf0e10cSrcweir SchXMLAxisContext::CorrectAxisPositions( uno::Reference< chart2::XChartDocument >( mrImportHelper.GetChartDocument(), uno::UNO_QUERY ), maChartTypeServiceName, GetImport().GetODFVersion(), m_bAxisPositionAttributeImported );
662cdf0e10cSrcweir }
663cdf0e10cSrcweir
664cdf0e10cSrcweir // ========================================
665cdf0e10cSrcweir
SchXMLDataPointContext(SchXMLImportHelper & rImpHelper,SvXMLImport & rImport,const rtl::OUString & rLocalName,::std::list<DataRowPointStyle> & rStyleList,const::com::sun::star::uno::Reference<::com::sun::star::chart2::XDataSeries> & xSeries,sal_Int32 & rIndex,bool bSymbolSizeForSeriesIsMissingInFile)666cdf0e10cSrcweir SchXMLDataPointContext::SchXMLDataPointContext( SchXMLImportHelper& rImpHelper,
667cdf0e10cSrcweir SvXMLImport& rImport, const rtl::OUString& rLocalName,
668cdf0e10cSrcweir ::std::list< DataRowPointStyle >& rStyleList,
669cdf0e10cSrcweir const ::com::sun::star::uno::Reference<
670cdf0e10cSrcweir ::com::sun::star::chart2::XDataSeries >& xSeries,
671cdf0e10cSrcweir sal_Int32& rIndex,
672cdf0e10cSrcweir bool bSymbolSizeForSeriesIsMissingInFile ) :
673cdf0e10cSrcweir SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ),
674cdf0e10cSrcweir mrImportHelper( rImpHelper ),
675cdf0e10cSrcweir mrStyleList( rStyleList ),
676cdf0e10cSrcweir m_xSeries( xSeries ),
677cdf0e10cSrcweir mrIndex( rIndex ),
678cdf0e10cSrcweir mbSymbolSizeForSeriesIsMissingInFile( bSymbolSizeForSeriesIsMissingInFile )
679cdf0e10cSrcweir {
680cdf0e10cSrcweir }
681cdf0e10cSrcweir
~SchXMLDataPointContext()682cdf0e10cSrcweir SchXMLDataPointContext::~SchXMLDataPointContext()
683cdf0e10cSrcweir {
684cdf0e10cSrcweir }
685cdf0e10cSrcweir
StartElement(const uno::Reference<xml::sax::XAttributeList> & xAttrList)686cdf0e10cSrcweir void SchXMLDataPointContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
687cdf0e10cSrcweir {
688cdf0e10cSrcweir sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
689cdf0e10cSrcweir ::rtl::OUString aValue;
690cdf0e10cSrcweir ::rtl::OUString sAutoStyleName;
691cdf0e10cSrcweir sal_Int32 nRepeat = 1;
692cdf0e10cSrcweir
693cdf0e10cSrcweir for( sal_Int16 i = 0; i < nAttrCount; i++ )
694cdf0e10cSrcweir {
695cdf0e10cSrcweir rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
696cdf0e10cSrcweir rtl::OUString aLocalName;
697cdf0e10cSrcweir sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
698cdf0e10cSrcweir
699cdf0e10cSrcweir if( nPrefix == XML_NAMESPACE_CHART )
700cdf0e10cSrcweir {
701cdf0e10cSrcweir if( IsXMLToken( aLocalName, XML_STYLE_NAME ) )
702cdf0e10cSrcweir sAutoStyleName = xAttrList->getValueByIndex( i );
703cdf0e10cSrcweir else if( IsXMLToken( aLocalName, XML_REPEATED ) )
704cdf0e10cSrcweir nRepeat = xAttrList->getValueByIndex( i ).toInt32();
705cdf0e10cSrcweir }
706cdf0e10cSrcweir }
707cdf0e10cSrcweir
708cdf0e10cSrcweir if( sAutoStyleName.getLength())
709cdf0e10cSrcweir {
710cdf0e10cSrcweir DataRowPointStyle aStyle(
711cdf0e10cSrcweir DataRowPointStyle::DATA_POINT,
712cdf0e10cSrcweir m_xSeries, mrIndex, nRepeat, sAutoStyleName );
713cdf0e10cSrcweir aStyle.mbSymbolSizeForSeriesIsMissingInFile = mbSymbolSizeForSeriesIsMissingInFile;
714cdf0e10cSrcweir mrStyleList.push_back( aStyle );
715cdf0e10cSrcweir }
716cdf0e10cSrcweir mrIndex += nRepeat;
717cdf0e10cSrcweir }
718cdf0e10cSrcweir
719cdf0e10cSrcweir // ========================================
720cdf0e10cSrcweir
SchXMLPositonAttributesHelper(SvXMLImport & rImporter)721cdf0e10cSrcweir SchXMLPositonAttributesHelper::SchXMLPositonAttributesHelper( SvXMLImport& rImporter )
722cdf0e10cSrcweir : m_rImport( rImporter )
723cdf0e10cSrcweir , m_aPosition(0,0)
724cdf0e10cSrcweir , m_aSize(0,0)
725cdf0e10cSrcweir , m_bHasSizeWidth( false )
726cdf0e10cSrcweir , m_bHasSizeHeight( false )
727cdf0e10cSrcweir , m_bHasPositionX( false )
728cdf0e10cSrcweir , m_bHasPositionY( false )
729cdf0e10cSrcweir , m_bAutoSize( false )
730cdf0e10cSrcweir , m_bAutoPosition( false )
731cdf0e10cSrcweir {
732cdf0e10cSrcweir }
733cdf0e10cSrcweir
~SchXMLPositonAttributesHelper()734cdf0e10cSrcweir SchXMLPositonAttributesHelper::~SchXMLPositonAttributesHelper()
735cdf0e10cSrcweir {
736cdf0e10cSrcweir }
737cdf0e10cSrcweir
hasSize() const738cdf0e10cSrcweir bool SchXMLPositonAttributesHelper::hasSize() const
739cdf0e10cSrcweir {
740cdf0e10cSrcweir return m_bHasSizeWidth && m_bHasSizeHeight;
741cdf0e10cSrcweir }
hasPosition() const742cdf0e10cSrcweir bool SchXMLPositonAttributesHelper::hasPosition() const
743cdf0e10cSrcweir {
744cdf0e10cSrcweir return m_bHasPositionX && m_bHasPositionY;
745cdf0e10cSrcweir }
hasPosSize() const746cdf0e10cSrcweir bool SchXMLPositonAttributesHelper::hasPosSize() const
747cdf0e10cSrcweir {
748cdf0e10cSrcweir return hasPosition() && hasSize();
749cdf0e10cSrcweir }
isAutomatic() const750cdf0e10cSrcweir bool SchXMLPositonAttributesHelper::isAutomatic() const
751cdf0e10cSrcweir {
752cdf0e10cSrcweir return m_bAutoSize || m_bAutoPosition;
753cdf0e10cSrcweir }
getPosition() const754cdf0e10cSrcweir awt::Point SchXMLPositonAttributesHelper::getPosition() const
755cdf0e10cSrcweir {
756cdf0e10cSrcweir return m_aPosition;
757cdf0e10cSrcweir }
getSize() const758cdf0e10cSrcweir awt::Size SchXMLPositonAttributesHelper::getSize() const
759cdf0e10cSrcweir {
760cdf0e10cSrcweir return m_aSize;
761cdf0e10cSrcweir }
getRectangle() const762cdf0e10cSrcweir awt::Rectangle SchXMLPositonAttributesHelper::getRectangle() const
763cdf0e10cSrcweir {
764cdf0e10cSrcweir return awt::Rectangle( m_aPosition.X, m_aPosition.Y, m_aSize.Width, m_aSize.Height );
765cdf0e10cSrcweir }
766cdf0e10cSrcweir
readPositioningAttribute(sal_uInt16 nPrefix,const::rtl::OUString & rLocalName,const::rtl::OUString & rValue)767cdf0e10cSrcweir bool SchXMLPositonAttributesHelper::readPositioningAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
768cdf0e10cSrcweir {
769cdf0e10cSrcweir //returns true if the attribute was proccessed
770cdf0e10cSrcweir bool bReturn = true;
771cdf0e10cSrcweir
772cdf0e10cSrcweir if( XML_NAMESPACE_SVG == nPrefix )
773cdf0e10cSrcweir {
774cdf0e10cSrcweir if( IsXMLToken( rLocalName, XML_X ) )
775cdf0e10cSrcweir {
776cdf0e10cSrcweir m_rImport.GetMM100UnitConverter().convertMeasure( m_aPosition.X, rValue );
777cdf0e10cSrcweir m_bHasPositionX = true;
778cdf0e10cSrcweir }
779cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_Y ) )
780cdf0e10cSrcweir {
781cdf0e10cSrcweir m_rImport.GetMM100UnitConverter().convertMeasure( m_aPosition.Y, rValue );
782cdf0e10cSrcweir m_bHasPositionY = true;
783cdf0e10cSrcweir }
784cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_WIDTH ) )
785cdf0e10cSrcweir {
786cdf0e10cSrcweir m_rImport.GetMM100UnitConverter().convertMeasure( m_aSize.Width, rValue );
787cdf0e10cSrcweir m_bHasSizeWidth = true;
788cdf0e10cSrcweir }
789cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_HEIGHT ) )
790cdf0e10cSrcweir {
791cdf0e10cSrcweir m_rImport.GetMM100UnitConverter().convertMeasure( m_aSize.Height, rValue );
792cdf0e10cSrcweir m_bHasSizeHeight = true;
793cdf0e10cSrcweir }
794cdf0e10cSrcweir else
795cdf0e10cSrcweir bReturn = false;
796cdf0e10cSrcweir }
797cdf0e10cSrcweir else
798cdf0e10cSrcweir bReturn = false;
799cdf0e10cSrcweir
800cdf0e10cSrcweir return bReturn;
801cdf0e10cSrcweir }
802cdf0e10cSrcweir
803cdf0e10cSrcweir
readAutomaticPositioningProperties(XMLPropStyleContext * pPropStyleContext,const SvXMLStylesContext * pStylesCtxt)804cdf0e10cSrcweir void SchXMLPositonAttributesHelper::readAutomaticPositioningProperties( XMLPropStyleContext* pPropStyleContext, const SvXMLStylesContext* pStylesCtxt )
805cdf0e10cSrcweir {
806cdf0e10cSrcweir if( pPropStyleContext && pStylesCtxt )
807cdf0e10cSrcweir {
808cdf0e10cSrcweir //handle automatic position and size
809cdf0e10cSrcweir SchXMLTools::getPropertyFromContext(
810cdf0e10cSrcweir ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AutomaticSize")), pPropStyleContext, pStylesCtxt ) >>= m_bAutoSize;
811cdf0e10cSrcweir SchXMLTools::getPropertyFromContext(
812cdf0e10cSrcweir ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AutomaticPosition")), pPropStyleContext, pStylesCtxt ) >>= m_bAutoPosition;
813cdf0e10cSrcweir }
814cdf0e10cSrcweir }
815cdf0e10cSrcweir
816cdf0e10cSrcweir // ========================================
817cdf0e10cSrcweir
SchXMLCoordinateRegionContext(SvXMLImport & rImport,sal_uInt16 nPrefix,const rtl::OUString & rLocalName,SchXMLPositonAttributesHelper & rPositioning)818cdf0e10cSrcweir SchXMLCoordinateRegionContext::SchXMLCoordinateRegionContext(
819cdf0e10cSrcweir SvXMLImport& rImport
820cdf0e10cSrcweir , sal_uInt16 nPrefix
821cdf0e10cSrcweir , const rtl::OUString& rLocalName
822cdf0e10cSrcweir , SchXMLPositonAttributesHelper& rPositioning )
823cdf0e10cSrcweir : SvXMLImportContext( rImport, nPrefix, rLocalName )
824cdf0e10cSrcweir , m_rPositioning( rPositioning )
825cdf0e10cSrcweir {
826cdf0e10cSrcweir }
827cdf0e10cSrcweir
~SchXMLCoordinateRegionContext()828cdf0e10cSrcweir SchXMLCoordinateRegionContext::~SchXMLCoordinateRegionContext()
829cdf0e10cSrcweir {
830cdf0e10cSrcweir }
831cdf0e10cSrcweir
StartElement(const uno::Reference<xml::sax::XAttributeList> & xAttrList)832cdf0e10cSrcweir void SchXMLCoordinateRegionContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
833cdf0e10cSrcweir {
834cdf0e10cSrcweir // parse attributes
835cdf0e10cSrcweir sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
836cdf0e10cSrcweir
837cdf0e10cSrcweir for( sal_Int16 i = 0; i < nAttrCount; i++ )
838cdf0e10cSrcweir {
839cdf0e10cSrcweir rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
840cdf0e10cSrcweir rtl::OUString aLocalName;
841cdf0e10cSrcweir rtl::OUString aValue = xAttrList->getValueByIndex( i );
842cdf0e10cSrcweir sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
843cdf0e10cSrcweir m_rPositioning.readPositioningAttribute( nPrefix, aLocalName, aValue );
844cdf0e10cSrcweir }
845cdf0e10cSrcweir }
846cdf0e10cSrcweir
847cdf0e10cSrcweir // ========================================
848cdf0e10cSrcweir
SchXMLWallFloorContext(SchXMLImportHelper & rImpHelper,SvXMLImport & rImport,sal_uInt16 nPrefix,const rtl::OUString & rLocalName,uno::Reference<chart::XDiagram> & xDiagram,ContextType eContextType)849cdf0e10cSrcweir SchXMLWallFloorContext::SchXMLWallFloorContext(
850cdf0e10cSrcweir SchXMLImportHelper& rImpHelper,
851cdf0e10cSrcweir SvXMLImport& rImport,
852cdf0e10cSrcweir sal_uInt16 nPrefix,
853cdf0e10cSrcweir const rtl::OUString& rLocalName,
854cdf0e10cSrcweir uno::Reference< chart::XDiagram >& xDiagram,
855cdf0e10cSrcweir ContextType eContextType ) :
856cdf0e10cSrcweir SvXMLImportContext( rImport, nPrefix, rLocalName ),
857cdf0e10cSrcweir mrImportHelper( rImpHelper ),
858cdf0e10cSrcweir mxWallFloorSupplier( xDiagram, uno::UNO_QUERY ),
859cdf0e10cSrcweir meContextType( eContextType )
860cdf0e10cSrcweir {
861cdf0e10cSrcweir }
862cdf0e10cSrcweir
~SchXMLWallFloorContext()863cdf0e10cSrcweir SchXMLWallFloorContext::~SchXMLWallFloorContext()
864cdf0e10cSrcweir {
865cdf0e10cSrcweir }
866cdf0e10cSrcweir
StartElement(const uno::Reference<xml::sax::XAttributeList> & xAttrList)867cdf0e10cSrcweir void SchXMLWallFloorContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
868cdf0e10cSrcweir {
869cdf0e10cSrcweir if( mxWallFloorSupplier.is())
870cdf0e10cSrcweir {
871cdf0e10cSrcweir sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
872cdf0e10cSrcweir rtl::OUString sAutoStyleName;
873cdf0e10cSrcweir
874cdf0e10cSrcweir for( sal_Int16 i = 0; i < nAttrCount; i++ )
875cdf0e10cSrcweir {
876cdf0e10cSrcweir rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
877cdf0e10cSrcweir rtl::OUString aLocalName;
878cdf0e10cSrcweir sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
879cdf0e10cSrcweir
880cdf0e10cSrcweir if( nPrefix == XML_NAMESPACE_CHART &&
881cdf0e10cSrcweir IsXMLToken( aLocalName, XML_STYLE_NAME ) )
882cdf0e10cSrcweir {
883cdf0e10cSrcweir sAutoStyleName = xAttrList->getValueByIndex( i );
884cdf0e10cSrcweir }
885cdf0e10cSrcweir }
886cdf0e10cSrcweir
887cdf0e10cSrcweir // set properties
888cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProp( ( meContextType == CONTEXT_TYPE_WALL )
889cdf0e10cSrcweir ? mxWallFloorSupplier->getWall()
890cdf0e10cSrcweir : mxWallFloorSupplier->getFloor(),
891cdf0e10cSrcweir uno::UNO_QUERY );
892cdf0e10cSrcweir if( xProp.is())
893cdf0e10cSrcweir {
894cdf0e10cSrcweir if( sAutoStyleName.getLength())
895cdf0e10cSrcweir {
896cdf0e10cSrcweir const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext();
897cdf0e10cSrcweir if( pStylesCtxt )
898cdf0e10cSrcweir {
899cdf0e10cSrcweir const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext(
900cdf0e10cSrcweir mrImportHelper.GetChartFamilyID(), sAutoStyleName );
901cdf0e10cSrcweir
902cdf0e10cSrcweir if( pStyle && pStyle->ISA( XMLPropStyleContext ))
903cdf0e10cSrcweir (( XMLPropStyleContext* )pStyle )->FillPropertySet( xProp );
904cdf0e10cSrcweir }
905cdf0e10cSrcweir }
906cdf0e10cSrcweir }
907cdf0e10cSrcweir }
908cdf0e10cSrcweir }
909cdf0e10cSrcweir
910cdf0e10cSrcweir // ========================================
911cdf0e10cSrcweir
SchXMLStockContext(SchXMLImportHelper & rImpHelper,SvXMLImport & rImport,sal_uInt16 nPrefix,const rtl::OUString & rLocalName,uno::Reference<chart::XDiagram> & xDiagram,ContextType eContextType)912cdf0e10cSrcweir SchXMLStockContext::SchXMLStockContext(
913cdf0e10cSrcweir SchXMLImportHelper& rImpHelper,
914cdf0e10cSrcweir SvXMLImport& rImport,
915cdf0e10cSrcweir sal_uInt16 nPrefix,
916cdf0e10cSrcweir const rtl::OUString& rLocalName,
917cdf0e10cSrcweir uno::Reference< chart::XDiagram >& xDiagram,
918cdf0e10cSrcweir ContextType eContextType ) :
919cdf0e10cSrcweir SvXMLImportContext( rImport, nPrefix, rLocalName ),
920cdf0e10cSrcweir mrImportHelper( rImpHelper ),
921cdf0e10cSrcweir mxStockPropProvider( xDiagram, uno::UNO_QUERY ),
922cdf0e10cSrcweir meContextType( eContextType )
923cdf0e10cSrcweir {
924cdf0e10cSrcweir }
925cdf0e10cSrcweir
~SchXMLStockContext()926cdf0e10cSrcweir SchXMLStockContext::~SchXMLStockContext()
927cdf0e10cSrcweir {
928cdf0e10cSrcweir }
929cdf0e10cSrcweir
StartElement(const uno::Reference<xml::sax::XAttributeList> & xAttrList)930cdf0e10cSrcweir void SchXMLStockContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
931cdf0e10cSrcweir {
932cdf0e10cSrcweir if( mxStockPropProvider.is())
933cdf0e10cSrcweir {
934cdf0e10cSrcweir sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
935cdf0e10cSrcweir rtl::OUString sAutoStyleName;
936cdf0e10cSrcweir
937cdf0e10cSrcweir for( sal_Int16 i = 0; i < nAttrCount; i++ )
938cdf0e10cSrcweir {
939cdf0e10cSrcweir rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
940cdf0e10cSrcweir rtl::OUString aLocalName;
941cdf0e10cSrcweir sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
942cdf0e10cSrcweir
943cdf0e10cSrcweir if( nPrefix == XML_NAMESPACE_CHART &&
944cdf0e10cSrcweir IsXMLToken( aLocalName, XML_STYLE_NAME ) )
945cdf0e10cSrcweir {
946cdf0e10cSrcweir sAutoStyleName = xAttrList->getValueByIndex( i );
947cdf0e10cSrcweir }
948cdf0e10cSrcweir }
949cdf0e10cSrcweir
950cdf0e10cSrcweir if( sAutoStyleName.getLength())
951cdf0e10cSrcweir {
952cdf0e10cSrcweir // set properties
953cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProp;
954cdf0e10cSrcweir switch( meContextType )
955cdf0e10cSrcweir {
956cdf0e10cSrcweir case CONTEXT_TYPE_GAIN:
957cdf0e10cSrcweir xProp = mxStockPropProvider->getUpBar();
958cdf0e10cSrcweir break;
959cdf0e10cSrcweir case CONTEXT_TYPE_LOSS:
960cdf0e10cSrcweir xProp = mxStockPropProvider->getDownBar();
961cdf0e10cSrcweir break;
962cdf0e10cSrcweir case CONTEXT_TYPE_RANGE:
963cdf0e10cSrcweir xProp = mxStockPropProvider->getMinMaxLine();
964cdf0e10cSrcweir break;
965cdf0e10cSrcweir }
966cdf0e10cSrcweir if( xProp.is())
967cdf0e10cSrcweir {
968cdf0e10cSrcweir const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext();
969cdf0e10cSrcweir if( pStylesCtxt )
970cdf0e10cSrcweir {
971cdf0e10cSrcweir const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext(
972cdf0e10cSrcweir mrImportHelper.GetChartFamilyID(), sAutoStyleName );
973cdf0e10cSrcweir
974cdf0e10cSrcweir if( pStyle && pStyle->ISA( XMLPropStyleContext ))
975cdf0e10cSrcweir (( XMLPropStyleContext* )pStyle )->FillPropertySet( xProp );
976cdf0e10cSrcweir }
977cdf0e10cSrcweir }
978cdf0e10cSrcweir }
979cdf0e10cSrcweir }
980cdf0e10cSrcweir }
981cdf0e10cSrcweir
982cdf0e10cSrcweir // ========================================
983cdf0e10cSrcweir
SchXMLStatisticsObjectContext(SchXMLImportHelper & rImpHelper,SvXMLImport & rImport,sal_uInt16 nPrefix,const rtl::OUString & rLocalName,::std::list<DataRowPointStyle> & rStyleList,const::com::sun::star::uno::Reference<::com::sun::star::chart2::XDataSeries> & xSeries,ContextType eContextType,const awt::Size & rChartSize)984cdf0e10cSrcweir SchXMLStatisticsObjectContext::SchXMLStatisticsObjectContext(
985cdf0e10cSrcweir
986cdf0e10cSrcweir SchXMLImportHelper& rImpHelper,
987cdf0e10cSrcweir SvXMLImport& rImport,
988cdf0e10cSrcweir sal_uInt16 nPrefix,
989cdf0e10cSrcweir const rtl::OUString& rLocalName,
990cdf0e10cSrcweir ::std::list< DataRowPointStyle >& rStyleList,
991cdf0e10cSrcweir const ::com::sun::star::uno::Reference<
992cdf0e10cSrcweir ::com::sun::star::chart2::XDataSeries >& xSeries,
993cdf0e10cSrcweir ContextType eContextType,
994cdf0e10cSrcweir const awt::Size & rChartSize ) :
995cdf0e10cSrcweir
996cdf0e10cSrcweir SvXMLImportContext( rImport, nPrefix, rLocalName ),
997cdf0e10cSrcweir mrImportHelper( rImpHelper ),
998cdf0e10cSrcweir mrStyleList( rStyleList ),
999cdf0e10cSrcweir m_xSeries( xSeries ),
1000cdf0e10cSrcweir meContextType( eContextType ),
1001cdf0e10cSrcweir maChartSize( rChartSize )
1002cdf0e10cSrcweir {}
1003cdf0e10cSrcweir
~SchXMLStatisticsObjectContext()1004cdf0e10cSrcweir SchXMLStatisticsObjectContext::~SchXMLStatisticsObjectContext()
1005cdf0e10cSrcweir {
1006cdf0e10cSrcweir }
1007cdf0e10cSrcweir
StartElement(const uno::Reference<xml::sax::XAttributeList> & xAttrList)1008cdf0e10cSrcweir void SchXMLStatisticsObjectContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
1009cdf0e10cSrcweir {
1010cdf0e10cSrcweir sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
1011cdf0e10cSrcweir ::rtl::OUString aValue;
1012cdf0e10cSrcweir ::rtl::OUString sAutoStyleName;
1013cdf0e10cSrcweir
1014cdf0e10cSrcweir for( sal_Int16 i = 0; i < nAttrCount; i++ )
1015cdf0e10cSrcweir {
1016cdf0e10cSrcweir rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
1017cdf0e10cSrcweir rtl::OUString aLocalName;
1018cdf0e10cSrcweir sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
1019cdf0e10cSrcweir
1020cdf0e10cSrcweir if( nPrefix == XML_NAMESPACE_CHART )
1021cdf0e10cSrcweir {
1022cdf0e10cSrcweir if( IsXMLToken( aLocalName, XML_STYLE_NAME ) )
1023cdf0e10cSrcweir sAutoStyleName = xAttrList->getValueByIndex( i );
1024cdf0e10cSrcweir }
1025cdf0e10cSrcweir }
1026cdf0e10cSrcweir
1027cdf0e10cSrcweir // note: regression-curves must get a style-object even if there is no
1028cdf0e10cSrcweir // auto-style set, because they can contain an equation
1029cdf0e10cSrcweir if( sAutoStyleName.getLength() || meContextType == CONTEXT_TYPE_REGRESSION_CURVE )
1030cdf0e10cSrcweir {
1031cdf0e10cSrcweir DataRowPointStyle::StyleType eType = DataRowPointStyle::MEAN_VALUE;
1032cdf0e10cSrcweir switch( meContextType )
1033cdf0e10cSrcweir {
1034cdf0e10cSrcweir case CONTEXT_TYPE_MEAN_VALUE_LINE:
1035cdf0e10cSrcweir eType = DataRowPointStyle::MEAN_VALUE;
1036cdf0e10cSrcweir break;
1037cdf0e10cSrcweir case CONTEXT_TYPE_REGRESSION_CURVE:
1038cdf0e10cSrcweir eType = DataRowPointStyle::REGRESSION;
1039cdf0e10cSrcweir break;
1040cdf0e10cSrcweir case CONTEXT_TYPE_ERROR_INDICATOR:
1041cdf0e10cSrcweir eType = DataRowPointStyle::ERROR_INDICATOR;
1042cdf0e10cSrcweir break;
1043cdf0e10cSrcweir }
1044cdf0e10cSrcweir DataRowPointStyle aStyle(
1045cdf0e10cSrcweir eType, m_xSeries, -1, 1, sAutoStyleName );
1046cdf0e10cSrcweir mrStyleList.push_back( aStyle );
1047cdf0e10cSrcweir }
1048cdf0e10cSrcweir }
1049cdf0e10cSrcweir
CreateChildContext(sal_uInt16 nPrefix,const rtl::OUString & rLocalName,const uno::Reference<xml::sax::XAttributeList> & xAttrList)1050cdf0e10cSrcweir SvXMLImportContext* SchXMLStatisticsObjectContext::CreateChildContext(
1051cdf0e10cSrcweir sal_uInt16 nPrefix,
1052cdf0e10cSrcweir const rtl::OUString& rLocalName,
1053cdf0e10cSrcweir const uno::Reference< xml::sax::XAttributeList >& xAttrList )
1054cdf0e10cSrcweir {
1055cdf0e10cSrcweir SvXMLImportContext* pContext = 0;
1056cdf0e10cSrcweir
1057cdf0e10cSrcweir if( nPrefix == XML_NAMESPACE_CHART &&
1058cdf0e10cSrcweir IsXMLToken( rLocalName, XML_EQUATION ) )
1059cdf0e10cSrcweir {
1060cdf0e10cSrcweir pContext = new SchXMLEquationContext(
1061cdf0e10cSrcweir mrImportHelper, GetImport(), nPrefix, rLocalName, m_xSeries, maChartSize, mrStyleList.back());
1062cdf0e10cSrcweir }
1063cdf0e10cSrcweir else
1064cdf0e10cSrcweir {
1065cdf0e10cSrcweir pContext = SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList );
1066cdf0e10cSrcweir }
1067cdf0e10cSrcweir
1068cdf0e10cSrcweir return pContext;
1069cdf0e10cSrcweir }
1070cdf0e10cSrcweir
1071cdf0e10cSrcweir // ========================================
1072cdf0e10cSrcweir
SchXMLEquationContext(SchXMLImportHelper & rImpHelper,SvXMLImport & rImport,sal_uInt16 nPrefix,const rtl::OUString & rLocalName,const::com::sun::star::uno::Reference<::com::sun::star::chart2::XDataSeries> & xSeries,const awt::Size & rChartSize,DataRowPointStyle & rRegressionStyle)1073cdf0e10cSrcweir SchXMLEquationContext::SchXMLEquationContext(
1074cdf0e10cSrcweir SchXMLImportHelper& rImpHelper,
1075cdf0e10cSrcweir SvXMLImport& rImport,
1076cdf0e10cSrcweir sal_uInt16 nPrefix,
1077cdf0e10cSrcweir const rtl::OUString& rLocalName,
1078cdf0e10cSrcweir const ::com::sun::star::uno::Reference<
1079cdf0e10cSrcweir ::com::sun::star::chart2::XDataSeries >& xSeries,
1080cdf0e10cSrcweir const awt::Size & rChartSize,
1081cdf0e10cSrcweir DataRowPointStyle & rRegressionStyle ) :
1082cdf0e10cSrcweir SvXMLImportContext( rImport, nPrefix, rLocalName ),
1083cdf0e10cSrcweir mrImportHelper( rImpHelper ),
1084cdf0e10cSrcweir mrRegressionStyle( rRegressionStyle ),
1085cdf0e10cSrcweir m_xSeries( xSeries ),
1086cdf0e10cSrcweir maChartSize( rChartSize )
1087cdf0e10cSrcweir {}
1088cdf0e10cSrcweir
~SchXMLEquationContext()1089cdf0e10cSrcweir SchXMLEquationContext::~SchXMLEquationContext()
1090cdf0e10cSrcweir {}
1091cdf0e10cSrcweir
StartElement(const uno::Reference<xml::sax::XAttributeList> & xAttrList)1092cdf0e10cSrcweir void SchXMLEquationContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
1093cdf0e10cSrcweir {
1094cdf0e10cSrcweir // parse attributes
1095cdf0e10cSrcweir sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
1096cdf0e10cSrcweir SchXMLImport& rImport = ( SchXMLImport& )GetImport();
1097cdf0e10cSrcweir const SvXMLTokenMap& rAttrTokenMap = mrImportHelper.GetRegEquationAttrTokenMap();
1098cdf0e10cSrcweir OUString sAutoStyleName;
1099cdf0e10cSrcweir
1100cdf0e10cSrcweir sal_Bool bShowEquation = sal_True;
1101cdf0e10cSrcweir sal_Bool bShowRSquare = sal_False;
1102cdf0e10cSrcweir awt::Point aPosition;
1103cdf0e10cSrcweir bool bHasXPos = false;
1104cdf0e10cSrcweir bool bHasYPos = false;
1105cdf0e10cSrcweir
1106cdf0e10cSrcweir for( sal_Int16 i = 0; i < nAttrCount; i++ )
1107cdf0e10cSrcweir {
1108cdf0e10cSrcweir rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
1109cdf0e10cSrcweir rtl::OUString aLocalName;
1110cdf0e10cSrcweir rtl::OUString aValue = xAttrList->getValueByIndex( i );
1111cdf0e10cSrcweir sal_uInt16 nPrefix = rImport.GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
1112cdf0e10cSrcweir
1113cdf0e10cSrcweir switch( rAttrTokenMap.Get( nPrefix, aLocalName ))
1114cdf0e10cSrcweir {
1115cdf0e10cSrcweir case XML_TOK_REGEQ_POS_X:
1116cdf0e10cSrcweir rImport.GetMM100UnitConverter().convertMeasure( aPosition.X, aValue );
1117cdf0e10cSrcweir bHasXPos = true;
1118cdf0e10cSrcweir break;
1119cdf0e10cSrcweir case XML_TOK_REGEQ_POS_Y:
1120cdf0e10cSrcweir rImport.GetMM100UnitConverter().convertMeasure( aPosition.Y, aValue );
1121cdf0e10cSrcweir bHasYPos = true;
1122cdf0e10cSrcweir break;
1123cdf0e10cSrcweir case XML_TOK_REGEQ_DISPLAY_EQUATION:
1124cdf0e10cSrcweir rImport.GetMM100UnitConverter().convertBool( bShowEquation, aValue );
1125cdf0e10cSrcweir break;
1126cdf0e10cSrcweir case XML_TOK_REGEQ_DISPLAY_R_SQUARE:
1127cdf0e10cSrcweir rImport.GetMM100UnitConverter().convertBool( bShowRSquare, aValue );
1128cdf0e10cSrcweir break;
1129cdf0e10cSrcweir case XML_TOK_REGEQ_STYLE_NAME:
1130cdf0e10cSrcweir sAutoStyleName = aValue;
1131cdf0e10cSrcweir break;
1132cdf0e10cSrcweir }
1133cdf0e10cSrcweir }
1134cdf0e10cSrcweir
1135cdf0e10cSrcweir if( sAutoStyleName.getLength() || bShowEquation || bShowRSquare )
1136cdf0e10cSrcweir {
1137cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xEqProp;
1138cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xFact( comphelper::getProcessServiceFactory(), uno::UNO_QUERY );
1139cdf0e10cSrcweir if( xFact.is())
1140cdf0e10cSrcweir xEqProp.set( xFact->createInstance(
1141cdf0e10cSrcweir ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.chart2.RegressionEquation" ))), uno::UNO_QUERY );
1142cdf0e10cSrcweir if( xEqProp.is())
1143cdf0e10cSrcweir {
1144cdf0e10cSrcweir if( sAutoStyleName.getLength() )
1145cdf0e10cSrcweir {
1146cdf0e10cSrcweir const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext();
1147cdf0e10cSrcweir if( pStylesCtxt )
1148cdf0e10cSrcweir {
1149cdf0e10cSrcweir const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext(
1150cdf0e10cSrcweir mrImportHelper.GetChartFamilyID(), sAutoStyleName );
1151cdf0e10cSrcweir // note: SvXMLStyleContext::FillPropertySet is not const
1152cdf0e10cSrcweir XMLPropStyleContext * pPropStyleContext =
1153cdf0e10cSrcweir const_cast< XMLPropStyleContext * >( dynamic_cast< const XMLPropStyleContext * >( pStyle ));
1154cdf0e10cSrcweir
1155cdf0e10cSrcweir if( pPropStyleContext )
1156cdf0e10cSrcweir pPropStyleContext->FillPropertySet( xEqProp );
1157cdf0e10cSrcweir }
1158cdf0e10cSrcweir }
1159cdf0e10cSrcweir xEqProp->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("ShowEquation")), uno::makeAny( bShowEquation ));
1160cdf0e10cSrcweir xEqProp->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("ShowCorrelationCoefficient")), uno::makeAny( bShowRSquare ));
1161cdf0e10cSrcweir
1162cdf0e10cSrcweir if( bHasXPos && bHasYPos )
1163cdf0e10cSrcweir {
1164cdf0e10cSrcweir chart2::RelativePosition aRelPos;
1165cdf0e10cSrcweir aRelPos.Primary = static_cast< double >( aPosition.X ) / static_cast< double >( maChartSize.Width );
1166cdf0e10cSrcweir aRelPos.Secondary = static_cast< double >( aPosition.Y ) / static_cast< double >( maChartSize.Height );
1167cdf0e10cSrcweir xEqProp->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "RelativePosition" )),
1168cdf0e10cSrcweir uno::makeAny( aRelPos ));
1169cdf0e10cSrcweir }
1170cdf0e10cSrcweir OSL_ASSERT( mrRegressionStyle.meType == DataRowPointStyle::REGRESSION );
1171cdf0e10cSrcweir mrRegressionStyle.m_xEquationProperties.set( xEqProp );
1172cdf0e10cSrcweir }
1173cdf0e10cSrcweir }
1174cdf0e10cSrcweir }
1175