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 
27 #include <vcl/event.hxx>
28 #include <vcl/svlbitm.hxx>
29 #include <vcl/treelistentry.hxx>
30 
32  Math,
33  Writer,
34  Calc,
35  Impress,
36  SmartArt,
37  Visio,
38  PDF,
40 };
41 
42 
44  : SfxTabPage(pParent, "cui/ui/optfltrpage.ui", "OptFltrPage", &rSet)
45  , m_xWBasicCodeCB(m_xBuilder->weld_check_button("wo_basic"))
46  , m_xWBasicWbctblCB(m_xBuilder->weld_check_button("wo_exec"))
47  , m_xWBasicStgCB(m_xBuilder->weld_check_button("wo_saveorig"))
48  , m_xEBasicCodeCB(m_xBuilder->weld_check_button("ex_basic"))
49  , m_xEBasicExectblCB(m_xBuilder->weld_check_button("ex_exec"))
50  , m_xEBasicStgCB(m_xBuilder->weld_check_button("ex_saveorig"))
51  , m_xPBasicCodeCB(m_xBuilder->weld_check_button("pp_basic"))
52  , m_xPBasicStgCB(m_xBuilder->weld_check_button("pp_saveorig"))
53 {
54  m_xWBasicCodeCB->connect_clicked( LINK( this, OfaMSFilterTabPage, LoadWordBasicCheckHdl_Impl ) );
55  m_xEBasicCodeCB->connect_clicked( LINK( this, OfaMSFilterTabPage, LoadExcelBasicCheckHdl_Impl ) );
56 }
57 
59 {
60 }
61 
62 IMPL_LINK_NOARG(OfaMSFilterTabPage, LoadWordBasicCheckHdl_Impl, weld::Button&, void)
63 {
64  m_xWBasicWbctblCB->set_sensitive(m_xWBasicCodeCB->get_active());
65 }
66 
67 IMPL_LINK_NOARG(OfaMSFilterTabPage, LoadExcelBasicCheckHdl_Impl, weld::Button&, void)
68 {
69  m_xEBasicExectblCB->set_sensitive(m_xEBasicCodeCB->get_active());
70 }
71 
73  const SfxItemSet* rAttrSet )
74 {
75  return VclPtr<OfaMSFilterTabPage>::Create(pParent, *rAttrSet);
76 }
77 
79 {
81 
82  if( m_xWBasicCodeCB->get_state_changed_from_saved() )
83  rOpt.SetLoadWordBasicCode( m_xWBasicCodeCB->get_active() );
84  if( m_xWBasicWbctblCB->get_state_changed_from_saved() )
85  rOpt.SetLoadWordBasicExecutable( m_xWBasicWbctblCB->get_active() );
86  if( m_xWBasicStgCB->get_state_changed_from_saved() )
87  rOpt.SetLoadWordBasicStorage( m_xWBasicStgCB->get_active() );
88 
89  if( m_xEBasicCodeCB->get_state_changed_from_saved())
90  rOpt.SetLoadExcelBasicCode( m_xEBasicCodeCB->get_active() );
91  if( m_xEBasicExectblCB->get_state_changed_from_saved())
92  rOpt.SetLoadExcelBasicExecutable( m_xEBasicExectblCB->get_active() );
93  if( m_xEBasicStgCB->get_state_changed_from_saved())
94  rOpt.SetLoadExcelBasicStorage( m_xEBasicStgCB->get_active() );
95 
96  if( m_xPBasicCodeCB->get_state_changed_from_saved())
97  rOpt.SetLoadPPointBasicCode( m_xPBasicCodeCB->get_active() );
98  if( m_xPBasicStgCB->get_state_changed_from_saved())
99  rOpt.SetLoadPPointBasicStorage( m_xPBasicStgCB->get_active() );
100 
101  return false;
102 }
103 
105 {
106  const SvtFilterOptions& rOpt = SvtFilterOptions::Get();
107 
108  m_xWBasicCodeCB->set_active( rOpt.IsLoadWordBasicCode() );
109  m_xWBasicCodeCB->save_state();
110  m_xWBasicWbctblCB->set_active( rOpt.IsLoadWordBasicExecutable() );
111  m_xWBasicWbctblCB->save_state();
112  m_xWBasicStgCB->set_active( rOpt.IsLoadWordBasicStorage() );
113  m_xWBasicStgCB->save_state();
114  LoadWordBasicCheckHdl_Impl( *m_xWBasicCodeCB );
115 
116  m_xEBasicCodeCB->set_active( rOpt.IsLoadExcelBasicCode() );
117  m_xEBasicCodeCB->save_state();
118  m_xEBasicExectblCB->set_active( rOpt.IsLoadExcelBasicExecutable() );
119  m_xEBasicExectblCB->save_state();
120  m_xEBasicStgCB->set_active( rOpt.IsLoadExcelBasicStorage() );
121  m_xEBasicStgCB->save_state();
122  LoadExcelBasicCheckHdl_Impl( *m_xEBasicCodeCB );
123 
124  m_xPBasicCodeCB->set_active( rOpt.IsLoadPPointBasicCode() );
125  m_xPBasicCodeCB->save_state();
126  m_xPBasicStgCB->set_active( rOpt.IsLoadPPointBasicStorage() );
127  m_xPBasicStgCB->save_state();
128 }
129 
131  : SfxTabPage(pParent, "cui/ui/optfltrembedpage.ui", "OptFilterPage", &rSet)
132  , sChgToFromMath(CuiResId(RID_SVXSTR_CHG_MATH))
133  , sChgToFromWriter(CuiResId(RID_SVXSTR_CHG_WRITER))
134  , sChgToFromCalc(CuiResId(RID_SVXSTR_CHG_CALC))
135  , sChgToFromImpress(CuiResId(RID_SVXSTR_CHG_IMPRESS))
136  , sChgToFromSmartArt(CuiResId(RID_SVXSTR_CHG_SMARTART))
137  , sChgToFromVisio(CuiResId(RID_SVXSTR_CHG_VISIO))
138  , sChgToFromPDF(CuiResId(RID_SVXSTR_CHG_PDF))
139  , m_xCheckLB(m_xBuilder->weld_tree_view("checklbcontainer"))
140  , m_xHighlightingRB(m_xBuilder->weld_radio_button("highlighting"))
141  , m_xShadingRB(m_xBuilder->weld_radio_button("shading"))
142  , m_xMSOLockFileCB(m_xBuilder->weld_check_button("mso_lockfile"))
143 {
144  Size aControlSize(248, 55);
145  aControlSize = LogicToPixel(aControlSize, MapMode(MapUnit::MapAppFont));
146 
147  std::vector<int> aWidths;
148  aWidths.push_back(m_xCheckLB->get_checkbox_column_width());
149  aWidths.push_back(m_xCheckLB->get_checkbox_column_width());
150  m_xCheckLB->set_column_fixed_widths(aWidths);
151 }
152 
154 {
155 }
156 
158  const SfxItemSet* rAttrSet )
159 {
160  return VclPtr<OfaMSFilterTabPage2>::Create( pParent, *rAttrSet );
161 }
162 
164 {
166 
167  static struct ChkCBoxEntries{
169  bool (SvtFilterOptions:: *FnIs)() const;
170  void (SvtFilterOptions:: *FnSet)( bool bFlag );
171  } const aChkArr[] = {
192  };
193 
194  bool bFirstCol = true;
195  for( const ChkCBoxEntries & rEntry : aChkArr )
196  {
197  // we loop through the list, alternating reading the first/second column,
198  // each row appears twice in the list (except for smartart and later entries, which are
199  // import only)
200  sal_uInt16 nCol = bFirstCol ? 0 : 1;
201  bFirstCol = !bFirstCol;
202  int nEntry = GetEntry4Type(rEntry.eType);
203  if (nEntry != -1)
204  {
205  bool bCheck = m_xCheckLB->get_toggle(nEntry, nCol);
206  if( bCheck != (rOpt.*rEntry.FnIs)() )
207  (rOpt.*rEntry.FnSet)( bCheck );
208  }
209  if (rEntry.eType == MSFltrPg2_CheckBoxEntries::SmartArt)
210  {
211  bFirstCol = !bFirstCol;
212  }
213  }
215  bool bPDFCheck = m_xCheckLB->get_toggle(nPDFEntry, 0);
216  if (bPDFCheck != officecfg::Office::Common::Filter::Adobe::Import::PDFToDraw::get())
217  {
218  std::shared_ptr<comphelper::ConfigurationChanges> pBatch(
220  officecfg::Office::Common::Filter::Adobe::Import::PDFToDraw::set(bPDFCheck, pBatch);
221  pBatch->commit();
222  }
223 
224  if( m_xHighlightingRB->get_state_changed_from_saved() )
225  {
226  if (m_xHighlightingRB->get_active())
228  else
230  }
231 
232  if (m_xMSOLockFileCB->get_state_changed_from_saved())
233  {
234  rOpt.EnableMSOLockFileCreation(m_xMSOLockFileCB->get_active());
235  }
236 
237  return true;
238 }
239 
241 {
243 
244  m_xCheckLB->freeze();
245  m_xCheckLB->clear();
246 
247  SvtModuleOptions aModuleOpt;
248 
249  // int the same sequence as the enums of MSFltrPg2_CheckBoxEntries
260  {
263  }
264 
265  static struct ChkCBoxEntries{
267  bool (SvtFilterOptions:: *FnIs)() const;
268  } const aChkArr[] = {
279  { MSFltrPg2_CheckBoxEntries::PDF, nullptr },
280  };
281 
282  bool bFirstCol = true;
283  for( const ChkCBoxEntries & rArr : aChkArr )
284  {
285  // we loop through the list, alternating reading the first/second column,
286  // each row appears twice in the list (except for smartart and later entries, which are
287  // import only)
288  sal_uInt16 nCol = bFirstCol ? 0 : 1;
289  bFirstCol = !bFirstCol;
290  int nEntry = GetEntry4Type( rArr.eType );
291  if (nEntry != -1)
292  {
293  bool bCheck = false;
294  if (rArr.eType != MSFltrPg2_CheckBoxEntries::PDF)
295  {
296  bCheck = (rOpt.*rArr.FnIs)();
297  }
298  else
299  {
300  bCheck = officecfg::Office::Common::Filter::Adobe::Import::PDFToDraw::get();
301  nCol = 0;
302  }
303  m_xCheckLB->set_toggle(nEntry, bCheck ? TRISTATE_TRUE : TRISTATE_FALSE, nCol);
304  }
305  if (rArr.eType == MSFltrPg2_CheckBoxEntries::SmartArt)
306  {
307  bFirstCol = !bFirstCol;
308  }
309  }
310  m_xCheckLB->thaw();
311 
313  m_xHighlightingRB->set_active(true);
314  else
315  m_xShadingRB->set_active(true);
316 
317  m_xHighlightingRB->save_state();
318 
320  m_xMSOLockFileCB->save_state();
321  m_xMSOLockFileCB->set_sensitive(!officecfg::Office::Common::Filter::Microsoft::Import::CreateMSOLockFiles::isReadOnly());
322 }
323 
324 void OfaMSFilterTabPage2::InsertEntry( const OUString& _rTxt, MSFltrPg2_CheckBoxEntries _nType )
325 {
326  InsertEntry( _rTxt, _nType, true );
327 }
328 
330  bool saveEnabled )
331 {
332  int nPos = m_xCheckLB->n_children();
333  m_xCheckLB->append();
334  m_xCheckLB->set_toggle(nPos, TRISTATE_FALSE, 0);
335  if (saveEnabled)
336  m_xCheckLB->set_toggle(nPos, TRISTATE_FALSE, 1);
337  m_xCheckLB->set_text(nPos, _rTxt, 2);
338  m_xCheckLB->set_id(nPos, OUString::number(static_cast<sal_Int32>(_nType)));
339 }
340 
342 {
343  for (int i = 0, nEntryCount = m_xCheckLB->n_children(); i < nEntryCount; ++i)
344  {
345  if (_nType == static_cast<MSFltrPg2_CheckBoxEntries>(m_xCheckLB->get_id(i).toInt32()))
346  return i;
347  }
348  return -1;
349 }
350 
351 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< weld::CheckButton > m_xWBasicStgCB
Definition: optfltr.hxx:30
void SetCalc2Excel(bool bFlag)
bool IsMathType2Math() const
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: optfltr.cxx:163
bool IsMSOLockFileCreationIsEnabled() const
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: optfltr.cxx:78
static VclPtr< SfxTabPage > Create(TabPageParent pParent, const SfxItemSet *rAttrSet)
Definition: optfltr.cxx:157
OUString sChgToFromImpress
Definition: optfltr.hxx:54
void SetPowerPoint2Impress(bool bFlag)
virtual ~OfaMSFilterTabPage() override
Definition: optfltr.cxx:58
bool IsModuleInstalled(EModule eModule) const
std::unique_ptr< weld::CheckButton > m_xPBasicStgCB
Definition: optfltr.hxx:35
virtual ~OfaMSFilterTabPage2() override
Definition: optfltr.cxx:153
bool IsLoadExcelBasicCode() const
void SetLoadExcelBasicExecutable(bool bFlag)
bool IsLoadExcelBasicExecutable() const
bool IsImpress2PowerPoint() const
std::unique_ptr< weld::CheckButton > m_xEBasicCodeCB
Definition: optfltr.hxx:31
void SetLoadPPointBasicStorage(bool bFlag)
void SetLoadExcelBasicCode(bool bFlag)
bool IsMath2MathType() const
OUString sChgToFromPDF
Definition: optfltr.hxx:54
void SetLoadExcelBasicStorage(bool bFlag)
TRISTATE_TRUE
std::unique_ptr< weld::CheckButton > m_xPBasicCodeCB
Definition: optfltr.hxx:34
virtual void Reset(const SfxItemSet *rSet) override
Definition: optfltr.cxx:104
std::unique_ptr< weld::RadioButton > m_xHighlightingRB
Definition: optfltr.hxx:63
void SetVisio2Draw(bool bFlag)
void SetMath2MathType(bool bFlag)
void SetWriter2WinWord(bool bFlag)
bool IsCalc2Excel() const
std::unique_ptr< weld::RadioButton > m_xShadingRB
Definition: optfltr.hxx:64
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:62
void InsertEntry(const OUString &_rTxt, MSFltrPg2_CheckBoxEntries _nType)
Definition: optfltr.cxx:324
std::unique_ptr< weld::TreeView > m_xCheckLB
Definition: optfltr.hxx:62
bool IsLoadWordBasicCode() const
void SetImpress2PowerPoint(bool bFlag)
int GetEntry4Type(MSFltrPg2_CheckBoxEntries _nType) const
Definition: optfltr.cxx:341
OUString sChgToFromVisio
Definition: optfltr.hxx:54
static SvtFilterOptions & Get()
std::unique_ptr< weld::CheckButton > m_xWBasicWbctblCB
Definition: optfltr.hxx:29
void SetExcel2Calc(bool bFlag)
OUString sChgToFromWriter
Definition: optfltr.hxx:54
MSFltrPg2_CheckBoxEntries
Definition: optfltr.cxx:31
void SetSmartArt2Shape(bool bFlag)
bool IsLoadPPointBasicCode() const
OfaMSFilterTabPage(TabPageParent pParent, const SfxItemSet &rSet)
Definition: optfltr.cxx:43
int i
bool IsLoadPPointBasicStorage() const
TRISTATE_FALSE
bool IsPowerPoint2Impress() const
std::unique_ptr< weld::CheckButton > m_xEBasicExectblCB
Definition: optfltr.hxx:32
void SetCharBackground2Highlighting()
OUString sChgToFromMath
Definition: optfltr.hxx:54
bool IsWriter2WinWord() const
OUString sChgToFromCalc
Definition: optfltr.hxx:54
DocumentType const eType
std::unique_ptr< weld::CheckButton > m_xWBasicCodeCB
Definition: optfltr.hxx:28
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:33
static VclPtr< reference_type > Create(Arg &&...arg)
bool IsLoadWordBasicStorage() const
void SetMathType2Math(bool bFlag)
bool IsCharBackground2Highlighting() const
OfaMSFilterTabPage2(TabPageParent pParent, const SfxItemSet &rSet)
Definition: optfltr.cxx:130
bool IsExcel2Calc() const
virtual void Reset(const SfxItemSet *rSet) override
Definition: optfltr.cxx:240
bool IsVisio2Draw() const
sal_Int32 nPos
void SetWinWord2Writer(bool bFlag)
OUString sChgToFromSmartArt
Definition: optfltr.hxx:54
void SetLoadWordBasicStorage(bool bFlag)
std::unique_ptr< weld::CheckButton > m_xMSOLockFileCB
Definition: optfltr.hxx:65
static VclPtr< SfxTabPage > Create(TabPageParent pParent, const SfxItemSet *rAttrSet)
Definition: optfltr.cxx:72
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo
bool IsLoadExcelBasicStorage() const