[Libreoffice-commits] .: 3 commits - svx/inc svx/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Jan 16 11:53:19 PST 2013


 svx/inc/svx/svdlayer.hxx       |   46 +++++++++++++-------------
 svx/source/svdraw/svdlayer.cxx |   71 ++++++++++++++++++++++++-----------------
 2 files changed, 65 insertions(+), 52 deletions(-)

New commits:
commit 2003d4ffbf9865bc87cbe081f48f98b287223820
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Wed Jan 16 14:34:15 2013 -0500

    Clean up SdrLayerAdmin too. Just a little.
    
    Change-Id: I3c8a195cd6c208c7ecd5cf326d3e7ccf3c02e935

diff --git a/svx/inc/svx/svdlayer.hxx b/svx/inc/svx/svdlayer.hxx
index 19d053e..6664064 100644
--- a/svx/inc/svx/svdlayer.hxx
+++ b/svx/inc/svx/svdlayer.hxx
@@ -20,7 +20,6 @@
 #ifndef _SVDLAYER_HXX
 #define _SVDLAYER_HXX
 
-#include <tools/string.hxx>
 #include <tools/stream.hxx>
 #include <svx/svdsob.hxx>
 #include <svx/svdtypes.hxx> // fuer typedef SdrLayerID
@@ -79,7 +78,7 @@ protected:
     std::vector<SdrLayer*> aLayer;
     SdrLayerAdmin* pParent; // Der Admin der Seite kennt den Admin des Docs
     SdrModel*      pModel; // zum Broadcasten
-    String         aControlLayerName;
+    OUString       maControlLayerName;
 protected:
     // Eine noch nicht verwendete LayerID raussuchen. Sind bereits alle
     // verbraucht, so gibt's 'ne 0. Wer sicher gehen will, muss vorher
@@ -117,7 +116,7 @@ public:
     // Alle Layer loeschen
     void               ClearLayer();
     // Neuer Layer wird angelegt und eingefuegt
-    SdrLayer*          NewLayer(const String& rName, sal_uInt16 nPos=0xFFFF);
+    SdrLayer*          NewLayer(const OUString& rName, sal_uInt16 nPos=0xFFFF);
     void               DeleteLayer(SdrLayer* pLayer)
     {
         std::vector<SdrLayer*>::iterator it = std::find(aLayer.begin(), aLayer.end(), pLayer);
@@ -137,14 +136,14 @@ public:
 
     sal_uInt16             GetLayerPos(SdrLayer* pLayer) const;
 
-    SdrLayer*          GetLayer(const String& rName, bool bInherited)            { return (SdrLayer*)(((const SdrLayerAdmin*)this)->GetLayer(rName,bInherited)); }
-    const SdrLayer*    GetLayer(const String& rName, bool bInherited) const;
-          SdrLayerID   GetLayerID(const String& rName, bool bInherited) const;
+    SdrLayer* GetLayer(const OUString& rName, bool bInherited);
+    const SdrLayer* GetLayer(const OUString& rName, bool bInherited) const;
+    SdrLayerID GetLayerID(const OUString& rName, bool bInherited) const;
           SdrLayer*    GetLayerPerID(sal_uInt16 nID)                                     { return (SdrLayer*)(((const SdrLayerAdmin*)this)->GetLayerPerID(nID)); }
     const SdrLayer*    GetLayerPerID(sal_uInt16 nID) const;
 
-    void               SetControlLayerName(const String& rNewName) { aControlLayerName=rNewName; }
-    const String&      GetControlLayerName() const                 { return aControlLayerName; }
+    void SetControlLayerName(const OUString& rNewName);
+    const OUString& GetControlLayerName() const { return maControlLayerName; }
 };
 
 /*
diff --git a/svx/source/svdraw/svdlayer.cxx b/svx/source/svdraw/svdlayer.cxx
index a28f307..4ce8f12 100644
--- a/svx/source/svdraw/svdlayer.cxx
+++ b/svx/source/svdraw/svdlayer.cxx
@@ -103,7 +103,9 @@ void SetOfByte::QueryValue( com::sun::star::uno::Any & rAny ) const
 SdrLayer::SdrLayer() : pModel(NULL), nType(0), nID(0) {}
 
 SdrLayer::SdrLayer(SdrLayerID nNewID, const OUString& rNewName) :
-    maName(rNewName), pModel(NULL), nType(0), nID(nNewID) {}
+    maName(rNewName), pModel(NULL), nType(0), nID(nNewID)
+{
+}
 
 void SdrLayer::SetID(SdrLayerID nNewID)
 {
@@ -152,18 +154,18 @@ bool SdrLayer::operator==(const SdrLayer& rCmpLayer) const
 
 SdrLayerAdmin::SdrLayerAdmin(SdrLayerAdmin* pNewParent):
     aLayer(),
-    pModel(NULL)
+    pParent(pNewParent),
+    pModel(NULL),
+    maControlLayerName("Controls")
 {
-    aControlLayerName = String(RTL_CONSTASCII_USTRINGPARAM("Controls"));
-    pParent=pNewParent;
 }
 
 SdrLayerAdmin::SdrLayerAdmin(const SdrLayerAdmin& rSrcLayerAdmin):
     aLayer(),
     pParent(NULL),
-    pModel(NULL)
+    pModel(NULL),
+    maControlLayerName("Controls")
 {
-    aControlLayerName = String(RTL_CONSTASCII_USTRINGPARAM("Controls"));
     *this = rSrcLayerAdmin;
 }
 
@@ -235,7 +237,7 @@ SdrLayer* SdrLayerAdmin::RemoveLayer(sal_uInt16 nPos)
     return pRetLayer;
 }
 
-SdrLayer* SdrLayerAdmin::NewLayer(const XubString& rName, sal_uInt16 nPos)
+SdrLayer* SdrLayerAdmin::NewLayer(const OUString& rName, sal_uInt16 nPos)
 {
     SdrLayerID nID=GetUniqueLayerID();
     SdrLayer* pLay=new SdrLayer(nID,rName);
@@ -276,14 +278,19 @@ sal_uInt16 SdrLayerAdmin::GetLayerPos(SdrLayer* pLayer) const
     return sal_uInt16(nRet);
 }
 
-const SdrLayer* SdrLayerAdmin::GetLayer(const XubString& rName, bool /*bInherited*/) const
+SdrLayer* SdrLayerAdmin::GetLayer(const OUString& rName, bool bInherited)
+{
+    return (SdrLayer*)(((const SdrLayerAdmin*)this)->GetLayer(rName, bInherited));
+}
+
+const SdrLayer* SdrLayerAdmin::GetLayer(const OUString& rName, bool /*bInherited*/) const
 {
     sal_uInt16 i(0);
     const SdrLayer* pLay = NULL;
 
     while(i < GetLayerCount() && !pLay)
     {
-        if(rName.Equals(GetLayer(i)->GetName()))
+        if (rName == GetLayer(i)->GetName())
             pLay = GetLayer(i);
         else
             i++;
@@ -297,7 +304,7 @@ const SdrLayer* SdrLayerAdmin::GetLayer(const XubString& rName, bool /*bInherite
     return pLay;
 }
 
-SdrLayerID SdrLayerAdmin::GetLayerID(const XubString& rName, bool bInherited) const
+SdrLayerID SdrLayerAdmin::GetLayerID(const OUString& rName, bool bInherited) const
 {
     SdrLayerID nRet=SDRLAYER_NOTFOUND;
     const SdrLayer* pLay=GetLayer(rName,bInherited);
@@ -349,4 +356,9 @@ SdrLayerID SdrLayerAdmin::GetUniqueLayerID() const
     return i;
 }
 
+void SdrLayerAdmin::SetControlLayerName(const OUString& rNewName)
+{
+    maControlLayerName = rNewName;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 5159695813b9dc08743de4bbcf7807f41e160b8f
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Wed Jan 16 13:03:52 2013 -0500

    Some cleanup of SdrLayer class.
    
    String replacement, proper use of initializer in constructors etc.
    
    Change-Id: Ic5e04c614ad044efcb32329a31540402524afe85

diff --git a/svx/inc/svx/svdlayer.hxx b/svx/inc/svx/svdlayer.hxx
index d0ddefe..19d053e 100644
--- a/svx/inc/svx/svdlayer.hxx
+++ b/svx/inc/svx/svdlayer.hxx
@@ -33,29 +33,29 @@ class SVX_DLLPUBLIC SdrLayer
 {
     friend class SdrLayerAdmin;
 
-    String     aName;
-    String      maTitle;
-    String      maDescription;
+    OUString maName;
+    OUString maTitle;
+    OUString maDescription;
     SdrModel*  pModel; // zum Broadcasten
     sal_uInt16     nType;  // 0=Userdefined,1=Standardlayer
     SdrLayerID nID;
 
-    SdrLayer(SdrLayerID nNewID, const String& rNewName)       { nID=nNewID; aName=rNewName; nType=0; pModel=NULL; }
-    void SetID(SdrLayerID nNewID)                             { nID=nNewID; }
+    SdrLayer(SdrLayerID nNewID, const OUString& rNewName);
+    void SetID(SdrLayerID nNewID);
 
 public:
-    SdrLayer(): pModel(NULL),nType(0),nID(0)                  {}
+    SdrLayer();
     bool      operator==(const SdrLayer& rCmpLayer) const;
     bool      operator!=(const SdrLayer& rCmpLayer) const { return !operator==(rCmpLayer); }
 
-    void          SetName(const String& rNewName);
-    const String& GetName() const                             { return aName; }
+    void SetName(const OUString& rNewName);
+    const OUString& GetName() const { return maName; }
 
-    void          SetTitle(const String& rTitle) { maTitle = rTitle; }
-    const String& GetTitle() const { return maTitle; }
+    void SetTitle(const OUString& rTitle) { maTitle = rTitle; }
+    const OUString& GetTitle() const { return maTitle; }
 
-    void          SetDescription(const String& rDesc) { maDescription = rDesc; }
-    const String& GetDescription() const { return maDescription; }
+    void SetDescription(const OUString& rDesc) { maDescription = rDesc; }
+    const OUString& GetDescription() const { return maDescription; }
 
     SdrLayerID    GetID() const                               { return nID; }
     void          SetModel(SdrModel* pNewModel)               { pModel=pNewModel; }
diff --git a/svx/source/svdraw/svdlayer.cxx b/svx/source/svdraw/svdlayer.cxx
index 7e85162..a28f307 100644
--- a/svx/source/svdraw/svdlayer.cxx
+++ b/svx/source/svdraw/svdlayer.cxx
@@ -24,10 +24,6 @@
 #include "svx/svdglob.hxx"  // StringCache
 #include "svx/svdstr.hrc"   // names taken from the resource
 
-////////////////////////////////////////////////////////////////////////////////////////////////////
-// SetOfByte
-////////////////////////////////////////////////////////////////////////////////////////////////////
-
 sal_Bool SetOfByte::IsEmpty() const
 {
     for(sal_uInt16 i(0); i < 32; i++)
@@ -104,15 +100,21 @@ void SetOfByte::QueryValue( com::sun::star::uno::Any & rAny ) const
     rAny <<= aSeq;
 }
 
-////////////////////////////////////////////////////////////////////////////////////////////////////
-// SdrLayer
-////////////////////////////////////////////////////////////////////////////////////////////////////
+SdrLayer::SdrLayer() : pModel(NULL), nType(0), nID(0) {}
+
+SdrLayer::SdrLayer(SdrLayerID nNewID, const OUString& rNewName) :
+    maName(rNewName), pModel(NULL), nType(0), nID(nNewID) {}
+
+void SdrLayer::SetID(SdrLayerID nNewID)
+{
+    nID = nNewID;
+}
 
 void SdrLayer::SetStandardLayer(bool bStd)
 {
     nType=(sal_uInt16)bStd;
     if (bStd) {
-        aName=ImpGetResStr(STR_StandardLayerName);
+        maName = ImpGetResStr(STR_StandardLayerName);
     }
     if (pModel!=NULL) {
         SdrHint aHint(HINT_LAYERCHG);
@@ -121,20 +123,19 @@ void SdrLayer::SetStandardLayer(bool bStd)
     }
 }
 
-void SdrLayer::SetName(const XubString& rNewName)
+void SdrLayer::SetName(const OUString& rNewName)
 {
-    if(!rNewName.Equals(aName))
-    {
-        aName = rNewName;
-        nType = 0; // user defined
+    if (rNewName == maName)
+        return;
 
-        if(pModel)
-        {
-            SdrHint aHint(HINT_LAYERCHG);
+    maName = rNewName;
+    nType = 0; // user defined
 
-            pModel->Broadcast(aHint);
-            pModel->SetChanged();
-        }
+    if (pModel)
+    {
+        SdrHint aHint(HINT_LAYERCHG);
+        pModel->Broadcast(aHint);
+        pModel->SetChanged();
     }
 }
 
@@ -142,7 +143,7 @@ bool SdrLayer::operator==(const SdrLayer& rCmpLayer) const
 {
     return (nID == rCmpLayer.nID
         && nType == rCmpLayer.nType
-        && aName.Equals(rCmpLayer.aName));
+        && maName == rCmpLayer.maName);
 }
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////
commit ff3e2a4a1ec23548dd42cab2e9a748bcd9156119
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Wed Jan 16 12:45:04 2013 -0500

    Nobody derives from SdrLayer. Change protected modifiers to private.
    
    Change-Id: I9d5822a055d90094a43a01f5cdb1f6f4d1156c49

diff --git a/svx/inc/svx/svdlayer.hxx b/svx/inc/svx/svdlayer.hxx
index 428b641..d0ddefe 100644
--- a/svx/inc/svx/svdlayer.hxx
+++ b/svx/inc/svx/svdlayer.hxx
@@ -31,17 +31,18 @@ class SdrModel;
 
 class SVX_DLLPUBLIC SdrLayer
 {
-friend class SdrLayerAdmin;
-protected:
+    friend class SdrLayerAdmin;
+
     String     aName;
     String      maTitle;
     String      maDescription;
     SdrModel*  pModel; // zum Broadcasten
     sal_uInt16     nType;  // 0=Userdefined,1=Standardlayer
     SdrLayerID nID;
-protected:
+
     SdrLayer(SdrLayerID nNewID, const String& rNewName)       { nID=nNewID; aName=rNewName; nType=0; pModel=NULL; }
     void SetID(SdrLayerID nNewID)                             { nID=nNewID; }
+
 public:
     SdrLayer(): pModel(NULL),nType(0),nID(0)                  {}
     bool      operator==(const SdrLayer& rCmpLayer) const;


More information about the Libreoffice-commits mailing list