summaryrefslogtreecommitdiff
path: root/sc/source/ui/dbgui
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source/ui/dbgui')
-rw-r--r--sc/source/ui/dbgui/makefile.mk1
-rw-r--r--sc/source/ui/dbgui/pvfundlg.cxx66
-rw-r--r--sc/source/ui/dbgui/pvlaydlg.cxx106
3 files changed, 124 insertions, 49 deletions
diff --git a/sc/source/ui/dbgui/makefile.mk b/sc/source/ui/dbgui/makefile.mk
index b495b5eabcc9..9ff21b6c4d08 100644
--- a/sc/source/ui/dbgui/makefile.mk
+++ b/sc/source/ui/dbgui/makefile.mk
@@ -80,6 +80,7 @@ EXCEPTIONSFILES= \
$(SLO)$/csvsplits.obj \
$(SLO)$/csvtablebox.obj \
$(SLO)$/fieldwnd.obj \
+ $(SLO)$/pvfundlg.obj \
$(SLO)$/pvlaydlg.obj \
$(SLO)$/dapidata.obj \
$(SLO)$/validate.obj
diff --git a/sc/source/ui/dbgui/pvfundlg.cxx b/sc/source/ui/dbgui/pvfundlg.cxx
index d44791ff6972..30ee1a44d384 100644
--- a/sc/source/ui/dbgui/pvfundlg.cxx
+++ b/sc/source/ui/dbgui/pvfundlg.cxx
@@ -48,12 +48,15 @@
#include "pvfundlg.hrc"
#include "globstr.hrc"
+#include <vector>
+
// ============================================================================
using namespace ::com::sun::star::sheet;
using ::rtl::OUString;
using ::com::sun::star::uno::Sequence;
+using ::std::vector;
// ============================================================================
@@ -86,6 +89,25 @@ bool lclFillListBox( ListBoxType& rLBox, const Sequence< OUString >& rStrings, U
return bEmpty;
}
+template< typename ListBoxType >
+bool lclFillListBox( ListBoxType& rLBox, const vector<ScDPLabelData::Member>& rMembers, USHORT nEmptyPos = LISTBOX_APPEND )
+{
+ bool bEmpty = false;
+ vector<ScDPLabelData::Member>::const_iterator itr = rMembers.begin(), itrEnd = rMembers.end();
+ for (; itr != itrEnd; ++itr)
+ {
+ OUString aName = itr->getDisplayName();
+ if (aName.getLength())
+ rLBox.InsertEntry(aName);
+ else
+ {
+ rLBox.InsertEntry(ScGlobal::GetRscString(STR_EMPTYDATA), nEmptyPos);
+ bEmpty = true;
+ }
+ }
+ return bEmpty;
+}
+
/** Searches for a listbox entry, starts search at specified position. */
USHORT lclFindListBoxEntry( const ListBox& rLBox, const String& rEntry, USHORT nStartPos )
{
@@ -253,7 +275,7 @@ void ScDPFunctionDlg::Init( const ScDPLabelData& rLabelData, const ScDPFuncData&
maLbFunc.SetSelection( nFuncMask );
// field name
- maFtName.SetText( rLabelData.maName );
+ maFtName.SetText(rLabelData.getDisplayName());
// "More button" controls
maBtnMore.AddWindow( &maFlDisplay );
@@ -271,7 +293,7 @@ void ScDPFunctionDlg::Init( const ScDPLabelData& rLabelData, const ScDPFuncData&
// base field list box
for( ScDPLabelDataVec::const_iterator aIt = mrLabelVec.begin(), aEnd = mrLabelVec.end(); aIt != aEnd; ++aIt )
- maLbBaseField.InsertEntry( aIt->maName );
+ maLbBaseField.InsertEntry(aIt->getDisplayName());
// base item list box
maLbBaseItem.SetSeparatorPos( SC_BASEITEM_USER_POS - 1 );
@@ -414,8 +436,6 @@ void ScDPSubtotalDlg::FillLabelData( ScDPLabelData& rLabelData ) const
rLabelData.mnUsedHier = maLabelData.mnUsedHier;
rLabelData.mbShowAll = maCbShowAll.IsChecked();
rLabelData.maMembers = maLabelData.maMembers;
- rLabelData.maVisible = maLabelData.maVisible;
- rLabelData.maShowDet = maLabelData.maShowDet;
rLabelData.maSortInfo = maLabelData.maSortInfo;
rLabelData.maLayoutInfo = maLabelData.maLayoutInfo;
rLabelData.maShowInfo = maLabelData.maShowInfo;
@@ -424,7 +444,7 @@ void ScDPSubtotalDlg::FillLabelData( ScDPLabelData& rLabelData ) const
void ScDPSubtotalDlg::Init( const ScDPLabelData& rLabelData, const ScDPFuncData& rFuncData )
{
// field name
- maFtName.SetText( rLabelData.maName );
+ maFtName.SetText(rLabelData.getDisplayName());
// radio buttons
maRbNone.SetClickHdl( LINK( this, ScDPSubtotalDlg, RadioClickHdl ) );
@@ -547,9 +567,8 @@ void ScDPSubtotalOptDlg::FillLabelData( ScDPLabelData& rLabelData ) const
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 );
+ rLabelData.maMembers[nPos].mbVisible = !maLbHide.IsChecked(nPos);
// *** HIERARCHY ***
@@ -563,7 +582,8 @@ void ScDPSubtotalOptDlg::Init( const ScDPNameVec& rDataFields, bool bEnableLayou
sal_Int32 nSortMode = maLabelData.maSortInfo.Mode;
// sort fields list box
- maLbSortBy.InsertEntry( maLabelData.maName );
+ maLbSortBy.InsertEntry(maLabelData.getDisplayName());
+
for( ScDPNameVec::const_iterator aIt = rDataFields.begin(), aEnd = rDataFields.end(); aIt != aEnd; ++aIt )
{
maLbSortBy.InsertEntry( *aIt );
@@ -656,8 +676,9 @@ 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 ] );
+ size_t n = maLabelData.maMembers.size();
+ for (size_t i = 0; i < n; ++i)
+ maLbHide.CheckEntryPos(static_cast<USHORT>(i), !maLabelData.maMembers[i].mbVisible);
bool bEnable = maLbHide.GetEntryCount() > 0;
maFlHide.Enable( bEnable );
maLbHide.Enable( bEnable );
@@ -690,8 +711,7 @@ IMPL_LINK( ScDPSubtotalOptDlg, SelectHdl, ListBox*, pLBox )
{
if( pLBox == &maLbHierarchy )
{
- mrDPObj.GetMembers( maLabelData.mnCol, maLbHierarchy.GetSelectEntryPos(),
- maLabelData.maMembers, &maLabelData.maVisible, &maLabelData.maShowDet );
+ mrDPObj.GetMembers(maLabelData.mnCol, maLbHierarchy.GetSelectEntryPos(), maLabelData.maMembers);
InitHideListBox();
}
return 0;
@@ -705,7 +725,9 @@ ScDPShowDetailDlg::ScDPShowDetailDlg( Window* pParent, ScDPObject& rDPObj, USHOR
maLbDims ( this, ScResId( LB_DIMS ) ),
maBtnOk ( this, ScResId( BTN_OK ) ),
maBtnCancel ( this, ScResId( BTN_CANCEL ) ),
- maBtnHelp ( this, ScResId( BTN_HELP ) )
+ maBtnHelp ( this, ScResId( BTN_HELP ) ),
+
+ mrDPObj(rDPObj)
{
FreeResource();
@@ -719,7 +741,13 @@ ScDPShowDetailDlg::ScDPShowDetailDlg( Window* pParent, ScDPObject& rDPObj, USHOR
{
const ScDPSaveDimension* pDimension = pSaveData ? pSaveData->GetExistingDimensionByName(aName) : 0;
if ( !pDimension || (pDimension->GetOrientation() != nOrient) )
+ {
+ const OUString* pLayoutName = pDimension->GetLayoutName();
+ if (pLayoutName)
+ aName = *pLayoutName;
maLbDims.InsertEntry( aName );
+ maNameIndexMap.insert(DimNameIndexMap::value_type(aName, nDim));
+ }
}
}
if( maLbDims.GetEntryCount() )
@@ -735,7 +763,17 @@ short ScDPShowDetailDlg::Execute()
String ScDPShowDetailDlg::GetDimensionName() const
{
- return maLbDims.GetSelectEntry();
+ // Look up the internal dimension name which may be different from the
+ // displayed field name.
+ String aSelectedName = maLbDims.GetSelectEntry();
+ DimNameIndexMap::const_iterator itr = maNameIndexMap.find(aSelectedName);
+ if (itr == maNameIndexMap.end())
+ // This should never happen!
+ return aSelectedName;
+
+ long nDim = itr->second;
+ BOOL bIsDataLayout = false;
+ return mrDPObj.GetDimName(nDim, bIsDataLayout);
}
IMPL_LINK( ScDPShowDetailDlg, DblClickHdl, ListBox*, pLBox )
diff --git a/sc/source/ui/dbgui/pvlaydlg.cxx b/sc/source/ui/dbgui/pvlaydlg.cxx
index 7b03e067a865..6a9bb63e3ae3 100644
--- a/sc/source/ui/dbgui/pvlaydlg.cxx
+++ b/sc/source/ui/dbgui/pvlaydlg.cxx
@@ -63,6 +63,8 @@
#include "sc.hrc" //CHINA001
#include "scabstdlg.hxx" //CHINA001
using namespace com::sun::star;
+using ::rtl::OUString;
+using ::std::vector;
//----------------------------------------------------------------------------
@@ -378,24 +380,23 @@ void ScDPLayoutDlg::StateChanged( StateChangedType nStateChange )
//----------------------------------------------------------------------------
-void ScDPLayoutDlg::InitWndSelect( LabelData** ppLabelArr, long nLabels )
+void ScDPLayoutDlg::InitWndSelect( const vector<ScDPLabelDataRef>& rLabels )
{
- if ( ppLabelArr )
+ size_t nLabelCount = rLabels.size();
+ if (nLabelCount > MAX_LABELS)
+ nLabelCount = MAX_LABELS;
+ size_t nLast = (nLabelCount > PAGE_SIZE) ? (PAGE_SIZE - 1) : (nLabelCount - 1);
+
+ aLabelDataArr.clear();
+ aLabelDataArr.reserve( nLabelCount );
+ for ( size_t i=0; i < nLabelCount; i++ )
{
- size_t nLabelCount = static_cast< size_t >( (nLabels > MAX_LABELS) ? MAX_LABELS : nLabels );
- size_t nLast = (nLabelCount > PAGE_SIZE) ? (PAGE_SIZE - 1) : (nLabelCount - 1);
+ aLabelDataArr.push_back(*rLabels[i]);
- aLabelDataArr.clear();
- aLabelDataArr.reserve( nLabelCount );
- for ( size_t i=0; i < nLabelCount; i++ )
+ if ( i <= nLast )
{
- aLabelDataArr.push_back( *ppLabelArr[i] );
-
- if ( i <= nLast )
- {
- aWndSelect.AddField( aLabelDataArr[i].maName, i );
- aSelectArr[i].reset( new ScDPFuncData( aLabelDataArr[i].mnCol, aLabelDataArr[i].mnFuncMask ) );
- }
+ aWndSelect.AddField(aLabelDataArr[i].getDisplayName(), i);
+ aSelectArr[i].reset( new ScDPFuncData( aLabelDataArr[i].mnCol, aLabelDataArr[i].mnFuncMask ) );
}
}
}
@@ -493,18 +494,19 @@ void ScDPLayoutDlg::InitFocus()
void ScDPLayoutDlg::InitFields()
{
- InitWndSelect( thePivotData.ppLabelArr, static_cast<long>(thePivotData.nLabels) );
+ InitWndSelect(thePivotData.maLabelArray);
InitWnd( thePivotData.aPageArr, static_cast<long>(thePivotData.nPageCount), TYPE_PAGE );
InitWnd( thePivotData.aColArr, static_cast<long>(thePivotData.nColCount), TYPE_COL );
InitWnd( thePivotData.aRowArr, static_cast<long>(thePivotData.nRowCount), TYPE_ROW );
InitWnd( thePivotData.aDataArr, static_cast<long>(thePivotData.nDataCount), TYPE_DATA );
+ size_t nLabels = thePivotData.maLabelArray.size();
aSlider.SetPageSize( PAGE_SIZE );
aSlider.SetVisibleSize( PAGE_SIZE );
aSlider.SetLineSize( LINE_SIZE );
- aSlider.SetRange( Range( 0, static_cast<long>(((thePivotData.nLabels+LINE_SIZE-1)/LINE_SIZE)*LINE_SIZE) ) );
+ aSlider.SetRange( Range( 0, static_cast<long>(((nLabels+LINE_SIZE-1)/LINE_SIZE)*LINE_SIZE) ) );
- if ( thePivotData.nLabels > PAGE_SIZE )
+ if ( nLabels > PAGE_SIZE )
{
aSlider.SetEndScrollHdl( LINK( this, ScDPLayoutDlg, ScrollHdl ) );
aSlider.Show();
@@ -594,7 +596,7 @@ void ScDPLayoutDlg::AddField( size_t nFromIndex, ScDPFieldType eToType, const Po
if ( !bDataArr )
{
- if ( toWnd->AddField( rData.maName,
+ if ( toWnd->AddField( rData.getDisplayName(),
DlgPos2WndPos( rAtPos, *toWnd ),
nAddedAt ) )
{
@@ -605,9 +607,9 @@ void ScDPLayoutDlg::AddField( size_t nFromIndex, ScDPFieldType eToType, const Po
else
{
USHORT nMask = fData.mnFuncMask;
- String aStr( GetFuncString( nMask, rData.mbIsValue ) );
+ OUString aStr = GetFuncString( nMask, rData.mbIsValue );
- aStr += rData.maName;
+ aStr += rData.getDisplayName();
if ( toWnd->AddField( aStr,
DlgPos2WndPos( rAtPos, *toWnd ),
@@ -1215,7 +1217,7 @@ String ScDPLayoutDlg::GetLabelString( SCsCOL nCol )
ScDPLabelData* pData = GetLabelData( nCol );
DBG_ASSERT( pData, "LabelData not found" );
if (pData)
- return pData->maName;
+ return pData->getDisplayName();
return String();
}
@@ -1491,6 +1493,8 @@ IMPL_LINK( ScDPLayoutDlg, OkHdl, OKButton *, EMPTYARG )
nPageCount, nColCount, nRowCount, nDataCount );
if ( bFit )
{
+ ScDPSaveData* pOldSaveData = xDlgDPObject->GetSaveData();
+
ScRange aOutRange( aAdrDest ); // bToNewTable is passed separately
ScDPSaveData aSaveData;
@@ -1522,31 +1526,63 @@ IMPL_LINK( ScDPLayoutDlg, OkHdl, OKButton *, EMPTYARG )
pDim->SetSortInfo( &aIt->maSortInfo );
pDim->SetLayoutInfo( &aIt->maLayoutInfo );
pDim->SetAutoShowInfo( &aIt->maShowInfo );
+ ScDPSaveDimension* pOldDim = NULL;
+ if (pOldSaveData)
+ {
+ // Transfer the existing layout names to new dimension instance.
+ pOldDim = pOldSaveData->GetExistingDimensionByName(aIt->maName);
+ if (pOldDim)
+ {
+ const OUString* pLayoutName = pOldDim->GetLayoutName();
+ if (pLayoutName)
+ pDim->SetLayoutName(*pLayoutName);
+
+ const OUString* pSubtotalName = pOldDim->GetSubtotalName();
+ if (pSubtotalName)
+ pDim->SetSubtotalName(*pSubtotalName);
+ }
+ }
bool bManualSort = ( aIt->maSortInfo.Mode == sheet::DataPilotFieldSortMode::MANUAL );
// visibility of members
- if( const rtl::OUString* pItem = aIt->maMembers.getConstArray() )
+ for (vector<ScDPLabelData::Member>::const_iterator itr = aIt->maMembers.begin(), itrEnd = aIt->maMembers.end();
+ itr != itrEnd; ++itr)
{
- sal_Int32 nIdx = 0;
- sal_Int32 nVisSize = aIt->maVisible.getLength();
- sal_Int32 nShowSize = aIt->maShowDet.getLength();
- for( const rtl::OUString* pEnd = pItem + aIt->maMembers.getLength(); pItem != pEnd; ++pItem, ++nIdx )
+ ScDPSaveMember* pMember = pDim->GetMemberByName(itr->maName);
+
+ // #i40054# create/access members only if flags are not default
+ // (or in manual sorting mode - to keep the order)
+ if (bManualSort || !itr->mbVisible || !itr->mbShowDetails)
+ {
+ pMember->SetIsVisible(itr->mbVisible);
+ pMember->SetShowDetails(itr->mbShowDetails);
+ }
+ if (pOldDim)
{
- // #i40054# create/access members only if flags are not default
- // (or in manual sorting mode - to keep the order)
- bool bIsVisible = (nIdx >= nVisSize) || aIt->maVisible[ nIdx ];
- bool bShowDetails = (nIdx >= nShowSize) || aIt->maShowDet[ nIdx ];
- if( bManualSort || !bIsVisible || !bShowDetails )
+ // Transfer the existing layout name.
+ ScDPSaveMember* pOldMember = pOldDim->GetMemberByName(itr->maName);
+ if (pOldMember)
{
- ScDPSaveMember* pMember = pDim->GetMemberByName( *pItem );
- pMember->SetIsVisible( bIsVisible );
- pMember->SetShowDetails( bShowDetails );
+ const OUString* pLayoutName = pOldMember->GetLayoutName();
+ if (pLayoutName)
+ pMember->SetLayoutName(*pLayoutName);
}
}
}
}
}
+ ScDPSaveDimension* pDim = aSaveData.GetDataLayoutDimension();
+ if (pDim && pOldSaveData)
+ {
+ ScDPSaveDimension* pOldDim = pOldSaveData->GetDataLayoutDimension();
+ if (pOldDim)
+ {
+ const OUString* pLayoutName = pOldDim->GetLayoutName();
+ if (pLayoutName)
+ pDim->SetLayoutName(*pLayoutName);
+ }
+ }
USHORT nWhichPivot = SC_MOD()->GetPool().GetWhich( SID_PIVOT_TABLE );
ScPivotItem aOutItem( nWhichPivot, &aSaveData, &aOutRange, bToNewTable );
@@ -1720,7 +1756,7 @@ IMPL_LINK( ScDPLayoutDlg, ScrollHdl, ScrollBar *, EMPTYARG )
for ( i=0; i<nFields; i++ )
{
const ScDPLabelData& rData = aLabelDataArr[nOffset+i];
- aWndSelect.AddField( rData.maName, i );
+ aWndSelect.AddField(rData.getDisplayName(), i);
aSelectArr[i].reset( new ScDPFuncData( rData.mnCol, rData.mnFuncMask ) );
}
for ( ; i<aSelectArr.size(); i++ )