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


Hi,

See
http://cgit.freedesktop.org/libreoffice/core/commit/?id=eeafdc5
http://cgit.freedesktop.org/libreoffice/core/commit/?id=ea04bbd

Regression from 3.4 -- neither of these applied cleanly in -3-5, so I'm
attaching backports. Testcase at sw/qa/extras/rtftok/data/fdo47107.rtf
on master.

(Yes, the first commit is a larger one, could not find a shorter way to
fix this.)

Thanks,

Miklos
From 2f3511ecd32d64b761ebef5e0b624891a9c75e50 Mon Sep 17 00:00:00 2001
From: Miklos Vajna <vmiklos@suse.cz>
Date: Wed, 11 Apr 2012 11:34:11 +0200
Subject: [PATCH 1/2] fdo#47107 rtftok: initial PN (legacy numbering syntax)
 support

---
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |   93 ++++++++++++++++++++++++
 writerfilter/source/rtftok/rtfdocumentimpl.hxx |    5 +-
 2 files changed, 97 insertions(+), 1 deletions(-)

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx 
b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index a117ec6..8e0cbce 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -920,6 +920,7 @@ void RTFDocumentImpl::text(OUString& rString)
         case DESTINATION_ANNOTATIONDATE:
         case DESTINATION_ANNOTATIONAUTHOR:
         case DESTINATION_FALT:
+        case DESTINATION_PARAGRAPHNUMBERING_TEXTAFTER:
             m_aStates.top().aDestinationText.append(rString);
             break;
         case DESTINATION_EQINSTRUCTION:
@@ -1338,6 +1339,16 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
         case RTF_DO:
             m_aStates.top().nDestinationState = DESTINATION_DRAWINGOBJECT;
             break;
+        case RTF_PN:
+            m_aStates.top().nDestinationState = DESTINATION_PARAGRAPHNUMBERING;
+            break;
+        case RTF_PNTEXT:
+            // This destination should be ignored by readers that support paragraph numbering.
+            m_aStates.top().nDestinationState = DESTINATION_SKIP;
+            break;
+        case RTF_PNTXTA:
+            m_aStates.top().nDestinationState = DESTINATION_PARAGRAPHNUMBERING_TEXTAFTER;
+            break;
         default:
 #if OSL_DEBUG_LEVEL > 1
             OSL_TRACE("%s: TODO handle destination '%s'", OSL_THIS_FUNC, 
lcl_RtfToString(nKeyword));
@@ -2066,6 +2077,18 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
                     m_aStates.top().aDrawingObject.aPendingProperties.push_back(aPropertyValue);
                 }
                 break;
+        case RTF_PNLVLBODY:
+                {
+                    RTFValue::Pointer_t pValue(new RTFValue(2));
+                    m_aStates.top().aTableAttributes->push_back(make_pair(NS_rtf::LN_LSID, 
pValue));
+                }
+                break;
+        case RTF_PNDEC:
+                {
+                    RTFValue::Pointer_t pValue(new RTFValue(0)); // decimal, same as \levelnfc0
+                    m_aStates.top().aTableSprms->push_back(make_pair(NS_rtf::LN_NFC, pValue));
+                }
+                break;
         default:
 #if OSL_DEBUG_LEVEL > 1
             OSL_TRACE("%s: TODO handle flag '%s'", OSL_THIS_FUNC, lcl_RtfToString(nKeyword));
@@ -2718,6 +2741,9 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
         case RTF_DPYSIZE:
             m_aStates.top().aDrawingObject.nBottom = TWIP_TO_MM100(nParam);
             break;
+        case RTF_PNSTART:
+            m_aStates.top().aTableSprms->push_back(make_pair(NS_rtf::LN_ISTARTAT, pIntValue));
+            break;
         default:
 #if OSL_DEBUG_LEVEL > 1
             OSL_TRACE("%s: TODO handle value '%s'", OSL_THIS_FUNC, lcl_RtfToString(nKeyword));
@@ -3319,6 +3345,73 @@ int RTFDocumentImpl::popState()
         RTFValue::Pointer_t pValue(new RTFValue(aAttributes, aSprms));
         m_aListTableSprms->push_back(make_pair(NS_ooxml::LN_CT_Numbering_abstractNum, pValue));
     }
+    else if (aState.nDestinationState == DESTINATION_PARAGRAPHNUMBERING)
+    {
+        RTFValue::Pointer_t pIdValue = aState.aTableAttributes.find(NS_rtf::LN_LSID);
+        if (pIdValue.get())
+        {
+            // Abstract numbering
+            RTFSprms aLeveltextAttributes;
+            OUString aTextValue(RTL_CONSTASCII_USTRINGPARAM("%1"));
+            RTFValue::Pointer_t pTextAfter = 
aState.aTableAttributes.find(NS_ooxml::LN_CT_LevelText_val);
+            if (pTextAfter.get())
+                aTextValue += pTextAfter->getString();
+            RTFValue::Pointer_t pTextValue(new RTFValue(aTextValue));
+            aLeveltextAttributes->push_back(make_pair(NS_ooxml::LN_CT_LevelText_val, pTextValue));
+
+            RTFSprms aLevelAttributes;
+            RTFSprms aLevelSprms;
+            RTFValue::Pointer_t pIlvlValue(new RTFValue(0));
+            aLevelAttributes->push_back(make_pair(NS_ooxml::LN_CT_Lvl_ilvl, pIlvlValue));
+
+            RTFValue::Pointer_t pNfcValue = aState.aTableSprms.find(NS_rtf::LN_NFC);
+            if (pNfcValue.get())
+                aLevelSprms->push_back(make_pair(NS_rtf::LN_NFC, pNfcValue));
+
+            RTFValue::Pointer_t pStartatValue = aState.aTableSprms.find(NS_rtf::LN_ISTARTAT);
+            if (pStartatValue.get())
+                aLevelSprms->push_back(make_pair(NS_rtf::LN_ISTARTAT, pStartatValue));
+
+            RTFValue::Pointer_t pLeveltextValue(new RTFValue(aLeveltextAttributes));
+            aLevelSprms->push_back(make_pair(NS_ooxml::LN_CT_Lvl_lvlText, pLeveltextValue));
+
+            RTFSprms aAbstractAttributes;
+            RTFSprms aAbstractSprms;
+            aAbstractAttributes->push_back(make_pair(NS_ooxml::LN_CT_AbstractNum_abstractNumId, 
pIdValue));
+            RTFValue::Pointer_t pLevelValue(new RTFValue(aLevelAttributes, aLevelSprms));
+            aAbstractSprms->push_back(make_pair(NS_ooxml::LN_CT_AbstractNum_lvl, pLevelValue));
+
+            RTFSprms aListTableSprms;
+            RTFValue::Pointer_t pAbstractValue(new RTFValue(aAbstractAttributes, aAbstractSprms));
+            aListTableSprms->push_back(make_pair(NS_ooxml::LN_CT_Numbering_abstractNum, 
pAbstractValue));
+
+            // Numbering
+            RTFSprms aNumberingAttributes;
+            RTFSprms aNumberingSprms;
+            aNumberingAttributes->push_back(make_pair(NS_rtf::LN_LSID, pIdValue));
+            aNumberingSprms->push_back(make_pair(NS_ooxml::LN_CT_Num_abstractNumId, pIdValue));
+            RTFValue::Pointer_t pNumberingValue(new RTFValue(aNumberingAttributes, 
aNumberingSprms));
+            aListTableSprms->push_back(make_pair(NS_ooxml::LN_CT_Numbering_num, pNumberingValue));
+
+            // Table
+            RTFSprms aListTableAttributes;
+            writerfilter::Reference<Properties>::Pointer_t const pProp(new 
RTFReferenceProperties(aListTableAttributes, aListTableSprms));
+
+            RTFReferenceTable::Entries_t aListTableEntries;
+            aListTableEntries.insert(make_pair(0, pProp));
+            writerfilter::Reference<Table>::Pointer_t const pTable(new 
RTFReferenceTable(aListTableEntries));
+            Mapper().table(NS_rtf::LN_LISTTABLE, pTable);
+
+            // Use it
+            lcl_putNestedSprm(m_aStates.top().aParagraphSprms, NS_ooxml::LN_CT_PPrBase_numPr, 
NS_sprm::LN_PIlvl, pIlvlValue);
+            lcl_putNestedSprm(m_aStates.top().aParagraphSprms, NS_ooxml::LN_CT_PPrBase_tabs, 
NS_sprm::LN_PIlfo, pIdValue);
+        }
+    }
+    else if (aState.nDestinationState == DESTINATION_PARAGRAPHNUMBERING_TEXTAFTER)
+    {
+        RTFValue::Pointer_t pValue(new RTFValue(aState.aDestinationText.makeStringAndClear(), 
true));
+        m_aStates.top().aTableAttributes->push_back(make_pair(NS_ooxml::LN_CT_LevelText_val, 
pValue));
+    }
     else if (bListLevelEnd)
     {
         RTFValue::Pointer_t pInnerValue(new RTFValue(m_aStates.top().nListLevelNum++));
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx 
b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 461b88e..f81cd7f 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -109,7 +109,10 @@ namespace writerfilter {
             DESTINATION_ANNOTATIONAUTHOR,
             DESTINATION_FALT,
             DESTINATION_FLYMAINCONTENT,
-            DESTINATION_DRAWINGOBJECT
+            DESTINATION_DRAWINGOBJECT,
+            DESTINATION_PARAGRAPHNUMBERING,
+            DESTINATION_PARAGRAPHNUMBERING_TEXTAFTER
+
         };
 
         enum RTFBorderState
-- 
1.7.7

From 79b7ec72a16c8ef82312a7948eec9b18965c14b9 Mon Sep 17 00:00:00 2001
From: Miklos Vajna <vmiklos@suse.cz>
Date: Wed, 11 Apr 2012 11:53:05 +0200
Subject: [PATCH 2/2] fdo#47107 rtftok: support bullet points in paragraph
 numberings

---
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |   33 ++++++++++++++++++++++-
 writerfilter/source/rtftok/rtfdocumentimpl.hxx |    1 +
 2 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx 
b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 8e0cbce..04160e6 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -921,6 +921,7 @@ void RTFDocumentImpl::text(OUString& rString)
         case DESTINATION_ANNOTATIONAUTHOR:
         case DESTINATION_FALT:
         case DESTINATION_PARAGRAPHNUMBERING_TEXTAFTER:
+        case DESTINATION_PARAGRAPHNUMBERING_TEXTBEFORE:
             m_aStates.top().aDestinationText.append(rString);
             break;
         case DESTINATION_EQINSTRUCTION:
@@ -1349,6 +1350,9 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
         case RTF_PNTXTA:
             m_aStates.top().nDestinationState = DESTINATION_PARAGRAPHNUMBERING_TEXTAFTER;
             break;
+        case RTF_PNTXTB:
+            m_aStates.top().nDestinationState = DESTINATION_PARAGRAPHNUMBERING_TEXTBEFORE;
+            break;
         default:
 #if OSL_DEBUG_LEVEL > 1
             OSL_TRACE("%s: TODO handle destination '%s'", OSL_THIS_FUNC, 
lcl_RtfToString(nKeyword));
@@ -2089,6 +2093,12 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
                     m_aStates.top().aTableSprms->push_back(make_pair(NS_rtf::LN_NFC, pValue));
                 }
                 break;
+        case RTF_PNLVLBLT:
+                {
+                    m_aStates.top().aTableAttributes->push_back(make_pair(NS_rtf::LN_LSID, 
RTFValue::Pointer_t(new RTFValue(1))));
+                    m_aStates.top().aTableSprms->push_back(make_pair(NS_rtf::LN_NFC, 
RTFValue::Pointer_t(new RTFValue(23)))); // bullets, same as \levelnfc23
+                }
+                break;
         default:
 #if OSL_DEBUG_LEVEL > 1
             OSL_TRACE("%s: TODO handle flag '%s'", OSL_THIS_FUNC, lcl_RtfToString(nKeyword));
@@ -2744,6 +2754,13 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
         case RTF_PNSTART:
             m_aStates.top().aTableSprms->push_back(make_pair(NS_rtf::LN_ISTARTAT, pIntValue));
             break;
+        case RTF_PNF:
+            {
+                int nFontIndex = getFontIndex(nParam);
+                RTFValue::Pointer_t pValue(new RTFValue(nFontIndex));
+                lcl_putNestedSprm(m_aStates.top().aTableSprms, NS_ooxml::LN_CT_Lvl_rPr, 
NS_sprm::LN_CRgFtc0, pValue);
+            }
+            break;
         default:
 #if OSL_DEBUG_LEVEL > 1
             OSL_TRACE("%s: TODO handle value '%s'", OSL_THIS_FUNC, lcl_RtfToString(nKeyword));
@@ -3352,8 +3369,12 @@ int RTFDocumentImpl::popState()
         {
             // Abstract numbering
             RTFSprms aLeveltextAttributes;
-            OUString aTextValue(RTL_CONSTASCII_USTRINGPARAM("%1"));
-            RTFValue::Pointer_t pTextAfter = 
aState.aTableAttributes.find(NS_ooxml::LN_CT_LevelText_val);
+            OUString aTextValue;
+            RTFValue::Pointer_t pTextBefore = 
aState.aTableAttributes.find(NS_ooxml::LN_CT_LevelText_val);
+            if (pTextBefore.get())
+                aTextValue += pTextBefore->getString();
+            aTextValue += OUString(RTL_CONSTASCII_USTRINGPARAM("%1"));
+            RTFValue::Pointer_t pTextAfter = 
aState.aTableAttributes.find(NS_ooxml::LN_CT_LevelSuffix_val);
             if (pTextAfter.get())
                 aTextValue += pTextAfter->getString();
             RTFValue::Pointer_t pTextValue(new RTFValue(aTextValue));
@@ -3374,6 +3395,9 @@ int RTFDocumentImpl::popState()
 
             RTFValue::Pointer_t pLeveltextValue(new RTFValue(aLeveltextAttributes));
             aLevelSprms->push_back(make_pair(NS_ooxml::LN_CT_Lvl_lvlText, pLeveltextValue));
+            RTFValue::Pointer_t pRunProps = aState.aTableSprms.find(NS_ooxml::LN_CT_Lvl_rPr);
+            if (pRunProps.get())
+                aLevelSprms->push_back(make_pair(NS_ooxml::LN_CT_Lvl_rPr, pRunProps));
 
             RTFSprms aAbstractAttributes;
             RTFSprms aAbstractSprms;
@@ -3410,6 +3434,11 @@ int RTFDocumentImpl::popState()
     else if (aState.nDestinationState == DESTINATION_PARAGRAPHNUMBERING_TEXTAFTER)
     {
         RTFValue::Pointer_t pValue(new RTFValue(aState.aDestinationText.makeStringAndClear(), 
true));
+        m_aStates.top().aTableAttributes->push_back(make_pair(NS_ooxml::LN_CT_LevelSuffix_val, 
pValue));
+    }
+    else if (aState.nDestinationState == DESTINATION_PARAGRAPHNUMBERING_TEXTBEFORE)
+    {
+        RTFValue::Pointer_t pValue(new RTFValue(aState.aDestinationText.makeStringAndClear(), 
true));
         m_aStates.top().aTableAttributes->push_back(make_pair(NS_ooxml::LN_CT_LevelText_val, 
pValue));
     }
     else if (bListLevelEnd)
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx 
b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index f81cd7f..4a7551d 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -111,6 +111,7 @@ namespace writerfilter {
             DESTINATION_FLYMAINCONTENT,
             DESTINATION_DRAWINGOBJECT,
             DESTINATION_PARAGRAPHNUMBERING,
+            DESTINATION_PARAGRAPHNUMBERING_TEXTBEFORE,
             DESTINATION_PARAGRAPHNUMBERING_TEXTAFTER
 
         };
-- 
1.7.7


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.