[Libreoffice-commits] core.git: solenv/clang-format sw/qa sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Oct 11 03:54:11 UTC 2018
solenv/clang-format/blacklist | 1
sw/qa/extras/ww8export/data/tdf120225_textControlCrossRef.doc |binary
sw/qa/extras/ww8export/ww8export3.cxx | 33 ++++++++++
sw/source/core/crsr/bookmrk.cxx | 7 +-
sw/source/core/doc/docbm.cxx | 2
sw/source/core/inc/bookmrk.hxx | 2
6 files changed, 41 insertions(+), 4 deletions(-)
New commits:
commit 4af4a473daf8b2530e6b6f5e49c7f4e3413f8378
Author: Justin Luth <justin.luth at collabora.com>
AuthorDate: Tue Oct 9 07:30:48 2018 +0300
Commit: Justin Luth <justin_luth at sil.org>
CommitDate: Thu Oct 11 05:53:44 2018 +0200
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 at sil.org>
Tested-by: Justin Luth <justin_luth at sil.org>
diff --git a/solenv/clang-format/blacklist b/solenv/clang-format/blacklist
index 16dc194b4dce..7f423cac9d51 100644
--- a/solenv/clang-format/blacklist
+++ b/solenv/clang-format/blacklist
@@ -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
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
Binary files /dev/null and b/sw/qa/extras/ww8export/data/tdf120225_textControlCrossRef.doc 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 827ac187185c..1fa3e307aca5 100644
--- a/sw/source/core/crsr/bookmrk.cxx
+++ b/sw/source/core/crsr/bookmrk.cxx
@@ -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)
{
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 5fdaa58590e1..aaa9731bba31 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -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));
diff --git a/sw/source/core/inc/bookmrk.hxx b/sw/source/core/inc/bookmrk.hxx
index 001f8561b012..d5f0495ef09e 100644
--- a/sw/source/core/inc/bookmrk.hxx
+++ b/sw/source/core/inc/bookmrk.hxx
@@ -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;
};
More information about the Libreoffice-commits
mailing list