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

New commits:
commit 88ce0e8cd145d51d6db3bab15cabc951caa2c6a0
Author:     Mike Kaganski <[email protected]>
AuthorDate: Thu Oct 9 12:21:41 2025 +0500
Commit:     Mike Kaganski <[email protected]>
CommitDate: Fri Oct 10 06:28:57 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

diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx
index d68e0e804fbe..aabc8c1b5b23 100644
--- a/include/oox/export/drawingml.hxx
+++ b/include/oox/export/drawingml.hxx
@@ -313,6 +313,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 61fd5caf3ebe..45e237a2df68 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -338,6 +338,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.
@@ -2489,7 +2498,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;
@@ -2544,8 +2552,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) )
@@ -2604,8 +2611,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) )
@@ -2652,12 +2658,10 @@ void DrawingML::WriteRunProperties( const Reference< 
XPropertySet >& rRun, bool
             usLanguage = aLanguageTag.getBcp47MS();
     }
 
-    if (bCheckDirect && GetPropertyAndState(rXPropSet, rXPropState, 
u"CharEscapement"_ustr, eState)
-        && eState == beans::PropertyState_DIRECT_VALUE)
+    if (bCheckDirect && GetDirectProperty(rXPropSet, rXPropState, 
u"CharEscapement"_ustr))
         mAny >>= nCharEscapement;
 
-    if (bCheckDirect && GetPropertyAndState(rXPropSet, rXPropState, 
u"CharEscapementHeight"_ustr, eState)
-        && eState == beans::PropertyState_DIRECT_VALUE)
+    if (bCheckDirect && GetDirectProperty(rXPropSet, rXPropState, 
u"CharEscapementHeight"_ustr))
         mAny >>= nCharEscapementHeight;
 
     if (DFLT_ESC_AUTO_SUPER == nCharEscapement)
@@ -2718,8 +2722,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) );
@@ -2812,9 +2815,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));
@@ -2852,12 +2853,9 @@ void DrawingML::WriteRunProperties( const Reference< 
XPropertySet >& rRun, bool
                                XML_charset, charset );
     }
 
-    if (bCheckDirect && ((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 (bCheckDirect
+        && 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 c150641a2fe5..4251c69a0f4e 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -1859,7 +1859,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;
@@ -1878,10 +1877,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