svx/source/tbxctrls/fontworkgallery.cxx | 37 +++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 8 deletions(-)
New commits: commit 9ddbd8e2bce697ce244a1f6161e8f45312f6e6b2 Author: Armin Le Grand <armin.le.gr...@cib.de> Date: Wed May 9 19:34:16 2018 +0200 tdf#116993 corrected FontWork to use correct SdrModel Had to adapt FontWorkGalleryDialog::insertSelectedFontwork() to use the correct target-SdrModel when cloning the FontWork SdrObject. This is due to FontWorkGalleryDialog being used differently from Calc - it calls SetSdrObjectRef to set an exceptional SdrModel as target which I took as the always to-be-used target SdrModel - due to it's name 'mpDestModel'. Change-Id: Ia4860283082f041711b8c31952fd2c398eeac30e Reviewed-on: https://gerrit.libreoffice.org/54045 Reviewed-by: Armin Le Grand <armin.le.gr...@cib.de> Tested-by: Jenkins <c...@libreoffice.org> diff --git a/svx/source/tbxctrls/fontworkgallery.cxx b/svx/source/tbxctrls/fontworkgallery.cxx index d504705ce4c6..2efa87a1592d 100644 --- a/svx/source/tbxctrls/fontworkgallery.cxx +++ b/svx/source/tbxctrls/fontworkgallery.cxx @@ -197,29 +197,50 @@ void FontWorkGalleryDialog::insertSelectedFontwork() SdrPage* pPage = pModel->GetPage(0); if( pPage && pPage->GetObjCount() ) { - // Clone directly to target SdrModel - SdrObject* pNewObject(pPage->GetObj(0)->CloneSdrObject(*mpDestModel)); + // tdf#116993 Calc uses a 'special' mode for this dialog in being the + // only caller of ::SetSdrObjectRef. Only in that case mpDestModel seems + // to be the correct target SdrModel. + // If this is not used, the correct SdrModel seems to be the one from + // the mpSdrView that is used to insert (InsertObjectAtView below) the + // cloned SdrObject. + const bool bUseSpecialCalcMode(nullptr != mppSdrObject && nullptr != mpDestModel); + const bool bSdrViewInsertMode(nullptr != mpSdrView); // center shape on current view - OutputDevice* pOutDev = mpSdrView->GetFirstOutputDevice(); - if( pOutDev ) + OutputDevice* pOutDev(mpSdrView->GetFirstOutputDevice()); + + if(pOutDev && (bUseSpecialCalcMode || bSdrViewInsertMode)) { + // Clone directly to target SdrModel (may be different due to user/caller (!)) + SdrObject* pNewObject( + pPage->GetObj(0)->CloneSdrObject( + bUseSpecialCalcMode ? *mpDestModel : mpSdrView->getSdrModelFromSdrView())); + tools::Rectangle aObjRect( pNewObject->GetLogicRect() ); tools::Rectangle aVisArea = pOutDev->PixelToLogic(tools::Rectangle(Point(0,0), pOutDev->GetOutputSizePixel())); Point aPagePos = aVisArea.Center(); aPagePos.AdjustX( -(aObjRect.GetWidth() / 2) ); aPagePos.AdjustY( -(aObjRect.GetHeight() / 2) ); tools::Rectangle aNewObjectRectangle(aPagePos, aObjRect.GetSize()); - SdrPageView* pPV = mpSdrView->GetSdrPageView(); pNewObject->SetLogicRect(aNewObjectRectangle); - if ( mppSdrObject ) + if(bUseSpecialCalcMode) { *mppSdrObject = pNewObject; } - else if( pPV ) + else // bSdrViewInsertMode { - mpSdrView->InsertObjectAtView( pNewObject, *pPV ); + SdrPageView* pPV(mpSdrView->GetSdrPageView()); + + if(nullptr != pPV) + { + mpSdrView->InsertObjectAtView( pNewObject, *pPV ); + } + else + { + // tdf#116993 no target -> delete clone + SdrObject::Free(pNewObject); + } } } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits