summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2018-10-09 07:30:48 +0300
committerAndras Timar <andras.timar@collabora.com>2018-10-11 10:39:23 +0200
commit5c57e18a775cf82714f7dfd385d970b7a5439c88 (patch)
tree4a186b182ac1037468359213021d31ecd7cbe456
parentd878b20f968a27a9643da629303bc6880ebfc2c9 (diff)
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/61565 Reviewed-by: Justin Luth <justin_luth@sil.org> Tested-by: Justin Luth <justin_luth@sil.org> (cherry picked from commit 4af4a473daf8b2530e6b6f5e49c7f4e3413f8378)
-rw-r--r--solenv/clang-format/blacklist1
-rw-r--r--sw/qa/extras/ww8export/data/tdf120225_textControlCrossRef.docbin0 -> 27136 bytes
-rw-r--r--sw/qa/extras/ww8export/ww8export3.cxx33
-rw-r--r--sw/source/core/crsr/bookmrk.cxx7
-rw-r--r--sw/source/core/doc/docbm.cxx2
-rw-r--r--sw/source/core/inc/bookmrk.hxx2
6 files changed, 41 insertions, 4 deletions
diff --git a/solenv/clang-format/blacklist b/solenv/clang-format/blacklist
index 96c80f2da548..f0128a230229 100644
--- a/solenv/clang-format/blacklist
+++ b/solenv/clang-format/blacklist
@@ -15252,6 +15252,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
diff --git a/sw/qa/extras/ww8export/data/tdf120225_textControlCrossRef.doc b/sw/qa/extras/ww8export/data/tdf120225_textControlCrossRef.doc
new file mode 100644
index 000000000000..713cdc336ba1
--- /dev/null
+++ b/sw/qa/extras/ww8export/data/tdf120225_textControlCrossRef.doc
Binary files differ
diff --git a/sw/qa/extras/ww8export/ww8export3.cxx b/sw/qa/extras/ww8export/ww8export3.cxx
index 8adc21445a6d..41d4ddcfe84f 100644
--- a/sw/qa/extras/ww8export/ww8export3.cxx
+++ b/sw/qa/extras/ww8export/ww8export3.cxx
@@ -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"),
diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx
index 8ea7445ea676..630bfe9c11d1 100644
--- a/sw/source/core/crsr/bookmrk.cxx
+++ b/sw/source/core/crsr/bookmrk.cxx
@@ -406,9 +406,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)
{
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index ba2279853128..c76fb55a6313 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -409,7 +409,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));
diff --git a/sw/source/core/inc/bookmrk.hxx b/sw/source/core/inc/bookmrk.hxx
index 76363043e505..6daa37d1d7e4 100644
--- a/sw/source/core/inc/bookmrk.hxx
+++ b/sw/source/core/inc/bookmrk.hxx
@@ -229,7 +229,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;
};