summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@suse.com>2011-08-09 15:49:15 -0400
committerKohei Yoshida <kohei.yoshida@suse.com>2011-08-09 15:52:34 -0400
commita81389fb840f21f855d0f7c900821587d33782da (patch)
treee88ddf82390a22dd173c4d9270a852c3e01e17b4 /sc
parentb2bd33ea253952ad3f8b4bfe4bd54c4af16cb86e (diff)
Correctly import from Excel charts with multiple ranges.
This was "fixed" in i#107275, but the fix only worked in locales where the range/argument separator was ';' (e.g. German locale). This is the correct fix that works in all locales regardless of the separator.
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/reftokenhelper.hxx2
-rw-r--r--sc/source/core/tool/reftokenhelper.cxx4
-rw-r--r--sc/source/filter/xml/XMLTableShapeResizer.cxx6
-rw-r--r--sc/source/ui/unoobj/chart2uno.cxx38
4 files changed, 34 insertions, 16 deletions
diff --git a/sc/inc/reftokenhelper.hxx b/sc/inc/reftokenhelper.hxx
index 36d28f156780..9119e3eb9b82 100644
--- a/sc/inc/reftokenhelper.hxx
+++ b/sc/inc/reftokenhelper.hxx
@@ -55,7 +55,7 @@ public:
*/
static void compileRangeRepresentation(
::std::vector<ScTokenRef>& rRefTokens, const ::rtl::OUString& rRangeStr, ScDocument* pDoc,
- ::formula::FormulaGrammar::Grammar eGrammar = ::formula::FormulaGrammar::GRAM_ENGLISH);
+ const sal_Unicode cSep, ::formula::FormulaGrammar::Grammar eGrammar);
static bool getRangeFromToken(ScRange& rRange, const ScTokenRef& pToken, bool bExternal = false);
diff --git a/sc/source/core/tool/reftokenhelper.cxx b/sc/source/core/tool/reftokenhelper.cxx
index 3e1a1f32f773..f4f09d635575 100644
--- a/sc/source/core/tool/reftokenhelper.cxx
+++ b/sc/source/core/tool/reftokenhelper.cxx
@@ -47,9 +47,9 @@ using ::std::auto_ptr;
using ::rtl::OUString;
void ScRefTokenHelper::compileRangeRepresentation(
- vector<ScTokenRef>& rRefTokens, const OUString& rRangeStr, ScDocument* pDoc, FormulaGrammar::Grammar eGrammar)
+ vector<ScTokenRef>& rRefTokens, const OUString& rRangeStr, ScDocument* pDoc,
+ const sal_Unicode cSep, FormulaGrammar::Grammar eGrammar)
{
- const sal_Unicode cSep = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
const sal_Unicode cQuote = '\'';
// #i107275# ignore parentheses
diff --git a/sc/source/filter/xml/XMLTableShapeResizer.cxx b/sc/source/filter/xml/XMLTableShapeResizer.cxx
index 0920b0ae6d43..c12a421f741b 100644
--- a/sc/source/filter/xml/XMLTableShapeResizer.cxx
+++ b/sc/source/filter/xml/XMLTableShapeResizer.cxx
@@ -35,7 +35,9 @@
#include "chartlis.hxx"
#include "XMLConverter.hxx"
#include "rangeutl.hxx"
+#include "compiler.hxx"
#include "reftokenhelper.hxx"
+
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
#include <com/sun/star/table/XColumnRowRange.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
@@ -93,7 +95,9 @@ void ScMyOLEFixer::CreateChartListener(ScDocument* pDoc,
return;
auto_ptr< vector<ScTokenRef> > pRefTokens(new vector<ScTokenRef>);
- ScRefTokenHelper::compileRangeRepresentation(*pRefTokens, aRangeStr, pDoc);
+ const sal_Unicode cSep = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
+ ScRefTokenHelper::compileRangeRepresentation(
+ *pRefTokens, aRangeStr, pDoc, cSep, formula::FormulaGrammar::GRAM_ENGLISH);
if (!pRefTokens->empty())
{
ScChartListener* pCL(new ScChartListener(rName, pDoc, pRefTokens.release()));
diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx
index 5d511026f48b..b5ac0c8ce9d6 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -1030,7 +1030,9 @@ void ScChart2DataProvider::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint
}
vector<ScTokenRef> aTokens;
- ScRefTokenHelper::compileRangeRepresentation(aTokens, aRangeRepresentation, m_pDocument, m_pDocument->GetGrammar());
+ const sal_Unicode cSep = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
+ ScRefTokenHelper::compileRangeRepresentation(
+ aTokens, aRangeRepresentation, m_pDocument, cSep, m_pDocument->GetGrammar());
return !aTokens.empty();
}
@@ -1406,7 +1408,9 @@ ScChart2DataProvider::createDataSource(
}
vector<ScTokenRef> aRefTokens;
- ScRefTokenHelper::compileRangeRepresentation(aRefTokens, aRangeRepresentation, m_pDocument, m_pDocument->GetGrammar());
+ const sal_Unicode cSep = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
+ ScRefTokenHelper::compileRangeRepresentation(
+ aRefTokens, aRangeRepresentation, m_pDocument, cSep, m_pDocument->GetGrammar());
if (aRefTokens.empty())
// Invalid range representation. Bail out.
throw lang::IllegalArgumentException();
@@ -1730,7 +1734,9 @@ uno::Sequence< beans::PropertyValue > SAL_CALL ScChart2DataProvider::detectArgum
{
bFirstCellAsLabel = true;
vector<ScTokenRef> aTokens;
- ScRefTokenHelper::compileRangeRepresentation( aTokens, xLabel->getSourceRangeRepresentation(), m_pDocument, m_pDocument->GetGrammar() );
+ const sal_Unicode cSep = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
+ ScRefTokenHelper::compileRangeRepresentation(
+ aTokens, xLabel->getSourceRangeRepresentation(), m_pDocument, cSep, m_pDocument->GetGrammar());
aLabel.initRangeAnalyzer(aTokens);
vector<ScTokenRef>::const_iterator itr = aTokens.begin(), itrEnd = aTokens.end();
for (; itr != itrEnd; ++itr)
@@ -1747,7 +1753,9 @@ uno::Sequence< beans::PropertyValue > SAL_CALL ScChart2DataProvider::detectArgum
if( xValues.is())
{
vector<ScTokenRef> aTokens;
- ScRefTokenHelper::compileRangeRepresentation( aTokens, xValues->getSourceRangeRepresentation(), m_pDocument, m_pDocument->GetGrammar() );
+ const sal_Unicode cSep = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
+ ScRefTokenHelper::compileRangeRepresentation(
+ aTokens, xValues->getSourceRangeRepresentation(), m_pDocument, cSep, m_pDocument->GetGrammar());
aValues.initRangeAnalyzer(aTokens);
vector<ScTokenRef>::const_iterator itr = aTokens.begin(), itrEnd = aTokens.end();
for (; itr != itrEnd; ++itr)
@@ -1954,7 +1962,9 @@ uno::Sequence< beans::PropertyValue > SAL_CALL ScChart2DataProvider::detectArgum
return false;
vector<ScTokenRef> aTokens;
- ScRefTokenHelper::compileRangeRepresentation(aTokens, aRangeRepresentation, m_pDocument, m_pDocument->GetGrammar());
+ const sal_Unicode cSep = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
+ ScRefTokenHelper::compileRangeRepresentation(
+ aTokens, aRangeRepresentation, m_pDocument, cSep, m_pDocument->GetGrammar());
return !aTokens.empty();
}
@@ -1971,14 +1981,16 @@ uno::Reference< chart2::data::XDataSequence > SAL_CALL
if(!m_pDocument || (aRangeRepresentation.getLength() == 0))
return xResult;
- // Note: the range representation must be in Calc A1 format. The import
- // filters use this method to pass data ranges, and they have no idea what
- // the current formula syntax is. In the future we should add another
- // method to allow the client code to directly pass tokens representing
- // ranges.
+ // Note: the range representation must be in Calc A1 format, with English
+ // function names and ';' as the union operator in case of multiple
+ // ranges. The import filters use this method to pass data ranges, and
+ // they have no idea what the current formula syntax is. In the future we
+ // should add another method to allow the client code to directly pass
+ // tokens representing ranges.
vector<ScTokenRef> aRefTokens;
- ScRefTokenHelper::compileRangeRepresentation(aRefTokens, aRangeRepresentation, m_pDocument);
+ ScRefTokenHelper::compileRangeRepresentation(
+ aRefTokens, aRangeRepresentation, m_pDocument, ';', FormulaGrammar::GRAM_ENGLISH);
if (aRefTokens.empty())
return xResult;
@@ -2016,7 +2028,9 @@ rtl::OUString SAL_CALL ScChart2DataProvider::convertRangeToXML( const rtl::OUStr
return aRet;
vector<ScTokenRef> aRefTokens;
- ScRefTokenHelper::compileRangeRepresentation(aRefTokens, sRangeRepresentation, m_pDocument, m_pDocument->GetGrammar());
+ const sal_Unicode cSep = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
+ ScRefTokenHelper::compileRangeRepresentation(
+ aRefTokens, sRangeRepresentation, m_pDocument, cSep, m_pDocument->GetGrammar());
if (aRefTokens.empty())
throw lang::IllegalArgumentException();