diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-10-11 01:22:21 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-11-28 13:28:24 -0500 |
commit | f7aae88a1cf539d18ccd3ff9d5c194121dada6a7 (patch) | |
tree | d9d8663c035d938a3c950bc3f30fcc9a8de3adf0 /sc | |
parent | 3911c022ef8d0b1b682d96e57281015298bfa9f7 (diff) |
Use sensible directory path for file picker, handle tree item select.
Change-Id: I2638b1d870ee6b7e6c8697a38df07872184df8c6
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/inc/xmlsourcedlg.hxx | 4 | ||||
-rw-r--r-- | sc/source/ui/xmlsource/xmlsourcedlg.cxx | 37 |
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: */ |