summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorKohei Yoshida <kyoshida@novell.com>2011-01-19 11:45:03 -0500
committerKohei Yoshida <kyoshida@novell.com>2011-01-19 12:10:41 -0500
commit781689a5554fcb0a3cbc8e526914d5287e41a0c5 (patch)
treef97727ceca791d43d3276297445512ecb698c518 /sc/source
parentada9698d918ffd6859680acbd361599d8f8dbd19 (diff)
parentb207eeb1182b078cf6c620a0529137b43429657b (diff)
Merge remote branch 'origin/libreoffice-3-3'
Conflicts: sc/inc/document.hxx sc/source/core/data/drwlayer.cxx sc/source/core/data/table2.cxx sc/source/core/data/table3.cxx
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/core/data/document.cxx7
-rw-r--r--sc/source/core/data/drwlayer.cxx6
-rw-r--r--sc/source/core/data/table1.cxx38
-rw-r--r--sc/source/core/data/table2.cxx60
-rw-r--r--sc/source/core/data/table3.cxx57
-rw-r--r--sc/source/filter/xml/xmlrowi.cxx17
-rw-r--r--sc/source/ui/docshell/externalrefmgr.cxx7
-rw-r--r--sc/source/ui/view/dbfunc.cxx5
-rw-r--r--sc/source/ui/view/tabvwshe.cxx4
9 files changed, 46 insertions, 155 deletions
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index b1e2a153010e..b8f517019654 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -720,15 +720,12 @@ bool ScDocument::ShrinkToDataArea(SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow
return true; // success!
}
-bool ScDocument::ShrinkToUsedDataArea( bool& o_bShrunk, SCTAB nTab, SCCOL& rStartCol,
+bool ScDocument::ShrinkToUsedDataArea( SCTAB nTab, SCCOL& rStartCol,
SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow, bool bColumnsOnly ) const
{
if (!ValidTab(nTab) || !pTab[nTab])
- {
- o_bShrunk = false;
return false;
- }
- return pTab[nTab]->ShrinkToUsedDataArea( o_bShrunk, rStartCol, rStartRow, rEndCol, rEndRow, bColumnsOnly);
+ return pTab[nTab]->ShrinkToUsedDataArea( rStartCol, rStartRow, rEndCol, rEndRow, bColumnsOnly);
}
// connected area
diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx
index 3b61c7f3cecc..7ea95632118a 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -999,7 +999,7 @@ void ScDrawLayer::MoveArea( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SCR
MoveCells( nTab, nCol1,nRow1, nCol2,nRow2, nDx,nDy, bUpdateNoteCaptionPos );
}
-BOOL ScDrawLayer::HasObjectsInRows( SCTAB nTab, SCROW nStartRow, SCROW nEndRow, bool bIncludeNotes )
+BOOL ScDrawLayer::HasObjectsInRows( SCTAB nTab, SCROW nStartRow, SCROW nEndRow )
{
DBG_ASSERT( pDoc, "ScDrawLayer::HasObjectsInRows without document" );
if ( !pDoc )
@@ -1040,9 +1040,7 @@ BOOL ScDrawLayer::HasObjectsInRows( SCTAB nTab, SCROW nStartRow, SCROW nEndRow,
while ( pObject && !bFound )
{
aObjRect = pObject->GetSnapRect(); //! GetLogicRect ?
- // #i116164# note captions are handled separately, don't have to be included for each single row height change
- if ( (aTestRect.IsInside(aObjRect.TopLeft()) || aTestRect.IsInside(aObjRect.BottomLeft())) &&
- (bIncludeNotes || !IsNoteCaption(pObject)) )
+ if (aTestRect.IsInside(aObjRect.TopLeft()) || aTestRect.IsInside(aObjRect.BottomLeft()))
bFound = TRUE;
pObject = aIter.Next();
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index b80f6374c2dc..735de70e0553 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -835,28 +835,18 @@ void ScTable::GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, S
}
-bool ScTable::ShrinkToUsedDataArea( bool& o_bShrunk, SCCOL& rStartCol, SCROW& rStartRow,
+bool ScTable::ShrinkToUsedDataArea( SCCOL& rStartCol, SCROW& rStartRow,
SCCOL& rEndCol, SCROW& rEndRow, bool bColumnsOnly ) const
{
- o_bShrunk = false;
-
- PutInOrder( rStartCol, rEndCol);
- PutInOrder( rStartRow, rEndRow);
- if (rStartCol < 0)
- rStartCol = 0, o_bShrunk = true;
- if (rStartRow < 0)
- rStartRow = 0, o_bShrunk = true;
- if (rEndCol > MAXCOL)
- rEndCol = MAXCOL, o_bShrunk = true;
- if (rEndRow > MAXROW)
- rEndRow = MAXROW, o_bShrunk = true;
-
+ bool bRet = false;
bool bChanged;
+
do
{
bChanged = false;
- while (rStartCol < rEndCol)
+ bool bCont = true;
+ while (rEndCol > 0 && bCont && rStartCol < rEndCol)
{
if (aCol[rEndCol].IsEmptyBlock( rStartRow, rEndRow))
{
@@ -864,10 +854,11 @@ bool ScTable::ShrinkToUsedDataArea( bool& o_bShrunk, SCCOL& rStartCol, SCROW& rS
bChanged = true;
}
else
- break; // while
+ bCont = false;
}
- while (rStartCol < rEndCol)
+ bCont = true;
+ while (rStartCol < MAXCOL && bCont && rStartCol < rEndCol)
{
if (aCol[rStartCol].IsEmptyBlock( rStartRow, rEndRow))
{
@@ -875,12 +866,12 @@ bool ScTable::ShrinkToUsedDataArea( bool& o_bShrunk, SCCOL& rStartCol, SCROW& rS
bChanged = true;
}
else
- break; // while
+ bCont = false;
}
if (!bColumnsOnly)
{
- if (rStartRow < rEndRow)
+ if (rStartRow < MAXROW && rStartRow < rEndRow)
{
bool bFound = false;
for (SCCOL i=rStartCol; i<=rEndCol && !bFound; i++)
@@ -893,7 +884,7 @@ bool ScTable::ShrinkToUsedDataArea( bool& o_bShrunk, SCCOL& rStartCol, SCROW& rS
}
}
- if (rStartRow < rEndRow)
+ if (rEndRow > 0 && rStartRow < rEndRow)
{
bool bFound = false;
for (SCCOL i=rStartCol; i<=rEndCol && !bFound; i++)
@@ -908,12 +899,9 @@ bool ScTable::ShrinkToUsedDataArea( bool& o_bShrunk, SCCOL& rStartCol, SCROW& rS
}
if (bChanged)
- o_bShrunk = true;
+ bRet = true;
} while( bChanged );
-
- return rStartCol != rEndCol || (bColumnsOnly ?
- !aCol[rStartCol].IsEmptyBlock( rStartRow, rEndRow) :
- (rStartRow != rEndRow || aCol[rStartCol].HasDataAt( rStartRow)));
+ return bRet;
}
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 98f90d656610..c7572380024a 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -774,9 +774,6 @@ void ScTable::CopyToTable(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
pDestTab->pRowFlags->CopyFrom(*pRowFlags, nRow1, nRow2);
// Hidden flags.
- // #i116164# Collect information first, then apply the changes,
- // so RowHidden doesn't rebuild the tree for each row range.
- std::vector<ScShowRowsEntry> aEntries;
for (SCROW i = nRow1; i <= nRow2; ++i)
{
SCROW nThisLastRow, nDestLastRow;
@@ -789,7 +786,7 @@ void ScTable::CopyToTable(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
// the last row shouldn't exceed the upper bound the caller specified.
nLastRow = nRow2;
- aEntries.push_back(ScShowRowsEntry(i, nLastRow, bThisHidden));
+ pDestTab->SetRowHidden(i, nLastRow, bThisHidden);
bool bThisHiddenChange = (bThisHidden != bDestHidden);
if (bThisHiddenChange && pCharts)
@@ -805,19 +802,6 @@ void ScTable::CopyToTable(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
i = nLastRow;
}
- std::vector<ScShowRowsEntry>::const_iterator aEnd = aEntries.end();
- std::vector<ScShowRowsEntry>::const_iterator aIter = aEntries.begin();
- if ( aIter != aEnd )
- {
- pDestTab->mpHiddenRows->setInsertFromBack(true); // important for undo document
- while (aIter != aEnd)
- {
- pDestTab->SetRowHidden(aIter->mnRow1, aIter->mnRow2, !aIter->mbShow);
- ++aIter;
- }
- pDestTab->mpHiddenRows->setInsertFromBack(false);
- }
-
// Filtered flags.
for (SCROW i = nRow1; i <= nRow2; ++i)
{
@@ -1135,16 +1119,10 @@ ScBaseCell* ScTable::GetCell( SCCOL nCol, SCROW nRow ) const
void ScTable::GetFirstDataPos(SCCOL& rCol, SCROW& rRow) const
{
rCol = 0;
- rRow = MAXROW+1;
+ rRow = 0;
while (aCol[rCol].IsEmptyData() && rCol < MAXCOL)
++rCol;
- SCCOL nCol = rCol;
- while (nCol <= MAXCOL && rRow > 0)
- {
- if (!aCol[nCol].IsEmptyData())
- rRow = ::std::min( rRow, aCol[nCol].GetFirstDataPos());
- ++nCol;
- }
+ rRow = aCol[rCol].GetFirstDataPos();
}
void ScTable::GetLastDataPos(SCCOL& rCol, SCROW& rRow) const
@@ -1154,8 +1132,11 @@ void ScTable::GetLastDataPos(SCCOL& rCol, SCROW& rRow) const
while (aCol[rCol].IsEmptyData() && (rCol > 0))
rCol--;
SCCOL nCol = rCol;
- while (nCol >= 0 && rRow < MAXROW)
- rRow = ::std::max( rRow, aCol[nCol--].GetLastDataPos());
+ while ((SCsCOL)nCol >= 0)
+ {
+ rRow = Max(rRow, aCol[nCol].GetLastDataPos());
+ nCol--;
+ }
}
@@ -2559,9 +2540,8 @@ void ScTable::DBShowRow(SCROW nRow, bool bShow)
}
-void ScTable::DBShowRows(SCROW nRow1, SCROW nRow2, bool bShow, bool bSetFlags)
+void ScTable::DBShowRows(SCROW nRow1, SCROW nRow2, bool bShow)
{
- // #i116164# IncRecalcLevel/DecRecalcLevel is in ScTable::Query
SCROW nStartRow = nRow1;
while (nStartRow <= nRow2)
{
@@ -2572,13 +2552,8 @@ void ScTable::DBShowRows(SCROW nRow1, SCROW nRow2, bool bShow, bool bSetFlags)
BOOL bChanged = ( bWasVis != bShow );
- // #i116164# Directly modify the flags only if there are drawing objects within the area.
- // Otherwise, all modifications are made together in ScTable::Query, so the tree isn't constantly rebuilt.
- if ( bSetFlags )
- {
- SetRowHidden(nStartRow, nEndRow, !bShow);
- SetRowFiltered(nStartRow, nEndRow, !bShow);
- }
+ SetRowHidden(nStartRow, nEndRow, !bShow);
+ SetRowFiltered(nStartRow, nEndRow, !bShow);
if ( bChanged )
{
@@ -2606,7 +2581,7 @@ void ScTable::ShowRows(SCROW nRow1, SCROW nRow2, bool bShow)
// #i116164# if there are no drawing objects within the row range, a single HeightChanged call is enough
ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer();
- bool bHasObjects = pDrawLayer && pDrawLayer->HasObjectsInRows( nTab, nRow1, nRow2, false );
+ bool bHasObjects = pDrawLayer && pDrawLayer->HasObjectsInRows( nTab, nRow1, nRow2 );
while (nStartRow <= nRow2)
{
@@ -2617,14 +2592,9 @@ void ScTable::ShowRows(SCROW nRow1, SCROW nRow2, bool bShow)
BOOL bChanged = ( bWasVis != bShow );
- // #i116164# Directly modify the flags only if there are drawing objects within the area.
- // Otherwise, all rows are modified together after the loop, so the tree isn't constantly rebuilt.
- if ( bHasObjects )
- {
- SetRowHidden(nStartRow, nEndRow, !bShow);
- if (bShow)
- SetRowFiltered(nStartRow, nEndRow, false);
- }
+ SetRowHidden(nStartRow, nEndRow, !bShow);
+ if (bShow)
+ SetRowFiltered(nStartRow, nEndRow, false);
if ( bChanged )
{
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 86bc8cb2c450..34f7faa3839f 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -61,7 +61,6 @@
#include "postit.hxx"
#include "queryparam.hxx"
#include "segmenttree.hxx"
-#include "drwlayer.hxx"
#include <vector>
@@ -1642,14 +1641,11 @@ SCSIZE ScTable::Query(ScQueryParam& rParamOrg, BOOL bKeepSub)
aParam.nDestCol, aParam.nDestRow, aParam.nDestTab );
}
+ InitializeNoteCaptions();
+
if (aParam.bInplace)
IncRecalcLevel(); // #i116164# once for all entries
- // #i116164# If there are no drawing objects within the area, call SetRowHidden/SetRowFiltered for all rows at the end
- std::vector<ScShowRowsEntry> aEntries;
- ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer();
- bool bHasObjects = pDrawLayer && pDrawLayer->HasObjectsInRows( nTab, aParam.nRow1 + nHeader, aParam.nRow2, false );
-
SCROW nRealRow2 = aParam.bUseDynamicRange ? aParam.nDynamicEndRow : aParam.nRow2;
for (SCROW j = aParam.nRow1 + nHeader; j <= nRealRow2; ++j)
{
@@ -1706,11 +1702,7 @@ SCSIZE ScTable::Query(ScQueryParam& rParamOrg, BOOL bKeepSub)
else
{
if (bStarted)
- {
- DBShowRows(nOldStart,nOldEnd, bOldResult, bHasObjects);
- if (!bHasObjects)
- aEntries.push_back(ScShowRowsEntry(nOldStart, nOldEnd, bOldResult));
- }
+ DBShowRows(nOldStart,nOldEnd, bOldResult);
nOldStart = nOldEnd = j;
bOldResult = bResult;
}
@@ -1729,49 +1721,10 @@ SCSIZE ScTable::Query(ScQueryParam& rParamOrg, BOOL bKeepSub)
}
if (aParam.bInplace && bStarted)
- {
- DBShowRows(nOldStart,nOldEnd, bOldResult, bHasObjects);
- if (!bHasObjects)
- aEntries.push_back(ScShowRowsEntry(nOldStart, nOldEnd, bOldResult));
- }
-
- // #i116164# execute the collected SetRowHidden/SetRowFiltered calls
- if (!bHasObjects)
- {
- std::vector<ScShowRowsEntry>::const_iterator aEnd = aEntries.end();
- std::vector<ScShowRowsEntry>::const_iterator aIter = aEntries.begin();
- if ( aIter != aEnd )
- {
- // clear the range first instead of many changes in the middle of the filled array
- SetRowHidden(aParam.nRow1 + nHeader, aParam.nRow2, false);
- SetRowFiltered(aParam.nRow1 + nHeader, aParam.nRow2, false);
-
- // insert from back, in case the filter range is large
- mpHiddenRows->setInsertFromBack(true);
- mpFilteredRows->setInsertFromBack(true);
-
- while (aIter != aEnd)
- {
- if (!aIter->mbShow)
- {
- SCROW nStartRow = aIter->mnRow1;
- SCROW nEndRow = aIter->mnRow2;
- SetRowHidden(nStartRow, nEndRow, true);
- SetRowFiltered(nStartRow, nEndRow, true);
- }
- ++aIter;
- }
-
- mpHiddenRows->setInsertFromBack(false);
- mpFilteredRows->setInsertFromBack(false);
- }
- }
-
- if (aParam.bInplace)
- DecRecalcLevel();
+ DBShowRows(nOldStart,nOldEnd, bOldResult);
delete[] pSpecial;
-
+ SetDrawPageSize();
return nCount;
}
diff --git a/sc/source/filter/xml/xmlrowi.cxx b/sc/source/filter/xml/xmlrowi.cxx
index ac26defad9ce..aa0e0e367326 100644
--- a/sc/source/filter/xml/xmlrowi.cxx
+++ b/sc/source/filter/xml/xmlrowi.cxx
@@ -172,7 +172,6 @@ void ScXMLTableRowContext::EndElement()
sal_Int32 nSheet = rXMLImport.GetTables().GetCurrentSheet();
sal_Int32 nCurrentRow(rXMLImport.GetTables().GetCurrentRow());
uno::Reference<sheet::XSpreadsheet> xSheet(rXMLImport.GetTables().GetCurrentXSheet());
- ScDocument* pDoc = rXMLImport.GetDocument();
if(xSheet.is())
{
sal_Int32 nFirstRow(nCurrentRow - nRepeatedRows + 1);
@@ -220,18 +219,10 @@ void ScXMLTableRowContext::EndElement()
bVisible = sal_False;
bFiltered = sal_True;
}
-
- // #i116164# call SetRowHidden/SetRowFiltered directly, so the tree doesn't have to be rebuilt
- // to compare with existing hidden flags.
- if (!bVisible && pDoc)
- pDoc->SetRowHidden((SCROW)nFirstRow, (SCROW)nCurrentRow, (SCTAB)nSheet, true);
- if (bFiltered && pDoc)
- pDoc->SetRowFiltered((SCROW)nFirstRow, (SCROW)nCurrentRow, (SCTAB)nSheet, true);
-
- //if (!bVisible)
- // xRowProperties->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ISVISIBLE)), uno::makeAny(bVisible));
- //if (bFiltered)
- // xRowProperties->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ISFILTERED)), uno::makeAny(bFiltered));
+ if (!bVisible)
+ xRowProperties->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ISVISIBLE)), uno::makeAny(bVisible));
+ if (bFiltered)
+ xRowProperties->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ISFILTERED)), uno::makeAny(bFiltered));
}
}
}
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index e4f52761429c..741837b29db2 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -1351,8 +1351,7 @@ static ScTokenArray* lcl_convertToTokenArray(const ScDocument* pSrcDoc, ScRange&
// Only loop within the data area.
SCCOL nDataCol1 = nCol1, nDataCol2 = nCol2;
SCROW nDataRow1 = nRow1, nDataRow2 = nRow2;
- bool bShrunk;
- if (!pSrcDoc->ShrinkToUsedDataArea( bShrunk, nTab, nDataCol1, nDataRow1, nDataCol2, nDataRow2, false))
+ if (!pSrcDoc->ShrinkToDataArea(nTab, nDataCol1, nDataRow1, nDataCol2, nDataRow2))
// no data within specified range.
continue;
@@ -1687,8 +1686,8 @@ ScExternalRefCache::TokenRef ScExternalRefManager::getSingleRefToken(
SCCOL nDataCol1 = 0, nDataCol2 = MAXCOL;
SCROW nDataRow1 = 0, nDataRow2 = MAXROW;
- bool bData = pSrcDoc->ShrinkToDataArea(nTab, nDataCol1, nDataRow1, nDataCol2, nDataRow2);
- if (!bData || rCell.Col() < nDataCol1 || nDataCol2 < rCell.Col() || rCell.Row() < nDataRow1 || nDataRow2 < rCell.Row())
+ pSrcDoc->ShrinkToDataArea(nTab, nDataCol1, nDataRow1, nDataCol2, nDataRow2);
+ if (rCell.Col() < nDataCol1 || nDataCol2 < rCell.Col() || rCell.Row() < nDataRow1 || nDataRow2 < rCell.Row())
{
// requested cell is outside the data area. Don't even bother caching
// this data, but add it to the cached range to prevent accessing the
diff --git a/sc/source/ui/view/dbfunc.cxx b/sc/source/ui/view/dbfunc.cxx
index 6b95b3b4ff8c..9dc58f936b81 100644
--- a/sc/source/ui/view/dbfunc.cxx
+++ b/sc/source/ui/view/dbfunc.cxx
@@ -155,10 +155,7 @@ ScDBData* ScDBFunc::GetDBData( BOOL bMark, ScGetDBMode eMode, ScGetDBSelection e
ScDocument* pDoc = pDocSh->GetDocument();
SCCOL nCol1 = aRange.aStart.Col(), nCol2 = aRange.aEnd.Col();
SCROW nRow1 = aRange.aStart.Row(), nRow2 = aRange.aEnd.Row();
- bool bShrunk;
- pDoc->ShrinkToUsedDataArea( bShrunk, aRange.aStart.Tab(),
- nCol1, nRow1, nCol2, nRow2, bShrinkColumnsOnly);
- if (bShrunk)
+ if (pDoc->ShrinkToUsedDataArea( aRange.aStart.Tab(), nCol1, nRow1, nCol2, nRow2, bShrinkColumnsOnly))
{
aRange.aStart.SetCol(nCol1);
aRange.aEnd.SetCol(nCol2);
diff --git a/sc/source/ui/view/tabvwshe.cxx b/sc/source/ui/view/tabvwshe.cxx
index 7e99ef7fc064..70f2876287ca 100644
--- a/sc/source/ui/view/tabvwshe.cxx
+++ b/sc/source/ui/view/tabvwshe.cxx
@@ -98,9 +98,7 @@ String ScTabViewShell::GetSelectionText( BOOL bWholeWord )
SCROW nRow1, nRow2;
SCTAB nTab1, nTab2;
aRange.GetVars( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2);
- bool bShrunk;
- pDoc->ShrinkToUsedDataArea( bShrunk, nTab1, nCol1, nRow1, nCol2, nRow2, false);
- if (bShrunk)
+ if (pDoc->ShrinkToUsedDataArea( nTab1, nCol1, nRow1, nCol2, nRow2, false))
{
aRange.aStart.SetCol( nCol1 );
aRange.aStart.SetRow( nRow1 );