vcl/source/components/dtranscomp.cxx |    2 ++
 vcl/source/treelist/transfer2.cxx    |    9 +++------
 2 files changed, 5 insertions(+), 6 deletions(-)

New commits:
commit 79a4b25db0baefbd4def1c4609ac055c8cde83cc
Author:     Michael Weghorn <[email protected]>
AuthorDate: Fri Feb 27 18:23:31 2026 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Sat Feb 28 09:35:52 2026 +0100

    vcl: Replace hack to pass extra service ctor param for primary selection
    
    The comment describes using the same service,
    "com.sun.star.datatransfer.clipboard.SystemClipboard",
    for both, primary selection and clipboard as a hack.
    
    Replace that and no longer get primary selection via
    the UNO service indirecation at all, but call
    SalInstance::CreateClipboard with the
    ClipboardSelectionType::Primary param instead.
    
    See vcl_SystemClipboard_get_implementation for
    where the param is evaluated and commit
    
        Change-Id: If913d7514fe7d5bcea34430928ec2ec3d98774b6
        Author: Michael Weghorn <[email protected]>
        Date:   Fri Feb 27 14:30:47 2026 +0100
    
            vcl: Centralize evaluating Sequence<Any> args for clipboard creation
    
    for more background on the now newly used approach
    allowing to pass an enum for the selection/clipboard
    type to SalInstance::CreateClipboard.
    
    The extra logic in vcl_SystemClipboard_get_implementation
    should be unnecessary now at least for LO-internal logic.
    While it shouldn't, at least in theory, third-party code
    (macros/extensions) could be depending on this implementation
    detail, so play it safe and leave it in place for now.
    
    Change-Id: I28f83f22a5826484327b91bcfd5a4c6650dc72de
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200647
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/vcl/source/components/dtranscomp.cxx 
b/vcl/source/components/dtranscomp.cxx
index 27e634d39ba6..a19f6d9c1475 100644
--- a/vcl/source/components/dtranscomp.cxx
+++ b/vcl/source/components/dtranscomp.cxx
@@ -152,6 +152,8 @@ vcl_SystemClipboard_get_implementation(
     SolarMutexGuard aGuard;
 
     ClipboardSelectionType eSelection = ClipboardSelectionType::Clipboard;
+    // in the past, GetSystemPrimarySelection 
(vcl/source/treelist/transfer2.cxx)
+    // used to pass a param of "PRIMARY" here to use primary selection
     if (args.hasElements())
     {
         OUString sSel;
diff --git a/vcl/source/treelist/transfer2.cxx 
b/vcl/source/treelist/transfer2.cxx
index e8c8642fd2a0..b3cef35b3729 100644
--- a/vcl/source/treelist/transfer2.cxx
+++ b/vcl/source/treelist/transfer2.cxx
@@ -36,6 +36,7 @@
 #include <vcl/dndlistenercontainer.hxx>
 #include <vcl/transfer.hxx>
 
+#include <salinst.hxx>
 #include <svdata.hxx>
 
 using namespace ::com::sun::star::uno;
@@ -507,14 +508,10 @@ Reference<XClipboard> GetSystemPrimarySelection()
     Reference<XClipboard> xSelection;
     try
     {
-        const Reference<XComponentContext>& 
xContext(comphelper::getProcessComponentContext());
 #if USING_X11
-        // A hack, making the primary selection available as an instance
-        // of the SystemClipboard service on X11:
-        Sequence< Any > args{ Any(u"PRIMARY"_ustr) };
-        
xSelection.set(xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
-            u"com.sun.star.datatransfer.clipboard.SystemClipboard"_ustr, args, 
xContext), UNO_QUERY_THROW);
+        xSelection = 
GetSalInstance()->CreateClipboard(ClipboardSelectionType::Primary);
 #else
+        const Reference<XComponentContext>& 
xContext(comphelper::getProcessComponentContext());
         static Reference< XClipboard > s_xSelection(
             xContext->getServiceManager()->createInstanceWithContext(
                 "com.sun.star.datatransfer.clipboard.GenericClipboard", 
xContext), UNO_QUERY);

Reply via email to