sw/source/uibase/dochdl/swdtflvr.cxx | 56 +++++++++++++---------------------- sw/source/uibase/inc/swdtflvr.hxx | 7 +--- sw/source/uibase/shells/basesh.cxx | 8 ----- vcl/unx/gtk3/gtkinst.cxx | 10 +++++- 4 files changed, 34 insertions(+), 47 deletions(-)
New commits: commit a287403a9f2b5a49d8cf05265865274b6e76adf6 Author: Ujjawal Kumar <[email protected]> AuthorDate: Sun Feb 22 16:33:40 2026 +0530 Commit: Michael Stahl <[email protected]> CommitDate: Wed Feb 25 14:01:50 2026 +0100 Add Markdown under paste special for gtk3. Change-Id: I423bfa356c337e7a6365beda0dcf1fff233f3edd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199980 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Michael Stahl <[email protected]> diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx index da7f4c6b8bcc..3765cf7fc224 100644 --- a/vcl/unx/gtk3/gtkinst.cxx +++ b/vcl/unx/gtk3/gtkinst.cxx @@ -699,6 +699,14 @@ std::vector<css::datatransfer::DataFlavor> GtkTransferable::getTransferDataFlavo aVector.push_back(aFlavor); } + if(bHaveText) + { + css::datatransfer::DataFlavor aFlavor; + aFlavor.MimeType = OUString("text/markdown"); + aFlavor.DataType = cppu::UnoType<OUString>::get(); + aVector.push_back(std::move(aFlavor)); + } + return aVector; } @@ -822,7 +830,7 @@ public: css::uno::Any aRet; css::datatransfer::DataFlavor aFlavor(rFlavor); - if (aFlavor.MimeType == "text/plain;charset=utf-16") + if (aFlavor.MimeType == "text/plain;charset=utf-16" || aFlavor.MimeType == "text/markdown") aFlavor.MimeType = "text/plain;charset=utf-8"; GdkClipboard* clipboard = clipboard_get(m_eSelection); commit 03cf68812b87e36de34d1fe00a61272c433a7497 Author: Ujjawal Kumar <[email protected]> AuthorDate: Fri Feb 20 17:06:53 2026 +0530 Commit: Michael Stahl <[email protected]> CommitDate: Wed Feb 25 14:01:40 2026 +0100 Remove bUseDetection used for heuristic detection of markdown content Change-Id: I4d49a7d927d7b33c9bc9e3420279ebb289bf98a3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199979 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Michael Stahl <[email protected]> diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx index 178466d299eb..fda33f444ec7 100644 --- a/sw/source/uibase/dochdl/swdtflvr.cxx +++ b/sw/source/uibase/dochdl/swdtflvr.cxx @@ -1465,7 +1465,7 @@ static sal_Int32 lcl_getLevel(OUString& sText, sal_Int32 nIdx) return nRet; } -bool SwTransferable::Paste(SwWrtShell& rSh, TransferableDataHelper& rData, RndStdIds nAnchorType, bool bIgnoreComments, PasteTableType ePasteTable, bool bUseDetection) +bool SwTransferable::Paste(SwWrtShell& rSh, TransferableDataHelper& rData, RndStdIds nAnchorType, bool bIgnoreComments, PasteTableType ePasteTable) { SwPasteContext aPasteContext(rSh); @@ -1697,7 +1697,7 @@ bool SwTransferable::Paste(SwWrtShell& rSh, TransferableDataHelper& rData, RndSt 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, @@ -1709,7 +1709,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; @@ -1873,7 +1873,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: @@ -2178,7 +2178,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 ) { TranslateId pResId = STR_CLPBRD_FORMAT_ERROR; bool bRet = false; @@ -2196,42 +2196,28 @@ 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 ); + if( rData.GetString( nFormat, sData ) ) + { + pStream = new SvMemoryStream( const_cast<sal_Unicode *>(sData.getStr()), + sData.getLength() * sizeof( sal_Unicode ), + StreamMode::READ ); #ifdef OSL_BIGENDIAN - pStream->SetEndian( SvStreamEndian::BIG ); + pStream->SetEndian( SvStreamEndian::BIG ); #else - pStream->SetEndian( SvStreamEndian::LITTLE ); + pStream->SetEndian( SvStreamEndian::LITTLE ); #endif - SwAsciiOptions aAOpt; - aAOpt.SetCharSet( RTL_TEXTENCODING_UCS2 ); - pRead->GetReaderOpt().SetASCIIOpts( aAOpt ); - } + 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 3b6e27cb35b1..5f3ea7134be5 100644 --- a/sw/source/uibase/inc/swdtflvr.hxx +++ b/sw/source/uibase/inc/swdtflvr.hxx @@ -113,8 +113,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, @@ -194,7 +193,7 @@ public: // paste - methods and helper methods for the paste static bool IsPaste( const SwWrtShell&, const TransferableDataHelper& ); SW_DLLPUBLIC static bool Paste( SwWrtShell&, 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, @@ -204,7 +203,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 018716bf8d7b..94ea2d116356 100644 --- a/sw/source/uibase/shells/basesh.cxx +++ b/sw/source/uibase/shells/basesh.cxx @@ -378,13 +378,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.IsObjSelected() ) rSh.EnterSelFrameMode();
