[Libreoffice-commits] libcdr.git: 2 commits - src/lib
Fridrich Štrba
fridrich.strba at bluewin.ch
Mon Jul 18 07:52:06 UTC 2016
src/lib/CDRCollector.cpp | 29 +++++++++++-
src/lib/CDRCollector.h | 6 +-
src/lib/CDRContentCollector.cpp | 16 +++---
src/lib/CDRContentCollector.h | 4 -
src/lib/CDRParser.cpp | 96 ++++++++++++++++++++--------------------
src/lib/CDRParser.h | 2
src/lib/CDRStylesCollector.cpp | 43 +++--------------
src/lib/CDRStylesCollector.h | 7 --
src/lib/CDRTypes.h | 14 ++---
9 files changed, 108 insertions(+), 109 deletions(-)
New commits:
commit 7f4bf72e375dee3f7004700ab6102f25720f154a
Author: Fridrich Štrba <fridrich.strba at bluewin.ch>
Date: Mon Jul 18 09:51:41 2016 +0200
Put the styles into the parser state struct
Change-Id: I72b7ddd9a7d9317f4379f5bd1a810db1f7ab4288
diff --git a/src/lib/CDRCollector.cpp b/src/lib/CDRCollector.cpp
index cc921a2..939eca4 100644
--- a/src/lib/CDRCollector.cpp
+++ b/src/lib/CDRCollector.cpp
@@ -14,7 +14,7 @@
#include "libcdr_utils.h"
libcdr::CDRParserState::CDRParserState()
- : m_bmps(), m_patterns(), m_vects(), m_pages(), m_documentPalette(), m_texts(),
+ : m_bmps(), m_patterns(), m_vects(), m_pages(), m_documentPalette(), m_texts(), m_styles(),
m_colorTransformCMYK2RGB(0), m_colorTransformLab2RGB(0), m_colorTransformRGB2RGB(0)
{
cmsHPROFILE tmpRGBProfile = cmsCreate_sRGBProfile();
@@ -576,4 +576,31 @@ librevenge::RVNGString libcdr::CDRParserState::getRGBColorString(const libcdr::C
return tempString;
}
+void libcdr::CDRParserState::getRecursedStyle(CDRStyle &style, unsigned styleId)
+{
+ std::map<unsigned, CDRStyle>::const_iterator iter = m_styles.find(styleId);
+ if (iter == m_styles.end())
+ return;
+
+ std::stack<CDRStyle> styleStack;
+ styleStack.push(iter->second);
+ if (iter->second.m_parentId)
+ {
+ std::map<unsigned, CDRStyle>::const_iterator iter2 = m_styles.find(iter->second.m_parentId);
+ while (iter2 != m_styles.end())
+ {
+ styleStack.push(iter2->second);
+ if (iter2->second.m_parentId)
+ iter2 = m_styles.find(iter2->second.m_parentId);
+ else
+ iter2 = m_styles.end();
+ }
+ }
+ while (!styleStack.empty())
+ {
+ style.overrideStyle(styleStack.top());
+ styleStack.pop();
+ }
+}
+
/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
diff --git a/src/lib/CDRCollector.h b/src/lib/CDRCollector.h
index a418208..ead8d17 100644
--- a/src/lib/CDRCollector.h
+++ b/src/lib/CDRCollector.h
@@ -40,6 +40,7 @@ public:
std::vector<CDRPage> m_pages;
std::map<unsigned, CDRColor> m_documentPalette;
std::map<unsigned, std::vector<CDRTextLine> > m_texts;
+ std::map<unsigned, CDRStyle> m_styles;
unsigned _getRGBColor(const CDRColor &color);
unsigned getBMPColor(const CDRColor &color);
@@ -50,6 +51,7 @@ public:
void setColorTransform(const std::vector<unsigned char> &profile);
void setColorTransform(librevenge::RVNGInputStream *input);
+ void getRecursedStyle(CDRStyle &style, unsigned styleId);
private:
CDRParserState(const CDRParserState &);
diff --git a/src/lib/CDRStylesCollector.cpp b/src/lib/CDRStylesCollector.cpp
index f7e34f6..3119cc2 100644
--- a/src/lib/CDRStylesCollector.cpp
+++ b/src/lib/CDRStylesCollector.cpp
@@ -23,7 +23,7 @@
libcdr::CDRStylesCollector::CDRStylesCollector(libcdr::CDRParserState &ps) :
- m_ps(ps), m_page(8.5, 11.0, -4.25, -5.5), m_styles()
+ m_ps(ps), m_page(8.5, 11.0, -4.25, -5.5)
{
}
@@ -221,7 +221,7 @@ void libcdr::CDRStylesCollector::collectText(unsigned textId, unsigned styleId,
unsigned j = 0;
std::vector<unsigned char> tmpTextData;
CDRStyle defaultCharStyle, tmpCharStyle;
- getRecursedStyle(defaultCharStyle, styleId);
+ m_ps.getRecursedStyle(defaultCharStyle, styleId);
CDRTextLine line;
for (i=0, j=0; i<charDescriptions.size() && j<data.size(); ++i)
@@ -266,34 +266,7 @@ void libcdr::CDRStylesCollector::collectText(unsigned textId, unsigned styleId,
void libcdr::CDRStylesCollector::collectStld(unsigned id, const CDRStyle &style)
{
- m_styles[id] = style;
-}
-
-void libcdr::CDRStylesCollector::getRecursedStyle(CDRStyle &style, unsigned styleId)
-{
- std::map<unsigned, CDRStyle>::const_iterator iter = m_styles.find(styleId);
- if (iter == m_styles.end())
- return;
-
- std::stack<CDRStyle> styleStack;
- styleStack.push(iter->second);
- if (iter->second.m_parentId)
- {
- std::map<unsigned, CDRStyle>::const_iterator iter2 = m_styles.find(iter->second.m_parentId);
- while (iter2 != m_styles.end())
- {
- styleStack.push(iter2->second);
- if (iter2->second.m_parentId)
- iter2 = m_styles.find(iter2->second.m_parentId);
- else
- iter2 = m_styles.end();
- }
- }
- while (!styleStack.empty())
- {
- style.overrideStyle(styleStack.top());
- styleStack.pop();
- }
+ m_ps.m_styles[id] = style;
}
/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
diff --git a/src/lib/CDRStylesCollector.h b/src/lib/CDRStylesCollector.h
index de47180..2183376 100644
--- a/src/lib/CDRStylesCollector.h
+++ b/src/lib/CDRStylesCollector.h
@@ -70,11 +70,8 @@ private:
CDRStylesCollector(const CDRStylesCollector &);
CDRStylesCollector &operator=(const CDRStylesCollector &);
- void getRecursedStyle(CDRStyle &style, unsigned styleId);
-
CDRParserState &m_ps;
CDRPage m_page;
- std::map<unsigned, CDRStyle> m_styles;
};
} // namespace libcdr
commit 46fdb6b2504457b8bcedbe7eb37d9f9d2132a08d
Author: Fridrich Štrba <fridrich.strba at bluewin.ch>
Date: Mon Jul 18 08:39:05 2016 +0200
This is not only for char styles
Change-Id: I46b13bd768d4bb87c2787a1d1f8936f8055dd1c3
diff --git a/src/lib/CDRCollector.h b/src/lib/CDRCollector.h
index 7ec3888..a418208 100644
--- a/src/lib/CDRCollector.h
+++ b/src/lib/CDRCollector.h
@@ -94,10 +94,10 @@ public:
virtual void collectVectorPattern(unsigned id, const librevenge::RVNGBinaryData &data) = 0;
virtual void collectPaletteEntry(unsigned colorId, unsigned userId, const CDRColor &color) = 0;
virtual void collectText(unsigned textId, unsigned styleId, const std::vector<unsigned char> &data,
- const std::vector<unsigned char> &charDescriptions, const std::map<unsigned, CDRCharacterStyle> &styleOverrides) = 0;
+ const std::vector<unsigned char> &charDescriptions, const std::map<unsigned, CDRStyle> &styleOverrides) = 0;
virtual void collectArtisticText(double x, double y) = 0;
virtual void collectParagraphText(double x, double y, double width, double height) = 0;
- virtual void collectStld(unsigned id, const CDRCharacterStyle &charStyle) = 0;
+ virtual void collectStld(unsigned id, const CDRStyle &style) = 0;
};
} // namespace libcdr
diff --git a/src/lib/CDRContentCollector.cpp b/src/lib/CDRContentCollector.cpp
index 4b24cdf..e19a6f8 100644
--- a/src/lib/CDRContentCollector.cpp
+++ b/src/lib/CDRContentCollector.cpp
@@ -435,12 +435,12 @@ void libcdr::CDRContentCollector::_flushCurrentPath()
{
y1 = m_currentBBox.getMinY();
y2 = m_currentBBox.getMinY() + m_currentBBox.getHeight();
- if ((*m_currentText)[0].m_line[0].m_charStyle.m_align == 2) // Center
+ if ((*m_currentText)[0].m_line[0].m_style.m_align == 2) // Center
{
x1 = m_currentBBox.getMinX() - m_currentBBox.getWidth() / 4.0;
x2 = m_currentBBox.getMinX() + (3.0 * m_currentBBox.getWidth() / 4.0);
}
- else if ((*m_currentText)[0].m_line[0].m_charStyle.m_align == 3) // Right
+ else if ((*m_currentText)[0].m_line[0].m_style.m_align == 3) // Right
{
x1 = m_currentBBox.getMinX() - m_currentBBox.getWidth() / 2.0;
x2 = m_currentBBox.getMinX() + m_currentBBox.getWidth() / 2.0;
@@ -480,7 +480,7 @@ void libcdr::CDRContentCollector::_flushCurrentPath()
continue;
librevenge::RVNGPropertyList paraProps;
bool rtl = false;
- switch (currentLine[0].m_charStyle.m_align)
+ switch (currentLine[0].m_style.m_align)
{
case 1: // Left
if (!rtl)
@@ -513,12 +513,12 @@ void libcdr::CDRContentCollector::_flushCurrentPath()
if (!currentLine[j].m_text.empty())
{
librevenge::RVNGPropertyList spanProps;
- double fontSize = (double)cdr_round(144.0*currentLine[j].m_charStyle.m_fontSize) / 2.0;
+ double fontSize = (double)cdr_round(144.0*currentLine[j].m_style.m_fontSize) / 2.0;
spanProps.insert("fo:font-size", fontSize, librevenge::RVNG_POINT);
- if (currentLine[j].m_charStyle.m_fontName.len())
- spanProps.insert("style:font-name", currentLine[j].m_charStyle.m_fontName);
- if (currentLine[j].m_charStyle.m_fillStyle.fillType != (unsigned short)-1)
- spanProps.insert("fo:color", m_ps.getRGBColorString(currentLine[j].m_charStyle.m_fillStyle.color1));
+ if (currentLine[j].m_style.m_fontName.len())
+ spanProps.insert("style:font-name", currentLine[j].m_style.m_fontName);
+ if (currentLine[j].m_style.m_fillStyle.fillType != (unsigned short)-1)
+ spanProps.insert("fo:color", m_ps.getRGBColorString(currentLine[j].m_style.m_fillStyle.color1));
outputElement.addOpenSpan(spanProps);
outputElement.addInsertText(currentLine[j].m_text);
outputElement.addCloseSpan();
diff --git a/src/lib/CDRContentCollector.h b/src/lib/CDRContentCollector.h
index 6d31f5d..517692a 100644
--- a/src/lib/CDRContentCollector.h
+++ b/src/lib/CDRContentCollector.h
@@ -62,10 +62,10 @@ public:
void collectVectorPattern(unsigned id, const librevenge::RVNGBinaryData &data);
void collectPaletteEntry(unsigned, unsigned, const CDRColor &) {}
void collectText(unsigned, unsigned, const std::vector<unsigned char> &,
- const std::vector<unsigned char> &, const std::map<unsigned, CDRCharacterStyle> &) {}
+ const std::vector<unsigned char> &, const std::map<unsigned, CDRStyle> &) {}
void collectArtisticText(double x, double y);
void collectParagraphText(double x, double y, double width, double height);
- void collectStld(unsigned, const CDRCharacterStyle &) {}
+ void collectStld(unsigned, const CDRStyle &) {}
private:
CDRContentCollector(const CDRContentCollector &);
diff --git a/src/lib/CDRParser.cpp b/src/lib/CDRParser.cpp
index 5368c35..76a8024 100644
--- a/src/lib/CDRParser.cpp
+++ b/src/lib/CDRParser.cpp
@@ -2729,7 +2729,7 @@ void libcdr::CDRParser::readStlt(librevenge::RVNGInputStream *input, unsigned le
for (std::map<unsigned, CDRStltRecord>::const_iterator iter = styles.begin();
iter != styles.end(); ++iter)
{
- CDRCharacterStyle tmpCharStyle;
+ CDRStyle tmpCharStyle;
unsigned fontRecId = iter->second.fontRecId;
if (fontRecId)
{
@@ -2887,7 +2887,7 @@ void libcdr::CDRParser::readTxsm(librevenge::RVNGInputStream *input, unsigned le
input->seek(1, librevenge::RVNG_SEEK_CUR);
input->seek(1, librevenge::RVNG_SEEK_CUR);
unsigned numRecords = readU32(input);
- std::map<unsigned, CDRCharacterStyle> charStyles;
+ std::map<unsigned, CDRStyle> styles;
unsigned i = 0;
for (i=0; i<numRecords && getRemainingLength(input) >= 3; ++i)
{
@@ -2898,7 +2898,7 @@ void libcdr::CDRParser::readTxsm(librevenge::RVNGInputStream *input, unsigned le
if (m_version >= 800)
fl3 = readU8(input);
- CDRCharacterStyle charStyle;
+ CDRStyle style;
// Read more information depending on the flags
if (fl2&1) // Font
{
@@ -2906,17 +2906,17 @@ void libcdr::CDRParser::readTxsm(librevenge::RVNGInputStream *input, unsigned le
std::map<unsigned, CDRFont>::const_iterator iterFont = m_fonts.find(fontId);
if (iterFont != m_fonts.end())
{
- charStyle.m_fontName = iterFont->second.m_name;
- charStyle.m_charSet = iterFont->second.m_encoding;
+ style.m_fontName = iterFont->second.m_name;
+ style.m_charSet = iterFont->second.m_encoding;
}
unsigned short charSet = readU16(input);
if (charSet)
- charStyle.m_charSet = charSet;
+ style.m_charSet = charSet;
}
if (fl2&2) // Bold/Italic, etc.
input->seek(4, librevenge::RVNG_SEEK_CUR);
if (fl2&4) // Font Size
- charStyle.m_fontSize = readCoordinate(input);
+ style.m_fontSize = readCoordinate(input);
if (fl2&8) // assumption
input->seek(4, librevenge::RVNG_SEEK_CUR);
if (fl2&0x10) // Offset X
@@ -2928,7 +2928,7 @@ void libcdr::CDRParser::readTxsm(librevenge::RVNGInputStream *input, unsigned le
unsigned fillId = readU32(input);
std::map<unsigned, CDRFillStyle>::const_iterator iter = m_fillStyles.find(fillId);
if (iter != m_fillStyles.end())
- charStyle.m_fillStyle = iter->second;
+ style.m_fillStyle = iter->second;
if (m_version >= 1500)
input->seek(48, librevenge::RVNG_SEEK_CUR);
}
@@ -2937,7 +2937,7 @@ void libcdr::CDRParser::readTxsm(librevenge::RVNGInputStream *input, unsigned le
unsigned outlId = readU32(input);
std::map<unsigned, CDRLineStyle>::const_iterator iter = m_lineStyles.find(outlId);
if (iter != m_lineStyles.end())
- charStyle.m_lineStyle = iter->second;
+ style.m_lineStyle = iter->second;
}
if (fl3&8) // Encoding
{
@@ -2959,7 +2959,7 @@ void libcdr::CDRParser::readTxsm(librevenge::RVNGInputStream *input, unsigned le
if (m_version >= 1300)
input->seek(48, librevenge::RVNG_SEEK_CUR);
- charStyles[2*i] = charStyle;
+ styles[2*i] = style;
}
unsigned numChars = readU32(input);
const unsigned charSize = m_version >= 1200 ? 8 : 4;
@@ -2987,8 +2987,8 @@ 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() || !charStyles.empty())
- m_collector->collectText(textId, stlId, textData, charDescriptions, charStyles);
+ if (!textData.empty() || !styles.empty())
+ m_collector->collectText(textId, stlId, textData, charDescriptions, styles);
}
#ifndef DEBUG
}
@@ -3050,16 +3050,16 @@ void libcdr::CDRParser::readTxsm16(librevenge::RVNGInputStream *input)
unsigned len2 = readU32(input);
if (m_version < 1700)
len2 *= 2;
- CDRCharacterStyle defaultStyle;
+ CDRStyle defaultStyle;
_readX6StyleString(input, len2, defaultStyle);
unsigned numRecords = readU32(input);
unsigned i = 0;
- std::map<unsigned, CDRCharacterStyle> charStyles;
+ std::map<unsigned, CDRStyle> styles;
for (i=0; i<numRecords && getRemainingLength(input) >= 17; ++i)
{
- charStyles[i*2] = defaultStyle;
+ styles[i*2] = defaultStyle;
input->seek(4, librevenge::RVNG_SEEK_CUR);
unsigned flag = readU8(input);
input->seek(1, librevenge::RVNG_SEEK_CUR);
@@ -3073,7 +3073,7 @@ void libcdr::CDRParser::readTxsm16(librevenge::RVNGInputStream *input)
lenN = readU32(input);
if (m_version < 1700)
lenN *= 2;
- _readX6StyleString(input, lenN, charStyles[i*2]);
+ _readX6StyleString(input, lenN, styles[i*2]);
}
unsigned numChars = readU32(input);
@@ -3094,7 +3094,7 @@ void libcdr::CDRParser::readTxsm16(librevenge::RVNGInputStream *input)
memcpy(&textData[0], buffer, numBytesRead);
if (!textData.empty())
- m_collector->collectText(textId, stlId, textData, charDescriptions, charStyles);
+ m_collector->collectText(textId, stlId, textData, charDescriptions, styles);
#ifndef DEBUG
}
catch (...)
@@ -3115,10 +3115,10 @@ void libcdr::CDRParser::readTxsm6(librevenge::RVNGInputStream *input)
unsigned stlId = readU32(input);
unsigned numSt = readU32(input);
unsigned i = 0;
- std::map<unsigned, CDRCharacterStyle> charStyles;
+ std::map<unsigned, CDRStyle> styles;
for (; i<numSt && getRemainingLength(input) >= 58; ++i)
{
- CDRCharacterStyle charStyle;
+ CDRStyle style;
unsigned char flag = readU8(input);
input->seek(3, librevenge::RVNG_SEEK_CUR);
if (flag&0x01)
@@ -3127,18 +3127,18 @@ void libcdr::CDRParser::readTxsm6(librevenge::RVNGInputStream *input)
std::map<unsigned, CDRFont>::const_iterator iterFont = m_fonts.find(fontId);
if (iterFont != m_fonts.end())
{
- charStyle.m_fontName = iterFont->second.m_name;
- charStyle.m_charSet = iterFont->second.m_encoding;
+ style.m_fontName = iterFont->second.m_name;
+ style.m_charSet = iterFont->second.m_encoding;
}
unsigned short charSet = readU16(input);
if (charSet)
- charStyle.m_charSet = charSet;
+ style.m_charSet = charSet;
}
else
input->seek(4, librevenge::RVNG_SEEK_CUR);
input->seek(4, librevenge::RVNG_SEEK_CUR);
if (flag&0x04)
- charStyle.m_fontSize = readCoordinate(input);
+ style.m_fontSize = readCoordinate(input);
else
input->seek(4, librevenge::RVNG_SEEK_CUR);
input->seek(44, librevenge::RVNG_SEEK_CUR);
@@ -3147,16 +3147,16 @@ void libcdr::CDRParser::readTxsm6(librevenge::RVNGInputStream *input)
unsigned fillId = readU32(input);
std::map<unsigned, CDRFillStyle>::const_iterator iter = m_fillStyles.find(fillId);
if (iter != m_fillStyles.end())
- charStyle.m_fillStyle = iter->second;
+ style.m_fillStyle = iter->second;
}
if (flag&0x20)
{
unsigned outlId = readU32(input);
std::map<unsigned, CDRLineStyle>::const_iterator iter = m_lineStyles.find(outlId);
if (iter != m_lineStyles.end())
- charStyle.m_lineStyle = iter->second;
+ style.m_lineStyle = iter->second;
}
- charStyles[2*i] = charStyle;
+ styles[2*i] = style;
}
unsigned numChars = readU32(input);
if (numChars > getRemainingLength(input) / 12)
@@ -3174,7 +3174,7 @@ void libcdr::CDRParser::readTxsm6(librevenge::RVNGInputStream *input)
input->seek(1, librevenge::RVNG_SEEK_CUR);
}
if (!textData.empty())
- m_collector->collectText(textId, stlId, textData, charDescriptions, charStyles);
+ m_collector->collectText(textId, stlId, textData, charDescriptions, styles);
}
void libcdr::CDRParser::readTxsm5(librevenge::RVNGInputStream *input)
@@ -3185,10 +3185,10 @@ void libcdr::CDRParser::readTxsm5(librevenge::RVNGInputStream *input)
unsigned stlId = readU16(input);
unsigned numSt = readU16(input);
unsigned i = 0;
- std::map<unsigned, CDRCharacterStyle> charStyles;
+ std::map<unsigned, CDRStyle> styles;
for (; i<numSt && getRemainingLength(input) >= 34; ++i)
{
- CDRCharacterStyle charStyle;
+ CDRStyle style;
unsigned char flag = readU8(input);
input->seek(1, librevenge::RVNG_SEEK_CUR);
if (flag&0x01)
@@ -3197,18 +3197,18 @@ void libcdr::CDRParser::readTxsm5(librevenge::RVNGInputStream *input)
std::map<unsigned, CDRFont>::const_iterator iterFont = m_fonts.find(fontId);
if (iterFont != m_fonts.end())
{
- charStyle.m_fontName = iterFont->second.m_name;
- charStyle.m_charSet = iterFont->second.m_encoding;
+ style.m_fontName = iterFont->second.m_name;
+ style.m_charSet = iterFont->second.m_encoding;
}
unsigned short charSet = readU8(input);
if (charSet)
- charStyle.m_charSet = charSet;
+ style.m_charSet = charSet;
}
else
input->seek(2, librevenge::RVNG_SEEK_CUR);
input->seek(6, librevenge::RVNG_SEEK_CUR);
if (flag&0x04)
- charStyle.m_fontSize = readCoordinate(input);
+ style.m_fontSize = readCoordinate(input);
else
input->seek(2, librevenge::RVNG_SEEK_CUR);
input->seek(2, librevenge::RVNG_SEEK_CUR);
@@ -3217,7 +3217,7 @@ void libcdr::CDRParser::readTxsm5(librevenge::RVNGInputStream *input)
unsigned fillId = readU32(input);
std::map<unsigned, CDRFillStyle>::const_iterator iter = m_fillStyles.find(fillId);
if (iter != m_fillStyles.end())
- charStyle.m_fillStyle = iter->second;
+ style.m_fillStyle = iter->second;
}
else
input->seek(4, librevenge::RVNG_SEEK_CUR);
@@ -3226,12 +3226,12 @@ void libcdr::CDRParser::readTxsm5(librevenge::RVNGInputStream *input)
unsigned outlId = readU32(input);
std::map<unsigned, CDRLineStyle>::const_iterator iter = m_lineStyles.find(outlId);
if (iter != m_lineStyles.end())
- charStyle.m_lineStyle = iter->second;
+ style.m_lineStyle = iter->second;
}
else
input->seek(4, librevenge::RVNG_SEEK_CUR);
input->seek(14, librevenge::RVNG_SEEK_CUR);
- charStyles[2*i] = charStyle;
+ styles[2*i] = style;
}
unsigned numChars = readU16(input);
if (numChars > getRemainingLength(input) / 8)
@@ -3248,7 +3248,7 @@ void libcdr::CDRParser::readTxsm5(librevenge::RVNGInputStream *input)
charDescriptions.push_back((readU16(input) >> 3) & 0xff);
}
if (!textData.empty())
- m_collector->collectText(textId, stlId, textData, charDescriptions, charStyles);
+ m_collector->collectText(textId, stlId, textData, charDescriptions, styles);
}
void libcdr::CDRParser::readUdta(librevenge::RVNGInputStream *input)
@@ -3295,8 +3295,8 @@ void libcdr::CDRParser::readStyd(librevenge::RVNGInputStream *input)
return;
if (numOfArgs > (chunkLength - startOfArgs) / 4) // avoid extra big allocation in case of a broken file
numOfArgs = (chunkLength - startOfArgs) / 4;
- CDRCharacterStyle charStyle;
- charStyle.m_parentId = readUnsigned(input);
+ CDRStyle style;
+ style.m_parentId = readUnsigned(input);
std::vector<unsigned> argOffsets(numOfArgs, 0);
std::vector<unsigned> argTypes(numOfArgs, 0);
unsigned i = 0;
@@ -3320,7 +3320,7 @@ void libcdr::CDRParser::readStyd(librevenge::RVNGInputStream *input)
unsigned fillId = readU32(input);
std::map<unsigned, CDRFillStyle>::const_iterator iter = m_fillStyles.find(fillId);
if (iter != m_fillStyles.end())
- charStyle.m_fillStyle = iter->second;
+ style.m_fillStyle = iter->second;
break;
}
case STYD_OUTL_ID:
@@ -3328,7 +3328,7 @@ void libcdr::CDRParser::readStyd(librevenge::RVNGInputStream *input)
unsigned outlId = readU32(input);
std::map<unsigned, CDRLineStyle>::const_iterator iter = m_lineStyles.find(outlId);
if (iter != m_lineStyles.end())
- charStyle.m_lineStyle = iter->second;
+ style.m_lineStyle = iter->second;
break;
}
case STYD_FONTS:
@@ -3339,19 +3339,19 @@ void libcdr::CDRParser::readStyd(librevenge::RVNGInputStream *input)
std::map<unsigned, CDRFont>::const_iterator iterFont = m_fonts.find(fontId);
if (iterFont != m_fonts.end())
{
- charStyle.m_fontName = iterFont->second.m_name;
- charStyle.m_charSet = iterFont->second.m_encoding;
+ style.m_fontName = iterFont->second.m_name;
+ style.m_charSet = iterFont->second.m_encoding;
}
unsigned short charSet = readUnsignedShort(input);
if (charSet)
- charStyle.m_charSet = charSet;
+ style.m_charSet = charSet;
if (m_version >= 600)
input->seek(8, librevenge::RVNG_SEEK_CUR);
- charStyle.m_fontSize = readCoordinate(input);
+ style.m_fontSize = readCoordinate(input);
break;
}
case STYD_ALIGN:
- charStyle.m_align = readUnsigned(input);
+ style.m_align = readUnsigned(input);
break;
case STYD_BULLETS:
break;
@@ -3372,7 +3372,7 @@ void libcdr::CDRParser::readStyd(librevenge::RVNGInputStream *input)
}
}
input->seek(startPosition+chunkLength, librevenge::RVNG_SEEK_SET);
- m_collector->collectStld(styleId, charStyle);
+ m_collector->collectStld(styleId, style);
}
void libcdr::CDRParser::readArtisticText(librevenge::RVNGInputStream *input)
@@ -3390,7 +3390,7 @@ void libcdr::CDRParser::readParagraphText(librevenge::RVNGInputStream *input)
m_collector->collectParagraphText(0.0, 0.0, width, height);
}
-void libcdr::CDRParser::_readX6StyleString(librevenge::RVNGInputStream *input, unsigned length, libcdr::CDRCharacterStyle &style)
+void libcdr::CDRParser::_readX6StyleString(librevenge::RVNGInputStream *input, unsigned length, libcdr::CDRStyle &style)
{
if (length > getRemainingLength(input))
{
diff --git a/src/lib/CDRParser.h b/src/lib/CDRParser.h
index 31f7ec7..ca30d50 100644
--- a/src/lib/CDRParser.h
+++ b/src/lib/CDRParser.h
@@ -94,7 +94,7 @@ private:
void readParagraphText(librevenge::RVNGInputStream *input);
bool _redirectX6Chunk(librevenge::RVNGInputStream **input, unsigned &length);
- void _readX6StyleString(librevenge::RVNGInputStream *input, unsigned length, CDRCharacterStyle &style);
+ void _readX6StyleString(librevenge::RVNGInputStream *input, unsigned length, CDRStyle &style);
std::vector<librevenge::RVNGInputStream *> m_externalStreams;
diff --git a/src/lib/CDRStylesCollector.cpp b/src/lib/CDRStylesCollector.cpp
index 10b7703..f7e34f6 100644
--- a/src/lib/CDRStylesCollector.cpp
+++ b/src/lib/CDRStylesCollector.cpp
@@ -23,7 +23,7 @@
libcdr::CDRStylesCollector::CDRStylesCollector(libcdr::CDRParserState &ps) :
- m_ps(ps), m_page(8.5, 11.0, -4.25, -5.5), m_charStyles()
+ m_ps(ps), m_page(8.5, 11.0, -4.25, -5.5), m_styles()
{
}
@@ -211,7 +211,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)
+ const std::vector<unsigned char> &charDescriptions, const std::map<unsigned, CDRStyle> &styleOverrides)
{
if (data.empty() && styleOverrides.empty())
return;
@@ -220,16 +220,16 @@ void libcdr::CDRStylesCollector::collectText(unsigned textId, unsigned styleId,
unsigned i = 0;
unsigned j = 0;
std::vector<unsigned char> tmpTextData;
- CDRCharacterStyle defaultCharStyle, tmpCharStyle;
+ CDRStyle defaultCharStyle, tmpCharStyle;
getRecursedStyle(defaultCharStyle, styleId);
CDRTextLine line;
for (i=0, j=0; i<charDescriptions.size() && j<data.size(); ++i)
{
tmpCharStyle = defaultCharStyle;
- std::map<unsigned, CDRCharacterStyle>::const_iterator iter = styleOverrides.find(tmpCharDescription & 0xfe);
+ std::map<unsigned, CDRStyle>::const_iterator iter = styleOverrides.find(tmpCharDescription & 0xfe);
if (iter != styleOverrides.end())
- tmpCharStyle.overrideCharacterStyle(iter->second);
+ tmpCharStyle.overrideStyle(iter->second);
if (charDescriptions[i] != tmpCharDescription)
{
librevenge::RVNGString text;
@@ -264,34 +264,34 @@ void libcdr::CDRStylesCollector::collectText(unsigned textId, unsigned styleId,
paragraphVector.push_back(line);
}
-void libcdr::CDRStylesCollector::collectStld(unsigned id, const CDRCharacterStyle &charStyle)
+void libcdr::CDRStylesCollector::collectStld(unsigned id, const CDRStyle &style)
{
- m_charStyles[id] = charStyle;
+ m_styles[id] = style;
}
-void libcdr::CDRStylesCollector::getRecursedStyle(CDRCharacterStyle &charStyle, unsigned styleId)
+void libcdr::CDRStylesCollector::getRecursedStyle(CDRStyle &style, unsigned styleId)
{
- std::map<unsigned, CDRCharacterStyle>::const_iterator iter = m_charStyles.find(styleId);
- if (iter == m_charStyles.end())
+ std::map<unsigned, CDRStyle>::const_iterator iter = m_styles.find(styleId);
+ if (iter == m_styles.end())
return;
- std::stack<CDRCharacterStyle> styleStack;
+ std::stack<CDRStyle> styleStack;
styleStack.push(iter->second);
if (iter->second.m_parentId)
{
- std::map<unsigned, CDRCharacterStyle>::const_iterator iter2 = m_charStyles.find(iter->second.m_parentId);
- while (iter2 != m_charStyles.end())
+ std::map<unsigned, CDRStyle>::const_iterator iter2 = m_styles.find(iter->second.m_parentId);
+ while (iter2 != m_styles.end())
{
styleStack.push(iter2->second);
if (iter2->second.m_parentId)
- iter2 = m_charStyles.find(iter2->second.m_parentId);
+ iter2 = m_styles.find(iter2->second.m_parentId);
else
- iter2 = m_charStyles.end();
+ iter2 = m_styles.end();
}
}
while (!styleStack.empty())
{
- charStyle.overrideCharacterStyle(styleStack.top());
+ style.overrideStyle(styleStack.top());
styleStack.pop();
}
}
diff --git a/src/lib/CDRStylesCollector.h b/src/lib/CDRStylesCollector.h
index 26d7bf0..de47180 100644
--- a/src/lib/CDRStylesCollector.h
+++ b/src/lib/CDRStylesCollector.h
@@ -61,20 +61,20 @@ public:
void collectVectorPattern(unsigned, const librevenge::RVNGBinaryData &) {}
void collectPaletteEntry(unsigned colorId, unsigned userId, const CDRColor &color);
void collectText(unsigned textId, unsigned styleId, const std::vector<unsigned char> &data,
- const std::vector<unsigned char> &charDescriptions, const std::map<unsigned, CDRCharacterStyle> &styleOverrides);
+ const std::vector<unsigned char> &charDescriptions, const std::map<unsigned, CDRStyle> &styleOverrides);
void collectArtisticText(double, double) {}
void collectParagraphText(double, double, double, double) {}
- void collectStld(unsigned id, const CDRCharacterStyle &charStyle);
+ void collectStld(unsigned id, const CDRStyle &style);
private:
CDRStylesCollector(const CDRStylesCollector &);
CDRStylesCollector &operator=(const CDRStylesCollector &);
- void getRecursedStyle(CDRCharacterStyle &charStyle, unsigned styleId);
+ void getRecursedStyle(CDRStyle &style, unsigned styleId);
CDRParserState &m_ps;
CDRPage m_page;
- std::map<unsigned, CDRCharacterStyle> m_charStyles;
+ std::map<unsigned, CDRStyle> m_styles;
};
} // namespace libcdr
diff --git a/src/lib/CDRTypes.h b/src/lib/CDRTypes.h
index 8ea9fe6..da732ac 100644
--- a/src/lib/CDRTypes.h
+++ b/src/lib/CDRTypes.h
@@ -133,7 +133,7 @@ struct CDRLineStyle
startMarker(sm), endMarker(em) {}
};
-struct CDRCharacterStyle
+struct CDRStyle
{
unsigned short m_charSet;
librevenge::RVNGString m_fontName;
@@ -143,14 +143,14 @@ struct CDRCharacterStyle
CDRLineStyle m_lineStyle;
CDRFillStyle m_fillStyle;
unsigned m_parentId;
- CDRCharacterStyle()
+ CDRStyle()
: m_charSet((unsigned short)-1), m_fontName(),
m_fontSize(0.0), m_align(0), m_leftIndent(0.0), m_firstIndent(0.0),
m_rightIndent(0.0), m_lineStyle(), m_fillStyle(), m_parentId(0)
{
m_fontName.clear();
}
- void overrideCharacterStyle(const CDRCharacterStyle &override)
+ void overrideStyle(const CDRStyle &override)
{
if (override.m_charSet != (unsigned short)-1 || override.m_fontName.len())
{
@@ -341,11 +341,11 @@ struct CDRLab4Color
struct CDRText
{
- CDRText() : m_text(), m_charStyle() {}
- CDRText(const librevenge::RVNGString &text, const CDRCharacterStyle &charStyle)
- : m_text(text), m_charStyle(charStyle) {}
+ CDRText() : m_text(), m_style() {}
+ CDRText(const librevenge::RVNGString &text, const CDRStyle &style)
+ : m_text(text), m_style(style) {}
librevenge::RVNGString m_text;
- CDRCharacterStyle m_charStyle;
+ CDRStyle m_style;
};
struct CDRTextLine
More information about the Libreoffice-commits
mailing list