summaryrefslogtreecommitdiffstats
path: root/writerfilter
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@suse.cz>2012-08-06 17:55:07 +0200
committerMiklos Vajna <vmiklos@suse.cz>2012-09-28 16:00:10 +0200
commitd93b9212023361bdf206a5479ec114067ccb1524 (patch)
tree9bfeaa0c05c7171ca9cab4e6abbd637ddc1dc3ae /writerfilter
parentn#772094: writerfilter, pictures anchored in header/footer won't be opaque (diff)
downloadcore-d93b9212023361bdf206a5479ec114067ccb1524.tar.gz
core-d93b9212023361bdf206a5479ec114067ccb1524.zip
support for deferred property processing in writerfilter
There currently does not seem to be any sane way to process an attribute or sprm that depends on another one that may not possibly be there yet (e.g. in e7ab4bb6b0e83f01148ffff41e8c5eaa0c5ba0a4, or w:position which for Svx internal reasons depends on fontsize and thus w:sz). So make it possible to defer such properties and process them only before they are actually used, instead of trying to get them out of PropertyMap, possibly in more places and possibly having to undo the changes that have been done to them already. Conflicts: writerfilter/source/dmapper/DomainMapper_Impl.hxx Change-Id: I1630057ecdf46443647ec1dd5253983ae15a083f
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/inc/dmapper/DomainMapper.hxx5
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx20
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx22
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.hxx14
4 files changed, 61 insertions, 0 deletions
diff --git a/writerfilter/inc/dmapper/DomainMapper.hxx b/writerfilter/inc/dmapper/DomainMapper.hxx
index fc0df7c1de54..7783499d4208 100644
--- a/writerfilter/inc/dmapper/DomainMapper.hxx
+++ b/writerfilter/inc/dmapper/DomainMapper.hxx
@@ -118,6 +118,11 @@ public:
GraphicZOrderHelper* graphicZOrderHelper();
bool IsInHeaderFooter() const;
+ /**
+ @see DomainMapper_Impl::processDeferredCharacterProperties()
+ */
+ void processDeferredCharacterProperties(
+ const std::map< sal_Int32, com::sun::star::uno::Any >& deferredCharacterProperties );
private:
// Stream
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 227b0705e8f9..fb26979e341e 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3346,6 +3346,26 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType
}
+void DomainMapper::processDeferredCharacterProperties( const std::map< sal_Int32, uno::Any >& deferredCharacterProperties )
+{
+ for( std::map< sal_Int32, uno::Any >::const_iterator it = deferredCharacterProperties.begin();
+ it != deferredCharacterProperties.end();
+ ++it )
+ {
+ sal_Int32 Id = it->first;
+ sal_Int32 nIntValue = 0;
+ OUString sStringValue;
+ it->second >>= nIntValue;
+ it->second >>= sStringValue;
+ switch( Id )
+ {
+ default:
+ SAL_WARN( "writerfilter", "Unhandled property in processDeferredCharacterProperty()" );
+ break;
+ }
+ }
+}
+
void DomainMapper::lcl_entry(int /*pos*/,
writerfilter::Reference<Properties>::Pointer_t ref)
{
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 7d2a5e004ad5..7930c3b2be75 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -406,7 +406,12 @@ void DomainMapper_Impl::PopProperties(ContextType eId)
m_pLastSectionContext = m_aPropertyStacks[eId].top( );
}
else if (eId == CONTEXT_CHARACTER)
+ {
m_pLastCharacterContext = m_aPropertyStacks[eId].top();
+ // Sadly an assert about deferredCharacterProperties being empty is not possible
+ // here, becase appendTextPortion() may not be called for every character section.
+ deferredCharacterProperties.clear();
+ }
m_aPropertyStacks[eId].pop();
m_aContextStack.pop();
@@ -1127,6 +1132,8 @@ void DomainMapper_Impl::appendTextPortion( const ::rtl::OUString& rString, Prope
{
if (m_aTextAppendStack.empty())
return;
+ if( pPropertyMap == m_pTopContext && !deferredCharacterProperties.empty())
+ processDeferredCharacterProperties();
uno::Reference< text::XTextAppend > xTextAppend = m_aTextAppendStack.top().xTextAppend;
if(xTextAppend.is() && ! getTableManager( ).isIgnore())
{
@@ -3722,6 +3729,21 @@ SectionPropertyMap * DomainMapper_Impl::GetSectionContext()
return pSectionContext;
}
+void DomainMapper_Impl::deferCharacterProperty( sal_Int32 id, com::sun::star::uno::Any value )
+{
+ deferredCharacterProperties[ id ] = value;
+}
+
+void DomainMapper_Impl::processDeferredCharacterProperties()
+{
+ // ACtually process in DomainMapper, so that it's the same source file like normal processing.
+ if( !deferredCharacterProperties.empty())
+ {
+ m_rDMapper.processDeferredCharacterProperties( deferredCharacterProperties );
+ deferredCharacterProperties.clear();
+ }
+}
+
}}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index 1b8257f77e44..8fe88da7b3cc 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -372,6 +372,8 @@ private:
throw(::com::sun::star::uno::Exception);
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > GetDocumentSettings();
+ std::map< sal_Int32, com::sun::star::uno::Any > deferredCharacterProperties;
+
public:
DomainMapper_Impl(
DomainMapper& rDMapper,
@@ -635,6 +637,18 @@ public:
com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> GetCurrentNumberingCharStyle();
/// If the current paragraph has a numbering style associated, this method returns its numbering rules
com::sun::star::uno::Reference<com::sun::star::container::XIndexAccess> GetCurrentNumberingRules(sal_Int32* pListLevel = 0);
+
+ /**
+ Used for attributes/sprms which cannot be evaluated immediatelly (e.g. they depend
+ on another one that comes in the same CONTEXT_CHARACTER). The property will be processed
+ again in DomainMapper::processDeferredCharacterProperties().
+ */
+ void deferCharacterProperty( sal_Int32 id, com::sun::star::uno::Any value );
+ /**
+ Processes properties deferred using deferCharacterProperty(). To be called whenever the top
+ CONTEXT_CHARACTER is going to be used (e.g. by appendText()).
+ */
+ void processDeferredCharacterProperties();
};
} //namespace dmapper
} //namespace writerfilter