sc/source/ui/inc/xmlsourcedlg.hxx | 8 +++ sc/source/ui/src/xmlsourcedlg.src | 7 +-- sc/source/ui/xmlsource/xmlsourcedlg.cxx | 71 +++++++++++++++++++++++++++++--- 3 files changed, 76 insertions(+), 10 deletions(-)
New commits: commit a94b5f1d038beb809c9201f49b32bd3465a79b6d Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Thu Oct 11 00:20:46 2012 -0400 Get the reference edit box to work properly. Change-Id: Ifd01fe05312c0ece867100019a9f84162e5778c4 diff --git a/sc/source/ui/inc/xmlsourcedlg.hxx b/sc/source/ui/inc/xmlsourcedlg.hxx index ee8225c..c145f8b 100644 --- a/sc/source/ui/inc/xmlsourcedlg.hxx +++ b/sc/source/ui/inc/xmlsourcedlg.hxx @@ -54,7 +54,8 @@ class ScXMLSourceDlg : public ScAnyRefDlg ScDocument* mpDoc; - bool mbRefMode; + formula::RefEdit* mpActiveEdit; + bool mbDlgLostFocus; public: ScXMLSourceDlg( @@ -63,6 +64,7 @@ public: virtual sal_Bool IsRefInputMode() const; virtual void SetReference(const ScRange& rRange, ScDocument* pDoc); + virtual void Deactivate(); virtual void SetActive(); virtual sal_Bool Close(); @@ -70,7 +72,11 @@ private: void SelectSourceFile(); void LoadSourceFileStructure(const OUString& rPath); + void HandleGetFocus(Control* pCtrl); + void HandleLoseFocus(Control* pCtrl); + DECL_LINK(GetFocusHdl, Control*); + DECL_LINK(LoseFocusHdl, Control*); DECL_LINK(BtnPressedHdl, Button*); }; diff --git a/sc/source/ui/src/xmlsourcedlg.src b/sc/source/ui/src/xmlsourcedlg.src index d4ef5ce..4119601 100644 --- a/sc/source/ui/src/xmlsourcedlg.src +++ b/sc/source/ui/src/xmlsourcedlg.src @@ -50,7 +50,7 @@ ModelessDialog RID_SCDLG_XML_SOURCE FixedText FT_MAPPED_CELL_TITLE { - Pos = MAP_APPFONT( 12, 50 ); + Pos = MAP_APPFONT( 12, 52 ); Size = MAP_APPFONT ( 100 , 8 ) ; Text [ en-US ] = ""; @@ -59,15 +59,14 @@ ModelessDialog RID_SCDLG_XML_SOURCE Edit ED_MAPPED_CELL { Border = TRUE ; - Pos = MAP_APPFONT ( 12 , 63 ) ; + Pos = MAP_APPFONT ( 12 , 66 ) ; Size = MAP_APPFONT ( 69 , 12 ) ; TabStop = TRUE ; }; - ImageButton BTN_MAPPED_CELL { - Pos = MAP_APPFONT ( 83 , 62 ) ; + Pos = MAP_APPFONT ( 83 , 65 ) ; Size = MAP_APPFONT ( 13 , 15 ) ; TabStop = FALSE ; QuickHelpText [ en-US ] = "Shrink" ; diff --git a/sc/source/ui/xmlsource/xmlsourcedlg.cxx b/sc/source/ui/xmlsource/xmlsourcedlg.cxx index 37e6c72..3a07997 100644 --- a/sc/source/ui/xmlsource/xmlsourcedlg.cxx +++ b/sc/source/ui/xmlsource/xmlsourcedlg.cxx @@ -34,8 +34,8 @@ ScXMLSourceDlg::ScXMLSourceDlg( maFtSourceFile(this, ScResId(FT_SOURCE_FILE)), maFtMapXmlDoc(this, ScResId(FL_MAP_XML_TO_DOCUMENT)), maFtMappedCellTitle(this, ScResId(FT_MAPPED_CELL_TITLE)), - maEdit(this, ScResId(ED_MAPPED_CELL)), - maBtnRb(this, ScResId(BTN_MAPPED_CELL)), + maEdit(this, this, ScResId(ED_MAPPED_CELL)), + maBtnRb(this, ScResId(BTN_MAPPED_CELL), &maEdit, this), maLbTree(this, ScResId(LB_SOURCE_TREE)), maBtnCancel(this, ScResId(BTN_CANCEL)), maImgFileOpen(ScResId(IMG_FILE_OPEN)), @@ -45,13 +45,21 @@ ScXMLSourceDlg::ScXMLSourceDlg( maStrCellLink(ScResId(STR_CELL_LINK).toString()), maStrRangeLink(ScResId(STR_RANGE_LINK).toString()), mpDoc(pDoc), - mbRefMode(false) + mpActiveEdit(&maEdit), + mbDlgLostFocus(false) { maBtnSelectSource.SetModeImage(maImgFileOpen); FreeResource(); maBtnSelectSource.SetClickHdl(LINK(this, ScXMLSourceDlg, BtnPressedHdl)); + Link aLink = LINK(this, ScXMLSourceDlg, GetFocusHdl); + maEdit.SetGetFocusHdl(aLink); + maBtnRb.SetGetFocusHdl(aLink); + aLink = LINK(this, ScXMLSourceDlg, LoseFocusHdl); + maEdit.SetLoseFocusHdl(aLink); + maBtnRb.SetLoseFocusHdl(aLink); + maFtMappedCellTitle.SetText(maStrCellLink); } @@ -61,16 +69,43 @@ ScXMLSourceDlg::~ScXMLSourceDlg() sal_Bool ScXMLSourceDlg::IsRefInputMode() const { - return mbRefMode; + return mpActiveEdit != NULL; } void ScXMLSourceDlg::SetReference(const ScRange& rRange, ScDocument* pDoc) { + if (!mpActiveEdit) + return; + + if (rRange.aStart != rRange.aEnd) + RefInputStart(mpActiveEdit); + + OUString aStr; + rRange.aStart.Format(aStr, SCA_ABS_3D, pDoc, pDoc->GetAddressConvention()); + mpActiveEdit->SetRefString(aStr); +} + +void ScXMLSourceDlg::Deactivate() +{ + mbDlgLostFocus = true; } void ScXMLSourceDlg::SetActive() { - GrabFocus(); + if (mbDlgLostFocus) + { + mbDlgLostFocus = false; + if (mpActiveEdit) + { + mpActiveEdit->GrabFocus(); + } + } + else + { + GrabFocus(); + } + + RefInputDone(); } sal_Bool ScXMLSourceDlg::Close() @@ -114,6 +149,32 @@ void ScXMLSourceDlg::LoadSourceFileStructure(const OUString& rPath) maLbTree, rPath, maImgElemDefault, maImgElemRepeat, maImgElemAttribute); } +void ScXMLSourceDlg::HandleGetFocus(Control* pCtrl) +{ + mpActiveEdit = NULL; + if (pCtrl == &maEdit || pCtrl == &maBtnRb) + mpActiveEdit = &maEdit; + + if (mpActiveEdit) + mpActiveEdit->SetSelection(Selection(0, SELECTION_MAX)); +} + +void ScXMLSourceDlg::HandleLoseFocus(Control* /*pCtrl*/) +{ +} + +IMPL_LINK(ScXMLSourceDlg, GetFocusHdl, Control*, pCtrl) +{ + HandleGetFocus(pCtrl); + return 0; +} + +IMPL_LINK(ScXMLSourceDlg, LoseFocusHdl, Control*, pCtrl) +{ + HandleLoseFocus(pCtrl); + return 0; +} + IMPL_LINK(ScXMLSourceDlg, BtnPressedHdl, Button*, pBtn) { if (pBtn == &maBtnSelectSource) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits