[Libreoffice-commits] .: 20 commits - sc/inc sc/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Wed Feb 22 11:03:12 PST 2012
sc/inc/dpobject.hxx | 16
sc/inc/dpsave.hxx | 11
sc/inc/dptabsrc.hxx | 18
sc/inc/pivot.hxx | 61 -
sc/inc/scabstdlg.hxx | 2
sc/inc/unonames.hxx | 1
sc/source/core/data/dpobject.cxx | 338 +++++----
sc/source/core/data/dpsave.cxx | 28
sc/source/core/data/dptabsrc.cxx | 26
sc/source/core/data/pivot2.cxx | 76 +-
sc/source/ui/Accessibility/AccessibleDataPilotControl.cxx | 8
sc/source/ui/attrdlg/scdlgfact.cxx | 2
sc/source/ui/attrdlg/scdlgfact.hxx | 2
sc/source/ui/dbgui/fieldwnd.cxx | 137 +++
sc/source/ui/dbgui/pvfundlg.cxx | 2
sc/source/ui/dbgui/pvlaydlg.cxx | 488 +++++++-------
sc/source/ui/inc/AccessibleDataPilotControl.hxx | 1
sc/source/ui/inc/dbfunc.hxx | 2
sc/source/ui/inc/fieldwnd.hxx | 28
sc/source/ui/inc/pvfundlg.hxx | 4
sc/source/ui/inc/pvlaydlg.hxx | 29
sc/source/ui/view/dbfunc3.cxx | 36 -
sc/source/ui/view/gridwin2.cxx | 4
23 files changed, 752 insertions(+), 568 deletions(-)
New commits:
commit 13ff8cf43fb003d4d54cecf6b11cc055339bb22b
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Feb 17 23:59:23 2012 -0500
No sense making a copy when you don't modify it.
diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx
index 5284c7e..abfe1fb 100644
--- a/sc/source/ui/view/dbfunc3.cxx
+++ b/sc/source/ui/view/dbfunc3.cxx
@@ -1419,8 +1419,6 @@ void ScDBFunc::DataPilotInput( const ScAddress& rPos, const rtl::OUString& rStri
{
using namespace ::com::sun::star::sheet;
- const rtl::OUString& aNewName = rString;
-
ScDocument* pDoc = GetViewData()->GetDocument();
ScDPObject* pDPObj = pDoc->GetDPAtCursor( rPos.Col(), rPos.Row(), rPos.Tab() );
if (!pDPObj)
@@ -1457,11 +1455,11 @@ void ScDBFunc::DataPilotInput( const ScAddress& rPos, const rtl::OUString& rStri
// valid name: not empty, no existing dimension (group or other)
if (!rString.isEmpty() && !pDPObj->IsDimNameInUse(rString))
{
- pGroupDim->Rename( aNewName );
+ pGroupDim->Rename( rString );
// also rename in SaveData to preserve the field settings
ScDPSaveDimension* pSaveDim = aData.GetDimensionByName( aOldText );
- pSaveDim->SetName( aNewName );
+ pSaveDim->SetName( rString );
bChange = sal_True;
}
@@ -1540,15 +1538,15 @@ void ScDBFunc::DataPilotInput( const ScAddress& rPos, const rtl::OUString& rStri
{
// valid name: not empty, no existing group in this dimension
//! ignore case?
- if (!aNewName.isEmpty() && !pGroupDim->GetNamedGroup(aNewName))
+ if (!rString.isEmpty() && !pGroupDim->GetNamedGroup(rString))
{
ScDPSaveGroupItem* pGroup = pGroupDim->GetNamedGroupAcc( aOldText );
if ( pGroup )
- pGroup->Rename( aNewName ); // rename the existing group
+ pGroup->Rename( rString ); // rename the existing group
else
{
// create a new group to replace the automatic group
- ScDPSaveGroupItem aGroup( aNewName );
+ ScDPSaveGroupItem aGroup( rString );
aGroup.AddElement( aOldText );
pGroupDim->AddGroupItem( aGroup );
}
@@ -1557,7 +1555,7 @@ void ScDBFunc::DataPilotInput( const ScAddress& rPos, const rtl::OUString& rStri
ScDPSaveDimension* pSaveDim = aData.GetDimensionByName( aDimName );
ScDPSaveMember* pSaveMember = pSaveDim->GetExistingMemberByName( aOldText );
if ( pSaveMember )
- pSaveMember->SetName( aNewName );
+ pSaveMember->SetName( rString );
bChange = true;
}
commit 58c292df96e4813359ac2d9150132d0da14cbfce
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Feb 17 23:58:02 2012 -0500
More string and bool conversion.
diff --git a/sc/source/ui/inc/dbfunc.hxx b/sc/source/ui/inc/dbfunc.hxx
index 9f201e3..284ebf2 100644
--- a/sc/source/ui/inc/dbfunc.hxx
+++ b/sc/source/ui/inc/dbfunc.hxx
@@ -95,7 +95,7 @@ public:
void DateGroupDataPilot( const ScDPNumGroupInfo& rInfo, sal_Int32 nParts );
void NumGroupDataPilot( const ScDPNumGroupInfo& rInfo );
void UngroupDataPilot();
- void DataPilotInput( const ScAddress& rPos, const String& rString );
+ void DataPilotInput( const ScAddress& rPos, const rtl::OUString& rString );
bool DataPilotSort( const ScAddress& rPos, bool bAscending, sal_uInt16* pUserListId = NULL );
sal_Bool DataPilotMove( const ScRange& rSource, const ScAddress& rDest );
diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx
index ef66672..5284c7e 100644
--- a/sc/source/ui/view/dbfunc3.cxx
+++ b/sc/source/ui/view/dbfunc3.cxx
@@ -1415,18 +1415,18 @@ static OUString lcl_replaceMemberNameInSubtotal(const OUString& rSubtotal, const
return aBuf.makeStringAndClear();
}
-void ScDBFunc::DataPilotInput( const ScAddress& rPos, const String& rString )
+void ScDBFunc::DataPilotInput( const ScAddress& rPos, const rtl::OUString& rString )
{
using namespace ::com::sun::star::sheet;
- String aNewName( rString );
+ const rtl::OUString& aNewName = rString;
ScDocument* pDoc = GetViewData()->GetDocument();
ScDPObject* pDPObj = pDoc->GetDPAtCursor( rPos.Col(), rPos.Row(), rPos.Tab() );
if (!pDPObj)
return;
- String aOldText;
+ rtl::OUString aOldText;
pDoc->GetString( rPos.Col(), rPos.Row(), rPos.Tab(), aOldText );
if ( aOldText == rString )
@@ -1455,7 +1455,7 @@ void ScDBFunc::DataPilotInput( const ScAddress& rPos, const String& rString )
if ( pGroupDim )
{
// valid name: not empty, no existing dimension (group or other)
- if ( rString.Len() && !pDPObj->IsDimNameInUse(rString) )
+ if (!rString.isEmpty() && !pDPObj->IsDimNameInUse(rString))
{
pGroupDim->Rename( aNewName );
@@ -1476,9 +1476,9 @@ void ScDBFunc::DataPilotInput( const ScAddress& rPos, const String& rString )
ScDPSaveDimension* pDim = bDataLayout ? aData.GetDataLayoutDimension() : aData.GetDimensionByName(aDimName);
if (pDim)
{
- if (rString.Len())
+ if (!rString.isEmpty())
{
- if (rString.EqualsIgnoreCaseAscii(String(aDimName)))
+ if (rString.equalsIgnoreAsciiCase(aDimName))
{
pDim->RemoveLayoutName();
bChange = true;
@@ -1502,7 +1502,7 @@ void ScDBFunc::DataPilotInput( const ScAddress& rPos, const String& rString )
ScDPSaveDimension* pDim = aData.GetFirstDimension(sheet::DataPilotFieldOrientation_DATA);
if (pDim)
{
- if (rString.Len())
+ if (!rString.isEmpty())
{
if (pDim->GetName().equalsIgnoreAsciiCase(rString))
{
@@ -1527,7 +1527,7 @@ void ScDBFunc::DataPilotInput( const ScAddress& rPos, const String& rString )
sheet::DataPilotTableHeaderData aPosData;
pDPObj->GetHeaderPositionData(rPos, aPosData);
- if ( (aPosData.Flags & MemberResultFlags::HASMEMBER) && aOldText.Len() )
+ if ((aPosData.Flags & MemberResultFlags::HASMEMBER) && !aOldText.isEmpty())
{
if ( aData.GetExistingDimensionData() && !(aPosData.Flags & MemberResultFlags::SUBTOTAL))
{
@@ -1540,7 +1540,7 @@ void ScDBFunc::DataPilotInput( const ScAddress& rPos, const String& rString )
{
// valid name: not empty, no existing group in this dimension
//! ignore case?
- if ( aNewName.Len() && !pGroupDim->GetNamedGroup( aNewName ) )
+ if (!aNewName.isEmpty() && !pGroupDim->GetNamedGroup(aNewName))
{
ScDPSaveGroupItem* pGroup = pGroupDim->GetNamedGroupAcc( aOldText );
if ( pGroup )
@@ -1559,7 +1559,7 @@ void ScDBFunc::DataPilotInput( const ScAddress& rPos, const String& rString )
if ( pSaveMember )
pSaveMember->SetName( aNewName );
- bChange = sal_True;
+ bChange = true;
}
else
nErrorId = STR_INVALIDNAME;
@@ -1586,7 +1586,7 @@ void ScDBFunc::DataPilotInput( const ScAddress& rPos, const String& rString )
if (!pDim)
break;
- if (!rString.Len())
+ if (rString.isEmpty())
{
nErrorId = STR_INVALIDNAME;
break;
@@ -1648,9 +1648,9 @@ void ScDBFunc::DataPilotInput( const ScAddress& rPos, const String& rString )
{
// Check to make sure the member name isn't
// already used.
- if (rString.Len())
+ if (!rString.isEmpty())
{
- if (::rtl::OUString(rString).equalsIgnoreAsciiCase(pMem->GetName()))
+ if (rString.equalsIgnoreAsciiCase(pMem->GetName()))
{
pMem->RemoveLayoutName();
bChange = true;
commit 057d4db997796fa47f71c31b3bcda892c97d65c7
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Feb 17 23:37:45 2012 -0500
Properly transfer layout and subtotal names before and after the dialog.
diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx
index 121b614..407e559 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 987f232..65d0498 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 c346aef..f97c475 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 bbfaa4a..71db065 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 27d6c68..a16732c 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 dd65511..2e4249f 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 b91289e..0052a44 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 );
commit b6ddd7008b4a7331d6dd1d7fdfcc342c41fbd06a
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Feb 17 21:58:22 2012 -0500
Reduce scope level.
diff --git a/sc/source/ui/dbgui/pvlaydlg.cxx b/sc/source/ui/dbgui/pvlaydlg.cxx
index 675eb0a..b91289e 100644
--- a/sc/source/ui/dbgui/pvlaydlg.cxx
+++ b/sc/source/ui/dbgui/pvlaydlg.cxx
@@ -1838,56 +1838,58 @@ IMPL_LINK( ScDPLayoutDlg, OkHdl, OKButton *, EMPTYARG )
for( ScDPLabelDataVec::const_iterator aIt = aLabelDataArr.begin(), aEnd = aLabelDataArr.end(); aIt != aEnd; ++aIt )
{
- if( ScDPSaveDimension* pDim = aSaveData.GetExistingDimensionByName( aIt->maName ) )
+ ScDPSaveDimension* pDim = aSaveData.GetExistingDimensionByName(aIt->maName);
+ if (!pDim)
+ continue;
+
+ pDim->SetUsedHierarchy( aIt->mnUsedHier );
+ pDim->SetShowEmpty( aIt->mbShowAll );
+ pDim->SetSortInfo( &aIt->maSortInfo );
+ pDim->SetLayoutInfo( &aIt->maLayoutInfo );
+ pDim->SetAutoShowInfo( &aIt->maShowInfo );
+ ScDPSaveDimension* pOldDim = NULL;
+ if (pOldSaveData)
{
- pDim->SetUsedHierarchy( aIt->mnUsedHier );
- pDim->SetShowEmpty( aIt->mbShowAll );
- 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)
{
- // 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* pLayoutName = pOldDim->GetLayoutName();
+ if (pLayoutName)
+ pDim->SetLayoutName(*pLayoutName);
- const OUString* pSubtotalName = pOldDim->GetSubtotalName();
- if (pSubtotalName)
- pDim->SetSubtotalName(*pSubtotalName);
- }
+ 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 );
+ // visibility of members
+ for (vector<ScDPLabelData::Member>::const_iterator itr = aIt->maMembers.begin(), itrEnd = aIt->maMembers.end();
+ itr != itrEnd; ++itr)
+ {
+ ScDPSaveMember* pMember = pDim->GetMemberByName(itr->maName);
- // visibility of members
- for (vector<ScDPLabelData::Member>::const_iterator itr = aIt->maMembers.begin(), itrEnd = aIt->maMembers.end();
- itr != itrEnd; ++itr)
+ // #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)
{
- ScDPSaveMember* pMember = pDim->GetMemberByName(itr->maName);
+ pMember->SetIsVisible(itr->mbVisible);
+ pMember->SetShowDetails(itr->mbShowDetails);
+ }
- // #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)
- {
- // Transfer the existing layout name.
- ScDPSaveMember* pOldMember = pOldDim->GetMemberByName(itr->maName);
- if (pOldMember)
- {
- const OUString* pLayoutName = pOldMember->GetLayoutName();
- if (pLayoutName)
- pMember->SetLayoutName(*pLayoutName);
- }
- }
+ if (!pOldDim)
+ continue;
+
+ // Transfer the existing layout name.
+ ScDPSaveMember* pOldMember = pOldDim->GetMemberByName(itr->maName);
+ if (pOldMember)
+ {
+ const OUString* pLayoutName = pOldMember->GetLayoutName();
+ if (pLayoutName)
+ pMember->SetLayoutName(*pLayoutName);
}
}
}
commit 518c1fd9a65b0b5567f54b481223d260b4befbb3
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Feb 17 21:43:37 2012 -0500
Correctly generate data field dimensions when pressing OK.
diff --git a/sc/inc/pivot.hxx b/sc/inc/pivot.hxx
index a73c431..c346aef 100644
--- a/sc/inc/pivot.hxx
+++ b/sc/inc/pivot.hxx
@@ -74,7 +74,7 @@ struct ScDPLabelData;
struct PivotField
{
SCCOL nCol; /// 0-based dimension index (not source column index)
- long mnOriginalDim;
+ long mnOriginalDim; /// >= 0 for duplicated field.
sal_uInt16 nFuncMask;
sal_uInt8 mnDupCount;
::com::sun::star::sheet::DataPilotFieldReference maFieldRef;
@@ -82,6 +82,7 @@ struct PivotField
explicit PivotField( SCCOL nNewCol = 0, sal_uInt16 nNewFuncMask = PIVOT_FUNC_NONE );
PivotField( const PivotField& r );
+ long getOriginalDim() const;
bool operator==( const PivotField& r ) const;
};
@@ -187,13 +188,14 @@ struct ScPivotField
struct ScDPFuncData
{
SCCOL mnCol;
+ long mnOriginalDim;
sal_uInt16 mnFuncMask;
sal_uInt8 mnDupCount;
::com::sun::star::sheet::DataPilotFieldReference maFieldRef;
explicit ScDPFuncData( SCCOL nNewCol, sal_uInt16 nNewFuncMask );
explicit ScDPFuncData(
- SCCOL nNewCol, sal_uInt16 nNewFuncMask, sal_uInt8 nDupCount,
+ SCCOL nNewCol, long nOriginalDim, sal_uInt16 nNewFuncMask, sal_uInt8 nDupCount,
const ::com::sun::star::sheet::DataPilotFieldReference& rFieldRef );
bool operator== (const ScDPFuncData& r) const;
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 9ee479e..bbfaa4a 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -2163,6 +2163,17 @@ bool hasFieldColumn(const vector<PivotField>* pRefFields, SCCOL nCol)
return false;
}
+class FindByOriginalDim : public std::unary_function<PivotField, bool>
+{
+ long mnDim;
+public:
+ FindByOriginalDim(long nDim) : mnDim(nDim) {}
+ bool operator() (const PivotField& r) const
+ {
+ return mnDim == r.getOriginalDim();
+ }
+};
+
}
void ScDPObject::ConvertOrientation(
@@ -2178,7 +2189,7 @@ void ScDPObject::ConvertOrientation(
{
const PivotField& rField = *itr;
- SCCOL nCol = rField.nCol;
+ long nCol = rField.getOriginalDim();
sal_uInt16 nFuncs = rField.nFuncMask;
const sheet::DataPilotFieldReference& rFieldRef = rField.maFieldRef;
@@ -2187,8 +2198,8 @@ void ScDPObject::ConvertOrientation(
pDim = rSaveData.GetDataLayoutDimension();
else
{
- String aDocStr = lcl_GetDimName( xSource, nCol ); // cols must start at 0
- if ( aDocStr.Len() )
+ rtl::OUString aDocStr = lcl_GetDimName( xSource, nCol ); // cols must start at 0
+ if (!aDocStr.isEmpty())
pDim = rSaveData.GetDimensionByName(aDocStr);
else
pDim = NULL;
@@ -2217,35 +2228,18 @@ void ScDPObject::ConvertOrientation(
{
// if set via api, a data column may occur several times
// (if the function hasn't been changed yet) -> also look for duplicate data column
- for (vector<PivotField>::const_iterator itr2 = itrBeg; itr2 != itr; ++itr2)
- {
- if (itr2->nCol == nCol)
- {
- bFirst = false;
- break;
- }
- }
+ bFirst = std::find_if(itrBeg, itr, FindByOriginalDim(nCol)) == itr;
}
- sal_uInt16 nMask = 1;
- for (sal_uInt16 nBit=0; nBit<16; nBit++)
- {
- if ( nFuncs & nMask )
- {
- sheet::GeneralFunction eFunc = ScDataPilotConversion::FirstFunc( nMask );
- ScDPSaveDimension* pCurrDim = bFirst ? pDim : rSaveData.DuplicateDimension(pDim->GetName());
- pCurrDim->SetOrientation( nOrient );
- pCurrDim->SetFunction( sal::static_int_cast<sal_uInt16>(eFunc) );
+ 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( rFieldRef.ReferenceType == sheet::DataPilotFieldReferenceType::NONE )
- pCurrDim->SetReferenceValue( 0 );
- else
- pCurrDim->SetReferenceValue( &rFieldRef );
-
- bFirst = false;
- }
- nMask *= 2;
- }
+ if( rFieldRef.ReferenceType == sheet::DataPilotFieldReferenceType::NONE )
+ pCurrDim->SetReferenceValue( 0 );
+ else
+ pCurrDim->SetReferenceValue( &rFieldRef );
}
else // set SubTotals
{
diff --git a/sc/source/core/data/pivot2.cxx b/sc/source/core/data/pivot2.cxx
index 685589e..dd65511 100644
--- a/sc/source/core/data/pivot2.cxx
+++ b/sc/source/core/data/pivot2.cxx
@@ -127,6 +127,11 @@ PivotField::PivotField( const PivotField& r ) :
mnDupCount(r.mnDupCount),
maFieldRef(r.maFieldRef) {}
+long PivotField::getOriginalDim() const
+{
+ return mnOriginalDim >= 0 ? mnOriginalDim : static_cast<long>(nCol);
+}
+
bool PivotField::operator==( const PivotField& r ) const
{
return (nCol == r.nCol)
@@ -211,14 +216,17 @@ bool ScPivotParam::operator==( const ScPivotParam& r ) const
ScDPFuncData::ScDPFuncData( SCCOL nCol, sal_uInt16 nFuncMask ) :
mnCol( nCol ),
+ mnOriginalDim(-1),
mnFuncMask( nFuncMask ),
mnDupCount(0)
{
}
ScDPFuncData::ScDPFuncData(
- SCCOL nCol, sal_uInt16 nFuncMask, sal_uInt8 nDupCount, const DataPilotFieldReference& rFieldRef ) :
+ SCCOL nCol, long nOriginalDim, sal_uInt16 nFuncMask, sal_uInt8 nDupCount,
+ const DataPilotFieldReference& rFieldRef) :
mnCol( nCol ),
+ mnOriginalDim(nOriginalDim),
mnFuncMask( nFuncMask ),
mnDupCount(nDupCount),
maFieldRef( rFieldRef )
@@ -227,7 +235,7 @@ ScDPFuncData::ScDPFuncData(
bool ScDPFuncData::operator== (const ScDPFuncData& r) const
{
- if (mnCol != r.mnCol || mnFuncMask != r.mnFuncMask || mnDupCount != r.mnDupCount)
+ if (mnCol != r.mnCol || mnOriginalDim != r.mnOriginalDim || mnFuncMask != r.mnFuncMask || mnDupCount != r.mnDupCount)
return false;
return equals(maFieldRef, r.maFieldRef);
diff --git a/sc/source/ui/dbgui/pvlaydlg.cxx b/sc/source/ui/dbgui/pvlaydlg.cxx
index c16c86e..675eb0a 100644
--- a/sc/source/ui/dbgui/pvlaydlg.cxx
+++ b/sc/source/ui/dbgui/pvlaydlg.cxx
@@ -382,7 +382,7 @@ void ScDPLayoutDlg::InitWndData(const vector<PivotField>& rFields)
size_t nFieldIndex = aDataArr.size();
aDataArr.push_back(
- new ScDPFuncData(nCol, nMask, it->mnDupCount, it->maFieldRef));
+ new ScDPFuncData(nCol, it->mnOriginalDim, nMask, it->mnDupCount, it->maFieldRef));
// data field - we need to concatenate function name with the field name.
ScDPLabelData* pData = GetLabelData(nCol);
@@ -422,7 +422,8 @@ void ScDPLayoutDlg::InitFieldWindow( const vector<PivotField>& rFields, ScDPFiel
continue;
size_t nFieldIndex = pInitArr->size();
- pInitArr->push_back(new ScDPFuncData(nCol, nMask, itr->mnDupCount, itr->maFieldRef));
+ pInitArr->push_back(
+ new ScDPFuncData(nCol, itr->mnOriginalDim, nMask, itr->mnDupCount, itr->maFieldRef));
pInitWnd->AddField(GetLabelString(nCol), nFieldIndex);
}
pInitWnd->ResetScrollBar();
@@ -1433,6 +1434,8 @@ public:
{
PivotField aField;
aField.nCol = r.mnCol;
+ aField.mnOriginalDim = r.mnOriginalDim;
+ aField.mnDupCount = r.mnDupCount;
aField.nFuncMask = r.mnFuncMask;
aField.maFieldRef = r.maFieldRef;
mrFields.push_back(aField);
commit f401f8ac518323e08d77507022b9c8a0703f9b14
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Feb 17 18:02:08 2012 -0500
Correctly display layout name of data fields.
diff --git a/sc/inc/pivot.hxx b/sc/inc/pivot.hxx
index 2ab0464..a73c431 100644
--- a/sc/inc/pivot.hxx
+++ b/sc/inc/pivot.hxx
@@ -73,12 +73,13 @@ struct ScDPLabelData;
struct PivotField
{
- SCsCOL nCol; /// 0-based dimension index (not source column index)
+ SCCOL nCol; /// 0-based dimension index (not source column index)
+ long mnOriginalDim;
sal_uInt16 nFuncMask;
sal_uInt8 mnDupCount;
::com::sun::star::sheet::DataPilotFieldReference maFieldRef;
- explicit PivotField( SCsCOL nNewCol = 0, sal_uInt16 nNewFuncMask = PIVOT_FUNC_NONE );
+ explicit PivotField( SCCOL nNewCol = 0, sal_uInt16 nNewFuncMask = PIVOT_FUNC_NONE );
PivotField( const PivotField& r );
bool operator==( const PivotField& r ) const;
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index f9862fb..9ee479e 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -1790,25 +1790,19 @@ void lcl_FillOldFields(
xDimProp, OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_ISDATALAYOUT)));
// is this dimension cloned?
- uno::Any aOrigAny;
+ long nDupSource = -1;
try
{
- aOrigAny = xDimProp->getPropertyValue(
- OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_ORIGINAL)));
+ uno::Any aOrigAny = xDimProp->getPropertyValue(
+ OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_ORIGINAL_POS)));
+ sal_Int32 nTmp;
+ if (aOrigAny >>= nTmp)
+ nDupSource = static_cast<sal_Int32>(nTmp);
}
catch(uno::Exception&)
{
}
- long nDupSource = -1;
- uno::Reference<uno::XInterface> xIntOrig = ScUnoHelpFunctions::AnyToInterface( aOrigAny );
- if ( xIntOrig.is() )
- {
- uno::Reference<container::XNamed> xNameOrig( xIntOrig, uno::UNO_QUERY );
- if ( xNameOrig.is() )
- nDupSource = lcl_FindName( xNameOrig->getName(), xDimsName );
- }
-
sal_uInt8 nDupCount = 0;
if (nDupSource >= 0)
{
@@ -1832,10 +1826,11 @@ void lcl_FillOldFields(
rField.nCol = PIVOT_DATA_FIELD;
bDataFound = true;
}
- else if (nDupSource >= 0)
- rField.nCol = static_cast<SCsCOL>(nDupSource); //! seek from name
else
- rField.nCol = static_cast<SCsCOL>(nDim); //! seek source column from name
+ {
+ rField.mnOriginalDim = nDupSource;
+ rField.nCol = static_cast<SCCOL>(nDim); //! seek source column from name
+ }
rField.nFuncMask = nMask;
rField.mnDupCount = nDupCount;
@@ -2023,6 +2018,7 @@ bool ScDPObject::FillLabelData(ScPivotParam& rParam)
continue;
bool bIsValue = true; //! check
+ aFieldName = comphelper::string::stripEnd(aFieldName, sal_Unicode('*'));
std::auto_ptr<ScDPLabelData> pNewLabel(
new ScDPLabelData(aFieldName, static_cast<SCCOL>(nDim), bIsValue));
diff --git a/sc/source/core/data/pivot2.cxx b/sc/source/core/data/pivot2.cxx
index 9679524..685589e 100644
--- a/sc/source/core/data/pivot2.cxx
+++ b/sc/source/core/data/pivot2.cxx
@@ -112,8 +112,9 @@ OUString ScDPLabelData::getDisplayName() const
return maName;
}
-PivotField::PivotField( SCsCOL nNewCol, sal_uInt16 nNewFuncMask ) :
+PivotField::PivotField(SCCOL nNewCol, sal_uInt16 nNewFuncMask) :
nCol( nNewCol ),
+ mnOriginalDim(-1),
nFuncMask( nNewFuncMask ),
mnDupCount(0)
{
@@ -121,14 +122,16 @@ PivotField::PivotField( SCsCOL nNewCol, sal_uInt16 nNewFuncMask ) :
PivotField::PivotField( const PivotField& r ) :
nCol(r.nCol),
+ mnOriginalDim(r.mnOriginalDim),
nFuncMask(r.nFuncMask),
mnDupCount(r.mnDupCount),
maFieldRef(r.maFieldRef) {}
bool PivotField::operator==( const PivotField& r ) const
{
- return (nCol == r.nCol)
- && (nFuncMask == r.nFuncMask)
+ return (nCol == r.nCol)
+ && (mnOriginalDim == r.mnOriginalDim)
+ && (nFuncMask == r.nFuncMask)
&& equals(maFieldRef, r.maFieldRef);
}
diff --git a/sc/source/ui/dbgui/pvlaydlg.cxx b/sc/source/ui/dbgui/pvlaydlg.cxx
index 0e69a20..c16c86e 100644
--- a/sc/source/ui/dbgui/pvlaydlg.cxx
+++ b/sc/source/ui/dbgui/pvlaydlg.cxx
@@ -356,16 +356,15 @@ void ScDPLayoutDlg::InitWndSelect(const ScDPLabelDataVec& rLabels)
{
const ScDPLabelData& r = rLabels[i];
- if (r.mnOriginalDim >= 0)
- // Don't add duplicate dimensions.
- continue;
-
- // TODO: For dimension with duplicates, use layout name only when all
- // its duplicate dimensions use the same layout name. Otherwise use
- // the original name.
aLabelDataArr.push_back(new ScDPLabelData(r));
- aWndSelect.AddField(aLabelDataArr[i].getDisplayName(), i);
- aSelectArr.push_back(new ScDPFuncData(aLabelDataArr[i].mnCol, aLabelDataArr[i].mnFuncMask));
+ if (r.mnOriginalDim < 0)
+ {
+ // TODO: For dimension with duplicates, use layout name only when
+ // all its duplicate dimensions use the same layout name.
+ // Otherwise use the original name.
+ aWndSelect.AddField(aLabelDataArr[i].getDisplayName(), i);
+ aSelectArr.push_back(new ScDPFuncData(aLabelDataArr[i].mnCol, aLabelDataArr[i].mnFuncMask));
+ }
}
aWndSelect.ResetScrollBar();
aWndSelect.Paint(Rectangle());
@@ -414,7 +413,7 @@ void ScDPLayoutDlg::InitFieldWindow( const vector<PivotField>& rFields, ScDPFiel
if (!pInitArr || !pInitWnd)
return;
- vector<PivotField>::const_iterator it = rFields.begin(), itrEnd = rFields.end();
+ vector<PivotField>::const_iterator itr = rFields.begin(), itrEnd = rFields.end();
for (; itr != itrEnd; ++itr)
{
SCCOL nCol = itr->nCol;
commit f57bd35e915aa5d000aed2b5c4c00f1c9491e551
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Feb 17 17:35:19 2012 -0500
Separate initialization of data field buttons.
diff --git a/sc/source/ui/dbgui/pvlaydlg.cxx b/sc/source/ui/dbgui/pvlaydlg.cxx
index 0439ff2..0e69a20 100644
--- a/sc/source/ui/dbgui/pvlaydlg.cxx
+++ b/sc/source/ui/dbgui/pvlaydlg.cxx
@@ -371,17 +371,50 @@ void ScDPLayoutDlg::InitWndSelect(const ScDPLabelDataVec& rLabels)
aWndSelect.Paint(Rectangle());
}
-//----------------------------------------------------------------------------
+void ScDPLayoutDlg::InitWndData(const vector<PivotField>& rFields)
+{
+ vector<PivotField>::const_iterator it = rFields.begin(), itEnd = rFields.end();
+ for (; it != itEnd; ++it)
+ {
+ SCCOL nCol = it->nCol;
+ sal_uInt16 nMask = it->nFuncMask;
+ if (nCol == PIVOT_DATA_FIELD)
+ continue;
+
+ size_t nFieldIndex = aDataArr.size();
+ aDataArr.push_back(
+ new ScDPFuncData(nCol, nMask, it->mnDupCount, it->maFieldRef));
+
+ // data field - we need to concatenate function name with the field name.
+ ScDPLabelData* pData = GetLabelData(nCol);
+ OSL_ENSURE( pData, "ScDPLabelData not found" );
+ if (pData)
+ {
+ OUString aStr = pData->maLayoutName;
+ if (aStr.isEmpty())
+ {
+ sal_uInt16 nInitMask = aDataArr.back().mnFuncMask;
+ aStr = GetFuncString(nInitMask, pData->mbIsValue);
+ aStr += pData->maName;
+ }
+
+ aWndData.AddField(aStr, nFieldIndex);
+ pData->mnFuncMask = nMask;
+ }
+ }
+ aWndData.ResetScrollBar();
+}
void ScDPLayoutDlg::InitFieldWindow( const vector<PivotField>& rFields, ScDPFieldType eType )
{
+ OSL_ASSERT(eType != TYPE_DATA);
ScDPFuncDataVec* pInitArr = GetFieldDataArray(eType);
ScDPFieldControlBase* pInitWnd = GetFieldWindow(eType);
if (!pInitArr || !pInitWnd)
return;
- vector<PivotField>::const_iterator itr = rFields.begin(), itrEnd = rFields.end();
+ vector<PivotField>::const_iterator it = rFields.begin(), itrEnd = rFields.end();
for (; itr != itrEnd; ++itr)
{
SCCOL nCol = itr->nCol;
@@ -391,28 +424,7 @@ void ScDPLayoutDlg::InitFieldWindow( const vector<PivotField>& rFields, ScDPFiel
size_t nFieldIndex = pInitArr->size();
pInitArr->push_back(new ScDPFuncData(nCol, nMask, itr->mnDupCount, itr->maFieldRef));
-
- if (eType == TYPE_DATA)
- {
- // data field - we need to concatenate function name with the field name.
- ScDPLabelData* pData = GetLabelData(nCol);
- OSL_ENSURE( pData, "ScDPLabelData not found" );
- if (pData)
- {
- OUString aStr = pData->maLayoutName;
- if (aStr.isEmpty())
- {
- sal_uInt16 nInitMask = pInitArr->back().mnFuncMask;
- aStr = GetFuncString(nInitMask, pData->mbIsValue);
- aStr += pData->maName;
- }
-
- pInitWnd->AddField(aStr, nFieldIndex);
- pData->mnFuncMask = nMask;
- }
- }
- else
- pInitWnd->AddField(GetLabelString(nCol), nFieldIndex);
+ pInitWnd->AddField(GetLabelString(nCol), nFieldIndex);
}
pInitWnd->ResetScrollBar();
}
@@ -436,7 +448,7 @@ void ScDPLayoutDlg::InitFields()
InitFieldWindow(thePivotData.maPageFields, TYPE_PAGE);
InitFieldWindow(thePivotData.maColFields, TYPE_COL);
InitFieldWindow(thePivotData.maRowFields, TYPE_ROW);
- InitFieldWindow(thePivotData.maDataFields, TYPE_DATA);
+ InitWndData(thePivotData.maDataFields);
}
//----------------------------------------------------------------------------
diff --git a/sc/source/ui/inc/pvlaydlg.hxx b/sc/source/ui/inc/pvlaydlg.hxx
index cb352d2..5f460a4 100644
--- a/sc/source/ui/inc/pvlaydlg.hxx
+++ b/sc/source/ui/inc/pvlaydlg.hxx
@@ -192,6 +192,7 @@ private:
private:
void Init (bool bNewOutput);
void InitWndSelect(const ScDPLabelDataVec& rLabels);
+ void InitWndData(const std::vector<PivotField>& rFields);
void InitFieldWindow ( const ::std::vector<PivotField>& rFields, ScDPFieldType eType );
void InitFocus ();
void InitFields ();
commit 1d71cba38cd72365dad7462bc9d5b06fb2b62637
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Feb 17 17:27:26 2012 -0500
Only show original dimensions in the select window.
diff --git a/sc/inc/pivot.hxx b/sc/inc/pivot.hxx
index 7d173e9..2ab0464 100644
--- a/sc/inc/pivot.hxx
+++ b/sc/inc/pivot.hxx
@@ -129,8 +129,8 @@ struct ScDPLabelData
::rtl::OUString maName; /// Original name of the dimension.
::rtl::OUString maLayoutName; /// Layout name (display name)
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_uInt8 mnDupCount;
sal_Int32 mnUsedHier; /// Used hierarchy.
sal_Int32 mnFlags; /// Flags from the DataPilotSource dimension
bool mbShowAll; /// true = Show all (also empty) results.
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 13d8b69..f9862fb 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -2003,12 +2003,12 @@ bool ScDPObject::FillLabelData(ScPivotParam& rParam)
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_ISDATALAYOUT)) );
//! error checking -- is "IsDataLayoutDimension" property required??
+ sal_Int32 nOrigPos = -1;
try
{
aFieldName = xDimName->getName();
uno::Any aOrigAny = xDimProp->getPropertyValue(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_ORIGINAL_POS)));
- sal_Int32 nOrigPos = -1;
if (aOrigAny >>= nOrigPos)
bDuplicated = nOrigPos >= 0;
}
@@ -2022,10 +2022,11 @@ bool ScDPObject::FillLabelData(ScPivotParam& rParam)
if (aFieldName.isEmpty() || bData)
continue;
- SCsCOL nCol = static_cast< SCsCOL >( nDim ); //! ???
bool bIsValue = true; //! check
- std::auto_ptr<ScDPLabelData> pNewLabel(new ScDPLabelData(aFieldName, nCol, bIsValue));
+ 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);
diff --git a/sc/source/core/data/pivot2.cxx b/sc/source/core/data/pivot2.cxx
index 7678f94..9679524 100644
--- a/sc/source/core/data/pivot2.cxx
+++ b/sc/source/core/data/pivot2.cxx
@@ -95,8 +95,8 @@ OUString ScDPLabelData::Member::getDisplayName() const
ScDPLabelData::ScDPLabelData(const rtl::OUString& rName, SCCOL nCol, bool bIsValue) :
maName( rName ),
mnCol( nCol ),
+ mnOriginalDim(-1),
mnFuncMask( PIVOT_FUNC_NONE ),
- mnDupCount(0),
mnUsedHier( 0 ),
mnFlags( 0 ),
mbShowAll( false ),
@@ -129,7 +129,6 @@ bool PivotField::operator==( const PivotField& r ) const
{
return (nCol == r.nCol)
&& (nFuncMask == r.nFuncMask)
- && (mnDupCount == r.mnDupCount)
&& equals(maFieldRef, r.maFieldRef);
}
diff --git a/sc/source/ui/dbgui/pvlaydlg.cxx b/sc/source/ui/dbgui/pvlaydlg.cxx
index cc2d450..0439ff2 100644
--- a/sc/source/ui/dbgui/pvlaydlg.cxx
+++ b/sc/source/ui/dbgui/pvlaydlg.cxx
@@ -354,7 +354,16 @@ void ScDPLayoutDlg::InitWndSelect(const ScDPLabelDataVec& rLabels)
aLabelDataArr.reserve( nLabelCount );
for ( size_t i=0; i < nLabelCount; i++ )
{
- aLabelDataArr.push_back(new ScDPLabelData(rLabels[i]));
+ const ScDPLabelData& r = rLabels[i];
+
+ if (r.mnOriginalDim >= 0)
+ // Don't add duplicate dimensions.
+ continue;
+
+ // TODO: For dimension with duplicates, use layout name only when all
+ // its duplicate dimensions use the same layout name. Otherwise use
+ // the original name.
+ aLabelDataArr.push_back(new ScDPLabelData(r));
aWndSelect.AddField(aLabelDataArr[i].getDisplayName(), i);
aSelectArr.push_back(new ScDPFuncData(aLabelDataArr[i].mnCol, aLabelDataArr[i].mnFuncMask));
}
commit c52c26e0c93576ad64a70396dccfd61c871f1759
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Feb 17 17:10:57 2012 -0500
Return original dimension position via UNO in case it's a duplicate.
diff --git a/sc/inc/unonames.hxx b/sc/inc/unonames.hxx
index 0a91ece..44f1aea 100644
--- a/sc/inc/unonames.hxx
+++ b/sc/inc/unonames.hxx
@@ -565,6 +565,7 @@
#define SC_UNO_DP_COLGRAND "ColumnGrand"
#define SC_UNO_DP_ROWGRAND "RowGrand"
#define SC_UNO_DP_ORIGINAL "Original"
+#define SC_UNO_DP_ORIGINAL_POS "OriginalPosition"
#define SC_UNO_DP_ISDATALAYOUT "IsDataLayoutDimension"
#define SC_UNO_DP_ORIENTATION "Orientation"
#define SC_UNO_DP_POSITION "Position"
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 7696226..13d8b69 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -2007,10 +2007,10 @@ bool ScDPObject::FillLabelData(ScPivotParam& rParam)
{
aFieldName = xDimName->getName();
uno::Any aOrigAny = xDimProp->getPropertyValue(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_ORIGINAL)) );
- uno::Reference<uno::XInterface> xIntOrig;
- if ( (aOrigAny >>= xIntOrig) && xIntOrig.is() )
- bDuplicated = true;
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_ORIGINAL_POS)));
+ sal_Int32 nOrigPos = -1;
+ if (aOrigAny >>= nOrigPos)
+ bDuplicated = nOrigPos >= 0;
}
catch(uno::Exception&)
{
diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx
index 2606926..5ee5325 100644
--- a/sc/source/core/data/dptabsrc.cxx
+++ b/sc/source/core/data/dptabsrc.cxx
@@ -1491,6 +1491,7 @@ uno::Reference<beans::XPropertySetInfo> SAL_CALL ScDPDimension::getPropertySetIn
{MAP_CHAR_LEN(SC_UNO_DP_NUMBERFO), 0, &getCppuType((sal_Int32*)0), beans::PropertyAttribute::READONLY, 0 },
{MAP_CHAR_LEN(SC_UNO_DP_ORIENTATION), 0, &getCppuType((sheet::DataPilotFieldOrientation*)0), 0, 0 },
{MAP_CHAR_LEN(SC_UNO_DP_ORIGINAL), 0, &getCppuType((uno::Reference<container::XNamed>*)0), beans::PropertyAttribute::READONLY, 0 },
+ {MAP_CHAR_LEN(SC_UNO_DP_ORIGINAL_POS), 0, &getCppuType((sal_Int32*)0), 0, 0 },
{MAP_CHAR_LEN(SC_UNO_DP_POSITION), 0, &getCppuType((sal_Int32*)0), 0, 0 },
{MAP_CHAR_LEN(SC_UNO_DP_REFVALUE), 0, &getCppuType((sheet::DataPilotFieldReference*)0), 0, 0 },
{MAP_CHAR_LEN(SC_UNO_DP_USEDHIERARCHY), 0, &getCppuType((sal_Int32*)0), 0, 0 },
@@ -1641,6 +1642,11 @@ uno::Any SAL_CALL ScDPDimension::getPropertyValue( const rtl::OUString& aPropert
xOriginal = pSource->GetDimensionsObject()->getByIndex(nSourceDim);
aRet <<= xOriginal;
}
+ else if (aPropertyName.equalsAscii(SC_UNO_DP_ORIGINAL_POS))
+ {
+ sal_Int32 nPos = static_cast<sal_Int32>(nSourceDim);
+ aRet <<= nPos;
+ }
else if ( aPropertyName.equalsAscii( SC_UNO_DP_FILTER ) )
{
if ( bHasSelectedPage )
commit 561dd143665caa8f21648b1822156e37d1e352bb
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Feb 17 16:57:09 2012 -0500
Removed virtual-ness from effectively non-virtual functions.
diff --git a/sc/inc/dptabsrc.hxx b/sc/inc/dptabsrc.hxx
index aa1f7e5..fd704ed 100644
--- a/sc/inc/dptabsrc.hxx
+++ b/sc/inc/dptabsrc.hxx
@@ -414,16 +414,14 @@ public:
virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
throw(::com::sun::star::uno::RuntimeException);
- virtual sal_uInt16 getOrientation() const;
- virtual void setOrientation(sal_uInt16 nNew);
- virtual long getPosition() const;
- virtual void setPosition(long nNew);
- virtual sal_Bool getIsDataLayoutDimension() const;
- virtual sal_uInt16 getFunction() const;
- virtual void setFunction(sal_uInt16 nNew); // for data dimension
- virtual long getUsedHierarchy() const;
- virtual void setUsedHierarchy(long nNew);
- virtual sal_Bool isDuplicated() const;
+ sal_uInt16 getOrientation() const;
+ void setOrientation(sal_uInt16 nNew);
+ long getPosition() const;
+ bool getIsDataLayoutDimension() const;
+ sal_uInt16 getFunction() const;
+ void setFunction(sal_uInt16 nNew); // for data dimension
+ long getUsedHierarchy() const;
+ void setUsedHierarchy(long nNew);
bool HasSelectedPage() const { return bHasSelectedPage; }
const ScDPItemData& GetSelectedData();
diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx
index 3cdde17..2606926 100644
--- a/sc/source/core/data/dptabsrc.cxx
+++ b/sc/source/core/data/dptabsrc.cxx
@@ -1388,12 +1388,7 @@ long ScDPDimension::getPosition() const
return pSource->GetPosition( nDim );
}
-void ScDPDimension::setPosition(long /* nNew */)
-{
- //! ...
-}
-
-sal_Bool ScDPDimension::getIsDataLayoutDimension() const
+bool ScDPDimension::getIsDataLayoutDimension() const
{
return pSource->GetData()->getIsDataLayoutDimension( nDim );
}
@@ -1438,11 +1433,6 @@ uno::Reference<util::XCloneable> SAL_CALL ScDPDimension::createClone() throw(uno
return CreateCloneObject();
}
-sal_Bool ScDPDimension::isDuplicated() const
-{
- return (nSourceDim >= 0);
-}
-
const sheet::DataPilotFieldReference& ScDPDimension::GetReferenceValue() const
{
return aReferenceValue;
@@ -1519,13 +1509,7 @@ void SAL_CALL ScDPDimension::setPropertyValue( const rtl::OUString& aPropertyNam
lang::IllegalArgumentException, lang::WrappedTargetException,
uno::RuntimeException)
{
- if ( aPropertyName.equalsAscii( SC_UNO_DP_POSITION ) )
- {
- sal_Int32 nInt = 0;
- if (aValue >>= nInt)
- setPosition( nInt );
- }
- else if ( aPropertyName.equalsAscii( SC_UNO_DP_USEDHIERARCHY ) )
+ if ( aPropertyName.equalsAscii( SC_UNO_DP_USEDHIERARCHY ) )
{
sal_Int32 nInt = 0;
if (aValue >>= nInt)
commit 94d5262ed88d40d7f1793e0d82534ecdc541b944
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Feb 17 16:32:04 2012 -0500
auto_ptr to boost::scoped_ptr.
diff --git a/sc/inc/dpsave.hxx b/sc/inc/dpsave.hxx
index 89f34a2..987f232 100644
--- a/sc/inc/dpsave.hxx
+++ b/sc/inc/dpsave.hxx
@@ -61,9 +61,7 @@ class ScDPSaveMember
{
private:
::rtl::OUString aName;
- SAL_WNODEPRECATED_DECLARATIONS_PUSH
- ::std::auto_ptr<rtl::OUString> mpLayoutName; // custom name to be displayed in the table.
- SAL_WNODEPRECATED_DECLARATIONS_POP
+ boost::scoped_ptr<rtl::OUString> mpLayoutName; // custom name to be displayed in the table.
sal_uInt16 nVisibleMode;
sal_uInt16 nShowDetailsMode;
@@ -107,10 +105,8 @@ class SC_DLLPUBLIC ScDPSaveDimension
private:
::rtl::OUString aName;
::rtl::OUString* pSelectedPage;
- SAL_WNODEPRECATED_DECLARATIONS_PUSH
- ::std::auto_ptr<rtl::OUString> mpLayoutName;
- ::std::auto_ptr<rtl::OUString> mpSubtotalName;
- SAL_WNODEPRECATED_DECLARATIONS_POP
+ boost::scoped_ptr<rtl::OUString> mpLayoutName;
+ boost::scoped_ptr<rtl::OUString> mpSubtotalName;
bool bIsDataLayout;
bool bDupFlag;
sal_uInt16 nOrientation;
diff --git a/sc/source/core/data/dpsave.cxx b/sc/source/core/data/dpsave.cxx
index 9f0f31c..27d6c68 100644
--- a/sc/source/core/data/dpsave.cxx
+++ b/sc/source/core/data/dpsave.cxx
@@ -94,7 +94,7 @@ ScDPSaveMember::ScDPSaveMember(const ScDPSaveMember& r) :
nVisibleMode( r.nVisibleMode ),
nShowDetailsMode( r.nShowDetailsMode )
{
- if (r.mpLayoutName.get())
+ if (r.mpLayoutName)
mpLayoutName.reset(new OUString(*r.mpLayoutName));
}
@@ -171,7 +171,7 @@ void ScDPSaveMember::WriteToSource( const uno::Reference<uno::XInterface>& xMemb
lcl_SetBoolProperty( xMembProp,
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_SHOWDETAILS)), (bool)nShowDetailsMode );
- if (mpLayoutName.get())
+ if (mpLayoutName)
ScUnoHelpFunctions::SetOptionalPropertyValue(xMembProp, SC_UNO_DP_LAYOUTNAME, *mpLayoutName);
if ( nPosition >= 0 )
@@ -248,9 +248,9 @@ ScDPSaveDimension::ScDPSaveDimension(const ScDPSaveDimension& r) :
pSelectedPage = new ::rtl::OUString( *(r.pSelectedPage) );
else
pSelectedPage = NULL;
- if (r.mpLayoutName.get())
+ if (r.mpLayoutName)
mpLayoutName.reset(new OUString(*r.mpLayoutName));
- if (r.mpSubtotalName.get())
+ if (r.mpSubtotalName)
mpSubtotalName.reset(new OUString(*r.mpSubtotalName));
}
@@ -584,7 +584,7 @@ void ScDPSaveDimension::WriteToSource( const uno::Reference<uno::XInterface>& xD
// else keep empty sequence
ScUnoHelpFunctions::SetOptionalPropertyValue(xDimProp, SC_UNO_DP_FILTER, aFilter);
- if (mpLayoutName.get())
+ if (mpLayoutName)
ScUnoHelpFunctions::SetOptionalPropertyValue(xDimProp, SC_UNO_DP_LAYOUTNAME, *mpLayoutName);
const OUString* pSubTotalName = GetSubtotalName();
commit 8550b9331d28b5691f21d6d2bed7a784d199f81c
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Feb 17 14:45:27 2012 -0500
Scope reduction.
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index fb4c2eb..7696226 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -1928,44 +1928,46 @@ bool ScDPObject::FillOldParam(ScPivotParam& rParam) const
void lcl_FillLabelData( ScDPLabelData& rData, const uno::Reference< beans::XPropertySet >& xDimProp )
{
uno::Reference<sheet::XHierarchiesSupplier> xDimSupp( xDimProp, uno::UNO_QUERY );
- if ( xDimProp.is() && xDimSupp.is() )
- {
- uno::Reference<container::XIndexAccess> xHiers = new ScNameToIndexAccess( xDimSupp->getHierarchies() );
- long nHierarchy = ScUnoHelpFunctions::GetLongProperty( xDimProp,
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_USEDHIERARCHY)) );
- if ( nHierarchy >= xHiers->getCount() )
- nHierarchy = 0;
- rData.mnUsedHier = nHierarchy;
+ if (!xDimProp.is() || !xDimSupp.is())
+ return;
- uno::Reference<uno::XInterface> xHier = ScUnoHelpFunctions::AnyToInterface(
- xHiers->getByIndex(nHierarchy) );
+ uno::Reference<container::XIndexAccess> xHiers = new ScNameToIndexAccess( xDimSupp->getHierarchies() );
+ long nHierarchy = ScUnoHelpFunctions::GetLongProperty(
+ xDimProp, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_USEDHIERARCHY)));
+ if ( nHierarchy >= xHiers->getCount() )
+ nHierarchy = 0;
+ rData.mnUsedHier = nHierarchy;
- uno::Reference<sheet::XLevelsSupplier> xHierSupp( xHier, uno::UNO_QUERY );
- if ( xHierSupp.is() )
- {
- uno::Reference<container::XIndexAccess> xLevels = new ScNameToIndexAccess( xHierSupp->getLevels() );
- uno::Reference<uno::XInterface> xLevel =
- ScUnoHelpFunctions::AnyToInterface( xLevels->getByIndex( 0 ) );
- uno::Reference<beans::XPropertySet> xLevProp( xLevel, uno::UNO_QUERY );
- if ( xLevProp.is() )
- {
- rData.mbShowAll = ScUnoHelpFunctions::GetBoolProperty( xLevProp,
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_SHOWEMPTY)) );
+ uno::Reference<uno::XInterface> xHier =
+ ScUnoHelpFunctions::AnyToInterface(xHiers->getByIndex(nHierarchy));
- try
- {
- xLevProp->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_DP_SORTING ) ) )
- >>= rData.maSortInfo;
- xLevProp->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_DP_LAYOUT ) ) )
- >>= rData.maLayoutInfo;
- xLevProp->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_DP_AUTOSHOW ) ) )
- >>= rData.maShowInfo;
- }
- catch(uno::Exception&)
- {
- }
- }
- }
+ uno::Reference<sheet::XLevelsSupplier> xHierSupp( xHier, uno::UNO_QUERY );
+ if (!xHierSupp.is())
+ return;
+
+ uno::Reference<container::XIndexAccess> xLevels =
+ new ScNameToIndexAccess( xHierSupp->getLevels() );
+
+ uno::Reference<uno::XInterface> xLevel =
+ ScUnoHelpFunctions::AnyToInterface( xLevels->getByIndex(0) );
+ uno::Reference<beans::XPropertySet> xLevProp( xLevel, uno::UNO_QUERY );
+ if (!xLevProp.is())
+ return;
+
+ rData.mbShowAll = ScUnoHelpFunctions::GetBoolProperty(
+ xLevProp, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_SHOWEMPTY)));
+
+ try
+ {
+ xLevProp->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_DP_SORTING ) ) )
+ >>= rData.maSortInfo;
+ xLevProp->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_DP_LAYOUT ) ) )
+ >>= rData.maLayoutInfo;
+ xLevProp->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_DP_AUTOSHOW ) ) )
+ >>= rData.maShowInfo;
+ }
+ catch(uno::Exception&)
+ {
}
}
@@ -1993,44 +1995,44 @@ bool ScDPObject::FillLabelData(ScPivotParam& rParam)
uno::Reference<container::XNamed> xDimName( xIntDim, uno::UNO_QUERY );
uno::Reference<beans::XPropertySet> xDimProp( xIntDim, uno::UNO_QUERY );
- if ( xDimName.is() && xDimProp.is() )
+ if (!xDimName.is() || !xDimProp.is())
+ continue;
+
+ bool bDuplicated = false;
+ bool bData = ScUnoHelpFunctions::GetBoolProperty( xDimProp,
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_ISDATALAYOUT)) );
+ //! error checking -- is "IsDataLayoutDimension" property required??
+
+ try
{
- bool bDuplicated = false;
- bool bData = ScUnoHelpFunctions::GetBoolProperty( xDimProp,
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_ISDATALAYOUT)) );
- //! error checking -- is "IsDataLayoutDimension" property required??
+ aFieldName = xDimName->getName();
+ uno::Any aOrigAny = xDimProp->getPropertyValue(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_ORIGINAL)) );
+ uno::Reference<uno::XInterface> xIntOrig;
+ if ( (aOrigAny >>= xIntOrig) && xIntOrig.is() )
+ bDuplicated = true;
+ }
+ catch(uno::Exception&)
+ {
+ }
- try
- {
- aFieldName = xDimName->getName();
- uno::Any aOrigAny = xDimProp->getPropertyValue(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_ORIGINAL)) );
- uno::Reference<uno::XInterface> xIntOrig;
- if ( (aOrigAny >>= xIntOrig) && xIntOrig.is() )
- bDuplicated = true;
- }
- catch(uno::Exception&)
- {
- }
+ OUString aLayoutName = ScUnoHelpFunctions::GetStringProperty(
+ xDimProp, OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_LAYOUTNAME)), OUString());
- OUString aLayoutName = ScUnoHelpFunctions::GetStringProperty(
- xDimProp, OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_LAYOUTNAME)), OUString());
+ if (aFieldName.isEmpty() || bData)
+ continue;
- if (!aFieldName.isEmpty() && !bData)
- {
- SCsCOL nCol = static_cast< SCsCOL >( nDim ); //! ???
- bool bIsValue = true; //! check
-
- std::auto_ptr<ScDPLabelData> pNewLabel(new ScDPLabelData(aFieldName, nCol, bIsValue));
- 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 );
- rParam.maLabelArray.push_back(pNewLabel);
- }
- }
+ SCsCOL nCol = static_cast< SCsCOL >( nDim ); //! ???
+ bool bIsValue = true; //! check
+
+ std::auto_ptr<ScDPLabelData> pNewLabel(new ScDPLabelData(aFieldName, nCol, bIsValue));
+ 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 );
+ rParam.maLabelArray.push_back(pNewLabel);
}
return true;
commit 1f4ce4ed9f8e9e47e866dc7a7a5d1ad292a4d78c
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Feb 17 14:36:02 2012 -0500
Some cleanups.
* No source column offset since we only store 0-based field index
everywhere now.
* No more function count since each pivot field can only have one
function.
diff --git a/sc/inc/pivot.hxx b/sc/inc/pivot.hxx
index aa857c1..7d173e9 100644
--- a/sc/inc/pivot.hxx
+++ b/sc/inc/pivot.hxx
@@ -73,9 +73,8 @@ struct ScDPLabelData;
struct PivotField
{
- SCsCOL nCol;
+ SCsCOL nCol; /// 0-based dimension index (not source column index)
sal_uInt16 nFuncMask;
- sal_uInt16 nFuncCount;
sal_uInt8 mnDupCount;
::com::sun::star::sheet::DataPilotFieldReference maFieldRef;
@@ -129,8 +128,9 @@ struct ScDPLabelData
{
::rtl::OUString maName; /// Original name of the dimension.
::rtl::OUString maLayoutName; /// Layout name (display name)
- SCCOL mnCol;
+ SCCOL mnCol; /// 0-based field index (not the source column index)
sal_uInt16 mnFuncMask; /// Page/Column/Row subtotal function.
+ sal_uInt8 mnDupCount;
sal_Int32 mnUsedHier; /// Used hierarchy.
sal_Int32 mnFlags; /// Flags from the DataPilotSource dimension
bool mbShowAll; /// true = Show all (also empty) results.
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index f9e9345..fb4c2eb 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -1736,7 +1736,7 @@ public:
void lcl_FillOldFields(
vector<PivotField>& rFields,
const uno::Reference<sheet::XDimensionsSupplier>& xSource,
- sal_uInt16 nOrient, SCCOL nColAdd, bool bAddData )
+ sal_uInt16 nOrient, bool bAddData )
{
vector<PivotField> aFields;
@@ -1814,11 +1814,11 @@ void lcl_FillOldFields(
{
// this dimension is cloned.
- SCsCOL nCompCol; // column ID of the original dimension.
+ SCsCOL nCompCol; // ID of the original dimension.
if ( bDataLayout )
nCompCol = PIVOT_DATA_FIELD;
else
- nCompCol = static_cast<SCsCOL>(nDupSource)+nColAdd; //! seek source column from name
+ nCompCol = static_cast<SCsCOL>(nDupSource); //! seek source column from name
vector<PivotField>::iterator it = std::find_if(aFields.begin(), aFields.end(), FindByColumn(nCompCol, nMask));
if (it != aFields.end())
@@ -1833,12 +1833,11 @@ void lcl_FillOldFields(
bDataFound = true;
}
else if (nDupSource >= 0)
- rField.nCol = static_cast<SCsCOL>(nDupSource)+nColAdd; //! seek from name
+ rField.nCol = static_cast<SCsCOL>(nDupSource); //! seek from name
else
- rField.nCol = static_cast<SCsCOL>(nDim)+nColAdd; //! seek source column from name
+ rField.nCol = static_cast<SCsCOL>(nDim); //! seek source column from name
rField.nFuncMask = nMask;
- rField.nFuncCount = lcl_CountBits(nMask);
rField.mnDupCount = nDupCount;
long nPos = ScUnoHelpFunctions::GetLongProperty(
xDimProp, OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_POSITION)));
@@ -1892,17 +1891,15 @@ bool ScDPObject::FillOldParam(ScPivotParam& rParam) const
rParam.nTab = aOutRange.aStart.Tab();
// ppLabelArr / nLabels is not changed
- SCCOL nSrcColOffset = 0;
-
bool bAddData = ( lcl_GetDataGetOrientation( xSource ) == sheet::DataPilotFieldOrientation_HIDDEN );
lcl_FillOldFields(
- rParam.maPageFields, xSource, sheet::DataPilotFieldOrientation_PAGE, nSrcColOffset, false);
+ rParam.maPageFields, xSource, sheet::DataPilotFieldOrientation_PAGE, false);
lcl_FillOldFields(
- rParam.maColFields, xSource, sheet::DataPilotFieldOrientation_COLUMN, nSrcColOffset, bAddData);
+ rParam.maColFields, xSource, sheet::DataPilotFieldOrientation_COLUMN, bAddData);
lcl_FillOldFields(
- rParam.maRowFields, xSource, sheet::DataPilotFieldOrientation_ROW, nSrcColOffset, false);
+ rParam.maRowFields, xSource, sheet::DataPilotFieldOrientation_ROW, false);
lcl_FillOldFields(
- rParam.maDataFields, xSource, sheet::DataPilotFieldOrientation_DATA, nSrcColOffset, false);
+ rParam.maDataFields, xSource, sheet::DataPilotFieldOrientation_DATA, false);
uno::Reference<beans::XPropertySet> xProp( xSource, uno::UNO_QUERY );
if (xProp.is())
@@ -1982,15 +1979,15 @@ bool ScDPObject::FillLabelData(ScPivotParam& rParam)
uno::Reference<container::XNameAccess> xDimsName = xSource->getDimensions();
uno::Reference<container::XIndexAccess> xDims = new ScNameToIndexAccess( xDimsName );
- long nDimCount = xDims->getCount();
+ sal_Int32 nDimCount = xDims->getCount();
if ( nDimCount > SC_DP_MAX_FIELDS )
nDimCount = SC_DP_MAX_FIELDS;
if (!nDimCount)
return false;
- for (long nDim=0; nDim < nDimCount; nDim++)
+ for (sal_Int32 nDim = 0; nDim < nDimCount; ++nDim)
{
- String aFieldName;
+ rtl::OUString aFieldName;
uno::Reference<uno::XInterface> xIntDim =
ScUnoHelpFunctions::AnyToInterface( xDims->getByIndex(nDim) );
uno::Reference<container::XNamed> xDimName( xIntDim, uno::UNO_QUERY );
@@ -2005,8 +2002,7 @@ bool ScDPObject::FillLabelData(ScPivotParam& rParam)
try
{
- aFieldName = String( xDimName->getName() );
-
+ aFieldName = xDimName->getName();
uno::Any aOrigAny = xDimProp->getPropertyValue(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_ORIGINAL)) );
uno::Reference<uno::XInterface> xIntOrig;
@@ -2020,7 +2016,7 @@ bool ScDPObject::FillLabelData(ScPivotParam& rParam)
OUString aLayoutName = ScUnoHelpFunctions::GetStringProperty(
xDimProp, OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_LAYOUTNAME)), OUString());
- if ( aFieldName.Len() && !bData && !bDuplicated )
+ if (!aFieldName.isEmpty() && !bData)
{
SCsCOL nCol = static_cast< SCsCOL >( nDim ); //! ???
bool bIsValue = true; //! check
diff --git a/sc/source/core/data/dpsave.cxx b/sc/source/core/data/dpsave.cxx
index 2c23783..9f0f31c 100644
--- a/sc/source/core/data/dpsave.cxx
+++ b/sc/source/core/data/dpsave.cxx
@@ -1098,6 +1098,10 @@ void ScDPSaveData::WriteToSource( const uno::Reference<sheet::XDimensionsSupplie
lcl_ResetOrient( xSource );
+ uno::Reference<container::XNameAccess> xDimsName = xSource->getDimensions();
+ uno::Reference<container::XIndexAccess> xIntDims = new ScNameToIndexAccess( xDimsName );
+ long nIntCount = xIntDims->getCount();
+
boost::ptr_vector<ScDPSaveDimension>::iterator iter = aDimList.begin();
for (long i = 0; iter != aDimList.end(); ++iter, ++i)
{
@@ -1109,9 +1113,6 @@ void ScDPSaveData::WriteToSource( const uno::Reference<sheet::XDimensionsSupplie
//! getByName for ScDPSource, including DataLayoutDimension !!!!!!!!
- uno::Reference<container::XNameAccess> xDimsName = xSource->getDimensions();
- uno::Reference<container::XIndexAccess> xIntDims = new ScNameToIndexAccess( xDimsName );
- long nIntCount = xIntDims->getCount();
bool bFound = false;
for (long nIntDim=0; nIntDim<nIntCount && !bFound; nIntDim++)
{
diff --git a/sc/source/core/data/pivot2.cxx b/sc/source/core/data/pivot2.cxx
index 111b716..7678f94 100644
--- a/sc/source/core/data/pivot2.cxx
+++ b/sc/source/core/data/pivot2.cxx
@@ -96,6 +96,7 @@ ScDPLabelData::ScDPLabelData(const rtl::OUString& rName, SCCOL nCol, bool bIsVal
maName( rName ),
mnCol( nCol ),
mnFuncMask( PIVOT_FUNC_NONE ),
+ mnDupCount(0),
mnUsedHier( 0 ),
mnFlags( 0 ),
mbShowAll( false ),
@@ -114,7 +115,6 @@ OUString ScDPLabelData::getDisplayName() const
PivotField::PivotField( SCsCOL nNewCol, sal_uInt16 nNewFuncMask ) :
nCol( nNewCol ),
nFuncMask( nNewFuncMask ),
- nFuncCount( 0 ),
mnDupCount(0)
{
}
@@ -122,7 +122,6 @@ PivotField::PivotField( SCsCOL nNewCol, sal_uInt16 nNewFuncMask ) :
PivotField::PivotField( const PivotField& r ) :
nCol(r.nCol),
nFuncMask(r.nFuncMask),
- nFuncCount(r.nFuncCount),
mnDupCount(r.mnDupCount),
maFieldRef(r.maFieldRef) {}
@@ -130,7 +129,6 @@ bool PivotField::operator==( const PivotField& r ) const
{
return (nCol == r.nCol)
&& (nFuncMask == r.nFuncMask)
- && (nFuncCount == r.nFuncCount)
&& (mnDupCount == r.mnDupCount)
&& equals(maFieldRef, r.maFieldRef);
}
commit c8cfc307d0b62dee93c4843a0f6f0c0660543e93
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Feb 17 14:12:21 2012 -0500
String and bool conversion.
diff --git a/sc/inc/pivot.hxx b/sc/inc/pivot.hxx
index 042226c..aa857c1 100644
--- a/sc/inc/pivot.hxx
+++ b/sc/inc/pivot.hxx
@@ -99,10 +99,10 @@ struct ScPivotParam
::std::vector<PivotField> maColFields;
::std::vector<PivotField> maRowFields;
::std::vector<PivotField> maDataFields;
- sal_Bool bIgnoreEmptyRows;
- sal_Bool bDetectCategories;
- sal_Bool bMakeTotalCol;
- sal_Bool bMakeTotalRow;
+ bool bIgnoreEmptyRows;
+ bool bDetectCategories;
+ bool bMakeTotalCol;
+ bool bMakeTotalRow;
ScPivotParam();
ScPivotParam( const ScPivotParam& r );
@@ -158,7 +158,7 @@ struct ScDPLabelData
::com::sun::star::sheet::DataPilotFieldLayoutInfo maLayoutInfo; /// Layout info.
::com::sun::star::sheet::DataPilotFieldAutoShowInfo maShowInfo; /// AutoShow info.
- explicit ScDPLabelData( const String& rName, SCCOL nCol, bool bIsValue );
+ explicit ScDPLabelData(const rtl::OUString& rName, SCCOL nCol, bool bIsValue);
/**
* return the name that should be displayed in the dp dialogs i.e. when
diff --git a/sc/source/core/data/pivot2.cxx b/sc/source/core/data/pivot2.cxx
index e555a21..111b716 100644
--- a/sc/source/core/data/pivot2.cxx
+++ b/sc/source/core/data/pivot2.cxx
@@ -92,7 +92,7 @@ OUString ScDPLabelData::Member::getDisplayName() const
return maName;
}
-ScDPLabelData::ScDPLabelData( const String& rName, SCCOL nCol, bool bIsValue ) :
+ScDPLabelData::ScDPLabelData(const rtl::OUString& rName, SCCOL nCol, bool bIsValue) :
maName( rName ),
mnCol( nCol ),
mnFuncMask( PIVOT_FUNC_NONE ),
commit 10be7247a8d0488aa535dcd60444a371f029e90b
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Thu Feb 16 23:40:28 2012 -0500
This is no longer true.
diff --git a/sc/inc/pivot.hxx b/sc/inc/pivot.hxx
index 038f707..042226c 100644
--- a/sc/inc/pivot.hxx
+++ b/sc/inc/pivot.hxx
@@ -89,7 +89,6 @@ struct PivotField
typedef boost::ptr_vector<ScDPLabelData> ScDPLabelDataVec;
-// implementation still in global2.cxx
struct ScPivotParam
{
SCCOL nCol; // cursor position /
commit ec057e46646f21e3a8eba82c935283daec84e147
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Thu Feb 16 23:35:05 2012 -0500
Use ptr_vector for ScDPLabelData vector.
diff --git a/sc/inc/pivot.hxx b/sc/inc/pivot.hxx
index 747506f..038f707 100644
--- a/sc/inc/pivot.hxx
+++ b/sc/inc/pivot.hxx
@@ -50,7 +50,7 @@
#include "dpglobal.hxx"
#include <vector>
-#include <boost/shared_ptr.hpp>
+#include <boost/ptr_container/ptr_vector.hpp>
class SubTotal;
@@ -68,7 +68,6 @@ class ScUserListData;
class ScProgress;
struct ScDPLabelData;
-typedef ::boost::shared_ptr<ScDPLabelData> ScDPLabelDataRef;
// -----------------------------------------------------------------------
@@ -88,13 +87,15 @@ struct PivotField
// -----------------------------------------------------------------------
+typedef boost::ptr_vector<ScDPLabelData> ScDPLabelDataVec;
+
// implementation still in global2.cxx
struct ScPivotParam
{
SCCOL nCol; // cursor position /
SCROW nRow; // or start of destination area
SCTAB nTab;
- ::std::vector<ScDPLabelDataRef> maLabelArray;
+ ScDPLabelDataVec maLabelArray;
::std::vector<PivotField> maPageFields;
::std::vector<PivotField> maColFields;
::std::vector<PivotField> maRowFields;
@@ -110,7 +111,7 @@ struct ScPivotParam
ScPivotParam& operator= ( const ScPivotParam& r );
bool operator== ( const ScPivotParam& r ) const;
- void SetLabelData (const ::std::vector<ScDPLabelDataRef>& r);
+ void SetLabelData(const ScDPLabelDataVec& r);
};
//------------------------------------------------------------------------
@@ -167,8 +168,6 @@ struct ScDPLabelData
::rtl::OUString SC_DLLPUBLIC getDisplayName() const;
};
-typedef std::vector< ScDPLabelData > ScDPLabelDataVector;
-
// ============================================================================
struct ScPivotField
@@ -183,8 +182,6 @@ struct ScPivotField
bool operator==( const ScPivotField& r ) const;
};
-typedef ::std::vector< ScPivotField > ScPivotFieldVector;
-
// ============================================================================
struct ScDPFuncData
@@ -204,7 +201,6 @@ struct ScDPFuncData
// ============================================================================
-typedef std::vector< ScDPLabelData > ScDPLabelDataVec;
typedef std::vector<ScDPName> ScDPNameVec;
#endif
diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx
index 1476982..43b0589 100644
--- a/sc/inc/scabstdlg.hxx
+++ b/sc/inc/scabstdlg.hxx
@@ -423,7 +423,7 @@ public:
const SfxItemSet& rArgSet, sal_uInt16 nSourceTab , int nId ) = 0;
virtual AbstractScDPFunctionDlg * CreateScDPFunctionDlg( Window* pParent, int nId,
- const ScDPLabelDataVector& rLabelVec,
+ const ScDPLabelDataVec& rLabelVec,
const ScDPLabelData& rLabelData,
const ScDPFuncData& rFuncData ) = 0;
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 5b1b9a9..f9e9345 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -2025,7 +2025,7 @@ bool ScDPObject::FillLabelData(ScPivotParam& rParam)
SCsCOL nCol = static_cast< SCsCOL >( nDim ); //! ???
bool bIsValue = true; //! check
- ScDPLabelDataRef pNewLabel(new ScDPLabelData(aFieldName, nCol, bIsValue));
+ std::auto_ptr<ScDPLabelData> pNewLabel(new ScDPLabelData(aFieldName, nCol, bIsValue));
pNewLabel->maLayoutName = aLayoutName;
GetHierarchies(nDim, pNewLabel->maHiers);
GetMembers(nDim, GetUsedHierarchy(nDim), pNewLabel->maMembers);
diff --git a/sc/source/core/data/pivot2.cxx b/sc/source/core/data/pivot2.cxx
index 022ba4d..e555a21 100644
--- a/sc/source/core/data/pivot2.cxx
+++ b/sc/source/core/data/pivot2.cxx
@@ -53,6 +53,7 @@
#include "refupdat.hxx"
#include "stlpool.hxx"
#include "stlsheet.hxx"
+#include "pivot.hxx"
using ::com::sun::star::sheet::DataPilotFieldReference;
using ::rtl::OUString;
@@ -159,16 +160,14 @@ ScPivotParam::~ScPivotParam()
{
}
-void ScPivotParam::SetLabelData(const vector<ScDPLabelDataRef>& r)
+void ScPivotParam::SetLabelData(const ScDPLabelDataVec& r)
{
- vector<ScDPLabelDataRef> aNewArray;
+ ScDPLabelDataVec aNewArray;
aNewArray.reserve(r.size());
- for (vector<ScDPLabelDataRef>::const_iterator itr = r.begin(), itrEnd = r.end();
- itr != itrEnd; ++itr)
- {
- ScDPLabelDataRef p(new ScDPLabelData(**itr));
- aNewArray.push_back(p);
- }
+ for (ScDPLabelDataVec::const_iterator itr = r.begin(), itrEnd = r.end();
+ itr != itrEnd; ++itr)
+ aNewArray.push_back(new ScDPLabelData(*itr));
+
maLabelArray.swap(aNewArray);
}
diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx
index 9b36097..bfba9f0 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -1175,7 +1175,7 @@ AbstractScPivotFilterDlg * ScAbstractDialogFactory_Impl::CreateScPivotFilterDlg
AbstractScDPFunctionDlg * ScAbstractDialogFactory_Impl::CreateScDPFunctionDlg ( Window* pParent,
int nId,
- const ScDPLabelDataVector& rLabelVec,
+ const ScDPLabelDataVec& rLabelVec,
const ScDPLabelData& rLabelData,
const ScDPFuncData& rFuncData )
{
diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx
index f864840..9c9e0b7 100644
--- a/sc/source/ui/attrdlg/scdlgfact.hxx
+++ b/sc/source/ui/attrdlg/scdlgfact.hxx
@@ -491,7 +491,7 @@ public:
const SfxItemSet& rArgSet, sal_uInt16 nSourceTab , int nId );
virtual AbstractScDPFunctionDlg * CreateScDPFunctionDlg( Window* pParent, int nId,
- const ScDPLabelDataVector& rLabelVec,
+ const ScDPLabelDataVec& rLabelVec,
const ScDPLabelData& rLabelData,
const ScDPFuncData& rFuncData );
diff --git a/sc/source/ui/dbgui/pvfundlg.cxx b/sc/source/ui/dbgui/pvfundlg.cxx
index 263a6ae..663e5a3 100644
--- a/sc/source/ui/dbgui/pvfundlg.cxx
+++ b/sc/source/ui/dbgui/pvfundlg.cxx
@@ -200,7 +200,7 @@ void ScDPFunctionListBox::FillFunctionNames()
// ============================================================================
ScDPFunctionDlg::ScDPFunctionDlg(
- Window* pParent, const ScDPLabelDataVector& rLabelVec,
+ Window* pParent, const ScDPLabelDataVec& rLabelVec,
const ScDPLabelData& rLabelData, const ScDPFuncData& rFuncData ) :
ModalDialog ( pParent, ScResId( RID_SCDLG_DPDATAFIELD ) ),
maFlFunc ( this, ScResId( FL_FUNC ) ),
diff --git a/sc/source/ui/dbgui/pvlaydlg.cxx b/sc/source/ui/dbgui/pvlaydlg.cxx
index eae9c3c..cc2d450 100644
--- a/sc/source/ui/dbgui/pvlaydlg.cxx
+++ b/sc/source/ui/dbgui/pvlaydlg.cxx
@@ -344,7 +344,7 @@ void ScDPLayoutDlg::StateChanged( StateChangedType nStateChange )
//----------------------------------------------------------------------------
-void ScDPLayoutDlg::InitWndSelect( const vector<ScDPLabelDataRef>& rLabels )
+void ScDPLayoutDlg::InitWndSelect(const ScDPLabelDataVec& rLabels)
{
size_t nLabelCount = rLabels.size();
if (nLabelCount > SC_DP_MAX_FIELDS)
@@ -354,7 +354,7 @@ void ScDPLayoutDlg::InitWndSelect( const vector<ScDPLabelDataRef>& rLabels )
aLabelDataArr.reserve( nLabelCount );
for ( size_t i=0; i < nLabelCount; i++ )
{
- aLabelDataArr.push_back(*rLabels[i]);
+ aLabelDataArr.push_back(new ScDPLabelData(rLabels[i]));
aWndSelect.AddField(aLabelDataArr[i].getDisplayName(), i);
aSelectArr.push_back(new ScDPFuncData(aLabelDataArr[i].mnCol, aLabelDataArr[i].mnFuncMask));
}
diff --git a/sc/source/ui/inc/pvfundlg.hxx b/sc/source/ui/inc/pvfundlg.hxx
index 673468a..e76329b 100644
--- a/sc/source/ui/inc/pvfundlg.hxx
+++ b/sc/source/ui/inc/pvfundlg.hxx
@@ -71,7 +71,7 @@ class ScDPFunctionDlg : public ModalDialog
{
typedef ::boost::unordered_map< ::rtl::OUString, ::rtl::OUString, ::rtl::OUStringHash > NameMapType;
public:
- explicit ScDPFunctionDlg( Window* pParent, const ScDPLabelDataVector& rLabelVec,
+ explicit ScDPFunctionDlg( Window* pParent, const ScDPLabelDataVec& rLabelVec,
const ScDPLabelData& rLabelData, const ScDPFuncData& rFuncData );
sal_uInt16 GetFuncMask() const;
@@ -111,7 +111,7 @@ private:
ScDPListBoxWrapper maLbTypeWrp; /// Wrapper for direct usage of API constants.
- const ScDPLabelDataVector& mrLabelVec; /// Data of all labels.
+ const ScDPLabelDataVec& mrLabelVec; /// Data of all labels.
bool mbEmptyItem; /// true = Empty base item in listbox.
};
diff --git a/sc/source/ui/inc/pvlaydlg.hxx b/sc/source/ui/inc/pvlaydlg.hxx
index eda66f0..cb352d2 100644
--- a/sc/source/ui/inc/pvlaydlg.hxx
+++ b/sc/source/ui/inc/pvlaydlg.hxx
@@ -191,7 +191,7 @@ private:
private:
void Init (bool bNewOutput);
- void InitWndSelect ( const ::std::vector<ScDPLabelDataRef>& rLabels );
+ void InitWndSelect(const ScDPLabelDataVec& rLabels);
void InitFieldWindow ( const ::std::vector<PivotField>& rFields, ScDPFieldType eType );
void InitFocus ();
void InitFields ();
diff --git a/sc/source/ui/view/gridwin2.cxx b/sc/source/ui/view/gridwin2.cxx
index 7f2ce83..54c3d53 100644
--- a/sc/source/ui/view/gridwin2.cxx
+++ b/sc/source/ui/view/gridwin2.cxx
@@ -467,7 +467,7 @@ void ScGridWindow::DPLaunchFieldPopupMenu(
// out-of-bound dimension ID. This should never happen!
return;
- const ScDPLabelData& rLabelData = *pDPData->maDPParam.maLabelArray[pDPData->mnDim];
+ const ScDPLabelData& rLabelData = pDPData->maDPParam.maLabelArray[pDPData->mnDim];
mpDPFieldPopup.reset(new ScCheckListMenuWindow(this, pViewData->GetDocument()));
mpDPFieldPopup->setName(OUString(RTL_CONSTASCII_USTRINGPARAM("DataPilot field member popup")));
@@ -568,7 +568,7 @@ void ScGridWindow::UpdateDPFromFieldPopupMenu()
return;
// Build a map of layout names to original names.
- const ScDPLabelData& rLabelData = *pDPData->maDPParam.maLabelArray[pDPData->mnDim];
+ const ScDPLabelData& rLabelData = pDPData->maDPParam.maLabelArray[pDPData->mnDim];
MemNameMapType aMemNameMap;
for (vector<ScDPLabelData::Member>::const_iterator itr = rLabelData.maMembers.begin(), itrEnd = rLabelData.maMembers.end();
itr != itrEnd; ++itr)
commit fb487ea4c16d015bf69fb965fd0ad36c5bb03fde
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Thu Feb 16 22:24:46 2012 -0500
Use ptr_vector to replace vector with shared_ptr inside.
diff --git a/sc/source/ui/dbgui/pvlaydlg.cxx b/sc/source/ui/dbgui/pvlaydlg.cxx
index 659cf15..eae9c3c 100644
--- a/sc/source/ui/dbgui/pvlaydlg.cxx
+++ b/sc/source/ui/dbgui/pvlaydlg.cxx
@@ -356,8 +356,7 @@ void ScDPLayoutDlg::InitWndSelect( const vector<ScDPLabelDataRef>& rLabels )
{
aLabelDataArr.push_back(*rLabels[i]);
aWndSelect.AddField(aLabelDataArr[i].getDisplayName(), i);
- ScDPFuncDataRef p(new ScDPFuncData(aLabelDataArr[i].mnCol, aLabelDataArr[i].mnFuncMask));
- aSelectArr.push_back(p);
+ aSelectArr.push_back(new ScDPFuncData(aLabelDataArr[i].mnCol, aLabelDataArr[i].mnFuncMask));
}
aWndSelect.ResetScrollBar();
aWndSelect.Paint(Rectangle());
@@ -382,8 +381,7 @@ void ScDPLayoutDlg::InitFieldWindow( const vector<PivotField>& rFields, ScDPFiel
continue;
size_t nFieldIndex = pInitArr->size();
- ScDPFuncDataRef p(new ScDPFuncData(nCol, nMask, itr->mnDupCount, itr->maFieldRef));
- pInitArr->push_back(p);
+ pInitArr->push_back(new ScDPFuncData(nCol, nMask, itr->mnDupCount, itr->maFieldRef));
if (eType == TYPE_DATA)
{
@@ -395,7 +393,7 @@ void ScDPLayoutDlg::InitFieldWindow( const vector<PivotField>& rFields, ScDPFiel
OUString aStr = pData->maLayoutName;
if (aStr.isEmpty())
{
- sal_uInt16 nInitMask = pInitArr->back()->mnFuncMask;
+ sal_uInt16 nInitMask = pInitArr->back().mnFuncMask;
aStr = GetFuncString(nInitMask, pData->mbIsValue);
aStr += pData->maName;
}
@@ -436,7 +434,7 @@ void ScDPLayoutDlg::InitFields()
void ScDPLayoutDlg::AddField( size_t nFromIndex, ScDPFieldType eToType, const Point& rAtPos )
{
- ScDPFuncData fData( *(aSelectArr[nFromIndex]) );
+ ScDPFuncData fData = aSelectArr[nFromIndex];
bool bAllowed = IsOrientationAllowed( fData.mnCol, eToType );
if (!bAllowed)
@@ -513,7 +511,7 @@ void ScDPLayoutDlg::AddField( size_t nFromIndex, ScDPFieldType eToType, const Po
void ScDPLayoutDlg::AppendField(size_t nFromIndex, ScDPFieldType eToType)
{
- ScDPFuncData aFuncData = *aSelectArr[nFromIndex];
+ ScDPFuncData aFuncData = aSelectArr[nFromIndex];
size_t nAt = 0;
ScDPFieldControlBase* toWnd = GetFieldWindow(eToType);
@@ -608,7 +606,7 @@ void ScDPLayoutDlg::MoveField( ScDPFieldType eFromType, size_t nFromIndex, ScDPF
if ( fromArr && toArr && fromWnd && toWnd )
{
- ScDPFuncData fData( *((*fromArr)[nFromIndex]) );
+ ScDPFuncData fData = (*fromArr)[nFromIndex];
bool bAllowed = IsOrientationAllowed( fData.mnCol, eToType );
size_t nAt = 0;
@@ -682,7 +680,7 @@ void ScDPLayoutDlg::MoveField( ScDPFieldType eFromType, size_t nFromIndex, ScDPF
size_t nAt = 0;
Point aToPos;
- ScDPFuncData fData( *((*theArr)[nFromIndex]) );
+ ScDPFuncData fData = (*theArr)[nFromIndex];
if ( Contains( theArr, fData, nAt ) )
{
@@ -727,7 +725,7 @@ void ScDPLayoutDlg::MoveFieldToEnd( ScDPFieldType eFromType, size_t nFromIndex,
if ( fromArr && toArr && fromWnd && toWnd )
{
- ScDPFuncData fData( *((*fromArr)[nFromIndex]) );
+ ScDPFuncData fData = (*fromArr)[nFromIndex];
size_t nAt = 0;
if ( Contains( fromArr, fData, nAt ) )
@@ -794,7 +792,7 @@ void ScDPLayoutDlg::MoveFieldToEnd( ScDPFieldType eFromType, size_t nFromIndex,
Point aToPos;
bool bDataArr = eFromType == TYPE_DATA;
- ScDPFuncData fData( *((*theArr)[nFromIndex]) );
+ ScDPFuncData fData = (*theArr)[nFromIndex];
if ( Contains( theArr, fData, nAt ) )
{
@@ -939,7 +937,7 @@ PointerStyle ScDPLayoutDlg::NotifyMouseMove( const Point& rAt )
case TYPE_DATA: fromArr = &aDataArr; break;
case TYPE_SELECT: fromArr = &aSelectArr; break;
}
- ScDPFuncData fData( *((*fromArr)[nDnDFromIndex]) );
+ ScDPFuncData fData = (*fromArr)[nDnDFromIndex];
if (IsOrientationAllowed( fData.mnCol, eCheckTarget ))
ePtr = lclGetPointerForField( eCheckTarget );
else
@@ -975,7 +973,7 @@ void ScDPLayoutDlg::NotifyDoubleClick( ScDPFieldType eType, size_t nFieldIndex )
}
size_t nArrPos = 0;
- if( ScDPLabelData* pData = GetLabelData( (*pArr)[nFieldIndex]->mnCol, &nArrPos ) )
+ if( ScDPLabelData* pData = GetLabelData( (*pArr)[nFieldIndex].mnCol, &nArrPos ) )
{
ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
@@ -989,9 +987,9 @@ void ScDPLayoutDlg::NotifyDoubleClick( ScDPFieldType eType, size_t nFieldIndex )
// list of names of all data fields
vector<ScDPName> aDataFieldNames;
for( ScDPFuncDataVec::const_iterator aIt = aDataArr.begin(), aEnd = aDataArr.end();
- (aIt != aEnd) && aIt->get(); ++aIt )
+ (aIt != aEnd); ++aIt)
{
- ScDPLabelData* pDFData = GetLabelData((*aIt)->mnCol);
+ ScDPLabelData* pDFData = GetLabelData(aIt->mnCol);
if (!pDFData)
continue;
@@ -1002,7 +1000,7 @@ void ScDPLayoutDlg::NotifyDoubleClick( ScDPFieldType eType, size_t nFieldIndex )
if (aLayoutName.isEmpty())
{
// No layout name exists. Use the stock name.
- sal_uInt16 nMask = (*aIt)->mnFuncMask;
+ sal_uInt16 nMask = aIt->mnFuncMask;
OUString aFuncStr = GetFuncString(nMask);
aLayoutName = aFuncStr + pDFData->maName;
}
@@ -1010,16 +1008,16 @@ void ScDPLayoutDlg::NotifyDoubleClick( ScDPFieldType eType, size_t nFieldIndex )
}
bool bLayout = (eType == TYPE_ROW) &&
- ((aDataFieldNames.size() > 1) || ((nFieldIndex + 1 < pArr->size()) && (*pArr)[nFieldIndex+1].get()));
+ ((aDataFieldNames.size() > 1) || (nFieldIndex + 1 < pArr->size()));
AbstractScDPSubtotalDlg* pDlg = pFact->CreateScDPSubtotalDlg(
this, RID_SCDLG_PIVOTSUBT,
- *xDlgDPObject, *pData, *(*pArr)[nFieldIndex], aDataFieldNames, bLayout );
+ *xDlgDPObject, *pData, (*pArr)[nFieldIndex], aDataFieldNames, bLayout );
if ( pDlg->Execute() == RET_OK )
{
pDlg->FillLabelData( *pData );
- (*pArr)[nFieldIndex]->mnFuncMask = pData->mnFuncMask;
+ (*pArr)[nFieldIndex].mnFuncMask = pData->mnFuncMask;
}
delete pDlg;
}
@@ -1027,7 +1025,7 @@ void ScDPLayoutDlg::NotifyDoubleClick( ScDPFieldType eType, size_t nFieldIndex )
case TYPE_DATA:
{
- ScDPFuncData& rFuncData = *aDataArr[nFieldIndex];
+ ScDPFuncData& rFuncData = aDataArr[nFieldIndex];
AbstractScDPFunctionDlg* pDlg = pFact->CreateScDPFunctionDlg(
this, RID_SCDLG_DPDATAFIELD,
aLabelDataArr, *pData, rFuncData);
@@ -1143,7 +1141,7 @@ bool ScDPLayoutDlg::Contains( ScDPFuncDataVec* pArr, const ScDPFuncData& rData,
ScDPFuncDataVec::const_iterator itr, itrBeg = pArr->begin(), itrEnd = pArr->end();
for (itr = itrBeg; itr != itrEnd; ++itr)
{
- if (**itr == rData)
+ if (*itr == rData)
{
// found!
nAt = ::std::distance(itrBeg, itr);
@@ -1170,7 +1168,7 @@ void ScDPLayoutDlg::Insert( ScDPFuncDataVec* pArr, const ScDPFuncData& rFData, s
if (!pArr)
return;
- ScDPFuncDataRef p (new ScDPFuncData(rFData));
+ std::auto_ptr<ScDPFuncData> p(new ScDPFuncData(rFData));
if (nAt >= pArr->size())
pArr->push_back(p);
else
@@ -1400,7 +1398,7 @@ void ScDPLayoutDlg::AdjustDlgSize()
namespace {
-class PivotFieldInserter : public ::std::unary_function<void, boost::shared_ptr<ScDPFuncData> >
+class PivotFieldInserter : public ::std::unary_function<ScDPFuncData, void>
{
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list