[Libreoffice-commits] .: Branch 'libreoffice-3-5' - 2 commits - writerfilter/source

Caolán McNamara caolan at kemper.freedesktop.org
Wed Apr 11 05:28:46 PDT 2012


 writerfilter/source/rtftok/rtfdocumentimpl.cxx |  122 +++++++++++++++++++++++++
 writerfilter/source/rtftok/rtfdocumentimpl.hxx |    6 +
 2 files changed, 127 insertions(+), 1 deletion(-)

New commits:
commit 586d6a57564c4c75c6464ec91c6f676aa66b0638
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Wed Apr 11 11:53:05 2012 +0200

    fdo#47107 rtftok: support bullet points in paragraph numberings

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
 
         };
commit d7e0c3e1d0fc155402d0d8f3ddbd12077005e5dd
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Wed Apr 11 11:34:11 2012 +0200

    fdo#47107 rtftok: initial PN (legacy numbering syntax) support

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


More information about the Libreoffice-commits mailing list