include/oox/export/drawingml.hxx |    3 +++
 oox/source/export/drawingml.cxx  |   37 +++++++++++++++++--------------------
 oox/source/export/shapes.cxx     |    5 ++---
 3 files changed, 22 insertions(+), 23 deletions(-)

New commits:
commit b903c33ccd429dfbe41de60eceec20c1d99fda48
Author:     Mike Kaganski <[email protected]>
AuthorDate: Thu Oct 9 12:21:41 2025 +0500
Commit:     Thorsten Behrens <[email protected]>
CommitDate: Tue Oct 14 23:46:11 2025 +0200

    Add GetDirectProperty helper method
    
    Allows to simplify most of places where GetPropertyAndState was used.
    
    Change-Id: I7392756d74cb27eb9ccc820b728cbd9901aa5bad
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192110
    Reviewed-by: Mike Kaganski <[email protected]>
    Tested-by: Jenkins
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192177
    Tested-by: allotropia jenkins <[email protected]>
    Reviewed-by: Thorsten Behrens <[email protected]>

diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx
index 864aaebbb61c..4a8a13f133b4 100644
--- a/include/oox/export/drawingml.hxx
+++ b/include/oox/export/drawingml.hxx
@@ -309,6 +309,9 @@ protected:
     bool GetPropertyAndState( const css::uno::Reference< 
css::beans::XPropertySet >& rXPropSet,
                   const css::uno::Reference< css::beans::XPropertyState >& 
rXPropState,
                   const OUString& aName, css::beans::PropertyState& eState );
+    bool GetDirectProperty(const 
css::uno::Reference<css::beans::XPropertySet>& rXPropSet,
+                           const 
css::uno::Reference<css::beans::XPropertyState>& rXPropState,
+                           const OUString& aName);
     OUString GetFieldValue( const css::uno::Reference< css::text::XTextRange 
>& rRun, bool& bIsURLField );
     /** Gets OOXML datetime field type from LO Date format
 
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 42bda5729098..cd90db98f0bd 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -314,6 +314,15 @@ bool DrawingML::GetPropertyAndState( const Reference< 
XPropertySet >& rXProperty
     return false;
 }
 
+bool DrawingML::GetDirectProperty(
+    const css::uno::Reference<css::beans::XPropertySet>& rXPropSet,
+    const css::uno::Reference<css::beans::XPropertyState>& rXPropState, const 
OUString& aName)
+{
+    PropertyState state;
+    return GetPropertyAndState(rXPropSet, rXPropState, aName, state)
+           && state == beans::PropertyState_DIRECT_VALUE;
+}
+
 namespace
 {
 /// Gets hexa value of color on string format.
@@ -2465,7 +2474,6 @@ void DrawingML::WriteRunProperties( const Reference< 
XPropertySet >& rRun, bool
     Reference< XPropertySet > rXPropSet = rRun;
     Reference< XPropertyState > rXPropState( rRun, UNO_QUERY );
     OUString usLanguage;
-    PropertyState eState;
     bool bComplex = ( nScriptType ==  css::i18n::ScriptType::COMPLEX );
     const char* bold = "0";
     const char* italic = nullptr;
@@ -2520,8 +2528,7 @@ void DrawingML::WriteRunProperties( const Reference< 
XPropertySet >& rRun, bool
                 break;
         }
 
-    if ((bCheckDirect && GetPropertyAndState(rXPropSet, rXPropState, 
u"CharUnderline"_ustr, eState)
-         && eState == beans::PropertyState_DIRECT_VALUE)
+    if ((bCheckDirect && GetDirectProperty(rXPropSet, rXPropState, 
u"CharUnderline"_ustr))
         || GetProperty(rXPropSet, u"CharUnderline"_ustr))
     {
         switch ( *o3tl::doAccess<sal_Int16>(mAny) )
@@ -2580,8 +2587,7 @@ void DrawingML::WriteRunProperties( const Reference< 
XPropertySet >& rRun, bool
         }
     }
 
-    if ((bCheckDirect && GetPropertyAndState(rXPropSet, rXPropState, 
u"CharStrikeout"_ustr, eState)
-         && eState == beans::PropertyState_DIRECT_VALUE)
+    if ((bCheckDirect && GetDirectProperty(rXPropSet, rXPropState, 
u"CharStrikeout"_ustr))
         || GetProperty(rXPropSet, u"CharStrikeout"_ustr))
     {
         switch ( *o3tl::doAccess<sal_Int16>(mAny) )
@@ -2628,12 +2634,10 @@ void DrawingML::WriteRunProperties( const Reference< 
XPropertySet >& rRun, bool
             usLanguage = aLanguageTag.getBcp47MS();
     }
 
-    if (GetPropertyAndState(rXPropSet, rXPropState, u"CharEscapement"_ustr, 
eState)
-        && eState == beans::PropertyState_DIRECT_VALUE)
+    if (GetDirectProperty(rXPropSet, rXPropState, u"CharEscapement"_ustr))
         mAny >>= nCharEscapement;
 
-    if (GetPropertyAndState(rXPropSet, rXPropState, 
u"CharEscapementHeight"_ustr, eState)
-        && eState == beans::PropertyState_DIRECT_VALUE)
+    if (GetDirectProperty(rXPropSet, rXPropState, 
u"CharEscapementHeight"_ustr))
         mAny >>= nCharEscapementHeight;
 
     if (DFLT_ESC_AUTO_SUPER == nCharEscapement)
@@ -2694,8 +2698,7 @@ void DrawingML::WriteRunProperties( const Reference< 
XPropertySet >& rRun, bool
     else
     {
         // mso doesn't like text color to be placed after typeface
-        if ((bCheckDirect && GetPropertyAndState(rXPropSet, rXPropState, 
u"CharColor"_ustr, eState)
-            && eState == beans::PropertyState_DIRECT_VALUE)
+        if ((bCheckDirect && GetDirectProperty(rXPropSet, rXPropState, 
u"CharColor"_ustr))
             || GetProperty(rXPropSet, u"CharColor"_ustr))
         {
             ::Color color( ColorTransparency, 
*o3tl::doAccess<sal_uInt32>(mAny) );
@@ -2781,9 +2784,7 @@ void DrawingML::WriteRunProperties( const Reference< 
XPropertySet >& rRun, bool
     }
 
     if (underline
-        && ((bCheckDirect
-             && GetPropertyAndState(rXPropSet, rXPropState, 
u"CharUnderlineColor"_ustr, eState)
-             && eState == beans::PropertyState_DIRECT_VALUE)
+        && ((bCheckDirect && GetDirectProperty(rXPropSet, rXPropState, 
u"CharUnderlineColor"_ustr))
             || GetProperty(rXPropSet, u"CharUnderlineColor"_ustr)))
     {
         ::Color color(ColorTransparency, *o3tl::doAccess<sal_uInt32>(mAny));
@@ -2817,12 +2818,8 @@ void DrawingML::WriteRunProperties( const Reference< 
XPropertySet >& rRun, bool
                                XML_charset, charset );
     }
 
-    if ((bComplex
-         && (GetPropertyAndState(rXPropSet, rXPropState, 
u"CharFontNameComplex"_ustr, eState)
-             && eState == beans::PropertyState_DIRECT_VALUE))
-        || (!bComplex
-            && (GetPropertyAndState(rXPropSet, rXPropState, 
u"CharFontNameAsian"_ustr, eState)
-                && eState == beans::PropertyState_DIRECT_VALUE)))
+    if (GetDirectProperty(rXPropSet, rXPropState,
+                          bComplex ? u"CharFontNameComplex"_ustr : 
u"CharFontNameAsian"_ustr))
     {
         const char* const pitch = nullptr;
         const char* const charset = nullptr;
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index e11010fb03da..9bf514169c0c 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -1779,7 +1779,6 @@ ShapeExport& ShapeExport::WriteConnectorShape( const 
Reference< XShape >& xShape
     awt::Point aStartPoint, aEndPoint;
     Reference< XShape > rXShapeA;
     Reference< XShape > rXShapeB;
-    PropertyState eState;
     ConnectorType eConnectorType = ConnectorType_STANDARD;
     if (GetProperty(rXPropSet, u"EdgeKind"_ustr))
         mAny >>= eConnectorType;
@@ -1798,10 +1797,10 @@ ShapeExport& ShapeExport::WriteConnectorShape( const 
Reference< XShape >& xShape
             break;
     }
 
-    if (GetPropertyAndState( rXPropSet, rXPropState, u"EdgeStartPoint"_ustr, 
eState ) && eState == beans::PropertyState_DIRECT_VALUE )
+    if (GetDirectProperty( rXPropSet, rXPropState, u"EdgeStartPoint"_ustr ))
     {
         mAny >>= aStartPoint;
-        if (GetPropertyAndState( rXPropSet, rXPropState, u"EdgeEndPoint"_ustr, 
eState ) && eState == beans::PropertyState_DIRECT_VALUE )
+        if (GetDirectProperty( rXPropSet, rXPropState, u"EdgeEndPoint"_ustr ))
             mAny >>= aEndPoint;
     }
     if (GetProperty(rXPropSet, u"EdgeStartConnection"_ustr))

Reply via email to