[Libreoffice-commits] .: Branch 'libreoffice-3-5' - 4 commits - oox/inc oox/source starmath/source
Lubos Lunak
llunak at kemper.freedesktop.org
Tue Dec 20 01:54:52 PST 2011
oox/inc/oox/mathml/importutils.hxx | 19 +++++++++++++++----
oox/source/mathml/importutils.cxx | 12 ++++++------
starmath/source/ooxmlexport.cxx | 32 +++++++++++---------------------
starmath/source/ooxmlexport.hxx | 2 +-
starmath/source/ooxmlimport.cxx | 29 ++++++++++++++++++++++++++---
starmath/source/ooxmlimport.hxx | 2 +-
6 files changed, 60 insertions(+), 36 deletions(-)
New commits:
commit 40f129a99e691babaf7320cb32dff7ec5c77275c
Author: LuboÅ¡ LuÅák <l.lunak at suse.cz>
Date: Tue Dec 20 10:46:43 2011 +0100
if a bracket pair has no left/right bracket, it needs to explicit (fdo#32636)
diff --git a/starmath/source/ooxmlimport.cxx b/starmath/source/ooxmlimport.cxx
index 60fb230..1cdee7f 100644
--- a/starmath/source/ooxmlimport.cxx
+++ b/starmath/source/ooxmlimport.cxx
@@ -346,6 +346,10 @@ OUString SmOoxmlImport::handleD()
closing = STR( " right " ) + closing;
if( separator == STR( "|" )) // plain "|" would be actually "V" (logical or)
separator = STR( " mline " );
+ if( opening.isEmpty())
+ opening = STR( "left none " );
+ if( closing.isEmpty())
+ closing = STR( " right none" );
OUStringBuffer ret;
ret.append( opening );
bool first = true;
commit 0e0988cc08269eb125bf6e362b8ddba0c0771296
Author: LuboÅ¡ LuÅák <l.lunak at suse.cz>
Date: Tue Dec 20 10:44:01 2011 +0100
import m:eqArr (part of fdo#32636)
diff --git a/starmath/source/ooxmlimport.cxx b/starmath/source/ooxmlimport.cxx
index 8a763a2..60fb230 100644
--- a/starmath/source/ooxmlimport.cxx
+++ b/starmath/source/ooxmlimport.cxx
@@ -116,6 +116,9 @@ OUString SmOoxmlImport::readOMathArg()
case OPENING( M_TOKEN( d )):
ret += handleD();
break;
+ case OPENING( M_TOKEN( eqArr )):
+ ret += handleEqArr();
+ break;
case OPENING( M_TOKEN( f )):
ret += handleF();
break;
@@ -358,6 +361,22 @@ OUString SmOoxmlImport::handleD()
return ret.makeStringAndClear();
}
+OUString SmOoxmlImport::handleEqArr()
+{
+ stream.ensureOpeningTag( M_TOKEN( eqArr ));
+ OUString ret;
+ do
+ { // there must be at least one m:e
+ if( !ret.isEmpty())
+ ret += STR( "#" );
+ ret += STR( " " );
+ ret += readOMathArgInElement( M_TOKEN( e ));
+ ret += STR( " " );
+ } while( !stream.atEnd() && stream.findTag( OPENING( M_TOKEN( e ))));
+ stream.ensureClosingTag( M_TOKEN( eqArr ));
+ return STR( "stack {" ) + ret + STR( "}" );
+}
+
OUString SmOoxmlImport::handleF()
{
stream.ensureOpeningTag( M_TOKEN( f ));
diff --git a/starmath/source/ooxmlimport.hxx b/starmath/source/ooxmlimport.hxx
index 5bea975..dc6816f 100644
--- a/starmath/source/ooxmlimport.hxx
+++ b/starmath/source/ooxmlimport.hxx
@@ -49,7 +49,7 @@ private:
rtl::OUString handleBox();
rtl::OUString handleBorderBox();
rtl::OUString handleD();
- rtl::OUString handleE();
+ rtl::OUString handleEqArr();
rtl::OUString handleF();
rtl::OUString handleFunc();
enum LimLowUpp_t { LimLow, LimUpp };
commit a77bbdb6f4203be700bacacd186757b058941346
Author: LuboÅ¡ LuÅák <l.lunak at suse.cz>
Date: Tue Dec 20 10:43:17 2011 +0100
export vertical stack as m:eqArr, seems to fit much better
diff --git a/starmath/source/ooxmlexport.cxx b/starmath/source/ooxmlexport.cxx
index 3604894..a7740da 100644
--- a/starmath/source/ooxmlexport.cxx
+++ b/starmath/source/ooxmlexport.cxx
@@ -152,7 +152,7 @@ void SmOoxmlExport::HandleTable( const SmNode* pNode, int nLevel )
//OOXML output stack which would grow
//without bound in a multi step conversion
if( nLevel || pNode->GetNumSubNodes() > 1 )
- HandleVerticalStack( pNode, nLevel, 0 );
+ HandleVerticalStack( pNode, nLevel );
else
HandleAllSubNodes( pNode, nLevel );
}
@@ -174,29 +174,19 @@ void SmOoxmlExport::HandleAllSubNodes( const SmNode* pNode, int nLevel )
}
}
-// output vertical stack, firstItem says which child to use as first (if there
-// are more than two children, OOXML can have only a vertical stack of two items,
-// so create a bigger vertical stack recursively)
-void SmOoxmlExport::HandleVerticalStack( const SmNode* pNode, int nLevel, int firstItem )
+void SmOoxmlExport::HandleVerticalStack( const SmNode* pNode, int nLevel )
{
- if( firstItem == pNode->GetNumSubNodes() - 1 ) // only one item, just output the item
+ m_pSerializer->startElementNS( XML_m, XML_eqArr, FSEND );
+ int size = pNode->GetNumSubNodes();
+ for( int i = 0;
+ i < size;
+ ++i )
{
- HandleNode( pNode->GetSubNode( firstItem ), nLevel + 1 );
- return;
+ m_pSerializer->startElementNS( XML_m, XML_e, FSEND );
+ HandleNode( pNode->GetSubNode( i ), nLevel + 1 );
+ m_pSerializer->endElementNS( XML_m, XML_e );
}
- m_pSerializer->startElementNS( XML_m, XML_f, FSEND );
- m_pSerializer->startElementNS( XML_m, XML_fPr, FSEND );
- m_pSerializer->singleElementNS( XML_m, XML_type, FSNS( XML_m, XML_val ), "noBar", FSEND );
- m_pSerializer->endElementNS( XML_m, XML_fPr );
- m_pSerializer->startElementNS( XML_m, XML_num, FSEND );
- HandleNode( pNode->GetSubNode( firstItem ), nLevel + 1 );
- m_pSerializer->endElementNS( XML_m, XML_num );
- // TODO this nesting means MSOffice will use smaller fonts for nested items,
- // not sure if there's another way to represent a bigger stack than 2 items
- m_pSerializer->startElementNS( XML_m, XML_den, FSEND );
- HandleVerticalStack( pNode, nLevel, firstItem + 1 );
- m_pSerializer->endElementNS( XML_m, XML_den );
- m_pSerializer->endElementNS( XML_m, XML_f );
+ m_pSerializer->endElementNS( XML_m, XML_eqArr );
}
void SmOoxmlExport::HandleText( const SmNode* pNode, int /*nLevel*/)
diff --git a/starmath/source/ooxmlexport.hxx b/starmath/source/ooxmlexport.hxx
index b1703c3..34b13ed 100644
--- a/starmath/source/ooxmlexport.hxx
+++ b/starmath/source/ooxmlexport.hxx
@@ -46,7 +46,7 @@ private:
void HandleNode( const SmNode* pNode, int nLevel );
void HandleAllSubNodes( const SmNode* pNode, int nLevel );
void HandleTable( const SmNode* pNode, int nLevel );
- void HandleVerticalStack( const SmNode* pNode, int nLevel, int firstItem );
+ void HandleVerticalStack( const SmNode* pNode, int nLevel );
void HandleText( const SmNode* pNode, int nLevel );
void HandleMath( const SmNode* pNode, int nLevel );
void HandleFractions( const SmNode* pNode, int nLevel, const char* type = NULL );
commit 54c83fa349620d178d3d4802be43dc4e100a9c3d
Author: LuboÅ¡ LuÅák <l.lunak at suse.cz>
Date: Tue Dec 20 10:42:30 2011 +0100
skip unknown elements when reading multiple elements from docx mathml
diff --git a/oox/inc/oox/mathml/importutils.hxx b/oox/inc/oox/mathml/importutils.hxx
index 6906851..9b90681 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 2a7d19c..4a71d56 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 73f0ea5..8a763a2 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( "}" );
}
More information about the Libreoffice-commits
mailing list