[Libreoffice-commits] .: Branch 'libreoffice-3-6' - writerfilter/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Nov 14 03:06:42 PST 2012
writerfilter/source/rtftok/rtfdocumentimpl.cxx | 37 +++++++++++++++++++++++++
1 file changed, 37 insertions(+)
New commits:
commit 2ebbfbb64ea0c1034e3d62e63d4212399b8651d6
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Tue Nov 13 17:30:18 2012 +0100
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.
(cherry picked from commit c4b91ae3178011c66c76c711c1a6469ba658872e)
Change-Id: I9b8fb700b6459e622396c98e4344aba79f62c96e
Reviewed-on: https://gerrit.libreoffice.org/1058
Reviewed-by: Tor Lillqvist <tml at iki.fi>
Tested-by: Tor Lillqvist <tml at iki.fi>
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index b84e303..cb54d38 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1583,6 +1583,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)
);
@@ -2642,6 +2658,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);
@@ -2677,6 +2703,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);
More information about the Libreoffice-commits
mailing list