sw/source/uibase/dochdl/swdtflvr.cxx |   40 +++++------------------------------
 sw/source/uibase/inc/swdtflvr.hxx    |    7 +++---
 sw/source/uibase/shells/basesh.cxx   |    2 -
 3 files changed, 11 insertions(+), 38 deletions(-)

New commits:
commit 372ae693fdaa1fb31bb5bb5462168e5081583d0b
Author:     Ujjawal Kumar <randomfores...@gmail.com>
AuthorDate: Sat Sep 20 15:14:30 2025 +0530
Commit:     Thorsten Behrens <thorsten.behr...@collabora.com>
CommitDate: Mon Sep 22 02:46:58 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.
    
    Change-Id: I571e0245a4b5a79893ecf5b68d8bd35d2b7ef33f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191225
    Tested-by: Jenkins
    Reviewed-by: Thorsten Behrens <thorsten.behr...@collabora.com>

diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx 
b/sw/source/uibase/dochdl/swdtflvr.cxx
index 610bc9d3b7f5..9b9bf0574496 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 <sfx2/linkmgr.hxx>
 #include <tools/urlobj.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>
@@ -1474,7 +1469,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 SwTransferable::Paste(SwWrtShell& rSh, const TransferableDataHelper& 
rData, RndStdIds nAnchorType, bool bIgnoreComments, PasteTableType ePasteTable, 
bool bUseDetection)
 {
     SwPasteContext aPasteContext(rSh);
 
@@ -1706,7 +1701,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);
+                                        nDestination, false, false, nullptr, 
0, false, nAnchorType, bIgnoreComments, &aPasteContext, ePasteTable, 
bUseDetection);
 }
 
 bool SwTransferable::PasteData( const TransferableDataHelper& rData,
@@ -1718,7 +1713,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;
@@ -1882,7 +1877,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:
@@ -2187,7 +2182,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 )
 {
     bool bRet = false;
 
@@ -2206,31 +2201,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)
-                {
-                    const SwView* pView = GetActiveView();
-                    GenericDropDownFieldDialog aDialog(pView ? 
pView->GetFrameWeld() : nullptr,
-                                                       
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 8c1e9dfd6e9f..9c6c00561050 100644
--- a/sw/source/uibase/inc/swdtflvr.hxx
+++ b/sw/source/uibase/inc/swdtflvr.hxx
@@ -110,7 +110,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,
@@ -190,7 +191,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 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,
@@ -200,7 +201,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 cab8f016da8a..7fac5c01c8c4 100644
--- a/sw/source/uibase/shells/basesh.cxx
+++ b/sw/source/uibase/shells/basesh.cxx
@@ -377,7 +377,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.GetSelectedObjCount() )
                         rSh.EnterSelFrameMode();

Reply via email to