From 343b52ee76f1a88a27007319af644dcce76536cc Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 22 Feb 2012 11:38:29 +0100 Subject: implement RTF import of non-box paragraph borders --- writerfilter/source/rtftok/rtfdocumentimpl.cxx | 30 ++++++++++++++++++++++++-- writerfilter/source/rtftok/rtfdocumentimpl.hxx | 1 + 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 806b43f6ca8f..4b1a1a71d2df 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& 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& 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 a6c09951c828..3644375adcb6 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 }; -- cgit