summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Mencken <dougmencken@gmail.com>2016-01-25 07:28:48 -0500
committerMichael Stahl <mstahl@redhat.com>2016-01-27 15:44:33 +0000
commit9a3d702c3d3546ea651d46a6d698cbc6df0e9b31 (patch)
treeb0f739da8bda3837b7eda7d6c20913de4f9c9e61
parent4cac0c05c645fbcc67cf6090144026a2dfd02064 (diff)
starmath.mathtype: change int -> bool for returned values
it looks like it always supposed to be bool Change-Id: Ie18dfdf9c91bb66828889d0370ceeb946cc9289d Reviewed-on: https://gerrit.libreoffice.org/21764 Reviewed-by: Michael Stahl <mstahl@redhat.com> Tested-by: Michael Stahl <mstahl@redhat.com>
-rw-r--r--starmath/source/document.cxx9
-rw-r--r--starmath/source/mathtype.cxx83
-rw-r--r--starmath/source/mathtype.hxx28
-rw-r--r--starmath/source/unofilter.cxx2
4 files changed, 57 insertions, 65 deletions
diff --git a/starmath/source/document.cxx b/starmath/source/document.cxx
index cafe784e9999..0ff39dc7f8dd 100644
--- a/starmath/source/document.cxx
+++ b/starmath/source/document.cxx
@@ -698,7 +698,7 @@ bool SmDocShell::ConvertFrom(SfxMedium &rMedium)
}
Reference<css::frame::XModel> xModel(GetModel());
SmXMLImportWrapper aEquation(xModel);
- bSuccess = 0 == aEquation.Import(rMedium);
+ bSuccess = ( ERRCODE_NONE == aEquation.Import(rMedium) );
}
else
{
@@ -712,7 +712,8 @@ bool SmDocShell::ConvertFrom(SfxMedium &rMedium)
{
// is this a MathType Storage?
MathType aEquation( aText );
- if ( (bSuccess = (1 == aEquation.Parse( aStorage )) ))
+ bSuccess = aEquation.Parse( aStorage );
+ if ( bSuccess )
Parse();
}
}
@@ -1338,9 +1339,7 @@ void SmDocShell::SetModified(bool bModified)
bool SmDocShell::WriteAsMathType3( SfxMedium& rMedium )
{
MathType aEquation( aText, pTree );
-
- bool bRet = 0 != aEquation.ConvertFromStarMath( rMedium );
- return bRet;
+ return aEquation.ConvertFromStarMath( rMedium );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/source/mathtype.cxx b/starmath/source/mathtype.cxx
index 962de9d19b67..94afcd582424 100644
--- a/starmath/source/mathtype.cxx
+++ b/starmath/source/mathtype.cxx
@@ -553,13 +553,13 @@ void MathType::TypeFaceToString(OUString &rTxt,sal_uInt8 nFace)
aFont.AppendStyleToText(rTxt);
}
-int MathType::Parse(SotStorage *pStor)
+bool MathType::Parse(SotStorage *pStor)
{
tools::SvRef<SotStorageStream> xSrc = pStor->OpenSotStream(
"Equation Native",
STREAM_STD_READ | StreamMode::NOCREATE);
if ( (!xSrc.Is()) || (SVSTREAM_OK != xSrc->GetError()))
- return 0;
+ return false;
pS = &xSrc;
pS->SetEndian( SvStreamEndian::LITTLE );
@@ -572,9 +572,9 @@ int MathType::Parse(SotStorage *pStor)
pS->ReadUChar( nProdSubVersion );
if (nVersion > 3) // allow only supported versions of MathType to be parsed
- return 0;
+ return false;
- int nRet = HandleRecords();
+ bool bRet = HandleRecords();
//little crude hack to close occasionally open expressions
//a sophisticated system to determine what expressions are
//opened is required, but this is as much work as rewriting
@@ -592,7 +592,7 @@ int MathType::Parse(SotStorage *pStor)
"Possibly unfully parsed formula");
# endif
#endif
- return nRet;
+ return bRet;
}
static void lcl_PrependDummyTerm(OUString &rRet, sal_Int32 &rTextStart)
@@ -638,15 +638,16 @@ void MathType::HandleNudge()
pS->ReadUInt16( nYLongNudge );
}
}
+
/* Fabulously complicated as many tokens have to be reordered and generally
* moved around from mathtypes paradigm to starmaths. */
-int MathType::HandleRecords(int nLevel,sal_uInt8 nSelector,
- sal_uInt8 nVariation, int nMatrixRows,int nMatrixCols)
+bool MathType::HandleRecords(int nLevel, sal_uInt8 nSelector,
+ sal_uInt8 nVariation, int nMatrixRows, int nMatrixCols)
{
sal_uInt8 nTag,nRecord;
sal_uInt8 nTabType,nTabStops;
sal_uInt16 nTabOffset;
- int i,nRet=1,newline=0;
+ int i, newline=0;
bool bSilent=false;
int nPart=0;
OUString sPush,sMainTerm;
@@ -656,6 +657,7 @@ int MathType::HandleRecords(int nLevel,sal_uInt8 nSelector,
sal_Int32 nTextStart = 0;
sal_Int32 nSubSupStartPos = 0;
sal_Int32 nLastTemplateBracket=-1;
+ bool bRet = true;
do
{
@@ -1246,8 +1248,8 @@ int MathType::HandleRecords(int nLevel,sal_uInt8 nSelector,
}
sal_Int16 nOldCurSize=nCurSize;
sal_Int32 nSizeStartPos = rRet.getLength();
- HandleSize(nLSize,nDSize,nSetSize);
- nRet = HandleRecords(nLevel+1);
+ HandleSize( nLSize, nDSize, nSetSize );
+ bRet = HandleRecords( nLevel+1 );
while (nSetSize)
{
bool bOk=false;
@@ -1683,26 +1685,24 @@ int MathType::HandleRecords(int nLevel,sal_uInt8 nSelector,
case CHAR:
if (xfLMOVE(nTag))
HandleNudge();
- nRet = HandleChar(nTextStart,nSetSize,nLevel,nTag,nSelector,
- nVariation,bSilent);
- break;
+ bRet = HandleChar( nTextStart, nSetSize, nLevel, nTag, nSelector, nVariation, bSilent );
+ break;
case TMPL:
if (xfLMOVE(nTag))
HandleNudge();
- nRet = HandleTemplate(nLevel,nSelector,nVariation,
- nLastTemplateBracket);
+ bRet = HandleTemplate( nLevel, nSelector, nVariation, nLastTemplateBracket );
break;
case PILE:
if (xfLMOVE(nTag))
HandleNudge();
- nRet = HandlePile(nSetAlign,nLevel,nSelector,nVariation);
- HandleMatrixSeparator(nMatrixRows,nMatrixCols,nCurCol,nCurRow);
+ bRet = HandlePile( nSetAlign, nLevel, nSelector, nVariation );
+ HandleMatrixSeparator( nMatrixRows, nMatrixCols, nCurCol, nCurRow );
break;
case MATRIX:
if (xfLMOVE(nTag))
HandleNudge();
- nRet = HandleMatrix(nLevel,nSelector,nVariation);
- HandleMatrixSeparator(nMatrixRows,nMatrixCols,nCurCol,nCurRow);
+ bRet = HandleMatrix( nLevel, nSelector, nVariation );
+ HandleMatrixSeparator( nMatrixRows, nMatrixCols, nCurCol, nCurRow );
break;
case EMBEL:
if (xfLMOVE(nTag))
@@ -1763,7 +1763,7 @@ int MathType::HandleRecords(int nLevel,sal_uInt8 nSelector,
rRet += "}";
nSetSize--;
}
- return nRet;
+ return bRet;
}
/*Simply determine if we are at the end of a record or the end of a line,
@@ -1878,10 +1878,10 @@ bool MathType::HandleSize(sal_Int16 nLstSize,sal_Int16 nDefSize, int &rSetSize)
return bRet;
}
-int MathType::ConvertFromStarMath( SfxMedium& rMedium )
+bool MathType::ConvertFromStarMath( SfxMedium& rMedium )
{
if (!pTree)
- return 0;
+ return false;
SvStream *pStream = rMedium.GetOutStream();
if ( pStream )
@@ -1921,7 +1921,7 @@ int MathType::ConvertFromStarMath( SfxMedium& rMedium )
tools::SvRef<SotStorageStream> xSrc = pStor->OpenSotStream("Equation Native");
if ( (!xSrc.Is()) || (SVSTREAM_OK != xSrc->GetError()))
- return 0;
+ return false;
pS = &xSrc;
pS->SetEndian( SvStreamEndian::LITTLE );
@@ -1946,7 +1946,7 @@ int MathType::ConvertFromStarMath( SfxMedium& rMedium )
pStor->Commit();
}
- return 1;
+ return true;
}
@@ -2158,7 +2158,6 @@ void MathType::HandleRoot(SmNode *pNode,int nLevel)
pS->WriteUChar( LINE|0x10 ); //dummy line
-
pS->WriteUChar( END );
}
@@ -2218,7 +2217,6 @@ sal_uInt8 MathType::HandleCScript(SmNode *pNode,SmNode *pContent,int nLevel,
}
-
/*
Sub and Sup scripts and another problem area, StarMath
can have all possible options used at the same time, whereas
@@ -2598,7 +2596,6 @@ void MathType::HandleOperator(SmNode *pNode,int nLevel)
pS->WriteUChar( LINE|0x10 );
}
-
pS->WriteUChar( 0x0D );
switch(pNode->GetToken().eType)
{
@@ -2643,8 +2640,7 @@ void MathType::HandleOperator(SmNode *pNode,int nLevel)
}
-int MathType::HandlePile(int &rSetAlign,int nLevel,sal_uInt8 nSelector,
- sal_uInt8 nVariation)
+bool MathType::HandlePile(int &rSetAlign, int nLevel, sal_uInt8 nSelector, sal_uInt8 nVariation)
{
pS->ReadUChar( nHAlign );
pS->ReadUChar( nVAlign );
@@ -2652,7 +2648,7 @@ int MathType::HandlePile(int &rSetAlign,int nLevel,sal_uInt8 nSelector,
HandleAlign(nHAlign,nVAlign,rSetAlign);
rRet += " stack {\n";
- int nRet = HandleRecords(nLevel+1,nSelector,nVariation,-1,-1);
+ bool bRet = HandleRecords( nLevel+1, nSelector, nVariation, -1, -1 );
rRet = rRet.replaceAt(rRet.getLength()-3,2,"");
rRet += "} ";
@@ -2661,11 +2657,10 @@ int MathType::HandlePile(int &rSetAlign,int nLevel,sal_uInt8 nSelector,
rRet += "} ";
rSetAlign--;
}
- return nRet;
+ return bRet;
}
-int MathType::HandleMatrix(int nLevel,sal_uInt8 nSelector,
- sal_uInt8 nVariation)
+bool MathType::HandleMatrix(int nLevel, sal_uInt8 nSelector, sal_uInt8 nVariation)
{
sal_uInt8 nH_just,nV_just,nRows,nCols;
pS->ReadUChar( nVAlign );
@@ -2682,7 +2677,7 @@ int MathType::HandleMatrix(int nLevel,sal_uInt8 nSelector,
nBytes++;
pS->SeekRel(nBytes);
rRet += " matrix {\n";
- int nRet = HandleRecords(nLevel+1,nSelector,nVariation,nRows,nCols);
+ bool bRet = HandleRecords( nLevel+1, nSelector, nVariation, nRows, nCols );
sal_Int32 nI = rRet.lastIndexOf('#');
if (nI > 0)
@@ -2690,10 +2685,10 @@ int MathType::HandleMatrix(int nLevel,sal_uInt8 nSelector,
rRet += "{}";
rRet += "\n} ";
- return nRet;
+ return bRet;
}
-int MathType::HandleTemplate(int nLevel,sal_uInt8 &rSelector,
+bool MathType::HandleTemplate(int nLevel, sal_uInt8 &rSelector,
sal_uInt8 &rVariation, sal_Int32 &rLastTemplateBracket)
{
sal_uInt8 nOption; //This appears utterly unused
@@ -2726,7 +2721,7 @@ int MathType::HandleTemplate(int nLevel,sal_uInt8 &rSelector,
}
//suborderlist
- int nRet = HandleRecords(nLevel+1,rSelector,rVariation);
+ bool bRet = HandleRecords( nLevel+1, rSelector, rVariation );
if (bRemove)
{
@@ -2740,7 +2735,7 @@ int MathType::HandleTemplate(int nLevel,sal_uInt8 &rSelector,
rLastTemplateBracket = -1;
rSelector = sal::static_int_cast< sal_uInt8 >(-1);
- return nRet;
+ return bRet;
}
void MathType::HandleEmblishments()
@@ -2846,11 +2841,11 @@ void MathType::HandleSetSize()
}
}
-int MathType::HandleChar(sal_Int32 &rTextStart,int &rSetSize,int nLevel,
- sal_uInt8 nTag,sal_uInt8 nSelector,sal_uInt8 nVariation, bool bSilent)
+bool MathType::HandleChar(sal_Int32 &rTextStart, int &rSetSize, int nLevel,
+ sal_uInt8 nTag, sal_uInt8 nSelector, sal_uInt8 nVariation, bool bSilent)
{
sal_Unicode nChar;
- int nRet=1;
+ bool bRet = true;
if (xfAUTO(nTag))
{
@@ -2873,7 +2868,7 @@ int MathType::HandleChar(sal_Int32 &rTextStart,int &rSetSize,int nLevel,
bad character, old mathtype < 3 has these
*/
if (nChar < 0x20)
- return nRet;
+ return bRet;
if (xfEMBELL(nTag))
{
@@ -2892,7 +2887,7 @@ int MathType::HandleChar(sal_Int32 &rTextStart,int &rSetSize,int nLevel,
rRet += " {"; // #i24340# make what would be "vec {A}_n" become "{vec {A}}_n"
if ((!bSilent) && ((nOriglen) > 1))
rRet += "\"";
- nRet = HandleRecords(nLevel+1,nSelector,nVariation);
+ bRet = HandleRecords( nLevel+1, nSelector, nVariation );
if (!bSilent)
{
if (nOriglen > 1)
@@ -2951,7 +2946,7 @@ int MathType::HandleChar(sal_Int32 &rTextStart,int &rSetSize,int nLevel,
rRet += "}}" + sPost; // #i24340# make what would be "vec {A}_n" become "{vec {A}}_n"
rTextStart = rRet.getLength();
}
- return nRet;
+ return bRet;
}
bool MathType::HandleLim(SmNode *pNode,int nLevel)
diff --git a/starmath/source/mathtype.hxx b/starmath/source/mathtype.hxx
index 16cc9e8aa487..49f8b0cfd66d 100644
--- a/starmath/source/mathtype.hxx
+++ b/starmath/source/mathtype.hxx
@@ -109,8 +109,8 @@ public:
Init();
}
- int Parse( SotStorage* pStor );
- int ConvertFromStarMath( SfxMedium& rMedium );
+ bool Parse( SotStorage* pStor );
+ bool ConvertFromStarMath( SfxMedium& rMedium );
private:
/*Ver 2 Header*/
@@ -124,23 +124,21 @@ private:
void Init();
- int HandleRecords(int nLevel=0,sal_uInt8 nSelector=0xFF,
- sal_uInt8 nVariation=0xFF,int nRows=0,int nCols=0);
- bool HandleSize(sal_Int16 nLSize,sal_Int16 nDSize, int &rSetSize);
- void HandleAlign(sal_uInt8 nHAlign,sal_uInt8 nVAlign, int &rSetAlign);
- int HandlePile(int &rSetAlign,int nLevel,sal_uInt8 nSelector,
- sal_uInt8 nVariation);
- int HandleMatrix(int nLevel,sal_uInt8 nSelector,sal_uInt8 nVariarion);
- void HandleMatrixSeparator(int nMatrixRows,int nMatrixCols,int &rCurCol,
- int &rCurRow);
- int HandleTemplate(int nLevel,sal_uInt8 &rSelector,sal_uInt8 &rVariation,
+ bool HandleRecords(int nLevel =0, sal_uInt8 nSelector =0xFF,
+ sal_uInt8 nVariation =0xFF, int nRows =0, int nCols =0);
+ bool HandleSize(sal_Int16 nLSize, sal_Int16 nDSize, int &rSetSize);
+ void HandleAlign(sal_uInt8 nHAlign, sal_uInt8 nVAlign, int &rSetAlign);
+ bool HandlePile(int &rSetAlign, int nLevel, sal_uInt8 nSelector, sal_uInt8 nVariation);
+ bool HandleMatrix(int nLevel, sal_uInt8 nSelector, sal_uInt8 nVariarion);
+ void HandleMatrixSeparator(int nMatrixRows, int nMatrixCols, int &rCurCol, int &rCurRow);
+ bool HandleTemplate(int nLevel, sal_uInt8 &rSelector, sal_uInt8 &rVariation,
sal_Int32 &rLastTemplateBracket);
void HandleEmblishments();
void HandleSetSize();
- int HandleChar(sal_Int32 &rTextStart,int &rSetSize,int nLevel,
- sal_uInt8 nTag,sal_uInt8 nSelector,sal_uInt8 nVariation,
- bool bSilent);
+ bool HandleChar(sal_Int32 &rTextStart, int &rSetSize, int nLevel,
+ sal_uInt8 nTag, sal_uInt8 nSelector, sal_uInt8 nVariation, bool bSilent);
void HandleNudge();
+
static int xfLMOVE(sal_uInt8 nTest) {return nTest&0x80;}
static int xfAUTO(sal_uInt8 nTest) {return nTest&0x10;}
static int xfEMBELL(sal_uInt8 nTest) {return nTest&0x20;}
diff --git a/starmath/source/unofilter.cxx b/starmath/source/unofilter.cxx
index ad5fb34ba9e8..2b005ed3c4d1 100644
--- a/starmath/source/unofilter.cxx
+++ b/starmath/source/unofilter.cxx
@@ -76,7 +76,7 @@ sal_Bool MathTypeFilter::filter(const uno::Sequence<beans::PropertyValue>& rDesc
SmDocShell* pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell());
OUString aText = pDocShell->GetText();
MathType aEquation(aText);
- bSuccess = aEquation.Parse(aStorage) == 1;
+ bSuccess = aEquation.Parse(aStorage);
if (bSuccess)
{
pDocShell->SetText(aText);