diff options
author | Armin Le Grand <alg@apache.org> | 2014-02-07 01:26:23 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-02-07 12:24:46 +0000 |
commit | 5c75cd95178e3d57e53fee64a9d64023c6d18acf (patch) | |
tree | 0b8608bbb949b1f07e62c82a188ba5d96da861e3 /sw | |
parent | coverity#708818 Unused pointer value (diff) | |
download | core-5c75cd95178e3d57e53fee64a9d64023c6d18acf.tar.gz core-5c75cd95178e3d57e53fee64a9d64023c6d18acf.zip |
Resolves: #i123922# Refactored D&D and insert picture from file...
in all apps for all object types to work the same
(cherry picked from commit 080a23dfb836bac49d9496fa1460b9dda9138f65)
Conflicts:
sc/source/ui/drawfunc/fuins1.cxx
sc/source/ui/inc/drawview.hxx
sc/source/ui/inc/viewfunc.hxx
sc/source/ui/view/drawview.cxx
sc/source/ui/view/viewfun3.cxx
sc/source/ui/view/viewfun7.cxx
sd/source/ui/func/fuinsert.cxx
sd/source/ui/view/sdview4.cxx
sw/source/core/frmedt/fecopy.cxx
sw/source/ui/dochdl/swdtflvr.cxx
sw/source/ui/inc/view.hxx
sw/source/ui/inc/wrtsh.hxx
sw/source/ui/shells/drawsh.cxx
sw/source/ui/uiview/view2.cxx
sw/source/ui/wrtsh/wrtsh1.cxx
Change-Id: I7f77d8c0812278ad434fe1c503a03d9747ea0b00
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 | 59 | ||||
-rw-r--r-- | sw/source/ui/dochdl/swdtflvr.cxx | 97 | ||||
-rw-r--r-- | sw/source/ui/inc/drawsh.hxx | 4 | ||||
-rw-r--r-- | sw/source/ui/inc/view.hxx | 5 | ||||
-rw-r--r-- | sw/source/ui/shells/drawsh.cxx | 142 | ||||
-rw-r--r-- | sw/source/ui/shells/grfsh.cxx | 7 | ||||
-rw-r--r-- | sw/source/ui/uiview/view2.cxx | 54 | ||||
-rw-r--r-- | sw/source/ui/wrtsh/wrtsh1.cxx | 23 |
10 files changed, 332 insertions, 65 deletions
diff --git a/sw/inc/fesh.hxx b/sw/inc/fesh.hxx index 6ca2008f6b3d..7fd2dfd7274a 100644 --- a/sw/inc/fesh.hxx +++ b/sw/inc/fesh.hxx @@ -512,7 +512,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 OUString& 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 3bd4a4a53dbc..e4751ea1d206 100644 --- a/sw/sdi/drawsh.sdi +++ b/sw/sdi/drawsh.sdi @@ -391,7 +391,9 @@ interface TextDraw : TextDrawBase ] SID_INSERT_GRAPHIC [ - StateMethod = StateDisableItems ; + // #i123922# 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 2bafe5163180..9868750e6550 100644 --- a/sw/source/core/frmedt/fecopy.cxx +++ b/sw/source/core/frmedt/fecopy.cxx @@ -24,6 +24,7 @@ #include <sot/storage.hxx> #include <unotools/pathoptions.hxx> #include <sfx2/dispatch.hxx> +#include <sfx2/docfile.hxx> #include <sfx2/viewsh.hxx> #include <svx/xexch.hxx> #include <svx/xflasit.hxx> @@ -71,7 +72,7 @@ #include <pagedesc.hxx> #include <mvsave.hxx> #include <vcl/virdev.hxx> - +#include <svx/svdundo.hxx> using namespace ::com::sun::star; @@ -1442,7 +1443,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 ); + { + // #i123922# 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; @@ -1545,24 +1551,59 @@ 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 OUString& 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); + // #i123922# 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); + + // #i123922# 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); + + OUString aReferer; + SwDocShell *pDocShell = GetDoc()->GetDocShell(); + if (pDocShell->HasName()) { + aReferer = pDocShell->GetMedium()->GetName(); + } - aSet.Put(XFillStyleItem(XFILL_BITMAP)); - aSet.Put(XFillBitmapItem(aEmptyOUStr, rGrf)); - pView->SetAttributes(aSet, false); + // set in all cases - the Clone() will have copied an existing link (!) + pNewGrafObj->SetGraphicLink(rURL, aReferer, OUString()); + + 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(OUString(), 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 ae1da814e4b4..f0d7f9da31ba 100644 --- a/sw/source/ui/dochdl/swdtflvr.cxx +++ b/sw/source/ui/dochdl/swdtflvr.cxx @@ -1950,7 +1950,7 @@ bool SwTransferable::_PasteTargetURL( TransferableDataHelper& rData, case SW_PASTESDR_SETATTR: if( rSh.IsObjSelected() ) - rSh.Paste( aGraphic ); + rSh.Paste( aGraphic, OUString() ); else if( OBJCNT_GRF == rSh.GetObjCntTypeOfSelection() ) rSh.ReRead( sURL, aEmptyOUStr, &aGraphic ); else @@ -2212,7 +2212,7 @@ bool SwTransferable::_PasteSdrFormat( TransferableDataHelper& rData, bool 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) { bool nRet = false; @@ -2308,52 +2308,81 @@ bool SwTransferable::_PasteGrf( TransferableDataHelper& rData, SwWrtShell& rSh, lclCheckAndPerformRotation(aGraphic); OUString sURL; - if( rSh.GetView().GetDocShell()->ISA(SwWebDocShell) ) + if( rSh.GetView().GetDocShell()->ISA(SwWebDocShell) + // #i123922# 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, aEmptyOUStr, aGraphic ); - break; + case SW_PASTESDR_INSERT: + { + SwTransferable::SetSelInShell( rSh, sal_False, pPt ); + rSh.Insert( sURL, aEmptyOUStr, aGraphic ); + break; + } - case SW_PASTESDR_REPLACE: - if( rSh.IsObjSelected() ) + case SW_PASTESDR_REPLACE: { - rSh.ReplaceSdrObj( sURL, aEmptyOUStr, &aGraphic ); - Point aPt( pPt ? *pPt : rSh.GetCrsrDocPos() ); - SwTransferable::SetSelInShell( rSh, sal_True, &aPt ); + if( rSh.IsObjSelected() ) + { + // #i123922# 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( aGraphic, sURL ); + + // rSh.ReplaceSdrObj( sURL, aEmptyOUStr, &aGraphic ); + // Point aPt( pPt ? *pPt : rSh.GetCrsrDocPos() ); + // SwTransferable::SetSelInShell( rSh, sal_True, &aPt ); + } + else + { + // set graphic at writer graphic without link + rSh.ReRead( sURL, aEmptyOUStr, &aGraphic ); + } + + break; } - else - rSh.ReRead( sURL, aEmptyOUStr, &aGraphic ); - 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(), 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( aGraphic, sURL ); + } + else if( OBJCNT_GRF == rSh.GetObjCntTypeOfSelection() ) + { + // set as linked graphic at writer graphic frame + rSh.ReRead( sURL, aEmptyOUStr, &aGraphic ); + } + else + { + SwTransferable::SetSelInShell( rSh, sal_False, pPt ); + rSh.Insert( aBkmk.GetURL(), aEmptyOUStr, aGraphic ); + } + break; } - else if( rSh.IsObjSelected() ) - rSh.Paste( aGraphic ); - else if( OBJCNT_GRF == rSh.GetObjCntTypeOfSelection() ) - rSh.ReRead( sURL, aEmptyOUStr, &aGraphic ); - else + default: { - SwTransferable::SetSelInShell( rSh, sal_False, pPt ); - rSh.Insert( aBkmk.GetURL(), aEmptyOUStr, aGraphic ); + nRet = 0; + break; } - break; - default: - nRet = false; } } diff --git a/sw/source/ui/inc/drawsh.hxx b/sw/source/ui/inc/drawsh.hxx index 7e4e655b76fe..545faf748d7d 100644 --- a/sw/source/ui/inc/drawsh.hxx +++ b/sw/source/ui/inc/drawsh.hxx @@ -39,6 +39,10 @@ public: void ExecFormText(SfxRequest& rReq); void GetFormTextState(SfxItemSet& rSet); + + // #i123922# 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 2bcb9b596c0f..6c8128c32851 100644 --- a/sw/source/ui/inc/view.hxx +++ b/sw/source/ui/inc/view.hxx @@ -360,10 +360,11 @@ class SW_DLLPUBLIC SwView: public SfxViewShell SAL_DLLPRIVATE virtual void Move(); - SAL_DLLPRIVATE sal_Bool InsertGraphicDlg( SfxRequest& ); - SAL_DLLPRIVATE void DocumentStatsChanged(); +public: // #i123922# Needs to be called from a 2nd place now as a helper method + SAL_DLLPRIVATE sal_Bool InsertGraphicDlg( SfxRequest& ); + protected: SwView_Impl* GetViewImpl() {return m_pViewImpl;} diff --git a/sw/source/ui/shells/drawsh.cxx b/sw/source/ui/shells/drawsh.cxx index 16a1f98eac84..84f394af081b 100644 --- a/sw/source/ui/shells/drawsh.cxx +++ b/sw/source/ui/shells/drawsh.cxx @@ -22,6 +22,7 @@ #include <svx/svdotext.hxx> #include <svl/whiter.hxx> #include <svx/fontwork.hxx> +#include <sfx2/docfile.hxx> #include <sfx2/request.hxx> #include <sfx2/bindings.hxx> #include <sfx2/objface.hxx> @@ -34,6 +35,8 @@ #include <wview.hxx> #include <swmodule.hxx> #include <swwait.hxx> +#include <doc.hxx> +#include <docsh.hxx> #include <docstat.hxx> #include <IDocumentStatistics.hxx> #include <tools/diagnose_ex.h> @@ -44,6 +47,12 @@ #include <svx/svdoashp.hxx> #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" @@ -74,6 +83,112 @@ SFX_IMPL_INTERFACE(SwDrawShell, SwDrawBaseShell, SW_RES(STR_SHELLNAME_DRAW)) TYPEINIT1(SwDrawShell,SwDrawBaseShell) +// #i123922# 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; +} + +// #i123922# 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); + + // #i123922# 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); + + OUString aReferer; + SwDocShell *pDocShell = rSh.GetDoc()->GetDocShell(); + if (pDocShell->HasName()) { + aReferer = pDocShell->GetMedium()->GetName(); + } + + // set in all cases - the Clone() will have copied an existing link (!) + pNewGrafObj->SetGraphicLink( + bAsLink ? aDlg.GetPath() : OUString(), + aReferer, + bAsLink ? aDlg.GetCurrentFilter() : OUString()); + + 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(OUString(), 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(); @@ -265,6 +380,20 @@ void SwDrawShell::Execute(SfxRequest &rReq) rReq.Ignore (); break; + case SID_INSERT_GRAPHIC: + { + // #i123922# check if we can do something + SdrObject* pObj = IsSingleFillableNonOLESelected(); + + if(pObj) + { + // ...and if yes, do something + InsertPictureFromFile(*pObj); + } + + break; + } + default: OSL_ENSURE(!this, "wrong dispatcher"); return; @@ -357,6 +486,19 @@ void SwDrawShell::GetState(SfxItemSet& rSet) } } break; + + case SID_INSERT_GRAPHIC: + { + // #i123922# 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 6e6c75714276..0ad28795b5b8 100644 --- a/sw/source/ui/shells/grfsh.cxx +++ b/sw/source/ui/shells/grfsh.cxx @@ -186,6 +186,13 @@ void SwGrfShell::Execute(SfxRequest &rReq) break; case SID_INSERT_GRAPHIC: + { + // #i123922# implement slot independent from the two below to + // bring up the insert graphic dialog and associated actions + SwView& rLclView = GetView(); + rReq.SetReturnValue(SfxBoolItem(nSlot, rLclView.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 4d66c6c325cc..3a43507e5d1b 100644 --- a/sw/source/ui/uiview/view2.cxx +++ b/sw/source/ui/uiview/view2.cxx @@ -238,28 +238,44 @@ int SwView::InsertGraphic( const OUString &rPath, const OUString &rFilter, } SwFlyFrmAttrMgr aFrameManager( sal_True, GetWrtShellPtr(), FRMMGR_TYPE_GRF ); - SwWrtShell& rShell = GetWrtShell(); - rShell.StartAction(); - if( bLink ) - { - SwDocShell* pDocSh = GetDocShell(); - INetURLObject aTemp( - pDocSh->HasName() ? - pDocSh->GetMedium()->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) : - OUString()); - OUString sURL = URIHelper::SmartRel2Abs( aTemp, rPath, URIHelper::GetMaybeFileHdl() ); + // #i123922# determine if we really want to insert or replace the graphic at a selected object + const bool bReplaceMode(rShell.HasSelection() && nsSelectionType::SEL_FRM == rShell.GetSelectionType()); - rShell.Insert( sURL, rFilter, aGraphic, &aFrameManager, bRule ); + if(bReplaceMode) + { + // #i123922# Do same as in D&D, ReRead graphic and all is done + rShell.ReRead( + bLink ? rPath : OUString(), + bLink ? rFilter : OUString(), + &aGraphic); } else { - rShell.Insert( OUString(), OUString(), aGraphic, &aFrameManager ); - } + rShell.StartAction(); + if( bLink ) + { + SwDocShell* pDocSh = GetDocShell(); + INetURLObject aTemp( + pDocSh->HasName() ? + pDocSh->GetMedium()->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) : + OUString()); + + OUString sURL = URIHelper::SmartRel2Abs( + aTemp, rPath, URIHelper::GetMaybeFileHdl() ); + + rShell.Insert( sURL, + rFilter, aGraphic, &aFrameManager, bRule ); + } + else + { + rShell.Insert( OUString(), OUString(), aGraphic, &aFrameManager ); + } - // it is too late after "EndAction" because the Shell can already be destroyed. - rShell.EndAction(); + // it is too late after "EndAction" because the Shell can already be destroyed. + rShell.EndAction(); + } } return aResult; } @@ -427,6 +443,9 @@ sal_Bool SwView::InsertGraphicDlg( SfxRequest& rReq ) SwRewriter aRewriter; aRewriter.AddRule(UndoArg1, SW_RESSTR(STR_GRAPHIC_DEFNAME)); + // #i123922# 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() ); @@ -434,7 +453,10 @@ sal_Bool SwView::InsertGraphicDlg( SfxRequest& rReq ) // format not equal to current filter (with autodetection) if( nError == GRFILTER_FORMATERROR ) nError = InsertGraphic( aFileName, OUString(), bAsLink, &GraphicFilter::GetGraphicFilter() ); - if ( rSh.IsFrmSelected() ) + + // #i123922# 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 4f03d0dc84ce..f1ccf3827922 100644 --- a/sw/source/ui/wrtsh/wrtsh1.cxx +++ b/sw/source/ui/wrtsh/wrtsh1.cxx @@ -166,7 +166,6 @@ sal_Bool SwWrtShell::IsEndWrd() } // Insert string - void SwWrtShell::InsertByWord( const OUString & rStr) { if( !rStr.isEmpty() ) @@ -1644,7 +1643,27 @@ sal_Bool SwWrtShell::Pop( sal_Bool bOldCrsr ) bool SwWrtShell::CanInsert() { - 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; } void SwWrtShell::ChgDBData(const SwDBData& aDBData) |