[Libreoffice-commits] .: 30 commits - sc/inc sc/source xmloff/inc xmloff/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Fri Nov 18 11:14:30 PST 2011
sc/inc/queryentry.hxx | 14
sc/inc/queryparam.hxx | 7
sc/source/core/data/table3.cxx | 16 -
sc/source/core/tool/queryparam.cxx | 89 ++++-
sc/source/filter/excel/excimp8.cxx | 283 ++++++++++--------
sc/source/filter/excel/read.cxx | 23 -
sc/source/filter/inc/excimp8.hxx | 25 -
sc/source/filter/xml/XMLExportDatabaseRanges.cxx | 57 +++
sc/source/filter/xml/xmldrani.cxx | 89 ++---
sc/source/filter/xml/xmldrani.hxx | 21 -
sc/source/filter/xml/xmlfilti.cxx | 348 +++++++++++++++--------
sc/source/filter/xml/xmlfilti.hxx | 93 ++++--
sc/source/filter/xml/xmlimprt.cxx | 36 ++
sc/source/filter/xml/xmlimprt.hxx | 14
sc/source/ui/cctrl/checklistmenu.cxx | 5
sc/source/ui/inc/checklistmenu.hxx | 1
sc/source/ui/inc/gridwin.hxx | 8
sc/source/ui/vba/vbarange.cxx | 23 -
sc/source/ui/view/gridwin.cxx | 119 +++++--
sc/source/ui/view/gridwin2.cxx | 4
sc/source/ui/view/tabview.cxx | 4
xmloff/inc/xmloff/xmltoken.hxx | 1
xmloff/source/core/xmltoken.cxx | 1
23 files changed, 804 insertions(+), 477 deletions(-)
New commits:
commit e046efdbb55329e97cddbd6fd7d6ec5c92bdf2c8
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Nov 18 14:11:38 2011 -0500
Removing the switch. Now we use the new autofilter popup for good.
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index ffb6f13..7793bad 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -42,10 +42,6 @@
#include <memory>
#include <boost/scoped_ptr.hpp>
-#define USE_NEW_AUTOFILTER 1
-
-// ---------------------------------------------------------------------------
-
struct ScTableInfo;
class ScViewSelectionEngine;
class ScDPObject;
@@ -343,10 +339,10 @@ public:
void LaunchDataSelectMenu( SCCOL nCol, SCROW nRow, bool bDataSelect );
void DoScenarioMenue( const ScRange& rScenRange );
-#if USE_NEW_AUTOFILTER
+
void LaunchAutoFilterMenu(SCCOL nCol, SCROW nRow);
void UpdateAutoFilterFromMenu();
-#endif
+
void LaunchPageFieldMenu( SCCOL nCol, SCROW nRow );
void LaunchDPFieldMenu( SCCOL nCol, SCROW nRow );
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index c69302f..6105ae3 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -586,7 +586,6 @@ void ScGridWindow::ExecPageFieldSelect( SCCOL nCol, SCROW nRow, sal_Bool bHasSel
}
}
-#if USE_NEW_AUTOFILTER
namespace {
class PopupAction : public ScMenuFloatingWindow::Action
@@ -760,7 +759,6 @@ void ScGridWindow::UpdateAutoFilterFromMenu()
pViewData->GetView()->Query(aParam, NULL, true);
pDBData->SetQueryParam(aParam);
}
-#endif
void ScGridWindow::LaunchPageFieldMenu( SCCOL nCol, SCROW nRow )
{
diff --git a/sc/source/ui/view/gridwin2.cxx b/sc/source/ui/view/gridwin2.cxx
index a3ecaae..2688e04 100644
--- a/sc/source/ui/view/gridwin2.cxx
+++ b/sc/source/ui/view/gridwin2.cxx
@@ -165,11 +165,7 @@ bool ScGridWindow::DoAutoFilterButton( SCCOL nCol, SCROW nRow, const MouseEvent&
HideCursor();
mpFilterButton->draw();
ShowCursor();
-#if USE_NEW_AUTOFILTER
LaunchAutoFilterMenu(nCol, nRow);
-#else
- LaunchDataSelectMenu(nCol, nRow, false);
-#endif
return true;
}
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index 6804c36..6e6863a 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -2403,14 +2403,10 @@ void ScTabView::StartDataSelect()
aViewData.GetDocument()->GetAttr(
nCol, nRow, aViewData.GetTabNo(), ATTR_MERGE_FLAG));
-#if USE_NEW_AUTOFILTER
if (pAttr->HasAutoFilter())
pWin->LaunchAutoFilterMenu(nCol, nRow);
else
pWin->LaunchDataSelectMenu(nCol, nRow, true);
-#else
- pWin->LaunchDataSelectMenu(nCol, nRow, !pAttr->HasAutoFilter());
-#endif
}
void ScTabView::EnableRefInput(bool bFlag)
commit bf034403ac8c98c9ebbe5ae59042502ab7c330d7
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Nov 18 14:02:51 2011 -0500
String to rtl::OUString.
diff --git a/sc/source/filter/excel/read.cxx b/sc/source/filter/excel/read.cxx
index d389402..d68fc51 100644
--- a/sc/source/filter/excel/read.cxx
+++ b/sc/source/filter/excel/read.cxx
@@ -835,8 +835,7 @@ FltError ImportExcel8::Read( void )
bool bSheetHasCodeName = false;
- std::vector< String > CodeNames;
-
+ std::vector<rtl::OUString> aCodeNames;
std::vector < SCTAB > nTabsWithNoCodeName;
while( eAkt != EXC_STATE_END )
@@ -1109,7 +1108,7 @@ FltError ImportExcel8::Read( void )
GetDoc().GetCodeName( GetCurrScTab(), sCodeName );
OSL_TRACE("Have CodeName %s for SheetName %s",
rtl::OUStringToOString( sCodeName, RTL_TEXTENCODING_UTF8 ).getStr(), rtl::OUStringToOString( sName, RTL_TEXTENCODING_UTF8 ).getStr() );
- CodeNames.push_back( sCodeName );
+ aCodeNames.push_back( sCodeName );
}
bSheetHasCodeName = false; // reset
@@ -1244,10 +1243,12 @@ FltError ImportExcel8::Read( void )
OSL_TRACE("Trying to find suitable codename for %d", *it );
while ( true )
{
- String sTmpName( RTL_CONSTASCII_USTRINGPARAM("Sheet" ) );
- sTmpName += String::CreateFromInt32( sal_Int32(nTab++) );
- std::vector< String >::iterator codeName_It = CodeNames.begin();
- std::vector< String >::iterator codeName_It_end = CodeNames.end();
+ rtl::OUStringBuffer aBuf;
+ aBuf.appendAscii("Sheet");
+ aBuf.append(static_cast<sal_Int32>(nTab++));
+ rtl::OUString sTmpName = aBuf.makeStringAndClear();
+ std::vector<rtl::OUString>::iterator codeName_It = aCodeNames.begin();
+ std::vector<rtl::OUString>::iterator codeName_It_end = aCodeNames.end();
// search for codename
for ( ; codeName_It != codeName_It_end; ++codeName_It )
{
@@ -1261,7 +1262,7 @@ FltError ImportExcel8::Read( void )
// Set new codename
GetDoc().SetCodeName( *it, sTmpName );
// Record newly used codename
- CodeNames.push_back( sTmpName );
+ aCodeNames.push_back(sTmpName);
// Record those we have created so they can be created in
// basic
maAutoGeneratedCodeNames.push_back( sTmpName );
commit e48ea72a2fb8099145a260e691461be3cc0323f5
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Nov 18 13:57:58 2011 -0500
A little cleanup.
diff --git a/sc/source/filter/excel/excimp8.cxx b/sc/source/filter/excel/excimp8.cxx
index 247af73..7101c48 100644
--- a/sc/source/filter/excel/excimp8.cxx
+++ b/sc/source/filter/excel/excimp8.cxx
@@ -292,13 +292,13 @@ void ImportExcel8::Scenman( void )
aIn.Ignore( 4 );
aIn >> nLastDispl;
- aScenList.nLastScenario = nLastDispl;
+ maScenList.nLastScenario = nLastDispl;
}
void ImportExcel8::Scenario( void )
{
- aScenList.aEntries.push_back( new ExcScenario( aIn, *pExcRoot ) );
+ maScenList.aEntries.push_back( new ExcScenario( aIn, *pExcRoot ) );
}
@@ -409,11 +409,11 @@ void ImportExcel8::PostDocLoad( void )
ImportExcel::PostDocLoad();
// Scenarien bemachen! ACHTUNG: Hier wird Tabellen-Anzahl im Dokument erhoeht!!
- if( !pD->IsClipboard() && aScenList.aEntries.size() )
+ if( !pD->IsClipboard() && maScenList.aEntries.size() )
{
pD->UpdateChartListenerCollection(); // references in charts must be updated
- aScenList.Apply( GetRoot() );
+ maScenList.Apply( GetRoot() );
}
// read doc info (no docshell while pasting from clipboard)
diff --git a/sc/source/filter/excel/read.cxx b/sc/source/filter/excel/read.cxx
index 8273c1c..d389402 100644
--- a/sc/source/filter/excel/read.cxx
+++ b/sc/source/filter/excel/read.cxx
@@ -1264,7 +1264,7 @@ FltError ImportExcel8::Read( void )
CodeNames.push_back( sTmpName );
// Record those we have created so they can be created in
// basic
- AutoGeneratedCodeNames.push_back( sTmpName );
+ maAutoGeneratedCodeNames.push_back( sTmpName );
break;
}
}
diff --git a/sc/source/filter/inc/excimp8.hxx b/sc/source/filter/inc/excimp8.hxx
index 81761c9..0e14fea 100644
--- a/sc/source/filter/inc/excimp8.hxx
+++ b/sc/source/filter/inc/excimp8.hxx
@@ -60,12 +60,6 @@ public:
virtual FltError Read( void );
-protected:
- // represents codename ( and associated modules )
- // not speficied directly in the binary format
- std::vector< String > AutoGeneratedCodeNames;
- ExcScenarioList aScenList;
-
void Calccount( void ); // 0x0C
void Precision( void ); // 0x0E
void Delta( void ); // 0x10
@@ -88,6 +82,12 @@ protected:
private:
void LoadDocumentProperties();
+
+private:
+ // represents codename ( and associated modules )
+ // not speficied directly in the binary format
+ std::vector<rtl::OUString> maAutoGeneratedCodeNames;
+ ExcScenarioList maScenList;
};
commit c4e782743b085731fe5ab03dcf0a431fed7bae61
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Nov 18 13:48:25 2011 -0500
Now we can import OR'ed conditions as single multi-item query.
But some restrictions do apply.
diff --git a/sc/source/filter/excel/excimp8.cxx b/sc/source/filter/excel/excimp8.cxx
index 7920e33..247af73 100644
--- a/sc/source/filter/excel/excimp8.cxx
+++ b/sc/source/filter/excel/excimp8.cxx
@@ -485,7 +485,6 @@ XclImpAutoFilterData::XclImpAutoFilterData( RootData* pRoot, const ScRange& rRan
ExcRoot( pRoot ),
pCurrDBData(NULL),
bActive( false ),
- bHasConflict( false ),
bCriteria( false ),
bAutoOrAdvanced(false)
{
@@ -518,7 +517,7 @@ void XclImpAutoFilterData::SetCellAttribs()
void XclImpAutoFilterData::InsertQueryParam()
{
- if( pCurrDBData && !bHasConflict )
+ if (pCurrDBData)
{
ScRange aAdvRange;
sal_Bool bHasAdv = pCurrDBData->GetAdvancedQuerySource( aAdvRange );
@@ -575,11 +574,13 @@ void XclImpAutoFilterData::ReadAutoFilter( XclImpStream& rStrm )
sal_uInt16 nCol, nFlags;
rStrm >> nCol >> nFlags;
- ScQueryConnect eConn = ::get_flagvalue( nFlags, EXC_AFFLAG_ANDORMASK, SC_OR, SC_AND );
- bool bTop10 = ::get_flag( nFlags, EXC_AFFLAG_TOP10 );
- bool bTopOfTop10 = ::get_flag( nFlags, EXC_AFFLAG_TOP10TOP );
- bool bPercent = ::get_flag( nFlags, EXC_AFFLAG_TOP10PERC );
- sal_uInt16 nCntOfTop10 = nFlags >> 7;
+ ScQueryConnect eConn = ::get_flagvalue( nFlags, EXC_AFFLAG_ANDORMASK, SC_OR, SC_AND );
+ bool bSimple1 = ::get_flag(nFlags, EXC_AFFLAG_SIMPLE1);
+ bool bSimple2 = ::get_flag(nFlags, EXC_AFFLAG_SIMPLE2);
+ bool bTop10 = ::get_flag(nFlags, EXC_AFFLAG_TOP10);
+ bool bTopOfTop10 = ::get_flag(nFlags, EXC_AFFLAG_TOP10TOP);
+ bool bPercent = ::get_flag(nFlags, EXC_AFFLAG_TOP10PERC);
+ sal_uInt16 nCntOfTop10 = nFlags >> 7;
if( bTop10 )
{
@@ -674,15 +675,7 @@ void XclImpAutoFilterData::ReadAutoFilter( XclImpStream& rStrm )
bIgnore = true;
}
- /* #i39464# conflict, if two conditions of one column are 'OR'ed,
- and they follow conditions of other columns.
- Example: Let A1 be a condition of column A, and B1 and B2
- conditions of column B, connected with OR. Excel performs
- 'A1 AND (B1 OR B2)' in this case, but Calc would do
- '(A1 AND B1) OR B2' instead. */
- if (nE && (eConn == SC_OR) && !bIgnore)
- bHasConflict = true;
- if( !bHasConflict && !bIgnore )
+ if (!bIgnore)
{
rEntry.bDoQuery = true;
rItem.meType = ScQueryEntry::ByString;
@@ -691,13 +684,54 @@ void XclImpAutoFilterData::ReadAutoFilter( XclImpStream& rStrm )
}
}
- for (size_t nE = 0; nE < 2; ++nE)
+ if (eConn == SC_AND)
{
- if (nStrLen[nE] && aEntries[nE].bDoQuery)
+ for (size_t nE = 0; nE < 2; ++nE)
+ {
+ if (nStrLen[nE] && aEntries[nE].bDoQuery)
+ {
+ aEntries[nE].GetQueryItem().maString = rStrm.ReadUniString(nStrLen[nE]);
+ ExcelQueryToOooQuery(aEntries[nE]);
+ aParam.AppendEntry() = aEntries[nE];
+ }
+ }
+ }
+ else
+ {
+ OSL_ASSERT(eConn == SC_OR);
+ // Import only when both conditions are for simple equality, else
+ // import only the 1st condition due to conflict with the ordering of
+ // conditions. #i39464#.
+ //
+ // Example: Let A1 be a condition of column A, and B1 and B2
+ // conditions of column B, connected with OR. Excel performs 'A1 AND
+ // (B1 OR B2)' in this case, but Calc would do '(A1 AND B1) OR B2'
+ // instead.
+
+ if (bSimple1 && bSimple2 && nStrLen[0] && nStrLen[1])
+ {
+ // Two simple OR'ed equal conditions. We can import this correctly.
+ ScQueryEntry& rEntry = aParam.AppendEntry();
+ rEntry.bDoQuery = true;
+ rEntry.eOp = SC_EQUAL;
+ rEntry.eConnect = SC_AND;
+ ScQueryEntry::QueryItemsType aItems;
+ aItems.reserve(2);
+ ScQueryEntry::Item aItem1, aItem2;
+ aItem1.maString = rStrm.ReadUniString(nStrLen[0]);
+ aItem1.meType = ScQueryEntry::ByString;
+ aItem2.maString = rStrm.ReadUniString(nStrLen[1]);
+ aItem2.meType = ScQueryEntry::ByString;
+ aItems.push_back(aItem1);
+ aItems.push_back(aItem2);
+ rEntry.GetQueryItems().swap(aItems);
+ }
+ else if (nStrLen[0] && aEntries[0].bDoQuery)
{
- aEntries[nE].GetQueryItem().maString = rStrm.ReadUniString(nStrLen[nE]);
- ExcelQueryToOooQuery(aEntries[nE]);
- aParam.AppendEntry() = aEntries[nE];
+ // Due to conflict, we can import only the first condition.
+ aEntries[0].GetQueryItem().maString = rStrm.ReadUniString(nStrLen[0]);
+ ExcelQueryToOooQuery(aEntries[0]);
+ aParam.AppendEntry() = aEntries[0];
}
}
}
diff --git a/sc/source/filter/inc/excimp8.hxx b/sc/source/filter/inc/excimp8.hxx
index 2bc75e0..81761c9 100644
--- a/sc/source/filter/inc/excimp8.hxx
+++ b/sc/source/filter/inc/excimp8.hxx
@@ -102,7 +102,6 @@ private:
ScQueryParam aParam;
ScRange aCriteriaRange;
bool bActive:1;
- bool bHasConflict:1;
bool bCriteria:1;
bool bAutoOrAdvanced:1;
commit 6437ca429386910c80ec24b86feb17eca78d2faa
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Nov 18 12:23:58 2011 -0500
sal_Bool to bool and other cleanup.
diff --git a/sc/source/filter/excel/excimp8.cxx b/sc/source/filter/excel/excimp8.cxx
index 2510752..7920e33 100644
--- a/sc/source/filter/excel/excimp8.cxx
+++ b/sc/source/filter/excel/excimp8.cxx
@@ -707,7 +707,7 @@ void XclImpAutoFilterData::SetAdvancedRange( const ScRange* pRange )
if (pRange)
{
aCriteriaRange = *pRange;
- bCriteria = sal_True;
+ bCriteria = true;
}
else
bCriteria = false;
diff --git a/sc/source/filter/inc/excimp8.hxx b/sc/source/filter/inc/excimp8.hxx
index 77aaffe..2bc75e0 100644
--- a/sc/source/filter/inc/excimp8.hxx
+++ b/sc/source/filter/inc/excimp8.hxx
@@ -100,16 +100,15 @@ class XclImpAutoFilterData : private ExcRoot
private:
ScDBData* pCurrDBData;
ScQueryParam aParam;
- sal_Bool bActive;
- sal_Bool bHasConflict;
- sal_Bool bCriteria;
- sal_Bool bAutoOrAdvanced;
ScRange aCriteriaRange;
+ bool bActive:1;
+ bool bHasConflict:1;
+ bool bCriteria:1;
+ bool bAutoOrAdvanced:1;
void CreateFromDouble( rtl::OUString& rStr, double fVal );
void SetCellAttribs();
void InsertQueryParam();
- void AmendAFName(const sal_Bool bUseUnNamed);
protected:
public:
@@ -127,10 +126,10 @@ public:
void ReadAutoFilter( XclImpStream& rStrm );
- inline void Activate() { bActive = sal_True; }
+ inline void Activate() { bActive = true; }
void SetAdvancedRange( const ScRange* pRange );
void SetExtractPos( const ScAddress& rAddr );
- inline void SetAutoOrAdvanced() { bAutoOrAdvanced = sal_True; }
+ inline void SetAutoOrAdvanced() { bAutoOrAdvanced = true; }
void Apply();
void CreateScDBData();
void EnableRemoveFilter();
commit 73ed12a50655b4053cfae7139507f1d4f5c2fb7e
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Nov 18 12:21:25 2011 -0500
We can now append query entry; no need to have this first empty member.
diff --git a/sc/source/filter/excel/excimp8.cxx b/sc/source/filter/excel/excimp8.cxx
index c3c4ee1..2510752 100644
--- a/sc/source/filter/excel/excimp8.cxx
+++ b/sc/source/filter/excel/excimp8.cxx
@@ -484,7 +484,6 @@ void ImportExcel8::AutoFilter( void )
XclImpAutoFilterData::XclImpAutoFilterData( RootData* pRoot, const ScRange& rRange ) :
ExcRoot( pRoot ),
pCurrDBData(NULL),
- nFirstEmpty( 0 ),
bActive( false ),
bHasConflict( false ),
bCriteria( false ),
@@ -581,26 +580,21 @@ void XclImpAutoFilterData::ReadAutoFilter( XclImpStream& rStrm )
bool bTopOfTop10 = ::get_flag( nFlags, EXC_AFFLAG_TOP10TOP );
bool bPercent = ::get_flag( nFlags, EXC_AFFLAG_TOP10PERC );
sal_uInt16 nCntOfTop10 = nFlags >> 7;
- SCSIZE nCount = aParam.GetEntryCount();
if( bTop10 )
{
- if( nFirstEmpty < nCount )
- {
- ScQueryEntry& aEntry = aParam.GetEntry( nFirstEmpty );
- ScQueryEntry::Item& rItem = aEntry.GetQueryItem();
- aEntry.bDoQuery = true;
- aEntry.nField = static_cast<SCCOLROW>(StartCol() + static_cast<SCCOL>(nCol));
- aEntry.eOp = bTopOfTop10 ?
- (bPercent ? SC_TOPPERC : SC_TOPVAL) : (bPercent ? SC_BOTPERC : SC_BOTVAL);
- aEntry.eConnect = SC_AND;
-
- rItem.meType = ScQueryEntry::ByString;
- rItem.maString = rtl::OUString::valueOf(static_cast<sal_Int32>(nCntOfTop10));
-
- rStrm.Ignore( 20 );
- nFirstEmpty++;
- }
+ ScQueryEntry& aEntry = aParam.AppendEntry();
+ ScQueryEntry::Item& rItem = aEntry.GetQueryItem();
+ aEntry.bDoQuery = true;
+ aEntry.nField = static_cast<SCCOLROW>(StartCol() + static_cast<SCCOL>(nCol));
+ aEntry.eOp = bTopOfTop10 ?
+ (bPercent ? SC_TOPPERC : SC_TOPVAL) : (bPercent ? SC_BOTPERC : SC_BOTVAL);
+ aEntry.eConnect = SC_AND;
+
+ rItem.meType = ScQueryEntry::ByString;
+ rItem.maString = rtl::OUString::valueOf(static_cast<sal_Int32>(nCntOfTop10));
+
+ rStrm.Ignore(20);
return;
}
@@ -614,93 +608,87 @@ void XclImpAutoFilterData::ReadAutoFilter( XclImpStream& rStrm )
for (size_t nE = 0; nE < 2; ++nE)
{
- if( nFirstEmpty < nCount )
- {
- ScQueryEntry& rEntry = aEntries[nE];
- ScQueryEntry::Item& rItem = rEntry.GetQueryItem();
- bIgnore = false;
+ ScQueryEntry& rEntry = aEntries[nE];
+ ScQueryEntry::Item& rItem = rEntry.GetQueryItem();
+ bIgnore = false;
- rStrm >> nType >> nOper;
- switch( nOper )
- {
- case EXC_AFOPER_LESS:
- rEntry.eOp = SC_LESS;
- break;
- case EXC_AFOPER_EQUAL:
- rEntry.eOp = SC_EQUAL;
- break;
- case EXC_AFOPER_LESSEQUAL:
- rEntry.eOp = SC_LESS_EQUAL;
- break;
- case EXC_AFOPER_GREATER:
- rEntry.eOp = SC_GREATER;
- break;
- case EXC_AFOPER_NOTEQUAL:
- rEntry.eOp = SC_NOT_EQUAL;
- break;
- case EXC_AFOPER_GREATEREQUAL:
- rEntry.eOp = SC_GREATER_EQUAL;
- break;
- default:
- rEntry.eOp = SC_EQUAL;
- }
+ rStrm >> nType >> nOper;
+ switch( nOper )
+ {
+ case EXC_AFOPER_LESS:
+ rEntry.eOp = SC_LESS;
+ break;
+ case EXC_AFOPER_EQUAL:
+ rEntry.eOp = SC_EQUAL;
+ break;
+ case EXC_AFOPER_LESSEQUAL:
+ rEntry.eOp = SC_LESS_EQUAL;
+ break;
+ case EXC_AFOPER_GREATER:
+ rEntry.eOp = SC_GREATER;
+ break;
+ case EXC_AFOPER_NOTEQUAL:
+ rEntry.eOp = SC_NOT_EQUAL;
+ break;
+ case EXC_AFOPER_GREATEREQUAL:
+ rEntry.eOp = SC_GREATER_EQUAL;
+ break;
+ default:
+ rEntry.eOp = SC_EQUAL;
+ }
- rtl::OUString aStr;
+ rtl::OUString aStr;
- switch( nType )
- {
- case EXC_AFTYPE_RK:
- rStrm >> nRK;
- rStrm.Ignore( 4 );
- CreateFromDouble(
- rItem.maString, XclTools::GetDoubleFromRK(nRK));
- break;
- case EXC_AFTYPE_DOUBLE:
- rStrm >> fVal;
- CreateFromDouble(rItem.maString, fVal);
- break;
- case EXC_AFTYPE_STRING:
- rStrm.Ignore( 4 );
- rStrm >> nStrLen[ nE ];
- rStrm.Ignore( 3 );
- rItem.maString = rtl::OUString();
- break;
- case EXC_AFTYPE_BOOLERR:
- rStrm >> nBoolErr >> nVal;
- rStrm.Ignore( 6 );
- rItem.maString = rtl::OUString::valueOf(static_cast<sal_Int32>(nVal));
- bIgnore = (nBoolErr != 0);
- break;
- case EXC_AFTYPE_EMPTY:
- rEntry.SetQueryByEmpty();
- break;
- case EXC_AFTYPE_NOTEMPTY:
- rEntry.SetQueryByNonEmpty();
- break;
- default:
- rStrm.Ignore( 8 );
- bIgnore = true;
- }
+ switch( nType )
+ {
+ case EXC_AFTYPE_RK:
+ rStrm >> nRK;
+ rStrm.Ignore( 4 );
+ CreateFromDouble(
+ rItem.maString, XclTools::GetDoubleFromRK(nRK));
+ break;
+ case EXC_AFTYPE_DOUBLE:
+ rStrm >> fVal;
+ CreateFromDouble(rItem.maString, fVal);
+ break;
+ case EXC_AFTYPE_STRING:
+ rStrm.Ignore( 4 );
+ rStrm >> nStrLen[ nE ];
+ rStrm.Ignore( 3 );
+ rItem.maString = rtl::OUString();
+ break;
+ case EXC_AFTYPE_BOOLERR:
+ rStrm >> nBoolErr >> nVal;
+ rStrm.Ignore( 6 );
+ rItem.maString = rtl::OUString::valueOf(static_cast<sal_Int32>(nVal));
+ bIgnore = (nBoolErr != 0);
+ break;
+ case EXC_AFTYPE_EMPTY:
+ rEntry.SetQueryByEmpty();
+ break;
+ case EXC_AFTYPE_NOTEMPTY:
+ rEntry.SetQueryByNonEmpty();
+ break;
+ default:
+ rStrm.Ignore( 8 );
+ bIgnore = true;
+ }
- /* #i39464# conflict, if two conditions of one column are 'OR'ed,
- and they follow conditions of other columns.
- Example: Let A1 be a condition of column A, and B1 and B2
- conditions of column B, connected with OR. Excel performs
- 'A1 AND (B1 OR B2)' in this case, but Calc would do
- '(A1 AND B1) OR B2' instead. */
- if( (nFirstEmpty > 1) && nE && (eConn == SC_OR) && !bIgnore )
- bHasConflict = true;
- if( !bHasConflict && !bIgnore )
- {
- rEntry.bDoQuery = true;
- rItem.meType = ScQueryEntry::ByString;
- rEntry.nField = static_cast<SCCOLROW>(StartCol() + static_cast<SCCOL>(nCol));
- rEntry.eConnect = nE ? eConn : SC_AND;
- nFirstEmpty++;
- }
+ /* #i39464# conflict, if two conditions of one column are 'OR'ed,
+ and they follow conditions of other columns.
+ Example: Let A1 be a condition of column A, and B1 and B2
+ conditions of column B, connected with OR. Excel performs
+ 'A1 AND (B1 OR B2)' in this case, but Calc would do
+ '(A1 AND B1) OR B2' instead. */
+ if (nE && (eConn == SC_OR) && !bIgnore)
+ bHasConflict = true;
+ if( !bHasConflict && !bIgnore )
+ {
+ rEntry.bDoQuery = true;
+ rItem.meType = ScQueryEntry::ByString;
+ rEntry.nField = static_cast<SCCOLROW>(StartCol() + static_cast<SCCOL>(nCol));
+ rEntry.eConnect = nE ? eConn : SC_AND;
}
- else
- rStrm.Ignore( 10 );
}
for (size_t nE = 0; nE < 2; ++nE)
@@ -788,9 +776,8 @@ void XclImpAutoFilterData::EnableRemoveFilter()
// only if this is a saved Advanced filter
if( !bActive && bAutoOrAdvanced )
{
- ScQueryEntry& aEntry = aParam.GetEntry( nFirstEmpty );
- aEntry.bDoQuery = sal_True;
- ++nFirstEmpty;
+ ScQueryEntry& aEntry = aParam.AppendEntry();
+ aEntry.bDoQuery = true;
}
// TBD: force the automatic activation of the
diff --git a/sc/source/filter/inc/excimp8.hxx b/sc/source/filter/inc/excimp8.hxx
index 6a9b36f..77aaffe 100644
--- a/sc/source/filter/inc/excimp8.hxx
+++ b/sc/source/filter/inc/excimp8.hxx
@@ -100,7 +100,6 @@ class XclImpAutoFilterData : private ExcRoot
private:
ScDBData* pCurrDBData;
ScQueryParam aParam;
- SCSIZE nFirstEmpty;
sal_Bool bActive;
sal_Bool bHasConflict;
sal_Bool bCriteria;
commit 88c456a0dccb05b300267da1bfaa4e53f8051e19
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Nov 18 12:17:43 2011 -0500
Parse the query data first, then committing the query entries later.
This gives us the change to examine the query data and do some
special-casing depending.
diff --git a/sc/inc/queryentry.hxx b/sc/inc/queryentry.hxx
index 19adf3f..835c84a 100644
--- a/sc/inc/queryentry.hxx
+++ b/sc/inc/queryentry.hxx
@@ -42,7 +42,7 @@ namespace utl {
/**
* Each instance of this struct represents a single filtering criteria.
*/
-struct ScQueryEntry
+struct SC_DLLPUBLIC ScQueryEntry
{
enum QueryType { ByValue, ByString, ByDate, ByEmpty };
@@ -73,12 +73,12 @@ struct ScQueryEntry
QueryItemsType& GetQueryItems();
const QueryItemsType& GetQueryItems() const;
- SC_DLLPUBLIC void SetQueryByEmpty();
- SC_DLLPUBLIC bool IsQueryByEmpty() const;
- SC_DLLPUBLIC void SetQueryByNonEmpty();
- SC_DLLPUBLIC bool IsQueryByNonEmpty() const;
- SC_DLLPUBLIC const Item& GetQueryItem() const;
- SC_DLLPUBLIC Item& GetQueryItem();
+ void SetQueryByEmpty();
+ bool IsQueryByEmpty() const;
+ void SetQueryByNonEmpty();
+ bool IsQueryByNonEmpty() const;
+ const Item& GetQueryItem() const;
+ Item& GetQueryItem();
void Clear();
ScQueryEntry& operator=( const ScQueryEntry& r );
bool operator==( const ScQueryEntry& r ) const;
diff --git a/sc/source/filter/excel/excimp8.cxx b/sc/source/filter/excel/excimp8.cxx
index 33747e7..c3c4ee1 100644
--- a/sc/source/filter/excel/excimp8.cxx
+++ b/sc/source/filter/excel/excimp8.cxx
@@ -604,46 +604,45 @@ void XclImpAutoFilterData::ReadAutoFilter( XclImpStream& rStrm )
return;
}
- sal_uInt8 nE, nType, nOper, nBoolErr, nVal;
+ sal_uInt8 nType, nOper, nBoolErr, nVal;
sal_Int32 nRK;
double fVal;
bool bIgnore;
- sal_uInt8 nStrLen[ 2 ] = { 0, 0 };
- ScQueryEntry *pQueryEntries[ 2 ] = { NULL, NULL };
+ sal_uInt8 nStrLen[2] = { 0, 0 };
+ ScQueryEntry aEntries[2];
- for( nE = 0; nE < 2; nE++ )
+ for (size_t nE = 0; nE < 2; ++nE)
{
if( nFirstEmpty < nCount )
{
- ScQueryEntry& aEntry = aParam.GetEntry( nFirstEmpty );
- ScQueryEntry::Item& rItem = aEntry.GetQueryItem();
- pQueryEntries[ nE ] = &aEntry;
+ ScQueryEntry& rEntry = aEntries[nE];
+ ScQueryEntry::Item& rItem = rEntry.GetQueryItem();
bIgnore = false;
rStrm >> nType >> nOper;
switch( nOper )
{
case EXC_AFOPER_LESS:
- aEntry.eOp = SC_LESS;
+ rEntry.eOp = SC_LESS;
break;
case EXC_AFOPER_EQUAL:
- aEntry.eOp = SC_EQUAL;
+ rEntry.eOp = SC_EQUAL;
break;
case EXC_AFOPER_LESSEQUAL:
- aEntry.eOp = SC_LESS_EQUAL;
+ rEntry.eOp = SC_LESS_EQUAL;
break;
case EXC_AFOPER_GREATER:
- aEntry.eOp = SC_GREATER;
+ rEntry.eOp = SC_GREATER;
break;
case EXC_AFOPER_NOTEQUAL:
- aEntry.eOp = SC_NOT_EQUAL;
+ rEntry.eOp = SC_NOT_EQUAL;
break;
case EXC_AFOPER_GREATEREQUAL:
- aEntry.eOp = SC_GREATER_EQUAL;
+ rEntry.eOp = SC_GREATER_EQUAL;
break;
default:
- aEntry.eOp = SC_EQUAL;
+ rEntry.eOp = SC_EQUAL;
}
rtl::OUString aStr;
@@ -673,10 +672,10 @@ void XclImpAutoFilterData::ReadAutoFilter( XclImpStream& rStrm )
bIgnore = (nBoolErr != 0);
break;
case EXC_AFTYPE_EMPTY:
- aEntry.SetQueryByEmpty();
+ rEntry.SetQueryByEmpty();
break;
case EXC_AFTYPE_NOTEMPTY:
- aEntry.SetQueryByNonEmpty();
+ rEntry.SetQueryByNonEmpty();
break;
default:
rStrm.Ignore( 8 );
@@ -693,10 +692,10 @@ void XclImpAutoFilterData::ReadAutoFilter( XclImpStream& rStrm )
bHasConflict = true;
if( !bHasConflict && !bIgnore )
{
- aEntry.bDoQuery = true;
+ rEntry.bDoQuery = true;
rItem.meType = ScQueryEntry::ByString;
- aEntry.nField = static_cast<SCCOLROW>(StartCol() + static_cast<SCCOL>(nCol));
- aEntry.eConnect = nE ? eConn : SC_AND;
+ rEntry.nField = static_cast<SCCOLROW>(StartCol() + static_cast<SCCOL>(nCol));
+ rEntry.eConnect = nE ? eConn : SC_AND;
nFirstEmpty++;
}
}
@@ -704,12 +703,15 @@ void XclImpAutoFilterData::ReadAutoFilter( XclImpStream& rStrm )
rStrm.Ignore( 10 );
}
- for( nE = 0; nE < 2; nE++ )
- if( nStrLen[ nE ] && pQueryEntries[ nE ] )
+ for (size_t nE = 0; nE < 2; ++nE)
+ {
+ if (nStrLen[nE] && aEntries[nE].bDoQuery)
{
- pQueryEntries[nE]->GetQueryItem().maString = rStrm.ReadUniString(nStrLen[nE]);
- ExcelQueryToOooQuery( *pQueryEntries[ nE ] );
+ aEntries[nE].GetQueryItem().maString = rStrm.ReadUniString(nStrLen[nE]);
+ ExcelQueryToOooQuery(aEntries[nE]);
+ aParam.AppendEntry() = aEntries[nE];
}
+ }
}
void XclImpAutoFilterData::SetAdvancedRange( const ScRange* pRange )
commit f3083a10f31f254058b7c847b27fd2adc4030b78
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Nov 18 12:05:16 2011 -0500
Reduce indentation level by early bail out.
diff --git a/sc/source/filter/excel/excimp8.cxx b/sc/source/filter/excel/excimp8.cxx
index f4b3320..33747e7 100644
--- a/sc/source/filter/excel/excimp8.cxx
+++ b/sc/source/filter/excel/excimp8.cxx
@@ -601,117 +601,115 @@ void XclImpAutoFilterData::ReadAutoFilter( XclImpStream& rStrm )
rStrm.Ignore( 20 );
nFirstEmpty++;
}
+ return;
}
- else
- {
- sal_uInt8 nE, nType, nOper, nBoolErr, nVal;
- sal_Int32 nRK;
- double fVal;
- bool bIgnore;
- sal_uInt8 nStrLen[ 2 ] = { 0, 0 };
- ScQueryEntry *pQueryEntries[ 2 ] = { NULL, NULL };
+ sal_uInt8 nE, nType, nOper, nBoolErr, nVal;
+ sal_Int32 nRK;
+ double fVal;
+ bool bIgnore;
- for( nE = 0; nE < 2; nE++ )
- {
- if( nFirstEmpty < nCount )
- {
- ScQueryEntry& aEntry = aParam.GetEntry( nFirstEmpty );
- ScQueryEntry::Item& rItem = aEntry.GetQueryItem();
- pQueryEntries[ nE ] = &aEntry;
- bIgnore = false;
+ sal_uInt8 nStrLen[ 2 ] = { 0, 0 };
+ ScQueryEntry *pQueryEntries[ 2 ] = { NULL, NULL };
- rStrm >> nType >> nOper;
- switch( nOper )
- {
- case EXC_AFOPER_LESS:
- aEntry.eOp = SC_LESS;
- break;
- case EXC_AFOPER_EQUAL:
- aEntry.eOp = SC_EQUAL;
- break;
- case EXC_AFOPER_LESSEQUAL:
- aEntry.eOp = SC_LESS_EQUAL;
- break;
- case EXC_AFOPER_GREATER:
- aEntry.eOp = SC_GREATER;
- break;
- case EXC_AFOPER_NOTEQUAL:
- aEntry.eOp = SC_NOT_EQUAL;
- break;
- case EXC_AFOPER_GREATEREQUAL:
- aEntry.eOp = SC_GREATER_EQUAL;
- break;
- default:
- aEntry.eOp = SC_EQUAL;
- }
+ for( nE = 0; nE < 2; nE++ )
+ {
+ if( nFirstEmpty < nCount )
+ {
+ ScQueryEntry& aEntry = aParam.GetEntry( nFirstEmpty );
+ ScQueryEntry::Item& rItem = aEntry.GetQueryItem();
+ pQueryEntries[ nE ] = &aEntry;
+ bIgnore = false;
- rtl::OUString aStr;
+ rStrm >> nType >> nOper;
+ switch( nOper )
+ {
+ case EXC_AFOPER_LESS:
+ aEntry.eOp = SC_LESS;
+ break;
+ case EXC_AFOPER_EQUAL:
+ aEntry.eOp = SC_EQUAL;
+ break;
+ case EXC_AFOPER_LESSEQUAL:
+ aEntry.eOp = SC_LESS_EQUAL;
+ break;
+ case EXC_AFOPER_GREATER:
+ aEntry.eOp = SC_GREATER;
+ break;
+ case EXC_AFOPER_NOTEQUAL:
+ aEntry.eOp = SC_NOT_EQUAL;
+ break;
+ case EXC_AFOPER_GREATEREQUAL:
+ aEntry.eOp = SC_GREATER_EQUAL;
+ break;
+ default:
+ aEntry.eOp = SC_EQUAL;
+ }
- switch( nType )
- {
- case EXC_AFTYPE_RK:
- rStrm >> nRK;
- rStrm.Ignore( 4 );
- CreateFromDouble(
- rItem.maString, XclTools::GetDoubleFromRK(nRK));
- break;
- case EXC_AFTYPE_DOUBLE:
- rStrm >> fVal;
- CreateFromDouble(rItem.maString, fVal);
- break;
- case EXC_AFTYPE_STRING:
- rStrm.Ignore( 4 );
- rStrm >> nStrLen[ nE ];
- rStrm.Ignore( 3 );
- rItem.maString = rtl::OUString();
- break;
- case EXC_AFTYPE_BOOLERR:
- rStrm >> nBoolErr >> nVal;
- rStrm.Ignore( 6 );
- rItem.maString = rtl::OUString::valueOf(static_cast<sal_Int32>(nVal));
- bIgnore = (nBoolErr != 0);
- break;
- case EXC_AFTYPE_EMPTY:
- aEntry.SetQueryByEmpty();
- break;
- case EXC_AFTYPE_NOTEMPTY:
- aEntry.SetQueryByNonEmpty();
- break;
- default:
- rStrm.Ignore( 8 );
- bIgnore = true;
- }
+ rtl::OUString aStr;
- /* #i39464# conflict, if two conditions of one column are 'OR'ed,
- and they follow conditions of other columns.
- Example: Let A1 be a condition of column A, and B1 and B2
- conditions of column B, connected with OR. Excel performs
- 'A1 AND (B1 OR B2)' in this case, but Calc would do
- '(A1 AND B1) OR B2' instead. */
- if( (nFirstEmpty > 1) && nE && (eConn == SC_OR) && !bIgnore )
- bHasConflict = true;
- if( !bHasConflict && !bIgnore )
- {
- aEntry.bDoQuery = true;
- rItem.meType = ScQueryEntry::ByString;
- aEntry.nField = static_cast<SCCOLROW>(StartCol() + static_cast<SCCOL>(nCol));
- aEntry.eConnect = nE ? eConn : SC_AND;
- nFirstEmpty++;
- }
+ switch( nType )
+ {
+ case EXC_AFTYPE_RK:
+ rStrm >> nRK;
+ rStrm.Ignore( 4 );
+ CreateFromDouble(
+ rItem.maString, XclTools::GetDoubleFromRK(nRK));
+ break;
+ case EXC_AFTYPE_DOUBLE:
+ rStrm >> fVal;
+ CreateFromDouble(rItem.maString, fVal);
+ break;
+ case EXC_AFTYPE_STRING:
+ rStrm.Ignore( 4 );
+ rStrm >> nStrLen[ nE ];
+ rStrm.Ignore( 3 );
+ rItem.maString = rtl::OUString();
+ break;
+ case EXC_AFTYPE_BOOLERR:
+ rStrm >> nBoolErr >> nVal;
+ rStrm.Ignore( 6 );
+ rItem.maString = rtl::OUString::valueOf(static_cast<sal_Int32>(nVal));
+ bIgnore = (nBoolErr != 0);
+ break;
+ case EXC_AFTYPE_EMPTY:
+ aEntry.SetQueryByEmpty();
+ break;
+ case EXC_AFTYPE_NOTEMPTY:
+ aEntry.SetQueryByNonEmpty();
+ break;
+ default:
+ rStrm.Ignore( 8 );
+ bIgnore = true;
}
- else
- rStrm.Ignore( 10 );
- }
- for( nE = 0; nE < 2; nE++ )
- if( nStrLen[ nE ] && pQueryEntries[ nE ] )
+ /* #i39464# conflict, if two conditions of one column are 'OR'ed,
+ and they follow conditions of other columns.
+ Example: Let A1 be a condition of column A, and B1 and B2
+ conditions of column B, connected with OR. Excel performs
+ 'A1 AND (B1 OR B2)' in this case, but Calc would do
+ '(A1 AND B1) OR B2' instead. */
+ if( (nFirstEmpty > 1) && nE && (eConn == SC_OR) && !bIgnore )
+ bHasConflict = true;
+ if( !bHasConflict && !bIgnore )
{
- pQueryEntries[nE]->GetQueryItem().maString = rStrm.ReadUniString(nStrLen[nE]);
- ExcelQueryToOooQuery( *pQueryEntries[ nE ] );
+ aEntry.bDoQuery = true;
+ rItem.meType = ScQueryEntry::ByString;
+ aEntry.nField = static_cast<SCCOLROW>(StartCol() + static_cast<SCCOL>(nCol));
+ aEntry.eConnect = nE ? eConn : SC_AND;
+ nFirstEmpty++;
}
-
+ }
+ else
+ rStrm.Ignore( 10 );
}
+
+ for( nE = 0; nE < 2; nE++ )
+ if( nStrLen[ nE ] && pQueryEntries[ nE ] )
+ {
+ pQueryEntries[nE]->GetQueryItem().maString = rStrm.ReadUniString(nStrLen[nE]);
+ ExcelQueryToOooQuery( *pQueryEntries[ nE ] );
+ }
}
void XclImpAutoFilterData::SetAdvancedRange( const ScRange* pRange )
commit 1e428385d20552a9977c9ab4ca0ef068e3fcdf7c
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Nov 18 12:01:46 2011 -0500
sal_Bool to bool.
diff --git a/sc/source/filter/excel/excimp8.cxx b/sc/source/filter/excel/excimp8.cxx
index 4cd628f..f4b3320 100644
--- a/sc/source/filter/excel/excimp8.cxx
+++ b/sc/source/filter/excel/excimp8.cxx
@@ -577,10 +577,10 @@ void XclImpAutoFilterData::ReadAutoFilter( XclImpStream& rStrm )
rStrm >> nCol >> nFlags;
ScQueryConnect eConn = ::get_flagvalue( nFlags, EXC_AFFLAG_ANDORMASK, SC_OR, SC_AND );
- sal_Bool bTop10 = ::get_flag( nFlags, EXC_AFFLAG_TOP10 );
- sal_Bool bTopOfTop10 = ::get_flag( nFlags, EXC_AFFLAG_TOP10TOP );
- sal_Bool bPercent = ::get_flag( nFlags, EXC_AFFLAG_TOP10PERC );
- sal_uInt16 nCntOfTop10 = nFlags >> 7;
+ bool bTop10 = ::get_flag( nFlags, EXC_AFFLAG_TOP10 );
+ bool bTopOfTop10 = ::get_flag( nFlags, EXC_AFFLAG_TOP10TOP );
+ bool bPercent = ::get_flag( nFlags, EXC_AFFLAG_TOP10PERC );
+ sal_uInt16 nCntOfTop10 = nFlags >> 7;
SCSIZE nCount = aParam.GetEntryCount();
if( bTop10 )
@@ -690,7 +690,7 @@ void XclImpAutoFilterData::ReadAutoFilter( XclImpStream& rStrm )
'A1 AND (B1 OR B2)' in this case, but Calc would do
'(A1 AND B1) OR B2' instead. */
if( (nFirstEmpty > 1) && nE && (eConn == SC_OR) && !bIgnore )
- bHasConflict = sal_True;
+ bHasConflict = true;
if( !bHasConflict && !bIgnore )
{
aEntry.bDoQuery = true;
commit 4f8976be9a04f3967b7e4a11f130f7aee50a56f4
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Nov 18 11:57:13 2011 -0500
Used constants if possible.
diff --git a/sc/source/filter/excel/read.cxx b/sc/source/filter/excel/read.cxx
index 7900d85..8273c1c 100644
--- a/sc/source/filter/excel/read.cxx
+++ b/sc/source/filter/excel/read.cxx
@@ -1126,8 +1126,8 @@ FltError ImportExcel8::Read( void )
case 0x8C: Country(); break; // COUNTRY [ 345 ]
case 0x99: Standardwidth(); break; // STANDARDWIDTH[ 45 ]
case 0x9B: FilterMode(); break; // FILTERMODE
- case 0x9D: AutoFilterInfo(); break;// AUTOFILTERINFO
- case 0x9E: AutoFilter(); break; // AUTOFILTER
+ case EXC_ID_AUTOFILTERINFO: AutoFilterInfo(); break;// AUTOFILTERINFO
+ case EXC_ID_AUTOFILTER: AutoFilter(); break; // AUTOFILTER
case 0x0208: Row34(); break; // ROW [ 34 ]
case EXC_ID2_ARRAY:
case EXC_ID3_ARRAY: Array34(); break; // ARRAY [ 34 ]
commit 3c8348017b77640262ca5dd88b9f9429e6d07037
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Nov 18 00:39:58 2011 -0500
Finally load the multi-match conditions properly.
diff --git a/sc/source/filter/xml/xmlfilti.cxx b/sc/source/filter/xml/xmlfilti.cxx
index c135d6e..5635b4f 100644
--- a/sc/source/filter/xml/xmlfilti.cxx
+++ b/sc/source/filter/xml/xmlfilti.cxx
@@ -388,7 +388,7 @@ SvXMLImportContext *ScXMLConditionContext::CreateChildContext( sal_uInt16 nPrefi
case XML_TOK_CONDITION_FILTER_SET_ITEM:
{
pContext = new ScXMLSetItemContext(
- GetScImport(), nPrefix, rLName, xAttrList);
+ GetScImport(), nPrefix, rLName, xAttrList, *this);
}
break;
}
@@ -451,6 +451,11 @@ void ScXMLConditionContext::GetOperator(
rEntry.eOp = SC_DOES_NOT_END_WITH;
}
+void ScXMLConditionContext::AddSetItem(const ScQueryEntry::Item& rItem)
+{
+ maQueryItems.push_back(rItem);
+}
+
void ScXMLConditionContext::EndElement()
{
ScQueryEntry& rEntry = mrQueryParam.AppendEntry();
@@ -464,17 +469,23 @@ void ScXMLConditionContext::EndElement()
GetOperator(sOperator, mrQueryParam, rEntry);
SCCOLROW nStartPos = mrQueryParam.bByRow ? mrQueryParam.nCol1 : mrQueryParam.nRow1;
rEntry.nField = nField + nStartPos;
- ScQueryEntry::Item& rItem = rEntry.GetQueryItem();
- if (IsXMLToken(sDataType, XML_NUMBER))
+
+ if (maQueryItems.empty())
{
- rItem.mfVal = sConditionValue.toDouble();
- rItem.meType = ScQueryEntry::ByValue;
+ ScQueryEntry::Item& rItem = rEntry.GetQueryItem();
+ if (IsXMLToken(sDataType, XML_NUMBER))
+ {
+ rItem.mfVal = sConditionValue.toDouble();
+ rItem.meType = ScQueryEntry::ByValue;
+ }
+ else
+ {
+ rItem.maString = sConditionValue;
+ rItem.meType = ScQueryEntry::ByString;
+ }
}
else
- {
- rItem.maString = sConditionValue;
- rItem.meType = ScQueryEntry::ByString;
- }
+ rEntry.GetQueryItems().swap(maQueryItems);
}
const ScXMLImport& ScXMLSetItemContext::GetScImport() const
@@ -489,7 +500,7 @@ ScXMLImport& ScXMLSetItemContext::GetScImport()
ScXMLSetItemContext::ScXMLSetItemContext(
ScXMLImport& rImport, sal_uInt16 nPrfx, const rtl::OUString& rLName,
- const Reference<XAttributeList>& xAttrList) :
+ const Reference<XAttributeList>& xAttrList, ScXMLConditionContext& rParent) :
SvXMLImportContext(rImport, nPrfx, rLName)
{
sal_Int32 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
@@ -507,7 +518,11 @@ ScXMLSetItemContext::ScXMLSetItemContext(
{
case XML_TOK_FILTER_SET_ITEM_ATTR_VALUE:
{
- // TODO: import the value.
+ ScQueryEntry::Item aItem;
+ aItem.maString = sValue;
+ aItem.meType = ScQueryEntry::ByString;
+ aItem.mfVal = 0.0;
+ rParent.AddSetItem(aItem);
}
break;
}
diff --git a/sc/source/filter/xml/xmlfilti.hxx b/sc/source/filter/xml/xmlfilti.hxx
index 5f44ecc..92a094c 100644
--- a/sc/source/filter/xml/xmlfilti.hxx
+++ b/sc/source/filter/xml/xmlfilti.hxx
@@ -40,12 +40,12 @@
#include "xmldrani.hxx"
#include "xmldpimp.hxx"
+#include "queryentry.hxx"
#include <vector>
class ScXMLImport;
struct ScQueryParam;
-struct ScQueryEntry;
class ScXMLFilterContext : public SvXMLImportContext
{
@@ -155,6 +155,7 @@ class ScXMLConditionContext : public SvXMLImportContext
ScQueryParam& mrQueryParam;
ScXMLFilterContext* pFilterContext;
+ ScQueryEntry::QueryItemsType maQueryItems;
rtl::OUString sDataType;
rtl::OUString sConditionValue;
rtl::OUString sOperator;
@@ -180,8 +181,10 @@ public:
const ::com::sun::star::uno::Reference<
::com::sun::star::xml::sax::XAttributeList>& xAttrList );
- void GetOperator(const rtl::OUString& aOpStr, ScQueryParam& rParam, ScQueryEntry& rEntry) const;
virtual void EndElement();
+
+ void GetOperator(const rtl::OUString& aOpStr, ScQueryParam& rParam, ScQueryEntry& rEntry) const;
+ void AddSetItem(const ScQueryEntry::Item& rItem);
};
class ScXMLSetItemContext : public SvXMLImportContext
@@ -192,7 +195,8 @@ public:
ScXMLSetItemContext(ScXMLImport& rImport, sal_uInt16 nPrfx,
const ::rtl::OUString& rLName,
const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList>& xAttrList);
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
+ ScXMLConditionContext& rParent);
virtual ~ScXMLSetItemContext();
commit e85842d3d02f5a4faaff6dc79d00887e4d062582
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Nov 18 00:18:02 2011 -0500
Set the db range to the query param first to calculate absolute column IDs.
It's less hacky this way.
diff --git a/sc/source/filter/xml/xmldrani.cxx b/sc/source/filter/xml/xmldrani.cxx
index 4605bd6..2014040 100644
--- a/sc/source/filter/xml/xmldrani.cxx
+++ b/sc/source/filter/xml/xmldrani.cxx
@@ -224,6 +224,12 @@ ScXMLDatabaseRangeContext::ScXMLDatabaseRangeContext( ScXMLImport& rImport,
}
}
+ mpQueryParam->nTab = maRange.aStart.Tab();
+ mpQueryParam->nCol1 = maRange.aStart.Col();
+ mpQueryParam->nRow1 = maRange.aStart.Row();
+ mpQueryParam->nCol2 = maRange.aEnd.Col();
+ mpQueryParam->nRow2 = maRange.aEnd.Row();
+
if (sDatabaseRangeName.matchAsciiL(STR_DB_LOCAL_NONAME, strlen(STR_DB_LOCAL_NONAME)))
meRangeType = ScDBCollection::SheetAnonymous;
else if (sDatabaseRangeName.matchAsciiL(STR_DB_GLOBAL_NONAME, strlen(STR_DB_GLOBAL_NONAME)))
@@ -307,6 +313,15 @@ ScDBData* ScXMLDatabaseRangeContext::ConvertToDBData(const OUString& rName)
pData->SetDoSize(bMoveCells);
pData->SetStripData(bStripData);
+ pData->SetQueryParam(*mpQueryParam);
+
+ if (bFilterConditionSourceRange)
+ {
+ ScRange aAdvSource;
+ ScUnoConversion::FillScRange(aAdvSource, aFilterConditionSourceRangeAddress);
+ pData->SetAdvancedQuerySource(&aAdvSource);
+ }
+
{
ScImportParam aParam;
aParam.bNative = bNative;
@@ -339,34 +354,6 @@ ScDBData* ScXMLDatabaseRangeContext::ConvertToDBData(const OUString& rName)
pData->SetImportParam(aParam);
}
- {
- mpQueryParam->nTab = maRange.aStart.Tab();
- mpQueryParam->nCol1 = maRange.aStart.Col();
- mpQueryParam->nRow1 = maRange.aStart.Row();
- mpQueryParam->nCol2 = maRange.aEnd.Col();
- mpQueryParam->nRow2 = maRange.aEnd.Row();
-
- // Convert from relative to absolute column IDs for the fields. Calc
- // core expects the field positions to be absolute column IDs.
- SCCOLROW nStartPos = mpQueryParam->bByRow ? maRange.aStart.Col() : maRange.aStart.Row();
- for (SCSIZE i = 0; i < mpQueryParam->GetEntryCount(); ++i)
- {
- ScQueryEntry& rEntry = mpQueryParam->GetEntry(i);
- if (!rEntry.bDoQuery)
- break;
- rEntry.nField += nStartPos;
- }
-
- pData->SetQueryParam(*mpQueryParam);
- }
-
- if (bFilterConditionSourceRange)
- {
- ScRange aAdvSource;
- ScUnoConversion::FillScRange(aAdvSource, aFilterConditionSourceRangeAddress);
- pData->SetAdvancedQuerySource(&aAdvSource);
- }
-
if (bContainsSort)
{
size_t nOldSize = aSortSequence.getLength();
diff --git a/sc/source/filter/xml/xmlfilti.cxx b/sc/source/filter/xml/xmlfilti.cxx
index 6cfa680..c135d6e 100644
--- a/sc/source/filter/xml/xmlfilti.cxx
+++ b/sc/source/filter/xml/xmlfilti.cxx
@@ -462,7 +462,8 @@ void ScXMLConditionContext::EndElement()
rEntry.eConnect = pFilterContext->GetConnection() ? SC_OR : SC_AND;
GetOperator(sOperator, mrQueryParam, rEntry);
- rEntry.nField = nField; // at this point this is relative to the left-most field.
+ SCCOLROW nStartPos = mrQueryParam.bByRow ? mrQueryParam.nCol1 : mrQueryParam.nRow1;
+ rEntry.nField = nField + nStartPos;
ScQueryEntry::Item& rItem = rEntry.GetQueryItem();
if (IsXMLToken(sDataType, XML_NUMBER))
{
commit e7e2f7c22a7e87b03e671c4a86aa3f9e31e2c460
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Nov 18 00:11:34 2011 -0500
I need to parse the range up-front.
diff --git a/sc/source/filter/xml/xmldrani.cxx b/sc/source/filter/xml/xmldrani.cxx
index f8276e6..4605bd6 100644
--- a/sc/source/filter/xml/xmldrani.cxx
+++ b/sc/source/filter/xml/xmldrani.cxx
@@ -134,6 +134,7 @@ ScXMLDatabaseRangeContext::ScXMLDatabaseRangeContext( ScXMLImport& rImport,
aSortSequence(),
nRefresh(0),
nSubTotalsUserListIndex(0),
+ mbValidRange(true),
bContainsSort(false),
bContainsSubTotal(false),
bNative(true),
@@ -206,7 +207,11 @@ ScXMLDatabaseRangeContext::ScXMLDatabaseRangeContext( ScXMLImport& rImport,
break;
case XML_TOK_DATABASE_RANGE_ATTR_TARGET_RANGE_ADDRESS :
{
- sRangeAddress = sValue;
+ ScDocument* pDoc = GetScImport().GetDocument();
+ sal_Int32 nOffset = 0;
+ if (!ScRangeStringConverter::GetRangeFromString(
+ maRange, sValue, pDoc, ::formula::FormulaGrammar::CONV_OOO, nOffset))
+ mbValidRange = false;
}
break;
case XML_TOK_DATABASE_RANGE_ATTR_REFRESH_DELAY :
@@ -287,16 +292,14 @@ SvXMLImportContext *ScXMLDatabaseRangeContext::CreateChildContext( sal_uInt16 nP
ScDBData* ScXMLDatabaseRangeContext::ConvertToDBData(const OUString& rName)
{
- ScDocument* pDoc = GetScImport().GetDocument();
-
- sal_Int32 nOffset = 0;
- ScRange aRange;
- if (!ScRangeStringConverter::GetRangeFromString(aRange, sRangeAddress, pDoc, ::formula::FormulaGrammar::CONV_OOO, nOffset))
+ if (!mbValidRange)
return NULL;
+ ScDocument* pDoc = GetScImport().GetDocument();
+
SAL_WNODEPRECATED_DECLARATIONS_PUSH
::std::auto_ptr<ScDBData> pData(
- new ScDBData(rName, aRange.aStart.Tab(), aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(), aRange.aEnd.Row()));
+ new ScDBData(rName, maRange.aStart.Tab(), maRange.aStart.Col(), maRange.aStart.Row(), maRange.aEnd.Col(), maRange.aEnd.Row()));
SAL_WNODEPRECATED_DECLARATIONS_POP
pData->SetAutoFilter(bAutoFilter);
@@ -337,15 +340,15 @@ ScDBData* ScXMLDatabaseRangeContext::ConvertToDBData(const OUString& rName)
}
{
- mpQueryParam->nTab = aRange.aStart.Tab();
- mpQueryParam->nCol1 = aRange.aStart.Col();
- mpQueryParam->nRow1 = aRange.aStart.Row();
- mpQueryParam->nCol2 = aRange.aEnd.Col();
- mpQueryParam->nRow2 = aRange.aEnd.Row();
+ mpQueryParam->nTab = maRange.aStart.Tab();
+ mpQueryParam->nCol1 = maRange.aStart.Col();
+ mpQueryParam->nRow1 = maRange.aStart.Row();
+ mpQueryParam->nCol2 = maRange.aEnd.Col();
+ mpQueryParam->nRow2 = maRange.aEnd.Row();
// Convert from relative to absolute column IDs for the fields. Calc
// core expects the field positions to be absolute column IDs.
- SCCOLROW nStartPos = mpQueryParam->bByRow ? aRange.aStart.Col() : aRange.aStart.Row();
+ SCCOLROW nStartPos = mpQueryParam->bByRow ? maRange.aStart.Col() : maRange.aStart.Row();
for (SCSIZE i = 0; i < mpQueryParam->GetEntryCount(); ++i)
{
ScQueryEntry& rEntry = mpQueryParam->GetEntry(i);
@@ -377,7 +380,7 @@ ScDBData* ScXMLDatabaseRangeContext::ConvertToDBData(const OUString& rName)
ScSortParam aParam;
ScSortDescriptor::FillSortParam(aParam, aSortSequence);
- SCCOLROW nStartPos = aParam.bByRow ? aRange.aStart.Col() : aRange.aStart.Row();
+ SCCOLROW nStartPos = aParam.bByRow ? maRange.aStart.Col() : maRange.aStart.Row();
for (size_t i = 0; i < MAXSORT; ++i)
{
if (!aParam.bDoSort[i])
diff --git a/sc/source/filter/xml/xmldrani.hxx b/sc/source/filter/xml/xmldrani.hxx
index 06c659a..9fe1408 100644
--- a/sc/source/filter/xml/xmldrani.hxx
+++ b/sc/source/filter/xml/xmldrani.hxx
@@ -78,9 +78,9 @@ struct ScSubTotalRule
class ScXMLDatabaseRangeContext : public SvXMLImportContext
{
boost::scoped_ptr<ScQueryParam> mpQueryParam;
+ ScRange maRange;
rtl::OUString sDatabaseRangeName;
rtl::OUString sConnectionRessource;
- rtl::OUString sRangeAddress;
rtl::OUString sDatabaseName;
rtl::OUString sSourceObject;
com::sun::star::uno::Sequence <com::sun::star::beans::PropertyValue> aSortSequence;
@@ -90,6 +90,7 @@ class ScXMLDatabaseRangeContext : public SvXMLImportContext
sal_Int32 nRefresh;
sal_Int16 nSubTotalsUserListIndex;
sal_Int16 nSubTotalRuleGroupFieldNumber;
+ bool mbValidRange;
bool bContainsSort;
bool bContainsSubTotal;
bool bNative;
commit dff8c99b01f2c87e3d56663d12a1a671835002cf
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Nov 18 00:00:28 2011 -0500
Populate the query entries directly.
diff --git a/sc/inc/queryparam.hxx b/sc/inc/queryparam.hxx
index 5e0899b..77108ab 100644
--- a/sc/inc/queryparam.hxx
+++ b/sc/inc/queryparam.hxx
@@ -53,6 +53,7 @@ struct ScQueryParamBase
SC_DLLPUBLIC SCSIZE GetEntryCount() const;
SC_DLLPUBLIC const ScQueryEntry& GetEntry(SCSIZE n) const;
SC_DLLPUBLIC ScQueryEntry& GetEntry(SCSIZE n);
+ SC_DLLPUBLIC ScQueryEntry& AppendEntry();
ScQueryEntry* FindEntryByField(SCCOLROW nField, bool bNew);
SC_DLLPUBLIC void RemoveEntryByField(SCCOLROW nField);
void Resize(size_t nNew);
diff --git a/sc/source/core/tool/queryparam.cxx b/sc/source/core/tool/queryparam.cxx
index c8c9686..7352d07 100644
--- a/sc/source/core/tool/queryparam.cxx
+++ b/sc/source/core/tool/queryparam.cxx
@@ -102,6 +102,21 @@ ScQueryEntry& ScQueryParamBase::GetEntry(SCSIZE n)
return maEntries[n];
}
+ScQueryEntry& ScQueryParamBase::AppendEntry()
+{
+ // Find the first unused entry.
+ EntriesType::iterator itr = std::find_if(
+ maEntries.begin(), maEntries.end(), FindUnused());
+
+ if (itr != maEntries.end())
+ // Found!
+ return *itr;
+
+ // Add a new entry to the end.
+ maEntries.push_back(new ScQueryEntry);
+ return maEntries.back();
+}
+
ScQueryEntry* ScQueryParamBase::FindEntryByField(SCCOLROW nField, bool bNew)
{
EntriesType::iterator itr = std::find_if(
@@ -117,14 +132,7 @@ ScQueryEntry* ScQueryParamBase::FindEntryByField(SCCOLROW nField, bool bNew)
// no existing entry found, and we are not creating a new one.
return NULL;
- // Find the first unused entry.
- itr = std::find_if(maEntries.begin(), maEntries.end(), FindUnused());
- if (itr != maEntries.end())
- return &(*itr);
-
- // Add a new entry to the end.
- maEntries.push_back(new ScQueryEntry);
- return &maEntries.back();
+ return &AppendEntry();
}
void ScQueryParamBase::RemoveEntryByField(SCCOLROW nField)
diff --git a/sc/source/filter/xml/xmldrani.cxx b/sc/source/filter/xml/xmldrani.cxx
index 6d0b599..f8276e6 100644
--- a/sc/source/filter/xml/xmldrani.cxx
+++ b/sc/source/filter/xml/xmldrani.cxx
@@ -343,8 +343,6 @@ ScDBData* ScXMLDatabaseRangeContext::ConvertToDBData(const OUString& rName)
mpQueryParam->nCol2 = aRange.aEnd.Col();
mpQueryParam->nRow2 = aRange.aEnd.Row();
- ScFilterDescriptorBase::fillQueryParam(*mpQueryParam, pDoc, aFilterFields);
-
// Convert from relative to absolute column IDs for the fields. Calc
// core expects the field positions to be absolute column IDs.
SCCOLROW nStartPos = mpQueryParam->bByRow ? aRange.aStart.Col() : aRange.aStart.Row();
diff --git a/sc/source/filter/xml/xmldrani.hxx b/sc/source/filter/xml/xmldrani.hxx
index 200cee0..06c659a 100644
--- a/sc/source/filter/xml/xmldrani.hxx
+++ b/sc/source/filter/xml/xmldrani.hxx
@@ -84,7 +84,6 @@ class ScXMLDatabaseRangeContext : public SvXMLImportContext
rtl::OUString sDatabaseName;
rtl::OUString sSourceObject;
com::sun::star::uno::Sequence <com::sun::star::beans::PropertyValue> aSortSequence;
- com::sun::star::uno::Sequence <com::sun::star::sheet::TableFilterField2> aFilterFields;
std::vector < ScSubTotalRule > aSubTotalRules;
com::sun::star::table::CellRangeAddress aFilterConditionSourceRangeAddress;
com::sun::star::sheet::DataImportMode nSourceType;
@@ -143,7 +142,6 @@ public:
void SetSubTotalsSortGroups(const bool bTemp) { bSubTotalsSortGroups = bTemp; }
void AddSubTotalRule(const ScSubTotalRule& rRule) { aSubTotalRules.push_back(rRule); }
void SetSortSequence(const com::sun::star::uno::Sequence <com::sun::star::beans::PropertyValue>& aTempSortSequence) { aSortSequence = aTempSortSequence; }
- void SetFilterFields(const com::sun::star::uno::Sequence <com::sun::star::sheet::TableFilterField2>& aTemp) { aFilterFields = aTemp; }
void SetFilterConditionSourceRangeAddress(const com::sun::star::table::CellRangeAddress& aTemp) { aFilterConditionSourceRangeAddress = aTemp;
bFilterConditionSourceRange = true; }
};
diff --git a/sc/source/filter/xml/xmlfilti.cxx b/sc/source/filter/xml/xmlfilti.cxx
index 2e5e1e3..6cfa680 100644
--- a/sc/source/filter/xml/xmlfilti.cxx
+++ b/sc/source/filter/xml/xmlfilti.cxx
@@ -61,7 +61,6 @@ ScXMLFilterContext::ScXMLFilterContext( ScXMLImport& rImport,
SvXMLImportContext( rImport, nPrfx, rLName ),
mrQueryParam(rParam),
pDatabaseRangeContext(pTempDatabaseRangeContext),
- aFilterFields(),
bSkipDuplicates(false),
bCopyOutputData(false),
bUseRegularExpressions(false),
@@ -129,20 +128,20 @@ SvXMLImportContext *ScXMLFilterContext::CreateChildContext( sal_uInt16 nPrefix,
{
case XML_TOK_FILTER_AND:
{
- pContext = new ScXMLAndContext( GetScImport(), nPrefix,
- rLName, xAttrList, this);
+ pContext = new ScXMLAndContext(
+ GetScImport(), nPrefix, rLName, xAttrList, mrQueryParam, this);
}
break;
case XML_TOK_FILTER_OR:
{
- pContext = new ScXMLOrContext( GetScImport(), nPrefix,
- rLName, xAttrList, this);
+ pContext = new ScXMLOrContext(
+ GetScImport(), nPrefix, rLName, xAttrList, mrQueryParam, this);
}
break;
case XML_TOK_FILTER_CONDITION:
{
- pContext = new ScXMLConditionContext( GetScImport(), nPrefix,
- rLName, xAttrList, this);
+ pContext = new ScXMLConditionContext(
+ GetScImport(), nPrefix, rLName, xAttrList, mrQueryParam, this);
}
break;
}
@@ -166,7 +165,6 @@ void ScXMLFilterContext::EndElement()
mrQueryParam.nDestTab = aOutputPosition.Sheet;
}
- pDatabaseRangeContext->SetFilterFields(aFilterFields);
if (bConditionSourceRange)
pDatabaseRangeContext->SetFilterConditionSourceRangeAddress(aConditionSourceRangeAddress);
}
@@ -217,19 +215,14 @@ bool ScXMLFilterContext::GetConnection()
return itr->mbOr; // connection of the last stack.
}
-void ScXMLFilterContext::AddFilterField(const sheet::TableFilterField2& aFilterField)
-{
- aFilterFields.realloc(aFilterFields.getLength() + 1);
- aFilterFields[aFilterFields.getLength() - 1] = aFilterField;
-}
-
ScXMLAndContext::ScXMLAndContext( ScXMLImport& rImport,
- sal_uInt16 nPrfx,
- const ::rtl::OUString& rLName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */,
- ScXMLFilterContext* pTempFilterContext) :
+ sal_uInt16 nPrfx,
+ const rtl::OUString& rLName,
+ const Reference<XAttributeList>& /* xAttrList */,
+ ScQueryParam& rParam,
+ ScXMLFilterContext* pTempFilterContext) :
SvXMLImportContext( rImport, nPrfx, rLName ),
+ mrQueryParam(rParam),
pFilterContext(pTempFilterContext)
{
pFilterContext->OpenConnection(false);
@@ -256,8 +249,8 @@ SvXMLImportContext *ScXMLAndContext::CreateChildContext( sal_uInt16 nPrefix,
break;
case XML_TOK_FILTER_CONDITION:
{
- pContext = new ScXMLConditionContext( GetScImport(), nPrefix,
- rLName, xAttrList, pFilterContext);
+ pContext = new ScXMLConditionContext(
+ GetScImport(), nPrefix, rLName, xAttrList, mrQueryParam, pFilterContext);
}
break;
}
@@ -274,12 +267,14 @@ void ScXMLAndContext::EndElement()
}
ScXMLOrContext::ScXMLOrContext( ScXMLImport& rImport,
- sal_uInt16 nPrfx,
- const ::rtl::OUString& rLName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */,
- ScXMLFilterContext* pTempFilterContext) :
+ sal_uInt16 nPrfx,
+ const rtl::OUString& rLName,
+ const Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */,
+ ScQueryParam& rParam,
+ ScXMLFilterContext* pTempFilterContext) :
SvXMLImportContext( rImport, nPrfx, rLName ),
+ mrQueryParam(rParam),
pFilterContext(pTempFilterContext)
{
pFilterContext->OpenConnection(true);
@@ -301,14 +296,14 @@ SvXMLImportContext *ScXMLOrContext::CreateChildContext( sal_uInt16 nPrefix,
{
case XML_TOK_FILTER_AND:
{
- pContext = new ScXMLAndContext( GetScImport(), nPrefix,
- rLName, xAttrList, pFilterContext);
+ pContext = new ScXMLAndContext(
+ GetScImport(), nPrefix, rLName, xAttrList, mrQueryParam, pFilterContext);
}
break;
case XML_TOK_FILTER_CONDITION:
{
- pContext = new ScXMLConditionContext( GetScImport(), nPrefix,
- rLName, xAttrList, pFilterContext);
+ pContext = new ScXMLConditionContext(
+ GetScImport(), nPrefix, rLName, xAttrList, mrQueryParam, pFilterContext);
}
break;
}
@@ -324,13 +319,13 @@ void ScXMLOrContext::EndElement()
pFilterContext->CloseConnection();
}
-ScXMLConditionContext::ScXMLConditionContext( ScXMLImport& rImport,
- sal_uInt16 nPrfx,
- const ::rtl::OUString& rLName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
- ScXMLFilterContext* pTempFilterContext) :
+ScXMLConditionContext::ScXMLConditionContext(
+ ScXMLImport& rImport, sal_uInt16 nPrfx, const rtl::OUString& rLName,
+ const Reference<XAttributeList>& xAttrList,
+ ScQueryParam& rParam,
+ ScXMLFilterContext* pTempFilterContext) :
SvXMLImportContext( rImport, nPrfx, rLName ),
+ mrQueryParam(rParam),
pFilterContext(pTempFilterContext),
bIsCaseSensitive(false)
{
@@ -404,80 +399,81 @@ SvXMLImportContext *ScXMLConditionContext::CreateChildContext( sal_uInt16 nPrefi
return pContext;
}
-void ScXMLConditionContext::getOperatorXML(const rtl::OUString sTempOperator, sal_Int32& aFilterOperator, bool& bUseRegularExpressions) const
+void ScXMLConditionContext::GetOperator(
+ const rtl::OUString& aOpStr, ScQueryParam& rParam, ScQueryEntry& rEntry) const
{
- bUseRegularExpressions = false;
- if (IsXMLToken(sTempOperator, XML_MATCH))
+ rParam.bRegExp = false;
+ if (IsXMLToken(aOpStr, XML_MATCH))
{
- bUseRegularExpressions = true;
- aFilterOperator = sheet::FilterOperator2::EQUAL;
+ rParam.bRegExp = true;
+ rEntry.eOp = SC_EQUAL;
}
- else if (IsXMLToken(sTempOperator, XML_NOMATCH))
+ else if (IsXMLToken(aOpStr, XML_NOMATCH))
{
- bUseRegularExpressions = true;
- aFilterOperator = sheet::FilterOperator2::NOT_EQUAL;
+ rParam.bRegExp = true;
+ rEntry.eOp = SC_NOT_EQUAL;
}
- else if (sTempOperator.compareToAscii("=") == 0)
- aFilterOperator = sheet::FilterOperator2::EQUAL;
- else if (sTempOperator.compareToAscii("!=") == 0)
- aFilterOperator = sheet::FilterOperator2::NOT_EQUAL;
- else if (IsXMLToken(sTempOperator, XML_BOTTOM_PERCENT))
- aFilterOperator = sheet::FilterOperator2::BOTTOM_PERCENT;
- else if (IsXMLToken(sTempOperator, XML_BOTTOM_VALUES))
- aFilterOperator = sheet::FilterOperator2::BOTTOM_VALUES;
- else if (IsXMLToken(sTempOperator, XML_EMPTY))
- aFilterOperator = sheet::FilterOperator2::EMPTY;
- else if (sTempOperator.compareToAscii(">") == 0)
- aFilterOperator = sheet::FilterOperator2::GREATER;
- else if (sTempOperator.compareToAscii(">=") == 0)
- aFilterOperator = sheet::FilterOperator2::GREATER_EQUAL;
- else if (sTempOperator.compareToAscii("<") == 0)
- aFilterOperator = sheet::FilterOperator2::LESS;
- else if (sTempOperator.compareToAscii("<=") == 0)
- aFilterOperator = sheet::FilterOperator2::LESS_EQUAL;
- else if (IsXMLToken(sTempOperator, XML_NOEMPTY))
- aFilterOperator = sheet::FilterOperator2::NOT_EMPTY;
- else if (IsXMLToken(sTempOperator, XML_TOP_PERCENT))
- aFilterOperator = sheet::FilterOperator2::TOP_PERCENT;
- else if (IsXMLToken(sTempOperator, XML_TOP_VALUES))
- aFilterOperator = sheet::FilterOperator2::TOP_VALUES;
- else if (IsXMLToken(sTempOperator, XML_CONTAINS))
- aFilterOperator = sheet::FilterOperator2::CONTAINS;
- else if (IsXMLToken(sTempOperator, XML_DOES_NOT_CONTAIN))
- aFilterOperator = sheet::FilterOperator2::DOES_NOT_CONTAIN;
- else if (IsXMLToken(sTempOperator, XML_BEGINS_WITH))
- aFilterOperator = sheet::FilterOperator2::BEGINS_WITH;
- else if (IsXMLToken(sTempOperator, XML_DOES_NOT_BEGIN_WITH))
- aFilterOperator = sheet::FilterOperator2::DOES_NOT_BEGIN_WITH;
- else if (IsXMLToken(sTempOperator, XML_ENDS_WITH))
- aFilterOperator = sheet::FilterOperator2::ENDS_WITH;
- else if (IsXMLToken(sTempOperator, XML_DOES_NOT_END_WITH))
- aFilterOperator = sheet::FilterOperator2::DOES_NOT_END_WITH;
+ else if (aOpStr.compareToAscii("=") == 0)
+ rEntry.eOp = SC_EQUAL;
+ else if (aOpStr.compareToAscii("!=") == 0)
+ rEntry.eOp = SC_NOT_EQUAL;
+ else if (IsXMLToken(aOpStr, XML_BOTTOM_PERCENT))
+ rEntry.eOp = SC_BOTPERC;
+ else if (IsXMLToken(aOpStr, XML_BOTTOM_VALUES))
+ rEntry.eOp = SC_BOTVAL;
+ else if (IsXMLToken(aOpStr, XML_EMPTY))
+ rEntry.SetQueryByEmpty();
+ else if (aOpStr.compareToAscii(">") == 0)
+ rEntry.eOp = SC_GREATER;
+ else if (aOpStr.compareToAscii(">=") == 0)
+ rEntry.eOp = SC_GREATER_EQUAL;
+ else if (aOpStr.compareToAscii("<") == 0)
+ rEntry.eOp = SC_LESS;
+ else if (aOpStr.compareToAscii("<=") == 0)
+ rEntry.eOp = SC_LESS_EQUAL;
+ else if (IsXMLToken(aOpStr, XML_NOEMPTY))
+ rEntry.SetQueryByNonEmpty();
+ else if (IsXMLToken(aOpStr, XML_TOP_PERCENT))
+ rEntry.eOp = SC_TOPPERC;
+ else if (IsXMLToken(aOpStr, XML_TOP_VALUES))
+ rEntry.eOp = SC_TOPVAL;
+ else if (IsXMLToken(aOpStr, XML_CONTAINS))
+ rEntry.eOp = SC_CONTAINS;
+ else if (IsXMLToken(aOpStr, XML_DOES_NOT_CONTAIN))
+ rEntry.eOp = SC_DOES_NOT_CONTAIN;
+ else if (IsXMLToken(aOpStr, XML_BEGINS_WITH))
+ rEntry.eOp = SC_BEGINS_WITH;
+ else if (IsXMLToken(aOpStr, XML_DOES_NOT_BEGIN_WITH))
+ rEntry.eOp = SC_DOES_NOT_BEGIN_WITH;
+ else if (IsXMLToken(aOpStr, XML_ENDS_WITH))
+ rEntry.eOp = SC_ENDS_WITH;
+ else if (IsXMLToken(aOpStr, XML_DOES_NOT_END_WITH))
+ rEntry.eOp = SC_DOES_NOT_END_WITH;
}
void ScXMLConditionContext::EndElement()
{
- sheet::TableFilterField2 aFilterField;
- if (pFilterContext->GetConnection())
- aFilterField.Connection = sheet::FilterConnection_OR;
- else
- aFilterField.Connection = sheet::FilterConnection_AND;
- pFilterContext->SetCaseSensitive(bIsCaseSensitive);
- bool bUseRegularExpressions;
- getOperatorXML(sOperator, aFilterField.Operator, bUseRegularExpressions);
- pFilterContext->SetUseRegularExpressions(bUseRegularExpressions);
- aFilterField.Field = nField;
+ ScQueryEntry& rEntry = mrQueryParam.AppendEntry();
+
+ // We currently don't support per-condition case sensitivity.
+ mrQueryParam.bCaseSens = bIsCaseSensitive;
+
+ rEntry.bDoQuery = true;
+ rEntry.eConnect = pFilterContext->GetConnection() ? SC_OR : SC_AND;
+
+ GetOperator(sOperator, mrQueryParam, rEntry);
+ rEntry.nField = nField; // at this point this is relative to the left-most field.
+ ScQueryEntry::Item& rItem = rEntry.GetQueryItem();
if (IsXMLToken(sDataType, XML_NUMBER))
{
- aFilterField.NumericValue = sConditionValue.toDouble();
- aFilterField.IsNumeric = true;
+ rItem.mfVal = sConditionValue.toDouble();
+ rItem.meType = ScQueryEntry::ByValue;
}
else
{
- aFilterField.StringValue = sConditionValue;
- aFilterField.IsNumeric = false;
+ rItem.maString = sConditionValue;
+ rItem.meType = ScQueryEntry::ByString;
}
- pFilterContext->AddFilterField(aFilterField);
}
const ScXMLImport& ScXMLSetItemContext::GetScImport() const
diff --git a/sc/source/filter/xml/xmlfilti.hxx b/sc/source/filter/xml/xmlfilti.hxx
index 2d06af8..5f44ecc 100644
--- a/sc/source/filter/xml/xmlfilti.hxx
+++ b/sc/source/filter/xml/xmlfilti.hxx
@@ -45,6 +45,7 @@
class ScXMLImport;
struct ScQueryParam;
+struct ScQueryEntry;
class ScXMLFilterContext : public SvXMLImportContext
{
@@ -57,7 +58,6 @@ class ScXMLFilterContext : public SvXMLImportContext
ScQueryParam& mrQueryParam;
ScXMLDatabaseRangeContext* pDatabaseRangeContext;
- com::sun::star::uno::Sequence <com::sun::star::sheet::TableFilterField2> aFilterFields;
com::sun::star::table::CellAddress aOutputPosition;
com::sun::star::table::CellRangeAddress aConditionSourceRangeAddress;
sal_Int16 nUserListIndex;
@@ -94,11 +94,11 @@ public:
void OpenConnection(bool b);
void CloseConnection();
bool GetConnection();
- void AddFilterField(const com::sun::star::sheet::TableFilterField2& aFilterField);
};
class ScXMLAndContext : public SvXMLImportContext
{
+ ScQueryParam& mrQueryParam;
ScXMLFilterContext* pFilterContext;
const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
@@ -107,10 +107,11 @@ class ScXMLAndContext : public SvXMLImportContext
public:
ScXMLAndContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
- const ::rtl::OUString& rLName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
- ScXMLFilterContext* pTempFilterContext);
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
+ ScQueryParam& rParam,
+ ScXMLFilterContext* pTempFilterContext);
virtual ~ScXMLAndContext();
@@ -124,6 +125,7 @@ public:
class ScXMLOrContext : public SvXMLImportContext
{
+ ScQueryParam& mrQueryParam;
ScXMLFilterContext* pFilterContext;
const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
@@ -132,10 +134,11 @@ class ScXMLOrContext : public SvXMLImportContext
public:
ScXMLOrContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
- const ::rtl::OUString& rLName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
- ScXMLFilterContext* pTempFilterContext);
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
+ ScQueryParam& rParam,
+ ScXMLFilterContext* pTempFilterContext);
virtual ~ScXMLOrContext();
@@ -149,6 +152,7 @@ public:
class ScXMLConditionContext : public SvXMLImportContext
{
+ ScQueryParam& mrQueryParam;
ScXMLFilterContext* pFilterContext;
rtl::OUString sDataType;
@@ -163,10 +167,11 @@ class ScXMLConditionContext : public SvXMLImportContext
public:
ScXMLConditionContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
- const ::rtl::OUString& rLName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
- ScXMLFilterContext* pTempFilterContext);
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
+ ScQueryParam& rParam,
+ ScXMLFilterContext* pTempFilterContext);
virtual ~ScXMLConditionContext();
@@ -175,7 +180,7 @@ public:
const ::com::sun::star::uno::Reference<
::com::sun::star::xml::sax::XAttributeList>& xAttrList );
- void getOperatorXML(const rtl::OUString sTempOperator, sal_Int32& aFilterOperator, bool& bUseRegularExpressions) const;
+ void GetOperator(const rtl::OUString& aOpStr, ScQueryParam& rParam, ScQueryEntry& rEntry) const;
virtual void EndElement();
};
commit 25ef3f6b4793d2ff340f07648648083975d11b6d
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Thu Nov 17 22:46:29 2011 -0500
Pick up more boolean data directly.
diff --git a/sc/source/filter/xml/xmldrani.cxx b/sc/source/filter/xml/xmldrani.cxx
index 0716111..6d0b599 100644
--- a/sc/source/filter/xml/xmldrani.cxx
+++ b/sc/source/filter/xml/xmldrani.cxx
@@ -148,9 +148,6 @@ ScXMLDatabaseRangeContext::ScXMLDatabaseRangeContext( ScXMLImport& rImport,
bSubTotalsSortGroups(false),
bSubTotalsEnabledUserList(false),
bSubTotalsAscending(true),
- bFilterCopyOutputData(false),
- bFilterSkipDuplicates(false),
- bFilterUseRegularExpressions(false),
bFilterConditionSourceRange(false),
meRangeType(ScDBCollection::GlobalNamed)
{
@@ -346,12 +343,6 @@ ScDBData* ScXMLDatabaseRangeContext::ConvertToDBData(const OUString& rName)
mpQueryParam->nCol2 = aRange.aEnd.Col();
mpQueryParam->nRow2 = aRange.aEnd.Row();
- mpQueryParam->bInplace = !bFilterCopyOutputData;
- mpQueryParam->bDuplicate = !bFilterSkipDuplicates;
- mpQueryParam->bRegExp = bFilterUseRegularExpressions;
- mpQueryParam->nDestTab = aFilterOutputPosition.Sheet;
- mpQueryParam->nDestCol = aFilterOutputPosition.Column;
- mpQueryParam->nDestRow = aFilterOutputPosition.Row;
ScFilterDescriptorBase::fillQueryParam(*mpQueryParam, pDoc, aFilterFields);
// Convert from relative to absolute column IDs for the fields. Calc
diff --git a/sc/source/filter/xml/xmldrani.hxx b/sc/source/filter/xml/xmldrani.hxx
index 9c4995e..200cee0 100644
--- a/sc/source/filter/xml/xmldrani.hxx
+++ b/sc/source/filter/xml/xmldrani.hxx
@@ -86,7 +86,6 @@ class ScXMLDatabaseRangeContext : public SvXMLImportContext
com::sun::star::uno::Sequence <com::sun::star::beans::PropertyValue> aSortSequence;
com::sun::star::uno::Sequence <com::sun::star::sheet::TableFilterField2> aFilterFields;
std::vector < ScSubTotalRule > aSubTotalRules;
- com::sun::star::table::CellAddress aFilterOutputPosition;
com::sun::star::table::CellRangeAddress aFilterConditionSourceRangeAddress;
com::sun::star::sheet::DataImportMode nSourceType;
sal_Int32 nRefresh;
@@ -106,9 +105,6 @@ class ScXMLDatabaseRangeContext : public SvXMLImportContext
bool bSubTotalsSortGroups;
bool bSubTotalsEnabledUserList;
bool bSubTotalsAscending;
- bool bFilterCopyOutputData;
- bool bFilterSkipDuplicates;
- bool bFilterUseRegularExpressions;
bool bFilterConditionSourceRange;
ScDBCollection::RangeType meRangeType;
@@ -147,11 +143,7 @@ public:
void SetSubTotalsSortGroups(const bool bTemp) { bSubTotalsSortGroups = bTemp; }
void AddSubTotalRule(const ScSubTotalRule& rRule) { aSubTotalRules.push_back(rRule); }
void SetSortSequence(const com::sun::star::uno::Sequence <com::sun::star::beans::PropertyValue>& aTempSortSequence) { aSortSequence = aTempSortSequence; }
- void SetFilterCopyOutputData(const bool bTemp) { bFilterCopyOutputData = bTemp; }
- void SetFilterSkipDuplicates(const bool bTemp) { bFilterSkipDuplicates = bTemp; }
- void SetFilterUseRegularExpressions(const bool bTemp) { bFilterUseRegularExpressions = bTemp; }
void SetFilterFields(const com::sun::star::uno::Sequence <com::sun::star::sheet::TableFilterField2>& aTemp) { aFilterFields = aTemp; }
- void SetFilterOutputPosition(const com::sun::star::table::CellAddress& aTemp) { aFilterOutputPosition = aTemp; }
void SetFilterConditionSourceRangeAddress(const com::sun::star::table::CellRangeAddress& aTemp) { aFilterConditionSourceRangeAddress = aTemp;
bFilterConditionSourceRange = true; }
};
diff --git a/sc/source/filter/xml/xmlfilti.cxx b/sc/source/filter/xml/xmlfilti.cxx
index 5cc07d8..2e5e1e3 100644
--- a/sc/source/filter/xml/xmlfilti.cxx
+++ b/sc/source/filter/xml/xmlfilti.cxx
@@ -155,15 +155,17 @@ SvXMLImportContext *ScXMLFilterContext::CreateChildContext( sal_uInt16 nPrefix,
void ScXMLFilterContext::EndElement()
{
- pDatabaseRangeContext->SetFilterUseRegularExpressions(bUseRegularExpressions);
+ mrQueryParam.bRegExp = bUseRegularExpressions;
+ mrQueryParam.bInplace = !bCopyOutputData;
+ mrQueryParam.bDuplicate = !bSkipDuplicates;
+
if (bCopyOutputData)
{
- pDatabaseRangeContext->SetFilterOutputPosition(aOutputPosition);
- pDatabaseRangeContext->SetFilterCopyOutputData(bCopyOutputData);
+ mrQueryParam.nDestCol = aOutputPosition.Column;
+ mrQueryParam.nDestRow = aOutputPosition.Row;
+ mrQueryParam.nDestTab = aOutputPosition.Sheet;
}
- else
- pDatabaseRangeContext->SetFilterCopyOutputData(false);
- pDatabaseRangeContext->SetFilterSkipDuplicates(bSkipDuplicates);
+
pDatabaseRangeContext->SetFilterFields(aFilterFields);
if (bConditionSourceRange)
pDatabaseRangeContext->SetFilterConditionSourceRangeAddress(aConditionSourceRangeAddress);
commit 0960ec3e1b7b0d872d1f84d2d56f480a4df08b21
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Thu Nov 17 21:50:14 2011 -0500
Simplified & clarified the connection logic.
diff --git a/sc/source/filter/xml/xmlfilti.cxx b/sc/source/filter/xml/xmlfilti.cxx
index 90eb1f7..5cc07d8 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 51c5e43..2d06af8 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(); }
commit d540bdccf5fd2b44732ebbfcb70cf1e11faa5b83
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Thu Nov 17 15:11:21 2011 -0500
Let's use std::vector instead.
diff --git a/sc/source/filter/xml/xmlfilti.cxx b/sc/source/filter/xml/xmlfilti.cxx
index 5338917..90eb1f7 100644
--- a/sc/source/filter/xml/xmlfilti.cxx
+++ b/sc/source/filter/xml/xmlfilti.cxx
@@ -176,27 +176,26 @@ void ScXMLFilterContext::SetCaseSensitive(bool b)
mrQueryParam.bCaseSens = b;
}
-void ScXMLFilterContext::SetUseRegularExpressions(bool bTemp)
+void ScXMLFilterContext::SetUseRegularExpressions(bool b)
{
if (!bUseRegularExpressions)
- bUseRegularExpressions = bTemp;
+ bUseRegularExpressions = b;
}
-void ScXMLFilterContext::OpenConnection(bool bTemp)
+void ScXMLFilterContext::OpenConnection(bool b)
{
- bool* pTemp = new bool;
- *pTemp = bConnectionOr;
+ bool bTemp = bConnectionOr;
bConnectionOr = bNextConnectionOr;
- bNextConnectionOr = bTemp;
- aConnectionOrStack.Push(pTemp);
+ bNextConnectionOr = b;
+ maOrConnectionStack.push_back(bTemp);
}
void ScXMLFilterContext::CloseConnection()
{
- bool* pTemp = static_cast <bool*> (aConnectionOrStack.Pop());
- bConnectionOr = *pTemp;
- bNextConnectionOr = *pTemp;
- delete pTemp;
+ bool bTemp = maOrConnectionStack.back();
+ maOrConnectionStack.pop_back();
+ bConnectionOr = bTemp;
+ bNextConnectionOr = bTemp;
}
bool ScXMLFilterContext::GetConnection()
diff --git a/sc/source/filter/xml/xmlfilti.hxx b/sc/source/filter/xml/xmlfilti.hxx
index 4a8bb3a..51c5e43 100644
--- a/sc/source/filter/xml/xmlfilti.hxx
+++ b/sc/source/filter/xml/xmlfilti.hxx
@@ -41,6 +41,8 @@
#include "xmldrani.hxx"
#include "xmldpimp.hxx"
+#include <vector>
+
class ScXMLImport;
struct ScQueryParam;
@@ -60,7 +62,7 @@ class ScXMLFilterContext : public SvXMLImportContext
bool bConnectionOr;
bool bNextConnectionOr;
bool bConditionSourceRange;
- Stack aConnectionOrStack;
+ std::vector<bool> maOrConnectionStack;
const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
@@ -84,8 +86,8 @@ public:
virtual void EndElement();
void SetCaseSensitive(const bool b);
- void SetUseRegularExpressions(bool bTemp);
- void OpenConnection(bool bTemp);
+ void SetUseRegularExpressions(bool b);
+ void OpenConnection(bool b);
void CloseConnection();
bool GetConnection();
void AddFilterField(const com::sun::star::sheet::TableFilterField2& aFilterField);
commit bbf435963eac44bc70c6a22605729b2d3f5417bf
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Thu Nov 17 13:09:54 2011 -0500
Removed pointless inlining of methods.
diff --git a/sc/source/filter/xml/xmlfilti.cxx b/sc/source/filter/xml/xmlfilti.cxx
index 7eb44cf..5338917 100644
--- a/sc/source/filter/xml/xmlfilti.cxx
+++ b/sc/source/filter/xml/xmlfilti.cxx
@@ -176,6 +176,42 @@ void ScXMLFilterContext::SetCaseSensitive(bool b)
mrQueryParam.bCaseSens = b;
}
+void ScXMLFilterContext::SetUseRegularExpressions(bool bTemp)
+{
+ if (!bUseRegularExpressions)
+ bUseRegularExpressions = bTemp;
+}
+
+void ScXMLFilterContext::OpenConnection(bool bTemp)
+{
+ bool* pTemp = new bool;
+ *pTemp = bConnectionOr;
+ bConnectionOr = bNextConnectionOr;
+ bNextConnectionOr = bTemp;
+ aConnectionOrStack.Push(pTemp);
+}
+
+void ScXMLFilterContext::CloseConnection()
+{
+ bool* pTemp = static_cast <bool*> (aConnectionOrStack.Pop());
+ bConnectionOr = *pTemp;
+ bNextConnectionOr = *pTemp;
+ delete pTemp;
+}
+
+bool ScXMLFilterContext::GetConnection()
+{
+ bool bTemp = bConnectionOr;
+ bConnectionOr = bNextConnectionOr;
+ return bTemp;
+}
+
+void ScXMLFilterContext::AddFilterField(const sheet::TableFilterField2& aFilterField)
+{
+ aFilterFields.realloc(aFilterFields.getLength() + 1);
+ aFilterFields[aFilterFields.getLength() - 1] = aFilterField;
+}
+
ScXMLAndContext::ScXMLAndContext( ScXMLImport& rImport,
sal_uInt16 nPrfx,
const ::rtl::OUString& rLName,
diff --git a/sc/source/filter/xml/xmlfilti.hxx b/sc/source/filter/xml/xmlfilti.hxx
index 4759b73..4a8bb3a 100644
--- a/sc/source/filter/xml/xmlfilti.hxx
+++ b/sc/source/filter/xml/xmlfilti.hxx
@@ -84,14 +84,11 @@ public:
virtual void EndElement();
void SetCaseSensitive(const bool b);
- void SetUseRegularExpressions(const bool bTemp) { if (!bUseRegularExpressions) bUseRegularExpressions = bTemp;}
- void OpenConnection(const bool bTemp) { bool* pTemp = new bool; *pTemp = bConnectionOr;
- bConnectionOr = bNextConnectionOr; bNextConnectionOr = bTemp;
- aConnectionOrStack.Push(pTemp);}
- void CloseConnection() { bool* pTemp = static_cast <bool*> (aConnectionOrStack.Pop()); bConnectionOr = *pTemp; bNextConnectionOr = *pTemp; delete pTemp;}
- bool GetConnection() { bool bTemp = bConnectionOr; bConnectionOr = bNextConnectionOr; return bTemp; }
- void AddFilterField(const com::sun::star::sheet::TableFilterField2 aFilterField) { aFilterFields.realloc(aFilterFields.getLength() + 1);
- aFilterFields[aFilterFields.getLength() - 1] = aFilterField; }
+ void SetUseRegularExpressions(bool bTemp);
+ void OpenConnection(bool bTemp);
+ void CloseConnection();
+ bool GetConnection();
+ void AddFilterField(const com::sun::star::sheet::TableFilterField2& aFilterField);
};
class ScXMLAndContext : public SvXMLImportContext
commit 1249182e1cd1245b9aaff908a6937bbc9010ff90
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Thu Nov 17 13:01:24 2011 -0500
Store case sensitivity flag directly.
diff --git a/sc/source/filter/xml/xmldrani.cxx b/sc/source/filter/xml/xmldrani.cxx
index 42a52eb..0716111 100644
--- a/sc/source/filter/xml/xmldrani.cxx
+++ b/sc/source/filter/xml/xmldrani.cxx
@@ -149,7 +149,6 @@ ScXMLDatabaseRangeContext::ScXMLDatabaseRangeContext( ScXMLImport& rImport,
bSubTotalsEnabledUserList(false),
bSubTotalsAscending(true),
bFilterCopyOutputData(false),
- bFilterIsCaseSensitive(false),
bFilterSkipDuplicates(false),
bFilterUseRegularExpressions(false),
bFilterConditionSourceRange(false),
@@ -263,8 +262,8 @@ SvXMLImportContext *ScXMLDatabaseRangeContext::CreateChildContext( sal_uInt16 nP
break;
case XML_TOK_FILTER :
{
- pContext = new ScXMLFilterContext( GetScImport(), nPrefix,
- rLName, xAttrList, this);
+ pContext = new ScXMLFilterContext(
+ GetScImport(), nPrefix, rLName, xAttrList, *mpQueryParam, this);
}
break;
case XML_TOK_SORT :
@@ -348,7 +347,6 @@ ScDBData* ScXMLDatabaseRangeContext::ConvertToDBData(const OUString& rName)
mpQueryParam->nRow2 = aRange.aEnd.Row();
mpQueryParam->bInplace = !bFilterCopyOutputData;
- mpQueryParam->bCaseSens = bFilterIsCaseSensitive;
mpQueryParam->bDuplicate = !bFilterSkipDuplicates;
mpQueryParam->bRegExp = bFilterUseRegularExpressions;
mpQueryParam->nDestTab = aFilterOutputPosition.Sheet;
diff --git a/sc/source/filter/xml/xmldrani.hxx b/sc/source/filter/xml/xmldrani.hxx
index e9c45ea..9c4995e 100644
--- a/sc/source/filter/xml/xmldrani.hxx
+++ b/sc/source/filter/xml/xmldrani.hxx
@@ -107,7 +107,6 @@ class ScXMLDatabaseRangeContext : public SvXMLImportContext
bool bSubTotalsEnabledUserList;
bool bSubTotalsAscending;
bool bFilterCopyOutputData;
- bool bFilterIsCaseSensitive;
bool bFilterSkipDuplicates;
bool bFilterUseRegularExpressions;
bool bFilterConditionSourceRange;
@@ -149,7 +148,6 @@ public:
void AddSubTotalRule(const ScSubTotalRule& rRule) { aSubTotalRules.push_back(rRule); }
void SetSortSequence(const com::sun::star::uno::Sequence <com::sun::star::beans::PropertyValue>& aTempSortSequence) { aSortSequence = aTempSortSequence; }
void SetFilterCopyOutputData(const bool bTemp) { bFilterCopyOutputData = bTemp; }
- void SetFilterIsCaseSensitive(const bool bTemp) { bFilterIsCaseSensitive = bTemp; }
void SetFilterSkipDuplicates(const bool bTemp) { bFilterSkipDuplicates = bTemp; }
void SetFilterUseRegularExpressions(const bool bTemp) { bFilterUseRegularExpressions = bTemp; }
void SetFilterFields(const com::sun::star::uno::Sequence <com::sun::star::sheet::TableFilterField2>& aTemp) { aFilterFields = aTemp; }
diff --git a/sc/source/filter/xml/xmlfilti.cxx b/sc/source/filter/xml/xmlfilti.cxx
index d1417b3..7eb44cf 100644
--- a/sc/source/filter/xml/xmlfilti.cxx
+++ b/sc/source/filter/xml/xmlfilti.cxx
@@ -53,12 +53,13 @@ using ::com::sun::star::xml::sax::XAttributeList;
//------------------------------------------------------------------
ScXMLFilterContext::ScXMLFilterContext( ScXMLImport& rImport,
- sal_uInt16 nPrfx,
- const ::rtl::OUString& rLName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
+ sal_uInt16 nPrfx,
+ const rtl::OUString& rLName,
+ const Reference<XAttributeList>& xAttrList,
+ ScQueryParam& rParam,
ScXMLDatabaseRangeContext* pTempDatabaseRangeContext) :
SvXMLImportContext( rImport, nPrfx, rLName ),
+ mrQueryParam(rParam),
pDatabaseRangeContext(pTempDatabaseRangeContext),
aFilterFields(),
bSkipDuplicates(false),
@@ -164,13 +165,17 @@ void ScXMLFilterContext::EndElement()
}
else
pDatabaseRangeContext->SetFilterCopyOutputData(false);
- pDatabaseRangeContext->SetFilterIsCaseSensitive(bIsCaseSensitive);
pDatabaseRangeContext->SetFilterSkipDuplicates(bSkipDuplicates);
pDatabaseRangeContext->SetFilterFields(aFilterFields);
if (bConditionSourceRange)
pDatabaseRangeContext->SetFilterConditionSourceRangeAddress(aConditionSourceRangeAddress);
}
+void ScXMLFilterContext::SetCaseSensitive(bool b)
+{
+ mrQueryParam.bCaseSens = b;
+}
+
ScXMLAndContext::ScXMLAndContext( ScXMLImport& rImport,
sal_uInt16 nPrfx,
const ::rtl::OUString& rLName,
@@ -410,7 +415,7 @@ void ScXMLConditionContext::EndElement()
aFilterField.Connection = sheet::FilterConnection_OR;
else
aFilterField.Connection = sheet::FilterConnection_AND;
- pFilterContext->SetIsCaseSensitive(bIsCaseSensitive);
+ pFilterContext->SetCaseSensitive(bIsCaseSensitive);
bool bUseRegularExpressions;
getOperatorXML(sOperator, aFilterField.Operator, bUseRegularExpressions);
pFilterContext->SetUseRegularExpressions(bUseRegularExpressions);
diff --git a/sc/source/filter/xml/xmlfilti.hxx b/sc/source/filter/xml/xmlfilti.hxx
index 90c7472..4759b73 100644
--- a/sc/source/filter/xml/xmlfilti.hxx
+++ b/sc/source/filter/xml/xmlfilti.hxx
@@ -42,9 +42,11 @@
#include "xmldpimp.hxx"
class ScXMLImport;
+struct ScQueryParam;
class ScXMLFilterContext : public SvXMLImportContext
{
+ ScQueryParam& mrQueryParam;
ScXMLDatabaseRangeContext* pDatabaseRangeContext;
com::sun::star::uno::Sequence <com::sun::star::sheet::TableFilterField2> aFilterFields;
@@ -54,7 +56,6 @@ class ScXMLFilterContext : public SvXMLImportContext
bool bSkipDuplicates;
bool bCopyOutputData;
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list