Hi
Convert tools/table.hxx usage in editeng/source/editeng/editdoc.hxx to
boost::ptr_map
Contributed under LGPLv3+ / MPL 1.1 or later.
(And my license statement is on file in the wiki)
Regards, Noel Grandin
Disclaimer: http://www.peralex.com/disclaimer.html
diff --git a/editeng/source/editeng/editattr.hxx b/editeng/source/editeng/editattr.hxx
index 8e82084..19632c0 100644
--- a/editeng/source/editeng/editattr.hxx
+++ b/editeng/source/editeng/editattr.hxx
@@ -30,9 +30,9 @@
#define _EDITATTR_HXX
#include <editeng/eeitem.hxx>
+#include <editeng/fontitem.hxx>
class SvxFont;
-class SvxFontItem;
class SvxWeightItem;
class SvxPostureItem;
class SvxShadowedItem;
diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx
index 0161eaa0..53e293d 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -2169,33 +2169,36 @@ bool CharAttribList::DbgCheckAttribs() const
}
#endif
-SvxFontTable::SvxFontTable()
+sal_uLong SvxFontTable::GetId( const SvxFontItem& rFontItem ) const
{
+ for(FontItemMap::const_iterator it = maFontItemMap.begin(); it != maFontItemMap.end(); ++it)
+ {
+ if ( *it->second == rFontItem )
+ return it->first;
+ }
+ DBG_WARNING( "Font not found: GetId()" );
+ return 0;
}
-SvxFontTable::~SvxFontTable()
+void SvxFontTable::Insert( sal_uLong nIdx, SvxFontItem *pFontItem)
{
- SvxFontItem* pItem = First();
- while( pItem )
- {
- delete pItem;
- pItem = Next();
- }
+ maFontItemMap.insert( nIdx, pFontItem );
}
-sal_uLong SvxFontTable::GetId( const SvxFontItem& rFontItem )
+int SvxFontTable::Count() const
{
- SvxFontItem* pItem = First();
- while ( pItem )
- {
- if ( *pItem == rFontItem )
- return GetCurKey();
- pItem = Next();
- }
- DBG_WARNING( "Font not found: GetId()" );
- return 0;
+ return maFontItemMap.size();
}
+SvxFontItem* SvxFontTable::Get( sal_uLong nIdx )
+{
+ FontItemMap::iterator it = maFontItemMap.find( nIdx );
+ if (it == maFontItemMap.end() )
+ return NULL;
+ return it->second;
+}
+
+
SvxColorList::SvxColorList()
{
}
diff --git a/editeng/source/editeng/editdoc.hxx b/editeng/source/editeng/editdoc.hxx
index 2b35c3e..6a14fdf 100644
--- a/editeng/source/editeng/editdoc.hxx
+++ b/editeng/source/editeng/editdoc.hxx
@@ -39,8 +39,8 @@
#include <svl/itempool.hxx>
#include <tools/table.hxx>
#include <vector>
-
#include <deque>
+#include "boost/ptr_container/ptr_map.hpp"
class ImpEditEngine;
class SvxTabStop;
@@ -141,15 +141,20 @@ SV_DECL_PTRARR( ContentInfoArray, ContentAttribsInfoPtr, 1 )
// ----------------------------------------------------------------------
// class SvxFontTable
// ----------------------------------------------------------------------
-DECLARE_TABLE( DummyFontTable, SvxFontItem* )
-class SvxFontTable : public DummyFontTable
+class SvxFontTable
{
+private:
+ typedef boost::ptr_map<sal_uLong, SvxFontItem> FontItemMap;
+ FontItemMap maFontItemMap;
public:
- SvxFontTable();
- ~SvxFontTable();
+ SvxFontTable() {}
+ ~SvxFontTable() {}
- sal_uLong GetId( const SvxFontItem& rFont );
+ sal_uLong GetId( const SvxFontItem& rFont ) const;
+ void Insert( sal_uLong nIdx, SvxFontItem *pFontItem );
+ int Count() const;
+ SvxFontItem* Get( sal_uLong nIdx );
};
// ----------------------------------------------------------------------
Context
- [PATCH] convert table.hxx use in editeng/source/editeng/editdoc.hxx · Noel Grandin
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.