summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-02-12 09:53:37 +0000
committerCaolán McNamara <caolanm@redhat.com>2014-02-12 13:03:52 +0000
commite414cdbf3321d579537b372d815d50c31195ecc3 (patch)
tree82db7062ea64860914ca7c63321fe2f78700193c /starmath
parent19cda6c79c6e2f2c77a6ec25fcd28e4c1bea5268 (diff)
coverity#1103660 Division or modulo by zero
Change-Id: I468b218635e10e04bb25150b6275e187ba8a8316
Diffstat (limited to 'starmath')
-rw-r--r--starmath/source/view.cxx21
1 files changed, 12 insertions, 9 deletions
diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx
index 627a443b4f9c..7b5e042d8810 100644
--- a/starmath/source/view.cxx
+++ b/starmath/source/view.cxx
@@ -1012,17 +1012,18 @@ Size SmViewShell::GetTextLineSize(OutputDevice& rDevice, const OUString& rLine)
Size aSize(rDevice.GetTextWidth(rLine), rDevice.GetTextHeight());
sal_uInt16 nTabs = comphelper::string::getTokenCount(rLine, '\t');
-
+ long nTabPos = 0;
if (nTabs > 0)
- {
- long TabPos = rDevice.GetTextWidth(OUString('n')) * 8;
+ nTabPos = rDevice.approximate_char_width() * 8;
+ if (nTabPos)
+ {
aSize.Width() = 0;
for (sal_uInt16 i = 0; i < nTabs; i++)
{
if (i > 0)
- aSize.Width() = ((aSize.Width() / TabPos) + 1) * TabPos;
+ aSize.Width() = ((aSize.Width() / nTabPos) + 1) * nTabPos;
OUString aText = rLine.getToken(i, '\t');
aText = comphelper::string::stripStart(aText, '\t');
@@ -1101,16 +1102,18 @@ void SmViewShell::DrawTextLine(OutputDevice& rDevice, const Point& rPosition, co
SAL_INFO( "starmath", "SmViewShell::DrawTextLine" );
Point aPoint (rPosition);
- sal_uInt16 nTabs = comphelper::string::getTokenCount(rLine, '\t');
+ sal_uInt16 nTabs = comphelper::string::getTokenCount(rLine, '\t');
+ long nTabPos = 0;
if (nTabs > 0)
- {
- long TabPos = rDevice.GetTextWidth(OUString('n')) * 8;
+ nTabPos = rDevice.approximate_char_width() * 8;
- for (sal_uInt16 i = 0; i < nTabs; i++)
+ if (nTabPos)
+ {
+ for (sal_uInt16 i = 0; i < nTabs; ++i)
{
if (i > 0)
- aPoint.X() = ((aPoint.X() / TabPos) + 1) * TabPos;
+ aPoint.X() = ((aPoint.X() / nTabPos) + 1) * nTabPos;
OUString aText = rLine.getToken(i, '\t');
aText = comphelper::string::stripStart(aText, '\t');