[Libreoffice-commits] core.git: sw/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Wed Jun 9 16:55:28 UTC 2021


 sw/source/ui/frmdlg/frmpage.cxx   |    7 +++++--
 sw/source/uibase/app/docst.cxx    |   25 ++++++++++++++++++++++++-
 sw/source/uibase/app/docstyle.cxx |    1 +
 3 files changed, 30 insertions(+), 3 deletions(-)

New commits:
commit 4895a92e67ffbbee87ec5ee1e2394cdc5b833fcb
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Wed Jun 9 17:59:08 2021 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Jun 9 18:54:48 2021 +0200

    sw keep aspect ratio: add style UI for this setting
    
    It's a per-document setting, but it was only possible to set/get this for a
    direct formatting dialog. Allow it for styles as well.
    
    Change-Id: Iafe1cab37be1eb741b895fe3c6613c21bc63f0d5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116931
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Jenkins

diff --git a/sw/source/ui/frmdlg/frmpage.cxx b/sw/source/ui/frmdlg/frmpage.cxx
index c42ce8dbf4fd..dc148972e277 100644
--- a/sw/source/ui/frmdlg/frmpage.cxx
+++ b/sw/source/ui/frmdlg/frmpage.cxx
@@ -886,7 +886,10 @@ void SwFramePage::Reset( const SfxItemSet *rSet )
     {
         // at formats no anchor editing
         m_xAnchorFrame->set_sensitive(false);
-        m_xFixedRatioCB->set_sensitive(false);
+        if (rSet->GetItemState(FN_KEEP_ASPECT_RATIO) != SfxItemState::SET)
+        {
+            m_xFixedRatioCB->set_sensitive(false);
+        }
     }
     else
     {
@@ -1205,7 +1208,7 @@ bool SwFramePage::FillItemSet(SfxItemSet *rSet)
                 aSz.SetWidthSizeType( eFrameSize );
         }
     }
-    if (!m_bFormat && m_xFixedRatioCB->get_state_changed_from_saved())
+    if (m_xFixedRatioCB->get_state_changed_from_saved())
         bRet |= nullptr != rSet->Put(SfxBoolItem(FN_KEEP_ASPECT_RATIO, m_xFixedRatioCB->get_active()));
 
     pOldItem = GetOldItem(*rSet, RES_FRM_SIZE);
diff --git a/sw/source/uibase/app/docst.cxx b/sw/source/uibase/app/docst.cxx
index 654ff05a0650..b9ab297aef78 100644
--- a/sw/source/uibase/app/docst.cxx
+++ b/sw/source/uibase/app/docst.cxx
@@ -642,6 +642,22 @@ IMPL_LINK_NOARG(ApplyStyle, ApplyHdl, LinkParamNone*, void)
                 }
             }
         }
+
+        if (m_nFamily == SfxStyleFamily::Frame)
+        {
+            const SfxPoolItem* pItem = nullptr;
+            if (aTmpSet.HasItem(FN_KEEP_ASPECT_RATIO, &pItem))
+            {
+                const auto& rBoolItem = static_cast<const SfxBoolItem&>(*pItem);
+                const SwViewOption* pVOpt = pWrtShell->GetViewOptions();
+                SwViewOption aUsrPref(*pVOpt);
+                aUsrPref.SetKeepRatio(rBoolItem.GetValue());
+                if (rBoolItem.GetValue() != pVOpt->IsKeepRatio())
+                {
+                    SW_MOD()->ApplyUsrPref(aUsrPref, &pWrtShell->GetView());
+                }
+            }
+        }
     }
 
     if(m_bNew)
@@ -913,6 +929,14 @@ void SwDocShell::Edit(
         rSet.Put(*oGrabBag);
     }
 
+    SwWrtShell* pCurrShell = pActShell ? pActShell : m_pWrtShell;
+    if (nFamily == SfxStyleFamily::Frame)
+    {
+        SfxItemSet& rSet = xTmp->GetItemSet();
+        const SwViewOption* pVOpt = pCurrShell->GetViewOptions();
+        rSet.Put(SfxBoolItem(FN_KEEP_ASPECT_RATIO, pVOpt->IsKeepRatio()));
+    }
+
     if (!bBasic)
     {
         // prior to the dialog the HtmlMode at the DocShell is being sunk
@@ -921,7 +945,6 @@ void SwDocShell::Edit(
         // In HTML mode, we do not always have a printer. In order to show
         // the correct page size in the Format - Page dialog, we have to
         // get one here.
-        SwWrtShell* pCurrShell = pActShell ? pActShell : m_pWrtShell;
         if( ( HTMLMODE_ON & nHtmlMode ) &&
             !pCurrShell->getIDocumentDeviceAccess().getPrinter( false ) )
             pCurrShell->InitPrt( pCurrShell->getIDocumentDeviceAccess().getPrinter( true ) );
diff --git a/sw/source/uibase/app/docstyle.cxx b/sw/source/uibase/app/docstyle.cxx
index 8b8d6bb3f63e..99b44f47ae86 100644
--- a/sw/source/uibase/app/docstyle.cxx
+++ b/sw/source/uibase/app/docstyle.cxx
@@ -486,6 +486,7 @@ SwDocStyleSheet::SwDocStyleSheet(   SwDoc&                rDocument,
             SID_ATTR_CHAR_GRABBAG, SID_ATTR_CHAR_GRABBAG,
             SID_ATTR_AUTO_STYLE_UPDATE, SID_ATTR_AUTO_STYLE_UPDATE,
             FN_PARAM_FTN_INFO, FN_PARAM_FTN_INFO,
+            FN_KEEP_ASPECT_RATIO, FN_KEEP_ASPECT_RATIO,
             FN_COND_COLL, FN_COND_COLL>{}),
     m_bPhysical(false)
 {


More information about the Libreoffice-commits mailing list