diff -urp --exclude=CVS --exclude=unxlngi6.pro --exclude=sc.vpj sc.clean/inc/dbcolect.hxx sc/inc/dbcolect.hxx --- sc.clean/inc/dbcolect.hxx 2008-03-03 11:24:43.000000000 -0500 +++ sc/inc/dbcolect.hxx 2008-03-05 11:52:43.000000000 -0500 @@ -115,6 +115,7 @@ private: ScQueryConnect eQueryConnect[MAXQUERY]; BOOL bIsAdvanced; // TRUE if created by advanced filter ScRange aAdvSource; // source range + SCROW nDynamicEndRow; // SubTotalParam BOOL bSubRemoveOnly; BOOL bSubReplace; @@ -165,9 +166,10 @@ public: const String& GetName() const { return aName; } void GetName(String& rName) const { rName = aName; } void SetName(const String& rName) { aName = rName; } - void GetArea(SCTAB& rTab, SCCOL& rCol1, SCROW& rRow1, SCCOL& rCol2, SCROW& rRow2) const; - SC_DLLPUBLIC void GetArea(ScRange& rRange) const; + void GetArea(SCTAB& rTab, SCCOL& rCol1, SCROW& rRow1, SCCOL& rCol2, SCROW& rRow2, bool bUseDynamicRange = false) const; + SC_DLLPUBLIC void GetArea(ScRange& rRange, bool bUseDynamicRange = false) const; void SetArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2); + void SetDynamicEndRow(SCROW nRow); void MoveTo(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2); BOOL IsByRow() const { return bByRow; } void SetByRow(BOOL bByR) { bByRow = bByR; } diff -urp --exclude=CVS --exclude=unxlngi6.pro --exclude=sc.vpj sc.clean/inc/document.hxx sc/inc/document.hxx --- sc.clean/inc/document.hxx 2008-03-03 11:24:43.000000000 -0500 +++ sc/inc/document.hxx 2008-03-05 11:47:35.000000000 -0500 @@ -864,7 +864,7 @@ SC_DLLPUBLIC ScDBCollection* GetDBCollec USHORT GetErrCode( const ScAddress& ) const; void GetDataArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow, - SCCOL& rEndCol, SCROW& rEndRow, BOOL bIncludeOld ); + SCCOL& rEndCol, SCROW& rEndRow, BOOL bIncludeOld ) const; BOOL GetCellArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow ) const; BOOL GetTableArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow ) const; BOOL GetPrintArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow, @@ -1381,6 +1381,9 @@ SC_DLLPUBLIC SvNumberFormatter* GetForma SCTAB nTab, ScQueryParam& rQueryParam ); void GetUpperCellString(SCCOL nCol, SCROW nRow, SCTAB nTab, String& rStr); + /** Update the dynamic end row position of a current data area. */ + void UpdateDynamicEndRow(ScDBData& rDBData) const; + BOOL GetFilterEntries( SCCOL nCol, SCROW nRow, SCTAB nTab, TypedStrCollection& rStrings, bool bFilter = false ); SC_DLLPUBLIC BOOL GetFilterEntriesArea( SCCOL nCol, SCROW nStartRow, SCROW nEndRow, Only in sc/inc: document.hxx.orig diff -urp --exclude=CVS --exclude=unxlngi6.pro --exclude=sc.vpj sc.clean/inc/global.hxx sc/inc/global.hxx --- sc.clean/inc/global.hxx 2008-03-03 11:24:43.000000000 -0500 +++ sc/inc/global.hxx 2008-03-05 00:52:49.000000000 -0500 @@ -932,6 +932,8 @@ struct SC_DLLPUBLIC ScQueryParam SCTAB nDestTab; SCCOL nDestCol; SCROW nDestRow; + SCROW nDynamicEndRow; + bool bUseDynamicRange; private: SCSIZE nEntryCount; diff -urp --exclude=CVS --exclude=unxlngi6.pro --exclude=sc.vpj sc.clean/inc/table.hxx sc/inc/table.hxx --- sc.clean/inc/table.hxx 2008-03-03 11:24:44.000000000 -0500 +++ sc/inc/table.hxx 2008-03-05 00:52:16.000000000 -0500 @@ -355,7 +355,7 @@ public: SCCOL nStartCol, SCROW nStartRow, SCCOL& rEndCol, SCROW nEndRow ); void GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow, - BOOL bIncludeOld ); + BOOL bIncludeOld ) const; SCSIZE GetEmptyLinesInBlock( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, ScDirection eDir ); diff -urp --exclude=CVS --exclude=unxlngi6.pro --exclude=sc.vpj sc.clean/source/core/data/documen3.cxx sc/source/core/data/documen3.cxx --- sc.clean/source/core/data/documen3.cxx 2008-03-03 11:24:50.000000000 -0500 +++ sc/source/core/data/documen3.cxx 2008-03-05 11:47:22.000000000 -0500 @@ -1282,6 +1282,18 @@ BOOL ScDocument::HasRowHeader( SCCOL nSt // GetFilterEntries - Eintraege fuer AutoFilter-Listbox // +void ScDocument::UpdateDynamicEndRow(ScDBData& rDBData) const +{ + SCCOL nCol1, nCol2; + SCROW nRow1, nRow2; + SCTAB nTab; + rDBData.GetArea(nTab, nCol1, nRow1, nCol2, nRow2); + SCCOL nCol1a = nCol1, nCol2a = nCol2; + SCROW nRow1a = nRow1, nRow2a = nRow2; + GetDataArea(nTab, nCol1a, nRow1a, nCol2a, nRow2a, false); + rDBData.SetDynamicEndRow(nRow2a); +} + BOOL ScDocument::GetFilterEntries( SCCOL nCol, SCROW nRow, SCTAB nTab, TypedStrCollection& rStrings, bool bFilter ) { if ( ValidTab(nTab) && pTab[nTab] && pDBCollection ) @@ -1289,6 +1301,7 @@ BOOL ScDocument::GetFilterEntries( SCCOL ScDBData* pDBData = pDBCollection->GetDBAtCursor(nCol, nRow, nTab, FALSE); //!?? if (pDBData) { + UpdateDynamicEndRow(*pDBData); SCTAB nAreaTab; SCCOL nStartCol; SCROW nStartRow; @@ -1300,6 +1313,7 @@ BOOL ScDocument::GetFilterEntries( SCCOL ScQueryParam aParam; pDBData->GetQueryParam( aParam ); + nEndRow = aParam.nDynamicEndRow; rStrings.SetCaseSensitive( aParam.bCaseSens ); // return all filter entries, if a filter condition is connected with a boolean OR Only in sc/source/core/data: documen3.cxx.orig diff -urp --exclude=CVS --exclude=unxlngi6.pro --exclude=sc.vpj sc.clean/source/core/data/document.cxx sc/source/core/data/document.cxx --- sc.clean/source/core/data/document.cxx 2008-03-03 11:24:50.000000000 -0500 +++ sc/source/core/data/document.cxx 2008-03-04 22:23:36.000000000 -0500 @@ -584,7 +584,7 @@ BOOL ScDocument::GetTableArea( SCTAB nTa // zusammenhaengender Bereich void ScDocument::GetDataArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow, - SCCOL& rEndCol, SCROW& rEndRow, BOOL bIncludeOld ) + SCCOL& rEndCol, SCROW& rEndRow, BOOL bIncludeOld ) const { if (VALIDTAB(nTab)) if (pTab[nTab]) Only in sc/source/core/data: document.cxx.orig diff -urp --exclude=CVS --exclude=unxlngi6.pro --exclude=sc.vpj sc.clean/source/core/data/global2.cxx sc/source/core/data/global2.cxx --- sc.clean/source/core/data/global2.cxx 2008-03-03 11:24:50.000000000 -0500 +++ sc/source/core/data/global2.cxx 2008-03-05 00:56:41.000000000 -0500 @@ -295,7 +295,8 @@ ScQueryParam::ScQueryParam( const ScQuer bHasHeader(r.bHasHeader), bByRow(r.bByRow), bInplace(r.bInplace), bCaseSens(r.bCaseSens), bRegExp(r.bRegExp), bMixedComparison(r.bMixedComparison), bDuplicate(r.bDuplicate), bDestPers(r.bDestPers), - nDestTab(r.nDestTab), nDestCol(r.nDestCol), nDestRow(r.nDestRow) + nDestTab(r.nDestTab), nDestCol(r.nDestCol), nDestRow(r.nDestRow), + nDynamicEndRow(r.nDynamicEndRow), bUseDynamicRange(r.bUseDynamicRange) { nEntryCount = 0; @@ -321,6 +322,8 @@ void ScQueryParam::Clear() nTab = SCTAB_MAX; bHasHeader = bCaseSens = bRegExp = bMixedComparison = FALSE; bInplace = bByRow = bDuplicate = bDestPers = TRUE; + nDynamicEndRow = 0; + bUseDynamicRange = false; Resize( MAXQUERY ); for (USHORT i=0; i( nCol2 + nDifX ); nRow2 = sal::static_int_cast( nRow2 + nDifY ); nTab = sal::static_int_cast( nTab + nDifZ ); + nDynamicEndRow = sal::static_int_cast( nDynamicEndRow + nDifY ); for (USHORT i=0; iGetDocShell(); ScDBData* pData = NULL; @@ -124,11 +124,20 @@ ScDBData* ScDBFunc::GetDBData( BOOL bMar ScRange( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() ), eMode, FALSE ); + if (!pData) + return NULL; - if ( pData && bMark ) + if (bExpandRows) + { + // Dynamically expand rows to include any new data rows that are + // immediately below the original range. + GetViewData()->GetDocument()->UpdateDynamicEndRow(*pData); + } + + if (bMark) { ScRange aFound; - pData->GetArea(aFound); + pData->GetArea(aFound, bExpandRows); MarkRange( aFound, FALSE ); } return pData; diff -urp --exclude=CVS --exclude=unxlngi6.pro --exclude=sc.vpj sc.clean/source/ui/view/gridwin.cxx sc/source/ui/view/gridwin.cxx --- sc.clean/source/ui/view/gridwin.cxx 2008-03-03 11:24:49.000000000 -0500 +++ sc/source/ui/view/gridwin.cxx 2008-03-05 11:12:33.000000000 -0500 @@ -1224,6 +1224,7 @@ void ScGridWindow::ExecFilter( ULONG nSe pViewData->GetViewShell()->UpdateInputHandler(); } + aParam.bUseDynamicRange = true; pViewData->GetView()->Query( aParam, NULL, TRUE ); pDBData->SetQueryParam( aParam ); // speichern } diff -urp --exclude=CVS --exclude=unxlngi6.pro --exclude=sc.vpj sc.clean/source/ui/view/tabvwshc.cxx sc/source/ui/view/tabvwshc.cxx --- sc.clean/source/ui/view/tabvwshc.cxx 2008-03-03 11:24:49.000000000 -0500 +++ sc/source/ui/view/tabvwshc.cxx 2008-03-05 11:43:37.000000000 -0500 @@ -195,8 +195,9 @@ SfxModelessDialog* ScTabViewShell::Creat SCITEM_QUERYDATA, SCITEM_QUERYDATA ); - ScDBData* pDBData = GetDBData(); + ScDBData* pDBData = GetDBData(true, SC_DB_MAKE, true); pDBData->GetQueryParam( aQueryParam ); + aQueryParam.bUseDynamicRange = true; ScQueryItem aItem( SCITEM_QUERYDATA, GetViewData(), &aQueryParam ); ScRange aAdvSource; @@ -220,8 +221,9 @@ SfxModelessDialog* ScTabViewShell::Creat SCITEM_QUERYDATA, SCITEM_QUERYDATA ); - ScDBData* pDBData = GetDBData(); + ScDBData* pDBData = GetDBData(true, SC_DB_MAKE, true); pDBData->GetQueryParam( aQueryParam ); + aQueryParam.bUseDynamicRange = true; aArgSet.Put( ScQueryItem( SCITEM_QUERYDATA, GetViewData(), Only in sc/source/ui/view: tabvwshc.cxx.orig