sc/inc/scabstdlg.hxx | 2 - sc/source/ui/attrdlg/scdlgfact.cxx | 4 +- sc/source/ui/attrdlg/scdlgfact.hxx | 2 - sc/source/ui/inc/xmlsourcedlg.hxx | 14 +++++++++ sc/source/ui/view/cellsh1.cxx | 2 - sc/source/ui/xmlsource/xmlsourcedlg.cxx | 46 ++++++++++++++++++++++++++++++-- 6 files changed, 62 insertions(+), 8 deletions(-)
New commits: commit 6072c41d03ab3742c282e1b633380e552a684d25 Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Fri Sep 28 20:22:23 2012 -0400 Use file picker dialog to pick the source xml file. Change-Id: Ie927d8a83fa93e3f61c2c2133fe655854667854c diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx index 9623615..5c04cec 100644 --- a/sc/inc/scabstdlg.hxx +++ b/sc/inc/scabstdlg.hxx @@ -537,7 +537,7 @@ public: virtual SfxAbstractTabDialog * CreateScSortDlg( Window* pParent, //add for ScSortDlg const SfxItemSet* pArgSet,int nId ) = 0; - virtual AbstractScXMLSourceDlg* CreateScXMLSourceDlg(Window* pParent, int nId) = 0; + virtual AbstractScXMLSourceDlg* CreateScXMLSourceDlg(Window* pParent, ScDocument* pDoc, int nId) = 0; // for tabpage virtual CreateTabPage GetTabPageCreatorFunc( sal_uInt16 nId ) = 0; diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx index 9257a9e..d437807 100644 --- a/sc/source/ui/attrdlg/scdlgfact.cxx +++ b/sc/source/ui/attrdlg/scdlgfact.cxx @@ -1596,9 +1596,9 @@ SfxAbstractTabDialog * ScAbstractDialogFactory_Impl::CreateScSortDlg( Window* return 0; } -AbstractScXMLSourceDlg* ScAbstractDialogFactory_Impl::CreateScXMLSourceDlg(Window* pParent, int nId) +AbstractScXMLSourceDlg* ScAbstractDialogFactory_Impl::CreateScXMLSourceDlg(Window* pParent, ScDocument* pDoc, int nId) { - ScXMLSourceDlg* pDlg = (nId == RID_SCDLG_XML_SOURCE) ? new ScXMLSourceDlg(pParent) : NULL; + ScXMLSourceDlg* pDlg = (nId == RID_SCDLG_XML_SOURCE) ? new ScXMLSourceDlg(pParent, pDoc) : NULL; return pDlg ? new AbstractScXMLSourceDlg_Impl(pDlg) : NULL; } diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx index 73b35d9..c250582 100644 --- a/sc/source/ui/attrdlg/scdlgfact.hxx +++ b/sc/source/ui/attrdlg/scdlgfact.hxx @@ -610,7 +610,7 @@ public: virtual SfxAbstractTabDialog * CreateScSortDlg( Window* pParent, //add for ScSortDlg const SfxItemSet* pArgSet,int nId ); - virtual AbstractScXMLSourceDlg* CreateScXMLSourceDlg(Window* pParent, int nId); + virtual AbstractScXMLSourceDlg* CreateScXMLSourceDlg(Window* pParent, ScDocument* pDoc, int nId); // For TabPage virtual CreateTabPage GetTabPageCreatorFunc( sal_uInt16 nId ); diff --git a/sc/source/ui/inc/xmlsourcedlg.hxx b/sc/source/ui/inc/xmlsourcedlg.hxx index 2213d42..5a54c70 100644 --- a/sc/source/ui/inc/xmlsourcedlg.hxx +++ b/sc/source/ui/inc/xmlsourcedlg.hxx @@ -15,6 +15,10 @@ #include "vcl/fixed.hxx" #include "svtools/svtreebx.hxx" +#include <boost/scoped_ptr.hpp> + +class ScDocument; + class ScXMLSourceTree : public SvTreeListBox { Image maImgElemDefault; @@ -37,9 +41,17 @@ class ScXMLSourceDlg : public ModalDialog Image maImgFileOpen; + ScDocument* mpDoc; + public: - ScXMLSourceDlg(Window* pParent); + ScXMLSourceDlg(Window* pParent, ScDocument* pDoc); virtual ~ScXMLSourceDlg(); + +private: + + void SelectSourceFile(); + + DECL_LINK(BtnPressedHdl, Button*); }; #endif diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx index 074f69a..4a3c6c8 100644 --- a/sc/source/ui/view/cellsh1.cxx +++ b/sc/source/ui/view/cellsh1.cxx @@ -2451,7 +2451,7 @@ void ScCellShell::ExecuteXMLSourceDialog() boost::scoped_ptr<AbstractScXMLSourceDlg> pDlg( pFact->CreateScXMLSourceDlg( - pTabViewShell->GetDialogParent(), RID_SCDLG_XML_SOURCE)); + pTabViewShell->GetDialogParent(), GetViewData()->GetDocument(), RID_SCDLG_XML_SOURCE)); if (!pDlg) return; diff --git a/sc/source/ui/xmlsource/xmlsourcedlg.cxx b/sc/source/ui/xmlsource/xmlsourcedlg.cxx index 378ba5f..e44f5c0 100644 --- a/sc/source/ui/xmlsource/xmlsourcedlg.cxx +++ b/sc/source/ui/xmlsource/xmlsourcedlg.cxx @@ -11,6 +11,14 @@ #include "xmlsourcedlg.hrc" #include "scresid.hxx" +#include "document.hxx" + +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/ui/dialogs/XFilePicker.hpp> +#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> + +using namespace com::sun::star; + ScXMLSourceTree::ScXMLSourceTree(Window* pParent, const ResId& rResId) : SvTreeListBox(pParent, rResId), @@ -30,7 +38,7 @@ ScXMLSourceTree::ScXMLSourceTree(Window* pParent, const ResId& rResId) : Expand(pPar); } -ScXMLSourceDlg::ScXMLSourceDlg(Window* pParent) : +ScXMLSourceDlg::ScXMLSourceDlg(Window* pParent, ScDocument* pDoc) : ModalDialog(pParent, ScResId(RID_SCDLG_XML_SOURCE)), maFlSourceFile(this, ScResId(FL_SOURCE_FILE)), maBtnSelectSource(this, ScResId(BTN_SELECT_SOURCE_FILE)), @@ -38,14 +46,48 @@ ScXMLSourceDlg::ScXMLSourceDlg(Window* pParent) : maFtMapXmlDoc(this, ScResId(FL_MAP_XML_TO_DOCUMENT)), maLbTree(this, ScResId(LB_SOURCE_TREE)), maBtnCancel(this, ScResId(BTN_CANCEL)), - maImgFileOpen(ScResId(IMG_FILE_OPEN)) + maImgFileOpen(ScResId(IMG_FILE_OPEN)), + mpDoc(pDoc) { maBtnSelectSource.SetModeImage(maImgFileOpen); FreeResource(); + + maBtnSelectSource.SetClickHdl(LINK(this, ScXMLSourceDlg, BtnPressedHdl)); } ScXMLSourceDlg::~ScXMLSourceDlg() { } +void ScXMLSourceDlg::SelectSourceFile() +{ + uno::Reference<lang::XMultiServiceFactory> xServiceMgr = mpDoc->GetServiceManager(); + if (!xServiceMgr.is()) + return; + + uno::Reference<ui::dialogs::XFilePicker> xFilePicker( + xServiceMgr->createInstance("com.sun.star.ui.dialogs.FilePicker"), uno::UNO_QUERY); + + if (!xFilePicker.is()) + return; + + if (xFilePicker->execute() != ui::dialogs::ExecutableDialogResults::OK) + // File picker dialog cancelled. + return; + + uno::Sequence<OUString> aFiles = xFilePicker->getFiles(); + if (!aFiles.getLength()) + return; + + // There should only be one file returned from the file picker. + maFtSourceFile.SetText(aFiles[0]); +} + +IMPL_LINK(ScXMLSourceDlg, BtnPressedHdl, Button*, pBtn) +{ + if (pBtn == &maBtnSelectSource) + SelectSourceFile(); + return 0; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits