[Libreoffice-commits] libvisio.git: 2 commits - src/lib

Fridrich Štrba fridrich.strba at bluewin.ch
Sat Apr 16 20:43:11 UTC 2016


 src/lib/VDXParser.cpp           |   16 +++++++++++++++
 src/lib/VSD5Parser.cpp          |    9 ++++++++
 src/lib/VSD5Parser.h            |    2 +
 src/lib/VSD6Parser.cpp          |    9 ++++++++
 src/lib/VSD6Parser.h            |    2 +
 src/lib/VSDContentCollector.cpp |   41 +++++++++++++++++++++++++++++++++++++---
 src/lib/VSDContentCollector.h   |    2 -
 src/lib/VSDParser.h             |    2 -
 src/lib/VSDXMLParserBase.cpp    |   22 +++++++++++++++++++++
 src/lib/VSDXMLParserBase.h      |    1 
 src/lib/VSDXParser.cpp          |   16 +++++++++++++++
 src/lib/tokens.txt              |    2 +
 12 files changed, 119 insertions(+), 5 deletions(-)

New commits:
commit e30e70afdc4a12f2f9ec9e039b82f623447c34cf
Author: Fridrich Štrba <fridrich.strba at bluewin.ch>
Date:   Sat Apr 16 18:56:15 2016 +0200

    Some work in view of parsing of connector information
    
    Change-Id: I4e8ce436e92c1a411960c0a923466206993ab8e3

diff --git a/src/lib/VDXParser.cpp b/src/lib/VDXParser.cpp
index 973e464..9f39ada 100644
--- a/src/lib/VDXParser.cpp
+++ b/src/lib/VDXParser.cpp
@@ -485,6 +485,22 @@ void libvisio::VDXParser::readMisc(xmlTextReaderPtr reader)
       if (XML_READER_TYPE_ELEMENT == tokenType)
         ret = readBoolData(m_shape.m_misc.m_hideText, reader);
       break;
+    case XML_BEGTRIGGER:
+      if (XML_READER_TYPE_ELEMENT == tokenType)
+      {
+        if (!m_shape.m_xform1d)
+          m_shape.m_xform1d = new XForm1D();
+        readTriggerId(m_shape.m_xform1d->beginId, reader);
+      }
+      break;
+    case XML_ENDTRIGGER:
+      if (XML_READER_TYPE_ELEMENT == tokenType)
+      {
+        if (!m_shape.m_xform1d)
+          m_shape.m_xform1d = new XForm1D();
+        readTriggerId(m_shape.m_xform1d->endId, reader);
+      }
+      break;
     default:
       break;
     }
diff --git a/src/lib/VSD5Parser.cpp b/src/lib/VSD5Parser.cpp
index 7900fa5..747be18 100644
--- a/src/lib/VSD5Parser.cpp
+++ b/src/lib/VSD5Parser.cpp
@@ -482,6 +482,15 @@ void libvisio::VSD5Parser::readNameIDX(librevenge::RVNGInputStream *input)
   m_namesMapMap[m_header.level] = names;
 }
 
+void libvisio::VSD5Parser::readMisc(librevenge::RVNGInputStream *input)
+{
+  unsigned char flags = readU8(input);
+  if (flags & 0x20)
+    m_shape.m_misc.m_hideText = true;
+  else
+    m_shape.m_misc.m_hideText = false;
+}
+
 
 unsigned libvisio::VSD5Parser::getUInt(librevenge::RVNGInputStream *input)
 {
diff --git a/src/lib/VSD5Parser.h b/src/lib/VSD5Parser.h
index 914f93d..886cc22 100644
--- a/src/lib/VSD5Parser.h
+++ b/src/lib/VSD5Parser.h
@@ -55,6 +55,8 @@ protected:
 
   virtual void readNameIDX(librevenge::RVNGInputStream *input);
 
+  virtual void readMisc(librevenge::RVNGInputStream *input);
+
   virtual unsigned getUInt(librevenge::RVNGInputStream *input);
   virtual int getInt(librevenge::RVNGInputStream *input);
 
diff --git a/src/lib/VSD6Parser.cpp b/src/lib/VSD6Parser.cpp
index c5d8b79..8f2bb0b 100644
--- a/src/lib/VSD6Parser.cpp
+++ b/src/lib/VSD6Parser.cpp
@@ -399,4 +399,13 @@ void libvisio::VSD6Parser::readTextField(librevenge::RVNGInputStream *input)
   }
 }
 
+void libvisio::VSD6Parser::readMisc(librevenge::RVNGInputStream *input)
+{
+  unsigned char flags = readU8(input);
+  if (flags & 0x20)
+    m_shape.m_misc.m_hideText = true;
+  else
+    m_shape.m_misc.m_hideText = false;
+}
+
 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
diff --git a/src/lib/VSD6Parser.h b/src/lib/VSD6Parser.h
index ea7d072..56e7534 100644
--- a/src/lib/VSD6Parser.h
+++ b/src/lib/VSD6Parser.h
@@ -35,6 +35,8 @@ private:
   virtual void readName2(librevenge::RVNGInputStream *input);
   virtual void readTextField(librevenge::RVNGInputStream *input);
   virtual void readLayerMem(librevenge::RVNGInputStream *input);
+  virtual void readMisc(librevenge::RVNGInputStream *input);
+
 
   VSD6Parser();
   VSD6Parser(const VSDParser &);
diff --git a/src/lib/VSDParser.h b/src/lib/VSDParser.h
index df81d4f..3b11d35 100644
--- a/src/lib/VSDParser.h
+++ b/src/lib/VSDParser.h
@@ -112,7 +112,7 @@ protected:
   virtual void readNameIDX(librevenge::RVNGInputStream *input);
   virtual void readNameIDX123(librevenge::RVNGInputStream *input);
 
-  void readMisc(librevenge::RVNGInputStream *input);
+  virtual void readMisc(librevenge::RVNGInputStream *input);
 
   virtual void readLayerList(librevenge::RVNGInputStream *input);
   virtual void readLayer(librevenge::RVNGInputStream *input);
diff --git a/src/lib/VSDXMLParserBase.cpp b/src/lib/VSDXMLParserBase.cpp
index 7b9dbcb..714399b 100644
--- a/src/lib/VSDXMLParserBase.cpp
+++ b/src/lib/VSDXMLParserBase.cpp
@@ -2215,4 +2215,26 @@ unsigned libvisio::VSDXMLParserBase::getIX(xmlTextReaderPtr reader)
   return ix;
 }
 
+void libvisio::VSDXMLParserBase::readTriggerId(unsigned &id, xmlTextReaderPtr reader)
+{
+  using namespace ::boost::spirit::classic;
+
+  unsigned triggerId = MINUS_ONE;
+  const boost::shared_ptr<xmlChar> triggerString(xmlTextReaderGetAttribute(reader, BAD_CAST("F")), xmlFree);
+  printf("Fridrich A %s\n", (const char *)triggerString.get());
+  if (triggerString)
+  {
+    if (parse((const char *)triggerString.get(),
+              //  Begin grammar
+              (
+                str_p("_XFTRIGGER")
+                >> '(' >> (+(alnum_p|space_p)) >> '.'
+                >> int_p[assign_a(triggerId)] >> '!' >> str_p("EventXFMod")
+              ) >> ')' >> end_p,
+              //  End grammar
+              space_p).full)
+      id = triggerId;
+  }
+}
+
 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
diff --git a/src/lib/VSDXMLParserBase.h b/src/lib/VSDXMLParserBase.h
index 2ee13ec..d53946c 100644
--- a/src/lib/VSDXMLParserBase.h
+++ b/src/lib/VSDXMLParserBase.h
@@ -81,6 +81,7 @@ protected:
   int readNURBSData(boost::optional<NURBSData> &data, xmlTextReaderPtr reader);
   int readPolylineData(boost::optional<PolylineData> &data, xmlTextReaderPtr reader);
   int readStringData(VSDName &text, xmlTextReaderPtr reader);
+  void readTriggerId(unsigned &id, xmlTextReaderPtr reader);
 
   virtual xmlChar *readStringData(xmlTextReaderPtr reader) = 0;
   unsigned getIX(xmlTextReaderPtr reader);
diff --git a/src/lib/VSDXParser.cpp b/src/lib/VSDXParser.cpp
index 22aa719..2f0167e 100644
--- a/src/lib/VSDXParser.cpp
+++ b/src/lib/VSDXParser.cpp
@@ -1065,6 +1065,22 @@ void libvisio::VSDXParser::readShapeProperties(xmlTextReaderPtr reader)
         ret = readDoubleData(m_shape.m_xform1d->beginY, reader);
       }
       break;
+    case XML_BEGTRIGGER:
+      if (XML_READER_TYPE_ELEMENT == tokenType)
+      {
+        if (!m_shape.m_xform1d)
+          m_shape.m_xform1d = new XForm1D();
+        readTriggerId(m_shape.m_xform1d->beginId, reader);
+      }
+      break;
+    case XML_ENDTRIGGER:
+      if (XML_READER_TYPE_ELEMENT == tokenType)
+      {
+        if (!m_shape.m_xform1d)
+          m_shape.m_xform1d = new XForm1D();
+        readTriggerId(m_shape.m_xform1d->endId, reader);
+      }
+      break;
     case XML_ENDX:
       if (XML_READER_TYPE_ELEMENT == tokenType)
       {
diff --git a/src/lib/tokens.txt b/src/lib/tokens.txt
index 4e85524..70d7042 100644
--- a/src/lib/tokens.txt
+++ b/src/lib/tokens.txt
@@ -55,6 +55,7 @@ B
 BeginArrow
 BeginX
 BeginY
+BegTrigger
 BottomMargin
 Bullet
 BulletFont
@@ -91,6 +92,7 @@ E
 Ellipse
 EllipticalArcTo
 EndArrow
+EndTrigger
 EndX
 EndY
 FaceName
commit 51fbff20ccea031a594cff6ed690d6073fa6c351
Author: Fridrich Štrba <fridrich.strba at bluewin.ch>
Date:   Sat Apr 16 12:59:11 2016 +0200

    Use the ids of the shapes
    
    Change-Id: I3d8485e2b48a0c148528d39b85765b603ad3521d

diff --git a/src/lib/VSDContentCollector.cpp b/src/lib/VSDContentCollector.cpp
index 16c7a34..fb216b0 100644
--- a/src/lib/VSDContentCollector.cpp
+++ b/src/lib/VSDContentCollector.cpp
@@ -210,6 +210,7 @@ void libvisio::VSDContentCollector::_flushShape()
   unsigned numPathElements = 0;
   unsigned numForeignElements = 0;
   unsigned numTextElements = 0;
+  unsigned shapeId = m_currentShapeId;
   if (m_fillStyle.pattern && !m_currentFillGeometry.empty())
     numPathElements++;
   if (m_lineStyle.pattern && !m_currentLineGeometry.empty())
@@ -220,11 +221,31 @@ void libvisio::VSDContentCollector::_flushShape()
     numTextElements++;
 
   if (numPathElements+numForeignElements+numTextElements > 1)
-    m_shapeOutputDrawing->addStartLayer(librevenge::RVNGPropertyList());
+  {
+    librevenge::RVNGPropertyList propList;
+    if (shapeId && shapeId != MINUS_ONE)
+    {
+      librevenge::RVNGString stringId;
+      stringId.sprintf("id%u", shapeId);
+      propList.insert("draw:id", stringId);
+      shapeId = MINUS_ONE;
+    }
+    m_shapeOutputDrawing->addStartLayer(propList);
+  }
 
   if (numPathElements > 1 && (numForeignElements || numTextElements))
+  {
+    librevenge::RVNGPropertyList propList;
+    if (shapeId && shapeId != MINUS_ONE)
+    {
+      librevenge::RVNGString stringId;
+      stringId.sprintf("id%u", shapeId);
+      propList.insert("draw:id", stringId);
+      shapeId = MINUS_ONE;
+    }
     m_shapeOutputDrawing->addStartLayer(librevenge::RVNGPropertyList());
-  _flushCurrentPath();
+  }
+  _flushCurrentPath(shapeId);
   if (numPathElements > 1 && (numForeignElements || numTextElements))
     m_shapeOutputDrawing->addEndLayer();
   _flushCurrentForeignData();
@@ -241,7 +262,7 @@ void libvisio::VSDContentCollector::_flushShape()
   m_isShapeStarted = false;
 }
 
-void libvisio::VSDContentCollector::_flushCurrentPath()
+void libvisio::VSDContentCollector::_flushCurrentPath(unsigned shapeId)
 {
   librevenge::RVNGPropertyList styleProps;
   _lineProperties(m_lineStyle, styleProps);
@@ -308,6 +329,13 @@ void libvisio::VSDContentCollector::_flushCurrentPath()
       m_shapeOutputDrawing->addStyle(fillPathProps);
       librevenge::RVNGPropertyList propList;
       propList.insert("svg:d", path);
+      if (shapeId && shapeId != MINUS_ONE)
+      {
+        librevenge::RVNGString stringId;
+        stringId.sprintf("id%u", shapeId);
+        propList.insert("draw:id", stringId);
+        shapeId = MINUS_ONE;
+      }
       _appendVisibleAndPrintable(propList);
       m_shapeOutputDrawing->addPath(propList);
     }
@@ -391,6 +419,13 @@ void libvisio::VSDContentCollector::_flushCurrentPath()
       m_shapeOutputDrawing->addStyle(linePathProps);
       librevenge::RVNGPropertyList propList;
       propList.insert("svg:d", path);
+      if (shapeId && shapeId != MINUS_ONE)
+      {
+        librevenge::RVNGString stringId;
+        stringId.sprintf("id%u", shapeId);
+        propList.insert("draw:id", stringId);
+        shapeId = MINUS_ONE;
+      }
       _appendVisibleAndPrintable(propList);
       m_shapeOutputDrawing->addPath(propList);
     }
diff --git a/src/lib/VSDContentCollector.h b/src/lib/VSDContentCollector.h
index 3e2fb38..4460e35 100644
--- a/src/lib/VSDContentCollector.h
+++ b/src/lib/VSDContentCollector.h
@@ -192,7 +192,7 @@ private:
   double _NURBSBasis(unsigned knot, unsigned degree, double point, const std::vector<double> &knotVector);
 
   void _flushShape();
-  void _flushCurrentPath();
+  void _flushCurrentPath(unsigned id);
   void _flushText();
   void _flushCurrentForeignData();
   void _flushCurrentPage();


More information about the Libreoffice-commits mailing list