Re: [PUSHED][PATCH] convert svxrtf.hxx in editeng module from table.hxx to std::map

2012-02-21 Thread Noel Grandin
On Tue, Feb 21, 2012 at 18:06, Ivan Timofeev  wrote:
> Could you prepare your future patches using 'git format-patch', please?
>

Will do!
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: [PUSHED][PATCH] convert svxrtf.hxx in editeng module from table.hxx to std::map

2012-02-21 Thread Ivan Timofeev

On 21.02.2012 15:09, Noel Grandin wrote:

Thanks, that was just the suggestion I needed! Converted patch to use
boost:ptr_map.


Great! Pushed, thanks for it.

Could you prepare your future patches using 'git format-patch', please?

Best Regards,
Ivan
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: [PATCH] convert svxrtf.hxx in editeng module from table.hxx to std::map

2012-02-21 Thread Noel Grandin

Hi

Thanks, that was just the suggestion I needed! Converted patch to use 
boost:ptr_map.


Regards, Noel Grandin

On 2012-02-20 17:17, Ivan Timofeev wrote:

On 20.02.2012 19:12, Noel Grandin wrote:

The error was sourced several levels down in the boost stuff, and the
originating point was everywhere I tried to assign into ptr_map.
I think it had something to with the copyability of the Font class.


Did you try to use 'insert(key, value)' instead of the [] operator?

Ivan
diff --git a/editeng/inc/editeng/svxrtf.hxx b/editeng/inc/editeng/svxrtf.hxx
index c79f2bd..4d255da 100644
--- a/editeng/inc/editeng/svxrtf.hxx
+++ b/editeng/inc/editeng/svxrtf.hxx
@@ -29,7 +29,6 @@
 #ifndef _SVXRTF_HXX
 #define _SVXRTF_HXX
 
-#include 
 #include 
 #include 
 #include 
@@ -39,6 +38,8 @@
 #include 
 #include 
 #include 
+#include "boost/ptr_container/ptr_map.hpp"
+
 class Font;
 class Color;
 class Graphic;
@@ -85,8 +86,8 @@ public:
 
 typedef Color* ColorPtr;
 typedef std::deque< ColorPtr > SvxRTFColorTbl;
-DECLARE_TABLE( SvxRTFFontTbl, Font* )
-DECLARE_TABLE( SvxRTFStyleTbl, SvxRTFStyleType* )
+typedef boost::ptr_map SvxRTFFontTbl;
+typedef boost::ptr_map SvxRTFStyleTbl;
 typedef SvxRTFItemStackType* SvxRTFItemStackTypePtr;
 SV_DECL_PTRARR_DEL( SvxRTFItemStackList, SvxRTFItemStackTypePtr, 1 )
 
diff --git a/editeng/source/editeng/eertfpar.cxx 
b/editeng/source/editeng/eertfpar.cxx
index d508716..4e7254f 100644
--- a/editeng/source/editeng/eertfpar.cxx
+++ b/editeng/source/editeng/eertfpar.cxx
@@ -371,10 +371,11 @@ void EditRTFParser::SetAttrInDoc( SvxRTFItemStackType 
&rSet )
 
 if ( rSet.StyleNo() && pImpEditEngine->GetStyleSheetPool() && 
pImpEditEngine->GetStatus().DoImportRTFStyleSheets() )
 {
-SvxRTFStyleType* pS = GetStyleTbl().Get( rSet.StyleNo() );
-DBG_ASSERT( pS, "Template not defined in RTF!" );
-if ( pS )
+SvxRTFStyleTbl::iterator it = GetStyleTbl().find( rSet.StyleNo() );
+DBG_ASSERT( it != GetStyleTbl().end(), "Template not defined in RTF!" 
);
+if ( it != GetStyleTbl().end() )
 {
+SvxRTFStyleType* pS = it->second;
 pImpEditEngine->SetStyleSheet( EditSelection( aStartPaM, aEndPaM 
), (SfxStyleSheet*)pImpEditEngine->GetStyleSheetPool()->Find( pS->sName, 
SFX_STYLE_FAMILY_ALL ) );
 nOutlLevel = pS->nOutlineNo;
 }
@@ -433,11 +434,17 @@ void EditRTFParser::SetAttrInDoc( SvxRTFItemStackType 
&rSet )
 
 SvxRTFStyleType* EditRTFParser::FindStyleSheet( const XubString& rName )
 {
-SvxRTFStyleType* pS = GetStyleTbl().First();
-while ( pS && ( pS->sName != rName ) )
-pS = GetStyleTbl().Next();
+SvxRTFStyleTbl aTable = GetStyleTbl();
+SvxRTFStyleTbl::iterator it = aTable.begin();
+while ( it != aTable.end() )
+{
+SvxRTFStyleType* pS = it->second;
+if ( pS->sName == rName )
+return pS;
+++it;
+}
 
-return pS;
+return NULL;
 }
 
 SfxStyleSheet* EditRTFParser::CreateStyleSheet( SvxRTFStyleType* pRTFStyle )
@@ -451,9 +458,13 @@ SfxStyleSheet* EditRTFParser::CreateStyleSheet( 
SvxRTFStyleType* pRTFStyle )
 String aParent;
 if ( pRTFStyle->nBasedOn )
 {
-SvxRTFStyleType* pS = GetStyleTbl().Get( pRTFStyle->nBasedOn );
-if ( pS && ( pS !=pRTFStyle ) )
-aParent = pS->sName;
+SvxRTFStyleTbl::iterator it = GetStyleTbl().find( pRTFStyle->nBasedOn 
);
+if ( it != GetStyleTbl().end())
+{
+SvxRTFStyleType* pS = it->second;
+if ( pS && ( pS !=pRTFStyle ) )
+aParent = pS->sName;
+}
 }
 
 pStyle = (SfxStyleSheet*) &pImpEditEngine->GetStyleSheetPool()->Make( 
aName, SFX_STYLE_FAMILY_PARA );
@@ -484,12 +495,10 @@ void EditRTFParser::CreateStyleSheets()
 // the SvxRTFParser haa  now created the template...
 if ( pImpEditEngine->GetStyleSheetPool() && 
pImpEditEngine->GetStatus().DoImportRTFStyleSheets() )
 {
-SvxRTFStyleType* pRTFStyle = GetStyleTbl().First();
-while ( pRTFStyle )
+for (SvxRTFStyleTbl::iterator it = GetStyleTbl().begin(); it != 
GetStyleTbl().end(); ++it)
 {
+SvxRTFStyleType* pRTFStyle = it->second;
 CreateStyleSheet( pRTFStyle );
-
-pRTFStyle = GetStyleTbl().Next();
 }
 }
 }
diff --git a/editeng/source/rtf/svxrtf.cxx b/editeng/source/rtf/svxrtf.cxx
index 8b9d93c..165c3c3 100644
--- a/editeng/source/rtf/svxrtf.cxx
+++ b/editeng/source/rtf/svxrtf.cxx
@@ -77,7 +77,6 @@ SvxRTFParser::SvxRTFParser( SfxItemPool& rPool, SvStream& rIn,
 int bReadNewDoc )
 : SvRTFParser( rIn, 5 ),
 rStrm(rIn),
-aFontTbl( 16, 4 ),
 pInsPos( 0 ),
 pAttrPool( &rPool ),
 m_xDocProps( i_xDocProps ),
@@ -119,10 +118,6 @@ SvxRTFParser::~SvxRTFParser()
 {
 if( !aColorTbl.empty() )
 ClearColorTbl();
-if( aFontTbl.Count() )
-ClearFontTbl();
-if( aStyleTbl.Count() )
-ClearStyleTbl();
 if

Re: [PATCH] convert svxrtf.hxx in editeng module from table.hxx to std::map

2012-02-20 Thread Ivan Timofeev

On 20.02.2012 19:12, Noel Grandin wrote:

The error was sourced several levels down in the boost stuff, and the
originating point was everywhere I tried to assign into ptr_map.
I think it had something to with the copyability of the Font class.


Did you try to use 'insert(key, value)' instead of the [] operator?

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


Re: [PATCH] convert svxrtf.hxx in editeng module from table.hxx to std::map

2012-02-20 Thread Noel Grandin
On Mon, Feb 20, 2012 at 16:38, Ivan Timofeev  wrote:
> Hi Noel,
>
>
> What line produces that error? I suppose we should do use ptr_map, because
> even you forgot to delete object :)

The error was sourced several levels down in the boost stuff, and the
originating point was everywhere I tried to assign into ptr_map.
I think it had something to with the copyability of the Font class.

I'll fix the errors you spotted and post a new patch tomorrow.
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: [PATCH] convert svxrtf.hxx in editeng module from table.hxx to std::map

2012-02-20 Thread Ivan Timofeev

Hi Noel,

On 14.02.2012 15:25, Noel Grandin wrote:

Note that I tried converting these usages to boost::ptr_map, but I ran
into entirely undecipherable C++ template errors.


Sorry for the late review... :(

What line produces that error? I suppose we should do use ptr_map, 
because even you forgot to delete object :)



@@ -385,14 +380,12 @@ void SvxRTFParser::ReadStyleTable()
 {
 pStyle->sName = DelCharAtEnd( aToken, ';' );

-if( aStyleTbl.Count() )
+if( !aStyleTbl.empty() )
 {
-SvxRTFStyleType* pOldSt = aStyleTbl.Remove( nStyleNo );
-if( pOldSt )
-delete pOldSt;
+aStyleTbl.erase(nStyleNo);
 }


Also


@@ -4041,10 +4046,11 @@ SwTxtFmtColl* SwRTFParser::MakeStyle( sal_uInt16 nNo, const 
SvxRTFStyleType& rSt
 if( iter == aTxtCollTbl.end())// noch nicht vorhanden, 
also anlegen
 {
 // ist die ueberhaupt als Style vorhanden ?
-SvxRTFStyleType* pMkStyle = GetStyleTbl().Get( nStyleNo );
-pNext = pMkStyle
-? MakeStyle( nStyleNo, *pMkStyle )
-: pDoc->GetTxtCollFromPool( RES_POOLCOLL_STANDARD, false );
+SvxRTFStyleTbl::iterator styleIter = GetStyleTbl().find( nStyleNo 
);
+if ( styleIter != GetStyleTbl().end() )
+pNext = MakeStyle( nStyleNo, *styleIter->second );
+else
+pDoc->GetTxtCollFromPool( RES_POOLCOLL_STANDARD, false );

   ^^^

should be pNext = pDoc->...

All the best,
Ivan
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


[PATCH] convert svxrtf.hxx in editeng module from table.hxx to std::map

2012-02-14 Thread Noel Grandin

Hi

License statement already on file.

"make check" succeeds.

Note that I tried converting these usages to boost::ptr_map, but I ran 
into entirely undecipherable C++ template errors.
 (can't wait for template-type-checking aka. concepts to make it into 
the language).


Regards, Noel Grandin

Disclaimer: http://www.peralex.com/disclaimer.html


diff --git a/editeng/inc/editeng/svxrtf.hxx b/editeng/inc/editeng/svxrtf.hxx
index c79f2bd..691725f 100644
--- a/editeng/inc/editeng/svxrtf.hxx
+++ b/editeng/inc/editeng/svxrtf.hxx
@@ -29,7 +29,6 @@
 #ifndef _SVXRTF_HXX
 #define _SVXRTF_HXX
 
-#include 
 #include 
 #include 
 #include 
@@ -39,6 +38,8 @@
 #include 
 #include 
 #include 
+#include 
+
 class Font;
 class Color;
 class Graphic;
@@ -85,8 +86,8 @@ public:
 
 typedef Color* ColorPtr;
 typedef std::deque< ColorPtr > SvxRTFColorTbl;
-DECLARE_TABLE( SvxRTFFontTbl, Font* )
-DECLARE_TABLE( SvxRTFStyleTbl, SvxRTFStyleType* )
+typedef std::map SvxRTFFontTbl;
+typedef std::map SvxRTFStyleTbl;
 typedef SvxRTFItemStackType* SvxRTFItemStackTypePtr;
 SV_DECL_PTRARR_DEL( SvxRTFItemStackList, SvxRTFItemStackTypePtr, 1 )
 
diff --git a/editeng/source/editeng/eertfpar.cxx 
b/editeng/source/editeng/eertfpar.cxx
index d508716..4e7254f 100644
--- a/editeng/source/editeng/eertfpar.cxx
+++ b/editeng/source/editeng/eertfpar.cxx
@@ -371,10 +371,11 @@ void EditRTFParser::SetAttrInDoc( SvxRTFItemStackType 
&rSet )
 
 if ( rSet.StyleNo() && pImpEditEngine->GetStyleSheetPool() && 
pImpEditEngine->GetStatus().DoImportRTFStyleSheets() )
 {
-SvxRTFStyleType* pS = GetStyleTbl().Get( rSet.StyleNo() );
-DBG_ASSERT( pS, "Template not defined in RTF!" );
-if ( pS )
+SvxRTFStyleTbl::iterator it = GetStyleTbl().find( rSet.StyleNo() );
+DBG_ASSERT( it != GetStyleTbl().end(), "Template not defined in RTF!" 
);
+if ( it != GetStyleTbl().end() )
 {
+SvxRTFStyleType* pS = it->second;
 pImpEditEngine->SetStyleSheet( EditSelection( aStartPaM, aEndPaM 
), (SfxStyleSheet*)pImpEditEngine->GetStyleSheetPool()->Find( pS->sName, 
SFX_STYLE_FAMILY_ALL ) );
 nOutlLevel = pS->nOutlineNo;
 }
@@ -433,11 +434,17 @@ void EditRTFParser::SetAttrInDoc( SvxRTFItemStackType 
&rSet )
 
 SvxRTFStyleType* EditRTFParser::FindStyleSheet( const XubString& rName )
 {
-SvxRTFStyleType* pS = GetStyleTbl().First();
-while ( pS && ( pS->sName != rName ) )
-pS = GetStyleTbl().Next();
+SvxRTFStyleTbl aTable = GetStyleTbl();
+SvxRTFStyleTbl::iterator it = aTable.begin();
+while ( it != aTable.end() )
+{
+SvxRTFStyleType* pS = it->second;
+if ( pS->sName == rName )
+return pS;
+++it;
+}
 
-return pS;
+return NULL;
 }
 
 SfxStyleSheet* EditRTFParser::CreateStyleSheet( SvxRTFStyleType* pRTFStyle )
@@ -451,9 +458,13 @@ SfxStyleSheet* EditRTFParser::CreateStyleSheet( 
SvxRTFStyleType* pRTFStyle )
 String aParent;
 if ( pRTFStyle->nBasedOn )
 {
-SvxRTFStyleType* pS = GetStyleTbl().Get( pRTFStyle->nBasedOn );
-if ( pS && ( pS !=pRTFStyle ) )
-aParent = pS->sName;
+SvxRTFStyleTbl::iterator it = GetStyleTbl().find( pRTFStyle->nBasedOn 
);
+if ( it != GetStyleTbl().end())
+{
+SvxRTFStyleType* pS = it->second;
+if ( pS && ( pS !=pRTFStyle ) )
+aParent = pS->sName;
+}
 }
 
 pStyle = (SfxStyleSheet*) &pImpEditEngine->GetStyleSheetPool()->Make( 
aName, SFX_STYLE_FAMILY_PARA );
@@ -484,12 +495,10 @@ void EditRTFParser::CreateStyleSheets()
 // the SvxRTFParser haa  now created the template...
 if ( pImpEditEngine->GetStyleSheetPool() && 
pImpEditEngine->GetStatus().DoImportRTFStyleSheets() )
 {
-SvxRTFStyleType* pRTFStyle = GetStyleTbl().First();
-while ( pRTFStyle )
+for (SvxRTFStyleTbl::iterator it = GetStyleTbl().begin(); it != 
GetStyleTbl().end(); ++it)
 {
+SvxRTFStyleType* pRTFStyle = it->second;
 CreateStyleSheet( pRTFStyle );
-
-pRTFStyle = GetStyleTbl().Next();
 }
 }
 }
diff --git a/editeng/source/rtf/svxrtf.cxx b/editeng/source/rtf/svxrtf.cxx
index 8b9d93c..8a148a8 100644
--- a/editeng/source/rtf/svxrtf.cxx
+++ b/editeng/source/rtf/svxrtf.cxx
@@ -77,7 +77,6 @@ SvxRTFParser::SvxRTFParser( SfxItemPool& rPool, SvStream& rIn,
 int bReadNewDoc )
 : SvRTFParser( rIn, 5 ),
 rStrm(rIn),
-aFontTbl( 16, 4 ),
 pInsPos( 0 ),
 pAttrPool( &rPool ),
 m_xDocProps( i_xDocProps ),
@@ -119,10 +118,10 @@ SvxRTFParser::~SvxRTFParser()
 {
 if( !aColorTbl.empty() )
 ClearColorTbl();
-if( aFontTbl.Count() )
-ClearFontTbl();
-if( aStyleTbl.Count() )
+if( !aStyleTbl.empty() )
 ClearStyleTbl();
+if( !aFontTbl.empty() )
+ClearFontTbl();
 if( !aAttrStack.empty() )
 ClearAttrStack();
 
@@ -149,11 +148,7 @@ SvParserState S