diff options
author | Kohei Yoshida <kohei.yoshida@suse.com> | 2012-02-14 12:06:21 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@suse.com> | 2012-02-14 17:18:58 -0500 |
commit | 4eedf5dc54ab19af39d7033462421082d1abb86d (patch) | |
tree | 18cd94282c6f38bca4a0a1096c310ed4dff9038c /sc | |
parent | 691f2451c86348239d3b9735ee81b8ecd3209161 (diff) |
Correctly set pivot's popup flag when importing from Excel docs.
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/dpsave.hxx | 19 | ||||
-rw-r--r-- | sc/source/core/data/dpsave.cxx | 22 | ||||
-rw-r--r-- | sc/source/filter/excel/xipivot.cxx | 64 |
3 files changed, 77 insertions, 28 deletions
diff --git a/sc/inc/dpsave.hxx b/sc/inc/dpsave.hxx index ee2fd6d0573e..08b5c76707ce 100644 --- a/sc/inc/dpsave.hxx +++ b/sc/inc/dpsave.hxx @@ -240,8 +240,10 @@ public: class ScDPSaveData { +public: + typedef boost::ptr_vector<ScDPSaveDimension> DimsType; private: - boost::ptr_vector<ScDPSaveDimension> aDimList; + DimsType aDimList; ScDPDimensionSaveData* pDimensionData; // settings that create new dimensions sal_uInt16 nColumnGrandMode; sal_uInt16 nRowGrandMode; @@ -270,8 +272,19 @@ public: SC_DLLPUBLIC void SetGrandTotalName(const ::rtl::OUString& rName); SC_DLLPUBLIC const ::rtl::OUString* GetGrandTotalName() const; - const boost::ptr_vector<ScDPSaveDimension>& GetDimensions() const - { return aDimList; } + SC_DLLPUBLIC const DimsType& GetDimensions() const; + + /** + * Get all dimensions in a given orientation. The order represents the + * actual order of occurrence. The returned list also includes data + * layout dimension. + * + * @param eOrientation orientation + * @param rDims (out) list of dimensions for specified orientation + */ + SC_DLLPUBLIC void GetAllDimensionsByOrientation( + com::sun::star::sheet::DataPilotFieldOrientation eOrientation, + std::vector<const ScDPSaveDimension*>& rDims) const; void AddDimension(ScDPSaveDimension* pDim) { aDimList.push_back(pDim); } diff --git a/sc/source/core/data/dpsave.cxx b/sc/source/core/data/dpsave.cxx index e27ef455c821..287c6b6859bb 100644 --- a/sc/source/core/data/dpsave.cxx +++ b/sc/source/core/data/dpsave.cxx @@ -818,6 +818,28 @@ const OUString* ScDPSaveData::GetGrandTotalName() const return mpGrandTotalName.get(); } +const ScDPSaveData::DimsType& ScDPSaveData::GetDimensions() const +{ + return aDimList; +} + +void ScDPSaveData::GetAllDimensionsByOrientation( + sheet::DataPilotFieldOrientation eOrientation, std::vector<const ScDPSaveDimension*>& rDims) const +{ + std::vector<const ScDPSaveDimension*> aDims; + DimsType::const_iterator it = aDimList.begin(), itEnd = aDimList.end(); + for (; it != itEnd; ++it) + { + const ScDPSaveDimension& rDim = *it; + if (rDim.GetOrientation() != static_cast<sal_uInt16>(eOrientation)) + continue; + + aDims.push_back(&rDim); + } + + rDims.swap(aDims); +} + ScDPSaveDimension* ScDPSaveData::GetDimensionByName(const ::rtl::OUString& rName) { boost::ptr_vector<ScDPSaveDimension>::const_iterator iter; diff --git a/sc/source/filter/excel/xipivot.cxx b/sc/source/filter/excel/xipivot.cxx index 7e93dff05e25..6cd0f48f6296 100644 --- a/sc/source/filter/excel/xipivot.cxx +++ b/sc/source/filter/excel/xipivot.cxx @@ -60,6 +60,8 @@ #include <vector> +using namespace com::sun::star; + using ::rtl::OUString; using ::rtl::OUStringBuffer; using ::com::sun::star::sheet::DataPilotFieldOrientation; @@ -1476,9 +1478,11 @@ void XclImpPivotTable::ApplyMergeFlags(const ScRange& rOutRange, const ScDPSaveD ScDocument& rDoc = GetDoc(); - vector<ScAddress> aPageBtns; - aGeometry.getPageFieldPositions(aPageBtns); - vector<ScAddress>::const_iterator itr = aPageBtns.begin(), itrEnd = aPageBtns.end(); + vector<const ScDPSaveDimension*> aFieldDims; + vector<ScAddress> aFieldBtns; + + aGeometry.getPageFieldPositions(aFieldBtns); + vector<ScAddress>::const_iterator itr = aFieldBtns.begin(), itrEnd = aFieldBtns.end(); for (; itr != itrEnd; ++itr) { sal_uInt16 nMFlag = SC_MF_BUTTON; @@ -1491,32 +1495,42 @@ void XclImpPivotTable::ApplyMergeFlags(const ScRange& rOutRange, const ScDPSaveD rDoc.ApplyFlagsTab(itr->Col()+1, itr->Row(), itr->Col()+1, itr->Row(), itr->Tab(), SC_MF_AUTO); } - vector<ScAddress> aColBtns; - aGeometry.getColumnFieldPositions(aColBtns); - itr = aColBtns.begin(); - itrEnd = aColBtns.end(); - for (; itr != itrEnd; ++itr) + aGeometry.getColumnFieldPositions(aFieldBtns); + rSaveData.GetAllDimensionsByOrientation(sheet::DataPilotFieldOrientation_COLUMN, aFieldDims); + if (aFieldBtns.size() == aFieldDims.size()) { - sal_Int16 nMFlag = SC_MF_BUTTON | SC_MF_BUTTON_POPUP; - rtl::OUString aName; - rDoc.GetString(itr->Col(), itr->Row(), itr->Tab(), aName); - if (rSaveData.HasInvisibleMember(aName)) - nMFlag |= SC_MF_HIDDEN_MEMBER; - rDoc.ApplyFlagsTab(itr->Col(), itr->Row(), itr->Col(), itr->Row(), itr->Tab(), nMFlag); + itr = aFieldBtns.begin(); + itrEnd = aFieldBtns.end(); + vector<const ScDPSaveDimension*>::const_iterator itDim = aFieldDims.begin(); + for (; itr != itrEnd; ++itr, ++itDim) + { + sal_Int16 nMFlag = SC_MF_BUTTON; + const ScDPSaveDimension* pDim = *itDim; + if (pDim->HasInvisibleMember()) + nMFlag |= SC_MF_HIDDEN_MEMBER; + if (!pDim->IsDataLayout()) + nMFlag |= SC_MF_BUTTON_POPUP; + rDoc.ApplyFlagsTab(itr->Col(), itr->Row(), itr->Col(), itr->Row(), itr->Tab(), nMFlag); + } } - vector<ScAddress> aRowBtns; - aGeometry.getRowFieldPositions(aRowBtns); - itr = aRowBtns.begin(); - itrEnd = aRowBtns.end(); - for (; itr != itrEnd; ++itr) + aGeometry.getRowFieldPositions(aFieldBtns); + rSaveData.GetAllDimensionsByOrientation(sheet::DataPilotFieldOrientation_ROW, aFieldDims); + if (aFieldBtns.size() == aFieldDims.size()) { - sal_Int16 nMFlag = SC_MF_BUTTON | SC_MF_BUTTON_POPUP; - rtl::OUString aName; - rDoc.GetString(itr->Col(), itr->Row(), itr->Tab(), aName); - if (rSaveData.HasInvisibleMember(aName)) - nMFlag |= SC_MF_HIDDEN_MEMBER; - rDoc.ApplyFlagsTab(itr->Col(), itr->Row(), itr->Col(), itr->Row(), itr->Tab(), nMFlag); + itr = aFieldBtns.begin(); + itrEnd = aFieldBtns.end(); + vector<const ScDPSaveDimension*>::const_iterator itDim = aFieldDims.begin(); + for (; itr != itrEnd; ++itr, ++itDim) + { + sal_Int16 nMFlag = SC_MF_BUTTON; + const ScDPSaveDimension* pDim = *itDim; + if (pDim->HasInvisibleMember()) + nMFlag |= SC_MF_HIDDEN_MEMBER; + if (!pDim->IsDataLayout()) + nMFlag |= SC_MF_BUTTON_POPUP; + rDoc.ApplyFlagsTab(itr->Col(), itr->Row(), itr->Col(), itr->Row(), itr->Tab(), nMFlag); + } } } |