diff options
author | Efe Gürkan YALAMAN <efeyalaman@gmail.com> | 2014-06-02 01:42:37 +0300 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2014-08-14 22:20:24 +0200 |
commit | 507b68aba74c40bd362b50a9a854daf2746bd4e7 (patch) | |
tree | 16dfd6fb3d7691c3f7925ba4227fa908a874f426 /sfx2 | |
parent | 031f11ee3b3cefe2814744a6d854857652f81e51 (diff) |
Some handlers and buttons moved
Some more handlers and buttons moved. Still not usable mostly.
Change-Id: I19c9c36a490030369b4e8d84b41f6d2962665426
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/dialog/backingwindow.cxx | 217 | ||||
-rw-r--r-- | sfx2/source/dialog/backingwindow.hxx | 12 |
2 files changed, 221 insertions, 8 deletions
diff --git a/sfx2/source/dialog/backingwindow.cxx b/sfx2/source/dialog/backingwindow.cxx index 81d6b48cec07..78ba0290377e 100644 --- a/sfx2/source/dialog/backingwindow.cxx +++ b/sfx2/source/dialog/backingwindow.cxx @@ -27,6 +27,12 @@ #include <svtools/openfiledroptargetlistener.hxx> #include <svtools/colorcfg.hxx> #include <svtools/langhelp.hxx> +#include <sfx2/filedlghelper.hxx> +#include <sfx2/sfxresid.hxx> +#include <sfx2/templatecontaineritem.hxx> +#include <vcl/msgbox.hxx> +#include <vcl/toolbox.hxx> + #include <comphelper/processfactory.hxx> #include <comphelper/sequenceashashmap.hxx> @@ -43,6 +49,10 @@ #include <com/sun/star/system/SystemShellExecuteFlags.hpp> #include <com/sun/star/util/URLTransformer.hpp> #include <com/sun/star/task/InteractionHandler.hpp> +#include <com/sun/star/ui/dialogs/TemplateDescription.hpp> + +//well find a better way for it. +#include "../doc/doc.hrc" using namespace ::com::sun::star; using namespace ::com::sun::star::beans; @@ -241,11 +251,18 @@ void BackingWindow::initControls() mpLocalView->Hide(); mpLocalView->filterItems(ViewFilter_Application(FILTER_APP_NONE)); + mpCurrentView = mpLocalView; + mpViewBar->SetButtonType(BUTTON_SYMBOLTEXT); mpViewBar->SetItemBits(mpViewBar->GetItemId("repository"), TIB_DROPDOWNONLY); - //mpViewBar->SetClickHdl(LINK(this,BackingWindow,TBXViewHdl)); + mpViewBar->SetClickHdl(LINK(this,BackingWindow,TBXViewHdl)); //mpViewBar->SetDropdownClickHdl(LINK(this,BackingWindow,TBXDropdownHdl)); mpViewBar->Hide(); + + //set handlers + mpLocalView->setItemStateHdl(LINK(this, BackingWindow, TVItemStateHdl)); + mpLocalView->setOpenRegionHdl(LINK(this, BackingWindow, OpenRegionHdl)); + /*FIXME: Add other things for Local View *Filter and the bars*/ @@ -439,6 +456,154 @@ void BackingWindow::Resize() Invalidate(); } +void BackingWindow::OnTemplateImport () +{ + size_t nDialogType = + com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE; + + sfx2::FileDialogHelper aFileDlg(nDialogType, SFXWB_MULTISELECTION); + + // add "All" filter + aFileDlg.AddFilter( SfxResId(STR_SFX_FILTERNAME_ALL).toString(), + OUString(FILEDIALOG_FILTER_ALL) ); + + // add template filter + OUString sFilterExt; + OUString sFilterName( SfxResId( STR_TEMPLATE_FILTER ).toString() ); + + // add filters of modules which are installed + SvtModuleOptions aModuleOpt; + if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SWRITER ) ) + sFilterExt += "*.ott;*.stw;*.oth"; + + if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SCALC ) ) + { + if ( !sFilterExt.isEmpty() ) + sFilterExt += ";"; + + sFilterExt += "*.ots;*.stc"; + } + + if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SIMPRESS ) ) + { + if ( !sFilterExt.isEmpty() ) + sFilterExt += ";"; + + sFilterExt += "*.otp;*.sti"; + } + + if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SDRAW ) ) + { + if ( !sFilterExt.isEmpty() ) + sFilterExt += ";"; + + sFilterExt += "*.otg;*.std"; + + + if ( !sFilterExt.isEmpty() ) + sFilterExt += ";"; + + sFilterExt += "*.vor"; + + sFilterName += " ("; + sFilterName += sFilterExt; + sFilterName += ")"; + + aFileDlg.AddFilter( sFilterName, sFilterExt ); + aFileDlg.SetCurrentFilter( sFilterName ); + + ErrCode nCode = aFileDlg.Execute(); + + if ( nCode == ERRCODE_NONE ) + { + com::sun::star::uno::Sequence<OUString> aFiles = aFileDlg.GetSelectedFiles(); + + if (aFiles.hasElements()) + { + if (!maSelFolders.empty()) + { + //Import to the selected regions + std::set<const ThumbnailViewItem*,selection_cmp_fn>::const_iterator pIter; + for (pIter = maSelFolders.begin(); pIter != maSelFolders.end(); ++pIter) + { + OUString aTemplateList; + TemplateContainerItem *pFolder = (TemplateContainerItem*)(*pIter); + + for (size_t i = 0, n = aFiles.getLength(); i < n; ++i) + { + if(!mpLocalView->copyFrom(pFolder,aFiles[i])) + { + if (aTemplateList.isEmpty()) + aTemplateList = aFiles[i]; + else + aTemplateList = aTemplateList + "\n" + aFiles[i]; + } + } + + if (!aTemplateList.isEmpty()) + { + OUString aMsg(SfxResId(STR_MSG_ERROR_IMPORT).toString()); + aMsg = aMsg.replaceFirst("$1",pFolder->maTitle); + ErrorBox(this,WB_OK,aMsg.replaceFirst("$2",aTemplateList)); + } + } + } + else + { + //Import to current region + OUString aTemplateList; + for (size_t i = 0, n = aFiles.getLength(); i < n; ++i) + { + if(!mpLocalView->copyFrom(aFiles[i])) + { + if (aTemplateList.isEmpty()) + aTemplateList = aFiles[i]; + else + aTemplateList = aTemplateList + "\n" + aFiles[i]; + } + } + + if (!aTemplateList.isEmpty()) + { + OUString aMsg(SfxResId(STR_MSG_ERROR_IMPORT).toString()); + aMsg = aMsg.replaceFirst("$1",mpLocalView->getCurRegionName()); + ErrorBox(this,WB_OK,aMsg.replaceFirst("$2",aTemplateList)); + } + } + + mpLocalView->Invalidate(INVALIDATE_NOERASE); + } + } + } +} + +void BackingWindow::OnRegionState (const ThumbnailViewItem *pItem) +{ + if (pItem->isSelected()) + { + if (maSelFolders.empty() && !mbIsSaveMode) + { + mpViewBar->ShowItem("import"); + mpViewBar->ShowItem("delete"); + mpViewBar->HideItem("new_folder"); + } + + maSelFolders.insert(pItem); + } + else + { + maSelFolders.erase(pItem); + + if (maSelFolders.empty() && !mbIsSaveMode) + { + mpViewBar->HideItem("import"); + mpViewBar->HideItem("delete"); + mpViewBar->ShowItem("new_folder"); + } + } +} + + IMPL_LINK(BackingWindow, ExtLinkClickHdl, Button*, pButton) { OUString aNode; @@ -523,23 +688,61 @@ IMPL_LINK( BackingWindow, ClickHdl, Button*, pButton ) return 0; } +//FIXME: Obvious enough IMPL_LINK_NOARG( BackingWindow, OpenRegionHdl) { - //maSelFolders.clear(); - //maSelTemplates.clear(); + maSelFolders.clear(); + maSelTemplates.clear(); - //mpViewBar->ShowItem(VIEWBAR_NEW_FOLDER, mpCurView->isNestedRegionAllowed()); + mpViewBar->ShowItem("new_folder", mpCurrentView->isNestedRegionAllowed()); - //if (!mbIsSaveMode) - //mpViewBar->ShowItem(VIEWBAR_IMPORT, mpCurView->isImportAllowed()); + if (!mbIsSaveMode) + mpViewBar->ShowItem("import", mpCurrentView->isImportAllowed()); //mpTemplateBar->Hide(); - //mpViewBar->Show(); + mpViewBar->Show(); //mpActionBar->Show(); return 0; } +//FIXME: Implement OnSomething() methods +IMPL_LINK_NOARG(BackingWindow,TBXViewHdl) +{ + const size_t nCurItemId = mpViewBar->GetCurItemId(); + + if (nCurItemId == mpViewBar->GetItemId("import")) + OnTemplateImport(); + //else if (nCurItemId == mpViewBar->GetItemId("delete")) + //{ + //if (mpCurView == mpLocalView) + ////OnFolderDelete(); + //else + ////OnRepositoryDelete(); + //} + //else if (nCurItemId == mpViewBar->GetItemId("new_folder")) + ////OnFolderNew(); + //else if (nCurItemId == mpViewBar->GetItemId("save")) + ////OnTemplateSaveAs(); + + return 0; +} + +IMPL_LINK(BackingWindow, TVItemStateHdl, const ThumbnailViewItem*, pItem) +{ + const TemplateContainerItem *pCntItem = dynamic_cast<const TemplateContainerItem*>(pItem); + + if (pCntItem) + OnRegionState(pItem); + //else + //FIXME:Move this to here + //OnTemplateState(pItem); + + return 0; +} + + + struct ImplDelayedDispatch { diff --git a/sfx2/source/dialog/backingwindow.hxx b/sfx2/source/dialog/backingwindow.hxx index cff49ec4e930..b80201a1ff0e 100644 --- a/sfx2/source/dialog/backingwindow.hxx +++ b/sfx2/source/dialog/backingwindow.hxx @@ -26,7 +26,6 @@ #include <vcl/button.hxx> #include <vcl/tabctrl.hxx> #include <vcl/layout.hxx> -#include <vcl/toolbox.hxx> #include <sfx2/recentdocsview.hxx> #include <sfx2/templatelocalview.hxx> @@ -45,10 +44,13 @@ #include <set> +class ToolBox; + class BackingWindow : public Window , public VclBuilderContainer { + typedef bool (*selection_cmp_fn)(const ThumbnailViewItem*,const ThumbnailViewItem*); com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > mxContext; com::sun::star::uno::Reference<com::sun::star::frame::XDispatchProvider > mxDesktopDispatchProvider; com::sun::star::uno::Reference<com::sun::star::frame::XFrame> mxFrame; @@ -89,11 +91,14 @@ class BackingWindow Rectangle maStartCentButtons; + bool mbIsSaveMode; bool mbInitControls; sal_Int32 mnHideExternalLinks; svt::AcceleratorExecute* mpAccExec; void setupButton( PushButton* pButton ); + void OnTemplateImport (); + void OnRegionState (const ThumbnailViewItem *pItem); void dispatchURL( const OUString& i_rURL, const OUString& i_rTarget = OUString( "_default" ), @@ -101,9 +106,14 @@ class BackingWindow const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& = com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >() ); + std::set<const ThumbnailViewItem*,selection_cmp_fn> maSelTemplates; + std::set<const ThumbnailViewItem*,selection_cmp_fn> maSelFolders; + DECL_LINK(ClickHdl, Button*); DECL_LINK(ExtLinkClickHdl, Button*); DECL_LINK(OpenRegionHdl, void*); + DECL_LINK(TBXViewHdl, void*); + DECL_LINK(TVItemStateHdl, const ThumbnailViewItem*); void initControls(); |