summaryrefslogtreecommitdiff
path: root/cui/source/customize/cfg.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'cui/source/customize/cfg.cxx')
-rw-r--r--cui/source/customize/cfg.cxx294
1 files changed, 147 insertions, 147 deletions
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
index 25f973016043..ff5702121755 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -24,16 +24,19 @@
#include <stdlib.h>
#include <typeinfo>
+#include <utility>
#include <vcl/stdtext.hxx>
#include <vcl/commandinfoprovider.hxx>
#include <vcl/event.hxx>
#include <vcl/graph.hxx>
+#include <vcl/graphicfilter.hxx>
#include <vcl/svapp.hxx>
#include <vcl/toolbox.hxx>
#include <vcl/weld.hxx>
#include <vcl/decoview.hxx>
#include <vcl/virdev.hxx>
+#include <sfx2/minfitem.hxx>
#include <sfx2/sfxhelp.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/filedlghelper.hxx>
@@ -41,7 +44,7 @@
#include <svl/stritem.hxx>
#include <rtl/ustrbuf.hxx>
#include <tools/debug.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <algorithm>
@@ -87,8 +90,9 @@
#include <com/sun/star/util/thePathSettings.hpp>
#include <comphelper/documentinfo.hxx>
#include <comphelper/propertysequence.hxx>
+#include <comphelper/propertyvalue.hxx>
#include <comphelper/processfactory.hxx>
-#include <officecfg/Office/Common.hxx>
+#include <config_features.h>
namespace uno = com::sun::star::uno;
namespace frame = com::sun::star::frame;
@@ -213,18 +217,29 @@ SvxConfigDialog::SvxConfigDialog(weld::Window * pParent, const SfxItemSet* pInSe
AddTabPage("keyboard", CreateKeyboardConfigPage, nullptr);
AddTabPage("events", CreateSvxEventConfigPage, nullptr);
- const SfxPoolItem* pItem =
- pInSet->GetItem( pInSet->GetPool()->GetWhich( SID_CONFIG ) );
-
- if ( pItem )
+ if (const SfxPoolItem* pItem = pInSet->GetItem(SID_CONFIG))
{
OUString text = static_cast<const SfxStringItem*>(pItem)->GetValue();
-
if (text.startsWith( ITEM_TOOLBAR_URL ) )
- {
SetCurPageId("toolbars");
- }
+ else if (text.startsWith( ITEM_EVENT_URL) )
+ SetCurPageId("events");
}
+#if HAVE_FEATURE_SCRIPTING
+ else if (pInSet->GetItemIfSet(SID_MACROINFO))
+ {
+ // for the "assign" button in the Basic Macros chooser automatically switch
+ // to the keyboard tab in which this macro will be pre-selected for assigning
+ // to a keystroke
+ SetCurPageId("keyboard");
+ }
+#endif
+}
+
+void SvxConfigDialog::ActivatePage(const OUString& rPage)
+{
+ SfxTabDialogController::ActivatePage(rPage);
+ GetResetButton()->set_visible(rPage != "keyboard");
}
void SvxConfigDialog::SetFrame(const css::uno::Reference<css::frame::XFrame>& xFrame)
@@ -242,7 +257,7 @@ void SvxConfigDialog::SetFrame(const css::uno::Reference<css::frame::XFrame>& xF
RemoveTabPage("keyboard");
}
-void SvxConfigDialog::PageCreated(const OString &rId, SfxTabPage& rPage)
+void SvxConfigDialog::PageCreated(const OUString &rId, SfxTabPage& rPage)
{
if (rId == "menus" || rId == "keyboard" || rId == "notebookbar"
|| rId == "toolbars" || rId == "contextmenus")
@@ -266,21 +281,19 @@ void SvxConfigDialog::PageCreated(const OString &rId, SfxTabPage& rPage)
uno::Reference< css::ui::XImageManager>* SaveInData::xDefaultImgMgr = nullptr;
SaveInData::SaveInData(
- const uno::Reference< css::ui::XUIConfigurationManager >& xCfgMgr,
- const uno::Reference< css::ui::XUIConfigurationManager >& xParentCfgMgr,
+ uno::Reference< css::ui::XUIConfigurationManager > xCfgMgr,
+ uno::Reference< css::ui::XUIConfigurationManager > xParentCfgMgr,
const OUString& aModuleId,
bool isDocConfig )
:
bModified( false ),
bDocConfig( isDocConfig ),
bReadOnly( false ),
- m_xCfgMgr( xCfgMgr ),
- m_xParentCfgMgr( xParentCfgMgr )
+ m_xCfgMgr(std::move( xCfgMgr )),
+ m_xParentCfgMgr(std::move( xParentCfgMgr )),
+ m_aSeparatorSeq{ comphelper::makePropertyValue(ITEM_DESCRIPTOR_TYPE,
+ css::ui::ItemType::SEPARATOR_LINE) }
{
- m_aSeparatorSeq.realloc( 1 );
- m_aSeparatorSeq[0].Name = ITEM_DESCRIPTOR_TYPE;
- m_aSeparatorSeq[0].Value <<= css::ui::ItemType::SEPARATOR_LINE;
-
if ( bDocConfig )
{
uno::Reference< css::ui::XUIConfigurationPersistence >
@@ -479,7 +492,7 @@ void SaveInData::LoadSubMenus( const uno::Reference< container::XIndexAccess >&
if ( a >>= aPropSeq )
{
OUString aMenuLabel;
- for ( const beans::PropertyValue& prop : std::as_const(aPropSeq) )
+ for (const beans::PropertyValue& prop : aPropSeq)
{
if ( bContextMenu )
{
@@ -603,8 +616,9 @@ void MenuSaveInData::Apply(
sal_Int32 nIndex = aPropValueSeq.getLength();
aPropValueSeq.realloc( nIndex + 1 );
- aPropValueSeq[nIndex].Name = m_aDescriptorContainer;
- aPropValueSeq[nIndex].Value <<= xSubMenuBar;
+ auto pPropValueSeq = aPropValueSeq.getArray();
+ pPropValueSeq[nIndex].Name = m_aDescriptorContainer;
+ pPropValueSeq[nIndex].Value <<= xSubMenuBar;
rMenuBar->insertByIndex(
rMenuBar->getCount(), uno::Any( aPropValueSeq ));
ApplyMenu( xSubMenuBar, rFactory, entryData );
@@ -631,8 +645,9 @@ void SaveInData::ApplyMenu(
sal_Int32 nIndex = aPropValueSeq.getLength();
aPropValueSeq.realloc( nIndex + 1 );
- aPropValueSeq[nIndex].Name = ITEM_DESCRIPTOR_CONTAINER;
- aPropValueSeq[nIndex].Value <<= xSubMenuBar;
+ auto pPropValueSeq = aPropValueSeq.getArray();
+ pPropValueSeq[nIndex].Name = ITEM_DESCRIPTOR_CONTAINER;
+ pPropValueSeq[nIndex].Value <<= xSubMenuBar;
rMenuBar->insertByIndex(
rMenuBar->getCount(), uno::Any( aPropValueSeq ));
@@ -708,7 +723,7 @@ OUString ContextMenuSaveInData::GetUIName( const OUString& rResourceURL )
catch ( const css::uno::Exception& )
{}
- for ( const auto& aProp : std::as_const(aProps) )
+ for (const auto& aProp : aProps)
{
if ( aProp.Name == ITEM_DESCRIPTOR_UINAME )
{
@@ -736,7 +751,7 @@ SvxEntries* ContextMenuSaveInData::GetEntries()
catch ( const css::lang::IllegalArgumentException& )
{}
- for ( const auto& aElement : std::as_const(aElementsInfo) )
+ for (const auto& aElement : aElementsInfo)
{
OUString aUrl;
for ( const auto& aElementProp : aElement )
@@ -784,7 +799,7 @@ SvxEntries* ContextMenuSaveInData::GetEntries()
catch ( const css::lang::IllegalArgumentException& )
{}
- for ( const auto& aElement : std::as_const(aParentElementsInfo) )
+ for (const auto& aElement : aParentElementsInfo)
{
OUString aUrl;
for ( const auto& aElementProp : aElement )
@@ -930,6 +945,7 @@ SvxMenuEntriesListBox::SvxMenuEntriesListBox(std::unique_ptr<weld::TreeView> xCo
m_xControl->enable_toggle_buttons(weld::ColumnToggleType::Check);
CreateDropDown();
m_xControl->connect_key_press(LINK(this, SvxMenuEntriesListBox, KeyInputHdl));
+ m_xControl->connect_query_tooltip(LINK(this, SvxMenuEntriesListBox, QueryTooltip));
}
SvxMenuEntriesListBox::~SvxMenuEntriesListBox()
@@ -961,6 +977,21 @@ IMPL_LINK(SvxMenuEntriesListBox, KeyInputHdl, const KeyEvent&, rKeyEvent, bool)
return true;
}
+IMPL_LINK(SvxMenuEntriesListBox, QueryTooltip, const weld::TreeIter&, rIter, OUString)
+{
+ SvxConfigEntry *pEntry = weld::fromId<SvxConfigEntry*>(m_xControl->get_id(rIter));
+ if (!pEntry || pEntry->GetCommand().isEmpty())
+ return OUString();
+ const OUString sCommand(pEntry->GetCommand());
+ OUString aModuleName(vcl::CommandInfoProvider::GetModuleIdentifier(m_pPage->GetFrame()));
+ auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(sCommand, aModuleName);
+ OUString sTooltipLabel = vcl::CommandInfoProvider::GetTooltipForCommand(sCommand, aProperties,
+ m_pPage->GetFrame());
+ return CuiResId(RID_CUISTR_COMMANDLABEL) + ": " + pEntry->GetName().replaceFirst("~", "") + "\n" +
+ CuiResId(RID_CUISTR_COMMANDNAME) + ": " + sCommand + "\n" +
+ CuiResId(RID_CUISTR_COMMANDTIP) + ": " + sTooltipLabel.replaceFirst("~", "");
+}
+
/******************************************************************************
*
* SvxConfigPage is the abstract base class on which the Menu and Toolbar
@@ -970,7 +1001,7 @@ IMPL_LINK(SvxMenuEntriesListBox, KeyInputHdl, const KeyEvent&, rKeyEvent, bool)
*****************************************************************************/
SvxConfigPage::SvxConfigPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
: SfxTabPage(pPage, pController, "cui/ui/menuassignpage.ui", "MenuAssignPage", &rSet)
- , m_aUpdateDataTimer("UpdateDataTimer")
+ , m_aUpdateDataTimer( "SvxConfigPage UpdateDataTimer" )
, bInitialised(false)
, pCurrentSaveInData(nullptr)
, m_xCommandCategoryListBox(new CommandCategoryListBox(m_xBuilder->weld_combo_box("commandcategorylist")))
@@ -986,9 +1017,11 @@ SvxConfigPage::SvxConfigPage(weld::Container* pPage, weld::DialogController* pCo
, m_xMoveUpButton(m_xBuilder->weld_button("up"))
, m_xMoveDownButton(m_xBuilder->weld_button("down"))
, m_xSaveInListBox(m_xBuilder->weld_combo_box("savein"))
+ , m_xCustomizeBox(m_xBuilder->weld_widget("customizebox"))
, m_xInsertBtn(m_xBuilder->weld_menu_button("insert"))
, m_xModifyBtn(m_xBuilder->weld_menu_button("modify"))
, m_xResetBtn(m_xBuilder->weld_button("defaultsbtn"))
+ , m_xCommandButtons(m_xBuilder->weld_widget("arrowgrid"))
, m_xAddCommandButton(m_xBuilder->weld_button("add"))
, m_xRemoveCommandButton(m_xBuilder->weld_button("remove"))
{
@@ -1002,7 +1035,6 @@ SvxConfigPage::SvxConfigPage(weld::Container* pPage, weld::DialogController* pCo
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));
@@ -1022,7 +1054,7 @@ SvxConfigPage::~SvxConfigPage()
int cnt = m_xSaveInListBox->get_count();
for(int i=0; i < cnt; ++i)
{
- SaveInData *pData = reinterpret_cast<SaveInData*>(m_xSaveInListBox->get_id(i).toInt64());
+ SaveInData *pData = weld::fromId<SaveInData*>(m_xSaveInListBox->get_id(i));
delete pData;
}
}
@@ -1074,7 +1106,7 @@ void SvxConfigPage::Reset( const SfxItemSet* )
if ( pModuleData != nullptr )
{
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pModuleData)));
+ OUString sId(weld::toId(pModuleData));
m_xSaveInListBox->append(sId, utl::ConfigManager::getProductName() + " " + aModuleName);
}
@@ -1105,7 +1137,7 @@ void SvxConfigPage::Reset( const SfxItemSet* )
if ( !pDocData->IsReadOnly() )
{
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pDocData)));
+ OUString sId(weld::toId(pDocData));
m_xSaveInListBox->append(sId, aTitle);
}
}
@@ -1171,7 +1203,7 @@ void SvxConfigPage::Reset( const SfxItemSet* )
DBG_UNHANDLED_EXCEPTION("cui.customize");
}
- for ( uno::Reference < frame::XFrame > const & xf : std::as_const(aFrameList) )
+ for (uno::Reference<frame::XFrame> const& xf : aFrameList)
{
if ( xf.is() && xf != m_xFrame )
{
@@ -1214,7 +1246,7 @@ void SvxConfigPage::Reset( const SfxItemSet* )
if ( pData && !pData->IsReadOnly() )
{
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pData)));
+ OUString sId(weld::toId(pData));
m_xSaveInListBox->append(sId, aTitle2);
}
}
@@ -1261,8 +1293,11 @@ OUString SvxConfigPage::GetFrameWithDefaultAndIdentify( uno::Reference< frame::X
_inout_rxFrame = xDesktop->getCurrentFrame();
}
- if ( !_inout_rxFrame.is() && SfxViewFrame::Current() )
- _inout_rxFrame = SfxViewFrame::Current()->GetFrame().GetFrameInterface();
+ if ( !_inout_rxFrame.is())
+ {
+ if (SfxViewFrame* pViewFrame = SfxViewFrame::Current())
+ _inout_rxFrame = pViewFrame->GetFrame().GetFrameInterface();
+ }
if ( !_inout_rxFrame.is() )
{
@@ -1284,7 +1319,7 @@ OUString SvxConfigPage::GetScriptURL() const
{
OUString result;
- SfxGroupInfo_Impl *pData = reinterpret_cast<SfxGroupInfo_Impl*>(m_xFunctions->get_selected_id().toInt64());
+ SfxGroupInfo_Impl *pData = weld::fromId<SfxGroupInfo_Impl*>(m_xFunctions->get_selected_id());
if (pData)
{
if ( ( pData->nKind == SfxCfgKind::FUNCTION_SLOT ) ||
@@ -1312,7 +1347,7 @@ bool SvxConfigPage::FillItemSet( SfxItemSet* )
OUString sId = m_xSaveInListBox->get_id(i);
if (sId != notebookbarTabScope)
{
- SaveInData* pData = reinterpret_cast<SaveInData*>(sId.toInt64());
+ SaveInData* pData = weld::fromId<SaveInData*>(sId);
result = pData->Apply();
}
}
@@ -1323,7 +1358,7 @@ IMPL_LINK_NOARG(SvxConfigPage, SelectSaveInLocation, weld::ComboBox&, void)
{
OUString sId = m_xSaveInListBox->get_active_id();
if (sId != notebookbarTabScope)
- pCurrentSaveInData = reinterpret_cast<SaveInData*>(sId.toInt64());
+ pCurrentSaveInData = weld::fromId<SaveInData*>(sId);
Init();
}
@@ -1336,7 +1371,7 @@ void SvxConfigPage::ReloadTopLevelListBox( SvxConfigEntry const * pToSelect )
{
for (auto const& entryData : *GetSaveInData()->GetEntries())
{
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(entryData)));
+ OUString sId(weld::toId(entryData));
m_xTopLevelListBox->append(sId, SvxConfigPageHelper::stripHotKey(entryData->GetName()));
if (entryData == pToSelect)
@@ -1370,7 +1405,7 @@ void SvxConfigPage::AddSubMenusToUI(
{
OUString subMenuTitle = OUString::Concat(rBaseTitle) + aMenuSeparatorStr + SvxConfigPageHelper::stripHotKey(entryData->GetName());
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(entryData)));
+ OUString sId(weld::toId(entryData));
m_xTopLevelListBox->append(sId, subMenuTitle);
AddSubMenusToUI( subMenuTitle, entryData );
@@ -1495,7 +1530,7 @@ int SvxConfigPage::AppendEntry(
int nCurEntry =
nTarget != -1 ? nTarget : m_xContentsListBox->get_selected_index();
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pNewEntryData)));
+ OUString sId(weld::toId(pNewEntryData));
if (nCurEntry == -1 || nCurEntry == m_xContentsListBox->n_children() - 1)
{
@@ -1506,7 +1541,7 @@ int SvxConfigPage::AppendEntry(
else
{
SvxConfigEntry* pEntryData =
- reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nCurEntry).toInt64());
+ weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nCurEntry));
SvxEntries::iterator iter = pEntries->begin();
SvxEntries::const_iterator end = pEntries->end();
@@ -1548,7 +1583,7 @@ namespace
template<typename itertype> void TmplInsertEntryIntoUI(SvxConfigEntry* pNewEntryData, weld::TreeView& rTreeView, itertype& rIter, SaveInData* pSaveInData,
VirtualDevice& rDropDown, bool bMenu)
{
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pNewEntryData)));
+ OUString sId(weld::toId(pNewEntryData));
rTreeView.set_id(rIter, sId);
@@ -1618,16 +1653,16 @@ IMPL_LINK_NOARG(SvxConfigPage, SelectFunctionHdl, weld::TreeView&, void)
}
else
{
- SfxGroupInfo_Impl *pData = reinterpret_cast<SfxGroupInfo_Impl*>(m_xFunctions->get_selected_id().toInt64());
+ SfxGroupInfo_Impl *pData = weld::fromId<SfxGroupInfo_Impl*>(m_xFunctions->get_selected_id());
if (pData)
{
bool bIsExperimental
= vcl::CommandInfoProvider::IsExperimental(pData->sCommand, m_aModuleId);
- OUString aExperimental = "\n" + CuiResId(RID_SVXSTR_COMMANDEXPERIMENTAL);
- OUString aLabel = CuiResId(RID_SVXSTR_COMMANDLABEL) + ": " + pData->sLabel + "\n";
- OUString aName = CuiResId(RID_SVXSTR_COMMANDNAME) + ": " + pData->sCommand + "\n";
- OUString aTip = CuiResId(RID_SVXSTR_COMMANDTIP) + ": " + pData->sTooltip;
+ OUString aExperimental = "\n" + CuiResId(RID_CUISTR_COMMANDEXPERIMENTAL);
+ OUString aLabel = CuiResId(RID_CUISTR_COMMANDLABEL) + ": " + pData->sLabel + "\n";
+ OUString aName = CuiResId(RID_CUISTR_COMMANDNAME) + ": " + pData->sCommand + "\n";
+ OUString aTip = CuiResId(RID_CUISTR_COMMANDTIP) + ": " + pData->sTooltip;
if (bIsExperimental)
m_xDescriptionField->set_text(aLabel + aName + aTip + aExperimental);
else
@@ -1716,32 +1751,30 @@ bool SvxConfigPage::MoveEntryData(int nSourceEntry, int nTargetEntry)
SvxEntries* pEntries = GetTopLevelSelection()->GetEntries();
SvxConfigEntry* pSourceData =
- reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nSourceEntry).toInt64());
+ weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nSourceEntry));
SvxConfigEntry* pTargetData =
- reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nTargetEntry).toInt64());
+ weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nTargetEntry));
- if ( pSourceData != nullptr && pTargetData != nullptr )
- {
- // remove the source entry from our list
- SvxConfigPageHelper::RemoveEntry( pEntries, pSourceData );
+ if ( pSourceData == nullptr || pTargetData == nullptr )
+ return false;
- SvxEntries::iterator iter = pEntries->begin();
- SvxEntries::const_iterator end = pEntries->end();
+ // remove the source entry from our list
+ SvxConfigPageHelper::RemoveEntry( pEntries, pSourceData );
- // advance the iterator to the position of the target entry
- while (*iter != pTargetData && ++iter != end) ;
+ SvxEntries::iterator iter = pEntries->begin();
+ SvxEntries::const_iterator end = pEntries->end();
- // insert the source entry at the position after the target
- pEntries->insert( ++iter, pSourceData );
+ // advance the iterator to the position of the target entry
+ while (*iter != pTargetData && ++iter != end) ;
- GetSaveInData()->SetModified();
- GetTopLevelSelection()->SetModified();
+ // insert the source entry at the position after the target
+ pEntries->insert( ++iter, pSourceData );
- return true;
- }
+ GetSaveInData()->SetModified();
+ GetTopLevelSelection()->SetModified();
- return false;
+ return true;
}
SvxMainMenuOrganizerDialog::SvxMainMenuOrganizerDialog(
@@ -1762,7 +1795,7 @@ SvxMainMenuOrganizerDialog::SvxMainMenuOrganizerDialog(
mpEntries.reset( new SvxEntries );
for (auto const& entry : *entries)
{
- m_xMenuListBox->append(OUString::number(reinterpret_cast<sal_uInt64>(entry)),
+ m_xMenuListBox->append(weld::toId(entry),
SvxConfigPageHelper::stripHotKey(entry->GetName()));
mpEntries->push_back(entry);
if (entry == selection)
@@ -1775,7 +1808,7 @@ SvxMainMenuOrganizerDialog::SvxMainMenuOrganizerDialog(
if ( bCreateMenu )
{
// Generate custom name for new menu
- OUString prefix = CuiResId( RID_SVXSTR_NEW_MENU );
+ OUString prefix = CuiResId( RID_CUISTR_NEW_MENU );
OUString newname = SvxConfigPageHelper::generateCustomName( prefix, entries );
OUString newurl = SvxConfigPageHelper::generateCustomMenuURL( mpEntries.get() );
@@ -1786,7 +1819,7 @@ SvxMainMenuOrganizerDialog::SvxMainMenuOrganizerDialog(
pNewEntryData->SetUserDefined();
pNewEntryData->SetMain();
- m_sNewMenuEntryId = OUString::number(reinterpret_cast<sal_uInt64>(pNewEntryData));
+ m_sNewMenuEntryId = weld::toId(pNewEntryData);
m_xMenuListBox->append(m_sNewMenuEntryId,
SvxConfigPageHelper::stripHotKey(pNewEntryData->GetName()));
m_xMenuListBox->select(m_xMenuListBox->n_children() - 1);
@@ -1802,7 +1835,7 @@ SvxMainMenuOrganizerDialog::SvxMainMenuOrganizerDialog(
// hide name label and textfield
m_xMenuBox->hide();
// change the title
- m_xDialog->set_title(CuiResId(RID_SVXSTR_MOVE_MENU));
+ m_xDialog->set_title(CuiResId(RID_CUISTR_MOVE_MENU));
}
m_xMenuListBox->connect_changed(LINK(this, SvxMainMenuOrganizerDialog, SelectHdl));
@@ -1825,7 +1858,7 @@ IMPL_LINK_NOARG(SvxMainMenuOrganizerDialog, ModifyHdl, weld::Entry&, void)
return;
}
- SvxConfigEntry* pNewEntryData = reinterpret_cast<SvxConfigEntry*>(m_sNewMenuEntryId.toUInt64());
+ SvxConfigEntry* pNewEntryData = weld::fromId<SvxConfigEntry*>(m_sNewMenuEntryId);
pNewEntryData->SetName(m_xMenuNameEdit->get_text());
const int nNewMenuPos = m_xMenuListBox->find_id(m_sNewMenuEntryId);
@@ -1882,14 +1915,14 @@ SvxConfigEntry* SvxMainMenuOrganizerDialog::GetSelectedEntry()
const int nSelected(m_xMenuListBox->get_selected_index());
if (nSelected == -1)
return nullptr;
- return reinterpret_cast<SvxConfigEntry*>(m_xMenuListBox->get_id(nSelected).toUInt64());
+ return weld::fromId<SvxConfigEntry*>(m_xMenuListBox->get_id(nSelected));
}
-SvxConfigEntry::SvxConfigEntry( const OUString& rDisplayName,
- const OUString& rCommandURL, bool bPopup, bool bParentData )
+SvxConfigEntry::SvxConfigEntry( OUString aDisplayName,
+ OUString aCommandURL, bool bPopup, bool bParentData )
: nId( 1 )
- , aLabel(rDisplayName)
- , aCommand(rCommandURL)
+ , aLabel(std::move(aDisplayName))
+ , aCommand(std::move(aCommandURL))
, bPopUp(bPopup)
, bStrEdited( false )
, bIsUserDefined( false )
@@ -1968,7 +2001,7 @@ sal_Int32 ToolbarSaveInData::GetSystemStyle( const OUString& rResourceURL )
if ( a >>= aProps )
{
- for ( beans::PropertyValue const & prop : std::as_const(aProps) )
+ for (beans::PropertyValue const& prop : aProps)
{
if ( prop.Name == ITEM_DESCRIPTOR_STYLE )
{
@@ -2058,7 +2091,7 @@ void ToolbarSaveInData::SetSystemStyle(
if ( a >>= aProps )
{
- for ( beans::PropertyValue& prop : aProps )
+ for ( beans::PropertyValue& prop : asNonConstRange(aProps) )
{
if ( prop.Name == ITEM_DESCRIPTOR_STYLE )
{
@@ -2095,7 +2128,7 @@ OUString ToolbarSaveInData::GetSystemUIName( const OUString& rResourceURL )
if ( a >>= aProps )
{
- for ( beans::PropertyValue const & prop : std::as_const(aProps) )
+ for (beans::PropertyValue const& prop : aProps)
{
if ( prop.Name == ITEM_DESCRIPTOR_UINAME )
{
@@ -2122,7 +2155,7 @@ OUString ToolbarSaveInData::GetSystemUIName( const OUString& rResourceURL )
uno::Sequence< beans::PropertyValue > aPropSeq;
if ( a >>= aPropSeq )
{
- for ( beans::PropertyValue const & prop : std::as_const(aPropSeq) )
+ for (beans::PropertyValue const& prop : aPropSeq)
{
if ( prop.Name == ITEM_DESCRIPTOR_LABEL )
{
@@ -2395,8 +2428,9 @@ void ToolbarSaveInData::ApplyToolbar(
sal_Int32 nIndex = aPropValueSeq.getLength();
aPropValueSeq.realloc( nIndex + 1 );
- aPropValueSeq[nIndex].Name = m_aDescriptorContainer;
- aPropValueSeq[nIndex].Value <<= xSubMenuBar;
+ auto pPropValueSeq = aPropValueSeq.getArray();
+ pPropValueSeq[nIndex].Name = m_aDescriptorContainer;
+ pPropValueSeq[nIndex].Value <<= xSubMenuBar;
rToolbarBar->insertByIndex(
rToolbarBar->getCount(), uno::Any( aPropValueSeq ));
@@ -2556,9 +2590,10 @@ void ToolbarSaveInData::RestoreToolbar( SvxConfigEntry* pToolbar )
// After reloading, ensure that the icon is reset of each entry
// in the toolbar
uno::Sequence< OUString > aURLSeq( 1 );
+ auto pURLSeq = aURLSeq.getArray();
for (auto const& entry : *pToolbar->GetEntries())
{
- aURLSeq[ 0 ] = entry->GetCommand();
+ pURLSeq[ 0 ] = entry->GetCommand();
try
{
@@ -2622,7 +2657,7 @@ void ToolbarSaveInData::LoadToolbar(
uno::Sequence< beans::PropertyValue > aPropSeq;
if ( a >>= aPropSeq )
{
- for ( beans::PropertyValue const & prop : std::as_const(aPropSeq) )
+ for (beans::PropertyValue const& prop : aPropSeq)
{
if ( prop.Name == "Name" )
{
@@ -2658,7 +2693,6 @@ void ToolbarSaveInData::LoadToolbar(
SvxNewToolbarDialog::SvxNewToolbarDialog(weld::Window* pWindow, const OUString& rName)
: GenericDialogController(pWindow, "cui/ui/newtoolbardialog.ui", "NewToolbarDialog")
, m_xEdtName(m_xBuilder->weld_entry("edit"))
- , m_xBtnOK(m_xBuilder->weld_button("ok"))
, m_xSaveInListBox(m_xBuilder->weld_combo_box("savein"))
{
m_xEdtName->set_text(rName);
@@ -2675,11 +2709,11 @@ SvxNewToolbarDialog::~SvxNewToolbarDialog()
*
*******************************************************************************/
SvxIconSelectorDialog::SvxIconSelectorDialog(weld::Window *pWindow,
- const uno::Reference< css::ui::XImageManager >& rXImageManager,
- const uno::Reference< css::ui::XImageManager >& rXParentImageManager)
+ uno::Reference< css::ui::XImageManager > xImageManager,
+ uno::Reference< css::ui::XImageManager > xParentImageManager)
: GenericDialogController(pWindow, "cui/ui/iconselectordialog.ui", "IconSelector")
- , m_xImageManager(rXImageManager)
- , m_xParentImageManager(rXParentImageManager)
+ , m_xImageManager(std::move(xImageManager))
+ , m_xParentImageManager(std::move(xParentImageManager))
, m_xTbSymbol(new ValueSet(m_xBuilder->weld_scrolled_window("symbolswin", true)))
, m_xTbSymbolWin(new weld::CustomWeld(*m_xBuilder, "symbolsToolbar", *m_xTbSymbol))
, m_xFtNote(m_xBuilder->weld_label("noteLabel"))
@@ -2739,9 +2773,8 @@ SvxIconSelectorDialog::SvxIconSelectorDialog(weld::Window *pWindow,
uno::Reference< lang::XSingleServiceFactory > xStorageFactory(
css::embed::FileSystemStorageFactory::create( xComponentContext ) );
- uno::Sequence< uno::Any > aArgs( 2 );
- aArgs[ 0 ] <<= aDirectory;
- aArgs[ 1 ] <<= css::embed::ElementModes::READWRITE;
+ uno::Sequence< uno::Any > aArgs{ uno::Any(aDirectory),
+ uno::Any(css::embed::ElementModes::READWRITE) };
uno::Reference< css::embed::XStorage > xStorage(
xStorageFactory->createInstanceWithArguments( aArgs ), uno::UNO_QUERY );
@@ -2763,9 +2796,10 @@ SvxIconSelectorDialog::SvxIconSelectorDialog(weld::Window *pWindow,
}
uno::Sequence< OUString > name( 1 );
+ auto pname = name.getArray();
for (auto const& elem : aImageInfo1)
{
- name[ 0 ] = elem.first;
+ pname[ 0 ] = elem.first;
uno::Sequence< uno::Reference< graphic::XGraphic> > graphics = m_xImportedImageManager->getImages( SvxConfigPageHelper::GetImageType(), name );
if ( graphics.hasElements() )
{
@@ -2797,7 +2831,7 @@ SvxIconSelectorDialog::SvxIconSelectorDialog(weld::Window *pWindow,
// large growth factor, expecting many entries
for (auto const& elem : aImageInfo)
{
- name[ 0 ] = elem.first;
+ pname[ 0 ] = elem.first;
uno::Sequence< uno::Reference< graphic::XGraphic> > graphics;
try
@@ -2874,6 +2908,7 @@ IMPL_LINK_NOARG(SvxIconSelectorDialog, ImportHdl, weld::Button&, void)
sfx2::FileDialogHelper aImportDialog(
css::ui::dialogs::TemplateDescription::FILEOPEN_LINK_PREVIEW,
FileDialogFlags::Graphic | FileDialogFlags::MultiSelection, m_xDialog.get());
+ aImportDialog.SetContext(sfx2::FileDialogHelper::IconImport);
// disable the link checkbox in the dialog
uno::Reference< css::ui::dialogs::XFilePickerControlAccess >
@@ -2885,8 +2920,9 @@ IMPL_LINK_NOARG(SvxIconSelectorDialog, ImportHdl, weld::Button&, void)
false);
}
- aImportDialog.SetCurrentFilter(
- "PNG - Portable Network Graphic");
+ GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter();
+ sal_uInt16 nFilter = rFilter.GetImportFormatNumberForShortName(u"png");
+ aImportDialog.SetCurrentFilter(rFilter.GetImportFormatName(nFilter));
if ( ERRCODE_NONE == aImportDialog.Execute() )
{
@@ -2897,7 +2933,7 @@ IMPL_LINK_NOARG(SvxIconSelectorDialog, ImportHdl, weld::Button&, void)
IMPL_LINK_NOARG(SvxIconSelectorDialog, DeleteHdl, weld::Button&, void)
{
- OUString message = CuiResId( RID_SVXSTR_DELETE_ICON_CONFIRM );
+ OUString message = CuiResId( RID_CUISTR_DELETE_ICON_CONFIRM );
std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(m_xDialog.get(),
VclMessageType::Warning, VclButtonsType::OkCancel,
@@ -2907,8 +2943,7 @@ IMPL_LINK_NOARG(SvxIconSelectorDialog, DeleteHdl, weld::Button&, void)
sal_uInt16 nId = m_xTbSymbol->GetSelectedItemId();
- OUString aSelImageText = m_xTbSymbol->GetItemText( nId );
- uno::Sequence< OUString > URLs { aSelImageText };
+ uno::Sequence<OUString> URLs { m_xTbSymbol->GetItemText(nId) };
m_xTbSymbol->RemoveItem(nId);
m_xImportedImageManager->removeImages( SvxConfigPageHelper::GetImageType(), URLs );
if ( m_xImportedImageManager->isModified() )
@@ -2920,13 +2955,8 @@ IMPL_LINK_NOARG(SvxIconSelectorDialog, DeleteHdl, weld::Button&, void)
bool SvxIconSelectorDialog::ReplaceGraphicItem(
const OUString& aURL )
{
- uno::Sequence< OUString > URLs(1);
- uno::Sequence< uno::Reference<graphic::XGraphic > > aImportGraph( 1 );
-
uno::Reference< graphic::XGraphic > xGraphic;
- uno::Sequence< beans::PropertyValue > aMediaProps( 1 );
- aMediaProps[0].Name = "URL";
- aMediaProps[0].Value <<= aURL;
+ uno::Sequence< beans::PropertyValue > aMediaProps{ comphelper::makePropertyValue("URL", aURL) };
css::awt::Size aSize;
bool bOK = false;
@@ -2962,7 +2992,6 @@ bool SvxIconSelectorDialog::ReplaceGraphicItem(
size_t nPos = nId - 1;
assert(nPos == m_xTbSymbol->GetItemPos(nId));
m_xTbSymbol->RemoveItem(nId);
- aMediaProps[0].Value <<= aURL;
Image aImage( xGraphic );
if ( bOK && ((aSize.Width != m_nExpectedSize) || (aSize.Height != m_nExpectedSize)) )
@@ -2975,9 +3004,7 @@ bool SvxIconSelectorDialog::ReplaceGraphicItem(
m_aGraphics[nPos] = Graphic(aImage.GetBitmapEx()).GetXGraphic();
- URLs[0] = aURL;
- aImportGraph[ 0 ] = xGraphic;
- m_xImportedImageManager->replaceImages( SvxConfigPageHelper::GetImageType(), URLs, aImportGraph );
+ m_xImportedImageManager->replaceImages( SvxConfigPageHelper::GetImageType(), { aURL }, { xGraphic } );
m_xImportedImageManager->store();
bResult = true;
@@ -2995,10 +3022,10 @@ bool SvxIconSelectorDialog::ReplaceGraphicItem(
namespace
{
- OUString ReplaceIconName(const OUString& rMessage)
+ OUString ReplaceIconName(std::u16string_view rMessage)
{
OUString name;
- OUString message = CuiResId( RID_SVXSTR_REPLACE_ICON_WARNING );
+ OUString message = CuiResId( RID_CUISTR_REPLACE_ICON_WARNING );
OUString placeholder("%ICONNAME" );
sal_Int32 pos = message.indexOf( placeholder );
if ( pos != -1 )
@@ -3014,13 +3041,13 @@ namespace
private:
std::unique_ptr<weld::MessageDialog> m_xQueryBox;
public:
- SvxIconReplacementDialog(weld::Window *pParent, const OUString& rMessage, bool bYestoAll)
+ SvxIconReplacementDialog(weld::Window *pParent, std::u16string_view rMessage, bool bYestoAll)
: m_xQueryBox(Application::CreateMessageDialog(pParent, VclMessageType::Warning, VclButtonsType::NONE, ReplaceIconName(rMessage)))
{
- m_xQueryBox->set_title(CuiResId(RID_SVXSTR_REPLACE_ICON_CONFIRM));
+ m_xQueryBox->set_title(CuiResId(RID_CUISTR_REPLACE_ICON_CONFIRM));
m_xQueryBox->add_button(GetStandardText(StandardButtonType::Yes), 2);
if (bYestoAll)
- m_xQueryBox->add_button(CuiResId(RID_SVXSTR_YESTOALL), 5);
+ m_xQueryBox->add_button(CuiResId(RID_CUISTR_YESTOALL), 5);
m_xQueryBox->add_button(GetStandardText(StandardButtonType::No), 4);
m_xQueryBox->add_button(GetStandardText(StandardButtonType::Cancel), 6);
m_xQueryBox->set_default_response(2);
@@ -3132,11 +3159,8 @@ bool SvxIconSelectorDialog::ImportGraphic( const OUString& aURL )
{
bool result = false;
- uno::Sequence< beans::PropertyValue > aMediaProps( 1 );
- aMediaProps[0].Name = "URL";
+ uno::Sequence< beans::PropertyValue > aMediaProps{ comphelper::makePropertyValue("URL", aURL) };
- uno::Reference< graphic::XGraphic > xGraphic;
- aMediaProps[0].Value <<= aURL;
try
{
uno::Reference< beans::XPropertySet > props =
@@ -3144,7 +3168,7 @@ bool SvxIconSelectorDialog::ImportGraphic( const OUString& aURL )
uno::Any a = props->getPropertyValue("SizePixel");
- xGraphic = m_xGraphProvider->queryGraphic( aMediaProps );
+ uno::Reference< graphic::XGraphic > xGraphic = m_xGraphProvider->queryGraphic( aMediaProps );
if ( xGraphic.is() )
{
bool bOK = true;
@@ -3168,8 +3192,7 @@ bool SvxIconSelectorDialog::ImportGraphic( const OUString& aURL )
m_xTbSymbol->InsertItem(m_aGraphics.size(), aImage, aURL);
uno::Sequence<OUString> aImportURL { aURL };
- uno::Sequence< uno::Reference<graphic::XGraphic > > aImportGraph( 1 );
- aImportGraph[ 0 ] = xGraphic;
+ uno::Sequence< uno::Reference<graphic::XGraphic > > aImportGraph{ xGraphic };
m_xImportedImageManager->insertImages( SvxConfigPageHelper::GetImageType(), aImportURL, aImportGraph );
if ( m_xImportedImageManager->isModified() )
{
@@ -3210,39 +3233,16 @@ SvxIconChangeDialog::SvxIconChangeDialog(weld::Window *pWindow, const OUString&
}
SvxConfigPageFunctionDropTarget::SvxConfigPageFunctionDropTarget(SvxConfigPage&rPage, weld::TreeView& rTreeView)
- : DropTargetHelper(rTreeView.get_drop_target())
+ : weld::ReorderingDropTarget(rTreeView)
, m_rPage(rPage)
- , m_rTreeView(rTreeView)
-{
-}
-
-sal_Int8 SvxConfigPageFunctionDropTarget::AcceptDrop(const AcceptDropEvent& rEvt)
{
- // to enable the autoscroll when we're close to the edges
- m_rTreeView.get_dest_row_at_pos(rEvt.maPosPixel, nullptr, true);
- return DND_ACTION_MOVE;
}
-sal_Int8 SvxConfigPageFunctionDropTarget::ExecuteDrop( const ExecuteDropEvent& rEvt )
+sal_Int8 SvxConfigPageFunctionDropTarget::ExecuteDrop(const ExecuteDropEvent& rEvt)
{
- weld::TreeView* pSource = m_rTreeView.get_drag_source();
- // only dragging within the same widget allowed
- if (!pSource || pSource != &m_rTreeView)
- return DND_ACTION_NONE;
-
- std::unique_ptr<weld::TreeIter> xSource(m_rTreeView.make_iterator());
- if (!m_rTreeView.get_selected(xSource.get()))
- return DND_ACTION_NONE;
-
- std::unique_ptr<weld::TreeIter> xTarget(m_rTreeView.make_iterator());
- int nTargetPos = -1;
- if (m_rTreeView.get_dest_row_at_pos(rEvt.maPosPixel, xTarget.get(), true))
- nTargetPos = m_rTreeView.get_iter_index_in_parent(*xTarget);
- m_rTreeView.move_subtree(*xSource, nullptr, nTargetPos);
-
+ sal_Int8 nRet = weld::ReorderingDropTarget::ExecuteDrop(rEvt);
m_rPage.ListModified();
-
- return DND_ACTION_NONE;
+ return nRet;;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */