summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authorMarcos Paulo de Souza <marcos.souza.org@gmail.com>2015-11-02 21:43:24 -0200
committerCaolán McNamara <caolanm@redhat.com>2015-11-10 11:54:27 +0000
commite2bfbfcb809329b9ed0bdd2fee14f343ca3603dd (patch)
treed3608f5b5b4056d81d28985237dbdebee8c8621f /starmath
parent66094c6ab5776d0ce871621922b90140e01982a6 (diff)
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@gmail.com> Reviewed-on: https://gerrit.libreoffice.org/19750 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'starmath')
-rw-r--r--starmath/inc/dialog.hxx1
-rw-r--r--starmath/inc/starmath.hrc1
-rw-r--r--starmath/source/cfgitem.cxx28
-rw-r--r--starmath/source/cfgitem.hxx2
-rw-r--r--starmath/source/dialog.cxx4
-rw-r--r--starmath/source/document.cxx1
-rw-r--r--starmath/source/edit.cxx6
-rw-r--r--starmath/source/smmod.cxx1
-rw-r--r--starmath/source/unomodel.cxx1
-rw-r--r--starmath/uiconfig/smath/ui/smathsettings.ui16
10 files changed, 59 insertions, 2 deletions
diff --git a/starmath/inc/dialog.hxx b/starmath/inc/dialog.hxx
index 16cf98d3857e..4e7f374268ae 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 9a64513dfd91..cefa6c538a20 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 858479d6cd1f..d6c91b76cb8a 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 c6c00de898c8..fecded401287 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 cd53905ee03a..e0431796750c 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 5ed4579a00b1..7430f589f562 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 26ab3433b54c..203740a7b3fa 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 7ded9e325851..45b546704c51 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 b1ecf5c4fdc5..34bf51a1b21d 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 29f7487bbf94..3d9eabd93d74 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>