sd/source/ui/func/fuinsert.cxx | 5 +- sd/source/ui/inc/View.hxx | 4 + sd/source/ui/view/sdview5.cxx | 90 ++++++++++++++++++++++++----------------- 3 files changed, 60 insertions(+), 39 deletions(-)
New commits: commit 4fb4ffcc6e13b2544e0ac5578e1b52030e85a295 Author: Radek Doulik <[email protected]> Date: Tue Dec 4 15:56:38 2012 +0100 changed behavior of insert picture - when single graphic object shape is selected, replace the graphic with inserted picture - otherwise proceed as before Change-Id: I767c3ab81abf26c34b612d6aac1f282aa0a53f6c diff --git a/sd/source/ui/func/fuinsert.cxx b/sd/source/ui/func/fuinsert.cxx index 7c53bb3..9333380 100644 --- a/sd/source/ui/func/fuinsert.cxx +++ b/sd/source/ui/func/fuinsert.cxx @@ -138,8 +138,9 @@ void FuInsertGraphic::DoExecute( SfxRequest& ) if( mpViewShell && mpViewShell->ISA(DrawViewShell)) { sal_Int8 nAction = DND_ACTION_COPY; - SdrObject* pPickObj = mpView->GetEmptyPresentationObject( PRESOBJ_GRAPHIC ); - if( pPickObj ) + SdrObject* pPickObj; + + if( ( pPickObj = mpView->GetSelectedSingleObject( mpView->GetPage() ) ) || ( pPickObj = mpView->GetEmptyPresentationObject( PRESOBJ_GRAPHIC ) ) ) nAction = DND_ACTION_LINK; Point aPos; commit 8aee959c430113639685d99285974da87d251d2c Author: Radek Doulik <[email protected]> Date: Tue Dec 4 15:54:24 2012 +0100 refactored GetEmptyPresentationObject, added GetSelectedSingleObject - also extracted part of GetEmptyPresentationObject into new GetPage() method Change-Id: I3002c3fae8236db1e443f0f454158e7298b56d70 diff --git a/sd/source/ui/inc/View.hxx b/sd/source/ui/inc/View.hxx index 7c3fa7d..8c96010 100644 --- a/sd/source/ui/inc/View.hxx +++ b/sd/source/ui/inc/View.hxx @@ -42,6 +42,7 @@ #include "smarttag.hxx" class SdDrawDocument; +class SdPage; class SdrOle2Obj; class SdrGrafObj; class SdrMediaObj; @@ -218,6 +219,9 @@ public: void SetMarkedSegmentsKindPossible( bool bSet ) { bSetMarkedSegmentsKindPossible = bSet; } SdrObject* GetEmptyPresentationObject( PresObjKind eKind ); + SdPage* GetPage(); + SdrObject* GetSelectedSingleObject(SdPage* pPage); + protected: DECL_LINK( OnParagraphInsertedHdl, ::Outliner * ); DECL_LINK( OnParagraphRemovingHdl, ::Outliner * ); diff --git a/sd/source/ui/view/sdview5.cxx b/sd/source/ui/view/sdview5.cxx index fce5e68..b2fadf1 100644 --- a/sd/source/ui/view/sdview5.cxx +++ b/sd/source/ui/view/sdview5.cxx @@ -51,57 +51,73 @@ static bool implIsMultiPresObj( PresObjKind eKind ) } } -SdrObject* View::GetEmptyPresentationObject( PresObjKind eKind ) +SdPage* View::GetPage() { - SdrObject* pEmptyObj = 0; - + SdPage* pPage = NULL; SdrPageView* pPV = GetSdrPageView(); if( pPV ) { - SdPage* pPage = static_cast< SdPage* >( pPV->GetPage() ); - if( pPage && !pPage->IsMasterPage() ) + pPage = static_cast< SdPage* >( pPV->GetPage() ); + } + + return pPage; +} + +// returns selected object in case there's just one object in the selection +SdrObject* View::GetSelectedSingleObject(SdPage* pPage) +{ + SdrObject* pRet = NULL; + if( pPage ) + { + // first try selected shape + if ( AreObjectsMarked() ) { - // first try selected shape - if ( AreObjectsMarked() ) + const SdrMarkList& rMarkList = GetMarkedObjectList(); + + if (rMarkList.GetMarkCount() == 1) { - /********************************************************** - * Is an empty graphic object available? - **********************************************************/ - const SdrMarkList& rMarkList = GetMarkedObjectList(); + SdrMark* pMark = rMarkList.GetMark(0); + pRet = pMark->GetMarkedSdrObj(); + } + } + } - if (rMarkList.GetMarkCount() == 1) - { - SdrMark* pMark = rMarkList.GetMark(0); - SdrObject* pObj = pMark->GetMarkedSdrObj(); + return pRet; +} - if( pObj->IsEmptyPresObj() && implIsMultiPresObj( pPage->GetPresObjKind(pObj) ) ) - pEmptyObj = pObj; - } - } +SdrObject* View::GetEmptyPresentationObject( PresObjKind eKind ) +{ + SdPage* pPage = GetPage(); + SdrObject* pEmptyObj = NULL; - // try to find empty pres obj of same type - if( !pEmptyObj ) + if ( pPage && !pPage->IsMasterPage() ) { + SdrObject* pObj = GetSelectedSingleObject( pPage ); + + if( pObj && pObj->IsEmptyPresObj() && implIsMultiPresObj( pPage->GetPresObjKind(pObj) ) ) + pEmptyObj = pObj; + + // try to find empty pres obj of same type + if( !pEmptyObj ) + { + int nIndex = 1; + do { - int nIndex = 1; - do - { - pEmptyObj = pPage->GetPresObj(eKind, nIndex++ ); - } - while( (pEmptyObj != 0) && (!pEmptyObj->IsEmptyPresObj()) ); + pEmptyObj = pPage->GetPresObj(eKind, nIndex++ ); } + while( (pEmptyObj != 0) && (!pEmptyObj->IsEmptyPresObj()) ); + } - // last try to find empty pres obj of multiple type - if( !pEmptyObj ) - { - const std::list< SdrObject* >& rShapes = pPage->GetPresentationShapeList().getList(); + // last try to find empty pres obj of multiple type + if( !pEmptyObj ) + { + const std::list< SdrObject* >& rShapes = pPage->GetPresentationShapeList().getList(); - for( std::list< SdrObject* >::const_iterator iter( rShapes.begin() ); iter != rShapes.end(); ++iter ) + for( std::list< SdrObject* >::const_iterator iter( rShapes.begin() ); iter != rShapes.end(); ++iter ) + { + if( (*iter)->IsEmptyPresObj() && implIsMultiPresObj(pPage->GetPresObjKind(*iter)) ) { - if( (*iter)->IsEmptyPresObj() && implIsMultiPresObj(pPage->GetPresObjKind(*iter)) ) - { - pEmptyObj = (*iter); - break; - } + pEmptyObj = (*iter); + break; } } } _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
