sw/source/core/doc/docfmt.cxx | 7 +--- sw/source/core/unocore/unocrsrhelper.cxx | 41 ++++++++++++++++--------- sw/source/core/unocore/unoobj.cxx | 2 - writerfilter/source/ooxml/OOXMLPropertySet.hxx | 34 ++++++++++---------- 4 files changed, 48 insertions(+), 36 deletions(-)
New commits: commit 156073b6ed57424da685bd141ee366bd4467c4e0 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Thu Jul 28 08:59:37 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Jul 28 13:03:43 2022 +0200 these classes can be final Change-Id: I84bb39b6365e445998a793798279c7f9f1064581 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137552 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/writerfilter/source/ooxml/OOXMLPropertySet.hxx b/writerfilter/source/ooxml/OOXMLPropertySet.hxx index b30fbaf61f9b..ceabfb586011 100644 --- a/writerfilter/source/ooxml/OOXMLPropertySet.hxx +++ b/writerfilter/source/ooxml/OOXMLPropertySet.hxx @@ -49,7 +49,7 @@ public: virtual OOXMLValue* clone() const; }; -class OOXMLProperty : public Sprm +class OOXMLProperty final : public Sprm { public: typedef tools::SvRef<OOXMLProperty> Pointer_t; @@ -79,7 +79,7 @@ public: void resolve(Properties& rProperties); }; -class OOXMLBinaryValue : public OOXMLValue +class OOXMLBinaryValue final : public OOXMLValue { mutable OOXMLBinaryObjectReference::Pointer_t mpBinaryObj; @@ -94,7 +94,7 @@ public: virtual OOXMLValue* clone() const override; }; -class OOXMLBooleanValue : public OOXMLValue +class OOXMLBooleanValue final : public OOXMLValue { bool mbValue; explicit OOXMLBooleanValue(bool bValue); @@ -118,7 +118,7 @@ public: virtual OOXMLValue* clone() const override; }; -class OOXMLStringValue : public OOXMLValue +class OOXMLStringValue final : public OOXMLValue { OUString mStr; @@ -139,7 +139,7 @@ public: virtual OOXMLValue* clone() const override; }; -class OOXMLInputStreamValue : public OOXMLValue +class OOXMLInputStreamValue final : public OOXMLValue { css::uno::Reference<css::io::XInputStream> mxInputStream; @@ -154,7 +154,7 @@ public: virtual OOXMLValue* clone() const override; }; -class OOXMLPropertySet : public writerfilter::Reference<Properties> +class OOXMLPropertySet final : public writerfilter::Reference<Properties> { public: typedef std::vector<OOXMLProperty::Pointer_t> OOXMLProperties_t; @@ -190,7 +190,7 @@ public: class OOXMLValue; -class OOXMLTable : public writerfilter::Reference<Table> +class OOXMLTable final : public writerfilter::Reference<Table> { public: typedef tools::SvRef<OOXMLValue> ValuePointer_t; @@ -211,7 +211,7 @@ private: PropertySets_t mPropertySets; }; -class OOXMLPropertySetValue : public OOXMLValue +class OOXMLPropertySetValue final : public OOXMLValue { OOXMLPropertySet::Pointer_t mpPropertySet; @@ -233,7 +233,7 @@ public: virtual OOXMLValue* clone() const override; }; -class OOXMLIntegerValue : public OOXMLValue +class OOXMLIntegerValue final : public OOXMLValue { sal_Int32 mnValue; explicit OOXMLIntegerValue(sal_Int32 nValue); @@ -277,7 +277,7 @@ public: virtual OOXMLValue* clone() const override; }; -class OOXMLHexColorValue : public OOXMLHexValue +class OOXMLHexColorValue final : public OOXMLHexValue { public: explicit OOXMLHexColorValue(const char* pValue); @@ -304,7 +304,7 @@ public: }; /// npPt is quotient defining how much units are in 1 pt -template <sal_uInt32 npPt> class OOXMLNthPtMeasureValue : public OOXMLUniversalMeasureValue +template <sal_uInt32 npPt> class OOXMLNthPtMeasureValue final : public OOXMLUniversalMeasureValue { public: explicit OOXMLNthPtMeasureValue(const char* pValue) @@ -320,7 +320,7 @@ typedef OOXMLNthPtMeasureValue<20> OOXMLTwipsMeasureValue; /// Handles OOXML's ST_HpsMeasure value. typedef OOXMLNthPtMeasureValue<2> OOXMLHpsMeasureValue; -class OOXMLMeasurementOrPercentValue : public OOXMLValue +class OOXMLMeasurementOrPercentValue final : public OOXMLValue { int mnValue; @@ -334,7 +334,7 @@ public: #endif }; -class OOXMLShapeValue : public OOXMLValue +class OOXMLShapeValue final : public OOXMLValue { css::uno::Reference<css::drawing::XShape> mrShape; @@ -349,7 +349,7 @@ public: virtual OOXMLValue* clone() const override; }; -class OOXMLStarMathValue : public OOXMLValue +class OOXMLStarMathValue final : public OOXMLValue { css::uno::Reference<css::embed::XEmbeddedObject> component; @@ -364,7 +364,7 @@ public: virtual OOXMLValue* clone() const override; }; -class OOXMLPropertySetEntryToString : public Properties +class OOXMLPropertySetEntryToString final : public Properties { Id mnId; OUString mStr; @@ -379,7 +379,7 @@ public: const OUString& getString() const { return mStr; } }; -class OOXMLPropertySetEntryToInteger : public Properties +class OOXMLPropertySetEntryToInteger final : public Properties { Id mnId; int mnValue; @@ -394,7 +394,7 @@ public: int getValue() const { return mnValue; } }; -class OOXMLPropertySetEntryToBool : public Properties +class OOXMLPropertySetEntryToBool final : public Properties { Id mnId; bool mValue; commit 031da439aca27c031bf122a837ee53d074c75358 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Wed Jul 27 21:32:34 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Jul 28 13:03:30 2022 +0200 tdf#119840 elide some allocations Change-Id: Ibff6a80a65463641337dc30d88c7ee8432cf816c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137551 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx index fc6317e65984..ba900eceef2f 100644 --- a/sw/source/core/doc/docfmt.cxx +++ b/sw/source/core/doc/docfmt.cxx @@ -246,6 +246,7 @@ void SwDoc::ResetAttrs( const SwPaM &rRg, SwRootFrame const*const pLayout) { SwPaM* pPam = const_cast<SwPaM*>(&rRg); + std::optional<SwPaM> oExtraPaM; if( !bTextAttr && !rAttrs.empty() && RES_TXTATR_END > *(rAttrs.begin()) ) bTextAttr = true; @@ -255,7 +256,8 @@ void SwDoc::ResetAttrs( const SwPaM &rRg, if( !pTextNd ) return ; - pPam = new SwPaM( *rRg.GetPoint() ); + oExtraPaM.emplace( *rRg.GetPoint() ); + pPam = &*oExtraPaM; SwContentIndex& rSt = pPam->GetPoint()->nContent; sal_Int32 nMkPos, nPtPos = rSt.GetIndex(); @@ -396,9 +398,6 @@ void SwDoc::ResetAttrs( const SwPaM &rRg, getIDocumentState().SetModified(); oDataChanged.reset(); //before delete pPam - - if( pPam != &rRg ) - delete pPam; } /// Set the rsid of the next nLen symbols of rRg to the current session number diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index b176138a0d2a..5ccfebd164ea 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -1259,29 +1259,43 @@ void makeRedline( SwPaM const & rPaM, throw lang::IllegalArgumentException(); //todo: what about REDLINE_FMTCOLL? - comphelper::SequenceAsHashMap aPropMap( rRedlineProperties ); std::size_t nAuthor = 0; OUString sAuthor; - if( aPropMap.getValue("RedlineAuthor") >>= sAuthor ) - nAuthor = rRedlineAccess.InsertRedlineAuthor(sAuthor); - OUString sComment; - SwRedlineData aRedlineData( eType, nAuthor ); - if( aPropMap.getValue("RedlineComment") >>= sComment ) - aRedlineData.SetComment( sComment ); - ::util::DateTime aStamp; - if( aPropMap.getValue("RedlineDateTime") >>= aStamp ) + uno::Sequence< beans::PropertyValue > aRevertProperties; + bool bIsMoved = false; + bool bFoundComment = false; + bool bFoundStamp = false; + bool bFoundRevertProperties = false; + for (const css::beans::PropertyValue & rProp : rRedlineProperties ) { - aRedlineData.SetTimeStamp( DateTime( aStamp)); + if (rProp.Name == "RedlineAuthor") + { + if( rProp.Value >>= sAuthor ) + nAuthor = rRedlineAccess.InsertRedlineAuthor(sAuthor); + } + else if (rProp.Name == "RedlineComment") + bFoundComment = rProp.Value >>= sComment; + else if (rProp.Name == "RedlineDateTime") + bFoundStamp = rProp.Value >>= aStamp; + else if (rProp.Name == "RedlineRevertProperties") + bFoundRevertProperties = rProp.Value >>= aRevertProperties; + else if (rProp.Name == "RedlineMoved") + rProp.Value >>= bIsMoved; } + SwRedlineData aRedlineData( eType, nAuthor ); + if( bFoundComment ) + aRedlineData.SetComment( sComment ); + if( bFoundStamp ) + aRedlineData.SetTimeStamp( DateTime( aStamp)); + std::unique_ptr<SwRedlineExtraData_FormatColl> xRedlineExtraData; // Read the 'Redline Revert Properties' from the parameters - uno::Sequence< beans::PropertyValue > aRevertProperties; // Check if the value exists - if ( aPropMap.getValue("RedlineRevertProperties") >>= aRevertProperties ) + if ( bFoundRevertProperties ) { int nMap = 0; // Make sure that paragraph format gets its own map, otherwise e.g. fill attributes are not preserved. @@ -1388,8 +1402,7 @@ void makeRedline( SwPaM const & rPaM, SwRangeRedline* pRedline = new SwRangeRedline( aRedlineData, rPaM ); // set IsMoved bit of the redline to show and handle moved text - bool bIsMoved; - if( (aPropMap.getValue("RedlineMoved") >>= bIsMoved) && bIsMoved ) + if( bIsMoved ) pRedline->SetMoved(); RedlineFlags nPrevMode = rRedlineAccess.GetRedlineFlags( ); diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index 87ab9acc6141..f13dccec4c64 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -1827,7 +1827,7 @@ void SwUnoCursorHelper::SetPropertyValues( if (!aEntries.empty()) { // Fetch, overwrite, and re-set the attributes from the core - SfxItemSet aItemSet(rDoc.GetAttrPool(), aRanges); + SfxItemSet aItemSet(rDoc.GetAttrPool(), std::move(aRanges)); bool bPreviousPropertyCausesSideEffectsInNodes = false; for (size_t i = 0; i < aEntries.size(); ++i)