summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorOliver Bolte <obo@openoffice.org>2004-06-04 13:10:50 +0000
committerOliver Bolte <obo@openoffice.org>2004-06-04 13:10:50 +0000
commitbc7dcc73184a24a2ce8989da6b9819f59e77675a (patch)
treea716e65a865b91457c915dd3cd89b27272399ec0 /sc
parentc4af64b24e503af1926341851277c6d7fc39cbb1 (diff)
INTEGRATION: CWS fieldoptions (1.4.332); FILE MERGED
2004/05/27 08:28:54 dr 1.4.332.10: #100000# dialogdiet changes 2004/05/19 10:24:04 dr 1.4.332.9: #i23447# do not set invalid hierarchy in FillLabelData() 2004/05/18 09:12:18 dr 1.4.332.8: #i23447# do not show single hierarchy in listbox 2004/05/07 11:49:19 dr 1.4.332.7: #i23447# DP subtotal options dialog: used hierarchy updates members list 2004/05/07 10:32:56 dr 1.4.332.6: #i23447# used hierarchy by index 2004/05/07 09:49:11 dr 1.4.332.5: #i23447# hidden members and used hierarchy 2004/05/06 11:13:51 dr 1.4.332.4: #i23447# auto show options in subtotal dialog 2004/05/05 16:02:08 dr 1.4.332.3: #i23447# layout options in subtotal dialog 2004/05/05 14:10:58 dr 1.4.332.2: #i23447# sort options in subtotal dialog 2004/05/04 16:31:14 dr 1.4.332.1: #i23447# DP data field options dialog
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/dbgui/pvfundlg.cxx774
1 files changed, 613 insertions, 161 deletions
diff --git a/sc/source/ui/dbgui/pvfundlg.cxx b/sc/source/ui/dbgui/pvfundlg.cxx
index 0dec7a1be17b..4414bd12afbb 100644
--- a/sc/source/ui/dbgui/pvfundlg.cxx
+++ b/sc/source/ui/dbgui/pvfundlg.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: pvfundlg.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: dr $ $Date: 2002-03-01 11:35:58 $
+ * last change: $Author: obo $ $Date: 2004-06-04 14:10:50 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -63,224 +63,676 @@
#include "ui_pch.hxx"
#endif
+#include "pvfundlg.hxx"
+
+#include <com/sun/star/sheet/DataPilotFieldReferenceType.hpp>
+#include <com/sun/star/sheet/DataPilotFieldReferenceItemType.hpp>
+#include <com/sun/star/sheet/DataPilotFieldLayoutMode.hpp>
+#include <com/sun/star/sheet/DataPilotFieldSortMode.hpp>
+#include <com/sun/star/sheet/DataPilotFieldShowItemsMode.hpp>
-#ifndef PCH
+#include <tools/resary.hxx>
#include <vcl/msgbox.hxx>
-#endif
#include "scresid.hxx"
-#include "pivot.hxx"
+#include "dpobject.hxx"
+#include "dpsave.hxx"
#include "pvfundlg.hrc"
-#include "pvfundlg.hxx"
+#include "globstr.hrc"
-//========================================================================
-
-ScDPFunctionDlg::ScDPFunctionDlg( Window* pParent,
- BOOL bSubTotalFunc,
- const String& rName,
- USHORT nFunctions,
- BOOL bIsShowAll )
-
- : ModalDialog ( pParent, ScResId( RID_SCDLG_PIVOTSUBT ) ),
- aBtnOk ( this, ScResId( BTN_OK ) ),
- aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
- aBtnHelp ( this, ScResId( BTN_HELP ) ),
- aBtnNone ( this, ScResId( BTN_NONE ) ),
- aBtnAuto ( this, ScResId( BTN_AUTO ) ),
- aBtnUser ( this, ScResId( BTN_USER ) ),
- aFlFunc ( this, ScResId( FL_FUNC ) ),
- aCbShowAll ( this, ScResId( CB_SHOWALL ) ),
- aFtNameLabel( this, ScResId( FT_NAMELABEL ) ),
- aFtName ( this, ScResId( FT_NAME ) ),
- aLbFunc ( this, ScResId( LB_FUNC ) ),
- nFuncMask ( nFunctions )
-{
- aFtName.SetText( rName );
- SetUI( bSubTotalFunc );
- InitFuncLb( nFunctions );
- if ( bSubTotalFunc ) // hidden in SetUI otherwise
- aCbShowAll.Check( bIsShowAll );
- FreeResource();
-}
+// ============================================================================
-//------------------------------------------------------------------------
+using namespace ::com::sun::star::sheet;
-__EXPORT ScDPFunctionDlg::~ScDPFunctionDlg()
-{
- USHORT nEntryCount = aLbFunc.GetEntryCount();
+using ::rtl::OUString;
+using ::com::sun::star::uno::Sequence;
+
+// ============================================================================
+
+namespace {
- for ( USHORT i=0; i<nEntryCount; i++ )
+/** Appends all strings from the Sequence to the list box.
+
+ Empty strings are replaced by a localized "(empty)" entry and inserted at
+ the specified position.
+
+ @return true = The passed string list contains an empty string entry.
+ */
+template< typename ListBoxType >
+bool lclFillListBox( ListBoxType& rLBox, const Sequence< OUString >& rStrings, USHORT nEmptyPos = LISTBOX_APPEND )
+{
+ bool bEmpty = false;
+ if( const OUString* pStr = rStrings.getConstArray() )
{
- delete (USHORT*)aLbFunc.GetEntryData( i );
- aLbFunc.SetEntryData( i, NULL );
+ for( const OUString* pEnd = pStr + rStrings.getLength(); pStr != pEnd; ++pStr )
+ {
+ if( pStr->getLength() )
+ rLBox.InsertEntry( *pStr );
+ else
+ {
+ rLBox.InsertEntry( ScGlobal::GetRscString( STR_EMPTYDATA ), nEmptyPos );
+ bEmpty = true;
+ }
+ }
}
+ return bEmpty;
}
-//------------------------------------------------------------------------
-
-BOOL ScDPFunctionDlg::GetShowAll() const
+/** Searches for a listbox entry, starts search at specified position. */
+USHORT lclFindListBoxEntry( const ListBox& rLBox, const String& rEntry, USHORT nStartPos )
{
- return aCbShowAll.IsChecked();
+ 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[] =
+{
+ PIVOT_FUNC_SUM,
+ PIVOT_FUNC_COUNT,
+ PIVOT_FUNC_AVERAGE,
+ PIVOT_FUNC_MAX,
+ PIVOT_FUNC_MIN,
+ PIVOT_FUNC_PRODUCT,
+ PIVOT_FUNC_COUNT_NUM,
+ PIVOT_FUNC_STD_DEV,
+ PIVOT_FUNC_STD_DEVP,
+ PIVOT_FUNC_STD_VAR,
+ PIVOT_FUNC_STD_VARP
+};
+
+const USHORT SC_BASEITEM_PREV_POS = 0;
+const USHORT SC_BASEITEM_NEXT_POS = 1;
+const USHORT SC_BASEITEM_USER_POS = 2;
+
+const USHORT SC_SORTNAME_POS = 0;
+const USHORT SC_SORTDATA_POS = 1;
+
+const long SC_SHOW_DEFAULT = 10;
+
+static const ScDPListBoxWrapper::MapEntryType spRefTypeMap[] =
+{
+ { 0, DataPilotFieldReferenceType::NONE },
+ { 1, DataPilotFieldReferenceType::ITEM_DIFFERENCE },
+ { 2, DataPilotFieldReferenceType::ITEM_PERCENTAGE },
+ { 3, DataPilotFieldReferenceType::ITEM_PERCENTAGE_DIFFERENCE },
+ { 4, DataPilotFieldReferenceType::RUNNING_TOTAL },
+ { 5, DataPilotFieldReferenceType::ROW_PERCENTAGE },
+ { 6, DataPilotFieldReferenceType::COLUMN_PERCENTAGE },
+ { 7, DataPilotFieldReferenceType::TOTAL_PERCENTAGE },
+ { 8, DataPilotFieldReferenceType::INDEX },
+ { LISTBOX_ENTRY_NOTFOUND, DataPilotFieldReferenceType::NONE }
+};
+
+static const ScDPListBoxWrapper::MapEntryType spLayoutMap[] =
+{
+ { 0, DataPilotFieldLayoutMode::TABULAR_LAYOUT },
+ { 1, DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_TOP },
+ { 2, DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_BOTTOM },
+ { LISTBOX_ENTRY_NOTFOUND, DataPilotFieldLayoutMode::TABULAR_LAYOUT }
+};
+
+static const ScDPListBoxWrapper::MapEntryType spShowFromMap[] =
+{
+ { 0, DataPilotFieldShowItemsMode::FROM_TOP },
+ { 1, DataPilotFieldShowItemsMode::FROM_BOTTOM },
+ { LISTBOX_ENTRY_NOTFOUND, DataPilotFieldShowItemsMode::FROM_TOP }
+};
-#define FUNC_SET(f) ( (nFunctions & (f)) == (f) )
+} // namespace
+// ============================================================================
-void ScDPFunctionDlg::InitFuncLb( USHORT nFunctions )
+ScDPFunctionListBox::ScDPFunctionListBox( Window* pParent, const ResId& rResId ) :
+ MultiListBox( pParent, rResId )
{
- aLbFunc.SetEntryData( 0, new USHORT(PIVOT_FUNC_SUM) );
- aLbFunc.SetEntryData( 1, new USHORT(PIVOT_FUNC_COUNT) );
- aLbFunc.SetEntryData( 2, new USHORT(PIVOT_FUNC_AVERAGE) );
- aLbFunc.SetEntryData( 3, new USHORT(PIVOT_FUNC_MAX) );
- aLbFunc.SetEntryData( 4, new USHORT(PIVOT_FUNC_MIN) );
- aLbFunc.SetEntryData( 5, new USHORT(PIVOT_FUNC_PRODUCT) );
- aLbFunc.SetEntryData( 6, new USHORT(PIVOT_FUNC_COUNT_NUM) );
- aLbFunc.SetEntryData( 7, new USHORT(PIVOT_FUNC_STD_DEV) );
- aLbFunc.SetEntryData( 8, new USHORT(PIVOT_FUNC_STD_DEVP) );
- aLbFunc.SetEntryData( 9, new USHORT(PIVOT_FUNC_STD_VAR) );
- aLbFunc.SetEntryData( 10, new USHORT(PIVOT_FUNC_STD_VARP) );
-
- if ( nFunctions == PIVOT_FUNC_NONE
- || nFunctions == PIVOT_FUNC_AUTO )
- {
- aLbFunc.SetNoSelection();
- }
+ FillFunctionNames();
+}
+
+ScDPFunctionListBox::ScDPFunctionListBox( Window* pParent, WinBits nStyle ) :
+ MultiListBox( pParent, nStyle )
+{
+ FillFunctionNames();
+}
+
+void ScDPFunctionListBox::SetSelection( USHORT nFuncMask )
+{
+ if( (nFuncMask == PIVOT_FUNC_NONE) || (nFuncMask == PIVOT_FUNC_AUTO) )
+ SetNoSelection();
else
- {
- aLbFunc.SelectEntryPos( 0, FUNC_SET( PIVOT_FUNC_SUM ) );
- aLbFunc.SelectEntryPos( 1, FUNC_SET( PIVOT_FUNC_COUNT ) );
- aLbFunc.SelectEntryPos( 2, FUNC_SET( PIVOT_FUNC_AVERAGE ) );
- aLbFunc.SelectEntryPos( 3, FUNC_SET( PIVOT_FUNC_MAX ) );
- aLbFunc.SelectEntryPos( 4, FUNC_SET( PIVOT_FUNC_MIN ) );
- aLbFunc.SelectEntryPos( 5, FUNC_SET( PIVOT_FUNC_PRODUCT ) );
- aLbFunc.SelectEntryPos( 6, FUNC_SET( PIVOT_FUNC_COUNT_NUM ) );
- aLbFunc.SelectEntryPos( 7, FUNC_SET( PIVOT_FUNC_STD_DEV ) );
- aLbFunc.SelectEntryPos( 8, FUNC_SET( PIVOT_FUNC_STD_DEVP ) );
- aLbFunc.SelectEntryPos( 9, FUNC_SET( PIVOT_FUNC_STD_VAR ) );
- aLbFunc.SelectEntryPos( 10, FUNC_SET( PIVOT_FUNC_STD_VARP ) );
- }
- aLbFunc.SetDoubleClickHdl( LINK( this, ScDPFunctionDlg, DblClickHdl ) );
+ for( USHORT nEntry = 0, nCount = GetEntryCount(); nEntry < nCount; ++nEntry )
+ SelectEntryPos( nEntry, (nFuncMask & spnFunctions[ nEntry ]) != 0 );
}
-#undef FUNC_SET
+USHORT ScDPFunctionListBox::GetSelection() const
+{
+ USHORT nFuncMask = PIVOT_FUNC_NONE;
+ for( USHORT nSel = 0, nCount = GetSelectEntryCount(); nSel < nCount; ++nSel )
+ nFuncMask |= spnFunctions[ GetSelectEntryPos( nSel ) ];
+ return nFuncMask;
+}
-//------------------------------------------------------------------------
+void ScDPFunctionListBox::FillFunctionNames()
+{
+ DBG_ASSERT( !GetEntryCount(), "ScDPFunctionListBox::FillFunctionNames - do not add texts to resource" );
+ Clear();
+ ResStringArray aArr( ScResId( SCSTR_DPFUNCLISTBOX ) );
+ for( USHORT nIndex = 0, nCount = aArr.Count(); nIndex < nCount; ++nIndex )
+ InsertEntry( aArr.GetString( nIndex ) );
+}
-void ScDPFunctionDlg::SetUI( BOOL bSubTotals )
+// ============================================================================
+
+ScDPFunctionDlg::ScDPFunctionDlg(
+ Window* pParent, const ScDPLabelDataVec& rLabelVec,
+ const ScDPLabelData& rLabelData, const ScDPFuncData& rFuncData ) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_DPDATAFIELD ) ),
+ maFlFunc ( this, ScResId( FL_FUNC ) ),
+ maLbFunc ( this, ScResId( LB_FUNC ) ),
+ maFtNameLabel ( this, ScResId( FT_NAMELABEL ) ),
+ maFtName ( this, ScResId( FT_NAME ) ),
+ maFlDisplay ( this, ScResId( FL_DISPLAY ) ),
+ maFtType ( this, ScResId( FT_TYPE ) ),
+ maLbType ( this, ScResId( LB_TYPE ) ),
+ maFtBaseField ( this, ScResId( FT_BASEFIELD ) ),
+ maLbBaseField ( this, ScResId( LB_BASEFIELD ) ),
+ maFtBaseItem ( this, ScResId( FT_BASEITEM ) ),
+ maLbBaseItem ( this, ScResId( LB_BASEITEM ) ),
+ maBtnOk ( this, ScResId( BTN_OK ) ),
+ maBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ maBtnHelp ( this, ScResId( BTN_HELP ) ),
+ maBtnMore ( this, ScResId( BTN_MORE ) ),
+ maLbTypeWrp ( maLbType, spRefTypeMap ),
+ mrLabelVec ( rLabelVec ),
+ mbEmptyItem ( false )
{
- aBtnOk.SetClickHdl ( LINK( this, ScDPFunctionDlg, ClickHdl ) );
+ FreeResource();
+ Init( rLabelData, rFuncData );
+}
- if ( bSubTotals )
- {
- aFlFunc.SetText( ScResId( STR_SUBTOTALS ) );
+USHORT ScDPFunctionDlg::GetFuncMask() const
+{
+ return maLbFunc.GetSelection();
+}
- aBtnNone.SetClickHdl ( LINK( this, ScDPFunctionDlg, RadioClickHdl ) );
- aBtnAuto.SetClickHdl ( LINK( this, ScDPFunctionDlg, RadioClickHdl ) );
- aBtnUser.SetClickHdl ( LINK( this, ScDPFunctionDlg, RadioClickHdl ) );
+DataPilotFieldReference ScDPFunctionDlg::GetFieldRef() const
+{
+ DataPilotFieldReference aRef;
- if ( nFuncMask == PIVOT_FUNC_NONE )
+ aRef.ReferenceType = maLbTypeWrp.GetControlValue();
+ aRef.ReferenceField = maLbBaseField.GetSelectEntry();
+
+ USHORT nBaseItemPos = maLbBaseItem.GetSelectEntryPos();
+ switch( nBaseItemPos )
+ {
+ case SC_BASEITEM_PREV_POS:
+ aRef.ReferenceItemType = DataPilotFieldReferenceItemType::PREVIOUS;
+ break;
+ case SC_BASEITEM_NEXT_POS:
+ aRef.ReferenceItemType = DataPilotFieldReferenceItemType::NEXT;
+ break;
+ default:
{
- aBtnNone.Check( nFuncMask == PIVOT_FUNC_NONE );
- aLbFunc.Disable();
+ aRef.ReferenceItemType = DataPilotFieldReferenceItemType::NAMED;
+ if( !mbEmptyItem || (nBaseItemPos > SC_BASEITEM_USER_POS) )
+ aRef.ReferenceItemName = maLbBaseItem.GetSelectEntry();
}
- else if ( nFuncMask == PIVOT_FUNC_AUTO )
+ }
+
+ return aRef;
+}
+
+void ScDPFunctionDlg::Init( const ScDPLabelData& rLabelData, const ScDPFuncData& rFuncData )
+{
+ // list box
+ USHORT nFuncMask = (rFuncData.mnFuncMask == PIVOT_FUNC_NONE) ? PIVOT_FUNC_SUM : rFuncData.mnFuncMask;
+ maLbFunc.SetSelection( nFuncMask );
+
+ // field name
+ maFtName.SetText( rLabelData.maName );
+
+ // "More button" controls
+ maBtnMore.AddWindow( &maFlDisplay );
+ maBtnMore.AddWindow( &maFtType );
+ maBtnMore.AddWindow( &maLbType );
+ maBtnMore.AddWindow( &maFtBaseField );
+ maBtnMore.AddWindow( &maLbBaseField );
+ maBtnMore.AddWindow( &maFtBaseItem );
+ maBtnMore.AddWindow( &maLbBaseItem );
+
+ // handlers
+ maLbFunc.SetDoubleClickHdl( LINK( this, ScDPFunctionDlg, DblClickHdl ) );
+ maLbType.SetSelectHdl( LINK( this, ScDPFunctionDlg, SelectHdl ) );
+ maLbBaseField.SetSelectHdl( LINK( this, ScDPFunctionDlg, SelectHdl ) );
+
+ // base field list box
+ for( ScDPLabelDataVec::const_iterator aIt = mrLabelVec.begin(), aEnd = mrLabelVec.end(); aIt != aEnd; ++aIt )
+ maLbBaseField.InsertEntry( aIt->maName );
+
+ // base item list box
+ maLbBaseItem.SetSeparatorPos( SC_BASEITEM_USER_POS - 1 );
+
+ // select field reference type
+ maLbTypeWrp.SetControlValue( rFuncData.maFieldRef.ReferenceType );
+ SelectHdl( &maLbType ); // enables base field/item list boxes
+
+ // select base field
+ maLbBaseField.SelectEntry( rFuncData.maFieldRef.ReferenceField );
+ if( maLbBaseField.GetSelectEntryPos() >= maLbBaseField.GetEntryCount() )
+ maLbBaseField.SelectEntryPos( 0 );
+ SelectHdl( &maLbBaseField ); // fills base item list, selects base item
+
+ // select base item
+ switch( rFuncData.maFieldRef.ReferenceItemType )
+ {
+ case DataPilotFieldReferenceItemType::PREVIOUS:
+ maLbBaseItem.SelectEntryPos( SC_BASEITEM_PREV_POS );
+ break;
+ case DataPilotFieldReferenceItemType::NEXT:
+ maLbBaseItem.SelectEntryPos( SC_BASEITEM_NEXT_POS );
+ break;
+ default:
{
- aBtnAuto.Check();
- aLbFunc.Disable();
+ if( mbEmptyItem && !rFuncData.maFieldRef.ReferenceItemName.getLength() )
+ {
+ // select special "(empty)" entry added before other items
+ maLbBaseItem.SelectEntryPos( SC_BASEITEM_USER_POS );
+ }
+ else
+ {
+ USHORT nStartPos = mbEmptyItem ? (SC_BASEITEM_USER_POS + 1) : SC_BASEITEM_USER_POS;
+ USHORT nPos = lclFindListBoxEntry( maLbBaseItem, 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 );
+ }
}
- else
+ }
+}
+
+IMPL_LINK( ScDPFunctionDlg, SelectHdl, ListBox*, pLBox )
+{
+ if( pLBox == &maLbType )
+ {
+ bool bEnableField, bEnableItem;
+ switch( maLbTypeWrp.GetControlValue() )
{
- aBtnUser.Check();
- aLbFunc.Enable();
+ case DataPilotFieldReferenceType::ITEM_DIFFERENCE:
+ case DataPilotFieldReferenceType::ITEM_PERCENTAGE:
+ case DataPilotFieldReferenceType::ITEM_PERCENTAGE_DIFFERENCE:
+ bEnableField = bEnableItem = true;
+ break;
+
+ case DataPilotFieldReferenceType::RUNNING_TOTAL:
+ bEnableField = true;
+ bEnableItem = false;
+ break;
+
+ default:
+ bEnableField = bEnableItem = false;
}
+
+ bEnableField &= maLbBaseField.GetEntryCount() > 0;
+ maFtBaseField.Enable( bEnableField );
+ maLbBaseField.Enable( bEnableField );
+
+ bEnableItem &= bEnableField;
+ maFtBaseItem.Enable( bEnableItem );
+ maLbBaseItem.Enable( bEnableItem );
}
- else
+ else if( pLBox == &maLbBaseField )
{
- aFlFunc.SetText( ScResId( STR_DATAFUNC ) );
-
- Size aSize( aFlFunc.GetSizePixel() );
- Point aPos1( aFtNameLabel.GetPosPixel() );
- Point aPos2( aFtName.GetPosPixel() );
- long nYDiff = aBtnUser.GetPosPixel().Y()
- - aBtnNone.GetPosPixel().Y()
- + aBtnNone.GetSizePixel().Height()
- + LogicToPixel( Point(5,0), MAP_APPFONT ).X();
-
- aPos1.Y() -= nYDiff;
- aPos2.Y() -= nYDiff;
-
- aLbFunc .SetPosPixel( aBtnNone.GetPosPixel() );
- aFtNameLabel.SetPosPixel( aPos1 );
- aFtName .SetPosPixel( aPos2 );
-
- aLbFunc.Enable();
- aBtnNone.Hide();
- aBtnAuto.Hide();
- aBtnUser.Hide();
- aBtnUser.Check();
-
- aCbShowAll.Disable();
- aCbShowAll.Hide();
-
- aSize = GetSizePixel();
- aSize.Height() -= nYDiff;
- SetSizePixel( aSize );
+ // keep "previous" and "next" entries
+ while( maLbBaseItem.GetEntryCount() > SC_BASEITEM_USER_POS )
+ maLbBaseItem.RemoveEntry( SC_BASEITEM_USER_POS );
+
+ // update item list for current base field
+ mbEmptyItem = false;
+ size_t nBasePos = maLbBaseField.GetSelectEntryPos();
+ if( nBasePos < mrLabelVec.size() )
+ mbEmptyItem = lclFillListBox( maLbBaseItem, mrLabelVec[ nBasePos ].maMembers, SC_BASEITEM_USER_POS );
+
+ // select base item
+ USHORT nItemPos = (maLbBaseItem.GetEntryCount() > SC_BASEITEM_USER_POS) ? SC_BASEITEM_USER_POS : SC_BASEITEM_PREV_POS;
+ maLbBaseItem.SelectEntryPos( nItemPos );
}
+ return 0;
}
-//------------------------------------------------------------------------
-// Handler:
+IMPL_LINK( ScDPFunctionDlg, DblClickHdl, MultiListBox*, EMPTYARG )
+{
+ maBtnOk.Click();
+ return 0;
+}
-IMPL_LINK( ScDPFunctionDlg, RadioClickHdl, RadioButton *, pBtn )
+// ============================================================================
+
+ScDPSubtotalDlg::ScDPSubtotalDlg( Window* pParent, ScDPObject& rDPObj,
+ const ScDPLabelData& rLabelData, const ScDPFuncData& rFuncData,
+ const ScDPNameVec& rDataFields, bool bEnableLayout ) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_PIVOTSUBT ) ),
+ maFlSubt ( this, ScResId( FL_FUNC ) ),
+ maRbNone ( this, ScResId( RB_NONE ) ),
+ maRbAuto ( this, ScResId( RB_AUTO ) ),
+ maRbUser ( this, ScResId( RB_USER ) ),
+ maLbFunc ( this, ScResId( LB_FUNC ) ),
+ maFtNameLabel ( this, ScResId( FT_NAMELABEL ) ),
+ maFtName ( this, ScResId( FT_NAME ) ),
+ maCbShowAll ( this, ScResId( CB_SHOWALL ) ),
+ maBtnOk ( this, ScResId( BTN_OK ) ),
+ maBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ maBtnHelp ( this, ScResId( BTN_HELP ) ),
+ maBtnOptions ( this, ScResId( BTN_OPTIONS ) ),
+ mrDPObj ( rDPObj ),
+ mrDataFields ( rDataFields ),
+ maLabelData ( rLabelData ),
+ mbEnableLayout ( bEnableLayout )
{
- if ( pBtn == &aBtnNone || pBtn == &aBtnAuto )
- {
- aLbFunc.Disable();
- }
- else if ( pBtn == &aBtnUser )
+ FreeResource();
+ Init( rLabelData, rFuncData );
+}
+
+USHORT ScDPSubtotalDlg::GetFuncMask() const
+{
+ USHORT nFuncMask = PIVOT_FUNC_NONE;
+
+ if( maRbAuto.IsChecked() )
+ nFuncMask = PIVOT_FUNC_AUTO;
+ else if( maRbUser.IsChecked() )
+ nFuncMask = maLbFunc.GetSelection();
+
+ return nFuncMask;
+}
+
+void ScDPSubtotalDlg::FillLabelData( ScDPLabelData& rLabelData ) const
+{
+ rLabelData.mnFuncMask = GetFuncMask();
+ rLabelData.mnUsedHier = maLabelData.mnUsedHier;
+ rLabelData.mbShowAll = maCbShowAll.IsChecked();
+ rLabelData.maMembers = maLabelData.maMembers;
+ rLabelData.maVisible = maLabelData.maVisible;
+ rLabelData.maSortInfo = maLabelData.maSortInfo;
+ rLabelData.maLayoutInfo = maLabelData.maLayoutInfo;
+ rLabelData.maShowInfo = maLabelData.maShowInfo;
+}
+
+void ScDPSubtotalDlg::Init( const ScDPLabelData& rLabelData, const ScDPFuncData& rFuncData )
+{
+ // field name
+ maFtName.SetText( rLabelData.maName );
+
+ // radio buttons
+ maRbNone.SetClickHdl( LINK( this, ScDPSubtotalDlg, RadioClickHdl ) );
+ maRbAuto.SetClickHdl( LINK( this, ScDPSubtotalDlg, RadioClickHdl ) );
+ maRbUser.SetClickHdl( LINK( this, ScDPSubtotalDlg, RadioClickHdl ) );
+
+ RadioButton* pRBtn = 0;
+ switch( rFuncData.mnFuncMask )
{
- aLbFunc.Enable();
+ case PIVOT_FUNC_NONE: pRBtn = &maRbNone; break;
+ case PIVOT_FUNC_AUTO: pRBtn = &maRbAuto; break;
+ default: pRBtn = &maRbUser;
}
- return 0;
+ pRBtn->Check();
+ RadioClickHdl( pRBtn );
+
+ // list box
+ maLbFunc.SetSelection( rFuncData.mnFuncMask );
+ maLbFunc.SetDoubleClickHdl( LINK( this, ScDPSubtotalDlg, DblClickHdl ) );
+
+ // show all
+ maCbShowAll.Check( rLabelData.mbShowAll );
+
+ // options
+ maBtnOptions.SetClickHdl( LINK( this, ScDPSubtotalDlg, ClickHdl ) );
}
+// ----------------------------------------------------------------------------
+
+IMPL_LINK( ScDPSubtotalDlg, RadioClickHdl, RadioButton*, pBtn )
+{
+ maLbFunc.Enable( pBtn == &maRbUser );
+ return 0;
+}
-//------------------------------------------------------------------------
+IMPL_LINK( ScDPSubtotalDlg, DblClickHdl, MultiListBox*, EMPTYARG )
+{
+ maBtnOk.Click();
+ return 0;
+}
-IMPL_LINK_INLINE_START( ScDPFunctionDlg, DblClickHdl, MultiListBox *, EMPTYARG )
+IMPL_LINK( ScDPSubtotalDlg, ClickHdl, PushButton*, pBtn )
{
- ClickHdl( &aBtnOk );
+ if( pBtn == &maBtnOptions )
+ {
+ ScDPSubtotalOptDlg* pDlg = new ScDPSubtotalOptDlg( this, mrDPObj, maLabelData, mrDataFields, mbEnableLayout );
+ if( pDlg->Execute() == RET_OK )
+ pDlg->FillLabelData( maLabelData );
+ delete pDlg;
+ }
return 0;
}
-IMPL_LINK_INLINE_END( ScDPFunctionDlg, DblClickHdl, MultiListBox *, EMPTYARG )
-//------------------------------------------------------------------------
+// ============================================================================
+
+ScDPSubtotalOptDlg::ScDPSubtotalOptDlg( Window* pParent, ScDPObject& rDPObj,
+ const ScDPLabelData& rLabelData, const ScDPNameVec& rDataFields,
+ bool bEnableLayout ) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_DPSUBTOTAL_OPT ) ),
+ maFlSortBy ( this, ScResId( FL_SORT_BY ) ),
+ maLbSortBy ( this, ScResId( LB_SORT_BY ) ),
+ maRbSortAsc ( this, ScResId( RB_SORT_ASC ) ),
+ maRbSortDesc ( this, ScResId( RB_SORT_DESC ) ),
+ maRbSortMan ( this, ScResId( RB_SORT_MAN ) ),
+ maFlLayout ( this, ScResId( FL_LAYOUT ) ),
+ maFtLayout ( this, ScResId( FT_LAYOUT ) ),
+ maLbLayout ( this, ScResId( LB_LAYOUT ) ),
+ maCbLayoutEmpty ( this, ScResId( CB_LAYOUT_EMPTY ) ),
+ maFlAutoShow ( this, ScResId( FL_AUTOSHOW ) ),
+ maCbShow ( this, ScResId( CB_SHOW ) ),
+ maNfShow ( this, ScResId( NF_SHOW ) ),
+ maFtShow ( this, ScResId( FT_SHOW ) ),
+ maFtShowFrom ( this, ScResId( FT_SHOW_FROM ) ),
+ maLbShowFrom ( this, ScResId( LB_SHOW_FROM ) ),
+ maFtShowUsing ( this, ScResId( FT_SHOW_USING ) ),
+ maLbShowUsing ( this, ScResId( LB_SHOW_USING ) ),
+ maFlHide ( this, ScResId( FL_HIDE ) ),
+ maLbHide ( this, ScResId( CT_HIDE ) ),
+ maFtHierarchy ( this, ScResId( FT_HIERARCHY ) ),
+ maLbHierarchy ( this, ScResId( LB_HIERARCHY ) ),
+ maBtnOk ( this, ScResId( BTN_OK ) ),
+ maBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ maBtnHelp ( this, ScResId( BTN_HELP ) ),
+ maLbLayoutWrp ( maLbLayout, spLayoutMap ),
+ maLbShowFromWrp ( maLbShowFrom, spShowFromMap ),
+ mrDPObj ( rDPObj ),
+ maLabelData ( rLabelData )
+{
+ FreeResource();
+ Init( rDataFields, bEnableLayout );
+}
+
+void ScDPSubtotalOptDlg::FillLabelData( ScDPLabelData& rLabelData ) const
+{
+ // *** SORTING ***
+
+ if( maRbSortMan.IsChecked() )
+ rLabelData.maSortInfo.Mode = DataPilotFieldSortMode::MANUAL;
+ else if( maLbSortBy.GetSelectEntryPos() == SC_SORTNAME_POS )
+ rLabelData.maSortInfo.Mode = DataPilotFieldSortMode::NAME;
+ else
+ rLabelData.maSortInfo.Mode = DataPilotFieldSortMode::DATA;
+
+ rLabelData.maSortInfo.Field = maLbSortBy.GetSelectEntry();
+ rLabelData.maSortInfo.IsAscending = maRbSortAsc.IsChecked();
+
+ // *** LAYOUT MODE ***
+
+ rLabelData.maLayoutInfo.LayoutMode = maLbLayoutWrp.GetControlValue();
+ rLabelData.maLayoutInfo.AddEmptyLines = maCbLayoutEmpty.IsChecked();
+
+ // *** AUTO SHOW ***
+
+ rLabelData.maShowInfo.IsEnabled = maCbShow.IsChecked();
+ rLabelData.maShowInfo.ShowItemsMode = maLbShowFromWrp.GetControlValue();
+ rLabelData.maShowInfo.ItemCount = maNfShow.GetValue();
+ rLabelData.maShowInfo.DataField = maLbShowUsing.GetSelectEntry();
+
+ // *** HIDDEN ITEMS ***
+
+ rLabelData.maMembers = maLabelData.maMembers;
+ ULONG nVisCount = maLbHide.GetEntryCount();
+ rLabelData.maVisible.realloc( nVisCount );
+ for( USHORT nPos = 0; nPos < nVisCount; ++nPos )
+ rLabelData.maVisible[ nPos ] = !maLbHide.IsChecked( nPos );
-IMPL_LINK( ScDPFunctionDlg, ClickHdl, PushButton *, pBtn )
+ // *** HIERARCHY ***
+
+ rLabelData.mnUsedHier = maLbHierarchy.GetSelectEntryCount() ? maLbHierarchy.GetSelectEntryPos() : 0;
+}
+
+void ScDPSubtotalOptDlg::Init( const ScDPNameVec& rDataFields, bool bEnableLayout )
{
- if ( pBtn == &aBtnOk )
+ // *** SORTING ***
+
+ sal_Int32 nSortMode = maLabelData.maSortInfo.Mode;
+
+ // sort fields list box
+ maLbSortBy.InsertEntry( maLabelData.maName );
+ for( ScDPNameVec::const_iterator aIt = rDataFields.begin(), aEnd = rDataFields.end(); aIt != aEnd; ++aIt )
{
- if ( aBtnNone.IsChecked() )
- nFuncMask = PIVOT_FUNC_NONE;
- else if ( aBtnAuto.IsChecked() )
- nFuncMask = PIVOT_FUNC_AUTO;
- else if ( aBtnUser.IsChecked() )
+ maLbSortBy.InsertEntry( *aIt );
+ maLbShowUsing.InsertEntry( *aIt ); // for AutoShow
+ }
+ if( maLbSortBy.GetEntryCount() > SC_SORTDATA_POS )
+ maLbSortBy.SetSeparatorPos( SC_SORTDATA_POS - 1 );
+
+ USHORT nSortPos = SC_SORTNAME_POS;
+ if( nSortMode == DataPilotFieldSortMode::DATA )
+ {
+ nSortPos = lclFindListBoxEntry( maLbSortBy, maLabelData.maSortInfo.Field, SC_SORTDATA_POS );
+ if( nSortPos >= maLbSortBy.GetEntryCount() )
{
- USHORT nPos = 0;
- USHORT nSelCount = aLbFunc.GetSelectEntryCount();
+ nSortPos = SC_SORTNAME_POS;
+ nSortMode = DataPilotFieldSortMode::MANUAL;
+ }
+ }
+ maLbSortBy.SelectEntryPos( nSortPos );
- nFuncMask = PIVOT_FUNC_NONE;
+ // sorting mode
+ maRbSortAsc.SetClickHdl( LINK( this, ScDPSubtotalOptDlg, RadioClickHdl ) );
+ maRbSortDesc.SetClickHdl( LINK( this, ScDPSubtotalOptDlg, RadioClickHdl ) );
+ maRbSortMan.SetClickHdl( LINK( this, ScDPSubtotalOptDlg, RadioClickHdl ) );
- for ( USHORT i=0; i<nSelCount; i++ )
- {
- nPos = aLbFunc.GetSelectEntryPos( i );
- nFuncMask = ( nFuncMask | *((USHORT*)aLbFunc.GetEntryData( nPos )) );
- }
- }
+ RadioButton* pRBtn = 0;
+ switch( nSortMode )
+ {
+ case DataPilotFieldSortMode::NONE:
+ case DataPilotFieldSortMode::MANUAL:
+ pRBtn = &maRbSortMan;
+ break;
+ default:
+ pRBtn = maLabelData.maSortInfo.IsAscending ? &maRbSortAsc : &maRbSortDesc;
+ }
+ pRBtn->Check();
+ RadioClickHdl( pRBtn );
+
+ // *** LAYOUT MODE ***
+
+ maFlLayout.Enable( bEnableLayout );
+ maFtLayout.Enable( bEnableLayout );
+ maLbLayout.Enable( bEnableLayout );
+ maCbLayoutEmpty.Enable( bEnableLayout );
+
+ maLbLayoutWrp.SetControlValue( maLabelData.maLayoutInfo.LayoutMode );
+ maCbLayoutEmpty.Check( maLabelData.maLayoutInfo.AddEmptyLines );
+
+ // *** AUTO SHOW ***
+
+ maCbShow.Check( maLabelData.maShowInfo.IsEnabled );
+ maCbShow.SetClickHdl( LINK( this, ScDPSubtotalOptDlg, CheckHdl ) );
+
+ maLbShowFromWrp.SetControlValue( maLabelData.maShowInfo.ShowItemsMode );
+ long nCount = static_cast< long >( maLabelData.maShowInfo.ItemCount );
+ if( nCount < 1 )
+ nCount = SC_SHOW_DEFAULT;
+ maNfShow.SetValue( nCount );
+
+ // maLbShowUsing already filled above
+ maLbShowUsing.SelectEntry( maLabelData.maShowInfo.DataField );
+ if( maLbShowUsing.GetSelectEntryPos() >= maLbShowUsing.GetEntryCount() )
+ maLbShowUsing.SelectEntryPos( 0 );
+
+ CheckHdl( &maCbShow ); // enable/disable dependent controls
+
+ // *** HIDDEN ITEMS ***
+
+ maLbHide.SetHelpId( HID_SC_DPSUBT_HIDE );
+ InitHideListBox();
+
+ // *** HIERARCHY ***
+
+ if( maLabelData.maHiers.getLength() > 1 )
+ {
+ lclFillListBox( maLbHierarchy, maLabelData.maHiers );
+ sal_Int32 nHier = maLabelData.mnUsedHier;
+ if( (nHier < 0) || (nHier >= maLabelData.maHiers.getLength()) ) nHier = 0;
+ maLbHierarchy.SelectEntryPos( static_cast< USHORT >( nHier ) );
+ maLbHierarchy.SetSelectHdl( LINK( this, ScDPSubtotalOptDlg, SelectHdl ) );
+ }
+ else
+ {
+ maFtHierarchy.Disable();
+ maLbHierarchy.Disable();
+ }
+}
+
+void ScDPSubtotalOptDlg::InitHideListBox()
+{
+ maLbHide.Clear();
+ lclFillListBox( maLbHide, maLabelData.maMembers );
+ for( sal_Int32 nVisIdx = 0, nVisSize = maLabelData.maVisible.getLength(); nVisIdx < nVisSize; ++nVisIdx )
+ maLbHide.CheckEntryPos( static_cast< USHORT >( nVisIdx ), !maLabelData.maVisible[ nVisIdx ] );
+ bool bEnable = maLbHide.GetEntryCount() > 0;
+ maFlHide.Enable( bEnable );
+ maLbHide.Enable( bEnable );
+}
+
+IMPL_LINK( ScDPSubtotalOptDlg, RadioClickHdl, RadioButton*, pBtn )
+{
+ maLbSortBy.Enable( pBtn != &maRbSortMan );
+ return 0;
+}
- EndDialog( RET_OK );
+IMPL_LINK( ScDPSubtotalOptDlg, CheckHdl, CheckBox*, pCBox )
+{
+ if( pCBox == &maCbShow )
+ {
+ bool bEnable = maCbShow.IsChecked();
+ maNfShow.Enable( bEnable );
+ maFtShow.Enable( bEnable );
+ maFtShowFrom.Enable( bEnable );
+ maLbShowFrom.Enable( bEnable );
+
+ bool bEnableUsing = bEnable && (maLbShowUsing.GetEntryCount() > 0);
+ maFtShowUsing.Enable( bEnableUsing );
+ maLbShowUsing.Enable( bEnableUsing );
+ }
+ return 0;
+}
+
+IMPL_LINK( ScDPSubtotalOptDlg, SelectHdl, ListBox*, pLBox )
+{
+ if( pLBox == &maLbHierarchy )
+ {
+ mrDPObj.GetMembers( maLabelData.mnCol, maLbHierarchy.GetSelectEntryPos(),
+ maLabelData.maMembers, &maLabelData.maVisible );
+ InitHideListBox();
}
return 0;
}
+
+// ============================================================================
+