diff options
Diffstat (limited to 'cui/source/options/optfltr.cxx')
-rw-r--r-- | cui/source/options/optfltr.cxx | 472 |
1 files changed, 472 insertions, 0 deletions
diff --git a/cui/source/options/optfltr.cxx b/cui/source/options/optfltr.cxx new file mode 100644 index 0000000000..b582b065bc --- /dev/null +++ b/cui/source/options/optfltr.cxx @@ -0,0 +1,472 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <unotools/moduleoptions.hxx> +#include <unotools/fltrcfg.hxx> +#include <officecfg/Office/Common.hxx> +#include <officecfg/Office/Calc.hxx> +#include <officecfg/Office/Writer.hxx> +#include <officecfg/Office/Impress.hxx> +#include "optfltr.hxx" +#include <strings.hrc> +#include <dialmgr.hxx> + +enum class MSFltrPg2_CheckBoxEntries { + Math, + Writer, + Calc, + Impress, + SmartArt, + Visio, + PDF, + InvalidCBEntry +}; + + +OfaMSFilterTabPage::OfaMSFilterTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet) + : SfxTabPage(pPage, pController, "cui/ui/optfltrpage.ui", "OptFltrPage", &rSet) + , m_xWBasicCodeCB(m_xBuilder->weld_check_button("wo_basic")) + , m_xWBasicCodeImg(m_xBuilder->weld_widget("lockwo_basic")) + , m_xWBasicWbctblCB(m_xBuilder->weld_check_button("wo_exec")) + , m_xWBasicWbctblImg(m_xBuilder->weld_widget("lockwo_exec")) + , m_xWBasicStgCB(m_xBuilder->weld_check_button("wo_saveorig")) + , m_xWBasicStgImg(m_xBuilder->weld_widget("lockwo_saveorig")) + , m_xEBasicCodeCB(m_xBuilder->weld_check_button("ex_basic")) + , m_xEBasicCodeImg(m_xBuilder->weld_widget("lockex_basic")) + , m_xEBasicExectblCB(m_xBuilder->weld_check_button("ex_exec")) + , m_xEBasicExectblImg(m_xBuilder->weld_widget("lockex_exec")) + , m_xEBasicStgCB(m_xBuilder->weld_check_button("ex_saveorig")) + , m_xEBasicStgImg(m_xBuilder->weld_widget("lockex_saveorig")) + , m_xPBasicCodeCB(m_xBuilder->weld_check_button("pp_basic")) + , m_xPBasicCodeImg(m_xBuilder->weld_widget("lockpp_basic")) + , m_xPBasicStgCB(m_xBuilder->weld_check_button("pp_saveorig")) + , m_xPBasicStgImg(m_xBuilder->weld_widget("lockpp_saveorig")) +{ + m_xWBasicCodeCB->connect_toggled( LINK( this, OfaMSFilterTabPage, LoadWordBasicCheckHdl_Impl ) ); + m_xEBasicCodeCB->connect_toggled( LINK( this, OfaMSFilterTabPage, LoadExcelBasicCheckHdl_Impl ) ); +} + +OfaMSFilterTabPage::~OfaMSFilterTabPage() +{ +} + +IMPL_LINK_NOARG(OfaMSFilterTabPage, LoadWordBasicCheckHdl_Impl, weld::Toggleable&, void) +{ + m_xWBasicWbctblCB->set_sensitive(m_xWBasicCodeCB->get_active() && !officecfg::Office::Writer::Filter::Import::VBA::Executable::isReadOnly()); + m_xWBasicWbctblImg->set_visible(officecfg::Office::Writer::Filter::Import::VBA::Executable::isReadOnly()); +} + +IMPL_LINK_NOARG(OfaMSFilterTabPage, LoadExcelBasicCheckHdl_Impl, weld::Toggleable&, void) +{ + m_xEBasicExectblCB->set_sensitive(m_xEBasicCodeCB->get_active() && !officecfg::Office::Calc::Filter::Import::VBA::Executable::isReadOnly()); + m_xEBasicExectblImg->set_visible(officecfg::Office::Calc::Filter::Import::VBA::Executable::isReadOnly()); +} + +std::unique_ptr<SfxTabPage> OfaMSFilterTabPage::Create( weld::Container* pPage, weld::DialogController* pController, + const SfxItemSet* rAttrSet ) +{ + return std::make_unique<OfaMSFilterTabPage>(pPage, pController, *rAttrSet); +} + +OUString OfaMSFilterTabPage::GetAllStrings() +{ + OUString sAllStrings; + OUString labels[] = { "label1", "label2", "label3" }; + + for (const auto& label : labels) + { + if (const auto& pString = m_xBuilder->weld_label(label)) + sAllStrings += pString->get_label() + " "; + } + + OUString checkButton[] = { "wo_basic", "wo_exec", "wo_saveorig", "ex_basic", + "ex_exec", "ex_saveorig", "pp_basic", "pp_saveorig" }; + + for (const auto& check : checkButton) + { + if (const auto& pString = m_xBuilder->weld_check_button(check)) + sAllStrings += pString->get_label() + " "; + } + + return sAllStrings.replaceAll("_", ""); +} + +bool OfaMSFilterTabPage::FillItemSet( SfxItemSet* ) +{ + SvtFilterOptions& rOpt = SvtFilterOptions::Get(); + + if( m_xWBasicCodeCB->get_state_changed_from_saved() ) + rOpt.SetLoadWordBasicCode( m_xWBasicCodeCB->get_active() ); + if( m_xWBasicWbctblCB->get_state_changed_from_saved() ) + rOpt.SetLoadWordBasicExecutable( m_xWBasicWbctblCB->get_active() ); + if( m_xWBasicStgCB->get_state_changed_from_saved() ) + rOpt.SetLoadWordBasicStorage( m_xWBasicStgCB->get_active() ); + + if( m_xEBasicCodeCB->get_state_changed_from_saved()) + rOpt.SetLoadExcelBasicCode( m_xEBasicCodeCB->get_active() ); + if( m_xEBasicExectblCB->get_state_changed_from_saved()) + rOpt.SetLoadExcelBasicExecutable( m_xEBasicExectblCB->get_active() ); + if( m_xEBasicStgCB->get_state_changed_from_saved()) + rOpt.SetLoadExcelBasicStorage( m_xEBasicStgCB->get_active() ); + + if( m_xPBasicCodeCB->get_state_changed_from_saved()) + rOpt.SetLoadPPointBasicCode( m_xPBasicCodeCB->get_active() ); + if( m_xPBasicStgCB->get_state_changed_from_saved()) + rOpt.SetLoadPPointBasicStorage( m_xPBasicStgCB->get_active() ); + + return false; +} + +void OfaMSFilterTabPage::Reset( const SfxItemSet* ) +{ + const SvtFilterOptions& rOpt = SvtFilterOptions::Get(); + + m_xWBasicCodeCB->set_active( rOpt.IsLoadWordBasicCode() ); + m_xWBasicCodeCB->set_sensitive(!officecfg::Office::Writer::Filter::Import::VBA::Load::isReadOnly()); + m_xWBasicCodeImg->set_visible(officecfg::Office::Writer::Filter::Import::VBA::Load::isReadOnly()); + m_xWBasicCodeCB->save_state(); + m_xWBasicWbctblCB->set_active( rOpt.IsLoadWordBasicExecutable() ); + m_xWBasicWbctblCB->set_sensitive(!officecfg::Office::Writer::Filter::Import::VBA::Executable::isReadOnly()); + m_xWBasicWbctblImg->set_visible(officecfg::Office::Writer::Filter::Import::VBA::Executable::isReadOnly()); + m_xWBasicWbctblCB->save_state(); + m_xWBasicStgCB->set_active( rOpt.IsLoadWordBasicStorage() ); + m_xWBasicStgCB->set_sensitive(!officecfg::Office::Writer::Filter::Import::VBA::Save::isReadOnly()); + m_xWBasicStgImg->set_visible(officecfg::Office::Writer::Filter::Import::VBA::Save::isReadOnly()); + m_xWBasicStgCB->save_state(); + LoadWordBasicCheckHdl_Impl( *m_xWBasicCodeCB ); + + m_xEBasicCodeCB->set_active( rOpt.IsLoadExcelBasicCode() ); + m_xEBasicCodeCB->set_sensitive(!officecfg::Office::Calc::Filter::Import::VBA::Load::isReadOnly()); + m_xEBasicCodeImg->set_visible(officecfg::Office::Calc::Filter::Import::VBA::Load::isReadOnly()); + m_xEBasicCodeCB->save_state(); + m_xEBasicExectblCB->set_active( rOpt.IsLoadExcelBasicExecutable() ); + m_xEBasicExectblCB->set_sensitive(!officecfg::Office::Calc::Filter::Import::VBA::Executable::isReadOnly()); + m_xEBasicExectblImg->set_visible(officecfg::Office::Calc::Filter::Import::VBA::Executable::isReadOnly()); + m_xEBasicExectblCB->save_state(); + m_xEBasicStgCB->set_active( rOpt.IsLoadExcelBasicStorage() ); + m_xEBasicStgCB->set_sensitive(!officecfg::Office::Calc::Filter::Import::VBA::Save::isReadOnly()); + m_xEBasicStgImg->set_visible(officecfg::Office::Calc::Filter::Import::VBA::Save::isReadOnly()); + m_xEBasicStgCB->save_state(); + LoadExcelBasicCheckHdl_Impl( *m_xEBasicCodeCB ); + + m_xPBasicCodeCB->set_active( rOpt.IsLoadPPointBasicCode() ); + m_xPBasicCodeCB->set_sensitive(!officecfg::Office::Impress::Filter::Import::VBA::Load::isReadOnly()); + m_xPBasicCodeImg->set_visible(officecfg::Office::Impress::Filter::Import::VBA::Load::isReadOnly()); + m_xPBasicCodeCB->save_state(); + m_xPBasicStgCB->set_active( rOpt.IsLoadPPointBasicStorage() ); + m_xPBasicStgCB->set_sensitive(!officecfg::Office::Impress::Filter::Import::VBA::Save::isReadOnly()); + m_xPBasicStgImg->set_visible(officecfg::Office::Impress::Filter::Import::VBA::Save::isReadOnly()); + m_xPBasicStgCB->save_state(); +} + +OfaMSFilterTabPage2::OfaMSFilterTabPage2(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet) + : SfxTabPage(pPage, pController, "cui/ui/optfltrembedpage.ui", "OptFilterPage", &rSet) + , sChgToFromMath(CuiResId(RID_CUISTR_CHG_MATH)) + , sChgToFromWriter(CuiResId(RID_CUISTR_CHG_WRITER)) + , sChgToFromCalc(CuiResId(RID_CUISTR_CHG_CALC)) + , sChgToFromImpress(CuiResId(RID_CUISTR_CHG_IMPRESS)) + , sChgToFromSmartArt(CuiResId(RID_CUISTR_CHG_SMARTART)) + , sChgToFromVisio(CuiResId(RID_CUISTR_CHG_VISIO)) + , sChgToFromPDF(CuiResId(RID_CUISTR_CHG_PDF)) + , m_xCheckLB(m_xBuilder->weld_tree_view("checklbcontainer")) + , m_xHighlightingFT(m_xBuilder->weld_label("label5")) + , m_xHighlightingRB(m_xBuilder->weld_radio_button("highlighting")) + , m_xShadingRB(m_xBuilder->weld_radio_button("shading")) + , m_xShadingImg(m_xBuilder->weld_widget("lockbuttonbox1")) + , m_xMSOLockFileCB(m_xBuilder->weld_check_button("mso_lockfile")) + , m_xMSOLockFileImg(m_xBuilder->weld_widget("lockmso_lockfile")) +{ + std::vector<int> aWidths + { + m_xCheckLB->get_checkbox_column_width(), + m_xCheckLB->get_checkbox_column_width() + }; + m_xCheckLB->set_column_fixed_widths(aWidths); +} + +OfaMSFilterTabPage2::~OfaMSFilterTabPage2() +{ +} + +std::unique_ptr<SfxTabPage> OfaMSFilterTabPage2::Create( weld::Container* pPage, weld::DialogController* pController, + const SfxItemSet* rAttrSet ) +{ + return std::make_unique<OfaMSFilterTabPage2>( pPage, pController, *rAttrSet ); +} + +OUString OfaMSFilterTabPage2::GetAllStrings() +{ + OUString sAllStrings; + OUString labels[] = { "label1", "label2", "label3", "label4", "label5", "label6" }; + + for (const auto& label : labels) + { + if (const auto& pString = m_xBuilder->weld_label(label)) + sAllStrings += pString->get_label() + " "; + } + + OUString radioButton[] = { "highlighting", "shading" }; + + for (const auto& radio : radioButton) + { + if (const auto& pString = m_xBuilder->weld_radio_button(radio)) + sAllStrings += pString->get_label() + " "; + } + + sAllStrings += m_xMSOLockFileCB->get_label() + " "; + + return sAllStrings.replaceAll("_", ""); +} + +bool OfaMSFilterTabPage2::FillItemSet( SfxItemSet* ) +{ + SvtFilterOptions& rOpt = SvtFilterOptions::Get(); + + static struct ChkCBoxEntries{ + MSFltrPg2_CheckBoxEntries eType; + bool (SvtFilterOptions::*FnIs)() const; + void (SvtFilterOptions::*FnSet)( bool bFlag ); + } const aChkArr[] = { + { MSFltrPg2_CheckBoxEntries::Math, &SvtFilterOptions::IsMathType2Math, + &SvtFilterOptions::SetMathType2Math }, + { MSFltrPg2_CheckBoxEntries::Math, &SvtFilterOptions::IsMath2MathType, + &SvtFilterOptions::SetMath2MathType }, + { MSFltrPg2_CheckBoxEntries::Writer, &SvtFilterOptions::IsWinWord2Writer, + &SvtFilterOptions::SetWinWord2Writer }, + { MSFltrPg2_CheckBoxEntries::Writer, &SvtFilterOptions::IsWriter2WinWord, + &SvtFilterOptions::SetWriter2WinWord }, + { MSFltrPg2_CheckBoxEntries::Calc, &SvtFilterOptions::IsExcel2Calc, + &SvtFilterOptions::SetExcel2Calc }, + { MSFltrPg2_CheckBoxEntries::Calc, &SvtFilterOptions::IsCalc2Excel, + &SvtFilterOptions::SetCalc2Excel }, + { MSFltrPg2_CheckBoxEntries::Impress, &SvtFilterOptions::IsPowerPoint2Impress, + &SvtFilterOptions::SetPowerPoint2Impress }, + { MSFltrPg2_CheckBoxEntries::Impress, &SvtFilterOptions::IsImpress2PowerPoint, + &SvtFilterOptions::SetImpress2PowerPoint }, + { MSFltrPg2_CheckBoxEntries::SmartArt, &SvtFilterOptions::IsSmartArt2Shape, + &SvtFilterOptions::SetSmartArt2Shape }, + { MSFltrPg2_CheckBoxEntries::Visio, &SvtFilterOptions::IsVisio2Draw, + &SvtFilterOptions::SetVisio2Draw }, + }; + + bool bFirstCol = true; + for( const ChkCBoxEntries & rEntry : aChkArr ) + { + // we loop through the list, alternating reading the first/second column, + // each row appears twice in the list (except for smartart and later entries, which are + // import only) + sal_uInt16 nCol = bFirstCol ? 0 : 1; + bFirstCol = !bFirstCol; + int nEntry = GetEntry4Type(rEntry.eType); + if (nEntry != -1) + { + bool bCheck = m_xCheckLB->get_toggle(nEntry, nCol); + if( bCheck != (rOpt.*rEntry.FnIs)() ) + (rOpt.*rEntry.FnSet)( bCheck ); + } + if (rEntry.eType == MSFltrPg2_CheckBoxEntries::SmartArt) + { + bFirstCol = !bFirstCol; + } + } + int nPDFEntry = GetEntry4Type(MSFltrPg2_CheckBoxEntries::PDF); + bool bPDFCheck = m_xCheckLB->get_toggle(nPDFEntry, 0); + if (bPDFCheck != officecfg::Office::Common::Filter::Adobe::Import::PDFToDraw::get()) + { + std::shared_ptr<comphelper::ConfigurationChanges> pBatch( + comphelper::ConfigurationChanges::create()); + officecfg::Office::Common::Filter::Adobe::Import::PDFToDraw::set(bPDFCheck, pBatch); + pBatch->commit(); + } + + if( m_xHighlightingRB->get_state_changed_from_saved() ) + { + if (m_xHighlightingRB->get_active()) + rOpt.SetCharBackground2Highlighting(); + else + rOpt.SetCharBackground2Shading(); + } + + if (m_xMSOLockFileCB->get_state_changed_from_saved()) + { + rOpt.EnableMSOLockFileCreation(m_xMSOLockFileCB->get_active()); + } + + return true; +} + +void OfaMSFilterTabPage2::Reset( const SfxItemSet* ) +{ + SvtFilterOptions& rOpt = SvtFilterOptions::Get(); + + m_xCheckLB->freeze(); + m_xCheckLB->clear(); + + SvtModuleOptions aModuleOpt; + + // int the same sequence as the enums of MSFltrPg2_CheckBoxEntries + if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::EModule::MATH ) ) + InsertEntry( sChgToFromMath, MSFltrPg2_CheckBoxEntries::Math ); + if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::EModule::WRITER ) ) + InsertEntry( sChgToFromWriter, MSFltrPg2_CheckBoxEntries::Writer ); + if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::EModule::CALC ) ) + InsertEntry( sChgToFromCalc, MSFltrPg2_CheckBoxEntries::Calc ); + if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::EModule::IMPRESS ) ) + InsertEntry( sChgToFromImpress, MSFltrPg2_CheckBoxEntries::Impress ); + InsertEntry( sChgToFromSmartArt, MSFltrPg2_CheckBoxEntries::SmartArt, false ); + if (aModuleOpt.IsModuleInstalled(SvtModuleOptions::EModule::DRAW)) + { + InsertEntry(sChgToFromVisio, MSFltrPg2_CheckBoxEntries::Visio, false); + InsertEntry(sChgToFromPDF, MSFltrPg2_CheckBoxEntries::PDF, false); + } + + static struct ChkCBoxEntries{ + MSFltrPg2_CheckBoxEntries eType; + bool (SvtFilterOptions::*FnIs)() const; + } const aChkArr[] = { + { MSFltrPg2_CheckBoxEntries::Math, &SvtFilterOptions::IsMathType2Math }, + { MSFltrPg2_CheckBoxEntries::Math, &SvtFilterOptions::IsMath2MathType }, + { MSFltrPg2_CheckBoxEntries::Writer, &SvtFilterOptions::IsWinWord2Writer }, + { MSFltrPg2_CheckBoxEntries::Writer, &SvtFilterOptions::IsWriter2WinWord }, + { MSFltrPg2_CheckBoxEntries::Calc, &SvtFilterOptions::IsExcel2Calc }, + { MSFltrPg2_CheckBoxEntries::Calc, &SvtFilterOptions::IsCalc2Excel }, + { MSFltrPg2_CheckBoxEntries::Impress, &SvtFilterOptions::IsPowerPoint2Impress }, + { MSFltrPg2_CheckBoxEntries::Impress, &SvtFilterOptions::IsImpress2PowerPoint }, + { MSFltrPg2_CheckBoxEntries::SmartArt, &SvtFilterOptions::IsSmartArt2Shape }, + { MSFltrPg2_CheckBoxEntries::Visio, &SvtFilterOptions::IsVisio2Draw }, + { MSFltrPg2_CheckBoxEntries::PDF, nullptr }, + }; + + bool bFirstCol = true; + bool bReadOnly = false; + for( const ChkCBoxEntries & rArr : aChkArr ) + { + // we loop through the list, alternating reading the first/second column, + // each row appears twice in the list (except for smartart and later entries, which are + // import only) + sal_uInt16 nCol = bFirstCol ? 0 : 1; + bFirstCol = !bFirstCol; + int nEntry = GetEntry4Type( rArr.eType ); + if (nEntry != -1) + { + bool bCheck = false; + if (rArr.eType != MSFltrPg2_CheckBoxEntries::PDF) + { + bCheck = (rOpt.*rArr.FnIs)(); + switch (rArr.eType) + { + case MSFltrPg2_CheckBoxEntries::Math: + if (nCol == 0) + bReadOnly = officecfg::Office::Common::Filter::Microsoft::Import::MathTypeToMath::isReadOnly(); + else + bReadOnly = officecfg::Office::Common::Filter::Microsoft::Export::MathToMathType::isReadOnly(); + break; + case MSFltrPg2_CheckBoxEntries::Writer: + if (nCol == 0) + bReadOnly = officecfg::Office::Common::Filter::Microsoft::Import::WinWordToWriter::isReadOnly(); + else + bReadOnly = officecfg::Office::Common::Filter::Microsoft::Export::WriterToWinWord::isReadOnly(); + break; + case MSFltrPg2_CheckBoxEntries::Calc: + if (nCol == 0) + bReadOnly = officecfg::Office::Common::Filter::Microsoft::Import::ExcelToCalc::isReadOnly(); + else + bReadOnly = officecfg::Office::Common::Filter::Microsoft::Export::CalcToExcel::isReadOnly(); + break; + case MSFltrPg2_CheckBoxEntries::Impress: + if (nCol == 0) + bReadOnly = officecfg::Office::Common::Filter::Microsoft::Import::PowerPointToImpress::isReadOnly(); + else + bReadOnly = officecfg::Office::Common::Filter::Microsoft::Export::ImpressToPowerPoint::isReadOnly(); + break; + case MSFltrPg2_CheckBoxEntries::SmartArt: + bReadOnly = officecfg::Office::Common::Filter::Microsoft::Import::SmartArtToShapes::isReadOnly(); + break; + case MSFltrPg2_CheckBoxEntries::Visio: + bReadOnly = officecfg::Office::Common::Filter::Microsoft::Import::VisioToDraw::isReadOnly(); + break; + default: + break; + } + } + else + { + bCheck = officecfg::Office::Common::Filter::Adobe::Import::PDFToDraw::get(); + bReadOnly = officecfg::Office::Common::Filter::Adobe::Import::PDFToDraw::isReadOnly(); + nCol = 0; + } + m_xCheckLB->set_toggle(nEntry, bCheck ? TRISTATE_TRUE : TRISTATE_FALSE, nCol); + m_xCheckLB->set_sensitive(nEntry, !bReadOnly, nCol); + } + if (rArr.eType == MSFltrPg2_CheckBoxEntries::SmartArt) + { + bFirstCol = !bFirstCol; + } + } + m_xCheckLB->thaw(); + + if (rOpt.IsCharBackground2Highlighting()) + m_xHighlightingRB->set_active(true); + else + m_xShadingRB->set_active(true); + + if (officecfg::Office::Common::Filter::Microsoft::Export::CharBackgroundToHighlighting::isReadOnly()) + { + m_xHighlightingRB->set_sensitive(false); + m_xShadingRB->set_sensitive(false); + m_xHighlightingFT->set_sensitive(false); + m_xShadingImg->set_visible(true); + } + + m_xHighlightingRB->save_state(); + + m_xMSOLockFileCB->set_active(rOpt.IsMSOLockFileCreationIsEnabled()); + m_xMSOLockFileCB->save_state(); + m_xMSOLockFileCB->set_sensitive(!officecfg::Office::Common::Filter::Microsoft::Import::CreateMSOLockFiles::isReadOnly()); + m_xMSOLockFileImg->set_visible(officecfg::Office::Common::Filter::Microsoft::Import::CreateMSOLockFiles::isReadOnly()); +} + +void OfaMSFilterTabPage2::InsertEntry( const OUString& _rTxt, MSFltrPg2_CheckBoxEntries _nType ) +{ + InsertEntry( _rTxt, _nType, true ); +} + +void OfaMSFilterTabPage2::InsertEntry( const OUString& _rTxt, MSFltrPg2_CheckBoxEntries _nType, + bool saveEnabled ) +{ + int nPos = m_xCheckLB->n_children(); + m_xCheckLB->append(); + m_xCheckLB->set_toggle(nPos, TRISTATE_FALSE, 0); + if (saveEnabled) + m_xCheckLB->set_toggle(nPos, TRISTATE_FALSE, 1); + m_xCheckLB->set_text(nPos, _rTxt, 2); + m_xCheckLB->set_id(nPos, OUString::number(static_cast<sal_Int32>(_nType))); +} + +int OfaMSFilterTabPage2::GetEntry4Type( MSFltrPg2_CheckBoxEntries _nType ) const +{ + for (int i = 0, nEntryCount = m_xCheckLB->n_children(); i < nEntryCount; ++i) + { + if (_nType == static_cast<MSFltrPg2_CheckBoxEntries>(m_xCheckLB->get_id(i).toInt32())) + return i; + } + return -1; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |