diff options
author | Luboš Luňák <l.lunak@suse.cz> | 2013-07-10 17:33:15 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2013-07-10 19:33:24 +0000 |
commit | cc3293b94ab58b196bc2786eb4012d64351e8fa4 (patch) | |
tree | 2bae24b69ead7bcbe31d9006ce8b28d149b0ef89 | |
parent | 60455c972b09ca02b18660c6fb3dafc03b30b2b5 (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
Reviewed-on: https://gerrit.libreoffice.org/4816
Reviewed-by: Michael Meeks <michael.meeks@suse.com>
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Tested-by: Michael Stahl <mstahl@redhat.com>
-rw-r--r-- | include/xmloff/txtimp.hxx | 11 | ||||
-rw-r--r-- | include/xmloff/txtimppr.hxx | 6 | ||||
-rw-r--r-- | reportdesign/source/filter/xml/xmlStyleImport.cxx | 4 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlstyli.cxx | 2 | ||||
-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 |
8 files changed, 21 insertions, 59 deletions
diff --git a/include/xmloff/txtimp.hxx b/include/xmloff/txtimp.hxx index 0fc68b529773..c15bd8b186a7 100644 --- a/include/xmloff/txtimp.hxx +++ b/include/xmloff/txtimp.hxx @@ -409,9 +409,6 @@ public: void SetAutoStyles( SvXMLStylesContext *pStyles ); - void SetFontDecls( XMLFontStylesContext *pFontDecls ); - const XMLFontStylesContext *GetFontDecls() const; - SvXMLImportContext *CreateTextChildContext( SvXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName, @@ -557,10 +554,10 @@ public: GetRubyImportPropertySetMapper() const; static SvXMLImportPropertyMapper *CreateShapeExtPropMapper(SvXMLImport&); - static SvXMLImportPropertyMapper *CreateParaExtPropMapper(SvXMLImport&, XMLFontStylesContext *pFontDecls = NULL); - static SvXMLImportPropertyMapper* CreateParaDefaultExtPropMapper(SvXMLImport&, XMLFontStylesContext* pFontDecls = NULL); - static SvXMLImportPropertyMapper* CreateTableDefaultExtPropMapper(SvXMLImport&, XMLFontStylesContext* pFontDecls = NULL); - static SvXMLImportPropertyMapper* CreateTableRowDefaultExtPropMapper(SvXMLImport&, XMLFontStylesContext* pFontDecls = NULL); + static SvXMLImportPropertyMapper *CreateParaExtPropMapper(SvXMLImport&); + static SvXMLImportPropertyMapper* CreateParaDefaultExtPropMapper(SvXMLImport&); + static SvXMLImportPropertyMapper* CreateTableDefaultExtPropMapper(SvXMLImport&); + static SvXMLImportPropertyMapper* CreateTableRowDefaultExtPropMapper(SvXMLImport&); SvI18NMap& GetRenameMap(); diff --git a/include/xmloff/txtimppr.hxx b/include/xmloff/txtimppr.hxx index ae58bdd9f55e..0bae7ed87635 100644 --- a/include/xmloff/txtimppr.hxx +++ b/include/xmloff/txtimppr.hxx @@ -28,7 +28,6 @@ class XMLOFF_DLLPUBLIC XMLTextImportPropertyMapper : public SvXMLImportPropertyM { sal_Int32 nSizeTypeIndex; sal_Int32 nWidthTypeIndex; - SvXMLImportContextRef xFontDecls; void FontFinished( XMLPropertyState *pFontFamilyNameState, @@ -58,12 +57,9 @@ protected: public: XMLTextImportPropertyMapper( const UniReference< XMLPropertySetMapper >& rMapper, - SvXMLImport& rImport, - XMLFontStylesContext *pFontDecls = 0 ); + SvXMLImport& rImport ); virtual ~XMLTextImportPropertyMapper(); - void SetFontDecls( XMLFontStylesContext *pFontDecls ); - /** This method is called when all attributes have benn processed. It may be used to remove items that are incomplete */ virtual void finished( ::std::vector< XMLPropertyState >& rProperties, diff --git a/reportdesign/source/filter/xml/xmlStyleImport.cxx b/reportdesign/source/filter/xml/xmlStyleImport.cxx index 4b80bcf1bbea..a79a9c2f5dea 100644 --- a/reportdesign/source/filter/xml/xmlStyleImport.cxx +++ b/reportdesign/source/filter/xml/xmlStyleImport.cxx @@ -213,9 +213,9 @@ UniReference < SvXMLImportPropertyMapper > if( !m_xCellImpPropMapper.is() ) { m_xCellImpPropMapper = - new XMLTextImportPropertyMapper/*OSpecialHanldeXMLImportPropertyMapper*/( rImport.GetCellStylesPropertySetMapper(), m_rImport , const_cast<XMLFontStylesContext*>(m_rImport.GetFontDecls())); + new XMLTextImportPropertyMapper/*OSpecialHanldeXMLImportPropertyMapper*/( rImport.GetCellStylesPropertySetMapper(), m_rImport ); - m_xCellImpPropMapper->ChainImportMapper(XMLTextImportHelper::CreateParaExtPropMapper(m_rImport, const_cast<XMLFontStylesContext*>(m_rImport.GetFontDecls()))); + m_xCellImpPropMapper->ChainImportMapper(XMLTextImportHelper::CreateParaExtPropMapper(m_rImport)); } xMapper = m_xCellImpPropMapper; } diff --git a/sc/source/filter/xml/xmlstyli.cxx b/sc/source/filter/xml/xmlstyli.cxx index 477f151cbba6..9ca8245e4c3c 100644 --- a/sc/source/filter/xml/xmlstyli.cxx +++ b/sc/source/filter/xml/xmlstyli.cxx @@ -750,7 +750,7 @@ UniReference < SvXMLImportPropertyMapper > { ((XMLTableStylesContext *)this)->xCellImpPropMapper = new ScXMLCellImportPropertyMapper( GetScImport().GetCellStylesPropertySetMapper(), const_cast<SvXMLImport&>(GetImport()) ); - xCellImpPropMapper->ChainImportMapper(XMLTextImportHelper::CreateParaExtPropMapper(const_cast<SvXMLImport&>(GetImport()), const_cast<XMLFontStylesContext*>(GetScImport().GetFontDecls()))); + xCellImpPropMapper->ChainImportMapper(XMLTextImportHelper::CreateParaExtPropMapper(const_cast<SvXMLImport&>(GetImport()))); } xMapper = xCellImpPropMapper; } diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx index d76eefe95d0d..263175d8be07 100644 --- a/xmloff/source/core/xmlimp.cxx +++ b/xmloff/source/core/xmlimp.cxx @@ -1491,7 +1491,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 af11d3571cce..79542932bba2 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 4b15efc9acfc..db06df836338 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 ); @@ -2156,20 +2148,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, |