Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / cui / source / options / optbasic.cxx
blobc550d9440edd148e1db9633ab502f9a35e4b3c03
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "optbasic.hxx"
21 #include <basic/codecompletecache.hxx>
22 #include <officecfg/Office/BasicIDE.hxx>
24 SvxBasicIDEOptionsPage::SvxBasicIDEOptionsPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
25 : SfxTabPage(pPage, pController, "cui/ui/optbasicidepage.ui", "OptBasicIDEPage", &rSet)
26 , m_xCodeCompleteChk(m_xBuilder->weld_check_button("codecomplete_enable"))
27 , m_xAutocloseProcChk(m_xBuilder->weld_check_button("autoclose_proc"))
28 , m_xAutocloseParenChk(m_xBuilder->weld_check_button("autoclose_paren"))
29 , m_xAutocloseQuotesChk(m_xBuilder->weld_check_button("autoclose_quotes"))
30 , m_xAutoCorrectChk(m_xBuilder->weld_check_button("autocorrect"))
31 , m_xUseExtendedTypesChk(m_xBuilder->weld_check_button("extendedtypes_enable"))
33 LoadConfig();
36 SvxBasicIDEOptionsPage::~SvxBasicIDEOptionsPage()
40 void SvxBasicIDEOptionsPage::LoadConfig()
42 m_xCodeCompleteChk->set_active( officecfg::Office::BasicIDE::Autocomplete::CodeComplete::get() );
43 m_xCodeCompleteChk->set_sensitive( !officecfg::Office::BasicIDE::Autocomplete::CodeComplete::isReadOnly() );
44 m_xAutocloseProcChk->set_active( officecfg::Office::BasicIDE::Autocomplete::AutocloseProc::get() );
45 m_xAutocloseProcChk->set_sensitive( !officecfg::Office::BasicIDE::Autocomplete::AutocloseProc::isReadOnly() );
46 m_xAutocloseQuotesChk->set_active( officecfg::Office::BasicIDE::Autocomplete::AutocloseDoubleQuotes::get() );
47 m_xAutocloseQuotesChk->set_sensitive( !officecfg::Office::BasicIDE::Autocomplete::AutocloseDoubleQuotes::isReadOnly() );
48 m_xAutocloseParenChk->set_active( officecfg::Office::BasicIDE::Autocomplete::AutocloseParenthesis::get() );
49 m_xAutocloseParenChk->set_sensitive( !officecfg::Office::BasicIDE::Autocomplete::AutocloseParenthesis::isReadOnly() );
50 m_xAutoCorrectChk->set_active( officecfg::Office::BasicIDE::Autocomplete::AutoCorrect::get() );
51 m_xAutoCorrectChk->set_sensitive( !officecfg::Office::BasicIDE::Autocomplete::AutoCorrect::isReadOnly() );
52 m_xUseExtendedTypesChk->set_active( officecfg::Office::BasicIDE::Autocomplete::UseExtended::get() );
53 m_xUseExtendedTypesChk->set_sensitive( !officecfg::Office::BasicIDE::Autocomplete::UseExtended::isReadOnly() );
56 bool SvxBasicIDEOptionsPage::FillItemSet( SfxItemSet* /*rCoreSet*/ )
58 bool bModified = false;
59 std::shared_ptr< comphelper::ConfigurationChanges > batch( comphelper::ConfigurationChanges::create() );
61 if( m_xAutocloseProcChk->get_state_changed_from_saved() )
63 officecfg::Office::BasicIDE::Autocomplete::AutocloseProc::set( m_xAutocloseProcChk->get_active(), batch );
64 CodeCompleteOptions::SetProcedureAutoCompleteOn( m_xAutocloseProcChk->get_active() );
65 bModified = true;
68 if( m_xCodeCompleteChk->get_state_changed_from_saved() )
70 //std::shared_ptr< comphelper::ConfigurationChanges > batch( comphelper::ConfigurationChanges::create() );
71 officecfg::Office::BasicIDE::Autocomplete::CodeComplete::set( m_xCodeCompleteChk->get_active(), batch );
72 CodeCompleteOptions::SetCodeCompleteOn( m_xCodeCompleteChk->get_active() );
73 bModified = true;
76 if( m_xUseExtendedTypesChk->get_state_changed_from_saved() )
78 officecfg::Office::BasicIDE::Autocomplete::UseExtended::set( m_xUseExtendedTypesChk->get_active(), batch );
79 CodeCompleteOptions::SetExtendedTypeDeclaration( m_xUseExtendedTypesChk->get_active() );
80 bModified = true;
83 if( m_xAutocloseParenChk->get_state_changed_from_saved() )
85 officecfg::Office::BasicIDE::Autocomplete::AutocloseParenthesis::set( m_xAutocloseParenChk->get_active(), batch );
86 CodeCompleteOptions::SetAutoCloseParenthesisOn( m_xAutocloseParenChk->get_active() );
87 bModified = true;
90 if( m_xAutocloseQuotesChk->get_state_changed_from_saved() )
92 officecfg::Office::BasicIDE::Autocomplete::AutocloseDoubleQuotes::set( m_xAutocloseQuotesChk->get_active(), batch );
93 CodeCompleteOptions::SetAutoCloseQuotesOn( m_xAutocloseQuotesChk->get_active() );
94 bModified = true;
97 if( m_xAutoCorrectChk->get_state_changed_from_saved() )
99 officecfg::Office::BasicIDE::Autocomplete::AutoCorrect::set( m_xAutoCorrectChk->get_active(), batch );
100 CodeCompleteOptions::SetAutoCorrectOn( m_xAutoCorrectChk->get_active() );
101 bModified = true;
104 if( bModified )
105 batch->commit();
107 return bModified;
110 void SvxBasicIDEOptionsPage::Reset( const SfxItemSet* /*rSet*/ )
112 LoadConfig();
113 m_xCodeCompleteChk->save_state();
114 m_xAutocloseProcChk->save_state();
115 m_xAutocloseQuotesChk->save_state();
116 m_xAutocloseParenChk->save_state();
117 m_xAutoCorrectChk->save_state();
118 m_xUseExtendedTypesChk->save_state();
121 std::unique_ptr<SfxTabPage> SvxBasicIDEOptionsPage::Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet )
123 return std::make_unique<SvxBasicIDEOptionsPage>(pPage, pController, *rAttrSet);
126 void SvxBasicIDEOptionsPage::FillUserData()
128 SetUserData( OUString() );
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */