/* -*- 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 <sal/config.h>
#include <osl/diagnose.h>
#include <o3tl/safeint.hxx>
#include <sal/log.hxx>
#include <svl/style.hxx>
#include <utility>
#include <vcl/weld.hxx>
#include <svl/stritem.hxx>
#include <unotools/pathoptions.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/docfile.hxx>
#include <sfx2/sfxdlg.hxx>
#include <svx/dialogs.hrc>
#include <svx/flagsdef.hxx>
#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
#include <com/sun/star/ui/dialogs/XFilePicker3.hpp>
#include <svtools/indexentryres.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <column.hxx>
#include <fmtfsize.hxx>
#include <authfld.hxx>
#include <swtypes.hxx>
#include <wrtsh.hxx>
#include <view.hxx>
#include <cnttab.hxx>
#include <swuicnttab.hxx>
#include <poolfmt.hxx>
#include <strings.hrc>
#include <uitool.hxx>
#include <fmtcol.hxx>
#include <fldbas.hxx>
#include <expfld.hxx>
#include <unotools.hxx>
#include <docsh.hxx>
#include <swmodule.hxx>
#include <modcfg.hxx>
#include <iodetect.hxx>
#include <cmdid.h>
#include <cnttab.hrc>
#include <SwStyleNameMapper.hxx>
#include <sfx2/filedlghelper.hxx>
#include <toxwrap.hxx>
#include <chpfld.hxx>
#include <names.hxx>
#include <svtools/editbrowsebox.hxx>
#include <cmath>
#include <memory>
#include <string_view>
#include <vector>
#include <numeric>
using namespace ::com::sun::star;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::uno;
using namespace com::sun::star::ui::dialogs;
using namespace ::sfx2;
const sal_Unicode aDeliStart =
'[' ;
// for the form
const sal_Unicode aDeliEnd =
']' ;
// for the form
static OUString lcl_CreateAutoMarkFileDlg(weld::Window* pParent,
const OUString& r
URL,
const OUString& rFileString, bool bOpen)
{
OUString sRet;
FileDialogHelper aDlgHelper( bOpen ?
TemplateDescription::FILEOPEN_SIMPLE : TemplateDescription::FILESAVE_AUTOEXTENSION,
FileDialogFlags::NONE, pParent);
uno::Reference < XFilePicker3 > xFP = aDlgHelper.GetFilePicker();
xFP->appendFilter( rFileString, u"*.sdi" _ustr );
xFP->setCurrentFilter( rFileString ) ;
if ( !rURL.isEmpty() )
xFP->setDisplayDirectory( rURL );
else
{
SvtPathOptions aPathOpt;
xFP->setDisplayDirectory( aPathOpt.GetUserConfigPath() );
}
const ErrCode aErrCode = aDlgHelper.Execute();
if (aErrCode == ERRCODE_NONE)
{
sRet = xFP->getSelectedFiles().getConstArray()[0];
}
// tdf#120405 - use previously selected file, if selection is aborted
else if (aErrCode == ERRCODE_ABORT && !rURL.isEmpty())
{
sRet = rURL;
}
return sRet;
}
namespace {
struct AutoMarkEntry
{
OUString sSearch;
OUString sAlternative;
OUString sPrimKey;
OUString sSecKey;
OUString sComment;
bool bCase;
bool bWord;
AutoMarkEntry() :
bCase(false ),
bWord(false ){}
};
}
namespace {
class SwEntryBrowseBox : public svt::EditBrowseBox
{
VclPtr<svt::EditControl> m_aCellEdit;
VclPtr<svt::CheckBoxControl> m_aCellCheckBox;
OUString m_sYes;
OUString m_sNo;
std::vector<std::unique_ptr<AutoMarkEntry>> m_Entries;
::svt::CellControllerRef m_xController;
::svt::CellControllerRef m_xCheckController;
sal_Int32 m_nCurrentRow;
bool m_bModified;
protected :
virtual bool SeekRow( sal_Int32 nRow ) override;
virtual void PaintCell(OutputDevice& rDev, const tools::Rectangle& rRect, sal_uInt16 nColId) const override;
virtual void InitController(::svt::CellControllerRef& rController, sal_Int32 nRow, sal_uInt16 nCol) override;
virtual ::svt::CellController* GetController(sal_Int32 nRow, sal_uInt16 nCol) override;
virtual bool SaveModified() override;
std::vector<tools::Long > GetOptimalColWidths() const ;
public :
SwEntryBrowseBox(const css::uno::Reference<css::awt::XWindow> &rParent);
virtual ~SwEntryBrowseBox() override;
virtual void dispose() override;
void ReadEntries(SvStream& rInStr);
void WriteEntries(SvStream& rOutStr);
bool IsModified()const override;
virtual OUString GetCellText( sal_Int32 nRow, sal_uInt16 nColumn ) const override;
virtual void Resize() override;
virtual Size GetOptimalSize() const override;
};
class SwAutoMarkDlg_Impl : public weld::GenericDialogController
{
OUString m_sAutoMarkURL;
bool m_bCreateMode;
std::unique_ptr<weld::Button> m_xOKPB;
std::unique_ptr<weld::Container> m_xTable;
css::uno::Reference<css::awt::XWindow> m_xTableCtrlParent;
VclPtr<SwEntryBrowseBox> m_xEntriesBB;
DECL_LINK(OkHdl, weld::Button&, void );
public :
SwAutoMarkDlg_Impl(weld::Window* pParent, OUString aAutoMarkURL,
bool bCreate);
virtual ~SwAutoMarkDlg_Impl() override;
};
}
sal_uInt16 CurTOXType::GetFlatIndex() const
{
return static_cast < sal_uInt16 >( (eType == TOX_USER && nIndex)
? TOX_AUTHORITIES + nIndex : eType );
}
SwMultiTOXTabDialog::SwMultiTOXTabDialog(weld::Widget* pParent, const SfxItemSet& rSet,
SwWrtShell &rShell, SwTOXBase* pCurTOX,
sal_uInt16 nToxType, bool bGlobal)
: SfxTabDialogController(pParent, u"modules/swriter/ui/tocdialog.ui" _ustr, u"TocDialog" _ustr, &rSet)
, m_pMgr( new SwTOXMgr( &rShell ) )
, m_rWrtShell(rShell)
, m_pParamTOXBase(pCurTOX)
, m_sUserDefinedIndex(SwResId(STR_USER_DEFINED_INDEX))
, m_nInitialTOXType(nToxType)
, m_bEditTOX(false )
, m_bExampleCreated(false )
, m_bGlobalFlag(bGlobal)
, m_xShowExampleCB(m_xBuilder->weld_check_button(u"showexample" _ustr))
{
m_eCurrentTOXType.eType = TOX_CONTENT;
m_eCurrentTOXType.nIndex = 0;
const sal_uInt16 nUserTypeCount = m_rWrtShell.GetTOXTypeCount(TOX_USER);
m_vTypeData.resize(nUserTypeCount + 6);
//the standard user index is on position TOX_USER
//all user indexes follow after position TOX_AUTHORITIES
if (pCurTOX)
{
m_bEditTOX = true ;
}
for (int i = m_vTypeData.size() - 1; i > -1; i--)
{
m_vTypeData[i].m_oIndexSections.emplace();
if (pCurTOX)
{
m_eCurrentTOXType.eType = pCurTOX->GetType();
sal_uInt16 nArrayIndex = static_cast < sal_uInt16 >(m_eCurrentTOXType.eType);
if (m_eCurrentTOXType.eType == TOX_USER)
{
//which user type is it?
for (sal_uInt16 nUser = 0; nUser < nUserTypeCount; nUser++)
{
const SwTOXType* pTemp = m_rWrtShell.GetTOXType(TOX_USER, nUser);
if (pCurTOX->GetTOXType() == pTemp)
{
m_eCurrentTOXType.nIndex = nUser;
nArrayIndex = static_cast < sal_uInt16 >(nUser > 0 ? TOX_AUTHORITIES + nUser : TOX_USER);
break ;
}
}
}
m_vTypeData[nArrayIndex].m_pForm.reset(new SwForm(pCurTOX->GetTOXForm()));
m_vTypeData[nArrayIndex].m_pDescription = CreateTOXDescFromTOXBase(pCurTOX);
if (TOX_AUTHORITIES == m_eCurrentTOXType.eType)
{
const SwAuthorityFieldType* pFType = static_cast <const SwAuthorityFieldType*>(
m_rWrtShell.GetFieldType(SwFieldIds::TableOfAuthorities, OUString()));
if (pFType)
{
OUString sBrackets;
if (pFType->GetPrefix())
sBrackets += OUStringChar(pFType->GetPrefix());
if (pFType->GetSuffix())
sBrackets += OUStringChar(pFType->GetSuffix());
m_vTypeData[nArrayIndex].m_pDescription->SetAuthBrackets(sBrackets);
m_vTypeData[nArrayIndex].m_pDescription->SetAuthSequence(pFType->IsSequence());
}
else
{
m_vTypeData[nArrayIndex].m_pDescription->SetAuthBrackets(u"[]" _ustr);
}
}
}
}
SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
AddTabPage(u"index" _ustr, SwTOXSelectTabPage::Create, nullptr);
AddTabPage(u"styles" _ustr, SwTOXStylesTabPage::Create, nullptr);
AddTabPage(u"columns" _ustr, SwColumnPage::Create, nullptr);
AddTabPage(u"background" _ustr, pFact->GetTabPageCreatorFunc(RID_SVXPAGE_BKG), nullptr);
AddTabPage(u"entries" _ustr, SwTOXEntryTabPage::Create, nullptr);
if (!pCurTOX)
SetCurPageId(u"index" _ustr);
m_xShowExampleCB->connect_toggled(LINK(this , SwMultiTOXTabDialog, ShowPreviewHdl));
m_xShowExampleCB->set_active(SwModule::get()->GetModuleConfig()->IsShowIndexPreview());
ShowPreview();
}
SwMultiTOXTabDialog::~SwMultiTOXTabDialog()
{
SwModule::get()->GetModuleConfig()->SetShowIndexPreview(m_xShowExampleCB->get_active());
}
void SwMultiTOXTabDialog::PageCreated(const OUString& rId, SfxTabPage &rPage)
{
if (rId == "background" )
{
SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, static_cast <sal_uInt32>(SvxBackgroundTabFlags::SHOW_SELECTOR)));
rPage.PageCreated(aSet);
}
else if (rId == "columns" )
{
const SwFormatFrameSize& rSize = GetInputSetImpl()->Get(RES_FRM_SIZE);
static_cast <SwColumnPage&>(rPage).SetPageWidth(rSize.GetWidth());
}
else if (rId == "entries" )
static_cast <SwTOXEntryTabPage&>(rPage).SetWrtShell(m_rWrtShell);
else if (rId == "index" )
{
static_cast <SwTOXSelectTabPage&>(rPage).SetWrtShell(m_rWrtShell);
if (USHRT_MAX != m_nInitialTOXType)
static_cast <SwTOXSelectTabPage&>(rPage).SelectType(static_cast <TOXTypes>(m_nInitialTOXType));
}
}
short SwMultiTOXTabDialog::Ok()
{
short nRet = SfxTabDialogController::Ok();
SwTOXDescription& rDesc = GetTOXDescription(m_eCurrentTOXType);
SwTOXBase aNewDef(*m_rWrtShell.GetDefaultTOXBase( m_eCurrentTOXType.eType, true ));
const sal_uInt16 nIndex = m_eCurrentTOXType.GetFlatIndex();
if (m_vTypeData[nIndex].m_pForm)
{
rDesc.SetForm(*m_vTypeData[nIndex].m_pForm);
aNewDef.SetTOXForm(*m_vTypeData[nIndex].m_pForm);
}
rDesc.ApplyTo(aNewDef);
if (!m_bGlobalFlag)
m_pMgr->UpdateOrInsertTOX(
rDesc, nullptr, GetOutputItemSet());
else if (m_bEditTOX)
m_pMgr->UpdateOrInsertTOX(
rDesc, &m_pParamTOXBase, GetOutputItemSet());
if (!m_eCurrentTOXType.nIndex)
m_rWrtShell.SetDefaultTOXBase(aNewDef);
return nRet;
}
SwForm* SwMultiTOXTabDialog::GetForm(CurTOXType eType)
{
const sal_uInt16 nIndex = eType.GetFlatIndex();
if (!m_vTypeData[nIndex].m_pForm)
m_vTypeData[nIndex].m_pForm.reset(new SwForm(eType.eType));
return m_vTypeData[nIndex].m_pForm.get();
}
SwTOXDescription& SwMultiTOXTabDialog::GetTOXDescription(CurTOXType eType)
{
const sal_uInt16 nIndex = eType.GetFlatIndex();
if (!m_vTypeData[nIndex].m_pDescription)
{
const SwTOXBase* pDef = m_rWrtShell.GetDefaultTOXBase( eType.eType );
if (pDef)
m_vTypeData[nIndex].m_pDescription = CreateTOXDescFromTOXBase(pDef);
else
{
m_vTypeData[nIndex].m_pDescription.reset(new SwTOXDescription(eType.eType));
if (eType.eType == TOX_USER)
m_vTypeData[nIndex].m_pDescription->SetTitle(m_sUserDefinedIndex);
else
m_vTypeData[nIndex].m_pDescription->SetTitle(
m_rWrtShell.GetTOXType(eType.eType, 0)->GetTypeName());
}
if (TOX_AUTHORITIES == eType.eType)
{
const SwAuthorityFieldType* pFType = static_cast <const SwAuthorityFieldType*>(
m_rWrtShell.GetFieldType(SwFieldIds::TableOfAuthorities, OUString()));
if (pFType)
{
m_vTypeData[nIndex].m_pDescription->SetAuthBrackets(OUStringChar(pFType->GetPrefix()) +
OUStringChar(pFType->GetSuffix()));
m_vTypeData[nIndex].m_pDescription->SetAuthSequence(pFType->IsSequence());
}
else
{
m_vTypeData[nIndex].m_pDescription->SetAuthBrackets(u"[]" _ustr);
}
}
else if (TOX_INDEX == eType.eType)
m_vTypeData[nIndex].m_pDescription->SetMainEntryCharStyle(UIName(SwResId(STR_POOLCHR_IDX_MAIN_ENTRY)));
}
return *m_vTypeData[nIndex].m_pDescription;
}
std::unique_ptr<SwTOXDescription> SwMultiTOXTabDialog::CreateTOXDescFromTOXBase(
const SwTOXBase*pCurTOX)
{
std::unique_ptr<SwTOXDescription> pDesc(new SwTOXDescription(pCurTOX->GetType()));
for (sal_uInt16 i = 0; i < MAXLEVEL; i++)
pDesc->SetStyleNames(pCurTOX->GetStyleNames(i), i);
pDesc->SetAutoMarkURL(m_rWrtShell.GetTOIAutoMarkURL());
pDesc->SetTitle(pCurTOX->GetTitle());
pDesc->SetContentOptions(pCurTOX->GetCreateType());
if (pDesc->GetTOXType() == TOX_INDEX)
pDesc->SetIndexOptions(pCurTOX->GetOptions());
pDesc->SetMainEntryCharStyle(pCurTOX->GetMainEntryCharStyle());
if (pDesc->GetTOXType() != TOX_INDEX)
pDesc->SetLevel(static_cast <sal_uInt8>(pCurTOX->GetLevel()));
pDesc->SetCreateFromObjectNames(pCurTOX->IsFromObjectNames());
pDesc->SetSequenceName(pCurTOX->GetSequenceName());
pDesc->SetCaptionDisplay(pCurTOX->GetCaptionDisplay());
pDesc->SetFromChapter(pCurTOX->IsFromChapter());
pDesc->SetReadonly(pCurTOX->IsProtected());
pDesc->SetOLEOptions(pCurTOX->GetOLEOptions());
pDesc->SetLevelFromChapter(pCurTOX->IsLevelFromChapter());
pDesc->SetLanguage(pCurTOX->GetLanguage());
pDesc->SetSortAlgorithm(pCurTOX->GetSortAlgorithm());
return pDesc;
}
void SwMultiTOXTabDialog::ShowPreview()
{
if (m_xShowExampleCB->get_active())
{
if (!m_xExampleFrame && !m_bExampleCreated)
{
m_bExampleCreated = true ;
OUString sTemplate(u"internal/idxexample.odt" _ustr);
SvtPathOptions aOpt;
bool bExist = aOpt.SearchFile( sTemplate, SvtPathOptions::Paths::Template );
if (!bExist)
{
OUString sInfo(SwResId(STR_FILE_NOT_FOUND));
sInfo = sInfo.replaceFirst( "%1" , sTemplate );
sInfo = sInfo.replaceFirst( "%2" , aOpt.GetTemplatePath() );
std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(m_xDialog.get(),
VclMessageType::Info, VclButtonsType::Ok,
sInfo));
xInfoBox->run();
}
else
{
Link<SwOneExampleFrame&,void > aLink(LINK(this , SwMultiTOXTabDialog, CreateExample_Hdl));
m_xExampleFrame.reset(new SwOneExampleFrame(EX_SHOW_ONLINE_LAYOUT | EX_LOCALIZE_TOC_STRINGS, &aLink, &sTemplate));
m_xExampleFrameWin.reset(new weld::CustomWeld(*m_xBuilder, u"example" _ustr, *m_xExampleFrame));
}
m_xShowExampleCB->set_visible(m_xExampleFrame != nullptr);
}
}
if (m_xExampleFrame)
{
const bool bSetViewWindow = m_xShowExampleCB->get_active();
if (bSetViewWindow)
m_xExampleFrame->Show();
else
m_xExampleFrame->Hide();
}
}
IMPL_LINK_NOARG(SwMultiTOXTabDialog, ShowPreviewHdl, weld::Toggleable&, void )
{
ShowPreview();
m_xDialog->resize_to_request();
}
bool SwMultiTOXTabDialog::IsNoNum(SwWrtShell& rSh, const UIName& rName)
{
SwTextFormatColl* pColl = rSh.GetParaStyle(rName);
if (pColl && ! pColl->IsAssignedToListLevelOfOutlineStyle())
return true ;
const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(
rName, SwGetPoolIdFromName::TxtColl);
return nId != USHRT_MAX &&
! rSh.GetTextCollFromPool(nId)->IsAssignedToListLevelOfOutlineStyle();
}
namespace {
class SwAddStylesDlg_Impl : public SfxDialogController
{
UIName* m_pStyleArr;
std::unique_ptr<weld::Button> m_xOk;
std::unique_ptr<weld::Button> m_xLeftPB;
std::unique_ptr<weld::Button> m_xRightPB;
std::unique_ptr<weld::TreeView> m_xHeaderTree;
void ToggleOn(int nEntry, int nToggleColumn);
DECL_LINK(OkHdl, weld::Button&, void );
DECL_LINK(LeftRightHdl, weld::Button&, void );
DECL_LINK(KeyInput, const KeyEvent&, bool );
DECL_LINK(TreeSizeAllocHdl, const Size&, void );
DECL_LINK(RadioToggleOnHdl, const weld::TreeView::iter_col&, void );
DECL_LINK(HeaderBarClick, int , void );
public :
SwAddStylesDlg_Impl(weld::Window* pParent, SwWrtShell const & rWrtSh, UIName rStringArr[]);
};
}
SwAddStylesDlg_Impl::SwAddStylesDlg_Impl(weld::Window* pParent,
SwWrtShell const & rWrtSh, UIName rStringArr[])
: SfxDialogController(pParent, u"modules/swriter/ui/assignstylesdialog.ui" _ustr, u"AssignStylesDialog" _ustr)
, m_pStyleArr(rStringArr)
, m_xOk(m_xBuilder->weld_button(u"ok" _ustr))
, m_xLeftPB(m_xBuilder->weld_button(u"left" _ustr))
, m_xRightPB(m_xBuilder->weld_button(u"right" _ustr))
, m_xHeaderTree(m_xBuilder->weld_tree_view(u"styles" _ustr))
{
m_xOk->connect_clicked(LINK(this , SwAddStylesDlg_Impl, OkHdl));
m_xLeftPB->connect_clicked(LINK(this , SwAddStylesDlg_Impl, LeftRightHdl));
m_xRightPB->connect_clicked(LINK(this , SwAddStylesDlg_Impl, LeftRightHdl));
m_xHeaderTree->connect_size_allocate(LINK(this , SwAddStylesDlg_Impl, TreeSizeAllocHdl));
m_xHeaderTree->enable_toggle_buttons(weld::ColumnToggleType::Radio);
m_xHeaderTree->connect_toggled(LINK(this , SwAddStylesDlg_Impl, RadioToggleOnHdl));
m_xHeaderTree->connect_column_clicked(LINK(this , SwAddStylesDlg_Impl, HeaderBarClick));
std::vector<int > aWidths
{
o3tl::narrowing<int >(m_xHeaderTree->get_approximate_digit_width() * 30)
};
int nPadding = m_xHeaderTree->get_approximate_digit_width() * 2;
OUString sTitle(m_xHeaderTree->get_column_title(1));
for (sal_uInt16 i = 0; i <= MAXLEVEL; ++i)
{
sTitle = OUString::number(i);
m_xHeaderTree->set_column_title(i + 1, sTitle);
aWidths.push_back(m_xHeaderTree->get_pixel_size(sTitle).Width() + nPadding);
}
m_xHeaderTree->set_column_fixed_widths(aWidths);
auto nWidth = std::accumulate(aWidths.begin(), aWidths.end(),
Application::GetSettings().GetStyleSettings().GetScrollBarSize());
m_xHeaderTree->set_size_request(nWidth, m_xHeaderTree->get_height_rows(15));
int nRow(0);
for (sal_uInt16 i = 0; i < MAXLEVEL; ++i)
{
const UIName &rStyles{rStringArr[i]};
if (rStyles.isEmpty())
continue ;
sal_Int32 nPos(0);
do
{
OUString sEntry = rStyles.toString().getToken(0, TOX_STYLE_DELIMITER, nPos);
m_xHeaderTree->append_text(sEntry);
for (sal_uInt16 j = 0; j <= MAXLEVEL; ++j)
{
TriState eState = i == j - 1 ? TRISTATE_TRUE : TRISTATE_FALSE;
m_xHeaderTree->set_toggle(nRow, eState, j + 1);
}
++nRow;
} while (nPos>=0);
}
// now the other styles
const sal_uInt16 nSz = rWrtSh.GetTextFormatCollCount();
for (sal_uInt16 j = 0; j < nSz; ++j)
{
const SwTextFormatColl& rColl = rWrtSh.GetTextFormatColl(j);
if (rColl.IsDefault())
continue ;
const UIName aName = rColl.GetName();
if (!aName.isEmpty())
{
bool bEntry = false ;
int nChildren = m_xHeaderTree->n_children();
for (int i = 0; i < nChildren; ++i)
{
if (m_xHeaderTree->get_text(i, 0) == aName)
{
bEntry = true ;
break ;
}
}
if (!bEntry)
{
m_xHeaderTree->append_text(aName.toString());
for (sal_uInt16 k = 0; k <= MAXLEVEL; ++k)
{
TriState eState = k == 0 ? TRISTATE_TRUE : TRISTATE_FALSE;
m_xHeaderTree->set_toggle(nRow, eState, k + 1);
}
++nRow;
}
}
}
m_xHeaderTree->make_sorted();
m_xHeaderTree->set_sort_column(0);
m_xHeaderTree->set_sort_order(true );
m_xHeaderTree->set_sort_indicator(TRISTATE_TRUE, 0);
m_xHeaderTree->select(0);
m_xHeaderTree->connect_key_release(LINK(this , SwAddStylesDlg_Impl, KeyInput));
}
IMPL_LINK(SwAddStylesDlg_Impl, HeaderBarClick, int , nColumn, void )
{
bool bSortAtoZ = m_xHeaderTree->get_sort_order();
//set new arrow positions in headerbar
if (nColumn == m_xHeaderTree->get_sort_column())
{
bSortAtoZ = !bSortAtoZ;
m_xHeaderTree->set_sort_order(bSortAtoZ);
}
if (nColumn != -1)
{
//sort lists
m_xHeaderTree->set_sort_indicator(bSortAtoZ ? TRISTATE_TRUE : TRISTATE_FALSE, nColumn);
}
}
IMPL_LINK(SwAddStylesDlg_Impl, TreeSizeAllocHdl, const Size&, rSize, void )
{
auto nWidth = rSize.Width() - Application::GetSettings().GetStyleSettings().GetScrollBarSize();
std::vector<int > aWidths { 0 };
int nPadding = m_xHeaderTree->get_approximate_digit_width() * 2;
for (sal_uInt16 i = 0; i <= MAXLEVEL; ++i)
{
OUString sTitle(m_xHeaderTree->get_column_title(i + 1));
aWidths.push_back(m_xHeaderTree->get_pixel_size(sTitle).Width() + nPadding);
}
auto nOtherWidth = std::accumulate(aWidths.begin(), aWidths.end(), 0);
aWidths[0] = nWidth - nOtherWidth;
m_xHeaderTree->set_column_fixed_widths(aWidths);
}
IMPL_LINK(SwAddStylesDlg_Impl, RadioToggleOnHdl, const weld::TreeView::iter_col&, rRowCol, void )
{
for (sal_uInt16 i = 0; i <= MAXLEVEL; ++i)
{
TriState eState = rRowCol.second == i + 1 ? TRISTATE_TRUE : TRISTATE_FALSE;
m_xHeaderTree->set_toggle(rRowCol.first, eState, i + 1);
}
}
IMPL_LINK(SwAddStylesDlg_Impl, KeyInput, const KeyEvent&, rKEvt, bool )
{
vcl::KeyCode aCode = rKEvt.GetKeyCode();
bool bHandled = false ;
sal_uInt16 nCode = aCode.GetCode();
switch (nCode)
{
case KEY_ADD:
LeftRightHdl(*m_xRightPB);
bHandled = true ;
break ;
case KEY_SUBTRACT:
LeftRightHdl(*m_xLeftPB);
bHandled = true ;
break ;
case KEY_0:
case KEY_1:
case KEY_2:
case KEY_3:
case KEY_4:
case KEY_5:
case KEY_6:
case KEY_7:
case KEY_8:
case KEY_9:
case KEY_A:
{
int nEntry = m_xHeaderTree->get_selected_index();
if (nEntry != -1)
{
ToggleOn(nEntry, nCode != KEY_A ? nCode - KEY_0 : 10);
bHandled = true ;
}
break ;
}
}
return bHandled;
}
IMPL_LINK_NOARG(SwAddStylesDlg_Impl, OkHdl, weld::Button&, void )
{
for (sal_uInt16 i = 0; i < MAXLEVEL; i++)
m_pStyleArr[i] = UIName();
int nChildren = m_xHeaderTree->n_children();
for (int i = 0; i < nChildren; ++i)
{
int nToggleColumn = 0;
for (sal_uInt16 j = 0; j <= MAXLEVEL; ++j)
{
if (m_xHeaderTree->get_toggle(i, j + 1) == TRISTATE_TRUE)
{
nToggleColumn = j;
break ;
}
}
if (nToggleColumn)
{
int nLevel = nToggleColumn - 1;
if (!m_pStyleArr[nLevel].isEmpty())
m_pStyleArr[nLevel] = UIName(m_pStyleArr[nLevel].toString() + OUStringChar(TOX_STYLE_DELIMITER));
m_pStyleArr[nLevel] = UIName(m_pStyleArr[nLevel].toString() + m_xHeaderTree->get_text(i, 0));
}
}
//TODO write back style names
m_xDialog->response(RET_OK);
}
IMPL_LINK(SwAddStylesDlg_Impl, LeftRightHdl, weld::Button&, rBtn, void )
{
bool bLeft = &rBtn == m_xLeftPB.get();
int nEntry = m_xHeaderTree->get_selected_index();
if (nEntry == -1)
return ;
int nToggleColumn = 0;
for (sal_uInt16 j = 0; j <= MAXLEVEL; ++j)
{
if (m_xHeaderTree->get_toggle(nEntry, j + 1) == TRISTATE_TRUE)
{
nToggleColumn = j;
break ;
}
}
if (bLeft)
{
if (nToggleColumn)
--nToggleColumn;
}
else
{
if (nToggleColumn < MAXLEVEL)
++nToggleColumn;
}
ToggleOn(nEntry, nToggleColumn);
}
void SwAddStylesDlg_Impl::ToggleOn(int nEntry, int nToggleColumn)
{
for (sal_uInt16 j = 0; j <= MAXLEVEL; ++j)
{
m_xHeaderTree->set_toggle(nEntry, j == nToggleColumn ? TRISTATE_TRUE : TRISTATE_FALSE, j + 1);
}
}
SwTOXSelectTabPage::SwTOXSelectTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rAttrSet)
: SfxTabPage(pPage, pController, u"modules/swriter/ui/tocindexpage.ui" _ustr, u"TocIndexPage" _ustr, &rAttrSet)
, m_sAutoMarkType(SwResId(STR_AUTOMARK_TYPE))
, m_bWaitingInitialSettings(true )
, m_xTitleED(m_xBuilder->weld_entry(u"title" _ustr))
, m_xTypeFT(m_xBuilder->weld_label(u"typeft" _ustr))
, m_xTypeLB(m_xBuilder->weld_combo_box(u"type" _ustr))
, m_xReadOnlyCB(m_xBuilder->weld_check_button(u"readonly" _ustr))
, m_xTitleToggleCB(m_xBuilder->weld_check_button(u"usetitle" _ustr))
, m_xAreaFrame(m_xBuilder->weld_widget(u"areaframe" _ustr))
, m_xAreaLB(m_xBuilder->weld_combo_box(u"scope" _ustr))
, m_xLevelFT(m_xBuilder->weld_label(u"levelft" _ustr))
, m_xLevelNF(m_xBuilder->weld_spin_button(u"level" _ustr))
, m_xCreateFrame(m_xBuilder->weld_widget(u"createframe" _ustr))
, m_xFromHeadingsCB(m_xBuilder->weld_check_button(u"fromheadings" _ustr))
, m_xStylesCB(m_xBuilder->weld_check_button(u"stylescb" _ustr))
, m_xAddStylesCB(m_xBuilder->weld_check_button(u"addstylescb" _ustr))
, m_xAddStylesPB(m_xBuilder->weld_button(u"styles" _ustr))
, m_xFromTablesCB(m_xBuilder->weld_check_button(u"fromtables" _ustr))
, m_xFromFramesCB(m_xBuilder->weld_check_button(u"fromframes" _ustr))
, m_xFromGraphicsCB(m_xBuilder->weld_check_button(u"fromgraphics" _ustr))
, m_xFromOLECB(m_xBuilder->weld_check_button(u"fromoles" _ustr))
, m_xLevelFromChapterCB(m_xBuilder->weld_check_button(u"uselevel" _ustr))
, m_xFromCaptionsRB(m_xBuilder->weld_radio_button(u"captions" _ustr))
, m_xFromObjectNamesRB(m_xBuilder->weld_radio_button(u"objnames" _ustr))
, m_xCaptionSequenceFT(m_xBuilder->weld_label(u"categoryft" _ustr))
, m_xCaptionSequenceLB(m_xBuilder->weld_combo_box(u"category" _ustr))
, m_xDisplayTypeFT(m_xBuilder->weld_label(u"displayft" _ustr))
, m_xDisplayTypeLB(m_xBuilder->weld_combo_box(u"display" _ustr))
, m_xParaStyleCB(m_xBuilder->weld_check_button(u"useparastyle" _ustr))
, m_xParaStyleLB(m_xBuilder->weld_combo_box(u"parastyle" _ustr))
, m_xTOXMarksCB(m_xBuilder->weld_check_button(u"indexmarks" _ustr))
, m_xIdxOptionsFrame(m_xBuilder->weld_widget(u"optionsframe" _ustr))
, m_xCollectSameCB(m_xBuilder->weld_check_button(u"combinesame" _ustr))
, m_xUseFFCB(m_xBuilder->weld_check_button(u"useff" _ustr))
, m_xUseDashCB(m_xBuilder->weld_check_button(u"usedash" _ustr))
, m_xCaseSensitiveCB(m_xBuilder->weld_check_button(u"casesens" _ustr))
, m_xInitialCapsCB(m_xBuilder->weld_check_button(u"initcaps" _ustr))
, m_xKeyAsEntryCB(m_xBuilder->weld_check_button(u"keyasentry" _ustr))
, m_xFromFileCB(m_xBuilder->weld_check_button(u"fromfile" _ustr))
, m_xAutoMarkPB(m_xBuilder->weld_menu_button(u"file" _ustr))
, m_xFromObjCLB(m_xBuilder->weld_tree_view(u"objects" _ustr))
, m_xFromObjFrame(m_xBuilder->weld_widget(u"objectframe" _ustr))
, m_xSequenceCB(m_xBuilder->weld_check_button(u"numberentries" _ustr))
, m_xBracketLB(m_xBuilder->weld_combo_box(u"brackets" _ustr))
, m_xAuthorityFrame(m_xBuilder->weld_widget(u"authframe" _ustr))
, m_xSortFrame(m_xBuilder->weld_widget(u"sortframe" _ustr))
, m_xLanguageLB(new SvxLanguageBox(m_xBuilder->weld_combo_box(u"lang" _ustr)))
, m_xSortAlgorithmLB(m_xBuilder->weld_combo_box(u"keytype" _ustr))
{
m_sAddStyleUser = m_xStylesCB->get_label();
m_pIndexEntryWrapper.reset(new IndexEntrySupplierWrapper());
m_xLanguageLB->SetLanguageList( SvxLanguageListFlags::ALL | SvxLanguageListFlags::ONLY_KNOWN,
false );
//Default mode is arranged to be the tallest mode
//of alphabetical index, lock that size in now
LanguageHdl(nullptr); //fill sort algorithm list
Size aPrefSize(m_xContainer->get_preferred_size());
m_xContainer->set_size_request(aPrefSize.Width(), aPrefSize.Height());
m_sAddStyleContent = m_xAddStylesCB->get_label();
m_xFromObjCLB->enable_toggle_buttons(weld::ColumnToggleType::Check);
for (size_t i = 0; i < SAL_N_ELEMENTS(RES_SRCTYPES); ++i)
{
OUString sId(OUString::number(static_cast <sal_uInt32>(RES_SRCTYPES[i].second)));
m_xFromObjCLB->append();
m_xFromObjCLB->set_toggle(i, TRISTATE_FALSE);
m_xFromObjCLB->set_text(i, SwResId(RES_SRCTYPES[i].first), 0);
m_xFromObjCLB->set_id(i, sId);
}
m_xFromObjCLB->set_size_request(-1, std::max<int >(m_xFromObjCLB->get_preferred_size().Height(),
m_xFromObjCLB->get_height_rows(SAL_N_ELEMENTS(RES_SRCTYPES))) + 2);
SetExchangeSupport();
m_xTypeLB->connect_changed(LINK(this , SwTOXSelectTabPage, TOXTypeHdl));
m_xAddStylesPB->connect_clicked(LINK(this , SwTOXSelectTabPage, AddStylesHdl));
m_xAutoMarkPB->connect_toggled(LINK(this , SwTOXSelectTabPage, MenuEnableHdl));
m_xAutoMarkPB->connect_selected(LINK(this , SwTOXSelectTabPage, MenuExecuteHdl));
Link<weld::Toggleable&,void > aLk = LINK(this , SwTOXSelectTabPage, CheckBoxHdl);
m_xAddStylesCB->connect_toggled(aLk);
m_xFromHeadingsCB->connect_toggled(aLk);
m_xTOXMarksCB->connect_toggled(aLk);
m_xFromFileCB->connect_toggled(aLk);
m_xCollectSameCB->connect_toggled(aLk);
m_xUseFFCB->connect_toggled(aLk);
m_xUseDashCB->connect_toggled(aLk);
m_xInitialCapsCB->connect_toggled(aLk);
m_xKeyAsEntryCB->connect_toggled(aLk);
m_xParaStyleCB->connect_toggled(aLk);
m_xTitleToggleCB->connect_toggled(aLk);
m_xTitleED->connect_changed(LINK(this , SwTOXSelectTabPage, ModifyEntryHdl));
m_xLevelNF->connect_value_changed(LINK(this , SwTOXSelectTabPage, ModifySpinHdl));
m_xSortAlgorithmLB->connect_changed(LINK(this , SwTOXSelectTabPage, ModifyListBoxHdl));
m_xParaStyleLB->connect_changed(LINK(this , SwTOXSelectTabPage, ModifyListBoxHdl));
aLk = LINK(this , SwTOXSelectTabPage, RadioButtonHdl);
m_xFromCaptionsRB->connect_toggled(aLk);
m_xFromObjectNamesRB->connect_toggled(aLk);
RadioButtonHdl(*m_xFromCaptionsRB);
m_xLanguageLB->connect_changed(LINK(this , SwTOXSelectTabPage, LanguageListBoxHdl));
m_xTypeLB->set_active(0);
m_xTitleED->save_value();
}
SwTOXSelectTabPage::~SwTOXSelectTabPage()
{
m_pIndexRes.reset();
m_pIndexEntryWrapper.reset();
m_xLanguageLB.reset();
}
void SwTOXSelectTabPage::SetWrtShell(SwWrtShell const & rSh)
{
const sal_uInt16 nUserTypeCount = rSh.GetTOXTypeCount(TOX_USER);
if (nUserTypeCount <= 1)
return ;
//insert all new user indexes names after the standard user index
sal_Int32 nPos = m_xTypeLB->find_id(OUString::number(sal_uInt32(TO_USER))) + 1;
for (sal_uInt16 nUser = 1; nUser < nUserTypeCount; nUser++)
{
sal_uInt32 nEntryData = nUser << 8;
nEntryData |= TO_USER;
OUString sId(OUString::number(nEntryData));
m_xTypeLB->insert(nPos++, rSh.GetTOXType(TOX_USER, nUser)->GetTypeName(),
&sId, nullptr, nullptr);
}
}
bool SwTOXSelectTabPage::FillItemSet( SfxItemSet* )
{
return true ;
}
static tools::Long lcl_TOXTypesToUserData(CurTOXType eType)
{
sal_uInt16 nRet = TOX_INDEX;
switch (eType.eType)
{
case TOX_INDEX : nRet = TO_INDEX; break ;
case TOX_USER :
{
nRet = eType.nIndex << 8;
nRet |= TO_USER;
}
break ;
case TOX_CONTENT : nRet = TO_CONTENT; break ;
case TOX_ILLUSTRATIONS:nRet = TO_ILLUSTRATION; break ;
case TOX_OBJECTS : nRet = TO_OBJECT; break ;
case TOX_TABLES : nRet = TO_TABLE; break ;
case TOX_AUTHORITIES : nRet = TO_AUTHORITIES; break ;
case TOX_BIBLIOGRAPHY : nRet = TO_BIBLIOGRAPHY; break ;
case TOX_CITATION :break ;
}
return nRet;
}
void SwTOXSelectTabPage::SelectType(TOXTypes eSet)
{
CurTOXType eCurType (eSet);
sal_uInt32 nData = lcl_TOXTypesToUserData(eCurType);
m_xTypeLB->set_active_id(OUString::number(nData));
m_xTypeFT->set_sensitive(false );
m_xTypeLB->set_sensitive(false );
TOXTypeHdl(*m_xTypeLB);
}
static CurTOXType lcl_UserData2TOXTypes(sal_uInt16 nData)
{
CurTOXType eRet;
switch (nData&0xff)
{
case TO_INDEX : eRet.eType = TOX_INDEX; break ;
case TO_USER :
{
eRet.eType = TOX_USER;
eRet.nIndex = (nData&0xff00) >> 8;
}
break ;
case TO_CONTENT : eRet.eType = TOX_CONTENT; break ;
case TO_ILLUSTRATION: eRet.eType = TOX_ILLUSTRATIONS; break ;
case TO_OBJECT : eRet.eType = TOX_OBJECTS; break ;
case TO_TABLE : eRet.eType = TOX_TABLES; break ;
case TO_AUTHORITIES : eRet.eType = TOX_AUTHORITIES; break ;
case TO_BIBLIOGRAPHY : eRet.eType = TOX_BIBLIOGRAPHY; break ;
default : OSL_FAIL("what a type?" );
}
return eRet;
}
void SwTOXSelectTabPage::ApplyTOXDescription()
{
SwMultiTOXTabDialog* pTOXDlg = static_cast <SwMultiTOXTabDialog*>(GetDialogController());
const CurTOXType aCurType = pTOXDlg->GetCurrentTOXType();
SwTOXDescription& rDesc = pTOXDlg->GetTOXDescription(aCurType);
m_xReadOnlyCB->set_active(rDesc.IsReadonly());
if (!m_xTitleED->get_value_changed_from_saved())
{
if (rDesc.GetTitle())
m_xTitleED->set_text(*rDesc.GetTitle());
else
m_xTitleED->set_text(OUString());
m_xTitleED->save_value();
}
m_xTitleToggleCB->set_active( !m_xTitleED->get_text().isEmpty() ); // if no title, toggle off
m_xAreaLB->set_active(rDesc.IsFromChapter() ? 1 : 0);
if (aCurType.eType != TOX_INDEX)
m_xLevelNF->set_value(rDesc.GetLevel()); //content, user
SwTOXElement nCreateType = rDesc.GetContentOptions();
//user + content
bool bHasStyleNames = false ;
for ( sal_uInt16 i = 0; i < MAXLEVEL; i++)
if (!rDesc.GetStyleNames(i).isEmpty())
{
bHasStyleNames = true ;
break ;
}
m_xAddStylesCB->set_active(bHasStyleNames && (nCreateType & SwTOXElement::Template ));
m_xFromOLECB->set_active( bool (nCreateType & SwTOXElement::Ole) );
m_xFromTablesCB->set_active( bool (nCreateType & SwTOXElement::Table) );
m_xFromGraphicsCB->set_active( bool (nCreateType & SwTOXElement::Graphic) );
m_xFromFramesCB->set_active( bool (nCreateType & SwTOXElement::Frame) );
m_xLevelFromChapterCB->set_active(rDesc.IsLevelFromChapter());
//all but illustration and table
m_xTOXMarksCB->set_active( bool (nCreateType & SwTOXElement::Mark) );
if (TOX_ILLUSTRATIONS == aCurType.eType || TOX_TABLES == aCurType.eType
|| TOX_OBJECTS== aCurType.eType)
{
// load all para styles...
m_xParaStyleLB->clear();
SwWrtShell const & rWrtSh(static_cast <SwMultiTOXTabDialog*>(GetDialogController())->GetWrtShell());
const sal_uInt16 nSz = rWrtSh.GetTextFormatCollCount();
for (sal_uInt16 j = 0; j < nSz; ++j)
{
SwTextFormatColl const & rColl = rWrtSh.GetTextFormatColl(j);
if (rColl.IsDefault())
continue ;
OUString const name(rColl.GetName().toString());
if (!name.isEmpty())
{
m_xParaStyleLB->append_text(name);
}
}
// first, init ParaStyle - because any later init (e.g. m_xFromCaptionsRB)
// ends up calling FillTOXDescription() resetting rDesc!
UIName const & rStyle(rDesc.GetStyleNames(0));
assert(rStyle.toString().indexOf(TOX_STYLE_DELIMITER) == -1);
if (rStyle.toString().isEmpty())
{
m_xParaStyleCB->set_active(false );
m_xParaStyleLB->set_sensitive(false );
}
else
{
m_xParaStyleCB->set_active(true );
m_xParaStyleLB->set_sensitive(true );
m_xParaStyleLB->set_active_text(rStyle.toString());
}
}
//content
if (TOX_CONTENT == aCurType.eType)
{
m_xFromHeadingsCB->set_active( bool (nCreateType & SwTOXElement::OutlineLevel) );
m_xAddStylesCB->set_label(m_sAddStyleContent);
m_xAddStylesPB->set_sensitive(m_xAddStylesCB->get_active());
}
//index only
else if (TOX_INDEX == aCurType.eType)
{
const SwTOIOptions nIndexOptions = rDesc.GetIndexOptions();
m_xCollectSameCB->set_active( bool (nIndexOptions & SwTOIOptions::SameEntry) );
m_xUseFFCB->set_active( bool (nIndexOptions & SwTOIOptions::FF) );
m_xUseDashCB->set_active( bool (nIndexOptions & SwTOIOptions::Dash) );
if (m_xUseFFCB->get_active())
m_xUseDashCB->set_sensitive(false );
else if (m_xUseDashCB->get_active())
m_xUseFFCB->set_sensitive(false );
m_xCaseSensitiveCB->set_active( bool (nIndexOptions & SwTOIOptions::CaseSensitive) );
m_xInitialCapsCB->set_active( bool (nIndexOptions & SwTOIOptions::InitialCaps) );
m_xKeyAsEntryCB->set_active( bool (nIndexOptions & SwTOIOptions::KeyAsEntry) );
}
else if (TOX_ILLUSTRATIONS == aCurType.eType || TOX_TABLES == aCurType.eType)
{
OUString sName(rDesc.GetSequenceName().toString());
int nIndex = m_xCaptionSequenceLB->find_text(sName);
if (nIndex != -1)
m_xCaptionSequenceLB->set_active(nIndex);
m_xDisplayTypeLB->set_active(static_cast <sal_Int32>(rDesc.GetCaptionDisplay()));
if (m_xDisplayTypeLB->get_active() == -1)
m_xDisplayTypeLB->set_active(0);
m_xFromObjectNamesRB->set_active(rDesc.IsCreateFromObjectNames());
m_xFromCaptionsRB->set_active(!rDesc.IsCreateFromObjectNames());
RadioButtonHdl(*m_xFromCaptionsRB);
}
else if (TOX_OBJECTS == aCurType.eType)
{
SwTOOElements nOLEData = rDesc.GetOLEOptions();
for (int nFromObj = 0, nCount = m_xFromObjCLB->n_children(); nFromObj < nCount; ++nFromObj)
{
SwTOOElements nData = static_cast <SwTOOElements>(m_xFromObjCLB->get_id(nFromObj).toInt32());
m_xFromObjCLB->set_toggle(nFromObj, bool (nData & nOLEData) ? TRISTATE_TRUE : TRISTATE_FALSE);
}
}
else if (TOX_AUTHORITIES == aCurType.eType)
{
const OUString& sBrackets(rDesc.GetAuthBrackets());
if (sBrackets.isEmpty() || sBrackets == " " )
m_xBracketLB->set_active(0);
else
m_xBracketLB->set_active_text(sBrackets);
m_xSequenceCB->set_active(rDesc.IsAuthSequence());
}
m_xAutoMarkPB->set_sensitive(m_xFromFileCB->get_active());
for (sal_uInt16 i = 0; i < MAXLEVEL; i++)
m_aStyleArr[i] = rDesc.GetStyleNames(i);
m_xLanguageLB->set_active_id(rDesc.GetLanguage());
LanguageHdl(nullptr);
for (int nCnt = 0, nEntryCount = m_xSortAlgorithmLB->get_count(); nCnt < nEntryCount; ++nCnt)
{
const OUString aEntryData = m_xSortAlgorithmLB->get_id(nCnt);
if (aEntryData == rDesc.GetSortAlgorithm())
{
m_xSortAlgorithmLB->set_active(nCnt);
break ;
}
}
}
void SwTOXSelectTabPage::FillTOXDescription()
{
SwMultiTOXTabDialog* pTOXDlg = static_cast <SwMultiTOXTabDialog*>(GetDialogController());
CurTOXType aCurType = pTOXDlg->GetCurrentTOXType();
SwTOXDescription& rDesc = pTOXDlg->GetTOXDescription(aCurType);
if (m_xTitleToggleCB->get_active())
{
rDesc.SetTitle(m_xTitleED->get_text());
}
else
{
rDesc.SetTitle(OUString());
}
m_xTitleED->set_sensitive(m_xTitleToggleCB->get_active());
rDesc.SetFromChapter(1 == m_xAreaLB->get_active());
SwTOXElement nContentOptions = SwTOXElement::NONE;
if (m_xTOXMarksCB->get_visible() && m_xTOXMarksCB->get_active())
nContentOptions |= SwTOXElement::Mark;
SwTOIOptions nIndexOptions = rDesc.GetIndexOptions()&SwTOIOptions::AlphaDelimiter;
switch (rDesc.GetTOXType())
{
case TOX_CONTENT:
if (m_xFromHeadingsCB->get_active())
nContentOptions |= SwTOXElement::OutlineLevel;
break ;
case TOX_USER:
{
rDesc.SetTOUName(m_xTypeLB->get_active_text());
if (m_xFromOLECB->get_active())
nContentOptions |= SwTOXElement::Ole;
if (m_xFromTablesCB->get_active())
nContentOptions |= SwTOXElement::Table;
if (m_xFromFramesCB->get_active())
nContentOptions |= SwTOXElement::Frame;
if (m_xFromGraphicsCB->get_active())
nContentOptions |= SwTOXElement::Graphic;
}
break ;
case TOX_INDEX:
{
nContentOptions = SwTOXElement::Mark;
if (m_xCollectSameCB->get_active())
nIndexOptions |= SwTOIOptions::SameEntry;
if (m_xUseFFCB->get_active())
nIndexOptions |= SwTOIOptions::FF;
if (m_xUseDashCB->get_active())
nIndexOptions |= SwTOIOptions::Dash;
if (m_xCaseSensitiveCB->get_active())
nIndexOptions |= SwTOIOptions::CaseSensitive;
if (m_xInitialCapsCB->get_active())
nIndexOptions |= SwTOIOptions::InitialCaps;
if (m_xKeyAsEntryCB->get_active())
nIndexOptions |= SwTOIOptions::KeyAsEntry;
if (m_xFromFileCB->get_active())
rDesc.SetAutoMarkURL(m_sAutoMarkURL);
else
rDesc.SetAutoMarkURL(OUString());
}
break ;
case TOX_ILLUSTRATIONS:
case TOX_TABLES :
rDesc.SetCreateFromObjectNames(m_xFromObjectNamesRB->get_active());
rDesc.SetSequenceName(UIName(m_xCaptionSequenceLB->get_active_text()));
rDesc.SetCaptionDisplay(static_cast <SwCaptionDisplay>(m_xDisplayTypeLB->get_active()));
if (m_xParaStyleCB->get_active())
{
m_aStyleArr[0] = UIName(m_xParaStyleLB->get_active_text());
}
else
{
m_aStyleArr[0] = UIName();
}
break ;
case TOX_OBJECTS:
{
SwTOOElements nOLEData = SwTOOElements::NONE;
for (int i = 0, nCount = m_xFromObjCLB->n_children(); i < nCount; ++i)
{
if (m_xFromObjCLB->get_toggle(i) == TRISTATE_TRUE)
{
SwTOOElements nData = static_cast <SwTOOElements>(m_xFromObjCLB->get_id(i).toInt32());
nOLEData |= nData;
}
}
rDesc.SetOLEOptions(nOLEData);
if (m_xParaStyleCB->get_active())
{
m_aStyleArr[0] = UIName(m_xParaStyleLB->get_active_text());
}
else
{
m_aStyleArr[0] = UIName();
}
}
break ;
case TOX_AUTHORITIES:
case TOX_BIBLIOGRAPHY :
{
if (m_xBracketLB->get_active())
rDesc.SetAuthBrackets(m_xBracketLB->get_active_text());
else
rDesc.SetAuthBrackets(OUString());
rDesc.SetAuthSequence(m_xSequenceCB->get_active());
}
break ;
case TOX_CITATION :
break ;
}
rDesc.SetLevelFromChapter( m_xLevelFromChapterCB->get_visible() &&
m_xLevelFromChapterCB->get_active());
if (m_xTOXMarksCB->get_active() && m_xTOXMarksCB->get_visible())
nContentOptions |= SwTOXElement::Mark;
if (m_xFromHeadingsCB->get_active() && m_xFromHeadingsCB->get_visible())
nContentOptions |= SwTOXElement::OutlineLevel;
if ((m_xAddStylesCB->get_active() && m_xAddStylesCB->get_visible())
|| (m_xParaStyleCB->get_active() && m_xParaStyleCB->get_visible()))
{
nContentOptions |= SwTOXElement::Template ;
}
rDesc.SetContentOptions(nContentOptions);
rDesc.SetIndexOptions(nIndexOptions);
rDesc.SetLevel(m_xLevelNF->get_value());
rDesc.SetReadonly(m_xReadOnlyCB->get_active());
for (sal_uInt16 i = 0; i < MAXLEVEL; i++)
rDesc.SetStyleNames(m_aStyleArr[i], i);
rDesc.SetLanguage(m_xLanguageLB->get_active_id());
const OUString aEntryData = m_xSortAlgorithmLB->get_active_id();
rDesc.SetSortAlgorithm(aEntryData);
}
void SwTOXSelectTabPage::Reset( const SfxItemSet* )
{
SwMultiTOXTabDialog* pTOXDlg = static_cast <SwMultiTOXTabDialog*>(GetDialogController());
SwWrtShell& rSh = pTOXDlg->GetWrtShell();
const CurTOXType aCurType = pTOXDlg->GetCurrentTOXType();
sal_uInt32 nData = lcl_TOXTypesToUserData(aCurType);
m_xTypeLB->set_active_id(OUString::number(nData));
m_sAutoMarkURL = INetURLObject::decode( rSh.GetTOIAutoMarkURL(),
INetURLObject::DecodeMechanism::Unambiguous );
m_xFromFileCB->set_active(!m_sAutoMarkURL.isEmpty());
m_xCaptionSequenceLB->clear();
const size_t nCount = rSh.GetFieldTypeCount(SwFieldIds::SetExp);
for (size_t i = 0; i < nCount; ++i)
{
SwFieldType *pType = rSh.GetFieldType( i, SwFieldIds::SetExp );
if ( pType->Which() == SwFieldIds::SetExp &&
static_cast <SwSetExpFieldType *>( pType)->GetType() & nsSwGetSetExpType::GSE_SEQ )
m_xCaptionSequenceLB->append_text(pType->GetName().toString());
}
if (pTOXDlg->IsTOXEditMode())
{
m_xTypeFT->set_sensitive(false );
m_xTypeLB->set_sensitive(false );
}
if (!m_bWaitingInitialSettings)
{
// save current values into the proper TOXDescription
FillTOXDescription();
}
m_bWaitingInitialSettings = false ;
TOXTypeHdl(*m_xTypeLB);
CheckBoxHdl(*m_xAddStylesCB);
}
void SwTOXSelectTabPage::ActivatePage( const SfxItemSet& )
{
//nothing to do
}
DeactivateRC SwTOXSelectTabPage::DeactivatePage(SfxItemSet* _pSet)
{
if (_pSet)
_pSet->Put(SfxUInt16Item(FN_PARAM_TOX_TYPE, m_xTypeLB->get_active_id().toUInt32()));
FillTOXDescription();
return DeactivateRC::LeavePage;
}
std::unique_ptr<SfxTabPage> SwTOXSelectTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet)
{
return std::make_unique<SwTOXSelectTabPage>(pPage, pController, *rAttrSet);
}
IMPL_LINK(SwTOXSelectTabPage, TOXTypeHdl, weld::ComboBox&, rBox, void )
{
SwMultiTOXTabDialog* pTOXDlg = static_cast <SwMultiTOXTabDialog*>(GetDialogController());
const sal_uInt16 nType = rBox.get_active_id().toUInt32();
CurTOXType eCurType = lcl_UserData2TOXTypes(nType);
pTOXDlg->SetCurrentTOXType(eCurType);
m_xAreaLB->set_visible( 0 != (nType & (TO_CONTENT|TO_ILLUSTRATION|TO_USER|TO_INDEX|TO_TABLE|TO_OBJECT)) );
m_xLevelFT->set_visible( 0 != (nType & (TO_CONTENT)) );
m_xLevelNF->set_visible( 0 != (nType & (TO_CONTENT)) );
m_xLevelFromChapterCB->set_visible( 0 != (nType & (TO_USER)) );
m_xAreaFrame->set_visible( 0 != (nType & (TO_CONTENT|TO_ILLUSTRATION|TO_USER|TO_INDEX|TO_TABLE|TO_OBJECT)) );
m_xFromHeadingsCB->set_visible( 0 != (nType & (TO_CONTENT)) );
m_xAddStylesCB->set_visible( 0 != (nType & (TO_CONTENT|TO_USER)) );
m_xAddStylesPB->set_visible( 0 != (nType & (TO_CONTENT|TO_USER)) );
m_xFromTablesCB->set_visible( 0 != (nType & (TO_USER)) );
m_xFromFramesCB->set_visible( 0 != (nType & (TO_USER)) );
m_xFromGraphicsCB->set_visible( 0 != (nType & (TO_USER)) );
m_xFromOLECB->set_visible( 0 != (nType & (TO_USER)) );
m_xFromCaptionsRB->set_visible( 0 != (nType & (TO_ILLUSTRATION|TO_TABLE)) );
m_xFromObjectNamesRB->set_visible( 0 != (nType & (TO_ILLUSTRATION|TO_TABLE)) );
m_xTOXMarksCB->set_visible( 0 != (nType & (TO_CONTENT|TO_USER)) );
m_xCreateFrame->set_visible( 0 != (nType & (TO_CONTENT|TO_ILLUSTRATION|TO_USER|TO_TABLE)) );
m_xCaptionSequenceFT->set_visible( 0 != (nType & (TO_ILLUSTRATION|TO_TABLE)) );
m_xCaptionSequenceLB->set_visible( 0 != (nType & (TO_ILLUSTRATION|TO_TABLE)) );
m_xDisplayTypeFT->set_visible( 0 != (nType & (TO_ILLUSTRATION|TO_TABLE)) );
m_xDisplayTypeLB->set_visible( 0 != (nType & (TO_ILLUSTRATION|TO_TABLE)) );
m_xParaStyleCB->set_visible(0 != (nType & (TO_ILLUSTRATION|TO_TABLE|TO_OBJECT)));
m_xParaStyleLB->set_visible(0 != (nType & (TO_ILLUSTRATION|TO_TABLE|TO_OBJECT)));
m_xAuthorityFrame->set_visible( 0 != (nType & TO_AUTHORITIES) );
bool bEnableSortLanguage = 0 != (nType & (TO_INDEX|TO_AUTHORITIES));
m_xSortFrame->set_visible(bEnableSortLanguage);
if ( nType & TO_ILLUSTRATION )
{
UIName sName(SwStyleNameMapper::GetUIName(RES_POOLCOLL_LABEL_FIGURE, ProgName()));
m_xCaptionSequenceLB->set_active_text(sName.toString());
}
else if ( nType & TO_TABLE )
{
UIName sName(SwStyleNameMapper::GetUIName(RES_POOLCOLL_LABEL_TABLE, ProgName()));
m_xCaptionSequenceLB->set_active_text(sName.toString());
}
else if ( nType & TO_USER )
{
m_xAddStylesCB->set_label(m_sAddStyleUser);
}
m_xIdxOptionsFrame->set_visible( 0 != (nType & TO_INDEX) );
//object index
m_xFromObjFrame->set_visible( 0 != (nType & TO_OBJECT) );
//set control values from the proper TOXDescription
{
ApplyTOXDescription();
}
ModifyHdl();
}
void SwTOXSelectTabPage::ModifyHdl()
{
if (!m_bWaitingInitialSettings)
{
FillTOXDescription();
SwMultiTOXTabDialog* pTOXDlg = static_cast <SwMultiTOXTabDialog*>(GetDialogController());
pTOXDlg->CreateOrUpdateExample(pTOXDlg->GetCurrentTOXType().eType, TOX_PAGE_SELECT);
}
}
IMPL_LINK_NOARG(SwTOXSelectTabPage, ModifyListBoxHdl, weld::ComboBox&, void )
{
ModifyHdl();
}
IMPL_LINK_NOARG(SwTOXSelectTabPage, ModifyEntryHdl, weld::Entry&, void )
{
ModifyHdl();
}
IMPL_LINK_NOARG(SwTOXSelectTabPage, ModifySpinHdl, weld::SpinButton&, void )
{
ModifyHdl();
}
IMPL_LINK(SwTOXSelectTabPage, CheckBoxHdl, weld::Toggleable&, rButton, void )
{
SwMultiTOXTabDialog* pTOXDlg = static_cast <SwMultiTOXTabDialog*>(GetDialogController());
const CurTOXType aCurType = pTOXDlg->GetCurrentTOXType();
if (TOX_CONTENT == aCurType.eType)
{
//at least one of the three CheckBoxes must be checked
if (!m_xAddStylesCB->get_active() && !m_xFromHeadingsCB->get_active() && !m_xTOXMarksCB->get_active())
{
//TODO: InfoBox?
rButton.set_active(true );
}
m_xAddStylesPB->set_sensitive(m_xAddStylesCB->get_active());
}
if (TOX_USER == aCurType.eType)
{
m_xAddStylesPB->set_sensitive(m_xAddStylesCB->get_active());
}
else if (TOX_INDEX == aCurType.eType)
{
m_xAutoMarkPB->set_sensitive(m_xFromFileCB->get_active());
m_xUseFFCB->set_sensitive(m_xCollectSameCB->get_active() && !m_xUseDashCB->get_active());
m_xUseDashCB->set_sensitive(m_xCollectSameCB->get_active() && !m_xUseFFCB->get_active());
m_xCaseSensitiveCB->set_sensitive(m_xCollectSameCB->get_active());
// tdf#164847 - update menu items based on concordance file presence
MenuEnableHdl(*m_xAutoMarkPB);
}
else if (TOX_ILLUSTRATIONS == aCurType.eType
|| TOX_TABLES == aCurType.eType
|| TOX_OBJECTS == aCurType.eType)
{
bool const bEnable(m_xParaStyleCB->get_active());
m_xParaStyleLB->set_sensitive(bEnable);
}
ModifyHdl();
};
IMPL_LINK_NOARG(SwTOXSelectTabPage, RadioButtonHdl, weld::Toggleable&, void )
{
bool bEnable = m_xFromCaptionsRB->get_active();
m_xCaptionSequenceFT->set_sensitive(bEnable);
m_xCaptionSequenceLB->set_sensitive(bEnable);
m_xDisplayTypeFT->set_sensitive(bEnable);
m_xDisplayTypeLB->set_sensitive(bEnable);
ModifyHdl();
}
IMPL_LINK(SwTOXSelectTabPage, LanguageListBoxHdl, weld::ComboBox&, rBox, void )
{
LanguageHdl(&rBox);
}
void SwTOXSelectTabPage::LanguageHdl(const weld::ComboBox* pBox)
{
lang::Locale aLcl( LanguageTag( m_xLanguageLB->get_active_id() ).getLocale() );
Sequence< OUString > aSeq = m_pIndexEntryWrapper->GetAlgorithmList( aLcl );
if ( !m_pIndexRes )
m_pIndexRes.reset(new IndexEntryResource());
OUString sOldString = m_xSortAlgorithmLB->get_active_id();
m_xSortAlgorithmLB->clear();
sal_Int32 nEnd = aSeq.getLength();
for ( sal_Int32 nCnt = 0; nCnt < nEnd; ++nCnt )
{
const OUString& sAlg(aSeq[ nCnt ]);
const OUString sUINm = m_pIndexRes->GetTranslation( sAlg );
m_xSortAlgorithmLB->append(sAlg, sUINm);
if ( sAlg == sOldString )
m_xSortAlgorithmLB->set_active(nCnt);
}
if (m_xSortAlgorithmLB->get_active() == -1)
m_xSortAlgorithmLB->set_active(0);
if (pBox)
ModifyHdl();
};
IMPL_LINK_NOARG(SwTOXSelectTabPage, AddStylesHdl, weld::Button&, void )
{
SwAddStylesDlg_Impl aDlg(GetFrameWeld(), static_cast <SwMultiTOXTabDialog*>(GetDialogController())->GetWrtShell(),
m_aStyleArr);
aDlg.run();
ModifyHdl();
}
IMPL_LINK_NOARG(SwTOXSelectTabPage, MenuEnableHdl, weld::Toggleable&, void )
{
m_xAutoMarkPB->set_item_sensitive(u"edit" _ustr, !m_sAutoMarkURL.isEmpty());
}
IMPL_LINK(SwTOXSelectTabPage, MenuExecuteHdl, const OUString&, rIdent, void )
{
const OUString sSaveAutoMarkURL = m_sAutoMarkURL;
if (rIdent == "open" )
{
m_sAutoMarkURL = lcl_CreateAutoMarkFileDlg(GetFrameWeld(),
m_sAutoMarkURL, m_sAutoMarkType, true );
}
else if (rIdent == "new" || rIdent == "edit" )
{
bool bNew = (rIdent == "new" );
if (bNew)
{
m_sAutoMarkURL = lcl_CreateAutoMarkFileDlg(GetFrameWeld(),
m_sAutoMarkURL, m_sAutoMarkType, false );
if (m_sAutoMarkURL.isEmpty())
return ;
}
SwAutoMarkDlg_Impl aAutoMarkDlg(GetFrameWeld(), m_sAutoMarkURL, bNew);
if (RET_OK != aAutoMarkDlg.run() && bNew)
m_sAutoMarkURL = sSaveAutoMarkURL;
}
// tdf#164847 - update menu items based on concordance file presence
MenuEnableHdl(*m_xAutoMarkPB);
}
class SwTOXWidget
{
protected :
Link<SwTOXWidget&,void > m_aGetFocusLink;
public :
virtual WindowType GetType() const = 0;
virtual void GrabFocus() = 0;
virtual void Hide() = 0;
virtual void set_grid_left_attach(int nPos) = 0;
virtual void get_extents_relative_to(weld::Widget& rRelative, int & x, int & y, int & width, int & height) = 0;
void SetGetFocusHdl(const Link<SwTOXWidget&,void >& rLink) { m_aGetFocusLink = rLink; }
virtual ~SwTOXWidget() {}
};
class SwTOXEdit : public SwTOXWidget
{
std::unique_ptr<weld::Builder> m_xBuilder;
SwFormToken m_aFormToken;
Link<SwTOXEdit&,void > m_aModifiedLink;
Link<SwTOXEdit&,void > m_aPrevNextControlLink;
bool m_bNextControl;
SwTokenWindow* m_pParent;
std::unique_ptr<weld::Entry> m_xEntry;
DECL_LINK(ModifyHdl, weld::Entry&, void );
public :
SwTOXEdit(SwTokenWindow* pTokenWin, const SwFormToken& rToken)
: m_xBuilder(Application::CreateBuilder(pTokenWin->get_child_container(), u"modules/swriter/ui/toxentrywidget.ui" _ustr))
, m_aFormToken(rToken)
, m_bNextControl(false )
, m_pParent(pTokenWin)
, m_xEntry(m_xBuilder->weld_entry(u"entry" _ustr))
{
m_xEntry->connect_changed(LINK(this , SwTOXEdit, ModifyHdl));
m_xEntry->connect_key_press(LINK(this , SwTOXEdit, KeyInputHdl));
m_xEntry->connect_focus_in(LINK(this , SwTOXEdit, FocusInHdl));
m_xEntry->set_tooltip_text(m_pParent->CreateQuickHelp(rToken));
}
virtual ~SwTOXEdit() override
{
m_pParent->get_child_container()->move(m_xEntry.get(), nullptr);
}
virtual WindowType GetType() const override
{
return WindowType::EDIT;
}
virtual void GrabFocus() override
{
m_xEntry->grab_focus();
}
virtual void Hide() override
{
m_xEntry->hide();
}
void Show()
{
m_xEntry->show();
}
void SetAccessibleName(const OUString& rName)
{
m_xEntry->set_accessible_name(rName);
}
virtual void set_grid_left_attach(int nPos) override
{
m_pParent->get_child_container()->set_child_left_attach(*m_xEntry, nPos);
}
virtual void get_extents_relative_to(weld::Widget& rRelative, int & x, int & y, int & width, int & height) override
{
m_xEntry->get_extents_relative_to(rRelative, x, y, width, height);
}
OUString GetText() const
{
return m_xEntry->get_text();
}
void SetText(const OUString& rText)
{
m_xEntry->set_text(rText);
}
void get_selection_bounds(int & rStartPos, int & rEndPos)
{
m_xEntry->get_selection_bounds(rStartPos, rEndPos);
}
void select_region(int nStartPos, int nEndPos)
{
m_xEntry->select_region(nStartPos, nEndPos);
}
void SetModifyHdl(const Link<SwTOXEdit&,void >& rLink)
{
m_aModifiedLink = rLink;
}
DECL_LINK(KeyInputHdl, const KeyEvent&, bool );
DECL_LINK(FocusInHdl, weld::Widget&, void );
bool IsNextControl() const { return m_bNextControl; }
void SetPrevNextLink(const Link<SwTOXEdit&,void >& rLink) { m_aPrevNextControlLink = rLink; }
const SwFormToken& GetFormToken()
{
m_aFormToken.sText = m_xEntry->get_text();
return m_aFormToken;
}
void SetCharStyleName(const UIName& rSet, sal_uInt16 nPoolId)
{
m_aFormToken.sCharStyleName = rSet;
m_aFormToken.nPoolId = nPoolId;
}
void AdjustSize();
};
IMPL_LINK_NOARG(SwTOXEdit, ModifyHdl, weld::Entry&, void )
{
m_aModifiedLink.Call(*this );
}
IMPL_LINK(SwTOXEdit, KeyInputHdl, const KeyEvent&, rKEvt, bool )
{
bool bCall = false ;
int nStartPos, nEndPos;
bool bStartIsEnd = !m_xEntry->get_selection_bounds(nStartPos, nEndPos);
int nMin = std::min(nStartPos, nEndPos);
const sal_Int32 nTextLen = GetText().getLength();
if ((bStartIsEnd && !nMin) || nMin == nTextLen)
{
vcl::KeyCode aCode = rKEvt.GetKeyCode();
if (aCode.GetCode() == KEY_RIGHT && nMin == nTextLen)
{
m_bNextControl = true ;
bCall = true ;
}
else if (aCode.GetCode() == KEY_LEFT && !nMin)
{
m_bNextControl = false ;
bCall = true ;
}
else if ( (aCode.GetCode() == KEY_F3) && aCode.IsShift() && !aCode.IsMod1() && !aCode.IsMod2() )
{
if (m_pParent)
{
m_pParent->SetFocus2theAllBtn();
}
}
if (bCall && m_aPrevNextControlLink.IsSet())
m_aPrevNextControlLink.Call(*this );
else
bCall = false ;
}
return bCall;
}
IMPL_LINK_NOARG(SwTOXEdit, FocusInHdl, weld::Widget&, void )
{
m_aGetFocusLink.Call(*this );
}
void SwTOXEdit::AdjustSize()
{
auto nWidth = m_xEntry->get_pixel_size(GetText()).Width();
float fChars = nWidth / m_xEntry->get_approximate_digit_width();
m_xEntry->set_width_chars(std::max(1.0f, std::ceil(fChars)));
}
class SwTOXButton : public SwTOXWidget
{
std::unique_ptr<weld::Builder> m_xBuilder;
SwFormToken m_aFormToken;
Link<SwTOXButton&,void > m_aPrevNextControlLink;
bool m_bNextControl;
SwTokenWindow* m_pParent;
std::unique_ptr<weld::ToggleButton> m_xButton;
public :
SwTOXButton(SwTokenWindow* pTokenWin, const SwFormToken& rToken)
: m_xBuilder(Application::CreateBuilder(pTokenWin->get_child_container(), u"modules/swriter/ui/toxbuttonwidget.ui" _ustr))
, m_aFormToken(rToken)
, m_bNextControl(false )
, m_pParent(pTokenWin)
, m_xButton(m_xBuilder->weld_toggle_button(u"button" _ustr))
{
m_xButton->connect_key_press(LINK(this , SwTOXButton, KeyInputHdl));
m_xButton->connect_focus_in(LINK(this , SwTOXButton, FocusInHdl));
m_xButton->set_tooltip_text(m_pParent->CreateQuickHelp(rToken));
}
virtual ~SwTOXButton() override
{
m_pParent->get_child_container()->move(m_xButton.get(), nullptr);
}
virtual WindowType GetType() const override
{
return WindowType::PUSHBUTTON;
}
virtual void GrabFocus() override
{
m_xButton->grab_focus();
}
virtual void Hide() override
{
m_xButton->hide();
}
void Show()
{
m_xButton->show();
}
void SetAccessibleName(const OUString& rName)
{
m_xButton->set_accessible_name(rName);
}
virtual void set_grid_left_attach(int nPos) override
{
m_pParent->get_child_container()->set_child_left_attach(*m_xButton, nPos);
}
void get_extents_relative_to(weld::Widget& rRelative, int & x, int & y, int & width, int & height) override
{
m_xButton->get_extents_relative_to(rRelative, x, y, width, height);
}
void Check(bool bCheck = true )
{
m_xButton->set_active(bCheck);
}
DECL_LINK(KeyInputHdl, const KeyEvent&, bool );
DECL_LINK(FocusInHdl, weld::Widget&, void );
bool IsNextControl() const {return m_bNextControl;}
void SetPrevNextLink(const Link<SwTOXButton&,void >& rLink) {m_aPrevNextControlLink = rLink;}
const SwFormToken& GetFormToken() const {return m_aFormToken;}
void SetCharStyleName(const UIName& rSet, sal_uInt16 nPoolId)
{
m_aFormToken.sCharStyleName = rSet;
m_aFormToken.nPoolId = nPoolId;
}
void SetTabPosition(SwTwips nSet)
{ m_aFormToken.nTabStopPosition = nSet; }
void SetFillChar( sal_Unicode cSet )
{ m_aFormToken.cTabFillChar = cSet; }
void SetTabAlign(SvxTabAdjust eAlign)
{ m_aFormToken.eTabAlign = eAlign;}
//---> i89791
//used for entry number format, in TOC only
//needed for different UI dialog position
void SetEntryNumberFormat(sal_uInt16 nSet) {
switch (nSet)
{
default :
case 0:
m_aFormToken.nChapterFormat = CF_NUMBER;
break ;
case 1:
m_aFormToken.nChapterFormat = CF_NUM_NOPREPST_TITLE;
break ;
}
}
void SetChapterInfo(sal_uInt16 nSet) {
switch (nSet)
{
default :
case 0:
m_aFormToken.nChapterFormat = CF_NUM_NOPREPST_TITLE;
break ;
case 1:
m_aFormToken.nChapterFormat = CF_TITLE;
break ;
case 2:
m_aFormToken.nChapterFormat = CF_NUMBER_NOPREPST;
break ;
}
}
void SetOutlineLevel( sal_uInt16 nSet ) { m_aFormToken.nOutlineLevel = nSet;}//i53420
void SetText(const OUString& rText)
{
m_xButton->set_label(rText);
}
void SetLinkEnd()
{
OSL_ENSURE(TOKEN_LINK_START == m_aFormToken.eTokenType,
"call SetLinkEnd for link start only!" );
m_aFormToken.eTokenType = TOKEN_LINK_END;
m_aFormToken.sText = SwForm::GetFormLinkEnd();
SetText(m_aFormToken.sText);
}
void SetLinkStart()
{
OSL_ENSURE(TOKEN_LINK_END == m_aFormToken.eTokenType,
"call SetLinkStart for link start only!" );
m_aFormToken.eTokenType = TOKEN_LINK_START;
m_aFormToken.sText = SwForm::GetFormLinkStt();
--> --------------------
--> maximum size reached
--> --------------------
Messung V0.5 C=97 H=94 G=95
¤ Dauer der Verarbeitung: 0.21 Sekunden
(vorverarbeitet)
¤
*© Formatika GbR, Deutschland