From 7efea44937b783ef1663006410e9d8c7f549f3be Mon Sep 17 00:00:00 2001 From: Niklas Nebel Date: Mon, 30 Aug 2010 18:45:51 +0200 Subject: calc59: #i114202# save table:show-empty attribute only if valid in ScDPSaveDimension --- sc/inc/dpsave.hxx | 1 + sc/source/core/data/dpsave.cxx | 5 +++++ sc/source/filter/xml/XMLExportDataPilot.cxx | 10 +++++++--- 3 files changed, 13 insertions(+), 3 deletions(-) (limited to 'sc') diff --git a/sc/inc/dpsave.hxx b/sc/inc/dpsave.hxx index bfff0b97a168..8272b850b27e 100644 --- a/sc/inc/dpsave.hxx +++ b/sc/inc/dpsave.hxx @@ -140,6 +140,7 @@ public: void SetSubTotals(long nCount, const USHORT* pFuncs); long GetSubTotalsCount() const { return nSubTotalCount; } USHORT GetSubTotalFunc(long nIndex) const { return pSubTotalFuncs[nIndex]; } + bool HasShowEmpty() const; void SetShowEmpty(BOOL bSet); BOOL GetShowEmpty() const { return BOOL(nShowEmptyMode); } void SetFunction(USHORT nNew); // enum GeneralFunction diff --git a/sc/source/core/data/dpsave.cxx b/sc/source/core/data/dpsave.cxx index dd493bb0df6c..bad05968bf72 100644 --- a/sc/source/core/data/dpsave.cxx +++ b/sc/source/core/data/dpsave.cxx @@ -410,6 +410,11 @@ void ScDPSaveDimension::SetSubTotals(long nCount, const USHORT* pFuncs) bSubTotalDefault = FALSE; } +bool ScDPSaveDimension::HasShowEmpty() const +{ + return nShowEmptyMode != SC_DPSAVEMODE_DONTKNOW; +} + void ScDPSaveDimension::SetShowEmpty(BOOL bSet) { nShowEmptyMode = bSet; diff --git a/sc/source/filter/xml/XMLExportDataPilot.cxx b/sc/source/filter/xml/XMLExportDataPilot.cxx index e43ff21a114d..f8cba5ecf6c3 100644 --- a/sc/source/filter/xml/XMLExportDataPilot.cxx +++ b/sc/source/filter/xml/XMLExportDataPilot.cxx @@ -503,9 +503,13 @@ void ScXMLExportDataPilot::WriteMembers(ScDPSaveDimension* pDim) void ScXMLExportDataPilot::WriteLevels(ScDPSaveDimension* pDim) { - rtl::OUStringBuffer sBuffer; - SvXMLUnitConverter::convertBool(sBuffer, pDim->GetShowEmpty()); - rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_SHOW_EMPTY, sBuffer.makeStringAndClear()); + // #i114202# GetShowEmpty is only valid if HasShowEmpty is true. + if (pDim->HasShowEmpty()) + { + rtl::OUStringBuffer sBuffer; + SvXMLUnitConverter::convertBool(sBuffer, pDim->GetShowEmpty()); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_SHOW_EMPTY, sBuffer.makeStringAndClear()); + } SvXMLElementExport aElemDPL(rExport, XML_NAMESPACE_TABLE, XML_DATA_PILOT_LEVEL, sal_True, sal_True); WriteSubTotals(pDim); -- cgit From 892fc048a385eebb365a0bfc7172f334f5d0ab57 Mon Sep 17 00:00:00 2001 From: Niklas Nebel Date: Wed, 1 Sep 2010 17:53:25 +0200 Subject: calc59: #i114256# Don't move DataPilot fields to orientations that the source doesn't support --- sc/inc/dpobject.hxx | 4 ++- sc/inc/pivot.hxx | 1 + sc/inc/unonames.hxx | 1 + sc/source/core/data/dpobject.cxx | 35 +++++++++++++++++++++++- sc/source/core/data/dptabsrc.cxx | 6 +++++ sc/source/core/data/pivot2.cxx | 1 + sc/source/ui/dbgui/pvfundlg.cxx | 5 ++-- sc/source/ui/dbgui/pvlaydlg.cxx | 58 +++++++++++++++++++++++++++++++++++----- sc/source/ui/inc/pvlaydlg.hxx | 1 + sc/source/ui/view/gridwin2.cxx | 13 ++++++--- 10 files changed, 111 insertions(+), 14 deletions(-) mode change 100755 => 100644 sc/source/core/data/dptabsrc.cxx (limited to 'sc') diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx index 44aa1daa9a92..e1b88919dad6 100644 --- a/sc/inc/dpobject.hxx +++ b/sc/inc/dpobject.hxx @@ -186,7 +186,7 @@ public: bool IsDataDescriptionCell(const ScAddress& rPos); bool IsDimNameInUse(const ::rtl::OUString& rName) const; - String GetDimName( long nDim, BOOL& rIsDataLayout ); + String GetDimName( long nDim, BOOL& rIsDataLayout, sal_Int32* pFlags = NULL ); BOOL IsDuplicated( long nDim ); long GetDimCount(); void GetHeaderPositionData(const ScAddress& rPos, ::com::sun::star::sheet::DataPilotTableHeaderData& rData); @@ -259,6 +259,8 @@ public: PivotField* pRefColFields = NULL, SCSIZE nRefColCount = 0, PivotField* pRefRowFields = NULL, SCSIZE nRefRowCount = 0, PivotField* pRefPageFields = NULL, SCSIZE nRefPageCount = 0 ); + + static bool IsOrientationAllowed( USHORT nOrient, sal_Int32 nDimFlags ); }; diff --git a/sc/inc/pivot.hxx b/sc/inc/pivot.hxx index 915a311411c4..489f272bc8ba 100644 --- a/sc/inc/pivot.hxx +++ b/sc/inc/pivot.hxx @@ -141,6 +141,7 @@ struct ScDPLabelData SCsCOL mnCol; USHORT 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. diff --git a/sc/inc/unonames.hxx b/sc/inc/unonames.hxx index 2d011f425398..1e56743d8129 100644 --- a/sc/inc/unonames.hxx +++ b/sc/inc/unonames.hxx @@ -565,6 +565,7 @@ #define SC_UNO_FIELD_SUBTOTALNAME "FieldSubtotalName" #define SC_UNO_GRANDTOTAL_NAME "GrandTotalName" #define SC_UNO_HAS_HIDDEN_MEMBER "HasHiddenMember" +#define SC_UNO_FLAGS "Flags" // (preliminary:) #define SC_UNO_REFVALUE "ReferenceValue" diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx index e994339f4a9a..29ba9f15dc92 100644 --- a/sc/source/core/data/dpobject.cxx +++ b/sc/source/core/data/dpobject.cxx @@ -65,6 +65,7 @@ #include #include #include +#include #include #include #include @@ -845,7 +846,7 @@ bool ScDPObject::IsDimNameInUse(const OUString& rName) const return false; } -String ScDPObject::GetDimName( long nDim, BOOL& rIsDataLayout ) +String ScDPObject::GetDimName( long nDim, BOOL& rIsDataLayout, sal_Int32* pFlags ) { rIsDataLayout = FALSE; String aRet; @@ -879,6 +880,10 @@ String ScDPObject::GetDimName( long nDim, BOOL& rIsDataLayout ) rIsDataLayout = TRUE; else aRet = String( aName ); + + if (pFlags) + *pFlags = ScUnoHelpFunctions::GetLongProperty( xDimProp, + rtl::OUString::createFromAscii(SC_UNO_FLAGS), 0 ); } } } @@ -2003,6 +2008,8 @@ BOOL ScDPObject::FillLabelData(ScPivotParam& rParam) GetHierarchies(nDim, pNewLabel->maHiers); GetMembers(nDim, GetUsedHierarchy(nDim), pNewLabel->maMembers); lcl_FillLabelData(*pNewLabel, xDimProp); + pNewLabel->mnFlags = ScUnoHelpFunctions::GetLongProperty( xDimProp, + rtl::OUString::createFromAscii(SC_UNO_FLAGS), 0 ); rParam.maLabelArray.push_back(pNewLabel); } } @@ -2231,6 +2238,32 @@ void ScDPObject::ConvertOrientation( ScDPSaveData& rSaveData, } } +// static +bool ScDPObject::IsOrientationAllowed( USHORT nOrient, sal_Int32 nDimFlags ) +{ + bool bAllowed = true; + switch (nOrient) + { + case sheet::DataPilotFieldOrientation_PAGE: + bAllowed = ( nDimFlags & sheet::DimensionFlags::NO_PAGE_ORIENTATION ) == 0; + break; + case sheet::DataPilotFieldOrientation_COLUMN: + bAllowed = ( nDimFlags & sheet::DimensionFlags::NO_COLUMN_ORIENTATION ) == 0; + break; + case sheet::DataPilotFieldOrientation_ROW: + bAllowed = ( nDimFlags & sheet::DimensionFlags::NO_ROW_ORIENTATION ) == 0; + break; + case sheet::DataPilotFieldOrientation_DATA: + bAllowed = ( nDimFlags & sheet::DimensionFlags::NO_DATA_ORIENTATION ) == 0; + break; + default: + { + // allowed to remove from previous orientation + } + } + return bAllowed; +} + // ----------------------------------------------------------------------- // static diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx old mode 100755 new mode 100644 index da40e6e230c4..b4ca5dbc7330 --- a/sc/source/core/data/dptabsrc.cxx +++ b/sc/source/core/data/dptabsrc.cxx @@ -1576,6 +1576,7 @@ uno::Reference SAL_CALL ScDPDimension::getPropertySetIn static SfxItemPropertyMapEntry aDPDimensionMap_Impl[] = { {MAP_CHAR_LEN(SC_UNO_FILTER), 0, &getCppuType((uno::Sequence*)0), 0, 0 }, + {MAP_CHAR_LEN(SC_UNO_FLAGS), 0, &getCppuType((sal_Int32*)0), beans::PropertyAttribute::READONLY, 0 }, {MAP_CHAR_LEN(SC_UNO_FUNCTION), 0, &getCppuType((sheet::GeneralFunction*)0), 0, 0 }, {MAP_CHAR_LEN(SC_UNO_ISDATALA), 0, &getBooleanCppuType(), beans::PropertyAttribute::READONLY, 0 }, {MAP_CHAR_LEN(SC_UNO_NUMBERFO), 0, &getCppuType((sal_Int32*)0), beans::PropertyAttribute::READONLY, 0 }, @@ -1753,6 +1754,11 @@ uno::Any SAL_CALL ScDPDimension::getPropertyValue( const rtl::OUString& aPropert aRet <<= mpSubtotalName.get() ? *mpSubtotalName : OUString::createFromAscii(""); else if (aNameStr.EqualsAscii(SC_UNO_HAS_HIDDEN_MEMBER)) aRet <<= mbHasHiddenMember; + else if (aNameStr.EqualsAscii(SC_UNO_FLAGS)) + { + sal_Int32 nFlags = 0; // tabular data: all orientations are possible + aRet <<= nFlags; + } else { DBG_ERROR("unknown property"); diff --git a/sc/source/core/data/pivot2.cxx b/sc/source/core/data/pivot2.cxx index 5a6174bc0129..ddac72f0230b 100644 --- a/sc/source/core/data/pivot2.cxx +++ b/sc/source/core/data/pivot2.cxx @@ -82,6 +82,7 @@ ScDPLabelData::ScDPLabelData( const String& rName, short nCol, bool bIsValue ) : mnCol( nCol ), mnFuncMask( PIVOT_FUNC_NONE ), mnUsedHier( 0 ), + mnFlags( 0 ), mbShowAll( false ), mbIsValue( bIsValue ) { diff --git a/sc/source/ui/dbgui/pvfundlg.cxx b/sc/source/ui/dbgui/pvfundlg.cxx index 6b04993ba0bc..b5a19ef0ec9b 100644 --- a/sc/source/ui/dbgui/pvfundlg.cxx +++ b/sc/source/ui/dbgui/pvfundlg.cxx @@ -735,8 +735,9 @@ ScDPShowDetailDlg::ScDPShowDetailDlg( Window* pParent, ScDPObject& rDPObj, USHOR for (long nDim=0; nDimGetExistingDimensionByName(aName) : 0; if ( !pDimension || (pDimension->GetOrientation() != nOrient) ) diff --git a/sc/source/ui/dbgui/pvlaydlg.cxx b/sc/source/ui/dbgui/pvlaydlg.cxx index 1eca44a787ed..d73ede0d4947 100644 --- a/sc/source/ui/dbgui/pvlaydlg.cxx +++ b/sc/source/ui/dbgui/pvlaydlg.cxx @@ -567,7 +567,9 @@ void ScDPLayoutDlg::AddField( size_t nFromIndex, ScDPFieldType eToType, const Po } } - if ( (toArr->back().get() == NULL) + bool bAllowed = IsOrientationAllowed( fData.mnCol, eToType ); + if ( bAllowed + && (toArr->back().get() == NULL) && (!Contains( toArr, fData.mnCol, nAt )) ) { // ggF. in anderem Fenster entfernen @@ -714,7 +716,8 @@ void ScDPLayoutDlg::MoveField( ScDPFieldType eFromType, size_t nFromIndex, ScDPF { ScDPFuncData fData( *((*fromArr)[nFromIndex]) ); - if ( Contains( fromArr, fData.mnCol, nAt ) ) + bool bAllowed = IsOrientationAllowed( fData.mnCol, eToType ); + if ( bAllowed && Contains( fromArr, fData.mnCol, nAt ) ) { fromWnd->DelField( nAt ); Remove( fromArr, nAt ); @@ -935,21 +938,42 @@ PointerStyle ScDPLayoutDlg::NotifyMouseMove( const Point& rAt ) if ( bIsDrag ) { Point aPos = ScreenToOutputPixel( rAt ); + ScDPFieldType eCheckTarget = TYPE_SELECT; if ( aRectPage.IsInside( aPos ) ) - ePtr = lclGetPointerForField( TYPE_PAGE ); + eCheckTarget = TYPE_PAGE; else if ( aRectCol.IsInside( aPos ) ) - ePtr = lclGetPointerForField( TYPE_COL ); + eCheckTarget = TYPE_COL; else if ( aRectRow.IsInside( aPos ) ) - ePtr = lclGetPointerForField( TYPE_ROW ); + eCheckTarget = TYPE_ROW; else if ( aRectData.IsInside( aPos ) ) - ePtr = lclGetPointerForField( TYPE_DATA ); + eCheckTarget = TYPE_DATA; else if ( eDnDFromType != TYPE_SELECT ) ePtr = POINTER_PIVOT_DELETE; else if ( aRectSelect.IsInside( aPos ) ) ePtr = lclGetPointerForField( TYPE_SELECT ); else ePtr = POINTER_NOTALLOWED; + + if ( eCheckTarget != TYPE_SELECT ) + { + // check if the target orientation is allowed for this field + bool bAllowed = true; + ScDPFuncDataVec* fromArr = NULL; + switch ( eDnDFromType ) + { + case TYPE_PAGE: fromArr = &aPageArr; break; + case TYPE_COL: fromArr = &aColArr; break; + case TYPE_ROW: fromArr = &aRowArr; break; + case TYPE_DATA: fromArr = &aDataArr; break; + case TYPE_SELECT: fromArr = &aSelectArr; break; + } + ScDPFuncData fData( *((*fromArr)[nDnDFromIndex]) ); + if (IsOrientationAllowed( fData.mnCol, eCheckTarget )) + ePtr = lclGetPointerForField( eCheckTarget ); + else + ePtr = POINTER_NOTALLOWED; + } } return ePtr; @@ -1218,6 +1242,28 @@ String ScDPLayoutDlg::GetLabelString( SCsCOL nCol ) return String(); } +//---------------------------------------------------------------------------- + +bool ScDPLayoutDlg::IsOrientationAllowed( SCsCOL nCol, ScDPFieldType eType ) +{ + bool bAllowed = true; + ScDPLabelData* pData = GetLabelData( nCol ); + DBG_ASSERT( pData, "LabelData not found" ); + if (pData) + { + sheet::DataPilotFieldOrientation eOrient = sheet::DataPilotFieldOrientation_HIDDEN; + switch (eType) + { + case TYPE_PAGE: eOrient = sheet::DataPilotFieldOrientation_PAGE; break; + case TYPE_COL: eOrient = sheet::DataPilotFieldOrientation_COLUMN; break; + case TYPE_ROW: eOrient = sheet::DataPilotFieldOrientation_ROW; break; + case TYPE_DATA: eOrient = sheet::DataPilotFieldOrientation_DATA; break; + case TYPE_SELECT: eOrient = sheet::DataPilotFieldOrientation_HIDDEN; break; + } + bAllowed = ScDPObject::IsOrientationAllowed( (USHORT)eOrient, pData->mnFlags ); + } + return bAllowed; +} //---------------------------------------------------------------------------- diff --git a/sc/source/ui/inc/pvlaydlg.hxx b/sc/source/ui/inc/pvlaydlg.hxx index c74b9e028d2f..e16c3266510e 100644 --- a/sc/source/ui/inc/pvlaydlg.hxx +++ b/sc/source/ui/inc/pvlaydlg.hxx @@ -198,6 +198,7 @@ private: Point DlgPos2WndPos ( const Point& rPt, Window& rWnd ); ScDPLabelData* GetLabelData ( SCsCOL nCol, size_t* pPos = NULL ); String GetLabelString ( SCsCOL nCol ); + bool IsOrientationAllowed( SCsCOL nCol, ScDPFieldType eType ); String GetFuncString ( USHORT& rFuncMask, BOOL bIsValue = TRUE ); BOOL Contains ( ScDPFuncDataVec* pArr, SCsCOL nCol, size_t& nAt ); void Remove ( ScDPFuncDataVec* pArr, size_t nAt ); diff --git a/sc/source/ui/view/gridwin2.cxx b/sc/source/ui/view/gridwin2.cxx index a64814d952ef..ec584213898c 100644 --- a/sc/source/ui/view/gridwin2.cxx +++ b/sc/source/ui/view/gridwin2.cxx @@ -309,10 +309,17 @@ void ScGridWindow::DPTestMouse( const MouseEvent& rMEvt, BOOL bMove ) aPosRect, nOrient, nDimPos ); UpdateDragRect( bHasRange && bMove, aPosRect ); + BOOL bIsDataLayout; + sal_Int32 nDimFlags = 0; + String aDimName = pDragDPObj->GetDimName( nDPField, bIsDataLayout, &nDimFlags ); + bool bAllowed = !bHasRange || ScDPObject::IsOrientationAllowed( nOrient, nDimFlags ); + if (bMove) // set mouse pointer { PointerStyle ePointer = POINTER_PIVOT_DELETE; - if ( bHasRange ) + if ( !bAllowed ) + ePointer = POINTER_NOTALLOWED; + else if ( bHasRange ) switch (nOrient) { case sheet::DataPilotFieldOrientation_COLUMN: ePointer = POINTER_PIVOT_COL; break; @@ -327,15 +334,13 @@ void ScGridWindow::DPTestMouse( const MouseEvent& rMEvt, BOOL bMove ) if (!bHasRange) nOrient = sheet::DataPilotFieldOrientation_HIDDEN; - BOOL bIsDataLayout; - String aDimName = pDragDPObj->GetDimName( nDPField, bIsDataLayout ); if ( bIsDataLayout && ( nOrient != sheet::DataPilotFieldOrientation_COLUMN && nOrient != sheet::DataPilotFieldOrientation_ROW ) ) { // removing data layout is not allowed pViewData->GetView()->ErrorMessage(STR_PIVOT_MOVENOTALLOWED); } - else + else if ( bAllowed ) { ScDPSaveData aSaveData( *pDragDPObj->GetSaveData() ); -- cgit From c87fa692ab3b94601d3556b0e81c396f7cadc40d Mon Sep 17 00:00:00 2001 From: Niklas Nebel Date: Wed, 1 Sep 2010 18:30:27 +0200 Subject: calc59: compiler warning --- sc/source/ui/dbgui/pvlaydlg.cxx | 1 - 1 file changed, 1 deletion(-) (limited to 'sc') diff --git a/sc/source/ui/dbgui/pvlaydlg.cxx b/sc/source/ui/dbgui/pvlaydlg.cxx index d73ede0d4947..56d7e3550cda 100644 --- a/sc/source/ui/dbgui/pvlaydlg.cxx +++ b/sc/source/ui/dbgui/pvlaydlg.cxx @@ -958,7 +958,6 @@ PointerStyle ScDPLayoutDlg::NotifyMouseMove( const Point& rAt ) if ( eCheckTarget != TYPE_SELECT ) { // check if the target orientation is allowed for this field - bool bAllowed = true; ScDPFuncDataVec* fromArr = NULL; switch ( eDnDFromType ) { -- cgit