Kaydet (Commit) 041f426a authored tarafından Caolán McNamara's avatar Caolán McNamara

ofz#7816 oom due to too many little allocations in short period of time

Change-Id: I5d575ee37926c24f9708710aa344bbf1f6ea8373
Reviewed-on: https://gerrit.libreoffice.org/53982Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst e84157af
......@@ -673,10 +673,14 @@ bool SmDocShell::ConvertFrom(SfxMedium &rMedium)
if ( aStorage->IsStream("Equation Native") )
{
// is this a MathType Storage?
MathType aEquation( maText );
OUStringBuffer aBuffer;
MathType aEquation(aBuffer);
bSuccess = aEquation.Parse( aStorage.get() );
if ( bSuccess )
{
maText = aBuffer.makeStringAndClear();
Parse();
}
}
}
}
......@@ -1284,7 +1288,8 @@ void SmDocShell::SetModified(bool bModified)
bool SmDocShell::WriteAsMathType3( SfxMedium& rMedium )
{
MathType aEquation( maText, mpTree.get() );
OUStringBuffer aTextAsBuffer(maText);
MathType aEquation(aTextAsBuffer, mpTree.get());
return aEquation.ConvertFromStarMath( rMedium );
}
......
This diff is collapsed.
......@@ -21,6 +21,7 @@
#define INCLUDED_STARMATH_SOURCE_MATHTYPE_HXX
#include <rtl/ustring.hxx>
#include <rtl/ustrbuf.hxx>
#include <set>
#include <vector>
......@@ -55,7 +56,7 @@ typedef ::std::set< MathTypeFont, LessMathTypeFont > MathTypeFontSet;
class MathType
{
public:
explicit MathType(OUString &rIn)
explicit MathType(OUStringBuffer &rIn)
: nVersion(0)
, pS(nullptr)
, rRet(rIn)
......@@ -76,7 +77,7 @@ public:
Init();
}
MathType(OUString &rIn,SmNode *pIn)
MathType(OUStringBuffer &rIn,SmNode *pIn)
: nVersion(0)
, pS(nullptr)
, rRet(rIn)
......@@ -149,7 +150,7 @@ private:
void HandleAttributes(SmNode *pNode,int nLevel);
void TypeFaceToString(OUString &rRet,sal_uInt8 nFace);
OUString &rRet;
OUStringBuffer &rRet;
SmNode *pTree;
sal_uInt8 nHAlign;
......@@ -182,7 +183,7 @@ private:
tmOARC
};
public:
static bool LookupChar(sal_Unicode nChar,OUString &rRet,
static bool LookupChar(sal_Unicode nChar,OUStringBuffer &rRet,
sal_uInt8 nVersion,sal_uInt8 nTypeFace=0);
};
......
......@@ -2447,13 +2447,11 @@ void SmMathSymbolNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
void SmMathSymbolNode::CreateTextFromNode(OUStringBuffer &rText)
{
OUString sStr;
sal_Unicode cChar = GetToken().cMathChar;
if (cChar == MS_INT && GetScaleMode() == SmScaleMode::Height)
sStr = "intd ";
rText.append("intd ");
else
MathType::LookupChar(cChar, sStr, 3);
rText.append(sStr);
MathType::LookupChar(cChar, rText, 3);
}
void SmRectangleNode::CreateTextFromNode(OUStringBuffer &rText)
......
......@@ -68,12 +68,12 @@ sal_Bool MathTypeFilter::filter(const uno::Sequence<beans::PropertyValue>& rDesc
if (auto pModel = dynamic_cast<SmModel*>(m_xDstDoc.get()))
{
auto pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell());
OUString aText = pDocShell->GetText();
OUStringBuffer aText(pDocShell->GetText());
MathType aEquation(aText);
bSuccess = aEquation.Parse(aStorage.get());
if (bSuccess)
{
pDocShell->SetText(aText);
pDocShell->SetText(aText.makeStringAndClear());
pDocShell->Parse();
}
}
......
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