merge the formfield patch from ooo-build
[ooovba.git] / applied_patches / 0136-chart-odf-always-calc-a1.diff
blobb79e05d3764cb7a814b4aef969e7fc390b5aa6bc
1 diff --git sc/inc/rangeutl.hxx sc/inc/rangeutl.hxx
2 index 58c00b2..d540256 100644
3 --- sc/inc/rangeutl.hxx
4 +++ sc/inc/rangeutl.hxx
5 @@ -38,6 +38,11 @@
6 #include <com/sun/star/table/CellRangeAddress.hpp>
7 #include <com/sun/star/uno/Sequence.hxx>
9 +// Chart always stores cell range addresses using CONV_OOO convention. But
10 +// if parsing with CONV_OOO fails, try parsing it using the current address
11 +// convention.
12 +#define CHART_ADDRESS_CONV_WORKAROUND 1
14 //------------------------------------------------------------------------
16 class SvStream;
17 diff --git sc/source/core/tool/rangeutl.cxx sc/source/core/tool/rangeutl.cxx
18 index 82d07bc..84a410c 100644
19 --- sc/source/core/tool/rangeutl.cxx
20 +++ sc/source/core/tool/rangeutl.cxx
21 @@ -480,6 +480,11 @@ sal_Bool ScRangeStringConverter::GetAddressFromString(
23 if ((rAddress.Parse( sToken, const_cast<ScDocument*>(pDocument), eConv ) & SCA_VALID) == SCA_VALID)
24 return true;
25 +#if CHART_ADDRESS_CONV_WORKAROUND
26 + ::formula::FormulaGrammar::AddressConvention eConvUI = pDocument->GetAddressConvention();
27 + if (eConv != eConvUI)
28 + return ((rAddress.Parse(sToken, const_cast<ScDocument*>(pDocument), eConvUI) & SCA_VALID) == SCA_VALID);
29 +#endif
31 return sal_False;
33 @@ -506,6 +511,11 @@ sal_Bool ScRangeStringConverter::GetRangeFromString(
34 if ( aUIString.GetChar(0) == (sal_Unicode) '.' )
35 aUIString.Erase( 0, 1 );
36 bResult = ((rRange.aStart.Parse( aUIString, const_cast<ScDocument*> (pDocument), eConv) & SCA_VALID) == SCA_VALID);
37 +#if CHART_ADDRESS_CONV_WORKAROUND
38 + if (!bResult && eConv != eConv)
39 + bResult = ((rRange.aStart.Parse(
40 + aUIString, const_cast<ScDocument*>(pDocument), eConv) & SCA_VALID) == SCA_VALID);
41 +#endif
42 rRange.aEnd = rRange.aStart;
44 else
45 @@ -530,6 +540,15 @@ sal_Bool ScRangeStringConverter::GetRangeFromString(
46 eConv) & SCA_VALID) == SCA_VALID) &&
47 ((rRange.aEnd.Parse( aUIString.Copy((xub_StrLen)nIndex+1), const_cast<ScDocument*>(pDocument),
48 eConv) & SCA_VALID) == SCA_VALID);
49 +#if CHART_ADDRESS_CONV_WORKAROUND
50 + if (!bResult && eConv != eConv)
51 + {
52 + bResult = ((rRange.aStart.Parse( aUIString.Copy(0, (xub_StrLen)nIndex), const_cast<ScDocument*>(pDocument),
53 + eConv) & SCA_VALID) == SCA_VALID) &&
54 + ((rRange.aEnd.Parse( aUIString.Copy((xub_StrLen)nIndex+1), const_cast<ScDocument*>(pDocument),
55 + eConv) & SCA_VALID) == SCA_VALID);
56 + }
57 +#endif
61 @@ -864,6 +885,8 @@ static void lcl_appendCellRangeAddress(
63 void ScRangeStringConverter::GetStringFromXMLRangeString( OUString& rString, const OUString& rXMLRange, ScDocument* pDoc )
65 + FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
66 + const OUString aRangeSep = GetScCompilerNativeSymbol(ocSep);
67 const sal_Unicode cSep = ' ';
68 const sal_Unicode cQuote = '\'';
70 @@ -903,13 +926,37 @@ void ScRangeStringConverter::GetStringFromXMLRangeString( OUString& rString, con
71 rtl::OUString aBuf;
72 USHORT nRet = aCell1.Parse(aBeginCell, pDoc, FormulaGrammar::CONV_OOO, &aExtInfo1);
73 if ((nRet & SCA_VALID) != SCA_VALID)
74 + {
75 // first cell is invalid.
76 +#if CHART_ADDRESS_CONV_WORKAROUND
77 + if (eConv == FormulaGrammar::CONV_OOO)
78 + continue;
80 + nRet = aCell1.Parse(aBeginCell, pDoc, eConv, &aExtInfo1);
81 + if ((nRet & SCA_VALID) != SCA_VALID)
82 + // first cell is really invalid.
83 + continue;
84 +#else
85 continue;
86 +#endif
87 + }
89 nRet = aCell2.Parse(aEndCell, pDoc, FormulaGrammar::CONV_OOO, &aExtInfo2);
90 if ((nRet & SCA_VALID) != SCA_VALID)
91 + {
92 // second cell is invalid.
93 +#if CHART_ADDRESS_CONV_WORKAROUND
94 + if (eConv == FormulaGrammar::CONV_OOO)
95 + continue;
97 + nRet = aCell2.Parse(aEndCell, pDoc, eConv, &aExtInfo2);
98 + if ((nRet & SCA_VALID) != SCA_VALID)
99 + // second cell is really invalid.
100 + continue;
101 +#else
102 continue;
103 +#endif
106 if (aExtInfo1.mnFileId != aExtInfo2.mnFileId || aExtInfo1.mbExternal != aExtInfo2.mbExternal)
107 // external info inconsistency.
108 @@ -920,7 +967,7 @@ void ScRangeStringConverter::GetStringFromXMLRangeString( OUString& rString, con
109 if (bFirst)
110 bFirst = false;
111 else
112 - aRetStr.appendAscii(";");
113 + aRetStr.append(aRangeSep);
115 lcl_appendCellRangeAddress(aRetStr, pDoc, aCell1, aCell2, aExtInfo1, aExtInfo2);
117 @@ -931,14 +978,22 @@ void ScRangeStringConverter::GetStringFromXMLRangeString( OUString& rString, con
118 ScAddress aCell;
119 USHORT nRet = aCell.Parse(aToken, pDoc, ::formula::FormulaGrammar::CONV_OOO, &aExtInfo);
120 if ((nRet & SCA_VALID) != SCA_VALID)
122 +#if CHART_ADDRESS_CONV_WORKAROUND
123 + nRet = aCell.Parse(aToken, pDoc, eConv, &aExtInfo);
124 + if ((nRet & SCA_VALID) != SCA_VALID)
125 + continue;
126 +#else
127 continue;
128 +#endif
131 // Looks good!
133 if (bFirst)
134 bFirst = false;
135 else
136 - aRetStr.appendAscii(";");
137 + aRetStr.append(aRangeSep);
139 lcl_appendCellAddress(aRetStr, pDoc, aCell, aExtInfo);