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

DOCX import: handle <w:cnfStyle> cell property

Change-Id: I849daf0ddee370775fda73e04739e69acbc64246
üst 5e2081fb
...@@ -3290,6 +3290,9 @@ void DocxAttributeOutput::TableBackgrounds( ww8::WW8TableNodeInfoInner::Pointer_ ...@@ -3290,6 +3290,9 @@ void DocxAttributeOutput::TableBackgrounds( ww8::WW8TableNodeInfoInner::Pointer_
for( aGrabBagElement = aGrabBag.begin(); aGrabBagElement != aGrabBag.end(); ++aGrabBagElement ) for( aGrabBagElement = aGrabBag.begin(); aGrabBagElement != aGrabBag.end(); ++aGrabBagElement )
{ {
if (!aGrabBagElement->second.has<OUString>())
continue;
OString sValue = OUStringToOString( aGrabBagElement->second.get<OUString>(), RTL_TEXTENCODING_UTF8 ); OString sValue = OUStringToOString( aGrabBagElement->second.get<OUString>(), RTL_TEXTENCODING_UTF8 );
if( aGrabBagElement->first == "themeFill") if( aGrabBagElement->first == "themeFill")
AddToAttrList( aAttrList, FSNS( XML_w, XML_themeFill ), sValue.getStr() ); AddToAttrList( aAttrList, FSNS( XML_w, XML_themeFill ), sValue.getStr() );
......
...@@ -2504,6 +2504,18 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext ) ...@@ -2504,6 +2504,18 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext )
} }
} }
break; break;
case NS_ooxml::LN_CT_TcPrBase_cnfStyle:
{
m_pImpl->enableInteropGrabBag("cnfStyle");
resourcemodel::resolveSprmProps(*this, rSprm);
TablePropertyMapPtr pPropMap(new TablePropertyMap());
pPropMap->Insert(PROP_CELL_CNF_STYLE, uno::makeAny(uno::makeAny(m_pImpl->m_aInteropGrabBag.getAsConstList())), true, CELL_GRAB_BAG);
m_pImpl->getTableManager().cellProps(pPropMap);
m_pImpl->disableInteropGrabBag();
}
break;
case NS_ooxml::LN_CT_PPrBase_cnfStyle: case NS_ooxml::LN_CT_PPrBase_cnfStyle:
{ {
m_pImpl->enableInteropGrabBag("cnfStyle"); m_pImpl->enableInteropGrabBag("cnfStyle");
......
...@@ -397,6 +397,7 @@ OUString PropertyNameSupplier::GetName( PropertyIds eId ) const ...@@ -397,6 +397,7 @@ OUString PropertyNameSupplier::GetName( PropertyIds eId ) const
case PROP_PARA_SDT_END_BEFORE: sName = "ParaSdtEndBefore"; break; case PROP_PARA_SDT_END_BEFORE: sName = "ParaSdtEndBefore"; break;
case META_PROP_TABLE_LOOK: sName = "TableStyleLook"; break; case META_PROP_TABLE_LOOK: sName = "TableStyleLook"; break;
case PROP_PARA_CNF_STYLE: sName = "ParaCnfStyle"; break; case PROP_PARA_CNF_STYLE: sName = "ParaCnfStyle"; break;
case PROP_CELL_CNF_STYLE: sName = "CellCnfStyle"; break;
} }
::std::pair<PropertyNameMap_t::iterator,bool> aInsertIt = ::std::pair<PropertyNameMap_t::iterator,bool> aInsertIt =
m_pImpl->aNameMap.insert( PropertyNameMap_t::value_type( eId, sName )); m_pImpl->aNameMap.insert( PropertyNameMap_t::value_type( eId, sName ));
......
...@@ -369,6 +369,7 @@ enum PropertyIds ...@@ -369,6 +369,7 @@ enum PropertyIds
,PROP_PARA_SDT_END_BEFORE ,PROP_PARA_SDT_END_BEFORE
,META_PROP_TABLE_LOOK ,META_PROP_TABLE_LOOK
,PROP_PARA_CNF_STYLE ,PROP_PARA_CNF_STYLE
,PROP_CELL_CNF_STYLE
}; };
struct PropertyNameSupplier_Impl; struct PropertyNameSupplier_Impl;
class PropertyNameSupplier class PropertyNameSupplier
......
...@@ -66,30 +66,50 @@ uno::Sequence< beans::PropertyValue > PropertyMap::GetPropertyValues(bool bCharG ...@@ -66,30 +66,50 @@ uno::Sequence< beans::PropertyValue > PropertyMap::GetPropertyValues(bool bCharG
{ {
size_t nCharGrabBag = 0; size_t nCharGrabBag = 0;
size_t nParaGrabBag = 0; size_t nParaGrabBag = 0;
size_t nCellGrabBag = 0;
size_t nCellGrabBagSaved = 0; // How many entries do we save from the returned sequence.
for (MapIterator i = m_vMap.begin(); i != m_vMap.end(); ++i) for (MapIterator i = m_vMap.begin(); i != m_vMap.end(); ++i)
{ {
if ( i->second.getGrabBagType() == CHAR_GRAB_BAG ) if ( i->second.getGrabBagType() == CHAR_GRAB_BAG )
nCharGrabBag++; nCharGrabBag++;
else if ( i->second.getGrabBagType() == PARA_GRAB_BAG ) else if ( i->second.getGrabBagType() == PARA_GRAB_BAG )
nParaGrabBag++; nParaGrabBag++;
else if ( i->second.getGrabBagType() == CELL_GRAB_BAG )
{
nCellGrabBag++;
nCellGrabBagSaved++;
}
else if ( i->first == PROP_CELL_INTEROP_GRAB_BAG)
{
uno::Sequence<beans::PropertyValue> aSeq;
i->second.getValue() >>= aSeq;
nCellGrabBag += aSeq.getLength();
nCellGrabBagSaved++;
}
} }
// In case there are properties to be grab-bagged and we can have a char grab-bag, allocate one slot for it. // In case there are properties to be grab-bagged and we can have a char grab-bag, allocate one slot for it.
size_t nCharGrabBagSize = 0; size_t nCharGrabBagSize = 0;
if (bCharGrabBag) if (bCharGrabBag)
nCharGrabBagSize = nCharGrabBag ? 1 : 0; nCharGrabBagSize = nCharGrabBag ? 1 : 0;
size_t nParaGrabBagSize = nParaGrabBag ? 1 : 0;
size_t nCellGrabBagSize = nCellGrabBag ? 1 : 0;
// If there are any grab bag properties, we need one slot for them. // If there are any grab bag properties, we need one slot for them.
m_aValues.realloc( m_vMap.size() - nCharGrabBag + nCharGrabBagSize m_aValues.realloc( m_vMap.size() - nCharGrabBag + nCharGrabBagSize
- nParaGrabBag + (nParaGrabBag ? 1 : 0)); - nParaGrabBag + nParaGrabBagSize
- nCellGrabBagSaved + nCellGrabBagSize);
::com::sun::star::beans::PropertyValue* pValues = m_aValues.getArray(); ::com::sun::star::beans::PropertyValue* pValues = m_aValues.getArray();
uno::Sequence<beans::PropertyValue> aCharGrabBagValues(nCharGrabBag); uno::Sequence<beans::PropertyValue> aCharGrabBagValues(nCharGrabBag);
uno::Sequence<beans::PropertyValue> aParaGrabBagValues(nParaGrabBag); uno::Sequence<beans::PropertyValue> aParaGrabBagValues(nParaGrabBag);
uno::Sequence<beans::PropertyValue> aCellGrabBagValues(nCellGrabBag);
beans::PropertyValue* pCharGrabBagValues = aCharGrabBagValues.getArray(); beans::PropertyValue* pCharGrabBagValues = aCharGrabBagValues.getArray();
beans::PropertyValue* pParaGrabBagValues = aParaGrabBagValues.getArray(); beans::PropertyValue* pParaGrabBagValues = aParaGrabBagValues.getArray();
beans::PropertyValue* pCellGrabBagValues = aCellGrabBagValues.getArray();
//style names have to be the first elements within the property sequence //style names have to be the first elements within the property sequence
//otherwise they will overwrite 'hard' attributes //otherwise they will overwrite 'hard' attributes
sal_Int32 nValue = 0; sal_Int32 nValue = 0;
sal_Int32 nCellGrabBagValue = 0;
sal_Int32 nParaGrabBagValue = 0; sal_Int32 nParaGrabBagValue = 0;
sal_Int32 nCharGrabBagValue = 0; sal_Int32 nCharGrabBagValue = 0;
PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier(); PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
...@@ -135,6 +155,24 @@ uno::Sequence< beans::PropertyValue > PropertyMap::GetPropertyValues(bool bCharG ...@@ -135,6 +155,24 @@ uno::Sequence< beans::PropertyValue > PropertyMap::GetPropertyValues(bool bCharG
pParaGrabBagValues[nParaGrabBagValue].Value = aMapIter->second.getValue(); pParaGrabBagValues[nParaGrabBagValue].Value = aMapIter->second.getValue();
++nParaGrabBagValue; ++nParaGrabBagValue;
} }
else if ( aMapIter->second.getGrabBagType() == CELL_GRAB_BAG )
{
pCellGrabBagValues[nCellGrabBagValue].Name = rPropNameSupplier.GetName( aMapIter->first );
pCellGrabBagValues[nCellGrabBagValue].Value = aMapIter->second.getValue();
++nCellGrabBagValue;
}
else
{
if (aMapIter->first == PROP_CELL_INTEROP_GRAB_BAG)
{
uno::Sequence<beans::PropertyValue> aSeq;
aMapIter->second.getValue() >>= aSeq;
for (sal_Int32 i = 0; i < aSeq.getLength(); ++i)
{
pCellGrabBagValues[nCellGrabBagValue] = aSeq[i];
++nCellGrabBagValue;
}
}
else else
{ {
pValues[nValue].Name = rPropNameSupplier.GetName( aMapIter->first ); pValues[nValue].Name = rPropNameSupplier.GetName( aMapIter->first );
...@@ -143,6 +181,7 @@ uno::Sequence< beans::PropertyValue > PropertyMap::GetPropertyValues(bool bCharG ...@@ -143,6 +181,7 @@ uno::Sequence< beans::PropertyValue > PropertyMap::GetPropertyValues(bool bCharG
} }
} }
} }
}
if (nCharGrabBag && bCharGrabBag) if (nCharGrabBag && bCharGrabBag)
{ {
pValues[nValue].Name = "CharInteropGrabBag"; pValues[nValue].Name = "CharInteropGrabBag";
...@@ -155,6 +194,12 @@ uno::Sequence< beans::PropertyValue > PropertyMap::GetPropertyValues(bool bCharG ...@@ -155,6 +194,12 @@ uno::Sequence< beans::PropertyValue > PropertyMap::GetPropertyValues(bool bCharG
pValues[nValue].Value = uno::makeAny(aParaGrabBagValues); pValues[nValue].Value = uno::makeAny(aParaGrabBagValues);
++nValue; ++nValue;
} }
if (nCellGrabBag)
{
pValues[nValue].Name = "CellInteropGrabBag";
pValues[nValue].Value = uno::makeAny(aCellGrabBagValues);
++nValue;
}
} }
return m_aValues; return m_aValues;
} }
......
...@@ -68,6 +68,7 @@ enum BorderPosition ...@@ -68,6 +68,7 @@ enum BorderPosition
enum GrabBagType enum GrabBagType
{ {
NO_GRAB_BAG, NO_GRAB_BAG,
CELL_GRAB_BAG,
PARA_GRAB_BAG, PARA_GRAB_BAG,
CHAR_GRAB_BAG CHAR_GRAB_BAG
}; };
......
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