31 #include <strings.hrc>
36 #include <dialmgr.hxx>
37 #include <libxml/parser.h>
38 #include <osl/file.hxx>
43 #include <com/sun/star/frame/theUICommandDescription.hpp>
53 std::u16string_view sActiveCategory,
bool& isCategory)
55 if (sUIItemId == sActiveCategory)
57 else if ((sClassId ==
u"GtkMenu" || sClassId ==
u"GtkGrid") && sUIItemId != sActiveCategory)
67 return OUString(cString, strlen(cString), RTL_TEXTENCODING_UTF8);
72 if (aFileName ==
u"notebookbar.ui")
74 else if (aFileName ==
u"notebookbar_compact.ui")
75 return "TabbedCompact";
76 else if (aFileName ==
u"notebookbar_groupedbar_full.ui")
78 else if (aFileName ==
u"notebookbar_groupedbar_compact.ui")
79 return "GroupedbarCompact";
86 if (sModuleName ==
u"Writer")
87 return "com.sun.star.text.TextDocument";
88 else if (sModuleName ==
u"Draw")
89 return "com.sun.star.drawing.DrawingDocument";
90 else if (sModuleName ==
u"Impress")
91 return "com.sun.star.presentation.PresentationDocument";
92 else if (sModuleName ==
u"Calc")
93 return "com.sun.star.sheet.SpreadsheetDocument";
120 rCommandCategoryBox.
hide();
163 const css::uno::Reference<css::ui::XUIConfigurationManager>& xCfgMgr,
164 const css::uno::Reference<css::ui::XUIConfigurationManager>& xParentCfgMgr,
165 const OUString& aModuleId,
bool bDocConfig)
175 OUString msg =
CuiResId(RID_SVXSTR_CONFIRM_TOOLBAR_RESET);
182 GetFrameWeld(), VclMessageType::Question, VclButtonsType::YesNo, label));
183 int nValue = xQueryBox->run();
188 osl::File::copy(sOriginalUIPath, sCustomizedUIPath);
192 OUString sUIPath =
"modules/s" +
m_sAppName.toAsciiLowerCase() +
"/ui/";
199 const OUString& sUIItemId,
200 const OUString& sUIItemCommand,
204 css::uno::Reference<css::container::XNameAccess> m_xCommandToLabelMap;
205 uno::Reference<uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext();
206 uno::Reference<container::XNameAccess> xNameAccess(
207 css::frame::theUICommandDescription::get(xContext));
209 uno::Sequence<beans::PropertyValue> aPropSeq;
215 uno::Any aModuleVal = m_xCommandToLabelMap->getByName(sUIItemCommand);
217 aModuleVal >>= aPropSeq;
219 catch (container::NoSuchElementException&)
224 for (
auto const& prop : std::as_const(aPropSeq))
225 if (prop.Name ==
"Name")
226 prop.Value >>= aLabel;
230 if (sClassId ==
u"GtkSeparatorMenuItem" || sClassId ==
u"GtkSeparator")
232 rTreeView.
set_text(rIter,
"--------------------------------------------", 0);
241 rTreeView.
set_text(rIter, aName, 0);
242 rTreeView.
set_id(rIter, sUIItemId);
248 pNodePtr = pNodePtr->xmlChildrenNode;
251 if (!(xmlStrcmp(pNodePtr->name, reinterpret_cast<const xmlChar*>(
"property"))))
253 xmlChar* UriValue = xmlGetProp(pNodePtr, reinterpret_cast<const xmlChar*>(
"name"));
254 if (!(xmlStrcmp(UriValue, reinterpret_cast<const xmlChar*>(
"visible"))))
256 xmlChar* aValue = xmlNodeGetContent(pNodePtr);
257 const char* cVisibleValue =
reinterpret_cast<const char*
>(aValue);
261 if (!(xmlStrcmp(UriValue, reinterpret_cast<const xmlChar*>(
"action_name"))))
263 xmlChar* aValue = xmlNodeGetContent(pNodePtr);
264 const char* cActionName =
reinterpret_cast<const char*
>(aValue);
270 pNodePtr = pNodePtr->next;
275 std::vector<CategoriesEntries>& aCategoryList,
276 OUString& sActiveCategory,
278 xmlNode* pNodePtr,
bool isCategory)
280 pNodePtr = pNodePtr->xmlChildrenNode;
283 if (pNodePtr->type == XML_ELEMENT_NODE)
285 const char* cNodeName =
reinterpret_cast<const char*
>(pNodePtr->name);
286 if (strcmp(cNodeName,
"object") == 0)
290 xmlChar* UriValue = xmlGetProp(pNodePtr, reinterpret_cast<const xmlChar*>(
"id"));
291 const char* cUIItemID =
reinterpret_cast<const char*
>(UriValue);
295 UriValue = xmlGetProp(pNodePtr, reinterpret_cast<const xmlChar*>(
"class"));
296 const char* cClassId =
reinterpret_cast<const char*
>(UriValue);
301 if (sClassId ==
"sfxlo-PriorityHBox")
306 aCategoryList.push_back(aCategoryEntry);
308 aCurItemEntry = aCategoryEntry;
310 else if (sClassId ==
"sfxlo-PriorityMergedHBox")
320 = aCurItemEntry.
sDisplayName.getToken(rPos,
' ', rPos) +
" | "
323 aCategoryList.push_back(aCategoryEntry);
324 aCurItemEntry = aCategoryEntry;
326 else if (sClassId ==
"svtlo-ManagedMenuButton")
329 sSecondVal = sUIItemId.getToken(rPos,
':', rPos);
330 if (!sSecondVal.isEmpty())
335 aCategoryList.push_back(aCategoryEntry);
344 if (sClassId ==
"GtkMenuItem" || sClassId ==
"GtkToolButton"
345 || sClassId ==
"GtkMenuToolButton"
346 || (sClassId ==
"svtlo-ManagedMenuButton" && sSecondVal.isEmpty()))
353 aEntries.push_back(nodeEntries);
355 else if (sClassId ==
"GtkSeparatorMenuItem" || sClassId ==
"GtkSeparator")
362 aEntries.push_back(nodeEntries);
364 else if (sClassId ==
"sfxlo-PriorityHBox"
365 || sClassId ==
"sfxlo-PriorityMergedHBox"
366 || sClassId ==
"svtlo-ManagedMenuButton")
371 = aCategoryList[aCategoryList.size() - 1].sDisplayName;
374 aEntries.push_back(nodeEntries);
379 pNodePtr, isCategory);
381 pNodePtr = pNodePtr->next;
386 std::vector<NotebookbarEntries>& aEntries,
387 std::vector<CategoriesEntries>& aCategoryList,
388 OUString& sActiveCategory)
399 xmlDocPtr pDoc = xmlParseFile(sUIFileUIPath.getStr());
402 xmlNodePtr pNodePtr = xmlDocGetRootElement(pDoc);
404 std::vector<NotebookbarEntries>
aEntries;
405 std::vector<CategoriesEntries> aCategoryList;
411 for (std::size_t nIdx = 0; nIdx < aCategoryList.size(); nIdx++)
413 aCategoryList[nIdx].sDisplayName);
416 if (aEntries[nStart].sClassId ==
"sfxlo-PriorityHBox"
417 || aEntries[nStart].sClassId ==
"sfxlo-PriorityMergedHBox")
420 std::vector<NotebookbarEntries> aTempEntries;
421 for (std::size_t nIdx = nStart; nIdx < aEntries.size(); nIdx++)
423 if (aEntries[nIdx].sClassId ==
"svtlo-ManagedMenuButton")
425 aTempEntries.push_back(aEntries[nIdx]);
426 std::vector<NotebookbarEntries> aGtkEntries;
428 sActiveCategory = aEntries[nIdx].sUIItemId.getToken(rPos,
':', rPos);
430 for (std::size_t Idx = 0; Idx < aGtkEntries.size(); Idx++)
431 aTempEntries.push_back(aGtkEntries[Idx]);
435 aTempEntries.push_back(aEntries[nIdx]);
438 aEntries = aTempEntries;
439 aTempEntries.clear();
443 aEntries.size(), [
this, &rTreeView, &aEntries](
weld::TreeIter& rIter,
int nIdx) {
444 OUString
sId(OUString::number(nIdx));
445 rTreeView.
set_id(rIter, sId);
446 if (aEntries[nIdx].sActionName !=
"Null")
448 if (aEntries[nIdx].sVisibleValue ==
"True")
458 aEntries[nIdx].sActionName, rTreeView, rIter);
478 const OUString& sNotebookbarInterface)
484 for (
int nIdx = 0; nIdx < aOldEntries.getLength(); nIdx++)
487 OUString sFirstValue = aOldEntries[nIdx].getToken(rPos,
',', rPos);
488 if (sFirstValue == sUIItemId)
490 aOldEntries[nIdx] = sSetEntry;
494 aNewEntries[nIdx] = aOldEntries[nIdx];
499 aNewEntries[aOldEntries.getLength()] = sSetEntry;
510 OUString sUIItemId =
m_xControl->get_selected_id();
518 OUString sSetEntries = sUIItemId +
",visible," + sVisible;
520 sSeqOfEntries[0] = sSetEntries;
523 OUString sUIPath =
"modules/s" +
m_pPage->
GetAppName().toAsciiLowerCase() +
"/ui/";
530 ChangedVisibility(
m_xControl->get_iter_index_in_parent(rRowCol.first));
540 ChangedVisibility(nRow);
543 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
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)
virtual void bulk_insert_for_each(int nSourceCount, const std::function< void(TreeIter &, int nSourceIndex)> &func, const std::vector< int > *pFixedWidths=nullptr)=0
IMPL_LINK(SvxNotebookbarEntriesListBox, CheckButtonHdl, const weld::TreeView::iter_col &, rRowCol, void)
static OString getSystemPath(OUString const &sURL)
static OUString getProductName()
#define notebookbarTabScope
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)
OUString CuiResId(const char *pKey)
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
#define HID_SVX_CONFIG_NOTEBOOKBAR_CONTENTS
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