From 6091e6b0ed363b7e65569830ac76cdcb7ba99b24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Mon, 2 Dec 2024 11:03:47 +0000 Subject: [PATCH] crashtesting: further failure to reload forum-de3-6592.docx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git show -w Change-Id: I2963833726779d784bcdfa772e152e65dfde3af5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177674 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- oox/source/shape/WpsContext.cxx | 95 +++++++++++++++++---------------- 1 file changed, 49 insertions(+), 46 deletions(-) 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 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 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 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 paraEnumAccess{ + xText, uno::UNO_QUERY }) { - uno::Reference xParagraph(paraEnum->nextElement(), - uno::UNO_QUERY); - uno::Reference runEnumAccess( - xParagraph, uno::UNO_QUERY); - if (!runEnumAccess.is()) - continue; - if (uno::Reference xParaPropSet{ xParagraph, - uno::UNO_QUERY }) - if ((xParaPropSet->getPropertyValue(u"ParaBackColor"_ustr) - >>= aColor) - && aColor != COL_AUTO) - continue; + uno::Reference paraEnum( + paraEnumAccess->createEnumeration()); - uno::Reference runEnum - = runEnumAccess->createEnumeration(); - - while (runEnum->hasMoreElements()) + while (paraEnum->hasMoreElements()) { - uno::Reference xRun(runEnum->nextElement(), - uno::UNO_QUERY); - const uno::Reference xRunState( - xRun, uno::UNO_QUERY); - if (!xRunState - || xRunState->getPropertyState(u"CharColor"_ustr) - == beans::PropertyState_DEFAULT_VALUE) - { - uno::Reference xRunPropSet(xRun, - uno::UNO_QUERY); - if (!xRunPropSet) - continue; - if ((xRunPropSet->getPropertyValue(u"CharBackColor"_ustr) + uno::Reference xParagraph(paraEnum->nextElement(), + uno::UNO_QUERY); + uno::Reference runEnumAccess( + xParagraph, uno::UNO_QUERY); + if (!runEnumAccess.is()) + continue; + if (uno::Reference 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 runEnum + = runEnumAccess->createEnumeration(); + + while (runEnum->hasMoreElements()) + { + uno::Reference xRun(runEnum->nextElement(), + uno::UNO_QUERY); + const uno::Reference xRunState( + xRun, uno::UNO_QUERY); + if (!xRunState + || xRunState->getPropertyState(u"CharColor"_ustr) + == beans::PropertyState_DEFAULT_VALUE) + { + uno::Reference 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); + } } } }