officecfg/registry/schema/org/openoffice/Office/Calc.xcs |   11 ++++
 sc/inc/scabstdlg.hxx                                     |    1 
 sc/source/ui/attrdlg/scdlgfact.cxx                       |    1 
 sc/source/ui/dbgui/textimportoptions.cxx                 |    6 --
 sc/source/ui/inc/textimportoptions.hxx                   |    2 
 sc/source/ui/inc/viewfunc.hxx                            |    8 +--
 sc/source/ui/view/cliputil.cxx                           |    2 
 sc/source/ui/view/viewfun3.cxx                           |    8 +--
 sc/source/ui/view/viewfun5.cxx                           |   35 ++++++---------
 sc/uiconfig/scalc/ui/textimportoptions.ui                |   16 ------
 10 files changed, 34 insertions(+), 56 deletions(-)

New commits:
commit fec431aeef76e2f4e21dca8ef55f6807b5ad228d
Author:     Shardul Vikram Singh <shardulvi...@gmail.com>
AuthorDate: Fri Feb 7 02:24:58 2025 +0530
Commit:     Heiko Tietze <heiko.tie...@documentfoundation.org>
CommitDate: Fri Mar 28 17:52:49 2025 +0100

    tdf#65872 Remove import dialog for normal paste in Calc
    
    Remove the import dialog when performing a normal paste.
    Show the dialog only for Paste Special to avoid unnecessary interruptions.
    For normal paste, use the last selected preferences from Paste Special.
    
    Change-Id: Idfc985b9c13cb3b995c91e947e815d1789e6f041
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181225
    Reviewed-by: Heiko Tietze <heiko.tie...@documentfoundation.org>
    Tested-by: Jenkins

diff --git a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs 
b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
index 98e1afc76b89..9d3da5ee9d83 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
@@ -1207,6 +1207,17 @@
           <value/>
         </prop>
       </group>
+      <group oor:name="ClipboardHTMLImport">
+        <prop oor:name="Language" oor:type="xs:int" oor:nillable="false">
+          <value>0</value> <!-- LANGUAGE_SYSTEM -->
+        </prop>
+        <prop oor:name="DetectSpecialNumbers" oor:type="xs:boolean" 
oor:nillable="false">
+          <value>false</value>
+        </prop>
+        <prop oor:name="DetectScientificNumbers" oor:type="xs:boolean" 
oor:nillable="false">
+          <value>false</value>
+        </prop>
+      </group>
       <group oor:name="TextToColumnsImport">
         <info>
           <desc>Contains setting for Text to Columns Import</desc>
diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx
index 245869363f2e..8d46f1b3a2dc 100644
--- a/sc/inc/scabstdlg.hxx
+++ b/sc/inc/scabstdlg.hxx
@@ -396,7 +396,6 @@ public:
     virtual LanguageType GetLanguageType() const = 0;
     virtual bool IsDateConversionSet() const = 0;
     virtual bool IsScientificConversionSet() const = 0;
-    virtual bool IsKeepAskingSet() const = 0;
 };
 
 class AbstractScGoToTabDlg : public VclAbstractDialog
diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx 
b/sc/source/ui/attrdlg/scdlgfact.cxx
index 2dc64da32d5f..637c9ae58d78 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -131,7 +131,6 @@ public:
     LanguageType GetLanguageType() const override { return 
m_pDlg->getLanguageType(); }
     bool IsDateConversionSet() const override { return 
m_pDlg->isDateConversionSet(); }
     bool IsScientificConversionSet() const override { return 
m_pDlg->isScientificConversionSet(); }
-    bool IsKeepAskingSet() const override { return m_pDlg->isKeepAskingSet(); }
 };
 }
 
diff --git a/sc/source/ui/dbgui/textimportoptions.cxx 
b/sc/source/ui/dbgui/textimportoptions.cxx
index b91f8eb6d1bd..84521cb216f3 100644
--- a/sc/source/ui/dbgui/textimportoptions.cxx
+++ b/sc/source/ui/dbgui/textimportoptions.cxx
@@ -32,7 +32,6 @@ ScTextImportOptionsDlg::ScTextImportOptionsDlg(weld::Window* 
pParent)
     , m_xRbCustom(m_xBuilder->weld_radio_button(u"custom"_ustr))
     , m_xCkbConvertDate(m_xBuilder->weld_check_button(u"convertdata"_ustr))
     , 
m_xCkbConvertScientific(m_xBuilder->weld_check_button(u"convertscientificnotation"_ustr))
-    , m_xCkbKeepAsking(m_xBuilder->weld_check_button(u"keepasking"_ustr))
     , m_xLbCustomLang(new 
SvxLanguageBox(m_xBuilder->weld_combo_box(u"lang"_ustr)))
 {
     init();
@@ -60,11 +59,6 @@ bool ScTextImportOptionsDlg::isScientificConversionSet() 
const
     return m_xCkbConvertScientific->get_active();
 }
 
-bool ScTextImportOptionsDlg::isKeepAskingSet() const
-{
-    return m_xCkbKeepAsking->get_active();
-}
-
 void ScTextImportOptionsDlg::init()
 {
     m_xBtnOk->connect_clicked(LINK(this, ScTextImportOptionsDlg, OKHdl));
diff --git a/sc/source/ui/inc/textimportoptions.hxx 
b/sc/source/ui/inc/textimportoptions.hxx
index 7a2cfb6df589..b12b58a26990 100644
--- a/sc/source/ui/inc/textimportoptions.hxx
+++ b/sc/source/ui/inc/textimportoptions.hxx
@@ -33,7 +33,6 @@ public:
     LanguageType getLanguageType() const;
     bool isDateConversionSet() const;
     bool isScientificConversionSet() const;
-    bool isKeepAskingSet() const;
 
 private:
     void init();
@@ -44,7 +43,6 @@ private:
     std::unique_ptr<weld::RadioButton> m_xRbCustom;
     std::unique_ptr<weld::CheckButton> m_xCkbConvertDate;
     std::unique_ptr<weld::CheckButton> m_xCkbConvertScientific;
-    std::unique_ptr<weld::CheckButton> m_xCkbKeepAsking;
     std::unique_ptr<SvxLanguageBox> m_xLbCustomLang;
 
     DECL_LINK(OKHdl, weld::Button&, void);
diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx
index ef3c9e2311b0..36cbb20853e8 100644
--- a/sc/source/ui/inc/viewfunc.hxx
+++ b/sc/source/ui/inc/viewfunc.hxx
@@ -127,8 +127,8 @@ public:
 
     void                        FillTab( InsertDeleteFlags nFlags, ScPasteFunc 
nFunction, bool bSkipEmpty, bool bAsLink );
 
-    SC_DLLPUBLIC void           PasteFromSystem();
-    SC_DLLPUBLIC bool           PasteFromSystem( SotClipboardFormatId 
nFormatId, bool bApi = false );
+    SC_DLLPUBLIC void           PasteFromSystem(bool useSavedPrefs = false);
+    SC_DLLPUBLIC bool           PasteFromSystem( SotClipboardFormatId 
nFormatId, bool bApi = false, bool useSavedPrefs = false );
     void                        PasteFromTransferable( const 
css::uno::Reference<
                                                        
css::datatransfer::XTransferable >& rxTransferable );
 
@@ -143,7 +143,7 @@ public:
     bool            PasteDataFormat( SotClipboardFormatId nFormatId,
                                         const css::uno::Reference< 
css::datatransfer::XTransferable >& rxTransferable,
                                         SCCOL nPosX, SCROW nPosY, const Point* 
pLogicPos,
-                                        bool bLink = false, bool bAllowDialogs 
= false );
+                                        bool bLink = false, bool bAllowDialogs 
= false, bool useSavedPrefs = false );
 
     bool            PasteFile( const Point&, const OUString&, bool bLink );
     bool            PasteObject( const Point&, const css::uno::Reference < 
css::embed::XEmbeddedObject >&, const Size*, const Graphic* = nullptr, const 
OUString& = OUString(), sal_Int64 nAspect = css::embed::Aspects::MSOLE_CONTENT 
);
@@ -381,7 +381,7 @@ private:
     bool            PasteDataFormatFormattedText( SotClipboardFormatId 
nFormatId,
                                         const css::uno::Reference< 
css::datatransfer::XTransferable >& rxTransferable,
                                         SCCOL nPosX, SCROW nPosY,
-                                        bool bAllowDialogs, const 
TransferableDataHelper& rDataHelper );
+                                        bool bAllowDialogs, const 
TransferableDataHelper& rDataHelper, bool useSavedPrefs = false );
 
     sal_uInt16      GetOptimalColWidth( SCCOL nCol, SCTAB nTab, bool bFormula 
);
 
diff --git a/sc/source/ui/view/cliputil.cxx b/sc/source/ui/view/cliputil.cxx
index 3c83c0066e70..b8834f0ab1af 100644
--- a/sc/source/ui/view/cliputil.cxx
+++ b/sc/source/ui/view/cliputil.cxx
@@ -82,7 +82,7 @@ void ScClipUtil::PasteFromClipboard( ScViewData& rViewData, 
ScTabViewShell* pTab
         weld::WaitObject aWait( rViewData.GetDialogParent() );
         if (!pOwnClip)
         {
-            pTabViewShell->PasteFromSystem();
+            pTabViewShell->PasteFromSystem(true);
             // Anchor To Cell rather than To Page
             ScDrawView* pDrawView = pTabViewShell->GetScDrawView();
             if(pDrawView)
diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx
index f485ea2d9439..2fd0bd881d3d 100644
--- a/sc/source/ui/view/viewfun3.cxx
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -489,7 +489,7 @@ void ScViewFunc::PasteDraw()
     }
 }
 
-void ScViewFunc::PasteFromSystem()
+void ScViewFunc::PasteFromSystem(bool useSavedPrefs)
 {
     UpdateInputLine();
 
@@ -605,7 +605,7 @@ void ScViewFunc::PasteFromSystem()
                 else if (aDataHelper.HasFormat(SotClipboardFormatId::RICHTEXT))
                     PasteFromSystem(SotClipboardFormatId::RICHTEXT);
                 else if (aDataHelper.HasFormat(SotClipboardFormatId::HTML))
-                    PasteFromSystem(SotClipboardFormatId::HTML);
+                    PasteFromSystem(SotClipboardFormatId::HTML, false, 
useSavedPrefs);
                 else if (aDataHelper.HasFormat(SotClipboardFormatId::BITMAP))
                     PasteFromSystem(SotClipboardFormatId::BITMAP);
                 else if 
(aDataHelper.HasFormat(SotClipboardFormatId::HTML_SIMPLE))
@@ -717,7 +717,7 @@ void ScViewFunc::PasteFromTransferable( const 
uno::Reference<datatransfer::XTran
     }
 }
 
-bool ScViewFunc::PasteFromSystem( SotClipboardFormatId nFormatId, bool bApi )
+bool ScViewFunc::PasteFromSystem( SotClipboardFormatId nFormatId, bool bApi, 
bool useSavedPrefs )
 {
     UpdateInputLine();
 
@@ -755,7 +755,7 @@ bool ScViewFunc::PasteFromSystem( SotClipboardFormatId 
nFormatId, bool bApi )
 
         bRet = PasteDataFormat( nFormatId, aDataHelper.GetTransferable(),
                                 nPosX, nPosY,
-                                nullptr, false, !bApi );       // allow 
warning dialog
+                                nullptr, false, !bApi, useSavedPrefs );       
// allow warning dialog
 
         if ( !bRet && !bApi )
         {
diff --git a/sc/source/ui/view/viewfun5.cxx b/sc/source/ui/view/viewfun5.cxx
index 42c59672fad5..345a3f973fc4 100644
--- a/sc/source/ui/view/viewfun5.cxx
+++ b/sc/source/ui/view/viewfun5.cxx
@@ -17,6 +17,8 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <i18nlangtag/lang.h>
+#include <officecfg/Office/Calc.hxx>
 #include <com/sun/star/embed/XEmbedObjectClipboardCreator.hpp>
 #include <com/sun/star/embed/Aspects.hpp>
 #include <com/sun/star/embed/MSOLEObjectSystemCreator.hpp>
@@ -76,7 +78,7 @@ using namespace com::sun::star;
 
 bool ScViewFunc::PasteDataFormat( SotClipboardFormatId nFormatId,
                     const uno::Reference<datatransfer::XTransferable>& 
rxTransferable,
-                    SCCOL nPosX, SCROW nPosY, const Point* pLogicPos, bool 
bLink, bool bAllowDialogs )
+                    SCCOL nPosX, SCROW nPosY, const Point* pLogicPos, bool 
bLink, bool bAllowDialogs, bool useSavedPrefs )
 {
     ScDocument& rDoc = GetViewData().GetDocument();
     rDoc.SetPastingDrawFromOtherDoc( true );
@@ -126,7 +128,7 @@ bool ScViewFunc::PasteDataFormat( SotClipboardFormatId 
nFormatId,
                 nFormatId == SotClipboardFormatId::EDITENGINE_ODF_TEXT_FLAT )
     {
         bRet = PasteDataFormatFormattedText(nFormatId, rxTransferable, nPosX, 
nPosY,
-                                        bAllowDialogs, aDataHelper);
+                                        bAllowDialogs, aDataHelper, 
useSavedPrefs);
     }
     else if (nFormatId == SotClipboardFormatId::SBA_DATAEXCHANGE)
     {
@@ -658,7 +660,7 @@ bool ScViewFunc::PasteDataFormatSource( 
SotClipboardFormatId nFormatId,
 bool ScViewFunc::PasteDataFormatFormattedText( SotClipboardFormatId nFormatId,
                     const uno::Reference<datatransfer::XTransferable>& 
rxTransferable,
                     SCCOL nPosX, SCROW nPosY, bool bAllowDialogs,
-                    const TransferableDataHelper& rDataHelper )
+                    const TransferableDataHelper& rDataHelper, bool 
useSavedPrefs )
 {
     if ( nFormatId == SotClipboardFormatId::RTF && rDataHelper.HasFormat( 
SotClipboardFormatId::EDITENGINE_ODF_TEXT_FLAT ) )
     {
@@ -676,22 +678,15 @@ bool ScViewFunc::PasteDataFormatFormattedText( 
SotClipboardFormatId nFormatId,
     auto pStrBuffer = std::make_shared<OUString>();
     if (std::unique_ptr<SvStream> xStream = rDataHelper.GetSotStorageStream( 
nFormatId ) )
     {
-        // Static variables for per-session storage. This could be
-        // changed to longer-term storage in future.
-        static bool bHaveSavedPreferences = false;
-        static LanguageType eSavedLanguage;
-        static bool bSavedDateConversion;
-        static bool bSavedScientificConversion;
-
         if (nFormatId == SotClipboardFormatId::HTML &&
             !comphelper::LibreOfficeKit::isActive())
         {
-            if (bHaveSavedPreferences)
+            if (useSavedPrefs)
             {
                 ScAsciiOptions aOptions;
-                aOptions.SetLanguage(eSavedLanguage);
-                aOptions.SetDetectSpecialNumber(bSavedDateConversion);
-                aOptions.SetDetectScientificNumber(bSavedScientificConversion);
+                
aOptions.SetLanguage(LanguageType(officecfg::Office::Calc::Dialogs::ClipboardHTMLImport::Language::get()));
+                
aOptions.SetDetectSpecialNumber(officecfg::Office::Calc::Dialogs::ClipboardHTMLImport::DetectSpecialNumbers::get());
+                
aOptions.SetDetectScientificNumber(officecfg::Office::Calc::Dialogs::ClipboardHTMLImport::DetectScientificNumbers::get());
                 pObj->SetExtOptions(aOptions);
             }
             else
@@ -710,13 +705,11 @@ bool ScViewFunc::PasteDataFormatFormattedText( 
SotClipboardFormatId nFormatId,
                     aOptions.SetLanguage(pDlg->GetLanguageType());
                     
aOptions.SetDetectSpecialNumber(pDlg->IsDateConversionSet());
                     
aOptions.SetDetectScientificNumber(pDlg->IsScientificConversionSet());
-                    if (!pDlg->IsKeepAskingSet())
-                    {
-                        bHaveSavedPreferences = true;
-                        eSavedLanguage = pDlg->GetLanguageType();
-                        bSavedDateConversion = pDlg->IsDateConversionSet();
-                        bSavedScientificConversion = 
pDlg->IsScientificConversionSet();
-                    }
+                    auto pChange(comphelper::ConfigurationChanges::create());
+                    
officecfg::Office::Calc::Dialogs::ClipboardHTMLImport::Language::set(pDlg->GetLanguageType().get(),
 pChange);
+                    
officecfg::Office::Calc::Dialogs::ClipboardHTMLImport::DetectSpecialNumbers::set(pDlg->IsDateConversionSet(),
 pChange);
+                    
officecfg::Office::Calc::Dialogs::ClipboardHTMLImport::DetectScientificNumbers::set(pDlg->IsScientificConversionSet(),
 pChange);
+                    pChange->commit();
                     pObj->SetExtOptions(aOptions);
                 }
                 else
diff --git a/sc/uiconfig/scalc/ui/textimportoptions.ui 
b/sc/uiconfig/scalc/ui/textimportoptions.ui
index 0abfd7f4b6bd..84e4531f91e6 100644
--- a/sc/uiconfig/scalc/ui/textimportoptions.ui
+++ b/sc/uiconfig/scalc/ui/textimportoptions.ui
@@ -49,22 +49,6 @@
                 <property name="position">1</property>
               </packing>
             </child>
-            <child>
-              <object class="GtkCheckButton" id="keepasking">
-                <property name="label" translatable="yes" 
context="textimportoptions|keepasking">Keep asking during this 
session</property>
-                <property name="visible">True</property>
-                <property name="can-focus">True</property>
-                <property name="receives-default">False</property>
-                <property name="active">True</property>
-                <property name="draw-indicator">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">2</property>
-                <property name="secondary">True</property>
-              </packing>
-            </child>
           </object>
           <packing>
             <property name="expand">False</property>

Reply via email to