diff options
author | Kohei Yoshida <kyoshida@novell.com> | 2011-05-13 21:55:11 -0400 |
---|---|---|
committer | Kohei Yoshida <kyoshida@novell.com> | 2011-05-13 22:54:10 -0400 |
commit | 5f43ea17a724aad3e3181d970d6f74057dbecc3b (patch) | |
tree | 1f66eb998aeb07bab18505e4930ab250fce6a1d8 | |
parent | 3cf690afecdc1d8dde3457efc17121af69688b5d (diff) |
Fixed incorrect exporting of global named database ranges.
-rw-r--r-- | sc/inc/dbcolect.hxx | 2 | ||||
-rw-r--r-- | sc/source/filter/xml/XMLExportDatabaseRanges.cxx | 38 | ||||
-rw-r--r-- | sc/source/filter/xml/xmldrani.cxx | 12 | ||||
-rw-r--r-- | sc/source/filter/xml/xmldrani.hxx | 6 |
4 files changed, 38 insertions, 20 deletions
diff --git a/sc/inc/dbcolect.hxx b/sc/inc/dbcolect.hxx index 280c59e77..bf2a0324c 100644 --- a/sc/inc/dbcolect.hxx +++ b/sc/inc/dbcolect.hxx @@ -161,6 +161,8 @@ public: class SC_DLLPUBLIC ScDBCollection { public: + enum RangeType { GlobalNamed, GlobalAnonymous, SheetAnonymous }; + /** * Stores global named database ranges. */ diff --git a/sc/source/filter/xml/XMLExportDatabaseRanges.cxx b/sc/source/filter/xml/XMLExportDatabaseRanges.cxx index 25fa489a7..b81f17979 100644 --- a/sc/source/filter/xml/XMLExportDatabaseRanges.cxx +++ b/sc/source/filter/xml/XMLExportDatabaseRanges.cxx @@ -576,12 +576,25 @@ namespace { class WriteDatabaseRange : public ::std::unary_function<ScDBData, void> { + ScXMLExport& mrExport; + ScDocument* mpDoc; + sal_Int32 mnCounter; + ScDBCollection::RangeType meRangeType; public: + WriteDatabaseRange(ScXMLExport& rExport, ScDocument* pDoc) : - mrExport(rExport), mpDoc(pDoc), mnCounter(0) {} + mrExport(rExport), mpDoc(pDoc), mnCounter(0), meRangeType(ScDBCollection::GlobalNamed) {} + + void setRangeType(ScDBCollection::RangeType eNew) + { + meRangeType = eNew; + } void operator() (const ::std::pair<SCTAB, const ScDBData*>& r) { + if (meRangeType != ScDBCollection::SheetAnonymous) + return; + // name OUStringBuffer aBuf; aBuf.appendAscii(STR_DB_LOCAL_NONAME); @@ -592,12 +605,17 @@ public: void operator() (const ScDBData& rData) { - // name - OUStringBuffer aBuf; - aBuf.appendAscii(STR_DB_GLOBAL_NONAME); - aBuf.append(++mnCounter); // 1-based, for entirely arbitrary reasons. The numbers are ignored on import. + if (meRangeType == ScDBCollection::GlobalAnonymous) + { + // name + OUStringBuffer aBuf; + aBuf.appendAscii(STR_DB_GLOBAL_NONAME); + aBuf.append(++mnCounter); // 1-based, for entirely arbitrary reasons. The numbers are ignored on import. - write(aBuf.makeStringAndClear(), rData); + write(aBuf.makeStringAndClear(), rData); + } + else if (meRangeType == ScDBCollection::GlobalNamed) + write(rData.GetName(), rData); } private: @@ -1075,11 +1093,6 @@ private: } } } - -private: - ScXMLExport& mrExport; - ScDocument* mpDoc; - sal_Int32 mnCounter; }; } @@ -1123,15 +1136,18 @@ void ScXMLExportDatabaseRanges::WriteDatabaseRanges() if (pDBCollection) { // Write global named ranges. + func.setRangeType(ScDBCollection::GlobalNamed); const ScDBCollection::NamedDBs& rNamedDBs = pDBCollection->getNamedDBs(); ::std::for_each(rNamedDBs.begin(), rNamedDBs.end(), func); // Add global anonymous DB ranges. + func.setRangeType(ScDBCollection::GlobalAnonymous); const ScDBCollection::AnonDBs& rAnonDBs = pDBCollection->getAnonDBs(); ::std::for_each(rAnonDBs.begin(), rAnonDBs.end(), func); } // Write sheet-local ranges. + func.setRangeType(ScDBCollection::SheetAnonymous); ::std::for_each(aSheetDBs.begin(), aSheetDBs.end(), func); } diff --git a/sc/source/filter/xml/xmldrani.cxx b/sc/source/filter/xml/xmldrani.cxx index b9cea6aad..bef1205b3 100644 --- a/sc/source/filter/xml/xmldrani.cxx +++ b/sc/source/filter/xml/xmldrani.cxx @@ -151,7 +151,7 @@ ScXMLDatabaseRangeContext::ScXMLDatabaseRangeContext( ScXMLImport& rImport, bFilterSkipDuplicates(false), bFilterUseRegularExpressions(false), bFilterConditionSourceRange(false), - meRangeType(GlobalNamed) + meRangeType(ScDBCollection::GlobalNamed) { nSourceType = sheet::DataImportMode_NONE; sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; @@ -223,9 +223,9 @@ ScXMLDatabaseRangeContext::ScXMLDatabaseRangeContext( ScXMLImport& rImport, } if (sDatabaseRangeName.matchAsciiL(STR_DB_LOCAL_NONAME, strlen(STR_DB_LOCAL_NONAME))) - meRangeType = SheetAnonymous; + meRangeType = ScDBCollection::SheetAnonymous; else if (sDatabaseRangeName.matchAsciiL(STR_DB_GLOBAL_NONAME, strlen(STR_DB_GLOBAL_NONAME))) - meRangeType = GlobalAnonymous; + meRangeType = ScDBCollection::GlobalAnonymous; } ScXMLDatabaseRangeContext::~ScXMLDatabaseRangeContext() @@ -476,7 +476,7 @@ void ScXMLDatabaseRangeContext::EndElement() if (!pDoc) return; - if (meRangeType == SheetAnonymous) + if (meRangeType == ScDBCollection::SheetAnonymous) { OUString aName(RTL_CONSTASCII_USTRINGPARAM(STR_DB_LOCAL_NONAME)); ::std::auto_ptr<ScDBData> pData(ConvertToDBData(aName)); @@ -491,7 +491,7 @@ void ScXMLDatabaseRangeContext::EndElement() } return; } - else if (meRangeType == GlobalAnonymous) + else if (meRangeType == ScDBCollection::GlobalAnonymous) { OUString aName(RTL_CONSTASCII_USTRINGPARAM(STR_DB_GLOBAL_NONAME)); ::std::auto_ptr<ScDBData> pData(ConvertToDBData(aName)); @@ -503,7 +503,7 @@ void ScXMLDatabaseRangeContext::EndElement() } return; } - else if (meRangeType == GlobalNamed) + else if (meRangeType == ScDBCollection::GlobalNamed) { ::std::auto_ptr<ScDBData> pData(ConvertToDBData(sDatabaseRangeName)); diff --git a/sc/source/filter/xml/xmldrani.hxx b/sc/source/filter/xml/xmldrani.hxx index 80b65247b..0f4d9c6cb 100644 --- a/sc/source/filter/xml/xmldrani.hxx +++ b/sc/source/filter/xml/xmldrani.hxx @@ -39,6 +39,8 @@ #include <com/sun/star/table/CellRangeAddress.hpp> #include <com/sun/star/table/TableOrientation.hpp> +#include "dbcolect.hxx" + class ScDBData; class ScXMLImport; @@ -72,8 +74,6 @@ struct ScSubTotalRule class ScXMLDatabaseRangeContext : public SvXMLImportContext { - enum RangeType { GlobalNamed, GlobalAnonymous, SheetAnonymous }; - rtl::OUString sDatabaseRangeName; rtl::OUString sConnectionRessource; rtl::OUString sRangeAddress; @@ -109,7 +109,7 @@ class ScXMLDatabaseRangeContext : public SvXMLImportContext sal_Bool bFilterSkipDuplicates; sal_Bool bFilterUseRegularExpressions; sal_Bool bFilterConditionSourceRange; - RangeType meRangeType; + ScDBCollection::RangeType meRangeType; const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } |