extensions/source/propctrlr/commoncontrol.hxx        |   14 ++++++-------
 extensions/source/propctrlr/formcomponenthandler.cxx |    5 ++--
 extensions/source/propctrlr/standardcontrol.hxx      |   20 +++++++++----------
 extensions/source/propctrlr/usercontrol.cxx          |   12 +++++++++++
 extensions/source/propctrlr/usercontrol.hxx          |   10 ++++++---
 5 files changed, 39 insertions(+), 22 deletions(-)

New commits:
commit 19dfdf86ad1f5b08041d8b7a9f196caf881231ab
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Wed Dec 21 11:07:18 2022 +0100
Commit:     Stephan Bergmann <sberg...@redhat.com>
CommitDate: Wed Dec 21 11:58:06 2022 +0000

    iloplugin:unocast (pcr::OFormattedNumericControl)
    
    (See the upcoming commit introducing that loplugin:unocast on why such
    dynamic_casts from UNO types are dangerous.)
    
    (Making the base class pcr::CommonBehaviourControl TControlInterface 
template
    parameter variadic required swapping it with the other TControlWindow 
template
    parameter.)
    
    Change-Id: Iadc9dc7eb8fbe882b63b5db49d8a39ae5c4c05c4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144653
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>

diff --git a/extensions/source/propctrlr/commoncontrol.hxx 
b/extensions/source/propctrlr/commoncontrol.hxx
index 746f2f56f600..eb92980eaff2 100644
--- a/extensions/source/propctrlr/commoncontrol.hxx
+++ b/extensions/source/propctrlr/commoncontrol.hxx
@@ -107,13 +107,13 @@ namespace pcr
         @param TControlWindow
             a class which is derived from weld::Widget
     */
-    template < class TControlInterface, class TControlWindow >
+    template < class TControlWindow, class... TControlInterface >
     class CommonBehaviourControl    :public ::cppu::BaseMutex
-                                    ,public ::cppu::WeakComponentImplHelper< 
TControlInterface >
+                                    ,public ::cppu::WeakComponentImplHelper< 
TControlInterface... >
                                     ,public CommonBehaviourControlHelper
     {
     protected:
-        typedef ::cppu::WeakComponentImplHelper< TControlInterface >    
ComponentBaseClass;
+        typedef ::cppu::WeakComponentImplHelper< TControlInterface... >    
ComponentBaseClass;
 
         inline CommonBehaviourControl(sal_Int16 nControlType,
                                       std::unique_ptr<weld::Builder> xBuilder,
@@ -179,8 +179,8 @@ namespace pcr
     };
 
     //= CommonBehaviourControl - implementation
-    template< class TControlInterface, class TControlWindow >
-    inline CommonBehaviourControl< TControlInterface, TControlWindow 
>::CommonBehaviourControl(sal_Int16 nControlType,
+    template< class TControlWindow, class... TControlInterface >
+    inline CommonBehaviourControl< TControlWindow, TControlInterface... 
>::CommonBehaviourControl(sal_Int16 nControlType,
                                                                                
                std::unique_ptr<weld::Builder> xBuilder,
                                                                                
                std::unique_ptr<TControlWindow> xWidget,
                                                                                
                bool bReadOnly)
@@ -196,8 +196,8 @@ namespace pcr
         }
     }
 
-    template< class TControlInterface, class TControlWindow >
-    inline void CommonBehaviourControl< TControlInterface, TControlWindow 
>::impl_checkDisposed_throw()
+    template< class TControlWindow, class... TControlInterface >
+    inline void CommonBehaviourControl< TControlWindow, TControlInterface... 
>::impl_checkDisposed_throw()
     {
         if ( ComponentBaseClass::rBHelper.bDisposed )
             throw css::lang::DisposedException( OUString(), *this );
diff --git a/extensions/source/propctrlr/formcomponenthandler.cxx 
b/extensions/source/propctrlr/formcomponenthandler.cxx
index dd4f1302fc31..a4e76388a413 100644
--- a/extensions/source/propctrlr/formcomponenthandler.cxx
+++ b/extensions/source/propctrlr/formcomponenthandler.cxx
@@ -77,6 +77,7 @@
 #include <com/sun/star/text/WritingMode2.hpp>
 
 #include <comphelper/extract.hxx>
+#include <comphelper/servicehelper.hxx>
 #include <comphelper/types.hxx>
 #include <connectivity/dbconversion.hxx>
 #include <connectivity/dbexception.hxx>
@@ -1708,7 +1709,7 @@ namespace pcr
                 catch( const UnknownPropertyException& ) {}
                 if ( xControl.is() )
                 {
-                    OFormattedNumericControl* pControl = dynamic_cast< 
OFormattedNumericControl* >( xControl.get() );
+                    OFormattedNumericControl* pControl = 
comphelper::getFromUnoTunnel< OFormattedNumericControl >( xControl );
                     DBG_ASSERT( pControl, 
"FormComponentPropertyHandler::actuatingPropertyChanged: invalid control!" );
                     if (pControl)
                     {
@@ -1754,7 +1755,7 @@ namespace pcr
                     catch( const UnknownPropertyException& ) {}
                     if ( xControl.is() )
                     {
-                        OFormattedNumericControl* pControl = dynamic_cast< 
OFormattedNumericControl* >( xControl.get() );
+                        OFormattedNumericControl* pControl = 
comphelper::getFromUnoTunnel< OFormattedNumericControl >( xControl );
                         DBG_ASSERT( pControl, 
"FormComponentPropertyHandler::actuatingPropertyChanged: invalid control!" );
                         if ( pControl )
                             pControl->SetFormatDescription( aNewDesc );
diff --git a/extensions/source/propctrlr/standardcontrol.hxx 
b/extensions/source/propctrlr/standardcontrol.hxx
index fcd194886a1a..df8924be806e 100644
--- a/extensions/source/propctrlr/standardcontrol.hxx
+++ b/extensions/source/propctrlr/standardcontrol.hxx
@@ -33,7 +33,7 @@
 namespace pcr
 {
     //= OTimeControl
-    typedef CommonBehaviourControl<css::inspection::XPropertyControl, 
weld::FormattedSpinButton> OTimeControl_Base;
+    typedef CommonBehaviourControl<weld::FormattedSpinButton, 
css::inspection::XPropertyControl> OTimeControl_Base;
     class OTimeControl : public OTimeControl_Base
     {
         std::unique_ptr<weld::TimeFormatter> m_xFormatter;
@@ -61,7 +61,7 @@ namespace pcr
     };
 
     //= ODateControl
-    typedef CommonBehaviourControl<css::inspection::XPropertyControl, 
weld::Container> ODateControl_Base;
+    typedef CommonBehaviourControl<weld::Container, 
css::inspection::XPropertyControl> ODateControl_Base;
     class ODateControl : public ODateControl_Base
     {
         std::unique_ptr<weld::Entry> m_xEntry;
@@ -97,7 +97,7 @@ namespace pcr
     };
 
     //= OEditControl
-    typedef CommonBehaviourControl<css::inspection::XPropertyControl, 
weld::Entry> OEditControl_Base;
+    typedef CommonBehaviourControl<weld::Entry, 
css::inspection::XPropertyControl> OEditControl_Base;
     class OEditControl final : public OEditControl_Base
     {
         bool m_bIsPassword : 1;
@@ -123,7 +123,7 @@ namespace pcr
     };
 
     //= ODateTimeControl
-    typedef CommonBehaviourControl<css::inspection::XPropertyControl, 
weld::Container> ODateTimeControl_Base;
+    typedef CommonBehaviourControl<weld::Container, 
css::inspection::XPropertyControl> ODateTimeControl_Base;
     class ODateTimeControl : public ODateTimeControl_Base
     {
     private:
@@ -162,7 +162,7 @@ namespace pcr
     };
 
     //= OHyperlinkControl
-    typedef CommonBehaviourControl<css::inspection::XHyperlinkControl, 
weld::Container> OHyperlinkControl_Base;
+    typedef CommonBehaviourControl<weld::Container, 
css::inspection::XHyperlinkControl> OHyperlinkControl_Base;
     class OHyperlinkControl final : public OHyperlinkControl_Base
     {
     private:
@@ -203,7 +203,7 @@ namespace pcr
     };
 
     //= ONumericControl
-    typedef CommonBehaviourControl<css::inspection::XNumericControl, 
weld::MetricSpinButton> ONumericControl_Base;
+    typedef CommonBehaviourControl<weld::MetricSpinButton, 
css::inspection::XNumericControl> ONumericControl_Base;
     class ONumericControl : public ONumericControl_Base
     {
     private:
@@ -255,7 +255,7 @@ namespace pcr
     };
 
     //= OColorControl
-    typedef CommonBehaviourControl<css::inspection::XPropertyControl, 
ColorListBox> OColorControl_Base;
+    typedef CommonBehaviourControl<ColorListBox, 
css::inspection::XPropertyControl> OColorControl_Base;
     class OColorControl : public OColorControl_Base
     {
     public:
@@ -281,7 +281,7 @@ namespace pcr
     };
 
     //= OListboxControl
-    typedef CommonBehaviourControl<css::inspection::XStringListControl, 
weld::ComboBox> OListboxControl_Base;
+    typedef CommonBehaviourControl<weld::ComboBox, 
css::inspection::XStringListControl> OListboxControl_Base;
     class OListboxControl : public OListboxControl_Base
     {
     public:
@@ -311,7 +311,7 @@ namespace pcr
     };
 
     //= OComboboxControl
-    typedef CommonBehaviourControl< css::inspection::XStringListControl, 
weld::ComboBox > OComboboxControl_Base;
+    typedef CommonBehaviourControl< weld::ComboBox, 
css::inspection::XStringListControl > OComboboxControl_Base;
     class OComboboxControl final : public OComboboxControl_Base
     {
     public:
@@ -351,7 +351,7 @@ namespace pcr
     };
 
     //= OMultilineEditControl
-    typedef CommonBehaviourControl<css::inspection::XPropertyControl, 
weld::Container> OMultilineEditControl_Base;
+    typedef CommonBehaviourControl<weld::Container, 
css::inspection::XPropertyControl> OMultilineEditControl_Base;
     class OMultilineEditControl : public OMultilineEditControl_Base
     {
     private:
diff --git a/extensions/source/propctrlr/usercontrol.cxx 
b/extensions/source/propctrlr/usercontrol.cxx
index 8cccb48e84b5..854abfa72037 100644
--- a/extensions/source/propctrlr/usercontrol.cxx
+++ b/extensions/source/propctrlr/usercontrol.cxx
@@ -20,6 +20,7 @@
 #include "usercontrol.hxx"
 
 #include <com/sun/star/inspection/PropertyControlType.hpp>
+#include <comphelper/servicehelper.hxx>
 #include <svl/numuno.hxx>
 #include <vcl/GraphicObject.hxx>
 #include <vcl/event.hxx>
@@ -199,6 +200,17 @@ namespace pcr
         return ::cppu::UnoType<double>::get();
     }
 
+    sal_Int64 OFormattedNumericControl::getSomething(
+        css::uno::Sequence<sal_Int8> const & aIdentifier)
+    {
+        return comphelper::getSomethingImpl(aIdentifier, this);
+    }
+
+    css::uno::Sequence<sal_Int8> const & 
OFormattedNumericControl::getUnoTunnelId() {
+        static comphelper::UnoIdInit const id;
+        return id.getSeq();
+    }
+
     void OFormattedNumericControl::SetFormatDescription(const 
FormatDescription& rDesc)
     {
         bool bFallback = true;
diff --git a/extensions/source/propctrlr/usercontrol.hxx 
b/extensions/source/propctrlr/usercontrol.hxx
index 86b53e7f122e..bb7a622d7669 100644
--- a/extensions/source/propctrlr/usercontrol.hxx
+++ b/extensions/source/propctrlr/usercontrol.hxx
@@ -20,6 +20,7 @@
 #pragma once
 
 #include "commoncontrol.hxx"
+#include <com/sun/star/lang/XUnoTunnel.hpp>
 #include <svtools/inettbc.hxx>
 #include <svl/zforlist.hxx>
 
@@ -28,7 +29,7 @@ class SvNumberFormatsSupplierObj;
 namespace pcr
 {
     //= OFormatSampleControl
-    typedef CommonBehaviourControl<css::inspection::XPropertyControl, 
weld::Container> OFormatSampleControl_Base;
+    typedef CommonBehaviourControl<weld::Container, 
css::inspection::XPropertyControl> OFormatSampleControl_Base;
     class OFormatSampleControl : public OFormatSampleControl_Base
     {
     private:
@@ -84,7 +85,7 @@ namespace pcr
     };
 
     //= OFormattedNumericControl
-    typedef CommonBehaviourControl<css::inspection::XPropertyControl, 
weld::FormattedSpinButton> OFormattedNumericControl_Base;
+    typedef CommonBehaviourControl<weld::FormattedSpinButton, 
css::inspection::XPropertyControl, css::lang::XUnoTunnel> 
OFormattedNumericControl_Base;
     class OFormattedNumericControl : public OFormattedNumericControl_Base
     {
     public:
@@ -95,6 +96,9 @@ namespace pcr
         virtual void SAL_CALL setValue( const css::uno::Any& _value ) override;
         virtual css::uno::Type SAL_CALL getValueType() override;
 
+        sal_Int64 SAL_CALL getSomething(css::uno::Sequence<sal_Int8> const & 
aIdentifier) override;
+        static css::uno::Sequence<sal_Int8> const & getUnoTunnelId();
+
         void SetFormatDescription( const FormatDescription& rDesc );
 
         // make some FormattedField methods available
@@ -115,7 +119,7 @@ namespace pcr
     };
 
     //= OFileUrlControl
-    typedef CommonBehaviourControl<css::inspection::XPropertyControl, 
SvtURLBox> OFileUrlControl_Base;
+    typedef CommonBehaviourControl<SvtURLBox, 
css::inspection::XPropertyControl> OFileUrlControl_Base;
     class OFileUrlControl : public OFileUrlControl_Base
     {
     private:

Reply via email to