[Libreoffice-commits] core.git: include/svx sd/inc sd/source svx/source

Varun Dhall varun.dhall at studentpartner.com
Tue Aug 15 22:13:56 UTC 2017


 include/svx/svdobj.hxx       |    2 +-
 sd/inc/sdpage.hxx            |    2 +-
 sd/source/core/drawdoc3.cxx  |    2 +-
 sd/source/core/sdpage2.cxx   |   38 ++++++++++++++++++++------------------
 svx/source/svdraw/svdobj.cxx |   42 ++++++++++++------------------------------
 5 files changed, 35 insertions(+), 51 deletions(-)

New commits:
commit 5be19d80f47cca8260cb46ac6e54ac19e5ea2705
Author: Varun Dhall <varun.dhall at studentpartner.com>
Date:   Tue Aug 15 21:27:43 2017 +0530

    Replace stringify by Equals in SdrObject and SdPage
    
    Change-Id: Ia4cf7a5382a05061ff98f423cf5640a51015236d
    Reviewed-on: https://gerrit.libreoffice.org/41182
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>

diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx
index e85d6de002c0..3d7ded0a7fe9 100644
--- a/include/svx/svdobj.hxx
+++ b/include/svx/svdobj.hxx
@@ -788,7 +788,7 @@ public:
     // #i121917#
     virtual bool HasText() const;
 
-    OString stringify() const;
+    bool Equals(const SdrObject&) const;;
 
     virtual void dumpAsXml(struct _xmlTextWriter* pWriter) const;
 
diff --git a/sd/inc/sdpage.hxx b/sd/inc/sdpage.hxx
index b4b72390b6bf..4edb82d0c874 100644
--- a/sd/inc/sdpage.hxx
+++ b/sd/inc/sdpage.hxx
@@ -375,7 +375,7 @@ public:
     void addAnnotation( const css::uno::Reference< css::office::XAnnotation >& xAnnotation, int nIndex );
     void removeAnnotation( const css::uno::Reference< css::office::XAnnotation >& xAnnotation );
     const sd::AnnotationVector& getAnnotations() const { return maAnnotations; }
-    OString stringify() const;
+    bool Equals(const SdPage&) const;
     virtual void dumpAsXml(struct _xmlTextWriter* pWriter) const override;
     sal_uInt16 getPageId() { return mnPageId; }
 
diff --git a/sd/source/core/drawdoc3.cxx b/sd/source/core/drawdoc3.cxx
index 23c687e6dc1e..69b6a83d6ef3 100644
--- a/sd/source/core/drawdoc3.cxx
+++ b/sd/source/core/drawdoc3.cxx
@@ -111,7 +111,7 @@ void InsertBookmarkAsPage_FindDuplicateLayouts::operator()( SdDrawDocument& rDoc
         {
             // Ignore Layouts with "Default" these seem to be special - in the sense that there are lot of assumption all over Impress
             // about this
-            if( bRenameDuplicates && aTest != SdResId( STR_LAYOUT_DEFAULT_NAME ) && pTestPage->stringify() != pBMMPage->stringify() )
+            if( bRenameDuplicates && aTest != SdResId( STR_LAYOUT_DEFAULT_NAME ) && !(pTestPage->Equals(*pBMMPage)) )
             {
                 pBookmarkDoc->RenameLayoutTemplate(
                     pBMMPage->GetLayoutName(), pBMMPage->GetName() + "_");
diff --git a/sd/source/core/sdpage2.cxx b/sd/source/core/sdpage2.cxx
index c4168094d373..65a7eaaabde8 100644
--- a/sd/source/core/sdpage2.cxx
+++ b/sd/source/core/sdpage2.cxx
@@ -557,25 +557,27 @@ void SdPage::setTransitionDuration ( double fTranstionDuration )
     ActionChanged();
 }
 
-OString SdPage::stringify() const
+bool SdPage::Equals(const SdPage& rOtherPage) const
 {
-    OStringBuffer aString(100);
-    aString.append((sal_Int32)mePageKind).append((sal_Int32)meAutoLayout).append((sal_Int32)mePresChange).append(mfTime).append(mbSoundOn).append(mbExcluded).
-             append(OUStringToOString( maLayoutName, RTL_TEXTENCODING_UTF8 )).
-             append(OUStringToOString(maSoundFile, RTL_TEXTENCODING_UTF8 )).
-             append(mbLoopSound).append(mbStopSound).
-             /*append(OUStringToOString(maCreatedPageName, RTL_TEXTENCODING_UTF8)).
-             append(OUStringToOString(maFileName, RTL_TEXTENCODING_UTF8)).*/
-             append(OUStringToOString(maBookmarkName, RTL_TEXTENCODING_UTF8)).
-             append(mbScaleObjects).append(mbBackgroundFullSize).append((sal_Int32)meCharSet).append((sal_Int32)mnPaperBin).
-             append((sal_Int32)meOrientation).append((sal_Int32)mnTransitionType).append((sal_Int32)mnTransitionSubtype).append(mbTransitionDirection).
-             append(mnTransitionFadeColor).append(mfTransitionDuration);//.append(mbIsPrecious);
-
-    const size_t n = GetObjCount();
-    for(size_t i = 0; i < n; ++i)
-        aString.append(GetObj(i)->stringify());
-    return aString.makeStringAndClear();
-}
+    bool isEqual = GetObjCount() == rOtherPage.GetObjCount();
+    if( isEqual )
+    {
+        for(size_t i = 0; i < GetObjCount(); ++i)
+            isEqual = isEqual && GetObj(i)->Equals(*(rOtherPage.GetObj(i)));
+    }
+
+    return (isEqual && mePageKind == rOtherPage.mePageKind && meAutoLayout == rOtherPage.meAutoLayout &&
+            mePresChange == rOtherPage.mePresChange && rtl::math::approxEqual(mfTime, rOtherPage.mfTime) &&
+            mbSoundOn == rOtherPage.mbSoundOn && mbExcluded == rOtherPage.mbExcluded &&
+            maLayoutName == rOtherPage.maLayoutName && maSoundFile == rOtherPage.maSoundFile &&
+            mbLoopSound == rOtherPage.mbLoopSound && mbStopSound == rOtherPage.mbStopSound &&
+            maBookmarkName == rOtherPage.maBookmarkName && mbScaleObjects == rOtherPage.mbScaleObjects &&
+            mbBackgroundFullSize == rOtherPage.mbBackgroundFullSize && meCharSet == rOtherPage.meCharSet &&
+            mnPaperBin == rOtherPage.mnPaperBin && meOrientation == rOtherPage.meOrientation &&
+            mnTransitionType == rOtherPage.mnTransitionType && mnTransitionSubtype == rOtherPage.mnTransitionSubtype &&
+            mbTransitionDirection == rOtherPage.mbTransitionDirection && mnTransitionFadeColor == rOtherPage.mnTransitionFadeColor &&
+            rtl::math::approxEqual(mfTransitionDuration, rOtherPage.mfTransitionDuration));
+ }
 
 void SdPage::createAnnotation( css::uno::Reference< css::office::XAnnotation >& xAnnotation )
 {
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index 2a1881eb974d..a21af0f7f328 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -1690,36 +1690,18 @@ bool SdrObject::HasTextEdit() const
     return false;
 }
 
-OString SdrObject::stringify() const
-{
-    OStringBuffer aString(100);
-    aString.append(aAnchor.X()).
-            append(aAnchor.Y()).
-            append(aGridOffset.X()).
-            append(aGridOffset.Y()).
-            append((sal_Int32)nOrdNum).
-            append((sal_Int32)mnNavigationPosition).
-            append(mbSupportTextIndentingOnLineWidthChange).
-            append(mbLineIsOutsideGeometry).
-            append(bMarkProt).
-            append(bIs3DObj).
-            append(bIsEdge).
-            append(bClosedObj).
-            append(bNotVisibleAsMaster).
-            append(bEmptyPresObj).
-            append(mbVisible).
-            append(bNoPrint).
-            append(bSizProt).
-            append(bMovProt).
-            append(false).
-            append(bInserted).
-            append(false).
-            append(bVirtObj).
-            append(sal_uInt8(mnLayerID));
-
-    aString.append(GetMergedItemSet().stringify());
-
-    return aString.makeStringAndClear();
+bool SdrObject::Equals(const SdrObject& rOtherObj) const
+{
+    return (aAnchor.X() == rOtherObj.aAnchor.X() && aAnchor.Y() == rOtherObj.aAnchor.Y() &&
+            aGridOffset.X() == rOtherObj.aGridOffset.X() && aGridOffset.Y() == rOtherObj.aGridOffset.Y() &&
+            nOrdNum == rOtherObj.nOrdNum && mnNavigationPosition == rOtherObj.mnNavigationPosition &&
+            mbSupportTextIndentingOnLineWidthChange == rOtherObj.mbSupportTextIndentingOnLineWidthChange &&
+            mbLineIsOutsideGeometry == rOtherObj.mbLineIsOutsideGeometry && bMarkProt == rOtherObj.bMarkProt &&
+            bIs3DObj == rOtherObj.bIs3DObj && bIsEdge == rOtherObj.bIsEdge && bClosedObj == rOtherObj.bClosedObj &&
+            bNotVisibleAsMaster == rOtherObj.bNotVisibleAsMaster && bEmptyPresObj == rOtherObj.bEmptyPresObj &&
+            mbVisible == rOtherObj.mbVisible && bNoPrint == rOtherObj.bNoPrint && bSizProt == rOtherObj.bSizProt &&
+            bMovProt == rOtherObj.bMovProt && bInserted == rOtherObj.bInserted && bVirtObj == rOtherObj.bVirtObj &&
+            mnLayerID == rOtherObj.mnLayerID && GetMergedItemSet().Equals(rOtherObj.GetMergedItemSet(), false) );
 }
 
 void SdrObject::dumpAsXml(xmlTextWriterPtr pWriter) const


More information about the Libreoffice-commits mailing list