chart2/qa/extras/xshape/data/reference/tdf149204.xml | 6 - chart2/source/view/inc/PropertyMapper.hxx | 10 ++ chart2/source/view/main/PropertyMapper.cxx | 29 ++++++++ chart2/source/view/main/ShapeFactory.cxx | 68 +++++++++---------- editeng/source/uno/unotext.cxx | 11 ++- 5 files changed, 86 insertions(+), 38 deletions(-)
New commits: commit 1c7472f60b078ed8bb4f6f7d9868f11bf7e227bc Author: Noel Grandin <[email protected]> AuthorDate: Thu Jan 22 10:46:29 2026 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Fri Jan 23 08:20:17 2026 +0100 tdf#167883 use setPropertyValues to set props in bulk instead of one at a time, which reduces the save time from 34s to 16s. Change-Id: I3b4cd0afc6851310b20c9333afb2354801fc1290 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197793 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/chart2/source/view/main/ShapeFactory.cxx b/chart2/source/view/main/ShapeFactory.cxx index 222a656901e6..ee1304074873 100644 --- a/chart2/source/view/main/ShapeFactory.cxx +++ b/chart2/source/view/main/ShapeFactory.cxx @@ -2284,10 +2284,19 @@ rtl::Reference<SvxShapeText> fFontHeight = convertPointToMm100(fFontHeight); sal_Int32 nXDistance = static_cast< sal_Int32 >( ::rtl::math::round( fFontHeight * 0.18f ) ); sal_Int32 nYDistance = static_cast< sal_Int32 >( ::rtl::math::round( fFontHeight * 0.30f ) ); - xShape->SvxShape::setPropertyValue( u"TextLeftDistance"_ustr, uno::Any( nXDistance ) ); - xShape->SvxShape::setPropertyValue( u"TextRightDistance"_ustr, uno::Any( nXDistance ) ); - xShape->SvxShape::setPropertyValue( u"TextUpperDistance"_ustr, uno::Any( nYDistance ) ); - xShape->SvxShape::setPropertyValue( u"TextLowerDistance"_ustr, uno::Any( nYDistance ) ); + uno::Sequence<OUString> aPropNames { + u"TextLeftDistance"_ustr, + u"TextRightDistance"_ustr, + u"TextUpperDistance"_ustr, + u"TextLowerDistance"_ustr, + }; + uno::Sequence<uno::Any> aPropVals { + uno::Any( nXDistance ), + uno::Any( nXDistance ), + uno::Any( nYDistance ), + uno::Any( nYDistance ), + }; + xShape->SvxShape::setPropertyValues( aPropNames, aPropVals ); } sal_Int32 nXPos = rPos.X; sal_Int32 nYPos = rPos.Y; @@ -2297,9 +2306,15 @@ rtl::Reference<SvxShapeText> ::basegfx::B2DHomMatrix aM; aM.rotate( -basegfx::deg2rad(nRotation) );//#i78696#->#i80521# aM.translate( nXPos, nYPos ); - xShape->SvxShape::setPropertyValue( u"Transformation"_ustr, uno::Any( B2DHomMatrixToHomogenMatrix3(aM) ) ); - - xShape->SvxShape::setPropertyValue( u"ParaAdjust"_ustr, uno::Any( style::ParagraphAdjust_CENTER ) ); + uno::Sequence<OUString> aPropNames { + u"Transformation"_ustr, + u"ParaAdjust"_ustr + }; + uno::Sequence<uno::Any> aPropVals { + uno::Any( B2DHomMatrixToHomogenMatrix3(aM) ), + uno::Any( style::ParagraphAdjust_CENTER ) + }; + xShape->SvxShape::setPropertyValues( aPropNames, aPropVals ); } catch( const uno::Exception& ) { diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx index b52d9911f1d6..fb2c22d772dc 100644 --- a/editeng/source/uno/unotext.cxx +++ b/editeng/source/uno/unotext.cxx @@ -2155,10 +2155,19 @@ uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextBase::appendTextPortion( SvxPropertyValuesToItemSet( aItemSet, rCharAndParaProps, ImplGetSvxTextPortionSfxPropertySet(), pTextForwarder, nPara ); pTextForwarder->QuickSetAttribs( aItemSet, aSel ); + rtl::Reference<SvxUnoTextRange> pRange = new SvxUnoTextRange( *this ); pRange->SetSelection( aSel ); + uno::Sequence<OUString> aPropNames(rCharAndParaProps.getLength()); + uno::Sequence<uno::Any> aPropVals(rCharAndParaProps.getLength()); + int i = 0; for( const beans::PropertyValue& rProp : rCharAndParaProps ) - pRange->setPropertyValue( rProp.Name, rProp.Value ); + { + aPropNames.getArray()[i] = rProp.Name; + aPropVals.getArray()[i] = rProp.Value; + ++i; + } + pRange->setPropertyValues( aPropNames, aPropVals ); return pRange; } commit 0e7de7e614cfc23f890abe370c3ec31d057b89c2 Author: Noel Grandin <[email protected]> AuthorDate: Wed Jan 21 13:27:56 2026 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Fri Jan 23 08:20:06 2026 +0100 tdf#167883 use appendTextPortion to construct svx text object which reduces the save time from >200s to 34s. Of course, this being svx, changing the ordering of setting properties results in some small layout changes in the unit tests, none of which look to be significant. Change-Id: Iccd568a9d61715cadd7812b8375496def8f8be52 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197741 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/chart2/qa/extras/xshape/data/reference/tdf149204.xml b/chart2/qa/extras/xshape/data/reference/tdf149204.xml index b14a27418d0a..8964dbd3b12f 100644 --- a/chart2/qa/extras/xshape/data/reference/tdf149204.xml +++ b/chart2/qa/extras/xshape/data/reference/tdf149204.xml @@ -175,7 +175,7 @@ <Line3 column1="0.000000" column2="0.000000" column3="1.000000"/> </Transformation> </XShape> - <XShape positionX="4074" positionY="985" sizeX="9286" sizeY="1295" type="com.sun.star.drawing.TextShape" name="CID/Title=" text="Gráfico de Colunas ou Barras" fontHeight="18.600000" fontColor="595959" textAutoGrowHeight="true" textAutoGrowWidth="true" textContourFrame="false" textFitToSize="NONE" textHorizontalAdjust="CENTER" textVerticalAdjust="CENTER" textLeftDistance="118" textRightDistance="118" textUpperDistance="197" textLowerDistance="197" textMaximumFrameHeight="0" textMaximumFrameWidth="11421" textMinimumFrameHeight="0" textMinimumFrameWidth="0" textAnimationAmount="0" textAnimationCount="0" textAnimationDelay="0" textAnimationDirection="LEFT" textAnimationKind="NONE" textAnimationStartInside="false" textAnimationStopInside="false" textWritingMode="LR_TB" fillStyle="NONE" fillColor="d9d9d9" fillTransparence="0" fillTransparenceGradientName=""> + <XShape positionX="4074" positionY="985" sizeX="9202" sizeY="1155" type="com.sun.star.drawing.TextShape" name="CID/Title=" text="Gráfico de Colunas ou Barras" fontHeight="12" fontColor="ffffffff" textAutoGrowHeight="true" textAutoGrowWidth="true" textContourFrame="false" textFitToSize="NONE" textHorizontalAdjust="CENTER" textVerticalAdjust="CENTER" textLeftDistance="76" textRightDistance="76" textUpperDistance="127" textLowerDistance="127" textMaximumFrameHeight="0" textMaximumFrameWidth="11421" textMinimumFrameHeight="0" textMinimumFrameWidth="0" textAnimationAmount="0" textAnimationCount="0" textAnimationDelay="0" textAnimationDirection="LEFT" textAnimationKind="NONE" textAnimationStartInside="false" textAnimationStopInside="false" textWritingMode="LR_TB" fillStyle="NONE" fillColor="d9d9d9" fillTransparence="0" fillTransparenceGradientName=""> <FillTransparenceGradient style="LINEAR" startColor="000000" endColor="000000" angle="0" border="0" xOffset="50" yOffset="50" startIntensity="100" endIntensity="100" stepCount="0"/> <FillGradient style="LINEAR" startColor="000000" endColor="ffffff" angle="0" border="0" xOffset="50" yOffset="50" startIntensity="100" endIntensity="100" stepCount="0"/> <FillHatch style="SINGLE" color="3465a4" distance="20" angle="0"/> @@ -184,8 +184,8 @@ <LineStart/> <LineEnd/> <Transformation> - <Line1 column1="9287.000000" column2="0.000000" column3="4074.000000"/> - <Line2 column1="0.000000" column2="1296.000000" column3="985.000000"/> + <Line1 column1="9203.000000" column2="0.000000" column3="4074.000000"/> + <Line2 column1="0.000000" column2="1156.000000" column3="985.000000"/> <Line3 column1="0.000000" column2="0.000000" column3="1.000000"/> </Transformation> </XShape> diff --git a/chart2/source/view/inc/PropertyMapper.hxx b/chart2/source/view/inc/PropertyMapper.hxx index c4d9a1fa2577..2ab24a1cc67f 100644 --- a/chart2/source/view/inc/PropertyMapper.hxx +++ b/chart2/source/view/inc/PropertyMapper.hxx @@ -22,6 +22,7 @@ #include <unordered_map> +#include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/uno/Sequence.h> #include <com/sun/star/uno/Reference.h> @@ -55,6 +56,15 @@ public: , const css::uno::Reference< css::beans::XPropertySet >& xSource , const tPropertyNameMap& rMap ); + /** + * Fetch property values from source object and store them into + * a sequence of beans::PropertyValue. For use when passing + * data to css::text::XTextPortionAppend. + */ + static css::uno::Sequence<css::beans::PropertyValue> getPropVals( + const css::uno::Reference< css::beans::XPropertySet >& xSource + , const tPropertyNameMap& rMap ); + /** * Fetch property values from the source object and map it to the * destination container. Only those properties that are explicitly set diff --git a/chart2/source/view/main/PropertyMapper.cxx b/chart2/source/view/main/PropertyMapper.cxx index 97a9a0466e7c..a0130156782c 100644 --- a/chart2/source/view/main/PropertyMapper.cxx +++ b/chart2/source/view/main/PropertyMapper.cxx @@ -27,6 +27,7 @@ #include <com/sun/star/drawing/LineJoint.hpp> #include <com/sun/star/style/ParagraphAdjust.hpp> #include <comphelper/diagnose_ex.hxx> +#include <comphelper/sequence.hxx> #include <svx/unoshape.hxx> namespace chart @@ -155,6 +156,34 @@ void PropertyMapper::setMappedProperties( } } +css::uno::Sequence<css::beans::PropertyValue> PropertyMapper::getPropVals( + const uno::Reference< beans::XPropertySet >& xSource + , const tPropertyNameMap& rMap ) +{ + std::vector<css::beans::PropertyValue> aRet; + aRet.reserve(rMap.size()); + uno::Reference< css::beans::XPropertySetInfo > xInfo = xSource->getPropertySetInfo(); + + for (auto const& elem : rMap) + { + const OUString & rTarget = elem.first; + const OUString & rSource = elem.second; + if (xInfo->hasPropertyByName(rSource)) + { + uno::Any aAny( xSource->getPropertyValue(rSource) ); + if( aAny.hasValue() ) + { + //do not set empty anys because of performance (otherwise SdrAttrObj::ItemChange will take much longer) + css::beans::PropertyValue aPropVal; + aPropVal.Name = rTarget; + aPropVal.Value = std::move(aAny); + aRet.push_back(std::move(aPropVal)); + } + } + } + return comphelper::containerToSequence(aRet); +} + void PropertyMapper::getValueMap( tPropertyNameValueMap& rValueMap , const tPropertyNameMap& rNameMap diff --git a/chart2/source/view/main/ShapeFactory.cxx b/chart2/source/view/main/ShapeFactory.cxx index 619fa840e683..222a656901e6 100644 --- a/chart2/source/view/main/ShapeFactory.cxx +++ b/chart2/source/view/main/ShapeFactory.cxx @@ -51,6 +51,7 @@ #include <basegfx/matrix/b3dhommatrix.hxx> #include <svx/svdpage.hxx> #include <svx/svdopath.hxx> +#include <svx/svdorect.hxx> #include <comphelper/diagnose_ex.hxx> #include <tools/helpers.hxx> #include <tools/UnitConversion.hxx> @@ -2228,6 +2229,9 @@ rtl::Reference<SvxShapeText> TOOLS_WARN_EXCEPTION("chart2", "" ); } + // Lock during property update to prevent unnecessary layout work. + xShape->addActionLock(); + uno::Reference< beans::XPropertySet > xSelectionProp(xSelectionCursor, uno::UNO_QUERY); if(bStackCharacters) { @@ -2237,24 +2241,14 @@ rtl::Reference<SvxShapeText> { if (!rxFS->getString().isEmpty()) { - xTextCursor->gotoEnd(false); - xSelectionCursor->gotoEnd(false); OUString aLabel = ShapeFactory::getStackedString(rxFS->getString(), bStackCharacters); if (nLBreaks-- > 0) aLabel += OUStringChar(' '); - xShape->insertString(xTextCursor, aLabel, false); - xSelectionCursor->gotoEnd(true); // select current paragraph uno::Reference< beans::XPropertySet > xSourceProps(rxFS, uno::UNO_QUERY); - if (xFormattedString.size() > 1 && xSelectionProp.is()) - { - PropertyMapper::setMappedProperties(xSelectionProp, xSourceProps, - PropertyMapper::getPropertyNameMapForTextShapeProperties()); - } - else - { - PropertyMapper::setMappedProperties(*xShape, xSourceProps, + uno::Sequence<beans::PropertyValue> aPropVals = + PropertyMapper::getPropVals(xSourceProps, PropertyMapper::getPropertyNameMapForTextShapeProperties()); - } + xShape->appendTextPortion(aLabel, aPropVals); } } } @@ -2264,26 +2258,17 @@ rtl::Reference<SvxShapeText> { if (!rxFS->getString().isEmpty()) { - xTextCursor->gotoEnd(false); - xSelectionCursor->gotoEnd(false); - xShape->insertString(xTextCursor, rxFS->getString(), false); - xSelectionCursor->gotoEnd(true); // select current paragraph uno::Reference< beans::XPropertySet > xSourceProps(rxFS, uno::UNO_QUERY); - if (xFormattedString.size() > 1 && xSelectionProp.is()) - { - PropertyMapper::setMappedProperties(xSelectionProp, xSourceProps, - PropertyMapper::getPropertyNameMapForTextShapeProperties()); - } - else - { - PropertyMapper::setMappedProperties(*xShape, xSourceProps, + uno::Sequence<beans::PropertyValue> aPropVals = + PropertyMapper::getPropVals(xSourceProps, PropertyMapper::getPropertyNameMapForTextShapeProperties()); - } + xShape->appendTextPortion(rxFS->getString(), aPropVals); } } - } + xShape->removeActionLock(); + // adapt font size according to page size awt::Size aOldRefSize; if( xTextProperties->getPropertyValue(u"ReferencePageSize"_ustr) >>= aOldRefSize )
