31 #include <strings.hrc>
36 #include <dialmgr.hxx>
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";
121 rCommandCategoryBox.
hide();
164 const css::uno::Reference<css::ui::XUIConfigurationManager>& xCfgMgr,
165 const css::uno::Reference<css::ui::XUIConfigurationManager>& xParentCfgMgr,
166 const OUString& aModuleId,
bool bDocConfig)
176 OUString msg =
CuiResId(RID_CUISTR_CONFIRM_TOOLBAR_RESET);
183 GetFrameWeld(), VclMessageType::Question, VclButtonsType::YesNo, label));
184 int nValue = xQueryBox->run();
189 osl::File::copy(sOriginalUIPath, sCustomizedUIPath);
193 OUString sUIPath =
"modules/s" +
m_sAppName.toAsciiLowerCase() +
"/ui/";
200 const OUString& sUIItemId,
201 const OUString& sUIItemCommand,
205 css::uno::Reference<css::container::XNameAccess> m_xCommandToLabelMap;
206 uno::Reference<uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext();
207 uno::Reference<container::XNameAccess> xNameAccess(
208 css::frame::theUICommandDescription::get(xContext));
210 uno::Sequence<beans::PropertyValue> aPropSeq;
216 uno::Any aModuleVal = m_xCommandToLabelMap->getByName(sUIItemCommand);
218 aModuleVal >>= aPropSeq;
220 catch (container::NoSuchElementException&)
225 for (
auto const& prop : std::as_const(aPropSeq))
226 if (prop.Name ==
"Name")
227 prop.Value >>= aLabel;
231 if (sClassId ==
u"GtkSeparatorMenuItem" || sClassId ==
u"GtkSeparator")
233 rTreeView.
set_text(rIter,
"--------------------------------------------", 0);
242 rTreeView.
set_text(rIter, aName, 0);
243 rTreeView.
set_id(rIter, sUIItemId);
249 pNodePtr = pNodePtr->xmlChildrenNode;
252 if (!(xmlStrcmp(pNodePtr->name, reinterpret_cast<const xmlChar*>(
"property"))))
254 xmlChar* UriValue = xmlGetProp(pNodePtr, reinterpret_cast<const xmlChar*>(
"name"));
255 if (!(xmlStrcmp(UriValue, reinterpret_cast<const xmlChar*>(
"visible"))))
257 xmlChar* aValue = xmlNodeGetContent(pNodePtr);
258 const char* cVisibleValue =
reinterpret_cast<const char*
>(aValue);
262 if (!(xmlStrcmp(UriValue, reinterpret_cast<const xmlChar*>(
"action_name"))))
264 xmlChar* aValue = xmlNodeGetContent(pNodePtr);
265 const char* cActionName =
reinterpret_cast<const char*
>(aValue);
271 pNodePtr = pNodePtr->next;
276 std::vector<CategoriesEntries>& aCategoryList,
277 OUString& sActiveCategory,
279 xmlNode* pNodePtr,
bool isCategory)
281 pNodePtr = pNodePtr->xmlChildrenNode;
284 if (pNodePtr->type == XML_ELEMENT_NODE)
286 const char* cNodeName =
reinterpret_cast<const char*
>(pNodePtr->name);
287 if (strcmp(cNodeName,
"object") == 0)
291 xmlChar* UriValue = xmlGetProp(pNodePtr, reinterpret_cast<const xmlChar*>(
"id"));
292 const char* cUIItemID =
reinterpret_cast<const char*
>(UriValue);
296 UriValue = xmlGetProp(pNodePtr, reinterpret_cast<const xmlChar*>(
"class"));
297 const char* cClassId =
reinterpret_cast<const char*
>(UriValue);
302 if (sClassId ==
"sfxlo-PriorityHBox")
307 aCategoryList.push_back(aCategoryEntry);
309 aCurItemEntry = aCategoryEntry;
311 else if (sClassId ==
"sfxlo-PriorityMergedHBox")
325 aCategoryList.push_back(aCategoryEntry);
326 aCurItemEntry = aCategoryEntry;
328 else if (sClassId ==
"svtlo-ManagedMenuButton")
331 sSecondVal = sUIItemId.getToken(rPos,
':', rPos);
332 if (!sSecondVal.isEmpty())
337 aCategoryList.push_back(aCategoryEntry);
346 if (sClassId ==
"GtkMenuItem" || sClassId ==
"GtkToolButton"
347 || sClassId ==
"GtkMenuToolButton"
348 || (sClassId ==
"svtlo-ManagedMenuButton" && sSecondVal.isEmpty()))
355 aEntries.push_back(nodeEntries);
357 else if (sClassId ==
"GtkSeparatorMenuItem" || sClassId ==
"GtkSeparator")
364 aEntries.push_back(nodeEntries);
366 else if (sClassId ==
"sfxlo-PriorityHBox"
367 || sClassId ==
"sfxlo-PriorityMergedHBox"
368 || sClassId ==
"svtlo-ManagedMenuButton")
373 = aCategoryList[aCategoryList.size() - 1].sDisplayName;
376 aEntries.push_back(nodeEntries);
381 pNodePtr, isCategory);
383 pNodePtr = pNodePtr->next;
388 std::vector<NotebookbarEntries>& aEntries,
389 std::vector<CategoriesEntries>& aCategoryList,
390 OUString& sActiveCategory)
401 xmlDocPtr pDoc = xmlParseFile(sUIFileUIPath.getStr());
404 xmlNodePtr pNodePtr = xmlDocGetRootElement(pDoc);
406 std::vector<NotebookbarEntries>
aEntries;
407 std::vector<CategoriesEntries> aCategoryList;
413 for (std::size_t nIdx = 0; nIdx < aCategoryList.size(); nIdx++)
415 aCategoryList[nIdx].sDisplayName);
418 if (aEntries[nStart].sClassId ==
"sfxlo-PriorityHBox"
419 || aEntries[nStart].sClassId ==
"sfxlo-PriorityMergedHBox")
422 std::vector<NotebookbarEntries> aTempEntries;
423 for (std::size_t nIdx = nStart; nIdx < aEntries.size(); nIdx++)
425 if (aEntries[nIdx].sClassId ==
"svtlo-ManagedMenuButton")
427 aTempEntries.push_back(aEntries[nIdx]);
429 sActiveCategory = aEntries[nIdx].sUIItemId.getToken(rPos,
':', rPos);
433 aTempEntries.push_back(aEntries[nIdx]);
436 aEntries = std::move(aTempEntries);
440 aEntries.size(), [
this, &rTreeView, &aEntries](
weld::TreeIter& rIter,
int nIdx) {
441 OUString
sId(OUString::number(nIdx));
442 rTreeView.
set_id(rIter, sId);
443 if (aEntries[nIdx].sActionName !=
"Null")
445 if (aEntries[nIdx].sVisibleValue ==
"True")
455 aEntries[nIdx].sActionName, rTreeView, rIter);
475 const OUString& sNotebookbarInterface)
481 auto pNewEntries = aNewEntries.getArray();
482 for (
int nIdx = 0; nIdx < aOldEntries.getLength(); nIdx++)
485 std::u16string_view sFirstValue =
o3tl::getToken(aOldEntries[nIdx], rPos,
',', rPos);
486 if (sFirstValue == sUIItemId)
488 aOldEntries.getArray()[nIdx] = sSetEntry;
492 pNewEntries[nIdx] = aOldEntries[nIdx];
497 pNewEntries[aOldEntries.getLength()] = sSetEntry;
508 OUString sUIItemId =
m_xControl->get_selected_id();
516 OUString sSetEntries = sUIItemId +
",visible," + sVisible;
520 OUString sUIPath =
"modules/s" +
m_pPage->
GetAppName().toAsciiLowerCase() +
"/ui/";
527 ChangedVisibility(
m_xControl->get_iter_index_in_parent(rRowCol.first));
537 ChangedVisibility(nRow);
540 return SvxMenuEntriesListBox::KeyInputHdl(rKeyEvent);
virtual void set_text(int row, const OUString &rText, int col=-1)=0
#define LINK(Instance, Class, Member)
std::unique_ptr< CuiConfigFunctionListBox > m_xFunctions
virtual ~SvxNotebookbarEntriesListBox() override
std::unique_ptr< weld::Button > m_xResetBtn
const OUString & GetFileName() const
static void EditRegistryFile(std::u16string_view sUIItemId, const OUString &sSetEntry, const OUString &sNotebookbarInterface)
std::unique_ptr< weld::MenuButton > m_xModifyBtn
std::unique_ptr< CommandCategoryListBox > m_xCommandCategoryListBox
static OUString stripHotKey(const OUString &str)
short QueryReset() override
static OUString charToString(const char *cString)
SaveInData * CreateSaveInData(const css::uno::Reference< css::ui::XUIConfigurationManager > &, const css::uno::Reference< css::ui::XUIConfigurationManager > &, const OUString &aModuleId, bool docConfig) override
static void searchNodeandAttribute(std::vector< NotebookbarEntries > &aEntries, std::vector< CategoriesEntries > &aCategoryList, OUString &sActiveCategory, CategoriesEntries &aCurCategoryEntry, xmlNode *pNodePtr, bool isCategory)
std::unique_ptr< SvxConfigPageFunctionDropTarget > m_xDropTargetHelper
static void modifyCustomizedUIFile(const Sequence< OUString > &sUIItemProperties)
static OUString getOriginalUIPath()
std::unique_ptr< weld::Button > m_xRemoveCommandButton
constexpr OUStringLiteral notebookbarTabScope
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
void UpdateButtonStates() override
css::uno::Reference< css::graphic::XGraphic > GetImage(const OUString &rCommandURL)
void DeleteSelectedTopLevel() override
std::unique_ptr< weld::Label > m_xCategoryLabel
constexpr sal_uInt16 KEY_SPACE
std::unique_ptr< SvxMenuEntriesListBox > m_xContentsListBox
virtual void set_id(int row, const OUString &rId)=0
static void getNodeValue(xmlNode *pNodePtr, NotebookbarEntries &aNodeEntries)
std::unique_ptr< weld::ComboBox > m_xTopLevelListBox
static void ReloadNotebookBar(std::u16string_view sUIPath)
static void createCustomizedUIFile()
std::unique_ptr< weld::Label > m_xDescriptionFieldLb
std::pair< const TreeIter &, int > iter_col
void InsertEntryIntoNotebookbarTabUI(std::u16string_view sClassId, const OUString &sUIItemId, const OUString &sUIItemCommand, weld::TreeView &rTreeView, const weld::TreeIter &rIter)
void ChangedVisibility(int nRow)
static OUString replaceSaveInName(const OUString &rMessage, std::u16string_view rSaveInName)
OUString CuiResId(TranslateId aKey)
IMPL_LINK(SvxNotebookbarEntriesListBox, CheckButtonHdl, const weld::TreeView::iter_col &, rRowCol, void)
static OString getSystemPath(OUString const &sURL)
static OUString getProductName()
constexpr OStringLiteral HID_SVX_CONFIG_NOTEBOOKBAR_CONTENTS
virtual ~SvxNotebookbarConfigPage() override
virtual void set_toggle(int row, TriState eState, int col=-1)=0
const OUString & GetAppName() const
std::unique_ptr< weld::Label > m_xSearchLabel
SvxNotebookbarEntriesListBox(std::unique_ptr< weld::TreeView > xControl, SvxConfigPage *pPg)
static bool isCategoryAvailable(std::u16string_view sClassId, std::u16string_view sUIItemId, std::u16string_view sActiveCategory, bool &isCategory)
void DeleteSelectedContent() override
static Sequence< OUString > getCustomizedUIItem(OUString sNotebookbarConfigType)
std::unique_ptr< weld::MenuButton > m_xInsertBtn
std::unique_ptr< weld::Entry > m_xSearchEdit
SvxNotebookbarConfigPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rItemSet)
weld::Window * GetFrameWeld() const
static OUString getCustomizedUIPath()
std::unique_ptr< weld::Label > m_xCustomizeLabel
static void FillFunctionsList(xmlNodePtr pRootNodePtr, std::vector< NotebookbarEntries > &aEntries, std::vector< CategoriesEntries > &aCategoryList, OUString &sActiveCategory)
std::unique_ptr< weld::Label > m_xLeftFunctionLabel
std::unique_ptr< weld::ComboBox > m_xSaveInListBox
virtual void set_image(int row, const OUString &rImage, int col=-1)=0
std::unique_ptr< weld::TextView > m_xDescriptionField
ScXMLEditAttributeMap::Entry const aEntries[]
std::unique_ptr< weld::Button > m_xMoveDownButton
static void setCustomizedUIItem(Sequence< OUString > sUIItemProperties, OUString sNotebookbarConfigType)
std::unique_ptr< weld::Button > m_xMoveUpButton
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
static OUString getFileName(std::u16string_view aFileName)
SaveInData * GetSaveInData()
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
static OUString getModuleId(std::u16string_view sModuleName)
std::unique_ptr< weld::Button > m_xAddCommandButton
virtual void SelectElement() override