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
12d44973
Kaydet (Commit)
12d44973
authored
Eyl 12, 2013
tarafından
Noel Grandin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
convert aCorrectedSymbol in formula::FormulaCompiler from String to OUString
Change-Id: I426b305fb8befffe0452e280d2097b6560843eef
üst
e42e0efe
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
33 deletions
+36
-33
FormulaCompiler.cxx
formula/source/core/api/FormulaCompiler.cxx
+18
-11
FormulaCompiler.hxx
include/formula/FormulaCompiler.hxx
+3
-1
compiler.cxx
sc/source/core/tool/compiler.cxx
+15
-21
No files found.
formula/source/core/api/FormulaCompiler.cxx
Dosyayı görüntüle @
12d44973
...
@@ -978,7 +978,7 @@ bool FormulaCompiler::GetToken()
...
@@ -978,7 +978,7 @@ bool FormulaCompiler::GetToken()
if
(
bAutoCorrect
&&
!
pStack
)
if
(
bAutoCorrect
&&
!
pStack
)
{
// don't merge stacked subroutine code into entered formula
{
// don't merge stacked subroutine code into entered formula
aCorrectedFormula
+=
aCorrectedSymbol
;
aCorrectedFormula
+=
aCorrectedSymbol
;
aCorrectedSymbol
.
Erase
()
;
aCorrectedSymbol
=
""
;
}
}
bool
bStop
=
false
;
bool
bStop
=
false
;
if
(
pArr
->
GetCodeError
()
&&
!
bIgnoreErrors
)
if
(
pArr
->
GetCodeError
()
&&
!
bIgnoreErrors
)
...
@@ -1361,7 +1361,7 @@ void FormulaCompiler::Factor()
...
@@ -1361,7 +1361,7 @@ void FormulaCompiler::Factor()
SetError
(
errParameterExpected
);
SetError
(
errParameterExpected
);
if
(
bAutoCorrect
&&
!
pStack
)
if
(
bAutoCorrect
&&
!
pStack
)
{
{
aCorrectedSymbol
.
Erase
()
;
aCorrectedSymbol
=
""
;
bCorrected
=
true
;
bCorrected
=
true
;
}
}
}
}
...
@@ -1380,7 +1380,7 @@ void FormulaCompiler::Factor()
...
@@ -1380,7 +1380,7 @@ void FormulaCompiler::Factor()
xub_StrLen
nLen
=
aCorrectedFormula
.
Len
();
xub_StrLen
nLen
=
aCorrectedFormula
.
Len
();
if
(
nLen
)
if
(
nLen
)
aCorrectedFormula
.
Erase
(
nLen
-
1
);
aCorrectedFormula
.
Erase
(
nLen
-
1
);
aCorrectedSymbol
.
Erase
()
;
aCorrectedSymbol
=
""
;
bCorrected
=
true
;
bCorrected
=
true
;
}
}
}
}
...
@@ -1588,7 +1588,7 @@ bool FormulaCompiler::CompileTokenArray()
...
@@ -1588,7 +1588,7 @@ bool FormulaCompiler::CompileTokenArray()
if
(
bAutoCorrect
)
if
(
bAutoCorrect
)
{
{
aCorrectedFormula
.
Erase
();
aCorrectedFormula
.
Erase
();
aCorrectedSymbol
.
Erase
()
;
aCorrectedSymbol
=
""
;
}
}
pArr
->
nRefs
=
0
;
// count from start
pArr
->
nRefs
=
0
;
// count from start
pArr
->
DelRPN
();
pArr
->
DelRPN
();
...
@@ -1707,6 +1707,13 @@ FormulaToken* FormulaCompiler::CreateStringFromToken( String& rFormula, FormulaT
...
@@ -1707,6 +1707,13 @@ FormulaToken* FormulaCompiler::CreateStringFromToken( String& rFormula, FormulaT
rFormula
+=
aBuffer
.
makeStringAndClear
();
rFormula
+=
aBuffer
.
makeStringAndClear
();
return
p
;
return
p
;
}
}
FormulaToken
*
FormulaCompiler
::
CreateStringFromToken
(
OUString
&
rFormula
,
FormulaToken
*
pTokenP
,
bool
bAllowArrAdvance
)
{
OUStringBuffer
aBuffer
;
FormulaToken
*
p
=
CreateStringFromToken
(
aBuffer
,
pTokenP
,
bAllowArrAdvance
);
rFormula
+=
aBuffer
.
makeStringAndClear
();
return
p
;
}
FormulaToken
*
FormulaCompiler
::
CreateStringFromToken
(
OUStringBuffer
&
rBuffer
,
FormulaToken
*
pTokenP
,
bool
bAllowArrAdvance
)
FormulaToken
*
FormulaCompiler
::
CreateStringFromToken
(
OUStringBuffer
&
rBuffer
,
FormulaToken
*
pTokenP
,
bool
bAllowArrAdvance
)
{
{
...
@@ -1930,7 +1937,7 @@ OpCode FormulaCompiler::NextToken()
...
@@ -1930,7 +1937,7 @@ OpCode FormulaCompiler::NextToken()
{
{
if
(
eOp
==
eLastOp
||
eLastOp
==
ocOpen
)
if
(
eOp
==
eLastOp
||
eLastOp
==
ocOpen
)
{
// throw away duplicated operator
{
// throw away duplicated operator
aCorrectedSymbol
.
Erase
()
;
aCorrectedSymbol
=
""
;
bCorrected
=
true
;
bCorrected
=
true
;
}
}
else
else
...
@@ -1947,7 +1954,7 @@ OpCode FormulaCompiler::NextToken()
...
@@ -1947,7 +1954,7 @@ OpCode FormulaCompiler::NextToken()
{
// >= instead of =>
{
// >= instead of =>
aCorrectedFormula
.
SetChar
(
nPos
,
aCorrectedFormula
.
SetChar
(
nPos
,
mxSymbols
->
getSymbol
(
ocGreater
).
GetChar
(
0
)
);
mxSymbols
->
getSymbol
(
ocGreater
).
GetChar
(
0
)
);
aCorrectedSymbol
=
c
;
aCorrectedSymbol
=
OUString
(
c
)
;
bCorrected
=
true
;
bCorrected
=
true
;
}
}
break
;
break
;
...
@@ -1956,14 +1963,14 @@ OpCode FormulaCompiler::NextToken()
...
@@ -1956,14 +1963,14 @@ OpCode FormulaCompiler::NextToken()
{
// <= instead of =<
{
// <= instead of =<
aCorrectedFormula
.
SetChar
(
nPos
,
aCorrectedFormula
.
SetChar
(
nPos
,
mxSymbols
->
getSymbol
(
ocLess
).
GetChar
(
0
)
);
mxSymbols
->
getSymbol
(
ocLess
).
GetChar
(
0
)
);
aCorrectedSymbol
=
c
;
aCorrectedSymbol
=
OUString
(
c
)
;
bCorrected
=
true
;
bCorrected
=
true
;
}
}
else
if
(
c
==
mxSymbols
->
getSymbol
(
ocGreater
).
GetChar
(
0
)
)
else
if
(
c
==
mxSymbols
->
getSymbol
(
ocGreater
).
GetChar
(
0
)
)
{
// <> instead of ><
{
// <> instead of ><
aCorrectedFormula
.
SetChar
(
nPos
,
aCorrectedFormula
.
SetChar
(
nPos
,
mxSymbols
->
getSymbol
(
ocLess
).
GetChar
(
0
)
);
mxSymbols
->
getSymbol
(
ocLess
).
GetChar
(
0
)
);
aCorrectedSymbol
=
c
;
aCorrectedSymbol
=
OUString
(
c
)
;
bCorrected
=
true
;
bCorrected
=
true
;
}
}
break
;
break
;
...
@@ -1972,7 +1979,7 @@ OpCode FormulaCompiler::NextToken()
...
@@ -1972,7 +1979,7 @@ OpCode FormulaCompiler::NextToken()
{
// *- instead of -*
{
// *- instead of -*
aCorrectedFormula
.
SetChar
(
nPos
,
aCorrectedFormula
.
SetChar
(
nPos
,
mxSymbols
->
getSymbol
(
ocMul
).
GetChar
(
0
)
);
mxSymbols
->
getSymbol
(
ocMul
).
GetChar
(
0
)
);
aCorrectedSymbol
=
c
;
aCorrectedSymbol
=
OUString
(
c
)
;
bCorrected
=
true
;
bCorrected
=
true
;
}
}
break
;
break
;
...
@@ -1981,7 +1988,7 @@ OpCode FormulaCompiler::NextToken()
...
@@ -1981,7 +1988,7 @@ OpCode FormulaCompiler::NextToken()
{
// /- instead of -/
{
// /- instead of -/
aCorrectedFormula
.
SetChar
(
nPos
,
aCorrectedFormula
.
SetChar
(
nPos
,
mxSymbols
->
getSymbol
(
ocDiv
).
GetChar
(
0
)
);
mxSymbols
->
getSymbol
(
ocDiv
).
GetChar
(
0
)
);
aCorrectedSymbol
=
c
;
aCorrectedSymbol
=
OUString
(
c
)
;
bCorrected
=
true
;
bCorrected
=
true
;
}
}
break
;
break
;
...
@@ -2067,7 +2074,7 @@ void FormulaCompiler::PushTokenArray( FormulaTokenArray* pa, bool bTemp )
...
@@ -2067,7 +2074,7 @@ void FormulaCompiler::PushTokenArray( FormulaTokenArray* pa, bool bTemp )
if
(
bAutoCorrect
&&
!
pStack
)
if
(
bAutoCorrect
&&
!
pStack
)
{
// don't merge stacked subroutine code into entered formula
{
// don't merge stacked subroutine code into entered formula
aCorrectedFormula
+=
aCorrectedSymbol
;
aCorrectedFormula
+=
aCorrectedSymbol
;
aCorrectedSymbol
.
Erase
()
;
aCorrectedSymbol
=
""
;
}
}
FormulaArrayStack
*
p
=
new
FormulaArrayStack
;
FormulaArrayStack
*
p
=
new
FormulaArrayStack
;
p
->
pNext
=
pStack
;
p
->
pNext
=
pStack
;
...
...
include/formula/FormulaCompiler.hxx
Dosyayı görüntüle @
12d44973
...
@@ -245,6 +245,8 @@ public:
...
@@ -245,6 +245,8 @@ public:
void
CreateStringFromTokenArray
(
String
&
rFormula
);
void
CreateStringFromTokenArray
(
String
&
rFormula
);
void
CreateStringFromTokenArray
(
OUStringBuffer
&
rBuffer
);
void
CreateStringFromTokenArray
(
OUStringBuffer
&
rBuffer
);
FormulaToken
*
CreateStringFromToken
(
OUString
&
rFormula
,
FormulaToken
*
pToken
,
bool
bAllowArrAdvance
=
false
);
FormulaToken
*
CreateStringFromToken
(
String
&
rFormula
,
FormulaToken
*
pToken
,
FormulaToken
*
CreateStringFromToken
(
String
&
rFormula
,
FormulaToken
*
pToken
,
bool
bAllowArrAdvance
=
false
);
bool
bAllowArrAdvance
=
false
);
FormulaToken
*
CreateStringFromToken
(
OUStringBuffer
&
rBuffer
,
FormulaToken
*
pToken
,
FormulaToken
*
CreateStringFromToken
(
OUStringBuffer
&
rBuffer
,
FormulaToken
*
pToken
,
...
@@ -306,7 +308,7 @@ protected:
...
@@ -306,7 +308,7 @@ protected:
bool
MergeRangeReference
(
FormulaToken
*
*
const
pCode1
,
FormulaToken
*
const
*
const
pCode2
);
bool
MergeRangeReference
(
FormulaToken
*
*
const
pCode1
,
FormulaToken
*
const
*
const
pCode2
);
String
aCorrectedFormula
;
// autocorrected Formula
String
aCorrectedFormula
;
// autocorrected Formula
String
aCorrectedSymbol
;
// autocorrected Symbol
OUString
aCorrectedSymbol
;
// autocorrected Symbol
OpCodeMapPtr
mxSymbols
;
// which symbols are used
OpCodeMapPtr
mxSymbols
;
// which symbols are used
...
...
sc/source/core/tool/compiler.cxx
Dosyayı görüntüle @
12d44973
...
@@ -3232,33 +3232,33 @@ bool ScCompiler::IsErrorConstant( const String& rName ) const
...
@@ -3232,33 +3232,33 @@ bool ScCompiler::IsErrorConstant( const String& rName ) const
void
ScCompiler
::
AutoCorrectParsedSymbol
()
void
ScCompiler
::
AutoCorrectParsedSymbol
()
{
{
xub_StrLen
nPos
=
aCorrectedSymbol
.
Len
();
sal_Int32
nPos
=
aCorrectedSymbol
.
getLength
();
if
(
nPos
)
if
(
nPos
)
{
{
nPos
--
;
nPos
--
;
const
sal_Unicode
cQuote
=
'\"'
;
const
sal_Unicode
cQuote
=
'\"'
;
const
sal_Unicode
cx
=
'x'
;
const
sal_Unicode
cx
=
'x'
;
const
sal_Unicode
cX
=
'X'
;
const
sal_Unicode
cX
=
'X'
;
sal_Unicode
c1
=
aCorrectedSymbol
.
GetChar
(
0
)
;
sal_Unicode
c1
=
aCorrectedSymbol
[
0
]
;
sal_Unicode
c2
=
aCorrectedSymbol
.
GetChar
(
nPos
)
;
sal_Unicode
c2
=
aCorrectedSymbol
[
nPos
]
;
sal_Unicode
c2p
=
nPos
>
0
?
aCorrectedSymbol
.
GetChar
(
nPos
-
1
)
:
0
;
sal_Unicode
c2p
=
nPos
>
0
?
aCorrectedSymbol
[
nPos
-
1
]
:
0
;
if
(
c1
==
cQuote
&&
c2
!=
cQuote
)
if
(
c1
==
cQuote
&&
c2
!=
cQuote
)
{
// "...
{
// "...
// What's not a word doesn't belong to it.
// What's not a word doesn't belong to it.
// Don't be pedantic: c < 128 should be sufficient here.
// Don't be pedantic: c < 128 should be sufficient here.
while
(
nPos
&&
((
aCorrectedSymbol
.
GetChar
(
nPos
)
<
128
)
&&
while
(
nPos
&&
((
aCorrectedSymbol
[
nPos
]
<
128
)
&&
((
GetCharTableFlags
(
aCorrectedSymbol
.
GetChar
(
nPos
),
aCorrectedSymbol
.
GetChar
(
nPos
-
1
)
)
&
((
GetCharTableFlags
(
aCorrectedSymbol
[
nPos
],
aCorrectedSymbol
[
nPos
-
1
]
)
&
(
SC_COMPILER_C_WORD
|
SC_COMPILER_C_CHAR_DONTCARE
))
==
0
))
)
(
SC_COMPILER_C_WORD
|
SC_COMPILER_C_CHAR_DONTCARE
))
==
0
))
)
nPos
--
;
nPos
--
;
if
(
nPos
==
MAXSTRLEN
-
2
)
if
(
nPos
==
MAXSTRLEN
-
2
)
aCorrectedSymbol
.
SetChar
(
nPos
,
cQuote
);
// '"' the 255th character
aCorrectedSymbol
=
aCorrectedSymbol
.
replaceAt
(
nPos
,
1
,
OUString
(
cQuote
)
);
// '"' the 255th character
else
else
aCorrectedSymbol
.
Insert
(
cQuote
,
nPos
+
1
);
aCorrectedSymbol
=
aCorrectedSymbol
.
replaceAt
(
nPos
+
1
,
0
,
OUString
(
cQuote
)
);
bCorrected
=
true
;
bCorrected
=
true
;
}
}
else
if
(
c1
!=
cQuote
&&
c2
==
cQuote
)
else
if
(
c1
!=
cQuote
&&
c2
==
cQuote
)
{
// ..."
{
// ..."
aCorrectedSymbol
.
Insert
(
cQuote
,
0
)
;
aCorrectedSymbol
=
OUString
(
cQuote
)
+
aCorrectedSymbol
;
bCorrected
=
true
;
bCorrected
=
true
;
}
}
else
if
(
nPos
==
0
&&
(
c1
==
cx
||
c1
==
cX
)
)
else
if
(
nPos
==
0
&&
(
c1
==
cx
||
c1
==
cX
)
)
...
@@ -3272,20 +3272,14 @@ void ScCompiler::AutoCorrectParsedSymbol()
...
@@ -3272,20 +3272,14 @@ void ScCompiler::AutoCorrectParsedSymbol()
xub_StrLen
nXcount
;
xub_StrLen
nXcount
;
if
(
(
nXcount
=
comphelper
::
string
::
getTokenCount
(
aCorrectedSymbol
,
cx
))
>
1
)
if
(
(
nXcount
=
comphelper
::
string
::
getTokenCount
(
aCorrectedSymbol
,
cx
))
>
1
)
{
// x => *
{
// x => *
xub_StrLen
nIndex
=
0
;
sal_Unicode
c
=
mxSymbols
->
getSymbol
(
ocMul
).
GetChar
(
0
);
sal_Unicode
c
=
mxSymbols
->
getSymbol
(
ocMul
).
GetChar
(
0
);
while
(
(
nIndex
=
aCorrectedSymbol
.
SearchAndReplace
(
aCorrectedSymbol
=
aCorrectedSymbol
.
replaceAll
(
OUString
(
cx
),
OUString
(
c
));
cx
,
c
,
nIndex
))
!=
STRING_NOTFOUND
)
nIndex
++
;
bCorrected
=
true
;
bCorrected
=
true
;
}
}
if
(
(
nXcount
=
comphelper
::
string
::
getTokenCount
(
aCorrectedSymbol
,
cX
))
>
1
)
if
(
(
nXcount
=
comphelper
::
string
::
getTokenCount
(
aCorrectedSymbol
,
cX
))
>
1
)
{
// X => *
{
// X => *
xub_StrLen
nIndex
=
0
;
sal_Unicode
c
=
mxSymbols
->
getSymbol
(
ocMul
).
GetChar
(
0
);
sal_Unicode
c
=
mxSymbols
->
getSymbol
(
ocMul
).
GetChar
(
0
);
while
(
(
nIndex
=
aCorrectedSymbol
.
SearchAndReplace
(
aCorrectedSymbol
=
aCorrectedSymbol
.
replaceAll
(
OUString
(
cX
),
OUString
(
c
));
cX
,
c
,
nIndex
))
!=
STRING_NOTFOUND
)
nIndex
++
;
bCorrected
=
true
;
bCorrected
=
true
;
}
}
}
}
...
@@ -3412,7 +3406,7 @@ void ScCompiler::AutoCorrectParsedSymbol()
...
@@ -3412,7 +3406,7 @@ void ScCompiler::AutoCorrectParsedSymbol()
aCorrectedSymbol
+=
aRef
[
0
];
aCorrectedSymbol
+=
aRef
[
0
];
if
(
nRefs
==
2
)
if
(
nRefs
==
2
)
{
{
aCorrectedSymbol
+=
':'
;
aCorrectedSymbol
+=
":"
;
aCorrectedSymbol
+=
aTab
[
1
];
aCorrectedSymbol
+=
aTab
[
1
];
aCorrectedSymbol
+=
aRef
[
1
];
aCorrectedSymbol
+=
aRef
[
1
];
}
}
...
@@ -3671,7 +3665,7 @@ ScTokenArray* ScCompiler::CompileString( const OUString& rFormula )
...
@@ -3671,7 +3665,7 @@ ScTokenArray* ScCompiler::CompileString( const OUString& rFormula )
if
(
bAutoCorrect
)
if
(
bAutoCorrect
)
{
{
aCorrectedFormula
.
Erase
();
aCorrectedFormula
.
Erase
();
aCorrectedSymbol
.
Erase
()
;
aCorrectedSymbol
=
""
;
}
}
sal_uInt8
nForced
=
0
;
// ==formula forces recalc even if cell is not visible
sal_uInt8
nForced
=
0
;
// ==formula forces recalc even if cell is not visible
if
(
aFormula
.
GetChar
(
nSrcPos
)
==
'='
)
if
(
aFormula
.
GetChar
(
nSrcPos
)
==
'='
)
...
@@ -3732,7 +3726,7 @@ ScTokenArray* ScCompiler::CompileString( const OUString& rFormula )
...
@@ -3732,7 +3726,7 @@ ScTokenArray* ScCompiler::CompileString( const OUString& rFormula )
if
(
bAutoCorrect
)
if
(
bAutoCorrect
)
{
{
bCorrected
=
true
;
bCorrected
=
true
;
aCorrectedSymbol
.
Erase
()
;
aCorrectedSymbol
=
""
;
}
}
}
}
else
else
...
@@ -3774,7 +3768,7 @@ ScTokenArray* ScCompiler::CompileString( const OUString& rFormula )
...
@@ -3774,7 +3768,7 @@ ScTokenArray* ScCompiler::CompileString( const OUString& rFormula )
if
(
bAutoCorrect
)
if
(
bAutoCorrect
)
{
{
bCorrected
=
true
;
bCorrected
=
true
;
aCorrectedSymbol
.
Erase
()
;
aCorrectedSymbol
=
""
;
}
}
}
}
if
(
bPODF
&&
nFunction
)
if
(
bPODF
&&
nFunction
)
...
...
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