diff options
author | Olivier Hallot <olivier.hallot@edx.srv.br> | 2013-09-11 21:34:32 -0300 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-09-12 15:51:39 +0000 |
commit | 9e5afc4e1be0ae76af3b66bc981d63b1a93c0a70 (patch) | |
tree | dfabea4efd22065425158a6c77625200779644ac /svx/source | |
parent | 6056965245915d3aeb84e8ccd065133bdf21d806 (diff) |
Convert connector tab page to widget UI
Also:
* Rename dimensionline.ui to dimensionlinetabpage for naming consistency
* Fix connector and measure dialogs for connectors and dimension lines
Change-Id: I921890b33a5f9807a6e12341ef7f374312abfc8b
Reviewed-on: https://gerrit.libreoffice.org/5920
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svx/source')
-rw-r--r-- | svx/source/dialog/connctrl.cxx | 155 |
1 files changed, 92 insertions, 63 deletions
diff --git a/svx/source/dialog/connctrl.cxx b/svx/source/dialog/connctrl.cxx index 65c386cb680b..fa38393787ad 100644 --- a/svx/source/dialog/connctrl.cxx +++ b/svx/source/dialog/connctrl.cxx @@ -32,86 +32,53 @@ #include <svx/sxelditm.hxx> #include <svx/sxmkitm.hxx> -SvxXConnectionPreview::SvxXConnectionPreview( Window* pParent, const ResId& rResId, - const SfxItemSet& rInAttrs ) : - Control ( pParent, rResId ), - rAttrs ( rInAttrs ), - pEdgeObj( NULL ), - pObjList( NULL ), - pView ( NULL ) +#include <vcl/builder.hxx> + +SvxXConnectionPreview::SvxXConnectionPreview( Window* pParent, WinBits nStyle) + : Control(pParent, nStyle) + , pEdgeObj(NULL) + , pObjList(NULL) + , pView(NULL) { SetMapMode( MAP_100TH_MM ); SetStyles(); } +extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSvxXConnectionPreview(Window *pParent, VclBuilder::stringmap &rMap) +{ + WinBits nWinStyle = 0; + OString sBorder = VclBuilder::extractCustomProperty(rMap); + if (!sBorder.isEmpty()) + nWinStyle |= WB_BORDER; + return new SvxXConnectionPreview(pParent, nWinStyle); +} + SvxXConnectionPreview::~SvxXConnectionPreview() { delete pObjList; } -void SvxXConnectionPreview::Construct() +void SvxXConnectionPreview::Resize() { - DBG_ASSERT( pView, "No valid view is passed on! "); - - const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); - sal_uIntPtr nMarkCount = rMarkList.GetMarkCount(); - - if( nMarkCount >= 1 ) - { - bool bFound = false; - const SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); - - - for( sal_uInt16 i = 0; i < nMarkCount && !bFound; i++ ) - { - pObj = rMarkList.GetMark( i )->GetMarkedSdrObj(); - sal_uInt32 nInv = pObj->GetObjInventor(); - sal_uInt16 nId = pObj->GetObjIdentifier(); - if( nInv == SdrInventor && nId == OBJ_EDGE ) - { - bFound = true; - SdrEdgeObj* pTmpEdgeObj = (SdrEdgeObj*) pObj; - pEdgeObj = (SdrEdgeObj*) pTmpEdgeObj->Clone(); - - SdrObjConnection& rConn1 = (SdrObjConnection&)pEdgeObj->GetConnection( sal_True ); - SdrObjConnection& rConn2 = (SdrObjConnection&)pEdgeObj->GetConnection( sal_False ); - - rConn1 = pTmpEdgeObj->GetConnection( sal_True ); - rConn2 = pTmpEdgeObj->GetConnection( sal_False ); + Control::Resize(); - SdrObject* pTmpObj1 = pTmpEdgeObj->GetConnectedNode( sal_True ); - SdrObject* pTmpObj2 = pTmpEdgeObj->GetConnectedNode( sal_False ); - - // potential memory leak here (!). Create SdrObjList only when there is - // not yet one. - if(!pObjList) - { - pObjList = new SdrObjList( pView->GetModel(), NULL ); - } + AdaptSize(); - if( pTmpObj1 ) - { - SdrObject* pObj1 = pTmpObj1->Clone(); - pObjList->InsertObject( pObj1 ); - pEdgeObj->ConnectToNode( sal_True, pObj1 ); - } - if( pTmpObj2 ) - { - SdrObject* pObj2 = pTmpObj2->Clone(); - pObjList->InsertObject( pObj2 ); - pEdgeObj->ConnectToNode( sal_False, pObj2 ); - } - pObjList->InsertObject( pEdgeObj ); - } - } - } + Invalidate(); +} - if( !pEdgeObj ) - pEdgeObj = new SdrEdgeObj(); +Size SvxXConnectionPreview::GetOptimalSize() const +{ + return LogicToPixel(Size(118 , 121), MapMode(MAP_APPFONT)); +} +void SvxXConnectionPreview::AdaptSize() +{ // Adapt size if( pObjList ) { + SetMapMode( MAP_100TH_MM ); + OutputDevice* pOD = pView->GetFirstOutputDevice(); // GetWin( 0 ); Rectangle aRect = pObjList->GetAllObjBoundRect(); @@ -161,13 +128,75 @@ void SvxXConnectionPreview::Construct() aDisplayMap.SetOrigin( aNewPos ); SetMapMode( aDisplayMap ); - Point aPos; MouseEvent aMEvt( aPos, 1, 0, MOUSE_RIGHT ); MouseButtonDown( aMEvt ); } } +void SvxXConnectionPreview::Construct() +{ + DBG_ASSERT( pView, "No valid view is passed on! "); + + const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); + sal_uIntPtr nMarkCount = rMarkList.GetMarkCount(); + + if( nMarkCount >= 1 ) + { + bool bFound = false; + const SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); + + + for( sal_uInt16 i = 0; i < nMarkCount && !bFound; i++ ) + { + pObj = rMarkList.GetMark( i )->GetMarkedSdrObj(); + sal_uInt32 nInv = pObj->GetObjInventor(); + sal_uInt16 nId = pObj->GetObjIdentifier(); + if( nInv == SdrInventor && nId == OBJ_EDGE ) + { + bFound = true; + SdrEdgeObj* pTmpEdgeObj = (SdrEdgeObj*) pObj; + pEdgeObj = (SdrEdgeObj*) pTmpEdgeObj->Clone(); + + SdrObjConnection& rConn1 = (SdrObjConnection&)pEdgeObj->GetConnection( sal_True ); + SdrObjConnection& rConn2 = (SdrObjConnection&)pEdgeObj->GetConnection( sal_False ); + + rConn1 = pTmpEdgeObj->GetConnection( sal_True ); + rConn2 = pTmpEdgeObj->GetConnection( sal_False ); + + SdrObject* pTmpObj1 = pTmpEdgeObj->GetConnectedNode( sal_True ); + SdrObject* pTmpObj2 = pTmpEdgeObj->GetConnectedNode( sal_False ); + + // potential memory leak here (!). Create SdrObjList only when there is + // not yet one. + if(!pObjList) + { + pObjList = new SdrObjList( pView->GetModel(), NULL ); + } + + if( pTmpObj1 ) + { + SdrObject* pObj1 = pTmpObj1->Clone(); + pObjList->InsertObject( pObj1 ); + pEdgeObj->ConnectToNode( sal_True, pObj1 ); + } + if( pTmpObj2 ) + { + SdrObject* pObj2 = pTmpObj2->Clone(); + pObjList->InsertObject( pObj2 ); + pEdgeObj->ConnectToNode( sal_False, pObj2 ); + } + pObjList->InsertObject( pEdgeObj ); + } + } + } + + if( !pEdgeObj ) + pEdgeObj = new SdrEdgeObj(); + + AdaptSize(); +} + void SvxXConnectionPreview::Paint( const Rectangle& ) { if( pObjList ) |