Kaydet (Commit) 4af4a473 authored tarafından Justin Luth's avatar Justin Luth Kaydeden (comit) Justin Luth

tdf#120225 ww8import: keep textform name

A bookmark cross-reference was trying to access the textform
field by name, but an autogenerated __Fieldmark__ name obviously
wasn't matching.

Change-Id: I1018fecf44fda5d947b214c599f1a405f311e2ee
Reviewed-on: https://gerrit.libreoffice.org/61565Reviewed-by: 's avatarJustin Luth <justin_luth@sil.org>
Tested-by: 's avatarJustin Luth <justin_luth@sil.org>
üst c8481c8a
......@@ -15122,6 +15122,7 @@ sw/qa/extras/txtexport/txtexport.cxx
sw/qa/extras/uiwriter/uiwriter.cxx
sw/qa/extras/ww8export/ww8export.cxx
sw/qa/extras/ww8export/ww8export2.cxx
sw/qa/extras/ww8export/ww8export3.cxx
sw/qa/extras/ww8import/ww8import.cxx
sw/qa/unit/sw-dialogs-test.cxx
sw/qa/unit/sw-dialogs-test_2.cxx
......
This diff was suppressed by a .gitattributes entry.
......@@ -31,6 +31,39 @@ public:
return OString(filename).endsWith(".doc");
}
};
DECLARE_WW8EXPORT_TEST(testTdf120225_textControlCrossRef, "tdf120225_textControlCrossRef.doc")
{
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
xRunEnum->nextElement();
uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(OUString("TextFieldStart"), getProperty<OUString>(xPropertySet, "TextPortionType"));
uno::Reference<container::XNamed> xBookmark(getProperty< uno::Reference<beans::XPropertySet> >(xPropertySet, "Bookmark"), uno::UNO_QUERY_THROW);
// Critical test: does TextField's bookmark name match cross-reference?
const OUString& sTextFieldName( xBookmark->getName() );
uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
CPPUNIT_ASSERT(xFields->hasMoreElements());
xPropertySet.set(xFields->nextElement(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sTextFieldName, getProperty<OUString>(xPropertySet, "SourceName"));
uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xBookmarksByIdx(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
uno::Reference<container::XNameAccess> xBookmarksByName(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
// TextFields should not be turned into real bookmarks.
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), xBookmarksByIdx->getCount());
// The actual name isn't critical, but if it fails, it is worth asking why.
CPPUNIT_ASSERT_EQUAL(OUString("Text1"), sTextFieldName);
}
DECLARE_WW8EXPORT_TEST(testTdf94009_zeroPgMargin, "tdf94009_zeroPgMargin.odt")
{
uno::Reference<beans::XPropertySet> defaultStyle(getStyles("PageStyles")->getByName("Standard"),
......
......@@ -407,9 +407,12 @@ namespace sw { namespace mark
xmlTextWriterEndElement(pWriter);
}
TextFieldmark::TextFieldmark(const SwPaM& rPaM)
TextFieldmark::TextFieldmark(const SwPaM& rPaM, const OUString& rName)
: Fieldmark(rPaM)
{ }
{
if ( !rName.isEmpty() )
m_aName = rName;
}
void TextFieldmark::InitDoc(SwDoc* const io_pDoc, sw::mark::InsertMode const eMode)
{
......
......@@ -410,7 +410,7 @@ namespace sw { namespace mark
switch(eType)
{
case IDocumentMarkAccess::MarkType::TEXT_FIELDMARK:
pMark = std::shared_ptr<IMark>(new TextFieldmark(rPaM));
pMark = std::shared_ptr<IMark>(new TextFieldmark(rPaM, rName));
break;
case IDocumentMarkAccess::MarkType::CHECKBOX_FIELDMARK:
pMark = std::shared_ptr<IMark>(new CheckboxFieldmark(rPaM));
......
......@@ -240,7 +240,7 @@ namespace sw {
: public Fieldmark
{
public:
TextFieldmark(const SwPaM& rPaM);
TextFieldmark(const SwPaM& rPaM, const OUString& rName);
virtual void InitDoc(SwDoc* const io_pDoc, sw::mark::InsertMode eMode) override;
virtual void ReleaseDoc(SwDoc* const pDoc) override;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment