officecfg/registry/schema/org/openoffice/VCL.xcs |    3 +++
 vcl/source/gdi/print3.cxx                        |   10 ++++------
 vcl/source/window/printdlg.cxx                   |    9 +++------
 3 files changed, 10 insertions(+), 12 deletions(-)

New commits:
commit 6faa7e6f7bae3e6a613b4f4b7cee4a9c6d2b7aae
Author:     Gabor Kelemen <[email protected]>
AuthorDate: Sun May 11 10:06:53 2025 +0200
Commit:     Gabor Kelemen <[email protected]>
CommitDate: Sat Jun 21 18:08:00 2025 +0200

    [API CHANGE] Replace VCL Settings (PrintDialog/LastPrinter)
    
    in order to simplify code.
    
    The flexibility provided by the ConfigurableSettings template
    is not really necessary for the simple settings VCL has
    
    Change-Id: I48e473adbcb844cf95911bd03f036b064a0840f2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185178
    Reviewed-by: Gabor Kelemen <[email protected]>
    Tested-by: Jenkins

diff --git a/officecfg/registry/schema/org/openoffice/VCL.xcs 
b/officecfg/registry/schema/org/openoffice/VCL.xcs
index 4b0a4f35aba9..2323bca1340c 100644
--- a/officecfg/registry/schema/org/openoffice/VCL.xcs
+++ b/officecfg/registry/schema/org/openoffice/VCL.xcs
@@ -127,6 +127,9 @@
                 <prop oor:name="Collate" oor:type="xs:boolean" 
oor:nillable="false">
                     <value>true</value>
                 </prop>
+                <prop oor:name="LastPrinter" oor:type="xs:string" 
oor:nillable="false">
+                    <value/>
+                </prop>
             </group>
             <group oor:name="WM">
                 <prop oor:name="ShouldSwitchWorkspace" oor:type="xs:boolean" 
oor:nillable="false">
diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx
index 75d28ca69688..0da1d81fe127 100644
--- a/vcl/source/gdi/print3.cxx
+++ b/vcl/source/gdi/print3.cxx
@@ -23,6 +23,7 @@
 #include <comphelper/propertyvalue.hxx>
 #include <comphelper/sequence.hxx>
 #include <o3tl/safeint.hxx>
+#include <officecfg/VCL.hxx>
 #include <comphelper/diagnose_ex.hxx>
 #include <tools/debug.hxx>
 #include <tools/urlobj.hxx>
@@ -34,7 +35,6 @@
 #include <vcl/svapp.hxx>
 #include <vcl/weld.hxx>
 
-#include <configsettings.hxx>
 #include <printdlg.hxx>
 #include <salinst.hxx>
 #include <salprn.hxx>
@@ -800,11 +800,9 @@ bool Printer::StartJob( const OUString& i_rJobName, 
std::shared_ptr<vcl::Printer
     // make last used printer persistent for UI jobs
     if (i_xController->isShowDialogs() && !i_xController->isDirectPrint())
     {
-        SettingsConfigItem* pItem = SettingsConfigItem::get();
-        pItem->setValue( u"PrintDialog"_ustr,
-                         u"LastPrinterUsed"_ustr,
-                         GetName()
-                         );
+        std::shared_ptr<comphelper::ConfigurationChanges> 
batch(comphelper::ConfigurationChanges::create());
+        officecfg::VCL::VCLSettings::PrintDialog::LastPrinter::set( GetName(), 
batch );
+        batch->commit();
     }
 
     return true;
diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx
index 4d7c74392a6d..6a8b02626849 100644
--- a/vcl/source/window/printdlg.cxx
+++ b/vcl/source/window/printdlg.cxx
@@ -606,9 +606,7 @@ PrintDialog::PrintDialog(weld::Window* i_pWindow, 
std::shared_ptr<PrinterControl
     else
     {
         // fall back to last printer
-        SettingsConfigItem* pItem = SettingsConfigItem::get();
-        OUString aValue( pItem->getValue( u"PrintDialog"_ustr,
-                                        u"LastPrinter"_ustr ) );
+        OUString aValue( 
officecfg::VCL::VCLSettings::PrintDialog::LastPrinter::get() );
         if (mxPrinters->find_text(aValue) != -1)
         {
             mxPrinters->set_active_text(aValue);
@@ -751,10 +749,9 @@ void PrintDialog::storeToSettings()
     SettingsConfigItem* pItem = SettingsConfigItem::get();
     std::shared_ptr<comphelper::ConfigurationChanges> 
batch(comphelper::ConfigurationChanges::create());
 
-    pItem->setValue( u"PrintDialog"_ustr,
-                     u"LastPrinter"_ustr,
+    officecfg::VCL::VCLSettings::PrintDialog::LastPrinter::set(
                       isPrintToFile() ? Printer::GetDefaultPrinterName()
-                                      : mxPrinters->get_active_text() );
+                                      : mxPrinters->get_active_text(), batch );
 
     pItem->setValue( u"PrintDialog"_ustr,
                      u"LastPage"_ustr,

Reply via email to