[Libreoffice-commits] core.git: 3 commits - sw/qa vcl/source writerfilter/source

Michael Stahl mstahl at redhat.com
Sat Aug 2 10:15:41 PDT 2014


 sw/qa/extras/rtfimport/data/fdo81944.rtf          |   15 +++++
 sw/qa/extras/rtfimport/rtfimport.cxx              |   13 ++++
 vcl/source/gdi/sallayout.cxx                      |    9 +--
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |    6 +-
 writerfilter/source/rtftok/rtfdocumentimpl.cxx    |   66 +++++++++-------------
 writerfilter/source/rtftok/rtfdocumentimpl.hxx    |    3 -
 6 files changed, 66 insertions(+), 46 deletions(-)

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

    fdo#81944: 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.
    
    Change-Id: Ic724ba48fe36bf782b1b430bdafdb1df480d5ad3

diff --git a/sw/qa/extras/rtfimport/data/fdo81944.rtf b/sw/qa/extras/rtfimport/data/fdo81944.rtf
new file mode 100644
index 0000000..780e9bd
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/fdo81944.rtf
@@ -0,0 +1,15 @@
+{\rtf1
+
+{\fonttbl
+{\f38\fbidi \fswiss\fcharset0\fprq2 Segoe UI;}
+{\fbiminor\f31507\fbidi \froman\fcharset0\fprq2 Times New Roman;}
+}
+
+{\stylesheet
+{\qc \rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0 \f38\fs18\lang1033\langfe1033 Normal;}
+}
+
+\pard
+
+\par
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index cc510ce..e9cf28d 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -1219,6 +1219,19 @@ DECLARE_RTFIMPORT_TEST(testPageBackground, "page-background.rtf")
     CPPUNIT_ASSERT_EQUAL(sal_Int32(0x92D050), getProperty<sal_Int32>(xPageStyle, "BackColor"));
 }
 
+DECLARE_RTFIMPORT_TEST(testFdo81944, "fdo81944.rtf")
+{
+    // font properties in style were not imported
+    uno::Reference<beans::XPropertySet> xPropertySet(
+        getStyles("ParagraphStyles")->getByName("Standard"), uno::UNO_QUERY);
+    uno::Reference<style::XStyle> xStyle(xPropertySet, uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(OUString("Segoe UI"), getProperty<OUString>(xStyle, "CharFontName"));
+    CPPUNIT_ASSERT_EQUAL(9.0f, getProperty<float>(xStyle, "CharHeight"));
+    // not sure if this should be set on Asian or Complex or both?
+    CPPUNIT_ASSERT_EQUAL(OUString("Times New Roman"), getProperty<OUString>(xStyle, "CharFontNameComplex"));
+    CPPUNIT_ASSERT_EQUAL(11.0f, getProperty<float>(xStyle, "CharHeightComplex"));
+}
+
 DECLARE_RTFIMPORT_TEST(testFdo62044, "fdo62044.rtf")
 {
     // The problem was that RTF import during copy&paste did not ignore existing paragraph styles.
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 685a98c..1c736f0 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -4690,15 +4690,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 e234a72..f2c0ae4 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1152,7 +1152,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));
                 }
@@ -3381,6 +3381,10 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
     case RTF_LEVELPICTURE:
         nSprm = NS_ooxml::LN_CT_Lvl_lvlPicBulletId;
         break;
+    case RTF_SBASEDON:
+        nSprm = NS_ooxml::LN_CT_Style_basedOn;
+        pIntValue.reset(new RTFValue(getStyleName(nParam)));
+        break;
     default:
         break;
     }
@@ -3457,10 +3461,6 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
     case RTF_ITAP:
         nSprm = NS_ooxml::LN_tblDepth;
         break;
-    case RTF_SBASEDON:
-        nSprm = NS_ooxml::LN_CT_Style_basedOn;
-        pIntValue.reset(new RTFValue(getStyleName(nParam)));
-        break;
     default:
         break;
     }
@@ -4764,19 +4764,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()
@@ -4786,21 +4788,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 3a9f0d8..72a3f5f 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -391,8 +391,7 @@ public:
 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_Size nPos, Id nId);
commit 6defffea57ba803a47fd10d1496e0c5c477009c8
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Aug 1 22:56:37 2014 +0200

    vcl: evidently a little more type safety is required here
    
    MultiSalLayout::AdjustLayout() crashes with mangled stack.
    
    (regression from 2b8528a2745bec7909bfe2265d6110a9964eef47)
    
    Change-Id: I20b7980dd89dd1b72063c2187ac3a4735babc4c4

diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx
index 8faddc5..21ee47f 100644
--- a/vcl/source/gdi/sallayout.cxx
+++ b/vcl/source/gdi/sallayout.cxx
@@ -1523,6 +1523,7 @@ void MultiSalLayout::AdjustLayout( ImplLayoutArgs& rArgs )
 {
     SalLayout::AdjustLayout( rArgs );
     ImplLayoutArgs aMultiArgs = rArgs;
+    boost::scoped_array<DeviceCoordinate> pJustificationArray;
 
     if( !rArgs.mpDXArray && rArgs.mnLayoutWidth )
     {
@@ -1537,8 +1538,8 @@ void MultiSalLayout::AdjustLayout( ImplLayoutArgs& rArgs )
             mpLayouts[n]->SalLayout::AdjustLayout( aMultiArgs );
         // then we can measure the unmodified metrics
         int nCharCount = rArgs.mnEndCharPos - rArgs.mnMinCharPos;
-        DeviceCoordinate* pJustificationArray = (DeviceCoordinate*)alloca( nCharCount * sizeof(sal_Int32) );
-        FillDXArray( pJustificationArray );
+        pJustificationArray.reset(new DeviceCoordinate[nCharCount]);
+        FillDXArray( pJustificationArray.get() );
         // #i17359# multilayout is not simplified yet, so calculating the
         // unjustified width needs handholding; also count the number of
         // stretchable virtual char widths
@@ -1585,8 +1586,8 @@ void MultiSalLayout::AdjustLayout( ImplLayoutArgs& rArgs )
                 }
             }
 
-            // change the mpDXArray temporarilly (just for the justification)
-            aMultiArgs.mpDXArray = pJustificationArray;
+            // change the mpDXArray temporarily (just for the justification)
+            aMultiArgs.mpDXArray = pJustificationArray.get();
         }
     }
 
commit b46956e73b6daff2578110c0395fd80150dc0b0b
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Aug 1 20:21:21 2014 +0200

    writerfilter: RTF import: ignore content of \upr, except for \ud
    
    The content of \upr and its nested \ud destination should be the same
    modulo text encoding, so ignore the legacy one.
    
    Change-Id: I007151e3075a9ac879a486ec3b5fb8549435dbba

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 3344fb1..e234a72 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1440,7 +1440,14 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
     setNeedSect();
     checkUnicode(/*bUnicode =*/ true, /*bHex =*/ true);
     RTFSkipDestination aSkip(*this);
-    switch (nKeyword)
+    // special case \upr: ignore everything except nested \ud
+    if (DESTINATION_UPR == m_aStates.top().nDestinationState
+        && RTF_UD != nKeyword)
+    {
+        m_aStates.top().nDestinationState = DESTINATION_SKIP;
+        aSkip.setParsed(false);
+    }
+    else switch (nKeyword)
     {
     case RTF_RTF:
         break;
@@ -1837,11 +1844,7 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
         m_aStates.top().nDestinationState = DESTINATION_PARAGRAPHNUMBERING_TEXTBEFORE;
         break;
     case RTF_TITLE:
-        // \title inside \upr but outside \ud should be ignored.
-        if (m_aStates.top().nDestinationState != DESTINATION_UPR)
-            m_aStates.top().nDestinationState = DESTINATION_TITLE;
-        else
-            m_aStates.top().nDestinationState = DESTINATION_SKIP;
+        m_aStates.top().nDestinationState = DESTINATION_TITLE;
         break;
     case RTF_SUBJECT:
         m_aStates.top().nDestinationState = DESTINATION_SUBJECT;


More information about the Libreoffice-commits mailing list