[Libreoffice-commits] .: 2 commits - sw/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Tue Jul 26 22:04:52 PDT 2011
sw/source/filter/html/htmlcss1.cxx | 8 +-
sw/source/filter/html/htmltab.cxx | 4 -
sw/source/filter/html/svxcss1.cxx | 109 +++++++++++++++++++++++--------------
sw/source/filter/html/svxcss1.hxx | 91 ++++--------------------------
4 files changed, 86 insertions(+), 126 deletions(-)
New commits:
commit 594648be754b8b5afeebc87320bab945d8edb98c
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Wed Jul 27 01:02:03 2011 -0400
Let's not make these methods inline....
diff --git a/sw/source/filter/html/svxcss1.cxx b/sw/source/filter/html/svxcss1.cxx
index 8a1c828..a80243b 100644
--- a/sw/source/filter/html/svxcss1.cxx
+++ b/sw/source/filter/html/svxcss1.cxx
@@ -802,8 +802,65 @@ SvxCSS1Parser::~SvxCSS1Parser()
delete pSearchEntry;
}
+void SvxCSS1Parser::InsertId( const String& rId,
+ const SfxItemSet& rItemSet,
+ const SvxCSS1PropertyInfo& rProp )
+{
+ InsertMapEntry( rId, rItemSet, rProp, aIds );
+}
-/* */
+const SvxCSS1MapEntry* SvxCSS1Parser::GetId( const String& rId ) const
+{
+ CSS1Map::const_iterator itr = aIds.find(rId);
+ return itr == aIds.end() ? NULL : itr->second;
+}
+
+void SvxCSS1Parser::InsertClass( const String& rClass,
+ const SfxItemSet& rItemSet,
+ const SvxCSS1PropertyInfo& rProp )
+{
+ InsertMapEntry( rClass, rItemSet, rProp, aClasses );
+}
+
+const SvxCSS1MapEntry* SvxCSS1Parser::GetClass( const String& rClass ) const
+{
+ CSS1Map::const_iterator itr = aClasses.find(rClass);
+ return itr == aClasses.end() ? NULL : itr->second;
+}
+
+void SvxCSS1Parser::InsertPage( const String& rPage,
+ sal_Bool bPseudo,
+ const SfxItemSet& rItemSet,
+ const SvxCSS1PropertyInfo& rProp )
+{
+ String aKey( rPage );
+ if( bPseudo )
+ aKey.Insert( ':', 0 );
+ InsertMapEntry( aKey, rItemSet, rProp, aPages );
+}
+
+SvxCSS1MapEntry* SvxCSS1Parser::GetPage( const String& rPage, bool bPseudo )
+{
+ String aKey( rPage );
+ if( bPseudo )
+ aKey.Insert( ':', 0 );
+
+ CSS1Map::iterator itr = aPages.find(aKey);
+ return itr == aPages.end() ? NULL : itr->second;
+}
+
+void SvxCSS1Parser::InsertTag( const String& rTag,
+ const SfxItemSet& rItemSet,
+ const SvxCSS1PropertyInfo& rProp )
+{
+ InsertMapEntry( rTag, rItemSet, rProp, aTags );
+}
+
+SvxCSS1MapEntry* SvxCSS1Parser::GetTag( const String& rTag )
+{
+ CSS1Map::iterator itr = aTags.find(rTag);
+ return itr == aTags.end() ? NULL : itr->second;
+}
sal_Bool SvxCSS1Parser::ParseStyleSheet( const String& rIn )
{
diff --git a/sw/source/filter/html/svxcss1.hxx b/sw/source/filter/html/svxcss1.hxx
index 49e4ae9..cbe6383 100644
--- a/sw/source/filter/html/svxcss1.hxx
+++ b/sw/source/filter/html/svxcss1.hxx
@@ -318,23 +318,23 @@ public:
void InsertId( const String& rId, const SfxItemSet& rItemSet,
const SvxCSS1PropertyInfo& rProp );
- inline const SvxCSS1MapEntry* GetId( const String& rId ) const;
+ const SvxCSS1MapEntry* GetId( const String& rId ) const;
void InsertClass( const String& rClass, const SfxItemSet& rItemSet,
const SvxCSS1PropertyInfo& rProp );
- inline const SvxCSS1MapEntry* GetClass( const String& rClass ) const;
+ const SvxCSS1MapEntry* GetClass( const String& rClass ) const;
- inline void InsertPage( const String& rPage, sal_Bool bPseudo,
+ void InsertPage( const String& rPage, sal_Bool bPseudo,
const SfxItemSet& rItemSet,
const SvxCSS1PropertyInfo& rProp );
- inline SvxCSS1MapEntry* GetPage( const String& rPage, bool bPseudo );
+ SvxCSS1MapEntry* GetPage( const String& rPage, bool bPseudo );
void InsertTag( const String& rTag, const SfxItemSet& rItemSet,
const SvxCSS1PropertyInfo& rProp );
- inline SvxCSS1MapEntry* GetTag( const String& rTag );
+ SvxCSS1MapEntry* GetTag( const String& rTag );
void MergeStyles( const SfxItemSet& rSrcSet,
const SvxCSS1PropertyInfo& rSrcInfo,
@@ -355,67 +355,6 @@ public:
};
-inline void SvxCSS1Parser::InsertId( const String& rId,
- const SfxItemSet& rItemSet,
- const SvxCSS1PropertyInfo& rProp )
-{
- InsertMapEntry( rId, rItemSet, rProp, aIds );
-}
-
-inline const SvxCSS1MapEntry* SvxCSS1Parser::GetId( const String& rId ) const
-{
- CSS1Map::const_iterator itr = aIds.find(rId);
- return itr == aIds.end() ? NULL : itr->second;
-}
-
-inline void SvxCSS1Parser::InsertClass( const String& rClass,
- const SfxItemSet& rItemSet,
- const SvxCSS1PropertyInfo& rProp )
-{
- InsertMapEntry( rClass, rItemSet, rProp, aClasses );
-}
-
-inline const SvxCSS1MapEntry* SvxCSS1Parser::GetClass( const String& rClass ) const
-{
- CSS1Map::const_iterator itr = aClasses.find(rClass);
- return itr == aClasses.end() ? NULL : itr->second;
-}
-
-inline void SvxCSS1Parser::InsertPage( const String& rPage,
- sal_Bool bPseudo,
- const SfxItemSet& rItemSet,
- const SvxCSS1PropertyInfo& rProp )
-{
- String aKey( rPage );
- if( bPseudo )
- aKey.Insert( ':', 0 );
- InsertMapEntry( aKey, rItemSet, rProp, aPages );
-}
-
-inline SvxCSS1MapEntry* SvxCSS1Parser::GetPage( const String& rPage, bool bPseudo )
-{
- String aKey( rPage );
- if( bPseudo )
- aKey.Insert( ':', 0 );
-
- CSS1Map::iterator itr = aPages.find(aKey);
- return itr == aPages.end() ? NULL : itr->second;
-}
-
-inline void SvxCSS1Parser::InsertTag( const String& rTag,
- const SfxItemSet& rItemSet,
- const SvxCSS1PropertyInfo& rProp )
-{
- InsertMapEntry( rTag, rItemSet, rProp, aTags );
-}
-
-inline SvxCSS1MapEntry* SvxCSS1Parser::GetTag( const String& rTag )
-{
- CSS1Map::iterator itr = aTags.find(rTag);
- return itr == aTags.end() ? NULL : itr->second;
-}
-
-
#endif
commit 0879332ff718822e5a49ce38e059790753047988
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Wed Jul 27 00:54:33 2011 -0400
Replace SV_*_PTRARR_SORT with boost::ptr_map.
diff --git a/sw/source/filter/html/htmlcss1.cxx b/sw/source/filter/html/htmlcss1.cxx
index 1b7d087..5d026ea 100644
--- a/sw/source/filter/html/htmlcss1.cxx
+++ b/sw/source/filter/html/htmlcss1.cxx
@@ -1238,7 +1238,7 @@ SwCharFmt* SwCSS1Parser::GetChrFmt( sal_uInt16 nToken2, const String& rClass ) c
}
else
{
- SvxCSS1MapEntry *pClass = GetClass( aClass );
+ const SvxCSS1MapEntry *pClass = GetClass( aClass );
if( pClass )
{
pCFmt = pDoc->MakeCharFmt( aTmp, pCFmt );
@@ -1884,7 +1884,7 @@ sal_Bool SwCSS1Parser::ParseStyleSheet( const String& rIn )
SwPageDesc *pMasterPageDesc =
pDoc->GetPageDescFromPool( RES_POOLPAGE_HTML, false );
- SvxCSS1MapEntry *pPageEntry = GetPage( aEmptyStr, sal_False );
+ SvxCSS1MapEntry *pPageEntry = GetPage( aEmptyStr, false );
if( pPageEntry )
{
// @page (wirkt auf alle Seiten, die es schon gibt
@@ -1942,7 +1942,7 @@ sal_Bool SwHTMLParser::ParseStyleOptions( const String &rStyle,
{
String aClass( rClass );
SwCSS1Parser::GetScriptFromClass( aClass );
- SvxCSS1MapEntry *pClass = pCSS1Parser->GetClass( aClass );
+ const SvxCSS1MapEntry *pClass = pCSS1Parser->GetClass( aClass );
if( pClass )
{
pCSS1Parser->MergeStyles( pClass->GetItemSet(),
@@ -1954,7 +1954,7 @@ sal_Bool SwHTMLParser::ParseStyleOptions( const String &rStyle,
if( rId.Len() )
{
- SvxCSS1MapEntry *pId = pCSS1Parser->GetId( rId );
+ const SvxCSS1MapEntry *pId = pCSS1Parser->GetId( rId );
if( pId )
pCSS1Parser->MergeStyles( pId->GetItemSet(),
pId->GetPropertyInfo(),
diff --git a/sw/source/filter/html/htmltab.cxx b/sw/source/filter/html/htmltab.cxx
index 9c52410..d4c1a1b 100644
--- a/sw/source/filter/html/htmltab.cxx
+++ b/sw/source/filter/html/htmltab.cxx
@@ -3027,14 +3027,14 @@ SvxBrushItem* SwHTMLParser::CreateBrushItem( const Color *pColor,
{
String aClass( rClass );
SwCSS1Parser::GetScriptFromClass( aClass );
- SvxCSS1MapEntry *pClass = pCSS1Parser->GetClass( aClass );
+ const SvxCSS1MapEntry *pClass = pCSS1Parser->GetClass( aClass );
if( pClass )
aItemSet.Put( pClass->GetItemSet() );
}
if( rId.Len() )
{
- SvxCSS1MapEntry *pId = pCSS1Parser->GetId( rId );
+ const SvxCSS1MapEntry *pId = pCSS1Parser->GetId( rId );
if( pId )
aItemSet.Put( pId->GetItemSet() );
}
diff --git a/sw/source/filter/html/svxcss1.cxx b/sw/source/filter/html/svxcss1.cxx
index 93b5fad..8a1c828 100644
--- a/sw/source/filter/html/svxcss1.cxx
+++ b/sw/source/filter/html/svxcss1.cxx
@@ -65,6 +65,8 @@
#include "css1kywd.hxx"
#include "svxcss1.hxx"
+#include <memory>
+
// die Funktionen zum Parsen einer CSS1-Property sind von folgendem Typ:
typedef void (*FnParseCSS1Prop)( const CSS1Expression *pExpr,
SfxItemSet& rItemSet,
@@ -139,8 +141,6 @@ static CSS1PropertyEnum const aDirectionTable[] =
{ 0, 0 }
};
-/* */
-
static CSS1PropertyEnum const aBGRepeatTable[] =
{
{ sCSS1_PV_repeat, GPOS_TILED },
@@ -166,8 +166,6 @@ static CSS1PropertyEnum const aBGVertPosTable[] =
{ 0, 0 }
};
-/* */
-
static CSS1PropertyEnum const aTextAlignTable[] =
{
{ sCSS1_PV_left, SVX_ADJUST_LEFT },
@@ -177,8 +175,6 @@ static CSS1PropertyEnum const aTextAlignTable[] =
{ 0, 0 }
};
-/* */
-
static CSS1PropertyEnum const aBorderWidthTable[] =
{
{ sCSS1_PV_thin, 0 }, // DEF_LINE_WIDTH_0 / DEF_DOUBLE_LINE0
@@ -240,8 +236,6 @@ static CSS1PropertyEnum const aPageBreakTable[] =
// /Feature: PrintExt
-/* */
-
static sal_uInt16 const aBorderWidths[] =
{
DEF_LINE_WIDTH_0,
@@ -252,8 +246,6 @@ static sal_uInt16 const aBorderWidths[] =
#undef SBORDER_ENTRY
#undef DBORDER_ENTRY
-/* */
-
struct SvxCSS1ItemIds
{
sal_uInt16 nFont;
@@ -371,9 +363,6 @@ void SvxCSS1BorderInfo::SetBorderLine( sal_uInt16 nLine, SvxBoxItem &rBoxItem )
rBoxItem.SetLine( &aBorderLine, nLine );
}
-
-/* */
-
SvxCSS1PropertyInfo::SvxCSS1PropertyInfo()
{
for( sal_uInt16 i=0; i<4; i++ )
@@ -678,9 +667,6 @@ void SvxCSS1PropertyInfo::SetBoxItem( SfxItemSet& rItemSet,
DestroyBorderInfos();
}
-
-/* */
-
SvxCSS1MapEntry::SvxCSS1MapEntry( const String& rKey, const SfxItemSet& rItemSet,
const SvxCSS1PropertyInfo& rProp ) :
aKey( rKey ),
@@ -703,10 +689,6 @@ sal_Bool operator<( const SvxCSS1MapEntry& rE1, const SvxCSS1MapEntry& rE2 )
}
#endif
-SV_IMPL_OP_PTRARR_SORT( SvxCSS1Map, SvxCSS1MapEntryPtr )
-
-/* */
-
sal_Bool SvxCSS1Parser::StyleParsed( const CSS1Selector * /*pSelector*/,
SfxItemSet& /*rItemSet*/,
SvxCSS1PropertyInfo& /*rPropInfo*/ )
@@ -920,37 +902,25 @@ const FontList *SvxCSS1Parser::GetFontList() const
return 0;
}
-SvxCSS1MapEntry *SvxCSS1Parser::GetMapEntry( const String& rKey,
- const SvxCSS1Map& rMap ) const
-{
- pSearchEntry->SetKey( rKey );
-
- SvxCSS1MapEntry *pRet = 0;
- sal_uInt16 nPos;
- if( rMap.Seek_Entry( pSearchEntry, &nPos ) )
- pRet = rMap[nPos];
-
- return pRet;
-}
-
void SvxCSS1Parser::InsertMapEntry( const String& rKey,
const SfxItemSet& rItemSet,
const SvxCSS1PropertyInfo& rProp,
- SvxCSS1Map& rMap )
+ CSS1Map& rMap )
{
- SvxCSS1MapEntry *pEntry = GetMapEntry( rKey, rMap );
- if( pEntry )
+ CSS1Map::iterator itr = rMap.find(rKey);
+ if (itr == rMap.end())
{
- MergeStyles( rItemSet, rProp,
- pEntry->GetItemSet(), pEntry->GetPropertyInfo(), sal_True );
+ std::auto_ptr<SvxCSS1MapEntry> p(new SvxCSS1MapEntry(rKey, rItemSet, rProp));
+ rMap.insert(rKey, p);
}
else
{
- rMap.Insert( new SvxCSS1MapEntry( rKey, rItemSet, rProp ) );
+ SvxCSS1MapEntry* p = itr->second;
+ MergeStyles( rItemSet, rProp,
+ p->GetItemSet(), p->GetPropertyInfo(), sal_True );
}
}
-
void SvxCSS1Parser::MergeStyles( const SfxItemSet& rSrcSet,
const SvxCSS1PropertyInfo& rSrcInfo,
SfxItemSet& rTargetSet,
diff --git a/sw/source/filter/html/svxcss1.hxx b/sw/source/filter/html/svxcss1.hxx
index b34c0ba..49e4ae9 100644
--- a/sw/source/filter/html/svxcss1.hxx
+++ b/sw/source/filter/html/svxcss1.hxx
@@ -40,13 +40,12 @@
#include "parcss1.hxx"
#include <boost/ptr_container/ptr_vector.hpp>
+#include <boost/ptr_container/ptr_map.hpp>
class SfxItemPool;
class SvxBoxItem;
class FontList;
-/* */
-
enum SvxCSS1Position
{
SVX_CSS1_POS_NONE, // nichts angegeben
@@ -197,10 +196,6 @@ public:
const SvxCSS1MapEntry& rE2 );
};
-typedef SvxCSS1MapEntry *SvxCSS1MapEntryPtr;
-SV_DECL_PTRARR_SORT_DEL( SvxCSS1Map, SvxCSS1MapEntryPtr, 5, 5 )
-
-
#if !defined( ICC )
inline sal_Bool operator==( const SvxCSS1MapEntry& rE1, const SvxCSS1MapEntry& rE2 )
{
@@ -223,12 +218,13 @@ inline sal_Bool operator<( const SvxCSS1MapEntry& rE1, const SvxCSS1MapEntry& rE
class SvxCSS1Parser : public CSS1Parser
{
typedef ::boost::ptr_vector<CSS1Selector> CSS1Selectors;
+ typedef ::boost::ptr_map<String, SvxCSS1MapEntry> CSS1Map;
CSS1Selectors aSelectors; // Liste der "offenen" Selectoren
- SvxCSS1Map aIds;
- SvxCSS1Map aClasses;
- SvxCSS1Map aPages;
- SvxCSS1Map aTags;
+ CSS1Map aIds;
+ CSS1Map aClasses;
+ CSS1Map aPages;
+ CSS1Map aTags;
String sBaseURL;
@@ -316,35 +312,29 @@ public:
const sal_uInt16 *GetWhichMap() const { return aWhichMap.GetData(); }
- SvxCSS1MapEntry *GetMapEntry( const String& rKey,
- const SvxCSS1Map& rMap ) const;
-
void InsertMapEntry( const String& rKey, const SfxItemSet& rItemSet,
- const SvxCSS1PropertyInfo& rProp, SvxCSS1Map& rMap );
+ const SvxCSS1PropertyInfo& rProp, CSS1Map& rMap );
void InsertId( const String& rId, const SfxItemSet& rItemSet,
const SvxCSS1PropertyInfo& rProp );
- inline SvxCSS1MapEntry *GetId( const String& rId ) const;
+ inline const SvxCSS1MapEntry* GetId( const String& rId ) const;
void InsertClass( const String& rClass, const SfxItemSet& rItemSet,
const SvxCSS1PropertyInfo& rProp );
- inline SvxCSS1MapEntry *GetClass( const String& rClass ) const;
+ inline const SvxCSS1MapEntry* GetClass( const String& rClass ) const;
inline void InsertPage( const String& rPage, sal_Bool bPseudo,
const SfxItemSet& rItemSet,
const SvxCSS1PropertyInfo& rProp );
- inline SvxCSS1MapEntry *GetPage( const String& rPage, sal_Bool bPseudo ) const;
-
- inline SvxCSS1MapEntry *GetPage( sal_uInt16 i ) const { return aPages[i]; }
- sal_uInt16 GetPageCount() const { return aPages.Count(); }
+ inline SvxCSS1MapEntry* GetPage( const String& rPage, bool bPseudo );
void InsertTag( const String& rTag, const SfxItemSet& rItemSet,
const SvxCSS1PropertyInfo& rProp );
- inline SvxCSS1MapEntry *GetTag( const String& rTag ) const;
+ inline SvxCSS1MapEntry* GetTag( const String& rTag );
void MergeStyles( const SfxItemSet& rSrcSet,
const SvxCSS1PropertyInfo& rSrcInfo,
@@ -372,9 +362,10 @@ inline void SvxCSS1Parser::InsertId( const String& rId,
InsertMapEntry( rId, rItemSet, rProp, aIds );
}
-inline SvxCSS1MapEntry *SvxCSS1Parser::GetId( const String& rId ) const
+inline const SvxCSS1MapEntry* SvxCSS1Parser::GetId( const String& rId ) const
{
- return GetMapEntry( rId, aIds );
+ CSS1Map::const_iterator itr = aIds.find(rId);
+ return itr == aIds.end() ? NULL : itr->second;
}
inline void SvxCSS1Parser::InsertClass( const String& rClass,
@@ -384,9 +375,10 @@ inline void SvxCSS1Parser::InsertClass( const String& rClass,
InsertMapEntry( rClass, rItemSet, rProp, aClasses );
}
-inline SvxCSS1MapEntry *SvxCSS1Parser::GetClass( const String& rClass ) const
+inline const SvxCSS1MapEntry* SvxCSS1Parser::GetClass( const String& rClass ) const
{
- return GetMapEntry( rClass, aClasses );
+ CSS1Map::const_iterator itr = aClasses.find(rClass);
+ return itr == aClasses.end() ? NULL : itr->second;
}
inline void SvxCSS1Parser::InsertPage( const String& rPage,
@@ -400,13 +392,14 @@ inline void SvxCSS1Parser::InsertPage( const String& rPage,
InsertMapEntry( aKey, rItemSet, rProp, aPages );
}
-inline SvxCSS1MapEntry *SvxCSS1Parser::GetPage( const String& rPage,
- sal_Bool bPseudo ) const
+inline SvxCSS1MapEntry* SvxCSS1Parser::GetPage( const String& rPage, bool bPseudo )
{
String aKey( rPage );
if( bPseudo )
aKey.Insert( ':', 0 );
- return GetMapEntry( aKey, aPages );
+
+ CSS1Map::iterator itr = aPages.find(aKey);
+ return itr == aPages.end() ? NULL : itr->second;
}
inline void SvxCSS1Parser::InsertTag( const String& rTag,
@@ -416,9 +409,10 @@ inline void SvxCSS1Parser::InsertTag( const String& rTag,
InsertMapEntry( rTag, rItemSet, rProp, aTags );
}
-inline SvxCSS1MapEntry *SvxCSS1Parser::GetTag( const String& rTag ) const
+inline SvxCSS1MapEntry* SvxCSS1Parser::GetTag( const String& rTag )
{
- return GetMapEntry( rTag, aTags );
+ CSS1Map::iterator itr = aTags.find(rTag);
+ return itr == aTags.end() ? NULL : itr->second;
}
More information about the Libreoffice-commits
mailing list