18#include <oox/token/namespaces.hxx>
19#include <rtl/ustring.hxx>
20#include <rtl/ustrbuf.hxx>
31#define OPENING( token ) XML_STREAM_OPENING( token )
32#define CLOSING( token ) XML_STREAM_CLOSING( token )
68 OUString ret2 = ret.makeStringAndClear().replaceAll(
"{}",
"<?>" );
71 ret2 = ret2.replaceAll(
"{ }",
"{}" );
72 SAL_INFO(
"starmath.ooxml",
"Formula: " << ret2 );
94 case OPENING( M_TOKEN( borderBox )):
100 case OPENING( M_TOKEN( eqArr )):
106 case OPENING( M_TOKEN( func )):
109 case OPENING( M_TOKEN( limLow )):
112 case OPENING( M_TOKEN( limUpp )):
115 case OPENING( M_TOKEN( groupChr )):
121 case OPENING( M_TOKEN( nary )):
130 case OPENING( M_TOKEN( sPre )):
133 case OPENING( M_TOKEN( sSub )):
136 case OPENING( M_TOKEN( sSubSup )):
139 case OPENING( M_TOKEN( sSup )):
147 return ret.makeStringAndClear();
166 accChr = chr.attribute( M_TOKEN( val ), accChr );
233 SAL_WARN(
"starmath.ooxml",
"Unknown m:chr in m:acc \'" << OUString(accChr) <<
"\'" );
238 return acc +
" {" + e +
"}";
244 enum pos_t {
top, bot } topbot = bot;
249 if(
pos.attribute( M_TOKEN( val )) ==
"top" )
251 else if(
pos.attribute( M_TOKEN( val )) ==
"bot" )
260 return "overline {" + e +
"}";
262 return "underline {" + e +
"}";
279 bool isStrikeH =
false;
284 if( strikeH.attribute( M_TOKEN( val ),
false ))
293 return "overstrike {" + e +
"}";
301 OUString opening =
"(";
302 OUString closing =
")";
308 opening = begChr.attribute( M_TOKEN( val ), opening );
318 closing = endChr.attribute( M_TOKEN( val ), closing );
324 opening =
"left lbrace ";
326 closing =
" right rbrace";
327 if( opening ==
u"\u27e6" )
328 opening =
"left ldbracket ";
329 if( closing ==
u"\u27e7" )
330 closing =
" right rdbracket";
332 opening =
"left lline ";
334 closing =
" right rline";
335 if (opening == OUStringChar(
MS_DLINE)
337 opening =
"left ldline ";
338 if (closing == OUStringChar(
MS_DLINE)
340 closing =
" right rdline";
343 opening =
"left langle ";
346 closing =
" right rangle";
348 if( opening ==
"(" || opening ==
"[" )
349 opening =
"left " + opening;
350 if( closing ==
")" || closing ==
"]" )
351 closing =
" right " + closing;
354 if( opening.isEmpty())
355 opening =
"left none ";
356 if( closing.isEmpty())
357 closing =
" right none";
358 OUStringBuffer ret( opening );
367 ret.append( closing );
369 return ret.makeStringAndClear();
385 return "stack {" + ret +
"}";
391 enum operation_t { bar, lin, noBar } operation = bar;
396 if(
type.attribute( M_TOKEN( val )) ==
"bar" )
398 else if(
type.attribute( M_TOKEN( val )) ==
"lin" )
400 else if(
type.attribute( M_TOKEN( val )) ==
"noBar" )
409 if( operation == bar )
410 return "{" + num +
"} over {" + den +
"}";
411 else if( operation == lin )
412 return "{" + num +
"} / {" + den +
"}";
415 return "binom {" + num +
"} {" + den +
"}";
425 if( fname.startsWith(
"lim csub {" ))
426 fname = OUString::Concat(
"lim from {") + fname.subView( 10 );
434 int token = limlowupp ==
LimLow ? M_TOKEN( limLow ) : M_TOKEN( limUpp );
440 if( limlowupp ==
LimUpp && e.endsWith(
" overbrace { }" ))
441 return e.subView( 0, e.getLength() - 2 ) + lim +
"}";
442 if( limlowupp ==
LimLow && e.endsWith(
" underbrace { }" ))
443 return e.subView( 0, e.getLength() - 2 ) + lim +
"}";
446 ? std::u16string_view(
u" csub {" ) : std::u16string_view(
u" csup {" ))
454 enum pos_t {
top, bot }
pos = bot;
459 chr = chrTag.attribute( M_TOKEN( val ), chr );
464 if( posTag.attribute( M_TOKEN( val ), OUString(
"bot" )) ==
"top" )
472 if(
pos ==
top && chr ==
u'\x23de')
473 return "{" + e +
"} overbrace { }";
474 if(
pos == bot && chr ==
u'\x23df')
475 return "{" + e +
"} underbrace { }";
477 return "{" + e +
"} csup {" + OUStringChar( chr ) +
"}";
479 return "{" + e +
"} csub {" + OUStringChar( chr ) +
"}";
485 OUStringBuffer allrows;
496 if( !allrows.isEmpty())
497 allrows.append(
" ## ");
502 return "matrix {" + allrows +
"}";
509 bool subHide =
false;
510 bool supHide =
false;
515 chr = chrTag.attribute( M_TOKEN( val ), chr );
520 subHide = subHideTag.attribute( M_TOKEN( val ), subHide );
525 supHide = supHideTag.attribute( M_TOKEN( val ), supHide );
564 SAL_WARN(
"starmath.ooxml",
"Unknown m:nary chr \'" << OUString(chr) <<
"\'" );
568 ret +=
" from {" + sub +
"}";
570 ret +=
" to {" + sup +
"}";
571 ret +=
" {" + e +
"}";
581 bool literal =
false;
586 literal = litTag.attribute( M_TOKEN( val ),
true );
591 normal = norTag.attribute( M_TOKEN( val ),
true );
604 if( rtag.
attribute( OOX_TOKEN( xml, space )) !=
"preserve" )
619 text.insert(0,
"\"");
622 return text.makeStringAndClear().replaceAll(
"{",
"\\{").replaceAll(
"}",
"\\}");
628 bool degHide =
false;
633 degHide = degHideTag.attribute( M_TOKEN( val ), degHide );
642 return "sqrt {" + e +
"}";
644 return "nroot {" + deg +
"} {" + e +
"}";
654 return "{" + e +
"} lsub {" + sub +
"} lsup {" + sup +
"}";
663 return "{" + e +
"} rsub {" + sub +
"}";
673 return "{" + e +
"} rsub {" + sub +
"} rsup {" + sup +
"}";
682 return "{" + e +
"} ^ {" + sup +
"}";
OUString ConvertToStarMath()
OUString readOMathArgInElement(int token)
OUString handleGroupChr()
SmOoxmlImport(oox::formulaimport::XmlStream &stream)
OUString readOMathArg(int stoptoken)
oox::formulaimport::XmlStream & m_rStream
OUString handleLimLowUpp(LimLowUpp_t limlowupp)
OUString handleBorderBox()
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
constexpr OUStringLiteral first
std::basic_string_view< charT, traits > trim(std::basic_string_view< charT, traits > str)
sal_Unicode const MS_DVERTLINE
sal_Unicode const MS_COMBOVERLINE
sal_Unicode const MS_TILDE
sal_Unicode const MS_RIGHTARROW
sal_Unicode const MS_LANGLE
sal_Unicode const MS_COMBBREVE
sal_Unicode const MS_COMBGRAVE
sal_Unicode const MS_IIINT
sal_Unicode const MS_LLINT
sal_Unicode const MS_COMBACUTE
sal_Unicode const MS_GRAVE
sal_Unicode const MS_RMATHANGLE
sal_Unicode const MS_DDOT
sal_Unicode const MS_DLINE
sal_Unicode const MS_DDDOT
sal_Unicode const MS_COMBDDOT
sal_Unicode const MS_CHECK
sal_Unicode const MS_ACUTE
sal_Unicode const MS_RANGLE
sal_Unicode const MS_LLLINT
sal_Unicode const MS_CIRCLE
sal_Unicode const MS_COMBBAR
sal_Unicode const MS_COMBCIRCLE
sal_Unicode const MS_COMBTILDE
sal_Unicode const MS_HARPOON
sal_Unicode const MS_COPROD
sal_Unicode const MS_COMBCHECK
sal_Unicode const MS_LMATHANGLE
sal_Unicode const MS_IINT
sal_Unicode const MS_PROD
sal_Unicode const MS_COMBDOT
sal_Unicode const MS_COMBHAT
sal_Unicode const MS_LINT
sal_Unicode const MS_BREVE