summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-05-30 14:47:49 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-05-30 15:01:40 -0400
commit16e299afa4051affc357fe7990d7632b37c6aea7 (patch)
tree9a028f9dc5a729f21c551a969c6d15b947317153 /sc
parentc887ea477f0d674d3721ffdf9ef92b5b5bfc5528 (diff)
fdo#79174: Use 3D address when the input and output are on different sheets.
Also some cleanup, mostly to avoid storing separate address convention object, which is not really necessary. Change-Id: Id3e104043f08b6786de2e91d69361557b83890f9 (cherry picked from commit 0ab538885d818a7b3706df48a625e2523a8ebbdf)
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.cxx2
-rw-r--r--sc/source/ui/StatisticsDialogs/DescriptiveStatisticsDialog.cxx7
-rw-r--r--sc/source/ui/StatisticsDialogs/ExponentialSmoothingDialog.cxx2
-rw-r--r--sc/source/ui/StatisticsDialogs/FTestDialog.cxx2
-rw-r--r--sc/source/ui/StatisticsDialogs/MatrixComparisonGenerator.cxx2
-rw-r--r--sc/source/ui/StatisticsDialogs/MovingAverageDialog.cxx2
-rw-r--r--sc/source/ui/StatisticsDialogs/TTestDialog.cxx2
-rw-r--r--sc/source/ui/StatisticsDialogs/TableFillingAndNavigationTools.cxx22
-rw-r--r--sc/source/ui/inc/TableFillingAndNavigationTools.hxx13
9 files changed, 28 insertions, 26 deletions
diff --git a/sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.cxx b/sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.cxx
index 09617603beb9..a764c1397321 100644
--- a/sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.cxx
+++ b/sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.cxx
@@ -548,7 +548,7 @@ ScRange ScAnalysisOfVarianceDialog::ApplyOutput(ScDocShell* pDocShell)
{
AddressWalkerWriter output(mOutputAddress, pDocShell, mDocument,
formula::FormulaGrammar::mergeToGrammar(formula::FormulaGrammar::GRAM_ENGLISH, mAddressDetails.eConv));
- FormulaTemplate aTemplate(mDocument, mAddressDetails);
+ FormulaTemplate aTemplate(mDocument);
if (meFactor == SINGLE_FACTOR)
{
diff --git a/sc/source/ui/StatisticsDialogs/DescriptiveStatisticsDialog.cxx b/sc/source/ui/StatisticsDialogs/DescriptiveStatisticsDialog.cxx
index 3c56be5d48bc..0d98e79d9a1e 100644
--- a/sc/source/ui/StatisticsDialogs/DescriptiveStatisticsDialog.cxx
+++ b/sc/source/ui/StatisticsDialogs/DescriptiveStatisticsDialog.cxx
@@ -84,7 +84,7 @@ ScRange ScDescriptiveStatisticsDialog::ApplyOutput(ScDocShell* pDocShell)
{
AddressWalkerWriter aOutput(mOutputAddress, pDocShell, mDocument,
formula::FormulaGrammar::mergeToGrammar( formula::FormulaGrammar::GRAM_ENGLISH, mAddressDetails.eConv));
- FormulaTemplate aTemplate(mDocument, mAddressDetails);
+ FormulaTemplate aTemplate(mDocument);
boost::scoped_ptr<DataRangeIterator> pIterator;
if (mGroupedBy == BY_COLUMN)
@@ -94,6 +94,9 @@ ScRange ScDescriptiveStatisticsDialog::ApplyOutput(ScDocShell* pDocShell)
aOutput.nextColumn();
+ // Use explicit sheet name in case the input and output are on different sheets.
+ bool b3DAddress = mInputRange.aStart.Tab() != mOutputAddress.Tab();
+
// Write column/row labels
for( ; pIterator->hasNext(); pIterator->next() )
{
@@ -128,7 +131,7 @@ ScRange ScDescriptiveStatisticsDialog::ApplyOutput(ScDocShell* pDocShell)
for(sal_Int32 i = 0; lclCalcDefinitions[i].aFormula != NULL; i++)
{
aTemplate.setTemplate(lclCalcDefinitions[i].aFormula);
- aTemplate.applyRange(strWildcardRange, pIterator->get());
+ aTemplate.applyRange(strWildcardRange, pIterator->get(), b3DAddress);
aOutput.writeFormula(aTemplate.getTemplate());
aOutput.nextRow();
}
diff --git a/sc/source/ui/StatisticsDialogs/ExponentialSmoothingDialog.cxx b/sc/source/ui/StatisticsDialogs/ExponentialSmoothingDialog.cxx
index 9f2b8e2aac05..091f1a05833b 100644
--- a/sc/source/ui/StatisticsDialogs/ExponentialSmoothingDialog.cxx
+++ b/sc/source/ui/StatisticsDialogs/ExponentialSmoothingDialog.cxx
@@ -53,7 +53,7 @@ ScRange ScExponentialSmoothingDialog::ApplyOutput(ScDocShell* pDocShell)
{
AddressWalkerWriter output(mOutputAddress, pDocShell, mDocument,
formula::FormulaGrammar::mergeToGrammar( formula::FormulaGrammar::GRAM_ENGLISH, mAddressDetails.eConv));
- FormulaTemplate aTemplate(mDocument, mAddressDetails);
+ FormulaTemplate aTemplate(mDocument);
// Smoothing factor
double aSmoothingFactor = mpSmoothingFactor->GetValue() / 100.0;
diff --git a/sc/source/ui/StatisticsDialogs/FTestDialog.cxx b/sc/source/ui/StatisticsDialogs/FTestDialog.cxx
index 6f07778805d2..785d47550214 100644
--- a/sc/source/ui/StatisticsDialogs/FTestDialog.cxx
+++ b/sc/source/ui/StatisticsDialogs/FTestDialog.cxx
@@ -63,7 +63,7 @@ ScRange ScFTestDialog::ApplyOutput(ScDocShell* pDocShell)
{
AddressWalkerWriter aOutput(mOutputAddress, pDocShell, mDocument,
formula::FormulaGrammar::mergeToGrammar(formula::FormulaGrammar::GRAM_ENGLISH, mAddressDetails.eConv));
- FormulaTemplate aTemplate(mDocument, mAddressDetails);
+ FormulaTemplate aTemplate(mDocument);
boost::scoped_ptr<DataRangeIterator> pVariable1Iterator;
if (mGroupedBy == BY_COLUMN)
diff --git a/sc/source/ui/StatisticsDialogs/MatrixComparisonGenerator.cxx b/sc/source/ui/StatisticsDialogs/MatrixComparisonGenerator.cxx
index ca9de2431425..ac7039ae9251 100644
--- a/sc/source/ui/StatisticsDialogs/MatrixComparisonGenerator.cxx
+++ b/sc/source/ui/StatisticsDialogs/MatrixComparisonGenerator.cxx
@@ -70,7 +70,7 @@ ScRange ScMatrixComparisonGenerator::ApplyOutput(ScDocShell* pDocShell)
{
AddressWalkerWriter output(mOutputAddress, pDocShell, mDocument,
formula::FormulaGrammar::mergeToGrammar( formula::FormulaGrammar::GRAM_ENGLISH, mAddressDetails.eConv));
- FormulaTemplate aTemplate(mDocument, mAddressDetails);
+ FormulaTemplate aTemplate(mDocument);
SCTAB inTab = mInputRange.aStart.Tab();
diff --git a/sc/source/ui/StatisticsDialogs/MovingAverageDialog.cxx b/sc/source/ui/StatisticsDialogs/MovingAverageDialog.cxx
index aafe29060525..2786e53b6626 100644
--- a/sc/source/ui/StatisticsDialogs/MovingAverageDialog.cxx
+++ b/sc/source/ui/StatisticsDialogs/MovingAverageDialog.cxx
@@ -53,7 +53,7 @@ ScRange ScMovingAverageDialog::ApplyOutput(ScDocShell* pDocShell)
{
AddressWalkerWriter output(mOutputAddress, pDocShell, mDocument,
formula::FormulaGrammar::mergeToGrammar( formula::FormulaGrammar::GRAM_ENGLISH, mAddressDetails.eConv));
- FormulaTemplate aTemplate(mDocument, mAddressDetails);
+ FormulaTemplate aTemplate(mDocument);
boost::scoped_ptr<DataRangeIterator> pIterator;
if (mGroupedBy == BY_COLUMN)
diff --git a/sc/source/ui/StatisticsDialogs/TTestDialog.cxx b/sc/source/ui/StatisticsDialogs/TTestDialog.cxx
index 9e335c9b8b14..144be46f57b5 100644
--- a/sc/source/ui/StatisticsDialogs/TTestDialog.cxx
+++ b/sc/source/ui/StatisticsDialogs/TTestDialog.cxx
@@ -63,7 +63,7 @@ ScRange ScTTestDialog::ApplyOutput(ScDocShell* pDocShell)
{
AddressWalkerWriter aOutput(mOutputAddress, pDocShell, mDocument,
formula::FormulaGrammar::mergeToGrammar( formula::FormulaGrammar::GRAM_ENGLISH, mAddressDetails.eConv));
- FormulaTemplate aTemplate(mDocument, mAddressDetails);
+ FormulaTemplate aTemplate(mDocument);
boost::scoped_ptr<DataRangeIterator> pVariable1Iterator;
if (mGroupedBy == BY_COLUMN)
diff --git a/sc/source/ui/StatisticsDialogs/TableFillingAndNavigationTools.cxx b/sc/source/ui/StatisticsDialogs/TableFillingAndNavigationTools.cxx
index 51b9541dabc7..d448e8fd43b4 100644
--- a/sc/source/ui/StatisticsDialogs/TableFillingAndNavigationTools.cxx
+++ b/sc/source/ui/StatisticsDialogs/TableFillingAndNavigationTools.cxx
@@ -18,10 +18,7 @@
#include "TableFillingAndNavigationTools.hxx"
-FormulaTemplate::FormulaTemplate(ScDocument* aDocument, ScAddress::Details aAddressDetails) :
- mDocument(aDocument),
- mAddressDetails(aAddressDetails)
-{}
+FormulaTemplate::FormulaTemplate(ScDocument* pDoc) : mpDoc(pDoc) {}
void FormulaTemplate::setTemplate(const OUString& aTemplate)
{
@@ -33,7 +30,7 @@ void FormulaTemplate::setTemplate(const char* aTemplate)
mTemplate = OUString::createFromAscii(aTemplate);
}
-OUString& FormulaTemplate::getTemplate()
+const OUString& FormulaTemplate::getTemplate()
{
RangeReplacementMap::iterator itRange;
for (itRange = mRangeReplacementMap.begin(); itRange != mRangeReplacementMap.end(); ++itRange)
@@ -58,22 +55,25 @@ void FormulaTemplate::autoReplaceAddress(const OUString& aVariable, ScAddress aA
mAddressReplacementMap.insert ( std::pair<OUString, ScAddress>(aVariable, aAddress) );
}
-void FormulaTemplate::applyRange(const OUString& aVariable, ScRange aRange)
+void FormulaTemplate::applyRange(const OUString& aVariable, const ScRange& aRange, bool b3D)
{
- OUString aString = aRange.Format(SCR_ABS, mDocument, mAddressDetails);
+ sal_uInt16 nFlag = b3D ? SCR_ABS_3D : SCR_ABS;
+ OUString aString = aRange.Format(nFlag, mpDoc, mpDoc->GetAddressConvention());
mTemplate = mTemplate.replaceAll(aVariable, aString);
}
-void FormulaTemplate::applyRangeList(const OUString& aVariable, const ScRangeList& aRangeList)
+void FormulaTemplate::applyRangeList(const OUString& aVariable, const ScRangeList& aRangeList, bool b3D)
{
+ sal_uInt16 nFlag = b3D ? SCR_ABS_3D : SCR_ABS;
OUString aString;
- aRangeList.Format(aString, SCR_ABS, mDocument);
+ aRangeList.Format(aString, nFlag, mpDoc, mpDoc->GetAddressConvention());
mTemplate = mTemplate.replaceAll(aVariable, aString);
}
-void FormulaTemplate::applyAddress(const OUString& aVariable, ScAddress aAddress)
+void FormulaTemplate::applyAddress(const OUString& aVariable, const ScAddress& aAddress, bool b3D)
{
- OUString aString = aAddress.Format(SCR_ABS, mDocument, mAddressDetails);
+ sal_uInt16 nFlag = b3D ? SCA_ABS_3D : SCA_ABS;
+ OUString aString = aAddress.Format(nFlag, mpDoc, mpDoc->GetAddressConvention());
mTemplate = mTemplate.replaceAll(aVariable, aString);
}
diff --git a/sc/source/ui/inc/TableFillingAndNavigationTools.hxx b/sc/source/ui/inc/TableFillingAndNavigationTools.hxx
index 853fa5ad3a50..d45e3a9446dd 100644
--- a/sc/source/ui/inc/TableFillingAndNavigationTools.hxx
+++ b/sc/source/ui/inc/TableFillingAndNavigationTools.hxx
@@ -25,8 +25,7 @@ class FormulaTemplate
{
private:
OUString mTemplate;
- ScDocument* mDocument;
- ScAddress::Details mAddressDetails;
+ ScDocument* mpDoc;
typedef std::map<OUString, ScRange> RangeReplacementMap;
typedef std::map<OUString, ScAddress> AddressReplacementMap;
@@ -35,18 +34,18 @@ private:
RangeReplacementMap mRangeReplacementMap;
public:
- FormulaTemplate(ScDocument* aDocument, ScAddress::Details aAddressDetails);
+ FormulaTemplate(ScDocument* pDoc);
void setTemplate(const OUString& aTemplate);
void setTemplate(const char* aTemplate);
- OUString& getTemplate();
+ const OUString& getTemplate();
void autoReplaceRange(const OUString& aVariable, ScRange aRange);
void autoReplaceAddress(const OUString& aVariable, ScAddress aAddress);
- void applyRange(const OUString& aVariable, ScRange aRange);
- void applyRangeList(const OUString& aVariable, const ScRangeList& aRangeList);
- void applyAddress(const OUString& aVariable, ScAddress aAddress);
+ void applyRange(const OUString& aVariable, const ScRange& aRange, bool b3D = true);
+ void applyRangeList(const OUString& aVariable, const ScRangeList& aRangeList, bool b3D = true);
+ void applyAddress(const OUString& aVariable, const ScAddress& aAddress, bool b3D = true);
void applyString(const OUString& aVariable, const OUString& aValue);
void applyNumber(const OUString& aVariable, sal_Int32 aValue);
};