Kaydet (Commit) e68bfafd authored tarafından Miklos Vajna's avatar Miklos Vajna

implement import/export of RTF_MNOR

Change-Id: I9caea7fbea4643e57d81ad3b7812d0cc10f54c11
üst d0fead61
...@@ -71,6 +71,9 @@ void SmRtfExport::HandleText(const SmNode* pNode, int /*nLevel*/) ...@@ -71,6 +71,9 @@ void SmRtfExport::HandleText(const SmNode* pNode, int /*nLevel*/)
{ {
m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MR " "); m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MR " ");
if( pNode->GetToken().eType == TTEXT ) // literal text
m_pBuffer->append(LO_STRING_SVTOOLS_RTF_MNOR " ");
SmTextNode* pTemp=(SmTextNode* )pNode; SmTextNode* pTemp=(SmTextNode* )pNode;
SAL_INFO("starmath.rtf", "Text: " << pTemp->GetText()); SAL_INFO("starmath.rtf", "Text: " << pTemp->GetText());
for (sal_Int32 i = 0; i < pTemp->GetText().getLength(); i++) for (sal_Int32 i = 0; i < pTemp->GetText().getLength(); i++)
......
...@@ -1203,6 +1203,7 @@ ...@@ -1203,6 +1203,7 @@
#define LO_STRING_SVTOOLS_RTF_MVERTJC "\\mvertJc" #define LO_STRING_SVTOOLS_RTF_MVERTJC "\\mvertJc"
#define LO_STRING_SVTOOLS_RTF_MMATH "\\mmath" #define LO_STRING_SVTOOLS_RTF_MMATH "\\mmath"
#define LO_STRING_SVTOOLS_RTF_MMATHPICT "\\mmathPict" #define LO_STRING_SVTOOLS_RTF_MMATHPICT "\\mmathPict"
#define LO_STRING_SVTOOLS_RTF_MNOR "\\mnor"
#endif // _RTFKEYWD_HXX #endif // _RTFKEYWD_HXX
......
{\rtf1\ansi\deff4\adeflang1025
{\fonttbl
{\f0\froman\fprq2\fcharset0 Times New Roman;}
{\f1\froman\fprq2\fcharset2 Symbol;}
{\f2\fswiss\fprq2\fcharset0 Arial;}
{\f3\froman\fprq2\fcharset0 Times New Roman;}
{\f4\fswiss\fprq0\fcharset1 Calibri;}
{\f5\fswiss\fprq2\fcharset0 Arial;}
{\f6\fswiss\fprq0\fcharset1 Times New Roman;}
{\f7\fswiss\fprq0\fcharset1 Tahoma;}
{\f8\fnil\fprq2\fcharset0 Droid Sans Fallback;}
{\f9\fnil\fprq2\fcharset0 Arial;}
{\f10\fswiss\fprq0\fcharset1 Arial;}
}
{\colortbl;\red0\green0\blue0;\red128\green128\blue128;}
{\stylesheet
{\s0\snext0\ql\nowidctlpar
\ltrpar\sl276\slmult1\sb0\sa200\cf0\dbch\af8\langfe2052\dbch\af9\afs24\alang1081\kerning1\loch\f6\fs24\lang1029 Default Style;}
{\*\cs15\snext15 Default Paragraph Font;}
{\*\cs16\sbasedon15\snext16\afs16\loch\f7\fs16 Balloon Text Char;}
{\s17\sbasedon0\snext18\ql\nowidctlpar
\sb240\sa120\keepn\ltrpar\cf0\dbch\af8\langfe2052\dbch\af9\afs28\alang1081\loch\f5\fs28\lang1029 Heading;}
{\s18\sbasedon0\snext18\ql\nowidctlpar
\sb0\sa120\ltrpar\cf0\dbch\af8\langfe2052\dbch\af9\afs24\alang1081\loch\f6\fs24\lang1029 Text Body;}
{\s19\sbasedon18\snext19\ql\nowidctlpar
\sb0\sa120\ltrpar\cf0\dbch\af8\langfe2052\dbch\af10\afs24\alang1081\loch\f4\fs24\lang1029 List;}
{\s20\sbasedon0\snext20\ql\nowidctlpar
\sb120\sa120\noline\ltrpar\cf0\i\dbch\af8\langfe2052\dbch\af10\afs24\alang1081\ai\loch\f4\fs24\lang1029 Caption;}
{\s21\sbasedon0\snext21\ql\nowidctlpar
\noline\ltrpar\cf0\dbch\af8\langfe2052\dbch\af10\afs24\alang1081\loch\f4\fs24\lang1029 Index;}
{\s22\sbasedon0\snext22\ql\nowidctlpar
\sb120\sa120\noline\ltrpar\cf0\i\dbch\af8\langfe2052\dbch\af9\afs24\alang1081\ai\loch\f6\fs24\lang1029 caption;}
{\s23\sbasedon0\snext23\ql\sl100\slmult0\nowidctlpar
\sb0\sa0\ltrpar\cf0\dbch\af8\langfe2052\dbch\af9\afs16\alang1081\loch\f7\fs16\lang1029 Balloon Text;}
}
{\info
{\creatim\yr2013\mo4\dy2\hr13\min40}
{\author vmiklos}
{\revtim\yr2013\mo4\dy2\hr13\min40}
{\printim\yr0\mo0\dy0\hr0\min0}
{\comment LibreOffice}
{\vern67174400}
}
\deftab709
\viewscale147
\formshade
\paperh16838\paperw11906\margl1134\margr1134\margt1134\margb1134\sectd\sbknone\sectunlocked1\pgndec\pgwsxn11906\pghsxn16838\marglsxn1134\margrsxn1134\margtsxn1134\margbsxn1134\ftnbj\ftnstart1\ftnrstcont\ftnnar\aenddoc\aftnrstcont\aftnstart1\aftnnrlc
\pgndec\pard\plain \s0\ql\nowidctlpar
\ltrpar\sl276\slmult1\sb0\sa200\cf0\dbch\af8\langfe2052\dbch\af9\afs24\alang1081\kerning1\loch\f6\fs24\lang1029
{
\rtlch \ltrch
{\mmath
{\*\moMath
{\mnary
{\mnaryPr
{\mchr \u8749\'2d}
}
{\msub
{\mr V}
}
{\msup }
{\me
{\mr \mnor divF}
}
}
{\mr dV}
{\mr =}
{\mnary
{\mnaryPr
{\mchr \u8751\'2f}
}
{\msub
{\mr S}
}
{\msup }
{\me
{\mr \mnor F}
{\mr \u8729\'19}
{\mr \mnor n }
{\mr dS}
}
}
}
}
}
\par }
...@@ -73,6 +73,7 @@ public: ...@@ -73,6 +73,7 @@ public:
void testFdo61507(); void testFdo61507();
void testFdo30983(); void testFdo30983();
void testPlaceholder(); void testPlaceholder();
void testMnor();
CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT) #if !defined(MACOSX) && !defined(WNT)
...@@ -120,6 +121,7 @@ void Test::run() ...@@ -120,6 +121,7 @@ void Test::run()
{"fdo61507.rtf", &Test::testFdo61507}, {"fdo61507.rtf", &Test::testFdo61507},
{"fdo30983.rtf", &Test::testFdo30983}, {"fdo30983.rtf", &Test::testFdo30983},
{"placeholder.odt", &Test::testPlaceholder}, {"placeholder.odt", &Test::testPlaceholder},
{"mnor.rtf", &Test::testMnor},
}; };
// Don't test the first import of these, for some reason those tests fail // Don't test the first import of these, for some reason those tests fail
const char* aBlacklist[] = { const char* aBlacklist[] = {
...@@ -506,6 +508,14 @@ void Test::testPlaceholder() ...@@ -506,6 +508,14 @@ void Test::testPlaceholder()
CPPUNIT_ASSERT_EQUAL(OUString("place holder"), getProperty<OUString>(xField, "Hint")); CPPUNIT_ASSERT_EQUAL(OUString("place holder"), getProperty<OUString>(xField, "Hint"));
} }
void Test::testMnor()
{
// \mnor wasn't handled, leading to missing quotes around "divF" and so on.
OUString aActual = getFormula(getRun(getParagraph(1), 1));
OUString aExpected("iiint from {V} to <?> {\"divF\"} dV = llint from {S} to <?> {\"F\"\"n\" dS}", 74, RTL_TEXTENCODING_UTF8);
CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
}
CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
...@@ -215,12 +215,20 @@ static util::DateTime lcl_getDateTime(RTFParserState& aState) ...@@ -215,12 +215,20 @@ static util::DateTime lcl_getDateTime(RTFParserState& aState)
aState.nDay, aState.nMonth, aState.nYear); aState.nDay, aState.nMonth, aState.nYear);
} }
static void lcl_DestinationToMath(OUStringBuffer& rDestinationText, oox::formulaimport::XmlStreamBuilder& rMathBuffer) static void lcl_DestinationToMath(OUStringBuffer& rDestinationText, oox::formulaimport::XmlStreamBuilder& rMathBuffer, bool& rMathNor)
{ {
OUString aStr = rDestinationText.makeStringAndClear(); OUString aStr = rDestinationText.makeStringAndClear();
if (!aStr.isEmpty()) if (!aStr.isEmpty())
{ {
rMathBuffer.appendOpeningTag(M_TOKEN(r)); rMathBuffer.appendOpeningTag(M_TOKEN(r));
if (rMathNor)
{
rMathBuffer.appendOpeningTag(M_TOKEN(rPr));
rMathBuffer.appendOpeningTag(M_TOKEN(nor));
rMathBuffer.appendClosingTag(M_TOKEN(nor));
rMathBuffer.appendClosingTag(M_TOKEN(rPr));
rMathNor = false;
}
rMathBuffer.appendOpeningTag(M_TOKEN(t)); rMathBuffer.appendOpeningTag(M_TOKEN(t));
rMathBuffer.appendCharacters(aStr); rMathBuffer.appendCharacters(aStr);
rMathBuffer.appendClosingTag(M_TOKEN(t)); rMathBuffer.appendClosingTag(M_TOKEN(t));
...@@ -275,6 +283,7 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x ...@@ -275,6 +283,7 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x
m_bIsInFrame(false), m_bIsInFrame(false),
m_aUnicodeBuffer(), m_aUnicodeBuffer(),
m_aHexBuffer(), m_aHexBuffer(),
m_bMathNor(false),
m_bIgnoreNextContSectBreak(false), m_bIgnoreNextContSectBreak(false),
m_bNeedSect(true), m_bNeedSect(true),
m_bWasInFrame(false), m_bWasInFrame(false),
...@@ -2651,6 +2660,9 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) ...@@ -2651,6 +2660,9 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
case RTF_NOWRAP: case RTF_NOWRAP:
m_aStates.top().aFrame.setSprm(NS_sprm::LN_PWr, NS_ooxml::LN_Value_wordprocessingml_ST_Wrap_notBeside); m_aStates.top().aFrame.setSprm(NS_sprm::LN_PWr, NS_ooxml::LN_Value_wordprocessingml_ST_Wrap_notBeside);
break; break;
case RTF_MNOR:
m_bMathNor = true;
break;
default: default:
{ {
SAL_INFO("writerfilter", "TODO handle flag '" << lcl_RtfToString(nKeyword) << "'"); SAL_INFO("writerfilter", "TODO handle flag '" << lcl_RtfToString(nKeyword) << "'");
...@@ -3667,7 +3679,7 @@ int RTFDocumentImpl::pushState() ...@@ -3667,7 +3679,7 @@ int RTFDocumentImpl::pushState()
else else
{ {
if (m_aStates.top().nDestinationState == DESTINATION_MR) if (m_aStates.top().nDestinationState == DESTINATION_MR)
lcl_DestinationToMath(m_aStates.top().aDestinationText, m_aMathBuffer); lcl_DestinationToMath(m_aStates.top().aDestinationText, m_aMathBuffer, m_bMathNor);
m_aStates.push(m_aStates.top()); m_aStates.push(m_aStates.top());
} }
m_aStates.top().aDestinationText.setLength(0); m_aStates.top().aDestinationText.setLength(0);
...@@ -4151,7 +4163,7 @@ int RTFDocumentImpl::popState() ...@@ -4151,7 +4163,7 @@ int RTFDocumentImpl::popState()
} }
break; break;
case DESTINATION_MR: case DESTINATION_MR:
lcl_DestinationToMath(m_aStates.top().aDestinationText, m_aMathBuffer); lcl_DestinationToMath(m_aStates.top().aDestinationText, m_aMathBuffer, m_bMathNor);
break; break;
case DESTINATION_MF: case DESTINATION_MF:
m_aMathBuffer.appendClosingTag(M_TOKEN(f)); m_aMathBuffer.appendClosingTag(M_TOKEN(f));
......
...@@ -590,6 +590,8 @@ namespace writerfilter { ...@@ -590,6 +590,8 @@ namespace writerfilter {
rtl::OStringBuffer m_aHexBuffer; rtl::OStringBuffer m_aHexBuffer;
/// Formula import. /// Formula import.
oox::formulaimport::XmlStreamBuilder m_aMathBuffer; oox::formulaimport::XmlStreamBuilder m_aMathBuffer;
/// Normal text property, that is math italic and math spacing are not applied to the current run.
bool m_bMathNor;
/// If the next continous section break should be ignored. /// If the next continous section break should be ignored.
bool m_bIgnoreNextContSectBreak; bool m_bIgnoreNextContSectBreak;
/// If a section break is needed before the end of the doc (false right after a section break). /// If a section break is needed before the end of the doc (false right after a section break).
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment