summaryrefslogtreecommitdiff
path: root/editeng/source/editeng/editdoc.hxx
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2012-03-29 01:43:30 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2012-03-29 01:52:31 -0400
commitc802cbad7f25d3070f2ae5fd8a7e1a7ce17f99a9 (patch)
tree280c9b8143c5104406430e8c722236a485dd9be8 /editeng/source/editeng/editdoc.hxx
parent8bf6eb4519b4b92390570341a10872e65fd95dc1 (diff)
ContentList no longer a child class of DummyContentList (take 2).
The previous commit was bad as it would cause segfalut on startup. This one is good as far as I can tell.
Diffstat (limited to 'editeng/source/editeng/editdoc.hxx')
-rw-r--r--editeng/source/editeng/editdoc.hxx63
1 files changed, 42 insertions, 21 deletions
diff --git a/editeng/source/editeng/editdoc.hxx b/editeng/source/editeng/editdoc.hxx
index 7b7a9e555fda..0114c099e681 100644
--- a/editeng/source/editeng/editdoc.hxx
+++ b/editeng/source/editeng/editdoc.hxx
@@ -38,10 +38,12 @@
#include <svl/style.hxx>
#include <svl/itempool.hxx>
#include <tools/table.hxx>
-#include <vector>
+#include <vector>
#include <deque>
+#include <boost/ptr_container/ptr_vector.hpp>
+
class ImpEditEngine;
class SvxTabStop;
class SvtCTLOptions;
@@ -193,11 +195,13 @@ public:
SvxTabStop FindTabStop( long nCurPos, sal_uInt16 nDefTab );
SfxItemSet& GetItems() { return aAttribSet; }
- SfxStyleSheet* GetStyleSheet() const { return pStyle; }
+ const SfxItemSet& GetItems() const { return aAttribSet; }
+ const SfxStyleSheet* GetStyleSheet() const { return pStyle; }
+ SfxStyleSheet* GetStyleSheet() { return pStyle; }
void SetStyleSheet( SfxStyleSheet* pS );
- const SfxPoolItem& GetItem( sal_uInt16 nWhich );
- sal_Bool HasItem( sal_uInt16 nWhich );
+ const SfxPoolItem& GetItem( sal_uInt16 nWhich ) const;
+ bool HasItem( sal_uInt16 nWhich ) const;
};
// -------------------------------------------------------------------------
@@ -222,8 +226,10 @@ public:
void DeleteEmptyAttribs( SfxItemPool& rItemPool );
void RemoveItemsFromPool( SfxItemPool* pItemPool );
+ const EditCharAttrib* FindAttrib( sal_uInt16 nWhich, sal_uInt16 nPos ) const;
EditCharAttrib* FindAttrib( sal_uInt16 nWhich, sal_uInt16 nPos );
const EditCharAttrib* FindNextAttrib( sal_uInt16 nWhich, sal_uInt16 nFromPos ) const;
+ const EditCharAttrib* FindEmptyAttrib( sal_uInt16 nWhich, sal_uInt16 nPos ) const;
EditCharAttrib* FindEmptyAttrib( sal_uInt16 nWhich, sal_uInt16 nPos );
const EditCharAttrib* FindFeature( sal_uInt16 nPos ) const;
@@ -271,7 +277,9 @@ public:
~ContentNode();
ContentAttribs& GetContentAttribs() { return aContentAttribs; }
+ const ContentAttribs& GetContentAttribs() const { return aContentAttribs; }
CharAttribList& GetCharAttribs() { return aCharAttribList; }
+ const CharAttribList& GetCharAttribs() const { return aCharAttribList; }
void ExpandAttribs( sal_uInt16 nIndex, sal_uInt16 nNewChars, SfxItemPool& rItemPool );
void CollapsAttribs( sal_uInt16 nIndex, sal_uInt16 nDelChars, SfxItemPool& rItemPool );
@@ -281,10 +289,12 @@ public:
void SetStyleSheet( SfxStyleSheet* pS, sal_Bool bRecalcFont = sal_True );
void SetStyleSheet( SfxStyleSheet* pS, const SvxFont& rFontFromStyle );
SfxStyleSheet* GetStyleSheet() { return aContentAttribs.GetStyleSheet(); }
+ const SfxStyleSheet* GetStyleSheet() const { return aContentAttribs.GetStyleSheet(); }
void CreateDefFont();
WrongList* GetWrongList() { return pWrongList; }
+ const WrongList* GetWrongList() const { return pWrongList; }
void SetWrongList( WrongList* p );
void CreateWrongList();
@@ -293,15 +303,22 @@ public:
sal_Bool IsFeature( sal_uInt16 nPos ) const { return ( GetChar( nPos ) == CH_FEATURE ); }
};
-typedef ContentNode* ContentNodePtr;
-SV_DECL_PTRARR( DummyContentList, ContentNodePtr, 0 )
-
-class ContentList : public DummyContentList
+class ContentList
{
- mutable sal_uInt16 nLastCache;
+ mutable size_t nLastCache;
+ boost::ptr_vector<ContentNode> maContents;
public:
ContentList();
- sal_uInt16 GetPos(ContentNode* p) const;
+ size_t GetPos(const ContentNode* p) const;
+ const ContentNode* GetObject(size_t nPos) const;
+ ContentNode* GetObject(size_t nPos);
+ const ContentNode* operator[](size_t nPos) const;
+ ContentNode* operator[](size_t nPos);
+
+ void Insert(size_t nPos, ContentNode* p);
+ void Remove(size_t nPos);
+ size_t Count() const;
+ void Clear();
};
// -------------------------------------------------------------------------
@@ -310,15 +327,17 @@ public:
class EditPaM
{
private:
- ContentNode* pNode;
+ ContentNode* pNode;
sal_uInt16 nIndex;
public:
- EditPaM() { pNode = NULL; nIndex = 0; }
- EditPaM( ContentNode* p, sal_uInt16 n ) { pNode = p; nIndex = n; }
+ EditPaM();
+ EditPaM(const EditPaM& r);
+ EditPaM(ContentNode* p, sal_uInt16 n);
- ContentNode* GetNode() const { return pNode; }
- void SetNode( ContentNode* p) { pNode = p; }
+ const ContentNode* GetNode() const;
+ ContentNode* GetNode();
+ void SetNode(ContentNode* p);
sal_uInt16 GetIndex() const { return nIndex; }
sal_uInt16& GetIndex() { return nIndex; }
@@ -758,7 +777,7 @@ public:
EditPaM Clear();
EditPaM RemoveText();
EditPaM RemoveChars( EditPaM aPaM, sal_uInt16 nChars );
- void InsertText( const EditPaM& rPaM, xub_Unicode c );
+ void InsertText( EditPaM& rPaM, xub_Unicode c );
EditPaM InsertText( EditPaM aPaM, const XubString& rStr );
EditPaM InsertParaBreak( EditPaM aPaM, sal_Bool bKeepEndingAttribs );
EditPaM InsertFeature( EditPaM aPaM, const SfxPoolItem& rItem );
@@ -768,7 +787,7 @@ public:
sal_uLong GetTextLen() const;
XubString GetParaAsString( sal_uInt16 nNode ) const;
- XubString GetParaAsString( ContentNode* pNode, sal_uInt16 nStartPos = 0, sal_uInt16 nEndPos = 0xFFFF, sal_Bool bResolveFields = sal_True ) const;
+ XubString GetParaAsString(const ContentNode* pNode, sal_uInt16 nStartPos = 0, sal_uInt16 nEndPos = 0xFFFF, bool bResolveFields = true) const;
inline EditPaM GetStartPaM() const;
inline EditPaM GetEndPaM() const;
@@ -785,20 +804,22 @@ public:
sal_Bool RemoveAttribs( ContentNode* pNode, sal_uInt16 nStart, sal_uInt16 nEnd, EditCharAttrib*& rpStarting, EditCharAttrib*& rpEnding, sal_uInt16 nWhich = 0 );
void FindAttribs( ContentNode* pNode, sal_uInt16 nStartPos, sal_uInt16 nEndPos, SfxItemSet& rCurSet );
- sal_uInt16 GetPos( ContentNode* pNode ) const { return ContentList::GetPos(pNode); }
- ContentNode* SaveGetObject( sal_uInt16 nPos ) const { return ( nPos < Count() ) ? GetObject( nPos ) : 0; }
+ sal_uInt16 GetPos( const ContentNode* pNode ) const { return ContentList::GetPos(pNode); }
+ const ContentNode* SaveGetObject(size_t nPos) const;
+ ContentNode* SaveGetObject(size_t nPos);
static XubString GetSepStr( LineEnd eEnd );
};
inline EditPaM EditDoc::GetStartPaM() const
{
- return EditPaM( GetObject( 0 ), 0 );
+ ContentNode* p = const_cast<ContentNode*>(GetObject(0));
+ return EditPaM(p, 0);
}
inline EditPaM EditDoc::GetEndPaM() const
{
- ContentNode* pLastNode = GetObject( Count()-1 );
+ ContentNode* pLastNode = const_cast<ContentNode*>(GetObject(Count()-1));
return EditPaM( pLastNode, pLastNode->Len() );
}