Kaydet (Commit) 23467fa5 authored tarafından Katarina Behrens's avatar Katarina Behrens

tdf#67770: Read/writer LastActiveDeck bits

Change-Id: Id5e3c3cb4144b9fc56ab5e4a4e49f1fc69e70023
Reviewed-on: https://gerrit.libreoffice.org/43493Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarKatarina Behrens <Katarina.Behrens@cib.de>
üst 0c46b3a9
...@@ -51,6 +51,7 @@ public: ...@@ -51,6 +51,7 @@ public:
void InitDeckContext(const Context& rContex); void InitDeckContext(const Context& rContex);
void SaveDecksSettings(const Context& rContext); void SaveDecksSettings(const Context& rContext);
void SaveDeckSettings(const DeckDescriptor* pDeckDesc); void SaveDeckSettings(const DeckDescriptor* pDeckDesc);
void SaveLastActiveDeck(const Context& rContext, const OUString& rActiveDeck);
void disposeDecks(); void disposeDecks();
...@@ -84,6 +85,8 @@ public: ...@@ -84,6 +85,8 @@ public:
const OUString& rsDeckId, const OUString& rsDeckId,
const css::uno::Reference<css::frame::XController>& rxController); const css::uno::Reference<css::frame::XController>& rxController);
const OUString& GetLastActiveDeck( const Context& rContext );
/** Remember the expansions state per panel and context. /** Remember the expansions state per panel and context.
*/ */
void StorePanelExpansionState(const OUString& rsPanelId, void StorePanelExpansionState(const OUString& rsPanelId,
...@@ -99,11 +102,13 @@ private: ...@@ -99,11 +102,13 @@ private:
typedef std::vector<std::shared_ptr<PanelDescriptor>> PanelContainer; typedef std::vector<std::shared_ptr<PanelDescriptor>> PanelContainer;
PanelContainer maPanels; PanelContainer maPanels;
mutable std::set<rtl::OUString> maProcessedApplications; mutable std::set<rtl::OUString> maProcessedApplications;
std::map<OUString, OUString> maLastActiveDecks;
SvtMiscOptions maMiscOptions; SvtMiscOptions maMiscOptions;
void ReadDeckList(); void ReadDeckList();
void ReadPanelList(); void ReadPanelList();
void ReadLastActive();
static void ReadContextList(const utl::OConfigurationNode& rNode, static void ReadContextList(const utl::OConfigurationNode& rNode,
ContextList& rContextList, ContextList& rContextList,
const OUString& rsDefaultMenuCommand); const OUString& rsDefaultMenuCommand);
......
...@@ -1549,10 +1549,5 @@ ...@@ -1549,10 +1549,5 @@
</prop> </prop>
</node> </node>
</node> </node>
<prop oor:name="LastActiveDeck">
<value oor:separator=";">
any, PropertyDeck;
</value>
</prop>
</node> </node>
</oor:component-data> </oor:component-data>
...@@ -245,7 +245,7 @@ ...@@ -245,7 +245,7 @@
<desc>Contains all registered sidebar content panels.</desc> <desc>Contains all registered sidebar content panels.</desc>
</info> </info>
</set> </set>
<prop oor:name="LastActiveDeck" oor:type="oor:string-list"> <prop oor:name="LastActiveDeck" oor:type="oor:string-list" oor:nillable="false">
<info> <info>
<desc>Contains IDs of the decks that were active last time the application was closed. <desc>Contains IDs of the decks that were active last time the application was closed.
Each entry is a string of 2 comma-separated values, application name and DeckID. Valid Each entry is a string of 2 comma-separated values, application name and DeckID. Valid
...@@ -255,6 +255,9 @@ ...@@ -255,6 +255,9 @@
Impress, PropertyDeck; Impress, PropertyDeck;
</desc> </desc>
</info> </info>
<value>
<it>any,PropertyDeck</it>
</value>
</prop> </prop>
</group> </group>
</component> </component>
......
...@@ -20,9 +20,11 @@ ...@@ -20,9 +20,11 @@
#include <sfx2/sidebar/ResourceManager.hxx> #include <sfx2/sidebar/ResourceManager.hxx>
#include <sfx2/sidebar/Tools.hxx> #include <sfx2/sidebar/Tools.hxx>
#include <officecfg/Office/UI/Sidebar.hxx>
#include <unotools/confignode.hxx> #include <unotools/confignode.hxx>
#include <comphelper/processfactory.hxx> #include <comphelper/processfactory.hxx>
#include <comphelper/namedvaluecollection.hxx> #include <comphelper/namedvaluecollection.hxx>
#include <comphelper/sequence.hxx>
#include <comphelper/types.hxx> #include <comphelper/types.hxx>
#include <rtl/ustrbuf.hxx> #include <rtl/ustrbuf.hxx>
...@@ -98,6 +100,7 @@ ResourceManager::ResourceManager() ...@@ -98,6 +100,7 @@ ResourceManager::ResourceManager()
{ {
ReadDeckList(); ReadDeckList();
ReadPanelList(); ReadPanelList();
ReadLastActive();
} }
ResourceManager::~ResourceManager() ResourceManager::~ResourceManager()
...@@ -243,6 +246,14 @@ const ResourceManager::PanelContextDescriptorContainer& ResourceManager::GetMatc ...@@ -243,6 +246,14 @@ const ResourceManager::PanelContextDescriptorContainer& ResourceManager::GetMatc
return rPanelIds; return rPanelIds;
} }
const OUString& ResourceManager::GetLastActiveDeck( const Context& rContext )
{
if( maLastActiveDecks.find( rContext.msApplication ) == maLastActiveDecks.end())
return maLastActiveDecks["any"];
else
return maLastActiveDecks[rContext.msApplication];
}
void ResourceManager::ReadDeckList() void ResourceManager::ReadDeckList()
{ {
const utl::OConfigurationTreeRoot aDeckRootNode( const utl::OConfigurationTreeRoot aDeckRootNode(
...@@ -394,6 +405,21 @@ void ResourceManager::SaveDeckSettings(const DeckDescriptor* pDeckDesc) ...@@ -394,6 +405,21 @@ void ResourceManager::SaveDeckSettings(const DeckDescriptor* pDeckDesc)
aPanelRootNode.commit(); aPanelRootNode.commit();
} }
void ResourceManager::SaveLastActiveDeck(const Context& rContext, const OUString& rActiveDeck)
{
maLastActiveDecks[rContext.msApplication] = rActiveDeck;
std::set<OUString> aLastActiveDecks;
for ( auto const & rEntry : maLastActiveDecks )
aLastActiveDecks.insert( rEntry.first + "," + rEntry.second);
std::shared_ptr<comphelper::ConfigurationChanges> cfgWriter( comphelper::ConfigurationChanges::create() );
officecfg::Office::UI::Sidebar::Content::LastActiveDeck::set(comphelper::containerToSequence(aLastActiveDecks), cfgWriter);
cfgWriter->commit();
}
void ResourceManager::ReadPanelList() void ResourceManager::ReadPanelList()
{ {
const utl::OConfigurationTreeRoot aPanelRootNode( const utl::OConfigurationTreeRoot aPanelRootNode(
...@@ -435,6 +461,29 @@ void ResourceManager::ReadPanelList() ...@@ -435,6 +461,29 @@ void ResourceManager::ReadPanelList()
} }
} }
void ResourceManager::ReadLastActive()
{
Sequence <OUString> aLastActive (officecfg::Office::UI::Sidebar::Content::LastActiveDeck::get());
for (auto& rDeckInfo : aLastActive)
{
sal_Int32 nCharIdx = rDeckInfo.lastIndexOf(',');
if ( nCharIdx <= 0 || (nCharIdx == rDeckInfo.getLength() - 1) )
{
SAL_WARN("sfx.sidebar", "Expecting 2 values separated by comma");
continue;
}
const OUString sApplicationName = rDeckInfo.copy( 0, nCharIdx );
vcl::EnumContext::Application eApplication (vcl::EnumContext::GetApplicationEnum(sApplicationName));
const OUString sLastUsed = rDeckInfo.copy( nCharIdx + 1 );
// guard against garbage in place of application
if (eApplication != vcl::EnumContext::Application::NONE)
maLastActiveDecks.insert( std::make_pair(sApplicationName, sLastUsed ) );
}
}
void ResourceManager::ReadContextList ( void ResourceManager::ReadContextList (
const utl::OConfigurationNode& rParentNode, const utl::OConfigurationNode& rParentNode,
ContextList& rContextList, ContextList& rContextList,
......
...@@ -140,7 +140,7 @@ rtl::Reference<SidebarController> SidebarController::create( ...@@ -140,7 +140,7 @@ rtl::Reference<SidebarController> SidebarController::create(
if (instance->mxReadOnlyModeDispatch.is()) if (instance->mxReadOnlyModeDispatch.is())
instance->mxReadOnlyModeDispatch->addStatusListener(instance.get(), aURL); instance->mxReadOnlyModeDispatch->addStatusListener(instance.get(), aURL);
instance->SwitchToDeck(gsDefaultDeckId); //first UpdateConfigurations call will SwitchToDeck
return instance; return instance;
} }
...@@ -210,7 +210,10 @@ void SAL_CALL SidebarController::disposing() ...@@ -210,7 +210,10 @@ void SAL_CALL SidebarController::disposing()
// so need to test if GetCurrentContext is still valid regarding msApplication // so need to test if GetCurrentContext is still valid regarding msApplication
if (GetCurrentContext().msApplication != "none") if (GetCurrentContext().msApplication != "none")
{
mpResourceManager->SaveDecksSettings(GetCurrentContext()); mpResourceManager->SaveDecksSettings(GetCurrentContext());
mpResourceManager->SaveLastActiveDeck(GetCurrentContext(), msCurrentDeckId);
}
// clear decks // clear decks
ResourceManager::DeckContextDescriptorContainer aDecks; ResourceManager::DeckContextDescriptorContainer aDecks;
...@@ -437,6 +440,15 @@ void SidebarController::UpdateConfigurations() ...@@ -437,6 +440,15 @@ void SidebarController::UpdateConfigurations()
if (maCurrentContext.msApplication != "none") if (maCurrentContext.msApplication != "none")
mpResourceManager->SaveDecksSettings(maCurrentContext); mpResourceManager->SaveDecksSettings(maCurrentContext);
// get last active deck for this application on first update
if (!maRequestedContext.msApplication.isEmpty() &&
(maCurrentContext.msApplication != maRequestedContext.msApplication))
{
OUString sLastActiveDeck = mpResourceManager->GetLastActiveDeck( maRequestedContext );
if (!sLastActiveDeck.isEmpty())
msCurrentDeckId = sLastActiveDeck;
}
maCurrentContext = maRequestedContext; maCurrentContext = maRequestedContext;
mpResourceManager->InitDeckContext(GetCurrentContext()); mpResourceManager->InitDeckContext(GetCurrentContext());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment