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,
32  SmartArt,
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_clicked( LINK( this, OfaMSFilterTabPage, LoadWordBasicCheckHdl_Impl ) );
51  m_xEBasicCodeCB->connect_clicked( LINK( this, OfaMSFilterTabPage, LoadExcelBasicCheckHdl_Impl ) );
52 }
53 
55 {
56 }
57 
58 IMPL_LINK_NOARG(OfaMSFilterTabPage, LoadWordBasicCheckHdl_Impl, weld::Button&, void)
59 {
60  m_xWBasicWbctblCB->set_sensitive(m_xWBasicCodeCB->get_active());
61 }
62 
63 IMPL_LINK_NOARG(OfaMSFilterTabPage, LoadExcelBasicCheckHdl_Impl, weld::Button&, void)
64 {
65  m_xEBasicExectblCB->set_sensitive(m_xEBasicCodeCB->get_active());
66 }
67 
68 std::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() )
81  rOpt.SetLoadWordBasicExecutable( m_xWBasicWbctblCB->get_active() );
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())
88  rOpt.SetLoadExcelBasicExecutable( m_xEBasicExectblCB->get_active() );
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 {
102  const SvtFilterOptions& rOpt = SvtFilterOptions::Get();
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();
114  m_xEBasicExectblCB->set_active( rOpt.IsLoadExcelBasicExecutable() );
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_SVXSTR_CHG_MATH))
129  , sChgToFromWriter(CuiResId(RID_SVXSTR_CHG_WRITER))
130  , sChgToFromCalc(CuiResId(RID_SVXSTR_CHG_CALC))
131  , sChgToFromImpress(CuiResId(RID_SVXSTR_CHG_IMPRESS))
132  , sChgToFromSmartArt(CuiResId(RID_SVXSTR_CHG_SMARTART))
133  , sChgToFromVisio(CuiResId(RID_SVXSTR_CHG_VISIO))
134  , sChgToFromPDF(CuiResId(RID_SVXSTR_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  aWidths.push_back(m_xCheckLB->get_checkbox_column_width());
142  aWidths.push_back(m_xCheckLB->get_checkbox_column_width());
143  m_xCheckLB->set_column_fixed_widths(aWidths);
144 }
145 
147 {
148 }
149 
150 std::unique_ptr<SfxTabPage> OfaMSFilterTabPage2::Create( weld::Container* pPage, weld::DialogController* pController,
151  const SfxItemSet* rAttrSet )
152 {
153  return std::make_unique<OfaMSFilterTabPage2>( pPage, pController, *rAttrSet );
154 }
155 
157 {
159 
160  static struct ChkCBoxEntries{
162  bool (SvtFilterOptions:: *FnIs)() const;
163  void (SvtFilterOptions:: *FnSet)( bool bFlag );
164  } const aChkArr[] = {
185  };
186 
187  bool bFirstCol = true;
188  for( const ChkCBoxEntries & rEntry : aChkArr )
189  {
190  // we loop through the list, alternating reading the first/second column,
191  // each row appears twice in the list (except for smartart and later entries, which are
192  // import only)
193  sal_uInt16 nCol = bFirstCol ? 0 : 1;
194  bFirstCol = !bFirstCol;
195  int nEntry = GetEntry4Type(rEntry.eType);
196  if (nEntry != -1)
197  {
198  bool bCheck = m_xCheckLB->get_toggle(nEntry, nCol);
199  if( bCheck != (rOpt.*rEntry.FnIs)() )
200  (rOpt.*rEntry.FnSet)( bCheck );
201  }
202  if (rEntry.eType == MSFltrPg2_CheckBoxEntries::SmartArt)
203  {
204  bFirstCol = !bFirstCol;
205  }
206  }
208  bool bPDFCheck = m_xCheckLB->get_toggle(nPDFEntry, 0);
209  if (bPDFCheck != officecfg::Office::Common::Filter::Adobe::Import::PDFToDraw::get())
210  {
211  std::shared_ptr<comphelper::ConfigurationChanges> pBatch(
213  officecfg::Office::Common::Filter::Adobe::Import::PDFToDraw::set(bPDFCheck, pBatch);
214  pBatch->commit();
215  }
216 
217  if( m_xHighlightingRB->get_state_changed_from_saved() )
218  {
219  if (m_xHighlightingRB->get_active())
221  else
223  }
224 
225  if (m_xMSOLockFileCB->get_state_changed_from_saved())
226  {
227  rOpt.EnableMSOLockFileCreation(m_xMSOLockFileCB->get_active());
228  }
229 
230  return true;
231 }
232 
234 {
236 
237  m_xCheckLB->freeze();
238  m_xCheckLB->clear();
239 
240  SvtModuleOptions aModuleOpt;
241 
242  // int the same sequence as the enums of MSFltrPg2_CheckBoxEntries
253  {
256  }
257 
258  static struct ChkCBoxEntries{
260  bool (SvtFilterOptions:: *FnIs)() const;
261  } const aChkArr[] = {
272  { MSFltrPg2_CheckBoxEntries::PDF, nullptr },
273  };
274 
275  bool bFirstCol = true;
276  for( const ChkCBoxEntries & rArr : aChkArr )
277  {
278  // we loop through the list, alternating reading the first/second column,
279  // each row appears twice in the list (except for smartart and later entries, which are
280  // import only)
281  sal_uInt16 nCol = bFirstCol ? 0 : 1;
282  bFirstCol = !bFirstCol;
283  int nEntry = GetEntry4Type( rArr.eType );
284  if (nEntry != -1)
285  {
286  bool bCheck = false;
287  if (rArr.eType != MSFltrPg2_CheckBoxEntries::PDF)
288  {
289  bCheck = (rOpt.*rArr.FnIs)();
290  }
291  else
292  {
293  bCheck = officecfg::Office::Common::Filter::Adobe::Import::PDFToDraw::get();
294  nCol = 0;
295  }
296  m_xCheckLB->set_toggle(nEntry, bCheck ? TRISTATE_TRUE : TRISTATE_FALSE, nCol);
297  }
298  if (rArr.eType == MSFltrPg2_CheckBoxEntries::SmartArt)
299  {
300  bFirstCol = !bFirstCol;
301  }
302  }
303  m_xCheckLB->thaw();
304 
306  m_xHighlightingRB->set_active(true);
307  else
308  m_xShadingRB->set_active(true);
309 
310  m_xHighlightingRB->save_state();
311 
313  m_xMSOLockFileCB->save_state();
314  m_xMSOLockFileCB->set_sensitive(!officecfg::Office::Common::Filter::Microsoft::Import::CreateMSOLockFiles::isReadOnly());
315 }
316 
317 void OfaMSFilterTabPage2::InsertEntry( const OUString& _rTxt, MSFltrPg2_CheckBoxEntries _nType )
318 {
319  InsertEntry( _rTxt, _nType, true );
320 }
321 
323  bool saveEnabled )
324 {
325  int nPos = m_xCheckLB->n_children();
326  m_xCheckLB->append();
327  m_xCheckLB->set_toggle(nPos, TRISTATE_FALSE, 0);
328  if (saveEnabled)
329  m_xCheckLB->set_toggle(nPos, TRISTATE_FALSE, 1);
330  m_xCheckLB->set_text(nPos, _rTxt, 2);
331  m_xCheckLB->set_id(nPos, OUString::number(static_cast<sal_Int32>(_nType)));
332 }
333 
335 {
336  for (int i = 0, nEntryCount = m_xCheckLB->n_children(); i < nEntryCount; ++i)
337  {
338  if (_nType == static_cast<MSFltrPg2_CheckBoxEntries>(m_xCheckLB->get_id(i).toInt32()))
339  return i;
340  }
341  return -1;
342 }
343 
344 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< weld::CheckButton > m_xWBasicStgCB
Definition: optfltr.hxx:28
void SetCalc2Excel(bool bFlag)
bool IsMathType2Math() const
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: optfltr.cxx:156
bool IsMSOLockFileCreationIsEnabled() const
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: optfltr.cxx:74
OUString sChgToFromImpress
Definition: optfltr.hxx:52
void SetPowerPoint2Impress(bool bFlag)
virtual ~OfaMSFilterTabPage() override
Definition: optfltr.cxx:54
bool IsModuleInstalled(EModule eModule) const
std::unique_ptr< weld::CheckButton > m_xPBasicStgCB
Definition: optfltr.hxx:33
virtual ~OfaMSFilterTabPage2() override
Definition: optfltr.cxx:146
bool IsLoadExcelBasicCode() const
void SetLoadExcelBasicExecutable(bool bFlag)
bool IsLoadExcelBasicExecutable() const
bool IsImpress2PowerPoint() const
std::unique_ptr< weld::CheckButton > m_xEBasicCodeCB
Definition: optfltr.hxx:29
void SetLoadPPointBasicStorage(bool bFlag)
void SetLoadExcelBasicCode(bool bFlag)
bool IsMath2MathType() const
OUString sChgToFromPDF
Definition: optfltr.hxx:52
void SetLoadExcelBasicStorage(bool bFlag)
TRISTATE_TRUE
std::unique_ptr< weld::CheckButton > m_xPBasicCodeCB
Definition: optfltr.hxx:32
virtual void Reset(const SfxItemSet *rSet) override
Definition: optfltr.cxx:100
std::unique_ptr< weld::RadioButton > m_xHighlightingRB
Definition: optfltr.hxx:61
void SetVisio2Draw(bool bFlag)
void SetMath2MathType(bool bFlag)
OfaMSFilterTabPage2(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: optfltr.cxx:126
void SetWriter2WinWord(bool bFlag)
bool IsCalc2Excel() const
std::unique_ptr< weld::RadioButton > m_xShadingRB
Definition: optfltr.hxx:62
static std::shared_ptr< ConfigurationChanges > create(css::uno::Reference< css::uno::XComponentContext > const &context=comphelper::getProcessComponentContext())
bool IsLoadWordBasicExecutable() const
IMPL_LINK_NOARG(OfaMSFilterTabPage, LoadWordBasicCheckHdl_Impl, weld::Button &, void)
Definition: optfltr.cxx:58
void InsertEntry(const OUString &_rTxt, MSFltrPg2_CheckBoxEntries _nType)
Definition: optfltr.cxx:317
std::unique_ptr< weld::TreeView > m_xCheckLB
Definition: optfltr.hxx:60
bool IsLoadWordBasicCode() const
void SetImpress2PowerPoint(bool bFlag)
int GetEntry4Type(MSFltrPg2_CheckBoxEntries _nType) const
Definition: optfltr.cxx:334
OUString sChgToFromVisio
Definition: optfltr.hxx:52
static SvtFilterOptions & Get()
std::unique_ptr< weld::CheckButton > m_xWBasicWbctblCB
Definition: optfltr.hxx:27
void SetExcel2Calc(bool bFlag)
OUString sChgToFromWriter
Definition: optfltr.hxx:52
MSFltrPg2_CheckBoxEntries
Definition: optfltr.cxx:27
void SetSmartArt2Shape(bool bFlag)
bool IsLoadPPointBasicCode() const
int i
bool IsLoadPPointBasicStorage() const
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: optfltr.cxx:68
TRISTATE_FALSE
bool IsPowerPoint2Impress() const
std::unique_ptr< weld::CheckButton > m_xEBasicExectblCB
Definition: optfltr.hxx:30
void SetCharBackground2Highlighting()
OUString sChgToFromMath
Definition: optfltr.hxx:52
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: optfltr.cxx:150
bool IsWriter2WinWord() const
OUString sChgToFromCalc
Definition: optfltr.hxx:52
DocumentType const eType
std::unique_ptr< weld::CheckButton > m_xWBasicCodeCB
Definition: optfltr.hxx:26
void SetLoadPPointBasicCode(bool bFlag)
OUString CuiResId(const char *pKey)
Definition: cuiresmgr.cxx:23
bool IsSmartArt2Shape() const
void SetLoadWordBasicCode(bool bFlag)
void EnableMSOLockFileCreation(bool bEnable)
bool IsWinWord2Writer() const
void SetCharBackground2Shading()
void SetLoadWordBasicExecutable(bool bFlag)
std::unique_ptr< weld::CheckButton > m_xEBasicStgCB
Definition: optfltr.hxx:31
bool IsLoadWordBasicStorage() const
void SetMathType2Math(bool bFlag)
bool IsCharBackground2Highlighting() const
bool IsExcel2Calc() const
virtual void Reset(const SfxItemSet *rSet) override
Definition: optfltr.cxx:233
bool IsVisio2Draw() const
sal_Int32 nPos
void SetWinWord2Writer(bool bFlag)
OfaMSFilterTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: optfltr.cxx:39
OUString sChgToFromSmartArt
Definition: optfltr.hxx:52
void SetLoadWordBasicStorage(bool bFlag)
std::unique_ptr< weld::CheckButton > m_xMSOLockFileCB
Definition: optfltr.hxx:63
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo
bool IsLoadExcelBasicStorage() const