summaryrefslogtreecommitdiff
path: root/sc/source/ui
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2013-12-05 15:37:10 -0500
committerEike Rathke <erack@redhat.com>2013-12-05 16:33:12 -0600
commit2ea5c1b6dd1d8fda41c1c1fdc3cf994c4f9e5895 (patch)
tree5749d89727d68b3c3d3aae6a83cbc98fcbc59c41 /sc/source/ui
parent1405c123157406e601adbea2c5f13e62c70f0ede (diff)
fdo#69984: Handle duplicate field names correctly.
Duplicate field names are represented in two ways: 1) 'Name' vs 'Name*' in the UNO part of the pivot engine, and 2) Name,0 vs Name,1 which are a pair of textural name and a numeric duplicate index in the non-UNO part of the engine. But some parts lost this duplicate index information and/or confused the 2 ways of representation. Hopefully this change will sort things out. (cherry picked from commit 7e491281d2ba71490fa22cce1e43ba91f60395e3) Conflicts: sc/inc/pivot.hxx Change-Id: I03ae7b6c011c31ace454679837542d6d0909ecaa Reviewed-on: https://gerrit.libreoffice.org/6944 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc/source/ui')
-rw-r--r--sc/source/ui/dbgui/pvfundlg.cxx34
-rw-r--r--sc/source/ui/dbgui/pvlaydlg.cxx7
-rw-r--r--sc/source/ui/inc/pvfundlg.hxx4
3 files changed, 30 insertions, 15 deletions
diff --git a/sc/source/ui/dbgui/pvfundlg.cxx b/sc/source/ui/dbgui/pvfundlg.cxx
index f9e468bbf668..af369f47a287 100644
--- a/sc/source/ui/dbgui/pvfundlg.cxx
+++ b/sc/source/ui/dbgui/pvfundlg.cxx
@@ -35,6 +35,7 @@
#include "dpsave.hxx"
#include "pvfundlg.hrc"
#include "globstr.hrc"
+#include "dputil.hxx"
#include <vector>
@@ -574,8 +575,13 @@ void ScDPSubtotalOptDlg::FillLabelData( ScDPLabelData& rLabelData ) const
else
rLabelData.maSortInfo.Mode = DataPilotFieldSortMode::DATA;
- rLabelData.maSortInfo.Field = GetFieldName(maLbSortBy.GetSelectEntry());
- rLabelData.maSortInfo.IsAscending = maRbSortAsc.IsChecked();
+ ScDPName aFieldName = GetFieldName(maLbSortBy.GetSelectEntry());
+ if (!aFieldName.maName.isEmpty())
+ {
+ rLabelData.maSortInfo.Field =
+ ScDPUtil::createDuplicateDimensionName(aFieldName.maName, aFieldName.mnDupCount);
+ rLabelData.maSortInfo.IsAscending = maRbSortAsc.IsChecked();
+ }
// *** LAYOUT MODE ***
@@ -584,10 +590,15 @@ void ScDPSubtotalOptDlg::FillLabelData( ScDPLabelData& rLabelData ) const
// *** AUTO SHOW ***
- rLabelData.maShowInfo.IsEnabled = maCbShow.IsChecked();
- rLabelData.maShowInfo.ShowItemsMode = maLbShowFromWrp.GetControlValue();
- rLabelData.maShowInfo.ItemCount = sal::static_int_cast<sal_Int32>( maNfShow.GetValue() );
- rLabelData.maShowInfo.DataField = GetFieldName(maLbShowUsing.GetSelectEntry());
+ aFieldName = GetFieldName(maLbShowUsing.GetSelectEntry());
+ if (!aFieldName.maName.isEmpty())
+ {
+ rLabelData.maShowInfo.IsEnabled = maCbShow.IsChecked();
+ rLabelData.maShowInfo.ShowItemsMode = maLbShowFromWrp.GetControlValue();
+ rLabelData.maShowInfo.ItemCount = sal::static_int_cast<sal_Int32>( maNfShow.GetValue() );
+ rLabelData.maShowInfo.DataField =
+ ScDPUtil::createDuplicateDimensionName(aFieldName.maName, aFieldName.mnDupCount);
+ }
// *** HIDDEN ITEMS ***
@@ -613,7 +624,7 @@ void ScDPSubtotalOptDlg::Init( const ScDPNameVec& rDataFields, bool bEnableLayou
for( ScDPNameVec::const_iterator aIt = rDataFields.begin(), aEnd = rDataFields.end(); aIt != aEnd; ++aIt )
{
// Cache names for later lookup.
- maDataFieldNameMap.insert(NameMapType::value_type(aIt->maLayoutName, aIt->maName));
+ maDataFieldNameMap.insert(NameMapType::value_type(aIt->maLayoutName, *aIt));
maLbSortBy.InsertEntry( aIt->maLayoutName );
maLbShowUsing.InsertEntry( aIt->maLayoutName ); // for AutoShow
@@ -714,10 +725,10 @@ void ScDPSubtotalOptDlg::InitHideListBox()
maLbHide.Enable( bEnable );
}
-const OUString& ScDPSubtotalOptDlg::GetFieldName(const OUString& rLayoutName) const
+ScDPName ScDPSubtotalOptDlg::GetFieldName(const OUString& rLayoutName) const
{
NameMapType::const_iterator itr = maDataFieldNameMap.find(rLayoutName);
- return itr == maDataFieldNameMap.end() ? rLayoutName : itr->second;
+ return itr == maDataFieldNameMap.end() ? ScDPName() : itr->second;
}
sal_uInt16 ScDPSubtotalOptDlg::FindListBoxEntry(
@@ -728,8 +739,9 @@ sal_uInt16 ScDPSubtotalOptDlg::FindListBoxEntry(
while (nPos < rLBox.GetEntryCount())
{
// translate the displayed field name back to its original field name.
- const OUString& rName = GetFieldName(rLBox.GetEntry(nPos));
- if (rName.equals(rEntry))
+ ScDPName aName = GetFieldName(rLBox.GetEntry(nPos));
+ OUString aUnoName = ScDPUtil::createDuplicateDimensionName(aName.maName, aName.mnDupCount);
+ if (aUnoName.equals(rEntry))
{
bFound = true;
break;
diff --git a/sc/source/ui/dbgui/pvlaydlg.cxx b/sc/source/ui/dbgui/pvlaydlg.cxx
index 79178c9f3e85..b68284544f1e 100644
--- a/sc/source/ui/dbgui/pvlaydlg.cxx
+++ b/sc/source/ui/dbgui/pvlaydlg.cxx
@@ -60,6 +60,7 @@
#include "dpsave.hxx"
#include "dpshttab.hxx"
#include "scmod.hxx"
+#include "dputil.hxx"
#include "sc.hrc"
#include "scabstdlg.hxx"
@@ -783,7 +784,7 @@ void ScPivotLayoutDlg::NotifyDoubleClick( ScPivotFieldType eType, size_t nFieldI
OUString aFuncStr = GetFuncString(nMask);
aLayoutName = aFuncStr + pDFData->maName;
}
- aDataFieldNames.push_back(ScDPName(pDFData->maName, aLayoutName));
+ aDataFieldNames.push_back(ScDPName(pDFData->maName, aLayoutName, pDFData->mnDupCount));
}
bool bLayout = (eType == PIVOTFIELDTYPE_ROW) &&
@@ -1588,7 +1589,9 @@ IMPL_LINK_NOARG(ScPivotLayoutDlg, OkHdl)
for( ScDPLabelDataVector::const_iterator aIt = maLabelData.begin(), aEnd = maLabelData.end(); aIt != aEnd; ++aIt )
{
- ScDPSaveDimension* pDim = aSaveData.GetExistingDimensionByName(aIt->maName);
+ // "UNO" name may have trailing '*'s which signifies duplicate index.
+ OUString aUnoName = ScDPUtil::createDuplicateDimensionName(aIt->maName, aIt->mnDupCount);
+ ScDPSaveDimension* pDim = aSaveData.GetExistingDimensionByName(aUnoName);
if (!pDim)
continue;
diff --git a/sc/source/ui/inc/pvfundlg.hxx b/sc/source/ui/inc/pvfundlg.hxx
index c02cb5c6a142..6ad269d473db 100644
--- a/sc/source/ui/inc/pvfundlg.hxx
+++ b/sc/source/ui/inc/pvfundlg.hxx
@@ -162,7 +162,7 @@ private:
void Init( const ScDPNameVec& rDataFields, bool bEnableLayout );
void InitHideListBox();
- const OUString& GetFieldName(const OUString& rLayoutName) const;
+ ScDPName GetFieldName(const OUString& rLayoutName) const;
/** Searches for a listbox entry, starts search at specified position. */
sal_uInt16 FindListBoxEntry( const ListBox& rLBox, const String& rEntry, sal_uInt16 nStartPos ) const;
@@ -203,7 +203,7 @@ private:
ScDPObject& mrDPObj; /// The DataPilot object (for member names).
ScDPLabelData maLabelData; /// Cache for members data.
- typedef ::boost::unordered_map< OUString, OUString, OUStringHash > NameMapType;
+ typedef ::boost::unordered_map<OUString, ScDPName, OUStringHash> NameMapType;
NameMapType maDataFieldNameMap; /// Cache for displayed name to field name mapping.
};