sw/qa/extras/ooxmlexport/data/tdf90789.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport7.cxx | 16 ++++++++++++++++ sw/source/core/unocore/unotext.cxx | 19 ++++++++++++------- 3 files changed, 28 insertions(+), 7 deletions(-)
New commits: commit 06f71499e1a62386e8980a497086216282303170 Author: Vasily Melenchuk <vasily.melenc...@cib.de> Date: Thu Oct 5 20:20:03 2017 +0300 tdf#90789 Anchored frames and shapes are identified by name/SdrObjects Previously shapes/frames were identified either by name or by SdrObject, but in some cases name can be empty. New approach is to use names if they exist and SdrObject reference if name is empty. This is just a partial fix for mentioned TDF issue. Reviewed-on: https://gerrit.libreoffice.org/43176 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de> Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport9.cxx Change-Id: I3bd53f07fdb3fe69b2898d855eda48b6534cd75d diff --git a/sw/qa/extras/ooxmlexport/data/tdf90789.docx b/sw/qa/extras/ooxmlexport/data/tdf90789.docx new file mode 100644 index 000000000000..b94b2ad7f7ff Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf90789.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx index 7d733ebf49d2..485ceebbcc09 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx @@ -24,6 +24,7 @@ #include <com/sun/star/text/HoriOrientation.hpp> #include <com/sun/star/text/RelOrientation.hpp> #include <com/sun/star/graphic/XGraphic.hpp> +#include <com/sun/star/view/XSelectionSupplier.hpp> #include <pagedesc.hxx> #include <comphelper/sequenceashashmap.hxx> @@ -1846,6 +1847,21 @@ DECLARE_OOXMLEXPORT_TEST(testTdf65955_2, "tdf65955_2.odt") CPPUNIT_ASSERT_EQUAL(xRange3->getString(), OUString("foo bar")); } +DECLARE_OOXMLEXPORT_TEST(testTdf90789, "tdf90789.docx") +{ + uno::Reference<text::XTextContent> xShape(getShape(1), uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT(xShape->getAnchor() != nullptr); + + uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY_THROW); + uno::Reference<view::XSelectionSupplier> xCtrl(xModel->getCurrentController(), uno::UNO_QUERY_THROW); + xCtrl->select(uno::makeAny(xShape->getAnchor())); + + uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xCtrl, uno::UNO_QUERY_THROW); + uno::Reference<text::XTextViewCursor> xTextCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY_THROW); + uno::Reference<text::XPageCursor> xPageCursor(xTextCursor.get(), uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(1), xPageCursor->getPage()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index f87543c69114..3255daa35c21 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -1653,9 +1653,9 @@ SwXText::convertToTextFrame( pEndPam.reset(nullptr); // see if there are frames already anchored to this node - std::set<OUString> aAnchoredFrames; - // for shapes, we have to work with the SdrObjects, as unique name is not guaranteed in their frame format - std::set<const SdrObject*> aAnchoredShapes; + // we have to work with the SdrObjects, as unique name is not guaranteed in their frame format + std::set<const SdrObject*> aAnchoredObjectsByPtr; + std::set<OUString> aAnchoredObjectsByName; for (size_t i = 0; i < m_pImpl->m_pDoc->GetSpzFrameFormats()->size(); ++i) { const SwFrameFormat* pFrameFormat = (*m_pImpl->m_pDoc->GetSpzFrameFormats())[i]; @@ -1664,10 +1664,14 @@ SwXText::convertToTextFrame( aStartPam.Start()->nNode.GetIndex() <= rAnchor.GetContentAnchor()->nNode.GetIndex() && aStartPam.End()->nNode.GetIndex() >= rAnchor.GetContentAnchor()->nNode.GetIndex()) { - if (pFrameFormat->Which() == RES_DRAWFRMFMT) - aAnchoredShapes.insert(pFrameFormat->FindSdrObject()); + if (pFrameFormat->GetName().isEmpty()) + { + aAnchoredObjectsByPtr.insert(pFrameFormat->FindSdrObject()); + } else - aAnchoredFrames.insert(pFrameFormat->GetName()); + { + aAnchoredObjectsByName.insert(pFrameFormat->GetName()); + } } } @@ -1712,7 +1716,8 @@ SwXText::convertToTextFrame( for (size_t i = 0; i < m_pImpl->m_pDoc->GetSpzFrameFormats()->size(); ++i) { SwFrameFormat* pFrameFormat = (*m_pImpl->m_pDoc->GetSpzFrameFormats())[i]; - if (aAnchoredFrames.find(pFrameFormat->GetName()) != aAnchoredFrames.end() || aAnchoredShapes.find(pFrameFormat->FindSdrObject()) != aAnchoredShapes.end()) + if ((!pFrameFormat->GetName().isEmpty() && aAnchoredObjectsByName.find(pFrameFormat->GetName()) != aAnchoredObjectsByName.end() ) || + ( pFrameFormat->GetName().isEmpty() && aAnchoredObjectsByPtr.find(pFrameFormat->FindSdrObject()) != aAnchoredObjectsByPtr.end()) ) { // copy the anchor to the next paragraph SwFormatAnchor aAnchor(pFrameFormat->GetAnchor()); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits