1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "xmlHelper.hxx"
21 #include <xmloff/XMLConstantsPropertyHandler.hxx>
22 #include <xmloff/xmlement.hxx>
23 #include <xmloff/xmlnamespace.hxx>
24 #include <xmloff/xmltoken.hxx>
25 #include <xmloff/xmltypes.hxx>
26 #include <xmloff/maptype.hxx>
28 #include <com/sun/star/awt/TextAlign.hpp>
29 #include <strings.hxx>
30 #include <rtl/ref.hxx>
34 using namespace ::xmloff::token
;
36 OPropertyHandlerFactory::OPropertyHandlerFactory()
40 OPropertyHandlerFactory::~OPropertyHandlerFactory()
45 const XMLPropertyHandler
* OPropertyHandlerFactory::GetPropertyHandler(sal_Int32 _nType
) const
47 const XMLPropertyHandler
* pHandler
= nullptr;
51 case XML_DB_TYPE_EQUAL
:
52 if (!m_pDisplayHandler
)
54 static const SvXMLEnumMapEntry
<bool> aDisplayMap
[] =
56 { XML_VISIBLE
, true },
57 { XML_COLLAPSE
, false },
58 { XML_TOKEN_INVALID
, false }
60 m_pDisplayHandler
.reset(new XMLConstantsPropertyHandler(aDisplayMap
, XML_TOKEN_INVALID
));
62 pHandler
= m_pDisplayHandler
.get();
66 pHandler
= OControlPropertyHandlerFactory::GetPropertyHandler(_nType
);
70 rtl::Reference
< XMLPropertySetMapper
> OXMLHelper::GetTableStylesPropertySetMapper( bool bForExport
)
72 static const XMLPropertyMapEntry s_aTableStylesProperties
[] =
76 rtl::Reference
< XMLPropertyHandlerFactory
> xFac
= new ::xmloff::OControlPropertyHandlerFactory();
77 return new XMLPropertySetMapper(s_aTableStylesProperties
, xFac
, bForExport
);
80 rtl::Reference
< XMLPropertySetMapper
> OXMLHelper::GetColumnStylesPropertySetMapper( bool bForExport
)
82 static const XMLPropertyMapEntry s_aColumnStylesProperties
[] =
84 { PROPERTY_WIDTH
, XML_NAMESPACE_STYLE
, XML_COLUMN_WIDTH
, XML_TYPE_MEASURE
|XML_TYPE_PROP_TABLE_COLUMN
, 0, SvtSaveOptions::ODFSVER_010
, false },
85 { PROPERTY_HIDDEN
, XML_NAMESPACE_TABLE
, XML_DISPLAY
, XML_DB_TYPE_EQUAL
|MID_FLAG_SPECIAL_ITEM
|XML_TYPE_PROP_TABLE_COLUMN
,
86 CTF_DB_ISVISIBLE
, SvtSaveOptions::ODFSVER_010
, false },
87 { PROPERTY_NUMBERFORMAT
, XML_NAMESPACE_STYLE
, XML_DATA_STYLE_NAME
, XML_TYPE_NUMBER
|MID_FLAG_SPECIAL_ITEM
|XML_TYPE_PROP_TABLE_COLUMN
,
88 CTF_DB_NUMBERFORMAT
, SvtSaveOptions::ODFSVER_010
, false },
91 rtl::Reference
< XMLPropertyHandlerFactory
> xFac
= new OPropertyHandlerFactory();
92 return new XMLPropertySetMapper(s_aColumnStylesProperties
, xFac
, bForExport
);
95 rtl::Reference
< XMLPropertySetMapper
> OXMLHelper::GetCellStylesPropertySetMapper( bool bForExport
)
97 static const XMLPropertyMapEntry s_aCellStylesProperties
[] =
99 { PROPERTY_ALIGN
, XML_NAMESPACE_FO
, XML_TEXT_ALIGN
, XML_TYPE_TEXT_ALIGN
|XML_TYPE_PROP_PARAGRAPH
, CTF_DB_COLUMN_TEXT_ALIGN
, SvtSaveOptions::ODFSVER_010
, false },
100 { PROPERTY_FONTNAME
, XML_NAMESPACE_STYLE
, XML_FONT_NAME
, XML_TYPE_STRING
|XML_TYPE_PROP_TEXT
, 0 , SvtSaveOptions::ODFSVER_010
, false },
101 { PROPERTY_TEXTCOLOR
, XML_NAMESPACE_FO
, XML_COLOR
, XML_TYPE_COLOR
|XML_TYPE_PROP_TEXT
, 0 , SvtSaveOptions::ODFSVER_010
, false },
102 { PROPERTY_TEXTLINECOLOR
, XML_NAMESPACE_STYLE
, XML_TEXT_UNDERLINE_COLOR
,
103 XML_TYPE_TEXT_UNDERLINE_COLOR
|MID_FLAG_MULTI_PROPERTY
|XML_TYPE_PROP_TEXT
, 0 , SvtSaveOptions::ODFSVER_010
, false },
104 { PROPERTY_TEXTRELIEF
, XML_NAMESPACE_STYLE
, XML_FONT_RELIEF
,
105 XML_TYPE_TEXT_FONT_RELIEF
|MID_FLAG_MULTI_PROPERTY
|XML_TYPE_PROP_TEXT
, 0 , SvtSaveOptions::ODFSVER_010
, false },
106 { PROPERTY_TEXTEMPHASIS
, XML_NAMESPACE_STYLE
, XML_TEXT_EMPHASIZE
, XML_TYPE_CONTROL_TEXT_EMPHASIZE
|XML_TYPE_PROP_TEXT
, 0 , SvtSaveOptions::ODFSVER_010
, false },
107 { PROPERTY_FONTCHARWIDTH
, XML_NAMESPACE_STYLE
, XML_FONT_CHAR_WIDTH
, XML_TYPE_NUMBER16
|XML_TYPE_PROP_TEXT
, 0 , SvtSaveOptions::ODFSVER_010
, false },
108 { PROPERTY_FONTCHARSET
, XML_NAMESPACE_STYLE
, XML_FONT_CHARSET
, XML_TYPE_TEXT_FONTENCODING
|XML_TYPE_PROP_TEXT
, 0 , SvtSaveOptions::ODFSVER_010
, false },
109 { PROPERTY_FONTFAMILY
, XML_NAMESPACE_STYLE
, XML_FONT_FAMILY_GENERIC
, XML_TYPE_TEXT_FONTFAMILY
|XML_TYPE_PROP_TEXT
, 0 , SvtSaveOptions::ODFSVER_010
, false },
110 { PROPERTY_FONTHEIGHT
, XML_NAMESPACE_FO
, XML_FONT_SIZE
, XML_TYPE_MEASURE16
|XML_TYPE_PROP_TEXT
, 0 , SvtSaveOptions::ODFSVER_010
, false },
111 { PROPERTY_FONTKERNING
, XML_NAMESPACE_STYLE
, XML_LETTER_KERNING
, XML_TYPE_BOOL
|XML_TYPE_PROP_TEXT
, 0 , SvtSaveOptions::ODFSVER_010
, false },
112 { PROPERTY_FONTORIENTATION
, XML_NAMESPACE_STYLE
, XML_ROTATION_ANGLE
, XML_TYPE_ROTATION_ANGLE
|XML_TYPE_PROP_TEXT
, 0 , SvtSaveOptions::ODFSVER_010
, false },
113 { PROPERTY_FONTPITCH
, XML_NAMESPACE_STYLE
, XML_FONT_PITCH
, XML_TYPE_TEXT_FONTPITCH
|XML_TYPE_PROP_TEXT
, 0 , SvtSaveOptions::ODFSVER_010
, false },
114 { PROPERTY_FONTSLANT
, XML_NAMESPACE_FO
, XML_FONT_STYLE
, XML_TYPE_TEXT_POSTURE
|XML_TYPE_PROP_TEXT
, 0 , SvtSaveOptions::ODFSVER_010
, false },
115 { PROPERTY_CHAR_STRIKEOUT
, XML_NAMESPACE_STYLE
, XML_TEXT_LINE_THROUGH_STYLE
,
116 XML_TYPE_TEXT_CROSSEDOUT_STYLE
|MID_FLAG_MERGE_PROPERTY
|XML_TYPE_PROP_TEXT
, 0, SvtSaveOptions::ODFSVER_010
, false },
117 { PROPERTY_CHAR_STRIKEOUT
, XML_NAMESPACE_STYLE
, XML_TEXT_LINE_THROUGH_TYPE
,
118 XML_TYPE_TEXT_CROSSEDOUT_TYPE
|MID_FLAG_MERGE_PROPERTY
|XML_TYPE_PROP_TEXT
, 0, SvtSaveOptions::ODFSVER_010
, false },
119 { PROPERTY_CHAR_STRIKEOUT
, XML_NAMESPACE_STYLE
, XML_TEXT_LINE_THROUGH_WIDTH
,
120 XML_TYPE_TEXT_CROSSEDOUT_WIDTH
|MID_FLAG_MERGE_PROPERTY
|XML_TYPE_PROP_TEXT
, 0, SvtSaveOptions::ODFSVER_010
, false },
121 { PROPERTY_CHAR_STRIKEOUT
, XML_NAMESPACE_STYLE
, XML_TEXT_LINE_THROUGH_TEXT
,
122 XML_TYPE_TEXT_CROSSEDOUT_TEXT
|MID_FLAG_MERGE_PROPERTY
|XML_TYPE_PROP_TEXT
, 0, SvtSaveOptions::ODFSVER_010
, false },
123 { PROPERTY_FONTSTYLENAME
, XML_NAMESPACE_STYLE
, XML_FONT_STYLE_NAME
, XML_TYPE_STRING
|XML_TYPE_PROP_TEXT
, 0 , SvtSaveOptions::ODFSVER_010
, false },
124 { PROPERTY_CHAR_UNDERLINE
, XML_NAMESPACE_STYLE
, XML_TEXT_UNDERLINE_STYLE
,
125 XML_TYPE_TEXT_UNDERLINE_STYLE
|MID_FLAG_MERGE_PROPERTY
|XML_TYPE_PROP_TEXT
, 0 , SvtSaveOptions::ODFSVER_010
, false },
126 { PROPERTY_CHAR_UNDERLINE
, XML_NAMESPACE_STYLE
, XML_TEXT_UNDERLINE_TYPE
,
127 XML_TYPE_TEXT_UNDERLINE_TYPE
|MID_FLAG_MERGE_PROPERTY
|XML_TYPE_PROP_TEXT
, 0 , SvtSaveOptions::ODFSVER_010
, false },
128 { PROPERTY_CHAR_UNDERLINE
, XML_NAMESPACE_STYLE
, XML_TEXT_UNDERLINE_WIDTH
,
129 XML_TYPE_TEXT_UNDERLINE_WIDTH
|MID_FLAG_MERGE_PROPERTY
|XML_TYPE_PROP_TEXT
, 0 , SvtSaveOptions::ODFSVER_010
, false },
130 { PROPERTY_CHAR_UNDERLINE_COLOR
, XML_NAMESPACE_STYLE
, XML_TEXT_UNDERLINE_COLOR
,
131 XML_TYPE_TEXT_UNDERLINE_COLOR
|MID_FLAG_MULTI_PROPERTY
|XML_TYPE_PROP_TEXT
, 0 , SvtSaveOptions::ODFSVER_010
, false },
132 { PROPERTY_CHAR_UNDERLINE_HAS_COLOR
, XML_NAMESPACE_STYLE
, XML_TEXT_UNDERLINE_COLOR
, XML_TYPE_TEXT_UNDERLINE_HASCOLOR
|MID_FLAG_MERGE_ATTRIBUTE
|XML_TYPE_PROP_TEXT
, 0 , SvtSaveOptions::ODFSVER_010
, false },
133 { PROPERTY_FONTWEIGHT
, XML_NAMESPACE_FO
, XML_FONT_WEIGHT
, XML_TYPE_TEXT_WEIGHT
|XML_TYPE_PROP_TEXT
, 0 , SvtSaveOptions::ODFSVER_010
, false },
134 { PROPERTY_FONTWIDTH
, XML_NAMESPACE_STYLE
, XML_FONT_WIDTH
, XML_TYPE_FONT_WIDTH
|XML_TYPE_PROP_TEXT
, 0 , SvtSaveOptions::ODFSVER_010
, false },
135 { PROPERTY_FONTWORDLINEMODE
, XML_NAMESPACE_STYLE
, XML_TEXT_UNDERLINE_MODE
,
136 XML_TYPE_TEXT_LINE_MODE
|MID_FLAG_MERGE_PROPERTY
|XML_TYPE_PROP_TEXT
, 0 , SvtSaveOptions::ODFSVER_010
, false },
139 rtl::Reference
< XMLPropertyHandlerFactory
> xFac
= new /*OPropertyHandlerFactory*/::xmloff::OControlPropertyHandlerFactory();
140 return new XMLPropertySetMapper(s_aCellStylesProperties
, xFac
, bForExport
);
143 rtl::Reference
< XMLPropertySetMapper
> OXMLHelper::GetRowStylesPropertySetMapper()
145 static const XMLPropertyMapEntry s_aStylesProperties
[] =
147 { PROPERTY_ROW_HEIGHT
, XML_NAMESPACE_STYLE
, XML_ROW_HEIGHT
, XML_TYPE_MEASURE
|XML_TYPE_PROP_TABLE_ROW
, 0, SvtSaveOptions::ODFSVER_010
, false },
150 rtl::Reference
< XMLPropertyHandlerFactory
> xFac
= new OPropertyHandlerFactory();
151 return new XMLPropertySetMapper(s_aStylesProperties
, xFac
, true/*bForExport*/);
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */