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 /sw | |
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 'sw')
-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 |
11 files changed, 331 insertions, 73 deletions
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; } |