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