163bba73cSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 363bba73cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 463bba73cSAndrew Rist * or more contributor license agreements. See the NOTICE file 563bba73cSAndrew Rist * distributed with this work for additional information 663bba73cSAndrew Rist * regarding copyright ownership. The ASF licenses this file 763bba73cSAndrew Rist * to you under the Apache License, Version 2.0 (the 863bba73cSAndrew Rist * "License"); you may not use this file except in compliance 963bba73cSAndrew Rist * with the License. You may obtain a copy of the License at 1063bba73cSAndrew Rist * 1163bba73cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 1263bba73cSAndrew Rist * 1363bba73cSAndrew Rist * Unless required by applicable law or agreed to in writing, 1463bba73cSAndrew Rist * software distributed under the License is distributed on an 1563bba73cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 1663bba73cSAndrew Rist * KIND, either express or implied. See the License for the 1763bba73cSAndrew Rist * specific language governing permissions and limitations 1863bba73cSAndrew Rist * under the License. 1963bba73cSAndrew Rist * 2063bba73cSAndrew Rist *************************************************************/ 2163bba73cSAndrew Rist 2263bba73cSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_xmloff.hxx" 26cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx" 27cdf0e10cSrcweir #include <xmloff/xmltoken.hxx> 28cdf0e10cSrcweir #include <xmloff/maptype.hxx> 29cdf0e10cSrcweir #include <xmloff/xmltypes.hxx> 30cdf0e10cSrcweir #ifndef __SGI_STL_ALGORITHM 31cdf0e10cSrcweir #include <algorithm> 32cdf0e10cSrcweir #endif 33cdf0e10cSrcweir #include "strings.hxx" 34cdf0e10cSrcweir #include <xmloff/contextid.hxx> 35cdf0e10cSrcweir #include "controlpropertymap.hxx" 36cdf0e10cSrcweir 37cdf0e10cSrcweir #include <string.h> 38cdf0e10cSrcweir 39cdf0e10cSrcweir using namespace ::xmloff::token; 40cdf0e10cSrcweir 41cdf0e10cSrcweir //......................................................................... 42cdf0e10cSrcweir namespace xmloff 43cdf0e10cSrcweir { 44cdf0e10cSrcweir //......................................................................... 45cdf0e10cSrcweir 46*1d438f2aSHerbert Dürr #define MAP_ASCII( name, prefix, token, type, context ) { name, sizeof(name)-1, prefix, token, static_cast<sal_Int32>(type|XML_TYPE_PROP_TEXT), context, SvtSaveOptions::ODFVER_010 } 47*1d438f2aSHerbert Dürr #define MAP_CONST( name, prefix, token, type, context ) { name.ascii, name.length, prefix, token, static_cast<sal_Int32>(type|XML_TYPE_PROP_TEXT), context, SvtSaveOptions::ODFVER_010 } 48*1d438f2aSHerbert Dürr #define MAP_CONST_P( name, prefix, token, type, context ) { name.ascii, name.length, prefix, token, static_cast<sal_Int32>(type|XML_TYPE_PROP_PARAGRAPH), context, SvtSaveOptions::ODFVER_010 } 49cdf0e10cSrcweir #define MAP_END() { NULL, 0, 0, XML_TOKEN_INVALID, 0, 0, SvtSaveOptions::ODFVER_010 } 50cdf0e10cSrcweir getControlStylePropertyMap_Access()51cdf0e10cSrcweir XMLPropertyMapEntry* getControlStylePropertyMap_Access( ) 52cdf0e10cSrcweir { 53cdf0e10cSrcweir static XMLPropertyMapEntry aControlStyleProperties[] = 54cdf0e10cSrcweir { 55cdf0e10cSrcweir MAP_CONST( PROPERTY_BACKGROUNDCOLOR, XML_NAMESPACE_FO, XML_BACKGROUND_COLOR, XML_TYPE_COLOR, 0 ), 56cdf0e10cSrcweir MAP_CONST_P( PROPERTY_ALIGN, XML_NAMESPACE_FO, XML_TEXT_ALIGN, XML_TYPE_TEXT_ALIGN, 0 ), 57cdf0e10cSrcweir MAP_CONST( PROPERTY_BORDER, XML_NAMESPACE_FO, XML_BORDER, XML_TYPE_CONTROL_BORDER|MID_FLAG_MULTI_PROPERTY|MID_FLAG_MERGE_ATTRIBUTE, 0 ), 58cdf0e10cSrcweir MAP_ASCII( "FontCharWidth", XML_NAMESPACE_STYLE, XML_FONT_CHAR_WIDTH, XML_TYPE_NUMBER16, 0 ), 59cdf0e10cSrcweir MAP_ASCII( "FontCharset", XML_NAMESPACE_STYLE, XML_FONT_CHARSET, XML_TYPE_TEXT_FONTENCODING, 0 ), 60cdf0e10cSrcweir MAP_ASCII( "FontFamily", XML_NAMESPACE_STYLE, XML_FONT_FAMILY_GENERIC, XML_TYPE_TEXT_FONTFAMILY, 0 ), 61cdf0e10cSrcweir MAP_ASCII( "FontHeight", XML_NAMESPACE_FO, XML_FONT_SIZE, XML_TYPE_CHAR_HEIGHT, 0 ), 62cdf0e10cSrcweir MAP_ASCII( "FontKerning", XML_NAMESPACE_STYLE, XML_LETTER_KERNING, XML_TYPE_BOOL, 0 ), 63cdf0e10cSrcweir MAP_ASCII( "FontName", XML_NAMESPACE_STYLE, XML_FONT_NAME, XML_TYPE_STRING, 0 ), 64cdf0e10cSrcweir MAP_ASCII( "FontOrientation", XML_NAMESPACE_STYLE, XML_ROTATION_ANGLE, XML_TYPE_ROTATION_ANGLE, 0 ), 65cdf0e10cSrcweir MAP_ASCII( "FontPitch", XML_NAMESPACE_STYLE, XML_FONT_PITCH, XML_TYPE_TEXT_FONTPITCH, 0 ), 66cdf0e10cSrcweir MAP_ASCII( "FontSlant", XML_NAMESPACE_FO, XML_FONT_STYLE, XML_TYPE_TEXT_POSTURE, 0 ), 67cdf0e10cSrcweir 68cdf0e10cSrcweir MAP_ASCII( "FontStrikeout", XML_NAMESPACE_STYLE, XML_TEXT_LINE_THROUGH_STYLE, XML_TYPE_TEXT_CROSSEDOUT_STYLE|MID_FLAG_MERGE_PROPERTY, 0), 69cdf0e10cSrcweir MAP_ASCII( "FontStrikeout", XML_NAMESPACE_STYLE, XML_TEXT_LINE_THROUGH_TYPE, XML_TYPE_TEXT_CROSSEDOUT_TYPE|MID_FLAG_MERGE_PROPERTY, 0), 70cdf0e10cSrcweir MAP_ASCII( "FontStrikeout", XML_NAMESPACE_STYLE, XML_TEXT_LINE_THROUGH_WIDTH, XML_TYPE_TEXT_CROSSEDOUT_WIDTH|MID_FLAG_MERGE_PROPERTY, 0), 71cdf0e10cSrcweir MAP_ASCII( "FontStrikeout", XML_NAMESPACE_STYLE, XML_TEXT_LINE_THROUGH_TEXT, XML_TYPE_TEXT_CROSSEDOUT_TEXT|MID_FLAG_MERGE_PROPERTY, 0), 72cdf0e10cSrcweir 73cdf0e10cSrcweir MAP_ASCII( "FontStyleName", XML_NAMESPACE_STYLE, XML_FONT_STYLE_NAME, XML_TYPE_STRING, 0 ), 74cdf0e10cSrcweir MAP_ASCII( "FontUnderline", XML_NAMESPACE_STYLE, XML_TEXT_UNDERLINE_STYLE, XML_TYPE_TEXT_UNDERLINE_STYLE|MID_FLAG_MERGE_PROPERTY, 0 ), 75cdf0e10cSrcweir MAP_ASCII( "FontUnderline", XML_NAMESPACE_STYLE, XML_TEXT_UNDERLINE_TYPE, XML_TYPE_TEXT_UNDERLINE_TYPE|MID_FLAG_MERGE_PROPERTY, 0 ), 76cdf0e10cSrcweir MAP_ASCII( "FontUnderline", XML_NAMESPACE_STYLE, XML_TEXT_UNDERLINE_WIDTH, XML_TYPE_TEXT_UNDERLINE_WIDTH|MID_FLAG_MERGE_PROPERTY, 0 ), 77cdf0e10cSrcweir MAP_ASCII( "FontWeight", XML_NAMESPACE_FO, XML_FONT_WEIGHT, XML_TYPE_TEXT_WEIGHT, 0 ), 78cdf0e10cSrcweir MAP_ASCII( "FontWidth", XML_NAMESPACE_STYLE, XML_FONT_WIDTH, XML_TYPE_FONT_WIDTH, 0 ), 79cdf0e10cSrcweir MAP_ASCII( "FontWordLineMode", XML_NAMESPACE_FO, XML_SCORE_SPACES, XML_TYPE_NBOOL, 0 ), 80cdf0e10cSrcweir MAP_ASCII( "SymbolColor", XML_NAMESPACE_STYLE, XML_COLOR, XML_TYPE_COLOR, 0 ), 81cdf0e10cSrcweir MAP_ASCII( "BorderColor", XML_NAMESPACE_FO, XML_BORDER, XML_TYPE_CONTROL_BORDER_COLOR|MID_FLAG_MULTI_PROPERTY|MID_FLAG_MERGE_ATTRIBUTE, 0 ), 82cdf0e10cSrcweir MAP_ASCII( "TextColor", XML_NAMESPACE_FO, XML_COLOR, XML_TYPE_COLOR, 0 ), 83cdf0e10cSrcweir 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 ), 84cdf0e10cSrcweir MAP_ASCII( "FontEmphasisMark", XML_NAMESPACE_STYLE, XML_TEXT_EMPHASIZE, XML_TYPE_CONTROL_TEXT_EMPHASIZE, 0 ), 85cdf0e10cSrcweir MAP_ASCII( "FontRelief", XML_NAMESPACE_STYLE, XML_FONT_RELIEF, XML_TYPE_TEXT_FONT_RELIEF|MID_FLAG_MULTI_PROPERTY, 0 ), 86cdf0e10cSrcweir MAP_ASCII( "TextLineColor", XML_NAMESPACE_STYLE, XML_TEXT_UNDERLINE_COLOR, XML_TYPE_TEXT_UNDERLINE_COLOR|MID_FLAG_MULTI_PROPERTY, 0 ), 87cdf0e10cSrcweir MAP_END() 88cdf0e10cSrcweir }; 89cdf0e10cSrcweir 90cdf0e10cSrcweir return aControlStyleProperties; 91cdf0e10cSrcweir } 92cdf0e10cSrcweir getControlStylePropertyMap()93cdf0e10cSrcweir const XMLPropertyMapEntry* getControlStylePropertyMap( ) 94cdf0e10cSrcweir { 95cdf0e10cSrcweir return getControlStylePropertyMap_Access(); 96cdf0e10cSrcweir } 97cdf0e10cSrcweir 98cdf0e10cSrcweir //===================================================================== 99cdf0e10cSrcweir //--------------------------------------------------------------------- 100cdf0e10cSrcweir struct XMLPropertyMapEntryLess 101cdf0e10cSrcweir { operator ()xmloff::XMLPropertyMapEntryLess102cdf0e10cSrcweir sal_Bool operator()(const XMLPropertyMapEntry& _rLeft, const XMLPropertyMapEntry& _rRight) 103cdf0e10cSrcweir { 104cdf0e10cSrcweir return strcmp(_rLeft.msApiName, _rRight.msApiName) < 0; 105cdf0e10cSrcweir } 106cdf0e10cSrcweir }; 107cdf0e10cSrcweir 108cdf0e10cSrcweir //--------------------------------------------------------------------- implSortMap(XMLPropertyMapEntry * _pMap)109cdf0e10cSrcweir void implSortMap(XMLPropertyMapEntry* _pMap) 110cdf0e10cSrcweir { 111cdf0e10cSrcweir XMLPropertyMapEntry* pEnd; 112cdf0e10cSrcweir // determine the last element 113cdf0e10cSrcweir for ( pEnd = _pMap; pEnd->msApiName; ++pEnd) 114cdf0e10cSrcweir ; 115cdf0e10cSrcweir ::std::sort(_pMap, pEnd, XMLPropertyMapEntryLess()); 116cdf0e10cSrcweir } 117cdf0e10cSrcweir 118cdf0e10cSrcweir //--------------------------------------------------------------------- initializePropertyMaps()119cdf0e10cSrcweir void initializePropertyMaps() 120cdf0e10cSrcweir { 121cdf0e10cSrcweir static sal_Bool bSorted = sal_False; 122cdf0e10cSrcweir if (!bSorted) 123cdf0e10cSrcweir { 124cdf0e10cSrcweir implSortMap(getControlStylePropertyMap_Access()); 125cdf0e10cSrcweir bSorted = sal_True; 126cdf0e10cSrcweir } 127cdf0e10cSrcweir } 128cdf0e10cSrcweir 129cdf0e10cSrcweir //===================================================================== 130cdf0e10cSrcweir //= OFormComponentStyleExportMapper 131cdf0e10cSrcweir //===================================================================== 132cdf0e10cSrcweir //--------------------------------------------------------------------- OFormComponentStyleExportMapper(const UniReference<XMLPropertySetMapper> & _rMapper)133cdf0e10cSrcweir OFormComponentStyleExportMapper::OFormComponentStyleExportMapper( const UniReference< XMLPropertySetMapper >& _rMapper ) 134cdf0e10cSrcweir :SvXMLExportPropertyMapper( _rMapper ) 135cdf0e10cSrcweir { 136cdf0e10cSrcweir } 137cdf0e10cSrcweir 138cdf0e10cSrcweir //--------------------------------------------------------------------- handleSpecialItem(SvXMLAttributeList & _rAttrList,const XMLPropertyState & _rProperty,const SvXMLUnitConverter & _rUnitConverter,const SvXMLNamespaceMap & _rNamespaceMap,const::std::vector<XMLPropertyState> * _pProperties,sal_uInt32 _nIdx) const139cdf0e10cSrcweir void OFormComponentStyleExportMapper::handleSpecialItem( SvXMLAttributeList& _rAttrList, const XMLPropertyState& _rProperty, const SvXMLUnitConverter& _rUnitConverter, 140cdf0e10cSrcweir const SvXMLNamespaceMap& _rNamespaceMap, const ::std::vector< XMLPropertyState >* _pProperties, 141cdf0e10cSrcweir sal_uInt32 _nIdx ) const 142cdf0e10cSrcweir { 143cdf0e10cSrcweir // ignore the number style of grid columns - this is formatted elsewhere 144cdf0e10cSrcweir if ( CTF_FORMS_DATA_STYLE != getPropertySetMapper()->GetEntryContextId( _rProperty.mnIndex ) ) 145cdf0e10cSrcweir SvXMLExportPropertyMapper::handleSpecialItem( _rAttrList, _rProperty, _rUnitConverter, _rNamespaceMap, _pProperties, _nIdx ); 146cdf0e10cSrcweir } 147cdf0e10cSrcweir 148cdf0e10cSrcweir //......................................................................... 149cdf0e10cSrcweir } // namespace xmloff 150cdf0e10cSrcweir //......................................................................... 151cdf0e10cSrcweir 152cdf0e10cSrcweir 153