[Libreoffice-commits] core.git: sc/inc sc/source
tagezi
lera.goncharuk at gmail.com
Wed Mar 21 00:08:26 UTC 2018
sc/inc/table.hxx | 2 +
sc/source/core/data/table1.cxx | 73 ++++++++++++++++++++++++++++++-----------
2 files changed, 57 insertions(+), 18 deletions(-)
New commits:
commit 3b3e203461441da733096be323641a8dc07ff24f
Author: tagezi <lera.goncharuk at gmail.com>
Date: Thu Feb 1 13:52:49 2018 +0300
tdf#68290 cursor moves with Enter in protected sheet
Change-Id: I2ac848f1799d94f521628480664cdb579417772a
Reviewed-on: https://gerrit.libreoffice.org/49085
Reviewed-by: Eike Rathke <erack at redhat.com>
Tested-by: Jenkins <ci at libreoffice.org>
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index b4634806069b..08ddea363fbf 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -593,6 +593,8 @@ public:
void GetNextPos( SCCOL& rCol, SCROW& rRow, SCCOL nMovX, SCROW nMovY,
bool bMarked, bool bUnprotected, const ScMarkData& rMark ) const;
+ bool SkipRow( const SCCOL rCol, SCROW& rRow, const SCROW nMovY, const ScMarkData& rMark,
+ const bool bUp, const SCROW nUsedY, const bool bSheetProtected ) const;
void LimitChartArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow ) const;
bool HasData( SCCOL nCol, SCROW nRow ) const;
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index ddc440d55fa0..5a0d97d83b60 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -1318,10 +1318,47 @@ bool ScTable::ValidNextPos( SCCOL nCol, SCROW nRow, const ScMarkData& rMark,
return true;
}
+// Skips the current cell if it is Hidden, Overlapped or Protected and Sheet is Protected
+bool ScTable::SkipRow( const SCCOL nCol, SCROW& rRow, const SCROW nMovY,
+ const ScMarkData& rMark, const bool bUp, const SCROW nUsedY, const bool bSheetProtected ) const
+{
+ if ( !ValidRow( rRow ))
+ return false;
+
+ if (bSheetProtected && pDocument->HasAttrib( nCol, rRow, nTab, nCol, rRow, nTab, HasAttrFlags::Protected))
+ {
+ if ( rRow > nUsedY )
+ rRow = (bUp ? nUsedY : MAXROW + nMovY);
+ else
+ rRow += nMovY;
+
+ rRow = rMark.GetNextMarked( nCol, rRow, bUp );
+
+ return true;
+ }
+ else
+ {
+ bool bRowHidden = RowHidden( rRow );
+ bool bOverlapped = pDocument->HasAttrib( nCol, rRow, nTab, nCol, rRow, nTab, HasAttrFlags::Overlapped );
+
+ if ( bRowHidden || bOverlapped )
+ {
+ rRow += nMovY;
+ rRow = rMark.GetNextMarked( nCol, rRow, bUp );
+
+ return true;
+ }
+ }
+
+ return false;
+}
+
void ScTable::GetNextPos( SCCOL& rCol, SCROW& rRow, SCCOL nMovX, SCROW nMovY,
bool bMarked, bool bUnprotected, const ScMarkData& rMark ) const
{
- if (bUnprotected && !IsProtected()) // Is sheet really protected?
+ bool bSheetProtected = IsProtected();
+
+ if ( bUnprotected && !bSheetProtected ) // Is sheet really protected?
bUnprotected = false;
sal_uInt16 nWrap = 0;
@@ -1336,30 +1373,33 @@ void ScTable::GetNextPos( SCCOL& rCol, SCROW& rRow, SCCOL nMovX, SCROW nMovY,
if ( nMovY && bMarked )
{
- bool bUp = ( nMovY < 0 );
+ bool bUp = ( nMovY < 0 );
+ SCROW nUsedY = nRow;
+ SCCOL nUsedX = nCol;
+
nRow = rMark.GetNextMarked( nCol, nRow, bUp );
- while ( ValidRow(nRow) &&
- (RowHidden(nRow) || pDocument->HasAttrib(nCol, nRow, nTab, nCol, nRow, nTab, HasAttrFlags::Overlapped)) )
- {
- // skip hidden rows (see above)
- nRow += nMovY;
- nRow = rMark.GetNextMarked( nCol, nRow, bUp );
- }
+ pDocument->GetPrintArea( nTab, nUsedX, nUsedY );
+
+ while ( SkipRow( nCol, nRow, nMovY, rMark, bUp, nUsedY, bSheetProtected ))
+ ;
while ( nRow < 0 || nRow > MAXROW )
{
nCol = sal::static_int_cast<SCCOL>( nCol + static_cast<SCCOL>(nMovY) );
+
while ( ValidCol(nCol) && ColHidden(nCol) )
nCol = sal::static_int_cast<SCCOL>( nCol + static_cast<SCCOL>(nMovY) ); // skip hidden rows (see above)
if (nCol < 0)
{
- nCol = MAXCOL;
+ nCol = (bSheetProtected ? nUsedX : MAXCOL);
+
if (++nWrap >= 2)
return;
}
- else if (nCol > MAXCOL)
+ else if (nCol > MAXCOL || ( nCol > nUsedX && bSheetProtected ))
{
nCol = 0;
+
if (++nWrap >= 2)
return;
}
@@ -1367,14 +1407,11 @@ void ScTable::GetNextPos( SCCOL& rCol, SCROW& rRow, SCCOL nMovX, SCROW nMovY,
nRow = MAXROW;
else if (nRow > MAXROW)
nRow = 0;
+
nRow = rMark.GetNextMarked( nCol, nRow, bUp );
- while ( ValidRow(nRow) &&
- (RowHidden(nRow) || pDocument->HasAttrib(nCol, nRow, nTab, nCol, nRow, nTab, HasAttrFlags::Overlapped)) )
- {
- // skip hidden rows (see above)
- nRow += nMovY;
- nRow = rMark.GetNextMarked( nCol, nRow, bUp );
- }
+
+ while ( SkipRow( nCol, nRow, nMovY, rMark, bUp, nUsedY, bSheetProtected ))
+ ;
}
}
More information about the Libreoffice-commits
mailing list