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* ...@@ -973,7 +973,7 @@ static bool ExchangeLeftRight( const PropertyMapPtr rContext, DomainMapper_Impl*
return bExchangeLeftRight; 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!"); OSL_ENSURE(rContext.get(), "PropertyMap has to be valid!");
if(!rContext.get()) if(!rContext.get())
...@@ -1065,30 +1065,6 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType ...@@ -1065,30 +1065,6 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType
case NS_ooxml::LN_CT_PPrBase_suppressLineNumbers: case NS_ooxml::LN_CT_PPrBase_suppressLineNumbers:
rContext->Insert(PROP_PARA_LINE_NUMBER_COUNT, uno::makeAny( nIntValue ? false : true) ); rContext->Insert(PROP_PARA_LINE_NUMBER_COUNT, uno::makeAny( nIntValue ? false : true) );
break; 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: case NS_ooxml::LN_inTbl:
break; break;
case NS_ooxml::LN_tblDepth: case NS_ooxml::LN_tblDepth:
......
...@@ -7,68 +7,6 @@ ...@@ -7,68 +7,6 @@
<UML:Model name="WW8Document"> <UML:Model name="WW8Document">
<UML:Namespace.ownedElement> <UML:Namespace.ownedElement>
<!--SPRMS--> <!--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--> <!--SPRM sprmPFWidowControl-->
<UML:Class xmi.id="sprmPFWidowControl" name="sprmPFWidowControl"> <UML:Class xmi.id="sprmPFWidowControl" name="sprmPFWidowControl">
<UML:ModelElement.stereotype> <UML:ModelElement.stereotype>
...@@ -317,21 +255,6 @@ ...@@ -317,21 +255,6 @@
</UML:ModelElement.taggedValue> </UML:ModelElement.taggedValue>
</UML:Class> </UML:Class>
<!--SPRM sprmTTextFlow--> <!--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--> <!--SPRMS-->
</UML:Namespace.ownedElement> </UML:Namespace.ownedElement>
</UML:Model> </UML:Model>
......
...@@ -81,7 +81,7 @@ static Id lcl_getParagraphBorder(sal_uInt32 nIndex) ...@@ -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, 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); RTFValue::Pointer_t pParent = rSprms.find(nParent);
if (!pParent.get()) if (!pParent.get())
...@@ -94,11 +94,11 @@ static void lcl_putNestedAttribute(RTFSprms& rSprms, Id nParent, Id nId, RTFValu ...@@ -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))); aAttributes.set(NS_ooxml::LN_CT_Shd_fill, RTFValue::Pointer_t(new RTFValue(0x0a)));
} }
RTFValue::Pointer_t pParentValue(new RTFValue(aAttributes)); RTFValue::Pointer_t pParentValue(new RTFValue(aAttributes));
rSprms.set(nParent, pParentValue, bOverwrite); rSprms.set(nParent, pParentValue, bOverwrite, bAppend);
pParent = pParentValue; pParent = pParentValue;
} }
RTFSprms& rAttributes = (bAttribute ? pParent->getAttributes() : pParent->getSprms()); 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) 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) ...@@ -3016,10 +3016,6 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
// Trivial paragraph sprms. // Trivial paragraph sprms.
switch (nKeyword) 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_ITAP: nSprm = NS_ooxml::LN_tblDepth; break;
case RTF_SBASEDON: case RTF_SBASEDON:
nSprm = NS_ooxml::LN_CT_Style_basedOn; nSprm = NS_ooxml::LN_CT_Style_basedOn;
...@@ -3845,15 +3841,6 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) ...@@ -3845,15 +3841,6 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
case RTF_DPFILLBGCB: case RTF_DPFILLBGCB:
m_aStates.top().aDrawingObject.nFillColorB = nParam; m_aStates.top().aDrawingObject.bHasFillColor = true; m_aStates.top().aDrawingObject.nFillColorB = nParam; m_aStates.top().aDrawingObject.bHasFillColor = true;
break; 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: case RTF_CLSHDNG:
{ {
int nValue = -1; int nValue = -1;
...@@ -3961,6 +3948,27 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) ...@@ -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))); lcl_putNestedSprm(m_aStates.top().aTableCellSprms, NS_ooxml::LN_CT_TcPrBase_tcMar, nSprm, RTFValue::Pointer_t(new RTFValue(aAttributes)));
} }
break; 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: default:
{ {
SAL_INFO("writerfilter", "TODO handle value '" << lcl_RtfToString(nKeyword) << "'"); SAL_INFO("writerfilter", "TODO handle value '" << lcl_RtfToString(nKeyword) << "'");
......
...@@ -91,19 +91,29 @@ RTFValue::Pointer_t RTFSprms::find(Id nKeyword, bool bFirst) ...@@ -91,19 +91,29 @@ RTFValue::Pointer_t RTFSprms::find(Id nKeyword, bool bFirst)
return pValue; 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(); ensureCopyBeforeWrite();
if (bOverwrite) bool bFound = false;
if (bOverwrite || !bAppend)
{ {
for (RTFSprms::Iterator_t i = m_pSprms->begin(); i != m_pSprms->end(); ++i) for (RTFSprms::Iterator_t i = m_pSprms->begin(); i != m_pSprms->end(); ++i)
if (i->first == nKeyword) if (i->first == nKeyword)
{ {
i->second = pValue; if (bOverwrite)
return; {
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) bool RTFSprms::erase(Id nKeyword)
......
...@@ -49,8 +49,13 @@ namespace writerfilter { ...@@ -49,8 +49,13 @@ namespace writerfilter {
~RTFSprms(); ~RTFSprms();
RTFSprms& operator=(const RTFSprms& rOther); RTFSprms& operator=(const RTFSprms& rOther);
RTFValue::Pointer_t find(Id nKeyword, bool bFirst = true); 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); bool erase(Id nKeyword);
/// Removes elements, which are already in the reference set. /// Removes elements, which are already in the reference set.
void deduplicate(RTFSprms& rReference); 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