[Libreoffice-commits] core.git: sw/qa writerfilter/source
Mike Kaganski
mike.kaganski at collabora.com
Fri Dec 23 03:56:32 UTC 2016
sw/qa/extras/uiwriter/data/tdf66405.docx |binary
sw/qa/extras/uiwriter/uiwriter.cxx | 35 ++++++++++++++++++++++
writerfilter/source/dmapper/DomainMapper_Impl.cxx | 19 +++++++++++
3 files changed, 54 insertions(+)
New commits:
commit c2a20af2c12bf75e7378a3a9dbc50a4dddabdebc
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date: Thu Dec 22 13:50:17 2016 +0300
tdf#66405: imported formulas should have all margins set to 0
Currently, imported formulas use default Math object's margins,
that are 2 mm left & right for embedded object and 1 mm left & right
for its model. Before commit eae2331f83bd58bacccd898d60f6c5f54856c036,
there was also 3.5 mm bottom margin for embedded object.
This commit sets all margins to 0.
Unit test is included.
Change-Id: I23c78d4cedaeba8f2a70a000dca8e31de20bcab2
Reviewed-on: https://gerrit.libreoffice.org/32334
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
diff --git a/sw/qa/extras/uiwriter/data/tdf66405.docx b/sw/qa/extras/uiwriter/data/tdf66405.docx
new file mode 100644
index 0000000..398b0ce
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf66405.docx differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 9db3dc1..1f4c032 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -220,6 +220,7 @@ public:
void testTdf104440();
void testTdf104425();
void testTdf104814();
+ void testTdf66405();
CPPUNIT_TEST_SUITE(SwUiWriterTest);
CPPUNIT_TEST(testReplaceForward);
@@ -336,6 +337,7 @@ public:
CPPUNIT_TEST(testTdf104440);
CPPUNIT_TEST(testTdf104425);
CPPUNIT_TEST(testTdf104814);
+ CPPUNIT_TEST(testTdf66405);
CPPUNIT_TEST_SUITE_END();
private:
@@ -4159,6 +4161,39 @@ void SwUiWriterTest::testTdf104814()
pEditShell->AcceptRedline(0);
}
+void SwUiWriterTest::testTdf66405()
+{
+ // Imported formula should have zero margins
+ createDoc("tdf66405.docx");
+ uno::Reference<text::XTextEmbeddedObjectsSupplier> xEmbeddedObjectsSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XNameAccess> xEmbeddedObjects = xEmbeddedObjectsSupplier->getEmbeddedObjects();
+ uno::Reference<beans::XPropertySet> xFormula;
+ xEmbeddedObjects->getByName(xEmbeddedObjects->getElementNames()[0]) >>= xFormula;
+ uno::Reference<beans::XPropertySet> xComponent;
+ xFormula->getPropertyValue("Component") >>= xComponent;
+
+ // Test embedded object's margins
+ sal_Int32 nLeftMargin, nRightMargin, nTopMargin, nBottomMargin;
+ xFormula->getPropertyValue("LeftMargin") >>= nLeftMargin;
+ xFormula->getPropertyValue("RightMargin") >>= nRightMargin;
+ xFormula->getPropertyValue("TopMargin") >>= nTopMargin;
+ xFormula->getPropertyValue("BottomMargin") >>= nBottomMargin;
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nLeftMargin);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nRightMargin);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nTopMargin);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nBottomMargin);
+
+ // Test embedded object component's margins
+ xComponent->getPropertyValue("LeftMargin") >>= nLeftMargin;
+ xComponent->getPropertyValue("RightMargin") >>= nRightMargin;
+ xComponent->getPropertyValue("TopMargin") >>= nTopMargin;
+ xComponent->getPropertyValue("BottomMargin") >>= nBottomMargin;
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nLeftMargin);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nRightMargin);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nTopMargin);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nBottomMargin);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 07e008f..3278f92 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1424,8 +1424,27 @@ void DomainMapper_Impl::appendStarMath( const Value& val )
xStarMathProperties->setPropertyValue(getPropertyName( PROP_EMBEDDED_OBJECT ),
val.getAny());
+ // tdf#66405: set zero margins for embedded object
+ xStarMathProperties->setPropertyValue(getPropertyName( PROP_LEFT_MARGIN ),
+ uno::makeAny(sal_Int32(0)));
+ xStarMathProperties->setPropertyValue(getPropertyName( PROP_RIGHT_MARGIN ),
+ uno::makeAny(sal_Int32(0)));
+ xStarMathProperties->setPropertyValue(getPropertyName( PROP_TOP_MARGIN ),
+ uno::makeAny(sal_Int32(0)));
+ xStarMathProperties->setPropertyValue(getPropertyName( PROP_BOTTOM_MARGIN ),
+ uno::makeAny(sal_Int32(0)));
uno::Reference< uno::XInterface > xInterface( formula->getComponent(), uno::UNO_QUERY );
+ // set zero margins for object's component
+ uno::Reference< beans::XPropertySet > xComponentProperties( xInterface, uno::UNO_QUERY_THROW );
+ xComponentProperties->setPropertyValue(getPropertyName( PROP_LEFT_MARGIN ),
+ uno::makeAny(sal_Int32(0)));
+ xComponentProperties->setPropertyValue(getPropertyName( PROP_RIGHT_MARGIN ),
+ uno::makeAny(sal_Int32(0)));
+ xComponentProperties->setPropertyValue(getPropertyName( PROP_TOP_MARGIN ),
+ uno::makeAny(sal_Int32(0)));
+ xComponentProperties->setPropertyValue(getPropertyName( PROP_BOTTOM_MARGIN ),
+ uno::makeAny(sal_Int32(0)));
Size size( 1000, 1000 );
if( oox::FormulaImportBase* formulaimport = dynamic_cast< oox::FormulaImportBase* >( xInterface.get()))
size = formulaimport->getFormulaSize();
More information about the Libreoffice-commits
mailing list