starmath/inc/unomodel.hxx    |    6 +++++-
 starmath/source/unomodel.cxx |   20 +++++++++++---------
 2 files changed, 16 insertions(+), 10 deletions(-)

New commits:
commit 107b35bd425fb79a9ff2e47b9e2054289cf0213e
Author:     Mike Kaganski <[email protected]>
AuthorDate: Fri Dec 15 16:07:29 2023 +0300
Commit:     Mike Kaganski <[email protected]>
CommitDate: Fri Dec 15 17:40:28 2023 +0100

    Put some static_casts into a dedicated function
    
    And make it explicit that SmModel ctor takes a SmDocShell*.
    
    Change-Id: Ic16b2bce8e0a57b9f00382fa03041867f5e3a4ba
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160828
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <[email protected]>

diff --git a/starmath/inc/unomodel.hxx b/starmath/inc/unomodel.hxx
index b16d69ee6640..cdb916bccffc 100644
--- a/starmath/inc/unomodel.hxx
+++ b/starmath/inc/unomodel.hxx
@@ -41,6 +41,7 @@ public:
     SmPrintUIOptions();
 };
 
+class SmDocShell;
 
 class SmModel final : public SfxBaseModel,
                 public comphelper::PropertySetHelper,
@@ -55,7 +56,7 @@ class SmModel final : public SfxBaseModel,
     virtual void _setPropertyValues( const comphelper::PropertyMapEntry** 
ppEntries, const css::uno::Any* pValues ) override;
     virtual void _getPropertyValues( const comphelper::PropertyMapEntry** 
ppEntries, css::uno::Any* pValue ) override;
 public:
-    explicit SmModel( SfxObjectShell *pObjSh );
+    explicit SmModel(SmDocShell* pObjSh);
     virtual ~SmModel() noexcept override;
 
     //XInterface
@@ -90,6 +91,9 @@ public:
     virtual void writeFormulaRtf(OStringBuffer& rBuffer, rtl_TextEncoding 
nEncoding) override;
     virtual void readFormulaOoxml( oox::formulaimport::XmlStream& stream ) 
override;
     virtual Size getFormulaSize() const override;
+
+private:
+    SmDocShell* GetSmDocShell() const;
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/source/unomodel.cxx b/starmath/source/unomodel.cxx
index ea12928d3dbc..695c48f1bab1 100644
--- a/starmath/source/unomodel.cxx
+++ b/starmath/source/unomodel.cxx
@@ -315,7 +315,7 @@ static const rtl::Reference<PropertySetInfo> & 
lcl_createModelPropertyInfo ()
     return PROPS_INFO;
 }
 
-SmModel::SmModel( SfxObjectShell *pObjSh )
+SmModel::SmModel(SmDocShell* pObjSh)
 : SfxBaseModel(pObjSh)
 , PropertySetHelper ( lcl_createModelPropertyInfo () )
 {
@@ -325,6 +325,8 @@ SmModel::~SmModel() noexcept
 {
 }
 
+SmDocShell* SmModel::GetSmDocShell() const { return 
static_cast<SmDocShell*>(GetObjectShell()); }
+
 uno::Any SAL_CALL SmModel::queryInterface( const uno::Type& rType )
 {
     uno::Any aRet =  ::cppu::queryInterface ( rType,
@@ -402,7 +404,7 @@ void SmModel::_setPropertyValues(const PropertyMapEntry** 
ppEntries, const Any*
 {
     SolarMutexGuard aGuard;
 
-    SmDocShell *pDocSh = static_cast < SmDocShell * > (GetObjectShell());
+    SmDocShell* pDocSh = GetSmDocShell();
 
     if ( nullptr == pDocSh )
         throw UnknownPropertyException();
@@ -716,7 +718,7 @@ void SmModel::_setPropertyValues(const PropertyMapEntry** 
ppEntries, const Any*
 
 void SmModel::_getPropertyValues( const PropertyMapEntry **ppEntries, Any 
*pValue )
 {
-    SmDocShell *pDocSh = static_cast < SmDocShell * > (GetObjectShell());
+    SmDocShell* pDocSh = GetSmDocShell();
 
     if ( nullptr == pDocSh )
         throw UnknownPropertyException();
@@ -953,7 +955,7 @@ uno::Sequence< beans::PropertyValue > SAL_CALL 
SmModel::getRenderer(
     if (0 != nRenderer)
         throw IllegalArgumentException();
 
-    SmDocShell *pDocSh = static_cast < SmDocShell * >( GetObjectShell() );
+    SmDocShell* pDocSh = GetSmDocShell();
     if (!pDocSh)
         throw RuntimeException();
 
@@ -994,7 +996,7 @@ void SAL_CALL SmModel::render(
     if (0 != nRenderer)
         throw IllegalArgumentException();
 
-    SmDocShell *pDocSh = static_cast < SmDocShell * >( GetObjectShell() );
+    SmDocShell* pDocSh = GetSmDocShell();
     if (!pDocSh)
         throw RuntimeException();
 
@@ -1088,22 +1090,22 @@ void SmModel::writeFormulaOoxml(
         oox::core::OoxmlVersion const version,
         oox::drawingml::DocumentType const documentType, sal_Int8 nAlign)
 {
-    static_cast<SmDocShell*>(GetObjectShell())->writeFormulaOoxml(pSerializer, 
version, documentType, nAlign);
+    GetSmDocShell()->writeFormulaOoxml(pSerializer, version, documentType, 
nAlign);
 }
 
 void SmModel::writeFormulaRtf(OStringBuffer& rBuffer, rtl_TextEncoding 
nEncoding)
 {
-    static_cast<SmDocShell*>(GetObjectShell())->writeFormulaRtf(rBuffer, 
nEncoding);
+    GetSmDocShell()->writeFormulaRtf(rBuffer, nEncoding);
 }
 
 void SmModel::readFormulaOoxml( oox::formulaimport::XmlStream& stream )
 {
-    static_cast< SmDocShell* >( GetObjectShell())->readFormulaOoxml( stream );
+    GetSmDocShell()->readFormulaOoxml(stream);
 }
 
 Size SmModel::getFormulaSize() const
 {
-    return o3tl::convert(static_cast< SmDocShell* >( 
GetObjectShell())->GetSize(), SmO3tlLengthUnit(), o3tl::Length::mm100);
+    return o3tl::convert(GetSmDocShell()->GetSize(), SmO3tlLengthUnit(), 
o3tl::Length::mm100);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to