Kaydet (Commit) e2bfbfcb authored tarafından Marcos Paulo de Souza's avatar Marcos Paulo de Souza Kaydeden (comit) Caolán McNamara

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: 's avatarMarcos Paulo de Souza <marcos.souza.org@gmail.com>
Reviewed-on: https://gerrit.libreoffice.org/19750Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 66094c6a
...@@ -329,6 +329,16 @@ ...@@ -329,6 +329,16 @@
</info> </info>
<value>true</value> <value>true</value>
</prop> </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>
<group oor:name="View"> <group oor:name="View">
<info> <info>
......
...@@ -61,6 +61,7 @@ class SmPrintOptionsTabPage : public SfxTabPage ...@@ -61,6 +61,7 @@ class SmPrintOptionsTabPage : public SfxTabPage
VclPtr<MetricField> m_pZoom; VclPtr<MetricField> m_pZoom;
VclPtr<CheckBox> m_pNoRightSpaces; VclPtr<CheckBox> m_pNoRightSpaces;
VclPtr<CheckBox> m_pSaveOnlyUsedSymbols; VclPtr<CheckBox> m_pSaveOnlyUsedSymbols;
VclPtr<CheckBox> m_pAutoCloseBrackets;
DECL_LINK_TYPED(SizeButtonClickHdl, Button *, void); DECL_LINK_TYPED(SizeButtonClickHdl, Button *, void);
......
...@@ -75,6 +75,7 @@ ...@@ -75,6 +75,7 @@
#define SID_NO_RIGHT_SPACES (SID_SMA_START + 124) #define SID_NO_RIGHT_SPACES (SID_SMA_START + 124)
#define SID_SAVE_ONLY_USED_SYMBOLS (SID_SMA_START + 125) #define SID_SAVE_ONLY_USED_SYMBOLS (SID_SMA_START + 125)
#define SID_ELEMENTSDOCKINGWINDOW (SID_SMA_START + 126) #define SID_ELEMENTSDOCKINGWINDOW (SID_SMA_START + 126)
#define SID_AUTO_CLOSE_BRACKETS (SID_SMA_START + 127)
#define RID_PRINTUIOPTIONS (RID_APP_START + 11) #define RID_PRINTUIOPTIONS (RID_APP_START + 11)
......
...@@ -123,6 +123,7 @@ struct SmCfgOther ...@@ -123,6 +123,7 @@ struct SmCfgOther
bool bPrintFormulaText; bool bPrintFormulaText;
bool bPrintFrame; bool bPrintFrame;
bool bIsSaveOnlyUsedSymbols; bool bIsSaveOnlyUsedSymbols;
bool bIsAutoCloseBrackets;
bool bIgnoreSpacesRight; bool bIgnoreSpacesRight;
bool bToolboxVisible; bool bToolboxVisible;
bool bAutoRedraw; bool bAutoRedraw;
...@@ -139,7 +140,8 @@ SmCfgOther::SmCfgOther() ...@@ -139,7 +140,8 @@ SmCfgOther::SmCfgOther()
bPrintTitle = bPrintFormulaText = bPrintTitle = bPrintFormulaText =
bPrintFrame = bIgnoreSpacesRight = bPrintFrame = bIgnoreSpacesRight =
bToolboxVisible = bAutoRedraw = bToolboxVisible = bAutoRedraw =
bFormulaCursor = bIsSaveOnlyUsedSymbols = true; bIsAutoCloseBrackets = bFormulaCursor
= bIsSaveOnlyUsedSymbols = true;
} }
...@@ -780,6 +782,7 @@ void SmMathConfig::LoadOther() ...@@ -780,6 +782,7 @@ void SmMathConfig::LoadOther()
pOther->ePrintSize = static_cast<SmPrintSize>(officecfg::Office::Math::Print::Size::get()); pOther->ePrintSize = static_cast<SmPrintSize>(officecfg::Office::Math::Print::Size::get());
pOther->nPrintZoomFactor = officecfg::Office::Math::Print::ZoomFactor::get(); pOther->nPrintZoomFactor = officecfg::Office::Math::Print::ZoomFactor::get();
pOther->bIsSaveOnlyUsedSymbols = officecfg::Office::Math::LoadSave::IsSaveOnlyUsedSymbols::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->bIgnoreSpacesRight = officecfg::Office::Math::Misc::IgnoreSpacesRight::get();
pOther->bToolboxVisible = officecfg::Office::Math::View::ToolboxVisible::get(); pOther->bToolboxVisible = officecfg::Office::Math::View::ToolboxVisible::get();
pOther->bAutoRedraw = officecfg::Office::Math::View::AutoRedraw::get(); pOther->bAutoRedraw = officecfg::Office::Math::View::AutoRedraw::get();
...@@ -801,6 +804,7 @@ void SmMathConfig::SaveOther() ...@@ -801,6 +804,7 @@ void SmMathConfig::SaveOther()
officecfg::Office::Math::Print::Size::set(pOther->ePrintSize, batch); officecfg::Office::Math::Print::Size::set(pOther->ePrintSize, batch);
officecfg::Office::Math::Print::ZoomFactor::set(pOther->nPrintZoomFactor, batch); officecfg::Office::Math::Print::ZoomFactor::set(pOther->nPrintZoomFactor, batch);
officecfg::Office::Math::LoadSave::IsSaveOnlyUsedSymbols::set(pOther->bIsSaveOnlyUsedSymbols, 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::Misc::IgnoreSpacesRight::set(pOther->bIgnoreSpacesRight, batch);
officecfg::Office::Math::View::ToolboxVisible::set(pOther->bToolboxVisible, batch); officecfg::Office::Math::View::ToolboxVisible::set(pOther->bToolboxVisible, batch);
officecfg::Office::Math::View::AutoRedraw::set(pOther->bAutoRedraw, batch); officecfg::Office::Math::View::AutoRedraw::set(pOther->bAutoRedraw, batch);
...@@ -1067,6 +1071,13 @@ bool SmMathConfig::IsSaveOnlyUsedSymbols() const ...@@ -1067,6 +1071,13 @@ bool SmMathConfig::IsSaveOnlyUsedSymbols() const
return pOther->bIsSaveOnlyUsedSymbols; return pOther->bIsSaveOnlyUsedSymbols;
} }
bool SmMathConfig::IsAutoCloseBrackets() const
{
if (!pOther)
const_cast<SmMathConfig*>(this)->LoadOther();
return pOther->bIsAutoCloseBrackets;
}
bool SmMathConfig::IsPrintFrame() const bool SmMathConfig::IsPrintFrame() const
{ {
if (!pOther) if (!pOther)
...@@ -1091,6 +1102,14 @@ void SmMathConfig::SetSaveOnlyUsedSymbols( bool bVal ) ...@@ -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 bool SmMathConfig::IsIgnoreSpacesRight() const
{ {
if (!pOther) if (!pOther)
...@@ -1187,6 +1206,12 @@ void SmMathConfig::ItemSetToConfig(const SfxItemSet &rSet) ...@@ -1187,6 +1206,12 @@ void SmMathConfig::ItemSetToConfig(const SfxItemSet &rSet)
SetSaveOnlyUsedSymbols( bVal ); SetSaveOnlyUsedSymbols( bVal );
} }
if (rSet.GetItemState(SID_AUTO_CLOSE_BRACKETS, true, &pItem) == SfxItemState::SET)
{
bVal = static_cast<const SfxBoolItem *>(pItem)->GetValue();
SetAutoCloseBrackets( bVal );
}
SaveOther(); SaveOther();
} }
...@@ -1206,6 +1231,7 @@ void SmMathConfig::ConfigToItemSet(SfxItemSet &rSet) const ...@@ -1206,6 +1231,7 @@ void SmMathConfig::ConfigToItemSet(SfxItemSet &rSet) const
rSet.Put(SfxBoolItem(pPool->GetWhich(SID_AUTOREDRAW), IsAutoRedraw())); rSet.Put(SfxBoolItem(pPool->GetWhich(SID_AUTOREDRAW), IsAutoRedraw()));
rSet.Put(SfxBoolItem(pPool->GetWhich(SID_NO_RIGHT_SPACES), IsIgnoreSpacesRight())); 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_SAVE_ONLY_USED_SYMBOLS), IsSaveOnlyUsedSymbols()));
rSet.Put(SfxBoolItem(pPool->GetWhich(SID_AUTO_CLOSE_BRACKETS), IsAutoCloseBrackets()));
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -168,6 +168,8 @@ public: ...@@ -168,6 +168,8 @@ public:
bool IsSaveOnlyUsedSymbols() const; bool IsSaveOnlyUsedSymbols() const;
void SetSaveOnlyUsedSymbols( bool bVal ); void SetSaveOnlyUsedSymbols( bool bVal );
bool IsAutoCloseBrackets() const;
void SetAutoCloseBrackets( bool bVal );
bool IsIgnoreSpacesRight() const; bool IsIgnoreSpacesRight() const;
void SetIgnoreSpacesRight( bool bVal ); void SetIgnoreSpacesRight( bool bVal );
bool IsAutoRedraw() const; bool IsAutoRedraw() const;
......
...@@ -176,6 +176,7 @@ SmPrintOptionsTabPage::SmPrintOptionsTabPage(vcl::Window* pParent, const SfxItem ...@@ -176,6 +176,7 @@ SmPrintOptionsTabPage::SmPrintOptionsTabPage(vcl::Window* pParent, const SfxItem
get( m_pZoom, "zoom"); get( m_pZoom, "zoom");
get( m_pNoRightSpaces, "norightspaces"); get( m_pNoRightSpaces, "norightspaces");
get( m_pSaveOnlyUsedSymbols, "saveonlyusedsymbols"); get( m_pSaveOnlyUsedSymbols, "saveonlyusedsymbols");
get( m_pAutoCloseBrackets, "autoclosebrackets");
m_pSizeNormal->SetClickHdl(LINK(this, SmPrintOptionsTabPage, SizeButtonClickHdl)); m_pSizeNormal->SetClickHdl(LINK(this, SmPrintOptionsTabPage, SizeButtonClickHdl));
m_pSizeScaled->SetClickHdl(LINK(this, SmPrintOptionsTabPage, SizeButtonClickHdl)); m_pSizeScaled->SetClickHdl(LINK(this, SmPrintOptionsTabPage, SizeButtonClickHdl));
...@@ -200,6 +201,7 @@ void SmPrintOptionsTabPage::dispose() ...@@ -200,6 +201,7 @@ void SmPrintOptionsTabPage::dispose()
m_pZoom.clear(); m_pZoom.clear();
m_pNoRightSpaces.clear(); m_pNoRightSpaces.clear();
m_pSaveOnlyUsedSymbols.clear(); m_pSaveOnlyUsedSymbols.clear();
m_pAutoCloseBrackets.clear();
SfxTabPage::dispose(); SfxTabPage::dispose();
} }
...@@ -221,6 +223,7 @@ bool SmPrintOptionsTabPage::FillItemSet(SfxItemSet* rSet) ...@@ -221,6 +223,7 @@ bool SmPrintOptionsTabPage::FillItemSet(SfxItemSet* rSet)
rSet->Put(SfxBoolItem(GetWhich(SID_PRINTFRAME), m_pFrame->IsChecked())); 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_NO_RIGHT_SPACES), m_pNoRightSpaces->IsChecked()));
rSet->Put(SfxBoolItem(GetWhich(SID_SAVE_ONLY_USED_SYMBOLS), m_pSaveOnlyUsedSymbols->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; return true;
} }
...@@ -243,6 +246,7 @@ void SmPrintOptionsTabPage::Reset(const SfxItemSet* rSet) ...@@ -243,6 +246,7 @@ void SmPrintOptionsTabPage::Reset(const SfxItemSet* rSet)
m_pFrame->Check(static_cast<const SfxBoolItem &>(rSet->Get(GetWhich(SID_PRINTFRAME))).GetValue()); 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_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_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) VclPtr<SfxTabPage> SmPrintOptionsTabPage::Create(vcl::Window* pWindow, const SfxItemSet& rSet)
......
...@@ -587,6 +587,7 @@ Printer* SmDocShell::GetPrt() ...@@ -587,6 +587,7 @@ Printer* SmDocShell::GetPrt()
SID_PRINTFRAME, SID_PRINTFRAME, SID_PRINTFRAME, SID_PRINTFRAME,
SID_NO_RIGHT_SPACES, SID_NO_RIGHT_SPACES, SID_NO_RIGHT_SPACES, SID_NO_RIGHT_SPACES,
SID_SAVE_ONLY_USED_SYMBOLS, SID_SAVE_ONLY_USED_SYMBOLS, SID_SAVE_ONLY_USED_SYMBOLS, SID_SAVE_ONLY_USED_SYMBOLS,
SID_AUTO_CLOSE_BRACKETS, SID_AUTO_CLOSE_BRACKETS,
0); 0);
SmModule *pp = SM_MOD(); SmModule *pp = SM_MOD();
pp->GetConfig()->ConfigToItemSet(*pOptions); pp->GetConfig()->ConfigToItemSet(*pOptions);
......
...@@ -435,7 +435,11 @@ void SmEditWindow::KeyInput(const KeyEvent& rKEvt) ...@@ -435,7 +435,11 @@ void SmEditWindow::KeyInput(const KeyEvent& rKEvt)
aSelection.Adjust(); aSelection.Adjust();
OUString selected = pEditView->GetEditEngine()->GetText(aSelection); 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; autoClose = true;
else if (selected.isEmpty() && !aSelection.HasRange()) else if (selected.isEmpty() && !aSelection.HasRange())
{ {
......
...@@ -274,6 +274,7 @@ SfxItemSet* SmModule::CreateItemSet( sal_uInt16 nId ) ...@@ -274,6 +274,7 @@ SfxItemSet* SmModule::CreateItemSet( sal_uInt16 nId )
SID_PRINTFRAME, SID_PRINTFRAME, SID_PRINTFRAME, SID_PRINTFRAME,
SID_NO_RIGHT_SPACES, SID_NO_RIGHT_SPACES, SID_NO_RIGHT_SPACES, SID_NO_RIGHT_SPACES,
SID_SAVE_ONLY_USED_SYMBOLS, SID_SAVE_ONLY_USED_SYMBOLS, SID_SAVE_ONLY_USED_SYMBOLS, SID_SAVE_ONLY_USED_SYMBOLS,
SID_AUTO_CLOSE_BRACKETS, SID_AUTO_CLOSE_BRACKETS,
0 ); 0 );
GetConfig()->ConfigToItemSet(*pRet); GetConfig()->ConfigToItemSet(*pRet);
......
...@@ -634,6 +634,7 @@ void SmModel::_setPropertyValues(const PropertyMapEntry** ppEntries, const Any* ...@@ -634,6 +634,7 @@ void SmModel::_setPropertyValues(const PropertyMapEntry** ppEntries, const Any*
SID_PRINTFRAME, SID_PRINTFRAME, SID_PRINTFRAME, SID_PRINTFRAME,
SID_NO_RIGHT_SPACES, SID_NO_RIGHT_SPACES, SID_NO_RIGHT_SPACES, SID_NO_RIGHT_SPACES,
SID_SAVE_ONLY_USED_SYMBOLS, SID_SAVE_ONLY_USED_SYMBOLS, SID_SAVE_ONLY_USED_SYMBOLS, SID_SAVE_ONLY_USED_SYMBOLS,
SID_AUTO_CLOSE_BRACKETS, SID_AUTO_CLOSE_BRACKETS,
0 0
}; };
SfxItemSet *pItemSet = new SfxItemSet( SmDocShell::GetPool(), nRange ); SfxItemSet *pItemSet = new SfxItemSet( SmDocShell::GetPool(), nRange );
......
...@@ -270,6 +270,22 @@ ...@@ -270,6 +270,22 @@
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </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> </object>
</child> </child>
</object> </object>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment