Hi,

This should address the first item in the "removal of duplicate template
classes in calc filter code" section from the easy hacks page.

Not quite a simple search-and-replace but pretty close.

The second item (ScfNoInstance) is slightly more involved. All of the
classes derived from ScfNoInstance are just collections of static
methods and none of them are derived from. Since C++ doesn't support
declaring classes as static, I'm thinking that converting those classes
to namespaces is the correct route? (My C++ skills are a bit rusty).

Nigel
>From d881db70d4b0577cf0286a73efea702a57ada612 Mon Sep 17 00:00:00 2001
From: Nigel Hawkins <n.hawk...@gmx.com>
Date: Wed, 10 Nov 2010 13:27:57 +0000
Subject: [PATCH] Replace ScfNoCopy with boost::noncopyable

Make boost::noncopyable references private
---
 sc/source/filter/inc/fprogressbar.hxx |    3 ++-
 sc/source/filter/inc/ftools.hxx       |   15 ++-------------
 sc/source/filter/inc/xehelper.hxx     |    3 ++-
 sc/source/filter/inc/xicontent.hxx    |    4 +++-
 sc/source/filter/inc/xihelper.hxx     |    5 +++--
 sc/source/filter/inc/xistyle.hxx      |   11 ++++++-----
 sc/source/filter/inc/xlpage.hxx       |    3 ++-
 7 files changed, 20 insertions(+), 24 deletions(-)

diff --git a/sc/source/filter/inc/fprogressbar.hxx b/sc/source/filter/inc/fprogressbar.hxx
index 751c9c6..11e0657 100644
--- a/sc/source/filter/inc/fprogressbar.hxx
+++ b/sc/source/filter/inc/fprogressbar.hxx
@@ -29,6 +29,7 @@
 #ifndef SC_FPROGRESSBAR_HXX
 #define SC_FPROGRESSBAR_HXX
 
+#include <boost/noncopyable.hpp>
 #include "globstr.hrc"
 #include "ftools.hxx"
 #include "scdllapi.h"
@@ -111,7 +112,7 @@ const sal_Int32 SCF_INV_SEGMENT = -1;
         // not allowed (second segment active):   aProgress.Progress();
         // not allowed (first segment not empty): aProgress.GetSegmentProgressBar( nSeg1 );
  */
-class ScfProgressBar : ScfNoCopy
+class ScfProgressBar : private boost::noncopyable
 {
 public:
     explicit            ScfProgressBar( SfxObjectShell* pDocShell, const String& rText );
diff --git a/sc/source/filter/inc/ftools.hxx b/sc/source/filter/inc/ftools.hxx
index 394c213..ab11beb 100644
--- a/sc/source/filter/inc/ftools.hxx
+++ b/sc/source/filter/inc/ftools.hxx
@@ -37,6 +37,7 @@
 #include <tools/list.hxx>
 #include <tools/debug.hxx>
 #include <oox/helper/helper.hxx>
+#include <boost/noncopyable.hpp>
 #include "filter.hxx"
 #include "scdllapi.h"
 
@@ -138,20 +139,8 @@ void insert_value( Type& rnBitField, InsertType nValue, sal_uInt8 nStartBit, sal
 
 // ============================================================================
 
-/** Deriving from this class prevents copy construction. */
-class ScfNoCopy
-{
-private:
-                        ScfNoCopy( const ScfNoCopy& );
-    ScfNoCopy&          operator=( const ScfNoCopy& );
-protected:
-    inline              ScfNoCopy() {}
-};
-
-// ----------------------------------------------------------------------------
-
 /** Deriving from this class prevents construction in general. */
-class ScfNoInstance : private ScfNoCopy {};
+class ScfNoInstance : private boost::noncopyable {};
 
 // ============================================================================
 
diff --git a/sc/source/filter/inc/xehelper.hxx b/sc/source/filter/inc/xehelper.hxx
index e82eaca..fe27f6e 100644
--- a/sc/source/filter/inc/xehelper.hxx
+++ b/sc/source/filter/inc/xehelper.hxx
@@ -29,6 +29,7 @@
 #ifndef SC_XEHELPER_HXX
 #define SC_XEHELPER_HXX
 
+#include <boost/noncopyable.hpp>
 #include "xladdress.hxx"
 #include "xeroot.hxx"
 #include "xestring.hxx"
@@ -364,7 +365,7 @@ class EditEngine;
     Known but unsupported control sequences:
     &G                      picture
  */
-class XclExpHFConverter : protected XclExpRoot, ScfNoCopy
+class XclExpHFConverter : protected XclExpRoot, private boost::noncopyable
 {
 public:
     explicit            XclExpHFConverter( const XclExpRoot& rRoot );
diff --git a/sc/source/filter/inc/xicontent.hxx b/sc/source/filter/inc/xicontent.hxx
index 982cfae..904ea2e 100644
--- a/sc/source/filter/inc/xicontent.hxx
+++ b/sc/source/filter/inc/xicontent.hxx
@@ -38,6 +38,8 @@
 
 #include <map>
 #include <boost/ptr_container/ptr_vector.hpp>
+#include <boost/noncopyable.hpp>
+
 
 /* ============================================================================
 Classes to import the big Excel document contents (related to several cells or
@@ -193,7 +195,7 @@ private:
 // Web queries ================================================================
 
 /** Stores the data of one web query. */
-class XclImpWebQuery : ScfNoCopy
+class XclImpWebQuery : private boost::noncopyable
 {
 public:
     explicit            XclImpWebQuery( const ScRange& rDestRange );
diff --git a/sc/source/filter/inc/xihelper.hxx b/sc/source/filter/inc/xihelper.hxx
index 6ee969c..eeb12e8 100644
--- a/sc/source/filter/inc/xihelper.hxx
+++ b/sc/source/filter/inc/xihelper.hxx
@@ -30,6 +30,7 @@
 #define SC_XIHELPER_HXX
 
 #include <editeng/editdata.hxx>
+#include <boost/noncopyable.hpp>
 #include "scmatrix.hxx"
 #include "xladdress.hxx"
 #include "xiroot.hxx"
@@ -165,7 +166,7 @@ struct XclFontData;
     Known but unsupported control sequences:
     &G                      picture
  */
-class XclImpHFConverter : protected XclImpRoot, ScfNoCopy
+class XclImpHFConverter : protected XclImpRoot, private boost::noncopyable
 {
 public:
     explicit            XclImpHFConverter( const XclImpRoot& rRoot );
@@ -288,7 +289,7 @@ class ScTokenArray;
 
 /** This class stores one cached value of a cached value list (used for instance in
     CRN, EXTERNNAME, tArray). */
-class XclImpCachedValue : ScfNoCopy
+class XclImpCachedValue : boost::noncopyable
 {
 public:
     /** Creates a cached value and reads contents from stream and stores it with its array address. */
diff --git a/sc/source/filter/inc/xistyle.hxx b/sc/source/filter/inc/xistyle.hxx
index d8e7f37..cceb76e 100644
--- a/sc/source/filter/inc/xistyle.hxx
+++ b/sc/source/filter/inc/xistyle.hxx
@@ -31,6 +31,7 @@
 
 #include <list>
 #include <tools/mempool.hxx>
+#include <boost/noncopyable.hpp>
 #include "rangelst.hxx"
 #include "patattr.hxx"
 #include "xladdress.hxx"
@@ -168,7 +169,7 @@ private:
 // ----------------------------------------------------------------------------
 
 /** Stores the data of all fonts occurred in an Excel file. */
-class XclImpFontBuffer : protected XclImpRoot, ScfNoCopy
+class XclImpFontBuffer : protected XclImpRoot, private boost::noncopyable
 {
 public:
     explicit            XclImpFontBuffer( const XclImpRoot& rRoot );
@@ -392,7 +393,7 @@ inline bool operator!=( const XclImpXFIndex& rLeft, const XclImpXFIndex& rRight
 // ----------------------------------------------------------------------------
 
 /** Contains all data of a XF record and a Calc item set. */
-class XclImpXF : public XclXFBase, protected XclImpRoot, ScfNoCopy
+class XclImpXF : public XclXFBase, protected XclImpRoot, private boost::noncopyable
 {
 public:
     explicit            XclImpXF( const XclImpRoot& rRoot );
@@ -480,7 +481,7 @@ private:
 
 /** Contains all XF records occured in the file.
     @descr  This class is able to read XF records (BIFF2 - BIFF8) and STYLE records (BIFF8). */
-class XclImpXFBuffer : protected XclImpRoot, ScfNoCopy
+class XclImpXFBuffer : protected XclImpRoot, private boost::noncopyable
 {
 public:
     explicit            XclImpXFBuffer( const XclImpRoot& rRoot );
@@ -564,7 +565,7 @@ inline bool XclImpXFRange::Contains( SCROW nScRow ) const
 // ----------------------------------------------------------------------------
 
 /** Contains the XF indexes for every used cell in a column. */
-class XclImpXFRangeColumn : ScfNoCopy
+class XclImpXFRangeColumn : private boost::noncopyable
 {
 public:
     inline explicit     XclImpXFRangeColumn() {}
@@ -601,7 +602,7 @@ private:
 // ----------------------------------------------------------------------------
 
 /** Contains the XF indexes for every used cell in a single sheet. */
-class XclImpXFRangeBuffer : protected XclImpRoot, ScfNoCopy
+class XclImpXFRangeBuffer : protected XclImpRoot, private boost::noncopyable
 {
 public:
     explicit            XclImpXFRangeBuffer( const XclImpRoot& rRoot );
diff --git a/sc/source/filter/inc/xlpage.hxx b/sc/source/filter/inc/xlpage.hxx
index 2accb86..67d1c3b 100644
--- a/sc/source/filter/inc/xlpage.hxx
+++ b/sc/source/filter/inc/xlpage.hxx
@@ -30,6 +30,7 @@
 #define SC_XLPAGE_HXX
 
 #include <tools/gen.hxx>
+#include <boost/noncopyable.hpp>
 #include "xltools.hxx"
 
 // Constants and Enumerations =================================================
@@ -100,7 +101,7 @@ class SvxBrushItem;
 class SfxPrinter;
 
 /** Contains all page (print) settings for a single sheet. */
-struct XclPageData : ScfNoCopy
+struct XclPageData : private boost::noncopyable
 {
     typedef ::std::auto_ptr< SvxBrushItem > SvxBrushItemPtr;
 
-- 
1.7.0.4

_______________________________________________
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice

Reply via email to