[Libreoffice-commits] core.git: 2 commits - editeng/source idl/inc include/editeng include/tools solenv/clang-format svx/source sw/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Jul 16 06:39:21 UTC 2018


 editeng/source/items/CustomPropertyField.cxx      |    2 
 editeng/source/items/flditem.cxx                  |   33 -------
 editeng/source/items/svdfield.cxx                 |    2 
 idl/inc/basobj.hxx                                |    1 
 idl/inc/database.hxx                              |    1 
 idl/inc/types.hxx                                 |    1 
 include/editeng/CustomPropertyField.hxx           |    2 
 include/editeng/flditem.hxx                       |   45 ++++++---
 include/editeng/measfld.hxx                       |    2 
 include/tools/pstm.hxx                            |   44 ---------
 solenv/clang-format/blacklist                     |    1 
 svx/source/sdr/primitive2d/sdrtextprimitive2d.cxx |   12 +-
 svx/source/svdraw/svdotext.cxx                    |   17 ---
 sw/source/core/inc/rolbck.hxx                     |   11 +-
 sw/source/core/undo/rolbck.cxx                    |  102 +++++++++-------------
 15 files changed, 94 insertions(+), 182 deletions(-)

New commits:
commit 99876774fbcd5409ca6a6a15c44ecd39a117236f
Author:     Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Sat Jul 14 16:46:20 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Mon Jul 16 08:39:11 2018 +0200

    SvPersistBase no longer necessary
    
    Change-Id: I928c0898d77d30bd6ca755d07acac6f78b20563b
    Reviewed-on: https://gerrit.libreoffice.org/57436
    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 3fbe5a89fe89..d46b47af52ae 100644
--- a/editeng/source/items/CustomPropertyField.cxx
+++ b/editeng/source/items/CustomPropertyField.cxx
@@ -28,8 +28,6 @@ CustomPropertyField::CustomPropertyField(OUString const & rName, OUString const
 CustomPropertyField::~CustomPropertyField()
 {}
 
-SV_IMPL_PERSIST1(CustomPropertyField);
-
 std::unique_ptr<SvxFieldData> CustomPropertyField::Clone() const
 {
     return o3tl::make_unique<CustomPropertyField>(msName, msCurrentPresentation);
diff --git a/editeng/source/items/flditem.cxx b/editeng/source/items/flditem.cxx
index 722d54a710db..3365761cd1d6 100644
--- a/editeng/source/items/flditem.cxx
+++ b/editeng/source/items/flditem.cxx
@@ -322,9 +322,6 @@ bool SvxFieldItem::operator==( const SfxPoolItem& rItem ) const
 // The following are the derivatives of SvxFieldData ...
 
 
-SV_IMPL_PERSIST1( SvxDateField );
-
-
 SvxDateField::SvxDateField()
 {
     nFixDate = Date( Date::SYSTEM ).GetDate();
@@ -436,9 +433,6 @@ MetaAction* SvxDateField::createBeginComment() const
     return new MetaCommentAction( "FIELD_SEQ_BEGIN" );
 }
 
-SV_IMPL_PERSIST1( SvxURLField );
-
-
 SvxURLField::SvxURLField()
 {
     eFormat = SvxURLFormat::Url;
@@ -484,8 +478,6 @@ MetaAction* SvxURLField::createBeginComment() const
 // SvxPageTitleField methods
 //
 
-SV_IMPL_PERSIST1( SvxPageTitleField );
-
 SvxPageTitleField::SvxPageTitleField() {}
 
 std::unique_ptr<SvxFieldData> SvxPageTitleField::Clone() const
@@ -509,8 +501,6 @@ MetaAction* SvxPageTitleField::createBeginComment() const
 // The fields that were removed from Calc:
 
 
-SV_IMPL_PERSIST1( SvxPageField );
-
 SvxPageField::SvxPageField() {}
 
 std::unique_ptr<SvxFieldData> SvxPageField::Clone() const
@@ -529,8 +519,6 @@ MetaAction* SvxPageField::createBeginComment() const
 }
 
 
-SV_IMPL_PERSIST1( SvxPagesField );
-
 SvxPagesField::SvxPagesField() {}
 
 std::unique_ptr<SvxFieldData> SvxPagesField::Clone() const
@@ -543,8 +531,6 @@ bool SvxPagesField::operator==( const SvxFieldData& rCmp ) const
     return ( dynamic_cast< const SvxPagesField *>(&rCmp) != nullptr);
 }
 
-SV_IMPL_PERSIST1( SvxTimeField );
-
 SvxTimeField::SvxTimeField() {}
 
 std::unique_ptr<SvxFieldData> SvxTimeField::Clone() const
@@ -562,8 +548,6 @@ MetaAction* SvxTimeField::createBeginComment() const
     return new MetaCommentAction( "FIELD_SEQ_BEGIN" );
 }
 
-SV_IMPL_PERSIST1( SvxFileField );
-
 SvxFileField::SvxFileField() {}
 
 std::unique_ptr<SvxFieldData> SvxFileField::Clone() const
@@ -576,8 +560,6 @@ bool SvxFileField::operator==( const SvxFieldData& rCmp ) const
     return ( dynamic_cast< const SvxFileField *>(&rCmp) != nullptr );
 }
 
-SV_IMPL_PERSIST1( SvxTableField );
-
 SvxTableField::SvxTableField() : mnTab(0) {}
 
 SvxTableField::SvxTableField(int nTab) : mnTab(nTab) {}
@@ -604,9 +586,6 @@ bool SvxTableField::operator==( const SvxFieldData& rCmp ) const
 //      SvxExtTimeField
 
 
-SV_IMPL_PERSIST1( SvxExtTimeField );
-
-
 SvxExtTimeField::SvxExtTimeField()
     : m_nFixTime( tools::Time(tools::Time::SYSTEM).GetTime() )
 {
@@ -721,9 +700,6 @@ MetaAction* SvxExtTimeField::createBeginComment() const
 //      SvxExtFileField
 
 
-SV_IMPL_PERSIST1( SvxExtFileField );
-
-
 SvxExtFileField::SvxExtFileField()
 {
     eType = SvxFileType::Var;
@@ -836,9 +812,6 @@ OUString SvxExtFileField::GetFormatted() const
 //      SvxAuthorField
 
 
-SV_IMPL_PERSIST1( SvxAuthorField );
-
-
 SvxAuthorField::SvxAuthorField( const OUString& rFirstName,
                                 const OUString& rLastName,
                                 const OUString& rShortName,
@@ -897,8 +870,6 @@ OUString SvxAuthorField::GetFormatted() const
     return aString;
 }
 
-SV_IMPL_PERSIST1( SvxHeaderField );
-
 SvxHeaderField::SvxHeaderField() {}
 
 std::unique_ptr<SvxFieldData> SvxHeaderField::Clone() const
@@ -911,8 +882,6 @@ bool SvxHeaderField::operator==( const SvxFieldData& rCmp ) const
     return ( dynamic_cast< const SvxHeaderField *>(&rCmp) != nullptr );
 }
 
-SV_IMPL_PERSIST1( SvxFooterField );
-
 SvxFooterField::SvxFooterField() {}
 
 std::unique_ptr<SvxFieldData> SvxFooterField::Clone() const
@@ -925,8 +894,6 @@ bool SvxFooterField::operator==( const SvxFieldData& rCmp ) const
     return ( dynamic_cast< const SvxFooterField *>(&rCmp) != nullptr );
 }
 
-SV_IMPL_PERSIST1( SvxDateTimeField );
-
 std::unique_ptr<SvxFieldData> SvxDateTimeField::Clone() const
 {
     return o3tl::make_unique<SvxDateTimeField>();        // empty
diff --git a/editeng/source/items/svdfield.cxx b/editeng/source/items/svdfield.cxx
index ac3c0900de37..4050871d515f 100644
--- a/editeng/source/items/svdfield.cxx
+++ b/editeng/source/items/svdfield.cxx
@@ -21,8 +21,6 @@
 #include <editeng/measfld.hxx>
 #include <o3tl/make_unique.hxx>
 
-SV_IMPL_PERSIST1(SdrMeasureField);
-
 SdrMeasureField::~SdrMeasureField()
 {
 }
diff --git a/idl/inc/basobj.hxx b/idl/inc/basobj.hxx
index f74b9230fb8a..d3ea84fdc7a9 100644
--- a/idl/inc/basobj.hxx
+++ b/idl/inc/basobj.hxx
@@ -22,7 +22,6 @@
 
 #include <tools/ref.hxx>
 #include "bastype.hxx"
-#include <tools/pstm.hxx>
 #include <functional>
 #include <vector>
 
diff --git a/idl/inc/database.hxx b/idl/inc/database.hxx
index 6b3904b55c1a..86e45c0dc844 100644
--- a/idl/inc/database.hxx
+++ b/idl/inc/database.hxx
@@ -24,7 +24,6 @@
 #include "hash.hxx"
 #include "lex.hxx"
 #include <rtl/string.hxx>
-#include <tools/pstm.hxx>
 
 #include <rtl/ustring.hxx>
 #include <set>
diff --git a/idl/inc/types.hxx b/idl/inc/types.hxx
index e946ed35436b..a0f796fc66f9 100644
--- a/idl/inc/types.hxx
+++ b/idl/inc/types.hxx
@@ -21,6 +21,7 @@
 #define INCLUDED_IDL_INC_TYPES_HXX
 
 #include <rtl/strbuf.hxx>
+#include <tools/solar.h>
 #include <tools/ref.hxx>
 #include "basobj.hxx"
 
diff --git a/include/editeng/CustomPropertyField.hxx b/include/editeng/CustomPropertyField.hxx
index 43580ac4b178..fbfc0410f727 100644
--- a/include/editeng/CustomPropertyField.hxx
+++ b/include/editeng/CustomPropertyField.hxx
@@ -34,7 +34,7 @@ public:
 
     virtual ~CustomPropertyField() override;
 
-    SV_DECL_PERSIST1(CustomPropertyField, css::text::textfield::Type::DOCINFO_CUSTOM)
+    virtual sal_Int32  GetClassId() const override { return css::text::textfield::Type::DOCINFO_CUSTOM; }
 
     virtual std::unique_ptr<SvxFieldData> Clone() const override;
     virtual bool operator==(const SvxFieldData&) const override;
diff --git a/include/editeng/flditem.hxx b/include/editeng/flditem.hxx
index 065dc60969f2..9ed775c01c1c 100644
--- a/include/editeng/flditem.hxx
+++ b/include/editeng/flditem.hxx
@@ -23,7 +23,6 @@
 #include <tools/time.hxx>
 #include <tools/date.hxx>
 #include <svl/poolitem.hxx>
-#include <tools/pstm.hxx>
 #include <editeng/editengdllapi.h>
 
 #include <com/sun/star/text/textfield/Type.hpp>
@@ -47,7 +46,8 @@ public:
 
     static SvxFieldData* Create(const css::uno::Reference<css::text::XTextContent>& xContent);
 
-    virtual sal_Int32  GetClassId() const { return css::text::textfield::Type::UNSPECIFIED; }
+    static constexpr auto CLASS_ID = css::text::textfield::Type::UNSPECIFIED;
+    virtual sal_Int32  GetClassId() const { return CLASS_ID; }
 
                             SvxFieldData();
     virtual                 ~SvxFieldData();
@@ -104,7 +104,8 @@ class EDITENG_DLLPUBLIC SvxDateField : public SvxFieldData
     SvxDateFormat           eFormat;
 
 public:
-    SV_DECL_PERSIST1( SvxDateField, css::text::textfield::Type::DATE )
+    static constexpr auto CLASS_ID = css::text::textfield::Type::DATE;
+    virtual sal_Int32  GetClassId() const override { return CLASS_ID; }
 
                             SvxDateField();
     explicit                SvxDateField( const Date& rDate,
@@ -147,7 +148,8 @@ private:
     OUString                aTargetFrame;       // In what Frame
 
 public:
-    SV_DECL_PERSIST1( SvxURLField, css::text::textfield::Type::URL )
+    static constexpr auto CLASS_ID = css::text::textfield::Type::URL;
+    virtual sal_Int32  GetClassId() const override { return CLASS_ID; }
 
                             SvxURLField();
                             SvxURLField( const OUString& rURL, const OUString& rRepres, SvxURLFormat eFmt = SvxURLFormat::Url );
@@ -173,7 +175,7 @@ public:
 class EDITENG_DLLPUBLIC SvxPageField final: public SvxFieldData
 {
 public:
-    SV_DECL_PERSIST1( SvxPageField, css::text::textfield::Type::PAGE )
+    virtual sal_Int32  GetClassId() const override { return css::text::textfield::Type::PAGE; }
     SvxPageField();
 
     virtual std::unique_ptr<SvxFieldData> Clone() const override;
@@ -185,7 +187,8 @@ public:
 class EDITENG_DLLPUBLIC SvxPageTitleField final: public SvxFieldData
 {
 public:
-    SV_DECL_PERSIST1( SvxPageTitleField, css::text::textfield::Type::PAGE_NAME )
+    static constexpr auto CLASS_ID = css::text::textfield::Type::PAGE_NAME;
+    virtual sal_Int32  GetClassId() const override { return CLASS_ID; }
     SvxPageTitleField();
 
     virtual std::unique_ptr<SvxFieldData> Clone() const override;
@@ -197,7 +200,8 @@ public:
 class EDITENG_DLLPUBLIC SvxPagesField final: public SvxFieldData
 {
 public:
-    SV_DECL_PERSIST1( SvxPagesField, css::text::textfield::Type::PAGES )
+    static constexpr auto CLASS_ID = css::text::textfield::Type::PAGES;
+    virtual sal_Int32  GetClassId() const override { return CLASS_ID; }
     SvxPagesField();
 
     virtual std::unique_ptr<SvxFieldData> Clone() const override;
@@ -207,7 +211,8 @@ public:
 class EDITENG_DLLPUBLIC SvxTimeField final: public SvxFieldData
 {
 public:
-    SV_DECL_PERSIST1( SvxTimeField, css::text::textfield::Type::TIME )
+    static constexpr auto CLASS_ID = css::text::textfield::Type::TIME;
+    virtual sal_Int32  GetClassId() const override { return CLASS_ID; }
     SvxTimeField();
 
     virtual std::unique_ptr<SvxFieldData> Clone() const override;
@@ -219,7 +224,8 @@ public:
 class EDITENG_DLLPUBLIC SvxFileField final: public SvxFieldData
 {
 public:
-    SV_DECL_PERSIST1( SvxFileField, css::text::textfield::Type::DOCINFO_TITLE )
+    static constexpr auto CLASS_ID = css::text::textfield::Type::DOCINFO_TITLE;
+    virtual sal_Int32  GetClassId() const override { return CLASS_ID; }
     SvxFileField();
 
     virtual std::unique_ptr<SvxFieldData> Clone() const override;
@@ -230,7 +236,8 @@ class EDITENG_DLLPUBLIC SvxTableField final: public SvxFieldData
 {
     int mnTab;
 public:
-    SV_DECL_PERSIST1( SvxTableField, css::text::textfield::Type::TABLE )
+    static constexpr auto CLASS_ID = css::text::textfield::Type::TABLE;
+    virtual sal_Int32  GetClassId() const override { return CLASS_ID; }
     SvxTableField();
     explicit SvxTableField(int nTab);
 
@@ -269,7 +276,8 @@ private:
     SvxTimeFormat           eFormat;
 
 public:
-    SV_DECL_PERSIST1( SvxExtTimeField, css::text::textfield::Type::EXTENDED_TIME )
+    static constexpr auto CLASS_ID = css::text::textfield::Type::EXTENDED_TIME;
+    virtual sal_Int32  GetClassId() const override { return CLASS_ID; }
                             SvxExtTimeField();
     explicit                SvxExtTimeField( const tools::Time& rTime,
                                 SvxTimeType eType,
@@ -316,7 +324,8 @@ private:
     SvxFileFormat           eFormat;
 
 public:
-    SV_DECL_PERSIST1( SvxExtFileField, css::text::textfield::Type::EXTENDED_FILE )
+    static constexpr auto CLASS_ID = css::text::textfield::Type::EXTENDED_FILE;
+    virtual sal_Int32  GetClassId() const override { return CLASS_ID; }
                             SvxExtFileField();
     explicit                SvxExtFileField( const OUString& rString,
                                 SvxFileType eType = SvxFileType::Var,
@@ -358,7 +367,8 @@ private:
     SvxAuthorFormat eFormat;
 
 public:
-    SV_DECL_PERSIST1( SvxAuthorField, css::text::textfield::Type::AUTHOR )
+    static constexpr auto CLASS_ID = css::text::textfield::Type::AUTHOR;
+    virtual sal_Int32  GetClassId() const override { return CLASS_ID; }
                             SvxAuthorField(
                                 const OUString& rFirstName,
                                 const OUString& rLastName,
@@ -383,7 +393,8 @@ public:
 class EDITENG_DLLPUBLIC SvxHeaderField final: public SvxFieldData
 {
 public:
-    SV_DECL_PERSIST1( SvxHeaderField, css::text::textfield::Type::PRESENTATION_HEADER )
+    static constexpr auto CLASS_ID = css::text::textfield::Type::PRESENTATION_HEADER;
+    virtual sal_Int32  GetClassId() const override { return CLASS_ID; }
     SvxHeaderField();
 
     virtual std::unique_ptr<SvxFieldData> Clone() const override;
@@ -395,7 +406,8 @@ public:
 class EDITENG_DLLPUBLIC SvxFooterField final: public SvxFieldData
 {
 public:
-    SV_DECL_PERSIST1( SvxFooterField, css::text::textfield::Type::PRESENTATION_FOOTER )
+    static constexpr auto CLASS_ID = css::text::textfield::Type::PRESENTATION_FOOTER;
+    virtual sal_Int32  GetClassId() const override { return CLASS_ID; }
     SvxFooterField();
     virtual std::unique_ptr<SvxFieldData> Clone() const override;
     virtual bool            operator==( const SvxFieldData& ) const override;
@@ -406,7 +418,8 @@ public:
 class EDITENG_DLLPUBLIC SvxDateTimeField final: public SvxFieldData
 {
 public:
-    SV_DECL_PERSIST1( SvxDateTimeField, css::text::textfield::Type::PRESENTATION_DATE_TIME )
+    static constexpr auto CLASS_ID = css::text::textfield::Type::PRESENTATION_DATE_TIME;
+    virtual sal_Int32  GetClassId() const override { return CLASS_ID; }
     SvxDateTimeField();
 
     static OUString    GetFormatted( Date const & rDate, tools::Time const & rTime,
diff --git a/include/editeng/measfld.hxx b/include/editeng/measfld.hxx
index 50bf3cc3e8df..2422ed9a8462 100644
--- a/include/editeng/measfld.hxx
+++ b/include/editeng/measfld.hxx
@@ -32,7 +32,7 @@ enum class SdrMeasureFieldKind { Value, Unit, Rotate90Blanks };
 class EDITENG_DLLPUBLIC SdrMeasureField: public SvxFieldData {
     SdrMeasureFieldKind eMeasureFieldKind;
 public:
-    SV_DECL_PERSIST1(SdrMeasureField, css::text::textfield::Type::MEASURE)
+    virtual sal_Int32  GetClassId() const override { return css::text::textfield::Type::MEASURE; }
     SdrMeasureField(SdrMeasureFieldKind eNewKind): eMeasureFieldKind(eNewKind) {}
     virtual ~SdrMeasureField() override;
     virtual std::unique_ptr<SvxFieldData> Clone() const override;
diff --git a/include/tools/pstm.hxx b/include/tools/pstm.hxx
deleted file mode 100644
index 062025891826..000000000000
--- a/include/tools/pstm.hxx
+++ /dev/null
@@ -1,44 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-#ifndef INCLUDED_TOOLS_PSTM_HXX
-#define INCLUDED_TOOLS_PSTM_HXX
-
-#include <tools/toolsdllapi.h>
-#include <tools/ref.hxx>
-#include <tools/stream.hxx>
-#include <map>
-#include <unordered_map>
-
-#define SV_DECL_PERSIST1( Class, CLASS_ID )                 \
-    static  sal_Int32  StaticClassId() { return CLASS_ID; }         \
-    virtual sal_Int32  GetClassId() const override;              \
-
-#define SV_IMPL_PERSIST1( Class )                           \
-    sal_Int32       Class::GetClassId() const                       \
-                    { return StaticClassId(); }                     \
-
-class SvPersistBase : public SvRefBase
-{
-public:
-    virtual sal_Int32  GetClassId() const = 0;
-};
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/solenv/clang-format/blacklist b/solenv/clang-format/blacklist
index 05ef966593b9..6f7e23976278 100644
--- a/solenv/clang-format/blacklist
+++ b/solenv/clang-format/blacklist
@@ -7776,7 +7776,6 @@ include/tools/mempool.hxx
 include/tools/multisel.hxx
 include/tools/pathutils.hxx
 include/tools/poly.hxx
-include/tools/pstm.hxx
 include/tools/ref.hxx
 include/tools/resary.hxx
 include/tools/solar.h
diff --git a/svx/source/sdr/primitive2d/sdrtextprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrtextprimitive2d.cxx
index e3d7aba47366..334f390756d7 100644
--- a/svx/source/sdr/primitive2d/sdrtextprimitive2d.cxx
+++ b/svx/source/sdr/primitive2d/sdrtextprimitive2d.cxx
@@ -111,12 +111,12 @@ namespace drawinglayer
         {
             const EditTextObject& rETO = maOutlinerParaObject.GetTextObject();
 
-            mbContainsPageField = rETO.HasField(SvxPageField::StaticClassId());
-            mbContainsPageCountField = rETO.HasField(SvxPagesField::StaticClassId());
-            mbContainsOtherFields = rETO.HasField(SvxHeaderField::StaticClassId())
-                || rETO.HasField(SvxFooterField::StaticClassId())
-                || rETO.HasField(SvxDateTimeField::StaticClassId())
-                || rETO.HasField(SvxAuthorField::StaticClassId());
+            mbContainsPageField = rETO.HasField(SvxPageField::CLASS_ID);
+            mbContainsPageCountField = rETO.HasField(SvxPagesField::CLASS_ID);
+            mbContainsOtherFields = rETO.HasField(SvxHeaderField::CLASS_ID)
+                || rETO.HasField(SvxFooterField::CLASS_ID)
+                || rETO.HasField(SvxDateTimeField::CLASS_ID)
+                || rETO.HasField(SvxAuthorField::CLASS_ID);
         }
 
         const SdrText* SdrTextPrimitive2D::getSdrText() const { return mrSdrText.get(); }
diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
index 167b8e50825e..d40dadb35131 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -1140,19 +1140,10 @@ void SdrTextObj::ImpCheckMasterCachable()
     if(!bNotVisibleAsMaster && pOutlinerParaObject && pOutlinerParaObject->IsEditDoc() )
     {
         const EditTextObject& rText= pOutlinerParaObject->GetTextObject();
-        bNotMasterCachable=rText.HasField(SvxPageField::StaticClassId());
-        if( !bNotMasterCachable )
-        {
-            bNotMasterCachable=rText.HasField(SvxHeaderField::StaticClassId());
-            if( !bNotMasterCachable )
-            {
-                bNotMasterCachable=rText.HasField(SvxFooterField::StaticClassId());
-                if( !bNotMasterCachable )
-                {
-                    bNotMasterCachable=rText.HasField(SvxDateTimeField::StaticClassId());
-                }
-            }
-        }
+        bNotMasterCachable = rText.HasField(SvxPageField::CLASS_ID)
+            || rText.HasField(SvxHeaderField::CLASS_ID)
+            || rText.HasField(SvxFooterField::CLASS_ID)
+            || rText.HasField(SvxDateTimeField::CLASS_ID);
     }
 }
 
commit 9df9e5b0a92caeda305c53214632a3ba42f02b2d
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Fri Jul 13 11:53:26 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Mon Jul 16 08:38:58 2018 +0200

    loplugin:useuniqueptr in SwHistory
    
    Change-Id: Ie36cdf1e7b3d09ae27cb2a5b51f8a644693fe2b3
    Reviewed-on: https://gerrit.libreoffice.org/57424
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sw/source/core/inc/rolbck.hxx b/sw/source/core/inc/rolbck.hxx
index 60edcb313033..5163fd59ca0e 100644
--- a/sw/source/core/inc/rolbck.hxx
+++ b/sw/source/core/inc/rolbck.hxx
@@ -311,7 +311,7 @@ class SwHistory
     friend class SwDoc;         // actually only SwDoc::DelUndoObj may access
     friend class SwRegHistory;  // for inserting History attributes
 
-    std::vector<SwHistoryHint*> m_SwpHstry;
+    std::vector<std::unique_ptr<SwHistoryHint>> m_SwpHstry;
     sal_uInt16 m_nEndDiff;
 
 public:
@@ -338,9 +338,9 @@ public:
     sal_uInt16 Count() const { return m_SwpHstry.size(); }
     sal_uInt16 GetTmpEnd() const { return m_SwpHstry.size() - m_nEndDiff; }
     sal_uInt16 SetTmpEnd( sal_uInt16 nTmpEnd );        // return previous value
-    SwHistoryHint      * operator[]( sal_uInt16 nPos ) { return m_SwpHstry[nPos]; }
+    SwHistoryHint      * operator[]( sal_uInt16 nPos ) { return m_SwpHstry[nPos].get(); }
     SwHistoryHint const* operator[]( sal_uInt16 nPos ) const
-        { return m_SwpHstry[nPos]; }
+        { return m_SwpHstry[nPos].get(); }
 
     // for SwUndoDelete::Undo/Redo
     void Move( sal_uInt16 nPos, SwHistory *pIns,
@@ -348,8 +348,9 @@ public:
     {
         auto itSourceBegin = pIns->m_SwpHstry.begin() + nStart;
         auto itSourceEnd = pIns->m_SwpHstry.end();
-        if (itSourceBegin == itSourceEnd) return;
-        m_SwpHstry.insert(m_SwpHstry.begin() + nPos, itSourceBegin, itSourceEnd);
+        if (itSourceBegin == itSourceEnd)
+            return;
+        m_SwpHstry.insert(m_SwpHstry.begin() + nPos, std::make_move_iterator(itSourceBegin), std::make_move_iterator(itSourceEnd));
         pIns->m_SwpHstry.erase( itSourceBegin, itSourceEnd );
     }
 
diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx
index 4d1b3889c21e..9de53a698523 100644
--- a/sw/source/core/undo/rolbck.cxx
+++ b/sw/source/core/undo/rolbck.cxx
@@ -879,10 +879,6 @@ SwHistory::SwHistory()
 
 SwHistory::~SwHistory()
 {
-    Delete();
-    std::vector<SwHistoryHint*>::const_iterator it;
-    for(it = m_SwpHstry.begin(); it != m_SwpHstry.end(); ++it)
-        delete *it;
 }
 
 void SwHistory::Add(
@@ -900,7 +896,7 @@ void SwHistory::Add(
     }
 
     // no default Attribute?
-    SwHistoryHint* pHt = nullptr;
+    std::unique_ptr<SwHistoryHint> pHt;
 
     // To be able to include the DrawingLayer FillItems something more
     // general has to be done to check if an Item is default than to check
@@ -911,14 +907,14 @@ void SwHistory::Add(
     // global tooling aka IsDefaultItem(const SfxPoolItem*) for now
     if(pOldValue && !IsDefaultItem(pOldValue))
     {
-        pHt = new SwHistorySetFormat( pOldValue, nNodeIdx );
+        pHt.reset( new SwHistorySetFormat( pOldValue, nNodeIdx ) );
     }
     else
     {
-        pHt = new SwHistoryResetFormat( pNewValue, nNodeIdx );
+        pHt.reset( new SwHistoryResetFormat( pNewValue, nNodeIdx ) );
     }
 
-    m_SwpHstry.push_back( pHt );
+    m_SwpHstry.push_back( std::move(pHt) );
 }
 
 // FIXME: refactor the following "Add" methods (DRY)?
@@ -926,65 +922,65 @@ void SwHistory::Add( SwTextAttr* pHint, sal_uLong nNodeIdx, bool bNewAttr )
 {
     OSL_ENSURE( !m_nEndDiff, "History was not deleted after REDO" );
 
-    SwHistoryHint * pHt = nullptr;
+    std::unique_ptr<SwHistoryHint> pHt;
     if( !bNewAttr )
     {
         switch ( pHint->Which() )
         {
             case RES_TXTATR_FTN:
-                pHt = new SwHistorySetFootnote(
-                            static_cast<SwTextFootnote*>(pHint), nNodeIdx );
+                pHt.reset( new SwHistorySetFootnote(
+                            static_cast<SwTextFootnote*>(pHint), nNodeIdx ) );
                 break;
             case RES_TXTATR_FLYCNT:
-                pHt = new SwHistoryTextFlyCnt( static_cast<SwTextFlyCnt*>(pHint)
-                            ->GetFlyCnt().GetFrameFormat() );
+                pHt.reset( new SwHistoryTextFlyCnt( static_cast<SwTextFlyCnt*>(pHint)
+                            ->GetFlyCnt().GetFrameFormat() ) );
                 break;
             case RES_TXTATR_FIELD:
             case RES_TXTATR_ANNOTATION:
-                pHt = new SwHistorySetTextField(
-                        static_txtattr_cast<SwTextField*>(pHint), nNodeIdx);
+                pHt.reset( new SwHistorySetTextField(
+                        static_txtattr_cast<SwTextField*>(pHint), nNodeIdx) );
                 break;
             case RES_TXTATR_TOXMARK:
-                pHt = new SwHistorySetTOXMark(
-                        static_txtattr_cast<SwTextTOXMark*>(pHint), nNodeIdx);
+                pHt.reset( new SwHistorySetTOXMark(
+                        static_txtattr_cast<SwTextTOXMark*>(pHint), nNodeIdx) );
                 break;
             case RES_TXTATR_REFMARK:
-                pHt = new SwHistorySetRefMark(
-                        static_txtattr_cast<SwTextRefMark*>(pHint), nNodeIdx);
+                pHt.reset( new SwHistorySetRefMark(
+                        static_txtattr_cast<SwTextRefMark*>(pHint), nNodeIdx) );
                 break;
             default:
-                pHt = new SwHistorySetText( pHint, nNodeIdx );
+                pHt.reset( new SwHistorySetText( pHint, nNodeIdx ) );
         }
     }
     else
     {
-        pHt = new SwHistoryResetText( pHint->Which(), pHint->GetStart(),
-                                    *pHint->GetAnyEnd(), nNodeIdx );
+        pHt.reset( new SwHistoryResetText( pHint->Which(), pHint->GetStart(),
+                                    *pHint->GetAnyEnd(), nNodeIdx ) );
     }
-    m_SwpHstry.push_back( pHt );
+    m_SwpHstry.push_back( std::move(pHt) );
 }
 
 void SwHistory::Add( SwFormatColl* pColl, sal_uLong nNodeIdx, SwNodeType nWhichNd )
 {
     OSL_ENSURE( !m_nEndDiff, "History was not deleted after REDO" );
 
-    SwHistoryHint * pHt =
-        new SwHistoryChangeFormatColl( pColl, nNodeIdx, nWhichNd );
-    m_SwpHstry.push_back( pHt );
+    std::unique_ptr<SwHistoryHint> pHt(
+        new SwHistoryChangeFormatColl( pColl, nNodeIdx, nWhichNd ));
+    m_SwpHstry.push_back( std::move(pHt) );
 }
 
 void SwHistory::Add(const ::sw::mark::IMark& rBkmk, bool bSavePos, bool bSaveOtherPos)
 {
     OSL_ENSURE( !m_nEndDiff, "History was not deleted after REDO" );
 
-    SwHistoryHint * pHt = new SwHistoryBookmark(rBkmk, bSavePos, bSaveOtherPos);
-    m_SwpHstry.push_back( pHt );
+    std::unique_ptr<SwHistoryHint> pHt(new SwHistoryBookmark(rBkmk, bSavePos, bSaveOtherPos));
+    m_SwpHstry.push_back( std::move(pHt) );
 }
 
 void SwHistory::Add( SwFrameFormat& rFormat )
 {
-    SwHistoryHint * pHt = new SwHistoryChangeFlyAnchor( rFormat );
-    m_SwpHstry.push_back( pHt );
+    std::unique_ptr<SwHistoryHint> pHt(new SwHistoryChangeFlyAnchor( rFormat ));
+    m_SwpHstry.push_back( std::move(pHt) );
 }
 
 void SwHistory::Add( SwFlyFrameFormat& rFormat, sal_uInt16& rSetPos )
@@ -994,8 +990,8 @@ void SwHistory::Add( SwFlyFrameFormat& rFormat, sal_uInt16& rSetPos )
     const sal_uInt16 nWh = rFormat.Which();
     if( RES_FLYFRMFMT == nWh || RES_DRAWFRMFMT == nWh )
     {
-        SwHistoryHint * pHint = new SwHistoryTextFlyCnt( &rFormat );
-        m_SwpHstry.push_back( pHint );
+        std::unique_ptr<SwHistoryHint> pHint(new SwHistoryTextFlyCnt( &rFormat ));
+        m_SwpHstry.push_back( std::move(pHint) );
 
         const SwFormatChain* pChainItem;
         if( SfxItemState::SET == rFormat.GetItemState( RES_CHAIN, false,
@@ -1003,9 +999,9 @@ void SwHistory::Add( SwFlyFrameFormat& rFormat, sal_uInt16& rSetPos )
         {
             if( pChainItem->GetNext() || pChainItem->GetPrev() )
             {
-                SwHistoryHint * pHt =
-                    new SwHistoryChangeFlyChain( rFormat, *pChainItem );
-                m_SwpHstry.insert( m_SwpHstry.begin() + rSetPos++, pHt );
+                std::unique_ptr<SwHistoryHint> pHt(
+                    new SwHistoryChangeFlyChain( rFormat, *pChainItem ));
+                m_SwpHstry.insert( m_SwpHstry.begin() + rSetPos++, std::move(pHt) );
                 if ( pChainItem->GetNext() )
                 {
                     SwFormatChain aTmp( pChainItem->GetNext()->GetChain() );
@@ -1026,15 +1022,15 @@ void SwHistory::Add( SwFlyFrameFormat& rFormat, sal_uInt16& rSetPos )
 
 void SwHistory::Add( const SwTextFootnote& rFootnote )
 {
-    SwHistoryHint *pHt = new SwHistorySetFootnote( rFootnote );
-    m_SwpHstry.push_back( pHt );
+    std::unique_ptr<SwHistoryHint> pHt(new SwHistorySetFootnote( rFootnote ));
+    m_SwpHstry.push_back( std::move(pHt) );
 }
 
 // #i27615#
 void SwHistory::Add(const SfxItemSet & rSet, const SwCharFormat & rFormat)
 {
-    SwHistoryHint * pHt = new SwHistoryChangeCharFormat(rSet, rFormat.GetName());
-    m_SwpHstry.push_back( pHt );
+    std::unique_ptr<SwHistoryHint> pHt(new SwHistoryChangeCharFormat(rSet, rFormat.GetName()));
+    m_SwpHstry.push_back( std::move(pHt) );
 }
 
 bool SwHistory::Rollback( SwDoc* pDoc, sal_uInt16 nStart )
@@ -1044,9 +1040,8 @@ bool SwHistory::Rollback( SwDoc* pDoc, sal_uInt16 nStart )
 
     for ( sal_uInt16 i = Count(); i > nStart ; )
     {
-        SwHistoryHint * pHHt = m_SwpHstry[ --i ];
+        SwHistoryHint * pHHt = m_SwpHstry[ --i ].get();
         pHHt->SetInDoc( pDoc, false );
-        delete pHHt;
     }
     m_SwpHstry.erase( m_SwpHstry.begin() + nStart, m_SwpHstry.end() );
     m_nEndDiff = 0;
@@ -1059,12 +1054,11 @@ bool SwHistory::TmpRollback( SwDoc* pDoc, sal_uInt16 nStart, bool bToFirst )
     if ( !Count() || !nEnd || nStart >= nEnd )
         return false;
 
-    SwHistoryHint * pHHt;
     if ( bToFirst )
     {
         for ( ; nEnd > nStart; ++m_nEndDiff )
         {
-            pHHt = m_SwpHstry[ --nEnd ];
+            SwHistoryHint* pHHt = m_SwpHstry[ --nEnd ].get();
             pHHt->SetInDoc( pDoc, true );
         }
     }
@@ -1072,7 +1066,7 @@ bool SwHistory::TmpRollback( SwDoc* pDoc, sal_uInt16 nStart, bool bToFirst )
     {
         for ( ; nStart < nEnd; ++m_nEndDiff, ++nStart )
         {
-            pHHt = m_SwpHstry[ nStart ];
+            SwHistoryHint* pHHt = m_SwpHstry[ nStart ].get();
             pHHt->SetInDoc( pDoc, true );
         }
     }
@@ -1081,11 +1075,7 @@ bool SwHistory::TmpRollback( SwDoc* pDoc, sal_uInt16 nStart, bool bToFirst )
 
 void SwHistory::Delete()
 {
-    for ( sal_uInt16 n = Count(); n > 0; )
-    {
-        delete m_SwpHstry[ --n ];
-        m_SwpHstry.erase( m_SwpHstry.begin() + n );
-    }
+    m_SwpHstry.clear();
     m_nEndDiff = 0;
 }
 
@@ -1245,27 +1235,27 @@ void SwRegHistory::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
         }
         else if (pOld && RES_ATTRSET_CHG == pNew->Which())
         {
-            SwHistoryHint* pNewHstr(nullptr);
+            std::unique_ptr<SwHistoryHint> pNewHstr;
             const SfxItemSet& rSet = *static_cast< const SwAttrSetChg* >(pOld)->GetChgSet();
 
             if ( 1 < rSet.Count() )
             {
-                pNewHstr = new SwHistorySetAttrSet( rSet, m_nNodeIndex, m_WhichIdSet );
+                pNewHstr.reset( new SwHistorySetAttrSet( rSet, m_nNodeIndex, m_WhichIdSet ) );
             }
             else if (const SfxPoolItem* pItem = SfxItemIter( rSet ).FirstItem())
             {
                 if ( m_WhichIdSet.count( pItem->Which() ) )
                 {
-                    pNewHstr = new SwHistorySetFormat( pItem, m_nNodeIndex );
+                    pNewHstr.reset( new SwHistorySetFormat( pItem, m_nNodeIndex ) );
                 }
                 else
                 {
-                    pNewHstr = new SwHistoryResetFormat( pItem, m_nNodeIndex );
+                    pNewHstr.reset( new SwHistoryResetFormat( pItem, m_nNodeIndex ) );
                 }
             }
 
             if (pNewHstr)
-                m_pHistory->m_SwpHstry.push_back( pNewHstr );
+                m_pHistory->m_SwpHstry.push_back( std::move(pNewHstr) );
         }
     }
 }
@@ -1322,9 +1312,9 @@ bool SwRegHistory::InsertItems( const SfxItemSet& rSet,
                           // nothing at all to be inserted
             assert(std::find_if(
                 m_pHistory->m_SwpHstry.begin(), m_pHistory->m_SwpHstry.end(),
-                [nExpected](SwHistoryHint *const pHint) -> bool {
+                [nExpected](std::unique_ptr<SwHistoryHint> const& pHint) -> bool {
                     SwHistoryResetText const*const pReset(
-                            dynamic_cast<SwHistoryResetText const*>(pHint));
+                            dynamic_cast<SwHistoryResetText const*>(pHint.get()));
                     return pReset && (pReset->GetWhich() == nExpected);
                 }) != m_pHistory->m_SwpHstry.end());
         }


More information about the Libreoffice-commits mailing list