[Libreoffice-commits] core.git: sc/source
Kohei Yoshida
kohei.yoshida at collabora.com
Thu Dec 19 12:46:32 PST 2013
sc/source/filter/xml/datastreamimport.cxx | 92 ++++++++++++++++++++++++++++++
sc/source/filter/xml/datastreamimport.hxx | 39 ++++++++++++
2 files changed, 131 insertions(+)
New commits:
commit c7794f592500f43ca7b83535389de6b4fa717173
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Thu Dec 19 15:47:19 2013 -0500
I forgot to check in these files.
Change-Id: Ibb0d6c85ba6de2085ce699c1ef1a3b54f8ae66dc
diff --git a/sc/source/filter/xml/datastreamimport.cxx b/sc/source/filter/xml/datastreamimport.cxx
new file mode 100644
index 0000000..3c5f17d
--- /dev/null
+++ b/sc/source/filter/xml/datastreamimport.cxx
@@ -0,0 +1,92 @@
+/* -*- 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 "datastreamimport.hxx"
+#include "xmlimprt.hxx"
+
+#include <rangeutl.hxx>
+#include <importfilterdata.hxx>
+#include <xmloff/nmspmap.hxx>
+#include <xmloff/xmltoken.hxx>
+#include <formula/grammar.hxx>
+
+using namespace com::sun::star;
+using namespace xmloff::token;
+
+ScXMLDataStreamContext::ScXMLDataStreamContext(
+ ScXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName,
+ const com::sun::star::uno::Reference<
+ com::sun::star::xml::sax::XAttributeList>& xAttrList ) :
+ ScXMLImportContext(rImport, nPrefix, rLocalName),
+ mbRefreshOnEmpty(false),
+ meInsertPos(sc::ImportPostProcessData::DataStream::InsertBottom)
+{
+ if (!xAttrList.is())
+ return;
+
+ const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataStreamAttrTokenMap();
+
+ for (sal_Int32 i = 0; i < xAttrList->getLength(); ++i)
+ {
+ const OUString& rName = xAttrList->getNameByIndex(i);
+ OUString aLocalName;
+ sal_uInt16 nLocalPrefix =
+ GetScImport().GetNamespaceMap().GetKeyByAttrName(rName, &aLocalName);
+
+ const OUString& rVal = xAttrList->getValueByIndex(i);
+ switch (rAttrTokenMap.Get(nLocalPrefix, aLocalName))
+ {
+ case XML_TOK_DATA_STREAM_ATTR_URL:
+ maURL = GetScImport().GetAbsoluteReference(rVal);
+ break;
+ case XML_TOK_DATA_STREAM_ATTR_RANGE:
+ {
+ ScDocument* pDoc = GetScImport().GetDocument();
+ sal_Int32 nOffset = 0;
+ if (!ScRangeStringConverter::GetRangeFromString(
+ maRange, rVal, pDoc, formula::FormulaGrammar::CONV_OOO, nOffset))
+ maRange.SetInvalid();
+ }
+ break;
+ case XML_TOK_DATA_STREAM_ATTR_EMPTY_LINE_REFRESH:
+ mbRefreshOnEmpty = IsXMLToken(rVal, XML_TRUE);
+ break;
+ case XML_TOK_DATA_STREAM_ATTR_INSERTION_POSITION:
+ meInsertPos = IsXMLToken(rVal, XML_TOP) ?
+ sc::ImportPostProcessData::DataStream::InsertTop :
+ sc::ImportPostProcessData::DataStream::InsertBottom;
+ break;
+ default:
+ ;
+ }
+ }
+}
+
+ScXMLDataStreamContext::~ScXMLDataStreamContext() {}
+
+void ScXMLDataStreamContext::EndElement()
+{
+ if (!maRange.IsValid())
+ // Range must be valid.
+ return;
+
+ sc::ImportPostProcessData* pData = GetScImport().GetPostProcessData();
+ if (!pData)
+ return;
+
+ pData->mpDataStream.reset(new sc::ImportPostProcessData::DataStream);
+ sc::ImportPostProcessData::DataStream& rData = *pData->mpDataStream;
+
+ rData.maURL = maURL;
+ rData.maRange = maRange;
+ rData.mbRefreshOnEmpty = mbRefreshOnEmpty;
+ rData.meInsertPos = meInsertPos;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/xml/datastreamimport.hxx b/sc/source/filter/xml/datastreamimport.hxx
new file mode 100644
index 0000000..a1b675b
--- /dev/null
+++ b/sc/source/filter/xml/datastreamimport.hxx
@@ -0,0 +1,39 @@
+/* -*- 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 SC_XML_DATASTREAMIMPORT_HXX
+#define SC_XML_DATASTREAMIMPORT_HXX
+
+#include "importcontext.hxx"
+
+#include <importfilterdata.hxx>
+#include <address.hxx>
+
+class ScXMLDataStreamContext : public ScXMLImportContext
+{
+ OUString maURL;
+ ScRange maRange;
+ bool mbRefreshOnEmpty;
+ bool mbInsertBottom;
+ sc::ImportPostProcessData::DataStream::InsertPos meInsertPos;
+
+public:
+ ScXMLDataStreamContext(
+ ScXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName,
+ const com::sun::star::uno::Reference<
+ com::sun::star::xml::sax::XAttributeList>& xAttrList );
+
+ virtual ~ScXMLDataStreamContext();
+
+ virtual void EndElement();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list