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>
This commit is contained in:
parent
4252096c68
commit
c2a20af2c1
BIN
sw/qa/extras/uiwriter/data/tdf66405.docx
Normal file
BIN
sw/qa/extras/uiwriter/data/tdf66405.docx
Normal file
Binary file not shown.
@ -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();
|
||||
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user