[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/source
Kohei Yoshida
kohei.yoshida at gmail.com
Tue May 14 18:32:50 PDT 2013
sc/source/core/data/document.cxx | 303 +++++++++++++++++++--------------------
1 file changed, 152 insertions(+), 151 deletions(-)
New commits:
commit 79b86d051f5c4e7d2c744201bde146ba5e5bf7e5
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Tue May 14 21:33:22 2013 -0400
Reduce indentation level by early bail-out.
Change-Id: I5e108efa0219620696d15a304d2f4e3566d58d57
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 3cfdaa6..c51804a 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -2434,173 +2434,174 @@ void ScDocument::CopyFromClip( const ScRange& rDestRange, const ScMarkData& rMar
bool bAsLink, bool bIncludeFiltered, bool bSkipAttrForEmpty,
const ScRangeList * pDestRanges )
{
- if (!bIsClip)
+ if (bIsClip)
+ return;
+
+ if (!pClipDoc)
{
- if (!pClipDoc)
+ OSL_FAIL("CopyFromClip: no ClipDoc");
+ pClipDoc = SC_MOD()->GetClipDoc();
+ }
+
+ if (!pClipDoc->bIsClip || !pClipDoc->GetTableCount())
+ return;
+
+ bool bOldAutoCalc = GetAutoCalc();
+ SetAutoCalc( false ); // avoid multiple recalculations
+
+ NumFmtMergeHandler aNumFmtMergeHdl(this, pClipDoc);
+
+ SCCOL nAllCol1 = rDestRange.aStart.Col();
+ SCROW nAllRow1 = rDestRange.aStart.Row();
+ SCCOL nAllCol2 = rDestRange.aEnd.Col();
+ SCROW nAllRow2 = rDestRange.aEnd.Row();
+
+ SCCOL nXw = 0;
+ SCROW nYw = 0;
+ ScRange aClipRange = pClipDoc->GetClipParam().getWholeRange();
+ for (SCTAB nTab = 0; nTab < static_cast<SCTAB>(pClipDoc->maTabs.size()); nTab++) // find largest merge overlap
+ if (pClipDoc->maTabs[nTab]) // all sheets of the clipboard content
{
- OSL_FAIL("CopyFromClip: no ClipDoc");
- pClipDoc = SC_MOD()->GetClipDoc();
+ SCCOL nThisEndX = aClipRange.aEnd.Col();
+ SCROW nThisEndY = aClipRange.aEnd.Row();
+ pClipDoc->ExtendMerge( aClipRange.aStart.Col(),
+ aClipRange.aStart.Row(),
+ nThisEndX, nThisEndY, nTab );
+ // only extra value from ExtendMerge
+ nThisEndX = sal::static_int_cast<SCCOL>( nThisEndX - aClipRange.aEnd.Col() );
+ nThisEndY = sal::static_int_cast<SCROW>( nThisEndY - aClipRange.aEnd.Row() );
+ if ( nThisEndX > nXw )
+ nXw = nThisEndX;
+ if ( nThisEndY > nYw )
+ nYw = nThisEndY;
}
- if (pClipDoc->bIsClip && pClipDoc->GetTableCount())
- {
- bool bOldAutoCalc = GetAutoCalc();
- SetAutoCalc( false ); // avoid multiple recalculations
- NumFmtMergeHandler aNumFmtMergeHdl(this, pClipDoc);
+ SCCOL nDestAddX;
+ SCROW nDestAddY;
+ pClipDoc->GetClipArea( nDestAddX, nDestAddY, bIncludeFiltered );
+ nXw = sal::static_int_cast<SCCOL>( nXw + nDestAddX );
+ nYw = sal::static_int_cast<SCROW>( nYw + nDestAddY ); // ClipArea, plus ExtendMerge value
+
+ /* Decide which contents to delete before copying. Delete all
+ contents if nInsFlag contains any real content flag.
+ #i102056# Notes are pasted from clipboard in a second pass,
+ together with the special flag IDF_ADDNOTES that states to not
+ overwrite/delete existing cells but to insert the notes into
+ these cells. In this case, just delete old notes from the
+ destination area. */
+ sal_uInt16 nDelFlag = IDF_NONE;
+ if ( (nInsFlag & (IDF_CONTENTS | IDF_ADDNOTES)) == (IDF_NOTE | IDF_ADDNOTES) )
+ nDelFlag |= IDF_NOTE;
+ else if ( nInsFlag & IDF_CONTENTS )
+ nDelFlag |= IDF_CONTENTS;
+ // With bSkipAttrForEmpty, don't remove attributes, copy
+ // on top of existing attributes instead.
+ if ( ( nInsFlag & IDF_ATTRIB ) && !bSkipAttrForEmpty )
+ nDelFlag |= IDF_ATTRIB;
- SCCOL nAllCol1 = rDestRange.aStart.Col();
- SCROW nAllRow1 = rDestRange.aStart.Row();
- SCCOL nAllCol2 = rDestRange.aEnd.Col();
- SCROW nAllRow2 = rDestRange.aEnd.Row();
+ ScCopyBlockFromClipParams aCBFCP;
+ aCBFCP.pRefUndoDoc = pRefUndoDoc;
+ aCBFCP.pClipDoc = pClipDoc;
+ aCBFCP.nInsFlag = nInsFlag;
+ aCBFCP.bAsLink = bAsLink;
+ aCBFCP.bSkipAttrForEmpty = bSkipAttrForEmpty;
+ aCBFCP.nTabStart = MAXTAB; // wird in der Schleife angepasst
+ aCBFCP.nTabEnd = 0; // wird in der Schleife angepasst
- SCCOL nXw = 0;
- SCROW nYw = 0;
- ScRange aClipRange = pClipDoc->GetClipParam().getWholeRange();
- for (SCTAB nTab = 0; nTab < static_cast<SCTAB>(pClipDoc->maTabs.size()); nTab++) // find largest merge overlap
- if (pClipDoc->maTabs[nTab]) // all sheets of the clipboard content
- {
- SCCOL nThisEndX = aClipRange.aEnd.Col();
- SCROW nThisEndY = aClipRange.aEnd.Row();
- pClipDoc->ExtendMerge( aClipRange.aStart.Col(),
- aClipRange.aStart.Row(),
- nThisEndX, nThisEndY, nTab );
- // only extra value from ExtendMerge
- nThisEndX = sal::static_int_cast<SCCOL>( nThisEndX - aClipRange.aEnd.Col() );
- nThisEndY = sal::static_int_cast<SCROW>( nThisEndY - aClipRange.aEnd.Row() );
- if ( nThisEndX > nXw )
- nXw = nThisEndX;
- if ( nThisEndY > nYw )
- nYw = nThisEndY;
- }
+ // Inc/DecRecalcLevel einmal aussen, damit nicht fuer jeden Block
+ // die Draw-Seitengroesse neu berechnet werden muss
+ //! nur wenn ganze Zeilen/Spalten kopiert werden?
- SCCOL nDestAddX;
- SCROW nDestAddY;
- pClipDoc->GetClipArea( nDestAddX, nDestAddY, bIncludeFiltered );
- nXw = sal::static_int_cast<SCCOL>( nXw + nDestAddX );
- nYw = sal::static_int_cast<SCROW>( nYw + nDestAddY ); // ClipArea, plus ExtendMerge value
-
- /* Decide which contents to delete before copying. Delete all
- contents if nInsFlag contains any real content flag.
- #i102056# Notes are pasted from clipboard in a second pass,
- together with the special flag IDF_ADDNOTES that states to not
- overwrite/delete existing cells but to insert the notes into
- these cells. In this case, just delete old notes from the
- destination area. */
- sal_uInt16 nDelFlag = IDF_NONE;
- if ( (nInsFlag & (IDF_CONTENTS | IDF_ADDNOTES)) == (IDF_NOTE | IDF_ADDNOTES) )
- nDelFlag |= IDF_NOTE;
- else if ( nInsFlag & IDF_CONTENTS )
- nDelFlag |= IDF_CONTENTS;
- // With bSkipAttrForEmpty, don't remove attributes, copy
- // on top of existing attributes instead.
- if ( ( nInsFlag & IDF_ATTRIB ) && !bSkipAttrForEmpty )
- nDelFlag |= IDF_ATTRIB;
-
- ScCopyBlockFromClipParams aCBFCP;
- aCBFCP.pRefUndoDoc = pRefUndoDoc;
- aCBFCP.pClipDoc = pClipDoc;
- aCBFCP.nInsFlag = nInsFlag;
- aCBFCP.bAsLink = bAsLink;
- aCBFCP.bSkipAttrForEmpty = bSkipAttrForEmpty;
- aCBFCP.nTabStart = MAXTAB; // wird in der Schleife angepasst
- aCBFCP.nTabEnd = 0; // wird in der Schleife angepasst
-
- // Inc/DecRecalcLevel einmal aussen, damit nicht fuer jeden Block
- // die Draw-Seitengroesse neu berechnet werden muss
- //! nur wenn ganze Zeilen/Spalten kopiert werden?
+ SCTAB nMax = static_cast<SCTAB>(maTabs.size());
+ ScMarkData::const_iterator itr = rMark.begin(), itrEnd = rMark.end();
+ for (; itr != itrEnd && *itr < nMax; ++itr)
+ if (maTabs[*itr])
+ {
+ if ( *itr < aCBFCP.nTabStart )
+ aCBFCP.nTabStart = *itr;
+ aCBFCP.nTabEnd = *itr;
+ }
- SCTAB nMax = static_cast<SCTAB>(maTabs.size());
- ScMarkData::const_iterator itr = rMark.begin(), itrEnd = rMark.end();
- for (; itr != itrEnd && *itr < nMax; ++itr)
- if (maTabs[*itr])
- {
- if ( *itr < aCBFCP.nTabStart )
- aCBFCP.nTabStart = *itr;
- aCBFCP.nTabEnd = *itr;
- }
+ ScRangeList aLocalRangeList;
+ if (!pDestRanges)
+ {
+ aLocalRangeList.Append( rDestRange);
+ pDestRanges = &aLocalRangeList;
+ }
- ScRangeList aLocalRangeList;
- if (!pDestRanges)
- {
- aLocalRangeList.Append( rDestRange);
- pDestRanges = &aLocalRangeList;
- }
+ bInsertingFromOtherDoc = true; // kein Broadcast/Listener aufbauen bei Insert
+
+ SCCOL nClipStartCol = aClipRange.aStart.Col();
+ SCROW nClipStartRow = aClipRange.aStart.Row();
+ SCROW nClipEndRow = aClipRange.aEnd.Row();
+ for ( size_t nRange = 0; nRange < pDestRanges->size(); ++nRange )
+ {
+ const ScRange* pRange = (*pDestRanges)[nRange];
+ SCCOL nCol1 = pRange->aStart.Col();
+ SCROW nRow1 = pRange->aStart.Row();
+ SCCOL nCol2 = pRange->aEnd.Col();
+ SCROW nRow2 = pRange->aEnd.Row();
+
+ DeleteArea(nCol1, nRow1, nCol2, nRow2, rMark, nDelFlag);
- bInsertingFromOtherDoc = true; // kein Broadcast/Listener aufbauen bei Insert
+ SCCOL nC1 = nCol1;
+ SCROW nR1 = nRow1;
+ SCCOL nC2 = nC1 + nXw;
+ if (nC2 > nCol2)
+ nC2 = nCol2;
+ SCROW nR2 = nR1 + nYw;
+ if (nR2 > nRow2)
+ nR2 = nRow2;
- SCCOL nClipStartCol = aClipRange.aStart.Col();
- SCROW nClipStartRow = aClipRange.aStart.Row();
- SCROW nClipEndRow = aClipRange.aEnd.Row();
- for ( size_t nRange = 0; nRange < pDestRanges->size(); ++nRange )
+ do
+ {
+ // Pasting is done column-wise, when pasting to a filtered
+ // area this results in partitioning and we have to
+ // remember and reset the start row for each column until
+ // it can be advanced for the next chunk of unfiltered
+ // rows.
+ SCROW nSaveClipStartRow = nClipStartRow;
+ do
{
- const ScRange* pRange = (*pDestRanges)[nRange];
- SCCOL nCol1 = pRange->aStart.Col();
- SCROW nRow1 = pRange->aStart.Row();
- SCCOL nCol2 = pRange->aEnd.Col();
- SCROW nRow2 = pRange->aEnd.Row();
-
- DeleteArea(nCol1, nRow1, nCol2, nRow2, rMark, nDelFlag);
-
- SCCOL nC1 = nCol1;
- SCROW nR1 = nRow1;
- SCCOL nC2 = nC1 + nXw;
- if (nC2 > nCol2)
- nC2 = nCol2;
- SCROW nR2 = nR1 + nYw;
- if (nR2 > nRow2)
- nR2 = nRow2;
-
- do
+ nClipStartRow = nSaveClipStartRow;
+ SCsCOL nDx = ((SCsCOL)nC1) - nClipStartCol;
+ SCsROW nDy = ((SCsROW)nR1) - nClipStartRow;
+ if ( bIncludeFiltered )
{
- // Pasting is done column-wise, when pasting to a filtered
- // area this results in partitioning and we have to
- // remember and reset the start row for each column until
- // it can be advanced for the next chunk of unfiltered
- // rows.
- SCROW nSaveClipStartRow = nClipStartRow;
- do
- {
- nClipStartRow = nSaveClipStartRow;
- SCsCOL nDx = ((SCsCOL)nC1) - nClipStartCol;
- SCsROW nDy = ((SCsROW)nR1) - nClipStartRow;
- if ( bIncludeFiltered )
- {
- CopyBlockFromClip( nC1, nR1, nC2, nR2, rMark, nDx,
- nDy, &aCBFCP );
- nClipStartRow += nR2 - nR1 + 1;
- }
- else
- {
- CopyNonFilteredFromClip( nC1, nR1, nC2, nR2, rMark,
- nDx, nDy, &aCBFCP, nClipStartRow );
- }
- nC1 = nC2 + 1;
- nC2 = std::min((SCCOL)(nC1 + nXw), nCol2);
- } while (nC1 <= nCol2);
- if (nClipStartRow > nClipEndRow)
- nClipStartRow = aClipRange.aStart.Row();
- nC1 = nCol1;
- nC2 = nC1 + nXw;
- if (nC2 > nCol2)
- nC2 = nCol2;
- nR1 = nR2 + 1;
- nR2 = std::min((SCROW)(nR1 + nYw), nRow2);
- } while (nR1 <= nRow2);
- }
+ CopyBlockFromClip( nC1, nR1, nC2, nR2, rMark, nDx,
+ nDy, &aCBFCP );
+ nClipStartRow += nR2 - nR1 + 1;
+ }
+ else
+ {
+ CopyNonFilteredFromClip( nC1, nR1, nC2, nR2, rMark,
+ nDx, nDy, &aCBFCP, nClipStartRow );
+ }
+ nC1 = nC2 + 1;
+ nC2 = std::min((SCCOL)(nC1 + nXw), nCol2);
+ } while (nC1 <= nCol2);
+ if (nClipStartRow > nClipEndRow)
+ nClipStartRow = aClipRange.aStart.Row();
+ nC1 = nCol1;
+ nC2 = nC1 + nXw;
+ if (nC2 > nCol2)
+ nC2 = nCol2;
+ nR1 = nR2 + 1;
+ nR2 = std::min((SCROW)(nR1 + nYw), nRow2);
+ } while (nR1 <= nRow2);
+ }
- itr = rMark.begin();
+ itr = rMark.begin();
- bInsertingFromOtherDoc = false;
+ bInsertingFromOtherDoc = false;
- // Listener aufbauen nachdem alles inserted wurde
- StartListeningFromClip( nAllCol1, nAllRow1, nAllCol2, nAllRow2, rMark, nInsFlag );
- // nachdem alle Listener aufgebaut wurden, kann gebroadcastet werden
- BroadcastFromClip( nAllCol1, nAllRow1, nAllCol2, nAllRow2, rMark, nInsFlag );
- if (bResetCut)
- pClipDoc->GetClipParam().mbCutMode = false;
- SetAutoCalc( bOldAutoCalc );
- }
- }
+ // Listener aufbauen nachdem alles inserted wurde
+ StartListeningFromClip( nAllCol1, nAllRow1, nAllCol2, nAllRow2, rMark, nInsFlag );
+ // nachdem alle Listener aufgebaut wurden, kann gebroadcastet werden
+ BroadcastFromClip( nAllCol1, nAllRow1, nAllCol2, nAllRow2, rMark, nInsFlag );
+ if (bResetCut)
+ pClipDoc->GetClipParam().mbCutMode = false;
+ SetAutoCalc( bOldAutoCalc );
}
static SCROW lcl_getLastNonFilteredRow(
More information about the Libreoffice-commits
mailing list