diff options
Diffstat (limited to 'sc')
-rw-r--r-- | sc/UIConfig_scalc.mk | 2 | ||||
-rw-r--r-- | sc/inc/globstr.hrc | 1 | ||||
-rw-r--r-- | sc/inc/helpids.h | 4 | ||||
-rw-r--r-- | sc/inc/strings.hrc | 1 | ||||
-rw-r--r-- | sc/source/ui/docshell/docsh.cxx | 28 | ||||
-rw-r--r-- | sc/source/ui/docshell/impex.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/inc/warnbox.hxx | 14 | ||||
-rw-r--r-- | sc/source/ui/miscdlgs/warnbox.cxx | 34 | ||||
-rw-r--r-- | sc/source/ui/view/viewfun3.cxx | 15 | ||||
-rw-r--r-- | sc/uiconfig/scalc/ui/checkwarningdialog.ui | 49 | ||||
-rw-r--r-- | sc/uiconfig/scalc/ui/sharedwarningdialog.ui | 48 |
11 files changed, 167 insertions, 34 deletions
diff --git a/sc/UIConfig_scalc.mk b/sc/UIConfig_scalc.mk index 78a0674eab40..bfbf46305226 100644 --- a/sc/UIConfig_scalc.mk +++ b/sc/UIConfig_scalc.mk @@ -92,6 +92,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/scalc,\ sc/uiconfig/scalc/ui/cellprotectionpage \ sc/uiconfig/scalc/ui/changesourcedialog \ sc/uiconfig/scalc/ui/chardialog \ + sc/uiconfig/scalc/ui/checkwarningdialog \ sc/uiconfig/scalc/ui/chisquaretestdialog \ sc/uiconfig/scalc/ui/colorrowdialog \ sc/uiconfig/scalc/ui/colwidthdialog \ @@ -200,6 +201,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/scalc,\ sc/uiconfig/scalc/ui/sharedocumentdlg \ sc/uiconfig/scalc/ui/sharedfooterdialog \ sc/uiconfig/scalc/ui/sharedheaderdialog \ + sc/uiconfig/scalc/ui/sharedwarningdialog \ sc/uiconfig/scalc/ui/showchangesdialog \ sc/uiconfig/scalc/ui/showdetaildialog \ sc/uiconfig/scalc/ui/showsheetdialog \ diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc index cf29d865364f..89f3150fa8d0 100644 --- a/sc/inc/globstr.hrc +++ b/sc/inc/globstr.hrc @@ -392,7 +392,6 @@ #define STR_DOC_WILLNOTBESAVED NC_("STR_DOC_WILLNOTBESAVED", "Already resolved merge conflicts will be lost and your changes to the shared spreadsheet will not be saved.\n\nDo you want to continue?") #define STR_DOC_DISABLESHARED NC_("STR_DOC_DISABLESHARED", "Disabling shared mode of a spreadsheet hinders all other users of the shared spreadsheet to merge back their work.\n\nDo you want to continue?") #define STR_DOC_NOLONGERSHARED NC_("STR_DOC_NOLONGERSHARED", "This spreadsheet is no longer in shared mode.\n\nSave your spreadsheet to a separate file and merge your changes to the shared spreadsheet manually.") -#define STR_SHARED_DOC_WARNING NC_("STR_SHARED_DOC_WARNING", "The spreadsheet is in shared mode. This allows multiple users to access and edit the spreadsheet at the same time.\n\nChanges to formatting attributes like fonts, colors, and number formats will not be saved and some functionalities like editing charts and drawing objects are not available in shared mode. Turn off shared mode to get exclusive access needed for those changes and functionalities.") #define STR_FILE_LOCKED_TRY_LATER NC_("STR_FILE_LOCKED_TRY_LATER", "The shared spreadsheet file is locked due to a merge in progress by user: '%1'\n\nSharing mode of a locked file cannot be disabled. Try again later.") #define STR_FILE_LOCKED_SAVE_LATER NC_("STR_FILE_LOCKED_SAVE_LATER", "The shared spreadsheet file is locked due to a merge in progress by user: '%1'\n\nTry again later to save your changes.") #define STR_UNKNOWN_USER NC_("STR_UNKNOWN_USER", "Unknown User") diff --git a/sc/inc/helpids.h b/sc/inc/helpids.h index 4f285dc45881..6d8606c8a246 100644 --- a/sc/inc/helpids.h +++ b/sc/inc/helpids.h @@ -66,10 +66,6 @@ // Other help IDs (max.70) --------------------------------------------------- #define HID_SELECTTABLES "SC_HID_SELECTTABLES" -#define HID_SC_REPLCELLSWARN "SC_HID_SC_REPLCELLSWARN" - - - // Analysis Addin Functions (max.120) ---------------------------------------- diff --git a/sc/inc/strings.hrc b/sc/inc/strings.hrc index 7aaf4fa723fb..c46331886c8f 100644 --- a/sc/inc/strings.hrc +++ b/sc/inc/strings.hrc @@ -77,7 +77,6 @@ #define STR_DLG_SELECTTABLES_TITLE NC_("STR_DLG_SELECTTABLES_TITLE", "Select Sheets") // Select tables dialog listbox #define STR_DLG_SELECTTABLES_LBNAME NC_("STR_DLG_SELECTTABLES_LBNAME", "~Selected sheets") -#define STR_REPLCELLSWARN NC_("STR_REPLCELLSWARN", "You are pasting data into cells that already contain data.\nDo you really want to overwrite the existing data?") #define STR_ACC_CSVRULER_NAME NC_("STR_ACC_CSVRULER_NAME", "Ruler") #define STR_ACC_CSVRULER_DESCR NC_("STR_ACC_CSVRULER_DESCR", "This ruler manages objects at fixed positions.") #define STR_ACC_CSVGRID_NAME NC_("STR_ACC_CSVGRID_NAME", "Preview") diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 767d5a502827..c8bbd5c93dd3 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -724,12 +724,28 @@ void ScDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint ) ScAppOptions aAppOptions = SC_MOD()->GetAppOptions(); if ( aAppOptions.GetShowSharedDocumentWarning() ) { - ScopedVclPtrInstance<WarningBox> aBox( GetActiveDialogParent(), MessBoxStyle::Ok, - ScGlobal::GetRscString( STR_SHARED_DOC_WARNING ) ); - aBox->SetDefaultCheckBoxText(); - aBox->Execute(); - bool bChecked = aBox->GetCheckBoxState(); - if ( bChecked ) + vcl::Window* pWin = ScDocShell::GetActiveDialogParent(); + + std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(pWin ? pWin->GetFrameWeld() : nullptr, + "modules/scalc/ui/sharedwarningdialog.ui")); + std::unique_ptr<weld::MessageDialog> xWarningBox(xBuilder->weld_message_dialog("SharedWarningDialog")); + std::unique_ptr<weld::CheckButton> xWarningOnBox(xBuilder->weld_check_button("ask")); + + //fdo#75121, a bit tricky because the widgets we want to align with + //don't actually exist in the ui description, they're implied + std::unique_ptr<weld::Container> xOrigParent(xWarningOnBox->weld_parent()); + std::unique_ptr<weld::Container> xContentArea(xWarningBox->weld_message_area()); + xOrigParent->remove(xWarningOnBox.get()); + xContentArea->add(xWarningOnBox.get()); + + xWarningBox->run(); + + //put them back as they were + xContentArea->remove(xWarningOnBox.get()); + xOrigParent->add(xWarningOnBox.get()); + + bool bChecked = xWarningOnBox->get_active(); + if (bChecked) { aAppOptions.SetShowSharedDocumentWarning( !bChecked ); SC_MOD()->SetAppOptions( aAppOptions ); diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx index e39abc0dc479..11c3e29103ad 100644 --- a/sc/source/ui/docshell/impex.cxx +++ b/sc/source/ui/docshell/impex.cxx @@ -1476,8 +1476,9 @@ bool ScImportExport::ExtText2Doc( SvStream& rStrm ) if ( !mbApi && nStartCol != nEndCol && !pDoc->IsBlockEmpty( nTab, nStartCol + 1, nStartRow, nEndCol, nRow ) ) { - ScopedVclPtrInstance< ScReplaceWarnBox > aBox( ScDocShell::GetActiveDialogParent() ); - if ( aBox->Execute() != RET_YES ) + vcl::Window* pWin = ScDocShell::GetActiveDialogParent(); + ScReplaceWarnBox aBox(pWin ? pWin->GetFrameWeld() : nullptr); + if (aBox.run() != RET_YES) { return false; } diff --git a/sc/source/ui/inc/warnbox.hxx b/sc/source/ui/inc/warnbox.hxx index c211a466665c..d4a17d69b94f 100644 --- a/sc/source/ui/inc/warnbox.hxx +++ b/sc/source/ui/inc/warnbox.hxx @@ -20,19 +20,25 @@ #ifndef INCLUDED_SC_SOURCE_UI_INC_WARNBOX_HXX #define INCLUDED_SC_SOURCE_UI_INC_WARNBOX_HXX -#include <vcl/msgbox.hxx> +#include <vcl/weld.hxx> /** Warning box for "Replace cell contents?". With warning image and "Do not show again" checkbox. */ -class ScReplaceWarnBox : public WarningBox +class ScReplaceWarnBox { + std::unique_ptr<weld::Builder> m_xBuilder; + std::unique_ptr<weld::MessageDialog> m_xDialog; + std::unique_ptr<weld::CheckButton> m_xWarningOnBox; + std::unique_ptr<weld::Container> m_xOrigParent; + std::unique_ptr<weld::Container> m_xContentArea; public: - ScReplaceWarnBox( vcl::Window* pParent ); + ScReplaceWarnBox(weld::Window* pParent); + ~ScReplaceWarnBox(); /** Opens dialog if IsDialogEnabled() returns true. @descr If after executing the dialog the checkbox "Do not show again" is set, the method DisableDialog() will be called. */ - virtual sal_Int16 Execute() override; + short run(); }; #endif diff --git a/sc/source/ui/miscdlgs/warnbox.cxx b/sc/source/ui/miscdlgs/warnbox.cxx index 9e74563d6452..dbe87229c6f9 100644 --- a/sc/source/ui/miscdlgs/warnbox.cxx +++ b/sc/source/ui/miscdlgs/warnbox.cxx @@ -25,23 +25,37 @@ #include <strings.hrc> #include <helpids.h> -ScReplaceWarnBox::ScReplaceWarnBox( vcl::Window* pParent ) : - WarningBox( pParent, MessBoxStyle::YesNo | MessBoxStyle::DefaultYes, ScResId( STR_REPLCELLSWARN ) ) -{ +ScReplaceWarnBox::ScReplaceWarnBox(weld::Window* pParent) + : m_xBuilder(Application::CreateBuilder(pParent, "modules/scalc/ui/checkwarningdialog.ui")) + , m_xDialog(m_xBuilder->weld_message_dialog("CheckWarningDialog")) // By default, the check box is ON, and the user needs to un-check it to // disable all future warnings. - SetCheckBoxState(true); - SetCheckBoxText(ScResId(SCSTR_WARN_ME_IN_FUTURE_CHECK)); - SetHelpId( HID_SC_REPLCELLSWARN ); + , m_xWarningOnBox(m_xBuilder->weld_check_button("ask")) + , m_xOrigParent(m_xWarningOnBox->weld_parent()) + , m_xContentArea(m_xDialog->weld_message_area()) +{ + m_xDialog->set_default_response(RET_YES); + + //fdo#75121, a bit tricky because the widgets we want to align with + //don't actually exist in the ui description, they're implied + m_xOrigParent->remove(m_xWarningOnBox.get()); + m_xContentArea->add(m_xWarningOnBox.get()); +} + +ScReplaceWarnBox::~ScReplaceWarnBox() +{ + //put them back as they were + m_xContentArea->remove(m_xWarningOnBox.get()); + m_xOrigParent->add(m_xWarningOnBox.get()); } -sal_Int16 ScReplaceWarnBox::Execute() +short ScReplaceWarnBox::run() { - sal_Int16 nRet = RET_YES; + short nRet = RET_YES; if( SC_MOD()->GetInputOptions().GetReplaceCellsWarn() ) { - nRet = WarningBox::Execute(); - if (!GetCheckBoxState()) + nRet = m_xDialog->run(); + if (!m_xWarningOnBox->get_active()) { ScModule* pScMod = SC_MOD(); ScInputOptions aInputOpt( pScMod->GetInputOptions() ); diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx index 623966231e62..ae15097d2720 100644 --- a/sc/source/ui/view/viewfun3.cxx +++ b/sc/source/ui/view/viewfun3.cxx @@ -822,7 +822,7 @@ static bool lcl_SelHasAttrib( const ScDocument* pDoc, SCCOL nCol1, SCROW nRow1, namespace { -bool checkDestRangeForOverwrite(const ScRangeList& rDestRanges, const ScDocument* pDoc, const ScMarkData& rMark, vcl::Window* pParentWnd) +bool checkDestRangeForOverwrite(const ScRangeList& rDestRanges, const ScDocument* pDoc, const ScMarkData& rMark, weld::Window* pParentWnd) { bool bIsEmpty = true; ScMarkData::const_iterator itrTab = rMark.begin(), itrTabEnd = rMark.end(); @@ -840,8 +840,8 @@ bool checkDestRangeForOverwrite(const ScRangeList& rDestRanges, const ScDocument if (!bIsEmpty) { - ScopedVclPtrInstance< ScReplaceWarnBox > aBox(pParentWnd); - if (aBox->Execute() != RET_YES) + ScReplaceWarnBox aBox(pParentWnd); + if (aBox.run() != RET_YES) { // changing the configuration is within the ScReplaceWarnBox return false; @@ -1143,7 +1143,8 @@ bool ScViewFunc::PasteFromClip( InsertDeleteFlags nFlags, ScDocument* pClipDoc, { ScRangeList aTestRanges; aTestRanges.Append(aUserRange); - if (!checkDestRangeForOverwrite(aTestRanges, pDoc, aFilteredMark, GetViewData().GetDialogParent())) + vcl::Window* pWin = GetViewData().GetDialogParent(); + if (!checkDestRangeForOverwrite(aTestRanges, pDoc, aFilteredMark, pWin ? pWin->GetFrameWeld() : nullptr)) return false; } } @@ -1511,7 +1512,8 @@ bool ScViewFunc::PasteMultiRangesFromClip( { ScRangeList aTestRanges; aTestRanges.Append(aMarkedRange); - if (!checkDestRangeForOverwrite(aTestRanges, pDoc, aMark, rViewData.GetDialogParent())) + vcl::Window* pWin = GetViewData().GetDialogParent(); + if (!checkDestRangeForOverwrite(aTestRanges, pDoc, aMark, pWin ? pWin->GetFrameWeld() : nullptr)) return false; } @@ -1673,7 +1675,8 @@ bool ScViewFunc::PasteFromClipToMultiRanges( if (bAskIfNotEmpty) { - if (!checkDestRangeForOverwrite(aRanges, pDoc, aMark, rViewData.GetDialogParent())) + vcl::Window* pWin = GetViewData().GetDialogParent(); + if (!checkDestRangeForOverwrite(aRanges, pDoc, aMark, pWin ? pWin->GetFrameWeld() : nullptr)) return false; } diff --git a/sc/uiconfig/scalc/ui/checkwarningdialog.ui b/sc/uiconfig/scalc/ui/checkwarningdialog.ui new file mode 100644 index 000000000000..addb933cfaa9 --- /dev/null +++ b/sc/uiconfig/scalc/ui/checkwarningdialog.ui @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.20.2 --> +<interface domain="sc"> + <requires lib="gtk+" version="3.20"/> + <object class="GtkMessageDialog" id="CheckWarningDialog"> + <property name="can_focus">False</property> + <property name="type_hint">dialog</property> + <property name="message_type">warning</property> + <property name="buttons">ok</property> + <property name="text" translatable="yes" context="checkwarningdialog|CheckWarningDialog">You are pasting data into cells that already contain data.</property> + <property name="secondary_text" translatable="yes" context="checkwarningdialog|CheckWarningDialog">Do you really want to overwrite the existing data?</property> + <child internal-child="vbox"> + <object class="GtkBox"> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">2</property> + <child internal-child="action_area"> + <object class="GtkButtonBox"> + <property name="can_focus">False</property> + <property name="homogeneous">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="ask"> + <property name="label" translatable="yes" context="checkwarningdialog|ask">Warn me about this in the future.</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> + </packing> + </child> + </object> + </child> + <child> + <placeholder/> + </child> + </object> +</interface> diff --git a/sc/uiconfig/scalc/ui/sharedwarningdialog.ui b/sc/uiconfig/scalc/ui/sharedwarningdialog.ui new file mode 100644 index 000000000000..bf894eaaa3e1 --- /dev/null +++ b/sc/uiconfig/scalc/ui/sharedwarningdialog.ui @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.20.2 --> +<interface domain="sc"> + <requires lib="gtk+" version="3.20"/> + <object class="GtkMessageDialog" id="SharedWarningDialog"> + <property name="can_focus">False</property> + <property name="type_hint">dialog</property> + <property name="message_type">warning</property> + <property name="buttons">ok</property> + <property name="text" translatable="yes" context="sharedwarningdialog|SharedWarningDialog">The spreadsheet is in shared mode. This allows multiple users to access and edit the spreadsheet at the same time.</property> + <property name="secondary_text" translatable="yes" context="sharedwarningdialog|SharedWarningDialog">Changes to formatting attributes like fonts, colors, and number formats will not be saved and some functionalities like editing charts and drawing objects are not available in shared mode. Turn off shared mode to get exclusive access needed for those changes and functionalities.</property> + <child internal-child="vbox"> + <object class="GtkBox"> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">2</property> + <child internal-child="action_area"> + <object class="GtkButtonBox"> + <property name="can_focus">False</property> + <property name="homogeneous">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="ask"> + <property name="label" translatable="yes" context="sharedwarningdialog|ask">Do not show warning again.</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + </object> + </child> + <child> + <placeholder/> + </child> + </object> +</interface> |