summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2022-12-21 16:48:44 +0100
committerStephan Bergmann <sbergman@redhat.com>2022-12-22 06:57:11 +0000
commit0c7585c5fa78887e5459885ed744e8044fd76137 (patch)
tree2a9b92cbf305227765c2b20081a039e85ba52a17
parent24e14afd1bfcaed6c200ab081973fba7e47267ca (diff)
loplugin:unocast (sd::TextApiObject)
(See the upcoming commit introducing that loplugin:unocast on why such dynamic_casts from UNO types are dangerous.) The odd implementation of TextApiObject::getImplementation had been effectively like that ever since the code's introduction in 5d431414afa79d392fe6a885940c559236c25aa2 "CWS-TOOLING: integrate CWS impressnotes01", for no obvious reason. And as it can be reduced to a single comphelper::getFromUnoTunnel call, drop the function and directly call that at the (single) call site. Change-Id: If50a81cf8bee0dddbdfb5e6b5516c24a03e858e9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144699 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
-rw-r--r--sd/inc/textapi.hxx3
-rw-r--r--sd/source/core/text/textapi.cxx15
-rw-r--r--sd/source/ui/annotations/annotationwindow.cxx3
3 files changed, 12 insertions, 9 deletions
diff --git a/sd/inc/textapi.hxx b/sd/inc/textapi.hxx
index 70110349053a..be7396358468 100644
--- a/sd/inc/textapi.hxx
+++ b/sd/inc/textapi.hxx
@@ -43,7 +43,8 @@ public:
void SetText( OutlinerParaObject const & rText );
OUString GetText() const;
- static TextApiObject* getImplementation( const css::uno::Reference< css::text::XText >& );
+ sal_Int64 SAL_CALL getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) override;
+ static css::uno::Sequence<sal_Int8> const & getUnoTunnelId();
private:
std::unique_ptr<TextAPIEditSource> mpSource;
diff --git a/sd/source/core/text/textapi.cxx b/sd/source/core/text/textapi.cxx
index 8c342f1fda63..d855b3cb3ebe 100644
--- a/sd/source/core/text/textapi.cxx
+++ b/sd/source/core/text/textapi.cxx
@@ -23,6 +23,7 @@
#include <textapi.hxx>
#include <drawdoc.hxx>
+#include <comphelper/servicehelper.hxx>
#include <editeng/eeitem.hxx>
#include <editeng/editeng.hxx>
#include <editeng/outlobj.hxx>
@@ -179,14 +180,14 @@ OUString TextApiObject::GetText() const
return mpSource->GetText();
}
-TextApiObject* TextApiObject::getImplementation( const css::uno::Reference< css::text::XText >& xText )
-{
- TextApiObject* pImpl = dynamic_cast< TextApiObject* >( xText.get() );
-
- if( !pImpl )
- pImpl = dynamic_cast< TextApiObject* >( comphelper::getFromUnoTunnel<SvxUnoTextBase>( xText ) );
+sal_Int64 TextApiObject::getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) {
+ return comphelper::getSomethingImpl(
+ aIdentifier, this, comphelper::FallbackToGetSomethingOf<SvxUnoText>{});
+}
- return pImpl;
+css::uno::Sequence<sal_Int8> const & TextApiObject::getUnoTunnelId() {
+ static comphelper::UnoIdInit const id;
+ return id.getSeq();
}
TextAPIEditSource::TextAPIEditSource(const TextAPIEditSource& rSource)
diff --git a/sd/source/ui/annotations/annotationwindow.cxx b/sd/source/ui/annotations/annotationwindow.cxx
index 6c1210575915..cc392994cb56 100644
--- a/sd/source/ui/annotations/annotationwindow.cxx
+++ b/sd/source/ui/annotations/annotationwindow.cxx
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <comphelper/servicehelper.hxx>
#include <editeng/eeitem.hxx>
#include <editeng/udlnitem.hxx>
#include <editeng/langitem.hxx>
@@ -487,7 +488,7 @@ TextApiObject* getTextApiObject( const Reference< XAnnotation >& xAnnotation )
if( xAnnotation.is() )
{
Reference< XText > xText( xAnnotation->getTextRange() );
- return TextApiObject::getImplementation( xText );
+ return comphelper::getFromUnoTunnel<TextApiObject>( xText );
}
return nullptr;
}