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 | |
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
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper.cxx | 6 | ||||
-rw-r--r-- | writerfilter/source/dmapper/PropertyMap.cxx | 59 | ||||
-rw-r--r-- | writerfilter/source/dmapper/PropertyMap.hxx | 22 |
3 files changed, 58 insertions, 29 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index da510fdac558..c63429b594bd 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -1197,7 +1197,7 @@ void DomainMapper::lcl_attribute(Id nName, Value & val) m_pImpl->GetTopContext()->Insert( PROP_PARA_TOP_MARGIN, uno::makeAny( ConversionHelper::convertTwipToMM100(default_spacing) ) ); if (nIntValue) // If auto spacing is set, then only store set value in InteropGrabBag { - m_pImpl->GetTopContext()->Insert( PROP_PARA_TOP_MARGIN_BEFORE_AUTO_SPACING, uno::makeAny( ConversionHelper::convertTwipToMM100(default_spacing) ),true,true ); + m_pImpl->GetTopContext()->Insert( PROP_PARA_TOP_MARGIN_BEFORE_AUTO_SPACING, uno::makeAny( ConversionHelper::convertTwipToMM100(default_spacing) ),true, PARA_GRAB_BAG ); } } break; @@ -1212,7 +1212,7 @@ void DomainMapper::lcl_attribute(Id nName, Value & val) m_pImpl->GetTopContext()->Insert( PROP_PARA_BOTTOM_MARGIN, uno::makeAny( ConversionHelper::convertTwipToMM100(default_spacing) ) ); if (nIntValue) // If auto spacing is set, then only store set value in InteropGrabBag { - m_pImpl->GetTopContext()->Insert( PROP_PARA_BOTTOM_MARGIN_AFTER_AUTO_SPACING, uno::makeAny( ConversionHelper::convertTwipToMM100(default_spacing) ),true,true ); + m_pImpl->GetTopContext()->Insert( PROP_PARA_BOTTOM_MARGIN_AFTER_AUTO_SPACING, uno::makeAny( ConversionHelper::convertTwipToMM100(default_spacing) ),true, PARA_GRAB_BAG ); } } break; @@ -3475,7 +3475,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType rContext->Insert(PROP_PARA_CONTEXT_MARGIN, uno::makeAny( sal_Bool( nIntValue ) )); break; case 0x2470: // mirrorIndents - rContext->Insert(PROP_MIRROR_INDENTS, uno::makeAny(sal_Bool(nIntValue)), true, true); + rContext->Insert(PROP_MIRROR_INDENTS, uno::makeAny(sal_Bool(nIntValue)), true, PARA_GRAB_BAG); break; case NS_ooxml::LN_EG_SectPrContents_formProt: //section protection, only form editing is enabled - unsupported case NS_ooxml::LN_EG_SectPrContents_vAlign: 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(); } diff --git a/writerfilter/source/dmapper/PropertyMap.hxx b/writerfilter/source/dmapper/PropertyMap.hxx index 456a48098a10..968d7f157b5c 100644 --- a/writerfilter/source/dmapper/PropertyMap.hxx +++ b/writerfilter/source/dmapper/PropertyMap.hxx @@ -64,21 +64,29 @@ enum BorderPosition BORDER_BOTTOM }; +enum GrabBagType +{ + NO_GRAB_BAG, + PARA_GRAB_BAG, + CHAR_GRAB_BAG +}; + class PropValue { uno::Any m_aValue; - bool m_bGrabBag; + GrabBagType m_rGrabBagType; public: - PropValue(const uno::Any& rValue, bool bGrabBag = false) : - m_aValue(rValue), m_bGrabBag(bGrabBag) {} + PropValue(const uno::Any& rValue, GrabBagType rGrabBagType = NO_GRAB_BAG) : + m_aValue(rValue), m_rGrabBagType(rGrabBagType) {} - PropValue() : m_aValue(), m_bGrabBag() {} + PropValue() : m_aValue(), m_rGrabBagType(NO_GRAB_BAG) {} - PropValue& operator=(const PropValue& rProp) { m_aValue = rProp.m_aValue; m_bGrabBag = rProp.m_bGrabBag; return *this; } + PropValue& operator=(const PropValue& rProp) { m_aValue = rProp.m_aValue; m_rGrabBagType = rProp.m_rGrabBagType; return *this; } const uno::Any& getValue() const { return m_aValue; } - bool hasGrabBag() const { return m_bGrabBag; } + bool hasGrabBag() const { return m_rGrabBagType != NO_GRAB_BAG; } + GrabBagType getGrabBagType() const { return m_rGrabBagType; } }; typedef std::map< PropertyIds, PropValue > _PropertyMap; @@ -108,7 +116,7 @@ public: bool hasEmptyPropertyValues() const {return !m_aValues.getLength();} /** Add property, usually overwrites already available attributes. It shouldn't overwrite in case of default attributes */ - void Insert( PropertyIds eId, const ::com::sun::star::uno::Any& rAny, bool bOverwrite = true, bool bGrabBag = false ); + void Insert( PropertyIds eId, const ::com::sun::star::uno::Any& rAny, bool bOverwrite = true, GrabBagType rGrabBagType = NO_GRAB_BAG ); void Insert( PropertyIds eId, const PropValue& rValue, bool bOverwrite = true ); void InsertProps(const boost::shared_ptr<PropertyMap> pMap); const ::com::sun::star::uno::Reference< ::com::sun::star::text::XFootnote>& GetFootnote() const; |