[Libreoffice-commits] libcdr.git: src/lib
Miklos Vajna
vmiklos at collabora.co.uk
Mon Nov 6 08:14:43 UTC 2017
src/lib/CDRCollector.cpp | 18 +++++++++---------
src/lib/CDRContentCollector.cpp | 10 +++++-----
src/lib/CDRDocument.cpp | 6 +++---
src/lib/CDRParser.cpp | 8 ++++----
src/lib/CDRPath.cpp | 2 +-
src/lib/CDRStylesCollector.cpp | 4 ++--
src/lib/CMXDocument.cpp | 6 +++---
src/lib/CMXParser.cpp | 8 ++++----
src/lib/libcdr_utils.cpp | 8 ++++----
9 files changed, 35 insertions(+), 35 deletions(-)
New commits:
commit 597d8bcb89cbedad5ba6009ad04ea43bf01188d3
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Mon Nov 6 09:14:23 2017 +0100
Use auto when declaring iterators and when initializing with a cast
Change-Id: Ife4f3562d0c655de8623870600b0e6bb7f1f12dc
diff --git a/src/lib/CDRCollector.cpp b/src/lib/CDRCollector.cpp
index ee88045..285f5e6 100644
--- a/src/lib/CDRCollector.cpp
+++ b/src/lib/CDRCollector.cpp
@@ -305,7 +305,7 @@ unsigned libcdr::CDRParserState::_getRGBColor(const CDRColor &color)
0x00, 0x46, 0x73, 0x91, 0xa2, 0xad, 0x2a, 0x3d, 0x69, 0x7d, 0x85, 0x8f, 0xa3,
};
- unsigned short pantoneIndex = (unsigned short)(((int)col1 << 8) | (int)col0);
+ auto pantoneIndex = (unsigned short)(((int)col1 << 8) | (int)col0);
double pantoneSaturation = (double)(((unsigned short)col3 << 8) | (unsigned short)col2) / 100.0;
typedef struct
{
@@ -322,9 +322,9 @@ unsigned libcdr::CDRParserState::_getRGBColor(const CDRColor &color)
pureColor.g = WaldoColorType0_G[pantoneIndex];
pureColor.b = WaldoColorType0_B[pantoneIndex];
}
- unsigned tmpRed = (unsigned)cdr_round(255.0*(1-pantoneSaturation) + (double)pureColor.r*pantoneSaturation);
- unsigned tmpGreen = (unsigned)cdr_round(255.0*(1-pantoneSaturation) + (double)pureColor.g*pantoneSaturation);
- unsigned tmpBlue = (unsigned)cdr_round(255.0*(1-pantoneSaturation) + (double)pureColor.b*pantoneSaturation);
+ auto tmpRed = (unsigned)cdr_round(255.0*(1-pantoneSaturation) + (double)pureColor.r*pantoneSaturation);
+ auto tmpGreen = (unsigned)cdr_round(255.0*(1-pantoneSaturation) + (double)pureColor.g*pantoneSaturation);
+ auto tmpBlue = (unsigned)cdr_round(255.0*(1-pantoneSaturation) + (double)pureColor.b*pantoneSaturation);
red = (tmpRed < 255 ? (unsigned char)tmpRed : 255);
green = (tmpGreen < 255 ? (unsigned char)tmpGreen : 255);
blue = (tmpBlue < 255 ? (unsigned char)tmpBlue : 255);
@@ -390,7 +390,7 @@ unsigned libcdr::CDRParserState::_getRGBColor(const CDRColor &color)
// HSB
case 0x06:
{
- unsigned short hue = (unsigned short)(((int)col1<<8) | col0);
+ auto hue = (unsigned short)(((int)col1<<8) | col0);
double saturation = (double)col2/255.0;
double brightness = (double)col3/255.0;
@@ -425,7 +425,7 @@ unsigned libcdr::CDRParserState::_getRGBColor(const CDRColor &color)
// HLS
case 0x07:
{
- unsigned short hue = (unsigned short)(((int)col1<<8) | col0);
+ auto hue = (unsigned short)(((int)col1<<8) | col0);
double lightness = (double)col2/255.0;
double saturation = (double)col3/255.0;
@@ -490,9 +490,9 @@ unsigned libcdr::CDRParserState::_getRGBColor(const CDRColor &color)
// YIQ255
case 0x0b:
{
- double y = (double)col0;
- double i = (double)col1;
- double q = (double)col2;
+ auto y = (double)col0;
+ auto i = (double)col1;
+ auto q = (double)col2;
y -= 100.0;
if (y < 0.0)
diff --git a/src/lib/CDRContentCollector.cpp b/src/lib/CDRContentCollector.cpp
index b2b08cd..b554fd1 100644
--- a/src/lib/CDRContentCollector.cpp
+++ b/src/lib/CDRContentCollector.cpp
@@ -797,7 +797,7 @@ void libcdr::CDRContentCollector::_fillProperties(librevenge::RVNGPropertyList &
case 7: // Pattern
case 8: // Pattern
{
- std::map<unsigned, CDRPattern>::iterator iterPattern = m_ps.m_patterns.find(m_currentFillStyle.imageFill.id);
+ auto iterPattern = m_ps.m_patterns.find(m_currentFillStyle.imageFill.id);
if (iterPattern != m_ps.m_patterns.end())
{
propList.insert("draw:fill", "bitmap");
@@ -871,7 +871,7 @@ void libcdr::CDRContentCollector::_fillProperties(librevenge::RVNGPropertyList &
case 9: // Bitmap
case 11: // Texture
{
- std::map<unsigned, librevenge::RVNGBinaryData>::iterator iterBmp = m_ps.m_bmps.find(m_currentFillStyle.imageFill.id);
+ auto iterBmp = m_ps.m_bmps.find(m_currentFillStyle.imageFill.id);
if (iterBmp != m_ps.m_bmps.end())
{
propList.insert("librevenge:mime-type", "image/bmp");
@@ -931,7 +931,7 @@ void libcdr::CDRContentCollector::_fillProperties(librevenge::RVNGPropertyList &
break;
case 10: // Full color
{
- std::map<unsigned, librevenge::RVNGBinaryData>::iterator iterVect = m_ps.m_vects.find(m_currentFillStyle.imageFill.id);
+ auto iterVect = m_ps.m_vects.find(m_currentFillStyle.imageFill.id);
if (iterVect != m_ps.m_vects.end())
{
propList.insert("draw:fill", "bitmap");
@@ -1155,7 +1155,7 @@ void libcdr::CDRContentCollector::_generateBitmapFromPattern(librevenge::RVNGBin
{
unsigned height = pattern.height;
unsigned width = pattern.width;
- unsigned tmpPixelSize = (unsigned)(height * width);
+ auto tmpPixelSize = (unsigned)(height * width);
if (tmpPixelSize < (unsigned)height) // overflow
return;
@@ -1224,7 +1224,7 @@ void libcdr::CDRContentCollector::_generateBitmapFromPattern(librevenge::RVNGBin
void libcdr::CDRContentCollector::collectBitmap(unsigned imageId, double x1, double x2, double y1, double y2)
{
- std::map<unsigned, librevenge::RVNGBinaryData>::iterator iter = m_ps.m_bmps.find(imageId);
+ auto iter = m_ps.m_bmps.find(imageId);
if (iter != m_ps.m_bmps.end())
m_currentImage = CDRImage(iter->second, x1, x2, y1, y2);
}
diff --git a/src/lib/CDRDocument.cpp b/src/lib/CDRDocument.cpp
index d2fe9bf..7827d5a 100644
--- a/src/lib/CDRDocument.cpp
+++ b/src/lib/CDRDocument.cpp
@@ -31,13 +31,13 @@ static unsigned getCDRVersion(librevenge::RVNGInputStream *input)
if (riff != CDR_FOURCC_RIFF)
return 0;
input->seek(4, librevenge::RVNG_SEEK_CUR);
- char signature_c = (char)readU8(input);
+ auto signature_c = (char)readU8(input);
if (signature_c != 'C' && signature_c != 'c')
return 0;
- char signature_d = (char)readU8(input);
+ auto signature_d = (char)readU8(input);
if (signature_d != 'D' && signature_d != 'd')
return 0;
- char signature_r = (char)readU8(input);
+ auto signature_r = (char)readU8(input);
if (signature_r != 'R' && signature_r != 'r')
return 0;
unsigned char c = readU8(input);
diff --git a/src/lib/CDRParser.cpp b/src/lib/CDRParser.cpp
index 79271d3..0744305 100644
--- a/src/lib/CDRParser.cpp
+++ b/src/lib/CDRParser.cpp
@@ -255,7 +255,7 @@ bool libcdr::CDRParser::parseWaldo(librevenge::RVNGInputStream *input)
if (!records1.empty() && !records2.empty())
{
- std::map<unsigned, WaldoRecordType1>::iterator iter1 = records1.find(1);
+ auto iter1 = records1.find(1);
std::stack<WaldoRecordType1> waldoStack;
if (iter1 != records1.end())
{
@@ -1538,7 +1538,7 @@ void libcdr::CDRParser::readWaldoOutl(librevenge::RVNGInputStream *input)
return;
unsigned short lineType = readU8(input);
lineType <<= 1;
- double lineWidth = (double)readCoordinate(input);
+ auto lineWidth = (double)readCoordinate(input);
double stretch = (double)readU16(input) / 100.0;
double angle = readAngle(input);
libcdr::CDRColor color = readColor(input);
@@ -1810,7 +1810,7 @@ void libcdr::CDRParser::readFild(librevenge::RVNGInputStream *input, unsigned le
gradient.m_mode = (unsigned char)(readUnsigned(input) & 0xff);
gradient.m_midPoint = (double)readU8(input) / 100.0;
input->seek(1, librevenge::RVNG_SEEK_CUR);
- unsigned short numStops = (unsigned short)(readUnsigned(input) & 0xffff);
+ auto numStops = (unsigned short)(readUnsigned(input) & 0xffff);
if (m_version >= 1300)
input->seek(3, librevenge::RVNG_SEEK_CUR);
for (unsigned short i = 0; i < numStops; ++i)
@@ -2040,7 +2040,7 @@ void libcdr::CDRParser::readOutl(librevenge::RVNGInputStream *input, unsigned le
unsigned short joinType = readU16(input);
if (m_version < 1300 && m_version >= 600)
input->seek(2, librevenge::RVNG_SEEK_CUR);
- double lineWidth = (double)readCoordinate(input);
+ auto lineWidth = (double)readCoordinate(input);
double stretch = (double)readU16(input) / 100.0;
if (m_version >= 600)
input->seek(2, librevenge::RVNG_SEEK_CUR);
diff --git a/src/lib/CDRPath.cpp b/src/lib/CDRPath.cpp
index 636544a..e2a66a8 100644
--- a/src/lib/CDRPath.cpp
+++ b/src/lib/CDRPath.cpp
@@ -516,7 +516,7 @@ void libcdr::CDRSplineToElement::writeOut(librevenge::RVNGPropertyListVector &ve
unsigned mult = b - i + 1;
if (mult < CDR_SPLINE_DEGREE)
{
- double numer = (double)(knot(b) - knot(a));
+ auto numer = (double)(knot(b) - knot(a));
unsigned j = CDR_SPLINE_DEGREE;
std::map<unsigned, double> alphas;
for (; j >mult; j--)
diff --git a/src/lib/CDRStylesCollector.cpp b/src/lib/CDRStylesCollector.cpp
index 11a39f3..c1c23ae 100644
--- a/src/lib/CDRStylesCollector.cpp
+++ b/src/lib/CDRStylesCollector.cpp
@@ -35,7 +35,7 @@ void libcdr::CDRStylesCollector::collectBmp(unsigned imageId, unsigned colorMode
if (height == 0)
height = 1;
- unsigned tmpPixelSize = (unsigned)(height * width);
+ auto tmpPixelSize = (unsigned)(height * width);
if (tmpPixelSize < (unsigned)height) // overflow
return;
@@ -226,7 +226,7 @@ void libcdr::CDRStylesCollector::collectText(unsigned textId, unsigned styleId,
for (i=0, j=0; i<charDescriptions.size() && j<data.size(); ++i)
{
tmpCharStyle = defaultCharStyle;
- std::map<unsigned, CDRStyle>::const_iterator iter = styleOverrides.find(tmpCharDescription & 0xfe);
+ auto iter = styleOverrides.find(tmpCharDescription & 0xfe);
if (iter != styleOverrides.end())
tmpCharStyle.overrideStyle(iter->second);
if (charDescriptions[i] != tmpCharDescription)
diff --git a/src/lib/CMXDocument.cpp b/src/lib/CMXDocument.cpp
index b52e631..4aa63c0 100644
--- a/src/lib/CMXDocument.cpp
+++ b/src/lib/CMXDocument.cpp
@@ -34,13 +34,13 @@ try
if (riff != CDR_FOURCC_RIFF && riff != CDR_FOURCC_RIFX)
return false;
input->seek(4, librevenge::RVNG_SEEK_CUR);
- char signature_c = (char)readU8(input);
+ auto signature_c = (char)readU8(input);
if (signature_c != 'C' && signature_c != 'c')
return false;
- char signature_d = (char)readU8(input);
+ auto signature_d = (char)readU8(input);
if (signature_d != 'M' && signature_d != 'm')
return false;
- char signature_r = (char)readU8(input);
+ auto signature_r = (char)readU8(input);
if (signature_r != 'X' && signature_r != 'x')
return false;
return true;
diff --git a/src/lib/CMXParser.cpp b/src/lib/CMXParser.cpp
index 26fd3e4..9cbfecc 100644
--- a/src/lib/CMXParser.cpp
+++ b/src/lib/CMXParser.cpp
@@ -228,7 +228,7 @@ void libcdr::CMXParser::readCMXHeader(librevenge::RVNGInputStream *input)
for (i = 0; i < 2; i++)
tmpString.append((char)readU8(input, m_bigEndian));
CDR_DEBUG_MSG(("CMX Coordinate Size: %s\n", tmpString.cstr()));
- unsigned short coordSize = (unsigned short)atoi(tmpString.cstr());
+ auto coordSize = (unsigned short)atoi(tmpString.cstr());
switch (coordSize)
{
case 2:
@@ -334,7 +334,7 @@ void libcdr::CMXParser::readDisp(librevenge::RVNGInputStream *input)
const unsigned *libcdr::CMXParser::_getOffsetByType(unsigned short type, const std::map<unsigned short, unsigned> &offsets)
{
- std::map<unsigned short, unsigned>::const_iterator iter = offsets.find(type);
+ auto iter = offsets.find(type);
if (iter != offsets.end())
return &(iter->second);
return nullptr;
@@ -1063,7 +1063,7 @@ bool libcdr::CMXParser::readFill(librevenge::RVNGInputStream *input)
libcdr::CDRColor color2;
libcdr::CDRImageFill imageFill;
libcdr::CDRGradient gradient;
- unsigned fillId = (unsigned)input->tell();
+ auto fillId = (unsigned)input->tell();
unsigned fillType = readU16(input, m_bigEndian);
switch (fillType)
{
@@ -1514,7 +1514,7 @@ bool libcdr::CMXParser::readRenderingAttributes(librevenge::RVNGInputStream *inp
if (bitMask & 0x02) // outline
{
CDRLineStyle lineStyle;
- unsigned lineStyleId = (unsigned)input->tell();
+ auto lineStyleId = (unsigned)input->tell();
if (m_precision == libcdr::PRECISION_32BIT)
{
do
diff --git a/src/lib/libcdr_utils.cpp b/src/lib/libcdr_utils.cpp
index 3fa0bbf..0db5a5c 100644
--- a/src/lib/libcdr_utils.cpp
+++ b/src/lib/libcdr_utils.cpp
@@ -262,8 +262,8 @@ double libcdr::readDouble(librevenge::RVNGInputStream *input, bool bigEndian)
double libcdr::readFixedPoint(librevenge::RVNGInputStream *input, bool bigEndian)
{
unsigned fixedPointNumber = readU32(input, bigEndian);
- short fixedPointNumberIntegerPart = (short)((fixedPointNumber & 0xFFFF0000) >> 16);
- double fixedPointNumberFractionalPart = (double)((double)(fixedPointNumber & 0x0000FFFF)/(double)0xFFFF);
+ auto fixedPointNumberIntegerPart = (short)((fixedPointNumber & 0xFFFF0000) >> 16);
+ auto fixedPointNumberFractionalPart = (double)((double)(fixedPointNumber & 0x0000FFFF)/(double)0xFFFF);
return ((double)fixedPointNumberIntegerPart + fixedPointNumberFractionalPart);
}
@@ -425,7 +425,7 @@ void libcdr::appendCharacters(librevenge::RVNGString &text, std::vector<unsigned
}
if (U_SUCCESS(status) && conv)
{
- const char *src = (const char *)&characters[0];
+ const auto *src = (const char *)&characters[0];
const char *srcLimit = (const char *)src + characters.size();
while (src < srcLimit)
{
@@ -449,7 +449,7 @@ void libcdr::appendCharacters(librevenge::RVNGString &text, std::vector<unsigned
if (U_SUCCESS(status) && conv)
{
- const char *src = (const char *)&characters[0];
+ const auto *src = (const char *)&characters[0];
const char *srcLimit = (const char *)src + characters.size();
while (src < srcLimit)
{
More information about the Libreoffice-commits
mailing list