[Libreoffice-commits] core.git: writerfilter/source
Miklos Vajna
vmiklos at collabora.co.uk
Tue Mar 4 10:23:13 PST 2014
writerfilter/source/dmapper/DomainMapper.cxx | 26 --------
writerfilter/source/doctok/resources.xmi | 77 -------------------------
writerfilter/source/rtftok/rtfdocumentimpl.cxx | 40 +++++++-----
writerfilter/source/rtftok/rtfsprm.cxx | 20 ++++--
writerfilter/source/rtftok/rtfsprm.hxx | 9 ++
5 files changed, 47 insertions(+), 125 deletions(-)
New commits:
commit e1e50f7b31a481f399318cb63efcae6c1d62f6f3
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Mar 4 18:57:27 2014 +0100
writerfilter: convert sprm:P{DxaRight,DxaLeft,DxaLeft1}
Change-Id: Iffb80e9844132aeeaf3e338c4817b44520e40f3a
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 39ce894..ccc6a85 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -973,7 +973,7 @@ static bool ExchangeLeftRight( const PropertyMapPtr rContext, DomainMapper_Impl*
return bExchangeLeftRight;
}
-void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType eSprmType )
+void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType /*eSprmType*/ )
{
OSL_ENSURE(rContext.get(), "PropertyMap has to be valid!");
if(!rContext.get())
@@ -1065,30 +1065,6 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType
case NS_ooxml::LN_CT_PPrBase_suppressLineNumbers:
rContext->Insert(PROP_PARA_LINE_NUMBER_COUNT, uno::makeAny( nIntValue ? false : true) );
break;
- case 0x845d: //right margin Asian - undocumented
- case 0x845e: //left margin Asian - undocumented
- case 16: // sprmPDxaRight - right margin
- case NS_sprm::LN_PDxaRight: // sprmPDxaRight - right margin
- case 17:
- case NS_sprm::LN_PDxaLeft: // sprmPDxaLeft
- {
- bool bExchangeLeftRight = ExchangeLeftRight( rContext, m_pImpl );
- if( NS_sprm::LN_PDxaLeft == nSprmId || 0x17 == nSprmId|| (bExchangeLeftRight && nSprmId == 0x845d) || ( !bExchangeLeftRight && nSprmId == 0x845e))
- rContext->Insert(
- eSprmType == SPRM_DEFAULT ? PROP_PARA_LEFT_MARGIN : PROP_LEFT_MARGIN,
- uno::makeAny( ConversionHelper::convertTwipToMM100( nIntValue ) ));
- else if(eSprmType == SPRM_DEFAULT)
- rContext->Insert(
- PROP_PARA_RIGHT_MARGIN,
- uno::makeAny( ConversionHelper::convertTwipToMM100(nIntValue ) ));
- }
- //TODO: what happens to the right margins in numberings?
- break;
- case NS_sprm::LN_PDxaLeft1: // sprmPDxaLeft1
- rContext->Insert(
- eSprmType == SPRM_DEFAULT ? PROP_PARA_FIRST_LINE_INDENT : PROP_FIRST_LINE_OFFSET,
- uno::makeAny( ConversionHelper::convertTwipToMM100(nIntValue ) ));
- break;
case NS_ooxml::LN_inTbl:
break;
case NS_ooxml::LN_tblDepth:
diff --git a/writerfilter/source/doctok/resources.xmi b/writerfilter/source/doctok/resources.xmi
index 4d0b7dd..7c955d1 100644
--- a/writerfilter/source/doctok/resources.xmi
+++ b/writerfilter/source/doctok/resources.xmi
@@ -7,68 +7,6 @@
<UML:Model name="WW8Document">
<UML:Namespace.ownedElement>
<!--SPRMS-->
- <!--SPRM sprmPDxaRight-->
- <UML:Class xmi.id="sprmPDxaRight" name="sprmPDxaRight">
- <UML:ModelElement.stereotype>
- <UML:Stereotype xmi.idref="ww8sprm"/>
- </UML:ModelElement.stereotype>
- <UML:ModelElement.taggedValue>
- <UML:TaggedValue>
- <UML:TaggedValue.dataValue>0x840E</UML:TaggedValue.dataValue>
- <UML:TaggedValue.type>
- <UML:TagDefinition xmi.idref="sprmcode"/>
- </UML:TaggedValue.type>
- </UML:TaggedValue>
- </UML:ModelElement.taggedValue>
- <UML:ModelElement.taggedValue>
- <UML:TaggedValue>
- <UML:TaggedValue.dataValue>rtf:sprmPDxaRight</UML:TaggedValue.dataValue>
- <UML:TaggedValue.type>
- <UML:TagDefinition xmi.idref="sprmid"/>
- </UML:TaggedValue.type>
- </UML:TaggedValue>
- </UML:ModelElement.taggedValue>
- <UML:ModelElement.taggedValue>
- <UML:TaggedValue>
- <UML:TaggedValue.dataValue>paragraph</UML:TaggedValue.dataValue>
- <UML:TaggedValue.type>
- <UML:TagDefinition xmi.idref="kind"/>
- </UML:TaggedValue.type>
- </UML:TaggedValue>
- </UML:ModelElement.taggedValue>
- </UML:Class>
- <!--SPRM sprmPDxaRight-->
- <!--SPRM sprmPDxaLeft-->
- <UML:Class xmi.id="sprmPDxaLeft" name="sprmPDxaLeft">
- <UML:ModelElement.stereotype>
- <UML:Stereotype xmi.idref="ww8sprm"/>
- </UML:ModelElement.stereotype>
- <UML:ModelElement.taggedValue>
- <UML:TaggedValue>
- <UML:TaggedValue.dataValue>0x840F</UML:TaggedValue.dataValue>
- <UML:TaggedValue.type>
- <UML:TagDefinition xmi.idref="sprmcode"/>
- </UML:TaggedValue.type>
- </UML:TaggedValue>
- </UML:ModelElement.taggedValue>
- <UML:ModelElement.taggedValue>
- <UML:TaggedValue>
- <UML:TaggedValue.dataValue>rtf:sprmPDxaLeft</UML:TaggedValue.dataValue>
- <UML:TaggedValue.type>
- <UML:TagDefinition xmi.idref="sprmid"/>
- </UML:TaggedValue.type>
- </UML:TaggedValue>
- </UML:ModelElement.taggedValue>
- <UML:ModelElement.taggedValue>
- <UML:TaggedValue>
- <UML:TaggedValue.dataValue>paragraph</UML:TaggedValue.dataValue>
- <UML:TaggedValue.type>
- <UML:TagDefinition xmi.idref="kind"/>
- </UML:TaggedValue.type>
- </UML:TaggedValue>
- </UML:ModelElement.taggedValue>
- </UML:Class>
- <!--SPRM sprmPDxaLeft-->
<!--SPRM sprmPFWidowControl-->
<UML:Class xmi.id="sprmPFWidowControl" name="sprmPFWidowControl">
<UML:ModelElement.stereotype>
@@ -317,21 +255,6 @@
</UML:ModelElement.taggedValue>
</UML:Class>
<!--SPRM sprmTTextFlow-->
- <!--SPRM sprmPDxaLeft1-->
- <UML:Class xmi.id="sprmPDxaLeft1" name="sprmPDxaLeft1">
- <UML:ModelElement.stereotype>
- <UML:Stereotype xmi.idref="ww8sprm"/>
- </UML:ModelElement.stereotype>
- <UML:ModelElement.taggedValue>
- <UML:TaggedValue>
- <UML:TaggedValue.dataValue>0x8460</UML:TaggedValue.dataValue>
- <UML:TaggedValue.type>
- <UML:TagDefinition xmi.idref="sprmcode"/>
- </UML:TaggedValue.type>
- </UML:TaggedValue>
- </UML:ModelElement.taggedValue>
- </UML:Class>
- <!--SPRM sprmPDxaLeft1-->
<!--SPRMS-->
</UML:Namespace.ownedElement>
</UML:Model>
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 6dbe1fb..60966e6 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -81,7 +81,7 @@ static Id lcl_getParagraphBorder(sal_uInt32 nIndex)
}
static void lcl_putNestedAttribute(RTFSprms& rSprms, Id nParent, Id nId, RTFValue::Pointer_t pValue,
- bool bOverwrite = true, bool bAttribute = true)
+ bool bOverwrite = true, bool bAttribute = true, bool bAppend = true)
{
RTFValue::Pointer_t pParent = rSprms.find(nParent);
if (!pParent.get())
@@ -94,11 +94,11 @@ static void lcl_putNestedAttribute(RTFSprms& rSprms, Id nParent, Id nId, RTFValu
aAttributes.set(NS_ooxml::LN_CT_Shd_fill, RTFValue::Pointer_t(new RTFValue(0x0a)));
}
RTFValue::Pointer_t pParentValue(new RTFValue(aAttributes));
- rSprms.set(nParent, pParentValue, bOverwrite);
+ rSprms.set(nParent, pParentValue, bOverwrite, bAppend);
pParent = pParentValue;
}
RTFSprms& rAttributes = (bAttribute ? pParent->getAttributes() : pParent->getSprms());
- rAttributes.set(nId, pValue, bOverwrite);
+ rAttributes.set(nId, pValue, bOverwrite, bAppend);
}
static void lcl_putNestedSprm(RTFSprms& rSprms, Id nParent, Id nId, RTFValue::Pointer_t pValue, bool bOverwrite = false)
@@ -3016,10 +3016,6 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
// Trivial paragraph sprms.
switch (nKeyword)
{
- case RTF_FI: nSprm = NS_sprm::LN_PDxaLeft1; break;
- case RTF_LIN: nSprm = 0x845e; break;
- case RTF_RI: nSprm = NS_sprm::LN_PDxaRight; break;
- case RTF_RIN: nSprm = 0x845d; break;
case RTF_ITAP: nSprm = NS_ooxml::LN_tblDepth; break;
case RTF_SBASEDON:
nSprm = NS_ooxml::LN_CT_Style_basedOn;
@@ -3845,15 +3841,6 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
case RTF_DPFILLBGCB:
m_aStates.top().aDrawingObject.nFillColorB = nParam; m_aStates.top().aDrawingObject.bHasFillColor = true;
break;
- case RTF_LI:
- {
- m_aStates.top().aParagraphSprms.set(NS_sprm::LN_PDxaLeft, pIntValue);
- // It turns out \li should reset the \fi inherited from the stylesheet.
- // So set the direct formatting to zero, if we don't have such direct formatting yet.
- if (!m_aStates.top().aParagraphSprms.find(NS_sprm::LN_PDxaLeft1).get())
- m_aStates.top().aParagraphSprms.set(NS_sprm::LN_PDxaLeft1, RTFValue::Pointer_t(new RTFValue(0)));
- }
- break;
case RTF_CLSHDNG:
{
int nValue = -1;
@@ -3961,6 +3948,27 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
lcl_putNestedSprm(m_aStates.top().aTableCellSprms, NS_ooxml::LN_CT_TcPrBase_tcMar, nSprm, RTFValue::Pointer_t(new RTFValue(aAttributes)));
}
break;
+ case RTF_FI:
+ lcl_putNestedAttribute(m_aStates.top().aParagraphSprms, NS_ooxml::LN_CT_PPrBase_ind, NS_ooxml::LN_CT_Ind_firstLine, pIntValue);
+ break;
+ case RTF_LI:
+ {
+ lcl_putNestedAttribute(m_aStates.top().aParagraphSprms, NS_ooxml::LN_CT_PPrBase_ind, NS_ooxml::LN_CT_Ind_left, pIntValue);
+ // It turns out \li should reset the \fi inherited from the stylesheet.
+ // So set the direct formatting to zero, if we don't have such direct formatting yet.
+ lcl_putNestedAttribute(m_aStates.top().aParagraphSprms, NS_ooxml::LN_CT_PPrBase_ind, NS_ooxml::LN_CT_Ind_firstLine, RTFValue::Pointer_t(new RTFValue(0)),
+ /*bOverwrite=*/false, /*bAttribute=*/true, /*bAppend=*/false);
+ }
+ break;
+ case RTF_RI:
+ lcl_putNestedAttribute(m_aStates.top().aParagraphSprms, NS_ooxml::LN_CT_PPrBase_ind, NS_ooxml::LN_CT_Ind_right, pIntValue);
+ break;
+ case RTF_LIN:
+ lcl_putNestedAttribute(m_aStates.top().aParagraphSprms, NS_ooxml::LN_CT_PPrBase_ind, NS_ooxml::LN_CT_Ind_start, pIntValue);
+ break;
+ case RTF_RIN:
+ lcl_putNestedAttribute(m_aStates.top().aParagraphSprms, NS_ooxml::LN_CT_PPrBase_ind, NS_ooxml::LN_CT_Ind_end, pIntValue);
+ break;
default:
{
SAL_INFO("writerfilter", "TODO handle value '" << lcl_RtfToString(nKeyword) << "'");
diff --git a/writerfilter/source/rtftok/rtfsprm.cxx b/writerfilter/source/rtftok/rtfsprm.cxx
index 5bea3dd..f27e10e 100644
--- a/writerfilter/source/rtftok/rtfsprm.cxx
+++ b/writerfilter/source/rtftok/rtfsprm.cxx
@@ -91,19 +91,29 @@ RTFValue::Pointer_t RTFSprms::find(Id nKeyword, bool bFirst)
return pValue;
}
-void RTFSprms::set(Id nKeyword, RTFValue::Pointer_t pValue, bool bOverwrite)
+void RTFSprms::set(Id nKeyword, RTFValue::Pointer_t pValue, bool bOverwrite, bool bAppend)
{
ensureCopyBeforeWrite();
- if (bOverwrite)
+ bool bFound = false;
+ if (bOverwrite || !bAppend)
{
for (RTFSprms::Iterator_t i = m_pSprms->begin(); i != m_pSprms->end(); ++i)
if (i->first == nKeyword)
{
- i->second = pValue;
- return;
+ if (bOverwrite)
+ {
+ i->second = pValue;
+ return;
+ }
+ else
+ {
+ bFound = true;
+ break;
+ }
}
}
- m_pSprms->push_back(std::make_pair(nKeyword, pValue));
+ if (bAppend || !bFound)
+ m_pSprms->push_back(std::make_pair(nKeyword, pValue));
}
bool RTFSprms::erase(Id nKeyword)
diff --git a/writerfilter/source/rtftok/rtfsprm.hxx b/writerfilter/source/rtftok/rtfsprm.hxx
index dc82256..c9ee0c6 100644
--- a/writerfilter/source/rtftok/rtfsprm.hxx
+++ b/writerfilter/source/rtftok/rtfsprm.hxx
@@ -49,8 +49,13 @@ namespace writerfilter {
~RTFSprms();
RTFSprms& operator=(const RTFSprms& rOther);
RTFValue::Pointer_t find(Id nKeyword, bool bFirst = true);
- /// Does the same as ->push_back(), except that it can overwrite existing entries.
- void set(Id nKeyword, RTFValue::Pointer_t pValue, bool bOverwrite = true);
+ /**
+ * Does the same as ->push_back(), except that it can overwrite existing entries.
+ *
+ * @param bOverwrite if existing element should be overwritten or appended.
+ * @param bAppend if not overwriting, then append or NOP.
+ */
+ void set(Id nKeyword, RTFValue::Pointer_t pValue, bool bOverwrite = true, bool bAppend = true);
bool erase(Id nKeyword);
/// Removes elements, which are already in the reference set.
void deduplicate(RTFSprms& rReference);
More information about the Libreoffice-commits
mailing list