diff options
author | Miklos Vajna <vmiklos@suse.cz> | 2012-11-13 17:30:18 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2012-11-14 09:43:51 +0100 |
commit | c4b91ae3178011c66c76c711c1a6469ba658872e (patch) | |
tree | e9d2dd98a395cb1cff67fe53fe77a18694010ca2 /writerfilter/source | |
parent | Deliver the right curl libraries (diff) | |
download | core-c4b91ae3178011c66c76c711c1a6469ba658872e.tar.gz core-c4b91ae3178011c66c76c711c1a6469ba658872e.zip |
fdo#55525 import RTF_TRLEFT
Additionally:
1) Make sure cell margins are zero when they are not defined.
2) Handle cellx values in case of a negative left margin.
Change-Id: I9b8fb700b6459e622396c98e4344aba79f62c96e
Diffstat (limited to 'writerfilter/source')
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.cxx | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index fd00febd19cd..8ef259fdad2c 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -1699,6 +1699,22 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword) RTFValue::Pointer_t pRowValue(new RTFValue(1)); if (m_aStates.top().nCells > 0) m_aStates.top().aTableRowSprms.set(NS_sprm::LN_PRow, pRowValue); + + RTFValue::Pointer_t pCellMar = m_aStates.top().aTableRowSprms.find(NS_ooxml::LN_CT_TblPrBase_tblCellMar); + if (!pCellMar.get()) + { + // If no cell margins are defined, the default left/right margin is 0 in Word, but not in Writer. + RTFSprms aAttributes; + aAttributes.set(NS_ooxml::LN_CT_TblWidth_type, RTFValue::Pointer_t(new RTFValue(NS_ooxml::LN_Value_ST_TblWidth_dxa))); + aAttributes.set(NS_ooxml::LN_CT_TblWidth_w, RTFValue::Pointer_t(new RTFValue(0))); + lcl_putNestedSprm(m_aStates.top().aTableRowSprms, + NS_ooxml::LN_CT_TblPrBase_tblCellMar, NS_ooxml::LN_CT_TblCellMar_left, + RTFValue::Pointer_t(new RTFValue(aAttributes))); + lcl_putNestedSprm(m_aStates.top().aTableRowSprms, + NS_ooxml::LN_CT_TblPrBase_tblCellMar, NS_ooxml::LN_CT_TblCellMar_right, + RTFValue::Pointer_t(new RTFValue(aAttributes))); + } + writerfilter::Reference<Properties>::Pointer_t const pTableRowProperties( new RTFReferenceProperties(m_aStates.top().aTableRowAttributes, m_aStates.top().aTableRowSprms) ); @@ -2845,6 +2861,16 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) case RTF_CELLX: { int nCellX = nParam - m_aStates.top().nCellX; + + // If there is a negative left margin, then the first cellx is relateve to that. + RTFValue::Pointer_t pTblInd = m_aStates.top().aTableRowSprms.find(NS_ooxml::LN_CT_TblPrBase_tblInd); + if (m_aStates.top().nCellX == 0 && pTblInd.get()) + { + RTFValue::Pointer_t pWidth = pTblInd->getAttributes().find(NS_ooxml::LN_CT_TblWidth_w); + if (pWidth.get() && pWidth->getInt() < 0) + nCellX = -1 * (pWidth->getInt() - nParam); + } + m_aStates.top().nCellX = nParam; RTFValue::Pointer_t pXValue(new RTFValue(nCellX)); m_aStates.top().aTableRowSprms.set(NS_ooxml::LN_CT_TblGridBase_gridCol, pXValue, false); @@ -2880,6 +2906,17 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) NS_ooxml::LN_CT_TrPrBase_trHeight, NS_ooxml::LN_CT_Height_hRule, pHRule); } break; + case RTF_TRLEFT: + { + // the value is in twips + lcl_putNestedAttribute(m_aStates.top().aTableRowSprms, + NS_ooxml::LN_CT_TblPrBase_tblInd, NS_ooxml::LN_CT_TblWidth_type, + RTFValue::Pointer_t(new RTFValue(NS_ooxml::LN_Value_ST_TblWidth_dxa))); + lcl_putNestedAttribute(m_aStates.top().aTableRowSprms, + NS_ooxml::LN_CT_TblPrBase_tblInd, NS_ooxml::LN_CT_TblWidth_w, + RTFValue::Pointer_t(new RTFValue(nParam))); + } + break; case RTF_COLS: lcl_putNestedAttribute(m_aStates.top().aSectionSprms, NS_ooxml::LN_EG_SectPrContents_cols, NS_ooxml::LN_CT_Columns_num, pIntValue); |