Kaydet (Commit) 057d4db9 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Properly transfer layout and subtotal names before and after the dialog.

üst b6ddd700
...@@ -238,13 +238,15 @@ public: ...@@ -238,13 +238,15 @@ public:
static com::sun::star::uno::Reference<com::sun::star::sheet::XDimensionsSupplier> static com::sun::star::uno::Reference<com::sun::star::sheet::XDimensionsSupplier>
CreateSource( const ScDPServiceDesc& rDesc ); CreateSource( const ScDPServiceDesc& rDesc );
static void ConvertOrientation( ScDPSaveData& rSaveData, static void ConvertOrientation(
const ::std::vector<PivotField>& rFields, sal_uInt16 nOrient, ScDPSaveData& rSaveData,
const com::sun::star::uno::Reference< const ::std::vector<PivotField>& rFields, sal_uInt16 nOrient,
com::sun::star::sheet::XDimensionsSupplier>& xSource, const com::sun::star::uno::Reference<
::std::vector<PivotField>* pRefColFields = NULL, com::sun::star::sheet::XDimensionsSupplier>& xSource,
::std::vector<PivotField>* pRefRowFields = NULL, const ScDPLabelDataVec& rLabels,
::std::vector<PivotField>* pRefPageFields = NULL ); std::vector<PivotField>* pRefColFields = NULL,
std::vector<PivotField>* pRefRowFields = NULL,
std::vector<PivotField>* pRefPageFields = NULL );
static bool IsOrientationAllowed( sal_uInt16 nOrient, sal_Int32 nDimFlags ); static bool IsOrientationAllowed( sal_uInt16 nOrient, sal_Int32 nDimFlags );
}; };
......
...@@ -181,6 +181,7 @@ public: ...@@ -181,6 +181,7 @@ public:
void RemoveLayoutName(); void RemoveLayoutName();
void SetSubtotalName(const ::rtl::OUString& rName); void SetSubtotalName(const ::rtl::OUString& rName);
const ::rtl::OUString* GetSubtotalName() const; const ::rtl::OUString* GetSubtotalName() const;
void RemoveSubtotalName();
bool IsMemberNameInUse(const ::rtl::OUString& rName) const; bool IsMemberNameInUse(const ::rtl::OUString& rName) const;
......
...@@ -128,15 +128,17 @@ struct ScDPName ...@@ -128,15 +128,17 @@ struct ScDPName
struct ScDPLabelData struct ScDPLabelData
{ {
::rtl::OUString maName; /// Original name of the dimension. rtl::OUString maName; /// Original name of the dimension.
::rtl::OUString maLayoutName; /// Layout name (display name) rtl::OUString maLayoutName; /// Layout name (display name)
rtl::OUString maSubtotalName;
SCCOL mnCol; /// 0-based field index (not the source column index) SCCOL mnCol; /// 0-based field index (not the source column index)
long mnOriginalDim; /// original dimension index (>= 0 for duplicated dimension) long mnOriginalDim; /// original dimension index (>= 0 for duplicated dimension)
sal_uInt16 mnFuncMask; /// Page/Column/Row subtotal function. sal_uInt16 mnFuncMask; /// Page/Column/Row subtotal function.
sal_Int32 mnUsedHier; /// Used hierarchy. sal_Int32 mnUsedHier; /// Used hierarchy.
sal_Int32 mnFlags; /// Flags from the DataPilotSource dimension sal_Int32 mnFlags; /// Flags from the DataPilotSource dimension
bool mbShowAll; /// true = Show all (also empty) results. bool mbShowAll:1; /// true = Show all (also empty) results.
bool mbIsValue; /// true = Sum or count in data field. bool mbIsValue:1; /// true = Sum or count in data field.
bool mbDataLayout:1;
struct Member struct Member
{ {
......
...@@ -2014,21 +2014,27 @@ bool ScDPObject::FillLabelData(ScPivotParam& rParam) ...@@ -2014,21 +2014,27 @@ bool ScDPObject::FillLabelData(ScPivotParam& rParam)
OUString aLayoutName = ScUnoHelpFunctions::GetStringProperty( OUString aLayoutName = ScUnoHelpFunctions::GetStringProperty(
xDimProp, OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_LAYOUTNAME)), OUString()); xDimProp, OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_LAYOUTNAME)), OUString());
if (aFieldName.isEmpty() || bData) OUString aSubtotalName = ScUnoHelpFunctions::GetStringProperty(
continue; xDimProp, OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_FIELD_SUBTOTALNAME)), OUString());
bool bIsValue = true; //! check bool bIsValue = true; //! check
aFieldName = comphelper::string::stripEnd(aFieldName, sal_Unicode('*')); aFieldName = comphelper::string::stripEnd(aFieldName, sal_Unicode('*'));
std::auto_ptr<ScDPLabelData> pNewLabel( std::auto_ptr<ScDPLabelData> pNewLabel(
new ScDPLabelData(aFieldName, static_cast<SCCOL>(nDim), bIsValue)); new ScDPLabelData(aFieldName, static_cast<SCCOL>(nDim), bIsValue));
pNewLabel->mnOriginalDim = static_cast<long>(nOrigPos); pNewLabel->mbDataLayout = bData;
pNewLabel->maLayoutName = aLayoutName;
GetHierarchies(nDim, pNewLabel->maHiers); if (!bData)
GetMembers(nDim, GetUsedHierarchy(nDim), pNewLabel->maMembers); {
lcl_FillLabelData(*pNewLabel, xDimProp); pNewLabel->mnOriginalDim = static_cast<long>(nOrigPos);
pNewLabel->mnFlags = ScUnoHelpFunctions::GetLongProperty( xDimProp, pNewLabel->maLayoutName = aLayoutName;
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_FLAGS)), 0 ); 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); rParam.maLabelArray.push_back(pNewLabel);
} }
...@@ -2179,6 +2185,7 @@ public: ...@@ -2179,6 +2185,7 @@ public:
void ScDPObject::ConvertOrientation( void ScDPObject::ConvertOrientation(
ScDPSaveData& rSaveData, const vector<PivotField>& rFields, sal_uInt16 nOrient, ScDPSaveData& rSaveData, const vector<PivotField>& rFields, sal_uInt16 nOrient,
const Reference<XDimensionsSupplier>& xSource, const Reference<XDimensionsSupplier>& xSource,
const ScDPLabelDataVec& rLabels,
vector<PivotField>* pRefColFields, vector<PivotField>* pRefRowFields, vector<PivotField>* pRefPageFields ) vector<PivotField>* pRefColFields, vector<PivotField>* pRefRowFields, vector<PivotField>* pRefPageFields )
{ {
// xSource must be set // xSource must be set
...@@ -2232,14 +2239,15 @@ void ScDPObject::ConvertOrientation( ...@@ -2232,14 +2239,15 @@ void ScDPObject::ConvertOrientation(
} }
sheet::GeneralFunction eFunc = ScDataPilotConversion::FirstFunc(rField.nFuncMask); sheet::GeneralFunction eFunc = ScDataPilotConversion::FirstFunc(rField.nFuncMask);
ScDPSaveDimension* pCurrDim = bFirst ? pDim : rSaveData.DuplicateDimension(pDim->GetName()); if (!bFirst)
pCurrDim->SetOrientation(nOrient); pDim = rSaveData.DuplicateDimension(pDim->GetName());
pCurrDim->SetFunction(sal::static_int_cast<sal_uInt16>(eFunc)); pDim->SetOrientation(nOrient);
pDim->SetFunction(sal::static_int_cast<sal_uInt16>(eFunc));
if( rFieldRef.ReferenceType == sheet::DataPilotFieldReferenceType::NONE ) if( rFieldRef.ReferenceType == sheet::DataPilotFieldReferenceType::NONE )
pCurrDim->SetReferenceValue( 0 ); pDim->SetReferenceValue(0);
else else
pCurrDim->SetReferenceValue( &rFieldRef ); pDim->SetReferenceValue(&rFieldRef);
} }
else // set SubTotals else // set SubTotals
{ {
...@@ -2261,6 +2269,18 @@ void ScDPObject::ConvertOrientation( ...@@ -2261,6 +2269,18 @@ void ScDPObject::ConvertOrientation(
if ( nCol == PIVOT_DATA_FIELD ) if ( nCol == PIVOT_DATA_FIELD )
pDim->SetShowEmpty( true ); 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);
}
} }
} }
......
...@@ -422,6 +422,11 @@ const OUString* ScDPSaveDimension::GetSubtotalName() const ...@@ -422,6 +422,11 @@ const OUString* ScDPSaveDimension::GetSubtotalName() const
return mpSubtotalName.get(); return mpSubtotalName.get();
} }
void ScDPSaveDimension::RemoveSubtotalName()
{
mpSubtotalName.reset();
}
bool ScDPSaveDimension::IsMemberNameInUse(const OUString& rName) const bool ScDPSaveDimension::IsMemberNameInUse(const OUString& rName) const
{ {
MemberList::const_iterator itr = maMemberList.begin(), itrEnd = maMemberList.end(); MemberList::const_iterator itr = maMemberList.begin(), itrEnd = maMemberList.end();
...@@ -904,9 +909,11 @@ ScDPSaveDimension* ScDPSaveData::GetExistingDataLayoutDimension() const ...@@ -904,9 +909,11 @@ ScDPSaveDimension* ScDPSaveData::GetExistingDataLayoutDimension() const
ScDPSaveDimension* ScDPSaveData::DuplicateDimension(const ::rtl::OUString& rName) ScDPSaveDimension* ScDPSaveData::DuplicateDimension(const ::rtl::OUString& rName)
{ {
// always insert new // 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 ); ScDPSaveDimension* pNew = new ScDPSaveDimension( *pOld );
pNew->SetDupFlag( true ); pNew->SetDupFlag( true );
aDimList.push_back(pNew); aDimList.push_back(pNew);
......
...@@ -100,7 +100,8 @@ ScDPLabelData::ScDPLabelData(const rtl::OUString& rName, SCCOL nCol, bool bIsVal ...@@ -100,7 +100,8 @@ ScDPLabelData::ScDPLabelData(const rtl::OUString& rName, SCCOL nCol, bool bIsVal
mnUsedHier( 0 ), mnUsedHier( 0 ),
mnFlags( 0 ), mnFlags( 0 ),
mbShowAll( false ), mbShowAll( false ),
mbIsValue( bIsValue ) mbIsValue( bIsValue ),
mbDataLayout(false)
{ {
} }
......
...@@ -357,7 +357,7 @@ void ScDPLayoutDlg::InitWndSelect(const ScDPLabelDataVec& rLabels) ...@@ -357,7 +357,7 @@ void ScDPLayoutDlg::InitWndSelect(const ScDPLabelDataVec& rLabels)
const ScDPLabelData& r = rLabels[i]; const ScDPLabelData& r = rLabels[i];
aLabelDataArr.push_back(new ScDPLabelData(r)); 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 // TODO: For dimension with duplicates, use layout name only when
// all its duplicate dimensions use the same layout name. // all its duplicate dimensions use the same layout name.
...@@ -1452,7 +1452,7 @@ bool ScDPLayoutDlg::GetPivotArrays( ...@@ -1452,7 +1452,7 @@ bool ScDPLayoutDlg::GetPivotArrays(
for_each(aPageArr.begin(), aPageArr.end(), PivotFieldInserter(aPageFields, aPageArr.size())); for_each(aPageArr.begin(), aPageArr.end(), PivotFieldInserter(aPageFields, aPageArr.size()));
vector<PivotField> aColFields; 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; vector<PivotField> aRowFields;
for_each(aRowArr.begin(), aRowArr.end(), PivotFieldInserter(aRowFields, aRowArr.size()+1)); for_each(aRowArr.begin(), aRowArr.end(), PivotFieldInserter(aRowFields, aRowArr.size()+1));
...@@ -1827,18 +1827,19 @@ IMPL_LINK( ScDPLayoutDlg, OkHdl, OKButton *, EMPTYARG ) ...@@ -1827,18 +1827,19 @@ IMPL_LINK( ScDPLayoutDlg, OkHdl, OKButton *, EMPTYARG )
uno::Reference<sheet::XDimensionsSupplier> xSource = xDlgDPObject->GetSource(); uno::Reference<sheet::XDimensionsSupplier> xSource = xDlgDPObject->GetSource();
ScDPObject::ConvertOrientation( ScDPObject::ConvertOrientation(
aSaveData, aPageFields, sheet::DataPilotFieldOrientation_PAGE, xSource ); aSaveData, aPageFields, sheet::DataPilotFieldOrientation_PAGE, xSource, aLabelDataArr);
ScDPObject::ConvertOrientation( ScDPObject::ConvertOrientation(
aSaveData, aColFields, sheet::DataPilotFieldOrientation_COLUMN, xSource ); aSaveData, aColFields, sheet::DataPilotFieldOrientation_COLUMN, xSource, aLabelDataArr);
ScDPObject::ConvertOrientation( ScDPObject::ConvertOrientation(
aSaveData, aRowFields, sheet::DataPilotFieldOrientation_ROW, xSource ); aSaveData, aRowFields, sheet::DataPilotFieldOrientation_ROW, xSource, aLabelDataArr);
ScDPObject::ConvertOrientation( ScDPObject::ConvertOrientation(
aSaveData, aDataFields, sheet::DataPilotFieldOrientation_DATA, xSource, aSaveData, aDataFields, sheet::DataPilotFieldOrientation_DATA, xSource, aLabelDataArr,
&aColFields, &aRowFields, &aPageFields ); &aColFields, &aRowFields, &aPageFields );
for( ScDPLabelDataVec::const_iterator aIt = aLabelDataArr.begin(), aEnd = aLabelDataArr.end(); aIt != aEnd; ++aIt ) for( ScDPLabelDataVec::const_iterator aIt = aLabelDataArr.begin(), aEnd = aLabelDataArr.end(); aIt != aEnd; ++aIt )
{ {
ScDPSaveDimension* pDim = aSaveData.GetExistingDimensionByName(aIt->maName); ScDPSaveDimension* pDim = aSaveData.GetExistingDimensionByName(aIt->maName);
if (!pDim) if (!pDim)
continue; continue;
...@@ -1848,21 +1849,6 @@ IMPL_LINK( ScDPLayoutDlg, OkHdl, OKButton *, EMPTYARG ) ...@@ -1848,21 +1849,6 @@ IMPL_LINK( ScDPLayoutDlg, OkHdl, OKButton *, EMPTYARG )
pDim->SetLayoutInfo( &aIt->maLayoutInfo ); pDim->SetLayoutInfo( &aIt->maLayoutInfo );
pDim->SetAutoShowInfo( &aIt->maShowInfo ); pDim->SetAutoShowInfo( &aIt->maShowInfo );
ScDPSaveDimension* pOldDim = NULL; 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 ); bool bManualSort = ( aIt->maSortInfo.Mode == sheet::DataPilotFieldSortMode::MANUAL );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment