summaryrefslogtreecommitdiffstats
path: root/oox
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@suse.cz>2011-11-29 19:17:35 +0100
committerLuboš Luňák <l.lunak@suse.cz>2011-11-29 21:20:27 +0100
commitf92bb660961a3f2dee392eac214bdd568ba2ea52 (patch)
treef8392c7f723542a2eb7e31260f463a092da819b1 /oox
parentmake debug output print tags as strings rather than id numbers (diff)
downloadcore-f92bb660961a3f2dee392eac214bdd568ba2ea52.tar.gz
core-f92bb660961a3f2dee392eac214bdd568ba2ea52.zip
no debug about skipping tags if not actually skipping
Diffstat (limited to 'oox')
-rw-r--r--oox/inc/oox/mathml/importutils.hxx1
-rw-r--r--oox/source/mathml/importutils.cxx38
2 files changed, 33 insertions, 6 deletions
diff --git a/oox/inc/oox/mathml/importutils.hxx b/oox/inc/oox/mathml/importutils.hxx
index a90028dadbcd..68f6a0ab8155 100644
--- a/oox/inc/oox/mathml/importutils.hxx
+++ b/oox/inc/oox/mathml/importutils.hxx
@@ -163,6 +163,7 @@ public:
void handleUnexpectedTag();
protected:
Tag checkTag( int token, bool optional );
+ bool recoverAndFindTagHelper( 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 3a21bad8f89c..703e96b8752d 100644
--- a/oox/source/mathml/importutils.cxx
+++ b/oox/source/mathml/importutils.cxx
@@ -42,6 +42,11 @@
#define CSTR( str ) ( rtl::OUStringToOString( str, RTL_TEXTENCODING_UTF8 ).getStr())
+// HACK - TODO convert to the real debug stuff
+#undef SAL_LOG_LEVEL
+#define SAL_LOG_LEVEL 2
+
+
using namespace com::sun::star;
using rtl::OUString;
@@ -220,6 +225,17 @@ XmlStream::Tag XmlStream::checkTag( int token, bool optional )
{
// either it's the following tag, or find it
int savedPos = pos;
+#if SAL_LOG_LEVEL >= 2
+ 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 && !recoverAndFindTagHelper( token, true ))
+ {
+ pos = savedPos;
+ return Tag();
+ }
+ }
+#endif
if( currentToken() == token || recoverAndFindTag( token ))
{
Tag ret = currentTag();
@@ -237,6 +253,11 @@ XmlStream::Tag XmlStream::checkTag( int token, bool optional )
bool XmlStream::recoverAndFindTag( int token )
{
+ return recoverAndFindTagHelper( token, false );
+}
+
+bool XmlStream::recoverAndFindTagHelper( int token, bool silent )
+{
int depth = 0;
for(;
!atEnd();
@@ -246,17 +267,20 @@ bool XmlStream::recoverAndFindTag( int token )
{
if( currentToken() == OPENING( currentToken()))
{
- fprintf( stderr, "Skipping tag %s\n", CSTR( tokenToString( currentToken())));
+ if( !silent )
+ fprintf( stderr, "Skipping tag %s\n", CSTR( tokenToString( currentToken())));
++depth;
}
else if( currentToken() == CLOSING( currentToken()))
- { // TODO debug output without the OPENING/CLOSING bits set
- fprintf( stderr, "Skipping tag %s\n", CSTR( tokenToString( currentToken())));
+ {
+ if( !silent )
+ fprintf( stderr, "Skipping tag %s\n", CSTR( tokenToString( currentToken())));
--depth;
}
else
{
- fprintf( stderr, "Malformed token %d (%s)\n", currentToken(), CSTR( tokenToString( currentToken())));
+ if( !silent )
+ fprintf( stderr, "Malformed token %d (%s)\n", currentToken(), CSTR( tokenToString( currentToken())));
abort();
}
continue;
@@ -267,13 +291,15 @@ bool XmlStream::recoverAndFindTag( int token )
return false; // that would be leaving current element, so not found
if( currentToken() == OPENING( currentToken()))
{
- fprintf( stderr, "Skipping tag %s\n", CSTR( tokenToString( currentToken())));
+ if( !silent )
+ fprintf( stderr, "Skipping tag %s\n", CSTR( tokenToString( currentToken())));
++depth;
}
else
abort();
}
- fprintf( stderr, "Unexpected end of stream reached.\n" );
+ if( !silent )
+ fprintf( stderr, "Unexpected end of stream reached.\n" );
return false;
}