include/vcl/toolkit/dialog.hxx | 2 + sw/qa/extras/tiledrendering/data/estonian.odt |binary sw/qa/extras/tiledrendering/tiledrendering.cxx | 26 +++++++++++++++++++++++++ sw/source/filter/html/htmlatr.cxx | 9 +++++--- sw/source/filter/html/wrthtml.cxx | 15 +++++++++----- sw/source/uibase/dochdl/swdtflvr.cxx | 2 - vcl/source/window/dialog.cxx | 13 +++++++++++- 7 files changed, 57 insertions(+), 10 deletions(-)
New commits: commit a0f29dc3e20a9f1682dab43ea2994e281272a10a Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Thu Dec 9 09:41:50 2021 +0100 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Thu Dec 30 09:02:09 2021 +0100 jsdialog: send info about initial focus in dialog Change-Id: I9daef497cb083e863d45a2acfd7eee3ee92bdc38 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126565 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Mert Tumer <mert.tu...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127682 Tested-by: Jenkins Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> diff --git a/include/vcl/toolkit/dialog.hxx b/include/vcl/toolkit/dialog.hxx index cec7ddbe67b3..31326106cbd5 100644 --- a/include/vcl/toolkit/dialog.hxx +++ b/include/vcl/toolkit/dialog.hxx @@ -131,6 +131,8 @@ private: bool ImplStartExecute(); static void ImplEndExecuteModal(); void ImplSetModalInputMode(bool bModal); + + vcl::Window* GetFirstControlForFocus(); public: /// Commence execution of a modal dialog, disposes owner on failure diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index 842c17dfcfbe..d0cd1cde95f2 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -1286,7 +1286,7 @@ void Dialog::ImplSetModalInputMode( bool bModal ) } } -void Dialog::GrabFocusToFirstControl() +vcl::Window* Dialog::GetFirstControlForFocus() { vcl::Window* pFocusControl = nullptr; vcl::Window* pFirstOverlapWindow = ImplGetFirstOverlapWindow(); @@ -1310,6 +1310,13 @@ void Dialog::GrabFocusToFirstControl() { pFocusControl = ImplGetDlgWindow( 0, GetDlgWindowType::First ); } + + return pFocusControl; +} + +void Dialog::GrabFocusToFirstControl() +{ + vcl::Window* pFocusControl = GetFirstControlForFocus(); if ( pFocusControl ) pFocusControl->ImplControlFocus( GetFocusFlags::Init ); } @@ -1685,6 +1692,10 @@ void Dialog::DumpAsPropertyTree(tools::JsonWriter& rJsonWriter) rJsonWriter.put("response", rResponse.second); } } + + vcl::Window* pFocusControl = GetFirstControlForFocus(); + if (pFocusControl) + rJsonWriter.put("init_focus_id", pFocusControl->get_id()); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 4dab08d7dd70d87aa737248442a3c9fe1a68cc2c Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Fri Nov 19 09:51:36 2021 +0100 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Thu Dec 30 09:01:59 2021 +0100 lok: don't limit line length in HTMLWriter Problem: https://github.com/CollaboraOnline/online/issues/3645 Test case: 1. Open Collabora Online and paste "Alphabet" section from wikipedia article: https://en.wikipedia.org/wiki/Estonian_language#Alphabet 2. Select last two sentences (starting from "The letter") 3. Open Insert -> Hyperlink dialog Result: notice that some spaces was removed/converted into new line Expected: Text field should contain original text Hyperlink dialog uses current selection which is get as HTML from the core. In the SwHTMLWriter there is a parameter defining how long line should be and it replaces ' ' space into '\n' new line when limit is reached. This patch turns off that feature but only for getting html for current selection in LOK case. For now don't remove new line at the beginning as cypress has to be fixed first. Added FIXME in the code. Change-Id: I03b540b0b2d639a08774ecc4fc75abb7b3f0b7a3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125482 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Andras Timar <andras.ti...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127680 Tested-by: Jenkins Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> diff --git a/sw/qa/extras/tiledrendering/data/estonian.odt b/sw/qa/extras/tiledrendering/data/estonian.odt new file mode 100644 index 000000000000..0d1fedd6babb Binary files /dev/null and b/sw/qa/extras/tiledrendering/data/estonian.odt differ diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index b8f3430e3269..1f007146809b 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -87,6 +87,7 @@ public: void testPostMouseEvent(); void testSetTextSelection(); void testGetTextSelection(); + void testGetTextSelectionLineLimit(); void testSetGraphicSelection(); void testResetSelection(); void testInsertShape(); @@ -171,6 +172,7 @@ public: CPPUNIT_TEST(testPostMouseEvent); CPPUNIT_TEST(testSetTextSelection); CPPUNIT_TEST(testGetTextSelection); + CPPUNIT_TEST(testGetTextSelectionLineLimit); CPPUNIT_TEST(testSetGraphicSelection); CPPUNIT_TEST(testResetSelection); CPPUNIT_TEST(testInsertShape); @@ -555,6 +557,30 @@ void SwTiledRenderingTest::testGetTextSelection() CPPUNIT_ASSERT_EQUAL(OString("Shape"), apitest::helper::transferable::getTextSelection(pXTextDocument->getSelection(), "text/plain;charset=utf-8")); } +void SwTiledRenderingTest::testGetTextSelectionLineLimit() +{ + static OStringLiteral sOriginalText(u8"Estonian employs the Latin script as the basis for its alphabet, which adds the letters ä, ö, ü, and õ, plus the later additions š and ž. The letters c, q, w, x and y are limited to proper names of foreign origin, and f, z, š, and ž appear in loanwords and foreign names only. Ö and Ü are pronounced similarly to their equivalents in Swedish and German. Unlike in standard German but like Swedish (when followed by 'r') and Finnish, Ä is pronounced [æ], as in English mat. The vowels Ä, Ö and Ü are clearly separate phonemes and inherent in Estonian, although the letter shapes come from German. The letter õ denotes /ɤ/, unrounded /o/, or a close-mid back unrounded vowel. It is almost identical to the Bulgarian ъ /ɤ̞/ and the Vietnamese ơ, and is also used to transcribe the Russian ы."); + static OStringLiteral sExpectedHtml(u8"Estonian employs the <a href=\"https://en.wikipedia.org/wiki/Latin_script\">Latin script</a> as the basis for <a href=\"https://en.wikipedia.org/wiki/Estonian_alphabet\">its alphabet</a>, which adds the letters <a href=\"https://en.wikipedia.org/wiki/%C3%84\"><i>ä</i></a>, <a href=\"https://en.wikipedia.org/wiki/%C3%96\"><i>ö</i></a>, <a href=\"https://en.wikipedia.org/wiki/%C3%9C\"><i>ü</i></a>, and <a href=\"https://en.wikipedia.org/wiki/%C3%95\"><i>õ</i></a>, plus the later additions <a href=\"https://en.wikipedia.org/wiki/%C5%A0\"><i>š</i></a> and <a href=\"https://en.wikipedia.org/wiki/%C5%BD\"><i>ž</i></a>. The letters <i>c</i>, <i>q</i>, <i>w</i>, <i>x</i> and <i>y</i> are limited to <a href=\"https://en.wikipedia.org/wiki/Proper_names\">proper names</a> of foreign origin, and <i>f</i>, <i>z</i>, <i>š</i>, and <i>ž</i> appear in loanwords and foreign names only. <i>Ö</i> and <i>Ü</i> are pronounced similarly to their equiva lents in Swedish and German. Unlike in standard German but like Swedish (when followed by 'r') and Finnish, <i>Ä</i> is pronounced [æ], as in English <i>mat</i>. The vowels Ä, Ö and Ü are clearly separate <a href=\"https://en.wikipedia.org/wiki/Phonemes\">phonemes</a> and inherent in Estonian, although the letter shapes come from German. The letter <a href=\"https://en.wikipedia.org/wiki/%C3%95\"><i>õ</i></a> denotes /ɤ/, unrounded /o/, or a <a href=\"https://en.wikipedia.org/wiki/Close-mid_back_unrounded_vowel\">close-mid back unrounded vowel</a>. It is almost identical to the <a href=\"https://en.wikipedia.org/wiki/Bulgarian_language\">Bulgarian</a> <a href=\"https://en.wikipedia.org/wiki/%D0%AA\">ъ</a> /ɤ̞/ and the <a href=\"https://en.wikipedia.org/wiki/Vietnamese_language\">Vietnamese</a> <a href=\"https://en.wikipedia.org/wiki/%C6%A0\">ơ</a>, and is also used to transcribe the Russian <a href=\"https://en.wikipedia.org/wiki/%D0%AB\">ы</a>."); + + SwXTextDocument* pXTextDocument = createDoc("estonian.odt"); + + SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell(); + // Move the cursor into the first word. + pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 2, /*bBasicCall=*/false); + // Create a selection. + pWrtShell->SelAll(); + + OString sPlainText = apitest::helper::transferable::getTextSelection(pXTextDocument->getSelection(), "text/plain;charset=utf-8"); + + CPPUNIT_ASSERT_EQUAL(OString(sOriginalText), sPlainText.trim()); + + OString sHtmlText = apitest::helper::transferable::getTextSelection(pXTextDocument->getSelection(), "text/html"); + + int nStart = sHtmlText.indexOf(u8"Estonian"); + + CPPUNIT_ASSERT(sHtmlText.match(sExpectedHtml, nStart)); +} + void SwTiledRenderingTest::testSetGraphicSelection() { SwXTextDocument* pXTextDocument = createDoc("shape.fodt"); diff --git a/sw/source/filter/html/htmlatr.cxx b/sw/source/filter/html/htmlatr.cxx index 856148d9e115..457e8483ec37 100644 --- a/sw/source/filter/html/htmlatr.cxx +++ b/sw/source/filter/html/htmlatr.cxx @@ -2221,8 +2221,10 @@ Writer& OutHTML_SwTextNode( Writer& rWrt, const SwContentNode& rNode ) rHTMLWrt.OutBookmarks(); // now it's a good opportunity again for an LF - if it is still allowed + // FIXME: for LOK case we set rHTMLWrt.m_nWishLineLen as -1, for now keep old flow + // when LOK side will be fixed - don't insert new line at the beginning if( rHTMLWrt.m_bLFPossible && - rHTMLWrt.GetLineLen() >= rHTMLWrt.m_nWishLineLen ) + rHTMLWrt.GetLineLen() >= (rHTMLWrt.m_nWishLineLen >= 0 ? rHTMLWrt.m_nWishLineLen : 70 ) ) { rHTMLWrt.OutNewLine(); } @@ -2459,8 +2461,9 @@ Writer& OutHTML_SwTextNode( Writer& rWrt, const SwContentNode& rNode ) nWordLen = nEnd; nWordLen -= nStrPos; - if( nLineLen >= rHTMLWrt.m_nWishLineLen || - (nLineLen+nWordLen) >= rHTMLWrt.m_nWishLineLen ) + if( rHTMLWrt.m_nWishLineLen >= 0 && + (nLineLen >= rHTMLWrt.m_nWishLineLen || + (nLineLen+nWordLen) >= rHTMLWrt.m_nWishLineLen ) ) { HTMLOutFuncs::FlushToAscii( rWrt.Strm(), aContext ); rHTMLWrt.OutNewLine(); diff --git a/sw/source/filter/html/wrthtml.cxx b/sw/source/filter/html/wrthtml.cxx index df4cef472ca2..0d6aa170c0ad 100644 --- a/sw/source/filter/html/wrthtml.cxx +++ b/sw/source/filter/html/wrthtml.cxx @@ -114,7 +114,7 @@ SwHTMLWriter::SwHTMLWriter( const OUString& rBaseURL, const OUString& rFilterOpt , m_nDfltTopMargin(0) , m_nDfltBottomMargin(0) , m_nIndentLvl(0) - , m_nWishLineLen(0) + , m_nWishLineLen(70) , m_nDefListLvl(0) , m_nDefListMargin(0) , m_nHeaderFooterSpace(0) @@ -218,19 +218,25 @@ void SwHTMLWriter::SetupFilterOptions(SfxMedium& rMedium) void SwHTMLWriter::SetupFilterOptions(const OUString& rFilterOptions) { - if (rFilterOptions == "SkipImages") + if (rFilterOptions.indexOf("SkipImages") >= 0) { mbSkipImages = true; } - else if (rFilterOptions == "SkipHeaderFooter") + else if (rFilterOptions.indexOf("SkipHeaderFooter") >= 0) { mbSkipHeaderFooter = true; } - else if (rFilterOptions == "EmbedImages") + else if (rFilterOptions.indexOf("EmbedImages") >= 0) { mbEmbedImages = true; } + // this option can be "on" together with any of above + if (rFilterOptions.indexOf("NoLineLimit") >= 0) + { + m_nWishLineLen = -1; + } + const uno::Sequence<OUString> aOptionSeq = comphelper::string::convertCommaSeparated(rFilterOptions); static const OUStringLiteral aXhtmlNsKey(u"xhtmlns="); for (const auto& rOption : aOptionSeq) @@ -369,7 +375,6 @@ ErrCode SwHTMLWriter::WriteStream() m_bFirstCSS1Property = m_bFirstCSS1Rule = false; m_bCSS1IgnoreFirstPageDesc = false; m_nIndentLvl = 0; - m_nWishLineLen = 70; m_nLastLFPos = 0; m_nDefListLvl = 0; m_nDefListMargin = ((m_xTemplate.is() && !m_bCfgOutStyles) ? m_xTemplate.get() : m_pDoc) diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx index 19a7d131ad20..c70bd679c658 100644 --- a/sw/source/uibase/dochdl/swdtflvr.cxx +++ b/sw/source/uibase/dochdl/swdtflvr.cxx @@ -786,7 +786,7 @@ bool SwTransferable::WriteObject( tools::SvRef<SotTempStream>& xStream, case SWTRANSFER_OBJECTTYPE_HTML: { // LOK is interested in getting images embedded for copy/paste support. - GetHTMLWriter( comphelper::LibreOfficeKit::isActive() ? OUString("EmbedImages") : OUString(), OUString(), xWrt ); + GetHTMLWriter( comphelper::LibreOfficeKit::isActive() ? OUString("EmbedImages;NoLineLimit") : OUString(), OUString(), xWrt ); break; }