[ooo-build-commit] .: binfilter/bf_svx binfilter/inc
Michael Meeks
mmeeks at kemper.freedesktop.org
Fri Oct 1 02:54:35 PDT 2010
binfilter/bf_svx/source/unodraw/svx_unomod.cxx | 34 -----
binfilter/bf_svx/source/unodraw/svx_unopage.cxx | 2
binfilter/bf_svx/source/unodraw/svx_unoprov.cxx | 143 ++++++++++++-----------
binfilter/bf_svx/source/unodraw/svx_unoshape.cxx | 17 --
binfilter/inc/bf_svx/unoprov.hxx | 30 +---
5 files changed, 97 insertions(+), 129 deletions(-)
New commits:
commit 841b960aaf6adb72dc8626b3b68f9edd00ecf9f4
Author: Michael Meeks <michael.meeks at novell.com>
Date: Fri Oct 1 10:52:52 2010 +0100
Fix memory corruption / double frees on exit
We were releasing static memory in error, from some unpleasant old code.
diff --git a/binfilter/bf_svx/source/unodraw/svx_unomod.cxx b/binfilter/bf_svx/source/unodraw/svx_unomod.cxx
index e5d33d7..0a2bc28 100644
--- a/binfilter/bf_svx/source/unodraw/svx_unomod.cxx
+++ b/binfilter/bf_svx/source/unodraw/svx_unomod.cxx
@@ -80,10 +80,9 @@
#include "unomodel.hxx"
#include "svdobj.hxx"
#include "unoshape.hxx"
+#include <hash_map>
namespace binfilter {
-extern UHashMapEntry pSdrShapeIdentifierMap[];
-
//-////////////////////////////////////////////////////////////////////
using namespace ::rtl;
@@ -206,14 +205,14 @@ sal_Bool SvxUnoDrawMSFactory::createEvent( const SdrModel* pDoc, const SdrHint*
return sal_True;
}
-uno::Reference< uno::XInterface > SAL_CALL SvxUnoDrawMSFactory::createInstance( const OUString& ServiceSpecifier )
+uno::Reference< uno::XInterface > SAL_CALL SvxUnoDrawMSFactory::createInstance( const OUString& rServiceSpecifier )
throw( uno::Exception, uno::RuntimeException )
{
const OUString aDrawingPrefix( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.") );
- if( ServiceSpecifier.compareTo( aDrawingPrefix, aDrawingPrefix.getLength() ) == 0 )
+ if( rServiceSpecifier.compareTo( aDrawingPrefix, aDrawingPrefix.getLength() ) == 0 )
{
- UINT32 nType = aSdrShapeIdentifierMap.getId( ServiceSpecifier );
+ sal_uInt32 nType = UHashMap::getId( rServiceSpecifier );
if( nType != UHASHMAP_NOTFOUND )
{
UINT16 nT = (UINT16)(nType & ~E3D_INVENTOR_FLAG);
@@ -223,7 +222,7 @@ uno::Reference< uno::XInterface > SAL_CALL SvxUnoDrawMSFactory::createInstance(
}
}
- uno::Reference< uno::XInterface > xRet( createTextField( ServiceSpecifier ) );
+ uno::Reference< uno::XInterface > xRet( createTextField( rServiceSpecifier ) );
if( !xRet.is() )
throw lang::ServiceNotRegisteredException();
@@ -296,28 +295,7 @@ uno::Reference< uno::XInterface > SAL_CALL SvxUnoDrawMSFactory::createInstanceWi
uno::Sequence< OUString > SAL_CALL SvxUnoDrawMSFactory::getAvailableServiceNames()
throw( uno::RuntimeException )
{
- UHashMapEntry* pMap = pSdrShapeIdentifierMap;
-
- UINT32 nCount = 0;
- while (pMap->aIdentifier.getLength())
- {
- pMap++;
- nCount++;
- }
-
- uno::Sequence< OUString > aSeq( nCount );
- OUString* pStrings = aSeq.getArray();
-
- pMap = pSdrShapeIdentifierMap;
- UINT32 nIdx = 0;
- while(pMap->aIdentifier.getLength())
- {
- pStrings[nIdx] = pMap->aIdentifier;
- pMap++;
- nIdx++;
- }
-
- return aSeq;
+ return UHashMap::getServiceNames();
}
uno::Sequence< OUString > SvxUnoDrawMSFactory::concatServiceNames( uno::Sequence< OUString >& rServices1, uno::Sequence< OUString >& rServices2 ) throw()
diff --git a/binfilter/bf_svx/source/unodraw/svx_unopage.cxx b/binfilter/bf_svx/source/unodraw/svx_unopage.cxx
index ebe552f..8fba131 100644
--- a/binfilter/bf_svx/source/unodraw/svx_unopage.cxx
+++ b/binfilter/bf_svx/source/unodraw/svx_unopage.cxx
@@ -478,7 +478,7 @@ SdrObject *SvxDrawPage::_CreateSdrObject( const Reference< drawing::XShape > & x
//----------------------------------------------------------------------
void SvxDrawPage::GetTypeAndInventor( sal_uInt16& rType, sal_uInt32& rInventor, const OUString& aName ) const throw()
{
- sal_uInt32 nTempType = aSdrShapeIdentifierMap.getId( aName );
+ sal_uInt32 nTempType = UHashMap::getId( aName );
if(nTempType & E3D_INVENTOR_FLAG)
{
diff --git a/binfilter/bf_svx/source/unodraw/svx_unoprov.cxx b/binfilter/bf_svx/source/unodraw/svx_unoprov.cxx
index ba54d8e..f6ad636 100644
--- a/binfilter/bf_svx/source/unodraw/svx_unoprov.cxx
+++ b/binfilter/bf_svx/source/unodraw/svx_unoprov.cxx
@@ -47,6 +47,8 @@
#include <vcl/svapp.hxx>
#endif
+#include <hash_map>
+
#include <comphelper/propertysetinfo.hxx>
#ifndef _SVX_DIALMGR_HXX
@@ -670,90 +672,103 @@ comphelper::PropertyMapEntry* ImplGetSvxDrawingDefaultsPropertyMap()
}
-// ---------------------------------------------------------------------
-
-SvxUnoPropertyMapProvider aSvxMapProvider;
-
-UHashMapEntry pSdrShapeIdentifierMap[] =
-{
- UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.RectangleShape"), OBJ_RECT ),
- UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.EllipseShape"), OBJ_CIRC ),
- UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.ControlShape"), OBJ_UNO ),
- UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.ConnectorShape"), OBJ_EDGE ),
- UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.MeasureShape"), OBJ_MEASURE ),
- UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.LineShape"), OBJ_LINE ),
- UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.PolyPolygonShape"), OBJ_POLY ),
- UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.PolyLineShape"), OBJ_PLIN ),
- UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.OpenBezierShape"), OBJ_PATHLINE ),
- UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.ClosedBezierShape"), OBJ_PATHFILL ),
- UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.OpenFreeHandShape"), OBJ_FREELINE ),
- UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.ClosedFreeHandShape"), OBJ_FREEFILL ),
- UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.PolyPolygonPathShape"), OBJ_PATHPOLY ),
- UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.PolyLinePathShape"), OBJ_PATHPLIN ),
- UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.GraphicObjectShape"), OBJ_GRAF ),
- UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.GroupShape"), OBJ_GRUP ),
- UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.TextShape"), OBJ_TEXT ),
- UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.OLE2Shape"), OBJ_OLE2 ),
- UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.PageShape"), OBJ_PAGE ),
- UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.CaptionShape"), OBJ_CAPTION ),
- UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.FrameShape"), OBJ_FRAME ),
- UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.PluginShape"), OBJ_OLE2_PLUGIN ),
- UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.AppletShape"), OBJ_OLE2_APPLET ),
-
- UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DSceneObject"), E3D_POLYSCENE_ID | E3D_INVENTOR_FLAG ),
- UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DCubeObject"), E3D_CUBEOBJ_ID | E3D_INVENTOR_FLAG ),
- UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DSphereObject"), E3D_SPHEREOBJ_ID | E3D_INVENTOR_FLAG ),
- UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DLatheObject"), E3D_LATHEOBJ_ID | E3D_INVENTOR_FLAG ),
- UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DExtrudeObject"), E3D_EXTRUDEOBJ_ID | E3D_INVENTOR_FLAG ),
- UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DPolygonObject"), E3D_POLYGONOBJ_ID | E3D_INVENTOR_FLAG ),
- UHashMapEntry (RTL_CONSTASCII_STRINGPARAM(""), 0 )
-};
-
-// ---------------------------------------------------------------------
-
-UHashMap aSdrShapeIdentifierMap( pSdrShapeIdentifierMap );
-
/***********************************************************************
* class UHashMap *
***********************************************************************/
-UHashMap::UHashMap( UHashMapEntry* pMap )
+typedef ::std::hash_map< rtl::OUString, sal_uInt32, rtl::OUStringHash > UHashMapImpl;
+// obsoleting these guys:
+// extern UHashMapEntry pSdrShapeIdentifierMap[];
+// extern UHashMap aSdrShapeIdentifierMap;
+
+namespace {
+ static const UHashMapImpl &GetUHashImpl()
+ {
+ static UHashMapImpl *pImpl = NULL;
+ if (!pImpl) {
+ struct { const char *name; sal_Int32 length; sal_uInt32 id; } aInit[] = {
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.RectangleShape"), OBJ_RECT },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.EllipseShape"), OBJ_CIRC },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.ControlShape"), OBJ_UNO },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.ConnectorShape"), OBJ_EDGE },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.MeasureShape"), OBJ_MEASURE },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.LineShape"), OBJ_LINE },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.PolyPolygonShape"), OBJ_POLY },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.PolyLineShape"), OBJ_PLIN },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.OpenBezierShape"), OBJ_PATHLINE },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.ClosedBezierShape"), OBJ_PATHFILL },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.OpenFreeHandShape"), OBJ_FREELINE },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.ClosedFreeHandShape"), OBJ_FREEFILL },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.PolyPolygonPathShape"), OBJ_PATHPOLY },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.PolyLinePathShape"), OBJ_PATHPLIN },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.GraphicObjectShape"), OBJ_GRAF },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.GroupShape"), OBJ_GRUP },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.TextShape"), OBJ_TEXT },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.OLE2Shape"), OBJ_OLE2 },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.PageShape"), OBJ_PAGE },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.CaptionShape"), OBJ_CAPTION },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.FrameShape"), OBJ_FRAME },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.PluginShape"), OBJ_OLE2_PLUGIN },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.AppletShape"), OBJ_OLE2_APPLET },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DSceneObject"), E3D_POLYSCENE_ID | E3D_INVENTOR_FLAG },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DCubeObject"), E3D_CUBEOBJ_ID | E3D_INVENTOR_FLAG },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DSphereObject"), E3D_SPHEREOBJ_ID | E3D_INVENTOR_FLAG },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DLatheObject"), E3D_LATHEOBJ_ID | E3D_INVENTOR_FLAG },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DExtrudeObject"), E3D_EXTRUDEOBJ_ID | E3D_INVENTOR_FLAG },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DPolygonObject"), E3D_POLYGONOBJ_ID | E3D_INVENTOR_FLAG }
+ };
+ pImpl = new UHashMapImpl(32);
+ for (sal_uInt32 i = 0; i < sizeof(aInit)/sizeof(aInit[0]); i++)
+ (*pImpl)[rtl::OUString( aInit[i].name, aInit[i].length, RTL_TEXTENCODING_ASCII_US ) ] = aInit[i].id;
+ }
+ return *pImpl;
+ }
+}
+
+//----------------------------------------------------------------------
+rtl::OUString UHashMap::getNameFromId(sal_uInt32 nId)
{
- while( pMap->aIdentifier.getLength() )
- {
- OUString aStr( pMap->aIdentifier );
- size_t nHash = aStr.hashCode() & (HASHARRAYSIZE-1);
+ const UHashMapImpl &rMap = GetUHashImpl();
- m_aHashList[nHash].Insert(pMap);
- pMap++;
+ for (UHashMapImpl::const_iterator it = rMap.begin(); it != rMap.end(); it++)
+ {
+ if (it->second == nId)
+ return it->first;
}
+ DBG_ERROR("[CL] unknown SdrObjekt identifier");
+ return rtl::OUString();
}
-// ---------------------------------------------------------------------
-
-UINT32 UHashMap::getId( const OUString& rCompareString )
+uno::Sequence< OUString > UHashMap::getServiceNames()
{
- size_t nHash = rCompareString.hashCode() & (HASHARRAYSIZE-1);
+ const UHashMapImpl &rMap = GetUHashImpl();
- UHashMapEntryList& rList = m_aHashList[nHash];
-
- UHashMapEntry * pMap = rList.First();
+ int i = 0;
+ uno::Sequence< OUString > aSeq( rMap.size() );
+ OUString* pStrings = aSeq.getArray();
- while(pMap)
- {
- if( rCompareString == pMap->aIdentifier )
- return pMap->nId;
+ for (UHashMapImpl::const_iterator it = rMap.begin(); it != rMap.end(); it++)
+ pStrings[i++] = it->first;
- pMap = rList.Next();
- }
+ return aSeq;
+}
- return UHASHMAP_NOTFOUND;
+UINT32 UHashMap::getId( const OUString& rCompareString )
+{
+ const UHashMapImpl &rMap = GetUHashImpl();
+ UHashMapImpl::const_iterator it = rMap.find( rCompareString );
+ if( it == rMap.end() )
+ return UHASHMAP_NOTFOUND;
+ else
+ return it->second;
}
/***********************************************************************
* class SvxUnoPropertyMapProvider *
***********************************************************************/
+SvxUnoPropertyMapProvider aSvxMapProvider;
+
EXTERN_C
#ifdef WNT
int _cdecl
diff --git a/binfilter/bf_svx/source/unodraw/svx_unoshape.cxx b/binfilter/bf_svx/source/unodraw/svx_unoshape.cxx
index a868ee7..88fdc51 100644
--- a/binfilter/bf_svx/source/unodraw/svx_unoshape.cxx
+++ b/binfilter/bf_svx/source/unodraw/svx_unoshape.cxx
@@ -1103,21 +1103,8 @@ void SAL_CALL SvxShape::setName( const ::rtl::OUString& aName ) throw(::com::sun
//----------------------------------------------------------------------
OUString SAL_CALL SvxShape::getShapeType() throw(uno::RuntimeException)
{
- if( 0 == aShapeType.getLength() )
- {
- UHashMapEntry* pMap = pSdrShapeIdentifierMap;
- while ( ( pMap->nId != mpImpl->mnObjId ) && pMap->aIdentifier.getLength() )
- ++pMap;
-
- if ( pMap->aIdentifier.getLength() )
- {
- return pMap->aIdentifier;
- }
- else
- {
- DBG_ERROR("[CL] unknown SdrObjekt identifier");
- }
- }
+ if( !aShapeType.getLength() )
+ return UHashMap::getNameFromId( mpImpl->mnObjId );
return aShapeType;
}
diff --git a/binfilter/inc/bf_svx/unoprov.hxx b/binfilter/inc/bf_svx/unoprov.hxx
index 6213524..13a6acc 100644
--- a/binfilter/inc/bf_svx/unoprov.hxx
+++ b/binfilter/inc/bf_svx/unoprov.hxx
@@ -41,35 +41,25 @@
#ifndef _LIST_HXX
#include <tools/list.hxx>
#endif
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HPP_
+#include <com/sun/star/uno/Sequence.hxx>
+#endif
+
namespace binfilter {
/***********************************************************************
* class UHashMap *
***********************************************************************/
-struct UHashMapEntry
-{
- ::rtl::OUString aIdentifier;
- UINT32 nId;
-
- UHashMapEntry(const sal_Char * value, sal_Int32 length, UINT32 _nId) : aIdentifier(value,length,RTL_TEXTENCODING_ASCII_US), nId(_nId) { }
-};
-
-DECLARE_LIST( UHashMapEntryList, UHashMapEntry* )//STRIP008 DECLARE_LIST( UHashMapEntryList, UHashMapEntry* );
-
-#define HASHARRAYSIZE 0x10
-#define UHASHMAP_NOTFOUND (~0)
+#define UHASHMAP_NOTFOUND sal::static_int_cast< UINT32 >(~0)
class UHashMap
{
-private:
- UHashMapEntryList m_aHashList[HASHARRAYSIZE];
-
+ UHashMap() {}
public:
- UHashMap( UHashMapEntry* pMap );
- ~UHashMap() {};
-
- UINT32 getId( const ::rtl::OUString& rCompareString );
+ static sal_uInt32 getId( const ::rtl::OUString& rCompareString );
+ static rtl::OUString getNameFromId (sal_uInt32 nId);
+ static ::com::sun::star::uno::Sequence< rtl::OUString > getServiceNames();
};
/***********************************************************************
@@ -120,8 +110,6 @@ const sal_Int16 OBJ_OLE2_APPLET = 100;
const sal_Int16 OBJ_OLE2_PLUGIN = 101;
extern SvxUnoPropertyMapProvider aSvxMapProvider;
-extern UHashMapEntry pSdrShapeIdentifierMap[];
-extern UHashMap aSdrShapeIdentifierMap;
#define SFX_METRIC_ITEM (0x40)
#define E3D_INVENTOR_FLAG (0x80000000)
More information about the ooo-build-commit
mailing list