Kaydet (Commit) 4dbed9ef authored tarafından Miklos Vajna's avatar Miklos Vajna

Use oox::drawingml::convertEmuToHmm()

And get rid of the writerfilter copy, that does no rounding.  Adjusted
testcases:

- testFdo80555: 245 -> 247 (should be 246.944444444, so a good change)
- testDMLGroupShapeChildPosition: roundtripped values are now closer to
  the initial ones, so also a good change

Change-Id: I4dec7857a0df77face01b7a8ba1da7c647a24b6c
üst 328f861d
...@@ -314,12 +314,12 @@ DECLARE_OOXMLEXPORT_TEST(testDMLShapeFillPattern, "dml-shape-fillpattern.docx") ...@@ -314,12 +314,12 @@ DECLARE_OOXMLEXPORT_TEST(testDMLShapeFillPattern, "dml-shape-fillpattern.docx")
DECLARE_OOXMLEXPORT_TEST(testDMLGroupShapeChildPosition, "dml-groupshape-childposition.docx") DECLARE_OOXMLEXPORT_TEST(testDMLGroupShapeChildPosition, "dml-groupshape-childposition.docx")
{ {
// Problem was parent transformation was ingnored fully, but translate component // Problem was parent transformation was ignored fully, but translate component
// which specify the position must be also applied for children of the group. // which specify the position must be also applied for children of the group.
uno::Reference<drawing::XShapes> xGroup(getShape(1), uno::UNO_QUERY); uno::Reference<drawing::XShapes> xGroup(getShape(1), uno::UNO_QUERY);
uno::Reference<drawing::XShape> xChildGroup(xGroup->getByIndex(1), uno::UNO_QUERY); uno::Reference<drawing::XShape> xChildGroup(xGroup->getByIndex(1), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int32(mbExported ? -2119 : -2122), xChildGroup->getPosition().X); CPPUNIT_ASSERT_EQUAL(sal_Int32(mbExported ? -2120 : -2122), xChildGroup->getPosition().X);
CPPUNIT_ASSERT_EQUAL(sal_Int32(mbExported ? 11336 : 11333), xChildGroup->getPosition().Y); CPPUNIT_ASSERT_EQUAL(sal_Int32(mbExported ? 11336 : 11333), xChildGroup->getPosition().Y);
xGroup.set(xChildGroup, uno::UNO_QUERY); xGroup.set(xChildGroup, uno::UNO_QUERY);
...@@ -328,7 +328,7 @@ DECLARE_OOXMLEXPORT_TEST(testDMLGroupShapeChildPosition, "dml-groupshape-childpo ...@@ -328,7 +328,7 @@ DECLARE_OOXMLEXPORT_TEST(testDMLGroupShapeChildPosition, "dml-groupshape-childpo
CPPUNIT_ASSERT_EQUAL(sal_Int32(mbExported ? 11336 : 11333), xChildGroup->getPosition().Y); CPPUNIT_ASSERT_EQUAL(sal_Int32(mbExported ? 11336 : 11333), xChildGroup->getPosition().Y);
xChildGroup.set(xGroup->getByIndex(1), uno::UNO_QUERY); xChildGroup.set(xGroup->getByIndex(1), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int32(mbExported ? -2119 : -2122), xChildGroup->getPosition().X); CPPUNIT_ASSERT_EQUAL(sal_Int32(mbExported ? -2120 : -2122), xChildGroup->getPosition().X);
CPPUNIT_ASSERT_EQUAL(sal_Int32(mbExported ? 14026 : 14023), xChildGroup->getPosition().Y); CPPUNIT_ASSERT_EQUAL(sal_Int32(mbExported ? 14026 : 14023), xChildGroup->getPosition().Y);
} }
......
...@@ -2268,7 +2268,7 @@ DECLARE_OOXMLIMPORT_TEST(testFdo80555, "fdo80555.docx") ...@@ -2268,7 +2268,7 @@ DECLARE_OOXMLIMPORT_TEST(testFdo80555, "fdo80555.docx")
uno::Reference<drawing::XShape> xShape = getShape(1); uno::Reference<drawing::XShape> xShape = getShape(1);
// Shape was wrongly placed at X=0, Y=0 // Shape was wrongly placed at X=0, Y=0
CPPUNIT_ASSERT_EQUAL(sal_Int32(3318), xShape->getPosition().X); CPPUNIT_ASSERT_EQUAL(sal_Int32(3318), xShape->getPosition().X);
CPPUNIT_ASSERT_EQUAL(sal_Int32(245), xShape->getPosition().Y); CPPUNIT_ASSERT_EQUAL(sal_Int32(247), xShape->getPosition().Y);
} }
DECLARE_OOXMLIMPORT_TEST(testFdo76803, "fdo76803.docx") DECLARE_OOXMLIMPORT_TEST(testFdo76803, "fdo76803.docx")
......
...@@ -423,11 +423,6 @@ sal_uInt32 convertTwipToMM100Unsigned(sal_Int32 _t) ...@@ -423,11 +423,6 @@ sal_uInt32 convertTwipToMM100Unsigned(sal_Int32 _t)
return convertTwipToMM100( _t ); return convertTwipToMM100( _t );
} }
sal_Int32 convertEMUToMM100(sal_Int32 _t)
{
return _t / 360;
}
sal_Int16 convertTableJustification( sal_Int32 nIntValue ) sal_Int16 convertTableJustification( sal_Int32 nIntValue )
{ {
sal_Int16 nOrient = text::HoriOrientation::LEFT_AND_WIDTH; sal_Int16 nOrient = text::HoriOrientation::LEFT_AND_WIDTH;
......
...@@ -45,8 +45,6 @@ namespace ConversionHelper{ ...@@ -45,8 +45,6 @@ namespace ConversionHelper{
// export just for test // export just for test
SAL_DLLPUBLIC_EXPORT sal_Int32 convertTwipToMM100(sal_Int32 _t); SAL_DLLPUBLIC_EXPORT sal_Int32 convertTwipToMM100(sal_Int32 _t);
SAL_DLLPUBLIC_EXPORT sal_uInt32 convertTwipToMM100Unsigned(sal_Int32 _t); SAL_DLLPUBLIC_EXPORT sal_uInt32 convertTwipToMM100Unsigned(sal_Int32 _t);
// probably the most useless unit in the world - English Metric Units (EMU) 360 000 EMU == 1cm
sal_Int32 convertEMUToMM100(sal_Int32 _t);
sal_Int16 convertTableJustification( sal_Int32 nIntValue ); sal_Int16 convertTableJustification( sal_Int32 nIntValue );
sal_Int16 ConvertNumberingType(sal_Int32 nFmt); sal_Int16 ConvertNumberingType(sal_Int32 nFmt);
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <com/sun/star/text/WrapTextMode.hpp> #include <com/sun/star/text/WrapTextMode.hpp>
#include "dmapperLoggers.hxx" #include "dmapperLoggers.hxx"
#include <oox/drawingml/drawingmltypes.hxx>
#include <iostream> #include <iostream>
using namespace std; using namespace std;
...@@ -152,9 +153,9 @@ sal_Int16 PositionHandler::orientation() const ...@@ -152,9 +153,9 @@ sal_Int16 PositionHandler::orientation() const
void PositionHandler::setPositionOffset(const OUString & sText, bool vertical) void PositionHandler::setPositionOffset(const OUString & sText, bool vertical)
{ {
if( vertical ) if( vertical )
savedPositionOffsetV = ConversionHelper::convertEMUToMM100( sText.toInt32()); savedPositionOffsetV = oox::drawingml::convertEmuToHmm(sText.toInt32());
else else
savedPositionOffsetH = ConversionHelper::convertEMUToMM100( sText.toInt32()); savedPositionOffsetH = oox::drawingml::convertEmuToHmm(sText.toInt32());
} }
int PositionHandler::getPositionOffset(bool vertical) int PositionHandler::getPositionOffset(bool vertical)
......
...@@ -544,12 +544,12 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue) ...@@ -544,12 +544,12 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue)
case NS_ooxml::LN_CT_Border_shadow: case NS_ooxml::LN_CT_Border_shadow:
m_pImpl->aBorders[m_pImpl->nCurrentBorderLine].bHasShadow = nIntValue ? true : false; m_pImpl->aBorders[m_pImpl->nCurrentBorderLine].bHasShadow = nIntValue ? true : false;
break; break;
case NS_ooxml::LN_CT_Border_frame: // ignored case NS_ooxml::LN_CT_Border_frame:
break; break;
case NS_ooxml::LN_CT_PositiveSize2D_cx:// 90407; case NS_ooxml::LN_CT_PositiveSize2D_cx:
case NS_ooxml::LN_CT_PositiveSize2D_cy:// 90408; case NS_ooxml::LN_CT_PositiveSize2D_cy:
{ {
sal_Int32 nDim = ConversionHelper::convertEMUToMM100( nIntValue ); sal_Int32 nDim = oox::drawingml::convertEmuToHmm(nIntValue);
if( nName == NS_ooxml::LN_CT_PositiveSize2D_cx ) if( nName == NS_ooxml::LN_CT_PositiveSize2D_cx )
m_pImpl->setXSize(nDim); m_pImpl->setXSize(nDim);
else else
...@@ -858,16 +858,16 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue) ...@@ -858,16 +858,16 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue)
} }
break; break;
case NS_ooxml::LN_CT_Inline_distT: case NS_ooxml::LN_CT_Inline_distT:
m_pImpl->nTopMargin = ConversionHelper::convertEMUToMM100(nIntValue); m_pImpl->nTopMargin = oox::drawingml::convertEmuToHmm(nIntValue);
break; break;
case NS_ooxml::LN_CT_Inline_distB: case NS_ooxml::LN_CT_Inline_distB:
m_pImpl->nBottomMargin = ConversionHelper::convertEMUToMM100(nIntValue); m_pImpl->nBottomMargin = oox::drawingml::convertEmuToHmm(nIntValue);
break; break;
case NS_ooxml::LN_CT_Inline_distL: case NS_ooxml::LN_CT_Inline_distL:
m_pImpl->nLeftMargin = ConversionHelper::convertEMUToMM100(nIntValue); m_pImpl->nLeftMargin = oox::drawingml::convertEmuToHmm(nIntValue);
break; break;
case NS_ooxml::LN_CT_Inline_distR: case NS_ooxml::LN_CT_Inline_distR:
m_pImpl->nRightMargin = ConversionHelper::convertEMUToMM100(nIntValue); m_pImpl->nRightMargin = oox::drawingml::convertEmuToHmm(nIntValue);
break; break;
case NS_ooxml::LN_CT_GraphicalObjectData_uri: case NS_ooxml::LN_CT_GraphicalObjectData_uri:
rValue.getString(); rValue.getString();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment