diff options
author | Jacobo Aragunde Pérez <jaragunde@igalia.com> | 2013-11-29 09:58:18 +0100 |
---|---|---|
committer | Jacobo Aragunde Pérez <jaragunde@igalia.com> | 2013-12-04 18:52:02 +0100 |
commit | fb5ee5c9953635a423d3102b901e409d15800096 (patch) | |
tree | 74e80eca42174c3526d5ed03abd1a7e8b336a1ae /writerfilter/source/dmapper/PropertyMap.cxx | |
parent | 8a631e4718fbd7e6a393d93b006fc693df73a89b (diff) |
sw: Add support for different grab bags at PropertyMap.
Now there are two types of grab bags, for character and paragraph
attributes.
Change-Id: I41362358cd2765e5642499520d94f23f2380631d
Diffstat (limited to 'writerfilter/source/dmapper/PropertyMap.cxx')
-rw-r--r-- | writerfilter/source/dmapper/PropertyMap.cxx | 59 |
1 files changed, 40 insertions, 19 deletions
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx index 055916b0f73c..efbede50f76d 100644 --- a/writerfilter/source/dmapper/PropertyMap.cxx +++ b/writerfilter/source/dmapper/PropertyMap.cxx @@ -64,19 +64,28 @@ uno::Sequence< beans::PropertyValue > PropertyMap::GetPropertyValues() { if(!m_aValues.getLength() && size()) { - size_t nGrabBag = 0; + size_t nCharGrabBag = 0; + size_t nParaGrabBag = 0; for (PropertyMap::iterator i = begin(); i != end(); ++i) - if (i->second.hasGrabBag()) - nGrabBag++; + { + if ( i->second.getGrabBagType() == CHAR_GRAB_BAG ) + nCharGrabBag++; + else if ( i->second.getGrabBagType() == PARA_GRAB_BAG ) + nParaGrabBag++; + } // If there are any grab bag properties, we need one slot for them. - m_aValues.realloc( size() - nGrabBag + (nGrabBag ? 1 : 0)); + m_aValues.realloc( size() - nCharGrabBag + (nCharGrabBag ? 1 : 0) + - nParaGrabBag + (nParaGrabBag ? 1 : 0)); ::com::sun::star::beans::PropertyValue* pValues = m_aValues.getArray(); - uno::Sequence<beans::PropertyValue> aGrabBagValues(nGrabBag); - beans::PropertyValue* pGrabBagValues = aGrabBagValues.getArray(); + uno::Sequence<beans::PropertyValue> aCharGrabBagValues(nCharGrabBag); + uno::Sequence<beans::PropertyValue> aParaGrabBagValues(nParaGrabBag); + beans::PropertyValue* pCharGrabBagValues = aCharGrabBagValues.getArray(); + beans::PropertyValue* pParaGrabBagValues = aParaGrabBagValues.getArray(); //style names have to be the first elements within the property sequence //otherwise they will overwrite 'hard' attributes sal_Int32 nValue = 0; - sal_Int32 nGrabBagValue = 0; + sal_Int32 nParaGrabBagValue = 0; + sal_Int32 nCharGrabBagValue = 0; PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier(); PropertyMap::iterator aParaStyleIter = find(PROP_PARA_STYLE_NAME); if( aParaStyleIter != end()) @@ -105,24 +114,36 @@ uno::Sequence< beans::PropertyValue > PropertyMap::GetPropertyValues() { if( aMapIter != aParaStyleIter && aMapIter != aCharStyleIter && aMapIter != aNumRuleIter ) { - if (!aMapIter->second.hasGrabBag()) + if ( aMapIter->second.getGrabBagType() == CHAR_GRAB_BAG ) { - pValues[nValue].Name = rPropNameSupplier.GetName( aMapIter->first ); - pValues[nValue].Value = aMapIter->second.getValue(); - ++nValue; + pCharGrabBagValues[nCharGrabBagValue].Name = rPropNameSupplier.GetName( aMapIter->first ); + pCharGrabBagValues[nCharGrabBagValue].Value = aMapIter->second.getValue(); + ++nCharGrabBagValue; + } + else if ( aMapIter->second.getGrabBagType() == PARA_GRAB_BAG ) + { + pParaGrabBagValues[nParaGrabBagValue].Name = rPropNameSupplier.GetName( aMapIter->first ); + pParaGrabBagValues[nParaGrabBagValue].Value = aMapIter->second.getValue(); + ++nParaGrabBagValue; } else { - pGrabBagValues[nGrabBagValue].Name = rPropNameSupplier.GetName( aMapIter->first ); - pGrabBagValues[nGrabBagValue].Value = aMapIter->second.getValue(); - ++nGrabBagValue; + pValues[nValue].Name = rPropNameSupplier.GetName( aMapIter->first ); + pValues[nValue].Value = aMapIter->second.getValue(); + ++nValue; } } } - if (nGrabBag) + if (nCharGrabBag) + { + pValues[nValue].Name = "CharInteropGrabBag"; + pValues[nValue].Value = uno::makeAny(aCharGrabBagValues); + ++nValue; + } + if (nParaGrabBag) { pValues[nValue].Name = "ParaInteropGrabBag"; - pValues[nValue].Value = uno::makeAny(aGrabBagValues); + pValues[nValue].Value = uno::makeAny(aParaGrabBagValues); ++nValue; } } @@ -154,7 +175,7 @@ static void lcl_AnyToTag(const uno::Any & rAny) } #endif -void PropertyMap::Insert( PropertyIds eId, const uno::Any& rAny, bool bOverwrite, bool bGrabBag ) +void PropertyMap::Insert( PropertyIds eId, const uno::Any& rAny, bool bOverwrite, GrabBagType rGrabBagType ) { #ifdef DEBUG_DMAPPER_PROPERTY_MAP const OUString& rInsert = PropertyNameSupplier:: @@ -170,11 +191,11 @@ void PropertyMap::Insert( PropertyIds eId, const uno::Any& rAny, bool bOverwrite if (aElement != end()) { if (bOverwrite) - aElement->second = PropValue(rAny, bGrabBag); + aElement->second = PropValue(rAny, rGrabBagType); return; } - _PropertyMap::insert(_PropertyMap::value_type(eId, PropValue(rAny, bGrabBag))); + _PropertyMap::insert(_PropertyMap::value_type(eId, PropValue(rAny, rGrabBagType))); Invalidate(); } |