oox/source/shape/WpsContext.cxx |   95 ++++++++++++++++++++--------------------
 1 file changed, 49 insertions(+), 46 deletions(-)

New commits:
commit 6091e6b0ed363b7e65569830ac76cdcb7ba99b24
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Mon Dec 2 11:03:47 2024 +0000
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Mon Dec 2 17:58:07 2024 +0100

    crashtesting: further failure to reload forum-de3-6592.docx
    
    git show -w
    
    Change-Id: I2963833726779d784bcdfa772e152e65dfde3af5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177674
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/oox/source/shape/WpsContext.cxx b/oox/source/shape/WpsContext.cxx
index 78cef2a0d45c..56abef55fcc1 100644
--- a/oox/source/shape/WpsContext.cxx
+++ b/oox/source/shape/WpsContext.cxx
@@ -730,60 +730,63 @@ oox::core::ContextHandlerRef 
WpsContext::onCreateContext(sal_Int32 nElementToken
 
                 // Apply character color of the shape to the shape's textbox.
                 uno::Reference<text::XText> xText(mxShape, uno::UNO_QUERY);
-                uno::Any xCharColor = 
xPropertySet->getPropertyValue(u"CharColor"_ustr);
-                Color aColor = COL_AUTO;
-                if ((xCharColor >>= aColor) && aColor != COL_AUTO)
+                if (xText)
                 {
-                    // tdf#135923 Apply character color of the shape to the 
textrun
-                    //            when the character color of the textrun is 
default.
-                    // tdf#153791 But only if the run has no background color 
(shd element in OOXML)
-                    if (uno::Reference<container::XEnumerationAccess> 
paraEnumAccess{
-                            xText, uno::UNO_QUERY })
+                    uno::Any xCharColor = 
xPropertySet->getPropertyValue(u"CharColor"_ustr);
+                    Color aColor = COL_AUTO;
+                    if ((xCharColor >>= aColor) && aColor != COL_AUTO)
                     {
-                        uno::Reference<container::XEnumeration> paraEnum(
-                            paraEnumAccess->createEnumeration());
-
-                        while (paraEnum->hasMoreElements())
+                        // tdf#135923 Apply character color of the shape to 
the textrun
+                        //            when the character color of the textrun 
is default.
+                        // tdf#153791 But only if the run has no background 
color (shd element in OOXML)
+                        if (uno::Reference<container::XEnumerationAccess> 
paraEnumAccess{
+                                xText, uno::UNO_QUERY })
                         {
-                            uno::Reference<text::XTextRange> 
xParagraph(paraEnum->nextElement(),
-                                                                        
uno::UNO_QUERY);
-                            uno::Reference<container::XEnumerationAccess> 
runEnumAccess(
-                                xParagraph, uno::UNO_QUERY);
-                            if (!runEnumAccess.is())
-                                continue;
-                            if (uno::Reference<beans::XPropertySet> 
xParaPropSet{ xParagraph,
-                                                                               
   uno::UNO_QUERY })
-                                if 
((xParaPropSet->getPropertyValue(u"ParaBackColor"_ustr)
-                                     >>= aColor)
-                                    && aColor != COL_AUTO)
-                                    continue;
-
-                            uno::Reference<container::XEnumeration> runEnum
-                                = runEnumAccess->createEnumeration();
+                            uno::Reference<container::XEnumeration> paraEnum(
+                                paraEnumAccess->createEnumeration());
 
-                            while (runEnum->hasMoreElements())
+                            while (paraEnum->hasMoreElements())
                             {
-                                uno::Reference<text::XTextRange> 
xRun(runEnum->nextElement(),
-                                                                      
uno::UNO_QUERY);
-                                const uno::Reference<beans::XPropertyState> 
xRunState(
-                                    xRun, uno::UNO_QUERY);
-                                if (!xRunState
-                                    || 
xRunState->getPropertyState(u"CharColor"_ustr)
-                                           == 
beans::PropertyState_DEFAULT_VALUE)
-                                {
-                                    uno::Reference<beans::XPropertySet> 
xRunPropSet(xRun,
-                                                                               
     uno::UNO_QUERY);
-                                    if (!xRunPropSet)
-                                        continue;
-                                    if 
((xRunPropSet->getPropertyValue(u"CharBackColor"_ustr)
+                                uno::Reference<text::XTextRange> 
xParagraph(paraEnum->nextElement(),
+                                                                            
uno::UNO_QUERY);
+                                uno::Reference<container::XEnumerationAccess> 
runEnumAccess(
+                                    xParagraph, uno::UNO_QUERY);
+                                if (!runEnumAccess.is())
+                                    continue;
+                                if (uno::Reference<beans::XPropertySet> 
xParaPropSet{
+                                        xParagraph, uno::UNO_QUERY })
+                                    if 
((xParaPropSet->getPropertyValue(u"ParaBackColor"_ustr)
                                          >>= aColor)
                                         && aColor != COL_AUTO)
                                         continue;
-                                    if 
(!(xRunPropSet->getPropertyValue(u"CharColor"_ustr)
-                                          >>= aColor)
-                                        || aColor == COL_AUTO)
-                                        
xRunPropSet->setPropertyValue(u"CharColor"_ustr,
-                                                                      
xCharColor);
+
+                                uno::Reference<container::XEnumeration> runEnum
+                                    = runEnumAccess->createEnumeration();
+
+                                while (runEnum->hasMoreElements())
+                                {
+                                    uno::Reference<text::XTextRange> 
xRun(runEnum->nextElement(),
+                                                                          
uno::UNO_QUERY);
+                                    const 
uno::Reference<beans::XPropertyState> xRunState(
+                                        xRun, uno::UNO_QUERY);
+                                    if (!xRunState
+                                        || 
xRunState->getPropertyState(u"CharColor"_ustr)
+                                               == 
beans::PropertyState_DEFAULT_VALUE)
+                                    {
+                                        uno::Reference<beans::XPropertySet> 
xRunPropSet(
+                                            xRun, uno::UNO_QUERY);
+                                        if (!xRunPropSet)
+                                            continue;
+                                        if 
((xRunPropSet->getPropertyValue(u"CharBackColor"_ustr)
+                                             >>= aColor)
+                                            && aColor != COL_AUTO)
+                                            continue;
+                                        if 
(!(xRunPropSet->getPropertyValue(u"CharColor"_ustr)
+                                              >>= aColor)
+                                            || aColor == COL_AUTO)
+                                            
xRunPropSet->setPropertyValue(u"CharColor"_ustr,
+                                                                          
xCharColor);
+                                    }
                                 }
                             }
                         }

Reply via email to