sw/source/core/table/swtable.cxx                  |   28 ++++++++++++++++------
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   18 --------------
 2 files changed, 21 insertions(+), 25 deletions(-)

New commits:
commit 498d2b82187ec3ff58f076e0d15741e64c0505ba
Author:     Balazs Santha <[email protected]>
AuthorDate: Thu Jul 29 15:00:54 2021 +0200
Commit:     László Németh <[email protected]>
CommitDate: Thu Aug 12 10:46:23 2021 +0200

    tdf#131546 DOCX import: fix performance regression at tables
    
    Commit 2ab481b038b62b1ff576ac4d49d03c1798cd7f84 "tdf#90069 DOCX:
    fix character style of new table rows" caused ~20% slowing down
    in loading time of documents with huge tables, related to the
    extra processing of the redundant w:rPr of table paragraph runs.
    (In DOCX tables, MSO exports the run properties into the run and
    paragraph sections too, probably because of compatibility or
    usability reasons.)
    
    Theoretically in this case, the run properties which are under the
    run section win. On the other hand, because LO copies the props
    which are applied on paragraph level, and only them, when copying
    a row (e.g. upon inserting a new one), it was needed to apply the
    mentioned run props not only as direct character formatting, but
    as a direct paragraph formatting too. This way, the support of
    copying of rows are solved. Unfortunately, this "double" applying
    was done for every single paragraph, which quite slowed down the
    opening time. This patch gives a workaround, which completely removes
    this double applying functionality in the writerfilter by reverting
    commit 2ab481b038b62b1ff576ac4d49d03c1798cd7f84 (except its unit test),
    and copy the mentioned run properties into paragraph level, when its
    needed: upon inserting a new row before/after. This way we spare a lot
    of cycles, as most of the original applies had no real use whatsoever.
    
    Change-Id: Ic24d0d1830e9ec43323e5e213d6481ec28e9abe3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118985
    Tested-by: László Németh <[email protected]>
    Reviewed-by: László Németh <[email protected]>

diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index c17d6882b019..5f633ef65546 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -141,13 +141,28 @@ void InsTableBox( SwDoc& rDoc, SwTableNode* pTableNd,
 
     if( pCNd->IsTextNode() )
     {
-        if( pBox->GetSaveNumFormatColor() && pCNd->GetpSwAttrSet() )
+        if( pCNd->GetpSwAttrSet() )
         {
             SwAttrSet aAttrSet( *pCNd->GetpSwAttrSet() );
-            if( pBox->GetSaveUserColor() )
-                aAttrSet.Put( SvxColorItem( *pBox->GetSaveUserColor(), 
RES_CHRATR_COLOR ));
-            else
-                aAttrSet.ClearItem( RES_CHRATR_COLOR );
+            SwTextNode* pTNd = static_cast<SwTextNode*>(pCNd);
+            SwpHints * pSwpHints = pTNd->GetpSwpHints();
+            if(pSwpHints && pSwpHints->Count()!=0)
+            {
+                SwTextAttr* textAttr = pSwpHints->Get(pSwpHints->Count()-1);
+                if(textAttr->Which() == RES_TXTATR_AUTOFMT )
+                {
+                    SwFormatAutoFormat& format = 
static_cast<SwFormatAutoFormat&>(textAttr->GetAttr());
+                    const std::shared_ptr<SfxItemSet>& handle = 
format.GetStyleHandle();
+                    aAttrSet.Put(*handle);
+                }
+            }
+            if( pBox->GetSaveNumFormatColor() )
+            {
+                if( pBox->GetSaveUserColor() )
+                    aAttrSet.Put( SvxColorItem( *pBox->GetSaveUserColor(), 
RES_CHRATR_COLOR ));
+                else
+                    aAttrSet.ClearItem( RES_CHRATR_COLOR );
+            }
             rDoc.GetNodes().InsBoxen( pTableNd, pLine, pBoxFrameFormat,
                                     
static_cast<SwTextNode*>(pCNd)->GetTextColl(),
                                     &aAttrSet, nInsPos, nCnt );
@@ -155,8 +170,7 @@ void InsTableBox( SwDoc& rDoc, SwTableNode* pTableNd,
         else
             rDoc.GetNodes().InsBoxen( pTableNd, pLine, pBoxFrameFormat,
                                     
static_cast<SwTextNode*>(pCNd)->GetTextColl(),
-                                    pCNd->GetpSwAttrSet(),
-                                    nInsPos, nCnt );
+                                    pCNd->GetpSwAttrSet(), nInsPos, nCnt );
     }
     else
         rDoc.GetNodes().InsBoxen( pTableNd, pLine, pBoxFrameFormat,
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 1249d45c82dd..fc1fbee7440f 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -2201,24 +2201,6 @@ void DomainMapper_Impl::finishParagraph( const 
PropertyMapPtr& pPropertyMap, con
                 // fix table paragraph properties
                 if ( xTextRange.is() && xParaProps && m_nTableDepth > 0 )
                 {
-                    uno::Sequence< beans::PropertyValue > aParaProps = 
pParaContext->GetPropertyValues(false);
-                    uno::Reference<text::XTextCursor> xCur =  
xTextRange->getText()->createTextCursorByRange(xTextRange);
-                    uno::Reference< beans::XPropertyState > xRunProperties( 
xCur, uno::UNO_QUERY_THROW );
-                    // tdf#90069 in tables, apply paragraph level character 
style also on
-                    // paragraph level to support its copy during insertion of 
new table rows
-                    for( const auto& rParaProp : std::as_const(aParaProps) )
-                    {
-                        if ( rParaProp.Name.startsWith("Char") && 
rParaProp.Name != "CharStyleName" && rParaProp.Name != "CharInteropGrabBag" &&
-                            // all text portions contain the same value, so 
next setPropertyValue() won't overwrite part of them
-                            xRunProperties->getPropertyState(rParaProp.Name) 
== css::beans::PropertyState_DIRECT_VALUE )
-                        {
-                            uno::Reference<beans::XPropertySet> 
xRunPropertySet(xCur, uno::UNO_QUERY);
-                            xParaProps->setPropertyValue( rParaProp.Name, 
xRunPropertySet->getPropertyValue(rParaProp.Name) );
-                            // remember this for table style handling
-                            
getTableManager().getCurrentParagraphs()->back().m_aParaOverrideApplied.insert(rParaProp.Name);
-                        }
-                    }
-
                     // tdf#128959 table paragraphs haven't got window and 
orphan controls
                     uno::Any aAny = uno::makeAny(static_cast<sal_Int8>(0));
                     xParaProps->setPropertyValue("ParaOrphans", aAny);

Reply via email to