sw/source/uibase/dochdl/swdtflvr.cxx | 39 +++++------------------------------ sw/source/uibase/inc/swdtflvr.hxx | 7 +++--- sw/source/uibase/shells/basesh.cxx | 2 - 3 files changed, 11 insertions(+), 37 deletions(-)
New commits: commit da6b93e01c76fb1e1cc20dbca29fb96030521b24 Author: Ujjawal Kumar <[email protected]> AuthorDate: Sat Sep 20 15:14:30 2025 +0530 Commit: Miklos Vajna <[email protected]> CommitDate: Mon Sep 29 13:23:56 2025 +0200 tdf#162153 Remove selection dialog for markdown when pasting Paste markdown only when content is being pasted using normal paste or ctrl+v (after heuristics detection). For pasting plain text, users can now use paste special / ctrl-shift+v. (cherry picked from commit 372ae693fdaa1fb31bb5bb5462168e5081583d0b) Conflicts: sw/source/uibase/dochdl/swdtflvr.cxx sw/source/uibase/inc/swdtflvr.hxx Change-Id: I571e0245a4b5a79893ecf5b68d8bd35d2b7ef33f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191604 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx index ad31fd3407ab..178466d299eb 100644 --- a/sw/source/uibase/dochdl/swdtflvr.cxx +++ b/sw/source/uibase/dochdl/swdtflvr.cxx @@ -28,8 +28,6 @@ #include <officecfg/Office/Writer.hxx> -#include <svtools/svtresid.hxx> -#include <svtools/strings.hrc> #include <svtools/embedtransfer.hxx> #include <svtools/insdlg.hxx> #include <unotools/tempfile.hxx> @@ -45,8 +43,6 @@ #include <unotools/ucbstreamhelper.hxx> #include <sot/filelist.hxx> #include <svx/svxdlg.hxx> -#include <svx/dialmgr.hxx> -#include <svx/strings.hrc> #include <toolkit/helper/vclunohelper.hxx> #include <osl/endian.h> #include <sfx2/linkmgr.hxx> @@ -135,7 +131,6 @@ #include <vcl/uitest/logger.hxx> #include <vcl/uitest/eventdescription.hxx> -#include <svx/GenericDropDownFieldDialog.hxx> #include <vcl/TypeSerializer.hxx> #include <comphelper/lok.hxx> #include <sfx2/classificationhelper.hxx> @@ -1470,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 SwTransferable::Paste(SwWrtShell& rSh, TransferableDataHelper& rData, RndStdIds nAnchorType, bool bIgnoreComments, PasteTableType ePasteTable, bool bUseDetection) { SwPasteContext aPasteContext(rSh); @@ -1702,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); + nDestination, false, false, nullptr, 0, false, nAnchorType, bIgnoreComments, &aPasteContext, ePasteTable, bUseDetection); } bool SwTransferable::PasteData( const TransferableDataHelper& rData, @@ -1714,7 +1709,7 @@ bool SwTransferable::PasteData( const TransferableDataHelper& rData, bool bPasteSelection, RndStdIds nAnchorType, bool bIgnoreComments, SwPasteContext* pContext, - PasteTableType ePasteTable ) + PasteTableType ePasteTable, bool bUseDetection ) { SwWait aWait( *rSh.GetView().GetDocShell(), false ); std::unique_ptr<SwTrnsfrActionAndUndo, o3tl::default_delete<SwTrnsfrActionAndUndo>> pAction; @@ -1878,7 +1873,7 @@ bool SwTransferable::PasteData( const TransferableDataHelper& rData, case SotClipboardFormatId::STRING: case SotClipboardFormatId::MARKDOWN: bRet = SwTransferable::PasteFileContent( rData, rSh, - nFormat, bMsg, bIgnoreComments ); + nFormat, bMsg, bIgnoreComments, bUseDetection ); break; case SotClipboardFormatId::NETSCAPE_BOOKMARK: @@ -2183,7 +2178,7 @@ bool CanSkipInvalidateNumRules(const SwPosition& rInsertPosition) } bool SwTransferable::PasteFileContent( const TransferableDataHelper& rData, - SwWrtShell& rSh, SotClipboardFormatId nFormat, bool bMsg, bool bIgnoreComments ) + SwWrtShell& rSh, SotClipboardFormatId nFormat, bool bMsg, bool bIgnoreComments, bool bUseDetection ) { TranslateId pResId = STR_CLPBRD_FORMAT_ERROR; bool bRet = false; @@ -2203,30 +2198,8 @@ bool SwTransferable::PasteFileContent( const TransferableDataHelper& rData, if( rData.GetString( nFormat, sData ) ) { - OUString aSelection; - std::vector<OUString> aFormats; - aFormats.push_back(SvtResId(STR_FORMAT_STRING)); - if(comphelper::IsMarkdownData(sData)) //markdown - { - aFormats.push_back(SvtResId(STR_FORMAT_ID_MARKDOWN)); - } - - if(aFormats.size() > 1) - { - GenericDropDownFieldDialog aDialog(GetActiveView()->GetFrameWeld(), - SvxResId(RID_SVXSTR_PASTE_AS_DIALOG_TITLE), - aFormats); - short nRet = aDialog.run(); - if( nRet == RET_OK) - { - aSelection = aDialog.GetSelectedItem(); - } - else if(nRet == RET_CANCEL) - return false; - } - - if(aSelection == SvtResId(STR_FORMAT_ID_MARKDOWN)) + if(bUseDetection && comphelper::IsMarkdownData(sData)) //markdown { OString aData = OUStringToOString(sData, RTL_TEXTENCODING_UTF8); diff --git a/sw/source/uibase/inc/swdtflvr.hxx b/sw/source/uibase/inc/swdtflvr.hxx index e301fa0d7540..3b6e27cb35b1 100644 --- a/sw/source/uibase/inc/swdtflvr.hxx +++ b/sw/source/uibase/inc/swdtflvr.hxx @@ -113,7 +113,8 @@ 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 ); + SwWrtShell& rSh, SotClipboardFormatId nFormat, bool bMsg, bool bIgnoreComments = false, + bool bUseDetection = false ); static bool PasteOLE( const TransferableDataHelper& rData, SwWrtShell& rSh, SotClipboardFormatId nFormat, SotExchangeActionFlags nActionFlags, bool bMsg ); static bool PasteTargetURL( const TransferableDataHelper& rData, SwWrtShell& rSh, @@ -193,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&, TransferableDataHelper&, RndStdIds nAnchorType = RndStdIds::FLY_AT_PARA, - bool bIgnoreComments = false, PasteTableType ePasteTable = PasteTableType::PASTE_DEFAULT ); + bool bIgnoreComments = false, PasteTableType ePasteTable = PasteTableType::PASTE_DEFAULT, bool bUseDetection = false ); static bool PasteData( const TransferableDataHelper& rData, SwWrtShell& rSh, sal_uInt8 nAction, SotExchangeActionFlags nActionFlags, SotClipboardFormatId nFormat, @@ -203,7 +204,7 @@ public: bool bPasteSelection = false, RndStdIds nAnchorType = RndStdIds::FLY_AT_PARA, bool bIgnoreComments = false, SwPasteContext* pContext = nullptr, - PasteTableType nPaste = PasteTableType::PASTE_DEFAULT ); + PasteTableType nPaste = PasteTableType::PASTE_DEFAULT, bool bUseDetection = false ); 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 67cedf8135a1..419e9bfa9967 100644 --- a/sw/source/uibase/shells/basesh.cxx +++ b/sw/source/uibase/shells/basesh.cxx @@ -376,7 +376,7 @@ void SwBaseShell::ExecClpbrd(SfxRequest &rReq) const SfxBoolItem* pIgnoreComments = rReq.GetArg<SfxBoolItem>(FN_PARAM_2); if (pIgnoreComments) bIgnoreComments = pIgnoreComments->GetValue(); - SwTransferable::Paste(rSh, aDataHelper, nAnchorType, bIgnoreComments, ePasteTable); + SwTransferable::Paste(rSh, aDataHelper, nAnchorType, bIgnoreComments, ePasteTable, true); if( rSh.IsFrameSelected() || rSh.IsObjSelected() ) rSh.EnterSelFrameMode();
