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

Miklos Vajna vmiklos at collabora.co.uk
Tue Oct 24 09:26:44 UTC 2017


 sw/qa/extras/rtfexport/data/tdf113202.rtf    |   42 +++++++++
 sw/qa/extras/rtfexport/rtfexport.cxx         |    6 +
 sw/source/core/inc/UndoTable.hxx             |   22 ++--
 sw/source/core/undo/untbl.cxx                |  120 +++++++++++++--------------
 writerfilter/source/dmapper/DomainMapper.cxx |    8 +
 5 files changed, 127 insertions(+), 71 deletions(-)

New commits:
commit f8b5ecc622e2b3e82576b27bf0ded9c8eac21cae
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Oct 24 09:27:19 2017 +0200

    tdf#113202 RTF import: fix lack of expected contextual spacing
    
    Upper, lower and contextual spacing are all stored in SvxULSpaceItem, so
    if after spacing is set as direct formatting, contextual spacing has to
    be set directly as well (having it in the paragraph style has no
    effect).
    
    Change-Id: Ie331c7561de7f2f16776a1613717e38fa083a541
    Reviewed-on: https://gerrit.libreoffice.org/43735
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/qa/extras/rtfexport/data/tdf113202.rtf b/sw/qa/extras/rtfexport/data/tdf113202.rtf
new file mode 100644
index 000000000000..43860bf0becf
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf113202.rtf
@@ -0,0 +1,42 @@
+{\rtf1\adeflang1037\ansi\ansicpg1252\uc1\adeff1\deff0\stshfdbch31506\stshfloch31506\stshfhich31506\stshfbi31507\deflang1033\deflangfe1033\themelang1033\themelangfe0\themelangcs0
+{\fonttbl
+{\f0\fbidi \froman\fcharset238\fprq2 Times New Roman;}
+{\f3\fbidi \froman\fcharset2\fprq2 Symbol;}
+{\f40\fbidi \fswiss\fcharset238\fprq2 Verdana;}
+}
+\noqfpromote
+{\stylesheet
+{\s15\ql \li720\ri0\sa200\sl276\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin720\itap0\contextualspace \rtlch\fcs1 \af1\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon0 \snext15 \sqformat \spriority34 List Paragraph;}
+}
+{\*\listtable
+{\list\listtemplateid1644085804\listhybrid
+{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace0\levelindent0
+{\leveltext
+\leveltemplateid67698689\'01\u-3913 ?;}
+{\levelnumbers;}
+\f3\fbias0 \fi-360\li720\lin720 }
+{\listname ;}
+\listid2028170298}
+}
+{\*\listoverridetable
+{\listoverride\listid2028170298\listoverridecount0\ls1}
+}
+\paperw12240\paperh15840\margl1417\margr1417\margt1417\margb1417
+\pard\plain \ltrpar
+\s15\ql \fi-360\li720\ri0\sa200\sl276\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\ls1\adjustright\rin0\lin720\itap0\contextualspace \rtlch\fcs1 \af1\afs22\alang1025 \ltrch\fcs0
+\f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033
+{\rtlch\fcs1 \af37\afs16 \ltrch\fcs0 \f40\fs16 Profile 1 \endash A1\par}
+{\rtlch\fcs1 \af37\afs16 \ltrch\fcs0 \f40\fs16 Profile 1 \endash A2\par}
+{\rtlch\fcs1 \af37\afs16 \ltrch\fcs0 \f40\fs16 Profile 1 \endash A3\par}
+\pard \ltrpar\s15\ql \fi-360\li720\ri0\sl276\slmult1
+\widctlpar\wrapdefault\aspalpha\aspnum\faauto\ls1\adjustright\rin0\lin720\itap0\contextualspace
+{\rtlch\fcs1 \af37\afs16 \ltrch\fcs0 \f40\fs16 Profile 4 }
+{\rtlch\fcs1 \af37\afs16 \ltrch\fcs0
+\f40\fs16 \endash }
+{\rtlch\fcs1 \af37\afs16 \ltrch\fcs0 \f40\fs16 }
+{\rtlch\fcs1 \af37\afs16 \ltrch\fcs0 \f40\fs16 A4}
+{\rtlch\fcs1 \af37\afs16 \ltrch\fcs0
+\f40\fs16
+\par }
+\pard\plain\par
+}
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index 5664cc8872f6..5923007b8d3a 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -1307,6 +1307,12 @@ DECLARE_RTFEXPORT_TEST(testTdf112211, "tdf112211.rtf")
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(-635), aRule["FirstLineIndent"].get<sal_Int32>());
 }
 
+DECLARE_RTFEXPORT_TEST(testTdf113202, "tdf113202.rtf")
+{
+    // This failed, contextual spacing in 4th paragraph was lost.
+    CPPUNIT_ASSERT(getProperty<bool>(getParagraph(4), "ParaContextMargin"));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index af3579441047..2a831262e6de 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -405,8 +405,16 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
         case NS_ooxml::LN_CT_Spacing_after:
             m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "after", OUString::number(nIntValue));
             if (m_pImpl->GetTopContext())
+            {
                 // Don't overwrite NS_ooxml::LN_CT_Spacing_afterAutospacing.
                 m_pImpl->GetTopContext()->Insert(PROP_PARA_BOTTOM_MARGIN, uno::makeAny( ConversionHelper::convertTwipToMM100( nIntValue ) ), false);
+
+                uno::Any aContextualSpacingFromStyle = m_pImpl->GetPropertyFromStyleSheet(PROP_PARA_CONTEXT_MARGIN);
+                if (aContextualSpacingFromStyle.hasValue())
+                    // Setting "after" spacing means Writer doesn't inherit
+                    // contexual spacing anymore from style, but Word does.
+                    m_pImpl->GetTopContext()->Insert(PROP_PARA_CONTEXT_MARGIN, aContextualSpacingFromStyle);
+            }
             break;
         case NS_ooxml::LN_CT_Spacing_afterLines:
             m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "afterLines", OUString::number(nIntValue));
commit 460d8428f9df48b13ae780b9e8a07ae8b31b8879
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Oct 24 09:26:33 2017 +0200

    sw: prefix members of SwUndoTableNumFormat
    
    Change-Id: I06cc74fe2c32f9d76ce6115b779ed764434634b7
    Reviewed-on: https://gerrit.libreoffice.org/43734
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/source/core/inc/UndoTable.hxx b/sw/source/core/inc/UndoTable.hxx
index 2cd09342f408..6b2fc68e4648 100644
--- a/sw/source/core/inc/UndoTable.hxx
+++ b/sw/source/core/inc/UndoTable.hxx
@@ -251,18 +251,18 @@ public:
 
 class SwUndoTableNumFormat : public SwUndo
 {
-    SfxItemSet *pBoxSet;
-    SwHistory* pHistory;
-    OUString aStr, aNewFormula;
+    SfxItemSet *m_pBoxSet;
+    SwHistory* m_pHistory;
+    OUString m_aStr, m_aNewFormula;
 
-    sal_uLong nFormatIdx, nNewFormatIdx;
-    double fNum, fNewNum;
-    sal_uLong nNode;
-    sal_uLong nNdPos;
+    sal_uLong m_nFormatIdx, m_nNewFormatIdx;
+    double m_fNum, m_fNewNum;
+    sal_uLong m_nNode;
+    sal_uLong m_nNodePos;
 
-    bool bNewFormat : 1;
-    bool bNewFormula : 1;
-    bool bNewValue : 1;
+    bool m_bNewFormat : 1;
+    bool m_bNewFormula : 1;
+    bool m_bNewValue : 1;
 
 public:
     SwUndoTableNumFormat( const SwTableBox& rBox, const SfxItemSet* pNewSet = nullptr );
@@ -273,7 +273,7 @@ public:
     virtual void RedoImpl( ::sw::UndoRedoContext & ) override;
 
     void SetNumFormat( sal_uLong nNewNumFormatIdx, const double& rNewNumber )
-            { nFormatIdx = nNewNumFormatIdx; fNum = rNewNumber; }
+            { m_nFormatIdx = nNewNumFormatIdx; m_fNum = rNewNumber; }
     void SetBox( const SwTableBox& rBox );
 };
 
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index f0bbd01cccad..946d7b6bfd42 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -2141,42 +2141,42 @@ void SwUndoTableMerge::SaveCollection( const SwTableBox& rBox )
 SwUndoTableNumFormat::SwUndoTableNumFormat( const SwTableBox& rBox,
                                     const SfxItemSet* pNewSet )
     : SwUndo(SwUndoId::TBLNUMFMT, rBox.GetFrameFormat()->GetDoc())
-    , pBoxSet(nullptr)
-    , pHistory(nullptr)
-    , nFormatIdx(css::util::NumberFormat::TEXT)
-    , nNewFormatIdx(0)
-    , fNum(0.0)
-    , fNewNum(0.0)
-    , bNewFormat(false)
-    , bNewFormula(false)
-    , bNewValue(false)
-{
-    nNode = rBox.GetSttIdx();
-
-    nNdPos = rBox.IsValidNumTextNd( nullptr == pNewSet );
+    , m_pBoxSet(nullptr)
+    , m_pHistory(nullptr)
+    , m_nFormatIdx(css::util::NumberFormat::TEXT)
+    , m_nNewFormatIdx(0)
+    , m_fNum(0.0)
+    , m_fNewNum(0.0)
+    , m_bNewFormat(false)
+    , m_bNewFormula(false)
+    , m_bNewValue(false)
+{
+    m_nNode = rBox.GetSttIdx();
+
+    m_nNodePos = rBox.IsValidNumTextNd( nullptr == pNewSet );
     SwDoc* pDoc = rBox.GetFrameFormat()->GetDoc();
 
-    if( ULONG_MAX != nNdPos )
+    if( ULONG_MAX != m_nNodePos )
     {
-        SwTextNode* pTNd = pDoc->GetNodes()[ nNdPos ]->GetTextNode();
+        SwTextNode* pTNd = pDoc->GetNodes()[ m_nNodePos ]->GetTextNode();
 
-        pHistory = new SwHistory;
-        SwRegHistory aRHst( *rBox.GetSttNd(), pHistory );
+        m_pHistory = new SwHistory;
+        SwRegHistory aRHst( *rBox.GetSttNd(), m_pHistory );
         // always save all text atttibutes because of possibly overlapping
         // areas of on/off
-        pHistory->CopyAttr( pTNd->GetpSwpHints(), nNdPos, 0,
+        m_pHistory->CopyAttr( pTNd->GetpSwpHints(), m_nNodePos, 0,
                             pTNd->GetText().getLength(), true );
 
         if( pTNd->HasSwAttrSet() )
-            pHistory->CopyFormatAttr( *pTNd->GetpSwAttrSet(), nNdPos );
+            m_pHistory->CopyFormatAttr( *pTNd->GetpSwAttrSet(), m_nNodePos );
 
-        aStr = pTNd->GetText();
+        m_aStr = pTNd->GetText();
         if( pTNd->GetpSwpHints() )
             pTNd->GetpSwpHints()->DeRegister();
     }
 
-    pBoxSet = new SfxItemSet( pDoc->GetAttrPool(), aTableBoxSetRange );
-    pBoxSet->Put( rBox.GetFrameFormat()->GetAttrSet() );
+    m_pBoxSet = new SfxItemSet( pDoc->GetAttrPool(), aTableBoxSetRange );
+    m_pBoxSet->Put( rBox.GetFrameFormat()->GetAttrSet() );
 
     if( pNewSet )
     {
@@ -2184,40 +2184,40 @@ SwUndoTableNumFormat::SwUndoTableNumFormat( const SwTableBox& rBox,
         if( SfxItemState::SET == pNewSet->GetItemState( RES_BOXATR_FORMAT,
                 false, &pItem ))
         {
-            bNewFormat = true;
-            nNewFormatIdx = static_cast<const SwTableBoxNumFormat*>(pItem)->GetValue();
+            m_bNewFormat = true;
+            m_nNewFormatIdx = static_cast<const SwTableBoxNumFormat*>(pItem)->GetValue();
         }
         if( SfxItemState::SET == pNewSet->GetItemState( RES_BOXATR_FORMULA,
                 false, &pItem ))
         {
-            bNewFormula = true;
-            aNewFormula = static_cast<const SwTableBoxFormula*>(pItem)->GetFormula();
+            m_bNewFormula = true;
+            m_aNewFormula = static_cast<const SwTableBoxFormula*>(pItem)->GetFormula();
         }
         if( SfxItemState::SET == pNewSet->GetItemState( RES_BOXATR_VALUE,
                 false, &pItem ))
         {
-            bNewValue = true;
-            fNewNum = static_cast<const SwTableBoxValue*>(pItem)->GetValue();
+            m_bNewValue = true;
+            m_fNewNum = static_cast<const SwTableBoxValue*>(pItem)->GetValue();
         }
     }
 
     // is a history needed at all?
-    if( pHistory && !pHistory->Count() )
-        DELETEZ( pHistory );
+    if( m_pHistory && !m_pHistory->Count() )
+        DELETEZ( m_pHistory );
 }
 
 SwUndoTableNumFormat::~SwUndoTableNumFormat()
 {
-    delete pHistory;
-    delete pBoxSet;
+    delete m_pHistory;
+    delete m_pBoxSet;
 }
 
 void SwUndoTableNumFormat::UndoImpl(::sw::UndoRedoContext & rContext)
 {
-    OSL_ENSURE( pBoxSet, "Where's the stored item set?" );
+    OSL_ENSURE( m_pBoxSet, "Where's the stored item set?" );
 
     SwDoc & rDoc = rContext.GetDoc();
-    SwStartNode* pSttNd = rDoc.GetNodes()[ nNode ]->
+    SwStartNode* pSttNd = rDoc.GetNodes()[ m_nNode ]->
                             FindSttNodeByType( SwTableBoxStartNode );
     OSL_ENSURE( pSttNd, "without StartNode no TableBox" );
     SwTableBox* pBox = pSttNd->FindTableNode()->GetTable().GetTableBox(
@@ -2225,46 +2225,46 @@ void SwUndoTableNumFormat::UndoImpl(::sw::UndoRedoContext & rContext)
     OSL_ENSURE( pBox, "found no TableBox" );
 
     SwTableBoxFormat* pFormat = rDoc.MakeTableBoxFormat();
-    pFormat->SetFormatAttr( *pBoxSet );
+    pFormat->SetFormatAttr( *m_pBoxSet );
     pBox->ChgFrameFormat( pFormat );
 
-    if( ULONG_MAX == nNdPos )
+    if( ULONG_MAX == m_nNodePos )
         return;
 
-    SwTextNode* pTextNd = rDoc.GetNodes()[ nNdPos ]->GetTextNode();
+    SwTextNode* pTextNd = rDoc.GetNodes()[ m_nNodePos ]->GetTextNode();
     // If more than one node was deleted than all "node" attributes were also
     // saved
     if( pTextNd->HasSwAttrSet() )
         pTextNd->ResetAllAttr();
 
-    if( pTextNd->GetpSwpHints() && !aStr.isEmpty() )
+    if( pTextNd->GetpSwpHints() && !m_aStr.isEmpty() )
         pTextNd->ClearSwpHintsArr( true );
 
     // ChgTextToNum(..) only acts when the strings are different. We need to do
     // the same here.
-    if( pTextNd->GetText() != aStr )
+    if( pTextNd->GetText() != m_aStr )
     {
         rDoc.getIDocumentRedlineAccess().DeleteRedline( *( pBox->GetSttNd() ), false, USHRT_MAX );
 
         SwIndex aIdx( pTextNd, 0 );
-        if( !aStr.isEmpty() )
+        if( !m_aStr.isEmpty() )
         {
             pTextNd->EraseText( aIdx );
-            pTextNd->InsertText( aStr, aIdx,
+            pTextNd->InsertText( m_aStr, aIdx,
                 SwInsertFlags::NOHINTEXPAND );
         }
     }
 
-    if( pHistory )
+    if( m_pHistory )
     {
-        sal_uInt16 nTmpEnd = pHistory->GetTmpEnd();
-        pHistory->TmpRollback( &rDoc, 0 );
-        pHistory->SetTmpEnd( nTmpEnd );
+        sal_uInt16 nTmpEnd = m_pHistory->GetTmpEnd();
+        m_pHistory->TmpRollback( &rDoc, 0 );
+        m_pHistory->SetTmpEnd( nTmpEnd );
     }
 
     SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor());
     pPam->DeleteMark();
-    pPam->GetPoint()->nNode = nNode + 1;
+    pPam->GetPoint()->nNode = m_nNode + 1;
     pPam->GetPoint()->nContent.Assign( pTextNd, 0 );
 }
 
@@ -2306,14 +2306,14 @@ RedlineFlagsInternGuard::~RedlineFlagsInternGuard()
 void SwUndoTableNumFormat::RedoImpl(::sw::UndoRedoContext & rContext)
 {
     // Could the box be changed?
-    if( !pBoxSet )
+    if( !m_pBoxSet )
         return ;
 
     SwDoc & rDoc = rContext.GetDoc();
     SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor());
 
     pPam->DeleteMark();
-    pPam->GetPoint()->nNode = nNode;
+    pPam->GetPoint()->nNode = m_nNode;
 
     SwNode * pNd = & pPam->GetPoint()->nNode.GetNode();
     SwStartNode* pSttNd = pNd->FindSttNodeByType( SwTableBoxStartNode );
@@ -2323,7 +2323,7 @@ void SwUndoTableNumFormat::RedoImpl(::sw::UndoRedoContext & rContext)
     OSL_ENSURE( pBox, "found no TableBox" );
 
     SwFrameFormat* pBoxFormat = pBox->ClaimFrameFormat();
-    if( bNewFormat || bNewFormula || bNewValue )
+    if( m_bNewFormat || m_bNewFormula || m_bNewValue )
     {
         SfxItemSet aBoxSet( rDoc.GetAttrPool(),
                                 svl::Items<RES_BOXATR_FORMAT, RES_BOXATR_VALUE>{} );
@@ -2332,16 +2332,16 @@ void SwUndoTableNumFormat::RedoImpl(::sw::UndoRedoContext & rContext)
         // text will be also formatted correctly.
         pBoxFormat->LockModify();
 
-        if( bNewFormula )
-            aBoxSet.Put( SwTableBoxFormula( aNewFormula ));
+        if( m_bNewFormula )
+            aBoxSet.Put( SwTableBoxFormula( m_aNewFormula ));
         else
             pBoxFormat->ResetFormatAttr( RES_BOXATR_FORMULA );
-        if( bNewFormat )
-            aBoxSet.Put( SwTableBoxNumFormat( nNewFormatIdx ));
+        if( m_bNewFormat )
+            aBoxSet.Put( SwTableBoxNumFormat( m_nNewFormatIdx ));
         else
             pBoxFormat->ResetFormatAttr( RES_BOXATR_FORMAT );
-        if( bNewValue )
-            aBoxSet.Put( SwTableBoxValue( fNewNum ));
+        if( m_bNewValue )
+            aBoxSet.Put( SwTableBoxValue( m_fNewNum ));
         else
             pBoxFormat->ResetFormatAttr( RES_BOXATR_VALUE );
         pBoxFormat->UnlockModify();
@@ -2352,13 +2352,13 @@ void SwUndoTableNumFormat::RedoImpl(::sw::UndoRedoContext & rContext)
         RedlineFlagsInternGuard aGuard( rDoc, RedlineFlags::NONE, RedlineFlags::Ignore );
         pBoxFormat->SetFormatAttr( aBoxSet );
     }
-    else if( css::util::NumberFormat::TEXT != static_cast<sal_Int16>(nFormatIdx) )
+    else if( css::util::NumberFormat::TEXT != static_cast<sal_Int16>(m_nFormatIdx) )
     {
         SfxItemSet aBoxSet( rDoc.GetAttrPool(),
                             svl::Items<RES_BOXATR_FORMAT, RES_BOXATR_VALUE>{} );
 
-        aBoxSet.Put( SwTableBoxNumFormat( nFormatIdx ));
-        aBoxSet.Put( SwTableBoxValue( fNum ));
+        aBoxSet.Put( SwTableBoxNumFormat( m_nFormatIdx ));
+        aBoxSet.Put( SwTableBoxValue( m_fNum ));
 
         // Resetting attributes is not enough. In addition, take care that the
         // text will be also formatted correctly.
@@ -2383,7 +2383,7 @@ void SwUndoTableNumFormat::RedoImpl(::sw::UndoRedoContext & rContext)
         pBoxFormat->ResetFormatAttr( RES_BOXATR_FORMAT, RES_BOXATR_VALUE );
     }
 
-    if( bNewFormula )
+    if( m_bNewFormula )
     {
         // No matter what was set, an update of the table is always a good idea
         SwTableFormulaUpdate aTableUpdate( &pSttNd->FindTableNode()->GetTable() );
@@ -2397,7 +2397,7 @@ void SwUndoTableNumFormat::RedoImpl(::sw::UndoRedoContext & rContext)
 
 void SwUndoTableNumFormat::SetBox( const SwTableBox& rBox )
 {
-    nNode = rBox.GetSttIdx();
+    m_nNode = rBox.GetSttIdx();
 }
 
 UndoTableCpyTable_Entry::UndoTableCpyTable_Entry( const SwTableBox& rBox )


More information about the Libreoffice-commits mailing list