2004-04-02 12:52:27 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-09 12:39:36 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2004-04-02 12:52:27 +00:00
|
|
|
*
|
2005-09-09 12:39:36 +00:00
|
|
|
* $RCSfile: EnhancedCustomShapeToken.cxx,v $
|
2004-04-02 12:52:27 +00:00
|
|
|
*
|
2005-09-09 12:39:36 +00:00
|
|
|
* $Revision: 1.7 $
|
2004-04-02 12:52:27 +00:00
|
|
|
*
|
2005-09-09 12:39:36 +00:00
|
|
|
* last change: $Author: rt $ $Date: 2005-09-09 13:39:36 $
|
2004-04-02 12:52:27 +00:00
|
|
|
*
|
2005-09-09 12:39:36 +00:00
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
2004-04-02 12:52:27 +00:00
|
|
|
*
|
|
|
|
*
|
2005-09-09 12:39:36 +00:00
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
2004-04-02 12:52:27 +00:00
|
|
|
*
|
2005-09-09 12:39:36 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
2004-04-02 12:52:27 +00:00
|
|
|
*
|
2005-09-09 12:39:36 +00:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2004-04-02 12:52:27 +00:00
|
|
|
*
|
2005-09-09 12:39:36 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
2004-04-02 12:52:27 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#ifndef _ENHANCED_CUSTOMSHAPE_TOKEN_HXX
|
|
|
|
#include "EnhancedCustomShapeToken.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _OSL_MUTEX_HXX_
|
|
|
|
#include <osl/mutex.hxx>
|
|
|
|
#endif
|
|
|
|
#include <hash_map>
|
|
|
|
|
|
|
|
namespace xmloff { namespace EnhancedCustomShapeToken {
|
|
|
|
|
|
|
|
struct TCheck
|
|
|
|
{
|
|
|
|
bool operator()( const char* s1, const char* s2 ) const
|
|
|
|
{
|
|
|
|
return strcmp( s1, s2 ) == 0;
|
|
|
|
}
|
|
|
|
};
|
2004-09-08 13:57:20 +00:00
|
|
|
typedef std::hash_map< const char*, EnhancedCustomShapeTokenEnum, std::hash<const char*>, TCheck> TypeNameHashMap;
|
2004-04-02 12:52:27 +00:00
|
|
|
static TypeNameHashMap* pHashMap = NULL;
|
|
|
|
static ::osl::Mutex& getHashMapMutex()
|
|
|
|
{
|
|
|
|
static osl::Mutex s_aHashMapProtection;
|
|
|
|
return s_aHashMapProtection;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TokenTable
|
|
|
|
{
|
2004-10-12 12:05:27 +00:00
|
|
|
char* pS;
|
2004-04-02 12:52:27 +00:00
|
|
|
EnhancedCustomShapeTokenEnum pE;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const TokenTable pTokenTableArray[] =
|
|
|
|
{
|
2004-11-26 13:09:29 +00:00
|
|
|
{ "type", EAS_type },
|
|
|
|
{ "name", EAS_name },
|
2004-04-02 12:52:27 +00:00
|
|
|
{ "mirror-horizontal", EAS_mirror_horizontal },
|
|
|
|
{ "mirror-vertical", EAS_mirror_vertical },
|
2004-10-12 12:05:27 +00:00
|
|
|
{ "viewBox", EAS_viewBox },
|
2004-04-02 12:52:27 +00:00
|
|
|
{ "text-rotate-angle", EAS_text_rotate_angle },
|
|
|
|
{ "extrusion-allowed", EAS_extrusion_allowed },
|
|
|
|
{ "extrusion-text-path-allowed", EAS_text_path_allowed },
|
|
|
|
{ "extrusion-concentric-gradient-fill", EAS_concentric_gradient_fill_allowed },
|
|
|
|
{ "extrusion", EAS_extrusion },
|
|
|
|
{ "extrusion-brightness", EAS_extrusion_brightness },
|
2004-10-12 12:05:27 +00:00
|
|
|
{ "extrusion-depth", EAS_extrusion_depth },
|
|
|
|
{ "extrusion-diffusion", EAS_extrusion_diffusion },
|
|
|
|
{ "extrusion-number-of-line-segments", EAS_extrusion_number_of_line_segments },
|
2004-04-02 12:52:27 +00:00
|
|
|
{ "extrusion-light-face", EAS_extrusion_light_face },
|
2004-10-12 12:05:27 +00:00
|
|
|
{ "extrusion-first-light-harsh", EAS_extrusion_first_light_harsh },
|
|
|
|
{ "extrusion-second-light-harsh", EAS_extrusion_second_light_harsh },
|
|
|
|
{ "extrusion-first-light-livel", EAS_extrusion_first_light_level },
|
|
|
|
{ "extrusion-second-light-level", EAS_extrusion_second_light_level },
|
|
|
|
{ "extrusion-first-light-direction", EAS_extrusion_first_light_direction },
|
|
|
|
{ "extrusion-second-light-direction", EAS_extrusion_second_light_direction },
|
2004-04-02 12:52:27 +00:00
|
|
|
{ "extrusion-metal", EAS_extrusion_metal },
|
2004-10-12 12:05:27 +00:00
|
|
|
{ "shade-mode", EAS_shade_mode },
|
|
|
|
{ "extrusion-rotation-angle", EAS_extrusion_rotation_angle },
|
|
|
|
{ "extrusion-rotation-center", EAS_extrusion_rotation_center },
|
2004-04-02 12:52:27 +00:00
|
|
|
{ "extrusion-shininess", EAS_extrusion_shininess },
|
|
|
|
{ "extrusion-skew", EAS_extrusion_skew },
|
|
|
|
{ "extrusion-specularity", EAS_extrusion_specularity },
|
2004-10-12 12:05:27 +00:00
|
|
|
{ "projection", EAS_projection },
|
2004-04-02 12:52:27 +00:00
|
|
|
{ "extrusion-viewpoint", EAS_extrusion_viewpoint },
|
2004-10-12 12:05:27 +00:00
|
|
|
{ "extrusion-origin", EAS_extrusion_origin },
|
2004-04-02 12:52:27 +00:00
|
|
|
{ "extrusion-color", EAS_extrusion_color },
|
|
|
|
{ "enhanced-path", EAS_enhanced_path },
|
|
|
|
{ "path-stretchpoint-x", EAS_path_stretchpoint_x },
|
|
|
|
{ "path-stretchpoint-y", EAS_path_stretchpoint_y },
|
2004-11-26 13:09:29 +00:00
|
|
|
{ "text-areas", EAS_text_areas },
|
2004-04-02 12:52:27 +00:00
|
|
|
{ "glue-points", EAS_glue_points },
|
|
|
|
{ "glue-point-type", EAS_glue_point_type },
|
|
|
|
{ "glue-point-leaving-directions", EAS_glue_point_leaving_directions },
|
|
|
|
{ "text-path", EAS_text_path },
|
2004-10-12 12:05:27 +00:00
|
|
|
{ "text-path-mode", EAS_text_path_mode },
|
2005-02-21 15:03:43 +00:00
|
|
|
{ "text-path-scale", EAS_text_path_scale },
|
2004-04-02 12:52:27 +00:00
|
|
|
{ "text-path-same-letter-heights", EAS_text_path_same_letter_heights },
|
2004-11-26 13:09:29 +00:00
|
|
|
{ "modifiers", EAS_modifiers },
|
2004-04-02 12:52:27 +00:00
|
|
|
{ "equation", EAS_equation },
|
|
|
|
{ "formula", EAS_formula },
|
|
|
|
{ "handle", EAS_handle },
|
|
|
|
{ "handle-mirror-horizontal", EAS_handle_mirror_horizontal },
|
|
|
|
{ "handle-mirror-vertical", EAS_handle_mirror_vertical },
|
|
|
|
{ "handle-switched", EAS_handle_switched },
|
|
|
|
{ "handle-position", EAS_handle_position },
|
|
|
|
{ "handle-range-x-minimum", EAS_handle_range_x_minimum },
|
|
|
|
{ "handle-range-x-maximum", EAS_handle_range_x_maximum },
|
|
|
|
{ "handle-range-y-minimum", EAS_handle_range_y_minimum },
|
|
|
|
{ "handle-range-y-maximum", EAS_handle_range_y_maximum },
|
|
|
|
{ "handle-polar", EAS_handle_polar },
|
|
|
|
{ "handle-radius-range-minimum", EAS_handle_radius_range_minimum },
|
|
|
|
{ "handle-radius-range-maximum", EAS_handle_radius_range_maximum },
|
|
|
|
|
|
|
|
{ "CustomShapeEngine", EAS_CustomShapeEngine },
|
2004-10-12 12:05:27 +00:00
|
|
|
{ "CustomShapeData", EAS_CustomShapeData },
|
2004-11-26 13:09:29 +00:00
|
|
|
{ "Type", EAS_Type },
|
2004-04-02 12:52:27 +00:00
|
|
|
{ "MirroredX", EAS_MirroredX },
|
|
|
|
{ "MirroredY", EAS_MirroredY },
|
2004-10-12 12:05:27 +00:00
|
|
|
{ "ViewBox", EAS_ViewBox },
|
2004-04-02 12:52:27 +00:00
|
|
|
{ "TextRotateAngle", EAS_TextRotateAngle },
|
|
|
|
{ "ExtrusionAllowed", EAS_ExtrusionAllowed },
|
|
|
|
{ "TextPathAllowed", EAS_TextPathAllowed },
|
|
|
|
{ "ConcentricGradientFillAllowed", EAS_ConcentricGradientFillAllowed },
|
|
|
|
{ "Extrusion", EAS_Extrusion },
|
|
|
|
{ "Equations", EAS_Equations },
|
|
|
|
{ "Equation", EAS_Equation },
|
|
|
|
{ "Path", EAS_Path },
|
|
|
|
{ "TextPath", EAS_TextPath },
|
|
|
|
{ "Handles", EAS_Handles },
|
|
|
|
{ "Handle", EAS_Handle },
|
|
|
|
{ "Brightness", EAS_Brightness },
|
2004-10-12 12:05:27 +00:00
|
|
|
{ "Depth", EAS_Depth },
|
|
|
|
{ "Diffusion", EAS_Diffusion },
|
|
|
|
{ "NumberOfLineSegments", EAS_NumberOfLineSegments },
|
2004-04-02 12:52:27 +00:00
|
|
|
{ "LightFace", EAS_LightFace },
|
2004-10-12 12:05:27 +00:00
|
|
|
{ "FirstLightHarsh", EAS_FirstLightHarsh },
|
|
|
|
{ "SecondLightHarsh", EAS_SecondLightHarsh },
|
|
|
|
{ "FirstLightLevel", EAS_FirstLightLevel },
|
|
|
|
{ "SecondLightLevel", EAS_SecondLightLevel },
|
|
|
|
{ "FirstLightDirection", EAS_FirstLightDirection },
|
|
|
|
{ "SecondLightDirection", EAS_SecondLightDirection },
|
2004-04-02 12:52:27 +00:00
|
|
|
{ "Metal", EAS_Metal },
|
2004-10-12 12:05:27 +00:00
|
|
|
{ "ShadeMode", EAS_ShadeMode },
|
|
|
|
{ "RotateAngle", EAS_RotateAngle },
|
|
|
|
{ "RotationCenter", EAS_RotationCenter },
|
2004-04-02 12:52:27 +00:00
|
|
|
{ "Shininess", EAS_Shininess },
|
|
|
|
{ "Skew", EAS_Skew },
|
|
|
|
{ "Specularity", EAS_Specularity },
|
2004-10-12 12:05:27 +00:00
|
|
|
{ "ProjectionMode", EAS_ProjectionMode },
|
2004-04-02 12:52:27 +00:00
|
|
|
{ "ViewPoint", EAS_ViewPoint },
|
2004-10-12 12:05:27 +00:00
|
|
|
{ "Origin", EAS_Origin },
|
2004-04-02 12:52:27 +00:00
|
|
|
{ "Color", EAS_Color },
|
|
|
|
{ "Switched", EAS_Switched },
|
|
|
|
{ "Polar", EAS_Polar },
|
|
|
|
{ "RangeXMinimum", EAS_RangeXMinimum },
|
|
|
|
{ "RangeXMaximum", EAS_RangeXMaximum },
|
|
|
|
{ "RangeYMinimum", EAS_RangeYMinimum },
|
|
|
|
{ "RangeYMaximum", EAS_RangeYMaximum },
|
|
|
|
{ "RadiusRangeMinimum", EAS_RadiusRangeMinimum },
|
|
|
|
{ "RadiusRangeMaximum", EAS_RadiusRangeMaximum },
|
|
|
|
{ "Coordinates", EAS_Coordinates },
|
|
|
|
{ "Segments", EAS_Segments },
|
2004-11-26 13:09:29 +00:00
|
|
|
{ "StretchX", EAS_StretchX },
|
|
|
|
{ "StretchY", EAS_StretchY },
|
2004-04-02 12:52:27 +00:00
|
|
|
{ "TextFrames", EAS_TextFrames },
|
|
|
|
{ "GluePoints", EAS_GluePoints },
|
|
|
|
{ "GluePointLeavingDirections", EAS_GluePointLeavingDirections },
|
|
|
|
{ "GluePointType", EAS_GluePointType },
|
2004-10-12 12:05:27 +00:00
|
|
|
{ "TextPathMode", EAS_TextPathMode },
|
2004-04-02 12:52:27 +00:00
|
|
|
{ "ScaleX", EAS_ScaleX },
|
|
|
|
{ "SameLetterHeights", EAS_SameLetterHeights },
|
|
|
|
{ "Position", EAS_Position },
|
|
|
|
{ "AdjustmentValues", EAS_AdjustmentValues },
|
|
|
|
|
|
|
|
{ "Last", EAS_Last },
|
|
|
|
{ "NotFound", EAS_NotFound }
|
|
|
|
};
|
|
|
|
|
|
|
|
EnhancedCustomShapeTokenEnum EASGet( const rtl::OUString& rShapeType )
|
|
|
|
{
|
|
|
|
if ( !pHashMap )
|
|
|
|
{ // init hash map
|
|
|
|
::osl::MutexGuard aGuard( getHashMapMutex() );
|
|
|
|
if ( !pHashMap )
|
|
|
|
{
|
|
|
|
TypeNameHashMap* pH = new TypeNameHashMap;
|
|
|
|
const TokenTable* pPtr = pTokenTableArray;
|
|
|
|
const TokenTable* pEnd = pPtr + ( sizeof( pTokenTableArray ) / sizeof( TokenTable ) );
|
|
|
|
for ( ; pPtr < pEnd; pPtr++ )
|
|
|
|
(*pH)[ pPtr->pS ] = pPtr->pE;
|
|
|
|
pHashMap = pH;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EnhancedCustomShapeTokenEnum eRetValue = EAS_NotFound;
|
|
|
|
int i, nLen = rShapeType.getLength();
|
|
|
|
char* pBuf = new char[ nLen + 1 ];
|
|
|
|
for ( i = 0; i < nLen; i++ )
|
|
|
|
pBuf[ i ] = (char)rShapeType[ i ];
|
|
|
|
pBuf[ i ] = 0;
|
|
|
|
TypeNameHashMap::iterator aHashIter( pHashMap->find( pBuf ) );
|
|
|
|
delete[] pBuf;
|
|
|
|
if ( aHashIter != pHashMap->end() )
|
|
|
|
eRetValue = (*aHashIter).second;
|
|
|
|
return eRetValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
rtl::OUString EASGet( const EnhancedCustomShapeTokenEnum eToken )
|
|
|
|
{
|
|
|
|
sal_uInt32 i = eToken >= EAS_Last
|
|
|
|
? (sal_uInt32)EAS_NotFound
|
|
|
|
: (sal_uInt32)eToken;
|
|
|
|
return rtl::OUString::createFromAscii( pTokenTableArray[ i ].pS );
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|