summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2016-12-22 13:50:17 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2016-12-23 03:56:12 +0000
commitc2a20af2c12bf75e7378a3a9dbc50a4dddabdebc (patch)
treebd60a4c11cb32ef539b72a36cfa57276f8d99e9e
parent4252096c68ce01ed8a06bcaf57260dbe46502cd3 (diff)
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@libreoffice.org> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r--sw/qa/extras/uiwriter/data/tdf66405.docxbin0 -> 13857 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx35
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx19
3 files changed, 54 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/data/tdf66405.docx b/sw/qa/extras/uiwriter/data/tdf66405.docx
new file mode 100644
index 000000000000..398b0ce77a11
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/tdf66405.docx
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 9db3dc1c85b3..1f4c03229bba 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 07e008feb32e..3278f9237538 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();