summaryrefslogtreecommitdiffstats
path: root/sc/inc
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2015-12-09 20:58:22 +0100
committerEike Rathke <erack@redhat.com>2015-12-09 21:14:20 +0100
commitcfecdd6199710921f8fd921f615203c9e34c551e (patch)
treee986f1191f25170f3f8c62ebf5a6fd87797259c6 /sc/inc
parentsvg export: no more an experimental feature (diff)
downloadcore-cfecdd6199710921f8fd921f615203c9e34c551e.tar.gz
core-cfecdd6199710921f8fd921f615203c9e34c551e.zip
sticky end col/row anchor for range references, tdf#92779
In range references referring more than one column/row where the end col/row points to the maximum column or row number that col/row is not decremented when the range is shrunken. Incrementing an end col/row is not done past the maximum column or row number, so such references do not yield #REF! errors anymore. This is also done in named expressions if the end col/row is an absolute reference. Change-Id: Iafa2d62abd3e816a1c56c3166af92807e55b75ce
Diffstat (limited to 'sc/inc')
-rw-r--r--sc/inc/address.hxx27
-rw-r--r--sc/inc/refdata.hxx10
2 files changed, 37 insertions, 0 deletions
diff --git a/sc/inc/address.hxx b/sc/inc/address.hxx
index aa700d99b6df..4bf5ee5404e4 100644
--- a/sc/inc/address.hxx
+++ b/sc/inc/address.hxx
@@ -542,6 +542,21 @@ public:
ScRange Intersection( const ScRange& rOther ) const;
+ /// If maximum end column should not be adapted during reference update.
+ inline bool IsEndColSticky() const;
+ /// If maximum end row should not be adapted during reference update.
+ inline bool IsEndRowSticky() const;
+
+ /** Increment or decrement end column unless sticky or until it becomes
+ sticky. Checks if the range encompasses at least two columns so should
+ be called before adjusting the start column. */
+ void IncEndColSticky( SCsCOL nDelta );
+
+ /** Increment or decrement end row unless sticky or until it becomes
+ sticky. Checks if the range encompasses at least two rows so should
+ be called before adjusting the start row. */
+ void IncEndRowSticky( SCsROW nDelta );
+
inline bool operator==( const ScRange& rRange ) const;
inline bool operator!=( const ScRange& rRange ) const;
inline bool operator<( const ScRange& rRange ) const;
@@ -562,6 +577,18 @@ inline void ScRange::GetVars( SCCOL& nCol1, SCROW& nRow1, SCTAB& nTab1,
aEnd.GetVars( nCol2, nRow2, nTab2 );
}
+inline bool ScRange::IsEndColSticky() const
+{
+ // Only in an actual column range, i.e. not if both columns are MAXCOL.
+ return aEnd.Col() == MAXCOL && aStart.Col() < aEnd.Col();
+}
+
+inline bool ScRange::IsEndRowSticky() const
+{
+ // Only in an actual row range, i.e. not if both rows are MAXROW.
+ return aEnd.Row() == MAXROW && aStart.Row() < aEnd.Row();
+}
+
inline bool ScRange::operator==( const ScRange& rRange ) const
{
return ( (aStart == rRange.aStart) && (aEnd == rRange.aEnd) );
diff --git a/sc/inc/refdata.hxx b/sc/inc/refdata.hxx
index b96acb7a7eec..5f3e7626940a 100644
--- a/sc/inc/refdata.hxx
+++ b/sc/inc/refdata.hxx
@@ -180,6 +180,16 @@ struct ScComplexRefData
ScComplexRefData& Extend( const ScSingleRefData & rRef, const ScAddress & rPos );
ScComplexRefData& Extend( const ScComplexRefData & rRef, const ScAddress & rPos );
+ /** Increment or decrement end column unless or until sticky.
+ @see ScRange::IncEndColSticky()
+ @return TRUE if changed. */
+ bool IncEndColSticky( SCCOL nDelta, const ScAddress& rPos );
+
+ /** Increment or decrement end row unless or until sticky.
+ @see ScRange::IncEndRowSticky()
+ @return TRUE if changed. */
+ bool IncEndRowSticky( SCROW nDelta, const ScAddress& rPos );
+
#if DEBUG_FORMULA_COMPILER
void Dump( int nIndent = 0 ) const;
#endif