From e9680d99c4403bd07ab4d50939a5d7791bceb98c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Tue, 13 Oct 2015 13:16:31 +0100 Subject: [PATCH] implement dialog control over enhanced shape control points use case is a desire to enable viewing and setting rounded rectangle radiuses to an exact known value Change-Id: I7e6a4db0699076950adf5869a61825159766c46a (cherry picked from commit b859d84e471fdb70b61607d2d919a7907d074bd0) --- cui/source/inc/transfrm.hxx | 6 + cui/source/tabpages/transfrm.cxx | 137 ++++++++++++++- cui/uiconfig/ui/slantcornertabpage.ui | 310 ++++++++++++++++++++++++++++++---- include/svx/EnhancedCustomShape2d.hxx | 1 + 4 files changed, 416 insertions(+), 38 deletions(-) diff --git a/cui/source/inc/transfrm.hxx b/cui/source/inc/transfrm.hxx index 2945d28..2fe2524 100644 --- a/cui/source/inc/transfrm.hxx +++ b/cui/source/inc/transfrm.hxx @@ -239,6 +239,12 @@ private: VclPtr m_pFlAngle; VclPtr m_pMtrAngle; + VclPtr m_aControlGroups[2]; + VclPtr m_aControlGroupX[2]; + VclPtr m_aControlX[2]; + VclPtr m_aControlGroupY[2]; + VclPtr m_aControlY[2]; + const SfxItemSet& rOutAttrs; const SdrView* pView; diff --git a/cui/source/tabpages/transfrm.cxx b/cui/source/tabpages/transfrm.cxx index 950a4b2..43375c2 100644 --- a/cui/source/tabpages/transfrm.cxx +++ b/cui/source/tabpages/transfrm.cxx @@ -18,6 +18,8 @@ */ #include +#include +#include #include #include #include @@ -430,6 +432,15 @@ SvxSlantTabPage::SvxSlantTabPage(vcl::Window* pParent, const SfxItemSet& rInAttr get(m_pFlAngle, "FL_SLANT"); get(m_pMtrAngle, "MTR_FLD_ANGLE"); + for (int i = 0; i < 2; ++i) + { + get(m_aControlGroups[i], "controlgroups" + OString::number(i+1)); + get(m_aControlGroupX[i], "controlgroupx" + OString::number(i+1)); + get(m_aControlX[i], "controlx" + OString::number(i+1)); + get(m_aControlGroupY[i], "controlgroupy" + OString::number(i+1)); + get(m_aControlY[i], "controly" + OString::number(i+1)); + } + // this page needs ExchangeSupport SetExchangeSupport(); @@ -450,6 +461,14 @@ void SvxSlantTabPage::dispose() m_pMtrRadius.clear(); m_pFlAngle.clear(); m_pMtrAngle.clear(); + for (int i = 0; i < 2; ++i) + { + m_aControlGroups[i].clear(); + m_aControlGroupX[i].clear(); + m_aControlX[i].clear(); + m_aControlGroupY[i].clear(); + m_aControlY[i].clear(); + } SvxTabPage::dispose(); } @@ -506,10 +525,56 @@ bool SvxSlantTabPage::FillItemSet(SfxItemSet* rAttrs) rAttrs->Put( SfxBoolItem( SID_ATTR_TRANSFORM_SHEAR_VERTICAL, false ) ); } - return bModified; -} + bool bControlPointsChanged = false; + for (int i = 0; i < 2; ++i) + { + bControlPointsChanged |= (m_aControlX[i]->IsValueChangedFromSaved() || + m_aControlY[i]->IsValueChangedFromSaved()); + } + + if (!bControlPointsChanged) + return bModified; + + SdrObject* pObj = pView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj(); + SdrModel* pModel = pObj->GetModel(); + SdrUndoAction* pUndo = pModel->IsUndoEnabled() ? + pModel->GetSdrUndoFactory().CreateUndoAttrObject(*pObj) : + nullptr; + if (pUndo) + pModel->BegUndo(pUndo->GetComment()); + + EnhancedCustomShape2d aShape(pObj); + Rectangle aLogicRect = aShape.GetLogicRect(); + + for (int i = 0; i < 2; ++i) + { + if (m_aControlX[i]->IsValueChangedFromSaved() || m_aControlY[i]->IsValueChangedFromSaved()) + { + Point aNewPosition(GetCoreValue(*m_aControlX[i], ePoolUnit), + GetCoreValue(*m_aControlY[i], ePoolUnit)); + aNewPosition.Move(aLogicRect.Left(), aLogicRect.Top()); + + css::awt::Point aPosition; + aPosition.X = aNewPosition.X(); + aPosition.Y = aNewPosition.Y(); + + aShape.SetHandleControllerPosition(i, aPosition); + } + } + + pObj->SetChanged(); + pObj->BroadcastObjectChange(); + bModified = true; + + if (pUndo) + { + pModel->AddUndo(pUndo); + pModel->EndUndo(); + } + return bModified; +} void SvxSlantTabPage::Reset(const SfxItemSet* rAttrs) { @@ -561,17 +626,76 @@ void SvxSlantTabPage::Reset(const SfxItemSet* rAttrs) } m_pMtrAngle->SaveValue(); -} - + const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); + if (rMarkList.GetMarkCount() == 1) + { + SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); + SdrObjKind eKind = (SdrObjKind) pObj->GetObjIdentifier(); + if (eKind == OBJ_CUSTOMSHAPE) + { + EnhancedCustomShape2d aShape(pObj); + Point aInitialPosition; + for (int i = 0; i < 2; ++i) + { + if (!aShape.GetHandlePosition(i, aInitialPosition)) + break; + m_aControlGroups[i]->Enable(); + css::awt::Point aPosition; + + aPosition.X = SAL_MAX_INT32; + aPosition.Y = SAL_MAX_INT32; + aShape.SetHandleControllerPosition(i, aPosition); + Point aMaxPosition; + aShape.GetHandlePosition(i, aMaxPosition); + + aPosition.X = SAL_MIN_INT32; + aPosition.Y = SAL_MIN_INT32; + aShape.SetHandleControllerPosition(i, aPosition); + Point aMinPosition; + aShape.GetHandlePosition(i, aMinPosition); + + Rectangle aLogicRect = aShape.GetLogicRect(); + aMaxPosition.Move(-aLogicRect.Left(), -aLogicRect.Top()); + aMinPosition.Move(-aLogicRect.Left(), -aLogicRect.Top()); + + aPosition.X = aInitialPosition.X(); + aPosition.Y = aInitialPosition.Y(); + aInitialPosition.Move(-aLogicRect.Left(), -aLogicRect.Top()); + aShape.SetHandleControllerPosition(i, aPosition); + + SetMetricValue(*m_aControlX[i], aInitialPosition.X(), ePoolUnit); + SetMetricValue(*m_aControlY[i], aInitialPosition.Y(), ePoolUnit); + + if (aMaxPosition.X() == aMinPosition.X()) + m_aControlGroupX[i]->Disable(); + else + { + m_aControlX[i]->SetMin(aMinPosition.X(), FUNIT_MM); + m_aControlX[i]->SetMax(aMaxPosition.X(), FUNIT_MM); + } + if (aMaxPosition.Y() == aMinPosition.Y()) + m_aControlGroupY[i]->Disable(); + else + { + m_aControlY[i]->SetMin(aMinPosition.Y(), FUNIT_MM); + m_aControlY[i]->SetMax(aMaxPosition.Y(), FUNIT_MM); + } + } + } + } + for (int i = 0; i < 2; ++i) + { + m_aControlX[i]->SaveValue(); + m_aControlY[i]->SaveValue(); + } +} VclPtr SvxSlantTabPage::Create( vcl::Window* pWindow, const SfxItemSet* rOutAttrs ) { return VclPtr::Create( pWindow, *rOutAttrs ); } - - void SvxSlantTabPage::ActivatePage( const SfxItemSet& rSet ) { SfxRectangleItem const * pRectItem = NULL; @@ -620,7 +744,6 @@ SvxPositionSizeTabPage::SvxPositionSizeTabPage(vcl::Window* pParent, const SfxIt , mfOldWidth(0.0) , mfOldHeight(0.0) { - get(m_pFlPosition, "FL_POSITION"); get(m_pMtrPosX, "MTR_FLD_POS_X"); get(m_pMtrPosY, "MTR_FLD_POS_Y"); diff --git a/cui/uiconfig/ui/slantcornertabpage.ui b/cui/uiconfig/ui/slantcornertabpage.ui index 37b7b0e..b3ce646 100644 --- a/cui/uiconfig/ui/slantcornertabpage.ui +++ b/cui/uiconfig/ui/slantcornertabpage.ui @@ -13,12 +13,132 @@ 1 10 - + True False 6 - vertical - 12 + 24 + 12 + + + True + False + False + 0 + none + + + True + False + 6 + 12 + + + True + False + 12 + 6 + + + True + False + 12 + + + True + False + _X: + True + controlx1:0.00cm + 0 + + + False + True + 0 + + + + + True + True + + 0.00 + 2 + + + False + True + 1 + + + + + 0 + 0 + + + + + True + False + 12 + + + True + False + _Y: + True + controly1:0.00cm + 0 + + + False + True + 0 + + + + + True + True + + 0.00 + 2 + + + False + True + 1 + + + + + 0 + 1 + + + + + + + + + True + False + Control Point 1 + 0 + + + + + + + + 0 + 1 + + True @@ -32,37 +152,36 @@ 6 12 - + True False - 12 + 12 True False - 0 _Radius: True MTR_FLD_RADIUS:0.00cm + 0 - False - True - 0 + 0 + 0 True - False + True + 0.00 adjustmentRADIUS 2 - False - True - 1 + 1 + 0 @@ -73,8 +192,8 @@ True False - 0 Corner Radius + 0 @@ -82,9 +201,8 @@ - False - True - 0 + 0 + 0 @@ -100,37 +218,36 @@ 6 12 - + True False - 12 + 12 True False - 0 _Angle: True MTR_FLD_ANGLE:0.00degrees + 0 - False - True - 0 + 0 + 0 True - False + True + 0.00 adjustmentSLANT 2 - False - True - 1 + 1 + 0 @@ -141,8 +258,128 @@ True False - 0 Slant + 0 + + + + + + + + 1 + 0 + + + + + True + False + False + 0 + none + + + True + False + 6 + 12 + + + True + False + 12 + 6 + + + True + False + 12 + + + True + False + _X: + True + controlx2:0.00cm + 0 + + + False + True + 0 + + + + + True + True + + 0.00 + 2 + + + False + True + 1 + + + + + 0 + 0 + + + + + True + False + 12 + + + True + False + _Y: + True + controly2:0.00cm + 0 + + + False + True + 0 + + + + + True + True + + 0.00 + 2 + + + False + True + 1 + + + + + 0 + 1 + + + + + + + + + True + False + Control Point 2 + 0 @@ -150,16 +387,19 @@ - False - True - 1 + 1 + 1 + + + + @@ -168,4 +408,12 @@ + + + + + + + + diff --git a/include/svx/EnhancedCustomShape2d.hxx b/include/svx/EnhancedCustomShape2d.hxx index b9ed6f2..b1cc1b7 100644 --- a/include/svx/EnhancedCustomShape2d.hxx +++ b/include/svx/EnhancedCustomShape2d.hxx @@ -191,6 +191,7 @@ class SVX_DLLPUBLIC EnhancedCustomShape2d : public SfxItemSet SdrObject* CreateObject( bool bLineGeometryNeededOnly ); void ApplyGluePoints( SdrObject* pObj ); Rectangle GetTextRect() const; + Rectangle GetLogicRect() const { return aLogicRect; } sal_uInt32 GetHdlCount() const; bool GetHandlePosition( const sal_uInt32 nIndex, Point& rReturnPosition ) const; -- 2.4.3