diff options
author | Armin Le Grand <alg@apache.org> | 2014-02-07 01:26:23 +0000 |
---|---|---|
committer | Armin Le Grand <alg@apache.org> | 2014-02-07 01:26:23 +0000 |
commit | 080a23dfb836bac49d9496fa1460b9dda9138f65 (patch) | |
tree | 643f70d0b0416160b37db5643d96e5a1f3cb34d1 /sd/source | |
parent | a7d6569fdecc36bd5ca093442a9b7aec093637d5 (diff) |
i123922 Refactored D&D and insert picture from file in all apps for all object types to work the same
Notes
Notes:
merged as: 5c75cd95178e3d57e53fee64a9d64023c6d18acf
Diffstat (limited to 'sd/source')
-rw-r--r-- | sd/source/ui/func/fuinsert.cxx | 15 | ||||
-rw-r--r-- | sd/source/ui/view/sdview4.cxx | 105 |
2 files changed, 69 insertions, 51 deletions
diff --git a/sd/source/ui/func/fuinsert.cxx b/sd/source/ui/func/fuinsert.cxx index 0fe881b4f0ee..a10ccd904563 100644 --- a/sd/source/ui/func/fuinsert.cxx +++ b/sd/source/ui/func/fuinsert.cxx @@ -142,8 +142,18 @@ void FuInsertGraphic::DoExecute( SfxRequest& ) { sal_Int8 nAction = DND_ACTION_COPY; SdrObject* pPickObj = mpView->GetEmptyPresentationObject( PRESOBJ_GRAPHIC ); + bool bSelectionReplaced(false); + if( pPickObj ) + { nAction = DND_ACTION_LINK; + } + else if(1 == mpView->GetMarkedObjectCount()) + { + pPickObj = mpView->GetMarkedObjectByIndex(0); + nAction = DND_ACTION_MOVE; + bSelectionReplaced = true; + } Point aPos; Rectangle aRect(aPos, mpWindow->GetOutputSizePixel() ); @@ -158,6 +168,11 @@ void FuInsertGraphic::DoExecute( SfxRequest& ) String aPath(aDlg.GetPath()); pGrafObj->SetGraphicLink(aPath, aFltName); } + + if(bSelectionReplaced && pGrafObj) + { + mpView->MarkObj(pGrafObj, mpView->GetSdrPageView()); + } } } else diff --git a/sd/source/ui/view/sdview4.cxx b/sd/source/ui/view/sdview4.cxx index 139b5686de71..802661d19737 100644 --- a/sd/source/ui/view/sdview4.cxx +++ b/sd/source/ui/view/sdview4.cxx @@ -107,67 +107,70 @@ SdrGrafObj* View::InsertGraphic( const Graphic& rGraphic, sal_Int8& rAction, PickObj(rPos, getHitTolLog(), pPickObj, pPageView); } - if( mnAction == DND_ACTION_LINK && pPickObj && pPV ) - { - const bool bIsGraphic(0 != dynamic_cast< SdrGrafObj* >(pPickObj)); + const bool bIsGraphic(0 != dynamic_cast< SdrGrafObj* >(pPickObj)); - if(bIsGraphic || (pPickObj->IsEmptyPresObj() && !bOnMaster)) // #121603# Do not use pObj, it may be NULL + if(pPickObj && !bIsGraphic && pPickObj->IsClosedObj() && !dynamic_cast< SdrOle2Obj* >(pPickObj)) + { + // fill style change (fill object with graphic), independent of mnAction + // and thus of DND_ACTION_LINK or DND_ACTION_MOVE + if( IsUndoEnabled() ) { - if( IsUndoEnabled() ) - BegUndo(String(SdResId(STR_INSERTGRAPHIC))); - - SdPage* pPage = (SdPage*) pPickObj->GetPage(); - - if( bIsGraphic ) - { - // Das Objekt wird mit der Bitmap gefuellt - pNewGrafObj = (SdrGrafObj*) pPickObj->Clone(); - pNewGrafObj->SetGraphic(rGraphic); - } - else - { - pNewGrafObj = new SdrGrafObj( rGraphic, pPickObj->GetLogicRect() ); - pNewGrafObj->SetEmptyPresObj(sal_True); - } - - if ( pNewGrafObj->IsEmptyPresObj() ) - { - Rectangle aRect( pNewGrafObj->GetLogicRect() ); - pNewGrafObj->AdjustToMaxRect( aRect, sal_False ); - pNewGrafObj->SetOutlinerParaObject(NULL); - pNewGrafObj->SetEmptyPresObj(sal_False); - } + BegUndo(String(SdResId(STR_UNDO_DRAGDROP))); + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pPickObj)); + EndUndo(); + } - if (pPage && pPage->IsPresObj(pPickObj)) - { - // Neues PresObj in die Liste eintragen - pPage->InsertPresObj( pNewGrafObj, PRESOBJ_GRAPHIC ); - pNewGrafObj->SetUserCall(pPickObj->GetUserCall()); - } + SfxItemSet aSet(mpDocSh->GetPool(), XATTR_FILLSTYLE, XATTR_FILLBITMAP); - if (pImageMap) - pNewGrafObj->InsertUserData(new SdIMapInfo(*pImageMap)); + aSet.Put(XFillStyleItem(XFILL_BITMAP)); + aSet.Put(XFillBitmapItem(&mpDocSh->GetPool(), rGraphic)); + pPickObj->SetMergedItemSetAndBroadcast(aSet); + } + else if(DND_ACTION_LINK == mnAction + && pPickObj + && pPV + && (bIsGraphic || (pPickObj->IsEmptyPresObj() && !bOnMaster))) // #121603# Do not use pObj, it may be NULL + { + // hit on SdrGrafObj with wanted new linked graphic (or PresObj placeholder hit) + if( IsUndoEnabled() ) + BegUndo(String(SdResId(STR_INSERTGRAPHIC))); - ReplaceObjectAtView(pPickObj, *pPV, pNewGrafObj); // maybe ReplaceObjectAtView + SdPage* pPage = (SdPage*) pPickObj->GetPage(); - if( IsUndoEnabled() ) - EndUndo(); + if( bIsGraphic ) + { + // Das Objekt wird mit der Bitmap gefuellt + pNewGrafObj = (SdrGrafObj*) pPickObj->Clone(); + pNewGrafObj->SetGraphic(rGraphic); } - else if(pPickObj->IsClosedObj()) + else { - // fill object with graphic - if( IsUndoEnabled() ) - { - BegUndo(String(SdResId(STR_UNDO_DRAGDROP))); - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pPickObj)); - EndUndo(); - } + pNewGrafObj = new SdrGrafObj( rGraphic, pPickObj->GetLogicRect() ); + pNewGrafObj->SetEmptyPresObj(sal_True); + } + + if ( pNewGrafObj->IsEmptyPresObj() ) + { + Rectangle aRect( pNewGrafObj->GetLogicRect() ); + pNewGrafObj->AdjustToMaxRect( aRect, sal_False ); + pNewGrafObj->SetOutlinerParaObject(NULL); + pNewGrafObj->SetEmptyPresObj(sal_False); + } - SfxItemSet aSet(mpDocSh->GetPool(), XATTR_FILLSTYLE, XATTR_FILLBITMAP); - aSet.Put(XFillStyleItem(XFILL_BITMAP)); - aSet.Put(XFillBitmapItem(&mpDocSh->GetPool(), rGraphic)); - pPickObj->SetMergedItemSetAndBroadcast(aSet); + if (pPage && pPage->IsPresObj(pPickObj)) + { + // Neues PresObj in die Liste eintragen + pPage->InsertPresObj( pNewGrafObj, PRESOBJ_GRAPHIC ); + pNewGrafObj->SetUserCall(pPickObj->GetUserCall()); } + + if (pImageMap) + pNewGrafObj->InsertUserData(new SdIMapInfo(*pImageMap)); + + ReplaceObjectAtView(pPickObj, *pPV, pNewGrafObj); // maybe ReplaceObjectAtView + + if( IsUndoEnabled() ) + EndUndo(); } else if ( pPV ) { |