SmRtfExport: get current encoding from Writer instead of assuming the default
Change-Id: Ia8bdf83f36d986ca45ddad985aca827224c194f4
This commit is contained in:
parent
3a06fbc041
commit
d216c9fcbb
8 changed files with 21 additions and 19 deletions
|
@ -44,7 +44,7 @@ class OOX_DLLPUBLIC FormulaExportBase
|
|||
{
|
||||
public:
|
||||
virtual void writeFormulaOoxml( ::sax_fastparser::FSHelperPtr m_pSerializer, oox::core::OoxmlVersion version ) = 0;
|
||||
virtual void writeFormulaRtf( OStringBuffer& rBuffer ) = 0;
|
||||
virtual void writeFormulaRtf( OStringBuffer& rBuffer, rtl_TextEncoding nEncoding ) = 0;
|
||||
|
||||
protected:
|
||||
FormulaExportBase();
|
||||
|
|
|
@ -156,7 +156,7 @@ class SmDocShell : public SfxObjectShell, public SfxListener
|
|||
void InvalidateCursor();
|
||||
|
||||
bool writeFormulaOoxml( ::sax_fastparser::FSHelperPtr m_pSerializer, oox::core::OoxmlVersion version );
|
||||
void writeFormulaRtf(OStringBuffer& rBuffer);
|
||||
void writeFormulaRtf(OStringBuffer& rBuffer, rtl_TextEncoding nEncoding);
|
||||
bool readFormulaOoxml( oox::formulaimport::XmlStream& stream );
|
||||
|
||||
public:
|
||||
|
|
|
@ -93,7 +93,7 @@ public:
|
|||
|
||||
// oox::FormulaExportBase
|
||||
virtual void writeFormulaOoxml( ::sax_fastparser::FSHelperPtr m_pSerializer, oox::core::OoxmlVersion version );
|
||||
virtual void writeFormulaRtf(OStringBuffer& rBuffer);
|
||||
virtual void writeFormulaRtf(OStringBuffer& rBuffer, rtl_TextEncoding nEncoding);
|
||||
// oox::FormulaImportBase
|
||||
virtual void readFormulaOoxml( oox::formulaimport::XmlStream& stream );
|
||||
virtual Size getFormulaSize() const;
|
||||
|
|
|
@ -987,14 +987,14 @@ bool SmDocShell::writeFormulaOoxml( ::sax_fastparser::FSHelperPtr m_pSerializer,
|
|||
return aEquation.ConvertFromStarMath( m_pSerializer );
|
||||
}
|
||||
|
||||
void SmDocShell::writeFormulaRtf(OStringBuffer& rBuffer)
|
||||
void SmDocShell::writeFormulaRtf(OStringBuffer& rBuffer, rtl_TextEncoding nEncoding)
|
||||
{
|
||||
if (!pTree)
|
||||
Parse();
|
||||
if (pTree && !IsFormulaArranged())
|
||||
ArrangeFormula();
|
||||
SmRtfExport aEquation(pTree);
|
||||
aEquation.ConvertFromStarMath(rBuffer);
|
||||
aEquation.ConvertFromStarMath(rBuffer, nEncoding);
|
||||
}
|
||||
|
||||
bool SmDocShell::readFormulaOoxml( oox::formulaimport::XmlStream& stream )
|
||||
|
|
|
@ -39,11 +39,12 @@ SmRtfExport::SmRtfExport(const SmNode* pIn)
|
|||
{
|
||||
}
|
||||
|
||||
bool SmRtfExport::ConvertFromStarMath(OStringBuffer& rBuffer)
|
||||
bool SmRtfExport::ConvertFromStarMath(OStringBuffer& rBuffer, rtl_TextEncoding nEncoding)
|
||||
{
|
||||
if (!m_pTree)
|
||||
return false;
|
||||
m_pBuffer = &rBuffer;
|
||||
m_nEncoding = nEncoding;
|
||||
m_pBuffer->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE LO_STRING_SVTOOLS_RTF_MOMATH " ");
|
||||
HandleNode(m_pTree, 0);
|
||||
m_pBuffer->append("}"); // moMath
|
||||
|
@ -76,7 +77,7 @@ void SmRtfExport::HandleText(const SmNode* pNode, int /*nLevel*/)
|
|||
{
|
||||
sal_uInt16 nChar = pTemp->GetText().GetChar(i);
|
||||
OUString aValue(SmTextNode::ConvertSymbolToUnicode(nChar));
|
||||
m_pBuffer->append(msfilter::rtfutil::OutString(aValue, RTL_TEXTENCODING_MS_1252));
|
||||
m_pBuffer->append(msfilter::rtfutil::OutString(aValue, m_nEncoding));
|
||||
}
|
||||
|
||||
m_pBuffer->append("}"); // mr
|
||||
|
@ -127,7 +128,7 @@ void SmRtfExport::HandleAttribute(const SmAttributNode* pNode, int nLevel)
|
|||
m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MACCPR " ");
|
||||
m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MCHR " ");
|
||||
OUString aValue(pNode->Attribute()->GetToken().cMathChar);
|
||||
m_pBuffer->append(msfilter::rtfutil::OutString(aValue, RTL_TEXTENCODING_MS_1252));
|
||||
m_pBuffer->append(msfilter::rtfutil::OutString(aValue, m_nEncoding));
|
||||
m_pBuffer->append("}"); // mchr
|
||||
m_pBuffer->append("}"); // maccPr
|
||||
m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
|
||||
|
@ -192,7 +193,7 @@ void SmRtfExport::HandleRoot(const SmRootNode* pNode, int nLevel)
|
|||
}
|
||||
|
||||
namespace {
|
||||
OString mathSymbolToString(const SmNode* node)
|
||||
OString mathSymbolToString(const SmNode* node, rtl_TextEncoding nEncoding)
|
||||
{
|
||||
assert(node->GetType() == NMATH);
|
||||
const SmTextNode* txtnode = static_cast<const SmTextNode*>(node);
|
||||
|
@ -201,7 +202,7 @@ OString mathSymbolToString(const SmNode* node)
|
|||
assert(txtnode->GetText().Len() == 1);
|
||||
sal_Unicode chr = SmTextNode::ConvertSymbolToUnicode(txtnode->GetText().GetChar(0));
|
||||
OUString aValue(chr);
|
||||
return msfilter::rtfutil::OutString(aValue, RTL_TEXTENCODING_MS_1252);
|
||||
return msfilter::rtfutil::OutString(aValue, nEncoding);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -225,7 +226,7 @@ void SmRtfExport::HandleOperator(const SmOperNode* pNode, int nLevel)
|
|||
m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MNARY " ");
|
||||
m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MNARYPR " ");
|
||||
m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MCHR " ");
|
||||
m_pBuffer->append(mathSymbolToString(operation));
|
||||
m_pBuffer->append(mathSymbolToString(operation, m_nEncoding));
|
||||
m_pBuffer->append("}"); // mchr
|
||||
if (!subsup || !subsup->GetSubSup(CSUB))
|
||||
m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSUBHIDE " 1}");
|
||||
|
@ -408,7 +409,7 @@ void SmRtfExport::HandleBrace(const SmBraceNode* pNode, int nLevel)
|
|||
m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MD " ");
|
||||
m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MDPR " ");
|
||||
m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MBEGCHR " ");
|
||||
m_pBuffer->append(mathSymbolToString(pNode->OpeningBrace()));
|
||||
m_pBuffer->append(mathSymbolToString(pNode->OpeningBrace(), m_nEncoding));
|
||||
m_pBuffer->append("}"); // mbegChr
|
||||
std::vector< const SmNode* > subnodes;
|
||||
if (pNode->Body()->GetType() == NBRACEBODY)
|
||||
|
@ -424,7 +425,7 @@ void SmRtfExport::HandleBrace(const SmBraceNode* pNode, int nLevel)
|
|||
if(!separatorWritten)
|
||||
{
|
||||
m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSEPCHR " ");
|
||||
m_pBuffer->append(mathSymbolToString(math));
|
||||
m_pBuffer->append(mathSymbolToString(math, m_nEncoding));
|
||||
m_pBuffer->append("}"); // msepChr
|
||||
separatorWritten = true;
|
||||
}
|
||||
|
@ -436,7 +437,7 @@ void SmRtfExport::HandleBrace(const SmBraceNode* pNode, int nLevel)
|
|||
else
|
||||
subnodes.push_back(pNode->Body());
|
||||
m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MENDCHR " ");
|
||||
m_pBuffer->append(mathSymbolToString(pNode->ClosingBrace()));
|
||||
m_pBuffer->append(mathSymbolToString(pNode->ClosingBrace(), m_nEncoding));
|
||||
m_pBuffer->append("}"); // mendChr
|
||||
m_pBuffer->append("}"); // mdPr
|
||||
for (unsigned int i = 0; i < subnodes.size(); ++i)
|
||||
|
@ -465,7 +466,7 @@ void SmRtfExport::HandleVerticalBrace(const SmVerticalBraceNode* pNode, int nLev
|
|||
m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MGROUPCHR " ");
|
||||
m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MGROUPCHRPR " ");
|
||||
m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MCHR " ");
|
||||
m_pBuffer->append(mathSymbolToString(pNode->Brace()));
|
||||
m_pBuffer->append(mathSymbolToString(pNode->Brace(), m_nEncoding));
|
||||
m_pBuffer->append("}"); // mchr
|
||||
// TODO not sure if pos and vertJc are correct
|
||||
m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MPOS " ").append(top ? "top" : "bot").append("}");
|
||||
|
|
|
@ -40,7 +40,7 @@ class SmRtfExport : public SmWordExportBase
|
|||
{
|
||||
public:
|
||||
SmRtfExport(const SmNode* pIn);
|
||||
bool ConvertFromStarMath(OStringBuffer& rBuffer);
|
||||
bool ConvertFromStarMath(OStringBuffer& rBuffer, rtl_TextEncoding nEncoding);
|
||||
private:
|
||||
virtual void HandleVerticalStack(const SmNode* pNode, int nLevel);
|
||||
virtual void HandleText(const SmNode* pNode, int nLevel);
|
||||
|
@ -55,6 +55,7 @@ private:
|
|||
virtual void HandleBlank();
|
||||
|
||||
OStringBuffer* m_pBuffer;
|
||||
rtl_TextEncoding m_nEncoding;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1123,9 +1123,9 @@ void SmModel::writeFormulaOoxml( ::sax_fastparser::FSHelperPtr m_pSerializer, oo
|
|||
static_cast< SmDocShell* >( GetObjectShell())->writeFormulaOoxml( m_pSerializer, version );
|
||||
}
|
||||
|
||||
void SmModel::writeFormulaRtf(OStringBuffer& rBuffer)
|
||||
void SmModel::writeFormulaRtf(OStringBuffer& rBuffer, rtl_TextEncoding nEncoding)
|
||||
{
|
||||
static_cast<SmDocShell*>(GetObjectShell())->writeFormulaRtf(rBuffer);
|
||||
static_cast<SmDocShell*>(GetObjectShell())->writeFormulaRtf(rBuffer, nEncoding);
|
||||
}
|
||||
|
||||
void SmModel::readFormulaOoxml( oox::formulaimport::XmlStream& stream )
|
||||
|
|
|
@ -3393,7 +3393,7 @@ bool RtfAttributeOutput::FlyFrameOLEMath(SwOLENode& rOLENode)
|
|||
{
|
||||
m_aRunText->append("{\\mmath");
|
||||
OStringBuffer aBuf;
|
||||
pBase->writeFormulaRtf(aBuf);
|
||||
pBase->writeFormulaRtf(aBuf, m_rExport.eCurrentEncoding);
|
||||
m_aRunText->append(aBuf.makeStringAndClear());
|
||||
m_aRunText->append("}");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue