sd/source/ui/dlg/tpoption.cxx  |   25 +++++++++++++++++++++++--
 sd/source/ui/view/drviewsg.cxx |    5 ++++-
 sd/source/ui/view/frmview.cxx  |    3 ++-
 3 files changed, 29 insertions(+), 4 deletions(-)

New commits:
commit c24f8262c884d9587ca40f3abb6b1a760c6522da
Author:     Gabor Kelemen <gabor.kelemen.ext...@allotropia.de>
AuthorDate: Fri May 3 11:27:31 2024 +0200
Commit:     Gabor Kelemen <gabor.kelemen.ext...@allotropia.de>
CommitDate: Sun May 12 13:17:56 2024 +0200

    Use less SdOptionsSnapItem->IsSnapHelplines/SetSnapHelplines
    
    in favor of officecfg
    
    Change-Id: I3f9d62380449c888b47020b4ffc765e9e8aa36ac
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167532
    Tested-by: Jenkins
    Reviewed-by: Gabor Kelemen <gabor.kelemen.ext...@allotropia.de>

diff --git a/sd/source/ui/dlg/tpoption.cxx b/sd/source/ui/dlg/tpoption.cxx
index fb16a14bebaf..1a2bfee07646 100644
--- a/sd/source/ui/dlg/tpoption.cxx
+++ b/sd/source/ui/dlg/tpoption.cxx
@@ -58,8 +58,20 @@ bool SdTpOptionsSnap::FillItemSet( SfxItemSet* rAttrs )
 {
     SvxGridTabPage::FillItemSet(rAttrs);
     SdOptionsSnapItem aOptsItem;
+    bool bDrawMode = SvxGridTabPage::IsDrawMode();
+
+    std::shared_ptr<comphelper::ConfigurationChanges> batch(
+        comphelper::ConfigurationChanges::create());
+
+    if (bDrawMode)
+    {
+        officecfg::Office::Draw::Snap::Object::SnapLine::set( 
m_xCbxSnapHelplines->get_active(), batch );
+    }
+    else
+    {
+        officecfg::Office::Impress::Snap::Object::SnapLine::set( 
m_xCbxSnapHelplines->get_active(), batch );
+    }
 
-    aOptsItem.GetOptionsSnap().SetSnapHelplines( 
m_xCbxSnapHelplines->get_active() );
     aOptsItem.GetOptionsSnap().SetSnapBorder( m_xCbxSnapBorder->get_active() );
     aOptsItem.GetOptionsSnap().SetSnapFrame( m_xCbxSnapFrame->get_active() );
     aOptsItem.GetOptionsSnap().SetSnapPoints( m_xCbxSnapPoints->get_active() );
@@ -71,6 +83,7 @@ bool SdTpOptionsSnap::FillItemSet( SfxItemSet* rAttrs )
     
aOptsItem.GetOptionsSnap().SetEliminatePolyPointLimitAngle(Degree100(m_xMtrFldBezAngle->get_value(FieldUnit::DEGREE)));
 
     rAttrs->Put( aOptsItem );
+    batch->commit();
 
     // we get a possible existing GridItem, this ensures that we do not set
     // some default values by accident
@@ -84,9 +97,17 @@ void SdTpOptionsSnap::Reset( const SfxItemSet* rAttrs )
     SdOptionsSnapItem aOptsItem( rAttrs->Get( ATTR_OPTIONS_SNAP ) );
 
     bool bDrawMode = SvxGridTabPage::IsDrawMode();
+    if (bDrawMode)
+    {
+        m_xCbxSnapHelplines->set_active( 
officecfg::Office::Draw::Snap::Object::SnapLine::get() );
+    }
+    else
+    {
+        m_xCbxSnapHelplines->set_active( 
officecfg::Office::Impress::Snap::Object::SnapLine::get() );
+    }
+
     bool bReadOnly = bDrawMode ? 
officecfg::Office::Draw::Snap::Object::SnapLine::isReadOnly() :
         officecfg::Office::Impress::Snap::Object::SnapLine::isReadOnly();
-    m_xCbxSnapHelplines->set_active( 
aOptsItem.GetOptionsSnap().IsSnapHelplines() );
     m_xCbxSnapHelplines->set_sensitive(!bReadOnly);
     m_xCbxSnapHelplinesImg->set_visible(bReadOnly);
 
diff --git a/sd/source/ui/view/drviewsg.cxx b/sd/source/ui/view/drviewsg.cxx
index 33cb87777391..e256ef926172 100644
--- a/sd/source/ui/view/drviewsg.cxx
+++ b/sd/source/ui/view/drviewsg.cxx
@@ -138,7 +138,10 @@ void DrawViewShell::ExecOptionsBar( SfxRequest& rReq )
 
         case SID_HELPLINES_USE:
         {
-            pOptions->SetSnapHelplines( !mpDrawView->IsHlplSnap() );
+            if (GetDoc()->GetDocumentType() == DocumentType::Impress)
+                
officecfg::Office::Impress::Snap::Object::SnapLine::set(!mpDrawView->IsHlplSnap(),
 batch);
+            else
+                
officecfg::Office::Draw::Snap::Object::SnapLine::set(!mpDrawView->IsHlplSnap(), 
batch);
         }
         break;
 
diff --git a/sd/source/ui/view/frmview.cxx b/sd/source/ui/view/frmview.cxx
index 1116f7d791f3..ad500cfb4eed 100644
--- a/sd/source/ui/view/frmview.cxx
+++ b/sd/source/ui/view/frmview.cxx
@@ -288,6 +288,7 @@ void FrameView::Update(SdOptions const * pOptions)
     {
         mbRuler = officecfg::Office::Impress::Layout::Display::Ruler::get();
         SetDragStripes( 
officecfg::Office::Impress::Layout::Display::Guide::get() );
+        SetHlplSnap( officecfg::Office::Impress::Snap::Object::SnapLine::get() 
);
         SetHlplVisible( 
officecfg::Office::Impress::Layout::Display::Helpline::get() );
         SetNoDragXorPolys ( 
!officecfg::Office::Impress::Layout::Display::Contour::get() );
         SetPlusHandlesAlwaysVisible( 
officecfg::Office::Impress::Layout::Display::Bezier::get() );
@@ -296,6 +297,7 @@ void FrameView::Update(SdOptions const * pOptions)
     {
         mbRuler = officecfg::Office::Draw::Layout::Display::Ruler::get();
         SetDragStripes( officecfg::Office::Draw::Layout::Display::Guide::get() 
);
+        SetHlplSnap( officecfg::Office::Draw::Snap::Object::SnapLine::get() );
         SetHlplVisible( 
officecfg::Office::Draw::Layout::Display::Helpline::get() );
         SetNoDragXorPolys ( 
!officecfg::Office::Draw::Layout::Display::Contour::get() );
         SetPlusHandlesAlwaysVisible( 
officecfg::Office::Draw::Layout::Display::Bezier::get() );
@@ -305,7 +307,6 @@ void FrameView::Update(SdOptions const * pOptions)
     SetSnapAngle( pOptions->GetAngle() );
     SetGridSnap( pOptions->IsUseGridSnap() );
     SetBordSnap( pOptions->IsSnapBorder()  );
-    SetHlplSnap( pOptions->IsSnapHelplines() );
     SetOFrmSnap( pOptions->IsSnapFrame() );
     SetOPntSnap( pOptions->IsSnapPoints() );
     SetSnapMagneticPixel( pOptions->GetSnapArea() );

Reply via email to