[Libreoffice-commits] core.git: editeng/source include/editeng include/svx sc/source

Noel Grandin noelgrandin at gmail.com
Fri Jul 13 06:39:40 UTC 2018


 editeng/source/items/CustomPropertyField.cxx |    5 -
 editeng/source/items/flditem.cxx             |   82 ++++++++++++++-------------
 editeng/source/items/svdfield.cxx            |    5 -
 editeng/source/uno/unofield.cxx              |   58 +++++++++----------
 editeng/source/uno/unotext.cxx               |   13 +---
 include/editeng/CustomPropertyField.hxx      |    2 
 include/editeng/flditem.hxx                  |   41 ++++++-------
 include/editeng/measfld.hxx                  |    2 
 include/editeng/unofield.hxx                 |    2 
 include/editeng/unotext.hxx                  |    2 
 include/svx/ClassificationField.hxx          |    5 -
 sc/source/filter/xml/xmlcelli.cxx            |   16 ++---
 sc/source/filter/xml/xmlcelli.hxx            |    6 -
 sc/source/ui/unoobj/fielduno.cxx             |    2 
 14 files changed, 122 insertions(+), 119 deletions(-)

New commits:
commit ddef60b9c26b1d2990c6c49dbbda73e7831f21fb
Author: Noel Grandin <noelgrandin at gmail.com>
Date:   Wed Jul 11 21:53:47 2018 +0200

    pass SvxFieldData around by std::unique_ptr
    
    Change-Id: I9c826547d348000dd6c80e45d833e048caae0ed8
    Reviewed-on: https://gerrit.libreoffice.org/57308
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/editeng/source/items/CustomPropertyField.cxx b/editeng/source/items/CustomPropertyField.cxx
index e8ef53ceebb2..3fbe5a89fe89 100644
--- a/editeng/source/items/CustomPropertyField.cxx
+++ b/editeng/source/items/CustomPropertyField.cxx
@@ -9,6 +9,7 @@
  */
 
 #include <editeng/CustomPropertyField.hxx>
+#include <o3tl/make_unique.hxx>
 #include <vcl/metaact.hxx>
 #include <com/sun/star/beans/XPropertyContainer.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
@@ -29,9 +30,9 @@ CustomPropertyField::~CustomPropertyField()
 
 SV_IMPL_PERSIST1(CustomPropertyField);
 
-tools::SvRef<SvxFieldData> CustomPropertyField::Clone() const
+std::unique_ptr<SvxFieldData> CustomPropertyField::Clone() const
 {
-    return new CustomPropertyField(msName, msCurrentPresentation);
+    return o3tl::make_unique<CustomPropertyField>(msName, msCurrentPresentation);
 }
 
 bool CustomPropertyField::operator==(const SvxFieldData& rOther) const
diff --git a/editeng/source/items/flditem.cxx b/editeng/source/items/flditem.cxx
index eca2d4a7ec78..722d54a710db 100644
--- a/editeng/source/items/flditem.cxx
+++ b/editeng/source/items/flditem.cxx
@@ -21,6 +21,7 @@
 #include <vcl/metaact.hxx>
 #include <svl/zforlist.hxx>
 #include <tools/urlobj.hxx>
+#include <o3tl/make_unique.hxx>
 
 #include <editeng/flditem.hxx>
 #include <editeng/CustomPropertyField.hxx>
@@ -238,9 +239,6 @@ SvxFieldData* SvxFieldData::Create(const uno::Reference<text::XTextContent>& xTe
 }
 
 
-SV_IMPL_PERSIST1( SvxFieldData );
-
-
 SvxFieldData::SvxFieldData()
 {
 }
@@ -251,9 +249,9 @@ SvxFieldData::~SvxFieldData()
 }
 
 
-tools::SvRef<SvxFieldData> SvxFieldData::Clone() const
+std::unique_ptr<SvxFieldData> SvxFieldData::Clone() const
 {
-    return new SvxFieldData;
+    return o3tl::make_unique<SvxFieldData>();
 }
 
 
@@ -276,16 +274,22 @@ MetaAction* SvxFieldData::createEndComment()
 }
 
 
+SvxFieldItem::SvxFieldItem( std::unique_ptr<SvxFieldData> pField, const sal_uInt16 nId ) :
+    SfxPoolItem( nId )
+    , mpField( std::move(pField) )
+{
+}
+
 SvxFieldItem::SvxFieldItem( const SvxFieldData& rField, const sal_uInt16 nId ) :
     SfxPoolItem( nId )
-    , mxField( rField.Clone() )
+    , mpField( rField.Clone() )
 {
 }
 
 
 SvxFieldItem::SvxFieldItem( const SvxFieldItem& rItem ) :
     SfxPoolItem ( rItem )
-    , mxField( rItem.GetField() ? rItem.GetField()->Clone() : nullptr )
+    , mpField( rItem.GetField() ? rItem.GetField()->Clone() : nullptr )
 {
 }
 
@@ -306,12 +310,12 @@ bool SvxFieldItem::operator==( const SfxPoolItem& rItem ) const
     assert(SfxPoolItem::operator==(rItem));
 
     const SvxFieldData* pOtherFld = static_cast<const SvxFieldItem&>(rItem).GetField();
-    if( mxField.get() == pOtherFld )
+    if( mpField.get() == pOtherFld )
         return true;
-    if( mxField == nullptr || pOtherFld == nullptr )
+    if( mpField == nullptr || pOtherFld == nullptr )
         return false;
-    return ( typeid(*mxField) == typeid(*pOtherFld) )
-            && ( *mxField == *pOtherFld );
+    return ( typeid(*mpField) == typeid(*pOtherFld) )
+            && ( *mpField == *pOtherFld );
 }
 
 
@@ -337,9 +341,9 @@ SvxDateField::SvxDateField( const Date& rDate, SvxDateType eT, SvxDateFormat eF
 }
 
 
-tools::SvRef<SvxFieldData> SvxDateField::Clone() const
+std::unique_ptr<SvxFieldData> SvxDateField::Clone() const
 {
-    return new SvxDateField( *this );
+    return o3tl::make_unique<SvxDateField>( *this );
 }
 
 
@@ -448,9 +452,9 @@ SvxURLField::SvxURLField( const OUString& rURL, const OUString& rRepres, SvxURLF
 }
 
 
-tools::SvRef<SvxFieldData> SvxURLField::Clone() const
+std::unique_ptr<SvxFieldData> SvxURLField::Clone() const
 {
-    return new SvxURLField( *this );
+    return o3tl::make_unique<SvxURLField>( *this );
 }
 
 
@@ -484,9 +488,9 @@ SV_IMPL_PERSIST1( SvxPageTitleField );
 
 SvxPageTitleField::SvxPageTitleField() {}
 
-tools::SvRef<SvxFieldData> SvxPageTitleField::Clone() const
+std::unique_ptr<SvxFieldData> SvxPageTitleField::Clone() const
 {
-    return new SvxPageTitleField();
+    return o3tl::make_unique<SvxPageTitleField>();
 }
 
 bool SvxPageTitleField::operator==( const SvxFieldData& rCmp ) const
@@ -509,9 +513,9 @@ SV_IMPL_PERSIST1( SvxPageField );
 
 SvxPageField::SvxPageField() {}
 
-tools::SvRef<SvxFieldData> SvxPageField::Clone() const
+std::unique_ptr<SvxFieldData> SvxPageField::Clone() const
 {
-    return new SvxPageField;        // empty
+    return o3tl::make_unique<SvxPageField>();        // empty
 }
 
 bool SvxPageField::operator==( const SvxFieldData& rCmp ) const
@@ -529,9 +533,9 @@ SV_IMPL_PERSIST1( SvxPagesField );
 
 SvxPagesField::SvxPagesField() {}
 
-tools::SvRef<SvxFieldData> SvxPagesField::Clone() const
+std::unique_ptr<SvxFieldData> SvxPagesField::Clone() const
 {
-    return new SvxPagesField;   // empty
+    return o3tl::make_unique<SvxPagesField>();   // empty
 }
 
 bool SvxPagesField::operator==( const SvxFieldData& rCmp ) const
@@ -543,9 +547,9 @@ SV_IMPL_PERSIST1( SvxTimeField );
 
 SvxTimeField::SvxTimeField() {}
 
-tools::SvRef<SvxFieldData> SvxTimeField::Clone() const
+std::unique_ptr<SvxFieldData> SvxTimeField::Clone() const
 {
-    return new SvxTimeField;    // empty
+    return o3tl::make_unique<SvxTimeField>();    // empty
 }
 
 bool SvxTimeField::operator==( const SvxFieldData& rCmp ) const
@@ -562,9 +566,9 @@ SV_IMPL_PERSIST1( SvxFileField );
 
 SvxFileField::SvxFileField() {}
 
-tools::SvRef<SvxFieldData> SvxFileField::Clone() const
+std::unique_ptr<SvxFieldData> SvxFileField::Clone() const
 {
-    return new SvxFileField;    // empty
+    return o3tl::make_unique<SvxFileField>();    // empty
 }
 
 bool SvxFileField::operator==( const SvxFieldData& rCmp ) const
@@ -584,9 +588,9 @@ void SvxTableField::SetTab(int nTab)
 }
 
 
-tools::SvRef<SvxFieldData> SvxTableField::Clone() const
+std::unique_ptr<SvxFieldData> SvxTableField::Clone() const
 {
-    return new SvxTableField(mnTab);
+    return o3tl::make_unique<SvxTableField>(mnTab);
 }
 
 bool SvxTableField::operator==( const SvxFieldData& rCmp ) const
@@ -619,9 +623,9 @@ SvxExtTimeField::SvxExtTimeField( const tools::Time& rTime, SvxTimeType eT, SvxT
 }
 
 
-tools::SvRef<SvxFieldData> SvxExtTimeField::Clone() const
+std::unique_ptr<SvxFieldData> SvxExtTimeField::Clone() const
 {
-    return new SvxExtTimeField( *this );
+    return o3tl::make_unique<SvxExtTimeField>( *this );
 }
 
 
@@ -735,9 +739,9 @@ SvxExtFileField::SvxExtFileField( const OUString& rStr, SvxFileType eT, SvxFileF
 }
 
 
-tools::SvRef<SvxFieldData> SvxExtFileField::Clone() const
+std::unique_ptr<SvxFieldData> SvxExtFileField::Clone() const
 {
-    return new SvxExtFileField( *this );
+    return o3tl::make_unique<SvxExtFileField>( *this );
 }
 
 
@@ -848,9 +852,9 @@ SvxAuthorField::SvxAuthorField( const OUString& rFirstName,
 }
 
 
-tools::SvRef<SvxFieldData> SvxAuthorField::Clone() const
+std::unique_ptr<SvxFieldData> SvxAuthorField::Clone() const
 {
-    return new SvxAuthorField( *this );
+    return o3tl::make_unique<SvxAuthorField>( *this );
 }
 
 
@@ -897,9 +901,9 @@ SV_IMPL_PERSIST1( SvxHeaderField );
 
 SvxHeaderField::SvxHeaderField() {}
 
-tools::SvRef<SvxFieldData> SvxHeaderField::Clone() const
+std::unique_ptr<SvxFieldData> SvxHeaderField::Clone() const
 {
-    return new SvxHeaderField;      // empty
+    return o3tl::make_unique<SvxHeaderField>();      // empty
 }
 
 bool SvxHeaderField::operator==( const SvxFieldData& rCmp ) const
@@ -911,9 +915,9 @@ SV_IMPL_PERSIST1( SvxFooterField );
 
 SvxFooterField::SvxFooterField() {}
 
-tools::SvRef<SvxFieldData> SvxFooterField::Clone() const
+std::unique_ptr<SvxFieldData> SvxFooterField::Clone() const
 {
-    return new SvxFooterField;      // empty
+    return o3tl::make_unique<SvxFooterField>();      // empty
 }
 
 bool SvxFooterField::operator==( const SvxFieldData& rCmp ) const
@@ -923,9 +927,9 @@ bool SvxFooterField::operator==( const SvxFieldData& rCmp ) const
 
 SV_IMPL_PERSIST1( SvxDateTimeField );
 
-tools::SvRef<SvxFieldData> SvxDateTimeField::Clone() const
+std::unique_ptr<SvxFieldData> SvxDateTimeField::Clone() const
 {
-    return new SvxDateTimeField;        // empty
+    return o3tl::make_unique<SvxDateTimeField>();        // empty
 }
 
 bool SvxDateTimeField::operator==( const SvxFieldData& rCmp ) const
diff --git a/editeng/source/items/svdfield.cxx b/editeng/source/items/svdfield.cxx
index e448126b5d39..ac3c0900de37 100644
--- a/editeng/source/items/svdfield.cxx
+++ b/editeng/source/items/svdfield.cxx
@@ -19,6 +19,7 @@
 
 
 #include <editeng/measfld.hxx>
+#include <o3tl/make_unique.hxx>
 
 SV_IMPL_PERSIST1(SdrMeasureField);
 
@@ -26,9 +27,9 @@ SdrMeasureField::~SdrMeasureField()
 {
 }
 
-tools::SvRef<SvxFieldData> SdrMeasureField::Clone() const
+std::unique_ptr<SvxFieldData> SdrMeasureField::Clone() const
 {
-    return new SdrMeasureField(*this);
+    return o3tl::make_unique<SdrMeasureField>(*this);
 }
 
 bool SdrMeasureField::operator==(const SvxFieldData& rSrc) const
diff --git a/editeng/source/uno/unofield.cxx b/editeng/source/uno/unofield.cxx
index 29b84fd2833b..6cc201e93725 100644
--- a/editeng/source/uno/unofield.cxx
+++ b/editeng/source/uno/unofield.cxx
@@ -411,9 +411,9 @@ SvxUnoTextField::~SvxUnoTextField() throw()
 {
 }
 
-SvxFieldData* SvxUnoTextField::CreateFieldData() const throw()
+std::unique_ptr<SvxFieldData> SvxUnoTextField::CreateFieldData() const throw()
 {
-    SvxFieldData* pData = nullptr;
+    std::unique_ptr<SvxFieldData> pData;
 
     switch( mnServiceId )
     {
@@ -424,25 +424,25 @@ SvxFieldData* SvxUnoTextField::CreateFieldData() const throw()
         if( mpImpl->mbBoolean2 ) // IsDate?
         {
             Date aDate( setDate( mpImpl->maDateTime ) );
-            pData = new SvxDateField( aDate, mpImpl->mbBoolean1?SvxDateType::Fix:SvxDateType::Var );
+            pData.reset( new SvxDateField( aDate, mpImpl->mbBoolean1?SvxDateType::Fix:SvxDateType::Var ) );
             if( mpImpl->mnInt32 >= static_cast<sal_Int32>(SvxDateFormat::AppDefault) &&
                 mpImpl->mnInt32 <= static_cast<sal_Int32>(SvxDateFormat::F) )
-                static_cast<SvxDateField*>(pData)->SetFormat( static_cast<SvxDateFormat>(mpImpl->mnInt32) );
+                static_cast<SvxDateField*>(pData.get())->SetFormat( static_cast<SvxDateFormat>(mpImpl->mnInt32) );
         }
         else
         {
             if( mnServiceId != text::textfield::Type::TIME && mnServiceId != text::textfield::Type::DATE )
             {
                 tools::Time aTime( setTime( mpImpl->maDateTime ) );
-                pData = new SvxExtTimeField( aTime, mpImpl->mbBoolean1?SvxTimeType::Fix:SvxTimeType::Var );
+                pData.reset( new SvxExtTimeField( aTime, mpImpl->mbBoolean1?SvxTimeType::Fix:SvxTimeType::Var ) );
 
                 if( static_cast<SvxTimeFormat>(mpImpl->mnInt32) >= SvxTimeFormat::AppDefault &&
                     static_cast<SvxTimeFormat>(mpImpl->mnInt32) <= SvxTimeFormat::HH12_MM_SS_00_AMPM )
-                    static_cast<SvxExtTimeField*>(pData)->SetFormat( static_cast<SvxTimeFormat>(mpImpl->mnInt32) );
+                    static_cast<SvxExtTimeField*>(pData.get())->SetFormat( static_cast<SvxTimeFormat>(mpImpl->mnInt32) );
             }
             else
             {
-                pData = new SvxTimeField();
+                pData.reset( new SvxTimeField() );
             }
         }
 
@@ -450,35 +450,35 @@ SvxFieldData* SvxUnoTextField::CreateFieldData() const throw()
         break;
 
     case text::textfield::Type::URL:
-        pData = new SvxURLField( mpImpl->msString3, mpImpl->msString1, !mpImpl->msString1.isEmpty() ? SvxURLFormat::Repr : SvxURLFormat::Url );
-        static_cast<SvxURLField*>(pData)->SetTargetFrame( mpImpl->msString2 );
+        pData.reset( new SvxURLField( mpImpl->msString3, mpImpl->msString1, !mpImpl->msString1.isEmpty() ? SvxURLFormat::Repr : SvxURLFormat::Url ) );
+        static_cast<SvxURLField*>(pData.get())->SetTargetFrame( mpImpl->msString2 );
         if( static_cast<SvxURLFormat>(mpImpl->mnInt16) >= SvxURLFormat::AppDefault &&
             static_cast<SvxURLFormat>(mpImpl->mnInt16) <= SvxURLFormat::Repr )
-            static_cast<SvxURLField*>(pData)->SetFormat( static_cast<SvxURLFormat>(mpImpl->mnInt16) );
+            static_cast<SvxURLField*>(pData.get())->SetFormat( static_cast<SvxURLFormat>(mpImpl->mnInt16) );
         break;
 
     case text::textfield::Type::PAGE:
-        pData = new SvxPageField();
+        pData.reset( new SvxPageField() );
         break;
 
     case text::textfield::Type::PAGES:
-        pData = new SvxPagesField();
+        pData.reset( new SvxPagesField() );
         break;
 
     case text::textfield::Type::DOCINFO_TITLE:
-        pData = new SvxFileField();
+        pData.reset( new SvxFileField() );
         break;
 
     case text::textfield::Type::TABLE:
-        pData = new SvxTableField();
+        pData.reset( new SvxTableField() );
         break;
 
     case text::textfield::Type::EXTENDED_FILE:
     {
         // #92009# pass fixed attribute to constructor
-        pData = new SvxExtFileField( mpImpl->msString1,
+        pData.reset( new SvxExtFileField( mpImpl->msString1,
                                      mpImpl->mbBoolean1 ? SvxFileType::Fix : SvxFileType::Var,
-                                     setFileNameDisplayFormat(mpImpl->mnInt16 ) );
+                                     setFileNameDisplayFormat(mpImpl->mnInt16 ) ) );
         break;
     }
 
@@ -509,17 +509,17 @@ SvxFieldData* SvxUnoTextField::CreateFieldData() const throw()
         }
 
         // #92009# pass fixed attribute to constructor
-        pData = new SvxAuthorField( aFirstName, aLastName, "",
-                                    mpImpl->mbBoolean1 ? SvxAuthorType::Fix : SvxAuthorType::Var );
+        pData.reset( new SvxAuthorField( aFirstName, aLastName, "",
+                                    mpImpl->mbBoolean1 ? SvxAuthorType::Fix : SvxAuthorType::Var ) );
 
         if( !mpImpl->mbBoolean2 )
         {
-            static_cast<SvxAuthorField*>(pData)->SetFormat( SvxAuthorFormat::ShortName );
+            static_cast<SvxAuthorField*>(pData.get())->SetFormat( SvxAuthorFormat::ShortName );
         }
         else if( static_cast<SvxAuthorFormat>(mpImpl->mnInt16) >= SvxAuthorFormat::FullName &&
                  static_cast<SvxAuthorFormat>(mpImpl->mnInt16) <= SvxAuthorFormat::ShortName )
         {
-            static_cast<SvxAuthorField*>(pData)->SetFormat( static_cast<SvxAuthorFormat>(mpImpl->mnInt16) );
+            static_cast<SvxAuthorField*>(pData.get())->SetFormat( static_cast<SvxAuthorFormat>(mpImpl->mnInt16) );
         }
 
         break;
@@ -530,23 +530,23 @@ SvxFieldData* SvxUnoTextField::CreateFieldData() const throw()
         SdrMeasureFieldKind eKind = SdrMeasureFieldKind::Value;
         if( mpImpl->mnInt16 == sal_Int16(SdrMeasureFieldKind::Unit) || mpImpl->mnInt16 == sal_Int16(SdrMeasureFieldKind::Rotate90Blanks) )
             eKind = static_cast<SdrMeasureFieldKind>(mpImpl->mnInt16);
-        pData = new SdrMeasureField( eKind);
+        pData.reset( new SdrMeasureField( eKind) );
         break;
     }
     case text::textfield::Type::PRESENTATION_HEADER:
-        pData = new SvxHeaderField();
+        pData.reset( new SvxHeaderField() );
         break;
     case text::textfield::Type::PRESENTATION_FOOTER:
-        pData = new SvxFooterField();
+        pData.reset( new SvxFooterField() );
         break;
     case text::textfield::Type::PRESENTATION_DATE_TIME:
-        pData = new SvxDateTimeField();
+        pData.reset( new SvxDateTimeField() );
         break;
     case text::textfield::Type::PAGE_NAME:
-        pData = new SvxPageTitleField();
+        pData.reset( new SvxPageTitleField() );
         break;
     case text::textfield::Type::DOCINFO_CUSTOM:
-        pData = new editeng::CustomPropertyField(mpImpl->msString1, mpImpl->msString2);
+        pData.reset( new editeng::CustomPropertyField(mpImpl->msString1, mpImpl->msString2) );
         break;
     };
 
@@ -666,11 +666,9 @@ void SAL_CALL SvxUnoTextField::attach( const uno::Reference< text::XTextRange >&
     if(pRange == nullptr)
         throw lang::IllegalArgumentException();
 
-    SvxFieldData* pData = CreateFieldData();
+    std::unique_ptr<SvxFieldData> pData = CreateFieldData();
     if( pData )
-        pRange->attachField( pData );
-
-    delete pData;
+        pRange->attachField( std::move(pData) );
 }
 
 uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextField::getAnchor()
diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx
index 261c8e30490e..22699090a93c 100644
--- a/editeng/source/uno/unotext.cxx
+++ b/editeng/source/uno/unotext.cxx
@@ -279,18 +279,15 @@ void SvxUnoTextRangeBase::SetEditSource( SvxEditSource* pSource ) throw()
 
 /** puts a field item with a copy of the given FieldData into the itemset
     corresponding with this range */
-void SvxUnoTextRangeBase::attachField( const SvxFieldData* pData ) throw()
+void SvxUnoTextRangeBase::attachField( std::unique_ptr<SvxFieldData> pData ) throw()
 {
     SolarMutexGuard aGuard;
 
-    if( pData )
+    SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr;
+    if( pForwarder )
     {
-        SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr;
-        if( pForwarder )
-        {
-            SvxFieldItem aField( *pData, EE_FEATURE_FIELD );
-            pForwarder->QuickInsertField( aField, maSelection );
-        }
+        SvxFieldItem aField( std::move(pData), EE_FEATURE_FIELD );
+        pForwarder->QuickInsertField( std::move(aField), maSelection );
     }
 }
 
diff --git a/include/editeng/CustomPropertyField.hxx b/include/editeng/CustomPropertyField.hxx
index 5ee612cc74a7..43580ac4b178 100644
--- a/include/editeng/CustomPropertyField.hxx
+++ b/include/editeng/CustomPropertyField.hxx
@@ -36,7 +36,7 @@ public:
 
     SV_DECL_PERSIST1(CustomPropertyField, css::text::textfield::Type::DOCINFO_CUSTOM)
 
-    virtual tools::SvRef<SvxFieldData> Clone() const override;
+    virtual std::unique_ptr<SvxFieldData> Clone() const override;
     virtual bool operator==(const SvxFieldData&) const override;
 
     virtual MetaAction* createBeginComment() const override;
diff --git a/include/editeng/flditem.hxx b/include/editeng/flditem.hxx
index 413d59148c2b..065dc60969f2 100644
--- a/include/editeng/flditem.hxx
+++ b/include/editeng/flditem.hxx
@@ -40,19 +40,19 @@ class MetaAction;
 // class SvxFieldItem ---------------------------------------------------
 
 
-class EDITENG_DLLPUBLIC SvxFieldData : public SvPersistBase
+class EDITENG_DLLPUBLIC SvxFieldData
 {
 public:
     static const sal_Int32 UNKNOWN_FIELD;
 
     static SvxFieldData* Create(const css::uno::Reference<css::text::XTextContent>& xContent);
 
-    SV_DECL_PERSIST1( SvxFieldData, css::text::textfield::Type::UNSPECIFIED)
+    virtual sal_Int32  GetClassId() const { return css::text::textfield::Type::UNSPECIFIED; }
 
                             SvxFieldData();
-    virtual                 ~SvxFieldData() override;
+    virtual                 ~SvxFieldData();
 
-    virtual tools::SvRef<SvxFieldData> Clone() const;
+    virtual std::unique_ptr<SvxFieldData> Clone() const;
     virtual bool            operator==( const SvxFieldData& ) const;
 
     virtual MetaAction*     createBeginComment() const;
@@ -66,8 +66,9 @@ public:
  */
 class EDITENG_DLLPUBLIC SvxFieldItem : public SfxPoolItem
 {
-    tools::SvRef<SvxFieldData>      mxField;
+    std::unique_ptr<SvxFieldData>  mpField;
 public:
+            SvxFieldItem( std::unique_ptr<SvxFieldData> pField, const sal_uInt16 nId  );
             SvxFieldItem( const SvxFieldData& rField, const sal_uInt16 nId  );
             SvxFieldItem( const SvxFieldItem& rItem );
             virtual ~SvxFieldItem() override;
@@ -75,7 +76,7 @@ public:
     virtual bool            operator==( const SfxPoolItem& ) const override;
     virtual SfxPoolItem*    Clone( SfxItemPool *pPool = nullptr ) const override;
 
-    const SvxFieldData*     GetField() const    { return mxField.get(); }
+    const SvxFieldData*     GetField() const    { return mpField.get(); }
 };
 
 
@@ -124,7 +125,7 @@ public:
     OUString                GetFormatted( SvNumberFormatter& rFormatter, LanguageType eLanguage ) const;
     static OUString         GetFormatted( Date const & rDate, SvxDateFormat eFormat, SvNumberFormatter& rFormatter, LanguageType eLanguage );
 
-    virtual tools::SvRef<SvxFieldData> Clone() const override;
+    virtual std::unique_ptr<SvxFieldData> Clone() const override;
     virtual bool            operator==( const SvxFieldData& ) const override;
 
     virtual MetaAction* createBeginComment() const override;
@@ -163,7 +164,7 @@ public:
     SvxURLFormat            GetFormat() const { return eFormat; }
     void                    SetFormat( SvxURLFormat eFmt ) { eFormat = eFmt; }
 
-    virtual tools::SvRef<SvxFieldData> Clone() const override;
+    virtual std::unique_ptr<SvxFieldData> Clone() const override;
     virtual bool            operator==( const SvxFieldData& ) const override;
 
     virtual MetaAction* createBeginComment() const override;
@@ -175,7 +176,7 @@ public:
     SV_DECL_PERSIST1( SvxPageField, css::text::textfield::Type::PAGE )
     SvxPageField();
 
-    virtual tools::SvRef<SvxFieldData> Clone() const override;
+    virtual std::unique_ptr<SvxFieldData> Clone() const override;
     virtual bool            operator==( const SvxFieldData& ) const override;
 
     virtual MetaAction* createBeginComment() const override;
@@ -187,7 +188,7 @@ public:
     SV_DECL_PERSIST1( SvxPageTitleField, css::text::textfield::Type::PAGE_NAME )
     SvxPageTitleField();
 
-    virtual tools::SvRef<SvxFieldData> Clone() const override;
+    virtual std::unique_ptr<SvxFieldData> Clone() const override;
     virtual bool            operator==( const SvxFieldData& ) const override;
 
     virtual MetaAction* createBeginComment() const override;
@@ -199,7 +200,7 @@ public:
     SV_DECL_PERSIST1( SvxPagesField, css::text::textfield::Type::PAGES )
     SvxPagesField();
 
-    virtual tools::SvRef<SvxFieldData> Clone() const override;
+    virtual std::unique_ptr<SvxFieldData> Clone() const override;
     virtual bool            operator==( const SvxFieldData& ) const override;
 };
 
@@ -209,7 +210,7 @@ public:
     SV_DECL_PERSIST1( SvxTimeField, css::text::textfield::Type::TIME )
     SvxTimeField();
 
-    virtual tools::SvRef<SvxFieldData> Clone() const override;
+    virtual std::unique_ptr<SvxFieldData> Clone() const override;
     virtual bool            operator==( const SvxFieldData& ) const override;
 
     virtual MetaAction* createBeginComment() const override;
@@ -221,7 +222,7 @@ public:
     SV_DECL_PERSIST1( SvxFileField, css::text::textfield::Type::DOCINFO_TITLE )
     SvxFileField();
 
-    virtual tools::SvRef<SvxFieldData> Clone() const override;
+    virtual std::unique_ptr<SvxFieldData> Clone() const override;
     virtual bool            operator==( const SvxFieldData& ) const override;
 };
 
@@ -236,7 +237,7 @@ public:
     void SetTab(int nTab);
     int GetTab() const { return mnTab;}
 
-    virtual tools::SvRef<SvxFieldData> Clone() const override;
+    virtual std::unique_ptr<SvxFieldData> Clone() const override;
     virtual bool            operator==( const SvxFieldData& ) const override;
 };
 
@@ -288,7 +289,7 @@ public:
     OUString                GetFormatted( SvNumberFormatter& rFormatter, LanguageType eLanguage ) const;
     static OUString         GetFormatted( tools::Time const & rTime, SvxTimeFormat eFormat, SvNumberFormatter& rFormatter, LanguageType eLanguage );
 
-    virtual tools::SvRef<SvxFieldData> Clone() const override;
+    virtual std::unique_ptr<SvxFieldData> Clone() const override;
     virtual bool            operator==( const SvxFieldData& ) const override;
 
     virtual MetaAction* createBeginComment() const override;
@@ -332,7 +333,7 @@ public:
 
     OUString                GetFormatted() const;
 
-    virtual tools::SvRef<SvxFieldData> Clone() const override;
+    virtual std::unique_ptr<SvxFieldData> Clone() const override;
     virtual bool            operator==( const SvxFieldData& ) const override;
 };
 
@@ -373,7 +374,7 @@ public:
 
     OUString                GetFormatted() const;
 
-    virtual tools::SvRef<SvxFieldData> Clone() const override;
+    virtual std::unique_ptr<SvxFieldData> Clone() const override;
     virtual bool            operator==( const SvxFieldData& ) const override;
 };
 
@@ -385,7 +386,7 @@ public:
     SV_DECL_PERSIST1( SvxHeaderField, css::text::textfield::Type::PRESENTATION_HEADER )
     SvxHeaderField();
 
-    virtual tools::SvRef<SvxFieldData> Clone() const override;
+    virtual std::unique_ptr<SvxFieldData> Clone() const override;
     virtual bool            operator==( const SvxFieldData& ) const override;
 };
 
@@ -396,7 +397,7 @@ class EDITENG_DLLPUBLIC SvxFooterField final: public SvxFieldData
 public:
     SV_DECL_PERSIST1( SvxFooterField, css::text::textfield::Type::PRESENTATION_FOOTER )
     SvxFooterField();
-    virtual tools::SvRef<SvxFieldData> Clone() const override;
+    virtual std::unique_ptr<SvxFieldData> Clone() const override;
     virtual bool            operator==( const SvxFieldData& ) const override;
 };
 
@@ -412,7 +413,7 @@ public:
                                      SvxDateFormat eDateFormat, SvxTimeFormat eTimeFormat,
                                      SvNumberFormatter& rFormatter, LanguageType eLanguage );
 
-    virtual tools::SvRef<SvxFieldData> Clone() const override;
+    virtual std::unique_ptr<SvxFieldData> Clone() const override;
     virtual bool            operator==( const SvxFieldData& ) const override;
 };
 
diff --git a/include/editeng/measfld.hxx b/include/editeng/measfld.hxx
index 40715662566f..50bf3cc3e8df 100644
--- a/include/editeng/measfld.hxx
+++ b/include/editeng/measfld.hxx
@@ -35,7 +35,7 @@ public:
     SV_DECL_PERSIST1(SdrMeasureField, css::text::textfield::Type::MEASURE)
     SdrMeasureField(SdrMeasureFieldKind eNewKind): eMeasureFieldKind(eNewKind) {}
     virtual ~SdrMeasureField() override;
-    virtual tools::SvRef<SvxFieldData> Clone() const override;
+    virtual std::unique_ptr<SvxFieldData> Clone() const override;
     virtual bool operator==(const SvxFieldData&) const override;
     SdrMeasureFieldKind GetMeasureFieldKind() const { return eMeasureFieldKind; }
 };
diff --git a/include/editeng/unofield.hxx b/include/editeng/unofield.hxx
index 604024ef8f7c..ea3afb36517e 100644
--- a/include/editeng/unofield.hxx
+++ b/include/editeng/unofield.hxx
@@ -60,7 +60,7 @@ public:
     virtual ~SvxUnoTextField() throw() override;
 
     // Internal
-    SvxFieldData* CreateFieldData() const throw();
+    std::unique_ptr<SvxFieldData> CreateFieldData() const throw();
 
     static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId() throw();
     virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
diff --git a/include/editeng/unotext.hxx b/include/editeng/unotext.hxx
index 07b1171e59f9..0b4a2bf445f9 100644
--- a/include/editeng/unotext.hxx
+++ b/include/editeng/unotext.hxx
@@ -333,7 +333,7 @@ public:
     /// @throws css::uno::RuntimeException
     static bool GetPropertyValueHelper(  SfxItemSet const & rSet, const SfxItemPropertySimpleEntry* pMap, css::uno::Any& aAny, const ESelection* pSelection = nullptr,  SvxEditSource* pEditSource = nullptr  );
 
-    void attachField( const SvxFieldData* pData ) throw();
+    void attachField( std::unique_ptr<SvxFieldData> pData ) throw();
 
     UNO3_GETIMPLEMENTATION_DECL( SvxUnoTextRangeBase )
 
diff --git a/include/svx/ClassificationField.hxx b/include/svx/ClassificationField.hxx
index b8e6ff71d382..79e30cff094a 100644
--- a/include/svx/ClassificationField.hxx
+++ b/include/svx/ClassificationField.hxx
@@ -14,6 +14,7 @@
 #include <sal/config.h>
 #include <svx/svxdllapi.h>
 #include <editeng/flditem.hxx>
+#include <o3tl/make_unique.hxx>
 
 namespace svx {
 
@@ -74,9 +75,9 @@ public:
         , msIdentifier(sIdentifier)
     {}
 
-    tools::SvRef<SvxFieldData> Clone() const override
+    std::unique_ptr<SvxFieldData> Clone() const override
     {
-        return new ClassificationField(meType, msDescription, msFullClassName, msIdentifier);
+        return o3tl::make_unique<ClassificationField>(meType, msDescription, msFullClassName, msIdentifier);
     }
 
     bool operator==(const SvxFieldData& rOther) const override
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index c279deb63993..32a0cb1e6392 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -110,7 +110,7 @@ using namespace xmloff::token;
 ScXMLTableRowCellContext::ParaFormat::ParaFormat(ScEditEngineDefaulter& rEditEngine) :
     maItemSet(rEditEngine.GetEmptyItemSet()) {}
 
-ScXMLTableRowCellContext::Field::Field(SvxFieldData* pData) : mpData(pData) {}
+ScXMLTableRowCellContext::Field::Field(std::unique_ptr<SvxFieldData> pData) : mpData(std::move(pData)) {}
 
 ScXMLTableRowCellContext::Field::~Field()
 {
@@ -325,10 +325,10 @@ void ScXMLTableRowCellContext::PushParagraphSpan(const OUString& rSpan, const OU
     PushFormat(nBegin, nEnd, rStyleName);
 }
 
-void ScXMLTableRowCellContext::PushParagraphField(SvxFieldData* pData, const OUString& rStyleName)
+void ScXMLTableRowCellContext::PushParagraphField(std::unique_ptr<SvxFieldData> pData, const OUString& rStyleName)
 {
     mbHasFormatRuns = true;
-    maFields.push_back(o3tl::make_unique<Field>(pData));
+    maFields.push_back(o3tl::make_unique<Field>(std::move(pData)));
     Field& rField = *maFields.back().get();
 
     sal_Int32 nPos = maParagraph.getLength();
@@ -583,27 +583,27 @@ OUString ScXMLTableRowCellContext::GetFirstParagraph() const
 
 void ScXMLTableRowCellContext::PushParagraphFieldDate(const OUString& rStyleName)
 {
-    PushParagraphField(new SvxDateField, rStyleName);
+    PushParagraphField(o3tl::make_unique<SvxDateField>(), rStyleName);
 }
 
 void ScXMLTableRowCellContext::PushParagraphFieldSheetName(const OUString& rStyleName)
 {
     SCTAB nTab = GetScImport().GetTables().GetCurrentCellPos().Tab();
-    PushParagraphField(new SvxTableField(nTab), rStyleName);
+    PushParagraphField(o3tl::make_unique<SvxTableField>(nTab), rStyleName);
 }
 
 void ScXMLTableRowCellContext::PushParagraphFieldDocTitle(const OUString& rStyleName)
 {
-    PushParagraphField(new SvxFileField, rStyleName);
+    PushParagraphField(o3tl::make_unique<SvxFileField>(), rStyleName);
 }
 
 void ScXMLTableRowCellContext::PushParagraphFieldURL(
     const OUString& rURL, const OUString& rRep, const OUString& rStyleName, const OUString& rTargetFrame)
 {
     OUString aAbsURL = GetScImport().GetAbsoluteReference(rURL);
-    SvxURLField* pURLField = new SvxURLField(aAbsURL, rRep, SvxURLFormat::Repr);
+    std::unique_ptr<SvxURLField> pURLField(new SvxURLField(aAbsURL, rRep, SvxURLFormat::Repr));
     pURLField->SetTargetFrame(rTargetFrame);
-    PushParagraphField(pURLField, rStyleName);
+    PushParagraphField(std::move(pURLField), rStyleName);
 }
 
 void ScXMLTableRowCellContext::PushParagraphEnd()
diff --git a/sc/source/filter/xml/xmlcelli.hxx b/sc/source/filter/xml/xmlcelli.hxx
index 0e567e051910..00f4122cdf3a 100644
--- a/sc/source/filter/xml/xmlcelli.hxx
+++ b/sc/source/filter/xml/xmlcelli.hxx
@@ -48,13 +48,13 @@ class ScXMLTableRowCellContext : public ScXMLImportContext
 
     struct Field
     {
-        tools::SvRef<SvxFieldData> mpData;
+        std::unique_ptr<SvxFieldData> mpData;
         ESelection maSelection;
 
         Field(const Field&) = delete;
         const Field& operator=(const Field&) = delete;
 
-        explicit Field(SvxFieldData* pData);
+        explicit Field(std::unique_ptr<SvxFieldData> pData);
         ~Field();
     };
 
@@ -121,7 +121,7 @@ class ScXMLTableRowCellContext : public ScXMLImportContext
 
     bool IsPossibleErrorString() const;
 
-    void PushParagraphField(SvxFieldData* pData, const OUString& rStyleName);
+    void PushParagraphField(std::unique_ptr<SvxFieldData> pData, const OUString& rStyleName);
 
     void PushFormat(sal_Int32 nBegin, sal_Int32 nEnd, const OUString& rStyleName);
 
diff --git a/sc/source/ui/unoobj/fielduno.cxx b/sc/source/ui/unoobj/fielduno.cxx
index 77856751701d..c75f351b9641 100644
--- a/sc/source/ui/unoobj/fielduno.cxx
+++ b/sc/source/ui/unoobj/fielduno.cxx
@@ -167,7 +167,7 @@ class ScUnoEditEngine : public ScEditEngineDefaulter
     ScUnoCollectMode    eMode;
     sal_uInt16          nFieldCount;
     sal_Int32           mnFieldType;
-    tools::SvRef<SvxFieldData>
+    std::unique_ptr<SvxFieldData>
                         pFound;         // local copy
     sal_Int32           nFieldPar;
     sal_Int32           nFieldPos;


More information about the Libreoffice-commits mailing list