[Libreoffice-commits] core.git: 3 commits - include/xmloff sc/source sw/source xmloff/source

Kohei Yoshida kohei.yoshida at collabora.com
Fri Jul 25 12:54:47 PDT 2014


 include/xmloff/prhdlfac.hxx            |   20 +++++++++++---------
 sc/source/filter/xml/xmlstyle.hxx      |    1 +
 sw/source/filter/xml/xmlexpit.cxx      |    1 +
 sw/source/filter/xml/xmlimpit.cxx      |    1 +
 xmloff/source/draw/animationexport.cxx |    1 +
 xmloff/source/draw/animationimport.cxx |    1 +
 xmloff/source/style/prhdlfac.cxx       |   33 +++++++++++++++++++++++----------
 7 files changed, 39 insertions(+), 19 deletions(-)

New commits:
commit 52a36fb30aef51fc1cecde4cf2ac9c43a5c88c09
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Fri Jul 25 15:32:29 2014 -0400

    pImplize XMLPropertyHandlerFactory.
    
    Change-Id: Iff524c9065e9374b39db998e3860704555130995

diff --git a/include/xmloff/prhdlfac.hxx b/include/xmloff/prhdlfac.hxx
index aca1469..1b1822b 100644
--- a/include/xmloff/prhdlfac.hxx
+++ b/include/xmloff/prhdlfac.hxx
@@ -20,13 +20,12 @@
 #ifndef INCLUDED_XMLOFF_PRHDLFAC_HXX
 #define INCLUDED_XMLOFF_PRHDLFAC_HXX
 
-#include <sal/config.h>
 #include <xmloff/dllapi.h>
 #include <sal/types.h>
 
-#include <map>
 #include <salhelper/simplereferenceobject.hxx>
-#include <xmloff/xmlprhdl.hxx>
+
+class XMLPropertyHandler;
 
 /**
  This class is a base-class to create XMLPropertyHandler.
@@ -39,7 +38,14 @@
 */
 class XMLOFF_DLLPUBLIC XMLPropertyHandlerFactory : public salhelper::SimpleReferenceObject
 {
+    struct Impl;
+    Impl* mpImpl;
+
+    XMLPropertyHandlerFactory( const XMLPropertyHandlerFactory& ); // disabled
+    XMLPropertyHandlerFactory& operator= ( const XMLPropertyHandlerFactory& ); // disabled
+
 public:
+    XMLPropertyHandlerFactory();
     virtual ~XMLPropertyHandlerFactory();
 
     /**
@@ -91,11 +97,7 @@ protected:
 private:
     /** Retrieves ( creates if necessary ) PropertyHandler for
         basic XML-types */
-    SAL_DLLPRIVATE const XMLPropertyHandler* GetBasicHandler( sal_Int32 nType )
-        const;
-
-    typedef ::std::map<sal_Int32, const XMLPropertyHandler*> CacheMap;
-    mutable CacheMap maHandlerCache;
+    SAL_DLLPRIVATE const XMLPropertyHandler* GetBasicHandler( sal_Int32 nType ) const;
 };
 
 #endif // INCLUDED_XMLOFF_PRHDLFAC_HXX
diff --git a/sc/source/filter/xml/xmlstyle.hxx b/sc/source/filter/xml/xmlstyle.hxx
index a3f3f12..5e625b0 100644
--- a/sc/source/filter/xml/xmlstyle.hxx
+++ b/sc/source/filter/xml/xmlstyle.hxx
@@ -28,6 +28,7 @@
 #include <xmloff/styleexp.hxx>
 #include <xmloff/xmlexppr.hxx>
 #include <xmloff/contextid.hxx>
+#include <xmloff/xmlprhdl.hxx>
 
 extern const XMLPropertyMapEntry aXMLScCellStylesProperties[];
 extern const XMLPropertyMapEntry aXMLScColumnStylesProperties[];
diff --git a/sw/source/filter/xml/xmlexpit.cxx b/sw/source/filter/xml/xmlexpit.cxx
index 119dac1..0ce5f74 100644
--- a/sw/source/filter/xml/xmlexpit.cxx
+++ b/sw/source/filter/xml/xmlexpit.cxx
@@ -32,6 +32,7 @@
 #include <xmloff/xmltypes.hxx>
 #include <editeng/xmlcnitm.hxx>
 #include <xmloff/xmlexp.hxx>
+#include <xmloff/xmlprhdl.hxx>
 #include <editeng/memberids.hrc>
 #include "hintids.hxx"
 #include "unomid.h"
diff --git a/sw/source/filter/xml/xmlimpit.cxx b/sw/source/filter/xml/xmlimpit.cxx
index 529a598..5a6a947 100644
--- a/sw/source/filter/xml/xmlimpit.cxx
+++ b/sw/source/filter/xml/xmlimpit.cxx
@@ -47,6 +47,7 @@
 #include "fmtlsplt.hxx"
 #include <xmloff/prhdlfac.hxx>
 #include <xmloff/xmltypes.hxx>
+#include <xmloff/xmlprhdl.hxx>
 #include "xmlithlp.hxx"
 #include <com/sun/star/uno/Any.hxx>
 
diff --git a/xmloff/source/draw/animationexport.cxx b/xmloff/source/draw/animationexport.cxx
index bf1c5b1..11ed567 100644
--- a/xmloff/source/draw/animationexport.cxx
+++ b/xmloff/source/draw/animationexport.cxx
@@ -63,6 +63,7 @@
 #include <xmloff/xmlement.hxx>
 #include <xmloff/nmspmap.hxx>
 #include <xmloff/shapeexport.hxx>
+#include <xmloff/xmlprhdl.hxx>
 
 #include "animations.hxx"
 #include <xmloff/animationexport.hxx>
diff --git a/xmloff/source/draw/animationimport.cxx b/xmloff/source/draw/animationimport.cxx
index e242ed0..66f3790 100644
--- a/xmloff/source/draw/animationimport.cxx
+++ b/xmloff/source/draw/animationimport.cxx
@@ -61,6 +61,7 @@
 #include <xmloff/xmluconv.hxx>
 #include <osl/mutex.hxx>
 #include <xmloff/nmspmap.hxx>
+#include <xmloff/xmlprhdl.hxx>
 #include "anim.hxx"
 #include "facreg.hxx"
 
diff --git a/xmloff/source/style/prhdlfac.cxx b/xmloff/source/style/prhdlfac.cxx
index 2829fe6..b60119d 100644
--- a/xmloff/source/style/prhdlfac.cxx
+++ b/xmloff/source/style/prhdlfac.cxx
@@ -17,15 +17,17 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <xmloff/prhdlfac.hxx>
+
 #include <com/sun/star/drawing/ColorMode.hpp>
 #include <com/sun/star/text/HorizontalAdjust.hpp>
 #include <com/sun/star/text/WritingMode2.hpp>
 
 #include <tools/debug.hxx>
 
-#include <xmloff/prhdlfac.hxx>
 #include <xmloff/xmltypes.hxx>
 #include <xmloff/xmltoken.hxx>
+#include <xmloff/xmlprhdl.hxx>
 #include "xmlbahdl.hxx"
 #include <xmloff/NamedBoolPropertyHdl.hxx>
 #include <xmloff/XMLConstantsPropertyHandler.hxx>
@@ -52,6 +54,8 @@
 #include "XMLRectangleMembersHandler.hxx"
 #include "DrawAspectHdl.hxx"
 
+#include <map>
+
 using namespace ::com::sun::star;
 using namespace ::xmloff::token;
 
@@ -94,11 +98,22 @@ static SvXMLEnumMapEntry const aXML_WritingDirection_Enum[] =
     { XML_TOKEN_INVALID, 0 }
 };
 
-// Dtor
+typedef std::map<sal_Int32, const XMLPropertyHandler*> CacheMap;
+
+struct XMLPropertyHandlerFactory::Impl
+{
+    mutable CacheMap maHandlerCache;
+};
+
+XMLPropertyHandlerFactory::XMLPropertyHandlerFactory() :
+    mpImpl(new Impl) {}
+
 XMLPropertyHandlerFactory::~XMLPropertyHandlerFactory()
 {
-    for( CacheMap::iterator pPos = maHandlerCache.begin(); pPos != maHandlerCache.end(); ++pPos )
+    for( CacheMap::iterator pPos = mpImpl->maHandlerCache.begin(); pPos != mpImpl->maHandlerCache.end(); ++pPos )
         delete pPos->second;
+
+    delete mpImpl;
 }
 
 // Interface
@@ -114,15 +129,15 @@ const XMLPropertyHandler* XMLPropertyHandlerFactory::GetHdlCache( sal_Int32 nTyp
 {
     const XMLPropertyHandler* pRet = NULL;
 
-    if( maHandlerCache.find( nType ) != maHandlerCache.end() )
-        pRet = maHandlerCache.find( nType )->second;
+    if( mpImpl->maHandlerCache.find( nType ) != mpImpl->maHandlerCache.end() )
+        pRet = mpImpl->maHandlerCache.find( nType )->second;
 
     return pRet;
 }
 
 void XMLPropertyHandlerFactory::PutHdlCache( sal_Int32 nType, const XMLPropertyHandler* pHdl ) const
 {
-    maHandlerCache[nType] = pHdl;
+    mpImpl->maHandlerCache[nType] = pHdl;
 }
 
 const XMLPropertyHandler* XMLPropertyHandlerFactory::GetBasicHandler( sal_Int32 nType ) const
commit 690f7ff8839c66c29f71f681b9e78cc51923c6b6
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Fri Jul 25 15:18:40 2014 -0400

    Store the handler as a const pointer.
    
    Handlers are conceptually stateless; we can keep them as const objects.
    
    Change-Id: I3d35ab0695037632e82f67f901c9795adf9bdd8d

diff --git a/include/xmloff/prhdlfac.hxx b/include/xmloff/prhdlfac.hxx
index 3b04583..aca1469 100644
--- a/include/xmloff/prhdlfac.hxx
+++ b/include/xmloff/prhdlfac.hxx
@@ -84,7 +84,7 @@ public:
 
 protected:
     /** Retrieves a PropertyHandler from the internal cache */
-    XMLPropertyHandler* GetHdlCache( sal_Int32 nType ) const;
+    const XMLPropertyHandler* GetHdlCache( sal_Int32 nType ) const;
     /** Puts a PropertyHandler into the internal cache */
     void PutHdlCache( sal_Int32 nType, const XMLPropertyHandler* pHdl ) const;
 
@@ -94,7 +94,7 @@ private:
     SAL_DLLPRIVATE const XMLPropertyHandler* GetBasicHandler( sal_Int32 nType )
         const;
 
-    typedef ::std::map< sal_Int32, XMLPropertyHandler* > CacheMap;
+    typedef ::std::map<sal_Int32, const XMLPropertyHandler*> CacheMap;
     mutable CacheMap maHandlerCache;
 };
 
diff --git a/xmloff/source/style/prhdlfac.cxx b/xmloff/source/style/prhdlfac.cxx
index 5607585..2829fe6 100644
--- a/xmloff/source/style/prhdlfac.cxx
+++ b/xmloff/source/style/prhdlfac.cxx
@@ -110,9 +110,9 @@ const XMLPropertyHandler* XMLPropertyHandlerFactory::GetPropertyHandler( sal_Int
 }
 
 // Helper-methods to create and cache PropertyHandler
-XMLPropertyHandler* XMLPropertyHandlerFactory::GetHdlCache( sal_Int32 nType ) const
+const XMLPropertyHandler* XMLPropertyHandlerFactory::GetHdlCache( sal_Int32 nType ) const
 {
-    XMLPropertyHandler* pRet = NULL;
+    const XMLPropertyHandler* pRet = NULL;
 
     if( maHandlerCache.find( nType ) != maHandlerCache.end() )
         pRet = maHandlerCache.find( nType )->second;
@@ -122,7 +122,7 @@ XMLPropertyHandler* XMLPropertyHandlerFactory::GetHdlCache( sal_Int32 nType ) co
 
 void XMLPropertyHandlerFactory::PutHdlCache( sal_Int32 nType, const XMLPropertyHandler* pHdl ) const
 {
-    maHandlerCache[nType] = (XMLPropertyHandler*)pHdl;
+    maHandlerCache[nType] = pHdl;
 }
 
 const XMLPropertyHandler* XMLPropertyHandlerFactory::GetBasicHandler( sal_Int32 nType ) const
commit dbf84a3574dd3524fcb8d89c3dcb91182656e1ce
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Fri Jul 25 15:13:42 2014 -0400

    The 'mutable' keyword exists for this kind of use.
    
    Change-Id: Ic52192f53039b7f1b4529a93c13de74c5f54e7f8

diff --git a/include/xmloff/prhdlfac.hxx b/include/xmloff/prhdlfac.hxx
index e21b5cb..3b04583 100644
--- a/include/xmloff/prhdlfac.hxx
+++ b/include/xmloff/prhdlfac.hxx
@@ -95,7 +95,7 @@ private:
         const;
 
     typedef ::std::map< sal_Int32, XMLPropertyHandler* > CacheMap;
-    CacheMap maHandlerCache;
+    mutable CacheMap maHandlerCache;
 };
 
 #endif // INCLUDED_XMLOFF_PRHDLFAC_HXX
diff --git a/xmloff/source/style/prhdlfac.cxx b/xmloff/source/style/prhdlfac.cxx
index 002c7f4..5607585 100644
--- a/xmloff/source/style/prhdlfac.cxx
+++ b/xmloff/source/style/prhdlfac.cxx
@@ -122,9 +122,7 @@ XMLPropertyHandler* XMLPropertyHandlerFactory::GetHdlCache( sal_Int32 nType ) co
 
 void XMLPropertyHandlerFactory::PutHdlCache( sal_Int32 nType, const XMLPropertyHandler* pHdl ) const
 {
-    // Don't be wondered about the following construct. The  sense is to be able to provide a const-
-    // method as class-interface.
-    ((XMLPropertyHandlerFactory*)this)->maHandlerCache[ nType ] = (XMLPropertyHandler*)pHdl;
+    maHandlerCache[nType] = (XMLPropertyHandler*)pHdl;
 }
 
 const XMLPropertyHandler* XMLPropertyHandlerFactory::GetBasicHandler( sal_Int32 nType ) const


More information about the Libreoffice-commits mailing list