sc/Library_sc.mk | 1 sc/Library_scfilt.mk | 1 sc/inc/orcusxml.hxx | 11 ++- sc/source/core/tool/orcusxml.cxx | 22 ++++++ sc/source/filter/orcus/orcusfiltersimpl.cxx | 2 sc/source/filter/orcus/orcusxml.cxx | 15 ---- sc/source/ui/inc/xmlsourcedlg.hrc | 4 - sc/source/ui/inc/xmlsourcedlg.hxx | 15 ++-- sc/source/ui/src/xmlsourcedlg.src | 24 +----- sc/source/ui/xmlsource/xmlsourcedlg.cxx | 100 +++++++++++++++++++++++----- 10 files changed, 131 insertions(+), 64 deletions(-)
New commits: commit 1100902333b55264855f3423bfc1f463e19c8f18 Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Fri Oct 12 21:32:09 2012 -0400 More progress on the dialog. Change-Id: Ib07d6d5de7cd0d72356bbb7859342f5038f05f95 diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk index 2953b4a..89f231a 100644 --- a/sc/Library_sc.mk +++ b/sc/Library_sc.mk @@ -206,6 +206,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\ sc/source/core/tool/navicfg \ sc/source/core/tool/odffmap \ sc/source/core/tool/optutil \ + sc/source/core/tool/orcusxml \ sc/source/core/tool/parclass \ sc/source/core/tool/printopt \ sc/source/core/tool/prnsave \ diff --git a/sc/Library_scfilt.mk b/sc/Library_scfilt.mk index 8809028..7a5256e 100644 --- a/sc/Library_scfilt.mk +++ b/sc/Library_scfilt.mk @@ -219,7 +219,6 @@ $(eval $(call gb_Library_add_exception_objects,scfilt,\ sc/source/filter/oox/worksheethelper \ sc/source/filter/oox/worksheetsettings \ sc/source/filter/orcus/orcusfiltersimpl \ - sc/source/filter/orcus/orcusxml \ )) # vim: set noet sw=4 ts=4: diff --git a/sc/inc/orcusxml.hxx b/sc/inc/orcusxml.hxx index cdc4679..d615ab6 100644 --- a/sc/inc/orcusxml.hxx +++ b/sc/inc/orcusxml.hxx @@ -10,10 +10,13 @@ #ifndef __SC_ORCUSXML_HXX__ #define __SC_ORCUSXML_HXX__ +#include "scdllapi.h" #include "vcl/image.hxx" #include <boost/ptr_container/ptr_vector.hpp> +class SvLBoxEntry; + /** * Parameter used during call to ScOrcusFilters::loadXMLStructure(). */ @@ -22,14 +25,14 @@ struct ScOrcusXMLTreeParam enum EntryType { ElementDefault, ElementRepeat, Attribute }; /** Custom data stored with each tree item. */ - struct TreeEntryUserData + struct EntryData { EntryType meType; - TreeEntryUserData(EntryType eType); + SC_DLLPUBLIC EntryData(EntryType eType); }; - typedef boost::ptr_vector<TreeEntryUserData> UserDataStoreType; + typedef boost::ptr_vector<EntryData> UserDataStoreType; Image maImgElementDefault; Image maImgElementRepeat; @@ -40,6 +43,8 @@ struct ScOrcusXMLTreeParam * the life cycle of user datas. */ UserDataStoreType maUserDataStore; + + static SC_DLLPUBLIC EntryData* getUserData(SvLBoxEntry& rEntry); }; #endif diff --git a/sc/source/core/tool/orcusxml.cxx b/sc/source/core/tool/orcusxml.cxx new file mode 100644 index 0000000..4e9ef80 --- /dev/null +++ b/sc/source/core/tool/orcusxml.cxx @@ -0,0 +1,22 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "orcusxml.hxx" + +#include "svtools/treelistbox.hxx" + +ScOrcusXMLTreeParam::EntryData::EntryData(EntryType eType) : + meType(eType) {} + +ScOrcusXMLTreeParam::EntryData* ScOrcusXMLTreeParam::getUserData(SvLBoxEntry& rEntry) +{ + return static_cast<ScOrcusXMLTreeParam::EntryData*>(rEntry.GetUserData()); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/filter/orcus/orcusfiltersimpl.cxx b/sc/source/filter/orcus/orcusfiltersimpl.cxx index c5b8711..b4a1408 100644 --- a/sc/source/filter/orcus/orcusfiltersimpl.cxx +++ b/sc/source/filter/orcus/orcusfiltersimpl.cxx @@ -179,7 +179,7 @@ namespace { void setUserDataToEntry( SvLBoxEntry& rEntry, ScOrcusXMLTreeParam::UserDataStoreType& rStore, ScOrcusXMLTreeParam::EntryType eType) { - rStore.push_back(new ScOrcusXMLTreeParam::TreeEntryUserData(eType)); + rStore.push_back(new ScOrcusXMLTreeParam::EntryData(eType)); rEntry.SetUserData(&rStore.back()); } diff --git a/sc/source/filter/orcus/orcusxml.cxx b/sc/source/filter/orcus/orcusxml.cxx deleted file mode 100644 index 68746be..0000000 --- a/sc/source/filter/orcus/orcusxml.cxx +++ /dev/null @@ -1,15 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#include "orcusxml.hxx" - -ScOrcusXMLTreeParam::TreeEntryUserData::TreeEntryUserData(EntryType eType) : - meType(eType) {} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/xmlsourcedlg.hrc b/sc/source/ui/inc/xmlsourcedlg.hrc index 03cb645..a5df403 100644 --- a/sc/source/ui/inc/xmlsourcedlg.hrc +++ b/sc/source/ui/inc/xmlsourcedlg.hrc @@ -17,7 +17,6 @@ #define FT_SOURCE_FILE 12 #define FL_MAP_XML_TO_DOCUMENT 20 -#define FT_TREE_ITEM_NAME 21 #define FT_MAPPED_CELL_TITLE 22 #define ED_MAPPED_CELL 23 #define BTN_MAPPED_CELL 24 @@ -28,7 +27,4 @@ #define IMG_ELEMENT_ATTRIBUTE 52 #define IMG_FILE_OPEN 53 -#define STR_CELL_LINK 70 -#define STR_RANGE_LINK 71 - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file diff --git a/sc/source/ui/inc/xmlsourcedlg.hxx b/sc/source/ui/inc/xmlsourcedlg.hxx index f946fb2..c6a5008 100644 --- a/sc/source/ui/inc/xmlsourcedlg.hxx +++ b/sc/source/ui/inc/xmlsourcedlg.hxx @@ -37,10 +37,9 @@ class ScXMLSourceDlg : public ScAnyRefDlg FixedLine maFtMapXmlDoc; - FixedText maFtTreeItemName; FixedText maFtMappedCellTitle; - formula::RefEdit maEdit; - formula::RefButton maBtnRb; + formula::RefEdit maRefEdit; + formula::RefButton maRefBtn; ScXMLSourceTree maLbTree; @@ -48,9 +47,6 @@ class ScXMLSourceDlg : public ScAnyRefDlg Image maImgFileOpen; - rtl::OUString maStrCellLink; - rtl::OUString maStrRangeLink; - rtl::OUString maSrcPath; ScOrcusXMLTreeParam maXMLParam; @@ -78,6 +74,13 @@ private: void HandleGetFocus(Control* pCtrl); void HandleLoseFocus(Control* pCtrl); void TreeItemSelected(); + void DefaultElementSelected(SvLBoxEntry& rEntry); + void RepeatElementSelected(SvLBoxEntry& rEntry); + void AttributeSelected(SvLBoxEntry& rEntry); + + void SetNonLinkable(); + void SetSingleLinkable(); + void SetRangeLinkable(); DECL_LINK(GetFocusHdl, Control*); DECL_LINK(LoseFocusHdl, Control*); diff --git a/sc/source/ui/src/xmlsourcedlg.src b/sc/source/ui/src/xmlsourcedlg.src index 342d47a..9d76d97 100644 --- a/sc/source/ui/src/xmlsourcedlg.src +++ b/sc/source/ui/src/xmlsourcedlg.src @@ -48,29 +48,25 @@ ModelessDialog RID_SCDLG_XML_SOURCE Text [ en-US ] = "Map to document"; }; - FixedText FT_TREE_ITEM_NAME - { - Pos = MAP_APPFONT( 12, 52 ); - Size = MAP_APPFONT ( 100 , 8 ) ; - }; - FixedText FT_MAPPED_CELL_TITLE { - Pos = MAP_APPFONT( 12, 67 ); + Pos = MAP_APPFONT( 12, 55 ); Size = MAP_APPFONT ( 100 , 8 ) ; + + Text [ en-US ] = "Linked cell"; }; Edit ED_MAPPED_CELL { Border = TRUE ; - Pos = MAP_APPFONT ( 12 , 81 ) ; + Pos = MAP_APPFONT ( 12 , 67 ) ; Size = MAP_APPFONT ( 69 , 12 ) ; TabStop = TRUE ; }; ImageButton BTN_MAPPED_CELL { - Pos = MAP_APPFONT ( 83 , 80 ) ; + Pos = MAP_APPFONT ( 83 , 66 ) ; Size = MAP_APPFONT ( 13 , 15 ) ; TabStop = FALSE ; QuickHelpText [ en-US ] = "Shrink" ; @@ -113,15 +109,5 @@ ModelessDialog RID_SCDLG_XML_SOURCE Pos = MAP_APPFONT ( 194 , 181 ) ; Size = MAP_APPFONT ( 50 , 14 ) ; }; - - String STR_CELL_LINK - { - Text [ en-US ] = "Link to cell"; - }; - - String STR_RANGE_LINK - { - Text [ en-US ] = "Link to range"; - }; }; diff --git a/sc/source/ui/xmlsource/xmlsourcedlg.cxx b/sc/source/ui/xmlsource/xmlsourcedlg.cxx index 6071f82..c4fb781 100644 --- a/sc/source/ui/xmlsource/xmlsourcedlg.cxx +++ b/sc/source/ui/xmlsource/xmlsourcedlg.cxx @@ -36,17 +36,14 @@ ScXMLSourceDlg::ScXMLSourceDlg( maBtnSelectSource(this, ScResId(BTN_SELECT_SOURCE_FILE)), maFtSourceFile(this, ScResId(FT_SOURCE_FILE)), maFtMapXmlDoc(this, ScResId(FL_MAP_XML_TO_DOCUMENT)), - maFtTreeItemName(this, ScResId(FT_TREE_ITEM_NAME)), maFtMappedCellTitle(this, ScResId(FT_MAPPED_CELL_TITLE)), - maEdit(this, this, ScResId(ED_MAPPED_CELL)), - maBtnRb(this, ScResId(BTN_MAPPED_CELL), &maEdit, this), + maRefEdit(this, this, ScResId(ED_MAPPED_CELL)), + maRefBtn(this, ScResId(BTN_MAPPED_CELL), &maRefEdit, this), maLbTree(this, ScResId(LB_SOURCE_TREE)), maBtnCancel(this, ScResId(BTN_CANCEL)), maImgFileOpen(ScResId(IMG_FILE_OPEN)), - maStrCellLink(ScResId(STR_CELL_LINK).toString()), - maStrRangeLink(ScResId(STR_RANGE_LINK).toString()), mpDoc(pDoc), - mpActiveEdit(&maEdit), + mpActiveEdit(&maRefEdit), mbDlgLostFocus(false) { maXMLParam.maImgElementDefault = Image(ScResId(IMG_ELEMENT_DEFAULT)); @@ -59,15 +56,16 @@ ScXMLSourceDlg::ScXMLSourceDlg( maBtnSelectSource.SetClickHdl(LINK(this, ScXMLSourceDlg, BtnPressedHdl)); Link aLink = LINK(this, ScXMLSourceDlg, GetFocusHdl); - maEdit.SetGetFocusHdl(aLink); - maBtnRb.SetGetFocusHdl(aLink); + maRefEdit.SetGetFocusHdl(aLink); + maRefBtn.SetGetFocusHdl(aLink); aLink = LINK(this, ScXMLSourceDlg, LoseFocusHdl); - maEdit.SetLoseFocusHdl(aLink); - maBtnRb.SetLoseFocusHdl(aLink); + maRefEdit.SetLoseFocusHdl(aLink); + maRefBtn.SetLoseFocusHdl(aLink); aLink = LINK(this, ScXMLSourceDlg, TreeItemSelectHdl); maLbTree.SetSelectHdl(aLink); - maFtMappedCellTitle.SetText(maStrCellLink); + + SetNonLinkable(); } ScXMLSourceDlg::~ScXMLSourceDlg() @@ -172,8 +170,8 @@ void ScXMLSourceDlg::LoadSourceFileStructure(const OUString& rPath) void ScXMLSourceDlg::HandleGetFocus(Control* pCtrl) { mpActiveEdit = NULL; - if (pCtrl == &maEdit || pCtrl == &maBtnRb) - mpActiveEdit = &maEdit; + if (pCtrl == &maRefEdit || pCtrl == &maRefBtn) + mpActiveEdit = &maRefEdit; if (mpActiveEdit) mpActiveEdit->SetSelection(Selection(0, SELECTION_MAX)); @@ -186,8 +184,80 @@ void ScXMLSourceDlg::HandleLoseFocus(Control* /*pCtrl*/) void ScXMLSourceDlg::TreeItemSelected() { SvLBoxEntry* pEntry = maLbTree.GetCurEntry(); - OUString aName = maLbTree.GetEntryText(pEntry); - maFtTreeItemName.SetText(aName); + if (!pEntry) + return; + + ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(*pEntry); + + if (!pUserData) + return; + + switch (pUserData->meType) + { + case ScOrcusXMLTreeParam::Attribute: + AttributeSelected(*pEntry); + break; + case ScOrcusXMLTreeParam::ElementDefault: + DefaultElementSelected(*pEntry); + break; + case ScOrcusXMLTreeParam::ElementRepeat: + RepeatElementSelected(*pEntry); + break; + default: + ; + } +} + +void ScXMLSourceDlg::DefaultElementSelected(SvLBoxEntry& rEntry) +{ + if (maLbTree.GetChildCount(&rEntry) > 0) + { + // Only an element with no child elements (leaf element) can be linked. + SetNonLinkable(); + return; + } + + // TODO: Check all its parents and make sure non of them are range-linked + // nor repeat elements. + SetSingleLinkable(); +} + +void ScXMLSourceDlg::RepeatElementSelected(SvLBoxEntry& rEntry) +{ + // TODO: Check all its child elements / attributes and make sure non of + // them are linked or repeat elements. In the future we will support + // range linking of repeat element who has another repeat elements. But + // first I need to support that in orcus. + + SetNonLinkable(); +} + +void ScXMLSourceDlg::AttributeSelected(SvLBoxEntry& rEntry) +{ + // TODO: Check all its parent elements and make sure non of them are + // range-linked nor repeat elements. + SetSingleLinkable(); +} + +void ScXMLSourceDlg::SetNonLinkable() +{ + maFtMappedCellTitle.Disable(); + maRefEdit.Disable(); + maRefBtn.Disable(); +} + +void ScXMLSourceDlg::SetSingleLinkable() +{ + maFtMappedCellTitle.Enable(); + maRefEdit.Enable(); + maRefBtn.Enable(); +} + +void ScXMLSourceDlg::SetRangeLinkable() +{ + maFtMappedCellTitle.Enable(); + maRefEdit.Enable(); + maRefBtn.Enable(); } IMPL_LINK(ScXMLSourceDlg, GetFocusHdl, Control*, pCtrl) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits