diff options
author | Luboš Luňák <l.lunak@suse.cz> | 2013-07-10 17:33:15 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@suse.cz> | 2013-07-10 17:35:27 +0200 |
commit | a1190c9d2e85c4ccb9db106fe9eb4a48219ac126 (patch) | |
tree | 6302a1c48d81d1f8823bba99c5450265076f81b8 /xmloff | |
parent | 0cf9b9ab4bec65055e88517e937d18f751818ff6 (diff) |
fix reading fonts from .odp using style::font-name (fdo#65338)
b40bcde076f9fabf24810d2520e878d604d99637 made writing .odp use style:font-name
and office:font-face-decls, instead of using fo:font-family . But the reading
back was broken, as xFontDecls is not set
in XMLTextImportPropertyMapper::handleSpecialItem(), so the font data was
ignored. And xFontDecls was not set because it's set while reading
office:font-face-decls, which is at the top of the xml document, but even
before the xml is parsed, the call to SdXMLImport::setTargetDocument() calls
GetShapeImport(), which creates XMLShapeImportHelper instance, which calls
XMLTextImportHelper::CreateParaExtPropMapper(), and XMLTextImportPropertyMapper
is created with rImport.GetFontDecls() still being NULL at that point.
And it actually doesn't seem to make any sense to just pass around all
the pointers to XMLFontStylesContext, as eventually it's always just the one
from SvXMLImport. So simply dump all that and make the one single place
that actually uses it (i.e. XMLTextImportPropertyMapper::handleSpecialItem())
refer directly to SvXMLImport::GetFontDecls().
Change-Id: Ib1b3e4b1bcaf87ca3e4703d1cc1563ad6b3f9ce7
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/core/xmlimp.cxx | 1 | ||||
-rw-r--r-- | xmloff/source/style/xmlnumi.cxx | 2 | ||||
-rw-r--r-- | xmloff/source/text/txtimp.cxx | 38 | ||||
-rw-r--r-- | xmloff/source/text/txtimppr.cxx | 16 |
4 files changed, 13 insertions, 44 deletions
diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx index 2e4eb46a33c4..121b4d458ef1 100644 --- a/xmloff/source/core/xmlimp.cxx +++ b/xmloff/source/core/xmlimp.cxx @@ -1490,7 +1490,6 @@ XMLEventImportHelper& SvXMLImport::GetEventImport() void SvXMLImport::SetFontDecls( XMLFontStylesContext *pFontDecls ) { mxFontDecls = pFontDecls; - GetTextImport()->SetFontDecls( pFontDecls ); } void SvXMLImport::SetStyles( SvXMLStylesContext *pStyles ) diff --git a/xmloff/source/style/xmlnumi.cxx b/xmloff/source/style/xmlnumi.cxx index 28553ba5ca06..b4ac805eda1e 100644 --- a/xmloff/source/style/xmlnumi.cxx +++ b/xmloff/source/style/xmlnumi.cxx @@ -784,7 +784,7 @@ SvxXMLListLevelStyleAttrContext_Impl::SvxXMLListLevelStyleAttrContext_Impl( if( !sFontName.isEmpty() ) { const XMLFontStylesContext *pFontDecls = - GetImport().GetTextImport()->GetFontDecls(); + GetImport().GetFontDecls(); if( pFontDecls ) { ::std::vector < XMLPropertyState > aProps; diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx index f35a46defd9a..eb74f00fd47f 100644 --- a/xmloff/source/text/txtimp.cxx +++ b/xmloff/source/text/txtimp.cxx @@ -1029,39 +1029,32 @@ SvXMLImportPropertyMapper *XMLTextImportHelper::CreateShapeExtPropMapper(SvXMLIm { XMLPropertySetMapper *pPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_FRAME ); - return new XMLTextImportPropertyMapper( pPropMapper, rImport, - const_cast<XMLFontStylesContext*>(rImport.GetFontDecls()) ); + return new XMLTextImportPropertyMapper( pPropMapper, rImport ); } -SvXMLImportPropertyMapper *XMLTextImportHelper::CreateParaExtPropMapper(SvXMLImport& rImport, XMLFontStylesContext *pFontDecls) +SvXMLImportPropertyMapper *XMLTextImportHelper::CreateParaExtPropMapper(SvXMLImport& rImport) { XMLPropertySetMapper *pPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_SHAPE_PARA ); - if (!pFontDecls) - pFontDecls = const_cast<XMLFontStylesContext*>(rImport.GetFontDecls()); - return new XMLTextImportPropertyMapper( pPropMapper, rImport, pFontDecls ); + return new XMLTextImportPropertyMapper( pPropMapper, rImport ); } -SvXMLImportPropertyMapper *XMLTextImportHelper::CreateParaDefaultExtPropMapper(SvXMLImport& rImport, XMLFontStylesContext* pFontDecls) +SvXMLImportPropertyMapper *XMLTextImportHelper::CreateParaDefaultExtPropMapper(SvXMLImport& rImport) { - if (!pFontDecls) - pFontDecls = const_cast<XMLFontStylesContext*>(rImport.GetFontDecls()); - XMLPropertySetMapper* pPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_SHAPE_PARA ); - SvXMLImportPropertyMapper* pImportMapper = new XMLTextImportPropertyMapper( pPropMapper, rImport, pFontDecls ); + SvXMLImportPropertyMapper* pImportMapper = new XMLTextImportPropertyMapper( pPropMapper, rImport ); pPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_TEXT_ADDITIONAL_DEFAULTS ); - pImportMapper->ChainImportMapper( new XMLTextImportPropertyMapper( pPropMapper, rImport, pFontDecls ) ); + pImportMapper->ChainImportMapper( new XMLTextImportPropertyMapper( pPropMapper, rImport ) ); return pImportMapper; } SvXMLImportPropertyMapper* XMLTextImportHelper::CreateTableDefaultExtPropMapper( - SvXMLImport& rImport, - XMLFontStylesContext* ) + SvXMLImport& rImport ) { XMLPropertySetMapper *pPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_TABLE_DEFAULTS ); @@ -1070,8 +1063,7 @@ SvXMLImportPropertyMapper* SvXMLImportPropertyMapper* XMLTextImportHelper::CreateTableRowDefaultExtPropMapper( - SvXMLImport& rImport, - XMLFontStylesContext* ) + SvXMLImport& rImport ) { XMLPropertySetMapper *pPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_TABLE_ROW_DEFAULTS ); @@ -2155,20 +2147,6 @@ void XMLTextImportHelper::SetAutoStyles( SvXMLStylesContext *pStyles ) m_pImpl->m_xAutoStyles = pStyles; } -void XMLTextImportHelper::SetFontDecls( XMLFontStylesContext *pFontDecls ) -{ - m_pImpl->m_xFontDecls = pFontDecls; - ((XMLTextImportPropertyMapper *)m_pImpl->m_xParaImpPrMap.get()) - ->SetFontDecls( pFontDecls ); - ((XMLTextImportPropertyMapper *)m_pImpl->m_xTextImpPrMap.get()) - ->SetFontDecls( pFontDecls ); -} - -const XMLFontStylesContext *XMLTextImportHelper::GetFontDecls() const -{ - return (XMLFontStylesContext *)&m_pImpl->m_xFontDecls; -} - SvXMLImportContext *XMLTextImportHelper::CreateTextChildContext( SvXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName, diff --git a/xmloff/source/text/txtimppr.cxx b/xmloff/source/text/txtimppr.cxx index 306ebb19f8db..40f5dc21bc3e 100644 --- a/xmloff/source/text/txtimppr.cxx +++ b/xmloff/source/text/txtimppr.cxx @@ -54,7 +54,7 @@ bool XMLTextImportPropertyMapper::handleSpecialItem( case CTF_FONTNAME: case CTF_FONTNAME_CJK: case CTF_FONTNAME_CTL: - if( xFontDecls.Is() ) + if( GetImport().GetFontDecls() != NULL ) { DBG_ASSERT( ( CTF_FONTFAMILYNAME == @@ -89,7 +89,7 @@ bool XMLTextImportPropertyMapper::handleSpecialItem( getPropertySetMapper()->GetEntryContextId(nIndex+5) ), "illegal property map" ); - ((XMLFontStylesContext *)&xFontDecls)->FillProperties( + GetImport().GetFontDecls()->FillProperties( rValue, rProperties, rProperty.mnIndex+1, rProperty.mnIndex+2, rProperty.mnIndex+3, rProperty.mnIndex+4, @@ -132,12 +132,10 @@ bool XMLTextImportPropertyMapper::handleSpecialItem( XMLTextImportPropertyMapper::XMLTextImportPropertyMapper( const UniReference< XMLPropertySetMapper >& rMapper, - SvXMLImport& rImp, - XMLFontStylesContext *pFontDecls ) : + SvXMLImport& rImp ) : SvXMLImportPropertyMapper( rMapper, rImp ), nSizeTypeIndex( -2 ), - nWidthTypeIndex( -2 ), - xFontDecls( pFontDecls ) + nWidthTypeIndex( -2 ) { } @@ -145,12 +143,6 @@ XMLTextImportPropertyMapper::~XMLTextImportPropertyMapper() { } -void XMLTextImportPropertyMapper::SetFontDecls( - XMLFontStylesContext *pFontDecls ) -{ - xFontDecls = pFontDecls; -} - void XMLTextImportPropertyMapper::FontFinished( XMLPropertyState *pFontFamilyNameState, XMLPropertyState *pFontStyleNameState, |