sw/inc/fldbas.hxx | 11 ++++++----- sw/source/core/fields/fldbas.cxx | 8 ++++++++ sw/source/core/unocore/unofield.cxx | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-)
New commits: commit e5e4472e4ebe0f84087cfaa551e3fc28e94fd399 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Tue Apr 18 22:52:02 2023 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Apr 19 11:25:21 2023 +0200 use more concrete UNO type in SwFieldType Change-Id: Iffb0ffad6daf102299fa7ce072bfc117cdf38b55 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150589 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/inc/fldbas.hxx b/sw/inc/fldbas.hxx index 8ece6e214da1..4aa874c3021d 100644 --- a/sw/inc/fldbas.hxx +++ b/sw/inc/fldbas.hxx @@ -28,6 +28,8 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <cppuhelper/weakref.hxx> #include <editeng/svxenum.hxx> +#include <unotools/weakref.hxx> +#include <rtl/ref.hxx> #include <vector> #include <climits> @@ -39,6 +41,7 @@ class SwRootFrame; class SvNumberFormatter; class IDocumentRedlineAccess; class SwGetRefField; +class SwXFieldMaster; namespace com::sun::star::uno { class Any; } typedef struct _xmlTextWriter* xmlTextWriterPtr; @@ -242,7 +245,7 @@ SwFieldTypesEnum SwFieldTypeFromString(std::u16string_view rString); class SW_DLLPUBLIC SwFieldType : public sw::BroadcastingModify { - css::uno::WeakReference<css::beans::XPropertySet> m_wXFieldMaster; + unotools::WeakReference<SwXFieldMaster> m_wXFieldMaster; SwFieldIds m_nWhich; @@ -257,12 +260,10 @@ protected: public: - SAL_DLLPRIVATE css::uno::WeakReference<css::beans::XPropertySet> const& GetXObject() const { + unotools::WeakReference<SwXFieldMaster> const& GetXObject() const { return m_wXFieldMaster; } - SAL_DLLPRIVATE void SetXObject(css::uno::Reference<css::beans::XPropertySet> const& xFieldMaster) { - m_wXFieldMaster = xFieldMaster; - } + void SetXObject(rtl::Reference<SwXFieldMaster> const& xFieldMaster); static const OUString & GetTypeStr( SwFieldTypesEnum nTypeId ); diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx index f511c047b183..c528f2a0d65a 100644 --- a/sw/source/core/fields/fldbas.cxx +++ b/sw/source/core/fields/fldbas.cxx @@ -43,6 +43,7 @@ #include <calbck.hxx> #include <viewsh.hxx> #include <hints.hxx> +#include <unofield.hxx> using namespace ::com::sun::star; using namespace nsSwDocInfoSubType; @@ -220,6 +221,11 @@ void SwFieldType::UpdateFields() CallSwClientNotify(sw::LegacyModifyHint(nullptr, nullptr)); }; +void SwFieldType::SetXObject(rtl::Reference<SwXFieldMaster> const& xFieldMaster) +{ + m_wXFieldMaster = xFieldMaster.get(); +} + void SwFieldTypes::dumpAsXml(xmlTextWriterPtr pWriter) const { (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwFieldTypes")); @@ -229,6 +235,8 @@ void SwFieldTypes::dumpAsXml(xmlTextWriterPtr pWriter) const (void)xmlTextWriterEndElement(pWriter); } + + // Base class for all fields. // A field (multiple can exist) references a field type (can exists only once) SwField::SwField( diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index 019da24f7241..36a4f5b27bc6 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -528,7 +528,7 @@ SwXFieldMaster::CreateXFieldMaster(SwDoc * pDoc, SwFieldType *const pType, rtl::Reference<SwXFieldMaster> xFM; if (pType) { - xFM = dynamic_cast<SwXFieldMaster*>(pType->GetXObject().get().get()); + xFM = pType->GetXObject().get(); } if (!xFM.is()) {