[Libreoffice-commits] core.git: include/xmloff reportdesign/source sc/source xmloff/source

Luboš Luňák l.lunak at suse.cz
Wed Jul 10 08:35:52 PDT 2013


 include/xmloff/txtimp.hxx                         |   11 ++----
 include/xmloff/txtimppr.hxx                       |    6 ---
 reportdesign/source/filter/xml/xmlStyleImport.cxx |    4 +-
 sc/source/filter/xml/xmlstyli.cxx                 |    2 -
 xmloff/source/core/xmlimp.cxx                     |    1 
 xmloff/source/style/xmlnumi.cxx                   |    2 -
 xmloff/source/text/txtimp.cxx                     |   38 ++++------------------
 xmloff/source/text/txtimppr.cxx                   |   16 ++-------
 8 files changed, 21 insertions(+), 59 deletions(-)

New commits:
commit a1190c9d2e85c4ccb9db106fe9eb4a48219ac126
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Wed Jul 10 17:33:15 2013 +0200

    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

diff --git a/include/xmloff/txtimp.hxx b/include/xmloff/txtimp.hxx
index 0fc68b5..c15bd8b 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 ae58bdd..0bae7ed 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 4b80bcf..a79a9c2 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 e96a1ec..f905a5e 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 2e4eb46..121b4d4 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 28553ba..b4ac805 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 f35a46d..eb74f00 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 306ebb1..40f5dc2 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,


More information about the Libreoffice-commits mailing list