25#include <officecfg/Office/Common.hxx>
26#include <officecfg/Office/UI/Sidebar.hxx>
39#include <com/sun/star/frame/ModuleManager.hpp>
40#include <com/sun/star/ui/XSidebarPanel.hpp>
41#include <com/sun/star/ui/XUpdateModel.hpp>
46using namespace css::uno;
66css::uno::Sequence<OUString> BuildContextList (
const ContextList& rContextList)
68 const ::std::vector<ContextList::Entry>& entries = rContextList.GetEntries();
70 css::uno::Sequence<OUString>
result(entries.size());
71 auto resultRange = asNonConstRange(result);
74 for (
auto const& entry : entries)
76 OUString appName = entry.maContext.msApplication;
77 OUString contextName = entry.maContext.msContext;
78 OUString menuCommand = entry.msMenuCommand;
81 if (entry.mbIsInitiallyVisible)
82 visibility =
"visible";
84 visibility =
"hidden";
86 OUString element = appName +
", " + contextName +
", " + visibility;
88 if (!menuCommand.isEmpty())
89 element +=
", "+menuCommand;
91 resultRange[
i] = element;
115 for (
auto const& deck :
maDecks)
131 for (
auto const& deck :
maDecks)
133 if (deck->mbExperimental && !officecfg::Office::Common::Misc::ExperimentalMode::get())
135 if (deck->msId == rsDeckId)
150 if (panel->msId == rsPanelId)
164 const bool bIsDocumentReadOnly,
165 const Reference<frame::XController>& rxController)
169 std::multimap<sal_Int32,DeckContextDescriptor> aOrderedIds;
170 for (
auto const& deck :
maDecks)
172 if (deck->mbExperimental && !officecfg::Office::Common::Misc::ExperimentalMode::get())
180 aDeckContextDescriptor.
msId = rDeckDescriptor.
msId;
186 aOrderedIds.emplace(rDeckDescriptor.
mnOrderIndex, aDeckContextDescriptor);
189 for (
auto const& orderId : aOrderedIds)
191 rDecks.push_back(orderId.second);
200 std::u16string_view sDeckId,
201 const Reference<frame::XController>& rxController)
205 std::multimap<sal_Int32, PanelContextDescriptor> aOrderedIds;
209 if (rPanelDescriptor.
mbExperimental && !officecfg::Office::Common::Misc::ExperimentalMode::get())
211 if ( rPanelDescriptor.
msDeckId != sDeckId )
215 if (pEntry ==
nullptr)
219 aPanelContextDescriptor.
msId = rPanelDescriptor.
msId;
223 aOrderedIds.emplace(rPanelDescriptor.
mnOrderIndex, aPanelContextDescriptor);
226 for (
auto const& orderId : aOrderedIds)
228 rPanelIds.push_back(orderId.second);
251 "org.openoffice.Office.UI.Sidebar/Content/DeckList",
256 const Sequence<OUString> aDeckNodeNames (aDeckRootNode.
getNodeNames());
258 for (
const OUString& aDeckName : aDeckNodeNames)
263 if (aDeckName ==
"GalleryDeck" || aDeckName ==
"StyleListDeck")
271 maDecks.push_back(std::make_shared<DeckDescriptor>());
281 rDeckDescriptor.
mnOrderIndex = getInt32(aDeckNode,
"OrderIndex");
282 rDeckDescriptor.
mbExperimental = getBool(aDeckNode,
"IsExperimental");
296 for (
auto const& deck :
maDecks)
313 "org.openoffice.Office.UI.Sidebar/Content/DeckList",
320 ::uno::Sequence< OUString > sContextList = BuildContextList(pDeckDesc->
maContextList);
324 css::uno::Any aTitle(
Any(pDeckDesc->
msTitle));
326 css::uno::Any aContextList(sContextList);
328 bool bChanged =
false;
339 if (aContextList != aDeckNode.
getNodeValue(
"ContextList"))
352 "org.openoffice.Office.UI.Sidebar/Content/PanelList",
364 for (
auto const& panel : rPanels)
366 OUString panelId = panel->GetId();
369 ::uno::Sequence< OUString > sPanelContextList = BuildContextList(xPanelDesc->maContextList);
373 aTitle <<= xPanelDesc->msTitle;
374 aOrder <<= xPanelDesc->mnOrderIndex;
375 aContextList <<= sPanelContextList;
387 if (aContextList != aPanelNode.
getNodeValue(
"ContextList"))
402 std::set<OUString> aLastActiveDecks;
404 aLastActiveDecks.insert( rEntry.first +
"," + rEntry.second);
417 "org.openoffice.Office.UI.Sidebar/Content/PanelList",
422 const Sequence<OUString> aPanelNodeNames (aPanelRootNode.
getNodeNames());
424 for (
const auto& rPanelNodeName : aPanelNodeNames)
433 OUString aPanelId =
getString(aPanelNode,
"Id");
434 if (aPanelId ==
"PageStylesPanel" || aPanelId ==
"PageHeaderPanel"
435 || aPanelId ==
"PageFooterPanel")
439 maPanels.push_back(std::make_shared<PanelDescriptor>());
449 rPanelDescriptor.
mnOrderIndex = getInt32(aPanelNode,
"OrderIndex");
451 rPanelDescriptor.
mbWantsCanvas = getBool(aPanelNode,
"WantsCanvas");
452 rPanelDescriptor.
mbWantsAWT = getBool(aPanelNode,
"WantsAWT");
453 rPanelDescriptor.
mbExperimental = getBool(aPanelNode,
"IsExperimental");
454 const OUString sDefaultMenuCommand(
getString(aPanelNode,
"DefaultMenuCommand"));
464 const Sequence <OUString> aLastActive (officecfg::Office::UI::Sidebar::Content::LastActiveDeck::get());
466 for (
const auto& rDeckInfo : aLastActive)
468 sal_Int32 nCharIdx = rDeckInfo.lastIndexOf(
',');
469 if ( nCharIdx <= 0 || (nCharIdx == rDeckInfo.getLength() - 1) )
471 SAL_WARN(
"sfx.sidebar",
"Expecting 2 values separated by comma");
475 const OUString sApplicationName = rDeckInfo.copy( 0, nCharIdx );
477 const OUString sLastUsed = rDeckInfo.copy( nCharIdx + 1 );
493 const OUString& rsDefaultMenuCommand)
496 Sequence<OUString> aValues;
497 if (!(aValue >>= aValues))
500 for (
const OUString& sValue : std::as_const(aValues))
502 sal_Int32 nCharacterIndex (0);
504 if (nCharacterIndex < 0)
506 if (sApplicationName.getLength() == 0)
515 OSL_FAIL(
"expecting three or four values per ContextList entry, separated by comma");
521 if (nCharacterIndex < 0)
523 OSL_FAIL(
"expecting three or four values per ContextList entry, separated by comma");
530 const OUString sMenuCommandOverride(
535 const OUString sMenuCommand(
536 sMenuCommandOverride.getLength() > 0
537 ? (sMenuCommandOverride ==
"none"
539 : sMenuCommandOverride)
540 : rsDefaultMenuCommand);
546 std::vector<vcl::EnumContext::Application> aApplications;
554 if (sApplicationName ==
"Writer")
556 else if (sApplicationName ==
"Calc")
558 else if (sApplicationName ==
"Draw")
560 else if (sApplicationName ==
"Impress")
562 else if (sApplicationName ==
"Chart")
564 else if (sApplicationName ==
"Math")
566 else if (sApplicationName ==
"DrawImpress")
575 else if (sApplicationName ==
"WriterVariants")
587 SAL_WARN(
"sfx.sidebar",
"application name " << sApplicationName <<
" not recognized");
594 aApplications.push_back(eApplication);
601 SAL_WARN(
"sfx.sidebar",
"context name " << sContextName <<
" not recognized");
607 bool bIsInitiallyVisible;
608 if (sInitialState ==
u"visible")
609 bIsInitiallyVisible =
true;
610 else if (sInitialState ==
u"hidden")
611 bIsInitiallyVisible =
false;
614 OSL_FAIL(
"unrecognized state");
620 for (
auto const& application : aApplications)
639 if (sModuleName.getLength() == 0)
655 if (!aLegacyRootNode.
isValid())
659 std::vector<OUString> aMatchingNodeNames;
661 const sal_Int32
nCount (aMatchingNodeNames.size());
662 for (sal_Int32 nReadIndex(0); nReadIndex<
nCount; ++nReadIndex)
664 const OUString& rsNodeName (aMatchingNodeNames[nReadIndex]);
669 if ( rsNodeName ==
"private:resource/toolpanel/DrawingFramework/CustomAnimations" ||
670 rsNodeName ==
"private:resource/toolpanel/DrawingFramework/Layouts" ||
671 rsNodeName ==
"private:resource/toolpanel/DrawingFramework/MasterPages" ||
672 rsNodeName ==
"private:resource/toolpanel/DrawingFramework/SlideTransitions" ||
673 rsNodeName ==
"private:resource/toolpanel/DrawingFramework/TableDesign" )
676 maDecks.push_back(std::make_shared<DeckDescriptor>());
679 rDeckDescriptor.
msId = rsNodeName;
689 maPanels.push_back(std::make_shared<PanelDescriptor>());
693 rPanelDescriptor.
msId = rsNodeName;
694 rPanelDescriptor.
msDeckId = rsNodeName;
707 std::u16string_view rsPanelId,
708 const bool bExpansionState,
713 if (panel->msId == rsPanelId)
716 if (pEntry !=
nullptr)
727 const Reference<frame::XModuleManager2> xModuleAccess = frame::ModuleManager::create(xContext);
729 const OUString sWindowStateRef(aModuleProperties.
getOrDefault(
730 "ooSetupFactoryWindowStateConfigRef",
733 OUString aPathComposer =
"org.openoffice.Office.UI." + sWindowStateRef +
734 "/UIElements/States";
747 std::vector<OUString>& rMatchingNames,
750 const Sequence<OUString> aChildNodeNames (aRoot.
getNodeNames());
751 std::copy_if(aChildNodeNames.begin(), aChildNodeNames.end(), std::back_inserter(rMatchingNames),
752 [](
const OUString& rChildNodeName) { return rChildNodeName.startsWith(
"private:resource/toolpanel/" ); });
756 std::u16string_view rsDeckId,
758 const Reference<frame::XController>& rxController)
767 for (
auto const& panelContextDescriptor : aPanelContextDescriptors)
769 if (panelContextDescriptor.mbShowForReadOnlyDocuments)
777 for (
auto const& deck :
maDecks)
784 for (
auto const& elem : rContainer)
786 css::uno::Reference<css::ui::XUpdateModel> xPanel(elem->GetPanelComponent(), css::uno::UNO_QUERY);
789 xPanel->updateModel(
xModel);
797 for (
auto const& deck :
maDecks)
799 deck->mpDeck.disposeAndClear();
static std::shared_ptr< ConfigurationChanges > create()
VALUE_TYPE getOrDefault(const OUString &_rValueName, const VALUE_TYPE &_rDefault) const
css::uno::Sequence< OUString > getNodeNames() const noexcept
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)
static const OUString & GetApplicationName(const Application eApplication)
static const OUString & GetContextName(const Context eContext)
static Context GetContextEnum(const OUString &rsContextName)
#define DBG_UNHANDLED_EXCEPTION(...)
#define SAL_WARN(area, stream)
bool getBOOL(const Any &_rAny)
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
sal_Int32 getINT32(const Any &_rAny)
Reference< XComponentContext > getProcessComponentContext()
OUString getString(const Any &_rAny)
std::basic_string_view< charT, traits > trim(std::basic_string_view< charT, traits > str)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
Reference< XModel > xModel