chart-odf-always-calc-a1.diff: always store ranges in ODF using A1 syntax
n#463305
This commit is contained in:
parent
4ef978de83
commit
98b4e6ddc7
2 changed files with 60 additions and 2 deletions
|
@ -35,6 +35,11 @@
|
|||
#include <com/sun/star/table/CellRangeAddress.hpp>
|
||||
#include <com/sun/star/uno/Sequence.hxx>
|
||||
|
||||
// Chart always stores cell range addresses using CONV_OOO convention. But
|
||||
// if parsing with CONV_OOO fails, try parsing it using the current address
|
||||
// convention.
|
||||
#define CHART_ADDRESS_CONV_WORKAROUND 1
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
class SvStream;
|
||||
|
|
|
@ -476,6 +476,11 @@ sal_Bool ScRangeStringConverter::GetAddressFromString(
|
|||
{
|
||||
if ((rAddress.Parse( sToken, const_cast<ScDocument*>(pDocument), eConv ) & SCA_VALID) == SCA_VALID)
|
||||
return true;
|
||||
#if CHART_ADDRESS_CONV_WORKAROUND
|
||||
::formula::FormulaGrammar::AddressConvention eConvUI = pDocument->GetAddressConvention();
|
||||
if (eConv != eConvUI)
|
||||
return ((rAddress.Parse(sToken, const_cast<ScDocument*>(pDocument), eConvUI) & SCA_VALID) == SCA_VALID);
|
||||
#endif
|
||||
}
|
||||
return sal_False;
|
||||
}
|
||||
|
@ -502,6 +507,11 @@ sal_Bool ScRangeStringConverter::GetRangeFromString(
|
|||
if ( aUIString.GetChar(0) == (sal_Unicode) '.' )
|
||||
aUIString.Erase( 0, 1 );
|
||||
bResult = ((rRange.aStart.Parse( aUIString, const_cast<ScDocument*> (pDocument), eConv) & SCA_VALID) == SCA_VALID);
|
||||
#if CHART_ADDRESS_CONV_WORKAROUND
|
||||
if (!bResult && eConv != eConv)
|
||||
bResult = ((rRange.aStart.Parse(
|
||||
aUIString, const_cast<ScDocument*>(pDocument), eConv) & SCA_VALID) == SCA_VALID);
|
||||
#endif
|
||||
rRange.aEnd = rRange.aStart;
|
||||
}
|
||||
else
|
||||
|
@ -526,6 +536,15 @@ sal_Bool ScRangeStringConverter::GetRangeFromString(
|
|||
eConv) & SCA_VALID) == SCA_VALID) &&
|
||||
((rRange.aEnd.Parse( aUIString.Copy((xub_StrLen)nIndex+1), const_cast<ScDocument*>(pDocument),
|
||||
eConv) & SCA_VALID) == SCA_VALID);
|
||||
#if CHART_ADDRESS_CONV_WORKAROUND
|
||||
if (!bResult && eConv != eConv)
|
||||
{
|
||||
bResult = ((rRange.aStart.Parse( aUIString.Copy(0, (xub_StrLen)nIndex), const_cast<ScDocument*>(pDocument),
|
||||
eConv) & SCA_VALID) == SCA_VALID) &&
|
||||
((rRange.aEnd.Parse( aUIString.Copy((xub_StrLen)nIndex+1), const_cast<ScDocument*>(pDocument),
|
||||
eConv) & SCA_VALID) == SCA_VALID);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -860,6 +879,8 @@ static void lcl_appendCellRangeAddress(
|
|||
|
||||
void ScRangeStringConverter::GetStringFromXMLRangeString( OUString& rString, const OUString& rXMLRange, ScDocument* pDoc )
|
||||
{
|
||||
FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
|
||||
const OUString aRangeSep = GetScCompilerNativeSymbol(ocSep);
|
||||
const sal_Unicode cSep = ' ';
|
||||
const sal_Unicode cQuote = '\'';
|
||||
|
||||
|
@ -912,13 +933,37 @@ void ScRangeStringConverter::GetStringFromXMLRangeString( OUString& rString, con
|
|||
rtl::OUString aBuf;
|
||||
USHORT nRet = aCell1.Parse(aBeginCell, pDoc, FormulaGrammar::CONV_OOO, &aExtInfo1);
|
||||
if ((nRet & SCA_VALID) != SCA_VALID)
|
||||
{
|
||||
// first cell is invalid.
|
||||
#if CHART_ADDRESS_CONV_WORKAROUND
|
||||
if (eConv == FormulaGrammar::CONV_OOO)
|
||||
continue;
|
||||
|
||||
nRet = aCell1.Parse(aBeginCell, pDoc, eConv, &aExtInfo1);
|
||||
if ((nRet & SCA_VALID) != SCA_VALID)
|
||||
// first cell is really invalid.
|
||||
continue;
|
||||
#else
|
||||
continue;
|
||||
#endif
|
||||
}
|
||||
|
||||
nRet = aCell2.Parse(aEndCell, pDoc, FormulaGrammar::CONV_OOO, &aExtInfo2);
|
||||
if ((nRet & SCA_VALID) != SCA_VALID)
|
||||
{
|
||||
// second cell is invalid.
|
||||
#if CHART_ADDRESS_CONV_WORKAROUND
|
||||
if (eConv == FormulaGrammar::CONV_OOO)
|
||||
continue;
|
||||
|
||||
nRet = aCell2.Parse(aEndCell, pDoc, eConv, &aExtInfo2);
|
||||
if ((nRet & SCA_VALID) != SCA_VALID)
|
||||
// second cell is really invalid.
|
||||
continue;
|
||||
#else
|
||||
continue;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (aExtInfo1.mnFileId != aExtInfo2.mnFileId || aExtInfo1.mbExternal != aExtInfo2.mbExternal)
|
||||
// external info inconsistency.
|
||||
|
@ -929,7 +974,7 @@ void ScRangeStringConverter::GetStringFromXMLRangeString( OUString& rString, con
|
|||
if (bFirst)
|
||||
bFirst = false;
|
||||
else
|
||||
aRetStr.appendAscii(";");
|
||||
aRetStr.append(aRangeSep);
|
||||
|
||||
lcl_appendCellRangeAddress(aRetStr, pDoc, aCell1, aCell2, aExtInfo1, aExtInfo2);
|
||||
}
|
||||
|
@ -940,14 +985,22 @@ void ScRangeStringConverter::GetStringFromXMLRangeString( OUString& rString, con
|
|||
ScAddress aCell;
|
||||
USHORT nRet = aCell.Parse(aToken, pDoc, ::formula::FormulaGrammar::CONV_OOO, &aExtInfo);
|
||||
if ((nRet & SCA_VALID) != SCA_VALID)
|
||||
{
|
||||
#if CHART_ADDRESS_CONV_WORKAROUND
|
||||
nRet = aCell.Parse(aToken, pDoc, eConv, &aExtInfo);
|
||||
if ((nRet & SCA_VALID) != SCA_VALID)
|
||||
continue;
|
||||
#else
|
||||
continue;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Looks good!
|
||||
|
||||
if (bFirst)
|
||||
bFirst = false;
|
||||
else
|
||||
aRetStr.appendAscii(";");
|
||||
aRetStr.append(aRangeSep);
|
||||
|
||||
lcl_appendCellAddress(aRetStr, pDoc, aCell, aExtInfo);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue