sc/source/ui/dbgui/csvgrid.cxx | 1 svgio/source/svgreader/svgcharacternode.cxx | 477 ++++++++++++++-------------- sw/source/uibase/utlui/content.cxx | 3 3 files changed, 244 insertions(+), 237 deletions(-)
New commits: commit 172dab3ee4b816f7f74eadb5e979f0aeda134d50 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Sat Aug 23 10:08:14 2025 +0100 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Sat Aug 23 14:36:13 2025 +0200 cid#1665121 silence bogus Improper use of negative value Change-Id: If6455f30d9634eaa427cb7221b904ac6c3fe1a9c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190088 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index 2b2ce94ab195..432a48bce845 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -1891,7 +1891,10 @@ IMPL_LINK(SwContentTree, CommandHdl, const CommandEvent&, rCEvt, bool) default: break; } if (!aIdent.isEmpty()) + { + assert(nContentType != ContentTypeId::UNKNOWN && "aIdent is empty if UNKNOWN type"); xPop->set_active(aIdent, mTrackContentType[nContentType]); + } // Edit only if the shown content is coming from the current view. if (State::HIDDEN != m_eState && commit d54453ef49037971bd62df15a0d73587283bca3d Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Thu Aug 21 19:55:54 2025 +0100 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Sat Aug 23 14:36:06 2025 +0200 cid#1660072 Overflowed return value Change-Id: I71d6ac5321d500c1cef16c118be758edca01a26f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190087 Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> Tested-by: Jenkins diff --git a/sc/source/ui/dbgui/csvgrid.cxx b/sc/source/ui/dbgui/csvgrid.cxx index fe29e4464975..1f25c6f20a10 100644 --- a/sc/source/ui/dbgui/csvgrid.cxx +++ b/sc/source/ui/dbgui/csvgrid.cxx @@ -492,6 +492,7 @@ sal_uInt32 ScCsvGrid::GetColumnFromPos( sal_Int32 nPos ) const sal_Int32 ScCsvGrid::GetColumnWidth( sal_uInt32 nColIndex ) const { + // coverity[ tainted_data_return : SUPPRESS ] 2024.6.1 return IsValidColumn( nColIndex ) ? (GetColumnPos( nColIndex + 1 ) - GetColumnPos( nColIndex )) : 0; } commit f71d0ce6d9a1f5dae6917a696c915ba2a749bb70 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Thu Aug 21 20:12:22 2025 +0100 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Sat Aug 23 14:35:59 2025 +0200 cid#1660550 silence Division or modulo by float zero Change-Id: Ib6c176b3c6429294ef582d9dc392f1a355c4e8a3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190086 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/svgio/source/svgreader/svgcharacternode.cxx b/svgio/source/svgreader/svgcharacternode.cxx index ca1f91ebb99a..72a867280ef5 100644 --- a/svgio/source/svgreader/svgcharacternode.cxx +++ b/svgio/source/svgreader/svgcharacternode.cxx @@ -137,309 +137,312 @@ namespace svgio::svgreader const SvgStyleAttributes& rSvgStyleAttributes) const { // prepare retval, index and length - rtl::Reference<BasePrimitive2D> pRetval; const sal_uInt32 nLength(getText().getLength()); + if (!nLength) + return nullptr; - if(nLength) - { - const sal_uInt32 nIndex(0); - - // prepare FontAttribute - const drawinglayer::attribute::FontAttribute aFontAttribute(getFontAttribute(rSvgStyleAttributes)); - - // prepare FontSizeNumber - double fFontWidth(rSvgStyleAttributes.getFontSizeNumber().solve(*this)); - double fFontHeight(fFontWidth); + const sal_uInt32 nIndex(0); - // prepare locale - css::lang::Locale aLocale; + // prepare FontAttribute + const drawinglayer::attribute::FontAttribute aFontAttribute(getFontAttribute(rSvgStyleAttributes)); - // prepare TextLayouterDevice; use a larger font size for more linear size - // calculations. Similar to nTextSizeFactor in sd/source/ui/view/sdview.cxx - // (ViewRedirector::createRedirectedPrimitive2DSequence). - const double sizeFactor = fFontHeight < 50000 ? 50000 / fFontHeight : 1.0; - TextLayouterDevice aTextLayouterDevice; - aTextLayouterDevice.setFontAttribute(aFontAttribute, fFontWidth * sizeFactor, fFontHeight * sizeFactor, aLocale); + // prepare FontSizeNumber + double fFontWidth(rSvgStyleAttributes.getFontSizeNumber().solve(*this)); - // prepare TextArray - ::std::vector< double > aTextArray(rSvgTextPosition.getX()); - ::std::vector< double > aDxArray(rSvgTextPosition.getDx()); + if (fFontWidth == 0) + return nullptr; - // Do nothing when X and Dx arrays are empty - if((!aTextArray.empty() || !aDxArray.empty()) && aTextArray.size() < nLength) - { - const sal_uInt32 nArray(aTextArray.size()); + rtl::Reference<BasePrimitive2D> pRetval; + double fFontHeight(fFontWidth); - double fStartX(0.0); - if (!aTextArray.empty()) - { - if(rSvgTextPosition.getParent() && rSvgTextPosition.getParent()->getAbsoluteX()) - { - fStartX = rSvgTextPosition.getParent()->getPosition().getX(); - } - else - { - fStartX = aTextArray[nArray - 1]; - } - } + // prepare locale + css::lang::Locale aLocale; - ::std::vector< double > aExtendArray(aTextLayouterDevice.getTextArray(getText(), nArray, nLength - nArray)); - double fComulativeDx(0.0); + // prepare TextLayouterDevice; use a larger font size for more linear size + // calculations. Similar to nTextSizeFactor in sd/source/ui/view/sdview.cxx + // (ViewRedirector::createRedirectedPrimitive2DSequence). + const double sizeFactor = fFontHeight < 50000 ? 50000 / fFontHeight : 1.0; + TextLayouterDevice aTextLayouterDevice; + aTextLayouterDevice.setFontAttribute(aFontAttribute, fFontWidth * sizeFactor, fFontHeight * sizeFactor, aLocale); - aTextArray.reserve(nLength); - for(size_t a = 0; a < aExtendArray.size(); ++a) - { - if (a < aDxArray.size()) - { - fComulativeDx += aDxArray[a]; - } - aTextArray.push_back(aExtendArray[a] / sizeFactor + fStartX + fComulativeDx); - } - } + // prepare TextArray + ::std::vector< double > aTextArray(rSvgTextPosition.getX()); + ::std::vector< double > aDxArray(rSvgTextPosition.getDx()); - // get current TextPosition and TextWidth in units - basegfx::B2DPoint aPosition(rSvgTextPosition.getPosition()); - double fTextWidth(aTextLayouterDevice.getTextWidth(getText(), nIndex, nLength) / sizeFactor); + // Do nothing when X and Dx arrays are empty + if((!aTextArray.empty() || !aDxArray.empty()) && aTextArray.size() < nLength) + { + const sal_uInt32 nArray(aTextArray.size()); - // check for user-given TextLength - if(0.0 != rSvgTextPosition.getTextLength() - && !basegfx::fTools::equal(fTextWidth, rSvgTextPosition.getTextLength())) + double fStartX(0.0); + if (!aTextArray.empty()) { - const double fFactor(rSvgTextPosition.getTextLength() / fTextWidth); - - if(rSvgTextPosition.getLengthAdjust()) + if(rSvgTextPosition.getParent() && rSvgTextPosition.getParent()->getAbsoluteX()) { - // spacing, need to create and expand TextArray - if(aTextArray.empty()) - { - auto aExtendArray(aTextLayouterDevice.getTextArray(getText(), nIndex, nLength)); - aTextArray.reserve(aExtendArray.size()); - for (auto n : aExtendArray) - aTextArray.push_back(n / sizeFactor); - } - - for(auto &a : aTextArray) - { - a *= fFactor; - } + fStartX = rSvgTextPosition.getParent()->getPosition().getX(); } else { - // spacing and glyphs, just apply to FontWidth - fFontWidth *= fFactor; + fStartX = aTextArray[nArray - 1]; } - - fTextWidth = rSvgTextPosition.getTextLength(); } - // get TextAlign - TextAlign aTextAlign(rSvgStyleAttributes.getTextAlign()); + ::std::vector< double > aExtendArray(aTextLayouterDevice.getTextArray(getText(), nArray, nLength - nArray)); + double fComulativeDx(0.0); - // map TextAnchor to TextAlign, there seems not to be a difference - if(TextAnchor::notset != rSvgStyleAttributes.getTextAnchor()) + aTextArray.reserve(nLength); + for(size_t a = 0; a < aExtendArray.size(); ++a) { - switch(rSvgStyleAttributes.getTextAnchor()) + if (a < aDxArray.size()) { - case TextAnchor::start: - { - aTextAlign = TextAlign::left; - break; - } - case TextAnchor::middle: - { - aTextAlign = TextAlign::center; - break; - } - case TextAnchor::end: - { - aTextAlign = TextAlign::right; - break; - } - default: - { - break; - } + fComulativeDx += aDxArray[a]; } + aTextArray.push_back(aExtendArray[a] / sizeFactor + fStartX + fComulativeDx); } + } - // apply TextAlign - switch(aTextAlign) - { - case TextAlign::right: - { - aPosition.setX(aPosition.getX() - mpParentLine->getTextLineWidth()); - break; - } - case TextAlign::center: - { - aPosition.setX(aPosition.getX() - (mpParentLine->getTextLineWidth() * 0.5)); - break; - } - case TextAlign::notset: - case TextAlign::left: - case TextAlign::justify: - { - // TextAlign::notset, TextAlign::left: nothing to do - // TextAlign::justify is not clear currently; handle as TextAlign::left - break; - } - } + // get current TextPosition and TextWidth in units + basegfx::B2DPoint aPosition(rSvgTextPosition.getPosition()); + double fTextWidth(aTextLayouterDevice.getTextWidth(getText(), nIndex, nLength) / sizeFactor); - // get DominantBaseline - const DominantBaseline aDominantBaseline(rSvgStyleAttributes.getDominantBaseline()); + // check for user-given TextLength + if(0.0 != rSvgTextPosition.getTextLength() + && !basegfx::fTools::equal(fTextWidth, rSvgTextPosition.getTextLength())) + { + const double fFactor(rSvgTextPosition.getTextLength() / fTextWidth); - basegfx::B2DRange aRange(aTextLayouterDevice.getTextBoundRect(getText(), nIndex, nLength)); - // apply DominantBaseline - switch(aDominantBaseline) + if(rSvgTextPosition.getLengthAdjust()) { - case DominantBaseline::Middle: - case DominantBaseline::Central: + // spacing, need to create and expand TextArray + if(aTextArray.empty()) { - aPosition.setY(aPosition.getY() - aRange.getCenterY() / sizeFactor); - break; + auto aExtendArray(aTextLayouterDevice.getTextArray(getText(), nIndex, nLength)); + aTextArray.reserve(aExtendArray.size()); + for (auto n : aExtendArray) + aTextArray.push_back(n / sizeFactor); } - case DominantBaseline::Hanging: - { - aPosition.setY(aPosition.getY() - aRange.getMinY() / sizeFactor); - break; - } - default: // DominantBaseline::Auto + + for(auto &a : aTextArray) { - // nothing to do - break; + a *= fFactor; } } + else + { + // spacing and glyphs, just apply to FontWidth + fFontWidth *= fFactor; + } + + fTextWidth = rSvgTextPosition.getTextLength(); + } - // get BaselineShift - const BaselineShift aBaselineShift(rSvgStyleAttributes.getBaselineShift()); + // get TextAlign + TextAlign aTextAlign(rSvgStyleAttributes.getTextAlign()); - // apply BaselineShift - switch(aBaselineShift) + // map TextAnchor to TextAlign, there seems not to be a difference + if(TextAnchor::notset != rSvgStyleAttributes.getTextAnchor()) + { + switch(rSvgStyleAttributes.getTextAnchor()) { - case BaselineShift::Sub: + case TextAnchor::start: { - aPosition.setY(aPosition.getY() + aTextLayouterDevice.getUnderlineOffset() / sizeFactor); + aTextAlign = TextAlign::left; break; } - case BaselineShift::Super: + case TextAnchor::middle: { - aPosition.setY(aPosition.getY() + aTextLayouterDevice.getOverlineOffset() / sizeFactor); + aTextAlign = TextAlign::center; break; } - case BaselineShift::Percentage: - case BaselineShift::Length: + case TextAnchor::end: { - const SvgNumber aNumber(rSvgStyleAttributes.getBaselineShiftNumber()); - const double mfBaselineShift(aNumber.solve(*this)); - - aPosition.setY(aPosition.getY() - mfBaselineShift); + aTextAlign = TextAlign::right; break; } - default: // BaselineShift::Baseline + default: { - // nothing to do break; } } + } - // get fill color - basegfx::BColor aFill(0, 0, 0); - if(rSvgStyleAttributes.getFill()) - aFill = *rSvgStyleAttributes.getFill(); - - // get fill opacity - double fFillOpacity = 1.0; - if (rSvgStyleAttributes.getFillOpacity().isSet()) + // apply TextAlign + switch(aTextAlign) + { + case TextAlign::right: + { + aPosition.setX(aPosition.getX() - mpParentLine->getTextLineWidth()); + break; + } + case TextAlign::center: + { + aPosition.setX(aPosition.getX() - (mpParentLine->getTextLineWidth() * 0.5)); + break; + } + case TextAlign::notset: + case TextAlign::left: + case TextAlign::justify: { - fFillOpacity = rSvgStyleAttributes.getFillOpacity().getNumber(); + // TextAlign::notset, TextAlign::left: nothing to do + // TextAlign::justify is not clear currently; handle as TextAlign::left + break; } + } - // prepare TextTransformation - basegfx::B2DHomMatrix aTextTransform; + // get DominantBaseline + const DominantBaseline aDominantBaseline(rSvgStyleAttributes.getDominantBaseline()); - aTextTransform.scale(fFontWidth, fFontHeight); - aTextTransform.translate(aPosition.getX(), aPosition.getY()); + basegfx::B2DRange aRange(aTextLayouterDevice.getTextBoundRect(getText(), nIndex, nLength)); + // apply DominantBaseline + switch(aDominantBaseline) + { + case DominantBaseline::Middle: + case DominantBaseline::Central: + { + aPosition.setY(aPosition.getY() - aRange.getCenterY() / sizeFactor); + break; + } + case DominantBaseline::Hanging: + { + aPosition.setY(aPosition.getY() - aRange.getMinY() / sizeFactor); + break; + } + default: // DominantBaseline::Auto + { + // nothing to do + break; + } + } - // check TextDecoration and if TextDecoratedPortionPrimitive2D is needed - const TextDecoration aDeco(rSvgStyleAttributes.getTextDecoration()); + // get BaselineShift + const BaselineShift aBaselineShift(rSvgStyleAttributes.getBaselineShift()); - if(TextDecoration::underline == aDeco - || TextDecoration::overline == aDeco - || TextDecoration::line_through == aDeco) + // apply BaselineShift + switch(aBaselineShift) + { + case BaselineShift::Sub: { - // get the fill for decoration as described by SVG. We cannot - // have different stroke colors/definitions for those, though - const SvgStyleAttributes* pDecoDef = rSvgStyleAttributes.getTextDecorationDefiningSvgStyleAttributes(); - - basegfx::BColor aDecoColor(aFill); - if(pDecoDef && pDecoDef->getFill()) - aDecoColor = *pDecoDef->getFill(); - - TextLine eFontOverline = TEXT_LINE_NONE; - if(TextDecoration::overline == aDeco) - eFontOverline = TEXT_LINE_SINGLE; - - TextLine eFontUnderline = TEXT_LINE_NONE; - if(TextDecoration::underline == aDeco) - eFontUnderline = TEXT_LINE_SINGLE; - - TextStrikeout eTextStrikeout = TEXT_STRIKEOUT_NONE; - if(TextDecoration::line_through == aDeco) - eTextStrikeout = TEXT_STRIKEOUT_SINGLE; - - // create decorated text primitive - pRetval = new TextDecoratedPortionPrimitive2D( - aTextTransform, - getText(), - nIndex, - nLength, - std::move(aTextArray), - {}, - aFontAttribute, - std::move(aLocale), - aFill, - COL_TRANSPARENT, - - // extra props for decorated - aDecoColor, - aDecoColor, - eFontOverline, - eFontUnderline, - false, - eTextStrikeout, - false, - TEXT_FONT_EMPHASIS_MARK_NONE, - true, - false, - TEXT_RELIEF_NONE, - false); + aPosition.setY(aPosition.getY() + aTextLayouterDevice.getUnderlineOffset() / sizeFactor); + break; } - else + case BaselineShift::Super: { - // create text primitive - pRetval = new TextSimplePortionPrimitive2D( - aTextTransform, - getText(), - nIndex, - nLength, - std::move(aTextArray), - {}, - aFontAttribute, - std::move(aLocale), - aFill); + aPosition.setY(aPosition.getY() + aTextLayouterDevice.getOverlineOffset() / sizeFactor); + break; } + case BaselineShift::Percentage: + case BaselineShift::Length: + { + const SvgNumber aNumber(rSvgStyleAttributes.getBaselineShiftNumber()); + const double mfBaselineShift(aNumber.solve(*this)); - if (fFillOpacity != 1.0) + aPosition.setY(aPosition.getY() - mfBaselineShift); + break; + } + default: // BaselineShift::Baseline { - pRetval = new UnifiedTransparencePrimitive2D( - drawinglayer::primitive2d::Primitive2DContainer{ pRetval }, - 1.0 - fFillOpacity); + // nothing to do + break; } + } + + // get fill color + basegfx::BColor aFill(0, 0, 0); + if(rSvgStyleAttributes.getFill()) + aFill = *rSvgStyleAttributes.getFill(); - // advance current TextPosition - rSvgTextPosition.setPosition(rSvgTextPosition.getPosition() + basegfx::B2DVector(fTextWidth, 0.0)); + // get fill opacity + double fFillOpacity = 1.0; + if (rSvgStyleAttributes.getFillOpacity().isSet()) + { + fFillOpacity = rSvgStyleAttributes.getFillOpacity().getNumber(); } + // prepare TextTransformation + basegfx::B2DHomMatrix aTextTransform; + + aTextTransform.scale(fFontWidth, fFontHeight); + aTextTransform.translate(aPosition.getX(), aPosition.getY()); + + // check TextDecoration and if TextDecoratedPortionPrimitive2D is needed + const TextDecoration aDeco(rSvgStyleAttributes.getTextDecoration()); + + if(TextDecoration::underline == aDeco + || TextDecoration::overline == aDeco + || TextDecoration::line_through == aDeco) + { + // get the fill for decoration as described by SVG. We cannot + // have different stroke colors/definitions for those, though + const SvgStyleAttributes* pDecoDef = rSvgStyleAttributes.getTextDecorationDefiningSvgStyleAttributes(); + + basegfx::BColor aDecoColor(aFill); + if(pDecoDef && pDecoDef->getFill()) + aDecoColor = *pDecoDef->getFill(); + + TextLine eFontOverline = TEXT_LINE_NONE; + if(TextDecoration::overline == aDeco) + eFontOverline = TEXT_LINE_SINGLE; + + TextLine eFontUnderline = TEXT_LINE_NONE; + if(TextDecoration::underline == aDeco) + eFontUnderline = TEXT_LINE_SINGLE; + + TextStrikeout eTextStrikeout = TEXT_STRIKEOUT_NONE; + if(TextDecoration::line_through == aDeco) + eTextStrikeout = TEXT_STRIKEOUT_SINGLE; + + // create decorated text primitive + pRetval = new TextDecoratedPortionPrimitive2D( + aTextTransform, + getText(), + nIndex, + nLength, + std::move(aTextArray), + {}, + aFontAttribute, + std::move(aLocale), + aFill, + COL_TRANSPARENT, + + // extra props for decorated + aDecoColor, + aDecoColor, + eFontOverline, + eFontUnderline, + false, + eTextStrikeout, + false, + TEXT_FONT_EMPHASIS_MARK_NONE, + true, + false, + TEXT_RELIEF_NONE, + false); + } + else + { + // create text primitive + pRetval = new TextSimplePortionPrimitive2D( + aTextTransform, + getText(), + nIndex, + nLength, + std::move(aTextArray), + {}, + aFontAttribute, + std::move(aLocale), + aFill); + } + + if (fFillOpacity != 1.0) + { + pRetval = new UnifiedTransparencePrimitive2D( + drawinglayer::primitive2d::Primitive2DContainer{ pRetval }, + 1.0 - fFillOpacity); + } + + // advance current TextPosition + rSvgTextPosition.setPosition(rSvgTextPosition.getPosition() + basegfx::B2DVector(fTextWidth, 0.0)); + return pRetval; }