diff options
author | Vasily Melenchuk <Vasily.Melenchuk@cib.de> | 2017-10-05 20:20:03 +0300 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2017-10-09 01:58:01 +0200 |
commit | b98c65538e9d9079e0d0f97793db76759a057beb (patch) | |
tree | a82a6947a551f14f16ce88c4049a3f6862e21f76 /sw | |
parent | b3ee9827d9cc7fd560b3bc06b2e6b435c9225a7b (diff) |
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.
Change-Id: I3bd53f07fdb3fe69b2898d855eda48b6534cd75d
Reviewed-on: https://gerrit.libreoffice.org/43176
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf90789.docx | bin | 0 -> 12023 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport9.cxx | 17 | ||||
-rw-r--r-- | sw/source/core/unocore/unotext.cxx | 19 |
3 files changed, 29 insertions, 7 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf90789.docx b/sw/qa/extras/ooxmlexport/data/tdf90789.docx Binary files differnew file mode 100644 index 000000000000..b94b2ad7f7ff --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf90789.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx index b4731f41de50..a612b14bfee2 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx @@ -27,6 +27,7 @@ #include <com/sun/star/text/VertOrientation.hpp> #include <com/sun/star/text/WrapTextMode.hpp> #include <com/sun/star/view/XViewSettingsSupplier.hpp> +#include <com/sun/star/view/XSelectionSupplier.hpp> #include <com/sun/star/style/LineSpacing.hpp> #include <com/sun/star/style/LineSpacingMode.hpp> #include <com/sun/star/drawing/XControlShape.hpp> @@ -1082,6 +1083,22 @@ DECLARE_OOXMLEXPORT_TEST(testTdf103090, "tdf103090.odt") CPPUNIT_ASSERT_EQUAL(expectedFieldName, fieldName); } +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 48a3ff6109f1..8170ecaa9fb7 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -1622,9 +1622,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]; @@ -1633,10 +1633,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()); + } } } @@ -1681,7 +1685,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()); |