[Libreoffice-commits] libcdr.git: 2 commits - configure.ac src/lib

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Mar 29 09:42:11 UTC 2021


 configure.ac                    |    2 
 src/lib/CDRCollector.cpp        |    6 +-
 src/lib/CDRContentCollector.cpp |   32 +++++-----
 src/lib/CDRInternalStream.cpp   |    6 +-
 src/lib/CDRParser.cpp           |  117 +++++++++++++++++++---------------------
 src/lib/CDRParser.h             |    2 
 src/lib/CDRPath.cpp             |   10 +--
 src/lib/CDRStylesCollector.cpp  |   12 ++--
 src/lib/CDRTypes.h              |    2 
 src/lib/CMXParser.cpp           |   96 ++++++++++++++++----------------
 src/lib/CMXParser.h             |    4 -
 src/lib/CommonParser.cpp        |    4 -
 src/lib/libcdr_utils.cpp        |    8 +-
 src/lib/libcdr_utils.h          |    1 
 14 files changed, 152 insertions(+), 150 deletions(-)

New commits:
commit 6fbf17368a4233071846cd2bb46c13b24a84598d
Author:     Fridrich Štrba <fridrich.strba at bluewin.ch>
AuthorDate: Mon Mar 29 11:34:02 2021 +0200
Commit:     Fridrich Štrba <fridrich.strba at bluewin.ch>
CommitDate: Mon Mar 29 11:34:02 2021 +0200

    Build with maximum werror
    
    Change-Id: I44ca70cc7c0ce726b91cccfb11128b163e7e4a4b

diff --git a/src/lib/CDRCollector.cpp b/src/lib/CDRCollector.cpp
index 3f204d0..8435ade 100644
--- a/src/lib/CDRCollector.cpp
+++ b/src/lib/CDRCollector.cpp
@@ -139,9 +139,9 @@ unsigned libcdr::CDRParserState::_getRGBColor(const CDRColor &color)
     // todo handle tint
   }
   unsigned char col0 = colorValue & 0xff;
-  unsigned char col1 = (colorValue & 0xff00) >> 8;
-  unsigned char col2 = (colorValue & 0xff0000) >> 16;
-  unsigned char col3 = (colorValue & 0xff000000) >> 24;
+  unsigned char col1 = (colorValue >> 8) & 0xff;
+  unsigned char col2 = (colorValue >> 16) & 0xff;
+  unsigned char col3 = (unsigned char)((colorValue >> 24) & 0xff);
   switch (colorModel)
   {
   case 0x00: // Pantone palette in CDR1
diff --git a/src/lib/CDRContentCollector.cpp b/src/lib/CDRContentCollector.cpp
index 683d8fd..f1a5817 100644
--- a/src/lib/CDRContentCollector.cpp
+++ b/src/lib/CDRContentCollector.cpp
@@ -409,7 +409,7 @@ void libcdr::CDRContentCollector::_flushCurrentPath()
     while (rotate > 2.0*M_PI)
       rotate -= 2.0*M_PI;
 
-    if (rotate != 0.0)
+    if (!CDR_ALMOST_ZERO(rotate))
       propList.insert("librevenge:rotate", rotate * 180 / M_PI, librevenge::RVNG_GENERIC);
 
     propList.insert("librevenge:mime-type", "image/bmp");
@@ -606,7 +606,7 @@ void libcdr::CDRContentCollector::collectLevel(unsigned level)
       const char *header =
         "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n";
       librevenge::RVNGBinaryData output((const unsigned char *)header, strlen(header));
-      output.append((unsigned char *)svgOutput[0].cstr(), strlen(svgOutput[0].cstr()));
+      output.append((const unsigned char *)svgOutput[0].cstr(), strlen(svgOutput[0].cstr()));
       m_ps.m_vects[m_spnd] = output;
     }
 #if DUMP_VECT
@@ -827,20 +827,20 @@ void libcdr::CDRContentCollector::_fillProperties(librevenge::RVNGPropertyList &
           propList.insert("draw:fill-image-ref-point", "bottom-left");
           if (m_currentFillStyle.imageFill.isRelative)
           {
-            if (m_currentFillStyle.imageFill.xOffset != 0.0 && m_currentFillStyle.imageFill.xOffset != 1.0)
+            if (!CDR_ALMOST_ZERO(m_currentFillStyle.imageFill.xOffset) && !CDR_ALMOST_ZERO(m_currentFillStyle.imageFill.xOffset))
               propList.insert("draw:fill-image-ref-point-x", m_currentFillStyle.imageFill.xOffset, librevenge::RVNG_PERCENT);
-            if (m_currentFillStyle.imageFill.yOffset != 0.0 && m_currentFillStyle.imageFill.yOffset != 1.0)
+            if (!CDR_ALMOST_ZERO(m_currentFillStyle.imageFill.yOffset) && !CDR_ALMOST_ZERO(m_currentFillStyle.imageFill.yOffset))
               propList.insert("draw:fill-image-ref-point-y", m_currentFillStyle.imageFill.yOffset, librevenge::RVNG_PERCENT);
           }
           else
           {
-            if (m_fillTransforms.getTranslateX() != 0.0)
+            if (!CDR_ALMOST_ZERO(m_fillTransforms.getTranslateX()))
             {
               double xOffset = m_fillTransforms.getTranslateX() / m_currentFillStyle.imageFill.width;
               normalize(xOffset);
               propList.insert("draw:fill-image-ref-point-x", xOffset, librevenge::RVNG_PERCENT);
             }
-            if (m_fillTransforms.getTranslateY() != 0.0)
+            if (!CDR_ALMOST_ZERO(m_fillTransforms.getTranslateY()))
             {
               double yOffset = m_fillTransforms.getTranslateY() / m_currentFillStyle.imageFill.width;
               normalize(yOffset);
@@ -887,14 +887,14 @@ void libcdr::CDRContentCollector::_fillProperties(librevenge::RVNGPropertyList &
           propList.insert("draw:fill-image-ref-point", "bottom-left");
           if (m_currentFillStyle.imageFill.isRelative)
           {
-            if (m_currentFillStyle.imageFill.xOffset != 0.0 && m_currentFillStyle.imageFill.xOffset != 1.0)
+            if (!CDR_ALMOST_ZERO(m_currentFillStyle.imageFill.xOffset) && !CDR_ALMOST_ZERO(m_currentFillStyle.imageFill.xOffset))
               propList.insert("draw:fill-image-ref-point-x", m_currentFillStyle.imageFill.xOffset, librevenge::RVNG_PERCENT);
-            if (m_currentFillStyle.imageFill.yOffset != 0.0 && m_currentFillStyle.imageFill.yOffset != 1.0)
+            if (!CDR_ALMOST_ZERO(m_currentFillStyle.imageFill.yOffset) && !CDR_ALMOST_ZERO(m_currentFillStyle.imageFill.yOffset))
               propList.insert("draw:fill-image-ref-point-y", m_currentFillStyle.imageFill.yOffset, librevenge::RVNG_PERCENT);
           }
           else
           {
-            if (m_fillTransforms.getTranslateX() != 0.0)
+            if (!CDR_ALMOST_ZERO(m_fillTransforms.getTranslateX()))
             {
               double xOffset = m_fillTransforms.getTranslateX() / m_currentFillStyle.imageFill.width;
               while (xOffset < 0.0)
@@ -903,7 +903,7 @@ void libcdr::CDRContentCollector::_fillProperties(librevenge::RVNGPropertyList &
                 xOffset -= 1.0;
               propList.insert("draw:fill-image-ref-point-x", xOffset, librevenge::RVNG_PERCENT);
             }
-            if (m_fillTransforms.getTranslateY() != 0.0)
+            if (!CDR_ALMOST_ZERO(m_fillTransforms.getTranslateY()))
             {
               double yOffset = m_fillTransforms.getTranslateY() / m_currentFillStyle.imageFill.width;
               while (yOffset < 0.0)
@@ -947,14 +947,14 @@ void libcdr::CDRContentCollector::_fillProperties(librevenge::RVNGPropertyList &
           propList.insert("draw:fill-image-ref-point", "bottom-left");
           if (m_currentFillStyle.imageFill.isRelative)
           {
-            if (m_currentFillStyle.imageFill.xOffset != 0.0 && m_currentFillStyle.imageFill.xOffset != 1.0)
+            if (!CDR_ALMOST_ZERO(m_currentFillStyle.imageFill.xOffset) && !CDR_ALMOST_ZERO(m_currentFillStyle.imageFill.xOffset))
               propList.insert("draw:fill-image-ref-point-x", m_currentFillStyle.imageFill.xOffset, librevenge::RVNG_PERCENT);
-            if (m_currentFillStyle.imageFill.yOffset != 0.0 && m_currentFillStyle.imageFill.yOffset != 1.0)
+            if (!CDR_ALMOST_ZERO(m_currentFillStyle.imageFill.yOffset) && !CDR_ALMOST_ZERO(m_currentFillStyle.imageFill.yOffset))
               propList.insert("draw:fill-image-ref-point-y", m_currentFillStyle.imageFill.yOffset, librevenge::RVNG_PERCENT);
           }
           else
           {
-            if (m_fillTransforms.getTranslateX() != 0.0)
+            if (!CDR_ALMOST_ZERO(m_fillTransforms.getTranslateX()))
             {
               double xOffset = m_fillTransforms.getTranslateX() / m_currentFillStyle.imageFill.width;
               while (xOffset < 0.0)
@@ -963,7 +963,7 @@ void libcdr::CDRContentCollector::_fillProperties(librevenge::RVNGPropertyList &
                 xOffset -= 1.0;
               propList.insert("draw:fill-image-ref-point-x", xOffset, librevenge::RVNG_PERCENT);
             }
-            if (m_fillTransforms.getTranslateY() != 0.0)
+            if (!CDR_ALMOST_ZERO(m_fillTransforms.getTranslateY()))
             {
               double yOffset = m_fillTransforms.getTranslateY() / m_currentFillStyle.imageFill.width;
               while (yOffset < 0.0)
@@ -1231,7 +1231,7 @@ void libcdr::CDRContentCollector::collectFillOpacity(double opacity)
 void libcdr::CDRContentCollector::collectBBox(double x0, double y0, double x1, double y1)
 {
   CDRBox bBox(x0, y0, x1, y1);
-  if (m_currentVectLevel && m_page.width == 0.0 && m_page.height == 0.0)
+  if (m_currentVectLevel && CDR_ALMOST_ZERO(m_page.width) && CDR_ALMOST_ZERO(m_page.height))
   {
     m_page.width = bBox.getWidth();
     m_page.height = bBox.getHeight();
@@ -1268,7 +1268,7 @@ void libcdr::CDRContentCollector::collectVectorPattern(unsigned id, const librev
     const char *header =
       "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n";
     librevenge::RVNGBinaryData output((const unsigned char *)header, strlen(header));
-    output.append((unsigned char *)svgOutput[0].cstr(), strlen(svgOutput[0].cstr()));
+    output.append((const unsigned char *)svgOutput[0].cstr(), strlen(svgOutput[0].cstr()));
     m_ps.m_vects[id] = output;
   }
 #if DUMP_VECT
diff --git a/src/lib/CDRInternalStream.cpp b/src/lib/CDRInternalStream.cpp
index d8171d7..6063a02 100644
--- a/src/lib/CDRInternalStream.cpp
+++ b/src/lib/CDRInternalStream.cpp
@@ -67,7 +67,7 @@ libcdr::CDRInternalStream::CDRInternalStream(librevenge::RVNGInputStream *input,
     }
 
     strm.avail_in = (uInt)tmpNumBytesRead;
-    strm.next_in = (Bytef *)tmpBuffer;
+    strm.next_in = const_cast<Bytef *>(tmpBuffer);
 
     do
     {
@@ -82,6 +82,8 @@ libcdr::CDRInternalStream::CDRInternalStream(librevenge::RVNGInputStream *input,
         (void)inflateEnd(&strm);
         m_buffer.clear();
         return;
+      default:
+        break;
       }
 
       unsigned have = CHUNK - strm.avail_out;
@@ -102,7 +104,7 @@ const unsigned char *libcdr::CDRInternalStream::read(unsigned long numBytes, uns
   if (numBytes == 0)
     return nullptr;
 
-  unsigned numBytesToRead;
+  unsigned long numBytesToRead;
 
   if ((m_offset+numBytes) < m_buffer.size())
     numBytesToRead = numBytes;
diff --git a/src/lib/CDRParser.cpp b/src/lib/CDRParser.cpp
index b9a95e9..1488a13 100644
--- a/src/lib/CDRParser.cpp
+++ b/src/lib/CDRParser.cpp
@@ -180,10 +180,10 @@ static int parseColourString(const char *colourString, libcdr::CDRColor &colour,
     return parseColourString(fallbackColours.begin()->c_str(), colour, opacity);
 
   if (colourModel)
-    colour.m_colorModel = get(colourModel);
+    colour.m_colorModel = (unsigned short)(get(colourModel));
 
   if (colourPalette)
-    colour.m_colorPalette = get(colourPalette);
+    colour.m_colorPalette = (unsigned short)(get(colourPalette));
 
   if (val.size() >= 5)
   {
@@ -344,7 +344,7 @@ bool libcdr::CDRParser::parseWaldo(librevenge::RVNGInputStream *input)
       if (iter1 != records1.end())
       {
         waldoStack.push(iter1->second);
-        m_collector->collectVect(waldoStack.size());
+        m_collector->collectVect((unsigned)(waldoStack.size()));
         parseWaldoStructure(input, waldoStack, records1, records2);
       }
       iter1 = records1.find(0);
@@ -352,7 +352,7 @@ bool libcdr::CDRParser::parseWaldo(librevenge::RVNGInputStream *input)
         return false;
       waldoStack = std::stack<WaldoRecordType1>();
       waldoStack.push(iter1->second);
-      m_collector->collectPage(waldoStack.size());
+      m_collector->collectPage((unsigned)(waldoStack.size()));
       if (!parseWaldoStructure(input, waldoStack, records1, records2))
         return false;
     }
@@ -427,7 +427,7 @@ bool libcdr::CDRParser::parseWaldoStructure(librevenge::RVNGInputStream *input,
     {
       if (waldoStack.size() > 1)
       {
-        m_collector->collectGroup(waldoStack.size());
+        m_collector->collectGroup((unsigned)(waldoStack.size()));
         m_collector->collectSpnd(waldoStack.top().m_id);
         CDRTransforms trafos;
         trafos.append(waldoStack.top().m_trafo);
@@ -437,19 +437,19 @@ bool libcdr::CDRParser::parseWaldoStructure(librevenge::RVNGInputStream *input,
       if (iter1 == records1.end())
         return false;
       waldoStack.push(iter1->second);
-      m_collector->collectLevel(waldoStack.size());
+      m_collector->collectLevel((unsigned)(waldoStack.size()));
     }
     else
     {
       if (waldoStack.size() > 1)
-        m_collector->collectObject(waldoStack.size());
+        m_collector->collectObject((unsigned)(waldoStack.size()));
       std::map<unsigned, WaldoRecordInfo>::const_iterator iter2 = records2.find(waldoStack.top().m_child);
       if (iter2 == records2.end())
         return false;
       readWaldoRecord(input, iter2->second);
       while (!waldoStack.empty() && !waldoStack.top().m_next)
         waldoStack.pop();
-      m_collector->collectLevel(waldoStack.size());
+      m_collector->collectLevel((unsigned)(waldoStack.size()));
       if (waldoStack.empty())
         return true;
       iter1 = records1.find(waldoStack.top().m_next);
@@ -634,7 +634,7 @@ bool libcdr::CDRParser::parseRecord(librevenge::RVNGInputStream *input, const st
         m_collector->collectGroup(level);
       else if ((listType & 0xffffff) == CDR_FOURCC_CDR || (listType & 0xffffff) == CDR_FOURCC_cdr)
       {
-        m_version = getCDRVersion((listType & 0xff000000) >> 24);
+        m_version = getCDRVersion((unsigned char)((listType & 0xff000000) >> 24));
         if (m_version < 600)
           m_precision = libcdr::PRECISION_16BIT;
         else
@@ -653,7 +653,7 @@ bool libcdr::CDRParser::parseRecord(librevenge::RVNGInputStream *input, const st
       else
       {
         std::vector<unsigned> tmpBlockLengths;
-        unsigned blocksLength = length + position - input->tell();
+        unsigned long blocksLength = length + position - input->tell();
         CDRInternalStream tmpBlocksStream(input, blocksLength, compressed);
         while (!tmpBlocksStream.isEnd())
           tmpBlockLengths.push_back(readU32(&tmpBlocksStream));
@@ -835,10 +835,10 @@ void libcdr::CDRParser::readRectangle(librevenge::RVNGInputStream *input)
   else
   {
     double scale = readDouble(input);
-    if (scale != 0)
+    if (!CDR_ALMOST_ZERO(scale))
       scaleX = scale;
     scale = readDouble(input);
-    if (scale != 0)
+    if (!CDR_ALMOST_ZERO(scale))
       scaleY = scale;
     unsigned int scale_with = readU8(input);
     input->seek(7, librevenge::RVNG_SEEK_CUR);
@@ -948,7 +948,7 @@ void libcdr::CDRParser::readEllipse(librevenge::RVNGInputStream *input)
   normalizeAngle(angle2);
 
   CDRPath path;
-  if (angle1 != angle2)
+  if (!CDR_ALMOST_EQUAL(angle1, angle2))
   {
     if (angle2 < angle1)
       angle2 += 2*M_PI;
@@ -1033,7 +1033,7 @@ void libcdr::CDRParser::readLineAndCurve(librevenge::RVNGInputStream *input)
 {
   CDR_DEBUG_MSG(("CDRParser::readLineAndCurve\n"));
 
-  unsigned short pointNum = readU16(input);
+  unsigned long pointNum = readU16(input);
   const unsigned short pointSize = 2 * (m_precision == PRECISION_16BIT ? 2 : 4) + 1;
   input->seek(2, librevenge::RVNG_SEEK_CUR);
   if (pointNum > getRemainingLength(input) / pointSize)
@@ -1042,14 +1042,14 @@ void libcdr::CDRParser::readLineAndCurve(librevenge::RVNGInputStream *input)
   std::vector<unsigned char> pointTypes;
   points.reserve(pointNum);
   pointTypes.reserve(pointNum);
-  for (unsigned j=0; j<pointNum; j++)
+  for (unsigned long j=0; j<pointNum; j++)
   {
     std::pair<double, double> point;
     point.first = (double)readCoordinate(input);
     point.second = (double)readCoordinate(input);
     points.push_back(point);
   }
-  for (unsigned k=0; k<pointNum; k++)
+  for (unsigned long k=0; k<pointNum; k++)
     pointTypes.push_back(readU8(input));
   outputPath(points, pointTypes);
 }
@@ -1059,7 +1059,7 @@ void libcdr::CDRParser::readPath(librevenge::RVNGInputStream *input)
   CDR_DEBUG_MSG(("CDRParser::readPath\n"));
 
   input->seek(4, librevenge::RVNG_SEEK_CUR);
-  unsigned short pointNum = readU16(input)+readU16(input);
+  unsigned long pointNum = readU16(input)+readU16(input);
   const unsigned short pointSize = 2 * (m_precision == PRECISION_16BIT ? 2 : 4) + 1;
   const unsigned long maxLength = getRemainingLength(input);
   if (maxLength < 16)
@@ -1071,14 +1071,14 @@ void libcdr::CDRParser::readPath(librevenge::RVNGInputStream *input)
   std::vector<unsigned char> pointTypes;
   points.reserve(pointNum);
   pointTypes.reserve(pointNum);
-  for (unsigned j=0; j<pointNum; j++)
+  for (unsigned long j=0; j<pointNum; j++)
   {
     std::pair<double, double> point;
     point.first = (double)readCoordinate(input);
     point.second = (double)readCoordinate(input);
     points.push_back(point);
   }
-  for (unsigned k=0; k<pointNum; k++)
+  for (unsigned long k=0; k<pointNum; k++)
     pointTypes.push_back(readU8(input));
   outputPath(points, pointTypes);
 }
@@ -1092,7 +1092,7 @@ void libcdr::CDRParser::readArrw(librevenge::RVNGInputStream *input, unsigned le
     throw GenericException();
   unsigned arrowId = readU32(input);
   input->seek(4, librevenge::RVNG_SEEK_CUR);
-  unsigned short pointNum = readU16(input);
+  unsigned long pointNum = readU16(input);
   const unsigned short pointSize = 2 * (m_precision == PRECISION_16BIT ? 2 : 4) + 1;
   const unsigned long maxLength = getRemainingLength(input);
   if (maxLength < 5)
@@ -1102,12 +1102,12 @@ void libcdr::CDRParser::readArrw(librevenge::RVNGInputStream *input, unsigned le
   input->seek(4, librevenge::RVNG_SEEK_CUR);
   std::vector<unsigned char> pointTypes;
   pointTypes.reserve(pointSize);
-  for (unsigned k=0; k<pointNum; k++)
+  for (unsigned long k=0; k<pointNum; k++)
     pointTypes.push_back(readU8(input));
   input->seek(1, librevenge::RVNG_SEEK_CUR);
   std::vector<std::pair<double, double> > points;
   points.reserve(pointSize);
-  for (unsigned j=0; j<pointNum; j++)
+  for (unsigned long j=0; j<pointNum; j++)
   {
     std::pair<double, double> point;
     point.second = (double)readCoordinate(input);
@@ -1164,7 +1164,7 @@ void libcdr::CDRParser::readBitmap(librevenge::RVNGInputStream *input)
     else
       input->seek(20, librevenge::RVNG_SEEK_CUR);
 
-    unsigned short pointNum = readU16(input);
+    unsigned long pointNum = readU16(input);
     input->seek(2, librevenge::RVNG_SEEK_CUR);
     const unsigned short pointSize = 2 * (m_precision == PRECISION_16BIT ? 2 : 4) + 1;
     if (pointNum > getRemainingLength(input) / pointSize)
@@ -1173,14 +1173,14 @@ void libcdr::CDRParser::readBitmap(librevenge::RVNGInputStream *input)
     std::vector<unsigned char> pointTypes;
     points.reserve(pointNum);
     pointTypes.reserve(pointNum);
-    for (unsigned j=0; j<pointNum; j++)
+    for (unsigned long j=0; j<pointNum; j++)
     {
       std::pair<double, double> point;
       point.first = (double)readCoordinate(input);
       point.second = (double)readCoordinate(input);
       points.push_back(point);
     }
-    for (unsigned k=0; k<pointNum; k++)
+    for (unsigned long k=0; k<pointNum; k++)
       pointTypes.push_back(readU8(input));
     outputPath(points, pointTypes);
   }
@@ -1199,7 +1199,7 @@ void libcdr::CDRParser::readWaldoOutl(librevenge::RVNGInputStream *input)
   libcdr::CDRColor color = readColor(input);
   input->seek(7, librevenge::RVNG_SEEK_CUR);
   unsigned short numDash = readU8(input);
-  int fixPosition = input->tell();
+  long fixPosition = input->tell();
   std::vector<unsigned> dashArray;
   for (unsigned short i = 0; i < numDash; ++i)
     dashArray.push_back(readU8(input));
@@ -1696,13 +1696,13 @@ void libcdr::CDRParser::readOutl(librevenge::RVNGInputStream *input, unsigned le
     input->seek(10, librevenge::RVNG_SEEK_CUR);
   else
     input->seek(16, librevenge::RVNG_SEEK_CUR);
-  unsigned short numDash = readU16(input);
+  unsigned long numDash = readU16(input);
   if (numDash > getRemainingLength(input) / 2)
     numDash = getRemainingLength(input) / 2;
-  int fixPosition = input->tell();
+  long fixPosition = input->tell();
   std::vector<unsigned> dashArray;
   dashArray.reserve(numDash);
-  for (unsigned short i = 0; i < numDash; ++i)
+  for (unsigned long i = 0; i < numDash; ++i)
     dashArray.push_back(readU16(input));
   if (m_version < 600)
     input->seek(fixPosition + 20, librevenge::RVNG_SEEK_SET);
@@ -1862,7 +1862,7 @@ void libcdr::CDRParser::readPolygonCoords(librevenge::RVNGInputStream *input)
 {
   CDR_DEBUG_MSG(("CDRParser::readPolygonCoords\n"));
 
-  unsigned short pointNum = readU16(input);
+  unsigned long pointNum = readU16(input);
   const unsigned short pointSize = 2 * (m_precision == PRECISION_16BIT ? 2 : 4) + 1;
   if (pointNum > getRemainingLength(input) / pointSize)
     pointNum = getRemainingLength(input) / pointSize;
@@ -1871,14 +1871,14 @@ void libcdr::CDRParser::readPolygonCoords(librevenge::RVNGInputStream *input)
   std::vector<unsigned char> pointTypes;
   points.reserve(pointNum);
   pointTypes.reserve(pointNum);
-  for (unsigned j=0; j<pointNum; j++)
+  for (unsigned long j=0; j<pointNum; j++)
   {
     std::pair<double, double> point;
     point.first = (double)readCoordinate(input);
     point.second = (double)readCoordinate(input);
     points.push_back(point);
   }
-  for (unsigned k=0; k<pointNum; k++)
+  for (unsigned long k=0; k<pointNum; k++)
     pointTypes.push_back(readU8(input));
   outputPath(points, pointTypes);
   m_collector->collectPolygon();
@@ -2012,7 +2012,7 @@ void libcdr::CDRParser::readPpdt(librevenge::RVNGInputStream *input, unsigned le
 {
   if (!_redirectX6Chunk(&input, length))
     throw GenericException();
-  unsigned short pointNum = readU16(input);
+  unsigned long pointNum = readU16(input);
   const unsigned short pointSize = 2 * (m_precision == PRECISION_16BIT ? 2 : 4) + 4;
   if (pointNum > getRemainingLength(input) / pointSize)
     pointNum = getRemainingLength(input) / pointSize;
@@ -2021,14 +2021,14 @@ void libcdr::CDRParser::readPpdt(librevenge::RVNGInputStream *input, unsigned le
   std::vector<unsigned> knotVector;
   points.reserve(pointNum);
   knotVector.reserve(pointNum);
-  for (unsigned j=0; j<pointNum; j++)
+  for (unsigned long j=0; j<pointNum; j++)
   {
     std::pair<double, double> point;
     point.first = (double)readCoordinate(input);
     point.second = (double)readCoordinate(input);
     points.push_back(point);
   }
-  for (unsigned k=0; k<pointNum; k++)
+  for (unsigned long k=0; k<pointNum; k++)
     knotVector.push_back(readU32(input));
   m_collector->collectPpdt(points, knotVector);
 }
@@ -2207,14 +2207,13 @@ void libcdr::CDRParser::readStlt(librevenge::RVNGInputStream *input, unsigned le
     CDR_DEBUG_MSG(("CDRParser::readStlt numRecords 0x%x\n", numRecords));
     if (!numRecords)
       return;
-    unsigned numFills = readU32(input);
+    unsigned long numFills = readU32(input);
     const unsigned fillSize = 3 * 4 + (m_version >= 1300 ? 48 : 0);
     if (numFills > getRemainingLength(input) / fillSize)
       numFills = getRemainingLength(input) / fillSize;
     CDR_DEBUG_MSG(("CDRParser::readStlt numFills 0x%x\n", numFills));
-    unsigned i = 0;
     std::map<unsigned, unsigned> fillIds;
-    for (i=0; i<numFills; ++i)
+    for (unsigned long i=0; i<numFills; ++i)
     {
       unsigned fillId = readU32(input);
       input->seek(4, librevenge::RVNG_SEEK_CUR);
@@ -2222,25 +2221,25 @@ void libcdr::CDRParser::readStlt(librevenge::RVNGInputStream *input, unsigned le
       if (m_version >= 1300)
         input->seek(48, librevenge::RVNG_SEEK_CUR);
     }
-    unsigned numOutls = readU32(input);
+    unsigned long numOutls = readU32(input);
     if (numOutls > getRemainingLength(input) / 12)
       numOutls = getRemainingLength(input) / 12;
     CDR_DEBUG_MSG(("CDRParser::readStlt numOutls 0x%x\n", numOutls));
     std::map<unsigned, unsigned> outlIds;
-    for (i=0; i<numOutls; ++i)
+    for (unsigned long i=0; i<numOutls; ++i)
     {
       unsigned outlId = readU32(input);
       input->seek(4, librevenge::RVNG_SEEK_CUR);
       outlIds[outlId] = readU32(input);
     }
-    unsigned numFonts = readU32(input);
+    unsigned long numFonts = readU32(input);
     const unsigned fontsSize = 4 + 2 * 2 + 8 + (m_precision == PRECISION_16BIT ? 2 : 4) + 2 * (m_version < 1000 ? 12 : 20);
     if (numFonts > getRemainingLength(input) / fontsSize)
       numFonts = getRemainingLength(input) / fontsSize;
     CDR_DEBUG_MSG(("CDRParser::readStlt numFonts 0x%x\n", numFonts));
     std::map<unsigned,unsigned short> fontIds, fontEncodings;
     std::map<unsigned,double> fontSizes;
-    for (i=0; i<numFonts; ++i)
+    for (unsigned long i=0; i<numFonts; ++i)
     {
       unsigned fontStyleId = readU32(input);
       if (m_version < 1000)
@@ -2256,12 +2255,12 @@ void libcdr::CDRParser::readStlt(librevenge::RVNGInputStream *input, unsigned le
       else
         input->seek(20, librevenge::RVNG_SEEK_CUR);
     }
-    unsigned numAligns = readU32(input);
+    unsigned long numAligns = readU32(input);
     if (numAligns > getRemainingLength(input) / 12)
       numAligns = getRemainingLength(input) / 12;
     std::map<unsigned,unsigned> aligns;
     CDR_DEBUG_MSG(("CDRParser::readStlt numAligns 0x%x\n", numAligns));
-    for (i=0; i<numAligns; ++i)
+    for (unsigned long i=0; i<numAligns; ++i)
     {
       unsigned alignId = readU32(input);
       input->seek(4, librevenge::RVNG_SEEK_CUR);
@@ -2278,7 +2277,7 @@ void libcdr::CDRParser::readStlt(librevenge::RVNGInputStream *input, unsigned le
     input->seek(784 * static_cast<long>(numTabs), librevenge::RVNG_SEEK_CUR);
     unsigned numBullets = readU32(input);
     CDR_DEBUG_MSG(("CDRParser::readStlt numBullets 0x%x\n", numBullets));
-    for (i=0; i<numBullets && getRemainingLength(input) >= 16; ++i)
+    for (unsigned i=0; i<numBullets && getRemainingLength(input) >= 16; ++i)
     {
       input->seek(40, librevenge::RVNG_SEEK_CUR);
       if (m_version > 1300)
@@ -2300,13 +2299,13 @@ void libcdr::CDRParser::readStlt(librevenge::RVNGInputStream *input, unsigned le
         input->seek(8, librevenge::RVNG_SEEK_CUR);
       }
     }
-    unsigned numIndents = readU32(input);
+    unsigned long numIndents = readU32(input);
     const unsigned indentSize = 4 + 3 * (m_precision == PRECISION_16BIT ? 2 : 4);
     if (numIndents > getRemainingLength(input) / indentSize)
       numIndents = getRemainingLength(input) / indentSize;
     std::map<unsigned, double> rightIndents, firstIndents, leftIndents;
     CDR_DEBUG_MSG(("CDRParser::readStlt numIndents 0x%x\n", numIndents));
-    for (i=0; i<numIndents; ++i)
+    for (unsigned long i=0; i<numIndents; ++i)
     {
       unsigned indentId = readU32(input);
       input->seek(12, librevenge::RVNG_SEEK_CUR);
@@ -2334,7 +2333,7 @@ void libcdr::CDRParser::readStlt(librevenge::RVNGInputStream *input, unsigned le
         input->seek(12 * static_cast<long>(numSet11s), librevenge::RVNG_SEEK_CUR);
       }
       std::map<unsigned, CDRStltRecord> styles;
-      for (i=0; i<numRecords && getRemainingLength(input) >= 32; ++i)
+      for (unsigned i=0; i<numRecords && getRemainingLength(input) >= 32; ++i)
       {
         CDR_DEBUG_MSG(("CDRParser::readStlt parsing styles\n"));
         unsigned num = readU32(input);
@@ -2641,21 +2640,21 @@ void libcdr::CDRParser::readTxsm(librevenge::RVNGInputStream *input, unsigned le
         }
         styles[2*i] = style;
       }
-      unsigned numChars = readU32(input);
+      unsigned long numChars = readU32(input);
       const unsigned charSize = m_version >= 1200 ? 8 : 4;
       if (numChars > getRemainingLength(input) / charSize)
         numChars = getRemainingLength(input) / charSize;
       std::vector<unsigned char> charDescriptions(numChars);
-      for (unsigned i = 0; i < numChars; ++i)
+      for (unsigned long i = 0; i < numChars; ++i)
       {
         unsigned tmpCharDescription = 0;
         if (m_version >= 1200)
           tmpCharDescription = readU64(input) & 0xffffffff;
         else
           tmpCharDescription = readU32(input);
-        charDescriptions[i] = (tmpCharDescription >> 16) | (tmpCharDescription & 0x01);
+        charDescriptions[i] = (unsigned char)((tmpCharDescription >> 16) | (tmpCharDescription & 0x01));
       }
-      unsigned numBytes = numChars;
+      unsigned long numBytes = numChars;
       if (m_version >= 1200)
         numBytes = readU32(input);
       unsigned long numBytesRead = 0;
@@ -2777,7 +2776,7 @@ void libcdr::CDRParser::readTxsm16(librevenge::RVNGInputStream *input)
       {
         unsigned tmpCharDescription = 0;
         tmpCharDescription = readU64(input) & 0xffffffff;
-        charDescriptions[i] = (tmpCharDescription >> 16) | (tmpCharDescription & 0x01);
+        charDescriptions[i] = (unsigned char)((tmpCharDescription >> 16) | (tmpCharDescription & 0x01));
       }
       unsigned numBytes = readU32(input);
       unsigned long numBytesRead = 0;
@@ -2961,19 +2960,19 @@ void libcdr::CDRParser::readTxsm5(librevenge::RVNGInputStream *input)
       input->seek(14, librevenge::RVNG_SEEK_CUR);
       styles[2*i] = style;
     }
-    unsigned numChars = readU16(input);
+    unsigned long numChars = readU16(input);
     if (numChars > getRemainingLength(input) / 8)
       numChars = getRemainingLength(input) / 8;
     std::vector<unsigned char> textData;
     std::vector<unsigned char> charDescriptions;
     textData.reserve(numChars);
     charDescriptions.reserve(numChars);
-    for (unsigned i=0; i<numChars; ++i)
+    for (unsigned long i=0; i<numChars; ++i)
     {
       input->seek(4, librevenge::RVNG_SEEK_CUR);
       textData.push_back(readU8(input));
       input->seek(1, librevenge::RVNG_SEEK_CUR);
-      charDescriptions.push_back((readU16(input) >> 3) & 0xff);
+      charDescriptions.push_back((unsigned char)((readU16(input) >> 3) & 0xff));
     }
     if (!textData.empty())
       m_collector->collectText(textId, stlId, textData, charDescriptions, styles);
@@ -3119,7 +3118,7 @@ void libcdr::CDRParser::readParagraphText(librevenge::RVNGInputStream *input)
   m_collector->collectParagraphText(0.0, 0.0, width, height);
 }
 
-void libcdr::CDRParser::_readX6StyleString(librevenge::RVNGInputStream *input, unsigned length, libcdr::CDRStyle &style)
+void libcdr::CDRParser::_readX6StyleString(librevenge::RVNGInputStream *input, unsigned long length, libcdr::CDRStyle &style)
 {
   if (length > getRemainingLength(input))
   {
@@ -3161,7 +3160,7 @@ void libcdr::CDRParser::_readX6StyleString(librevenge::RVNGInputStream *input, u
     boost::optional<std::string> fontName = pt.get_optional<std::string>("character.latin.font");
     if (!!fontName)
       style.m_fontName = fontName.get().c_str();
-    unsigned short encoding = pt.get("character.latin.charset", 0);
+    unsigned short encoding = (unsigned short)(pt.get("character.latin.charset", 0));
     if (encoding || style.m_charSet == (unsigned short)-1)
       style.m_charSet = encoding;
     processNameForEncoding(style.m_fontName, style.m_charSet);
@@ -3259,7 +3258,7 @@ void libcdr::CDRParser::_resolveColorPalette(libcdr::CDRColor &color)
   unsigned char k = 100;
 
   unsigned short ix = color.m_colorValue & 0xffff;
-  unsigned short tint = (color.m_colorValue >> 16) & 0xffff;
+  unsigned short tint = (unsigned short)((color.m_colorValue >> 16) & 0xffff);
 
   if (color.m_colorModel == 0x19)
   {
diff --git a/src/lib/CDRParser.h b/src/lib/CDRParser.h
index 75acc0e..b14f100 100644
--- a/src/lib/CDRParser.h
+++ b/src/lib/CDRParser.h
@@ -93,7 +93,7 @@ private:
   void readParagraphText(librevenge::RVNGInputStream *input);
 
   bool _redirectX6Chunk(librevenge::RVNGInputStream **input, unsigned &length);
-  void _readX6StyleString(librevenge::RVNGInputStream *input, unsigned length, CDRStyle &style);
+  void _readX6StyleString(librevenge::RVNGInputStream *input, unsigned long length, CDRStyle &style);
   void _skipX3Optional(librevenge::RVNGInputStream *input);
   void _resolveColorPalette(CDRColor &color);
 
diff --git a/src/lib/CDRPath.cpp b/src/lib/CDRPath.cpp
index cb45f67..e060ebd 100644
--- a/src/lib/CDRPath.cpp
+++ b/src/lib/CDRPath.cpp
@@ -40,7 +40,7 @@ static void getEllipticalArcBBox(double x0, double y0,
   if (ry < 0.0)
     ry *= -1.0;
 
-  if (rx == 0.0 || ry == 0.0)
+  if (CDR_ALMOST_ZERO(rx) || CDR_ALMOST_ZERO(ry))
   {
     xmin = (x0 < x ? x0 : x);
     xmax = (x0 > x ? x0 : x);
@@ -83,7 +83,7 @@ static void getEllipticalArcBBox(double x0, double y0,
 
   double txmin, txmax, tymin, tymax;
 
-  if (phi == 0 || phi == M_PI)
+  if (CDR_ALMOST_ZERO(phi) || CDR_ALMOST_EQUAL(phi, M_PI))
   {
     xmin = cx - rx;
     txmin = getAngle(-rx, 0);
@@ -94,7 +94,7 @@ static void getEllipticalArcBBox(double x0, double y0,
     ymax = cy + ry;
     tymax = getAngle(0, ry);
   }
-  else if (phi == M_PI / 2.0 || phi == 3.0*M_PI/2.0)
+  else if (CDR_ALMOST_EQUAL(phi, M_PI / 2.0) || CDR_ALMOST_EQUAL(phi, 3.0*M_PI/2.0))
   {
     xmin = cx - ry;
     txmin = getAngle(-ry, 0);
@@ -166,7 +166,7 @@ static inline double quadraticExtreme(double t, double a, double b, double c)
 static inline double quadraticDerivative(double a, double b, double c)
 {
   double denominator = a - 2.0*b + c;
-  if (fabs(denominator) != 0.0)
+  if (!CDR_ALMOST_ZERO(denominator))
     return (a - b)/denominator;
   return -1.0;
 }
@@ -501,7 +501,7 @@ void CDRSplineToElement::writeOut(librevenge::RVNGPropertyListVector &vec) const
    * The NURBS Book, 2nd Edition, 1997
    */
 
-  unsigned m = m_points.size() + CDR_SPLINE_DEGREE + 1;
+  unsigned long m = m_points.size() + CDR_SPLINE_DEGREE + 1;
   unsigned a = CDR_SPLINE_DEGREE;
   unsigned b = CDR_SPLINE_DEGREE + 1;
   std::vector< std::pair<double, double> > Qw(CDR_SPLINE_DEGREE+1), NextQw(CDR_SPLINE_DEGREE+1);
diff --git a/src/lib/CDRStylesCollector.cpp b/src/lib/CDRStylesCollector.cpp
index 3222a34..daeb295 100644
--- a/src/lib/CDRStylesCollector.cpp
+++ b/src/lib/CDRStylesCollector.cpp
@@ -70,7 +70,7 @@ void libcdr::CDRStylesCollector::collectBmp(unsigned imageId, unsigned colorMode
   writeU32(image, 0); // ColorsImportant
 
   // Cater for eventual padding
-  unsigned lineWidth = bitmap.size() / height;
+  unsigned long lineWidth = bitmap.size() / height;
 
   bool storeBMP = true;
 
@@ -103,18 +103,18 @@ void libcdr::CDRStylesCollector::collectBmp(unsigned imageId, unsigned colorMode
       {
         unsigned char c = bitmap[j*lineWidth+i];
         i++;
-        writeU32(image, m_ps.getBMPColor(libcdr::CDRColor(colorModel, c)));
+        writeU32(image, m_ps.getBMPColor(libcdr::CDRColor((unsigned short)colorModel, c)));
       }
     }
     else if (!palette.empty())
     {
       while (i < lineWidth && i < width)
       {
-        unsigned char c = bitmap[j*lineWidth+i];
+        unsigned long c = bitmap[j*lineWidth+i];
         if (c >= palette.size())
           c = palette.size() - 1;
         i++;
-        writeU32(image, m_ps.getBMPColor(libcdr::CDRColor(colorModel, palette[c])));
+        writeU32(image, m_ps.getBMPColor(libcdr::CDRColor((unsigned short)colorModel, palette[c])));
       }
     }
     else if (bpp == 24 && lineWidth >= 3)
@@ -123,7 +123,7 @@ void libcdr::CDRStylesCollector::collectBmp(unsigned imageId, unsigned colorMode
       {
         unsigned c = ((unsigned)bitmap[j*lineWidth+i+2] << 16) | ((unsigned)bitmap[j*lineWidth+i+1] << 8) | ((unsigned)bitmap[j*lineWidth+i]);
         i += 3;
-        writeU32(image, m_ps.getBMPColor(libcdr::CDRColor(colorModel, c)));
+        writeU32(image, m_ps.getBMPColor(libcdr::CDRColor((unsigned short)colorModel, c)));
         k++;
       }
     }
@@ -133,7 +133,7 @@ void libcdr::CDRStylesCollector::collectBmp(unsigned imageId, unsigned colorMode
       {
         unsigned c = (bitmap[j*lineWidth+i+3] << 24) | (bitmap[j*lineWidth+i+2] << 16) | (bitmap[j*lineWidth+i+1] << 8) | (bitmap[j*lineWidth+i]);
         i += 4;
-        writeU32(image, m_ps.getBMPColor(libcdr::CDRColor(colorModel, c)));
+        writeU32(image, m_ps.getBMPColor(libcdr::CDRColor((unsigned short)colorModel, c)));
         k++;
       }
     }
diff --git a/src/lib/CDRTypes.h b/src/lib/CDRTypes.h
index 9144592..6225a62 100644
--- a/src/lib/CDRTypes.h
+++ b/src/lib/CDRTypes.h
@@ -166,7 +166,7 @@ struct CDRStyle
       m_fontSize = override.m_fontSize;
     if (override.m_align)
       m_align = override.m_align;
-    if (override.m_leftIndent != 0.0 && override.m_firstIndent != 0.0 && override.m_rightIndent != 0.0)
+    if (!CDR_ALMOST_ZERO(override.m_leftIndent) && !CDR_ALMOST_ZERO(override.m_firstIndent) && !CDR_ALMOST_ZERO(override.m_rightIndent))
     {
       m_leftIndent = override.m_leftIndent;
       m_firstIndent = override.m_firstIndent;
diff --git a/src/lib/CMXParser.cpp b/src/lib/CMXParser.cpp
index 02852c9..f87bb91 100644
--- a/src/lib/CMXParser.cpp
+++ b/src/lib/CMXParser.cpp
@@ -47,7 +47,7 @@ uint16_t readTagLength(librevenge::RVNGInputStream *const input, const bool bigE
 }
 
 void sanitizeNumRecords(
-  unsigned &numRecords,
+  unsigned long &numRecords,
   const libcdr::CoordinatePrecision precision, const unsigned size16, const unsigned size32,
   const unsigned long remainingLength)
 {
@@ -61,7 +61,7 @@ void sanitizeNumRecords(
 }
 
 void sanitizeNumRecords(
-  unsigned &numRecords,
+  unsigned long &numRecords,
   const libcdr::CoordinatePrecision precision, const unsigned size16, const unsigned size32, const unsigned tags,
   const unsigned long remainingLength)
 {
@@ -116,7 +116,7 @@ bool libcdr::CMXParser::parseRecord(librevenge::RVNGInputStream *input, unsigned
     else
       return true;
     unsigned fourCC = readU32(input, m_bigEndian);
-    unsigned length = readU32(input, m_bigEndian);
+    unsigned long length = readU32(input, m_bigEndian);
     const unsigned long maxLength = getRemainingLength(input);
     if (length > maxLength)
       length = maxLength;
@@ -134,7 +134,7 @@ bool libcdr::CMXParser::parseRecord(librevenge::RVNGInputStream *input, unsigned
       input->seek(4, librevenge::RVNG_SEEK_CUR);
 #endif
       CDR_DEBUG_MSG(("CMX listType: %s\n", toFourCC(listType)));
-      unsigned dataSize = length-4;
+      unsigned long dataSize = length-4;
       if (!parseRecords(input, dataSize, level+1))
         return false;
     }
@@ -167,7 +167,7 @@ void libcdr::CMXParser::parseImage(librevenge::RVNGInputStream *input)
     else
       return;
     unsigned fourCC = readU32(input, m_bigEndian);
-    unsigned length = readU32(input, m_bigEndian);
+    unsigned long length = readU32(input, m_bigEndian);
     const unsigned long maxLength = getRemainingLength(input);
     if (length > maxLength)
       length = maxLength;
@@ -179,7 +179,7 @@ void libcdr::CMXParser::parseImage(librevenge::RVNGInputStream *input)
     CDR_DEBUG_MSG(("CMX listType: %s\n", toFourCC(listType)));
     if (listType != CDR_FOURCC_imag)
       return;
-    unsigned dataSize = length-4;
+    unsigned long dataSize = length-4;
     if (!parseRecords(input, dataSize, (unsigned)-1))
       return;
 
@@ -191,7 +191,7 @@ void libcdr::CMXParser::parseImage(librevenge::RVNGInputStream *input)
   }
 }
 
-void libcdr::CMXParser::readRecord(unsigned fourCC, unsigned &length, librevenge::RVNGInputStream *input)
+void libcdr::CMXParser::readRecord(unsigned fourCC, unsigned long length, librevenge::RVNGInputStream *input)
 {
   long recordEnd = input->tell() + length;
   switch (fourCC)
@@ -293,7 +293,7 @@ void libcdr::CMXParser::readDisp(librevenge::RVNGInputStream *input)
   unsigned fourCC = readU32(input, m_bigEndian);
   if (CDR_FOURCC_DISP != fourCC)
     return;
-  unsigned length = readU32(input, m_bigEndian);
+  unsigned long length = readU32(input, m_bigEndian);
   const unsigned long maxLength = getRemainingLength(input);
   if (length > maxLength)
     length = maxLength;
@@ -314,7 +314,7 @@ void libcdr::CMXParser::readDisp(librevenge::RVNGInputStream *input)
 
   long startPosition = input->tell();
   input->seek(0x18, librevenge::RVNG_SEEK_CUR);
-  int lengthX = length + 10 - readU32(input, m_bigEndian);
+  unsigned long lengthX = length + 10 - readU32(input, m_bigEndian);
   input->seek(startPosition, librevenge::RVNG_SEEK_SET);
 
   previewImage.append((unsigned char)((lengthX) & 0x000000ff));
@@ -323,7 +323,7 @@ void libcdr::CMXParser::readDisp(librevenge::RVNGInputStream *input)
   previewImage.append((unsigned char)(((lengthX) & 0xff000000) >> 24));
 
   input->seek(4, librevenge::RVNG_SEEK_CUR);
-  for (unsigned i = 4; i<length; i++)
+  for (unsigned long i = 4; i<length; i++)
     previewImage.append(readU8(input, m_bigEndian));
 #if DUMP_PREVIEW_IMAGE
   FILE *f = fopen("previewImage.bmp", "wb");
@@ -354,11 +354,11 @@ void libcdr::CMXParser::readIxmr(librevenge::RVNGInputStream *input)
 
   readU16(input, m_bigEndian); // Master ID
   readU16(input, m_bigEndian); // Size
-  unsigned short recordCount = readU16(input, m_bigEndian);
+  unsigned long recordCount = readU16(input, m_bigEndian);
   if (recordCount > getRemainingLength(input) / 6)
     recordCount = getRemainingLength(input) / 6;
   std::map<unsigned short, unsigned> offsets;
-  for (unsigned short i = 1; i <= recordCount; ++i)
+  for (unsigned long i = 1; i <= recordCount; ++i)
   {
     unsigned short indexRecordId = readU16(input, m_bigEndian);
     unsigned offset = readU32(input, m_bigEndian);
@@ -590,7 +590,7 @@ void libcdr::CMXParser::readBeginGroup(librevenge::RVNGInputStream *input)
 void libcdr::CMXParser::readPolyCurve(librevenge::RVNGInputStream *input)
 {
   m_collector->collectObject(1);
-  unsigned pointNum = 0;
+  unsigned long pointNum = 0;
   std::vector<std::pair<double, double> > points;
   std::vector<unsigned char> pointTypes;
   if (m_precision == libcdr::PRECISION_32BIT)
@@ -619,14 +619,14 @@ void libcdr::CMXParser::readPolyCurve(librevenge::RVNGInputStream *input)
           pointNum = getRemainingLength(input) / (2 * 4 + 1);
         points.reserve(pointNum);
         pointTypes.reserve(pointNum);
-        for (unsigned i = 0; i < pointNum; ++i)
+        for (unsigned long i = 0; i < pointNum; ++i)
         {
           std::pair<double, double> point;
           point.first = readCoordinate(input, m_bigEndian);
           point.second = readCoordinate(input, m_bigEndian);
           points.push_back(point);
         }
-        for (unsigned j = 0; j < pointNum; ++j)
+        for (unsigned long j = 0; j < pointNum; ++j)
           pointTypes.push_back(readU8(input, m_bigEndian));
         break;
       default:
@@ -645,14 +645,14 @@ void libcdr::CMXParser::readPolyCurve(librevenge::RVNGInputStream *input)
     const unsigned long maxPoints = getRemainingLength(input) / (2 * 2 + 1);
     if (pointNum > maxPoints)
       pointNum = maxPoints;
-    for (unsigned i = 0; i < pointNum; ++i)
+    for (unsigned long i = 0; i < pointNum; ++i)
     {
       std::pair<double, double> point;
       point.first = readCoordinate(input, m_bigEndian);
       point.second = readCoordinate(input, m_bigEndian);
       points.push_back(point);
     }
-    for (unsigned j = 0; j < pointNum; ++j)
+    for (unsigned long j = 0; j < pointNum; ++j)
       pointTypes.push_back(readU8(input, m_bigEndian));
   }
   else
@@ -729,7 +729,7 @@ void libcdr::CMXParser::readEllipse(librevenge::RVNGInputStream *input)
     return;
 
   CDRPath path;
-  if (angle1 != angle2)
+  if (!CDR_ALMOST_EQUAL(angle1,angle2))
   {
     if (angle2 < angle1)
       angle2 += 2*M_PI;
@@ -1006,11 +1006,11 @@ libcdr::CDRBox libcdr::CMXParser::readBBox(librevenge::RVNGInputStream *input)
 
 librevenge::RVNGString libcdr::CMXParser::readString(librevenge::RVNGInputStream *input)
 {
-  unsigned short count = readU16(input, m_bigEndian);
+  unsigned long count = readU16(input, m_bigEndian);
   if (count > getRemainingLength(input))
     count = getRemainingLength(input);
   librevenge::RVNGString tmpString;
-  for (unsigned short i = 0; i < count; ++i)
+  for (unsigned long i = 0; i < count; ++i)
     tmpString.append((char)readU8(input, m_bigEndian));
   return tmpString;
 }
@@ -1143,10 +1143,10 @@ bool libcdr::CMXParser::readFill(librevenge::RVNGInputStream *input)
         }
         case CMX_Tag_RenderAttr_FillSpec_Fountain_Color:
         {
-          unsigned short colorCount = readU16(input, m_bigEndian);
+          unsigned long colorCount = readU16(input, m_bigEndian);
           if (colorCount > getRemainingLength(input) / 4)
             colorCount = getRemainingLength(input) / 4;
-          for (unsigned short i = 0; i < colorCount; ++i)
+          for (unsigned long i = 0; i < colorCount; ++i)
           {
             unsigned short colorRef = readU16(input, m_bigEndian);
             unsigned short offset = readU16(input, m_bigEndian);
@@ -1176,10 +1176,10 @@ bool libcdr::CMXParser::readFill(librevenge::RVNGInputStream *input)
       gradient.m_centerYOffset = readS16(input, m_bigEndian);
       /* unsigned short steps = */ readU16(input, m_bigEndian);
       gradient.m_mode = (unsigned char)(readU16(input, m_bigEndian) & 0xff);
-      unsigned short colorCount = readU16(input, m_bigEndian);
+      unsigned long colorCount = readU16(input, m_bigEndian);
       if (colorCount > getRemainingLength(input) / 4)
         colorCount = getRemainingLength(input) / 4;
-      for (unsigned short i = 0; i < colorCount; ++i)
+      for (unsigned long i = 0; i < colorCount; ++i)
       {
         unsigned short colorRef = readU16(input, m_bigEndian);
         unsigned short offset = readU16(input, m_bigEndian);
@@ -1198,10 +1198,10 @@ bool libcdr::CMXParser::readFill(librevenge::RVNGInputStream *input)
     else if (m_precision == libcdr::PRECISION_16BIT)
     {
       /* unsigned atom = */ readU32(input, m_bigEndian);
-      unsigned short count = readU16(input, m_bigEndian);
+      unsigned long count = readU16(input, m_bigEndian);
       if (count > getRemainingLength(input) / 2)
         count = getRemainingLength(input) / 2;
-      for (unsigned short i = 0; i < count; ++i)
+      for (unsigned long i = 0; i < count; ++i)
         readU16(input, m_bigEndian);
       readString(input);
     }
@@ -1234,7 +1234,7 @@ bool libcdr::CMXParser::readFill(librevenge::RVNGInputStream *input)
           double tileOffsetX = (double)readU16(input, m_bigEndian) / 100.0;
           double tileOffsetY = (double)readU16(input, m_bigEndian) / 100.0;
           double rcpOffset = (double)readU16(input, m_bigEndian) / 100.0;
-          unsigned char flags = readU16(input, m_bigEndian) & 0xff;
+          unsigned char flags = (unsigned char)(readU16(input, m_bigEndian) & 0xff);
           input->seek(1, librevenge::RVNG_SEEK_CUR); // CMX_Tag_EndTag
           double patternWidth = (double)tmpWidth / 254000.0;
           double patternHeight = (double)tmpHeight / 254000.0;
@@ -1267,7 +1267,7 @@ bool libcdr::CMXParser::readFill(librevenge::RVNGInputStream *input)
       double tileOffsetX = (double)readU16(input, m_bigEndian) / 100.0;
       double tileOffsetY = (double)readU16(input, m_bigEndian) / 100.0;
       double rcpOffset = (double)readU16(input, m_bigEndian) / 100.0;
-      unsigned char flags = readU16(input, m_bigEndian) & 0xff;
+      unsigned char flags = (unsigned char)(readU16(input, m_bigEndian) & 0xff);
       double patternWidth = (double)tmpWidth / 1000.0;
       double patternHeight = (double)tmpHeight / 1000.0;
       bool isRelative = false;
@@ -1311,7 +1311,7 @@ bool libcdr::CMXParser::readFill(librevenge::RVNGInputStream *input)
           double tileOffsetX = (double)readU16(input, m_bigEndian) / 100.0;
           double tileOffsetY = (double)readU16(input, m_bigEndian) / 100.0;
           double rcpOffset = (double)readU16(input, m_bigEndian) / 100.0;
-          unsigned char flags = readU16(input, m_bigEndian) & 0xff;
+          unsigned char flags = (unsigned char)(readU16(input, m_bigEndian) & 0xff);
           input->seek(1, librevenge::RVNG_SEEK_CUR); // CMX_Tag_EndTag
           double patternWidth = (double)tmpWidth / 254000.0;
           double patternHeight = (double)tmpHeight / 254000.0;
@@ -1342,7 +1342,7 @@ bool libcdr::CMXParser::readFill(librevenge::RVNGInputStream *input)
       double tileOffsetX = (double)readU16(input, m_bigEndian) / 100.0;
       double tileOffsetY = (double)readU16(input, m_bigEndian) / 100.0;
       double rcpOffset = (double)readU16(input, m_bigEndian) / 100.0;
-      unsigned char flags = readU16(input, m_bigEndian) & 0xff;
+      unsigned char flags = (unsigned char)(readU16(input, m_bigEndian) & 0xff);
       double patternWidth = (double)tmpWidth / 1000.0;
       double patternHeight = (double)tmpHeight / 1000.0;
       bool isRelative = false;
@@ -1396,7 +1396,7 @@ bool libcdr::CMXParser::readFill(librevenge::RVNGInputStream *input)
               double tileOffsetX = (double)readU16(input, m_bigEndian) / 100.0;
               double tileOffsetY = (double)readU16(input, m_bigEndian) / 100.0;
               double rcpOffset = (double)readU16(input, m_bigEndian) / 100.0;
-              unsigned char flags = readU16(input, m_bigEndian) & 0xff;
+              unsigned char flags = (unsigned char)(readU16(input, m_bigEndian) & 0xff);
               input->seek(1, librevenge::RVNG_SEEK_CUR); // CMX_Tag_EndTag
               double patternWidth = (double)tmpWidth / 254000.0;
               double patternHeight = (double)tmpHeight / 254000.0;
@@ -1434,7 +1434,7 @@ bool libcdr::CMXParser::readFill(librevenge::RVNGInputStream *input)
       double tileOffsetX = (double)readU16(input, m_bigEndian) / 100.0;
       double tileOffsetY = (double)readU16(input, m_bigEndian) / 100.0;
       double rcpOffset = (double)readU16(input, m_bigEndian) / 100.0;
-      unsigned char flags = readU16(input, m_bigEndian) & 0xff;
+      unsigned char flags = (unsigned char)(readU16(input, m_bigEndian) & 0xff);
       double patternWidth = (double)tmpWidth / 1000.0;
       double patternHeight = (double)tmpHeight / 1000.0;
       bool isRelative = false;
@@ -1451,10 +1451,10 @@ bool libcdr::CMXParser::readFill(librevenge::RVNGInputStream *input)
       /* librevenge::RVNGString lib = */ readString(input);
       /* librevenge::RVNGString name = */ readString(input);
       /* librevenge::RVNGString stl = */ readString(input);
-      unsigned short count = readU16(input, m_bigEndian);
+      unsigned long count = readU16(input, m_bigEndian);
       if (count > getRemainingLength(input) / 8)
         count = getRemainingLength(input) / 8;
-      for (unsigned short i = 0; i < count; ++i)
+      for (unsigned long i = 0; i < count; ++i)
       {
         readU16(input, m_bigEndian);
         readU16(input, m_bigEndian);
@@ -1469,7 +1469,7 @@ bool libcdr::CMXParser::readFill(librevenge::RVNGInputStream *input)
       return false;
     break;
   }
-  m_collector->collectFillStyle(fillId, CDRFillStyle(fillType, color1, color2, gradient, imageFill));
+  m_collector->collectFillStyle(fillId, CDRFillStyle((unsigned short)fillType, color1, color2, gradient, imageFill));
   m_collector->collectFillStyleId(fillId);
   return true;
 }
@@ -1688,7 +1688,7 @@ void libcdr::CMXParser::readRclr(librevenge::RVNGInputStream *input)
     return;
   /* unsigned length = */ readU32(input, m_bigEndian);
 
-  unsigned numRecords = readU16(input, m_bigEndian);
+  unsigned long numRecords = readU16(input, m_bigEndian);
   CDR_DEBUG_MSG(("CMXParser::readRclr - numRecords %i\n", numRecords));
   sanitizeNumRecords(numRecords, m_precision, 2, 2 + 0, 2, getRemainingLength(input));
   for (unsigned j = 1; j <= numRecords; ++j)
@@ -1739,7 +1739,7 @@ void libcdr::CMXParser::readRdot(librevenge::RVNGInputStream *input)
     return;
   /* unsigned length = */ readU32(input, m_bigEndian);
 
-  unsigned numRecords = readU16(input, m_bigEndian);
+  unsigned long numRecords = readU16(input, m_bigEndian);
   CDR_DEBUG_MSG(("CMXParser::readRdot - numRecords %i\n", numRecords));
   sanitizeNumRecords(numRecords, m_precision, 2, 2, 1, getRemainingLength(input));
   for (unsigned j = 1; j <= numRecords; ++j)
@@ -1759,10 +1759,10 @@ void libcdr::CMXParser::readRdot(librevenge::RVNGInputStream *input)
         {
         case CMX_Tag_DescrSection_Dash:
         {
-          unsigned short dotCount = readU16(input, m_bigEndian);
+          unsigned long dotCount = readU16(input, m_bigEndian);
           if (dotCount > getRemainingLength(input) / 2)
             dotCount = getRemainingLength(input) / 2;
-          for (unsigned short i = 0; i < dotCount; ++i)
+          for (unsigned long i = 0; i < dotCount; ++i)
             dots.push_back(readU16(input, m_bigEndian));
           break;
         }
@@ -1775,10 +1775,10 @@ void libcdr::CMXParser::readRdot(librevenge::RVNGInputStream *input)
     }
     else if (m_precision == libcdr::PRECISION_16BIT)
     {
-      unsigned short dotCount = readU16(input, m_bigEndian);
+      unsigned long dotCount = readU16(input, m_bigEndian);
       if (dotCount > getRemainingLength(input) / 2)
         dotCount = getRemainingLength(input) / 2;
-      for (unsigned short i = 0; i < dotCount; ++i)
+      for (unsigned long i = 0; i < dotCount; ++i)
         dots.push_back(readU16(input, m_bigEndian));
     }
     else
@@ -1794,7 +1794,7 @@ void libcdr::CMXParser::readRott(librevenge::RVNGInputStream *input)
     return;
   /* unsigned length = */ readU32(input, m_bigEndian);
 
-  unsigned numRecords = readU16(input, m_bigEndian);
+  unsigned long numRecords = readU16(input, m_bigEndian);
   CDR_DEBUG_MSG(("CMXParser::readRott - numRecords %i\n", numRecords));
   sanitizeNumRecords(numRecords, m_precision, 2, 2, 1, getRemainingLength(input));
   for (unsigned j = 1; j <= numRecords; ++j)
@@ -1843,7 +1843,7 @@ void libcdr::CMXParser::readRotl(librevenge::RVNGInputStream *input)
     return;
   /* unsigned length = */ readU32(input, m_bigEndian);
 
-  unsigned numRecords = readU16(input, m_bigEndian);
+  unsigned long numRecords = readU16(input, m_bigEndian);
   CDR_DEBUG_MSG(("CMXParser::readRotl - numRecords %i\n", numRecords));
   sanitizeNumRecords(numRecords, m_precision, 12, 12, 1, getRemainingLength(input));
   for (unsigned j = 1; j <= numRecords; ++j)
@@ -1900,7 +1900,7 @@ void libcdr::CMXParser::readRpen(librevenge::RVNGInputStream *input)
     return;
   /* unsigned length = */ readU32(input, m_bigEndian);
 
-  unsigned numRecords = readU16(input, m_bigEndian);
+  unsigned long numRecords = readU16(input, m_bigEndian);
   CDR_DEBUG_MSG(("CMXParser::readRpen - numRecords %i\n", numRecords));
   sanitizeNumRecords(numRecords, m_precision, 10, 12, 1, getRemainingLength(input));
   for (unsigned j = 1; j <= numRecords; ++j)
@@ -1954,7 +1954,7 @@ void libcdr::CMXParser::readIxtl(librevenge::RVNGInputStream *input)
     return;
   /* unsigned length = */ readU32(input, m_bigEndian);
 
-  unsigned numRecords = readU16(input, m_bigEndian);
+  unsigned long numRecords = readU16(input, m_bigEndian);
   CDR_DEBUG_MSG(("CMXParser::readIxtl - numRecords %i\n", numRecords));
   int sizeInFile(0);
   if (m_precision == libcdr::PRECISION_32BIT)
@@ -1999,7 +1999,7 @@ void libcdr::CMXParser::readIxef(librevenge::RVNGInputStream *input)
     return;
   /* unsigned length = */ readU32(input, m_bigEndian);
 
-  unsigned numRecords = readU16(input, m_bigEndian);
+  unsigned long numRecords = readU16(input, m_bigEndian);
   CDR_DEBUG_MSG(("CMXParser::readIxef - numRecords %i\n", numRecords));
   sanitizeNumRecords(numRecords, m_precision, 6, 8, getRemainingLength(input));
   for (unsigned j = 1; j <= numRecords; ++j)
@@ -2036,7 +2036,7 @@ void libcdr::CMXParser::readIxpg(librevenge::RVNGInputStream *input)
     return;
   /* unsigned length = */ readU32(input, m_bigEndian);
 
-  unsigned numRecords = readU16(input, m_bigEndian);
+  unsigned long numRecords = readU16(input, m_bigEndian);
   CDR_DEBUG_MSG(("CMXParser::readIxpg - numRecords %i\n", numRecords));
   sanitizeNumRecords(numRecords, m_precision, 16, 18, getRemainingLength(input));
   for (unsigned j = 1; j <= numRecords; ++j)
@@ -2359,7 +2359,7 @@ libcdr::CDRLineStyle libcdr::CMXParser::getLineStyle(unsigned id)
   if (iterPen != m_parserState.m_pens.end())
   {
     tmpLineStyle.lineWidth = iterPen->second.m_width * (iterPen->second.m_matrix.getScaleX()+iterPen->second.m_matrix.getScaleY())/ 2.0;
-    if (iterPen->second.m_matrix.getScaleY() != 0)
+    if (!CDR_ALMOST_ZERO(iterPen->second.m_matrix.getScaleY()))
       tmpLineStyle.stretch = iterPen->second.m_matrix.getScaleX()/iterPen->second.m_matrix.getScaleY();
     else
       tmpLineStyle.stretch = 1.0;
diff --git a/src/lib/CMXParser.h b/src/lib/CMXParser.h
index ffdb861..01d436a 100644
--- a/src/lib/CMXParser.h
+++ b/src/lib/CMXParser.h
@@ -114,7 +114,7 @@ private:
   CMXParser(const CMXParser &);
   CMXParser &operator=(const CMXParser &);
   bool parseRecord(librevenge::RVNGInputStream *input, unsigned level = 0);
-  void readRecord(unsigned fourCC, unsigned &length, librevenge::RVNGInputStream *input);
+  void readRecord(unsigned fourCC, unsigned long length, librevenge::RVNGInputStream *input);
   void parseImage(librevenge::RVNGInputStream *input);
 
   void readCMXHeader(librevenge::RVNGInputStream *input);
@@ -167,7 +167,7 @@ private:
   double m_scale;
   double m_xmin, m_xmax, m_ymin, m_ymax;
   unsigned m_fillIndex;
-  unsigned m_nextInstructionOffset;
+  unsigned long m_nextInstructionOffset;
   CMXParserState &m_parserState;
   CMXImageInfo m_currentImageInfo;
   std::unique_ptr<CDRPattern> m_currentPattern;
diff --git a/src/lib/CommonParser.cpp b/src/lib/CommonParser.cpp
index d604a39..0f37646 100644
--- a/src/lib/CommonParser.cpp
+++ b/src/lib/CommonParser.cpp
@@ -149,11 +149,11 @@ void libcdr::CommonParser::readRImage(unsigned &colorModel, unsigned &width, uns
   {
     palette.clear();
     input->seek(2, librevenge::RVNG_SEEK_CUR);
-    unsigned short palettesize = readU16(input);
+    unsigned long palettesize = readU16(input);
     if (palettesize > getRemainingLength(input) / 3)
       palettesize = getRemainingLength(input) / 3;
     palette.reserve(palettesize);
-    for (unsigned short i = 0; i <palettesize; ++i)
+    for (unsigned long i = 0; i <palettesize; ++i)
     {
       unsigned b = readU8(input);
       unsigned g = readU8(input);
diff --git a/src/lib/libcdr_utils.cpp b/src/lib/libcdr_utils.cpp
index c900b0a..d92e62d 100644
--- a/src/lib/libcdr_utils.cpp
+++ b/src/lib/libcdr_utils.cpp
@@ -97,7 +97,7 @@ static unsigned short getEncodingFromICUName(const char *name)
   return 0;
 }
 
-static unsigned short getEncoding(const unsigned char *buffer, unsigned bufferLength)
+static unsigned short getEncoding(const unsigned char *buffer, unsigned long bufferLength)
 {
   if (!buffer)
     return 0;
@@ -109,7 +109,7 @@ static unsigned short getEncoding(const unsigned char *buffer, unsigned bufferLe
     if (U_FAILURE(status) || !csd)
       return 0;
     ucsdet_enableInputFilter(csd, true);
-    ucsdet_setText(csd, (const char *)buffer, bufferLength, &status);
+    ucsdet_setText(csd, (const char *)buffer, (unsigned)bufferLength, &status);
     if (U_FAILURE(status))
       throw libcdr::EncodingException();
     const UCharsetMatch *csm = ucsdet_detect(csd, &status);
@@ -189,8 +189,8 @@ uint16_t libcdr::readU16(librevenge::RVNGInputStream *input, bool bigEndian)
   if (p && numBytesRead == sizeof(uint16_t))
   {
     if (bigEndian)
-      return (uint16_t)p[1]|((uint16_t)p[0]<<8);
-    return (uint16_t)p[0]|((uint16_t)p[1]<<8);
+      return (uint16_t)(p[1]|((uint16_t)p[0]<<8));
+    return (uint16_t)(p[0]|((uint16_t)p[1]<<8));
   }
   CDR_DEBUG_MSG(("Throwing EndOfStreamException\n"));
   throw EndOfStreamException();
diff --git a/src/lib/libcdr_utils.h b/src/lib/libcdr_utils.h
index 52871e3..5f3fccb 100644
--- a/src/lib/libcdr_utils.h
+++ b/src/lib/libcdr_utils.h
@@ -29,6 +29,7 @@
 
 #define CDR_EPSILON 1E-6
 #define CDR_ALMOST_ZERO(m) (fabs(m) <= CDR_EPSILON)
+#define CDR_ALMOST_EQUAL(m, n) CDR_ALMOST_ZERO(m-n)
 
 #if defined(HAVE_FUNC_ATTRIBUTE_FORMAT)
 #  define CDR_ATTRIBUTE_PRINTF(fmt, arg) __attribute__((__format__(__printf__, fmt, arg)))
commit 059e890e4289ffaa1971f0159c167ccb997c5795
Author:     Fridrich Štrba <fridrich.strba at bluewin.ch>
AuthorDate: Mon Mar 29 10:47:56 2021 +0200
Commit:     Fridrich Štrba <fridrich.strba at bluewin.ch>
CommitDate: Mon Mar 29 10:47:56 2021 +0200

    We don't want to enumerate all lcms enum values when we use only 2
    
    Change-Id: If3f8bddd56c5336092297797c91674b434ffa4e5

diff --git a/configure.ac b/configure.ac
index 4e316de..9b2dd6c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -259,7 +259,7 @@ AS_IF([test "x$native_win32" = "xyes"], [
 			CXXFLAGS="$CXXFLAGS -Wpointer-arith -Wredundant-decls -Wreturn-type"
 			CXXFLAGS="$CXXFLAGS -Wsequence-point -Wsign-compare -Wstrict-aliasing"
 			CXXFLAGS="$CXXFLAGS -Wstrict-aliasing=2 -Wswitch -Wswitch-default"
-			CXXFLAGS="$CXXFLAGS -Wswitch-enum -Wtrigraphs -Wunknown-pragmas -Wunused"
+			CXXFLAGS="$CXXFLAGS -Wtrigraphs -Wunknown-pragmas -Wunused"
 			CXXFLAGS="$CXXFLAGS -Wunused-function -Wunused-label -Wunused-parameter"
 			CXXFLAGS="$CXXFLAGS -Wunused-value -Wvariadic-macros"
 			CXXFLAGS="$CXXFLAGS -Wvolatile-register-var -Wwrite-strings"


More information about the Libreoffice-commits mailing list