Date: prev next · Thread: first prev next last
2014 Archives by date, by thread · List index


In

commit a4cd841541a729d7b8126d27d91fa28e30b01403
Author: Muthu Subramanian <sumuthu@collabora.com>
Date:   Thu Feb 13 16:10:47 2014 +0530

    n#757432: Styles (rename &) copy to different decks.

there is a stringify method added whose results only get passed to
getHash which is then used in sd to see if two SfxItemSets do not have
the same contents (I think). It would be nice to be able to get rid of
stringify to enable getting rid of SfxItemSet::Store

So.. would the simple attached patch to use SfxItemSet's operator== work
for the original n#757432 problem ? Or is the comparison too
strict/lax ?
From 0c10015dbfbc934628826676b44b36980b36e881 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
Date: Mon, 9 Jun 2014 15:15:04 +0100
Subject: [PATCH] can we drop getHash+stringify and use existing operator== for
 the comparison ?

Change-Id: I3ad7f8b1833c9b76a3e992274e3923b8c0010dbf
---
 include/svl/itemset.hxx      |  3 +--
 sd/source/core/stlpool.cxx   |  5 ++---
 svl/source/items/itemset.cxx | 20 --------------------
 3 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/include/svl/itemset.hxx b/include/svl/itemset.hxx
index 83d6ed7..50d3f4d 100644
--- a/include/svl/itemset.hxx
+++ b/include/svl/itemset.hxx
@@ -144,8 +144,7 @@ public:
     virtual SvStream &          Store( SvStream &, bool bDirect = false ) const;
 
     bool                        operator==(const SfxItemSet &) const;
-    sal_Int32                   getHash() const;
-    virtual OString             stringify() const;
+    bool                        operator!=(const SfxItemSet& rSet) const { return !(*this == 
rSet); }
 };
 
 inline void SfxItemSet::SetParent( const SfxItemSet* pNew )
diff --git a/sd/source/core/stlpool.cxx b/sd/source/core/stlpool.cxx
index 3d1ee56..dddab23 100644
--- a/sd/source/core/stlpool.cxx
+++ b/sd/source/core/stlpool.cxx
@@ -669,9 +669,8 @@ void SdStyleSheetPool::CopySheets(SdStyleSheetPool& rSourcePool, SfxStyleFamily
             // if we have a rename suffix, try to find a new name
             pExistingSheet =
                 GetStyleSheetByPositionInIndex(aSheetsWithName.front()).get();
-            sal_Int32 nHash = xSheet->GetItemSet().getHash();
             if (!rRenameSuffix.isEmpty() &&
-                pExistingSheet->GetItemSet().getHash() != nHash)
+                pExistingSheet->GetItemSet() != xSheet->GetItemSet())
             {
                 // we have found a sheet with the same name, but different contents. Try to find a 
new name.
                 // If we already have a sheet with the new name, and it is equal to the one in the 
source pool,
@@ -683,7 +682,7 @@ void SdStyleSheetPool::CopySheets(SdStyleSheetPool& rSourcePool, SfxStyleFamily
                     aTmpName = aName + rRenameSuffix + OUString::number(nSuffix);
                     pExistingSheet = Find(aTmpName, eFamily);
                     nSuffix++;
-                } while( pExistingSheet && pExistingSheet->GetItemSet().getHash() != nHash );
+                } while( pExistingSheet && pExistingSheet->GetItemSet() != xSheet->GetItemSet() );
                 aName = aTmpName;
                 bAddToList = true;
             }
diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx
index 24fc381..8df4d05 100644
--- a/svl/source/items/itemset.cxx
+++ b/svl/source/items/itemset.cxx
@@ -1988,24 +1988,4 @@ SfxItemSet *SfxAllItemSet::Clone(bool bItems, SfxItemPool *pToPool ) const
         return bItems ? new SfxAllItemSet(*this) : new SfxAllItemSet(*_pPool);
 }
 
-
-
-sal_Int32 SfxItemSet::getHash() const
-{
-    return stringify().hashCode();
-}
-
-
-
-OString SfxItemSet::stringify() const
-{
-    SvMemoryStream aStream;
-    SfxItemSet aSet(*this);
-    aSet.InvalidateDefaultItems();
-    aSet.Store(aStream, true);
-    aStream.Flush();
-    return OString(
-        static_cast<char const *>(aStream.GetData()), aStream.GetEndOfData());
-}
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-- 
1.9.3


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.