summaryrefslogtreecommitdiff
path: root/sc/source/ui/xmlsource
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2012-09-28 20:22:23 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2012-11-28 13:28:21 -0500
commit8ca9f3c53e231bd528ff0f0a8af511ba9f517172 (patch)
treead4323c8e42e67537258ac5aaf22f27e4dce1235 /sc/source/ui/xmlsource
parent650dbb4f1600aaceec1394c62355f3702ea28a05 (diff)
Use file picker dialog to pick the source xml file.
Change-Id: Ie927d8a83fa93e3f61c2c2133fe655854667854c
Diffstat (limited to 'sc/source/ui/xmlsource')
-rw-r--r--sc/source/ui/xmlsource/xmlsourcedlg.cxx46
1 files changed, 44 insertions, 2 deletions
diff --git a/sc/source/ui/xmlsource/xmlsourcedlg.cxx b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
index 378ba5fcbad5..e44f5c0ed9a6 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: */