summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@novell.com>2010-10-01 11:24:01 +0100
committerMichael Meeks <michael.meeks@novell.com>2010-10-01 14:46:19 +0100
commite89b0abfaa75f48f187565d7f4e6041e2f2ed5b3 (patch)
tree1b9b95aba40775cfad751de9e90303c609fc369f /svx
parentf410283f26dd2e850031e919666062344b744a16 (diff)
Port binfilter crash-on-exit fix ...
Diffstat (limited to 'svx')
-rw-r--r--svx/inc/svx/unoprov.hxx26
-rw-r--r--svx/source/unodraw/unomod.cxx33
-rw-r--r--svx/source/unodraw/unopage.cxx2
-rw-r--r--svx/source/unodraw/unoprov.cxx135
-rw-r--r--svx/source/unodraw/unoshape.cxx21
5 files changed, 110 insertions, 107 deletions
diff --git a/svx/inc/svx/unoprov.hxx b/svx/inc/svx/unoprov.hxx
index 34cb60371582..46ab2b48c97a 100644
--- a/svx/inc/svx/unoprov.hxx
+++ b/svx/inc/svx/unoprov.hxx
@@ -29,6 +29,7 @@
#define SVX_UNOPROV_HXX
#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
#include <svl/itemprop.hxx>
#include <tools/list.hxx>
#include "svx/svxdllapi.h"
@@ -40,29 +41,14 @@ class SfxItemPool;
* 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* )
-
-#define HASHARRAYSIZE 0x10
#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();
};
/***********************************************************************
@@ -119,8 +105,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 E3D_INVENTOR_FLAG (0x80000000)
diff --git a/svx/source/unodraw/unomod.cxx b/svx/source/unodraw/unomod.cxx
index a10d097981f5..0a2452deadf0 100644
--- a/svx/source/unodraw/unomod.cxx
+++ b/svx/source/unodraw/unomod.cxx
@@ -62,8 +62,6 @@
#include <svx/svdpage.hxx>
#include <svx/unoshape.hxx>
-extern UHashMapEntry pSdrShapeIdentifierMap[];
-
//-////////////////////////////////////////////////////////////////////
using namespace ::rtl;
@@ -185,14 +183,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);
@@ -202,7 +200,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();
@@ -223,28 +221,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/svx/source/unodraw/unopage.cxx b/svx/source/unodraw/unopage.cxx
index 9d5e1695c5cb..277022be53b5 100644
--- a/svx/source/unodraw/unopage.cxx
+++ b/svx/source/unodraw/unopage.cxx
@@ -650,7 +650,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 == UHASHMAP_NOTFOUND )
{
diff --git a/svx/source/unodraw/unoprov.cxx b/svx/source/unodraw/unoprov.cxx
index a69aadd65634..e04a869a7c17 100644
--- a/svx/source/unodraw/unoprov.cxx
+++ b/svx/source/unodraw/unoprov.cxx
@@ -39,6 +39,7 @@
#include <com/sun/star/media/ZoomLevel.hpp>
#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <hash_map>
#include <vcl/fldunit.hxx>
#include <tools/shl.hxx>
#include <vos/mutex.hxx>
@@ -816,7 +817,6 @@ comphelper::PropertyMapEntry* ImplGetSvxDrawingDefaultsPropertyMap()
return aSvxDrawingDefaultsPropertyMap_Impl;
}
-// OD 13.10.2003 #i18732#
comphelper::PropertyMapEntry* ImplGetAdditionalWriterDrawingDefaultsPropertyMap()
{
static comphelper::PropertyMapEntry aSvxAdditionalDefaultsPropertyMap_Impl[] =
@@ -829,55 +829,110 @@ comphelper::PropertyMapEntry* ImplGetAdditionalWriterDrawingDefaultsPropertyMap(
return aSvxAdditionalDefaultsPropertyMap_Impl;
}
-// ---------------------------------------------------------------------
+/***********************************************************************
+* class UHashMap *
+***********************************************************************/
+
+typedef ::std::hash_map< rtl::OUString, sal_uInt32, rtl::OUStringHash > UHashMapImpl;
+
+namespace {
+ static const UHashMapImpl &GetUHashImpl()
+ {
+ static UHashMapImpl aImpl(63);
+ static bool bInited = false;
+ if (!bInited) {
+ 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.CustomShape"), OBJ_CUSTOMSHAPE },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.MediaShape"), OBJ_MEDIA },
+
+ { 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 },
+ };
+ for (sal_uInt32 i = 0; i < sizeof(aInit)/sizeof(aInit[0]); i++)
+ aImpl[rtl::OUString( aInit[i].name, aInit[i].length, RTL_TEXTENCODING_ASCII_US ) ] = aInit[i].id;
+ bInited = true;
+ }
+ return aImpl;
+ }
+}
+
+//----------------------------------------------------------------------
+rtl::OUString UHashMap::getNameFromId(sal_uInt32 nId)
+{
+ const UHashMapImpl &rMap = GetUHashImpl();
+
+ 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();
+}
+
+uno::Sequence< OUString > UHashMap::getServiceNames()
+{
+ const UHashMapImpl &rMap = GetUHashImpl();
+
+ int i = 0;
+ uno::Sequence< OUString > aSeq( rMap.size() );
+ OUString* pStrings = aSeq.getArray();
+
+ for (UHashMapImpl::const_iterator it = rMap.begin(); it != rMap.end(); it++)
+ pStrings[i++] = it->first;
+
+ return aSeq;
+}
+
+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;
+}
+
+
-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.CustomShape"), OBJ_CUSTOMSHAPE ),
- UHashMapEntry (RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.MediaShape"), OBJ_MEDIA ),
-
- 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 )
+ { RTL_CONSTASCII_STRINGPARAM(""), 0 )
};
// ---------------------------------------------------------------------
UHashMap aSdrShapeIdentifierMap( pSdrShapeIdentifierMap );
-/***********************************************************************
-* class UHashMap *
-***********************************************************************/
-
UHashMap::UHashMap( UHashMapEntry* pMap )
{
while( pMap->aIdentifier.getLength() )
diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx
index d860f4973fd2..f261b3d3d62e 100644
--- a/svx/source/unodraw/unoshape.cxx
+++ b/svx/source/unodraw/unoshape.cxx
@@ -1385,23 +1385,10 @@ void SAL_CALL SvxShape::setName( const ::rtl::OUString& aName ) throw(::com::sun
//----------------------------------------------------------------------
OUString SAL_CALL SvxShape::getShapeType() throw(uno::RuntimeException)
{
- if( 0 == maShapeType.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");
- }
- }
-
- return maShapeType;
+ if( !aShapeType.getLength() )
+ return UHashMap::getNameFromId( mpImpl->mnObjId );
+ else
+ return maShapeType;
}
// XComponent