diff options
author | Akshay Deep <akshaydeepiitr@gmail.com> | 2016-06-25 22:00:01 +0530 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2016-06-27 07:42:22 +0000 |
commit | 77725bf4df6e9cf63469c1d7f8888ea339575b5e (patch) | |
tree | 99211e832e06313a8446cba31d7a6552d0d07a38 /sfx2/source | |
parent | e7ca62bbd485c5f450e720c8102db2ab9561429f (diff) |
GSoC: Remove TemplateRemoteView from Template Manager
Conflicts:
include/sfx2/templatedlg.hxx
sfx2/source/doc/templatedlg.cxx
Change-Id: Ia0623707e452c79346d92b5a5ab75a4063928c20
Reviewed-on: https://gerrit.libreoffice.org/26658
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'sfx2/source')
-rw-r--r-- | sfx2/source/control/templateremoteview.cxx | 174 | ||||
-rw-r--r-- | sfx2/source/doc/templatedlg.cxx | 329 |
2 files changed, 41 insertions, 462 deletions
diff --git a/sfx2/source/control/templateremoteview.cxx b/sfx2/source/control/templateremoteview.cxx deleted file mode 100644 index c04b4d12d75f..000000000000 --- a/sfx2/source/control/templateremoteview.cxx +++ /dev/null @@ -1,174 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#include <sfx2/templateremoteview.hxx> - -#include <comphelper/processfactory.hxx> -#include <sfx2/templaterepository.hxx> -#include <sfx2/templateviewitem.hxx> -#include <svtools/imagemgr.hxx> -#include <tools/urlobj.hxx> -#include <ucbhelper/content.hxx> -#include <ucbhelper/commandenvironment.hxx> -#include <vcl/builderfactory.hxx> - -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/task/InteractionHandler.hpp> -#include <com/sun/star/sdbc/XResultSet.hpp> -#include <com/sun/star/sdbc/XRow.hpp> -#include <com/sun/star/ucb/XContentAccess.hpp> -#include <com/sun/star/ucb/XDynamicResultSet.hpp> - -using namespace com::sun::star; -using namespace com::sun::star::lang; -using namespace com::sun::star::task; -using namespace com::sun::star::sdbc; -using namespace com::sun::star::ucb; -using namespace com::sun::star::uno; - -enum -{ - ROW_TITLE = 1, - ROW_SIZE, - ROW_DATE_MOD, - ROW_DATE_CREATE, - ROW_TARGET_URL, - ROW_IS_HIDDEN, - ROW_IS_REMOTE, - ROW_IS_REMOVABLE -}; - -TemplateRemoteView::TemplateRemoteView (vcl::Window *pParent, WinBits nWinStyle, bool bDisableTransientChildren) - : TemplateAbstractView(pParent,nWinStyle,bDisableTransientChildren) -{ - Reference< XComponentContext > xContext = comphelper::getProcessComponentContext(); - Reference< XInteractionHandler > xGlobalInteractionHandler( - InteractionHandler::createWithParent(xContext, nullptr), UNO_QUERY_THROW ); - - m_xCmdEnv = new ucbhelper::CommandEnvironment( xGlobalInteractionHandler, Reference< XProgressHandler >() ); -} - -VCL_BUILDER_DECL_FACTORY(TemplateRemoteView) -{ - (void)rMap; - rRet = VclPtr<TemplateRemoteView>::Create(pParent, WB_VSCROLL, false); -} - -void TemplateRemoteView::showRegion(TemplateContainerItem * /*pItem*/) -{ - //TODO: -} - -void TemplateRemoteView::showAllTemplates() -{ - //TODO: -} - -bool TemplateRemoteView::loadRepository (TemplateRepository* pItem) -{ - if (!pItem) - return false; - - if (!pItem->getTemplates().empty()) - { - insertItems(pItem->getTemplates()); - return true; - } - - mnCurRegionId = pItem->mnId; - maCurRegionName = pItem->maTitle; - - OUString aURL = pItem->getURL(); - - try - { - - uno::Sequence<OUString> aProps(8); - - aProps[0] = "Title"; - aProps[1] = "Size"; - aProps[2] = "DateModified"; - aProps[3] = "DateCreated"; - aProps[4] = "TargetURL"; - aProps[5] = "IsHidden"; - aProps[6] = "IsRemote"; - aProps[7] = "IsRemoveable"; - - ucbhelper::Content aContent(aURL, m_xCmdEnv, comphelper::getProcessComponentContext()); - - uno::Reference< XResultSet > xResultSet; - uno::Reference< XDynamicResultSet > xDynResultSet; - - ucbhelper::ResultSetInclude eInclude = ucbhelper::INCLUDE_FOLDERS_AND_DOCUMENTS; - xDynResultSet = aContent.createDynamicCursor( aProps, eInclude ); - - if ( xDynResultSet.is() ) - xResultSet = xDynResultSet->getStaticResultSet(); - - if ( xResultSet.is() ) - { - pItem->clearTemplates(); - - uno::Reference< XRow > xRow( xResultSet, UNO_QUERY ); - uno::Reference< XContentAccess > xContentAccess( xResultSet, UNO_QUERY ); - - std::vector<TemplateItemProperties> aItems; - - sal_uInt16 nIdx = 0; - while ( xResultSet->next() ) - { - bool bIsHidden = xRow->getBoolean( ROW_IS_HIDDEN ); - - // don't show hidden files or anything besides documents - if ( !bIsHidden || xRow->wasNull() ) - { - OUString aContentURL = xContentAccess->queryContentIdentifierString(); - OUString aTargetURL = xRow->getString( ROW_TARGET_URL ); - bool bHasTargetURL = !xRow->wasNull() && !aTargetURL.isEmpty(); - - OUString sRealURL = bHasTargetURL ? aTargetURL : aContentURL; - - TemplateItemProperties aTemplateItem; - aTemplateItem.nId = nIdx+1; - aTemplateItem.nRegionId = pItem->mnId-1; - aTemplateItem.aPath = sRealURL; - aTemplateItem.aThumbnail = TemplateAbstractView::fetchThumbnail(sRealURL, - TEMPLATE_THUMBNAIL_MAX_WIDTH, - TEMPLATE_THUMBNAIL_MAX_HEIGHT); - aTemplateItem.aName = xRow->getString( ROW_TITLE ); - - pItem->insertTemplate(aTemplateItem); - aItems.push_back(aTemplateItem); - ++nIdx; - } - } - - insertItems(aItems); - } - } - catch( ucb::CommandAbortedException& ) - { - } - catch( uno::RuntimeException& ) - { - } - catch( uno::Exception& ) - { - } - - return true; -} - -sal_uInt16 TemplateRemoteView::createRegion(const OUString &/*rName*/) -{ - // TODO: Create new folder in current remote repository - return 0; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index e7f5d0658c2e..1f97776da105 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -24,15 +24,12 @@ #include <sfx2/sfxresid.hxx> #include <sfx2/templatelocalview.hxx> #include <sfx2/templatecontaineritem.hxx> -#include <sfx2/templateremoteview.hxx> -#include <sfx2/templaterepository.hxx> #include <sfx2/templateviewitem.hxx> #include <sfx2/thumbnailviewitem.hxx> #include <sot/storage.hxx> #include <svtools/imagemgr.hxx> #include <svtools/langhelp.hxx> #include <svtools/miscopt.hxx> -#include <svtools/PlaceEditDialog.hxx> #include <tools/urlobj.hxx> #include <unotools/moduleoptions.hxx> #include <unotools/pathoptions.hxx> @@ -40,6 +37,7 @@ #include <vcl/edit.hxx> #include <vcl/layout.hxx> #include <vcl/toolbox.hxx> +#include <vcl/lstbox.hxx> #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/configuration/theDefaultProvider.hpp> @@ -67,7 +65,6 @@ const char TM_SETTING_LASTAPPLICATION[] = "LastApplication"; const char SERVICENAME_CFGREADACCESS[] = "com.sun.star.configuration.ConfigurationAccess"; -const char ACTIONBAR_REPOSITORY[] = "repository"; const char ACTIONBAR_ACTION[] = "action_menu"; #define MNI_ACTION_NEW_FOLDER 1 @@ -75,9 +72,6 @@ const char ACTIONBAR_ACTION[] = "action_menu"; #define MNI_ACTION_DELETE_FOLDER 3 #define MNI_ACTION_REFRESH 4 #define MNI_ACTION_DEFAULT 5 -#define MNI_REPOSITORY_LOCAL 1 -#define MNI_REPOSITORY_NEW 2 -#define MNI_REPOSITORY_BASE 3 #define MNI_WRITER 1 #define MNI_CALC 2 #define MNI_IMPRESS 3 @@ -160,9 +154,7 @@ static bool cmpSelectionItems (const ThumbnailViewItem *pItem1, const ThumbnailV SfxTemplateManagerDlg::SfxTemplateManagerDlg(vcl::Window *parent) : ModalDialog(parent, "TemplateDialog", "sfx/ui/templatedlg.ui"), - maSelTemplates(cmpSelectionItems), - mxDesktop( Desktop::create(comphelper::getProcessComponentContext()) ), - maRepositories() + maSelTemplates(cmpSelectionItems) { get(mpSearchFilter, "search_filter"); get(mpCBApp, "filter_application"); @@ -170,7 +162,6 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg(vcl::Window *parent) get(mpActionBar, "action_action"); get(mpLocalView, "template_view"); get(mpSearchView, "search_view"); - get(mpRemoteView, "remote_view"); get(mpOKButton, "ok"); get(mpMoveButton, "move_btn"); get(mpExportButton, "export_btn"); @@ -194,18 +185,11 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg(vcl::Window *parent) mpActionMenu->InsertItem(MNI_ACTION_DEFAULT,SfxResId(STR_ACTION_DEFAULT).toString()); mpActionMenu->SetSelectHdl(LINK(this,SfxTemplateManagerDlg,MenuSelectHdl)); - mpRepositoryMenu = VclPtr<PopupMenu>::Create(); - mpRepositoryMenu->SetSelectHdl(LINK(this,SfxTemplateManagerDlg,RepositoryMenuSelectHdl)); - mpTemplateDefaultMenu = VclPtr<PopupMenu>::Create(); mpTemplateDefaultMenu->SetSelectHdl(LINK(this,SfxTemplateManagerDlg,DefaultTemplateMenuSelectHdl)); mpActionMenu->SetPopupMenu(MNI_ACTION_DEFAULT,mpTemplateDefaultMenu); - // Set toolbox styles - mpActionBar->SetButtonType(ButtonType::SYMBOLTEXT); - // Set toolbox button bits - mpActionBar->SetItemBits(mpActionBar->GetItemId(ACTIONBAR_REPOSITORY), ToolBoxItemBits::DROPDOWNONLY); mpActionBar->SetItemBits(mpActionBar->GetItemId(ACTIONBAR_ACTION), ToolBoxItemBits::DROPDOWNONLY); // Set toolbox handlers @@ -226,17 +210,6 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg(vcl::Window *parent) mpLocalView->setDeleteTemplateHdl(LINK(this,SfxTemplateManagerDlg, DeleteTemplateHdl)); mpLocalView->setDefaultTemplateHdl(LINK(this,SfxTemplateManagerDlg, DefaultTemplateHdl)); - // Set online view position and dimensions - mpRemoteView->setItemMaxTextLength(TEMPLATE_ITEM_MAX_TEXT_LENGTH); - - mpRemoteView->setItemDimensions(TEMPLATE_ITEM_MAX_WIDTH,TEMPLATE_ITEM_THUMBNAIL_MAX_HEIGHT, - TEMPLATE_ITEM_MAX_HEIGHT-TEMPLATE_ITEM_THUMBNAIL_MAX_HEIGHT, - TEMPLATE_ITEM_PADDING); - - mpRemoteView->setItemStateHdl(LINK(this,SfxTemplateManagerDlg,TVItemStateHdl)); - mpRemoteView->setOpenRegionHdl(LINK(this,SfxTemplateManagerDlg,OpenRegionHdl)); - mpRemoteView->setOpenTemplateHdl(LINK(this,SfxTemplateManagerDlg,OpenTemplateHdl)); - mpSearchView->setItemMaxTextLength(TEMPLATE_ITEM_MAX_TEXT_LENGTH); mpSearchView->setItemDimensions(TEMPLATE_ITEM_MAX_WIDTH,TEMPLATE_ITEM_THUMBNAIL_MAX_HEIGHT, @@ -263,24 +236,12 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg(vcl::Window *parent) mpSearchFilter->EnableUpdateData(); mpSearchFilter->SetGetFocusHdl(LINK( this, SfxTemplateManagerDlg, GetFocusHdl )); - SvtMiscOptions aMiscOptions; - if ( !aMiscOptions.IsExperimentalMode() ) - { - sal_uInt16 nPos = mpActionBar->GetItemPos(mpActionBar->GetItemId(ACTIONBAR_REPOSITORY)); - mpActionBar->RemoveItem(nPos); - } - mpActionBar->Show(); - switchMainView(true); - - loadRepositories(); - - createRepositoryMenu(); createDefaultTemplateMenu(); mpLocalView->Populate(); - mpCurView->filterItems(ViewFilter_Application(FILTER_APPLICATION::NONE)); + mpLocalView->filterItems(ViewFilter_Application(FILTER_APPLICATION::NONE)); mpCBApp->SelectEntryPos(0); fillFolderComboBox(); @@ -304,20 +265,11 @@ void SfxTemplateManagerDlg::dispose() { writeSettings(); - // Synchronize the config before deleting it - syncRepositories(); - for (TemplateRepository* p : maRepositories) - delete p; - // Ignore view events since we are cleaning the object mpLocalView->setItemStateHdl(Link<const ThumbnailViewItem*,void>()); mpLocalView->setOpenRegionHdl(Link<void*,void>()); mpLocalView->setOpenTemplateHdl(Link<ThumbnailViewItem*, void>()); - mpRemoteView->setItemStateHdl(Link<const ThumbnailViewItem*,void>()); - mpRemoteView->setOpenRegionHdl(Link<void*,void>()); - mpRemoteView->setOpenTemplateHdl(Link<ThumbnailViewItem*,void>()); - mpSearchView->setItemStateHdl(Link<const ThumbnailViewItem*,void>()); mpSearchView->setOpenTemplateHdl(Link<ThumbnailViewItem*, void>()); @@ -332,9 +284,8 @@ void SfxTemplateManagerDlg::dispose() mpCBFolder.clear(); mpActionBar.clear(); mpSearchView.clear(); - mpCurView.clear(); mpLocalView.clear(); - mpRemoteView.clear(); + ModalDialog::dispose(); } @@ -388,7 +339,7 @@ void SfxTemplateManagerDlg::getApplicationSpecificSettings() mpCBApp->SelectEntryPos(0); mpCBFolder->SelectEntryPos(0); mpActionMenu->HideItem(MNI_ACTION_RENAME_FOLDER); - mpCurView->filterItems(ViewFilter_Application(getCurrentApplicationFilter())); + mpLocalView->filterItems(ViewFilter_Application(getCurrentApplicationFilter())); mpLocalView->showAllTemplates(); return; } @@ -416,7 +367,7 @@ void SfxTemplateManagerDlg::getApplicationSpecificSettings() break; } - mpCurView->filterItems(ViewFilter_Application(getCurrentApplicationFilter())); + mpLocalView->filterItems(ViewFilter_Application(getCurrentApplicationFilter())); mpCBFolder->SelectEntryPos(0); mpActionMenu->HideItem(MNI_ACTION_RENAME_FOLDER); mpLocalView->showAllTemplates(); @@ -457,7 +408,7 @@ void SfxTemplateManagerDlg::readSettings () } } - mpCurView->filterItems(ViewFilter_Application(getCurrentApplicationFilter())); + mpLocalView->filterItems(ViewFilter_Application(getCurrentApplicationFilter())); if (aLastFolder.isEmpty()) { @@ -478,7 +429,7 @@ void SfxTemplateManagerDlg::writeSettings () { OUString aLastFolder; - if (mpCurView == mpLocalView && mpLocalView->getCurRegionId()) + if (mpLocalView->getCurRegionId()) aLastFolder = mpLocalView->getRegionName(mpLocalView->getCurRegionId()-1); // last folder @@ -495,10 +446,10 @@ void SfxTemplateManagerDlg::writeSettings () IMPL_LINK_NOARG_TYPED(SfxTemplateManagerDlg, SelectApplicationHdl, ListBox&, void) { - if(mpCurView == mpLocalView && mpCurView->IsVisible()) + if(mpLocalView->IsVisible()) { - mpCurView->filterItems(ViewFilter_Application(getCurrentApplicationFilter())); - mpCurView->showAllTemplates(); + mpLocalView->filterItems(ViewFilter_Application(getCurrentApplicationFilter())); + mpLocalView->showAllTemplates(); mpCBFolder->SelectEntryPos(0); mpActionMenu->HideItem(MNI_ACTION_RENAME_FOLDER); } @@ -509,19 +460,17 @@ IMPL_LINK_NOARG_TYPED(SfxTemplateManagerDlg, SelectApplicationHdl, ListBox&, voi IMPL_LINK_NOARG_TYPED(SfxTemplateManagerDlg, SelectRegionHdl, ListBox&, void) { - if(mpCurView == mpLocalView) + const OUString sSelectedRegion = mpCBFolder->GetSelectEntry(); + + if(mpCBFolder->GetSelectEntryPos() == 0) { - const OUString sSelectedRegion = mpCBFolder->GetSelectEntry(); - if(mpCBFolder->GetSelectEntryPos() == 0) - { - mpLocalView->showAllTemplates(); - mpActionMenu->HideItem(MNI_ACTION_RENAME_FOLDER); - } - else - { - mpLocalView->showRegion(sSelectedRegion); - mpActionMenu->ShowItem(MNI_ACTION_RENAME_FOLDER); - } + mpLocalView->showAllTemplates(); + mpActionMenu->HideItem(MNI_ACTION_RENAME_FOLDER); + } + else + { + mpLocalView->showRegion(sSelectedRegion); + mpActionMenu->ShowItem(MNI_ACTION_RENAME_FOLDER); } if(mpSearchView->IsVisible()) @@ -535,8 +484,6 @@ IMPL_LINK_NOARG_TYPED(SfxTemplateManagerDlg, TBXDropdownHdl, ToolBox*, void) if (nCurItemId == mpActionBar->GetItemId(ACTIONBAR_ACTION)) mpActionMenu->Execute(mpActionBar, mpActionBar->GetItemRect(nCurItemId), PopupMenuFlags::ExecuteDown); - else if (nCurItemId == mpActionBar->GetItemId(ACTIONBAR_REPOSITORY)) - mpRepositoryMenu->Execute(mpActionBar, mpActionBar->GetItemRect(nCurItemId), PopupMenuFlags::ExecuteDown); mpActionBar->SetItemDown( nCurItemId, false ); mpActionBar->EndSelection(); @@ -567,7 +514,7 @@ IMPL_LINK_TYPED(SfxTemplateManagerDlg, MenuSelectHdl, Menu*, pMenu, bool) OnCategoryDelete(); break; case MNI_ACTION_REFRESH: - mpCurView->reload(); + mpLocalView->reload(); break; default: break; @@ -576,57 +523,6 @@ IMPL_LINK_TYPED(SfxTemplateManagerDlg, MenuSelectHdl, Menu*, pMenu, bool) return false; } -IMPL_LINK_TYPED(SfxTemplateManagerDlg, RepositoryMenuSelectHdl, Menu*, pMenu, bool) -{ - sal_uInt16 nMenuId = pMenu->GetCurItemId(); - - if (nMenuId == MNI_REPOSITORY_LOCAL) - { - switchMainView(true); - } - else if (nMenuId == MNI_REPOSITORY_NEW) - { - ScopedVclPtrInstance< PlaceEditDialog > dlg(this); - - if (dlg->Execute()) - { - std::shared_ptr<Place> xPlace = dlg->GetPlace(); - - if (insertRepository(xPlace->GetName(), xPlace->GetUrl())) - { - // update repository list menu. - createRepositoryMenu(); - } - else - { - OUString aMsg(SfxResId(STR_MSG_ERROR_REPOSITORY_NAME).toString()); - aMsg = aMsg.replaceFirst("$1", xPlace->GetName()); - ScopedVclPtrInstance<MessageDialog>(this, aMsg)->Execute(); - } - } - } - else - { - sal_uInt16 nRepoId = nMenuId - MNI_REPOSITORY_BASE; - - TemplateRepository *pRepository = nullptr; - - for (TemplateRepository* p : maRepositories) - { - if (p->mnId == nRepoId) - { - pRepository = p; - break; - } - } - - if (mpRemoteView->loadRepository(pRepository)) - switchMainView(false); - } - - return false; -} - IMPL_LINK_TYPED(SfxTemplateManagerDlg, DefaultTemplateMenuSelectHdl, Menu*, pMenu, bool) { sal_uInt16 nId = pMenu->GetCurItemId(); @@ -672,27 +568,15 @@ IMPL_LINK_NOARG_TYPED(SfxTemplateManagerDlg, MoveClickHdl, Button*, void) } } else - { nItemId = mpLocalView->getRegionId(sCategory); - } } if(nItemId) { if (mpSearchView->IsVisible()) - { - // Check if we are searching the local or remote templates - if (mpCurView == mpLocalView) - localSearchMoveTo(nItemId); - } + localSearchMoveTo(nItemId); else - { - // Check if we are displaying the local or remote templates - if (mpCurView == mpLocalView) - localMoveTo(nItemId); - else - remoteMoveTo(nItemId); - } + localMoveTo(nItemId); } mpLocalView->reload(); @@ -715,7 +599,7 @@ IMPL_LINK_NOARG_TYPED(SfxTemplateManagerDlg, ImportClickHdl, Button*, void) bool bIsNewCategory = aDlg->IsNewCategoryCreated(); if(bIsNewCategory) { - if(mpCurView->createRegion(sCategory)) + if(mpLocalView->createRegion(sCategory)) { mpCBFolder->InsertEntry(sCategory); OnTemplateImportCategory(sCategory); @@ -756,13 +640,10 @@ IMPL_LINK_TYPED(SfxTemplateManagerDlg, CreateContextMenuHdl, ThumbnailViewItem*, if (pViewItem) { - if(mpCurView == mpLocalView) - { - if(mpSearchView->IsVisible()) - mpSearchView->createContextMenu(pViewItem->IsDefaultTemplate()); - else - mpLocalView->createContextMenu(pViewItem->IsDefaultTemplate()); - } + if(mpSearchView->IsVisible()) + mpSearchView->createContextMenu(pViewItem->IsDefaultTemplate()); + else + mpLocalView->createContextMenu(pViewItem->IsDefaultTemplate()); } } @@ -888,9 +769,9 @@ IMPL_LINK_NOARG_TYPED(SfxTemplateManagerDlg, SearchUpdateHdl, Edit&, void) // if the search view is hidden, hide the folder view and display search one if (!mpSearchView->IsVisible()) { - mpCurView->deselectItems(); + mpLocalView->deselectItems(); mpSearchView->Show(); - mpCurView->Hide(); + mpLocalView->Hide(); } std::vector<TemplateItemProperties> aItems = @@ -916,21 +797,20 @@ IMPL_LINK_NOARG_TYPED(SfxTemplateManagerDlg, SearchUpdateHdl, Edit&, void) { mpSearchView->deselectItems(); mpSearchView->Hide(); - mpCurView->Show(); - mpCurView->filterItems(ViewFilter_Application(getCurrentApplicationFilter())); - if(mpCurView == mpLocalView) - { - mpLocalView->reload(); - OUString sLastFolder = mpCBFolder->GetSelectEntry(); - mpLocalView->showRegion(sLastFolder); - mpActionMenu->ShowItem(MNI_ACTION_RENAME_FOLDER); - } + mpLocalView->Show(); + mpLocalView->filterItems(ViewFilter_Application(getCurrentApplicationFilter())); + mpLocalView->reload(); + OUString sLastFolder = mpCBFolder->GetSelectEntry(); + mpLocalView->showRegion(sLastFolder); + mpActionMenu->ShowItem(MNI_ACTION_RENAME_FOLDER); } } IMPL_LINK_NOARG_TYPED(SfxTemplateManagerDlg, GetFocusHdl, Control&, void) { - mpCurView->deselectItems(); + mpLocalView->deselectItems(); + mpSearchView->deselectItems(); + maSelTemplates.clear(); } @@ -1215,7 +1095,7 @@ void SfxTemplateManagerDlg::OnCategoryNew() { OUString aName = dlg->GetEntryText(); - if(mpCurView->createRegion(aName)) + if(mpLocalView->createRegion(aName)) mpCBFolder->InsertEntry(aName); else { @@ -1293,21 +1173,6 @@ void SfxTemplateManagerDlg::OnCategoryDelete() mpActionMenu->HideItem(MNI_ACTION_RENAME_FOLDER); } -void SfxTemplateManagerDlg::createRepositoryMenu() -{ - mpRepositoryMenu->Clear(); - - mpRepositoryMenu->InsertItem(MNI_REPOSITORY_LOCAL,SfxResId(STR_REPOSITORY_LOCAL).toString()); - - const std::vector<TemplateRepository*> &rRepos = getRepositories(); - - for (const TemplateRepository* pRepo : rRepos) - mpRepositoryMenu->InsertItem(MNI_REPOSITORY_BASE+pRepo->mnId, pRepo->maTitle); - - mpRepositoryMenu->InsertSeparator(); - mpRepositoryMenu->InsertItem(MNI_REPOSITORY_NEW,SfxResId(STR_REPOSITORY_NEW).toString()); -} - void SfxTemplateManagerDlg::createDefaultTemplateMenu () { std::vector<OUString> aList = lcl_getAllFactoryURLs(); @@ -1331,23 +1196,6 @@ void SfxTemplateManagerDlg::createDefaultTemplateMenu () mpActionMenu->HideItem(MNI_ACTION_DEFAULT); } -void SfxTemplateManagerDlg::switchMainView(bool bDisplayLocal) -{ - if (bDisplayLocal) - { - mpCurView = mpLocalView.get(); - - mpRemoteView->Hide(); - mpLocalView->Show(); - } - else - { - mpCurView = mpRemoteView.get(); - mpLocalView->Hide(); - mpRemoteView->Show(); - } -} - void SfxTemplateManagerDlg::localMoveTo(sal_uInt16 nItemId) { if (nItemId) @@ -1358,39 +1206,6 @@ void SfxTemplateManagerDlg::localMoveTo(sal_uInt16 nItemId) } } -void SfxTemplateManagerDlg::remoteMoveTo(const sal_uInt16 nItemId) -{ - if (nItemId) - { - OUString aTemplateList; - - std::set<const ThumbnailViewItem*,selection_cmp_fn>::const_iterator aIter; - for (aIter = maSelTemplates.begin(); aIter != maSelTemplates.end(); ++aIter) - { - const TemplateSearchViewItem *pItem = - static_cast<const TemplateSearchViewItem*>(*aIter); - - if(!mpLocalView->copyFrom(nItemId,pItem->maPreview1,pItem->getPath())) - { - if (aTemplateList.isEmpty()) - aTemplateList = pItem->maTitle; - else - aTemplateList = aTemplateList + "\n" + pItem->maTitle; - } - } - - mpLocalView->Invalidate(InvalidateFlags::NoErase); - - if (!aTemplateList.isEmpty()) - { - OUString aMsg(SfxResId(STR_MSG_ERROR_REMOTE_MOVE).toString()); - aMsg = aMsg.replaceFirst("$1",mpRemoteView->getCurRegionName()); - aMsg = aMsg.replaceFirst("$2",mpLocalView->getRegionItemName(nItemId)); - ScopedVclPtrInstance<MessageDialog>::Create(this, aMsg.replaceFirst("$1",aTemplateList))->Execute(); - } - } -} - void SfxTemplateManagerDlg::localSearchMoveTo(sal_uInt16 nItemId) { if (nItemId) @@ -1421,68 +1236,6 @@ void SfxTemplateManagerDlg::localSearchMoveTo(sal_uInt16 nItemId) SearchUpdateHdl(*mpSearchFilter); } -void SfxTemplateManagerDlg::loadRepositories() -{ - uno::Reference< uno::XComponentContext > xContext(comphelper::getProcessComponentContext()); - - // Load from user settings - css::uno::Sequence<OUString> aUrls = - officecfg::Office::Common::Misc::TemplateRepositoryUrls::get(xContext); - - css::uno::Sequence<OUString> aNames = - officecfg::Office::Common::Misc::TemplateRepositoryNames::get(xContext); - - for (sal_Int32 i = 0; i < aUrls.getLength() && i < aNames.getLength(); ++i) - { - TemplateRepository *pItem = new TemplateRepository(); - - pItem->mnId = i+1; - pItem->maTitle = aNames[i]; - pItem->setURL(aUrls[i]); - - maRepositories.push_back(pItem); - } -} - -bool SfxTemplateManagerDlg::insertRepository(const OUString &rName, const OUString &rURL) -{ - for (TemplateRepository* pRepo : maRepositories) - { - if (pRepo->maTitle == rName) - return false; - } - - TemplateRepository *pItem = new TemplateRepository(); - - pItem->mnId = maRepositories.size()+1; - pItem->maTitle = rName; - pItem->setURL(rURL); - - maRepositories.push_back(pItem); - - return true; -} - -void SfxTemplateManagerDlg::syncRepositories() const -{ - uno::Reference < uno::XComponentContext > pContext(comphelper::getProcessComponentContext()); - std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create(pContext)); - - size_t nSize = maRepositories.size(); - uno::Sequence<OUString> aUrls(nSize); - uno::Sequence<OUString> aNames(nSize); - - for(size_t i = 0; i < nSize; ++i) - { - aUrls[i] = maRepositories[i]->getURL(); - aNames[i] = maRepositories[i]->maTitle; - } - - officecfg::Office::Common::Misc::TemplateRepositoryUrls::set(aUrls, batch); - officecfg::Office::Common::Misc::TemplateRepositoryNames::set(aNames, batch); - batch->commit(); -} - static bool lcl_getServiceName ( const OUString &rFileURL, OUString &rName ) { bool bRet = false; |