[Libreoffice-commits] core.git: officecfg/registry starmath/inc starmath/source starmath/uiconfig

Marcos Paulo de Souza marcos.souza.org at gmail.com
Tue Nov 10 03:54:49 PST 2015


 officecfg/registry/schema/org/openoffice/Office/Math.xcs |   10 +++++
 starmath/inc/dialog.hxx                                  |    1 
 starmath/inc/starmath.hrc                                |    1 
 starmath/source/cfgitem.cxx                              |   28 ++++++++++++++-
 starmath/source/cfgitem.hxx                              |    2 +
 starmath/source/dialog.cxx                               |    4 ++
 starmath/source/document.cxx                             |    1 
 starmath/source/edit.cxx                                 |    6 ++-
 starmath/source/smmod.cxx                                |    1 
 starmath/source/unomodel.cxx                             |    1 
 starmath/uiconfig/smath/ui/smathsettings.ui              |   16 ++++++++
 11 files changed, 69 insertions(+), 2 deletions(-)

New commits:
commit e2bfbfcb809329b9ed0bdd2fee14f343ca3603dd
Author: Marcos Paulo de Souza <marcos.souza.org at gmail.com>
Date:   Mon Nov 2 21:43:24 2015 -0200

    tdf#43090: Add option to disable auto close brackets
    
    As many users asked, now there is a checkbox inside Tools->Math
    called "Auto close brackets, parentheses and braces". This option is
    enabled by default, but can be turned off now.
    
    Change-Id: I6f96201c0720fb62fc2dce99222f97194e930fbe
    Signed-off-by: Marcos Paulo de Souza <marcos.souza.org at gmail.com>
    Reviewed-on: https://gerrit.libreoffice.org/19750
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/officecfg/registry/schema/org/openoffice/Office/Math.xcs b/officecfg/registry/schema/org/openoffice/Office/Math.xcs
index 3b05a12..c89c779 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Math.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Math.xcs
@@ -329,6 +329,16 @@
         </info>
         <value>true</value>
       </prop>
+      <prop oor:name="AutoCloseBrackets" oor:type="xs:boolean" oor:nillable="false">
+        <!-- OldPath: Math/Misc -->
+        <!-- OldLocation: Soffice.cfg -->
+        <!-- UIHints: Tools - Options  Formula  Settings - [Section] Miscellaneous options -->
+        <info>
+          <desc>Auto close brackets, parentheses and braces when editing a formula.</desc>
+          <label>Auto close brackets, parentheses and braces when editing a formula</label>
+        </info>
+        <value>true</value>
+      </prop>
     </group>
     <group oor:name="View">
       <info>
diff --git a/starmath/inc/dialog.hxx b/starmath/inc/dialog.hxx
index 16cf98d..4e7f374 100644
--- a/starmath/inc/dialog.hxx
+++ b/starmath/inc/dialog.hxx
@@ -61,6 +61,7 @@ class SmPrintOptionsTabPage : public SfxTabPage
     VclPtr<MetricField>    m_pZoom;
     VclPtr<CheckBox>       m_pNoRightSpaces;
     VclPtr<CheckBox>       m_pSaveOnlyUsedSymbols;
+    VclPtr<CheckBox>       m_pAutoCloseBrackets;
 
     DECL_LINK_TYPED(SizeButtonClickHdl, Button *, void);
 
diff --git a/starmath/inc/starmath.hrc b/starmath/inc/starmath.hrc
index 9a64513..cefa6c5 100644
--- a/starmath/inc/starmath.hrc
+++ b/starmath/inc/starmath.hrc
@@ -75,6 +75,7 @@
 #define SID_NO_RIGHT_SPACES         (SID_SMA_START + 124)
 #define SID_SAVE_ONLY_USED_SYMBOLS  (SID_SMA_START + 125)
 #define SID_ELEMENTSDOCKINGWINDOW   (SID_SMA_START + 126)
+#define SID_AUTO_CLOSE_BRACKETS     (SID_SMA_START + 127)
 
 #define RID_PRINTUIOPTIONS          (RID_APP_START + 11)
 
diff --git a/starmath/source/cfgitem.cxx b/starmath/source/cfgitem.cxx
index 858479d..d6c91b7 100644
--- a/starmath/source/cfgitem.cxx
+++ b/starmath/source/cfgitem.cxx
@@ -123,6 +123,7 @@ struct SmCfgOther
     bool            bPrintFormulaText;
     bool            bPrintFrame;
     bool            bIsSaveOnlyUsedSymbols;
+    bool            bIsAutoCloseBrackets;
     bool            bIgnoreSpacesRight;
     bool            bToolboxVisible;
     bool            bAutoRedraw;
@@ -139,7 +140,8 @@ SmCfgOther::SmCfgOther()
     bPrintTitle         = bPrintFormulaText   =
     bPrintFrame         = bIgnoreSpacesRight  =
     bToolboxVisible     = bAutoRedraw         =
-    bFormulaCursor      = bIsSaveOnlyUsedSymbols = true;
+    bIsAutoCloseBrackets = bFormulaCursor
+    = bIsSaveOnlyUsedSymbols = true;
 }
 
 
@@ -780,6 +782,7 @@ void SmMathConfig::LoadOther()
     pOther->ePrintSize = static_cast<SmPrintSize>(officecfg::Office::Math::Print::Size::get());
     pOther->nPrintZoomFactor = officecfg::Office::Math::Print::ZoomFactor::get();
     pOther->bIsSaveOnlyUsedSymbols = officecfg::Office::Math::LoadSave::IsSaveOnlyUsedSymbols::get();
+    pOther->bIsAutoCloseBrackets = officecfg::Office::Math::Misc::AutoCloseBrackets::get();
     pOther->bIgnoreSpacesRight = officecfg::Office::Math::Misc::IgnoreSpacesRight::get();
     pOther->bToolboxVisible = officecfg::Office::Math::View::ToolboxVisible::get();
     pOther->bAutoRedraw = officecfg::Office::Math::View::AutoRedraw::get();
@@ -801,6 +804,7 @@ void SmMathConfig::SaveOther()
     officecfg::Office::Math::Print::Size::set(pOther->ePrintSize, batch);
     officecfg::Office::Math::Print::ZoomFactor::set(pOther->nPrintZoomFactor, batch);
     officecfg::Office::Math::LoadSave::IsSaveOnlyUsedSymbols::set(pOther->bIsSaveOnlyUsedSymbols, batch);
+    officecfg::Office::Math::Misc::AutoCloseBrackets::set(pOther->bIsAutoCloseBrackets, batch);
     officecfg::Office::Math::Misc::IgnoreSpacesRight::set(pOther->bIgnoreSpacesRight, batch);
     officecfg::Office::Math::View::ToolboxVisible::set(pOther->bToolboxVisible, batch);
     officecfg::Office::Math::View::AutoRedraw::set(pOther->bAutoRedraw, batch);
@@ -1067,6 +1071,13 @@ bool SmMathConfig::IsSaveOnlyUsedSymbols() const
     return pOther->bIsSaveOnlyUsedSymbols;
 }
 
+bool SmMathConfig::IsAutoCloseBrackets() const
+{
+    if (!pOther)
+        const_cast<SmMathConfig*>(this)->LoadOther();
+    return pOther->bIsAutoCloseBrackets;
+}
+
 bool SmMathConfig::IsPrintFrame() const
 {
     if (!pOther)
@@ -1091,6 +1102,14 @@ void SmMathConfig::SetSaveOnlyUsedSymbols( bool bVal )
 }
 
 
+void SmMathConfig::SetAutoCloseBrackets( bool bVal )
+{
+    if (!pOther)
+        LoadOther();
+    SetOtherIfNotEqual( pOther->bIsAutoCloseBrackets, bVal );
+}
+
+
 bool SmMathConfig::IsIgnoreSpacesRight() const
 {
     if (!pOther)
@@ -1187,6 +1206,12 @@ void SmMathConfig::ItemSetToConfig(const SfxItemSet &rSet)
         SetSaveOnlyUsedSymbols( bVal );
     }
 
+    if (rSet.GetItemState(SID_AUTO_CLOSE_BRACKETS, true, &pItem) == SfxItemState::SET)
+    {
+        bVal = static_cast<const SfxBoolItem *>(pItem)->GetValue();
+        SetAutoCloseBrackets( bVal );
+    }
+
     SaveOther();
 }
 
@@ -1206,6 +1231,7 @@ void SmMathConfig::ConfigToItemSet(SfxItemSet &rSet) const
     rSet.Put(SfxBoolItem(pPool->GetWhich(SID_AUTOREDRAW), IsAutoRedraw()));
     rSet.Put(SfxBoolItem(pPool->GetWhich(SID_NO_RIGHT_SPACES), IsIgnoreSpacesRight()));
     rSet.Put(SfxBoolItem(pPool->GetWhich(SID_SAVE_ONLY_USED_SYMBOLS), IsSaveOnlyUsedSymbols()));
+    rSet.Put(SfxBoolItem(pPool->GetWhich(SID_AUTO_CLOSE_BRACKETS), IsAutoCloseBrackets()));
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/source/cfgitem.hxx b/starmath/source/cfgitem.hxx
index c6c00de..fecded4 100644
--- a/starmath/source/cfgitem.hxx
+++ b/starmath/source/cfgitem.hxx
@@ -168,6 +168,8 @@ public:
 
     bool            IsSaveOnlyUsedSymbols() const;
     void            SetSaveOnlyUsedSymbols( bool bVal );
+    bool            IsAutoCloseBrackets() const;
+    void            SetAutoCloseBrackets( bool bVal );
     bool            IsIgnoreSpacesRight() const;
     void            SetIgnoreSpacesRight( bool bVal );
     bool            IsAutoRedraw() const;
diff --git a/starmath/source/dialog.cxx b/starmath/source/dialog.cxx
index cd53905..e043179 100644
--- a/starmath/source/dialog.cxx
+++ b/starmath/source/dialog.cxx
@@ -176,6 +176,7 @@ SmPrintOptionsTabPage::SmPrintOptionsTabPage(vcl::Window* pParent, const SfxItem
     get( m_pZoom,                "zoom");
     get( m_pNoRightSpaces,       "norightspaces");
     get( m_pSaveOnlyUsedSymbols, "saveonlyusedsymbols");
+    get( m_pAutoCloseBrackets,   "autoclosebrackets");
 
     m_pSizeNormal->SetClickHdl(LINK(this, SmPrintOptionsTabPage, SizeButtonClickHdl));
     m_pSizeScaled->SetClickHdl(LINK(this, SmPrintOptionsTabPage, SizeButtonClickHdl));
@@ -200,6 +201,7 @@ void SmPrintOptionsTabPage::dispose()
     m_pZoom.clear();
     m_pNoRightSpaces.clear();
     m_pSaveOnlyUsedSymbols.clear();
+    m_pAutoCloseBrackets.clear();
     SfxTabPage::dispose();
 }
 
@@ -221,6 +223,7 @@ bool SmPrintOptionsTabPage::FillItemSet(SfxItemSet* rSet)
     rSet->Put(SfxBoolItem(GetWhich(SID_PRINTFRAME), m_pFrame->IsChecked()));
     rSet->Put(SfxBoolItem(GetWhich(SID_NO_RIGHT_SPACES), m_pNoRightSpaces->IsChecked()));
     rSet->Put(SfxBoolItem(GetWhich(SID_SAVE_ONLY_USED_SYMBOLS), m_pSaveOnlyUsedSymbols->IsChecked()));
+    rSet->Put(SfxBoolItem(GetWhich(SID_AUTO_CLOSE_BRACKETS), m_pAutoCloseBrackets->IsChecked()));
 
     return true;
 }
@@ -243,6 +246,7 @@ void SmPrintOptionsTabPage::Reset(const SfxItemSet* rSet)
     m_pFrame->Check(static_cast<const SfxBoolItem &>(rSet->Get(GetWhich(SID_PRINTFRAME))).GetValue());
     m_pNoRightSpaces->Check(static_cast<const SfxBoolItem &>(rSet->Get(GetWhich(SID_NO_RIGHT_SPACES))).GetValue());
     m_pSaveOnlyUsedSymbols->Check(static_cast<const SfxBoolItem &>(rSet->Get(GetWhich(SID_SAVE_ONLY_USED_SYMBOLS))).GetValue());
+    m_pAutoCloseBrackets->Check(static_cast<const SfxBoolItem &>(rSet->Get(GetWhich(SID_AUTO_CLOSE_BRACKETS))).GetValue());
 }
 
 VclPtr<SfxTabPage> SmPrintOptionsTabPage::Create(vcl::Window* pWindow, const SfxItemSet& rSet)
diff --git a/starmath/source/document.cxx b/starmath/source/document.cxx
index 5ed4579..7430f58 100644
--- a/starmath/source/document.cxx
+++ b/starmath/source/document.cxx
@@ -587,6 +587,7 @@ Printer* SmDocShell::GetPrt()
                                               SID_PRINTFRAME,      SID_PRINTFRAME,
                                               SID_NO_RIGHT_SPACES, SID_NO_RIGHT_SPACES,
                                               SID_SAVE_ONLY_USED_SYMBOLS, SID_SAVE_ONLY_USED_SYMBOLS,
+                                              SID_AUTO_CLOSE_BRACKETS,    SID_AUTO_CLOSE_BRACKETS,
                                               0);
         SmModule *pp = SM_MOD();
         pp->GetConfig()->ConfigToItemSet(*pOptions);
diff --git a/starmath/source/edit.cxx b/starmath/source/edit.cxx
index 26ab343..203740a 100644
--- a/starmath/source/edit.cxx
+++ b/starmath/source/edit.cxx
@@ -435,7 +435,11 @@ void SmEditWindow::KeyInput(const KeyEvent& rKEvt)
         aSelection.Adjust();
         OUString selected = pEditView->GetEditEngine()->GetText(aSelection);
 
-        if (selected.trim() == "<?>")
+        // Check is auto close brackets/braces is disabled
+        SmModule *pMod = SM_MOD();
+        if (pMod && !pMod->GetConfig()->IsAutoCloseBrackets())
+            autoClose = false;
+        else if (selected.trim() == "<?>")
             autoClose = true;
         else if (selected.isEmpty() && !aSelection.HasRange())
         {
diff --git a/starmath/source/smmod.cxx b/starmath/source/smmod.cxx
index 7ded9e3..45b5467 100644
--- a/starmath/source/smmod.cxx
+++ b/starmath/source/smmod.cxx
@@ -274,6 +274,7 @@ SfxItemSet*  SmModule::CreateItemSet( sal_uInt16 nId )
                              SID_PRINTFRAME,        SID_PRINTFRAME,
                              SID_NO_RIGHT_SPACES,   SID_NO_RIGHT_SPACES,
                              SID_SAVE_ONLY_USED_SYMBOLS, SID_SAVE_ONLY_USED_SYMBOLS,
+                             SID_AUTO_CLOSE_BRACKETS,    SID_AUTO_CLOSE_BRACKETS,
                              0 );
 
             GetConfig()->ConfigToItemSet(*pRet);
diff --git a/starmath/source/unomodel.cxx b/starmath/source/unomodel.cxx
index b1ecf5c..34bf51a 100644
--- a/starmath/source/unomodel.cxx
+++ b/starmath/source/unomodel.cxx
@@ -634,6 +634,7 @@ void SmModel::_setPropertyValues(const PropertyMapEntry** ppEntries, const Any*
                         SID_PRINTFRAME,      SID_PRINTFRAME,
                         SID_NO_RIGHT_SPACES, SID_NO_RIGHT_SPACES,
                         SID_SAVE_ONLY_USED_SYMBOLS, SID_SAVE_ONLY_USED_SYMBOLS,
+                        SID_AUTO_CLOSE_BRACKETS,    SID_AUTO_CLOSE_BRACKETS,
                         0
                     };
                     SfxItemSet *pItemSet = new SfxItemSet( SmDocShell::GetPool(), nRange );
diff --git a/starmath/uiconfig/smath/ui/smathsettings.ui b/starmath/uiconfig/smath/ui/smathsettings.ui
index 29f7487..3d9eabd 100644
--- a/starmath/uiconfig/smath/ui/smathsettings.ui
+++ b/starmath/uiconfig/smath/ui/smathsettings.ui
@@ -270,6 +270,22 @@
                     <property name="position">1</property>
                   </packing>
                 </child>
+                <child>
+                  <object class="GtkCheckButton" id="autoclosebrackets">
+                    <property name="label" translatable="yes">Auto close brackets, parentheses and braces</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="use_underline">True</property>
+                    <property name="xalign">0</property>
+                    <property name="draw_indicator">True</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">2</property>
+                  </packing>
+                </child>
               </object>
             </child>
           </object>


More information about the Libreoffice-commits mailing list