cui/source/dialogs/SpellDialog.cxx | 2 sc/source/ui/docshell/impex.cxx | 73 +++++++++++++++---------- sw/qa/extras/rtfexport/data/tdf104390.rtf | 6 ++ sw/qa/extras/rtfexport/data/tdf118047.rtf | 14 ++++ sw/qa/extras/rtfexport/data/tdf131234.rtf | 12 ++++ sw/qa/extras/rtfexport/rtfexport5.cxx | 47 ++++++++++++++++ sw/qa/extras/uiwriter/uiwriter3.cxx | 45 +++++++++++++++ sw/source/core/frmedt/fetab.cxx | 22 +------ sw/source/core/txtnode/fntcache.cxx | 4 + vcl/source/gdi/pdfwriter_impl.cxx | 4 - writerfilter/source/rtftok/rtfdispatchflag.cxx | 6 -- writerfilter/source/rtftok/rtfdocumentimpl.cxx | 47 +++++++++------- writerfilter/source/rtftok/rtfdocumentimpl.hxx | 3 - writerfilter/source/rtftok/rtfsprm.cxx | 12 ++++ 14 files changed, 223 insertions(+), 74 deletions(-)
New commits: commit 4d2d9cf9c3165e2460466cc75e5a8453346610c8 Author: Vasily Melenchuk <vasily.melenc...@cib.de> AuthorDate: Mon Mar 21 17:12:12 2022 +0300 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Fri Mar 25 12:59:34 2022 +0100 tdf#104390: rtf import: init default font for entire state stack If first document element is buried deep in destinations and thus deep in state stack (m_aStates) initialization of default font is very local and will be lost after closing these destinations. So let's initialize entire states stack with default font if none is provided istead of initialization just a top element. Change-Id: I966c282f43b84baece909a4c3cd359cbcd317e63 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131906 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmik...@collabora.com> (cherry picked from commit 24b5490cb0fd8de19415509fbf452874669106ad) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131864 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sw/qa/extras/rtfexport/data/tdf104390.rtf b/sw/qa/extras/rtfexport/data/tdf104390.rtf new file mode 100644 index 000000000000..842e73e19a85 --- /dev/null +++ b/sw/qa/extras/rtfexport/data/tdf104390.rtf @@ -0,0 +1,6 @@ +{\rtf1\deff0 +{\fonttbl +{\f0 Courier New;}} +\fs72 +{{{{Hello }}}{World!}} +} \ No newline at end of file diff --git a/sw/qa/extras/rtfexport/rtfexport5.cxx b/sw/qa/extras/rtfexport/rtfexport5.cxx index 36bf6c839b65..297635fce37e 100644 --- a/sw/qa/extras/rtfexport/rtfexport5.cxx +++ b/sw/qa/extras/rtfexport/rtfexport5.cxx @@ -1339,6 +1339,21 @@ DECLARE_RTFEXPORT_TEST(testTdf118047, "tdf118047.rtf") CPPUNIT_ASSERT_MESSAGE("Header is too large", 1000 > nHeight); } +DECLARE_RTFEXPORT_TEST(testTdf104390, "tdf104390.rtf") +{ + uno::Reference<text::XTextRange> xPara = getParagraph(1); + uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xPara, uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration(); + + // Check font in first run + uno::Reference<text::XTextRange> xRun(xRunEnum->nextElement(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(36.f, getProperty<float>(xRun, "CharHeight")); + CPPUNIT_ASSERT_EQUAL(OUString("Courier New"), getProperty<OUString>(xRun, "CharFontName")); + + // Ensure there is only one run + CPPUNIT_ASSERT_MESSAGE("Extra elements in paragraph", !xRunEnum->hasMoreElements()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 072430ebe15f..af4ba47158c3 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -397,16 +397,22 @@ void RTFDocumentImpl::checkFirstRun() assert(!m_bNeedSect || m_bFirstRunException); setNeedSect(true); // first call that succeeds - // set the requested default font, if there are none + // set the requested default font, if there are none for each state in stack RTFValue::Pointer_t pFont = getNestedAttribute(m_aDefaultState.getCharacterSprms(), NS_ooxml::LN_EG_RPrBase_rFonts, NS_ooxml::LN_CT_Fonts_ascii); - RTFValue::Pointer_t pCurrentFont - = getNestedAttribute(m_aStates.top().getCharacterSprms(), NS_ooxml::LN_EG_RPrBase_rFonts, - NS_ooxml::LN_CT_Fonts_ascii); - if (pFont && !pCurrentFont) - putNestedAttribute(m_aStates.top().getCharacterSprms(), NS_ooxml::LN_EG_RPrBase_rFonts, - NS_ooxml::LN_CT_Fonts_ascii, pFont); + if (!pFont) + return; + + for (size_t i = 0; i < m_aStates.size(); i++) + { + RTFValue::Pointer_t pCurrentFont + = getNestedAttribute(m_aStates[i].getCharacterSprms(), NS_ooxml::LN_EG_RPrBase_rFonts, + NS_ooxml::LN_CT_Fonts_ascii); + if (!pCurrentFont) + putNestedAttribute(m_aStates[i].getCharacterSprms(), NS_ooxml::LN_EG_RPrBase_rFonts, + NS_ooxml::LN_CT_Fonts_ascii, pFont); + } } void RTFDocumentImpl::setNeedPar(bool bNeedPar) { m_bNeedPar = bNeedPar; } commit 36ca3df126b7497969b782a4188c8f71181b6d2d Author: Vasily Melenchuk <vasily.melenc...@cib.de> AuthorDate: Mon Mar 21 13:54:28 2022 +0300 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Fri Mar 25 12:59:33 2022 +0100 tdf#118047: RTF import: better deduplication for header/footer Here are two related fixes in one patch: 1. By default current style index is 0, not -1. Due to this we can assume usage of default "Normal" style during deduplication. Seems there is no difference in case of no style mentioning in run or mentioning "Normal" one (\s0), so value -1 looks unnesesary. 2. During header/footer "substreams" processing StyleTableEntires was not reused in new domain mapper impl instance. So deduplication did not work well. 2a. To avoid copying of whole StyleTableEntries between instances it is stored as pointer in domain mapper impl. Change-Id: Id003d35554e9b43186238920d9a6373452095121 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131899 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmik...@collabora.com> (cherry picked from commit 79b5ff92b17fde902c2f9db3e806f1c77a387dff) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131862 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sw/qa/extras/rtfexport/data/tdf118047.rtf b/sw/qa/extras/rtfexport/data/tdf118047.rtf new file mode 100644 index 000000000000..258d99de9bef --- /dev/null +++ b/sw/qa/extras/rtfexport/data/tdf118047.rtf @@ -0,0 +1,14 @@ +{\rtf1\ansi + +{\stylesheet +{\fs72\sa3200 Normal;} +} + +\sectd +{ +\headerr +Header\par +} + +Text\par +} diff --git a/sw/qa/extras/rtfexport/rtfexport5.cxx b/sw/qa/extras/rtfexport/rtfexport5.cxx index b9a7321d724b..36bf6c839b65 100644 --- a/sw/qa/extras/rtfexport/rtfexport5.cxx +++ b/sw/qa/extras/rtfexport/rtfexport5.cxx @@ -1324,6 +1324,21 @@ DECLARE_RTFEXPORT_TEST(testTdf131234, "tdf131234.rtf") CPPUNIT_ASSERT_EQUAL(awt::FontSlant_NONE, getProperty<awt::FontSlant>(xRun, "CharPosture")); } +DECLARE_RTFEXPORT_TEST(testTdf118047, "tdf118047.rtf") +{ + uno::Reference<text::XTextRange> xPara = getParagraph(1); + + // Ensure that default "Normal" style properties are not applied to text: + // text remains with fontsize 12pt and no huge margin below + CPPUNIT_ASSERT_EQUAL(12.f, getProperty<float>(getRun(xPara, 1), "CharHeight")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(getParagraph(1), "ParaBottomMargin")); + + // Same for header, it should not derive props from "Normal" style + CPPUNIT_ASSERT_EQUAL(OUString("Header"), parseDump("/root/page[1]/header/txt/text()")); + sal_Int32 nHeight = parseDump("/root/page[1]/header/infos/bounds", "height").toInt32(); + CPPUNIT_ASSERT_MESSAGE("Header is too large", 1000 > nHeight); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/rtftok/rtfdispatchflag.cxx b/writerfilter/source/rtftok/rtfdispatchflag.cxx index 2acb4d59f977..83c5a0966259 100644 --- a/writerfilter/source/rtftok/rtfdispatchflag.cxx +++ b/writerfilter/source/rtftok/rtfdispatchflag.cxx @@ -520,12 +520,8 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) { m_aStates.top().getParagraphSprms().set(NS_ooxml::LN_CT_PPrBase_pStyle, new RTFValue(aName)); - m_aStates.top().setCurrentStyleIndex(0); - } - else - { - m_aStates.top().setCurrentStyleIndex(-1); } + m_aStates.top().setCurrentStyleIndex(0); } // Need to send paragraph properties again, if there will be any. m_bNeedPap = true; diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index fb331f4b265a..072430ebe15f 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -324,6 +324,8 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x m_pTokenizer = new RTFTokenizer(*this, m_pInStream.get(), m_xStatusIndicator); m_pSdrImport = new RTFSdrImport(*this, m_xDstDoc); + + m_pStyleTableEntries = std::make_shared<RTFReferenceTable::Entries_t>(); } RTFDocumentImpl::~RTFDocumentImpl() = default; @@ -363,6 +365,7 @@ void RTFDocumentImpl::resolveSubstream(std::size_t nPos, Id nId, OUString const& m_aAuthorInitials.clear(); } pImpl->m_nDefaultFontIndex = m_nDefaultFontIndex; + pImpl->m_pStyleTableEntries = m_pStyleTableEntries; pImpl->Strm().Seek(nPos); SAL_INFO("writerfilter.rtf", "substream start"); Mapper().substream(nId, pImpl); @@ -497,16 +500,16 @@ RTFDocumentImpl::getProperties(const RTFSprms& rAttributes, RTFSprms const& rSpr int nStyle = 0; if (!m_aStates.empty()) nStyle = m_aStates.top().getCurrentStyleIndex(); - auto it = m_aStyleTableEntries.find(nStyle); - if (it != m_aStyleTableEntries.end()) + auto it = m_pStyleTableEntries->find(nStyle); + if (it != m_pStyleTableEntries->end()) { // cloneAndDeduplicate() wants to know about only a single "style", so // let's merge paragraph and character style properties here. - auto itChar = m_aStyleTableEntries.end(); + auto itChar = m_pStyleTableEntries->end(); if (!m_aStates.empty()) { int nCharStyle = m_aStates.top().getCurrentCharacterStyleIndex(); - itChar = m_aStyleTableEntries.find(nCharStyle); + itChar = m_pStyleTableEntries->find(nCharStyle); } RTFSprms aStyleSprms; @@ -517,7 +520,7 @@ RTFDocumentImpl::getProperties(const RTFSprms& rAttributes, RTFSprms const& rSpr RTFReferenceProperties& rProps = *static_cast<RTFReferenceProperties*>(it->second.get()); lcl_copyFlatten(rProps, aStyleAttributes, aStyleSprms); - if (itChar != m_aStyleTableEntries.end()) + if (itChar != m_pStyleTableEntries->end()) { // Found active character style, then update aStyleSprms/Attributes. if (!nStyleType || nStyleType == NS_ooxml::LN_Value_ST_StyleType_character) @@ -1402,7 +1405,7 @@ void RTFDocumentImpl::text(OUString& rString) writerfilter::Reference<Properties>::Pointer_t const pProp( createStyleProperties()); - m_aStyleTableEntries.insert( + m_pStyleTableEntries->insert( std::make_pair(m_nCurrentStyleIndex, pProp)); } else @@ -2091,7 +2094,7 @@ writerfilter::Reference<Properties>::Pointer_t RTFDocumentImpl::createStylePrope /** 2 different representations of the styles are needed: 1) flat content, as read from the input file: - stored in m_aStyleTableEntries, used as reference input for + stored in m_pStyleTableEntries, used as reference input for deduplication both here and for hard formatting in getProperties() 2) real content, with proper override of sprms/attributes where it differs @@ -2100,7 +2103,7 @@ writerfilter::Reference<Properties>::Pointer_t RTFDocumentImpl::createStylePrope RTFReferenceTable::Entries_t RTFDocumentImpl::deduplicateStyleTable() { RTFReferenceTable::Entries_t ret; - for (auto const& it : m_aStyleTableEntries) + for (auto const& it : *m_pStyleTableEntries) { auto pStyle = it.second; ret[it.first] = pStyle; @@ -2116,8 +2119,8 @@ RTFReferenceTable::Entries_t RTFDocumentImpl::deduplicateStyleTable() if (it.first == nBasedOn) continue; - auto const itParent(m_aStyleTableEntries.find(nBasedOn)); // definition as read! - if (itParent != m_aStyleTableEntries.end()) + auto const itParent(m_pStyleTableEntries->find(nBasedOn)); // definition as read! + if (itParent != m_pStyleTableEntries->end()) { auto const pStyleType( static_cast<RTFReferenceProperties&>(*pStyle).getAttributes().find( @@ -2143,7 +2146,7 @@ RTFReferenceTable::Entries_t RTFDocumentImpl::deduplicateStyleTable() } } } - assert(ret.size() == m_aStyleTableEntries.size()); + assert(ret.size() == m_pStyleTableEntries->size()); return ret; } @@ -3668,7 +3671,7 @@ RTFParserState::RTFParserState(RTFDocumentImpl* pDocumentImpl) , m_nHour(0) , m_nMinute(0) , m_pCurrentDestinationText(nullptr) - , m_nCurrentStyleIndex(-1) + , m_nCurrentStyleIndex(0) , m_nCurrentCharacterStyleIndex(-1) , m_pCurrentBuffer(nullptr) , m_bInListpicture(false) diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx index fc5c8802b5d7..66e27a509be5 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx @@ -933,7 +933,8 @@ private: /// Raw default font index, use getFont() on it to get a real one. int m_nDefaultFontIndex; - RTFReferenceTable::Entries_t m_aStyleTableEntries; + /// To avoid copying entries between DomainMapper instances it is stored as pointer + std::shared_ptr<RTFReferenceTable::Entries_t> m_pStyleTableEntries; int m_nCurrentStyleIndex; bool m_bFormField; /// For the INCLUDEPICTURE field's argument. commit b9b0117e305486f11eb6fb87cf86a7f70d85ae19 Author: Vasily Melenchuk <vasily.melenc...@cib.de> AuthorDate: Sun Mar 20 08:48:17 2022 +0300 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Fri Mar 25 12:59:33 2022 +0100 tdf#131234: RTF import: extend default char props list There are much more character attributes should be applied wth default values if style contain them, but they were not mentioned in current run. These are obviously not a complete set yet, but most common ones are included. Change-Id: Ide52245bc98628febc2f3bd2e25166f0dcdf35cc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131853 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmik...@collabora.com> (cherry picked from commit 494020efe6d29bc319c3abcd3245425e394674ec) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131857 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sw/qa/extras/rtfexport/data/tdf131234.rtf b/sw/qa/extras/rtfexport/data/tdf131234.rtf new file mode 100644 index 000000000000..976987bee113 --- /dev/null +++ b/sw/qa/extras/rtfexport/data/tdf131234.rtf @@ -0,0 +1,12 @@ +{\rtf1\ansi +{\fonttbl +{\f3 Tahoma;} +} +{\colortbl;\red123\green0\blue0;\red0\green0\blue255;} +{\stylesheet +{\s1\f3\fs64\cf2\b1\i1\ul1 Test112;} +} + +\s1 Hello\par + +} diff --git a/sw/qa/extras/rtfexport/rtfexport5.cxx b/sw/qa/extras/rtfexport/rtfexport5.cxx index 28daa538f677..b9a7321d724b 100644 --- a/sw/qa/extras/rtfexport/rtfexport5.cxx +++ b/sw/qa/extras/rtfexport/rtfexport5.cxx @@ -35,6 +35,9 @@ #include <com/sun/star/text/XTextDocument.hpp> #include <com/sun/star/beans/XPropertyState.hpp> #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> +#include <com/sun/star/awt/FontWeight.hpp> +#include <com/sun/star/awt/FontSlant.hpp> +#include <com/sun/star/awt/FontUnderline.hpp> #include <rtl/ustring.hxx> #include <tools/UnitConversion.hxx> @@ -1307,6 +1310,20 @@ DECLARE_RTFEXPORT_TEST(testTdf144437, "tdf144437.odt") CPPUNIT_ASSERT_MESSAGE("Bookmark start & end are wrong", nBmkEndPos > nBmkStartPos); } +DECLARE_RTFEXPORT_TEST(testTdf131234, "tdf131234.rtf") +{ + uno::Reference<text::XTextRange> xRun = getRun(getParagraph(1), 1, OUString(u"Hello")); + + // Ensure that text has default font attrs in spite of style referenced + // E.g. 12pt, Times New Roman, black, no bold, no italic, no underline + CPPUNIT_ASSERT_EQUAL(12.f, getProperty<float>(xRun, "CharHeight")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xRun, "CharColor")); + CPPUNIT_ASSERT_EQUAL(OUString("Times New Roman"), getProperty<OUString>(xRun, "CharFontName")); + CPPUNIT_ASSERT_EQUAL(awt::FontWeight::NORMAL, getProperty<float>(xRun, "CharWeight")); + CPPUNIT_ASSERT_EQUAL(awt::FontUnderline::NONE, getProperty<sal_Int16>(xRun, "CharUnderline")); + CPPUNIT_ASSERT_EQUAL(awt::FontSlant_NONE, getProperty<awt::FontSlant>(xRun, "CharPosture")); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/rtftok/rtfsprm.cxx b/writerfilter/source/rtftok/rtfsprm.cxx index 8c54fe95e345..04df49bc0287 100644 --- a/writerfilter/source/rtftok/rtfsprm.cxx +++ b/writerfilter/source/rtftok/rtfsprm.cxx @@ -163,8 +163,20 @@ static RTFValue::Pointer_t getDefaultSPRM(Id const id, Id nStyleType) { switch (id) { + case NS_ooxml::LN_EG_RPrBase_szCs: + case NS_ooxml::LN_EG_RPrBase_sz: + return new RTFValue(24); + case NS_ooxml::LN_CT_Color_val: + return new RTFValue(0); case NS_ooxml::LN_EG_RPrBase_b: + case NS_ooxml::LN_EG_RPrBase_i: return new RTFValue(0); + case NS_ooxml::LN_CT_Underline_val: + return new RTFValue(NS_ooxml::LN_Value_ST_Underline_none); + case NS_ooxml::LN_CT_Fonts_ascii: + case NS_ooxml::LN_CT_Fonts_eastAsia: + case NS_ooxml::LN_CT_Fonts_cs: + return new RTFValue("Times New Roman"); default: break; } commit 81087356b96c893358fa61d45945a575e44716b8 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Thu Mar 17 08:26:59 2022 +0100 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Fri Mar 25 12:59:33 2022 +0100 Call corresponding base class method in SpellDialog::Deactivate At a quick glance, the fact that `SpellDialog::Deactivate` previously did the same as `SpellDialog::Activate` looks like a copy-paste mistake; both were added in commit 5261417cbb3051b812164838d19c0f748573df45 Date: Fri Jun 14 21:56:44 2019 +0100 weld SpellDialog Change-Id: Ib06d19e46470141d5bfcfc7e790160c1879b6a00 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131598 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/cui/source/dialogs/SpellDialog.cxx b/cui/source/dialogs/SpellDialog.cxx index dae7b92c9155..329b20d54e29 100644 --- a/cui/source/dialogs/SpellDialog.cxx +++ b/cui/source/dialogs/SpellDialog.cxx @@ -945,7 +945,7 @@ void SpellDialog::Activate() void SpellDialog::Deactivate() { - SfxModelessDialogController::Activate(); + SfxModelessDialogController::Deactivate(); ToplevelFocusChanged(); } commit a54185bbdd4944dd903962d8185f411bad3b53d9 Author: László Németh <nem...@numbertext.org> AuthorDate: Thu Mar 17 11:14:15 2022 +0100 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Fri Mar 25 12:58:50 2022 +0100 tdf#147347 sw: hide deleted table at deletion in Hide Changes Last deleted row of a table frame was visible in Hide Changes mode, if it is deleted in Hide Changes mode. Fix also missing immediate update of the table layout during deleting only rows in the table. Follow-up to commit a74c51025fa4519caaf461492e4ed8e68bd34885 "tdf#146962 sw: hide deleted row at deletion in Hide Changes" Change-Id: Ic0bf09ac68dd336bd53e84e58f52ebe88ca56238 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131701 Tested-by: Jenkins Reviewed-by: László Németh <nem...@numbertext.org> (cherry picked from commit 794fd10af7361d5a64a0f8bfbe5c8b5f308617a5) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131599 diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx index a7db089432e0..b8cb857043b2 100644 --- a/sw/qa/extras/uiwriter/uiwriter3.cxx +++ b/sw/qa/extras/uiwriter/uiwriter3.cxx @@ -1989,6 +1989,51 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf146962) assertXPath(pXmlDoc, "/root/page[1]/body/tab/row", 1); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf147347) +{ + // load a 2-row table, set Hide Changes mode and delete the table with change tracking + SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf116789.fodt"); + CPPUNIT_ASSERT(pDoc); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + CPPUNIT_ASSERT(pWrtShell); + + // enable redlining + dispatchCommand(mxComponent, ".uno:TrackChanges", {}); + CPPUNIT_ASSERT_MESSAGE("redlining should be on", + pDoc->getIDocumentRedlineAccess().IsRedlineOn()); + // hide changes + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + CPPUNIT_ASSERT(pWrtShell->GetLayout()->IsHideRedlines()); + + dispatchCommand(mxComponent, ".uno:DeleteTable", {}); + + // Without the fix in place, the deleted row would be visible + + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + // This was 1 + assertXPath(pXmlDoc, "/root/page[1]/body/tab/row", 0); + + // check it in Show Changes mode + + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + CPPUNIT_ASSERT(!pWrtShell->GetLayout()->IsHideRedlines()); + + discardDumpedLayout(); + pXmlDoc = parseLayoutDump(); + // 2 rows are visible now + assertXPath(pXmlDoc, "/root/page[1]/body/tab/row", 2); + + // check it in Hide Changes mode again + + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + CPPUNIT_ASSERT(pWrtShell->GetLayout()->IsHideRedlines()); + + discardDumpedLayout(); + pXmlDoc = parseLayoutDump(); + // no visible row again + assertXPath(pXmlDoc, "/root/page[1]/body/tab/row", 0); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf135014) { createSwDoc(); diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx index 7bb2ff5edc68..ecb7cfc39f2a 100644 --- a/sw/source/core/frmedt/fetab.cxx +++ b/sw/source/core/frmedt/fetab.cxx @@ -480,26 +480,14 @@ bool SwFEShell::DeleteRow(bool bCompleteTable) pPam->DeleteMark(); } - // remove row frames in Hide Changes mode + // remove row frames in Hide Changes mode (and table frames, if needed) if ( bRecordAndHideChanges ) { - for (auto & rpFndLine : aFndBox.GetLines()) + pTableNd->DelFrames(); + if ( !pTableNd->GetTable().IsDeleted() ) { - SwTableLine* pTmpLine = rpFndLine->GetLine(); - SwIterator<SwRowFrame,SwFormat> aIt( *pTmpLine->GetFrameFormat() ); - for( SwRowFrame* pRowFrame = aIt.First(); pRowFrame; pRowFrame = aIt.Next() ) - { - auto pTabFrame = pRowFrame->GetUpper(); - // FIXME remove table frame instead of keeping the last row frame - if ( pTabFrame->IsTabFrame() && pTabFrame->Lower() == pTabFrame->GetLastLower() ) - break; - - if( pRowFrame->GetTabLine() == pTmpLine ) - { - pRowFrame->RemoveFromLayout(); - SwFrame::DestroyFrame(pRowFrame); - } - } + SwNodeIndex aTableIdx( *pTableNd->EndOfSectionNode(), 1 ); + pTableNd->MakeOwnFrames(&aTableIdx); } EndAllActionAndCall(); commit c958ff4da3fc809b588b36ab11231e2257ebdb00 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Thu Mar 17 16:24:16 2022 +0000 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Fri Mar 25 12:58:50 2022 +0100 Resolves: tdf#148053 fix a crash in out of range dx array also seen with tdf#124116 Change-Id: I211c5b9d58ee5857c8286b2009e4159b35a9e047 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131602 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx index 6ceaeaf99206..64da82258a83 100644 --- a/sw/source/core/txtnode/fntcache.cxx +++ b/sw/source/core/txtnode/fntcache.cxx @@ -2189,6 +2189,10 @@ TextFrameIndex SwFntObj::GetModelPositionForViewPoint(SwDrawTextInfo &rInf) if ( nIdx <= nLastIdx ) break; + // the next character might be outside the layout range (e.g tdf124116-1.odt) + if (nIdx > nEnd) + nIdx = nEnd; + nLeft = nRight; nRight = aKernArray[sal_Int32(nIdx - rInf.GetIdx()) - 1] + nKernSum + nSpaceSum; commit e4c6cc21754f8275d3f84e933a8018d41426971c Author: Eike Rathke <er...@redhat.com> AuthorDate: Thu Mar 17 22:44:26 2022 +0100 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Fri Mar 25 12:58:50 2022 +0100 Resolves: tdf#148054 Advance offset for all columns, tdf#104927 regression Regression from commit 621c189173b35ac7f5ce4c578f57045479c63ab6 CommitDate: Sat Jan 9 05:13:55 2021 +0100 tdf#104927 consider character width for CSV import that for fixed width introduced a visual count of character widths for CJK IVS characters but did not advance the character offset for skipped hidden columns. Instead of having to ask bDetermineRange three times in the loop, split off an extra loop for bDetermineRange, advancing the offset then is straight forward and just only non-skipped columns are extracted and written to document. Change-Id: Ib6ab6b68c5fc0f6ff854d629d75742c39ed6ddf5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131722 Reviewed-by: Eike Rathke <er...@redhat.com> Tested-by: Jenkins (cherry picked from commit 6b768542ddd52573bbdb0e7b5b85ce5a9dd4551d) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131605 Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx index f9d17f6898af..f98847bd4e18 100644 --- a/sc/source/ui/docshell/impex.cxx +++ b/sc/source/ui/docshell/impex.cxx @@ -1619,40 +1619,55 @@ bool ScImportExport::ExtText2Doc( SvStream& rStrm ) bool bMultiLine = false; if ( bFixed ) // Fixed line length { - sal_Int32 nStartIdx = 0; - // Yes, the check is nCol<=rDoc.MaxCol()+1, +1 because it is only an - // overflow if there is really data following to be put behind - // the last column, which doesn't happen if info is - // SC_COL_SKIP. - for ( i=0; i<nInfoCount && nCol <= rDoc.MaxCol()+1; i++ ) + if (bDetermineRange) { - sal_uInt8 nFmt = pColFormat[i]; - if (nFmt != SC_COL_SKIP) // otherwise don't increment nCol either + // Yes, the check is nCol<=rDoc.MaxCol()+1, +1 because it + // is only an overflow if there is really data following to + // be put behind the last column, which doesn't happen if + // info is SC_COL_SKIP. + for (i=0; i < nInfoCount && nCol <= rDoc.MaxCol()+1; ++i) { - if (nCol > rDoc.MaxCol()) - bOverflowCol = true; // display warning on import - else if (!bDetermineRange) + const sal_uInt8 nFmt = pColFormat[i]; + if (nFmt != SC_COL_SKIP) // otherwise don't increment nCol either + { + if (nCol > rDoc.MaxCol()) + bOverflowCol = true; // display warning on import + ++nCol; + } + } + } + else + { + sal_Int32 nStartIdx = 0; + // Same maxcol+1 check reason as above. + for (i=0; i < nInfoCount && nCol <= rDoc.MaxCol()+1; ++i) + { + sal_Int32 nNextIdx = nStartIdx; + if (i + 1 < nInfoCount) + CountVisualWidth( aLine, nNextIdx, pColStart[i+1] - pColStart[i] ); + else + nNextIdx = nLineLen; + sal_uInt8 nFmt = pColFormat[i]; + if (nFmt != SC_COL_SKIP) // otherwise don't increment nCol either { - sal_Int32 nNextIdx = nStartIdx; - if ( i + 1 < nInfoCount ) - CountVisualWidth( aLine, nNextIdx, pColStart[i+1] - pColStart[i] ); + if (nCol > rDoc.MaxCol()) + bOverflowCol = true; // display warning on import else - nNextIdx = nLineLen; - - bool bIsQuoted = false; - aCell = lcl_GetFixed( aLine, nStartIdx, nNextIdx, bIsQuoted, bOverflowCell ); - if (bIsQuoted && bQuotedAsText) - nFmt = SC_COL_TEXT; - - bMultiLine |= lcl_PutString( - aDocImport, !mbOverwriting, nCol, nRow, nTab, aCell, nFmt, - &aNumFormatter, bDetectNumFormat, bEvaluateFormulas, bSkipEmptyCells, - aTransliteration, aCalendar, - pEnglishTransliteration.get(), pEnglishCalendar.get()); - - nStartIdx = nNextIdx; + { + bool bIsQuoted = false; + aCell = lcl_GetFixed( aLine, nStartIdx, nNextIdx, bIsQuoted, bOverflowCell ); + if (bIsQuoted && bQuotedAsText) + nFmt = SC_COL_TEXT; + + bMultiLine |= lcl_PutString( + aDocImport, !mbOverwriting, nCol, nRow, nTab, aCell, nFmt, + &aNumFormatter, bDetectNumFormat, bEvaluateFormulas, bSkipEmptyCells, + aTransliteration, aCalendar, + pEnglishTransliteration.get(), pEnglishCalendar.get()); + } + ++nCol; } - ++nCol; + nStartIdx = nNextIdx; } } } commit 1ff3436c5c6eed74c32c2d4a3db4bd016f4a42d2 Author: Lemures Lemniscati <lemures.lemnisc...@gmail.com> AuthorDate: Thu Mar 17 18:44:39 2022 +0100 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Fri Mar 25 12:58:50 2022 +0100 tdf#148033: Loss of precision in /MediaBox (PDFWriterImpl::emitCatalog()) License statement provided here: https://bugs.documentfoundation.org/show_bug.cgi?id=148033#c4 Change-Id: I93333a17d4a6a266fc25a92abf50c22cb01a2b1d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131716 (cherry picked from commit fb48a6408a515057a03c485bf00df5c34706595b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131603 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index a3ad137230fd..eea47fc48fe3 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -4539,8 +4539,8 @@ bool PDFWriterImpl::emitCatalog() aLine.append( getResourceDictObj() ); aLine.append( " 0 R\n" ); - sal_Int32 nMediaBoxWidth = 0; - sal_Int32 nMediaBoxHeight = 0; + double nMediaBoxWidth = 0; + double nMediaBoxHeight = 0; sal_Int32 nUserUnit = 1; if( m_aPages.empty() ) // sanity check, this should not happen {