Kaydet (Commit) 76dce95e authored tarafından Michael Stahl's avatar Michael Stahl

coverity#705391: xmloff: XMLMergeElemTransformerContext misuse of enum

The enum types XMLElemTransformerAction and XMLAttrTransformerAction
use the same integer values so a mixture of values from these 2 in one
switch is very suspicious.  In the various *ActionTable arrays in
OOo2Oasis/Oasis2OOo there is just one such array that mixes values from
the 2 enums, and that is just the values that coverity complains about.

The XML_ETACTION_EXTRACT_CHARACTERS was added at a later date in commits
8d374c039e7d349141befe3c9ef97f82f42bfa7
2685b93a
7d2405a5
c276550e

...but it turns out that the XMLAttrTransformerAction ones are handled
in StartElement() and ProcessAttrs() methods but the
XMLElemTransformerAction ones are handled in CreateChildContext()
methods so probably the XML_ATACTION_MOVE_FROM_ELEM* values are in
the wrong enum.

Change-Id: Ib1791f6eafac4fb1e99334f41c17a90cfb076359
üst d42c80e5
......@@ -69,9 +69,6 @@ enum XMLAttrTransformerAction
XML_ATACTION_MOVE_TO_ELEM, // turn attr into an elem
// - param1: namespace +
// token of local name
XML_ATACTION_MOVE_FROM_ELEM, // turn elem into an attr:
// - param1: namespace +
// token of local name
XML_ATACTION_NEG_PERCENT, // replace % val with 100-%
XML_ATACTION_RENAME_NEG_PERCENT, // replace % val with 100-%, rename attr
// - param1: namespace +
......@@ -113,9 +110,6 @@ enum XMLAttrTransformerAction
XML_ATACTION_RENAME_RNG2ISO_DATETIME,// converts . into , in datetimes and renames the attribute
// - param1: namespace +
// token of local name
XML_ATACTION_MOVE_FROM_ELEM_RNG2ISO_DATETIME, // turn elem into an attr and convert . to , in datetimes
// - param1: namespace +
// token of local name
XML_ATACTION_SVG_WIDTH_HEIGHT_OOO, // replace "inch" with "in" and subtracts 1/100th mm
XML_ATACTION_SVG_WIDTH_HEIGHT_OASIS, // replace "in" with "inch" and adds 1/100th mm
XML_ATACTION_DRAW_MIRROR_OOO, // renames draw:mirror to style:mirror and adapts values
......
......@@ -81,6 +81,12 @@ enum XMLElemTransformerAction
// and put them together into the
// current element
// the child elements are removed
XML_ETACTION_MOVE_TO_ATTR, // turn elem into an attr:
// - param1: namespace +
// token of local name
XML_ETACTION_MOVE_TO_ATTR_RNG2ISO_DATETIME, // turn elem into an attr and convert . to , in datetimes
// - param1: namespace +
// token of local name
XML_ETACTION_USER_DEFINED=0x40000000,// user defined actions start here
XML_ETACTION_END=XML_TACTION_END
};
......
......@@ -232,7 +232,7 @@ XMLTransformerContext *XMLMergeElemTransformerContext::CreateChildContext(
{
switch( (*aIter).second.m_nActionType )
{
case XML_ATACTION_MOVE_FROM_ELEM_RNG2ISO_DATETIME:
case XML_ETACTION_MOVE_TO_ATTR_RNG2ISO_DATETIME:
{
XMLPersTextContentTContext *pTC =
new XMLPersTextContentRNGTransformTContext(
......@@ -244,7 +244,7 @@ XMLTransformerContext *XMLMergeElemTransformerContext::CreateChildContext(
pContext = pTC;
}
break;
case XML_ATACTION_MOVE_FROM_ELEM:
case XML_ETACTION_MOVE_TO_ATTR:
{
XMLPersTextContentTContext *pTC =
new XMLPersTextContentTContext(
......
......@@ -926,24 +926,24 @@ static XMLTransformerActionInit aTableValueTypeActionTable[] =
// action table for OASIS_ANNOTATION_ACTIONS
static XMLTransformerActionInit aAnnotationActionTable[] =
{
ENTRY1Q( DC, CREATOR, XML_ATACTION_MOVE_FROM_ELEM,
ENTRY1Q( DC, CREATOR, XML_ETACTION_MOVE_TO_ATTR,
XML_NAMESPACE_OFFICE, XML_AUTHOR ),
ENTRY1Q( DC, DATE, XML_ATACTION_MOVE_FROM_ELEM_RNG2ISO_DATETIME,
ENTRY1Q( DC, DATE, XML_ETACTION_MOVE_TO_ATTR_RNG2ISO_DATETIME,
XML_NAMESPACE_OFFICE, XML_CREATE_DATE ),
ENTRY1Q( META, DATE_STRING, XML_ATACTION_MOVE_FROM_ELEM,
ENTRY1Q( META, DATE_STRING, XML_ETACTION_MOVE_TO_ATTR,
XML_NAMESPACE_OFFICE, XML_CREATE_DATE_STRING ),
ENTRY0( TEXT, P, XML_ETACTION_EXTRACT_CHARACTERS ),
ENTRY0( OFFICE, TOKEN_INVALID, XML_ATACTION_EOT )
ENTRY0( OFFICE, TOKEN_INVALID, XML_ETACTION_EOT )
};
// action table for OASIS_CHANGE_INFO_ACTIONS
static XMLTransformerActionInit aChangeInfoActionTable[] =
{
ENTRY1Q( DC, CREATOR, XML_ATACTION_MOVE_FROM_ELEM,
ENTRY1Q( DC, CREATOR, XML_ETACTION_MOVE_TO_ATTR,
XML_NAMESPACE_OFFICE, XML_CHG_AUTHOR ),
ENTRY1Q( DC, DATE, XML_ATACTION_MOVE_FROM_ELEM_RNG2ISO_DATETIME,
ENTRY1Q( DC, DATE, XML_ETACTION_MOVE_TO_ATTR_RNG2ISO_DATETIME,
XML_NAMESPACE_OFFICE, XML_CHG_DATE_TIME ),
ENTRY0( OFFICE, TOKEN_INVALID, XML_ATACTION_EOT )
ENTRY0( OFFICE, TOKEN_INVALID, XML_ETACTION_EOT )
};
// OASIS_BACKGROUND_IMAGE_ACTIONS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment