solenv/clang-format/blacklist | 1 sw/qa/extras/ww8export/data/tdf120225_textControlCrossRef.doc |binary sw/qa/extras/ww8export/ww8export.cxx | 6 + 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 sw/source/filter/ww8/wrtww8.cxx | 1 8 files changed, 48 insertions(+), 4 deletions(-)
New commits: commit 6b9fb354be966e00b9b9425eb99ec1a339babe22 Author: Justin Luth <justin.l...@collabora.com> AuthorDate: Wed Oct 10 23:38:22 2018 +0300 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Thu Oct 11 10:39:37 2018 +0200 related tdf#120225 ww8export: save PROTECT_FORM Change-Id: I20664f8c2dc2c49feec17ee6a1df72776d43cc40 Reviewed-on: https://gerrit.libreoffice.org/61635 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_l...@sil.org> (cherry picked from commit 9943f37e8a80f2c4df6d58da4c50f3e7f3d6f3ce) diff --git a/sw/qa/extras/ww8export/ww8export.cxx b/sw/qa/extras/ww8export/ww8export.cxx index bcbaad089c59..ea0333ace59f 100644 --- a/sw/qa/extras/ww8export/ww8export.cxx +++ b/sw/qa/extras/ww8export/ww8export.cxx @@ -11,6 +11,7 @@ //#include <com/sun/star/text/XDependentTextField.hpp> +#include <IDocumentSettingAccess.hxx> #include <com/sun/star/awt/FontWeight.hpp> #include <com/sun/star/awt/Size.hpp> #include <com/sun/star/awt/XBitmap.hpp> @@ -382,6 +383,11 @@ DECLARE_WW8EXPORT_TEST(testCp1000044, "cp1000044.doc") uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); // It wasn't possible to fill out this form. CPPUNIT_ASSERT_EQUAL(false, bool(xStorable->isReadonly())); + + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); + CPPUNIT_ASSERT_EQUAL( true, pDoc->getIDocumentSettingAccess().get( DocumentSettingId::PROTECT_FORM ) ); } DECLARE_WW8EXPORT_TEST(testBorderColours, "bordercolours.doc") diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index afef206af619..374665f56ec8 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -510,6 +510,7 @@ static void WriteDop( WW8Export& rWrt ) } if ((rWrt.pSepx && rWrt.pSepx->DocumentIsProtected()) || + rWrt.m_pDoc->getIDocumentSettingAccess().get(DocumentSettingId::PROTECT_FORM ) || rDop.lKeyProtDoc != 0) { rDop.fProtEnabled = true; commit 5c57e18a775cf82714f7dfd385d970b7a5439c88 Author: Justin Luth <justin.l...@collabora.com> AuthorDate: Tue Oct 9 07:30:48 2018 +0300 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Thu Oct 11 10:39:23 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_l...@sil.org> Tested-by: Justin Luth <justin_l...@sil.org> (cherry picked from commit 4af4a473daf8b2530e6b6f5e49c7f4e3413f8378) 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 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 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; }; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits