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();
161 const css::uno::Reference<css::ui::XUIConfigurationManager>& xCfgMgr,
162 const css::uno::Reference<css::ui::XUIConfigurationManager>& xParentCfgMgr,
163 const OUString& aModuleId,
bool bDocConfig)
173 OUString msg =
CuiResId(RID_CUISTR_CONFIRM_TOOLBAR_RESET);
181 int nValue = xQueryBox->run();
186 osl::File::copy(sOriginalUIPath, sCustomizedUIPath);
188 Sequence<OUString> sSequenceEntries;
190 OUString sUIPath =
"modules/s" +
m_sAppName.toAsciiLowerCase() +
"/ui/";
197 const OUString& sUIItemId,
198 const OUString& sUIItemCommand,
202 css::uno::Reference<css::container::XNameAccess> m_xCommandToLabelMap;
205 css::frame::theUICommandDescription::get(xContext));
213 uno::Any aModuleVal = m_xCommandToLabelMap->getByName(sUIItemCommand);
215 aModuleVal >>= aPropSeq;
217 catch (container::NoSuchElementException&)
222 for (
auto const& prop : std::as_const(aPropSeq))
223 if (prop.Name ==
"Name")
228 if (sClassId ==
u"GtkSeparatorMenuItem" || sClassId ==
u"GtkSeparator")
230 rTreeView.
set_text(rIter,
"--------------------------------------------", 0);
240 rTreeView.
set_id(rIter, sUIItemCommand);
246 pNodePtr = pNodePtr->xmlChildrenNode;
249 if (!(xmlStrcmp(pNodePtr->name,
reinterpret_cast<const xmlChar*
>(
"property"))))
251 xmlChar* UriValue = xmlGetProp(pNodePtr,
reinterpret_cast<const xmlChar*
>(
"name"));
252 if (!(xmlStrcmp(UriValue,
reinterpret_cast<const xmlChar*
>(
"visible"))))
254 xmlChar* aValue = xmlNodeGetContent(pNodePtr);
255 const char* cVisibleValue =
reinterpret_cast<const char*
>(aValue);
259 if (!(xmlStrcmp(UriValue,
reinterpret_cast<const xmlChar*
>(
"action_name"))))
261 xmlChar* aValue = xmlNodeGetContent(pNodePtr);
262 const char* cActionName =
reinterpret_cast<const char*
>(aValue);
268 pNodePtr = pNodePtr->next;
273 std::vector<CategoriesEntries>& aCategoryList,
274 OUString& sActiveCategory,
276 xmlNode* pNodePtr,
bool isCategory)
278 pNodePtr = pNodePtr->xmlChildrenNode;
281 if (pNodePtr->type == XML_ELEMENT_NODE)
283 const char* cNodeName =
reinterpret_cast<const char*
>(pNodePtr->name);
284 if (strcmp(cNodeName,
"object") == 0)
288 xmlChar* UriValue = xmlGetProp(pNodePtr,
reinterpret_cast<const xmlChar*
>(
"id"));
289 const char* cUIItemID =
reinterpret_cast<const char*
>(UriValue);
293 UriValue = xmlGetProp(pNodePtr,
reinterpret_cast<const xmlChar*
>(
"class"));
294 const char* cClassId =
reinterpret_cast<const char*
>(UriValue);
299 if (sClassId ==
"sfxlo-PriorityHBox")
304 aCategoryList.push_back(aCategoryEntry);
306 aCurItemEntry = aCategoryEntry;
308 else if (sClassId ==
"sfxlo-PriorityMergedHBox")
322 aCategoryList.push_back(aCategoryEntry);
323 aCurItemEntry = aCategoryEntry;
325 else if (sClassId ==
"svtlo-ManagedMenuButton")
328 sSecondVal = sUIItemId.getToken(rPos,
':', rPos);
329 if (!sSecondVal.isEmpty())
334 aCategoryList.push_back(aCategoryEntry);
343 if (sClassId ==
"GtkMenuItem" || sClassId ==
"GtkToolButton"
344 || sClassId ==
"GtkMenuToolButton"
345 || (sClassId ==
"svtlo-ManagedMenuButton" && sSecondVal.isEmpty()))
354 else if (sClassId ==
"GtkSeparatorMenuItem" || sClassId ==
"GtkSeparator")
363 else if (sClassId ==
"sfxlo-PriorityHBox"
364 || sClassId ==
"sfxlo-PriorityMergedHBox"
365 || sClassId ==
"svtlo-ManagedMenuButton")
370 = aCategoryList[aCategoryList.size() - 1].sDisplayName;
378 pNodePtr, isCategory);
380 pNodePtr = pNodePtr->next;
385 std::vector<NotebookbarEntries>& aEntries,
386 std::vector<CategoriesEntries>& aCategoryList,
387 OUString& sActiveCategory)
398 xmlDocPtr pDoc = xmlParseFile(sUIFileUIPath.getStr());
401 xmlNodePtr pNodePtr = xmlDocGetRootElement(pDoc);
403 std::vector<NotebookbarEntries>
aEntries;
404 std::vector<CategoriesEntries> aCategoryList;
410 for (
const auto& rCategory : aCategoryList)
414 if (
aEntries[nStart].sClassId ==
"sfxlo-PriorityHBox"
415 ||
aEntries[nStart].sClassId ==
"sfxlo-PriorityMergedHBox")
418 std::vector<NotebookbarEntries> aTempEntries;
419 for (std::size_t nIdx = nStart; nIdx <
aEntries.size(); nIdx++)
421 if (
aEntries[nIdx].sClassId ==
"svtlo-ManagedMenuButton")
423 aTempEntries.push_back(
aEntries[nIdx]);
425 sActiveCategory =
aEntries[nIdx].sUIItemId.getToken(rPos,
':', rPos);
429 aTempEntries.push_back(
aEntries[nIdx]);
437 if (aEntries[nIdx].sActionName !=
"Null")
439 if (aEntries[nIdx].sVisibleValue ==
"True")
441 rTreeView.set_toggle(rIter, TRISTATE_TRUE);
445 rTreeView.set_toggle(rIter, TRISTATE_FALSE);
449 aEntries[nIdx].sActionName, rTreeView, rIter);
472 const OUString& sNotebookbarInterface)
475 Sequence<OUString> aOldEntries
477 Sequence<OUString> aNewEntries(aOldEntries.getLength() + 1);
478 auto pNewEntries = aNewEntries.getArray();
479 for (
int nIdx = 0; nIdx < aOldEntries.getLength(); nIdx++)
482 std::u16string_view sFirstValue =
o3tl::getToken(aOldEntries[nIdx], rPos,
',', rPos);
483 if (sFirstValue == sUIItemId)
485 aOldEntries.getArray()[nIdx] = sSetEntry;
489 pNewEntries[nIdx] = aOldEntries[nIdx];
494 pNewEntries[aOldEntries.getLength()] = sSetEntry;
505 OUString sUIItemId =
m_xControl->get_selected_id();
513 OUString sSetEntries = sUIItemId +
",visible," + sVisible;
514 Sequence<OUString> sSeqOfEntries{ sSetEntries };
517 OUString sUIPath =
"modules/s" +
m_pPage->
GetAppName().toAsciiLowerCase() +
"/ui/";
524 ChangedVisibility(
m_xControl->get_iter_index_in_parent(rRowCol.first));
534 ChangedVisibility(nRow);
537 return SvxMenuEntriesListBox::KeyInputHdl(rKeyEvent);
542 OUString sCommand =
m_xControl->get_id(rIter);
543 if (sCommand.isEmpty())
548 m_pPage->GetFrame());
549 return CuiResId(RID_CUISTR_COMMANDLABEL) +
": "
550 +
m_xControl->get_text(rIter).replaceFirst(
"~",
"") +
"\n"
551 +
CuiResId(RID_CUISTR_COMMANDNAME) +
": " + sCommand +
"\n"
552 +
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)
static void setCustomizedUIItem(Sequence< OUString > sUIItemProperties, OUString sNotebookbarConfigType)
static OUString getOriginalUIPath()
static OUString getCustomizedUIPath()
static OString getSystemPath(OUString const &sURL)
static void createCustomizedUIFile()
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
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 OStringLiteral 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)