Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
9ed9f30f
Kaydet (Commit)
9ed9f30f
authored
Kas 09, 2015
tarafından
Michael Stahl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
starmath: replace boost::ptr_deque with std::deque<std::unique_ptr>
Change-Id: I1d2671a0b355bd4dbb195d69af2c432c50df904e
üst
e126cf6c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
168 additions
and
150 deletions
+168
-150
node.hxx
starmath/inc/node.hxx
+9
-8
mathmlimport.cxx
starmath/source/mathmlimport.cxx
+73
-66
parse.cxx
starmath/source/parse.cxx
+86
-76
No files found.
starmath/inc/node.hxx
Dosyayı görüntüle @
9ed9f30f
...
...
@@ -20,16 +20,16 @@
#ifndef INCLUDED_STARMATH_INC_NODE_HXX
#define INCLUDED_STARMATH_INC_NODE_HXX
#include <vector>
#include <ostream>
#include "types.hxx"
#include "token.hxx"
#include "error.hxx"
#include "rect.hxx"
#include "format.hxx"
#include <boost/ptr_container/ptr_deque.hpp>
#include <memory>
#include <vector>
#include <deque>
#include <ostream>
#define ATTR_BOLD 0x0001
#define ATTR_ITALIC 0x0002
...
...
@@ -61,15 +61,16 @@ class SmNode;
class
SmStructureNode
;
typedef
std
::
shared_ptr
<
SmNode
>
SmNodePointer
;
typedef
boost
::
ptr_deque
<
SmNode
>
SmNodeStack
;
typedef
std
::
deque
<
std
::
unique_ptr
<
SmNode
>
>
SmNodeStack
;
typedef
std
::
vector
<
SmNode
*
>
SmNodeArray
;
template
<
typename
T
>
T
*
popOrZero
(
boost
::
ptr_deque
<
T
>
&
rStack
)
T
*
popOrZero
(
std
::
deque
<
std
::
unique_ptr
<
T
>>
&
rStack
)
{
if
(
rStack
.
empty
())
return
0
;
auto
pTmp
=
rStack
.
pop_front
();
return
nullptr
;
std
::
unique_ptr
<
T
>
pTmp
(
std
::
move
(
rStack
.
front
()));
rStack
.
pop_front
();
return
pTmp
.
release
();
}
...
...
starmath/source/mathmlimport.cxx
Dosyayı görüntüle @
9ed9f30f
...
...
@@ -42,6 +42,7 @@ one go*/
#include <comphelper/processfactory.hxx>
#include <comphelper/servicehelper.hxx>
#include <comphelper/string.hxx>
#include <o3tl/make_unique.hxx>
#include <rtl/math.hxx>
#include <sfx2/frame.hxx>
#include <sfx2/docfile.hxx>
...
...
@@ -670,9 +671,9 @@ void SmXMLContext_Helper::ApplyAttrs()
aToken
.
eType
=
TBOLD
;
else
aToken
.
eType
=
TNBOLD
;
SmFontNode
*
pFontNode
=
new
SmFontNode
(
aToken
);
std
::
unique_ptr
<
SmFontNode
>
pFontNode
(
new
SmFontNode
(
aToken
)
);
pFontNode
->
SetSubNodes
(
0
,
popOrZero
(
rNodeStack
));
rNodeStack
.
push_front
(
pFontNode
);
rNodeStack
.
push_front
(
std
::
move
(
pFontNode
)
);
}
if
(
nIsItalic
!=
-
1
)
{
...
...
@@ -680,14 +681,14 @@ void SmXMLContext_Helper::ApplyAttrs()
aToken
.
eType
=
TITALIC
;
else
aToken
.
eType
=
TNITALIC
;
SmFontNode
*
pFontNode
=
new
SmFontNode
(
aToken
);
std
::
unique_ptr
<
SmFontNode
>
pFontNode
(
new
SmFontNode
(
aToken
)
);
pFontNode
->
SetSubNodes
(
0
,
popOrZero
(
rNodeStack
));
rNodeStack
.
push_front
(
pFontNode
);
rNodeStack
.
push_front
(
std
::
move
(
pFontNode
)
);
}
if
(
nFontSize
!=
0.0
)
{
aToken
.
eType
=
TSIZE
;
SmFontNode
*
pFontNode
=
new
SmFontNode
(
aToken
);
std
::
unique_ptr
<
SmFontNode
>
pFontNode
(
new
SmFontNode
(
aToken
)
);
if
(
util
::
MeasureUnit
::
PERCENT
==
rContext
.
GetSmImport
()
.
GetMM100UnitConverter
().
GetXMLMeasureUnit
())
...
...
@@ -703,7 +704,7 @@ void SmXMLContext_Helper::ApplyAttrs()
pFontNode
->
SetSizeParameter
(
Fraction
(
nFontSize
),
FontSizeType
::
ABSOLUT
);
pFontNode
->
SetSubNodes
(
0
,
popOrZero
(
rNodeStack
));
rNodeStack
.
push_front
(
pFontNode
);
rNodeStack
.
push_front
(
std
::
move
(
pFontNode
)
);
}
if
(
!
sFontFamily
.
isEmpty
())
{
...
...
@@ -718,9 +719,9 @@ void SmXMLContext_Helper::ApplyAttrs()
return
;
aToken
.
aText
=
sFontFamily
;
SmFontNode
*
pFontNode
=
new
SmFontNode
(
aToken
);
std
::
unique_ptr
<
SmFontNode
>
pFontNode
(
new
SmFontNode
(
aToken
)
);
pFontNode
->
SetSubNodes
(
0
,
popOrZero
(
rNodeStack
));
rNodeStack
.
push_front
(
pFontNode
);
rNodeStack
.
push_front
(
std
::
move
(
pFontNode
)
);
}
if
(
!
sColor
.
isEmpty
())
{
...
...
@@ -732,9 +733,9 @@ void SmXMLContext_Helper::ApplyAttrs()
if
(
tok
!=
XML_TOK_UNKNOWN
)
{
aToken
.
eType
=
static_cast
<
SmTokenType
>
(
tok
);
SmFontNode
*
pFontNode
=
new
SmFontNode
(
aToken
);
std
::
unique_ptr
<
SmFontNode
>
pFontNode
(
new
SmFontNode
(
aToken
)
);
pFontNode
->
SetSubNodes
(
0
,
popOrZero
(
rNodeStack
));
rNodeStack
.
push_front
(
pFontNode
);
rNodeStack
.
push_front
(
std
::
move
(
pFontNode
)
);
}
}
...
...
@@ -929,10 +930,10 @@ void SmXMLPhantomContext_Impl::EndElement()
aToken
.
nLevel
=
5
;
aToken
.
eType
=
TPHANTOM
;
SmFontNode
*
pPhantom
=
new
SmFontNode
(
aToken
);
std
::
unique_ptr
<
SmFontNode
>
pPhantom
(
new
SmFontNode
(
aToken
)
);
SmNodeStack
&
rNodeStack
=
GetSmImport
().
GetNodeStack
();
pPhantom
->
SetSubNodes
(
0
,
popOrZero
(
rNodeStack
));
rNodeStack
.
push_front
(
pPhantom
);
rNodeStack
.
push_front
(
std
::
move
(
pPhantom
)
);
}
...
...
@@ -994,7 +995,7 @@ void SmXMLFencedContext_Impl::EndElement()
aToken
.
eType
=
TLPARENT
;
aToken
.
cMathChar
=
cBegin
;
SmStructureNode
*
pSNode
=
new
SmBraceNode
(
aToken
);
std
::
unique_ptr
<
SmStructureNode
>
pSNode
(
new
SmBraceNode
(
aToken
)
);
SmNode
*
pLeft
=
new
SmMathSymbolNode
(
aToken
);
aToken
.
cMathChar
=
cEnd
;
...
...
@@ -1014,7 +1015,8 @@ void SmXMLFencedContext_Impl::EndElement()
aRelationArray
.
resize
(
i
);
while
(
rNodeStack
.
size
()
>
nElementCount
)
{
auto
pNode
=
rNodeStack
.
pop_front
();
auto
pNode
=
std
::
move
(
rNodeStack
.
front
());
rNodeStack
.
pop_front
();
aRelationArray
[
--
i
]
=
pNode
.
release
();
if
(
i
>
1
&&
rNodeStack
.
size
()
>
1
)
aRelationArray
[
--
i
]
=
new
SmGlyphSpecialNode
(
aToken
);
...
...
@@ -1027,7 +1029,7 @@ void SmXMLFencedContext_Impl::EndElement()
pSNode
->
SetSubNodes
(
pLeft
,
pBody
,
pRight
);
pSNode
->
SetScaleMode
(
SCALE_HEIGHT
);
GetSmImport
().
GetNodeStack
().
push_front
(
pSNode
);
GetSmImport
().
GetNodeStack
().
push_front
(
std
::
move
(
pSNode
)
);
}
...
...
@@ -1088,7 +1090,7 @@ void SmXMLNumberContext_Impl::TCharacters(const OUString &rChars)
void
SmXMLNumberContext_Impl
::
EndElement
()
{
GetSmImport
().
GetNodeStack
().
push_front
(
new
SmTextNode
(
aToken
,
FNT_NUMBER
));
GetSmImport
().
GetNodeStack
().
push_front
(
o3tl
::
make_unique
<
SmTextNode
>
(
aToken
,
FNT_NUMBER
));
}
...
...
@@ -1167,7 +1169,7 @@ void SmXMLTextContext_Impl::TCharacters(const OUString &rChars)
void
SmXMLTextContext_Impl
::
EndElement
()
{
GetSmImport
().
GetNodeStack
().
push_front
(
new
SmTextNode
(
aToken
,
FNT_TEXT
));
GetSmImport
().
GetNodeStack
().
push_front
(
o3tl
::
make_unique
<
SmTextNode
>
(
aToken
,
FNT_TEXT
));
}
...
...
@@ -1209,7 +1211,7 @@ void SmXMLStringContext_Impl::TCharacters(const OUString &rChars)
void
SmXMLStringContext_Impl
::
EndElement
()
{
GetSmImport
().
GetNodeStack
().
push_front
(
new
SmTextNode
(
aToken
,
FNT_FIXED
));
GetSmImport
().
GetNodeStack
().
push_front
(
o3tl
::
make_unique
<
SmTextNode
>
(
aToken
,
FNT_FIXED
));
}
...
...
@@ -1240,18 +1242,18 @@ public:
void
SmXMLIdentifierContext_Impl
::
EndElement
()
{
SmTextNode
*
pNode
=
0
;
std
::
unique_ptr
<
SmTextNode
>
pNode
;
//we will handle identifier italic/normal here instead of with a standalone
//font node
if
(((
aStyleHelper
.
nIsItalic
==
-
1
)
&&
(
aToken
.
aText
.
getLength
()
>
1
))
||
((
aStyleHelper
.
nIsItalic
==
0
)
&&
(
aToken
.
aText
.
getLength
()
==
1
)))
{
pNode
=
new
SmTextNode
(
aToken
,
FNT_FUNCTION
);
pNode
.
reset
(
new
SmTextNode
(
aToken
,
FNT_FUNCTION
)
);
pNode
->
GetFont
().
SetItalic
(
ITALIC_NONE
);
aStyleHelper
.
nIsItalic
=
-
1
;
}
else
pNode
=
new
SmTextNode
(
aToken
,
FNT_VARIABLE
);
pNode
.
reset
(
new
SmTextNode
(
aToken
,
FNT_VARIABLE
)
);
if
(
aStyleHelper
.
bFontNodeNeeded
&&
aStyleHelper
.
nIsItalic
!=
-
1
)
{
if
(
aStyleHelper
.
nIsItalic
)
...
...
@@ -1268,7 +1270,7 @@ void SmXMLIdentifierContext_Impl::EndElement()
aStyleHelper
.
bFontNodeNeeded
=
false
;
if
(
aStyleHelper
.
bFontNodeNeeded
)
aStyleHelper
.
ApplyAttrs
();
GetSmImport
().
GetNodeStack
().
push_front
(
pNode
);
GetSmImport
().
GetNodeStack
().
push_front
(
std
::
move
(
pNode
)
);
}
void
SmXMLIdentifierContext_Impl
::
TCharacters
(
const
OUString
&
rChars
)
...
...
@@ -1306,13 +1308,13 @@ void SmXMLOperatorContext_Impl::TCharacters(const OUString &rChars)
void
SmXMLOperatorContext_Impl
::
EndElement
()
{
SmMathSymbolNode
*
pNode
=
new
SmMathSymbolNode
(
aToken
);
std
::
unique_ptr
<
SmMathSymbolNode
>
pNode
(
new
SmMathSymbolNode
(
aToken
)
);
//For stretchy scaling the scaling must be retrieved from this node
//and applied to the expression itself so as to get the expression
//to scale the operator to the height of the expression itself
if
(
bIsStretchy
)
pNode
->
SetScaleMode
(
SCALE_HEIGHT
);
GetSmImport
().
GetNodeStack
().
push_front
(
pNode
);
GetSmImport
().
GetNodeStack
().
push_front
(
std
::
move
(
pNode
)
);
}
...
...
@@ -1365,9 +1367,9 @@ void SmXMLSpaceContext_Impl::StartElement(
aToken
.
cMathChar
=
'\0'
;
aToken
.
eType
=
TBLANK
;
aToken
.
nLevel
=
5
;
SmBlankNode
*
pBlank
=
new
SmBlankNode
(
aToken
);
std
::
unique_ptr
<
SmBlankNode
>
pBlank
(
new
SmBlankNode
(
aToken
)
);
pBlank
->
IncreaseBy
(
aToken
);
GetSmImport
().
GetNodeStack
().
push_front
(
pBlank
);
GetSmImport
().
GetNodeStack
().
push_front
(
std
::
move
(
pBlank
)
);
}
...
...
@@ -1400,7 +1402,7 @@ void SmXMLSubContext_Impl::GenericEndElement(SmTokenType eType, SmSubSup eSubSup
SmToken
aToken
;
aToken
.
cMathChar
=
'\0'
;
aToken
.
eType
=
eType
;
SmSubSupNode
*
pNode
=
new
SmSubSupNode
(
aToken
);
std
::
unique_ptr
<
SmSubSupNode
>
pNode
(
new
SmSubSupNode
(
aToken
)
);
SmNodeStack
&
rNodeStack
=
GetSmImport
().
GetNodeStack
();
// initialize subnodes array
...
...
@@ -1412,7 +1414,7 @@ void SmXMLSubContext_Impl::GenericEndElement(SmTokenType eType, SmSubSup eSubSup
aSubNodes
[
eSubSup
+
1
]
=
popOrZero
(
rNodeStack
);
aSubNodes
[
0
]
=
popOrZero
(
rNodeStack
);
pNode
->
SetSubNodes
(
aSubNodes
);
rNodeStack
.
push_front
(
pNode
);
rNodeStack
.
push_front
(
std
::
move
(
pNode
)
);
}
...
...
@@ -1460,7 +1462,7 @@ void SmXMLSubSupContext_Impl::GenericEndElement(SmTokenType eType,
SmToken
aToken
;
aToken
.
cMathChar
=
'\0'
;
aToken
.
eType
=
eType
;
SmSubSupNode
*
pNode
=
new
SmSubSupNode
(
aToken
);
std
::
unique_ptr
<
SmSubSupNode
>
pNode
(
new
SmSubSupNode
(
aToken
)
);
SmNodeStack
&
rNodeStack
=
GetSmImport
().
GetNodeStack
();
// initialize subnodes array
...
...
@@ -1473,7 +1475,7 @@ void SmXMLSubSupContext_Impl::GenericEndElement(SmTokenType eType,
aSubNodes
[
aSub
+
1
]
=
popOrZero
(
rNodeStack
);
aSubNodes
[
0
]
=
popOrZero
(
rNodeStack
);
pNode
->
SetSubNodes
(
aSubNodes
);
rNodeStack
.
push_front
(
pNode
);
rNodeStack
.
push_front
(
std
::
move
(
pNode
)
);
}
...
...
@@ -1519,7 +1521,7 @@ void SmXMLUnderContext_Impl::HandleAccent()
SmNodeArray
aSubNodes
;
aSubNodes
.
resize
(
2
);
SmStructureNode
*
pNode
=
new
SmAttributNode
(
aToken
);
std
::
unique_ptr
<
SmStructureNode
>
pNode
(
new
SmAttributNode
(
aToken
)
);
if
((
pTest
->
GetToken
().
cMathChar
&
0x0FFF
)
==
0x0332
)
{
aSubNodes
[
0
]
=
new
SmRectangleNode
(
aToken
);
...
...
@@ -1531,7 +1533,7 @@ void SmXMLUnderContext_Impl::HandleAccent()
aSubNodes
[
1
]
=
popOrZero
(
rNodeStack
);
pNode
->
SetSubNodes
(
aSubNodes
);
pNode
->
SetScaleMode
(
SCALE_WIDTH
);
rNodeStack
.
push_front
(
pNode
);
rNodeStack
.
push_front
(
std
::
move
(
pNode
)
);
}
...
...
@@ -1588,7 +1590,7 @@ void SmXMLOverContext_Impl::HandleAccent()
aToken
.
cMathChar
=
'\0'
;
aToken
.
eType
=
TACUTE
;
SmAttributNode
*
pNode
=
new
SmAttributNode
(
aToken
);
std
::
unique_ptr
<
SmAttributNode
>
pNode
(
new
SmAttributNode
(
aToken
)
);
SmNodeStack
&
rNodeStack
=
GetSmImport
().
GetNodeStack
();
SmNodeArray
aSubNodes
;
...
...
@@ -1597,7 +1599,7 @@ void SmXMLOverContext_Impl::HandleAccent()
aSubNodes
[
1
]
=
popOrZero
(
rNodeStack
);
pNode
->
SetSubNodes
(
aSubNodes
);
pNode
->
SetScaleMode
(
SCALE_WIDTH
);
rNodeStack
.
push_front
(
pNode
);
rNodeStack
.
push_front
(
std
::
move
(
pNode
)
);
}
...
...
@@ -1657,7 +1659,7 @@ void SmXMLNoneContext_Impl::EndElement()
aToken
.
nLevel
=
5
;
aToken
.
eType
=
TIDENT
;
GetSmImport
().
GetNodeStack
().
push_front
(
new
SmTextNode
(
aToken
,
FNT_VARIABLE
));
o3tl
::
make_unique
<
SmTextNode
>
(
aToken
,
FNT_VARIABLE
));
}
...
...
@@ -2136,21 +2138,22 @@ void SmXMLDocContext_Impl::EndElement()
ContextArray
[
0
]
=
popOrZero
(
rNodeStack
);
SmToken
aDummy
;
SmStructureNode
*
pSNode
=
new
SmLineNode
(
aDummy
);
std
::
unique_ptr
<
SmStructureNode
>
pSNode
(
new
SmLineNode
(
aDummy
)
);
pSNode
->
SetSubNodes
(
ContextArray
);
rNodeStack
.
push_front
(
pSNode
);
rNodeStack
.
push_front
(
std
::
move
(
pSNode
)
);
SmNodeArray
LineArray
;
auto
n
=
rNodeStack
.
size
();
LineArray
.
resize
(
n
);
for
(
size_t
j
=
0
;
j
<
n
;
j
++
)
{
auto
pNode
=
rNodeStack
.
pop_front
();
auto
pNode
=
std
::
move
(
rNodeStack
.
front
());
rNodeStack
.
pop_front
();
LineArray
[
n
-
(
j
+
1
)]
=
pNode
.
release
();
}
SmStructureNode
*
pSNode2
=
new
SmTableNode
(
aDummy
);
std
::
unique_ptr
<
SmStructureNode
>
pSNode2
(
new
SmTableNode
(
aDummy
)
);
pSNode2
->
SetSubNodes
(
LineArray
);
rNodeStack
.
push_front
(
pSNode2
);
rNodeStack
.
push_front
(
std
::
move
(
pSNode2
)
);
}
void
SmXMLFracContext_Impl
::
EndElement
()
...
...
@@ -2164,12 +2167,12 @@ void SmXMLFracContext_Impl::EndElement()
SmToken
aToken
;
aToken
.
cMathChar
=
'\0'
;
aToken
.
eType
=
TOVER
;
SmStructureNode
*
pSNode
=
new
SmBinVerNode
(
aToken
);
std
::
unique_ptr
<
SmStructureNode
>
pSNode
(
new
SmBinVerNode
(
aToken
)
);
SmNode
*
pOper
=
new
SmRectangleNode
(
aToken
);
SmNode
*
pSecond
=
popOrZero
(
rNodeStack
);
SmNode
*
pFirst
=
popOrZero
(
rNodeStack
);
pSNode
->
SetSubNodes
(
pFirst
,
pOper
,
pSecond
);
rNodeStack
.
push_front
(
pSNode
);
rNodeStack
.
push_front
(
std
::
move
(
pSNode
)
);
}
void
SmXMLRootContext_Impl
::
EndElement
()
...
...
@@ -2183,13 +2186,13 @@ void SmXMLRootContext_Impl::EndElement()
SmToken
aToken
;
aToken
.
cMathChar
=
MS_SQRT
;
//Temporary: alert, based on StarSymbol font
aToken
.
eType
=
TNROOT
;
SmStructureNode
*
pSNode
=
new
SmRootNode
(
aToken
);
std
::
unique_ptr
<
SmStructureNode
>
pSNode
(
new
SmRootNode
(
aToken
)
);
SmNode
*
pOper
=
new
SmRootSymbolNode
(
aToken
);
SmNodeStack
&
rNodeStack
=
GetSmImport
().
GetNodeStack
();
SmNode
*
pIndex
=
popOrZero
(
rNodeStack
);
SmNode
*
pBase
=
popOrZero
(
rNodeStack
);
pSNode
->
SetSubNodes
(
pIndex
,
pOper
,
pBase
);
rNodeStack
.
push_front
(
pSNode
);
rNodeStack
.
push_front
(
std
::
move
(
pSNode
)
);
}
void
SmXMLSqrtContext_Impl
::
EndElement
()
...
...
@@ -2205,11 +2208,11 @@ void SmXMLSqrtContext_Impl::EndElement()
SmToken
aToken
;
aToken
.
cMathChar
=
MS_SQRT
;
//Temporary: alert, based on StarSymbol font
aToken
.
eType
=
TSQRT
;
SmStructureNode
*
pSNode
=
new
SmRootNode
(
aToken
);
std
::
unique_ptr
<
SmStructureNode
>
pSNode
(
new
SmRootNode
(
aToken
)
);
SmNode
*
pOper
=
new
SmRootSymbolNode
(
aToken
);
SmNodeStack
&
rNodeStack
=
GetSmImport
().
GetNodeStack
();
pSNode
->
SetSubNodes
(
0
,
pOper
,
popOrZero
(
rNodeStack
));
rNodeStack
.
push_front
(
pSNode
);
rNodeStack
.
push_front
(
std
::
move
(
pSNode
)
);
}
void
SmXMLRowContext_Impl
::
EndElement
()
...
...
@@ -2224,7 +2227,8 @@ void SmXMLRowContext_Impl::EndElement()
aRelationArray
.
resize
(
nSize
);
for
(
auto
j
=
nSize
;
j
>
0
;
j
--
)
{
auto
pNode
=
rNodeStack
.
pop_front
();
auto
pNode
=
std
::
move
(
rNodeStack
.
front
());
rNodeStack
.
pop_front
();
aRelationArray
[
j
-
1
]
=
pNode
.
release
();
}
...
...
@@ -2279,13 +2283,13 @@ void SmXMLRowContext_Impl::EndElement()
}
SmToken
aDummy
;
SmStructureNode
*
pSNode
=
new
SmBraceNode
(
aToken
);
std
::
unique_ptr
<
SmStructureNode
>
pSNode
(
new
SmBraceNode
(
aToken
)
);
SmStructureNode
*
pBody
=
new
SmExpressionNode
(
aDummy
);
pBody
->
SetSubNodes
(
aRelationArray2
);
pSNode
->
SetSubNodes
(
pLeft
,
pBody
,
pRight
);
pSNode
->
SetScaleMode
(
SCALE_HEIGHT
);
rNodeStack
.
push_front
(
pSNode
);
rNodeStack
.
push_front
(
std
::
move
(
pSNode
)
);
return
;
}
}
...
...
@@ -2300,9 +2304,9 @@ void SmXMLRowContext_Impl::EndElement()
}
SmToken
aDummy
;
SmStructureNode
*
pSNode
=
new
SmExpressionNode
(
aDummy
);
std
::
unique_ptr
<
SmStructureNode
>
pSNode
(
new
SmExpressionNode
(
aDummy
)
);
pSNode
->
SetSubNodes
(
aRelationArray
);
rNodeStack
.
push_front
(
pSNode
);
rNodeStack
.
push_front
(
std
::
move
(
pSNode
)
);
}
...
...
@@ -2429,8 +2433,9 @@ void SmXMLMultiScriptsContext_Impl::ProcessSubSupPairs(bool bIsPrescript)
SmNodeStack
aReverseStack
;
for
(
size_t
i
=
0
;
i
<
nCount
+
1
;
i
++
)
{
auto
pNode
=
rNodeStack
.
pop_front
();
aReverseStack
.
push_front
(
pNode
.
release
());
auto
pNode
=
std
::
move
(
rNodeStack
.
front
());
rNodeStack
.
pop_front
();
aReverseStack
.
push_front
(
std
::
move
(
pNode
));
}
SmSubSup
eSub
=
bIsPrescript
?
LSUB
:
RSUB
;
...
...
@@ -2438,7 +2443,7 @@ void SmXMLMultiScriptsContext_Impl::ProcessSubSupPairs(bool bIsPrescript)
for
(
size_t
i
=
0
;
i
<
nCount
;
i
+=
2
)
{
SmSubSupNode
*
pNode
=
new
SmSubSupNode
(
aToken
);
std
::
unique_ptr
<
SmSubSupNode
>
pNode
(
new
SmSubSupNode
(
aToken
)
);
// initialize subnodes array
SmNodeArray
aSubNodes
(
1
+
SUBSUP_NUM_ENTRIES
);
...
...
@@ -2459,11 +2464,12 @@ void SmXMLMultiScriptsContext_Impl::ProcessSubSupPairs(bool bIsPrescript)
aSubNodes
[
eSup
+
1
]
=
pScriptNode
;
pNode
->
SetSubNodes
(
aSubNodes
);
aReverseStack
.
push_front
(
pNode
);
aReverseStack
.
push_front
(
std
::
move
(
pNode
)
);
}
assert
(
!
aReverseStack
.
empty
());
auto
pNode
=
aReverseStack
.
pop_front
();
rNodeStack
.
push_front
(
pNode
.
release
());
auto
pNode
=
std
::
move
(
aReverseStack
.
front
());
aReverseStack
.
pop_front
();
rNodeStack
.
push_front
(
std
::
move
(
pNode
));
}
else
{
...
...
@@ -2489,8 +2495,8 @@ void SmXMLTableContext_Impl::EndElement()
SmStructureNode
*
pArray
;
for
(
auto
i
=
nRows
;
i
>
0
;
i
--
)
{
auto
pNode
=
rNodeStack
.
pop_front
(
);
pArray
=
static_cast
<
SmStructureNode
*>
(
pNode
.
release
()
);
pArray
=
static_cast
<
SmStructureNode
*>
(
rNodeStack
.
front
().
release
()
);
rNodeStack
.
pop_front
(
);
if
(
pArray
->
GetNumSubNodes
()
==
0
)
{
//This is a little tricky, it is possible that there was
...
...
@@ -2511,14 +2517,14 @@ void SmXMLTableContext_Impl::EndElement()
if
(
pArray
->
GetNumSubNodes
()
>
nCols
)
nCols
=
pArray
->
GetNumSubNodes
();
aReverseStack
.
push_front
(
pArray
);
aReverseStack
.
push_front
(
std
::
unique_ptr
<
SmStructureNode
>
(
pArray
)
);
}
aExpressionArray
.
resize
(
nCols
*
nRows
);
size_t
j
=
0
;
while
(
!
aReverseStack
.
empty
()
)
{
auto
pNode
=
aReverseStack
.
pop_front
(
);
pArray
=
static_cast
<
SmStructureNode
*>
(
pNode
.
release
()
);
pArray
=
static_cast
<
SmStructureNode
*>
(
aReverseStack
.
front
().
release
()
);
aReverseStack
.
pop_front
(
);
for
(
sal_uInt16
i
=
0
;
i
<
pArray
->
GetNumSubNodes
();
i
++
)
aExpressionArray
[
j
++
]
=
pArray
->
GetSubNode
(
i
);
}
...
...
@@ -2527,10 +2533,10 @@ void SmXMLTableContext_Impl::EndElement()
aToken
.
cMathChar
=
'\0'
;
aToken
.
nGroup
=
TRGROUP
;
aToken
.
eType
=
TMATRIX
;
SmMatrixNode
*
pSNode
=
new
SmMatrixNode
(
aToken
);
std
::
unique_ptr
<
SmMatrixNode
>
pSNode
(
new
SmMatrixNode
(
aToken
)
);
pSNode
->
SetSubNodes
(
aExpressionArray
);
pSNode
->
SetRowCol
(
static_cast
<
sal_uInt16
>
(
nRows
),
nCols
);
rNodeStack
.
push_front
(
pSNode
);
rNodeStack
.
push_front
(
std
::
move
(
pSNode
)
);
}
SvXMLImportContext
*
SmXMLTableRowContext_Impl
::
CreateChildContext
(
...
...
@@ -2630,12 +2636,13 @@ void SmXMLActionContext_Impl::EndElement()
{
rNodeStack
.
pop_front
();
}
auto
pSelected
=
rNodeStack
.
pop_front
();
auto
pSelected
=
std
::
move
(
rNodeStack
.
front
());
rNodeStack
.
pop_front
();
for
(
auto
i
=
rNodeStack
.
size
()
-
nElementCount
;
i
>
0
;
i
--
)
{
rNodeStack
.
pop_front
();
}
rNodeStack
.
push_front
(
pSelected
.
release
(
));
rNodeStack
.
push_front
(
std
::
move
(
pSelected
));
}
SvXMLImportContext
*
SmXMLImport
::
CreateContext
(
sal_uInt16
nPrefix
,
...
...
starmath/source/parse.cxx
Dosyayı görüntüle @
9ed9f30f
...
...
@@ -23,6 +23,7 @@
#include <editeng/unolingu.hxx>
#include <unotools/syslocale.hxx>
#include <sal/macros.h>
#include <o3tl/make_unique.hxx>
#include <vcl/settings.hxx>
#include "parse.hxx"
#include "starmath.hrc"
...
...
@@ -978,13 +979,14 @@ void SmParser::DoTable()
for
(
size_t
i
=
0
;
i
<
n
;
i
++
)
{
auto
pNode
=
m_aNodeStack
.
pop_front
();
auto
pNode
=
std
::
move
(
m_aNodeStack
.
front
());
m_aNodeStack
.
pop_front
();
LineArray
[
n
-
(
i
+
1
)]
=
pNode
.
release
();
}
SmStructureNode
*
pSNode
=
new
SmTableNode
(
m_aCurToken
);
std
::
unique_ptr
<
SmStructureNode
>
pSNode
(
new
SmTableNode
(
m_aCurToken
)
);
pSNode
->
SetSubNodes
(
LineArray
);
m_aNodeStack
.
push_front
(
pSNode
);
m_aNodeStack
.
push_front
(
std
::
move
(
pSNode
)
);
}
void
SmParser
::
DoAlign
()
...
...
@@ -1012,7 +1014,7 @@ void SmParser::DoAlign()
if
(
pSNode
)
{
pSNode
->
SetSubNode
(
0
,
popOrZero
(
m_aNodeStack
));
m_aNodeStack
.
push_front
(
pSNode
);
m_aNodeStack
.
push_front
(
std
::
unique_ptr
<
SmStructureNode
>
(
pSNode
)
);
}
}
...
...
@@ -1045,9 +1047,9 @@ void SmParser::DoLine()
ExpressionArray
.
push_back
(
new
SmExpressionNode
(
aTok
));
}
SmStructureNode
*
pSNode
=
new
SmLineNode
(
m_aCurToken
);
std
::
unique_ptr
<
SmStructureNode
>
pSNode
(
new
SmLineNode
(
m_aCurToken
)
);
pSNode
->
SetSubNodes
(
ExpressionArray
);
m_aNodeStack
.
push_front
(
pSNode
);
m_aNodeStack
.
push_front
(
std
::
move
(
pSNode
)
);
}
void
SmParser
::
DoExpression
()
...
...
@@ -1055,11 +1057,16 @@ void SmParser::DoExpression()
bool
bUseExtraSpaces
=
true
;
if
(
!
m_aNodeStack
.
empty
())
{
auto
pNode
=
m_aNodeStack
.
pop_front
();
auto
pNode
=
std
::
move
(
m_aNodeStack
.
front
());
m_aNodeStack
.
pop_front
();
if
(
pNode
->
GetToken
().
eType
==
TNOSPACE
)
bUseExtraSpaces
=
false
;
else
m_aNodeStack
.
push_front
(
pNode
.
release
());
// push the node from above again (now to be used as argument to this current 'nospace' node)
{
// push the node from above again (now to be used as argument
// to this current 'nospace' node)
m_aNodeStack
.
push_front
(
std
::
move
(
pNode
));
}
}
SmNodeArray
RelationArray
;
...
...
@@ -1075,15 +1082,15 @@ void SmParser::DoExpression()
if
(
RelationArray
.
size
()
>
1
)
{
SmExpressionNode
*
pSNode
=
new
SmExpressionNode
(
m_aCurToken
);
std
::
unique_ptr
<
SmExpressionNode
>
pSNode
(
new
SmExpressionNode
(
m_aCurToken
)
);
pSNode
->
SetSubNodes
(
RelationArray
);
pSNode
->
SetUseExtraSpaces
(
bUseExtraSpaces
);
m_aNodeStack
.
push_front
(
pSNode
);
m_aNodeStack
.
push_front
(
std
::
move
(
pSNode
)
);
}
else
{
// This expression has only one node so just push this node.
m_aNodeStack
.
push_front
(
RelationArray
[
0
]
);
m_aNodeStack
.
push_front
(
std
::
unique_ptr
<
SmNode
>
(
RelationArray
[
0
])
);
}
}
...
...
@@ -1092,7 +1099,7 @@ void SmParser::DoRelation()
DoSum
();
while
(
TokenInGroup
(
TGRELATION
))
{
SmStructureNode
*
pSNode
=
new
SmBinHorNode
(
m_aCurToken
);
std
::
unique_ptr
<
SmStructureNode
>
pSNode
(
new
SmBinHorNode
(
m_aCurToken
)
);
SmNode
*
pFirst
=
popOrZero
(
m_aNodeStack
);
DoOpSubSup
();
...
...
@@ -1101,7 +1108,7 @@ void SmParser::DoRelation()
DoSum
();
pSNode
->
SetSubNodes
(
pFirst
,
pSecond
,
popOrZero
(
m_aNodeStack
));
m_aNodeStack
.
push_front
(
pSNode
);
m_aNodeStack
.
push_front
(
std
::
move
(
pSNode
)
);
}
}
...
...
@@ -1110,7 +1117,7 @@ void SmParser::DoSum()
DoProduct
();
while
(
TokenInGroup
(
TGSUM
))
{
SmStructureNode
*
pSNode
=
new
SmBinHorNode
(
m_aCurToken
);
std
::
unique_ptr
<
SmStructureNode
>
pSNode
(
new
SmBinHorNode
(
m_aCurToken
)
);
SmNode
*
pFirst
=
popOrZero
(
m_aNodeStack
);
DoOpSubSup
();
...
...
@@ -1119,7 +1126,7 @@ void SmParser::DoSum()
DoProduct
();
pSNode
->
SetSubNodes
(
pFirst
,
pSecond
,
popOrZero
(
m_aNodeStack
));
m_aNodeStack
.
push_front
(
pSNode
);
m_aNodeStack
.
push_front
(
std
::
move
(
pSNode
)
);
}
}
...
...
@@ -1195,7 +1202,7 @@ void SmParser::DoProduct()
{
pSNode
->
SetSubNodes
(
pFirst
,
pOper
,
popOrZero
(
m_aNodeStack
));
}
m_aNodeStack
.
push_front
(
pSNode
);
m_aNodeStack
.
push_front
(
std
::
unique_ptr
<
SmStructureNode
>
(
pSNode
)
);
}
}
...
...
@@ -1208,7 +1215,7 @@ void SmParser::DoSubSup(sal_uLong nActiveGroup)
// already finish
return
;
SmSubSupNode
*
pNode
=
new
SmSubSupNode
(
m_aCurToken
);
std
::
unique_ptr
<
SmSubSupNode
>
pNode
(
new
SmSubSupNode
(
m_aCurToken
)
);
//! Of course 'm_aCurToken' is just the first sub-/supscript token.
//! It should be of no further interest. The positions of the
//! sub-/supscripts will be identified by the corresponding subnodes
...
...
@@ -1264,13 +1271,13 @@ void SmParser::DoSubSup(sal_uLong nActiveGroup)
}
pNode
->
SetSubNodes
(
aSubNodes
);
m_aNodeStack
.
push_front
(
pNode
);
m_aNodeStack
.
push_front
(
std
::
move
(
pNode
)
);
}
void
SmParser
::
DoOpSubSup
()
{
// push operator symbol
m_aNodeStack
.
push_front
(
new
SmMathSymbolNode
(
m_aCurToken
));
m_aNodeStack
.
push_front
(
o3tl
::
make_unique
<
SmMathSymbolNode
>
(
m_aCurToken
));
// skip operator token
NextToken
();
// get sub- supscripts if any
...
...
@@ -1289,7 +1296,7 @@ void SmParser::DoPower()
void
SmParser
::
DoBlank
()
{
OSL_ENSURE
(
TokenInGroup
(
TGBLANK
),
"Sm : wrong token"
);
SmBlankNode
*
pBlankNode
=
new
SmBlankNode
(
m_aCurToken
);
std
::
unique_ptr
<
SmBlankNode
>
pBlankNode
(
new
SmBlankNode
(
m_aCurToken
)
);
while
(
TokenInGroup
(
TGBLANK
))
{
...
...
@@ -1304,7 +1311,7 @@ void SmParser::DoBlank()
pBlankNode
->
Clear
();
}
m_aNodeStack
.
push_front
(
pBlankNode
);
m_aNodeStack
.
push_front
(
std
::
move
(
pBlankNode
)
);
}
void
SmParser
::
DoTerm
(
bool
bGroupNumberIdent
)
...
...
@@ -1321,7 +1328,7 @@ void SmParser::DoTerm(bool bGroupNumberIdent)
bool
bNoSpace
=
m_aCurToken
.
eType
==
TNOSPACE
;
if
(
bNoSpace
)
// push 'no space' node and continue to parse expression
{
m_aNodeStack
.
push_front
(
new
SmExpressionNode
(
m_aCurToken
));
m_aNodeStack
.
push_front
(
o3tl
::
make_unique
<
SmExpressionNode
>
(
m_aCurToken
));
NextToken
();
}
if
(
m_aCurToken
.
eType
!=
TLGROUP
)
...
...
@@ -1338,9 +1345,9 @@ void SmParser::DoTerm(bool bGroupNumberIdent)
{
if
(
bNoSpace
)
// get rid of the 'no space' node pushed above
m_aNodeStack
.
pop_front
();
SmStructureNode
*
pSNode
=
new
SmExpressionNode
(
m_aCurToken
);
std
::
unique_ptr
<
SmStructureNode
>
pSNode
(
new
SmExpressionNode
(
m_aCurToken
)
);
pSNode
->
SetSubNodes
(
NULL
,
NULL
);
m_aNodeStack
.
push_front
(
pSNode
);
m_aNodeStack
.
push_front
(
std
::
move
(
pSNode
)
);
NextToken
();
}
...
...
@@ -1366,17 +1373,17 @@ void SmParser::DoTerm(bool bGroupNumberIdent)
break
;
case
TTEXT
:
m_aNodeStack
.
push_front
(
new
SmTextNode
(
m_aCurToken
,
FNT_TEXT
));
m_aNodeStack
.
push_front
(
o3tl
::
make_unique
<
SmTextNode
>
(
m_aCurToken
,
FNT_TEXT
));
NextToken
();
break
;
case
TCHARACTER
:
m_aNodeStack
.
push_front
(
new
SmTextNode
(
m_aCurToken
,
FNT_VARIABLE
));
m_aNodeStack
.
push_front
(
o3tl
::
make_unique
<
SmTextNode
>
(
m_aCurToken
,
FNT_VARIABLE
));
NextToken
();
break
;
case
TIDENT
:
case
TNUMBER
:
{
m_aNodeStack
.
push_front
(
new
SmTextNode
(
m_aCurToken
,
m_aNodeStack
.
push_front
(
o3tl
::
make_unique
<
SmTextNode
>
(
m_aCurToken
,
m_aCurToken
.
eType
==
TNUMBER
?
FNT_NUMBER
:
FNT_VARIABLE
));
...
...
@@ -1413,7 +1420,7 @@ void SmParser::DoTerm(bool bGroupNumberIdent)
moveToNextToken
=
false
;
break
;
}
m_aNodeStack
.
push_front
(
new
SmTextNode
(
m_aCurToken
,
m_aNodeStack
.
push_front
(
o3tl
::
make_unique
<
SmTextNode
>
(
m_aCurToken
,
m_aCurToken
.
eType
==
TNUMBER
?
FNT_NUMBER
:
...
...
@@ -1432,9 +1439,9 @@ void SmParser::DoTerm(bool bGroupNumberIdent)
nodeArray
[
nTokens
-
1
]
=
popOrZero
(
m_aNodeStack
);
nTokens
--
;
}
SmExpressionNode
*
pNode
=
new
SmExpressionNode
(
SmToken
(
));
std
::
unique_ptr
<
SmExpressionNode
>
pNode
(
new
SmExpressionNode
(
SmToken
()
));
pNode
->
SetSubNodes
(
nodeArray
);
m_aNodeStack
.
push_front
(
pNode
);
m_aNodeStack
.
push_front
(
std
::
move
(
pNode
)
);
}
}
break
;
...
...
@@ -1459,7 +1466,7 @@ void SmParser::DoTerm(bool bGroupNumberIdent)
case
TDOTSLOW
:
case
TDOTSUP
:
case
TDOTSVERT
:
m_aNodeStack
.
push_front
(
new
SmMathSymbolNode
(
m_aCurToken
));
m_aNodeStack
.
push_front
(
o3tl
::
make_unique
<
SmMathSymbolNode
>
(
m_aCurToken
));
NextToken
();
break
;
...
...
@@ -1477,12 +1484,12 @@ void SmParser::DoTerm(bool bGroupNumberIdent)
case
TWP
:
case
TEMPTYSET
:
case
TINFINITY
:
m_aNodeStack
.
push_front
(
new
SmMathIdentifierNode
(
m_aCurToken
));
m_aNodeStack
.
push_front
(
o3tl
::
make_unique
<
SmMathIdentifierNode
>
(
m_aCurToken
));
NextToken
();
break
;
case
TPLACE
:
m_aNodeStack
.
push_front
(
new
SmPlaceNode
(
m_aCurToken
));
m_aNodeStack
.
push_front
(
o3tl
::
make_unique
<
SmPlaceNode
>
(
m_aCurToken
));
NextToken
();
break
;
...
...
@@ -1546,7 +1553,7 @@ void SmParser::DoTerm(bool bGroupNumberIdent)
pNode
->
SetSubNodes
(
0
,
pFirstNode
);
pFirstNode
=
pNode
;
}
m_aNodeStack
.
push_front
(
pFirstNode
);
m_aNodeStack
.
push_front
(
std
::
unique_ptr
<
SmNode
>
(
pFirstNode
)
);
}
else
if
(
TokenInGroup
(
TGFUNCTION
))
{
...
...
@@ -1588,8 +1595,8 @@ void SmParser::DoEscape()
Error
(
PE_UNEXPECTED_TOKEN
);
}
SmNode
*
pNode
=
new
SmMathSymbolNode
(
m_aCurToken
);
m_aNodeStack
.
push_front
(
pNode
);
std
::
unique_ptr
<
SmNode
>
pNode
(
new
SmMathSymbolNode
(
m_aCurToken
)
);
m_aNodeStack
.
push_front
(
std
::
move
(
pNode
)
);
NextToken
();
}
...
...
@@ -1597,7 +1604,8 @@ void SmParser::DoEscape()
void
SmParser
::
DoOperator
()
{
if
(
TokenInGroup
(
TGOPER
))
{
SmStructureNode
*
pSNode
=
new
SmOperNode
(
m_aCurToken
);
{
std
::
unique_ptr
<
SmStructureNode
>
pSNode
(
new
SmOperNode
(
m_aCurToken
));
// put operator on top of stack
DoOper
();
...
...
@@ -1610,14 +1618,14 @@ void SmParser::DoOperator()
DoPower
();
pSNode
->
SetSubNodes
(
pOperator
,
popOrZero
(
m_aNodeStack
));
m_aNodeStack
.
push_front
(
pSNode
);
m_aNodeStack
.
push_front
(
std
::
move
(
pSNode
)
);
}
}
void
SmParser
::
DoOper
()
{
SmTokenType
eType
(
m_aCurToken
.
eType
);
SmNode
*
pNode
=
NULL
;
std
::
unique_ptr
<
SmNode
>
pNode
;
switch
(
eType
)
{
...
...
@@ -1630,7 +1638,7 @@ void SmParser::DoOper()
case
TLINT
:
case
TLLINT
:
case
TLLLINT
:
pNode
=
new
SmMathSymbolNode
(
m_aCurToken
);
pNode
.
reset
(
new
SmMathSymbolNode
(
m_aCurToken
)
);
break
;
case
TLIM
:
...
...
@@ -1648,7 +1656,7 @@ void SmParser::DoOper()
}
if
(
pLim
)
m_aCurToken
.
aText
=
OUString
::
createFromAscii
(
pLim
);
pNode
=
new
SmTextNode
(
m_aCurToken
,
FNT_TEXT
);
pNode
.
reset
(
new
SmTextNode
(
m_aCurToken
,
FNT_TEXT
)
);
}
break
;
...
...
@@ -1656,13 +1664,13 @@ void SmParser::DoOper()
NextToken
();
OSL_ENSURE
(
m_aCurToken
.
eType
==
TSPECIAL
,
"Sm: wrong token"
);
pNode
=
new
SmGlyphSpecialNode
(
m_aCurToken
);
pNode
.
reset
(
new
SmGlyphSpecialNode
(
m_aCurToken
)
);
break
;
default
:
assert
(
false
&&
"unknown case"
);
}
m_aNodeStack
.
push_front
(
pNode
);
m_aNodeStack
.
push_front
(
std
::
move
(
pNode
)
);
NextToken
();
}
...
...
@@ -1675,7 +1683,7 @@ void SmParser::DoUnOper()
SmTokenType
eType
=
m_aCurToken
.
eType
;
bool
bIsPostfix
=
eType
==
TFACT
;
SmStructureNode
*
pSNode
;
std
::
unique_ptr
<
SmStructureNode
>
pSNode
;
SmNode
*
pOper
=
0
,
*
pExtra
=
0
,
*
pArg
;
...
...
@@ -1725,7 +1733,8 @@ void SmParser::DoUnOper()
pArg
=
popOrZero
(
m_aNodeStack
);
if
(
eType
==
TABS
)
{
pSNode
=
new
SmBraceNode
(
aNodeToken
);
{
pSNode
.
reset
(
new
SmBraceNode
(
aNodeToken
));
pSNode
->
SetScaleMode
(
SCALE_HEIGHT
);
// build nodes for left & right lines
...
...
@@ -1742,18 +1751,20 @@ void SmParser::DoUnOper()
pSNode
->
SetSubNodes
(
pLeft
,
pArg
,
pRight
);
}
else
if
(
eType
==
TSQRT
||
eType
==
TNROOT
)
{
pSNode
=
new
SmRootNode
(
aNodeToken
);
{
pSNode
.
reset
(
new
SmRootNode
(
aNodeToken
));
pOper
=
new
SmRootSymbolNode
(
aNodeToken
);
pSNode
->
SetSubNodes
(
pExtra
,
pOper
,
pArg
);
}
else
if
(
eType
==
TINTD
)
{
pSNode
=
new
SmDynIntegralNode
(
aNodeToken
);
{
pSNode
.
reset
(
new
SmDynIntegralNode
(
aNodeToken
));
pOper
=
new
SmDynIntegralSymbolNode
(
aNodeToken
);
pSNode
->
SetSubNodes
(
pOper
,
pArg
);
}
else
{
pSNode
=
new
SmUnHorNode
(
aNodeToken
);
{
pSNode
.
reset
(
new
SmUnHorNode
(
aNodeToken
));
if
(
bIsPostfix
)
pSNode
->
SetSubNodes
(
pArg
,
pOper
);
else
...
...
@@ -1761,14 +1772,14 @@ void SmParser::DoUnOper()
pSNode
->
SetSubNodes
(
pOper
,
pArg
);
}
m_aNodeStack
.
push_front
(
pSNode
);
m_aNodeStack
.
push_front
(
std
::
move
(
pSNode
)
);
}
void
SmParser
::
DoAttribut
()
{
OSL_ENSURE
(
TokenInGroup
(
TGATTRIBUT
),
"Sm: wrong token group"
);
SmStructureNode
*
pSNode
=
new
SmAttributNode
(
m_aCurToken
);
std
::
unique_ptr
<
SmStructureNode
>
pSNode
(
new
SmAttributNode
(
m_aCurToken
)
);
SmNode
*
pAttr
;
SmScaleMode
eScaleMode
=
SCALE_NONE
;
...
...
@@ -1796,7 +1807,7 @@ void SmParser::DoAttribut()
pSNode
->
SetSubNodes
(
pAttr
,
0
);
pSNode
->
SetScaleMode
(
eScaleMode
);
m_aNodeStack
.
push_front
(
pSNode
);
m_aNodeStack
.
push_front
(
std
::
move
(
pSNode
)
);
}
...
...
@@ -1811,7 +1822,7 @@ void SmParser::DoFontAttribut()
case
TBOLD
:
case
TNBOLD
:
case
TPHANTOM
:
m_aNodeStack
.
push_front
(
new
SmFontNode
(
m_aCurToken
));
m_aNodeStack
.
push_front
(
o3tl
::
make_unique
<
SmFontNode
>
(
m_aCurToken
));
NextToken
();
break
;
...
...
@@ -1849,7 +1860,7 @@ void SmParser::DoColor()
Error
(
PE_COLOR_EXPECTED
);
}
while
(
m_aCurToken
.
eType
==
TCOLOR
);
m_aNodeStack
.
push_front
(
new
SmFontNode
(
aToken
));
m_aNodeStack
.
push_front
(
o3tl
::
make_unique
<
SmFontNode
>
(
aToken
));
}
void
SmParser
::
DoFont
()
...
...
@@ -1869,7 +1880,7 @@ void SmParser::DoFont()
Error
(
PE_FONT_EXPECTED
);
}
while
(
m_aCurToken
.
eType
==
TFONT
);
m_aNodeStack
.
push_front
(
new
SmFontNode
(
aToken
));
m_aNodeStack
.
push_front
(
o3tl
::
make_unique
<
SmFontNode
>
(
aToken
));
}
...
...
@@ -1900,7 +1911,7 @@ void SmParser::DoFontSize()
OSL_ENSURE
(
m_aCurToken
.
eType
==
TSIZE
,
"Sm : Ooops..."
);
FontSizeType
Type
;
SmFontNode
*
pFontNode
=
new
SmFontNode
(
m_aCurToken
);
std
::
unique_ptr
<
SmFontNode
>
pFontNode
(
new
SmFontNode
(
m_aCurToken
)
);
NextToken
();
...
...
@@ -1913,7 +1924,6 @@ void SmParser::DoFontSize()
case
TDIVIDEBY
:
Type
=
FontSizeType
::
DIVIDE
;
break
;
default
:
delete
pFontNode
;
Error
(
PE_SIZE_EXPECTED
);
return
;
}
...
...
@@ -1923,7 +1933,6 @@ void SmParser::DoFontSize()
NextToken
();
if
(
m_aCurToken
.
eType
!=
TNUMBER
)
{
delete
pFontNode
;
Error
(
PE_SIZE_EXPECTED
);
return
;
}
...
...
@@ -1960,7 +1969,7 @@ void SmParser::DoFontSize()
NextToken
();
pFontNode
->
SetSizeParameter
(
aValue
,
Type
);
m_aNodeStack
.
push_front
(
pFontNode
);
m_aNodeStack
.
push_front
(
std
::
move
(
pFontNode
)
);
}
void
SmParser
::
DoBrace
()
...
...
@@ -1968,7 +1977,7 @@ void SmParser::DoBrace()
OSL_ENSURE
(
m_aCurToken
.
eType
==
TLEFT
||
TokenInGroup
(
TGLBRACES
),
"Sm: kein Klammer Ausdruck"
);
SmStructureNode
*
pSNode
=
new
SmBraceNode
(
m_aCurToken
);
std
::
unique_ptr
<
SmStructureNode
>
pSNode
(
new
SmBraceNode
(
m_aCurToken
)
);
SmNode
*
pBody
=
0
,
*
pLeft
=
0
,
*
pRight
=
0
;
...
...
@@ -2049,10 +2058,11 @@ void SmParser::DoBrace()
OSL_ENSURE
(
pRight
,
"Sm: NULL pointer"
);
pSNode
->
SetSubNodes
(
pLeft
,
pBody
,
pRight
);
pSNode
->
SetScaleMode
(
eScaleMode
);
m_aNodeStack
.
push_front
(
pSNode
);
m_aNodeStack
.
push_front
(
std
::
move
(
pSNode
)
);
}
else
{
delete
pSNode
;
{
pSNode
.
reset
();
delete
pBody
;
delete
pLeft
;
delete
pRight
;
...
...
@@ -2063,7 +2073,7 @@ void SmParser::DoBrace()
void
SmParser
::
DoBracebody
(
bool
bIsLeftRight
)
{
SmStructureNode
*
pBody
=
new
SmBracebodyNode
(
m_aCurToken
);
std
::
unique_ptr
<
SmStructureNode
>
pBody
(
new
SmBracebodyNode
(
m_aCurToken
)
);
SmNodeArray
aNodes
;
sal_uInt16
nNum
=
0
;
...
...
@@ -2074,7 +2084,7 @@ void SmParser::DoBracebody(bool bIsLeftRight)
{
if
(
m_aCurToken
.
eType
==
TMLINE
)
{
m_aNodeStack
.
push_front
(
new
SmMathSymbolNode
(
m_aCurToken
));
m_aNodeStack
.
push_front
(
o3tl
::
make_unique
<
SmMathSymbolNode
>
(
m_aCurToken
));
NextToken
();
nNum
++
;
}
...
...
@@ -2094,7 +2104,7 @@ void SmParser::DoBracebody(bool bIsLeftRight)
{
if
(
m_aCurToken
.
eType
==
TMLINE
)
{
m_aNodeStack
.
push_front
(
new
SmMathSymbolNode
(
m_aCurToken
));
m_aNodeStack
.
push_front
(
o3tl
::
make_unique
<
SmMathSymbolNode
>
(
m_aCurToken
));
NextToken
();
nNum
++
;
}
...
...
@@ -2118,7 +2128,7 @@ void SmParser::DoBracebody(bool bIsLeftRight)
pBody
->
SetSubNodes
(
aNodes
);
pBody
->
SetScaleMode
(
bIsLeftRight
?
SCALE_HEIGHT
:
SCALE_NONE
);
m_aNodeStack
.
push_front
(
pBody
);
m_aNodeStack
.
push_front
(
std
::
move
(
pBody
)
);
}
void
SmParser
::
DoFunction
()
...
...
@@ -2148,7 +2158,7 @@ void SmParser::DoFunction()
case
TLN
:
case
TLOG
:
case
TEXP
:
m_aNodeStack
.
push_front
(
new
SmTextNode
(
m_aCurToken
,
FNT_FUNCTION
));
m_aNodeStack
.
push_front
(
o3tl
::
make_unique
<
SmTextNode
>
(
m_aCurToken
,
FNT_FUNCTION
));
NextToken
();
break
;
...
...
@@ -2160,7 +2170,7 @@ void SmParser::DoFunction()
void
SmParser
::
DoBinom
()
{
SmNodeArray
ExpressionArray
;
SmStructureNode
*
pSNode
=
new
SmTableNode
(
m_aCurToken
);
std
::
unique_ptr
<
SmStructureNode
>
pSNode
(
new
SmTableNode
(
m_aCurToken
)
);
NextToken
();
...
...
@@ -2175,7 +2185,7 @@ void SmParser::DoBinom()
}
pSNode
->
SetSubNodes
(
ExpressionArray
);
m_aNodeStack
.
push_front
(
pSNode
);
m_aNodeStack
.
push_front
(
std
::
move
(
pSNode
)
);
}
void
SmParser
::
DoStack
()
...
...
@@ -2210,9 +2220,9 @@ void SmParser::DoStack()
//it's used in SmNodeToTextVisitor
SmToken
aTok
=
m_aCurToken
;
aTok
.
eType
=
TSTACK
;
SmStructureNode
*
pSNode
=
new
SmTableNode
(
aTok
);
std
::
unique_ptr
<
SmStructureNode
>
pSNode
(
new
SmTableNode
(
aTok
)
);
pSNode
->
SetSubNodes
(
ExpressionArray
);
m_aNodeStack
.
push_front
(
pSNode
);
m_aNodeStack
.
push_front
(
std
::
move
(
pSNode
)
);
}
else
Error
(
PE_LGROUP_EXPECTED
);
...
...
@@ -2271,10 +2281,10 @@ void SmParser::DoMatrix()
NextToken
();
SmMatrixNode
*
pMNode
=
new
SmMatrixNode
(
m_aCurToken
);
std
::
unique_ptr
<
SmMatrixNode
>
pMNode
(
new
SmMatrixNode
(
m_aCurToken
)
);
pMNode
->
SetSubNodes
(
ExpressionArray
);
pMNode
->
SetRowCol
(
r
,
c
);
m_aNodeStack
.
push_front
(
pMNode
);
m_aNodeStack
.
push_front
(
std
::
move
(
pMNode
)
);
}
else
Error
(
PE_LGROUP_EXPECTED
);
...
...
@@ -2317,13 +2327,13 @@ void SmParser::DoSpecial()
if
(
!
aSymbolName
.
isEmpty
())
AddToUsedSymbols
(
aSymbolName
);
m_aNodeStack
.
push_front
(
new
SmSpecialNode
(
m_aCurToken
));
m_aNodeStack
.
push_front
(
o3tl
::
make_unique
<
SmSpecialNode
>
(
m_aCurToken
));
NextToken
();
}
void
SmParser
::
DoGlyphSpecial
()
{
m_aNodeStack
.
push_front
(
new
SmGlyphSpecialNode
(
m_aCurToken
));
m_aNodeStack
.
push_front
(
o3tl
::
make_unique
<
SmGlyphSpecialNode
>
(
m_aCurToken
));
NextToken
();
}
...
...
@@ -2336,7 +2346,7 @@ void SmParser::Error(SmParseError eError)
//! put a structure node on the stack (instead of the error node itself)
//! because sometimes such a node is expected in order to attach some
//! subnodes
m_aNodeStack
.
push_front
(
pSNode
);
m_aNodeStack
.
push_front
(
std
::
unique_ptr
<
SmStructureNode
>
(
pSNode
)
);
AddError
(
eError
,
pSNode
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment