1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: controlpropertymap.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
33 #include "xmlnmspe.hxx"
34 #include <xmloff/xmltoken.hxx>
35 #include <xmloff/maptype.hxx>
36 #include <xmloff/xmltypes.hxx>
37 #ifndef __SGI_STL_ALGORITHM
40 #include "strings.hxx"
41 #include <xmloff/contextid.hxx>
42 #include "controlpropertymap.hxx"
46 using namespace ::xmloff::token
;
48 //.........................................................................
51 //.........................................................................
53 #define MAP_ASCII( name, prefix, token, type, context ) { name, sizeof(name)-1, prefix, token, type|XML_TYPE_PROP_TEXT, context, SvtSaveOptions::ODFVER_010 }
54 #define MAP_CONST( name, prefix, token, type, context ) { name.ascii, name.length, prefix, token, type|XML_TYPE_PROP_TEXT, context, SvtSaveOptions::ODFVER_010 }
55 #define MAP_CONST_P( name, prefix, token, type, context ) { name.ascii, name.length, prefix, token, type|XML_TYPE_PROP_PARAGRAPH, context, SvtSaveOptions::ODFVER_010 }
56 #define MAP_END() { NULL, 0, 0, XML_TOKEN_INVALID, 0, 0, SvtSaveOptions::ODFVER_010 }
58 XMLPropertyMapEntry
* getControlStylePropertyMap_Access( )
60 static XMLPropertyMapEntry aControlStyleProperties
[] =
62 MAP_CONST( PROPERTY_BACKGROUNDCOLOR
, XML_NAMESPACE_FO
, XML_BACKGROUND_COLOR
, XML_TYPE_COLOR
, 0 ),
63 MAP_CONST_P( PROPERTY_ALIGN
, XML_NAMESPACE_FO
, XML_TEXT_ALIGN
, XML_TYPE_TEXT_ALIGN
, 0 ),
64 MAP_CONST( PROPERTY_BORDER
, XML_NAMESPACE_FO
, XML_BORDER
, XML_TYPE_CONTROL_BORDER
|MID_FLAG_MULTI_PROPERTY
|MID_FLAG_MERGE_ATTRIBUTE
, 0 ),
65 MAP_ASCII( "FontCharWidth", XML_NAMESPACE_STYLE
, XML_FONT_CHAR_WIDTH
, XML_TYPE_NUMBER16
, 0 ),
66 MAP_ASCII( "FontCharset", XML_NAMESPACE_STYLE
, XML_FONT_CHARSET
, XML_TYPE_TEXT_FONTENCODING
, 0 ),
67 MAP_ASCII( "FontFamily", XML_NAMESPACE_STYLE
, XML_FONT_FAMILY_GENERIC
, XML_TYPE_TEXT_FONTFAMILY
, 0 ),
68 MAP_ASCII( "FontHeight", XML_NAMESPACE_FO
, XML_FONT_SIZE
, XML_TYPE_CHAR_HEIGHT
, 0 ),
69 MAP_ASCII( "FontKerning", XML_NAMESPACE_STYLE
, XML_LETTER_KERNING
, XML_TYPE_BOOL
, 0 ),
70 MAP_ASCII( "FontName", XML_NAMESPACE_STYLE
, XML_FONT_NAME
, XML_TYPE_STRING
, 0 ),
71 MAP_ASCII( "FontOrientation", XML_NAMESPACE_STYLE
, XML_ROTATION_ANGLE
, XML_TYPE_ROTATION_ANGLE
, 0 ),
72 MAP_ASCII( "FontPitch", XML_NAMESPACE_STYLE
, XML_FONT_PITCH
, XML_TYPE_TEXT_FONTPITCH
, 0 ),
73 MAP_ASCII( "FontSlant", XML_NAMESPACE_FO
, XML_FONT_STYLE
, XML_TYPE_TEXT_POSTURE
, 0 ),
75 MAP_ASCII( "FontStrikeout", XML_NAMESPACE_STYLE
, XML_TEXT_LINE_THROUGH_STYLE
, XML_TYPE_TEXT_CROSSEDOUT_STYLE
|MID_FLAG_MERGE_PROPERTY
, 0),
76 MAP_ASCII( "FontStrikeout", XML_NAMESPACE_STYLE
, XML_TEXT_LINE_THROUGH_TYPE
, XML_TYPE_TEXT_CROSSEDOUT_TYPE
|MID_FLAG_MERGE_PROPERTY
, 0),
77 MAP_ASCII( "FontStrikeout", XML_NAMESPACE_STYLE
, XML_TEXT_LINE_THROUGH_WIDTH
, XML_TYPE_TEXT_CROSSEDOUT_WIDTH
|MID_FLAG_MERGE_PROPERTY
, 0),
78 MAP_ASCII( "FontStrikeout", XML_NAMESPACE_STYLE
, XML_TEXT_LINE_THROUGH_TEXT
, XML_TYPE_TEXT_CROSSEDOUT_TEXT
|MID_FLAG_MERGE_PROPERTY
, 0),
80 MAP_ASCII( "FontStyleName", XML_NAMESPACE_STYLE
, XML_FONT_STYLE_NAME
, XML_TYPE_STRING
, 0 ),
81 MAP_ASCII( "FontUnderline", XML_NAMESPACE_STYLE
, XML_TEXT_UNDERLINE_STYLE
, XML_TYPE_TEXT_UNDERLINE_STYLE
|MID_FLAG_MERGE_PROPERTY
, 0 ),
82 MAP_ASCII( "FontUnderline", XML_NAMESPACE_STYLE
, XML_TEXT_UNDERLINE_TYPE
, XML_TYPE_TEXT_UNDERLINE_TYPE
|MID_FLAG_MERGE_PROPERTY
, 0 ),
83 MAP_ASCII( "FontUnderline", XML_NAMESPACE_STYLE
, XML_TEXT_UNDERLINE_WIDTH
, XML_TYPE_TEXT_UNDERLINE_WIDTH
|MID_FLAG_MERGE_PROPERTY
, 0 ),
84 MAP_ASCII( "FontWeight", XML_NAMESPACE_FO
, XML_FONT_WEIGHT
, XML_TYPE_TEXT_WEIGHT
, 0 ),
85 MAP_ASCII( "FontWidth", XML_NAMESPACE_STYLE
, XML_FONT_WIDTH
, XML_TYPE_FONT_WIDTH
, 0 ),
86 MAP_ASCII( "FontWordLineMode", XML_NAMESPACE_FO
, XML_SCORE_SPACES
, XML_TYPE_NBOOL
, 0 ),
87 MAP_ASCII( "SymbolColor", XML_NAMESPACE_STYLE
, XML_COLOR
, XML_TYPE_COLOR
, 0 ),
88 MAP_ASCII( "BorderColor", XML_NAMESPACE_FO
, XML_BORDER
, XML_TYPE_CONTROL_BORDER_COLOR
|MID_FLAG_MULTI_PROPERTY
|MID_FLAG_MERGE_ATTRIBUTE
, 0 ),
89 MAP_ASCII( "TextColor", XML_NAMESPACE_FO
, XML_COLOR
, XML_TYPE_COLOR
, 0 ),
90 MAP_CONST( PROPERTY_FORMATKEY
, XML_NAMESPACE_STYLE
, XML_DATA_STYLE_NAME
, XML_TYPE_STRING
| MID_FLAG_NO_PROPERTY_EXPORT
| MID_FLAG_SPECIAL_ITEM
, CTF_FORMS_DATA_STYLE
),
91 MAP_ASCII( "FontEmphasisMark", XML_NAMESPACE_STYLE
, XML_TEXT_EMPHASIZE
, XML_TYPE_CONTROL_TEXT_EMPHASIZE
, 0 ),
92 MAP_ASCII( "FontRelief", XML_NAMESPACE_STYLE
, XML_FONT_RELIEF
, XML_TYPE_TEXT_FONT_RELIEF
|MID_FLAG_MULTI_PROPERTY
, 0 ),
93 MAP_ASCII( "TextLineColor", XML_NAMESPACE_STYLE
, XML_TEXT_UNDERLINE_COLOR
, XML_TYPE_TEXT_UNDERLINE_COLOR
|MID_FLAG_MULTI_PROPERTY
, 0 ),
97 return aControlStyleProperties
;
100 const XMLPropertyMapEntry
* getControlStylePropertyMap( )
102 return getControlStylePropertyMap_Access();
105 //=====================================================================
106 //---------------------------------------------------------------------
107 struct XMLPropertyMapEntryLess
109 sal_Bool
operator()(const XMLPropertyMapEntry
& _rLeft
, const XMLPropertyMapEntry
& _rRight
)
111 return strcmp(_rLeft
.msApiName
, _rRight
.msApiName
) < 0;
115 //---------------------------------------------------------------------
116 void implSortMap(XMLPropertyMapEntry
* _pMap
)
118 XMLPropertyMapEntry
* pEnd
;
119 // determine the last element
120 for ( pEnd
= _pMap
; pEnd
->msApiName
; ++pEnd
)
122 ::std::sort(_pMap
, pEnd
, XMLPropertyMapEntryLess());
125 //---------------------------------------------------------------------
126 void initializePropertyMaps()
128 static sal_Bool bSorted
= sal_False
;
131 implSortMap(getControlStylePropertyMap_Access());
136 //=====================================================================
137 //= OFormComponentStyleExportMapper
138 //=====================================================================
139 //---------------------------------------------------------------------
140 OFormComponentStyleExportMapper::OFormComponentStyleExportMapper( const UniReference
< XMLPropertySetMapper
>& _rMapper
)
141 :SvXMLExportPropertyMapper( _rMapper
)
145 //---------------------------------------------------------------------
146 void OFormComponentStyleExportMapper::handleSpecialItem( SvXMLAttributeList
& _rAttrList
, const XMLPropertyState
& _rProperty
, const SvXMLUnitConverter
& _rUnitConverter
,
147 const SvXMLNamespaceMap
& _rNamespaceMap
, const ::std::vector
< XMLPropertyState
>* _pProperties
,
148 sal_uInt32 _nIdx
) const
150 // ignore the number style of grid columns - this is formatted elsewhere
151 if ( CTF_FORMS_DATA_STYLE
!= getPropertySetMapper()->GetEntryContextId( _rProperty
.mnIndex
) )
152 SvXMLExportPropertyMapper::handleSpecialItem( _rAttrList
, _rProperty
, _rUnitConverter
, _rNamespaceMap
, _pProperties
, _nIdx
);
155 //.........................................................................
156 } // namespace xmloff
157 //.........................................................................