[Libreoffice-commits] core.git: sw/CppunitTest_sw_ooxmlimport.mk sw/qa writerfilter/source
Miklos Vajna
vmiklos at collabora.co.uk
Thu Jan 28 12:40:06 PST 2016
sw/CppunitTest_sw_ooxmlimport.mk | 1 +
sw/qa/extras/ooxmlimport/data/tdf97371.docx |binary
sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 15 +++++++++++++++
writerfilter/source/dmapper/GraphicImport.cxx | 7 ++++++-
4 files changed, 22 insertions(+), 1 deletion(-)
New commits:
commit 8f1a1092d47947847e1d888b0284e8364c663d1f
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Jan 28 17:52:40 2016 +0100
tdf#97371 DOCX import: fix text covered by shape
Regression from commit 358666e4204364ce915ee95372dc6f2fca545253
(tdf#90153 DOCX import: fix default sw TextFrame roundtrip, 2015-09-28),
the problem was that at the moment SwTextBoxHelper::syncProperty()
doesn't handle an AnchorType at-para -> at-char transition, so the
importer shouldn't do that for TextBoxes till sw core gets extended to
support the scenario.
Change-Id: I8308bfd306672bc68984fbf019767c174130e18d
Reviewed-on: https://gerrit.libreoffice.org/21885
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Jenkins <ci at libreoffice.org>
diff --git a/sw/CppunitTest_sw_ooxmlimport.mk b/sw/CppunitTest_sw_ooxmlimport.mk
index 4074255..dbcead9 100644
--- a/sw/CppunitTest_sw_ooxmlimport.mk
+++ b/sw/CppunitTest_sw_ooxmlimport.mk
@@ -27,6 +27,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_ooxmlimport, \
sw \
tl \
vcl \
+ svxcore \
$(gb_UWINAPI) \
))
diff --git a/sw/qa/extras/ooxmlimport/data/tdf97371.docx b/sw/qa/extras/ooxmlimport/data/tdf97371.docx
new file mode 100644
index 0000000..87e67dd
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf97371.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 14ddf51..2fe18f8 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -74,10 +74,12 @@
#include <comphelper/sequenceashashmap.hxx>
#include <com/sun/star/text/GraphicCrop.hpp>
#include <swtypes.hxx>
+#include <drawdoc.hxx>
#include <tools/datetimeutils.hxx>
#include <oox/drawingml/drawingmltypes.hxx>
#include <unotools/streamwrap.hxx>
#include <comphelper/propertysequence.hxx>
+#include <svx/svdpage.hxx>
#include <com/sun/star/drawing/HomogenMatrix3.hpp>
#include <bordertest.hxx>
@@ -3064,6 +3066,19 @@ DECLARE_OOXMLIMPORT_TEST(testTdf95213, "tdf95213.docx")
CPPUNIT_ASSERT_EQUAL(awt::FontWeight::NORMAL, getProperty<float>(xStyle, "CharWeight"));
}
+DECLARE_OOXMLIMPORT_TEST(testTdf97371, "tdf97371.docx")
+{
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get());
+ CPPUNIT_ASSERT(pTextDoc);
+ SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
+ SdrPage* pPage = pDoc->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
+ SdrObject* pShape = pPage->GetObj(0);
+ SdrObject* pTextBox = pPage->GetObj(1);
+ long nDiff = std::abs(pShape->GetSnapRect().Top() - pTextBox->GetSnapRect().Top());
+ // The top of the two shapes were 410 and 3951, now it should be 3950 and 3951.
+ CPPUNIT_ASSERT(nDiff < 10);
+}
+
// base class to supply a helper method for testHFLinkToPrev
class testHFBase : public Test
{
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index a9d3225..735687d 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -805,8 +805,13 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue)
// This needs to be AT_PARAGRAPH by default and not AT_CHARACTER, otherwise shape will move when the user inserts a new paragraph.
text::TextContentAnchorType eAnchorType = text::TextContentAnchorType_AT_PARAGRAPH;
- if (m_pImpl->nVertRelation == text::RelOrientation::TEXT_LINE)
+
+ // Avoid setting AnchorType for TextBoxes till SwTextBoxHelper::syncProperty() doesn't handle transition.
+ bool bTextBox = false;
+ xShapeProps->getPropertyValue("TextBox") >>= bTextBox;
+ if (m_pImpl->nVertRelation == text::RelOrientation::TEXT_LINE && !bTextBox)
eAnchorType = text::TextContentAnchorType_AT_CHARACTER;
+
xShapeProps->setPropertyValue("AnchorType", uno::makeAny(eAnchorType));
//only the position orientation is handled in applyPosition()
More information about the Libreoffice-commits
mailing list