[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-4.2' - writerfilter/source

Michael Stahl mstahl at redhat.com
Mon Sep 8 06:16:30 PDT 2014


 writerfilter/source/dmapper/DomainMapper_Impl.cxx |    6 +-
 writerfilter/source/rtftok/rtfdocumentimpl.cxx    |   51 ++++++++--------------
 writerfilter/source/rtftok/rtfdocumentimpl.hxx    |    3 -
 3 files changed, 24 insertions(+), 36 deletions(-)

New commits:
commit 01a53d19b138cf7285e3b31be545dc915958b3c9
Author: Michael Stahl <mstahl at redhat.com>
Date:   Sat Aug 2 18:55:55 2014 +0200

    fdo#81944 fdo#82107: writerfilter: RTF import: don't drop fonts in stylesheet
    
    The font definitions in the style sheet meet an untimely death in
    StyleSheetTable::lcl_sprm(), which special-cases LN_EG_RPrBase_rFonts,
    routing it into TblStylePrHandler.
    
    Avoid this by sending style entries to the domain mapper in the same way
    as the OOXML tokenizer, i.e., with paragraph and run properties nested
    below CT_Style_pPr/rPr.
    
    This reveals that the CT_Style_basedOn was wrongly handled as paragraph
    property.
    
    (cherry picked from commit f8e8e476aa0a5576234dbb4daac9dc299e044e61)
    
    Conflicts:
    	writerfilter/source/rtftok/rtfdocumentimpl.cxx
    
    Change-Id: Ic724ba48fe36bf782b1b430bdafdb1df480d5ad3

diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 2b87cd7..4e9a6f1 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -4333,15 +4333,17 @@ uno::Reference<container::XIndexAccess> DomainMapper_Impl::GetCurrentNumberingRu
 
         // So we are in a paragraph style and it has numbering. Look up the relevant numbering rules.
         OUString aListName = ListDef::GetStyleName(nListId);
-        uno::Reference< style::XStyleFamiliesSupplier > xStylesSupplier(GetTextDocument(), uno::UNO_QUERY);
+        uno::Reference< style::XStyleFamiliesSupplier > xStylesSupplier(GetTextDocument(), uno::UNO_QUERY_THROW);
         uno::Reference< container::XNameAccess > xStyleFamilies = xStylesSupplier->getStyleFamilies();
         uno::Reference<container::XNameAccess> xNumberingStyles;
         xStyleFamilies->getByName("NumberingStyles") >>= xNumberingStyles;
         uno::Reference<beans::XPropertySet> xStyle(xNumberingStyles->getByName(aListName), uno::UNO_QUERY);
         xRet.set(xStyle->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
     }
-    catch( const uno::Exception& )
+    catch (const uno::Exception& e)
     {
+        SAL_WARN("writerfilter.dmapper",
+                "GetCurrentNumberingRules: exception caught: " << e.Message);
     }
     return xRet;
 }
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 649b3fc..76a083c 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1127,7 +1127,7 @@ void RTFDocumentImpl::text(OUString& rString)
                                 m_aStates.top().aTableSprms.set(NS_ooxml::LN_CT_Style_name, pValue);
 
                                 writerfilter::Reference<Properties>::Pointer_t const pProp(
-                                        new RTFReferenceProperties(mergeAttributes(), mergeSprms())
+                       createStyleProperties()
                                         );
                                 m_aStyleTableEntries.insert(make_pair(m_nCurrentStyleIndex, pProp));
                             }
@@ -3059,6 +3059,10 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
         case RTF_LEVELNFC: nSprm = NS_rtf::LN_NFC; break;
         case RTF_LEVELSTARTAT: nSprm = NS_rtf::LN_ISTARTAT; break;
         case RTF_LEVELPICTURE: nSprm = NS_ooxml::LN_CT_Lvl_lvlPicBulletId; break;
+        case RTF_SBASEDON:
+           nSprm = (nKeyword == RTF_SBASEDON) ? NS_ooxml::LN_CT_Style_basedOn : NS_ooxml::LN_CT_Style_next;
+           pIntValue.reset(new RTFValue(getStyleName(nParam)));
+           break;
         default: break;
     }
     if (nSprm > 0)
@@ -3096,10 +3100,6 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
         case RTF_RI: nSprm = NS_sprm::LN_PDxaRight; break;
         case RTF_RIN: nSprm = 0x845d; break;
         case RTF_ITAP: nSprm = NS_sprm::LN_PTableDepth; break;
-        case RTF_SBASEDON:
-           nSprm = (nKeyword == RTF_SBASEDON) ? NS_ooxml::LN_CT_Style_basedOn : NS_ooxml::LN_CT_Style_next;
-           pIntValue.reset(new RTFValue(getStyleName(nParam)));
-           break;
         default: break;
     }
     if (nSprm > 0)
@@ -4194,19 +4194,21 @@ int RTFDocumentImpl::pushState()
     return 0;
 }
 
-RTFSprms RTFDocumentImpl::mergeSprms()
+writerfilter::Reference<Properties>::Pointer_t
+RTFDocumentImpl::createStyleProperties()
 {
-    RTFSprms aSprms;
-    for (RTFSprms::Iterator_t i = m_aStates.top().aTableSprms.begin();
-            i != m_aStates.top().aTableSprms.end(); ++i)
-        aSprms.set(i->first, i->second);
-    for (RTFSprms::Iterator_t i = m_aStates.top().aCharacterSprms.begin();
-            i != m_aStates.top().aCharacterSprms.end(); ++i)
-        aSprms.set(i->first, i->second);
-    for (RTFSprms::Iterator_t i = m_aStates.top().aParagraphSprms.begin();
-            i != m_aStates.top().aParagraphSprms.end(); ++i)
-        aSprms.set(i->first, i->second);
-    return aSprms;
+    RTFValue::Pointer_t const pParaProps(
+        new RTFValue(m_aStates.top().aParagraphAttributes, m_aStates.top().aParagraphSprms));
+    RTFValue::Pointer_t const pCharProps(
+        new RTFValue(m_aStates.top().aCharacterAttributes, m_aStates.top().aCharacterSprms));
+
+    // resetSprms will clean up this modification
+    m_aStates.top().aTableSprms.set(NS_ooxml::LN_CT_Style_pPr, pParaProps);
+    m_aStates.top().aTableSprms.set(NS_ooxml::LN_CT_Style_rPr, pCharProps);
+
+    writerfilter::Reference<Properties>::Pointer_t const pProps(
+        new RTFReferenceProperties(m_aStates.top().aTableAttributes, m_aStates.top().aTableSprms));
+    return pProps;
 }
 
 void RTFDocumentImpl::resetSprms()
@@ -4216,21 +4218,6 @@ void RTFDocumentImpl::resetSprms()
     m_aStates.top().aParagraphSprms.clear();
 }
 
-RTFSprms RTFDocumentImpl::mergeAttributes()
-{
-    RTFSprms aAttributes;
-    for (RTFSprms::Iterator_t i = m_aStates.top().aTableAttributes.begin();
-            i != m_aStates.top().aTableAttributes.end(); ++i)
-        aAttributes.set(i->first, i->second);
-    for (RTFSprms::Iterator_t i = m_aStates.top().aCharacterAttributes.begin();
-            i != m_aStates.top().aCharacterAttributes.end(); ++i)
-        aAttributes.set(i->first, i->second);
-    for (RTFSprms::Iterator_t i = m_aStates.top().aParagraphAttributes.begin();
-            i != m_aStates.top().aParagraphAttributes.end(); ++i)
-        aAttributes.set(i->first, i->second);
-    return aAttributes;
-}
-
 void RTFDocumentImpl::resetAttributes()
 {
     m_aStates.top().aTableAttributes.clear();
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 07571d2..599b58d 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -369,8 +369,7 @@ namespace writerfilter {
             private:
                 SvStream& Strm();
                 sal_uInt32 getColorTable(sal_uInt32 nIndex);
-                RTFSprms mergeSprms();
-                RTFSprms mergeAttributes();
+    writerfilter::Reference<Properties>::Pointer_t createStyleProperties();
                 void resetSprms();
                 void resetAttributes();
                 void resolveSubstream(sal_uInt32 nPos, Id nId);


More information about the Libreoffice-commits mailing list