summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKatarina Behrens <Katarina.Behrens@cib.de>2017-10-18 12:50:59 +0200
committerJan-Marek Glogowski <glogow@fbihome.de>2017-10-20 22:37:59 +0200
commitbb8de5570e651c8d0ad40ab3cec8ff1aa783cd61 (patch)
tree27bc731e205be3bba852b5a0d5b9207f78350762
parent9317c32ef42331428cb2f42d7b2913574abee44c (diff)
WIP Don't merge tdf#67770: Read LastActiveDeck bits private/jmux/scheduler-fixes
Change-Id: Id5e3c3cb4144b9fc56ab5e4a4e49f1fc69e70023
-rw-r--r--include/sfx2/sidebar/ResourceManager.hxx5
-rw-r--r--sfx2/source/sidebar/ResourceManager.cxx51
-rw-r--r--sfx2/source/sidebar/SidebarController.cxx15
3 files changed, 70 insertions, 1 deletions
diff --git a/include/sfx2/sidebar/ResourceManager.hxx b/include/sfx2/sidebar/ResourceManager.hxx
index 8c50ecfe6316..2d68d3525783 100644
--- a/include/sfx2/sidebar/ResourceManager.hxx
+++ b/include/sfx2/sidebar/ResourceManager.hxx
@@ -51,6 +51,7 @@ public:
void InitDeckContext(const Context& rContex);
void SaveDecksSettings(const Context& rContext);
void SaveDeckSettings(const DeckDescriptor* pDeckDesc);
+ void SaveLastActiveDeck(const Context& rContext, const OUString& rActiveDeck);
void disposeDecks();
@@ -84,6 +85,8 @@ public:
const OUString& rsDeckId,
const css::uno::Reference<css::frame::XController>& rxController);
+ const OUString& GetLastActiveDeck( const Context& rContext );
+
/** Remember the expansions state per panel and context.
*/
void StorePanelExpansionState(const OUString& rsPanelId,
@@ -99,11 +102,13 @@ private:
typedef std::vector<std::shared_ptr<PanelDescriptor>> PanelContainer;
PanelContainer maPanels;
mutable std::set<rtl::OUString> maProcessedApplications;
+ std::map<OUString, OUString> maLastActiveDecks;
SvtMiscOptions maMiscOptions;
void ReadDeckList();
void ReadPanelList();
+ void ReadLastActive();
static void ReadContextList(const utl::OConfigurationNode& rNode,
ContextList& rContextList,
const OUString& rsDefaultMenuCommand);
diff --git a/sfx2/source/sidebar/ResourceManager.cxx b/sfx2/source/sidebar/ResourceManager.cxx
index 1f8fb2863d4f..873aeb203781 100644
--- a/sfx2/source/sidebar/ResourceManager.cxx
+++ b/sfx2/source/sidebar/ResourceManager.cxx
@@ -20,9 +20,11 @@
#include <sfx2/sidebar/ResourceManager.hxx>
#include <sfx2/sidebar/Tools.hxx>
+#include <officecfg/Office/UI/Sidebar.hxx>
#include <unotools/confignode.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/namedvaluecollection.hxx>
+#include <comphelper/sequence.hxx>
#include <comphelper/types.hxx>
#include <rtl/ustrbuf.hxx>
@@ -98,6 +100,7 @@ ResourceManager::ResourceManager()
{
ReadDeckList();
ReadPanelList();
+ ReadLastActive();
}
ResourceManager::~ResourceManager()
@@ -243,6 +246,14 @@ const ResourceManager::PanelContextDescriptorContainer& ResourceManager::GetMatc
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()
{
const utl::OConfigurationTreeRoot aDeckRootNode(
@@ -394,6 +405,22 @@ void ResourceManager::SaveDeckSettings(const DeckDescriptor* pDeckDesc)
aPanelRootNode.commit();
}
+void ResourceManager::SaveLastActiveDeck(const Context& rContext, const OUString& rActiveDeck)
+{
+ //if( maLastActiveDecks.find( rContext.msApplication ) != maLastActiveDecks.end())
+ maLastActiveDecks[rContext.msApplication] = rActiveDeck;
+
+ std::set<OUString> aLastActiveDecks;
+ for ( auto 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()
{
const utl::OConfigurationTreeRoot aPanelRootNode(
@@ -435,6 +462,30 @@ void ResourceManager::ReadPanelList()
}
}
+
+void ResourceManager::ReadLastActive()
+{
+ boost::optional< Sequence <OUString> > aLastActive (officecfg::Office::UI::Sidebar::Content::LastActiveDeck::get());
+
+ if (aLastActive)
+ {
+ const css::uno::Sequence<OUString>& rLastActiveDecks = aLastActive.get();
+ for (auto i = rLastActiveDecks.begin(); i != rLastActiveDecks.end(); ++i)
+ {
+ sal_Int32 nCharIdx = i->lastIndexOf(',');
+ if ( nCharIdx < 0 )
+ {
+ SAL_WARN("sfx.sidebar", "Expecting 2 values separated by comma");
+ continue;
+ }
+
+ const OUString sApplicationName = i->copy( 0, nCharIdx ).trim();
+ const OUString sLastUsed = i->copy( nCharIdx + 1 ).trim();
+ maLastActiveDecks.insert( std::make_pair(sApplicationName, sLastUsed ) );
+ }
+ }
+}
+
void ResourceManager::ReadContextList (
const utl::OConfigurationNode& rParentNode,
ContextList& rContextList,
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
index e5cc4296b74a..9ab3b39a6c5e 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -140,7 +140,8 @@ rtl::Reference<SidebarController> SidebarController::create(
if (instance->mxReadOnlyModeDispatch.is())
instance->mxReadOnlyModeDispatch->addStatusListener(instance.get(), aURL);
- instance->SwitchToDeck(gsDefaultDeckId);
+
+ //instance->SwitchToDeck(gsDefaultDeckId);
return instance;
}
@@ -210,7 +211,10 @@ void SAL_CALL SidebarController::disposing()
// so need to test if GetCurrentContext is still valid regarding msApplication
if (GetCurrentContext().msApplication != "none")
+ {
mpResourceManager->SaveDecksSettings(GetCurrentContext());
+ mpResourceManager->SaveLastActiveDeck(GetCurrentContext(), msCurrentDeckId);
+ }
// clear decks
ResourceManager::DeckContextDescriptorContainer aDecks;
@@ -437,6 +441,15 @@ void SidebarController::UpdateConfigurations()
if (maCurrentContext.msApplication != "none")
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;
mpResourceManager->InitDeckContext(GetCurrentContext());