diff options
-rw-r--r-- | extras/source/glade/libreoffice-catalog.xml.in | 3 | ||||
-rw-r--r-- | include/sfx2/templatedlg.hxx | 21 | ||||
-rw-r--r-- | include/sfx2/templateremoteview.hxx | 42 | ||||
-rw-r--r-- | include/sfx2/templaterepository.hxx | 46 | ||||
-rw-r--r-- | sfx2/Library_sfx.mk | 1 | ||||
-rw-r--r-- | sfx2/source/control/templateremoteview.cxx | 174 | ||||
-rw-r--r-- | sfx2/source/doc/templatedlg.cxx | 329 | ||||
-rw-r--r-- | sfx2/uiconfig/ui/templatedlg.ui | 28 |
8 files changed, 41 insertions, 603 deletions
diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in index f79b89c35412..e1117edb3d60 100644 --- a/extras/source/glade/libreoffice-catalog.xml.in +++ b/extras/source/glade/libreoffice-catalog.xml.in @@ -773,9 +773,6 @@ <glade-widget-class title="Template Search View" name="sfxlo-TemplateSearchView" generic-name="Template Icon View" parent="GtkIconView" icon-name="widget-gtk-iconview"/> - <glade-widget-class title="Template Remote View" name="sfxlo-TemplateRemoteView" - generic-name="Template Icon View" parent="GtkIconView" - icon-name="widget-gtk-iconview"/> <glade-widget-class title="Driver List Control" name="cuilo-DriverListControl" generic-name="DriverListControl" parent="GtkEntry" diff --git a/include/sfx2/templatedlg.hxx b/include/sfx2/templatedlg.hxx index 5e3bce04c336..765c959c153b 100644 --- a/include/sfx2/templatedlg.hxx +++ b/include/sfx2/templatedlg.hxx @@ -25,8 +25,6 @@ class Edit; class PopupMenu; class TemplateAbstractView; class TemplateLocalView; -class TemplateRemoteView; -class TemplateRepository; class TemplateSearchView; class ThumbnailView; class ThumbnailViewItem; @@ -77,7 +75,6 @@ protected: DECL_LINK_TYPED(TVItemStateHdl, const ThumbnailViewItem*, void); DECL_LINK_TYPED(MenuSelectHdl, Menu*, bool); - DECL_LINK_TYPED(RepositoryMenuSelectHdl, Menu*, bool); DECL_LINK_TYPED(DefaultTemplateMenuSelectHdl, Menu*, bool); DECL_LINK_TYPED(OpenRegionHdl, void*, void); @@ -101,8 +98,6 @@ protected: void OnCategoryRename(); void OnCategoryDelete(); - void createRepositoryMenu (); - void createDefaultTemplateMenu (); // Exchange view between local/online view. @@ -116,8 +111,6 @@ protected: void localMoveTo (sal_uInt16 nMenuId); - void remoteMoveTo (const sal_uInt16 nMenuId); - /** * * Move search result templates stored in the filesystem to another folder. @@ -126,15 +119,6 @@ protected: void localSearchMoveTo (sal_uInt16 nMenuId); - // Remote repositories handling methods - void loadRepositories (); - - const std::vector<TemplateRepository*>& getRepositories () const { return maRepositories; } - - bool insertRepository (const OUString &rName, const OUString &rURL); - - void syncRepositories () const; - /// Return filter according to the currently selected application filter. FILTER_APPLICATION getCurrentApplicationFilter(); @@ -152,19 +136,14 @@ protected: VclPtr<CheckBox> mpCBXHideDlg; VclPtr<ToolBox> mpActionBar; VclPtr<TemplateSearchView> mpSearchView; - VclPtr<TemplateAbstractView> mpCurView; VclPtr<TemplateLocalView> mpLocalView; - VclPtr<TemplateRemoteView> mpRemoteView; VclPtr<PopupMenu> mpActionMenu; - VclPtr<PopupMenu> mpRepositoryMenu; VclPtr<PopupMenu> mpTemplateDefaultMenu; std::set<const ThumbnailViewItem*,selection_cmp_fn> maSelTemplates; css::uno::Reference< css::frame::XModel > m_xModel; css::uno::Reference< css::frame::XDesktop2 > mxDesktop; - - std::vector<TemplateRepository*> maRepositories; ///< Stores the remote repositories for templates }; // class SfxTemplateCategoryDialog ------------------------------------------------------------------- diff --git a/include/sfx2/templateremoteview.hxx b/include/sfx2/templateremoteview.hxx deleted file mode 100644 index 067ef0ad7f64..000000000000 --- a/include/sfx2/templateremoteview.hxx +++ /dev/null @@ -1,42 +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/. - */ - -#ifndef INCLUDED_SFX2_TEMPLATEREMOTEVIEW_HXX -#define INCLUDED_SFX2_TEMPLATEREMOTEVIEW_HXX - -#include <sfx2/templateabstractview.hxx> -#include <sfx2/templateproperties.hxx> - -#include <com/sun/star/ucb/XCommandEnvironment.hpp> - -class TemplateRepository; - -class TemplateRemoteView : public TemplateAbstractView -{ -public: - - TemplateRemoteView (vcl::Window *pParent, WinBits nWinStyle, bool bDisableTransientChildren); - - virtual void showAllTemplates () override; - - virtual void showRegion (TemplateContainerItem *pItem) override; - - bool loadRepository (TemplateRepository* pRepository); - - virtual sal_uInt16 createRegion (const OUString &rName) override; - -private: - - css::uno::Reference< css::ucb::XCommandEnvironment > m_xCmdEnv; -}; - -#endif // INCLUDED_SFX2_TEMPLATEREMOTEVIEW_HXX - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/templaterepository.hxx b/include/sfx2/templaterepository.hxx deleted file mode 100644 index ac502f5d1eb8..000000000000 --- a/include/sfx2/templaterepository.hxx +++ /dev/null @@ -1,46 +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/. - */ - -#ifndef INCLUDED_SFX2_TEMPLATEREPOSITORY_HXX -#define INCLUDED_SFX2_TEMPLATEREPOSITORY_HXX - -#include <sfx2/templateproperties.hxx> - -class TemplateRepository -{ -public: - - TemplateRepository () : mnId(0) { }; - - virtual ~TemplateRepository () { }; - - void setURL (const OUString &rURL) { maUrl = rURL; } - - const OUString& getURL () const { return maUrl; } - - void insertTemplate (const TemplateItemProperties &prop) { maTemplates.push_back(prop); } - - void clearTemplates () { maTemplates.clear(); } - - const std::vector<TemplateItemProperties>& getTemplates () const { return maTemplates; } - -public: - - sal_uInt16 mnId; - OUString maTitle; - -private: - - OUString maUrl; - std::vector<TemplateItemProperties> maTemplates; -}; - -#endif // INCLUDED_SFX2_TEMPLATEREPOSITORY_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk index 696402b6eb0b..2cbeb2673ca1 100644 --- a/sfx2/Library_sfx.mk +++ b/sfx2/Library_sfx.mk @@ -155,7 +155,6 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\ sfx2/source/control/templateviewitem \ sfx2/source/control/templatelocalview \ sfx2/source/control/templatecontaineritem \ - sfx2/source/control/templateremoteview \ sfx2/source/control/templatesearchview \ sfx2/source/control/thumbnailviewitem \ sfx2/source/control/thumbnailviewacc \ 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; diff --git a/sfx2/uiconfig/ui/templatedlg.ui b/sfx2/uiconfig/ui/templatedlg.ui index 4c7bdf0741e4..c4624f0d4c6a 100644 --- a/sfx2/uiconfig/ui/templatedlg.ui +++ b/sfx2/uiconfig/ui/templatedlg.ui @@ -263,20 +263,6 @@ <property name="position">3</property> </packing> </child> - <child> - <object class="sfxlo-TemplateRemoteView" id="remote_view"> - <property name="can_focus">True</property> - <property name="no_show_all">True</property> - <property name="margin">0</property> - <property name="hexpand">True</property> - <property name="vexpand">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">4</property> - </packing> - </child> </object> <packing> <property name="expand">False</property> @@ -301,20 +287,6 @@ <property name="halign">end</property> <property name="hexpand">True</property> <child> - <object class="GtkToolButton" id="repository"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="action_name">repository</property> - <property name="label" translatable="yes">Repository</property> - <property name="use_underline">True</property> - <property name="icon_name">sfx2/imglst/actionview026.png</property> - </object> - <packing> - <property name="expand">False</property> - <property name="homogeneous">True</property> - </packing> - </child> - <child> <object class="GtkToolButton" id="action_menu"> <property name="visible">True</property> <property name="can_focus">False</property> |