diff options
author | Kohei Yoshida <kohei.yoshida@suse.com> | 2011-11-17 21:50:14 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@suse.com> | 2011-11-18 14:13:22 -0500 |
commit | 0960ec3e1b7b0d872d1f84d2d56f480a4df08b21 (patch) | |
tree | 379e2ad069f2262c1241c8885d4194d913a92cf8 /sc | |
parent | d540bdccf5fd2b44732ebbfcb70cf1e11faa5b83 (diff) |
Simplified & clarified the connection logic.
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/filter/xml/xmlfilti.cxx | 38 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlfilti.hxx | 10 |
2 files changed, 31 insertions, 17 deletions
diff --git a/sc/source/filter/xml/xmlfilti.cxx b/sc/source/filter/xml/xmlfilti.cxx index 90eb1f7434e7..5cc07d8e95bb 100644 --- a/sc/source/filter/xml/xmlfilti.cxx +++ b/sc/source/filter/xml/xmlfilti.cxx @@ -50,7 +50,7 @@ using namespace xmloff::token; using ::com::sun::star::uno::Reference; using ::com::sun::star::xml::sax::XAttributeList; -//------------------------------------------------------------------ +ScXMLFilterContext::ConnStackItem::ConnStackItem(bool bOr) : mbOr(bOr), mnCondCount(0) {} ScXMLFilterContext::ScXMLFilterContext( ScXMLImport& rImport, sal_uInt16 nPrfx, @@ -65,8 +65,6 @@ ScXMLFilterContext::ScXMLFilterContext( ScXMLImport& rImport, bSkipDuplicates(false), bCopyOutputData(false), bUseRegularExpressions(false), - bConnectionOr(true), - bNextConnectionOr(true), bConditionSourceRange(false) { ScDocument* pDoc(GetScImport().GetDocument()); @@ -184,25 +182,37 @@ void ScXMLFilterContext::SetUseRegularExpressions(bool b) void ScXMLFilterContext::OpenConnection(bool b) { - bool bTemp = bConnectionOr; - bConnectionOr = bNextConnectionOr; - bNextConnectionOr = b; - maOrConnectionStack.push_back(bTemp); + maConnStack.push_back(ConnStackItem(b)); } void ScXMLFilterContext::CloseConnection() { - bool bTemp = maOrConnectionStack.back(); - maOrConnectionStack.pop_back(); - bConnectionOr = bTemp; - bNextConnectionOr = bTemp; + maConnStack.pop_back(); } bool ScXMLFilterContext::GetConnection() { - bool bTemp = bConnectionOr; - bConnectionOr = bNextConnectionOr; - return bTemp; + // For condition items in each stack, the first one gets the connection of + // the last stack, while the rest of them get that of the current stack. + + if (maConnStack.empty()) + // This should never happen. + return true; + + ConnStackItem& rItem = maConnStack.back(); + if (rItem.mnCondCount) + // secondary item gets the current connection. + return rItem.mbOr; + + if (maConnStack.size() < 2) + // There is no last stack. Likely the first condition in the first + // stack whose connection is not used. + return true; + + ++rItem.mnCondCount; + std::vector<ConnStackItem>::reverse_iterator itr = maConnStack.rbegin(); + ++itr; + return itr->mbOr; // connection of the last stack. } void ScXMLFilterContext::AddFilterField(const sheet::TableFilterField2& aFilterField) diff --git a/sc/source/filter/xml/xmlfilti.hxx b/sc/source/filter/xml/xmlfilti.hxx index 51c5e434d6de..2d06af8b3ed6 100644 --- a/sc/source/filter/xml/xmlfilti.hxx +++ b/sc/source/filter/xml/xmlfilti.hxx @@ -48,6 +48,12 @@ struct ScQueryParam; class ScXMLFilterContext : public SvXMLImportContext { + struct ConnStackItem + { + bool mbOr; + int mnCondCount; + ConnStackItem(bool bOr); + }; ScQueryParam& mrQueryParam; ScXMLDatabaseRangeContext* pDatabaseRangeContext; @@ -59,10 +65,8 @@ class ScXMLFilterContext : public SvXMLImportContext bool bCopyOutputData; bool bUseRegularExpressions; bool bEnabledUserList; - bool bConnectionOr; - bool bNextConnectionOr; bool bConditionSourceRange; - std::vector<bool> maOrConnectionStack; + std::vector<ConnStackItem> maConnStack; const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } |