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
This commit is contained in:
parent
f85d10fdf6
commit
0ab538885d
9 changed files with 28 additions and 26 deletions
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue