[Libreoffice-commits] .: 2 commits - sc/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Fri May 27 21:25:31 PDT 2011
sc/source/ui/view/tabview2.cxx | 644 ++++++++++++++++++++---------------------
1 file changed, 328 insertions(+), 316 deletions(-)
New commits:
commit 578ff26f5c8346193743ffa2aa3e7800d6a58134
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Sat May 28 00:10:01 2011 -0400
Consolidated local functions in anonymous namespace.
diff --git a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx
index 4f929b9..6c0565e 100644
--- a/sc/source/ui/view/tabview2.cxx
+++ b/sc/source/ui/view/tabview2.cxx
@@ -154,6 +154,231 @@ void expandSelectionByMergedCell(
rBlockEndY = nCurY + nCurYOffset > MAXROW ? MAXROW : nCurY + nCurYOffset;
}
+bool isCellQualified(ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab, bool bSelectLocked, bool bSelectUnlocked)
+{
+ bool bCellProtected = pDoc->HasAttrib(
+ nCol, nRow, nTab, nCol, nRow, nTab, HASATTR_PROTECTED);
+
+ if (bCellProtected && !bSelectLocked)
+ return false;
+
+ if (!bCellProtected && !bSelectUnlocked)
+ return false;
+
+ return true;
+}
+
+void moveCursorByProtRule(
+ SCCOL& rCol, SCROW& rRow, SCsCOL nMovX, SCsROW nMovY, SCTAB nTab, ScDocument* pDoc)
+{
+ bool bSelectLocked = true;
+ bool bSelectUnlocked = true;
+ ScTableProtection* pTabProtection = pDoc->GetTabProtection(nTab);
+ if (pTabProtection && pTabProtection->isProtected())
+ {
+ bSelectLocked = pTabProtection->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
+ bSelectUnlocked = pTabProtection->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
+ }
+
+ if (nMovX > 0)
+ {
+ if (rCol < MAXCOL)
+ {
+ for (SCCOL i = 0; i < nMovX; ++i)
+ {
+ if (!isCellQualified(pDoc, rCol+1, rRow, nTab, bSelectLocked, bSelectUnlocked))
+ break;
+ ++rCol;
+ }
+ }
+ }
+ else if (nMovX < 0)
+ {
+ if (rCol > 0)
+ {
+ nMovX = -nMovX;
+ for (SCCOL i = 0; i < nMovX; ++i)
+ {
+ if (!isCellQualified(pDoc, rCol-1, rRow, nTab, bSelectLocked, bSelectUnlocked))
+ break;
+ --rCol;
+ }
+ }
+ }
+
+ if (nMovY > 0)
+ {
+ if (rRow < MAXROW)
+ {
+ for (SCROW i = 0; i < nMovY; ++i)
+ {
+ if (!isCellQualified(pDoc, rCol, rRow+1, nTab, bSelectLocked, bSelectUnlocked))
+ break;
+ ++rRow;
+ }
+ }
+ }
+ else if (nMovY < 0)
+ {
+ if (rRow > 0)
+ {
+ nMovY = -nMovY;
+ for (SCROW i = 0; i < nMovY; ++i)
+ {
+ if (!isCellQualified(pDoc, rCol, rRow-1, nTab, bSelectLocked, bSelectUnlocked))
+ break;
+ --rRow;
+ }
+ }
+ }
+}
+
+bool checkBoundary(SCCOL& rCol, SCROW& rRow)
+{
+ bool bGood = true;
+ if (rCol < 0)
+ {
+ rCol = 0;
+ bGood = false;
+ }
+ else if (rCol > MAXCOL)
+ {
+ rCol = MAXCOL;
+ bGood = false;
+ }
+
+ if (rRow < 0)
+ {
+ rRow = 0;
+ bGood = false;
+ }
+ else if (rRow > MAXROW)
+ {
+ rRow = MAXROW;
+ bGood = false;
+ }
+ return bGood;
+}
+
+void moveCursorByMergedCell(
+ SCCOL& rCol, SCROW& rRow, SCsCOL nMovX, SCsROW nMovY, SCTAB nTab,
+ ScDocument* pDoc, const ScViewData& rViewData)
+{
+ SCCOL nOrigX = rViewData.GetCurX();
+ SCROW nOrigY = rViewData.GetCurY();
+
+ ScTableProtection* pTabProtection = pDoc->GetTabProtection(nTab);
+ bool bSelectLocked = true;
+ bool bSelectUnlocked = true;
+ if (pTabProtection && pTabProtection->isProtected())
+ {
+ bSelectLocked = pTabProtection->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
+ bSelectUnlocked = pTabProtection->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
+ }
+
+ const ScMergeAttr* pMergeAttr = static_cast<const ScMergeAttr*>(
+ pDoc->GetAttr(nOrigX, nOrigY, nTab, ATTR_MERGE));
+
+ bool bOriginMerged = false;
+ SCsCOL nColSpan = 1;
+ SCsROW nRowSpan = 1;
+ if (pMergeAttr && pMergeAttr->IsMerged())
+ {
+ nColSpan = pMergeAttr->GetColMerge();
+ nRowSpan = pMergeAttr->GetRowMerge();
+ bOriginMerged = true;
+ }
+
+ if (nMovX > 0)
+ {
+ SCCOL nOld = rCol;
+ if (bOriginMerged)
+ {
+ // Original cell is merged. Push the block end outside the merged region.
+ if (nOrigX < MAXCOL && nOrigX < rCol && rCol <= nOrigX + nColSpan - 1)
+ rCol = nOrigX + nColSpan;
+ }
+ else
+ {
+ pDoc->SkipOverlapped(rCol, rRow, nTab);
+ }
+
+ if (nOld < rCol)
+ {
+ // The block end has moved. Check the protection setting and move back if needed.
+ checkBoundary(rCol, rRow);
+ if (!isCellQualified(pDoc, rCol, rRow, nTab, bSelectLocked, bSelectUnlocked))
+ --rCol;
+ }
+ }
+ if (nMovX < 0)
+ {
+ SCCOL nOld = rCol;
+ if (bOriginMerged)
+ {
+ if (nOrigX > 0 && nOrigX <= rCol && rCol < nOrigX + nColSpan - 1)
+ // Block end is still within the merged region. Push it outside.
+ rCol = nOrigX - 1;
+ }
+ else
+ {
+ pDoc->SkipOverlapped(rCol, rRow, nTab);
+ }
+
+ if (nOld > rCol)
+ {
+ // The block end has moved. Check the protection setting and move back if needed.
+ checkBoundary(rCol, rRow);
+ if (!isCellQualified(pDoc, rCol, rRow, nTab, bSelectLocked, bSelectUnlocked))
+ ++rCol;
+ }
+ }
+ if (nMovY > 0)
+ {
+ SCROW nOld = rRow;
+ if (bOriginMerged)
+ {
+ // Original cell is merged. Push the block end outside the merged region.
+ if (nOrigY < MAXROW && nOrigY < rRow && rRow <= nOrigY + nRowSpan - 1)
+ rRow = nOrigY + nRowSpan;
+ }
+ else
+ {
+ pDoc->SkipOverlapped(rCol, rRow, nTab);
+ }
+
+ if (nOld < rRow)
+ {
+ // The block end has moved. Check the protection setting and move back if needed.
+ checkBoundary(rCol, rRow);
+ if (!isCellQualified(pDoc, rCol, rRow, nTab, bSelectLocked, bSelectUnlocked))
+ --rRow;
+ }
+ }
+ if (nMovY < 0)
+ {
+ SCROW nOld = rRow;
+ if (bOriginMerged)
+ {
+ if (nOrigY > 0 && nOrigY <= rRow && rRow < nOrigY + nRowSpan - 1)
+ // Block end is still within the merged region. Push it outside.
+ rRow = nOrigY - 1;
+ }
+ else
+ {
+ pDoc->SkipOverlapped(rCol, rRow, nTab);
+ }
+
+ if (nOld > rRow)
+ {
+ // The block end has moved. Check the protection setting and move back if needed.
+ checkBoundary(rCol, rRow);
+ if (!isCellQualified(pDoc, rCol, rRow, nTab, bSelectLocked, bSelectUnlocked))
+ ++rRow;
+ }
+ }
+}
+
}
void ScTabView::PaintMarks(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow )
@@ -608,235 +833,6 @@ void ScTabView::SkipCursorVertical(SCsCOL& rCurX, SCsROW& rCurY, SCsROW nOldY, S
}
}
-namespace {
-
-bool isCellQualified(ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab, bool bSelectLocked, bool bSelectUnlocked)
-{
- bool bCellProtected = pDoc->HasAttrib(
- nCol, nRow, nTab, nCol, nRow, nTab, HASATTR_PROTECTED);
-
- if (bCellProtected && !bSelectLocked)
- return false;
-
- if (!bCellProtected && !bSelectUnlocked)
- return false;
-
- return true;
-}
-
-void moveCursorByProtRule(
- SCCOL& rCol, SCROW& rRow, SCsCOL nMovX, SCsROW nMovY, SCTAB nTab, ScDocument* pDoc)
-{
- bool bSelectLocked = true;
- bool bSelectUnlocked = true;
- ScTableProtection* pTabProtection = pDoc->GetTabProtection(nTab);
- if (pTabProtection && pTabProtection->isProtected())
- {
- bSelectLocked = pTabProtection->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
- bSelectUnlocked = pTabProtection->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
- }
-
- if (nMovX > 0)
- {
- if (rCol < MAXCOL)
- {
- for (SCCOL i = 0; i < nMovX; ++i)
- {
- if (!isCellQualified(pDoc, rCol+1, rRow, nTab, bSelectLocked, bSelectUnlocked))
- break;
- ++rCol;
- }
- }
- }
- else if (nMovX < 0)
- {
- if (rCol > 0)
- {
- nMovX = -nMovX;
- for (SCCOL i = 0; i < nMovX; ++i)
- {
- if (!isCellQualified(pDoc, rCol-1, rRow, nTab, bSelectLocked, bSelectUnlocked))
- break;
- --rCol;
- }
- }
- }
-
- if (nMovY > 0)
- {
- if (rRow < MAXROW)
- {
- for (SCROW i = 0; i < nMovY; ++i)
- {
- if (!isCellQualified(pDoc, rCol, rRow+1, nTab, bSelectLocked, bSelectUnlocked))
- break;
- ++rRow;
- }
- }
- }
- else if (nMovY < 0)
- {
- if (rRow > 0)
- {
- nMovY = -nMovY;
- for (SCROW i = 0; i < nMovY; ++i)
- {
- if (!isCellQualified(pDoc, rCol, rRow-1, nTab, bSelectLocked, bSelectUnlocked))
- break;
- --rRow;
- }
- }
- }
-}
-
-bool checkBoundary(SCCOL& rCol, SCROW& rRow)
-{
- bool bGood = true;
- if (rCol < 0)
- {
- rCol = 0;
- bGood = false;
- }
- else if (rCol > MAXCOL)
- {
- rCol = MAXCOL;
- bGood = false;
- }
-
- if (rRow < 0)
- {
- rRow = 0;
- bGood = false;
- }
- else if (rRow > MAXROW)
- {
- rRow = MAXROW;
- bGood = false;
- }
- return bGood;
-}
-
-void moveCursorByMergedCell(
- SCCOL& rCol, SCROW& rRow, SCsCOL nMovX, SCsROW nMovY, SCTAB nTab,
- ScDocument* pDoc, const ScViewData& rViewData)
-{
- SCCOL nOrigX = rViewData.GetCurX();
- SCROW nOrigY = rViewData.GetCurY();
-
- ScTableProtection* pTabProtection = pDoc->GetTabProtection(nTab);
- bool bSelectLocked = true;
- bool bSelectUnlocked = true;
- if (pTabProtection && pTabProtection->isProtected())
- {
- bSelectLocked = pTabProtection->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
- bSelectUnlocked = pTabProtection->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
- }
-
- const ScMergeAttr* pMergeAttr = static_cast<const ScMergeAttr*>(
- pDoc->GetAttr(nOrigX, nOrigY, nTab, ATTR_MERGE));
-
- bool bOriginMerged = false;
- SCsCOL nColSpan = 1;
- SCsROW nRowSpan = 1;
- if (pMergeAttr && pMergeAttr->IsMerged())
- {
- nColSpan = pMergeAttr->GetColMerge();
- nRowSpan = pMergeAttr->GetRowMerge();
- bOriginMerged = true;
- }
-
- if (nMovX > 0)
- {
- SCCOL nOld = rCol;
- if (bOriginMerged)
- {
- // Original cell is merged. Push the block end outside the merged region.
- if (nOrigX < MAXCOL && nOrigX < rCol && rCol <= nOrigX + nColSpan - 1)
- rCol = nOrigX + nColSpan;
- }
- else
- {
- pDoc->SkipOverlapped(rCol, rRow, nTab);
- }
-
- if (nOld < rCol)
- {
- // The block end has moved. Check the protection setting and move back if needed.
- checkBoundary(rCol, rRow);
- if (!isCellQualified(pDoc, rCol, rRow, nTab, bSelectLocked, bSelectUnlocked))
- --rCol;
- }
- }
- if (nMovX < 0)
- {
- SCCOL nOld = rCol;
- if (bOriginMerged)
- {
- if (nOrigX > 0 && nOrigX <= rCol && rCol < nOrigX + nColSpan - 1)
- // Block end is still within the merged region. Push it outside.
- rCol = nOrigX - 1;
- }
- else
- {
- pDoc->SkipOverlapped(rCol, rRow, nTab);
- }
-
- if (nOld > rCol)
- {
- // The block end has moved. Check the protection setting and move back if needed.
- checkBoundary(rCol, rRow);
- if (!isCellQualified(pDoc, rCol, rRow, nTab, bSelectLocked, bSelectUnlocked))
- ++rCol;
- }
- }
- if (nMovY > 0)
- {
- SCROW nOld = rRow;
- if (bOriginMerged)
- {
- // Original cell is merged. Push the block end outside the merged region.
- if (nOrigY < MAXROW && nOrigY < rRow && rRow <= nOrigY + nRowSpan - 1)
- rRow = nOrigY + nRowSpan;
- }
- else
- {
- pDoc->SkipOverlapped(rCol, rRow, nTab);
- }
-
- if (nOld < rRow)
- {
- // The block end has moved. Check the protection setting and move back if needed.
- checkBoundary(rCol, rRow);
- if (!isCellQualified(pDoc, rCol, rRow, nTab, bSelectLocked, bSelectUnlocked))
- --rRow;
- }
- }
- if (nMovY < 0)
- {
- SCROW nOld = rRow;
- if (bOriginMerged)
- {
- if (nOrigY > 0 && nOrigY <= rRow && rRow < nOrigY + nRowSpan - 1)
- // Block end is still within the merged region. Push it outside.
- rRow = nOrigY - 1;
- }
- else
- {
- pDoc->SkipOverlapped(rCol, rRow, nTab);
- }
-
- if (nOld > rRow)
- {
- // The block end has moved. Check the protection setting and move back if needed.
- checkBoundary(rCol, rRow);
- if (!isCellQualified(pDoc, rCol, rRow, nTab, bSelectLocked, bSelectUnlocked))
- ++rRow;
- }
- }
-}
-
-}
-
void ScTabView::ExpandBlock(SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode)
{
if (!nMovX && !nMovY)
commit 4f46e40020699ea79d0d7254431aff27b087e4e2
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Sat May 28 00:08:03 2011 -0400
Extracted a method from a code block.
diff --git a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx
index 7dd0920..4f929b9 100644
--- a/sc/source/ui/view/tabview2.cxx
+++ b/sc/source/ui/view/tabview2.cxx
@@ -56,6 +56,106 @@
#include "scmod.hxx"
#include "tabprotection.hxx"
+namespace {
+
+/**
+ * Expand selection area accordingly when the current selection ends with a
+ * merged cell.
+ */
+void expandSelectionByMergedCell(
+ SCsCOL& rBlockStartX, SCsROW& rBlockStartY, SCsCOL& rBlockEndX, SCsROW& rBlockEndY,
+ SCCOL nCurX, SCROW nCurY, SCTAB nTab, ScDocument* pDoc)
+{
+ SCsCOL nBlockStartXOld = rBlockStartX;
+ SCsROW nBlockStartYOld = rBlockStartY;
+
+ SCsCOL nCurXOffset = 0;
+ SCsCOL nBlockStartXOffset = 0;
+ SCsROW nCurYOffset = 0;
+ SCsROW nBlockStartYOffset = 0;
+ bool bBlockStartMerged = false;
+ const ScMergeAttr* pMergeAttr = NULL;
+
+ // The following block checks whether or not the "BlockStart" (anchor)
+ // cell is merged. If it's merged, it'll then move the position of the
+ // anchor cell to the corner that's diagonally opposite of the
+ // direction of a current selection area. For instance, if a current
+ // selection is moving in the upperleft direction, the anchor cell will
+ // move to the lower-right corner of the merged anchor cell, and so on.
+
+ pMergeAttr = static_cast<const ScMergeAttr*>(
+ pDoc->GetAttr(rBlockStartX, rBlockStartY, nTab, ATTR_MERGE));
+
+ if (pMergeAttr->IsMerged())
+ {
+ SCsCOL nColSpan = pMergeAttr->GetColMerge();
+ SCsROW nRowSpan = pMergeAttr->GetRowMerge();
+
+ if ( !(nCurX >= nBlockStartXOld + nColSpan - 1 && nCurY >= nBlockStartYOld + nRowSpan - 1) )
+ {
+ rBlockStartX = nCurX >= nBlockStartXOld ? nBlockStartXOld : nBlockStartXOld + nColSpan - 1;
+ rBlockStartY = nCurY >= nBlockStartYOld ? nBlockStartYOld : nBlockStartYOld + nRowSpan - 1;
+ nCurXOffset = nCurX >= nBlockStartXOld && nCurX < nBlockStartXOld + nColSpan - 1 ?
+ nBlockStartXOld - nCurX + nColSpan - 1 : 0;
+ nCurYOffset = nCurY >= nBlockStartYOld && nCurY < nBlockStartYOld + nRowSpan - 1 ?
+ nBlockStartYOld - nCurY + nRowSpan - 1 : 0;
+ bBlockStartMerged = true;
+ }
+ }
+
+ // The following block checks whether or not the current cell is
+ // merged. If it is, it'll then set the appropriate X & Y offset
+ // values (nCurXOffset & nCurYOffset) such that the selection area will
+ // grow by those specified offset amounts. Note that the values of
+ // nCurXOffset/nCurYOffset may also be specified in the previous code
+ // block, in which case whichever value is greater will take on.
+
+ pMergeAttr = static_cast<const ScMergeAttr*>(
+ pDoc->GetAttr(nCurX, nCurY, nTab, ATTR_MERGE));
+ if ( pMergeAttr->IsMerged() )
+ {
+ SCsCOL nColSpan = pMergeAttr->GetColMerge();
+ SCsROW nRowSpan = pMergeAttr->GetRowMerge();
+
+ if ( !(rBlockStartX >= nCurX + nColSpan - 1 && rBlockStartY >= nCurY + nRowSpan - 1) )
+ {
+ if ( rBlockStartX <= nCurX + nColSpan - 1 )
+ {
+ SCsCOL nCurXOffsetTemp = nCurX < nCurX + nColSpan - 1 ? nColSpan - 1 : 0;
+ nCurXOffset = nCurXOffset > nCurXOffsetTemp ? nCurXOffset : nCurXOffsetTemp;
+ }
+ if ( rBlockStartY <= nCurY + nRowSpan - 1 )
+ {
+ SCsROW nCurYOffsetTemp = nCurY < nCurY + nRowSpan - 1 ? nRowSpan - 1 : 0;
+ nCurYOffset = nCurYOffset > nCurYOffsetTemp ? nCurYOffset : nCurYOffsetTemp;
+ }
+ if ( !( rBlockStartX <= nCurX && rBlockStartY <= nCurY ) &&
+ !( rBlockStartX > nCurX + nColSpan - 1 && rBlockStartY > nCurY + nRowSpan - 1 ) )
+ {
+ nBlockStartXOffset = rBlockStartX > nCurX && rBlockStartX <= nCurX + nColSpan - 1 ? nCurX - rBlockStartX : 0;
+ nBlockStartYOffset = rBlockStartY > nCurY && rBlockStartY <= nCurY + nRowSpan - 1 ? nCurY - rBlockStartY : 0;
+ }
+ }
+ }
+ else
+ {
+ // The current cell is not merged. Move the anchor cell to its
+ // original position.
+ if (!bBlockStartMerged)
+ {
+ rBlockStartX = nBlockStartXOld;
+ rBlockStartY = nBlockStartYOld;
+ }
+ }
+
+ rBlockStartX = rBlockStartX + nBlockStartXOffset >= 0 ? rBlockStartX + nBlockStartXOffset : 0;
+ rBlockStartY = rBlockStartY + nBlockStartYOffset >= 0 ? rBlockStartY + nBlockStartYOffset : 0;
+ rBlockEndX = nCurX + nCurXOffset > MAXCOL ? MAXCOL : nCurX + nCurXOffset;
+ rBlockEndY = nCurY + nCurYOffset > MAXROW ? MAXROW : nCurY + nCurYOffset;
+}
+
+}
+
void ScTabView::PaintMarks(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow )
{
if (!ValidCol(nStartCol)) nStartCol = MAXCOL;
@@ -247,93 +347,9 @@ void ScTabView::MarkCursor( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ,
if ( bCellSelection )
{
- // Expand selection area accordingly when the current selection ends
- // with a merged cell.
- SCsCOL nBlockStartXOld = nBlockStartX;
- SCsROW nBlockStartYOld = nBlockStartY;
- SCsCOL nCurXOffset = 0;
- SCsCOL nBlockStartXOffset = 0;
- SCsROW nCurYOffset = 0;
- SCsROW nBlockStartYOffset = 0;
- bool bBlockStartMerged = false;
- const ScMergeAttr* pMergeAttr = NULL;
- ScDocument* pDocument = aViewData.GetDocument();
-
- // The following block checks whether or not the "BlockStart" (anchor)
- // cell is merged. If it's merged, it'll then move the position of the
- // anchor cell to the corner that's diagonally opposite of the
- // direction of a current selection area. For instance, if a current
- // selection is moving in the upperleft direction, the anchor cell will
- // move to the lower-right corner of the merged anchor cell, and so on.
-
- pMergeAttr = static_cast<const ScMergeAttr*>(
- pDocument->GetAttr( nBlockStartX, nBlockStartY, nTab, ATTR_MERGE ) );
- if ( pMergeAttr->IsMerged() )
- {
- SCsCOL nColSpan = pMergeAttr->GetColMerge();
- SCsROW nRowSpan = pMergeAttr->GetRowMerge();
-
- if ( !( nCurX >= nBlockStartXOld + nColSpan - 1 && nCurY >= nBlockStartYOld + nRowSpan - 1 ) )
- {
- nBlockStartX = nCurX >= nBlockStartXOld ? nBlockStartXOld : nBlockStartXOld + nColSpan - 1;
- nBlockStartY = nCurY >= nBlockStartYOld ? nBlockStartYOld : nBlockStartYOld + nRowSpan - 1;
- nCurXOffset = nCurX >= nBlockStartXOld && nCurX < nBlockStartXOld + nColSpan - 1 ?
- nBlockStartXOld - nCurX + nColSpan - 1 : 0;
- nCurYOffset = nCurY >= nBlockStartYOld && nCurY < nBlockStartYOld + nRowSpan - 1 ?
- nBlockStartYOld - nCurY + nRowSpan - 1 : 0;
- bBlockStartMerged = sal_True;
- }
- }
-
- // The following block checks whether or not the current cell is
- // merged. If it is, it'll then set the appropriate X & Y offset
- // values (nCurXOffset & nCurYOffset) such that the selection area will
- // grow by those specified offset amounts. Note that the values of
- // nCurXOffset/nCurYOffset may also be specified in the previous code
- // block, in which case whichever value is greater will take on.
-
- pMergeAttr = static_cast<const ScMergeAttr*>(
- pDocument->GetAttr( nCurX, nCurY, nTab, ATTR_MERGE ) );
- if ( pMergeAttr->IsMerged() )
- {
- SCsCOL nColSpan = pMergeAttr->GetColMerge();
- SCsROW nRowSpan = pMergeAttr->GetRowMerge();
-
- if ( !( nBlockStartX >= nCurX + nColSpan - 1 && nBlockStartY >= nCurY + nRowSpan - 1 ) )
- {
- if ( nBlockStartX <= nCurX + nColSpan - 1 )
- {
- SCsCOL nCurXOffsetTemp = nCurX < nCurX + nColSpan - 1 ? nColSpan - 1 : 0;
- nCurXOffset = nCurXOffset > nCurXOffsetTemp ? nCurXOffset : nCurXOffsetTemp;
- }
- if ( nBlockStartY <= nCurY + nRowSpan - 1 )
- {
- SCsROW nCurYOffsetTemp = nCurY < nCurY + nRowSpan - 1 ? nRowSpan - 1 : 0;
- nCurYOffset = nCurYOffset > nCurYOffsetTemp ? nCurYOffset : nCurYOffsetTemp;
- }
- if ( !( nBlockStartX <= nCurX && nBlockStartY <= nCurY ) &&
- !( nBlockStartX > nCurX + nColSpan - 1 && nBlockStartY > nCurY + nRowSpan - 1 ) )
- {
- nBlockStartXOffset = nBlockStartX > nCurX && nBlockStartX <= nCurX + nColSpan - 1 ? nCurX - nBlockStartX : 0;
- nBlockStartYOffset = nBlockStartY > nCurY && nBlockStartY <= nCurY + nRowSpan - 1 ? nCurY - nBlockStartY : 0;
- }
- }
- }
- else
- {
- // The current cell is not merged. Move the anchor cell to its
- // original position.
- if ( !bBlockStartMerged )
- {
- nBlockStartX = nBlockStartXOld;
- nBlockStartY = nBlockStartYOld;
- }
- }
-
- nBlockStartX = nBlockStartX + nBlockStartXOffset >= 0 ? nBlockStartX + nBlockStartXOffset : 0;
- nBlockStartY = nBlockStartY + nBlockStartYOffset >= 0 ? nBlockStartY + nBlockStartYOffset : 0;
- nBlockEndX = nCurX + nCurXOffset > MAXCOL ? MAXCOL : nCurX + nCurXOffset;
- nBlockEndY = nCurY + nCurYOffset > MAXROW ? MAXROW : nCurY + nCurYOffset;
+ expandSelectionByMergedCell(
+ nBlockStartX, nBlockStartY, nBlockEndX, nBlockEndY,
+ nCurX, nCurY, nTab, aViewData.GetDocument());
}
else
{
More information about the Libreoffice-commits
mailing list