summaryrefslogtreecommitdiff
path: root/svx/source/unodraw/unoshape.cxx
diff options
context:
space:
mode:
authorArmin Le Grand <Armin.Le.Grand@cib.de>2018-05-02 18:24:09 +0200
committerArmin Le Grand <Armin.Le.Grand@cib.de>2018-05-03 00:27:37 +0200
commitd57033ddf8eaa2f6992ac7d89c33dc47c7293492 (patch)
treee550e14925a64db3402fc993d6d55bbf8dc214e1 /svx/source/unodraw/unoshape.cxx
parent52b6e4c9e508af0db7f942b30735bec1bb184399 (diff)
tdf#117145 Cleanup MapMode handling between SdrModel/UNO API
In current versions MapMode handling is done in ::TRSet/Get- BaseGeometry methods. These belong to SdrModel level and should not do any MapMode conversions (else all geometry and Rectangle setters/getters should have to do these, too). Instead, the UNO API implementation should do these, there are already some done there and this is the level which offers pure 100ThMM handling to the caller, independent from the used application. Change-Id: I3d7781440fc0fc6a20b5d4e79c747c988677483d Reviewed-on: https://gerrit.libreoffice.org/53748 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de>
Diffstat (limited to 'svx/source/unodraw/unoshape.cxx')
-rw-r--r--svx/source/unodraw/unoshape.cxx84
1 files changed, 76 insertions, 8 deletions
diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx
index e12bbf4c5c93..33299173e71e 100644
--- a/svx/source/unodraw/unoshape.cxx
+++ b/svx/source/unodraw/unoshape.cxx
@@ -471,7 +471,6 @@ void SvxShape::ForceMetricToItemPoolMetric(Pair& rPoint) const throw()
}
}
-// Reintroduction of fix for issue i59051 (#i108851#)
void SvxShape::ForceMetricToItemPoolMetric(basegfx::B2DPolyPolygon& rPolyPolygon) const throw()
{
DBG_TESTSOLARMUTEX();
@@ -500,6 +499,35 @@ void SvxShape::ForceMetricToItemPoolMetric(basegfx::B2DPolyPolygon& rPolyPolygon
}
}
+void SvxShape::ForceMetricToItemPoolMetric(basegfx::B2DHomMatrix& rB2DHomMatrix) const throw()
+{
+ DBG_TESTSOLARMUTEX();
+ if(HasSdrObject())
+ {
+ MapUnit eMapUnit(GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetMetric(0));
+ if(eMapUnit != MapUnit::Map100thMM)
+ {
+ switch(eMapUnit)
+ {
+ case MapUnit::MapTwip :
+ {
+ const double fMMToTWIPS(72.0 / 127.0);
+ const basegfx::utils::B2DHomMatrixBufferedDecompose aDecomposedTransform(rB2DHomMatrix);
+ rB2DHomMatrix = basegfx::utils::createScaleShearXRotateTranslateB2DHomMatrix(
+ aDecomposedTransform.getScale() * fMMToTWIPS,
+ aDecomposedTransform.getShearX(),
+ aDecomposedTransform.getRotate(),
+ aDecomposedTransform.getTranslate() * fMMToTWIPS);
+ break;
+ }
+ default:
+ {
+ OSL_FAIL("Missing unit translation to PoolMetric!");
+ }
+ }
+ }
+ }
+}
void SvxShape::ForceMetricTo100th_mm(Pair& rPoint) const throw()
{
@@ -527,7 +555,6 @@ void SvxShape::ForceMetricTo100th_mm(Pair& rPoint) const throw()
}
}
-// Reintroduction of fix for issue i59051 (#i108851#)
void SvxShape::ForceMetricTo100th_mm(basegfx::B2DPolyPolygon& rPolyPolygon) const throw()
{
DBG_TESTSOLARMUTEX();
@@ -556,6 +583,36 @@ void SvxShape::ForceMetricTo100th_mm(basegfx::B2DPolyPolygon& rPolyPolygon) cons
}
}
+void SvxShape::ForceMetricTo100th_mm(basegfx::B2DHomMatrix& rB2DHomMatrix) const throw()
+{
+ DBG_TESTSOLARMUTEX();
+ MapUnit eMapUnit = MapUnit::Map100thMM;
+ if(HasSdrObject())
+ {
+ eMapUnit = GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetMetric(0);
+ if(eMapUnit != MapUnit::Map100thMM)
+ {
+ switch(eMapUnit)
+ {
+ case MapUnit::MapTwip :
+ {
+ const double fTWIPSToMM(127.0 / 72.0);
+ const basegfx::utils::B2DHomMatrixBufferedDecompose aDecomposedTransform(rB2DHomMatrix);
+ rB2DHomMatrix = basegfx::utils::createScaleShearXRotateTranslateB2DHomMatrix(
+ aDecomposedTransform.getScale() * fTWIPSToMM,
+ aDecomposedTransform.getShearX(),
+ aDecomposedTransform.getRotate(),
+ aDecomposedTransform.getTranslate() * fTWIPSToMM);
+ break;
+ }
+ default:
+ {
+ OSL_FAIL("Missing unit translation to 100th mm!");
+ }
+ }
+ }
+ }
+}
void SvxItemPropertySet_ObtainSettingsFromPropertySet(const SvxItemPropertySet& rPropSet,
SfxItemSet& rSet, const uno::Reference< beans::XPropertySet >& xSet, const SfxItemPropertyMap* pMap )
@@ -2031,6 +2088,10 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
{
Point aVclPoint( aPnt.X, aPnt.Y );
+ // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
+ // Need to adapt aVclPoint from 100thmm to app-specific
+ ForceMetricToItemPoolMetric(aVclPoint);
+
// #90763# position is relative to top left, make it absolute
basegfx::B2DPolyPolygon aNewPolyPolygon;
basegfx::B2DHomMatrix aNewHomogenMatrix;
@@ -2039,9 +2100,6 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
aVclPoint.AdjustX(basegfx::fround(aNewHomogenMatrix.get(0, 2)) );
aVclPoint.AdjustY(basegfx::fround(aNewHomogenMatrix.get(1, 2)) );
- // #88657# metric of pool maybe twips (writer)
- ForceMetricToItemPoolMetric(aVclPoint);
-
// #88491# position relative to anchor
if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
{
@@ -2062,6 +2120,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
basegfx::B2DPolyPolygon aNewPolyPolygon;
basegfx::B2DHomMatrix aNewHomogenMatrix;
+ // tdf#117145 SdrModel data is app-specific
GetSdrObject()->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
aNewHomogenMatrix.set(0, 0, aMatrix.Line1.Column1);
@@ -2074,6 +2133,10 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
aNewHomogenMatrix.set(2, 1, aMatrix.Line3.Column2);
aNewHomogenMatrix.set(2, 2, aMatrix.Line3.Column3);
+ // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
+ // Need to adapt aNewHomogenMatrix from 100thmm to app-specific
+ ForceMetricToItemPoolMetric(aNewHomogenMatrix);
+
GetSdrObject()->TRSetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
return true;
}
@@ -2474,9 +2537,6 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
aVclPoint -= GetSdrObject()->GetAnchorPos();
}
- // #88657# metric of pool maybe twips (writer)
- ForceMetricTo100th_mm(aVclPoint);
-
// #90763# pos is absolute, make it relative to top left
basegfx::B2DPolyPolygon aNewPolyPolygon;
basegfx::B2DHomMatrix aNewHomogenMatrix;
@@ -2485,6 +2545,10 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
aVclPoint.AdjustX( -(basegfx::fround(aNewHomogenMatrix.get(0, 2))) );
aVclPoint.AdjustY( -(basegfx::fround(aNewHomogenMatrix.get(1, 2))) );
+ // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
+ // Need to adapt aVclPoint from app-specific to 100thmm
+ ForceMetricTo100th_mm(aVclPoint);
+
awt::Point aPnt( aVclPoint.X(), aVclPoint.Y() );
rValue <<= aPnt;
break;
@@ -2497,6 +2561,10 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
GetSdrObject()->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
drawing::HomogenMatrix3 aMatrix;
+ // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
+ // Need to adapt aNewHomogenMatrix from app-specific to 100thmm
+ ForceMetricTo100th_mm(aNewHomogenMatrix);
+
aMatrix.Line1.Column1 = aNewHomogenMatrix.get(0, 0);
aMatrix.Line1.Column2 = aNewHomogenMatrix.get(0, 1);
aMatrix.Line1.Column3 = aNewHomogenMatrix.get(0, 2);