Kaydet (Commit) e1e50f7b authored tarafından Miklos Vajna's avatar Miklos Vajna

writerfilter: convert sprm:P{DxaRight,DxaLeft,DxaLeft1}

Change-Id: Iffb80e9844132aeeaf3e338c4817b44520e40f3a
üst bfdd18eb
......@@ -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:
......
......@@ -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>
......
......@@ -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) << "'");
......
......@@ -91,18 +91,28 @@ 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)
{
if (bOverwrite)
{
i->second = pValue;
return;
}
else
{
bFound = true;
break;
}
}
}
if (bAppend || !bFound)
m_pSprms->push_back(std::make_pair(nKeyword, pValue));
}
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment