summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/source/ui/inc/xmlsourcedlg.hxx4
-rw-r--r--sc/source/ui/xmlsource/xmlsourcedlg.cxx37
2 files changed, 39 insertions, 2 deletions
diff --git a/sc/source/ui/inc/xmlsourcedlg.hxx b/sc/source/ui/inc/xmlsourcedlg.hxx
index c145f8b9ec4e..965dae75fdbb 100644
--- a/sc/source/ui/inc/xmlsourcedlg.hxx
+++ b/sc/source/ui/inc/xmlsourcedlg.hxx
@@ -52,6 +52,8 @@ class ScXMLSourceDlg : public ScAnyRefDlg
rtl::OUString maStrCellLink;
rtl::OUString maStrRangeLink;
+ rtl::OUString maSrcPath;
+
ScDocument* mpDoc;
formula::RefEdit* mpActiveEdit;
@@ -74,10 +76,12 @@ private:
void LoadSourceFileStructure(const OUString& rPath);
void HandleGetFocus(Control* pCtrl);
void HandleLoseFocus(Control* pCtrl);
+ void TreeItemSelected();
DECL_LINK(GetFocusHdl, Control*);
DECL_LINK(LoseFocusHdl, Control*);
DECL_LINK(BtnPressedHdl, Button*);
+ DECL_LINK(TreeItemSelectHdl, void*);
};
#endif
diff --git a/sc/source/ui/xmlsource/xmlsourcedlg.cxx b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
index 3a079970a3f8..cc255b8c300a 100644
--- a/sc/source/ui/xmlsource/xmlsourcedlg.cxx
+++ b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
@@ -16,6 +16,9 @@
#include "filter.hxx"
#include "reffact.hxx"
+#include "unotools/pathoptions.hxx"
+#include "tools/urlobj.hxx"
+
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
@@ -60,6 +63,8 @@ ScXMLSourceDlg::ScXMLSourceDlg(
maEdit.SetLoseFocusHdl(aLink);
maBtnRb.SetLoseFocusHdl(aLink);
+ aLink = LINK(this, ScXMLSourceDlg, TreeItemSelectHdl);
+ maLbTree.SetSelectHdl(aLink);
maFtMappedCellTitle.SetText(maStrCellLink);
}
@@ -125,6 +130,19 @@ void ScXMLSourceDlg::SelectSourceFile()
if (!xFilePicker.is())
return;
+ if (maSrcPath.isEmpty())
+ // Use default path.
+ xFilePicker->setDisplayDirectory(SvtPathOptions().GetWorkPath());
+ else
+ {
+ // Use the directory of current source file.
+ INetURLObject aURL(maSrcPath);
+ aURL.removeSegment();
+ aURL.removeFinalSlash();
+ OUString aPath = aURL.GetMainURL(INetURLObject::NO_DECODE);
+ xFilePicker->setDisplayDirectory(aPath);
+ }
+
if (xFilePicker->execute() != ui::dialogs::ExecutableDialogResults::OK)
// File picker dialog cancelled.
return;
@@ -133,10 +151,11 @@ void ScXMLSourceDlg::SelectSourceFile()
if (!aFiles.getLength())
return;
+ maSrcPath = aFiles[0];
// There should only be one file returned from the file picker.
- maFtSourceFile.SetText(aFiles[0]);
+ maFtSourceFile.SetText(maSrcPath);
- LoadSourceFileStructure(aFiles[0]);
+ LoadSourceFileStructure(maSrcPath);
}
void ScXMLSourceDlg::LoadSourceFileStructure(const OUString& rPath)
@@ -163,6 +182,14 @@ void ScXMLSourceDlg::HandleLoseFocus(Control* /*pCtrl*/)
{
}
+void ScXMLSourceDlg::TreeItemSelected()
+{
+ SvLBoxEntry* pEntry = maLbTree.GetCurEntry();
+ OUString aName = maLbTree.GetEntryText(pEntry);
+ fprintf(stdout, "ScXMLSourceDlg::TreeItemSelected: name = '%s'\n",
+ rtl::OUStringToOString(aName, RTL_TEXTENCODING_UTF8).getStr());
+}
+
IMPL_LINK(ScXMLSourceDlg, GetFocusHdl, Control*, pCtrl)
{
HandleGetFocus(pCtrl);
@@ -182,4 +209,10 @@ IMPL_LINK(ScXMLSourceDlg, BtnPressedHdl, Button*, pBtn)
return 0;
}
+IMPL_LINK_NOARG(ScXMLSourceDlg, TreeItemSelectHdl)
+{
+ TreeItemSelected();
+ return 0;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */