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

David Tardon dtardon at redhat.com
Tue Jul 21 02:48:15 PDT 2015


 src/lib/Makefile.am        |   55 ++++++++++++++++++++++-----------------------
 src/lib/VSDStyles.h        |    2 -
 src/lib/VSDXParser.cpp     |    3 +-
 src/test/data/bgcolor.vsdx |binary
 src/test/importtest.cpp    |   34 +++++++++++++++++++++++++++
 5 files changed, 64 insertions(+), 30 deletions(-)

New commits:
commit f8392b3160f7b64263b324bf49b654007b98f80a
Author: David Tardon <dtardon at redhat.com>
Date:   Tue Jul 21 11:39:48 2015 +0200

    sort file list
    
    Change-Id: Ie7e75271d0e02b5dd5cac01269365268c57269d4

diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index f5968fd..dc0f8fd 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -26,61 +26,60 @@ libvisio_ at VSD_MAJOR_VERSION@_ at VSD_MINOR_VERSION@_la_LIBADD  = $(LIBVISIO_LIBS) @
 libvisio_ at VSD_MAJOR_VERSION@_ at VSD_MINOR_VERSION@_la_DEPENDENCIES = @LIBVISIO_WIN32_RESOURCE@
 libvisio_ at VSD_MAJOR_VERSION@_ at VSD_MINOR_VERSION@_la_LDFLAGS = $(version_info) -export-dynamic -no-undefined
 libvisio_ at VSD_MAJOR_VERSION@_ at VSD_MINOR_VERSION@_la_SOURCES = \
-	libvisio_utils.cpp \
-	libvisio_xml.cpp \
-	VisioDocument.cpp \
+	VDXParser.cpp \
+	VDXParser.h \
 	VSD5Parser.cpp \
-	VSD6Parser.cpp \
-	VSDInternalStream.cpp \
-	VSDCharacterList.cpp \
-	VSDContentCollector.cpp \
-	VSDFieldList.cpp \
-	VSDGeometryList.cpp \
-	VSDOutputElementList.cpp \
-	VSDPages.cpp \
-	VSDParagraphList.cpp \
-	VSDParser.cpp \
-	VSDMetaData.cpp \
-	VSDShapeList.cpp \
-	VSDStencils.cpp \
-	VSDStyles.cpp \
-	VSDStylesCollector.cpp \
-	VSDXMLHelper.cpp \
-	libvisio_utils.h \
-	libvisio_xml.h \
 	VSD5Parser.h \
+	VSD6Parser.cpp \
 	VSD6Parser.h \
-	VSDInternalStream.h \
+	VSDCharacterList.cpp \
 	VSDCharacterList.h \
 	VSDCollector.h \
+	VSDContentCollector.cpp \
 	VSDContentCollector.h \
 	VSDDocumentStructure.h \
+	VSDFieldList.cpp \
 	VSDFieldList.h \
+	VSDGeometryList.cpp \
 	VSDGeometryList.h \
+	VSDInternalStream.cpp \
+	VSDInternalStream.h \
+	VSDMetaData.cpp \
+	VSDMetaData.h \
+	VSDOutputElementList.cpp \
 	VSDOutputElementList.h \
+	VSDPages.cpp \
 	VSDPages.h \
+	VSDParagraphList.cpp \
 	VSDParagraphList.h \
+	VSDParser.cpp \
 	VSDParser.h \
-	VSDMetaData.h \
+	VSDShapeList.cpp \
 	VSDShapeList.h \
+	VSDStencils.cpp \
 	VSDStencils.h \
+	VSDStyles.cpp \
 	VSDStyles.h \
+	VSDStylesCollector.cpp \
 	VSDStylesCollector.h \
 	VSDTypes.h \
+	VSDXMLHelper.cpp \
 	VSDXMLHelper.h \
-	 \
-	VDXParser.cpp \
-	VDXParser.h \
 	VSDXMLParserBase.cpp \
 	VSDXMLParserBase.h \
 	VSDXMLTokenMap.cpp \
 	VSDXMLTokenMap.h \
+	VSDXMetaData.cpp \
+	VSDXMetaData.h \
 	VSDXParser.cpp \
 	VSDXParser.h \
 	VSDXTheme.cpp \
 	VSDXTheme.h \
-	VSDXMetaData.cpp \
-	VSDXMetaData.h \
+	VisioDocument.cpp \
+	libvisio_utils.cpp \
+	libvisio_utils.h \
+	libvisio_xml.cpp \
+	libvisio_xml.h \
 	$(generated_files)
 	
 
commit c1a5828d135b89ffb80cb096bce5f0aa745a265d
Author: Andras Timar <andras.timar at collabora.com>
Date:   Mon Jun 29 22:55:48 2015 +0200

    unit test of VSDX char background handling
    
    Change-Id: I4a57aa9465827108630ec85f5986bdd59e1a8f5c

diff --git a/src/test/data/bgcolor.vsdx b/src/test/data/bgcolor.vsdx
new file mode 100644
index 0000000..5081dd5
Binary files /dev/null and b/src/test/data/bgcolor.vsdx differ
diff --git a/src/test/importtest.cpp b/src/test/importtest.cpp
index f7b8972..705a8c7 100644
--- a/src/test/importtest.cpp
+++ b/src/test/importtest.cpp
@@ -66,6 +66,30 @@ void assertXPath(xmlDocPtr doc, const librevenge::RVNGString &xpath, const libre
   CPPUNIT_ASSERT_EQUAL_MESSAGE(message.cstr(), expectedValue, actualValue);
 }
 
+/// Assert that xpath exists, and does not contain the given attribute
+void assertXPathNoAttribute(xmlDocPtr doc, const librevenge::RVNGString &xpath, const librevenge::RVNGString &attribute)
+{
+  xmlXPathObjectPtr xpathobject = getXPathNode(doc, xpath);
+  xmlNodeSetPtr nodeset = xpathobject->nodesetval;
+  librevenge::RVNGString message1("In <");
+  message1.append(doc->name);
+  message1.append(">, XPath '");
+  message1.append(xpath);
+  message1.append("' number of nodes is incorrect");
+  CPPUNIT_ASSERT_EQUAL_MESSAGE(message1.cstr(), 1, xmlXPathNodeSetGetLength(nodeset));
+  xmlNodePtr node = nodeset->nodeTab[0];
+  librevenge::RVNGString message2("In <");
+  message2.append(doc->name);
+  message2.append(">, XPath '");
+  message2.append(xpath);
+  message2.append("' unexpected '");
+  message2.append(attribute);
+  message2.append("' attribute");
+  CPPUNIT_ASSERT_EQUAL_MESSAGE(message2.cstr(), static_cast<xmlChar*>(0), xmlGetProp(node, BAD_CAST(attribute.cstr())));
+  xmlXPathFreeObject(xpathobject);
+}
+
+
 #if 0 // keep for future use
 /// Same as the assertXPathContent(), but don't assert: return the string instead.
 librevenge::RVNGString getXPathContent(xmlDocPtr doc, const librevenge::RVNGString &xpath)
@@ -127,6 +151,7 @@ class ImportTest : public CPPUNIT_NS::TestFixture
   CPPUNIT_TEST(testVsdUserDefinedMetadata);
   CPPUNIT_TEST(testVsdxUserDefinedMetadata);
   CPPUNIT_TEST(testVsdxImportBgColorFromTheme);
+  CPPUNIT_TEST(testVsdxCharBgColor);
   CPPUNIT_TEST_SUITE_END();
 
   void testVsdxMetadataTitle();
@@ -135,6 +160,7 @@ class ImportTest : public CPPUNIT_NS::TestFixture
   void testVsdUserDefinedMetadata();
   void testVsdxUserDefinedMetadata();
   void testVsdxImportBgColorFromTheme();
+  void testVsdxCharBgColor();
 
   xmlBufferPtr m_buffer;
   xmlDocPtr m_doc;
@@ -238,6 +264,14 @@ void ImportTest::testVsdxImportBgColorFromTheme()
   assertXPath(m_doc, "/document/page/layer[7]//setStyle[2]", "fill-color", "#5b9bd5");
 }
 
+void ImportTest::testVsdxCharBgColor()
+{
+  m_doc = parse("bgcolor.vsdx", m_buffer);
+  assertXPathNoAttribute(m_doc, "/document/page/layer/textObject/paragraph/span", "background-color");
+  assertXPath(m_doc, "/document/page/layer/layer[2]/textObject/paragraph/span", "background-color", "#9dbb61");
+  assertXPath(m_doc, "/document/page/layer/layer[2]/layer[2]/textObject/paragraph/span", "background-color", "#9dbb61");
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(ImportTest);
 
 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
commit 251f18076a9429a88b10b42a76fdb1d5b6bc22e1
Author: Andras Timar <andras.timar at collabora.com>
Date:   Mon Jun 29 22:53:54 2015 +0200

    tdf#92271 fix VSDX char background handling
    
    When char background is not set, we should not export white.
    When char background is set, we should export that color, not black.
    Unfortunately transparency is not supported in ODF.
    
    Change-Id: I805f06c8907243576a137152ac663dba40e720fb

diff --git a/src/lib/VSDStyles.h b/src/lib/VSDStyles.h
index 425d5ff..0d6519a 100644
--- a/src/lib/VSDStyles.h
+++ b/src/lib/VSDStyles.h
@@ -426,7 +426,7 @@ struct VSDTextBlockStyle
 {
   VSDTextBlockStyle() :
     leftMargin(0.0), rightMargin(0.0), topMargin(0.0), bottomMargin(0.0), verticalAlign(1),
-    isTextBkgndFilled(true), textBkgndColour(0xff,0xff,0xff,0), defaultTabStop(0.5), textDirection(0) {}
+    isTextBkgndFilled(false), textBkgndColour(0xff,0xff,0xff,0), defaultTabStop(0.5), textDirection(0) {}
   VSDTextBlockStyle(double lm, double rm, double tm, double bm, unsigned char va,
                     bool isBgFilled, Colour bgClr, double defTab, unsigned char td) :
     leftMargin(lm), rightMargin(rm), topMargin(tm), bottomMargin(bm), verticalAlign(va),
diff --git a/src/lib/VSDXParser.cpp b/src/lib/VSDXParser.cpp
index 33f5695..a72bd73 100644
--- a/src/lib/VSDXParser.cpp
+++ b/src/lib/VSDXParser.cpp
@@ -929,7 +929,7 @@ int libvisio::VSDXParser::getElementDepth(xmlTextReaderPtr reader)
 void libvisio::VSDXParser::readShapeProperties(xmlTextReaderPtr reader)
 {
   // Text block properties
-  long bgClrId = 0;
+  long bgClrId = -1;
 
   int ret = 1;
   int tokenId = XML_TOKEN_INVALID;
@@ -1203,6 +1203,7 @@ void libvisio::VSDXParser::readShapeProperties(xmlTextReaderPtr reader)
             textBkgndColour = Colour(0xff, 0xff, 0xff, 0);
         }
         m_shape.m_textBlockStyle.textBkgndColour = textBkgndColour;
+        m_shape.m_textBlockStyle.isTextBkgndFilled = true;
       }
       break;
     case XML_DEFAULTTABSTOP:


More information about the Libreoffice-commits mailing list