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 | |
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
-rw-r--r-- | sc/source/ui/drawfunc/fuins1.cxx | 35 | ||||
-rw-r--r-- | sc/source/ui/inc/drawview.hxx | 10 | ||||
-rw-r--r-- | sc/source/ui/inc/viewfunc.hxx | 8 | ||||
-rw-r--r-- | sc/source/ui/view/drawview.cxx | 38 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/view/viewfun3.cxx | 73 | ||||
-rw-r--r-- | sc/source/ui/view/viewfun7.cxx | 80 | ||||
-rw-r--r-- | sd/source/ui/func/fuinsert.cxx | 15 | ||||
-rw-r--r-- | sd/source/ui/view/sdview4.cxx | 105 | ||||
-rw-r--r-- | sw/inc/fesh.hxx | 2 | ||||
-rw-r--r-- | sw/sdi/drawsh.sdi | 4 | ||||
-rw-r--r-- | sw/source/core/frmedt/fecopy.cxx | 52 | ||||
-rw-r--r-- | sw/source/ui/dochdl/swdtflvr.cxx | 98 | ||||
-rw-r--r-- | sw/source/ui/inc/drawsh.hxx | 4 | ||||
-rw-r--r-- | sw/source/ui/inc/view.hxx | 1 | ||||
-rw-r--r-- | sw/source/ui/inc/wrtsh.hxx | 4 | ||||
-rw-r--r-- | sw/source/ui/shells/drawsh.cxx | 134 | ||||
-rw-r--r-- | sw/source/ui/shells/grfsh.cxx | 7 | ||||
-rw-r--r-- | sw/source/ui/uiview/view2.cxx | 57 | ||||
-rw-r--r-- | sw/source/ui/wrtsh/wrtsh1.cxx | 41 |
20 files changed, 567 insertions, 205 deletions
diff --git a/sc/source/ui/drawfunc/fuins1.cxx b/sc/source/ui/drawfunc/fuins1.cxx index 274f1004ab0e..ed4c5e027301 100644 --- a/sc/source/ui/drawfunc/fuins1.cxx +++ b/sc/source/ui/drawfunc/fuins1.cxx @@ -45,6 +45,7 @@ #include "scresid.hxx" #include "progress.hxx" #include "sc.hrc" +#include "globstr.hrc" @@ -147,11 +148,41 @@ void lcl_InsertGraphic( const Graphic& rGraphic, const String& rFileName, const String& rFilterName, sal_Bool bAsLink, sal_Bool bApi, ScTabViewShell* pViewSh, Window* pWindow, SdrView* pView ) { + ScDrawView* pDrawView = pViewSh->GetScDrawView(); + + // #123922# check if an existing object is selected; if yes, evtl. replace + // the graphic for a SdrGraphObj (including link state updates) or adapt the fill + // style for other objects + if(pDrawView && 1 == pDrawView->GetMarkedObjectCount()) + { + SdrObject* pPickObj = pDrawView->GetMarkedObjectByIndex(0); + + if(pPickObj) + { + //sal_Int8 nAction(DND_ACTION_MOVE); + //Point aPos; + const String aBeginUndo(ScGlobal::GetRscString(STR_UNDO_DRAGDROP)); + const String aEmpty; + + SdrObject* pResult = pDrawView->ApplyGraphicToObject( + *pPickObj, + rGraphic, + aBeginUndo, + bAsLink ? rFileName : aEmpty, + bAsLink ? rFilterName : aEmpty); + + if(pResult) + { + // we are done; mark the modified/new object + pDrawView->MarkObj(pResult, pDrawView->GetSdrPageView()); + return; + } + } + } + // #74778# set the size so the graphic has its original pixel size // at 100% view scale (as in SetMarkedOriginalSize), // instead of respecting the current view scale - - ScDrawView* pDrawView = pViewSh->GetScDrawView(); MapMode aSourceMap = rGraphic.GetPrefMapMode(); MapMode aDestMap( MAP_100TH_MM ); if ( aSourceMap.GetMapUnit() == MAP_PIXEL && pDrawView ) diff --git a/sc/source/ui/inc/drawview.hxx b/sc/source/ui/inc/drawview.hxx index ddba58b693cb..e70d4ddd84e1 100644 --- a/sc/source/ui/inc/drawview.hxx +++ b/sc/source/ui/inc/drawview.hxx @@ -158,6 +158,16 @@ public: SdrObject* GetObjectByName(const String& rName); sal_Bool GetObjectIsMarked( SdrObject * pObject ); sal_Bool SelectCurrentViewObject( const String& rName ); + + // #123922# helper which checks if a Graphic may be appied to an existing + // SdrObject; if it's a SdrGrafObj the fill will be replaced. If it's a + // fillable, non-OLE SdrObject, the FillStyle will be adapted + SdrObject* ApplyGraphicToObject( + SdrObject& rHitObject, + const Graphic& rGraphic, + const String& rBeginUndoText, + const String& rFile, + const String& rFilter); }; diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx index 948bfa55525b..b937116b133b 100644 --- a/sc/source/ui/inc/viewfunc.hxx +++ b/sc/source/ui/inc/viewfunc.hxx @@ -127,9 +127,9 @@ public: void PasteDraw( const Point& rLogicPos, SdrModel* pModel, sal_Bool bGroup = sal_False, sal_Bool bSameDocClipboard = sal_False ); - sal_Bool PasteOnDrawObject( const ::com::sun::star::uno::Reference< - ::com::sun::star::datatransfer::XTransferable >& rxTransferable, - SdrObject* pHitObj, sal_Bool bLink ); + sal_Bool PasteOnDrawObjectLinked( + const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& rxTransferable, + SdrObject& rHitObj); sal_Bool PasteDataFormat( sal_uLong nFormatId, const ::com::sun::star::uno::Reference< @@ -150,8 +150,6 @@ public: sal_Bool PasteDDE( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& rxTransferable ); - sal_Bool ApplyGraphicToObject( SdrObject* pObject, const Graphic& rGraphic ); - void InsertBookmark( const String& rDescription, const String& rURL, SCCOL nPosX, SCROW nPosY, const String* pTarget = NULL, sal_Bool bTryReplace = sal_False ); diff --git a/sc/source/ui/view/drawview.cxx b/sc/source/ui/view/drawview.cxx index 33041a104891..d539a84fd342 100644 --- a/sc/source/ui/view/drawview.cxx +++ b/sc/source/ui/view/drawview.cxx @@ -43,6 +43,7 @@ #include <sfx2/bindings.hxx> #include <sfx2/viewfrm.hxx> #include <svx/sdrundomanager.hxx> +#include <svx/xbtmpit.hxx> #include "drawview.hxx" #include "global.hxx" @@ -976,4 +977,41 @@ SdrUndoManager* ScDrawView::getSdrUndoManagerForEnhancedTextEdit() const return pDoc ? dynamic_cast< SdrUndoManager* >(pDoc->GetUndoManager()) : 0; } +// #123922# helper to apply a Graphic to an existing SdrObject +SdrObject* ScDrawView::ApplyGraphicToObject( + SdrObject& rHitObject, + const Graphic& rGraphic, + const String& rBeginUndoText, + const String& rFile, + const String& rFilter) +{ + if(dynamic_cast< SdrGrafObj* >(&rHitObject)) + { + SdrGrafObj* pNewGrafObj = (SdrGrafObj*)rHitObject.Clone(); + + pNewGrafObj->SetGraphic(rGraphic); + BegUndo(rBeginUndoText); + ReplaceObjectAtView(&rHitObject, *GetSdrPageView(), pNewGrafObj); + + // set in all cases - the Clone() will have copied an existing link (!) + pNewGrafObj->SetGraphicLink( rFile, rFilter ); + + EndUndo(); + return pNewGrafObj; + } + else if(rHitObject.IsClosedObj() && !dynamic_cast< SdrOle2Obj* >(&rHitObject)) + { + AddUndo(new SdrUndoAttrObj(rHitObject)); + + SfxItemSet aSet(GetModel()->GetItemPool(), XATTR_FILLSTYLE, XATTR_FILLBITMAP); + + aSet.Put(XFillStyleItem(XFILL_BITMAP)); + aSet.Put(XFillBitmapItem(String(), rGraphic)); + rHitObject.SetMergedItemSetAndBroadcast(aSet); + return &rHitObject; + } + + return false; +} + // eof diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 4b5c6dccf9ad..faec587beeeb 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -4283,8 +4283,8 @@ sal_Int8 ScGridWindow::ExecuteDrop( const ExecuteDropEvent& rEvt ) if ( pHitObj && bIsLink ) { // dropped on drawing object - // PasteOnDrawObject checks for valid formats - if ( pViewData->GetView()->PasteOnDrawObject( rEvt.maDropEvent.Transferable, pHitObj, sal_True ) ) + // PasteOnDrawObjectLinked checks for valid formats + if ( pViewData->GetView()->PasteOnDrawObjectLinked( rEvt.maDropEvent.Transferable, *pHitObj ) ) return rEvt.mnAction; } diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx index 664d45b53ddf..191a3ae176f2 100644 --- a/sc/source/ui/view/viewfun3.cxx +++ b/sc/source/ui/view/viewfun3.cxx @@ -820,41 +820,66 @@ sal_Bool ScViewFunc::PasteFromSystem( sal_uLong nFormatId, sal_Bool bApi ) //---------------------------------------------------------------------------- // P A S T E -sal_Bool ScViewFunc::PasteOnDrawObject( const uno::Reference<datatransfer::XTransferable>& rxTransferable, - SdrObject* pHitObj, sal_Bool bLink ) +sal_Bool ScViewFunc::PasteOnDrawObjectLinked( + const uno::Reference<datatransfer::XTransferable>& rxTransferable, + SdrObject& rHitObj) { - sal_Bool bRet = sal_False; - if ( bLink ) + TransferableDataHelper aDataHelper( rxTransferable ); + + if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_SVXB ) ) { - TransferableDataHelper aDataHelper( rxTransferable ); - if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_SVXB ) ) + SotStorageStreamRef xStm; + ScDrawView* pScDrawView = GetScDrawView(); + + if( pScDrawView && aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_SVXB, xStm ) ) { - SotStorageStreamRef xStm; - if( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_SVXB, xStm ) ) + Graphic aGraphic; + + *xStm >> aGraphic; + + const String aEmpty; + const String aBeginUndo(ScGlobal::GetRscString(STR_UNDO_DRAGDROP)); + + if(pScDrawView->ApplyGraphicToObject( rHitObj, aGraphic, aBeginUndo, aEmpty, aEmpty )) { - Graphic aGraphic; - *xStm >> aGraphic; - bRet = ApplyGraphicToObject( pHitObj, aGraphic ); + return sal_True; } } - else if ( aDataHelper.HasFormat( SOT_FORMAT_GDIMETAFILE ) ) - { - GDIMetaFile aMtf; - if( aDataHelper.GetGDIMetaFile( FORMAT_GDIMETAFILE, aMtf ) ) - bRet = ApplyGraphicToObject( pHitObj, Graphic(aMtf) ); - } - else if ( aDataHelper.HasFormat( SOT_FORMAT_BITMAP ) || aDataHelper.HasFormat( SOT_FORMATSTR_ID_PNG ) ) + } + else if ( aDataHelper.HasFormat( SOT_FORMAT_GDIMETAFILE ) ) + { + GDIMetaFile aMtf; + ScDrawView* pScDrawView = GetScDrawView(); + + if( pScDrawView && aDataHelper.GetGDIMetaFile( FORMAT_GDIMETAFILE, aMtf ) ) { - BitmapEx aBmpEx; - if( aDataHelper.GetBitmapEx( FORMAT_BITMAP, aBmpEx ) ) - bRet = ApplyGraphicToObject( pHitObj, Graphic(aBmpEx) ); + const String aEmpty; + const String aBeginUndo(ScGlobal::GetRscString(STR_UNDO_DRAGDROP)); + + if(pScDrawView->ApplyGraphicToObject( rHitObj, Graphic(aMtf), aBeginUndo, aEmpty, aEmpty )) + { + return sal_True; + } } } - else + else if ( aDataHelper.HasFormat( SOT_FORMAT_BITMAP ) || aDataHelper.HasFormat( SOT_FORMATSTR_ID_PNG ) ) { - // ham' wa noch nich + BitmapEx aBmpEx; + ScDrawView* pScDrawView = GetScDrawView(); + + if( pScDrawView && aDataHelper.GetBitmapEx( FORMAT_BITMAP, aBmpEx ) ) + { + const String aEmpty; + const String aBeginUndo(ScGlobal::GetRscString(STR_UNDO_DRAGDROP)); + + if(pScDrawView->ApplyGraphicToObject( rHitObj, Graphic(aBmpEx), aBeginUndo, aEmpty, aEmpty )) + { + return sal_True; + } + } } - return bRet; + + return sal_False; } sal_Bool lcl_SelHasAttrib( ScDocument* pDoc, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, diff --git a/sc/source/ui/view/viewfun7.cxx b/sc/source/ui/view/viewfun7.cxx index 12c3fcd64741..6c1c7ceb6c3a 100644 --- a/sc/source/ui/view/viewfun7.cxx +++ b/sc/source/ui/view/viewfun7.cxx @@ -390,6 +390,38 @@ sal_Bool ScViewFunc::PasteGraphic( const Point& rPos, const Graphic& rGraphic, MakeDrawLayer(); ScDrawView* pScDrawView = GetScDrawView(); + // #123922# check if the drop was over an existing object; if yes, evtl. replace + // the graphic for a SdrGraphObj (including link state updates) or adapt the fill + // style for other objects + if(pScDrawView) + { + SdrObject* pPickObj = 0; + SdrPageView* pPageView = pScDrawView->GetSdrPageView(); + + if(pPageView) + { + pScDrawView->PickObj(rPos, pScDrawView->getHitTolLog(), pPickObj, pPageView); + } + + if(pPickObj) + { + const String aBeginUndo(ScGlobal::GetRscString(STR_UNDO_DRAGDROP)); + SdrObject* pResult = pScDrawView->ApplyGraphicToObject( + *pPickObj, + rGraphic, + aBeginUndo, + rFile, + rFilter); + + if(pResult) + { + // we are done; mark the modified/new object + pScDrawView->MarkObj(pResult, pScDrawView->GetSdrPageView()); + return sal_True; + } + } + } + Point aPos( rPos ); Window* pWin = GetActiveWin(); MapMode aSourceMap = rGraphic.GetPrefMapMode(); @@ -411,7 +443,6 @@ sal_Bool ScViewFunc::PasteGraphic( const Point& rPos, const Graphic& rGraphic, aPos.X() -= aSize.Width(); GetViewData()->GetViewShell()->SetDrawShell( sal_True ); - Rectangle aRect(aPos, aSize); SdrGrafObj* pGrafObj = new SdrGrafObj(rGraphic, aRect); @@ -435,50 +466,3 @@ sal_Bool ScViewFunc::PasteGraphic( const Point& rPos, const Graphic& rGraphic, return sal_True; } -sal_Bool ScViewFunc::ApplyGraphicToObject( SdrObject* pPickObj, const Graphic& rGraphic ) -{ - sal_Bool bRet = sal_False; - SdrGrafObj* pNewGrafObj = NULL; - - ScDrawView* pScDrawView = GetScDrawView(); - if ( pScDrawView && pPickObj ) - { - /********************************************************************** - * Objekt neu attributieren - **********************************************************************/ - SdrPageView* pPV = pScDrawView->GetSdrPageView(); - if (pPickObj->ISA(SdrGrafObj)) - { - /****************************************************************** - * Das Graphik-Objekt bekommt eine neue Graphik - ******************************************************************/ - pNewGrafObj = (SdrGrafObj*) pPickObj->Clone(); - pNewGrafObj->SetGraphic(rGraphic); - - pScDrawView->BegUndo(ScGlobal::GetRscString(STR_UNDO_DRAGDROP)); - pScDrawView->ReplaceObjectAtView(pPickObj, *pPV, pNewGrafObj); - pScDrawView->EndUndo(); - - bRet = sal_True; - } - else if (pPickObj->IsClosedObj() && !pPickObj->ISA(SdrOle2Obj)) - { - /****************************************************************** - * Das Objekt wird mit der Graphik gefuellt - ******************************************************************/ - pScDrawView->AddUndo(new SdrUndoAttrObj(*pPickObj)); - - SfxItemSet aSet( pScDrawView->GetModel()->GetItemPool(), - XATTR_FILLSTYLE, XATTR_FILLBITMAP ); - aSet.Put(XFillStyleItem(XFILL_BITMAP)); - aSet.Put(XFillBitmapItem(String(), rGraphic)); - - pPickObj->SetMergedItemSetAndBroadcast(aSet); - - bRet = sal_True; - } - } - return bRet; -} - - 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 ) { diff --git a/sw/inc/fesh.hxx b/sw/inc/fesh.hxx index 221aa1f86646..ce8859a1ef79 100644 --- a/sw/inc/fesh.hxx +++ b/sw/inc/fesh.hxx @@ -536,7 +536,7 @@ public: sal_Bool GetDrawObjGraphic( sal_uLong nFmt, Graphic& rGrf ) const; void Paste( SvStream& rStm, sal_uInt16 nAction, const Point* pPt = 0 ); - sal_Bool Paste( const Graphic &rGrf ); + bool Paste( const Graphic &rGrf, const String& rURL ); sal_Bool Paste( SotDataObject& rObj, const Point& rPt ); sal_Bool IsAlignPossible() const; diff --git a/sw/sdi/drawsh.sdi b/sw/sdi/drawsh.sdi index 17c8ea8c95ee..d6589a2aeb1c 100644 --- a/sw/sdi/drawsh.sdi +++ b/sw/sdi/drawsh.sdi @@ -396,7 +396,9 @@ interface TextDraw : TextDrawBase ] SID_INSERT_GRAPHIC [ - StateMethod = StateDisableItems ; + // #123922# Add Exec and State methods for the case where Graphic DrawObjects are selected (SdrGrafObj) + ExecMethod = Execute ; + StateMethod = GetState ; ] SID_TWAIN_SELECT [ diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx index 4ecb78f62d88..2ad670677769 100644 --- a/sw/source/core/frmedt/fecopy.cxx +++ b/sw/source/core/frmedt/fecopy.cxx @@ -83,7 +83,7 @@ #include <pagedesc.hxx> #include <mvsave.hxx> #include <vcl/virdev.hxx> - +#include <svx/svdundo.hxx> using namespace ::com::sun::star; @@ -1459,7 +1459,12 @@ void SwFEShell::Paste( SvStream& rStrm, sal_uInt16 nAction, const Point* pPt ) pFmt = GetDoc()->Insert( *GetCrsr(), *pNewObj, &aFrmSet, NULL ); } else - pView->ReplaceObjectAtView( pOldObj, *Imp()->GetPageView(), pNewObj, sal_True ); + { + // #123922# for handling MasterObject and virtual ones correctly, SW + // wants us to call ReplaceObject at the page, but that also + // triggers the same assertion (I tried it), so stay at the view method + pView->ReplaceObjectAtView(pOldObj, *Imp()->GetPageView(), pNewObj); + } } break; @@ -1564,23 +1569,52 @@ void SwFEShell::Paste( SvStream& rStrm, sal_uInt16 nAction, const Point* pPt ) delete pModel; } -sal_Bool SwFEShell::Paste( const Graphic &rGrf ) +bool SwFEShell::Paste( const Graphic &rGrf, const String& rURL ) { SET_CURR_SHELL( this ); - SdrObject* pObj; + SdrObject* pObj = 0; SdrView *pView = Imp()->GetDrawView(); sal_Bool bRet = 1 == pView->GetMarkedObjectList().GetMarkCount() && (pObj = pView->GetMarkedObjectList().GetMark( 0 )->GetMarkedSdrObj())->IsClosedObj() && !pObj->ISA( SdrOle2Obj ); - if( bRet ) + if( bRet && pObj ) { - SfxItemSet aSet(GetAttrPool(), XATTR_FILLSTYLE, XATTR_FILLBITMAP); + // #123922# added code to handle the two cases of SdrGrafObj and a fillable, non- + // OLE object in focus + SdrObject* pResult = pObj; + + if(dynamic_cast< SdrGrafObj* >(pObj)) + { + SdrGrafObj* pNewGrafObj = (SdrGrafObj*)pObj->Clone(); + + pNewGrafObj->SetGraphic(rGrf); + + // #123922# for handling MasterObject and virtual ones correctly, SW + // wants us to call ReplaceObject at the page, but that also + // triggers the same assertion (I tried it), so stay at the view method + pView->ReplaceObjectAtView(pObj, *pView->GetSdrPageView(), pNewGrafObj); + + // set in all cases - the Clone() will have copied an existing link (!) + pNewGrafObj->SetGraphicLink(rURL, String()); - aSet.Put(XFillStyleItem(XFILL_BITMAP)); - aSet.Put(XFillBitmapItem(aEmptyStr, rGrf)); - pView->SetAttributes(aSet, false); + pResult = pNewGrafObj; + } + else + { + pView->AddUndo(new SdrUndoAttrObj(*pObj)); + + SfxItemSet aSet(pView->GetModel()->GetItemPool(), XATTR_FILLSTYLE, XATTR_FILLBITMAP); + + aSet.Put(XFillStyleItem(XFILL_BITMAP)); + aSet.Put(XFillBitmapItem(String(), rGrf)); + pObj->SetMergedItemSetAndBroadcast(aSet); + } + + // we are done; mark the modified/new object + pView->MarkObj(pResult, pView->GetSdrPageView()); } + return bRet; } diff --git a/sw/source/ui/dochdl/swdtflvr.cxx b/sw/source/ui/dochdl/swdtflvr.cxx index 60192d038d85..6b5d98b5bd29 100644 --- a/sw/source/ui/dochdl/swdtflvr.cxx +++ b/sw/source/ui/dochdl/swdtflvr.cxx @@ -1999,7 +1999,7 @@ int SwTransferable::_PasteTargetURL( TransferableDataHelper& rData, case SW_PASTESDR_SETATTR: if( rSh.IsObjSelected() ) - rSh.Paste( aGrf ); + rSh.Paste( aGrf, String() ); else if( OBJCNT_GRF == rSh.GetObjCntTypeOfSelection() ) rSh.ReRead( sURL, aEmptyStr, &aGrf ); else @@ -2272,7 +2272,7 @@ int SwTransferable::_PasteSdrFormat( TransferableDataHelper& rData, int SwTransferable::_PasteGrf( TransferableDataHelper& rData, SwWrtShell& rSh, sal_uLong nFmt, sal_uInt16 nAction, const Point* pPt, - sal_uInt8 nActionFlags, sal_Int8 /* nDropAction */, bool bNeedToSelectBeforePaste) + sal_uInt8 nActionFlags, sal_Int8 nDropAction, bool bNeedToSelectBeforePaste) { int nRet = 0; @@ -2372,52 +2372,82 @@ int SwTransferable::_PasteGrf( TransferableDataHelper& rData, SwWrtShell& rSh, if( nRet ) { String sURL; - if( rSh.GetView().GetDocShell()->ISA(SwWebDocShell) ) + + if( rSh.GetView().GetDocShell()->ISA(SwWebDocShell) + // #123922# if link action is noted, also take URL + || DND_ACTION_LINK == nDropAction) + { sURL = aBkmk.GetURL(); + } switch( nAction ) { - case SW_PASTESDR_INSERT: - SwTransferable::SetSelInShell( rSh, sal_False, pPt ); - rSh.Insert( sURL, aEmptyStr, aGrf ); - break; + case SW_PASTESDR_INSERT: + { + SwTransferable::SetSelInShell( rSh, sal_False, pPt ); + rSh.Insert( sURL, aEmptyStr, aGrf ); + break; + } - case SW_PASTESDR_REPLACE: - if( rSh.IsObjSelected() ) + case SW_PASTESDR_REPLACE: { - rSh.ReplaceSdrObj( sURL, aEmptyStr, &aGrf ); - Point aPt( pPt ? *pPt : rSh.GetCrsrDocPos() ); - SwTransferable::SetSelInShell( rSh, sal_True, &aPt ); + if( rSh.IsObjSelected() ) + { + // #123922# for D&D on draw objects, do for now the same for + // SW_PASTESDR_REPLACE (D&D) as for SW_PASTESDR_SETATTR (D&D and + // CTRL+SHIFT). The code below replaces the draw object with + // a writer graphic; maybe this is an option later again if wanted + rSh.Paste( aGrf, sURL ); + + // rSh.ReplaceSdrObj( sURL, aEmptyStr, &aGrf ); + // Point aPt( pPt ? *pPt : rSh.GetCrsrDocPos() ); + // SwTransferable::SetSelInShell( rSh, sal_True, &aPt ); + } + else + { + // set graphic at writer graphic without link + rSh.ReRead( sURL, aEmptyStr, &aGrf ); + } + + break; } - else - rSh.ReRead( sURL, aEmptyStr, &aGrf ); - break; - case SW_PASTESDR_SETATTR: - if( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK == nFmt ) + case SW_PASTESDR_SETATTR: { - if( rSh.IsFrmSelected() ) + if( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK == nFmt ) { - SfxItemSet aSet( rSh.GetAttrPool(), RES_URL, RES_URL ); - rSh.GetFlyFrmAttr( aSet ); - SwFmtURL aURL( (SwFmtURL&)aSet.Get( RES_URL ) ); - aURL.SetURL( aBkmk.GetURL(), sal_False ); - aSet.Put( aURL ); - rSh.SetFlyFrmAttr( aSet ); + if( rSh.IsFrmSelected() ) + { + SfxItemSet aSet( rSh.GetAttrPool(), RES_URL, RES_URL ); + rSh.GetFlyFrmAttr( aSet ); + SwFmtURL aURL( (SwFmtURL&)aSet.Get( RES_URL ) ); + aURL.SetURL( aBkmk.GetURL(), sal_False ); + aSet.Put( aURL ); + rSh.SetFlyFrmAttr( aSet ); + } } + else if( rSh.IsObjSelected() ) + { + // set as attribute at DrawObject + rSh.Paste( aGrf, sURL ); + } + else if( OBJCNT_GRF == rSh.GetObjCntTypeOfSelection() ) + { + // set as linked graphic at writer graphic frame + rSh.ReRead( sURL, aEmptyStr, &aGrf ); + } + else + { + SwTransferable::SetSelInShell( rSh, sal_False, pPt ); + rSh.Insert( aBkmk.GetURL(), aEmptyStr, aGrf ); + } + break; } - else if( rSh.IsObjSelected() ) - rSh.Paste( aGrf ); - else if( OBJCNT_GRF == rSh.GetObjCntTypeOfSelection() ) - rSh.ReRead( sURL, aEmptyStr, &aGrf ); - else + default: { - SwTransferable::SetSelInShell( rSh, sal_False, pPt ); - rSh.Insert( aBkmk.GetURL(), aEmptyStr, aGrf ); + nRet = 0; + break; } - break; - default: - nRet = 0; } } diff --git a/sw/source/ui/inc/drawsh.hxx b/sw/source/ui/inc/drawsh.hxx index 5fc67a789d4f..8670afe68332 100644 --- a/sw/source/ui/inc/drawsh.hxx +++ b/sw/source/ui/inc/drawsh.hxx @@ -43,6 +43,10 @@ public: void ExecFormText(SfxRequest& rReq); void GetFormTextState(SfxItemSet& rSet); + + // #123922# added helper methods to handle applying graphic data to draw objects + SdrObject* IsSingleFillableNonOLESelected(); + void InsertPictureFromFile(SdrObject& rObject); }; #endif diff --git a/sw/source/ui/inc/view.hxx b/sw/source/ui/inc/view.hxx index 315ed532b94f..83fce290a2af 100644 --- a/sw/source/ui/inc/view.hxx +++ b/sw/source/ui/inc/view.hxx @@ -372,6 +372,7 @@ class SW_DLLPUBLIC SwView: public SfxViewShell SW_DLLPRIVATE virtual void Move(); +public: // #123922# Needs to be called from a 2nd place now as a helper method SW_DLLPRIVATE sal_Bool InsertGraphicDlg( SfxRequest& ); protected: diff --git a/sw/source/ui/inc/wrtsh.hxx b/sw/source/ui/inc/wrtsh.hxx index a3e3116a93f5..5cde385f9f2e 100644 --- a/sw/source/ui/inc/wrtsh.hxx +++ b/sw/source/ui/inc/wrtsh.hxx @@ -312,7 +312,7 @@ typedef sal_Bool (SwWrtShell:: *FNSimpleMove)(); void InsertColumnBreak(); void InsertFootnote(const String &, sal_Bool bEndNote = sal_False, sal_Bool bEdit = sal_True ); void SplitNode( sal_Bool bAutoFormat = sal_False, sal_Bool bCheckTableStart = sal_True ); - sal_Bool CanInsert(); + bool CanInsert(); // Verzeichnisse void InsertTableOf(const SwTOXBase& rTOX, const SfxItemSet* pSet = 0); @@ -598,7 +598,7 @@ private: SW_DLLPRIVATE long Ignore(const Point *, sal_Bool bProp=sal_False ); SW_DLLPRIVATE void LeaveExtSel() { bSelWrd = bSelLn = sal_False;} - SW_DLLPRIVATE sal_Bool _CanInsert(); + SW_DLLPRIVATE bool _CanInsert(); SW_DLLPRIVATE sal_Bool GoStart(sal_Bool KeepArea = sal_False, sal_Bool * = 0, sal_Bool bSelect = sal_False, sal_Bool bDontMoveRegion = sal_False); diff --git a/sw/source/ui/shells/drawsh.cxx b/sw/source/ui/shells/drawsh.cxx index 234cf7a97df2..e77f2931aa93 100644 --- a/sw/source/ui/shells/drawsh.cxx +++ b/sw/source/ui/shells/drawsh.cxx @@ -51,6 +51,11 @@ #include <svx/xtable.hxx> #include <sfx2/sidebar/EnumContext.hxx> #include <svx/svdoashp.hxx> +#include <svx/svdoole2.hxx> +#include <sfx2/opengrf.hxx> +#include <svx/svdograf.hxx> +#include <svx/svdundo.hxx> +#include <svx/xbtmpit.hxx> #include "swundo.hxx" #include "wrtsh.hxx" @@ -85,6 +90,105 @@ TYPEINIT1(SwDrawShell,SwDrawBaseShell) --------------------------------------------------------------------*/ +// #123922# check as the name implies +SdrObject* SwDrawShell::IsSingleFillableNonOLESelected() +{ + SwWrtShell &rSh = GetShell(); + SdrView* pSdrView = rSh.GetDrawView(); + + if(!pSdrView) + { + return 0; + } + + if(1 != pSdrView->GetMarkedObjectCount()) + { + return 0; + } + + SdrObject* pPickObj = pSdrView->GetMarkedObjectByIndex(0); + + if(!pPickObj) + { + return 0; + } + + if(!pPickObj->IsClosedObj()) + { + return 0; + } + + if(dynamic_cast< SdrOle2Obj* >(pPickObj)) + { + return 0; + } + + return pPickObj; +} + +// #123922# insert given graphic data dependent of the object type in focus +void SwDrawShell::InsertPictureFromFile(SdrObject& rObject) +{ + SwWrtShell &rSh = GetShell(); + SdrView* pSdrView = rSh.GetDrawView(); + + if(pSdrView) + { + SvxOpenGraphicDialog aDlg(SW_RESSTR(STR_INSERT_GRAPHIC)); + + if(GRFILTER_OK == aDlg.Execute()) + { + Graphic aGraphic; + int nError(aDlg.GetGraphic(aGraphic)); + + if(GRFILTER_OK == nError) + { + const bool bAsLink(aDlg.IsAsLink()); + SdrObject* pResult = &rObject; + + rSh.StartUndo(UNDO_PASTE_CLIPBOARD); + + if(dynamic_cast< SdrGrafObj* >(&rObject)) + { + SdrGrafObj* pNewGrafObj = (SdrGrafObj*)rObject.Clone(); + + pNewGrafObj->SetGraphic(aGraphic); + + // #123922# for handling MasterObject and virtual ones correctly, SW + // wants us to call ReplaceObject at the page, but that also + // triggers the same assertion (I tried it), so stay at the view method + pSdrView->ReplaceObjectAtView(&rObject, *pSdrView->GetSdrPageView(), pNewGrafObj); + + // set in all cases - the Clone() will have copied an existing link (!) + pNewGrafObj->SetGraphicLink( + bAsLink ? aDlg.GetPath() : String(), + bAsLink ? aDlg.GetCurrentFilter() : String()); + + pResult = pNewGrafObj; + } + else // if(rObject.IsClosedObj() && !dynamic_cast< SdrOle2Obj* >(&rObject)) + { + pSdrView->AddUndo(new SdrUndoAttrObj(rObject)); + + SfxItemSet aSet(pSdrView->GetModel()->GetItemPool(), XATTR_FILLSTYLE, XATTR_FILLBITMAP); + + aSet.Put(XFillStyleItem(XFILL_BITMAP)); + aSet.Put(XFillBitmapItem(String(), aGraphic)); + rObject.SetMergedItemSetAndBroadcast(aSet); + } + + rSh.EndUndo( UNDO_END ); + + if(pResult) + { + // we are done; mark the modified/new object + pSdrView->MarkObj(pResult, pSdrView->GetSdrPageView()); + } + } + } + } +} + void SwDrawShell::Execute(SfxRequest &rReq) { SwWrtShell &rSh = GetShell(); @@ -285,6 +389,21 @@ void SwDrawShell::Execute(SfxRequest &rReq) rReq.Ignore (); break; + case SID_INSERT_GRAPHIC: + { + // #123922# check if we can do something + SdrObject* pObj = IsSingleFillableNonOLESelected(); + + if(pObj) + { + // ...and if yes, do something + InsertPictureFromFile(*pObj); + bool bBla = true; + } + + break; + } + default: DBG_ASSERT(!this, "falscher Dispatcher"); return; @@ -299,8 +418,6 @@ void SwDrawShell::Execute(SfxRequest &rReq) Beschreibung: --------------------------------------------------------------------*/ - - void SwDrawShell::GetState(SfxItemSet& rSet) { SwWrtShell &rSh = GetShell(); @@ -383,6 +500,19 @@ void SwDrawShell::GetState(SfxItemSet& rSet) } } break; + + case SID_INSERT_GRAPHIC: + { + // #123922# check if we can do something + SdrObject* pObj = IsSingleFillableNonOLESelected(); + + if(!pObj) + { + rSet.DisableItem(nWhich); + } + + break; + } } nWhich = aIter.NextWhich(); } diff --git a/sw/source/ui/shells/grfsh.cxx b/sw/source/ui/shells/grfsh.cxx index 4dda12e079ce..b6ffc2dcd54e 100644 --- a/sw/source/ui/shells/grfsh.cxx +++ b/sw/source/ui/shells/grfsh.cxx @@ -113,6 +113,13 @@ void SwGrfShell::Execute(SfxRequest &rReq) } break; case SID_INSERT_GRAPHIC: + { + // #123922# implement slot independent from the two below to + // bring up the insert graphic dialog and associated actions + SwView& rView = GetView(); + rReq.SetReturnValue(SfxBoolItem(nSlot, rView.InsertGraphicDlg( rReq ))); + break; + } case FN_FORMAT_GRAFIC_DLG: case FN_DRAW_WRAP_DLG: { diff --git a/sw/source/ui/uiview/view2.cxx b/sw/source/ui/uiview/view2.cxx index b9e39e6cde39..4630ce7becfa 100644 --- a/sw/source/ui/uiview/view2.cxx +++ b/sw/source/ui/uiview/view2.cxx @@ -225,27 +225,44 @@ int SwView::InsertGraphic( const String &rPath, const String &rFilter, if( GRFILTER_OK == nRes ) { SwFlyFrmAttrMgr aFrmMgr( sal_True, GetWrtShellPtr(), FRMMGR_TYPE_GRF ); - SwWrtShell &rSh = GetWrtShell(); - rSh.StartAction(); - if( bLink ) - { - SwDocShell* pDocSh = GetDocShell(); - INetURLObject aTemp( - pDocSh->HasName() ? - pDocSh->GetMedium()->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) : - rtl::OUString()); - String sURL = URIHelper::SmartRel2Abs( - aTemp, rPath, URIHelper::GetMaybeFileHdl() ); + // #123922# determine if we really want to insert or replace the graphic at a selected object + const bool bReplaceMode(rSh.HasSelection() && nsSelectionType::SEL_FRM == rSh.GetSelectionType()); - rSh.Insert( sURL, - rFilter, aGrf, &aFrmMgr, bRule ); + if(bReplaceMode) + { + // #123922# Do same as in D&D, ReRead graphic and all is done + rSh.ReRead( + bLink ? rPath : String(), + bLink ? rFilter : String(), + &aGrf); } else - rSh.Insert( aEmptyStr, aEmptyStr, aGrf, &aFrmMgr ); - // nach dem EndAction ist es zu spaet, weil die Shell dann schon zerstoert sein kann - rSh.EndAction(); + { + rSh.StartAction(); + if( bLink ) + { + SwDocShell* pDocSh = GetDocShell(); + INetURLObject aTemp( + pDocSh->HasName() ? + pDocSh->GetMedium()->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) : + rtl::OUString()); + + String sURL = URIHelper::SmartRel2Abs( + aTemp, rPath, URIHelper::GetMaybeFileHdl() ); + + rSh.Insert( sURL, + rFilter, aGrf, &aFrmMgr, bRule ); + } + else + { + rSh.Insert( aEmptyStr, aEmptyStr, aGrf, &aFrmMgr ); + } + + // nach dem EndAction ist es zu spaet, weil die Shell dann schon zerstoert sein kann + rSh.EndAction(); + } } return nRes; } @@ -408,6 +425,9 @@ sal_Bool SwView::InsertGraphicDlg( SfxRequest& rReq ) SwRewriter aRewriter; aRewriter.AddRule(UNDO_ARG1, String(SW_RES(STR_GRAPHIC_DEFNAME))); + // #123922# determine if we really want to insert or replace the graphic at a selected object + const bool bReplaceMode(rSh.HasSelection() && nsSelectionType::SEL_FRM == rSh.GetSelectionType()); + rSh.StartUndo(UNDO_INSERT, &aRewriter); int nError = InsertGraphic( aFileName, aFilterName, bAsLink, GraphicFilter::GetGraphicFilter() ); @@ -415,7 +435,10 @@ sal_Bool SwView::InsertGraphicDlg( SfxRequest& rReq ) // Format ist ungleich Current Filter, jetzt mit auto. detection if( nError == GRFILTER_FORMATERROR ) nError = InsertGraphic( aFileName, aEmptyStr, bAsLink, GraphicFilter::GetGraphicFilter() ); - if ( rSh.IsFrmSelected() ) + + // #123922# no new FrameFormat for replace mode, only when new object was created, + // else this would reset the current setting for the frame holding the graphic + if ( !bReplaceMode && rSh.IsFrmSelected() ) { SwFrmFmt* pFmt = pDoc->FindFrmFmtByName( sGraphicFormat ); if(!pFmt) diff --git a/sw/source/ui/wrtsh/wrtsh1.cxx b/sw/source/ui/wrtsh/wrtsh1.cxx index eeb26a652ae7..ac32b3494b1e 100644 --- a/sw/source/ui/wrtsh/wrtsh1.cxx +++ b/sw/source/ui/wrtsh/wrtsh1.cxx @@ -182,17 +182,17 @@ sal_Bool SwWrtShell::IsEndWrd() Beschreibung: Abfrage, ob Einfuegen moeglich ist; gfs. Beep ------------------------------------------------------------------------*/ - - -sal_Bool SwWrtShell::_CanInsert() +bool SwWrtShell::_CanInsert() { if(!CanInsert()) { Sound::Beep(); - return sal_False; + return false; } - return sal_True; + + return true; } + /*------------------------------------------------------------------------ Beschreibung: String einfuegen ------------------------------------------------------------------------*/ @@ -1820,9 +1820,36 @@ sal_Bool SwWrtShell::Pop( sal_Bool bOldCrsr ) /*-------------------------------------------------------------------- Beschreibung: --------------------------------------------------------------------*/ -sal_Bool SwWrtShell::CanInsert() +bool SwWrtShell::CanInsert() { - return (!(IsSelFrmMode() | IsObjSelected() | (GetView().GetDrawFuncPtr() != NULL) | (GetView().GetPostItMgr()->GetActiveSidebarWin()!= NULL))); + // #123922# The original expression looks sleek, but it is not. Using the mathematical or ('|') + // instead of the logical one ('||') forces the compiler to evaluate all conditions to allow or-ing + // them together (yes, he could do better). Using the logical or allows to return on the first + // failing statement instead. + // + // return (!(IsSelFrmMode() | IsObjSelected() | (GetView().GetDrawFuncPtr() != NULL) | (GetView().GetPostItMgr()->GetActiveSidebarWin()!= NULL))); + + if(IsSelFrmMode()) + { + return false; + } + + if(IsObjSelected()) + { + return false; + } + + if(GetView().GetDrawFuncPtr()) + { + return false; + } + + if(GetView().GetPostItMgr()->GetActiveSidebarWin()) + { + return false; + } + + return true; } |