bump product version to 5.0.4.1
[LibreOffice.git] / cui / source / options / optbasic.cxx
blob913b8a230f0fc030d7d1abf41c3b583bfa6b1df1
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 <svtools/miscopt.hxx>
23 #include <iostream>
24 #include <officecfg/Office/BasicIDE.hxx>
25 #include <boost/shared_ptr.hpp>
26 #include <cuires.hrc>
28 SvxBasicIDEOptionsPage::SvxBasicIDEOptionsPage( vcl::Window* pParent, const SfxItemSet& rSet )
29 : SfxTabPage(pParent, "OptBasicIDEPage", "cui/ui/optbasicidepage.ui", &rSet)
31 SvtMiscOptions aMiscOpt;
32 if( ! aMiscOpt.IsExperimentalMode() )
34 Disable();
37 get(pCodeCompleteChk, "codecomplete_enable");
38 get(pAutocloseProcChk, "autoclose_proc");
39 get(pAutocloseParenChk, "autoclose_paren");
40 get(pAutocloseQuotesChk, "autoclose_quotes");
41 get(pAutoCorrectChk, "autocorrect");
42 get(pUseExtendedTypesChk, "extendedtypes_enable");
44 LoadConfig();
48 SvxBasicIDEOptionsPage::~SvxBasicIDEOptionsPage()
50 disposeOnce();
53 void SvxBasicIDEOptionsPage::dispose()
55 pCodeCompleteChk.clear();
56 pAutocloseProcChk.clear();
57 pAutocloseParenChk.clear();
58 pAutocloseQuotesChk.clear();
59 pAutoCorrectChk.clear();
60 pUseExtendedTypesChk.clear();
61 SfxTabPage::dispose();
64 void SvxBasicIDEOptionsPage::LoadConfig()
66 bool bProcClose = officecfg::Office::BasicIDE::Autocomplete::AutocloseProc::get();
67 bool bExtended = officecfg::Office::BasicIDE::Autocomplete::UseExtended::get();
68 bool bCodeCompleteOn = officecfg::Office::BasicIDE::Autocomplete::CodeComplete::get();
69 bool bParenClose = officecfg::Office::BasicIDE::Autocomplete::AutocloseParenthesis::get();
70 bool bQuoteClose = officecfg::Office::BasicIDE::Autocomplete::AutocloseDoubleQuotes::get();
71 bool bCorrect = officecfg::Office::BasicIDE::Autocomplete::AutoCorrect::get();
73 pCodeCompleteChk->Check( bCodeCompleteOn );
74 pAutocloseProcChk->Check( bProcClose );
75 pAutocloseQuotesChk->Check( bQuoteClose );
76 pAutocloseParenChk->Check( bParenClose );
77 pAutoCorrectChk->Check( bCorrect );
78 pUseExtendedTypesChk->Check( bExtended );
81 bool SvxBasicIDEOptionsPage::FillItemSet( SfxItemSet* /*rCoreSet*/ )
83 bool bModified = false;
84 std::shared_ptr< comphelper::ConfigurationChanges > batch( comphelper::ConfigurationChanges::create() );
86 if( pAutocloseProcChk->IsValueChangedFromSaved() )
88 officecfg::Office::BasicIDE::Autocomplete::AutocloseProc::set( pAutocloseProcChk->IsChecked(), batch );
89 CodeCompleteOptions::SetProcedureAutoCompleteOn( pAutocloseProcChk->IsChecked() );
90 bModified = true;
93 if( pCodeCompleteChk->IsValueChangedFromSaved() )
95 //std::shared_ptr< comphelper::ConfigurationChanges > batch( comphelper::ConfigurationChanges::create() );
96 officecfg::Office::BasicIDE::Autocomplete::CodeComplete::set( pCodeCompleteChk->IsChecked(), batch );
97 CodeCompleteOptions::SetCodeCompleteOn( pCodeCompleteChk->IsChecked() );
98 bModified = true;
101 if( pUseExtendedTypesChk->IsValueChangedFromSaved() )
103 officecfg::Office::BasicIDE::Autocomplete::UseExtended::set( pUseExtendedTypesChk->IsChecked(), batch );
104 CodeCompleteOptions::SetExtendedTypeDeclaration( pUseExtendedTypesChk->IsChecked() );
105 bModified = true;
108 if( pAutocloseParenChk->IsValueChangedFromSaved() )
110 officecfg::Office::BasicIDE::Autocomplete::AutocloseParenthesis::set( pAutocloseParenChk->IsChecked(), batch );
111 CodeCompleteOptions::SetAutoCloseParenthesisOn( pAutocloseParenChk->IsChecked() );
112 bModified = true;
115 if( pAutocloseQuotesChk->IsValueChangedFromSaved() )
117 officecfg::Office::BasicIDE::Autocomplete::AutocloseDoubleQuotes::set( pAutocloseQuotesChk->IsChecked(), batch );
118 CodeCompleteOptions::SetAutoCloseQuotesOn( pAutocloseQuotesChk->IsChecked() );
119 bModified = true;
122 if( pAutoCorrectChk->IsValueChangedFromSaved() )
124 officecfg::Office::BasicIDE::Autocomplete::AutoCorrect::set( pAutoCorrectChk->IsChecked(), batch );
125 CodeCompleteOptions::SetAutoCorrectOn( pAutoCorrectChk->IsChecked() );
126 bModified = true;
129 if( bModified )
130 batch->commit();
132 return bModified;
135 void SvxBasicIDEOptionsPage::Reset( const SfxItemSet* /*rSet*/ )
137 LoadConfig();
138 pCodeCompleteChk->SaveValue();
140 pAutocloseProcChk->SaveValue();
142 pAutocloseQuotesChk->SaveValue();
144 pAutocloseParenChk->SaveValue();
146 pAutoCorrectChk->SaveValue();
148 pUseExtendedTypesChk->SaveValue();
151 VclPtr<SfxTabPage> SvxBasicIDEOptionsPage::Create( vcl::Window* pParent, const SfxItemSet* rAttrSet )
153 return VclPtr<SvxBasicIDEOptionsPage>::Create( pParent, *rAttrSet );
156 void SvxBasicIDEOptionsPage::FillUserData()
158 OUString aUserData;
159 SetUserData( aUserData );
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */