tdf#151518 Do not tweak text area distances in Writer
The fix for tdf#148321 has introduced tweaks to the upper and lower text distances for the case, that their sum is larger than the text area height. That works well in import from PowerPoint but conflicts with import of SmartArt shapes from Word. Reason of the problem is not only the missing Twip to Hmm conversion in TextBodyProperties::readjustTextDistances(). But I have not found which detail in the tweak produces the wrong text location. For now I have disabled the tweak for import from Word. Maybe someone finds a better solution in future. Because the user cannot insert such large distances in Word and SmartArt shapes do not use such distances anyway, I think it does not harm to disable the method for text documents. Import from Excel cannot be tested because of tdf#83671. Change-Id: I2e133f6864bba4419ad96e94d88aec86fe97d0fa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141414 Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Tested-by: Jenkins
This commit is contained in:
BIN
oox/qa/unit/data/tdf151518_SmartArtTextLocation.docx
Normal file
BIN
oox/qa/unit/data/tdf151518_SmartArtTextLocation.docx
Normal file
Binary file not shown.
@@ -20,6 +20,8 @@
|
||||
#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
|
||||
#include <com/sun/star/frame/Desktop.hpp>
|
||||
#include <com/sun/star/beans/XPropertySet.hpp>
|
||||
|
||||
#include <officecfg/Office/Common.hxx>
|
||||
#include <rtl/math.hxx>
|
||||
#include <svx/svdoashp.hxx>
|
||||
|
||||
@@ -233,6 +235,58 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testTdf151008VertAnchor)
|
||||
}
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(OoxShapeTest, testTdf151518VertAnchor)
|
||||
{
|
||||
// Make sure SmartArt is loaded as group shape
|
||||
bool bUseGroup = officecfg::Office::Common::Filter::Microsoft::Import::SmartArtToShapes::get();
|
||||
if (!bUseGroup)
|
||||
{
|
||||
std::shared_ptr<comphelper::ConfigurationChanges> pChange(
|
||||
comphelper::ConfigurationChanges::create());
|
||||
officecfg::Office::Common::Filter::Microsoft::Import::SmartArtToShapes::set(true, pChange);
|
||||
pChange->commit();
|
||||
}
|
||||
|
||||
// The document contains SmartArt with shapes with not default text area. Without fix the
|
||||
// text was shifted up because of wrong values in TextLowerDistance and TextUpperDistance.
|
||||
load(u"tdf151518_SmartArtTextLocation.docx");
|
||||
|
||||
struct TextDistance
|
||||
{
|
||||
OUString sShapeName;
|
||||
sal_Int16 nSubShapeIndex;
|
||||
sal_Int32 nLowerDistance;
|
||||
sal_Int32 nUpperDistance;
|
||||
};
|
||||
TextDistance aExpected[4] = { { u"Diagram Target List", 2, 2979, 201 },
|
||||
{ u"Diagram Nested Target", 1, 3203, 127 },
|
||||
{ u"Diagram Stacked Venn", 1, 3112, -302 },
|
||||
{ u"Diagram Grouped List", 1, 4106, 196 } };
|
||||
// without the fix the observed distances were
|
||||
// {4434, -464}, {4674, -751}, {4620, -1399}, {6152, -744}
|
||||
for (size_t i = 0; i < 4; ++i)
|
||||
{
|
||||
uno::Reference<drawing::XShapes> xDiagramShape(getShapeByName(aExpected[i].sShapeName),
|
||||
uno::UNO_QUERY);
|
||||
uno::Reference<beans::XPropertySet> xShapeProps(
|
||||
xDiagramShape->getByIndex(aExpected[i].nSubShapeIndex), uno::UNO_QUERY);
|
||||
sal_Int32 nLower;
|
||||
sal_Int32 nUpper;
|
||||
CPPUNIT_ASSERT(xShapeProps->getPropertyValue("TextLowerDistance") >>= nLower);
|
||||
CPPUNIT_ASSERT(xShapeProps->getPropertyValue("TextUpperDistance") >>= nUpper);
|
||||
CPPUNIT_ASSERT_EQUAL(aExpected[i].nLowerDistance, nLower);
|
||||
CPPUNIT_ASSERT_EQUAL(aExpected[i].nUpperDistance, nUpper);
|
||||
}
|
||||
|
||||
if (!bUseGroup)
|
||||
{
|
||||
std::shared_ptr<comphelper::ConfigurationChanges> pChange(
|
||||
comphelper::ConfigurationChanges::create());
|
||||
officecfg::Office::Common::Filter::Microsoft::Import::SmartArtToShapes::set(false, pChange);
|
||||
pChange->commit();
|
||||
}
|
||||
}
|
||||
|
||||
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
@@ -99,6 +99,7 @@
|
||||
#include <tools/stream.hxx>
|
||||
#include <unotools/streamwrap.hxx>
|
||||
#include <unotools/fltrcfg.hxx>
|
||||
#include <unotools/mediadescriptor.hxx>
|
||||
#include <vcl/graph.hxx>
|
||||
#include <vcl/graphicfilter.hxx>
|
||||
#include <vcl/svapp.hxx>
|
||||
@@ -1892,9 +1893,15 @@ Reference< XShape > const & Shape::createAndInsert(
|
||||
finalizeXShape( rFilterBase, rxShapes );
|
||||
|
||||
if (mpTextBody)
|
||||
mpTextBody->getTextProperties().readjustTextDistances(mxShape);
|
||||
{
|
||||
// tdf#151518. The method readjustTextDistances is fix for tdf#148321, but conflicts with
|
||||
// text position in some of the SmartArt types in Writer. So exclude Writer here.
|
||||
OUString sDocumentService;
|
||||
rFilterBase.getMediaDescriptor()[utl::MediaDescriptor::PROP_DOCUMENTSERVICE] >>= sDocumentService;
|
||||
if (sDocumentService != u"com.sun.star.text.TextDocument")
|
||||
mpTextBody->getTextProperties().readjustTextDistances(mxShape);
|
||||
}
|
||||
}
|
||||
|
||||
return mxShape;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user