summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmin Le Grand <Armin.Le.Grand@cib.de>2018-05-09 19:34:16 +0200
committerJulien Nabet <serval2412@yahoo.fr>2018-05-11 11:12:28 +0200
commit9ddbd8e2bce697ce244a1f6161e8f45312f6e6b2 (patch)
tree688dd8bf4dff28b89c1e739e4218ebedec06eb73
parent752a1e27246e768984fed43153f3327379b76c99 (diff)
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.Grand@cib.de> Tested-by: Jenkins <ci@libreoffice.org>
-rw-r--r--svx/source/tbxctrls/fontworkgallery.cxx37
1 files changed, 29 insertions, 8 deletions
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);
+ }
}
}
}