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

New commits:
commit fe4cea3e8b7416151f67bc6e72e12cc6cf6a0f6d
Author: Miklos Vajna <[email protected]>
Date:   Wed Feb 22 11:43:25 2012 +0100

    RTF: clean up border property handling

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx 
b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 4b1a1a7..581f912 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -146,6 +146,7 @@ static RTFSprms& lcl_getLastAttributes(RTFSprms& rSprms, Id 
nId)
 
 static void lcl_putBorderProperty(std::stack<RTFParserState>& aStates, Id nId, 
RTFValue::Pointer_t pValue)
 {
+    RTFSprms* pAttributes = 0;
     if (aStates.top().nBorderState == BORDER_PARAGRAPH_BOX)
         for (int i = 0; i < 4; i++)
         {
@@ -156,24 +157,15 @@ static void 
lcl_putBorderProperty(std::stack<RTFParserState>& aStates, Id nId, R
                 rAttributes->push_back(make_pair(nId, pValue));
             }
         }
+    // Attributes of the last border type
     else if (aStates.top().nBorderState == BORDER_PARAGRAPH)
-    {
-        // Attributes of the last border type
-        RTFSprms& rAttributes = 
lcl_getLastAttributes(aStates.top().aParagraphSprms, 
NS_ooxml::LN_CT_PrBase_pBdr);
-        rAttributes->push_back(make_pair(nId, pValue));
-    }
+        pAttributes = &lcl_getLastAttributes(aStates.top().aParagraphSprms, 
NS_ooxml::LN_CT_PrBase_pBdr);
     else if (aStates.top().nBorderState == BORDER_CELL)
-    {
-        // Attributes of the last border type
-        RTFSprms& rAttributes = 
lcl_getLastAttributes(aStates.top().aTableCellSprms, 
NS_ooxml::LN_CT_TcPrBase_tcBorders);
-        rAttributes->push_back(make_pair(nId, pValue));
-    }
+        pAttributes = &lcl_getLastAttributes(aStates.top().aTableCellSprms, 
NS_ooxml::LN_CT_TcPrBase_tcBorders);
     else if (aStates.top().nBorderState == BORDER_PAGE)
-    {
-        // Attributes of the last border type
-        RTFSprms& rAttributes = 
lcl_getLastAttributes(aStates.top().aSectionSprms, 
NS_ooxml::LN_EG_SectPrContents_pgBorders);
-        rAttributes->push_back(make_pair(nId, pValue));
-    }
+        pAttributes = &lcl_getLastAttributes(aStates.top().aSectionSprms, 
NS_ooxml::LN_EG_SectPrContents_pgBorders);
+    if (pAttributes)
+        (*pAttributes)->push_back(make_pair(nId, pValue));
 }
 
 // NEEDSWORK: DocxAttributeOutput's impl_AppendTwoDigits does the same.
commit 343b52ee76f1a88a27007319af644dcce76536cc
Author: Miklos Vajna <[email protected]>
Date:   Wed Feb 22 11:38:29 2012 +0100

    implement RTF import of non-box paragraph borders

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx 
b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 806b43f..4b1a1a7 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -146,7 +146,7 @@ static RTFSprms& lcl_getLastAttributes(RTFSprms& rSprms, Id 
nId)
 
 static void lcl_putBorderProperty(std::stack<RTFParserState>& aStates, Id nId, 
RTFValue::Pointer_t pValue)
 {
-    if (aStates.top().nBorderState == BORDER_PARAGRAPH)
+    if (aStates.top().nBorderState == BORDER_PARAGRAPH_BOX)
         for (int i = 0; i < 4; i++)
         {
             RTFValue::Pointer_t p = 
aStates.top().aParagraphSprms.find(lcl_getParagraphBorder(i));
@@ -156,6 +156,12 @@ static void 
lcl_putBorderProperty(std::stack<RTFParserState>& aStates, Id nId, R
                 rAttributes->push_back(make_pair(nId, pValue));
             }
         }
+    else if (aStates.top().nBorderState == BORDER_PARAGRAPH)
+    {
+        // Attributes of the last border type
+        RTFSprms& rAttributes = 
lcl_getLastAttributes(aStates.top().aParagraphSprms, 
NS_ooxml::LN_CT_PrBase_pBdr);
+        rAttributes->push_back(make_pair(nId, pValue));
+    }
     else if (aStates.top().nBorderState == BORDER_CELL)
     {
         // Attributes of the last border type
@@ -1772,7 +1778,7 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
                 
m_aStates.top().aParagraphSprms->push_back(make_pair(NS_sprm::LN_PBrcLeft, 
pValue));
                 
m_aStates.top().aParagraphSprms->push_back(make_pair(NS_sprm::LN_PBrcBottom, 
pValue));
                 
m_aStates.top().aParagraphSprms->push_back(make_pair(NS_sprm::LN_PBrcRight, 
pValue));
-                m_aStates.top().nBorderState = BORDER_PARAGRAPH;
+                m_aStates.top().nBorderState = BORDER_PARAGRAPH_BOX;
             }
             break;
         case RTF_LTRSECT:
@@ -1849,6 +1855,26 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
                 m_aStates.top().nBorderState = BORDER_PAGE;
             }
             break;
+        case RTF_BRDRT:
+        case RTF_BRDRL:
+        case RTF_BRDRB:
+        case RTF_BRDRR:
+            {
+                RTFSprms aAttributes;
+                RTFSprms aSprms;
+                RTFValue::Pointer_t pValue(new RTFValue(aAttributes, aSprms));
+                switch (nKeyword)
+                {
+                    case RTF_BRDRT: nParam = lcl_getParagraphBorder(0); break;
+                    case RTF_BRDRL: nParam = lcl_getParagraphBorder(1); break;
+                    case RTF_BRDRB: nParam = lcl_getParagraphBorder(2); break;
+                    case RTF_BRDRR: nParam = lcl_getParagraphBorder(3); break;
+                    default: break;
+                }
+                lcl_putNestedSprm(m_aStates.top().aParagraphSprms, 
NS_ooxml::LN_CT_PrBase_pBdr, nParam, pValue);
+                m_aStates.top().nBorderState = BORDER_PARAGRAPH;
+            }
+            break;
         case RTF_CLVMGF:
             {
                 RTFValue::Pointer_t pValue(new 
RTFValue(NS_ooxml::LN_Value_ST_Merge_restart));
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx 
b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index a6c0995..3644375 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -116,6 +116,7 @@ namespace writerfilter {
         {
             BORDER_NONE,
             BORDER_PARAGRAPH,
+            BORDER_PARAGRAPH_BOX,
             BORDER_CELL,
             BORDER_PAGE
         };
_______________________________________________
Libreoffice-commits mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to