LibreOffice Module cui (master) 1
optfltr.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
21#include <unotools/fltrcfg.hxx>
22#include <officecfg/Office/Common.hxx>
23#include "optfltr.hxx"
24#include <strings.hrc>
25#include <dialmgr.hxx>
26
28 Math,
29 Writer,
30 Calc,
31 Impress,
33 Visio,
34 PDF,
36};
37
38
40 : SfxTabPage(pPage, pController, "cui/ui/optfltrpage.ui", "OptFltrPage", &rSet)
41 , m_xWBasicCodeCB(m_xBuilder->weld_check_button("wo_basic"))
42 , m_xWBasicWbctblCB(m_xBuilder->weld_check_button("wo_exec"))
43 , m_xWBasicStgCB(m_xBuilder->weld_check_button("wo_saveorig"))
44 , m_xEBasicCodeCB(m_xBuilder->weld_check_button("ex_basic"))
45 , m_xEBasicExectblCB(m_xBuilder->weld_check_button("ex_exec"))
46 , m_xEBasicStgCB(m_xBuilder->weld_check_button("ex_saveorig"))
47 , m_xPBasicCodeCB(m_xBuilder->weld_check_button("pp_basic"))
48 , m_xPBasicStgCB(m_xBuilder->weld_check_button("pp_saveorig"))
49{
50 m_xWBasicCodeCB->connect_toggled( LINK( this, OfaMSFilterTabPage, LoadWordBasicCheckHdl_Impl ) );
51 m_xEBasicCodeCB->connect_toggled( LINK( this, OfaMSFilterTabPage, LoadExcelBasicCheckHdl_Impl ) );
52}
53
55{
56}
57
58IMPL_LINK_NOARG(OfaMSFilterTabPage, LoadWordBasicCheckHdl_Impl, weld::Toggleable&, void)
59{
60 m_xWBasicWbctblCB->set_sensitive(m_xWBasicCodeCB->get_active());
61}
62
63IMPL_LINK_NOARG(OfaMSFilterTabPage, LoadExcelBasicCheckHdl_Impl, weld::Toggleable&, void)
64{
65 m_xEBasicExectblCB->set_sensitive(m_xEBasicCodeCB->get_active());
66}
67
68std::unique_ptr<SfxTabPage> OfaMSFilterTabPage::Create( weld::Container* pPage, weld::DialogController* pController,
69 const SfxItemSet* rAttrSet )
70{
71 return std::make_unique<OfaMSFilterTabPage>(pPage, pController, *rAttrSet);
72}
73
75{
77
78 if( m_xWBasicCodeCB->get_state_changed_from_saved() )
79 rOpt.SetLoadWordBasicCode( m_xWBasicCodeCB->get_active() );
80 if( m_xWBasicWbctblCB->get_state_changed_from_saved() )
82 if( m_xWBasicStgCB->get_state_changed_from_saved() )
83 rOpt.SetLoadWordBasicStorage( m_xWBasicStgCB->get_active() );
84
85 if( m_xEBasicCodeCB->get_state_changed_from_saved())
86 rOpt.SetLoadExcelBasicCode( m_xEBasicCodeCB->get_active() );
87 if( m_xEBasicExectblCB->get_state_changed_from_saved())
89 if( m_xEBasicStgCB->get_state_changed_from_saved())
90 rOpt.SetLoadExcelBasicStorage( m_xEBasicStgCB->get_active() );
91
92 if( m_xPBasicCodeCB->get_state_changed_from_saved())
93 rOpt.SetLoadPPointBasicCode( m_xPBasicCodeCB->get_active() );
94 if( m_xPBasicStgCB->get_state_changed_from_saved())
95 rOpt.SetLoadPPointBasicStorage( m_xPBasicStgCB->get_active() );
96
97 return false;
98}
99
101{
103
104 m_xWBasicCodeCB->set_active( rOpt.IsLoadWordBasicCode() );
105 m_xWBasicCodeCB->save_state();
106 m_xWBasicWbctblCB->set_active( rOpt.IsLoadWordBasicExecutable() );
107 m_xWBasicWbctblCB->save_state();
108 m_xWBasicStgCB->set_active( rOpt.IsLoadWordBasicStorage() );
109 m_xWBasicStgCB->save_state();
110 LoadWordBasicCheckHdl_Impl( *m_xWBasicCodeCB );
111
112 m_xEBasicCodeCB->set_active( rOpt.IsLoadExcelBasicCode() );
113 m_xEBasicCodeCB->save_state();
115 m_xEBasicExectblCB->save_state();
116 m_xEBasicStgCB->set_active( rOpt.IsLoadExcelBasicStorage() );
117 m_xEBasicStgCB->save_state();
118 LoadExcelBasicCheckHdl_Impl( *m_xEBasicCodeCB );
119
120 m_xPBasicCodeCB->set_active( rOpt.IsLoadPPointBasicCode() );
121 m_xPBasicCodeCB->save_state();
122 m_xPBasicStgCB->set_active( rOpt.IsLoadPPointBasicStorage() );
123 m_xPBasicStgCB->save_state();
124}
125
127 : SfxTabPage(pPage, pController, "cui/ui/optfltrembedpage.ui", "OptFilterPage", &rSet)
128 , sChgToFromMath(CuiResId(RID_CUISTR_CHG_MATH))
129 , sChgToFromWriter(CuiResId(RID_CUISTR_CHG_WRITER))
130 , sChgToFromCalc(CuiResId(RID_CUISTR_CHG_CALC))
131 , sChgToFromImpress(CuiResId(RID_CUISTR_CHG_IMPRESS))
132 , sChgToFromSmartArt(CuiResId(RID_CUISTR_CHG_SMARTART))
133 , sChgToFromVisio(CuiResId(RID_CUISTR_CHG_VISIO))
134 , sChgToFromPDF(CuiResId(RID_CUISTR_CHG_PDF))
135 , m_xCheckLB(m_xBuilder->weld_tree_view("checklbcontainer"))
136 , m_xHighlightingRB(m_xBuilder->weld_radio_button("highlighting"))
137 , m_xShadingRB(m_xBuilder->weld_radio_button("shading"))
138 , m_xMSOLockFileCB(m_xBuilder->weld_check_button("mso_lockfile"))
139{
140 std::vector<int> aWidths
141 {
142 m_xCheckLB->get_checkbox_column_width(),
143 m_xCheckLB->get_checkbox_column_width()
144 };
145 m_xCheckLB->set_column_fixed_widths(aWidths);
146}
147
149{
150}
151
152std::unique_ptr<SfxTabPage> OfaMSFilterTabPage2::Create( weld::Container* pPage, weld::DialogController* pController,
153 const SfxItemSet* rAttrSet )
154{
155 return std::make_unique<OfaMSFilterTabPage2>( pPage, pController, *rAttrSet );
156}
157
159{
161
162 static struct ChkCBoxEntries{
164 bool (SvtFilterOptions::*FnIs)() const;
165 void (SvtFilterOptions::*FnSet)( bool bFlag );
166 } const aChkArr[] = {
187 };
188
189 bool bFirstCol = true;
190 for( const ChkCBoxEntries & rEntry : aChkArr )
191 {
192 // we loop through the list, alternating reading the first/second column,
193 // each row appears twice in the list (except for smartart and later entries, which are
194 // import only)
195 sal_uInt16 nCol = bFirstCol ? 0 : 1;
196 bFirstCol = !bFirstCol;
197 int nEntry = GetEntry4Type(rEntry.eType);
198 if (nEntry != -1)
199 {
200 bool bCheck = m_xCheckLB->get_toggle(nEntry, nCol);
201 if( bCheck != (rOpt.*rEntry.FnIs)() )
202 (rOpt.*rEntry.FnSet)( bCheck );
203 }
204 if (rEntry.eType == MSFltrPg2_CheckBoxEntries::SmartArt)
205 {
206 bFirstCol = !bFirstCol;
207 }
208 }
210 bool bPDFCheck = m_xCheckLB->get_toggle(nPDFEntry, 0);
211 if (bPDFCheck != officecfg::Office::Common::Filter::Adobe::Import::PDFToDraw::get())
212 {
213 std::shared_ptr<comphelper::ConfigurationChanges> pBatch(
215 officecfg::Office::Common::Filter::Adobe::Import::PDFToDraw::set(bPDFCheck, pBatch);
216 pBatch->commit();
217 }
218
219 if( m_xHighlightingRB->get_state_changed_from_saved() )
220 {
221 if (m_xHighlightingRB->get_active())
223 else
225 }
226
227 if (m_xMSOLockFileCB->get_state_changed_from_saved())
228 {
230 }
231
232 return true;
233}
234
236{
238
239 m_xCheckLB->freeze();
240 m_xCheckLB->clear();
241
242 SvtModuleOptions aModuleOpt;
243
244 // int the same sequence as the enums of MSFltrPg2_CheckBoxEntries
255 {
258 }
259
260 static struct ChkCBoxEntries{
262 bool (SvtFilterOptions::*FnIs)() const;
263 } const aChkArr[] = {
275 };
276
277 bool bFirstCol = true;
278 for( const ChkCBoxEntries & rArr : aChkArr )
279 {
280 // we loop through the list, alternating reading the first/second column,
281 // each row appears twice in the list (except for smartart and later entries, which are
282 // import only)
283 sal_uInt16 nCol = bFirstCol ? 0 : 1;
284 bFirstCol = !bFirstCol;
285 int nEntry = GetEntry4Type( rArr.eType );
286 if (nEntry != -1)
287 {
288 bool bCheck = false;
289 if (rArr.eType != MSFltrPg2_CheckBoxEntries::PDF)
290 {
291 bCheck = (rOpt.*rArr.FnIs)();
292 }
293 else
294 {
295 bCheck = officecfg::Office::Common::Filter::Adobe::Import::PDFToDraw::get();
296 nCol = 0;
297 }
298 m_xCheckLB->set_toggle(nEntry, bCheck ? TRISTATE_TRUE : TRISTATE_FALSE, nCol);
299 }
300 if (rArr.eType == MSFltrPg2_CheckBoxEntries::SmartArt)
301 {
302 bFirstCol = !bFirstCol;
303 }
304 }
305 m_xCheckLB->thaw();
306
308 m_xHighlightingRB->set_active(true);
309 else
310 m_xShadingRB->set_active(true);
311
312 m_xHighlightingRB->save_state();
313
315 m_xMSOLockFileCB->save_state();
316 m_xMSOLockFileCB->set_sensitive(!officecfg::Office::Common::Filter::Microsoft::Import::CreateMSOLockFiles::isReadOnly());
317}
318
320{
321 InsertEntry( _rTxt, _nType, true );
322}
323
325 bool saveEnabled )
326{
327 int nPos = m_xCheckLB->n_children();
328 m_xCheckLB->append();
329 m_xCheckLB->set_toggle(nPos, TRISTATE_FALSE, 0);
330 if (saveEnabled)
331 m_xCheckLB->set_toggle(nPos, TRISTATE_FALSE, 1);
332 m_xCheckLB->set_text(nPos, _rTxt, 2);
333 m_xCheckLB->set_id(nPos, OUString::number(static_cast<sal_Int32>(_nType)));
334}
335
337{
338 for (int i = 0, nEntryCount = m_xCheckLB->n_children(); i < nEntryCount; ++i)
339 {
340 if (_nType == static_cast<MSFltrPg2_CheckBoxEntries>(m_xCheckLB->get_id(i).toInt32()))
341 return i;
342 }
343 return -1;
344}
345
346/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString sChgToFromImpress
Definition: optfltr.hxx:54
OUString sChgToFromVisio
Definition: optfltr.hxx:56
OUString sChgToFromCalc
Definition: optfltr.hxx:53
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: optfltr.cxx:158
virtual void Reset(const SfxItemSet *rSet) override
Definition: optfltr.cxx:235
OUString sChgToFromWriter
Definition: optfltr.hxx:52
std::unique_ptr< weld::RadioButton > m_xShadingRB
Definition: optfltr.hxx:61
OUString sChgToFromSmartArt
Definition: optfltr.hxx:55
std::unique_ptr< weld::CheckButton > m_xMSOLockFileCB
Definition: optfltr.hxx:62
OfaMSFilterTabPage2(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: optfltr.cxx:126
OUString sChgToFromMath
Definition: optfltr.hxx:51
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: optfltr.cxx:152
int GetEntry4Type(MSFltrPg2_CheckBoxEntries _nType) const
Definition: optfltr.cxx:336
std::unique_ptr< weld::TreeView > m_xCheckLB
Definition: optfltr.hxx:59
void InsertEntry(const OUString &_rTxt, MSFltrPg2_CheckBoxEntries _nType)
Definition: optfltr.cxx:319
OUString sChgToFromPDF
Definition: optfltr.hxx:57
std::unique_ptr< weld::RadioButton > m_xHighlightingRB
Definition: optfltr.hxx:60
virtual ~OfaMSFilterTabPage2() override
Definition: optfltr.cxx:148
std::unique_ptr< weld::CheckButton > m_xEBasicStgCB
Definition: optfltr.hxx:30
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: optfltr.cxx:74
std::unique_ptr< weld::CheckButton > m_xEBasicExectblCB
Definition: optfltr.hxx:29
std::unique_ptr< weld::CheckButton > m_xEBasicCodeCB
Definition: optfltr.hxx:28
std::unique_ptr< weld::CheckButton > m_xWBasicWbctblCB
Definition: optfltr.hxx:26
OfaMSFilterTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: optfltr.cxx:39
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: optfltr.cxx:68
virtual void Reset(const SfxItemSet *rSet) override
Definition: optfltr.cxx:100
std::unique_ptr< weld::CheckButton > m_xWBasicCodeCB
Definition: optfltr.hxx:25
virtual ~OfaMSFilterTabPage() override
Definition: optfltr.cxx:54
std::unique_ptr< weld::CheckButton > m_xPBasicCodeCB
Definition: optfltr.hxx:31
std::unique_ptr< weld::CheckButton > m_xPBasicStgCB
Definition: optfltr.hxx:32
std::unique_ptr< weld::CheckButton > m_xWBasicStgCB
Definition: optfltr.hxx:27
void SetCharBackground2Highlighting()
void SetLoadExcelBasicExecutable(bool bFlag)
bool IsLoadExcelBasicStorage() const
bool IsCharBackground2Highlighting() const
bool IsMathType2Math() const
void SetWriter2WinWord(bool bFlag)
bool IsLoadPPointBasicStorage() const
bool IsCalc2Excel() const
void SetImpress2PowerPoint(bool bFlag)
void SetMath2MathType(bool bFlag)
bool IsLoadExcelBasicExecutable() const
bool IsWinWord2Writer() const
static SvtFilterOptions & Get()
bool IsImpress2PowerPoint() const
void SetLoadWordBasicCode(bool bFlag)
void SetLoadPPointBasicStorage(bool bFlag)
void SetLoadExcelBasicStorage(bool bFlag)
void SetCharBackground2Shading()
void SetMathType2Math(bool bFlag)
void SetLoadWordBasicExecutable(bool bFlag)
bool IsLoadExcelBasicCode() const
bool IsWriter2WinWord() const
bool IsMSOLockFileCreationIsEnabled() const
void SetPowerPoint2Impress(bool bFlag)
void SetVisio2Draw(bool bFlag)
bool IsLoadWordBasicCode() const
void EnableMSOLockFileCreation(bool bEnable)
bool IsMath2MathType() const
void SetSmartArt2Shape(bool bFlag)
void SetLoadPPointBasicCode(bool bFlag)
bool IsLoadWordBasicStorage() const
void SetLoadWordBasicStorage(bool bFlag)
bool IsExcel2Calc() const
bool IsLoadWordBasicExecutable() const
bool IsPowerPoint2Impress() const
bool IsVisio2Draw() const
void SetCalc2Excel(bool bFlag)
void SetExcel2Calc(bool bFlag)
void SetWinWord2Writer(bool bFlag)
bool IsLoadPPointBasicCode() const
bool IsSmartArt2Shape() const
void SetLoadExcelBasicCode(bool bFlag)
bool IsModuleInstalled(EModule eModule) const
static std::shared_ptr< ConfigurationChanges > create()
OUString CuiResId(TranslateId aKey)
Definition: cuiresmgr.cxx:23
DocumentType eType
TRISTATE_FALSE
TRISTATE_TRUE
sal_uInt16 nPos
int i
IMPL_LINK_NOARG(OfaMSFilterTabPage, LoadWordBasicCheckHdl_Impl, weld::Toggleable &, void)
Definition: optfltr.cxx:58
MSFltrPg2_CheckBoxEntries
Definition: optfltr.cxx:27
static SfxItemSet & rSet