summaryrefslogtreecommitdiff
path: root/xmloff/source/chart
diff options
context:
space:
mode:
Diffstat (limited to 'xmloff/source/chart')
-rw-r--r--xmloff/source/chart/ColorPropertySet.cxx225
-rw-r--r--xmloff/source/chart/ColorPropertySet.hxx126
-rw-r--r--xmloff/source/chart/MultiPropertySetHandler.hxx294
-rw-r--r--xmloff/source/chart/PropertyMap.hxx325
-rw-r--r--xmloff/source/chart/PropertyMaps.cxx618
-rw-r--r--xmloff/source/chart/SchXMLAutoStylePoolP.cxx91
-rw-r--r--xmloff/source/chart/SchXMLAutoStylePoolP.hxx53
-rwxr-xr-xxmloff/source/chart/SchXMLCalculationSettingsContext.cxx86
-rwxr-xr-xxmloff/source/chart/SchXMLCalculationSettingsContext.hxx51
-rw-r--r--xmloff/source/chart/SchXMLChartContext.cxx1432
-rw-r--r--xmloff/source/chart/SchXMLChartContext.hxx189
-rw-r--r--xmloff/source/chart/SchXMLExport.cxx4037
-rw-r--r--xmloff/source/chart/SchXMLImport.cxx960
-rw-r--r--xmloff/source/chart/SchXMLParagraphContext.cxx118
-rw-r--r--xmloff/source/chart/SchXMLParagraphContext.hxx64
-rw-r--r--xmloff/source/chart/SchXMLPlotAreaContext.cxx2130
-rw-r--r--xmloff/source/chart/SchXMLPlotAreaContext.hxx391
-rw-r--r--xmloff/source/chart/SchXMLSeries2Context.cxx1073
-rw-r--r--xmloff/source/chart/SchXMLSeries2Context.hxx135
-rw-r--r--xmloff/source/chart/SchXMLSeriesHelper.cxx301
-rw-r--r--xmloff/source/chart/SchXMLSeriesHelper.hxx80
-rw-r--r--xmloff/source/chart/SchXMLTableContext.cxx1218
-rw-r--r--xmloff/source/chart/SchXMLTableContext.hxx229
-rwxr-xr-xxmloff/source/chart/SchXMLTextListContext.cxx136
-rwxr-xr-xxmloff/source/chart/SchXMLTextListContext.hxx58
-rw-r--r--xmloff/source/chart/SchXMLTools.cxx897
-rw-r--r--xmloff/source/chart/SchXMLTools.hxx152
-rw-r--r--xmloff/source/chart/XMLAxisPositionPropertyHdl.cxx128
-rw-r--r--xmloff/source/chart/XMLAxisPositionPropertyHdl.hxx45
-rw-r--r--xmloff/source/chart/XMLChartPropertyContext.cxx82
-rw-r--r--xmloff/source/chart/XMLChartPropertyContext.hxx58
-rw-r--r--xmloff/source/chart/XMLChartStyleContext.cxx161
-rw-r--r--xmloff/source/chart/XMLErrorBarStylePropertyHdl.cxx68
-rw-r--r--xmloff/source/chart/XMLErrorBarStylePropertyHdl.hxx41
-rw-r--r--xmloff/source/chart/XMLErrorIndicatorPropertyHdl.cxx105
-rw-r--r--xmloff/source/chart/XMLErrorIndicatorPropertyHdl.hxx46
-rw-r--r--xmloff/source/chart/XMLLabelSeparatorContext.cxx87
-rw-r--r--xmloff/source/chart/XMLLabelSeparatorContext.hxx54
-rw-r--r--xmloff/source/chart/XMLSymbolImageContext.cxx150
-rw-r--r--xmloff/source/chart/XMLSymbolImageContext.hxx59
-rw-r--r--xmloff/source/chart/XMLSymbolTypePropertyHdl.cxx170
-rw-r--r--xmloff/source/chart/XMLSymbolTypePropertyHdl.hxx46
-rw-r--r--xmloff/source/chart/XMLTextOrientationHdl.cxx80
-rw-r--r--xmloff/source/chart/XMLTextOrientationHdl.hxx46
-rw-r--r--xmloff/source/chart/contexts.cxx233
-rw-r--r--xmloff/source/chart/contexts.hxx115
-rw-r--r--xmloff/source/chart/makefile.mk70
-rw-r--r--xmloff/source/chart/transporttypes.cxx38
-rw-r--r--xmloff/source/chart/transporttypes.hxx222
49 files changed, 17573 insertions, 0 deletions
diff --git a/xmloff/source/chart/ColorPropertySet.cxx b/xmloff/source/chart/ColorPropertySet.cxx
new file mode 100644
index 000000000000..e65f00ef135f
--- /dev/null
+++ b/xmloff/source/chart/ColorPropertySet.cxx
@@ -0,0 +1,225 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmloff.hxx"
+
+#include "ColorPropertySet.hxx"
+
+#include <cppuhelper/implbase1.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::beans;
+
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::rtl::OUString;
+using ::com::sun::star::uno::RuntimeException;
+
+// ================================================================================
+
+namespace
+{
+class lcl_ColorPropertySetInfo : public ::cppu::WeakImplHelper1<
+ XPropertySetInfo >
+{
+public:
+ lcl_ColorPropertySetInfo( bool bFillColor );
+
+protected:
+ // ____ XPropertySetInfo ____
+ virtual Sequence< Property > SAL_CALL getProperties() throw (RuntimeException);
+ virtual Property SAL_CALL getPropertyByName( const OUString& aName ) throw (UnknownPropertyException, RuntimeException);
+ virtual sal_Bool SAL_CALL hasPropertyByName( const OUString& Name ) throw (RuntimeException);
+
+private:
+ bool m_bIsFillColor;
+ OUString m_aColorPropName;
+ Property m_aColorProp;
+};
+
+lcl_ColorPropertySetInfo::lcl_ColorPropertySetInfo( bool bFillColor ) :
+ m_bIsFillColor( bFillColor ),
+ // note: length of FillColor and LineColor is 9
+ m_aColorPropName( (bFillColor ? "FillColor" : "LineColor"), 9, RTL_TEXTENCODING_ASCII_US ),
+ m_aColorProp( m_aColorPropName, -1,
+ ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), 0)
+{}
+
+Sequence< Property > SAL_CALL lcl_ColorPropertySetInfo::getProperties()
+ throw (RuntimeException)
+{
+
+ return Sequence< Property >( & m_aColorProp, 1 );
+}
+
+Property SAL_CALL lcl_ColorPropertySetInfo::getPropertyByName( const OUString& aName )
+ throw (UnknownPropertyException, RuntimeException)
+{
+ if( aName.equals( m_aColorPropName ))
+ return m_aColorProp;
+ throw UnknownPropertyException( m_aColorPropName, static_cast< uno::XWeak * >( this ));
+}
+
+sal_Bool SAL_CALL lcl_ColorPropertySetInfo::hasPropertyByName( const OUString& Name )
+ throw (RuntimeException)
+{
+ return Name.equals( m_aColorPropName );
+}
+
+} // anonymous namespace
+
+// ================================================================================
+
+namespace xmloff
+{
+namespace chart
+{
+
+ColorPropertySet::ColorPropertySet( sal_Int32 nColor, bool bFillColor /* = true */ ) :
+ // note: length of FillColor and LineColor is 9
+ m_aColorPropName( (bFillColor ? "FillColor" : "LineColor"), 9, RTL_TEXTENCODING_ASCII_US ),
+ m_nColor( nColor ),
+ m_bIsFillColor( bFillColor ),
+ m_nDefaultColor( 0x0099ccff ) // blue 8
+{}
+
+ColorPropertySet::~ColorPropertySet()
+{}
+
+void ColorPropertySet::setColor( sal_Int32 nColor )
+{
+ m_nColor = nColor;
+}
+
+sal_Int32 ColorPropertySet::getColor()
+{
+ return m_nColor;
+}
+
+// ____ XPropertySet ____
+
+Reference< XPropertySetInfo > SAL_CALL ColorPropertySet::getPropertySetInfo()
+ throw (uno::RuntimeException)
+{
+ if( ! m_xInfo.is())
+ m_xInfo.set( new lcl_ColorPropertySetInfo( m_bIsFillColor ));
+
+ return m_xInfo;
+}
+
+void SAL_CALL ColorPropertySet::setPropertyValue( const OUString& /* aPropertyName */, const uno::Any& aValue )
+ throw (UnknownPropertyException,
+ PropertyVetoException,
+ lang::IllegalArgumentException,
+ lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ aValue >>= m_nColor;
+}
+
+uno::Any SAL_CALL ColorPropertySet::getPropertyValue( const OUString& /* PropertyName */ )
+ throw (UnknownPropertyException,
+ lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ return uno::makeAny( m_nColor );
+}
+
+void SAL_CALL ColorPropertySet::addPropertyChangeListener( const OUString& /* aPropertyName */, const Reference< XPropertyChangeListener >& /* xListener */ )
+ throw (UnknownPropertyException,
+ lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ OSL_ENSURE( false, "Not Implemented" );
+ return;
+}
+
+void SAL_CALL ColorPropertySet::removePropertyChangeListener( const OUString& /* aPropertyName */, const Reference< XPropertyChangeListener >& /* aListener */ )
+ throw (UnknownPropertyException,
+ lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ OSL_ENSURE( false, "Not Implemented" );
+ return;
+}
+
+void SAL_CALL ColorPropertySet::addVetoableChangeListener( const OUString& /* PropertyName */, const Reference< XVetoableChangeListener >& /* aListener */ )
+ throw (UnknownPropertyException,
+ lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ OSL_ENSURE( false, "Not Implemented" );
+ return;
+}
+
+void SAL_CALL ColorPropertySet::removeVetoableChangeListener( const OUString& /* PropertyName */, const Reference< XVetoableChangeListener >& /* aListener */ )
+ throw (UnknownPropertyException,
+ lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ OSL_ENSURE( false, "Not Implemented" );
+ return;
+}
+
+// ____ XPropertyState ____
+
+PropertyState SAL_CALL ColorPropertySet::getPropertyState( const OUString& /* PropertyName */ )
+ throw (UnknownPropertyException,
+ uno::RuntimeException)
+{
+ return PropertyState_DIRECT_VALUE;
+}
+
+Sequence< PropertyState > SAL_CALL ColorPropertySet::getPropertyStates( const Sequence< OUString >& /* aPropertyName */ )
+ throw (UnknownPropertyException,
+ uno::RuntimeException)
+{
+ PropertyState aState = PropertyState_DIRECT_VALUE;
+ return Sequence< PropertyState >( & aState, 1 );
+}
+
+void SAL_CALL ColorPropertySet::setPropertyToDefault( const OUString& PropertyName )
+ throw (UnknownPropertyException,
+ uno::RuntimeException)
+{
+ if( PropertyName.equals( m_aColorPropName ))
+ m_nColor = m_nDefaultColor;
+}
+
+uno::Any SAL_CALL ColorPropertySet::getPropertyDefault( const OUString& aPropertyName )
+ throw (UnknownPropertyException,
+ lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ if( aPropertyName.equals( m_aColorPropName ))
+ return uno::makeAny( m_nDefaultColor );
+ return uno::Any();
+}
+
+} // namespace chart
+} // namespace xmloff
diff --git a/xmloff/source/chart/ColorPropertySet.hxx b/xmloff/source/chart/ColorPropertySet.hxx
new file mode 100644
index 000000000000..32d11182c3b2
--- /dev/null
+++ b/xmloff/source/chart/ColorPropertySet.hxx
@@ -0,0 +1,126 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef XMLOFF_COLORPROPERTYSET_HXX
+#define XMLOFF_COLORPROPERTYSET_HXX
+
+#include <cppuhelper/implbase2.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XPropertyState.hpp>
+
+namespace xmloff
+{
+namespace chart
+{
+
+class ColorPropertySet : public ::cppu::WeakImplHelper2<
+ ::com::sun::star::beans::XPropertySet,
+ ::com::sun::star::beans::XPropertyState >
+{
+public:
+ // if bFillColor == false, the color is a LineColor
+ explicit ColorPropertySet( sal_Int32 nColor, bool bFillColor = true );
+ virtual ~ColorPropertySet();
+
+ void setColor( sal_Int32 nColor );
+ sal_Int32 getColor();
+
+protected:
+ // ____ XPropertySet ____
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPropertyValue(
+ const ::rtl::OUString& aPropertyName,
+ const ::com::sun::star::uno::Any& aValue )
+ throw (::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::beans::PropertyVetoException,
+ ::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
+ const ::rtl::OUString& PropertyName )
+ throw (::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addPropertyChangeListener(
+ const ::rtl::OUString& aPropertyName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener )
+ throw (::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removePropertyChangeListener(
+ const ::rtl::OUString& aPropertyName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener )
+ throw (::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addVetoableChangeListener(
+ const ::rtl::OUString& PropertyName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener )
+ throw (::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeVetoableChangeListener(
+ const ::rtl::OUString& PropertyName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener )
+ throw (::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
+
+ // ____ XPropertyState ____
+ virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState(
+ const ::rtl::OUString& PropertyName )
+ throw (::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates(
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyName )
+ throw (::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPropertyToDefault(
+ const ::rtl::OUString& PropertyName )
+ throw (::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault(
+ const ::rtl::OUString& aPropertyName )
+ throw (::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
+
+private:
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySetInfo > m_xInfo;
+ ::rtl::OUString m_aColorPropName;
+ sal_Int32 m_nColor;
+ bool m_bIsFillColor;
+ sal_Int32 m_nDefaultColor;
+};
+
+} // namespace chart
+} // namespace xmloff
+
+// XMLOFF_COLORPROPERTYSET_HXX
+#endif
diff --git a/xmloff/source/chart/MultiPropertySetHandler.hxx b/xmloff/source/chart/MultiPropertySetHandler.hxx
new file mode 100644
index 000000000000..a0ccf8a1c92b
--- /dev/null
+++ b/xmloff/source/chart/MultiPropertySetHandler.hxx
@@ -0,0 +1,294 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _MULTI_PROPERTY_SET_HANDLER_HXX
+#define _MULTI_PROPERTY_SET_HANDLER_HXX
+
+#include <rtl/ustring.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XMultiPropertySet.hpp>
+
+
+/** @descr MultiPropertySetHandler handles the two slightly different
+ interfaces XPropertySet and XMultiPorpertySet for accessing
+ properties of an object.
+
+ It uses the classes PropertyWrapperBase and the template
+ PropertyWrapper for a type safe access to single properties.
+
+ The function class OUStringComparison is used by a STL map to
+ sort the properties by names.
+*/
+
+/** @descr Base class for the templated property wrappers.
+ Having a common base class allows to set a variable to the
+ property's value without explicit knowledge of its type.
+*/
+class PropertyWrapperBase
+{
+public:
+ /** @descr Create a class instance and store the given name.
+ @param rName The name of the property.
+ */
+ PropertyWrapperBase (const ::rtl::OUString & rName)
+ : msName (rName)
+ {}
+ virtual ~PropertyWrapperBase()
+ {}
+
+ /** @descr Abstract interface of a method for setting a variables
+ value to that of the property.
+ */
+ virtual void SetValue (const ::com::sun::star::uno::Any & rValue) = 0;
+
+ const ::rtl::OUString msName;
+};
+
+
+
+
+/** @descr For every property type there will be one instantiation of this
+ template class with its own and type specific version of SetValue.
+*/
+template<class T> class PropertyWrapper : public PropertyWrapperBase
+{
+public:
+ /** @descr Create a wrapper for a property of type T.
+ */
+ PropertyWrapper (const ::rtl::OUString & rName, T & rValue)
+ : PropertyWrapperBase (rName),
+ mrValue (rValue)
+ {}
+
+ /** descr Set the given value inside an Any to the variable referenced
+ by the data member.
+ */
+ virtual void SetValue (const ::com::sun::star::uno::Any & rValue)
+ {
+ rValue >>= mrValue;
+ }
+
+private:
+ /// Reference to a variable. Its value can be modified by a call to SetValue.
+ T & mrValue;
+};
+
+
+
+
+/** @descr Function object for comparing two OUStrings.
+*/
+class OUStringComparison
+{
+public:
+ /// Compare two strings. Returns true if the first is before the second.
+ inline bool operator() (const ::rtl::OUString & a, const ::rtl::OUString & b) const
+ {
+ return (a.compareTo (b) < 0);
+ }
+};
+
+
+
+
+/** @descr This class lets you get the values from an object that either
+ supports the interface XPropertySet or XMultiPropertySet. If it
+ supports both interfaces then XMultiPropertySet is preferred.
+
+ Using it works in three steps.
+ 1. Create an instance and pass a reference to the object from which to
+ get the property values.
+ 2. Make all properties whose values you want to get known to the object
+ by using the Add method. This creates instances of a template class
+ that stores the properties name and a reference to the variable in
+ which to store its value.
+ 3. Finally call GetProperties to store the properties values into the
+ variables specified in step 2. This uses either the XPropertySet or
+ (preferred) the XMultiPropertySet interface.
+*/
+class MultiPropertySetHandler
+{
+public:
+ /** @descr Create a handler of the property set of the given
+ object.
+ @param xObject A reference to any of the object's interfaces.
+ not neccessarily XPropertySet or XMultiPropertySet. It
+ is casted later to one of the two of them.
+ */
+ MultiPropertySetHandler (::com::sun::star::uno::Reference<
+ ::com::sun::star::uno::XInterface> xObject);
+ ~MultiPropertySetHandler (void);
+ /** @descr Add a property to handle. The type given implicitely by the
+ reference to a variable is used to create an instance of
+ the PropertyWrapper template class.
+ @param sName Name of the property.
+ @param rValue Reference to a variable whose value is set by the
+ call to GetProperties to the property's value.
+ */
+ template<class T> void Add (const ::rtl::OUString & sName, T& rValue)
+ {
+ aPropertyList[sName] = new PropertyWrapper<T> (sName, rValue);
+ }
+
+ /** @descr Try to get the values for all properties added with the Add
+ method. If possible it uses the XMultiPropertySet. If that fails
+ (i.e. for an UnknownPropertyExcption) or if the interface is not
+ supported it uses the XPropertySet interface.
+ @return If none of the two interfaces is supported or using them both
+ fails then FALSE is returned. Else True is returned.
+ */
+ inline BOOL GetProperties (void);
+
+private:
+ /** @descr Try to use the XMultiPropertySet interface to get the property
+ values.
+ @param rNameList A precomputed and sorted sequence of OUStrings
+ containing the properties names.
+ @return True if values could be derived.
+ */
+ inline BOOL MultiGet (const ::com::sun::star::uno::Sequence<
+ ::rtl::OUString> & rNameList);
+
+ /** @descr Try to use the XPropertySet interface to get the property
+ values.
+ @param rNameList A precomputed and sorted sequence of OUStrings
+ containing the properties names.
+ @return True if values could be derived.
+ */
+ inline BOOL SingleGet (const ::com::sun::star::uno::Sequence<
+ ::rtl::OUString> & rNameList);
+
+ /** @descr STL map that maps from property names to polymorphic instances of
+ PropertyWrapper. It uses OUStringComparison for sorting
+ the property names.
+ */
+ ::std::map< ::rtl::OUString, PropertyWrapperBase*, OUStringComparison> aPropertyList;
+
+ /// The object from which to get the property values.
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> mxObject;
+};
+
+
+
+//===== Inline implementation of the methods declared above ==========================
+
+MultiPropertySetHandler::MultiPropertySetHandler (::com::sun::star::uno::Reference<
+ ::com::sun::star::uno::XInterface> xObject)
+ : mxObject (xObject)
+{
+}
+
+
+
+
+MultiPropertySetHandler::~MultiPropertySetHandler (void)
+{
+ ::std::map< ::rtl::OUString, PropertyWrapperBase*, OUStringComparison>::iterator I;
+ for (I=aPropertyList.begin(); I!=aPropertyList.end(); I++)
+ delete I->second;
+}
+
+
+/*
+template<class T> void MultiPropertySetHandler::Add (const ::rtl::OUString & sName, T& pValue)
+{
+ aPropertyList[sName] = new PropertyWrapper<T> (sName, pValue);
+}
+*/
+
+
+
+BOOL MultiPropertySetHandler::GetProperties (void)
+{
+ ::std::map< ::rtl::OUString, PropertyWrapperBase*, OUStringComparison>::iterator I;
+ ::com::sun::star::uno::Sequence< ::rtl::OUString> aNameList (aPropertyList.size());
+ int i;
+ for (I=aPropertyList.begin(),i=0; I!=aPropertyList.end(); I++)
+ aNameList[i++] = I->second->msName;
+ if ( ! MultiGet(aNameList))
+ if ( ! SingleGet(aNameList))
+ return FALSE;
+ return TRUE;
+}
+
+
+
+
+BOOL MultiPropertySetHandler::MultiGet (const ::com::sun::star::uno::Sequence<
+ ::rtl::OUString> & rNameList)
+{
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XMultiPropertySet> xMultiSet (
+ mxObject, ::com::sun::star::uno::UNO_QUERY);
+ if (xMultiSet.is())
+ try
+ {
+ ::std::map< ::rtl::OUString, PropertyWrapperBase*, OUStringComparison>::iterator I;
+ int i;
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any> aValueList =
+ xMultiSet->getPropertyValues (rNameList);
+ for (I=aPropertyList.begin(),i=0; I!=aPropertyList.end(); I++)
+ I->second->SetValue (aValueList[i++]);
+ }
+ catch (::com::sun::star::beans::UnknownPropertyException e)
+ {
+ return FALSE;
+ }
+ else
+ return FALSE;
+
+ return TRUE;
+}
+
+
+
+
+BOOL MultiPropertySetHandler::SingleGet (const ::com::sun::star::uno::Sequence<
+ ::rtl::OUString> & rNameList)
+{
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> xSingleSet (
+ mxObject, ::com::sun::star::uno::UNO_QUERY);
+ if (xSingleSet.is())
+ try
+ {
+ ::std::map< ::rtl::OUString, PropertyWrapperBase*, OUStringComparison>::iterator I;
+ int i;
+ for (I=aPropertyList.begin(),i=0; I!=aPropertyList.end(); I++)
+ I->second->SetValue (xSingleSet->getPropertyValue (rNameList[i++]));
+ }
+ catch (::com::sun::star::beans::UnknownPropertyException e)
+ {
+ return FALSE;
+ }
+ else
+ return FALSE;
+
+ return TRUE;
+}
+
+
+#endif
+
diff --git a/xmloff/source/chart/PropertyMap.hxx b/xmloff/source/chart/PropertyMap.hxx
new file mode 100644
index 000000000000..79a59ab6910f
--- /dev/null
+++ b/xmloff/source/chart/PropertyMap.hxx
@@ -0,0 +1,325 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _PROPERTYMAP_HXX_
+#define _PROPERTYMAP_HXX_
+
+#include <xmloff/maptype.hxx>
+#include "xmlnmspe.hxx"
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/xmltypes.hxx>
+#include <xmloff/contextid.hxx>
+#include <xmloff/xmlement.hxx>
+#include <com/sun/star/chart/ChartAxisArrangeOrderType.hpp>
+#include <com/sun/star/chart/ChartAxisLabelPosition.hpp>
+#include <com/sun/star/chart/ChartAxisMarkPosition.hpp>
+#include <com/sun/star/chart/ErrorBarStyle.hpp>
+#include <com/sun/star/chart/ChartErrorIndicatorType.hpp>
+#include <com/sun/star/chart/ChartRegressionCurveType.hpp>
+#include <com/sun/star/chart/ChartSolidType.hpp>
+#include <com/sun/star/chart/ChartDataRowSource.hpp>
+#include <com/sun/star/chart/DataLabelPlacement.hpp>
+#include <com/sun/star/chart/MissingValueTreatment.hpp>
+
+// custom types
+#define XML_SCH_TYPE_AXIS_ARRANGEMENT ( XML_SCH_TYPES_START + 0 )
+#define XML_SCH_TYPE_ERROR_BAR_STYLE ( XML_SCH_TYPES_START + 1 )
+#define XML_SCH_TYPE_REGRESSION_TYPE ( XML_SCH_TYPES_START + 2 )
+#define XML_SCH_TYPE_SOLID_TYPE ( XML_SCH_TYPES_START + 3 )
+#define XML_SCH_TYPE_ERROR_INDICATOR_UPPER ( XML_SCH_TYPES_START + 4 )
+#define XML_SCH_TYPE_ERROR_INDICATOR_LOWER ( XML_SCH_TYPES_START + 5 )
+#define XML_SCH_TYPE_DATAROWSOURCE ( XML_SCH_TYPES_START + 6 )
+#define XML_SCH_TYPE_TEXT_ORIENTATION ( XML_SCH_TYPES_START + 7 )
+#define XML_SCH_TYPE_INTERPOLATION ( XML_SCH_TYPES_START + 8 )
+#define XML_SCH_TYPE_SYMBOL_TYPE ( XML_SCH_TYPES_START + 9 )
+#define XML_SCH_TYPE_NAMED_SYMBOL ( XML_SCH_TYPES_START + 10 )
+#define XML_SCH_TYPE_LABEL_PLACEMENT_TYPE ( XML_SCH_TYPES_START + 11 )
+#define XML_SCH_TYPE_MISSING_VALUE_TREATMENT ( XML_SCH_TYPES_START + 12 )
+#define XML_SCH_TYPE_AXIS_POSITION ( XML_SCH_TYPES_START + 13 )
+#define XML_SCH_TYPE_AXIS_POSITION_VALUE ( XML_SCH_TYPES_START + 14 )
+#define XML_SCH_TYPE_AXIS_LABEL_POSITION ( XML_SCH_TYPES_START + 15 )
+#define XML_SCH_TYPE_TICK_MARK_POSITION ( XML_SCH_TYPES_START + 16 )
+
+// context ids
+#define XML_SCH_CONTEXT_USER_SYMBOL ( XML_SCH_CTF_START + 0 )
+#define XML_SCH_CONTEXT_MIN ( XML_SCH_CTF_START + 1 )
+#define XML_SCH_CONTEXT_MAX ( XML_SCH_CTF_START + 2 )
+#define XML_SCH_CONTEXT_STEP_MAIN ( XML_SCH_CTF_START + 3 )
+#define XML_SCH_CONTEXT_STEP_HELP_COUNT ( XML_SCH_CTF_START + 4 )
+#define XML_SCH_CONTEXT_ORIGIN ( XML_SCH_CTF_START + 5 )
+#define XML_SCH_CONTEXT_LOGARITHMIC ( XML_SCH_CTF_START + 6 )
+#define XML_SCH_CONTEXT_STOCK_WITH_VOLUME ( XML_SCH_CTF_START + 7 )
+#define XML_SCH_CONTEXT_LINES_USED ( XML_SCH_CTF_START + 8 )
+
+#define XML_SCH_CONTEXT_SPECIAL_TICKS_MAJ_INNER ( XML_SCH_CTF_START + 10 )
+#define XML_SCH_CONTEXT_SPECIAL_TICKS_MAJ_OUTER ( XML_SCH_CTF_START + 11 )
+#define XML_SCH_CONTEXT_SPECIAL_TICKS_MIN_INNER ( XML_SCH_CTF_START + 12 )
+#define XML_SCH_CONTEXT_SPECIAL_TICKS_MIN_OUTER ( XML_SCH_CTF_START + 13 )
+#define XML_SCH_CONTEXT_SPECIAL_TEXT_ROTATION ( XML_SCH_CTF_START + 14 )
+#define XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_NUMBER ( XML_SCH_CTF_START + 15 )
+#define XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_TEXT ( XML_SCH_CTF_START + 16 )
+#define XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_SYMBOL ( XML_SCH_CTF_START + 17 )
+#define XML_SCH_CONTEXT_SPECIAL_NUMBER_FORMAT ( XML_SCH_CTF_START + 18 )
+#define XML_SCH_CONTEXT_SPECIAL_DATA_ROW_SOURCE ( XML_SCH_CTF_START + 19 )
+#define XML_SCH_CONTEXT_SPECIAL_SYMBOL_WIDTH ( XML_SCH_CTF_START + 20 )
+#define XML_SCH_CONTEXT_SPECIAL_SYMBOL_HEIGHT ( XML_SCH_CTF_START + 21 )
+#define XML_SCH_CONTEXT_SPECIAL_SYMBOL_IMAGE_NAME ( XML_SCH_CTF_START + 22 )
+#define XML_SCH_CONTEXT_SPECIAL_SYMBOL_IMAGE ( XML_SCH_CTF_START + 23 )
+#define XML_SCH_CONTEXT_SPECIAL_LABEL_SEPARATOR ( XML_SCH_CTF_START + 24 )
+
+#define MAP_FULL( ApiName, NameSpace, XMLTokenName, XMLType, ContextId, EarliestODFVersionForExport ) { ApiName, sizeof(ApiName)-1, XML_NAMESPACE_##NameSpace, xmloff::token::XMLTokenName, XMLType|XML_TYPE_PROP_CHART, ContextId, EarliestODFVersionForExport }
+#define MAP_ENTRY( a, ns, nm, t ) { a, sizeof(a)-1, XML_NAMESPACE_##ns, xmloff::token::nm, t|XML_TYPE_PROP_CHART, 0, SvtSaveOptions::ODFVER_010 }
+#define MAP_ENTRY_ODF12( a, ns, nm, t ) { a, sizeof(a)-1, XML_NAMESPACE_##ns, xmloff::token::nm, t|XML_TYPE_PROP_CHART, 0, SvtSaveOptions::ODFVER_012 }
+#define MAP_CONTEXT( a, ns, nm, t, c ) { a, sizeof(a)-1, XML_NAMESPACE_##ns, xmloff::token::nm, t|XML_TYPE_PROP_CHART, c, SvtSaveOptions::ODFVER_010 }
+#define MAP_SPECIAL( a, ns, nm, t, c ) { a, sizeof(a)-1, XML_NAMESPACE_##ns, xmloff::token::nm, t|XML_TYPE_PROP_CHART | MID_FLAG_SPECIAL_ITEM, c, SvtSaveOptions::ODFVER_010 }
+#define MAP_SPECIAL_ODF12( a, ns, nm, t, c ) { a, sizeof(a)-1, XML_NAMESPACE_##ns, xmloff::token::nm, t|XML_TYPE_PROP_CHART | MID_FLAG_SPECIAL_ITEM, c, SvtSaveOptions::ODFVER_012 }
+#define MAP_ENTRY_END { 0,0,0,xmloff::token::XML_TOKEN_INVALID,0,0,SvtSaveOptions::ODFVER_010 }
+
+// ---------------------------------------------------------
+// PropertyMap for Chart properties drawing- and
+// textproperties are added later using the chaining
+// mechanism
+// ---------------------------------------------------------
+
+// only create maps once!
+// this define is set in PropertyMaps.cxx
+
+#ifdef XML_SCH_CREATE_GLOBAL_MAPS
+
+const XMLPropertyMapEntry aXMLChartPropMap[] =
+{
+ // chart subtypes
+ MAP_ENTRY( "UpDown", CHART, XML_JAPANESE_CANDLE_STICK, XML_TYPE_BOOL ), // formerly XML_STOCK_UPDOWN_BARS
+ MAP_CONTEXT( "Volume", CHART, XML_STOCK_WITH_VOLUME, XML_TYPE_BOOL, XML_SCH_CONTEXT_STOCK_WITH_VOLUME ),
+ MAP_ENTRY( "Dim3D", CHART, XML_THREE_DIMENSIONAL, XML_TYPE_BOOL ),
+ MAP_ENTRY( "Deep", CHART, XML_DEEP, XML_TYPE_BOOL ),
+ MAP_ENTRY( "Lines", CHART, XML_LINES, XML_TYPE_BOOL ),
+ MAP_ENTRY( "Percent", CHART, XML_PERCENTAGE, XML_TYPE_BOOL ),
+ MAP_ENTRY( "SolidType", CHART, XML_SOLID_TYPE, XML_SCH_TYPE_SOLID_TYPE ),
+ MAP_ENTRY( "SplineType", CHART, XML_INTERPOLATION, XML_SCH_TYPE_INTERPOLATION ),
+ MAP_ENTRY( "Stacked", CHART, XML_STACKED, XML_TYPE_BOOL ),
+ // type: "none", "automatic", "named-symbol" or "image"
+ MAP_ENTRY( "SymbolType", CHART, XML_SYMBOL_TYPE, XML_SCH_TYPE_SYMBOL_TYPE | MID_FLAG_MULTI_PROPERTY ),
+ // if type=="named-symbol" => name of symbol (square, diamond, ...)
+ MAP_ENTRY( "SymbolType", CHART, XML_SYMBOL_NAME, XML_SCH_TYPE_NAMED_SYMBOL | MID_FLAG_MULTI_PROPERTY ),
+ // if type=="image" => an xlink:href element with a linked (package) URI
+ MAP_SPECIAL( "SymbolBitmapURL", CHART, XML_SYMBOL_IMAGE, XML_TYPE_STRING | MID_FLAG_ELEMENT_ITEM, XML_SCH_CONTEXT_SPECIAL_SYMBOL_IMAGE ),
+ MAP_SPECIAL( "SymbolSize", CHART, XML_SYMBOL_WIDTH, XML_TYPE_MEASURE | MID_FLAG_MERGE_PROPERTY, XML_SCH_CONTEXT_SPECIAL_SYMBOL_WIDTH ),
+ MAP_SPECIAL( "SymbolSize", CHART, XML_SYMBOL_HEIGHT, XML_TYPE_MEASURE | MID_FLAG_MERGE_PROPERTY, XML_SCH_CONTEXT_SPECIAL_SYMBOL_HEIGHT ),
+ MAP_ENTRY( "Vertical", CHART, XML_VERTICAL, XML_TYPE_BOOL ),
+ // #i32368# property should no longer be used as XML-property (in OASIS
+ // format), but is still ex-/imported for compatibility with the OOo file format
+ MAP_CONTEXT( "NumberOfLines", CHART, XML_LINES_USED, XML_TYPE_NUMBER, XML_SCH_CONTEXT_LINES_USED ),
+ MAP_ENTRY( "StackedBarsConnected", CHART, XML_CONNECT_BARS, XML_TYPE_BOOL ),
+
+ MAP_ENTRY_ODF12( "GroupBarsPerAxis", CHART, XML_GROUP_BARS_PER_AXIS, XML_TYPE_BOOL ),
+ MAP_ENTRY_ODF12( "IncludeHiddenCells", CHART, XML_INCLUDE_HIDDEN_CELLS, XML_TYPE_BOOL ),
+ MAP_ENTRY_ODF12( "AutomaticPosition", CHART, XML_AUTOMATIC_POSITION, XML_TYPE_BOOL ),
+ MAP_ENTRY_ODF12( "AutomaticSize", CHART, XML_AUTOMATIC_SIZE, XML_TYPE_BOOL ),
+ MAP_ENTRY_ODF12( "StartingAngle", CHART, XML_ANGLE_OFFSET, XML_TYPE_NUMBER ),
+ MAP_ENTRY_ODF12( "MissingValueTreatment", CHART, XML_TREAT_EMPTY_CELLS, XML_SCH_TYPE_MISSING_VALUE_TREATMENT ),
+ MAP_ENTRY( "ScaleText", CHART, XML_SCALE_TEXT, XML_TYPE_BOOL ),
+
+ // spline settings
+ MAP_ENTRY( "SplineOrder", CHART, XML_SPLINE_ORDER, XML_TYPE_NUMBER ),
+ MAP_ENTRY( "SplineResolution", CHART, XML_SPLINE_RESOLUTION, XML_TYPE_NUMBER ),
+
+ // plot-area properties
+ MAP_ENTRY( "DataRowSource", CHART, XML_SERIES_SOURCE, XML_SCH_TYPE_DATAROWSOURCE ),
+ MAP_ENTRY_ODF12( "SortByXValues", CHART, XML_SORT_BY_X_VALUES, XML_TYPE_BOOL ),
+ MAP_ENTRY_ODF12( "RightAngledAxes", CHART, XML_RIGHT_ANGLED_AXES, XML_TYPE_BOOL ),
+
+ // axis properties
+ MAP_ENTRY( "DisplayLabels", CHART, XML_DISPLAY_LABEL, XML_TYPE_BOOL ),
+ MAP_SPECIAL( "Marks", CHART, XML_TICK_MARKS_MAJOR_INNER, XML_TYPE_NUMBER | MID_FLAG_MERGE_PROPERTY, XML_SCH_CONTEXT_SPECIAL_TICKS_MAJ_INNER ), // convert one constant
+ MAP_SPECIAL( "Marks", CHART, XML_TICK_MARKS_MAJOR_OUTER, XML_TYPE_NUMBER | MID_FLAG_MERGE_PROPERTY, XML_SCH_CONTEXT_SPECIAL_TICKS_MAJ_OUTER ), // to two bools
+ MAP_SPECIAL( "HelpMarks", CHART, XML_TICK_MARKS_MINOR_INNER, XML_TYPE_NUMBER | MID_FLAG_MERGE_PROPERTY, XML_SCH_CONTEXT_SPECIAL_TICKS_MIN_INNER ), // see above
+ MAP_SPECIAL( "HelpMarks", CHART, XML_TICK_MARKS_MINOR_OUTER, XML_TYPE_NUMBER | MID_FLAG_MERGE_PROPERTY, XML_SCH_CONTEXT_SPECIAL_TICKS_MIN_OUTER ),
+ MAP_CONTEXT( "Logarithmic", CHART, XML_LOGARITHMIC, XML_TYPE_BOOL, XML_SCH_CONTEXT_LOGARITHMIC ),
+ MAP_CONTEXT( "Min", CHART, XML_MINIMUM, XML_TYPE_DOUBLE, XML_SCH_CONTEXT_MIN ),
+ MAP_CONTEXT( "Max", CHART, XML_MAXIMUM, XML_TYPE_DOUBLE, XML_SCH_CONTEXT_MAX ),
+ MAP_CONTEXT( "Origin", CHART, XML_ORIGIN, XML_TYPE_DOUBLE, XML_SCH_CONTEXT_ORIGIN ),
+ MAP_CONTEXT( "StepMain", CHART, XML_INTERVAL_MAJOR, XML_TYPE_DOUBLE, XML_SCH_CONTEXT_STEP_MAIN ),
+ MAP_CONTEXT( "StepHelpCount", CHART, XML_INTERVAL_MINOR_DIVISOR, XML_TYPE_NUMBER, XML_SCH_CONTEXT_STEP_HELP_COUNT ),
+ MAP_ENTRY( "GapWidth", CHART, XML_GAP_WIDTH, XML_TYPE_NUMBER ),
+ MAP_ENTRY( "Overlap", CHART, XML_OVERLAP, XML_TYPE_NUMBER ),
+ MAP_ENTRY( "TextCanOverlap", CHART, XML_TEXT_OVERLAP, XML_TYPE_BOOL ),
+ MAP_ENTRY_ODF12( "ReverseDirection", CHART, XML_REVERSE_DIRECTION, XML_TYPE_BOOL ),
+ MAP_ENTRY( "TextBreak", TEXT, XML_LINE_BREAK, XML_TYPE_BOOL ),
+ MAP_ENTRY( "ArrangeOrder", CHART, XML_LABEL_ARRANGEMENT, XML_SCH_TYPE_AXIS_ARRANGEMENT ),
+ MAP_SPECIAL( "NumberFormat", STYLE, XML_DATA_STYLE_NAME, XML_TYPE_NUMBER, XML_SCH_CONTEXT_SPECIAL_NUMBER_FORMAT ),
+ MAP_ENTRY( "LinkNumberFormatToSource", CHART, XML_LINK_DATA_STYLE_TO_SOURCE, XML_TYPE_BOOL ),
+ MAP_ENTRY( "Visible", CHART, XML_VISIBLE, XML_TYPE_BOOL ),
+
+ MAP_FULL( "CrossoverPosition", CHART, XML_AXIS_POSITION, XML_SCH_TYPE_AXIS_POSITION|MID_FLAG_MERGE_ATTRIBUTE|MID_FLAG_MULTI_PROPERTY, 0, SvtSaveOptions::ODFVER_012 ),
+ MAP_FULL( "CrossoverValue", CHART, XML_AXIS_POSITION, XML_SCH_TYPE_AXIS_POSITION_VALUE|MID_FLAG_MERGE_ATTRIBUTE|MID_FLAG_MULTI_PROPERTY, 0, SvtSaveOptions::ODFVER_012 ),
+ MAP_FULL( "LabelPosition", CHART, XML_AXIS_LABEL_POSITION, XML_SCH_TYPE_AXIS_LABEL_POSITION, 0, SvtSaveOptions::ODFVER_012 ),
+ MAP_FULL( "MarkPosition", CHART, XML_TICK_MARK_POSITION, XML_SCH_TYPE_TICK_MARK_POSITION, 0, SvtSaveOptions::ODFVER_012 ),
+
+ // statistical properties
+ MAP_ENTRY( "MeanValue", CHART, XML_MEAN_VALUE, XML_TYPE_BOOL ),
+ MAP_ENTRY( "ErrorMargin", CHART, XML_ERROR_MARGIN, XML_TYPE_DOUBLE ),
+ MAP_ENTRY( "ConstantErrorLow", CHART, XML_ERROR_LOWER_LIMIT, XML_TYPE_DOUBLE ),
+ MAP_ENTRY( "ConstantErrorHigh", CHART, XML_ERROR_UPPER_LIMIT, XML_TYPE_DOUBLE ),
+ MAP_ENTRY( "ErrorIndicator", CHART, XML_ERROR_UPPER_INDICATOR, XML_SCH_TYPE_ERROR_INDICATOR_UPPER | MID_FLAG_MERGE_PROPERTY ), // convert one constant
+ MAP_ENTRY( "ErrorIndicator", CHART, XML_ERROR_LOWER_INDICATOR, XML_SCH_TYPE_ERROR_INDICATOR_LOWER | MID_FLAG_MERGE_PROPERTY ), // to two bools
+ MAP_ENTRY( "ErrorBarStyle", CHART, XML_ERROR_CATEGORY, XML_SCH_TYPE_ERROR_BAR_STYLE ),
+ MAP_ENTRY( "PercentageError", CHART, XML_ERROR_PERCENTAGE, XML_TYPE_DOUBLE ),
+ MAP_ENTRY( "RegressionCurves", CHART, XML_REGRESSION_TYPE, XML_SCH_TYPE_REGRESSION_TYPE ),
+ MAP_ENTRY_ODF12( "ErrorBarRangePositive", CHART, XML_ERROR_UPPER_RANGE, XML_TYPE_STRING ),
+ MAP_ENTRY_ODF12( "ErrorBarRangeNegative", CHART, XML_ERROR_LOWER_RANGE, XML_TYPE_STRING ),
+
+ // series/data-point properties
+ MAP_SPECIAL( "DataCaption", CHART, XML_DATA_LABEL_NUMBER, XML_TYPE_NUMBER | MID_FLAG_MERGE_PROPERTY, XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_NUMBER ), // convert one constant
+ MAP_SPECIAL( "DataCaption", CHART, XML_DATA_LABEL_TEXT, XML_TYPE_NUMBER | MID_FLAG_MERGE_PROPERTY, XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_TEXT ), // to 'tristate' and two bools
+ MAP_SPECIAL( "DataCaption", CHART, XML_DATA_LABEL_SYMBOL, XML_TYPE_NUMBER | MID_FLAG_MERGE_PROPERTY, XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_SYMBOL ),
+ MAP_SPECIAL_ODF12( "LabelSeparator", CHART, XML_LABEL_SEPARATOR, XML_TYPE_STRING | MID_FLAG_ELEMENT_ITEM, XML_SCH_CONTEXT_SPECIAL_LABEL_SEPARATOR ),
+ MAP_ENTRY_ODF12( "LabelPlacement", CHART, XML_LABEL_POSITION, XML_SCH_TYPE_LABEL_PLACEMENT_TYPE ),
+ MAP_ENTRY( "SegmentOffset", CHART, XML_PIE_OFFSET, XML_TYPE_NUMBER ),
+ MAP_SPECIAL_ODF12( "PercentageNumberFormat", STYLE, XML_PERCENTAGE_DATA_STYLE_NAME, XML_TYPE_NUMBER, XML_SCH_CONTEXT_SPECIAL_NUMBER_FORMAT ),
+
+ // text properties for titles
+ MAP_SPECIAL( "TextRotation", STYLE, XML_ROTATION_ANGLE, XML_TYPE_NUMBER, XML_SCH_CONTEXT_SPECIAL_TEXT_ROTATION ), // convert 1/100th degrees to degrees
+ MAP_ENTRY( "StackedText", STYLE, XML_DIRECTION, XML_SCH_TYPE_TEXT_ORIENTATION ),
+
+ // for compatability to pre 6.0beta documents
+// MAP_SPECIAL( "SymbolBitmapURL", CHART, XML_SYMBOL_IMAGE_NAME, XML_TYPE_STRING, XML_SCH_CONTEXT_SPECIAL_SYMBOL_IMAGE_NAME ),
+
+ MAP_ENTRY( "ChartUserDefinedAttributes", TEXT, XML_XMLNS, XML_TYPE_ATTRIBUTE_CONTAINER | MID_FLAG_SPECIAL_ITEM ),
+
+ MAP_ENTRY_END
+};
+
+// ----------------------------------------
+// maps for enums to XML attributes
+// ----------------------------------------
+
+SvXMLEnumMapEntry aXMLChartAxisLabelPositionEnumMap[] =
+{
+ { ::xmloff::token::XML_NEAR_AXIS, ::com::sun::star::chart::ChartAxisLabelPosition_NEAR_AXIS },
+ { ::xmloff::token::XML_NEAR_AXIS_OTHER_SIDE, ::com::sun::star::chart::ChartAxisLabelPosition_NEAR_AXIS_OTHER_SIDE },
+ { ::xmloff::token::XML_OUTSIDE_START, ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_START },
+ { ::xmloff::token::XML_OUTSIDE_END, ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_END },
+ { ::xmloff::token::XML_OUTSIDE_MINIMUM, ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_START },//#i114142#
+ { ::xmloff::token::XML_OUTSIDE_MAXIMUM, ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_END },//#i114142#
+ { ::xmloff::token::XML_TOKEN_INVALID, 0 }
+};
+
+SvXMLEnumMapEntry aXMLChartAxisMarkPositionEnumMap[] =
+{
+ { ::xmloff::token::XML_AT_LABELS, ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS },
+ { ::xmloff::token::XML_AT_AXIS, ::com::sun::star::chart::ChartAxisMarkPosition_AT_AXIS },
+ { ::xmloff::token::XML_AT_LABELS_AND_AXIS, ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS_AND_AXIS },
+ { ::xmloff::token::XML_TOKEN_INVALID, 0 }
+};
+
+SvXMLEnumMapEntry aXMLChartAxisArrangementEnumMap[] =
+{
+ { ::xmloff::token::XML_SIDE_BY_SIDE, ::com::sun::star::chart::ChartAxisArrangeOrderType_SIDE_BY_SIDE },
+ { ::xmloff::token::XML_STAGGER_EVEN, ::com::sun::star::chart::ChartAxisArrangeOrderType_STAGGER_EVEN },
+ { ::xmloff::token::XML_STAGGER_ODD, ::com::sun::star::chart::ChartAxisArrangeOrderType_STAGGER_ODD },
+ { ::xmloff::token::XML_TOKEN_INVALID, 0 }
+};
+
+SvXMLEnumMapEntry aXMLChartErrorBarStyleEnumMap[] =
+{
+ { ::xmloff::token::XML_NONE, ::com::sun::star::chart::ErrorBarStyle::NONE },
+ { ::xmloff::token::XML_VARIANCE, ::com::sun::star::chart::ErrorBarStyle::VARIANCE },
+ { ::xmloff::token::XML_STANDARD_DEVIATION, ::com::sun::star::chart::ErrorBarStyle::STANDARD_DEVIATION },
+ { ::xmloff::token::XML_CONSTANT, ::com::sun::star::chart::ErrorBarStyle::ABSOLUTE },
+ { ::xmloff::token::XML_PERCENTAGE, ::com::sun::star::chart::ErrorBarStyle::RELATIVE },
+ { ::xmloff::token::XML_ERROR_MARGIN, ::com::sun::star::chart::ErrorBarStyle::ERROR_MARGIN },
+ { ::xmloff::token::XML_STANDARD_ERROR, ::com::sun::star::chart::ErrorBarStyle::STANDARD_ERROR },
+ { ::xmloff::token::XML_CELL_RANGE, ::com::sun::star::chart::ErrorBarStyle::FROM_DATA },
+ { ::xmloff::token::XML_TOKEN_INVALID, 0 }
+};
+
+SvXMLEnumMapEntry aXMLChartRegressionCurveTypeEnumMap[] =
+{
+ { ::xmloff::token::XML_NONE, ::com::sun::star::chart::ChartRegressionCurveType_NONE },
+ { ::xmloff::token::XML_LINEAR, ::com::sun::star::chart::ChartRegressionCurveType_LINEAR },
+ { ::xmloff::token::XML_LOGARITHMIC, ::com::sun::star::chart::ChartRegressionCurveType_LOGARITHM },
+ { ::xmloff::token::XML_EXPONENTIAL, ::com::sun::star::chart::ChartRegressionCurveType_EXPONENTIAL },
+ { ::xmloff::token::XML_POLYNOMIAL, ::com::sun::star::chart::ChartRegressionCurveType_POLYNOMIAL },
+ { ::xmloff::token::XML_POWER, ::com::sun::star::chart::ChartRegressionCurveType_POWER },
+ { ::xmloff::token::XML_TOKEN_INVALID, 0 }
+};
+
+SvXMLEnumMapEntry aXMLChartSolidTypeEnumMap[] =
+{
+ { ::xmloff::token::XML_CUBOID, ::com::sun::star::chart::ChartSolidType::RECTANGULAR_SOLID },
+ { ::xmloff::token::XML_CYLINDER, ::com::sun::star::chart::ChartSolidType::CYLINDER },
+ { ::xmloff::token::XML_CONE, ::com::sun::star::chart::ChartSolidType::CONE },
+ { ::xmloff::token::XML_PYRAMID, ::com::sun::star::chart::ChartSolidType::PYRAMID },
+ { ::xmloff::token::XML_TOKEN_INVALID, 0 }
+};
+
+SvXMLEnumMapEntry aXMLChartDataRowSourceTypeEnumMap[] =
+{
+ { ::xmloff::token::XML_COLUMNS, ::com::sun::star::chart::ChartDataRowSource_COLUMNS },
+ { ::xmloff::token::XML_ROWS, ::com::sun::star::chart::ChartDataRowSource_ROWS },
+ { ::xmloff::token::XML_TOKEN_INVALID, 0 }
+};
+
+SvXMLEnumMapEntry aXMLChartInterpolationTypeEnumMap[] =
+{
+ // this is neither an enum nor a constants group, but just a
+ // documented long property
+ { ::xmloff::token::XML_NONE, 0 },
+ { ::xmloff::token::XML_CUBIC_SPLINE, 1 },
+ { ::xmloff::token::XML_B_SPLINE, 2 },
+ { ::xmloff::token::XML_TOKEN_INVALID,0 }
+};
+
+SvXMLEnumMapEntry aXMLChartDataLabelPlacementEnumMap[] =
+{
+ { ::xmloff::token::XML_AVOID_OVERLAP, ::com::sun::star::chart::DataLabelPlacement::AVOID_OVERLAP },
+ { ::xmloff::token::XML_CENTER, ::com::sun::star::chart::DataLabelPlacement::CENTER },
+ { ::xmloff::token::XML_TOP, ::com::sun::star::chart::DataLabelPlacement::TOP },
+ { ::xmloff::token::XML_TOP_LEFT, ::com::sun::star::chart::DataLabelPlacement::TOP_LEFT },
+ { ::xmloff::token::XML_LEFT, ::com::sun::star::chart::DataLabelPlacement::LEFT },
+ { ::xmloff::token::XML_BOTTOM_LEFT, ::com::sun::star::chart::DataLabelPlacement::BOTTOM_LEFT },
+ { ::xmloff::token::XML_BOTTOM, ::com::sun::star::chart::DataLabelPlacement::BOTTOM },
+ { ::xmloff::token::XML_BOTTOM_RIGHT, ::com::sun::star::chart::DataLabelPlacement::BOTTOM_RIGHT },
+ { ::xmloff::token::XML_RIGHT, ::com::sun::star::chart::DataLabelPlacement::RIGHT },
+ { ::xmloff::token::XML_TOP_RIGHT, ::com::sun::star::chart::DataLabelPlacement::TOP_RIGHT },
+ { ::xmloff::token::XML_INSIDE, ::com::sun::star::chart::DataLabelPlacement::INSIDE },
+ { ::xmloff::token::XML_OUTSIDE, ::com::sun::star::chart::DataLabelPlacement::OUTSIDE },
+ { ::xmloff::token::XML_NEAR_ORIGIN, ::com::sun::star::chart::DataLabelPlacement::NEAR_ORIGIN },
+ { ::xmloff::token::XML_TOKEN_INVALID, 0 }
+};
+
+SvXMLEnumMapEntry aXMLChartMissingValueTreatmentEnumMap[] =
+{
+ { ::xmloff::token::XML_LEAVE_GAP, ::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP },
+ { ::xmloff::token::XML_USE_ZERO, ::com::sun::star::chart::MissingValueTreatment::USE_ZERO },
+ { ::xmloff::token::XML_IGNORE, ::com::sun::star::chart::MissingValueTreatment::CONTINUE },
+ { ::xmloff::token::XML_TOKEN_INVALID,0 },
+};
+
+#endif // XML_SCH_CREATE_GLOBAL_MAPS
+
+#endif // _PROPERTYMAP_HXX_
diff --git a/xmloff/source/chart/PropertyMaps.cxx b/xmloff/source/chart/PropertyMaps.cxx
new file mode 100644
index 000000000000..d2be11a0013e
--- /dev/null
+++ b/xmloff/source/chart/PropertyMaps.cxx
@@ -0,0 +1,618 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmloff.hxx"
+
+// include PropertyMap.hxx with this define
+// to create the maps
+#ifndef _PROPERTYMAP_HXX_
+#define XML_SCH_CREATE_GLOBAL_MAPS
+#include "PropertyMap.hxx"
+#undef XML_SCH_CREATE_GLOBAL_MAPS
+#endif
+
+#include "XMLChartPropertySetMapper.hxx"
+#include "SchXMLTools.hxx"
+#include <xmloff/EnumPropertyHdl.hxx>
+#include <xmloff/XMLConstantsPropertyHandler.hxx>
+#include <xmloff/attrlist.hxx>
+#include <xmloff/nmspmap.hxx>
+#include <xmloff/xmluconv.hxx>
+#include <xmloff/shapeimport.hxx>
+#include <xmloff/NamedBoolPropertyHdl.hxx>
+#include <xmloff/xmlexp.hxx>
+#include <xmloff/xmltoken.hxx>
+#include "XMLErrorIndicatorPropertyHdl.hxx"
+#include "XMLErrorBarStylePropertyHdl.hxx"
+#include "XMLTextOrientationHdl.hxx"
+#include "XMLSymbolTypePropertyHdl.hxx"
+#include "XMLAxisPositionPropertyHdl.hxx"
+#include <com/sun/star/chart/ChartAxisMarks.hpp>
+#include <com/sun/star/chart/ChartDataCaption.hpp>
+#include <com/sun/star/chart/ChartSymbolType.hpp>
+#include <com/sun/star/drawing/LineStyle.hpp>
+#include <com/sun/star/drawing/FillStyle.hpp>
+#include <com/sun/star/drawing/LineJoint.hpp>
+#include <com/sun/star/chart/ChartDataRowSource.hpp>
+#include <com/sun/star/chart/ChartAxisPosition.hpp>
+
+// header for any2enum
+#include <comphelper/extract.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <rtl/math.hxx>
+
+#define SCH_XML_SETFLAG( status, flag ) (status)|= (flag)
+#define SCH_XML_UNSETFLAG( status, flag ) (status) = ((status) | (flag)) - (flag)
+
+using namespace com::sun::star;
+using namespace ::xmloff::token;
+
+// the following class implementations are in this file:
+//
+// * XMLChartPropHdlFactory
+// * XMLChartPropertySetMapper
+// * XMLChartExportPropertyMapper
+// * XMLChartImportPropertyMapper
+// * SchXMLStyleExport
+
+// ----------------------------------------
+
+XMLChartPropHdlFactory::~XMLChartPropHdlFactory()
+{
+}
+
+const XMLPropertyHandler* XMLChartPropHdlFactory::GetPropertyHandler( sal_Int32 nType ) const
+{
+ const XMLPropertyHandler* pHdl = XMLPropertyHandlerFactory::GetPropertyHandler( nType );
+ if( ! pHdl )
+ {
+ switch( nType )
+ {
+ case XML_SCH_TYPE_AXIS_POSITION:
+ pHdl = new XMLAxisPositionPropertyHdl( false );
+ break;
+ case XML_SCH_TYPE_AXIS_POSITION_VALUE:
+ pHdl = new XMLAxisPositionPropertyHdl( true );
+ break;
+
+ case XML_SCH_TYPE_AXIS_LABEL_POSITION:
+ pHdl = new XMLEnumPropertyHdl( aXMLChartAxisLabelPositionEnumMap,
+ ::getCppuType((const chart::ChartAxisLabelPosition*)0) );
+ break;
+
+ case XML_SCH_TYPE_TICK_MARK_POSITION:
+ pHdl = new XMLEnumPropertyHdl( aXMLChartAxisMarkPositionEnumMap,
+ ::getCppuType((const chart::ChartAxisMarkPosition*)0) );
+ break;
+
+ case XML_SCH_TYPE_AXIS_ARRANGEMENT:
+ pHdl = new XMLEnumPropertyHdl( aXMLChartAxisArrangementEnumMap,
+ ::getCppuType((const chart::ChartAxisArrangeOrderType*)0) );
+ break;
+
+ case XML_SCH_TYPE_ERROR_BAR_STYLE:
+ // here we have a constant rather than an enum
+ pHdl = new XMLErrorBarStylePropertyHdl( aXMLChartErrorBarStyleEnumMap,
+ ::getCppuType((const sal_Int32*)0) );
+ break;
+
+ case XML_SCH_TYPE_REGRESSION_TYPE:
+ pHdl = new XMLEnumPropertyHdl( aXMLChartRegressionCurveTypeEnumMap,
+ ::getCppuType((const chart::ChartRegressionCurveType*)0) );
+ break;
+
+ case XML_SCH_TYPE_ERROR_INDICATOR_LOWER:
+ pHdl = new XMLErrorIndicatorPropertyHdl( sal_False );
+ break;
+ case XML_SCH_TYPE_ERROR_INDICATOR_UPPER:
+ pHdl = new XMLErrorIndicatorPropertyHdl( sal_True );
+ break;
+
+ case XML_SCH_TYPE_SOLID_TYPE:
+ // here we have a constant rather than an enum
+ pHdl = new XMLEnumPropertyHdl( aXMLChartSolidTypeEnumMap,
+ ::getCppuType((const sal_Int32*)0) );
+ break;
+ case XML_SCH_TYPE_LABEL_PLACEMENT_TYPE:
+ // here we have a constant rather than an enum
+ pHdl = new XMLEnumPropertyHdl( aXMLChartDataLabelPlacementEnumMap,
+ ::getCppuType((const sal_Int32*)0) );
+ break;
+ case XML_SCH_TYPE_DATAROWSOURCE:
+ pHdl = new XMLEnumPropertyHdl( aXMLChartDataRowSourceTypeEnumMap,
+ ::getCppuType((const chart::ChartDataRowSource*)0) );
+ break;
+ case XML_SCH_TYPE_TEXT_ORIENTATION:
+ pHdl = new XMLTextOrientationHdl();
+ break;
+
+ case XML_SCH_TYPE_INTERPOLATION:
+ pHdl = new XMLEnumPropertyHdl( aXMLChartInterpolationTypeEnumMap,
+ ::getCppuType((const sal_Int32*)0) );
+ break;
+ case XML_SCH_TYPE_SYMBOL_TYPE:
+ pHdl = new XMLSymbolTypePropertyHdl( false );
+ break;
+
+ case XML_SCH_TYPE_NAMED_SYMBOL:
+ pHdl = new XMLSymbolTypePropertyHdl( true );
+ break;
+
+ case XML_SCH_TYPE_MISSING_VALUE_TREATMENT:
+ pHdl = new XMLEnumPropertyHdl( aXMLChartMissingValueTreatmentEnumMap,
+ ::getCppuType((const sal_Int32*)0) );
+ break;
+ }
+ if( pHdl )
+ PutHdlCache( nType, pHdl );
+ }
+
+ return pHdl;
+}
+
+// ----------------------------------------
+
+XMLChartPropertySetMapper::XMLChartPropertySetMapper() :
+ XMLPropertySetMapper( aXMLChartPropMap, new XMLChartPropHdlFactory )
+{
+}
+
+XMLChartPropertySetMapper::~XMLChartPropertySetMapper()
+{
+}
+
+// ----------------------------------------
+
+XMLChartExportPropertyMapper::XMLChartExportPropertyMapper( const UniReference< XMLPropertySetMapper >& rMapper,
+ SvXMLExport& rExport) :
+ SvXMLExportPropertyMapper( rMapper ),
+ msTrue( GetXMLToken( XML_TRUE )),
+ msFalse( GetXMLToken( XML_FALSE )),
+ mrExport( rExport )
+{
+ // chain draw properties
+ ChainExportMapper( XMLShapeExport::CreateShapePropMapper( rExport ));
+
+ // chain text properties
+ ChainExportMapper( XMLTextParagraphExport::CreateParaExtPropMapper( rExport ));
+}
+
+XMLChartExportPropertyMapper::~XMLChartExportPropertyMapper()
+{
+}
+
+void XMLChartExportPropertyMapper::ContextFilter(
+ std::vector< XMLPropertyState >& rProperties,
+ uno::Reference< beans::XPropertySet > rPropSet ) const
+{
+ ::rtl::OUString aAutoPropName;
+ sal_Bool bCheckAuto = sal_False;
+
+ // filter properties
+ for( std::vector< XMLPropertyState >::iterator property = rProperties.begin();
+ property != rProperties.end();
+ property++ )
+ {
+ // find properties with context
+ // to prevent writing this property set mnIndex member to -1
+ switch( getPropertySetMapper()->GetEntryContextId( property->mnIndex ))
+ {
+ // if Auto... is set the corresponding properties mustn't be exported
+ case XML_SCH_CONTEXT_MIN:
+ bCheckAuto = sal_True;
+ aAutoPropName = ::rtl::OUString::createFromAscii( "AutoMin" );
+ break;
+ case XML_SCH_CONTEXT_MAX:
+ bCheckAuto = sal_True;
+ aAutoPropName = ::rtl::OUString::createFromAscii( "AutoMax" );
+ break;
+ case XML_SCH_CONTEXT_STEP_MAIN:
+ bCheckAuto = sal_True;
+ aAutoPropName = ::rtl::OUString::createFromAscii( "AutoStepMain" );
+ break;
+ case XML_SCH_CONTEXT_STEP_HELP_COUNT:
+ bCheckAuto = sal_True;
+ aAutoPropName = ::rtl::OUString::createFromAscii( "AutoStepHelp" );
+ break;
+
+ case XML_SCH_CONTEXT_ORIGIN:
+ bCheckAuto = sal_True;
+ aAutoPropName = ::rtl::OUString::createFromAscii( "AutoOrigin" );
+ break;
+
+ // the following property is deprecated
+ // elemet-item symbol-image is used now
+ case XML_SCH_CONTEXT_SPECIAL_SYMBOL_IMAGE_NAME:
+ property->mnIndex = -1;
+ break;
+
+ case XML_SCH_CONTEXT_STOCK_WITH_VOLUME:
+ case XML_SCH_CONTEXT_LINES_USED:
+ // note this avoids export of the properties in OASIS format,
+ // but also for the OOo XML Flat format (used by binfilter),
+ // because there, the transformation to OOo is done after the
+ // complete export of the chart in OASIS format.
+ if( mrExport.getExportFlags() & EXPORT_OASIS )
+ property->mnIndex = -1;
+ break;
+ }
+
+ if( bCheckAuto )
+ {
+ if( rPropSet.is())
+ {
+ try
+ {
+ sal_Bool bAuto = false;
+ uno::Any aAny = rPropSet->getPropertyValue( aAutoPropName );
+ aAny >>= bAuto;
+ if( bAuto )
+ property->mnIndex = -1;
+ }
+ catch( beans::UnknownPropertyException )
+ {
+ }
+ }
+ bCheckAuto = sal_False;
+ }
+ }
+
+ SvXMLExportPropertyMapper::ContextFilter(rProperties, rPropSet);
+}
+
+void XMLChartExportPropertyMapper::handleElementItem(
+ SvXMLExport& rExport,
+ const XMLPropertyState& rProperty, sal_uInt16 nFlags,
+ const ::std::vector< XMLPropertyState > *pProperties,
+ sal_uInt32 nIdx ) const
+{
+ switch( getPropertySetMapper()->GetEntryContextId( rProperty.mnIndex ))
+ {
+ case XML_SCH_CONTEXT_SPECIAL_SYMBOL_IMAGE:
+ {
+ ::rtl::OUString aURLStr;
+ rProperty.maValue >>= aURLStr;
+
+ // export as XLink reference into the package
+ // if embedding is off
+ ::rtl::OUString sTempURL( mrExport.AddEmbeddedGraphicObject( aURLStr ));
+ if( sTempURL.getLength() )
+ {
+ mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, sTempURL );
+ mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE,
+ XML_SIMPLE );
+ mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE,
+ XML_ONLOAD );
+ }
+
+ {
+ sal_uInt32 nPropIndex = rProperty.mnIndex;
+ // this is the element that has to live until the next statement
+ SvXMLElementExport aElem( mrExport,
+ getPropertySetMapper()->GetEntryNameSpace( nPropIndex ),
+ getPropertySetMapper()->GetEntryXMLName( nPropIndex ),
+ sal_True, sal_True );
+
+ // export as Base64 embedded graphic
+ // if embedding is on
+ if( aURLStr.getLength())
+ mrExport.AddEmbeddedGraphicObjectAsBase64( aURLStr );
+ }
+ }
+ break;
+
+ case XML_SCH_CONTEXT_SPECIAL_LABEL_SEPARATOR:
+ {
+ ::rtl::OUString aSeparator;
+ rProperty.maValue >>= aSeparator;
+
+ if( aSeparator.getLength() )
+ {
+ sal_uInt32 nPropIndex = rProperty.mnIndex;
+ SvXMLElementExport aElem( mrExport,
+ getPropertySetMapper()->GetEntryNameSpace( nPropIndex ),
+ getPropertySetMapper()->GetEntryXMLName( nPropIndex ),
+ sal_True, sal_True );
+
+ SchXMLTools::exportText( mrExport, aSeparator, true );
+ }
+ }
+ break;
+
+ default:
+ // call parent
+ SvXMLExportPropertyMapper::handleElementItem( rExport, rProperty,
+ nFlags, pProperties, nIdx );
+ break;
+ }
+}
+
+void XMLChartExportPropertyMapper::handleSpecialItem(
+ SvXMLAttributeList& rAttrList, const XMLPropertyState& rProperty,
+ const SvXMLUnitConverter& rUnitConverter,
+ const SvXMLNamespaceMap& rNamespaceMap,
+ const ::std::vector< XMLPropertyState > *pProperties,
+ sal_uInt32 nIdx ) const
+{
+ sal_Bool bHandled = sal_False;
+
+ sal_Int32 nContextId = maPropMapper->GetEntryContextId( rProperty.mnIndex );
+
+ if( nContextId )
+ {
+ bHandled = sal_True;
+
+ rtl::OUString sAttrName = maPropMapper->GetEntryXMLName( rProperty.mnIndex );
+ sal_uInt16 nNameSpace = maPropMapper->GetEntryNameSpace( rProperty.mnIndex );
+ rtl::OUStringBuffer sValueBuffer;
+ rtl::OUString sValue;
+
+ sal_Int32 nValue = 0;
+ sal_Bool bValue = sal_False;
+
+ switch( nContextId )
+ {
+ case XML_SCH_CONTEXT_SPECIAL_TICKS_MAJ_INNER:
+ case XML_SCH_CONTEXT_SPECIAL_TICKS_MIN_INNER:
+ rProperty.maValue >>= nValue;
+ bValue = (( nValue & chart::ChartAxisMarks::INNER ) == chart::ChartAxisMarks::INNER );
+ SvXMLUnitConverter::convertBool( sValueBuffer, bValue );
+ break;
+ case XML_SCH_CONTEXT_SPECIAL_TICKS_MAJ_OUTER:
+ case XML_SCH_CONTEXT_SPECIAL_TICKS_MIN_OUTER:
+ rProperty.maValue >>= nValue;
+ bValue = (( nValue & chart::ChartAxisMarks::OUTER ) == chart::ChartAxisMarks::OUTER );
+ SvXMLUnitConverter::convertBool( sValueBuffer, bValue );
+ break;
+ case XML_SCH_CONTEXT_SPECIAL_TEXT_ROTATION:
+ {
+ // convert from 100th degrees to degrees (double)
+ rProperty.maValue >>= nValue;
+ double fVal = (double)(nValue) / 100.0;
+ SvXMLUnitConverter::convertDouble( sValueBuffer, fVal );
+ }
+ break;
+ case XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_NUMBER:
+ {
+ rProperty.maValue >>= nValue;
+ if((( nValue & chart::ChartDataCaption::VALUE ) == chart::ChartDataCaption::VALUE ))
+ {
+ if( ( nValue & chart::ChartDataCaption::PERCENT ) == chart::ChartDataCaption::PERCENT )
+ {
+ const SvtSaveOptions::ODFDefaultVersion nCurrentVersion( SvtSaveOptions().GetODFDefaultVersion() );
+ if( nCurrentVersion < SvtSaveOptions::ODFVER_012 )
+ sValueBuffer.append( GetXMLToken( XML_PERCENTAGE ));
+ else
+ sValueBuffer.append( GetXMLToken( XML_VALUE_AND_PERCENTAGE ));
+ }
+ else
+ sValueBuffer.append( GetXMLToken( XML_VALUE ));
+ }
+ else if(( nValue & chart::ChartDataCaption::PERCENT ) == chart::ChartDataCaption::PERCENT )
+ sValueBuffer.append( GetXMLToken( XML_PERCENTAGE ));
+ else
+ sValueBuffer.append( GetXMLToken( XML_NONE ));
+ }
+ break;
+ case XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_TEXT:
+ rProperty.maValue >>= nValue;
+ bValue = (( nValue & chart::ChartDataCaption::TEXT ) == chart::ChartDataCaption::TEXT );
+ SvXMLUnitConverter::convertBool( sValueBuffer, bValue );
+ break;
+ case XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_SYMBOL:
+ rProperty.maValue >>= nValue;
+ bValue = (( nValue & chart::ChartDataCaption::SYMBOL ) == chart::ChartDataCaption::SYMBOL );
+ SvXMLUnitConverter::convertBool( sValueBuffer, bValue );
+ break;
+
+ case XML_SCH_CONTEXT_SPECIAL_SYMBOL_WIDTH:
+ case XML_SCH_CONTEXT_SPECIAL_SYMBOL_HEIGHT:
+ {
+ awt::Size aSize;
+ rProperty.maValue >>= aSize;
+ rUnitConverter.convertMeasure( sValueBuffer,
+ nContextId == XML_SCH_CONTEXT_SPECIAL_SYMBOL_WIDTH
+ ? aSize.Width
+ : aSize.Height );
+ }
+ break;
+
+ case XML_SCH_CONTEXT_SPECIAL_NUMBER_FORMAT:
+ {
+ // just for import
+ break;
+ }
+
+ default:
+ bHandled = sal_False;
+ break;
+ }
+
+ if( sValueBuffer.getLength())
+ {
+ sValue = sValueBuffer.makeStringAndClear();
+ sAttrName = rNamespaceMap.GetQNameByKey( nNameSpace, sAttrName );
+ rAttrList.AddAttribute( sAttrName, sValue );
+ }
+ }
+
+ if( !bHandled )
+ {
+ // call parent
+ SvXMLExportPropertyMapper::handleSpecialItem( rAttrList, rProperty, rUnitConverter, rNamespaceMap, pProperties, nIdx );
+ }
+}
+
+// ----------------------------------------
+
+XMLChartImportPropertyMapper::XMLChartImportPropertyMapper( const UniReference< XMLPropertySetMapper >& rMapper,
+ const SvXMLImport& _rImport ) :
+ SvXMLImportPropertyMapper( rMapper, const_cast< SvXMLImport & >( _rImport )),
+ mrImport( const_cast< SvXMLImport & > ( _rImport ))
+{
+ // chain shape mapper for drawing properties
+
+ // give an empty model. It is only used for numbering rules that don't exist in chart
+ uno::Reference< frame::XModel > xEmptyModel;
+ ChainImportMapper( XMLShapeImportHelper::CreateShapePropMapper( xEmptyModel, mrImport ));
+
+ //#i14365# save and load writing-mode for chart elements
+ //The property TextWritingMode is mapped wrongly in the underlying draw mapper, but for draw it is necessary
+ //We remove that property here only for chart thus the chart can use the correct mapping from the writer paragraph settings (attribute 'writing-mode' <-> property 'WritingMode')
+ sal_Int32 nUnwantedWrongEntry = maPropMapper->FindEntryIndex( "TextWritingMode", XML_NAMESPACE_STYLE, GetXMLToken(XML_WRITING_MODE) );
+ maPropMapper->RemoveEntry(nUnwantedWrongEntry);
+
+ // do not chain text properties: on import this is done by shape mapper
+ // to import old documents
+// ChainImportMapper( XMLTextImportHelper::CreateParaExtPropMapper());
+}
+
+XMLChartImportPropertyMapper::~XMLChartImportPropertyMapper()
+{
+}
+
+sal_Bool XMLChartImportPropertyMapper::handleSpecialItem(
+ XMLPropertyState& rProperty,
+ ::std::vector< XMLPropertyState >& rProperties,
+ const ::rtl::OUString& rValue,
+ const SvXMLUnitConverter& rUnitConverter,
+ const SvXMLNamespaceMap& rNamespaceMap ) const
+{
+ static const ::rtl::OUString sPackageProtocol( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.Package:" ) );
+ sal_Int32 nContextId = maPropMapper->GetEntryContextId( rProperty.mnIndex );
+ sal_Bool bRet = (nContextId != 0);
+
+ if( nContextId )
+ {
+ sal_Int32 nValue = 0;
+ sal_Bool bValue = sal_False;
+
+ switch( nContextId )
+ {
+ case XML_SCH_CONTEXT_SPECIAL_TICKS_MAJ_INNER:
+ case XML_SCH_CONTEXT_SPECIAL_TICKS_MIN_INNER:
+ SvXMLUnitConverter::convertBool( bValue, rValue );
+ // modify old value
+ rProperty.maValue >>= nValue;
+ if( bValue )
+ SCH_XML_SETFLAG( nValue, chart::ChartAxisMarks::INNER );
+ else
+ SCH_XML_UNSETFLAG( nValue, chart::ChartAxisMarks::INNER );
+ rProperty.maValue <<= nValue;
+ break;
+ case XML_SCH_CONTEXT_SPECIAL_TICKS_MAJ_OUTER:
+ case XML_SCH_CONTEXT_SPECIAL_TICKS_MIN_OUTER:
+ SvXMLUnitConverter::convertBool( bValue, rValue );
+ // modify old value
+ rProperty.maValue >>= nValue;
+ if( bValue )
+ SCH_XML_SETFLAG( nValue, chart::ChartAxisMarks::OUTER );
+ else
+ SCH_XML_UNSETFLAG( nValue, chart::ChartAxisMarks::OUTER );
+ rProperty.maValue <<= nValue;
+ break;
+ case XML_SCH_CONTEXT_SPECIAL_TEXT_ROTATION:
+ {
+ // convert from degrees (double) to 100th degrees (integer)
+ double fVal;
+ SvXMLUnitConverter::convertDouble( fVal, rValue );
+ nValue = (sal_Int32)( fVal * 100.0 );
+ rProperty.maValue <<= nValue;
+ }
+ break;
+ case XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_NUMBER:
+ {
+ // modify old value
+ rProperty.maValue >>= nValue;
+ if( IsXMLToken( rValue, XML_NONE ))
+ SCH_XML_UNSETFLAG( nValue, chart::ChartDataCaption::VALUE | chart::ChartDataCaption::PERCENT );
+ else if( IsXMLToken( rValue, XML_VALUE_AND_PERCENTAGE ) )
+ SCH_XML_SETFLAG( nValue, chart::ChartDataCaption::VALUE | chart::ChartDataCaption::PERCENT );
+ else if( IsXMLToken( rValue, XML_VALUE ) )
+ SCH_XML_SETFLAG( nValue, chart::ChartDataCaption::VALUE );
+ else // must be XML_PERCENTAGE
+ SCH_XML_SETFLAG( nValue, chart::ChartDataCaption::PERCENT );
+ rProperty.maValue <<= nValue;
+ }
+ break;
+ case XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_TEXT:
+ rProperty.maValue >>= nValue;
+ SvXMLUnitConverter::convertBool( bValue, rValue );
+ if( bValue )
+ SCH_XML_SETFLAG( nValue, chart::ChartDataCaption::TEXT );
+ else
+ SCH_XML_UNSETFLAG( nValue, chart::ChartDataCaption::TEXT );
+ rProperty.maValue <<= nValue;
+ break;
+ case XML_SCH_CONTEXT_SPECIAL_DATA_LABEL_SYMBOL:
+ rProperty.maValue >>= nValue;
+ SvXMLUnitConverter::convertBool( bValue, rValue );
+ if( bValue )
+ SCH_XML_SETFLAG( nValue, chart::ChartDataCaption::SYMBOL );
+ else
+ SCH_XML_UNSETFLAG( nValue, chart::ChartDataCaption::SYMBOL );
+ rProperty.maValue <<= nValue;
+ break;
+ case XML_SCH_CONTEXT_SPECIAL_SYMBOL_WIDTH:
+ case XML_SCH_CONTEXT_SPECIAL_SYMBOL_HEIGHT:
+ {
+ awt::Size aSize;
+ rProperty.maValue >>= aSize;
+ rUnitConverter.convertMeasure( nContextId == XML_SCH_CONTEXT_SPECIAL_SYMBOL_WIDTH
+ ? aSize.Width
+ : aSize.Height,
+ rValue );
+ rProperty.maValue <<= aSize;
+ }
+ break;
+
+ // deprecated from 6.0 beta on
+ case XML_SCH_CONTEXT_SPECIAL_SYMBOL_IMAGE_NAME:
+ rProperty.maValue <<= mrImport.ResolveGraphicObjectURL( rValue, sal_False );
+ break;
+
+ default:
+ bRet = sal_False;
+ break;
+ }
+ }
+
+
+ // if we didn't handle it, the parent should
+ if( !bRet )
+ {
+ // call parent
+ bRet = SvXMLImportPropertyMapper::handleSpecialItem( rProperty, rProperties, rValue, rUnitConverter, rNamespaceMap );
+ }
+
+ return bRet;
+}
+
+void XMLChartImportPropertyMapper::finished( ::std::vector< XMLPropertyState >& /*rProperties*/, sal_Int32 /*nStartIndex*/, sal_Int32 /*nEndIndex*/ ) const
+{
+}
diff --git a/xmloff/source/chart/SchXMLAutoStylePoolP.cxx b/xmloff/source/chart/SchXMLAutoStylePoolP.cxx
new file mode 100644
index 000000000000..fc70b5831d9b
--- /dev/null
+++ b/xmloff/source/chart/SchXMLAutoStylePoolP.cxx
@@ -0,0 +1,91 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmloff.hxx"
+#include "SchXMLAutoStylePoolP.hxx"
+#include "PropertyMap.hxx"
+#include "SchXMLExport.hxx"
+#include "XMLChartPropertySetMapper.hxx"
+#include <xmloff/families.hxx>
+#include <xmloff/nmspmap.hxx>
+#include <xmloff/xmltoken.hxx>
+
+using ::xmloff::token::GetXMLToken;
+using ::xmloff::token::XML_CDATA;
+
+SchXMLAutoStylePoolP::SchXMLAutoStylePoolP( SchXMLExport& rSchXMLExport ) :
+ SvXMLAutoStylePoolP( rSchXMLExport ),
+ mrSchXMLExport( rSchXMLExport )
+{}
+
+SchXMLAutoStylePoolP::~SchXMLAutoStylePoolP()
+{}
+
+void SchXMLAutoStylePoolP::exportStyleAttributes(
+ SvXMLAttributeList& rAttrList,
+ sal_Int32 nFamily,
+ const ::std::vector< XMLPropertyState >& rProperties,
+ const SvXMLExportPropertyMapper& rPropExp
+ , const SvXMLUnitConverter& rUnitConverter,
+ const SvXMLNamespaceMap& rNamespaceMap
+ ) const
+{
+ const rtl::OUString sCDATA( GetXMLToken( XML_CDATA ));
+ SvXMLAutoStylePoolP::exportStyleAttributes( rAttrList, nFamily, rProperties,
+ rPropExp, rUnitConverter, rNamespaceMap );
+
+ if( nFamily == XML_STYLE_FAMILY_SCH_CHART_ID )
+ {
+ for( ::std::vector< XMLPropertyState >::const_iterator iter = rProperties.begin();
+ (iter != rProperties.end()); iter++ )
+ {
+ if( iter->mnIndex == -1 )
+ continue;
+
+ UniReference< XMLPropertySetMapper > aPropMapper =
+ mrSchXMLExport.GetPropertySetMapper();
+ sal_Int16 nContextID = aPropMapper->GetEntryContextId( iter->mnIndex );
+ if( nContextID == XML_SCH_CONTEXT_SPECIAL_NUMBER_FORMAT )
+ {
+ sal_Int32 nNumberFormat = -1;
+ if( ( iter->maValue >>= nNumberFormat ) &&
+ ( nNumberFormat != -1 ))
+ {
+ rtl::OUString sAttrValue = mrSchXMLExport.getDataStyleName( nNumberFormat );
+ if( sAttrValue.getLength() )
+ {
+ mrSchXMLExport.AddAttribute(
+ aPropMapper->GetEntryNameSpace( iter->mnIndex ),
+ aPropMapper->GetEntryXMLName( iter->mnIndex ),
+ sAttrValue );
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/xmloff/source/chart/SchXMLAutoStylePoolP.hxx b/xmloff/source/chart/SchXMLAutoStylePoolP.hxx
new file mode 100644
index 000000000000..d16973347c1d
--- /dev/null
+++ b/xmloff/source/chart/SchXMLAutoStylePoolP.hxx
@@ -0,0 +1,53 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _SCH_XMLAUTOSTYLEPOOLP_HXX_
+#define _SCH_XMLAUTOSTYLEPOOLP_HXX_
+
+#include <xmloff/xmlaustp.hxx>
+
+class SchXMLExport;
+
+class SchXMLAutoStylePoolP : public SvXMLAutoStylePoolP
+{
+protected:
+ SchXMLExport& mrSchXMLExport;
+
+ virtual void exportStyleAttributes(
+ SvXMLAttributeList& rAttrList,
+ sal_Int32 nFamily,
+ const ::std::vector< XMLPropertyState >& rProperties,
+ const SvXMLExportPropertyMapper& rPropExp
+ , const SvXMLUnitConverter& rUnitConverter,
+ const SvXMLNamespaceMap& rNamespaceMap
+ ) const;
+
+public:
+ SchXMLAutoStylePoolP( SchXMLExport& rSchXMLExport );
+ virtual ~SchXMLAutoStylePoolP();
+};
+
+#endif // _SCH_XMLAUTOSTYLEPOOLP_HXX_
diff --git a/xmloff/source/chart/SchXMLCalculationSettingsContext.cxx b/xmloff/source/chart/SchXMLCalculationSettingsContext.cxx
new file mode 100755
index 000000000000..f66fd3fd8561
--- /dev/null
+++ b/xmloff/source/chart/SchXMLCalculationSettingsContext.cxx
@@ -0,0 +1,86 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmloff.hxx"
+#include <SchXMLCalculationSettingsContext.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/util/DateTime.hpp>
+#include <xmloff/xmlimp.hxx>
+#include <xmloff/nmspmap.hxx>
+#include "xmlnmspe.hxx"
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/xmluconv.hxx>
+
+
+using ::rtl::OUString;
+using ::rtl::OUStringBuffer;
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star;
+using namespace ::xmloff::token;
+
+SchXMLCalculationSettingsContext::SchXMLCalculationSettingsContext( SvXMLImport& rImport,
+ sal_uInt16 p_nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList >& xAttrList )
+: SvXMLImportContext ( rImport, p_nPrefix, rLocalName )
+{
+ const SvXMLNamespaceMap& rMap = GetImport().GetNamespaceMap();
+ const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ for( sal_Int16 i=0; i < nAttrCount; i++ )
+ {
+ const rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
+ rtl::OUString aLocalName;
+ const sal_uInt16 nPrefix = rMap.GetKeyByAttrName(sAttrName, &aLocalName );
+ if ( nPrefix == XML_NAMESPACE_TABLE && IsXMLToken( aLocalName, XML_DATE_VALUE ) )
+ {
+ util::DateTime aNullDate;
+ const rtl::OUString sValue = xAttrList->getValueByIndex( i );
+ GetImport().GetMM100UnitConverter().convertDateTime(aNullDate, sValue);
+ m_aNullDate <<= aNullDate;
+ }
+ }
+}
+SvXMLImportContext* SchXMLCalculationSettingsContext::CreateChildContext( USHORT nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList )
+{
+ return new SchXMLCalculationSettingsContext(GetImport(),nPrefix,rLocalName,xAttrList);
+}
+
+void SchXMLCalculationSettingsContext::EndElement()
+{
+ if ( m_aNullDate.hasValue() )
+ {
+ Reference < XPropertySet > xPropSet ( GetImport().GetModel(), UNO_QUERY );
+ ::rtl::OUString sNullDate( RTL_CONSTASCII_USTRINGPARAM ( "NullDate" ) );
+ xPropSet->setPropertyValue ( sNullDate, m_aNullDate );
+ }
+}
diff --git a/xmloff/source/chart/SchXMLCalculationSettingsContext.hxx b/xmloff/source/chart/SchXMLCalculationSettingsContext.hxx
new file mode 100755
index 000000000000..9fe2db8a30a4
--- /dev/null
+++ b/xmloff/source/chart/SchXMLCalculationSettingsContext.hxx
@@ -0,0 +1,51 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _XMLOFF_SCHXMLCALCULATIONSETTINGSCONTEXT_HXX
+#define _XMLOFF_SCHXMLCALCULATIONSETTINGSCONTEXT_HXX
+
+#include <xmloff/xmlictxt.hxx>
+
+class SchXMLCalculationSettingsContext : public SvXMLImportContext
+{
+ com::sun::star::uno::Any m_aNullDate;
+public:
+ SchXMLCalculationSettingsContext( SvXMLImport& rImport,
+ sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
+
+ virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
+
+ virtual void EndElement();
+};
+
+
+#endif
diff --git a/xmloff/source/chart/SchXMLChartContext.cxx b/xmloff/source/chart/SchXMLChartContext.cxx
new file mode 100644
index 000000000000..e9e3771eb0d7
--- /dev/null
+++ b/xmloff/source/chart/SchXMLChartContext.cxx
@@ -0,0 +1,1432 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmloff.hxx"
+
+#include "SchXMLChartContext.hxx"
+#include "SchXMLImport.hxx"
+#include "SchXMLPlotAreaContext.hxx"
+#include "SchXMLParagraphContext.hxx"
+#include "SchXMLTableContext.hxx"
+#include "SchXMLSeriesHelper.hxx"
+#include "SchXMLSeries2Context.hxx"
+#include "SchXMLTools.hxx"
+#include <comphelper/mediadescriptor.hxx>
+#include <tools/debug.hxx>
+// header for class ByteString
+#include <tools/string.hxx>
+#include "xmlnmspe.hxx"
+#include <xmloff/xmlement.hxx>
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/nmspmap.hxx>
+#include <xmloff/xmluconv.hxx>
+#include <xmloff/xmlstyle.hxx>
+#include <xmloff/prstylei.hxx>
+
+#include "vector"
+#include <com/sun/star/chart/XChartDocument.hpp>
+#include <com/sun/star/chart/XDiagram.hpp>
+#include <com/sun/star/xml/sax/XAttributeList.hpp>
+#include <com/sun/star/chart/ChartLegendPosition.hpp>
+#include <com/sun/star/util/XStringMapping.hpp>
+#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#include <com/sun/star/drawing/XDrawPage.hpp>
+#include <com/sun/star/chart/ChartDataRowSource.hpp>
+#include <com/sun/star/awt/PosSize.hpp>
+#include <com/sun/star/embed/Aspects.hpp>
+#include <com/sun/star/embed/XVisualObject.hpp>
+#include <com/sun/star/drawing/FillStyle.hpp>
+
+#include <com/sun/star/chart2/XChartDocument.hpp>
+#include <com/sun/star/chart2/XChartTypeTemplate.hpp>
+#include <com/sun/star/chart2/data/XDataSink.hpp>
+#include <com/sun/star/chart2/XDataSeriesContainer.hpp>
+#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
+#include <com/sun/star/chart2/XChartTypeContainer.hpp>
+#include <com/sun/star/chart2/XTitled.hpp>
+
+using namespace com::sun::star;
+using namespace ::xmloff::token;
+using ::rtl::OUString;
+using com::sun::star::uno::Reference;
+using namespace ::SchXMLTools;
+
+namespace
+{
+uno::Reference< chart2::XChartTypeTemplate > lcl_getTemplate( const uno::Reference< chart2::XChartDocument > & xDoc )
+{
+ uno::Reference< chart2::XChartTypeTemplate > xResult;
+ try
+ {
+ if( !xDoc.is())
+ return xResult;
+ uno::Reference< lang::XMultiServiceFactory > xChartTypeManager( xDoc->getChartTypeManager(), uno::UNO_QUERY );
+ if( !xChartTypeManager.is())
+ return xResult;
+ uno::Reference< chart2::XDiagram > xDiagram( xDoc->getFirstDiagram());
+ if( !xDiagram.is())
+ return xResult;
+
+ uno::Sequence< ::rtl::OUString > aServiceNames( xChartTypeManager->getAvailableServiceNames());
+ const sal_Int32 nLength = aServiceNames.getLength();
+
+ for( sal_Int32 i = 0; i < nLength; ++i )
+ {
+ try
+ {
+ uno::Reference< chart2::XChartTypeTemplate > xTempl(
+ xChartTypeManager->createInstance( aServiceNames[ i ] ), uno::UNO_QUERY_THROW );
+
+ if( xTempl->matchesTemplate( xDiagram, sal_True ))
+ {
+ xResult.set( xTempl );
+ break;
+ }
+ }
+ catch( uno::Exception & )
+ {
+ DBG_ERROR( "Exception during determination of chart type template" );
+ }
+ }
+ }
+ catch( uno::Exception & )
+ {
+ DBG_ERROR( "Exception during import lcl_getTemplate" );
+ }
+ return xResult;
+}
+
+void lcl_setRoleAtLabeledSequence(
+ const uno::Reference< chart2::data::XLabeledDataSequence > & xLSeq,
+ const ::rtl::OUString &rRole )
+{
+ // set role of sequence
+ uno::Reference< chart2::data::XDataSequence > xValues( xLSeq->getValues());
+ if( xValues.is())
+ {
+ uno::Reference< beans::XPropertySet > xProp( xValues, uno::UNO_QUERY );
+ if( xProp.is())
+ xProp->setPropertyValue(OUString::createFromAscii("Role"), uno::makeAny( rRole ));
+ }
+}
+
+void lcl_MoveDataToCandleStickSeries(
+ const uno::Reference< chart2::data::XDataSource > & xDataSource,
+ const uno::Reference< chart2::XDataSeries > & xDestination,
+ const OUString & rRole )
+{
+ try
+ {
+ uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aLabeledSeq(
+ xDataSource->getDataSequences());
+ if( aLabeledSeq.getLength())
+ {
+ lcl_setRoleAtLabeledSequence( aLabeledSeq[0], rRole );
+
+ // add to data series
+ uno::Reference< chart2::data::XDataSource > xSource( xDestination, uno::UNO_QUERY_THROW );
+ // @todo: realloc only once outside this function
+ uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aData( xSource->getDataSequences());
+ aData.realloc( aData.getLength() + 1);
+ aData[ aData.getLength() - 1 ] = aLabeledSeq[0];
+ uno::Reference< chart2::data::XDataSink > xSink( xDestination, uno::UNO_QUERY_THROW );
+ xSink->setData( aData );
+ }
+ }
+ catch( uno::Exception & )
+ {
+ OSL_ENSURE( false, "Exception caught while moving data to candlestick series" );
+ }
+}
+
+void lcl_setRoleAtFirstSequence(
+ const uno::Reference< chart2::XDataSeries > & xSeries,
+ const ::rtl::OUString & rRole )
+{
+ uno::Reference< chart2::data::XDataSource > xSource( xSeries, uno::UNO_QUERY );
+ if( xSource.is())
+ {
+ uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aSeq( xSource->getDataSequences());
+ if( aSeq.getLength())
+ lcl_setRoleAtLabeledSequence( aSeq[0], rRole );
+ }
+}
+
+void lcl_removeEmptyChartTypeGroups( const uno::Reference< chart2::XChartDocument > & xDoc )
+{
+ if( ! xDoc.is())
+ return;
+
+ uno::Reference< chart2::XDiagram > xDia( xDoc->getFirstDiagram());
+ if( ! xDia.is())
+ return;
+
+ try
+ {
+ // count all charttype groups to be able to leave at least one
+ sal_Int32 nRemainingGroups = 0;
+ uno::Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDia, uno::UNO_QUERY_THROW );
+ uno::Sequence< uno::Reference< chart2::XCoordinateSystem > >
+ aCooSysSeq( xCooSysCnt->getCoordinateSystems());
+ for( sal_Int32 nI = aCooSysSeq.getLength(); nI--; )
+ {
+ uno::Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[nI], uno::UNO_QUERY_THROW );
+ nRemainingGroups += xCTCnt->getChartTypes().getLength();
+ }
+
+ // delete all empty groups, but leave at least group (empty or not)
+ for( sal_Int32 nI = aCooSysSeq.getLength(); nI-- && (nRemainingGroups > 1); )
+ {
+ uno::Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[nI], uno::UNO_QUERY_THROW );
+ uno::Sequence< uno::Reference< chart2::XChartType > > aCTSeq( xCTCnt->getChartTypes());
+ for( sal_Int32 nJ=aCTSeq.getLength(); nJ-- && (nRemainingGroups > 1); )
+ {
+ uno::Reference< chart2::XDataSeriesContainer > xDSCnt( aCTSeq[nJ], uno::UNO_QUERY_THROW );
+ if( xDSCnt->getDataSeries().getLength() == 0 )
+ {
+ // note: iterator stays valid as we have a local sequence
+ xCTCnt->removeChartType( aCTSeq[nJ] );
+ --nRemainingGroups;
+ }
+ }
+ }
+ }
+ catch( uno::Exception & ex )
+ {
+ String aStr( ex.Message );
+ ByteString aBStr( aStr, RTL_TEXTENCODING_ASCII_US );
+ DBG_ERROR1( "Exception caught while removing empty chart types: %s", aBStr.GetBuffer());
+ }
+}
+
+uno::Sequence< sal_Int32 > lcl_getNumberSequenceFromString( const ::rtl::OUString& rStr, bool bAddOneToEachOldIndex )
+{
+ const sal_Unicode aSpace( ' ' );
+
+ // count number of entries
+ ::std::vector< sal_Int32 > aVec;
+ sal_Int32 nLastPos = 0;
+ sal_Int32 nPos = 0;
+ while( nPos != -1 )
+ {
+ nPos = rStr.indexOf( aSpace, nLastPos );
+ if( nPos > nLastPos )
+ {
+ aVec.push_back( rStr.copy( nLastPos, (nPos - nLastPos) ).toInt32() );
+ }
+ if( nPos != -1 )
+ nLastPos = nPos + 1;
+ }
+ // last entry
+ if( nLastPos != 0 &&
+ rStr.getLength() > nLastPos )
+ {
+ aVec.push_back( rStr.copy( nLastPos, (rStr.getLength() - nLastPos) ).toInt32() );
+ }
+
+ const sal_Int32 nVecSize = aVec.size();
+ uno::Sequence< sal_Int32 > aSeq( nVecSize );
+
+ if(!bAddOneToEachOldIndex)
+ {
+ sal_Int32* pSeqArr = aSeq.getArray();
+ for( nPos = 0; nPos < nVecSize; ++nPos )
+ {
+ pSeqArr[ nPos ] = aVec[ nPos ];
+ }
+ }
+ else if( bAddOneToEachOldIndex )
+ {
+ aSeq.realloc( nVecSize+1 );
+ aSeq[0]=0;
+
+ sal_Int32* pSeqArr = aSeq.getArray();
+ for( nPos = 0; nPos < nVecSize; ++nPos )
+ {
+ pSeqArr[ nPos+1 ] = aVec[ nPos ]+1;
+ }
+ }
+
+ return aSeq;
+}
+
+} // anonymous namespace
+
+static __FAR_DATA SvXMLEnumMapEntry aXMLLegendAlignmentMap[] =
+{
+// { XML_LEFT, chart::ChartLegendPosition_LEFT },
+ // #i35421#
+ { XML_START, chart::ChartLegendPosition_LEFT },
+ { XML_TOP, chart::ChartLegendPosition_TOP },
+// { XML_RIGHT, chart::ChartLegendPosition_RIGHT },
+ // #i35421#
+ { XML_END, chart::ChartLegendPosition_RIGHT },
+ { XML_BOTTOM, chart::ChartLegendPosition_BOTTOM },
+ { XML_TOKEN_INVALID, 0 }
+};
+
+// ----------------------------------------
+
+SchXMLChartContext::SchXMLChartContext( SchXMLImportHelper& rImpHelper,
+ SvXMLImport& rImport, const rtl::OUString& rLocalName ) :
+ SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ),
+ mrImportHelper( rImpHelper ),
+ m_bHasRangeAtPlotArea( false ),
+ m_bHasTableElement( false ),
+ mbAllRangeAddressesAvailable( sal_True ),
+ mbColHasLabels( sal_False ),
+ mbRowHasLabels( sal_False ),
+ meDataRowSource( chart::ChartDataRowSource_COLUMNS ),
+ mbIsStockChart( false )
+{
+}
+
+SchXMLChartContext::~SchXMLChartContext()
+{}
+
+void SchXMLChartContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
+{
+ // parse attributes
+ sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
+ const SvXMLTokenMap& rAttrTokenMap = mrImportHelper.GetChartAttrTokenMap();
+
+ uno::Reference< embed::XVisualObject > xVisualObject( mrImportHelper.GetChartDocument(), uno::UNO_QUERY);
+ DBG_ASSERT(xVisualObject.is(),"need xVisualObject for page size");
+ if( xVisualObject.is() )
+ maChartSize = xVisualObject->getVisualAreaSize( embed::Aspects::MSOLE_CONTENT ); //#i103460# take the size given from the parent frame as default
+
+ // this flag is necessarry for pie charts in the core
+ sal_Bool bSetSwitchData = sal_False;
+
+ ::rtl::OUString sAutoStyleName;
+ ::rtl::OUString aOldChartTypeName;
+ bool bHasAddin = false;
+
+ for( sal_Int16 i = 0; i < nAttrCount; i++ )
+ {
+ rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
+ rtl::OUString aLocalName;
+ rtl::OUString aValue = xAttrList->getValueByIndex( i );
+ USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
+
+ switch( rAttrTokenMap.Get( nPrefix, aLocalName ))
+ {
+ case XML_TOK_CHART_HREF:
+ m_aXLinkHRefAttributeToIndicateDataProvider = aValue;
+ break;
+
+ case XML_TOK_CHART_CLASS:
+ {
+ rtl::OUString sClassName;
+ sal_uInt16 nClassPrefix =
+ GetImport().GetNamespaceMap().GetKeyByAttrName(
+ aValue, &sClassName );
+ if( XML_NAMESPACE_CHART == nClassPrefix )
+ {
+ SchXMLChartTypeEnum eChartTypeEnum = SchXMLTools::GetChartTypeEnum( sClassName );
+ if( eChartTypeEnum != XML_CHART_CLASS_UNKNOWN )
+ {
+ aOldChartTypeName = SchXMLTools::GetChartTypeByClassName( sClassName, true /* bUseOldNames */ );
+ maChartTypeServiceName = SchXMLTools::GetChartTypeByClassName( sClassName, false /* bUseOldNames */ );
+ switch( eChartTypeEnum )
+ {
+ case XML_CHART_CLASS_CIRCLE:
+ bSetSwitchData = sal_True;
+ break;
+ case XML_CHART_CLASS_STOCK:
+ mbIsStockChart = true;
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ else if( XML_NAMESPACE_OOO == nClassPrefix )
+ {
+ // service is taken from add-in-name attribute
+ bHasAddin = true;
+
+ aOldChartTypeName = sClassName;
+ maChartTypeServiceName = sClassName;
+ }
+ }
+ break;
+
+ case XML_TOK_CHART_WIDTH:
+ GetImport().GetMM100UnitConverter().convertMeasure( maChartSize.Width, aValue );
+ break;
+
+ case XML_TOK_CHART_HEIGHT:
+ GetImport().GetMM100UnitConverter().convertMeasure( maChartSize.Height, aValue );
+ break;
+
+ case XML_TOK_CHART_STYLE_NAME:
+ sAutoStyleName = aValue;
+ break;
+
+ case XML_TOK_CHART_COL_MAPPING:
+ msColTrans = aValue;
+ break;
+ case XML_TOK_CHART_ROW_MAPPING:
+ msRowTrans = aValue;
+ break;
+ }
+ }
+
+ if( aOldChartTypeName.getLength()<= 0 )
+ {
+ DBG_ERROR( "need a charttype to create a diagram" );
+ //set a fallback value:
+ ::rtl::OUString aChartClass_Bar( GetXMLToken(XML_BAR ) );
+ aOldChartTypeName = SchXMLTools::GetChartTypeByClassName( aChartClass_Bar, true /* bUseOldNames */ );
+ maChartTypeServiceName = SchXMLTools::GetChartTypeByClassName( aChartClass_Bar, false /* bUseOldNames */ );
+ }
+
+ // Set the size of the draw page.
+ if( xVisualObject.is() )
+ xVisualObject->setVisualAreaSize( embed::Aspects::MSOLE_CONTENT, maChartSize );
+
+ InitChart( aOldChartTypeName, bSetSwitchData);
+
+ if( bHasAddin )
+ {
+ //correct charttype serveice name when having an addin
+ //and don't refresh addin during load
+ uno::Reference< beans::XPropertySet > xDocProp( mrImportHelper.GetChartDocument(), uno::UNO_QUERY );
+ if( xDocProp.is() )
+ {
+ try
+ {
+ xDocProp->getPropertyValue( ::rtl::OUString::createFromAscii("BaseDiagram")) >>= aOldChartTypeName;
+ maChartTypeServiceName = SchXMLTools::GetNewChartTypeName( aOldChartTypeName );
+ xDocProp->setPropertyValue( rtl::OUString::createFromAscii( "RefreshAddInAllowed" ) , uno::makeAny( sal_False) );
+ }
+ catch( uno::Exception & )
+ {
+ DBG_ERROR( "Exception during import SchXMLChartContext::StartElement" );
+ }
+ }
+ }
+
+ // set auto-styles for Area
+ uno::Reference< beans::XPropertySet > xProp( mrImportHelper.GetChartDocument()->getArea(), uno::UNO_QUERY );
+ if( xProp.is())
+ {
+ const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext();
+ if( pStylesCtxt )
+ {
+ const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext(
+ mrImportHelper.GetChartFamilyID(), sAutoStyleName );
+
+ if( pStyle && pStyle->ISA( XMLPropStyleContext ))
+ (( XMLPropStyleContext* )pStyle )->FillPropertySet( xProp );
+ }
+ }
+}
+
+namespace
+{
+
+struct NewDonutSeries
+{
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XDataSeries > m_xSeries;
+ ::rtl::OUString msStyleName;
+ sal_Int32 mnAttachedAxis;
+
+ ::std::vector< ::rtl::OUString > m_aSeriesStyles;
+ ::std::vector< ::rtl::OUString > m_aPointStyles;
+
+ NewDonutSeries( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XDataSeries >& xSeries, sal_Int32 nPointCount )
+ : m_xSeries( xSeries )
+ , mnAttachedAxis( 1 )
+ {
+ m_aPointStyles.resize(nPointCount);
+ m_aSeriesStyles.resize(nPointCount);
+ }
+
+ void setSeriesStyleNameToPoint( const ::rtl::OUString& rStyleName, sal_Int32 nPointIndex )
+ {
+ DBG_ASSERT(nPointIndex < static_cast<sal_Int32>(m_aSeriesStyles.size()),"donut point <-> series count mismatch");
+ if( nPointIndex < static_cast<sal_Int32>(m_aSeriesStyles.size()) )
+ m_aSeriesStyles[nPointIndex]=rStyleName;
+ }
+
+ void setPointStyleNameToPoint( const ::rtl::OUString& rStyleName, sal_Int32 nPointIndex )
+ {
+ DBG_ASSERT(nPointIndex < static_cast<sal_Int32>(m_aPointStyles.size()),"donut point <-> series count mismatch");
+ if( nPointIndex < static_cast<sal_Int32>(m_aPointStyles.size()) )
+ m_aPointStyles[nPointIndex]=rStyleName;
+ }
+
+ ::std::list< DataRowPointStyle > creatStyleList()
+ {
+ ::std::list< DataRowPointStyle > aRet;
+
+ DataRowPointStyle aSeriesStyle( DataRowPointStyle::DATA_SERIES
+ , m_xSeries, -1, 1, msStyleName, mnAttachedAxis );
+ aRet.push_back( aSeriesStyle );
+
+ sal_Int32 nPointIndex=0;
+ ::std::vector< ::rtl::OUString >::iterator aPointIt( m_aPointStyles.begin() );
+ ::std::vector< ::rtl::OUString >::iterator aPointEnd( m_aPointStyles.end() );
+ while( aPointIt != aPointEnd )
+ {
+ DataRowPointStyle aPointStyle( DataRowPointStyle::DATA_POINT
+ , m_xSeries, nPointIndex, 1, *aPointIt, mnAttachedAxis );
+ if( nPointIndex < static_cast<sal_Int32>(m_aSeriesStyles.size()) )
+ {
+ aPointStyle.msSeriesStyleNameForDonuts = m_aSeriesStyles[nPointIndex];
+ }
+ if( aPointStyle.msSeriesStyleNameForDonuts.getLength()
+ || aPointStyle.msStyleName.getLength() )
+ aRet.push_back( aPointStyle );
+ ++aPointIt;
+ ++nPointIndex;
+ }
+
+ return aRet;
+ }
+};
+
+void lcl_swapPointAndSeriesStylesForDonutCharts( ::std::list< DataRowPointStyle >& rStyleList
+ , const ::std::map< ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XDataSeries> , sal_Int32 >& rSeriesMap )
+{
+ ::std::list< DataRowPointStyle >::iterator aIt(rStyleList.begin());
+ ::std::list< DataRowPointStyle >::iterator aEnd(rStyleList.end());
+
+ //detect old series count
+ //and add old series to aSeriesMap
+ ::std::map< ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XDataSeries >, sal_Int32 > aSeriesMap(rSeriesMap);
+ sal_Int32 nOldSeriesCount = 0;
+ {
+ sal_Int32 nMaxOldSeriesIndex = 0;
+ sal_Int32 nOldSeriesIndex = 0;
+ for( aIt = rStyleList.begin(); aIt != aEnd; ++aIt )
+ {
+ DataRowPointStyle aStyle(*aIt);
+ if(aStyle.meType == DataRowPointStyle::DATA_SERIES &&
+ aStyle.m_xSeries.is() )
+ {
+ nMaxOldSeriesIndex = nOldSeriesIndex;
+
+ if( aSeriesMap.end() == aSeriesMap.find(aStyle.m_xSeries) )
+ aSeriesMap[aStyle.m_xSeries] = nOldSeriesIndex;
+
+ nOldSeriesIndex++;
+ }
+ }
+ nOldSeriesCount = nMaxOldSeriesIndex+1;
+ }
+ /*
+ sal_Int32 nOldSeriesCount = 0;
+ {
+ sal_Int32 nMaxOldSeriesIndex = 0;
+ sal_Int32 nOldSeriesIndex = 0;
+ for( aIt = rStyleList.begin(); aIt != aEnd; ++aIt )
+ {
+ DataRowPointStyle aStyle(*aIt);
+ if(aStyle.meType == DataRowPointStyle::DATA_SERIES )
+ {
+ nMaxOldSeriesIndex = nOldSeriesIndex;
+ nOldSeriesIndex++;
+ }
+ }
+ nOldSeriesCount = nMaxOldSeriesIndex+1;
+ }
+ */
+
+
+ //initialize new series styles
+ ::std::map< Reference< chart2::XDataSeries >, sal_Int32 >::const_iterator aSeriesMapIt( aSeriesMap.begin() );
+ ::std::map< Reference< chart2::XDataSeries >, sal_Int32 >::const_iterator aSeriesMapEnd( aSeriesMap.end() );
+
+ //sort by index
+ ::std::vector< NewDonutSeries > aNewSeriesVector;
+ {
+ ::std::map< sal_Int32, Reference< chart2::XDataSeries > > aIndexSeriesMap;
+ for( ; aSeriesMapIt != aSeriesMapEnd; ++aSeriesMapIt )
+ aIndexSeriesMap[aSeriesMapIt->second] = aSeriesMapIt->first;
+
+ ::std::map< sal_Int32, Reference< chart2::XDataSeries > >::const_iterator aIndexIt( aIndexSeriesMap.begin() );
+ ::std::map< sal_Int32, Reference< chart2::XDataSeries > >::const_iterator aIndexEnd( aIndexSeriesMap.end() );
+
+ for( ; aIndexIt != aIndexEnd; ++aIndexIt )
+ aNewSeriesVector.push_back( NewDonutSeries(aIndexIt->second,nOldSeriesCount) );
+ }
+
+ //overwrite attached axis information according to old series styles
+ for( aIt = rStyleList.begin(); aIt != aEnd; ++aIt )
+ {
+ DataRowPointStyle aStyle(*aIt);
+ if(aStyle.meType == DataRowPointStyle::DATA_SERIES )
+ {
+ aSeriesMapIt = aSeriesMap.find( aStyle.m_xSeries );
+ if( aSeriesMapIt != aSeriesMapEnd && aSeriesMapIt->second < static_cast<sal_Int32>(aNewSeriesVector.size()) )
+ aNewSeriesVector[aSeriesMapIt->second].mnAttachedAxis = aStyle.mnAttachedAxis;
+ }
+ }
+
+ //overwrite new series style names with old series style name information
+ for( aIt = rStyleList.begin(); aIt != aEnd; ++aIt )
+ {
+ DataRowPointStyle aStyle(*aIt);
+ if( aStyle.meType == DataRowPointStyle::DATA_SERIES )
+ {
+ aSeriesMapIt = aSeriesMap.find(aStyle.m_xSeries);
+ if( aSeriesMapEnd != aSeriesMapIt )
+ {
+ sal_Int32 nNewPointIndex = aSeriesMapIt->second;
+
+ ::std::vector< NewDonutSeries >::iterator aNewSeriesIt( aNewSeriesVector.begin() );
+ ::std::vector< NewDonutSeries >::iterator aNewSeriesEnd( aNewSeriesVector.end() );
+
+ for( ;aNewSeriesIt!=aNewSeriesEnd; ++aNewSeriesIt)
+ aNewSeriesIt->setSeriesStyleNameToPoint( aStyle.msStyleName, nNewPointIndex );
+ }
+ }
+ }
+
+ //overwrite new series style names with point style name information
+ for( aIt = rStyleList.begin(); aIt != aEnd; ++aIt )
+ {
+ DataRowPointStyle aStyle(*aIt);
+ if( aStyle.meType == DataRowPointStyle::DATA_POINT )
+ {
+ aSeriesMapIt = aSeriesMap.find(aStyle.m_xSeries);
+ if( aSeriesMapEnd != aSeriesMapIt )
+ {
+ sal_Int32 nNewPointIndex = aSeriesMapIt->second;
+ sal_Int32 nNewSeriesIndex = aStyle.m_nPointIndex;
+ sal_Int32 nRepeatCount = aStyle.m_nPointRepeat;
+
+ while( nRepeatCount && (nNewSeriesIndex>=0) && (nNewSeriesIndex< static_cast<sal_Int32>(aNewSeriesVector.size()) ) )
+ {
+ NewDonutSeries& rNewSeries( aNewSeriesVector[nNewSeriesIndex] );
+ rNewSeries.setPointStyleNameToPoint( aStyle.msStyleName, nNewPointIndex );
+
+ nRepeatCount--;
+ nNewSeriesIndex++;
+ }
+ }
+ }
+ }
+
+ //put information from aNewSeriesVector to output parameter rStyleList
+ rStyleList.clear();
+
+ ::std::vector< NewDonutSeries >::iterator aNewSeriesIt( aNewSeriesVector.begin() );
+ ::std::vector< NewDonutSeries >::iterator aNewSeriesEnd( aNewSeriesVector.end() );
+ for( ;aNewSeriesIt!=aNewSeriesEnd; ++aNewSeriesIt)
+ {
+ ::std::list< DataRowPointStyle > aList( aNewSeriesIt->creatStyleList() );
+ rStyleList.insert(rStyleList.end(),aList.begin(),aList.end());
+ }
+}
+
+bool lcl_SpecialHandlingForDonutChartNeeded(
+ const ::rtl::OUString & rServiceName,
+ const SvXMLImport & rImport )
+{
+ bool bResult = false;
+ if( rServiceName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart2.DonutChartType" )))
+ {
+ bResult = SchXMLTools::isDocumentGeneratedWithOpenOfficeOlderThan2_3( rImport.GetModel() );
+ }
+ return bResult;
+}
+
+} // anonymous namespace
+
+
+void lcl_ApplyDataFromRectangularRangeToDiagram(
+ const uno::Reference< chart2::XChartDocument >& xNewDoc
+ , const rtl::OUString& rRectangularRange
+ , ::com::sun::star::chart::ChartDataRowSource eDataRowSource
+ , bool bRowHasLabels, bool bColHasLabels
+ , bool bSwitchOnLabelsAndCategoriesForOwnData
+ , const rtl::OUString& sColTrans
+ , const rtl::OUString& sRowTrans )
+{
+ if( !xNewDoc.is() )
+ return;
+
+ uno::Reference< chart2::XDiagram > xNewDia( xNewDoc->getFirstDiagram());
+ uno::Reference< chart2::data::XDataProvider > xDataProvider( xNewDoc->getDataProvider() );
+ if( !xNewDia.is() || !xDataProvider.is() )
+ return;
+
+ uno::Reference< chart2::XChartTypeTemplate > xTemplate( lcl_getTemplate( xNewDoc ));
+ if(!xTemplate.is())
+ return;
+
+ sal_Bool bFirstCellAsLabel =
+ (eDataRowSource==chart::ChartDataRowSource_COLUMNS)? bRowHasLabels : bColHasLabels;
+ sal_Bool bHasCateories =
+ (eDataRowSource==chart::ChartDataRowSource_COLUMNS)? bColHasLabels : bRowHasLabels;
+
+ if( bSwitchOnLabelsAndCategoriesForOwnData )
+ {
+ bFirstCellAsLabel = true;
+ bHasCateories = true;
+ }
+
+ uno::Sequence< beans::PropertyValue > aArgs( 3 );
+ aArgs[0] = beans::PropertyValue(
+ ::rtl::OUString::createFromAscii("CellRangeRepresentation"),
+ -1, uno::makeAny( rRectangularRange ),
+ beans::PropertyState_DIRECT_VALUE );
+ aArgs[1] = beans::PropertyValue(
+ ::rtl::OUString::createFromAscii("DataRowSource"),
+ -1, uno::makeAny( eDataRowSource ),
+ beans::PropertyState_DIRECT_VALUE );
+ aArgs[2] = beans::PropertyValue(
+ ::rtl::OUString::createFromAscii("FirstCellAsLabel"),
+ -1, uno::makeAny( bFirstCellAsLabel ),
+ beans::PropertyState_DIRECT_VALUE );
+
+ if( sColTrans.getLength() || sRowTrans.getLength() )
+ {
+ aArgs.realloc( aArgs.getLength() + 1 );
+ aArgs[ aArgs.getLength() - 1 ] = beans::PropertyValue(
+ ::rtl::OUString::createFromAscii("SequenceMapping"),
+ -1, uno::makeAny( sColTrans.getLength()
+ ? lcl_getNumberSequenceFromString( sColTrans, bHasCateories && !xNewDoc->hasInternalDataProvider() )
+ : lcl_getNumberSequenceFromString( sRowTrans, bHasCateories && !xNewDoc->hasInternalDataProvider() ) ),
+ beans::PropertyState_DIRECT_VALUE );
+ }
+
+ //work around wrong writer ranges ( see Issue 58464 )
+ {
+ rtl::OUString aChartOleObjectName;
+ uno::Reference< frame::XModel > xModel(xNewDoc, uno::UNO_QUERY );
+ if( xModel.is() )
+ {
+ comphelper::MediaDescriptor aMediaDescriptor( xModel->getArgs() );
+
+ comphelper::MediaDescriptor::const_iterator aIt(
+ aMediaDescriptor.find( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HierarchicalDocumentName" ))));
+ if( aIt != aMediaDescriptor.end() )
+ {
+ aChartOleObjectName = (*aIt).second.get< ::rtl::OUString >();
+ }
+ }
+ if( aChartOleObjectName.getLength() )
+ {
+ aArgs.realloc( aArgs.getLength() + 1 );
+ aArgs[ aArgs.getLength() - 1 ] = beans::PropertyValue(
+ ::rtl::OUString::createFromAscii("ChartOleObjectName"),
+ -1, uno::makeAny( aChartOleObjectName ),
+ beans::PropertyState_DIRECT_VALUE );
+ }
+ }
+
+
+ uno::Reference< chart2::data::XDataSource > xDataSource(
+ xDataProvider->createDataSource( aArgs ));
+
+ aArgs.realloc( aArgs.getLength() + 1 );
+ aArgs[ aArgs.getLength() - 1 ] = beans::PropertyValue(
+ ::rtl::OUString::createFromAscii("HasCategories"),
+ -1, uno::makeAny( bHasCateories ),
+ beans::PropertyState_DIRECT_VALUE );
+
+ xTemplate->changeDiagramData( xNewDia, xDataSource, aArgs );
+}
+
+void SchXMLChartContext::EndElement()
+{
+ uno::Reference< chart::XChartDocument > xDoc = mrImportHelper.GetChartDocument();
+ uno::Reference< beans::XPropertySet > xProp( xDoc, uno::UNO_QUERY );
+ uno::Reference< chart2::XChartDocument > xNewDoc( xDoc, uno::UNO_QUERY );
+
+ if( xProp.is())
+ {
+ if( maMainTitle.getLength())
+ {
+ uno::Reference< beans::XPropertySet > xTitleProp( xDoc->getTitle(), uno::UNO_QUERY );
+ if( xTitleProp.is())
+ {
+ try
+ {
+ uno::Any aAny;
+ aAny <<= maMainTitle;
+ xTitleProp->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "String" )), aAny );
+ }
+ catch( beans::UnknownPropertyException )
+ {
+ DBG_ERROR( "Property String for Title not available" );
+ }
+ }
+ }
+ if( maSubTitle.getLength())
+ {
+ uno::Reference< beans::XPropertySet > xTitleProp( xDoc->getSubTitle(), uno::UNO_QUERY );
+ if( xTitleProp.is())
+ {
+ try
+ {
+ uno::Any aAny;
+ aAny <<= maSubTitle;
+ xTitleProp->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "String" )), aAny );
+ }
+ catch( beans::UnknownPropertyException )
+ {
+ DBG_ERROR( "Property String for Title not available" );
+ }
+ }
+ }
+ }
+
+ // cleanup: remove empty chart type groups
+ lcl_removeEmptyChartTypeGroups( xNewDoc );
+
+ // set stack mode before a potential template detection (in case we have a
+ // rectangular range)
+ uno::Reference< chart::XDiagram > xDiagram( xDoc->getDiagram() );
+ uno::Reference< beans::XPropertySet > xDiaProp( xDiagram, uno::UNO_QUERY );
+ if( xDiaProp.is())
+ {
+ if( maSeriesDefaultsAndStyles.maStackedDefault.hasValue())
+ xDiaProp->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Stacked")),maSeriesDefaultsAndStyles.maStackedDefault);
+ if( maSeriesDefaultsAndStyles.maPercentDefault.hasValue())
+ xDiaProp->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Percent")),maSeriesDefaultsAndStyles.maPercentDefault);
+ if( maSeriesDefaultsAndStyles.maDeepDefault.hasValue())
+ xDiaProp->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Deep")),maSeriesDefaultsAndStyles.maDeepDefault);
+ if( maSeriesDefaultsAndStyles.maStackedBarsConnectedDefault.hasValue())
+ xDiaProp->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StackedBarsConnected")),maSeriesDefaultsAndStyles.maStackedBarsConnectedDefault);
+ }
+
+ //the OOo 2.0 implementation and older has a bug with donuts
+ bool bSpecialHandlingForDonutChart = lcl_SpecialHandlingForDonutChartNeeded(
+ maChartTypeServiceName, GetImport());
+
+ // apply data
+ if(!xNewDoc.is())
+ return;
+
+ bool bHasOwnData = false;
+ if( m_aXLinkHRefAttributeToIndicateDataProvider.equalsAscii( "." ) ) //data comes from the chart itself
+ bHasOwnData = true;
+ else if( m_aXLinkHRefAttributeToIndicateDataProvider.equalsAscii( ".." ) ) //data comes from the parent application
+ bHasOwnData = false;
+ else if( m_aXLinkHRefAttributeToIndicateDataProvider.getLength() ) //not supported so far to get the data by sibling objects -> fall back to chart itself if data are available
+ bHasOwnData = m_bHasTableElement;
+ else
+ bHasOwnData = !m_bHasRangeAtPlotArea;
+
+ if( xNewDoc->hasInternalDataProvider())
+ {
+ if( !m_bHasTableElement && !m_aXLinkHRefAttributeToIndicateDataProvider.equalsAscii( "." ) )
+ {
+ //#i103147# ODF, workaround broken files with a missing table:cell-range-address at the plot-area
+ bool bSwitchSuccessful = SchXMLTools::switchBackToDataProviderFromParent( xNewDoc, maLSequencesPerIndex );
+ bHasOwnData = !bSwitchSuccessful;
+ }
+ else
+ bHasOwnData = true;//e.g. in case of copy->paste from calc to impress
+ }
+ else if( bHasOwnData )
+ {
+ xNewDoc->createInternalDataProvider( sal_False /* bCloneExistingData */ );
+ }
+ if( bHasOwnData )
+ msChartAddress = ::rtl::OUString::createFromAscii("all");
+
+ bool bSwitchRangesFromOuterToInternalIfNecessary = false;
+ if( !bHasOwnData && mbAllRangeAddressesAvailable )
+ {
+ // special handling for stock chart (merge series together)
+ if( mbIsStockChart )
+ MergeSeriesForStockChart();
+ }
+ else if( msChartAddress.getLength() )
+ {
+ //own data or only rectangular range available
+
+ if( xNewDoc->hasInternalDataProvider() )
+ SchXMLTableHelper::applyTableToInternalDataProvider( maTable, xNewDoc );
+
+ bool bOlderThan2_3 = SchXMLTools::isDocumentGeneratedWithOpenOfficeOlderThan2_3( Reference< frame::XModel >( xNewDoc, uno::UNO_QUERY ));
+ bool bOldFileWithOwnDataFromRows = (bOlderThan2_3 && bHasOwnData && (meDataRowSource==chart::ChartDataRowSource_ROWS)); // in this case there are range addresses that are simply wrong.
+
+ if( mbAllRangeAddressesAvailable && !bSpecialHandlingForDonutChart && !mbIsStockChart &&
+ !bOldFileWithOwnDataFromRows )
+ {
+ //bHasOwnData is true in this case!
+ //e.g. for normal files with own data or also in case of copy paste scenario (e.g. calc to impress)
+ bSwitchRangesFromOuterToInternalIfNecessary = true;
+ }
+ else
+ {
+ //apply data from rectangular range
+
+ // create datasource from data provider with rectangular range
+ // parameters and change the diagram via template mechanism
+ try
+ {
+ if( bOlderThan2_3 && xDiaProp.is() )//for older charts the hidden cells were removed by calc on the fly
+ xDiaProp->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IncludeHiddenCells")),uno::makeAny(false));
+
+ // note: mbRowHasLabels means the first row contains labels, that means we have "column-descriptions",
+ // (analogously mbColHasLabels means we have "row-descriptions")
+ lcl_ApplyDataFromRectangularRangeToDiagram( xNewDoc, msChartAddress, meDataRowSource, mbRowHasLabels, mbColHasLabels, bHasOwnData, msColTrans, msRowTrans );
+ }
+ catch( uno::Exception & )
+ {
+ //try to fallback to internal data
+ DBG_ERROR( "Exception during import SchXMLChartContext::lcl_ApplyDataFromRectangularRangeToDiagram try to fallback to internal data" );
+ if(!bHasOwnData)
+ {
+ bHasOwnData = true;
+ msChartAddress = ::rtl::OUString::createFromAscii("all");
+ if( !xNewDoc->hasInternalDataProvider() )
+ {
+ xNewDoc->createInternalDataProvider( sal_False /* bCloneExistingData */ );
+ SchXMLTableHelper::applyTableToInternalDataProvider( maTable, xNewDoc );
+ try
+ {
+ lcl_ApplyDataFromRectangularRangeToDiagram( xNewDoc, msChartAddress, meDataRowSource, mbRowHasLabels, mbColHasLabels, bHasOwnData, msColTrans, msRowTrans );
+ }
+ catch( uno::Exception & )
+ {
+ DBG_ERROR( "Exception during import SchXMLChartContext::lcl_ApplyDataFromRectangularRangeToDiagram fallback to internal data failed also" );
+ }
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ DBG_ERROR( " Must not get here" );
+ }
+
+ // now all series and data point properties are available and can be set
+ {
+ if( bSpecialHandlingForDonutChart )
+ {
+ uno::Reference< chart2::XDiagram > xNewDiagram( xNewDoc->getFirstDiagram() );
+ lcl_swapPointAndSeriesStylesForDonutCharts( maSeriesDefaultsAndStyles.maSeriesStyleList
+ , SchXMLSeriesHelper::getDataSeriesIndexMapFromDiagram(xNewDiagram) );
+ }
+
+ SchXMLSeries2Context::initSeriesPropertySets( maSeriesDefaultsAndStyles, uno::Reference< frame::XModel >(xDoc, uno::UNO_QUERY ) );
+
+ //set defaults from diagram to the new series:
+ //check whether we need to remove lines from symbol only charts
+ bool bSwitchOffLinesForScatter = false;
+ {
+ bool bLinesOn = true;
+ if( (maSeriesDefaultsAndStyles.maLinesOnProperty >>= bLinesOn) && !bLinesOn )
+ {
+ if( 0 == maChartTypeServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart2.ScatterChartType" ) ) )
+ {
+ bSwitchOffLinesForScatter = true;
+ SchXMLSeries2Context::switchSeriesLinesOff( maSeriesDefaultsAndStyles.maSeriesStyleList );
+ }
+ }
+ }
+ SchXMLSeries2Context::setDefaultsToSeries( maSeriesDefaultsAndStyles );
+
+ // set autostyles for series and data points
+ const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext();
+ const SvXMLStyleContext* pStyle = NULL;
+ ::rtl::OUString sCurrStyleName;
+
+ if( pStylesCtxt )
+ {
+ //iterate over data-series first
+ //don't set series styles for donut charts
+ if( !bSpecialHandlingForDonutChart )
+ {
+ SchXMLSeries2Context::setStylesToSeries( maSeriesDefaultsAndStyles
+ , pStylesCtxt, pStyle, sCurrStyleName, mrImportHelper, GetImport(), mbIsStockChart, maLSequencesPerIndex );
+ // ... then set attributes for statistics (after their existence was set in the series)
+ SchXMLSeries2Context::setStylesToStatisticsObjects( maSeriesDefaultsAndStyles
+ , pStylesCtxt, pStyle, sCurrStyleName );
+ }
+ }
+
+ //#i98319# call switchRangesFromOuterToInternalIfNecessary before the data point styles are applied, otherwise in copy->paste scenario the data point styles do get lost
+ if( bSwitchRangesFromOuterToInternalIfNecessary )
+ {
+ if( xNewDoc->hasInternalDataProvider() )
+ SchXMLTableHelper::switchRangesFromOuterToInternalIfNecessary( maTable, maLSequencesPerIndex, xNewDoc, meDataRowSource );
+ }
+
+ if( pStylesCtxt )
+ {
+ // ... then iterate over data-point attributes, so the latter are not overwritten
+ SchXMLSeries2Context::setStylesToDataPoints( maSeriesDefaultsAndStyles
+ , pStylesCtxt, pStyle, sCurrStyleName, mrImportHelper, GetImport(), mbIsStockChart, bSpecialHandlingForDonutChart, bSwitchOffLinesForScatter );
+ }
+ }
+
+ if( xProp.is())
+ xProp->setPropertyValue( rtl::OUString::createFromAscii( "RefreshAddInAllowed" ) , uno::makeAny( sal_True) );
+}
+
+void SchXMLChartContext::MergeSeriesForStockChart()
+{
+ OSL_ASSERT( mbIsStockChart );
+ try
+ {
+ uno::Reference< chart::XChartDocument > xOldDoc( mrImportHelper.GetChartDocument());
+ uno::Reference< chart2::XChartDocument > xDoc( xOldDoc, uno::UNO_QUERY_THROW );
+ uno::Reference< chart2::XDiagram > xDiagram( xDoc->getFirstDiagram());
+ if( ! xDiagram.is())
+ return;
+
+ bool bHasJapaneseCandlestick = true;
+ uno::Reference< chart2::XDataSeriesContainer > xDSContainer;
+ uno::Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY_THROW );
+ uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems());
+ for( sal_Int32 nCooSysIdx=0; nCooSysIdx<aCooSysSeq.getLength(); ++nCooSysIdx )
+ {
+ uno::Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[nCooSysIdx], uno::UNO_QUERY_THROW );
+ uno::Sequence< uno::Reference< chart2::XChartType > > aChartTypes( xCTCnt->getChartTypes());
+ for( sal_Int32 nCTIdx=0; nCTIdx<aChartTypes.getLength(); ++nCTIdx )
+ {
+ if( aChartTypes[nCTIdx]->getChartType().equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.CandleStickChartType")))
+ {
+ xDSContainer.set( aChartTypes[nCTIdx], uno::UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySet > xCTProp( aChartTypes[nCTIdx], uno::UNO_QUERY_THROW );
+ xCTProp->getPropertyValue( ::rtl::OUString::createFromAscii("Japanese")) >>= bHasJapaneseCandlestick;
+ break;
+ }
+ }
+ }
+
+ if( xDSContainer.is())
+ {
+ // with japanese candlesticks: open, low, high, close
+ // otherwise: low, high, close
+ uno::Sequence< uno::Reference< chart2::XDataSeries > > aSeriesSeq( xDSContainer->getDataSeries());
+ const sal_Int32 nSeriesCount( aSeriesSeq.getLength());
+ const sal_Int32 nSeriesPerCandleStick = bHasJapaneseCandlestick ? 4: 3;
+ sal_Int32 nCandleStickCount = nSeriesCount / nSeriesPerCandleStick;
+ OSL_ASSERT( nSeriesPerCandleStick * nCandleStickCount == nSeriesCount );
+ uno::Sequence< uno::Reference< chart2::XDataSeries > > aNewSeries( nCandleStickCount );
+ for( sal_Int32 i=0; i<nCandleStickCount; ++i )
+ {
+ sal_Int32 nSeriesIndex = i*nSeriesPerCandleStick;
+ if( bHasJapaneseCandlestick )
+ {
+ // open values
+ lcl_setRoleAtFirstSequence( aSeriesSeq[ nSeriesIndex ], OUString::createFromAscii("values-first"));
+ aNewSeries[i] = aSeriesSeq[ nSeriesIndex ];
+ // low values
+ lcl_MoveDataToCandleStickSeries(
+ uno::Reference< chart2::data::XDataSource >( aSeriesSeq[ ++nSeriesIndex ], uno::UNO_QUERY_THROW ),
+ aNewSeries[i], OUString::createFromAscii("values-min"));
+ }
+ else
+ {
+ // low values
+ lcl_setRoleAtFirstSequence( aSeriesSeq[ nSeriesIndex ], OUString::createFromAscii("values-min"));
+ aNewSeries[i] = aSeriesSeq[ nSeriesIndex ];
+ }
+ // high values
+ lcl_MoveDataToCandleStickSeries(
+ uno::Reference< chart2::data::XDataSource >( aSeriesSeq[ ++nSeriesIndex ], uno::UNO_QUERY_THROW ),
+ aNewSeries[i], OUString::createFromAscii("values-max"));
+ // close values
+ lcl_MoveDataToCandleStickSeries(
+ uno::Reference< chart2::data::XDataSource >( aSeriesSeq[ ++nSeriesIndex ], uno::UNO_QUERY_THROW ),
+ aNewSeries[i], OUString::createFromAscii("values-last"));
+ }
+ xDSContainer->setDataSeries( aNewSeries );
+ }
+ }
+ catch( uno::Exception & )
+ {
+ DBG_ERROR( "Exception while merging series for stock chart" );
+ }
+}
+
+SvXMLImportContext* SchXMLChartContext::CreateChildContext(
+ USHORT nPrefix,
+ const rtl::OUString& rLocalName,
+ const uno::Reference< xml::sax::XAttributeList >& xAttrList )
+{
+ static const sal_Bool bTrue = sal_True;
+ static const uno::Any aTrueBool( &bTrue, ::getBooleanCppuType());
+
+ SvXMLImportContext* pContext = 0;
+ const SvXMLTokenMap& rTokenMap = mrImportHelper.GetChartElemTokenMap();
+ uno::Reference< chart::XChartDocument > xDoc = mrImportHelper.GetChartDocument();
+ uno::Reference< beans::XPropertySet > xProp( xDoc, uno::UNO_QUERY );
+
+ switch( rTokenMap.Get( nPrefix, rLocalName ))
+ {
+ case XML_TOK_CHART_PLOT_AREA:
+ pContext = new SchXMLPlotAreaContext( mrImportHelper, GetImport(), rLocalName,
+ m_aXLinkHRefAttributeToIndicateDataProvider,
+ maSeriesAddresses, msCategoriesAddress,
+ msChartAddress, m_bHasRangeAtPlotArea, mbAllRangeAddressesAvailable,
+ mbColHasLabels, mbRowHasLabels,
+ meDataRowSource,
+ maSeriesDefaultsAndStyles,
+ maChartTypeServiceName,
+ maLSequencesPerIndex, maChartSize );
+ break;
+
+ case XML_TOK_CHART_TITLE:
+ if( xDoc.is())
+ {
+ if( xProp.is())
+ {
+ xProp->setPropertyValue( rtl::OUString::createFromAscii( "HasMainTitle" ), aTrueBool );
+ }
+ uno::Reference< drawing::XShape > xTitleShape( xDoc->getTitle(), uno::UNO_QUERY );
+ pContext = new SchXMLTitleContext( mrImportHelper, GetImport(),
+ rLocalName, maMainTitle, xTitleShape );
+ }
+ break;
+
+ case XML_TOK_CHART_SUBTITLE:
+ if( xDoc.is())
+ {
+ if( xProp.is())
+ {
+ xProp->setPropertyValue( rtl::OUString::createFromAscii( "HasSubTitle" ), aTrueBool );
+ }
+ uno::Reference< drawing::XShape > xTitleShape( xDoc->getSubTitle(), uno::UNO_QUERY );
+ pContext = new SchXMLTitleContext( mrImportHelper, GetImport(),
+ rLocalName, maSubTitle, xTitleShape );
+ }
+ break;
+
+ case XML_TOK_CHART_LEGEND:
+ pContext = new SchXMLLegendContext( mrImportHelper, GetImport(), rLocalName );
+ break;
+
+ case XML_TOK_CHART_TABLE:
+ {
+ SchXMLTableContext * pTableContext =
+ new SchXMLTableContext( mrImportHelper, GetImport(), rLocalName, maTable );
+ m_bHasTableElement = true;
+ // #i85913# take into account column- and row- mapping for
+ // charts with own data only for those which were not copied
+ // from a place where they got data from the container. Note,
+ // that this requires the plot-area been read before the table
+ // (which is required in the ODF spec)
+ // Note: For stock charts and donut charts with special handling
+ // the mapping must not be applied!
+ if( !msChartAddress.getLength() && !mbIsStockChart &&
+ !lcl_SpecialHandlingForDonutChartNeeded(
+ maChartTypeServiceName, GetImport()))
+ {
+ if( msColTrans.getLength() > 0 )
+ {
+ OSL_ASSERT( msRowTrans.getLength() == 0 );
+ pTableContext->setColumnPermutation( lcl_getNumberSequenceFromString( msColTrans, true ));
+ msColTrans = OUString();
+ }
+ else if( msRowTrans.getLength() > 0 )
+ {
+ pTableContext->setRowPermutation( lcl_getNumberSequenceFromString( msRowTrans, true ));
+ msRowTrans = OUString();
+ }
+ }
+ pContext = pTableContext;
+ }
+ break;
+
+ default:
+ // try importing as an additional shape
+ if( ! mxDrawPage.is())
+ {
+ uno::Reference< drawing::XDrawPageSupplier > xSupp( xDoc, uno::UNO_QUERY );
+ if( xSupp.is())
+ mxDrawPage = uno::Reference< drawing::XShapes >( xSupp->getDrawPage(), uno::UNO_QUERY );
+
+ DBG_ASSERT( mxDrawPage.is(), "Invalid Chart Page" );
+ }
+ if( mxDrawPage.is())
+ pContext = GetImport().GetShapeImport()->CreateGroupChildContext(
+ GetImport(), nPrefix, rLocalName, xAttrList, mxDrawPage );
+ break;
+ }
+
+ if( ! pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+
+ return pContext;
+}
+
+
+/*
+ With a locked controller the following is done here:
+ 1. Hide title, subtitle, and legend.
+ 2. Set the size of the draw page.
+ 3. Set a (logically) empty data set.
+ 4. Set the chart type.
+*/
+void SchXMLChartContext::InitChart(
+ const OUString & rChartTypeServiceName, // currently the old service name
+ sal_Bool /* bSetSwitchData */ )
+{
+ uno::Reference< chart::XChartDocument > xDoc = mrImportHelper.GetChartDocument();
+ DBG_ASSERT( xDoc.is(), "No valid document!" );
+ uno::Reference< frame::XModel > xModel (xDoc, uno::UNO_QUERY );
+
+ // Remove Title and Diagram ("De-InitNew")
+ uno::Reference< chart2::XChartDocument > xNewDoc( mrImportHelper.GetChartDocument(), uno::UNO_QUERY );
+ if( xNewDoc.is())
+ {
+ xNewDoc->setFirstDiagram( 0 );
+ uno::Reference< chart2::XTitled > xTitled( xNewDoc, uno::UNO_QUERY );
+ if( xTitled.is())
+ xTitled->setTitleObject( 0 );
+ }
+
+ // Set the chart type via setting the diagram.
+ if( rChartTypeServiceName.getLength() &&
+ xDoc.is())
+ {
+ uno::Reference< lang::XMultiServiceFactory > xFact( xDoc, uno::UNO_QUERY );
+ if( xFact.is())
+ {
+ uno::Reference< chart::XDiagram > xDia( xFact->createInstance( rChartTypeServiceName ), uno::UNO_QUERY );
+ if( xDia.is())
+ xDoc->setDiagram( xDia );
+ }
+ }
+}
+
+// ----------------------------------------
+
+SchXMLTitleContext::SchXMLTitleContext( SchXMLImportHelper& rImpHelper, SvXMLImport& rImport,
+ const rtl::OUString& rLocalName,
+ rtl::OUString& rTitle,
+ uno::Reference< drawing::XShape >& xTitleShape ) :
+ SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ),
+ mrImportHelper( rImpHelper ),
+ mrTitle( rTitle ),
+ mxTitleShape( xTitleShape )
+{
+}
+
+SchXMLTitleContext::~SchXMLTitleContext()
+{}
+
+void SchXMLTitleContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
+{
+ sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
+
+ com::sun::star::awt::Point maPosition;
+ bool bHasXPosition=false;
+ bool bHasYPosition=false;
+
+ for( sal_Int16 i = 0; i < nAttrCount; i++ )
+ {
+ rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
+ rtl::OUString aLocalName;
+ rtl::OUString aValue = xAttrList->getValueByIndex( i );
+ USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
+
+ if( nPrefix == XML_NAMESPACE_SVG )
+ {
+ if( IsXMLToken( aLocalName, XML_X ) )
+ {
+ GetImport().GetMM100UnitConverter().convertMeasure( maPosition.X, aValue );
+ bHasXPosition = true;
+ }
+ else if( IsXMLToken( aLocalName, XML_Y ) )
+ {
+ GetImport().GetMM100UnitConverter().convertMeasure( maPosition.Y, aValue );
+ bHasYPosition = true;
+ }
+ }
+ else if( nPrefix == XML_NAMESPACE_CHART )
+ {
+ if( IsXMLToken( aLocalName, XML_STYLE_NAME ) )
+ msAutoStyleName = aValue;
+ }
+ }
+
+
+ if( mxTitleShape.is())
+ {
+ if( bHasXPosition && bHasYPosition )
+ mxTitleShape->setPosition( maPosition );
+
+ uno::Reference< beans::XPropertySet > xProp( mxTitleShape, uno::UNO_QUERY );
+ if( xProp.is())
+ {
+ const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext();
+ if( pStylesCtxt )
+ {
+ const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext(
+ mrImportHelper.GetChartFamilyID(), msAutoStyleName );
+
+ if( pStyle && pStyle->ISA( XMLPropStyleContext ))
+ (( XMLPropStyleContext* )pStyle )->FillPropertySet( xProp );
+ }
+ }
+ }
+}
+
+SvXMLImportContext* SchXMLTitleContext::CreateChildContext(
+ USHORT nPrefix,
+ const rtl::OUString& rLocalName,
+ const uno::Reference< xml::sax::XAttributeList >& )
+{
+ SvXMLImportContext* pContext = 0;
+
+ if( nPrefix == XML_NAMESPACE_TEXT &&
+ IsXMLToken( rLocalName, XML_P ) )
+ {
+ pContext = new SchXMLParagraphContext( GetImport(), rLocalName, mrTitle );
+ }
+ else
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+
+ return pContext;
+}
+
+// ----------------------------------------
+
+SchXMLLegendContext::SchXMLLegendContext( SchXMLImportHelper& rImpHelper,
+ SvXMLImport& rImport, const rtl::OUString& rLocalName ) :
+ SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ),
+ mrImportHelper( rImpHelper )
+{
+}
+
+void SchXMLLegendContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
+{
+ uno::Reference< chart::XChartDocument > xDoc = mrImportHelper.GetChartDocument();
+ if( ! xDoc.is())
+ return;
+
+ // turn on legend
+ uno::Reference< beans::XPropertySet > xDocProp( xDoc, uno::UNO_QUERY );
+ if( xDocProp.is())
+ {
+ uno::Any aTrueBool;
+ aTrueBool <<= (sal_Bool)(sal_True);
+ try
+ {
+ xDocProp->setPropertyValue( rtl::OUString::createFromAscii( "HasLegend" ), aTrueBool );
+ }
+ catch( beans::UnknownPropertyException )
+ {
+ DBG_ERROR( "Property HasLegend not found" );
+ }
+ }
+
+ // parse attributes
+ sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
+ const SvXMLTokenMap& rAttrTokenMap = mrImportHelper.GetLegendAttrTokenMap();
+
+ awt::Point aLegendPos;
+ bool bHasXPosition=false;
+ bool bHasYPosition=false;
+
+ rtl::OUString sAutoStyleName;
+
+ for( sal_Int16 i = 0; i < nAttrCount; i++ )
+ {
+ rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
+ rtl::OUString aLocalName;
+ rtl::OUString aValue = xAttrList->getValueByIndex( i );
+ USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
+
+ switch( rAttrTokenMap.Get( nPrefix, aLocalName ))
+ {
+ case XML_TOK_LEGEND_POSITION:
+ {
+ // set anchor position
+ uno::Reference< beans::XPropertySet > xProp( xDoc->getLegend(), uno::UNO_QUERY );
+ if( xProp.is())
+ {
+ try
+ {
+ USHORT nEnumVal;
+ if( GetImport().GetMM100UnitConverter().convertEnum( nEnumVal, aValue, aXMLLegendAlignmentMap ))
+ {
+ uno::Any aAny;
+ aAny <<= (chart::ChartLegendPosition)(nEnumVal);
+ xProp->setPropertyValue( rtl::OUString::createFromAscii( "Alignment" ), aAny );
+ }
+ }
+ catch( beans::UnknownPropertyException )
+ {
+ DBG_ERROR( "Property Alignment (legend) not found" );
+ }
+ }
+ }
+ break;
+
+ case XML_TOK_LEGEND_X:
+ GetImport().GetMM100UnitConverter().convertMeasure( aLegendPos.X, aValue );
+ bHasXPosition = true;
+ break;
+ case XML_TOK_LEGEND_Y:
+ GetImport().GetMM100UnitConverter().convertMeasure( aLegendPos.Y, aValue );
+ bHasYPosition = true;
+ break;
+ case XML_TOK_LEGEND_STYLE_NAME:
+ sAutoStyleName = aValue;
+ }
+ }
+
+ uno::Reference< drawing::XShape > xLegendShape( xDoc->getLegend(), uno::UNO_QUERY );
+ if( xLegendShape.is() && bHasXPosition && bHasYPosition )
+ xLegendShape->setPosition( aLegendPos );
+
+ // set auto-styles for Legend
+ uno::Reference< beans::XPropertySet > xProp( xLegendShape, uno::UNO_QUERY );
+ if( xProp.is())
+ {
+ // the fill style has the default "none" in XML, but "solid" in the model.
+ xProp->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillStyle" )),
+ uno::makeAny( drawing::FillStyle_NONE ));
+ const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext();
+ if( pStylesCtxt )
+ {
+ const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext(
+ mrImportHelper.GetChartFamilyID(), sAutoStyleName );
+
+ if( pStyle && pStyle->ISA( XMLPropStyleContext ))
+ (( XMLPropStyleContext* )pStyle )->FillPropertySet( xProp );
+ }
+ }
+}
+
+SchXMLLegendContext::~SchXMLLegendContext()
+{
+}
diff --git a/xmloff/source/chart/SchXMLChartContext.hxx b/xmloff/source/chart/SchXMLChartContext.hxx
new file mode 100644
index 000000000000..0f1fb0b4ab83
--- /dev/null
+++ b/xmloff/source/chart/SchXMLChartContext.hxx
@@ -0,0 +1,189 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _SCH_XMLCHARTCONTEXT_HXX_
+#define _SCH_XMLCHARTCONTEXT_HXX_
+
+#include <xmloff/xmlictxt.hxx>
+#include <com/sun/star/uno/Sequence.h>
+#include <com/sun/star/drawing/XShape.hpp>
+#include <com/sun/star/chart/ChartDataRowSource.hpp>
+#include <com/sun/star/chart2/XChartDocument.hpp>
+#include <com/sun/star/awt/Size.hpp>
+
+#include "transporttypes.hxx"
+
+#include <list>
+#include <map>
+
+class SchXMLImport;
+class SchXMLImportHelper;
+
+namespace com { namespace sun { namespace star {
+ namespace chart {
+ class XChartDocument;
+ class XDiagram;
+ struct ChartSeriesAddress;
+ }
+ namespace util {
+ class XStringMapping;
+ }
+ namespace xml { namespace sax {
+ class XAttributeList;
+ }}
+ namespace drawing {
+ class XShapes;
+ }
+}}}
+
+// ----------------------------------------
+
+struct SeriesDefaultsAndStyles
+{
+ //default values for series:
+ ::com::sun::star::uno::Any maSymbolTypeDefault;
+ ::com::sun::star::uno::Any maDataCaptionDefault;
+
+ ::com::sun::star::uno::Any maErrorIndicatorDefault;
+ ::com::sun::star::uno::Any maErrorCategoryDefault;
+ ::com::sun::star::uno::Any maConstantErrorLowDefault;
+ ::com::sun::star::uno::Any maConstantErrorHighDefault;
+ ::com::sun::star::uno::Any maPercentageErrorDefault;
+ ::com::sun::star::uno::Any maErrorMarginDefault;
+
+ ::com::sun::star::uno::Any maMeanValueDefault;
+ ::com::sun::star::uno::Any maRegressionCurvesDefault;
+
+ ::com::sun::star::uno::Any maStackedDefault;
+ ::com::sun::star::uno::Any maPercentDefault;
+ ::com::sun::star::uno::Any maDeepDefault;
+ ::com::sun::star::uno::Any maStackedBarsConnectedDefault;
+
+ //additional information
+ ::com::sun::star::uno::Any maLinesOnProperty;
+
+ //styles for series and datapoints
+ ::std::list< DataRowPointStyle > maSeriesStyleList;
+};
+
+class SchXMLChartContext : public SvXMLImportContext
+{
+public:
+ SchXMLChartContext( SchXMLImportHelper& rImpHelper,
+ SvXMLImport& rImport, const rtl::OUString& rLocalName );
+ virtual ~SchXMLChartContext();
+
+ virtual void StartElement( const com::sun::star::uno::Reference<
+ com::sun::star::xml::sax::XAttributeList >& xAttrList );
+ virtual void EndElement();
+ virtual SvXMLImportContext *CreateChildContext(
+ USHORT nPrefix,
+ const rtl::OUString& rLocalName,
+ const com::sun::star::uno::Reference<
+ com::sun::star::xml::sax::XAttributeList >& xAttrList );
+
+private:
+ SchXMLTable maTable;
+ SchXMLImportHelper& mrImportHelper;
+
+ ::rtl::OUString maMainTitle, maSubTitle;
+ com::sun::star::awt::Point maMainTitlePos, maSubTitlePos, maLegendPos;
+ ::rtl::OUString m_aXLinkHRefAttributeToIndicateDataProvider;
+ bool m_bHasRangeAtPlotArea;
+ bool m_bHasTableElement;
+ sal_Bool mbAllRangeAddressesAvailable;
+ sal_Bool mbColHasLabels;
+ sal_Bool mbRowHasLabels;
+ ::com::sun::star::chart::ChartDataRowSource meDataRowSource;
+ bool mbIsStockChart;
+
+ com::sun::star::uno::Sequence< com::sun::star::chart::ChartSeriesAddress > maSeriesAddresses;
+ ::rtl::OUString msCategoriesAddress;
+ ::rtl::OUString msChartAddress;
+
+ SeriesDefaultsAndStyles maSeriesDefaultsAndStyles;
+ tSchXMLLSequencesPerIndex maLSequencesPerIndex;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > mxDrawPage;
+ ::rtl::OUString msColTrans;
+ ::rtl::OUString msRowTrans;
+ ::rtl::OUString maChartTypeServiceName;
+
+ ::com::sun::star::awt::Size maChartSize;
+
+ /** @descr This method bundles some settings to the chart model and executes them with
+ a locked controller. This includes setting the chart type.
+ @param aServiceName The name of the service the diagram is initialized with.
+ @param bSetWitchData Indicates wether the data set takes it's data series from
+ rows or from columns.
+ */
+ void InitChart (const ::rtl::OUString & rChartTypeServiceName,
+ sal_Bool bSetSwitchData);
+
+ void MergeSeriesForStockChart();
+};
+
+// ----------------------------------------
+
+class SchXMLTitleContext : public SvXMLImportContext
+{
+private:
+ SchXMLImportHelper& mrImportHelper;
+ rtl::OUString& mrTitle;
+ com::sun::star::uno::Reference< com::sun::star::drawing::XShape > mxTitleShape;
+ rtl::OUString msAutoStyleName;
+
+public:
+ SchXMLTitleContext( SchXMLImportHelper& rImpHelper,
+ SvXMLImport& rImport, const rtl::OUString& rLocalName,
+ rtl::OUString& rTitle,
+ com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xTitleShape );
+ virtual ~SchXMLTitleContext();
+
+ virtual void StartElement( const com::sun::star::uno::Reference<
+ com::sun::star::xml::sax::XAttributeList >& xAttrList );
+ virtual SvXMLImportContext *CreateChildContext(
+ USHORT nPrefix,
+ const rtl::OUString& rLocalName,
+ const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList );
+};
+
+// ----------------------------------------
+
+class SchXMLLegendContext : public SvXMLImportContext
+{
+private:
+ SchXMLImportHelper& mrImportHelper;
+
+public:
+ SchXMLLegendContext( SchXMLImportHelper& rImpHelper,
+ SvXMLImport& rImport, const rtl::OUString& rLocalName );
+ virtual ~SchXMLLegendContext();
+
+ virtual void StartElement( const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList );
+};
+
+#endif // _SCH_XMLCHARTCONTEXT_HXX_
diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx
new file mode 100644
index 000000000000..e6f6fc6d9340
--- /dev/null
+++ b/xmloff/source/chart/SchXMLExport.cxx
@@ -0,0 +1,4037 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmloff.hxx"
+
+#include <xmloff/xmlprmap.hxx>
+
+#include "SchXMLExport.hxx"
+#include "XMLChartPropertySetMapper.hxx"
+#include "SchXMLSeriesHelper.hxx"
+#include "ColorPropertySet.hxx"
+#include "SchXMLTools.hxx"
+#include <tools/debug.hxx>
+#include <rtl/logfile.hxx>
+#include <comphelper/processfactory.hxx>
+#include <tools/globname.hxx>
+#include <sot/clsids.hxx>
+
+#include <xmloff/nmspmap.hxx>
+#include "xmlnmspe.hxx"
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/families.hxx>
+#include <xmloff/xmlaustp.hxx>
+#include <xmloff/xmluconv.hxx>
+#include <xmloff/xmlmetae.hxx>
+#include "xexptran.hxx"
+#include <rtl/math.hxx>
+// header for any2enum
+#include <comphelper/extract.hxx>
+
+#include <list>
+#include <typeinfo>
+#include <algorithm>
+
+#include <com/sun/star/task/XStatusIndicatorSupplier.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XServiceName.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/util/XRefreshable.hpp>
+
+#include <com/sun/star/chart/XChartDocument.hpp>
+#include <com/sun/star/chart/ChartLegendPosition.hpp>
+#include <com/sun/star/chart/XTwoAxisXSupplier.hpp>
+#include <com/sun/star/chart/XTwoAxisYSupplier.hpp>
+#include <com/sun/star/chart/XAxisZSupplier.hpp>
+#include <com/sun/star/chart/XComplexDescriptionAccess.hpp>
+#include <com/sun/star/chart/ChartDataRowSource.hpp>
+#include <com/sun/star/chart/ChartAxisAssign.hpp>
+#include <com/sun/star/chart/ChartSeriesAddress.hpp>
+#include <com/sun/star/chart/X3DDisplay.hpp>
+#include <com/sun/star/chart/XStatisticDisplay.hpp>
+#include <com/sun/star/chart/XSecondAxisTitleSupplier.hpp>
+#include <com/sun/star/chart/XDiagramPositioning.hpp>
+
+#include <com/sun/star/chart2/XChartDocument.hpp>
+#include <com/sun/star/chart2/XDiagram.hpp>
+#include <com/sun/star/chart2/RelativePosition.hpp>
+#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
+#include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
+#include <com/sun/star/chart2/XChartTypeContainer.hpp>
+#include <com/sun/star/chart2/XDataSeriesContainer.hpp>
+#include <com/sun/star/chart2/data/XDataSource.hpp>
+#include <com/sun/star/chart2/data/XDataSink.hpp>
+#include <com/sun/star/chart2/data/XDataReceiver.hpp>
+#include <com/sun/star/chart2/data/XDataProvider.hpp>
+#include <com/sun/star/chart2/data/XDatabaseDataProvider.hpp>
+#include <com/sun/star/chart2/data/XRangeXMLConversion.hpp>
+#include <com/sun/star/chart2/data/XTextualDataSequence.hpp>
+#include <com/sun/star/chart2/data/XNumericalDataSequence.hpp>
+
+#include <com/sun/star/util/XStringMapping.hpp>
+#include <com/sun/star/drawing/HomogenMatrix.hpp>
+#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#include <com/sun/star/drawing/XShapes.hpp>
+#include <com/sun/star/embed/Aspects.hpp>
+#include <com/sun/star/embed/XVisualObject.hpp>
+#include <com/sun/star/container/XChild.hpp>
+
+
+#include "MultiPropertySetHandler.hxx"
+#include "PropertyMap.hxx"
+
+using namespace com::sun::star;
+using namespace ::xmloff::token;
+
+using ::rtl::OUString;
+using ::rtl::OUStringBuffer;
+using ::rtl::OUStringToOString;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Any;
+using ::std::vector;
+
+// ========================================
+// class SchXMLExportHelper_Impl
+// ========================================
+
+class SchXMLExportHelper_Impl
+{
+public:
+ // first: data sequence for label, second: data sequence for values.
+ typedef ::std::pair< ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence >,
+ ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence > > tLabelValuesDataPair;
+ typedef ::std::vector< tLabelValuesDataPair > tDataSequenceCont;
+
+public:
+ SchXMLExportHelper_Impl( SvXMLExport& rExport,
+ SvXMLAutoStylePoolP& rASPool );
+
+ virtual ~SchXMLExportHelper_Impl();
+
+ // auto-styles
+ /// parse chart and collect all auto-styles used in current pool
+ void collectAutoStyles( com::sun::star::uno::Reference<
+ com::sun::star::chart::XChartDocument > rChartDoc );
+
+ /// write the styles collected into the current pool as <style:style> elements
+ void exportAutoStyles();
+
+ /** export the <chart:chart> element corresponding to rChartDoc
+ if bIncludeTable is true, the chart data is exported as <table:table>
+ element (inside the chart element).
+
+ Otherwise the external references stored in the chart document are used
+ for writing the corresponding attributes at series
+
+ All attributes contained in xAttrList are written at the chart element,
+ which ist the outer element of a chart. So these attributes can easily
+ be parsed again by the container
+ */
+ void exportChart( com::sun::star::uno::Reference<
+ com::sun::star::chart::XChartDocument > rChartDoc,
+ sal_Bool bIncludeTable );
+
+ UniReference< XMLPropertySetMapper > GetPropertySetMapper() const;
+
+ void SetChartRangeAddress( const ::rtl::OUString& rAddress )
+ { msChartAddress = rAddress; }
+ void SetTableNumberList( const ::rtl::OUString& rList )
+ { msTableNumberList = rList; }
+
+ void InitRangeSegmentationProperties(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XChartDocument > & xChartDoc );
+
+ ::com::sun::star::awt::Size getPageSize(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XChartDocument > & xChartDoc ) const;
+
+ /** first parseDocument: collect autostyles and store names in this queue
+ second parseDocument: export content and use names from this queue
+ */
+ ::std::queue< ::rtl::OUString > maAutoStyleNameQueue;
+ void CollectAutoStyle(
+ const std::vector< XMLPropertyState >& aStates );
+ void AddAutoStyleAttribute(
+ const std::vector< XMLPropertyState >& aStates );
+
+ SvXMLAutoStylePoolP& GetAutoStylePoolP()
+ { return mrAutoStylePool; }
+
+ /// if bExportContent is false the auto-styles are collected
+ void parseDocument( com::sun::star::uno::Reference<
+ com::sun::star::chart::XChartDocument >& rChartDoc,
+ sal_Bool bExportContent,
+ sal_Bool bIncludeTable = sal_False );
+ void exportTable();
+ void exportPlotArea(
+ com::sun::star::uno::Reference< com::sun::star::chart::XDiagram > xDiagram,
+ com::sun::star::uno::Reference< com::sun::star::chart2::XDiagram > xNewDiagram,
+ const ::com::sun::star::awt::Size & rPageSize,
+ sal_Bool bExportContent,
+ sal_Bool bIncludeTable );
+ void exportCoordinateRegion( const com::sun::star::uno::Reference< com::sun::star::chart::XDiagram >& xDiagram );
+ void exportAxes( const com::sun::star::uno::Reference< com::sun::star::chart::XDiagram > & xDiagram,
+ const com::sun::star::uno::Reference< com::sun::star::chart2::XDiagram > & xNewDiagram,
+ sal_Bool bExportContent );
+
+ void exportSeries(
+ const com::sun::star::uno::Reference< com::sun::star::chart2::XDiagram > & xNewDiagram,
+ const ::com::sun::star::awt::Size & rPageSize,
+ sal_Bool bExportContent,
+ sal_Bool bHasTwoYAxes );
+ void exportCandleStickSeries(
+ const ::com::sun::star::uno::Sequence<
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XDataSeries > > & aSeriesSeq,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XDiagram > & xDiagram,
+ sal_Bool bJapaneseCandleSticks,
+ sal_Bool bExportContent );
+ void exportDataPoints(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > & xSeriesProperties,
+ sal_Int32 nSeriesLength,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XDiagram > & xDiagram,
+ sal_Bool bExportContent );
+ void exportRegressionCurve(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XDataSeries > & xSeries,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > & xSeriesProp,
+ const ::com::sun::star::awt::Size & rPageSize,
+ sal_Bool bExportContent );
+
+ /// add svg position as attribute for current element
+ void addPosition( const ::com::sun::star::awt::Point & rPosition );
+ void addPosition( com::sun::star::uno::Reference< com::sun::star::drawing::XShape > xShape );
+ /// add svg size as attribute for current element
+ void addSize( const ::com::sun::star::awt::Size & rSize );
+ void addSize( com::sun::star::uno::Reference< com::sun::star::drawing::XShape > xShape );
+ /// fills the member msString with the appropriate String (i.e. "A3")
+ void getCellAddress( sal_Int32 nCol, sal_Int32 nRow );
+ /// exports a string as a paragraph element
+ void exportText( const ::rtl::OUString& rText, bool bConvertTabsLFs = false );
+ void exportErrorBarRanges();
+
+ SchXMLExportHelper_Impl(SchXMLExportHelper_Impl &); // not defined
+ void operator =(SchXMLExportHelper_Impl &); // not defined
+
+public:
+ SvXMLExport& mrExport;
+ SvXMLAutoStylePoolP& mrAutoStylePool;
+ UniReference< XMLPropertyHandlerFactory > mxPropertyHandlerFactory;
+ UniReference< XMLPropertySetMapper > mxPropertySetMapper;
+ UniReference< XMLChartExportPropertyMapper > mxExpPropMapper;
+
+ rtl::OUString msTableName;
+ rtl::OUStringBuffer msStringBuffer;
+ rtl::OUString msString;
+
+ // members filled by InitRangeSegmentationProperties (retrieved from DataProvider)
+ sal_Bool mbHasSeriesLabels;
+ sal_Bool mbHasCategoryLabels; //if the categories are only automatically generated this will be false
+ sal_Bool mbRowSourceColumns;
+ rtl::OUString msChartAddress;
+ rtl::OUString msTableNumberList;
+ ::com::sun::star::uno::Sequence< sal_Int32 > maSequenceMapping;
+
+ rtl::OUString msCLSID;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > mxAdditionalShapes;
+
+ tDataSequenceCont m_aDataSequencesToExport;
+ rtl::OUString maCategoriesRange;
+};
+
+namespace
+{
+Reference< uno::XComponentContext > lcl_getComponentContext()
+{
+ Reference< uno::XComponentContext > xContext;
+ try
+ {
+ Reference< beans::XPropertySet > xFactProp( comphelper::getProcessServiceFactory(), uno::UNO_QUERY );
+ if( xFactProp.is())
+ xFactProp->getPropertyValue(OUString::createFromAscii("DefaultContext")) >>= xContext;
+ }
+ catch( uno::Exception& )
+ {}
+
+ return xContext;
+}
+
+class lcl_MatchesRole : public ::std::unary_function< Reference< chart2::data::XLabeledDataSequence >, bool >
+{
+public:
+ explicit lcl_MatchesRole( const OUString & aRole ) :
+ m_aRole( aRole )
+ {}
+
+ bool operator () ( const Reference< chart2::data::XLabeledDataSequence > & xSeq ) const
+ {
+ if( !xSeq.is() )
+ return false;
+ Reference< beans::XPropertySet > xProp( xSeq->getValues(), uno::UNO_QUERY );
+ OUString aRole;
+
+ return ( xProp.is() &&
+ (xProp->getPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "Role" )) ) >>= aRole ) &&
+ m_aRole.equals( aRole ));
+ }
+
+private:
+ OUString m_aRole;
+};
+
+template< typename T >
+ void lcl_SequenceToVectorAppend( const Sequence< T > & rSource, ::std::vector< T > & rDestination )
+{
+ rDestination.reserve( rDestination.size() + rSource.getLength());
+ ::std::copy( rSource.getConstArray(), rSource.getConstArray() + rSource.getLength(),
+ ::std::back_inserter( rDestination ));
+}
+
+template< typename T >
+ void lcl_SequenceToVector( const Sequence< T > & rSource, ::std::vector< T > & rDestination )
+{
+ rDestination.clear();
+ lcl_SequenceToVectorAppend( rSource, rDestination );
+}
+
+Reference< chart2::data::XLabeledDataSequence > lcl_getCategories( const Reference< chart2::XDiagram > & xDiagram )
+{
+ Reference< chart2::data::XLabeledDataSequence > xResult;
+ try
+ {
+ Reference< chart2::XCoordinateSystemContainer > xCooSysCnt(
+ xDiagram, uno::UNO_QUERY_THROW );
+ Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq(
+ xCooSysCnt->getCoordinateSystems());
+ for( sal_Int32 i=0; i<aCooSysSeq.getLength(); ++i )
+ {
+ Reference< chart2::XCoordinateSystem > xCooSys( aCooSysSeq[i] );
+ OSL_ASSERT( xCooSys.is());
+ for( sal_Int32 nN = xCooSys->getDimension(); nN--; )
+ {
+ const sal_Int32 nMaxAxisIndex = xCooSys->getMaximumAxisIndexByDimension(nN);
+ for(sal_Int32 nI=0; nI<=nMaxAxisIndex; ++nI)
+ {
+ Reference< chart2::XAxis > xAxis = xCooSys->getAxisByDimension( nN, nI );
+ OSL_ASSERT( xAxis.is());
+ if( xAxis.is())
+ {
+ chart2::ScaleData aScaleData = xAxis->getScaleData();
+ if( aScaleData.Categories.is())
+ {
+ xResult.set( aScaleData.Categories );
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ catch( uno::Exception & ex )
+ {
+ (void)ex; // avoid warning for pro build
+ OSL_ENSURE( false, OUStringToOString(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "Exception caught. Type: " )) +
+ OUString::createFromAscii( typeid( ex ).name()) +
+ OUString( RTL_CONSTASCII_USTRINGPARAM( ", Message: " )) +
+ ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
+ }
+
+ return xResult;
+}
+
+Reference< chart2::data::XDataSource > lcl_createDataSource(
+ const Sequence< Reference< chart2::data::XLabeledDataSequence > > & aData )
+{
+ Reference< chart2::data::XDataSink > xSink;
+ Reference< uno::XComponentContext > xContext( lcl_getComponentContext());
+ if( xContext.is() )
+ xSink.set(
+ xContext->getServiceManager()->createInstanceWithContext(
+ OUString::createFromAscii("com.sun.star.chart2.data.DataSource"),
+ xContext ), uno::UNO_QUERY_THROW );
+ if( xSink.is())
+ xSink->setData( aData );
+
+ return Reference< chart2::data::XDataSource >( xSink, uno::UNO_QUERY );
+}
+
+Sequence< Reference< chart2::data::XLabeledDataSequence > > lcl_getAllSeriesSequences( const Reference< chart2::XChartDocument >& xChartDoc )
+{
+ ::std::vector< Reference< chart2::data::XLabeledDataSequence > > aContainer;
+ if( xChartDoc.is() )
+ {
+ Reference< chart2::XDiagram > xDiagram( xChartDoc->getFirstDiagram());
+ ::std::vector< Reference< chart2::XDataSeries > > aSeriesVector( SchXMLSeriesHelper::getDataSeriesFromDiagram( xDiagram ));
+ for( ::std::vector< Reference< chart2::XDataSeries > >::const_iterator aSeriesIt( aSeriesVector.begin() )
+ ; aSeriesIt != aSeriesVector.end(); ++aSeriesIt )
+ {
+ Reference< chart2::data::XDataSource > xDataSource( *aSeriesIt, uno::UNO_QUERY );
+ if( !xDataSource.is() )
+ continue;
+ uno::Sequence< Reference< chart2::data::XLabeledDataSequence > > aDataSequences( xDataSource->getDataSequences() );
+ lcl_SequenceToVectorAppend( aDataSequences, aContainer );
+ }
+ }
+
+ Sequence< Reference< chart2::data::XLabeledDataSequence > > aRet( aContainer.size());
+ ::std::copy( aContainer.begin(), aContainer.end(), aRet.getArray());
+
+ return aRet;
+}
+
+Reference< chart2::data::XLabeledDataSequence >
+ lcl_getDataSequenceByRole(
+ const Sequence< Reference< chart2::data::XLabeledDataSequence > > & aLabeledSeq,
+ const OUString & rRole )
+{
+ Reference< chart2::data::XLabeledDataSequence > aNoResult;
+
+ const Reference< chart2::data::XLabeledDataSequence > * pBegin = aLabeledSeq.getConstArray();
+ const Reference< chart2::data::XLabeledDataSequence > * pEnd = pBegin + aLabeledSeq.getLength();
+ const Reference< chart2::data::XLabeledDataSequence > * pMatch =
+ ::std::find_if( pBegin, pEnd, lcl_MatchesRole( rRole ));
+
+ if( pMatch != pEnd )
+ return *pMatch;
+
+ return aNoResult;
+}
+
+Reference< chart2::data::XDataSource > lcl_pressUsedDataIntoRectangularFormat( const Reference< chart2::XChartDocument >& xChartDoc, sal_Bool& rOutSourceHasCategoryLabels )
+{
+ ::std::vector< Reference< chart2::data::XLabeledDataSequence > > aLabeledSeqVector;
+
+ //categories are always the first sequence
+ Reference< chart2::XDiagram > xDiagram( xChartDoc->getFirstDiagram());
+ Reference< chart2::data::XLabeledDataSequence > xCategories( lcl_getCategories( xDiagram ) );
+ if( xCategories.is() )
+ aLabeledSeqVector.push_back( xCategories );
+ rOutSourceHasCategoryLabels = sal_Bool(xCategories.is());
+
+ Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeriesSeqVector(
+ lcl_getAllSeriesSequences( xChartDoc ) );
+
+ //the first x-values is always the next sequence //todo ... other x-values get lost for old format
+ Reference< chart2::data::XLabeledDataSequence > xXValues(
+ lcl_getDataSequenceByRole( aSeriesSeqVector, OUString::createFromAscii("values-x" ) ) );
+ if( xXValues.is() )
+ aLabeledSeqVector.push_back( xXValues );
+
+ //add all other sequences now without x-values
+ lcl_MatchesRole aHasXValues( OUString::createFromAscii("values-x" ) );
+ for( sal_Int32 nN=0; nN<aSeriesSeqVector.getLength(); nN++ )
+ {
+ if( !aHasXValues( aSeriesSeqVector[nN] ) )
+ aLabeledSeqVector.push_back( aSeriesSeqVector[nN] );
+ }
+
+ Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeq( aLabeledSeqVector.size() );
+ ::std::copy( aLabeledSeqVector.begin(), aLabeledSeqVector.end(), aSeq.getArray() );
+
+ return lcl_createDataSource( aSeq );
+}
+
+bool lcl_isSeriesAttachedToFirstAxis(
+ const Reference< chart2::XDataSeries > & xDataSeries )
+{
+ bool bResult=true;
+
+ try
+ {
+ sal_Int32 nAxisIndex = 0;
+ Reference< beans::XPropertySet > xProp( xDataSeries, uno::UNO_QUERY_THROW );
+ if( xProp.is() )
+ xProp->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("AttachedAxisIndex") ) ) >>= nAxisIndex;
+ bResult = (0==nAxisIndex);
+ }
+ catch( uno::Exception & ex )
+ {
+ (void)ex; // avoid warning for pro build
+ OSL_ENSURE( false, OUStringToOString(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "Exception caught. Type: " )) +
+ OUString::createFromAscii( typeid( ex ).name()) +
+ OUString( RTL_CONSTASCII_USTRINGPARAM( ", Message: " )) +
+ ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
+ }
+
+ return bResult;
+}
+
+OUString lcl_ConvertRange( const ::rtl::OUString & rRange, const Reference< chart2::XChartDocument > & xDoc )
+{
+ OUString aResult = rRange;
+ if( !xDoc.is() )
+ return aResult;
+ Reference< chart2::data::XRangeXMLConversion > xConversion(
+ xDoc->getDataProvider(), uno::UNO_QUERY );
+ if( xConversion.is())
+ aResult = xConversion->convertRangeToXML( rRange );
+ return aResult;
+}
+
+typedef ::std::pair< OUString, OUString > tLabelAndValueRange;
+
+tLabelAndValueRange lcl_getLabelAndValueRangeByRole(
+ const Sequence< Reference< chart2::data::XLabeledDataSequence > > & aSeqCnt,
+ const OUString & rRole,
+ const Reference< chart2::XChartDocument > & xDoc,
+ SchXMLExportHelper_Impl::tDataSequenceCont & rOutSequencesToExport )
+{
+ tLabelAndValueRange aResult;
+
+ Reference< chart2::data::XLabeledDataSequence > xLabeledSeq(
+ lcl_getDataSequenceByRole( aSeqCnt, rRole ));
+ if( xLabeledSeq.is())
+ {
+ Reference< chart2::data::XDataSequence > xLabelSeq( xLabeledSeq->getLabel());
+ if( xLabelSeq.is())
+ aResult.first = lcl_ConvertRange( xLabelSeq->getSourceRangeRepresentation(), xDoc );
+
+ Reference< chart2::data::XDataSequence > xValueSeq( xLabeledSeq->getValues());
+ if( xValueSeq.is())
+ aResult.second = lcl_ConvertRange( xValueSeq->getSourceRangeRepresentation(), xDoc );
+
+ if( xLabelSeq.is() || xValueSeq.is())
+ rOutSequencesToExport.push_back( SchXMLExportHelper_Impl::tLabelValuesDataPair( xLabelSeq, xValueSeq ));
+ }
+
+ return aResult;
+}
+
+sal_Int32 lcl_getSequenceLengthByRole(
+ const Sequence< Reference< chart2::data::XLabeledDataSequence > > & aSeqCnt,
+ const OUString & rRole )
+{
+ Reference< chart2::data::XLabeledDataSequence > xLabeledSeq(
+ lcl_getDataSequenceByRole( aSeqCnt, rRole ));
+ if( xLabeledSeq.is())
+ {
+ Reference< chart2::data::XDataSequence > xSeq( xLabeledSeq->getValues());
+ return xSeq->getData().getLength();
+ }
+ return 0;
+}
+
+bool lcl_hasChartType( const Reference< chart2::XDiagram > & xDiagram, const OUString & rChartType )
+{
+ try
+ {
+ Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY_THROW );
+ Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems());
+ for( sal_Int32 nCooSysIdx=0; nCooSysIdx<aCooSysSeq.getLength(); ++nCooSysIdx )
+ {
+ Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[nCooSysIdx], uno::UNO_QUERY_THROW );
+ Sequence< Reference< chart2::XChartType > > aChartTypes( xCTCnt->getChartTypes());
+ for( sal_Int32 nCTIdx=0; nCTIdx<aChartTypes.getLength(); ++nCTIdx )
+ {
+ if( aChartTypes[nCTIdx]->getChartType().equals( rChartType ))
+ return true;
+ }
+ }
+ }
+ catch( uno::Exception & )
+ {
+ DBG_ERROR( "Exception while searching for chart type in diagram" );
+ }
+ return false;
+}
+
+OUString lcl_flattenStringSequence( const Sequence< OUString > & rSequence )
+{
+ OUStringBuffer aResult;
+ bool bPrecedeWithSpace = false;
+ for( sal_Int32 nIndex=0; nIndex<rSequence.getLength(); ++nIndex )
+ {
+ if( rSequence[nIndex].getLength())
+ {
+ if( bPrecedeWithSpace )
+ aResult.append( static_cast< sal_Unicode >( ' ' ));
+ aResult.append( rSequence[nIndex] );
+ bPrecedeWithSpace = true;
+ }
+ }
+ return aResult.makeStringAndClear();
+}
+
+OUString lcl_getLabelString( const Reference< chart2::data::XDataSequence > & xLabelSeq )
+{
+ Sequence< OUString > aLabels;
+
+ uno::Reference< chart2::data::XTextualDataSequence > xTextualDataSequence( xLabelSeq, uno::UNO_QUERY );
+ if( xTextualDataSequence.is())
+ {
+ aLabels = xTextualDataSequence->getTextualData();
+ }
+ else if( xLabelSeq.is())
+ {
+ Sequence< uno::Any > aAnies( xLabelSeq->getData());
+ aLabels.realloc( aAnies.getLength());
+ for( sal_Int32 i=0; i<aAnies.getLength(); ++i )
+ aAnies[i] >>= aLabels[i];
+ }
+
+ return lcl_flattenStringSequence( aLabels );
+}
+
+sal_Int32 lcl_getMaxSequenceLength(
+ const SchXMLExportHelper_Impl::tDataSequenceCont & rContainer )
+{
+ sal_Int32 nResult = 0;
+ for( SchXMLExportHelper_Impl::tDataSequenceCont::const_iterator aIt( rContainer.begin());
+ aIt != rContainer.end(); ++aIt )
+ {
+ if( aIt->second.is())
+ {
+ sal_Int32 nSeqLength = aIt->second->getData().getLength();
+ if( nSeqLength > nResult )
+ nResult = nSeqLength;
+ }
+ }
+ return nResult;
+}
+
+double lcl_getValueFromSequence( const Reference< chart2::data::XDataSequence > & xSeq, sal_Int32 nIndex )
+{
+ double fResult = 0.0;
+ ::rtl::math::setNan( &fResult );
+ Reference< chart2::data::XNumericalDataSequence > xNumSeq( xSeq, uno::UNO_QUERY );
+ if( xNumSeq.is())
+ {
+ Sequence< double > aValues( xNumSeq->getNumericalData());
+ if( nIndex < aValues.getLength() )
+ fResult = aValues[nIndex];
+ }
+ else
+ {
+ Sequence< uno::Any > aAnies( xSeq->getData());
+ if( nIndex < aAnies.getLength() )
+ aAnies[nIndex] >>= fResult;
+ }
+ return fResult;
+}
+
+::std::vector< double > lcl_getAllValuesFromSequence( const Reference< chart2::data::XDataSequence > & xSeq )
+{
+ double fNan = 0.0;
+ ::rtl::math::setNan( &fNan );
+ ::std::vector< double > aResult;
+
+ Reference< chart2::data::XNumericalDataSequence > xNumSeq( xSeq, uno::UNO_QUERY );
+ if( xNumSeq.is())
+ {
+ Sequence< double > aValues( xNumSeq->getNumericalData());
+ ::std::copy( aValues.getConstArray(), aValues.getConstArray() + aValues.getLength(),
+ ::std::back_inserter( aResult ));
+ }
+ else if( xSeq.is())
+ {
+ Sequence< uno::Any > aAnies( xSeq->getData());
+ aResult.resize( aAnies.getLength(), fNan );
+ for( sal_Int32 i=0; i<aAnies.getLength(); ++i )
+ aAnies[i] >>= aResult[i];
+ }
+ return aResult;
+}
+
+bool lcl_SequenceHasUnhiddenData( const uno::Reference< chart2::data::XDataSequence >& xDataSequence )
+{
+ if( !xDataSequence.is() )
+ return false;
+ uno::Reference< beans::XPropertySet > xProp( xDataSequence, uno::UNO_QUERY );
+ if( xProp.is() )
+ {
+ uno::Sequence< sal_Int32 > aHiddenValues;
+ try
+ {
+ xProp->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "HiddenValues" ) ) ) >>= aHiddenValues;
+ if( !aHiddenValues.getLength() )
+ return true;
+ }
+ catch( uno::Exception& e )
+ {
+ (void)e; // avoid warning
+ return true;
+ }
+ }
+ if( xDataSequence->getData().getLength() )
+ return true;
+ return false;
+}
+
+typedef vector< OUString > tStringVector;
+typedef vector< vector< OUString > > t2DStringVector;
+typedef vector< vector< double > > t2DNumberContainer;
+
+struct lcl_TableData
+{
+ t2DNumberContainer aDataInRows;
+ tStringVector aDataRangeRepresentations;
+
+ tStringVector aColumnDescriptions;
+ tStringVector aColumnDescriptions_Ranges;
+
+ tStringVector aRowDescriptions;
+ tStringVector aRowDescriptions_Ranges;
+
+ Sequence< Sequence< OUString > > aComplexColumnDescriptions;//outer index is columns - inner index is level
+ Sequence< Sequence< OUString > > aComplexRowDescriptions;//outer index is rows - inner index is level
+
+ ::std::vector< sal_Int32 > aHiddenColumns;
+};
+
+// ::std::bind2nd( ::std::mem_fun_ref( &T::resize ), nSize ) does not work
+template< class T >
+ struct lcl_resize
+ {
+ lcl_resize( typename T::size_type nSize, typename T::value_type fDefaultValue ) : m_nSize( nSize ), m_fDefaultValue( fDefaultValue ) {}
+ void operator()( T & t )
+ { t.resize( m_nSize, m_fDefaultValue ); }
+ private:
+ typename T::size_type m_nSize;
+ typename T::value_type m_fDefaultValue;
+ };
+
+
+typedef ::std::map< sal_Int32, SchXMLExportHelper_Impl::tLabelValuesDataPair >
+ lcl_DataSequenceMap;
+
+struct lcl_SequenceToMapElement :
+ public ::std::unary_function< lcl_DataSequenceMap::mapped_type, lcl_DataSequenceMap::value_type >
+{
+ lcl_SequenceToMapElement()
+ {}
+ result_type operator() ( const argument_type & rContent )
+ {
+ sal_Int32 nIndex = -1;
+ if( rContent.second.is()) //has values
+ {
+ OUString aRangeRep( rContent.second->getSourceRangeRepresentation());
+ nIndex = aRangeRep.toInt32();
+ }
+ else if( rContent.first.is()) //has labels
+ nIndex = rContent.first->getSourceRangeRepresentation().copy( sizeof("label ")).toInt32();
+ return result_type( nIndex, rContent );
+ }
+};
+
+void lcl_ReorderInternalSequencesAccordingToTheirRangeName(
+ SchXMLExportHelper_Impl::tDataSequenceCont & rInOutSequences )
+{
+ lcl_DataSequenceMap aIndexSequenceMap;
+ ::std::transform( rInOutSequences.begin(), rInOutSequences.end(),
+ ::std::inserter( aIndexSequenceMap, aIndexSequenceMap.begin()),
+ lcl_SequenceToMapElement());
+
+ rInOutSequences.clear();
+ sal_Int32 nIndex = 0;
+ for( lcl_DataSequenceMap::const_iterator aIt = aIndexSequenceMap.begin();
+ aIt != aIndexSequenceMap.end(); ++aIt, ++nIndex )
+ {
+ if( aIt->first < 0 )
+ continue;
+ // fill empty columns
+ for( ; nIndex < aIt->first; ++nIndex )
+ rInOutSequences.push_back(
+ SchXMLExportHelper_Impl::tDataSequenceCont::value_type( 0, 0 ));
+ OSL_ASSERT( nIndex == aIt->first );
+ rInOutSequences.push_back( aIt->second );
+ }
+}
+
+
+lcl_TableData lcl_getDataForLocalTable(
+ const SchXMLExportHelper_Impl::tDataSequenceCont & aSequencesToExport,
+ const Reference< chart::XComplexDescriptionAccess >& xComplexDescriptionAccess,
+ const OUString& rCategoriesRange,
+ bool bSeriesFromColumns,
+ const Reference< chart2::data::XRangeXMLConversion > & xRangeConversion )
+{
+ lcl_TableData aResult;
+
+ try
+ {
+ Sequence< OUString > aSimpleCategories;
+ if( xComplexDescriptionAccess.is() )
+ {
+ if( bSeriesFromColumns )
+ aSimpleCategories = xComplexDescriptionAccess->getRowDescriptions();
+ else
+ aSimpleCategories = xComplexDescriptionAccess->getColumnDescriptions();
+
+ aResult.aComplexColumnDescriptions = xComplexDescriptionAccess->getComplexColumnDescriptions();
+ aResult.aComplexRowDescriptions = xComplexDescriptionAccess->getComplexRowDescriptions();
+ }
+
+ SchXMLExportHelper_Impl::tDataSequenceCont::size_type nNumSequences = aSequencesToExport.size();
+ SchXMLExportHelper_Impl::tDataSequenceCont::const_iterator aBegin( aSequencesToExport.begin());
+ SchXMLExportHelper_Impl::tDataSequenceCont::const_iterator aEnd( aSequencesToExport.end());
+ SchXMLExportHelper_Impl::tDataSequenceCont::const_iterator aIt( aBegin );
+
+ size_t nMaxSequenceLength( lcl_getMaxSequenceLength( aSequencesToExport ));
+ size_t nCategoriesLength( aSimpleCategories.getLength() );
+ if( nCategoriesLength > nMaxSequenceLength )
+ {
+ aSimpleCategories.realloc(nMaxSequenceLength);//#i110617#
+ nCategoriesLength = nMaxSequenceLength;
+ }
+ size_t nNumColumns( bSeriesFromColumns ? nNumSequences : nMaxSequenceLength );
+ size_t nNumRows( bSeriesFromColumns ? nMaxSequenceLength : nNumSequences );
+
+ // resize data
+ aResult.aDataInRows.resize( nNumRows );
+ double fNan = 0.0;
+ ::rtl::math::setNan( &fNan );
+ ::std::for_each( aResult.aDataInRows.begin(), aResult.aDataInRows.end(),
+ lcl_resize< t2DNumberContainer::value_type >( nNumColumns, fNan ));
+ aResult.aColumnDescriptions.resize( nNumColumns );
+ aResult.aComplexColumnDescriptions.realloc( nNumColumns );
+ aResult.aRowDescriptions.resize( nNumRows );
+ aResult.aComplexRowDescriptions.realloc( nNumRows );
+
+ tStringVector& rCategories = bSeriesFromColumns ? aResult.aRowDescriptions : aResult.aColumnDescriptions;
+ tStringVector& rLabels = bSeriesFromColumns ? aResult.aColumnDescriptions : aResult.aRowDescriptions;
+
+ //categories
+ lcl_SequenceToVector( aSimpleCategories, rCategories );
+ if( rCategoriesRange.getLength() )
+ {
+ OUString aRange(rCategoriesRange);
+ if( xRangeConversion.is())
+ aRange = xRangeConversion->convertRangeToXML( aRange );
+ if( bSeriesFromColumns )
+ aResult.aRowDescriptions_Ranges.push_back( aRange );
+ else
+ aResult.aColumnDescriptions_Ranges.push_back( aRange );
+ }
+
+ // iterate over all sequences
+ size_t nSeqIdx = 0;
+ for( ; aIt != aEnd; ++aIt, ++nSeqIdx )
+ {
+ OUString aRange;
+ if( aIt->first.is())
+ {
+ rLabels[nSeqIdx] = lcl_getLabelString( aIt->first );
+ aRange = aIt->first->getSourceRangeRepresentation();
+ if( xRangeConversion.is())
+ aRange = xRangeConversion->convertRangeToXML( aRange );
+ }
+ else if( aIt->second.is())
+ rLabels[nSeqIdx] = lcl_flattenStringSequence(
+ aIt->second->generateLabel( chart2::data::LabelOrigin_SHORT_SIDE ));
+ if( bSeriesFromColumns )
+ aResult.aColumnDescriptions_Ranges.push_back( aRange );
+ else
+ aResult.aRowDescriptions_Ranges.push_back( aRange );
+
+ ::std::vector< double > aNumbers( lcl_getAllValuesFromSequence( aIt->second ));
+ if( bSeriesFromColumns )
+ {
+ const sal_Int32 nSize( static_cast< sal_Int32 >( aNumbers.size()));
+ for( sal_Int32 nIdx=0; nIdx<nSize; ++nIdx )
+ aResult.aDataInRows[nIdx][nSeqIdx] = aNumbers[nIdx];
+ }
+ else
+ aResult.aDataInRows[nSeqIdx] = aNumbers;
+
+ if( aIt->second.is())
+ {
+ aRange = aIt->second->getSourceRangeRepresentation();
+ if( xRangeConversion.is())
+ aRange = xRangeConversion->convertRangeToXML( aRange );
+ }
+ aResult.aDataRangeRepresentations.push_back( aRange );
+
+ //is column hidden?
+ if( !lcl_SequenceHasUnhiddenData(aIt->first) && !lcl_SequenceHasUnhiddenData(aIt->second) )
+ aResult.aHiddenColumns.push_back(nSeqIdx);
+ }
+ }
+ catch( uno::Exception & rEx )
+ {
+ (void)rEx; // avoid warning for pro build
+ OSL_TRACE( OUStringToOString( OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "something went wrong during table data collection: " )) + rEx.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
+ }
+
+ return aResult;
+}
+
+void lcl_exportNumberFormat( const OUString& rPropertyName, const Reference< beans::XPropertySet >& xPropSet,
+ SvXMLExport& rExport )
+{
+ if( xPropSet.is())
+ {
+ sal_Int32 nNumberFormat = 0;
+ Any aNumAny = xPropSet->getPropertyValue( rPropertyName );
+ if( (aNumAny >>= nNumberFormat) && (nNumberFormat != -1) )
+ rExport.addDataStyle( nNumberFormat );
+ }
+}
+
+::std::vector< Reference< chart2::data::XDataSequence > >
+ lcl_getErrorBarSequences( const Reference< beans::XPropertySet > & xErrorBarProp )
+{
+ ::std::vector< Reference< chart2::data::XDataSequence > > aResult;
+ Reference< chart2::data::XDataSource > xErrorBarDataSource( xErrorBarProp, uno::UNO_QUERY );
+ if( !xErrorBarDataSource.is())
+ return aResult;
+
+ const OUString aRolePrefix( RTL_CONSTASCII_USTRINGPARAM( "error-bars-" ));
+// const OUString aXRolePrefix( aRolePrefix + OUString( RTL_CONSTASCII_USTRINGPARAM( "x-" )));
+// const OUString aYRolePrefix( aRolePrefix + OUString( RTL_CONSTASCII_USTRINGPARAM( "y-" )));
+// const OUString aPositivePostfix( RTL_CONSTASCII_USTRINGPARAM( "positive" ));
+// const OUString aNegativePostfix( RTL_CONSTASCII_USTRINGPARAM( "negative" ));
+
+ Sequence< Reference< chart2::data::XLabeledDataSequence > > aSequences(
+ xErrorBarDataSource->getDataSequences());
+ for( sal_Int32 nI=0; nI< aSequences.getLength(); ++nI )
+ {
+ try
+ {
+ if( aSequences[nI].is())
+ {
+ Reference< chart2::data::XDataSequence > xSequence( aSequences[nI]->getValues());
+ Reference< beans::XPropertySet > xSeqProp( xSequence, uno::UNO_QUERY_THROW );
+ OUString aRole;
+ if( ( xSeqProp->getPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "Role" ))) >>= aRole ) &&
+ aRole.match( aRolePrefix ))
+ {
+ aResult.push_back( xSequence );
+ }
+ }
+ }
+ catch( uno::Exception & rEx )
+ {
+#ifdef DBG_UTIL
+ String aStr( rEx.Message );
+ ByteString aBStr( aStr, RTL_TEXTENCODING_ASCII_US );
+ DBG_ERROR1( "chart:exporting error bar ranges: %s", aBStr.GetBuffer());
+#else
+ (void)rEx; // avoid warning
+#endif
+ }
+ }
+
+ return aResult;
+}
+
+bool lcl_exportDomainForThisSequence( const Reference< chart2::data::XDataSequence > xValues, rtl::OUString& rFirstRangeForThisDomainIndex, SvXMLExport& rExport )
+{
+ bool bDomainExported = false;
+ if( xValues.is())
+ {
+ Reference< chart2::XChartDocument > xNewDoc( rExport.GetModel(), uno::UNO_QUERY );
+ OUString aRange( lcl_ConvertRange( xValues->getSourceRangeRepresentation(), xNewDoc ) );
+
+ //work around error in OOo 2.0 (problems with multiple series having a domain element)
+ if( !rFirstRangeForThisDomainIndex.getLength() || !aRange.equals(rFirstRangeForThisDomainIndex) )
+ {
+ rExport.AddAttribute( XML_NAMESPACE_TABLE, XML_CELL_RANGE_ADDRESS, aRange);
+ SvXMLElementExport aDomain( rExport, XML_NAMESPACE_CHART, XML_DOMAIN, sal_True, sal_True );
+ bDomainExported = true;
+ }
+
+ if( !rFirstRangeForThisDomainIndex.getLength() )
+ rFirstRangeForThisDomainIndex = aRange;
+ }
+ return bDomainExported;
+}
+
+} // anonymous namespace
+
+struct SchXMLDataPointStruct
+{
+ OUString maStyleName;
+ sal_Int32 mnRepeat;
+
+ SchXMLDataPointStruct() : mnRepeat( 1 ) {}
+};
+
+// ========================================
+// class SchXMLExportHelper
+// ========================================
+
+SchXMLExportHelper::SchXMLExportHelper( SvXMLExport& rExport, SvXMLAutoStylePoolP& rASPool )
+ : m_pImpl( new SchXMLExportHelper_Impl( rExport, rASPool ) )
+{
+}
+
+SchXMLExportHelper::~SchXMLExportHelper()
+{
+ delete m_pImpl;
+}
+
+const OUString& SchXMLExportHelper::getChartCLSID()
+{
+ return m_pImpl->msCLSID;
+}
+
+UniReference< XMLPropertySetMapper > SchXMLExportHelper_Impl::GetPropertySetMapper() const
+{
+ return mxPropertySetMapper;
+}
+
+void SchXMLExportHelper_Impl::exportAutoStyles()
+{
+ if( mxExpPropMapper.is())
+ {
+ //ToDo: when embedded in calc/writer this is not necessary because the
+ // numberformatter is shared between both documents
+ mrExport.exportAutoDataStyles();
+
+ // export chart auto styles
+ mrAutoStylePool.exportXML(
+ XML_STYLE_FAMILY_SCH_CHART_ID
+ , mrExport.GetDocHandler(),
+ mrExport.GetMM100UnitConverter(),
+ mrExport.GetNamespaceMap()
+ );
+
+ // export auto styles for additional shapes
+ mrExport.GetShapeExport()->exportAutoStyles();
+ // and for text in additional shapes
+ mrExport.GetTextParagraphExport()->exportTextAutoStyles();
+ }
+}
+
+// private methods
+// ---------------
+
+SchXMLExportHelper_Impl::SchXMLExportHelper_Impl(
+ SvXMLExport& rExport,
+ SvXMLAutoStylePoolP& rASPool ) :
+ mrExport( rExport ),
+ mrAutoStylePool( rASPool ),
+ mbHasSeriesLabels( sal_False ),
+ mbHasCategoryLabels( sal_False ),
+ mbRowSourceColumns( sal_True )
+ // #110680#
+ // this id depends on the ServiceManager used due to the binary filter stripping.
+ // ,msCLSID( rtl::OUString( SvGlobalName( SO3_SCH_CLASSID ).GetHexName()))
+{
+ // #110680#
+ // changed initialisation for msCLSID. Compare the ServiceInfo name with
+ // the known name of the LegacyServiceManager.
+ Reference<lang::XServiceInfo> xServiceInfo( mrExport.getServiceFactory(), uno::UNO_QUERY );
+ DBG_ASSERT( xServiceInfo.is(), "XMultiServiceFactory without xServiceInfo (!)" );
+ OUString rdbURL = xServiceInfo->getImplementationName();
+ OUString implLegacyServiceManagerName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.office.LegacyServiceManager" ) );
+
+ if( rdbURL.equals( implLegacyServiceManagerName ))
+ {
+ msCLSID = OUString( SvGlobalName( BF_SO3_SCH_CLASSID ).GetHexName());
+ }
+ else
+ {
+ msCLSID = OUString( SvGlobalName( SO3_SCH_CLASSID ).GetHexName());
+ }
+
+ msTableName = OUString::createFromAscii( "local-table" );
+
+ // create factory
+ mxPropertyHandlerFactory = new XMLChartPropHdlFactory;
+
+ if( mxPropertyHandlerFactory.is() )
+ {
+ // create property set mapper
+ mxPropertySetMapper = new XMLChartPropertySetMapper;
+ }
+
+ mxExpPropMapper = new XMLChartExportPropertyMapper( mxPropertySetMapper, rExport );
+
+ // register chart auto-style family
+ mrAutoStylePool.AddFamily(
+ XML_STYLE_FAMILY_SCH_CHART_ID,
+ OUString::createFromAscii( XML_STYLE_FAMILY_SCH_CHART_NAME ),
+ mxExpPropMapper.get(),
+ OUString::createFromAscii( XML_STYLE_FAMILY_SCH_CHART_PREFIX ));
+
+ // register shape family
+ mrAutoStylePool.AddFamily(
+ XML_STYLE_FAMILY_SD_GRAPHICS_ID,
+ OUString::createFromAscii( XML_STYLE_FAMILY_SD_GRAPHICS_NAME ),
+ mxExpPropMapper.get(),
+ OUString::createFromAscii( XML_STYLE_FAMILY_SD_GRAPHICS_PREFIX ));
+ // register paragraph family also for shapes
+ mrAutoStylePool.AddFamily(
+ XML_STYLE_FAMILY_TEXT_PARAGRAPH,
+ GetXMLToken( XML_PARAGRAPH ),
+ mxExpPropMapper.get(),
+ String( 'P' ));
+ // register text family also for shapes
+ mrAutoStylePool.AddFamily(
+ XML_STYLE_FAMILY_TEXT_TEXT,
+ GetXMLToken( XML_TEXT ),
+ mxExpPropMapper.get(),
+ String( 'T' ));
+}
+
+SchXMLExportHelper_Impl::~SchXMLExportHelper_Impl()
+{
+}
+
+void SchXMLExportHelper_Impl::collectAutoStyles( Reference< chart::XChartDocument > rChartDoc )
+{
+ parseDocument( rChartDoc, sal_False );
+}
+
+void SchXMLExportHelper_Impl::exportChart( Reference< chart::XChartDocument > rChartDoc,
+ sal_Bool bIncludeTable )
+{
+ parseDocument( rChartDoc, sal_True, bIncludeTable );
+ DBG_ASSERT( maAutoStyleNameQueue.empty(), "There are still remaining autostyle names in the queue" );
+}
+
+::rtl::OUString lcl_GetStringFromNumberSequence( const ::com::sun::star::uno::Sequence< sal_Int32 >& rSequenceMapping, bool bRemoveOneFromEachIndex /*should be true if having categories*/ )
+{
+ const sal_Int32* pArray = rSequenceMapping.getConstArray();
+ const sal_Int32 nSize = rSequenceMapping.getLength();
+ sal_Int32 i = 0;
+ OUStringBuffer aBuf;
+ bool bHasPredecessor = false;
+ for( i = 0; i < nSize; ++i )
+ {
+ sal_Int32 nIndex = pArray[ i ];
+ if( bRemoveOneFromEachIndex )
+ --nIndex;
+ if(nIndex>=0)
+ {
+ if(bHasPredecessor)
+ aBuf.append( static_cast< sal_Unicode >( ' ' ));
+ aBuf.append( nIndex, 10 );
+ bHasPredecessor = true;
+ }
+ }
+ return aBuf.makeStringAndClear();
+}
+
+/// if bExportContent is false the auto-styles are collected
+void SchXMLExportHelper_Impl::parseDocument( Reference< chart::XChartDocument >& rChartDoc,
+ sal_Bool bExportContent,
+ sal_Bool bIncludeTable )
+{
+ Reference< chart2::XChartDocument > xNewDoc( rChartDoc, uno::UNO_QUERY );
+ if( !rChartDoc.is() || !xNewDoc.is() )
+ {
+ DBG_ERROR( "No XChartDocument was given for export." );
+ return;
+ }
+
+ awt::Size aPageSize( getPageSize( xNewDoc ));
+ if( bExportContent )
+ addSize( aPageSize );
+ Reference< chart::XDiagram > xDiagram = rChartDoc->getDiagram();
+ Reference< chart2::XDiagram > xNewDiagram;
+ if( xNewDoc.is())
+ xNewDiagram.set( xNewDoc->getFirstDiagram());
+
+ //todo remove if model changes are notified and view is updated automatically
+ if( bExportContent )
+ {
+ Reference< util::XRefreshable > xRefreshable( xNewDoc, uno::UNO_QUERY );
+ if( xRefreshable.is() )
+ xRefreshable->refresh();
+ }
+
+ // get Properties of ChartDocument
+ sal_Bool bHasMainTitle = sal_False;
+ sal_Bool bHasSubTitle = sal_False;
+ sal_Bool bHasLegend = sal_False;
+ util::DateTime aNullDate(0,0,0,0,30,12,1899);
+
+ std::vector< XMLPropertyState > aPropertyStates;
+
+ Reference< beans::XPropertySet > xDocPropSet( rChartDoc, uno::UNO_QUERY );
+ if( xDocPropSet.is())
+ {
+ try
+ {
+ Any aAny( xDocPropSet->getPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "HasMainTitle" ))));
+ aAny >>= bHasMainTitle;
+ aAny = xDocPropSet->getPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "HasSubTitle" )));
+ aAny >>= bHasSubTitle;
+ aAny = xDocPropSet->getPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "HasLegend" )));
+ aAny >>= bHasLegend;
+ if ( bIncludeTable )
+ {
+ OUString sNullDate( RTL_CONSTASCII_USTRINGPARAM( "NullDate" ));
+ aAny = xDocPropSet->getPropertyValue(sNullDate);
+ if ( !aAny.hasValue() )
+ {
+ Reference<container::XChild> xChild(rChartDoc, uno::UNO_QUERY );
+ if ( xChild.is() )
+ {
+ Reference< beans::XPropertySet > xParentDoc( xChild->getParent(),uno::UNO_QUERY);
+ if ( xParentDoc.is() && xParentDoc->getPropertySetInfo()->hasPropertyByName(sNullDate) )
+ aAny = xParentDoc->getPropertyValue(sNullDate);
+ }
+ }
+
+ aAny >>= aNullDate;
+ }
+ }
+ catch( beans::UnknownPropertyException & )
+ {
+ DBG_WARNING( "Required property not found in ChartDocument" );
+ }
+ } // if( xDocPropSet.is())
+
+ if ( bIncludeTable && (aNullDate.Day != 30 || aNullDate.Month != 12 || aNullDate.Year != 1899 ) )
+ {
+ SvXMLElementExport aSet( mrExport, XML_NAMESPACE_TABLE, XML_CALCULATION_SETTINGS, sal_True, sal_True );
+ {
+ ::rtl::OUStringBuffer sBuffer;
+ SvXMLUnitConverter::convertDateTime(sBuffer,aNullDate);
+ mrExport.AddAttribute( XML_NAMESPACE_TABLE,XML_DATE_VALUE,sBuffer.makeStringAndClear());
+ SvXMLElementExport aNull( mrExport, XML_NAMESPACE_TABLE, XML_NULL_DATE, sal_True, sal_True );
+ }
+ }
+
+ // chart element
+ // -------------
+
+ SvXMLElementExport* pElChart = 0;
+ // get property states for autostyles
+ if( mxExpPropMapper.is())
+ {
+ Reference< beans::XPropertySet > xPropSet( rChartDoc->getArea(), uno::UNO_QUERY );
+ if( xPropSet.is())
+ aPropertyStates = mxExpPropMapper->Filter( xPropSet );
+ }
+
+ if( bExportContent )
+ {
+ //export data provider in xlink:href attribute
+ const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion( SvtSaveOptions().GetODFDefaultVersion() );
+ if( nCurrentODFVersion >= SvtSaveOptions::ODFVER_012 )
+ {
+ OUString aDataProviderURL( RTL_CONSTASCII_USTRINGPARAM( ".." ) );
+ if( xNewDoc->hasInternalDataProvider() )
+ aDataProviderURL = OUString( RTL_CONSTASCII_USTRINGPARAM( "." ) );
+ else //special handling for data base data provider necessary
+ {
+ Reference< chart2::data::XDatabaseDataProvider > xDBDataProvider( xNewDoc->getDataProvider(), uno::UNO_QUERY );
+ if( xDBDataProvider.is() )
+ aDataProviderURL = OUString( RTL_CONSTASCII_USTRINGPARAM( "." ) );
+ }
+ mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, aDataProviderURL );
+ mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
+ }
+
+ OUString sChartType( xDiagram->getDiagramType() );
+
+ // attributes
+ // determine class
+ if( sChartType.getLength())
+ {
+ enum XMLTokenEnum eXMLChartType = SchXMLTools::getTokenByChartType( sChartType, true /* bUseOldNames */ );
+
+ DBG_ASSERT( eXMLChartType != XML_TOKEN_INVALID, "invalid chart class" );
+ if( eXMLChartType == XML_TOKEN_INVALID )
+ eXMLChartType = XML_BAR;
+
+ if( eXMLChartType == XML_ADD_IN )
+ {
+ // sChartType is the servie-name of the add-in
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_CLASS,
+ mrExport.GetNamespaceMap().GetQNameByKey(
+ XML_NAMESPACE_OOO, sChartType) );
+ }
+ else if( eXMLChartType != XML_TOKEN_INVALID )
+ {
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_CLASS,
+ mrExport.GetNamespaceMap().GetQNameByKey(
+ XML_NAMESPACE_CHART, GetXMLToken(eXMLChartType )) );
+ }
+
+ //column-mapping or row-mapping
+ if( maSequenceMapping.getLength() )
+ {
+ enum XMLTokenEnum eTransToken = ::xmloff::token::XML_ROW_MAPPING;
+ if( mbRowSourceColumns )
+ eTransToken = ::xmloff::token::XML_COLUMN_MAPPING;
+ ::rtl::OUString aSequenceMappingStr( lcl_GetStringFromNumberSequence(
+ maSequenceMapping, mbHasCategoryLabels && !xNewDoc->hasInternalDataProvider() ) );
+
+ mrExport.AddAttribute( XML_NAMESPACE_CHART,
+ ::xmloff::token::GetXMLToken( eTransToken ),
+ aSequenceMappingStr );
+ }
+ }
+ // write style name
+ AddAutoStyleAttribute( aPropertyStates );
+
+ //element
+ pElChart = new SvXMLElementExport( mrExport, XML_NAMESPACE_CHART, XML_CHART, sal_True, sal_True );
+ }
+ else // autostyles
+ {
+ CollectAutoStyle( aPropertyStates );
+ }
+ // remove property states for autostyles
+ aPropertyStates.clear();
+
+ // title element
+ // -------------
+
+ if( bHasMainTitle )
+ {
+ // get property states for autostyles
+ if( mxExpPropMapper.is())
+ {
+ Reference< beans::XPropertySet > xPropSet( rChartDoc->getTitle(), uno::UNO_QUERY );
+ if( xPropSet.is())
+ aPropertyStates = mxExpPropMapper->Filter( xPropSet );
+ }
+ if( bExportContent )
+ {
+ Reference< drawing::XShape > xShape = rChartDoc->getTitle();
+ if( xShape.is()) // && "hasTitleBeenMoved"
+ addPosition( xShape );
+
+ // write style name
+ AddAutoStyleAttribute( aPropertyStates );
+
+ // element
+ SvXMLElementExport aElTitle( mrExport, XML_NAMESPACE_CHART, XML_TITLE, sal_True, sal_True );
+
+ // content (text:p)
+ Reference< beans::XPropertySet > xPropSet( xShape, uno::UNO_QUERY );
+ if( xPropSet.is())
+ {
+ Any aAny( xPropSet->getPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "String" ))));
+ OUString aText;
+ aAny >>= aText;
+ exportText( aText );
+ }
+ }
+ else // autostyles
+ {
+ CollectAutoStyle( aPropertyStates );
+ }
+ // remove property states for autostyles
+ aPropertyStates.clear();
+ }
+
+ // subtitle element
+ // ----------------
+
+ if( bHasSubTitle )
+ {
+ // get property states for autostyles
+ if( mxExpPropMapper.is())
+ {
+ Reference< beans::XPropertySet > xPropSet( rChartDoc->getSubTitle(), uno::UNO_QUERY );
+ if( xPropSet.is())
+ aPropertyStates = mxExpPropMapper->Filter( xPropSet );
+ }
+
+ if( bExportContent )
+ {
+ Reference< drawing::XShape > xShape = rChartDoc->getSubTitle();
+ if( xShape.is())
+ addPosition( xShape );
+
+ // write style name
+ AddAutoStyleAttribute( aPropertyStates );
+
+ // element (has no subelements)
+ SvXMLElementExport aElSubTitle( mrExport, XML_NAMESPACE_CHART, XML_SUBTITLE, sal_True, sal_True );
+
+ // content (text:p)
+ Reference< beans::XPropertySet > xPropSet( xShape, uno::UNO_QUERY );
+ if( xPropSet.is())
+ {
+ Any aAny( xPropSet->getPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "String" ))));
+ OUString aText;
+ aAny >>= aText;
+ exportText( aText );
+ }
+ }
+ else // autostyles
+ {
+ CollectAutoStyle( aPropertyStates );
+ }
+ // remove property states for autostyles
+ aPropertyStates.clear();
+ }
+
+ // legend element
+ // --------------
+ if( bHasLegend )
+ {
+ // get property states for autostyles
+ if( mxExpPropMapper.is())
+ {
+ Reference< beans::XPropertySet > xPropSet( rChartDoc->getLegend(), uno::UNO_QUERY );
+ if( xPropSet.is())
+ aPropertyStates = mxExpPropMapper->Filter( xPropSet );
+ }
+
+ if( bExportContent )
+ {
+ Reference< beans::XPropertySet > xProp( rChartDoc->getLegend(), uno::UNO_QUERY );
+ if( xProp.is())
+ {
+ chart::ChartLegendPosition aLegendPos = chart::ChartLegendPosition_NONE;
+ try
+ {
+ Any aAny( xProp->getPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "Alignment" ))));
+ aAny >>= aLegendPos;
+ }
+ catch( beans::UnknownPropertyException & )
+ {
+ DBG_WARNING( "Property Align not found in ChartLegend" );
+ }
+
+ switch( aLegendPos )
+ {
+ case chart::ChartLegendPosition_LEFT:
+// msString = GetXMLToken(XML_LEFT);
+ // #i35421# change left->start (not clear why this was done)
+ msString = GetXMLToken(XML_START);
+ break;
+ case chart::ChartLegendPosition_RIGHT:
+// msString = GetXMLToken(XML_RIGHT);
+ // #i35421# change right->end (not clear why this was done)
+ msString = GetXMLToken(XML_END);
+ break;
+ case chart::ChartLegendPosition_TOP:
+ msString = GetXMLToken(XML_TOP);
+ break;
+ case chart::ChartLegendPosition_BOTTOM:
+ msString = GetXMLToken(XML_BOTTOM);
+ break;
+ case chart::ChartLegendPosition_NONE:
+ case chart::ChartLegendPosition_MAKE_FIXED_SIZE:
+ // nothing
+ break;
+ }
+
+ // export anchor position
+ if( msString.getLength())
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_LEGEND_POSITION, msString );
+
+ // export absolute position
+ msString = OUString();
+ Reference< drawing::XShape > xShape( xProp, uno::UNO_QUERY );
+ if( xShape.is())
+ addPosition( xShape );
+ }
+
+ // write style name
+ AddAutoStyleAttribute( aPropertyStates );
+
+ // element
+ SvXMLElementExport aLegend( mrExport, XML_NAMESPACE_CHART, XML_LEGEND, sal_True, sal_True );
+ }
+ else // autostyles
+ {
+ CollectAutoStyle( aPropertyStates );
+ }
+ // remove property states for autostyles
+ aPropertyStates.clear();
+ }
+
+ // plot-area element
+ // -----------------
+ if( xDiagram.is())
+ exportPlotArea( xDiagram, xNewDiagram, aPageSize, bExportContent, bIncludeTable );
+
+ // export additional shapes
+ // ------------------------
+ if( xDocPropSet.is() )
+ {
+ if( bExportContent )
+ {
+ if( mxAdditionalShapes.is())
+ {
+ // can't call exportShapes with all shapes because the
+ // initialisation happend with the complete draw page and not
+ // the XShapes object used here. Thus the shapes have to be
+ // exported one by one
+ UniReference< XMLShapeExport > rShapeExport = mrExport.GetShapeExport();
+ Reference< drawing::XShape > xShape;
+ const sal_Int32 nShapeCount( mxAdditionalShapes->getCount());
+ for( sal_Int32 nShapeId = 0; nShapeId < nShapeCount; nShapeId++ )
+ {
+ mxAdditionalShapes->getByIndex( nShapeId ) >>= xShape;
+ DBG_ASSERT( xShape.is(), "Shape without an XShape?" );
+ if( ! xShape.is())
+ continue;
+
+ rShapeExport->exportShape( xShape );
+ }
+ // this would be the easier way if it worked:
+ //mrExport.GetShapeExport()->exportShapes( mxAdditionalShapes );
+ }
+ }
+ else
+ {
+ // get a sequence of non-chart shapes (inserted via clipboard)
+ try
+ {
+ Any aShapesAny = xDocPropSet->getPropertyValue( OUString::createFromAscii( "AdditionalShapes" ));
+ aShapesAny >>= mxAdditionalShapes;
+ }
+ catch( uno::Exception & rEx )
+ {
+ (void)rEx; // avoid warning for pro build
+ OSL_TRACE(
+ OUStringToOString(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "AdditionalShapes not found: " )) +
+ rEx.Message,
+ RTL_TEXTENCODING_ASCII_US ).getStr());
+ }
+
+ if( mxAdditionalShapes.is())
+ {
+ // seek shapes has to be called for the whole page because in
+ // the shape export the vector of shapes is accessed via the
+ // ZOrder which might be (actually is) larger than the number of
+ // shapes in mxAdditionalShapes
+ Reference< drawing::XDrawPageSupplier > xSupplier( rChartDoc, uno::UNO_QUERY );
+ DBG_ASSERT( xSupplier.is(), "Cannot retrieve draw page to initialize shape export" );
+ if( xSupplier.is() )
+ {
+ Reference< drawing::XShapes > xDrawPage( xSupplier->getDrawPage(), uno::UNO_QUERY );
+ DBG_ASSERT( xDrawPage.is(), "Invalid draw page for initializing shape export" );
+ if( xDrawPage.is())
+ mrExport.GetShapeExport()->seekShapes( xDrawPage );
+ }
+
+ // can't call collectShapesAutoStyles with all shapes because
+ // the initialisation happend with the complete draw page and
+ // not the XShapes object used here. Thus the shapes have to be
+ // exported one by one
+ UniReference< XMLShapeExport > rShapeExport = mrExport.GetShapeExport();
+ Reference< drawing::XShape > xShape;
+ const sal_Int32 nShapeCount( mxAdditionalShapes->getCount());
+ for( sal_Int32 nShapeId = 0; nShapeId < nShapeCount; nShapeId++ )
+ {
+ mxAdditionalShapes->getByIndex( nShapeId ) >>= xShape;
+ DBG_ASSERT( xShape.is(), "Shape without an XShape?" );
+ if( ! xShape.is())
+ continue;
+
+ rShapeExport->collectShapeAutoStyles( xShape );
+ }
+ // this would be the easier way if it worked:
+ // mrExport.GetShapeExport()->collectShapesAutoStyles( mxAdditionalShapes );
+ }
+ }
+ }
+
+ // table element
+ // (is included as subelement of chart)
+ // ------------------------------------
+ if( bExportContent )
+ {
+ // #85929# always export table, otherwise clipboard may loose data
+ exportTable();
+ }
+
+ // close <chart:chart> element
+ if( pElChart )
+ delete pElChart;
+}
+
+void lcl_exportComplexLabel( const Sequence< OUString >& rComplexLabel, SvXMLExport& rExport )
+{
+ sal_Int32 nLength = rComplexLabel.getLength();
+ if( nLength<=1 )
+ return;
+ SvXMLElementExport aTextList( rExport, XML_NAMESPACE_TEXT, XML_LIST, sal_True, sal_True );
+ for(sal_Int32 nN=0; nN<nLength; nN++)
+ {
+ SvXMLElementExport aListItem( rExport, XML_NAMESPACE_TEXT, XML_LIST_ITEM, sal_True, sal_True );
+ SchXMLTools::exportText( rExport, rComplexLabel[nN], false /*bConvertTabsLFs*/ );
+ }
+}
+
+void SchXMLExportHelper_Impl::exportTable()
+{
+ // table element
+ // -------------
+ mrExport.AddAttribute( XML_NAMESPACE_TABLE, XML_NAME, msTableName );
+ SvXMLElementExport aTable( mrExport, XML_NAMESPACE_TABLE, XML_TABLE, sal_True, sal_True );
+
+ bool bHasOwnData = false;
+ Reference< chart2::XChartDocument > xNewDoc( mrExport.GetModel(), uno::UNO_QUERY );
+ Reference< chart2::data::XRangeXMLConversion > xRangeConversion;
+ if( xNewDoc.is())
+ {
+ bHasOwnData = xNewDoc->hasInternalDataProvider();
+ xRangeConversion.set( xNewDoc->getDataProvider(), uno::UNO_QUERY );
+ }
+
+ Reference< chart::XComplexDescriptionAccess > xComplexDescriptionAccess;
+ {
+ Reference< chart::XChartDocument > xChartDoc( mrExport.GetModel(), uno::UNO_QUERY );
+ if( xChartDoc.is() )
+ xComplexDescriptionAccess = Reference< chart::XComplexDescriptionAccess >( xChartDoc->getData(), uno::UNO_QUERY );
+ }
+
+ if( bHasOwnData )
+ lcl_ReorderInternalSequencesAccordingToTheirRangeName( m_aDataSequencesToExport );
+ lcl_TableData aData( lcl_getDataForLocalTable( m_aDataSequencesToExport
+ , xComplexDescriptionAccess, maCategoriesRange
+ , mbRowSourceColumns, xRangeConversion ));
+
+ tStringVector::const_iterator aDataRangeIter( aData.aDataRangeRepresentations.begin());
+ const tStringVector::const_iterator aDataRangeEndIter( aData.aDataRangeRepresentations.end());
+
+ tStringVector::const_iterator aRowDescriptions_RangeIter( aData.aRowDescriptions_Ranges.begin());
+ const tStringVector::const_iterator aRowDescriptions_RangeEnd( aData.aRowDescriptions_Ranges.end());
+
+ // declare columns
+ {
+ SvXMLElementExport aHeaderColumns( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_HEADER_COLUMNS, sal_True, sal_True );
+ SvXMLElementExport aHeaderColumn( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_COLUMN, sal_True, sal_True );
+ }
+ {
+ SvXMLElementExport aColumns( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_COLUMNS, sal_True, sal_True );
+
+ sal_Int32 nNextIndex = 0;
+ for( size_t nN=0; nN< aData.aHiddenColumns.size(); nN++ )
+ {
+ //i91578 display of hidden values (copy paste scenario; export hidden flag thus it can be used during migration to locale table upon paste )
+ sal_Int32 nHiddenIndex = aData.aHiddenColumns[nN];
+ if( nHiddenIndex > nNextIndex )
+ {
+ sal_Int64 nRepeat = static_cast< sal_Int64 >( nHiddenIndex - nNextIndex );
+ if(nRepeat>1)
+ mrExport.AddAttribute( XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED,
+ OUString::valueOf( nRepeat ));
+ SvXMLElementExport aColumn( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_COLUMN, sal_True, sal_True );
+ }
+ mrExport.AddAttribute( XML_NAMESPACE_TABLE, XML_VISIBILITY, GetXMLToken( XML_COLLAPSE ) );
+ SvXMLElementExport aColumn( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_COLUMN, sal_True, sal_True );
+ nNextIndex = nHiddenIndex+1;
+ }
+
+ sal_Int32 nEndIndex = aData.aColumnDescriptions.size()-1;
+ if( nEndIndex >= nNextIndex )
+ {
+ sal_Int64 nRepeat = static_cast< sal_Int64 >( nEndIndex - nNextIndex + 1 );
+ if(nRepeat>1)
+ mrExport.AddAttribute( XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED,
+ OUString::valueOf( nRepeat ));
+ SvXMLElementExport aColumn( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_COLUMN, sal_True, sal_True );
+ }
+ }
+
+ // export rows with content
+ //export header row
+ {
+ SvXMLElementExport aHeaderRows( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_HEADER_ROWS, sal_True, sal_True );
+ SvXMLElementExport aRow( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_ROW, sal_True, sal_True );
+
+ //first one empty cell for the row descriptions
+ {
+ SvXMLElementExport aEmptyCell( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_CELL, sal_True, sal_True );
+ SvXMLElementExport aEmptyParagraph( mrExport, XML_NAMESPACE_TEXT, XML_P, sal_True, sal_True );
+ }
+
+ //export column descriptions
+ tStringVector::const_iterator aColumnDescriptions_RangeIter( aData.aColumnDescriptions_Ranges.begin());
+ const tStringVector::const_iterator aColumnDescriptions_RangeEnd( aData.aColumnDescriptions_Ranges.end());
+ const Sequence< Sequence< OUString > >& rComplexColumnDescriptions = aData.aComplexColumnDescriptions;
+ sal_Int32 nComplexCount = rComplexColumnDescriptions.getLength();
+ sal_Int32 nC = 0;
+ for( tStringVector::const_iterator aIt( aData.aColumnDescriptions.begin());
+ aIt != aData.aColumnDescriptions.end(); ++aIt )
+ {
+ mrExport.AddAttribute( XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_STRING );
+ SvXMLElementExport aCell( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_CELL, sal_True, sal_True );
+ exportText( *aIt );
+ if( nC < nComplexCount )
+ lcl_exportComplexLabel( rComplexColumnDescriptions[nC++], mrExport );
+ if( !bHasOwnData && aColumnDescriptions_RangeIter != aColumnDescriptions_RangeEnd )
+ {
+ // remind the original range to allow a correct re-association when copying via clipboard
+ if ((*aColumnDescriptions_RangeIter).getLength())
+ SchXMLTools::exportRangeToSomewhere( mrExport, *aColumnDescriptions_RangeIter );
+ ++aColumnDescriptions_RangeIter;
+ }
+ }
+ OSL_ASSERT( bHasOwnData || aColumnDescriptions_RangeIter == aColumnDescriptions_RangeEnd );
+ } // closing row and header-rows elements
+
+ // export value rows
+ {
+ SvXMLElementExport aRows( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_ROWS, sal_True, sal_True );
+ tStringVector::const_iterator aRowDescriptionsIter( aData.aRowDescriptions.begin());
+ const Sequence< Sequence< OUString > >& rComplexRowDescriptions = aData.aComplexRowDescriptions;
+ sal_Int32 nComplexCount = rComplexRowDescriptions.getLength();
+ sal_Int32 nC = 0;
+
+ for( t2DNumberContainer::const_iterator aRowIt( aData.aDataInRows.begin());
+ aRowIt != aData.aDataInRows.end(); ++aRowIt )
+ {
+ SvXMLElementExport aRow( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_ROW, sal_True, sal_True );
+
+ //export row descriptions
+ {
+ mrExport.AddAttribute( XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_STRING );
+ SvXMLElementExport aCell( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_CELL, sal_True, sal_True );
+ if( aRowDescriptionsIter != aData.aRowDescriptions.end())
+ {
+ exportText( *aRowDescriptionsIter );
+ ++aRowDescriptionsIter;
+ if( nC < nComplexCount )
+ lcl_exportComplexLabel( rComplexRowDescriptions[nC++], mrExport );
+ if( !bHasOwnData && aRowDescriptions_RangeIter != aRowDescriptions_RangeEnd )
+ {
+ // remind the original range to allow a correct re-association when copying via clipboard
+ SchXMLTools::exportRangeToSomewhere( mrExport, *aRowDescriptions_RangeIter++ );
+ }
+ }
+ }
+
+ //export row values
+ for( t2DNumberContainer::value_type::const_iterator aColIt( aRowIt->begin());
+ aColIt != aRowIt->end(); ++aColIt )
+ {
+ SvXMLUnitConverter::convertDouble( msStringBuffer, *aColIt );
+ msString = msStringBuffer.makeStringAndClear();
+ mrExport.AddAttribute( XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_FLOAT );
+ mrExport.AddAttribute( XML_NAMESPACE_OFFICE, XML_VALUE, msString );
+ SvXMLElementExport aCell( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_CELL, sal_True, sal_True );
+ exportText( msString, false ); // do not convert tabs and lfs
+ if( ( !bHasOwnData && aDataRangeIter != aDataRangeEndIter ) &&
+ ( mbRowSourceColumns || (aColIt == aRowIt->begin()) ) )
+ {
+ // remind the original range to allow a correct re-association when copying via clipboard
+ if ((*aDataRangeIter).getLength())
+ SchXMLTools::exportRangeToSomewhere( mrExport, *aDataRangeIter );
+ ++aDataRangeIter;
+ }
+ }
+ }
+ }
+
+ // if range iterator was used it should have reached its end
+ OSL_ASSERT( bHasOwnData || (aDataRangeIter == aDataRangeEndIter) );
+ OSL_ASSERT( bHasOwnData || (aRowDescriptions_RangeIter == aRowDescriptions_RangeEnd) );
+}
+
+void SchXMLExportHelper_Impl::exportPlotArea(
+ Reference< chart::XDiagram > xDiagram,
+ Reference< chart2::XDiagram > xNewDiagram,
+ const awt::Size & rPageSize,
+ sal_Bool bExportContent,
+ sal_Bool bIncludeTable )
+{
+ DBG_ASSERT( xDiagram.is(), "Invalid XDiagram as parameter" );
+ if( ! xDiagram.is())
+ return;
+
+ // variables for autostyles
+ Reference< beans::XPropertySet > xPropSet;
+ std::vector< XMLPropertyState > aPropertyStates;
+
+ OUString aASName;
+ sal_Bool bHasTwoYAxes = sal_False;
+ sal_Bool bIs3DChart = sal_False;
+ drawing::HomogenMatrix aTransMatrix;
+
+ msStringBuffer.setLength( 0 );
+
+ // plot-area element
+ // -----------------
+
+ SvXMLElementExport* pElPlotArea = 0;
+ // get property states for autostyles
+ xPropSet = Reference< beans::XPropertySet >( xDiagram, uno::UNO_QUERY );
+ if( xPropSet.is())
+ {
+ if( mxExpPropMapper.is())
+ aPropertyStates = mxExpPropMapper->Filter( xPropSet );
+ }
+ if( bExportContent )
+ {
+ UniReference< XMLShapeExport > rShapeExport;
+
+ // write style name
+ AddAutoStyleAttribute( aPropertyStates );
+
+ if( msChartAddress.getLength() )
+ {
+ if( !bIncludeTable )
+ mrExport.AddAttribute( XML_NAMESPACE_TABLE, XML_CELL_RANGE_ADDRESS, msChartAddress );
+
+ Reference< chart::XChartDocument > xDoc( mrExport.GetModel(), uno::UNO_QUERY );
+ if( xDoc.is() )
+ {
+ Reference< beans::XPropertySet > xDocProp( xDoc, uno::UNO_QUERY );
+ if( xDocProp.is())
+ {
+ Any aAny;
+ sal_Bool bFirstCol = false, bFirstRow = false;
+
+ try
+ {
+ aAny = xDocProp->getPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "DataSourceLabelsInFirstColumn" )));
+ aAny >>= bFirstCol;
+ aAny = xDocProp->getPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "DataSourceLabelsInFirstRow" )));
+ aAny >>= bFirstRow;
+
+ if( bFirstCol || bFirstRow )
+ {
+ mrExport.AddAttribute( XML_NAMESPACE_CHART,
+ ::xmloff::token::GetXMLToken( ::xmloff::token::XML_DATA_SOURCE_HAS_LABELS ),
+ ( bFirstCol
+ ? ( bFirstRow
+ ? ::xmloff::token::GetXMLToken( ::xmloff::token::XML_BOTH )
+ : ::xmloff::token::GetXMLToken( ::xmloff::token::XML_COLUMN ))
+ : ::xmloff::token::GetXMLToken( ::xmloff::token::XML_ROW )));
+ }
+ }
+ catch( beans::UnknownPropertyException & )
+ {
+ DBG_ERRORFILE( "Properties missing" );
+ }
+ }
+ }
+ }
+
+ // #i72973#, #144135# only export table-number-list in OOo format (also for binary)
+ Reference< beans::XPropertySet > xExportInfo( mrExport.getExportInfo());
+ if( msTableNumberList.getLength() &&
+ xExportInfo.is())
+ {
+ try
+ {
+ OUString sExportTableNumListPropName( RTL_CONSTASCII_USTRINGPARAM("ExportTableNumberList"));
+ Reference< beans::XPropertySetInfo > xInfo( xExportInfo->getPropertySetInfo());
+ bool bExportTableNumberList = false;
+ if( xInfo.is() && xInfo->hasPropertyByName( sExportTableNumListPropName ) &&
+ (xExportInfo->getPropertyValue( sExportTableNumListPropName ) >>= bExportTableNumberList) &&
+ bExportTableNumberList )
+ {
+ // this attribute is for charts embedded in calc documents only.
+ // With this you are able to store a file again in 5.0 binary format
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_TABLE_NUMBER_LIST, msTableNumberList );
+ }
+ }
+ catch( uno::Exception & rEx )
+ {
+#ifdef DBG_UTIL
+ String aStr( rEx.Message );
+ ByteString aBStr( aStr, RTL_TEXTENCODING_ASCII_US );
+ DBG_ERROR1( "chart:TableNumberList property caught: %s", aBStr.GetBuffer());
+#else
+ (void)rEx; // avoid warning
+#endif
+ }
+ }
+
+ // attributes
+ Reference< drawing::XShape > xShape ( xDiagram, uno::UNO_QUERY );
+ if( xShape.is())
+ {
+ addPosition( xShape );
+ addSize( xShape );
+ }
+
+ if( xPropSet.is())
+ {
+ Any aAny;
+ try
+ {
+ aAny = xPropSet->getPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "HasSecondaryYAxis" )));
+ aAny >>= bHasTwoYAxes;
+ }
+ catch( beans::UnknownPropertyException & )
+ {
+ DBG_ERROR( "Property HasSecondaryYAxis not found in Diagram" );
+ }
+
+ // 3d attributes
+ try
+ {
+ aAny = xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Dim3D" )));
+ aAny >>= bIs3DChart;
+
+ if( bIs3DChart )
+ {
+ rShapeExport = mrExport.GetShapeExport();
+ if( rShapeExport.is())
+ rShapeExport->export3DSceneAttributes( xPropSet );
+ }
+ }
+ catch( uno::Exception & rEx )
+ {
+#ifdef DBG_UTIL
+ String aStr( rEx.Message );
+ ByteString aBStr( aStr, RTL_TEXTENCODING_ASCII_US );
+ DBG_ERROR1( "chart:exportPlotAreaException caught: %s", aBStr.GetBuffer());
+#else
+ (void)rEx; // avoid warning
+#endif
+ }
+ }
+
+ // plot-area element
+ pElPlotArea = new SvXMLElementExport( mrExport, XML_NAMESPACE_CHART, XML_PLOT_AREA, sal_True, sal_True );
+
+ //inner position rectangle element
+ exportCoordinateRegion( xDiagram );
+
+ // light sources (inside plot area element)
+ if( bIs3DChart &&
+ rShapeExport.is())
+ rShapeExport->export3DLamps( xPropSet );
+ }
+ else // autostyles
+ {
+ CollectAutoStyle( aPropertyStates );
+ }
+ // remove property states for autostyles
+ aPropertyStates.clear();
+
+ // axis elements
+ // -------------
+ exportAxes( xDiagram, xNewDiagram, bExportContent );
+
+ // series elements
+ // ---------------
+ exportSeries( xNewDiagram, rPageSize, bExportContent, bHasTwoYAxes );
+
+ // stock-chart elements
+ OUString sChartType ( xDiagram->getDiagramType());
+ if( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart.StockDiagram" )))
+ {
+ Reference< chart::XStatisticDisplay > xStockPropProvider( xDiagram, uno::UNO_QUERY );
+ if( xStockPropProvider.is())
+ {
+ // stock-gain-marker
+ Reference< beans::XPropertySet > xStockPropSet = xStockPropProvider->getUpBar();
+ if( xStockPropSet.is())
+ {
+ aPropertyStates.clear();
+ aPropertyStates = mxExpPropMapper->Filter( xStockPropSet );
+
+ if( !aPropertyStates.empty() )
+ {
+ if( bExportContent )
+ {
+ AddAutoStyleAttribute( aPropertyStates );
+
+ SvXMLElementExport aGain( mrExport, XML_NAMESPACE_CHART, XML_STOCK_GAIN_MARKER, sal_True, sal_True );
+ }
+ else
+ {
+ CollectAutoStyle( aPropertyStates );
+ }
+ }
+ }
+
+ // stock-loss-marker
+ xStockPropSet = xStockPropProvider->getDownBar();
+ if( xStockPropSet.is())
+ {
+ aPropertyStates.clear();
+ aPropertyStates = mxExpPropMapper->Filter( xStockPropSet );
+
+ if( !aPropertyStates.empty() )
+ {
+ if( bExportContent )
+ {
+ AddAutoStyleAttribute( aPropertyStates );
+
+ SvXMLElementExport aGain( mrExport, XML_NAMESPACE_CHART, XML_STOCK_LOSS_MARKER, sal_True, sal_True );
+ }
+ else
+ {
+ CollectAutoStyle( aPropertyStates );
+ }
+ }
+ }
+
+ // stock-range-line
+ xStockPropSet = xStockPropProvider->getMinMaxLine();
+ if( xStockPropSet.is())
+ {
+ aPropertyStates.clear();
+ aPropertyStates = mxExpPropMapper->Filter( xStockPropSet );
+
+ if( !aPropertyStates.empty() )
+ {
+ if( bExportContent )
+ {
+ AddAutoStyleAttribute( aPropertyStates );
+
+ SvXMLElementExport aGain( mrExport, XML_NAMESPACE_CHART, XML_STOCK_RANGE_LINE, sal_True, sal_True );
+ }
+ else
+ {
+ CollectAutoStyle( aPropertyStates );
+ }
+ }
+ }
+ }
+ }
+
+ // wall and floor element
+ // ----------------------
+
+ Reference< chart::X3DDisplay > xWallFloorSupplier( xDiagram, uno::UNO_QUERY );
+ if( mxExpPropMapper.is() &&
+ xWallFloorSupplier.is())
+ {
+ // remove property states for autostyles
+ aPropertyStates.clear();
+
+ Reference< beans::XPropertySet > xWallPropSet( xWallFloorSupplier->getWall(), uno::UNO_QUERY );
+ if( xWallPropSet.is())
+ {
+ aPropertyStates = mxExpPropMapper->Filter( xWallPropSet );
+
+ if( !aPropertyStates.empty() )
+ {
+ // write element
+ if( bExportContent )
+ {
+ // add style name attribute
+ AddAutoStyleAttribute( aPropertyStates );
+
+ SvXMLElementExport aWall( mrExport, XML_NAMESPACE_CHART, XML_WALL, sal_True, sal_True );
+ }
+ else // autostyles
+ {
+ CollectAutoStyle( aPropertyStates );
+ }
+ }
+ }
+
+ // floor element
+ // -------------
+
+ // remove property states for autostyles
+ aPropertyStates.clear();
+
+ Reference< beans::XPropertySet > xFloorPropSet( xWallFloorSupplier->getFloor(), uno::UNO_QUERY );
+ if( xFloorPropSet.is())
+ {
+ aPropertyStates = mxExpPropMapper->Filter( xFloorPropSet );
+
+ if( !aPropertyStates.empty() )
+ {
+ // write element
+ if( bExportContent )
+ {
+ // add style name attribute
+ AddAutoStyleAttribute( aPropertyStates );
+
+ SvXMLElementExport aFloor( mrExport, XML_NAMESPACE_CHART, XML_FLOOR, sal_True, sal_True );
+ }
+ else // autostyles
+ {
+ CollectAutoStyle( aPropertyStates );
+ }
+ }
+ }
+ }
+
+ if( pElPlotArea )
+ delete pElPlotArea;
+}
+
+void SchXMLExportHelper_Impl::exportCoordinateRegion( const uno::Reference< chart::XDiagram >& xDiagram )
+{
+ const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion( SvtSaveOptions().GetODFDefaultVersion() );
+ if( nCurrentODFVersion <= SvtSaveOptions::ODFVER_012 )//do not export to ODF 1.2 or older
+ return;
+ if( nCurrentODFVersion != SvtSaveOptions::ODFVER_LATEST )//export only if extensions are enabled //#i100778# todo: change this dependent on fileformat evolution
+ return;
+
+ Reference< chart::XDiagramPositioning > xDiaPos( xDiagram, uno::UNO_QUERY );
+ DBG_ASSERT( xDiaPos.is(), "Invalid xDiaPos as parameter" );
+ if( !xDiaPos.is() )
+ return;
+
+ awt::Rectangle aRect( xDiaPos->calculateDiagramPositionExcludingAxes() );
+ addPosition( awt::Point(aRect.X,aRect.Y) );
+ addSize( awt::Size(aRect.Width,aRect.Height) );
+
+ SvXMLElementExport aCoordinateRegion( mrExport, XML_NAMESPACE_CHART_EXT, XML_COORDINATE_REGION, sal_True, sal_True );//#i100778# todo: change to chart namespace in future - dependent on fileformat
+}
+
+void SchXMLExportHelper_Impl::exportAxes(
+ const Reference< chart::XDiagram > & xDiagram,
+ const Reference< chart2::XDiagram > & xNewDiagram,
+ sal_Bool bExportContent )
+{
+ DBG_ASSERT( xDiagram.is(), "Invalid XDiagram as parameter" );
+ if( ! xDiagram.is())
+ return;
+
+ // variables for autostyles
+ const OUString sNumFormat( OUString::createFromAscii( "NumberFormat" ));
+ Reference< beans::XPropertySet > xPropSet;
+ std::vector< XMLPropertyState > aPropertyStates;
+
+ OUString aASName;
+
+ // get some properties from document first
+ sal_Bool bHasXAxis = sal_False,
+ bHasYAxis = sal_False,
+ bHasZAxis = sal_False,
+ bHasSecondaryXAxis = sal_False,
+ bHasSecondaryYAxis = sal_False;
+ sal_Bool bHasXAxisTitle = sal_False,
+ bHasYAxisTitle = sal_False,
+ bHasZAxisTitle = sal_False,
+ bHasSecondaryXAxisTitle = sal_False,
+ bHasSecondaryYAxisTitle = sal_False;
+ sal_Bool bHasXAxisMajorGrid = sal_False,
+ bHasXAxisMinorGrid = sal_False,
+ bHasYAxisMajorGrid = sal_False,
+ bHasYAxisMinorGrid = sal_False,
+ bHasZAxisMajorGrid = sal_False,
+ bHasZAxisMinorGrid = sal_False;
+ sal_Bool bIs3DChart = sal_False;
+
+ // get multiple properties using XMultiPropertySet
+ MultiPropertySetHandler aDiagramProperties (xDiagram);
+
+ // Check for supported services and then the properties provided by this service.
+ Reference<lang::XServiceInfo> xServiceInfo (xDiagram, uno::UNO_QUERY);
+ if (xServiceInfo.is())
+ {
+ if (xServiceInfo->supportsService(
+ OUString::createFromAscii ("com.sun.star.chart.ChartAxisXSupplier")))
+ {
+ aDiagramProperties.Add (
+ OUString(RTL_CONSTASCII_USTRINGPARAM("HasXAxis")), bHasXAxis);
+ }
+ if (xServiceInfo->supportsService(
+ OUString::createFromAscii ("com.sun.star.chart.ChartAxisYSupplier")))
+ {
+ aDiagramProperties.Add (
+ OUString(RTL_CONSTASCII_USTRINGPARAM("HasYAxis")), bHasYAxis);
+ }
+ if (xServiceInfo->supportsService(
+ OUString::createFromAscii ("com.sun.star.chart.ChartAxisZSupplier")))
+ {
+ aDiagramProperties.Add (
+ OUString(RTL_CONSTASCII_USTRINGPARAM("HasZAxis")), bHasZAxis);
+ }
+ if (xServiceInfo->supportsService(
+ OUString::createFromAscii ("com.sun.star.chart.ChartTwoAxisXSupplier")))
+ {
+ aDiagramProperties.Add (
+ OUString(RTL_CONSTASCII_USTRINGPARAM("HasSecondaryXAxis")), bHasSecondaryXAxis);
+ }
+ if (xServiceInfo->supportsService(
+ OUString::createFromAscii ("com.sun.star.chart.ChartTwoAxisYSupplier")))
+ {
+ aDiagramProperties.Add (
+ OUString(RTL_CONSTASCII_USTRINGPARAM("HasSecondaryYAxis")), bHasSecondaryYAxis);
+ }
+ }
+
+ aDiagramProperties.Add (
+ OUString (RTL_CONSTASCII_USTRINGPARAM ("HasXAxisTitle")), bHasXAxisTitle);
+ aDiagramProperties.Add (
+ OUString (RTL_CONSTASCII_USTRINGPARAM ("HasYAxisTitle")), bHasYAxisTitle);
+ aDiagramProperties.Add (
+ OUString (RTL_CONSTASCII_USTRINGPARAM ("HasZAxisTitle")), bHasZAxisTitle);
+ aDiagramProperties.Add (
+ OUString (RTL_CONSTASCII_USTRINGPARAM ("HasSecondaryXAxisTitle")), bHasSecondaryXAxisTitle);
+ aDiagramProperties.Add (
+ OUString (RTL_CONSTASCII_USTRINGPARAM ("HasSecondaryYAxisTitle")), bHasSecondaryYAxisTitle);
+
+ aDiagramProperties.Add (
+ OUString (RTL_CONSTASCII_USTRINGPARAM ("HasXAxisGrid")), bHasXAxisMajorGrid);
+ aDiagramProperties.Add (
+ OUString (RTL_CONSTASCII_USTRINGPARAM ("HasYAxisGrid")), bHasYAxisMajorGrid);
+ aDiagramProperties.Add (
+ OUString (RTL_CONSTASCII_USTRINGPARAM ("HasZAxisGrid")), bHasZAxisMajorGrid);
+
+ aDiagramProperties.Add (
+ OUString (RTL_CONSTASCII_USTRINGPARAM ("HasXAxisHelpGrid")), bHasXAxisMinorGrid);
+ aDiagramProperties.Add (
+ OUString (RTL_CONSTASCII_USTRINGPARAM ("HasYAxisHelpGrid")), bHasYAxisMinorGrid);
+ aDiagramProperties.Add (
+ OUString (RTL_CONSTASCII_USTRINGPARAM ("HasZAxisHelpGrid")), bHasZAxisMinorGrid);
+
+ aDiagramProperties.Add(
+ OUString (RTL_CONSTASCII_USTRINGPARAM ("Dim3D")), bIs3DChart);
+
+ if ( ! aDiagramProperties.GetProperties ())
+ {
+ DBG_WARNING ("Required properties not found in Chart diagram");
+ }
+
+ SvXMLElementExport* pAxis = NULL;
+
+ // x axis
+ // -------
+
+ // write axis element also if the axis itself is not visible, but a grid or
+ // title
+ Reference< chart::XAxisXSupplier > xAxisXSupp( xDiagram, uno::UNO_QUERY );
+ if( xAxisXSupp.is())
+ {
+ bool bHasAxisProperties = false;
+ // get property states for autostyles
+ if( mxExpPropMapper.is())
+ {
+ xPropSet = xAxisXSupp->getXAxis();
+ if( xPropSet.is())
+ {
+ bHasAxisProperties = true;
+ lcl_exportNumberFormat( sNumFormat, xPropSet, mrExport );
+ aPropertyStates = mxExpPropMapper->Filter( xPropSet );
+ }
+ }
+
+ if( bHasXAxis ||
+ bHasXAxisTitle || bHasXAxisMajorGrid || bHasXAxisMinorGrid ||
+ mbHasCategoryLabels || bHasAxisProperties )
+ {
+ if( bExportContent )
+ {
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_DIMENSION, XML_X );
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_NAME, XML_PRIMARY_X );
+
+ // write style name
+ AddAutoStyleAttribute( aPropertyStates );
+
+ // element
+ pAxis = new SvXMLElementExport( mrExport, XML_NAMESPACE_CHART, XML_AXIS, sal_True, sal_True );
+ }
+ else // autostyles
+ {
+ CollectAutoStyle( aPropertyStates );
+ }
+ aPropertyStates.clear();
+
+ // axis-title
+ if( bHasXAxisTitle )
+ {
+ Reference< beans::XPropertySet > xTitleProp( xAxisXSupp->getXAxisTitle(), uno::UNO_QUERY );
+ if( xTitleProp.is())
+ {
+ aPropertyStates = mxExpPropMapper->Filter( xTitleProp );
+ if( bExportContent )
+ {
+ OUString aText;
+ Any aAny( xTitleProp->getPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "String" ))));
+ aAny >>= aText;
+
+ Reference< drawing::XShape > xShape( xTitleProp, uno::UNO_QUERY );
+ if( xShape.is())
+ addPosition( xShape );
+
+ AddAutoStyleAttribute( aPropertyStates );
+ SvXMLElementExport aTitle( mrExport, XML_NAMESPACE_CHART, XML_TITLE, sal_True, sal_True );
+
+ // paragraph containing title
+ exportText( aText );
+ }
+ else
+ {
+ CollectAutoStyle( aPropertyStates );
+ }
+ aPropertyStates.clear();
+ }
+ }
+
+ // categories if we have a categories chart
+ if( bExportContent &&
+ mbHasCategoryLabels )
+ {
+ OUString aCategoriesRange;
+ // fill msString with cell-range-address of categories
+ // export own table references
+ if( xNewDiagram.is())
+ {
+ Reference< chart2::data::XLabeledDataSequence > xCategories( lcl_getCategories( xNewDiagram ) );
+ if( xCategories.is() )
+ {
+ Reference< chart2::data::XDataSequence > xValues( xCategories->getValues() );
+ if( xValues.is())
+ {
+ Reference< chart2::XChartDocument > xNewDoc( mrExport.GetModel(), uno::UNO_QUERY );
+ maCategoriesRange = xValues->getSourceRangeRepresentation();
+ aCategoriesRange = lcl_ConvertRange( maCategoriesRange, xNewDoc );
+ }
+ }
+ }
+
+ if( aCategoriesRange.getLength())
+ mrExport.AddAttribute( XML_NAMESPACE_TABLE, XML_CELL_RANGE_ADDRESS, aCategoriesRange );
+ SvXMLElementExport aCategories( mrExport, XML_NAMESPACE_CHART, XML_CATEGORIES, sal_True, sal_True );
+ }
+
+ // grid
+ Reference< beans::XPropertySet > xMajorGrid( xAxisXSupp->getXMainGrid(), uno::UNO_QUERY );
+ if( bHasXAxisMajorGrid && xMajorGrid.is())
+ {
+ aPropertyStates = mxExpPropMapper->Filter( xMajorGrid );
+ if( bExportContent )
+ {
+ AddAutoStyleAttribute( aPropertyStates );
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_CLASS, XML_MAJOR );
+ SvXMLElementExport aGrid( mrExport, XML_NAMESPACE_CHART, XML_GRID, sal_True, sal_True );
+ }
+ else
+ {
+ CollectAutoStyle( aPropertyStates );
+ }
+ aPropertyStates.clear();
+ }
+ Reference< beans::XPropertySet > xMinorGrid( xAxisXSupp->getXHelpGrid(), uno::UNO_QUERY );
+ if( bHasXAxisMinorGrid && xMinorGrid.is())
+ {
+ aPropertyStates = mxExpPropMapper->Filter( xMinorGrid );
+ if( bExportContent )
+ {
+ AddAutoStyleAttribute( aPropertyStates );
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_CLASS, XML_MINOR );
+ SvXMLElementExport aGrid( mrExport, XML_NAMESPACE_CHART, XML_GRID, sal_True, sal_True );
+ }
+ else
+ {
+ CollectAutoStyle( aPropertyStates );
+ }
+ aPropertyStates.clear();
+ }
+ if( pAxis )
+ {
+ delete pAxis;
+ pAxis = NULL;
+ }
+ }
+ }
+
+ // secondary x axis
+ if( bHasSecondaryXAxis || bHasSecondaryXAxisTitle )
+ {
+ Reference< chart::XTwoAxisXSupplier > xAxisTwoXSupp( xDiagram, uno::UNO_QUERY );
+ if( xAxisTwoXSupp.is())
+ {
+ // get property states for autostyles
+ if( mxExpPropMapper.is())
+ {
+ xPropSet = xAxisTwoXSupp->getSecondaryXAxis();
+ lcl_exportNumberFormat( sNumFormat, xPropSet, mrExport );
+ if( xPropSet.is())
+ aPropertyStates = mxExpPropMapper->Filter( xPropSet );
+ }
+ if( bExportContent )
+ {
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_DIMENSION, XML_X );
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_NAME, XML_SECONDARY_X );
+ AddAutoStyleAttribute( aPropertyStates );
+ pAxis = new SvXMLElementExport( mrExport, XML_NAMESPACE_CHART, XML_AXIS, sal_True, sal_True );
+ }
+ else // autostyles
+ {
+ CollectAutoStyle( aPropertyStates );
+ }
+ aPropertyStates.clear();
+
+ if( bHasSecondaryXAxisTitle )
+ {
+ Reference< chart::XSecondAxisTitleSupplier > xAxisSupp( xDiagram, uno::UNO_QUERY );
+ Reference< beans::XPropertySet > xTitleProp( xAxisSupp->getSecondXAxisTitle(), uno::UNO_QUERY );
+ if( xTitleProp.is())
+ {
+ aPropertyStates = mxExpPropMapper->Filter( xTitleProp );
+ if( bExportContent )
+ {
+ OUString aText;
+ Any aAny( xTitleProp->getPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "String" ))));
+ aAny >>= aText;
+
+ Reference< drawing::XShape > xShape( xTitleProp, uno::UNO_QUERY );
+ if( xShape.is())
+ addPosition( xShape );
+
+ AddAutoStyleAttribute( aPropertyStates );
+ SvXMLElementExport aTitle( mrExport, XML_NAMESPACE_CHART, XML_TITLE, sal_True, sal_True );
+
+ exportText( aText );
+ }
+ else
+ {
+ CollectAutoStyle( aPropertyStates );
+ }
+ aPropertyStates.clear();
+ }
+ }
+
+ if( pAxis )
+ {
+ delete pAxis;
+ pAxis = NULL;
+ }
+ }
+ }
+
+ // y axis
+ // -------
+
+ // write axis element also if the axis itself is not visible, but a grid or
+ // title
+ Reference< chart::XAxisYSupplier > xAxisYSupp( xDiagram, uno::UNO_QUERY );
+ if( xAxisYSupp.is())
+ {
+ bool bHasAxisProperties = false;
+ // get property states for autostyles
+ if( mxExpPropMapper.is())
+ {
+ xPropSet = xAxisYSupp->getYAxis();
+ if( xPropSet.is())
+ {
+ bHasAxisProperties = true;
+ lcl_exportNumberFormat( sNumFormat, xPropSet, mrExport );
+ aPropertyStates = mxExpPropMapper->Filter( xPropSet );
+ }
+ }
+
+ if( bHasYAxis ||
+ bHasYAxisTitle || bHasYAxisMajorGrid || bHasYAxisMinorGrid || bHasAxisProperties )
+ {
+ if( bExportContent )
+ {
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_DIMENSION, XML_Y );
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_NAME, XML_PRIMARY_Y );
+ AddAutoStyleAttribute( aPropertyStates );
+ pAxis = new SvXMLElementExport( mrExport, XML_NAMESPACE_CHART, XML_AXIS, sal_True, sal_True );
+ }
+ else
+ {
+ CollectAutoStyle( aPropertyStates );
+ }
+ aPropertyStates.clear();
+
+ // axis-title
+ if( bHasYAxisTitle )
+ {
+ Reference< beans::XPropertySet > xTitleProp( xAxisYSupp->getYAxisTitle(), uno::UNO_QUERY );
+ if( xTitleProp.is())
+ {
+ aPropertyStates = mxExpPropMapper->Filter( xTitleProp );
+ if( bExportContent )
+ {
+ OUString aText;
+ Any aAny( xTitleProp->getPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "String" ))));
+ aAny >>= aText;
+
+ Reference< drawing::XShape > xShape( xTitleProp, uno::UNO_QUERY );
+ if( xShape.is())
+ addPosition( xShape );
+
+ AddAutoStyleAttribute( aPropertyStates );
+ SvXMLElementExport aTitle( mrExport, XML_NAMESPACE_CHART, XML_TITLE, sal_True, sal_True );
+
+ // paragraph containing title
+ exportText( aText );
+ }
+ else
+ {
+ CollectAutoStyle( aPropertyStates );
+ }
+ aPropertyStates.clear();
+ }
+ }
+
+ // grid
+ Reference< beans::XPropertySet > xMajorGrid( xAxisYSupp->getYMainGrid(), uno::UNO_QUERY );
+ if( bHasYAxisMajorGrid && xMajorGrid.is())
+ {
+ aPropertyStates = mxExpPropMapper->Filter( xMajorGrid );
+
+ if( bExportContent )
+ {
+ AddAutoStyleAttribute( aPropertyStates );
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_CLASS, XML_MAJOR );
+ SvXMLElementExport aGrid( mrExport, XML_NAMESPACE_CHART, XML_GRID, sal_True, sal_True );
+ }
+ else
+ {
+ CollectAutoStyle( aPropertyStates );
+ }
+ aPropertyStates.clear();
+ }
+ // minor grid
+ Reference< beans::XPropertySet > xMinorGrid( xAxisYSupp->getYHelpGrid(), uno::UNO_QUERY );
+ if( bHasYAxisMinorGrid && xMinorGrid.is())
+ {
+ aPropertyStates = mxExpPropMapper->Filter( xMinorGrid );
+
+ if( bExportContent )
+ {
+ AddAutoStyleAttribute( aPropertyStates );
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_CLASS, XML_MINOR );
+ SvXMLElementExport aGrid( mrExport, XML_NAMESPACE_CHART, XML_GRID, sal_True, sal_True );
+ }
+ else
+ {
+ CollectAutoStyle( aPropertyStates );
+ }
+ aPropertyStates.clear();
+ }
+ if( pAxis )
+ {
+ delete pAxis;
+ pAxis = NULL;
+ }
+ }
+ }
+
+ if( bHasSecondaryYAxis || bHasSecondaryYAxisTitle )
+ {
+ Reference< chart::XTwoAxisYSupplier > xAxisTwoYSupp( xDiagram, uno::UNO_QUERY );
+ if( xAxisTwoYSupp.is())
+ {
+ // get property states for autostyles
+ if( mxExpPropMapper.is())
+ {
+ xPropSet = xAxisTwoYSupp->getSecondaryYAxis();
+ lcl_exportNumberFormat( sNumFormat, xPropSet, mrExport );
+ if( xPropSet.is())
+ aPropertyStates = mxExpPropMapper->Filter( xPropSet );
+ }
+ if( bExportContent )
+ {
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_DIMENSION, XML_Y );
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_NAME, XML_SECONDARY_Y );
+ AddAutoStyleAttribute( aPropertyStates );
+ pAxis = new SvXMLElementExport( mrExport, XML_NAMESPACE_CHART, XML_AXIS, sal_True, sal_True );
+ }
+ else // autostyles
+ {
+ CollectAutoStyle( aPropertyStates );
+ }
+ aPropertyStates.clear();
+ if( bHasSecondaryYAxisTitle )
+ {
+ Reference< chart::XSecondAxisTitleSupplier > xAxisSupp( xDiagram, uno::UNO_QUERY );
+ Reference< beans::XPropertySet > xTitleProp( xAxisSupp->getSecondYAxisTitle(), uno::UNO_QUERY );
+ if( xTitleProp.is())
+ {
+ aPropertyStates = mxExpPropMapper->Filter( xTitleProp );
+ if( bExportContent )
+ {
+ OUString aText;
+ Any aAny( xTitleProp->getPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "String" ))));
+ aAny >>= aText;
+
+ Reference< drawing::XShape > xShape( xTitleProp, uno::UNO_QUERY );
+ if( xShape.is())
+ addPosition( xShape );
+
+ AddAutoStyleAttribute( aPropertyStates );
+ SvXMLElementExport aTitle( mrExport, XML_NAMESPACE_CHART, XML_TITLE, sal_True, sal_True );
+
+ exportText( aText );
+ }
+ else
+ {
+ CollectAutoStyle( aPropertyStates );
+ }
+ aPropertyStates.clear();
+ }
+ }
+
+ if( pAxis )
+ {
+ delete pAxis;
+ pAxis = NULL;
+ }
+ }
+ }
+
+ // z axis
+ // -------
+
+ if( bHasZAxis &&
+ bIs3DChart )
+ {
+ Reference< chart::XAxisZSupplier > xAxisZSupp( xDiagram, uno::UNO_QUERY );
+ if( xAxisZSupp.is())
+ {
+ // get property states for autostyles
+ if( mxExpPropMapper.is())
+ {
+ xPropSet = xAxisZSupp->getZAxis();
+ lcl_exportNumberFormat( sNumFormat, xPropSet, mrExport );
+ if( xPropSet.is())
+ aPropertyStates = mxExpPropMapper->Filter( xPropSet );
+ }
+ if( bExportContent )
+ {
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_DIMENSION, XML_Z );
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_NAME, XML_PRIMARY_Z );
+
+ AddAutoStyleAttribute( aPropertyStates );
+ pAxis = new SvXMLElementExport( mrExport, XML_NAMESPACE_CHART, XML_AXIS, sal_True, sal_True );
+ }
+ else
+ {
+ CollectAutoStyle( aPropertyStates );
+ }
+ aPropertyStates.clear();
+
+ // axis-title
+ if( bHasZAxisTitle )
+ {
+ Reference< beans::XPropertySet > xTitleProp( xAxisZSupp->getZAxisTitle(), uno::UNO_QUERY );
+ if( xTitleProp.is())
+ {
+ aPropertyStates = mxExpPropMapper->Filter( xTitleProp );
+ if( bExportContent )
+ {
+ OUString aText;
+ Any aAny( xTitleProp->getPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "String" ))));
+ aAny >>= aText;
+
+ Reference< drawing::XShape > xShape( xTitleProp, uno::UNO_QUERY );
+ if( xShape.is())
+ addPosition( xShape );
+
+ AddAutoStyleAttribute( aPropertyStates );
+ SvXMLElementExport aTitle( mrExport, XML_NAMESPACE_CHART, XML_TITLE, sal_True, sal_True );
+
+ // paragraph containing title
+ exportText( aText );
+ }
+ else
+ {
+ CollectAutoStyle( aPropertyStates );
+ }
+ aPropertyStates.clear();
+ }
+ }
+
+ // grid
+ Reference< beans::XPropertySet > xMajorGrid( xAxisZSupp->getZMainGrid(), uno::UNO_QUERY );
+ if( bHasZAxisMajorGrid && xMajorGrid.is())
+ {
+ aPropertyStates = mxExpPropMapper->Filter( xMajorGrid );
+
+ if( bExportContent )
+ {
+ AddAutoStyleAttribute( aPropertyStates );
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_CLASS, XML_MAJOR );
+ SvXMLElementExport aGrid( mrExport, XML_NAMESPACE_CHART, XML_GRID, sal_True, sal_True );
+ }
+ else
+ {
+ CollectAutoStyle( aPropertyStates );
+ }
+ aPropertyStates.clear();
+ }
+ // minor grid
+ Reference< beans::XPropertySet > xMinorGrid( xAxisZSupp->getZHelpGrid(), uno::UNO_QUERY );
+ if( bHasZAxisMinorGrid && xMinorGrid.is())
+ {
+ aPropertyStates = mxExpPropMapper->Filter( xMinorGrid );
+
+ if( bExportContent )
+ {
+ AddAutoStyleAttribute( aPropertyStates );
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_CLASS, XML_MINOR );
+ SvXMLElementExport aGrid( mrExport, XML_NAMESPACE_CHART, XML_GRID, sal_True, sal_True );
+ }
+ else
+ {
+ CollectAutoStyle( aPropertyStates );
+ }
+ aPropertyStates.clear();
+ }
+ }
+ if( pAxis )
+ {
+ delete pAxis;
+ pAxis = NULL;
+ }
+ }
+}
+
+void SchXMLExportHelper_Impl::exportSeries(
+ const Reference< chart2::XDiagram > & xNewDiagram,
+ const awt::Size & rPageSize,
+ sal_Bool bExportContent,
+ sal_Bool bHasTwoYAxes )
+{
+ Reference< chart2::XCoordinateSystemContainer > xBCooSysCnt( xNewDiagram, uno::UNO_QUERY );
+ if( ! xBCooSysCnt.is())
+ return;
+ Reference< chart2::XChartDocument > xNewDoc( mrExport.GetModel(), uno::UNO_QUERY );
+
+ OUString aFirstXDomainRange;
+ OUString aFirstYDomainRange;
+
+ std::vector< XMLPropertyState > aPropertyStates;
+
+ const OUString sNumFormat( OUString::createFromAscii( "NumberFormat" ));
+ const OUString sPercentageNumFormat( OUString::createFromAscii( "PercentageNumberFormat" ));
+
+ Sequence< Reference< chart2::XCoordinateSystem > >
+ aCooSysSeq( xBCooSysCnt->getCoordinateSystems());
+ for( sal_Int32 nCSIdx=0; nCSIdx<aCooSysSeq.getLength(); ++nCSIdx )
+ {
+ Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[nCSIdx], uno::UNO_QUERY );
+ if( ! xCTCnt.is())
+ continue;
+ Sequence< Reference< chart2::XChartType > > aCTSeq( xCTCnt->getChartTypes());
+ for( sal_Int32 nCTIdx=0; nCTIdx<aCTSeq.getLength(); ++nCTIdx )
+ {
+ Reference< chart2::XDataSeriesContainer > xDSCnt( aCTSeq[nCTIdx], uno::UNO_QUERY );
+ if( ! xDSCnt.is())
+ continue;
+ // note: if xDSCnt.is() then also aCTSeq[nCTIdx]
+ OUString aChartType( aCTSeq[nCTIdx]->getChartType());
+ OUString aLabelRole = aCTSeq[nCTIdx]->getRoleOfSequenceForSeriesLabel();
+
+ // special export for stock charts
+ if( aChartType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.CandleStickChartType")))
+ {
+ sal_Bool bJapaneseCandleSticks = sal_False;
+ Reference< beans::XPropertySet > xCTProp( aCTSeq[nCTIdx], uno::UNO_QUERY );
+ if( xCTProp.is())
+ xCTProp->getPropertyValue( OUString::createFromAscii("Japanese")) >>= bJapaneseCandleSticks;
+ exportCandleStickSeries(
+ xDSCnt->getDataSeries(), xNewDiagram, bJapaneseCandleSticks, bExportContent );
+ continue;
+ }
+
+ // export dataseries for current chart-type
+ Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xDSCnt->getDataSeries());
+ for( sal_Int32 nSeriesIdx=0; nSeriesIdx<aSeriesSeq.getLength(); ++nSeriesIdx )
+ {
+ // export series
+ Reference< chart2::data::XDataSource > xSource( aSeriesSeq[nSeriesIdx], uno::UNO_QUERY );
+ if( xSource.is())
+ {
+ SvXMLElementExport* pSeries = NULL;
+ Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeqCnt(
+ xSource->getDataSequences());
+ sal_Int32 nMainSequenceIndex = -1;
+ sal_Int32 nSeriesLength = 0;
+ sal_Int32 nAttachedAxis = chart::ChartAxisAssign::PRIMARY_Y;
+ sal_Bool bHasMeanValueLine = false;
+ chart::ChartRegressionCurveType eRegressionType( chart::ChartRegressionCurveType_NONE );
+ chart::ChartErrorIndicatorType eErrorType( chart::ChartErrorIndicatorType_NONE );
+ sal_Int32 nErrorBarStyle( chart::ErrorBarStyle::NONE );
+ Reference< beans::XPropertySet > xPropSet;
+ tLabelValuesDataPair aSeriesLabelValuesPair;
+
+ // search for main sequence and create a series element
+ {
+ Reference< chart2::data::XDataSequence > xValuesSeq;
+ Reference< chart2::data::XDataSequence > xLabelSeq;
+ sal_Int32 nSeqIdx=0;
+ for( ; nSeqIdx<aSeqCnt.getLength(); ++nSeqIdx )
+ {
+ OUString aRole;
+ Reference< chart2::data::XDataSequence > xTempValueSeq( aSeqCnt[nSeqIdx]->getValues() );
+ if( nMainSequenceIndex==-1 )
+ {
+ Reference< beans::XPropertySet > xSeqProp( xTempValueSeq, uno::UNO_QUERY );
+ if( xSeqProp.is())
+ xSeqProp->getPropertyValue(OUString::createFromAscii("Role")) >>= aRole;
+ // "main" sequence
+ if( aRole.equals( aLabelRole ))
+ {
+ xValuesSeq.set( xTempValueSeq );
+ xLabelSeq.set( aSeqCnt[nSeqIdx]->getLabel());
+ nMainSequenceIndex = nSeqIdx;
+ }
+ }
+ sal_Int32 nSequenceLength = (xTempValueSeq.is()? xTempValueSeq->getData().getLength() : sal_Int32(0));
+ if( nSeriesLength < nSequenceLength )
+ nSeriesLength = nSequenceLength;
+ }
+
+ // have found the main sequence, then xValuesSeq and
+ // xLabelSeq contain those. Otherwise both are empty
+ {
+ // get property states for autostyles
+ try
+ {
+ xPropSet = SchXMLSeriesHelper::createOldAPISeriesPropertySet(
+ aSeriesSeq[nSeriesIdx], mrExport.GetModel() );
+ }
+ catch( uno::Exception & rEx )
+ {
+ (void)rEx; // avoid warning for pro build
+ OSL_TRACE(
+ OUStringToOString(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "Series not found or no XPropertySet: " )) +
+ rEx.Message,
+ RTL_TEXTENCODING_ASCII_US ).getStr());
+ continue;
+ }
+ if( xPropSet.is())
+ {
+ // determine attached axis
+ try
+ {
+ Any aAny( xPropSet->getPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "Axis" ))));
+ aAny >>= nAttachedAxis;
+
+ aAny = xPropSet->getPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM ( "MeanValue" )));
+ aAny >>= bHasMeanValueLine;
+
+ aAny = xPropSet->getPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "RegressionCurves" )));
+ aAny >>= eRegressionType;
+
+ aAny = xPropSet->getPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "ErrorIndicator" )));
+ aAny >>= eErrorType;
+
+ aAny = xPropSet->getPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "ErrorBarStyle" )));
+ aAny >>= nErrorBarStyle;
+ }
+ catch( beans::UnknownPropertyException & rEx )
+ {
+ (void)rEx; // avoid warning for pro build
+ OSL_TRACE(
+ OUStringToOString(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "Required property not found in DataRowProperties: " )) +
+ rEx.Message,
+ RTL_TEXTENCODING_ASCII_US ).getStr());
+ }
+
+ const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion( SvtSaveOptions().GetODFDefaultVersion() );
+ if( nCurrentODFVersion >= SvtSaveOptions::ODFVER_012 )
+ {
+ lcl_exportNumberFormat( sNumFormat, xPropSet, mrExport );
+ lcl_exportNumberFormat( sPercentageNumFormat, xPropSet, mrExport );
+ }
+
+ if( mxExpPropMapper.is())
+ aPropertyStates = mxExpPropMapper->Filter( xPropSet );
+ }
+
+ if( bExportContent )
+ {
+ if( bHasTwoYAxes )
+ {
+ if( nAttachedAxis == chart::ChartAxisAssign::SECONDARY_Y )
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_ATTACHED_AXIS, XML_SECONDARY_Y );
+ else
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_ATTACHED_AXIS, XML_PRIMARY_Y );
+ }
+
+ // write style name
+ AddAutoStyleAttribute( aPropertyStates );
+
+ if( xValuesSeq.is())
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_VALUES_CELL_RANGE_ADDRESS,
+ lcl_ConvertRange(
+ xValuesSeq->getSourceRangeRepresentation(),
+ xNewDoc ));
+ else
+ // #i75297# allow empty series, export empty range to have all ranges on import
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_VALUES_CELL_RANGE_ADDRESS, OUString());
+
+ if( xLabelSeq.is())
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_LABEL_CELL_ADDRESS,
+ lcl_ConvertRange(
+ xLabelSeq->getSourceRangeRepresentation(),
+ xNewDoc ));
+ if( xLabelSeq.is() || xValuesSeq.is() )
+ aSeriesLabelValuesPair = tLabelValuesDataPair( xLabelSeq, xValuesSeq );
+
+ // chart-type for mixed types
+ enum XMLTokenEnum eCTToken(
+ SchXMLTools::getTokenByChartType( aChartType, false /* bUseOldNames */ ));
+ //@todo: get token for current charttype
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_CLASS,
+ mrExport.GetNamespaceMap().GetQNameByKey(
+ XML_NAMESPACE_CHART, GetXMLToken( eCTToken )));
+
+ // open series element until end of for loop
+ pSeries = new SvXMLElementExport( mrExport, XML_NAMESPACE_CHART, XML_SERIES, sal_True, sal_True );
+ }
+ else // autostyles
+ {
+ CollectAutoStyle( aPropertyStates );
+ }
+ // remove property states for autostyles
+ aPropertyStates.clear();
+ }
+ }
+
+ // export domain elements if we have a series parent element
+ if( pSeries )
+ {
+ // domain elements
+ if( bExportContent )
+ {
+ bool bIsScatterChart = aChartType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.ScatterChartType"));
+ bool bIsBubbleChart = aChartType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.BubbleChartType"));
+ Reference< chart2::data::XDataSequence > xYValuesForBubbleChart;
+ if( bIsBubbleChart )
+ {
+ Reference< chart2::data::XLabeledDataSequence > xSequence( lcl_getDataSequenceByRole( aSeqCnt, OUString::createFromAscii("values-y" ) ) );
+ if( xSequence.is() )
+ {
+ xYValuesForBubbleChart = xSequence->getValues();
+ if( !lcl_exportDomainForThisSequence( xYValuesForBubbleChart, aFirstYDomainRange, mrExport ) )
+ xYValuesForBubbleChart = 0;
+ }
+ }
+ if( bIsScatterChart || bIsBubbleChart )
+ {
+ Reference< chart2::data::XLabeledDataSequence > xSequence( lcl_getDataSequenceByRole( aSeqCnt, OUString::createFromAscii("values-x" ) ) );
+ if( xSequence.is() )
+ {
+ Reference< chart2::data::XDataSequence > xValues( xSequence->getValues() );
+ if( lcl_exportDomainForThisSequence( xValues, aFirstXDomainRange, mrExport ) )
+ m_aDataSequencesToExport.push_back( tLabelValuesDataPair( 0, xValues ));
+ }
+ }
+ if( xYValuesForBubbleChart.is() )
+ m_aDataSequencesToExport.push_back( tLabelValuesDataPair( 0, xYValuesForBubbleChart ));
+ }
+ }
+
+ // add sequences for main sequence after domain sequences,
+ // so that the export of the local table has the correct order
+ if( bExportContent &&
+ (aSeriesLabelValuesPair.first.is() || aSeriesLabelValuesPair.second.is()))
+ m_aDataSequencesToExport.push_back( aSeriesLabelValuesPair );
+
+ // statistical objects:
+ // regression curves and mean value lines
+ if( bHasMeanValueLine &&
+ xPropSet.is() &&
+ mxExpPropMapper.is() )
+ {
+ Reference< beans::XPropertySet > xStatProp;
+ try
+ {
+ Any aPropAny( xPropSet->getPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "DataMeanValueProperties" ))));
+ aPropAny >>= xStatProp;
+ }
+ catch( uno::Exception & rEx )
+ {
+ (void)rEx; // avoid warning for pro build
+ DBG_ERROR1( "Exception caught during Export of series - optional DataMeanValueProperties not available: %s",
+ OUStringToOString( rEx.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
+ }
+
+ if( xStatProp.is() )
+ {
+ aPropertyStates = mxExpPropMapper->Filter( xStatProp );
+
+ if( !aPropertyStates.empty() )
+ {
+ // write element
+ if( bExportContent )
+ {
+ // add style name attribute
+ AddAutoStyleAttribute( aPropertyStates );
+
+ SvXMLElementExport( mrExport, XML_NAMESPACE_CHART, XML_MEAN_VALUE, sal_True, sal_True );
+ }
+ else // autostyles
+ {
+ CollectAutoStyle( aPropertyStates );
+ }
+ }
+ }
+ }
+
+ if( eRegressionType != chart::ChartRegressionCurveType_NONE &&
+ xPropSet.is() &&
+ mxExpPropMapper.is() )
+ {
+ exportRegressionCurve( aSeriesSeq[nSeriesIdx], xPropSet, rPageSize, bExportContent );
+ }
+
+ if( nErrorBarStyle != chart::ErrorBarStyle::NONE &&
+ eErrorType != chart::ChartErrorIndicatorType_NONE &&
+ xPropSet.is() &&
+ mxExpPropMapper.is() )
+ {
+ Reference< beans::XPropertySet > xStatProp;
+ try
+ {
+ Any aPropAny( xPropSet->getPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "DataErrorProperties" ))));
+ aPropAny >>= xStatProp;
+ }
+ catch( uno::Exception & rEx )
+ {
+ (void)rEx; // avoid warning for pro build
+ DBG_ERROR1( "Exception caught during Export of series - optional DataErrorProperties not available: %s",
+ OUStringToOString( rEx.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
+ }
+
+ if( xStatProp.is() )
+ {
+ if( bExportContent &&
+ nErrorBarStyle == chart::ErrorBarStyle::FROM_DATA )
+ {
+ // register data ranges for error bars for export in local table
+ ::std::vector< Reference< chart2::data::XDataSequence > > aErrorBarSequences(
+ lcl_getErrorBarSequences( xStatProp ));
+ for( ::std::vector< Reference< chart2::data::XDataSequence > >::const_iterator aIt(
+ aErrorBarSequences.begin()); aIt != aErrorBarSequences.end(); ++aIt )
+ {
+ m_aDataSequencesToExport.push_back( tLabelValuesDataPair( 0, *aIt ));
+ }
+ }
+
+ aPropertyStates = mxExpPropMapper->Filter( xStatProp );
+
+ if( !aPropertyStates.empty() )
+ {
+ // write element
+ if( bExportContent )
+ {
+ // add style name attribute
+ AddAutoStyleAttribute( aPropertyStates );
+
+ const SvtSaveOptions::ODFDefaultVersion nCurrentVersion( SvtSaveOptions().GetODFDefaultVersion() );
+ if( nCurrentVersion >= SvtSaveOptions::ODFVER_012 )
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_DIMENSION, XML_Y );//#i114149#
+ SvXMLElementExport( mrExport, XML_NAMESPACE_CHART, XML_ERROR_INDICATOR, sal_True, sal_True );
+ }
+ else // autostyles
+ {
+ CollectAutoStyle( aPropertyStates );
+ }
+ }
+ }
+ }
+
+ exportDataPoints(
+ uno::Reference< beans::XPropertySet >( aSeriesSeq[nSeriesIdx], uno::UNO_QUERY ),
+ nSeriesLength, xNewDiagram, bExportContent );
+
+ // close series element
+ if( pSeries )
+ delete pSeries;
+ }
+ }
+ aPropertyStates.clear();
+ }
+ }
+}
+
+void SchXMLExportHelper_Impl::exportRegressionCurve(
+ const Reference< chart2::XDataSeries > & xSeries,
+ const Reference< beans::XPropertySet > & xSeriesProp,
+ const awt::Size & rPageSize,
+ sal_Bool bExportContent )
+{
+ OSL_ASSERT( mxExpPropMapper.is());
+
+ std::vector< XMLPropertyState > aPropertyStates;
+ std::vector< XMLPropertyState > aEquationPropertyStates;
+ Reference< beans::XPropertySet > xStatProp;
+ try
+ {
+ Any aPropAny( xSeriesProp->getPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "DataRegressionProperties" ))));
+ aPropAny >>= xStatProp;
+ }
+ catch( uno::Exception & rEx )
+ {
+ (void)rEx; // avoid warning for pro build
+ DBG_ERROR1( "Exception caught during Export of series - optional DataRegressionProperties not available: %s",
+ OUStringToOString( rEx.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
+ }
+
+ if( xStatProp.is() )
+ {
+ Reference< chart2::XRegressionCurve > xRegCurve( SchXMLTools::getRegressionCurve( xSeries ));
+ Reference< beans::XPropertySet > xEquationProperties;
+ if( xRegCurve.is())
+ xEquationProperties.set( xRegCurve->getEquationProperties());
+
+ bool bShowEquation = false;
+ bool bShowRSquared = false;
+ bool bExportEquation = false;
+ aPropertyStates = mxExpPropMapper->Filter( xStatProp );
+ if( xEquationProperties.is())
+ {
+ xEquationProperties->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "ShowEquation" )))
+ >>= bShowEquation;
+ xEquationProperties->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "ShowCorrelationCoefficient" )))
+ >>= bShowRSquared;
+ bExportEquation = ( bShowEquation || bShowRSquared );
+ const SvtSaveOptions::ODFDefaultVersion nCurrentVersion( SvtSaveOptions().GetODFDefaultVersion() );
+ if( nCurrentVersion < SvtSaveOptions::ODFVER_012 )
+ bExportEquation=false;
+ if( bExportEquation )
+ {
+ // number format
+ sal_Int32 nNumberFormat = 0;
+ if( ( xEquationProperties->getPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "NumberFormat" ))) >>= nNumberFormat ) &&
+ nNumberFormat != -1 )
+ {
+ mrExport.addDataStyle( nNumberFormat );
+ }
+ aEquationPropertyStates = mxExpPropMapper->Filter( xEquationProperties );
+ }
+ }
+
+ if( !aPropertyStates.empty() || bExportEquation )
+ {
+ // write element
+ if( bExportContent )
+ {
+ // add style name attribute
+ if( !aPropertyStates.empty())
+ AddAutoStyleAttribute( aPropertyStates );
+ SvXMLElementExport aRegressionExport( mrExport, XML_NAMESPACE_CHART, XML_REGRESSION_CURVE, sal_True, sal_True );
+ if( bExportEquation )
+ {
+ // default is true
+ if( !bShowEquation )
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_DISPLAY_EQUATION, XML_FALSE );
+ // default is false
+ if( bShowRSquared )
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_DISPLAY_R_SQUARE, XML_TRUE );
+
+ // export position
+ chart2::RelativePosition aRelativePosition;
+ if( xEquationProperties->getPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("RelativePosition"))) >>= aRelativePosition )
+ {
+ double fX = aRelativePosition.Primary * rPageSize.Width;
+ double fY = aRelativePosition.Secondary * rPageSize.Height;
+ awt::Point aPos;
+ aPos.X = static_cast< sal_Int32 >( ::rtl::math::round( fX ));
+ aPos.Y = static_cast< sal_Int32 >( ::rtl::math::round( fY ));
+ addPosition( aPos );
+ }
+
+ if( !aEquationPropertyStates.empty())
+ AddAutoStyleAttribute( aEquationPropertyStates );
+
+ SvXMLElementExport( mrExport, XML_NAMESPACE_CHART, XML_EQUATION, sal_True, sal_True );
+ }
+ }
+ else // autostyles
+ {
+ if( !aPropertyStates.empty())
+ CollectAutoStyle( aPropertyStates );
+ if( bExportEquation && !aEquationPropertyStates.empty())
+ CollectAutoStyle( aEquationPropertyStates );
+ }
+ }
+ }
+}
+
+void SchXMLExportHelper_Impl::exportCandleStickSeries(
+ const Sequence< Reference< chart2::XDataSeries > > & aSeriesSeq,
+ const Reference< chart2::XDiagram > & xDiagram,
+ sal_Bool bJapaneseCandleSticks,
+ sal_Bool bExportContent )
+{
+// std::vector< XMLPropertyState > aPropertyStates;
+
+ for( sal_Int32 nSeriesIdx=0; nSeriesIdx<aSeriesSeq.getLength(); ++nSeriesIdx )
+ {
+ Reference< chart2::XDataSeries > xSeries( aSeriesSeq[nSeriesIdx] );
+ sal_Int32 nAttachedAxis = lcl_isSeriesAttachedToFirstAxis( xSeries )
+ ? chart::ChartAxisAssign::PRIMARY_Y
+ : chart::ChartAxisAssign::SECONDARY_Y;
+
+ Reference< chart2::data::XDataSource > xSource( xSeries, uno::UNO_QUERY );
+ if( xSource.is())
+ {
+ // export series in correct order (as we don't store roles)
+ // with japanese candlesticks: open, low, high, close
+ // otherwise: low, high, close
+ Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeqCnt(
+ xSource->getDataSequences());
+
+ sal_Int32 nSeriesLength =
+ lcl_getSequenceLengthByRole( aSeqCnt, OUString::createFromAscii("values-last"));
+
+ if( bExportContent )
+ {
+ Reference< chart2::XChartDocument > xNewDoc( mrExport.GetModel(), uno::UNO_QUERY );
+ //@todo: export data points
+
+ // open
+ if( bJapaneseCandleSticks )
+ {
+ tLabelAndValueRange aRanges( lcl_getLabelAndValueRangeByRole(
+ aSeqCnt, OUString::createFromAscii("values-first"), xNewDoc, m_aDataSequencesToExport ));
+ if( aRanges.second.getLength())
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_VALUES_CELL_RANGE_ADDRESS, aRanges.second );
+ if( aRanges.first.getLength())
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_LABEL_CELL_ADDRESS, aRanges.first );
+ if( nAttachedAxis == chart::ChartAxisAssign::SECONDARY_Y )
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_ATTACHED_AXIS, XML_SECONDARY_Y );
+ else
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_ATTACHED_AXIS, XML_PRIMARY_Y );
+ SvXMLElementExport aOpenSeries( mrExport, XML_NAMESPACE_CHART, XML_SERIES, sal_True, sal_True );
+ // export empty data points
+ exportDataPoints( 0, nSeriesLength, xDiagram, bExportContent );
+ }
+
+ // low
+ {
+ tLabelAndValueRange aRanges( lcl_getLabelAndValueRangeByRole(
+ aSeqCnt, OUString::createFromAscii("values-min"), xNewDoc, m_aDataSequencesToExport ));
+ if( aRanges.second.getLength())
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_VALUES_CELL_RANGE_ADDRESS, aRanges.second );
+ if( aRanges.first.getLength())
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_LABEL_CELL_ADDRESS, aRanges.first );
+ if( nAttachedAxis == chart::ChartAxisAssign::SECONDARY_Y )
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_ATTACHED_AXIS, XML_SECONDARY_Y );
+ else
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_ATTACHED_AXIS, XML_PRIMARY_Y );
+ SvXMLElementExport aLowSeries( mrExport, XML_NAMESPACE_CHART, XML_SERIES, sal_True, sal_True );
+ // export empty data points
+ exportDataPoints( 0, nSeriesLength, xDiagram, bExportContent );
+ }
+
+ // high
+ {
+ tLabelAndValueRange aRanges( lcl_getLabelAndValueRangeByRole(
+ aSeqCnt, OUString::createFromAscii("values-max"), xNewDoc, m_aDataSequencesToExport ));
+ if( aRanges.second.getLength())
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_VALUES_CELL_RANGE_ADDRESS, aRanges.second );
+ if( aRanges.first.getLength())
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_LABEL_CELL_ADDRESS, aRanges.first );
+ if( nAttachedAxis == chart::ChartAxisAssign::SECONDARY_Y )
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_ATTACHED_AXIS, XML_SECONDARY_Y );
+ else
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_ATTACHED_AXIS, XML_PRIMARY_Y );
+ SvXMLElementExport aHighSeries( mrExport, XML_NAMESPACE_CHART, XML_SERIES, sal_True, sal_True );
+ // export empty data points
+ exportDataPoints( 0, nSeriesLength, xDiagram, bExportContent );
+ }
+
+ // close
+ {
+ tLabelAndValueRange aRanges( lcl_getLabelAndValueRangeByRole(
+ aSeqCnt, OUString::createFromAscii("values-last"), xNewDoc, m_aDataSequencesToExport ));
+ if( aRanges.second.getLength())
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_VALUES_CELL_RANGE_ADDRESS, aRanges.second );
+ if( aRanges.first.getLength())
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_LABEL_CELL_ADDRESS, aRanges.first );
+ if( nAttachedAxis == chart::ChartAxisAssign::SECONDARY_Y )
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_ATTACHED_AXIS, XML_SECONDARY_Y );
+ else
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_ATTACHED_AXIS, XML_PRIMARY_Y );
+ // write style name
+// AddAutoStyleAttribute( aPropertyStates );
+ // chart type
+// mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_CLASS,
+// mrExport.GetNamespaceMap().GetQNameByKey(
+// XML_NAMESPACE_CHART, GetXMLToken( XML_STOCK )));
+ SvXMLElementExport aCloseSeries( mrExport, XML_NAMESPACE_CHART, XML_SERIES, sal_True, sal_True );
+ // export empty data points
+ exportDataPoints( 0, nSeriesLength, xDiagram, bExportContent );
+ }
+ }
+ else // autostyles
+ {
+ // for close series
+// CollectAutoStyle( aPropertyStates );
+ }
+ // remove property states for autostyles
+// aPropertyStates.clear();
+ }
+ }
+}
+
+void SchXMLExportHelper_Impl::exportDataPoints(
+ const uno::Reference< beans::XPropertySet > & xSeriesProperties,
+ sal_Int32 nSeriesLength,
+ const uno::Reference< chart2::XDiagram > & xDiagram,
+ sal_Bool bExportContent )
+{
+ // data-points
+ // -----------
+ // write data-points only if they contain autostyles
+ // objects with equal autostyles are grouped using the attribute
+ // repeat="number"
+
+ // Note: if only the nth data-point has autostyles there is an element
+ // without style and repeat="n-1" attribute written in advance.
+
+ // the sequence aDataPointSeq contains indices of data-points that
+ // do have own attributes. This increases the performance substantially.
+
+ // more performant version for #93600#
+ if( mxExpPropMapper.is())
+ {
+ uno::Reference< chart2::XDataSeries > xSeries( xSeriesProperties, uno::UNO_QUERY );
+
+ std::vector< XMLPropertyState > aPropertyStates;
+
+ const OUString sNumFormat( OUString::createFromAscii( "NumberFormat" ));
+ const OUString sPercentageNumFormat( OUString::createFromAscii( "PercentageNumberFormat" ));
+
+ bool bVaryColorsByPoint = false;
+ Sequence< sal_Int32 > aDataPointSeq;
+ if( xSeriesProperties.is())
+ {
+ Any aAny = xSeriesProperties->getPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "AttributedDataPoints" )));
+ aAny >>= aDataPointSeq;
+ xSeriesProperties->getPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "VaryColorsByPoint" ))) >>= bVaryColorsByPoint;
+ }
+
+
+ sal_Int32 nSize = aDataPointSeq.getLength();
+ DBG_ASSERT( nSize <= nSeriesLength, "Too many point attributes" );
+
+ const sal_Int32 * pPoints = aDataPointSeq.getConstArray();
+ sal_Int32 nElement;
+ sal_Int32 nRepeat;
+ Reference< chart2::XColorScheme > xColorScheme;
+ if( xDiagram.is())
+ xColorScheme.set( xDiagram->getDefaultColorScheme());
+
+ ::std::list< SchXMLDataPointStruct > aDataPointList;
+
+ sal_Int32 nLastIndex = -1;
+ sal_Int32 nCurrIndex = 0;
+
+ // collect elements
+ if( bVaryColorsByPoint && xColorScheme.is() )
+ {
+ ::std::set< sal_Int32 > aAttrPointSet;
+ ::std::copy( pPoints, pPoints + aDataPointSeq.getLength(),
+ ::std::inserter( aAttrPointSet, aAttrPointSet.begin()));
+ const ::std::set< sal_Int32 >::const_iterator aEndIt( aAttrPointSet.end());
+ for( nElement = 0; nElement < nSeriesLength; ++nElement )
+ {
+ aPropertyStates.clear();
+ uno::Reference< beans::XPropertySet > xPropSet;
+ bool bExportNumFmt = false;
+ if( aAttrPointSet.find( nElement ) != aEndIt )
+ {
+ try
+ {
+ xPropSet = SchXMLSeriesHelper::createOldAPIDataPointPropertySet(
+ xSeries, nElement, mrExport.GetModel() );
+ bExportNumFmt = true;
+ }
+ catch( uno::Exception & rEx )
+ {
+ (void)rEx; // avoid warning for pro build
+ DBG_ERROR1( "Exception caught during Export of data point: %s",
+ OUStringToOString( rEx.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
+ }
+ }
+ else
+ {
+ // property set only containing the color
+ xPropSet.set( new ::xmloff::chart::ColorPropertySet(
+ xColorScheme->getColorByIndex( nElement )));
+ }
+ DBG_ASSERT( xPropSet.is(), "Pie Segments should have properties" );
+ if( xPropSet.is())
+ {
+ const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion( SvtSaveOptions().GetODFDefaultVersion() );
+ if( nCurrentODFVersion >= SvtSaveOptions::ODFVER_012 && bExportNumFmt )
+ {
+ lcl_exportNumberFormat( sNumFormat, xPropSet, mrExport );
+ lcl_exportNumberFormat( sPercentageNumFormat, xPropSet, mrExport );
+ }
+
+ aPropertyStates = mxExpPropMapper->Filter( xPropSet );
+ if( !aPropertyStates.empty() )
+ {
+ if( bExportContent )
+ {
+ // write data-point with style
+ DBG_ASSERT( ! maAutoStyleNameQueue.empty(), "Autostyle queue empty!" );
+
+ SchXMLDataPointStruct aPoint;
+ aPoint.maStyleName = maAutoStyleNameQueue.front();
+ maAutoStyleNameQueue.pop();
+ aDataPointList.push_back( aPoint );
+ }
+ else
+ {
+ CollectAutoStyle( aPropertyStates );
+ }
+ }
+ }
+ }
+ DBG_ASSERT( !bExportContent || (static_cast<sal_Int32>(aDataPointList.size()) == nSeriesLength),
+ "not enough data points on content export" );
+ }
+ else
+ {
+ for( nElement = 0; nElement < nSize; ++nElement )
+ {
+ aPropertyStates.clear();
+ nCurrIndex = pPoints[ nElement ];
+ //assuming sorted indices in pPoints
+
+ if( nCurrIndex<0 || nCurrIndex>=nSeriesLength )
+ break;
+
+ // write leading empty data points
+ if( nCurrIndex - nLastIndex > 1 )
+ {
+ SchXMLDataPointStruct aPoint;
+ aPoint.mnRepeat = nCurrIndex - nLastIndex - 1;
+ aDataPointList.push_back( aPoint );
+ }
+
+ uno::Reference< beans::XPropertySet > xPropSet;
+ // get property states
+ try
+ {
+ xPropSet = SchXMLSeriesHelper::createOldAPIDataPointPropertySet(
+ xSeries, nCurrIndex, mrExport.GetModel() );
+ }
+ catch( uno::Exception & rEx )
+ {
+ (void)rEx; // avoid warning for pro build
+ DBG_ERROR1( "Exception caught during Export of data point: %s",
+ OUStringToOString( rEx.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
+ }
+ if( xPropSet.is())
+ {
+ const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion( SvtSaveOptions().GetODFDefaultVersion() );
+ if( nCurrentODFVersion >= SvtSaveOptions::ODFVER_012 )
+ {
+ lcl_exportNumberFormat( sNumFormat, xPropSet, mrExport );
+ lcl_exportNumberFormat( sPercentageNumFormat, xPropSet, mrExport );
+ }
+
+ aPropertyStates = mxExpPropMapper->Filter( xPropSet );
+ if( !aPropertyStates.empty() )
+ {
+ if( bExportContent )
+ {
+ // write data-point with style
+ DBG_ASSERT( ! maAutoStyleNameQueue.empty(), "Autostyle queue empty!" );
+ SchXMLDataPointStruct aPoint;
+ aPoint.maStyleName = maAutoStyleNameQueue.front();
+ maAutoStyleNameQueue.pop();
+
+ aDataPointList.push_back( aPoint );
+ nLastIndex = nCurrIndex;
+ }
+ else
+ {
+ CollectAutoStyle( aPropertyStates );
+ }
+ continue;
+ }
+ }
+
+ // if we get here the property states are empty
+ SchXMLDataPointStruct aPoint;
+ aDataPointList.push_back( aPoint );
+
+ nLastIndex = nCurrIndex;
+ }
+ // final empty elements
+ nRepeat = nSeriesLength - nLastIndex - 1;
+ if( nRepeat > 0 )
+ {
+ SchXMLDataPointStruct aPoint;
+ aPoint.mnRepeat = nRepeat;
+ aDataPointList.push_back( aPoint );
+ }
+ }
+
+ if( bExportContent )
+ {
+ // write elements (merge equal ones)
+ ::std::list< SchXMLDataPointStruct >::iterator aIter = aDataPointList.begin();
+ SchXMLDataPointStruct aPoint;
+ SchXMLDataPointStruct aLastPoint;
+
+ // initialize so that it doesn't matter if
+ // the element is counted in the first iteration
+ aLastPoint.mnRepeat = 0;
+
+ for( ; aIter != aDataPointList.end(); ++aIter )
+ {
+ aPoint = (*aIter);
+
+ if( aPoint.maStyleName == aLastPoint.maStyleName )
+ aPoint.mnRepeat += aLastPoint.mnRepeat;
+ else if( aLastPoint.mnRepeat > 0 )
+ {
+ // write last element
+ if( aLastPoint.maStyleName.getLength() )
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_STYLE_NAME, aLastPoint.maStyleName );
+
+ if( aLastPoint.mnRepeat > 1 )
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_REPEATED,
+ OUString::valueOf( (sal_Int64)( aLastPoint.mnRepeat ) ));
+
+ SvXMLElementExport aPointElem( mrExport, XML_NAMESPACE_CHART, XML_DATA_POINT, sal_True, sal_True );
+ }
+ aLastPoint = aPoint;
+ }
+ // write last element if it hasn't been written in last iteration
+ if( aPoint.maStyleName == aLastPoint.maStyleName )
+ {
+ if( aLastPoint.maStyleName.getLength() )
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_STYLE_NAME, aLastPoint.maStyleName );
+
+ if( aLastPoint.mnRepeat > 1 )
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_REPEATED,
+ OUString::valueOf( (sal_Int64)( aLastPoint.mnRepeat ) ));
+
+ SvXMLElementExport aPointElem( mrExport, XML_NAMESPACE_CHART, XML_DATA_POINT, sal_True, sal_True );
+ }
+ }
+ }
+}
+
+
+void SchXMLExportHelper_Impl::getCellAddress( sal_Int32 nCol, sal_Int32 nRow )
+{
+ msStringBuffer.append( (sal_Unicode)'.' );
+ if( nCol < 26 )
+ msStringBuffer.append( (sal_Unicode)('A' + nCol) );
+ else if( nCol < 702 )
+ {
+ msStringBuffer.append( (sal_Unicode)('A' + nCol / 26 - 1 ));
+ msStringBuffer.append( (sal_Unicode)('A' + nCol % 26) );
+ }
+ else
+ {
+ msStringBuffer.append( (sal_Unicode)('A' + nCol / 702 - 1 ));
+ msStringBuffer.append( (sal_Unicode)('A' + (nCol % 702) / 26 ));
+ msStringBuffer.append( (sal_Unicode)('A' + nCol % 26) );
+ }
+
+ msStringBuffer.append( nRow + (sal_Int32)1 );
+}
+
+void SchXMLExportHelper_Impl::addPosition( const awt::Point & rPosition )
+{
+ mrExport.GetMM100UnitConverter().convertMeasure( msStringBuffer, rPosition.X );
+ msString = msStringBuffer.makeStringAndClear();
+ mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_X, msString );
+
+ mrExport.GetMM100UnitConverter().convertMeasure( msStringBuffer, rPosition.Y );
+ msString = msStringBuffer.makeStringAndClear();
+ mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_Y, msString );
+}
+
+void SchXMLExportHelper_Impl::addPosition( Reference< drawing::XShape > xShape )
+{
+ if( xShape.is())
+ addPosition( xShape->getPosition());
+}
+
+void SchXMLExportHelper_Impl::addSize( const awt::Size & rSize )
+{
+ mrExport.GetMM100UnitConverter().convertMeasure( msStringBuffer, rSize.Width );
+ msString = msStringBuffer.makeStringAndClear();
+ mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_WIDTH, msString );
+
+ mrExport.GetMM100UnitConverter().convertMeasure( msStringBuffer, rSize.Height );
+ msString = msStringBuffer.makeStringAndClear();
+ mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_HEIGHT, msString );
+}
+
+void SchXMLExportHelper_Impl::addSize( Reference< drawing::XShape > xShape )
+{
+ if( xShape.is())
+ addSize( xShape->getSize() );
+}
+
+awt::Size SchXMLExportHelper_Impl::getPageSize( const Reference< chart2::XChartDocument > & xChartDoc ) const
+{
+ awt::Size aSize( 8000, 7000 );
+ uno::Reference< embed::XVisualObject > xVisualObject( xChartDoc, uno::UNO_QUERY );
+ DBG_ASSERT( xVisualObject.is(),"need XVisualObject for page size" );
+ if( xVisualObject.is() )
+ aSize = xVisualObject->getVisualAreaSize( embed::Aspects::MSOLE_CONTENT );
+
+ return aSize;
+}
+
+void SchXMLExportHelper_Impl::CollectAutoStyle( const std::vector< XMLPropertyState >& aStates )
+{
+ if( !aStates.empty() )
+ maAutoStyleNameQueue.push( GetAutoStylePoolP().Add( XML_STYLE_FAMILY_SCH_CHART_ID, aStates ));
+}
+
+void SchXMLExportHelper_Impl::AddAutoStyleAttribute( const std::vector< XMLPropertyState >& aStates )
+{
+ if( !aStates.empty() )
+ {
+ DBG_ASSERT( ! maAutoStyleNameQueue.empty(), "Autostyle queue empty!" );
+
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_STYLE_NAME, maAutoStyleNameQueue.front() );
+ maAutoStyleNameQueue.pop();
+ }
+}
+
+void SchXMLExportHelper_Impl::exportText( const OUString& rText, bool bConvertTabsLFs )
+{
+ SchXMLTools::exportText( mrExport, rText, bConvertTabsLFs );
+}
+
+// ========================================
+// class SchXMLExport
+// ========================================
+
+// #110680#
+SchXMLExport::SchXMLExport(
+ const Reference< lang::XMultiServiceFactory >& xServiceFactory,
+ sal_uInt16 nExportFlags )
+: SvXMLExport( xServiceFactory, MAP_CM, ::xmloff::token::XML_CHART, nExportFlags ),
+ maAutoStylePool( *this ),
+ maExportHelper( *this, maAutoStylePool )
+{
+ if( getDefaultVersion() == SvtSaveOptions::ODFVER_LATEST )
+ _GetNamespaceMap().Add( GetXMLToken(XML_NP_CHART_EXT), GetXMLToken(XML_N_CHART_EXT), XML_NAMESPACE_CHART_EXT);
+}
+
+
+SchXMLExport::~SchXMLExport()
+{
+ // stop progress view
+ if( mxStatusIndicator.is())
+ {
+ mxStatusIndicator->end();
+ mxStatusIndicator->reset();
+ }
+}
+
+sal_uInt32 SchXMLExport::exportDoc( enum ::xmloff::token::XMLTokenEnum eClass )
+{
+ Reference< chart2::XChartDocument > xChartDoc( GetModel(), uno::UNO_QUERY );
+ maExportHelper.m_pImpl->InitRangeSegmentationProperties( xChartDoc );
+ return SvXMLExport::exportDoc( eClass );
+}
+
+void SchXMLExport::_ExportStyles( sal_Bool bUsed )
+{
+ SvXMLExport::_ExportStyles( bUsed );
+}
+
+void SchXMLExport::_ExportMasterStyles()
+{
+ // not available in chart
+ DBG_WARNING( "Master Style Export requested. Not available for Chart" );
+}
+
+void SchXMLExport::_ExportAutoStyles()
+{
+ // there are no styles that require their own autostyles
+ if( getExportFlags() & EXPORT_CONTENT )
+ {
+ Reference< chart::XChartDocument > xChartDoc( GetModel(), uno::UNO_QUERY );
+ if( xChartDoc.is())
+ {
+ maExportHelper.m_pImpl->collectAutoStyles( xChartDoc );
+ maExportHelper.m_pImpl->exportAutoStyles();
+ }
+ else
+ {
+ DBG_ERROR( "Couldn't export chart due to wrong XModel (must be XChartDocument)" );
+ }
+ }
+}
+
+void SchXMLExport::_ExportContent()
+{
+ Reference< chart::XChartDocument > xChartDoc( GetModel(), uno::UNO_QUERY );
+ if( xChartDoc.is())
+ {
+ // determine if data comes from the outside
+ sal_Bool bIncludeTable = sal_True;
+
+ Reference< chart2::XChartDocument > xNewDoc( xChartDoc, uno::UNO_QUERY );
+ if( xNewDoc.is())
+ {
+ // check if we have own data. If so we must not export the complete
+ // range string, as this is our only indicator for having own or
+ // external data. @todo: fix this in the file format!
+ Reference< lang::XServiceInfo > xDPServiceInfo( xNewDoc->getDataProvider(), uno::UNO_QUERY );
+ if( ! (xDPServiceInfo.is() &&
+ xDPServiceInfo->getImplementationName().equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( "com.sun.star.comp.chart.InternalDataProvider" ))))
+ {
+ bIncludeTable = sal_False;
+ }
+ }
+ else
+ {
+ Reference< lang::XServiceInfo > xServ( xChartDoc, uno::UNO_QUERY );
+ if( xServ.is())
+ {
+ if( xServ->supportsService(
+ OUString::createFromAscii( "com.sun.star.chart.ChartTableAddressSupplier" )))
+ {
+ Reference< beans::XPropertySet > xProp( xServ, uno::UNO_QUERY );
+ if( xProp.is())
+ {
+ Any aAny;
+ try
+ {
+ OUString sChartAddress;
+ aAny = xProp->getPropertyValue(
+ OUString::createFromAscii( "ChartRangeAddress" ));
+ aAny >>= sChartAddress;
+ maExportHelper.m_pImpl->SetChartRangeAddress( sChartAddress );
+
+ OUString sTableNumberList;
+ aAny = xProp->getPropertyValue(
+ OUString::createFromAscii( "TableNumberList" ));
+ aAny >>= sTableNumberList;
+ maExportHelper.m_pImpl->SetTableNumberList( sTableNumberList );
+
+ // do not include own table if there are external addresses
+ bIncludeTable = (sChartAddress.getLength() == 0);
+ }
+ catch( beans::UnknownPropertyException & )
+ {
+ DBG_ERROR( "Property ChartRangeAddress not supported by ChartDocument" );
+ }
+ }
+ }
+ }
+ }
+ maExportHelper.m_pImpl->exportChart( xChartDoc, bIncludeTable );
+ }
+ else
+ {
+ DBG_ERROR( "Couldn't export chart due to wrong XModel" );
+ }
+}
+
+void SchXMLExport::SetProgress( sal_Int32 nPercentage )
+{
+ // set progress view
+ if( mxStatusIndicator.is())
+ mxStatusIndicator->setValue( nPercentage );
+}
+
+UniReference< XMLPropertySetMapper > SchXMLExport::GetPropertySetMapper() const
+{
+ return maExportHelper.m_pImpl->GetPropertySetMapper();
+}
+
+void SchXMLExportHelper_Impl::InitRangeSegmentationProperties( const Reference< chart2::XChartDocument > & xChartDoc )
+{
+ if( xChartDoc.is())
+ try
+ {
+ Reference< chart2::data::XDataProvider > xDataProvider( xChartDoc->getDataProvider() );
+ OSL_ENSURE( xDataProvider.is(), "No DataProvider" );
+ if( xDataProvider.is())
+ {
+ Reference< chart2::data::XDataSource > xDataSource( lcl_pressUsedDataIntoRectangularFormat( xChartDoc, mbHasCategoryLabels ));
+ Sequence< beans::PropertyValue > aArgs( xDataProvider->detectArguments( xDataSource ));
+ ::rtl::OUString sCellRange, sBrokenRange;
+ bool bBrokenRangeAvailable = false;
+ for( sal_Int32 i=0; i<aArgs.getLength(); ++i )
+ {
+ if( aArgs[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("CellRangeRepresentation")))
+ aArgs[i].Value >>= sCellRange;
+ else if( aArgs[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("BrokenCellRangeForExport")))
+ {
+ if( aArgs[i].Value >>= sBrokenRange )
+ bBrokenRangeAvailable = true;
+ }
+ else if( aArgs[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("DataRowSource")))
+ {
+ chart::ChartDataRowSource eRowSource;
+ aArgs[i].Value >>= eRowSource;
+ mbRowSourceColumns = ( eRowSource == chart::ChartDataRowSource_COLUMNS );
+ }
+ else if( aArgs[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("FirstCellAsLabel")))
+ aArgs[i].Value >>= mbHasSeriesLabels;
+ else if( aArgs[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("SequenceMapping")))
+ aArgs[i].Value >>= maSequenceMapping;
+ else if( aArgs[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("TableNumberList")))
+ aArgs[i].Value >>= msTableNumberList;
+ }
+
+ // #i79009# For Writer we have to export a broken version of the
+ // range, where every row number is noe too large, so that older
+ // version can correctly read those files.
+ msChartAddress = (bBrokenRangeAvailable ? sBrokenRange : sCellRange);
+ if( msChartAddress.getLength() > 0 )
+ {
+ // convert format to XML-conform one
+ Reference< chart2::data::XRangeXMLConversion > xConversion( xDataProvider, uno::UNO_QUERY );
+ if( xConversion.is())
+ msChartAddress = xConversion->convertRangeToXML( msChartAddress );
+ }
+ }
+ }
+ catch( uno::Exception & ex )
+ {
+ (void)ex; // avoid warning for pro build
+ OSL_ENSURE( false, OUStringToOString(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "Exception caught. Type: " )) +
+ OUString::createFromAscii( typeid( ex ).name()) +
+ OUString( RTL_CONSTASCII_USTRINGPARAM( ", Message: " )) +
+ ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
+ }
+}
+
+// export components ========================================
+
+// first version: everything goes in one storage
+
+Sequence< OUString > SAL_CALL SchXMLExport_getSupportedServiceNames() throw()
+{
+ const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Chart.XMLExporter" ) );
+ const Sequence< OUString > aSeq( &aServiceName, 1 );
+ return aSeq;
+}
+
+OUString SAL_CALL SchXMLExport_getImplementationName() throw()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "SchXMLExport.Compact" ) );
+}
+
+Reference< uno::XInterface > SAL_CALL SchXMLExport_createInstance(const Reference< lang::XMultiServiceFactory > & rSMgr) throw( uno::Exception )
+{
+ // #110680#
+ // #103997# removed some flags from EXPORT_ALL
+ // return (cppu::OWeakObject*)new SchXMLExport( EXPORT_ALL ^ ( EXPORT_SETTINGS | EXPORT_MASTERSTYLES | EXPORT_SCRIPTS ));
+ return (cppu::OWeakObject*)new SchXMLExport( rSMgr, EXPORT_ALL ^ ( EXPORT_SETTINGS | EXPORT_MASTERSTYLES | EXPORT_SCRIPTS ));
+}
+
+// Oasis format
+Sequence< OUString > SAL_CALL SchXMLExport_Oasis_getSupportedServiceNames() throw()
+{
+ const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Chart.XMLOasisExporter" ) );
+ const Sequence< OUString > aSeq( &aServiceName, 1 );
+ return aSeq;
+}
+
+OUString SAL_CALL SchXMLExport_Oasis_getImplementationName() throw()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "SchXMLExport.Oasis.Compact" ) );
+}
+
+Reference< uno::XInterface > SAL_CALL SchXMLExport_Oasis_createInstance(const Reference< lang::XMultiServiceFactory > & rSMgr) throw( uno::Exception )
+{
+ // #103997# removed some flags from EXPORT_ALL
+ return (cppu::OWeakObject*)new SchXMLExport( rSMgr,
+ (EXPORT_ALL ^ ( EXPORT_SETTINGS | EXPORT_MASTERSTYLES | EXPORT_SCRIPTS )) | EXPORT_OASIS );
+}
+
+// ============================================================
+
+// multiple storage version: one for content / styles / meta
+
+Sequence< OUString > SAL_CALL SchXMLExport_Styles_getSupportedServiceNames() throw()
+{
+ const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Chart.XMLStylesExporter" ));
+ const Sequence< OUString > aSeq( &aServiceName, 1 );
+ return aSeq;
+}
+
+OUString SAL_CALL SchXMLExport_Styles_getImplementationName() throw()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "SchXMLExport.Styles" ));
+}
+
+Reference< uno::XInterface > SAL_CALL SchXMLExport_Styles_createInstance(const Reference< lang::XMultiServiceFactory >& rSMgr) throw( uno::Exception )
+{
+ // #110680#
+ // return (cppu::OWeakObject*)new SchXMLExport( EXPORT_STYLES );
+ return (cppu::OWeakObject*)new SchXMLExport( rSMgr, EXPORT_STYLES );
+}
+
+// Oasis format
+Sequence< OUString > SAL_CALL SchXMLExport_Oasis_Styles_getSupportedServiceNames() throw()
+{
+ const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Chart.XMLOasisStylesExporter" ));
+ const Sequence< OUString > aSeq( &aServiceName, 1 );
+ return aSeq;
+}
+
+OUString SAL_CALL SchXMLExport_Oasis_Styles_getImplementationName() throw()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "SchXMLExport.Oasis.Styles" ));
+}
+
+Reference< uno::XInterface > SAL_CALL SchXMLExport_Oasis_Styles_createInstance(const Reference< lang::XMultiServiceFactory > & rSMgr) throw( uno::Exception )
+{
+ return (cppu::OWeakObject*)new SchXMLExport( rSMgr, EXPORT_STYLES | EXPORT_OASIS );
+}
+
+// ------------------------------------------------------------
+
+Sequence< OUString > SAL_CALL SchXMLExport_Content_getSupportedServiceNames() throw()
+{
+ const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Chart.XMLContentExporter" ));
+ const Sequence< OUString > aSeq( &aServiceName, 1 );
+ return aSeq;
+}
+
+OUString SAL_CALL SchXMLExport_Content_getImplementationName() throw()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "SchXMLExport.Content" ));
+}
+
+Reference< uno::XInterface > SAL_CALL SchXMLExport_Content_createInstance(const Reference< lang::XMultiServiceFactory > & rSMgr) throw( uno::Exception )
+{
+ // #110680#
+ // return (cppu::OWeakObject*)new SchXMLExport( EXPORT_AUTOSTYLES | EXPORT_CONTENT | EXPORT_FONTDECLS );
+ return (cppu::OWeakObject*)new SchXMLExport( rSMgr, EXPORT_AUTOSTYLES | EXPORT_CONTENT | EXPORT_FONTDECLS );
+}
+
+// Oasis format
+Sequence< OUString > SAL_CALL SchXMLExport_Oasis_Content_getSupportedServiceNames() throw()
+{
+ const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Chart.XMLOasisContentExporter" ));
+ const Sequence< OUString > aSeq( &aServiceName, 1 );
+ return aSeq;
+}
+
+OUString SAL_CALL SchXMLExport_Oasis_Content_getImplementationName() throw()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "SchXMLExport.Oasis.Content" ));
+}
+
+Reference< uno::XInterface > SAL_CALL SchXMLExport_Oasis_Content_createInstance(const Reference< lang::XMultiServiceFactory > & rSMgr) throw( uno::Exception )
+{
+ return (cppu::OWeakObject*)new SchXMLExport( rSMgr, EXPORT_AUTOSTYLES | EXPORT_CONTENT | EXPORT_FONTDECLS | EXPORT_OASIS );
+}
+
+// ------------------------------------------------------------
+
+// Sequence< OUString > SAL_CALL SchXMLExport_Meta_getSupportedServiceNames() throw()
+// {
+// const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Chart.XMLMetaExporter" ));
+// const Sequence< OUString > aSeq( &aServiceName, 1 );
+// return aSeq;
+// }
+
+// OUString SAL_CALL SchXMLExport_Meta_getImplementationName() throw()
+// {
+// return OUString( RTL_CONSTASCII_USTRINGPARAM( "SchXMLExport.Meta" ));
+// }
+
+// Reference< uno::XInterface > SAL_CALL SchXMLExport_Meta_createInstance(const Reference< lang::XMultiServiceFactory > & rSMgr) throw( uno::Exception )
+// {
+// return (cppu::OWeakObject*)new SchXMLExport( EXPORT_META );
+// }
+
+// Oasis format
+Sequence< OUString > SAL_CALL SchXMLExport_Oasis_Meta_getSupportedServiceNames() throw()
+{
+ const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Chart.XMLOasisMetaExporter" ));
+ const Sequence< OUString > aSeq( &aServiceName, 1 );
+ return aSeq;
+}
+
+OUString SAL_CALL SchXMLExport_Oasis_Meta_getImplementationName() throw()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "SchXMLExport.Oasis.Meta" ));
+}
+
+Reference< uno::XInterface > SAL_CALL SchXMLExport_Oasis_Meta_createInstance(const Reference< lang::XMultiServiceFactory > & rSMgr) throw( uno::Exception )
+{
+ return (cppu::OWeakObject*)new SchXMLExport( rSMgr, EXPORT_META | EXPORT_OASIS );
+}
+
+
+// XServiceInfo
+OUString SAL_CALL SchXMLExport::getImplementationName() throw( uno::RuntimeException )
+{
+ switch( getExportFlags())
+ {
+ case EXPORT_ALL:
+ return SchXMLExport_getImplementationName();
+ case EXPORT_STYLES:
+ return SchXMLExport_Styles_getImplementationName();
+ case ( EXPORT_AUTOSTYLES | EXPORT_CONTENT | EXPORT_FONTDECLS ):
+ return SchXMLExport_Content_getImplementationName();
+// case EXPORT_META:
+// return SchXMLExport_Meta_getImplementationName();
+
+ // Oasis format
+ case ( EXPORT_ALL | EXPORT_OASIS ):
+ return SchXMLExport_Oasis_getImplementationName();
+ case ( EXPORT_STYLES | EXPORT_OASIS ):
+ return SchXMLExport_Oasis_Styles_getImplementationName();
+ case ( EXPORT_AUTOSTYLES | EXPORT_CONTENT | EXPORT_FONTDECLS | EXPORT_OASIS ):
+ return SchXMLExport_Oasis_Content_getImplementationName();
+ case ( EXPORT_META | EXPORT_OASIS ):
+ return SchXMLExport_Oasis_Meta_getImplementationName();
+
+ case EXPORT_SETTINGS:
+ // there is no settings component in chart
+ default:
+ return OUString::createFromAscii( "SchXMLExport" );
+ }
+}
diff --git a/xmloff/source/chart/SchXMLImport.cxx b/xmloff/source/chart/SchXMLImport.cxx
new file mode 100644
index 000000000000..587070202c9c
--- /dev/null
+++ b/xmloff/source/chart/SchXMLImport.cxx
@@ -0,0 +1,960 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmloff.hxx"
+
+#include "SchXMLImport.hxx"
+#include "SchXMLChartContext.hxx"
+#include "contexts.hxx"
+#include "XMLChartPropertySetMapper.hxx"
+#include "SchXMLTools.hxx"
+
+#include <tools/debug.hxx>
+#include <rtl/ustrbuf.hxx>
+// header for class ByteString
+#include <tools/string.hxx>
+#include <comphelper/processfactory.hxx>
+#include "xmlnmspe.hxx"
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/xmluconv.hxx>
+#include <xmloff/nmspmap.hxx>
+#include <xmloff/xmlictxt.hxx>
+#include <xmloff/xmlstyle.hxx>
+#include <com/sun/star/task/XStatusIndicatorSupplier.hpp>
+#include <com/sun/star/chart/XChartDocument.hpp>
+#include <com/sun/star/chart/ChartDataRowSource.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/chart2/data/XDataReceiver.hpp>
+#include <com/sun/star/chart2/data/XDataProvider.hpp>
+#include <com/sun/star/chart2/XChartDocument.hpp>
+#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
+#include <com/sun/star/chart2/XChartTypeContainer.hpp>
+#include <com/sun/star/chart2/XDataSeriesContainer.hpp>
+
+#include <com/sun/star/document/XDocumentProperties.hpp>
+#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
+
+#include <typeinfo>
+
+using namespace com::sun::star;
+using namespace ::xmloff::token;
+
+using ::rtl::OUString;
+using ::rtl::OUStringBuffer;
+using ::rtl::OUStringToOString;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+
+namespace
+{
+Reference< uno::XComponentContext > lcl_getComponentContext()
+{
+ Reference< uno::XComponentContext > xContext;
+ try
+ {
+ Reference< beans::XPropertySet > xFactProp( comphelper::getProcessServiceFactory(), uno::UNO_QUERY );
+ if( xFactProp.is())
+ xFactProp->getPropertyValue(OUString::createFromAscii("DefaultContext")) >>= xContext;
+ }
+ catch( uno::Exception& )
+ {}
+
+ return xContext;
+}
+
+class lcl_MatchesChartType : public ::std::unary_function< Reference< chart2::XChartType >, bool >
+{
+public:
+ explicit lcl_MatchesChartType( const OUString & aChartTypeName ) :
+ m_aChartTypeName( aChartTypeName )
+ {}
+
+ bool operator () ( const Reference< chart2::XChartType > & xChartType ) const
+ {
+ return (xChartType.is() &&
+ xChartType->getChartType().equals( m_aChartTypeName ));
+ }
+
+private:
+ OUString m_aChartTypeName;
+};
+} // anonymous namespace
+
+/* ----------------------------------------
+ TokenMaps for distinguishing different
+ tokens in different contexts
+ ----------------------------------------*/
+
+// ----------------------------------------
+// element maps
+// ----------------------------------------
+
+
+
+
+
+
+
+// ----------------------------------------
+// attribute maps
+// ----------------------------------------
+
+
+
+
+
+
+
+
+
+// ========================================
+
+SchXMLImportHelper::SchXMLImportHelper() :
+ mpAutoStyles( 0 ),
+
+ mpChartDocElemTokenMap( 0 ),
+ mpTableElemTokenMap( 0 ),
+ mpChartElemTokenMap( 0 ),
+ mpPlotAreaElemTokenMap( 0 ),
+ mpSeriesElemTokenMap( 0 ),
+ mpAxisElemTokenMap( 0 ),
+
+ mpChartAttrTokenMap( 0 ),
+ mpPlotAreaAttrTokenMap( 0 ),
+ mpAxisAttrTokenMap( 0 ),
+ mpLegendAttrTokenMap( 0 ),
+ mpAutoStyleAttrTokenMap( 0 ),
+ mpCellAttrTokenMap( 0 ),
+ mpSeriesAttrTokenMap( 0 ),
+ mpRegEquationAttrTokenMap( 0 )
+{
+}
+
+SchXMLImportHelper::~SchXMLImportHelper()
+{
+ // delete token maps
+ if( mpChartDocElemTokenMap )
+ delete mpChartDocElemTokenMap;
+ if( mpTableElemTokenMap )
+ delete mpTableElemTokenMap;
+ if( mpChartElemTokenMap )
+ delete mpChartElemTokenMap;
+ if( mpPlotAreaElemTokenMap )
+ delete mpPlotAreaElemTokenMap;
+ if( mpSeriesElemTokenMap )
+ delete mpSeriesElemTokenMap;
+ if( mpAxisElemTokenMap )
+ delete mpAxisElemTokenMap;
+
+ if( mpChartAttrTokenMap )
+ delete mpChartAttrTokenMap;
+ if( mpPlotAreaAttrTokenMap )
+ delete mpPlotAreaAttrTokenMap;
+ if( mpAxisAttrTokenMap )
+ delete mpAxisAttrTokenMap;
+ if( mpLegendAttrTokenMap )
+ delete mpLegendAttrTokenMap;
+ if( mpAutoStyleAttrTokenMap )
+ delete mpAutoStyleAttrTokenMap;
+ if( mpCellAttrTokenMap )
+ delete mpCellAttrTokenMap;
+ if( mpSeriesAttrTokenMap )
+ delete mpSeriesAttrTokenMap;
+}
+
+SvXMLImportContext* SchXMLImportHelper::CreateChartContext(
+ SvXMLImport& rImport,
+ sal_uInt16 nPrefix, const OUString& rLocalName,
+ const Reference< frame::XModel > xChartModel,
+ const Reference< xml::sax::XAttributeList >& )
+{
+ SvXMLImportContext* pContext = 0;
+
+ Reference< chart::XChartDocument > xDoc( xChartModel, uno::UNO_QUERY );
+ if( xDoc.is())
+ {
+ mxChartDoc = xDoc;
+ pContext = new SchXMLChartContext( *this, rImport, rLocalName );
+ }
+ else
+ {
+ DBG_ERROR( "No valid XChartDocument given as XModel" );
+ pContext = new SvXMLImportContext( rImport, nPrefix, rLocalName );
+ }
+
+ return pContext;
+}
+
+/* ----------------------------------------
+ get various token maps
+ ----------------------------------------*/
+
+const SvXMLTokenMap& SchXMLImportHelper::GetDocElemTokenMap()
+{
+ if( ! mpChartDocElemTokenMap )
+ {
+ static __FAR_DATA SvXMLTokenMapEntry aDocElemTokenMap[] =
+ {
+ { XML_NAMESPACE_OFFICE, XML_AUTOMATIC_STYLES, XML_TOK_DOC_AUTOSTYLES },
+ { XML_NAMESPACE_OFFICE, XML_STYLES, XML_TOK_DOC_STYLES },
+ { XML_NAMESPACE_OFFICE, XML_META, XML_TOK_DOC_META },
+ { XML_NAMESPACE_OFFICE, XML_BODY, XML_TOK_DOC_BODY },
+ XML_TOKEN_MAP_END
+ };
+
+ mpChartDocElemTokenMap = new SvXMLTokenMap( aDocElemTokenMap );
+ } // if( ! mpChartDocElemTokenMap )
+
+ return *mpChartDocElemTokenMap;
+}
+
+const SvXMLTokenMap& SchXMLImportHelper::GetTableElemTokenMap()
+{
+ if( ! mpTableElemTokenMap )
+ {
+ static __FAR_DATA SvXMLTokenMapEntry aTableElemTokenMap[] =
+ {
+ { XML_NAMESPACE_TABLE, XML_TABLE_HEADER_COLUMNS, XML_TOK_TABLE_HEADER_COLS },
+ { XML_NAMESPACE_TABLE, XML_TABLE_COLUMNS, XML_TOK_TABLE_COLUMNS },
+ { XML_NAMESPACE_TABLE, XML_TABLE_COLUMN, XML_TOK_TABLE_COLUMN },
+ { XML_NAMESPACE_TABLE, XML_TABLE_HEADER_ROWS, XML_TOK_TABLE_HEADER_ROWS },
+ { XML_NAMESPACE_TABLE, XML_TABLE_ROWS, XML_TOK_TABLE_ROWS },
+ { XML_NAMESPACE_TABLE, XML_TABLE_ROW, XML_TOK_TABLE_ROW },
+ XML_TOKEN_MAP_END
+ };
+
+ mpTableElemTokenMap = new SvXMLTokenMap( aTableElemTokenMap );
+ } // if( ! mpTableElemTokenMap )
+
+ return *mpTableElemTokenMap;
+}
+
+const SvXMLTokenMap& SchXMLImportHelper::GetChartElemTokenMap()
+{
+ if( ! mpChartElemTokenMap )
+ {
+ static __FAR_DATA SvXMLTokenMapEntry aChartElemTokenMap[] =
+ {
+ { XML_NAMESPACE_CHART, XML_PLOT_AREA, XML_TOK_CHART_PLOT_AREA },
+ { XML_NAMESPACE_CHART, XML_TITLE, XML_TOK_CHART_TITLE },
+ { XML_NAMESPACE_CHART, XML_SUBTITLE, XML_TOK_CHART_SUBTITLE },
+ { XML_NAMESPACE_CHART, XML_LEGEND, XML_TOK_CHART_LEGEND },
+ { XML_NAMESPACE_TABLE, XML_TABLE, XML_TOK_CHART_TABLE },
+ XML_TOKEN_MAP_END
+ };
+
+ mpChartElemTokenMap = new SvXMLTokenMap( aChartElemTokenMap );
+ } // if( ! mpChartElemTokenMap )
+
+ return *mpChartElemTokenMap;
+}
+
+const SvXMLTokenMap& SchXMLImportHelper::GetPlotAreaElemTokenMap()
+{
+ if( ! mpPlotAreaElemTokenMap )
+ {
+ static __FAR_DATA SvXMLTokenMapEntry aPlotAreaElemTokenMap[] =
+{
+ { XML_NAMESPACE_CHART_EXT, XML_COORDINATE_REGION, XML_TOK_PA_COORDINATE_REGION_EXT },
+ { XML_NAMESPACE_CHART, XML_COORDINATE_REGION, XML_TOK_PA_COORDINATE_REGION },
+ { XML_NAMESPACE_CHART, XML_AXIS, XML_TOK_PA_AXIS },
+ { XML_NAMESPACE_CHART, XML_SERIES, XML_TOK_PA_SERIES },
+ { XML_NAMESPACE_CHART, XML_WALL, XML_TOK_PA_WALL },
+ { XML_NAMESPACE_CHART, XML_FLOOR, XML_TOK_PA_FLOOR },
+ { XML_NAMESPACE_DR3D, XML_LIGHT, XML_TOK_PA_LIGHT_SOURCE },
+ { XML_NAMESPACE_CHART, XML_STOCK_GAIN_MARKER, XML_TOK_PA_STOCK_GAIN },
+ { XML_NAMESPACE_CHART, XML_STOCK_LOSS_MARKER, XML_TOK_PA_STOCK_LOSS },
+ { XML_NAMESPACE_CHART, XML_STOCK_RANGE_LINE, XML_TOK_PA_STOCK_RANGE },
+ XML_TOKEN_MAP_END
+};
+
+ mpPlotAreaElemTokenMap = new SvXMLTokenMap( aPlotAreaElemTokenMap );
+ } // if( ! mpPlotAreaElemTokenMap )
+
+ return *mpPlotAreaElemTokenMap;
+}
+
+const SvXMLTokenMap& SchXMLImportHelper::GetSeriesElemTokenMap()
+{
+ if( ! mpSeriesElemTokenMap )
+ {
+ static __FAR_DATA SvXMLTokenMapEntry aSeriesElemTokenMap[] =
+{
+ { XML_NAMESPACE_CHART, XML_DATA_POINT, XML_TOK_SERIES_DATA_POINT },
+ { XML_NAMESPACE_CHART, XML_DOMAIN, XML_TOK_SERIES_DOMAIN },
+ { XML_NAMESPACE_CHART, XML_MEAN_VALUE, XML_TOK_SERIES_MEAN_VALUE_LINE },
+ { XML_NAMESPACE_CHART, XML_REGRESSION_CURVE, XML_TOK_SERIES_REGRESSION_CURVE },
+ { XML_NAMESPACE_CHART, XML_ERROR_INDICATOR, XML_TOK_SERIES_ERROR_INDICATOR },
+ XML_TOKEN_MAP_END
+};
+
+ mpSeriesElemTokenMap = new SvXMLTokenMap( aSeriesElemTokenMap );
+ } // if( ! mpSeriesElemTokenMap )
+
+ return *mpSeriesElemTokenMap;
+}
+
+const SvXMLTokenMap& SchXMLImportHelper::GetAxisElemTokenMap()
+{
+ if( ! mpAxisElemTokenMap )
+ {
+ static __FAR_DATA SvXMLTokenMapEntry aAxisElemTokenMap[] =
+{
+ { XML_NAMESPACE_CHART, XML_TITLE, XML_TOK_AXIS_TITLE },
+ { XML_NAMESPACE_CHART, XML_CATEGORIES, XML_TOK_AXIS_CATEGORIES },
+ { XML_NAMESPACE_CHART, XML_GRID, XML_TOK_AXIS_GRID },
+ XML_TOKEN_MAP_END
+};
+
+ mpAxisElemTokenMap = new SvXMLTokenMap( aAxisElemTokenMap );
+ } // if( ! mpAxisElemTokenMap )
+
+ return *mpAxisElemTokenMap;
+}
+
+// ----------------------------------------
+
+const SvXMLTokenMap& SchXMLImportHelper::GetChartAttrTokenMap()
+{
+ if( ! mpChartAttrTokenMap )
+ {
+ static __FAR_DATA SvXMLTokenMapEntry aChartAttrTokenMap[] =
+{
+ { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_CHART_HREF },
+ { XML_NAMESPACE_CHART, XML_CLASS, XML_TOK_CHART_CLASS },
+ { XML_NAMESPACE_SVG, XML_WIDTH, XML_TOK_CHART_WIDTH },
+ { XML_NAMESPACE_SVG, XML_HEIGHT, XML_TOK_CHART_HEIGHT },
+ { XML_NAMESPACE_CHART, XML_STYLE_NAME, XML_TOK_CHART_STYLE_NAME },
+ { XML_NAMESPACE_CHART, XML_COLUMN_MAPPING, XML_TOK_CHART_COL_MAPPING },
+ { XML_NAMESPACE_CHART, XML_ROW_MAPPING, XML_TOK_CHART_ROW_MAPPING },
+ XML_TOKEN_MAP_END
+};
+
+ mpChartAttrTokenMap = new SvXMLTokenMap( aChartAttrTokenMap );
+ } // if( ! mpChartAttrTokenMap )
+
+ return *mpChartAttrTokenMap;
+}
+
+const SvXMLTokenMap& SchXMLImportHelper::GetPlotAreaAttrTokenMap()
+{
+ if( ! mpPlotAreaAttrTokenMap )
+ {
+ static __FAR_DATA SvXMLTokenMapEntry aPlotAreaAttrTokenMap[] =
+{
+ { XML_NAMESPACE_SVG, XML_X, XML_TOK_PA_X },
+ { XML_NAMESPACE_SVG, XML_Y, XML_TOK_PA_Y },
+ { XML_NAMESPACE_SVG, XML_WIDTH, XML_TOK_PA_WIDTH },
+ { XML_NAMESPACE_SVG, XML_HEIGHT, XML_TOK_PA_HEIGHT },
+ { XML_NAMESPACE_CHART, XML_STYLE_NAME, XML_TOK_PA_STYLE_NAME },
+ { XML_NAMESPACE_TABLE, XML_CELL_RANGE_ADDRESS, XML_TOK_PA_CHART_ADDRESS },
+ { XML_NAMESPACE_CHART, XML_DATA_SOURCE_HAS_LABELS, XML_TOK_PA_DS_HAS_LABELS },
+ { XML_NAMESPACE_DR3D, XML_TRANSFORM, XML_TOK_PA_TRANSFORM },
+ { XML_NAMESPACE_DR3D, XML_VRP, XML_TOK_PA_VRP },
+ { XML_NAMESPACE_DR3D, XML_VPN, XML_TOK_PA_VPN },
+ { XML_NAMESPACE_DR3D, XML_VUP, XML_TOK_PA_VUP },
+ { XML_NAMESPACE_DR3D, XML_PROJECTION, XML_TOK_PA_PROJECTION },
+ { XML_NAMESPACE_DR3D, XML_DISTANCE, XML_TOK_PA_DISTANCE },
+ { XML_NAMESPACE_DR3D, XML_FOCAL_LENGTH, XML_TOK_PA_FOCAL_LENGTH },
+ { XML_NAMESPACE_DR3D, XML_SHADOW_SLANT, XML_TOK_PA_SHADOW_SLANT },
+ { XML_NAMESPACE_DR3D, XML_SHADE_MODE, XML_TOK_PA_SHADE_MODE },
+ { XML_NAMESPACE_DR3D, XML_AMBIENT_COLOR, XML_TOK_PA_AMBIENT_COLOR },
+ { XML_NAMESPACE_DR3D, XML_LIGHTING_MODE, XML_TOK_PA_LIGHTING_MODE },
+ XML_TOKEN_MAP_END
+};
+
+ mpPlotAreaAttrTokenMap = new SvXMLTokenMap( aPlotAreaAttrTokenMap );
+ } // if( ! mpPlotAreaAttrTokenMap )
+
+ return *mpPlotAreaAttrTokenMap;
+}
+
+const SvXMLTokenMap& SchXMLImportHelper::GetAxisAttrTokenMap()
+{
+ if( ! mpAxisAttrTokenMap )
+ {
+ static __FAR_DATA SvXMLTokenMapEntry aAxisAttrTokenMap[] =
+{
+ { XML_NAMESPACE_CHART, XML_DIMENSION, XML_TOK_AXIS_DIMENSION },
+ { XML_NAMESPACE_CHART, XML_NAME, XML_TOK_AXIS_NAME },
+ { XML_NAMESPACE_CHART, XML_STYLE_NAME, XML_TOK_AXIS_STYLE_NAME },
+ XML_TOKEN_MAP_END
+};
+
+ mpAxisAttrTokenMap = new SvXMLTokenMap( aAxisAttrTokenMap );
+ } // if( ! mpAxisAttrTokenMap )
+
+ return *mpAxisAttrTokenMap;
+}
+
+const SvXMLTokenMap& SchXMLImportHelper::GetLegendAttrTokenMap()
+{
+ if( ! mpLegendAttrTokenMap )
+ {
+ static __FAR_DATA SvXMLTokenMapEntry aLegendAttrTokenMap[] =
+{
+ { XML_NAMESPACE_CHART, XML_LEGEND_POSITION, XML_TOK_LEGEND_POSITION },
+ { XML_NAMESPACE_SVG, XML_X, XML_TOK_LEGEND_X },
+ { XML_NAMESPACE_SVG, XML_Y, XML_TOK_LEGEND_Y },
+ { XML_NAMESPACE_CHART, XML_STYLE_NAME, XML_TOK_LEGEND_STYLE_NAME },
+ XML_TOKEN_MAP_END
+};
+
+ mpLegendAttrTokenMap = new SvXMLTokenMap( aLegendAttrTokenMap );
+ } // if( ! mpLegendAttrTokenMap )
+
+ return *mpLegendAttrTokenMap;
+}
+
+const SvXMLTokenMap& SchXMLImportHelper::GetAutoStyleAttrTokenMap()
+{
+ if( ! mpAutoStyleAttrTokenMap )
+ {
+ static __FAR_DATA SvXMLTokenMapEntry aAutoStyleAttrTokenMap[] =
+{
+ { XML_NAMESPACE_STYLE, XML_FAMILY, XML_TOK_AS_FAMILY },
+ { XML_NAMESPACE_STYLE, XML_NAME, XML_TOK_AS_NAME },
+ XML_TOKEN_MAP_END
+};
+
+ mpAutoStyleAttrTokenMap = new SvXMLTokenMap( aAutoStyleAttrTokenMap );
+ } // if( ! mpAutoStyleAttrTokenMap )
+
+ return *mpAutoStyleAttrTokenMap;
+}
+
+const SvXMLTokenMap& SchXMLImportHelper::GetCellAttrTokenMap()
+{
+ if( ! mpCellAttrTokenMap )
+ {
+ static __FAR_DATA SvXMLTokenMapEntry aCellAttrTokenMap[] =
+{
+ { XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_TOK_CELL_VAL_TYPE },
+ { XML_NAMESPACE_OFFICE, XML_VALUE, XML_TOK_CELL_VALUE },
+ XML_TOKEN_MAP_END
+};
+
+ mpCellAttrTokenMap = new SvXMLTokenMap( aCellAttrTokenMap );
+ } // if( ! mpCellAttrTokenMap )
+
+ return *mpCellAttrTokenMap;
+}
+
+const SvXMLTokenMap& SchXMLImportHelper::GetSeriesAttrTokenMap()
+{
+ if( ! mpSeriesAttrTokenMap )
+ {
+ static __FAR_DATA SvXMLTokenMapEntry aSeriesAttrTokenMap[] =
+{
+ { XML_NAMESPACE_CHART, XML_VALUES_CELL_RANGE_ADDRESS, XML_TOK_SERIES_CELL_RANGE },
+ { XML_NAMESPACE_CHART, XML_LABEL_CELL_ADDRESS, XML_TOK_SERIES_LABEL_ADDRESS },
+ { XML_NAMESPACE_CHART, XML_ATTACHED_AXIS, XML_TOK_SERIES_ATTACHED_AXIS },
+ { XML_NAMESPACE_CHART, XML_STYLE_NAME, XML_TOK_SERIES_STYLE_NAME },
+ { XML_NAMESPACE_CHART, XML_CLASS, XML_TOK_SERIES_CHART_CLASS },
+ XML_TOKEN_MAP_END
+};
+
+ mpSeriesAttrTokenMap = new SvXMLTokenMap( aSeriesAttrTokenMap );
+ } // if( ! mpSeriesAttrTokenMap )
+
+ return *mpSeriesAttrTokenMap;
+}
+
+const SvXMLTokenMap& SchXMLImportHelper::GetRegEquationAttrTokenMap()
+{
+ if( ! mpRegEquationAttrTokenMap )
+ {
+ static __FAR_DATA SvXMLTokenMapEntry aRegressionEquationAttrTokenMap[] =
+{
+ { XML_NAMESPACE_CHART, XML_STYLE_NAME, XML_TOK_REGEQ_STYLE_NAME },
+ { XML_NAMESPACE_CHART, XML_DISPLAY_EQUATION, XML_TOK_REGEQ_DISPLAY_EQUATION },
+ { XML_NAMESPACE_CHART, XML_DISPLAY_R_SQUARE, XML_TOK_REGEQ_DISPLAY_R_SQUARE },
+ { XML_NAMESPACE_SVG, XML_X, XML_TOK_REGEQ_POS_X },
+ { XML_NAMESPACE_SVG, XML_Y, XML_TOK_REGEQ_POS_Y },
+ XML_TOKEN_MAP_END
+};
+
+ mpRegEquationAttrTokenMap = new SvXMLTokenMap( aRegressionEquationAttrTokenMap );
+ } // if( ! mpRegEquationAttrTokenMap )
+
+ return *mpRegEquationAttrTokenMap;
+}
+
+// ----------------------------------------
+
+//static
+void SchXMLImportHelper::DeleteDataSeries(
+ const Reference< chart2::XDataSeries > & xSeries,
+ const Reference< chart2::XChartDocument > & xDoc )
+{
+ if( xDoc.is() )
+ try
+ {
+ Reference< chart2::XCoordinateSystemContainer > xCooSysCnt(
+ xDoc->getFirstDiagram(), uno::UNO_QUERY_THROW );
+ Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq(
+ xCooSysCnt->getCoordinateSystems());
+
+ sal_Int32 nCooSysIndex = 0;
+ for( nCooSysIndex=0; nCooSysIndex<aCooSysSeq.getLength(); nCooSysIndex++ )
+ {
+ Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[ nCooSysIndex ], uno::UNO_QUERY_THROW );
+ Sequence< Reference< chart2::XChartType > > aChartTypes( xCTCnt->getChartTypes());
+
+ sal_Int32 nChartTypeIndex = 0;
+ for( nChartTypeIndex=0; nChartTypeIndex<aChartTypes.getLength(); nChartTypeIndex++ )
+ {
+ Reference< chart2::XDataSeriesContainer > xSeriesCnt( aChartTypes[nChartTypeIndex], uno::UNO_QUERY_THROW );
+ Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xSeriesCnt->getDataSeries());
+
+ sal_Int32 nSeriesIndex = 0;
+ for( nSeriesIndex=0; nSeriesIndex<aSeriesSeq.getLength(); nSeriesIndex++ )
+ {
+ if( xSeries==aSeriesSeq[nSeriesIndex] )
+ {
+ xSeriesCnt->removeDataSeries(xSeries);
+ return;
+ }
+ }
+ }
+ }
+ }
+ catch( uno::Exception & ex )
+ {
+ (void)ex; // avoid warning for pro build
+ OSL_ENSURE( false, OUStringToOString(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "Exception caught. Type: " )) +
+ OUString::createFromAscii( typeid( ex ).name()) +
+ OUString( RTL_CONSTASCII_USTRINGPARAM( ", Message: " )) +
+ ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
+ }
+}
+
+// static
+Reference< chart2::XDataSeries > SchXMLImportHelper::GetNewDataSeries(
+ const Reference< chart2::XChartDocument > & xDoc,
+ sal_Int32 nCoordinateSystemIndex,
+ const OUString & rChartTypeName,
+ bool bPushLastChartType /* = false */ )
+{
+ Reference< chart2::XDataSeries > xResult;
+ if(!xDoc.is())
+ return xResult;
+
+ try
+ {
+ Reference< chart2::XCoordinateSystemContainer > xCooSysCnt(
+ xDoc->getFirstDiagram(), uno::UNO_QUERY_THROW );
+ Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq(
+ xCooSysCnt->getCoordinateSystems());
+ Reference< uno::XComponentContext > xContext( lcl_getComponentContext());
+
+ if( nCoordinateSystemIndex < aCooSysSeq.getLength())
+ {
+ Reference< chart2::XChartType > xCurrentType;
+ {
+ Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[ nCoordinateSystemIndex ], uno::UNO_QUERY_THROW );
+ Sequence< Reference< chart2::XChartType > > aChartTypes( xCTCnt->getChartTypes());
+ // find matching chart type group
+ const Reference< chart2::XChartType > * pBegin = aChartTypes.getConstArray();
+ const Reference< chart2::XChartType > * pEnd = pBegin + aChartTypes.getLength();
+ const Reference< chart2::XChartType > * pIt =
+ ::std::find_if( pBegin, pEnd, lcl_MatchesChartType( rChartTypeName ));
+ if( pIt != pEnd )
+ xCurrentType.set( *pIt );
+ // if chart type is set at series and differs from current one,
+ // create a new chart type
+ if( !xCurrentType.is())
+ {
+ xCurrentType.set(
+ xContext->getServiceManager()->createInstanceWithContext( rChartTypeName, xContext ),
+ uno::UNO_QUERY );
+ if( xCurrentType.is())
+ {
+ if( bPushLastChartType && aChartTypes.getLength())
+ {
+ sal_Int32 nIndex( aChartTypes.getLength() - 1 );
+ aChartTypes.realloc( aChartTypes.getLength() + 1 );
+ aChartTypes[ nIndex + 1 ] = aChartTypes[ nIndex ];
+ aChartTypes[ nIndex ] = xCurrentType;
+ xCTCnt->setChartTypes( aChartTypes );
+ }
+ else
+ xCTCnt->addChartType( xCurrentType );
+ }
+ }
+ }
+
+ if( xCurrentType.is())
+ {
+ Reference< chart2::XDataSeriesContainer > xSeriesCnt( xCurrentType, uno::UNO_QUERY_THROW );
+ Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xSeriesCnt->getDataSeries());
+
+ if( xContext.is() )
+ {
+ xResult.set(
+ xContext->getServiceManager()->createInstanceWithContext(
+ OUString::createFromAscii("com.sun.star.chart2.DataSeries"),
+ xContext ), uno::UNO_QUERY_THROW );
+ }
+ if( xResult.is() )
+ xSeriesCnt->addDataSeries( xResult );
+ }
+ }
+ }
+ catch( uno::Exception & ex )
+ {
+ (void)ex; // avoid warning for pro build
+ OSL_ENSURE( false, OUStringToOString(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "Exception caught. Type: " )) +
+ OUString::createFromAscii( typeid( ex ).name()) +
+ OUString( RTL_CONSTASCII_USTRINGPARAM( ", Message: " )) +
+ ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
+ }
+ return xResult;
+}
+
+// static
+Reference< chart2::data::XLabeledDataSequence > SchXMLImportHelper::GetNewLabeledDataSequence()
+{
+ // @todo: remove this asap
+ OSL_ENSURE( false, "Do not call this method" );
+ Reference< chart2::data::XLabeledDataSequence > xResult;
+ // DO NOT USED -- DEPRECATED. Use SchXMLTools::GetNewLabeledDataSequence() instead
+ return xResult;
+}
+
+// ========================================
+
+// #110680#
+SchXMLImport::SchXMLImport(
+ const Reference< lang::XMultiServiceFactory >& xServiceFactory,
+ sal_uInt16 nImportFlags ) :
+ SvXMLImport( xServiceFactory, nImportFlags )
+{
+ GetNamespaceMap().Add( GetXMLToken(XML_NP_XLINK), GetXMLToken(XML_N_XLINK), XML_NAMESPACE_XLINK );
+ GetNamespaceMap().Add( GetXMLToken(XML_NP_CHART_EXT), GetXMLToken(XML_N_CHART_EXT), XML_NAMESPACE_CHART_EXT);
+
+ mbIsGraphicLoadOnDemandSupported = false;
+}
+
+// #110680#
+SchXMLImport::SchXMLImport(
+ const Reference< lang::XMultiServiceFactory >& xServiceFactory,
+ Reference< frame::XModel > xModel,
+ Reference< document::XGraphicObjectResolver >& rGrfContainer,
+ sal_Bool /*bLoadDoc*/, sal_Bool bShowProgress )
+: SvXMLImport( xServiceFactory, xModel, rGrfContainer )
+{
+ GetNamespaceMap().Add( GetXMLToken(XML_NP_XLINK), GetXMLToken(XML_N_XLINK), XML_NAMESPACE_XLINK );
+ GetNamespaceMap().Add( GetXMLToken(XML_NP_CHART_EXT), GetXMLToken(XML_N_CHART_EXT), XML_NAMESPACE_CHART_EXT);
+
+ // get status indicator (if requested)
+ if( bShowProgress )
+ {
+ Reference< frame::XController > xController( xModel->getCurrentController());
+ if( xController.is())
+ {
+ Reference< frame::XFrame > xFrame( xController->getFrame());
+ if( xFrame.is())
+ {
+ Reference< task::XStatusIndicatorSupplier > xFactory( xFrame, uno::UNO_QUERY );
+ if( xFactory.is())
+ {
+ mxStatusIndicator = xFactory->getStatusIndicator();
+ }
+ }
+ }
+ }
+
+ // add progress view
+ if( mxStatusIndicator.is())
+ {
+ const OUString aText( RTL_CONSTASCII_USTRINGPARAM( "XML Import" ));
+ mxStatusIndicator->start( aText, 100 ); // use percentage as values
+ }
+}
+
+SchXMLImport::~SchXMLImport() throw ()
+{
+ // stop progress view
+ if( mxStatusIndicator.is())
+ {
+ mxStatusIndicator->end();
+ mxStatusIndicator->reset();
+ }
+
+ uno::Reference< chart2::XChartDocument > xChartDoc( GetModel(), uno::UNO_QUERY );
+ if( xChartDoc.is() && xChartDoc->hasControllersLocked() )
+ xChartDoc->unlockControllers();
+}
+
+// create the main context (subcontexts are created
+// by the one created here)
+SvXMLImportContext *SchXMLImport::CreateContext( USHORT nPrefix, const OUString& rLocalName,
+ const Reference< xml::sax::XAttributeList >& xAttrList )
+{
+ SvXMLImportContext* pContext = 0;
+
+ // accept <office:document>
+ if( XML_NAMESPACE_OFFICE == nPrefix &&
+ ( IsXMLToken( rLocalName, XML_DOCUMENT_STYLES) ||
+ IsXMLToken( rLocalName, XML_DOCUMENT_CONTENT) ))
+ {
+ pContext = new SchXMLDocContext( maImportHelper, *this, nPrefix, rLocalName );
+ } else if ( (XML_NAMESPACE_OFFICE == nPrefix) &&
+ ( IsXMLToken(rLocalName, XML_DOCUMENT) ||
+ (IsXMLToken(rLocalName, XML_DOCUMENT_META)
+ && (getImportFlags() & IMPORT_META) )) )
+ {
+ uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
+ GetModel(), uno::UNO_QUERY);
+ // mst@: right now, this seems to be not supported, so it is untested
+ if (xDPS.is()) {
+ uno::Reference<xml::sax::XDocumentHandler> xDocBuilder(
+ mxServiceFactory->createInstance(
+ ::rtl::OUString::createFromAscii(
+ "com.sun.star.xml.dom.SAXDocumentBuilder")),
+ uno::UNO_QUERY_THROW);
+ pContext = (IsXMLToken(rLocalName, XML_DOCUMENT_META))
+ ? new SvXMLMetaDocumentContext(*this,
+ XML_NAMESPACE_OFFICE, rLocalName,
+ xDPS->getDocumentProperties(), xDocBuilder)
+ // flat OpenDocument file format
+ : new SchXMLFlatDocContext_Impl(
+ maImportHelper, *this, nPrefix, rLocalName,
+ xDPS->getDocumentProperties(), xDocBuilder);
+ } else {
+ pContext = (IsXMLToken(rLocalName, XML_DOCUMENT_META))
+ ? SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList )
+ : new SchXMLDocContext( maImportHelper, *this,
+ nPrefix, rLocalName );
+ }
+ } else {
+ pContext = SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList );
+ }
+
+ return pContext;
+}
+
+SvXMLImportContext* SchXMLImport::CreateStylesContext(
+ const OUString& rLocalName,
+ const Reference<xml::sax::XAttributeList>& xAttrList )
+{
+ //#i103287# make sure that the version information is set before importing all the properties (especially stroke-opacity!)
+ SchXMLTools::setBuildIDAtImportInfo( GetModel(), getImportInfo() );
+
+ SvXMLStylesContext* pStylesCtxt =
+ new SvXMLStylesContext( *(this), XML_NAMESPACE_OFFICE, rLocalName, xAttrList );
+
+ // set context at base class, so that all auto-style classes are imported
+ SetAutoStyles( pStylesCtxt );
+ maImportHelper.SetAutoStylesContext( pStylesCtxt );
+
+ return pStylesCtxt;
+}
+
+void SAL_CALL SchXMLImport::setTargetDocument( const uno::Reference< lang::XComponent >& xDoc )
+ throw(lang::IllegalArgumentException, uno::RuntimeException)
+{
+ uno::Reference< chart2::XChartDocument > xOldDoc( GetModel(), uno::UNO_QUERY );
+ if( xOldDoc.is() && xOldDoc->hasControllersLocked() )
+ xOldDoc->unlockControllers();
+
+ SvXMLImport::setTargetDocument( xDoc );
+
+ //set data provider and number formatter
+ // try to get an XDataProvider and set it
+ // @todo: if we have our own data, we must not use the parent as data provider
+ uno::Reference< chart2::XChartDocument > xChartDoc( GetModel(), uno::UNO_QUERY );
+
+ if( xChartDoc.is() )
+ try
+ {
+ //prevent rebuild of view during load ( necesarry especially if loaded not via load api, which is the case for example if binary files are loaded )
+ xChartDoc->lockControllers();
+
+ uno::Reference< container::XChild > xChild( xChartDoc, uno::UNO_QUERY );
+ uno::Reference< chart2::data::XDataReceiver > xDataReceiver( xChartDoc, uno::UNO_QUERY );
+ bool bHasOwnData = true;
+ if( xChild.is() && xDataReceiver.is())
+ {
+ Reference< lang::XMultiServiceFactory > xFact( xChild->getParent(), uno::UNO_QUERY );
+ if( xFact.is() )
+ {
+ //if the parent has a number formatter we will use the numberformatter of the parent
+ Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier( xFact, uno::UNO_QUERY );
+ xDataReceiver->attachNumberFormatsSupplier( xNumberFormatsSupplier );
+
+ if ( !xChartDoc->getDataProvider().is() )
+ {
+ const OUString aDataProviderServiceName( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart2.data.DataProvider"));
+ const uno::Sequence< OUString > aServiceNames( xFact->getAvailableServiceNames());
+ const OUString * pBegin = aServiceNames.getConstArray();
+ const OUString * pEnd = pBegin + aServiceNames.getLength();
+ if( ::std::find( pBegin, pEnd, aDataProviderServiceName ) != pEnd )
+ {
+ Reference< chart2::data::XDataProvider > xProvider(
+ xFact->createInstance( aDataProviderServiceName ), uno::UNO_QUERY );
+ if( xProvider.is())
+ {
+ xDataReceiver->attachDataProvider( xProvider );
+ bHasOwnData = false;
+ }
+ }
+ }
+ else
+ bHasOwnData = false;
+ }
+// else we have no parent => we have our own data
+
+ if( bHasOwnData && ! xChartDoc->hasInternalDataProvider() )
+ xChartDoc->createInternalDataProvider( sal_False );
+ }
+ }
+ catch( uno::Exception & rEx )
+ {
+#ifdef DBG_UTIL
+ String aStr( rEx.Message );
+ ByteString aBStr( aStr, RTL_TEXTENCODING_ASCII_US );
+ DBG_ERROR1( "SchXMLChartContext::StartElement(): Exception caught: %s", aBStr.GetBuffer());
+#else
+ (void)rEx; // avoid warning for pro build
+#endif
+ }
+}
+
+// export components ========================================
+
+// first version: everything comes from one storage
+
+Sequence< OUString > SAL_CALL SchXMLImport_getSupportedServiceNames() throw()
+{
+ const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Chart.XMLOasisImporter" ) );
+ const Sequence< OUString > aSeq( &aServiceName, 1 );
+ return aSeq;
+}
+
+OUString SAL_CALL SchXMLImport_getImplementationName() throw()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "SchXMLImport" ) );
+}
+
+Reference< uno::XInterface > SAL_CALL SchXMLImport_createInstance(const Reference< lang::XMultiServiceFactory > & rSMgr) throw( uno::Exception )
+{
+ // #110680#
+ // return (cppu::OWeakObject*)new SchXMLImport();
+ return (cppu::OWeakObject*)new SchXMLImport(rSMgr);
+}
+
+// ============================================================
+
+// multiple storage version: one for content / styles / meta
+
+Sequence< OUString > SAL_CALL SchXMLImport_Styles_getSupportedServiceNames() throw()
+{
+ const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Chart.XMLOasisStylesImporter" ) );
+ const Sequence< OUString > aSeq( &aServiceName, 1 );
+ return aSeq;
+}
+
+OUString SAL_CALL SchXMLImport_Styles_getImplementationName() throw()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "SchXMLImport.Styles" ) );
+}
+
+Reference< uno::XInterface > SAL_CALL SchXMLImport_Styles_createInstance(const Reference< lang::XMultiServiceFactory > & rSMgr) throw( uno::Exception )
+{
+ // #110680#
+ // return (cppu::OWeakObject*)new SchXMLImport( IMPORT_STYLES );
+ return (cppu::OWeakObject*)new SchXMLImport( rSMgr, IMPORT_STYLES );
+}
+
+// ------------------------------------------------------------
+
+Sequence< OUString > SAL_CALL SchXMLImport_Content_getSupportedServiceNames() throw()
+{
+ const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Chart.XMLOasisContentImporter" ) );
+ const Sequence< OUString > aSeq( &aServiceName, 1 );
+ return aSeq;
+}
+
+OUString SAL_CALL SchXMLImport_Content_getImplementationName() throw()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "SchXMLImport.Content" ) );
+}
+
+Reference< uno::XInterface > SAL_CALL SchXMLImport_Content_createInstance(const Reference< lang::XMultiServiceFactory > & rSMgr) throw( uno::Exception )
+{
+ // #110680#
+ // return (cppu::OWeakObject*)new SchXMLImport( IMPORT_CONTENT | IMPORT_AUTOSTYLES | IMPORT_FONTDECLS );
+ return (cppu::OWeakObject*)new SchXMLImport( rSMgr, IMPORT_CONTENT | IMPORT_AUTOSTYLES | IMPORT_FONTDECLS );
+}
+
+// ------------------------------------------------------------
+
+Sequence< OUString > SAL_CALL SchXMLImport_Meta_getSupportedServiceNames() throw()
+{
+ const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Chart.XMLOasisMetaImporter" ) );
+ const Sequence< OUString > aSeq( &aServiceName, 1 );
+ return aSeq;
+}
+
+OUString SAL_CALL SchXMLImport_Meta_getImplementationName() throw()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "SchXMLImport.Meta" ) );
+}
+
+Reference< uno::XInterface > SAL_CALL SchXMLImport_Meta_createInstance(const Reference< lang::XMultiServiceFactory > & rSMgr) throw( uno::Exception )
+{
+ // #110680#
+ // return (cppu::OWeakObject*)new SchXMLImport( IMPORT_META );
+ return (cppu::OWeakObject*)new SchXMLImport( rSMgr, IMPORT_META );
+}
+
+// XServiceInfo
+OUString SAL_CALL SchXMLImport::getImplementationName() throw( uno::RuntimeException )
+{
+ switch( getImportFlags())
+ {
+ case IMPORT_ALL:
+ return SchXMLImport_getImplementationName();
+ case IMPORT_STYLES:
+ return SchXMLImport_Styles_getImplementationName();
+ case ( IMPORT_CONTENT | IMPORT_AUTOSTYLES | IMPORT_FONTDECLS ):
+ return SchXMLImport_Content_getImplementationName();
+ case IMPORT_META:
+ return SchXMLImport_Meta_getImplementationName();
+
+ case IMPORT_SETTINGS:
+ // there is no settings component in chart
+ default:
+ return OUString::createFromAscii( "SchXMLImport" );
+ }
+}
diff --git a/xmloff/source/chart/SchXMLParagraphContext.cxx b/xmloff/source/chart/SchXMLParagraphContext.cxx
new file mode 100644
index 000000000000..972bc9016d4f
--- /dev/null
+++ b/xmloff/source/chart/SchXMLParagraphContext.cxx
@@ -0,0 +1,118 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmloff.hxx"
+
+#include "SchXMLImport.hxx"
+#include "SchXMLParagraphContext.hxx"
+
+#include "xmlnmspe.hxx"
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/nmspmap.hxx>
+
+using ::rtl::OUString;
+using namespace com::sun::star;
+using namespace ::xmloff::token;
+
+SchXMLParagraphContext::SchXMLParagraphContext( SvXMLImport& rImport,
+ const OUString& rLocalName,
+ OUString& rText,
+ OUString * pOutId /* = 0 */ ) :
+ SvXMLImportContext( rImport, XML_NAMESPACE_TEXT, rLocalName ),
+ mrText( rText ),
+ mpId( pOutId )
+{
+}
+
+SchXMLParagraphContext::~SchXMLParagraphContext()
+{}
+
+void SchXMLParagraphContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
+{
+ // remember the id. It is used for storing the original cell range string in
+ // a local table (cached data)
+ if( mpId )
+ {
+ sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
+ rtl::OUString aValue;
+ bool bHaveXmlId( false );
+
+ for( sal_Int16 i = 0; i < nAttrCount; i++ )
+ {
+ rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
+ rtl::OUString aLocalName;
+ USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
+
+ if (IsXMLToken(aLocalName, XML_ID))
+ {
+ if (nPrefix == XML_NAMESPACE_XML)
+ {
+ (*mpId) = xAttrList->getValueByIndex( i );
+ bHaveXmlId = true;
+ }
+ if (nPrefix == XML_NAMESPACE_TEXT)
+ { // text:id shall be ignored if xml:id exists
+ if (!bHaveXmlId)
+ {
+ (*mpId) = xAttrList->getValueByIndex( i );
+ }
+ }
+ }
+ }
+ }
+}
+
+void SchXMLParagraphContext::EndElement()
+{
+ mrText = maBuffer.makeStringAndClear();
+}
+
+SvXMLImportContext* SchXMLParagraphContext::CreateChildContext(
+ USHORT nPrefix,
+ const OUString& rLocalName,
+ const uno::Reference< xml::sax::XAttributeList >& )
+{
+ if( nPrefix == XML_NAMESPACE_TEXT )
+ {
+ if( rLocalName.equals( ::xmloff::token::GetXMLToken( ::xmloff::token::XML_TAB_STOP )))
+ {
+ maBuffer.append( sal_Unicode( 0x0009 )); // tabulator
+ }
+ else if( rLocalName.equals( ::xmloff::token::GetXMLToken( ::xmloff::token::XML_LINE_BREAK )))
+ {
+ maBuffer.append( sal_Unicode( 0x000A )); // linefeed
+ }
+ }
+
+ return new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+}
+
+void SchXMLParagraphContext::Characters( const OUString& rChars )
+{
+ maBuffer.append( rChars );
+}
diff --git a/xmloff/source/chart/SchXMLParagraphContext.hxx b/xmloff/source/chart/SchXMLParagraphContext.hxx
new file mode 100644
index 000000000000..a40c305d5d2c
--- /dev/null
+++ b/xmloff/source/chart/SchXMLParagraphContext.hxx
@@ -0,0 +1,64 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _SCH_XMLPARAGRAPHCONTEXT_HXX_
+#define _SCH_XMLPARAGRAPHCONTEXT_HXX_
+
+#include <xmloff/xmlictxt.hxx>
+#include "rtl/ustring.hxx"
+#include "rtl/ustrbuf.hxx"
+
+class SchXMLImport;
+
+namespace com { namespace sun { namespace star { namespace xml { namespace sax {
+ class XAttributeList;
+}}}}}
+
+class SchXMLParagraphContext : public SvXMLImportContext
+{
+private:
+ ::rtl::OUString& mrText;
+ ::rtl::OUString* mpId;
+ ::rtl::OUStringBuffer maBuffer;
+
+public:
+ SchXMLParagraphContext( SvXMLImport& rImport,
+ const ::rtl::OUString& rLocalName,
+ ::rtl::OUString& rText,
+ ::rtl::OUString * pOutId = 0 );
+ virtual ~SchXMLParagraphContext();
+ virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
+ virtual void EndElement();
+
+ virtual SvXMLImportContext* CreateChildContext(
+ USHORT nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList );
+
+ virtual void Characters( const rtl::OUString& rChars );
+};
+
+#endif // _SCH_XMLPARAGRAPHCONTEXT_HXX_
diff --git a/xmloff/source/chart/SchXMLPlotAreaContext.cxx b/xmloff/source/chart/SchXMLPlotAreaContext.cxx
new file mode 100644
index 000000000000..9b6731f78da3
--- /dev/null
+++ b/xmloff/source/chart/SchXMLPlotAreaContext.cxx
@@ -0,0 +1,2130 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmloff.hxx"
+
+#include "SchXMLPlotAreaContext.hxx"
+#include "SchXMLImport.hxx"
+#include "SchXMLSeries2Context.hxx"
+#include "SchXMLTools.hxx"
+#include <tools/debug.hxx>
+#ifdef DBG_UTIL
+#include <tools/string.hxx>
+#endif
+
+#include <comphelper/processfactory.hxx>
+#include "xmlnmspe.hxx"
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/xmlement.hxx>
+#include <xmloff/nmspmap.hxx>
+#include <xmloff/xmluconv.hxx>
+#include <xmloff/prstylei.hxx>
+#include <xmloff/xmlstyle.hxx>
+#include "xexptran.hxx"
+#include <cppuhelper/implbase1.hxx>
+
+#include <com/sun/star/awt/Point.hpp>
+#include <com/sun/star/awt/Size.hpp>
+
+#include <com/sun/star/chart/ChartAxisLabelPosition.hpp>
+#include <com/sun/star/chart/ChartAxisMarkPosition.hpp>
+#include <com/sun/star/chart/ChartAxisPosition.hpp>
+#include <com/sun/star/chart/XTwoAxisXSupplier.hpp>
+#include <com/sun/star/chart/XTwoAxisYSupplier.hpp>
+#include <com/sun/star/chart/XAxisZSupplier.hpp>
+#include <com/sun/star/chart/XSecondAxisTitleSupplier.hpp>
+#include <com/sun/star/chart/ChartDataRowSource.hpp>
+#include <com/sun/star/chart/X3DDisplay.hpp>
+#include <com/sun/star/chart/XStatisticDisplay.hpp>
+#include <com/sun/star/chart/XDiagramPositioning.hpp>
+
+#include <com/sun/star/chart2/XChartDocument.hpp>
+#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
+#include <com/sun/star/chart2/data/XRangeXMLConversion.hpp>
+#include <com/sun/star/chart2/XChartTypeContainer.hpp>
+#include <com/sun/star/chart2/XDataSeriesContainer.hpp>
+#include <com/sun/star/chart2/AxisType.hpp>
+#include <com/sun/star/chart2/RelativePosition.hpp>
+
+#include <com/sun/star/drawing/CameraGeometry.hpp>
+#include <com/sun/star/drawing/FillStyle.hpp>
+#include <com/sun/star/drawing/LineStyle.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/util/XStringMapping.hpp>
+#include <com/sun/star/xml/sax/XAttributeList.hpp>
+
+using namespace com::sun::star;
+using namespace ::xmloff::token;
+
+using ::rtl::OUString;
+using com::sun::star::uno::Reference;
+
+static __FAR_DATA SvXMLEnumMapEntry aXMLAxisClassMap[] =
+{
+ { XML_X, SCH_XML_AXIS_X },
+ { XML_Y, SCH_XML_AXIS_Y },
+ { XML_Z, SCH_XML_AXIS_Z },
+ { XML_TOKEN_INVALID, 0 }
+};
+
+namespace
+{
+
+struct lcl_AxisHasCategories : public ::std::unary_function< SchXMLAxis, bool >
+{
+ bool operator() ( const SchXMLAxis & rAxis )
+ {
+ return rAxis.bHasCategories;
+ }
+};
+
+OUString lcl_ConvertRange( const ::rtl::OUString & rRange, const uno::Reference< chart2::XChartDocument > & xDoc )
+{
+ OUString aResult = rRange;
+ if(!xDoc.is())
+ return aResult;
+ uno::Reference< chart2::data::XRangeXMLConversion > xConversion(
+ xDoc->getDataProvider(), uno::UNO_QUERY );
+ if( xConversion.is())
+ aResult = xConversion->convertRangeFromXML( rRange );
+ return aResult;
+}
+
+Reference< chart2::XAxis > lcl_getAxis( const Reference< chart2::XCoordinateSystem > xCooSys, sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex )
+{
+ Reference< chart2::XAxis > xAxis;
+ try
+ {
+ xAxis = xCooSys->getAxisByDimension( nDimensionIndex, nAxisIndex );
+ }
+ catch( uno::Exception & )
+ {
+ }
+ return xAxis;
+}
+
+} // anonymous namespace
+
+SchXML3DSceneAttributesHelper::SchXML3DSceneAttributesHelper( SvXMLImport& rImporter )
+ : SdXML3DSceneAttributesHelper( rImporter )
+{
+}
+
+void SchXML3DSceneAttributesHelper::getCameraDefaultFromDiagram( const uno::Reference< chart::XDiagram >& xDiagram )
+{
+ //different defaults for camera geometry necessary to workaround wrong behaviour in old chart
+ //in future make this version dependent if we have versioning (metastream) for ole objects
+
+ try
+ {
+ uno::Reference< beans::XPropertySet > xProp( xDiagram, uno::UNO_QUERY );
+ if( xProp.is() )
+ {
+ drawing::CameraGeometry aCamGeo;
+ xProp->getPropertyValue( ::rtl::OUString::createFromAscii("D3DCameraGeometry")) >>= aCamGeo;
+ maVRP.setX( aCamGeo.vrp.PositionX );
+ maVRP.setY( aCamGeo.vrp.PositionY );
+ maVRP.setZ( aCamGeo.vrp.PositionZ );
+ maVPN.setX( aCamGeo.vpn.DirectionX );
+ maVPN.setY( aCamGeo.vpn.DirectionY );
+ maVPN.setZ( aCamGeo.vpn.DirectionZ );
+ maVUP.setX( aCamGeo.vup.DirectionX );
+ maVUP.setY( aCamGeo.vup.DirectionY );
+ maVUP.setZ( aCamGeo.vup.DirectionZ );
+ }
+ }
+ catch( uno::Exception & rEx )
+ {
+#ifdef DBG_UTIL
+ String aStr( rEx.Message );
+ ByteString aBStr( aStr, RTL_TEXTENCODING_ASCII_US );
+ DBG_ERROR1( "Exception caught for property NumberOfLines: %s", aBStr.GetBuffer());
+#else
+ (void)rEx; // avoid warning for pro build
+#endif
+ }
+}
+
+SchXML3DSceneAttributesHelper::~SchXML3DSceneAttributesHelper()
+{
+}
+
+SchXMLPlotAreaContext::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 ) :
+ SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ),
+ mrImportHelper( rImpHelper ),
+ mrSeriesAddresses( rSeriesAddresses ),
+ mrCategoriesAddress( rCategoriesAddress ),
+ mrSeriesDefaultsAndStyles( rSeriesDefaultsAndStyles ),
+ mnNumOfLinesProp( 0 ),
+ mbStockHasVolume( sal_False ),
+ mnSeries( 0 ),
+ m_aGlobalSeriesImportInfo( rAllRangeAddressesAvailable ),
+ maSceneImportHelper( rImport ),
+ m_aOuterPositioning( rImport ),
+ m_aInnerPositioning( rImport ),
+ mbPercentStacked(false),
+ m_bAxisPositionAttributeImported(false),
+ m_rXLinkHRefAttributeToIndicateDataProvider(rXLinkHRefAttributeToIndicateDataProvider),
+ mrChartAddress( rChartAddress ),
+ m_rbHasRangeAtPlotArea( rbHasRangeAtPlotArea ),
+ mrColHasLabels( rColHasLabels ),
+ mrRowHasLabels( rRowHasLabels ),
+ mrDataRowSource( rDataRowSource ),
+ maChartTypeServiceName( aChartTypeServiceName ),
+ mrLSequencesPerIndex( rLSequencesPerIndex ),
+ mbGlobalChartTypeUsedBySeries( false ),
+ maChartSize( rChartSize )
+{
+ m_rbHasRangeAtPlotArea = false;
+
+ // get Diagram
+ uno::Reference< chart::XChartDocument > xDoc( rImpHelper.GetChartDocument(), uno::UNO_QUERY );
+ if( xDoc.is())
+ {
+ mxDiagram = xDoc->getDiagram();
+ mxNewDoc.set( xDoc, uno::UNO_QUERY );
+
+ maSceneImportHelper.getCameraDefaultFromDiagram( mxDiagram );
+ }
+ DBG_ASSERT( mxDiagram.is(), "Couldn't get XDiagram" );
+
+ // turn off all axes initially
+ uno::Any aFalseBool;
+ aFalseBool <<= (sal_Bool)(sal_False);
+
+ uno::Reference< lang::XServiceInfo > xInfo( mxDiagram, uno::UNO_QUERY );
+ uno::Reference< beans::XPropertySet > xProp( mxDiagram, uno::UNO_QUERY );
+ if( xInfo.is() &&
+ xProp.is())
+ {
+ try
+ {
+ if( xInfo->supportsService( rtl::OUString::createFromAscii( "com.sun.star.chart.ChartAxisXSupplier" )))
+ {
+ xProp->setPropertyValue(
+ rtl::OUString::createFromAscii( "HasXAxis" ), aFalseBool );
+ xProp->setPropertyValue(
+ rtl::OUString::createFromAscii( "HasXAxisGrid" ), aFalseBool );
+ xProp->setPropertyValue(
+ rtl::OUString::createFromAscii( "HasXAxisDescription" ), aFalseBool );
+ }
+ if( xInfo->supportsService( rtl::OUString::createFromAscii( "com.sun.star.chart.ChartTwoAxisXSupplier" )))
+ {
+ xProp->setPropertyValue(
+ rtl::OUString::createFromAscii( "HasSecondaryXAxis" ), aFalseBool );
+ xProp->setPropertyValue(
+ rtl::OUString::createFromAscii( "HasSecondaryXAxisDescription" ), aFalseBool );
+ }
+
+ if( xInfo->supportsService( rtl::OUString::createFromAscii( "com.sun.star.chart.ChartAxisYSupplier" )))
+ {
+ xProp->setPropertyValue(
+ rtl::OUString::createFromAscii( "HasYAxis" ), aFalseBool );
+ xProp->setPropertyValue(
+ rtl::OUString::createFromAscii( "HasYAxisGrid" ), aFalseBool );
+ xProp->setPropertyValue(
+ rtl::OUString::createFromAscii( "HasYAxisDescription" ), aFalseBool );
+ }
+ if( xInfo->supportsService( rtl::OUString::createFromAscii( "com.sun.star.chart.ChartTwoAxisYSupplier" )))
+ {
+ xProp->setPropertyValue(
+ rtl::OUString::createFromAscii( "HasSecondaryYAxis" ), aFalseBool );
+ xProp->setPropertyValue(
+ rtl::OUString::createFromAscii( "HasSecondaryYAxisDescription" ), aFalseBool );
+ }
+
+ if( xInfo->supportsService( rtl::OUString::createFromAscii( "com.sun.star.chart.ChartAxisZSupplier" )))
+ {
+ xProp->setPropertyValue(
+ rtl::OUString::createFromAscii( "HasZAxis" ), aFalseBool );
+ xProp->setPropertyValue(
+ rtl::OUString::createFromAscii( "HasZAxisDescription" ), aFalseBool );
+ }
+ uno::Any aAny;
+ chart::ChartDataRowSource eSource = chart::ChartDataRowSource_COLUMNS;
+ aAny <<= eSource;
+ xProp->setPropertyValue( rtl::OUString::createFromAscii( "DataRowSource" ), aAny );
+ }
+ catch( beans::UnknownPropertyException & )
+ {
+ DBG_ERROR( "Property required by service not supported" );
+ }
+ }
+}
+
+SchXMLPlotAreaContext::~SchXMLPlotAreaContext()
+{}
+
+void SchXMLPlotAreaContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
+{
+ // parse attributes
+ sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
+ const SvXMLTokenMap& rAttrTokenMap = mrImportHelper.GetPlotAreaAttrTokenMap();
+ uno::Reference< chart2::XChartDocument > xNewDoc( GetImport().GetModel(), uno::UNO_QUERY );
+
+ for( sal_Int16 i = 0; i < nAttrCount; i++ )
+ {
+ rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
+ rtl::OUString aLocalName;
+ rtl::OUString aValue = xAttrList->getValueByIndex( i );
+ USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
+
+ switch( rAttrTokenMap.Get( nPrefix, aLocalName ))
+ {
+ case XML_TOK_PA_X:
+ case XML_TOK_PA_Y:
+ case XML_TOK_PA_WIDTH:
+ case XML_TOK_PA_HEIGHT:
+ m_aOuterPositioning.readPositioningAttribute( nPrefix, aLocalName, aValue );
+ break;
+ case XML_TOK_PA_STYLE_NAME:
+ msAutoStyleName = aValue;
+ break;
+ case XML_TOK_PA_CHART_ADDRESS:
+ mrChartAddress = lcl_ConvertRange( aValue, xNewDoc );
+ // indicator for getting data from the outside
+ m_rbHasRangeAtPlotArea = true;
+ break;
+ case XML_TOK_PA_DS_HAS_LABELS:
+ {
+ if( aValue.equals( ::xmloff::token::GetXMLToken( ::xmloff::token::XML_BOTH )))
+ mrColHasLabels = mrRowHasLabels = sal_True;
+ else if( aValue.equals( ::xmloff::token::GetXMLToken( ::xmloff::token::XML_ROW )))
+ mrRowHasLabels = sal_True;
+ else if( aValue.equals( ::xmloff::token::GetXMLToken( ::xmloff::token::XML_COLUMN )))
+ mrColHasLabels = sal_True;
+ }
+ break;
+ case XML_TOK_PA_TRANSFORM:
+ case XML_TOK_PA_VRP:
+ case XML_TOK_PA_VPN:
+ case XML_TOK_PA_VUP:
+ case XML_TOK_PA_PROJECTION:
+ case XML_TOK_PA_DISTANCE:
+ case XML_TOK_PA_FOCAL_LENGTH:
+ case XML_TOK_PA_SHADOW_SLANT:
+ case XML_TOK_PA_SHADE_MODE:
+ case XML_TOK_PA_AMBIENT_COLOR:
+ case XML_TOK_PA_LIGHTING_MODE:
+ maSceneImportHelper.processSceneAttribute( nPrefix, aLocalName, aValue );
+ break;
+ }
+ }
+
+ if( ! mxNewDoc.is())
+ {
+ uno::Reference< beans::XPropertySet > xDocProp( mrImportHelper.GetChartDocument(), uno::UNO_QUERY );
+ if( xDocProp.is())
+ {
+ try
+ {
+ uno::Any aAny;
+ aAny <<= (sal_Bool)(mrColHasLabels);
+ xDocProp->setPropertyValue(
+ ::rtl::OUString::createFromAscii( "DataSourceLabelsInFirstColumn" ),
+ aAny );
+
+ aAny <<= (sal_Bool)(mrRowHasLabels);
+ xDocProp->setPropertyValue(
+ ::rtl::OUString::createFromAscii( "DataSourceLabelsInFirstRow" ),
+ aAny );
+ }
+ catch( beans::UnknownPropertyException & )
+ {
+ DBG_ERRORFILE( "Properties missing" );
+ }
+ }
+ }
+
+ // set properties
+ uno::Reference< beans::XPropertySet > xProp( mxDiagram, uno::UNO_QUERY );
+ if( msAutoStyleName.getLength())
+ {
+ if( xProp.is())
+ {
+ const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext();
+ if( pStylesCtxt )
+ {
+ const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext(
+ mrImportHelper.GetChartFamilyID(), msAutoStyleName );
+
+ XMLPropStyleContext* pPropStyleContext =
+ const_cast< XMLPropStyleContext * >(
+ dynamic_cast< const XMLPropStyleContext * >( pStyle ) );
+ if( pPropStyleContext )
+ {
+ pPropStyleContext->FillPropertySet( xProp );
+
+ // get the data row source that was set without having data
+ xProp->getPropertyValue( ::rtl::OUString::createFromAscii("DataRowSource"))
+ >>= mrDataRowSource;
+
+ //lines on/off
+ //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
+ mrSeriesDefaultsAndStyles.maLinesOnProperty = SchXMLTools::getPropertyFromContext(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Lines")), pPropStyleContext, pStylesCtxt );
+
+ //handle automatic position and size
+ m_aOuterPositioning.readAutomaticPositioningProperties( pPropStyleContext, pStylesCtxt );
+
+ //correct default starting angle for old 3D pies
+ if( SchXMLTools::isDocumentGeneratedWithOpenOfficeOlderThan3_0( GetImport().GetModel() ) )
+ {
+ bool bIs3d = false;
+ if( xProp.is() && ( xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Dim3D"))) >>= bIs3d ) &&
+ bIs3d )
+ {
+ if( maChartTypeServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart2.PieChartType" ))
+ || maChartTypeServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart2.DonutChartType" )) )
+ {
+ ::rtl::OUString aPropName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StartingAngle")) );
+ uno::Any aAStartingAngle( SchXMLTools::getPropertyFromContext( aPropName, pPropStyleContext, pStylesCtxt ) );
+ if( !aAStartingAngle.hasValue() )
+ xProp->setPropertyValue( aPropName, uno::makeAny(sal_Int32(0)) ) ;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ //remember default values for dataseries
+ if(xProp.is())
+ try
+ {
+ mrSeriesDefaultsAndStyles.maSymbolTypeDefault = xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SymbolType")));
+ mrSeriesDefaultsAndStyles.maDataCaptionDefault = xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataCaption")));
+
+ mrSeriesDefaultsAndStyles.maErrorIndicatorDefault = xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ErrorIndicator")));
+ mrSeriesDefaultsAndStyles.maErrorCategoryDefault = xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ErrorCategory")));
+ mrSeriesDefaultsAndStyles.maConstantErrorLowDefault = xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ConstantErrorLow")));
+ mrSeriesDefaultsAndStyles.maConstantErrorHighDefault = xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ConstantErrorHigh")));
+ mrSeriesDefaultsAndStyles.maPercentageErrorDefault = xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PercentageError")));
+ mrSeriesDefaultsAndStyles.maErrorMarginDefault = xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ErrorMargin")));
+
+ mrSeriesDefaultsAndStyles.maMeanValueDefault = xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MeanValue")));
+ mrSeriesDefaultsAndStyles.maRegressionCurvesDefault = xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RegressionCurves")));
+
+ bool bStacked = false;
+ mrSeriesDefaultsAndStyles.maStackedDefault = xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Stacked")));
+ mrSeriesDefaultsAndStyles.maStackedDefault >>= bStacked;
+ mrSeriesDefaultsAndStyles.maPercentDefault = xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Percent")));
+ mrSeriesDefaultsAndStyles.maPercentDefault >>= mbPercentStacked;
+ mrSeriesDefaultsAndStyles.maStackedBarsConnectedDefault = xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StackedBarsConnected")));
+
+ // deep
+ uno::Any aDeepProperty( xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Deep"))));
+ // #124488# old versions store a 3d area and 3D line deep chart with Deep==false => workaround for this
+ if( ! (bStacked || mbPercentStacked ))
+ {
+ if( SchXMLTools::isDocumentGeneratedWithOpenOfficeOlderThan2_3( GetImport().GetModel() ) )
+ {
+ bool bIs3d = false;
+ if( ( xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Dim3D"))) >>= bIs3d ) &&
+ bIs3d )
+ {
+ if( maChartTypeServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart2.AreaChartType" )) ||
+ maChartTypeServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart2.LineChartType" )) )
+ {
+ aDeepProperty <<= uno::makeAny( true );
+ }
+ }
+ }
+ }
+ mrSeriesDefaultsAndStyles.maDeepDefault = aDeepProperty;
+
+ xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NumberOfLines"))) >>= mnNumOfLinesProp;
+ xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Volume"))) >>= mbStockHasVolume;
+ }
+ catch( uno::Exception & rEx )
+ {
+#ifdef DBG_UTIL
+ String aStr( rEx.Message );
+ ByteString aBStr( aStr, RTL_TEXTENCODING_ASCII_US );
+ DBG_ERROR1( "PlotAreaContext:EndElement(): Exception caught: %s", aBStr.GetBuffer());
+#else
+ (void)rEx; // avoid warning for pro build
+#endif
+ }
+ //
+
+ bool bCreateInternalDataProvider = false;
+ if( m_rXLinkHRefAttributeToIndicateDataProvider.equalsAscii( "." ) ) //data comes from the chart itself
+ bCreateInternalDataProvider = true;
+ else if( m_rXLinkHRefAttributeToIndicateDataProvider.equalsAscii( ".." ) ) //data comes from the parent application
+ bCreateInternalDataProvider = false;
+ else if( m_rXLinkHRefAttributeToIndicateDataProvider.getLength() ) //not supported so far to get the data by sibling objects -> fall back to chart itself
+ bCreateInternalDataProvider = true;
+ else if( !m_rbHasRangeAtPlotArea )
+ bCreateInternalDataProvider = true;
+
+ if( bCreateInternalDataProvider && mxNewDoc.is() )
+ {
+ // we have no complete range => we have own data, so switch the data
+ // provider to internal. Clone is not necessary, as we don't have any
+ // data yet.
+ mxNewDoc->createInternalDataProvider( false /* bCloneExistingData */ );
+ if( xProp.is() && mrDataRowSource!=chart::ChartDataRowSource_COLUMNS )
+ xProp->setPropertyValue( rtl::OUString::createFromAscii( "DataRowSource" ), uno::makeAny(mrDataRowSource) );
+ }
+}
+
+SvXMLImportContext* SchXMLPlotAreaContext::CreateChildContext(
+ USHORT nPrefix,
+ const rtl::OUString& rLocalName,
+ const uno::Reference< xml::sax::XAttributeList >& xAttrList )
+{
+ SvXMLImportContext* pContext = 0;
+ const SvXMLTokenMap& rTokenMap = mrImportHelper.GetPlotAreaElemTokenMap();
+
+ switch( rTokenMap.Get( nPrefix, rLocalName ))
+ {
+ case XML_TOK_PA_COORDINATE_REGION_EXT:
+ case XML_TOK_PA_COORDINATE_REGION:
+ {
+ pContext = new SchXMLCoordinateRegionContext( GetImport(), nPrefix, rLocalName, m_aInnerPositioning );
+ }
+ break;
+
+ case XML_TOK_PA_AXIS:
+ {
+ bool bAddMissingXAxisForNetCharts = false;
+ bool bAdaptWrongPercentScaleValues = false;
+ if( SchXMLTools::isDocumentGeneratedWithOpenOfficeOlderThan2_3( GetImport().GetModel() ) )
+ {
+ //correct errors from older versions
+
+ // for NetCharts there were no xAxis exported to older files
+ // so we need to add the x axis here for those old NetChart files
+ if( maChartTypeServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart2.NetChartType" )) )
+ bAddMissingXAxisForNetCharts = true;
+
+ //Issue 59288
+ if( mbPercentStacked )
+ bAdaptWrongPercentScaleValues = true;
+ }
+
+ bool bAdaptXAxisOrientationForOld2DBarCharts = false;
+ if( SchXMLTools::isDocumentGeneratedWithOpenOfficeOlderThan2_4( GetImport().GetModel() ) )
+ {
+ //issue74660
+ if( maChartTypeServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart2.ColumnChartType" )) )
+ bAdaptXAxisOrientationForOld2DBarCharts = true;
+ }
+
+ pContext = new SchXMLAxisContext( mrImportHelper, GetImport(), rLocalName, mxDiagram, maAxes, mrCategoriesAddress,
+ bAddMissingXAxisForNetCharts, bAdaptWrongPercentScaleValues, bAdaptXAxisOrientationForOld2DBarCharts, m_bAxisPositionAttributeImported );
+ }
+ break;
+
+ case XML_TOK_PA_SERIES:
+ {
+ if( mxNewDoc.is())
+ {
+ pContext = new SchXMLSeries2Context(
+ mrImportHelper, GetImport(), rLocalName,
+ mxNewDoc, maAxes,
+ mrSeriesDefaultsAndStyles.maSeriesStyleList,
+ mnSeries,
+ mbStockHasVolume,
+ m_aGlobalSeriesImportInfo,
+ maChartTypeServiceName,
+ mrLSequencesPerIndex,
+ mbGlobalChartTypeUsedBySeries, maChartSize );
+ }
+ mnSeries++;
+ }
+ break;
+
+ case XML_TOK_PA_WALL:
+ pContext = new SchXMLWallFloorContext( mrImportHelper, GetImport(), nPrefix, rLocalName, mxDiagram,
+ SchXMLWallFloorContext::CONTEXT_TYPE_WALL );
+ break;
+ case XML_TOK_PA_FLOOR:
+ pContext = new SchXMLWallFloorContext( mrImportHelper, GetImport(), nPrefix, rLocalName, mxDiagram,
+ SchXMLWallFloorContext::CONTEXT_TYPE_FLOOR );
+ break;
+
+ case XML_TOK_PA_LIGHT_SOURCE:
+ pContext = maSceneImportHelper.create3DLightContext( nPrefix, rLocalName, xAttrList );
+ break;
+
+ // elements for stock charts
+ case XML_TOK_PA_STOCK_GAIN:
+ pContext = new SchXMLStockContext( mrImportHelper, GetImport(), nPrefix, rLocalName, mxDiagram,
+ SchXMLStockContext::CONTEXT_TYPE_GAIN );
+ break;
+ case XML_TOK_PA_STOCK_LOSS:
+ pContext = new SchXMLStockContext( mrImportHelper, GetImport(), nPrefix, rLocalName, mxDiagram,
+ SchXMLStockContext::CONTEXT_TYPE_LOSS );
+ break;
+ case XML_TOK_PA_STOCK_RANGE:
+ pContext = new SchXMLStockContext( mrImportHelper, GetImport(), nPrefix, rLocalName, mxDiagram,
+ SchXMLStockContext::CONTEXT_TYPE_RANGE );
+ break;
+
+ default:
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+ }
+
+ return pContext;
+}
+
+void SchXMLPlotAreaContext::EndElement()
+{
+ // set categories
+ if( mrCategoriesAddress.getLength() && mxNewDoc.is())
+ {
+ uno::Reference< chart2::data::XDataProvider > xDataProvider(
+ mxNewDoc->getDataProvider() );
+ // @todo: correct coordinate system index
+ sal_Int32 nDimension( 0 );
+ ::std::vector< SchXMLAxis >::const_iterator aIt(
+ ::std::find_if( maAxes.begin(), maAxes.end(), lcl_AxisHasCategories()));
+ if( aIt != maAxes.end())
+ nDimension = static_cast< sal_Int32 >( (*aIt).eClass );
+ SchXMLTools::CreateCategories(
+ xDataProvider, mxNewDoc, mrCategoriesAddress,
+ 0 /* nCooSysIndex */,
+ nDimension, &mrLSequencesPerIndex );
+ }
+
+ uno::Reference< beans::XPropertySet > xDiaProp( mxDiagram, uno::UNO_QUERY );
+ if( xDiaProp.is())
+ {
+ sal_Bool bIsThreeDim = sal_False;
+ uno::Any aAny = xDiaProp->getPropertyValue( ::rtl::OUString::createFromAscii( "Dim3D" ));
+ aAny >>= bIsThreeDim;
+
+ // set 3d scene attributes
+ if( bIsThreeDim )
+ {
+ // set scene attributes at diagram
+ maSceneImportHelper.setSceneAttributes( xDiaProp );
+ }
+
+ // set correct number of lines at series
+ if( ! m_aGlobalSeriesImportInfo.rbAllRangeAddressesAvailable &&
+ mnNumOfLinesProp > 0 &&
+ maChartTypeServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart2.ColumnChartType" )))
+ {
+ try
+ {
+ xDiaProp->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NumberOfLines" )),
+ uno::makeAny( mnNumOfLinesProp ));
+ }
+ catch( uno::Exception & rEx )
+ {
+#ifdef DBG_UTIL
+ String aStr( rEx.Message );
+ ByteString aBStr( aStr, RTL_TEXTENCODING_ASCII_US );
+ DBG_ERROR1( "Exception caught for property NumberOfLines: %s", aBStr.GetBuffer());
+#else
+ (void)rEx; // avoid warning for pro build
+#endif
+ }
+ }
+
+ // #i32366# stock has volume
+ if( ( 0 == mxDiagram->getDiagramType().reverseCompareToAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart.StockDiagram" ))) &&
+ mbStockHasVolume )
+ {
+ try
+ {
+ xDiaProp->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Volume" )),
+ uno::makeAny( true ));
+ }
+ catch( uno::Exception & rEx )
+ {
+#ifdef DBG_UTIL
+ String aStr( rEx.Message );
+ ByteString aBStr( aStr, RTL_TEXTENCODING_ASCII_US );
+ DBG_ERROR1( "Exception caught for property Volume: %s", aBStr.GetBuffer());
+#else
+ (void)rEx; // avoid warning for pro build
+#endif
+ }
+ }
+ }
+
+ // set changed size and position after properties (esp. 3d)
+
+ uno::Reference< chart::XDiagramPositioning > xDiaPos( mxDiagram, uno::UNO_QUERY );
+ if( xDiaPos.is())
+ {
+ if( !m_aOuterPositioning.isAutomatic() )
+ {
+ if( m_aInnerPositioning.hasPosSize() )
+ xDiaPos->setDiagramPositionExcludingAxes( m_aInnerPositioning.getRectangle() );
+ else if( m_aOuterPositioning.hasPosSize() )
+ {
+ if( SchXMLTools::isDocumentGeneratedWithOpenOfficeOlderThan3_3( GetImport().GetModel() ) ) //old version of OOo did write a wrong rectangle for the diagram size
+ xDiaPos->setDiagramPositionIncludingAxesAndAxisTitles( m_aOuterPositioning.getRectangle() );
+ else
+ xDiaPos->setDiagramPositionIncludingAxes( m_aOuterPositioning.getRectangle() );
+ }
+ }
+ }
+
+ CorrectAxisPositions();
+}
+
+void SchXMLPlotAreaContext::CorrectAxisPositions()
+{
+ ::rtl::OUString aODFVersionOfFile( GetImport().GetODFVersion() );
+
+ if( ( !aODFVersionOfFile.getLength() || aODFVersionOfFile.equalsAscii("1.0")
+ || aODFVersionOfFile.equalsAscii("1.1")
+ || ( aODFVersionOfFile.equalsAscii("1.2") && !m_bAxisPositionAttributeImported ) ) )
+ {
+ uno::Reference< chart2::XChartDocument > xNewDoc( mrImportHelper.GetChartDocument(), uno::UNO_QUERY );
+
+ try
+ {
+ Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xNewDoc->getFirstDiagram(), uno::UNO_QUERY_THROW );
+ uno::Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems());
+ if( aCooSysSeq.getLength() )
+ {
+ Reference< chart2::XCoordinateSystem > xCooSys( aCooSysSeq[0] );
+ if( xCooSys.is() )
+ {
+ Reference< chart2::XAxis > xMainXAxis = lcl_getAxis( xCooSys, 0, 0 );
+ Reference< chart2::XAxis > xMainYAxis = lcl_getAxis( xCooSys, 1, 0 );
+ //Reference< chart2::XAxis > xMajorZAxis = lcl_getAxis( xCooSys, 2, 0 );
+ Reference< chart2::XAxis > xSecondaryXAxis = lcl_getAxis( xCooSys, 0, 1 );
+ Reference< chart2::XAxis > xSecondaryYAxis = lcl_getAxis( xCooSys, 1, 1 );
+
+ uno::Reference< beans::XPropertySet > xMainXAxisProp( xMainXAxis, uno::UNO_QUERY );
+ uno::Reference< beans::XPropertySet > xMainYAxisProp( xMainYAxis, uno::UNO_QUERY );
+ uno::Reference< beans::XPropertySet > xSecondaryXAxisProp( xSecondaryXAxis, uno::UNO_QUERY );
+ uno::Reference< beans::XPropertySet > xSecondaryYAxisProp( xSecondaryYAxis, uno::UNO_QUERY );
+
+ if( xMainXAxisProp.is() && xMainYAxisProp.is() )
+ {
+ chart2::ScaleData aMainXScale = xMainXAxis->getScaleData();
+ if( 0 == maChartTypeServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart2.ScatterChartType" ) ) )
+ {
+ xMainYAxisProp->setPropertyValue( rtl::OUString::createFromAscii("CrossoverPosition")
+ , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_VALUE) );
+ double fCrossoverValue = 0.0;
+ aMainXScale.Origin >>= fCrossoverValue;
+ xMainYAxisProp->setPropertyValue( rtl::OUString::createFromAscii("CrossoverValue")
+ , uno::makeAny( fCrossoverValue ) );
+
+ if( aMainXScale.Orientation == chart2::AxisOrientation_REVERSE )
+ {
+ xMainYAxisProp->setPropertyValue( rtl::OUString::createFromAscii("LabelPosition")
+ , uno::makeAny( ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_END) );
+ xMainYAxisProp->setPropertyValue( rtl::OUString::createFromAscii("MarkPosition")
+ , uno::makeAny( ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS) );
+ if( xSecondaryYAxisProp.is() )
+ xSecondaryYAxisProp->setPropertyValue( rtl::OUString::createFromAscii("CrossoverPosition")
+ , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_START) );
+ }
+ else
+ {
+ xMainYAxisProp->setPropertyValue( rtl::OUString::createFromAscii("LabelPosition")
+ , uno::makeAny( ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_START) );
+ xMainYAxisProp->setPropertyValue( rtl::OUString::createFromAscii("MarkPosition")
+ , uno::makeAny( ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS) );
+ if( xSecondaryYAxisProp.is() )
+ xSecondaryYAxisProp->setPropertyValue( rtl::OUString::createFromAscii("CrossoverPosition")
+ , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_END) );
+ }
+ }
+ else
+ {
+ if( aMainXScale.Orientation == chart2::AxisOrientation_REVERSE )
+ {
+ xMainYAxisProp->setPropertyValue( rtl::OUString::createFromAscii("CrossoverPosition")
+ , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_END) );
+ if( xSecondaryYAxisProp.is() )
+ xSecondaryYAxisProp->setPropertyValue( rtl::OUString::createFromAscii("CrossoverPosition")
+ , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_START) );
+ }
+ else
+ {
+ xMainYAxisProp->setPropertyValue( rtl::OUString::createFromAscii("CrossoverPosition")
+ , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_START) );
+ if( xSecondaryYAxisProp.is() )
+ xSecondaryYAxisProp->setPropertyValue( rtl::OUString::createFromAscii("CrossoverPosition")
+ , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_END) );
+ }
+ }
+
+ chart2::ScaleData aMainYScale = xMainYAxis->getScaleData();
+ xMainXAxisProp->setPropertyValue( rtl::OUString::createFromAscii("CrossoverPosition")
+ , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_VALUE) );
+ double fCrossoverValue = 0.0;
+ aMainYScale.Origin >>= fCrossoverValue;
+ xMainXAxisProp->setPropertyValue( rtl::OUString::createFromAscii("CrossoverValue")
+ , uno::makeAny( fCrossoverValue ) );
+
+ if( aMainYScale.Orientation == chart2::AxisOrientation_REVERSE )
+ {
+ xMainXAxisProp->setPropertyValue( rtl::OUString::createFromAscii("LabelPosition")
+ , uno::makeAny( ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_END) );
+ xMainXAxisProp->setPropertyValue( rtl::OUString::createFromAscii("MarkPosition")
+ , uno::makeAny( ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS) );
+ if( xSecondaryXAxisProp.is() )
+ xSecondaryXAxisProp->setPropertyValue( rtl::OUString::createFromAscii("CrossoverPosition")
+ , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_START) );
+ }
+ else
+ {
+ xMainXAxisProp->setPropertyValue( rtl::OUString::createFromAscii("LabelPosition")
+ , uno::makeAny( ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_START) );
+ xMainXAxisProp->setPropertyValue( rtl::OUString::createFromAscii("MarkPosition")
+ , uno::makeAny( ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS) );
+ if( xSecondaryXAxisProp.is() )
+ xSecondaryXAxisProp->setPropertyValue( rtl::OUString::createFromAscii("CrossoverPosition")
+ , uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_END) );
+ }
+ }
+ }
+ }
+ }
+ catch( uno::Exception & )
+ {
+ }
+ }
+}
+
+// ========================================
+
+SchXMLAxisContext::SchXMLAxisContext( SchXMLImportHelper& rImpHelper,
+ SvXMLImport& rImport, const rtl::OUString& rLocalName,
+ uno::Reference< chart::XDiagram > xDiagram,
+ std::vector< SchXMLAxis >& aAxes,
+ ::rtl::OUString & rCategoriesAddress,
+ bool bAddMissingXAxisForNetCharts,
+ bool bAdaptWrongPercentScaleValues,
+ bool bAdaptXAxisOrientationForOld2DBarCharts,
+ bool& rbAxisPositionAttributeImported ) :
+ SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ),
+ mrImportHelper( rImpHelper ),
+ mxDiagram( xDiagram ),
+ maAxes( aAxes ),
+ mrCategoriesAddress( rCategoriesAddress ),
+ mbAddMissingXAxisForNetCharts( bAddMissingXAxisForNetCharts ),
+ mbAdaptWrongPercentScaleValues( bAdaptWrongPercentScaleValues ),
+ mbAdaptXAxisOrientationForOld2DBarCharts( bAdaptXAxisOrientationForOld2DBarCharts ),
+ m_rbAxisPositionAttributeImported( rbAxisPositionAttributeImported )
+{
+}
+
+SchXMLAxisContext::~SchXMLAxisContext()
+{}
+
+/* returns a shape for the current axis's title. The property
+ "Has...AxisTitle" is set to "True" to get the shape
+ */
+uno::Reference< drawing::XShape > SchXMLAxisContext::getTitleShape()
+{
+ uno::Reference< drawing::XShape > xResult;
+ uno::Any aTrueBool;
+ aTrueBool <<= (sal_Bool)(sal_True);
+ uno::Reference< beans::XPropertySet > xDiaProp( mxDiagram, uno::UNO_QUERY );
+
+ switch( maCurrentAxis.eClass )
+ {
+ case SCH_XML_AXIS_X:
+ if( maCurrentAxis.nIndexInCategory == 0 )
+ {
+ uno::Reference< chart::XAxisXSupplier > xSuppl( mxDiagram, uno::UNO_QUERY );
+ if( xSuppl.is())
+ {
+ if( xDiaProp.is())
+ xDiaProp->setPropertyValue( rtl::OUString::createFromAscii( "HasXAxisTitle" ), aTrueBool );
+ xResult = uno::Reference< drawing::XShape >( xSuppl->getXAxisTitle(), uno::UNO_QUERY );
+ }
+ }
+ else
+ {
+ uno::Reference< chart::XSecondAxisTitleSupplier > xSuppl( mxDiagram, uno::UNO_QUERY );
+ if( xSuppl.is() )
+ {
+ if( xDiaProp.is() )
+ xDiaProp->setPropertyValue( rtl::OUString::createFromAscii( "HasSecondaryXAxisTitle" ), aTrueBool );
+ xResult = uno::Reference< drawing::XShape >( xSuppl->getSecondXAxisTitle(), uno::UNO_QUERY );
+ }
+ }
+ break;
+ case SCH_XML_AXIS_Y:
+ if( maCurrentAxis.nIndexInCategory == 0 )
+ {
+ uno::Reference< chart::XAxisYSupplier > xSuppl( mxDiagram, uno::UNO_QUERY );
+ if( xSuppl.is())
+ {
+ if( xDiaProp.is())
+ xDiaProp->setPropertyValue( rtl::OUString::createFromAscii( "HasYAxisTitle" ), aTrueBool );
+ xResult = uno::Reference< drawing::XShape >( xSuppl->getYAxisTitle(), uno::UNO_QUERY );
+ }
+ }
+ else
+ {
+ uno::Reference< chart::XSecondAxisTitleSupplier > xSuppl( mxDiagram, uno::UNO_QUERY );
+ if( xSuppl.is() )
+ {
+ if( xDiaProp.is() )
+ xDiaProp->setPropertyValue( rtl::OUString::createFromAscii( "HasSecondaryYAxisTitle" ), aTrueBool );
+ xResult = uno::Reference< drawing::XShape >( xSuppl->getSecondYAxisTitle(), uno::UNO_QUERY );
+ }
+ }
+ break;
+ case SCH_XML_AXIS_Z:
+ {
+ uno::Reference< chart::XAxisZSupplier > xSuppl( mxDiagram, uno::UNO_QUERY );
+ if( xSuppl.is())
+ {
+ if( xDiaProp.is())
+ xDiaProp->setPropertyValue( rtl::OUString::createFromAscii( "HasZAxisTitle" ), aTrueBool );
+ xResult = uno::Reference< drawing::XShape >( xSuppl->getZAxisTitle(), uno::UNO_QUERY );
+ }
+ break;
+ }
+ case SCH_XML_AXIS_UNDEF:
+ DBG_ERROR( "Invalid axis" );
+ break;
+ }
+
+ return xResult;
+}
+
+void SchXMLAxisContext::CreateGrid( ::rtl::OUString sAutoStyleName,
+ sal_Bool bIsMajor )
+{
+ uno::Reference< chart::XDiagram > xDia = mrImportHelper.GetChartDocument()->getDiagram();
+ uno::Reference< beans::XPropertySet > xGridProp;
+ ::rtl::OUString sPropertyName;
+ DBG_ASSERT( xDia.is(), "diagram object is invalid!" );
+
+ uno::Reference< beans::XPropertySet > xDiaProp( xDia, uno::UNO_QUERY );
+ uno::Any aTrueBool( uno::makeAny( true ));
+
+ switch( maCurrentAxis.eClass )
+ {
+ case SCH_XML_AXIS_X:
+ {
+ uno::Reference< chart::XAxisXSupplier > xSuppl( xDia, uno::UNO_QUERY );
+ if( xSuppl.is())
+ {
+ if( bIsMajor )
+ {
+ if( xDiaProp.is())
+ xDiaProp->setPropertyValue( ::rtl::OUString::createFromAscii("HasXAxisGrid"), aTrueBool );
+ xGridProp = xSuppl->getXMainGrid();
+ }
+ else
+ {
+ if( xDiaProp.is())
+ xDiaProp->setPropertyValue( ::rtl::OUString::createFromAscii("HasXAxisHelpGrid"), aTrueBool );
+ xGridProp = xSuppl->getXHelpGrid();
+ }
+ }
+ }
+ break;
+ case SCH_XML_AXIS_Y:
+ {
+ uno::Reference< chart::XAxisYSupplier > xSuppl( xDia, uno::UNO_QUERY );
+ if( xSuppl.is())
+ {
+ if( bIsMajor )
+ {
+ if( xDiaProp.is())
+ xDiaProp->setPropertyValue( ::rtl::OUString::createFromAscii("HasYAxisGrid"), aTrueBool );
+ xGridProp = xSuppl->getYMainGrid();
+ }
+ else
+ {
+ if( xDiaProp.is())
+ xDiaProp->setPropertyValue( ::rtl::OUString::createFromAscii("HasYAxisHelpGrid"), aTrueBool );
+ xGridProp = xSuppl->getYHelpGrid();
+ }
+ }
+ }
+ break;
+ case SCH_XML_AXIS_Z:
+ {
+ uno::Reference< chart::XAxisZSupplier > xSuppl( xDia, uno::UNO_QUERY );
+ if( xSuppl.is())
+ {
+ if( bIsMajor )
+ {
+ if( xDiaProp.is())
+ xDiaProp->setPropertyValue( ::rtl::OUString::createFromAscii("HasZAxisGrid"), aTrueBool );
+ xGridProp = xSuppl->getZMainGrid();
+ }
+ else
+ {
+ if( xDiaProp.is())
+ xDiaProp->setPropertyValue( ::rtl::OUString::createFromAscii("HasZAxisHelpGrid"), aTrueBool );
+ xGridProp = xSuppl->getZHelpGrid();
+ }
+ }
+ }
+ break;
+ case SCH_XML_AXIS_UNDEF:
+ DBG_ERROR( "Invalid axis" );
+ break;
+ }
+
+ // set properties
+ if( xGridProp.is())
+ {
+ // the line color is black as default, in the model it is a light gray
+ xGridProp->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineColor" )),
+ uno::makeAny( COL_BLACK ));
+ if( sAutoStyleName.getLength())
+ {
+ const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext();
+ if( pStylesCtxt )
+ {
+ const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext(
+ mrImportHelper.GetChartFamilyID(), sAutoStyleName );
+
+ if( pStyle && pStyle->ISA( XMLPropStyleContext ))
+ (( XMLPropStyleContext* )pStyle )->FillPropertySet( xGridProp );
+ }
+ }
+ }
+}
+
+void SchXMLAxisContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
+{
+ // parse attributes
+ sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
+ SchXMLImport& rImport = ( SchXMLImport& )GetImport();
+ const SvXMLTokenMap& rAttrTokenMap = mrImportHelper.GetAxisAttrTokenMap();
+
+ for( sal_Int16 i = 0; i < nAttrCount; i++ )
+ {
+ rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
+ rtl::OUString aLocalName;
+ rtl::OUString aValue = xAttrList->getValueByIndex( i );
+ USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
+
+ switch( rAttrTokenMap.Get( nPrefix, aLocalName ))
+ {
+ case XML_TOK_AXIS_DIMENSION:
+ {
+ USHORT nEnumVal;
+ if( rImport.GetMM100UnitConverter().convertEnum( nEnumVal, aValue, aXMLAxisClassMap ))
+ maCurrentAxis.eClass = ( SchXMLAxisClass )nEnumVal;
+ }
+ break;
+ case XML_TOK_AXIS_NAME:
+ maCurrentAxis.aName = aValue;
+ break;
+ case XML_TOK_AXIS_STYLE_NAME:
+ msAutoStyleName = aValue;
+ break;
+ }
+ }
+
+ // check for number of axes with same category
+ maCurrentAxis.nIndexInCategory = 0;
+ sal_Int32 nNumOfAxes = maAxes.size();
+ for( sal_Int32 nCurrent = 0; nCurrent < nNumOfAxes; nCurrent++ )
+ {
+ if( maAxes[ nCurrent ].eClass == maCurrentAxis.eClass )
+ maCurrentAxis.nIndexInCategory++;
+ }
+ CreateAxis();
+}
+namespace
+{
+
+uno::Reference< chart2::XAxis > lcl_getAxis( const uno::Reference< frame::XModel >& xChartModel,
+ sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex )
+{
+ uno::Reference< chart2::XAxis > xAxis;
+
+ try
+ {
+ uno::Reference< chart2::XChartDocument > xChart2Document( xChartModel, uno::UNO_QUERY );
+ if( xChart2Document.is() )
+ {
+ uno::Reference< chart2::XDiagram > xDiagram( xChart2Document->getFirstDiagram());
+ uno::Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY_THROW );
+ uno::Sequence< uno::Reference< chart2::XCoordinateSystem > >
+ aCooSysSeq( xCooSysCnt->getCoordinateSystems());
+ sal_Int32 nCooSysIndex = 0;
+ if( nCooSysIndex < aCooSysSeq.getLength() )
+ {
+ uno::Reference< chart2::XCoordinateSystem > xCooSys( aCooSysSeq[nCooSysIndex] );
+ if( xCooSys.is() && nDimensionIndex < xCooSys->getDimension() )
+ {
+ const sal_Int32 nMaxAxisIndex = xCooSys->getMaximumAxisIndexByDimension(nDimensionIndex);
+ if( nAxisIndex <= nMaxAxisIndex )
+ xAxis = xCooSys->getAxisByDimension( nDimensionIndex, nAxisIndex );
+ }
+ }
+ }
+ }
+ catch( uno::Exception & )
+ {
+ DBG_ERROR( "Couldn't get axis" );
+ }
+
+ return xAxis;
+}
+
+bool lcl_divideBy100( uno::Any& rDoubleAny )
+{
+ bool bChanged = false;
+ double fValue=0.0;
+ if( (rDoubleAny>>=fValue) && (fValue!=0.0) )
+ {
+ fValue/=100.0;
+ rDoubleAny = uno::makeAny(fValue);
+ bChanged = true;
+ }
+ return bChanged;
+}
+
+bool lcl_AdaptWrongPercentScaleValues(chart2::ScaleData& rScaleData)
+{
+ bool bChanged = lcl_divideBy100( rScaleData.Minimum );
+ bChanged = lcl_divideBy100( rScaleData.Maximum ) || bChanged;
+ bChanged = lcl_divideBy100( rScaleData.Origin ) || bChanged;
+ bChanged = lcl_divideBy100( rScaleData.IncrementData.Distance ) || bChanged;
+ return bChanged;
+}
+
+}//end anonymous namespace
+
+void SchXMLAxisContext::CreateAxis()
+{
+ // add new Axis to list
+ maAxes.push_back( maCurrentAxis );
+
+ // set axis at chart
+ uno::Reference< beans::XPropertySet > xDiaProp( mxDiagram, uno::UNO_QUERY );
+ uno::Reference< beans::XPropertySet > xProp;
+ uno::Any aTrueBool;
+ aTrueBool <<= (sal_Bool)(sal_True);
+ uno::Any aFalseBool;
+ aFalseBool <<= (sal_Bool)(sal_False);
+ uno::Reference< frame::XModel > xDoc( mrImportHelper.GetChartDocument(), uno::UNO_QUERY );
+
+ switch( maCurrentAxis.eClass )
+ {
+ case SCH_XML_AXIS_X:
+ if( maCurrentAxis.nIndexInCategory == 0 )
+ {
+ try
+ {
+ xDiaProp->setPropertyValue(
+ rtl::OUString::createFromAscii( "HasXAxis" ), aTrueBool );
+ }
+ catch( beans::UnknownPropertyException & )
+ {
+ DBG_ERROR( "Couldn't turn on x axis" );
+ }
+ uno::Reference< chart::XAxisXSupplier > xSuppl( mxDiagram, uno::UNO_QUERY );
+ if( xSuppl.is())
+ xProp = xSuppl->getXAxis();
+ }
+ else
+ {
+ try
+ {
+ xDiaProp->setPropertyValue(
+ rtl::OUString::createFromAscii( "HasSecondaryXAxis" ), aTrueBool );
+ }
+ catch( beans::UnknownPropertyException & )
+ {
+ DBG_ERROR( "Couldn't turn on second x axis" );
+ }
+ uno::Reference< chart::XTwoAxisXSupplier > xSuppl( mxDiagram, uno::UNO_QUERY );
+ if( xSuppl.is())
+ xProp = xSuppl->getSecondaryXAxis();
+ }
+ break;
+
+ case SCH_XML_AXIS_Y:
+ if( maCurrentAxis.nIndexInCategory == 0 )
+ {
+ try
+ {
+ xDiaProp->setPropertyValue(
+ rtl::OUString::createFromAscii( "HasYAxis" ), aTrueBool );
+ }
+ catch( beans::UnknownPropertyException & )
+ {
+ DBG_ERROR( "Couldn't turn on y axis" );
+ }
+ uno::Reference< chart::XAxisYSupplier > xSuppl( mxDiagram, uno::UNO_QUERY );
+ if( xSuppl.is())
+ xProp = xSuppl->getYAxis();
+
+
+ if( mbAddMissingXAxisForNetCharts )
+ {
+ if( xDiaProp.is() )
+ {
+ try
+ {
+ xDiaProp->setPropertyValue(
+ rtl::OUString::createFromAscii( "HasXAxis" ), uno::makeAny(sal_True) );
+ }
+ catch( beans::UnknownPropertyException & )
+ {
+ DBG_ERROR( "Couldn't turn on x axis" );
+ }
+ }
+ }
+ }
+ else
+ {
+ try
+ {
+ xDiaProp->setPropertyValue(
+ rtl::OUString::createFromAscii( "HasSecondaryYAxis" ), aTrueBool );
+ }
+ catch( beans::UnknownPropertyException & )
+ {
+ DBG_ERROR( "Couldn't turn on second y axis" );
+ }
+ uno::Reference< chart::XTwoAxisYSupplier > xSuppl( mxDiagram, uno::UNO_QUERY );
+ if( xSuppl.is())
+ xProp = xSuppl->getSecondaryYAxis();
+ }
+ break;
+
+ case SCH_XML_AXIS_Z:
+ {
+ bool bSettingZAxisSuccedded = false;
+ try
+ {
+ rtl::OUString sHasZAxis( rtl::OUString::createFromAscii( "HasZAxis" ) );
+ xDiaProp->setPropertyValue( sHasZAxis, aTrueBool );
+ xDiaProp->getPropertyValue( sHasZAxis ) >>= bSettingZAxisSuccedded;
+ }
+ catch( beans::UnknownPropertyException & )
+ {
+ DBG_ERROR( "Couldn't turn on z axis" );
+ }
+ if( bSettingZAxisSuccedded )
+ {
+ uno::Reference< chart::XAxisZSupplier > xSuppl( mxDiagram, uno::UNO_QUERY );
+ if( xSuppl.is())
+ xProp = xSuppl->getZAxis();
+ }
+ }
+ break;
+ case SCH_XML_AXIS_UNDEF:
+ // nothing
+ break;
+ }
+
+ // set properties
+ if( xProp.is())
+ {
+ // #i109879# the line color is black as default, in the model it is a light gray
+ xProp->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineColor" )),
+ uno::makeAny( COL_BLACK ));
+
+ xProp->setPropertyValue( rtl::OUString::createFromAscii( "DisplayLabels" ), aFalseBool );
+
+ // #88077# AutoOrigin 'on' is default
+ xProp->setPropertyValue( rtl::OUString::createFromAscii( "AutoOrigin" ), aTrueBool );
+
+ if( msAutoStyleName.getLength())
+ {
+ const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext();
+ if( pStylesCtxt )
+ {
+ const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext(
+ mrImportHelper.GetChartFamilyID(), msAutoStyleName );
+
+ if( pStyle && pStyle->ISA( XMLPropStyleContext ))
+ {
+ // note: SvXMLStyleContext::FillPropertySet is not const
+ XMLPropStyleContext * pPropStyleContext = const_cast< XMLPropStyleContext * >( dynamic_cast< const XMLPropStyleContext * >( pStyle ));
+ if( pPropStyleContext )
+ pPropStyleContext->FillPropertySet( xProp );
+
+ if( mbAdaptWrongPercentScaleValues && maCurrentAxis.eClass==SCH_XML_AXIS_Y )
+ {
+ //set scale data of added x axis back to default
+ uno::Reference< chart2::XAxis > xAxis( lcl_getAxis( GetImport().GetModel(),
+ 1 /*nDimensionIndex*/, maCurrentAxis.nIndexInCategory /*nAxisIndex*/ ) );
+ if( xAxis.is() )
+ {
+ chart2::ScaleData aScaleData( xAxis->getScaleData());
+ if( lcl_AdaptWrongPercentScaleValues(aScaleData) )
+ xAxis->setScaleData( aScaleData );
+ }
+ }
+
+ if( mbAddMissingXAxisForNetCharts )
+ {
+ //copy style from y axis to added x axis:
+
+ uno::Reference< chart::XAxisXSupplier > xSuppl( mxDiagram, uno::UNO_QUERY );
+ if( xSuppl.is() )
+ {
+ uno::Reference< beans::XPropertySet > xXAxisProp( xSuppl->getXAxis() );
+ (( XMLPropStyleContext* )pStyle )->FillPropertySet( xXAxisProp );
+ }
+
+ //set scale data of added x axis back to default
+ uno::Reference< chart2::XAxis > xAxis( lcl_getAxis( GetImport().GetModel(),
+ 0 /*nDimensionIndex*/, 0 /*nAxisIndex*/ ) );
+ if( xAxis.is() )
+ {
+ chart2::ScaleData aScaleData;
+ aScaleData.AxisType = chart2::AxisType::CATEGORY;
+ aScaleData.Orientation = chart2::AxisOrientation_MATHEMATICAL;
+ xAxis->setScaleData( aScaleData );
+ }
+
+ //set line style of added x axis to invisible
+ uno::Reference< beans::XPropertySet > xNewAxisProp( xAxis, uno::UNO_QUERY );
+ if( xNewAxisProp.is() )
+ {
+ xNewAxisProp->setPropertyValue( rtl::OUString::createFromAscii("LineStyle")
+ , uno::makeAny(drawing::LineStyle_NONE));
+ }
+ }
+
+ if( mbAdaptXAxisOrientationForOld2DBarCharts && maCurrentAxis.eClass == SCH_XML_AXIS_X )
+ {
+ bool bIs3DChart = false;
+ if( xDiaProp.is() && ( xDiaProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Dim3D"))) >>= bIs3DChart )
+ && !bIs3DChart )
+ {
+ uno::Reference< chart2::XChartDocument > xChart2Document( GetImport().GetModel(), uno::UNO_QUERY );
+ if( xChart2Document.is() )
+ {
+ uno::Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xChart2Document->getFirstDiagram(), uno::UNO_QUERY );
+ if( xCooSysCnt.is() )
+ {
+ uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems() );
+ if( aCooSysSeq.getLength() )
+ {
+ bool bSwapXandYAxis = false;
+ uno::Reference< chart2::XCoordinateSystem > xCooSys( aCooSysSeq[0] );
+ uno::Reference< beans::XPropertySet > xCooSysProp( xCooSys, uno::UNO_QUERY );
+ if( xCooSysProp.is() && ( xCooSysProp->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SwapXAndYAxis"))) >>= bSwapXandYAxis )
+ && bSwapXandYAxis )
+ {
+ uno::Reference< chart2::XAxis > xAxis = xCooSys->getAxisByDimension( 0, maCurrentAxis.nIndexInCategory );
+ if( xAxis.is() )
+ {
+ chart2::ScaleData aScaleData = xAxis->getScaleData();
+ aScaleData.Orientation = chart2::AxisOrientation_REVERSE;
+ xAxis->setScaleData( aScaleData );
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ m_rbAxisPositionAttributeImported = m_rbAxisPositionAttributeImported || SchXMLTools::getPropertyFromContext(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CrossoverPosition")), pPropStyleContext, pStylesCtxt ).hasValue();
+ }
+ }
+ }
+ }
+}
+
+void SchXMLAxisContext::SetAxisTitle()
+{
+ // add new Axis to list
+ maAxes.push_back( maCurrentAxis );
+
+ // set axis at chart
+ sal_Bool bHasTitle = ( maCurrentAxis.aTitle.getLength() > 0 );
+ uno::Reference< frame::XModel > xDoc( mrImportHelper.GetChartDocument(), uno::UNO_QUERY );
+
+ switch( maCurrentAxis.eClass )
+ {
+ case SCH_XML_AXIS_X:
+ if( maCurrentAxis.nIndexInCategory == 0 )
+ {
+ uno::Reference< chart::XAxisXSupplier > xSuppl( mxDiagram, uno::UNO_QUERY );
+ if( xSuppl.is() &&
+ bHasTitle )
+ {
+ uno::Reference< beans::XPropertySet > xTitleProp( xSuppl->getXAxisTitle(), uno::UNO_QUERY );
+ if( xTitleProp.is())
+ {
+ try
+ {
+ uno::Any aAny;
+ aAny <<= maCurrentAxis.aTitle;
+ xTitleProp->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "String" )), aAny );
+ }
+ catch( beans::UnknownPropertyException & )
+ {
+ DBG_ERROR( "Property String for Title not available" );
+ }
+ }
+ }
+ }
+ else
+ {
+ uno::Reference< chart::XSecondAxisTitleSupplier > xSuppl( mxDiagram, uno::UNO_QUERY );
+ if( xSuppl.is() &&
+ bHasTitle )
+ {
+ uno::Reference< beans::XPropertySet > xTitleProp( xSuppl->getSecondXAxisTitle(), uno::UNO_QUERY );
+ if( xTitleProp.is())
+ {
+ try
+ {
+ uno::Any aAny;
+ aAny <<= maCurrentAxis.aTitle;
+ xTitleProp->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "String" )), aAny );
+ }
+ catch( beans::UnknownPropertyException & )
+ {
+ DBG_ERROR( "Property String for Title not available" );
+ }
+ }
+ }
+ }
+ break;
+
+ case SCH_XML_AXIS_Y:
+ if( maCurrentAxis.nIndexInCategory == 0 )
+ {
+ uno::Reference< chart::XAxisYSupplier > xSuppl( mxDiagram, uno::UNO_QUERY );
+ if( xSuppl.is() &&
+ bHasTitle )
+ {
+ uno::Reference< beans::XPropertySet > xTitleProp( xSuppl->getYAxisTitle(), uno::UNO_QUERY );
+ if( xTitleProp.is())
+ {
+ try
+ {
+ uno::Any aAny;
+ aAny <<= maCurrentAxis.aTitle;
+ xTitleProp->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "String" )), aAny );
+ }
+ catch( beans::UnknownPropertyException & )
+ {
+ DBG_ERROR( "Property String for Title not available" );
+ }
+ }
+ }
+ }
+ else
+ {
+ uno::Reference< chart::XSecondAxisTitleSupplier > xSuppl( mxDiagram, uno::UNO_QUERY );
+ if( xSuppl.is() &&
+ bHasTitle )
+ {
+ uno::Reference< beans::XPropertySet > xTitleProp( xSuppl->getSecondYAxisTitle(), uno::UNO_QUERY );
+ if( xTitleProp.is())
+ {
+ try
+ {
+ uno::Any aAny;
+ aAny <<= maCurrentAxis.aTitle;
+ xTitleProp->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "String" )), aAny );
+ }
+ catch( beans::UnknownPropertyException & )
+ {
+ DBG_ERROR( "Property String for Title not available" );
+ }
+ }
+ }
+ }
+ break;
+
+ case SCH_XML_AXIS_Z:
+ {
+ uno::Reference< chart::XAxisZSupplier > xSuppl( mxDiagram, uno::UNO_QUERY );
+ if( xSuppl.is() &&
+ bHasTitle )
+ {
+ uno::Reference< beans::XPropertySet > xTitleProp( xSuppl->getZAxisTitle(), uno::UNO_QUERY );
+ if( xTitleProp.is())
+ {
+ try
+ {
+ uno::Any aAny;
+ aAny <<= maCurrentAxis.aTitle;
+ xTitleProp->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "String" )), aAny );
+ }
+ catch( beans::UnknownPropertyException & )
+ {
+ DBG_ERROR( "Property String for Title not available" );
+ }
+ }
+ }
+ }
+ break;
+ case SCH_XML_AXIS_UNDEF:
+ // nothing
+ break;
+ }
+}
+
+SvXMLImportContext* SchXMLAxisContext::CreateChildContext(
+ USHORT p_nPrefix,
+ const rtl::OUString& rLocalName,
+ const uno::Reference< xml::sax::XAttributeList >& xAttrList )
+{
+ SvXMLImportContext* pContext = 0;
+ const SvXMLTokenMap& rTokenMap = mrImportHelper.GetAxisElemTokenMap();
+
+ switch( rTokenMap.Get( p_nPrefix, rLocalName ))
+ {
+ case XML_TOK_AXIS_TITLE:
+ {
+ uno::Reference< drawing::XShape > xTitleShape = getTitleShape();
+ pContext = new SchXMLTitleContext( mrImportHelper, GetImport(), rLocalName,
+ maCurrentAxis.aTitle,
+ xTitleShape );
+ }
+ break;
+
+ case XML_TOK_AXIS_CATEGORIES:
+ pContext = new SchXMLCategoriesContext( mrImportHelper, GetImport(),
+ p_nPrefix, rLocalName,
+ mrCategoriesAddress );
+ maCurrentAxis.bHasCategories = true;
+ break;
+
+ case XML_TOK_AXIS_GRID:
+ {
+ sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
+ sal_Bool bIsMajor = sal_True; // default value for class is "major"
+ rtl::OUString sAutoStyleName;
+
+ for( sal_Int16 i = 0; i < nAttrCount; i++ )
+ {
+ rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
+ rtl::OUString aLocalName;
+ USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
+
+ if( nPrefix == XML_NAMESPACE_CHART )
+ {
+ if( IsXMLToken( aLocalName, XML_CLASS ) )
+ {
+ if( IsXMLToken( xAttrList->getValueByIndex( i ), XML_MINOR ) )
+ bIsMajor = sal_False;
+ }
+ else if( IsXMLToken( aLocalName, XML_STYLE_NAME ) )
+ sAutoStyleName = xAttrList->getValueByIndex( i );
+ }
+ }
+
+ CreateGrid( sAutoStyleName, bIsMajor );
+
+ // don't create a context => use default context. grid elements are empty
+ pContext = new SvXMLImportContext( GetImport(), p_nPrefix, rLocalName );
+ }
+ break;
+
+ default:
+ pContext = new SvXMLImportContext( GetImport(), p_nPrefix, rLocalName );
+ break;
+ }
+
+ return pContext;
+}
+
+void SchXMLAxisContext::EndElement()
+{
+ SetAxisTitle();
+}
+
+// ========================================
+
+SchXMLDataPointContext::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 ) :
+ SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ),
+ mrImportHelper( rImpHelper ),
+ mrStyleList( rStyleList ),
+ m_xSeries( xSeries ),
+ mrIndex( rIndex ),
+ mbSymbolSizeForSeriesIsMissingInFile( bSymbolSizeForSeriesIsMissingInFile )
+{
+}
+
+SchXMLDataPointContext::~SchXMLDataPointContext()
+{
+}
+
+void SchXMLDataPointContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
+{
+ sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
+ ::rtl::OUString aValue;
+ ::rtl::OUString sAutoStyleName;
+ sal_Int32 nRepeat = 1;
+
+ for( sal_Int16 i = 0; i < nAttrCount; i++ )
+ {
+ rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
+ rtl::OUString aLocalName;
+ USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
+
+ if( nPrefix == XML_NAMESPACE_CHART )
+ {
+ if( IsXMLToken( aLocalName, XML_STYLE_NAME ) )
+ sAutoStyleName = xAttrList->getValueByIndex( i );
+ else if( IsXMLToken( aLocalName, XML_REPEATED ) )
+ nRepeat = xAttrList->getValueByIndex( i ).toInt32();
+ }
+ }
+
+ if( sAutoStyleName.getLength())
+ {
+ DataRowPointStyle aStyle(
+ DataRowPointStyle::DATA_POINT,
+ m_xSeries, mrIndex, nRepeat, sAutoStyleName );
+ aStyle.mbSymbolSizeForSeriesIsMissingInFile = mbSymbolSizeForSeriesIsMissingInFile;
+ mrStyleList.push_back( aStyle );
+ }
+ mrIndex += nRepeat;
+}
+
+// ========================================
+
+SchXMLCategoriesContext::SchXMLCategoriesContext(
+ SchXMLImportHelper& rImpHelper,
+ SvXMLImport& rImport,
+ sal_uInt16 nPrefix,
+ const rtl::OUString& rLocalName,
+ rtl::OUString& rAddress ) :
+ SvXMLImportContext( rImport, nPrefix, rLocalName ),
+ mrImportHelper( rImpHelper ),
+ mrAddress( rAddress )
+{
+}
+
+SchXMLCategoriesContext::~SchXMLCategoriesContext()
+{
+}
+
+void SchXMLCategoriesContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
+{
+ sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
+
+ for( sal_Int16 i = 0; i < nAttrCount; i++ )
+ {
+ rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
+ rtl::OUString aLocalName;
+ USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
+
+ if( nPrefix == XML_NAMESPACE_TABLE &&
+ IsXMLToken( aLocalName, XML_CELL_RANGE_ADDRESS ) )
+ {
+ uno::Reference< chart2::XChartDocument > xNewDoc( GetImport().GetModel(), uno::UNO_QUERY );
+ mrAddress = xAttrList->getValueByIndex( i );
+ // lcl_ConvertRange( xAttrList->getValueByIndex( i ), xNewDoc );
+ }
+ }
+}
+
+// ========================================
+
+SchXMLPositonAttributesHelper::SchXMLPositonAttributesHelper( SvXMLImport& rImporter )
+ : m_rImport( rImporter )
+ , m_aPosition(0,0)
+ , m_aSize(0,0)
+ , m_bHasSizeWidth( false )
+ , m_bHasSizeHeight( false )
+ , m_bHasPositionX( false )
+ , m_bHasPositionY( false )
+ , m_bAutoSize( false )
+ , m_bAutoPosition( false )
+{
+}
+
+SchXMLPositonAttributesHelper::~SchXMLPositonAttributesHelper()
+{
+}
+
+bool SchXMLPositonAttributesHelper::hasSize() const
+{
+ return m_bHasSizeWidth && m_bHasSizeHeight;
+}
+bool SchXMLPositonAttributesHelper::hasPosition() const
+{
+ return m_bHasPositionX && m_bHasPositionY;
+}
+bool SchXMLPositonAttributesHelper::hasPosSize() const
+{
+ return hasPosition() && hasSize();
+}
+bool SchXMLPositonAttributesHelper::isAutomatic() const
+{
+ return m_bAutoSize || m_bAutoPosition;
+}
+awt::Point SchXMLPositonAttributesHelper::getPosition() const
+{
+ return m_aPosition;
+}
+awt::Size SchXMLPositonAttributesHelper::getSize() const
+{
+ return m_aSize;
+}
+awt::Rectangle SchXMLPositonAttributesHelper::getRectangle() const
+{
+ return awt::Rectangle( m_aPosition.X, m_aPosition.Y, m_aSize.Width, m_aSize.Height );
+}
+
+bool SchXMLPositonAttributesHelper::readPositioningAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
+{
+ //returns true if the attribute was proccessed
+ bool bReturn = true;
+
+ if( XML_NAMESPACE_SVG == nPrefix )
+ {
+ if( IsXMLToken( rLocalName, XML_X ) )
+ {
+ m_rImport.GetMM100UnitConverter().convertMeasure( m_aPosition.X, rValue );
+ m_bHasPositionX = true;
+ }
+ else if( IsXMLToken( rLocalName, XML_Y ) )
+ {
+ m_rImport.GetMM100UnitConverter().convertMeasure( m_aPosition.Y, rValue );
+ m_bHasPositionY = true;
+ }
+ else if( IsXMLToken( rLocalName, XML_WIDTH ) )
+ {
+ m_rImport.GetMM100UnitConverter().convertMeasure( m_aSize.Width, rValue );
+ m_bHasSizeWidth = true;
+ }
+ else if( IsXMLToken( rLocalName, XML_HEIGHT ) )
+ {
+ m_rImport.GetMM100UnitConverter().convertMeasure( m_aSize.Height, rValue );
+ m_bHasSizeHeight = true;
+ }
+ else
+ bReturn = false;
+ }
+ else
+ bReturn = false;
+
+ return bReturn;
+}
+
+
+void SchXMLPositonAttributesHelper::readAutomaticPositioningProperties( XMLPropStyleContext* pPropStyleContext, const SvXMLStylesContext* pStylesCtxt )
+{
+ if( pPropStyleContext && pStylesCtxt )
+ {
+ //handle automatic position and size
+ SchXMLTools::getPropertyFromContext(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AutomaticSize")), pPropStyleContext, pStylesCtxt ) >>= m_bAutoSize;
+ SchXMLTools::getPropertyFromContext(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AutomaticPosition")), pPropStyleContext, pStylesCtxt ) >>= m_bAutoPosition;
+ }
+}
+
+// ========================================
+
+SchXMLCoordinateRegionContext::SchXMLCoordinateRegionContext(
+ SvXMLImport& rImport
+ , sal_uInt16 nPrefix
+ , const rtl::OUString& rLocalName
+ , SchXMLPositonAttributesHelper& rPositioning )
+ : SvXMLImportContext( rImport, nPrefix, rLocalName )
+ , m_rPositioning( rPositioning )
+{
+}
+
+SchXMLCoordinateRegionContext::~SchXMLCoordinateRegionContext()
+{
+}
+
+void SchXMLCoordinateRegionContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
+{
+ // parse attributes
+ sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
+
+ for( sal_Int16 i = 0; i < nAttrCount; i++ )
+ {
+ rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
+ rtl::OUString aLocalName;
+ rtl::OUString aValue = xAttrList->getValueByIndex( i );
+ USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
+ m_rPositioning.readPositioningAttribute( nPrefix, aLocalName, aValue );
+ }
+}
+
+// ========================================
+
+SchXMLWallFloorContext::SchXMLWallFloorContext(
+ SchXMLImportHelper& rImpHelper,
+ SvXMLImport& rImport,
+ sal_uInt16 nPrefix,
+ const rtl::OUString& rLocalName,
+ uno::Reference< chart::XDiagram >& xDiagram,
+ ContextType eContextType ) :
+ SvXMLImportContext( rImport, nPrefix, rLocalName ),
+ mrImportHelper( rImpHelper ),
+ mxWallFloorSupplier( xDiagram, uno::UNO_QUERY ),
+ meContextType( eContextType )
+{
+}
+
+SchXMLWallFloorContext::~SchXMLWallFloorContext()
+{
+}
+
+void SchXMLWallFloorContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
+{
+ if( mxWallFloorSupplier.is())
+ {
+ sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
+ rtl::OUString sAutoStyleName;
+
+ for( sal_Int16 i = 0; i < nAttrCount; i++ )
+ {
+ rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
+ rtl::OUString aLocalName;
+ USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
+
+ if( nPrefix == XML_NAMESPACE_CHART &&
+ IsXMLToken( aLocalName, XML_STYLE_NAME ) )
+ {
+ sAutoStyleName = xAttrList->getValueByIndex( i );
+ }
+ }
+
+ // set properties
+ uno::Reference< beans::XPropertySet > xProp( ( meContextType == CONTEXT_TYPE_WALL )
+ ? mxWallFloorSupplier->getWall()
+ : mxWallFloorSupplier->getFloor(),
+ uno::UNO_QUERY );
+ if( xProp.is())
+ {
+ if( sAutoStyleName.getLength())
+ {
+ const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext();
+ if( pStylesCtxt )
+ {
+ const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext(
+ mrImportHelper.GetChartFamilyID(), sAutoStyleName );
+
+ if( pStyle && pStyle->ISA( XMLPropStyleContext ))
+ (( XMLPropStyleContext* )pStyle )->FillPropertySet( xProp );
+ }
+ }
+ }
+ }
+}
+
+// ========================================
+
+SchXMLStockContext::SchXMLStockContext(
+ SchXMLImportHelper& rImpHelper,
+ SvXMLImport& rImport,
+ sal_uInt16 nPrefix,
+ const rtl::OUString& rLocalName,
+ uno::Reference< chart::XDiagram >& xDiagram,
+ ContextType eContextType ) :
+ SvXMLImportContext( rImport, nPrefix, rLocalName ),
+ mrImportHelper( rImpHelper ),
+ mxStockPropProvider( xDiagram, uno::UNO_QUERY ),
+ meContextType( eContextType )
+{
+}
+
+SchXMLStockContext::~SchXMLStockContext()
+{
+}
+
+void SchXMLStockContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
+{
+ if( mxStockPropProvider.is())
+ {
+ sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
+ rtl::OUString sAutoStyleName;
+
+ for( sal_Int16 i = 0; i < nAttrCount; i++ )
+ {
+ rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
+ rtl::OUString aLocalName;
+ USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
+
+ if( nPrefix == XML_NAMESPACE_CHART &&
+ IsXMLToken( aLocalName, XML_STYLE_NAME ) )
+ {
+ sAutoStyleName = xAttrList->getValueByIndex( i );
+ }
+ }
+
+ if( sAutoStyleName.getLength())
+ {
+ // set properties
+ uno::Reference< beans::XPropertySet > xProp;
+ switch( meContextType )
+ {
+ case CONTEXT_TYPE_GAIN:
+ xProp = mxStockPropProvider->getUpBar();
+ break;
+ case CONTEXT_TYPE_LOSS:
+ xProp = mxStockPropProvider->getDownBar();
+ break;
+ case CONTEXT_TYPE_RANGE:
+ xProp = mxStockPropProvider->getMinMaxLine();
+ break;
+ }
+ if( xProp.is())
+ {
+ const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext();
+ if( pStylesCtxt )
+ {
+ const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext(
+ mrImportHelper.GetChartFamilyID(), sAutoStyleName );
+
+ if( pStyle && pStyle->ISA( XMLPropStyleContext ))
+ (( XMLPropStyleContext* )pStyle )->FillPropertySet( xProp );
+ }
+ }
+ }
+ }
+}
+
+// ========================================
+
+SchXMLStatisticsObjectContext::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 ) :
+
+ SvXMLImportContext( rImport, nPrefix, rLocalName ),
+ mrImportHelper( rImpHelper ),
+ mrStyleList( rStyleList ),
+ m_xSeries( xSeries ),
+ meContextType( eContextType ),
+ maChartSize( rChartSize )
+{}
+
+SchXMLStatisticsObjectContext::~SchXMLStatisticsObjectContext()
+{
+}
+
+void SchXMLStatisticsObjectContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
+{
+ sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
+ ::rtl::OUString aValue;
+ ::rtl::OUString sAutoStyleName;
+
+ for( sal_Int16 i = 0; i < nAttrCount; i++ )
+ {
+ rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
+ rtl::OUString aLocalName;
+ USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
+
+ if( nPrefix == XML_NAMESPACE_CHART )
+ {
+ if( IsXMLToken( aLocalName, XML_STYLE_NAME ) )
+ sAutoStyleName = xAttrList->getValueByIndex( i );
+ }
+ }
+
+ // note: regression-curves must get a style-object even if there is no
+ // auto-style set, because they can contain an equation
+ if( sAutoStyleName.getLength() || meContextType == CONTEXT_TYPE_REGRESSION_CURVE )
+ {
+ DataRowPointStyle::StyleType eType = DataRowPointStyle::MEAN_VALUE;
+ switch( meContextType )
+ {
+ case CONTEXT_TYPE_MEAN_VALUE_LINE:
+ eType = DataRowPointStyle::MEAN_VALUE;
+ break;
+ case CONTEXT_TYPE_REGRESSION_CURVE:
+ eType = DataRowPointStyle::REGRESSION;
+ break;
+ case CONTEXT_TYPE_ERROR_INDICATOR:
+ eType = DataRowPointStyle::ERROR_INDICATOR;
+ break;
+ }
+ DataRowPointStyle aStyle(
+ eType, m_xSeries, -1, 1, sAutoStyleName );
+ mrStyleList.push_back( aStyle );
+ }
+}
+
+SvXMLImportContext* SchXMLStatisticsObjectContext::CreateChildContext(
+ USHORT nPrefix,
+ const rtl::OUString& rLocalName,
+ const uno::Reference< xml::sax::XAttributeList >& xAttrList )
+{
+ SvXMLImportContext* pContext = 0;
+
+ if( nPrefix == XML_NAMESPACE_CHART &&
+ IsXMLToken( rLocalName, XML_EQUATION ) )
+ {
+ pContext = new SchXMLEquationContext(
+ mrImportHelper, GetImport(), nPrefix, rLocalName, m_xSeries, maChartSize, mrStyleList.back());
+ }
+ else
+ {
+ pContext = SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList );
+ }
+
+ return pContext;
+}
+
+// ========================================
+
+SchXMLEquationContext::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 ) :
+ SvXMLImportContext( rImport, nPrefix, rLocalName ),
+ mrImportHelper( rImpHelper ),
+ mrRegressionStyle( rRegressionStyle ),
+ m_xSeries( xSeries ),
+ maChartSize( rChartSize )
+{}
+
+SchXMLEquationContext::~SchXMLEquationContext()
+{}
+
+void SchXMLEquationContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
+{
+ // parse attributes
+ sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
+ SchXMLImport& rImport = ( SchXMLImport& )GetImport();
+ const SvXMLTokenMap& rAttrTokenMap = mrImportHelper.GetRegEquationAttrTokenMap();
+ OUString sAutoStyleName;
+
+ sal_Bool bShowEquation = sal_True;
+ sal_Bool bShowRSquare = sal_False;
+ awt::Point aPosition;
+ bool bHasXPos = false;
+ bool bHasYPos = false;
+
+ for( sal_Int16 i = 0; i < nAttrCount; i++ )
+ {
+ rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
+ rtl::OUString aLocalName;
+ rtl::OUString aValue = xAttrList->getValueByIndex( i );
+ USHORT nPrefix = rImport.GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
+
+ switch( rAttrTokenMap.Get( nPrefix, aLocalName ))
+ {
+ case XML_TOK_REGEQ_POS_X:
+ rImport.GetMM100UnitConverter().convertMeasure( aPosition.X, aValue );
+ bHasXPos = true;
+ break;
+ case XML_TOK_REGEQ_POS_Y:
+ rImport.GetMM100UnitConverter().convertMeasure( aPosition.Y, aValue );
+ bHasYPos = true;
+ break;
+ case XML_TOK_REGEQ_DISPLAY_EQUATION:
+ rImport.GetMM100UnitConverter().convertBool( bShowEquation, aValue );
+ break;
+ case XML_TOK_REGEQ_DISPLAY_R_SQUARE:
+ rImport.GetMM100UnitConverter().convertBool( bShowRSquare, aValue );
+ break;
+ case XML_TOK_REGEQ_STYLE_NAME:
+ sAutoStyleName = aValue;
+ break;
+ }
+ }
+
+ if( sAutoStyleName.getLength() || bShowEquation || bShowRSquare )
+ {
+ uno::Reference< beans::XPropertySet > xEqProp;
+ uno::Reference< lang::XMultiServiceFactory > xFact( comphelper::getProcessServiceFactory(), uno::UNO_QUERY );
+ if( xFact.is())
+ xEqProp.set( xFact->createInstance(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.chart2.RegressionEquation" ))), uno::UNO_QUERY );
+ if( xEqProp.is())
+ {
+ if( sAutoStyleName.getLength() )
+ {
+ const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext();
+ if( pStylesCtxt )
+ {
+ const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext(
+ mrImportHelper.GetChartFamilyID(), sAutoStyleName );
+ // note: SvXMLStyleContext::FillPropertySet is not const
+ XMLPropStyleContext * pPropStyleContext =
+ const_cast< XMLPropStyleContext * >( dynamic_cast< const XMLPropStyleContext * >( pStyle ));
+
+ if( pPropStyleContext )
+ pPropStyleContext->FillPropertySet( xEqProp );
+ }
+ }
+ xEqProp->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("ShowEquation")), uno::makeAny( bShowEquation ));
+ xEqProp->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("ShowCorrelationCoefficient")), uno::makeAny( bShowRSquare ));
+
+ if( bHasXPos && bHasYPos )
+ {
+ chart2::RelativePosition aRelPos;
+ aRelPos.Primary = static_cast< double >( aPosition.X ) / static_cast< double >( maChartSize.Width );
+ aRelPos.Secondary = static_cast< double >( aPosition.Y ) / static_cast< double >( maChartSize.Height );
+ xEqProp->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "RelativePosition" )),
+ uno::makeAny( aRelPos ));
+ }
+ OSL_ASSERT( mrRegressionStyle.meType == DataRowPointStyle::REGRESSION );
+ mrRegressionStyle.m_xEquationProperties.set( xEqProp );
+ }
+ }
+}
diff --git a/xmloff/source/chart/SchXMLPlotAreaContext.hxx b/xmloff/source/chart/SchXMLPlotAreaContext.hxx
new file mode 100644
index 000000000000..1f0de466dcb1
--- /dev/null
+++ b/xmloff/source/chart/SchXMLPlotAreaContext.hxx
@@ -0,0 +1,391 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _SCH_XMLPLOTAREACONTEXT_HXX_
+#define _SCH_XMLPLOTAREACONTEXT_HXX_
+
+#include "SchXMLImport.hxx"
+#include "SchXMLChartContext.hxx"
+#include <xmloff/xmlictxt.hxx>
+#include <xmloff/shapeimport.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/chart/ChartSeriesAddress.hpp>
+#include <com/sun/star/chart/ChartDataRowSource.hpp>
+
+#include "transporttypes.hxx"
+
+class SvXMLImport;
+
+namespace com { namespace sun { namespace star {
+ namespace chart {
+ class XDiagram;
+ class X3DDisplay;
+ class XStatisticDisplay;
+ }
+ namespace chart2 {
+ class XChartDocument;
+ }
+ namespace xml { namespace sax {
+ class XAttributeList;
+}}}}}
+
+// ----------------------------------------
+
+class SchXML3DSceneAttributesHelper : public SdXML3DSceneAttributesHelper
+{
+public:
+ SchXML3DSceneAttributesHelper( SvXMLImport& rImporter );
+ virtual ~SchXML3DSceneAttributesHelper();
+
+ void getCameraDefaultFromDiagram( const ::com::sun::star::uno::Reference< com::sun::star::chart::XDiagram >& xDiagram );
+
+private:
+ SchXML3DSceneAttributesHelper();
+};
+
+// ----------------------------------------
+
+class SchXMLPositonAttributesHelper
+{
+public:
+ SchXMLPositonAttributesHelper( SvXMLImport& rImporter );
+ ~SchXMLPositonAttributesHelper();
+
+ bool readPositioningAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue );
+ void readAutomaticPositioningProperties( XMLPropStyleContext* pPropStyleContext, const SvXMLStylesContext* pStylesCtxt );
+
+ bool hasPosSize() const;
+ bool isAutomatic() const;
+ ::com::sun::star::awt::Rectangle getRectangle() const;
+
+
+private:
+ bool hasSize() const;
+ bool hasPosition() const;
+ ::com::sun::star::awt::Size getSize() const;
+ ::com::sun::star::awt::Point getPosition() const;
+
+ SvXMLImport& m_rImport;
+
+ ::com::sun::star::awt::Point m_aPosition;
+ ::com::sun::star::awt::Size m_aSize;
+
+ bool m_bHasSizeWidth;
+ bool m_bHasSizeHeight;
+ bool m_bHasPositionX;
+ bool m_bHasPositionY;
+ sal_Bool m_bAutoSize;
+ sal_Bool m_bAutoPosition;
+};
+
+// ----------------------------------------
+
+class SchXMLPlotAreaContext : public SvXMLImportContext
+{
+public:
+ SchXMLPlotAreaContext( SchXMLImportHelper& rImpHelper,
+ SvXMLImport& rImport, const rtl::OUString& rLocalName,
+ const rtl::OUString& rXLinkHRefAttributeToIndicateDataProvider,
+ ::com::sun::star::uno::Sequence<
+ ::com::sun::star::chart::ChartSeriesAddress >& rSeriesAddresses,
+ ::rtl::OUString& rCategoriesAddress,
+ ::rtl::OUString& rChartAddress,
+ bool& bHasRangeAtPlotArea,
+ sal_Bool & rAllRangeAddressesAvailable,
+ sal_Bool & rColHasLabels,
+ sal_Bool & rRowHasLabels,
+ ::com::sun::star::chart::ChartDataRowSource & rDataRowSource,
+ SeriesDefaultsAndStyles& rSeriesDefaultsAndStyles,
+ const ::rtl::OUString& aChartTypeServiceName,
+ tSchXMLLSequencesPerIndex & rLSequencesPerIndex,
+ const ::com::sun::star::awt::Size & rChartSize );
+ virtual ~SchXMLPlotAreaContext();
+
+ virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
+ virtual SvXMLImportContext* CreateChildContext(
+ USHORT nPrefix,
+ const rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
+ virtual void EndElement();
+
+ void CorrectAxisPositions();
+
+private:
+ SchXMLImportHelper& mrImportHelper;
+ ::com::sun::star::uno::Reference< com::sun::star::chart::XDiagram > mxDiagram;
+ ::com::sun::star::uno::Reference< com::sun::star::chart2::XChartDocument > mxNewDoc;
+ ::std::vector< SchXMLAxis > maAxes;
+ ::com::sun::star::uno::Sequence< ::com::sun::star::chart::ChartSeriesAddress >& mrSeriesAddresses;
+ rtl::OUString& mrCategoriesAddress;
+ SeriesDefaultsAndStyles& mrSeriesDefaultsAndStyles;
+ sal_Int32 mnNumOfLinesProp;
+ sal_Bool mbStockHasVolume;
+ sal_Int32 mnSeries;
+ GlobalSeriesImportInfo m_aGlobalSeriesImportInfo;
+
+ SchXML3DSceneAttributesHelper maSceneImportHelper;
+ SchXMLPositonAttributesHelper m_aOuterPositioning;//including axes and axes titles
+ SchXMLPositonAttributesHelper m_aInnerPositioning;//excluding axes and axes titles
+ bool mbPercentStacked;
+ bool m_bAxisPositionAttributeImported;
+ ::rtl::OUString msAutoStyleName;
+ const ::rtl::OUString& m_rXLinkHRefAttributeToIndicateDataProvider;
+ ::rtl::OUString& mrChartAddress;
+ bool& m_rbHasRangeAtPlotArea;
+ sal_Bool & mrColHasLabels;
+ sal_Bool & mrRowHasLabels;
+ ::com::sun::star::chart::ChartDataRowSource & mrDataRowSource;
+ ::rtl::OUString maChartTypeServiceName;
+
+ tSchXMLLSequencesPerIndex & mrLSequencesPerIndex;
+
+ bool mbGlobalChartTypeUsedBySeries;
+ ::com::sun::star::awt::Size maChartSize;
+};
+
+// ----------------------------------------
+
+class SchXMLAxisContext : public SvXMLImportContext
+{
+private:
+ SchXMLImportHelper& mrImportHelper;
+ ::com::sun::star::uno::Reference< ::com::sun::star::chart::XDiagram > mxDiagram;
+ SchXMLAxis maCurrentAxis;
+ std::vector< SchXMLAxis >& maAxes;
+ rtl::OUString msAutoStyleName;
+ rtl::OUString& mrCategoriesAddress;
+ bool mbAddMissingXAxisForNetCharts; //to correct errors from older versions
+ bool mbAdaptWrongPercentScaleValues; //to correct errors from older versions
+ bool mbAdaptXAxisOrientationForOld2DBarCharts; //to correct different behaviour from older versions
+ bool& m_rbAxisPositionAttributeImported;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > getTitleShape();
+ void CreateGrid( ::rtl::OUString sAutoStyleName, sal_Bool bIsMajor );
+ void CreateAxis();
+ void SetAxisTitle();
+
+public:
+ SchXMLAxisContext( SchXMLImportHelper& rImpHelper,
+ SvXMLImport& rImport, const rtl::OUString& rLocalName,
+ ::com::sun::star::uno::Reference< ::com::sun::star::chart::XDiagram > xDiagram,
+ std::vector< SchXMLAxis >& aAxes,
+ ::rtl::OUString& rCategoriesAddress,
+ bool bAddMissingXAxisForNetCharts,
+ bool bAdaptWrongPercentScaleValues,
+ bool bAdaptXAxisOrientationForOld2DBarCharts,
+ bool& rbAxisPositionAttributeImported );
+ virtual ~SchXMLAxisContext();
+
+ virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
+ virtual void EndElement();
+ virtual SvXMLImportContext* CreateChildContext(
+ USHORT nPrefix,
+ const rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
+};
+
+//----------------------------------------
+
+class SchXMLDataPointContext : public SvXMLImportContext
+{
+private:
+ SchXMLImportHelper& mrImportHelper;
+ ::std::list< DataRowPointStyle >& mrStyleList;
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XDataSeries > m_xSeries;
+ sal_Int32& mrIndex;
+ bool mbSymbolSizeForSeriesIsMissingInFile;
+
+public:
+ 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 );
+ virtual ~SchXMLDataPointContext();
+
+ virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
+};
+
+// ----------------------------------------
+
+class SchXMLCategoriesContext : public SvXMLImportContext
+{
+private:
+ SchXMLImportHelper& mrImportHelper;
+ rtl::OUString& mrAddress;
+
+public:
+ SchXMLCategoriesContext( SchXMLImportHelper& rImpHelper,
+ SvXMLImport& rImport,
+ sal_uInt16 nPrefix,
+ const rtl::OUString& rLocalName,
+ rtl::OUString& rAddress );
+ virtual ~SchXMLCategoriesContext();
+ virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
+};
+
+// ----------------------------------------
+
+class SchXMLCoordinateRegionContext : public SvXMLImportContext
+{
+public:
+ SchXMLCoordinateRegionContext(
+ SvXMLImport& rImport
+ , sal_uInt16 nPrefix
+ , const rtl::OUString& rLocalName
+ , SchXMLPositonAttributesHelper& rPositioning );
+ virtual ~SchXMLCoordinateRegionContext();
+ virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
+
+private:
+ SchXMLPositonAttributesHelper& m_rPositioning;
+};
+
+// ----------------------------------------
+
+class SchXMLWallFloorContext : public SvXMLImportContext
+{
+public:
+ enum ContextType
+ {
+ CONTEXT_TYPE_WALL,
+ CONTEXT_TYPE_FLOOR
+ };
+
+private:
+ SchXMLImportHelper& mrImportHelper;
+ ::com::sun::star::uno::Reference< ::com::sun::star::chart::X3DDisplay > mxWallFloorSupplier;
+ ContextType meContextType;
+
+public:
+ SchXMLWallFloorContext( SchXMLImportHelper& rImportHelper,
+ SvXMLImport& rImport,
+ sal_uInt16 nPrefix,
+ const rtl::OUString& rLocalName,
+ ::com::sun::star::uno::Reference< ::com::sun::star::chart::XDiagram >& xDiagram,
+ ContextType eContextType );
+ virtual ~SchXMLWallFloorContext();
+ virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
+};
+
+// ----------------------------------------
+
+class SchXMLStockContext : public SvXMLImportContext
+{
+public:
+ enum ContextType
+ {
+ CONTEXT_TYPE_GAIN,
+ CONTEXT_TYPE_LOSS,
+ CONTEXT_TYPE_RANGE
+ };
+
+private:
+ SchXMLImportHelper& mrImportHelper;
+ ::com::sun::star::uno::Reference< ::com::sun::star::chart::XStatisticDisplay > mxStockPropProvider;
+ ContextType meContextType;
+
+public:
+ SchXMLStockContext( SchXMLImportHelper& rImportHelper,
+ SvXMLImport& rImport,
+ sal_uInt16 nPrefix,
+ const rtl::OUString& rLocalName,
+ ::com::sun::star::uno::Reference< ::com::sun::star::chart::XDiagram >& xDiagram,
+ ContextType eContextType );
+ virtual ~SchXMLStockContext();
+ virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
+};
+
+// ----------------------------------------
+
+class SchXMLStatisticsObjectContext : public SvXMLImportContext
+{
+public:
+ enum ContextType
+ {
+ CONTEXT_TYPE_MEAN_VALUE_LINE,
+ CONTEXT_TYPE_REGRESSION_CURVE,
+ CONTEXT_TYPE_ERROR_INDICATOR
+ };
+
+ SchXMLStatisticsObjectContext(
+ SchXMLImportHelper& rImportHelper,
+ 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 ::com::sun::star::awt::Size & rChartSize );
+
+ virtual ~SchXMLStatisticsObjectContext();
+
+ virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
+ virtual SvXMLImportContext* CreateChildContext(
+ USHORT nPrefix,
+ const rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
+
+private:
+ SchXMLImportHelper & mrImportHelper;
+ ::std::list< DataRowPointStyle > & mrStyleList;
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XDataSeries > m_xSeries;
+ ContextType meContextType;
+ ::com::sun::star::awt::Size maChartSize;
+};
+
+// ----------------------------------------
+
+class SchXMLEquationContext : public SvXMLImportContext
+{
+public:
+ SchXMLEquationContext(
+ SchXMLImportHelper& rImportHelper,
+ SvXMLImport& rImport,
+ sal_uInt16 nPrefix,
+ const rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XDataSeries >& xSeries,
+ const ::com::sun::star::awt::Size & rChartSize,
+ DataRowPointStyle & rRegressionStyle );
+
+ virtual ~SchXMLEquationContext();
+
+ virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
+
+private:
+ SchXMLImportHelper & mrImportHelper;
+ DataRowPointStyle & mrRegressionStyle;
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XDataSeries > m_xSeries;
+ ::com::sun::star::awt::Size maChartSize;
+};
+
+#endif // _SCH_XMLPLOTAREACONTEXT_HXX_
diff --git a/xmloff/source/chart/SchXMLSeries2Context.cxx b/xmloff/source/chart/SchXMLSeries2Context.cxx
new file mode 100644
index 000000000000..86e9693ee225
--- /dev/null
+++ b/xmloff/source/chart/SchXMLSeries2Context.cxx
@@ -0,0 +1,1073 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmloff.hxx"
+
+#include "SchXMLSeries2Context.hxx"
+#include "SchXMLPlotAreaContext.hxx"
+#include "SchXMLSeriesHelper.hxx"
+#include "SchXMLTools.hxx"
+#include "PropertyMap.hxx"
+
+#include <com/sun/star/chart2/XChartDocument.hpp>
+#include <com/sun/star/chart2/XDataSeries.hpp>
+#include <com/sun/star/chart2/XRegressionCurve.hpp>
+#include <com/sun/star/chart2/data/XDataSink.hpp>
+#include <com/sun/star/chart2/data/XDataReceiver.hpp>
+
+#include <com/sun/star/chart/ChartAxisAssign.hpp>
+#include <com/sun/star/chart/ChartSymbolType.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/chart/ChartLegendPosition.hpp>
+#include <com/sun/star/drawing/LineStyle.hpp>
+#include <com/sun/star/embed/Aspects.hpp>
+#include <com/sun/star/embed/XVisualObject.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+// header for define DBG_ERROR1
+#include <tools/debug.hxx>
+#include <rtl/ustrbuf.hxx>
+#include "xmlnmspe.hxx"
+#include <xmloff/xmlimp.hxx>
+#ifndef _XMLOFF_NMSPMAP_HX
+#include <xmloff/nmspmap.hxx>
+#endif
+#include "SchXMLImport.hxx"
+// header for class XMLPropStyleContext
+#include <xmloff/prstylei.hxx>
+#include <xmloff/xmlprmap.hxx>
+
+#include <typeinfo>
+
+using namespace ::com::sun::star;
+using namespace ::xmloff::token;
+
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::rtl::OUString;
+using ::rtl::OUStringBuffer;
+
+// ================================================================================
+
+namespace
+{
+
+class SchXMLDomain2Context : public SvXMLImportContext
+{
+private:
+ SchXMLImportHelper& mrImportHelper;
+ ::std::vector< OUString > & mrAddresses;
+
+public:
+ SchXMLDomain2Context( SchXMLImportHelper& rImpHelper,
+ SvXMLImport& rImport,
+ sal_uInt16 nPrefix,
+ const rtl::OUString& rLocalName,
+ ::std::vector< OUString > & rAddresses );
+ virtual ~SchXMLDomain2Context();
+ virtual void StartElement( const Reference< xml::sax::XAttributeList >& xAttrList );
+};
+
+SchXMLDomain2Context::SchXMLDomain2Context(
+ SchXMLImportHelper& rImpHelper,
+ SvXMLImport& rImport,
+ sal_uInt16 nPrefix,
+ const rtl::OUString& rLocalName,
+ ::std::vector< ::rtl::OUString > & rAddresses ) :
+ SvXMLImportContext( rImport, nPrefix, rLocalName ),
+ mrImportHelper( rImpHelper ),
+ mrAddresses( rAddresses )
+{
+}
+
+SchXMLDomain2Context::~SchXMLDomain2Context()
+{
+}
+
+void SchXMLDomain2Context::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
+{
+ sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
+
+ for( sal_Int16 i = 0; i < nAttrCount; i++ )
+ {
+ rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
+ rtl::OUString aLocalName;
+ USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
+
+ if( nPrefix == XML_NAMESPACE_TABLE &&
+ IsXMLToken( aLocalName, XML_CELL_RANGE_ADDRESS ) )
+ {
+ Reference< chart2::XChartDocument > xNewDoc( GetImport().GetModel(), uno::UNO_QUERY );
+ mrAddresses.push_back( xAttrList->getValueByIndex( i ));
+ }
+ }
+}
+
+void lcl_setAutomaticSymbolSize( const uno::Reference< beans::XPropertySet >& xSeriesOrPointProp, const SvXMLImport& rImport )
+{
+ awt::Size aSymbolSize(140,140);//old default for standard sized charts 7cm height
+
+ double fScale = 1;
+ uno::Reference< chart::XChartDocument > xChartDoc( rImport.GetModel(), uno::UNO_QUERY );
+ if( xChartDoc.is() )
+ {
+ uno::Reference< beans::XPropertySet > xLegendProp( xChartDoc->getLegend(), uno::UNO_QUERY );
+ chart::ChartLegendPosition aLegendPosition = chart::ChartLegendPosition_NONE;
+ if( xLegendProp.is() && (xLegendProp->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Alignment" ))) >>= aLegendPosition)
+ && chart::ChartLegendPosition_NONE != aLegendPosition )
+ {
+
+ double fFontHeight = 6.0;
+ if( xLegendProp->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "CharHeight" ))) >>= fFontHeight )
+ fScale = 0.75*fFontHeight/6.0;
+ }
+ else
+ {
+ uno::Reference< embed::XVisualObject > xVisualObject( rImport.GetModel(), uno::UNO_QUERY );
+ if( xVisualObject.is() )
+ {
+ awt::Size aPageSize( xVisualObject->getVisualAreaSize( embed::Aspects::MSOLE_CONTENT ) );
+ fScale = aPageSize.Height/7000.0;
+ }
+ }
+ if( fScale>0 )
+ {
+ aSymbolSize.Height = static_cast<sal_Int32>( fScale * aSymbolSize.Height );
+ aSymbolSize.Width = aSymbolSize.Height;
+ }
+ }
+ xSeriesOrPointProp->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SymbolSize")),uno::makeAny( aSymbolSize ));
+}
+
+void lcl_setSymbolSizeIfNeeded( const uno::Reference< beans::XPropertySet >& xSeriesOrPointProp, const SvXMLImport& rImport )
+{
+ if( !xSeriesOrPointProp.is() )
+ return;
+
+ sal_Int32 nSymbolType = chart::ChartSymbolType::NONE;
+ if( xSeriesOrPointProp.is() && ( xSeriesOrPointProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SymbolType"))) >>= nSymbolType) )
+ {
+ if(chart::ChartSymbolType::NONE!=nSymbolType)
+ {
+ if( chart::ChartSymbolType::BITMAPURL==nSymbolType )
+ {
+ //set special size for graphics to indicate to use the bitmap size itself
+ xSeriesOrPointProp->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SymbolSize")),uno::makeAny( awt::Size(-1,-1) ));
+ }
+ else
+ {
+ lcl_setAutomaticSymbolSize( xSeriesOrPointProp, rImport );
+ }
+ }
+ }
+}
+
+void lcl_resetSymbolSizeForPointsIfNecessary( const uno::Reference< beans::XPropertySet >& xPointProp, const SvXMLImport& rImport
+ , const XMLPropStyleContext * pPropStyleContext, const SvXMLStylesContext* pStylesCtxt )
+{
+ uno::Any aASymbolSize( SchXMLTools::getPropertyFromContext( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SymbolSize")), pPropStyleContext, pStylesCtxt ) );
+ if( !aASymbolSize.hasValue() )
+ lcl_setSymbolSizeIfNeeded( xPointProp, rImport );
+}
+
+void lcl_insertErrorBarLSequencesToMap(
+ tSchXMLLSequencesPerIndex & rInOutMap,
+ const uno::Reference< beans::XPropertySet > & xSeriesProp,
+ bool bYError = true )
+{
+ Reference< chart2::data::XDataSource > xErrorBarSource;
+ const OUString aPropName(
+ bYError
+ ? ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ErrorBarY" ))
+ : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ErrorBarX" )));
+ if( ( xSeriesProp->getPropertyValue( aPropName ) >>= xErrorBarSource ) &&
+ xErrorBarSource.is() )
+ {
+ Sequence< Reference< chart2::data::XLabeledDataSequence > > aLSequences(
+ xErrorBarSource->getDataSequences());
+ for( sal_Int32 nIndex = 0; nIndex < aLSequences.getLength(); ++nIndex )
+ {
+ // use "0" as data index. This is ok, as it is not used for error bars
+ rInOutMap.insert(
+ tSchXMLLSequencesPerIndex::value_type(
+ tSchXMLIndexWithPart( 0, SCH_XML_PART_ERROR_BARS ), aLSequences[ nIndex ] ));
+ }
+ }
+}
+
+Reference< chart2::data::XLabeledDataSequence > lcl_createAndAddSequenceToSeries( const rtl::OUString& rRole
+ , const rtl::OUString& rRange
+ , const Reference< chart2::XChartDocument >& xChartDoc
+ , const Reference< chart2::XDataSeries >& xSeries )
+{
+ Reference< chart2::data::XLabeledDataSequence > xLabeledSeq;
+
+ Reference< chart2::data::XDataSource > xSeriesSource( xSeries,uno::UNO_QUERY );
+ Reference< chart2::data::XDataSink > xSeriesSink( xSeries, uno::UNO_QUERY );
+
+ if( !(rRange.getLength() && xChartDoc.is() && xSeriesSource.is() && xSeriesSink.is()) )
+ return xLabeledSeq;
+
+ // create a new sequence
+ xLabeledSeq = SchXMLTools::GetNewLabeledDataSequence();
+
+ // set values at the new sequence
+ Reference< chart2::data::XDataSequence > xSeq = SchXMLTools::CreateDataSequence( rRange, xChartDoc );
+ Reference< beans::XPropertySet > xSeqProp( xSeq, uno::UNO_QUERY );
+ if( xSeqProp.is())
+ xSeqProp->setPropertyValue(OUString::createFromAscii("Role"), uno::makeAny( rRole));
+ xLabeledSeq->setValues( xSeq );
+
+ // add new sequence to data series / push to front to have the correct sequence order if charttype is changed afterwards
+ Sequence< Reference< chart2::data::XLabeledDataSequence > > aOldSeq( xSeriesSource->getDataSequences());
+ sal_Int32 nOldCount = aOldSeq.getLength();
+ Sequence< Reference< chart2::data::XLabeledDataSequence > > aNewSeq( nOldCount + 1 );
+ aNewSeq[0]=xLabeledSeq;
+ for( sal_Int32 nN=0; nN<nOldCount; nN++ )
+ aNewSeq[nN+1] = aOldSeq[nN];
+ xSeriesSink->setData( aNewSeq );
+
+ return xLabeledSeq;
+}
+
+} // anonymous namespace
+
+// ================================================================================
+
+SchXMLSeries2Context::SchXMLSeries2Context(
+ SchXMLImportHelper& rImpHelper,
+ SvXMLImport& rImport, const rtl::OUString& rLocalName,
+ const Reference< chart2::XChartDocument > & xNewDoc,
+ std::vector< SchXMLAxis >& rAxes,
+ ::std::list< DataRowPointStyle >& rStyleList,
+ sal_Int32 nSeriesIndex,
+ sal_Bool bStockHasVolume,
+ GlobalSeriesImportInfo& rGlobalSeriesImportInfo,
+ const OUString & aGlobalChartTypeName,
+ tSchXMLLSequencesPerIndex & rLSequencesPerIndex,
+ bool& rGlobalChartTypeUsedBySeries,
+ const awt::Size & rChartSize ) :
+ SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ),
+ mrImportHelper( rImpHelper ),
+ mxNewDoc( xNewDoc ),
+ mrAxes( rAxes ),
+ mrStyleList( rStyleList ),
+ m_xSeries(0),
+ mnSeriesIndex( nSeriesIndex ),
+ mnDataPointIndex( 0 ),
+ m_bStockHasVolume( bStockHasVolume ),
+ m_rGlobalSeriesImportInfo(rGlobalSeriesImportInfo),
+ mpAttachedAxis( NULL ),
+ maGlobalChartTypeName( aGlobalChartTypeName ),
+ maSeriesChartTypeName( aGlobalChartTypeName ),
+ m_bHasDomainContext(false),
+ mrLSequencesPerIndex( rLSequencesPerIndex ),
+ mrGlobalChartTypeUsedBySeries( rGlobalChartTypeUsedBySeries ),
+ mbSymbolSizeIsMissingInFile(false),
+ maChartSize( rChartSize )
+{
+ if( 0 == aGlobalChartTypeName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart2.DonutChartType" ) ) )
+ {
+ maSeriesChartTypeName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart2.PieChartType" ));
+ maGlobalChartTypeName = maSeriesChartTypeName;
+ }
+}
+
+SchXMLSeries2Context::~SchXMLSeries2Context()
+{
+ OSL_ASSERT( maPostponedSequences.empty());
+}
+
+void SchXMLSeries2Context::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
+{
+ // parse attributes
+ sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
+ const SvXMLTokenMap& rAttrTokenMap = mrImportHelper.GetSeriesAttrTokenMap();
+ mnAttachedAxis = 1;
+
+ bool bHasRange = false;
+ bool bHasLabelRange = false;
+
+ for( sal_Int16 i = 0; i < nAttrCount; i++ )
+ {
+ rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
+ rtl::OUString aLocalName;
+ rtl::OUString aValue = xAttrList->getValueByIndex( i );
+ USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
+
+ switch( rAttrTokenMap.Get( nPrefix, aLocalName ))
+ {
+ case XML_TOK_SERIES_CELL_RANGE:
+ m_aSeriesRange = aValue;
+ bHasRange = true;
+ break;
+ case XML_TOK_SERIES_LABEL_ADDRESS:
+ m_aSeriesLabelRange = aValue;
+ bHasLabelRange = true;
+ break;
+ case XML_TOK_SERIES_ATTACHED_AXIS:
+ {
+ sal_Int32 nNumOfAxes = mrAxes.size();
+ for( sal_Int32 nCurrent = 0; nCurrent < nNumOfAxes; nCurrent++ )
+ {
+ if( aValue.equals( mrAxes[ nCurrent ].aName ) &&
+ mrAxes[ nCurrent ].eClass == SCH_XML_AXIS_Y )
+ {
+ mpAttachedAxis = &( mrAxes[ nCurrent ] );
+ }
+ }
+ }
+ break;
+ case XML_TOK_SERIES_STYLE_NAME:
+ msAutoStyleName = aValue;
+ break;
+ case XML_TOK_SERIES_CHART_CLASS:
+ {
+ OUString aClassName;
+ sal_uInt16 nClassPrefix =
+ GetImport().GetNamespaceMap().GetKeyByAttrName(
+ aValue, &aClassName );
+ if( XML_NAMESPACE_CHART == nClassPrefix )
+ maSeriesChartTypeName = SchXMLTools::GetChartTypeByClassName( aClassName, false /* bUseOldNames */ );
+
+ if( ! maSeriesChartTypeName.getLength())
+ maSeriesChartTypeName = aClassName;
+ }
+ break;
+ }
+ }
+
+ if( mpAttachedAxis )
+ {
+ if( mpAttachedAxis->nIndexInCategory > 0 )
+ {
+ // secondary axis => property has to be set (primary is default)
+ mnAttachedAxis = 2;
+ }
+ }
+
+ try
+ {
+ OSL_ASSERT( mxNewDoc.is());
+ if( m_rGlobalSeriesImportInfo.rbAllRangeAddressesAvailable && ! bHasRange )
+ m_rGlobalSeriesImportInfo.rbAllRangeAddressesAvailable = sal_False;
+
+ bool bIsCandleStick = maGlobalChartTypeName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.CandleStickChartType"));
+ if( maSeriesChartTypeName.getLength() )
+ {
+ bIsCandleStick = maSeriesChartTypeName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.CandleStickChartType"));
+ }
+ else
+ {
+ if( bIsCandleStick
+ && m_bStockHasVolume
+ && mnSeriesIndex == 0 )
+ {
+ maSeriesChartTypeName = OUString::createFromAscii( "com.sun.star.chart2.ColumnChartType" );
+ bIsCandleStick = false;
+ }
+ else
+ {
+ maSeriesChartTypeName = maGlobalChartTypeName;
+ }
+ }
+ if( ! mrGlobalChartTypeUsedBySeries )
+ mrGlobalChartTypeUsedBySeries = (maSeriesChartTypeName.equals( maGlobalChartTypeName ));
+ sal_Int32 nCoordinateSystemIndex = 0;//so far we can only import one coordinate system
+ m_xSeries.set(
+ mrImportHelper.GetNewDataSeries( mxNewDoc, nCoordinateSystemIndex, maSeriesChartTypeName, ! mrGlobalChartTypeUsedBySeries ));
+ Reference< chart2::data::XLabeledDataSequence > xLabeledSeq(
+ SchXMLTools::GetNewLabeledDataSequence());
+
+ if( bIsCandleStick )
+ {
+ // set default color for range-line to black (before applying styles)
+ Reference< beans::XPropertySet > xSeriesProp( m_xSeries, uno::UNO_QUERY );
+ if( xSeriesProp.is())
+ xSeriesProp->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Color")),
+ uno::makeAny( sal_Int32( 0x000000 ))); // black
+ }
+ else if( maSeriesChartTypeName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.PieChartType")))
+ {
+ //@todo: this property should be saved
+ Reference< beans::XPropertySet > xSeriesProp( m_xSeries, uno::UNO_QUERY );
+ if( xSeriesProp.is())
+ xSeriesProp->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VaryColorsByPoint")),
+ uno::makeAny( true ));
+ }
+
+ // values
+ Reference< chart2::data::XDataSequence > xSeq;
+ if( bHasRange )
+ xSeq = SchXMLTools::CreateDataSequence( m_aSeriesRange, mxNewDoc );
+
+ Reference< beans::XPropertySet > xSeqProp( xSeq, uno::UNO_QUERY );
+ if( xSeqProp.is())
+ {
+ OUString aMainRole( OUString::createFromAscii("values-y") );
+ if( maSeriesChartTypeName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.BubbleChartType") ) )
+ aMainRole = OUString::createFromAscii("values-size");
+ xSeqProp->setPropertyValue(OUString::createFromAscii("Role"), uno::makeAny( aMainRole ));
+ }
+ xLabeledSeq->setValues( xSeq );
+
+ // register for setting local data if external data provider is not present
+ maPostponedSequences.insert(
+ tSchXMLLSequencesPerIndex::value_type(
+ tSchXMLIndexWithPart( m_rGlobalSeriesImportInfo.nCurrentDataIndex, SCH_XML_PART_VALUES ), xLabeledSeq ));
+
+ // label
+ if( bHasLabelRange )
+ {
+ Reference< chart2::data::XDataSequence > xLabelSequence =
+ SchXMLTools::CreateDataSequence( m_aSeriesLabelRange, mxNewDoc );
+ xLabeledSeq->setLabel( xLabelSequence );
+ }
+
+ // Note: Even if we have no label, we have to register the label
+ // for creation, because internal data always has labels. If
+ // they don't exist in the original, auto-generated labels are
+ // used for the internal data.
+ maPostponedSequences.insert(
+ tSchXMLLSequencesPerIndex::value_type(
+ tSchXMLIndexWithPart( m_rGlobalSeriesImportInfo.nCurrentDataIndex, SCH_XML_PART_LABEL ), xLabeledSeq ));
+
+
+ Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeq( &xLabeledSeq, 1 );
+ Reference< chart2::data::XDataSink > xSink( m_xSeries, uno::UNO_QUERY_THROW );
+ xSink->setData( aSeq );
+ }
+ catch( uno::Exception & ex )
+ {
+ (void)ex; // avoid warning for pro build
+ OSL_ENSURE( false, ::rtl::OUStringToOString(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Exception caught. Type: " )) +
+ ::rtl::OUString::createFromAscii( typeid( ex ).name()) +
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ", Message: " )) +
+ ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
+ }
+
+ //init mbSymbolSizeIsMissingInFile:
+ try
+ {
+ if( msAutoStyleName.getLength() )
+ {
+ const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext();
+ if( pStylesCtxt )
+ {
+ const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext(
+ mrImportHelper.GetChartFamilyID(), msAutoStyleName );
+
+ const XMLPropStyleContext* pPropStyleContext = dynamic_cast< const XMLPropStyleContext * >( pStyle );
+
+ uno::Any aASymbolSize( SchXMLTools::getPropertyFromContext( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SymbolSize"))
+ , pPropStyleContext, pStylesCtxt ) );
+ mbSymbolSizeIsMissingInFile = !aASymbolSize.hasValue();
+ }
+ }
+ }
+ catch( uno::Exception & ex )
+ {
+ (void)ex; // avoid warning for pro build
+ }
+}
+
+struct DomainInfo
+{
+ DomainInfo( const rtl::OUString& rRole, const rtl::OUString& rRange, sal_Int32 nIndex )
+ : aRole(rRole), aRange(rRange), nIndexForLocalData(nIndex)
+ {}
+
+ rtl::OUString aRole;
+ rtl::OUString aRange;
+ sal_Int32 nIndexForLocalData;
+};
+
+void SchXMLSeries2Context::EndElement()
+{
+ // special handling for different chart types. This is necessary as the
+ // roles are not yet saved in the file format
+ sal_Int32 nDomainCount = maDomainAddresses.size();
+ bool bIsScatterChart = maSeriesChartTypeName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.ScatterChartType"));
+ bool bIsBubbleChart = maSeriesChartTypeName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.BubbleChartType"));
+ bool bDeleteSeries = false;
+ std::vector< DomainInfo > aDomainInfos;
+
+ //different handling for different chart types necessary
+ if( bIsScatterChart || ( nDomainCount==1 && !bIsBubbleChart ) )
+ {
+ DomainInfo aDomainInfo( OUString::createFromAscii("values-x"), m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress, m_rGlobalSeriesImportInfo.nFirstFirstDomainIndex ) ;
+ bool bCreateXValues = true;
+ if( !maDomainAddresses.empty() )
+ {
+ if( !m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress.getLength() )
+ {
+ m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress = maDomainAddresses.front();
+ m_rGlobalSeriesImportInfo.nFirstFirstDomainIndex = m_rGlobalSeriesImportInfo.nCurrentDataIndex;
+ }
+ aDomainInfo.aRange = maDomainAddresses.front();
+ aDomainInfo.nIndexForLocalData = m_rGlobalSeriesImportInfo.nCurrentDataIndex;
+ m_rGlobalSeriesImportInfo.nCurrentDataIndex++;
+ }
+ else if( !m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress.getLength() && !m_bHasDomainContext && mnSeriesIndex==0 )
+ {
+ if( SchXMLTools::isDocumentGeneratedWithOpenOfficeOlderThan2_3( GetImport().GetModel() ) ) //wrong old chart files:
+ {
+ //for xy charts the first series needs to have a domain
+ //if this by error iss not the case the first series is taken s x values
+ //needed for wrong files created while having an addin (e.g. BoxPlot)
+ m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress = m_aSeriesRange;
+ m_rGlobalSeriesImportInfo.nFirstFirstDomainIndex = m_rGlobalSeriesImportInfo.nCurrentDataIndex++;
+ bDeleteSeries = true;
+ bCreateXValues = false;//they will be created for the next series
+ }
+ }
+ if( bCreateXValues )
+ aDomainInfos.push_back( aDomainInfo );
+ }
+ else if( bIsBubbleChart )
+ {
+ if( nDomainCount>1 )
+ {
+ DomainInfo aDomainInfo( OUString::createFromAscii("values-x"), maDomainAddresses[1], m_rGlobalSeriesImportInfo.nCurrentDataIndex ) ;
+ if( !m_rGlobalSeriesImportInfo.aFirstSecondDomainAddress.getLength() )
+ {
+ //for bubble chart the second domain contains the x values which should become an index smaller than y values for own data table
+ //->so second first
+ m_rGlobalSeriesImportInfo.aFirstSecondDomainAddress = maDomainAddresses[1];
+ m_rGlobalSeriesImportInfo.nFirstSecondDomainIndex = m_rGlobalSeriesImportInfo.nCurrentDataIndex;
+ }
+ aDomainInfos.push_back( aDomainInfo );
+ m_rGlobalSeriesImportInfo.nCurrentDataIndex++;
+ }
+ else if( m_rGlobalSeriesImportInfo.aFirstSecondDomainAddress.getLength() )
+ {
+ DomainInfo aDomainInfo( OUString::createFromAscii("values-x"), m_rGlobalSeriesImportInfo.aFirstSecondDomainAddress, m_rGlobalSeriesImportInfo.nFirstSecondDomainIndex ) ;
+ aDomainInfos.push_back( aDomainInfo );
+ }
+ if( nDomainCount>0)
+ {
+ DomainInfo aDomainInfo( OUString::createFromAscii("values-y"), maDomainAddresses.front(), m_rGlobalSeriesImportInfo.nCurrentDataIndex ) ;
+ if( !m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress.getLength() )
+ {
+ m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress = maDomainAddresses.front();
+ m_rGlobalSeriesImportInfo.nFirstFirstDomainIndex = m_rGlobalSeriesImportInfo.nCurrentDataIndex;
+ }
+ aDomainInfos.push_back( aDomainInfo );
+ m_rGlobalSeriesImportInfo.nCurrentDataIndex++;
+ }
+ }
+
+ if( bDeleteSeries )
+ {
+ //delete created series
+ SchXMLImportHelper::DeleteDataSeries(
+ m_xSeries, Reference< chart2::XChartDocument >( GetImport().GetModel(), uno::UNO_QUERY ) );
+ }
+ else
+ {
+ //add style
+ if( msAutoStyleName.getLength() ||
+ mnAttachedAxis != 1 )
+ {
+ DataRowPointStyle aStyle(
+ DataRowPointStyle::DATA_SERIES,
+ m_xSeries,
+ -1, 1,
+ msAutoStyleName, mnAttachedAxis );
+ aStyle.mbSymbolSizeForSeriesIsMissingInFile=mbSymbolSizeIsMissingInFile;
+ mrStyleList.push_back( aStyle );
+ }
+ }
+
+ for( std::vector< DomainInfo >::reverse_iterator aIt( aDomainInfos.rbegin() ); aIt!= aDomainInfos.rend(); ++aIt )
+ {
+ DomainInfo aDomainInfo( *aIt );
+ Reference< chart2::data::XLabeledDataSequence > xLabeledSeq =
+ lcl_createAndAddSequenceToSeries( aDomainInfo.aRole, aDomainInfo.aRange, mxNewDoc, m_xSeries );
+ if( xLabeledSeq.is() )
+ {
+ // register for setting local data if external data provider is not present
+ mrLSequencesPerIndex.insert(
+ tSchXMLLSequencesPerIndex::value_type(
+ tSchXMLIndexWithPart( aDomainInfo.nIndexForLocalData, SCH_XML_PART_VALUES ), xLabeledSeq ));
+ }
+ }
+
+ if( !bDeleteSeries )
+ {
+ for( tSchXMLLSequencesPerIndex::const_iterator aIt( maPostponedSequences.begin());
+ aIt != maPostponedSequences.end(); ++aIt )
+ {
+ sal_Int32 nNewIndex = aIt->first.first + nDomainCount;
+ mrLSequencesPerIndex.insert(
+ tSchXMLLSequencesPerIndex::value_type(
+ tSchXMLIndexWithPart( nNewIndex, aIt->first.second ), aIt->second ));
+ }
+ m_rGlobalSeriesImportInfo.nCurrentDataIndex++;
+ }
+ maPostponedSequences.clear();
+}
+
+SvXMLImportContext* SchXMLSeries2Context::CreateChildContext(
+ USHORT nPrefix,
+ const rtl::OUString& rLocalName,
+ const uno::Reference< xml::sax::XAttributeList >& )
+{
+ SvXMLImportContext* pContext = 0;
+ const SvXMLTokenMap& rTokenMap = mrImportHelper.GetSeriesElemTokenMap();
+
+ switch( rTokenMap.Get( nPrefix, rLocalName ))
+ {
+ case XML_TOK_SERIES_DOMAIN:
+ if( m_xSeries.is())
+ {
+ m_bHasDomainContext = true;
+ pContext = new SchXMLDomain2Context(
+ mrImportHelper, GetImport(),
+ nPrefix, rLocalName,
+ maDomainAddresses );
+ }
+ break;
+
+ case XML_TOK_SERIES_MEAN_VALUE_LINE:
+ pContext = new SchXMLStatisticsObjectContext(
+ mrImportHelper, GetImport(),
+ nPrefix, rLocalName,
+ mrStyleList, m_xSeries,
+ SchXMLStatisticsObjectContext::CONTEXT_TYPE_MEAN_VALUE_LINE,
+ maChartSize );
+ break;
+ case XML_TOK_SERIES_REGRESSION_CURVE:
+ pContext = new SchXMLStatisticsObjectContext(
+ mrImportHelper, GetImport(),
+ nPrefix, rLocalName,
+ mrStyleList, m_xSeries,
+ SchXMLStatisticsObjectContext::CONTEXT_TYPE_REGRESSION_CURVE,
+ maChartSize );
+ break;
+ case XML_TOK_SERIES_ERROR_INDICATOR:
+ pContext = new SchXMLStatisticsObjectContext(
+ mrImportHelper, GetImport(),
+ nPrefix, rLocalName,
+ mrStyleList, m_xSeries,
+ SchXMLStatisticsObjectContext::CONTEXT_TYPE_ERROR_INDICATOR,
+ maChartSize );
+ break;
+
+ case XML_TOK_SERIES_DATA_POINT:
+ pContext = new SchXMLDataPointContext( mrImportHelper, GetImport(), rLocalName,
+ mrStyleList, m_xSeries, mnDataPointIndex, mbSymbolSizeIsMissingInFile );
+ break;
+
+ default:
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+ }
+
+ return pContext;
+}
+
+//static
+void SchXMLSeries2Context::initSeriesPropertySets( SeriesDefaultsAndStyles& rSeriesDefaultsAndStyles
+ , const uno::Reference< frame::XModel >& xChartModel )
+{
+ ::std::list< DataRowPointStyle >::iterator iStyle;
+
+ // iterate over series first and remind propertysets in map
+ // new api <-> old api wrapper
+ ::std::map< Reference< chart2::XDataSeries >, Reference< beans::XPropertySet > > aSeriesMap;
+ for( iStyle = rSeriesDefaultsAndStyles.maSeriesStyleList.begin(); iStyle != rSeriesDefaultsAndStyles.maSeriesStyleList.end(); iStyle++ )
+ {
+ if( iStyle->meType != DataRowPointStyle::DATA_SERIES )
+ continue;
+
+ if( !iStyle->m_xOldAPISeries.is() )
+ iStyle->m_xOldAPISeries = SchXMLSeriesHelper::createOldAPISeriesPropertySet( iStyle->m_xSeries, xChartModel );
+
+ aSeriesMap[iStyle->m_xSeries] = iStyle->m_xOldAPISeries;
+
+ }
+
+ //initialize m_xOldAPISeries for all other styles also
+ for( iStyle = rSeriesDefaultsAndStyles.maSeriesStyleList.begin(); iStyle != rSeriesDefaultsAndStyles.maSeriesStyleList.end(); iStyle++ )
+ {
+ if( iStyle->meType == DataRowPointStyle::DATA_SERIES )
+ continue;
+ iStyle->m_xOldAPISeries = aSeriesMap[iStyle->m_xSeries];
+ }
+}
+
+//static
+void SchXMLSeries2Context::setDefaultsToSeries( SeriesDefaultsAndStyles& rSeriesDefaultsAndStyles )
+{
+ ::std::list< DataRowPointStyle >::iterator iStyle;
+ // iterate over series
+ // call initSeriesPropertySets first
+
+ for( iStyle = rSeriesDefaultsAndStyles.maSeriesStyleList.begin(); iStyle != rSeriesDefaultsAndStyles.maSeriesStyleList.end(); iStyle++ )
+ {
+ if( iStyle->meType != DataRowPointStyle::DATA_SERIES )
+ continue;
+
+ try
+ {
+ uno::Reference< beans::XPropertySet > xSeries( iStyle->m_xOldAPISeries );
+ if( !xSeries.is() )
+ continue;
+
+ if( rSeriesDefaultsAndStyles.maSymbolTypeDefault.hasValue() )
+ xSeries->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SymbolType")),rSeriesDefaultsAndStyles.maSymbolTypeDefault);
+ if( rSeriesDefaultsAndStyles.maDataCaptionDefault.hasValue() )
+ xSeries->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataCaption")),rSeriesDefaultsAndStyles.maDataCaptionDefault);
+
+ if( rSeriesDefaultsAndStyles.maErrorIndicatorDefault.hasValue() )
+ xSeries->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ErrorIndicator")),rSeriesDefaultsAndStyles.maErrorIndicatorDefault);
+ if( rSeriesDefaultsAndStyles.maErrorCategoryDefault.hasValue() )
+ xSeries->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ErrorCategory")),rSeriesDefaultsAndStyles.maErrorCategoryDefault);
+ if( rSeriesDefaultsAndStyles.maConstantErrorLowDefault.hasValue() )
+ xSeries->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ConstantErrorLow")),rSeriesDefaultsAndStyles.maConstantErrorLowDefault);
+ if( rSeriesDefaultsAndStyles.maConstantErrorHighDefault.hasValue() )
+ xSeries->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ConstantErrorHigh")),rSeriesDefaultsAndStyles.maConstantErrorHighDefault);
+ if( rSeriesDefaultsAndStyles.maPercentageErrorDefault.hasValue() )
+ xSeries->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PercentageError")),rSeriesDefaultsAndStyles.maPercentageErrorDefault);
+ if( rSeriesDefaultsAndStyles.maErrorMarginDefault.hasValue() )
+ xSeries->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ErrorMargin")),rSeriesDefaultsAndStyles.maErrorMarginDefault);
+
+ if( rSeriesDefaultsAndStyles.maMeanValueDefault.hasValue() )
+ xSeries->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MeanValue")),rSeriesDefaultsAndStyles.maMeanValueDefault);
+ if( rSeriesDefaultsAndStyles.maRegressionCurvesDefault.hasValue() )
+ xSeries->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RegressionCurves")),rSeriesDefaultsAndStyles.maRegressionCurvesDefault);
+ }
+ catch( uno::Exception & )
+ {
+ //end of series reached
+ }
+ }
+}
+
+//static
+void SchXMLSeries2Context::setStylesToSeries( SeriesDefaultsAndStyles& rSeriesDefaultsAndStyles
+ , const SvXMLStylesContext* pStylesCtxt
+ , const SvXMLStyleContext*& rpStyle
+ , ::rtl::OUString& rCurrStyleName
+ , SchXMLImportHelper& rImportHelper
+ , const SvXMLImport& rImport
+ , bool bIsStockChart
+ , tSchXMLLSequencesPerIndex & rInOutLSequencesPerIndex )
+{
+ ::std::list< DataRowPointStyle >::iterator iStyle;
+
+ // iterate over series
+ for( iStyle = rSeriesDefaultsAndStyles.maSeriesStyleList.begin(); iStyle != rSeriesDefaultsAndStyles.maSeriesStyleList.end(); iStyle++ )
+ {
+ if( iStyle->meType == DataRowPointStyle::DATA_SERIES )
+ {
+ try
+ {
+ uno::Reference< beans::XPropertySet > xSeriesProp( iStyle->m_xOldAPISeries );
+ if( !xSeriesProp.is() )
+ continue;
+
+ if( iStyle->mnAttachedAxis != 1 )
+ {
+ xSeriesProp->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Axis" ))
+ , uno::makeAny(chart::ChartAxisAssign::SECONDARY_Y) );
+ }
+
+ if( (iStyle->msStyleName).getLength())
+ {
+ if( ! rCurrStyleName.equals( iStyle->msStyleName ))
+ {
+ rCurrStyleName = iStyle->msStyleName;
+ rpStyle = pStylesCtxt->FindStyleChildContext(
+ rImportHelper.GetChartFamilyID(), rCurrStyleName );
+ }
+
+ //set style to series
+ // note: SvXMLStyleContext::FillPropertySet is not const
+ XMLPropStyleContext * pPropStyleContext =
+ const_cast< XMLPropStyleContext * >(
+ dynamic_cast< const XMLPropStyleContext * >( rpStyle ));
+ if( pPropStyleContext )
+ {
+ // error bar style must be set before the other error
+ // bar properties (which may be alphabetically before
+ // this property)
+ bool bHasErrorBarRangesFromData = false;
+ {
+ const ::rtl::OUString aErrorBarStylePropName( RTL_CONSTASCII_USTRINGPARAM("ErrorBarStyle"));
+ uno::Any aErrorBarStyle(
+ SchXMLTools::getPropertyFromContext( aErrorBarStylePropName, pPropStyleContext, pStylesCtxt ));
+ if( aErrorBarStyle.hasValue())
+ {
+ xSeriesProp->setPropertyValue( aErrorBarStylePropName, aErrorBarStyle );
+ sal_Int32 eEBStyle = chart::ErrorBarStyle::NONE;
+ bHasErrorBarRangesFromData =
+ ( ( aErrorBarStyle >>= eEBStyle ) &&
+ eEBStyle == chart::ErrorBarStyle::FROM_DATA );
+ }
+ }
+
+ //don't set the style to the min max line series of a stock chart
+ //otherwise the min max line properties gets overwritten and the series becomes invisible typically
+ bool bIsMinMaxSeries = false;
+ if( bIsStockChart )
+ {
+ if( SchXMLSeriesHelper::isCandleStickSeries( iStyle->m_xSeries
+ , uno::Reference< frame::XModel >( rImportHelper.GetChartDocument(), uno::UNO_QUERY ) ) )
+ bIsMinMaxSeries = true;
+ }
+ if( !bIsMinMaxSeries )
+ {
+ pPropStyleContext->FillPropertySet( xSeriesProp );
+ if( iStyle->mbSymbolSizeForSeriesIsMissingInFile )
+ lcl_setSymbolSizeIfNeeded( xSeriesProp, rImport );
+ if( bHasErrorBarRangesFromData )
+ lcl_insertErrorBarLSequencesToMap( rInOutLSequencesPerIndex, xSeriesProp );
+ }
+ }
+ }
+ }
+ catch( uno::Exception & rEx )
+ {
+ (void)rEx; // avoid warning for pro build
+ DBG_ERROR1( "Exception caught during setting styles to series: %s",
+ OUStringToOString( rEx.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
+ }
+ }
+ }
+}
+
+// static
+void SchXMLSeries2Context::setStylesToStatisticsObjects( SeriesDefaultsAndStyles& rSeriesDefaultsAndStyles
+ , const SvXMLStylesContext* pStylesCtxt
+ , const SvXMLStyleContext*& rpStyle
+ , ::rtl::OUString& rCurrStyleName )
+{
+ ::std::list< DataRowPointStyle >::iterator iStyle;
+
+ // iterate over regession etc
+ for( iStyle = rSeriesDefaultsAndStyles.maSeriesStyleList.begin(); iStyle != rSeriesDefaultsAndStyles.maSeriesStyleList.end(); iStyle++ )
+ {
+ if( iStyle->meType == DataRowPointStyle::REGRESSION ||
+ iStyle->meType == DataRowPointStyle::ERROR_INDICATOR ||
+ iStyle->meType == DataRowPointStyle::MEAN_VALUE )
+ {
+ try
+ {
+ uno::Reference< beans::XPropertySet > xSeriesProp( iStyle->m_xOldAPISeries );
+ if( !xSeriesProp.is() )
+ continue;
+
+ if( (iStyle->msStyleName).getLength())
+ {
+ if( ! rCurrStyleName.equals( iStyle->msStyleName ))
+ {
+ rCurrStyleName = iStyle->msStyleName;
+ rpStyle = pStylesCtxt->FindStyleChildContext(
+ SchXMLImportHelper::GetChartFamilyID(), rCurrStyleName );
+ }
+
+ // note: SvXMLStyleContext::FillPropertySet is not const
+ XMLPropStyleContext * pPropStyleContext =
+ const_cast< XMLPropStyleContext * >(
+ dynamic_cast< const XMLPropStyleContext * >( rpStyle ));
+ if( pPropStyleContext )
+ {
+ Reference< beans::XPropertySet > xStatPropSet;
+ switch( iStyle->meType )
+ {
+ case DataRowPointStyle::MEAN_VALUE:
+ xSeriesProp->getPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "DataMeanValueProperties" ))) >>= xStatPropSet;
+ break;
+ case DataRowPointStyle::REGRESSION:
+ xSeriesProp->getPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "DataRegressionProperties" ))) >>= xStatPropSet;
+ break;
+ case DataRowPointStyle::ERROR_INDICATOR:
+ xSeriesProp->getPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "DataErrorProperties" ))) >>= xStatPropSet;
+ break;
+ default:
+ break;
+ }
+ if( xStatPropSet.is())
+ pPropStyleContext->FillPropertySet( xStatPropSet );
+ }
+ }
+
+ // set equation properties at a regression curve
+ // note: this must be done after setting the regression
+ // properties at the old API, otherwise the curve itself does
+ // not exist here
+ if( iStyle->meType == DataRowPointStyle::REGRESSION && iStyle->m_xEquationProperties.is())
+ {
+ OSL_ASSERT( iStyle->m_xSeries.is());
+ Reference< chart2::XRegressionCurve > xRegCurve( SchXMLTools::getRegressionCurve( iStyle->m_xSeries ));
+ if( xRegCurve.is())
+ xRegCurve->setEquationProperties( iStyle->m_xEquationProperties );
+ }
+ }
+ catch( uno::Exception & rEx )
+ {
+ (void)rEx; // avoid warning for pro build
+ DBG_ERROR1( "Exception caught during setting styles to series: %s",
+ OUStringToOString( rEx.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
+ }
+ }
+ }
+}
+
+//static
+void SchXMLSeries2Context::setStylesToDataPoints( SeriesDefaultsAndStyles& rSeriesDefaultsAndStyles
+ , const SvXMLStylesContext* pStylesCtxt
+ , const SvXMLStyleContext*& rpStyle
+ , ::rtl::OUString& rCurrStyleName
+ , SchXMLImportHelper& rImportHelper
+ , const SvXMLImport& rImport
+ , bool bIsStockChart, bool bIsDonutChart, bool bSwitchOffLinesForScatter )
+{
+ ::std::list< DataRowPointStyle >::iterator iStyle;
+ for( iStyle = rSeriesDefaultsAndStyles.maSeriesStyleList.begin(); iStyle != rSeriesDefaultsAndStyles.maSeriesStyleList.end(); iStyle++ )
+ {
+ if( iStyle->meType != DataRowPointStyle::DATA_POINT )
+ continue;
+
+ if( iStyle->m_nPointIndex == -1 )
+ continue;
+
+ //ignore datapoint properties for stock charts
+ //... todo ...
+ if( bIsStockChart )
+ {
+ if( SchXMLSeriesHelper::isCandleStickSeries( iStyle->m_xSeries, uno::Reference< frame::XModel >( rImportHelper.GetChartDocument(), uno::UNO_QUERY ) ) )
+ continue;
+ }
+
+ // data point style
+ for( sal_Int32 i = 0; i < iStyle->m_nPointRepeat; i++ )
+ {
+ try
+ {
+ uno::Reference< beans::XPropertySet > xSeriesProp( iStyle->m_xOldAPISeries );
+ if(!xSeriesProp.is())
+ continue;
+
+ uno::Reference< beans::XPropertySet > xPointProp(
+ SchXMLSeriesHelper::createOldAPIDataPointPropertySet( iStyle->m_xSeries, iStyle->m_nPointIndex + i
+ , uno::Reference< frame::XModel >( rImportHelper.GetChartDocument(), uno::UNO_QUERY ) ) );
+
+ if( !xPointProp.is() )
+ continue;
+
+ if( bIsDonutChart )
+ {
+ //set special series styles for donut charts first
+ if( !rCurrStyleName.equals( iStyle->msSeriesStyleNameForDonuts ) )
+ {
+ rCurrStyleName = iStyle->msSeriesStyleNameForDonuts;
+ rpStyle = pStylesCtxt->FindStyleChildContext(
+ rImportHelper.GetChartFamilyID(), rCurrStyleName );
+ }
+
+ // note: SvXMLStyleContext::FillPropertySet is not const
+ XMLPropStyleContext * pPropStyleContext =
+ const_cast< XMLPropStyleContext * >(
+ dynamic_cast< const XMLPropStyleContext * >( rpStyle ));
+ if( pPropStyleContext )
+ pPropStyleContext->FillPropertySet( xPointProp );
+ }
+
+ try
+ {
+ //need to set this explicitely here for old files as the new api does not support this property fully anymore
+ if( bSwitchOffLinesForScatter )
+ xPointProp->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Lines")),uno::makeAny(sal_False));
+ }
+ catch( uno::Exception & rEx )
+ {
+ (void)rEx; // avoid warning for pro build
+ }
+
+ if( !rCurrStyleName.equals( iStyle->msStyleName ) )
+ {
+ rCurrStyleName = iStyle->msStyleName;
+ rpStyle = pStylesCtxt->FindStyleChildContext(
+ rImportHelper.GetChartFamilyID(), rCurrStyleName );
+ }
+
+ // note: SvXMLStyleContext::FillPropertySet is not const
+ XMLPropStyleContext * pPropStyleContext =
+ const_cast< XMLPropStyleContext * >(
+ dynamic_cast< const XMLPropStyleContext * >( rpStyle ));
+ if( pPropStyleContext )
+ {
+ pPropStyleContext->FillPropertySet( xPointProp );
+ if( iStyle->mbSymbolSizeForSeriesIsMissingInFile )
+ lcl_resetSymbolSizeForPointsIfNecessary( xPointProp, rImport, pPropStyleContext, pStylesCtxt );
+ }
+ }
+ catch( uno::Exception & rEx )
+ {
+ (void)rEx; // avoid warning for pro build
+ DBG_ERROR1( "Exception caught during setting styles to data points: %s",
+ OUStringToOString( rEx.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
+ }
+ }
+ } // styles iterator
+}
+
+//static
+void SchXMLSeries2Context::switchSeriesLinesOff( ::std::list< DataRowPointStyle >& rSeriesStyleList )
+{
+ ::std::list< DataRowPointStyle >::iterator iStyle;
+ // iterate over series
+
+ for( iStyle = rSeriesStyleList.begin(); iStyle != rSeriesStyleList.end(); iStyle++ )
+ {
+ if( iStyle->meType != DataRowPointStyle::DATA_SERIES )
+ continue;
+
+ try
+ {
+ uno::Reference< beans::XPropertySet > xSeries( iStyle->m_xOldAPISeries );
+ if( !xSeries.is() )
+ continue;
+
+ xSeries->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Lines")),uno::makeAny(sal_False));
+ }
+ catch( uno::Exception & )
+ {
+ //end of series reached
+ }
+ }
+}
diff --git a/xmloff/source/chart/SchXMLSeries2Context.hxx b/xmloff/source/chart/SchXMLSeries2Context.hxx
new file mode 100644
index 000000000000..faa42b2809ac
--- /dev/null
+++ b/xmloff/source/chart/SchXMLSeries2Context.hxx
@@ -0,0 +1,135 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef XMLOFF_SCHXMLSERIES2CONTEXT_HXX
+#define XMLOFF_SCHXMLSERIES2CONTEXT_HXX
+
+#include "transporttypes.hxx"
+#include "SchXMLChartContext.hxx"
+#include <xmloff/xmlictxt.hxx>
+#include <xmloff/SchXMLImportHelper.hxx>
+// header for class SvXMLStyleContext
+#include <xmloff/xmlstyle.hxx>
+
+#include <vector>
+#include <list>
+
+namespace com { namespace sun { namespace star {
+ namespace chart2 {
+ class XChartDocument;
+ class XDataSeries;
+ }
+ namespace awt {
+ struct Size;
+ }
+}}}
+
+// class for child contexts: series, data point and statistics objects
+class SchXMLSeries2Context : public SvXMLImportContext
+{
+private:
+ SchXMLImportHelper& mrImportHelper;
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XChartDocument > mxNewDoc;
+ ::std::vector< SchXMLAxis >& mrAxes;
+ ::std::list< DataRowPointStyle >& mrStyleList;
+ ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > m_xSeries;
+ sal_Int32 mnSeriesIndex;
+ sal_Int32 mnDataPointIndex;
+ sal_Bool m_bStockHasVolume;
+
+ GlobalSeriesImportInfo& m_rGlobalSeriesImportInfo;
+
+ SchXMLAxis* mpAttachedAxis;
+ sal_Int32 mnAttachedAxis;
+ ::rtl::OUString msAutoStyleName;
+ ::std::vector< ::rtl::OUString > maDomainAddresses;
+ ::rtl::OUString maGlobalChartTypeName;
+ ::rtl::OUString maSeriesChartTypeName;
+ ::rtl::OUString m_aSeriesRange;
+ ::rtl::OUString m_aSeriesLabelRange;
+ bool m_bHasDomainContext;
+ tSchXMLLSequencesPerIndex & mrLSequencesPerIndex;
+ tSchXMLLSequencesPerIndex maPostponedSequences;
+ bool& mrGlobalChartTypeUsedBySeries;
+ bool mbSymbolSizeIsMissingInFile;
+ ::com::sun::star::awt::Size maChartSize;
+
+public:
+ SchXMLSeries2Context( SchXMLImportHelper& rImpHelper,
+ SvXMLImport& rImport, const rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XChartDocument > & xNewDoc,
+ std::vector< SchXMLAxis >& rAxes,
+ ::std::list< DataRowPointStyle >& rStyleList,
+ sal_Int32 nSeriesIndex,
+ sal_Bool bStockHasVolume,
+ GlobalSeriesImportInfo& rGlobalSeriesImportInfo,
+ const ::rtl::OUString & aGlobalChartTypeName,
+ tSchXMLLSequencesPerIndex & rLSequencesPerIndex,
+ bool& rGlobalChartTypeUsedBySeries,
+ const ::com::sun::star::awt::Size & rChartSize );
+ virtual ~SchXMLSeries2Context();
+
+ virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
+ virtual SvXMLImportContext* CreateChildContext(
+ USHORT nPrefix,
+ const rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
+ virtual void EndElement();
+
+ static void initSeriesPropertySets( SeriesDefaultsAndStyles& rSeriesDefaultsAndStyles
+ , const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel );
+
+ static void setDefaultsToSeries( SeriesDefaultsAndStyles& rSeriesDefaultsAndStyles );
+
+ static void setStylesToSeries( SeriesDefaultsAndStyles& rSeriesDefaultsAndStyles
+ , const SvXMLStylesContext* pStylesCtxt
+ , const SvXMLStyleContext*& rpStyle
+ , ::rtl::OUString& rCurrStyleName
+ , SchXMLImportHelper& rImportHelper
+ , const SvXMLImport& rImport
+ , bool bIsStockChart
+ , tSchXMLLSequencesPerIndex & rInOutLSequencesPerIndex );
+
+ static void setStylesToStatisticsObjects( SeriesDefaultsAndStyles& rSeriesDefaultsAndStyles
+ , const SvXMLStylesContext* pStylesCtxt
+ , const SvXMLStyleContext*& rpStyle
+ , ::rtl::OUString& rCurrStyleName );
+
+ static void setStylesToDataPoints( SeriesDefaultsAndStyles& rSeriesDefaultsAndStyles
+ , const SvXMLStylesContext* pStylesCtxt
+ , const SvXMLStyleContext*& rpStyle
+ , ::rtl::OUString& rCurrStyleName
+ , SchXMLImportHelper& rImportHelper
+ , const SvXMLImport& rImport
+ , bool bIsStockChart, bool bIsDonutChart, bool bSwitchOffLinesForScatter );
+
+ static void switchSeriesLinesOff( ::std::list< DataRowPointStyle >& rSeriesStyleList );
+};
+
+// XMLOFF_SCHXMLSERIES2CONTEXT_HXX
+#endif
diff --git a/xmloff/source/chart/SchXMLSeriesHelper.cxx b/xmloff/source/chart/SchXMLSeriesHelper.cxx
new file mode 100644
index 000000000000..a7518a6cbade
--- /dev/null
+++ b/xmloff/source/chart/SchXMLSeriesHelper.cxx
@@ -0,0 +1,301 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmloff.hxx"
+
+#include "SchXMLSeriesHelper.hxx"
+#include <com/sun/star/chart2/XChartDocument.hpp>
+#include <com/sun/star/chart2/XChartTypeContainer.hpp>
+#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
+#include <com/sun/star/chart2/XDataSeriesContainer.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+// header for define RTL_CONSTASCII_USTRINGPARAM
+#include <rtl/ustring.h>
+// header for define DBG_ERROR1
+#include <tools/debug.hxx>
+
+#include <typeinfo>
+
+using namespace ::com::sun::star;
+using ::rtl::OUString;
+using ::rtl::OUStringToOString;
+
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::rtl::OUString;
+
+// ----------------------------------------
+
+::std::vector< Reference< chart2::XDataSeries > >
+ SchXMLSeriesHelper::getDataSeriesFromDiagram(
+ const Reference< chart2::XDiagram > & xDiagram )
+{
+ ::std::vector< Reference< chart2::XDataSeries > > aResult;
+
+ try
+ {
+ Reference< chart2::XCoordinateSystemContainer > xCooSysCnt(
+ xDiagram, uno::UNO_QUERY_THROW );
+ Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq(
+ xCooSysCnt->getCoordinateSystems());
+ for( sal_Int32 i=0; i<aCooSysSeq.getLength(); ++i )
+ {
+ Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[i], uno::UNO_QUERY_THROW );
+ Sequence< Reference< chart2::XChartType > > aChartTypeSeq( xCTCnt->getChartTypes());
+ for( sal_Int32 j=0; j<aChartTypeSeq.getLength(); ++j )
+ {
+ Reference< chart2::XDataSeriesContainer > xDSCnt( aChartTypeSeq[j], uno::UNO_QUERY_THROW );
+ Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xDSCnt->getDataSeries() );
+ ::std::copy( aSeriesSeq.getConstArray(), aSeriesSeq.getConstArray() + aSeriesSeq.getLength(),
+ ::std::back_inserter( aResult ));
+ }
+ }
+ }
+ catch( uno::Exception & ex )
+ {
+ (void)ex; // avoid warning for pro build
+
+ OSL_ENSURE( false, OUStringToOString( OUString(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "Exception caught. Type: " )) +
+ OUString::createFromAscii( typeid( ex ).name()) +
+ OUString( RTL_CONSTASCII_USTRINGPARAM( ", Message: " )) +
+ ex.Message), RTL_TEXTENCODING_ASCII_US ).getStr());
+
+ }
+
+ return aResult;
+}
+
+::std::map< Reference< chart2::XDataSeries >, sal_Int32 > SchXMLSeriesHelper::getDataSeriesIndexMapFromDiagram(
+ const Reference< chart2::XDiagram > & xDiagram )
+{
+ ::std::map< Reference< chart2::XDataSeries >, sal_Int32 > aRet;
+
+ sal_Int32 nIndex=0;
+
+ ::std::vector< Reference< chart2::XDataSeries > > aSeriesVector( SchXMLSeriesHelper::getDataSeriesFromDiagram( xDiagram ));
+ for( ::std::vector< Reference< chart2::XDataSeries > >::const_iterator aSeriesIt( aSeriesVector.begin() )
+ ; aSeriesIt != aSeriesVector.end()
+ ; aSeriesIt++, nIndex++ )
+ {
+ Reference< chart2::XDataSeries > xSeries( *aSeriesIt );
+ if( xSeries.is() )
+ {
+ if( aRet.end() == aRet.find(xSeries) )
+ aRet[xSeries]=nIndex;
+ }
+ }
+ return aRet;
+}
+
+uno::Reference< chart2::XChartType > lcl_getChartTypeOfSeries(
+ const uno::Reference< chart2::XDiagram >& xDiagram
+ , const Reference< chart2::XDataSeries >& xSeries )
+{
+ if(!xDiagram.is())
+ return 0;
+
+ //iterate through the model to find the given xSeries
+ //the found parent indicates the charttype
+
+ //iterate through all coordinate systems
+ uno::Reference< chart2::XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY );
+ if( !xCooSysContainer.is())
+ return 0;
+
+ uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() );
+ for( sal_Int32 nCS = 0; nCS < aCooSysList.getLength(); ++nCS )
+ {
+ uno::Reference< chart2::XCoordinateSystem > xCooSys( aCooSysList[nCS] );
+
+ //iterate through all chart types in the current coordinate system
+ uno::Reference< chart2::XChartTypeContainer > xChartTypeContainer( xCooSys, uno::UNO_QUERY );
+ OSL_ASSERT( xChartTypeContainer.is());
+ if( !xChartTypeContainer.is() )
+ continue;
+ uno::Sequence< uno::Reference< chart2::XChartType > > aChartTypeList( xChartTypeContainer->getChartTypes() );
+ for( sal_Int32 nT = 0; nT < aChartTypeList.getLength(); ++nT )
+ {
+ uno::Reference< chart2::XChartType > xChartType( aChartTypeList[nT] );
+
+ //iterate through all series in this chart type
+ uno::Reference< chart2::XDataSeriesContainer > xDataSeriesContainer( xChartType, uno::UNO_QUERY );
+ OSL_ASSERT( xDataSeriesContainer.is());
+ if( !xDataSeriesContainer.is() )
+ continue;
+
+ uno::Sequence< uno::Reference< chart2::XDataSeries > > aSeriesList( xDataSeriesContainer->getDataSeries() );
+ for( sal_Int32 nS = 0; nS < aSeriesList.getLength(); ++nS )
+ {
+ Reference< chart2::XDataSeries > xCurrentSeries( aSeriesList[nS] );
+
+ if( xSeries == xCurrentSeries )
+ return xChartType;
+ }
+ }
+ }
+ return 0;
+}
+
+bool SchXMLSeriesHelper::isCandleStickSeries(
+ const Reference< chart2::XDataSeries >& xSeries
+ , const Reference< frame::XModel >& xChartModel )
+{
+ bool bRet = false;
+
+ uno::Reference< chart2::XChartDocument > xNewDoc( xChartModel, uno::UNO_QUERY );
+ if( xNewDoc.is() )
+ {
+ uno::Reference< chart2::XDiagram > xNewDiagram( xNewDoc->getFirstDiagram() );
+ if( xNewDiagram.is() )
+ {
+ uno::Reference< chart2::XChartType > xChartType( lcl_getChartTypeOfSeries(
+ xNewDiagram, xSeries ) );
+ if( xChartType.is() )
+ {
+ rtl::OUString aServiceName( xChartType->getChartType() );
+ if( aServiceName.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.chart2.CandleStickChartType" ) ) ) )
+ bRet = true;
+ }
+ }
+ }
+ return bRet;
+}
+
+// static
+Reference< chart2::XDataSeries > SchXMLSeriesHelper::getFirstCandleStickSeries(
+ const Reference< chart2::XDiagram > & xDiagram )
+{
+ Reference< chart2::XDataSeries > xResult;
+
+ try
+ {
+ Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY_THROW );
+ Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems());
+ for( sal_Int32 nCooSysIdx=0; !xResult.is() && nCooSysIdx<aCooSysSeq.getLength(); ++nCooSysIdx )
+ {
+ Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[nCooSysIdx], uno::UNO_QUERY_THROW );
+ Sequence< Reference< chart2::XChartType > > aCTSeq( xCTCnt->getChartTypes());
+ for( sal_Int32 nCTIdx=0; !xResult.is() && nCTIdx<aCTSeq.getLength(); ++nCTIdx )
+ {
+ if( aCTSeq[nCTIdx]->getChartType().equals(
+ ::rtl::OUString::createFromAscii("com.sun.star.chart2.CandleStickChartType")))
+ {
+ Reference< chart2::XDataSeriesContainer > xSeriesCnt( aCTSeq[nCTIdx], uno::UNO_QUERY_THROW );
+ Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xSeriesCnt->getDataSeries() );
+ if( aSeriesSeq.getLength())
+ xResult.set( aSeriesSeq[0] );
+ break;
+ }
+ }
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ OSL_ENSURE( false, "Exception caught" );
+ }
+ return xResult;
+}
+
+//static
+uno::Reference< beans::XPropertySet > SchXMLSeriesHelper::createOldAPISeriesPropertySet(
+ const uno::Reference< chart2::XDataSeries >& xSeries
+ , const uno::Reference< frame::XModel >& xChartModel )
+{
+ uno::Reference< beans::XPropertySet > xRet;
+
+ if( xSeries.is() )
+ {
+ try
+ {
+ uno::Reference< lang::XMultiServiceFactory > xFactory( xChartModel, uno::UNO_QUERY );
+ if( xFactory.is() )
+ {
+ xRet = uno::Reference< beans::XPropertySet >( xFactory->createInstance(
+ OUString::createFromAscii( "com.sun.star.comp.chart2.DataSeriesWrapper" ) ), uno::UNO_QUERY );
+ Reference< lang::XInitialization > xInit( xRet, uno::UNO_QUERY );
+ if(xInit.is())
+ {
+ Sequence< uno::Any > aArguments(1);
+ aArguments[0]=uno::makeAny(xSeries);
+ xInit->initialize(aArguments);
+ }
+ }
+ }
+ catch( uno::Exception & rEx )
+ {
+ (void)rEx; // avoid warning for pro build
+ DBG_ERROR1( "Exception caught SchXMLSeriesHelper::createOldAPISeriesPropertySet: %s",
+ OUStringToOString( rEx.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
+ }
+ }
+
+ return xRet;
+}
+
+//static
+uno::Reference< beans::XPropertySet > SchXMLSeriesHelper::createOldAPIDataPointPropertySet(
+ const uno::Reference< chart2::XDataSeries >& xSeries
+ , sal_Int32 nPointIndex
+ , const uno::Reference< frame::XModel >& xChartModel )
+{
+ uno::Reference< beans::XPropertySet > xRet;
+
+ if( xSeries.is() )
+ {
+ try
+ {
+ uno::Reference< lang::XMultiServiceFactory > xFactory( xChartModel, uno::UNO_QUERY );
+ if( xFactory.is() )
+ {
+ xRet = uno::Reference< beans::XPropertySet >( xFactory->createInstance(
+ OUString::createFromAscii( "com.sun.star.comp.chart2.DataSeriesWrapper" ) ), uno::UNO_QUERY );
+ Reference< lang::XInitialization > xInit( xRet, uno::UNO_QUERY );
+ if(xInit.is())
+ {
+ Sequence< uno::Any > aArguments(2);
+ aArguments[0]=uno::makeAny(xSeries);
+ aArguments[1]=uno::makeAny(nPointIndex);
+ xInit->initialize(aArguments);
+ }
+ }
+ }
+ catch( uno::Exception & rEx )
+ {
+ (void)rEx; // avoid warning for pro build
+
+ DBG_ERROR1( "Exception caught SchXMLSeriesHelper::createOldAPIDataPointPropertySet: %s",
+ OUStringToOString( rEx.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
+ }
+ }
+
+ return xRet;
+}
+
diff --git a/xmloff/source/chart/SchXMLSeriesHelper.hxx b/xmloff/source/chart/SchXMLSeriesHelper.hxx
new file mode 100644
index 000000000000..3af1654ef55b
--- /dev/null
+++ b/xmloff/source/chart/SchXMLSeriesHelper.hxx
@@ -0,0 +1,80 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _XMLOFF_SCH_XML_SERIESHELPER_HXX
+#define _XMLOFF_SCH_XML_SERIESHELPER_HXX
+
+#include <com/sun/star/chart2/data/XDataSequence.hpp>
+#include <com/sun/star/chart2/data/XDataSource.hpp>
+#include <com/sun/star/chart2/XDataSeries.hpp>
+#include <com/sun/star/chart2/XDiagram.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+
+#include <vector>
+#include <map>
+
+class SchXMLSeriesHelper
+{
+public:
+ static ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > >
+ getDataSeriesFromDiagram(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XDiagram > & xDiagram );
+ static ::std::map< ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XDataSeries >, sal_Int32 >
+ getDataSeriesIndexMapFromDiagram(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XDiagram > & xDiagram );
+
+ static bool isCandleStickSeries(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XDataSeries >& xSeries
+ , const ::com::sun::star::uno::Reference<
+ ::com::sun::star::frame::XModel >& xChartModel );
+
+ static ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XDataSeries > getFirstCandleStickSeries(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XDiagram > & xDiagram );
+
+ static ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > createOldAPISeriesPropertySet(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XDataSeries >& xSeries
+ , const ::com::sun::star::uno::Reference<
+ ::com::sun::star::frame::XModel >& xChartModel );
+
+ static ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > createOldAPIDataPointPropertySet(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XDataSeries >& xSeries
+ , sal_Int32 nPointIndex
+ , const ::com::sun::star::uno::Reference<
+ ::com::sun::star::frame::XModel >& xChartModel );
+};
+
+// _XMLOFF_SCH_XML_SERIESHELPER_HXX
+#endif
diff --git a/xmloff/source/chart/SchXMLTableContext.cxx b/xmloff/source/chart/SchXMLTableContext.cxx
new file mode 100644
index 000000000000..d3f0670f672d
--- /dev/null
+++ b/xmloff/source/chart/SchXMLTableContext.cxx
@@ -0,0 +1,1218 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmloff.hxx"
+
+#include "SchXMLTableContext.hxx"
+#include "SchXMLParagraphContext.hxx"
+#include "SchXMLTextListContext.hxx"
+#include "SchXMLImport.hxx"
+#include "SchXMLTools.hxx"
+#include "transporttypes.hxx"
+#include "XMLStringBufferImportContext.hxx"
+#include <tools/debug.hxx>
+#include <rtl/math.hxx>
+#include "xmlnmspe.hxx"
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/nmspmap.hxx>
+#include <xmloff/xmluconv.hxx>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/chart2/XDataSeriesContainer.hpp>
+#include <com/sun/star/chart2/XChartDocument.hpp>
+#include <com/sun/star/chart2/XChartTypeContainer.hpp>
+#include <com/sun/star/chart2/XInternalDataProvider.hpp>
+#include <com/sun/star/chart/XComplexDescriptionAccess.hpp>
+#include <com/sun/star/chart/ChartSeriesAddress.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+
+#include <com/sun/star/chart2/XDiagram.hpp>
+#include <com/sun/star/chart2/XAxis.hpp>
+#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
+#include <com/sun/star/chart2/AxisType.hpp>
+
+#include <vector>
+#include <algorithm>
+
+using namespace com::sun::star;
+using namespace ::xmloff::token;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::Reference;
+using ::rtl::OUString;
+
+namespace
+{
+
+const OUString lcl_aLabelPrefix( RTL_CONSTASCII_USTRINGPARAM("label "));
+const OUString lcl_aCategoriesRange( RTL_CONSTASCII_USTRINGPARAM("categories"));
+
+typedef ::std::multimap< ::rtl::OUString, ::rtl::OUString >
+ lcl_tOriginalRangeToInternalRangeMap;
+
+Sequence< OUString > lcl_getCategoriesFromTable( const SchXMLTable & rTable, bool bHasLabels )
+{
+ sal_Int32 nNumRows( static_cast< sal_Int32 >( rTable.aData.size()));
+ OSL_ENSURE( static_cast< size_t >( nNumRows ) == rTable.aData.size(), "Table too big" );
+
+ sal_Int32 nOffset(bHasLabels ? 1 : 0);
+ Sequence< OUString > aResult( nNumRows - nOffset );
+ sal_Int32 i=nOffset;
+ for( ; i<nNumRows; ++i )
+ {
+ if( !rTable.aData[i].empty() && (rTable.aData[i].front().eType == SCH_CELL_TYPE_STRING ))
+ aResult[i - nOffset] = rTable.aData[i].front().aString;
+ }
+ return aResult;
+}
+
+std::vector< Reference< chart2::XAxis > > lcl_getAxesHoldingCategoriesFromDiagram(
+ const Reference< chart2::XDiagram > & xDiagram )
+{
+ std::vector< Reference< chart2::XAxis > > aRet;
+
+ Reference< chart2::XAxis > xResult;
+ // return first x-axis as fall-back
+ Reference< chart2::XAxis > xFallBack;
+ try
+ {
+ Reference< chart2::XCoordinateSystemContainer > xCooSysCnt(
+ xDiagram, uno::UNO_QUERY_THROW );
+ Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq(
+ xCooSysCnt->getCoordinateSystems());
+ for( sal_Int32 i=0; i<aCooSysSeq.getLength(); ++i )
+ {
+ Reference< chart2::XCoordinateSystem > xCooSys( aCooSysSeq[i] );
+ OSL_ASSERT( xCooSys.is());
+ for( sal_Int32 nN = xCooSys->getDimension(); nN--; )
+ {
+ const sal_Int32 nMaximumScaleIndex = xCooSys->getMaximumAxisIndexByDimension(nN);
+ for(sal_Int32 nI=0; nI<=nMaximumScaleIndex; ++nI)
+ {
+ Reference< chart2::XAxis > xAxis = xCooSys->getAxisByDimension( nN,nI );
+ OSL_ASSERT( xAxis.is());
+ if( xAxis.is())
+ {
+ chart2::ScaleData aScaleData = xAxis->getScaleData();
+ if( aScaleData.Categories.is() || (aScaleData.AxisType == chart2::AxisType::CATEGORY) )
+ {
+ aRet.push_back(xAxis);
+ }
+ if( (nN == 0) && !xFallBack.is())
+ xFallBack.set( xAxis );
+ }
+ }
+ }
+ }
+ }
+ catch( uno::Exception & )
+ {
+ }
+
+ if( aRet.empty())
+ aRet.push_back(xFallBack);
+
+ return aRet;
+}
+
+struct lcl_ApplyCellToData : public ::std::unary_function< SchXMLCell, void >
+{
+ lcl_ApplyCellToData( Sequence< double > & rOutData ) :
+ m_rData( rOutData ),
+ m_nIndex( 0 ),
+ m_nSize( rOutData.getLength())
+ {
+ ::rtl::math::setNan( &m_fNaN );
+ }
+
+ void operator() ( const SchXMLCell & rCell )
+ {
+ if( m_nIndex < m_nSize )
+ {
+ if( rCell.eType == SCH_CELL_TYPE_FLOAT )
+ m_rData[m_nIndex] = rCell.fValue;
+ else
+ m_rData[m_nIndex] = m_fNaN;
+ }
+ ++m_nIndex;
+ }
+
+ sal_Int32 getCurrentIndex() const
+ {
+ return m_nIndex;
+ }
+
+private:
+ Sequence< double > & m_rData;
+ sal_Int32 m_nIndex;
+ sal_Int32 m_nSize;
+ double m_fNaN;
+};
+
+Sequence< Sequence< double > > lcl_getSwappedArray( const Sequence< Sequence< double > > & rData )
+{
+ sal_Int32 nOldOuterSize = rData.getLength();
+ sal_Int32 nOldInnerSize = (nOldOuterSize == 0 ? 0 : rData[0].getLength());
+ Sequence< Sequence< double > > aResult( nOldInnerSize );
+
+ for( sal_Int32 i=0; i<nOldInnerSize; ++i )
+ aResult[i].realloc( nOldOuterSize );
+
+ for( sal_Int32 nOuter=0; nOuter<nOldOuterSize; ++nOuter )
+ for( sal_Int32 nInner=0; nInner<nOldInnerSize; ++nInner )
+ aResult[nInner][nOuter] = rData[nOuter][nInner];
+
+ return aResult;
+}
+
+void lcl_fillRangeMapping(
+ const SchXMLTable & rTable,
+ lcl_tOriginalRangeToInternalRangeMap & rOutRangeMap,
+ chart::ChartDataRowSource eDataRowSource )
+{
+ sal_Int32 nRowOffset = ( rTable.bHasHeaderRow ? 1 : 0 );
+ sal_Int32 nColOffset = ( rTable.bHasHeaderColumn ? 1 : 0 );
+
+ // Fill range mapping
+ const size_t nTableRowCount( rTable.aData.size());
+ for( size_t nRow = 0; nRow < nTableRowCount; ++nRow )
+ {
+ const ::std::vector< SchXMLCell > & rRow( rTable.aData[nRow] );
+ const size_t nTableColCount( rRow.size());
+ for( size_t nCol = 0; nCol < nTableColCount; ++nCol )
+ {
+ OUString aRangeId( rRow[nCol].aRangeId );
+ if( aRangeId.getLength())
+ {
+ if( eDataRowSource == chart::ChartDataRowSource_COLUMNS )
+ {
+ if( nCol == 0 && rTable.bHasHeaderColumn )
+ {
+ OSL_ASSERT( static_cast< sal_Int32 >( nRow ) == nRowOffset );
+ rOutRangeMap.insert( lcl_tOriginalRangeToInternalRangeMap::value_type(
+ aRangeId, lcl_aCategoriesRange ));
+ }
+ else
+ {
+ OUString aColNumStr = OUString::valueOf( static_cast< sal_Int32 >( nCol - nColOffset ));
+ if( nRow == 0 && rTable.bHasHeaderRow )
+ rOutRangeMap.insert( lcl_tOriginalRangeToInternalRangeMap::value_type(
+ aRangeId, lcl_aLabelPrefix + aColNumStr ));
+ else
+ rOutRangeMap.insert( lcl_tOriginalRangeToInternalRangeMap::value_type(
+ aRangeId, aColNumStr ));
+ }
+ }
+ else // eDataRowSource == chart::ChartDataRowSource_ROWS
+ {
+ if( nRow == 0 && rTable.bHasHeaderRow )
+ {
+ OSL_ASSERT( static_cast< sal_Int32 >( nCol ) == nColOffset );
+ rOutRangeMap.insert( lcl_tOriginalRangeToInternalRangeMap::value_type(
+ aRangeId, lcl_aCategoriesRange ));
+ }
+ else
+ {
+ OUString aRowNumStr = OUString::valueOf( static_cast< sal_Int32 >( nRow - nRowOffset ));
+ if( nCol == 0 && rTable.bHasHeaderColumn )
+ rOutRangeMap.insert( lcl_tOriginalRangeToInternalRangeMap::value_type(
+ aRangeId, lcl_aLabelPrefix + aRowNumStr ));
+ else
+ rOutRangeMap.insert( lcl_tOriginalRangeToInternalRangeMap::value_type(
+ aRangeId, aRowNumStr ));
+ }
+ }
+ }
+ }
+ }
+}
+
+Reference< chart2::data::XDataSequence >
+ lcl_reassignDataSequence(
+ const Reference< chart2::data::XDataSequence > & xSequence,
+ const Reference< chart2::data::XDataProvider > & xDataProvider,
+ lcl_tOriginalRangeToInternalRangeMap & rRangeMap,
+ const OUString & rRange )
+{
+ Reference< chart2::data::XDataSequence > xResult( xSequence );
+ lcl_tOriginalRangeToInternalRangeMap::iterator aIt( rRangeMap.find( rRange ));
+ if( aIt != rRangeMap.end())
+ {
+ // set sequence with correct data
+ xResult.set( xDataProvider->createDataSequenceByRangeRepresentation( aIt->second ));
+ // remove translation, because it was used
+ rRangeMap.erase( aIt );
+ }
+
+ return xResult;
+}
+
+bool lcl_mapContainsRange(
+ lcl_tOriginalRangeToInternalRangeMap & rRangeMap,
+ const OUString & rRange )
+{
+ lcl_tOriginalRangeToInternalRangeMap::iterator aIt( rRangeMap.find( rRange ));
+ return ( aIt != rRangeMap.end());
+}
+
+bool lcl_tableOfRangeMatches(
+ const ::rtl::OUString & rRange,
+ const ::rtl::OUString & rTableName )
+{
+ // both strings are non-empty and the table name is part of the range
+ return ( (rRange.getLength() > 0) &&
+ (rTableName.getLength() > 0) &&
+ (rRange.indexOf( rTableName ) != -1 ));
+}
+
+template< typename T >
+::std::vector< T > lcl_SequenceToVector( const uno::Sequence< T > & rSequence )
+{
+ ::std::vector< T > aResult( rSequence.getLength());
+ ::std::copy( rSequence.getConstArray(), rSequence.getConstArray() + rSequence.getLength(),
+ aResult.begin());
+ return aResult;
+}
+
+} // anonymous namespace
+
+
+// ----------------------------------------
+// class SchXMLTableContext
+// ----------------------------------------
+
+SchXMLTableContext::SchXMLTableContext( SchXMLImportHelper& rImpHelper,
+ SvXMLImport& rImport,
+ const rtl::OUString& rLName,
+ SchXMLTable& aTable ) :
+ SvXMLImportContext( rImport, XML_NAMESPACE_TABLE, rLName ),
+ mrImportHelper( rImpHelper ),
+ mrTable( aTable ),
+ mbHasRowPermutation( false ),
+ mbHasColumnPermutation( false )
+{
+ mrTable.nColumnIndex = -1;
+ mrTable.nMaxColumnIndex = -1;
+ mrTable.nRowIndex = -1;
+ mrTable.aData.clear();
+}
+
+SchXMLTableContext::~SchXMLTableContext()
+{
+}
+
+SvXMLImportContext *SchXMLTableContext::CreateChildContext(
+ USHORT nPrefix,
+ const rtl::OUString& rLocalName,
+ const uno::Reference< xml::sax::XAttributeList >& )
+{
+ SvXMLImportContext* pContext = 0;
+ const SvXMLTokenMap& rTokenMap = mrImportHelper.GetTableElemTokenMap();
+
+ switch( rTokenMap.Get( nPrefix, rLocalName ))
+ {
+ case XML_TOK_TABLE_HEADER_COLS:
+ mrTable.bHasHeaderColumn = true;
+ // fall through intended
+ case XML_TOK_TABLE_COLUMNS:
+ pContext = new SchXMLTableColumnsContext( mrImportHelper, GetImport(), rLocalName, mrTable );
+ break;
+
+ case XML_TOK_TABLE_COLUMN:
+ pContext = new SchXMLTableColumnContext( mrImportHelper, GetImport(), rLocalName, mrTable );
+ break;
+
+ case XML_TOK_TABLE_HEADER_ROWS:
+ mrTable.bHasHeaderRow = true;
+ // fall through intended
+ case XML_TOK_TABLE_ROWS:
+ pContext = new SchXMLTableRowsContext( mrImportHelper, GetImport(), rLocalName, mrTable );
+ break;
+
+ case XML_TOK_TABLE_ROW:
+ pContext = new SchXMLTableRowContext( mrImportHelper, GetImport(), rLocalName, mrTable );
+ break;
+
+ default:
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+ }
+
+ return pContext;
+}
+
+void SchXMLTableContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
+{
+ // get table-name
+ sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
+
+ for( sal_Int16 i = 0; i < nAttrCount; i++ )
+ {
+ rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
+ rtl::OUString aLocalName;
+ USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
+
+ if( nPrefix == XML_NAMESPACE_TABLE &&
+ IsXMLToken( aLocalName, XML_NAME ) )
+ {
+ mrTable.aTableNameOfFile = xAttrList->getValueByIndex( i );
+ break; // we only need this attribute
+ }
+ }
+}
+
+void SchXMLTableContext::EndElement()
+{
+ if( mbHasColumnPermutation )
+ {
+ OSL_ASSERT( !mbHasRowPermutation );
+ ::std::vector< sal_Int32 > aPermutation( lcl_SequenceToVector( maColumnPermutation ));
+ OSL_ASSERT( !aPermutation.empty());
+ if( aPermutation.empty())
+ return;
+
+ // permute the values of all rows according to aPermutation
+ for( ::std::vector< ::std::vector< SchXMLCell > >::iterator aRowIt( mrTable.aData.begin());
+ aRowIt != mrTable.aData.end(); ++aRowIt )
+ {
+ bool bModified = false;
+ ::std::vector< SchXMLCell > aModifiedRow;
+ const size_t nPermSize = aPermutation.size();
+ OSL_ASSERT( static_cast< sal_Int32 >( nPermSize ) - 1 == *(::std::max_element( aPermutation.begin(), aPermutation.end())));
+ const size_t nRowSize = aRowIt->size();
+ const size_t nDestSize = ::std::min( nPermSize, nRowSize );
+ for( size_t nDestinationIndex = 0; nDestinationIndex < nDestSize; ++nDestinationIndex )
+ {
+ const size_t nSourceIndex = static_cast< size_t >( aPermutation[ nDestinationIndex ] );
+ if( nSourceIndex != nDestinationIndex &&
+ nSourceIndex < nRowSize )
+ {
+ // copy original on first real permutation
+ if( !bModified )
+ {
+ OSL_ASSERT( aModifiedRow.empty());
+ aModifiedRow.reserve( aRowIt->size());
+ ::std::copy( aRowIt->begin(), aRowIt->end(), ::std::back_inserter( aModifiedRow ));
+ OSL_ASSERT( !aModifiedRow.empty());
+ }
+ OSL_ASSERT( nDestinationIndex < aModifiedRow.size());
+ aModifiedRow[ nDestinationIndex ] = (*aRowIt)[ nSourceIndex ];
+ bModified = true;
+ }
+ }
+ // copy back
+ if( bModified )
+ ::std::copy( aModifiedRow.begin(), aModifiedRow.end(), aRowIt->begin());
+ }
+ }
+ else if( mbHasRowPermutation )
+ {
+ ::std::vector< sal_Int32 > aPermutation( lcl_SequenceToVector( maRowPermutation ));
+ OSL_ASSERT( !aPermutation.empty());
+ if( aPermutation.empty())
+ return;
+
+ bool bModified = false;
+ const size_t nPermSize = aPermutation.size();
+ OSL_ASSERT( static_cast< sal_Int32 >( nPermSize ) - 1 == *(::std::max_element( aPermutation.begin(), aPermutation.end())));
+ const size_t nTableRowCount = mrTable.aData.size();
+ const size_t nDestSize = ::std::min( nPermSize, nTableRowCount );
+ ::std::vector< ::std::vector< SchXMLCell > > aDestination;
+ for( size_t nDestinationIndex = 0; nDestinationIndex < nDestSize; ++nDestinationIndex )
+ {
+ const size_t nSourceIndex = static_cast< size_t >( aPermutation[ nDestinationIndex ] );
+ if( nSourceIndex != nDestinationIndex &&
+ nSourceIndex < nTableRowCount )
+ {
+ // copy original on first real permutation
+ if( !bModified )
+ {
+ OSL_ASSERT( aDestination.empty());
+ aDestination.reserve( mrTable.aData.size());
+ ::std::copy( mrTable.aData.begin(), mrTable.aData.end(), ::std::back_inserter( aDestination ));
+ OSL_ASSERT( !aDestination.empty());
+ }
+ OSL_ASSERT( nDestinationIndex < aDestination.size());
+ aDestination[ nDestinationIndex ] = mrTable.aData[ nSourceIndex ];
+ bModified = true;
+ }
+ }
+ if( bModified )
+ {
+ // copy back
+ ::std::copy( aDestination.begin(), aDestination.end(), mrTable.aData.begin());
+ }
+ }
+}
+
+void SchXMLTableContext::setRowPermutation( const uno::Sequence< sal_Int32 > & rPermutation )
+{
+ maRowPermutation = rPermutation;
+ mbHasRowPermutation = ( rPermutation.getLength() > 0 );
+
+ if( mbHasRowPermutation && mbHasColumnPermutation )
+ {
+ mbHasColumnPermutation = false;
+ maColumnPermutation.realloc( 0 );
+ }
+}
+
+void SchXMLTableContext::setColumnPermutation( const uno::Sequence< sal_Int32 > & rPermutation )
+{
+ maColumnPermutation = rPermutation;
+ mbHasColumnPermutation = ( rPermutation.getLength() > 0 );
+
+ if( mbHasColumnPermutation && mbHasRowPermutation )
+ {
+ mbHasRowPermutation = false;
+ maRowPermutation.realloc( 0 );
+ }
+}
+
+// ========================================
+// classes for columns
+// ========================================
+
+// ----------------------------------------
+// class SchXMLTableColumnsContext
+// ----------------------------------------
+
+SchXMLTableColumnsContext::SchXMLTableColumnsContext(
+ SchXMLImportHelper& rImpHelper,
+ SvXMLImport& rImport,
+ const rtl::OUString& rLocalName,
+ SchXMLTable& aTable ) :
+ SvXMLImportContext( rImport, XML_NAMESPACE_TABLE, rLocalName ),
+ mrImportHelper( rImpHelper ),
+ mrTable( aTable )
+{
+}
+
+SchXMLTableColumnsContext::~SchXMLTableColumnsContext()
+{
+}
+
+SvXMLImportContext* SchXMLTableColumnsContext::CreateChildContext(
+ USHORT nPrefix,
+ const rtl::OUString& rLocalName,
+ const uno::Reference< xml::sax::XAttributeList >& )
+{
+ SvXMLImportContext* pContext = 0;
+
+ if( nPrefix == XML_NAMESPACE_TABLE &&
+ IsXMLToken( rLocalName, XML_TABLE_COLUMN ) )
+ {
+ pContext = new SchXMLTableColumnContext( mrImportHelper, GetImport(), rLocalName, mrTable );
+ }
+ else
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+
+ return pContext;
+}
+
+// ----------------------------------------
+// class SchXMLTableColumnContext
+// ----------------------------------------
+
+SchXMLTableColumnContext::SchXMLTableColumnContext(
+ SchXMLImportHelper& rImpHelper,
+ SvXMLImport& rImport,
+ const rtl::OUString& rLocalName,
+ SchXMLTable& aTable ) :
+ SvXMLImportContext( rImport, XML_NAMESPACE_TABLE, rLocalName ),
+ mrImportHelper( rImpHelper ),
+ mrTable( aTable )
+{
+}
+
+void SchXMLTableColumnContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
+{
+ // get number-columns-repeated attribute
+ sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
+ sal_Int32 nRepeated = 1;
+ bool bHidden = false;
+
+ for( sal_Int16 i = 0; i < nAttrCount; i++ )
+ {
+ rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
+ rtl::OUString aLocalName;
+ USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
+
+ if( nPrefix == XML_NAMESPACE_TABLE &&
+ IsXMLToken( aLocalName, XML_NUMBER_COLUMNS_REPEATED ) )
+ {
+ rtl::OUString aValue = xAttrList->getValueByIndex( i );
+ if( aValue.getLength())
+ nRepeated = aValue.toInt32();
+ }
+ else if( nPrefix == XML_NAMESPACE_TABLE &&
+ IsXMLToken( aLocalName, XML_VISIBILITY ) )
+ {
+ rtl::OUString aVisibility = xAttrList->getValueByIndex( i );
+ bHidden = aVisibility.equals( GetXMLToken( XML_COLLAPSE ) );
+ }
+ }
+
+ sal_Int32 nOldCount = mrTable.nNumberOfColsEstimate;
+ sal_Int32 nNewCount = nOldCount + nRepeated;
+ mrTable.nNumberOfColsEstimate = nNewCount;
+
+ if( bHidden )
+ {
+ //i91578 display of hidden values (copy paste scenario; use hidden flag during migration to locale table upon paste )
+ sal_Int32 nColOffset = ( mrTable.bHasHeaderColumn ? 1 : 0 );
+ for( sal_Int32 nN = nOldCount; nN<nNewCount; nN++ )
+ {
+ sal_Int32 nHiddenColumnIndex = nN-nColOffset;
+ if( nHiddenColumnIndex>=0 )
+ mrTable.aHiddenColumns.push_back(nHiddenColumnIndex);
+ }
+ }
+}
+
+SchXMLTableColumnContext::~SchXMLTableColumnContext()
+{
+}
+
+// ========================================
+// classes for rows
+// ========================================
+
+// ----------------------------------------
+// class SchXMLTableRowsContext
+// ----------------------------------------
+
+SchXMLTableRowsContext::SchXMLTableRowsContext(
+ SchXMLImportHelper& rImpHelper,
+ SvXMLImport& rImport,
+ const rtl::OUString& rLocalName,
+ SchXMLTable& aTable ) :
+ SvXMLImportContext( rImport, XML_NAMESPACE_TABLE, rLocalName ),
+ mrImportHelper( rImpHelper ),
+ mrTable( aTable )
+{
+}
+
+SchXMLTableRowsContext::~SchXMLTableRowsContext()
+{
+}
+
+SvXMLImportContext* SchXMLTableRowsContext::CreateChildContext(
+ USHORT nPrefix,
+ const rtl::OUString& rLocalName,
+ const uno::Reference< xml::sax::XAttributeList >& )
+{
+ SvXMLImportContext* pContext = 0;
+
+ if( nPrefix == XML_NAMESPACE_TABLE &&
+ IsXMLToken( rLocalName, XML_TABLE_ROW ) )
+ {
+ pContext = new SchXMLTableRowContext( mrImportHelper, GetImport(), rLocalName, mrTable );
+ }
+ else
+ {
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+ }
+
+ return pContext;
+}
+
+// ----------------------------------------
+// class SchXMLTableRowContext
+// ----------------------------------------
+
+SchXMLTableRowContext::SchXMLTableRowContext(
+ SchXMLImportHelper& rImpHelper,
+ SvXMLImport& rImport,
+ const rtl::OUString& rLocalName,
+ SchXMLTable& aTable ) :
+ SvXMLImportContext( rImport, XML_NAMESPACE_TABLE, rLocalName ),
+ mrImportHelper( rImpHelper ),
+ mrTable( aTable )
+{
+ mrTable.nColumnIndex = -1;
+ mrTable.nRowIndex++;
+
+ std::vector< SchXMLCell > aNewRow;
+ aNewRow.reserve( mrTable.nNumberOfColsEstimate );
+ while( mrTable.aData.size() <= (unsigned long)mrTable.nRowIndex )
+ mrTable.aData.push_back( aNewRow );
+}
+
+SchXMLTableRowContext::~SchXMLTableRowContext()
+{
+}
+
+SvXMLImportContext* SchXMLTableRowContext::CreateChildContext(
+ USHORT nPrefix,
+ const rtl::OUString& rLocalName,
+ const uno::Reference< xml::sax::XAttributeList >& )
+{
+ SvXMLImportContext* pContext = 0;
+
+ // <table:table-cell> element
+ if( nPrefix == XML_NAMESPACE_TABLE &&
+ IsXMLToken(rLocalName, XML_TABLE_CELL ) )
+ {
+ pContext = new SchXMLTableCellContext( mrImportHelper, GetImport(), rLocalName, mrTable );
+ }
+ else
+ {
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+ }
+
+ return pContext;
+}
+
+//---------------------------------------------------------------------------------------------------
+//---------------------------------------------------------------------------------------------------
+
+class SchXMLRangeSomewhereContext : public SvXMLImportContext
+{
+//#i113950# previously the range was exported to attribute text:id,
+//but that attribute does not allow arbitrary strings anymore
+//so we need to find an alternative to save that range info for copy/paste scenario ...
+//-> use description at an empty group element for now
+
+private:
+ ::rtl::OUString& mrRangeString;
+ ::rtl::OUStringBuffer maRangeStringBuffer;
+
+public:
+ SchXMLRangeSomewhereContext( SvXMLImport& rImport,
+ const ::rtl::OUString& rLocalName,
+ ::rtl::OUString& rRangeString );
+ virtual ~SchXMLRangeSomewhereContext();
+
+ virtual SvXMLImportContext* CreateChildContext(
+ USHORT nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList );
+ virtual void EndElement();
+};
+
+//---------------------------------------------------------------------------------------------------
+//---------------------------------------------------------------------------------------------------
+
+// ========================================
+// classes for cells and their content
+// ========================================
+
+// ----------------------------------------
+// class SchXMLTableCellContext
+// ----------------------------------------
+
+SchXMLTableCellContext::SchXMLTableCellContext(
+ SchXMLImportHelper& rImpHelper,
+ SvXMLImport& rImport,
+ const rtl::OUString& rLocalName,
+ SchXMLTable& aTable ) :
+ SvXMLImportContext( rImport, XML_NAMESPACE_TABLE, rLocalName ),
+ mrImportHelper( rImpHelper ),
+ mrTable( aTable )
+{
+}
+
+SchXMLTableCellContext::~SchXMLTableCellContext()
+{
+}
+
+void SchXMLTableCellContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
+{
+ sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
+ rtl::OUString aValue;
+ rtl::OUString aLocalName;
+ rtl::OUString aCellContent;
+ SchXMLCellType eValueType = SCH_CELL_TYPE_UNKNOWN;
+ const SvXMLTokenMap& rAttrTokenMap = mrImportHelper.GetCellAttrTokenMap();
+
+ for( sal_Int16 i = 0; i < nAttrCount; i++ )
+ {
+ rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
+ USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
+
+ switch( rAttrTokenMap.Get( nPrefix, aLocalName ))
+ {
+ case XML_TOK_CELL_VAL_TYPE:
+ aValue = xAttrList->getValueByIndex( i );
+ if( IsXMLToken( aValue, XML_FLOAT ) )
+ eValueType = SCH_CELL_TYPE_FLOAT;
+ else if( IsXMLToken( aValue, XML_STRING ) )
+ eValueType = SCH_CELL_TYPE_STRING;
+ break;
+
+ case XML_TOK_CELL_VALUE:
+ aCellContent = xAttrList->getValueByIndex( i );
+ break;
+ }
+ }
+
+ mbReadText = sal_True;
+ SchXMLCell aCell;
+ aCell.eType = eValueType;
+
+ if( eValueType == SCH_CELL_TYPE_FLOAT )
+ {
+ double fData;
+ // the result may be false if a NaN is read, but that's ok
+ SvXMLUnitConverter::convertDouble( fData, aCellContent );
+
+ aCell.fValue = fData;
+ // dont read text from following <text:p> or <text:list> element
+ mbReadText = sal_False;
+ }
+
+ mrTable.aData[ mrTable.nRowIndex ].push_back( aCell );
+ mrTable.nColumnIndex++;
+ if( mrTable.nMaxColumnIndex < mrTable.nColumnIndex )
+ mrTable.nMaxColumnIndex = mrTable.nColumnIndex;
+}
+
+SvXMLImportContext* SchXMLTableCellContext::CreateChildContext(
+ USHORT nPrefix,
+ const rtl::OUString& rLocalName,
+ const uno::Reference< xml::sax::XAttributeList >& )
+{
+ SvXMLImportContext* pContext = 0;
+
+ // <text:list> element
+ if( nPrefix == XML_NAMESPACE_TEXT && IsXMLToken( rLocalName, XML_LIST ) && mbReadText )
+ {
+ SchXMLCell& rCell = mrTable.aData[ mrTable.nRowIndex ][ mrTable.nColumnIndex ];
+ rCell.pComplexString = new Sequence< OUString >();
+ rCell.eType = SCH_CELL_TYPE_COMPLEX_STRING;
+ pContext = new SchXMLTextListContext( GetImport(), rLocalName, *rCell.pComplexString );
+ mbReadText = sal_False;//don't apply text from <text:p>
+ }
+ // <text:p> element - read text (and range from text:id old version)
+ else if( nPrefix == XML_NAMESPACE_TEXT && IsXMLToken( rLocalName, XML_P ) )
+ {
+ pContext = new SchXMLParagraphContext( GetImport(), rLocalName, maCellContent, &maRangeId );
+ }
+ // <draw:g> element - read range
+ else if( nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( rLocalName, XML_G ) )
+ {
+ //#i113950# previously the range was exported to attribute text:id, but that attribute does not allow arbitrary strings anymore
+ //so we need to find an alternative to save that range info for copy/paste scenario ... -> use description at an empty group element for now
+ pContext = new SchXMLRangeSomewhereContext( GetImport(), rLocalName, maRangeId );
+ }
+ else
+ {
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+ }
+
+ return pContext;
+}
+
+void SchXMLTableCellContext::EndElement()
+{
+ if( mbReadText && maCellContent.getLength() ) //apply text from <text:p> element
+ mrTable.aData[ mrTable.nRowIndex ][ mrTable.nColumnIndex ].aString = maCellContent;
+ if( maRangeId.getLength())
+ mrTable.aData[ mrTable.nRowIndex ][ mrTable.nColumnIndex ].aRangeId = maRangeId;
+}
+
+// ========================================
+
+void lcl_ApplyCellToComplexLabel( const SchXMLCell& rCell, Sequence< OUString >& rComplexLabel )
+{
+ if( rCell.eType == SCH_CELL_TYPE_STRING )
+ {
+ rComplexLabel.realloc(1);
+ rComplexLabel[0] = rCell.aString;
+ }
+ else if( rCell.pComplexString && rCell.eType == SCH_CELL_TYPE_COMPLEX_STRING )
+ rComplexLabel = *rCell.pComplexString;
+}
+
+void SchXMLTableHelper::applyTableToInternalDataProvider(
+ const SchXMLTable& rTable,
+ uno::Reference< chart2::XChartDocument > xChartDoc )
+{
+ // apply all data read from the local table to the internal data provider
+ if( !xChartDoc.is() || !xChartDoc->hasInternalDataProvider() )
+ return;
+ Reference< chart2::data::XDataProvider > xDataProv( xChartDoc->getDataProvider() );
+ if( !xDataProv.is() )
+ return;
+
+ //prepare the read local table data
+ sal_Int32 nNumRows( static_cast< sal_Int32 >( rTable.aData.size()));
+ sal_Int32 nRowOffset = 0;
+ if( rTable.bHasHeaderRow )
+ {
+ --nNumRows;
+ nRowOffset = 1;
+ }
+ sal_Int32 nNumColumns( rTable.nMaxColumnIndex + 1 );
+ sal_Int32 nColOffset = 0;
+ if( rTable.bHasHeaderColumn )
+ {
+ --nNumColumns;
+ nColOffset = 1;
+ }
+
+ Sequence< Sequence< double > > aDataInRows( nNumRows );
+ Sequence< Sequence< OUString > > aComplexRowDescriptions( nNumRows );
+ Sequence< Sequence< OUString > > aComplexColumnDescriptions( nNumColumns );
+ for( sal_Int32 i=0; i<nNumRows; ++i )
+ aDataInRows[i].realloc( nNumColumns );
+
+ if( rTable.aData.begin() != rTable.aData.end())
+ {
+ //apply column labels
+ if( rTable.bHasHeaderRow )
+ {
+ const ::std::vector< SchXMLCell >& rFirstRow = rTable.aData.front();
+ const sal_Int32 nColumnLabelsSize = aComplexColumnDescriptions.getLength();
+ const sal_Int32 nMax = ::std::min< sal_Int32 >( nColumnLabelsSize, static_cast< sal_Int32 >( rFirstRow.size()) - nColOffset );
+ OSL_ASSERT( nMax == nColumnLabelsSize );
+ for( sal_Int32 i=0; i<nMax; ++i )
+ lcl_ApplyCellToComplexLabel( rFirstRow[i+nColOffset], aComplexColumnDescriptions[i] );
+ }
+
+ std::vector< ::std::vector< SchXMLCell > >::const_iterator aRowIter( rTable.aData.begin() + nRowOffset );
+ std::vector< ::std::vector< SchXMLCell > >::const_iterator aEnd( rTable.aData.end() );
+ for( sal_Int32 nRow = 0; aRowIter != aEnd && nRow < nNumRows; ++aRowIter, ++nRow )
+ {
+ const ::std::vector< SchXMLCell >& rRow = *aRowIter;
+ if( !rRow.empty() )
+ {
+ // row label
+ if( rTable.bHasHeaderColumn )
+ lcl_ApplyCellToComplexLabel( rRow.front(), aComplexRowDescriptions[nRow] );
+
+ // values
+ Sequence< double >& rTargetRow = aDataInRows[nRow];
+ lcl_ApplyCellToData aApplyCellToData = ::std::for_each( rRow.begin() + nColOffset, rRow.end(), lcl_ApplyCellToData( rTargetRow ) );
+ double fNaN = 0.0;
+ ::rtl::math::setNan( &fNaN );
+ for( sal_Int32 nCurrentIndex = aApplyCellToData.getCurrentIndex(); nCurrentIndex<nNumColumns; nCurrentIndex++ )
+ rTargetRow[nCurrentIndex] = fNaN;//#i110615#
+ }
+ }
+ }
+
+ //apply the collected data to the chart
+ Reference< chart::XComplexDescriptionAccess > xDataAccess( xDataProv, uno::UNO_QUERY );
+ if( !xDataAccess.is() )
+ return;
+
+ xDataAccess->setData( aDataInRows );
+ if( rTable.bHasHeaderColumn )
+ xDataAccess->setComplexRowDescriptions( aComplexRowDescriptions );
+ if( rTable.bHasHeaderRow )
+ xDataAccess->setComplexColumnDescriptions( aComplexColumnDescriptions );
+}
+
+void SchXMLTableHelper::switchRangesFromOuterToInternalIfNecessary(
+ const SchXMLTable& rTable,
+ const tSchXMLLSequencesPerIndex & rLSequencesPerIndex,
+ uno::Reference< chart2::XChartDocument > xChartDoc,
+ chart::ChartDataRowSource eDataRowSource )
+{
+ if( ! (xChartDoc.is() && xChartDoc->hasInternalDataProvider()))
+ return;
+
+ // If the range-strings are valid (starting with "local-table") they should
+ // be interpreted like given, otherwise (when the ranges refer to Calc- or
+ // Writer-ranges, but the container is not available like when pasting a
+ // chart from Calc to Impress) the range is ignored, and every object gets
+ // one table column in the order of appearance, which is: 1. categories,
+ // 2. data series: 2.a) domains, 2.b) values (main-role, usually y-values)
+
+ Reference< chart2::data::XDataProvider > xDataProv( xChartDoc->getDataProvider());
+
+ // create a mapping from original ranges to new ranges
+ lcl_tOriginalRangeToInternalRangeMap aRangeMap;
+
+ lcl_fillRangeMapping( rTable, aRangeMap, eDataRowSource );
+
+ bool bCategoriesApplied = false;
+ // translate ranges (using the map created before)
+ for( tSchXMLLSequencesPerIndex::const_iterator aLSeqIt( rLSequencesPerIndex.begin());
+ aLSeqIt != rLSequencesPerIndex.end(); ++aLSeqIt )
+ {
+ if( aLSeqIt->second.is())
+ {
+ // values/error bars/categories
+ if( aLSeqIt->first.second == SCH_XML_PART_VALUES ||
+ aLSeqIt->first.second == SCH_XML_PART_ERROR_BARS )
+ {
+ Reference< chart2::data::XDataSequence > xSeq( aLSeqIt->second->getValues());
+ OUString aRange;
+ if( xSeq.is() &&
+ SchXMLTools::getXMLRangePropertyFromDataSequence( xSeq, aRange, /* bClearProp = */ true ) &&
+ lcl_mapContainsRange( aRangeMap, aRange ))
+ {
+ Reference< chart2::data::XDataSequence > xNewSeq(
+ lcl_reassignDataSequence( xSeq, xDataProv, aRangeMap, aRange ));
+ if( xNewSeq != xSeq )
+ {
+ SchXMLTools::copyProperties( Reference< beans::XPropertySet >( xSeq, uno::UNO_QUERY ),
+ Reference< beans::XPropertySet >( xNewSeq, uno::UNO_QUERY ));
+ aLSeqIt->second->setValues( xNewSeq );
+ }
+ }
+ else
+ {
+ if( lcl_tableOfRangeMatches( aRange, rTable.aTableNameOfFile ))
+ {
+ if( aLSeqIt->first.first == SCH_XML_CATEGORIES_INDEX )
+ bCategoriesApplied = true;
+ }
+ else
+ {
+ if( aLSeqIt->first.first == SCH_XML_CATEGORIES_INDEX )
+ {
+ Reference< beans::XPropertySet > xOldSequenceProp( aLSeqIt->second->getValues(), uno::UNO_QUERY );
+ Reference< chart2::data::XDataSequence > xNewSequence(
+ xDataProv->createDataSequenceByRangeRepresentation(
+ OUString(RTL_CONSTASCII_USTRINGPARAM("categories"))));
+ SchXMLTools::copyProperties(
+ xOldSequenceProp, Reference< beans::XPropertySet >( xNewSequence, uno::UNO_QUERY ));
+ aLSeqIt->second->setValues( xNewSequence );
+ bCategoriesApplied = true;
+ }
+ else
+ {
+ Reference< beans::XPropertySet > xOldSequenceProp( aLSeqIt->second->getValues(), uno::UNO_QUERY );
+ OUString aRep( OUString::valueOf( aLSeqIt->first.first ));
+ Reference< chart2::data::XDataSequence > xNewSequence(
+ xDataProv->createDataSequenceByRangeRepresentation( aRep ));
+ SchXMLTools::copyProperties(
+ xOldSequenceProp, Reference< beans::XPropertySet >( xNewSequence, uno::UNO_QUERY ));
+ aLSeqIt->second->setValues( xNewSequence );
+ }
+ }
+ }
+ }
+ else // labels
+ {
+ OSL_ASSERT( aLSeqIt->first.second == SCH_XML_PART_LABEL );
+ // labels
+ Reference< chart2::data::XDataSequence > xSeq( aLSeqIt->second->getLabel());
+ OUString aRange;
+ if( xSeq.is() &&
+ SchXMLTools::getXMLRangePropertyFromDataSequence( xSeq, aRange, /* bClearProp = */ true ) &&
+ lcl_mapContainsRange( aRangeMap, aRange ))
+ {
+ Reference< chart2::data::XDataSequence > xNewSeq(
+ lcl_reassignDataSequence( xSeq, xDataProv, aRangeMap, aRange ));
+ if( xNewSeq != xSeq )
+ {
+ SchXMLTools::copyProperties( Reference< beans::XPropertySet >( xSeq, uno::UNO_QUERY ),
+ Reference< beans::XPropertySet >( xNewSeq, uno::UNO_QUERY ));
+ aLSeqIt->second->setLabel( xNewSeq );
+ }
+ }
+ else if( ! lcl_tableOfRangeMatches( aRange, rTable.aTableNameOfFile ))
+ {
+ OUString aRep( RTL_CONSTASCII_USTRINGPARAM("label "));
+ aRep += OUString::valueOf( aLSeqIt->first.first );
+
+ Reference< chart2::data::XDataSequence > xNewSeq(
+ xDataProv->createDataSequenceByRangeRepresentation( aRep ));
+ SchXMLTools::copyProperties( Reference< beans::XPropertySet >( xSeq, uno::UNO_QUERY ),
+ Reference< beans::XPropertySet >( xNewSeq, uno::UNO_QUERY ));
+ aLSeqIt->second->setLabel( xNewSeq );
+ }
+ }
+ }
+ }
+
+ // there exist files with own data without a categories element but with row
+ // descriptions. The row descriptions were used as categories even without
+ // the categories element
+ if( ! bCategoriesApplied )
+ {
+ SchXMLTools::CreateCategories(
+ xDataProv, xChartDoc, OUString(RTL_CONSTASCII_USTRINGPARAM("categories")),
+ 0 /* nCooSysIndex */, 0 /* nDimension */ );
+ }
+
+ //i91578 display of hidden values (copy paste scenario; use hidden flag during migration to locale table upon paste )
+ //remove series that consist only of hidden columns
+ Reference< chart2::XInternalDataProvider > xInternalDataProvider( xDataProv, uno::UNO_QUERY );
+ if( xInternalDataProvider.is() && !rTable.aHiddenColumns.empty() )
+ {
+ try
+ {
+ Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xChartDoc->getFirstDiagram(), uno::UNO_QUERY_THROW );
+ Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems() );
+ for( sal_Int32 nC=0; nC<aCooSysSeq.getLength(); ++nC )
+ {
+ Reference< chart2::XChartTypeContainer > xCooSysContainer( aCooSysSeq[nC], uno::UNO_QUERY_THROW );
+ Sequence< Reference< chart2::XChartType > > aChartTypeSeq( xCooSysContainer->getChartTypes());
+ for( sal_Int32 nT=0; nT<aChartTypeSeq.getLength(); ++nT )
+ {
+ Reference< chart2::XDataSeriesContainer > xSeriesContainer( aChartTypeSeq[nT], uno::UNO_QUERY );
+ if(!xSeriesContainer.is())
+ continue;
+ Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xSeriesContainer->getDataSeries() );
+ std::vector< Reference< chart2::XDataSeries > > aRemainingSeries;
+
+ for( sal_Int32 nS = 0; nS < aSeriesSeq.getLength(); nS++ )
+ {
+ Reference< chart2::data::XDataSource > xDataSource( aSeriesSeq[nS], uno::UNO_QUERY );
+ if( xDataSource.is() )
+ {
+ bool bHasUnhiddenColumns = false;
+ rtl::OUString aRange;
+ uno::Sequence< Reference< chart2::data::XLabeledDataSequence > > aSequences( xDataSource->getDataSequences() );
+ for( sal_Int32 nN=0; nN< aSequences.getLength(); ++nN )
+ {
+ Reference< chart2::data::XLabeledDataSequence > xLabeledSequence( aSequences[nN] );
+ if(!xLabeledSequence.is())
+ continue;
+ Reference< chart2::data::XDataSequence > xValues( xLabeledSequence->getValues() );
+ if( xValues.is() )
+ {
+ aRange = xValues->getSourceRangeRepresentation();
+ if( ::std::find( rTable.aHiddenColumns.begin(), rTable.aHiddenColumns.end(), aRange.toInt32() ) == rTable.aHiddenColumns.end() )
+ bHasUnhiddenColumns = true;
+ }
+ if( !bHasUnhiddenColumns )
+ {
+ Reference< chart2::data::XDataSequence > xLabel( xLabeledSequence->getLabel() );
+ if( xLabel.is() )
+ {
+ aRange = xLabel->getSourceRangeRepresentation();
+ sal_Int32 nSearchIndex = 0;
+ OUString aSecondToken = aRange.getToken( 1, ' ', nSearchIndex );
+ if( ::std::find( rTable.aHiddenColumns.begin(), rTable.aHiddenColumns.end(), aSecondToken.toInt32() ) == rTable.aHiddenColumns.end() )
+ bHasUnhiddenColumns = true;
+ }
+ }
+ }
+ if( bHasUnhiddenColumns )
+ aRemainingSeries.push_back( aSeriesSeq[nS] );
+ }
+ }
+
+ if( static_cast<sal_Int32>(aRemainingSeries.size()) != aSeriesSeq.getLength() )
+ {
+ //remove the series that have only hidden data
+ Sequence< Reference< chart2::XDataSeries > > aRemainingSeriesSeq( aRemainingSeries.size());
+ ::std::copy( aRemainingSeries.begin(), aRemainingSeries.end(), aRemainingSeriesSeq.getArray());
+ xSeriesContainer->setDataSeries( aRemainingSeriesSeq );
+
+ //remove unused sequences
+ Reference< chart2::data::XDataSource > xDataSource( xChartDoc, uno::UNO_QUERY );
+ if( xDataSource.is() )
+ {
+ //first detect which collumns are really used
+ std::map< sal_Int32, bool > aUsageMap;
+ rtl::OUString aRange;
+ Sequence< Reference< chart2::data::XLabeledDataSequence > > aUsedSequences( xDataSource->getDataSequences() );
+ for( sal_Int32 nN=0; nN< aUsedSequences.getLength(); ++nN )
+ {
+ Reference< chart2::data::XLabeledDataSequence > xLabeledSequence( aUsedSequences[nN] );
+ if(!xLabeledSequence.is())
+ continue;
+ Reference< chart2::data::XDataSequence > xValues( xLabeledSequence->getValues() );
+ if( xValues.is() )
+ {
+ aRange = xValues->getSourceRangeRepresentation();
+ sal_Int32 nIndex = aRange.toInt32();
+ if( nIndex!=0 || !aRange.equals(lcl_aCategoriesRange) )
+ aUsageMap[nIndex] = true;
+ }
+ Reference< chart2::data::XDataSequence > xLabel( xLabeledSequence->getLabel() );
+ if( xLabel.is() )
+ {
+ aRange = xLabel->getSourceRangeRepresentation();
+ sal_Int32 nSearchIndex = 0;
+ OUString aSecondToken = aRange.getToken( 1, ' ', nSearchIndex );
+ if( aSecondToken.getLength() )
+ aUsageMap[aSecondToken.toInt32()] = true;
+ }
+ }
+
+ ::std::vector< sal_Int32 > aSequenceIndexesToDelete;
+ for( ::std::vector< sal_Int32 >::const_iterator aIt(
+ rTable.aHiddenColumns.begin()); aIt != rTable.aHiddenColumns.end(); ++aIt )
+ {
+ sal_Int32 nSequenceIndex = *aIt;
+ if( aUsageMap.find(nSequenceIndex) != aUsageMap.end() )
+ continue;
+ aSequenceIndexesToDelete.push_back(nSequenceIndex);
+ }
+
+ // delete unnecessary sequences of the internal data
+ // iterate using greatest index first, so that deletion does not
+ // shift other sequences that will be deleted later
+ ::std::sort( aSequenceIndexesToDelete.begin(), aSequenceIndexesToDelete.end());
+ for( ::std::vector< sal_Int32 >::reverse_iterator aIt(
+ aSequenceIndexesToDelete.rbegin()); aIt != aSequenceIndexesToDelete.rend(); ++aIt )
+ {
+ if( *aIt != -1 )
+ xInternalDataProvider->deleteSequence( *aIt );
+ }
+ }
+ }
+ }
+ }
+ }
+ catch( uno::Exception & ex )
+ {
+ (void)ex; // avoid warning for pro build
+ }
+ }
+}
+
+//---------------------------------------------------------------------------------------------------
+
+SchXMLRangeSomewhereContext::SchXMLRangeSomewhereContext( SvXMLImport& rImport,
+ const OUString& rLocalName,
+ OUString& rRangeString ) :
+ SvXMLImportContext( rImport, XML_NAMESPACE_TEXT, rLocalName ),
+ mrRangeString( rRangeString )
+{
+}
+
+SchXMLRangeSomewhereContext::~SchXMLRangeSomewhereContext()
+{
+}
+
+SvXMLImportContext* SchXMLRangeSomewhereContext::CreateChildContext(
+ USHORT nPrefix,
+ const OUString& rLocalName,
+ const uno::Reference< xml::sax::XAttributeList >& )
+{
+ if( XML_NAMESPACE_SVG == nPrefix && IsXMLToken( rLocalName, XML_DESC ) )
+ {
+ return new XMLStringBufferImportContext(
+ GetImport(), nPrefix, rLocalName, maRangeStringBuffer );
+ }
+ return new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+}
+
+void SchXMLRangeSomewhereContext::EndElement()
+{
+ mrRangeString = maRangeStringBuffer.makeStringAndClear();
+}
diff --git a/xmloff/source/chart/SchXMLTableContext.hxx b/xmloff/source/chart/SchXMLTableContext.hxx
new file mode 100644
index 000000000000..717628b18de0
--- /dev/null
+++ b/xmloff/source/chart/SchXMLTableContext.hxx
@@ -0,0 +1,229 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _SCH_XMLTABLECONTEXT_HXX_
+#define _SCH_XMLTABLECONTEXT_HXX_
+
+#include <xmloff/xmlictxt.hxx>
+#include "SchXMLImport.hxx"
+// #include "SchXMLChartContext.hxx"
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <com/sun/star/chart/ChartDataRowSource.hpp>
+
+#include "transporttypes.hxx"
+
+namespace com { namespace sun { namespace star {
+ namespace frame {
+ class XModel;
+ }
+ namespace xml { namespace sax {
+ class XAttributeList;
+ }}
+ namespace chart {
+ class XChartDocument;
+ struct ChartSeriesAddress;
+}}}}
+
+// ========================================
+
+class SchXMLTableContext : public SvXMLImportContext
+{
+private:
+ SchXMLImportHelper& mrImportHelper;
+ SchXMLTable& mrTable;
+
+ bool mbHasRowPermutation;
+ bool mbHasColumnPermutation;
+ ::com::sun::star::uno::Sequence< sal_Int32 > maRowPermutation;
+ ::com::sun::star::uno::Sequence< sal_Int32 > maColumnPermutation;
+
+public:
+ SchXMLTableContext( SchXMLImportHelper& rImpHelper,
+ SvXMLImport& rImport,
+ const rtl::OUString& rLocalName,
+ SchXMLTable& aTable );
+ virtual ~SchXMLTableContext();
+
+ virtual SvXMLImportContext* CreateChildContext(
+ USHORT nPrefix,
+ const rtl::OUString& rLocalName,
+ const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList );
+ virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
+ virtual void EndElement();
+
+ void setRowPermutation( const ::com::sun::star::uno::Sequence< sal_Int32 > & rPermutation );
+ void setColumnPermutation( const ::com::sun::star::uno::Sequence< sal_Int32 > & rPermutation );
+};
+
+// ----------------------------------------
+
+class SchXMLTableHelper
+{
+private:
+ static void GetCellAddress( const rtl::OUString& rStr, sal_Int32& rCol, sal_Int32& rRow );
+ static sal_Bool GetCellRangeAddress( const rtl::OUString& rStr, SchNumericCellRangeAddress& rResult );
+ static void PutTableContentIntoSequence(
+ const SchXMLTable& rTable,
+ SchNumericCellRangeAddress& rAddress,
+ sal_Int32 nSeriesIndex,
+ com::sun::star::uno::Sequence< com::sun::star::uno::Sequence< double > >& aSequence );
+ static void AdjustMax( const SchNumericCellRangeAddress& rAddr,
+ sal_Int32& nRows, sal_Int32& nColumns );
+
+public:
+ static void applyTableToInternalDataProvider( const SchXMLTable& rTable,
+ com::sun::star::uno::Reference< com::sun::star::chart2::XChartDocument > xChartDoc );
+
+ /** This function reorders local data to fit the correct data structure.
+ Call it after the data series got their styles set.
+ */
+ static void switchRangesFromOuterToInternalIfNecessary( const SchXMLTable& rTable,
+ const tSchXMLLSequencesPerIndex & rLSequencesPerIndex,
+ com::sun::star::uno::Reference< com::sun::star::chart2::XChartDocument > xChartDoc,
+ ::com::sun::star::chart::ChartDataRowSource eDataRowSource );
+};
+
+// ========================================
+
+// ----------------------------------------
+// classes for columns
+// ----------------------------------------
+
+/** With this context all column elements are parsed to
+ determine the index of the column containing
+ the row descriptions and probably get an estimate
+ for the altogether number of columns
+ */
+class SchXMLTableColumnsContext : public SvXMLImportContext
+{
+private:
+ SchXMLImportHelper& mrImportHelper;
+ SchXMLTable& mrTable;
+
+public:
+ SchXMLTableColumnsContext( SchXMLImportHelper& rImpHelper,
+ SvXMLImport& rImport,
+ const rtl::OUString& rLocalName,
+ SchXMLTable& aTable );
+ virtual ~SchXMLTableColumnsContext();
+
+ virtual SvXMLImportContext* CreateChildContext(
+ USHORT nPrefix,
+ const rtl::OUString& rLocalName,
+ const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList );
+};
+
+// ----------------------------------------
+
+class SchXMLTableColumnContext : public SvXMLImportContext
+{
+private:
+ SchXMLImportHelper& mrImportHelper;
+ SchXMLTable& mrTable;
+
+public:
+ SchXMLTableColumnContext( SchXMLImportHelper& rImpHelper,
+ SvXMLImport& rImport,
+ const rtl::OUString& rLocalName,
+ SchXMLTable& aTable );
+ virtual ~SchXMLTableColumnContext();
+ virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
+};
+
+// ----------------------------------------
+// classes for rows
+// ----------------------------------------
+
+class SchXMLTableRowsContext : public SvXMLImportContext
+{
+private:
+ SchXMLImportHelper& mrImportHelper;
+ SchXMLTable& mrTable;
+
+public:
+ SchXMLTableRowsContext( SchXMLImportHelper& rImpHelper,
+ SvXMLImport& rImport,
+ const rtl::OUString& rLocalName,
+ SchXMLTable& aTable );
+ virtual ~SchXMLTableRowsContext();
+
+ virtual SvXMLImportContext* CreateChildContext(
+ USHORT nPrefix,
+ const rtl::OUString& rLocalName,
+ const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList );
+};
+
+// ----------------------------------------
+
+class SchXMLTableRowContext : public SvXMLImportContext
+{
+private:
+ SchXMLImportHelper& mrImportHelper;
+ SchXMLTable& mrTable;
+
+public:
+ SchXMLTableRowContext( SchXMLImportHelper& rImpHelper,
+ SvXMLImport& rImport,
+ const rtl::OUString& rLocalName,
+ SchXMLTable& aTable );
+ virtual ~SchXMLTableRowContext();
+
+ virtual SvXMLImportContext* CreateChildContext(
+ USHORT nPrefix,
+ const rtl::OUString& rLocalName,
+ const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList );
+};
+
+// ----------------------------------------
+// classes for cells and their content
+// ----------------------------------------
+
+class SchXMLTableCellContext : public SvXMLImportContext
+{
+private:
+ SchXMLImportHelper& mrImportHelper;
+ SchXMLTable& mrTable;
+ rtl::OUString maCellContent;
+ rtl::OUString maRangeId;
+ sal_Bool mbReadText;
+
+public:
+ SchXMLTableCellContext( SchXMLImportHelper& rImpHelper,
+ SvXMLImport& rImport,
+ const rtl::OUString& rLocalName,
+ SchXMLTable& aTable );
+ virtual ~SchXMLTableCellContext();
+
+ virtual SvXMLImportContext* CreateChildContext(
+ USHORT nPrefix,
+ const rtl::OUString& rLocalName,
+ const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList );
+ virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
+ virtual void EndElement();
+};
+
+#endif // _SCH_XMLTABLECONTEXT_HXX_
diff --git a/xmloff/source/chart/SchXMLTextListContext.cxx b/xmloff/source/chart/SchXMLTextListContext.cxx
new file mode 100755
index 000000000000..884acb473108
--- /dev/null
+++ b/xmloff/source/chart/SchXMLTextListContext.cxx
@@ -0,0 +1,136 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmloff.hxx"
+
+#include "SchXMLImport.hxx"
+#include "SchXMLTextListContext.hxx"
+#include "SchXMLParagraphContext.hxx"
+
+#include "xmlnmspe.hxx"
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/nmspmap.hxx>
+
+using ::rtl::OUString;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::Reference;
+using namespace com::sun::star;
+using namespace ::xmloff::token;
+
+//-------------------------------------------------
+class SchXMLListItemContext : public SvXMLImportContext
+{
+public:
+ SchXMLListItemContext( SvXMLImport& rImport, const OUString& rLocalName, OUString& rText );
+ virtual ~SchXMLListItemContext();
+ virtual void StartElement( const Reference< xml::sax::XAttributeList >& xAttrList );
+ virtual void EndElement();
+
+ virtual SvXMLImportContext* CreateChildContext(
+ USHORT nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList );
+
+private:
+ ::rtl::OUString& m_rText;
+};
+
+SchXMLListItemContext::SchXMLListItemContext(
+ SvXMLImport& rImport
+ , const OUString& rLocalName
+ , OUString& rText )
+ : SvXMLImportContext( rImport, XML_NAMESPACE_TEXT, rLocalName )
+ , m_rText( rText )
+{
+}
+
+SchXMLListItemContext::~SchXMLListItemContext()
+{}
+
+void SchXMLListItemContext::StartElement( const Reference< xml::sax::XAttributeList >& /*xAttrList*/ )
+{
+}
+
+void SchXMLListItemContext::EndElement()
+{
+}
+
+SvXMLImportContext* SchXMLListItemContext::CreateChildContext(
+ USHORT nPrefix, const OUString& rLocalName,
+ const uno::Reference< xml::sax::XAttributeList >& )
+{
+ SvXMLImportContext* pContext = 0;
+ if( nPrefix == XML_NAMESPACE_TEXT && IsXMLToken( rLocalName, XML_P ) )
+ pContext = new SchXMLParagraphContext( GetImport(), rLocalName, m_rText );
+ else
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+ return pContext;
+}
+
+//-------------------------------------------------
+
+SchXMLTextListContext::SchXMLTextListContext(
+ SvXMLImport& rImport
+ , const OUString& rLocalName
+ , Sequence< OUString>& rTextList )
+ : SvXMLImportContext( rImport, XML_NAMESPACE_TEXT, rLocalName )
+ , m_rTextList( rTextList )
+ , m_aTextVector()
+{
+}
+
+SchXMLTextListContext::~SchXMLTextListContext()
+{
+}
+
+void SchXMLTextListContext::StartElement( const Reference< xml::sax::XAttributeList >& /*xAttrList*/ )
+{
+}
+
+void SchXMLTextListContext::EndElement()
+{
+ sal_Int32 nCount = m_aTextVector.size();
+ m_rTextList.realloc(nCount);
+ for( sal_Int32 nN=0; nN<nCount; nN++ )
+ m_rTextList[nN]=m_aTextVector[nN];
+}
+
+SvXMLImportContext* SchXMLTextListContext::CreateChildContext(
+ USHORT nPrefix, const OUString& rLocalName,
+ const uno::Reference< xml::sax::XAttributeList >& )
+{
+ SvXMLImportContext* pContext = 0;
+ if( nPrefix == XML_NAMESPACE_TEXT && IsXMLToken( rLocalName, XML_LIST_ITEM ) )
+ {
+ m_aTextVector.push_back( OUString() );
+ pContext = new SchXMLListItemContext( GetImport(), rLocalName, m_aTextVector.back() );
+ }
+ else
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+ return pContext;
+}
diff --git a/xmloff/source/chart/SchXMLTextListContext.hxx b/xmloff/source/chart/SchXMLTextListContext.hxx
new file mode 100755
index 000000000000..736331d10e71
--- /dev/null
+++ b/xmloff/source/chart/SchXMLTextListContext.hxx
@@ -0,0 +1,58 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _SCH_XMLTEXTLISTCONTEXT_HXX_
+#define _SCH_XMLTEXTLISTCONTEXT_HXX_
+
+#include <xmloff/xmlictxt.hxx>
+#include "rtl/ustring.hxx"
+#include <vector>
+
+namespace com { namespace sun { namespace star { namespace xml { namespace sax {
+ class XAttributeList;
+}}}}}
+
+class SchXMLTextListContext : public SvXMLImportContext
+{
+public:
+ SchXMLTextListContext( SvXMLImport& rImport,
+ const ::rtl::OUString& rLocalName,
+ ::com::sun::star::uno::Sequence< ::rtl::OUString>& rTextList );
+ virtual ~SchXMLTextListContext();
+ virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
+ virtual void EndElement();
+
+ virtual SvXMLImportContext* CreateChildContext(
+ USHORT nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList );
+
+private:
+ ::com::sun::star::uno::Sequence< ::rtl::OUString>& m_rTextList;
+ std::vector< ::rtl::OUString> m_aTextVector;
+};
+
+#endif // _SCH_XMLTEXTLISTCONTEXT_HXX_
diff --git a/xmloff/source/chart/SchXMLTools.cxx b/xmloff/source/chart/SchXMLTools.cxx
new file mode 100644
index 000000000000..b2a90e534771
--- /dev/null
+++ b/xmloff/source/chart/SchXMLTools.cxx
@@ -0,0 +1,897 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmloff.hxx"
+
+#include "SchXMLTools.hxx"
+
+/*
+#include <tools/debug.hxx>
+*/
+#include <rtl/ustrbuf.hxx>
+#include <comphelper/InlineContainer.hxx>
+// header for class SvXMLUnitConverter
+#include <xmloff/xmluconv.hxx>
+// header for struct SvXMLEnumMapEntry
+#include <xmloff/xmlement.hxx>
+// header for define __FAR_DATA
+#include <tools/solar.h>
+
+// header for class SvXMLImportPropertyMapper
+#include <xmloff/xmlimppr.hxx>
+// header for class XMLPropStyleContext
+#include <xmloff/prstylei.hxx>
+// header for class XMLPropertySetMapper
+#include <xmloff/xmlprmap.hxx>
+#include <xmloff/xmlexp.hxx>
+#include "xmlnmspe.hxx"
+#include <xmloff/xmlmetai.hxx>
+
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/chart2/data/XDataProvider.hpp>
+#include <com/sun/star/chart2/data/XDataReceiver.hpp>
+#include <com/sun/star/chart2/data/XRangeXMLConversion.hpp>
+#include <com/sun/star/chart2/XChartDocument.hpp>
+#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
+#include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/document/XDocumentProperties.hpp>
+#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
+#include <com/sun/star/lang/XServiceName.hpp>
+
+#include <comphelper/processfactory.hxx>
+
+using namespace com::sun::star;
+using namespace ::xmloff::token;
+
+using ::rtl::OUString;
+using ::rtl::OUStringBuffer;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+
+namespace
+{
+Reference< uno::XComponentContext > lcl_getComponentContext()
+{
+ Reference< uno::XComponentContext > xContext;
+ try
+ {
+ Reference< beans::XPropertySet > xFactProp( comphelper::getProcessServiceFactory(), uno::UNO_QUERY );
+ if( xFactProp.is())
+ xFactProp->getPropertyValue(OUString::createFromAscii("DefaultContext")) >>= xContext;
+ }
+ catch( uno::Exception& )
+ {}
+
+ return xContext;
+}
+
+rtl::OUString lcl_getGeneratorFromModel( const uno::Reference< frame::XModel >& xChartModel )
+{
+ ::rtl::OUString aGenerator;
+ uno::Reference< document::XDocumentPropertiesSupplier> xChartDocumentPropertiesSupplier( xChartModel, uno::UNO_QUERY );
+ if( xChartDocumentPropertiesSupplier.is() )
+ {
+ uno::Reference< document::XDocumentProperties > xChartDocumentProperties(
+ xChartDocumentPropertiesSupplier->getDocumentProperties());
+ if( xChartDocumentProperties.is() )
+ aGenerator = xChartDocumentProperties->getGenerator();
+ }
+ return aGenerator;
+}
+
+rtl::OUString lcl_getGeneratorFromModelOrItsParent( const uno::Reference< frame::XModel >& xChartModel )
+{
+ ::rtl::OUString aGenerator( lcl_getGeneratorFromModel(xChartModel) );
+ if( !aGenerator.getLength() ) //try to get the missing info from the parent document
+ {
+ uno::Reference< container::XChild > xChild( xChartModel, uno::UNO_QUERY );
+ if( xChild.is() )
+ aGenerator = lcl_getGeneratorFromModel( uno::Reference< frame::XModel >( xChild->getParent(), uno::UNO_QUERY) );
+ }
+ return aGenerator;
+}
+
+sal_Int32 lcl_getBuildIDFromGenerator( const ::rtl::OUString& rGenerator )
+{
+ //returns -1 if nothing found
+ sal_Int32 nBuildId = -1;
+ const OUString sBuildCompare( RTL_CONSTASCII_USTRINGPARAM( "$Build-" ) );
+ sal_Int32 nEnd = -1;
+ sal_Int32 nBegin = rGenerator.indexOf( sBuildCompare, nEnd );
+ if( nBegin != -1 )
+ {
+ OUString sBuildId( rGenerator.copy( nBegin + sBuildCompare.getLength() ) );
+ nBuildId = sBuildId.toInt32();
+ }
+ return nBuildId;
+}
+
+OUString lcl_ConvertRange( const ::rtl::OUString & rRange, const Reference< chart2::data::XDataProvider >& xDataProvider )
+{
+ OUString aResult = rRange;
+ Reference< chart2::data::XRangeXMLConversion > xRangeConversion( xDataProvider, uno::UNO_QUERY );
+ if( xRangeConversion.is())
+ aResult = xRangeConversion->convertRangeFromXML( rRange );
+ return aResult;
+}
+
+Reference< chart2::data::XDataSequence > lcl_createNewSequenceFromCachedXMLRange( const Reference< chart2::data::XDataSequence >& xSeq, const Reference< chart2::data::XDataProvider >& xDataProvider )
+{
+ Reference< chart2::data::XDataSequence > xRet;
+ OUString aRange;
+ if( xSeq.is() && SchXMLTools::getXMLRangePropertyFromDataSequence( xSeq, aRange, /* bClearProp = */ true ) )
+ {
+ xRet.set( xDataProvider->createDataSequenceByRangeRepresentation(
+ lcl_ConvertRange( aRange, xDataProvider )) );
+ SchXMLTools::copyProperties( Reference< beans::XPropertySet >( xSeq, uno::UNO_QUERY ),
+ Reference< beans::XPropertySet >( xRet, uno::UNO_QUERY ));
+ }
+ return xRet;
+}
+
+} // anonymous namespace
+
+// ----------------------------------------
+
+namespace SchXMLTools
+{
+
+static __FAR_DATA SvXMLEnumMapEntry aXMLChartClassMap[] =
+{
+ { XML_LINE, XML_CHART_CLASS_LINE },
+ { XML_AREA, XML_CHART_CLASS_AREA },
+ { XML_CIRCLE, XML_CHART_CLASS_CIRCLE },
+ { XML_RING, XML_CHART_CLASS_RING },
+ { XML_SCATTER, XML_CHART_CLASS_SCATTER },
+ { XML_RADAR, XML_CHART_CLASS_RADAR },
+ { XML_FILLED_RADAR, XML_CHART_CLASS_FILLED_RADAR },
+ { XML_BAR, XML_CHART_CLASS_BAR },
+ { XML_STOCK, XML_CHART_CLASS_STOCK },
+ { XML_BUBBLE, XML_CHART_CLASS_BUBBLE },
+ { XML_SURFACE, XML_CHART_CLASS_BAR }, //@todo change this if a surface chart is available
+ { XML_ADD_IN, XML_CHART_CLASS_ADDIN },
+ { XML_TOKEN_INVALID, XML_CHART_CLASS_UNKNOWN }
+};
+
+SchXMLChartTypeEnum GetChartTypeEnum( const OUString& rClassName )
+{
+ USHORT nEnumVal = XML_CHART_CLASS_UNKNOWN;
+ if( !SvXMLUnitConverter::convertEnum(
+ nEnumVal, rClassName, aXMLChartClassMap ) )
+ nEnumVal = XML_CHART_CLASS_UNKNOWN;
+ return SchXMLChartTypeEnum(nEnumVal);
+}
+
+typedef ::comphelper::MakeMap< ::rtl::OUString, ::rtl::OUString > tMakeStringStringMap;
+//static
+const tMakeStringStringMap& lcl_getChartTypeNameMap()
+{
+ //shape property -- chart model object property
+ static tMakeStringStringMap g_aChartTypeNameMap =
+ tMakeStringStringMap
+ ( ::rtl::OUString::createFromAscii( "com.sun.star.chart.LineDiagram" )
+ , ::rtl::OUString::createFromAscii( "com.sun.star.chart2.LineChartType" ) )
+
+ ( ::rtl::OUString::createFromAscii( "com.sun.star.chart.AreaDiagram" )
+ , ::rtl::OUString::createFromAscii( "com.sun.star.chart2.AreaChartType" ) )
+
+ ( ::rtl::OUString::createFromAscii( "com.sun.star.chart.BarDiagram" )
+ , ::rtl::OUString::createFromAscii( "com.sun.star.chart2.ColumnChartType" ) )
+
+ ( ::rtl::OUString::createFromAscii( "com.sun.star.chart.PieDiagram" )
+ , ::rtl::OUString::createFromAscii( "com.sun.star.chart2.PieChartType" ) )
+
+ ( ::rtl::OUString::createFromAscii( "com.sun.star.chart.DonutDiagram" )
+ , ::rtl::OUString::createFromAscii( "com.sun.star.chart2.DonutChartType" ) )
+
+ ( ::rtl::OUString::createFromAscii( "com.sun.star.chart.XYDiagram" )
+ , ::rtl::OUString::createFromAscii( "com.sun.star.chart2.ScatterChartType" ) )
+
+ ( ::rtl::OUString::createFromAscii( "com.sun.star.chart.NetDiagram" )
+ , ::rtl::OUString::createFromAscii( "com.sun.star.chart2.NetChartType" ) )
+
+ ( ::rtl::OUString::createFromAscii( "com.sun.star.chart.FilledNetDiagram" )
+ , ::rtl::OUString::createFromAscii( "com.sun.star.chart2.FilledNetChartType" ) )
+
+ ( ::rtl::OUString::createFromAscii( "com.sun.star.chart.StockDiagram" )
+ , ::rtl::OUString::createFromAscii( "com.sun.star.chart2.CandleStickChartType" ) )
+
+ ( ::rtl::OUString::createFromAscii( "com.sun.star.chart.BubbleDiagram" )
+ , ::rtl::OUString::createFromAscii( "com.sun.star.chart2.BubbleChartType" ) )
+
+ ;
+ return g_aChartTypeNameMap;
+}
+
+
+OUString GetNewChartTypeName( const OUString & rOldChartTypeName )
+{
+ OUString aNew(rOldChartTypeName);
+
+ const tMakeStringStringMap& rMap = lcl_getChartTypeNameMap();
+ tMakeStringStringMap::const_iterator aIt( rMap.find( rOldChartTypeName ));
+ if( aIt != rMap.end())
+ {
+ aNew = aIt->second;
+ }
+ return aNew;
+}
+
+OUString GetChartTypeByClassName(
+ const OUString & rClassName, bool bUseOldNames )
+{
+ OUStringBuffer aResultBuffer;
+ bool bInternalType = false;
+
+ if( bUseOldNames )
+ aResultBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart."));
+ else
+ aResultBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2."));
+
+ bInternalType = true;
+
+ if( IsXMLToken( rClassName, XML_LINE ))
+ aResultBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM("Line"));
+ else if( IsXMLToken( rClassName, XML_AREA ))
+ aResultBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM("Area"));
+ else if( IsXMLToken( rClassName, XML_BAR ))
+ {
+ if( bUseOldNames )
+ aResultBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM("Bar"));
+ else
+ {
+ aResultBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM("Column"));
+ // @todo: might be Bar
+ }
+ }
+ else if( IsXMLToken( rClassName, XML_CIRCLE ))
+ aResultBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM("Pie"));
+ else if( IsXMLToken( rClassName, XML_RING ))
+ aResultBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM("Donut"));
+ else if( IsXMLToken( rClassName, XML_SCATTER ))
+ {
+ if( bUseOldNames )
+ aResultBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM("XY"));
+ else
+ aResultBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM("Scatter"));
+ }
+
+ else if( IsXMLToken( rClassName, XML_BUBBLE ))
+ aResultBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM("Bubble"));
+ else if( IsXMLToken( rClassName, XML_RADAR ))
+ aResultBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM("Net"));
+ else if( IsXMLToken( rClassName, XML_FILLED_RADAR ))
+ aResultBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM("FilledNet"));
+ else if( IsXMLToken( rClassName, XML_STOCK ))
+ {
+ if( bUseOldNames )
+ aResultBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM("Stock"));
+ else
+ aResultBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM("CandleStick"));
+ }
+ else if( IsXMLToken( rClassName, XML_SURFACE ))
+ {
+ //@todo change this if a surface chart is available
+ if( bUseOldNames )
+ aResultBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM("Bar"));
+ else
+ aResultBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM("Column"));
+ }
+ else
+ bInternalType = false;
+
+ if( ! bInternalType )
+ return OUString();
+
+ if( bUseOldNames )
+ aResultBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM("Diagram"));
+ else
+ aResultBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM("ChartType"));
+
+ return aResultBuffer.makeStringAndClear();
+
+}
+
+XMLTokenEnum getTokenByChartType(
+ const OUString & rChartTypeService, bool bUseOldNames )
+{
+ XMLTokenEnum eResult = XML_TOKEN_INVALID;
+ OUString aPrefix, aPostfix;
+
+ if( bUseOldNames )
+ {
+ aPrefix = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart."));
+ aPostfix = OUString( RTL_CONSTASCII_USTRINGPARAM("Diagram"));
+ }
+ else
+ {
+ aPrefix = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart2."));
+ aPostfix = OUString( RTL_CONSTASCII_USTRINGPARAM("ChartType"));
+ }
+
+ if( rChartTypeService.match( aPrefix ))
+ {
+ sal_Int32 nSkip = aPrefix.getLength();
+ OSL_ASSERT( rChartTypeService.getLength() >= nSkip );
+ sal_Int32 nTypeLength = rChartTypeService.getLength() - nSkip - aPostfix.getLength();
+ // if postfix matches and leaves a non-empty type
+ if( nTypeLength > 0 && rChartTypeService.match( aPostfix, nSkip + nTypeLength ))
+ {
+ OUString aServiceName( rChartTypeService.copy( nSkip, nTypeLength ));
+
+ if( aServiceName.equalsAscii("Line"))
+ eResult = XML_LINE;
+ else if( aServiceName.equalsAscii("Area"))
+ eResult = XML_AREA;
+ else if( aServiceName.equalsAscii("Bar") ||
+ (!bUseOldNames && aServiceName.equalsAscii("Column")))
+ eResult = XML_BAR;
+ else if( aServiceName.equalsAscii("Pie"))
+ eResult = XML_CIRCLE;
+ else if( aServiceName.equalsAscii("Donut"))
+ eResult = XML_RING;
+ else if( (bUseOldNames && aServiceName.equalsAscii("XY")) ||
+ (!bUseOldNames && aServiceName.equalsAscii("Scatter")))
+ eResult = XML_SCATTER;
+ else if( aServiceName.equalsAscii("Bubble"))
+ eResult = XML_BUBBLE;
+ else if( aServiceName.equalsAscii("Net"))
+ eResult = XML_RADAR;
+ else if( aServiceName.equalsAscii("FilledNet"))
+ eResult = XML_FILLED_RADAR;
+ else if( (bUseOldNames && aServiceName.equalsAscii("Stock")) ||
+ (!bUseOldNames && aServiceName.equalsAscii("CandleStick")))
+ eResult = XML_STOCK;
+ }
+ }
+
+ if( eResult == XML_TOKEN_INVALID && rChartTypeService.getLength() > 0 )
+ eResult = XML_ADD_IN;
+
+ return eResult;
+}
+
+Reference< chart2::data::XLabeledDataSequence > GetNewLabeledDataSequence()
+{
+ Reference< chart2::data::XLabeledDataSequence > xResult;
+ Reference< uno::XComponentContext > xContext( lcl_getComponentContext());
+ if( xContext.is() )
+ xResult.set(
+ xContext->getServiceManager()->createInstanceWithContext(
+ OUString::createFromAscii("com.sun.star.chart2.data.LabeledDataSequence"),
+ xContext ), uno::UNO_QUERY_THROW );
+ return xResult;
+}
+
+Reference< chart2::data::XDataSequence > CreateDataSequence(
+ const OUString & rRange,
+ const Reference< chart2::XChartDocument >& xChartDoc )
+{
+ Reference< chart2::data::XDataSequence > xRet;
+
+ if( !xChartDoc.is() )
+ {
+ DBG_ERROR( "need a chart document" );
+ return xRet;
+ }
+
+ Reference< chart2::data::XDataProvider > xDataProvider( xChartDoc->getDataProvider() );
+ if( !xDataProvider.is() )
+ {
+ DBG_ERROR( "need a data provider" );
+ return xRet;
+ }
+
+ try
+ {
+ xRet.set( xDataProvider->createDataSequenceByRangeRepresentation( lcl_ConvertRange( rRange, xDataProvider )));
+ SchXMLTools::setXMLRangePropertyAtDataSequence( xRet, rRange );
+ }
+ catch( const lang::IllegalArgumentException & )
+ {
+ DBG_ERROR( "could not create data sequence" );
+ }
+
+ if( !xRet.is() && !xChartDoc->hasInternalDataProvider() )
+ {
+ //#i103911# switch to internal data in case the parent cannot provide the requested data
+ xChartDoc->createInternalDataProvider( sal_True /* bCloneExistingData */ );
+ xDataProvider = xChartDoc->getDataProvider();
+ try
+ {
+ xRet.set( xDataProvider->createDataSequenceByRangeRepresentation( lcl_ConvertRange( rRange, xDataProvider )));
+ SchXMLTools::setXMLRangePropertyAtDataSequence( xRet, rRange );
+ }
+ catch( const lang::IllegalArgumentException & )
+ {
+ DBG_ERROR( "could not create data sequence" );
+ }
+ }
+ return xRet;
+}
+
+void CreateCategories(
+ const uno::Reference< chart2::data::XDataProvider > & xDataProvider,
+ const uno::Reference< chart2::XChartDocument > & xNewDoc,
+ const OUString & rRangeAddress,
+ sal_Int32 nCooSysIndex,
+ sal_Int32 nDimensionIndex,
+ tSchXMLLSequencesPerIndex * pLSequencesPerIndex )
+{
+ try
+ {
+ if( xNewDoc.is() && rRangeAddress.getLength())
+ {
+ if( xDataProvider.is())
+ {
+ uno::Reference< chart2::XDiagram > xDia( xNewDoc->getFirstDiagram());
+ if( !xDia.is())
+ return;
+
+ uno::Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDia, uno::UNO_QUERY_THROW );
+ uno::Sequence< uno::Reference< chart2::XCoordinateSystem > >
+ aCooSysSeq( xCooSysCnt->getCoordinateSystems());
+ if( nCooSysIndex < aCooSysSeq.getLength())
+ {
+ uno::Reference< chart2::XCoordinateSystem > xCooSys( aCooSysSeq[nCooSysIndex] );
+ OSL_ASSERT( xCooSys.is());
+ if( nDimensionIndex < xCooSys->getDimension() )
+ {
+ const sal_Int32 nMaxAxisIndex = xCooSys->getMaximumAxisIndexByDimension(nDimensionIndex);
+ for(sal_Int32 nI=0; nI<=nMaxAxisIndex; ++nI)
+ {
+ uno::Reference< chart2::XAxis > xAxis( xCooSys->getAxisByDimension( nDimensionIndex, nI ));
+ if( xAxis.is() )
+ {
+ chart2::ScaleData aData( xAxis->getScaleData());
+ uno::Reference< chart2::data::XLabeledDataSequence > xLabeledSeq(
+ GetNewLabeledDataSequence());
+ try
+ {
+ OUString aConvertedRange( rRangeAddress );
+ bool bRangeConverted = false;
+ if( ! (xNewDoc->hasInternalDataProvider() &&
+ aConvertedRange.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("categories"))))
+ {
+ Reference< chart2::data::XRangeXMLConversion > xXMLConv( xDataProvider, uno::UNO_QUERY );
+ if( xXMLConv.is())
+ {
+ aConvertedRange = xXMLConv->convertRangeFromXML( rRangeAddress );
+ bRangeConverted = true;
+ }
+ }
+ Reference< chart2::data::XDataSequence > xSeq(
+ xDataProvider->createDataSequenceByRangeRepresentation( aConvertedRange ));
+ xLabeledSeq->setValues( xSeq );
+ if( bRangeConverted )
+ setXMLRangePropertyAtDataSequence( xSeq, rRangeAddress );
+ }
+ catch( const lang::IllegalArgumentException & ex )
+ {
+ (void)ex; // avoid warning for pro build
+ OSL_ENSURE( false, ::rtl::OUStringToOString(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IllegalArgumentException caught, Message: " )) +
+ ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
+ }
+ aData.Categories.set( xLabeledSeq );
+ if( pLSequencesPerIndex )
+ {
+ // register for setting local data if external data provider is not present
+ pLSequencesPerIndex->insert(
+ tSchXMLLSequencesPerIndex::value_type(
+ tSchXMLIndexWithPart( SCH_XML_CATEGORIES_INDEX, SCH_XML_PART_VALUES ), xLabeledSeq ));
+ }
+ xAxis->setScaleData( aData );
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ catch( uno::Exception & )
+ {
+ OSL_ENSURE( false, "Exception caught while creating Categories" );
+ }
+}
+
+
+uno::Any getPropertyFromContext( const rtl::OUString& rPropertyName, const XMLPropStyleContext* pPropStyleContext, const SvXMLStylesContext* pStylesCtxt )
+{
+ uno::Any aRet;
+ if( !pPropStyleContext || !pStylesCtxt )
+ return aRet;
+ const ::std::vector< XMLPropertyState >& rProperties = pPropStyleContext->GetProperties();
+ const UniReference< XMLPropertySetMapper >& rMapper = pStylesCtxt->GetImportPropertyMapper( pPropStyleContext->GetFamily()/*XML_STYLE_FAMILY_SCH_CHART_ID*/ )->getPropertySetMapper();
+ ::std::vector< XMLPropertyState >::const_iterator aEnd( rProperties.end() );
+ ::std::vector< XMLPropertyState >::const_iterator aPropIter( rProperties.begin() );
+ for( aPropIter = rProperties.begin(); aPropIter != aEnd; ++aPropIter )
+ {
+ sal_Int32 nIdx = aPropIter->mnIndex;
+ if( nIdx == -1 )
+ continue;
+ OUString aPropName = rMapper->GetEntryAPIName( nIdx );
+ if(rPropertyName.equals(aPropName))
+ return aPropIter->maValue;
+ }
+ return aRet;
+}
+
+void exportText( SvXMLExport& rExport, const OUString& rText, bool bConvertTabsLFs )
+{
+ SvXMLElementExport aPara( rExport, XML_NAMESPACE_TEXT,
+ ::xmloff::token::GetXMLToken( ::xmloff::token::XML_P ),
+ sal_True, sal_False );
+
+ if( bConvertTabsLFs )
+ {
+ sal_Int32 nStartPos = 0;
+ sal_Int32 nEndPos = rText.getLength();
+ sal_Unicode cChar;
+
+ for( sal_Int32 nPos = 0; nPos < nEndPos; nPos++ )
+ {
+ cChar = rText[ nPos ];
+ switch( cChar )
+ {
+ case 0x0009: // tabulator
+ {
+ if( nPos > nStartPos )
+ rExport.GetDocHandler()->characters( rText.copy( nStartPos, (nPos - nStartPos)) );
+ nStartPos = nPos + 1;
+
+ SvXMLElementExport aElem( rExport, XML_NAMESPACE_TEXT,
+ ::xmloff::token::GetXMLToken( ::xmloff::token::XML_TAB_STOP ),
+ sal_False, sal_False );
+ }
+ break;
+
+ case 0x000A: // linefeed
+ {
+ if( nPos > nStartPos )
+ rExport.GetDocHandler()->characters( rText.copy( nStartPos, (nPos - nStartPos)) );
+ nStartPos = nPos + 1;
+
+ SvXMLElementExport aElem( rExport, XML_NAMESPACE_TEXT,
+ ::xmloff::token::GetXMLToken( ::xmloff::token::XML_LINE_BREAK ),
+ sal_False, sal_False );
+ }
+ break;
+ }
+ }
+ if( nEndPos > nStartPos )
+ {
+ if( nStartPos == 0 )
+ rExport.GetDocHandler()->characters( rText );
+ else
+ rExport.GetDocHandler()->characters( rText.copy( nStartPos, (nEndPos - nStartPos)) );
+ }
+ }
+ else // do not convert tabs and linefeeds (eg for numbers coming from unit converter)
+ {
+ rExport.GetDocHandler()->characters( rText );
+ }
+}
+
+void exportRangeToSomewhere( SvXMLExport& rExport, const ::rtl::OUString& rValue )
+{
+ //with issue #i366# and CWS chart20 ranges for error bars were introduced
+ //to keep them during copy paste from calc to impress for example it
+ //was necessary to introduce a mapping between the used ranges within calc and the data written to the local table
+ //this is why we write this ranges here
+
+ //#i113950# first the range was exported to attribute text:id, but that attribute does not allow arbitrary strings anymore within ODF 1.2
+ //as an alternative the range info is now saved into the description at an empty group element (not very nice, but ODF conform)
+
+ const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion( SvtSaveOptions().GetODFDefaultVersion() );
+ if( nCurrentODFVersion == SvtSaveOptions::ODFVER_010 || nCurrentODFVersion == SvtSaveOptions::ODFVER_011 )
+ return;//svg:desc is not allowed at draw:g in ODF1.0; but as the ranges for error bars are anyhow not allowed within ODF1.0 nor ODF1.1 we do not need the information
+
+ SvXMLElementExport aEmptyShapeGroup( rExport, XML_NAMESPACE_DRAW,
+ ::xmloff::token::GetXMLToken( ::xmloff::token::XML_G ),
+ sal_True, sal_False );
+ SvXMLElementExport aDescription( rExport, XML_NAMESPACE_SVG,
+ ::xmloff::token::GetXMLToken( ::xmloff::token::XML_DESC ),
+ sal_True, sal_False );
+ rExport.GetDocHandler()->characters( rValue );
+}
+
+Reference< chart2::XRegressionCurve > getRegressionCurve(
+ const Reference< chart2::XDataSeries > & xDataSeries )
+{
+ Reference< chart2::XRegressionCurve > xResult;
+
+ Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( xDataSeries, uno::UNO_QUERY );
+ if( xRegCurveCnt.is())
+ {
+ // find equation properties of first regression curve
+ Sequence< Reference< chart2::XRegressionCurve > > aCurveSeq(
+ xRegCurveCnt->getRegressionCurves() );
+ for( sal_Int32 nI=0; nI<aCurveSeq.getLength(); ++nI )
+ {
+ // skip mean-value line
+ Reference< lang::XServiceName > xServiceName( aCurveSeq[nI], uno::UNO_QUERY );
+ if( xServiceName.is())
+ {
+ OUString aServiceName( xServiceName->getServiceName());
+ if( aServiceName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart2.MeanValueRegressionCurve" )))
+ continue;
+ }
+ // take first non-empty curve
+ if( aCurveSeq[nI].is())
+ {
+ xResult.set( aCurveSeq[nI] );
+ break;
+ }
+ }
+ }
+ return xResult;
+}
+
+void setXMLRangePropertyAtDataSequence(
+ const Reference< chart2::data::XDataSequence > & xDataSequence,
+ const OUString & rXMLRange )
+{
+ if( !xDataSequence.is())
+ return;
+ try
+ {
+ const OUString aXMLRangePropName( RTL_CONSTASCII_USTRINGPARAM( "CachedXMLRange" ));
+ Reference< beans::XPropertySet > xProp( xDataSequence, uno::UNO_QUERY_THROW );
+ Reference< beans::XPropertySetInfo > xInfo( xProp->getPropertySetInfo());
+ if( xInfo.is() && xInfo->hasPropertyByName( aXMLRangePropName ))
+ xProp->setPropertyValue( aXMLRangePropName, uno::makeAny( rXMLRange ));
+ }
+ catch( const uno::Exception & ex )
+ {
+ (void)ex; // avoid warning for pro build
+ OSL_ENSURE( false, ::rtl::OUStringToOString(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Exception caught, Message: " )) +
+ ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
+ }
+}
+
+bool getXMLRangePropertyFromDataSequence(
+ const Reference< chart2::data::XDataSequence > & xDataSequence,
+ OUString & rOutXMLRange,
+ bool bClearProp /* = false */)
+{
+ bool bResult = false;
+ if( xDataSequence.is())
+ {
+ try
+ {
+ const OUString aXMLRangePropName( RTL_CONSTASCII_USTRINGPARAM( "CachedXMLRange" ));
+ Reference< beans::XPropertySet > xProp( xDataSequence, uno::UNO_QUERY_THROW );
+ Reference< beans::XPropertySetInfo > xInfo( xProp->getPropertySetInfo());
+ bResult =
+ ( xInfo.is() && xInfo->hasPropertyByName( aXMLRangePropName ) &&
+ ( xProp->getPropertyValue( aXMLRangePropName ) >>= rOutXMLRange ) &&
+ rOutXMLRange.getLength());
+ // clear the property after usage
+ if( bClearProp && bResult )
+ xProp->setPropertyValue( aXMLRangePropName, uno::Any( OUString()));
+ }
+ catch( const uno::Exception & ex )
+ {
+ (void)ex; // avoid warning for pro build
+ OSL_ENSURE( false, ::rtl::OUStringToOString(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Exception caught, Message: " )) +
+ ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
+ }
+ }
+ return bResult;
+}
+
+void copyProperties(
+ const Reference< beans::XPropertySet > & xSource,
+ const Reference< beans::XPropertySet > & xDestination )
+{
+ if( ! (xSource.is() && xDestination.is()) )
+ return;
+
+ try
+ {
+ Reference< beans::XPropertySetInfo > xSrcInfo( xSource->getPropertySetInfo(), uno::UNO_QUERY_THROW );
+ Reference< beans::XPropertySetInfo > xDestInfo( xDestination->getPropertySetInfo(), uno::UNO_QUERY_THROW );
+ Sequence< beans::Property > aProperties( xSrcInfo->getProperties());
+ const sal_Int32 nLength = aProperties.getLength();
+ for( sal_Int32 i = 0; i < nLength; ++i )
+ {
+ OUString aName( aProperties[i].Name);
+ if( xDestInfo->hasPropertyByName( aName ))
+ {
+ beans::Property aProp( xDestInfo->getPropertyByName( aName ));
+ if( (aProp.Attributes & beans::PropertyAttribute::READONLY) == 0 )
+ xDestination->setPropertyValue(
+ aName, xSource->getPropertyValue( aName ));
+ }
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ OSL_ENSURE( false, "Copying property sets failed!" );
+ }
+}
+
+bool switchBackToDataProviderFromParent( const Reference< chart2::XChartDocument >& xChartDoc, const tSchXMLLSequencesPerIndex & rLSequencesPerIndex )
+{
+ //return whether the switch is successful
+ if( !xChartDoc.is() || !xChartDoc->hasInternalDataProvider() )
+ return false;
+ Reference< chart2::data::XDataProvider > xDataProviderFromParent( SchXMLTools::getDataProviderFromParent( xChartDoc ) );
+ if( !xDataProviderFromParent.is() )
+ return false;
+ uno::Reference< chart2::data::XDataReceiver > xDataReceiver( xChartDoc, uno::UNO_QUERY );
+ if( !xDataReceiver.is() )
+ return false;
+
+ xDataReceiver->attachDataProvider( xDataProviderFromParent );
+
+ for( tSchXMLLSequencesPerIndex::const_iterator aLSeqIt( rLSequencesPerIndex.begin() );
+ aLSeqIt != rLSequencesPerIndex.end(); ++aLSeqIt )
+ {
+ Reference< chart2::data::XLabeledDataSequence > xLabeledSeq( aLSeqIt->second );
+ if( !xLabeledSeq.is() )
+ continue;
+ Reference< chart2::data::XDataSequence > xNewSeq;
+ xNewSeq = lcl_createNewSequenceFromCachedXMLRange( xLabeledSeq->getValues(), xDataProviderFromParent );
+ if( xNewSeq.is() )
+ xLabeledSeq->setValues( xNewSeq );
+ xNewSeq = lcl_createNewSequenceFromCachedXMLRange( xLabeledSeq->getLabel(), xDataProviderFromParent );
+ if( xNewSeq.is() )
+ xLabeledSeq->setLabel( xNewSeq );
+ }
+ return true;
+}
+
+void setBuildIDAtImportInfo( uno::Reference< frame::XModel > xModel, Reference< beans::XPropertySet > xImportInfo )
+{
+ ::rtl::OUString aGenerator( lcl_getGeneratorFromModelOrItsParent(xModel) );
+ if( aGenerator.getLength() )
+ SvXMLMetaDocumentContext::setBuildId( aGenerator, xImportInfo );
+}
+
+bool isDocumentGeneratedWithOpenOfficeOlderThan3_3( const uno::Reference< frame::XModel >& xChartModel )
+{
+ bool bResult = isDocumentGeneratedWithOpenOfficeOlderThan3_0( xChartModel );
+ if( !bResult )
+ {
+ ::rtl::OUString aGenerator( lcl_getGeneratorFromModel(xChartModel) );
+ if( aGenerator.indexOf( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("OpenOffice.org_project/3") ) ) != -1 )
+ {
+ if( aGenerator.indexOf( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("OpenOffice.org_project/300m") ) ) != -1 )
+ {
+ sal_Int32 nBuilId = lcl_getBuildIDFromGenerator( lcl_getGeneratorFromModel(xChartModel) );
+ if( nBuilId>0 && nBuilId<9491 ) //9491 is build id of dev300m76
+ bResult= true;
+ }
+ else if( aGenerator.indexOf( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("OpenOffice.org_project/310m") ) ) != -1 )
+ bResult= true;
+ else if( aGenerator.indexOf( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("OpenOffice.org_project/320m") ) ) != -1 )
+ bResult= true;
+ }
+ }
+ return bResult;
+}
+
+bool isDocumentGeneratedWithOpenOfficeOlderThan3_0( const uno::Reference< frame::XModel >& xChartModel )
+{
+ bool bResult = isDocumentGeneratedWithOpenOfficeOlderThan2_3( xChartModel );
+ if( !bResult )
+ {
+ ::rtl::OUString aGenerator( lcl_getGeneratorFromModel(xChartModel) );
+ if( aGenerator.indexOf( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("OpenOffice.org_project/680m") ) ) != -1 )
+ bResult= true;
+ }
+ return bResult;
+}
+
+bool isDocumentGeneratedWithOpenOfficeOlderThan2_4( const uno::Reference< frame::XModel >& xChartModel )
+{
+ if( isDocumentGeneratedWithOpenOfficeOlderThan2_3( xChartModel ) )
+ return true;
+
+ if( isDocumentGeneratedWithOpenOfficeOlderThan3_0( xChartModel ) )
+ {
+ sal_Int32 nBuilId = lcl_getBuildIDFromGenerator( lcl_getGeneratorFromModel(xChartModel) );
+ if( nBuilId>0 && nBuilId<=9238 ) //9238 is build id of OpenOffice.org 2.3.1
+ return true;
+ }
+ return false;
+}
+
+bool isDocumentGeneratedWithOpenOfficeOlderThan2_3( const uno::Reference< frame::XModel >& xChartModel )
+{
+ bool bResult = false;
+ ::rtl::OUString aGenerator( lcl_getGeneratorFromModel(xChartModel) );
+ //if there is a meta stream at the chart object it was not written with an older OpenOffice version < 2.3
+ if( !aGenerator.getLength() )
+ {
+ //if there is no meta stream at the chart object we need to check whether the parent document is OpenOffice at all
+ uno::Reference< container::XChild > xChild( xChartModel, uno::UNO_QUERY );
+ if( xChild.is() )
+ {
+ aGenerator = lcl_getGeneratorFromModel( uno::Reference< frame::XModel >( xChild->getParent(), uno::UNO_QUERY) );
+ if( aGenerator.indexOf( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("OpenOffice.org_project") ) ) != -1 )
+ {
+ //the chart application has not created files without a meta stream since OOo 2.3 (OOo 2.3 has written a metastream already)
+ //only the report builder extension has created some files with OOo 3.1 that do not have a meta stream
+ if( aGenerator.indexOf( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("OpenOffice.org_project/31") ) ) != -1 )
+ bResult = false;//#i100102# probably generated with OOo 3.1 by the report designer
+ else
+ bResult= true; //in this case the OLE chart was created by an older version, as OLE objects are sometimes stream copied the version can differ from the parents version, so the parents version is not a reliable indicator
+ }
+ else if( isDocumentGeneratedWithOpenOfficeOlderThan2_0(xChartModel) )
+ bResult= true;
+ }
+ }
+ return bResult;
+}
+
+bool isDocumentGeneratedWithOpenOfficeOlderThan2_0( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel)
+{
+ bool bResult = false;
+ ::rtl::OUString aGenerator( lcl_getGeneratorFromModelOrItsParent(xChartModel) );
+ if( ( aGenerator.indexOf( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("OpenOffice.org 1") ) ) == 0 )
+ || ( aGenerator.indexOf( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("StarOffice 6") ) ) == 0 )
+ || ( aGenerator.indexOf( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("StarOffice 7") ) ) == 0 )
+ || ( aGenerator.indexOf( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("StarSuite 6") ) ) == 0 )
+ || ( aGenerator.indexOf( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("StarSuite 7") ) ) == 0 )
+ )
+ bResult= true;
+ return bResult;
+}
+
+Reference< chart2::data::XDataProvider > getDataProviderFromParent( const Reference< chart2::XChartDocument >& xChartDoc )
+{
+ Reference< chart2::data::XDataProvider > xRet;
+ uno::Reference< container::XChild > xChild( xChartDoc, uno::UNO_QUERY );
+ if( xChild.is() )
+ {
+ Reference< lang::XMultiServiceFactory > xFact( xChild->getParent(), uno::UNO_QUERY );
+ if( xFact.is() )
+ {
+ const OUString aDataProviderServiceName( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart2.data.DataProvider"));
+ const uno::Sequence< OUString > aServiceNames( xFact->getAvailableServiceNames());
+ const OUString * pBegin = aServiceNames.getConstArray();
+ const OUString * pEnd = pBegin + aServiceNames.getLength();
+ if( ::std::find( pBegin, pEnd, aDataProviderServiceName ) != pEnd )
+ {
+ xRet = Reference< chart2::data::XDataProvider >(
+ xFact->createInstance( aDataProviderServiceName ), uno::UNO_QUERY );
+ }
+ }
+ }
+ return xRet;
+}
+
+} // namespace SchXMLTools
diff --git a/xmloff/source/chart/SchXMLTools.hxx b/xmloff/source/chart/SchXMLTools.hxx
new file mode 100644
index 000000000000..d8841bf3861b
--- /dev/null
+++ b/xmloff/source/chart/SchXMLTools.hxx
@@ -0,0 +1,152 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SCH_XML_TOOLS_HXX_
+#define SCH_XML_TOOLS_HXX_
+
+#include <rtl/ustring.hxx>
+#include <xmloff/xmltoken.hxx>
+#include "transporttypes.hxx"
+
+#include <com/sun/star/frame/XModel.hpp>
+
+namespace com { namespace sun { namespace star {
+ namespace chart2 {
+ class XChartDocument;
+ class XRegressionCurve;
+ namespace data {
+ class XDataProvider;
+ class XLabeledDataSequence;
+ }
+ }
+}}}
+
+class XMLPropStyleContext;
+class SvXMLStylesContext;
+class SvXMLExport;
+
+namespace SchXMLTools
+{
+ bool isDocumentGeneratedWithOpenOfficeOlderThan2_0( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel);
+ bool isDocumentGeneratedWithOpenOfficeOlderThan2_3( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel);
+ bool isDocumentGeneratedWithOpenOfficeOlderThan2_4( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel);
+ bool isDocumentGeneratedWithOpenOfficeOlderThan3_0( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel);
+ bool isDocumentGeneratedWithOpenOfficeOlderThan3_3( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel);
+
+ void setBuildIDAtImportInfo( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > xModel
+ , ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xImportInfo );
+
+ enum SchXMLChartTypeEnum
+ {
+ XML_CHART_CLASS_LINE,
+ XML_CHART_CLASS_AREA,
+ XML_CHART_CLASS_CIRCLE,
+ XML_CHART_CLASS_RING,
+ XML_CHART_CLASS_SCATTER,
+ XML_CHART_CLASS_RADAR,
+ XML_CHART_CLASS_FILLED_RADAR,
+ XML_CHART_CLASS_BAR,
+ XML_CHART_CLASS_STOCK,
+ XML_CHART_CLASS_BUBBLE,
+ XML_CHART_CLASS_ADDIN,
+ XML_CHART_CLASS_UNKNOWN
+ };
+
+ SchXMLChartTypeEnum GetChartTypeEnum( const ::rtl::OUString& rClassName );
+
+ ::rtl::OUString GetChartTypeByClassName(
+ const ::rtl::OUString & rClassName, bool bUseOldNames );
+
+ ::xmloff::token::XMLTokenEnum getTokenByChartType(
+ const ::rtl::OUString & rChartTypeService, bool bUseOldNames );
+
+ ::rtl::OUString GetNewChartTypeName( const ::rtl::OUString & rOldChartTypeName );
+
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::data::XLabeledDataSequence > GetNewLabeledDataSequence();
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence > CreateDataSequence(
+ const ::rtl::OUString& rRange,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XChartDocument >& xChartDoc );
+
+ void CreateCategories(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider > & xDataProvider,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > & xNewDoc,
+ const ::rtl::OUString & rRangeAddress,
+ sal_Int32 nCooSysIndex,
+ sal_Int32 nDimensionIndex,
+ tSchXMLLSequencesPerIndex * pLSequencesPerIndex = 0 );
+
+ ::com::sun::star::uno::Any getPropertyFromContext( const ::rtl::OUString& rPropertyName, const XMLPropStyleContext * pPropStyleContext, const SvXMLStylesContext* pStylesCtxt );
+
+ void exportText( SvXMLExport& rExport, const ::rtl::OUString& rText, bool bConvertTabsLFs );
+
+ void exportRangeToSomewhere( SvXMLExport& rExport, const ::rtl::OUString& rValue );
+
+ /** returns the properties of the equation of the first regression curve
+ that is no mean-value line
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XRegressionCurve > getRegressionCurve(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XDataSeries > & xDataSeries );
+
+ /** checks if the data sequence has the property "CachedXMLRange" (true for
+ internal data sequences), and if so sets this property to the range
+ given in rXMLRange
+ */
+ void setXMLRangePropertyAtDataSequence(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::data::XDataSequence > & xDataSequence,
+ const ::rtl::OUString & rXMLRange );
+
+ /** checks if the data sequence has the property "CachedXMLRange" (true for
+ internal data sequences), and if so retrieves this property and applies
+ it to the range given in rOutXMLRange.
+
+ @param bClearProp If true, the property is reset to its default after it
+ was assigned to rOutXMLRange
+
+ @return true, if the property was found, assigned and is non-empty
+ */
+ bool getXMLRangePropertyFromDataSequence(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::data::XDataSequence > & xDataSequence,
+ ::rtl::OUString & rOutXMLRange,
+ bool bClearProp = false );
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider > getDataProviderFromParent( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >& xChartDoc );
+
+ bool switchBackToDataProviderFromParent( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XChartDocument >& xChartDoc
+ , const tSchXMLLSequencesPerIndex & rLSequencesPerIndex );
+
+ void copyProperties(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & xSource,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & xDestination );
+}
+
+#endif // SCH_XML_TOOLS_HXX_
diff --git a/xmloff/source/chart/XMLAxisPositionPropertyHdl.cxx b/xmloff/source/chart/XMLAxisPositionPropertyHdl.cxx
new file mode 100644
index 000000000000..3b16ca293901
--- /dev/null
+++ b/xmloff/source/chart/XMLAxisPositionPropertyHdl.cxx
@@ -0,0 +1,128 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmloff.hxx"
+#include "XMLAxisPositionPropertyHdl.hxx"
+#include <xmloff/xmluconv.hxx>
+#include <com/sun/star/chart/ChartAxisPosition.hpp>
+#include <rtl/ustrbuf.hxx>
+
+using namespace ::xmloff::token;
+using ::rtl::OUString;
+using ::rtl::OUStringBuffer;
+
+using namespace com::sun::star;
+
+XMLAxisPositionPropertyHdl::XMLAxisPositionPropertyHdl( bool bCrossingValue )
+ : m_bCrossingValue( bCrossingValue )
+{}
+
+XMLAxisPositionPropertyHdl::~XMLAxisPositionPropertyHdl()
+{}
+
+sal_Bool XMLAxisPositionPropertyHdl::importXML( const OUString& rStrImpValue,
+ uno::Any& rValue, const SvXMLUnitConverter& /*rUnitConverter*/ ) const
+{
+ sal_Bool bResult = false;
+
+ if( rStrImpValue.equals( GetXMLToken(XML_START) ) )
+ {
+ if( !m_bCrossingValue )
+ {
+ rValue <<= ::com::sun::star::chart::ChartAxisPosition_START;
+ bResult = true;
+ }
+ }
+ else if( rStrImpValue.equals( GetXMLToken(XML_END) ) )
+ {
+ if( !m_bCrossingValue )
+ {
+ rValue <<= ::com::sun::star::chart::ChartAxisPosition_END;
+ bResult = true;
+ }
+ }
+ else
+ {
+ if( !m_bCrossingValue )
+ {
+ rValue <<= ::com::sun::star::chart::ChartAxisPosition_VALUE;
+ bResult = true;
+ }
+ else
+ {
+ double fDblValue=0.0;
+ bResult = SvXMLUnitConverter::convertDouble( fDblValue, rStrImpValue );
+ rValue <<= fDblValue;
+ }
+ }
+
+ return bResult;
+}
+
+sal_Bool XMLAxisPositionPropertyHdl::exportXML( OUString& rStrExpValue,
+ const uno::Any& rValue, const SvXMLUnitConverter& /*rUnitConverter*/ ) const
+{
+ sal_Bool bResult = sal_False;
+
+ rtl::OUStringBuffer sValueBuffer;
+ if( m_bCrossingValue )
+ {
+ if(rStrExpValue.getLength() == 0)
+ {
+ double fValue = 0.0;
+ rValue >>= fValue;
+ SvXMLUnitConverter::convertDouble( sValueBuffer, fValue );
+ rStrExpValue = sValueBuffer.makeStringAndClear();
+ bResult = true;
+ }
+ }
+ else
+ {
+ ::com::sun::star::chart::ChartAxisPosition ePosition( ::com::sun::star::chart::ChartAxisPosition_ZERO );
+ rValue >>= ePosition;
+ switch(ePosition)
+ {
+ case ::com::sun::star::chart::ChartAxisPosition_START:
+ rStrExpValue = GetXMLToken( XML_START );
+ bResult = true;
+ break;
+ case ::com::sun::star::chart::ChartAxisPosition_END:
+ rStrExpValue = GetXMLToken( XML_END );
+ bResult = true;
+ break;
+ case ::com::sun::star::chart::ChartAxisPosition_ZERO:
+ SvXMLUnitConverter::convertDouble( sValueBuffer, 0.0 );
+ rStrExpValue = sValueBuffer.makeStringAndClear();
+ bResult = true;
+ break;
+ default:
+ break;
+ }
+ }
+ return bResult;
+}
diff --git a/xmloff/source/chart/XMLAxisPositionPropertyHdl.hxx b/xmloff/source/chart/XMLAxisPositionPropertyHdl.hxx
new file mode 100644
index 000000000000..0f7438698816
--- /dev/null
+++ b/xmloff/source/chart/XMLAxisPositionPropertyHdl.hxx
@@ -0,0 +1,45 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _XMLAXISPOSITIONPROPERTYHDL_HXX_
+#define _XMLAXISPOSITIONPROPERTYHDL_HXX_
+
+#include <xmloff/xmlprhdl.hxx>
+
+class XMLAxisPositionPropertyHdl : public XMLPropertyHandler
+{
+public:
+ XMLAxisPositionPropertyHdl( bool bCrossingValue );
+ virtual ~XMLAxisPositionPropertyHdl();
+
+ virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
+ virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
+
+private:
+ bool m_bCrossingValue;
+};
+
+#endif // _XMLAXISPOSITIONPROPERTYHDL_HXX_
diff --git a/xmloff/source/chart/XMLChartPropertyContext.cxx b/xmloff/source/chart/XMLChartPropertyContext.cxx
new file mode 100644
index 000000000000..c61fd2c610ea
--- /dev/null
+++ b/xmloff/source/chart/XMLChartPropertyContext.cxx
@@ -0,0 +1,82 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmloff.hxx"
+#include "XMLChartPropertyContext.hxx"
+#include "PropertyMap.hxx"
+
+#include "XMLSymbolImageContext.hxx"
+#include "XMLLabelSeparatorContext.hxx"
+
+TYPEINIT1( XMLChartPropertyContext, SvXMLImportContext );
+
+using namespace ::com::sun::star;
+
+XMLChartPropertyContext::XMLChartPropertyContext(
+ SvXMLImport& rImport,
+ sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName,
+ const uno::Reference< xml::sax::XAttributeList > & xAttrList,
+ sal_uInt32 nFamily,
+ ::std::vector< XMLPropertyState >& rProps,
+ const UniReference< SvXMLImportPropertyMapper >& rMapper ) :
+ SvXMLPropertySetContext( rImport, nPrfx, rLName, xAttrList, nFamily, rProps, rMapper )
+{
+}
+
+XMLChartPropertyContext::~XMLChartPropertyContext()
+{}
+
+SvXMLImportContext* XMLChartPropertyContext::CreateChildContext(
+ sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const uno::Reference< xml::sax::XAttributeList > & xAttrList,
+ ::std::vector< XMLPropertyState > &rProperties,
+ const XMLPropertyState& rProp )
+{
+ SvXMLImportContext *pContext = 0;
+
+ switch( mxMapper->getPropertySetMapper()->GetEntryContextId( rProp.mnIndex ) )
+ {
+ case XML_SCH_CONTEXT_SPECIAL_SYMBOL_IMAGE:
+ pContext = new XMLSymbolImageContext( GetImport(), nPrefix, rLocalName, rProp, rProperties );
+ break;
+ case XML_SCH_CONTEXT_SPECIAL_LABEL_SEPARATOR:
+ pContext = new XMLLabelSeparatorContext( GetImport(), nPrefix, rLocalName, rProp, rProperties );
+ break;
+ }
+
+ // default / no context yet: create child context by base class
+ if( !pContext )
+ {
+ pContext = SvXMLPropertySetContext::CreateChildContext(
+ nPrefix, rLocalName, xAttrList, rProperties, rProp );
+ }
+
+ return pContext;
+}
diff --git a/xmloff/source/chart/XMLChartPropertyContext.hxx b/xmloff/source/chart/XMLChartPropertyContext.hxx
new file mode 100644
index 000000000000..c6f629d29fc6
--- /dev/null
+++ b/xmloff/source/chart/XMLChartPropertyContext.hxx
@@ -0,0 +1,58 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _XMLOFF_CHARTPROPERTYCONTEXT_HXX_
+#define _XMLOFF_CHARTPROPERTYCONTEXT_HXX_
+
+#include <xmloff/xmlprcon.hxx>
+
+class XMLChartPropertyContext : public SvXMLPropertySetContext
+{
+public:
+ TYPEINFO();
+
+ XMLChartPropertyContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
+ sal_uInt32 nFamily,
+ ::std::vector< XMLPropertyState >& rProps,
+ const UniReference< SvXMLImportPropertyMapper >& rMapper );
+ virtual ~XMLChartPropertyContext();
+
+ using SvXMLPropertySetContext::CreateChildContext;
+ virtual SvXMLImportContext* CreateChildContext(
+ sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
+ ::std::vector< XMLPropertyState > &rProperties,
+ const XMLPropertyState& rProp );
+
+private:
+};
+
+#endif // _XMLOFF_CHARTPROPERTYCONTEXT_HXX_
diff --git a/xmloff/source/chart/XMLChartStyleContext.cxx b/xmloff/source/chart/XMLChartStyleContext.cxx
new file mode 100644
index 000000000000..87adea123ab4
--- /dev/null
+++ b/xmloff/source/chart/XMLChartStyleContext.cxx
@@ -0,0 +1,161 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmloff.hxx"
+#include "XMLChartStyleContext.hxx"
+#include <xmloff/xmltoken.hxx>
+#include "xmlnmspe.hxx"
+#include <xmloff/xmlnumfi.hxx>
+#include <xmloff/families.hxx>
+
+#include "XMLChartPropertyContext.hxx"
+
+using namespace com::sun::star;
+using ::xmloff::token::IsXMLToken;
+using ::xmloff::token::XML_DATA_STYLE_NAME;
+using ::xmloff::token::XML_PERCENTAGE_DATA_STYLE_NAME;
+using ::xmloff::token::XML_TEXT_PROPERTIES;
+using ::xmloff::token::XML_PARAGRAPH_PROPERTIES;
+using ::xmloff::token::XML_GRAPHIC_PROPERTIES;
+using ::xmloff::token::XML_CHART_PROPERTIES;
+
+
+TYPEINIT1( XMLChartStyleContext, XMLPropStyleContext );
+
+// protected
+
+void XMLChartStyleContext::SetAttribute(
+ sal_uInt16 nPrefixKey,
+ const ::rtl::OUString& rLocalName,
+ const ::rtl::OUString& rValue )
+{
+ if( IsXMLToken( rLocalName, XML_DATA_STYLE_NAME ) )
+ {
+ msDataStyleName =rValue;
+ }
+ else if( IsXMLToken( rLocalName, XML_PERCENTAGE_DATA_STYLE_NAME ) )
+ {
+ msPercentageDataStyleName =rValue;
+ }
+ else
+ {
+ XMLShapeStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
+ }
+}
+
+//public
+
+// CTOR
+XMLChartStyleContext::XMLChartStyleContext(
+ SvXMLImport& rImport, sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName,
+ const uno::Reference< xml::sax::XAttributeList > & xAttrList,
+ SvXMLStylesContext& rStyles, sal_uInt16 nFamily ) :
+
+ XMLShapeStyleContext( rImport, nPrfx, rLName, xAttrList, rStyles, nFamily ),
+ mrStyles( rStyles )
+{}
+
+// DTOR
+XMLChartStyleContext::~XMLChartStyleContext()
+{}
+
+namespace
+{
+
+ void lcl_NumberFormatStyleToProperty( const ::rtl::OUString& rStyleName, const ::rtl::OUString& rPropertyName,
+ const SvXMLStylesContext& rStylesContext,
+ const uno::Reference< beans::XPropertySet >& rPropSet )
+{
+ if( rStyleName.getLength())
+ {
+ SvXMLNumFormatContext* pStyle = (SvXMLNumFormatContext *)rStylesContext.FindStyleChildContext(
+ XML_STYLE_FAMILY_DATA_STYLE, rStyleName, sal_True );
+ if( pStyle )
+ {
+ uno::Any aNumberFormat;
+ sal_Int32 nNumberFormat = pStyle->GetKey();
+ aNumberFormat <<= nNumberFormat;
+ rPropSet->setPropertyValue( rPropertyName, aNumberFormat );
+ }
+ }
+}
+
+}// anonymous namespace
+
+void XMLChartStyleContext::FillPropertySet(
+ const uno::Reference< beans::XPropertySet > & rPropSet )
+{
+ try
+ {
+ XMLShapeStyleContext::FillPropertySet( rPropSet );
+ }
+ catch( beans::UnknownPropertyException& )
+ {
+ DBG_ASSERT( false, "unknown property exception -> shape style not completly imported for chart style" );
+ }
+
+ lcl_NumberFormatStyleToProperty( msDataStyleName, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NumberFormat" )), mrStyles, rPropSet );
+ lcl_NumberFormatStyleToProperty( msPercentageDataStyleName, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PercentageNumberFormat" )), mrStyles, rPropSet );
+}
+
+SvXMLImportContext *XMLChartStyleContext::CreateChildContext(
+ sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const uno::Reference< xml::sax::XAttributeList > & xAttrList )
+{
+ SvXMLImportContext* pContext = NULL;
+
+ if( XML_NAMESPACE_STYLE == nPrefix )
+ {
+ sal_uInt32 nFamily = 0;
+ if( IsXMLToken( rLocalName, XML_TEXT_PROPERTIES ) )
+ nFamily = XML_TYPE_PROP_TEXT;
+ else if( IsXMLToken( rLocalName, XML_PARAGRAPH_PROPERTIES ) )
+ nFamily = XML_TYPE_PROP_PARAGRAPH;
+ else if( IsXMLToken( rLocalName, XML_GRAPHIC_PROPERTIES ) )
+ nFamily = XML_TYPE_PROP_GRAPHIC;
+ else if( IsXMLToken( rLocalName, XML_CHART_PROPERTIES ) )
+ nFamily = XML_TYPE_PROP_CHART;
+ if( nFamily )
+ {
+ UniReference < SvXMLImportPropertyMapper > xImpPrMap =
+ GetStyles()->GetImportPropertyMapper( GetFamily() );
+ if( xImpPrMap.is() )
+ pContext = new XMLChartPropertyContext(
+ GetImport(), nPrefix, rLocalName, xAttrList, nFamily,
+ GetProperties(), xImpPrMap );
+ }
+ }
+
+ if( !pContext )
+ pContext = XMLShapeStyleContext::CreateChildContext( nPrefix, rLocalName,
+ xAttrList );
+
+ return pContext;
+}
diff --git a/xmloff/source/chart/XMLErrorBarStylePropertyHdl.cxx b/xmloff/source/chart/XMLErrorBarStylePropertyHdl.cxx
new file mode 100644
index 000000000000..2520454f1176
--- /dev/null
+++ b/xmloff/source/chart/XMLErrorBarStylePropertyHdl.cxx
@@ -0,0 +1,68 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmloff.hxx"
+#include "XMLErrorBarStylePropertyHdl.hxx"
+#include <unotools/saveopt.hxx>
+
+#include <com/sun/star/chart/ErrorBarStyle.hpp>
+#include <com/sun/star/uno/Any.hxx>
+
+using ::rtl::OUString;
+using namespace com::sun::star;
+
+XMLErrorBarStylePropertyHdl::XMLErrorBarStylePropertyHdl( const SvXMLEnumMapEntry* pEnumMap, const ::com::sun::star::uno::Type & rType )
+ : XMLEnumPropertyHdl( pEnumMap, rType )
+{
+}
+
+XMLErrorBarStylePropertyHdl::~XMLErrorBarStylePropertyHdl()
+{
+}
+
+sal_Bool XMLErrorBarStylePropertyHdl::exportXML( OUString& rStrExpValue,
+ const uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const
+{
+ uno::Any aValue(rValue);
+ const SvtSaveOptions::ODFDefaultVersion nCurrentVersion( SvtSaveOptions().GetODFDefaultVersion() );
+ if( nCurrentVersion < SvtSaveOptions::ODFVER_012 )
+ {
+ sal_Int32 nValue = 0;
+ if(rValue >>= nValue )
+ {
+ if( nValue == ::com::sun::star::chart::ErrorBarStyle::STANDARD_ERROR
+ || nValue == ::com::sun::star::chart::ErrorBarStyle::FROM_DATA )
+ {
+ nValue = ::com::sun::star::chart::ErrorBarStyle::NONE;
+ aValue = uno::makeAny(nValue);
+ }
+ }
+ }
+
+ return XMLEnumPropertyHdl::exportXML( rStrExpValue, aValue, rUnitConverter );
+}
diff --git a/xmloff/source/chart/XMLErrorBarStylePropertyHdl.hxx b/xmloff/source/chart/XMLErrorBarStylePropertyHdl.hxx
new file mode 100644
index 000000000000..af9b34b3bff7
--- /dev/null
+++ b/xmloff/source/chart/XMLErrorBarStylePropertyHdl.hxx
@@ -0,0 +1,41 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _XMLERRORBARSTYLEPROPERTYHDL_HXX_
+#define _XMLERRORBARSTYLEPROPERTYHDL_HXX_
+
+#include <xmloff/EnumPropertyHdl.hxx>
+
+class XMLErrorBarStylePropertyHdl : public XMLEnumPropertyHdl
+{
+public:
+ XMLErrorBarStylePropertyHdl( const SvXMLEnumMapEntry* pEnumMap, const ::com::sun::star::uno::Type & rType );
+ virtual ~XMLErrorBarStylePropertyHdl();
+
+ virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
+};
+
+#endif // _XMLERRORBARSTYLEPROPERTYHDL_HXX_
diff --git a/xmloff/source/chart/XMLErrorIndicatorPropertyHdl.cxx b/xmloff/source/chart/XMLErrorIndicatorPropertyHdl.cxx
new file mode 100644
index 000000000000..6dbb39926c6c
--- /dev/null
+++ b/xmloff/source/chart/XMLErrorIndicatorPropertyHdl.cxx
@@ -0,0 +1,105 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmloff.hxx"
+#include "XMLErrorIndicatorPropertyHdl.hxx"
+#include <xmloff/xmluconv.hxx>
+#include <com/sun/star/chart/ChartErrorIndicatorType.hpp>
+#include <rtl/ustrbuf.hxx>
+
+using namespace com::sun::star;
+
+XMLErrorIndicatorPropertyHdl::~XMLErrorIndicatorPropertyHdl()
+{}
+
+sal_Bool XMLErrorIndicatorPropertyHdl::importXML( const ::rtl::OUString& rStrImpValue,
+ uno::Any& rValue, const SvXMLUnitConverter& /*rUnitConverter*/ ) const
+{
+ sal_Bool bValue;
+ SvXMLUnitConverter::convertBool( bValue, rStrImpValue );
+
+ // modify existing value
+ chart::ChartErrorIndicatorType eType = chart::ChartErrorIndicatorType_NONE;
+ if( rValue.hasValue())
+ rValue >>= eType;
+
+ if( bValue ) // enable flag
+ {
+ if( eType != chart::ChartErrorIndicatorType_TOP_AND_BOTTOM )
+ {
+ if( mbUpperIndicator )
+ eType = ( eType == chart::ChartErrorIndicatorType_LOWER )
+ ? chart::ChartErrorIndicatorType_TOP_AND_BOTTOM
+ : chart::ChartErrorIndicatorType_UPPER;
+ else
+ eType = ( eType == chart::ChartErrorIndicatorType_UPPER )
+ ? chart::ChartErrorIndicatorType_TOP_AND_BOTTOM
+ : chart::ChartErrorIndicatorType_LOWER;
+ }
+ }
+ else // disable flag
+ {
+ if( eType != chart::ChartErrorIndicatorType_NONE )
+ {
+ if( mbUpperIndicator )
+ eType = ( eType == chart::ChartErrorIndicatorType_UPPER )
+ ? chart::ChartErrorIndicatorType_NONE
+ : chart::ChartErrorIndicatorType_LOWER;
+ else
+ eType = ( eType == chart::ChartErrorIndicatorType_LOWER )
+ ? chart::ChartErrorIndicatorType_NONE
+ : chart::ChartErrorIndicatorType_UPPER;
+ }
+ }
+
+ rValue <<= eType;
+
+ return sal_True;
+}
+
+sal_Bool XMLErrorIndicatorPropertyHdl::exportXML( ::rtl::OUString& rStrExpValue,
+ const uno::Any& rValue, const SvXMLUnitConverter& /*rUnitConverter*/ ) const
+{
+ rtl::OUStringBuffer aBuffer;
+ chart::ChartErrorIndicatorType eType;
+
+ rValue >>= eType;
+ sal_Bool bValue = ( eType == chart::ChartErrorIndicatorType_TOP_AND_BOTTOM ||
+ ( mbUpperIndicator
+ ? ( eType == chart::ChartErrorIndicatorType_UPPER )
+ : ( eType == chart::ChartErrorIndicatorType_LOWER )));
+
+ if( bValue )
+ {
+ SvXMLUnitConverter::convertBool( aBuffer, bValue );
+ rStrExpValue = aBuffer.makeStringAndClear();
+ }
+
+ // only export if set to true
+ return bValue;
+}
diff --git a/xmloff/source/chart/XMLErrorIndicatorPropertyHdl.hxx b/xmloff/source/chart/XMLErrorIndicatorPropertyHdl.hxx
new file mode 100644
index 000000000000..70304f196379
--- /dev/null
+++ b/xmloff/source/chart/XMLErrorIndicatorPropertyHdl.hxx
@@ -0,0 +1,46 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _XMLERRORINDICATORPROPERTYHDL_HXX_
+#define _XMLERRORINDICATORPROPERTYHDL_HXX_
+
+#include <xmloff/xmlprhdl.hxx>
+
+class XMLErrorIndicatorPropertyHdl : public XMLPropertyHandler
+{
+private:
+ sal_Bool mbUpperIndicator;
+
+public:
+ XMLErrorIndicatorPropertyHdl( sal_Bool bUpper ) : mbUpperIndicator( bUpper )
+ {}
+ virtual ~XMLErrorIndicatorPropertyHdl();
+
+ virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
+ virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
+};
+
+#endif // _XMLERRORINDICATORPROPERTYHDL_HXX_
diff --git a/xmloff/source/chart/XMLLabelSeparatorContext.cxx b/xmloff/source/chart/XMLLabelSeparatorContext.cxx
new file mode 100644
index 000000000000..dfebf77050f1
--- /dev/null
+++ b/xmloff/source/chart/XMLLabelSeparatorContext.cxx
@@ -0,0 +1,87 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmloff.hxx"
+#include "XMLLabelSeparatorContext.hxx"
+
+#include "SchXMLParagraphContext.hxx"
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/xmltkmap.hxx>
+#include "xmlnmspe.hxx"
+#include <xmloff/xmlimp.hxx>
+#include <xmloff/nmspmap.hxx>
+
+TYPEINIT1( XMLLabelSeparatorContext, XMLElementPropertyContext );
+
+using namespace ::com::sun::star;
+
+XMLLabelSeparatorContext::XMLLabelSeparatorContext(
+ SvXMLImport& rImport, sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLocalName,
+ const XMLPropertyState& rProp,
+ ::std::vector< XMLPropertyState > &rProps ) :
+ XMLElementPropertyContext(
+ rImport, nPrfx, rLocalName, rProp, rProps ),
+ m_aSeparator()
+{
+}
+
+XMLLabelSeparatorContext::~XMLLabelSeparatorContext()
+{}
+
+void XMLLabelSeparatorContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& /*xAttrList*/ )
+{
+}
+
+SvXMLImportContext* XMLLabelSeparatorContext::CreateChildContext(
+ sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName,
+ const uno::Reference< xml::sax::XAttributeList > & /*xAttrList*/ )
+{
+ SvXMLImportContext* pContext = NULL;
+ if( xmloff::token::IsXMLToken( rLocalName, xmloff::token::XML_P ) )
+ {
+ pContext = new SchXMLParagraphContext( GetImport(),
+ rLocalName, m_aSeparator );
+ }
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+
+ return pContext;
+}
+
+void XMLLabelSeparatorContext::EndElement()
+{
+ if( m_aSeparator.getLength() )
+ {
+ // aProp is a member of XMLElementPropertyContext
+ aProp.maValue <<= m_aSeparator;
+ SetInsert( sal_True );
+ }
+
+ XMLElementPropertyContext::EndElement();
+}
diff --git a/xmloff/source/chart/XMLLabelSeparatorContext.hxx b/xmloff/source/chart/XMLLabelSeparatorContext.hxx
new file mode 100644
index 000000000000..2678ca0ca7aa
--- /dev/null
+++ b/xmloff/source/chart/XMLLabelSeparatorContext.hxx
@@ -0,0 +1,54 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef XMLOFF_LABELSEPARATORCONTEXT_HXX_
+#define XMLOFF_LABELSEPARATORCONTEXT_HXX_
+
+#include "XMLElementPropertyContext.hxx"
+
+class XMLLabelSeparatorContext : public XMLElementPropertyContext
+{
+public:
+ TYPEINFO();
+
+ XMLLabelSeparatorContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName,
+ const XMLPropertyState& rProp,
+ ::std::vector< XMLPropertyState > &rProps );
+ virtual ~XMLLabelSeparatorContext();
+
+ virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
+ virtual SvXMLImportContext *CreateChildContext(
+ USHORT nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
+ virtual void EndElement();
+
+private:
+ ::rtl::OUString m_aSeparator;
+};
+
+#endif // _XMLOFF_SYMBOLIMAGECONTEXT_HXX_
diff --git a/xmloff/source/chart/XMLSymbolImageContext.cxx b/xmloff/source/chart/XMLSymbolImageContext.cxx
new file mode 100644
index 000000000000..99ce619be43f
--- /dev/null
+++ b/xmloff/source/chart/XMLSymbolImageContext.cxx
@@ -0,0 +1,150 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmloff.hxx"
+#include "XMLSymbolImageContext.hxx"
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/xmltkmap.hxx>
+#include "xmlnmspe.hxx"
+#include <xmloff/xmlimp.hxx>
+#include <xmloff/nmspmap.hxx>
+#include <xmloff/XMLBase64ImportContext.hxx>
+#include <com/sun/star/io/XOutputStream.hpp>
+
+TYPEINIT1( XMLSymbolImageContext, XMLElementPropertyContext );
+
+using namespace ::com::sun::star;
+
+enum SvXMLTokenMapAttrs
+{
+ XML_TOK_SYMBOL_IMAGE_HREF,
+ XML_TOK_SYMBOL_IMAGE_TYPE,
+ XML_TOK_SYMBOL_IMAGE_ACTUATE,
+ XML_TOK_SYMBOL_IMAGE_SHOW,
+ XML_TOK_SYMBOL_IMAGE_END = XML_TOK_UNKNOWN
+};
+
+static __FAR_DATA SvXMLTokenMapEntry aSymbolImageAttrTokenMap[] =
+{
+ { XML_NAMESPACE_XLINK, ::xmloff::token::XML_HREF, XML_TOK_SYMBOL_IMAGE_HREF },
+ { XML_NAMESPACE_XLINK, ::xmloff::token::XML_TYPE, XML_TOK_SYMBOL_IMAGE_TYPE },
+ { XML_NAMESPACE_XLINK, ::xmloff::token::XML_ACTUATE, XML_TOK_SYMBOL_IMAGE_ACTUATE },
+ { XML_NAMESPACE_XLINK, ::xmloff::token::XML_SHOW, XML_TOK_SYMBOL_IMAGE_SHOW },
+ XML_TOKEN_MAP_END
+};
+
+XMLSymbolImageContext::XMLSymbolImageContext(
+ SvXMLImport& rImport, sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName,
+ const XMLPropertyState& rProp,
+ ::std::vector< XMLPropertyState > &rProps ) :
+ XMLElementPropertyContext(
+ rImport, nPrfx, rLName, rProp, rProps )
+{
+}
+
+XMLSymbolImageContext::~XMLSymbolImageContext()
+{}
+
+void XMLSymbolImageContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
+{
+ SvXMLTokenMap aTokenMap( aSymbolImageAttrTokenMap );
+ ::rtl::OUString aLocalName;
+
+ sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ for( sal_Int16 i = 0; i < nAttrCount; i++ )
+ {
+ const ::rtl::OUString& rAttrName = xAttrList->getNameByIndex( i );
+ sal_uInt16 nPrefix =
+ GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
+ &aLocalName );
+ const ::rtl::OUString& rValue = xAttrList->getValueByIndex( i );
+
+ switch( aTokenMap.Get( nPrefix, aLocalName ) )
+ {
+ case XML_TOK_SYMBOL_IMAGE_HREF:
+ msURL = rValue;
+ break;
+ case XML_TOK_SYMBOL_IMAGE_ACTUATE:
+ case XML_TOK_SYMBOL_IMAGE_TYPE:
+ case XML_TOK_SYMBOL_IMAGE_SHOW:
+ // these values are currently not interpreted
+ // it is always assumed 'actuate=onLoad', 'type=simple', 'show=embed'
+ break;
+ }
+ }
+}
+
+SvXMLImportContext* XMLSymbolImageContext::CreateChildContext(
+ sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName,
+ const uno::Reference< xml::sax::XAttributeList > & xAttrList )
+{
+ SvXMLImportContext* pContext = NULL;
+ if( xmloff::token::IsXMLToken( rLocalName,
+ xmloff::token::XML_BINARY_DATA ) )
+ {
+ if( ! msURL.getLength() && ! mxBase64Stream.is() )
+ {
+ mxBase64Stream = GetImport().GetStreamForGraphicObjectURLFromBase64();
+ if( mxBase64Stream.is() )
+ pContext = new XMLBase64ImportContext( GetImport(), nPrefix,
+ rLocalName, xAttrList,
+ mxBase64Stream );
+ }
+ }
+ if( ! pContext )
+ {
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+ }
+
+ return pContext;
+}
+
+void XMLSymbolImageContext::EndElement()
+{
+ ::rtl::OUString sResolvedURL;
+
+ if( msURL.getLength() )
+ {
+ sResolvedURL = GetImport().ResolveGraphicObjectURL( msURL, sal_False );
+ }
+ else if( mxBase64Stream.is() )
+ {
+ sResolvedURL = GetImport().ResolveGraphicObjectURLFromBase64( mxBase64Stream );
+ mxBase64Stream = 0;
+ }
+
+ if( sResolvedURL.getLength())
+ {
+ // aProp is a member of XMLElementPropertyContext
+ aProp.maValue <<= sResolvedURL;
+ SetInsert( sal_True );
+ }
+
+ XMLElementPropertyContext::EndElement();
+}
diff --git a/xmloff/source/chart/XMLSymbolImageContext.hxx b/xmloff/source/chart/XMLSymbolImageContext.hxx
new file mode 100644
index 000000000000..419d2b61ed6d
--- /dev/null
+++ b/xmloff/source/chart/XMLSymbolImageContext.hxx
@@ -0,0 +1,59 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _XMLOFF_SYMBOLIMAGECONTEXT_HXX_
+#define _XMLOFF_SYMBOLIMAGECONTEXT_HXX_
+
+#include "XMLElementPropertyContext.hxx"
+
+namespace com { namespace sun { namespace star {
+ namespace io { class XOutputStream; }
+} } }
+
+class XMLSymbolImageContext : public XMLElementPropertyContext
+{
+public:
+ TYPEINFO();
+
+ XMLSymbolImageContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName,
+ const XMLPropertyState& rProp,
+ ::std::vector< XMLPropertyState > &rProps );
+ virtual ~XMLSymbolImageContext();
+
+ virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
+ virtual SvXMLImportContext *CreateChildContext(
+ USHORT nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
+ virtual void EndElement();
+
+private:
+ ::rtl::OUString msURL;
+ ::com::sun::star::uno::Reference < ::com::sun::star::io::XOutputStream > mxBase64Stream;
+};
+
+#endif // _XMLOFF_SYMBOLIMAGECONTEXT_HXX_
diff --git a/xmloff/source/chart/XMLSymbolTypePropertyHdl.cxx b/xmloff/source/chart/XMLSymbolTypePropertyHdl.cxx
new file mode 100644
index 000000000000..b476a094540a
--- /dev/null
+++ b/xmloff/source/chart/XMLSymbolTypePropertyHdl.cxx
@@ -0,0 +1,170 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmloff.hxx"
+#include "XMLSymbolTypePropertyHdl.hxx"
+#include <xmloff/xmluconv.hxx>
+#include <com/sun/star/chart/ChartErrorIndicatorType.hpp>
+#include <rtl/ustrbuf.hxx>
+
+using namespace ::xmloff::token;
+using ::rtl::OUString;
+using ::rtl::OUStringBuffer;
+
+namespace
+{
+struct SvXMLSignedEnumMapEntry
+{
+ ::xmloff::token::XMLTokenEnum eToken;
+ sal_Int32 nValue;
+};
+
+SvXMLSignedEnumMapEntry aXMLChartSymbolTypeEnumMap[] =
+{
+ { XML_NONE, -3 },
+ { XML_AUTOMATIC, -2 },
+ { XML_IMAGE, -1 },
+ { XML_TOKEN_INVALID, 0 }
+};
+
+SvXMLSignedEnumMapEntry aXMLChartSymbolNameMap[] =
+{
+ { XML_GRADIENTSTYLE_SQUARE, 0 }, // "square"
+ { XML_DIAMOND, 1 },
+ { XML_ARROW_DOWN, 2 },
+ { XML_ARROW_UP, 3 },
+ { XML_ARROW_RIGHT, 4 },
+ { XML_ARROW_LEFT, 5 },
+ { XML_BOW_TIE, 6 },
+ { XML_HOURGLASS, 7 },
+ { XML_TOKEN_INVALID, 0 }
+};
+
+sal_Bool lcl_convertEnum(
+ OUStringBuffer & rBuffer,
+ sal_Int32 nValue,
+ const SvXMLSignedEnumMapEntry *pMap )
+{
+ enum XMLTokenEnum eTok = XML_TOKEN_INVALID;
+
+ while( pMap->eToken != XML_TOKEN_INVALID )
+ {
+ if( pMap->nValue == nValue )
+ {
+ eTok = pMap->eToken;
+ break;
+ }
+ pMap++;
+ }
+
+ if( eTok != XML_TOKEN_INVALID )
+ rBuffer.append( GetXMLToken(eTok) );
+
+ return (eTok != XML_TOKEN_INVALID);
+}
+
+sal_Bool lcl_convertEnum(
+ sal_Int32 & rEnum,
+ const OUString & rValue,
+ const SvXMLSignedEnumMapEntry *pMap )
+{
+ while( pMap->eToken != XML_TOKEN_INVALID )
+ {
+ if( IsXMLToken( rValue, pMap->eToken ) )
+ {
+ rEnum = pMap->nValue;
+ return sal_True;
+ }
+ pMap++;
+ }
+ return sal_False;
+}
+
+} // anonymous namespace
+
+using namespace com::sun::star;
+
+XMLSymbolTypePropertyHdl::XMLSymbolTypePropertyHdl( bool bIsNamedSymbol )
+ : m_bIsNamedSymbol( bIsNamedSymbol )
+{}
+
+XMLSymbolTypePropertyHdl::~XMLSymbolTypePropertyHdl()
+{}
+
+sal_Bool XMLSymbolTypePropertyHdl::importXML( const OUString& rStrImpValue,
+ uno::Any& rValue, const SvXMLUnitConverter& /*rUnitConverter*/ ) const
+{
+ sal_Bool bResult = sal_False;
+
+ if( m_bIsNamedSymbol )
+ {
+ sal_Int32 nValue = -3; // NONE
+ bResult = lcl_convertEnum( nValue, rStrImpValue, aXMLChartSymbolNameMap );
+ rValue <<= nValue;
+ }
+ else
+ {
+ sal_Int32 nValue = -3; // NONE
+ bResult = lcl_convertEnum( nValue, rStrImpValue, aXMLChartSymbolTypeEnumMap );
+ rValue <<= nValue;
+ }
+
+ return bResult;
+}
+
+sal_Bool XMLSymbolTypePropertyHdl::exportXML( OUString& rStrExpValue,
+ const uno::Any& rValue, const SvXMLUnitConverter& /*rUnitConverter*/ ) const
+{
+ sal_Bool bResult = sal_False;
+
+ sal_Int32 nType = -3; // NONE
+ rValue >>= nType;
+
+ if( m_bIsNamedSymbol )
+ {
+ OUStringBuffer aBuf;
+ bResult = lcl_convertEnum( aBuf, nType, aXMLChartSymbolNameMap );
+ rStrExpValue = aBuf.makeStringAndClear();
+ }
+ else
+ {
+ if( nType < 0 )
+ {
+ OUStringBuffer aBuf;
+ bResult = lcl_convertEnum( aBuf, nType, aXMLChartSymbolTypeEnumMap );
+ rStrExpValue = aBuf.makeStringAndClear();
+ }
+ else
+ {
+ bResult = true;
+ rStrExpValue = GetXMLToken( XML_NAMED_SYMBOL );
+ }
+ }
+
+ return bResult;
+}
diff --git a/xmloff/source/chart/XMLSymbolTypePropertyHdl.hxx b/xmloff/source/chart/XMLSymbolTypePropertyHdl.hxx
new file mode 100644
index 000000000000..df6f7310c18a
--- /dev/null
+++ b/xmloff/source/chart/XMLSymbolTypePropertyHdl.hxx
@@ -0,0 +1,46 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _XMLSYMBOLTYPEPROPERTYHDL_HXX_
+#define _XMLSYMBOLTYPEPROPERTYHDL_HXX_
+
+#include <xmloff/xmlprhdl.hxx>
+
+class XMLSymbolTypePropertyHdl : public XMLPropertyHandler
+{
+public:
+ XMLSymbolTypePropertyHdl( bool bIsNamedSymbol );
+ virtual ~XMLSymbolTypePropertyHdl();
+
+ virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
+ virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const;
+
+private:
+ bool m_bIsNamedSymbol;
+ sal_Int32 nSymbolType;
+};
+
+#endif // _XMLSYMBOLTYPEPROPERTYHDL_HXX_
diff --git a/xmloff/source/chart/XMLTextOrientationHdl.cxx b/xmloff/source/chart/XMLTextOrientationHdl.cxx
new file mode 100644
index 000000000000..706cf5044178
--- /dev/null
+++ b/xmloff/source/chart/XMLTextOrientationHdl.cxx
@@ -0,0 +1,80 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmloff.hxx"
+#include "XMLTextOrientationHdl.hxx"
+#include <xmloff/xmluconv.hxx>
+#include <xmloff/xmltoken.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::xmloff::token;
+
+XMLTextOrientationHdl::~XMLTextOrientationHdl()
+{
+}
+
+sal_Bool XMLTextOrientationHdl::importXML(
+ const ::rtl::OUString& rStrImpValue,
+ ::com::sun::star::uno::Any& rValue,
+ const SvXMLUnitConverter& /*rUnitConverter*/ ) const
+{
+ sal_Bool bRetval( sal_False );
+
+ if( IsXMLToken( rStrImpValue, XML_LTR ))
+ {
+ rValue <<= static_cast< sal_Bool >( sal_False );
+ bRetval = sal_True;
+ }
+ else if( IsXMLToken( rStrImpValue, XML_TTB ))
+ {
+ rValue <<= static_cast< sal_Bool >( sal_True );
+ bRetval = sal_True;
+ }
+
+ return bRetval;
+}
+
+sal_Bool XMLTextOrientationHdl::exportXML(
+ ::rtl::OUString& rStrExpValue,
+ const ::com::sun::star::uno::Any& rValue,
+ const SvXMLUnitConverter& /*rUnitConverter*/ ) const
+{
+ sal_Bool bVal (sal_False );
+ sal_Bool bRetval( sal_False );
+
+ if( rValue >>= bVal )
+ {
+ if( bVal )
+ rStrExpValue = GetXMLToken( XML_TTB );
+ else
+ rStrExpValue = GetXMLToken( XML_LTR );
+ bRetval = sal_True;
+ }
+
+ return bRetval;
+}
diff --git a/xmloff/source/chart/XMLTextOrientationHdl.hxx b/xmloff/source/chart/XMLTextOrientationHdl.hxx
new file mode 100644
index 000000000000..a7fa80cef5c6
--- /dev/null
+++ b/xmloff/source/chart/XMLTextOrientationHdl.hxx
@@ -0,0 +1,46 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _XMLTEXTORIENTATIONHDL_HXX_
+#define _XMLTEXTORIENTATIONHDL_HXX_
+
+#include <xmloff/xmlprhdl.hxx>
+
+class XMLTextOrientationHdl : public XMLPropertyHandler
+{
+private:
+public:
+ virtual ~XMLTextOrientationHdl();
+
+ virtual sal_Bool importXML( const ::rtl::OUString& rStrImpValue,
+ ::com::sun::star::uno::Any& rValue,
+ const SvXMLUnitConverter& rUnitConverter ) const;
+ virtual sal_Bool exportXML( ::rtl::OUString& rStrExpValue,
+ const ::com::sun::star::uno::Any& rValue,
+ const SvXMLUnitConverter& rUnitConverter ) const;
+};
+
+#endif // _XMLTEXTORIENTATIONHDL_HXX_
diff --git a/xmloff/source/chart/contexts.cxx b/xmloff/source/chart/contexts.cxx
new file mode 100644
index 000000000000..8d9ba3b7ff26
--- /dev/null
+++ b/xmloff/source/chart/contexts.cxx
@@ -0,0 +1,233 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmloff.hxx"
+#include <tools/debug.hxx>
+#include <xmloff/xmltoken.hxx>
+#include "xmlnmspe.hxx"
+#include <xmloff/xmlmetai.hxx>
+#include <xmloff/xmlstyle.hxx>
+#include "SchXMLImport.hxx"
+#include "SchXMLCalculationSettingsContext.hxx"
+
+#include "contexts.hxx"
+#include "SchXMLChartContext.hxx"
+
+using namespace com::sun::star;
+using namespace ::xmloff::token;
+
+// ==================================================
+
+class SchXMLBodyContext_Impl : public SvXMLImportContext
+{
+private:
+ SchXMLImportHelper& mrImportHelper;
+
+public:
+
+ SchXMLBodyContext_Impl( SchXMLImportHelper& rImpHelper,
+ SvXMLImport& rImport, sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName );
+ virtual ~SchXMLBodyContext_Impl();
+
+ virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const uno::Reference< xml::sax::XAttributeList > & xAttrList );
+};
+
+SchXMLBodyContext_Impl::SchXMLBodyContext_Impl(
+ SchXMLImportHelper& rImpHelper, SvXMLImport& rImport,
+ sal_uInt16 nPrfx, const ::rtl::OUString& rLName ) :
+ SvXMLImportContext( rImport, nPrfx, rLName ),
+ mrImportHelper( rImpHelper )
+{
+}
+
+SchXMLBodyContext_Impl::~SchXMLBodyContext_Impl()
+{
+}
+
+SvXMLImportContext *SchXMLBodyContext_Impl::CreateChildContext(
+ sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const uno::Reference< xml::sax::XAttributeList > & )
+{
+ return new SchXMLBodyContext( mrImportHelper, GetImport(), nPrefix,
+ rLocalName );
+}
+
+// ==================================================
+
+SchXMLDocContext::SchXMLDocContext( SchXMLImportHelper& rImpHelper,
+ SvXMLImport& rImport,
+ USHORT nPrefix,
+ const rtl::OUString& rLName ) :
+ SvXMLImportContext( rImport, nPrefix, rLName ),
+ mrImportHelper( rImpHelper )
+{
+ DBG_ASSERT( XML_NAMESPACE_OFFICE == nPrefix &&
+ ( IsXMLToken( rLName, XML_DOCUMENT ) ||
+ IsXMLToken( rLName, XML_DOCUMENT_META) ||
+ IsXMLToken( rLName, XML_DOCUMENT_STYLES) ||
+ IsXMLToken( rLName, XML_DOCUMENT_CONTENT) ),
+ "SchXMLDocContext instanciated with no <office:document> element" );
+}
+
+SchXMLDocContext::~SchXMLDocContext()
+{}
+
+TYPEINIT1( SchXMLDocContext, SvXMLImportContext );
+
+SvXMLImportContext* SchXMLDocContext::CreateChildContext(
+ sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const uno::Reference< xml::sax::XAttributeList >& xAttrList )
+{
+ SvXMLImportContext* pContext = 0;
+ const SvXMLTokenMap& rTokenMap = mrImportHelper.GetDocElemTokenMap();
+ sal_uInt16 nFlags = GetImport().getImportFlags();
+
+ switch( rTokenMap.Get( nPrefix, rLocalName ))
+ {
+ case XML_TOK_DOC_AUTOSTYLES:
+ if( nFlags & IMPORT_AUTOSTYLES )
+ // not nice, but this is safe, as the SchXMLDocContext class can only by
+ // instantiated by the chart import class SchXMLImport (header is not exported)
+ pContext =
+ static_cast< SchXMLImport& >( GetImport() ).CreateStylesContext( rLocalName, xAttrList );
+ break;
+ case XML_TOK_DOC_STYLES:
+ // for draw styles containing gradients/hatches/markers and dashes
+ if( nFlags & IMPORT_STYLES )
+ pContext = new SvXMLStylesContext( GetImport(), nPrefix, rLocalName, xAttrList );
+ break;
+ case XML_TOK_DOC_META:
+ // we come here in the flat ODF file format,
+ // if XDocumentPropertiesSupplier is not supported at the model
+// DBG_WARNING("XML_TOK_DOC_META: should not have come here, maybe document is invalid?");
+ pContext = SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList );
+ break;
+ case XML_TOK_DOC_BODY:
+ if( nFlags & IMPORT_CONTENT )
+ pContext = new SchXMLBodyContext_Impl( mrImportHelper, GetImport(), nPrefix, rLocalName );
+ break;
+ }
+
+ // call parent when no own context was created
+ if( ! pContext )
+ pContext = SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList );
+
+ return pContext;
+}
+
+// ==================================================
+
+SchXMLFlatDocContext_Impl::SchXMLFlatDocContext_Impl(
+ SchXMLImportHelper& i_rImpHelper,
+ SchXMLImport& i_rImport,
+ USHORT i_nPrefix, const ::rtl::OUString & i_rLName,
+ const uno::Reference<document::XDocumentProperties>& i_xDocProps,
+ const uno::Reference<xml::sax::XDocumentHandler>& i_xDocBuilder) :
+ SvXMLImportContext(i_rImport, i_nPrefix, i_rLName),
+ SchXMLDocContext(i_rImpHelper, i_rImport, i_nPrefix, i_rLName),
+ SvXMLMetaDocumentContext(i_rImport, i_nPrefix, i_rLName,
+ i_xDocProps, i_xDocBuilder)
+{
+}
+
+SchXMLFlatDocContext_Impl::~SchXMLFlatDocContext_Impl() { }
+
+
+SvXMLImportContext *SchXMLFlatDocContext_Impl::CreateChildContext(
+ USHORT i_nPrefix, const ::rtl::OUString& i_rLocalName,
+ const uno::Reference<xml::sax::XAttributeList>& i_xAttrList)
+{
+ // behave like meta base class iff we encounter office:meta
+ const SvXMLTokenMap& rTokenMap =
+ mrImportHelper.GetDocElemTokenMap();
+ if ( XML_TOK_DOC_META == rTokenMap.Get( i_nPrefix, i_rLocalName ) ) {
+ return SvXMLMetaDocumentContext::CreateChildContext(
+ i_nPrefix, i_rLocalName, i_xAttrList );
+ } else {
+ return SchXMLDocContext::CreateChildContext(
+ i_nPrefix, i_rLocalName, i_xAttrList );
+ }
+}
+
+// ----------------------------------------
+
+SchXMLBodyContext::SchXMLBodyContext( SchXMLImportHelper& rImpHelper,
+ SvXMLImport& rImport,
+ USHORT nPrefix,
+ const rtl::OUString& rLName ) :
+ SvXMLImportContext( rImport, nPrefix, rLName ),
+ mrImportHelper( rImpHelper )
+{
+ DBG_ASSERT( XML_NAMESPACE_OFFICE == nPrefix &&
+ IsXMLToken( rLName, XML_CHART ),
+ "SchXMLBodyContext instanciated with no <office:chart> element" );
+}
+
+SchXMLBodyContext::~SchXMLBodyContext()
+{}
+
+void SchXMLBodyContext::EndElement()
+{
+}
+
+SvXMLImportContext* SchXMLBodyContext::CreateChildContext(
+ sal_uInt16 nPrefix,
+ const rtl::OUString& rLocalName,
+ const uno::Reference< xml::sax::XAttributeList >& xAttrList )
+{
+ SvXMLImportContext* pContext = 0;
+
+ // <chart:chart> element
+ if( nPrefix == XML_NAMESPACE_CHART &&
+ IsXMLToken( rLocalName, XML_CHART ) )
+ {
+ pContext = mrImportHelper.CreateChartContext( GetImport(),
+ nPrefix, rLocalName,
+ GetImport().GetModel(),
+ xAttrList );
+ }
+ else if(nPrefix == XML_NAMESPACE_TABLE &&
+ IsXMLToken( rLocalName, XML_CALCULATION_SETTINGS ))
+ {
+ // i99104 handle null date correctly
+ pContext = new SchXMLCalculationSettingsContext ( GetImport(), nPrefix, rLocalName, xAttrList);
+ }
+ else
+ {
+ pContext = SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList );
+ }
+
+ return pContext;
+}
+
+
diff --git a/xmloff/source/chart/contexts.hxx b/xmloff/source/chart/contexts.hxx
new file mode 100644
index 000000000000..1fb23147a34b
--- /dev/null
+++ b/xmloff/source/chart/contexts.hxx
@@ -0,0 +1,115 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _SCH_XML_CONTEXTS_HXX_
+#define _SCH_XML_CONTEXTS_HXX_
+
+#include "SchXMLImport.hxx"
+#include "SchXMLTableContext.hxx"
+#include <xmloff/xmlictxt.hxx>
+#include <xmloff/xmltkmap.hxx>
+
+#include <xmloff/xmlmetai.hxx>
+
+namespace com { namespace sun { namespace star { namespace xml { namespace sax {
+ class XAttributeList;
+}}}}}
+
+/* ========================================
+
+ These contexts are only nedded by
+ SchXMLImport not by the SchXMLImportHelper
+ that is also used by other applications
+
+ ======================================== */
+
+class SchXMLDocContext : public virtual SvXMLImportContext
+{
+protected:
+ SchXMLImportHelper& mrImportHelper;
+
+public:
+ SchXMLDocContext(
+ SchXMLImportHelper& rImpHelper,
+ SvXMLImport& rImport,
+ sal_uInt16 nPrefix,
+ const rtl::OUString& rLName );
+ virtual ~SchXMLDocContext();
+
+ TYPEINFO();
+
+ virtual SvXMLImportContext* CreateChildContext(
+ sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList );
+};
+
+// ========================================
+
+// context for flat file xml format
+class SchXMLFlatDocContext_Impl
+ : public SchXMLDocContext, public SvXMLMetaDocumentContext
+{
+public:
+ SchXMLFlatDocContext_Impl(
+ SchXMLImportHelper& i_rImpHelper,
+ SchXMLImport& i_rImport,
+ USHORT i_nPrefix, const ::rtl::OUString & i_rLName,
+ const com::sun::star::uno::Reference<com::sun::star::document::XDocumentProperties>& i_xDocProps,
+ const com::sun::star::uno::Reference<com::sun::star::xml::sax::XDocumentHandler>& i_xDocBuilder);
+
+ virtual ~SchXMLFlatDocContext_Impl();
+
+ virtual SvXMLImportContext *CreateChildContext(
+ USHORT i_nPrefix, const ::rtl::OUString& i_rLocalName,
+ const com::sun::star::uno::Reference<com::sun::star::xml::sax::XAttributeList>& i_xAttrList);
+};
+
+// ========================================
+
+class SchXMLBodyContext : public SvXMLImportContext
+{
+private:
+ SchXMLImportHelper& mrImportHelper;
+
+public:
+ SchXMLBodyContext(
+ SchXMLImportHelper& rImpHelper,
+ SvXMLImport& rImport,
+ sal_uInt16 nPrefix,
+ const rtl::OUString& rLName );
+ virtual ~SchXMLBodyContext();
+
+ virtual void EndElement();
+ virtual SvXMLImportContext* CreateChildContext(
+ sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList );
+};
+
+// ========================================
+
+#endif // _SCH_XML_CONTEXTS_HXX_
diff --git a/xmloff/source/chart/makefile.mk b/xmloff/source/chart/makefile.mk
new file mode 100644
index 000000000000..bfdc9aeb5e22
--- /dev/null
+++ b/xmloff/source/chart/makefile.mk
@@ -0,0 +1,70 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ = ..$/..
+PRJNAME = xmloff
+TARGET = chart
+AUTOSEG = true
+ENABLE_EXCEPTIONS = TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE: $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES = $(SLO)$/ColorPropertySet.obj \
+ $(SLO)$/SchXMLTools.obj \
+ $(SLO)$/SchXMLExport.obj \
+ $(SLO)$/SchXMLImport.obj \
+ $(SLO)$/contexts.obj \
+ $(SLO)$/SchXMLTableContext.obj \
+ $(SLO)$/SchXMLChartContext.obj \
+ $(SLO)$/SchXMLPlotAreaContext.obj \
+ $(SLO)$/SchXMLParagraphContext.obj \
+ $(SLO)$/SchXMLTextListContext.obj \
+ $(SLO)$/SchXMLSeriesHelper.obj \
+ $(SLO)$/SchXMLSeries2Context.obj \
+ $(SLO)$/PropertyMaps.obj \
+ $(SLO)$/XMLChartStyleContext.obj \
+ $(SLO)$/XMLErrorIndicatorPropertyHdl.obj \
+ $(SLO)$/XMLErrorBarStylePropertyHdl.obj \
+ $(SLO)$/SchXMLAutoStylePoolP.obj \
+ $(SLO)$/XMLChartPropertyContext.obj \
+ $(SLO)$/XMLSymbolImageContext.obj \
+ $(SLO)$/XMLLabelSeparatorContext.obj \
+ $(SLO)$/XMLTextOrientationHdl.obj \
+ $(SLO)$/XMLSymbolTypePropertyHdl.obj \
+ $(SLO)$/XMLAxisPositionPropertyHdl.obj \
+ $(SLO)$/SchXMLCalculationSettingsContext.obj \
+ $(SLO)$/transporttypes.obj
+
+# --- Targets --------------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/xmloff/source/chart/transporttypes.cxx b/xmloff/source/chart/transporttypes.cxx
new file mode 100644
index 000000000000..c0a1e65e0eba
--- /dev/null
+++ b/xmloff/source/chart/transporttypes.cxx
@@ -0,0 +1,38 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmloff.hxx"
+
+#include "transporttypes.hxx"
+
+bool operator < ( const tSchXMLIndexWithPart & rFirst, const tSchXMLIndexWithPart & rSecond )
+{
+ if( rFirst.first == rSecond.first )
+ return (static_cast< int >( rFirst.second ) < static_cast< int >( rSecond.second ));
+ return (rFirst.first < rSecond.first);
+}
diff --git a/xmloff/source/chart/transporttypes.hxx b/xmloff/source/chart/transporttypes.hxx
new file mode 100644
index 000000000000..27c8850e2b81
--- /dev/null
+++ b/xmloff/source/chart/transporttypes.hxx
@@ -0,0 +1,222 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SCH_XML_TRANSPORTTYPES_HXX_
+#define SCH_XML_TRANSPORTTYPES_HXX_
+
+#include <com/sun/star/chart2/XDataSeries.hpp>
+#include <com/sun/star/chart2/data/XLabeledDataSequence.hpp>
+
+#include <vector>
+#include <map>
+
+enum SchXMLCellType
+{
+ SCH_CELL_TYPE_UNKNOWN,
+ SCH_CELL_TYPE_FLOAT,
+ SCH_CELL_TYPE_STRING,
+ SCH_CELL_TYPE_COMPLEX_STRING
+};
+
+struct SchXMLCell
+{
+ rtl::OUString aString;
+ ::com::sun::star::uno::Sequence< rtl::OUString >* pComplexString;
+ double fValue;
+ SchXMLCellType eType;
+ rtl::OUString aRangeId;
+
+ SchXMLCell() : pComplexString(0), fValue( 0.0 ), eType( SCH_CELL_TYPE_UNKNOWN )
+ {}
+
+ SchXMLCell( const SchXMLCell& rOther )
+ : aString( rOther.aString )
+ , pComplexString( rOther.pComplexString ? new ::com::sun::star::uno::Sequence< rtl::OUString >( *rOther.pComplexString ) : 0 )
+ , fValue( rOther.fValue )
+ , eType( rOther.eType )
+ , aRangeId( rOther.aRangeId )
+ {}
+
+ ~SchXMLCell()
+ {
+ if(pComplexString)
+ {
+ delete pComplexString;
+ pComplexString=0;
+ }
+ }
+};
+
+struct SchXMLTable
+{
+ std::vector< std::vector< SchXMLCell > > aData; /// an array of rows containing the table contents
+
+ sal_Int32 nRowIndex; /// reflects the index of the row currently parsed
+ sal_Int32 nColumnIndex; /// reflects the index of the column currently parsed
+ sal_Int32 nMaxColumnIndex; /// the greatest number of columns detected
+
+ sal_Int32 nNumberOfColsEstimate; /// parsing column-elements may yield an estimate
+
+ bool bHasHeaderRow;
+ bool bHasHeaderColumn;
+
+ ::rtl::OUString aTableNameOfFile; /// the table name read at the table:table element
+
+ ::std::vector< sal_Int32 > aHiddenColumns;
+
+ SchXMLTable() : nRowIndex( -1 ),
+ nColumnIndex( -1 ),
+ nMaxColumnIndex( -1 ),
+ nNumberOfColsEstimate( 0 ),
+ bHasHeaderRow( false ),
+ bHasHeaderColumn( false )
+ {}
+};
+
+typedef sal_Int32 tSchXMLIndex;
+#define SCH_XML_CATEGORIES_INDEX (static_cast<tSchXMLIndex>(-1))
+enum SchXMLLabeledSequencePart
+{
+ SCH_XML_PART_LABEL,
+ SCH_XML_PART_VALUES,
+ SCH_XML_PART_ERROR_BARS
+};
+typedef ::std::pair< tSchXMLIndex, SchXMLLabeledSequencePart > tSchXMLIndexWithPart;
+typedef ::std::multimap< tSchXMLIndexWithPart,
+ ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence > >
+ tSchXMLLSequencesPerIndex;
+
+bool operator < ( const tSchXMLIndexWithPart & rFirst, const tSchXMLIndexWithPart & rSecond );
+
+// ----------------------------------------
+
+struct SchNumericCellRangeAddress
+{
+ sal_Int32 nRow1, nRow2;
+ sal_Int32 nCol1, nCol2;
+
+ SchNumericCellRangeAddress() :
+ nRow1( -1 ), nRow2( -1 ),
+ nCol1( -1 ), nCol2( -1 )
+ {}
+
+ SchNumericCellRangeAddress( const SchNumericCellRangeAddress& aOther )
+ {
+ nRow1 = aOther.nRow1; nRow2 = aOther.nRow2;
+ nCol1 = aOther.nCol1; nCol2 = aOther.nCol2;
+ }
+};
+
+// ----------------------------------------
+
+enum SchXMLAxisClass
+{
+ SCH_XML_AXIS_X = 0,
+ SCH_XML_AXIS_Y,
+ SCH_XML_AXIS_Z,
+ SCH_XML_AXIS_UNDEF
+};
+
+struct SchXMLAxis
+{
+ enum SchXMLAxisClass eClass;
+ sal_Int8 nIndexInCategory;
+ rtl::OUString aName;
+ rtl::OUString aTitle;
+ bool bHasCategories;
+
+ SchXMLAxis() : eClass( SCH_XML_AXIS_UNDEF ), nIndexInCategory( 0 ), bHasCategories( false ) {}
+};
+
+// ----------------------------------------
+
+struct GlobalSeriesImportInfo
+{
+ GlobalSeriesImportInfo( sal_Bool& rAllRangeAddressesAvailable )
+ : rbAllRangeAddressesAvailable( rAllRangeAddressesAvailable )
+ , nCurrentDataIndex( 0 )
+ , nFirstFirstDomainIndex( -1 )
+ , nFirstSecondDomainIndex( -1 )
+ {}
+
+ sal_Bool& rbAllRangeAddressesAvailable;
+
+ sal_Int32 nCurrentDataIndex;
+
+ ::rtl::OUString aFirstFirstDomainAddress;
+ sal_Int32 nFirstFirstDomainIndex;
+
+ ::rtl::OUString aFirstSecondDomainAddress;
+ sal_Int32 nFirstSecondDomainIndex;
+};
+
+struct DataRowPointStyle
+{
+ enum StyleType
+ {
+ DATA_POINT,
+ DATA_SERIES,
+ MEAN_VALUE,
+ REGRESSION,
+ ERROR_INDICATOR
+ };
+
+ StyleType meType;
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XDataSeries > m_xSeries;
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > m_xOldAPISeries;
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > m_xEquationProperties;
+ sal_Int32 m_nPointIndex;
+ sal_Int32 m_nPointRepeat;
+ ::rtl::OUString msStyleName;
+ ::rtl::OUString msSeriesStyleNameForDonuts;
+ sal_Int32 mnAttachedAxis;
+ bool mbSymbolSizeForSeriesIsMissingInFile;
+
+ DataRowPointStyle( StyleType eType
+ , const ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XDataSeries >& xSeries
+ , sal_Int32 nPointIndex
+ , sal_Int32 nPointRepeat
+ , ::rtl::OUString sStyleName
+ , sal_Int32 nAttachedAxis = 0 ) :
+ meType( eType ),
+ m_xSeries( xSeries ),
+ m_xOldAPISeries( 0 ),
+ m_nPointIndex( nPointIndex ),
+ m_nPointRepeat( nPointRepeat ),
+ msStyleName( sStyleName ),
+ mnAttachedAxis( nAttachedAxis ),
+ mbSymbolSizeForSeriesIsMissingInFile( false )
+ {}
+};
+
+typedef ::std::multimap< ::rtl::OUString, ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::data::XDataSequence > > tSchXMLRangeSequenceMap;
+
+#endif // SCH_XML_TRANSPORTTYPES_HXX_