summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2012-03-28 12:33:21 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2012-03-28 12:46:33 -0400
commitb35980d9b28f1e3985f94238f7d8c9962f654bd0 (patch)
treed009ce569c432bf8654c4648741ef8da97823efe
parent86a1e6de4fc3af897271bc5f7f04506261d4f286 (diff)
Move away from SV_DECL_PTRARR in CharAttribList.
This is a huge change. I'm sure I broke something somewhere...
-rw-r--r--editeng/source/editeng/editattr.cxx20
-rw-r--r--editeng/source/editeng/editattr.hxx45
-rw-r--r--editeng/source/editeng/editdoc.cxx423
-rw-r--r--editeng/source/editeng/editdoc.hxx36
-rw-r--r--editeng/source/editeng/editeng.cxx42
-rw-r--r--editeng/source/editeng/editview.cxx14
-rw-r--r--editeng/source/editeng/edtspell.cxx22
-rw-r--r--editeng/source/editeng/impedit.cxx18
-rw-r--r--editeng/source/editeng/impedit2.cxx58
-rw-r--r--editeng/source/editeng/impedit3.cxx36
-rw-r--r--editeng/source/editeng/impedit4.cxx4
-rw-r--r--editeng/source/editeng/impedit5.cxx66
12 files changed, 425 insertions, 359 deletions
diff --git a/editeng/source/editeng/editattr.cxx b/editeng/source/editeng/editattr.cxx
index 8c7677a37968..171eb3652ed9 100644
--- a/editeng/source/editeng/editattr.cxx
+++ b/editeng/source/editeng/editattr.cxx
@@ -66,6 +66,12 @@ EditAttrib::EditAttrib( const SfxPoolItem& rAttr )
66 pItem = &rAttr; 66 pItem = &rAttr;
67} 67}
68 68
69EditAttrib::EditAttrib(const EditAttrib& r) :
70 pItem(r.pItem)
71{
72 DBG_CTOR( EE_EditAttrib, 0 );
73}
74
69EditAttrib::~EditAttrib() 75EditAttrib::~EditAttrib()
70{ 76{
71 DBG_DTOR( EE_EditAttrib, 0 ); 77 DBG_DTOR( EE_EditAttrib, 0 );
@@ -74,18 +80,18 @@ EditAttrib::~EditAttrib()
74// ------------------------------------------------------------------------- 80// -------------------------------------------------------------------------
75// class EditCharAttrib 81// class EditCharAttrib
76// ------------------------------------------------------------------------- 82// -------------------------------------------------------------------------
77EditCharAttrib::EditCharAttrib( const SfxPoolItem& rAttr, sal_uInt16 nS, sal_uInt16 nE ) 83EditCharAttrib::EditCharAttrib( const SfxPoolItem& rAttr, sal_uInt16 nS, sal_uInt16 nE ) :
78 : EditAttrib( rAttr ) 84 EditAttrib(rAttr),
85 nStart(nS), nEnd(nE), bFeature(false), bEdge(false)
79{ 86{
80 nStart = nS;
81 nEnd = nE;
82 bFeature = sal_False;
83 bEdge = sal_False;
84
85 DBG_ASSERT( ( rAttr.Which() >= EE_ITEMS_START ) && ( rAttr.Which() <= EE_ITEMS_END ), "EditCharAttrib CTOR: Invalid id!" ); 87 DBG_ASSERT( ( rAttr.Which() >= EE_ITEMS_START ) && ( rAttr.Which() <= EE_ITEMS_END ), "EditCharAttrib CTOR: Invalid id!" );
86 DBG_ASSERT( ( rAttr.Which() < EE_FEATURE_START ) || ( rAttr.Which() > EE_FEATURE_END ) || ( nE == (nS+1) ), "EditCharAttrib CTOR: Invalid feature!" ); 88 DBG_ASSERT( ( rAttr.Which() < EE_FEATURE_START ) || ( rAttr.Which() > EE_FEATURE_END ) || ( nE == (nS+1) ), "EditCharAttrib CTOR: Invalid feature!" );
87} 89}
88 90
91EditCharAttrib::EditCharAttrib(const EditCharAttrib& r) :
92 EditAttrib(r),
93 nStart(r.nStart), nEnd(r.nEnd), bFeature(r.bFeature), bEdge(r.bEdge) {}
94
89void EditCharAttrib::SetFont( SvxFont&, OutputDevice* ) 95void EditCharAttrib::SetFont( SvxFont&, OutputDevice* )
90{ 96{
91} 97}
diff --git a/editeng/source/editeng/editattr.hxx b/editeng/source/editeng/editattr.hxx
index 8e820848a209..0ad35a23e5e4 100644
--- a/editeng/source/editeng/editattr.hxx
+++ b/editeng/source/editeng/editattr.hxx
@@ -71,14 +71,14 @@ class SfxVoidItem;
71class EditAttrib 71class EditAttrib
72{ 72{
73private: 73private:
74 EditAttrib() {;} 74 EditAttrib();
75 EditAttrib( const EditAttrib & ) {;}
76 75
77protected: 76protected:
78 const SfxPoolItem* pItem; 77 const SfxPoolItem* pItem;
79 78
80 EditAttrib( const SfxPoolItem& rAttr ); 79 EditAttrib( const SfxPoolItem& rAttr );
81 virtual ~EditAttrib(); 80 EditAttrib(const EditAttrib& r);
81 virtual ~EditAttrib();
82 82
83public: 83public:
84 // RemoveFromPool must always be called before the destructor!! 84 // RemoveFromPool must always be called before the destructor!!
@@ -103,7 +103,8 @@ protected:
103 sal_Bool bEdge :1; 103 sal_Bool bEdge :1;
104 104
105public: 105public:
106 EditCharAttrib( const SfxPoolItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd ); 106 EditCharAttrib( const SfxPoolItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
107 EditCharAttrib(const EditCharAttrib& r);
107 108
108 sal_uInt16& GetStart() { return nStart; } 109 sal_uInt16& GetStart() { return nStart; }
109 sal_uInt16& GetEnd() { return nEnd; } 110 sal_uInt16& GetEnd() { return nEnd; }
@@ -180,7 +181,7 @@ public:
180 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ); 181 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
181}; 182};
182 183
183 // ------------------------------------------------------------------------- 184// -------------------------------------------------------------------------
184// class EditCharAttribWeight 185// class EditCharAttribWeight
185// ------------------------------------------------------------------------- 186// -------------------------------------------------------------------------
186class EditCharAttribWeight : public EditCharAttrib 187class EditCharAttribWeight : public EditCharAttrib
@@ -190,7 +191,7 @@ public:
190 191
191 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ); 192 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
192}; 193};
193 // ------------------------------------------------------------------------- 194// -------------------------------------------------------------------------
194// class EditCharAttribItalic 195// class EditCharAttribItalic
195// ------------------------------------------------------------------------- 196// -------------------------------------------------------------------------
196class EditCharAttribItalic : public EditCharAttrib 197class EditCharAttribItalic : public EditCharAttrib
@@ -201,7 +202,7 @@ public:
201 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ); 202 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
202}; 203};
203 204
204 // ------------------------------------------------------------------------- 205// -------------------------------------------------------------------------
205// class EditCharAttribShadow 206// class EditCharAttribShadow
206// ------------------------------------------------------------------------- 207// -------------------------------------------------------------------------
207class EditCharAttribShadow : public EditCharAttrib 208class EditCharAttribShadow : public EditCharAttrib
@@ -212,7 +213,7 @@ public:
212 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ); 213 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
213}; 214};
214 215
215 // ------------------------------------------------------------------------- 216// -------------------------------------------------------------------------
216// class EditCharAttribEscapement 217// class EditCharAttribEscapement
217// ------------------------------------------------------------------------- 218// -------------------------------------------------------------------------
218class EditCharAttribEscapement : public EditCharAttrib 219class EditCharAttribEscapement : public EditCharAttrib
@@ -223,7 +224,7 @@ public:
223 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ); 224 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
224}; 225};
225 226
226 // ------------------------------------------------------------------------- 227// -------------------------------------------------------------------------
227// class EditCharAttribOutline 228// class EditCharAttribOutline
228// ------------------------------------------------------------------------- 229// -------------------------------------------------------------------------
229class EditCharAttribOutline : public EditCharAttrib 230class EditCharAttribOutline : public EditCharAttrib
@@ -234,7 +235,7 @@ public:
234 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ); 235 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
235}; 236};
236 237
237 // ------------------------------------------------------------------------- 238// -------------------------------------------------------------------------
238// class EditCharAttribStrikeout 239// class EditCharAttribStrikeout
239// ------------------------------------------------------------------------- 240// -------------------------------------------------------------------------
240class EditCharAttribStrikeout : public EditCharAttrib 241class EditCharAttribStrikeout : public EditCharAttrib
@@ -245,7 +246,7 @@ public:
245 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ); 246 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
246}; 247};
247 248
248 // ------------------------------------------------------------------------- 249// -------------------------------------------------------------------------
249// class EditCharAttribUnderline 250// class EditCharAttribUnderline
250// ------------------------------------------------------------------------- 251// -------------------------------------------------------------------------
251class EditCharAttribUnderline : public EditCharAttrib 252class EditCharAttribUnderline : public EditCharAttrib
@@ -289,7 +290,7 @@ public:
289 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ); 290 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
290}; 291};
291 292
292 // ------------------------------------------------------------------------- 293// -------------------------------------------------------------------------
293// class EditCharAttribFontHeight 294// class EditCharAttribFontHeight
294// ------------------------------------------------------------------------- 295// -------------------------------------------------------------------------
295class EditCharAttribFontHeight : public EditCharAttrib 296class EditCharAttribFontHeight : public EditCharAttrib
@@ -300,7 +301,7 @@ public:
300 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ); 301 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
301}; 302};
302 303
303 // ------------------------------------------------------------------------- 304// -------------------------------------------------------------------------
304// class EditCharAttribFontWidth 305// class EditCharAttribFontWidth
305// ------------------------------------------------------------------------- 306// -------------------------------------------------------------------------
306class EditCharAttribFontWidth : public EditCharAttrib 307class EditCharAttribFontWidth : public EditCharAttrib
@@ -311,7 +312,7 @@ public:
311 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ); 312 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
312}; 313};
313 314
314 // ------------------------------------------------------------------------- 315// -------------------------------------------------------------------------
315// class EditCharAttribColor 316// class EditCharAttribColor
316// ------------------------------------------------------------------------- 317// -------------------------------------------------------------------------
317class EditCharAttribColor : public EditCharAttrib 318class EditCharAttribColor : public EditCharAttrib
@@ -322,7 +323,7 @@ public:
322 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ); 323 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
323}; 324};
324 325
325 // ------------------------------------------------------------------------- 326// -------------------------------------------------------------------------
326// class EditCharAttribLanguage 327// class EditCharAttribLanguage
327// ------------------------------------------------------------------------- 328// -------------------------------------------------------------------------
328class EditCharAttribLanguage : public EditCharAttrib 329class EditCharAttribLanguage : public EditCharAttrib
@@ -333,7 +334,7 @@ public:
333 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ); 334 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
334}; 335};
335 336
336 // ------------------------------------------------------------------------- 337// -------------------------------------------------------------------------
337// class EditCharAttribTab 338// class EditCharAttribTab
338// ------------------------------------------------------------------------- 339// -------------------------------------------------------------------------
339class EditCharAttribTab : public EditCharAttrib 340class EditCharAttribTab : public EditCharAttrib
@@ -344,7 +345,7 @@ public:
344 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ); 345 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
345}; 346};
346 347
347 // ------------------------------------------------------------------------- 348// -------------------------------------------------------------------------
348// class EditCharAttribLineBreak 349// class EditCharAttribLineBreak
349// ------------------------------------------------------------------------- 350// -------------------------------------------------------------------------
350class EditCharAttribLineBreak : public EditCharAttrib 351class EditCharAttribLineBreak : public EditCharAttrib
@@ -355,7 +356,7 @@ public:
355 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ); 356 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
356}; 357};
357 358
358 // ------------------------------------------------------------------------- 359// -------------------------------------------------------------------------
359// class EditCharAttribField 360// class EditCharAttribField
360// ------------------------------------------------------------------------- 361// -------------------------------------------------------------------------
361class EditCharAttribField: public EditCharAttrib 362class EditCharAttribField: public EditCharAttrib
@@ -390,7 +391,7 @@ public:
390 } 391 }
391}; 392};
392 393
393 // ------------------------------------------------------------------------- 394// -------------------------------------------------------------------------
394// class EditCharAttribPairKerning 395// class EditCharAttribPairKerning
395// ------------------------------------------------------------------------- 396// -------------------------------------------------------------------------
396class EditCharAttribPairKerning : public EditCharAttrib 397class EditCharAttribPairKerning : public EditCharAttrib
@@ -401,7 +402,7 @@ public:
401 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ); 402 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
402}; 403};
403 404
404 // ------------------------------------------------------------------------- 405// -------------------------------------------------------------------------
405// class EditCharAttribKerning 406// class EditCharAttribKerning
406// ------------------------------------------------------------------------- 407// -------------------------------------------------------------------------
407class EditCharAttribKerning : public EditCharAttrib 408class EditCharAttribKerning : public EditCharAttrib
@@ -412,7 +413,7 @@ public:
412 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ); 413 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
413}; 414};
414 415
415 // ------------------------------------------------------------------------- 416// -------------------------------------------------------------------------
416// class EditCharAttribWordLineMode 417// class EditCharAttribWordLineMode
417// ------------------------------------------------------------------------- 418// -------------------------------------------------------------------------
418class EditCharAttribWordLineMode: public EditCharAttrib 419class EditCharAttribWordLineMode: public EditCharAttrib
diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx
index 98268d90a9c8..f83d05420aa7 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -63,7 +63,8 @@
63#include <tools/shl.hxx> 63#include <tools/shl.hxx>
64#include <vcl/svapp.hxx> 64#include <vcl/svapp.hxx>
65#include <com/sun/star/i18n/ScriptType.hpp> 65#include <com/sun/star/i18n/ScriptType.hpp>
66#include <stdlib.h> // qsort 66
67#include <boost/bind.hpp>
67 68
68using namespace ::com::sun::star; 69using namespace ::com::sun::star;
69 70
@@ -257,15 +258,6 @@ sal_uInt16 aV5Map[] = {
257 258
258SV_IMPL_PTRARR( DummyContentList, ContentNode* ); 259SV_IMPL_PTRARR( DummyContentList, ContentNode* );
259 260
260int SAL_CALL CompareStart( const void* pFirst, const void* pSecond )
261{
262 if ( (*((EditCharAttrib**)pFirst))->GetStart() < (*((EditCharAttrib**)pSecond))->GetStart() )
263 return (-1);
264 else if ( (*((EditCharAttrib**)pFirst))->GetStart() > (*((EditCharAttrib**)pSecond))->GetStart() )
265 return (1);
266 return 0;
267}
268
269EditCharAttrib* MakeCharAttrib( SfxItemPool& rPool, const SfxPoolItem& rAttr, sal_uInt16 nS, sal_uInt16 nE ) 261EditCharAttrib* MakeCharAttrib( SfxItemPool& rPool, const SfxPoolItem& rAttr, sal_uInt16 nS, sal_uInt16 nE )
270{ 262{
271 // Create a new attribute in the pool 263 // Create a new attribute in the pool
@@ -719,11 +711,12 @@ void ContentNode::ExpandAttribs( sal_uInt16 nIndex, sal_uInt16 nNew, SfxItemPool
719 // an existing special case, must (n-1) opportunities be provided with 711 // an existing special case, must (n-1) opportunities be provided with
720 // bResort. The most likely possibility receives no bResort, so that is 712 // bResort. The most likely possibility receives no bResort, so that is
721 // not sorted anew when all attributes are the same. 713 // not sorted anew when all attributes are the same.
722 sal_Bool bResort = sal_False; 714 bool bResort = false;
723 sal_Bool bExpandedEmptyAtIndexNull = sal_False; 715 bool bExpandedEmptyAtIndexNull = false;
724 716
725 sal_uInt16 nAttr = 0; 717 size_t nAttr = 0;
726 EditCharAttrib* pAttrib = GetAttrib( aCharAttribList.GetAttribs(), nAttr ); 718 CharAttribList::AttribsType& rAttribs = aCharAttribList.GetAttribs();
719 EditCharAttrib* pAttrib = GetAttrib(rAttribs, nAttr);
727 while ( pAttrib ) 720 while ( pAttrib )
728 { 721 {
729 if ( pAttrib->GetEnd() >= nIndex ) 722 if ( pAttrib->GetEnd() >= nIndex )
@@ -777,7 +770,7 @@ void ContentNode::ExpandAttribs( sal_uInt16 nIndex, sal_uInt16 nNew, SfxItemPool
777 } 770 }
778 else 771 else
779 { 772 {
780 sal_Bool bExpand = sal_False; 773 bool bExpand = false;
781 if ( nIndex == 0 ) 774 if ( nIndex == 0 )
782 { 775 {
783 bExpand = sal_True; 776 bExpand = sal_True;
@@ -787,10 +780,10 @@ void ContentNode::ExpandAttribs( sal_uInt16 nIndex, sal_uInt16 nNew, SfxItemPool
787 sal_uInt16 nW = pAttrib->GetItem()->Which(); 780 sal_uInt16 nW = pAttrib->GetItem()->Which();
788 for ( sal_uInt16 nA = 0; nA < nAttr; nA++ ) 781 for ( sal_uInt16 nA = 0; nA < nAttr; nA++ )
789 { 782 {
790 EditCharAttrib* pA = aCharAttribList.GetAttribs()[nA]; 783 const EditCharAttrib& r = aCharAttribList.GetAttribs()[nA];
791 if ( ( pA->GetStart() == 0 ) && ( pA->GetItem()->Which() == nW ) ) 784 if ( ( r.GetStart() == 0 ) && ( r.GetItem()->Which() == nW ) )
792 { 785 {
793 bExpand = sal_False; 786 bExpand = false;
794 break; 787 break;
795 } 788 }
796 } 789 }
@@ -800,7 +793,7 @@ void ContentNode::ExpandAttribs( sal_uInt16 nIndex, sal_uInt16 nNew, SfxItemPool
800 if ( bExpand ) 793 if ( bExpand )
801 { 794 {
802 pAttrib->Expand( nNew ); 795 pAttrib->Expand( nNew );
803 bResort = sal_True; 796 bResort = true;
804 } 797 }
805 else 798 else
806 { 799 {
@@ -811,7 +804,7 @@ void ContentNode::ExpandAttribs( sal_uInt16 nIndex, sal_uInt16 nNew, SfxItemPool
811 } 804 }
812 805
813 if ( pAttrib->IsEdge() ) 806 if ( pAttrib->IsEdge() )
814 pAttrib->SetEdge( sal_False ); 807 pAttrib->SetEdge(false);
815 808
816 DBG_ASSERT( !pAttrib->IsFeature() || ( pAttrib->GetLen() == 1 ), "Expand: FeaturesLen != 1" ); 809 DBG_ASSERT( !pAttrib->IsFeature() || ( pAttrib->GetLen() == 1 ), "Expand: FeaturesLen != 1" );
817 810
@@ -820,14 +813,13 @@ void ContentNode::ExpandAttribs( sal_uInt16 nIndex, sal_uInt16 nNew, SfxItemPool
820 if ( pAttrib->IsEmpty() ) 813 if ( pAttrib->IsEmpty() )
821 { 814 {
822 OSL_FAIL( "Empty Attribute after ExpandAttribs?" ); 815 OSL_FAIL( "Empty Attribute after ExpandAttribs?" );
823 bResort = sal_True; 816 bResort = true;
824 aCharAttribList.GetAttribs().Remove( nAttr );
825 rItemPool.Remove( *pAttrib->GetItem() ); 817 rItemPool.Remove( *pAttrib->GetItem() );
826 delete pAttrib; 818 rAttribs.erase(rAttribs.begin()+nAttr);
827 nAttr--; 819 --nAttr;
828 } 820 }
829 nAttr++; 821 ++nAttr;
830 pAttrib = GetAttrib( aCharAttribList.GetAttribs(), nAttr ); 822 pAttrib = GetAttrib(rAttribs, nAttr);
831 } 823 }
832 824
833 if ( bResort ) 825 if ( bResort )
@@ -851,15 +843,16 @@ void ContentNode::CollapsAttribs( sal_uInt16 nIndex, sal_uInt16 nDeleted, SfxIte
851 843
852 // Since features are treated differently than normal character attributes, 844 // Since features are treated differently than normal character attributes,
853 // can also the order of the start list be change! 845 // can also the order of the start list be change!
854 sal_Bool bResort = sal_False; 846 bool bResort = false;
855 sal_Bool bDelAttr = sal_False; 847 bool bDelAttr = false;
856 sal_uInt16 nEndChanges = nIndex+nDeleted; 848 sal_uInt16 nEndChanges = nIndex+nDeleted;
857 849
858 sal_uInt16 nAttr = 0; 850 size_t nAttr = 0;
859 EditCharAttrib* pAttrib = GetAttrib( aCharAttribList.GetAttribs(), nAttr ); 851 CharAttribList::AttribsType& rAttribs = aCharAttribList.GetAttribs();
852 EditCharAttrib* pAttrib = GetAttrib(rAttribs, nAttr);
860 while ( pAttrib ) 853 while ( pAttrib )
861 { 854 {
862 bDelAttr = sal_False; 855 bDelAttr = false;
863 if ( pAttrib->GetEnd() >= nIndex ) 856 if ( pAttrib->GetEnd() >= nIndex )
864 { 857 {
865 // Move all Attribute behind the insert point... 858 // Move all Attribute behind the insert point...
@@ -908,17 +901,16 @@ void ContentNode::CollapsAttribs( sal_uInt16 nIndex, sal_uInt16 nDeleted, SfxIte
908 DBG_ASSERT( ( pAttrib->GetEnd() <= Len()) || bDelAttr, "Collaps: Attribute larger than paragraph!" ); 901 DBG_ASSERT( ( pAttrib->GetEnd() <= Len()) || bDelAttr, "Collaps: Attribute larger than paragraph!" );
909 if ( bDelAttr ) 902 if ( bDelAttr )
910 { 903 {
911 bResort = sal_True; 904 bResort = true;
912 aCharAttribList.GetAttribs().Remove( nAttr );
913 rItemPool.Remove( *pAttrib->GetItem() ); 905 rItemPool.Remove( *pAttrib->GetItem() );
914 delete pAttrib; 906 rAttribs.erase(rAttribs.begin()+nAttr);
915 nAttr--; 907 nAttr--;
916 } 908 }
917 else if ( pAttrib->IsEmpty() ) 909 else if ( pAttrib->IsEmpty() )
918 aCharAttribList.HasEmptyAttribs() = sal_True; 910 aCharAttribList.SetHasEmptyAttribs(true);
919 911
920 nAttr++; 912 nAttr++;
921 pAttrib = GetAttrib( aCharAttribList.GetAttribs(), nAttr ); 913 pAttrib = GetAttrib(rAttribs, nAttr);
922 } 914 }
923 915
924 if ( bResort ) 916 if ( bResort )
@@ -938,8 +930,9 @@ void ContentNode::CopyAndCutAttribs( ContentNode* pPrevNode, SfxItemPool& rPool,
938 930
939 xub_StrLen nCut = pPrevNode->Len(); 931 xub_StrLen nCut = pPrevNode->Len();
940 932
941 sal_uInt16 nAttr = 0; 933 size_t nAttr = 0;
942 EditCharAttrib* pAttrib = GetAttrib( pPrevNode->GetCharAttribs().GetAttribs(), nAttr ); 934 CharAttribList::AttribsType& rPrevAttribs = pPrevNode->GetCharAttribs().GetAttribs();
935 EditCharAttrib* pAttrib = GetAttrib(rPrevAttribs, nAttr);
943 while ( pAttrib ) 936 while ( pAttrib )
944 { 937 {
945 if ( pAttrib->GetEnd() < nCut ) 938 if ( pAttrib->GetEnd() < nCut )
@@ -969,9 +962,9 @@ void ContentNode::CopyAndCutAttribs( ContentNode* pPrevNode, SfxItemPool& rPool,
969 else 962 else
970 { 963 {
971 // Move all attributes in the current node (this) 964 // Move all attributes in the current node (this)
972// pPrevNode->GetCharAttribs().RemoveAttrib( pAttrib ); 965 CharAttribList::AttribsType::iterator it = rPrevAttribs.begin() + nAttr;
973 pPrevNode->GetCharAttribs().GetAttribs().Remove( nAttr ); 966 aCharAttribList.InsertAttrib(rPrevAttribs.release(it).release());
974 aCharAttribList.InsertAttrib( pAttrib ); 967
975 DBG_ASSERT( pAttrib->GetStart() >= nCut, "Start < nCut!" ); 968 DBG_ASSERT( pAttrib->GetStart() >= nCut, "Start < nCut!" );
976 DBG_ASSERT( pAttrib->GetEnd() >= nCut, "End < nCut!" ); 969 DBG_ASSERT( pAttrib->GetEnd() >= nCut, "End < nCut!" );
977 pAttrib->GetStart() = pAttrib->GetStart() - nCut; 970 pAttrib->GetStart() = pAttrib->GetStart() - nCut;
@@ -979,7 +972,7 @@ void ContentNode::CopyAndCutAttribs( ContentNode* pPrevNode, SfxItemPool& rPool,
979 nAttr--; 972 nAttr--;
980 } 973 }
981 nAttr++; 974 nAttr++;
982 pAttrib = GetAttrib( pPrevNode->GetCharAttribs().GetAttribs(), nAttr ); 975 pAttrib = GetAttrib(rPrevAttribs, nAttr);
983 } 976 }
984} 977}
985 978
@@ -993,16 +986,17 @@ void ContentNode::AppendAttribs( ContentNode* pNextNode )
993 OSL_ENSURE( aCharAttribList.DbgCheckAttribs(), "Attribute before AppendAttribs broken" ); 986 OSL_ENSURE( aCharAttribList.DbgCheckAttribs(), "Attribute before AppendAttribs broken" );
994#endif 987#endif
995 988
996 sal_uInt16 nAttr = 0; 989 size_t nAttr = 0;
997 EditCharAttrib* pAttrib = GetAttrib( pNextNode->GetCharAttribs().GetAttribs(), nAttr ); 990 CharAttribList::AttribsType& rNextAttribs = pNextNode->GetCharAttribs().GetAttribs();
991 EditCharAttrib* pAttrib = GetAttrib(rNextAttribs, nAttr);
998 while ( pAttrib ) 992 while ( pAttrib )
999 { 993 {
1000 // Move all attributes in the current node (this) 994 // Move all attributes in the current node (this)
1001 sal_Bool bMelted = sal_False; 995 bool bMelted = false;
1002 if ( ( pAttrib->GetStart() == 0 ) && ( !pAttrib->IsFeature() ) ) 996 if ( ( pAttrib->GetStart() == 0 ) && ( !pAttrib->IsFeature() ) )
1003 { 997 {
1004 // Attributes can possibly be summarized as: 998 // Attributes can possibly be summarized as:
1005 sal_uInt16 nTmpAttr = 0; 999 size_t nTmpAttr = 0;
1006 EditCharAttrib* pTmpAttrib = GetAttrib( aCharAttribList.GetAttribs(), nTmpAttr ); 1000 EditCharAttrib* pTmpAttrib = GetAttrib( aCharAttribList.GetAttribs(), nTmpAttr );
1007 while ( !bMelted && pTmpAttrib ) 1001 while ( !bMelted && pTmpAttrib )
1008 { 1002 {
@@ -1013,10 +1007,9 @@ void ContentNode::AppendAttribs( ContentNode* pNextNode )
1013 { 1007 {
1014 pTmpAttrib->GetEnd() = 1008 pTmpAttrib->GetEnd() =
1015 pTmpAttrib->GetEnd() + pAttrib->GetLen(); 1009 pTmpAttrib->GetEnd() + pAttrib->GetLen();
1016 pNextNode->GetCharAttribs().GetAttribs().Remove( nAttr ); 1010 rNextAttribs.erase(rNextAttribs.begin()+nAttr);
1017 // Unsubscribe from the pool?! 1011 // Unsubscribe from the pool?!
1018 delete pAttrib; 1012 bMelted = true;
1019 bMelted = sal_True;
1020 } 1013 }
1021 } 1014 }
1022 ++nTmpAttr; 1015 ++nTmpAttr;
@@ -1028,13 +1021,13 @@ void ContentNode::AppendAttribs( ContentNode* pNextNode )
1028 { 1021 {
1029 pAttrib->GetStart() = pAttrib->GetStart() + nNewStart; 1022 pAttrib->GetStart() = pAttrib->GetStart() + nNewStart;
1030 pAttrib->GetEnd() = pAttrib->GetEnd() + nNewStart; 1023 pAttrib->GetEnd() = pAttrib->GetEnd() + nNewStart;
1031 aCharAttribList.InsertAttrib( pAttrib ); 1024 CharAttribList::AttribsType::iterator it = rNextAttribs.begin() + nAttr;
1032 ++nAttr; 1025 aCharAttribList.InsertAttrib(rNextAttribs.release(it).release());
1033 } 1026 }
1034 pAttrib = GetAttrib( pNextNode->GetCharAttribs().GetAttribs(), nAttr ); 1027 pAttrib = GetAttrib(rNextAttribs, nAttr);
1035 } 1028 }
1036 // For the Attributes that just moved over: 1029 // For the Attributes that just moved over:
1037 pNextNode->GetCharAttribs().Clear(); 1030 rNextAttribs.clear();
1038 1031
1039#if OSL_DEBUG_LEVEL > 2 1032#if OSL_DEBUG_LEVEL > 2
1040 OSL_ENSURE( aCharAttribList.DbgCheckAttribs(), "Attribute after AppendAttribs broken" ); 1033 OSL_ENSURE( aCharAttribList.DbgCheckAttribs(), "Attribute after AppendAttribs broken" );
@@ -1232,8 +1225,8 @@ void EditDoc::RemoveItemsFromPool( ContentNode* pNode )
1232{ 1225{
1233 for ( sal_uInt16 nAttr = 0; nAttr < pNode->GetCharAttribs().Count(); nAttr++ ) 1226 for ( sal_uInt16 nAttr = 0; nAttr < pNode->GetCharAttribs().Count(); nAttr++ )
1234 { 1227 {
1235 EditCharAttrib* pAttr = pNode->GetCharAttribs().GetAttribs()[nAttr]; 1228 const EditCharAttrib& rAttr = pNode->GetCharAttribs().GetAttribs()[nAttr];
1236 GetItemPool().Remove( *pAttr->GetItem() ); 1229 GetItemPool().Remove(*rAttr.GetItem());
1237 } 1230 }
1238} 1231}
1239 1232
@@ -1391,7 +1384,7 @@ XubString EditDoc::GetParaAsString( ContentNode* pNode, sal_uInt16 nStartPos, sa
1391 1384
1392 sal_uInt16 nIndex = nStartPos; 1385 sal_uInt16 nIndex = nStartPos;
1393 XubString aStr; 1386 XubString aStr;
1394 EditCharAttrib* pNextFeature = pNode->GetCharAttribs().FindFeature( nIndex ); 1387 const EditCharAttrib* pNextFeature = pNode->GetCharAttribs().FindFeature( nIndex );
1395 while ( nIndex < nEndPos ) 1388 while ( nIndex < nEndPos )
1396 { 1389 {
1397 sal_uInt16 nEnd = nEndPos; 1390 sal_uInt16 nEnd = nEndPos;
@@ -1414,8 +1407,9 @@ XubString EditDoc::GetParaAsString( ContentNode* pNode, sal_uInt16 nStartPos, sa
1414 break; 1407 break;
1415 case EE_FEATURE_LINEBR: aStr += '\x0A'; 1408 case EE_FEATURE_LINEBR: aStr += '\x0A';
1416 break; 1409 break;
1417 case EE_FEATURE_FIELD: if ( bResolveFields ) 1410 case EE_FEATURE_FIELD:
1418 aStr += ((EditCharAttribField*)pNextFeature)->GetFieldValue(); 1411 if ( bResolveFields )
1412 aStr += static_cast<const EditCharAttribField*>(pNextFeature)->GetFieldValue();
1419 break; 1413 break;
1420 default: OSL_FAIL( "What feature?" ); 1414 default: OSL_FAIL( "What feature?" );
1421 } 1415 }
@@ -1434,13 +1428,13 @@ sal_uLong EditDoc::GetTextLen() const
1434 ContentNode* pNode = GetObject( nNode ); 1428 ContentNode* pNode = GetObject( nNode );
1435 nLen += pNode->Len(); 1429 nLen += pNode->Len();
1436 // Fields can be longer than the placeholder in the Node 1430 // Fields can be longer than the placeholder in the Node
1437 const CharAttribArray& rAttrs = pNode->GetCharAttribs().GetAttribs(); 1431 const CharAttribList::AttribsType& rAttrs = pNode->GetCharAttribs().GetAttribs();
1438 for ( sal_uInt16 nAttr = rAttrs.Count(); nAttr; ) 1432 for (size_t nAttr = rAttrs.size(); nAttr; )
1439 { 1433 {
1440 EditCharAttrib* pAttr = rAttrs[--nAttr]; 1434 const EditCharAttrib& rAttr = rAttrs[--nAttr];
1441 if ( pAttr->Which() == EE_FEATURE_FIELD ) 1435 if (rAttr.Which() == EE_FEATURE_FIELD)
1442 { 1436 {
1443 sal_uInt16 nFieldLen = ((EditCharAttribField*)pAttr)->GetFieldValue().Len(); 1437 sal_uInt16 nFieldLen = static_cast<const EditCharAttribField&>(rAttr).GetFieldValue().Len();
1444 if ( !nFieldLen ) 1438 if ( !nFieldLen )
1445 nLen--; 1439 nLen--;
1446 else 1440 else
@@ -1639,8 +1633,7 @@ void EditDoc::InsertAttribInSelection( ContentNode* pNode, sal_uInt16 nStart, sa
1639 // Will become a large Attribute. 1633 // Will become a large Attribute.
1640 pEndingAttrib->GetEnd() = pStartingAttrib->GetEnd(); 1634 pEndingAttrib->GetEnd() = pStartingAttrib->GetEnd();
1641 GetItemPool().Remove( *(pStartingAttrib->GetItem()) ); 1635 GetItemPool().Remove( *(pStartingAttrib->GetItem()) );
1642 pNode->GetCharAttribs().GetAttribs().Remove( pNode->GetCharAttribs().GetAttribs().GetPos( pStartingAttrib ) ); 1636 pNode->GetCharAttribs().Remove(pStartingAttrib);
1643 delete pStartingAttrib;
1644 } 1637 }
1645 else if ( pStartingAttrib && ( *(pStartingAttrib->GetItem()) == rPoolItem ) ) 1638 else if ( pStartingAttrib && ( *(pStartingAttrib->GetItem()) == rPoolItem ) )
1646 pStartingAttrib->GetStart() = nStart; 1639 pStartingAttrib->GetStart() = nStart;
@@ -1652,7 +1645,7 @@ void EditDoc::InsertAttribInSelection( ContentNode* pNode, sal_uInt16 nStart, sa
1652 if ( pStartingAttrib ) 1645 if ( pStartingAttrib )
1653 pNode->GetCharAttribs().ResortAttribs(); 1646 pNode->GetCharAttribs().ResortAttribs();
1654 1647
1655 SetModified( sal_True ); 1648 SetModified(true);
1656} 1649}
1657 1650
1658sal_Bool EditDoc::RemoveAttribs( ContentNode* pNode, sal_uInt16 nStart, sal_uInt16 nEnd, sal_uInt16 nWhich ) 1651sal_Bool EditDoc::RemoveAttribs( ContentNode* pNode, sal_uInt16 nStart, sal_uInt16 nEnd, sal_uInt16 nWhich )
@@ -1673,16 +1666,17 @@ sal_Bool EditDoc::RemoveAttribs( ContentNode* pNode, sal_uInt16 nStart, sal_uInt
1673 // This starts at the end of the selection => can be expanded 1666 // This starts at the end of the selection => can be expanded
1674 rpStarting = 0; 1667 rpStarting = 0;
1675 1668
1676 sal_Bool bChanged = sal_False; 1669 bool bChanged = false;
1677 1670
1678 DBG_ASSERT( nStart <= nEnd, "Small miscalculations in InsertAttribInSelection" ); 1671 DBG_ASSERT( nStart <= nEnd, "Small miscalculations in InsertAttribInSelection" );
1679 1672
1680 // iterate over the attributes ... 1673 // iterate over the attributes ...
1681 sal_uInt16 nAttr = 0; 1674 size_t nAttr = 0;
1682 EditCharAttrib* pAttr = GetAttrib( pNode->GetCharAttribs().GetAttribs(), nAttr ); 1675 CharAttribList::AttribsType& rAttribs = pNode->GetCharAttribs().GetAttribs();
1676 EditCharAttrib* pAttr = GetAttrib(rAttribs, nAttr);
1683 while ( pAttr ) 1677 while ( pAttr )
1684 { 1678 {
1685 sal_Bool bRemoveAttrib = sal_False; 1679 bool bRemoveAttrib = false;
1686 sal_uInt16 nAttrWhich = pAttr->Which(); 1680 sal_uInt16 nAttrWhich = pAttr->Which();
1687 if ( ( nAttrWhich < EE_FEATURE_START ) && ( !nWhich || ( nAttrWhich == nWhich ) ) ) 1681 if ( ( nAttrWhich < EE_FEATURE_START ) && ( !nWhich || ( nAttrWhich == nWhich ) ) )
1688 { 1682 {
@@ -1752,21 +1746,19 @@ sal_Bool EditDoc::RemoveAttribs( ContentNode* pNode, sal_uInt16 nStart, sal_uInt
1752 { 1746 {
1753 DBG_ASSERT( ( pAttr != rpStarting ) && ( pAttr != rpEnding ), "Delete and retain the same attribute?" ); 1747 DBG_ASSERT( ( pAttr != rpStarting ) && ( pAttr != rpEnding ), "Delete and retain the same attribute?" );
1754 DBG_ASSERT( !pAttr->IsFeature(), "RemoveAttribs: Remove a feature?!" ); 1748 DBG_ASSERT( !pAttr->IsFeature(), "RemoveAttribs: Remove a feature?!" );
1755 pNode->GetCharAttribs().GetAttribs().Remove(nAttr);
1756 GetItemPool().Remove( *pAttr->GetItem() ); 1749 GetItemPool().Remove( *pAttr->GetItem() );
1757 delete pAttr; 1750 rAttribs.erase(rAttribs.begin()+nAttr);
1758 nAttr--; 1751 nAttr--;
1759 } 1752 }
1760 nAttr++; 1753 nAttr++;
1761 pAttr = GetAttrib( pNode->GetCharAttribs().GetAttribs(), nAttr ); 1754 pAttr = GetAttrib(rAttribs, nAttr);
1762 } 1755 }
1763 1756
1764 if ( bChanged ) 1757 if ( bChanged )
1765 { 1758 {
1766 // char attributes need to be sorted by start again 1759 // char attributes need to be sorted by start again
1767 pNode->GetCharAttribs().ResortAttribs(); 1760 pNode->GetCharAttribs().ResortAttribs();
1768 1761 SetModified(true);
1769 SetModified( sal_True );
1770 } 1762 }
1771 1763
1772 return bChanged; 1764 return bChanged;
@@ -1796,8 +1788,7 @@ void EditDoc::InsertAttrib( ContentNode* pNode, sal_uInt16 nStart, sal_uInt16 nE
1796 if ( pAttr ) 1788 if ( pAttr )
1797 { 1789 {
1798 // Remove attribute.... 1790 // Remove attribute....
1799 pNode->GetCharAttribs().GetAttribs().Remove( 1791 pNode->GetCharAttribs().Remove(pAttr);
1800 pNode->GetCharAttribs().GetAttribs().GetPos( pAttr ) );
1801 } 1792 }
1802 1793
1803 // check whether 'the same' attribute exist at this place. 1794 // check whether 'the same' attribute exist at this place.
@@ -1932,6 +1923,17 @@ void EditDoc::FindAttribs( ContentNode* pNode, sal_uInt16 nStartPos, sal_uInt16
1932 } 1923 }
1933} 1924}
1934 1925
1926namespace {
1927
1928struct LessByStart : std::binary_function<EditCharAttrib, EditCharAttrib, bool>
1929{
1930 bool operator() (const EditCharAttrib& left, const EditCharAttrib& right) const
1931 {
1932 return left.GetStart() < right.GetStart();
1933 }
1934};
1935
1936}
1935 1937
1936CharAttribList::CharAttribList() 1938CharAttribList::CharAttribList()
1937{ 1939{
@@ -1942,16 +1944,6 @@ CharAttribList::CharAttribList()
1942CharAttribList::~CharAttribList() 1944CharAttribList::~CharAttribList()
1943{ 1945{
1944 DBG_DTOR( EE_CharAttribList, 0 ); 1946 DBG_DTOR( EE_CharAttribList, 0 );
1945
1946 sal_uInt16 nAttr = 0;
1947 EditCharAttrib* pAttr = GetAttrib( aAttribs, nAttr );
1948 while ( pAttr )
1949 {
1950 delete pAttr;
1951 ++nAttr;
1952 pAttr = GetAttrib( aAttribs, nAttr );
1953 }
1954 Clear();
1955} 1947}
1956 1948
1957void CharAttribList::InsertAttrib( EditCharAttrib* pAttrib ) 1949void CharAttribList::InsertAttrib( EditCharAttrib* pAttrib )
@@ -1965,61 +1957,48 @@ void CharAttribList::InsertAttrib( EditCharAttrib* pAttrib )
1965 // (InsertBinTextObject!) binary search would not be optimal here. 1957 // (InsertBinTextObject!) binary search would not be optimal here.
1966 // => Would bring something! 1958 // => Would bring something!
1967 1959
1968 const sal_uInt16 nCount = Count();
1969 const sal_uInt16 nStart = pAttrib->GetStart(); // may be better for Comp.Opt. 1960 const sal_uInt16 nStart = pAttrib->GetStart(); // may be better for Comp.Opt.
1970 1961
1971 if ( pAttrib->IsEmpty() ) 1962 if ( pAttrib->IsEmpty() )
1972 bHasEmptyAttribs = sal_True; 1963 bHasEmptyAttribs = true;
1973 1964
1974 sal_Bool bInserted = sal_False; 1965 for (size_t i = 0, n = aAttribs.size(); i < n; ++i)
1975 for ( sal_uInt16 x = 0; x < nCount; x++ )
1976 { 1966 {
1977 EditCharAttribPtr pCurAttrib = aAttribs[x]; 1967 const EditCharAttrib& rCurAttrib = aAttribs[i];
1978 if ( pCurAttrib->GetStart() > nStart ) 1968 if (rCurAttrib.GetStart() > nStart)
1979 { 1969 {
1980 aAttribs.Insert( pAttrib, x ); 1970 aAttribs.insert(aAttribs.begin()+i, pAttrib);
1981 bInserted = sal_True; 1971 return;
1982 break;
1983 } 1972 }
1984 } 1973 }
1985 if ( !bInserted ) 1974
1986 aAttribs.Insert( pAttrib, nCount ); 1975 aAttribs.push_back(pAttrib);
1987} 1976}
1988 1977
1989void CharAttribList::ResortAttribs() 1978void CharAttribList::ResortAttribs()
1990{ 1979{
1991 if ( Count() ) 1980 std::sort(aAttribs.begin(), aAttribs.end(), LessByStart());
1992 {
1993#if defined __SUNPRO_CC
1994#pragma disable_warn
1995#endif
1996 qsort( (void*)aAttribs.GetData(), aAttribs.Count(), sizeof( EditCharAttrib* ), CompareStart );
1997#if defined __SUNPRO_CC
1998#pragma enable_warn
1999#endif
2000 }
2001} 1981}
2002 1982
2003void CharAttribList::OptimizeRanges( SfxItemPool& rItemPool ) 1983void CharAttribList::OptimizeRanges( SfxItemPool& rItemPool )
2004{ 1984{
2005 for ( sal_uInt16 n = 0; n < aAttribs.Count(); n++ ) 1985 for (size_t i = 0, n = aAttribs.size(); i < n; ++i)
2006 { 1986 {
2007 EditCharAttrib* pAttr = aAttribs.GetObject( n ); 1987 EditCharAttrib& rAttr = aAttribs[i];
2008 for ( sal_uInt16 nNext = n+1; nNext < aAttribs.Count(); nNext++ ) 1988 for (size_t nNext = i+1; nNext < n; ++nNext)
2009 { 1989 {
2010 EditCharAttrib* p = aAttribs.GetObject( nNext ); 1990 EditCharAttrib& rNext = aAttribs[nNext];
2011 if ( !pAttr->IsFeature() && ( p->GetStart() == pAttr->GetEnd() ) && ( p->Which() == pAttr->Which() ) ) 1991 if (!rAttr.IsFeature() && rNext.GetStart() == rAttr.GetEnd() && rNext.Which() == rAttr.Which())
2012 { 1992 {
2013 if ( *p->GetItem() == *pAttr->GetItem() ) 1993 if (*rNext.GetItem() == *rAttr.GetItem())
2014 { 1994 {
2015 pAttr->GetEnd() = p->GetEnd(); 1995 rAttr.GetEnd() = rNext.GetEnd();
2016 aAttribs.Remove( nNext ); 1996 aAttribs.erase(aAttribs.begin()+nNext);
2017 rItemPool.Remove( *p->GetItem() ); 1997 rItemPool.Remove(*rNext.GetItem());
2018 delete p;
2019 } 1998 }
2020 break; // only 1 attr with same which can start here. 1999 break; // only 1 attr with same which can start here.
2021 } 2000 }
2022 else if ( p->GetStart() > pAttr->GetEnd() ) 2001 else if (rNext.GetStart() > rAttr.GetEnd())
2023 { 2002 {
2024 break; 2003 break;
2025 } 2004 }
@@ -2027,131 +2006,199 @@ void CharAttribList::OptimizeRanges( SfxItemPool& rItemPool )
2027 } 2006 }
2028} 2007}
2029 2008
2009size_t CharAttribList::Count() const
2010{
2011 return aAttribs.size();
2012}
2013
2014void CharAttribList::Clear()
2015{
2016 aAttribs.clear();
2017}
2018
2030EditCharAttrib* CharAttribList::FindAttrib( sal_uInt16 nWhich, sal_uInt16 nPos ) 2019EditCharAttrib* CharAttribList::FindAttrib( sal_uInt16 nWhich, sal_uInt16 nPos )
2031{ 2020{
2032 // Backwards, if one ends where the next starts. 2021 // Backwards, if one ends where the next starts.
2033 // => The starting one is the valid one ... 2022 // => The starting one is the valid one ...
2034 sal_uInt16 nAttr = aAttribs.Count()-1; 2023 AttribsType::reverse_iterator it = aAttribs.rbegin(), itEnd = aAttribs.rend();
2035 EditCharAttrib* pAttr = GetAttrib( aAttribs, nAttr ); 2024 for (; it != itEnd; ++it)
2036 while ( pAttr )
2037 { 2025 {
2038 if ( ( pAttr->Which() == nWhich ) && pAttr->IsIn(nPos) ) 2026 EditCharAttrib& rAttr = *it;
2039 return pAttr; 2027 if (rAttr.Which() == nWhich && rAttr.IsIn(nPos))
2040 pAttr = GetAttrib( aAttribs, --nAttr ); 2028 return &rAttr;
2041 } 2029 }
2042 return 0; 2030 return NULL;
2043} 2031}
2044 2032
2045EditCharAttrib* CharAttribList::FindNextAttrib( sal_uInt16 nWhich, sal_uInt16 nFromPos ) const 2033const EditCharAttrib* CharAttribList::FindNextAttrib( sal_uInt16 nWhich, sal_uInt16 nFromPos ) const
2046{ 2034{
2047 DBG_ASSERT( nWhich, "FindNextAttrib: Which?" ); 2035 DBG_ASSERT( nWhich, "FindNextAttrib: Which?" );
2048 const sal_uInt16 nAttribs = aAttribs.Count(); 2036 AttribsType::const_iterator it = aAttribs.begin(), itEnd = aAttribs.end();
2049 for ( sal_uInt16 nAttr = 0; nAttr < nAttribs; nAttr++ ) 2037 for (; it != itEnd; ++it)
2050 { 2038 {
2051 EditCharAttrib* pAttr = aAttribs[ nAttr ]; 2039 const EditCharAttrib& rAttr = *it;
2052 if ( ( pAttr->GetStart() >= nFromPos ) && ( pAttr->Which() == nWhich ) ) 2040 if (rAttr.GetStart() >= nFromPos && rAttr.Which() == nWhich)
2053 return pAttr; 2041 return &rAttr;
2054 } 2042 }
2055 return 0; 2043 return NULL;
2044}
2045
2046bool CharAttribList::HasAttrib( sal_uInt16 nStartPos, sal_uInt16 nEndPos ) const
2047{
2048 AttribsType::const_reverse_iterator it = aAttribs.rbegin(), itEnd = aAttribs.rend();
2049 for (; it != itEnd; ++it)
2050 {
2051 const EditCharAttrib& rAttr = *it;
2052 if (rAttr.GetStart() < nEndPos && rAttr.GetEnd() > nStartPos)
2053 return true;
2054 }
2055 return false;
2056}
2057
2058CharAttribList::AttribsType& CharAttribList::GetAttribs()
2059{
2060 return aAttribs;
2056} 2061}
2057 2062
2058sal_Bool CharAttribList::HasAttrib( sal_uInt16 nStartPos, sal_uInt16 nEndPos ) const 2063const CharAttribList::AttribsType& CharAttribList::GetAttribs() const
2059{ 2064{
2060 sal_Bool bAttr = sal_False; 2065 return aAttribs;
2061 for ( sal_uInt16 nAttr = aAttribs.Count(); nAttr && !bAttr; ) 2066}
2067
2068namespace {
2069
2070class FindByAddress : std::unary_function<EditCharAttrib, bool>
2071{
2072 const EditCharAttrib* mpAttr;
2073public:
2074 FindByAddress(const EditCharAttrib* p) : mpAttr(p) {}
2075 bool operator() (const EditCharAttrib& r) const
2062 { 2076 {
2063 const EditCharAttrib* pAttr = aAttribs[--nAttr]; 2077 return &r == mpAttr;
2064 if ( ( pAttr->GetStart() < nEndPos ) && ( pAttr->GetEnd() > nStartPos ) )
2065 return bAttr = sal_True;
2066 } 2078 }
2067 return bAttr; 2079};
2080
2081}
2082
2083void CharAttribList::Remove(const EditCharAttrib* p)
2084{
2085 AttribsType::iterator it = std::find_if(aAttribs.begin(), aAttribs.end(), FindByAddress(p));
2086 if (it != aAttribs.end())
2087 aAttribs.erase(it);
2068} 2088}
2069 2089
2090void CharAttribList::Remove(size_t nPos)
2091{
2092 if (nPos >= aAttribs.size())
2093 return;
2094
2095 aAttribs.erase(aAttribs.begin()+nPos);
2096}
2097
2098void CharAttribList::SetHasEmptyAttribs(bool b)
2099{
2100 bHasEmptyAttribs = b;
2101}
2070 2102
2071sal_Bool CharAttribList::HasBoundingAttrib( sal_uInt16 nBound ) 2103bool CharAttribList::HasBoundingAttrib( sal_uInt16 nBound ) const
2072{ 2104{
2073 // Backwards, if one ends where the next starts. 2105 // Backwards, if one ends where the next starts.
2074 // => The starting one is the valid one ... 2106 // => The starting one is the valid one ...
2075 sal_uInt16 nAttr = aAttribs.Count()-1; 2107 AttribsType::const_reverse_iterator it = aAttribs.rbegin(), itEnd = aAttribs.rend();
2076 EditCharAttrib* pAttr = GetAttrib( aAttribs, nAttr ); 2108 for (; it != itEnd; ++it)
2077 while ( pAttr && ( pAttr->GetEnd() >= nBound ) )
2078 { 2109 {
2079 if ( ( pAttr->GetStart() == nBound ) || ( pAttr->GetEnd() == nBound ) ) 2110 const EditCharAttrib& rAttr = *it;
2080 return sal_True; 2111 if (rAttr.GetEnd() < nBound)
2081 pAttr = GetAttrib( aAttribs, --nAttr ); 2112 return false;
2113
2114 if (rAttr.GetStart() == nBound || rAttr.GetEnd() == nBound)
2115 return true;
2082 } 2116 }
2083 return sal_False; 2117 return false;
2084} 2118}
2085 2119
2086EditCharAttrib* CharAttribList::FindEmptyAttrib( sal_uInt16 nWhich, sal_uInt16 nPos ) 2120EditCharAttrib* CharAttribList::FindEmptyAttrib( sal_uInt16 nWhich, sal_uInt16 nPos )
2087{ 2121{
2088 if ( !bHasEmptyAttribs ) 2122 if ( !bHasEmptyAttribs )
2089 return 0; 2123 return NULL;
2090 sal_uInt16 nAttr = 0; 2124
2091 EditCharAttrib* pAttr = GetAttrib( aAttribs, nAttr ); 2125 AttribsType::iterator it = aAttribs.begin(), itEnd = aAttribs.end();
2092 while ( pAttr && ( pAttr->GetStart() <= nPos ) ) 2126 for (; it != itEnd; ++it)
2093 { 2127 {
2094 if ( ( pAttr->GetStart() == nPos ) && ( pAttr->GetEnd() == nPos ) && ( pAttr->Which() == nWhich ) ) 2128 EditCharAttrib& rAttr = *it;
2095 return pAttr; 2129 if (rAttr.GetStart() == nPos && rAttr.GetEnd() == nPos && rAttr.Which() == nWhich)
2096 nAttr++; 2130 return &rAttr;
2097 pAttr = GetAttrib( aAttribs, nAttr );
2098 } 2131 }
2099 return 0; 2132 return NULL;
2100} 2133}
2101 2134
2102EditCharAttrib* CharAttribList::FindFeature( sal_uInt16 nPos ) const 2135namespace {
2103{
2104
2105 sal_uInt16 nAttr = 0;
2106 EditCharAttrib* pNextAttrib = GetAttrib( aAttribs, nAttr );
2107 2136
2108 // first to the desired position ... 2137class FindByStartPos : std::unary_function<EditCharAttrib, bool>
2109 while ( pNextAttrib && ( pNextAttrib->GetStart() < nPos ) ) 2138{
2139 sal_uInt16 mnPos;
2140public:
2141 FindByStartPos(sal_uInt16 nPos) : mnPos(nPos) {}
2142 bool operator() (const EditCharAttrib& r) const
2110 { 2143 {
2111 nAttr++; 2144 return r.GetStart() >= mnPos;
2112 pNextAttrib = GetAttrib( aAttribs, nAttr );
2113 } 2145 }
2146};
2114 2147
2115 // Now search for the Feature... 2148}
2116 while ( pNextAttrib && !pNextAttrib->IsFeature() ) 2149
2117 { 2150const EditCharAttrib* CharAttribList::FindFeature( sal_uInt16 nPos ) const
2118 nAttr++; 2151{
2119 pNextAttrib = GetAttrib( aAttribs, nAttr ); 2152 // First, find the first attribute that starts at or after specified position.
2120 } 2153 AttribsType::const_iterator it =
2154 std::find_if(aAttribs.begin(), aAttribs.end(), FindByStartPos(nPos));
2121 2155
2122 return pNextAttrib; 2156 if (it == aAttribs.end())
2157 // All attributes are before the specified position.
2158 return NULL;
2159
2160 // And find the first attribute with feature.
2161 it = std::find_if(it, aAttribs.end(), boost::bind(&EditCharAttrib::IsFeature, _1) == true);
2162 return it == aAttribs.end() ? NULL : &(*it);
2123} 2163}
2124 2164
2165namespace {
2125 2166
2126void CharAttribList::DeleteEmptyAttribs( SfxItemPool& rItemPool ) 2167class RemoveEmptyAttrItem : std::unary_function<EditCharAttrib, void>
2127{ 2168{
2128 for ( sal_uInt16 nAttr = 0; nAttr < aAttribs.Count(); nAttr++ ) 2169 SfxItemPool& mrItemPool;
2170public:
2171 RemoveEmptyAttrItem(SfxItemPool& rPool) : mrItemPool(rPool) {}
2172 void operator() (const EditCharAttrib& r)
2129 { 2173 {
2130 EditCharAttrib* pAttr = aAttribs[nAttr]; 2174 if (r.IsEmpty())
2131 if ( pAttr->IsEmpty() ) 2175 mrItemPool.Remove(*r.GetItem());
2132 {
2133 rItemPool.Remove( *pAttr->GetItem() );
2134 aAttribs.Remove( nAttr );
2135 delete pAttr;
2136 nAttr--;
2137 }
2138 } 2176 }
2139 bHasEmptyAttribs = sal_False; 2177};
2178
2179}
2180
2181void CharAttribList::DeleteEmptyAttribs( SfxItemPool& rItemPool )
2182{
2183 std::for_each(aAttribs.begin(), aAttribs.end(), RemoveEmptyAttrItem(rItemPool));
2184 aAttribs.erase_if(boost::bind(&EditCharAttrib::IsEmpty, _1) == true);
2185 bHasEmptyAttribs = false;
2140} 2186}
2141 2187
2142#if OSL_DEBUG_LEVEL > 2 2188#if OSL_DEBUG_LEVEL > 2
2143bool CharAttribList::DbgCheckAttribs() const 2189bool CharAttribList::DbgCheckAttribs() const
2144{ 2190{
2145 bool bOK = true; 2191 bool bOK = true;
2146 for ( sal_uInt16 nAttr = 0; nAttr < aAttribs.Count(); nAttr++ ) 2192 AttribsType::const_iterator it = aAttribs.begin(), itEnd = aAttribs.end();
2193 for (; it != itEnd; ++it)
2147 { 2194 {
2148 const EditCharAttrib* pAttr = aAttribs[nAttr]; 2195 const EditCharAttrib& rAttr = *it;
2149 if ( pAttr->GetStart() > pAttr->GetEnd() ) 2196 if (rAttr.GetStart() > rAttr.GetEnd())
2150 { 2197 {
2151 bOK = false; 2198 bOK = false;
2152 OSL_FAIL( "Attribute is distorted" ); 2199 OSL_FAIL( "Attribute is distorted" );
2153 } 2200 }
2154 else if ( pAttr->IsFeature() && ( pAttr->GetLen() != 1 ) ) 2201 else if (rAttr.IsFeature() && rAttr.GetLen() != 1)
2155 { 2202 {
2156 bOK = false; 2203 bOK = false;
2157 OSL_FAIL( "Feature, Len != 1" ); 2204 OSL_FAIL( "Feature, Len != 1" );
diff --git a/editeng/source/editeng/editdoc.hxx b/editeng/source/editeng/editdoc.hxx
index e9b196cc5cea..7ddaa392c2f8 100644
--- a/editeng/source/editeng/editdoc.hxx
+++ b/editeng/source/editeng/editdoc.hxx
@@ -208,10 +208,13 @@ public:
208// ------------------------------------------------------------------------- 208// -------------------------------------------------------------------------
209class CharAttribList 209class CharAttribList
210{ 210{
211public:
212 typedef boost::ptr_vector<EditCharAttrib> AttribsType;
213
211private: 214private:
212 CharAttribArray aAttribs; 215 AttribsType aAttribs;
213 SvxFont aDefFont; // faster than ever from the pool! 216 SvxFont aDefFont; // faster than ever from the pool!
214 sal_Bool bHasEmptyAttribs; 217 bool bHasEmptyAttribs;
215 218
216 CharAttribList( const CharAttribList& ) {;} 219 CharAttribList( const CharAttribList& ) {;}
217 220
@@ -223,27 +226,32 @@ public:
223 void RemoveItemsFromPool( SfxItemPool* pItemPool ); 226 void RemoveItemsFromPool( SfxItemPool* pItemPool );
224 227
225 EditCharAttrib* FindAttrib( sal_uInt16 nWhich, sal_uInt16 nPos ); 228 EditCharAttrib* FindAttrib( sal_uInt16 nWhich, sal_uInt16 nPos );
226 EditCharAttrib* FindNextAttrib( sal_uInt16 nWhich, sal_uInt16 nFromPos ) const; 229 const EditCharAttrib* FindNextAttrib( sal_uInt16 nWhich, sal_uInt16 nFromPos ) const;
227 EditCharAttrib* FindEmptyAttrib( sal_uInt16 nWhich, sal_uInt16 nPos ); 230 EditCharAttrib* FindEmptyAttrib( sal_uInt16 nWhich, sal_uInt16 nPos );
228 EditCharAttrib* FindFeature( sal_uInt16 nPos ) const; 231 const EditCharAttrib* FindFeature( sal_uInt16 nPos ) const;
229 232
230 233
231 void ResortAttribs(); 234 void ResortAttribs();
232 void OptimizeRanges( SfxItemPool& rItemPool ); 235 void OptimizeRanges( SfxItemPool& rItemPool );
233 236
234 sal_uInt16 Count() { return aAttribs.Count(); } 237 size_t Count() const;
235 void Clear() { aAttribs.Remove( 0, aAttribs.Count()); } 238 void Clear();
239
236 void InsertAttrib( EditCharAttrib* pAttrib ); 240 void InsertAttrib( EditCharAttrib* pAttrib );
237 241
238 SvxFont& GetDefFont() { return aDefFont; } 242 SvxFont& GetDefFont() { return aDefFont; }
239 243
240 sal_Bool HasEmptyAttribs() const { return bHasEmptyAttribs; } 244 bool HasEmptyAttribs() const { return bHasEmptyAttribs; }
241 sal_Bool& HasEmptyAttribs() { return bHasEmptyAttribs; } 245 void SetHasEmptyAttribs(bool b);
242 sal_Bool HasBoundingAttrib( sal_uInt16 nBound ); 246 bool HasBoundingAttrib( sal_uInt16 nBound ) const;
243 sal_Bool HasAttrib( sal_uInt16 nStartPos, sal_uInt16 nEndPos ) const; 247 bool HasAttrib( sal_uInt16 nStartPos, sal_uInt16 nEndPos ) const;
248
249 AttribsType& GetAttribs();
250 const AttribsType& GetAttribs() const;
251
252 void Remove(const EditCharAttrib* p);
253 void Remove(size_t nPos);
244 254
245 CharAttribArray& GetAttribs() { return aAttribs; }
246 const CharAttribArray& GetAttribs() const { return aAttribs; }
247#if OSL_DEBUG_LEVEL > 2 255#if OSL_DEBUG_LEVEL > 2
248 // Debug: 256 // Debug:
249 bool DbgCheckAttribs() const; 257 bool DbgCheckAttribs() const;
@@ -788,9 +796,9 @@ inline EditPaM EditDoc::GetEndPaM() const
788 return EditPaM( pLastNode, pLastNode->Len() ); 796 return EditPaM( pLastNode, pLastNode->Len() );
789} 797}
790 798
791inline EditCharAttrib* GetAttrib( const CharAttribArray& rAttribs, sal_uInt16 nAttr ) 799inline EditCharAttrib* GetAttrib(CharAttribList::AttribsType& rAttribs, size_t nAttr)
792{ 800{
793 return ( nAttr < rAttribs.Count() ) ? rAttribs[nAttr] : 0; 801 return (nAttr < rAttribs.size()) ? &rAttribs[nAttr] : NULL;
794} 802}
795 803
796sal_Bool CheckOrderedList( CharAttribArray& rAttribs, sal_Bool bStart ); 804sal_Bool CheckOrderedList( CharAttribArray& rAttribs, sal_Bool bStart );
diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx
index 2964ad4b0d47..0954d51195bb 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -2043,12 +2043,12 @@ sal_uInt16 EditEngine::GetFieldCount( sal_uInt16 nPara ) const
2043 ContentNode* pNode = pImpEditEngine->GetEditDoc().SaveGetObject( nPara ); 2043 ContentNode* pNode = pImpEditEngine->GetEditDoc().SaveGetObject( nPara );
2044 if ( pNode ) 2044 if ( pNode )
2045 { 2045 {
2046 const CharAttribArray& rAttrs = pNode->GetCharAttribs().GetAttribs(); 2046 const CharAttribList::AttribsType& rAttrs = pNode->GetCharAttribs().GetAttribs();
2047 for ( sal_uInt16 nAttr = 0; nAttr < rAttrs.Count(); nAttr++ ) 2047 CharAttribList::AttribsType::const_iterator it = rAttrs.begin(), itEnd = rAttrs.end();
2048 for (; it != itEnd; ++it)
2048 { 2049 {
2049 EditCharAttrib* pAttr = rAttrs[nAttr]; 2050 if (it->Which() == EE_FEATURE_FIELD)
2050 if ( pAttr->Which() == EE_FEATURE_FIELD ) 2051 ++nFields;
2051 nFields++;
2052 } 2052 }
2053 } 2053 }
2054 2054
@@ -2061,20 +2061,22 @@ EFieldInfo EditEngine::GetFieldInfo( sal_uInt16 nPara, sal_uInt16 nField ) const
2061 if ( pNode ) 2061 if ( pNode )
2062 { 2062 {
2063 sal_uInt16 nCurrentField = 0; 2063 sal_uInt16 nCurrentField = 0;
2064 const CharAttribArray& rAttrs = pNode->GetCharAttribs().GetAttribs(); 2064 const CharAttribList::AttribsType& rAttrs = pNode->GetCharAttribs().GetAttribs();
2065 for ( sal_uInt16 nAttr = 0; nAttr < rAttrs.Count(); nAttr++ ) 2065 CharAttribList::AttribsType::const_iterator it = rAttrs.begin(), itEnd = rAttrs.end();
2066 for (; it != itEnd; ++it)
2066 { 2067 {
2067 EditCharAttrib* pAttr = rAttrs[nAttr]; 2068 const EditCharAttrib& rAttr = *it;
2068 if ( pAttr->Which() == EE_FEATURE_FIELD ) 2069 if (rAttr.Which() == EE_FEATURE_FIELD)
2069 { 2070 {
2070 if ( nCurrentField == nField ) 2071 if ( nCurrentField == nField )
2071 { 2072 {
2072 EFieldInfo aInfo( *(const SvxFieldItem*)pAttr->GetItem(), nPara, pAttr->GetStart() ); 2073 const SvxFieldItem* p = static_cast<const SvxFieldItem*>(rAttr.GetItem());
2073 aInfo.aCurrentText = ((EditCharAttribField*)pAttr)->GetFieldValue(); 2074 EFieldInfo aInfo(*p, nPara, rAttr.GetStart());
2075 aInfo.aCurrentText = static_cast<const EditCharAttribField&>(rAttr).GetFieldValue();
2074 return aInfo; 2076 return aInfo;
2075 } 2077 }
2076 2078
2077 nCurrentField++; 2079 ++nCurrentField;
2078 } 2080 }
2079 } 2081 }
2080 } 2082 }
@@ -2102,18 +2104,18 @@ void EditEngine::RemoveFields( sal_Bool bKeepFieldText, TypeId aType )
2102 for ( sal_uInt16 nPara = 0; nPara < nParas; nPara++ ) 2104 for ( sal_uInt16 nPara = 0; nPara < nParas; nPara++ )
2103 { 2105 {
2104 ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( nPara ); 2106 ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( nPara );
2105 const CharAttribArray& rAttrs = pNode->GetCharAttribs().GetAttribs(); 2107 const CharAttribList::AttribsType& rAttrs = pNode->GetCharAttribs().GetAttribs();
2106 for ( sal_uInt16 nAttr = rAttrs.Count(); nAttr; ) 2108 for (size_t nAttr = rAttrs.size(); nAttr; )
2107 { 2109 {
2108 const EditCharAttrib* pAttr = rAttrs[--nAttr]; 2110 const EditCharAttrib& rAttr = rAttrs[--nAttr];
2109 if ( pAttr->Which() == EE_FEATURE_FIELD ) 2111 if (rAttr.Which() == EE_FEATURE_FIELD)
2110 { 2112 {
2111 const SvxFieldData* pFldData = ((const SvxFieldItem*)pAttr->GetItem())->GetField(); 2113 const SvxFieldData* pFldData = static_cast<const SvxFieldItem*>(rAttr.GetItem())->GetField();
2112 if ( pFldData && ( !aType || ( pFldData->IsA( aType ) ) ) ) 2114 if ( pFldData && ( !aType || ( pFldData->IsA( aType ) ) ) )
2113 { 2115 {
2114 DBG_ASSERT( pAttr->GetItem()->ISA( SvxFieldItem ), "no field item..." ); 2116 DBG_ASSERT( rAttr->GetItem()->ISA( SvxFieldItem ), "no field item..." );
2115 EditSelection aSel( EditPaM( pNode, pAttr->GetStart() ), EditPaM( pNode, pAttr->GetEnd() ) ); 2117 EditSelection aSel( EditPaM(pNode, rAttr.GetStart()), EditPaM(pNode, rAttr.GetEnd()) );
2116 String aFieldText = ((EditCharAttribField*)pAttr)->GetFieldValue(); 2118 String aFieldText = static_cast<const EditCharAttribField&>(rAttr).GetFieldValue();
2117 pImpEditEngine->ImpInsertText( aSel, aFieldText ); 2119 pImpEditEngine->ImpInsertText( aSel, aFieldText );
2118 } 2120 }
2119 } 2121 }
diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx
index bff5f04f4af1..b7dfee803481 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -1225,16 +1225,16 @@ const SvxFieldItem* EditView::GetFieldAtSelection() const
1225 ( aSel.Max().GetIndex() == aSel.Min().GetIndex()+1 ) ) ) 1225 ( aSel.Max().GetIndex() == aSel.Min().GetIndex()+1 ) ) )
1226 { 1226 {
1227 EditPaM aPaM = aSel.Min(); 1227 EditPaM aPaM = aSel.Min();
1228 const CharAttribArray& rAttrs = aPaM.GetNode()->GetCharAttribs().GetAttribs(); 1228 const CharAttribList::AttribsType& rAttrs = aPaM.GetNode()->GetCharAttribs().GetAttribs();
1229 sal_uInt16 nXPos = aPaM.GetIndex(); 1229 sal_uInt16 nXPos = aPaM.GetIndex();
1230 for ( sal_uInt16 nAttr = rAttrs.Count(); nAttr; ) 1230 for (size_t nAttr = rAttrs.size(); nAttr; )
1231 { 1231 {
1232 EditCharAttrib* pAttr = rAttrs[--nAttr]; 1232 const EditCharAttrib& rAttr = rAttrs[--nAttr];
1233 if ( pAttr->GetStart() == nXPos ) 1233 if (rAttr.GetStart() == nXPos)
1234 if ( pAttr->Which() == EE_FEATURE_FIELD ) 1234 if (rAttr.Which() == EE_FEATURE_FIELD)
1235 { 1235 {
1236 DBG_ASSERT( pAttr->GetItem()->ISA( SvxFieldItem ), "No FeldItem..." ); 1236 DBG_ASSERT(rAttr.GetItem()->ISA( SvxFieldItem ), "No FeldItem...");
1237 return (const SvxFieldItem*)pAttr->GetItem(); 1237 return static_cast<const SvxFieldItem*>(rAttr.GetItem());
1238 } 1238 }
1239 } 1239 }
1240 } 1240 }
diff --git a/editeng/source/editeng/edtspell.cxx b/editeng/source/editeng/edtspell.cxx
index b3c9dbb70637..0dcea4f9ae78 100644
--- a/editeng/source/editeng/edtspell.cxx
+++ b/editeng/source/editeng/edtspell.cxx
@@ -694,23 +694,23 @@ sal_Bool EdtAutoCorrDoc::HasSymbolChars( sal_uInt16 nStt, sal_uInt16 nEnd )
694 sal_uInt16 nScriptType = pImpEE->GetScriptType( EditPaM( pCurNode, nStt ) ); 694 sal_uInt16 nScriptType = pImpEE->GetScriptType( EditPaM( pCurNode, nStt ) );
695 sal_uInt16 nScriptFontInfoItemId = GetScriptItemId( EE_CHAR_FONTINFO, nScriptType ); 695 sal_uInt16 nScriptFontInfoItemId = GetScriptItemId( EE_CHAR_FONTINFO, nScriptType );
696 696
697 CharAttribArray& rAttribs = pCurNode->GetCharAttribs().GetAttribs(); 697 const CharAttribList::AttribsType& rAttribs = pCurNode->GetCharAttribs().GetAttribs();
698 sal_uInt16 nAttrs = rAttribs.Count(); 698 CharAttribList::AttribsType::const_iterator it = rAttribs.begin(), itEnd = rAttribs.end();
699 for ( sal_uInt16 n = 0; n < nAttrs; n++ ) 699 for (; it != itEnd; ++it)
700 { 700 {
701 EditCharAttrib* pAttr = rAttribs.GetObject( n ); 701 const EditCharAttrib& rAttr = *it;
702 if ( pAttr->GetStart() >= nEnd ) 702 if (rAttr.GetStart() >= nEnd)
703 return sal_False; 703 return false;
704 704
705 if ( ( pAttr->Which() == nScriptFontInfoItemId ) && 705 if (rAttr.Which() == nScriptFontInfoItemId &&
706 ( ((SvxFontItem*)pAttr->GetItem())->GetCharSet() == RTL_TEXTENCODING_SYMBOL ) ) 706 static_cast<const SvxFontItem*>(rAttr.GetItem())->GetCharSet() == RTL_TEXTENCODING_SYMBOL)
707 { 707 {
708 // check if the Attribtuteis within range... 708 // check if the Attribtuteis within range...
709 if ( pAttr->GetEnd() >= nStt ) 709 if (rAttr.GetEnd() >= nStt)
710 return sal_True; 710 return true;
711 } 711 }
712 } 712 }
713 return sal_False; 713 return false;
714} 714}
715 715
716const String* EdtAutoCorrDoc::GetPrevPara( sal_Bool ) 716const String* EdtAutoCorrDoc::GetPrevPara( sal_Bool )
diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index c5a3f5d4bbd6..f63ab6aa1dce 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -1181,21 +1181,23 @@ const SvxFieldItem* ImpEditView::GetField( const Point& rPos, sal_uInt16* pPara,
1181 return 0; 1181 return 0;
1182 } 1182 }
1183 1183
1184 const CharAttribArray& rAttrs = aPaM.GetNode()->GetCharAttribs().GetAttribs(); 1184 const CharAttribList::AttribsType& rAttrs = aPaM.GetNode()->GetCharAttribs().GetAttribs();
1185 sal_uInt16 nXPos = aPaM.GetIndex(); 1185 sal_uInt16 nXPos = aPaM.GetIndex();
1186 for ( sal_uInt16 nAttr = rAttrs.Count(); nAttr; ) 1186 for (size_t nAttr = rAttrs.size(); nAttr; )
1187 { 1187 {
1188 EditCharAttrib* pAttr = rAttrs[--nAttr]; 1188 const EditCharAttrib& rAttr = rAttrs[--nAttr];
1189 if ( pAttr->GetStart() == nXPos ) 1189 if (rAttr.GetStart() == nXPos)
1190 if ( pAttr->Which() == EE_FEATURE_FIELD ) 1190 {
1191 if (rAttr.Which() == EE_FEATURE_FIELD)
1191 { 1192 {
1192 DBG_ASSERT( pAttr->GetItem()->ISA( SvxFieldItem ), "No FieldItem..." ); 1193 DBG_ASSERT(dynamic_cast<const SvxFieldItem*>(rAttr.GetItem()), "No FieldItem...");
1193 if ( pPara ) 1194 if ( pPara )
1194 *pPara = pEditEngine->pImpEditEngine->GetEditDoc().GetPos( aPaM.GetNode() ); 1195 *pPara = pEditEngine->pImpEditEngine->GetEditDoc().GetPos( aPaM.GetNode() );
1195 if ( pPos ) 1196 if ( pPos )
1196 *pPos = pAttr->GetStart(); 1197 *pPos = rAttr.GetStart();
1197 return (const SvxFieldItem*)pAttr->GetItem(); 1198 return static_cast<const SvxFieldItem*>(rAttr.GetItem());
1198 } 1199 }
1200 }
1199 } 1201 }
1200 return NULL; 1202 return NULL;
1201} 1203}
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index 80f2710b050d..8d0c04c96ac7 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -73,6 +73,8 @@
73 73
74#include <unicode/ubidi.h> 74#include <unicode/ubidi.h>
75 75
76#include <boost/scoped_ptr.hpp>
77
76using namespace ::com::sun::star; 78using namespace ::com::sun::star;
77 79
78sal_uInt16 lcl_CalcExtraSpace( ParaPortion*, const SvxLineSpacingItem& rLSItem ) 80sal_uInt16 lcl_CalcExtraSpace( ParaPortion*, const SvxLineSpacingItem& rLSItem )
@@ -1404,7 +1406,7 @@ EditPaM ImpEditEngine::CursorEndOfLine( const EditPaM& rPaM )
1404 if ( aNewPaM.GetNode()->IsFeature( aNewPaM.GetIndex() - 1 ) ) 1406 if ( aNewPaM.GetNode()->IsFeature( aNewPaM.GetIndex() - 1 ) )
1405 { 1407 {
1406 // When a soft break, be in front of it! 1408 // When a soft break, be in front of it!
1407 EditCharAttrib* pNextFeature = aNewPaM.GetNode()->GetCharAttribs().FindFeature( aNewPaM.GetIndex()-1 ); 1409 const EditCharAttrib* pNextFeature = aNewPaM.GetNode()->GetCharAttribs().FindFeature( aNewPaM.GetIndex()-1 );
1408 if ( pNextFeature && ( pNextFeature->GetItem()->Which() == EE_FEATURE_LINEBR ) ) 1410 if ( pNextFeature && ( pNextFeature->GetItem()->Which() == EE_FEATURE_LINEBR ) )
1409 aNewPaM = CursorLeft( aNewPaM ); 1411 aNewPaM = CursorLeft( aNewPaM );
1410 } 1412 }
@@ -1685,10 +1687,10 @@ void ImpEditEngine::InitScriptTypes( sal_uInt16 nPara )
1685 1687
1686 // To handle fields put the character from the field in the string, 1688 // To handle fields put the character from the field in the string,
1687 // because endOfScript( ... ) will skip the CH_FEATURE, because this is WEAK 1689 // because endOfScript( ... ) will skip the CH_FEATURE, because this is WEAK
1688 EditCharAttrib* pField = pNode->GetCharAttribs().FindNextAttrib( EE_FEATURE_FIELD, 0 ); 1690 const EditCharAttrib* pField = pNode->GetCharAttribs().FindNextAttrib( EE_FEATURE_FIELD, 0 );
1689 while ( pField ) 1691 while ( pField )
1690 { 1692 {
1691 ::rtl::OUString aFldText( ((EditCharAttribField*)pField)->GetFieldValue() ); 1693 rtl::OUString aFldText = static_cast<const EditCharAttribField*>(pField)->GetFieldValue();
1692 if ( !aFldText.isEmpty() ) 1694 if ( !aFldText.isEmpty() )
1693 { 1695 {
1694 aText.SetChar( pField->GetStart(), aFldText.getStr()[0] ); 1696 aText.SetChar( pField->GetStart(), aFldText.getStr()[0] );
@@ -2102,11 +2104,11 @@ void ImpEditEngine::ImpRemoveChars( const EditPaM& rPaM, sal_uInt16 nChars, Edit
2102 // Check whether attributes are deleted or changed: 2104 // Check whether attributes are deleted or changed:
2103 sal_uInt16 nStart = rPaM.GetIndex(); 2105 sal_uInt16 nStart = rPaM.GetIndex();
2104 sal_uInt16 nEnd = nStart + nChars; 2106 sal_uInt16 nEnd = nStart + nChars;
2105 CharAttribArray& rAttribs = rPaM.GetNode()->GetCharAttribs().GetAttribs(); 2107 const CharAttribList::AttribsType& rAttribs = rPaM.GetNode()->GetCharAttribs().GetAttribs();
2106 for ( sal_uInt16 nAttr = 0; nAttr < rAttribs.Count(); nAttr++ ) 2108 for (size_t i = 0, n = rAttribs.size(); i < n; ++i)
2107 { 2109 {
2108 EditCharAttrib* pAttr = rAttribs[nAttr]; 2110 const EditCharAttrib& rAttr = rAttribs[i];
2109 if ( ( pAttr->GetEnd() >= nStart ) && ( pAttr->GetStart() < nEnd ) ) 2111 if (rAttr.GetEnd() >= nStart && rAttr.GetStart() < nEnd)
2110 { 2112 {
2111 EditSelection aSel( rPaM ); 2113 EditSelection aSel( rPaM );
2112 aSel.Max().GetIndex() = aSel.Max().GetIndex() + nChars; 2114 aSel.Max().GetIndex() = aSel.Max().GetIndex() + nChars;
@@ -2964,37 +2966,37 @@ EditPaM ImpEditEngine::InsertField( EditSelection aCurSel, const SvxFieldItem& r
2964 2966
2965sal_Bool ImpEditEngine::UpdateFields() 2967sal_Bool ImpEditEngine::UpdateFields()
2966{ 2968{
2967 sal_Bool bChanges = sal_False; 2969 bool bChanges = false;
2968 sal_uInt16 nParas = GetEditDoc().Count(); 2970 sal_uInt16 nParas = GetEditDoc().Count();
2969 for ( sal_uInt16 nPara = 0; nPara < nParas; nPara++ ) 2971 for ( sal_uInt16 nPara = 0; nPara < nParas; nPara++ )
2970 { 2972 {
2971 sal_Bool bChangesInPara = sal_False; 2973 bool bChangesInPara = false;
2972 ContentNode* pNode = GetEditDoc().GetObject( nPara ); 2974 ContentNode* pNode = GetEditDoc().GetObject( nPara );
2973 OSL_ENSURE( pNode, "NULL-Pointer in Doc" ); 2975 OSL_ENSURE( pNode, "NULL-Pointer in Doc" );
2974 CharAttribArray& rAttribs = pNode->GetCharAttribs().GetAttribs(); 2976 CharAttribList::AttribsType& rAttribs = pNode->GetCharAttribs().GetAttribs();
2975 for ( sal_uInt16 nAttr = 0; nAttr < rAttribs.Count(); nAttr++ ) 2977 for (size_t nAttr = 0; nAttr < rAttribs.size(); ++nAttr)
2976 { 2978 {
2977 EditCharAttrib* pAttr = rAttribs[nAttr]; 2979 EditCharAttrib& rAttr = rAttribs[nAttr];
2978 if ( pAttr->Which() == EE_FEATURE_FIELD ) 2980 if (rAttr.Which() == EE_FEATURE_FIELD)
2979 { 2981 {
2980 EditCharAttribField* pField = (EditCharAttribField*)pAttr; 2982 EditCharAttribField& rField = static_cast<EditCharAttribField&>(rAttr);
2981 EditCharAttribField* pCurrent = new EditCharAttribField( *pField ); 2983 boost::scoped_ptr<EditCharAttribField> pCurrent(new EditCharAttribField(rField));
2982 pField->Reset(); 2984 rField.Reset();
2983 2985
2984 if ( aStatus.MarkFields() ) 2986 if ( aStatus.MarkFields() )
2985 pField->GetFldColor() = new Color( GetColorConfig().GetColorValue( svtools::WRITERFIELDSHADINGS ).nColor ); 2987 rField.GetFldColor() = new Color( GetColorConfig().GetColorValue( svtools::WRITERFIELDSHADINGS ).nColor );
2986 2988
2987 XubString aFldValue = GetEditEnginePtr()->CalcFieldValue( 2989 rtl::OUString aFldValue =
2988 (const SvxFieldItem&)*pField->GetItem(), 2990 GetEditEnginePtr()->CalcFieldValue(
2989 nPara, pField->GetStart(), 2991 static_cast<const SvxFieldItem&>(*rField.GetItem()),
2990 pField->GetTxtColor(), pField->GetFldColor() ); 2992 nPara, rField.GetStart(), rField.GetTxtColor(), rField.GetFldColor());
2991 pField->GetFieldValue() = aFldValue; 2993
2992 if ( *pField != *pCurrent ) 2994 rField.GetFieldValue() = aFldValue;
2995 if (rField != *pCurrent)
2993 { 2996 {
2994 bChanges = sal_True; 2997 bChanges = true;
2995 bChangesInPara = sal_True; 2998 bChangesInPara = true;
2996 } 2999 }
2997 delete pCurrent;
2998 } 3000 }
2999 } 3001 }
3000 if ( bChangesInPara ) 3002 if ( bChangesInPara )
@@ -4310,7 +4312,7 @@ void ImpEditEngine::IndentBlock( EditView* pEditView, sal_Bool bRight )
4310 else 4312 else
4311 { 4313 {
4312 // Remove Tabs 4314 // Remove Tabs
4313 EditCharAttrib* pFeature = pNode->GetCharAttribs().FindFeature( 0 ); 4315 const EditCharAttrib* pFeature = pNode->GetCharAttribs().FindFeature( 0 );
4314 if ( pFeature && ( pFeature->GetStart() == 0 ) && 4316 if ( pFeature && ( pFeature->GetStart() == 0 ) &&
4315 ( pFeature->GetItem()->Which() == EE_FEATURE_TAB ) ) 4317 ( pFeature->GetItem()->Which() == EE_FEATURE_TAB ) )
4316 { 4318 {
diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx
index a7919a2c7a57..110d5fbf380f 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -889,7 +889,7 @@ sal_Bool ImpEditEngine::CreateLines( sal_uInt16 nPara, sal_uInt32 nStartPosY )
889 TextPortion* pPortion = 0; 889 TextPortion* pPortion = 0;
890 sal_Bool bBrokenLine = sal_False; 890 sal_Bool bBrokenLine = sal_False;
891 bLineBreak = sal_False; 891 bLineBreak = sal_False;
892 EditCharAttrib* pNextFeature = pNode->GetCharAttribs().FindFeature( pLine->GetStart() ); 892 const EditCharAttrib* pNextFeature = pNode->GetCharAttribs().FindFeature( pLine->GetStart() );
893 while ( ( nTmpWidth < nXWidth ) && !bEOL && ( nTmpPortion < pParaPortion->GetTextPortions().Count() ) ) 893 while ( ( nTmpWidth < nXWidth ) && !bEOL && ( nTmpPortion < pParaPortion->GetTextPortions().Count() ) )
894 { 894 {
895 nPortionStart = nTmpPos; 895 nPortionStart = nTmpPos;
@@ -1734,13 +1734,13 @@ void ImpEditEngine::ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, Te
1734 else 1734 else
1735 { 1735 {
1736 sal_uInt16 nMinBreakPos = pLine->GetStart(); 1736 sal_uInt16 nMinBreakPos = pLine->GetStart();
1737 sal_uInt16 nAttrs = pNode->GetCharAttribs().GetAttribs().Count(); 1737 const CharAttribList::AttribsType& rAttrs = pNode->GetCharAttribs().GetAttribs();
1738 for ( sal_uInt16 nAttr = nAttrs; nAttr; ) 1738 for (size_t nAttr = rAttrs.size(); nAttr; )
1739 { 1739 {
1740 EditCharAttrib* pAttr = pNode->GetCharAttribs().GetAttribs()[--nAttr]; 1740 const EditCharAttrib& rAttr = rAttrs[--nAttr];
1741 if ( pAttr->IsFeature() && ( pAttr->GetEnd() > nMinBreakPos ) && ( pAttr->GetEnd() <= nMaxBreakPos ) ) 1741 if (rAttr.IsFeature() && rAttr.GetEnd() > nMinBreakPos && rAttr.GetEnd() <= nMaxBreakPos)
1742 { 1742 {
1743 nMinBreakPos = pAttr->GetEnd(); 1743 nMinBreakPos = rAttr.GetEnd();
1744 break; 1744 break;
1745 } 1745 }
1746 } 1746 }
@@ -2563,9 +2563,9 @@ void ImpEditEngine::SeekCursor( ContentNode* pNode, sal_uInt16 nPos, SvxFont& rF
2563 2563
2564 if ( aStatus.UseCharAttribs() ) 2564 if ( aStatus.UseCharAttribs() )
2565 { 2565 {
2566 const CharAttribArray& rAttribs = pNode->GetCharAttribs().GetAttribs(); 2566 CharAttribList::AttribsType& rAttribs = pNode->GetCharAttribs().GetAttribs();
2567 sal_uInt16 nAttr = 0; 2567 size_t nAttr = 0;
2568 EditCharAttrib* pAttrib = GetAttrib( rAttribs, nAttr ); 2568 EditCharAttrib* pAttrib = GetAttrib(rAttribs, nAttr);
2569 while ( pAttrib && ( pAttrib->GetStart() <= nPos ) ) 2569 while ( pAttrib && ( pAttrib->GetStart() <= nPos ) )
2570 { 2570 {
2571 // when seeking, ignore attributes which start there! Empty attributes 2571 // when seeking, ignore attributes which start there! Empty attributes
@@ -3078,7 +3078,7 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRec, Point aSta
3078 } 3078 }
3079 else if ( pTextPortion->GetKind() == PORTIONKIND_FIELD ) 3079 else if ( pTextPortion->GetKind() == PORTIONKIND_FIELD )
3080 { 3080 {
3081 EditCharAttrib* pAttr = pPortion->GetNode()->GetCharAttribs().FindFeature( nIndex ); 3081 const EditCharAttrib* pAttr = pPortion->GetNode()->GetCharAttribs().FindFeature(nIndex);
3082 DBG_ASSERT( pAttr, "Field not found"); 3082 DBG_ASSERT( pAttr, "Field not found");
3083 DBG_ASSERT( pAttr && pAttr->GetItem()->ISA( SvxFieldItem ), "Field of the wrong type! "); 3083 DBG_ASSERT( pAttr && pAttr->GetItem()->ISA( SvxFieldItem ), "Field of the wrong type! ");
3084 aText = ((EditCharAttribField*)pAttr)->GetFieldValue(); 3084 aText = ((EditCharAttribField*)pAttr)->GetFieldValue();
@@ -3096,7 +3096,7 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRec, Point aSta
3096 // add a meta file comment if we record to a metafile 3096 // add a meta file comment if we record to a metafile
3097 if( bMetafileValid ) 3097 if( bMetafileValid )
3098 { 3098 {
3099 SvxFieldItem* pFieldItem = PTR_CAST( SvxFieldItem, pAttr->GetItem() ); 3099 const SvxFieldItem* pFieldItem = dynamic_cast<const SvxFieldItem*>(pAttr->GetItem());
3100 if( pFieldItem ) 3100 if( pFieldItem )
3101 { 3101 {
3102 const SvxFieldData* pFieldData = pFieldItem->GetField(); 3102 const SvxFieldData* pFieldData = pFieldItem->GetField();
@@ -3187,8 +3187,8 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRec, Point aSta
3187 3187
3188 if(PORTIONKIND_FIELD == pTextPortion->GetKind()) 3188 if(PORTIONKIND_FIELD == pTextPortion->GetKind())
3189 { 3189 {
3190 EditCharAttrib* pAttr = pPortion->GetNode()->GetCharAttribs().FindFeature(nIndex); 3190 const EditCharAttrib* pAttr = pPortion->GetNode()->GetCharAttribs().FindFeature(nIndex);
3191 SvxFieldItem* pFieldItem = PTR_CAST(SvxFieldItem, pAttr->GetItem()); 3191 const SvxFieldItem* pFieldItem = dynamic_cast<const SvxFieldItem*>(pAttr->GetItem());
3192 3192
3193 if(pFieldItem) 3193 if(pFieldItem)
3194 { 3194 {
@@ -3335,8 +3335,8 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRec, Point aSta
3335 { 3335 {
3336 if ( pTextPortion->GetKind() == PORTIONKIND_FIELD ) 3336 if ( pTextPortion->GetKind() == PORTIONKIND_FIELD )
3337 { 3337 {
3338 EditCharAttrib* pAttr = pPortion->GetNode()->GetCharAttribs().FindFeature( nIndex ); 3338 const EditCharAttrib* pAttr = pPortion->GetNode()->GetCharAttribs().FindFeature(nIndex);
3339 SvxFieldItem* pFieldItem = PTR_CAST( SvxFieldItem, pAttr->GetItem() ); 3339 const SvxFieldItem* pFieldItem = dynamic_cast<const SvxFieldItem*>(pAttr->GetItem());
3340 if( pFieldItem ) 3340 if( pFieldItem )
3341 { 3341 {
3342 const SvxFieldData* pFieldData = pFieldItem->GetField(); 3342 const SvxFieldData* pFieldData = pFieldItem->GetField();
@@ -3344,8 +3344,6 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRec, Point aSta
3344 { 3344 {
3345 Point aTopLeft( aTmpPos ); 3345 Point aTopLeft( aTmpPos );
3346 aTopLeft.Y() -= pLine->GetMaxAscent(); 3346 aTopLeft.Y() -= pLine->GetMaxAscent();
3347// if ( nOrientation )
3348// aTopLeft = lcl_ImplCalcRotatedPos( aTopLeft, aOrigin, nSin, nCos );
3349 3347
3350 Rectangle aRect( aTopLeft, pTextPortion->GetSize() ); 3348 Rectangle aRect( aTopLeft, pTextPortion->GetSize() );
3351 vcl::PDFExtOutDevBookmarkEntry aBookmark; 3349 vcl::PDFExtOutDevBookmarkEntry aBookmark;
@@ -3386,14 +3384,14 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRec, Point aSta
3386 3384
3387 if ( pTextPortion->GetKind() == PORTIONKIND_FIELD ) 3385 if ( pTextPortion->GetKind() == PORTIONKIND_FIELD )
3388 { 3386 {
3389 EditCharAttrib* pAttr = pPortion->GetNode()->GetCharAttribs().FindFeature( nIndex ); 3387 const EditCharAttrib* pAttr = pPortion->GetNode()->GetCharAttribs().FindFeature(nIndex);
3390 DBG_ASSERT( pAttr, "Field not found" ); 3388 DBG_ASSERT( pAttr, "Field not found" );
3391 DBG_ASSERT( pAttr && pAttr->GetItem()->ISA( SvxFieldItem ), "Wrong type of field!" ); 3389 DBG_ASSERT( pAttr && pAttr->GetItem()->ISA( SvxFieldItem ), "Wrong type of field!" );
3392 3390
3393 // add a meta file comment if we record to a metafile 3391 // add a meta file comment if we record to a metafile
3394 if( bMetafileValid ) 3392 if( bMetafileValid )
3395 { 3393 {
3396 SvxFieldItem* pFieldItem = PTR_CAST( SvxFieldItem, pAttr->GetItem() ); 3394 const SvxFieldItem* pFieldItem = dynamic_cast<const SvxFieldItem*>(pAttr->GetItem());
3397 3395
3398 if( pFieldItem ) 3396 if( pFieldItem )
3399 { 3397 {
diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx
index 5a23d6236fc3..405a4d086f9c 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -627,7 +627,7 @@ sal_uInt32 ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel )
627 nEndPortion = pParaPortion->GetTextPortions().FindPortion( nEndPos, nPortionStart ); 627 nEndPortion = pParaPortion->GetTextPortions().FindPortion( nEndPos, nPortionStart );
628 } 628 }
629 629
630 EditCharAttrib* pNextFeature = pNode->GetCharAttribs().FindFeature( nIndex ); 630 const EditCharAttrib* pNextFeature = pNode->GetCharAttribs().FindFeature(nIndex);
631 // start at 0, so the index is right ... 631 // start at 0, so the index is right ...
632 for ( sal_uInt16 n = 0; n <= nEndPortion; n++ ) 632 for ( sal_uInt16 n = 0; n <= nEndPortion; n++ )
633 { 633 {
@@ -2060,7 +2060,7 @@ void ImpEditEngine::AddPortionIterated(
2060 //determine whether a field and has been reached 2060 //determine whether a field and has been reached
2061 bIsEndField = nEndField == aCursor.GetIndex(); 2061 bIsEndField = nEndField == aCursor.GetIndex();
2062 //search for a new field attribute 2062 //search for a new field attribute
2063 EditCharAttrib* _pFieldAttr = aCursor.GetNode()->GetCharAttribs(). 2063 const EditCharAttrib* _pFieldAttr = aCursor.GetNode()->GetCharAttribs().
2064 FindFeature( aCursor.GetIndex() ); 2064 FindFeature( aCursor.GetIndex() );
2065 bIsField = _pFieldAttr && 2065 bIsField = _pFieldAttr &&
2066 _pFieldAttr->GetStart() == aCursor.GetIndex() && 2066 _pFieldAttr->GetStart() == aCursor.GetIndex() &&
diff --git a/editeng/source/editeng/impedit5.cxx b/editeng/source/editeng/impedit5.cxx
index d99e30550fe3..02b39a6d104a 100644
--- a/editeng/source/editeng/impedit5.cxx
+++ b/editeng/source/editeng/impedit5.cxx
@@ -217,10 +217,10 @@ EditUndoSetAttribs* ImpEditEngine::CreateAttribUndo( EditSelection aSel, const S
217 217
218 for ( sal_uInt16 nAttr = 0; nAttr < pNode->GetCharAttribs().Count(); nAttr++ ) 218 for ( sal_uInt16 nAttr = 0; nAttr < pNode->GetCharAttribs().Count(); nAttr++ )
219 { 219 {
220 EditCharAttribPtr pAttr = pNode->GetCharAttribs().GetAttribs()[ nAttr ]; 220 const EditCharAttrib& rAttr = pNode->GetCharAttribs().GetAttribs()[nAttr];
221 if ( pAttr->GetLen() ) 221 if (rAttr.GetLen())
222 { 222 {
223 EditCharAttribPtr pNew = MakeCharAttrib( *pPool, *pAttr->GetItem(), pAttr->GetStart(), pAttr->GetEnd() ); 223 EditCharAttrib* pNew = MakeCharAttrib(*pPool, *rAttr.GetItem(), rAttr.GetStart(), rAttr.GetEnd());
224 pInf->GetPrevCharAttribs().Insert( pNew, pInf->GetPrevCharAttribs().Count() ); 224 pInf->GetPrevCharAttribs().Insert( pNew, pInf->GetPrevCharAttribs().Count() );
225 } 225 }
226 } 226 }
@@ -438,50 +438,50 @@ SfxItemSet ImpEditEngine::GetAttribs( sal_uInt16 nPara, sal_uInt16 nStart, sal_u
438 // Make testing easier... 438 // Make testing easier...
439 pNode->GetCharAttribs().OptimizeRanges( ((ImpEditEngine*)this)->GetEditDoc().GetItemPool() ); 439 pNode->GetCharAttribs().OptimizeRanges( ((ImpEditEngine*)this)->GetEditDoc().GetItemPool() );
440 440
441 const CharAttribArray& rAttrs = pNode->GetCharAttribs().GetAttribs(); 441 const CharAttribList::AttribsType& rAttrs = pNode->GetCharAttribs().GetAttribs();
442 for ( sal_uInt16 nAttr = 0; nAttr < rAttrs.Count(); nAttr++ ) 442 for (size_t nAttr = 0; nAttr < rAttrs.size(); ++nAttr)
443 { 443 {
444 EditCharAttrib* pAttr = rAttrs.GetObject( nAttr ); 444 const EditCharAttrib& rAttr = rAttrs[nAttr];
445 445
446 if ( nStart == nEnd ) 446 if ( nStart == nEnd )
447 { 447 {
448 sal_uInt16 nCursorPos = nStart; 448 sal_uInt16 nCursorPos = nStart;
449 if ( ( pAttr->GetStart() <= nCursorPos ) && ( pAttr->GetEnd() >= nCursorPos ) ) 449 if ( ( rAttr.GetStart() <= nCursorPos ) && ( rAttr.GetEnd() >= nCursorPos ) )
450 { 450 {
451 // To be used the attribute has to start BEFORE the position, or it must be a 451 // To be used the attribute has to start BEFORE the position, or it must be a
452 // new empty attr AT the position, or we are on position 0. 452 // new empty attr AT the position, or we are on position 0.
453 if ( ( pAttr->GetStart() < nCursorPos ) || pAttr->IsEmpty() || !nCursorPos ) 453 if ( ( rAttr.GetStart() < nCursorPos ) || rAttr.IsEmpty() || !nCursorPos )
454 { 454 {
455 // maybe this attrib ends here and a new attrib with 0 Len may follow and be valid here, 455 // maybe this attrib ends here and a new attrib with 0 Len may follow and be valid here,
456 // but that s no problem, the empty item will come later and win. 456 // but that s no problem, the empty item will come later and win.
457 aAttribs.Put( *pAttr->GetItem() ); 457 aAttribs.Put( *rAttr.GetItem() );
458 } 458 }
459 } 459 }
460 } 460 }
461 else 461 else
462 { 462 {
463 // Check every attribute covering the area, partial or full. 463 // Check every attribute covering the area, partial or full.
464 if ( ( pAttr->GetStart() < nEnd ) && ( pAttr->GetEnd() > nStart ) ) 464 if ( ( rAttr.GetStart() < nEnd ) && ( rAttr.GetEnd() > nStart ) )
465 { 465 {
466 if ( ( pAttr->GetStart() <= nStart ) && ( pAttr->GetEnd() >= nEnd ) ) 466 if ( ( rAttr.GetStart() <= nStart ) && ( rAttr.GetEnd() >= nEnd ) )
467 { 467 {
468 // full coverage 468 // full coverage
469 aAttribs.Put( *pAttr->GetItem() ); 469 aAttribs.Put( *rAttr.GetItem() );
470 } 470 }
471 else 471 else
472 { 472 {
473 // OptimizeRagnge() assures that not the same attr can follow for full coverage 473 // OptimizeRagnge() assures that not the same attr can follow for full coverage
474 // only partial, check with current, when using para/styhe, otherwise invalid. 474 // only partial, check with current, when using para/styhe, otherwise invalid.
475 if ( !( nFlags & (GETATTRIBS_PARAATTRIBS|GETATTRIBS_STYLESHEET) ) || 475 if ( !( nFlags & (GETATTRIBS_PARAATTRIBS|GETATTRIBS_STYLESHEET) ) ||
476 ( *pAttr->GetItem() != aAttribs.Get( pAttr->Which() ) ) ) 476 ( *rAttr.GetItem() != aAttribs.Get( rAttr.Which() ) ) )
477 { 477 {
478 aAttribs.InvalidateItem( pAttr->Which() ); 478 aAttribs.InvalidateItem( rAttr.Which() );
479 } 479 }
480 } 480 }
481 } 481 }
482 } 482 }
483 483
484 if ( pAttr->GetStart() > nEnd ) 484 if ( rAttr.GetStart() > nEnd )
485 { 485 {
486 break; 486 break;
487 } 487 }
@@ -556,17 +556,16 @@ void ImpEditEngine::SetAttribs( EditSelection aSel, const SfxItemSet& rSet, sal_
556 bCharAttribFound = sal_True; 556 bCharAttribFound = sal_True;
557 if ( nSpecial == ATTRSPECIAL_EDGE ) 557 if ( nSpecial == ATTRSPECIAL_EDGE )
558 { 558 {
559 CharAttribArray& rAttribs = pNode->GetCharAttribs().GetAttribs(); 559 CharAttribList::AttribsType& rAttribs = pNode->GetCharAttribs().GetAttribs();
560 sal_uInt16 nAttrs = rAttribs.Count(); 560 for (size_t i = 0, n = rAttribs.size(); i < n; ++i)
561 for ( sal_uInt16 n = 0; n < nAttrs; n++ )
562 { 561 {
563 EditCharAttrib* pAttr = rAttribs.GetObject( n ); 562 EditCharAttrib& rAttr = rAttribs[i];
564 if ( pAttr->GetStart() > nEndPos ) 563 if (rAttr.GetStart() > nEndPos)
565 break; 564 break;
566 565
567 if ( ( pAttr->GetEnd() == nEndPos ) && ( pAttr->Which() == nWhich ) ) 566 if (rAttr.GetEnd() == nEndPos && rAttr.Which() == nWhich)
568 { 567 {
569 pAttr->SetEdge( sal_True ); 568 rAttr.SetEdge(true);
570 break; 569 break;
571 } 570 }
572 } 571 }
@@ -671,19 +670,19 @@ void ImpEditEngine::RemoveCharAttribs( sal_uInt16 nPara, sal_uInt16 nWhich, sal_
671 if ( !pNode ) 670 if ( !pNode )
672 return; 671 return;
673 672
674 sal_uInt16 nAttr = 0; 673 size_t nAttr = 0;
675 EditCharAttribPtr pAttr = GetAttrib( pNode->GetCharAttribs().GetAttribs(), nAttr ); 674 CharAttribList::AttribsType& rAttrs = pNode->GetCharAttribs().GetAttribs();
675 EditCharAttrib* pAttr = GetAttrib(rAttrs, nAttr);
676 while ( pAttr ) 676 while ( pAttr )
677 { 677 {
678 if ( ( !pAttr->IsFeature() || bRemoveFeatures ) && 678 if ( ( !pAttr->IsFeature() || bRemoveFeatures ) &&
679 ( !nWhich || ( pAttr->GetItem()->Which() == nWhich ) ) ) 679 ( !nWhich || ( pAttr->GetItem()->Which() == nWhich ) ) )
680 { 680 {
681 pNode->GetCharAttribs().GetAttribs().Remove( nAttr ); 681 pNode->GetCharAttribs().Remove(nAttr);
682 delete pAttr;
683 nAttr--; 682 nAttr--;
684 } 683 }
685 nAttr++; 684 nAttr++;
686 pAttr = GetAttrib( pNode->GetCharAttribs().GetAttribs(), nAttr ); 685 pAttr = GetAttrib(rAttrs, nAttr);
687 } 686 }
688 687
689 pPortion->MarkSelectionInvalid( 0, pNode->Len() ); 688 pPortion->MarkSelectionInvalid( 0, pNode->Len() );
@@ -749,14 +748,15 @@ void ImpEditEngine::GetCharAttribs( sal_uInt16 nPara, std::vector<EECharAttrib>&
749 if ( pNode ) 748 if ( pNode )
750 { 749 {
751 rLst.reserve(pNode->GetCharAttribs().Count()); 750 rLst.reserve(pNode->GetCharAttribs().Count());
752 for (size_t i = 0; i < pNode->GetCharAttribs().Count(); ++i) 751 const CharAttribList::AttribsType& rAttrs = pNode->GetCharAttribs().GetAttribs();
752 for (size_t i = 0; i < rAttrs.size(); ++i)
753 { 753 {
754 EditCharAttribPtr pAttr = pNode->GetCharAttribs().GetAttribs()[i]; 754 const EditCharAttrib& rAttr = rAttrs[i];
755 EECharAttrib aEEAttr; 755 EECharAttrib aEEAttr;
756 aEEAttr.pAttr = pAttr->GetItem(); 756 aEEAttr.pAttr = rAttr.GetItem();
757 aEEAttr.nPara = nPara; 757 aEEAttr.nPara = nPara;
758 aEEAttr.nStart = pAttr->GetStart(); 758 aEEAttr.nStart = rAttr.GetStart();
759 aEEAttr.nEnd = pAttr->GetEnd(); 759 aEEAttr.nEnd = rAttr.GetEnd();
760 rLst.push_back(aEEAttr); 760 rLst.push_back(aEEAttr);
761 } 761 }
762 } 762 }
@@ -773,7 +773,7 @@ void ImpEditEngine::ParaAttribsToCharAttribs( ContentNode* pNode )
773 const SfxPoolItem& rItem = pNode->GetContentAttribs().GetItem( nWhich ); 773 const SfxPoolItem& rItem = pNode->GetContentAttribs().GetItem( nWhich );
774 // Fill the gap: 774 // Fill the gap:
775 sal_uInt16 nLastEnd = 0; 775 sal_uInt16 nLastEnd = 0;
776 EditCharAttrib* pAttr = pNode->GetCharAttribs().FindNextAttrib( nWhich, nLastEnd ); 776 const EditCharAttrib* pAttr = pNode->GetCharAttribs().FindNextAttrib( nWhich, nLastEnd );
777 while ( pAttr ) 777 while ( pAttr )
778 { 778 {
779 nLastEnd = pAttr->GetEnd(); 779 nLastEnd = pAttr->GetEnd();