summaryrefslogtreecommitdiffstats
path: root/oox
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@suse.cz>2011-12-20 10:42:30 +0100
committerLuboš Luňák <l.lunak@suse.cz>2011-12-20 10:49:40 +0100
commit0acff1783abf132a9fc3481848b6b1a81559086a (patch)
tree3aba7f01a6be153aa428e6a17caee531d42821fb /oox
parentByteString->rtl::OString (diff)
downloadcore-0acff1783abf132a9fc3481848b6b1a81559086a.tar.gz
core-0acff1783abf132a9fc3481848b6b1a81559086a.zip
skip unknown elements when reading multiple elements from docx mathml
Diffstat (limited to 'oox')
-rw-r--r--oox/inc/oox/mathml/importutils.hxx19
-rw-r--r--oox/source/mathml/importutils.cxx12
2 files changed, 21 insertions, 10 deletions
diff --git a/oox/inc/oox/mathml/importutils.hxx b/oox/inc/oox/mathml/importutils.hxx
index 6906851e5091..9b90681ffb0a 100644
--- a/oox/inc/oox/mathml/importutils.hxx
+++ b/oox/inc/oox/mathml/importutils.hxx
@@ -104,7 +104,18 @@ while( !stream.atEnd() && stream.currentToken() != CLOSING( element ))
stream.ensureClosingTag( element );
@endcode
- If there may be just a one type of sub-element, handle it directly without the switch statement.
+ If there may not be a zero number of sub-elements, use a helper bool variable or use a do-while loop.
+
+ Parse an element that may contain an unknown number of sub-elements of the same type:
+ @code
+stream.ensureOpeningTag( element );
+while( !stream.atEnd() && stream.findTag( OPENING( subelement )))
+ {
+ handleSubelement();
+ }
+stream.ensureClosingTag( element );
+ @endcode
+
If there may not be a zero number of sub-elements, use a helper bool variable or use a do-while loop.
@since 3.5
@@ -198,9 +209,9 @@ public:
void ensureClosingTag( int token );
/**
Tries to find the given token, until either found (returns true) or end of current element.
- Position in the stream is set to make the tag current.
+ Position in the stream is set to make the tag current (i.e. it will be the next one read).
*/
- bool recoverAndFindTag( int token );
+ bool findTag( int token );
/**
Skips the given element (i.e. reads up to and including the matching closing tag).
*/
@@ -211,7 +222,7 @@ public:
void handleUnexpectedTag();
protected:
Tag checkTag( int token, bool optional );
- bool recoverAndFindTagInternal( int token, bool silent );
+ bool findTagInternal( int token, bool silent );
void skipElementInternal( int token, bool silent );
std::vector< Tag > tags;
unsigned int pos;
diff --git a/oox/source/mathml/importutils.cxx b/oox/source/mathml/importutils.cxx
index 2a7d19c9db07..4a71d5616729 100644
--- a/oox/source/mathml/importutils.cxx
+++ b/oox/source/mathml/importutils.cxx
@@ -233,14 +233,14 @@ XmlStream::Tag XmlStream::checkTag( int token, bool optional )
if( optional )
{ // avoid printing debug messages about skipping tags if the optional one
// will not be found and the position will be reset back
- if( currentToken() != token && !recoverAndFindTagInternal( token, true ))
+ if( currentToken() != token && !findTagInternal( token, true ))
{
pos = savedPos;
return Tag();
}
}
#endif
- if( currentToken() == token || recoverAndFindTag( token ))
+ if( currentToken() == token || findTag( token ))
{
Tag ret = currentTag();
moveToNextTag();
@@ -255,12 +255,12 @@ XmlStream::Tag XmlStream::checkTag( int token, bool optional )
return Tag();
}
-bool XmlStream::recoverAndFindTag( int token )
+bool XmlStream::findTag( int token )
{
- return recoverAndFindTagInternal( token, false );
+ return findTagInternal( token, false );
}
-bool XmlStream::recoverAndFindTagInternal( int token, bool /*silent*/ )
+bool XmlStream::findTagInternal( int token, bool /*silent*/ )
{
int depth = 0;
for(;
@@ -320,7 +320,7 @@ void XmlStream::skipElementInternal( int token, bool /*silent*/ )
// fprintf( stderr, "Skipping unexpected element %s\n", CSTR( tokenToString( currentToken())));
moveToNextTag();
// and just find the matching closing tag
- if( recoverAndFindTag( closing ))
+ if( findTag( closing ))
{
// if( !silent )
// fprintf( stderr, "Skipped unexpected element %s\n", CSTR( tokenToString( token )));