[Libreoffice-commits] libcdr.git: 3 commits - .gitignore src/lib
David Tardon
dtardon at redhat.com
Fri Dec 25 06:23:33 PST 2015
.gitignore | 1 +
src/lib/CDRContentCollector.cpp | 23 +++++++++++++----------
src/lib/CDRParser.cpp | 2 +-
src/lib/CDRStylesCollector.cpp | 8 ++++----
src/lib/libcdr_utils.cpp | 12 ++++++++++++
src/lib/libcdr_utils.h | 14 ++++++++++++--
6 files changed, 43 insertions(+), 17 deletions(-)
New commits:
commit 96efcc9a1a166c0e8c94282b84bdd5094401ce68
Author: David Tardon <dtardon at redhat.com>
Date: Fri Dec 25 15:01:42 2015 +0100
tdf#67873 do not drop empty text lines
Change-Id: I667ff13e01ae3b47b62267ad0c911d9d806d0cb6
diff --git a/src/lib/CDRContentCollector.cpp b/src/lib/CDRContentCollector.cpp
index ae51b44..15abc1f 100644
--- a/src/lib/CDRContentCollector.cpp
+++ b/src/lib/CDRContentCollector.cpp
@@ -493,16 +493,19 @@ void libcdr::CDRContentCollector::_flushCurrentPath()
outputElement.addOpenParagraph(paraProps);
for (unsigned j = 0; j < (*m_currentText)[i].m_line.size(); ++j)
{
- librevenge::RVNGPropertyList spanProps;
- double fontSize = (double)cdr_round(144.0*(*m_currentText)[i].m_line[j].m_charStyle.m_fontSize) / 2.0;
- spanProps.insert("fo:font-size", fontSize, librevenge::RVNG_POINT);
- if ((*m_currentText)[i].m_line[j].m_charStyle.m_fontName.len())
- spanProps.insert("style:font-name", (*m_currentText)[i].m_line[j].m_charStyle.m_fontName);
- if ((*m_currentText)[i].m_line[j].m_charStyle.m_fillStyle.fillType != (unsigned short)-1)
- spanProps.insert("fo:color", m_ps.getRGBColorString((*m_currentText)[i].m_line[j].m_charStyle.m_fillStyle.color1));
- outputElement.addOpenSpan(spanProps);
- outputElement.addInsertText((*m_currentText)[i].m_line[j].m_text);
- outputElement.addCloseSpan();
+ if (!(*m_currentText)[i].m_line[j].m_text.empty())
+ {
+ librevenge::RVNGPropertyList spanProps;
+ double fontSize = (double)cdr_round(144.0*(*m_currentText)[i].m_line[j].m_charStyle.m_fontSize) / 2.0;
+ spanProps.insert("fo:font-size", fontSize, librevenge::RVNG_POINT);
+ if ((*m_currentText)[i].m_line[j].m_charStyle.m_fontName.len())
+ spanProps.insert("style:font-name", (*m_currentText)[i].m_line[j].m_charStyle.m_fontName);
+ if ((*m_currentText)[i].m_line[j].m_charStyle.m_fillStyle.fillType != (unsigned short)-1)
+ spanProps.insert("fo:color", m_ps.getRGBColorString((*m_currentText)[i].m_line[j].m_charStyle.m_fillStyle.color1));
+ outputElement.addOpenSpan(spanProps);
+ outputElement.addInsertText((*m_currentText)[i].m_line[j].m_text);
+ outputElement.addCloseSpan();
+ }
}
outputElement.addCloseParagraph();
}
diff --git a/src/lib/CDRParser.cpp b/src/lib/CDRParser.cpp
index 7f600f6..fa54117 100644
--- a/src/lib/CDRParser.cpp
+++ b/src/lib/CDRParser.cpp
@@ -3021,7 +3021,7 @@ void libcdr::CDRParser::readTxsm(librevenge::RVNGInputStream *input, unsigned le
memcpy(&textData[0], buffer, numBytesRead);
input->seek(1, librevenge::RVNG_SEEK_CUR); //skip the 0 ending character
- if (!textData.empty())
+ if (!textData.empty() || !charStyles.empty())
m_collector->collectText(textId, stlId, textData, charDescriptions, charStyles);
}
#ifndef DEBUG
diff --git a/src/lib/CDRStylesCollector.cpp b/src/lib/CDRStylesCollector.cpp
index 7ead9b1..10b7703 100644
--- a/src/lib/CDRStylesCollector.cpp
+++ b/src/lib/CDRStylesCollector.cpp
@@ -213,7 +213,7 @@ void libcdr::CDRStylesCollector::collectPaletteEntry(unsigned colorId, unsigned
void libcdr::CDRStylesCollector::collectText(unsigned textId, unsigned styleId, const std::vector<unsigned char> &data,
const std::vector<unsigned char> &charDescriptions, const std::map<unsigned, CDRCharacterStyle> &styleOverrides)
{
- if (data.empty() || charDescriptions.empty())
+ if (data.empty() && styleOverrides.empty())
return;
unsigned char tmpCharDescription = 0;
@@ -249,16 +249,16 @@ void libcdr::CDRStylesCollector::collectText(unsigned textId, unsigned styleId,
if ((tmpCharDescription & 0x01) && (j < data.size()))
tmpTextData.push_back(data[j++]);
}
+ librevenge::RVNGString text;
if (!tmpTextData.empty())
{
- librevenge::RVNGString text;
if (tmpCharDescription & 0x01)
appendCharacters(text, tmpTextData);
else
appendCharacters(text, tmpTextData, tmpCharStyle.m_charSet);
- line.append(CDRText(text, tmpCharStyle));
- CDR_DEBUG_MSG(("CDRStylesCollector::collectText - Text: %s\n", text.cstr()));
}
+ line.append(CDRText(text, tmpCharStyle));
+ CDR_DEBUG_MSG(("CDRStylesCollector::collectText - Text: %s\n", text.cstr()));
std::vector<CDRTextLine> ¶graphVector = m_ps.m_texts[textId];
paragraphVector.push_back(line);
commit d006b719a063460ed717caf4b464de7940d4d73c
Author: David Tardon <dtardon at redhat.com>
Date: Fri Dec 25 11:06:38 2015 +0100
add test-driver to .gitignore
Change-Id: I2d93112ebbcaf1bf04338cdc85cd45fc76ab9f38
diff --git a/.gitignore b/.gitignore
index 60fdb73..519a2a0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,6 +23,7 @@ missing
mkinstalldirs
stamp-h1
tags
+test-driver
*.pc
*.rc
*~
commit 72f8053c53885a92e2e0843fa277bdb96d4ad6fa
Author: David Tardon <dtardon at redhat.com>
Date: Fri Dec 25 10:42:41 2015 +0100
print debug messages to stderr
Change-Id: Iead7aaad540e8fd11d3a531a0ce5db3323fe92b3
diff --git a/src/lib/libcdr_utils.cpp b/src/lib/libcdr_utils.cpp
index e4f2fcc..6d480cd 100644
--- a/src/lib/libcdr_utils.cpp
+++ b/src/lib/libcdr_utils.cpp
@@ -8,6 +8,8 @@
*/
#include <cassert>
+#include <cstdarg>
+#include <cstdio>
#include <string.h>
#include "libcdr_utils.h"
@@ -23,6 +25,7 @@
namespace
{
+
static unsigned short getEncodingFromICUName(const char *name)
{
// ANSI
@@ -460,6 +463,15 @@ void libcdr::appendCharacters(librevenge::RVNGString &text, std::vector<unsigned
}
#ifdef DEBUG
+
+void libcdr::debugPrint(const char *const format, ...)
+{
+ va_list args;
+ va_start(args, format);
+ std::vfprintf(stderr, format, args);
+ va_end(args);
+}
+
const char *libcdr::toFourCC(unsigned value, bool bigEndian)
{
static char sValue[5] = { 0, 0, 0, 0, 0 };
diff --git a/src/lib/libcdr_utils.h b/src/lib/libcdr_utils.h
index 273b0e9..0a7ba87 100644
--- a/src/lib/libcdr_utils.h
+++ b/src/lib/libcdr_utils.h
@@ -24,6 +24,12 @@
#define CDR_EPSILON 1E-6
#define CDR_ALMOST_ZERO(m) (fabs(m) <= CDR_EPSILON)
+#if defined(__clang__) || defined(__GNUC__)
+# define CDR_ATTRIBUTE_PRINTF(fmt, arg) __attribute__((__format__(__printf__, fmt, arg)))
+#else
+# define CDR_ATTRIBUTE_PRINTF(fmt, arg)
+#endif
+
#ifdef _MSC_VER
typedef unsigned char uint8_t;
@@ -63,11 +69,15 @@ typedef __int64 int64_t;
// do nothing with debug messages in a release compile
#ifdef DEBUG
+namespace libcdr
+{
+void debugPrint(const char *format, ...) CDR_ATTRIBUTE_PRINTF(1, 2);
+}
#ifdef VERBOSE_DEBUG
-#define CDR_DEBUG_MSG(M) printf("%15s:%5d: ", __FILE__, __LINE__); printf M
+#define CDR_DEBUG_MSG(M) libcdr::debugPrint("%15s:%5d: ", __FILE__, __LINE__); libcdr::debugPrint M
#define CDR_DEBUG(M) M
#else
-#define CDR_DEBUG_MSG(M) printf M
+#define CDR_DEBUG_MSG(M) libcdr::debugPrint M
#define CDR_DEBUG(M) M
#endif
#else
More information about the Libreoffice-commits
mailing list