sw/source/filter/ww8/ww8par.cxx | 80 -------------------------------------- sw/source/filter/ww8/ww8par.hxx | 3 - sw/source/filter/ww8/ww8par2.cxx | 2 sw/source/filter/ww8/ww8par6.cxx | 47 +++++----------------- sw/source/filter/ww8/ww8struc.hxx | 1 5 files changed, 13 insertions(+), 120 deletions(-)
New commits: commit 6e8a89b762d625adc10227402de506c7a632e073 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Thu Apr 20 13:41:47 2023 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Thu Apr 20 17:26:43 2023 +0200 sw floattable: remove no longer needed DOC import heuristics Now that IsFlySplitAllowed() is true, bNoFly and related code in can go in sw/source/filter/ww8/. Change-Id: I5c3eb4002151af3436c596ccca72d5de7ec690dd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150679 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 4782992c2986..b57678ec9495 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -2619,86 +2619,6 @@ void SwWW8ImplReader::EndSpecial() OSL_ENSURE(!m_nInTable, "unclosed table!"); } -bool SwWW8ImplReader::FloatingTableConversion(WW8PLCFx_Cp_FKP* pPap) -{ - // This is ww8 version of the code deciding if the table needs to be - // in a floating frame. - - // Note that this is just a list of heuristics till sw core can have a - // table that is floating and can span over multiple pages at the same - // time. - - // If the floating table is in a header or footer, then it won't be a - // multi-page one, so can always do the conversion. - if (m_bIsHeader || m_bIsFooter) - { - return true; - } - - bool bResult = true; - - SprmResult aRes = pPap->HasSprm(NS_sprm::TDefTable::val); - if (nullptr != aRes.pSprm) - { - bResult = false; - WW8TabBandDesc aDesc; - aDesc.ReadDef(false, aRes.pSprm, aRes.nRemainingData); - int nTextAreaWidth = m_aSectionManager.GetTextAreaWidth(); - int nTableWidth = aDesc.nCenter[aDesc.nWwCols] - aDesc.nCenter[0]; - - // It seems Word has a limit here, so that in case the table width is quite - // close to the text area width, then it won't perform a wrapping, even in - // case the content (e.g. an empty paragraph) would fit. The magic constant - // here represents this limit. - const int nMagicNumber = 469; - - // If the table is wider than the text area, then don't create a fly - // for the table: no wrapping will be performed anyway, but multi-page - // tables will be broken. - if ((nTableWidth + nMagicNumber) < nTextAreaWidth) - bResult = true; - - // If there are columns, do create a fly, as the flow of the columns - // would otherwise restrict the table. - if (!bResult && (m_aSectionManager.CurrentSectionColCount() >= 2)) - bResult = true; - } - - if (bResult) - { - WW8PLCFxSave1 aSave; - pPap->Save(aSave); - if (SearchTableEnd(pPap)) - { - // Table is considered to be imported into a fly frame and we - // know where the end of the table is. - bool bIsUnicode; - WW8_FC nFc = m_xSBase->WW8Cp2Fc(pPap->Where(), &bIsUnicode); - sal_uInt64 nPos = m_pStrm->Tell(); - m_pStrm->Seek(nFc); - sal_uInt16 nUChar = 0; - if (bIsUnicode) - m_pStrm->ReadUInt16(nUChar); - else - { - sal_uInt8 nChar = 0; - m_pStrm->ReadUChar(nChar); - nUChar = nChar; - } - m_pStrm->Seek(nPos); - if (nUChar == 0xc) - // The pap after the table starts with a page break, so - // there will be no wrapping around the float-table. - // Request no fly in this case, so the table can properly - // be a multi-page one if necessary. - bResult = false; - } - pPap->Restore(aSave); - } - - return bResult; -} - bool SwWW8ImplReader::ProcessSpecial(bool &rbReSync, WW8_CP nStartCp) { // Frame/Table/Anl diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx index dcb6c977cc16..9bbefdab98b6 100644 --- a/sw/source/filter/ww8/ww8par.hxx +++ b/sw/source/filter/ww8/ww8par.hxx @@ -1824,7 +1824,7 @@ public: // really private, but can only be done public void Read_TabRowEnd( sal_uInt16, const sal_uInt8* pData, short nLen ); void Read_TabCellEnd( sal_uInt16, const sal_uInt8* pData, short nLen ); - bool ParseTabPos(WW8_TablePos *aTabPos, WW8PLCFx_Cp_FKP* pPap); + static bool ParseTabPos(WW8_TablePos *aTabPos, WW8PLCFx_Cp_FKP* pPap); void Read_Shade( sal_uInt16, const sal_uInt8* pData, short nLen ); void Read_ANLevelNo( sal_uInt16, const sal_uInt8* pData, short nLen ); void Read_ANLevelDesc( sal_uInt16, const sal_uInt8* pData, short nLen ); @@ -1918,7 +1918,6 @@ public: // really private, but can only be done public bool SearchRowEnd(WW8PLCFx_Cp_FKP* pPap,WW8_CP &rStartCp, int nLevel) const; /// Seek to the end of the table with pPap, returns true on success. bool SearchTableEnd(WW8PLCFx_Cp_FKP* pPap) const; - bool FloatingTableConversion(WW8PLCFx_Cp_FKP* pPap); const WW8Fib& GetFib() const { return *m_xWwFib; } SwDoc& GetDoc() const { return m_rDoc; } diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx index bc15f0fc96d5..8e145ee4e90a 100644 --- a/sw/source/filter/ww8/ww8par2.cxx +++ b/sw/source/filter/ww8/ww8par2.cxx @@ -2069,7 +2069,7 @@ WW8TabDesc::WW8TabDesc(SwWW8ImplReader* pIoClass, WW8_CP nStartCp) : //Get the end of row new table positioning data WW8_CP nMyStartCp=nStartCp; if (m_pIo->SearchRowEnd(pPap, nMyStartCp, m_pIo->m_nInTable)) - if (m_pIo->ParseTabPos(&aTabPos, pPap)) + if (SwWW8ImplReader::ParseTabPos(&aTabPos, pPap)) pTabPos = &aTabPos; //Move back to this cell diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index eed7d978a939..671e25a97aa5 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -2459,22 +2459,6 @@ bool SwWW8ImplReader::IsDropCap() const return false; } -namespace -{ -bool IsFlySplitAllowed(bool bFuzzing) -{ - bool bRet = bFuzzing || - officecfg::Office::Writer::Filter::Import::DOC::ImportFloatingTableAsSplitFly::get(); - - if (!bRet) - { - bRet = getenv("SW_DISABLE_FLY_SPLIT") == nullptr; - } - - return bRet; -} -} - bool SwWW8ImplReader::StartApo(const ApoTestResults &rApo, const WW8_TablePos *pTabPos) { m_xWFlyPara = ConstructApo(rApo, pTabPos); @@ -2507,28 +2491,20 @@ bool SwWW8ImplReader::StartApo(const ApoTestResults &rApo, const WW8_TablePos *p WW8FlySet aFlySet(*this, m_xWFlyPara.get(), m_xSFlyPara.get(), false); - // Always map floating tables to split flys when fly split is allowed. - if (pTabPos && pTabPos->bNoFly && !IsFlySplitAllowed(m_bFuzzing)) + // ofz#34749 we shouldn't anchor anything into an 'extra' paragraph scheduled for + // removal at end of import, but check if that scenario is happening + m_aExtraneousParas.remove_if_present(m_pPaM->GetPointNode().GetTextNode()); + + if (pTabPos) { - m_xSFlyPara->SetFlyFormat(nullptr); + // Map a positioned table to a split fly. + aFlySet.Put(SwFormatFlySplit(true)); } - else - { - // ofz#34749 we shouldn't anchor anything into an 'extra' paragraph scheduled for - // removal at end of import, but check if that scenario is happening - m_aExtraneousParas.remove_if_present(m_pPaM->GetPointNode().GetTextNode()); - if (pTabPos && IsFlySplitAllowed(m_bFuzzing)) - { - // Map a positioned table to a split fly. - aFlySet.Put(SwFormatFlySplit(true)); - } - - m_xSFlyPara->SetFlyFormat(m_rDoc.MakeFlySection(WW8SwFlyPara::eAnchor, - m_pPaM->GetPoint(), &aFlySet)); - OSL_ENSURE(m_xSFlyPara->GetFlyFormat()->GetAnchor().GetAnchorId() == - WW8SwFlyPara::eAnchor, "Not the anchor type requested!"); - } + m_xSFlyPara->SetFlyFormat(m_rDoc.MakeFlySection(WW8SwFlyPara::eAnchor, + m_pPaM->GetPoint(), &aFlySet)); + OSL_ENSURE(m_xSFlyPara->GetFlyFormat()->GetAnchor().GetAnchorId() == + WW8SwFlyPara::eAnchor, "Not the anchor type requested!"); if (SwFlyFrameFormat* pFlyFormat = m_xSFlyPara->GetFlyFormat()) { @@ -5375,7 +5351,6 @@ bool SwWW8ImplReader::ParseTabPos(WW8_TablePos *pTabPos, WW8PLCFx_Cp_FKP* pPap) aRes = pPap->HasSprm(NS_sprm::TDyaFromTextBottom::val); if (aRes.pSprm && aRes.nRemainingData >= 2) pTabPos->nLowerMargin = SVBT16ToUInt16(aRes.pSprm); - pTabPos->bNoFly = !FloatingTableConversion(pPap); bRet = true; } return bRet; diff --git a/sw/source/filter/ww8/ww8struc.hxx b/sw/source/filter/ww8/ww8struc.hxx index d13b3744d06c..cdd1fed1da8f 100644 --- a/sw/source/filter/ww8/ww8struc.hxx +++ b/sw/source/filter/ww8/ww8struc.hxx @@ -897,7 +897,6 @@ struct WW8_TablePos sal_Int16 nLowerMargin; sal_uInt8 nTPc; sal_uInt8 nPWr; - bool bNoFly; }; struct WW8_FSPA