diff options
author | Akshay Deep <akshaydeepiitr@gmail.com> | 2016-05-24 01:53:56 +0530 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2016-05-25 09:19:48 +0000 |
commit | d37a18ff0576dcbc1e776bef7dc475928c0dd948 (patch) | |
tree | 5ac47d595275b3929af92c6140dbf1023ac38cb5 /sfx2 | |
parent | 233df63c540f4431ae67693021309ccb66b8f764 (diff) |
Template Manager: Filter by Application (Default)
Change-Id: I3ff4a55e3c53df15079730a8d0a283108a74f212
Reviewed-on: https://gerrit.libreoffice.org/25377
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/appl/appopen.cxx | 10 | ||||
-rw-r--r-- | sfx2/source/doc/templatedlg.cxx | 86 |
2 files changed, 79 insertions, 17 deletions
diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx index f1cfc5a2c45c..e5ff943baa32 100644 --- a/sfx2/source/appl/appopen.cxx +++ b/sfx2/source/appl/appopen.cxx @@ -448,7 +448,17 @@ void SfxApplication::NewDocExec_Impl( SfxRequest& rReq ) bool bNewWin = false; vcl::Window* pTopWin = GetTopWindow(); + SfxObjectShell* pCurrentShell = SfxObjectShell::Current(); + Reference<XModel> xModel; + + if(pCurrentShell) + xModel = pCurrentShell->GetModel(); + ScopedVclPtrInstance< SfxTemplateManagerDlg > aTemplDlg; + + if(xModel.is()) + aTemplDlg->setDocumentModel(pCurrentShell->GetModel()); + int nRet = aTemplDlg->Execute(); if ( nRet == RET_OK ) { diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index e9279fcb0a9a..13476b832c47 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -291,8 +291,6 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg(vcl::Window *parent) mpCBApp->SetSelectHdl(LINK(this, SfxTemplateManagerDlg, SelectApplicationHdl)); mpCBFolder->SetSelectHdl(LINK(this, SfxTemplateManagerDlg, SelectRegionHdl)); - readSettings(); - mpLocalView->Show(); } @@ -339,6 +337,15 @@ void SfxTemplateManagerDlg::dispose() ModalDialog::dispose(); } +short SfxTemplateManagerDlg::Execute() +{ + //use application specific settings if there's no previous setting + getApplicationSpecificSettings(); + readSettings(); + + return ModalDialog::Execute(); +} + void SfxTemplateManagerDlg::setDocumentModel(const uno::Reference<frame::XModel> &rModel) { m_xModel = rModel; @@ -373,6 +380,45 @@ void SfxTemplateManagerDlg::fillFolderComboBox() mpLocalView->ShowTooltips(true); } +void SfxTemplateManagerDlg::getApplicationSpecificSettings() +{ + if ( ! m_xModel.is() ) + { + mpCBApp->SelectEntryPos(0); + mpCBFolder->SelectEntryPos(0); + mpCurView->filterItems(ViewFilter_Application(getCurrentApplicationFilter())); + mpLocalView->showAllTemplates(); + return; + } + + SvtModuleOptions::EFactory eFactory = SvtModuleOptions::ClassifyFactoryByModel(m_xModel); + + switch(eFactory) + { + case SvtModuleOptions::EFactory::WRITER: + case SvtModuleOptions::EFactory::WRITERWEB: + case SvtModuleOptions::EFactory::WRITERGLOBAL: + mpCBApp->SelectEntryPos(MNI_WRITER); + break; + case SvtModuleOptions::EFactory::CALC: + mpCBApp->SelectEntryPos(MNI_CALC); + break; + case SvtModuleOptions::EFactory::IMPRESS: + mpCBApp->SelectEntryPos(MNI_IMPRESS); + break; + case SvtModuleOptions::EFactory::DRAW: + mpCBApp->SelectEntryPos(MNI_DRAW); + break; + default: + mpCBApp->SelectEntryPos(0); + break; + } + + mpCurView->filterItems(ViewFilter_Application(getCurrentApplicationFilter())); + mpCBFolder->SelectEntryPos(0); + mpLocalView->showAllTemplates(); +} + void SfxTemplateManagerDlg::readSettings () { OUString aLastFolder; @@ -383,22 +429,28 @@ void SfxTemplateManagerDlg::readSettings () sal_uInt16 nTmp = 0; aViewSettings.GetUserItem(TM_SETTING_LASTFOLDER) >>= aLastFolder; aViewSettings.GetUserItem(TM_SETTING_LASTAPPLICATION) >>= nTmp; - switch (nTmp) + + //open last remembered application only when application model is not set + if(!m_xModel.is()) { - case MNI_WRITER: - mpCBApp->SelectEntryPos(MNI_WRITER); - break; - case MNI_CALC: - mpCBApp->SelectEntryPos(MNI_CALC); - break; - case MNI_IMPRESS: - mpCBApp->SelectEntryPos(MNI_IMPRESS); - break; - case MNI_DRAW: - mpCBApp->SelectEntryPos(MNI_DRAW); - break; - default: - mpCBApp->SelectEntryPos(0); + switch (nTmp) + { + case MNI_WRITER: + mpCBApp->SelectEntryPos(MNI_WRITER); + break; + case MNI_CALC: + mpCBApp->SelectEntryPos(MNI_CALC); + break; + case MNI_IMPRESS: + mpCBApp->SelectEntryPos(MNI_IMPRESS); + break; + case MNI_DRAW: + mpCBApp->SelectEntryPos(MNI_DRAW); + break; + default: + mpCBApp->SelectEntryPos(0); + break; + } } } |