sd/source/core/drawdoc.cxx  |   14 +++++++++---
 sd/source/ui/app/sdmod2.cxx |   49 ++++++++++++++++++++++++++++++++++++++------
 2 files changed, 54 insertions(+), 9 deletions(-)

New commits:
commit dd8cf8a3f061d77ed7781a8b591cee86067ab973
Author:     Gabor Kelemen <gabor.kelemen.ext...@allotropia.de>
AuthorDate: Wed Apr 24 12:54:26 2024 +0200
Commit:     Gabor Kelemen <gabor.kelemen.ext...@allotropia.de>
CommitDate: Fri May 10 14:11:06 2024 +0200

    Use less SdOptionsLayout->Get/SetDefTab in favor of officecfg
    
    Change-Id: I028790b7e5750893f38ef7775cac1671104cd603
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166600
    Tested-by: Jenkins
    Reviewed-by: Gabor Kelemen <gabor.kelemen.ext...@allotropia.de>

diff --git a/sd/source/core/drawdoc.cxx b/sd/source/core/drawdoc.cxx
index b759f9b4e883..55e3a1fe6240 100644
--- a/sd/source/core/drawdoc.cxx
+++ b/sd/source/core/drawdoc.cxx
@@ -171,7 +171,7 @@ SdDrawDocument::SdDrawDocument(DocumentType eType, 
SfxObjectShell* pDrDocSh)
         if (aSysLocale.GetLocaleData().getMeasurementSystemEnum() == 
MeasurementSystem::Metric)
             SetUIUnit( 
static_cast<FieldUnit>(officecfg::Office::Impress::Layout::Other::MeasureUnit::Metric::get()),
 Fraction( 1, 1 ) );    // default
         else
-                        SetUIUnit( 
static_cast<FieldUnit>(officecfg::Office::Impress::Layout::Other::MeasureUnit::NonMetric::get()),
 Fraction( 1, 1 ) );    // default
+            SetUIUnit( 
static_cast<FieldUnit>(officecfg::Office::Impress::Layout::Other::MeasureUnit::NonMetric::get()),
 Fraction( 1, 1 ) );    // default
 
     SetScaleUnit(MapUnit::Map100thMM);
     SetDefaultFontHeight(o3tl::convert(24, o3tl::Length::pt, 
o3tl::Length::mm100));
@@ -219,8 +219,16 @@ SdDrawDocument::SdDrawDocument(DocumentType eType, 
SfxObjectShell* pDrDocSh)
     }
 
     // Set DefTab and SpellOptions for the SD module
-    sal_uInt16 nDefTab = pOptions->GetDefTab();
-    SetDefaultTabulator( nDefTab );
+    if (eType == DocumentType::Impress)
+        if (aSysLocale.GetLocaleData().getMeasurementSystemEnum() == 
MeasurementSystem::Metric)
+            SetDefaultTabulator( 
static_cast<sal_uInt16>(officecfg::Office::Impress::Layout::Other::TabStop::Metric::get())
 );
+        else
+            SetDefaultTabulator( 
static_cast<sal_uInt16>(officecfg::Office::Impress::Layout::Other::TabStop::NonMetric::get())
 );
+    else
+        if (aSysLocale.GetLocaleData().getMeasurementSystemEnum() == 
MeasurementSystem::Metric)
+            SetDefaultTabulator( 
static_cast<sal_uInt16>(officecfg::Office::Draw::Layout::Other::TabStop::Metric::get())
 );
+        else
+            SetDefaultTabulator( 
static_cast<sal_uInt16>(officecfg::Office::Draw::Layout::Other::TabStop::NonMetric::get())
 );
 
     try
     {
diff --git a/sd/source/ui/app/sdmod2.cxx b/sd/source/ui/app/sdmod2.cxx
index c33ea3c3f5a8..7e98287c2bc7 100644
--- a/sd/source/ui/app/sdmod2.cxx
+++ b/sd/source/ui/app/sdmod2.cxx
@@ -466,14 +466,28 @@ std::optional<SfxItemSet> SdModule::CreateItemSet( 
sal_uInt16 nSlot )
     aRet.Put( SdOptionsLayoutItem( pOptions, pFrameView ) );
 
     sal_uInt16 nDefTab = 0;
+    SvtSysLocale aSysLocale;
+
     if( pFrameView)
         nDefTab = pDoc->GetDefaultTabulator();
     else
-        nDefTab = pOptions->GetDefTab();
+    {
+        if (eDocType == DocumentType::Impress)
+            if (aSysLocale.GetLocaleData().getMeasurementSystemEnum() == 
MeasurementSystem::Metric)
+                nDefTab = 
officecfg::Office::Impress::Layout::Other::TabStop::Metric::get();
+            else
+                nDefTab = 
officecfg::Office::Impress::Layout::Other::TabStop::NonMetric::get();
+        else
+            if (aSysLocale.GetLocaleData().getMeasurementSystemEnum() == 
MeasurementSystem::Metric)
+                nDefTab = 
officecfg::Office::Draw::Layout::Other::TabStop::Metric::get();
+            else
+                nDefTab = 
officecfg::Office::Draw::Layout::Other::TabStop::NonMetric::get();
+    }
+
     aRet.Put( SfxUInt16Item( SID_ATTR_DEFTABSTOP, nDefTab ) );
 
     FieldUnit nMetric = FieldUnit(0xffff);
-    SvtSysLocale aSysLocale;
+
     if( pFrameView)
         nMetric = pDoc->GetUIUnit();
     else
@@ -551,6 +565,7 @@ void SdModule::ApplyItemSet( sal_uInt16 nSlot, const 
SfxItemSet& rSet )
     bool bNewDefTab = false;
     bool bNewPrintOptions = false;
     bool bMiscOptions = false;
+    SvtSysLocale aSysLocale;
 
     ::sd::DrawDocShell* pDocSh = dynamic_cast< ::sd::DrawDocShell *>( 
SfxObjectShell::Current() );
     SdDrawDocument* pDoc = nullptr;
@@ -588,7 +603,6 @@ void SdModule::ApplyItemSet( sal_uInt16 nSlot, const 
SfxItemSet& rSet )
         if( pDoc && eDocType == pDoc->GetDocumentType() )
             PutItem( *pItem );
 
-        SvtSysLocale aSysLocale;
         std::shared_ptr<comphelper::ConfigurationChanges> batch(
             comphelper::ConfigurationChanges::create());
         if (eDocType == DocumentType::Impress)
@@ -604,12 +618,36 @@ void SdModule::ApplyItemSet( sal_uInt16 nSlot, const 
SfxItemSet& rSet )
         batch->commit();
 
     }
-    sal_uInt16 nDefTab = pOptions->GetDefTab();
+    sal_uInt16 nDefTab;
+    if (eDocType == DocumentType::Impress)
+        if (aSysLocale.GetLocaleData().getMeasurementSystemEnum() == 
MeasurementSystem::Metric)
+            nDefTab = 
officecfg::Office::Impress::Layout::Other::TabStop::Metric::get();
+        else
+            nDefTab = 
officecfg::Office::Impress::Layout::Other::TabStop::NonMetric::get();
+    else
+        if (aSysLocale.GetLocaleData().getMeasurementSystemEnum() == 
MeasurementSystem::Metric)
+            nDefTab = 
officecfg::Office::Draw::Layout::Other::TabStop::Metric::get();
+        else
+            nDefTab = 
officecfg::Office::Draw::Layout::Other::TabStop::NonMetric::get();
+
     // Default-Tabulator
     if( const SfxUInt16Item* pItem = rSet.GetItemIfSet( SID_ATTR_DEFTABSTOP, 
false ) )
     {
         nDefTab = pItem->GetValue();
-        pOptions->SetDefTab( nDefTab );
+        std::shared_ptr<comphelper::ConfigurationChanges> batch(
+            comphelper::ConfigurationChanges::create());
+
+        if (eDocType == DocumentType::Impress)
+            if (aSysLocale.GetLocaleData().getMeasurementSystemEnum() == 
MeasurementSystem::Metric)
+                
officecfg::Office::Impress::Layout::Other::TabStop::Metric::set(nDefTab, batch);
+            else
+                
officecfg::Office::Impress::Layout::Other::TabStop::NonMetric::set(nDefTab, 
batch);
+        else
+            if (aSysLocale.GetLocaleData().getMeasurementSystemEnum() == 
MeasurementSystem::Metric)
+                
officecfg::Office::Draw::Layout::Other::TabStop::Metric::set(nDefTab, batch);
+            else
+                
officecfg::Office::Draw::Layout::Other::TabStop::NonMetric::set(nDefTab, batch);
+        batch->commit();
 
         bNewDefTab = true;
     }
@@ -731,7 +769,6 @@ void SdModule::ApplyItemSet( sal_uInt16 nSlot, const 
SfxItemSet& rSet )
     if( pDocSh && pDoc && eDocType == pDoc->GetDocumentType() )
     {
         FieldUnit eUIUnit;
-        SvtSysLocale aSysLocale;
         if (eDocType == DocumentType::Impress)
             if (aSysLocale.GetLocaleData().getMeasurementSystemEnum() == 
MeasurementSystem::Metric)
                 eUIUnit = 
static_cast<FieldUnit>(officecfg::Office::Impress::Layout::Other::MeasureUnit::Metric::get());

Reply via email to