summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/Library_xo.mk1
-rw-r--r--xmloff/source/chart/PropertyMaps.cxx6
-rw-r--r--xmloff/source/chart/SchXMLChartContext.cxx4
-rw-r--r--xmloff/source/chart/SchXMLDataTableContext.cxx87
-rw-r--r--xmloff/source/chart/SchXMLDataTableContext.hxx40
-rw-r--r--xmloff/source/chart/SchXMLExport.cxx38
-rw-r--r--xmloff/source/core/xmltoken.cxx11
-rw-r--r--xmloff/source/token/tokens.txt5
8 files changed, 184 insertions, 8 deletions
diff --git a/xmloff/Library_xo.mk b/xmloff/Library_xo.mk
index 50d268b470b1..2c59632c8537 100644
--- a/xmloff/Library_xo.mk
+++ b/xmloff/Library_xo.mk
@@ -74,6 +74,7 @@ $(eval $(call gb_Library_add_exception_objects,xo,\
xmloff/source/chart/SchXMLAxisContext \
xmloff/source/chart/SchXMLCalculationSettingsContext \
xmloff/source/chart/SchXMLChartContext \
+ xmloff/source/chart/SchXMLDataTableContext \
xmloff/source/chart/SchXMLEnumConverter \
xmloff/source/chart/SchXMLExport \
xmloff/source/chart/SchXMLImport \
diff --git a/xmloff/source/chart/PropertyMaps.cxx b/xmloff/source/chart/PropertyMaps.cxx
index e40ac207a284..09a580512199 100644
--- a/xmloff/source/chart/PropertyMaps.cxx
+++ b/xmloff/source/chart/PropertyMaps.cxx
@@ -130,6 +130,12 @@ const XMLPropertyMapEntry aXMLChartPropMap[] =
MAP_ENTRY_ODF_EXT( "LabelFillBackground", LO_EXT, XML_FILL_HATCH_SOLID, XML_TYPE_BOOL ),
MAP_ENTRY_ODF_EXT( "LabelFillHatchName", LO_EXT, XML_FILL_HATCH_NAME, XML_TYPE_STYLENAME),
+ // Data table
+ MAP_ENTRY_ODF_EXT( "HBorder", LO_EXT, XML_SHOW_HORIZONTAL_BORDER, XML_TYPE_BOOL ),
+ MAP_ENTRY_ODF_EXT( "VBorder", LO_EXT, XML_SHOW_VERTICAL_BORDER, XML_TYPE_BOOL ),
+ MAP_ENTRY_ODF_EXT( "Outline", LO_EXT, XML_SHOW_OUTLINE, XML_TYPE_BOOL ),
+ MAP_ENTRY_ODF_EXT( "Keys", LO_EXT, XML_SHOW_KEYS, XML_TYPE_BOOL ),
+
MAP_ENTRY( "ScaleText", CHART, XML_SCALE_TEXT, XML_TYPE_BOOL ),
// spline settings
diff --git a/xmloff/source/chart/SchXMLChartContext.cxx b/xmloff/source/chart/SchXMLChartContext.cxx
index 7d1a767e784f..d8be7470d013 100644
--- a/xmloff/source/chart/SchXMLChartContext.cxx
+++ b/xmloff/source/chart/SchXMLChartContext.cxx
@@ -20,6 +20,7 @@
#include "SchXMLChartContext.hxx"
#include <SchXMLImport.hxx>
#include "SchXMLLegendContext.hxx"
+#include "SchXMLDataTableContext.hxx"
#include "SchXMLPlotAreaContext.hxx"
#include "SchXMLParagraphContext.hxx"
#include "SchXMLTableContext.hxx"
@@ -1070,6 +1071,9 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > SchXMLChartContext::cr
case XML_ELEMENT(CHART, XML_LEGEND):
pContext = new SchXMLLegendContext( mrImportHelper, GetImport() );
break;
+ case XML_ELEMENT(LO_EXT, XML_DATA_TABLE):
+ pContext = new SchXMLDataTableContext(mrImportHelper, GetImport());
+ break;
case XML_ELEMENT(TABLE, XML_TABLE):
{
SchXMLTableContext * pTableContext =
diff --git a/xmloff/source/chart/SchXMLDataTableContext.cxx b/xmloff/source/chart/SchXMLDataTableContext.cxx
new file mode 100644
index 000000000000..4271221ed71f
--- /dev/null
+++ b/xmloff/source/chart/SchXMLDataTableContext.cxx
@@ -0,0 +1,87 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "SchXMLDataTableContext.hxx"
+
+#include <xmloff/xmlimp.hxx>
+#include <xmloff/xmlnamespace.hxx>
+#include <xmloff/namespacemap.hxx>
+#include <xmloff/xmluconv.hxx>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/chart/XChartDocument.hpp>
+#include <com/sun/star/chart2/XChartDocument.hpp>
+#include <com/sun/star/chart2/XDiagram.hpp>
+#include <com/sun/star/chart2/XDataTable.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+using namespace ::xmloff::token;
+using namespace css;
+
+SchXMLDataTableContext::SchXMLDataTableContext(SchXMLImportHelper& rImpHelper, SvXMLImport& rImport)
+ : SvXMLImportContext(rImport)
+ , mrImportHelper(rImpHelper)
+{
+}
+
+void SchXMLDataTableContext::startFastElement(
+ sal_Int32 /*nElement*/, const uno::Reference<xml::sax::XFastAttributeList>& xAttrList)
+{
+ printf("SchXMLDataTableContext::startFastElement\n");
+ auto xChartDocument = mrImportHelper.GetChartDocument();
+ if (!xChartDocument.is())
+ return;
+
+ uno::Reference<chart2::XChartDocument> xNewChartDocument(xChartDocument, uno::UNO_QUERY);
+ if (!xNewChartDocument.is())
+ return;
+
+ uno::Reference<chart2::XDiagram> xDiagram(xNewChartDocument->getFirstDiagram());
+ if (!xDiagram.is())
+ return;
+
+ uno::Reference<lang::XMultiServiceFactory> xFactory = comphelper::getProcessServiceFactory();
+ uno::Reference<chart2::XDataTable> xDataTable(
+ xFactory->createInstance("com.sun.star.chart2.DataTable"), uno::UNO_QUERY);
+ if (!xDataTable.is())
+ return;
+
+ xDiagram->setDataTable(xDataTable);
+
+ OUString sAutoStyleName;
+
+ for (auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList))
+ {
+ if (aIter.getToken() == XML_ELEMENT(CHART, XML_STYLE_NAME))
+ sAutoStyleName = aIter.toString();
+ else
+ XMLOFF_WARN_UNKNOWN("xmloff", aIter);
+ }
+
+ // set properties
+ uno::Reference<beans::XPropertySet> xPropertySet(xDataTable, uno::UNO_QUERY);
+
+ if (!sAutoStyleName.isEmpty() && xPropertySet.is())
+ {
+ mrImportHelper.FillAutoStyle(sAutoStyleName, xPropertySet);
+ }
+}
+
+SchXMLDataTableContext::~SchXMLDataTableContext() {}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmloff/source/chart/SchXMLDataTableContext.hxx b/xmloff/source/chart/SchXMLDataTableContext.hxx
new file mode 100644
index 000000000000..716f445ed61e
--- /dev/null
+++ b/xmloff/source/chart/SchXMLDataTableContext.hxx
@@ -0,0 +1,40 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#pragma once
+
+#include <com/sun/star/xml/sax/XAttributeList.hpp>
+
+#include <xmloff/SchXMLImportHelper.hxx>
+#include <xmloff/xmlictxt.hxx>
+
+class SchXMLDataTableContext : public SvXMLImportContext
+{
+public:
+ SchXMLDataTableContext(SchXMLImportHelper& rImpHelper, SvXMLImport& rImport);
+ virtual ~SchXMLDataTableContext() override;
+
+ virtual void SAL_CALL startFastElement(
+ sal_Int32 nElement,
+ const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList) override;
+
+private:
+ SchXMLImportHelper& mrImportHelper;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx
index 533fcb569c33..0ed2683944ec 100644
--- a/xmloff/source/chart/SchXMLExport.cxx
+++ b/xmloff/source/chart/SchXMLExport.cxx
@@ -1147,6 +1147,8 @@ void SchXMLExportHelper_Impl::parseDocument( Reference< chart::XChartDocument >
return;
}
+ const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion(mrExport.getSaneDefaultVersion());
+
mxExpPropMapper->setChartDoc(xNewDoc);
awt::Size aPageSize( getPageSize( xNewDoc ));
@@ -1232,8 +1234,6 @@ void SchXMLExportHelper_Impl::parseDocument( Reference< chart::XChartDocument >
if( bExportContent )
{
//export data provider in xlink:href attribute
- const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion(
- mrExport.getSaneDefaultVersion());
if (nCurrentODFVersion >= SvtSaveOptions::ODFSVER_012)
{
@@ -1407,9 +1407,6 @@ void SchXMLExportHelper_Impl::parseDocument( Reference< chart::XChartDocument >
Reference< beans::XPropertySet > xProp( rChartDoc->getLegend(), uno::UNO_QUERY );
if( xProp.is())
{
- const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion(
- mrExport.getSaneDefaultVersion());
-
// export legend anchor position
try
{
@@ -1496,6 +1493,37 @@ void SchXMLExportHelper_Impl::parseDocument( Reference< chart::XChartDocument >
aPropertyStates.clear();
}
+ // Data table
+ if (xNewDiagram.is() && nCurrentODFVersion & SvtSaveOptions::ODFSVER_EXTENDED)
+ {
+ auto xDataTable = xNewDiagram->getDataTable();
+
+ if (xDataTable.is())
+ {
+ // get property states for autostyles
+ if (mxExpPropMapper.is())
+ {
+ uno::Reference<beans::XPropertySet> xPropSet(xDataTable, uno::UNO_QUERY);
+ if (xPropSet.is())
+ aPropertyStates = mxExpPropMapper->Filter(mrExport, xPropSet);
+ }
+
+ if (bExportContent)
+ {
+ // add style name attribute
+ AddAutoStyleAttribute(aPropertyStates);
+ SvXMLElementExport aDataTableElement(mrExport, XML_NAMESPACE_LO_EXT, XML_DATA_TABLE, true, true);
+ }
+ else
+ {
+ CollectAutoStyle(std::move(aPropertyStates));
+ }
+ }
+
+ // remove property states for autostyles
+ aPropertyStates.clear();
+ }
+
// plot-area element
if( xDiagram.is())
exportPlotArea( xDiagram, xNewDiagram, aPageSize, bExportContent, bIncludeTable );
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index 71d10f72d338..30158b20660e 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -617,6 +617,7 @@ namespace xmloff::token {
TOKEN( "data-stream-source", XML_DATA_STREAM_SOURCE ),
TOKEN( "data-style", XML_DATA_STYLE ),
TOKEN( "data-style-name", XML_DATA_STYLE_NAME ),
+ TOKEN( "data-table", XML_DATA_TABLE ),
TOKEN( "data-type", XML_DATA_TYPE ),
TOKEN( "database-display", XML_DATABASE_DISPLAY ),
TOKEN( "database-name", XML_DATABASE_NAME ),
@@ -1760,12 +1761,16 @@ namespace xmloff::token {
TOKEN( "show-changes-by-datetime-second-datetime", XML_SHOW_CHANGES_BY_DATETIME_SECOND_DATETIME ),
TOKEN( "show-changes-by-ranges", XML_SHOW_CHANGES_BY_RANGES ),
TOKEN( "show-changes-by-ranges-list", XML_SHOW_CHANGES_BY_RANGES_LIST ),
+ TOKEN( "show-horizontal-border", XML_SHOW_HORIZONTAL_BORDER ),
+ TOKEN( "show-keys", XML_SHOW_KEYS ),
TOKEN( "show-logo", XML_SHOW_LOGO ),
TOKEN( "show-rejected-changes", XML_SHOW_REJECTED_CHANGES ),
TOKEN( "show-shape", XML_SHOW_SHAPE ),
TOKEN( "show-text", XML_SHOW_TEXT ),
TOKEN( "show-unit", XML_SHOW_UNIT ),
TOKEN( "show-value", XML_SHOW_VALUE ),
+ TOKEN( "show-vertical-border", XML_SHOW_VERTICAL_BORDER ),
+ TOKEN( "show-outline", XML_SHOW_OUTLINE ),
TOKEN( "shows", XML_SHOWS ),
TOKEN( "side-by-side", XML_SIDE_BY_SIDE ),
TOKEN( "silver", XML_SILVER ),
@@ -3428,9 +3433,9 @@ namespace xmloff::token {
TOKEN( "rfc-language-tag", XML_RFC_LANGUAGE_TAG ),
TOKEN( "rfc-language-tag-asian", XML_RFC_LANGUAGE_TAG_ASIAN ),
TOKEN( "rfc-language-tag-complex", XML_RFC_LANGUAGE_TAG_COMPLEX ),
- TOKEN( "data-table-show-horz-border", XML_DATA_TABLE_SHOW_HORZ_BORDER ),
- TOKEN( "data-table-show-vert-border", XML_DATA_TABLE_SHOW_VERT_BORDER ),
- TOKEN( "data-table-show-outline", XML_DATA_TABLE_SHOW_OUTLINE ),
+ TOKEN( "data-table-show-horz-border", XML_DATA_TABLE_SHOW_HORZ_BORDER ), // obsolete - use XML_SHOW_HORIZONTAL_BORDER
+ TOKEN( "data-table-show-vert-border", XML_DATA_TABLE_SHOW_VERT_BORDER ), // obsolete - use XML_SHOW_VERTICAL_BORDER
+ TOKEN( "data-table-show-outline", XML_DATA_TABLE_SHOW_OUTLINE ), // obsolete - use XML_SHOW_OUTLINE
TOKEN( "display-units", XML_CHART_DUNITS_DISPLAYUNITS ),
TOKEN( "display-units-built-in-unit", XML_CHART_DUNITS_BUILTINUNIT ),
TOKEN( "external-data", XML_EXTERNALDATA),
diff --git a/xmloff/source/token/tokens.txt b/xmloff/source/token/tokens.txt
index 0a3b256d2b99..918ab44981c4 100644
--- a/xmloff/source/token/tokens.txt
+++ b/xmloff/source/token/tokens.txt
@@ -522,6 +522,7 @@ data-range
data-stream-source
data-style
data-style-name
+data-table
data-type
database-display
database-name
@@ -1660,12 +1661,16 @@ show-changes-by-datetime-mode
show-changes-by-datetime-second-datetime
show-changes-by-ranges
show-changes-by-ranges-list
+show-horizontal-border
+show-keys
show-logo
show-rejected-changes
show-shape
show-text
show-unit
show-value
+show-vertical-border
+show-outline
shows
side-by-side
silver