[Libreoffice-commits] core.git: sw/CppunitTest_sw_apitests.mk sw/inc sw/qa sw/source
sw/CppunitTest_sw_apitests.mk |1 sw/inc/unoframe.hxx | 15 ++--- sw/qa/api/SwXTextFrame.cxx | 107 sw/source/core/unocore/unoframe.cxx | 45 ++- 4 files changed, 145 insertions(+), 23 deletions(-) New commits: commit e2372c4bef2180ab8cbb04128accf6ab40654448 Author: Bjoern Michaelsen AuthorDate: Sun Sep 22 01:28:39 2019 +0200 Commit: Björn Michaelsen CommitDate: Mon Sep 23 10:44:16 2019 +0200 SwXFrame: SwClient no more Change-Id: I0831e662a5142ae824dde537baa8c2dd5d15671a Reviewed-on: https://gerrit.libreoffice.org/79369 Tested-by: Jenkins Reviewed-by: Björn Michaelsen diff --git a/sw/CppunitTest_sw_apitests.mk b/sw/CppunitTest_sw_apitests.mk index 370ed779d8b9..6f73e8406421 100644 --- a/sw/CppunitTest_sw_apitests.mk +++ b/sw/CppunitTest_sw_apitests.mk @@ -16,6 +16,7 @@ $(eval $(call gb_CppunitTest_use_external,sw_apitests,boost_headers)) $(eval $(call gb_CppunitTest_add_exception_objects,sw_apitests, \ sw/qa/api/SwXDocumentIndex \ sw/qa/api/SwXDocumentSettings \ + sw/qa/api/SwXTextFrame \ sw/qa/api/SwXTextField \ sw/qa/api/SwXTextTable \ )) diff --git a/sw/inc/unoframe.hxx b/sw/inc/unoframe.hxx index 207fbaac7414..c7e432a075ba 100644 --- a/sw/inc/unoframe.hxx +++ b/sw/inc/unoframe.hxx @@ -54,11 +54,12 @@ class SwXFrame : public cppu::WeakImplHelper css::container::XNamed, css::text::XTextContent >, -public SwClient +public SvtListener { private: class Impl; ::sw::UnoImplPtr m_pImpl; +SwFrameFormat* m_pFrameFormat; const SfxItemPropertySet* m_pPropSet; SwDoc* m_pDoc; @@ -76,11 +77,12 @@ private: sal_Int64 m_nVisibleAreaWidth; sal_Int64 m_nVisibleAreaHeight; css::uno::Reference m_xParentText; +void DisposeInternal(); protected: css::uno::Reference< css::beans::XPropertySet > mxStyleData; css::uno::Reference< css::container::XNameAccess > mxStyleFamily; -virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override; +virtual void Notify(const SfxHint&) override; virtual ~SwXFrame() override; @@ -149,13 +151,10 @@ public: void attachToRange(const css::uno::Reference< css::text::XTextRange > & xTextRange); const SwFrameFormat* GetFrameFormat() const -{ -return dynamic_cast( GetRegisteredIn() ); -} +{ return m_pFrameFormat; } SwFrameFormat* GetFrameFormat() -{ -return dynamic_cast< SwFrameFormat*>( GetRegisteredIn() ); -} +{ return m_pFrameFormat; } + FlyCntType GetFlyCntType()const {return eType;} bool IsDescriptor() const {return bIsDescriptor;} diff --git a/sw/qa/api/SwXTextFrame.cxx b/sw/qa/api/SwXTextFrame.cxx new file mode 100644 index ..546823b5dbe2 --- /dev/null +++ b/sw/qa/api/SwXTextFrame.cxx @@ -0,0 +1,107 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include + +using namespace css; + +namespace +{ +/** + * Test for Java API test of file com.sun.star.comp.office.SwXTextFrame.csv + */ +class SwXTextFrame final : public test::BootstrapFixture, + public unotest::MacrosTest, + public apitest::XServiceInfo, + public apitest::XComponent +{ +uno::Reference mxComponentContext; +uno::Reference mxTextDocument; +uno::Reference mxTextRange; +uno::Reference mxTextContent; + +public: +virtual void setUp() override; +virtual void tearDown() override; + +SwXTextFrame() +: apitest::XServiceInfo("SwXTextFrame", "com.sun.star.text.TextFrame"){}; +uno::Reference init() override; +uno::Reference getTextDocument() { return mxTextDocument; } +void triggerDesktopTerminate() override { mxDesktop->terminate(); } + +CPPUNIT_TEST_SUITE(SwXTextFrame); +CPPUNIT_TEST(testGetImplementationName); +CPPUNIT_TEST(testGetSupportedServiceNames); +CPPUNIT_TEST(testSupportsService); +CPPUNIT_TEST(testAddEventListener); +CPPUNIT_TEST(testRemoveEventListener); +CPPUNIT_TEST_SUITE_END(); +}; + +void SwXTextFrame::setUp() +{ +test::BootstrapFixture::setUp(); + + mxComponentContext.set(comphelper::getComponentContext(getMultiServiceFactory())); +mxDesktop.set(frame::Desktop::create(mxComponentContext)); +mxTextDocument = uno::Reference( +
[Libreoffice-commits] core.git: sw/CppunitTest_sw_apitests.mk sw/inc sw/qa sw/source
sw/CppunitTest_sw_apitests.mk |1 sw/inc/fmtfld.hxx |2 sw/qa/api/SwXTextField.cxx | 89 ++ sw/qa/python/xtext.py |8 + sw/source/core/txtnode/atrfld.cxx |4 sw/source/core/unocore/unofield.cxx | 174 6 files changed, 177 insertions(+), 101 deletions(-) New commits: commit e18359445fabad9ba1a704600e9ee327112cc6ae Author: Bjoern Michaelsen AuthorDate: Sun Apr 14 13:33:35 2019 +0200 Commit: Björn Michaelsen CommitDate: Sun May 5 22:27:54 2019 +0200 [API CHANGE] SwXTextField: no more SwModify/SwClient - fix unittest assuming the double-insertion of annotation throwing an IllegalArgumentException was intentional - remove SwModify/SwClient in SwXTextField - also: add basic C++ api test Change-Id: Ia4657dc65dfadc3e975bdf409bd5e43413ea1f5a Reviewed-on: https://gerrit.libreoffice.org/71452 Tested-by: Jenkins Reviewed-by: Björn Michaelsen diff --git a/sw/CppunitTest_sw_apitests.mk b/sw/CppunitTest_sw_apitests.mk index ca2c919e0aa6..370ed779d8b9 100644 --- a/sw/CppunitTest_sw_apitests.mk +++ b/sw/CppunitTest_sw_apitests.mk @@ -16,6 +16,7 @@ $(eval $(call gb_CppunitTest_use_external,sw_apitests,boost_headers)) $(eval $(call gb_CppunitTest_add_exception_objects,sw_apitests, \ sw/qa/api/SwXDocumentIndex \ sw/qa/api/SwXDocumentSettings \ +sw/qa/api/SwXTextField \ sw/qa/api/SwXTextTable \ )) diff --git a/sw/inc/fmtfld.hxx b/sw/inc/fmtfld.hxx index b144243ec4c9..d9eafeea82a3 100644 --- a/sw/inc/fmtfld.hxx +++ b/sw/inc/fmtfld.hxx @@ -36,7 +36,7 @@ namespace com { namespace sun { namespace star { namespace text { class XTextFie // ATT_FLD class SW_DLLPUBLIC SwFormatField : public SfxPoolItem -, public SwModify +, public sw::BroadcastingModify , public SfxBroadcaster { friend void InitCore(); diff --git a/sw/qa/api/SwXTextField.cxx b/sw/qa/api/SwXTextField.cxx new file mode 100644 index ..1de775d1e3d7 --- /dev/null +++ b/sw/qa/api/SwXTextField.cxx @@ -0,0 +1,89 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include +#include +#include + +#include + +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include + +using namespace css; +using namespace css::uno; +using namespace css::beans; + +namespace +{ +/** + * Initial tests for SwXTextField. + */ +struct SwXTextField final : public test::BootstrapFixture, +public unotest::MacrosTest, +public apitest::XComponent +{ +virtual void setUp() override; + +Reference init() override; +void triggerDesktopTerminate() override; + +CPPUNIT_TEST_SUITE(SwXTextField); +CPPUNIT_TEST(testAddEventListener); +CPPUNIT_TEST(testRemoveEventListener); +//CPPUNIT_TEST(testDisposedByDesktopTerminate); +CPPUNIT_TEST_SUITE_END(); +}; + +void SwXTextField::setUp() +{ +test::BootstrapFixture::setUp(); +mxDesktop.set( + frame::Desktop::create(comphelper::getComponentContext(getMultiServiceFactory(; +} + +void SwXTextField::triggerDesktopTerminate() { mxDesktop->terminate(); } + +Reference SwXTextField::init() +{ +auto xComponent = loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument"); +CPPUNIT_ASSERT(xComponent.is()); +Reference xTextDocument(xComponent, UNO_QUERY_THROW); +Reference xMSF(xComponent, UNO_QUERY_THROW); + +Reference xFieldMaster( +xMSF->createInstance("com.sun.star.text.FieldMaster.Database"), UNO_QUERY_THROW); +xFieldMaster->setPropertyValue("DataBaseName", makeAny(OUString("Address Book File"))); +xFieldMaster->setPropertyValue("DataTableName", makeAny(OUString("address"))); +xFieldMaster->setPropertyValue("DataColumnName", makeAny(OUString("FIRSTNAME"))); + +Reference xField( +xMSF->createInstance("com.sun.star.text.TextField.Database"), UNO_QUERY_THROW); +xField->attachTextFieldMaster(xFieldMaster); +Reference xText = xTextDocument->getText(); +Reference xCursor = xText->createTextCursor(); +Reference xFieldAsContent(xField, UNO_QUERY_THROW); +xText->insertTextContent(xCursor, xFieldAsContent, false); +return Reference(xField, UNO_QUERY_THROW); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(SwXTextField); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/python/xtext.py b/sw/qa/python/xtext.py index d137cb1f69ce..b8bc25d90e92 100644 --- a/sw/qa/python/xtext.py +++ b/sw/qa/python/xtext.py @@ -37,9 +37,11 @@ class TestXText(unittest.TestCase): # And the