Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


Hi,

this patch adds support for the drop caps letters setting.
+ it fixes the column-count and column-gap reading.

Greetings,
Franz Schmid
From 36f37dfd42b7ca2778a6c91135804135cd7d6f38 Mon Sep 17 00:00:00 2001
From: Franz Schmid <franz@linux-hp-i7.site>
Date: Wed, 1 May 2013 20:35:07 +0200
Subject: [PATCH] Added support for DropCaps letter setting and fixed column and
 column-gap output.

---
 src/lib/MSPUBBlockID.h     |    2 ++
 src/lib/MSPUBCollector.cpp |   18 ++++++++++++++++++
 src/lib/MSPUBParser.cpp    |   27 +++++++++++++++------------
 src/lib/MSPUBTypes.h       |    3 ++-
 4 files changed, 37 insertions(+), 13 deletions(-)

diff --git a/src/lib/MSPUBBlockID.h b/src/lib/MSPUBBlockID.h
index a44c5a8..4cd7c2b 100644
--- a/src/lib/MSPUBBlockID.h
+++ b/src/lib/MSPUBBlockID.h
@@ -69,6 +69,8 @@ enum MSPUBBlockID // Don't be alarmed by multiple elements with the same value;
   PARAGRAPH_LEFT_INDENT = 0xD,
   PARAGRAPH_RIGHT_INDENT = 0xE,
   PARAGRAPH_DROP_CAP_LINES = 0x8,
+  PARAGRAPH_DROP_CAP_UP = 0x2C,
+  PARAGRAPH_DROP_CAP_LETTERS = 0x2D,
   THIS_MASTER_NAME = 0xE,
   APPLIED_MASTER_NAME = 0xD,
   BA_ARRAY = 0x02,
diff --git a/src/lib/MSPUBCollector.cpp b/src/lib/MSPUBCollector.cpp
index f16ae79..a23c713 100644
--- a/src/lib/MSPUBCollector.cpp
+++ b/src/lib/MSPUBCollector.cpp
@@ -809,6 +809,18 @@ boost::function<void(void)> libmspub::MSPUBCollector::paintShape(const 
ShapeInfo
         break;
       }
     }
+    if (info.m_numColumns)
+    {
+      unsigned ncols = info.m_numColumns.get_value_or(0);
+      if (ncols > 0)
+        props.insert("fo:column-count", (int)ncols);
+    }
+    if (info.m_columnSpacing)
+    {
+      unsigned ngap = info.m_columnSpacing;
+      if (ngap > 0)
+        props.insert("fo:column-gap", (double)ngap / EMUS_IN_INCH);
+    }
     m_painter->startTextObject(props, WPXPropertyListVector());
     for (unsigned i_lines = 0; i_lines < text.size(); ++i_lines)
     {
@@ -1199,6 +1211,12 @@ WPXPropertyList libmspub::MSPUBCollector::getParaStyleProps(const 
ParagraphStyle
   {
     ret.insert("style:drop-cap", (int)dropCapLines);
   }
+  unsigned dropCapLetters = style.m_dropCapLetters.get_value_or(
+                              defaultStyle.m_dropCapLetters.get_value_or(0));
+  if (dropCapLetters != 0)
+  {
+    ret.insert("style:length", (int)dropCapLetters);
+  }
   return ret;
 }
 
diff --git a/src/lib/MSPUBParser.cpp b/src/lib/MSPUBParser.cpp
index 418ea1b..993b706 100644
--- a/src/lib/MSPUBParser.cpp
+++ b/src/lib/MSPUBParser.cpp
@@ -1263,6 +1263,9 @@ libmspub::ParagraphStyle 
libmspub::MSPUBParser::getParagraphStyle(WPXInputStream
     case PARAGRAPH_DROP_CAP_LINES:
       ret.m_dropCapLines = info.data;
       break;
+    case PARAGRAPH_DROP_CAP_LETTERS:
+      ret.m_dropCapLetters = info.data;
+      break;
     default:
       break;
     }
@@ -1686,17 +1689,19 @@ void libmspub::MSPUBParser::parseEscherShape(WPXInputStream *input, const 
Escher
                                         dotStyle));
           }
 
-          unsigned *ptr_numColumns = getIfExists(foptValues.m_scalarValues,
-                                                 FIELDID_NUM_COLUMNS);
-          if (ptr_numColumns)
-          {
-            m_collector->setShapeNumColumns(*shapeSeqNum, *ptr_numColumns);
-          }
-          unsigned *ptr_columnSpacing = getIfExists(foptValues.m_scalarValues,
-                                        FIELDID_COLUMN_SPACING);
-          if (ptr_columnSpacing)
+          if (!!maybe_tertiaryFoptValues)
           {
-            m_collector->setShapeColumnSpacing(*shapeSeqNum, *ptr_columnSpacing);
+            std::map<unsigned short, unsigned> &tertiaryFoptValues = 
maybe_tertiaryFoptValues.get();
+            unsigned *ptr_numColumns = getIfExists(tertiaryFoptValues, FIELDID_NUM_COLUMNS);
+            if (ptr_numColumns)
+            {
+              m_collector->setShapeNumColumns(*shapeSeqNum, *ptr_numColumns);
+            }
+            unsigned *ptr_columnSpacing = getIfExists(tertiaryFoptValues, FIELDID_COLUMN_SPACING);
+            if (ptr_columnSpacing)
+            {
+              m_collector->setShapeColumnSpacing(*shapeSeqNum, *ptr_columnSpacing);
+            }
           }
           unsigned *ptr_beginArrowStyle = getIfExists(foptValues.m_scalarValues,
                                           FIELDID_BEGIN_ARROW_STYLE);
@@ -1774,7 +1779,6 @@ void libmspub::MSPUBParser::parseEscherShape(WPXInputStream *input, const 
Escher
           {
             std::vector<libmspub::Vertex> ret = parseVertices(wrapVertexData);
             m_collector->setShapeClipPath(*shapeSeqNum, ret);
-            MSPUB_DEBUG_MSG(("Current Escher shape has wrap Path\n"));
           }
         }
         if (foundAnchor)
@@ -2171,7 +2175,6 @@ libmspub::FOPTValues libmspub::MSPUBParser::extractFOPTValues(WPXInputStream 
*in
     unsigned short id = readU16(input);
     unsigned value  = readU32(input);
     ret.m_scalarValues[id] = value;
-    MSPUB_DEBUG_MSG(("EscherFopt ID %u  Value %u\n", id, value));
     bool complex = id & 0x8000;
     if (complex)
     {
diff --git a/src/lib/MSPUBTypes.h b/src/lib/MSPUBTypes.h
index 946f9c4..984ce5c 100644
--- a/src/lib/MSPUBTypes.h
+++ b/src/lib/MSPUBTypes.h
@@ -159,10 +159,11 @@ struct ParagraphStyle
   boost::optional<ListInfo> m_listInfo;
   std::vector<unsigned> m_tabStopsInEmu;
   boost::optional<unsigned> m_dropCapLines;
+  boost::optional<unsigned> m_dropCapLetters;
   ParagraphStyle() :
     m_align(), m_defaultCharStyleIndex(), m_lineSpacing(), m_spaceBeforeEmu(),
     m_spaceAfterEmu(), m_firstLineIndentEmu(), m_leftIndentEmu(),
-    m_rightIndentEmu(), m_listInfo(), m_tabStopsInEmu(), m_dropCapLines()
+    m_rightIndentEmu(), m_listInfo(), m_tabStopsInEmu(), m_dropCapLines(), m_dropCapLetters()
   {
   }
 };
-- 
1.7.1


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.