[Libreoffice-commits] core.git: Branch 'distro/vector/vector-7.0' - officecfg/registry sw/inc sw/source sw/uiconfig

Heiko Tietze (via logerrit) logerrit at kemper.freedesktop.org
Wed Feb 24 12:55:35 UTC 2021


 officecfg/registry/schema/org/openoffice/Office/Writer.xcs |   25 ++++
 sw/inc/viewopt.hxx                                         |   10 +
 sw/source/ui/config/optpage.cxx                            |    3 
 sw/source/uibase/config/cfgitems.cxx                       |    6 
 sw/source/uibase/config/usrpref.cxx                        |   21 ++-
 sw/source/uibase/config/viewopt.cxx                        |   23 +++
 sw/source/uibase/frmdlg/frmmgr.cxx                         |    3 
 sw/source/uibase/inc/cfgitems.hxx                          |    1 
 sw/source/uibase/inc/optpage.hxx                           |    2 
 sw/uiconfig/swriter/ui/optformataidspage.ui                |   81 +++++++++++++
 10 files changed, 168 insertions(+), 7 deletions(-)

New commits:
commit 64e84a6ac9b2bf81a271be9191a524c59cb44a72
Author:     Heiko Tietze <tietze.heiko at gmail.com>
AuthorDate: Tue Dec 1 12:21:10 2020 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Feb 24 12:21:27 2021 +0100

    Resolves tdf#99646 - Make default type of anchoring optional
    
    Option introduced at Tools > Options > Writer > Formatting Aids
    
    (cherry picked from commit 504f651e8240d17b366cd970ded7110803d28070)
    
    Conflicts:
            officecfg/registry/schema/org/openoffice/Office/Writer.xcs
            sw/source/ui/config/optpage.cxx
            sw/source/uibase/config/cfgitems.cxx
            sw/source/uibase/config/usrpref.cxx
            sw/source/uibase/inc/cfgitems.hxx
            sw/uiconfig/swriter/ui/optformataidspage.ui
    
    Change-Id: I8d890f84107647821c39669114b991c301727788

diff --git a/officecfg/registry/schema/org/openoffice/Office/Writer.xcs b/officecfg/registry/schema/org/openoffice/Office/Writer.xcs
index dab6d9af6711..d01f763b8b7b 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Writer.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Writer.xcs
@@ -1071,6 +1071,31 @@
           </info>
           <value>true</value>
         </prop>
+        <prop oor:name="DefaultAnchor" oor:type="xs:int" oor:nillable="false">
+          <!-- UIHints: Tools - Options - Writer - View - Default Anchor -->
+          <info>
+            <desc>Specifies the anchor of newly inserted images.</desc>
+            <label>Default Anchor</label>
+          </info>
+          <constraints>
+            <enumeration oor:value="0">
+              <info>
+                <desc>FLY_TO_PARA</desc>
+              </info>
+            </enumeration>
+            <enumeration oor:value="1">
+              <info>
+                <desc>FLY_TO_CHAR</desc>
+              </info>
+            </enumeration>
+            <enumeration oor:value="2">
+              <info>
+                <desc>FLY_AS_CHAR</desc>
+              </info>
+            </enumeration>
+          </constraints>
+          <value>1</value>
+        </prop>
       </group>
       <group oor:name="NonprintingCharacter">
         <info>
diff --git a/sw/inc/viewopt.hxx b/sw/inc/viewopt.hxx
index f5add2b728d1..6a8b21ddf2e1 100644
--- a/sw/inc/viewopt.hxx
+++ b/sw/inc/viewopt.hxx
@@ -25,6 +25,7 @@
 #include <tools/gen.hxx>
 #include <tools/color.hxx>
 
+#include <svx/swframetypes.hxx>
 #include <sfx2/zoomitem.hxx>
 #include "swdllapi.h"
 
@@ -170,6 +171,7 @@ class SW_DLLPUBLIC SwViewOption
     bool            mbHideWhitespaceMode : 1; // Hide header, footer, and pagebreak.
     bool            m_bShowPlaceHolderFields : 1; // Only used in printing!
     mutable bool    m_bIdle;
+    sal_Int32       m_nDefaultAnchor;     // GetDefaultAnchorType() to convert int to RndStdIds
 
     // Scale
     sal_uInt16          m_nZoom;          // In percent.
@@ -650,6 +652,14 @@ public:
     static void     SetDocBoundaries(bool bSet)   {SetAppearanceFlag(ViewOptFlags::DocBoundaries, bSet);}
 
     static void     ApplyColorConfigValues(const svtools::ColorConfig& rConfig);
+
+    // get/set default anchor (0..2); use GetDefaultAnchorType() to convert into RndStdIds::FLY_*
+    sal_Int32 GetDefaultAnchor() const
+        {   return m_nDefaultAnchor; }
+    void SetDefaultAnchor( const sal_Int32 aFlag )
+        { m_nDefaultAnchor = aFlag; }
+
+    RndStdIds GetDefaultAnchorType();
 };
 
 inline bool SwViewOption::operator==( const SwViewOption &rOpt ) const
diff --git a/sw/source/ui/config/optpage.cxx b/sw/source/ui/config/optpage.cxx
index 7c6140ea3a6c..fcfe6cd1a2e6 100644
--- a/sw/source/ui/config/optpage.cxx
+++ b/sw/source/ui/config/optpage.cxx
@@ -1199,6 +1199,7 @@ SwShdwCursorOptionsTabPage::SwShdwCursorOptionsTabPage(weld::Container* pPage, w
     , m_xDirectCursorFillMode(m_xBuilder->weld_combo_box("cxDirectCursorFillMode"))
     , m_xCursorProtFrame(m_xBuilder->weld_frame("crsrprotframe"))
     , m_xCursorInProtCB(m_xBuilder->weld_check_button("cursorinprot"))
+    , m_xDefaultAnchorType(m_xBuilder->weld_combo_box("cxDefaultAnchor"))
     , m_xMathBaselineAlignmentCB(m_xBuilder->weld_check_button("mathbaseline"))
 {
     const SfxPoolItem* pItem = nullptr;
@@ -1289,6 +1290,7 @@ bool SwShdwCursorOptionsTabPage::FillItemSet( SfxItemSet* rSet )
     aDisp.bCharHiddenText       = m_xCharHiddenCB->get_active();
     aDisp.bBookmarks            = m_xBookmarkCB->get_active();
     aDisp.bManualBreak          = m_xBreakCB->get_active();
+    aDisp.m_xDefaultAnchor        = m_xDefaultAnchorType->get_active();
 
     bRet |= (!pOldAttr || aDisp != *pOldAttr);
     if(bRet)
@@ -1337,6 +1339,7 @@ void SwShdwCursorOptionsTabPage::Reset( const SfxItemSet* rSet )
         m_xCharHiddenCB->set_active( pDocDisplayAttr->bCharHiddenText );
         m_xBookmarkCB->set_active(pDocDisplayAttr->bBookmarks);
         m_xBreakCB->set_active( pDocDisplayAttr->bManualBreak );
+        m_xDefaultAnchorType->set_active( pDocDisplayAttr->m_xDefaultAnchor );
     }
 }
 
diff --git a/sw/source/uibase/config/cfgitems.cxx b/sw/source/uibase/config/cfgitems.cxx
index 41ce1246072d..7d103cd761a8 100644
--- a/sw/source/uibase/config/cfgitems.cxx
+++ b/sw/source/uibase/config/cfgitems.cxx
@@ -34,6 +34,7 @@ SwDocDisplayItem::SwDocDisplayItem() :
     bCharHiddenText     =
     bBookmarks          =
     bManualBreak        = true;
+    m_xDefaultAnchor      = 1; //FLY_TO_CHAR
 };
 
 // Item for the Settings dialog, page document view
@@ -48,6 +49,7 @@ SwDocDisplayItem::SwDocDisplayItem(const SwViewOption& rVOpt ) :
     bCharHiddenText     = rVOpt.IsShowHiddenChar(true);
     bBookmarks          = rVOpt.IsShowBookmarks(true);
     bManualBreak        = rVOpt.IsLineBreak(true);
+    m_xDefaultAnchor    = rVOpt.GetDefaultAnchor();
 }
 
 SwDocDisplayItem* SwDocDisplayItem::Clone( SfxItemPool*  ) const
@@ -68,7 +70,8 @@ bool SwDocDisplayItem::operator==( const SfxPoolItem& rAttr ) const
               bSoftHyphen           == rItem.bSoftHyphen         &&
               bCharHiddenText       == rItem.bCharHiddenText         &&
               bBookmarks            == rItem.bBookmarks          &&
-              bManualBreak          == rItem.bManualBreak );
+              bManualBreak          == rItem.bManualBreak &&
+              m_xDefaultAnchor      == rItem.m_xDefaultAnchor);
 }
 
 void SwDocDisplayItem::FillViewOptions( SwViewOption& rVOpt) const
@@ -81,6 +84,7 @@ void SwDocDisplayItem::FillViewOptions( SwViewOption& rVOpt) const
     rVOpt.SetShowHiddenChar(bCharHiddenText );
     rVOpt.SetShowBookmarks(bBookmarks       );
     rVOpt.SetLineBreak  (bManualBreak       );
+    rVOpt.SetDefaultAnchor(m_xDefaultAnchor);
 }
 
 SwElemItem::SwElemItem() :
diff --git a/sw/source/uibase/config/usrpref.cxx b/sw/source/uibase/config/usrpref.cxx
index 77790b82c220..388bc895dd12 100644
--- a/sw/source/uibase/config/usrpref.cxx
+++ b/sw/source/uibase/config/usrpref.cxx
@@ -76,6 +76,7 @@ SwMasterUsrPref::~SwMasterUsrPref()
 }
 
 static const auto g_UpdateLinkIndex = 17;
+static const auto g_DefaultAnchor = 22;
 
 Sequence<OUString> SwContentViewConfig::GetPropertyNames() const
 {
@@ -86,8 +87,8 @@ Sequence<OUString> SwContentViewConfig::GetPropertyNames() const
         "Display/DrawingControl",                   //  2
         "Display/FieldCode",                        //  3
         "Display/Note",                             //  4
-        "Display/ShowContentTips",                      //  5
-        "NonprintingCharacter/MetaCharacters",     //   6
+        "Display/ShowContentTips",                  //  5
+        "NonprintingCharacter/MetaCharacters",      //  6
         "NonprintingCharacter/ParagraphEnd",        //  7
         "NonprintingCharacter/OptionalHyphen",      //  8
         "NonprintingCharacter/Space",               //  9
@@ -102,7 +103,8 @@ Sequence<OUString> SwContentViewConfig::GetPropertyNames() const
         "Update/Field",                         // 18
         "Update/Chart",                         // 19
         "Display/ShowInlineTooltips",           // 20
-        "Display/UseHeaderFooterMenu"           // 21
+        "Display/UseHeaderFooterMenu",          // 21
+        "Display/DefaultAnchor"                 // 22
     };
 #if defined(__GNUC__) && !defined(__clang__)
     // clang 8.0.0 says strcmp isn't constexpr
@@ -170,8 +172,9 @@ void SwContentViewConfig::ImplCommit()
             case 19: bVal = rParent.IsUpdateCharts(); break;// "Update/Chart"
             case 20: bVal = rParent.IsShowInlineTooltips(); break;// "Display/ShowInlineTooltips"
             case 21: bVal = rParent.IsUseHeaderFooterMenu(); break;// "Display/UseHeaderFooterMenu"
+            case 22: pValues[nProp] <<= rParent.GetDefaultAnchor(); break;// "Display/DefaultAnchor"
         }
-        if (nProp != g_UpdateLinkIndex)
+        if ((nProp != g_UpdateLinkIndex) && (nProp != g_DefaultAnchor))
             pValues[nProp] <<= bVal;
     }
     PutProperties(aNames, aValues);
@@ -189,7 +192,8 @@ void SwContentViewConfig::Load()
         {
             if(pValues[nProp].hasValue())
             {
-                bool bSet = nProp != g_UpdateLinkIndex && *o3tl::doAccess<bool>(pValues[nProp]);
+                bool bSet = nProp != g_UpdateLinkIndex && nProp != g_DefaultAnchor
+                            && *o3tl::doAccess<bool>(pValues[nProp]);
                 switch(nProp)
                 {
                     case  0: rParent.SetGraphic(bSet);  break;// "Display/GraphicObject",
@@ -220,6 +224,13 @@ void SwContentViewConfig::Load()
                     case 19: rParent.SetUpdateCharts(bSet); break;// "Update/Chart"
                     case 20: rParent.SetShowInlineTooltips(bSet); break;// "Display/ShowInlineTooltips"
                     case 21: rParent.SetUseHeaderFooterMenu(bSet); break;// "Display/UseHeaderFooterMenu"
+                    case 22:
+                    {
+                        sal_Int32 nSet;
+                        pValues[nProp] >>= nSet;
+                        rParent.SetDefaultAnchor(nSet);
+                    }
+                    break; // "Display/DefaultAnchor"
                 }
             }
         }
diff --git a/sw/source/uibase/config/viewopt.cxx b/sw/source/uibase/config/viewopt.cxx
index 194c89bbac51..384090485f07 100644
--- a/sw/source/uibase/config/viewopt.cxx
+++ b/sw/source/uibase/config/viewopt.cxx
@@ -80,6 +80,7 @@ bool SwViewOption::IsEqualFlags( const SwViewOption &rOpt ) const
             && mbHideWhitespaceMode == rOpt.mbHideWhitespaceMode
             && m_bShowPlaceHolderFields == rOpt.m_bShowPlaceHolderFields
             && m_bIdle == rOpt.m_bIdle
+            && m_nDefaultAnchor == rOpt.m_nDefaultAnchor
 #ifdef DBG_UTIL
             // correspond to the statements in ui/config/cfgvw.src
             && m_bTest1 == rOpt.IsTest1()
@@ -207,6 +208,8 @@ SwViewOption::SwViewOption() :
 
     m_bIdle = true;
 
+    m_nDefaultAnchor = 1; //FLY_TO_CHAR
+
 #ifdef DBG_UTIL
     // correspond to the statements in ui/config/cfgvw.src
     m_bTest1 = m_bTest2 = m_bTest3 = m_bTest4 =
@@ -245,6 +248,7 @@ SwViewOption::SwViewOption(const SwViewOption& rVOpt)
     mbHideWhitespaceMode = rVOpt.mbHideWhitespaceMode;
     m_bShowPlaceHolderFields = rVOpt.m_bShowPlaceHolderFields;
     m_bIdle           = rVOpt.m_bIdle;
+    m_nDefaultAnchor  = rVOpt.m_nDefaultAnchor;
 
 #ifdef DBG_UTIL
     m_bTest1  = rVOpt.m_bTest1;
@@ -286,6 +290,7 @@ SwViewOption& SwViewOption::operator=( const SwViewOption &rVOpt )
     mbHideWhitespaceMode = rVOpt.mbHideWhitespaceMode;
     m_bShowPlaceHolderFields = rVOpt.m_bShowPlaceHolderFields;
     m_bIdle           = rVOpt.m_bIdle;
+    m_nDefaultAnchor  = rVOpt.m_nDefaultAnchor;
 
 #ifdef DBG_UTIL
     m_bTest1  = rVOpt.m_bTest1;
@@ -357,6 +362,24 @@ sal_uInt16      GetHtmlMode(const SwDocShell* pShell)
     return nRet;
 }
 
+RndStdIds SwViewOption::GetDefaultAnchorType()
+{
+    switch ( m_nDefaultAnchor )
+    {
+      case 0:
+        return RndStdIds::FLY_AT_PARA; //0
+        break;
+      case 1:
+        return RndStdIds::FLY_AT_CHAR; //4
+        break;
+      case 2:
+        return RndStdIds::FLY_AS_CHAR; //1
+        break;
+      default:
+        return RndStdIds::FLY_AT_CHAR; //4
+    }//switch
+}
+
 Color&   SwViewOption::GetDocColor()
 {
     return s_aDocColor;
diff --git a/sw/source/uibase/frmdlg/frmmgr.cxx b/sw/source/uibase/frmdlg/frmmgr.cxx
index 926a949e2f98..ff72e7ae3f4d 100644
--- a/sw/source/uibase/frmdlg/frmmgr.cxx
+++ b/sw/source/uibase/frmdlg/frmmgr.cxx
@@ -90,7 +90,8 @@ SwFlyFrameAttrMgr::SwFlyFrameAttrMgr( bool bNew, SwWrtShell* pSh, Frmmgr_Type nT
             if (!pName || *pName != SvGlobalName( SO3_SM_CLASSID ))
             {
                 // Default anchor for new graphics and objects is at-char, except for Math objects.
-                m_aSet.Put(SwFormatAnchor(RndStdIds::FLY_AT_CHAR));
+                SwViewOption aViewOpt(*pSh->GetViewOptions());
+                m_aSet.Put(SwFormatAnchor(aViewOpt.GetDefaultAnchorType()));//RndStdIds::FLY_AT_CHAR
             }
         }
     }
diff --git a/sw/source/uibase/inc/cfgitems.hxx b/sw/source/uibase/inc/cfgitems.hxx
index bf50b8f105f0..d18d90e25ae1 100644
--- a/sw/source/uibase/inc/cfgitems.hxx
+++ b/sw/source/uibase/inc/cfgitems.hxx
@@ -52,6 +52,7 @@ class SW_DLLPUBLIC SwDocDisplayItem : public SfxPoolItem
     bool bCharHiddenText    :1;
     bool bBookmarks         :1;
     bool bManualBreak       :1;
+    sal_Int32 m_xDefaultAnchor;
 
 public:
                                 SwDocDisplayItem();
diff --git a/sw/source/uibase/inc/optpage.hxx b/sw/source/uibase/inc/optpage.hxx
index 73062bb3b730..bb7bd2c682aa 100644
--- a/sw/source/uibase/inc/optpage.hxx
+++ b/sw/source/uibase/inc/optpage.hxx
@@ -238,6 +238,8 @@ class SwShdwCursorOptionsTabPage : public SfxTabPage
     std::unique_ptr<weld::Frame> m_xCursorProtFrame;
     std::unique_ptr<weld::CheckButton> m_xCursorInProtCB;
 
+    std::unique_ptr<weld::ComboBox> m_xDefaultAnchorType;
+
     std::unique_ptr<weld::CheckButton> m_xMathBaselineAlignmentCB;
 
 public:
diff --git a/sw/uiconfig/swriter/ui/optformataidspage.ui b/sw/uiconfig/swriter/ui/optformataidspage.ui
index d95f1f0ca331..a83fdb8cdeba 100644
--- a/sw/uiconfig/swriter/ui/optformataidspage.ui
+++ b/sw/uiconfig/swriter/ui/optformataidspage.ui
@@ -243,6 +243,7 @@
           <packing>
             <property name="left_attach">0</property>
             <property name="top_attach">1</property>
+            <property name="height">2</property>
           </packing>
         </child>
         <child>
@@ -447,6 +448,86 @@
             <property name="top_attach">0</property>
           </packing>
         </child>
+        <child>
+          <object class="GtkFrame" id="frmImage">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label_xalign">0</property>
+            <property name="shadow_type">none</property>
+            <child>
+              <object class="GtkAlignment" id="alignment3">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="top_padding">6</property>
+                <property name="left_padding">12</property>
+                <child>
+                  <object class="GtkGrid" id="grid4">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="row_spacing">6</property>
+                    <child>
+                      <object class="GtkBox" id="bxFillMode1">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="spacing">6</property>
+                        <child>
+                          <object class="GtkLabel" id="lbDefaultAnchor">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="label" translatable="yes" context="optformataidspage|anchor">_Anchor:</property>
+                            <property name="use_underline">True</property>
+                            <property name="mnemonic_widget">cxDefaultAnchor</property>
+                            <property name="xalign">0</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkComboBoxText" id="cxDefaultAnchor">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="active_id">2</property>
+                            <items>
+                              <item id="0" translatable="yes" context="optformataidspage|cxDefaultAnchor1">To Paragraph</item>
+                              <item id="1" translatable="yes" context="optformataidspage|cxDefaultAnchor2">To Character</item>
+                              <item id="2" translatable="yes" context="optformataidspage|cxDefaultAnchor3">As Character</item>
+                            </items>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+            <child type="label">
+              <object class="GtkLabel" id="lbImage">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes" context="optformataidspage|lbImage">Image</property>
+                <attributes>
+                  <attribute name="weight" value="bold"/>
+                </attributes>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="left_attach">1</property>
+            <property name="top_attach">2</property>
+          </packing>
+        </child>
       </object>
       <packing>
         <property name="expand">False</property>


More information about the Libreoffice-commits mailing list