diff options
author | Rafael Dominguez <venccsralph@gmail.com> | 2013-03-28 23:33:59 -0430 |
---|---|---|
committer | Rafael Dominguez <venccsralph@gmail.com> | 2013-03-28 23:33:59 -0430 |
commit | 05a9ca5b8920e2452130b0a327763a2c3f6dfd24 (patch) | |
tree | c34f5833ec8c3eb2cb5b966e4337a1723ba71450 /sfx2/source | |
parent | 45264d8fd882101912065b9bbb47260fa6db200c (diff) |
fdo#60844 Remember last open folder and filter in Template Manager.
Change-Id: I81982af9a540c9966df8c0474b6527c5d08ed6f3
Diffstat (limited to 'sfx2/source')
-rw-r--r-- | sfx2/source/control/templatelocalview.cxx | 12 | ||||
-rw-r--r-- | sfx2/source/doc/templatedlg.cxx | 89 |
2 files changed, 98 insertions, 3 deletions
diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx index 90f928b4c0cd..1f867eaf07b9 100644 --- a/sfx2/source/control/templatelocalview.cxx +++ b/sfx2/source/control/templatelocalview.cxx @@ -159,6 +159,18 @@ void TemplateLocalView::showRegion(ThumbnailViewItem *pItem) maOpenRegionHdl.Call(NULL); } +void TemplateLocalView::showRegion(const OUString &rName) +{ + for (int i = 0, n = maRegions.size(); i < n; ++i) + { + if (maRegions[i]->maTitle == rName) + { + showRegion(maRegions[i]); + break; + } + } +} + sal_uInt16 TemplateLocalView::getCurRegionItemId() const { for (size_t i = 0; i < maRegions.size(); ++i) diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index 22bc0ed1d2d1..cfe5b6c68fa4 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -35,6 +35,7 @@ #include <tools/urlobj.hxx> #include <unotools/moduleoptions.hxx> #include <unotools/pathoptions.hxx> +#include <unotools/viewoptions.hxx> #include <vcl/edit.hxx> #include <vcl/msgbox.hxx> #include <vcl/toolbox.hxx> @@ -58,6 +59,10 @@ #define PADDING_DLG_BORDER 10 +#define TM_SETTING_MANAGER "TemplateManager" +#define TM_SETTING_LASTFOLDER "LastFolder" +#define TM_SETTING_FILTER "SelectedFilter" + using namespace ::com::sun::star; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::embed; @@ -251,16 +256,19 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg (Window *parent) createDefaultTemplateMenu(); maView->Populate(); - maView->showRootRegion(); - maView->Show(); - mpCurView->filterItems(ViewFilter_Application(FILTER_APP_WRITER)); + readSettings(); + + maView->Show(); + FreeResource(); } SfxTemplateManagerDlg::~SfxTemplateManagerDlg () { + writeSettings(); + // Synchronize the config before deleting it syncRepositories(); for (size_t i = 0, n = maRepositories.size(); i < n; ++i) @@ -340,6 +348,81 @@ IMPL_LINK_NOARG(SfxTemplateManagerDlg,ActivatePageHdl) return 0; } +void SfxTemplateManagerDlg::readSettings () +{ + OUString aLastFolder; + sal_uInt16 nPageId = FILTER_DOCS; + SvtViewOptions aViewSettings( E_DIALOG, TM_SETTING_MANAGER ); + + if ( aViewSettings.Exists() ) + { + sal_uInt16 nFilter; + aViewSettings.GetUserItem(TM_SETTING_LASTFOLDER) >>= aLastFolder; + aViewSettings.GetUserItem(TM_SETTING_FILTER) >>= nFilter; + + switch (nFilter) + { + case FILTER_APP_WRITER: + nPageId = FILTER_DOCS; + break; + case FILTER_APP_IMPRESS: + nPageId = FILTER_PRESENTATIONS; + break; + case FILTER_APP_CALC: + nPageId = FILTER_SHEETS; + break; + case FILTER_APP_DRAW: + nPageId = FILTER_DRAWS; + break; + } + } + + if (!aLastFolder.getLength()) + maView->showRootRegion(); + else + maView->showRegion(aLastFolder); + + maTabControl.SelectTabPage(nPageId); +} + +void SfxTemplateManagerDlg::writeSettings () +{ + Sequence< NamedValue > aSettings(2); + + OUString aLastFolder; + + if (mpCurView == maView && maView->getCurRegionId()) + aLastFolder = maView->getRegionName(maView->getCurRegionId()-1); + + // last folder + aSettings[0].Name = TM_SETTING_LASTFOLDER; + aSettings[0].Value <<= aLastFolder; + + sal_uInt16 nFilter = FILTER_APP_WRITER; + switch (maTabControl.GetCurPageId()) + { + case FILTER_DOCS: + nFilter = FILTER_APP_WRITER; + break; + case FILTER_PRESENTATIONS: + nFilter = FILTER_APP_IMPRESS; + break; + case FILTER_SHEETS: + nFilter = FILTER_APP_CALC; + break; + case FILTER_DRAWS: + nFilter = FILTER_APP_DRAW; + break; + } + + aSettings[1].Name = TM_SETTING_FILTER; + aSettings[1].Value <<= nFilter; + + // write + SvtViewOptions aViewSettings( E_DIALOG, TM_SETTING_MANAGER ); + aViewSettings.SetUserData( aSettings ); +} + void SfxTemplateManagerDlg::Resize() { // Fit the tab page control and the toolbars |