diff options
author | Kohei Yoshida <kohei.yoshida@suse.com> | 2012-02-17 23:37:45 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@suse.com> | 2012-02-22 14:02:05 -0500 |
commit | 057d4db997796fa47f71c31b3bcda892c97d65c7 (patch) | |
tree | 19defcabedfd982011e14dfadb2408250bd229a3 | |
parent | Reduce scope level. (diff) | |
download | core-057d4db997796fa47f71c31b3bcda892c97d65c7.tar.gz core-057d4db997796fa47f71c31b3bcda892c97d65c7.zip |
Properly transfer layout and subtotal names before and after the dialog.
-rw-r--r-- | sc/inc/dpobject.hxx | 16 | ||||
-rw-r--r-- | sc/inc/dpsave.hxx | 1 | ||||
-rw-r--r-- | sc/inc/pivot.hxx | 10 | ||||
-rw-r--r-- | sc/source/core/data/dpobject.cxx | 48 | ||||
-rw-r--r-- | sc/source/core/data/dpsave.cxx | 11 | ||||
-rw-r--r-- | sc/source/core/data/pivot2.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/dbgui/pvlaydlg.cxx | 28 |
7 files changed, 68 insertions, 49 deletions
diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx index 121b6149a4d1..407e559fb9a2 100644 --- a/sc/inc/dpobject.hxx +++ b/sc/inc/dpobject.hxx @@ -238,13 +238,15 @@ public: static com::sun::star::uno::Reference<com::sun::star::sheet::XDimensionsSupplier> CreateSource( const ScDPServiceDesc& rDesc ); - static void ConvertOrientation( ScDPSaveData& rSaveData, - const ::std::vector<PivotField>& rFields, sal_uInt16 nOrient, - const com::sun::star::uno::Reference< - com::sun::star::sheet::XDimensionsSupplier>& xSource, - ::std::vector<PivotField>* pRefColFields = NULL, - ::std::vector<PivotField>* pRefRowFields = NULL, - ::std::vector<PivotField>* pRefPageFields = NULL ); + static void ConvertOrientation( + ScDPSaveData& rSaveData, + const ::std::vector<PivotField>& rFields, sal_uInt16 nOrient, + const com::sun::star::uno::Reference< + com::sun::star::sheet::XDimensionsSupplier>& xSource, + const ScDPLabelDataVec& rLabels, + std::vector<PivotField>* pRefColFields = NULL, + std::vector<PivotField>* pRefRowFields = NULL, + std::vector<PivotField>* pRefPageFields = NULL ); static bool IsOrientationAllowed( sal_uInt16 nOrient, sal_Int32 nDimFlags ); }; diff --git a/sc/inc/dpsave.hxx b/sc/inc/dpsave.hxx index 987f232d491b..65d04984cbac 100644 --- a/sc/inc/dpsave.hxx +++ b/sc/inc/dpsave.hxx @@ -181,6 +181,7 @@ public: void RemoveLayoutName(); void SetSubtotalName(const ::rtl::OUString& rName); const ::rtl::OUString* GetSubtotalName() const; + void RemoveSubtotalName(); bool IsMemberNameInUse(const ::rtl::OUString& rName) const; diff --git a/sc/inc/pivot.hxx b/sc/inc/pivot.hxx index c346aefcc00b..f97c47536a2b 100644 --- a/sc/inc/pivot.hxx +++ b/sc/inc/pivot.hxx @@ -128,15 +128,17 @@ struct ScDPName struct ScDPLabelData { - ::rtl::OUString maName; /// Original name of the dimension. - ::rtl::OUString maLayoutName; /// Layout name (display name) + rtl::OUString maName; /// Original name of the dimension. + rtl::OUString maLayoutName; /// Layout name (display name) + rtl::OUString maSubtotalName; SCCOL mnCol; /// 0-based field index (not the source column index) long mnOriginalDim; /// original dimension index (>= 0 for duplicated dimension) sal_uInt16 mnFuncMask; /// Page/Column/Row subtotal function. sal_Int32 mnUsedHier; /// Used hierarchy. sal_Int32 mnFlags; /// Flags from the DataPilotSource dimension - bool mbShowAll; /// true = Show all (also empty) results. - bool mbIsValue; /// true = Sum or count in data field. + bool mbShowAll:1; /// true = Show all (also empty) results. + bool mbIsValue:1; /// true = Sum or count in data field. + bool mbDataLayout:1; struct Member { diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx index bbfaa4a9affd..71db065aa2b9 100644 --- a/sc/source/core/data/dpobject.cxx +++ b/sc/source/core/data/dpobject.cxx @@ -2014,21 +2014,27 @@ bool ScDPObject::FillLabelData(ScPivotParam& rParam) OUString aLayoutName = ScUnoHelpFunctions::GetStringProperty( xDimProp, OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_LAYOUTNAME)), OUString()); - if (aFieldName.isEmpty() || bData) - continue; + OUString aSubtotalName = ScUnoHelpFunctions::GetStringProperty( + xDimProp, OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_FIELD_SUBTOTALNAME)), OUString()); bool bIsValue = true; //! check aFieldName = comphelper::string::stripEnd(aFieldName, sal_Unicode('*')); std::auto_ptr<ScDPLabelData> pNewLabel( new ScDPLabelData(aFieldName, static_cast<SCCOL>(nDim), bIsValue)); - pNewLabel->mnOriginalDim = static_cast<long>(nOrigPos); - pNewLabel->maLayoutName = aLayoutName; - GetHierarchies(nDim, pNewLabel->maHiers); - GetMembers(nDim, GetUsedHierarchy(nDim), pNewLabel->maMembers); - lcl_FillLabelData(*pNewLabel, xDimProp); - pNewLabel->mnFlags = ScUnoHelpFunctions::GetLongProperty( xDimProp, - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_FLAGS)), 0 ); + pNewLabel->mbDataLayout = bData; + + if (!bData) + { + pNewLabel->mnOriginalDim = static_cast<long>(nOrigPos); + pNewLabel->maLayoutName = aLayoutName; + pNewLabel->maSubtotalName = aSubtotalName; + GetHierarchies(nDim, pNewLabel->maHiers); + GetMembers(nDim, GetUsedHierarchy(nDim), pNewLabel->maMembers); + lcl_FillLabelData(*pNewLabel, xDimProp); + pNewLabel->mnFlags = ScUnoHelpFunctions::GetLongProperty( xDimProp, + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_FLAGS)), 0 ); + } rParam.maLabelArray.push_back(pNewLabel); } @@ -2179,6 +2185,7 @@ public: void ScDPObject::ConvertOrientation( ScDPSaveData& rSaveData, const vector<PivotField>& rFields, sal_uInt16 nOrient, const Reference<XDimensionsSupplier>& xSource, + const ScDPLabelDataVec& rLabels, vector<PivotField>* pRefColFields, vector<PivotField>* pRefRowFields, vector<PivotField>* pRefPageFields ) { // xSource must be set @@ -2232,14 +2239,15 @@ void ScDPObject::ConvertOrientation( } sheet::GeneralFunction eFunc = ScDataPilotConversion::FirstFunc(rField.nFuncMask); - ScDPSaveDimension* pCurrDim = bFirst ? pDim : rSaveData.DuplicateDimension(pDim->GetName()); - pCurrDim->SetOrientation(nOrient); - pCurrDim->SetFunction(sal::static_int_cast<sal_uInt16>(eFunc)); + if (!bFirst) + pDim = rSaveData.DuplicateDimension(pDim->GetName()); + pDim->SetOrientation(nOrient); + pDim->SetFunction(sal::static_int_cast<sal_uInt16>(eFunc)); if( rFieldRef.ReferenceType == sheet::DataPilotFieldReferenceType::NONE ) - pCurrDim->SetReferenceValue( 0 ); + pDim->SetReferenceValue(0); else - pCurrDim->SetReferenceValue( &rFieldRef ); + pDim->SetReferenceValue(&rFieldRef); } else // set SubTotals { @@ -2261,6 +2269,18 @@ void ScDPObject::ConvertOrientation( if ( nCol == PIVOT_DATA_FIELD ) pDim->SetShowEmpty( true ); } + + size_t nDimIndex = rField.nCol; + pDim->RemoveLayoutName(); + pDim->RemoveSubtotalName(); + if (nDimIndex < rLabels.size()) + { + const ScDPLabelData& rLabel = rLabels[nDimIndex]; + if (!rLabel.maLayoutName.isEmpty()) + pDim->SetLayoutName(rLabel.maLayoutName); + if (!rLabel.maSubtotalName.isEmpty()) + pDim->SetSubtotalName(rLabel.maSubtotalName); + } } } diff --git a/sc/source/core/data/dpsave.cxx b/sc/source/core/data/dpsave.cxx index 27d6c686ca23..a16732c13176 100644 --- a/sc/source/core/data/dpsave.cxx +++ b/sc/source/core/data/dpsave.cxx @@ -422,6 +422,11 @@ const OUString* ScDPSaveDimension::GetSubtotalName() const return mpSubtotalName.get(); } +void ScDPSaveDimension::RemoveSubtotalName() +{ + mpSubtotalName.reset(); +} + bool ScDPSaveDimension::IsMemberNameInUse(const OUString& rName) const { MemberList::const_iterator itr = maMemberList.begin(), itrEnd = maMemberList.end(); @@ -904,9 +909,11 @@ ScDPSaveDimension* ScDPSaveData::GetExistingDataLayoutDimension() const ScDPSaveDimension* ScDPSaveData::DuplicateDimension(const ::rtl::OUString& rName) { // always insert new - //! check if dimension is there? - ScDPSaveDimension* pOld = GetDimensionByName( rName ); + ScDPSaveDimension* pOld = GetExistingDimensionByName(rName); + if (!pOld) + return NULL; + ScDPSaveDimension* pNew = new ScDPSaveDimension( *pOld ); pNew->SetDupFlag( true ); aDimList.push_back(pNew); diff --git a/sc/source/core/data/pivot2.cxx b/sc/source/core/data/pivot2.cxx index dd65511afcbe..2e4249f9dd22 100644 --- a/sc/source/core/data/pivot2.cxx +++ b/sc/source/core/data/pivot2.cxx @@ -100,7 +100,8 @@ ScDPLabelData::ScDPLabelData(const rtl::OUString& rName, SCCOL nCol, bool bIsVal mnUsedHier( 0 ), mnFlags( 0 ), mbShowAll( false ), - mbIsValue( bIsValue ) + mbIsValue( bIsValue ), + mbDataLayout(false) { } diff --git a/sc/source/ui/dbgui/pvlaydlg.cxx b/sc/source/ui/dbgui/pvlaydlg.cxx index b91289ed8ed3..0052a448a335 100644 --- a/sc/source/ui/dbgui/pvlaydlg.cxx +++ b/sc/source/ui/dbgui/pvlaydlg.cxx @@ -357,7 +357,7 @@ void ScDPLayoutDlg::InitWndSelect(const ScDPLabelDataVec& rLabels) const ScDPLabelData& r = rLabels[i]; aLabelDataArr.push_back(new ScDPLabelData(r)); - if (r.mnOriginalDim < 0) + if (r.mnOriginalDim < 0 && !r.mbDataLayout) { // TODO: For dimension with duplicates, use layout name only when // all its duplicate dimensions use the same layout name. @@ -1452,7 +1452,7 @@ bool ScDPLayoutDlg::GetPivotArrays( for_each(aPageArr.begin(), aPageArr.end(), PivotFieldInserter(aPageFields, aPageArr.size())); vector<PivotField> aColFields; - for_each(aColArr.begin(), aColArr.end(), PivotFieldInserter(aColFields, aColArr.size())); + for_each(aColArr.begin(), aColArr.end(), PivotFieldInserter(aColFields, aColArr.size()+1)); vector<PivotField> aRowFields; for_each(aRowArr.begin(), aRowArr.end(), PivotFieldInserter(aRowFields, aRowArr.size()+1)); @@ -1827,18 +1827,19 @@ IMPL_LINK( ScDPLayoutDlg, OkHdl, OKButton *, EMPTYARG ) uno::Reference<sheet::XDimensionsSupplier> xSource = xDlgDPObject->GetSource(); ScDPObject::ConvertOrientation( - aSaveData, aPageFields, sheet::DataPilotFieldOrientation_PAGE, xSource ); + aSaveData, aPageFields, sheet::DataPilotFieldOrientation_PAGE, xSource, aLabelDataArr); ScDPObject::ConvertOrientation( - aSaveData, aColFields, sheet::DataPilotFieldOrientation_COLUMN, xSource ); + aSaveData, aColFields, sheet::DataPilotFieldOrientation_COLUMN, xSource, aLabelDataArr); ScDPObject::ConvertOrientation( - aSaveData, aRowFields, sheet::DataPilotFieldOrientation_ROW, xSource ); + aSaveData, aRowFields, sheet::DataPilotFieldOrientation_ROW, xSource, aLabelDataArr); ScDPObject::ConvertOrientation( - aSaveData, aDataFields, sheet::DataPilotFieldOrientation_DATA, xSource, + aSaveData, aDataFields, sheet::DataPilotFieldOrientation_DATA, xSource, aLabelDataArr, &aColFields, &aRowFields, &aPageFields ); for( ScDPLabelDataVec::const_iterator aIt = aLabelDataArr.begin(), aEnd = aLabelDataArr.end(); aIt != aEnd; ++aIt ) { ScDPSaveDimension* pDim = aSaveData.GetExistingDimensionByName(aIt->maName); + if (!pDim) continue; @@ -1848,21 +1849,6 @@ IMPL_LINK( ScDPLayoutDlg, OkHdl, OKButton *, EMPTYARG ) 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 ); |