[Libreoffice-commits] libcdr.git: 3 commits - src/lib
Fridrich Å trba
fridrich.strba at bluewin.ch
Wed Apr 10 03:36:17 PDT 2013
src/lib/CDRContentCollector.cpp | 9 +-
src/lib/CDRParser.cpp | 142 ++++++++++++++++++----------------------
src/lib/CDRTypes.h | 13 ++-
3 files changed, 81 insertions(+), 83 deletions(-)
New commits:
commit 7b9388dcbca9c176e556c8b67138593d4d98a116
Author: Fridrich Å trba <fridrich.strba at bluewin.ch>
Date: Wed Apr 10 10:32:26 2013 +0200
The indents don't seem to be really giving anything coherent
diff --git a/src/lib/CDRContentCollector.cpp b/src/lib/CDRContentCollector.cpp
index 2de80ae..fa905d3 100644
--- a/src/lib/CDRContentCollector.cpp
+++ b/src/lib/CDRContentCollector.cpp
@@ -479,9 +479,9 @@ void libcdr::CDRContentCollector::_flushCurrentPath()
default:
break;
}
- paraProps.insert("fo:text-indent", (*m_currentText)[i].m_charStyle.m_firstIndent);
- paraProps.insert("fo:margin-left", (*m_currentText)[i].m_charStyle.m_leftIndent);
- paraProps.insert("fo:margin-right", (*m_currentText)[i].m_charStyle.m_rightIndent);
+// paraProps.insert("fo:text-indent", (*m_currentText)[i].m_charStyle.m_firstIndent);
+// paraProps.insert("fo:margin-left", (*m_currentText)[i].m_charStyle.m_leftIndent);
+// paraProps.insert("fo:margin-right", (*m_currentText)[i].m_charStyle.m_rightIndent);
outputElement.addStartTextLine(paraProps);
WPXPropertyList spanProps;
double fontSize = (double)cdr_round(144.0*(*m_currentText)[i].m_charStyle.m_fontSize) / 2.0;
commit d9834c77f04db7680118789b21ef27140911426a
Author: Fridrich Å trba <fridrich.strba at bluewin.ch>
Date: Wed Apr 10 09:34:33 2013 +0200
Improve readability
diff --git a/src/lib/CDRParser.cpp b/src/lib/CDRParser.cpp
index fdc7699..097226a 100644
--- a/src/lib/CDRParser.cpp
+++ b/src/lib/CDRParser.cpp
@@ -47,6 +47,33 @@
#define M_PI 3.14159265358979323846
#endif
+// The local variable name and CDRStltRecord member name have to be identical
+// for this macro to work
+
+#define CDR_EXTRACT(membername) \
+ if (iter->second.membername) \
+ membername = iter->second.membername; \
+ else if (iter->second.parentId) \
+ { \
+ unsigned parentId = iter->second.parentId; \
+ while (true) \
+ { \
+ std::map<unsigned, CDRStltRecord>::const_iterator iter2 = styles.find(parentId); \
+ if (iter2 == styles.end()) \
+ break; \
+ if (iter2->second.membername) \
+ { \
+ membername = iter2->second.membername; \
+ break; \
+ } \
+ if (iter2->second.parentId) \
+ parentId = iter2->second.parentId; \
+ else \
+ break; \
+ } \
+ }
+
+
namespace
{
@@ -2578,134 +2605,30 @@ void libcdr::CDRParser::readStlt(WPXInputStream *input, unsigned length)
for (std::map<unsigned, CDRStltRecord>::const_iterator iter = styles.begin();
iter != styles.end(); ++iter)
{
- unsigned fontRecordId = 0;
- if (iter->second.fontRecId)
- fontRecordId = iter->second.fontRecId;
- else if (iter->second.parentId)
- {
- unsigned parentId = iter->second.parentId;
- while (true)
- {
- std::map<unsigned, CDRStltRecord>::const_iterator iter2 = styles.find(parentId);
- if (iter2 == styles.end())
- break;
- if (iter2->second.fontRecId)
- {
- fontRecordId = iter2->second.fontRecId;
- break;
- }
- if (iter2->second.parentId)
- parentId = iter2->second.parentId;
- else
- break;
- }
- }
- unsigned alignId = 0;
- if (iter->second.alignId)
- alignId = iter->second.alignId;
- else if (iter->second.parentId)
+ unsigned fontRecId = 0;
+ CDR_EXTRACT(fontRecId)
+ if (fontRecId)
{
- unsigned parentId = iter->second.parentId;
- while (true)
- {
- std::map<unsigned, CDRStltRecord>::const_iterator iter2 = styles.find(parentId);
- if (iter2 == styles.end())
- break;
- if (iter2->second.alignId)
- {
- alignId = iter2->second.alignId;
- break;
- }
- if (iter2->second.parentId)
- parentId = iter2->second.parentId;
- else
- break;
- }
- }
- unsigned indentId = 0;
- if (iter->second.indentId)
- indentId = iter->second.indentId;
- else if (iter->second.parentId)
- {
- unsigned parentId = iter->second.parentId;
- while (true)
- {
- std::map<unsigned, CDRStltRecord>::const_iterator iter2 = styles.find(parentId);
- if (iter2 == styles.end())
- break;
- if (iter2->second.indentId)
- {
- indentId = iter2->second.indentId;
- break;
- }
- if (iter2->second.parentId)
- parentId = iter2->second.parentId;
- else
- break;
- }
- }
- unsigned fillId = 0;
- if (iter->second.fillId)
- fillId = iter->second.fillId;
- else if (iter->second.parentId)
- {
- unsigned parentId = iter->second.parentId;
- while (true)
- {
- std::map<unsigned, CDRStltRecord>::const_iterator iter2 = styles.find(parentId);
- if (iter2 == styles.end())
- break;
- if (iter2->second.fillId)
- {
- fillId = iter2->second.fillId;
- break;
- }
- if (iter2->second.parentId)
- parentId = iter2->second.parentId;
- else
- break;
- }
- }
- unsigned outlId = 0;
- if (iter->second.outlId)
- outlId = iter->second.outlId;
- else if (iter->second.parentId)
- {
- unsigned parentId = iter->second.parentId;
- while (true)
- {
- std::map<unsigned, CDRStltRecord>::const_iterator iter2 = styles.find(parentId);
- if (iter2 == styles.end())
- break;
- if (iter2->second.outlId)
- {
- outlId = iter2->second.outlId;
- break;
- }
- if (iter2->second.parentId)
- parentId = iter2->second.parentId;
- else
- break;
- }
- }
- if (fontRecordId)
- {
- std::map<unsigned, unsigned short>::const_iterator iterFontId = fontIds.find(fontRecordId);
+ std::map<unsigned, unsigned short>::const_iterator iterFontId = fontIds.find(fontRecId);
if (iterFontId != fontIds.end())
tmpCharStyle.m_fontId = iterFontId->second;
- std::map<unsigned, unsigned short>::const_iterator iterCharSet = fontEncodings.find(fontRecordId);
+ std::map<unsigned, unsigned short>::const_iterator iterCharSet = fontEncodings.find(fontRecId);
if (iterCharSet != fontEncodings.end())
tmpCharStyle.m_charSet = iterCharSet->second;
- std::map<unsigned, double>::const_iterator iterFontSize = fontSizes.find(fontRecordId);
+ std::map<unsigned, double>::const_iterator iterFontSize = fontSizes.find(fontRecId);
if (iterFontSize != fontSizes.end())
tmpCharStyle.m_fontSize = iterFontSize->second;
}
+ unsigned alignId = 0;
+ CDR_EXTRACT(alignId);
if (alignId)
{
std::map<unsigned, unsigned>::const_iterator iterAlign = aligns.find(alignId);
if (iterAlign != aligns.end())
tmpCharStyle.m_align = iterAlign->second;
}
+ unsigned indentId = 0;
+ CDR_EXTRACT(indentId);
if (indentId)
{
std::map<unsigned, double>::const_iterator iterRight = rightIndents.find(indentId);
@@ -2718,12 +2641,16 @@ void libcdr::CDRParser::readStlt(WPXInputStream *input, unsigned length)
if (iterLeft != leftIndents.end())
tmpCharStyle.m_leftIndent = iterLeft->second;
}
+ unsigned fillId = 0;
+ CDR_EXTRACT(fillId);
if (fillId)
{
std::map<unsigned, unsigned>::const_iterator iterFill = fillIds.find(fillId);
if (iterFill != fillIds.end())
tmpCharStyle.m_fillId = iterFill->second;
}
+ unsigned outlId = 0;
+ CDR_EXTRACT(outlId);
if (outlId)
{
std::map<unsigned, unsigned>::const_iterator iterOutl = outlIds.find(outlId);
commit f46ff71bb5cf18301caa8768f164c0cd06b12d50
Author: Fridrich Å trba <fridrich.strba at bluewin.ch>
Date: Wed Apr 10 09:10:26 2013 +0200
BIPU support of text colour
diff --git a/src/lib/CDRContentCollector.cpp b/src/lib/CDRContentCollector.cpp
index 502cf65..2de80ae 100644
--- a/src/lib/CDRContentCollector.cpp
+++ b/src/lib/CDRContentCollector.cpp
@@ -489,6 +489,9 @@ void libcdr::CDRContentCollector::_flushCurrentPath()
std::map<unsigned, CDRFont>::const_iterator iterFont = m_ps.m_fonts.find((*m_currentText)[i].m_charStyle.m_fontId);
if (iterFont != m_ps.m_fonts.end())
spanProps.insert("style:font-name", iterFont->second.m_name);
+ std::map<unsigned, CDRFillStyle>::const_iterator iterFill = m_ps.m_fillStyles.find((*m_currentText)[i].m_charStyle.m_fillId);
+ if (iterFill != m_ps.m_fillStyles.end())
+ spanProps.insert("fo:color", m_ps.getRGBColorString(iterFill->second.color1));
outputElement.addStartTextSpan(spanProps);
outputElement.addInsertText((*m_currentText)[i].m_text);
outputElement.addEndTextSpan();
diff --git a/src/lib/CDRParser.cpp b/src/lib/CDRParser.cpp
index 6cc31de..fdc7699 100644
--- a/src/lib/CDRParser.cpp
+++ b/src/lib/CDRParser.cpp
@@ -2410,17 +2410,23 @@ void libcdr::CDRParser::readStlt(WPXInputStream *input, unsigned length)
unsigned numFills = readU32(input);
CDR_DEBUG_MSG(("CDRParser::readStlt numFills 0x%x\n", numFills));
unsigned i = 0;
+ std::map<unsigned, unsigned> fillIds;
for (i=0; i<numFills; ++i)
{
- input->seek(12, WPX_SEEK_CUR);
+ unsigned fillId = readU32(input);
+ input->seek(4, WPX_SEEK_CUR);
+ fillIds[fillId] = readU32(input);
if (m_version >= 1300)
input->seek(48, WPX_SEEK_CUR);
}
unsigned numOutls = readU32(input);
CDR_DEBUG_MSG(("CDRParser::readStlt numOutls 0x%x\n", numOutls));
+ std::map<unsigned, unsigned> outlIds;
for (i=0; i<numOutls; ++i)
{
- input->seek(12, WPX_SEEK_CUR);
+ unsigned outlId = readU32(input);
+ input->seek(4, WPX_SEEK_CUR);
+ outlIds[outlId] = readU32(input);
}
unsigned numFonts = readU32(input);
CDR_DEBUG_MSG(("CDRParser::readStlt numFonts 0x%x\n", numFonts));
@@ -2638,6 +2644,50 @@ void libcdr::CDRParser::readStlt(WPXInputStream *input, unsigned length)
break;
}
}
+ unsigned fillId = 0;
+ if (iter->second.fillId)
+ fillId = iter->second.fillId;
+ else if (iter->second.parentId)
+ {
+ unsigned parentId = iter->second.parentId;
+ while (true)
+ {
+ std::map<unsigned, CDRStltRecord>::const_iterator iter2 = styles.find(parentId);
+ if (iter2 == styles.end())
+ break;
+ if (iter2->second.fillId)
+ {
+ fillId = iter2->second.fillId;
+ break;
+ }
+ if (iter2->second.parentId)
+ parentId = iter2->second.parentId;
+ else
+ break;
+ }
+ }
+ unsigned outlId = 0;
+ if (iter->second.outlId)
+ outlId = iter->second.outlId;
+ else if (iter->second.parentId)
+ {
+ unsigned parentId = iter->second.parentId;
+ while (true)
+ {
+ std::map<unsigned, CDRStltRecord>::const_iterator iter2 = styles.find(parentId);
+ if (iter2 == styles.end())
+ break;
+ if (iter2->second.outlId)
+ {
+ outlId = iter2->second.outlId;
+ break;
+ }
+ if (iter2->second.parentId)
+ parentId = iter2->second.parentId;
+ else
+ break;
+ }
+ }
if (fontRecordId)
{
std::map<unsigned, unsigned short>::const_iterator iterFontId = fontIds.find(fontRecordId);
@@ -2668,6 +2718,18 @@ void libcdr::CDRParser::readStlt(WPXInputStream *input, unsigned length)
if (iterLeft != leftIndents.end())
tmpCharStyle.m_leftIndent = iterLeft->second;
}
+ if (fillId)
+ {
+ std::map<unsigned, unsigned>::const_iterator iterFill = fillIds.find(fillId);
+ if (iterFill != fillIds.end())
+ tmpCharStyle.m_fillId = iterFill->second;
+ }
+ if (outlId)
+ {
+ std::map<unsigned, unsigned>::const_iterator iterOutl = outlIds.find(outlId);
+ if (iterOutl != outlIds.end())
+ tmpCharStyle.m_outlId = iterOutl->second;
+ }
charStyles[iter->first] = tmpCharStyle;
}
}
@@ -2771,9 +2833,8 @@ void libcdr::CDRParser::readTxsm(WPXInputStream *input, unsigned length)
// Read more information depending on the flags
if (fl2&1) // Font
{
- unsigned flag = readU32(input);
- charStyle.m_charSet = (flag >> 16);
- charStyle.m_fontId = flag & 0xff;
+ charStyle.m_fontId = readU16(input);
+ charStyle.m_charSet = readU16(input);
}
if (fl2&2) // Bold/Italic, etc.
input->seek(4, WPX_SEEK_CUR);
@@ -2787,12 +2848,12 @@ void libcdr::CDRParser::readTxsm(WPXInputStream *input, unsigned length)
input->seek(4, WPX_SEEK_CUR);
if (fl2&0x40) // Font Colour
{
- input->seek(4, WPX_SEEK_CUR);
+ charStyle.m_fillId = readU32(input);
if (m_version >= 1500)
input->seek(48, WPX_SEEK_CUR);
}
if (fl2&0x80) // Font Outl Colour
- input->seek(4, WPX_SEEK_CUR);
+ charStyle.m_outlId = readU32(input);
if (fl3&8) // Encoding
{
diff --git a/src/lib/CDRTypes.h b/src/lib/CDRTypes.h
index aa5b946..4579df7 100644
--- a/src/lib/CDRTypes.h
+++ b/src/lib/CDRTypes.h
@@ -157,13 +157,16 @@ struct CDRCharacterStyle
double m_fontSize;
unsigned m_align;
double m_leftIndent, m_firstIndent, m_rightIndent;
+ unsigned m_outlId, m_fillId;
CDRCharacterStyle()
: m_charSet(0), m_fontId(0), m_fontSize(0.0), m_align(0), m_leftIndent(0.0), m_firstIndent(0.0),
- m_rightIndent(0.0) {}
+ m_rightIndent(0.0), m_outlId(0), m_fillId(0) {}
CDRCharacterStyle(unsigned short charSet, unsigned short fontId, double fontSize, unsigned align,
- double leftIndent, double firstIndent, double rightIndent)
+ double leftIndent, double firstIndent, double rightIndent, unsigned outlId,
+ unsigned fillId)
: m_charSet(charSet), m_fontId(fontId), m_fontSize(fontSize), m_align(align),
- m_leftIndent(leftIndent), m_firstIndent(firstIndent), m_rightIndent(rightIndent) {}
+ m_leftIndent(leftIndent), m_firstIndent(firstIndent), m_rightIndent(rightIndent),
+ m_outlId(outlId), m_fillId(fillId) {}
void overrideCharacterStyle(const CDRCharacterStyle &override)
{
if (override.m_charSet || override.m_fontId)
@@ -181,6 +184,10 @@ struct CDRCharacterStyle
m_firstIndent = override.m_firstIndent;
m_rightIndent = override.m_rightIndent;
}
+ if (override.m_outlId)
+ m_outlId = override.m_outlId;
+ if (override.m_fillId)
+ m_fillId = override.m_fillId;
}
};
More information about the Libreoffice-commits
mailing list