view2.cxx (dec99bbd) view2.cxx (52f1c2ee)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 211 unchanged lines hidden (view full) ---

220 if( !pFlt )
221 pFlt = GraphicFilter::GetGraphicFilter();
222 nRes = GraphicFilter::LoadGraphic( rPath, rFilter, aGrf, pFlt /*, nFilter*/ );
223 }
224
225 if( GRFILTER_OK == nRes )
226 {
227 SwFlyFrmAttrMgr aFrmMgr( sal_True, GetWrtShellPtr(), FRMMGR_TYPE_GRF );
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 211 unchanged lines hidden (view full) ---

220 if( !pFlt )
221 pFlt = GraphicFilter::GetGraphicFilter();
222 nRes = GraphicFilter::LoadGraphic( rPath, rFilter, aGrf, pFlt /*, nFilter*/ );
223 }
224
225 if( GRFILTER_OK == nRes )
226 {
227 SwFlyFrmAttrMgr aFrmMgr( sal_True, GetWrtShellPtr(), FRMMGR_TYPE_GRF );
228
229 SwWrtShell &rSh = GetWrtShell();
228 SwWrtShell &rSh = GetWrtShell();
230 rSh.StartAction();
231 if( bLink )
232 {
233 SwDocShell* pDocSh = GetDocShell();
234 INetURLObject aTemp(
235 pDocSh->HasName() ?
236 pDocSh->GetMedium()->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) :
237 rtl::OUString());
238
229
239 String sURL = URIHelper::SmartRel2Abs(
240 aTemp, rPath, URIHelper::GetMaybeFileHdl() );
230 // #123922# determine if we really want to insert or replace the graphic at a selected object
231 const bool bReplaceMode(rSh.HasSelection() && nsSelectionType::SEL_FRM == rSh.GetSelectionType());
241
232
242 rSh.Insert( sURL,
243 rFilter, aGrf, &aFrmMgr, bRule );
233 if(bReplaceMode)
234 {
235 // #123922# Do same as in D&D, ReRead graphic and all is done
236 rSh.ReRead(
237 bLink ? rPath : String(),
238 bLink ? rFilter : String(),
239 &aGrf);
244 }
245 else
240 }
241 else
246 rSh.Insert( aEmptyStr, aEmptyStr, aGrf, &aFrmMgr );
247 // nach dem EndAction ist es zu spaet, weil die Shell dann schon zerstoert sein kann
248 rSh.EndAction();
242 {
243 rSh.StartAction();
244 if( bLink )
245 {
246 SwDocShell* pDocSh = GetDocShell();
247 INetURLObject aTemp(
248 pDocSh->HasName() ?
249 pDocSh->GetMedium()->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) :
250 rtl::OUString());
251
252 String sURL = URIHelper::SmartRel2Abs(
253 aTemp, rPath, URIHelper::GetMaybeFileHdl() );
254
255 rSh.Insert( sURL,
256 rFilter, aGrf, &aFrmMgr, bRule );
257 }
258 else
259 {
260 rSh.Insert( aEmptyStr, aEmptyStr, aGrf, &aFrmMgr );
261 }
262
263 // nach dem EndAction ist es zu spaet, weil die Shell dann schon zerstoert sein kann
264 rSh.EndAction();
265 }
249 }
250 return nRes;
251}
252
253
254sal_Bool SwView::InsertGraphicDlg( SfxRequest& rReq )
255{
256#ifndef ENABLE_PROP_WITHOUTLINK

--- 146 unchanged lines hidden (view full) ---

403 SwWrtShell& rSh = GetWrtShell();
404 rSh.LockPaint();
405 rSh.StartAction();
406
407 /// #111827#
408 SwRewriter aRewriter;
409 aRewriter.AddRule(UNDO_ARG1, String(SW_RES(STR_GRAPHIC_DEFNAME)));
410
266 }
267 return nRes;
268}
269
270
271sal_Bool SwView::InsertGraphicDlg( SfxRequest& rReq )
272{
273#ifndef ENABLE_PROP_WITHOUTLINK

--- 146 unchanged lines hidden (view full) ---

420 SwWrtShell& rSh = GetWrtShell();
421 rSh.LockPaint();
422 rSh.StartAction();
423
424 /// #111827#
425 SwRewriter aRewriter;
426 aRewriter.AddRule(UNDO_ARG1, String(SW_RES(STR_GRAPHIC_DEFNAME)));
427
428 // #123922# determine if we really want to insert or replace the graphic at a selected object
429 const bool bReplaceMode(rSh.HasSelection() && nsSelectionType::SEL_FRM == rSh.GetSelectionType());
430
411 rSh.StartUndo(UNDO_INSERT, &aRewriter);
412
413 int nError = InsertGraphic( aFileName, aFilterName, bAsLink, GraphicFilter::GetGraphicFilter() );
414
415 // Format ist ungleich Current Filter, jetzt mit auto. detection
416 if( nError == GRFILTER_FORMATERROR )
417 nError = InsertGraphic( aFileName, aEmptyStr, bAsLink, GraphicFilter::GetGraphicFilter() );
431 rSh.StartUndo(UNDO_INSERT, &aRewriter);
432
433 int nError = InsertGraphic( aFileName, aFilterName, bAsLink, GraphicFilter::GetGraphicFilter() );
434
435 // Format ist ungleich Current Filter, jetzt mit auto. detection
436 if( nError == GRFILTER_FORMATERROR )
437 nError = InsertGraphic( aFileName, aEmptyStr, bAsLink, GraphicFilter::GetGraphicFilter() );
418 if ( rSh.IsFrmSelected() )
438
439 // #123922# no new FrameFormat for replace mode, only when new object was created,
440 // else this would reset the current setting for the frame holding the graphic
441 if ( !bReplaceMode && rSh.IsFrmSelected() )
419 {
420 SwFrmFmt* pFmt = pDoc->FindFrmFmtByName( sGraphicFormat );
421 if(!pFmt)
422 pFmt = pDoc->MakeFrmFmt(sGraphicFormat,
423 pDocShell->GetDoc()->GetDfltFrmFmt(),
424 sal_True, sal_False);
425 rSh.SetFrmFmt( pFmt );
426 }

--- 2056 unchanged lines hidden ---
442 {
443 SwFrmFmt* pFmt = pDoc->FindFrmFmtByName( sGraphicFormat );
444 if(!pFmt)
445 pFmt = pDoc->MakeFrmFmt(sGraphicFormat,
446 pDocShell->GetDoc()->GetDfltFrmFmt(),
447 sal_True, sal_False);
448 rSh.SetFrmFmt( pFmt );
449 }

--- 2056 unchanged lines hidden ---