cui/source/tabpages/transfrm.cxx                    |   48 --------------
 svx/source/sidebar/possize/PosSizePropertyPanel.cxx |   65 +-------------------
 svx/source/svdraw/svdedtv1.cxx                      |   38 +----------
 3 files changed, 11 insertions(+), 140 deletions(-)

New commits:
commit d042c73ad1205e186ef4137568049da4781d9343
Author:     Michael Meeks <michael.me...@collabora.com>
AuthorDate: Mon Dec 2 22:10:15 2019 +0000
Commit:     Michael Meeks <michael.me...@collabora.com>
CommitDate: Tue Dec 3 09:49:31 2019 +0100

    lok: shape selection: perform the needed unit conversion in a clever way
    
    follow-on fixup of: 35d6c6ffc9b3f66e3802d1770c4e87cf843c3a48 which ended
    up not removing the duplicated conversion logic it should have.
    
    Change-Id: I28ef0180749f6356ec456b4f0b1eef1b474fd6c9
    Reviewed-on: https://gerrit.libreoffice.org/84283
    Reviewed-by: Michael Meeks <michael.me...@collabora.com>
    Tested-by: Michael Meeks <michael.me...@collabora.com>

diff --git a/cui/source/tabpages/transfrm.cxx b/cui/source/tabpages/transfrm.cxx
index 6d5f6c51fc5a..e77b890cb8d3 100644
--- a/cui/source/tabpages/transfrm.cxx
+++ b/cui/source/tabpages/transfrm.cxx
@@ -41,7 +41,6 @@
 #include <svl/rectitem.hxx>
 #include <svl/aeitem.hxx>
 #include <swpossizetabpage.hxx>
-#include <comphelper/lok.hxx>
 
 // static ----------------------------------------------------------------
 
@@ -84,28 +83,6 @@ const sal_uInt16 SvxSlantTabPage::pSlantRanges[] =
     0
 };
 
-namespace {
-
-bool lcl_twipsNeeded(const SdrView* pView)
-{
-    const bool bTiledRendering = comphelper::LibreOfficeKit::isActive();
-    if (bTiledRendering)
-    {
-        // We gets the position in twips
-        if (OutputDevice* pOutputDevice = pView->GetFirstOutputDevice())
-        {
-            if (pOutputDevice->GetMapMode().GetMapUnit() == 
MapUnit::Map100thMM)
-            {
-                return true;
-            }
-        }
-    }
-    return false;
-}
-
-} // anonymouus ns
-
-
 /*************************************************************************
 |*
 |* constructor of the tab dialog: adds the pages to the dialog
@@ -275,18 +252,9 @@ bool SvxAngleTabPage::FillItemSet(SfxItemSet* rSet)
         const double fTmpX((GetCoreValue(*m_xMtrPosX, ePoolUnit) + 
maAnchor.getX()) * fUIScale);
         const double fTmpY((GetCoreValue(*m_xMtrPosY, ePoolUnit) + 
maAnchor.getY()) * fUIScale);
 
-        long nRotateX = basegfx::fround(fTmpX);
-        long nRotateY = basegfx::fround(fTmpY);
-
-        if (lcl_twipsNeeded(pView))
-        {
-            nRotateX = OutputDevice::LogicToLogic(nRotateX, 
MapUnit::Map100thMM, MapUnit::MapTwip);
-            nRotateY = OutputDevice::LogicToLogic(nRotateY, 
MapUnit::Map100thMM, MapUnit::MapTwip);
-        }
-
         rSet->Put(SfxInt32Item(GetWhich(SID_ATTR_TRANSFORM_ANGLE), 
m_aCtlAngle.GetRotation()));
-        rSet->Put(SfxInt32Item(GetWhich(SID_ATTR_TRANSFORM_ROT_X), nRotateX));
-        rSet->Put(SfxInt32Item(GetWhich(SID_ATTR_TRANSFORM_ROT_Y), nRotateY));
+        rSet->Put(SfxInt32Item(GetWhich(SID_ATTR_TRANSFORM_ROT_X), 
basegfx::fround(fTmpX)));
+        rSet->Put(SfxInt32Item(GetWhich(SID_ATTR_TRANSFORM_ROT_Y), 
basegfx::fround(fTmpY)));
 
         bModified = true;
     }
@@ -968,12 +936,6 @@ bool SvxPositionSizeTabPage::FillItemSet( SfxItemSet* 
rOutAttrs )
             // #101581# GetTopLeftPosition(...) needs coordinates after UI 
scaling, in real PagePositions
             GetTopLeftPosition(fX, fY, maRange);
 
-            if (lcl_twipsNeeded(mpView))
-            {
-                fX = OutputDevice::LogicToLogic(fX, MapUnit::Map100thMM, 
MapUnit::MapTwip);
-                fY = OutputDevice::LogicToLogic(fY, MapUnit::Map100thMM, 
MapUnit::MapTwip);
-            }
-
             rOutAttrs->Put(SfxInt32Item(GetWhich(SID_ATTR_TRANSFORM_POS_X), 
basegfx::fround(fX)));
             rOutAttrs->Put(SfxInt32Item(GetWhich(SID_ATTR_TRANSFORM_POS_Y), 
basegfx::fround(fY)));
 
@@ -1013,12 +975,6 @@ bool SvxPositionSizeTabPage::FillItemSet( SfxItemSet* 
rOutAttrs )
         lHeight = OutputDevice::LogicToLogic( lHeight, MapUnit::Map100thMM, 
mePoolUnit );
         lHeight = static_cast<long>(m_xMtrHeight->denormalize( lHeight ));
 
-        if (lcl_twipsNeeded(mpView))
-        {
-            lWidth = OutputDevice::LogicToLogic(lWidth, MapUnit::Map100thMM, 
MapUnit::MapTwip);
-            lHeight = OutputDevice::LogicToLogic(lHeight, MapUnit::Map100thMM, 
MapUnit::MapTwip);
-        }
-
         // put Width & Height to itemset
         rOutAttrs->Put( SfxUInt32Item( GetWhich( SID_ATTR_TRANSFORM_WIDTH ), 
static_cast<sal_uInt32>(lWidth) ) );
         rOutAttrs->Put( SfxUInt32Item( GetWhich( SID_ATTR_TRANSFORM_HEIGHT ), 
static_cast<sal_uInt32>(lHeight) ) );
diff --git a/svx/source/sidebar/possize/PosSizePropertyPanel.cxx 
b/svx/source/sidebar/possize/PosSizePropertyPanel.cxx
index 36d13b1d843f..78a1bd1809ee 100644
--- a/svx/source/sidebar/possize/PosSizePropertyPanel.cxx
+++ b/svx/source/sidebar/possize/PosSizePropertyPanel.cxx
@@ -46,28 +46,7 @@
 using namespace css;
 using namespace css::uno;
 
-const char USERITEM_NAME[]      = "FitItem";
-
-namespace {
-
-bool lcl_twipsNeeded(const SdrView* pView)
-{
-    const bool bTiledRendering = comphelper::LibreOfficeKit::isActive();
-    if (bTiledRendering)
-    {
-        // We gets the position in twips
-        if (OutputDevice* pOutputDevice = pView->GetFirstOutputDevice())
-        {
-            if (pOutputDevice->GetMapMode().GetMapUnit() == 
MapUnit::Map100thMM)
-            {
-                return true;
-            }
-        }
-    }
-    return false;
-}
-
-} // anonymouus ns
+const char USERITEM_NAME[] = "FitItem";
 
 namespace svx { namespace sidebar {
 
@@ -412,11 +391,6 @@ IMPL_LINK_NOARG( PosSizePropertyPanel, ChangePosXHdl, 
Edit&, void )
         Fraction aUIScale = mpView->GetModel()->GetUIScale();
         lX = long( lX * aUIScale );
 
-        if (lcl_twipsNeeded(mpView))
-        {
-            lX = OutputDevice::LogicToLogic(lX, MapUnit::Map100thMM, 
MapUnit::MapTwip);
-        }
-
         SfxInt32Item aPosXItem( 
SID_ATTR_TRANSFORM_POS_X,static_cast<sal_uInt32>(lX));
 
         GetBindings()->GetDispatcher()->ExecuteList(
@@ -434,11 +408,6 @@ IMPL_LINK_NOARG( PosSizePropertyPanel, ChangePosYHdl, 
Edit&, void )
         Fraction aUIScale = mpView->GetModel()->GetUIScale();
         lY = long( lY * aUIScale );
 
-        if (lcl_twipsNeeded(mpView))
-        {
-            lY = OutputDevice::LogicToLogic(lY, MapUnit::Map100thMM, 
MapUnit::MapTwip);
-        }
-
         SfxInt32Item aPosYItem( 
SID_ATTR_TRANSFORM_POS_Y,static_cast<sal_uInt32>(lY));
 
         GetBindings()->GetDispatcher()->ExecuteList(
@@ -496,18 +465,9 @@ IMPL_LINK_NOARG( PosSizePropertyPanel, AngleModifiedHdl, 
Edit&, void )
 
     // #i123993# Need to take UIScale into account when executing rotations
     const double fUIScale(mpView && mpView->GetModel() ? 
double(mpView->GetModel()->GetUIScale()) : 1.0);
-    long nRotateX = basegfx::fround(mlRotX * fUIScale);
-    long nRotateY = basegfx::fround(mlRotY * fUIScale);
-
-    if (lcl_twipsNeeded(mpView))
-    {
-        nRotateX = OutputDevice::LogicToLogic(nRotateX, MapUnit::Map100thMM, 
MapUnit::MapTwip);
-        nRotateY = OutputDevice::LogicToLogic(nRotateY, MapUnit::Map100thMM, 
MapUnit::MapTwip);
-    }
-
     SfxInt32Item aAngleItem( 
SID_ATTR_TRANSFORM_ANGLE,static_cast<sal_uInt32>(nTmp));
-    SfxInt32Item aRotXItem( SID_ATTR_TRANSFORM_ROT_X, nRotateX);
-    SfxInt32Item aRotYItem( SID_ATTR_TRANSFORM_ROT_Y, nRotateY);
+    SfxInt32Item aRotXItem( SID_ATTR_TRANSFORM_ROT_X, basegfx::fround(mlRotX * 
fUIScale));
+    SfxInt32Item aRotYItem( SID_ATTR_TRANSFORM_ROT_Y, basegfx::fround(mlRotY * 
fUIScale));
 
     GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_TRANSFORM,
             SfxCallMode::RECORD, { &aAngleItem, &aRotXItem, &aRotYItem });
@@ -520,18 +480,9 @@ IMPL_LINK_NOARG( PosSizePropertyPanel, RotationHdl, 
DialControl*, void )
 
     // #i123993# Need to take UIScale into account when executing rotations
     const double fUIScale(mpView && mpView->GetModel() ? 
double(mpView->GetModel()->GetUIScale()) : 1.0);
-    long nRotateX = basegfx::fround(mlRotX * fUIScale);
-    long nRotateY = basegfx::fround(mlRotY * fUIScale);
-
-    if (lcl_twipsNeeded(mpView))
-    {
-        nRotateX = OutputDevice::LogicToLogic(nRotateX, MapUnit::Map100thMM, 
MapUnit::MapTwip);
-        nRotateY = OutputDevice::LogicToLogic(nRotateY, MapUnit::Map100thMM, 
MapUnit::MapTwip);
-    }
-
     SfxInt32Item aAngleItem( 
SID_ATTR_TRANSFORM_ANGLE,static_cast<sal_uInt32>(nTmp));
-    SfxInt32Item aRotXItem( SID_ATTR_TRANSFORM_ROT_X, nRotateX);
-    SfxInt32Item aRotYItem( SID_ATTR_TRANSFORM_ROT_Y, nRotateY);
+    SfxInt32Item aRotXItem( SID_ATTR_TRANSFORM_ROT_X, basegfx::fround(mlRotX * 
fUIScale));
+    SfxInt32Item aRotYItem( SID_ATTR_TRANSFORM_ROT_Y, basegfx::fround(mlRotY * 
fUIScale));
 
     GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_TRANSFORM,
             SfxCallMode::RECORD, { &aAngleItem, &aRotXItem, &aRotYItem });
@@ -908,12 +859,6 @@ void PosSizePropertyPanel::executeSize()
     lHeight = OutputDevice::LogicToLogic( lHeight, MapUnit::Map100thMM, 
mePoolUnit );
     lHeight = static_cast<long>(mpMtrWidth->Denormalize( lHeight ));
 
-    if (lcl_twipsNeeded(mpView))
-    {
-        lWidth = OutputDevice::LogicToLogic(lWidth, MapUnit::Map100thMM, 
MapUnit::MapTwip);
-        lHeight = OutputDevice::LogicToLogic(lHeight, MapUnit::Map100thMM, 
MapUnit::MapTwip);
-    }
-
     // put Width & Height to itemset
     SfxUInt32Item aWidthItem( SID_ATTR_TRANSFORM_WIDTH, 
static_cast<sal_uInt32>(lWidth));
     SfxUInt32Item aHeightItem( SID_ATTR_TRANSFORM_HEIGHT, 
static_cast<sal_uInt32>(lHeight));
diff --git a/svx/source/svdraw/svdedtv1.cxx b/svx/source/svdraw/svdedtv1.cxx
index 3189215e29cc..4284993d6ae8 100644
--- a/svx/source/svdraw/svdedtv1.cxx
+++ b/svx/source/svdraw/svdedtv1.cxx
@@ -1542,19 +1542,7 @@ static Point ImpGetPoint(const tools::Rectangle& rRect, 
RectPoint eRP)
 
 void SdrEditView::SetGeoAttrToMarked(const SfxItemSet& rAttr)
 {
-    bool bDealingWithTwips = false;
     const bool bTiledRendering = comphelper::LibreOfficeKit::isActive();
-    if (bTiledRendering)
-    {
-        // We gets the position in twips
-        if (OutputDevice* pOutputDevice = 
mpMarkedPV->GetView().GetFirstOutputDevice())
-        {
-            if (pOutputDevice->GetMapMode().GetMapUnit() == 
MapUnit::Map100thMM)
-            {
-                bDealingWithTwips = true;
-            }
-        }
-    }
 
     tools::Rectangle aRect(GetMarkedObjRect());
 
@@ -1570,14 +1558,8 @@ void SdrEditView::SetGeoAttrToMarked(const SfxItemSet& 
rAttr)
     SdrObject* pObj=nullptr;
 
     RectPoint eSizePoint=RectPoint::MM;
-    long nPosX=aRect.Left();
-    long nPosY=aRect.Top();
-    if (bDealingWithTwips)
-    {
-        nPosX = OutputDevice::LogicToLogic(nPosX, MapUnit::Map100thMM, 
MapUnit::MapTwip);
-        nPosY = OutputDevice::LogicToLogic(nPosY, MapUnit::Map100thMM, 
MapUnit::MapTwip);
-    }
-
+    long nPosDX=0;
+    long nPosDY=0;
     long nSizX=0;
     long nSizY=0;
     long nRotateAngle=0;
@@ -1619,11 +1601,11 @@ void SdrEditView::SetGeoAttrToMarked(const SfxItemSet& 
rAttr)
 
     // position
     if 
(SfxItemState::SET==rAttr.GetItemState(SID_ATTR_TRANSFORM_POS_X,true,&pPoolItem))
 {
-        nPosX=static_cast<const SfxInt32Item*>(pPoolItem)->GetValue();
+        nPosDX=static_cast<const SfxInt32Item*>(pPoolItem)->GetValue() - 
aRect.Left();
         bChgPos=true;
     }
     if 
(SfxItemState::SET==rAttr.GetItemState(SID_ATTR_TRANSFORM_POS_Y,true,&pPoolItem)){
-        nPosY=static_cast<const SfxInt32Item*>(pPoolItem)->GetValue();
+        nPosDY=static_cast<const SfxInt32Item*>(pPoolItem)->GetValue() - 
aRect.Top();
         bChgPos=true;
     }
     // size
@@ -1713,18 +1695,6 @@ void SdrEditView::SetGeoAttrToMarked(const SfxItemSet& 
rAttr)
         bSetAttr=true;
     }
 
-    if(bDealingWithTwips) {
-        nPosX = OutputDevice::LogicToLogic(nPosX, MapUnit::MapTwip, 
MapUnit::Map100thMM);
-        nPosY = OutputDevice::LogicToLogic(nPosY, MapUnit::MapTwip, 
MapUnit::Map100thMM);
-        nSizX = OutputDevice::LogicToLogic(nSizX, MapUnit::MapTwip, 
MapUnit::Map100thMM);
-        nSizY = OutputDevice::LogicToLogic(nSizY, MapUnit::MapTwip, 
MapUnit::Map100thMM);
-        nRotateX = OutputDevice::LogicToLogic(nRotateX, MapUnit::MapTwip, 
MapUnit::Map100thMM);
-        nRotateY = OutputDevice::LogicToLogic(nRotateY, MapUnit::MapTwip, 
MapUnit::Map100thMM);
-    }
-
-    long nPosDX = nPosX - aRect.Left();
-    long nPosDY = nPosY - aRect.Top();
-
     ForcePossibilities();
 
     BegUndo(SvxResId(STR_EditTransform),GetDescriptionOfMarkedObjects());
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to