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: xmlHelper.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_dbaccess.hxx"
33 #ifndef DBA_XMLHELPER_HXX
34 #include "xmlHelper.hxx"
36 #ifndef _XMLOFF_XMLNMSPE_HXX
37 #include <xmloff/xmlnmspe.hxx>
39 #ifndef _XMLOFF_XMLTOKEN_HXX
40 #include <xmloff/xmltoken.hxx>
42 #ifndef _COM_SUN_STAR_AWT_TEXTALIGN_HPP_
43 #include <com/sun/star/awt/TextAlign.hpp>
45 #ifndef DBACCESS_SHARED_XMLSTRINGS_HRC
46 #include "xmlstrings.hrc"
48 #ifndef DBA_XMLENUMS_HXX
49 #include "xmlEnums.hxx"
51 #ifndef _XMLOFF_CONTEXTID_HXX_
52 #include <xmloff/contextid.hxx>
54 #ifndef _XMLOFF_XMLCONSTANTSPROPERTYHANDLER_HXX
55 #include <xmloff/XMLConstantsPropertyHandler.hxx>
57 #ifndef _XMLOFF_XMLEMENT_HXX
58 #include <xmloff/xmlement.hxx>
60 #ifndef _COM_SUN_STAR_AWT_TEXTALIGN_HPP_
61 #include <com/sun/star/awt/TextAlign.hpp>
63 #ifndef _TOOLS_DEBUG_HXX
64 #include <tools/debug.hxx>
69 using namespace ::xmloff::token
;
70 using namespace ::com::sun::star::awt
;
71 DBG_NAME(OPropertyHandlerFactory
)
73 OPropertyHandlerFactory::OPropertyHandlerFactory()
75 DBG_CTOR(OPropertyHandlerFactory
,NULL
);
78 // -----------------------------------------------------------------------------
79 OPropertyHandlerFactory::~OPropertyHandlerFactory()
82 DBG_DTOR(OPropertyHandlerFactory
,NULL
);
84 // -----------------------------------------------------------------------------
85 const XMLPropertyHandler
* OPropertyHandlerFactory::GetPropertyHandler(sal_Int32 _nType
) const
87 const XMLPropertyHandler
* pHandler
= NULL
;
91 case XML_DB_TYPE_EQUAL
:
92 if ( !m_pDisplayHandler
.get() )
94 static SvXMLEnumMapEntry aDisplayMap
[] =
96 { XML_VISIBLE
, sal_True
},
97 { XML_COLLAPSE
, sal_False
},
98 { XML_TOKEN_INVALID
, 0 }
100 m_pDisplayHandler
.reset(new XMLConstantsPropertyHandler(aDisplayMap
, XML_TOKEN_INVALID
));
102 pHandler
= m_pDisplayHandler
.get();
106 pHandler
= OControlPropertyHandlerFactory::GetPropertyHandler(_nType
);
109 // -----------------------------------------------------------------------------
110 #define MAP_CONST( name, prefix, token, type, context ) { name.ascii, name.length, prefix, token, type|XML_TYPE_PROP_TABLE, context, SvtSaveOptions::ODFVER_010 }
111 #define MAP_CONST_ASCII( name, prefix, token, type, context ) { name, sizeof(name)-1, prefix, token, type|XML_TYPE_PROP_TABLE, context, SvtSaveOptions::ODFVER_010 }
112 #define MAP_END() { NULL, 0, 0, XML_TOKEN_INVALID, 0 , 0, SvtSaveOptions::ODFVER_010}
113 // -----------------------------------------------------------------------------
114 UniReference
< XMLPropertySetMapper
> OXMLHelper::GetTableStylesPropertySetMapper()
116 static const XMLPropertyMapEntry s_aTableStylesProperties
[] =
118 //MAP_CONST( PROPERTY_FONTNAME, XML_NAMESPACE_STYLE, XML_FONT_NAME, XML_TYPE_STRING, 0 ),
119 //MAP_CONST( PROPERTY_TEXTCOLOR, XML_NAMESPACE_FO, XML_COLOR, XML_TYPE_COLOR, 0 ),
120 //MAP_CONST( PROPERTY_TEXTLINECOLOR, XML_NAMESPACE_STYLE, XML_TEXT_UNDERLINE_COLOR, XML_TYPE_TEXT_UNDERLINE_COLOR|MID_FLAG_MULTI_PROPERTY, 0 ),
122 //MAP_CONST( PROPERTY_TEXTRELIEF, XML_NAMESPACE_STYLE, XML_FONT_RELIEF, XML_TYPE_TEXT_FONT_RELIEF|MID_FLAG_MULTI_PROPERTY, 0 ),
123 //MAP_CONST( PROPERTY_TEXTEMPHASIS, XML_NAMESPACE_STYLE, XML_TEXT_EMPHASIZE, XML_TYPE_CONTROL_TEXT_EMPHASIZE, 0 ),
124 //MAP_CONST( PROPERTY_FONTCHARWIDTH, XML_NAMESPACE_STYLE, XML_FONT_CHAR_WIDTH, XML_TYPE_NUMBER16, 0 ),
125 //MAP_CONST( PROPERTY_FONTCHARSET, XML_NAMESPACE_STYLE, XML_FONT_CHARSET, XML_TYPE_TEXT_FONTENCODING, 0 ),
126 //MAP_CONST( PROPERTY_FONTFAMILY, XML_NAMESPACE_STYLE, XML_FONT_FAMILY_GENERIC, XML_TYPE_TEXT_FONTFAMILY, 0 ),
127 //MAP_CONST( PROPERTY_FONTHEIGHT, XML_NAMESPACE_FO, XML_FONT_SIZE, XML_TYPE_MEASURE16, 0 ),
128 //MAP_CONST( PROPERTY_FONTKERNING, XML_NAMESPACE_STYLE, XML_LETTER_KERNING, XML_TYPE_BOOL, 0 ),
130 //MAP_CONST( PROPERTY_FONTORIENTATION, XML_NAMESPACE_STYLE, XML_ROTATION_ANGLE, XML_TYPE_ROTATION_ANGLE, 0 ),
131 //MAP_CONST( PROPERTY_FONTPITCH, XML_NAMESPACE_STYLE, XML_FONT_PITCH, XML_TYPE_TEXT_FONTPITCH, 0 ),
132 //MAP_CONST( PROPERTY_FONTSLANT, XML_NAMESPACE_FO, XML_FONT_STYLE, XML_TYPE_TEXT_POSTURE, 0 ),
133 //MAP_CONST_ASCII( "CharStrikeout", XML_NAMESPACE_STYLE, XML_TEXT_LINE_THROUGH_STYLE, XML_TYPE_TEXT_CROSSEDOUT_STYLE|MID_FLAG_MERGE_PROPERTY, 0),
134 //MAP_CONST_ASCII( "CharStrikeout", XML_NAMESPACE_STYLE, XML_TEXT_LINE_THROUGH_TYPE, XML_TYPE_TEXT_CROSSEDOUT_TYPE|MID_FLAG_MERGE_PROPERTY, 0),
135 //MAP_CONST_ASCII( "CharStrikeout", XML_NAMESPACE_STYLE, XML_TEXT_LINE_THROUGH_WIDTH, XML_TYPE_TEXT_CROSSEDOUT_WIDTH|MID_FLAG_MERGE_PROPERTY, 0),
136 //MAP_CONST_ASCII( "CharStrikeout", XML_NAMESPACE_STYLE, XML_TEXT_LINE_THROUGH_TEXT, XML_TYPE_TEXT_CROSSEDOUT_TEXT|MID_FLAG_MERGE_PROPERTY, 0),
137 //MAP_CONST( PROPERTY_FONTSTYLENAME, XML_NAMESPACE_STYLE, XML_FONT_STYLE_NAME, XML_TYPE_STRING, 0 ),
138 //MAP_CONST_ASCII( "CharUnderline", XML_NAMESPACE_STYLE, XML_TEXT_UNDERLINE_STYLE, XML_TYPE_TEXT_UNDERLINE_STYLE|MID_FLAG_MERGE_PROPERTY, 0 ),
139 //MAP_CONST_ASCII( "CharUnderline", XML_NAMESPACE_STYLE, XML_TEXT_UNDERLINE_TYPE, XML_TYPE_TEXT_UNDERLINE_TYPE|MID_FLAG_MERGE_PROPERTY, 0 ),
140 //MAP_CONST_ASCII( "CharUnderline", XML_NAMESPACE_STYLE, XML_TEXT_UNDERLINE_WIDTH, XML_TYPE_TEXT_UNDERLINE_WIDTH|MID_FLAG_MERGE_PROPERTY, 0 ),
141 //MAP_CONST_ASCII( "CharUnderlineColor", XML_NAMESPACE_STYLE, XML_TEXT_UNDERLINE_COLOR, XML_TYPE_TEXT_UNDERLINE_COLOR|MID_FLAG_MULTI_PROPERTY, 0 ),
142 //MAP_CONST_ASCII( "CharUnderlineHasColor",XML_NAMESPACE_STYLE, XML_TEXT_UNDERLINE_COLOR, XML_TYPE_TEXT_UNDERLINE_HASCOLOR|MID_FLAG_MERGE_ATTRIBUTE, 0 ),
143 //MAP_CONST( PROPERTY_FONTWEIGHT, XML_NAMESPACE_FO, XML_FONT_WEIGHT, XML_TYPE_TEXT_WEIGHT, 0 ),
144 //MAP_CONST( PROPERTY_FONTWIDTH, XML_NAMESPACE_STYLE, XML_FONT_WIDTH, XML_TYPE_FONT_WIDTH, 0 ),
145 //MAP_CONST( PROPERTY_FONTWORDLINEMODE, XML_NAMESPACE_STYLE, XML_TEXT_UNDERLINE_MODE, XML_TYPE_TEXT_LINE_MODE, 0 ),
148 UniReference
< XMLPropertyHandlerFactory
> xFac
= new ::xmloff::OControlPropertyHandlerFactory();
149 return new XMLPropertySetMapper((XMLPropertyMapEntry
*)s_aTableStylesProperties
, xFac
);
151 // -----------------------------------------------------------------------------
152 UniReference
< XMLPropertySetMapper
> OXMLHelper::GetColumnStylesPropertySetMapper()
154 #define MAP_CONST_COLUMN( name, prefix, token, type, context ) { name.ascii, name.length, prefix, token, type|XML_TYPE_PROP_TABLE_COLUMN, context, SvtSaveOptions::ODFVER_010 }
155 static const XMLPropertyMapEntry s_aColumnStylesProperties
[] =
157 MAP_CONST_COLUMN( PROPERTY_WIDTH
, XML_NAMESPACE_STYLE
, XML_COLUMN_WIDTH
, XML_TYPE_MEASURE
, 0),
158 MAP_CONST_COLUMN( PROPERTY_HIDDEN
, XML_NAMESPACE_TABLE
, XML_DISPLAY
, XML_DB_TYPE_EQUAL
|MID_FLAG_SPECIAL_ITEM
, CTF_DB_ISVISIBLE
),
159 MAP_CONST_COLUMN( PROPERTY_NUMBERFORMAT
, XML_NAMESPACE_STYLE
, XML_DATA_STYLE_NAME
, XML_TYPE_NUMBER
|MID_FLAG_SPECIAL_ITEM
, CTF_DB_NUMBERFORMAT
),
162 UniReference
< XMLPropertyHandlerFactory
> xFac
= new OPropertyHandlerFactory();
163 return new XMLPropertySetMapper((XMLPropertyMapEntry
*)s_aColumnStylesProperties
, xFac
);
165 // -----------------------------------------------------------------------------
166 UniReference
< XMLPropertySetMapper
> OXMLHelper::GetCellStylesPropertySetMapper()
168 #define MAP_CONST_CELL( name, prefix, token, type, context ) { name.ascii, name.length, prefix, token, type|XML_TYPE_PROP_PARAGRAPH, context, SvtSaveOptions::ODFVER_010 }
169 #define MAP_CONST_TEXT( name, prefix, token, type, context ) { name.ascii, name.length, prefix, token, type|XML_TYPE_PROP_TEXT, context, SvtSaveOptions::ODFVER_010 }
170 #define MAP_CONST_TEXT_ASCII( name, prefix, token, type, context ) { name, sizeof(name)-1, prefix, token, type|XML_TYPE_PROP_TEXT, context, SvtSaveOptions::ODFVER_010 }
171 static const XMLPropertyMapEntry s_aCellStylesProperties
[] =
173 MAP_CONST_CELL( PROPERTY_ALIGN
, XML_NAMESPACE_FO
, XML_TEXT_ALIGN
, XML_TYPE_TEXT_ALIGN
, CTF_DB_COLUMN_TEXT_ALIGN
),
174 MAP_CONST_TEXT( PROPERTY_FONTNAME
, XML_NAMESPACE_STYLE
, XML_FONT_NAME
, XML_TYPE_STRING
, 0 ),
175 MAP_CONST_TEXT( PROPERTY_TEXTCOLOR
, XML_NAMESPACE_FO
, XML_COLOR
, XML_TYPE_COLOR
, 0 ),
176 MAP_CONST_TEXT( PROPERTY_TEXTLINECOLOR
, XML_NAMESPACE_STYLE
, XML_TEXT_UNDERLINE_COLOR
, XML_TYPE_TEXT_UNDERLINE_COLOR
|MID_FLAG_MULTI_PROPERTY
, 0 ),
178 MAP_CONST_TEXT( PROPERTY_TEXTRELIEF
, XML_NAMESPACE_STYLE
, XML_FONT_RELIEF
, XML_TYPE_TEXT_FONT_RELIEF
|MID_FLAG_MULTI_PROPERTY
, 0 ),
179 MAP_CONST_TEXT( PROPERTY_TEXTEMPHASIS
, XML_NAMESPACE_STYLE
, XML_TEXT_EMPHASIZE
, XML_TYPE_CONTROL_TEXT_EMPHASIZE
, 0 ),
180 MAP_CONST_TEXT( PROPERTY_FONTCHARWIDTH
, XML_NAMESPACE_STYLE
, XML_FONT_CHAR_WIDTH
, XML_TYPE_NUMBER16
, 0 ),
181 MAP_CONST_TEXT( PROPERTY_FONTCHARSET
, XML_NAMESPACE_STYLE
, XML_FONT_CHARSET
, XML_TYPE_TEXT_FONTENCODING
, 0 ),
182 MAP_CONST_TEXT( PROPERTY_FONTFAMILY
, XML_NAMESPACE_STYLE
, XML_FONT_FAMILY_GENERIC
, XML_TYPE_TEXT_FONTFAMILY
, 0 ),
183 MAP_CONST_TEXT( PROPERTY_FONTHEIGHT
, XML_NAMESPACE_FO
, XML_FONT_SIZE
, XML_TYPE_MEASURE16
, 0 ),
184 MAP_CONST_TEXT( PROPERTY_FONTKERNING
, XML_NAMESPACE_STYLE
, XML_LETTER_KERNING
, XML_TYPE_BOOL
, 0 ),
186 MAP_CONST_TEXT( PROPERTY_FONTORIENTATION
, XML_NAMESPACE_STYLE
, XML_ROTATION_ANGLE
, XML_TYPE_ROTATION_ANGLE
, 0 ),
187 MAP_CONST_TEXT( PROPERTY_FONTPITCH
, XML_NAMESPACE_STYLE
, XML_FONT_PITCH
, XML_TYPE_TEXT_FONTPITCH
, 0 ),
188 MAP_CONST_TEXT( PROPERTY_FONTSLANT
, XML_NAMESPACE_FO
, XML_FONT_STYLE
, XML_TYPE_TEXT_POSTURE
, 0 ),
189 MAP_CONST_TEXT_ASCII( "CharStrikeout", XML_NAMESPACE_STYLE
, XML_TEXT_LINE_THROUGH_STYLE
, XML_TYPE_TEXT_CROSSEDOUT_STYLE
|MID_FLAG_MERGE_PROPERTY
, 0),
190 MAP_CONST_TEXT_ASCII( "CharStrikeout", XML_NAMESPACE_STYLE
, XML_TEXT_LINE_THROUGH_TYPE
, XML_TYPE_TEXT_CROSSEDOUT_TYPE
|MID_FLAG_MERGE_PROPERTY
, 0),
191 MAP_CONST_TEXT_ASCII( "CharStrikeout", XML_NAMESPACE_STYLE
, XML_TEXT_LINE_THROUGH_WIDTH
, XML_TYPE_TEXT_CROSSEDOUT_WIDTH
|MID_FLAG_MERGE_PROPERTY
, 0),
192 MAP_CONST_TEXT_ASCII( "CharStrikeout", XML_NAMESPACE_STYLE
, XML_TEXT_LINE_THROUGH_TEXT
, XML_TYPE_TEXT_CROSSEDOUT_TEXT
|MID_FLAG_MERGE_PROPERTY
, 0),
193 MAP_CONST_TEXT( PROPERTY_FONTSTYLENAME
, XML_NAMESPACE_STYLE
, XML_FONT_STYLE_NAME
, XML_TYPE_STRING
, 0 ),
194 MAP_CONST_TEXT_ASCII( "CharUnderline", XML_NAMESPACE_STYLE
, XML_TEXT_UNDERLINE_STYLE
, XML_TYPE_TEXT_UNDERLINE_STYLE
|MID_FLAG_MERGE_PROPERTY
, 0 ),
195 MAP_CONST_TEXT_ASCII( "CharUnderline", XML_NAMESPACE_STYLE
, XML_TEXT_UNDERLINE_TYPE
, XML_TYPE_TEXT_UNDERLINE_TYPE
|MID_FLAG_MERGE_PROPERTY
, 0 ),
196 MAP_CONST_TEXT_ASCII( "CharUnderline", XML_NAMESPACE_STYLE
, XML_TEXT_UNDERLINE_WIDTH
, XML_TYPE_TEXT_UNDERLINE_WIDTH
|MID_FLAG_MERGE_PROPERTY
, 0 ),
197 MAP_CONST_TEXT_ASCII( "CharUnderlineColor", XML_NAMESPACE_STYLE
, XML_TEXT_UNDERLINE_COLOR
, XML_TYPE_TEXT_UNDERLINE_COLOR
|MID_FLAG_MULTI_PROPERTY
, 0 ),
198 MAP_CONST_TEXT_ASCII( "CharUnderlineHasColor",XML_NAMESPACE_STYLE
, XML_TEXT_UNDERLINE_COLOR
, XML_TYPE_TEXT_UNDERLINE_HASCOLOR
|MID_FLAG_MERGE_ATTRIBUTE
, 0 ),
199 MAP_CONST_TEXT( PROPERTY_FONTWEIGHT
, XML_NAMESPACE_FO
, XML_FONT_WEIGHT
, XML_TYPE_TEXT_WEIGHT
, 0 ),
200 MAP_CONST_TEXT( PROPERTY_FONTWIDTH
, XML_NAMESPACE_STYLE
, XML_FONT_WIDTH
, XML_TYPE_FONT_WIDTH
, 0 ),
201 MAP_CONST_TEXT( PROPERTY_FONTWORDLINEMODE
, XML_NAMESPACE_STYLE
, XML_TEXT_UNDERLINE_MODE
, XML_TYPE_TEXT_LINE_MODE
|MID_FLAG_MERGE_PROPERTY
, 0 ),
204 UniReference
< XMLPropertyHandlerFactory
> xFac
= new /*OPropertyHandlerFactory*/::xmloff::OControlPropertyHandlerFactory();
205 return new XMLPropertySetMapper((XMLPropertyMapEntry
*)s_aCellStylesProperties
, xFac
);
207 // -----------------------------------------------------------------------------
208 UniReference
< XMLPropertySetMapper
> OXMLHelper::GetRowStylesPropertySetMapper()
210 #define MAP_CONST_ROW( name, prefix, token, type, context ) { name.ascii, name.length, prefix, token, type|XML_TYPE_PROP_TABLE_ROW, context, SvtSaveOptions::ODFVER_010 }
211 static const XMLPropertyMapEntry s_aStylesProperties
[] =
213 MAP_CONST_ROW( PROPERTY_ROW_HEIGHT
, XML_NAMESPACE_STYLE
, XML_ROW_HEIGHT
, XML_TYPE_MEASURE
, 0),
216 UniReference
< XMLPropertyHandlerFactory
> xFac
= new OPropertyHandlerFactory();
217 return new XMLPropertySetMapper((XMLPropertyMapEntry
*)s_aStylesProperties
, xFac
);
219 // -----------------------------------------------------------------------------