summaryrefslogtreecommitdiffstats
path: root/cui/source/customize
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-03-04 17:31:24 +0000
committerCaolán McNamara <caolanm@redhat.com>2019-03-11 10:00:31 +0100
commitccb2b0078f07194befa61f1e3fd88e53ff236871 (patch)
tree0bfe058721741581eb3ef6489737fdbd902f8d04 /cui/source/customize
parentweld SfxDocumentPage (diff)
downloadcore-ccb2b0078f07194befa61f1e3fd88e53ff236871.tar.gz
core-ccb2b0078f07194befa61f1e3fd88e53ff236871.zip
weld SvxMenuConfigPage/SvxToolbarConfigPage
Change-Id: I166ac6c0be8461ea38db711796d1e14fc5b78998 Reviewed-on: https://gerrit.libreoffice.org/68889 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'cui/source/customize')
-rw-r--r--cui/source/customize/CommandCategoryListBox.cxx159
-rw-r--r--cui/source/customize/SvxMenuConfigPage.cxx260
-rw-r--r--cui/source/customize/SvxToolbarConfigPage.cxx635
-rw-r--r--cui/source/customize/acccfg.cxx10
-rw-r--r--cui/source/customize/cfg.cxx567
-rw-r--r--cui/source/customize/cfgutil.cxx85
6 files changed, 668 insertions, 1048 deletions
diff --git a/cui/source/customize/CommandCategoryListBox.cxx b/cui/source/customize/CommandCategoryListBox.cxx
index 7b50dd9a8719..2f9a9a451512 100644
--- a/cui/source/customize/CommandCategoryListBox.cxx
+++ b/cui/source/customize/CommandCategoryListBox.cxx
@@ -41,18 +41,19 @@
#include <dialmgr.hxx>
#include <strings.hrc>
#include <bitmaps.hlst>
+#include <comphelper/processfactory.hxx>
#include <comphelper/sequenceashashmap.hxx>
+#include <comphelper/string.hxx>
+#include <i18nlangtag/languagetag.hxx>
#include <i18nutil/searchopt.hxx>
#include <sal/log.hxx>
#include <cfg.hxx> //for SaveInData
-CommandCategoryListBox::CommandCategoryListBox(vcl::Window* pParent)
- : ListBox( pParent, WB_BORDER | WB_DROPDOWN | WB_SORT )
- , pStylesInfo( nullptr )
+CommandCategoryListBox::CommandCategoryListBox(std::unique_ptr<weld::ComboBox> xControl)
+ : pStylesInfo( nullptr )
+ , m_xControl(std::move(xControl))
{
- SetDropDownLineCount(25);
-
//Initialize search util
m_searchOptions.AlgorithmType2 = css::util::SearchAlgorithms2::ABSOLUTE;
m_searchOptions.transliterateFlags |= TransliterationFlags::IGNORE_CASE;
@@ -60,17 +61,9 @@ CommandCategoryListBox::CommandCategoryListBox(vcl::Window* pParent)
| css::util::SearchFlags::REG_NOT_ENDOFLINE);
}
-VCL_BUILDER_FACTORY(CommandCategoryListBox);
-
CommandCategoryListBox::~CommandCategoryListBox()
{
- disposeOnce();
-}
-
-void CommandCategoryListBox::dispose()
-{
ClearAll();
- ListBox::dispose();
}
void CommandCategoryListBox::ClearAll()
@@ -99,7 +92,7 @@ void CommandCategoryListBox::ClearAll()
}
m_aGroupInfo.clear();
- Clear();
+ m_xControl->clear();
}
void CommandCategoryListBox::Init(
@@ -108,7 +101,7 @@ void CommandCategoryListBox::Init(
const OUString& sModuleLongName)
{
// User will not see incomplete UI
- SetUpdateMode(false);
+ m_xControl->freeze();
ClearAll();
m_xContext = xContext;
@@ -136,24 +129,25 @@ void CommandCategoryListBox::Init(
css::uno::Sequence< sal_Int16 > lGroups = xProvider->getSupportedCommandGroups();
sal_Int32 nGroupsLength = lGroups.getLength();
- sal_Int32 nEntryPos = 0;
if ( nGroupsLength > 0 )
{
// Add the category of "All commands"
- nEntryPos = InsertEntry( CuiResId(RID_SVXSTR_ALLFUNCTIONS) );
m_aGroupInfo.push_back( std::make_unique<SfxGroupInfo_Impl>( SfxCfgKind::GROUP_ALLFUNCTIONS, 0 ) );
- SetEntryData( nEntryPos, m_aGroupInfo.back().get() );
+ m_xControl->append(OUString::number(reinterpret_cast<sal_Int64>(m_aGroupInfo.back().get())), CuiResId(RID_SVXSTR_ALLFUNCTIONS));
}
// Separate the "All commands"category from the actual categories
- AddSeparator( 0 );
+ m_xControl->append_separator();
+
+ typedef std::pair<OUString, sal_Int16> str_id;
+ std::vector<str_id> aCategories;
// Add the actual categories
for (sal_Int32 i = 0; i < nGroupsLength; ++i)
{
- sal_Int16& rGroupID = lGroups[i];
- OUString sGroupID = OUString::number(rGroupID);
+ sal_Int16 nGroupID = lGroups[i];
+ OUString sGroupID = OUString::number(nGroupID);
OUString sGroupName;
try
@@ -166,33 +160,39 @@ void CommandCategoryListBox::Init(
{
continue;
}
+ aCategories.emplace_back(std::make_pair(sGroupName, nGroupID));
+ }
+
+ auto const sort = comphelper::string::NaturalStringSorter(
+ comphelper::getProcessComponentContext(),
+ Application::GetSettings().GetUILanguageTag().getLocale());
+
+ std::sort(aCategories.begin(), aCategories.end(),
+ [&sort](const str_id& a, const str_id& b)
+ { return sort.compare(a.first, b.first) < 0; });
- nEntryPos = InsertEntry( sGroupName );
- m_aGroupInfo.push_back(
- std::make_unique<SfxGroupInfo_Impl>( SfxCfgKind::GROUP_FUNCTION, rGroupID ) );
- SetEntryData( nEntryPos, m_aGroupInfo.back().get() );
+ // Add the actual categories
+ for (const auto &a : aCategories)
+ {
+ const OUString& rGroupName = a.first;
+ sal_Int16 nGroupID = a.second;
+ m_aGroupInfo.push_back(std::make_unique<SfxGroupInfo_Impl>(SfxCfgKind::GROUP_FUNCTION, nGroupID));
+ m_xControl->append(OUString::number(reinterpret_cast<sal_Int64>(m_aGroupInfo.back().get())), rGroupName);
}
// Separate regular commands from styles and macros
- AddSeparator( GetEntryCount() - 1 );
-
- // Stop sorting, and add Macros and Styles to the end of the list
- SetStyle(GetStyle() & ~WB_SORT);
+ m_xControl->append_separator();
// Add macros category
- OUString sMacros( CuiResId(RID_SVXSTR_MACROS) );
- nEntryPos = InsertEntry( sMacros );
m_aGroupInfo.push_back(
std::make_unique<SfxGroupInfo_Impl>( SfxCfgKind::GROUP_SCRIPTCONTAINER, 0, nullptr) );
- SetEntryData( nEntryPos, m_aGroupInfo.back().get() );
+ m_xControl->append(OUString::number(reinterpret_cast<sal_Int64>(m_aGroupInfo.back().get())), CuiResId(RID_SVXSTR_MACROS));
// Add styles category
- OUString sStyle( CuiResId(RID_SVXSTR_GROUP_STYLES) );
- nEntryPos = InsertEntry( sStyle );
//TODO: last param should contain user data?
m_aGroupInfo.push_back(
std::make_unique<SfxGroupInfo_Impl>( SfxCfgKind::GROUP_STYLES, 0, nullptr ) );
- SetEntryData( nEntryPos, m_aGroupInfo.back().get() );
+ m_xControl->append(OUString::number(reinterpret_cast<sal_Int64>(m_aGroupInfo.back().get())), CuiResId(RID_SVXSTR_GROUP_STYLES));
}
catch(const css::uno::RuntimeException&)
{ throw; }
@@ -200,13 +200,13 @@ void CommandCategoryListBox::Init(
{}
// Reveal the updated UI to user
- SetUpdateMode(true);
- SelectEntryPos(0);
+ m_xControl->thaw();
+ m_xControl->set_active(0);
}
void CommandCategoryListBox::FillFunctionsList(
const css::uno::Sequence<css::frame::DispatchInformation>& xCommands,
- const VclPtr<SfxConfigFunctionListBox>& pFunctionListBox,
+ CuiConfigFunctionListBox* pFunctionListBox,
const OUString& filterTerm,
SaveInData *pCurrentSaveInData )
{
@@ -233,17 +233,15 @@ void CommandCategoryListBox::FillFunctionsList(
continue;
}
- Image aImage;
+ css::uno::Reference<css::graphic::XGraphic> xImage;
if (pCurrentSaveInData)
- aImage = pCurrentSaveInData->GetImage(rInfo.Command);
-
- SvTreeListEntry* pFuncEntry = pFunctionListBox->InsertEntry(sUIName, aImage, aImage );
+ xImage = pCurrentSaveInData->GetImage(rInfo.Command);
m_aGroupInfo.push_back( std::make_unique<SfxGroupInfo_Impl>( SfxCfgKind::FUNCTION_SLOT, 0 ) );
SfxGroupInfo_Impl* pGrpInfo = m_aGroupInfo.back().get();
pGrpInfo->sCommand = rInfo.Command;
pGrpInfo->sLabel = sUIName;
- pFuncEntry->SetUserData(pGrpInfo);
+ pFunctionListBox->append(OUString::number(reinterpret_cast<sal_Int64>(m_aGroupInfo.back().get())), sUIName, xImage);
}
}
@@ -274,11 +272,11 @@ OUString CommandCategoryListBox::getCommandName(const OUString& sCommand)
return sUIName;
}
-void CommandCategoryListBox::categorySelected( const VclPtr<SfxConfigFunctionListBox>& pFunctionListBox,
- const OUString& filterTerm , SaveInData *pCurrentSaveInData)
+void CommandCategoryListBox::categorySelected(CuiConfigFunctionListBox* pFunctionListBox,
+ const OUString& filterTerm , SaveInData *pCurrentSaveInData)
{
- SfxGroupInfo_Impl *pInfo = static_cast<SfxGroupInfo_Impl*>(GetSelectedEntryData());
- pFunctionListBox->SetUpdateMode(false);
+ SfxGroupInfo_Impl *pInfo = reinterpret_cast<SfxGroupInfo_Impl*>(m_xControl->get_active_id().toInt64());
+ pFunctionListBox->freeze();
pFunctionListBox->ClearAll();
switch ( pInfo->nKind )
@@ -287,12 +285,12 @@ void CommandCategoryListBox::categorySelected( const VclPtr<SfxConfigFunctionLi
{
css::uno::Reference< css::frame::XDispatchInformationProvider >
xProvider( m_xFrame, css::uno::UNO_QUERY );
- sal_Int32 nEntryCount = GetEntryCount();
+ sal_Int32 nEntryCount = m_xControl->get_count();
for (sal_Int32 nCurPos = 0; nCurPos < nEntryCount; ++nCurPos)
{
SfxGroupInfo_Impl *pCurrentInfo =
- static_cast<SfxGroupInfo_Impl*>(GetEntryData(nCurPos));
+ reinterpret_cast<SfxGroupInfo_Impl*>(m_xControl->get_id(nCurPos).toInt64());
if (pCurrentInfo->nKind == SfxCfgKind::GROUP_FUNCTION)
{
@@ -375,25 +373,22 @@ void CommandCategoryListBox::categorySelected( const VclPtr<SfxConfigFunctionLi
continue;
}
- SvTreeListEntry* pMacroGroup = pFunctionListBox->InsertEntry( sUIName );
m_aGroupInfo.push_back(
std::make_unique<SfxGroupInfo_Impl>(
SfxCfgKind::GROUP_SCRIPTCONTAINER, 0 ) );
- SfxGroupInfo_Impl* pGrpInfo = m_aGroupInfo.back().get();
- pMacroGroup->SetUserData(pGrpInfo);
- pMacroGroup->EnableChildrenOnDemand();
+ std::unique_ptr<weld::TreeIter> xMacroGroup(pFunctionListBox->append_ondemand(OUString::number(reinterpret_cast<sal_Int64>(m_aGroupInfo.back().get())), sUIName));
//Add the children and the grand children
- addChildren( pMacroGroup, childGroup, pFunctionListBox, filterTerm, pCurrentSaveInData );
+ addChildren(xMacroGroup.get(), childGroup, pFunctionListBox, filterTerm, pCurrentSaveInData);
// Remove the main group if empty
- if (!pMacroGroup->HasChildren())
+ if (!pFunctionListBox->iter_has_child(*xMacroGroup))
{
- pFunctionListBox->RemoveEntry( pMacroGroup );
+ pFunctionListBox->remove(*xMacroGroup);
}
else if (!filterTerm.isEmpty())
{
- pFunctionListBox->Expand( pMacroGroup );
+ pFunctionListBox->expand_row(*xMacroGroup);
}
}
}
@@ -412,12 +407,10 @@ void CommandCategoryListBox::categorySelected( const VclPtr<SfxConfigFunctionLi
continue;
}
- SvTreeListEntry* pFuncEntry = pFunctionListBox->InsertEntry( pIt.sLabel ); // Name of the style family
m_aGroupInfo.push_back( std::make_unique<SfxGroupInfo_Impl>( SfxCfgKind::GROUP_STYLES, 0 ) );
- SfxGroupInfo_Impl* pGrpInfo = m_aGroupInfo.back().get();
- pFuncEntry->SetUserData(pGrpInfo);
- pFuncEntry->EnableChildrenOnDemand();
+ // pIt.sLabel is Name of the style family
+ std::unique_ptr<weld::TreeIter> xFuncEntry(pFunctionListBox->append_ondemand(OUString::number(reinterpret_cast<sal_Int64>(m_aGroupInfo.back().get())), pIt.sLabel));
const std::vector< SfxStyleInfo_Impl > lStyles = pStylesInfo->getStyles(pIt.sFamily);
@@ -441,26 +434,24 @@ void CommandCategoryListBox::categorySelected( const VclPtr<SfxConfigFunctionLi
SfxStyleInfo_Impl* pStyle = new SfxStyleInfo_Impl(pStyleIt);
- SvTreeListEntry* pSubFuncEntry = pFunctionListBox->InsertEntry(
- sUIName, pFuncEntry );
-
m_aGroupInfo.push_back(
std::make_unique<SfxGroupInfo_Impl>(
SfxCfgKind::GROUP_STYLES, 0, pStyle ) );
m_aGroupInfo.back()->sCommand = pStyle->sCommand;
m_aGroupInfo.back()->sLabel = pStyle->sLabel;
- pSubFuncEntry->SetUserData( m_aGroupInfo.back().get() );
+
+ pFunctionListBox->append(OUString::number(reinterpret_cast<sal_Int64>(m_aGroupInfo.back().get())), sUIName, xFuncEntry.get());
}
// Remove the style group from the list if no children
- if (!pFuncEntry->HasChildren())
+ if (!pFunctionListBox->iter_has_child(*xFuncEntry))
{
- pFunctionListBox->RemoveEntry(pFuncEntry);
+ pFunctionListBox->remove(*xFuncEntry);
}
else if (!filterTerm.isEmpty())
{
- pFunctionListBox->Expand(pFuncEntry);
+ pFunctionListBox->expand_row(*xFuncEntry);
}
}
@@ -472,10 +463,10 @@ void CommandCategoryListBox::categorySelected( const VclPtr<SfxConfigFunctionLi
break;
}
- if ( pFunctionListBox->GetEntryCount() )
- pFunctionListBox->Select( pFunctionListBox->GetEntry( nullptr, 0 ) );
+ pFunctionListBox->thaw();
- pFunctionListBox->SetUpdateMode(true);
+ if (pFunctionListBox->n_children())
+ pFunctionListBox->select(0);
}
void CommandCategoryListBox::SetStylesInfo(SfxStylesInfo_Impl* pStyles)
@@ -484,8 +475,8 @@ void CommandCategoryListBox::SetStylesInfo(SfxStylesInfo_Impl* pStyles)
}
void CommandCategoryListBox::addChildren(
- SvTreeListEntry* parentEntry, const css::uno::Reference< css::script::browse::XBrowseNode > &parentNode,
- const VclPtr<SfxConfigFunctionListBox>& pFunctionListBox, const OUString& filterTerm , SaveInData *pCurrentSaveInData)
+ weld::TreeIter* parentEntry, const css::uno::Reference< css::script::browse::XBrowseNode > &parentNode,
+ CuiConfigFunctionListBox* pFunctionListBox, const OUString& filterTerm , SaveInData *pCurrentSaveInData)
{
// Setup search filter parameters
m_searchOptions.searchString = filterTerm;
@@ -500,21 +491,17 @@ void CommandCategoryListBox::addChildren(
{
OUString sUIName = child.get()->getName();
- SvTreeListEntry* pNewEntry = pFunctionListBox->InsertEntry( sUIName, parentEntry );
-
m_aGroupInfo.push_back( std::make_unique<SfxGroupInfo_Impl>(SfxCfgKind::GROUP_SCRIPTCONTAINER,
0, static_cast<void *>( child.get())));
- pNewEntry->SetUserData( m_aGroupInfo.back().get() );
- pNewEntry->EnableChildrenOnDemand();
+ std::unique_ptr<weld::TreeIter> xNewEntry(pFunctionListBox->append_ondemand(OUString::number(reinterpret_cast<sal_Int64>(m_aGroupInfo.back().get())), sUIName, parentEntry));
- addChildren(pNewEntry, child, pFunctionListBox, filterTerm, pCurrentSaveInData);
+ addChildren(xNewEntry.get(), child, pFunctionListBox, filterTerm, pCurrentSaveInData);
// Remove the group if empty
- if (!pNewEntry->HasChildren())
- pFunctionListBox->RemoveEntry( pNewEntry );
+ if (!pFunctionListBox->iter_has_child(*xNewEntry))
+ pFunctionListBox->remove(*xNewEntry);
else
- pFunctionListBox->Expand( pNewEntry );
-
+ pFunctionListBox->expand_row(*xNewEntry);
}
else if ( child.get()->getType() == css::script::browse::BrowseNodeTypes::SCRIPT )
{
@@ -558,17 +545,15 @@ void CommandCategoryListBox::addChildren(
OUString* pScriptURI = new OUString( uri );
- Image aImage;
+ css::uno::Reference<css::graphic::XGraphic> xImage;
if (pCurrentSaveInData)
- aImage = pCurrentSaveInData->GetImage(uri);
-
- SvTreeListEntry* pNewEntry = pFunctionListBox->InsertEntry( sUIName, aImage, aImage, parentEntry );
+ xImage = pCurrentSaveInData->GetImage(uri);
m_aGroupInfo.push_back( std::make_unique<SfxGroupInfo_Impl>( SfxCfgKind::FUNCTION_SCRIPT, 0, pScriptURI ));
m_aGroupInfo.back()->sCommand = uri;
m_aGroupInfo.back()->sLabel = sUIName;
m_aGroupInfo.back()->sHelpText = description;
- pNewEntry->SetUserData( m_aGroupInfo.back().get() );
+ pFunctionListBox->append(OUString::number(reinterpret_cast<sal_Int64>(m_aGroupInfo.back().get())), sUIName, xImage, parentEntry);
}
}
}
diff --git a/cui/source/customize/SvxMenuConfigPage.cxx b/cui/source/customize/SvxMenuConfigPage.cxx
index 06836f52d6ea..8e8adf5ed598 100644
--- a/cui/source/customize/SvxMenuConfigPage.cxx
+++ b/cui/source/customize/SvxMenuConfigPage.cxx
@@ -96,68 +96,90 @@
#include <dlgname.hxx>
-SvxMenuConfigPage::SvxMenuConfigPage(vcl::Window *pParent, const SfxItemSet& rSet, bool bIsMenuBar)
+SvxMenuConfigPage::SvxMenuConfigPage(TabPageParent pParent, const SfxItemSet& rSet, bool bIsMenuBar)
: SvxConfigPage(pParent, rSet)
- , m_bIsMenuBar( bIsMenuBar )
+ , m_bIsMenuBar(bIsMenuBar)
{
- m_pContentsListBox = VclPtr<SvxMenuEntriesListBox>::Create(m_pEntries, this);
- m_pContentsListBox->set_grid_left_attach(0);
- m_pContentsListBox->set_grid_top_attach(0);
- m_pContentsListBox->set_hexpand(true);
- m_pContentsListBox->set_vexpand(true);
- m_pContentsListBox->Show();
-
- m_pTopLevelListBox->SetSelectHdl(
- LINK( this, SvxMenuConfigPage, SelectMenu ) );
-
- m_pContentsListBox->SetSelectHdl(
+ m_xContentsListBox.reset(new SvxMenuEntriesListBox(m_xBuilder->weld_tree_view("menucontents"), this));
+ weld::TreeView& rTreeView = m_xContentsListBox->get_widget();
+ rTreeView.connect_size_allocate(LINK(this, SvxMenuConfigPage, MenuEntriesSizeAllocHdl));
+ Size aSize(m_xFunctions->get_size_request());
+ rTreeView.set_size_request(aSize.Width(), aSize.Height());
+ MenuEntriesSizeAllocHdl(aSize);
+ rTreeView.set_grid_left_attach(0);
+ rTreeView.set_grid_top_attach(0);
+ rTreeView.set_hexpand(true);
+ rTreeView.set_vexpand(true);
+ rTreeView.show();
+
+ rTreeView.connect_changed(
LINK( this, SvxMenuConfigPage, SelectMenuEntry ) );
- m_pGearBtn->SetSelectHdl(
- LINK( this, SvxMenuConfigPage, GearHdl ) );
+ rTreeView.connect_model_changed(LINK(this, SvxMenuConfigPage, ListModifiedHdl));
+
+ m_xGearBtn->connect_selected(LINK(this, SvxMenuConfigPage, GearHdl));
- m_pCommandCategoryListBox->SetSelectHdl(
- LINK( this, SvxMenuConfigPage, SelectCategory ) );
+ m_xCommandCategoryListBox->connect_changed(LINK(this, SvxMenuConfigPage, SelectCategory));
- m_pMoveUpButton->SetClickHdl ( LINK( this, SvxConfigPage, MoveHdl) );
- m_pMoveDownButton->SetClickHdl ( LINK( this, SvxConfigPage, MoveHdl) );
+ m_xMoveUpButton->connect_clicked( LINK( this, SvxConfigPage, MoveHdl) );
+ m_xMoveDownButton->connect_clicked( LINK( this, SvxConfigPage, MoveHdl) );
- m_pAddCommandButton->SetClickHdl( LINK( this, SvxMenuConfigPage, AddCommandHdl ) );
- m_pRemoveCommandButton->SetClickHdl( LINK( this, SvxMenuConfigPage, RemoveCommandHdl ) );
+ m_xAddCommandButton->connect_clicked( LINK( this, SvxMenuConfigPage, AddCommandHdl ) );
+ m_xRemoveCommandButton->connect_clicked( LINK( this, SvxMenuConfigPage, RemoveCommandHdl ) );
- m_pInsertBtn->SetSelectHdl(
+ m_xInsertBtn->connect_selected(
LINK( this, SvxMenuConfigPage, InsertHdl ) );
- m_pModifyBtn->SetSelectHdl(
+ m_xModifyBtn->connect_selected(
LINK( this, SvxMenuConfigPage, ModifyItemHdl ) );
- m_pResetBtn->SetClickHdl(
+ m_xResetBtn->connect_clicked(
LINK( this, SvxMenuConfigPage, ResetMenuHdl ) );
- PopupMenu* pPopup = m_pModifyBtn->GetPopupMenu();
// These operations are not possible on menus/context menus yet
- pPopup->EnableItem( pPopup->GetItemId("changeIcon"), false );
- pPopup->EnableItem( pPopup->GetItemId("resetIcon"), false );
- pPopup->EnableItem( pPopup->GetItemId("restoreItem"), false );
- pPopup->RemoveDisabledEntries();
+ m_xModifyBtn->remove_item("changeIcon");
+ m_xModifyBtn->remove_item("resetIcon");
+ m_xModifyBtn->remove_item("restoreItem");
- PopupMenu* pGearMenu = m_pGearBtn->GetPopupMenu();
- pGearMenu->EnableItem( pGearMenu->GetItemId("gear_iconAndText"), false );
- pGearMenu->EnableItem( pGearMenu->GetItemId("gear_iconOnly"), false );
- pGearMenu->EnableItem( pGearMenu->GetItemId("gear_textOnly"), false );
- pGearMenu->RemoveDisabledEntries();
+ m_xGearBtn->remove_item("gear_iconAndText");
+ m_xGearBtn->remove_item("gear_iconOnly");
+ m_xGearBtn->remove_item("gear_textOnly");
if ( !bIsMenuBar )
{
//TODO: Remove this when the gear button is implemented for context menus
- m_pGearBtn->Disable();
- m_pGearBtn->Hide();
+ m_xGearBtn->set_sensitive(false);
+ m_xGearBtn->hide();
}
else
{
// TODO: Remove this when it is possible to reset menubar menus individually
- m_pResetBtn->Disable();
+ m_xResetBtn->set_sensitive(false);
}
}
+IMPL_LINK_NOARG(SvxMenuConfigPage, ListModifiedHdl, weld::TreeView&, void)
+{
+ // regenerate with the current ordering within the list
+ SvxEntries* pEntries = GetTopLevelSelection()->GetEntries();
+ pEntries->clear();
+
+ for (int i = 0; i < m_xContentsListBox->n_children(); ++i)
+ pEntries->push_back(reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(i).toInt64()));
+
+ GetSaveInData()->SetModified();
+ GetTopLevelSelection()->SetModified();
+ UpdateButtonStates();
+}
+
+IMPL_LINK(SvxMenuConfigPage, MenuEntriesSizeAllocHdl, const Size&, rSize, void)
+{
+ weld::TreeView& rTreeView = m_xContentsListBox->get_widget();
+ std::vector<int> aWidths;
+ int nImageColWidth = rTreeView.get_checkbox_column_width();
+ aWidths.push_back(nImageColWidth);
+ aWidths.push_back(rSize.Width() - 2 * nImageColWidth);
+ rTreeView.set_column_fixed_widths(aWidths);
+}
+
SvxMenuConfigPage::~SvxMenuConfigPage()
{
disposeOnce();
@@ -167,33 +189,31 @@ SvxMenuConfigPage::~SvxMenuConfigPage()
void SvxMenuConfigPage::Init()
{
// ensure that the UI is cleared before populating it
- m_pTopLevelListBox->Clear();
- m_pContentsListBox->Clear();
+ m_xTopLevelListBox->clear();
+ m_xContentsListBox->clear();
ReloadTopLevelListBox();
- m_pTopLevelListBox->SelectEntryPos(0);
- m_pTopLevelListBox->GetSelectHdl().Call(*m_pTopLevelListBox);
+ m_xTopLevelListBox->set_active(0);
+ SelectElement();
- m_pCommandCategoryListBox->Init(
+ m_xCommandCategoryListBox->Init(
comphelper::getProcessComponentContext(),
m_xFrame,
vcl::CommandInfoProvider::GetModuleIdentifier(m_xFrame));
- m_pCommandCategoryListBox->categorySelected( m_pFunctions, OUString(), GetSaveInData() );
+ m_xCommandCategoryListBox->categorySelected(m_xFunctions.get(), OUString(), GetSaveInData());
}
void SvxMenuConfigPage::dispose()
{
- for ( sal_Int32 i = 0 ; i < m_pSaveInListBox->GetEntryCount(); ++i )
- {
- delete static_cast<SaveInData*>(m_pSaveInListBox->GetEntryData( i ));
- }
- m_pSaveInListBox->Clear();
+ for (int i = 0, nCount = m_xSaveInListBox->get_count(); i < nCount; ++i)
+ delete reinterpret_cast<SaveInData*>(m_xSaveInListBox->get_id(i).toInt64());
+ m_xSaveInListBox->clear();
SvxConfigPage::dispose();
}
-IMPL_LINK_NOARG( SvxMenuConfigPage, SelectMenuEntry, SvTreeListBox *, void )
+IMPL_LINK_NOARG(SvxMenuConfigPage, SelectMenuEntry, weld::TreeView&, void)
{
UpdateButtonStates();
}
@@ -201,31 +221,30 @@ IMPL_LINK_NOARG( SvxMenuConfigPage, SelectMenuEntry, SvTreeListBox *, void )
void SvxMenuConfigPage::UpdateButtonStates()
{
// Disable Up and Down buttons depending on current selection
- SvTreeListEntry* selection = m_pContentsListBox->GetCurEntry();
+ int selection = m_xContentsListBox->get_selected_index();
bool bIsSeparator =
- selection && static_cast<SvxConfigEntry*>(selection->GetUserData())->IsSeparator();
+ selection != -1 && reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(selection).toInt64())->IsSeparator();
bool bIsValidSelection =
- !(m_pContentsListBox->GetEntryCount() == 0 || selection == nullptr);
+ !(m_xContentsListBox->n_children() == 0 || selection == -1);
- m_pMoveUpButton->Enable(
- bIsValidSelection && selection != m_pContentsListBox->First() );
- m_pMoveDownButton->Enable(
- bIsValidSelection && selection != m_pContentsListBox->Last() );
+ m_xMoveUpButton->set_sensitive(
+ bIsValidSelection && selection != 0 );
+ m_xMoveDownButton->set_sensitive(
+ bIsValidSelection && selection != m_xContentsListBox->n_children() - 1);
- m_pRemoveCommandButton->Enable( bIsValidSelection );
+ m_xRemoveCommandButton->set_sensitive( bIsValidSelection );
- m_pModifyBtn->Enable( bIsValidSelection && !bIsSeparator);
+ m_xModifyBtn->set_sensitive( bIsValidSelection && !bIsSeparator);
//Handle the gear button
if (m_bIsMenuBar)
{
SvxConfigEntry* pMenuData = GetTopLevelSelection();
- PopupMenu* pGearPopup = m_pGearBtn->GetPopupMenu();
// Add option (gear_add) will always be enabled
- pGearPopup->EnableItem( "gear_delete", pMenuData->IsDeletable() );
- pGearPopup->EnableItem( "gear_rename", pMenuData->IsRenamable() );
- pGearPopup->EnableItem( "gear_move", pMenuData->IsMovable() );
+ m_xGearBtn->set_item_sensitive( "gear_delete", pMenuData->IsDeletable() );
+ m_xGearBtn->set_item_sensitive( "gear_rename", pMenuData->IsRenamable() );
+ m_xGearBtn->set_item_sensitive( "gear_move", pMenuData->IsMovable() );
}
}
@@ -246,13 +265,13 @@ void SvxMenuConfigPage::DeleteSelectedTopLevel()
void SvxMenuConfigPage::DeleteSelectedContent()
{
- SvTreeListEntry *pActEntry = m_pContentsListBox->FirstSelected();
+ int nActEntry = m_xContentsListBox->get_selected_index();
- if ( pActEntry != nullptr )
+ if (nActEntry != -1)
{
// get currently selected menu entry
SvxConfigEntry* pMenuEntry =
- static_cast<SvxConfigEntry*>(pActEntry->GetUserData());
+ reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry).toInt64());
// get currently selected menu
SvxConfigEntry* pMenu = GetTopLevelSelection();
@@ -261,7 +280,7 @@ void SvxMenuConfigPage::DeleteSelectedContent()
SvxConfigPageHelper::RemoveEntry( pMenu->GetEntries(), pMenuEntry );
// remove menu entry from UI
- m_pContentsListBox->GetModel()->Remove( pActEntry );
+ m_xContentsListBox->remove(nActEntry);
// if this is a submenu entry, redraw the menus list box
if ( pMenuEntry->IsPopup() )
@@ -281,20 +300,19 @@ short SvxMenuConfigPage::QueryReset()
{
OUString msg = CuiResId( RID_SVXSTR_CONFIRM_MENU_RESET );
- OUString saveInName = m_pSaveInListBox->GetEntry(
- m_pSaveInListBox->GetSelectedEntryPos() );
+ OUString saveInName = m_xSaveInListBox->get_active_text();
OUString label = SvxConfigPageHelper::replaceSaveInName( msg, saveInName );
- std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetFrameWeld(),
+ std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetDialogFrameWeld(),
VclMessageType::Question, VclButtonsType::YesNo,
label));
return xQueryBox->run();
}
-IMPL_LINK_NOARG( SvxMenuConfigPage, SelectMenu, ListBox&, void )
+void SvxMenuConfigPage::SelectElement()
{
- m_pContentsListBox->Clear();
+ m_xContentsListBox->clear();
SvxConfigEntry* pMenuData = GetTopLevelSelection();
@@ -302,22 +320,24 @@ IMPL_LINK_NOARG( SvxMenuConfigPage, SelectMenu, ListBox&, void )
{
SvxEntries* pEntries = pMenuData->GetEntries();
+ int i = 0;
for (auto const& entry : *pEntries)
{
- InsertEntryIntoUI(entry);
+ OUString sId(OUString::number(reinterpret_cast<sal_Int64>(entry)));
+ m_xContentsListBox->insert(i, sId);
+ InsertEntryIntoUI(entry, i, 0);
+ ++i;
}
}
UpdateButtonStates();
}
-IMPL_LINK( SvxMenuConfigPage, GearHdl, MenuButton *, pButton, void )
+IMPL_LINK(SvxMenuConfigPage, GearHdl, const OString&, rIdent, void)
{
- OString sIdent = pButton->GetCurItemIdent();
-
- if (sIdent == "gear_add")
+ if (rIdent == "gear_add")
{
- SvxMainMenuOrganizerDialog aDialog(GetFrameWeld(),
+ SvxMainMenuOrganizerDialog aDialog(GetDialogFrameWeld(),
GetSaveInData()->GetEntries(), nullptr, true );
if (aDialog.run() == RET_OK)
@@ -327,20 +347,20 @@ IMPL_LINK( SvxMenuConfigPage, GearHdl, MenuButton *, pButton, void )
GetSaveInData()->SetModified();
}
}
- else if (sIdent == "gear_delete")
+ else if (rIdent == "gear_delete")
{
DeleteSelectedTopLevel();
}
- else if (sIdent == "gear_rename")
+ else if (rIdent == "gear_rename")
{
SvxConfigEntry* pMenuData = GetTopLevelSelection();
OUString sCurrentName( SvxConfigPageHelper::stripHotKey( pMenuData->GetName() ) );
OUString sDesc = CuiResId( RID_SVXSTR_LABEL_NEW_NAME );
- SvxNameDialog aNameDialog( GetFrameWeld(), sCurrentName, sDesc );
- aNameDialog.set_help_id( HID_SVX_CONFIG_RENAME_MENU );
- aNameDialog.set_title( CuiResId( RID_SVXSTR_RENAME_MENU ) );
+ SvxNameDialog aNameDialog(GetDialogFrameWeld(), sCurrentName, sDesc);
+ aNameDialog.set_help_id(HID_SVX_CONFIG_RENAME_MENU);
+ aNameDialog.set_title(CuiResId(RID_SVXSTR_RENAME_MENU));
if ( aNameDialog.run() == RET_OK )
{
@@ -356,11 +376,11 @@ IMPL_LINK( SvxMenuConfigPage, GearHdl, MenuButton *, pButton, void )
GetSaveInData()->SetModified();
}
}
- else if (sIdent == "gear_move")
+ else if (rIdent == "gear_move")
{
SvxConfigEntry* pMenuData = GetTopLevelSelection();
- SvxMainMenuOrganizerDialog aDialog(GetFrameWeld(), GetSaveInData()->GetEntries(),
+ SvxMainMenuOrganizerDialog aDialog(GetDialogFrameWeld(), GetSaveInData()->GetEntries(),
pMenuData, false );
if (aDialog.run() == RET_OK)
{
@@ -374,26 +394,31 @@ IMPL_LINK( SvxMenuConfigPage, GearHdl, MenuButton *, pButton, void )
else
{
//This block should never be reached
- SAL_WARN("cui.customize", "Unknown gear menu option: " << sIdent);
+ SAL_WARN("cui.customize", "Unknown gear menu option: " << rIdent);
return;
}
UpdateButtonStates();
}
-IMPL_LINK_NOARG( SvxMenuConfigPage, SelectCategory, ListBox&, void )
+IMPL_LINK_NOARG(SvxMenuConfigPage, SelectCategory, weld::ComboBox&, void)
{
- OUString aSearchTerm( m_pSearchEdit->GetText() );
+ OUString aSearchTerm( m_xSearchEdit->get_text() );
- m_pCommandCategoryListBox->categorySelected( m_pFunctions, aSearchTerm, GetSaveInData() );
+ m_xCommandCategoryListBox->categorySelected(m_xFunctions.get(), aSearchTerm, GetSaveInData());
}
-IMPL_LINK_NOARG( SvxMenuConfigPage, AddCommandHdl, Button *, void )
+IMPL_LINK_NOARG( SvxMenuConfigPage, AddCommandHdl, weld::Button&, void )
{
- AddFunction();
+ int nPos = AddFunction();
+ if (nPos == -1)
+ return;
+ SvxConfigEntry* pEntry =
+ reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nPos).toInt64());
+ InsertEntryIntoUI(pEntry, nPos, 0);
}
-IMPL_LINK_NOARG( SvxMenuConfigPage, RemoveCommandHdl, Button *, void )
+IMPL_LINK_NOARG( SvxMenuConfigPage, RemoveCommandHdl, weld::Button&, void )
{
DeleteSelectedContent();
if ( GetSaveInData()->IsModified() )
@@ -402,22 +427,21 @@ IMPL_LINK_NOARG( SvxMenuConfigPage, RemoveCommandHdl, Button *, void )
}
}
-IMPL_LINK( SvxMenuConfigPage, InsertHdl, MenuButton *, pButton, void )
+IMPL_LINK(SvxMenuConfigPage, InsertHdl, const OString&, rIdent, void)
{
- OString sIdent = pButton->GetCurItemIdent();
-
- if (sIdent == "insertseparator")
+ if (rIdent == "insertseparator")
{
SvxConfigEntry* pNewEntryData = new SvxConfigEntry;
pNewEntryData->SetUserDefined();
- InsertEntry( pNewEntryData );
+ int nPos = InsertEntry(pNewEntryData, -1);
+ InsertEntryIntoUI(pNewEntryData, nPos, 0);
}
- else if (sIdent == "insertsubmenu")
+ else if (rIdent == "insertsubmenu")
{
OUString aNewName;
OUString aDesc = CuiResId( RID_SVXSTR_SUBMENU_NAME );
- SvxNameDialog aNameDialog(GetFrameWeld(), aNewName, aDesc);
+ SvxNameDialog aNameDialog(GetDialogFrameWeld(), aNewName, aDesc);
aNameDialog.set_help_id(HID_SVX_CONFIG_NAME_SUBMENU);
aNameDialog.set_title(CuiResId( RID_SVXSTR_ADD_SUBMENU));
@@ -430,10 +454,14 @@ IMPL_LINK( SvxMenuConfigPage, InsertHdl, MenuButton *, pButton, void )
pNewEntryData->SetName( aNewName );
pNewEntryData->SetUserDefined();
- InsertEntry( pNewEntryData );
+ int nPos = InsertEntry(pNewEntryData, -1);
+ InsertEntryIntoUI(pNewEntryData, nPos, 0);
ReloadTopLevelListBox();
+ m_xContentsListBox->scroll_to_row(nPos);
+ m_xContentsListBox->select(nPos);
+
GetSaveInData()->SetModified();
}
@@ -441,7 +469,7 @@ IMPL_LINK( SvxMenuConfigPage, InsertHdl, MenuButton *, pButton, void )
else
{
//This block should never be reached
- SAL_WARN("cui.customize", "Unknown insert option: " << sIdent);
+ SAL_WARN("cui.customize", "Unknown insert option: " << rIdent);
return;
}
@@ -451,22 +479,18 @@ IMPL_LINK( SvxMenuConfigPage, InsertHdl, MenuButton *, pButton, void )
}
}
-IMPL_LINK( SvxMenuConfigPage, ModifyItemHdl, MenuButton *, pButton, void )
+IMPL_LINK(SvxMenuConfigPage, ModifyItemHdl, const OString&, rIdent, void)
{
- OString sIdent = pButton->GetCurItemIdent();
-
- SAL_WARN("cui.customize", "sIdent: " << sIdent);
-
- if (sIdent == "renameItem")
+ if (rIdent == "renameItem")
{
- SvTreeListEntry* pActEntry = m_pContentsListBox->GetCurEntry();
+ int nActEntry = m_xContentsListBox->get_selected_index();
SvxConfigEntry* pEntry =
- static_cast<SvxConfigEntry*>(pActEntry->GetUserData());
+ reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry).toInt64());
OUString aNewName( SvxConfigPageHelper::stripHotKey( pEntry->GetName() ) );
OUString aDesc = CuiResId( RID_SVXSTR_LABEL_NEW_NAME );
- SvxNameDialog aNameDialog(GetFrameWeld(), aNewName, aDesc);
+ SvxNameDialog aNameDialog(GetDialogFrameWeld(), aNewName, aDesc);
aNameDialog.set_help_id(HID_SVX_CONFIG_RENAME_MENU_ITEM);
aNameDialog.set_title(CuiResId(RID_SVXSTR_RENAME_MENU));
@@ -475,7 +499,7 @@ IMPL_LINK( SvxMenuConfigPage, ModifyItemHdl, MenuButton *, pButton, void )
aNewName = aNameDialog.GetName();
pEntry->SetName( aNewName );
- m_pContentsListBox->SetEntryText( pActEntry, aNewName );
+ m_xContentsListBox->set_text(nActEntry, aNewName, 1);
GetSaveInData()->SetModified();
GetTopLevelSelection()->SetModified();
@@ -484,7 +508,7 @@ IMPL_LINK( SvxMenuConfigPage, ModifyItemHdl, MenuButton *, pButton, void )
else
{
//This block should never be reached
- SAL_WARN("cui.customize", "Unknown insert option: " << sIdent);
+ SAL_WARN("cui.customize", "Unknown insert option: " << rIdent);
return;
}
@@ -494,7 +518,7 @@ IMPL_LINK( SvxMenuConfigPage, ModifyItemHdl, MenuButton *, pButton, void )
}
}
-IMPL_LINK_NOARG( SvxMenuConfigPage, ResetMenuHdl, Button *, void )
+IMPL_LINK_NOARG(SvxMenuConfigPage, ResetMenuHdl, weld::Button&, void)
{
SvxConfigEntry* pMenuData = GetTopLevelSelection();
@@ -504,7 +528,7 @@ IMPL_LINK_NOARG( SvxMenuConfigPage, ResetMenuHdl, Button *, void )
return;
}
- std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetFrameWeld(),
+ std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetDialogFrameWeld(),
VclMessageType::Question, VclButtonsType::YesNo,
CuiResId(RID_SVXSTR_CONFIRM_RESTORE_DEFAULT_MENU)));
@@ -512,20 +536,20 @@ IMPL_LINK_NOARG( SvxMenuConfigPage, ResetMenuHdl, Button *, void )
// So we are resetting only if it is a context menu
if (!m_bIsMenuBar && xQueryBox->run() == RET_YES)
{
- sal_Int32 nPos = m_pTopLevelListBox->GetSelectedEntryPos();
+ sal_Int32 nPos = m_xTopLevelListBox->get_active();
ContextMenuSaveInData* pSaveInData = static_cast< ContextMenuSaveInData* >(GetSaveInData());
pSaveInData->ResetContextMenu(pMenuData);
// ensure that the UI is cleared before populating it
- m_pTopLevelListBox->Clear();
- m_pContentsListBox->Clear();
+ m_xTopLevelListBox->clear();
+ m_xContentsListBox->clear();
ReloadTopLevelListBox();
// Reselect the resetted menu
- m_pTopLevelListBox->SelectEntryPos(nPos);
- m_pTopLevelListBox->GetSelectHdl().Call(*m_pTopLevelListBox);
+ m_xTopLevelListBox->set_active(nPos);
+ SelectElement();
}
}
diff --git a/cui/source/customize/SvxToolbarConfigPage.cxx b/cui/source/customize/SvxToolbarConfigPage.cxx
index 56c9c85c6734..252efe5bb7ba 100644
--- a/cui/source/customize/SvxToolbarConfigPage.cxx
+++ b/cui/source/customize/SvxToolbarConfigPage.cxx
@@ -96,60 +96,65 @@
#include <dlgname.hxx>
-SvxToolbarConfigPage::SvxToolbarConfigPage(vcl::Window *pParent, const SfxItemSet& rSet)
+SvxToolbarConfigPage::SvxToolbarConfigPage(TabPageParent pParent, const SfxItemSet& rSet)
: SvxConfigPage(pParent, rSet)
{
- SetHelpId( HID_SVX_CONFIG_TOOLBAR );
-
- m_pContentsListBox = VclPtr<SvxToolbarEntriesListBox>::Create(m_pEntries, this);
- m_pContentsListBox->set_grid_left_attach(0);
- m_pContentsListBox->set_grid_top_attach(0);
- m_pContentsListBox->set_hexpand(true);
- m_pContentsListBox->set_vexpand(true);
- m_pContentsListBox->Show();
-
- m_pTopLevelListBox->SetHelpId ( HID_SVX_TOPLEVELLISTBOX );
- m_pContentsListBox->SetHelpId( HID_SVX_CONFIG_TOOLBAR_CONTENTS );
- m_pSaveInListBox->SetHelpId( HID_SVX_SAVE_IN );
- m_pMoveUpButton->SetHelpId( HID_SVX_UP_TOOLBAR_ITEM );
- m_pMoveDownButton->SetHelpId( HID_SVX_DOWN_TOOLBAR_ITEM );
- m_pDescriptionField->SetHelpId ( HID_SVX_DESCFIELD );
-
- m_pTopLevelListBox->SetSelectHdl(
- LINK( this, SvxToolbarConfigPage, SelectToolbar ) );
- m_pContentsListBox->SetSelectHdl(
+ m_xContainer->set_help_id(HID_SVX_CONFIG_TOOLBAR);
+
+ m_xContentsListBox.reset(new SvxToolbarEntriesListBox(m_xBuilder->weld_tree_view("toolcontents"), this));
+ std::vector<int> aWidths;
+ weld::TreeView& rTreeView = m_xContentsListBox->get_widget();
+ Size aSize(m_xFunctions->get_size_request());
+ rTreeView.set_size_request(aSize.Width(), aSize.Height());
+ aWidths.push_back(rTreeView.get_checkbox_column_width());
+ aWidths.push_back(rTreeView.get_checkbox_column_width());
+ rTreeView.set_column_fixed_widths(aWidths);
+ rTreeView.set_grid_left_attach(0);
+ rTreeView.set_grid_top_attach(0);
+ rTreeView.set_hexpand(true);
+ rTreeView.set_vexpand(true);
+ rTreeView.set_help_id( HID_SVX_CONFIG_TOOLBAR_CONTENTS );
+ rTreeView.show();
+
+ rTreeView.connect_changed(
LINK( this, SvxToolbarConfigPage, SelectToolbarEntry ) );
- m_pCommandCategoryListBox->SetSelectHdl(
+
+ rTreeView.connect_model_changed(LINK(this, SvxToolbarConfigPage, ListModifiedHdl));
+
+ m_xTopLevelListBox->set_help_id ( HID_SVX_TOPLEVELLISTBOX );
+ m_xSaveInListBox->set_help_id( HID_SVX_SAVE_IN );
+ m_xMoveUpButton->set_help_id( HID_SVX_UP_TOOLBAR_ITEM );
+ m_xMoveDownButton->set_help_id( HID_SVX_DOWN_TOOLBAR_ITEM );
+ m_xDescriptionField->set_help_id ( HID_SVX_DESCFIELD );
+
+ m_xCommandCategoryListBox->connect_changed(
LINK( this, SvxToolbarConfigPage, SelectCategory ) );
- m_pGearBtn->SetSelectHdl(
+ m_xGearBtn->connect_selected(
LINK( this, SvxToolbarConfigPage, GearHdl ) );
- m_pMoveUpButton->SetClickHdl ( LINK( this, SvxToolbarConfigPage, MoveHdl) );
- m_pMoveDownButton->SetClickHdl ( LINK( this, SvxToolbarConfigPage, MoveHdl) );
+ m_xMoveUpButton->connect_clicked( LINK( this, SvxToolbarConfigPage, MoveHdl) );
+ m_xMoveDownButton->connect_clicked( LINK( this, SvxToolbarConfigPage, MoveHdl) );
// Always enable Up and Down buttons
// added for issue i53677 by shizhoubo
- m_pMoveDownButton->Enable();
- m_pMoveUpButton->Enable();
+ m_xMoveDownButton->set_sensitive(true);
+ m_xMoveUpButton->set_sensitive(true);
- m_pAddCommandButton->SetClickHdl( LINK( this, SvxToolbarConfigPage, AddCommandHdl ) );
- m_pRemoveCommandButton->SetClickHdl( LINK( this, SvxToolbarConfigPage, RemoveCommandHdl ) );
+ m_xAddCommandButton->connect_clicked( LINK( this, SvxToolbarConfigPage, AddCommandHdl ) );
+ m_xRemoveCommandButton->connect_clicked( LINK( this, SvxToolbarConfigPage, RemoveCommandHdl ) );
- m_pInsertBtn->SetSelectHdl(
+ m_xInsertBtn->connect_selected(
LINK( this, SvxToolbarConfigPage, InsertHdl ) );
- m_pModifyBtn->SetSelectHdl(
+ m_xModifyBtn->connect_selected(
LINK( this, SvxToolbarConfigPage, ModifyItemHdl ) );
- m_pResetBtn->SetClickHdl(
+ m_xResetBtn->connect_clicked(
LINK( this, SvxToolbarConfigPage, ResetToolbarHdl ) );
// "Insert Submenu" is irrelevant to the toolbars
- PopupMenu* pPopup = m_pInsertBtn->GetPopupMenu();
- pPopup->EnableItem(OString( "insertsubmenu"), false );
- pPopup->RemoveDisabledEntries();
+ m_xInsertBtn->remove_item("insertsubmenu");
// Gear menu's "Move" action is irrelevant to the toolbars
- pPopup = m_pGearBtn->GetPopupMenu();
- pPopup->EnableItem("gear_move", false);
+ m_xGearBtn->set_item_sensitive("gear_move", false);
// default toolbar to select is standardbar unless a different one
// has been passed in
@@ -169,6 +174,23 @@ SvxToolbarConfigPage::SvxToolbarConfigPage(vcl::Window *pParent, const SfxItemSe
}
}
+IMPL_LINK_NOARG(SvxToolbarConfigPage, ListModifiedHdl, weld::TreeView&, void)
+{
+ // regenerate with the current ordering within the list
+ SvxEntries* pEntries = GetTopLevelSelection()->GetEntries();
+ pEntries->clear();
+
+ for (int i = 0; i < m_xContentsListBox->n_children(); ++i)
+ pEntries->push_back(reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(i).toInt64()));
+
+ GetSaveInData()->SetModified();
+ GetTopLevelSelection()->SetModified();
+
+ SvxConfigEntry* pToolbar = GetTopLevelSelection();
+ if ( pToolbar )
+ static_cast<ToolbarSaveInData*>(GetSaveInData())->ApplyToolbar( pToolbar );
+}
+
SvxToolbarConfigPage::~SvxToolbarConfigPage()
{
disposeOnce();
@@ -176,41 +198,41 @@ SvxToolbarConfigPage::~SvxToolbarConfigPage()
void SvxToolbarConfigPage::dispose()
{
- for ( sal_Int32 i = 0 ; i < m_pSaveInListBox->GetEntryCount(); ++i )
+ for (int i = 0, nCount = m_xSaveInListBox->get_count(); i < nCount; ++i)
{
ToolbarSaveInData* pData =
- static_cast<ToolbarSaveInData*>(m_pSaveInListBox->GetEntryData( i ));
-
+ reinterpret_cast<ToolbarSaveInData*>(m_xSaveInListBox->get_id(i).toInt64());
delete pData;
}
- m_pSaveInListBox->Clear();
+ m_xSaveInListBox->clear();
SvxConfigPage::dispose();
}
void SvxToolbarConfigPage::DeleteSelectedTopLevel()
{
- const sal_Int32 nSelectionPos = m_pTopLevelListBox->GetSelectedEntryPos();
+ const sal_Int32 nSelectionPos = m_xTopLevelListBox->get_active();
ToolbarSaveInData* pSaveInData = static_cast<ToolbarSaveInData*>( GetSaveInData() );
pSaveInData->RemoveToolbar( GetTopLevelSelection() );
- if ( m_pTopLevelListBox->GetEntryCount() > 1 )
+ int nCount = m_xTopLevelListBox->get_count();
+ if (nCount > 1)
{
// select next entry after the one being deleted
// selection position is indexed from 0 so need to
// subtract one from the entry count
- if ( nSelectionPos != m_pTopLevelListBox->GetEntryCount() - 1 )
+ if (nSelectionPos != nCount - 1)
{
- m_pTopLevelListBox->SelectEntryPos( nSelectionPos + 1 );
+ m_xTopLevelListBox->set_active(nSelectionPos + 1);
}
else
{
- m_pTopLevelListBox->SelectEntryPos( nSelectionPos - 1 );
+ m_xTopLevelListBox->set_active(nSelectionPos - 1);
}
- m_pTopLevelListBox->GetSelectHdl().Call( *m_pTopLevelListBox );
+ SelectElement();
// and now remove the entry
- m_pTopLevelListBox->RemoveEntry( nSelectionPos );
+ m_xTopLevelListBox->remove(nSelectionPos);
}
else
{
@@ -220,13 +242,13 @@ void SvxToolbarConfigPage::DeleteSelectedTopLevel()
void SvxToolbarConfigPage::DeleteSelectedContent()
{
- SvTreeListEntry *pActEntry = m_pContentsListBox->FirstSelected();
+ int nActEntry = m_xContentsListBox->get_selected_index();
- if ( pActEntry != nullptr )
+ if (nActEntry != -1)
{
// get currently selected entry
SvxConfigEntry* pEntry =
- static_cast<SvxConfigEntry*>(pActEntry->GetUserData());
+ reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry).toInt64());
SvxConfigEntry* pToolbar = GetTopLevelSelection();
@@ -234,7 +256,7 @@ void SvxToolbarConfigPage::DeleteSelectedContent()
SvxConfigPageHelper::RemoveEntry( pToolbar->GetEntries(), pEntry );
// remove toolbar entry from UI
- m_pContentsListBox->GetModel()->Remove( pActEntry );
+ m_xContentsListBox->remove(nActEntry);
// delete data for toolbar entry
delete pEntry;
@@ -245,10 +267,10 @@ void SvxToolbarConfigPage::DeleteSelectedContent()
// if this is the last entry in the toolbar and it is a user
// defined toolbar pop up a dialog asking the user if they
// want to delete the toolbar
- if ( m_pContentsListBox->GetEntryCount() == 0 &&
+ if ( m_xContentsListBox->n_children() == 0 &&
GetTopLevelSelection()->IsDeletable() )
{
- std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetFrameWeld(),
+ std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetDialogFrameWeld(),
VclMessageType::Question, VclButtonsType::YesNo,
CuiResId(RID_SXVSTR_CONFIRM_DELETE_TOOLBAR)));
if (xQueryBox->run() == RET_YES)
@@ -259,9 +281,9 @@ void SvxToolbarConfigPage::DeleteSelectedContent()
}
}
-IMPL_LINK( SvxToolbarConfigPage, MoveHdl, Button *, pButton, void )
+IMPL_LINK( SvxToolbarConfigPage, MoveHdl, weld::Button&, rButton, void )
{
- MoveEntry(pButton == m_pMoveUpButton);
+ MoveEntry(&rButton == m_xMoveUpButton.get());
}
void SvxToolbarConfigPage::MoveEntry( bool bMoveUp )
@@ -282,18 +304,18 @@ void SvxToolbarConfigPage::MoveEntry( bool bMoveUp )
void SvxToolbarConfigPage::Init()
{
// ensure that the UI is cleared before populating it
- m_pTopLevelListBox->Clear();
- m_pContentsListBox->Clear();
+ m_xTopLevelListBox->clear();
+ m_xContentsListBox->clear();
ReloadTopLevelListBox();
sal_Int32 nPos = 0;
if ( !m_aURLToSelect.isEmpty() )
{
- for ( sal_Int32 i = 0 ; i < m_pTopLevelListBox->GetEntryCount(); ++i )
+ for (sal_Int32 i = 0, nCount = m_xTopLevelListBox->get_count(); i < nCount; ++i)
{
SvxConfigEntry* pData =
- static_cast<SvxConfigEntry*>(m_pTopLevelListBox->GetEntryData( i ));
+ reinterpret_cast<SvxConfigEntry*>(m_xTopLevelListBox->get_id(i).toInt64());
if ( pData->GetCommand().equals( m_aURLToSelect ) )
{
@@ -307,14 +329,14 @@ void SvxToolbarConfigPage::Init()
m_aURLToSelect += "standardbar";
}
- m_pTopLevelListBox->SelectEntryPos(nPos);
- m_pTopLevelListBox->GetSelectHdl().Call(*m_pTopLevelListBox);
+ m_xTopLevelListBox->set_active(nPos);
+ SelectElement();
- m_pCommandCategoryListBox->Init(
+ m_xCommandCategoryListBox->Init(
comphelper::getProcessComponentContext(),
m_xFrame,
vcl::CommandInfoProvider::GetModuleIdentifier(m_xFrame));
- m_pCommandCategoryListBox->categorySelected( m_pFunctions, OUString(), GetSaveInData() );
+ m_xCommandCategoryListBox->categorySelected(m_xFunctions.get(), OUString(), GetSaveInData());
}
SaveInData* SvxToolbarConfigPage::CreateSaveInData(
@@ -327,17 +349,16 @@ SaveInData* SvxToolbarConfigPage::CreateSaveInData(
new ToolbarSaveInData( xCfgMgr, xParentCfgMgr, aModuleId, bDocConfig ));
}
-IMPL_LINK_NOARG( SvxToolbarConfigPage, SelectToolbarEntry, SvTreeListBox *, void )
+IMPL_LINK_NOARG(SvxToolbarConfigPage, SelectToolbarEntry, weld::TreeView&, void)
{
UpdateButtonStates();
}
-IMPL_LINK( SvxToolbarConfigPage, GearHdl, MenuButton *, pButton, void )
+IMPL_LINK( SvxToolbarConfigPage, GearHdl, const OString&, rIdent, void )
{
- OString sIdent = pButton->GetCurItemIdent();
SvxConfigEntry* pCurrentToolbar = GetTopLevelSelection();
- if (sIdent == "gear_add")
+ if (rIdent == "gear_add")
{
OUString prefix = CuiResId( RID_SVXSTR_NEW_TOOLBAR );
@@ -347,13 +368,13 @@ IMPL_LINK( SvxToolbarConfigPage, GearHdl, MenuButton *, pButton, void )
OUString aNewURL =
SvxConfigPageHelper::generateCustomURL( GetSaveInData()->GetEntries() );
- SvxNewToolbarDialog aNameDialog(GetFrameWeld(), aNewName);
+ SvxNewToolbarDialog aNameDialog(GetDialogFrameWeld(), aNewName);
- // Reflect the actual m_pSaveInListBox into the new toolbar dialog
- for (sal_Int32 i = 0; i < m_pSaveInListBox->GetEntryCount(); ++i)
- aNameDialog.m_xSaveInListBox->append_text(m_pSaveInListBox->GetEntry(i));
+ // Reflect the actual m_xSaveInListBox into the new toolbar dialog
+ for (int i = 0, nCount = m_xSaveInListBox->get_count(); i < nCount; ++i)
+ aNameDialog.m_xSaveInListBox->append_text(m_xSaveInListBox->get_text(i));
- aNameDialog.m_xSaveInListBox->set_active(m_pSaveInListBox->GetSelectedEntryPos());
+ aNameDialog.m_xSaveInListBox->set_active(m_xSaveInListBox->get_active());
if (aNameDialog.run() == RET_OK)
{
@@ -363,13 +384,13 @@ IMPL_LINK( SvxToolbarConfigPage, GearHdl, MenuButton *, pButton, void )
int nInsertPos = aNameDialog.m_xSaveInListBox->get_active();
ToolbarSaveInData* pData =
- static_cast<ToolbarSaveInData*>(
- m_pSaveInListBox->GetEntryData( nInsertPos ) );
+ reinterpret_cast<ToolbarSaveInData*>(
+ m_xSaveInListBox->get_id(nInsertPos).toInt64() );
if ( GetSaveInData() != pData )
{
- m_pSaveInListBox->SelectEntryPos( nInsertPos );
- m_pSaveInListBox->GetSelectHdl().Call(*m_pSaveInListBox);
+ m_xSaveInListBox->set_active(nInsertPos);
+ SelectSaveInLocation(*m_xSaveInListBox);
}
SvxConfigEntry* pToolbar =
@@ -380,15 +401,15 @@ IMPL_LINK( SvxToolbarConfigPage, GearHdl, MenuButton *, pButton, void )
pData->CreateToolbar( pToolbar );
- nInsertPos = m_pTopLevelListBox->InsertEntry( pToolbar->GetName() );
- m_pTopLevelListBox->SetEntryData( nInsertPos, pToolbar );
- m_pTopLevelListBox->SelectEntryPos( nInsertPos );
- m_pTopLevelListBox->GetSelectHdl().Call(*m_pTopLevelListBox);
+ OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pToolbar)));
+ m_xTopLevelListBox->append(sId, pToolbar->GetName());
+ m_xTopLevelListBox->set_active_id(sId);
+ SelectElement();
pData->SetModified();
}
}
- else if (sIdent == "gear_delete")
+ else if (rIdent == "gear_delete")
{
if ( pCurrentToolbar && pCurrentToolbar->IsDeletable() )
{
@@ -396,20 +417,20 @@ IMPL_LINK( SvxToolbarConfigPage, GearHdl, MenuButton *, pButton, void )
UpdateButtonStates();
}
}
- else if (sIdent == "gear_rename")
+ else if (rIdent == "gear_rename")
{
- sal_Int32 nSelectionPos = m_pTopLevelListBox->GetSelectedEntryPos();
+ sal_Int32 nSelectionPos = m_xTopLevelListBox->get_active();
SvxConfigEntry* pToolbar =
- static_cast<SvxConfigEntry*>(m_pTopLevelListBox->GetEntryData( nSelectionPos ));
+ reinterpret_cast<SvxConfigEntry*>(m_xTopLevelListBox->get_id(nSelectionPos).toInt64());
ToolbarSaveInData* pSaveInData = static_cast<ToolbarSaveInData*>( GetSaveInData() );
//Rename the toolbar
OUString sCurrentName( SvxConfigPageHelper::stripHotKey( pToolbar->GetName() ) );
OUString sDesc = CuiResId( RID_SVXSTR_LABEL_NEW_NAME );
- SvxNameDialog aNameDialog( GetFrameWeld(), sCurrentName, sDesc );
- aNameDialog.set_help_id( HID_SVX_CONFIG_RENAME_TOOLBAR );
- aNameDialog.set_title( CuiResId( RID_SVXSTR_RENAME_TOOLBAR ) );
+ SvxNameDialog aNameDialog(GetDialogFrameWeld(), sCurrentName, sDesc);
+ aNameDialog.set_help_id(HID_SVX_CONFIG_RENAME_TOOLBAR);
+ aNameDialog.set_title(CuiResId(RID_SVXSTR_RENAME_TOOLBAR));
if ( aNameDialog.run() == RET_OK )
{
@@ -422,14 +443,13 @@ IMPL_LINK( SvxToolbarConfigPage, GearHdl, MenuButton *, pButton, void )
pSaveInData->ApplyToolbar( pToolbar );
// have to use remove and insert to change the name
- m_pTopLevelListBox->RemoveEntry( nSelectionPos );
- nSelectionPos =
- m_pTopLevelListBox->InsertEntry( sNewName, nSelectionPos );
- m_pTopLevelListBox->SetEntryData( nSelectionPos, pToolbar );
- m_pTopLevelListBox->SelectEntryPos( nSelectionPos );
+ m_xTopLevelListBox->remove(nSelectionPos);
+ OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pToolbar)));
+ m_xTopLevelListBox->insert(nSelectionPos, sNewName, &sId, nullptr, nullptr);
+ m_xTopLevelListBox->set_active_id(sId);
}
}
- else if (sIdent == "gear_iconOnly" || sIdent == "gear_textOnly" || sIdent == "gear_iconAndText")
+ else if (rIdent == "gear_iconOnly" || rIdent == "gear_textOnly" || rIdent == "gear_iconAndText")
{
ToolbarSaveInData* pSaveInData = static_cast<ToolbarSaveInData*>( GetSaveInData() );
@@ -440,48 +460,46 @@ IMPL_LINK( SvxToolbarConfigPage, GearHdl, MenuButton *, pButton, void )
}
sal_Int32 nStyle = 0;
- if (sIdent == "gear_iconOnly")
+ if (rIdent == "gear_iconOnly")
nStyle = 0;
- else if (sIdent == "gear_textOnly")
+ else if (rIdent == "gear_textOnly")
nStyle = 1;
- else if (sIdent == "gear_iconAndText")
+ else if (rIdent == "gear_iconAndText")
nStyle = 2;
pCurrentToolbar->SetStyle( nStyle );
pSaveInData->SetSystemStyle( m_xFrame, pCurrentToolbar->GetCommand(), nStyle );
- m_pTopLevelListBox->GetSelectHdl().Call( *m_pTopLevelListBox );
+ SelectElement();
}
else
{
//This block should never be reached
- SAL_WARN("cui.customize", "Unknown gear menu option: " << sIdent);
+ SAL_WARN("cui.customize", "Unknown gear menu option: " << rIdent);
return;
}
}
-IMPL_LINK_NOARG( SvxToolbarConfigPage, SelectCategory, ListBox&, void )
+IMPL_LINK_NOARG( SvxToolbarConfigPage, SelectCategory, weld::ComboBox&, void )
{
- OUString aSearchTerm( m_pSearchEdit->GetText() );
+ OUString aSearchTerm(m_xSearchEdit->get_text());
- m_pCommandCategoryListBox->categorySelected( m_pFunctions, aSearchTerm, GetSaveInData() );
+ m_xCommandCategoryListBox->categorySelected(m_xFunctions.get(), aSearchTerm, GetSaveInData());
}
-IMPL_LINK_NOARG( SvxToolbarConfigPage, AddCommandHdl, Button *, void )
+IMPL_LINK_NOARG( SvxToolbarConfigPage, AddCommandHdl, weld::Button&, void )
{
AddFunction();
}
-IMPL_LINK_NOARG( SvxToolbarConfigPage, RemoveCommandHdl, Button *, void )
+IMPL_LINK_NOARG( SvxToolbarConfigPage, RemoveCommandHdl, weld::Button&, void )
{
DeleteSelectedContent();
}
-IMPL_LINK( SvxToolbarConfigPage, InsertHdl, MenuButton *, pButton, void )
+IMPL_LINK(SvxToolbarConfigPage, InsertHdl, const OString&, rIdent, void)
{
- OString sIdent = pButton->GetCurItemIdent();
-
- if (sIdent == "insertseparator")
+ if (rIdent == "insertseparator")
{
// Get the currently selected toolbar
SvxConfigEntry* pToolbar = GetTopLevelSelection();
@@ -489,11 +507,8 @@ IMPL_LINK( SvxToolbarConfigPage, InsertHdl, MenuButton *, pButton, void )
SvxConfigEntry* pNewEntryData = new SvxConfigEntry;
pNewEntryData->SetUserDefined();
- SvTreeListEntry* pNewLBEntry = InsertEntry( pNewEntryData );
-
- m_pContentsListBox->SetCheckButtonInvisible( pNewLBEntry );
- m_pContentsListBox->SetCheckButtonState(
- pNewLBEntry, SvButtonState::Tristate );
+ int nPos = InsertEntry(pNewEntryData, -1);
+ InsertEntryIntoUI(pNewEntryData, nPos, 1);
static_cast<ToolbarSaveInData*>( GetSaveInData())->ApplyToolbar( pToolbar );
@@ -502,35 +517,34 @@ IMPL_LINK( SvxToolbarConfigPage, InsertHdl, MenuButton *, pButton, void )
else
{
//This block should never be reached
- SAL_WARN("cui.customize", "Unknown insert option: " << sIdent);
+ SAL_WARN("cui.customize", "Unknown insert option: " << rIdent);
return;
}
}
-IMPL_LINK( SvxToolbarConfigPage, ModifyItemHdl, MenuButton *, pButton, void )
+IMPL_LINK(SvxToolbarConfigPage, ModifyItemHdl, const OString&, rIdent, void)
{
bool bNeedsApply = false;
// get currently selected toolbar
SvxConfigEntry* pToolbar = GetTopLevelSelection();
- OString sIdent = pButton->GetCurItemIdent();
- if (sIdent.isEmpty() || pToolbar == nullptr)
+ if (rIdent.isEmpty() || pToolbar == nullptr)
{
- SAL_WARN("cui.customize", "No toolbar selected, or empty sIdent!");
+ SAL_WARN("cui.customize", "No toolbar selected, or empty rIdent!");
return;
}
- if (sIdent == "renameItem")
+ if (rIdent == "renameItem")
{
- SvTreeListEntry* pActEntry = m_pContentsListBox->GetCurEntry();
+ int nActEntry = m_xContentsListBox->get_selected_index();
SvxConfigEntry* pEntry =
- static_cast<SvxConfigEntry*>(pActEntry->GetUserData());
+ reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry).toInt64());
OUString aNewName( SvxConfigPageHelper::stripHotKey( pEntry->GetName() ) );
OUString aDesc = CuiResId( RID_SVXSTR_LABEL_NEW_NAME );
- SvxNameDialog aNameDialog(GetFrameWeld(), aNewName, aDesc);
+ SvxNameDialog aNameDialog(GetDialogFrameWeld(), aNewName, aDesc);
aNameDialog.set_help_id(HID_SVX_CONFIG_RENAME_TOOLBAR_ITEM);
aNameDialog.set_title(CuiResId(RID_SVXSTR_RENAME_TOOLBAR));
@@ -543,19 +557,15 @@ IMPL_LINK( SvxToolbarConfigPage, ModifyItemHdl, MenuButton *, pButton, void )
else
pEntry->SetName( aNewName );
- m_pContentsListBox->SetEntryText( pActEntry, aNewName );
+ m_xContentsListBox->set_text(nActEntry, aNewName, 2);
bNeedsApply = true;
}
}
- else if (sIdent == "changeIcon")
+ else if (rIdent == "changeIcon")
{
- SvTreeListEntry* pActEntry = m_pContentsListBox->GetCurEntry();
+ int nActEntry = m_xContentsListBox->get_selected_index();
SvxConfigEntry* pEntry =
- static_cast<SvxConfigEntry*>(pActEntry->GetUserData());
-
- // Position of entry within the list
- // TODO: Add a GetSelectionPos() method to the SvTreeListBox class
- sal_uInt16 nSelectionPos = m_pContentsListBox->GetModel()->GetAbsPos( pActEntry );
+ reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry).toInt64());
SvxIconSelectorDialog aIconDialog(GetDialogFrameWeld(),
GetSaveInData()->GetImageManager(),
@@ -575,13 +585,13 @@ IMPL_LINK( SvxToolbarConfigPage, ModifyItemHdl, MenuButton *, pButton, void )
if ( !pEntry->GetBackupGraphic().is() )
{
- css::uno::Reference< css::graphic::XGraphic > backup;
- backup = SvxConfigPageHelper::GetGraphic(
- GetSaveInData()->GetImageManager(), aURLSeq[ 0 ] );
+ css::uno::Reference< css::graphic::XGraphic > backup =
+ SvxConfigPageHelper::GetGraphic(GetSaveInData()->GetImageManager(),
+ aURLSeq[0]);
if ( backup.is() )
{
- pEntry->SetBackupGraphic( backup );
+ pEntry->SetBackupGraphic(backup);
}
}
@@ -591,16 +601,15 @@ IMPL_LINK( SvxToolbarConfigPage, ModifyItemHdl, MenuButton *, pButton, void )
GetSaveInData()->GetImageManager()->replaceImages(
SvxConfigPageHelper::GetImageType(), aURLSeq, aGraphicSeq );
- m_pContentsListBox->GetModel()->Remove( pActEntry );
- SvTreeListEntry* pNewLBEntry =
- InsertEntryIntoUI( pEntry, nSelectionPos );
+ m_xContentsListBox->remove(nActEntry);
- m_pContentsListBox->SetCheckButtonState( pNewLBEntry,
- pEntry->IsVisible() ?
- SvButtonState::Checked : SvButtonState::Unchecked );
+ OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pEntry)));
+ m_xContentsListBox->insert(nActEntry, sId);
+ m_xContentsListBox->set_toggle(nActEntry, pEntry->IsVisible(), 0);
+ InsertEntryIntoUI(pEntry, nActEntry, 1);
- m_pContentsListBox->Select( pNewLBEntry );
- m_pContentsListBox->MakeVisible( pNewLBEntry );
+ m_xContentsListBox->select(nActEntry);
+ m_xContentsListBox->scroll_to_row(nActEntry);
GetSaveInData()->PersistChanges(
GetSaveInData()->GetImageManager() );
@@ -612,15 +621,11 @@ IMPL_LINK( SvxToolbarConfigPage, ModifyItemHdl, MenuButton *, pButton, void )
}
}
}
- else if (sIdent == "resetIcon")
+ else if (rIdent == "resetIcon")
{
- SvTreeListEntry* pActEntry = m_pContentsListBox->GetCurEntry();
+ int nActEntry = m_xContentsListBox->get_selected_index();
SvxConfigEntry* pEntry =
- static_cast<SvxConfigEntry*>(pActEntry->GetUserData());
-
- // Position of entry within the list
- // TODO: Add a GetSelectionPos() method to the SvTreeListBox class
- sal_uInt16 nSelectionPos = m_pContentsListBox->GetModel()->GetAbsPos( pActEntry );
+ reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry).toInt64());
css::uno::Reference< css::graphic::XGraphic > backup =
pEntry->GetBackupGraphic();
@@ -636,17 +641,15 @@ IMPL_LINK( SvxToolbarConfigPage, ModifyItemHdl, MenuButton *, pButton, void )
GetSaveInData()->GetImageManager()->replaceImages(
SvxConfigPageHelper::GetImageType(), aURLSeq, aGraphicSeq );
- m_pContentsListBox->GetModel()->Remove( pActEntry );
+ m_xContentsListBox->remove(nActEntry);
- SvTreeListEntry* pNewLBEntry =
- InsertEntryIntoUI( pEntry, nSelectionPos );
+ OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pEntry)));
+ m_xContentsListBox->insert(nActEntry, sId);
+ m_xContentsListBox->set_toggle(nActEntry, pEntry->IsVisible(), 0);
+ InsertEntryIntoUI(pEntry, nActEntry, 1);
- m_pContentsListBox->SetCheckButtonState( pNewLBEntry,
- pEntry->IsVisible() ?
- SvButtonState::Checked : SvButtonState::Unchecked );
-
- m_pContentsListBox->Select( pNewLBEntry );
- m_pContentsListBox->MakeVisible( pNewLBEntry );
+ m_xContentsListBox->select(nActEntry);
+ m_xContentsListBox->scroll_to_row(nActEntry);
// reset backup in entry
pEntry->SetBackupGraphic(
@@ -660,15 +663,11 @@ IMPL_LINK( SvxToolbarConfigPage, ModifyItemHdl, MenuButton *, pButton, void )
SAL_WARN("cui.customize", "Error resetting image: " << e);
}
}
- else if (sIdent == "restoreItem")
+ else if (rIdent == "restoreItem")
{
- SvTreeListEntry* pActEntry = m_pContentsListBox->GetCurEntry();
+ int nActEntry = m_xContentsListBox->get_selected_index();
SvxConfigEntry* pEntry =
- static_cast<SvxConfigEntry*>(pActEntry->GetUserData());
-
- // Position of entry within the list
- // TODO: Add a GetSelectionPos() method to the SvTreeListBox class
- sal_uInt16 nSelectionPos = m_pContentsListBox->GetModel()->GetAbsPos( pActEntry );
+ reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry).toInt64());
ToolbarSaveInData* pSaveInData =
static_cast<ToolbarSaveInData*>( GetSaveInData() );
@@ -679,8 +678,8 @@ IMPL_LINK( SvxToolbarConfigPage, ModifyItemHdl, MenuButton *, pButton, void )
if ( !pEntry->GetName().equals( aSystemName ) )
{
pEntry->SetName( aSystemName );
- m_pContentsListBox->SetEntryText(
- pActEntry, SvxConfigPageHelper::stripHotKey( aSystemName ) );
+ m_xContentsListBox->set_text(
+ nActEntry, SvxConfigPageHelper::stripHotKey(aSystemName), 2);
bNeedsApply = true;
}
@@ -698,17 +697,16 @@ IMPL_LINK( SvxToolbarConfigPage, ModifyItemHdl, MenuButton *, pButton, void )
GetSaveInData()->PersistChanges(
GetSaveInData()->GetImageManager() );
- m_pContentsListBox->RemoveEntry( pActEntry );
+ m_xContentsListBox->remove(nActEntry);
- SvTreeListEntry* pNewLBEntry =
- InsertEntryIntoUI( pEntry, nSelectionPos );
+ OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pEntry)));
+ m_xContentsListBox->insert(nActEntry, sId);
+ m_xContentsListBox->set_toggle(nActEntry,
+ pEntry->IsVisible(), 0);
+ InsertEntryIntoUI(pEntry, nActEntry, 1);
- m_pContentsListBox->SetCheckButtonState( pNewLBEntry,
- pEntry->IsVisible() ?
- SvButtonState::Checked : SvButtonState::Unchecked );
-
- m_pContentsListBox->Select( pNewLBEntry );
- m_pContentsListBox->MakeVisible( pNewLBEntry );
+ m_xContentsListBox->select(nActEntry);
+ m_xContentsListBox->scroll_to_row(nActEntry);
bNeedsApply = true;
}
@@ -720,7 +718,7 @@ IMPL_LINK( SvxToolbarConfigPage, ModifyItemHdl, MenuButton *, pButton, void )
else
{
//This block should never be reached
- SAL_WARN("cui.customize", "Unknown insert option: " << sIdent);
+ SAL_WARN("cui.customize", "Unknown insert option: " << rIdent);
return;
}
@@ -731,14 +729,14 @@ IMPL_LINK( SvxToolbarConfigPage, ModifyItemHdl, MenuButton *, pButton, void )
}
}
-IMPL_LINK_NOARG( SvxToolbarConfigPage, ResetToolbarHdl, Button *, void )
+IMPL_LINK_NOARG(SvxToolbarConfigPage, ResetToolbarHdl, weld::Button&, void)
{
- sal_Int32 nSelectionPos = m_pTopLevelListBox->GetSelectedEntryPos();
+ sal_Int32 nSelectionPos = m_xTopLevelListBox->get_active();
SvxConfigEntry* pToolbar =
- static_cast<SvxConfigEntry*>(m_pTopLevelListBox->GetEntryData( nSelectionPos ));
+ reinterpret_cast<SvxConfigEntry*>(m_xTopLevelListBox->get_id(nSelectionPos).toInt64());
- std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetFrameWeld(),
+ std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetDialogFrameWeld(),
VclMessageType::Question, VclButtonsType::YesNo,
CuiResId(RID_SVXSTR_CONFIRM_RESTORE_DEFAULT)));
if (xQueryBox->run() == RET_YES)
@@ -748,115 +746,103 @@ IMPL_LINK_NOARG( SvxToolbarConfigPage, ResetToolbarHdl, Button *, void )
pSaveInData->RestoreToolbar( pToolbar );
- m_pTopLevelListBox->GetSelectHdl().Call( *m_pTopLevelListBox );
+ SelectElement();
}
}
void SvxToolbarConfigPage::UpdateButtonStates()
{
SvxConfigEntry* pToolbar = GetTopLevelSelection();
- SvTreeListEntry* selection = m_pContentsListBox->GetCurEntry();
+ int selection = m_xContentsListBox->get_selected_index();
bool bIsSeparator =
- selection && static_cast<SvxConfigEntry*>(selection->GetUserData())->IsSeparator();
+ selection != -1 && reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(selection).toInt64())->IsSeparator();
bool bIsValidSelection =
- !(m_pContentsListBox->GetEntryCount() == 0 || selection == nullptr);
+ !(m_xContentsListBox->n_children() == 0 || selection == -1);
- m_pMoveUpButton->Enable( bIsValidSelection );
- m_pMoveDownButton->Enable( bIsValidSelection );
+ m_xMoveUpButton->set_sensitive( bIsValidSelection );
+ m_xMoveDownButton->set_sensitive( bIsValidSelection );
- m_pRemoveCommandButton->Enable( bIsValidSelection );
+ m_xRemoveCommandButton->set_sensitive( bIsValidSelection );
- m_pModifyBtn->Enable( bIsValidSelection && !bIsSeparator );
+ m_xModifyBtn->set_sensitive( bIsValidSelection && !bIsSeparator );
// Handle the gear button
- PopupMenu* pPopup = m_pGearBtn->GetPopupMenu();
// "gear_add" option is always enabled
- pPopup->EnableItem( "gear_delete", pToolbar && pToolbar->IsDeletable() );
- pPopup->EnableItem( "gear_rename", pToolbar && pToolbar->IsRenamable() );
+ m_xGearBtn->set_item_sensitive("gear_delete", pToolbar && pToolbar->IsDeletable());
+ m_xGearBtn->set_item_sensitive("gear_rename", pToolbar && pToolbar->IsRenamable());
}
short SvxToolbarConfigPage::QueryReset()
{
OUString msg = CuiResId( RID_SVXSTR_CONFIRM_TOOLBAR_RESET );
- OUString saveInName = m_pSaveInListBox->GetEntry(
- m_pSaveInListBox->GetSelectedEntryPos() );
+ OUString saveInName = m_xSaveInListBox->get_active_text();
OUString label = SvxConfigPageHelper::replaceSaveInName( msg, saveInName );
- std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetFrameWeld(),
+ std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetDialogFrameWeld(),
VclMessageType::Question, VclButtonsType::YesNo,
label));
return xQueryBox->run();
}
-IMPL_LINK_NOARG( SvxToolbarConfigPage, SelectToolbar, ListBox&, void )
+void SvxToolbarConfigPage::SelectElement()
{
- m_pContentsListBox->Clear();
+ m_xContentsListBox->clear();
SvxConfigEntry* pToolbar = GetTopLevelSelection();
if ( pToolbar == nullptr )
{
//TODO: Disable related buttons
- m_pInsertBtn->Enable( false );
- m_pResetBtn->Enable( false );
- m_pGearBtn->Enable( false );
+ m_xInsertBtn->set_sensitive( false );
+ m_xResetBtn->set_sensitive( false );
+ m_xGearBtn->set_sensitive( false );
return;
}
else
{
- m_pInsertBtn->Enable();
- m_pResetBtn->Enable();
- m_pGearBtn->Enable();
+ m_xInsertBtn->set_sensitive(true);
+ m_xResetBtn->set_sensitive(true);
+ m_xGearBtn->set_sensitive(true);
}
- PopupMenu* pGearMenu = m_pGearBtn->GetPopupMenu();
- switch( pToolbar->GetStyle() )
+ switch (pToolbar->GetStyle())
{
case 0:
{
- pGearMenu->CheckItem( "gear_iconOnly" );
+ m_xGearBtn->set_item_active("gear_iconOnly", true);
break;
}
case 1:
{
- pGearMenu->CheckItem( "gear_textOnly" );
+ m_xGearBtn->set_item_active("gear_textOnly", true);
break;
}
case 2:
{
- pGearMenu->CheckItem( "gear_iconAndText" );
+ m_xGearBtn->set_item_active("gear_iconAndText", true);
break;
}
}
+ int i = 0;
SvxEntries* pEntries = pToolbar->GetEntries();
for (auto const& entry : *pEntries)
{
- SvTreeListEntry* pNewLBEntry = InsertEntryIntoUI(entry);
-
- if(entry->IsSeparator())
- m_pContentsListBox->SetCheckButtonInvisible( pNewLBEntry );
-
- if (entry->IsBinding())
- {
- m_pContentsListBox->SetCheckButtonState( pNewLBEntry,
- entry->IsVisible() ? SvButtonState::Checked : SvButtonState::Unchecked );
- }
- else
- {
- m_pContentsListBox->SetCheckButtonState(
- pNewLBEntry, SvButtonState::Tristate );
- }
+ OUString sId(OUString::number(reinterpret_cast<sal_Int64>(entry)));
+ m_xContentsListBox->insert(i, sId);
+ if (entry->IsBinding() && !entry->IsSeparator())
+ m_xContentsListBox->set_toggle(i, entry->IsVisible(), 0);
+ InsertEntryIntoUI(entry, i, 1);
+ ++i;
}
UpdateButtonStates();
}
-void SvxToolbarConfigPage::AddFunction(
- SvTreeListEntry* pTarget, bool bFront )
+void SvxToolbarConfigPage::AddFunction(int nTarget, bool bFront)
{
SvxConfigEntry* pToolbar = GetTopLevelSelection();
@@ -864,26 +850,22 @@ void SvxToolbarConfigPage::AddFunction(
return;
// Add the command to the contents listbox of the selected toolbar
- SvTreeListEntry* pNewLBEntry =
- SvxConfigPage::AddFunction( pTarget, bFront, true/*bAllowDuplicates*/ );
+ int nNewLBEntry =
+ SvxConfigPage::AddFunction(nTarget, bFront, true/*bAllowDuplicates*/);
- if (pNewLBEntry == nullptr)
+ if (nNewLBEntry == -1)
return;
- SvxConfigEntry* pEntry = static_cast<SvxConfigEntry*>(pNewLBEntry->GetUserData());
+ SvxConfigEntry* pEntry = reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nNewLBEntry).toInt64());
- if ( pEntry->IsBinding() )
- {
- pEntry->SetVisible( true );
- m_pContentsListBox->SetCheckButtonState(
- pNewLBEntry, SvButtonState::Checked );
- }
- else
+ if ( pEntry->IsBinding() ) //TODO sep ?
{
- m_pContentsListBox->SetCheckButtonState(
- pNewLBEntry, SvButtonState::Tristate );
+ pEntry->SetVisible(true);
+ m_xContentsListBox->set_toggle(nNewLBEntry, true, 0);
}
+ InsertEntryIntoUI(pEntry, nNewLBEntry, 1);
+
// Changes are not visible on the toolbar until this point
// TODO: Figure out a way to show the changes on the toolbar, but revert if
// the dialog is closed by pressing "Cancel"
@@ -894,187 +876,56 @@ void SvxToolbarConfigPage::AddFunction(
}
}
-SvxToolbarEntriesListBox::SvxToolbarEntriesListBox(vcl::Window* pParent, SvxToolbarConfigPage* pPg)
- : SvxMenuEntriesListBox(pParent, pPg)
- , pPage(pPg)
+SvxToolbarEntriesListBox::SvxToolbarEntriesListBox(std::unique_ptr<weld::TreeView> xParent, SvxToolbarConfigPage* pPg)
+ : SvxMenuEntriesListBox(std::move(xParent), pPg)
{
- m_pButtonData.reset(new SvLBoxButtonData( this ));
- BuildCheckBoxButtonImages( m_pButtonData.get() );
- EnableCheckButton( m_pButtonData.get() );
+ m_xControl->connect_toggled(LINK(this, SvxToolbarEntriesListBox, CheckButtonHdl));
+ m_xControl->connect_key_press(Link<const KeyEvent&, bool>()); //acknowledge we first remove the old one
+ m_xControl->connect_key_press(LINK(this, SvxToolbarEntriesListBox, KeyInputHdl)); // then add the new one
}
SvxToolbarEntriesListBox::~SvxToolbarEntriesListBox()
{
- disposeOnce();
-}
-
-void SvxToolbarEntriesListBox::dispose()
-{
- m_pButtonData.reset();
-
- pPage.clear();
- SvxMenuEntriesListBox::dispose();
}
-void SvxToolbarEntriesListBox::BuildCheckBoxButtonImages( SvLBoxButtonData* pData )
+void SvxToolbarEntriesListBox::ChangedVisibility(int nRow)
{
- // Build checkbox images according to the current application
- // settings. This is necessary to be able to have correct colors
- // in all color modes, like high contrast.
- const AllSettings& rSettings = Application::GetSettings();
-
- ScopedVclPtrInstance< VirtualDevice > pVDev;
- Size aSize( 26, 20 );
-
- pVDev->SetOutputSizePixel( aSize );
-
- Image aImage = GetSizedImage( *pVDev, aSize,
- CheckBox::GetCheckImage( rSettings, DrawButtonFlags::Default ));
-
- // Fill button data struct with new images
- pData->SetImage(SvBmp::UNCHECKED, aImage);
- pData->SetImage(SvBmp::CHECKED, GetSizedImage( *pVDev, aSize, CheckBox::GetCheckImage( rSettings, DrawButtonFlags::Checked )) );
- pData->SetImage(SvBmp::HICHECKED, GetSizedImage( *pVDev, aSize, CheckBox::GetCheckImage( rSettings, DrawButtonFlags::Checked | DrawButtonFlags::Pressed )) );
- pData->SetImage(SvBmp::HIUNCHECKED, GetSizedImage( *pVDev, aSize, CheckBox::GetCheckImage( rSettings, DrawButtonFlags::Default | DrawButtonFlags::Pressed)) );
- pData->SetImage(SvBmp::TRISTATE, GetSizedImage( *pVDev, aSize, Image() ) ); // Use tristate bitmaps to have no checkbox for separator entries
- pData->SetImage(SvBmp::HITRISTATE, GetSizedImage( *pVDev, aSize, Image() ) );
-}
+ SvxConfigEntry* pEntryData =
+ reinterpret_cast<SvxConfigEntry*>(m_xControl->get_id(nRow).toInt64());
-Image SvxToolbarEntriesListBox::GetSizedImage(
- VirtualDevice& rVDev, const Size& aNewSize, const Image& aImage )
-{
- // Create new checkbox images for treelistbox. They must have a
- // decent width to have a clear column for the visibility checkbox.
-
- // Standard transparent color is light magenta as is won't be
- // used for other things
- Color aFillColor( COL_LIGHTMAGENTA );
-
- // Position image at the center of (width-2),(height) rectangle.
- // We need 2 pixels to have a bigger border to the next button image
- sal_uInt16 nPosX = std::max( static_cast<sal_uInt16>(((( aNewSize.Width() - 2 ) - aImage.GetSizePixel().Width() ) / 2 ) - 1), sal_uInt16(0) );
- sal_uInt16 nPosY = std::max( static_cast<sal_uInt16>(((( aNewSize.Height() - 2 ) - aImage.GetSizePixel().Height() ) / 2 ) + 1), sal_uInt16(0) );
- Point aPos( std::max<sal_uInt16>(nPosX, 0), std::max<sal_uInt16>(nPosY, 0) );
- rVDev.SetFillColor( aFillColor );
- rVDev.SetLineColor( aFillColor );
- rVDev.DrawRect( ::tools::Rectangle( Point(), aNewSize ));
- rVDev.DrawImage( aPos, aImage );
-
- // Draw separator line 2 pixels left from the right border
- Color aLineColor = GetDisplayBackground().GetColor().IsDark() ? COL_WHITE : COL_BLACK;
- rVDev.SetLineColor( aLineColor );
- rVDev.DrawLine( Point( aNewSize.Width()-3, 0 ), Point( aNewSize.Width()-3, aNewSize.Height()-1 ));
-
- // Create new image that uses the fillcolor as transparent
- return Image(BitmapEx(rVDev.GetBitmapEx(Point(), aNewSize).GetBitmap(), aFillColor));
-}
-
-void SvxToolbarEntriesListBox::DataChanged( const DataChangedEvent& rDCEvt )
-{
- SvTreeListBox::DataChanged( rDCEvt );
-
- if (( rDCEvt.GetType() == DataChangedEventType::SETTINGS ) &&
- ( rDCEvt.GetFlags() & AllSettingsFlags::STYLE ))
- {
- BuildCheckBoxButtonImages( m_pButtonData.get() );
- Invalidate();
- }
-}
-
-
-void SvxToolbarEntriesListBox::ChangeVisibility( SvTreeListEntry* pEntry )
-{
- if ( pEntry != nullptr )
+ if (pEntryData->IsBinding())
{
- SvxConfigEntry* pEntryData =
- static_cast<SvxConfigEntry*>(pEntry->GetUserData());
-
- if ( pEntryData->IsBinding() )
- {
- pEntryData->SetVisible( !pEntryData->IsVisible() );
-
- SvxConfigEntry* pToolbar = pPage->GetTopLevelSelection();
+ pEntryData->SetVisible(m_xControl->get_toggle(nRow, 0));
- ToolbarSaveInData* pToolbarSaveInData = static_cast<ToolbarSaveInData*>(
- pPage->GetSaveInData() );
+ SvxConfigEntry* pToolbar = pPage->GetTopLevelSelection();
- pToolbarSaveInData->ApplyToolbar( pToolbar );
+ ToolbarSaveInData* pToolbarSaveInData = static_cast<ToolbarSaveInData*>(
+ pPage->GetSaveInData() );
- SetCheckButtonState( pEntry, pEntryData->IsVisible() ?
- SvButtonState::Checked : SvButtonState::Unchecked );
- }
+ pToolbarSaveInData->ApplyToolbar( pToolbar );
}
}
-void SvxToolbarEntriesListBox::CheckButtonHdl()
+IMPL_LINK(SvxToolbarEntriesListBox, CheckButtonHdl, const row_col&, rRowCol, void)
{
- ChangeVisibility( GetHdlEntry() );
+ ChangedVisibility(rRowCol.first);
}
-void SvxToolbarEntriesListBox::KeyInput( const KeyEvent& rKeyEvent )
+IMPL_LINK(SvxToolbarEntriesListBox, KeyInputHdl, const KeyEvent&, rKeyEvent, bool)
{
// space key will change visibility of toolbar items
if ( rKeyEvent.GetKeyCode() == KEY_SPACE )
{
- ChangeVisibility( GetCurEntry() );
- }
- else
- {
- // pass on to superclass
- SvxMenuEntriesListBox::KeyInput( rKeyEvent );
- }
-}
-
-TriState SvxToolbarEntriesListBox::NotifyMoving(
- SvTreeListEntry* pTarget, SvTreeListEntry* pSource,
- SvTreeListEntry*& rpNewParent, sal_uLong& rNewChildPos)
-{
- TriState result = SvxMenuEntriesListBox::NotifyMoving(
- pTarget, pSource, rpNewParent, rNewChildPos );
-
- if ( result )
- {
- // Instant Apply changes to UI
- SvxConfigEntry* pToolbar = pPage->GetTopLevelSelection();
- if ( pToolbar != nullptr )
+ int nRow = m_xControl->get_selected_index();
+ SvxConfigEntry* pEntryData = reinterpret_cast<SvxConfigEntry*>(m_xControl->get_id(nRow).toInt64());
+ if (pEntryData->IsBinding() && !pEntryData->IsSeparator())
{
- ToolbarSaveInData* pSaveInData =
- static_cast<ToolbarSaveInData*>( pPage->GetSaveInData() );
- pSaveInData->ApplyToolbar( pToolbar );
+ m_xControl->set_toggle(nRow, !m_xControl->get_toggle(nRow, 0), 0);
+ ChangedVisibility(nRow);
}
+ return true;
}
-
- return result;
-}
-
-TriState SvxToolbarEntriesListBox::NotifyCopying(
- SvTreeListEntry* pTarget,
- SvTreeListEntry*,
- SvTreeListEntry*&,
- sal_uLong&)
-{
-
- if ( !m_bIsInternalDrag )
- {
- // if the target is NULL then add function to the start of the list
- static_cast<SvxToolbarConfigPage*>(pPage.get())->AddFunction( pTarget, pTarget == nullptr );
-
- // Instant Apply changes to UI
- SvxConfigEntry* pToolbar = pPage->GetTopLevelSelection();
- if ( pToolbar != nullptr )
- {
- ToolbarSaveInData* pSaveInData =
- static_cast<ToolbarSaveInData*>( pPage->GetSaveInData() );
- pSaveInData->ApplyToolbar( pToolbar );
- }
-
- // AddFunction already adds the listbox entry so return TRISTATE_FALSE
- // to stop another listbox entry being added
- return TRISTATE_FALSE;
- }
-
- // Copying is only allowed from external controls, not within the listbox
- return TRISTATE_FALSE;
+ return SvxMenuEntriesListBox::KeyInputHdl(rKeyEvent);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/customize/acccfg.cxx b/cui/source/customize/acccfg.cxx
index 4146be2ae20d..40f15d588721 100644
--- a/cui/source/customize/acccfg.cxx
+++ b/cui/source/customize/acccfg.cxx
@@ -887,6 +887,7 @@ SfxAcceleratorConfigPage::SfxAcceleratorConfigPage(TabPageParent pParent, const
m_xOfficeButton->connect_clicked( LINK( this, SfxAcceleratorConfigPage, RadioHdl ));
m_xModuleButton->connect_clicked( LINK( this, SfxAcceleratorConfigPage, RadioHdl ));
m_xSearchEdit->connect_changed( LINK( this, SfxAcceleratorConfigPage, SearchUpdateHdl ));
+ m_xSearchEdit->connect_focus_out(LINK(this, SfxAcceleratorConfigPage, FocusOut_Impl));
// detect max keyname width
int nMaxWidth = 0;
@@ -1121,6 +1122,15 @@ IMPL_LINK_NOARG(SfxAcceleratorConfigPage, SearchUpdateHdl, weld::Entry&, void)
m_aUpdateDataTimer.Start();
}
+IMPL_LINK_NOARG(SfxAcceleratorConfigPage, FocusOut_Impl, weld::Widget&, void)
+{
+ if (m_aUpdateDataTimer.IsActive())
+ {
+ m_aUpdateDataTimer.Stop();
+ m_aUpdateDataTimer.Invoke();
+ }
+}
+
IMPL_LINK_NOARG(SfxAcceleratorConfigPage, Load, weld::Button&, void)
{
// ask for filename, where we should load the new config data from
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
index d830b2ef8f7e..8f28bb77dc64 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -101,8 +101,6 @@
#include <dlgname.hxx>
-#define ENTRY_HEIGHT 16
-
namespace uno = com::sun::star::uno;
namespace frame = com::sun::star::frame;
namespace lang = com::sun::star::lang;
@@ -178,12 +176,12 @@ SvxConfigPage::CanConfig( const OUString& aModuleId )
static VclPtr<SfxTabPage> CreateSvxMenuConfigPage( TabPageParent pParent, const SfxItemSet* rSet )
{
- return VclPtr<SvxMenuConfigPage>::Create( pParent.pParent, *rSet );
+ return VclPtr<SvxMenuConfigPage>::Create(pParent, *rSet);
}
static VclPtr<SfxTabPage> CreateSvxContextMenuConfigPage( TabPageParent pParent, const SfxItemSet* rSet )
{
- return VclPtr<SvxMenuConfigPage>::Create( pParent.pParent, *rSet, false );
+ return VclPtr<SvxMenuConfigPage>::Create(pParent, *rSet, false);
}
static VclPtr<SfxTabPage> CreateKeyboardConfigPage( TabPageParent pParent, const SfxItemSet* rSet )
@@ -193,7 +191,7 @@ static VclPtr<SfxTabPage> CreateKeyboardConfigPage( TabPageParent pParent, const
static VclPtr<SfxTabPage> CreateSvxToolbarConfigPage( TabPageParent pParent, const SfxItemSet* rSet )
{
- return VclPtr<SvxToolbarConfigPage>::Create( pParent.pParent, *rSet );
+ return VclPtr<SvxToolbarConfigPage>::Create(pParent, *rSet);
}
static VclPtr<SfxTabPage> CreateSvxEventConfigPage( TabPageParent pParent, const SfxItemSet* rSet )
@@ -325,28 +323,17 @@ SaveInData::SaveInData(
}
}
-Image SaveInData::GetImage( const OUString& rCommandURL )
+uno::Reference<graphic::XGraphic> SaveInData::GetImage(const OUString& rCommandURL)
{
- Image aImage;
-
uno::Reference< graphic::XGraphic > xGraphic =
SvxConfigPageHelper::GetGraphic( m_xImgMgr, rCommandURL );
- if ( xGraphic.is() )
- {
- aImage = Image( xGraphic );
- }
- else if ( xDefaultImgMgr != nullptr && (*xDefaultImgMgr).is() )
+ if (!xGraphic.is() && xDefaultImgMgr != nullptr && (*xDefaultImgMgr).is())
{
xGraphic = SvxConfigPageHelper::GetGraphic( (*xDefaultImgMgr), rCommandURL );
-
- if ( xGraphic.is() )
- {
- aImage = Image( xGraphic );
- }
}
- return aImage;
+ return xGraphic;
}
bool SaveInData::PersistChanges(
@@ -922,55 +909,25 @@ void ContextMenuSaveInData::ResetContextMenu( const SvxConfigEntry* pEntry )
m_pRootEntry.reset();
}
-class PopupPainter : public SvLBoxString
+void SvxMenuEntriesListBox::CreateDropDown()
{
-public:
- explicit PopupPainter(const OUString& rStr)
- : SvLBoxString(rStr)
- {
- }
-
- virtual void Paint(const Point& rPos, SvTreeListBox& rOutDev, vcl::RenderContext& rRenderContext,
- const SvViewDataEntry* pView, const SvTreeListEntry& rEntry) override
- {
- SvLBoxString::Paint(rPos, rOutDev, rRenderContext, pView, rEntry);
+ int nWidth = m_xControl->get_text_height();
+ m_xDropDown->SetOutputSizePixel(Size(nWidth, nWidth));
- rRenderContext.Push(PushFlags::FILLCOLOR);
+ int nSize = nWidth / 2;
+ int nHalfSize = nSize / 2;
+ int nY = nHalfSize;
+ int nX = 0;
- long nX = rOutDev.GetSizePixel().Width();
-
- ScrollBar* pVScroll = rOutDev.GetVScroll();
- if (pVScroll->IsVisible())
- {
- nX -= pVScroll->GetSizePixel().Width();
- }
+ m_xDropDown->SetFillColor(COL_BLACK);
- const SvViewDataItem* pItem = rOutDev.GetViewDataItem( &rEntry, this );
- nX -= pItem->maSize.Height();
-
- long nSize = pItem->maSize.Height() / 2;
- long nHalfSize = nSize / 2;
- long nY = rPos.Y() + nHalfSize;
-
- if (rRenderContext.GetFillColor() == COL_WHITE)
- {
- rRenderContext.SetFillColor(COL_BLACK);
- }
- else
- {
- rRenderContext.SetFillColor(COL_WHITE);
- }
-
- long n = 0;
- while (n <= nHalfSize)
- {
- rRenderContext.DrawRect(::tools::Rectangle(nX + n, nY + n, nX + n, nY + nSize - n));
- ++n;
- }
-
- rRenderContext.Pop();
+ int n = 0;
+ while (n <= nHalfSize)
+ {
+ m_xDropDown->DrawRect(::tools::Rectangle(nX + n, nY + n, nX + n, nY + nSize - n));
+ ++n;
}
-};
+}
/******************************************************************************
*
@@ -980,112 +937,21 @@ public:
* listbox
*
*****************************************************************************/
-SvxMenuEntriesListBox::SvxMenuEntriesListBox(vcl::Window* pParent, SvxConfigPage* pPg)
- : SvTreeListBox(pParent, WB_TABSTOP|WB_CLIPCHILDREN|WB_HIDESELECTION|WB_BORDER)
+SvxMenuEntriesListBox::SvxMenuEntriesListBox(std::unique_ptr<weld::TreeView> xControl, SvxConfigPage* pPg)
+ : m_xControl(std::move(xControl))
+ , m_xDropDown(VclPtr<VirtualDevice>::Create(*Application::GetDefaultDevice(), DeviceFormat::DEFAULT, DeviceFormat::DEFAULT))
, pPage(pPg)
, m_bIsInternalDrag( false )
{
- SetSpaceBetweenEntries( 3 );
- SetEntryHeight( ENTRY_HEIGHT );
-
- SetHighlightRange();
- SetSelectionMode(SelectionMode::Single);
-
- SetDragDropMode( DragDropMode::CTRL_MOVE |
- DragDropMode::APP_COPY |
- DragDropMode::ENABLE_TOP |
- DragDropMode::APP_DROP);
+ CreateDropDown();
+ m_xControl->connect_key_press(LINK(this, SvxMenuEntriesListBox, KeyInputHdl));
}
SvxMenuEntriesListBox::~SvxMenuEntriesListBox()
{
- disposeOnce();
-}
-
-void SvxMenuEntriesListBox::dispose()
-{
- pPage.clear();
- SvTreeListBox::dispose();
-}
-
-// drag and drop support
-DragDropMode SvxMenuEntriesListBox::NotifyStartDrag(
- TransferDataContainer&, SvTreeListEntry* )
-{
- m_bIsInternalDrag = true;
- return GetDragDropMode();
-}
-
-void SvxMenuEntriesListBox::DragFinished( sal_Int8 )
-{
- m_bIsInternalDrag = false;
-}
-
-sal_Int8 SvxMenuEntriesListBox::AcceptDrop( const AcceptDropEvent& rEvt )
-{
- if ( m_bIsInternalDrag )
- {
- // internal copy isn't allowed!
- if ( rEvt.mnAction == DND_ACTION_COPY )
- return DND_ACTION_NONE;
- else
- return SvTreeListBox::AcceptDrop( rEvt );
- }
-
- // Always do COPY instead of MOVE if D&D comes from outside!
- AcceptDropEvent aNewAcceptDropEvent( rEvt );
- aNewAcceptDropEvent.mnAction = DND_ACTION_COPY;
- return SvTreeListBox::AcceptDrop( aNewAcceptDropEvent );
-}
-
-bool SvxMenuEntriesListBox::NotifyAcceptDrop( SvTreeListEntry* )
-{
- return true;
-}
-
-TriState SvxMenuEntriesListBox::NotifyMoving(
- SvTreeListEntry* pTarget, SvTreeListEntry* pSource,
- SvTreeListEntry*& rpNewParent, sal_uLong& rNewChildPos)
-{
- // only try to do a move if we are dragging within the list box
- if ( m_bIsInternalDrag )
- {
- if ( pPage->MoveEntryData( pSource, pTarget ) )
- {
- SvTreeListBox::NotifyMoving(
- pTarget, pSource, rpNewParent, rNewChildPos );
- return TRISTATE_TRUE;
- }
- else
- {
- return TRISTATE_FALSE;
- }
- }
- else
- {
- return NotifyCopying( pTarget, pSource, rpNewParent, rNewChildPos );
- }
-}
-
-TriState SvxMenuEntriesListBox::NotifyCopying(
- SvTreeListEntry* pTarget, SvTreeListEntry*,
- SvTreeListEntry*&, sal_uLong&)
-{
- if ( !m_bIsInternalDrag )
- {
- // if the target is NULL then add function to the start of the list
- pPage->AddFunction( pTarget, pTarget == nullptr );
-
- // AddFunction already adds the listbox entry so return TRISTATE_FALSE
- // to stop another listbox entry being added
- return TRISTATE_FALSE;
- }
-
- // Copying is only allowed from external controls, not within the listbox
- return TRISTATE_FALSE;
}
-void SvxMenuEntriesListBox::KeyInput( const KeyEvent& rKeyEvent )
+IMPL_LINK(SvxMenuEntriesListBox, KeyInputHdl, const KeyEvent&, rKeyEvent, bool)
{
vcl::KeyCode keycode = rKeyEvent.GetKeyCode();
@@ -1105,9 +971,9 @@ void SvxMenuEntriesListBox::KeyInput( const KeyEvent& rKeyEvent )
}
else
{
- // pass on to superclass
- SvTreeListBox::KeyInput( rKeyEvent );
+ return false; // pass on to default handler
}
+ return true;
}
/******************************************************************************
@@ -1117,88 +983,53 @@ void SvxMenuEntriesListBox::KeyInput( const KeyEvent& rKeyEvent )
* both tabpages to add, delete, move and rename items etc.
*
*****************************************************************************/
-SvxConfigPage::SvxConfigPage(vcl::Window *pParent, const SfxItemSet& rSet)
- : SfxTabPage(pParent, "MenuAssignPage", "cui/ui/menuassignpage.ui", &rSet)
+SvxConfigPage::SvxConfigPage(TabPageParent pParent, const SfxItemSet& rSet)
+ : SfxTabPage(pParent, "cui/ui/menuassignpage.ui", "MenuAssignPage", &rSet)
+ , m_aUpdateDataTimer("UpdateDataTimer")
, bInitialised(false)
, pCurrentSaveInData(nullptr)
- , m_pContentsListBox(nullptr)
-{
- get(m_pSearchEdit, "searchEntry");
- get(m_pCommandCategoryListBox, "commandcategorylist");
- get(m_pFunctions, "functions");
-
- get(m_pAddCommandButton, "add");
- get(m_pRemoveCommandButton, "remove");
-
- get(m_pTopLevelListBox, "toplevellist");
- get(m_pGearBtn, "gearbtn");
- get(m_pMoveUpButton, "up");
- get(m_pMoveDownButton, "down");
- get(m_pSaveInListBox, "savein");
- get(m_pInsertBtn, "insert");
- get(m_pModifyBtn, "modify");
- get(m_pResetBtn, "defaultsbtn");
- get(m_pDescriptionFieldLb, "descriptionlabel");
- get(m_pDescriptionField, "desc");
- m_pDescriptionField->set_height_request(m_pDescriptionField->GetTextHeight()*2.9);
- get(m_pEntries, "entries");
- Size aSize(LogicToPixel(Size(108, 115), MapMode(MapUnit::MapAppFont)));
- m_pEntries->set_height_request(aSize.Height());
- m_pEntries->set_width_request(aSize.Width());
- m_pFunctions->set_height_request(aSize.Height());
- //TODO: Add SvxMenuEntriesListBox into the glade catalog, and use it on the
- // .ui file to get rid of the extra VCLContainer, and all these manual
- // sizing and widget creation tricks.
- m_pFunctions->set_width_request(aSize.Width() * 1.45);
- m_pFunctions->SetNodeDefaultImages();
- m_pFunctions->SetStyle( m_pFunctions->GetStyle() | WB_HASBUTTONS | WB_HASBUTTONSATROOT |
- WB_HASLINES | WB_HASLINESATROOT | WB_CLIPCHILDREN | WB_HSCROLL );
-
- // Make the middle buttons bigger
- m_pAddCommandButton->set_height_request( m_pAddCommandButton->GetOptimalSize().Height() * 1.5 );
- m_pAddCommandButton->set_width_request( m_pAddCommandButton->GetOptimalSize().Width() * 1.5 );
- m_pRemoveCommandButton->set_height_request( m_pRemoveCommandButton->GetOptimalSize().Height() * 1.5 );
- m_pRemoveCommandButton->set_width_request( m_pRemoveCommandButton->GetOptimalSize().Width() * 1.5 );
-
- m_pDescriptionField->SetControlBackground( GetSettings().GetStyleSettings().GetDialogColor() );
- m_pDescriptionField->EnableCursor( false );
- m_pDescriptionField->SetStyle( m_pDescriptionField->GetStyle() | WB_TABSTOP ); // Include in the tab sequence
-
- m_pSearchEdit->SetUpdateDataHdl ( LINK( this, SvxConfigPage, SearchUpdateHdl ));
- m_pSearchEdit->EnableUpdateData();
-
- m_pFunctions->SetDoubleClickHdl( LINK( this, SvxConfigPage, FunctionDoubleClickHdl ) );
- m_pFunctions->SetSelectHdl(
- LINK( this, SvxConfigPage, SelectFunctionHdl ) );
- m_pGearBtn->SetDropDown(PushButtonDropdownStyle::NONE);
+ , m_xSearchEdit(m_xBuilder->weld_entry("searchEntry"))
+ , m_xCommandCategoryListBox(new CommandCategoryListBox(m_xBuilder->weld_combo_box("commandcategorylist")))
+ , m_xFunctions(new CuiConfigFunctionListBox(m_xBuilder->weld_tree_view("functions")))
+ , m_xDescriptionFieldLb(m_xBuilder->weld_label("descriptionlabel"))
+ , m_xDescriptionField(m_xBuilder->weld_text_view("desc"))
+ , m_xTopLevelListBox(m_xBuilder->weld_combo_box("toplevellist"))
+ , m_xGearBtn(m_xBuilder->weld_menu_button("gearbtn"))
+ , m_xMoveUpButton(m_xBuilder->weld_button("up"))
+ , m_xMoveDownButton(m_xBuilder->weld_button("down"))
+ , m_xSaveInListBox(m_xBuilder->weld_combo_box("savein"))
+ , m_xInsertBtn(m_xBuilder->weld_menu_button("insert"))
+ , m_xModifyBtn(m_xBuilder->weld_menu_button("modify"))
+ , m_xResetBtn(m_xBuilder->weld_button("defaultsbtn"))
+ , m_xAddCommandButton(m_xBuilder->weld_button("add"))
+ , m_xRemoveCommandButton(m_xBuilder->weld_button("remove"))
+{
+ m_xTopLevelListBox->connect_changed(LINK(this, SvxMenuConfigPage, SelectElementHdl));
+
+ weld::TreeView& rTreeView = m_xFunctions->get_widget();
+ Size aSize(rTreeView.get_approximate_digit_width() * 40, rTreeView.get_height_rows(8));
+ m_xFunctions->set_size_request(aSize.Width(), aSize.Height());
+ m_xDescriptionField->set_size_request(aSize.Width(), m_xDescriptionField->get_height_rows(3));
+
+ m_aUpdateDataTimer.SetInvokeHandler(LINK(this, SvxConfigPage, ImplUpdateDataHdl));
+ m_aUpdateDataTimer.SetDebugName( "SvxConfigPage UpdateDataTimer" );
+ m_aUpdateDataTimer.SetTimeout(EDIT_UPDATEDATA_TIMEOUT);
+
+ m_xSearchEdit->connect_changed(LINK(this, SvxConfigPage, SearchUpdateHdl));
+ m_xSearchEdit->connect_focus_out(LINK(this, SvxConfigPage, FocusOut_Impl));
+
+ rTreeView.connect_row_activated(LINK(this, SvxConfigPage, FunctionDoubleClickHdl));
+ rTreeView.connect_changed(LINK(this, SvxConfigPage, SelectFunctionHdl));
}
-SvxConfigPage::~SvxConfigPage()
+IMPL_LINK_NOARG(SvxConfigPage, SelectElementHdl, weld::ComboBox&, void)
{
- disposeOnce();
+ SelectElement();
}
-void SvxConfigPage::dispose()
+SvxConfigPage::~SvxConfigPage()
{
- m_pTopLevelListBox.clear();
- m_pGearBtn.clear();
- m_pSearchEdit.clear();
- m_pCommandCategoryListBox.clear();
- m_pEntries.clear();
- m_pFunctions.clear();
- m_pAddCommandButton.clear();
- m_pRemoveCommandButton.clear();
- m_pMoveUpButton.clear();
- m_pMoveDownButton.clear();
- m_pSaveInListBox.clear();
- m_pInsertBtn.clear();
- m_pModifyBtn.clear();
- m_pResetBtn.clear();
- m_pDescriptionFieldLb.clear();
- m_pDescriptionField.clear();
-
- m_pContentsListBox.disposeAndClear();
- SfxTabPage::dispose();
+ disposeOnce();
}
void SvxConfigPage::Reset( const SfxItemSet* )
@@ -1248,9 +1079,8 @@ void SvxConfigPage::Reset( const SfxItemSet* )
if ( pModuleData != nullptr )
{
- nPos = m_pSaveInListBox->InsertEntry(
- utl::ConfigManager::getProductName() + " " + aModuleName );
- m_pSaveInListBox->SetEntryData( nPos, pModuleData );
+ OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pModuleData)));
+ m_xSaveInListBox->append(sId, utl::ConfigManager::getProductName() + " " + aModuleName);
}
// try to retrieve the document based ui configuration manager
@@ -1280,8 +1110,8 @@ void SvxConfigPage::Reset( const SfxItemSet* )
if ( !pDocData->IsReadOnly() )
{
- nPos = m_pSaveInListBox->InsertEntry( aTitle );
- m_pSaveInListBox->SetEntryData( nPos, pDocData );
+ OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pDocData)));
+ m_xSaveInListBox->append(sId, aTitle);
}
}
@@ -1292,13 +1122,13 @@ void SvxConfigPage::Reset( const SfxItemSet* )
{
if ( pDocData && pDocData->HasURL( m_aURLToSelect ) )
{
- m_pSaveInListBox->SelectEntryPos( nPos );
+ m_xSaveInListBox->set_active(nPos);
pCurrentSaveInData = pDocData;
bURLToSelectFound = true;
}
else if ( pModuleData && pModuleData->HasURL( m_aURLToSelect ) )
{
- m_pSaveInListBox->SelectEntryPos( 0 );
+ m_xSaveInListBox->set_active(0);
pCurrentSaveInData = pModuleData;
bURLToSelectFound = true;
}
@@ -1310,12 +1140,12 @@ void SvxConfigPage::Reset( const SfxItemSet* )
// it the SaveIn listbox, otherwise select the module data
if ( pDocData != nullptr && pDocData->HasSettings() )
{
- m_pSaveInListBox->SelectEntryPos( nPos );
+ m_xSaveInListBox->set_active(nPos);
pCurrentSaveInData = pDocData;
}
else
{
- m_pSaveInListBox->SelectEntryPos( 0 );
+ m_xSaveInListBox->set_active(0);
pCurrentSaveInData = pModuleData;
}
}
@@ -1391,8 +1221,8 @@ void SvxConfigPage::Reset( const SfxItemSet* )
if ( pData && !pData->IsReadOnly() )
{
- nPos = m_pSaveInListBox->InsertEntry( aTitle2 );
- m_pSaveInListBox->SetEntryData( nPos, pData );
+ OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pData)));
+ m_xSaveInListBox->append(sId, aTitle2);
}
}
}
@@ -1400,7 +1230,7 @@ void SvxConfigPage::Reset( const SfxItemSet* )
}
}
- m_pSaveInListBox->SetSelectHdl(
+ m_xSaveInListBox->connect_changed(
LINK( this, SvxConfigPage, SelectSaveInLocation ) );
bInitialised = true;
@@ -1471,10 +1301,10 @@ OUString SvxConfigPage::GetScriptURL() const
{
OUString result;
- SvTreeListEntry *pEntry = m_pFunctions->FirstSelected();
- if ( pEntry )
+ int nEntry = m_xFunctions->get_selected_index();
+ if (nEntry != -1)
{
- SfxGroupInfo_Impl *pData = static_cast<SfxGroupInfo_Impl*>(pEntry->GetUserData());
+ SfxGroupInfo_Impl *pData = reinterpret_cast<SfxGroupInfo_Impl*>(m_xFunctions->get_id(nEntry).toInt64());
if ( ( pData->nKind == SfxCfgKind::FUNCTION_SLOT ) ||
( pData->nKind == SfxCfgKind::FUNCTION_SCRIPT ) ||
( pData->nKind == SfxCfgKind::GROUP_STYLES ) )
@@ -1488,45 +1318,43 @@ OUString SvxConfigPage::GetScriptURL() const
OUString SvxConfigPage::GetSelectedDisplayName()
{
- return m_pFunctions->GetEntryText( m_pFunctions->FirstSelected() );
+ return m_xFunctions->get_selected_text();
}
bool SvxConfigPage::FillItemSet( SfxItemSet* )
{
bool result = false;
- for ( sal_Int32 i = 0 ; i < m_pSaveInListBox->GetEntryCount(); ++i )
+ for (int i = 0, nCount = m_xSaveInListBox->get_count(); i < nCount; ++i)
{
SaveInData* pData =
- static_cast<SaveInData*>(m_pSaveInListBox->GetEntryData( i ));
+ reinterpret_cast<SaveInData*>(m_xSaveInListBox->get_id(i).toInt64());
result = pData->Apply();
}
return result;
}
-IMPL_LINK_NOARG( SvxConfigPage, SelectSaveInLocation, ListBox&, void )
+IMPL_LINK_NOARG(SvxConfigPage, SelectSaveInLocation, weld::ComboBox&, void)
{
- pCurrentSaveInData = static_cast<SaveInData*>(m_pSaveInListBox->GetEntryData(
- m_pSaveInListBox->GetSelectedEntryPos()));
-
+ pCurrentSaveInData = reinterpret_cast<SaveInData*>(m_xSaveInListBox->get_active_id().toInt64());
Init();
}
void SvxConfigPage::ReloadTopLevelListBox( SvxConfigEntry const * pToSelect )
{
- sal_Int32 nSelectionPos = m_pTopLevelListBox->GetSelectedEntryPos();
- m_pTopLevelListBox->Clear();
+ int nSelectionPos = m_xTopLevelListBox->get_active();
+ m_xTopLevelListBox->clear();
if ( GetSaveInData() && GetSaveInData()->GetEntries() )
{
for (auto const& entryData : *GetSaveInData()->GetEntries())
{
- const sal_Int32 nPos = m_pTopLevelListBox->InsertEntry( SvxConfigPageHelper::stripHotKey(entryData->GetName()) );
- m_pTopLevelListBox->SetEntryData( nPos, entryData );
+ OUString sId(OUString::number(reinterpret_cast<sal_Int64>(entryData)));
+ m_xTopLevelListBox->append(sId, SvxConfigPageHelper::stripHotKey(entryData->GetName()));
- if ( entryData == pToSelect )
- nSelectionPos = nPos;
+ if (entryData == pToSelect)
+ nSelectionPos = m_xTopLevelListBox->get_count() - 1;
AddSubMenusToUI( SvxConfigPageHelper::stripHotKey( entryData->GetName() ), entryData );
}
@@ -1540,11 +1368,11 @@ void SvxConfigPage::ReloadTopLevelListBox( SvxConfigEntry const * pToSelect )
}
#endif
- nSelectionPos = nSelectionPos < m_pTopLevelListBox->GetEntryCount() ?
- nSelectionPos : m_pTopLevelListBox->GetEntryCount() - 1;
+ nSelectionPos = (nSelectionPos != -1 && nSelectionPos < m_xTopLevelListBox->get_count()) ?
+ nSelectionPos : m_xTopLevelListBox->get_count() - 1;
- m_pTopLevelListBox->SelectEntryPos( nSelectionPos );
- m_pTopLevelListBox->GetSelectHdl().Call( *m_pTopLevelListBox );
+ m_xTopLevelListBox->set_active(nSelectionPos);
+ SelectElement();
}
void SvxConfigPage::AddSubMenusToUI(
@@ -1556,8 +1384,8 @@ void SvxConfigPage::AddSubMenusToUI(
{
OUString subMenuTitle = rBaseTitle + aMenuSeparatorStr + SvxConfigPageHelper::stripHotKey(entryData->GetName());
- const sal_Int32 nPos = m_pTopLevelListBox->InsertEntry( subMenuTitle );
- m_pTopLevelListBox->SetEntryData( nPos, entryData );
+ OUString sId(OUString::number(reinterpret_cast<sal_Int64>(entryData)));
+ m_xTopLevelListBox->append(sId, subMenuTitle);
AddSubMenusToUI( subMenuTitle, entryData );
}
@@ -1588,15 +1416,14 @@ SvxEntries* SvxConfigPage::FindParentForChild(
return nullptr;
}
-SvTreeListEntry* SvxConfigPage::AddFunction(
- SvTreeListEntry* pTarget, bool bFront, bool bAllowDuplicates )
+int SvxConfigPage::AddFunction(int nTarget, bool bFront, bool bAllowDuplicates)
{
OUString aURL = GetScriptURL();
SvxConfigEntry* pParent = GetTopLevelSelection();
if ( aURL.isEmpty() || pParent == nullptr )
{
- return nullptr;
+ return -1;
}
OUString aDisplayName;
@@ -1623,49 +1450,53 @@ SvTreeListEntry* SvxConfigPage::AddFunction(
{
if ( entry->GetCommand() == pNewEntryData->GetCommand() )
{
- std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(),
+ std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetDialogFrameWeld(),
VclMessageType::Info, VclButtonsType::Ok, CuiResId(RID_SVXSTR_MNUCFG_ALREADY_INCLUDED)));
- (void)xBox->run();
+ xBox->run();
delete pNewEntryData;
- return nullptr;
+ return -1;
}
}
}
- return InsertEntry( pNewEntryData, pTarget, bFront );
+ return InsertEntry(pNewEntryData, nTarget, bFront);
}
-SvTreeListEntry* SvxConfigPage::InsertEntry(
+int SvxConfigPage::InsertEntry(
SvxConfigEntry* pNewEntryData,
- SvTreeListEntry* pTarget,
- bool bFront )
+ int nTarget,
+ bool bFront)
{
SvxConfigEntry* pTopLevelSelection = GetTopLevelSelection();
if (pTopLevelSelection == nullptr)
- return nullptr;
+ return -1;
// Grab the entries list for the currently selected menu
SvxEntries* pEntries = pTopLevelSelection->GetEntries();
- SvTreeListEntry* pNewEntry = nullptr;
- SvTreeListEntry* pCurEntry =
- pTarget != nullptr ? pTarget : m_pContentsListBox->GetCurEntry();
+ int nNewEntry = -1;
+ int nCurEntry =
+ nTarget != -1 ? nTarget : m_xContentsListBox->get_selected_index();
+
+ OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pNewEntryData)));
- if ( bFront )
+ if (bFront)
{
pEntries->insert( pEntries->begin(), pNewEntryData );
- pNewEntry = InsertEntryIntoUI( pNewEntryData, 0 );
+ m_xContentsListBox->insert(0, sId);
+ nNewEntry = 0;
}
- else if ( pCurEntry == nullptr || pCurEntry == m_pContentsListBox->Last() )
+ else if (nCurEntry == -1 || nCurEntry == m_xContentsListBox->n_children() - 1)
{
pEntries->push_back( pNewEntryData );
- pNewEntry = InsertEntryIntoUI( pNewEntryData );
+ m_xContentsListBox->insert(-1, sId);
+ nNewEntry = m_xContentsListBox->n_children() - 1;
}
else
{
SvxConfigEntry* pEntryData =
- static_cast<SvxConfigEntry*>(pCurEntry->GetUserData());
+ reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nCurEntry).toInt64());
SvxEntries::iterator iter = pEntries->begin();
SvxEntries::const_iterator end = pEntries->end();
@@ -1685,82 +1516,66 @@ SvTreeListEntry* SvxConfigPage::InsertEntry(
if ( iter != end )
{
pEntries->insert( iter, pNewEntryData );
- pNewEntry = InsertEntryIntoUI( pNewEntryData, nPos );
+ m_xContentsListBox->insert(nPos, sId);
+ nNewEntry = nPos;
}
}
- if ( pNewEntry != nullptr )
+ if (nNewEntry != -1)
{
- m_pContentsListBox->Select( pNewEntry );
- m_pContentsListBox->MakeVisible( pNewEntry );
+ m_xContentsListBox->select(nNewEntry);
+ m_xContentsListBox->scroll_to_row(nNewEntry);
GetSaveInData()->SetModified();
GetTopLevelSelection()->SetModified();
}
- return pNewEntry;
+ return nNewEntry;
}
-SvTreeListEntry* SvxConfigPage::InsertEntryIntoUI(
- SvxConfigEntry* pNewEntryData, sal_uLong nPos )
+void SvxConfigPage::InsertEntryIntoUI(SvxConfigEntry* pNewEntryData, int nPos, int nStartCol)
{
- SvTreeListEntry* pNewEntry = nullptr;
+ OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pNewEntryData)));
+
+ m_xContentsListBox->set_id(nPos, sId);
if (pNewEntryData->IsSeparator())
{
- pNewEntry = m_pContentsListBox->InsertEntry(
- OUString("----------------------------------"),
- nullptr, false, nPos, pNewEntryData);
+ m_xContentsListBox->set_text(nPos, "----------------------------------", nStartCol + 1);
}
else
{
+ auto xImage = GetSaveInData()->GetImage(pNewEntryData->GetCommand());
+ if (xImage.is())
+ m_xContentsListBox->set_image(nPos, xImage, nStartCol);
OUString aName = SvxConfigPageHelper::stripHotKey( pNewEntryData->GetName() );
+ m_xContentsListBox->set_text(nPos, aName, nStartCol + 1);
+ }
- Image aImage = GetSaveInData()->GetImage(
- pNewEntryData->GetCommand());
-
- if ( !!aImage )
- {
- pNewEntry = m_pContentsListBox->InsertEntry(
- aName, aImage, aImage, nullptr, false, nPos, pNewEntryData );
- }
+ if (nStartCol == 0) // menus
+ {
+ if (pNewEntryData->IsPopup() || pNewEntryData->GetStyle() & css::ui::ItemStyle::DROP_DOWN)
+ m_xContentsListBox->set_dropdown(nPos, nStartCol + 2);
else
- {
- pNewEntry = m_pContentsListBox->InsertEntry(
- aName, nullptr, false, nPos, pNewEntryData );
- }
-
- if ( pNewEntryData->IsPopup() ||
- pNewEntryData->GetStyle() & css::ui::ItemStyle::DROP_DOWN )
- {
- // add new popup painter, it gets destructed by the entry
- pNewEntry->ReplaceItem( std::make_unique<PopupPainter>(aName), pNewEntry->ItemCount() - 1 );
- }
+ m_xContentsListBox->set_image(nPos, nullptr, nStartCol + 2);
}
-
- return pNewEntry;
}
-IMPL_LINK( SvxConfigPage, MoveHdl, Button *, pButton, void )
+IMPL_LINK(SvxConfigPage, MoveHdl, weld::Button&, rButton, void)
{
- MoveEntry(pButton == m_pMoveUpButton);
+ MoveEntry(&rButton == m_xMoveUpButton.get());
}
-IMPL_LINK_NOARG( SvxConfigPage, FunctionDoubleClickHdl, SvTreeListBox *, bool )
+IMPL_LINK_NOARG(SvxConfigPage, FunctionDoubleClickHdl, weld::TreeView&, void)
{
- if ( m_pAddCommandButton->IsEnabled() )
- {
- m_pAddCommandButton->Click();
- return false;
- }
- else
- return true;
+ if (m_xAddCommandButton->get_sensitive())
+ m_xAddCommandButton->clicked();
}
-IMPL_LINK_NOARG( SvxConfigPage, SelectFunctionHdl, SvTreeListBox *, void )
+IMPL_LINK_NOARG(SvxConfigPage, SelectFunctionHdl, weld::TreeView&, void)
{
// Store the tooltip of the description field at first run
- static const OUString sDescTooltip = m_pDescriptionField->GetQuickHelpText();
+ static const OUString sDescTooltip = m_xDescriptionField->get_tooltip_text();
// GetScriptURL() returns a non-empty string if a
// valid command is selected on the left box
@@ -1769,52 +1584,67 @@ IMPL_LINK_NOARG( SvxConfigPage, SelectFunctionHdl, SvTreeListBox *, void )
// Enable/disable Add and Remove buttons depending on current selection
if (bIsValidCommand)
{
- m_pAddCommandButton->Enable();
- m_pRemoveCommandButton->Enable();
+ m_xAddCommandButton->set_sensitive(true);
+ m_xRemoveCommandButton->set_sensitive(true);
- m_pDescriptionField->SetText( m_pFunctions->GetHelpText( false ) );
+ m_xDescriptionField->set_text(m_xFunctions->GetHelpText(false));
}
else
{
- m_pAddCommandButton->Disable();
- m_pRemoveCommandButton->Disable();
+ m_xAddCommandButton->set_sensitive(false);
+ m_xRemoveCommandButton->set_sensitive(false);
- m_pDescriptionField->SetText("");
+ m_xDescriptionField->set_text("");
}
// Disable the description field and its label if the local help is not installed
// And inform the user via tooltips
if ( !SfxHelp::IsHelpInstalled() )
{
- m_pDescriptionField->Disable();
- m_pDescriptionFieldLb->Disable();
- m_pDescriptionField->SetQuickHelpText( sDescTooltip );
- m_pDescriptionFieldLb->SetQuickHelpText( sDescTooltip );
+ m_xDescriptionField->set_sensitive(false);
+ m_xDescriptionFieldLb->set_sensitive(false);
+ m_xDescriptionField->set_tooltip_text( sDescTooltip );
+ m_xDescriptionFieldLb->set_tooltip_text( sDescTooltip );
}
else
{
- m_pDescriptionField->Enable();
- m_pDescriptionFieldLb->Enable();
- m_pDescriptionField->SetQuickHelpText("");
- m_pDescriptionFieldLb->SetQuickHelpText("");
+ m_xDescriptionField->set_sensitive(true);
+ m_xDescriptionFieldLb->set_sensitive(true);
+ m_xDescriptionField->set_tooltip_text("");
+ m_xDescriptionFieldLb->set_tooltip_text("");
}
}
-IMPL_LINK_NOARG(SvxConfigPage, SearchUpdateHdl, Edit&, void)
+IMPL_LINK_NOARG(SvxConfigPage, ImplUpdateDataHdl, Timer*, void)
+{
+ OUString aSearchTerm(m_xSearchEdit->get_text());
+ m_xCommandCategoryListBox->categorySelected(m_xFunctions.get(), aSearchTerm, GetSaveInData());
+}
+
+IMPL_LINK_NOARG(SvxConfigPage, SearchUpdateHdl, weld::Entry&, void)
{
- OUString aSearchTerm( m_pSearchEdit->GetText() );
+ m_aUpdateDataTimer.Start();
+}
- m_pCommandCategoryListBox->categorySelected( m_pFunctions, aSearchTerm, GetSaveInData() );
+IMPL_LINK_NOARG(SvxConfigPage, FocusOut_Impl, weld::Widget&, void)
+{
+ if (m_aUpdateDataTimer.IsActive())
+ {
+ m_aUpdateDataTimer.Stop();
+ m_aUpdateDataTimer.Invoke();
+ }
}
-void SvxConfigPage::MoveEntry( bool bMoveUp )
+void SvxConfigPage::MoveEntry(bool bMoveUp)
{
- SvTreeListEntry *pSourceEntry = m_pContentsListBox->FirstSelected();
- SvTreeListEntry *pTargetEntry = nullptr;
- SvTreeListEntry *pToSelect = nullptr;
+ weld::TreeView& rTreeView = m_xContentsListBox->get_widget();
- if ( !pSourceEntry )
+ int nSourceEntry = rTreeView.get_selected_index();
+ int nTargetEntry = -1;
+ int nToSelect = -1;
+
+ if (nSourceEntry == -1)
{
return;
}
@@ -1822,31 +1652,30 @@ void SvxConfigPage::MoveEntry( bool bMoveUp )
if ( bMoveUp )
{
// Move Up is just a Move Down with the source and target reversed
- pTargetEntry = pSourceEntry;
- pSourceEntry = pTargetEntry->PrevSibling();
- pToSelect = pTargetEntry;
+ nTargetEntry = nSourceEntry;
+ nSourceEntry = nTargetEntry - 1;
+ nToSelect = nSourceEntry;
}
else
{
- pTargetEntry = pSourceEntry->NextSibling();
- pToSelect = pSourceEntry;
+ nTargetEntry = nSourceEntry + 1;
+ nToSelect = nTargetEntry;
}
- if ( MoveEntryData( pSourceEntry, pTargetEntry ) )
+ if (MoveEntryData(nSourceEntry, nTargetEntry))
{
- m_pContentsListBox->GetModel()->Move( pSourceEntry, pTargetEntry );
- m_pContentsListBox->Select( pToSelect );
- m_pContentsListBox->MakeVisible( pToSelect );
+ rTreeView.swap(nSourceEntry, nTargetEntry);
+ rTreeView.select(nToSelect);
+ rTreeView.scroll_to_row(nToSelect);
UpdateButtonStates();
}
}
-bool SvxConfigPage::MoveEntryData(
- SvTreeListEntry const * pSourceEntry, SvTreeListEntry const * pTargetEntry )
+bool SvxConfigPage::MoveEntryData(int nSourceEntry, int nTargetEntry)
{
//#i53677#
- if (nullptr == pSourceEntry || nullptr == pTargetEntry)
+ if (nSourceEntry == -1 || nTargetEntry == -1)
{
return false;
}
@@ -1855,10 +1684,10 @@ bool SvxConfigPage::MoveEntryData(
SvxEntries* pEntries = GetTopLevelSelection()->GetEntries();
SvxConfigEntry* pSourceData =
- static_cast<SvxConfigEntry*>(pSourceEntry->GetUserData());
+ reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nSourceEntry).toInt64());
SvxConfigEntry* pTargetData =
- static_cast<SvxConfigEntry*>(pTargetEntry->GetUserData());
+ reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nTargetEntry).toInt64());
if ( pSourceData != nullptr && pTargetData != nullptr )
{
diff --git a/cui/source/customize/cfgutil.cxx b/cui/source/customize/cfgutil.cxx
index 408612685283..f8de79671425 100644
--- a/cui/source/customize/cfgutil.cxx
+++ b/cui/source/customize/cfgutil.cxx
@@ -247,86 +247,6 @@ std::vector< SfxStyleInfo_Impl > SfxStylesInfo_Impl::getStyles(const OUString& s
return lStyles;
}
-SfxConfigFunctionListBox::SfxConfigFunctionListBox(vcl::Window* pParent, WinBits nStyle)
- : SvTreeListBox( pParent, nStyle )
-{
- SetStyle( GetStyle() | WB_CLIPCHILDREN | WB_HSCROLL | WB_SORT );
- GetModel()->SetSortMode( SortAscending );
- SetQuickSearch( true );
-}
-
-VCL_BUILDER_FACTORY_CONSTRUCTOR(SfxConfigFunctionListBox, WB_TABSTOP)
-
-SfxConfigFunctionListBox::~SfxConfigFunctionListBox()
-{
- disposeOnce();
-}
-
-void SfxConfigFunctionListBox::dispose()
-{
- ClearAll();
- SvTreeListBox::dispose();
-}
-
-void SfxConfigFunctionListBox::MouseMove( const MouseEvent& )
-{
-}
-
-void SfxConfigFunctionListBox::ClearAll()
-/* Description
- Deletes all entries in the FunctionListBox, all UserData and all
- possibly existing MacroInfo.
-*/
-{
- sal_uInt16 nCount = aArr.size();
- for ( sal_uInt16 i=0; i<nCount; ++i )
- {
- SfxGroupInfo_Impl *pData = aArr[i].get();
-
- if ( pData->nKind == SfxCfgKind::FUNCTION_SCRIPT )
- {
- OUString* pScriptURI = static_cast<OUString*>(pData->pObject);
- delete pScriptURI;
- }
-
- if ( pData->nKind == SfxCfgKind::GROUP_SCRIPTCONTAINER )
- {
- XInterface* xi = static_cast<XInterface *>(pData->pObject);
- if (xi != nullptr)
- {
- xi->release();
- }
- }
- }
-
- aArr.clear();
- Clear();
-}
-
-OUString SfxConfigFunctionListBox::GetHelpText( bool bConsiderParent )
-{
- SvTreeListEntry *pEntry = FirstSelected();
- if ( pEntry )
- {
- SfxGroupInfo_Impl *pData = static_cast<SfxGroupInfo_Impl*>(pEntry->GetUserData());
- if ( pData )
- {
- if ( pData->nKind == SfxCfgKind::FUNCTION_SLOT )
- {
- if (bConsiderParent)
- return Application::GetHelp()->GetHelpText( pData->sCommand, this );
- else
- return Application::GetHelp()->GetHelpText( pData->sCommand, static_cast<weld::Widget*>(nullptr) );
- }
- else if ( pData->nKind == SfxCfgKind::FUNCTION_SCRIPT )
- {
- return pData->sHelpText;
- }
- }
- }
- return OUString();
-}
-
OUString CuiConfigFunctionListBox::GetHelpText( bool bConsiderParent )
{
int nSelected = m_xTreeView->get_selected_index();
@@ -377,6 +297,7 @@ OUString CuiConfigFunctionListBox::GetCurLabel()
CuiConfigFunctionListBox::CuiConfigFunctionListBox(std::unique_ptr<weld::TreeView> xTreeView)
: m_xTreeView(std::move(xTreeView))
+ , m_xScratchIter(m_xTreeView->make_iterator())
{
m_xTreeView->make_sorted();
m_xTreeView->set_size_request(m_xTreeView->get_approximate_digit_width() * 35, m_xTreeView->get_height_rows(9));
@@ -599,7 +520,7 @@ void CuiConfigGroupListBox::InitModule()
}
void CuiConfigGroupListBox::FillScriptList(const css::uno::Reference< css::script::browse::XBrowseNode >& xRootNode,
- weld::TreeIter* pParentEntry, bool bCheapChildrenOnDemand)
+ const weld::TreeIter* pParentEntry, bool bCheapChildrenOnDemand)
{
try {
if ( xRootNode->hasChildNodes() )
@@ -1046,7 +967,7 @@ void CuiConfigGroupListBox::GroupSelected()
/* Description
A basic or a library is opened.
*/
-IMPL_LINK(CuiConfigGroupListBox, ExpandingHdl, weld::TreeIter&, rIter, bool)
+IMPL_LINK(CuiConfigGroupListBox, ExpandingHdl, const weld::TreeIter&, rIter, bool)
{
SfxGroupInfo_Impl *pInfo = reinterpret_cast<SfxGroupInfo_Impl*>(m_xTreeView->get_id(rIter).toInt64());
switch ( pInfo->nKind )