desktop/qa/desktop_lib/test_desktop_lib.cxx | 20 ---------- desktop/source/lib/init.cxx | 2 - sfx2/sdi/sfx.sdi | 2 - sw/source/uibase/dochdl/swdtflvr.cxx | 56 ++++++++++------------------ sw/source/uibase/inc/swdtflvr.hxx | 7 +-- sw/source/uibase/shells/basesh.cxx | 8 ---- 6 files changed, 26 insertions(+), 69 deletions(-)
New commits: commit c10f8589facc86e601fb745424819b2f9ab5d808 Author: Ujjawal Kumar <[email protected]> AuthorDate: Wed Feb 11 17:20:20 2026 +0530 Commit: Thorsten Behrens <[email protected]> CommitDate: Mon Feb 16 05:08:32 2026 +0100 Remove bUseDetection used for heuristic detection of markdown content Change-Id: I4d49a7d927d7b33c9bc9e3420279ebb289bf98a3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199156 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <[email protected]> diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 142427b58ebe..85c41736bea6 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -755,26 +755,6 @@ void DesktopLOKTest::testPasteWriter() // Without the accompanying fix in place, this test would have failed, as we had a comment // between "foo" and "baz". CPPUNIT_ASSERT(!xTextPortionEnumeration->hasMoreElements()); - - // Overwrite the doc contents with an explicitly plain text paste. - pDocument->pClass->postUnoCommand(pDocument, ".uno:SelectAll", nullptr, false); - Scheduler::ProcessEventsToIdle(); - OString aPlainText("foo _bar_ baz"_ostr); - CPPUNIT_ASSERT(pDocument->pClass->paste(pDocument, "text/plain", aPlainText.getStr(), - aPlainText.getLength())); - - // Check if '_bar_' was pasted as-is. - xParagraphEnumeration = xParagraphEnumerationAccess->createEnumeration(); - xParagraph.set(xParagraphEnumeration->nextElement(), uno::UNO_QUERY); - xTextPortionEnumeration = xParagraph->createEnumeration(); - uno::Reference<text::XTextRange> xTextPortionRange(xTextPortionEnumeration->nextElement(), - uno::UNO_QUERY); - // Without the accompanying fix in place, this test would have failed with: - // - Expected: foo _bar_ baz - // - Actual : foo - // i.e. the text/plain input was parsed as markdown, while that should not happen when - // specifying the text/plain mimetype explicitly (and not text/markdown). - CPPUNIT_ASSERT_EQUAL(u"foo _bar_ baz"_ustr, xTextPortionRange->getString()); } void DesktopLOKTest::testPasteWriterJPEG() diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 12f024652cf5..b642116bf455 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -6378,8 +6378,6 @@ static bool doc_paste(LibreOfficeKitDocument* pThis, const char* pMimeType, cons { {"AnchorType", uno::Any(static_cast<sal_uInt16>(css::text::TextContentAnchorType_AS_CHARACTER))}, {"IgnoreComments", uno::Any(true)}, - // The MIME type is specified explicitly, don't guess. - {"SkipDetection", uno::Any(true)}, })); if (!comphelper::dispatchCommand(u".uno:Paste"_ustr, aPropertyValues)) { diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi index 2c055e922a05..602450835bc9 100644 --- a/sfx2/sdi/sfx.sdi +++ b/sfx2/sdi/sfx.sdi @@ -3204,7 +3204,7 @@ SfxTemplateItem ParaStyle SID_STYLE_FAMILY2 SfxVoidItem Paste SID_PASTE -(SfxUInt16Item AnchorType FN_PARAM_1, SfxBoolItem IgnoreComments FN_PARAM_2, SfxBoolItem SkipDetection FN_PARAM_3) +(SfxUInt16Item AnchorType FN_PARAM_1, SfxBoolItem IgnoreComments FN_PARAM_2) [ AutoUpdate = FALSE, FastCall = TRUE, diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx index 226266294d04..25aee13ea755 100644 --- a/sw/source/uibase/dochdl/swdtflvr.cxx +++ b/sw/source/uibase/dochdl/swdtflvr.cxx @@ -1486,7 +1486,7 @@ static sal_Int32 lcl_getLevel(std::u16string_view sText, sal_Int32 nIdx) return nRet; } -bool SwTransferable::Paste(SwWrtShell& rSh, const TransferableDataHelper& rData, RndStdIds nAnchorType, bool bIgnoreComments, PasteTableType ePasteTable, bool bUseDetection) +bool SwTransferable::Paste(SwWrtShell& rSh, const TransferableDataHelper& rData, RndStdIds nAnchorType, bool bIgnoreComments, PasteTableType ePasteTable) { SwPasteContext aPasteContext(rSh); @@ -1718,7 +1718,7 @@ bool SwTransferable::Paste(SwWrtShell& rSh, const TransferableDataHelper& rData, return EXCHG_INOUT_ACTION_NONE != nAction && SwTransferable::PasteData( rData, rSh, nAction, nActionFlags, nFormat, - nDestination, false, false, nullptr, 0, false, nAnchorType, bIgnoreComments, &aPasteContext, ePasteTable, bUseDetection); + nDestination, false, false, nullptr, 0, false, nAnchorType, bIgnoreComments, &aPasteContext, ePasteTable); } bool SwTransferable::PasteData( const TransferableDataHelper& rData, @@ -1730,7 +1730,7 @@ bool SwTransferable::PasteData( const TransferableDataHelper& rData, bool bPasteSelection, RndStdIds nAnchorType, bool bIgnoreComments, SwPasteContext* pContext, - PasteTableType ePasteTable, bool bUseDetection ) + PasteTableType ePasteTable) { SwWait aWait( *rSh.GetView().GetDocShell(), false ); std::unique_ptr<SwTrnsfrActionAndUndo, o3tl::default_delete<SwTrnsfrActionAndUndo>> pAction; @@ -1894,7 +1894,7 @@ bool SwTransferable::PasteData( const TransferableDataHelper& rData, case SotClipboardFormatId::STRING: case SotClipboardFormatId::MARKDOWN: bRet = SwTransferable::PasteFileContent( rData, rSh, - nFormat, bMsg, bIgnoreComments, bUseDetection ); + nFormat, bMsg, bIgnoreComments); break; case SotClipboardFormatId::NETSCAPE_BOOKMARK: @@ -2200,7 +2200,7 @@ bool CanSkipInvalidateNumRules(const SwPosition& rInsertPosition) } bool SwTransferable::PasteFileContent( const TransferableDataHelper& rData, - SwWrtShell& rSh, SotClipboardFormatId nFormat, bool bMsg, bool bIgnoreComments, bool bUseDetection ) + SwWrtShell& rSh, SotClipboardFormatId nFormat, bool bMsg, bool bIgnoreComments) { bool bRet = false; @@ -2217,38 +2217,24 @@ bool SwTransferable::PasteFileContent( const TransferableDataHelper& rData, { pRead = ReadAscii; - if( rData.GetString( nFormat, sData ) ) + const SwPosition& rInsertPosition = *rSh.GetCursor()->Start(); + if (CanSkipInvalidateNumRules(rInsertPosition)) { + // Insertion point is not a numbering and we paste plain text: then no need to + // invalidate all numberings. + bSkipInvalidateNumRules = true; + } - if(bUseDetection && comphelper::IsMarkdownData(sData)) //markdown - { - OString aData = OUStringToOString(sData, RTL_TEXTENCODING_UTF8); - - pStream = new SvMemoryStream(); - pStream->WriteBytes(aData.getStr(), aData.getLength()); - pStream->Seek(0); - - pRead = ReadMarkdown; - } - else - { - const SwPosition& rInsertPosition = *rSh.GetCursor()->Start(); - if (CanSkipInvalidateNumRules(rInsertPosition)) - { - // Insertion point is not a numbering and we paste plain text: then no need to - // invalidate all numberings. - bSkipInvalidateNumRules = true; - } - - pStream = new SvMemoryStream( const_cast<sal_Unicode *>(sData.getStr()), - sData.getLength() * sizeof( sal_Unicode ), - StreamMode::READ ); - pStream->ResetEndianSwap(); - - SwAsciiOptions aAOpt; - aAOpt.SetCharSet( RTL_TEXTENCODING_UCS2 ); - pRead->GetReaderOpt().SetASCIIOpts( aAOpt ); - } + if( rData.GetString( nFormat, sData ) ) + { + pStream = new SvMemoryStream( const_cast<sal_Unicode *>(sData.getStr()), + sData.getLength() * sizeof( sal_Unicode ), + StreamMode::READ ); + pStream->ResetEndianSwap(); + + SwAsciiOptions aAOpt; + aAOpt.SetCharSet( RTL_TEXTENCODING_UCS2 ); + pRead->GetReaderOpt().SetASCIIOpts( aAOpt ); break; } } diff --git a/sw/source/uibase/inc/swdtflvr.hxx b/sw/source/uibase/inc/swdtflvr.hxx index 2301d783ba02..03bdbf3ebc37 100644 --- a/sw/source/uibase/inc/swdtflvr.hxx +++ b/sw/source/uibase/inc/swdtflvr.hxx @@ -110,8 +110,7 @@ class SAL_DLLPUBLIC_RTTI SwTransferable final : public TransferableHelper SotClipboardFormatId nFormat, SotExchangeDest nDestination ); static bool PasteFileContent( const TransferableDataHelper&, - SwWrtShell& rSh, SotClipboardFormatId nFormat, bool bMsg, bool bIgnoreComments = false, - bool bUseDetection = false ); + SwWrtShell& rSh, SotClipboardFormatId nFormat, bool bMsg, bool bIgnoreComments = false); static bool PasteOLE( const TransferableDataHelper& rData, SwWrtShell& rSh, SotClipboardFormatId nFormat, SotExchangeActionFlags nActionFlags, bool bMsg ); static bool PasteTargetURL( const TransferableDataHelper& rData, SwWrtShell& rSh, @@ -195,7 +194,7 @@ public: // paste - methods and helper methods for the paste static bool IsPaste( const SwWrtShell&, const TransferableDataHelper& ); SW_DLLPUBLIC static bool Paste( SwWrtShell&, const TransferableDataHelper&, RndStdIds nAnchorType = RndStdIds::FLY_AT_PARA, - bool bIgnoreComments = false, PasteTableType ePasteTable = PasteTableType::PASTE_DEFAULT, bool bUseDetection = false ); + bool bIgnoreComments = false, PasteTableType ePasteTable = PasteTableType::PASTE_DEFAULT); static bool PasteData( const TransferableDataHelper& rData, SwWrtShell& rSh, sal_uInt8 nAction, SotExchangeActionFlags nActionFlags, SotClipboardFormatId nFormat, @@ -205,7 +204,7 @@ public: bool bPasteSelection = false, RndStdIds nAnchorType = RndStdIds::FLY_AT_PARA, bool bIgnoreComments = false, SwPasteContext* pContext = nullptr, - PasteTableType nPaste = PasteTableType::PASTE_DEFAULT, bool bUseDetection = false ); + PasteTableType nPaste = PasteTableType::PASTE_DEFAULT); static bool IsPasteSpecial( const SwWrtShell& rWrtShell, const TransferableDataHelper& ); diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx index 30114f726ac3..77340ecfed24 100644 --- a/sw/source/uibase/shells/basesh.cxx +++ b/sw/source/uibase/shells/basesh.cxx @@ -379,13 +379,7 @@ void SwBaseShell::ExecClpbrd(SfxRequest &rReq) if (pIgnoreComments) bIgnoreComments = pIgnoreComments->GetValue(); - // See if detection should be used. - bool bSkipDetection = false; - const SfxBoolItem* pSkipDetection = rReq.GetArg<SfxBoolItem>(FN_PARAM_3); - if (pSkipDetection) - bSkipDetection = pSkipDetection->GetValue(); - - SwTransferable::Paste(rSh, aDataHelper, nAnchorType, bIgnoreComments, ePasteTable, !bSkipDetection); + SwTransferable::Paste(rSh, aDataHelper, nAnchorType, bIgnoreComments, ePasteTable); if( rSh.IsFrameSelected() || rSh.GetSelectedObjCount() ) rSh.EnterSelFrameMode();
