21#include <rtl/bootstrap.hxx>
22#include <config_folders.h>
24#include <osl/file.hxx>
25#include <osl/thread.h>
29#include <com/sun/star/frame/ModuleManager.hpp>
31#include <libxml/parser.h>
34#define aUIPropertiesCount 3
45 return "ActiveWriter";
49 return "ActiveImpress";
80 const Reference<frame::XFrame>&
xFrame = pViewFrame->GetFrame().GetFrameInterface();
81 const Reference<frame::XModuleManager> xModuleManager
82 = frame::ModuleManager::create(::comphelper::getProcessComponentContext());
87 return "org.openoffice.Office.UI.ToolbarMode/Applications/" + sAppName;
92 OUString sDirPath(
"${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER
"/" SAL_CONFIGFILE(
93 "bootstrap")
":UserInstallation}/user/config/soffice.cfg/");
94 rtl::Bootstrap::expandMacros(sDirPath);
100 OUString sAppName, sNotebookbarUIFileName;
103 + sNotebookbarUIFileName;
108 OUString sAppName, sNotebookbarUIFileName;
111 + sNotebookbarUIFileName;
116 OUString sAppName, sNotebookbarUIFileName;
127 OUString sSystemPathSettings;
128 if (osl_getSystemPathFromFileURL(sURL.pData, &sSystemPathSettings.pData) != osl_File_E_None)
130 SAL_WARN(
"cui.customnotebookbar",
"Cannot get system path for :" << sURL);
133 OString osSystemPathSettings
135 return osSystemPathSettings;
138static void changeNodeValue(xmlNode* pNodePtr,
const char* pProperty,
const char* pValue)
140 pNodePtr = pNodePtr->xmlChildrenNode;
143 if (!(xmlStrcmp(pNodePtr->name,
reinterpret_cast<const xmlChar*
>(
"property"))))
145 xmlChar* UriValue = xmlGetProp(pNodePtr,
reinterpret_cast<const xmlChar*
>(
"name"));
146 if (!(xmlStrcmp(UriValue,
reinterpret_cast<const xmlChar*
>(pProperty))))
147 xmlNodeSetContent(pNodePtr,
reinterpret_cast<const xmlChar*
>(pValue));
151 pNodePtr = pNodePtr->next;
158 pNodePtr = pNodePtr->xmlChildrenNode;
161 if (pNodePtr->type == XML_ELEMENT_NODE)
163 if (!(xmlStrcmp(pNodePtr->name,
reinterpret_cast<const xmlChar*
>(
"object"))))
165 xmlChar* UriValue = xmlGetProp(pNodePtr,
reinterpret_cast<const xmlChar*
>(
"id"));
166 if (!(xmlStrcmp(UriValue,
reinterpret_cast<const xmlChar*
>(pUIItemID))))
172 pNodePtr = pNodePtr->next;
177 const OString& rProperty,
const OString& rValue)
179 xmlDocPtr pDocPtr = xmlParseFile(rDocName.getStr());
180 xmlNodePtr pNodePtr = xmlDocGetRootElement(pDocPtr);
188 if (osl::File(sUIPath).open(osl_File_OpenFlag_Read) != osl::FileBase::E_None)
192 for (
auto const& aValue : sUIItemProperties)
206 xmlSaveFormatFile(sCustomizedUIPath.getStr(), doc, 1);
213 OUString& sNotebookbarUIFileName)
222 const Reference<frame::XModuleManager> xModuleManager = frame::ModuleManager::create(xContext);
229 aValue >>= sNotebookbarUIFileName;
238 sal_uInt32 nflag = osl_File_OpenFlag_Read | osl_File_OpenFlag_Write;
239 osl::Directory aDirectory(sUserUIDir);
240 if (aDirectory.open() != osl::FileBase::E_None)
241 osl::Directory::create(sUserUIDir, nflag);
244 "Cannot create the directory or directory was present :" << sUserUIDir);
246 osl::File aFile(sCustomizedUIPath);
247 if (aFile.open(nflag) != osl::FileBase::E_None)
248 osl::File::copy(sOriginalUIPath, sCustomizedUIPath);
251 "Cannot copy the file or file was present :" << sCustomizedUIPath);
263 Sequence<OUString> aValues;
269 OUString sNotebookbarConfigType)
277 css::uno::Any aUIItemProperties(sUIItemProperties);
278 aModeNode.
setNodeValue(
"UIItemProperties", aUIItemProperties);
static void searchNodeAndAttribute(xmlNode *pNodePtr, const char *pUIItemID, const char *pProperty, const char *pValue)
static void changeNodeValue(xmlNode *pNodePtr, const char *pProperty, const char *pValue)
static OUString getAppNameRegistryPath()
static xmlDocPtr notebookbarXMLParser(const OString &rDocName, const OString &rUIItemID, const OString &rProperty, const OString &rValue)
#define aUIPropertiesCount
static OUString getUIDirPath()
static OUString customizedUIPathBuffer()
static OUString lcl_activeAppName(vcl::EnumContext::Application eApp)
static OUString lcl_getAppName(vcl::EnumContext::Application eApp)
PropertiesInfo aProperties
static OUString GetUIRootDir()
CustomNotebookbarGenerator()
static void setCustomizedUIItem(Sequence< OUString > sUIItemProperties, OUString sNotebookbarConfigType)
static OUString getOriginalUIPath()
static OUString getCustomizedUIPath()
static void getFileNameAndAppName(OUString &sAppName, OUString &sNotebookbarUIFileName)
static OString getSystemPath(OUString const &sURL)
static void createCustomizedUIFile()
static void modifyCustomizedUIFile(const Sequence< OUString > &sUIItemProperties)
static Sequence< OUString > getCustomizedUIItem(OUString sNotebookbarConfigType)
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
static SAL_WARN_UNUSED_RESULT SfxViewFrame * Current()
SfxFrame & GetFrame() const
css::uno::Any getNodeValue(const OUString &_rPath) const noexcept
bool setNodeValue(const OUString &_rPath, const css::uno::Any &_rValue) const noexcept
OConfigurationNode openNode(const OUString &_rPath) const noexcept
bool commit() const noexcept
static Application GetApplicationEnum(const OUString &rsApplicationName)
#define SAL_CONFIGFILE(name)
std::deque< AttacherIndex_Impl > aIndex
#define SAL_WARN(area, stream)
Reference< XComponentContext > getProcessComponentContext()
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
Reference< XFrame > xFrame