summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-05-24 23:27:24 (GMT)
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-05-25 20:40:16 (GMT)
commit1171a1375825785c9da40fd4e043d445c562c4aa (patch)
treee01ab5091855e682e741d02699708218a8c738db
parent6540cc8ee0d4d2396e6b731ad71a241e8344531d (diff)
import new conditional format information
Change-Id: Iaa16792a74a3e33d3880cb9db41baf5613804387
-rw-r--r--sc/Library_sc.mk1
-rw-r--r--sc/inc/colorscale.hxx1
-rw-r--r--sc/source/core/data/colorscale.cxx11
-rw-r--r--sc/source/filter/xml/xmlcondformat.cxx390
-rw-r--r--sc/source/filter/xml/xmlcondformat.hxx185
-rw-r--r--sc/source/filter/xml/xmlexprt.cxx16
-rw-r--r--sc/source/filter/xml/xmlimprt.cxx152
-rw-r--r--sc/source/filter/xml/xmlimprt.hxx66
-rw-r--r--sc/source/filter/xml/xmltabi.cxx4
-rw-r--r--xmloff/source/core/xmlimp.cxx2
10 files changed, 819 insertions, 9 deletions
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index cbc337d..20a5eaf 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -254,6 +254,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
sc/source/filter/xml/xmlbodyi \
sc/source/filter/xml/xmlcelli \
sc/source/filter/xml/xmlcoli \
+ sc/source/filter/xml/xmlcondformat \
sc/source/filter/xml/xmlconti \
sc/source/filter/xml/xmlcvali \
sc/source/filter/xml/xmldpimp \
diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx
index 3187f84..562f981 100644
--- a/sc/inc/colorscale.hxx
+++ b/sc/inc/colorscale.hxx
@@ -71,6 +71,7 @@ public:
bool GetPercentile() const;
bool HasFormula() const;
const ScTokenArray* GetFormula() const;
+ rtl::OUString GetFormula( formula::FormulaGrammar::Grammar eGrammar ) const;
void SetMin(bool bMin);
void SetMax(bool bMax);
void SetPercent(bool bPercent);
diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx
index c5db859..62b16e2 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -88,6 +88,17 @@ const ScTokenArray* ScColorScaleEntry::GetFormula() const
return NULL;
}
+rtl::OUString ScColorScaleEntry::GetFormula( formula::FormulaGrammar::Grammar eGrammar ) const
+{
+ rtl::OUString aFormula;
+ if(mpCell)
+ {
+ mpCell->GetFormula(aFormula, eGrammar);
+ }
+
+ return aFormula;
+}
+
double ScColorScaleEntry::GetValue() const
{
if(mpCell)
diff --git a/sc/source/filter/xml/xmlcondformat.cxx b/sc/source/filter/xml/xmlcondformat.cxx
new file mode 100644
index 0000000..3e3d3c4
--- /dev/null
+++ b/sc/source/filter/xml/xmlcondformat.cxx
@@ -0,0 +1,390 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2012 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include "xmlcondformat.hxx"
+#include <xmloff/nmspmap.hxx>
+
+#include "colorscale.hxx"
+#include "document.hxx"
+#include <sax/tools/converter.hxx>
+#include "rangelst.hxx"
+#include "rangeutl.hxx"
+#include "docfunc.hxx"
+#include "markdata.hxx"
+#include "docpool.hxx"
+#include "scitems.hxx"
+#include "patattr.hxx"
+#include "svl/intitem.hxx"
+
+
+ScXMLConditionalFormatsContext::ScXMLConditionalFormatsContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName):
+ SvXMLImportContext( rImport, nPrfx, rLName )
+{
+}
+
+SvXMLImportContext* ScXMLConditionalFormatsContext::CreateChildContext( sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
+{
+ const SvXMLTokenMap& rTokenMap = GetScImport().GetCondFormatsTokenMap();
+ sal_uInt16 nToken = rTokenMap.Get(nPrefix, rLocalName);
+ SvXMLImportContext* pContext = NULL;
+ switch (nToken)
+ {
+ case XML_TOK_CONDFORMATS_CONDFORMAT:
+ pContext = new ScXMLConditionalFormatContext( GetScImport(), nPrefix, rLocalName, xAttrList );
+ break;
+ }
+
+ return pContext;
+}
+
+void ScXMLConditionalFormatsContext::EndElement()
+{
+}
+
+ScXMLConditionalFormatContext::ScXMLConditionalFormatContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList>& xAttrList):
+ SvXMLImportContext( rImport, nPrfx, rLName )
+{
+ rtl::OUString sRange;
+
+ sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
+ const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetCondFormatAttrMap();
+ for( sal_Int16 i=0; i < nAttrCount; ++i )
+ {
+ const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
+ rtl::OUString aLocalName;
+ sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
+ sAttrName, &aLocalName ));
+ const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
+
+ switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
+ {
+ case XML_TOK_CONDFORMAT_TARGET_RANGE:
+ sRange = sValue;
+ break;
+ default:
+ break;
+ }
+ }
+
+ ScRangeStringConverter::GetRangeListFromString(maRange, sRange, GetScImport().GetDocument(),
+ formula::FormulaGrammar::CONV_ODF);
+
+}
+
+SvXMLImportContext* ScXMLConditionalFormatContext::CreateChildContext( sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
+{
+ const SvXMLTokenMap& rTokenMap = GetScImport().GetCondFormatTokenMap();
+ sal_uInt16 nToken = rTokenMap.Get(nPrefix, rLocalName);
+ SvXMLImportContext* pContext = NULL;
+ switch (nToken)
+ {
+ case XML_TOK_CONDFORMAT_COLORSCALE:
+ pContext = new ScXMLColorScaleFormatContext( GetScImport(), nPrefix, rLocalName, maRange );
+ break;
+ case XML_TOK_CONDFORMAT_DATABAR:
+ pContext = new ScXMLDataBarFormatContext( GetScImport(), nPrefix, rLocalName, xAttrList, maRange );
+ break;
+ default:
+ break;
+ }
+
+ return pContext;
+}
+
+void ScXMLConditionalFormatContext::EndElement()
+{
+}
+
+ScXMLColorScaleFormatContext::ScXMLColorScaleFormatContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName, const ScRangeList& rRange):
+ SvXMLImportContext( rImport, nPrfx, rLName ),
+ pColorScaleFormat(NULL)
+{
+ pColorScaleFormat = new ScColorScaleFormat(GetScImport().GetDocument());
+ pColorScaleFormat->SetRange(rRange);
+}
+
+SvXMLImportContext* ScXMLColorScaleFormatContext::CreateChildContext( sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
+{
+ const SvXMLTokenMap& rTokenMap = GetScImport().GetColorScaleTokenMap();
+ sal_uInt16 nToken = rTokenMap.Get(nPrefix, rLocalName);
+ SvXMLImportContext* pContext = NULL;
+ switch (nToken)
+ {
+ case XML_TOK_COLORSCALE_COLORSCALEENTRY:
+ pContext = new ScXMLColorScaleFormatEntryContext( GetScImport(), nPrefix, rLocalName, xAttrList, pColorScaleFormat );
+ break;
+ default:
+ break;
+ }
+
+ return pContext;
+}
+
+void ScXMLColorScaleFormatContext::EndElement()
+{
+ ScDocument* pDoc = GetScImport().GetDocument();
+
+ sal_uLong nIndex = pDoc->AddColorFormat(pColorScaleFormat, GetScImport().GetTables().GetCurrentSheet());
+
+ ScPatternAttr aPattern( pDoc->GetPool() );
+ aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_COLORSCALE, nIndex ) );
+ ScMarkData aMarkData;
+ aMarkData.MarkFromRangeList(pColorScaleFormat->GetRange(), true);
+ pDoc->ApplySelectionPattern( aPattern , aMarkData);
+}
+
+ScXMLDataBarFormatContext::ScXMLDataBarFormatContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
+ const ScRangeList& rRange):
+ SvXMLImportContext( rImport, nPrfx, rLName ),
+ mpDataBarFormat(NULL),
+ mpFormatData(NULL)
+{
+ rtl::OUString sPositiveColor;
+ rtl::OUString sNegativeColor;
+ rtl::OUString sGradient;
+
+ sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
+ const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataBarAttrMap();
+ for( sal_Int16 i=0; i < nAttrCount; ++i )
+ {
+ const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
+ rtl::OUString aLocalName;
+ sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
+ sAttrName, &aLocalName ));
+ const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
+
+ switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
+ {
+ case XML_TOK_DATABAR_POSITIVE_COLOR:
+ sPositiveColor = sValue;
+ break;
+ case XML_TOK_DATABAR_GRADIENT:
+ sGradient = sValue;
+ break;
+ default:
+ break;
+ }
+ }
+
+ mpDataBarFormat = new ScDataBarFormat(rImport.GetDocument());
+ mpFormatData = new ScDataBarFormatData();
+ mpDataBarFormat->SetDataBarData(mpFormatData);
+ if(!sGradient.isEmpty())
+ {
+ bool bGradient = true;
+ sax::Converter::convertBool( bGradient, sGradient);
+ mpFormatData->mbGradient = bGradient;
+ }
+ if(!sPositiveColor.isEmpty())
+ {
+ sal_Int32 nColor = 0;
+ sax::Converter::convertColor( nColor, sPositiveColor );
+ mpFormatData->maPositiveColor = Color(nColor);
+ }
+ if(!sNegativeColor.isEmpty())
+ {
+ sal_Int32 nColor = 0;
+ sax::Converter::convertColor( nColor, sPositiveColor );
+ mpFormatData->mpNegativeColor.reset(new Color(nColor));
+ }
+
+ mpDataBarFormat->SetRange(rRange);
+}
+
+SvXMLImportContext* ScXMLDataBarFormatContext::CreateChildContext( sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
+{
+ const SvXMLTokenMap& rTokenMap = GetScImport().GetDataBarTokenMap();
+ sal_uInt16 nToken = rTokenMap.Get(nPrefix, rLocalName);
+ SvXMLImportContext* pContext = NULL;
+ switch (nToken)
+ {
+ case XML_TOK_DATABAR_DATABARENTRY:
+ pContext = new ScXMLDataBarFormatEntryContext( GetScImport(), nPrefix, rLocalName, xAttrList, mpFormatData );
+ break;
+ default:
+ break;
+ }
+
+ return pContext;
+}
+
+void ScXMLDataBarFormatContext::EndElement()
+{
+ ScDocument* pDoc = GetScImport().GetDocument();
+
+ sal_uLong nIndex = pDoc->AddColorFormat(mpDataBarFormat, GetScImport().GetTables().GetCurrentSheet());
+
+ ScPatternAttr aPattern( pDoc->GetPool() );
+ aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_COLORSCALE, nIndex ) );
+ ScMarkData aMarkData;
+ aMarkData.MarkFromRangeList(mpDataBarFormat->GetRange(), true);
+ pDoc->ApplySelectionPattern( aPattern , aMarkData);
+}
+
+namespace {
+
+void setColorEntryType(const rtl::OUString& rType, ScColorScaleEntry* pEntry)
+{
+ if(rType == "minimum")
+ pEntry->SetMin(true);
+ else if(rType == "maximum")
+ pEntry->SetMax(true);
+ else if(rType == "percentile")
+ pEntry->SetPercentile(true);
+ else if(rType == "percent")
+ pEntry->SetPercent(true);
+
+ //TODO: add formulas
+}
+
+}
+
+ScXMLColorScaleFormatEntryContext::ScXMLColorScaleFormatEntryContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
+ ScColorScaleFormat* pFormat):
+ SvXMLImportContext( rImport, nPrfx, rLName ),
+ mpFormat( pFormat ),
+ mpFormatEntry( NULL )
+{
+ double nVal = 0;
+ Color aColor;
+
+ rtl::OUString sType;
+ rtl::OUString sVal;
+ rtl::OUString sColor;
+
+ sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
+ const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetColorScaleEntryAttrMap();
+ for( sal_Int16 i=0; i < nAttrCount; ++i )
+ {
+ const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
+ rtl::OUString aLocalName;
+ sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
+ sAttrName, &aLocalName ));
+ const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
+
+ switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
+ {
+ case XML_TOK_COLORSCALEENTRY_TYPE:
+ sType = sValue;
+ break;
+ case XML_TOK_COLORSCALEENTRY_VALUE:
+ sVal = sValue;
+ break;
+ case XML_TOK_COLORSCALEENTRY_COLOR:
+ sColor = sValue;
+ break;
+ default:
+ break;
+ }
+ }
+
+ sal_Int32 nColor;
+ sax::Converter::convertColor(nColor, sColor);
+ aColor = Color(nColor);
+
+ //TODO: formulas
+ if(!sVal.isEmpty())
+ sax::Converter::convertDouble(nVal, sVal);
+
+ mpFormatEntry = new ScColorScaleEntry(nVal, aColor);
+ setColorEntryType(sType, mpFormatEntry);
+ pFormat->AddEntry(mpFormatEntry);
+}
+
+void ScXMLColorScaleFormatEntryContext::EndElement()
+{
+}
+
+ScXMLDataBarFormatEntryContext::ScXMLDataBarFormatEntryContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
+ ScDataBarFormatData* pData):
+ SvXMLImportContext( rImport, nPrfx, rLName )
+{
+ rtl::OUString sVal;
+ rtl::OUString sType;
+
+ sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
+ const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataBarEntryAttrMap();
+ for( sal_Int16 i=0; i < nAttrCount; ++i )
+ {
+ const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
+ rtl::OUString aLocalName;
+ sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
+ sAttrName, &aLocalName ));
+ const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
+
+ switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
+ {
+ case XML_TOK_DATABARENTRY_TYPE:
+ sType = sValue;
+ break;
+ case XML_TOK_DATABARENTRY_VALUE:
+ sVal = sValue;
+ break;
+ default:
+ break;
+ }
+ }
+
+ double nVal = 0;
+ if(!sVal.isEmpty())
+ sax::Converter::convertDouble(nVal, sVal);
+
+ ScColorScaleEntry* pEntry = new ScColorScaleEntry(nVal, Color());
+ setColorEntryType(sType, pEntry);
+ if(pData->mpLowerLimit)
+ {
+ pData->mpUpperLimit.reset(pEntry);
+ }
+ else
+ {
+ pData->mpLowerLimit.reset(pEntry);
+ }
+}
+
+void ScXMLDataBarFormatEntryContext::EndElement()
+{
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/xml/xmlcondformat.hxx b/sc/source/filter/xml/xmlcondformat.hxx
new file mode 100644
index 0000000..42e5d0a
--- /dev/null
+++ b/sc/source/filter/xml/xmlcondformat.hxx
@@ -0,0 +1,185 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2012 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <xmloff/xmlictxt.hxx>
+#include "xmlimprt.hxx"
+#include "rangelst.hxx"
+
+class ScColorScaleFormat;
+class ScColorScaleEntry;
+class ScDataBarFormat;
+struct ScDataBarFormatData;
+
+class ScXMLConditionalFormatsContext : public SvXMLImportContext
+{
+ const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
+ ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
+public:
+ ScXMLConditionalFormatsContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName );
+
+ virtual ~ScXMLConditionalFormatsContext() {}
+
+ virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
+
+ virtual void EndElement();
+};
+
+class ScXMLConditionalFormatContext : public SvXMLImportContext
+{
+ const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
+ ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
+public:
+ ScXMLConditionalFormatContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList);
+
+ virtual ~ScXMLConditionalFormatContext() {}
+
+ virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
+
+ virtual void EndElement();
+
+private:
+
+ ScRangeList maRange;
+};
+
+class ScXMLColorScaleFormatContext : public SvXMLImportContext
+{
+private:
+ const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
+ ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
+
+public:
+ ScXMLColorScaleFormatContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName, const ScRangeList& rRange);
+
+ virtual ~ScXMLColorScaleFormatContext() {}
+
+
+ virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
+
+ virtual void EndElement();
+
+private:
+
+ ScColorScaleFormat* pColorScaleFormat;
+};
+
+class ScXMLDataBarFormatContext : public SvXMLImportContext
+{
+ const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
+ ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
+public:
+ ScXMLDataBarFormatContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
+ const ScRangeList& rRange);
+
+ virtual ~ScXMLDataBarFormatContext() {}
+
+
+ virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
+
+ virtual void EndElement();
+
+private:
+
+ ScDataBarFormat* mpDataBarFormat;
+ ScDataBarFormatData* mpFormatData;
+
+};
+
+class ScXMLColorScaleFormatEntryContext : public SvXMLImportContext
+{
+ const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
+ ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
+public:
+ ScXMLColorScaleFormatEntryContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
+ ScColorScaleFormat* pFormat);
+
+ virtual ~ScXMLColorScaleFormatEntryContext() {}
+
+ virtual void EndElement();
+
+private:
+
+ ScColorScaleFormat* mpFormat;
+ ScColorScaleEntry* mpFormatEntry;
+};
+
+class ScXMLDataBarFormatEntryContext : public SvXMLImportContext
+{
+ const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
+ ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
+public:
+ ScXMLDataBarFormatEntryContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
+ ScDataBarFormatData* pData);
+
+ virtual ~ScXMLDataBarFormatEntryContext() {}
+
+ virtual void EndElement();
+};
+
+class ScXMLConditionContext : public SvXMLImportContext
+{
+ const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
+ ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
+public:
+ ScXMLConditionContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList);
+
+ virtual ~ScXMLConditionContext() {}
+
+ virtual void EndElement();
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 2379401..3aea14a 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -1169,7 +1169,7 @@ void ScXMLExport::WriteRowContent()
if (nCols > 1)
{
rtl::OUStringBuffer aBuf;
- ::sax::Converter::convertNumber(aBuf, nCols);
+ ::sax::Converter::convertNumber(aBuf, nCols);
AddAttribute(sAttrColumnsRepeated, aBuf.makeStringAndClear());
}
SvXMLElementExport aElemC(*this, sElemCell, true, true);
@@ -1193,7 +1193,7 @@ void ScXMLExport::WriteRowContent()
if (nCols > 1)
{
rtl::OUStringBuffer aBuf;
- ::sax::Converter::convertNumber(aBuf, nCols);
+ ::sax::Converter::convertNumber(aBuf, nCols);
AddAttribute(sAttrColumnsRepeated, aBuf.makeStringAndClear());
}
SvXMLElementExport aElemC(*this, sElemCell, true, true);
@@ -3865,9 +3865,9 @@ void ScXMLExport::ExportConditionalFormat(SCTAB nTab)
for(ScColorScaleFormat::const_iterator it = mrColorScale.begin();
it != mrColorScale.end(); ++it)
{
- if(it->GetFormula())
+ if(it->HasFormula())
{
- rtl::OUString sFormula;
+ rtl::OUString sFormula = it->GetFormula(formula::FormulaGrammar::GRAM_ODFF);
AddAttribute(XML_NAMESPACE_CALC_EXT, XML_VALUE, sFormula);
}
else
@@ -3891,9 +3891,9 @@ void ScXMLExport::ExportConditionalFormat(SCTAB nTab)
SvXMLElementExport aElementDataBar(*this, XML_NAMESPACE_CALC_EXT, XML_DATA_BAR, true, true);
{
- if(pFormatData->mpLowerLimit->GetFormula())
+ if(pFormatData->mpLowerLimit->HasFormula())
{
- rtl::OUString sFormula;
+ rtl::OUString sFormula = pFormatData->mpLowerLimit->GetFormula(formula::FormulaGrammar::GRAM_ODFF);
AddAttribute(XML_NAMESPACE_CALC_EXT, XML_VALUE, sFormula);
}
else
@@ -3903,9 +3903,9 @@ void ScXMLExport::ExportConditionalFormat(SCTAB nTab)
}
{
- if(pFormatData->mpUpperLimit->GetFormula())
+ if(pFormatData->mpUpperLimit->HasFormula())
{
- rtl::OUString sFormula;
+ rtl::OUString sFormula = pFormatData->mpUpperLimit->GetFormula(formula::FormulaGrammar::GRAM_ODFF);
AddAttribute(XML_NAMESPACE_CALC_EXT, XML_VALUE, sFormula);
}
else
diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx
index 673b1f2..f689fcb 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -597,6 +597,141 @@ const SvXMLTokenMap& ScXMLImport::GetContentValidationErrorMacroAttrTokenMap()
return *pContentValidationErrorMacroAttrTokenMap;
}
+const SvXMLTokenMap& ScXMLImport::GetCondFormatsTokenMap()
+{
+ if( !pCondFormatsTokenMap )
+ {
+ static SvXMLTokenMapEntry aCondFormatsElemTokenMap[] =
+ {
+ { XML_NAMESPACE_CALC_EXT, XML_CONDITIONAL_FORMAT, XML_TOK_CONDFORMATS_CONDFORMAT },
+ XML_TOKEN_MAP_END
+ };
+
+ pCondFormatsTokenMap = new SvXMLTokenMap( aCondFormatsElemTokenMap );
+ }
+
+ return *pCondFormatsTokenMap;
+}
+
+const SvXMLTokenMap& ScXMLImport::GetCondFormatTokenMap()
+{
+ if( !pCondFormatTokenMap )
+ {
+ static SvXMLTokenMapEntry aCondFormatElemTokenMap[] =
+ {
+ { XML_NAMESPACE_CALC_EXT, XML_COLOR_SCALE, XML_TOK_CONDFORMAT_COLORSCALE },
+ { XML_NAMESPACE_CALC_EXT, XML_DATA_BAR, XML_TOK_CONDFORMAT_DATABAR },
+ XML_TOKEN_MAP_END
+ };
+
+ pCondFormatTokenMap = new SvXMLTokenMap( aCondFormatElemTokenMap );
+ }
+
+ return *pCondFormatTokenMap;
+}
+
+const SvXMLTokenMap& ScXMLImport::GetCondFormatAttrMap()
+{
+ if( !pCondFormatAttrMap )
+ {
+ static SvXMLTokenMapEntry aCondFormatAttrTokenMap[] =
+ {
+ { XML_NAMESPACE_CALC_EXT, XML_TARGET_RANGE_ADDRESS, XML_TOK_CONDFORMAT_TARGET_RANGE },
+ XML_TOKEN_MAP_END
+ };
+
+ pCondFormatAttrMap = new SvXMLTokenMap( aCondFormatAttrTokenMap );
+ }
+
+ return *pCondFormatAttrMap;
+}
+
+const SvXMLTokenMap& ScXMLImport::GetColorScaleTokenMap()
+{
+ if( !pColorScaleTokenMap )
+ {
+ static SvXMLTokenMapEntry aColorScaleElemTokenMap[] =
+ {
+ { XML_NAMESPACE_CALC_EXT, XML_COLOR_SCALE_ENTRY, XML_TOK_COLORSCALE_COLORSCALEENTRY },
+ XML_TOKEN_MAP_END
+ };
+
+ pColorScaleTokenMap = new SvXMLTokenMap( aColorScaleElemTokenMap );
+ }
+
+ return *pColorScaleTokenMap;
+}
+
+const SvXMLTokenMap& ScXMLImport::GetColorScaleEntryAttrMap()
+{
+ if( !pColorScaleEntryAttrTokenMap )
+ {
+ static SvXMLTokenMapEntry aColorScaleAttrTokenMap[] =
+ {
+ { XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_TOK_COLORSCALEENTRY_TYPE },
+ { XML_NAMESPACE_CALC_EXT, XML_VALUE, XML_TOK_COLORSCALEENTRY_VALUE },
+ { XML_NAMESPACE_CALC_EXT, XML_COLOR, XML_TOK_COLORSCALEENTRY_COLOR },
+ XML_TOKEN_MAP_END
+ };
+
+ pColorScaleEntryAttrTokenMap = new SvXMLTokenMap( aColorScaleAttrTokenMap );
+ }
+
+ return *pColorScaleEntryAttrTokenMap;
+}
+
+const SvXMLTokenMap& ScXMLImport::GetDataBarTokenMap()
+{
+ if( !pDataBarTokenMap )
+ {
+ static SvXMLTokenMapEntry aDataBarElemTokenMap[] =
+ {
+ { XML_NAMESPACE_CALC_EXT, XML_DATA_BAR_ENTRY, XML_TOK_DATABAR_DATABARENTRY },
+ XML_TOKEN_MAP_END
+ };
+
+ pDataBarTokenMap = new SvXMLTokenMap( aDataBarElemTokenMap );
+ }
+
+ return *pDataBarTokenMap;
+}
+
+const SvXMLTokenMap& ScXMLImport::GetDataBarAttrMap()
+{
+ if( !pDataBarAttrMap )
+ {
+ static SvXMLTokenMapEntry aDataBarAttrTokenMap[] =
+ {
+ { XML_NAMESPACE_CALC_EXT, XML_POSITIVE_COLOR, XML_TOK_DATABAR_POSITIVE_COLOR },
+ //{ XML_NAMESPACE_CALC_EXT, XML_NEGATIVE_COLOR, XML_TOK_DATABAR_NEGATIVE_COLOR },
+ { XML_NAMESPACE_CALC_EXT, XML_GRADIENT, XML_TOK_DATABAR_GRADIENT },
+ //{ XML_NAMESPACE_CALC_EXT, XML_AXIS_POSITION, XML_TOK_DATABAR_AXISPOSITION },
+ XML_TOKEN_MAP_END
+ };
+
+ pDataBarAttrMap = new SvXMLTokenMap( aDataBarAttrTokenMap );
+ }
+
+ return *pDataBarAttrMap;
+}
+
+const SvXMLTokenMap& ScXMLImport::GetDataBarEntryAttrMap()
+{
+ if( !pDataBarEntryAttrMap )
+ {
+ static SvXMLTokenMapEntry aDataBarAttrEntryTokenMap[] =
+ {
+ { XML_NAMESPACE_CALC_EXT, XML_TYPE, XML_TOK_DATABARENTRY_TYPE },
+ { XML_NAMESPACE_CALC_EXT, XML_VALUE, XML_TOK_DATABARENTRY_VALUE },
+ XML_TOKEN_MAP_END
+ };
+
+ pDataBarEntryAttrMap = new SvXMLTokenMap( aDataBarAttrEntryTokenMap );
+ }
+
+ return *pDataBarEntryAttrMap;
+}
+
const SvXMLTokenMap& ScXMLImport::GetLabelRangesElemTokenMap()
{
if( !pLabelRangesElemTokenMap )
@@ -653,6 +788,7 @@ const SvXMLTokenMap& ScXMLImport::GetTableElemTokenMap()
{ XML_NAMESPACE_OFFICE, XML_FORMS, XML_TOK_TABLE_FORMS },
{ XML_NAMESPACE_OFFICE, XML_EVENT_LISTENERS, XML_TOK_TABLE_EVENT_LISTENERS },
{ XML_NAMESPACE_OFFICE_EXT, XML_EVENT_LISTENERS, XML_TOK_TABLE_EVENT_LISTENERS_EXT },
+ { XML_NAMESPACE_CALC_EXT, XML_CONDITIONAL_FORMATS, XML_TOK_TABLE_CONDFORMATS },
XML_TOKEN_MAP_END
};
@@ -1716,6 +1852,14 @@ ScXMLImport::ScXMLImport(
pContentValidationHelpMessageAttrTokenMap( 0 ),
pContentValidationErrorMessageAttrTokenMap( 0 ),
pContentValidationErrorMacroAttrTokenMap( 0 ),
+ pCondFormatsTokenMap( 0 ),
+ pCondFormatTokenMap( 0 ),
+ pCondFormatAttrMap( 0 ),
+ pColorScaleTokenMap( 0 ),
+ pColorScaleEntryAttrTokenMap( 0 ),
+ pDataBarTokenMap( 0 ),
+ pDataBarAttrMap( 0 ),
+ pDataBarEntryAttrMap( 0 ),
pLabelRangesElemTokenMap( 0 ),
pLabelRangeAttrTokenMap( 0 ),
pTableElemTokenMap( 0 ),
@@ -1843,6 +1987,14 @@ ScXMLImport::~ScXMLImport() throw()
delete pContentValidationHelpMessageAttrTokenMap;
delete pContentValidationErrorMessageAttrTokenMap;
delete pContentValidationErrorMacroAttrTokenMap;
+ delete pCondFormatsTokenMap;
+ delete pCondFormatTokenMap;
+ delete pCondFormatAttrMap;
+ delete pColorScaleTokenMap;
+ delete pColorScaleEntryAttrTokenMap;
+ delete pDataBarTokenMap;
+ delete pDataBarAttrMap;
+ delete pDataBarEntryAttrMap;
delete pLabelRangesElemTokenMap;
delete pLabelRangeAttrTokenMap;
delete pTableElemTokenMap;
diff --git a/sc/source/filter/xml/xmlimprt.hxx b/sc/source/filter/xml/xmlimprt.hxx
index 8df2f77..9743c69 100644
--- a/sc/source/filter/xml/xmlimprt.hxx
+++ b/sc/source/filter/xml/xmlimprt.hxx
@@ -151,6 +151,53 @@ enum ScXMLContentValidationErrorMacroAttrTokens
XML_TOK_ERROR_MACRO_ATTR_EXECUTE
};
+enum ScXMLCondFormatsTokens
+{
+ XML_TOK_CONDFORMATS_CONDFORMAT
+};
+
+enum ScXMLCondFormatTokens
+{
+ XML_TOK_CONDFORMAT_COLORSCALE,
+ XML_TOK_CONDFORMAT_DATABAR
+};
+
+enum ScXMLCondFormatAttrTokens
+{
+ XML_TOK_CONDFORMAT_TARGET_RANGE
+};
+
+enum ScXMLColorScaleFormatTokens
+{
+ XML_TOK_COLORSCALE_COLORSCALEENTRY
+};
+
+enum ScXMLColorScaleEntryAttrTokens
+{
+ XML_TOK_COLORSCALEENTRY_TYPE,
+ XML_TOK_COLORSCALEENTRY_VALUE,
+ XML_TOK_COLORSCALEENTRY_COLOR
+};
+
+enum ScXMLDataBarFormatTokens
+{
+ XML_TOK_DATABAR_DATABARENTRY
+};
+
+enum ScXMLDataBarAttrTokens
+{
+ XML_TOK_DATABAR_POSITIVE_COLOR,
+ XML_TOK_DATABAR_NEGATIVE_COLOR,
+ XML_TOK_DATABAR_GRADIENT,
+ XML_TOK_DATABAR_AXISPOSITION
+};
+
+enum ScXMLDataBarEntryAttrTokens
+{
+ XML_TOK_DATABARENTRY_TYPE,
+ XML_TOK_DATABARENTRY_VALUE
+};
+
enum ScXMLLabelRangesElemTokens
{
XML_TOK_LABEL_RANGE_ELEM
@@ -180,7 +227,8 @@ enum ScXMLTableTokens
XML_TOK_TABLE_SHAPES,
XML_TOK_TABLE_FORMS,
XML_TOK_TABLE_EVENT_LISTENERS,
- XML_TOK_TABLE_EVENT_LISTENERS_EXT
+ XML_TOK_TABLE_EVENT_LISTENERS_EXT,
+ XML_TOK_TABLE_CONDFORMATS
};
enum ScXMLTokenProtectionTokens
@@ -717,6 +765,14 @@ class ScXMLImport: public SvXMLImport
SvXMLTokenMap *pContentValidationHelpMessageAttrTokenMap;
SvXMLTokenMap *pContentValidationErrorMessageAttrTokenMap;
SvXMLTokenMap *pContentValidationErrorMacroAttrTokenMap;
+ SvXMLTokenMap *pCondFormatsTokenMap;
+ SvXMLTokenMap *pCondFormatTokenMap;
+ SvXMLTokenMap *pCondFormatAttrMap;
+ SvXMLTokenMap *pColorScaleTokenMap;
+ SvXMLTokenMap *pColorScaleEntryAttrTokenMap;
+ SvXMLTokenMap *pDataBarTokenMap;
+ SvXMLTokenMap *pDataBarAttrMap;
+ SvXMLTokenMap *pDataBarEntryAttrMap;
SvXMLTokenMap *pLabelRangesElemTokenMap;
SvXMLTokenMap *pLabelRangeAttrTokenMap;
SvXMLTokenMap *pTableElemTokenMap;
@@ -870,6 +926,14 @@ public:
const SvXMLTokenMap& GetContentValidationHelpMessageAttrTokenMap();
const SvXMLTokenMap& GetContentValidationErrorMessageAttrTokenMap();
const SvXMLTokenMap& GetContentValidationErrorMacroAttrTokenMap();
+ const SvXMLTokenMap& GetCondFormatsTokenMap();
+ const SvXMLTokenMap& GetCondFormatTokenMap();
+ const SvXMLTokenMap& GetCondFormatAttrMap();
+ const SvXMLTokenMap& GetColorScaleTokenMap();
+ const SvXMLTokenMap& GetColorScaleEntryAttrMap();
+ const SvXMLTokenMap& GetDataBarTokenMap();
+ const SvXMLTokenMap& GetDataBarAttrMap();
+ const SvXMLTokenMap& GetDataBarEntryAttrMap();
const SvXMLTokenMap& GetLabelRangesElemTokenMap();
const SvXMLTokenMap& GetLabelRangeAttrTokenMap();
const SvXMLTokenMap& GetTableElemTokenMap();
diff --git a/sc/source/filter/xml/xmltabi.cxx b/sc/source/filter/xml/xmltabi.cxx
index 7add17f..e973c90 100644
--- a/sc/source/filter/xml/xmltabi.cxx
+++ b/sc/source/filter/xml/xmltabi.cxx
@@ -48,6 +48,7 @@
#include "rangeutl.hxx"
#include "externalrefmgr.hxx"
#include "sheetdata.hxx"
+#include "xmlcondformat.hxx"
#include <xmloff/xmltkmap.hxx>
#include <xmloff/nmspmap.hxx>
@@ -356,6 +357,9 @@ SvXMLImportContext *ScXMLTableContext::CreateChildContext( sal_uInt16 nPrefix,
pContext = new XMLEventsImportContext( GetImport(), nPrefix, rLName, xSupplier );
}
break;
+ case XML_TOK_TABLE_CONDFORMATS:
+ pContext = new ScXMLConditionalFormatsContext( GetScImport(), nPrefix, rLName );
+ break;
default:
;
}
diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx
index 1c50276..d2567a7 100644
--- a/xmloff/source/core/xmlimp.cxx
+++ b/xmloff/source/core/xmlimp.cxx
@@ -323,6 +323,8 @@ void SvXMLImport::_InitCtor()
mpNamespaceMap->Add(
OUString( RTL_CONSTASCII_USTRINGPARAM( sXML_np__css3text ) ),
GetXMLToken(XML_N_CSS3TEXT), XML_NAMESPACE_CSS3TEXT );
+
+ mpNamespaceMap->Add( OUString("_calc_libo"), GetXMLToken(XML_N_CALC_EXT), XML_NAMESPACE_CALC_EXT);
}
msPackageProtocol = OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.Package:" ) );