37#include <libxml/parser.h>
38#include <osl/file.hxx>
44#include <com/sun/star/frame/theUICommandDescription.hpp>
54 std::u16string_view sActiveCategory,
bool& isCategory)
56 if (sUIItemId == sActiveCategory)
58 else if ((sClassId ==
u"GtkMenu" || sClassId ==
u"GtkGrid") && sUIItemId != sActiveCategory)
68 return OUString(cString, strlen(cString), RTL_TEXTENCODING_UTF8);
73 if (aFileName ==
u"notebookbar.ui")
75 else if (aFileName ==
u"notebookbar_compact.ui")
76 return CuiResId(RID_CUISTR_TABBED_COMPACT);
77 else if (aFileName ==
u"notebookbar_groupedbar_full.ui")
78 return CuiResId(RID_CUISTR_GROUPEDBAR);
79 else if (aFileName ==
u"notebookbar_groupedbar_compact.ui")
80 return CuiResId(RID_CUISTR_GROUPEDBAR_COMPACT);
87 if (sModuleName ==
u"Writer")
88 return "com.sun.star.text.TextDocument";
89 else if (sModuleName ==
u"Draw")
90 return "com.sun.star.drawing.DrawingDocument";
91 else if (sModuleName ==
u"Impress")
92 return "com.sun.star.presentation.PresentationDocument";
93 else if (sModuleName ==
u"Calc")
94 return "com.sun.star.sheet.SpreadsheetDocument";
118 rCommandCategoryBox.
hide();
160 const css::uno::Reference<css::ui::XUIConfigurationManager>& xCfgMgr,
161 const css::uno::Reference<css::ui::XUIConfigurationManager>& xParentCfgMgr,
162 const OUString& aModuleId,
bool bDocConfig)
172 OUString msg =
CuiResId(RID_CUISTR_CONFIRM_TOOLBAR_RESET);
180 int nValue = xQueryBox->run();
186 Sequence<OUString> sSequenceEntries;
188 OUString sUIPath =
"modules/s" +
m_sAppName.toAsciiLowerCase() +
"/ui/";
195 const OUString& sUIItemId,
196 const OUString& sUIItemCommand,
200 css::uno::Reference<css::container::XNameAccess> m_xCommandToLabelMap;
203 css::frame::theUICommandDescription::get(xContext));
211 uno::Any aModuleVal = m_xCommandToLabelMap->getByName(sUIItemCommand);
213 aModuleVal >>= aPropSeq;
215 catch (container::NoSuchElementException&)
220 for (
auto const& prop : std::as_const(aPropSeq))
221 if (prop.Name ==
"Name")
226 if (sClassId ==
u"GtkSeparatorMenuItem" || sClassId ==
u"GtkSeparator")
228 rTreeView.
set_text(rIter,
"--------------------------------------------", 0);
238 rTreeView.
set_id(rIter, sUIItemId);
244 pNodePtr = pNodePtr->xmlChildrenNode;
247 if (!(xmlStrcmp(pNodePtr->name,
reinterpret_cast<const xmlChar*
>(
"property"))))
249 xmlChar* UriValue = xmlGetProp(pNodePtr,
reinterpret_cast<const xmlChar*
>(
"name"));
250 if (!(xmlStrcmp(UriValue,
reinterpret_cast<const xmlChar*
>(
"visible"))))
252 xmlChar* aValue = xmlNodeGetContent(pNodePtr);
253 const char* cVisibleValue =
reinterpret_cast<const char*
>(aValue);
257 if (!(xmlStrcmp(UriValue,
reinterpret_cast<const xmlChar*
>(
"action_name"))))
259 xmlChar* aValue = xmlNodeGetContent(pNodePtr);
260 const char* cActionName =
reinterpret_cast<const char*
>(aValue);
266 pNodePtr = pNodePtr->next;
271 std::vector<CategoriesEntries>& aCategoryList,
272 OUString& sActiveCategory,
274 xmlNode* pNodePtr,
bool isCategory)
276 pNodePtr = pNodePtr->xmlChildrenNode;
279 if (pNodePtr->type == XML_ELEMENT_NODE)
281 const char* cNodeName =
reinterpret_cast<const char*
>(pNodePtr->name);
282 if (strcmp(cNodeName,
"object") == 0)
286 xmlChar* UriValue = xmlGetProp(pNodePtr,
reinterpret_cast<const xmlChar*
>(
"id"));
287 const char* cUIItemID =
reinterpret_cast<const char*
>(UriValue);
291 UriValue = xmlGetProp(pNodePtr,
reinterpret_cast<const xmlChar*
>(
"class"));
292 const char* cClassId =
reinterpret_cast<const char*
>(UriValue);
297 if (sClassId ==
"sfxlo-PriorityHBox")
302 aCategoryList.push_back(aCategoryEntry);
304 aCurItemEntry = aCategoryEntry;
306 else if (sClassId ==
"sfxlo-PriorityMergedHBox")
320 aCategoryList.push_back(aCategoryEntry);
321 aCurItemEntry = aCategoryEntry;
323 else if (sClassId ==
"svtlo-ManagedMenuButton")
326 sSecondVal = sUIItemId.getToken(rPos,
':', rPos);
327 if (!sSecondVal.isEmpty())
332 aCategoryList.push_back(aCategoryEntry);
341 if (sClassId ==
"GtkMenuItem" || sClassId ==
"GtkToolButton"
342 || sClassId ==
"GtkMenuToolButton"
343 || (sClassId ==
"svtlo-ManagedMenuButton" && sSecondVal.isEmpty()))
352 else if (sClassId ==
"GtkSeparatorMenuItem" || sClassId ==
"GtkSeparator")
361 else if (sClassId ==
"sfxlo-PriorityHBox"
362 || sClassId ==
"sfxlo-PriorityMergedHBox"
363 || sClassId ==
"svtlo-ManagedMenuButton")
368 = aCategoryList[aCategoryList.size() - 1].sDisplayName;
376 pNodePtr, isCategory);
378 pNodePtr = pNodePtr->next;
383 std::vector<NotebookbarEntries>& aEntries,
384 std::vector<CategoriesEntries>& aCategoryList,
385 OUString& sActiveCategory)
396 xmlDocPtr pDoc = xmlParseFile(sUIFileUIPath.getStr());
401 pDoc = xmlParseFile(sUIFileUIPath.getStr());
406 xmlNodePtr pNodePtr = xmlDocGetRootElement(pDoc);
408 std::vector<NotebookbarEntries>
aEntries;
409 std::vector<CategoriesEntries> aCategoryList;
415 for (
const auto& rCategory : aCategoryList)
419 if (
aEntries[nStart].sClassId ==
"sfxlo-PriorityHBox"
420 ||
aEntries[nStart].sClassId ==
"sfxlo-PriorityMergedHBox")
423 std::vector<NotebookbarEntries> aTempEntries;
424 for (std::size_t nIdx = nStart; nIdx <
aEntries.size(); nIdx++)
426 if (
aEntries[nIdx].sClassId ==
"svtlo-ManagedMenuButton")
428 aTempEntries.push_back(
aEntries[nIdx]);
430 sActiveCategory =
aEntries[nIdx].sUIItemId.getToken(rPos,
':', rPos);
434 aTempEntries.push_back(
aEntries[nIdx]);
443 if (
aEntries[nIdx].sActionName !=
"Null")
445 if (
aEntries[nIdx].sVisibleValue ==
"True")
455 aEntries[nIdx].sActionName, rTreeView, rIter);
456 if (
aEntries[nIdx].sClassId !=
u"GtkSeparatorMenuItem"
457 &&
aEntries[nIdx].sClassId !=
u"GtkSeparator")
460 ->GetTooltipMap()[
aEntries[nIdx].sDisplayName]
485 const OUString& sNotebookbarInterface)
488 Sequence<OUString> aOldEntries
490 Sequence<OUString> aNewEntries(aOldEntries.getLength() + 1);
491 auto pNewEntries = aNewEntries.getArray();
492 for (
int nIdx = 0; nIdx < aOldEntries.getLength(); nIdx++)
495 std::u16string_view sFirstValue =
o3tl::getToken(aOldEntries[nIdx], rPos,
',', rPos);
496 if (sFirstValue == sUIItemId)
498 aOldEntries.getArray()[nIdx] = sSetEntry;
502 pNewEntries[nIdx] = aOldEntries[nIdx];
507 pNewEntries[aOldEntries.getLength()] = sSetEntry;
518 OUString sUIItemId =
m_xControl->get_selected_id();
526 OUString sSetEntries = sUIItemId +
",visible," + sVisible;
527 Sequence<OUString> sSeqOfEntries{ sSetEntries };
530 OUString sUIPath =
"modules/s" +
m_pPage->
GetAppName().toAsciiLowerCase() +
"/ui/";
537 ChangedVisibility(
m_xControl->get_iter_index_in_parent(rRowCol.first));
547 ChangedVisibility(nRow);
550 return SvxMenuEntriesListBox::KeyInputHdl(rKeyEvent);
555 const OUString& rsCommand = m_aTooltipMap[
m_xControl->get_id(rIter)];
556 if (rsCommand.isEmpty())
561 m_pPage->GetFrame());
562 return CuiResId(RID_CUISTR_COMMANDLABEL) +
": "
563 +
m_xControl->get_text(rIter).replaceFirst(
"~",
"") +
"\n"
564 +
CuiResId(RID_CUISTR_COMMANDNAME) +
": " + rsCommand +
"\n"
565 +
CuiResId(RID_CUISTR_COMMANDTIP) +
": " + sTooltipLabel.replaceFirst(
"~",
"");
IMPL_LINK(SvxNotebookbarEntriesListBox, CheckButtonHdl, const weld::TreeView::iter_col &, rRowCol, void)
static OUString getFileName(std::u16string_view aFileName)
static void EditRegistryFile(std::u16string_view sUIItemId, const OUString &sSetEntry, const OUString &sNotebookbarInterface)
static OUString charToString(const char *cString)
static OUString getModuleId(std::u16string_view sModuleName)
static bool isCategoryAvailable(std::u16string_view sClassId, std::u16string_view sUIItemId, std::u16string_view sActiveCategory, bool &isCategory)
PropertiesInfo aProperties
constexpr OUStringLiteral notebookbarTabScope
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
static void setCustomizedUIItem(Sequence< OUString > sUIItemProperties, OUString sNotebookbarConfigType)
static OUString getOriginalUIPath()
static OUString getCustomizedUIPath()
static OString getSystemPath(OUString const &sURL)
static void modifyCustomizedUIFile(const Sequence< OUString > &sUIItemProperties)
static Sequence< OUString > getCustomizedUIItem(OUString sNotebookbarConfigType)
css::uno::Reference< css::graphic::XGraphic > GetImage(const OUString &rCommandURL)
weld::Window * GetFrameWeld() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
static OUString replaceSaveInName(const OUString &rMessage, std::u16string_view rSaveInName)
static OUString stripHotKey(const OUString &str)
void InsertEntryIntoNotebookbarTabUI(std::u16string_view sClassId, const OUString &sUIItemId, const OUString &sUIItemCommand, weld::TreeView &rTreeView, const weld::TreeIter &rIter)
std::unique_ptr< weld::Button > m_xMoveUpButton
std::unique_ptr< weld::ComboBox > m_xTopLevelListBox
std::unique_ptr< weld::Label > m_xDescriptionFieldLb
std::unique_ptr< SvxConfigPageFunctionDropTarget > m_xDropTargetHelper
std::unique_ptr< weld::Widget > m_xCommandButtons
std::unique_ptr< weld::Label > m_xCategoryLabel
std::unique_ptr< CuiConfigFunctionListBox > m_xFunctions
std::unique_ptr< CommandCategoryListBox > m_xCommandCategoryListBox
std::unique_ptr< weld::Widget > m_xCustomizeBox
std::unique_ptr< weld::Entry > m_xSearchEdit
const OUString & GetFileName() const
std::unique_ptr< weld::TextView > m_xDescriptionField
std::unique_ptr< weld::Label > m_xLeftFunctionLabel
std::unique_ptr< weld::Button > m_xMoveDownButton
std::unique_ptr< weld::Label > m_xSearchLabel
std::unique_ptr< weld::Label > m_xCustomizeLabel
std::unique_ptr< weld::ComboBox > m_xSaveInListBox
const OUString & GetAppName() const
SaveInData * GetSaveInData()
std::unique_ptr< SvxMenuEntriesListBox > m_xContentsListBox
void UpdateButtonStates() override
short QueryReset() override
virtual ~SvxNotebookbarConfigPage() override
void DeleteSelectedContent() override
static void getNodeValue(xmlNode *pNodePtr, NotebookbarEntries &aNodeEntries)
static void searchNodeandAttribute(std::vector< NotebookbarEntries > &aEntries, std::vector< CategoriesEntries > &aCategoryList, OUString &sActiveCategory, CategoriesEntries &aCurCategoryEntry, xmlNode *pNodePtr, bool isCategory)
SvxNotebookbarConfigPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rItemSet)
virtual void SelectElement() override
SaveInData * CreateSaveInData(const css::uno::Reference< css::ui::XUIConfigurationManager > &, const css::uno::Reference< css::ui::XUIConfigurationManager > &, const OUString &aModuleId, bool docConfig) override
void DeleteSelectedTopLevel() override
static void FillFunctionsList(xmlNodePtr pRootNodePtr, std::vector< NotebookbarEntries > &aEntries, std::vector< CategoriesEntries > &aCategoryList, OUString &sActiveCategory)
virtual ~SvxNotebookbarEntriesListBox() override
SvxNotebookbarEntriesListBox(std::unique_ptr< weld::TreeView > xControl, SvxConfigPage *pPg)
void ChangedVisibility(int nRow)
static void ReloadNotebookBar(std::u16string_view sUIPath)
static OUString getProductName()
virtual void set_text(int row, const OUString &rText, int col=-1)=0
virtual void set_toggle(int row, TriState eState, int col=-1)=0
std::pair< const TreeIter &, int > iter_col
virtual void set_image(int row, const OUString &rImage, int col=-1)=0
virtual void set_id(int row, const OUString &rId)=0
virtual void bulk_insert_for_each(int nSourceCount, const std::function< void(TreeIter &, int nSourceIndex)> &func, const weld::TreeIter *pParent=nullptr, const std::vector< int > *pFixedWidths=nullptr)=0
OUString CuiResId(TranslateId aKey)
ScXMLEditAttributeMap::Entry const aEntries[]
constexpr OUStringLiteral HID_SVX_CONFIG_NOTEBOOKBAR_CONTENTS
constexpr sal_uInt16 KEY_SPACE
#define LINK(Instance, Class, Member)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
Sequence< beans::PropertyValue > GetCommandProperties(const OUString &rsCommandName, const OUString &rsModuleName)
OUString GetTooltipForCommand(const OUString &rsCommandName, const css::uno::Sequence< css::beans::PropertyValue > &rProperties, const Reference< frame::XFrame > &rxFrame)
OUString GetModuleIdentifier(const Reference< frame::XFrame > &rxFrame)