summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--oox/inc/oox/mathml/importutils.hxx19
-rw-r--r--oox/source/mathml/importutils.cxx12
-rw-r--r--starmath/source/ooxmlimport.cxx6
3 files changed, 24 insertions, 13 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 )));
diff --git a/starmath/source/ooxmlimport.cxx b/starmath/source/ooxmlimport.cxx
index 73f0ea50b7dd..8a763a2caeb4 100644
--- a/starmath/source/ooxmlimport.cxx
+++ b/starmath/source/ooxmlimport.cxx
@@ -346,7 +346,7 @@ OUString SmOoxmlImport::handleD()
OUStringBuffer ret;
ret.append( opening );
bool first = true;
- while( stream.currentToken() == OPENING( M_TOKEN( e )))
+ while( stream.findTag( OPENING( M_TOKEN( e ))))
{
if( !first )
ret.append( separator );
@@ -464,12 +464,12 @@ OUString SmOoxmlImport::handleM()
if( !row.isEmpty())
row += STR( " # " );
row += readOMathArgInElement( M_TOKEN( e ));
- } while( !stream.atEnd() && stream.currentToken() == OPENING( M_TOKEN( e )));
+ } while( !stream.atEnd() && stream.findTag( OPENING( M_TOKEN( e ))));
if( !allrows.isEmpty())
allrows += STR( " ## " );
allrows += row;
stream.ensureClosingTag( M_TOKEN( mr ));
- } while( !stream.atEnd() && stream.currentToken() == OPENING( M_TOKEN( mr )));
+ } while( !stream.atEnd() && stream.findTag( OPENING( M_TOKEN( mr ))));
stream.ensureClosingTag( M_TOKEN( m ));
return STR( "matrix {" ) + allrows + STR( "}" );
}