[ooo-build-commit] .: patches/dev300
Kohei Yoshida
kohei at kemper.freedesktop.org
Fri Aug 27 10:23:08 PDT 2010
patches/dev300/calc-dp-sort-fix.diff | 200 +++++++++++++++++++++++++++++++++--
1 file changed, 192 insertions(+), 8 deletions(-)
New commits:
commit cee4ef6d45c2f3d17c000146526976a89f837b40
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Fri Aug 27 12:21:39 2010 -0400
Various fix in data pilot dialogs.
* Make the previous "sort by" selection in the data field options
dialog persistent. (n#634974)
* Translate display field and field member names into their original
counterparts for referenced field and item names. The data pilot
previously failed to compute results when referenced fields are
used and the names were custome names. (n#634974)
* patches/dev300/calc-dp-sort-fix.diff:
diff --git a/patches/dev300/calc-dp-sort-fix.diff b/patches/dev300/calc-dp-sort-fix.diff
index 49c1a70..ab50c13 100644
--- a/patches/dev300/calc-dp-sort-fix.diff
+++ b/patches/dev300/calc-dp-sort-fix.diff
@@ -45,10 +45,133 @@ index eea170b..e2bfbe8 100644
mbVisible(true),
mbShowDetails(true)
diff --git sc/source/ui/dbgui/pvfundlg.cxx sc/source/ui/dbgui/pvfundlg.cxx
-index bcaa5de..f697842 100644
+index bcaa5de..a5f32de 100644
--- sc/source/ui/dbgui/pvfundlg.cxx
+++ sc/source/ui/dbgui/pvfundlg.cxx
-@@ -545,7 +545,7 @@ void ScDPSubtotalOptDlg::FillLabelData( ScDPLabelData& rLabelData ) const
+@@ -105,15 +105,6 @@ bool lclFillListBox( ListBoxType& rLBox, const vector<ScDPLabelData::Member>& rM
+ return bEmpty;
+ }
+
+-/** Searches for a listbox entry, starts search at specified position. */
+-USHORT lclFindListBoxEntry( const ListBox& rLBox, const String& rEntry, USHORT nStartPos )
+-{
+- USHORT nPos = nStartPos;
+- while( (nPos < rLBox.GetEntryCount()) && (rLBox.GetEntry( nPos ) != rEntry) )
+- ++nPos;
+- return (nPos < rLBox.GetEntryCount()) ? nPos : LISTBOX_ENTRY_NOTFOUND;
+-}
+-
+ /** This table represents the order of the strings in the resource string array. */
+ static const USHORT spnFunctions[] =
+ {
+@@ -243,7 +234,7 @@ DataPilotFieldReference ScDPFunctionDlg::GetFieldRef() const
+ DataPilotFieldReference aRef;
+
+ aRef.ReferenceType = maLbTypeWrp.GetControlValue();
+- aRef.ReferenceField = maLbBaseField.GetSelectEntry();
++ aRef.ReferenceField = GetBaseFieldName(maLbBaseField.GetSelectEntry());
+
+ USHORT nBaseItemPos = maLbBaseItem.GetSelectEntryPos();
+ switch( nBaseItemPos )
+@@ -258,7 +249,7 @@ DataPilotFieldReference ScDPFunctionDlg::GetFieldRef() const
+ {
+ aRef.ReferenceItemType = DataPilotFieldReferenceItemType::NAMED;
+ if( !mbEmptyItem || (nBaseItemPos > SC_BASEITEM_USER_POS) )
+- aRef.ReferenceItemName = maLbBaseItem.GetSelectEntry();
++ aRef.ReferenceItemName = GetBaseItemName(maLbBaseItem.GetSelectEntry());
+ }
+ }
+
+@@ -289,8 +280,15 @@ void ScDPFunctionDlg::Init( const ScDPLabelData& rLabelData, const ScDPFuncData&
+ maLbBaseField.SetSelectHdl( LINK( this, ScDPFunctionDlg, SelectHdl ) );
+
+ // base field list box
++ OUString aSelectedEntry;
+ for( ScDPLabelDataVec::const_iterator aIt = mrLabelVec.begin(), aEnd = mrLabelVec.end(); aIt != aEnd; ++aIt )
++ {
+ maLbBaseField.InsertEntry(aIt->getDisplayName());
++ maBaseFieldNameMap.insert(
++ NameMapType::value_type(aIt->getDisplayName(), aIt->maName));
++ if (aIt->maName == rFuncData.maFieldRef.ReferenceField)
++ aSelectedEntry = aIt->getDisplayName();
++ }
+
+ // base item list box
+ maLbBaseItem.SetSeparatorPos( SC_BASEITEM_USER_POS - 1 );
+@@ -300,7 +298,7 @@ void ScDPFunctionDlg::Init( const ScDPLabelData& rLabelData, const ScDPFuncData&
+ SelectHdl( &maLbType ); // enables base field/item list boxes
+
+ // select base field
+- maLbBaseField.SelectEntry( rFuncData.maFieldRef.ReferenceField );
++ maLbBaseField.SelectEntry(aSelectedEntry);
+ if( maLbBaseField.GetSelectEntryPos() >= maLbBaseField.GetEntryCount() )
+ maLbBaseField.SelectEntryPos( 0 );
+ SelectHdl( &maLbBaseField ); // fills base item list, selects base item
+@@ -324,7 +322,7 @@ void ScDPFunctionDlg::Init( const ScDPLabelData& rLabelData, const ScDPFuncData&
+ else
+ {
+ USHORT nStartPos = mbEmptyItem ? (SC_BASEITEM_USER_POS + 1) : SC_BASEITEM_USER_POS;
+- USHORT nPos = lclFindListBoxEntry( maLbBaseItem, rFuncData.maFieldRef.ReferenceItemName, nStartPos );
++ USHORT nPos = FindBaseItemPos( rFuncData.maFieldRef.ReferenceItemName, nStartPos );
+ if( nPos >= maLbBaseItem.GetEntryCount() )
+ nPos = (maLbBaseItem.GetEntryCount() > SC_BASEITEM_USER_POS) ? SC_BASEITEM_USER_POS : SC_BASEITEM_PREV_POS;
+ maLbBaseItem.SelectEntryPos( nPos );
+@@ -333,6 +331,36 @@ void ScDPFunctionDlg::Init( const ScDPLabelData& rLabelData, const ScDPFuncData&
+ }
+ }
+
++const OUString& ScDPFunctionDlg::GetBaseFieldName(const OUString& rLayoutName) const
++{
++ NameMapType::const_iterator itr = maBaseFieldNameMap.find(rLayoutName);
++ return itr == maBaseFieldNameMap.end() ? rLayoutName : itr->second;
++}
++
++const OUString& ScDPFunctionDlg::GetBaseItemName(const OUString& rLayoutName) const
++{
++ NameMapType::const_iterator itr = maBaseItemNameMap.find(rLayoutName);
++ return itr == maBaseItemNameMap.end() ? rLayoutName : itr->second;
++}
++
++sal_uInt16 ScDPFunctionDlg::FindBaseItemPos( const String& rEntry, USHORT nStartPos ) const
++{
++ sal_uInt16 nPos = nStartPos;
++ bool bFound = false;
++ while (nPos < maLbBaseItem.GetEntryCount())
++ {
++ // translate the displayed field name back to its original field name.
++ const OUString& rName = GetBaseItemName(maLbBaseItem.GetEntry(nPos));
++ if (rName.equals(rEntry))
++ {
++ bFound = true;
++ break;
++ }
++ ++nPos;
++ }
++ return bFound ? nPos : LISTBOX_ENTRY_NOTFOUND;
++}
++
+ IMPL_LINK( ScDPFunctionDlg, SelectHdl, ListBox*, pLBox )
+ {
+ if( pLBox == &maLbType )
+@@ -373,7 +401,16 @@ IMPL_LINK( ScDPFunctionDlg, SelectHdl, ListBox*, pLBox )
+ mbEmptyItem = false;
+ size_t nBasePos = maLbBaseField.GetSelectEntryPos();
+ if( nBasePos < mrLabelVec.size() )
+- mbEmptyItem = lclFillListBox( maLbBaseItem, mrLabelVec[ nBasePos ].maMembers, SC_BASEITEM_USER_POS );
++ {
++ const vector<ScDPLabelData::Member>& rMembers = mrLabelVec[nBasePos].maMembers;
++ mbEmptyItem = lclFillListBox( maLbBaseItem, rMembers, SC_BASEITEM_USER_POS );
++ // build cache for base names.
++ NameMapType aMap;
++ vector<ScDPLabelData::Member>::const_iterator itr = rMembers.begin(), itrEnd = rMembers.end();
++ for (; itr != itrEnd; ++itr)
++ aMap.insert(NameMapType::value_type(itr->getDisplayName(), itr->maName));
++ maBaseItemNameMap.swap(aMap);
++ }
+
+ // select base item
+ USHORT nItemPos = (maLbBaseItem.GetEntryCount() > SC_BASEITEM_USER_POS) ? SC_BASEITEM_USER_POS : SC_BASEITEM_PREV_POS;
+@@ -545,7 +582,7 @@ void ScDPSubtotalOptDlg::FillLabelData( ScDPLabelData& rLabelData ) const
else
rLabelData.maSortInfo.Mode = DataPilotFieldSortMode::DATA;
@@ -57,7 +180,7 @@ index bcaa5de..f697842 100644
rLabelData.maSortInfo.IsAscending = maRbSortAsc.IsChecked();
// *** LAYOUT MODE ***
-@@ -558,7 +558,7 @@ void ScDPSubtotalOptDlg::FillLabelData( ScDPLabelData& rLabelData ) const
+@@ -558,7 +595,7 @@ void ScDPSubtotalOptDlg::FillLabelData( ScDPLabelData& rLabelData ) const
rLabelData.maShowInfo.IsEnabled = maCbShow.IsChecked();
rLabelData.maShowInfo.ShowItemsMode = maLbShowFromWrp.GetControlValue();
rLabelData.maShowInfo.ItemCount = sal::static_int_cast<sal_Int32>( maNfShow.GetValue() );
@@ -66,7 +189,7 @@ index bcaa5de..f697842 100644
// *** HIDDEN ITEMS ***
-@@ -583,9 +583,13 @@ void ScDPSubtotalOptDlg::Init( const ScDPNameVec& rDataFields, bool bEnableLayou
+@@ -583,16 +620,20 @@ void ScDPSubtotalOptDlg::Init( const ScDPNameVec& rDataFields, bool bEnableLayou
for( ScDPNameVec::const_iterator aIt = rDataFields.begin(), aEnd = rDataFields.end(); aIt != aEnd; ++aIt )
{
@@ -82,7 +205,15 @@ index bcaa5de..f697842 100644
if( maLbSortBy.GetEntryCount() > SC_SORTDATA_POS )
maLbSortBy.SetSeparatorPos( SC_SORTDATA_POS - 1 );
-@@ -681,6 +685,12 @@ void ScDPSubtotalOptDlg::InitHideListBox()
+ USHORT nSortPos = SC_SORTNAME_POS;
+ if( nSortMode == DataPilotFieldSortMode::DATA )
+ {
+- nSortPos = lclFindListBoxEntry( maLbSortBy, maLabelData.maSortInfo.Field, SC_SORTDATA_POS );
++ nSortPos = FindListBoxEntry( maLbSortBy, maLabelData.maSortInfo.Field, SC_SORTDATA_POS );
+ if( nSortPos >= maLbSortBy.GetEntryCount() )
+ {
+ nSortPos = SC_SORTNAME_POS;
+@@ -681,6 +722,31 @@ void ScDPSubtotalOptDlg::InitHideListBox()
maLbHide.Enable( bEnable );
}
@@ -92,6 +223,25 @@ index bcaa5de..f697842 100644
+ return itr == maDataFieldNameMap.end() ? rLayoutName : itr->second;
+}
+
++sal_uInt16 ScDPSubtotalOptDlg::FindListBoxEntry(
++ const ListBox& rLBox, const String& rEntry, USHORT nStartPos ) const
++{
++ sal_uInt16 nPos = nStartPos;
++ bool bFound = false;
++ 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))
++ {
++ bFound = true;
++ break;
++ }
++ ++nPos;
++ }
++ return bFound ? nPos : LISTBOX_ENTRY_NOTFOUND;
++}
++
IMPL_LINK( ScDPSubtotalOptDlg, RadioClickHdl, RadioButton*, pBtn )
{
maLbSortBy.Enable( pBtn != &maRbSortMan );
@@ -220,19 +370,53 @@ index 1b2c41e..81eac1b 100644
}
delete pDlg;
diff --git sc/source/ui/inc/pvfundlg.hxx sc/source/ui/inc/pvfundlg.hxx
-index 4f219d8..9b9ef3e 100644
+index 4f219d8..ab61819 100644
--- sc/source/ui/inc/pvfundlg.hxx
+++ sc/source/ui/inc/pvfundlg.hxx
-@@ -170,6 +170,8 @@ private:
+@@ -78,6 +78,7 @@ private:
+
+ class ScDPFunctionDlg : public ModalDialog
+ {
++ typedef ::std::hash_map< ::rtl::OUString, ::rtl::OUString, ::rtl::OUStringHash > NameMapType;
+ public:
+ explicit ScDPFunctionDlg( Window* pParent, const ScDPLabelDataVec& rLabelVec,
+ const ScDPLabelData& rLabelData, const ScDPFuncData& rFuncData );
+@@ -88,6 +89,12 @@ public:
+ private:
+ void Init( const ScDPLabelData& rLabelData, const ScDPFuncData& rFuncData );
+
++ const ::rtl::OUString& GetBaseFieldName(const ::rtl::OUString& rLayoutName) const;
++ const ::rtl::OUString& GetBaseItemName(const ::rtl::OUString& rLayoutName) const;
++
++ /** Searches for a listbox entry, starts search at specified position. */
++ sal_uInt16 FindBaseItemPos( const String& rEntry, USHORT nStartPos ) const;
++
+ DECL_LINK( SelectHdl, ListBox* );
+ DECL_LINK( DblClickHdl, MultiListBox* );
+
+@@ -108,6 +115,9 @@ private:
+ HelpButton maBtnHelp;
+ MoreButton maBtnMore;
+
++ NameMapType maBaseFieldNameMap; // cache for base field display -> original name.
++ NameMapType maBaseItemNameMap; // cache for base item display -> original name.
++
+ ScDPListBoxWrapper maLbTypeWrp; /// Wrapper for direct usage of API constants.
+
+ const ScDPLabelDataVec& mrLabelVec; /// Data of all labels.
+@@ -170,6 +180,11 @@ private:
void Init( const ScDPNameVec& rDataFields, bool bEnableLayout );
void InitHideListBox();
+ const ::rtl::OUString& GetFieldName(const ::rtl::OUString& rLayoutName) const;
+
++ /** Searches for a listbox entry, starts search at specified position. */
++ sal_uInt16 FindListBoxEntry( const ListBox& rLBox, const String& rEntry, USHORT nStartPos ) const;
++
DECL_LINK( RadioClickHdl, RadioButton* );
DECL_LINK( CheckHdl, CheckBox* );
DECL_LINK( SelectHdl, ListBox* );
-@@ -205,6 +207,9 @@ private:
+@@ -205,6 +220,9 @@ private:
ScDPObject& mrDPObj; /// The DataPilot object (for member names).
ScDPLabelData maLabelData; /// Cache for members data.
More information about the ooo-build-commit
mailing list