src/lib/CDRCollector.h | 4 ++-- src/lib/CDRContentCollector.cpp | 27 +++++++++++++++------------ src/lib/CDRContentCollector.h | 6 +++--- src/lib/CDRParser.cpp | 21 ++++++++++++++++++--- src/lib/CDRParser.h | 2 ++ src/lib/CDRStylesCollector.h | 4 ++-- src/lib/CDRTypes.h | 6 +++--- src/lib/CMXParser.cpp | 8 ++++---- src/lib/CMXParser.h | 2 +- 9 files changed, 50 insertions(+), 30 deletions(-)
New commits: commit 2aca278872fb6d9cc7fdecd41322ae82b4fa541d Author: Fridrich Å trba <fridrich.st...@bluewin.ch> Date: Tue Mar 5 11:00:40 2013 +0100 Trying to get some reasonable position for the text diff --git a/src/lib/CDRContentCollector.cpp b/src/lib/CDRContentCollector.cpp index fe6fe90..840f164 100644 --- a/src/lib/CDRContentCollector.cpp +++ b/src/lib/CDRContentCollector.cpp @@ -1145,10 +1145,8 @@ void libcdr::CDRContentCollector::collectArtisticText(double, double) m_currentText = &(iter->second); } -void libcdr::CDRContentCollector::collectParagraphText(double x, double y, double width, double height) +void libcdr::CDRContentCollector::collectParagraphText(double, double, double width, double height) { - m_currentBox.m_x = x; - m_currentBox.m_y = y; m_currentBox.m_w = width; m_currentBox.m_h = height; std::map<unsigned, std::vector<CDRText> >::const_iterator iter = m_ps.m_texts.find(m_spnd); commit fe0ea8729b77daa9d732b8b3ebf054381b7bed1c Author: Fridrich Å trba <fridrich.st...@bluewin.ch> Date: Tue Mar 5 10:56:42 2013 +0100 Some more work on the text frames diff --git a/src/lib/CDRContentCollector.cpp b/src/lib/CDRContentCollector.cpp index e72a7e3..fe6fe90 100644 --- a/src/lib/CDRContentCollector.cpp +++ b/src/lib/CDRContentCollector.cpp @@ -53,7 +53,7 @@ libcdr::CDRContentCollector::CDRContentCollector(libcdr::CDRParserState &ps, lib m_page(ps.m_pages[0]), m_pageIndex(0), m_currentFildId(0), m_currentOutlId(0), m_spnd(0), m_currentObjectLevel(0), m_currentGroupLevel(0), m_currentVectLevel(0), m_currentPageLevel(0), m_currentImage(), m_currentText(0), m_currentTextOffsetX(0.0), m_currentTextOffsetY(0.0), - m_currentBBox(), m_currentPath(), m_currentTransforms(), m_fillTransforms(), + m_currentBox(), m_currentPath(), m_currentTransforms(), m_fillTransforms(), m_polygon(0), m_isInPolygon(false), m_isInSpline(false), m_outputElements(0), m_contentOutputElements(), m_fillOutputElements(), m_groupLevels(), m_groupTransforms(), m_splineData(), m_fillOpacity(1.0), m_ps(ps) @@ -111,7 +111,7 @@ void libcdr::CDRContentCollector::collectObject(unsigned level) m_currentObjectLevel = level; m_currentFildId = 0; m_currentOutlId = 0; - m_currentBBox = CDRBox(); + m_currentBox = CDRBox(); } void libcdr::CDRContentCollector::collectGroup(unsigned level) @@ -399,19 +399,19 @@ void libcdr::CDRContentCollector::_flushCurrentPath() if (!m_groupTransforms.empty()) m_groupTransforms.top().applyToPoint(currentTextOffsetX, currentTextOffsetY); WPXPropertyList textFrameProps; - if (m_currentBBox.getWidth() > 0.0 && m_currentBBox.getHeight() > 0.0) + if (m_currentBox.getWidth() > 0.0 && m_currentBox.getHeight() > 0.0) { - textFrameProps.insert("svg:width", m_currentBBox.getWidth() * 1.05); - textFrameProps.insert("svg:height", m_currentBBox.getHeight()); - currentTextOffsetX = m_currentBBox.getMinX(); - currentTextOffsetY = m_currentBBox.getMinY(); + textFrameProps.insert("svg:width", m_currentBox.getWidth() * 1.05); + textFrameProps.insert("svg:height", m_currentBox.getHeight()); + currentTextOffsetX = m_currentBox.getMinX(); + currentTextOffsetY = m_currentBox.getMinY(); } CDRTransform tmpTrafo(1.0, 0.0, -m_page.offsetX, 0.0, 1.0, -m_page.offsetY); tmpTrafo.applyToPoint(currentTextOffsetX, currentTextOffsetY); tmpTrafo = CDRTransform(1.0, 0.0, 0.0, 0.0, -1.0, m_page.height); tmpTrafo.applyToPoint(currentTextOffsetX, currentTextOffsetY); textFrameProps.insert("svg:x", currentTextOffsetX); - textFrameProps.insert("svg:y", currentTextOffsetY - m_currentBBox.getHeight()); + textFrameProps.insert("svg:y", currentTextOffsetY - m_currentBox.getHeight()); textFrameProps.insert("fo:padding-top", 0.0); textFrameProps.insert("fo:padding-bottom", 0.0); textFrameProps.insert("fo:padding-left", 0.0); @@ -1094,7 +1094,7 @@ void libcdr::CDRContentCollector::collectBBox(double x0, double y0, double x1, d m_page.offsetX = bBox.getMinX(); m_page.offsetY = bBox.getMinY(); } - m_currentBBox = bBox; + m_currentBox = bBox; } void libcdr::CDRContentCollector::collectSpnd(unsigned spnd) @@ -1137,15 +1137,20 @@ void libcdr::CDRContentCollector::collectVectorPattern(unsigned id, const WPXBin #endif } -void libcdr::CDRContentCollector::collectArtisticText(double /* x */, double /* y */) +void libcdr::CDRContentCollector::collectArtisticText(double, double) { + m_currentBox.m_w *= 2.0; std::map<unsigned, std::vector<CDRText> >::const_iterator iter = m_ps.m_texts.find(m_spnd); if (iter != m_ps.m_texts.end()) m_currentText = &(iter->second); } -void libcdr::CDRContentCollector::collectParagraphText(double /* x */, double /* y */, double /* width */, double /* height */) +void libcdr::CDRContentCollector::collectParagraphText(double x, double y, double width, double height) { + m_currentBox.m_x = x; + m_currentBox.m_y = y; + m_currentBox.m_w = width; + m_currentBox.m_h = height; std::map<unsigned, std::vector<CDRText> >::const_iterator iter = m_ps.m_texts.find(m_spnd); if (iter != m_ps.m_texts.end()) m_currentText = &(iter->second); diff --git a/src/lib/CDRContentCollector.h b/src/lib/CDRContentCollector.h index abdaa2a..5781d25 100644 --- a/src/lib/CDRContentCollector.h +++ b/src/lib/CDRContentCollector.h @@ -121,7 +121,7 @@ private: const std::vector<CDRText> *m_currentText; double m_currentTextOffsetX; double m_currentTextOffsetY; - CDRBox m_currentBBox; + CDRBox m_currentBox; CDRPath m_currentPath; CDRTransforms m_currentTransforms; diff --git a/src/lib/CDRParser.cpp b/src/lib/CDRParser.cpp index 631a2f1..9103507 100644 --- a/src/lib/CDRParser.cpp +++ b/src/lib/CDRParser.cpp @@ -517,7 +517,7 @@ bool libcdr::CDRParser::parseRecord(WPXInputStream *input, unsigned *blockLength m_collector->collectPage(level); else if (listType == FOURCC_obj) m_collector->collectObject(level); - else if (listType == FOURCC_grp) + else if (listType == FOURCC_grp || listType == FOURCC_lnkg) m_collector->collectGroup(level); else if ((listType & 0xffffff) == FOURCC_CDR || (listType & 0xffffff) == FOURCC_cdr) { commit b68d1926a0bf57a3a48327683bcb7a7f472de325 Author: Fridrich Å trba <fridrich.st...@bluewin.ch> Date: Tue Mar 5 09:35:13 2013 +0100 CDRBBox -> CDRBox diff --git a/src/lib/CDRContentCollector.cpp b/src/lib/CDRContentCollector.cpp index c2a3702..e72a7e3 100644 --- a/src/lib/CDRContentCollector.cpp +++ b/src/lib/CDRContentCollector.cpp @@ -111,7 +111,7 @@ void libcdr::CDRContentCollector::collectObject(unsigned level) m_currentObjectLevel = level; m_currentFildId = 0; m_currentOutlId = 0; - m_currentBBox = CDRBBox(); + m_currentBBox = CDRBox(); } void libcdr::CDRContentCollector::collectGroup(unsigned level) @@ -1086,7 +1086,7 @@ void libcdr::CDRContentCollector::collectFillOpacity(double opacity) void libcdr::CDRContentCollector::collectBBox(double x0, double y0, double x1, double y1) { - CDRBBox bBox(x0, y0, x1, y1); + CDRBox bBox(x0, y0, x1, y1); if (m_currentVectLevel && m_page.width == 0.0 && m_page.height == 0.0) { m_page.width = bBox.getWidth(); diff --git a/src/lib/CDRContentCollector.h b/src/lib/CDRContentCollector.h index 52daef8..abdaa2a 100644 --- a/src/lib/CDRContentCollector.h +++ b/src/lib/CDRContentCollector.h @@ -121,7 +121,7 @@ private: const std::vector<CDRText> *m_currentText; double m_currentTextOffsetX; double m_currentTextOffsetY; - CDRBBox m_currentBBox; + CDRBox m_currentBBox; CDRPath m_currentPath; CDRTransforms m_currentTransforms; diff --git a/src/lib/CDRTypes.h b/src/lib/CDRTypes.h index ff371ba..b6e19c7 100644 --- a/src/lib/CDRTypes.h +++ b/src/lib/CDRTypes.h @@ -38,15 +38,15 @@ namespace libcdr { class CDRPath; -struct CDRBBox +struct CDRBox { double m_x; double m_y; double m_w; double m_h; - CDRBBox() + CDRBox() : m_x(0.0), m_y(0.0), m_w(0.0), m_h(0.0) {} - CDRBBox(double x0, double y0, double x1, double y1) + CDRBox(double x0, double y0, double x1, double y1) : m_x(x0 < x1 ? x0 : x1), m_y(y0 < y1 ? y0 : y1), m_w(fabs(x1-x0)), m_h(fabs(y1-y0)) {} double getWidth() const { diff --git a/src/lib/CMXParser.cpp b/src/lib/CMXParser.cpp index 9df2b56..ce0150a 100644 --- a/src/lib/CMXParser.cpp +++ b/src/lib/CMXParser.cpp @@ -199,7 +199,7 @@ void libcdr::CMXParser::readCMXHeader(WPXInputStream *input) m_infoSectionOffset = readU32(input, m_bigEndian); m_thumbnailOffset = readU32(input, m_bigEndian); #ifdef DEBUG - CDRBBox box = readBBox(input); + CDRBox box = readBBox(input); #endif CDR_DEBUG_MSG(("CMX Offsets: index section 0x%.8x, info section: 0x%.8x, thumbnail: 0x%.8x\n", m_indexSectionOffset, m_infoSectionOffset, m_thumbnailOffset)); @@ -297,7 +297,7 @@ void libcdr::CMXParser::readPage(WPXInputStream *input, unsigned length) void libcdr::CMXParser::readBeginPage(WPXInputStream *input) { - CDRBBox box; + CDRBox box; CDRTransform matrix; unsigned flags = 0; if (m_precision == libcdr::PRECISION_32BIT) @@ -622,13 +622,13 @@ libcdr::CDRTransform libcdr::CMXParser::readMatrix(WPXInputStream *input) } } -libcdr::CDRBBox libcdr::CMXParser::readBBox(WPXInputStream *input) +libcdr::CDRBox libcdr::CMXParser::readBBox(WPXInputStream *input) { double x0 = readCoordinate(input, m_bigEndian); double y0 = readCoordinate(input, m_bigEndian); double x1 = readCoordinate(input, m_bigEndian); double y1 = readCoordinate(input, m_bigEndian); - CDRBBox box(x0, y0, x1, y1); + CDRBox box(x0, y0, x1, y1); return box; } diff --git a/src/lib/CMXParser.h b/src/lib/CMXParser.h index 9fa44eb..a2f814a 100644 --- a/src/lib/CMXParser.h +++ b/src/lib/CMXParser.h @@ -73,7 +73,7 @@ private: // Types readers CDRTransform readMatrix(WPXInputStream *input); - CDRBBox readBBox(WPXInputStream *input); + CDRBox readBBox(WPXInputStream *input); void readFill(WPXInputStream *input); // Complex types readers commit 59a24dd4cc9a8aa697609e5d21c789f901709e3d Author: Fridrich Å trba <fridrich.st...@bluewin.ch> Date: Tue Mar 5 09:30:20 2013 +0100 Stub reading and processing of text coordinates diff --git a/src/lib/CDRCollector.h b/src/lib/CDRCollector.h index e2cac1f..c481a53 100644 --- a/src/lib/CDRCollector.h +++ b/src/lib/CDRCollector.h @@ -126,8 +126,8 @@ public: virtual void collectFont(unsigned fontId, unsigned short fontEncoding, const WPXString &font) = 0; virtual void collectText(unsigned textId, unsigned styleId, const std::vector<unsigned char> &data, const std::vector<uint64_t> &charDescriptions, const std::map<unsigned, CDRCharacterStyle> &styleOverrides) = 0; - virtual void collectArtisticText() = 0; - virtual void collectParagraphText() = 0; + virtual void collectArtisticText(double x, double y) = 0; + virtual void collectParagraphText(double x, double y, double width, double height) = 0; virtual void collectStlt(const std::map<unsigned, CDRCharacterStyle> &charStyles) = 0; }; diff --git a/src/lib/CDRContentCollector.cpp b/src/lib/CDRContentCollector.cpp index 3e9669f..c2a3702 100644 --- a/src/lib/CDRContentCollector.cpp +++ b/src/lib/CDRContentCollector.cpp @@ -1137,14 +1137,14 @@ void libcdr::CDRContentCollector::collectVectorPattern(unsigned id, const WPXBin #endif } -void libcdr::CDRContentCollector::collectArtisticText() +void libcdr::CDRContentCollector::collectArtisticText(double /* x */, double /* y */) { std::map<unsigned, std::vector<CDRText> >::const_iterator iter = m_ps.m_texts.find(m_spnd); if (iter != m_ps.m_texts.end()) m_currentText = &(iter->second); } -void libcdr::CDRContentCollector::collectParagraphText() +void libcdr::CDRContentCollector::collectParagraphText(double /* x */, double /* y */, double /* width */, double /* height */) { std::map<unsigned, std::vector<CDRText> >::const_iterator iter = m_ps.m_texts.find(m_spnd); if (iter != m_ps.m_texts.end()) diff --git a/src/lib/CDRContentCollector.h b/src/lib/CDRContentCollector.h index 56fc5ce..52daef8 100644 --- a/src/lib/CDRContentCollector.h +++ b/src/lib/CDRContentCollector.h @@ -89,8 +89,8 @@ public: void collectFont(unsigned, unsigned short, const WPXString &) {} void collectText(unsigned, unsigned, const std::vector<unsigned char>&, const std::vector<uint64_t>&, const std::map<unsigned, CDRCharacterStyle>&) {} - void collectArtisticText(); - void collectParagraphText(); + void collectArtisticText(double x, double y); + void collectParagraphText(double x, double y, double width, double height); void collectStlt(const std::map<unsigned, CDRCharacterStyle> &) {} private: diff --git a/src/lib/CDRParser.cpp b/src/lib/CDRParser.cpp index 08dcccf..631a2f1 100644 --- a/src/lib/CDRParser.cpp +++ b/src/lib/CDRParser.cpp @@ -1962,11 +1962,11 @@ void libcdr::CDRParser::readLoda(WPXInputStream *input, unsigned length) else if (chunkType == 0x25) // Path readPath(input); else if ((m_version >= 400 && chunkType == 0x04) || (m_version < 400 && chunkType == 0x03)) // Artistic text - m_collector->collectArtisticText(); + readArtisticText(input); else if ((m_version >= 400 && chunkType == 0x05) || (m_version < 400 && chunkType == 0x04)) // Bitmap readBitmap(input); else if ((m_version >= 400 && chunkType == 0x06) || (m_version < 400 && chunkType == 0x05)) // Paragraph text - m_collector->collectParagraphText(); + readParagraphText(input); else if (chunkType == 0x14) // Polygon readPolygonCoords(input); } @@ -2975,4 +2975,19 @@ void libcdr::CDRParser::readStyd(WPXInputStream *input) input->seek(startPosition+chunkLength, WPX_SEEK_SET); } +void libcdr::CDRParser::readArtisticText(WPXInputStream *input) +{ + double x = readCoordinate(input); + double y = readCoordinate(input); + m_collector->collectArtisticText(x, y); +} + +void libcdr::CDRParser::readParagraphText(WPXInputStream *input) +{ + input->seek(4, WPX_SEEK_CUR); + double width = readCoordinate(input); + double height = readCoordinate(input); + m_collector->collectParagraphText(0.0, 0.0, width, height); +} + /* vim:set shiftwidth=2 softtabstop=2 expandtab: */ diff --git a/src/lib/CDRParser.h b/src/lib/CDRParser.h index 967ed57..9e74bf8 100644 --- a/src/lib/CDRParser.h +++ b/src/lib/CDRParser.h @@ -108,6 +108,8 @@ private: void readTxsm16(WPXInputStream *input); void readTxsm6(WPXInputStream *input); void readTxsm5(WPXInputStream *input); + void readArtisticText(WPXInputStream *input); + void readParagraphText(WPXInputStream *input); bool _redirectX6Chunk(WPXInputStream **input, unsigned &length); diff --git a/src/lib/CDRStylesCollector.h b/src/lib/CDRStylesCollector.h index c284cf2..2f7742a 100644 --- a/src/lib/CDRStylesCollector.h +++ b/src/lib/CDRStylesCollector.h @@ -91,8 +91,8 @@ public: void collectFont(unsigned fontId, unsigned short fontEncoding, const WPXString &font); void collectText(unsigned textId, unsigned styleId, const std::vector<unsigned char> &data, const std::vector<uint64_t> &charDescriptions, const std::map<unsigned, CDRCharacterStyle> &styleOverrides); - void collectArtisticText() {} - void collectParagraphText() {} + void collectArtisticText(double, double) {} + void collectParagraphText(double, double, double, double) {} void collectStlt(const std::map<unsigned, CDRCharacterStyle> &charStyles); private:
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits