1 diff --git sc/inc/reftokenhelper.hxx sc/inc/reftokenhelper.hxx
2 index b1159cc..d7b335f 100644
3 --- sc/inc/reftokenhelper.hxx
4 +++ sc/inc/reftokenhelper.hxx
5 @@ -56,7 +56,8 @@ public:
6 * The source range may consist of multiple ranges separated by ';'s.
8 static void compileRangeRepresentation(
9 - ::std::vector<ScSharedTokenRef>& rRefTokens, const ::rtl::OUString& rRangeStr, ScDocument* pDoc);
10 + ::std::vector<ScSharedTokenRef>& rRefTokens, const ::rtl::OUString& rRangeStr, ScDocument* pDoc,
11 + ::formula::FormulaGrammar::Grammar eGrammar = ::formula::FormulaGrammar::GRAM_ENGLISH);
13 static bool getRangeFromToken(ScRange& rRange, const ScSharedTokenRef& pToken, bool bExternal = false);
15 diff --git sc/source/core/data/documen5.cxx sc/source/core/data/documen5.cxx
16 index 19f6b09..a921945 100644
17 --- sc/source/core/data/documen5.cxx
18 +++ sc/source/core/data/documen5.cxx
19 @@ -130,6 +130,7 @@ void lcl_SetChartRanges( const uno::Reference< chart2::XChartDocument >& xChartD
23 + // the range string must be in Calc A1 format.
24 uno::Reference< chart2::data::XDataSequence > xNewSeq(
25 xDataProvider->createDataSequenceByRangeRepresentation( rRanges[nRange++] ));
27 @@ -145,6 +146,7 @@ void lcl_SetChartRanges( const uno::Reference< chart2::XChartDocument >& xChartD
31 + // the range string must be in Calc A1 format.
32 uno::Reference< chart2::data::XDataSequence > xNewSeq(
33 xDataProvider->createDataSequenceByRangeRepresentation( rRanges[nRange++] ));
35 @@ -391,7 +393,7 @@ void ScDocument::GetChartRanges( const String& rChartName, ::std::vector< ScRang
36 for( sal_Int32 nN=0; nN<aRangeStrings.getLength(); nN++ )
39 - aRanges.Parse( aRangeStrings[nN], pSheetNameDoc );
40 + aRanges.Parse( aRangeStrings[nN], pSheetNameDoc, SCA_VALID, pSheetNameDoc->GetAddressConvention() );
41 rRangesVector.push_back(aRanges);
44 @@ -407,8 +409,8 @@ void ScDocument::SetChartRanges( const String& rChartName, const ::std::vector<
45 for( sal_Int32 nN=0; nN<nCount; nN++ )
47 ScRangeList aScRangeList( rRangesVector[nN] );
49 - aScRangeList.Format( sRangeStr, SCR_ABS_3D, this, GetAddressConvention() );
50 + String sRangeStr; // This range must be in Calc A1 format.
51 + aScRangeList.Format( sRangeStr, SCR_ABS_3D, this );
52 aRangeStrings[nN]=sRangeStr;
54 lcl_SetChartRanges( xChartDoc, aRangeStrings );
55 diff --git sc/source/core/tool/reftokenhelper.cxx sc/source/core/tool/reftokenhelper.cxx
56 index 8ecb44a..0e07819 100644
57 --- sc/source/core/tool/reftokenhelper.cxx
58 +++ sc/source/core/tool/reftokenhelper.cxx
59 @@ -49,7 +49,7 @@ using ::std::auto_ptr;
60 using ::rtl::OUString;
62 void ScRefTokenHelper::compileRangeRepresentation(
63 - vector<ScSharedTokenRef>& rRefTokens, const OUString& rRangeStr, ScDocument* pDoc)
64 + vector<ScSharedTokenRef>& rRefTokens, const OUString& rRangeStr, ScDocument* pDoc, FormulaGrammar::Grammar eGrammar)
66 const sal_Unicode cSep = ';';
67 const sal_Unicode cQuote = '\'';
68 @@ -63,7 +63,7 @@ void ScRefTokenHelper::compileRangeRepresentation(
71 ScCompiler aCompiler(pDoc, ScAddress(0,0,0));
72 - aCompiler.SetGrammar(FormulaGrammar::GRAM_ENGLISH);
73 + aCompiler.SetGrammar(eGrammar);
74 auto_ptr<ScTokenArray> pArray(aCompiler.CompileString(aToken));
76 // There should only be one reference per range token.
77 diff --git sc/source/ui/drawfunc/fuins2.cxx sc/source/ui/drawfunc/fuins2.cxx
78 index f2562a3..22b46b9 100644
79 --- sc/source/ui/drawfunc/fuins2.cxx
80 +++ sc/source/ui/drawfunc/fuins2.cxx
81 @@ -167,8 +167,10 @@ void lcl_ChartInit( const uno::Reference < embed::XEmbeddedObject >& xObj, ScVie
82 if ( aRangeListRef->Count() )
84 pScDoc->LimitChartIfAll( aRangeListRef ); // limit whole columns/rows to used area
86 + // update string from modified ranges. The ranges must be in the current formula syntax.
88 - aRangeListRef->Format( aTmpStr, SCR_ABS_3D, pScDoc, pScDoc->GetAddressConvention() ); // update string from changed ranges
89 + aRangeListRef->Format( aTmpStr, SCR_ABS_3D, pScDoc, pScDoc->GetAddressConvention() );
90 aRangeString = aTmpStr;
92 ScChartPositioner aChartPositioner( pScDoc, aRangeListRef );
93 diff --git sc/source/ui/unoobj/chart2uno.cxx sc/source/ui/unoobj/chart2uno.cxx
94 index 8bbd382..d9c2698 100644
95 --- sc/source/ui/unoobj/chart2uno.cxx
96 +++ sc/source/ui/unoobj/chart2uno.cxx
97 @@ -1057,7 +1057,7 @@ void lcl_SeperateOneRowRange(ScRange aR, const ScAddress& rPos, ScRangeListRef&
100 vector<ScSharedTokenRef> aTokens;
101 - ScRefTokenHelper::compileRangeRepresentation(aTokens, aRangeRepresentation, m_pDocument);
102 + ScRefTokenHelper::compileRangeRepresentation(aTokens, aRangeRepresentation, m_pDocument, m_pDocument->GetGrammar());
103 return !aTokens.empty();
106 @@ -1451,7 +1451,7 @@ ScChart2DataProvider::createDataSource(
109 vector<ScSharedTokenRef> aRefTokens;
110 - ScRefTokenHelper::compileRangeRepresentation(aRefTokens, aRangeRepresentation, m_pDocument);
111 + ScRefTokenHelper::compileRangeRepresentation(aRefTokens, aRangeRepresentation, m_pDocument, m_pDocument->GetGrammar());
112 if (aRefTokens.empty())
113 // Invalid range representation. Bail out.
114 throw lang::IllegalArgumentException();
115 @@ -2184,7 +2184,7 @@ uno::Sequence< beans::PropertyValue > SAL_CALL ScChart2DataProvider::detectArgum
118 vector<ScSharedTokenRef> aTokens;
119 - ScRefTokenHelper::compileRangeRepresentation(aTokens, aRangeRepresentation, m_pDocument);
120 + ScRefTokenHelper::compileRangeRepresentation(aTokens, aRangeRepresentation, m_pDocument, m_pDocument->GetGrammar());
121 return !aTokens.empty();
124 @@ -2201,6 +2201,12 @@ uno::Reference< chart2::data::XDataSequence > SAL_CALL
125 if(!m_pDocument || (aRangeRepresentation.getLength() == 0))
128 + // Note: the range representation must be in Calc A1 format. The import
129 + // filters use this method to pass data ranges, and they have no idea what
130 + // the current formula syntax is. In the future we should add another
131 + // method to allow the client code to directly pass tokens representing
134 vector<ScSharedTokenRef> aRefTokens;
135 ScRefTokenHelper::compileRangeRepresentation(aRefTokens, aRangeRepresentation, m_pDocument);
136 if (aRefTokens.empty())
137 @@ -2246,7 +2252,7 @@ rtl::OUString SAL_CALL ScChart2DataProvider::convertRangeToXML( const rtl::OUStr
140 vector<ScSharedTokenRef> aRefTokens;
141 - ScRefTokenHelper::compileRangeRepresentation(aRefTokens, sRangeRepresentation, m_pDocument);
142 + ScRefTokenHelper::compileRangeRepresentation(aRefTokens, sRangeRepresentation, m_pDocument, m_pDocument->GetGrammar());
143 if (aRefTokens.empty())
144 throw lang::IllegalArgumentException();
146 @@ -2405,7 +2411,7 @@ void ScChart2DataProvider::detectRangesFromDataSource(vector<ScSharedTokenRef>&
148 const OUString& rRangeRep = *itr;
149 vector<ScSharedTokenRef> aTokens;
150 - ScRefTokenHelper::compileRangeRepresentation(aTokens, rRangeRep, m_pDocument);
151 + ScRefTokenHelper::compileRangeRepresentation(aTokens, rRangeRep, m_pDocument, m_pDocument->GetGrammar());
153 CollectRefTokens func;
154 func = for_each(aTokens.begin(), aTokens.end(), func);
155 diff --git sc/inc/document.hxx sc/inc/document.hxx
156 index 810f215..1be2397 100644
157 --- sc/inc/document.hxx
158 +++ sc/inc/document.hxx
159 @@ -607,7 +607,7 @@ public:
160 SC_DLLPUBLIC BOOL IsActiveScenario( SCTAB nTab ) const;
161 SC_DLLPUBLIC void SetActiveScenario( SCTAB nTab, BOOL bActive ); // nur fuer Undo etc.
162 SC_DLLPUBLIC formula::FormulaGrammar::AddressConvention GetAddressConvention() const;
163 - formula::FormulaGrammar::Grammar GetGrammar() const;
164 + SC_DLLPUBLIC formula::FormulaGrammar::Grammar GetGrammar() const;
165 void SetGrammar( formula::FormulaGrammar::Grammar eGram );
166 SC_DLLPUBLIC BYTE GetLinkMode( SCTAB nTab ) const;
167 BOOL IsLinked( SCTAB nTab ) const;
168 diff --git sc/source/filter/excel/xechart.cxx sc/source/filter/excel/xechart.cxx
169 index b01bdc6..cf3f218 100644
170 --- sc/source/filter/excel/xechart.cxx
171 +++ sc/source/filter/excel/xechart.cxx
172 @@ -717,11 +717,12 @@ sal_uInt16 XclExpChSourceLink::ConvertDataSequence( Reference< XDataSequence > x
176 - // Compile the range representation string into token array.
177 + // Compile the range representation string into token array. Note that the
178 + // source range text depends on the current grammar.
179 OUString aRangeRepr = xDataSeq->getSourceRangeRepresentation();
180 ScRangeList aScRanges;
181 ScCompiler aComp(GetDocPtr(), ScAddress());
182 - aComp.SetGrammar(FormulaGrammar::GRAM_ENGLISH);
183 + aComp.SetGrammar(GetDocPtr()->GetGrammar());
184 ScTokenArray* pArray = aComp.CompileString(aRangeRepr);