summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens-Heiner Rechtien <hr@openoffice.org>2010-04-16 10:27:47 +0200
committerJens-Heiner Rechtien <hr@openoffice.org>2010-04-16 10:27:47 +0200
commit8a241125de5db7c23fba21e491d68d7834ebcac7 (patch)
tree3b565a46bf90ab75c6da792e0fda946b7d044e98
parent8bd51f02a305446c85cec058797a75bf59d60c4d (diff)
parent19e19bafa255e9ff6daa0b9504eaa88cf1bfa4fa (diff)
CWS-TOOLING: integrate CWS calcfilterrange
-rw-r--r--sc/inc/document.hxx11
-rw-r--r--sc/inc/global.hxx23
-rw-r--r--sc/inc/table.hxx4
-rw-r--r--sc/source/core/data/document.cxx12
-rw-r--r--sc/source/core/data/table1.cxx138
-rw-r--r--[-rwxr-xr-x]sc/source/core/tool/interpr4.cxx2
-rw-r--r--sc/source/ui/docshell/dbdocfun.cxx4
-rw-r--r--sc/source/ui/docshell/dbdocimp.cxx2
-rw-r--r--sc/source/ui/docshell/docsh4.cxx2
-rw-r--r--sc/source/ui/docshell/docsh5.cxx37
-rw-r--r--sc/source/ui/inc/dbfunc.hxx2
-rw-r--r--sc/source/ui/inc/docsh.hxx2
-rw-r--r--sc/source/ui/unoobj/cellsuno.cxx22
-rw-r--r--sc/source/ui/unoobj/cursuno.cxx6
-rw-r--r--sc/source/ui/view/cellsh2.cxx2
-rw-r--r--sc/source/ui/view/dbfunc.cxx73
-rw-r--r--sc/source/ui/view/tabview3.cxx2
-rw-r--r--sc/source/ui/view/tabvwshc.cxx4
-rw-r--r--sc/source/ui/view/viewfun5.cxx2
19 files changed, 264 insertions, 86 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 6f083a1fc199..17ec77b0f9a7 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -896,10 +896,17 @@ public:
USHORT GetErrCode( const ScAddress& ) const;
- bool ShrinkToDataArea(SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow) const;
+ /** Shrink a range to only include data area.
+ This is not the actually used area within the
+ selection, but the bounds of the sheet's data area
+ instead. */
+ bool ShrinkToDataArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow ) const;
+
+ /** Shrink a range to only include used data area. */
+ bool ShrinkToUsedDataArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow, bool bColumnsOnly ) const;
void GetDataArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow,
- SCCOL& rEndCol, SCROW& rEndRow, BOOL bIncludeOld );
+ SCCOL& rEndCol, SCROW& rEndRow, BOOL bIncludeOld, bool bOnlyDown );
SC_DLLPUBLIC BOOL GetCellArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow ) const;
SC_DLLPUBLIC BOOL GetTableArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow ) const;
SC_DLLPUBLIC BOOL GetPrintArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow,
diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx
index 185113e77389..b85205741334 100644
--- a/sc/inc/global.hxx
+++ b/sc/inc/global.hxx
@@ -414,6 +414,29 @@ enum ScGetDBMode
SC_DB_OLD // nicht neu anlegen
};
+/// For ScDBFunc::GetDBData()
+enum ScGetDBSelection
+{
+ /** Keep selection as is, expand to used data area if no selection. */
+ SC_DBSEL_KEEP,
+
+ /** Shrink selection to sheet's data area. */
+ SC_DBSEL_SHRINK_TO_SHEET_DATA,
+
+ /** Shrink selection to actually used data area within the selection. */
+ SC_DBSEL_SHRINK_TO_USED_DATA,
+
+ /** If only one row or portion thereof is selected, shrink row to used data
+ columns and select further rows down until end of data. If an area is
+ selected, shrink rows to actually used columns. Else, no selection,
+ expand to used data area. */
+ SC_DBSEL_ROW_DOWN,
+
+ /** Behave as if the range corresponding to a ScDBData area was selected,
+ for API use. */
+ SC_DBSEL_FORCE_MARK
+};
+
enum ScLkUpdMode
{ //Verknuepfungen
LM_ALWAYS, //immer aktualisieren
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index bbf900f40c62..442e908542f3 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -380,7 +380,9 @@ public:
SCCOL nStartCol, SCROW nStartRow, SCCOL& rEndCol, SCROW nEndRow );
void GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow,
- BOOL bIncludeOld );
+ BOOL bIncludeOld, bool bOnlyDown ) const;
+
+ bool ShrinkToUsedDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow, bool bColumnsOnly ) const;
SCSIZE GetEmptyLinesInBlock( SCCOL nStartCol, SCROW nStartRow,
SCCOL nEndCol, SCROW nEndRow, ScDirection eDir );
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 149680a194ae..3f25ad5a310e 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -696,14 +696,22 @@ bool ScDocument::ShrinkToDataArea(SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow
return true; // success!
}
+bool ScDocument::ShrinkToUsedDataArea( SCTAB nTab, SCCOL& rStartCol,
+ SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow, bool bColumnsOnly ) const
+{
+ if (!ValidTab(nTab) || !pTab[nTab])
+ return false;
+ return pTab[nTab]->ShrinkToUsedDataArea( rStartCol, rStartRow, rEndCol, rEndRow, bColumnsOnly);
+}
+
// zusammenhaengender Bereich
void ScDocument::GetDataArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow,
- SCCOL& rEndCol, SCROW& rEndRow, BOOL bIncludeOld )
+ SCCOL& rEndCol, SCROW& rEndRow, BOOL bIncludeOld, bool bOnlyDown )
{
if (VALIDTAB(nTab))
if (pTab[nTab])
- pTab[nTab]->GetDataArea( rStartCol, rStartRow, rEndCol, rEndRow, bIncludeOld );
+ pTab[nTab]->GetDataArea( rStartCol, rStartRow, rEndCol, rEndRow, bIncludeOld, bOnlyDown );
}
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index d220ec42eadf..f8cf1489f3aa 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -683,7 +683,7 @@ BOOL ScTable::GetDataStart( SCCOL& rStartCol, SCROW& rStartRow ) const
}
void ScTable::GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow,
- BOOL bIncludeOld )
+ BOOL bIncludeOld, bool bOnlyDown ) const
{
BOOL bLeft = FALSE;
BOOL bRight = FALSE;
@@ -698,26 +698,44 @@ void ScTable::GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, S
{
bChanged = FALSE;
- SCROW nStart = rStartRow;
- SCROW nEnd = rEndRow;
- if (nStart>0) --nStart;
- if (nEnd<MAXROW) ++nEnd;
+ if (!bOnlyDown)
+ {
+ SCROW nStart = rStartRow;
+ SCROW nEnd = rEndRow;
+ if (nStart>0) --nStart;
+ if (nEnd<MAXROW) ++nEnd;
- if (rEndCol < MAXCOL)
- if (!aCol[rEndCol+1].IsEmptyBlock(nStart,nEnd))
- {
- ++rEndCol;
- bChanged = TRUE;
- bRight = TRUE;
- }
+ if (rEndCol < MAXCOL)
+ if (!aCol[rEndCol+1].IsEmptyBlock(nStart,nEnd))
+ {
+ ++rEndCol;
+ bChanged = TRUE;
+ bRight = TRUE;
+ }
- if (rStartCol > 0)
- if (!aCol[rStartCol-1].IsEmptyBlock(nStart,nEnd))
+ if (rStartCol > 0)
+ if (!aCol[rStartCol-1].IsEmptyBlock(nStart,nEnd))
+ {
+ --rStartCol;
+ bChanged = TRUE;
+ bLeft = TRUE;
+ }
+
+ if (rStartRow > 0)
{
- --rStartCol;
- bChanged = TRUE;
- bLeft = TRUE;
+ nTest = rStartRow-1;
+ bFound = FALSE;
+ for (i=rStartCol; i<=rEndCol && !bFound; i++)
+ if (aCol[i].HasDataAt(nTest))
+ bFound = TRUE;
+ if (bFound)
+ {
+ --rStartRow;
+ bChanged = TRUE;
+ bTop = TRUE;
+ }
}
+ }
if (rEndRow < MAXROW)
{
@@ -733,21 +751,6 @@ void ScTable::GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, S
bBottom = TRUE;
}
}
-
- if (rStartRow > 0)
- {
- nTest = rStartRow-1;
- bFound = FALSE;
- for (i=rStartCol; i<=rEndCol && !bFound; i++)
- if (aCol[i].HasDataAt(nTest))
- bFound = TRUE;
- if (bFound)
- {
- --rStartRow;
- bChanged = TRUE;
- bTop = TRUE;
- }
- }
}
while( bChanged );
@@ -780,6 +783,77 @@ void ScTable::GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, S
}
}
+
+bool ScTable::ShrinkToUsedDataArea( SCCOL& rStartCol, SCROW& rStartRow,
+ SCCOL& rEndCol, SCROW& rEndRow, bool bColumnsOnly ) const
+{
+ bool bRet = false;
+ bool bChanged;
+
+ do
+ {
+ bChanged = false;
+
+ bool bCont = true;
+ while (rEndCol > 0 && bCont && rStartCol < rEndCol)
+ {
+ if (aCol[rEndCol].IsEmptyBlock( rStartRow, rEndRow))
+ {
+ --rEndCol;
+ bChanged = true;
+ }
+ else
+ bCont = false;
+ }
+
+ bCont = true;
+ while (rStartCol < MAXCOL && bCont && rStartCol < rEndCol)
+ {
+ if (aCol[rStartCol].IsEmptyBlock( rStartRow, rEndRow))
+ {
+ ++rStartCol;
+ bChanged = true;
+ }
+ else
+ bCont = false;
+ }
+
+ if (!bColumnsOnly)
+ {
+ if (rStartRow < MAXROW && rStartRow < rEndRow)
+ {
+ bool bFound = false;
+ for (SCCOL i=rStartCol; i<=rEndCol && !bFound; i++)
+ if (aCol[i].HasDataAt( rStartRow))
+ bFound = true;
+ if (!bFound)
+ {
+ ++rStartRow;
+ bChanged = true;
+ }
+ }
+
+ if (rEndRow > 0 && rStartRow < rEndRow)
+ {
+ bool bFound = false;
+ for (SCCOL i=rStartCol; i<=rEndCol && !bFound; i++)
+ if (aCol[i].HasDataAt( rEndRow))
+ bFound = true;
+ if (!bFound)
+ {
+ --rEndRow;
+ bChanged = true;
+ }
+ }
+ }
+
+ if (bChanged)
+ bRet = true;
+ } while( bChanged );
+ return bRet;
+}
+
+
SCSIZE ScTable::GetEmptyLinesInBlock( SCCOL nStartCol, SCROW nStartRow,
SCCOL nEndCol, SCROW nEndRow, ScDirection eDir )
{
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 8a6c0df0db16..ffba9aafc511 100755..100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -3115,7 +3115,7 @@ void ScInterpreter::ScColRowNameAuto()
(SCROW&) aRefData.Ref1.nRow,
(SCCOL&) aRefData.Ref2.nCol,
(SCROW&) aRefData.Ref2.nRow,
- TRUE );
+ TRUE, false );
// DataArea im Ursprung begrenzen
aRefData.Ref1.nCol = nStartCol;
aRefData.Ref1.nRow = nStartRow;
diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx
index 2053cebc8ce5..9895f0f43610 100644
--- a/sc/source/ui/docshell/dbdocfun.cxx
+++ b/sc/source/ui/docshell/dbdocfun.cxx
@@ -593,7 +593,7 @@ BOOL ScDBDocFunc::Sort( SCTAB nTab, const ScSortParam& rSortParam,
if (pDestData)
pNewData = pDestData; // Bereich vorhanden -> anpassen
else // Bereich ab Cursor/Markierung wird angelegt
- pNewData = rDocShell.GetDBData(aDestPos, SC_DB_MAKE, TRUE );
+ pNewData = rDocShell.GetDBData(aDestPos, SC_DB_MAKE, SC_DBSEL_FORCE_MARK );
if (pNewData)
{
pNewData->SetArea( nTab,
@@ -920,7 +920,7 @@ BOOL ScDBDocFunc::Query( SCTAB nTab, const ScQueryParam& rQueryParam,
pNewData = rDocShell.GetDBData(
ScRange( aLocalParam.nCol1, aLocalParam.nRow1, nDestTab,
aLocalParam.nCol2, aLocalParam.nRow2, nDestTab ),
- SC_DB_MAKE, TRUE );
+ SC_DB_MAKE, SC_DBSEL_FORCE_MARK );
if (pNewData)
{
diff --git a/sc/source/ui/docshell/dbdocimp.cxx b/sc/source/ui/docshell/dbdocimp.cxx
index be856ec9240b..a073e50d105c 100644
--- a/sc/source/ui/docshell/dbdocimp.cxx
+++ b/sc/source/ui/docshell/dbdocimp.cxx
@@ -189,7 +189,7 @@ BOOL ScDBDocFunc::DoImportUno( const ScAddress& rPos,
// create database range
//! merge this with SID_SBA_IMPORT execute in docsh4.cxx
- ScDBData* pDBData = rDocShell.GetDBData( ScRange(rPos), SC_DB_IMPORT, FALSE );
+ ScDBData* pDBData = rDocShell.GetDBData( ScRange(rPos), SC_DB_IMPORT, SC_DBSEL_KEEP );
DBG_ASSERT(pDBData, "can't create DB data");
String sTarget = pDBData->GetName();
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index 26d61a82c6be..157b98497e83 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -264,7 +264,7 @@ void ScDocShell::Execute( SfxRequest& rReq )
GetUndoManager()->EnterListAction( aStrImport, aStrImport );
}
- ScDBData* pDBData = GetDBData( ScRange(aPos), SC_DB_IMPORT, FALSE );
+ ScDBData* pDBData = GetDBData( ScRange(aPos), SC_DB_IMPORT, SC_DBSEL_KEEP );
DBG_ASSERT(pDBData, "kann DB-Daten nicht anlegen");
sTarget = pDBData->GetName();
}
diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx
index 6fa6a5ac7863..1bbf9437bc1c 100644
--- a/sc/source/ui/docshell/docsh5.cxx
+++ b/sc/source/ui/docshell/docsh5.cxx
@@ -148,7 +148,7 @@ ScDBData* lcl_GetDBNearCursor( ScDBCollection* pColl, SCCOL nCol, SCROW nRow, SC
return pNoNameData; // "unbenannt" nur zurueck, wenn sonst nichts gefunden
}
-ScDBData* ScDocShell::GetDBData( const ScRange& rMarked, ScGetDBMode eMode, BOOL bForceMark )
+ScDBData* ScDocShell::GetDBData( const ScRange& rMarked, ScGetDBMode eMode, ScGetDBSelection eSel )
{
SCCOL nCol = rMarked.aStart.Col();
SCROW nRow = rMarked.aStart.Row();
@@ -169,7 +169,9 @@ ScDBData* ScDocShell::GetDBData( const ScRange& rMarked, ScGetDBMode eMode, BOOL
if (!pData)
pData = lcl_GetDBNearCursor( aDocument.GetDBCollection(), nCol, nRow, nTab );
- BOOL bSelected = ( bForceMark || rMarked.aStart != rMarked.aEnd );
+ BOOL bSelected = ( eSel == SC_DBSEL_FORCE_MARK ||
+ (rMarked.aStart != rMarked.aEnd && eSel != SC_DBSEL_ROW_DOWN) );
+ bool bOnlyDown = (!bSelected && eSel == SC_DBSEL_ROW_DOWN && rMarked.aStart.Row() == rMarked.aEnd.Row());
BOOL bUseThis = FALSE;
if (pData)
@@ -189,12 +191,21 @@ ScDBData* ScDocShell::GetDBData( const ScRange& rMarked, ScGetDBMode eMode, BOOL
bUseThis = TRUE;
if ( bIsNoName && eMode == SC_DB_MAKE )
{
- // wenn nichts markiert, "unbenannt" auf zusammenhaengenden Bereich anpassen
+ // If nothing marked or only one row marked, adapt
+ // "unbenannt"/"unnamed" to contiguous area.
nStartCol = nCol;
nStartRow = nRow;
- nEndCol = nStartCol;
- nEndRow = nStartRow;
- aDocument.GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow, FALSE );
+ if (bOnlyDown)
+ {
+ nEndCol = rMarked.aEnd.Col();
+ nEndRow = rMarked.aEnd.Row();
+ }
+ else
+ {
+ nEndCol = nStartCol;
+ nEndRow = nStartRow;
+ }
+ aDocument.GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow, FALSE, bOnlyDown );
if ( nOldCol1 != nStartCol || nOldCol2 != nEndCol || nOldRow1 != nStartRow )
bUseThis = FALSE; // passt gar nicht
else if ( nOldRow2 != nEndRow )
@@ -242,9 +253,17 @@ ScDBData* ScDocShell::GetDBData( const ScRange& rMarked, ScGetDBMode eMode, BOOL
{ // zusammenhaengender Bereich
nStartCol = nCol;
nStartRow = nRow;
- nEndCol = nStartCol;
- nEndRow = nStartRow;
- aDocument.GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow, FALSE );
+ if (bOnlyDown)
+ {
+ nEndCol = rMarked.aEnd.Col();
+ nEndRow = rMarked.aEnd.Row();
+ }
+ else
+ {
+ nEndCol = nStartCol;
+ nEndRow = nStartRow;
+ }
+ aDocument.GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow, FALSE, bOnlyDown );
}
BOOL bHasHeader = aDocument.HasColHeader( nStartCol,nStartRow, nEndCol,nEndRow, nTab );
diff --git a/sc/source/ui/inc/dbfunc.hxx b/sc/source/ui/inc/dbfunc.hxx
index be206b396733..baadae0a64dc 100644
--- a/sc/source/ui/inc/dbfunc.hxx
+++ b/sc/source/ui/inc/dbfunc.hxx
@@ -77,7 +77,7 @@ public:
void GotoDBArea( const String& rDBName );
// DB-Bereich vom Cursor
- ScDBData* GetDBData( BOOL bMarkArea = TRUE, ScGetDBMode eMode = SC_DB_MAKE, bool bShrinkToData = false );
+ ScDBData* GetDBData( BOOL bMarkArea = TRUE, ScGetDBMode eMode = SC_DB_MAKE, ScGetDBSelection eSel = SC_DBSEL_KEEP );
void NotifyCloseDbNameDlg( const ScDBCollection& rNewColl, const List& rDelAreaList );
diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx
index 88bbeb699539..09d34c661995 100644
--- a/sc/source/ui/inc/docsh.hxx
+++ b/sc/source/ui/inc/docsh.hxx
@@ -313,7 +313,7 @@ public:
BOOL IsOle();
void DBAreaDeleted( SCTAB nTab, SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2 );
- ScDBData* GetDBData( const ScRange& rMarked, ScGetDBMode eMode, BOOL bForceMark );
+ ScDBData* GetDBData( const ScRange& rMarked, ScGetDBMode eMode, ScGetDBSelection eSel );
ScDBData* GetOldAutoDBRange(); // has to be deleted by caller!
void CancelAutoDBRange(); // called when dialog is cancelled
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index c61a6443af99..4eddb447e8a9 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -5515,7 +5515,7 @@ uno::Sequence<beans::PropertyValue> SAL_CALL ScCellRangeObj::createSortDescripto
if ( pDocSh )
{
// DB-Bereich anlegen erst beim Ausfuehren, per API immer genau den Bereich
- ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, TRUE );
+ ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
if (pData)
{
pData->GetSortParam(aParam);
@@ -5546,7 +5546,7 @@ void SAL_CALL ScCellRangeObj::sort( const uno::Sequence<beans::PropertyValue>& a
{
USHORT i;
ScSortParam aParam;
- ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_MAKE, TRUE ); // ggf. Bereich anlegen
+ ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
if (pData)
{
// alten Einstellungen holen, falls nicht alles neu gesetzt wird
@@ -5575,7 +5575,7 @@ void SAL_CALL ScCellRangeObj::sort( const uno::Sequence<beans::PropertyValue>& a
aParam.nCol2 = aRange.aEnd.Col();
aParam.nRow2 = aRange.aEnd.Row();
- pDocSh->GetDBData( aRange, SC_DB_MAKE, TRUE ); // ggf. Bereich anlegen
+ pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
ScDBDocFunc aFunc(*pDocSh); // Bereich muss angelegt sein
aFunc.Sort( nTab, aParam, TRUE, TRUE, TRUE );
@@ -5593,7 +5593,7 @@ uno::Reference<sheet::XSheetFilterDescriptor> SAL_CALL ScCellRangeObj::createFil
if ( !bEmpty && pDocSh )
{
// DB-Bereich anlegen erst beim Ausfuehren, per API immer genau den Bereich
- ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, TRUE );
+ ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
if (pData)
{
ScQueryParam aParam;
@@ -5675,7 +5675,7 @@ void SAL_CALL ScCellRangeObj::filter( const uno::Reference<sheet::XSheetFilterDe
aParam.nCol2 = aRange.aEnd.Col();
aParam.nRow2 = aRange.aEnd.Row();
- pDocSh->GetDBData( aRange, SC_DB_MAKE, TRUE ); // ggf. Bereich anlegen
+ pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
//! keep source range in filter descriptor
//! if created by createFilterDescriptorByObject ???
@@ -5762,7 +5762,7 @@ uno::Reference<sheet::XSubTotalDescriptor> SAL_CALL ScCellRangeObj::createSubTot
if ( !bEmpty && pDocSh )
{
// DB-Bereich anlegen erst beim Ausfuehren, per API immer genau den Bereich
- ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, TRUE );
+ ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
if (pData)
{
ScSubTotalParam aParam;
@@ -5825,7 +5825,7 @@ void SAL_CALL ScCellRangeObj::applySubTotals(
aParam.nCol2 = aRange.aEnd.Col();
aParam.nRow2 = aRange.aEnd.Row();
- pDocSh->GetDBData( aRange, SC_DB_MAKE, TRUE ); // ggf. Bereich anlegen
+ pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
ScDBDocFunc aFunc(*pDocSh);
aFunc.DoSubTotals( nTab, aParam, NULL, TRUE, TRUE ); // Bereich muss angelegt sein
@@ -5840,7 +5840,7 @@ void SAL_CALL ScCellRangeObj::removeSubTotals() throw(uno::RuntimeException)
if (pDocSh)
{
ScSubTotalParam aParam;
- ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, TRUE );
+ ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
if (pData)
pData->GetSubTotalParam(aParam); // auch bei Remove die Feld-Eintraege behalten
@@ -5852,7 +5852,7 @@ void SAL_CALL ScCellRangeObj::removeSubTotals() throw(uno::RuntimeException)
aParam.nCol2 = aRange.aEnd.Col();
aParam.nRow2 = aRange.aEnd.Row();
- pDocSh->GetDBData( aRange, SC_DB_MAKE, TRUE ); // ggf. Bereich anlegen
+ pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
ScDBDocFunc aFunc(*pDocSh);
aFunc.DoSubTotals( nTab, aParam, NULL, TRUE, TRUE ); // Bereich muss angelegt sein
@@ -5868,7 +5868,7 @@ uno::Sequence<beans::PropertyValue> SAL_CALL ScCellRangeObj::createImportDescrip
if ( !bEmpty && pDocSh )
{
// DB-Bereich anlegen erst beim Ausfuehren, per API immer genau den Bereich
- ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, TRUE );
+ ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
if (pData)
pData->GetImportParam(aParam);
}
@@ -5897,7 +5897,7 @@ void SAL_CALL ScCellRangeObj::doImport( const uno::Sequence<beans::PropertyValue
//! TODO: could we get passed a valid result set by any means?
uno::Reference< sdbc::XResultSet > xResultSet;
- pDocSh->GetDBData( aRange, SC_DB_MAKE, TRUE ); // ggf. Bereich anlegen
+ pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
ScDBDocFunc aFunc(*pDocSh); // Bereich muss angelegt sein
aFunc.DoImport( nTab, aParam, xResultSet, NULL, TRUE, FALSE ); //! Api-Flag als Parameter
diff --git a/sc/source/ui/unoobj/cursuno.cxx b/sc/source/ui/unoobj/cursuno.cxx
index 39ed859aa574..daf075964a3a 100644
--- a/sc/source/ui/unoobj/cursuno.cxx
+++ b/sc/source/ui/unoobj/cursuno.cxx
@@ -133,7 +133,7 @@ void SAL_CALL ScCellCursorObj::collapseToCurrentRegion() throw(uno::RuntimeExcep
SCTAB nTab = aOneRange.aStart.Tab();
pDocSh->GetDocument()->GetDataArea(
- nTab, nStartCol, nStartRow, nEndCol, nEndRow, TRUE );
+ nTab, nStartCol, nStartRow, nEndCol, nEndRow, TRUE, false );
ScRange aNew( nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab );
SetNewRange( aNew );
@@ -331,7 +331,7 @@ void SAL_CALL ScCellCursorObj::gotoStart() throw(uno::RuntimeException)
SCTAB nTab = aOneRange.aStart.Tab();
pDocSh->GetDocument()->GetDataArea(
- nTab, nStartCol, nStartRow, nEndCol, nEndRow, FALSE );
+ nTab, nStartCol, nStartRow, nEndCol, nEndRow, FALSE, false );
ScRange aNew( nStartCol, nStartRow, nTab );
SetNewRange( aNew );
@@ -359,7 +359,7 @@ void SAL_CALL ScCellCursorObj::gotoEnd() throw(uno::RuntimeException)
SCTAB nTab = aOneRange.aStart.Tab();
pDocSh->GetDocument()->GetDataArea(
- nTab, nStartCol, nStartRow, nEndCol, nEndRow, FALSE );
+ nTab, nStartCol, nStartRow, nEndCol, nEndRow, FALSE, false );
ScRange aNew( nEndCol, nEndRow, nTab );
SetNewRange( aNew );
diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx
index c082c6da375d..086160263739 100644
--- a/sc/source/ui/view/cellsh2.cxx
+++ b/sc/source/ui/view/cellsh2.cxx
@@ -161,7 +161,7 @@ BOOL lcl_GetSortParam( const ScViewData* pData, ScSortParam& rSortParam )
SCCOL nStartCol = aExternalRange.aStart.Col();
SCROW nEndRow = aExternalRange.aEnd.Row();
SCCOL nEndCol = aExternalRange.aEnd.Col();
- pDoc->GetDataArea( aExternalRange.aStart.Tab(), nStartCol, nStartRow, nEndCol, nEndRow, FALSE );
+ pDoc->GetDataArea( aExternalRange.aStart.Tab(), nStartCol, nStartRow, nEndCol, nEndRow, FALSE, false );
aExternalRange.aStart.SetRow( nStartRow );
aExternalRange.aStart.SetCol( nStartCol );
aExternalRange.aEnd.SetRow( nEndRow );
diff --git a/sc/source/ui/view/dbfunc.cxx b/sc/source/ui/view/dbfunc.cxx
index 02dfd77f7460..1e5a6b9da4ae 100644
--- a/sc/source/ui/view/dbfunc.cxx
+++ b/sc/source/ui/view/dbfunc.cxx
@@ -104,7 +104,7 @@ void ScDBFunc::GotoDBArea( const String& rDBName )
// aktuellen Datenbereich fuer Sortieren / Filtern suchen
-ScDBData* ScDBFunc::GetDBData( BOOL bMark, ScGetDBMode eMode, bool bShrinkToData )
+ScDBData* ScDBFunc::GetDBData( BOOL bMark, ScGetDBMode eMode, ScGetDBSelection eSel )
{
ScDocShell* pDocSh = GetViewData()->GetDocShell();
ScDBData* pData = NULL;
@@ -112,27 +112,72 @@ ScDBData* ScDBFunc::GetDBData( BOOL bMark, ScGetDBMode eMode, bool bShrinkToData
ScMarkType eMarkType = GetViewData()->GetSimpleArea(aRange);
if ( eMarkType == SC_MARK_SIMPLE || eMarkType == SC_MARK_SIMPLE_FILTERED )
{
- if (bShrinkToData)
+ bool bShrinkColumnsOnly = false;
+ if (eSel == SC_DBSEL_ROW_DOWN)
{
- // Shrink the range to only include data area.
- ScDocument* pDoc = pDocSh->GetDocument();
- SCCOL nCol1 = aRange.aStart.Col(), nCol2 = aRange.aEnd.Col();
- SCROW nRow1 = aRange.aStart.Row(), nRow2 = aRange.aEnd.Row();
- if (pDoc->ShrinkToDataArea(aRange.aStart.Tab(), nCol1, nRow1, nCol2, nRow2))
+ // Don't alter row range, additional rows may have been selected on
+ // purpose to append data, or to have a fake header row.
+ bShrinkColumnsOnly = true;
+ // Select further rows only if only one row or a portion thereof is
+ // selected.
+ if (aRange.aStart.Row() != aRange.aEnd.Row())
+ {
+ // If an area is selected shrink that to the actual used
+ // columns, don't draw filter buttons for empty columns.
+ eSel = SC_DBSEL_SHRINK_TO_USED_DATA;
+ }
+ else if (aRange.aStart.Col() == aRange.aEnd.Col())
{
- aRange.aStart.SetCol(nCol1);
- aRange.aEnd.SetCol(nCol2);
- aRange.aStart.SetRow(nRow1);
- aRange.aEnd.SetRow(nRow2);
+ // One cell only, if it is not marked obtain entire used data
+ // area.
+ const ScMarkData& rMarkData = GetViewData()->GetMarkData();
+ if (!(rMarkData.IsMarked() || rMarkData.IsMultiMarked()))
+ eSel = SC_DBSEL_KEEP;
}
}
- pData = pDocSh->GetDBData( aRange, eMode, FALSE );
+ switch (eSel)
+ {
+ case SC_DBSEL_SHRINK_TO_SHEET_DATA:
+ {
+ // Shrink the selection to sheet data area.
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCCOL nCol1 = aRange.aStart.Col(), nCol2 = aRange.aEnd.Col();
+ SCROW nRow1 = aRange.aStart.Row(), nRow2 = aRange.aEnd.Row();
+ if (pDoc->ShrinkToDataArea( aRange.aStart.Tab(), nCol1, nRow1, nCol2, nRow2))
+ {
+ aRange.aStart.SetCol(nCol1);
+ aRange.aEnd.SetCol(nCol2);
+ aRange.aStart.SetRow(nRow1);
+ aRange.aEnd.SetRow(nRow2);
+ }
+ }
+ break;
+ case SC_DBSEL_SHRINK_TO_USED_DATA:
+ case SC_DBSEL_ROW_DOWN:
+ {
+ // Shrink the selection to actual used area.
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCCOL nCol1 = aRange.aStart.Col(), nCol2 = aRange.aEnd.Col();
+ SCROW nRow1 = aRange.aStart.Row(), nRow2 = aRange.aEnd.Row();
+ if (pDoc->ShrinkToUsedDataArea( aRange.aStart.Tab(), nCol1, nRow1, nCol2, nRow2, bShrinkColumnsOnly))
+ {
+ aRange.aStart.SetCol(nCol1);
+ aRange.aEnd.SetCol(nCol2);
+ aRange.aStart.SetRow(nRow1);
+ aRange.aEnd.SetRow(nRow2);
+ }
+ }
+ break;
+ default:
+ ; // nothing
+ }
+ pData = pDocSh->GetDBData( aRange, eMode, eSel );
}
else if ( eMode != SC_DB_OLD )
pData = pDocSh->GetDBData(
ScRange( GetViewData()->GetCurX(), GetViewData()->GetCurY(),
GetViewData()->GetTabNo() ),
- eMode, FALSE );
+ eMode, SC_DBSEL_KEEP );
if ( pData && bMark )
{
@@ -290,7 +335,7 @@ void ScDBFunc::ToggleAutoFilter()
ScQueryParam aParam;
ScDocument* pDoc = GetViewData()->GetDocument();
- ScDBData* pDBData = GetDBData( FALSE );
+ ScDBData* pDBData = GetDBData( FALSE, SC_DB_MAKE, SC_DBSEL_ROW_DOWN );
pDBData->SetByRow( TRUE ); //! Undo, vorher abfragen ??
pDBData->GetQueryParam( aParam );
diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
index 304a858fa21f..750e49ec2334 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -1423,7 +1423,7 @@ void ScTabView::MarkDataArea( BOOL bIncludeCursor )
SCCOL nEndCol = nStartCol;
SCROW nEndRow = nStartRow;
- pDoc->GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow, bIncludeCursor );
+ pDoc->GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow, bIncludeCursor, false );
HideAllCursors();
DoneBlockMode();
diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx
index 74a824a709d6..7d1cbb05761b 100644
--- a/sc/source/ui/view/tabvwshc.cxx
+++ b/sc/source/ui/view/tabvwshc.cxx
@@ -175,7 +175,7 @@ SfxModelessDialog* ScTabViewShell::CreateRefDialog(
SCITEM_QUERYDATA,
SCITEM_QUERYDATA );
- ScDBData* pDBData = GetDBData();
+ ScDBData* pDBData = GetDBData( TRUE, SC_DB_MAKE, SC_DBSEL_ROW_DOWN);
pDBData->GetQueryParam( aQueryParam );
ScQueryItem aItem( SCITEM_QUERYDATA, GetViewData(), &aQueryParam );
@@ -200,7 +200,7 @@ SfxModelessDialog* ScTabViewShell::CreateRefDialog(
SCITEM_QUERYDATA,
SCITEM_QUERYDATA );
- ScDBData* pDBData = GetDBData();
+ ScDBData* pDBData = GetDBData( TRUE, SC_DB_MAKE, SC_DBSEL_ROW_DOWN);
pDBData->GetQueryParam( aQueryParam );
aArgSet.Put( ScQueryItem( SCITEM_QUERYDATA,
diff --git a/sc/source/ui/view/viewfun5.cxx b/sc/source/ui/view/viewfun5.cxx
index 794ee488afed..9697cae3a57e 100644
--- a/sc/source/ui/view/viewfun5.cxx
+++ b/sc/source/ui/view/viewfun5.cxx
@@ -387,7 +387,7 @@ BOOL ScViewFunc::PasteDataFormat( ULONG nFormatId,
// Creation of database area "Import1" isn't here, but in the DocShell
// slot execute, so it can be added to the undo action
- ScDBData* pDBData = pDocSh->GetDBData( ScRange(nPosX,nPosY,nTab), SC_DB_OLD, FALSE );
+ ScDBData* pDBData = pDocSh->GetDBData( ScRange(nPosX,nPosY,nTab), SC_DB_OLD, SC_DBSEL_KEEP );
String sTarget;
if (pDBData)
sTarget = pDBData->GetName();