[Libreoffice-commits] libmspub.git: 4 commits - src/lib

David Tardon dtardon at redhat.com
Tue Jan 9 16:06:28 UTC 2018


 src/lib/MSPUBCollector.cpp |    2 +-
 src/lib/MSPUBParser.cpp    |   14 +++++++++-----
 src/lib/MSPUBTypes.h       |   12 ++++++------
 3 files changed, 16 insertions(+), 12 deletions(-)

New commits:
commit 796f5e1f01b1a654964dfd8551cb1eaaa3a51287
Author: David Tardon <dtardon at redhat.com>
Date:   Tue Jan 9 17:05:28 2018 +0100

    ofz#4951 do not shift signed value
    
    Change-Id: I6c2a48589fe6a585ce37c57a59d06c7e5ef31b25

diff --git a/src/lib/MSPUBParser.cpp b/src/lib/MSPUBParser.cpp
index 8a4ada7..30b6e7d 100644
--- a/src/lib/MSPUBParser.cpp
+++ b/src/lib/MSPUBParser.cpp
@@ -2032,7 +2032,7 @@ std::shared_ptr<Fill> MSPUBParser::getNewFill(const std::map<unsigned short, uns
     const unsigned *ptr_fillOpacity = getIfExists_const(foptProperties, FIELDID_FILL_OPACITY);
     const unsigned *ptr_fillBackOpacity = getIfExists_const(foptProperties, FIELDID_FILL_BACK_OPACITY);
     const unsigned *ptr_fillFocus = getIfExists_const(foptProperties, FIELDID_FILL_FOCUS);
-    short fillFocus = ptr_fillFocus ? ((int)(*ptr_fillFocus) << 16) >> 16 : 0;
+    short fillFocus = ptr_fillFocus ? int((*ptr_fillFocus << 16) >> 16) : 0;
     angle = ptr_angle ? *ptr_angle : 0;
     angle >>= 16; //it's actually only 16 bits
     // Don't try to figure out what sense the following switch statement makes.
commit 035c728fc49b86c68bf8c8db9a13be1590c04b1a
Author: David Tardon <dtardon at redhat.com>
Date:   Tue Jan 9 16:55:21 2018 +0100

    ofz#4916 fix division by 0
    
    Change-Id: I629399bb0790b27e71bea9cd89485ecd471830d8

diff --git a/src/lib/MSPUBParser.cpp b/src/lib/MSPUBParser.cpp
index 1b1be01..8a4ada7 100644
--- a/src/lib/MSPUBParser.cpp
+++ b/src/lib/MSPUBParser.cpp
@@ -1952,7 +1952,11 @@ void MSPUBParser::parseEscherShape(librevenge::RVNGInputStream *input, const Esc
           {
             input->seek(cAnchor.contentsOffset, librevenge::RVNG_SEEK_SET);
             int coordSystemWidth = thisParentCoordinateSystem.m_xe - thisParentCoordinateSystem.m_xs;
+            if (coordSystemWidth == 0)
+              coordSystemWidth = 1;
             int coordSystemHeight = thisParentCoordinateSystem.m_ye - thisParentCoordinateSystem.m_ys;
+            if (coordSystemHeight == 0)
+              coordSystemHeight = 1;
             int groupWidth = parentGroupAbsoluteCoord.m_xe - parentGroupAbsoluteCoord.m_xs;
             int groupHeight = parentGroupAbsoluteCoord.m_ye - parentGroupAbsoluteCoord.m_ys;
             double widthScale = (double)groupWidth / coordSystemWidth;
commit ab9002c37b6be82e572c354281de9c7d5e636a61
Author: David Tardon <dtardon at redhat.com>
Date:   Tue Jan 9 16:48:38 2018 +0100

    avoid undef. behavior casting arbitrary int to enum
    
    Just pass the values around as unsigned ints and use the enums as
    constant sets. The previous code doesn't add any extra type safety
    anyway.
    
    Change-Id: I914e136136a97cbf411fad7e1bedbbb79a7c49d2

diff --git a/src/lib/MSPUBParser.cpp b/src/lib/MSPUBParser.cpp
index 8a307eb..1b1be01 100644
--- a/src/lib/MSPUBParser.cpp
+++ b/src/lib/MSPUBParser.cpp
@@ -2387,7 +2387,7 @@ bool MSPUBParser::parseContentChunkReference(librevenge::RVNGInputStream *input,
 {
   //input should be at block.dataOffset + 4 , that is, at the beginning of the list of sub-blocks
   MSPUB_DEBUG_MSG(("Parsing chunk reference 0x%x\n", m_lastSeenSeqNum));
-  MSPUBContentChunkType type = UNKNOWN_CHUNK;
+  unsigned type = UNKNOWN_CHUNK;
   unsigned long offset = 0;
   unsigned parentSeqNum = 0;
   bool seenType = false;
@@ -2399,7 +2399,7 @@ bool MSPUBParser::parseContentChunkReference(librevenge::RVNGInputStream *input,
     //FIXME: Warn if multiple of these blocks seen.
     if (subBlock.id == CHUNK_TYPE)
     {
-      type = (MSPUBContentChunkType)subBlock.data;
+      type = subBlock.data;
       seenType = true;
     }
     else if (subBlock.id == CHUNK_OFFSET)
@@ -2498,8 +2498,8 @@ MSPUBBlockInfo MSPUBParser::parseBlock(librevenge::RVNGInputStream *input, bool
 {
   MSPUBBlockInfo info;
   info.startPosition = input->tell();
-  info.id = (MSPUBBlockID)readU8(input);
-  info.type = (MSPUBBlockType)readU8(input);
+  info.id = readU8(input);
+  info.type = readU8(input);
   info.dataOffset = input->tell();
   int len = getBlockDataLength(info.type);
   bool varLen = len < 0;
diff --git a/src/lib/MSPUBTypes.h b/src/lib/MSPUBTypes.h
index 04219d0..d44d020 100644
--- a/src/lib/MSPUBTypes.h
+++ b/src/lib/MSPUBTypes.h
@@ -77,9 +77,9 @@ struct EscherContainerInfo
 
 struct MSPUBBlockInfo
 {
-  MSPUBBlockInfo() : id((MSPUBBlockID)0), type((MSPUBBlockType)0), startPosition(0), dataOffset(0), dataLength(0), data(0), stringData() { }
-  MSPUBBlockID id;
-  MSPUBBlockType type;
+  MSPUBBlockInfo() : id(0), type(0), startPosition(0), dataOffset(0), dataLength(0), data(0), stringData() { }
+  unsigned id;
+  unsigned type;
   unsigned long startPosition;
   unsigned long dataOffset;
   unsigned long dataLength;
@@ -89,10 +89,10 @@ struct MSPUBBlockInfo
 
 struct ContentChunkReference
 {
-  ContentChunkReference() : type(UNKNOWN_CHUNK), offset(0), end(0), seqNum(0), parentSeqNum(0) { }
-  ContentChunkReference(MSPUBContentChunkType t, unsigned long o, unsigned long e, unsigned sn, unsigned psn) :
+  ContentChunkReference() : type(0), offset(0), end(0), seqNum(0), parentSeqNum(0) { }
+  ContentChunkReference(unsigned t, unsigned long o, unsigned long e, unsigned sn, unsigned psn) :
     type(t), offset(o), end(e), seqNum(sn), parentSeqNum(psn) {}
-  MSPUBContentChunkType type;
+  unsigned type;
   unsigned long offset;
   unsigned long end; //offset of the last element plus one.
   unsigned seqNum;
commit 9c252a30064a7968b8e548db46cfa8018d4876c1
Author: David Tardon <dtardon at redhat.com>
Date:   Tue Jan 9 16:08:27 2018 +0100

    ofz#4903 avoid division by 0
    
    Change-Id: I6322d2093e3f4646a238f68ad9beff9a6a6448d0

diff --git a/src/lib/MSPUBCollector.cpp b/src/lib/MSPUBCollector.cpp
index 723955a..350f029 100644
--- a/src/lib/MSPUBCollector.cpp
+++ b/src/lib/MSPUBCollector.cpp
@@ -819,7 +819,7 @@ std::function<void(void)> MSPUBCollector::paintShape(const ShapeInfo &info, cons
   const std::vector<Line> &lines = info.m_lines;
   if (hasStroke)
   {
-    if (hasBorderArt)
+    if (hasBorderArt && lines[0].m_widthInEmu > 0)
     {
       bool stretch = info.m_stretchBorderArt;
       double x = coord.getXIn(m_width);


More information about the Libreoffice-commits mailing list