summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-08-28 15:05:08 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-08-28 16:13:52 -0400
commit97001b1e48ba663dce111d413bdcea0727061572 (patch)
tree6d0b2785d572f50c37ce56229e172bf3c01435d9 /editeng
parentb129867306ce918f4f8fbf9ec5f7dce86e52c9d2 (diff)
Use smart pointers for these.
Change-Id: I1a1e38dd36b2144a3e6b96886a56a11a023c47fe
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/editeng/editdoc.cxx42
-rw-r--r--editeng/source/editeng/editdoc.hxx9
-rw-r--r--editeng/source/editeng/editobj.cxx29
-rw-r--r--editeng/source/editeng/editobj2.hxx9
-rw-r--r--editeng/source/editeng/impedit4.cxx1
5 files changed, 52 insertions, 38 deletions
diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx
index 65de34a381a8..8cd17b787c68 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -1299,20 +1299,17 @@ sal_Bool operator != ( const EditPaM& r1, const EditPaM& r2 )
ContentNode::ContentNode( SfxItemPool& rPool ) : aContentAttribs( rPool )
{
DBG_CTOR( EE_ContentNode, 0 );
- pWrongList = NULL;
}
ContentNode::ContentNode( const XubString& rStr, const ContentAttribs& rContentAttribs ) :
maString(rStr), aContentAttribs(rContentAttribs)
{
DBG_CTOR( EE_ContentNode, 0 );
- pWrongList = NULL;
}
ContentNode::~ContentNode()
{
DBG_DTOR( EE_ContentNode, 0 );
- delete pWrongList;
}
void ContentNode::ExpandAttribs( sal_uInt16 nIndex, sal_uInt16 nNew, SfxItemPool& rItemPool )
@@ -1440,10 +1437,10 @@ void ContentNode::ExpandAttribs( sal_uInt16 nIndex, sal_uInt16 nNew, SfxItemPool
if ( bResort )
aCharAttribList.ResortAttribs();
- if ( pWrongList )
+ if (mpWrongList)
{
bool bSep = ( maString.GetChar( nIndex ) == ' ' ) || IsFeature( nIndex );
- pWrongList->TextInserted( nIndex, nNew, bSep );
+ mpWrongList->TextInserted( nIndex, nNew, bSep );
}
#if OSL_DEBUG_LEVEL > 2
@@ -1531,8 +1528,8 @@ void ContentNode::CollapsAttribs( sal_uInt16 nIndex, sal_uInt16 nDeleted, SfxIte
if ( bResort )
aCharAttribList.ResortAttribs();
- if ( pWrongList )
- pWrongList->TextDeleted( nIndex, nDeleted );
+ if (mpWrongList)
+ mpWrongList->TextDeleted(nIndex, nDeleted);
#if OSL_DEBUG_LEVEL > 2
OSL_ENSURE( CheckOrderedList( aCharAttribList.GetAttribs(), sal_True ), "Collaps: Start list distorted" );
@@ -1680,12 +1677,6 @@ void ContentNode::SetStyleSheet( SfxStyleSheet* pS, sal_Bool bRecalcFont )
CreateDefFont();
}
-void ContentNode::DestroyWrongList()
-{
- delete pWrongList;
- pWrongList = NULL;
-}
-
bool ContentNode::IsFeature( sal_uInt16 nPos ) const
{
return maString.GetChar(nPos) == CH_FEATURE;
@@ -1741,16 +1732,31 @@ sal_Unicode ContentNode::GetChar(sal_uInt16 nPos) const
return maString.GetChar(nPos);
}
-void ContentNode::CreateWrongList()
+WrongList* ContentNode::GetWrongList()
+{
+ return mpWrongList.get();
+}
+
+const WrongList* ContentNode::GetWrongList() const
{
- DBG_ASSERT( !pWrongList, "WrongList already exist!" );
- pWrongList = new WrongList;
+ return mpWrongList.get();
}
void ContentNode::SetWrongList( WrongList* p )
{
- DBG_ASSERT( !pWrongList, "WrongList already exist!" );
- pWrongList = p;
+ DBG_ASSERT(!mpWrongList, "WrongList already exist!");
+ mpWrongList.reset(p);
+}
+
+void ContentNode::CreateWrongList()
+{
+ DBG_ASSERT(!mpWrongList, "WrongList already exist!");
+ mpWrongList.reset(new WrongList);
+}
+
+void ContentNode::DestroyWrongList()
+{
+ mpWrongList.reset();
}
ContentAttribs::ContentAttribs( SfxItemPool& rPool ) :
diff --git a/editeng/source/editeng/editdoc.hxx b/editeng/source/editeng/editdoc.hxx
index 485d976cbc7a..1a6d1d0fd1fd 100644
--- a/editeng/source/editeng/editdoc.hxx
+++ b/editeng/source/editeng/editdoc.hxx
@@ -34,6 +34,7 @@
#include <boost/ptr_container/ptr_vector.hpp>
#include <boost/noncopyable.hpp>
+#include <boost/scoped_ptr.hpp>
class ImpEditEngine;
class SvxTabStop;
@@ -258,7 +259,7 @@ private:
XubString maString;
ContentAttribs aContentAttribs;
CharAttribList aCharAttribList;
- WrongList* pWrongList;
+ boost::scoped_ptr<WrongList> mpWrongList;
public:
ContentNode( SfxItemPool& rItemPool );
@@ -282,9 +283,9 @@ public:
void CreateDefFont();
- WrongList* GetWrongList() { return pWrongList; }
- const WrongList* GetWrongList() const { return pWrongList; }
- void SetWrongList( WrongList* p );
+ WrongList* GetWrongList();
+ const WrongList* GetWrongList() const;
+ void SetWrongList( WrongList* p );
void CreateWrongList();
void DestroyWrongList();
diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx
index 0a6700942ad0..b730e72c8e2f 100644
--- a/editeng/source/editeng/editobj.cxx
+++ b/editeng/source/editeng/editobj.cxx
@@ -112,22 +112,21 @@ const XParaPortion& XParaPortionList::operator [](size_t i) const
return maList[i];
}
-ContentInfo::ContentInfo( SfxItemPool& rPool ) : aParaAttribs( rPool, EE_PARA_START, EE_CHAR_END )
+ContentInfo::ContentInfo( SfxItemPool& rPool ) :
+ eFamily(SFX_STYLE_FAMILY_PARA),
+ aParaAttribs(rPool, EE_PARA_START, EE_CHAR_END)
{
- eFamily = SFX_STYLE_FAMILY_PARA;
- pWrongs = NULL;
}
// the real Copy constructor is nonsens, since I have to work with another Pool!
-ContentInfo::ContentInfo( const ContentInfo& rCopyFrom, SfxItemPool& rPoolToUse )
- : aParaAttribs( rPoolToUse, EE_PARA_START, EE_CHAR_END )
- , pWrongs(0)
+ContentInfo::ContentInfo( const ContentInfo& rCopyFrom, SfxItemPool& rPoolToUse ) :
+ aText(rCopyFrom.aText),
+ aStyle(rCopyFrom.aStyle),
+ eFamily(rCopyFrom.eFamily),
+ aParaAttribs(rPoolToUse, EE_PARA_START, EE_CHAR_END)
{
// this should ensure that the Items end up in the correct Pool!
aParaAttribs.Set( rCopyFrom.GetParaAttribs() );
- aText = rCopyFrom.GetText();
- aStyle = rCopyFrom.GetStyle();
- eFamily = rCopyFrom.GetFamily();
for (size_t i = 0; i < rCopyFrom.aAttribs.size(); ++i)
{
@@ -138,7 +137,7 @@ ContentInfo::ContentInfo( const ContentInfo& rCopyFrom, SfxItemPool& rPoolToUse
}
if ( rCopyFrom.GetWrongList() )
- pWrongs = rCopyFrom.GetWrongList()->Clone();
+ mpWrongs.reset(rCopyFrom.GetWrongList()->Clone());
}
ContentInfo::~ContentInfo()
@@ -147,8 +146,16 @@ ContentInfo::~ContentInfo()
for (; it != itEnd; ++it)
aParaAttribs.GetPool()->Remove(*it->GetItem());
aAttribs.clear();
+}
- delete pWrongs;
+WrongList* ContentInfo::GetWrongList() const
+{
+ return mpWrongs.get();
+}
+
+void ContentInfo::SetWrongList( WrongList* p )
+{
+ mpWrongs.reset(p);
}
// #i102062#
diff --git a/editeng/source/editeng/editobj2.hxx b/editeng/source/editeng/editobj2.hxx
index 8d7fd6d19dab..801abe805556 100644
--- a/editeng/source/editeng/editobj2.hxx
+++ b/editeng/source/editeng/editobj2.hxx
@@ -27,6 +27,7 @@
#include <boost/ptr_container/ptr_vector.hpp>
#include <boost/noncopyable.hpp>
+#include <boost/scoped_ptr.hpp>
namespace editeng {
@@ -114,7 +115,7 @@ public:
};
-class ContentInfo
+class ContentInfo : boost::noncopyable
{
friend class EditTextObjectImpl;
public:
@@ -127,7 +128,7 @@ private:
XEditAttributesType aAttribs;
SfxStyleFamily eFamily;
SfxItemSet aParaAttribs;
- WrongList* pWrongs;
+ boost::scoped_ptr<WrongList> mpWrongs;
ContentInfo( SfxItemPool& rPool );
ContentInfo( const ContentInfo& rCopyFrom, SfxItemPool& rPoolToUse );
@@ -148,8 +149,8 @@ public:
SfxItemSet& GetParaAttribs() { return aParaAttribs; }
SfxStyleFamily& GetFamily() { return eFamily; }
- WrongList* GetWrongList() const { return pWrongs; }
- void SetWrongList( WrongList* p ) { pWrongs = p; }
+ WrongList* GetWrongList() const;
+ void SetWrongList( WrongList* p );
bool operator==( const ContentInfo& rCompare ) const;
bool operator!=( const ContentInfo& rCompare ) const;
diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx
index 3b5bac35ac71..004bdcb2b97c 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -1373,7 +1373,6 @@ EditSelection ImpEditEngine::InsertTextObject( const EditTextObject& rTextObject
if ( bNewContent && GetStatus().DoOnlineSpelling() && pC->GetWrongList() )
{
- aPaM.GetNode()->DestroyWrongList(); // otherwise MLK, if list exists...
aPaM.GetNode()->SetWrongList( pC->GetWrongList()->Clone() );
}