summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorMarco Cecchetti <mrcekets@gmail.com>2018-11-30 17:20:37 +0100
committerAndras Timar <andras.timar@collabora.com>2018-12-15 12:33:16 +0100
commit0be31ab89261524a6c979332e45ae1eb6dcbe5e4 (patch)
treef4f38ee54e9554df149bd04ce1e73ba85f253b8b /svx
parentdfe497c0c7628ed2d2abb5dbae2bf8756a371f29 (diff)
lok: shape selection: perform the needed unit conversion in a clever way
Change-Id: I505bd41801b5fd1898a9eddc81b102f2f7ae20b5
Diffstat (limited to 'svx')
-rw-r--r--svx/source/sidebar/possize/PosSizePropertyPanel.cxx65
-rw-r--r--svx/source/svdraw/svdedtv1.cxx38
2 files changed, 9 insertions, 94 deletions
diff --git a/svx/source/sidebar/possize/PosSizePropertyPanel.cxx b/svx/source/sidebar/possize/PosSizePropertyPanel.cxx
index 4985f370dfe3..3ac3a789c58d 100644
--- a/svx/source/sidebar/possize/PosSizePropertyPanel.cxx
+++ b/svx/source/sidebar/possize/PosSizePropertyPanel.cxx
@@ -37,34 +37,13 @@
#include <svl/aeitem.hxx>
#include <svx/svdview.hxx>
#include <svx/transfrmhelper.hxx>
-#include <comphelper/lok.hxx>
+
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
-
namespace svx { namespace sidebar {
PosSizePropertyPanel::PosSizePropertyPanel(
@@ -394,11 +373,6 @@ IMPL_LINK_NOARG( PosSizePropertyPanel, ChangePosXHdl, Edit&, void )
lX += maAnchorPos.X();
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(
@@ -417,11 +391,6 @@ IMPL_LINK_NOARG( PosSizePropertyPanel, ChangePosYHdl, Edit&, void )
lY += maAnchorPos.Y();
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(
@@ -479,18 +448,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 });
@@ -503,18 +463,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 });
@@ -881,12 +832,6 @@ void PosSizePropertyPanel::executeSize()
lHeight = OutputDevice::LogicToLogic( lHeight, MapUnit::Map100thMM, mePoolUnit );
lHeight = (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, (sal_uInt32) lWidth);
SfxUInt32Item aHeightItem( SID_ATTR_TRANSFORM_HEIGHT, (sal_uInt32) lHeight);
diff --git a/svx/source/svdraw/svdedtv1.cxx b/svx/source/svdraw/svdedtv1.cxx
index 1dda837a5d1f..d25711fa4eac 100644
--- a/svx/source/svdraw/svdedtv1.cxx
+++ b/svx/source/svdraw/svdedtv1.cxx
@@ -1438,19 +1438,7 @@ 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());
@@ -1466,14 +1454,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;
@@ -1515,11 +1497,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
@@ -1609,18 +1591,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(ImpGetResStr(STR_EditTransform),GetDescriptionOfMarkedObjects());