diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2024-08-06 16:19:01 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-08-08 15:51:19 +0200 |
commit | 5b1bf578fb23ab929602715077138a5362dcb5ce (patch) | |
tree | 6c41a6ce274f65a003b224ab1e0d7245f0699862 | |
parent | 2c9f8ad2705834cdbe208373e10a0daad1040fd2 (diff) |
use more concrete UNO type in writerfilter
Change-Id: I25af4b33b1a1a98e93ff9564175ec4d067b0aae0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171601
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | sw/inc/unocoll.hxx | 4 | ||||
-rw-r--r-- | sw/inc/unotext.hxx | 4 | ||||
-rw-r--r-- | sw/inc/unotxdoc.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/unocore/unocoll.cxx | 11 | ||||
-rw-r--r-- | sw/source/uibase/uno/unotxdoc.cxx | 10 | ||||
-rw-r--r-- | sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx | 60 | ||||
-rw-r--r-- | sw/source/writerfilter/dmapper/DomainMapper_Impl.hxx | 4 | ||||
-rw-r--r-- | sw/source/writerfilter/dmapper/PropertyMap.hxx | 7 |
8 files changed, 58 insertions, 44 deletions
diff --git a/sw/inc/unocoll.hxx b/sw/inc/unocoll.hxx index 0ecca6fb45c2..365336ad61f3 100644 --- a/sw/inc/unocoll.hxx +++ b/sw/inc/unocoll.hxx @@ -463,7 +463,7 @@ public: SwXFootnotes(bool bEnd, SwDoc* pDoc); //XIndexAccess - virtual sal_Int32 SAL_CALL getCount() override; + SW_DLLPUBLIC virtual sal_Int32 SAL_CALL getCount() override; virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override; //XElementAccess @@ -475,6 +475,8 @@ public: virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + SW_DLLPUBLIC rtl::Reference<SwXFootnote> getFootnoteByIndex(sal_Int32 nIndex) ; + static rtl::Reference<SwXFootnote> GetObject( SwDoc& rDoc, const SwFormatFootnote& rFormat ); }; diff --git a/sw/inc/unotext.hxx b/sw/inc/unotext.hxx index 751a1a213070..237a1e4b31f5 100644 --- a/sw/inc/unotext.hxx +++ b/sw/inc/unotext.hxx @@ -135,7 +135,7 @@ public: SW_DLLPUBLIC virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override; virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() override; virtual OUString SAL_CALL getString() override; - virtual void SAL_CALL setString(const OUString& rString) override; + SW_DLLPUBLIC virtual void SAL_CALL setString(const OUString& rString) override; // XSimpleText virtual void SAL_CALL insertString( @@ -220,7 +220,7 @@ public: rTableProperties) override; // XTextCopy - virtual void SAL_CALL copyText( + SW_DLLPUBLIC virtual void SAL_CALL copyText( const css::uno::Reference< css::text::XTextCopy >& xSource ) override; // XTextRangeCompare diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx index b7494d2f0c98..9b2824700fa4 100644 --- a/sw/inc/unotxdoc.hxx +++ b/sw/inc/unotxdoc.hxx @@ -522,6 +522,8 @@ public: SwDocShell* GetDocShell() {return m_pDocShell;} + rtl::Reference<SwXFootnotes> getSwXFootnotes(); + rtl::Reference<SwXFootnotes> getSwXEndnotes(); rtl::Reference<SwXTextFieldMasters> getSwXTextFieldMasters(); rtl::Reference<SwXFieldMaster> createFieldMaster(std::u16string_view sServiceName); rtl::Reference<SwXTextField> createTextField(std::u16string_view sServiceName); diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index 7bd99220f931..0a6c269e3eee 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -1704,15 +1704,19 @@ sal_Int32 SwXFootnotes::getCount() uno::Any SwXFootnotes::getByIndex(sal_Int32 nIndex) { + return uno::Any(uno::Reference< XFootnote >(getFootnoteByIndex(nIndex))); +} + +rtl::Reference<SwXFootnote> SwXFootnotes::getFootnoteByIndex(sal_Int32 nIndex) +{ SolarMutexGuard aGuard; - uno::Any aRet; + rtl::Reference<SwXFootnote> xRef; sal_Int32 nCount = 0; auto& rDoc = GetDoc(); auto& rIdxs = rDoc.GetFootnoteIdxs(); const size_t nFootnoteCnt = rIdxs.size(); SwTextFootnote* pTextFootnote; - uno::Reference< XFootnote > xRef; for( size_t n = 0; n < nFootnoteCnt; ++n ) { pTextFootnote = rIdxs[n]; @@ -1724,7 +1728,6 @@ uno::Any SwXFootnotes::getByIndex(sal_Int32 nIndex) { xRef = SwXFootnote::CreateXFootnote(rDoc, &const_cast<SwFormatFootnote&>(rFootnote)); - aRet <<= xRef; break; } nCount++; @@ -1732,7 +1735,7 @@ uno::Any SwXFootnotes::getByIndex(sal_Int32 nIndex) if(!xRef.is()) throw IndexOutOfBoundsException(); - return aRet; + return xRef; } uno::Type SAL_CALL SwXFootnotes::getElementType() diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 300f7b81bb61..23d4d3974c79 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -620,6 +620,11 @@ Reference< XIndexAccess > SwXTextDocument::getNumberingRules() Reference< XIndexAccess > SwXTextDocument::getFootnotes() { + return getSwXFootnotes(); +} + +rtl::Reference< SwXFootnotes > SwXTextDocument::getSwXFootnotes() +{ SolarMutexGuard aGuard; ThrowIfInvalid(); if(!mxXFootnotes.is()) @@ -643,6 +648,11 @@ Reference< XPropertySet > SAL_CALL Reference< XIndexAccess > SwXTextDocument::getEndnotes() { + return getSwXEndnotes(); +} + +rtl::Reference< SwXFootnotes > SwXTextDocument::getSwXEndnotes() +{ SolarMutexGuard aGuard; ThrowIfInvalid(); if(!mxXEndnotes.is()) diff --git a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx index 9f4920657a03..a00466a10e0b 100644 --- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx +++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx @@ -4370,24 +4370,24 @@ static void lcl_PasteRedlines( } bool DomainMapper_Impl::CopyTemporaryNotes( - uno::Reference< text::XFootnote > xNoteSrc, - uno::Reference< text::XFootnote > xNoteDest ) + rtl::Reference< SwXFootnote > xNoteSrc, + rtl::Reference< SwXFootnote > xNoteDest ) { if (!m_bSaxError && xNoteSrc != xNoteDest) { - uno::Reference< text::XText > xSrc( xNoteSrc, uno::UNO_QUERY_THROW ); - uno::Reference< text::XText > xDest( xNoteDest, uno::UNO_QUERY_THROW ); - uno::Reference< text::XTextCopy > xTxt, xTxt2; - xTxt.set( xSrc, uno::UNO_QUERY_THROW ); - xTxt2.set( xDest, uno::UNO_QUERY_THROW ); - xTxt2->copyText( xTxt ); +// uno::Reference< text::XText > xSrc( xNoteSrc, uno::UNO_QUERY_THROW ); +// uno::Reference< text::XText > xDest( xNoteDest, uno::UNO_QUERY_THROW ); +// uno::Reference< text::XTextCopy > xTxt, xTxt2; +// xTxt.set( xSrc, uno::UNO_QUERY_THROW ); +// xTxt2.set( xDest, uno::UNO_QUERY_THROW ); + xNoteDest->copyText( xNoteSrc ); // copy its redlines std::vector<sal_Int32> redPos, redLen; sal_Int32 redIdx; enum StoredRedlines eType = IsInFootnote() ? StoredRedlines::FOOTNOTE : StoredRedlines::ENDNOTE; - lcl_CopyRedlines(xSrc, m_aStoredRedlines[eType], redPos, redLen, redIdx); - lcl_PasteRedlines(xDest, m_aStoredRedlines[eType], redPos, redLen, redIdx); + lcl_CopyRedlines(xNoteSrc, m_aStoredRedlines[eType], redPos, redLen, redIdx); + lcl_PasteRedlines(xNoteDest, m_aStoredRedlines[eType], redPos, redLen, redIdx); // remove processed redlines for( size_t i = 0; redIdx > -1 && i <= sal::static_int_cast<size_t>(redIdx) + 2; i++) @@ -4402,40 +4402,36 @@ bool DomainMapper_Impl::CopyTemporaryNotes( void DomainMapper_Impl::RemoveTemporaryFootOrEndnotes() { rtl::Reference< SwXTextDocument> xTextDoc( GetTextDocument() ); - uno::Reference< text::XFootnote > xNote; + rtl::Reference< SwXFootnote > xNote; if (GetFootnoteCount() > 0) { - auto xFootnotes = xTextDoc->getFootnotes(); + rtl::Reference<SwXFootnotes> xFootnotes = xTextDoc->getSwXFootnotes(); if ( m_nFirstFootnoteIndex > 0 ) { - uno::Reference< text::XFootnote > xFirstNote; - xFootnotes->getByIndex(0) >>= xFirstNote; - uno::Reference< text::XText > xText( xFirstNote, uno::UNO_QUERY_THROW ); - xText->setString(u""_ustr); - xFootnotes->getByIndex(m_nFirstFootnoteIndex) >>= xNote; + rtl::Reference< SwXFootnote > xFirstNote = xFootnotes->getFootnoteByIndex(0); + xFirstNote->setString(u""_ustr); + xNote = xFootnotes->getFootnoteByIndex(m_nFirstFootnoteIndex); CopyTemporaryNotes(xNote, xFirstNote); } for (sal_Int32 i = GetFootnoteCount(); i > 0; --i) { - xFootnotes->getByIndex(i) >>= xNote; + xNote = xFootnotes->getFootnoteByIndex(i); xNote->getAnchor()->setString(u""_ustr); } } if (GetEndnoteCount() > 0) { - auto xEndnotes = xTextDoc->getEndnotes(); + rtl::Reference<SwXFootnotes> xEndnotes = xTextDoc->getSwXEndnotes(); if ( m_nFirstEndnoteIndex > 0 ) { - uno::Reference< text::XFootnote > xFirstNote; - xEndnotes->getByIndex(0) >>= xFirstNote; - uno::Reference< text::XText > xText( xFirstNote, uno::UNO_QUERY_THROW ); - xText->setString(u""_ustr); - xEndnotes->getByIndex(m_nFirstEndnoteIndex) >>= xNote; + rtl::Reference< SwXFootnote > xFirstNote = xEndnotes->getFootnoteByIndex(0); + xFirstNote->setString(u""_ustr); + xNote = xEndnotes->getFootnoteByIndex(m_nFirstEndnoteIndex); CopyTemporaryNotes(xNote, xFirstNote); } for (sal_Int32 i = GetEndnoteCount(); i > 0; --i) { - xEndnotes->getByIndex(i) >>= xNote; + xNote = xEndnotes->getFootnoteByIndex(i); xNote->getAnchor()->setString(u""_ustr); } } @@ -4473,13 +4469,13 @@ void DomainMapper_Impl::PopFootOrEndnote() if ( m_xTextDocument && IsInFootOrEndnote() && ( ( IsInFootnote() && GetFootnoteCount() > -1 ) || ( !IsInFootnote() && GetEndnoteCount() > -1 ) ) ) { - uno::Reference< text::XFootnote > xNoteFirst, xNoteLast; - auto xFootnotes = m_xTextDocument->getFootnotes(); - auto xEndnotes = m_xTextDocument->getEndnotes(); + rtl::Reference< SwXFootnote > xNoteFirst, xNoteLast; + rtl::Reference<SwXFootnotes> xFootnotes = m_xTextDocument->getSwXFootnotes(); + rtl::Reference<SwXFootnotes> xEndnotes = m_xTextDocument->getSwXEndnotes(); if ( ( ( IsInFootnote() && xFootnotes->getCount() > 1 && - ( xFootnotes->getByIndex(xFootnotes->getCount()-1) >>= xNoteLast ) ) || + ( xNoteLast = xFootnotes->getFootnoteByIndex(xFootnotes->getCount()-1) ) ) || ( !IsInFootnote() && xEndnotes->getCount() > 1 && - ( xEndnotes->getByIndex(xEndnotes->getCount()-1) >>= xNoteLast ) ) + ( xNoteLast = xEndnotes->getFootnoteByIndex(xEndnotes->getCount()-1) ) ) ) && xNoteLast->getLabel().isEmpty() ) { // copy content of the next temporary footnote @@ -4493,7 +4489,7 @@ void DomainMapper_Impl::PopFootOrEndnote() m_bSaxError = true; else { - xFootnotes->getByIndex(m_aFootnoteIds.front()) >>= xNoteFirst; + xNoteFirst = xFootnotes->getFootnoteByIndex(m_aFootnoteIds.front()); m_aFootnoteIds.pop_front(); } } @@ -4505,7 +4501,7 @@ void DomainMapper_Impl::PopFootOrEndnote() m_bSaxError = true; else { - xEndnotes->getByIndex(m_aEndnoteIds.front()) >>= xNoteFirst; + xNoteFirst = xEndnotes->getFootnoteByIndex(m_aEndnoteIds.front()); m_aEndnoteIds.pop_front(); } } diff --git a/sw/source/writerfilter/dmapper/DomainMapper_Impl.hxx b/sw/source/writerfilter/dmapper/DomainMapper_Impl.hxx index 6c2123b743c7..af3f7bd419a1 100644 --- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.hxx +++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.hxx @@ -956,8 +956,8 @@ public: sal_Int32 GetEndnoteCount() const { return m_nEndnotes; } void IncrementEndnoteCount() { ++m_nEndnotes; } bool CopyTemporaryNotes( - css::uno::Reference< css::text::XFootnote > xNoteSrc, - css::uno::Reference< css::text::XFootnote > xNoteDest ); + rtl::Reference< SwXFootnote > xNoteSrc, + rtl::Reference< SwXFootnote > xNoteDest ); void RemoveTemporaryFootOrEndnotes(); void PushAnnotation(); diff --git a/sw/source/writerfilter/dmapper/PropertyMap.hxx b/sw/source/writerfilter/dmapper/PropertyMap.hxx index 565b42c020e4..e03224125859 100644 --- a/sw/source/writerfilter/dmapper/PropertyMap.hxx +++ b/sw/source/writerfilter/dmapper/PropertyMap.hxx @@ -30,6 +30,7 @@ #include <com/sun/star/uno/Any.h> #include <com/sun/star/drawing/XShape.hpp> #include "PropertyIds.hxx" +#include <unofootnote.hxx> #include <memory> #include <optional> #include <map> @@ -142,7 +143,7 @@ private: // marks context as footnote context - ::text( ) events contain either the footnote character or can be ignored // depending on sprmCSymbol - css::uno::Reference< css::text::XFootnote > m_xFootnote; + rtl::Reference< SwXFootnote > m_xFootnote; OUString m_sFootnoteCharStyleName; std::map< PropertyIds, PropValue > m_vMap; std::vector< RedlineParamsPtr > m_aRedlines; @@ -174,10 +175,10 @@ public: bool isSet( PropertyIds eId ) const; bool isDocDefault( PropertyIds eId ) const; - const css::uno::Reference< css::text::XFootnote >& GetFootnote() const { return m_xFootnote; } + const rtl::Reference< SwXFootnote >& GetFootnote() const { return m_xFootnote; } const OUString& GetFootnoteStyle() const { return m_sFootnoteCharStyleName; } - void SetFootnote(const css::uno::Reference< css::text::XFootnote >& xFootnote, const OUString& sStyleName) + void SetFootnote(const rtl::Reference< SwXFootnote >& xFootnote, const OUString& sStyleName) { m_xFootnote = xFootnote; m_sFootnoteCharStyleName = sStyleName; |