22 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
23 #include <com/sun/star/ui/ImageType.hpp>
24 #include <com/sun/star/ui/ItemType.hpp>
30 static sal_Int16
theImageType = css::ui::ImageType::COLOR_NORMAL | css::ui::ImageType::SIZE_DEFAULT;
34 SvxEntries::iterator iter = pEntries->begin();
36 while (iter != pEntries->end())
38 if (pChildEntry == *iter)
40 pEntries->erase(iter);
48 std::u16string_view rSaveInName)
50 OUString
name = rMessage.replaceFirst(
"%SAVE IN SELECTION%", rSaveInName);
59 return str.replaceAll(OUString::number(16), OUString::number(nReplacement));
66 theImageType = css::ui::ImageType::COLOR_NORMAL | css::ui::ImageType::SIZE_DEFAULT;
78 css::uno::Reference<css::graphic::XGraphic>
80 const OUString& rCommandURL)
82 css::uno::Reference<css::graphic::XGraphic>
result;
84 if (xImageManager.is())
87 css::uno::Sequence<css::uno::Reference<css::graphic::XGraphic>> aGraphicSeq;
89 css::uno::Sequence<OUString> aImageCmdSeq{ rCommandURL };
93 aGraphicSeq = xImageManager->getImages(
GetImageType(), aImageCmdSeq);
95 if (aGraphicSeq.hasElements())
97 result = aGraphicSeq[0];
100 catch (css::uno::Exception&)
116 name = prefix.replaceFirst(
"%n", OUString::number(suffix), &pos);
121 name += OUString::number(suffix);
128 bool bFoundEntry =
false;
129 for (
auto const& entry : *entries)
131 if (name.equals(entry->GetName()))
149 OUString url =
"vnd.openoffice.org:CustomMenu" + OUString::number(suffix);
154 bool bFoundEntry =
false;
155 for (
auto const& entry : *entries)
157 if (url.equals(entry->GetCommand()))
185 bool bFoundEntry =
false;
186 for (
auto const& entry : *entries)
188 if (url.equals(entry->GetCommand()))
206 if (aModuleId ==
u"com.sun.star.text.TextDocument"
207 || aModuleId ==
u"com.sun.star.text.GlobalDocument")
209 else if (aModuleId ==
u"com.sun.star.text.WebDocument")
211 else if (aModuleId ==
u"com.sun.star.drawing.DrawingDocument")
213 else if (aModuleId ==
u"com.sun.star.presentation.PresentationDocument")
215 else if (aModuleId ==
u"com.sun.star.sheet.SpreadsheetDocument")
217 else if (aModuleId ==
u"com.sun.star.script.BasicIDE")
219 else if (aModuleId ==
u"com.sun.star.formula.FormulaProperties")
221 else if (aModuleId ==
u"com.sun.star.sdb.RelationDesign")
222 return "Relation Design";
223 else if (aModuleId ==
u"com.sun.star.sdb.QueryDesign")
224 return "Query Design";
225 else if (aModuleId ==
u"com.sun.star.sdb.TableDesign")
226 return "Table Design";
227 else if (aModuleId ==
u"com.sun.star.sdb.DataSourceBrowser")
228 return "Data Source Browser";
229 else if (aModuleId ==
u"com.sun.star.sdb.DatabaseDocument")
236 const OUString& aModuleId,
237 const css::uno::Reference<css::frame::XModuleManager2>& rModuleManager)
239 assert(rModuleManager.is());
241 OUString aModuleUIName;
245 css::uno::Any
a = rModuleManager->getByName(aModuleId);
246 css::uno::Sequence<css::beans::PropertyValue>
aSeq;
250 for (css::beans::PropertyValue
const& rProp : std::as_const(aSeq))
252 if (rProp.Name ==
"ooSetupFactoryUIName")
254 rProp.Value >>= aModuleUIName;
260 catch (css::uno::RuntimeException&)
264 catch (css::uno::Exception&)
268 if (aModuleUIName.isEmpty())
271 return aModuleUIName;
275 const css::uno::Reference<css::container::XIndexAccess>& rItemContainer, sal_Int32 nIndex,
276 OUString& rCommandURL, OUString& rLabel, sal_uInt16& rType, sal_Int32& rStyle,
277 css::uno::Reference<css::container::XIndexAccess>& rSubMenu)
281 css::uno::Sequence<css::beans::PropertyValue> aProps;
282 if (rItemContainer->getByIndex(nIndex) >>= aProps)
284 for (css::beans::PropertyValue
const& rProp : std::as_const(aProps))
288 rProp.Value >>= rCommandURL;
292 rProp.Value >>= rSubMenu;
296 rProp.Value >>= rStyle;
300 rProp.Value >>= rLabel;
304 rProp.Value >>= rType;
311 catch (css::lang::IndexOutOfBoundsException&)
319 const css::uno::Reference<css::container::XIndexAccess>& rItemContainer, sal_Int32 nIndex,
320 OUString& rCommandURL, OUString& rLabel, sal_uInt16& rType,
bool& rIsVisible, sal_Int32& rStyle)
324 css::uno::Sequence<css::beans::PropertyValue> aProps;
325 if (rItemContainer->getByIndex(nIndex) >>= aProps)
327 for (css::beans::PropertyValue
const& rProp : std::as_const(aProps))
331 rProp.Value >>= rCommandURL;
335 rProp.Value >>= rStyle;
339 rProp.Value >>= rLabel;
343 rProp.Value >>= rType;
347 rProp.Value >>= rIsVisible;
354 catch (css::lang::IndexOutOfBoundsException&)
361 css::uno::Sequence<css::beans::PropertyValue>
364 css::uno::Sequence<css::beans::PropertyValue> aPropSeq(4);
370 aPropSeq[1].Value <<= css::ui::ItemType::DEFAULT;
378 aPropSeq[2].Value <<= OUString();
382 aPropSeq[2].Value <<= pEntry->
GetName();
386 aPropSeq[3].Value <<=
static_cast<sal_Int16
>(pEntry->
GetStyle());
391 css::uno::Sequence<css::beans::PropertyValue>
394 css::uno::Sequence<css::beans::PropertyValue> aPropSeq(5);
400 aPropSeq[1].Value <<= css::ui::ItemType::DEFAULT;
408 aPropSeq[2].Value <<= OUString();
412 aPropSeq[2].Value <<= pEntry->
GetName();
416 aPropSeq[3].Value <<= pEntry->
IsVisible();
419 aPropSeq[4].Value <<=
static_cast<sal_Int16
>(pEntry->
GetStyle());
435 for (
const auto& entry : *pEntries)
static OUString replaceSixteen(const OUString &str, sal_Int32 nReplacement)
SvxEntries * GetEntries() const
const char ITEM_DESCRIPTOR_TYPE[]
const OUString & GetName() const
static OUString generateCustomURL(SvxEntries *entries)
Generates a custom resource URL for a new toolbar.
static OUString stripHotKey(const OUString &str)
constexpr OUStringLiteral ITEM_DESCRIPTOR_CONTAINER
static void InitImageType()
static sal_Int16 GetImageType()
static OUString GetUIModuleName(const OUString &aModuleId, const css::uno::Reference< css::frame::XModuleManager2 > &rModuleManager)
constexpr OUStringLiteral CUSTOM_TOOLBAR_STR
const char ITEM_DESCRIPTOR_ISVISIBLE[]
static css::uno::Reference< css::graphic::XGraphic > GetGraphic(const css::uno::Reference< css::ui::XImageManager > &xImageManager, const OUString &rCommandURL)
unsigned int uniform_uint_distribution(unsigned int a, unsigned int b)
std::vector< SvxConfigEntry * > SvxEntries
const OUString & GetCommand() const
static bool SvxConfigEntryModified(SvxConfigEntry const *pEntry)
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
static void RemoveEntry(SvxEntries *pEntries, SvxConfigEntry const *pChildEntry)
static OUString generateCustomMenuURL(SvxEntries *entries, sal_Int32 suffix=1)
static OUString replaceSaveInName(const OUString &rMessage, std::u16string_view rSaveInName)
static OUString generateCustomName(const OUString &prefix, SvxEntries *entries, sal_Int32 suffix=1)
static bool EntrySort(SvxConfigEntry const *a, SvxConfigEntry const *b)
const char ITEM_DESCRIPTOR_STYLE[]
const char ITEM_DESCRIPTOR_LABEL[]
static css::uno::Sequence< css::beans::PropertyValue > ConvertToolbarEntry(const SvxConfigEntry *pEntry)
static css::uno::Sequence< css::beans::PropertyValue > ConvertSvxConfigEntry(const SvxConfigEntry *pEntry)
static sal_uInt32 generateRandomValue()
sal_Int32 GetStyle() const
static OUString GetModuleName(std::u16string_view aModuleId)
constexpr char16_t ITEM_TOOLBAR_URL[]
Sequence< sal_Int8 > aSeq
const char ITEM_DESCRIPTOR_COMMANDURL[]
static bool GetToolbarItemData(const css::uno::Reference< css::container::XIndexAccess > &rItemContainer, sal_Int32 nIndex, OUString &rCommandURL, OUString &rLabel, sal_uInt16 &rType, bool &rIsVisible, sal_Int32 &rStyle)
static bool GetMenuItemData(const css::uno::Reference< css::container::XIndexAccess > &rItemContainer, sal_Int32 nIndex, OUString &rCommandURL, OUString &rLabel, sal_uInt16 &rType, sal_Int32 &rStyle, css::uno::Reference< css::container::XIndexAccess > &rSubMenu)
static sal_Int16 theImageType
bool HasChangedName() const