diff options
Diffstat (limited to 'cui/source/customize/SvxNotebookbarConfigPage.cxx')
-rw-r--r-- | cui/source/customize/SvxNotebookbarConfigPage.cxx | 65 |
1 files changed, 45 insertions, 20 deletions
diff --git a/cui/source/customize/SvxNotebookbarConfigPage.cxx b/cui/source/customize/SvxNotebookbarConfigPage.cxx index af08789c67b0..7389d05b91d2 100644 --- a/cui/source/customize/SvxNotebookbarConfigPage.cxx +++ b/cui/source/customize/SvxNotebookbarConfigPage.cxx @@ -40,14 +40,13 @@ #include <sfx2/notebookbar/SfxNotebookBar.hxx> #include <unotools/configmgr.hxx> #include <comphelper/processfactory.hxx> +#include <o3tl/string_view.hxx> #include <com/sun/star/frame/theUICommandDescription.hpp> namespace uno = com::sun::star::uno; namespace frame = com::sun::star::frame; -namespace lang = com::sun::star::lang; namespace container = com::sun::star::container; namespace beans = com::sun::star::beans; -namespace graphic = com::sun::star::graphic; static bool isCategoryAvailable(std::u16string_view sClassId, std::u16string_view sUIItemId, std::u16string_view sActiveCategory, bool& isCategory) @@ -106,14 +105,11 @@ SvxNotebookbarConfigPage::SvxNotebookbarConfigPage(weld::Container* pPage, m_xDescriptionField->set_visible(false); m_xMoveUpButton->set_visible(false); m_xMoveDownButton->set_visible(false); - m_xAddCommandButton->set_visible(false); - m_xRemoveCommandButton->set_visible(false); + m_xCommandButtons->set_visible(false); m_xLeftFunctionLabel->set_visible(false); m_xSearchLabel->set_visible(false); m_xCategoryLabel->set_visible(false); - m_xInsertBtn->set_visible(false); - m_xModifyBtn->set_visible(false); - m_xResetBtn->set_visible(false); + m_xCustomizeBox->set_visible(false); m_xCustomizeLabel->set_visible(false); weld::TreeView& rCommandCategoryBox = m_xFunctions->get_widget(); @@ -144,7 +140,6 @@ void SvxNotebookbarConfigPage::Init() m_xTopLevelListBox->clear(); m_xContentsListBox->clear(); m_xSaveInListBox->clear(); - CustomNotebookbarGenerator::createCustomizedUIFile(); OUString sNotebookbarInterface = getFileName(m_sFileName); OUString sScopeName @@ -183,9 +178,8 @@ short SvxNotebookbarConfigPage::QueryReset() int nValue = xQueryBox->run(); if (nValue == RET_YES) { - OUString sOriginalUIPath = CustomNotebookbarGenerator::getOriginalUIPath(); - OUString sCustomizedUIPath = CustomNotebookbarGenerator::getCustomizedUIPath(); - osl::File::copy(sOriginalUIPath, sCustomizedUIPath); + osl::File::remove(CustomNotebookbarGenerator::getCustomizedUIPath()); + OUString sNotebookbarInterface = getFileName(m_sFileName); Sequence<OUString> sSequenceEntries; CustomNotebookbarGenerator::setCustomizedUIItem(sSequenceEntries, sNotebookbarInterface); @@ -221,7 +215,7 @@ void SvxConfigPage::InsertEntryIntoNotebookbarTabUI(std::u16string_view sClassId } OUString aLabel; - for (auto const& prop : std::as_const(aPropSeq)) + for (auto const& prop : aPropSeq) if (prop.Name == "Name") prop.Value >>= aLabel; @@ -317,8 +311,9 @@ void SvxNotebookbarConfigPage::searchNodeandAttribute(std::vector<NotebookbarEnt { sal_Int32 rPos = 0; aCategoryEntry.sDisplayName - = aCurItemEntry.sDisplayName.getToken(rPos, ' ', rPos) + " | " - + sUIItemId; + = OUString::Concat( + o3tl::getToken(aCurItemEntry.sDisplayName, rPos, ' ', rPos)) + + " | " + sUIItemId; } aCategoryList.push_back(aCategoryEntry); aCurItemEntry = aCategoryEntry; @@ -398,6 +393,13 @@ void SvxNotebookbarConfigPage::SelectElement() CustomNotebookbarGenerator::getCustomizedUIPath()); xmlDocPtr pDoc = xmlParseFile(sUIFileUIPath.getStr()); if (!pDoc) + { + sUIFileUIPath = CustomNotebookbarGenerator::getSystemPath( + CustomNotebookbarGenerator::getOriginalUIPath()); + pDoc = xmlParseFile(sUIFileUIPath.getStr()); + } + + if (!pDoc) return; xmlNodePtr pNodePtr = xmlDocGetRootElement(pDoc); @@ -408,9 +410,8 @@ void SvxNotebookbarConfigPage::SelectElement() if (m_xTopLevelListBox->get_count() == 1) { - for (std::size_t nIdx = 0; nIdx < aCategoryList.size(); nIdx++) - m_xTopLevelListBox->append(aCategoryList[nIdx].sUIItemId, - aCategoryList[nIdx].sDisplayName); + for (const auto& rCategory : aCategoryList) + m_xTopLevelListBox->append(rCategory.sUIItemId, rCategory.sDisplayName); } tools::ULong nStart = 0; if (aEntries[nStart].sClassId == "sfxlo-PriorityHBox" @@ -433,11 +434,10 @@ void SvxNotebookbarConfigPage::SelectElement() aEntries = std::move(aTempEntries); + static_cast<SvxNotebookbarEntriesListBox*>(m_xContentsListBox.get())->GetTooltipMap().clear(); weld::TreeView& rTreeView = m_xContentsListBox->get_widget(); rTreeView.bulk_insert_for_each( aEntries.size(), [this, &rTreeView, &aEntries](weld::TreeIter& rIter, int nIdx) { - OUString sId(OUString::number(nIdx)); - rTreeView.set_id(rIter, sId); if (aEntries[nIdx].sActionName != "Null") { if (aEntries[nIdx].sVisibleValue == "True") @@ -451,6 +451,13 @@ void SvxNotebookbarConfigPage::SelectElement() } InsertEntryIntoNotebookbarTabUI(aEntries[nIdx].sClassId, aEntries[nIdx].sDisplayName, aEntries[nIdx].sActionName, rTreeView, rIter); + if (aEntries[nIdx].sClassId != u"GtkSeparatorMenuItem" + && aEntries[nIdx].sClassId != u"GtkSeparator") + { + static_cast<SvxNotebookbarEntriesListBox*>(m_xContentsListBox.get()) + ->GetTooltipMap()[aEntries[nIdx].sDisplayName] + = aEntries[nIdx].sActionName; + } }); aEntries.clear(); @@ -465,6 +472,9 @@ SvxNotebookbarEntriesListBox::SvxNotebookbarEntriesListBox(std::unique_ptr<weld: m_xControl->connect_toggled(LINK(this, SvxNotebookbarEntriesListBox, CheckButtonHdl)); m_xControl->connect_key_press(Link<const KeyEvent&, bool>()); m_xControl->connect_key_press(LINK(this, SvxNotebookbarEntriesListBox, KeyInputHdl)); + // remove the inherited connect_query_tooltip then add the new one + m_xControl->connect_query_tooltip(Link<const weld::TreeIter&, OUString>()); + m_xControl->connect_query_tooltip(LINK(this, SvxNotebookbarEntriesListBox, QueryTooltip)); } SvxNotebookbarEntriesListBox::~SvxNotebookbarEntriesListBox() {} @@ -480,7 +490,7 @@ static void EditRegistryFile(std::u16string_view sUIItemId, const OUString& sSet for (int nIdx = 0; nIdx < aOldEntries.getLength(); nIdx++) { sal_Int32 rPos = 0; - OUString sFirstValue = aOldEntries[nIdx].getToken(rPos, ',', rPos); + std::u16string_view sFirstValue = o3tl::getToken(aOldEntries[nIdx], rPos, ',', rPos); if (sFirstValue == sUIItemId) { aOldEntries.getArray()[nIdx] = sSetEntry; @@ -538,4 +548,19 @@ IMPL_LINK(SvxNotebookbarEntriesListBox, KeyInputHdl, const KeyEvent&, rKeyEvent, return SvxMenuEntriesListBox::KeyInputHdl(rKeyEvent); } +IMPL_LINK(SvxNotebookbarEntriesListBox, QueryTooltip, const weld::TreeIter&, rIter, OUString) +{ + const OUString& rsCommand = m_aTooltipMap[m_xControl->get_id(rIter)]; + if (rsCommand.isEmpty()) + return OUString(); + OUString aModuleName(vcl::CommandInfoProvider::GetModuleIdentifier(m_pPage->GetFrame())); + auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(rsCommand, aModuleName); + OUString sTooltipLabel = vcl::CommandInfoProvider::GetTooltipForCommand(rsCommand, aProperties, + m_pPage->GetFrame()); + return CuiResId(RID_CUISTR_COMMANDLABEL) + ": " + + m_xControl->get_text(rIter).replaceFirst("~", "") + "\n" + + CuiResId(RID_CUISTR_COMMANDNAME) + ": " + rsCommand + "\n" + + CuiResId(RID_CUISTR_COMMANDTIP) + ": " + sTooltipLabel.replaceFirst("~", ""); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |