Author: alg
Date: Fri Feb 7 01:26:23 2014
New Revision: 1565510
URL: http://svn.apache.org/r1565510
Log:
i123922 Refactored D&D and insert picture from file in all apps for all object
types to work the same
Modified:
openoffice/trunk/main/sc/source/ui/drawfunc/fuins1.cxx
openoffice/trunk/main/sc/source/ui/inc/drawview.hxx
openoffice/trunk/main/sc/source/ui/inc/viewfunc.hxx
openoffice/trunk/main/sc/source/ui/view/drawview.cxx
openoffice/trunk/main/sc/source/ui/view/gridwin.cxx
openoffice/trunk/main/sc/source/ui/view/viewfun3.cxx
openoffice/trunk/main/sc/source/ui/view/viewfun7.cxx
openoffice/trunk/main/sd/source/ui/func/fuinsert.cxx
openoffice/trunk/main/sd/source/ui/view/sdview4.cxx
openoffice/trunk/main/sw/inc/fesh.hxx
openoffice/trunk/main/sw/sdi/drawsh.sdi
openoffice/trunk/main/sw/source/core/frmedt/fecopy.cxx
openoffice/trunk/main/sw/source/ui/dochdl/swdtflvr.cxx
openoffice/trunk/main/sw/source/ui/inc/drawsh.hxx
openoffice/trunk/main/sw/source/ui/inc/view.hxx
openoffice/trunk/main/sw/source/ui/inc/wrtsh.hxx
openoffice/trunk/main/sw/source/ui/shells/drawsh.cxx
openoffice/trunk/main/sw/source/ui/shells/grfsh.cxx
openoffice/trunk/main/sw/source/ui/uiview/view2.cxx
openoffice/trunk/main/sw/source/ui/wrtsh/wrtsh1.cxx
Modified: openoffice/trunk/main/sc/source/ui/drawfunc/fuins1.cxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/sc/source/ui/drawfunc/fuins1.cxx?rev=1565510&r1=1565509&r2=1565510&view=diff
==============================================================================
--- openoffice/trunk/main/sc/source/ui/drawfunc/fuins1.cxx (original)
+++ openoffice/trunk/main/sc/source/ui/drawfunc/fuins1.cxx Fri Feb 7 01:26:23
2014
@@ -45,6 +45,7 @@
#include "scresid.hxx"
#include "progress.hxx"
#include "sc.hrc"
+#include "globstr.hrc"
@@ -147,12 +148,42 @@ void lcl_InsertGraphic( const Graphic& r
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 aSourceMap = rGraphic.GetPrefMapMode();
MapMode aDestMap( MAP_100TH_MM );
if ( aSourceMap.GetMapUnit() == MAP_PIXEL && pDrawView )
{
Modified: openoffice/trunk/main/sc/source/ui/inc/drawview.hxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/sc/source/ui/inc/drawview.hxx?rev=1565510&r1=1565509&r2=1565510&view=diff
==============================================================================
--- openoffice/trunk/main/sc/source/ui/inc/drawview.hxx (original)
+++ openoffice/trunk/main/sc/source/ui/inc/drawview.hxx Fri Feb 7 01:26:23 2014
@@ -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);
};
Modified: openoffice/trunk/main/sc/source/ui/inc/viewfunc.hxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/sc/source/ui/inc/viewfunc.hxx?rev=1565510&r1=1565509&r2=1565510&view=diff
==============================================================================
--- openoffice/trunk/main/sc/source/ui/inc/viewfunc.hxx (original)
+++ openoffice/trunk/main/sc/source/ui/inc/viewfunc.hxx Fri Feb 7 01:26:23 2014
@@ -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 );
Modified: openoffice/trunk/main/sc/source/ui/view/drawview.cxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/sc/source/ui/view/drawview.cxx?rev=1565510&r1=1565509&r2=1565510&view=diff
==============================================================================
--- openoffice/trunk/main/sc/source/ui/view/drawview.cxx (original)
+++ openoffice/trunk/main/sc/source/ui/view/drawview.cxx Fri Feb 7 01:26:23
2014
@@ -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::getSdrUndoMa
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
Modified: openoffice/trunk/main/sc/source/ui/view/gridwin.cxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/sc/source/ui/view/gridwin.cxx?rev=1565510&r1=1565509&r2=1565510&view=diff
==============================================================================
--- openoffice/trunk/main/sc/source/ui/view/gridwin.cxx (original)
+++ openoffice/trunk/main/sc/source/ui/view/gridwin.cxx Fri Feb 7 01:26:23 2014
@@ -4283,8 +4283,8 @@ sal_Int8 ScGridWindow::ExecuteDrop( cons
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;
}
Modified: openoffice/trunk/main/sc/source/ui/view/viewfun3.cxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/sc/source/ui/view/viewfun3.cxx?rev=1565510&r1=1565509&r2=1565510&view=diff
==============================================================================
--- openoffice/trunk/main/sc/source/ui/view/viewfun3.cxx (original)
+++ openoffice/trunk/main/sc/source/ui/view/viewfun3.cxx Fri Feb 7 01:26:23
2014
@@ -820,41 +820,66 @@ sal_Bool ScViewFunc::PasteFromSystem( sa
//----------------------------------------------------------------------------
// 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 ) )
- {
- SotStorageStreamRef xStm;
- if( aDataHelper.GetSotStorageStream(
SOT_FORMATSTR_ID_SVXB, xStm ) )
- {
- Graphic aGraphic;
- *xStm >> aGraphic;
- bRet = ApplyGraphicToObject( pHitObj, aGraphic
);
- }
- }
- 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 ) )
- {
- BitmapEx aBmpEx;
- if( aDataHelper.GetBitmapEx( FORMAT_BITMAP, aBmpEx ) )
- bRet = ApplyGraphicToObject( pHitObj,
Graphic(aBmpEx) );
- }
- }
- else
- {
- // ham' wa noch nich
- }
- return bRet;
+ TransferableDataHelper aDataHelper( rxTransferable );
+
+ if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_SVXB ) )
+ {
+ SotStorageStreamRef xStm;
+ ScDrawView* pScDrawView = GetScDrawView();
+
+ if( pScDrawView && 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 ))
+ {
+ return sal_True;
+ }
+ }
+ }
+ else if ( aDataHelper.HasFormat( SOT_FORMAT_GDIMETAFILE ) )
+ {
+ GDIMetaFile aMtf;
+ ScDrawView* pScDrawView = GetScDrawView();
+
+ if( pScDrawView && aDataHelper.GetGDIMetaFile( FORMAT_GDIMETAFILE,
aMtf ) )
+ {
+ const String aEmpty;
+ const String aBeginUndo(ScGlobal::GetRscString(STR_UNDO_DRAGDROP));
+
+ if(pScDrawView->ApplyGraphicToObject( rHitObj, Graphic(aMtf),
aBeginUndo, aEmpty, aEmpty ))
+ {
+ return sal_True;
+ }
+ }
+ }
+ else if ( aDataHelper.HasFormat( SOT_FORMAT_BITMAP ) ||
aDataHelper.HasFormat( SOT_FORMATSTR_ID_PNG ) )
+ {
+ 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 sal_False;
}
sal_Bool lcl_SelHasAttrib( ScDocument* pDoc, SCCOL nCol1, SCROW nRow1, SCCOL
nCol2, SCROW nRow2,
Modified: openoffice/trunk/main/sc/source/ui/view/viewfun7.cxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/sc/source/ui/view/viewfun7.cxx?rev=1565510&r1=1565509&r2=1565510&view=diff
==============================================================================
--- openoffice/trunk/main/sc/source/ui/view/viewfun7.cxx (original)
+++ openoffice/trunk/main/sc/source/ui/view/viewfun7.cxx Fri Feb 7 01:26:23
2014
@@ -390,6 +390,38 @@ sal_Bool ScViewFunc::PasteGraphic( const
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,8 +443,7 @@ sal_Bool ScViewFunc::PasteGraphic( const
aPos.X() -= aSize.Width();
GetViewData()->GetViewShell()->SetDrawShell( sal_True );
-
- Rectangle aRect(aPos, aSize);
+ Rectangle aRect(aPos, aSize);
SdrGrafObj* pGrafObj = new SdrGrafObj(rGraphic, aRect);
// #118522# calling SetGraphicLink here doesn't work
@@ -435,50 +466,3 @@ sal_Bool ScViewFunc::PasteGraphic( const
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;
-}
-
-
Modified: openoffice/trunk/main/sd/source/ui/func/fuinsert.cxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/sd/source/ui/func/fuinsert.cxx?rev=1565510&r1=1565509&r2=1565510&view=diff
==============================================================================
--- openoffice/trunk/main/sd/source/ui/func/fuinsert.cxx (original)
+++ openoffice/trunk/main/sd/source/ui/func/fuinsert.cxx Fri Feb 7 01:26:23
2014
@@ -142,8 +142,18 @@ void FuInsertGraphic::DoExecute( SfxRequ
{
sal_Int8 nAction = DND_ACTION_COPY;
SdrObject* pPickObj =
mpView->GetEmptyPresentationObject( PRESOBJ_GRAPHIC );
- if( pPickObj )
- nAction = DND_ACTION_LINK;
+ 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( SfxRequ
String aPath(aDlg.GetPath());
pGrafObj->SetGraphicLink(aPath,
aFltName);
}
+
+ if(bSelectionReplaced && pGrafObj)
+ {
+ mpView->MarkObj(pGrafObj, mpView->GetSdrPageView());
+ }
}
}
else
Modified: openoffice/trunk/main/sd/source/ui/view/sdview4.cxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/sd/source/ui/view/sdview4.cxx?rev=1565510&r1=1565509&r2=1565510&view=diff
==============================================================================
--- openoffice/trunk/main/sd/source/ui/view/sdview4.cxx (original)
+++ openoffice/trunk/main/sd/source/ui/view/sdview4.cxx Fri Feb 7 01:26:23 2014
@@ -107,67 +107,70 @@ SdrGrafObj* View::InsertGraphic( const G
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( IsUndoEnabled() )
- BegUndo(String(SdResId(STR_INSERTGRAPHIC)));
+ 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() )
+ {
+ BegUndo(String(SdResId(STR_UNDO_DRAGDROP)));
+
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pPickObj));
+ EndUndo();
+ }
+
+ SfxItemSet aSet(mpDocSh->GetPool(), XATTR_FILLSTYLE, XATTR_FILLBITMAP);
+
+ 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)));
- SdPage* pPage = (SdPage*) pPickObj->GetPage();
+ 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);
- }
+ 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 (pPage && pPage->IsPresObj(pPickObj))
- {
- // Neues PresObj in die Liste eintragen
- pPage->InsertPresObj( pNewGrafObj,
PRESOBJ_GRAPHIC );
-
pNewGrafObj->SetUserCall(pPickObj->GetUserCall());
- }
+ if ( pNewGrafObj->IsEmptyPresObj() )
+ {
+ Rectangle aRect( pNewGrafObj->GetLogicRect() );
+ pNewGrafObj->AdjustToMaxRect( aRect, sal_False );
+ pNewGrafObj->SetOutlinerParaObject(NULL);
+ pNewGrafObj->SetEmptyPresObj(sal_False);
+ }
- if (pImageMap)
- pNewGrafObj->InsertUserData(new
SdIMapInfo(*pImageMap));
+ if (pPage && pPage->IsPresObj(pPickObj))
+ {
+ // Neues PresObj in die Liste eintragen
+ pPage->InsertPresObj( pNewGrafObj, PRESOBJ_GRAPHIC );
+ pNewGrafObj->SetUserCall(pPickObj->GetUserCall());
+ }
- ReplaceObjectAtView(pPickObj, *pPV, pNewGrafObj); //
maybe ReplaceObjectAtView
+ if (pImageMap)
+ pNewGrafObj->InsertUserData(new SdIMapInfo(*pImageMap));
- if( IsUndoEnabled() )
- EndUndo();
- }
- else if(pPickObj->IsClosedObj())
- {
- // fill object with graphic
- if( IsUndoEnabled() )
- {
- BegUndo(String(SdResId(STR_UNDO_DRAGDROP)));
-
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pPickObj));
- EndUndo();
- }
+ ReplaceObjectAtView(pPickObj, *pPV, pNewGrafObj); // maybe
ReplaceObjectAtView
- SfxItemSet aSet(mpDocSh->GetPool(), XATTR_FILLSTYLE,
XATTR_FILLBITMAP);
- aSet.Put(XFillStyleItem(XFILL_BITMAP));
- aSet.Put(XFillBitmapItem(&mpDocSh->GetPool(),
rGraphic));
- pPickObj->SetMergedItemSetAndBroadcast(aSet);
- }
+ if( IsUndoEnabled() )
+ EndUndo();
}
else if ( pPV )
{
Modified: openoffice/trunk/main/sw/inc/fesh.hxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/sw/inc/fesh.hxx?rev=1565510&r1=1565509&r2=1565510&view=diff
==============================================================================
--- openoffice/trunk/main/sw/inc/fesh.hxx (original)
+++ openoffice/trunk/main/sw/inc/fesh.hxx Fri Feb 7 01:26:23 2014
@@ -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;
Modified: openoffice/trunk/main/sw/sdi/drawsh.sdi
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/sw/sdi/drawsh.sdi?rev=1565510&r1=1565509&r2=1565510&view=diff
==============================================================================
--- openoffice/trunk/main/sw/sdi/drawsh.sdi (original)
+++ openoffice/trunk/main/sw/sdi/drawsh.sdi Fri Feb 7 01:26:23 2014
@@ -395,9 +395,11 @@ interface TextDraw : TextDrawBase
StateMethod = GetState ;
]
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
[
StateMethod = StateDisableItems ;
Modified: openoffice/trunk/main/sw/source/core/frmedt/fecopy.cxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/core/frmedt/fecopy.cxx?rev=1565510&r1=1565509&r2=1565510&view=diff
==============================================================================
--- openoffice/trunk/main/sw/source/core/frmedt/fecopy.cxx (original)
+++ openoffice/trunk/main/sw/source/core/frmedt/fecopy.cxx Fri Feb 7 01:26:23
2014
@@ -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,
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,
delete pModel;
}
-sal_Bool SwFEShell::Paste( const Graphic &rGrf )
+bool SwFEShell::Paste( const Graphic &rGrf, const String& rURL )
{
- SET_CURR_SHELL( this );
- SdrObject* pObj;
- SdrView *pView = Imp()->GetDrawView();
+ SET_CURR_SHELL( this );
+ SdrObject* pObj = 0;
+ SdrView *pView = Imp()->GetDrawView();
- sal_Bool bRet = 1 == pView->GetMarkedObjectList().GetMarkCount() &&
- (pObj = pView->GetMarkedObjectList().GetMark( 0
)->GetMarkedSdrObj())->IsClosedObj() &&
- !pObj->ISA( SdrOle2Obj );
+ sal_Bool bRet = 1 == pView->GetMarkedObjectList().GetMarkCount() &&
+ (pObj = pView->GetMarkedObjectList().GetMark( 0
)->GetMarkedSdrObj())->IsClosedObj() &&
+ !pObj->ISA( SdrOle2Obj );
- if( bRet )
- {
- SfxItemSet aSet(GetAttrPool(), XATTR_FILLSTYLE,
XATTR_FILLBITMAP);
+ if( bRet && pObj )
+ {
+ // #123922# added code to handle the two cases of SdrGrafObj and a
fillable, non-
+ // OLE object in focus
+ SdrObject* pResult = pObj;
- aSet.Put(XFillStyleItem(XFILL_BITMAP));
- aSet.Put(XFillBitmapItem(aEmptyStr, rGrf));
- pView->SetAttributes(aSet, false);
- }
- return bRet;
+ 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());
+
+ 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;
}
Modified: openoffice/trunk/main/sw/source/ui/dochdl/swdtflvr.cxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/ui/dochdl/swdtflvr.cxx?rev=1565510&r1=1565509&r2=1565510&view=diff
==============================================================================
--- openoffice/trunk/main/sw/source/ui/dochdl/swdtflvr.cxx (original)
+++ openoffice/trunk/main/sw/source/ui/dochdl/swdtflvr.cxx Fri Feb 7 01:26:23
2014
@@ -1999,7 +1999,7 @@ int SwTransferable::_PasteTargetURL( Tra
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( Tr
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;
@@ -2371,55 +2371,85 @@ int SwTransferable::_PasteGrf( Transfera
if( nRet )
{
- String sURL;
- if( rSh.GetView().GetDocShell()->ISA(SwWebDocShell) )
- sURL = aBkmk.GetURL();
-
- switch( nAction )
- {
- case SW_PASTESDR_INSERT:
- SwTransferable::SetSelInShell( rSh, sal_False, pPt );
- rSh.Insert( sURL, aEmptyStr, aGrf );
- break;
+ String sURL;
- case SW_PASTESDR_REPLACE:
- if( rSh.IsObjSelected() )
- {
- rSh.ReplaceSdrObj( sURL, aEmptyStr, &aGrf );
- Point aPt( pPt ? *pPt : rSh.GetCrsrDocPos() );
- SwTransferable::SetSelInShell( rSh, sal_True,
&aPt );
- }
- else
- rSh.ReRead( sURL, aEmptyStr, &aGrf );
- break;
+ if( rSh.GetView().GetDocShell()->ISA(SwWebDocShell)
+ // #123922# if link action is noted, also take URL
+ || DND_ACTION_LINK == nDropAction)
+ {
+ sURL = aBkmk.GetURL();
+ }
- case SW_PASTESDR_SETATTR:
- if( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK == nFmt )
- {
- 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() )
- rSh.Paste( aGrf );
- else if( OBJCNT_GRF == rSh.GetObjCntTypeOfSelection() )
- rSh.ReRead( sURL, aEmptyStr, &aGrf );
- else
- {
- SwTransferable::SetSelInShell( rSh, sal_False,
pPt );
- rSh.Insert( aBkmk.GetURL(), aEmptyStr, aGrf );
- }
- break;
- default:
- nRet = 0;
- }
- }
+ switch( nAction )
+ {
+ case SW_PASTESDR_INSERT:
+ {
+ SwTransferable::SetSelInShell( rSh, sal_False, pPt );
+ rSh.Insert( sURL, aEmptyStr, aGrf );
+ break;
+ }
+
+ case SW_PASTESDR_REPLACE:
+ {
+ 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;
+ }
+
+ case SW_PASTESDR_SETATTR:
+ {
+ if( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK == nFmt )
+ {
+ 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;
+ }
+ default:
+ {
+ nRet = 0;
+ break;
+ }
+ }
+ }
if( nRet )
{
Modified: openoffice/trunk/main/sw/source/ui/inc/drawsh.hxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/ui/inc/drawsh.hxx?rev=1565510&r1=1565509&r2=1565510&view=diff
==============================================================================
--- openoffice/trunk/main/sw/source/ui/inc/drawsh.hxx (original)
+++ openoffice/trunk/main/sw/source/ui/inc/drawsh.hxx Fri Feb 7 01:26:23 2014
@@ -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
Modified: openoffice/trunk/main/sw/source/ui/inc/view.hxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/ui/inc/view.hxx?rev=1565510&r1=1565509&r2=1565510&view=diff
==============================================================================
--- openoffice/trunk/main/sw/source/ui/inc/view.hxx (original)
+++ openoffice/trunk/main/sw/source/ui/inc/view.hxx Fri Feb 7 01:26:23 2014
@@ -372,6 +372,7 @@ class SW_DLLPUBLIC SwView: public SfxVie
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:
Modified: openoffice/trunk/main/sw/source/ui/inc/wrtsh.hxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/ui/inc/wrtsh.hxx?rev=1565510&r1=1565509&r2=1565510&view=diff
==============================================================================
--- openoffice/trunk/main/sw/source/ui/inc/wrtsh.hxx (original)
+++ openoffice/trunk/main/sw/source/ui/inc/wrtsh.hxx Fri Feb 7 01:26:23 2014
@@ -312,7 +312,7 @@ typedef sal_Bool (SwWrtShell:: *FNSimple
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);
Modified: openoffice/trunk/main/sw/source/ui/shells/drawsh.cxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/ui/shells/drawsh.cxx?rev=1565510&r1=1565509&r2=1565510&view=diff
==============================================================================
--- openoffice/trunk/main/sw/source/ui/shells/drawsh.cxx (original)
+++ openoffice/trunk/main/sw/source/ui/shells/drawsh.cxx Fri Feb 7 01:26:23
2014
@@ -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 &rR
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 &rR
Beschreibung:
--------------------------------------------------------------------*/
-
-
void SwDrawShell::GetState(SfxItemSet& rSet)
{
SwWrtShell &rSh = GetShell();
@@ -383,6 +500,19 @@ void SwDrawShell::GetState(SfxItemSet& r
}
}
break;
+
+ case SID_INSERT_GRAPHIC:
+ {
+ // #123922# check if we can do something
+ SdrObject* pObj = IsSingleFillableNonOLESelected();
+
+ if(!pObj)
+ {
+ rSet.DisableItem(nWhich);
+ }
+
+ break;
+ }
}
nWhich = aIter.NextWhich();
}
Modified: openoffice/trunk/main/sw/source/ui/shells/grfsh.cxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/ui/shells/grfsh.cxx?rev=1565510&r1=1565509&r2=1565510&view=diff
==============================================================================
--- openoffice/trunk/main/sw/source/ui/shells/grfsh.cxx (original)
+++ openoffice/trunk/main/sw/source/ui/shells/grfsh.cxx Fri Feb 7 01:26:23 2014
@@ -112,7 +112,14 @@ void SwGrfShell::Execute(SfxRequest &rRe
}
}
break;
- case SID_INSERT_GRAPHIC:
+ 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:
{
Modified: openoffice/trunk/main/sw/source/ui/uiview/view2.cxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/ui/uiview/view2.cxx?rev=1565510&r1=1565509&r2=1565510&view=diff
==============================================================================
--- openoffice/trunk/main/sw/source/ui/uiview/view2.cxx (original)
+++ openoffice/trunk/main/sw/source/ui/uiview/view2.cxx Fri Feb 7 01:26:23 2014
@@ -225,27 +225,44 @@ int SwView::InsertGraphic( const String
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( SfxRe
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( SfxRe
// 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)
Modified: openoffice/trunk/main/sw/source/ui/wrtsh/wrtsh1.cxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/ui/wrtsh/wrtsh1.cxx?rev=1565510&r1=1565509&r2=1565510&view=diff
==============================================================================
--- openoffice/trunk/main/sw/source/ui/wrtsh/wrtsh1.cxx (original)
+++ openoffice/trunk/main/sw/source/ui/wrtsh/wrtsh1.cxx Fri Feb 7 01:26:23 2014
@@ -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 sal_True;
+ if(!CanInsert())
+ {
+ Sound::Beep();
+ return false;
+ }
+
+ return true;
}
+
/*------------------------------------------------------------------------
Beschreibung: String einfuegen
------------------------------------------------------------------------*/
@@ -1820,9 +1820,36 @@ sal_Bool SwWrtShell::Pop( sal_Bool bOldC
/*--------------------------------------------------------------------
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;
}