[Libreoffice-commits] core.git: Branch 'private/moggi/chart-opengl-fixes' - xmloff/source

Markus Mohrhard markus.mohrhard at collabora.co.uk
Sun Mar 16 21:37:54 PDT 2014


 xmloff/source/chart/SchXMLPropertyMappingContext.cxx |  111 +++++++++++++++++++
 xmloff/source/chart/SchXMLPropertyMappingContext.hxx |   50 ++++++++
 2 files changed, 161 insertions(+)

New commits:
commit 96b024019472b34696f25c895898e1a92e397bfd
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Mon Mar 17 05:36:10 2014 +0100

    add missing files
    
    Change-Id: I1d79c1b6678e9ae42642bb0371f8292c42eb4c53

diff --git a/xmloff/source/chart/SchXMLPropertyMappingContext.cxx b/xmloff/source/chart/SchXMLPropertyMappingContext.cxx
new file mode 100644
index 0000000..affe3aa
--- /dev/null
+++ b/xmloff/source/chart/SchXMLPropertyMappingContext.cxx
@@ -0,0 +1,111 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "SchXMLPropertyMappingContext.hxx"
+#include "PropertyMap.hxx"
+#include "SchXMLTools.hxx"
+#include <xmloff/xmlnmspe.hxx>
+#include <xmloff/xmlimp.hxx>
+#include <xmloff/nmspmap.hxx>
+#include <xmloff/SchXMLSeriesHelper.hxx>
+#include "SchXMLImport.hxx"
+
+#include <com/sun/star/chart2/data/XLabeledDataSequence2.hpp>
+#include <com/sun/star/chart2/data/XDataSource.hpp>
+#include <com/sun/star/chart2/data/XDataSink.hpp>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace {
+
+Reference< chart2::data::XLabeledDataSequence2 > createAndAddSequenceToSeries( const OUString& rRole
+        , const OUString& rRange
+        , const Reference< chart2::XChartDocument >& xChartDoc
+        , const Reference< chart2::XDataSeries >& xSeries )
+{
+    Reference< chart2::data::XLabeledDataSequence2 > xLabeledSeq;
+
+    Reference< chart2::data::XDataSource > xSeriesSource( xSeries,uno::UNO_QUERY );
+
+    if( !(!rRange.isEmpty() && xChartDoc.is() && xSeriesSource.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("Role", uno::makeAny( rRole));
+    xLabeledSeq->setValues( xSeq );
+
+    return xLabeledSeq;
+}
+
+}
+
+SchXMLPropertyMappingContext::SchXMLPropertyMappingContext( SchXMLImportHelper& rImpHelper,
+        SvXMLImport& rImport, const OUString& rLocalName,
+        tSchXMLLSequencesPerIndex & rLSequencesPerIndex,
+        uno::Reference<
+        chart2::XDataSeries > xSeries ):
+    SvXMLImportContext( rImport, XML_NAMESPACE_LO_EXT, rLocalName ),
+    mrImportHelper( rImpHelper ),
+    mxDataSeries(xSeries),
+    mrLSequencesPerIndex(rLSequencesPerIndex)
+{
+
+}
+
+SchXMLPropertyMappingContext::~SchXMLPropertyMappingContext()
+{
+}
+
+void SchXMLPropertyMappingContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList )
+{
+    OUString aRange;
+    OUString aRole;
+    // parse attributes
+    sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
+    const SvXMLTokenMap& rAttrTokenMap = mrImportHelper.GetPropMappingAttrTokenMap();
+
+    for( sal_Int16 i = 0; i < nAttrCount; i++ )
+    {
+        OUString sAttrName = xAttrList->getNameByIndex( i );
+        OUString aLocalName;
+        OUString aValue = xAttrList->getValueByIndex( i );
+        sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
+
+        switch( rAttrTokenMap.Get( nPrefix, aLocalName ))
+        {
+            case XML_TOK_PROPERTY_MAPPING_PROPERTY:
+                aRole = aValue;
+                break;
+            case XML_TOK_PROPERTY_MAPPING_RANGE:
+                aRange = aValue;
+                break;
+        }
+    }
+
+    if( !aRange.isEmpty() && !aRole.isEmpty() )
+    {
+        Reference< chart2::XChartDocument > xChartDoc( GetImport().GetModel(), uno::UNO_QUERY );
+        Reference< chart2::data::XLabeledDataSequence2 > xSeq =
+            createAndAddSequenceToSeries(aRole, aRange, xChartDoc, mxDataSeries);
+        mrLSequencesPerIndex.insert(
+                tSchXMLLSequencesPerIndex::value_type(
+                    tSchXMLIndexWithPart( 0, SCH_XML_PART_VALUES),
+                    Reference< chart2::data::XLabeledDataSequence >( xSeq, UNO_QUERY )));
+    }
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmloff/source/chart/SchXMLPropertyMappingContext.hxx b/xmloff/source/chart/SchXMLPropertyMappingContext.hxx
new file mode 100644
index 0000000..b42bba2
--- /dev/null
+++ b/xmloff/source/chart/SchXMLPropertyMappingContext.hxx
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_XMLOFF_SOURCE_CHART_SCHXMLPROPERTYMAPPINGCONTEXt_HXX
+#define INCLUDED_XMLOFF_SOURCE_CHART_SCHXMLPROPERTYMAPPINGCONTEXt_HXX
+
+#include "transporttypes.hxx"
+#include "SchXMLChartContext.hxx"
+#include <xmloff/xmlictxt.hxx>
+#include <xmloff/SchXMLImportHelper.hxx>
+
+namespace com { namespace sun { namespace star {
+    namespace chart2 {
+        class XChartDocument;
+        class XDataSeries;
+    }
+}}}
+
+class SchXMLPropertyMappingContext : public SvXMLImportContext
+{
+public:
+
+    SchXMLPropertyMappingContext( SchXMLImportHelper& rImpHelper,
+                          SvXMLImport& rImport, const OUString& rLocalName,
+                          tSchXMLLSequencesPerIndex& rLSequencesPerIndex,
+                              com::sun::star::uno::Reference<
+                              com::sun::star::chart2::XDataSeries > xSeries );
+
+    virtual ~SchXMLPropertyMappingContext();
+
+    virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
+private:
+
+    com::sun::star::uno::Reference< com::sun::star::chart2::XChartDocument > mxChartDocument;
+    SchXMLImportHelper& mrImportHelper;
+    com::sun::star::uno::Reference< com::sun::star::chart2::XDataSeries > mxDataSeries;
+
+    tSchXMLLSequencesPerIndex& mrLSequencesPerIndex;
+
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list