diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-12-05 15:37:10 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-12-05 15:43:45 -0500 |
commit | 7e491281d2ba71490fa22cce1e43ba91f60395e3 (patch) | |
tree | 57332cdfc4d5511a6b4dee24761122a568972221 /sc/source/ui/dbgui/pvfundlg.cxx | |
parent | 40fba2316ac3ebb11b69c157cfac7da92a63821b (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.
Change-Id: I03ae7b6c011c31ace454679837542d6d0909ecaa
Diffstat (limited to 'sc/source/ui/dbgui/pvfundlg.cxx')
-rw-r--r-- | sc/source/ui/dbgui/pvfundlg.cxx | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/sc/source/ui/dbgui/pvfundlg.cxx b/sc/source/ui/dbgui/pvfundlg.cxx index b1705dae3141..40e431eb7f7b 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; |