summaryrefslogtreecommitdiff
path: root/sc/source/core/tool/compiler.cxx
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2015-06-26 17:43:36 +0200
committerEike Rathke <erack@redhat.com>2015-06-26 17:52:32 +0200
commiteeea41e2e726dd5d69cd323909e1666efb9de472 (patch)
tree6897371b30e6e92823472a7a462d142c15119e57 /sc/source/core/tool/compiler.cxx
parent1ebe3004d6e9372ef5419d456b3c29059b539bc9 (diff)
tdf#44419 display entire column/row references as A:A/1:1
... if both anchors of the other axis are absolute. Now that we can parse them as of commit 0c8778ce1df92ca3bc2a8dd2f64568fb257e9e39 (and follow-up 4091b4fbdce40262eba46ab94653287b1fd928e8). Change-Id: Ie67127fe2d7546e7e598ee1a4d89133c08222262
Diffstat (limited to 'sc/source/core/tool/compiler.cxx')
-rw-r--r--sc/source/core/tool/compiler.cxx88
1 files changed, 65 insertions, 23 deletions
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 9d0a03a4dcb5..9251731997f4 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -762,12 +762,25 @@ struct ConventionOOO_A1 : public Convention_A1
rBuf.append('.');
}
+ enum SingletonDisplay
+ {
+ SINGLETON_NONE,
+ SINGLETON_COL,
+ SINGLETON_ROW
+ };
+
static void MakeOneRefStrImpl(
OUStringBuffer& rBuffer,
const OUString& rErrRef, const std::vector<OUString>& rTabNames,
const ScSingleRefData& rRef, const ScAddress& rAbsRef,
- bool bForceTab, bool bODF )
+ bool bForceTab, bool bODF, SingletonDisplay eSingletonDisplay )
{
+ // For ODF override singleton so earlier releases still can read what
+ // we write now as of 2015-06-26.
+ /* TODO: we may want to change that in future in a few releases. */
+ if (bODF)
+ eSingletonDisplay = SINGLETON_NONE;
+
if( rRef.IsFlag3D() || bForceTab )
{
if (!ValidTab(rAbsRef.Tab()) || rRef.IsTabDeleted())
@@ -786,18 +799,45 @@ struct ConventionOOO_A1 : public Convention_A1
}
else if (bODF)
rBuffer.append('.');
- if (!rRef.IsColRel())
- rBuffer.append('$');
- if (!ValidCol(rAbsRef.Col()) || rRef.IsColDeleted())
- rBuffer.append(rErrRef);
- else
- MakeColStr(rBuffer, rAbsRef.Col());
- if (!rRef.IsRowRel())
- rBuffer.append('$');
- if (!ValidRow(rAbsRef.Row()) || rRef.IsRowDeleted())
- rBuffer.append(rErrRef);
- else
- MakeRowStr(rBuffer, rAbsRef.Row());
+
+ if (eSingletonDisplay != SINGLETON_ROW)
+ {
+ if (!rRef.IsColRel())
+ rBuffer.append('$');
+ if (!ValidCol(rAbsRef.Col()) || rRef.IsColDeleted())
+ rBuffer.append(rErrRef);
+ else
+ MakeColStr(rBuffer, rAbsRef.Col());
+ }
+
+ if (eSingletonDisplay != SINGLETON_COL)
+ {
+ if (!rRef.IsRowRel())
+ rBuffer.append('$');
+ if (!ValidRow(rAbsRef.Row()) || rRef.IsRowDeleted())
+ rBuffer.append(rErrRef);
+ else
+ MakeRowStr(rBuffer, rAbsRef.Row());
+ }
+ }
+
+ static SingletonDisplay getSingletonDisplay( const ScAddress& rAbs1, const ScAddress& rAbs2,
+ const ScComplexRefData& rRef )
+ {
+ // If any part is error, display as such.
+ if (!ValidCol(rAbs1.Col()) || rRef.Ref1.IsColDeleted() || !ValidRow(rAbs1.Row()) || rRef.Ref1.IsRowDeleted() ||
+ !ValidCol(rAbs2.Col()) || rRef.Ref2.IsColDeleted() || !ValidRow(rAbs2.Row()) || rRef.Ref2.IsRowDeleted())
+ return SINGLETON_NONE;
+
+ // A:A or $A:$A or A:$A or $A:A, both row anchors must be absolute.
+ if (rAbs1.Row() == 0 && rAbs2.Row() == MAXROW && !rRef.Ref1.IsRowRel() && !rRef.Ref2.IsRowRel())
+ return SINGLETON_COL;
+
+ // 1:1 or $1:$1 or 1:$1 or $1:1, both column anchors must be absolute.
+ if (rAbs1.Col() == 0 && rAbs2.Col() == MAXCOL && !rRef.Ref1.IsColRel() && !rRef.Ref2.IsColRel())
+ return SINGLETON_ROW;
+
+ return SINGLETON_NONE;
}
virtual void makeRefStr( OUStringBuffer& rBuffer,
@@ -808,18 +848,19 @@ struct ConventionOOO_A1 : public Convention_A1
bool bSingleRef,
bool /*bFromRangeName*/ ) const SAL_OVERRIDE
{
- ScComplexRefData aRef( rRef );
// In case absolute/relative positions weren't separately available:
// transform relative to absolute!
- ScAddress aAbs1 = aRef.Ref1.toAbs(rPos), aAbs2;
+ ScAddress aAbs1 = rRef.Ref1.toAbs(rPos), aAbs2;
if( !bSingleRef )
- aAbs2 = aRef.Ref2.toAbs(rPos);
+ aAbs2 = rRef.Ref2.toAbs(rPos);
- MakeOneRefStrImpl(rBuffer, rErrRef, rTabNames, aRef.Ref1, aAbs1, false, false);
+ SingletonDisplay eSingleton = bSingleRef ? SINGLETON_NONE : getSingletonDisplay( aAbs1, aAbs2, rRef);
+ MakeOneRefStrImpl(rBuffer, rErrRef, rTabNames, rRef.Ref1, aAbs1, false, false, eSingleton);
if (!bSingleRef)
{
rBuffer.append(':');
- MakeOneRefStrImpl(rBuffer, rErrRef, rTabNames, aRef.Ref2, aAbs2, aAbs1.Tab() != aAbs2.Tab(), false);
+ MakeOneRefStrImpl(rBuffer, rErrRef, rTabNames, rRef.Ref2, aAbs2, aAbs1.Tab() != aAbs2.Tab(), false,
+ eSingleton);
}
}
@@ -963,12 +1004,11 @@ struct ConventionOOO_A1_ODF : public ConventionOOO_A1
bool /*bFromRangeName*/ ) const SAL_OVERRIDE
{
rBuffer.append('[');
- ScComplexRefData aRef( rRef );
// In case absolute/relative positions weren't separately available:
// transform relative to absolute!
- ScAddress aAbs1 = aRef.Ref1.toAbs(rPos), aAbs2;
+ ScAddress aAbs1 = rRef.Ref1.toAbs(rPos), aAbs2;
if( !bSingleRef )
- aAbs2 = aRef.Ref2.toAbs(rPos);
+ aAbs2 = rRef.Ref2.toAbs(rPos);
if (FormulaGrammar::isODFF(eGram) && (!ValidAddress(aAbs1) || !ValidAddress(aAbs2)))
{
@@ -979,11 +1019,13 @@ struct ConventionOOO_A1_ODF : public ConventionOOO_A1
}
else
{
- MakeOneRefStrImpl(rBuffer, rErrRef, rTabNames, aRef.Ref1, aAbs1, false, true);
+ SingletonDisplay eSingleton = bSingleRef ? SINGLETON_NONE : getSingletonDisplay( aAbs1, aAbs2, rRef);
+ MakeOneRefStrImpl(rBuffer, rErrRef, rTabNames, rRef.Ref1, aAbs1, false, true, eSingleton);
if (!bSingleRef)
{
rBuffer.append(':');
- MakeOneRefStrImpl(rBuffer, rErrRef, rTabNames, aRef.Ref2, aAbs2, aAbs1.Tab() != aAbs2.Tab(), true);
+ MakeOneRefStrImpl(rBuffer, rErrRef, rTabNames, rRef.Ref2, aAbs2, aAbs1.Tab() != aAbs2.Tab(), true,
+ eSingleton);
}
}
rBuffer.append(']');