[Libreoffice-commits] core.git: sc/source
Vikas
vikasmahato0 at gmail.com
Sun Jul 1 23:39:51 UTC 2018
sc/source/filter/xml/XMLExportDatabaseRanges.cxx | 140 +++++++++++------------
sc/source/filter/xml/XMLExportDatabaseRanges.hxx | 4
2 files changed, 73 insertions(+), 71 deletions(-)
New commits:
commit b30b4e9c7c492542e1ae726e2e45627ee33f7cd5
Author: Vikas <vikasmahato0 at gmail.com>
Date: Fri Jun 29 12:19:58 2018 +0530
Move writesort() method from WriteDatabaseRange to free function
Change-Id: I732a0693aae92c5e654d1f8f414b7d6bd38b0562
Reviewed-on: https://gerrit.libreoffice.org/56662
Tested-by: Jenkins
Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
diff --git a/sc/source/filter/xml/XMLExportDatabaseRanges.cxx b/sc/source/filter/xml/XMLExportDatabaseRanges.cxx
index a11a796a7e3d..187d63383723 100644
--- a/sc/source/filter/xml/XMLExportDatabaseRanges.cxx
+++ b/sc/source/filter/xml/XMLExportDatabaseRanges.cxx
@@ -52,6 +52,71 @@
using namespace com::sun::star;
using namespace xmloff::token;
+void writeSort(ScXMLExport& mrExport, const ScSortParam& aParam, const ScRange& aRange, const ScDocument* mpDoc)
+{
+ // Count sort items first.
+ size_t nSortCount = 0;
+ for (; nSortCount < aParam.GetSortKeyCount(); ++nSortCount)
+ {
+ if (!aParam.maKeyState[nSortCount].bDoSort)
+ break;
+ }
+
+ if (!nSortCount)
+ // Nothing to export.
+ return;
+
+ ScAddress aOutPos(aParam.nDestCol, aParam.nDestRow, aParam.nDestTab);
+
+ if (!aParam.bIncludePattern)
+ mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_BIND_STYLES_TO_CONTENT, XML_FALSE);
+
+ if (!aParam.bInplace)
+ {
+ OUString aStr;
+ ScRangeStringConverter::GetStringFromAddress(
+ aStr, aOutPos, mpDoc, ::formula::FormulaGrammar::CONV_OOO);
+ mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_TARGET_RANGE_ADDRESS, aStr);
+ }
+
+ if (aParam.bCaseSens)
+ mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_CASE_SENSITIVE, XML_TRUE);
+
+ mrExport.AddLanguageTagAttributes( XML_NAMESPACE_TABLE, XML_NAMESPACE_TABLE, aParam.aCollatorLocale, false);
+ if (!aParam.aCollatorAlgorithm.isEmpty())
+ mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ALGORITHM, aParam.aCollatorAlgorithm);
+
+ SvXMLElementExport aElemS(mrExport, XML_NAMESPACE_TABLE, XML_SORT, true, true);
+
+ SCCOLROW nFieldStart = aParam.bByRow ? aRange.aStart.Col() : aRange.aStart.Row();
+
+ for (size_t i = 0; i < nSortCount; ++i)
+ {
+ // Convert field value from absolute to relative.
+ SCCOLROW nField = aParam.maKeyState[i].nField - nFieldStart;
+ mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_FIELD_NUMBER, OUString::number(nField));
+
+ if (!aParam.maKeyState[i].bAscending)
+ mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ORDER, XML_DESCENDING);
+
+ if (aParam.bUserDef)
+ {
+ OUStringBuffer aBuf;
+ aBuf.append(SC_USERLIST);
+ aBuf.append(static_cast<sal_Int32>(aParam.nUserIndex));
+ mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATA_TYPE, aBuf.makeStringAndClear());
+ }
+ else
+ {
+ // Right now we only support automatic field type. In the
+ // future we may support numeric or alphanumeric field type.
+ mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATA_TYPE, XML_AUTOMATIC);
+ }
+
+ SvXMLElementExport aElemSb(mrExport, XML_NAMESPACE_TABLE, XML_SORT_BY, true, true);
+ }
+}
+
ScXMLExportDatabaseRanges::ScXMLExportDatabaseRanges(ScXMLExport& rTempExport)
: rExport(rTempExport),
pDoc( nullptr )
@@ -207,9 +272,12 @@ private:
SvXMLElementExport aElemDR(mrExport, XML_NAMESPACE_TABLE, XML_DATABASE_RANGE, true, true);
+ ScSortParam aParam;
+ rData.GetSortParam(aParam);
+
writeImport(rData);
writeFilter(rData);
- writeSort(rData);
+ writeSort(mrExport, aParam, aRange, mpDoc);
writeSubtotals(rData);
}
@@ -294,76 +362,6 @@ private:
}
}
- void writeSort(const ScDBData& rData)
- {
- ScSortParam aParam;
- rData.GetSortParam(aParam);
-
- // Count sort items first.
- size_t nSortCount = 0;
- for (; nSortCount < aParam.GetSortKeyCount(); ++nSortCount)
- {
- if (!aParam.maKeyState[nSortCount].bDoSort)
- break;
- }
-
- if (!nSortCount)
- // Nothing to export.
- return;
-
- ScAddress aOutPos(aParam.nDestCol, aParam.nDestRow, aParam.nDestTab);
-
- if (!aParam.bIncludePattern)
- mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_BIND_STYLES_TO_CONTENT, XML_FALSE);
-
- if (!aParam.bInplace)
- {
- OUString aStr;
- ScRangeStringConverter::GetStringFromAddress(
- aStr, aOutPos, mpDoc, ::formula::FormulaGrammar::CONV_OOO);
- mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_TARGET_RANGE_ADDRESS, aStr);
- }
-
- if (aParam.bCaseSens)
- mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_CASE_SENSITIVE, XML_TRUE);
-
- mrExport.AddLanguageTagAttributes( XML_NAMESPACE_TABLE, XML_NAMESPACE_TABLE, aParam.aCollatorLocale, false);
- if (!aParam.aCollatorAlgorithm.isEmpty())
- mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ALGORITHM, aParam.aCollatorAlgorithm);
-
- SvXMLElementExport aElemS(mrExport, XML_NAMESPACE_TABLE, XML_SORT, true, true);
-
- ScRange aRange;
- rData.GetArea(aRange);
- SCCOLROW nFieldStart = aParam.bByRow ? aRange.aStart.Col() : aRange.aStart.Row();
-
- for (size_t i = 0; i < nSortCount; ++i)
- {
- // Convert field value from absolute to relative.
- SCCOLROW nField = aParam.maKeyState[i].nField - nFieldStart;
- mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_FIELD_NUMBER, OUString::number(nField));
-
- if (!aParam.maKeyState[i].bAscending)
- mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ORDER, XML_DESCENDING);
-
- if (aParam.bUserDef)
- {
- OUStringBuffer aBuf;
- aBuf.append(SC_USERLIST);
- aBuf.append(static_cast<sal_Int32>(aParam.nUserIndex));
- mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATA_TYPE, aBuf.makeStringAndClear());
- }
- else
- {
- // Right now we only support automatic field type. In the
- // future we may support numeric or alphanumeric field type.
- mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATA_TYPE, XML_AUTOMATIC);
- }
-
- SvXMLElementExport aElemSb(mrExport, XML_NAMESPACE_TABLE, XML_SORT_BY, true, true);
- }
- }
-
static OUString getOperatorXML(const ScQueryEntry& rEntry, utl::SearchParam::SearchType eSearchType)
{
switch (rEntry.eOp)
diff --git a/sc/source/filter/xml/XMLExportDatabaseRanges.hxx b/sc/source/filter/xml/XMLExportDatabaseRanges.hxx
index 134bbe3be0db..7dda5de96f35 100644
--- a/sc/source/filter/xml/XMLExportDatabaseRanges.hxx
+++ b/sc/source/filter/xml/XMLExportDatabaseRanges.hxx
@@ -20,11 +20,15 @@
#ifndef INCLUDED_SC_SOURCE_FILTER_XML_XMLEXPORTDATABASERANGES_HXX
#define INCLUDED_SC_SOURCE_FILTER_XML_XMLEXPORTDATABASERANGES_HXX
+#include <sortparam.hxx>
+#include <address.hxx>
class ScXMLExport;
class ScDocument;
class ScMyEmptyDatabaseRangesContainer;
+void writeSort(ScXMLExport& mrExport, const ScSortParam& aParam, const ScRange& aRange, const ScDocument* mpDoc);
+
class ScXMLExportDatabaseRanges
{
ScXMLExport& rExport;
More information about the Libreoffice-commits
mailing list