sc/inc/orcusfilters.hxx | 4 sc/inc/orcusxml.hxx | 13 - sc/source/core/tool/orcusxml.cxx | 6 sc/source/filter/inc/orcusfiltersimpl.hxx | 2 sc/source/filter/orcus/xmlcontext.cxx | 63 ++--- sc/source/ui/inc/xmlsourcedlg.hxx | 75 +++--- sc/source/ui/view/reffact.cxx | 4 sc/source/ui/view/tabvwshc.cxx | 11 sc/source/ui/xmlsource/xmlsourcedlg.cxx | 361 ++++++++++++------------------ sc/uiconfig/scalc/ui/xmlsourcedialog.ui | 205 ++++++++++------- solenv/sanitizers/ui/modules/scalc.false | 1 solenv/sanitizers/ui/modules/scalc.suppr | 4 vcl/unx/gtk3/gtk3gtkinst.cxx | 1 13 files changed, 376 insertions(+), 374 deletions(-)
New commits: commit 260e5b61209b92e1583623d70b2ba3032b5ced14 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Sun Apr 28 19:47:03 2019 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Mon Apr 29 14:31:51 2019 +0200 weld ScXMLSourceDlg Change-Id: If8894b7c432006f196e040571757943c940f13ea Reviewed-on: https://gerrit.libreoffice.org/71489 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/sc/inc/orcusfilters.hxx b/sc/inc/orcusfilters.hxx index 1f96d6ac1769..99f55306b226 100644 --- a/sc/inc/orcusfilters.hxx +++ b/sc/inc/orcusfilters.hxx @@ -13,11 +13,11 @@ #include <rtl/ustring.hxx> class ScDocument; -class SvTreeListBox; struct ScOrcusXMLTreeParam; struct ScOrcusImportXMLParam; class ScOrcusXMLContext; class SfxMedium; +namespace weld { class TreeView; } /** * Collection of orcus filter wrappers. @@ -60,7 +60,7 @@ class ScOrcusXMLContext public: virtual ~ScOrcusXMLContext() {} - virtual void loadXMLStructure(SvTreeListBox& rTreeCtrl, ScOrcusXMLTreeParam& rParam) = 0; + virtual void loadXMLStructure(weld::TreeView& rTreeCtrl, ScOrcusXMLTreeParam& rParam) = 0; virtual void importXML(const ScOrcusImportXMLParam& rParam) = 0; }; diff --git a/sc/inc/orcusxml.hxx b/sc/inc/orcusxml.hxx index 2b8f94425f73..b635eca2d43d 100644 --- a/sc/inc/orcusxml.hxx +++ b/sc/inc/orcusxml.hxx @@ -17,7 +17,10 @@ #include <vector> #include <memory> -class SvTreeListEntry; +namespace weld { + class TreeIter; + class TreeView; +} /** * Parameter used during call to ScOrcusFilters::loadXMLStructure(). @@ -40,9 +43,9 @@ struct ScOrcusXMLTreeParam typedef std::vector<std::unique_ptr<EntryData>> UserDataStoreType; - Image maImgElementDefault; - Image maImgElementRepeat; - Image maImgAttribute; + OUString maImgElementDefault; + OUString maImgElementRepeat; + OUString maImgAttribute; /** * Store all custom data instances since the tree control doesn't manage @@ -50,7 +53,7 @@ struct ScOrcusXMLTreeParam */ UserDataStoreType m_UserDataStore; - static SC_DLLPUBLIC EntryData* getUserData(const SvTreeListEntry& rEntry); + static SC_DLLPUBLIC EntryData* getUserData(const weld::TreeView& rControl, const weld::TreeIter& rEntry); }; struct ScOrcusImportXMLParam diff --git a/sc/source/core/tool/orcusxml.cxx b/sc/source/core/tool/orcusxml.cxx index 13101973d2c6..1323362b4124 100644 --- a/sc/source/core/tool/orcusxml.cxx +++ b/sc/source/core/tool/orcusxml.cxx @@ -9,7 +9,7 @@ #include <orcusxml.hxx> -#include <vcl/treelistentry.hxx> +#include <vcl/weld.hxx> ScOrcusXMLTreeParam::EntryData::EntryData(EntryType eType) : mnNamespaceID(0) @@ -19,9 +19,9 @@ ScOrcusXMLTreeParam::EntryData::EntryData(EntryType eType) , mbLeafNode(true) {} -ScOrcusXMLTreeParam::EntryData* ScOrcusXMLTreeParam::getUserData(const SvTreeListEntry& rEntry) +ScOrcusXMLTreeParam::EntryData* ScOrcusXMLTreeParam::getUserData(const weld::TreeView& rControl, const weld::TreeIter& rEntry) { - return static_cast<ScOrcusXMLTreeParam::EntryData*>(rEntry.GetUserData()); + return reinterpret_cast<ScOrcusXMLTreeParam::EntryData*>(rControl.get_id(rEntry).toInt64()); } ScOrcusImportXMLParam::CellLink::CellLink(const ScAddress& rPos, const OString& rPath) : diff --git a/sc/source/filter/inc/orcusfiltersimpl.hxx b/sc/source/filter/inc/orcusfiltersimpl.hxx index 1a27dc93ec1c..bef07a43e2dc 100644 --- a/sc/source/filter/inc/orcusfiltersimpl.hxx +++ b/sc/source/filter/inc/orcusfiltersimpl.hxx @@ -41,7 +41,7 @@ public: ScOrcusXMLContextImpl(ScDocument& rDoc, const OUString& rPath); virtual ~ScOrcusXMLContextImpl() override; - virtual void loadXMLStructure(SvTreeListBox& rTreeCtrl, ScOrcusXMLTreeParam& rParam) override; + virtual void loadXMLStructure(weld::TreeView& rTreeCtrl, ScOrcusXMLTreeParam& rParam) override; virtual void importXML(const ScOrcusImportXMLParam& rParam) override; }; diff --git a/sc/source/filter/orcus/xmlcontext.cxx b/sc/source/filter/orcus/xmlcontext.cxx index 636e66271a7d..9cac43207cf4 100644 --- a/sc/source/filter/orcus/xmlcontext.cxx +++ b/sc/source/filter/orcus/xmlcontext.cxx @@ -15,6 +15,7 @@ #include <vcl/treelistbox.hxx> #include <vcl/treelistentry.hxx> +#include <vcl/weld.hxx> #include <ucbhelper/content.hxx> #include <sal/log.hxx> @@ -38,11 +39,11 @@ using namespace com::sun::star; namespace { -ScOrcusXMLTreeParam::EntryData& setUserDataToEntry( - SvTreeListEntry& rEntry, ScOrcusXMLTreeParam::UserDataStoreType& rStore, ScOrcusXMLTreeParam::EntryType eType) +ScOrcusXMLTreeParam::EntryData& setUserDataToEntry(weld::TreeView& rControl, + weld::TreeIter& rEntry, ScOrcusXMLTreeParam::UserDataStoreType& rStore, ScOrcusXMLTreeParam::EntryType eType) { rStore.push_back(std::make_unique<ScOrcusXMLTreeParam::EntryData>(eType)); - rEntry.SetUserData(rStore.back().get()); + rControl.set_id(rEntry, OUString::number(reinterpret_cast<sal_Int64>(rStore.back().get()))); return *rStore.back(); } @@ -68,17 +69,17 @@ OUString toString(const orcus::xml_structure_tree::entity_name& entity, const or } void populateTree( - SvTreeListBox& rTreeCtrl, orcus::xml_structure_tree::walker& rWalker, + weld::TreeView& rTreeCtrl, orcus::xml_structure_tree::walker& rWalker, const orcus::xml_structure_tree::entity_name& rElemName, bool bRepeat, - SvTreeListEntry* pParent, ScOrcusXMLTreeParam& rParam) + weld::TreeIter* pParent, ScOrcusXMLTreeParam& rParam) { - SvTreeListEntry* pEntry = rTreeCtrl.InsertEntry(toString(rElemName, rWalker), pParent); - if (!pEntry) - // Can this ever happen!? - return; + OUString sEntry(toString(rElemName, rWalker)); + std::unique_ptr<weld::TreeIter> xEntry(rTreeCtrl.make_iterator()); + rTreeCtrl.insert(pParent, -1, &sEntry, nullptr, nullptr, nullptr, nullptr, false, xEntry.get()); + rTreeCtrl.set_image(*xEntry, rParam.maImgElementDefault, -1); - ScOrcusXMLTreeParam::EntryData& rEntryData = setUserDataToEntry( - *pEntry, rParam.m_UserDataStore, + ScOrcusXMLTreeParam::EntryData& rEntryData = setUserDataToEntry(rTreeCtrl, + *xEntry, rParam.m_UserDataStore, bRepeat ? ScOrcusXMLTreeParam::ElementRepeat : ScOrcusXMLTreeParam::ElementDefault); setEntityNameToUserData(rEntryData, rElemName, rWalker); @@ -86,32 +87,25 @@ void populateTree( if (bRepeat) { // Recurring elements use different icon. - rTreeCtrl.SetExpandedEntryBmp(pEntry, rParam.maImgElementRepeat); - rTreeCtrl.SetCollapsedEntryBmp(pEntry, rParam.maImgElementRepeat); + rTreeCtrl.set_image(*xEntry, rParam.maImgElementRepeat, -1); } - if (pParent) - rTreeCtrl.Expand(pParent); - orcus::xml_structure_tree::entity_names_type aNames; // Insert attributes. rWalker.get_attributes(aNames); for (const orcus::xml_structure_tree::entity_name& rAttrName : aNames) { - SvTreeListEntry* pAttr = rTreeCtrl.InsertEntry(toString(rAttrName, rWalker), pEntry); - - if (!pAttr) - continue; + OUString sAttr(toString(rAttrName, rWalker)); + std::unique_ptr<weld::TreeIter> xAttr(rTreeCtrl.make_iterator()); + rTreeCtrl.insert(xEntry.get(), -1, &sAttr, nullptr, nullptr, nullptr, nullptr, false, xAttr.get()); ScOrcusXMLTreeParam::EntryData& rAttrData = - setUserDataToEntry(*pAttr, rParam.m_UserDataStore, ScOrcusXMLTreeParam::Attribute); + setUserDataToEntry(rTreeCtrl, *xAttr, rParam.m_UserDataStore, ScOrcusXMLTreeParam::Attribute); setEntityNameToUserData(rAttrData, rAttrName, rWalker); - rTreeCtrl.SetExpandedEntryBmp(pAttr, rParam.maImgAttribute); - rTreeCtrl.SetCollapsedEntryBmp(pAttr, rParam.maImgAttribute); + rTreeCtrl.set_image(*xAttr, rParam.maImgAttribute, -1); } - rTreeCtrl.Expand(pEntry); rWalker.get_children(aNames); @@ -122,23 +116,23 @@ void populateTree( for (const auto& rName : aNames) { orcus::xml_structure_tree::element aElem = rWalker.descend(rName); - populateTree(rTreeCtrl, rWalker, rName, aElem.repeat, pEntry, rParam); + populateTree(rTreeCtrl, rWalker, rName, aElem.repeat, xEntry.get(), rParam); rWalker.ascend(); } } class TreeUpdateSwitch { - SvTreeListBox& mrTreeCtrl; + weld::TreeView& mrTreeCtrl; public: - explicit TreeUpdateSwitch(SvTreeListBox& rTreeCtrl) : mrTreeCtrl(rTreeCtrl) + explicit TreeUpdateSwitch(weld::TreeView& rTreeCtrl) : mrTreeCtrl(rTreeCtrl) { - mrTreeCtrl.SetUpdateMode(false); + mrTreeCtrl.freeze(); } ~TreeUpdateSwitch() { - mrTreeCtrl.SetUpdateMode(true); + mrTreeCtrl.thaw(); } }; @@ -180,7 +174,7 @@ ScOrcusXMLContextImpl::ScOrcusXMLContextImpl(ScDocument& rDoc, const OUString& r ScOrcusXMLContextImpl::~ScOrcusXMLContextImpl() {} -void ScOrcusXMLContextImpl::loadXMLStructure(SvTreeListBox& rTreeCtrl, ScOrcusXMLTreeParam& rParam) +void ScOrcusXMLContextImpl::loadXMLStructure(weld::TreeView& rTreeCtrl, ScOrcusXMLTreeParam& rParam) { rParam.m_UserDataStore.clear(); @@ -197,9 +191,7 @@ void ScOrcusXMLContextImpl::loadXMLStructure(SvTreeListBox& rTreeCtrl, ScOrcusXM aXmlTree.parse(&aStrm[0], aStrm.size()); TreeUpdateSwitch aSwitch(rTreeCtrl); - rTreeCtrl.Clear(); - rTreeCtrl.SetDefaultCollapsedEntryBmp(rParam.maImgElementDefault); - rTreeCtrl.SetDefaultExpandedEntryBmp(rParam.maImgElementDefault); + rTreeCtrl.clear(); orcus::xml_structure_tree::walker aWalker = aXmlTree.get_walker(); @@ -215,6 +207,11 @@ void ScOrcusXMLContextImpl::loadXMLStructure(SvTreeListBox& rTreeCtrl, ScOrcusXM { SAL_WARN("sc.orcus", "parsing failed with an unknown error " << e.what()); } + + rTreeCtrl.all_foreach([&rTreeCtrl](weld::TreeIter& rEntry){ + rTreeCtrl.expand_row(rEntry); + return false; + }); } namespace { diff --git a/sc/source/ui/inc/xmlsourcedlg.hxx b/sc/source/ui/inc/xmlsourcedlg.hxx index 822ac54b72ea..8b4c6b1871cb 100644 --- a/sc/source/ui/inc/xmlsourcedlg.hxx +++ b/sc/source/ui/inc/xmlsourcedlg.hxx @@ -26,78 +26,89 @@ class ScDocument; class ScRange; class ScOrcusXMLContext; -class ScXMLSourceDlg : public ScAnyRefDlg +struct CustomCompare { - VclPtr<PushButton> mpBtnSelectSource; - VclPtr<FixedText> mpFtSourceFile; - - VclPtr<VclContainer> mpMapGrid; - - VclPtr<SvTreeListBox> mpLbTree; - VclPtr<formula::RefEdit> mpRefEdit; - VclPtr<formula::RefButton> mpRefBtn; + weld::TreeView& mrLbTree; + CustomCompare(weld::TreeView& rLbTree) + : mrLbTree(rLbTree) + { + } + bool operator()(const std::unique_ptr<weld::TreeIter>& lhs, const std::unique_ptr<weld::TreeIter>& rhs) const + { + return mrLbTree.iter_compare(*lhs, *rhs) == -1; + } +}; - VclPtr<PushButton> mpBtnOk; - VclPtr<CancelButton> mpBtnCancel; +class ScXMLSourceDlg : public ScAnyRefDlgController +{ OUString maSrcPath; ScOrcusXMLTreeParam maXMLParam; - std::set<const SvTreeListEntry*> maCellLinks; - std::set<const SvTreeListEntry*> maRangeLinks; - std::vector<SvTreeListEntry*> maHighlightedEntries; - SvTreeListEntry* mpCurRefEntry; + std::unique_ptr<weld::TreeIter> mxCurRefEntry; std::unique_ptr<ScOrcusXMLContext> mpXMLContext; ScDocument* mpDoc; - - VclPtr<formula::RefEdit> mpActiveEdit; bool mbDlgLostFocus; + formula::WeldRefEdit* mpActiveEdit; + std::unique_ptr<weld::Button> mxBtnSelectSource; + std::unique_ptr<weld::Label> mxFtSourceFile; + + std::unique_ptr<weld::Container> mxMapGrid; + + std::unique_ptr<weld::TreeView> mxLbTree; + std::unique_ptr<formula::WeldRefEdit> mxRefEdit; + std::unique_ptr<formula::WeldRefButton> mxRefBtn; + + std::unique_ptr<weld::Button> mxBtnOk; + std::unique_ptr<weld::Button> mxBtnCancel; + + CustomCompare maCustomCompare; + + std::set<std::unique_ptr<weld::TreeIter>, CustomCompare> maCellLinks; + std::set<std::unique_ptr<weld::TreeIter>, CustomCompare> maRangeLinks; + public: - ScXMLSourceDlg( - SfxBindings* pB, SfxChildWindow* pCW, vcl::Window* pParent, ScDocument* pDoc); + ScXMLSourceDlg(SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent, ScDocument* pDoc); virtual ~ScXMLSourceDlg() override; - virtual void dispose() override; virtual bool IsRefInputMode() const override; virtual void SetReference(const ScRange& rRange, ScDocument* pDoc) override; virtual void Deactivate() override; virtual void SetActive() override; - virtual bool Close() override; + virtual void Close() override; private: void SelectSourceFile(); void LoadSourceFileStructure(const OUString& rPath); - void HandleGetFocus(const Control* pCtrl); void TreeItemSelected(); - void DefaultElementSelected(SvTreeListEntry& rEntry); - void RepeatElementSelected(SvTreeListEntry& rEntry); - void AttributeSelected(SvTreeListEntry& rEntry); + void DefaultElementSelected(weld::TreeIter& rEntry); + void RepeatElementSelected(weld::TreeIter& rEntry); + void AttributeSelected(weld::TreeIter& rEntry); void SetNonLinkable(); void SetSingleLinkable(); void SetRangeLinkable(); - void SelectAllChildEntries(SvTreeListEntry& rEntry); + void SelectAllChildEntries(weld::TreeIter& rEntry); /** * Check if any of its parents is linked or repeated. The passed entry is * not checked; its parent is the first one to be checked, then all its * parents get checked all the way to the root. */ - bool IsParentDirty(SvTreeListEntry* pEntry) const; + bool IsParentDirty(weld::TreeIter* pEntry) const; - bool IsChildrenDirty(SvTreeListEntry* pEntry) const; + bool IsChildrenDirty(weld::TreeIter* pEntry) const; void OkPressed(); void CancelPressed(); void RefEditModified(); - DECL_LINK(GetFocusHdl, Control&, void); - DECL_LINK(BtnPressedHdl, Button*, void); - DECL_LINK(TreeItemSelectHdl, SvTreeListBox*, void); - DECL_LINK(RefModifiedHdl, Edit&, void); + DECL_LINK(BtnPressedHdl, weld::Button&, void); + DECL_LINK(TreeItemSelectHdl, weld::TreeView&, void); + DECL_LINK(RefModifiedHdl, formula::WeldRefEdit&, void); }; #endif diff --git a/sc/source/ui/view/reffact.cxx b/sc/source/ui/view/reffact.cxx index cb743915f43a..fd4e47966f6b 100644 --- a/sc/source/ui/view/reffact.cxx +++ b/sc/source/ui/view/reffact.cxx @@ -36,7 +36,7 @@ SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScNameDlgWrapper, FID_DEFINE_NAME) SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScNameDefDlgWrapper, FID_ADD_NAME ) SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScSolverDlgWrapper, SID_OPENDLG_SOLVE ) SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScOptSolverDlgWrapper, SID_OPENDLG_OPTSOLVER ) -SFX_IMPL_MODELESSDIALOG_WITHID(ScXMLSourceDlgWrapper, SID_MANAGE_XML_SOURCE) +SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScXMLSourceDlgWrapper, SID_MANAGE_XML_SOURCE) SFX_IMPL_MODELESSDIALOG_WITHID(ScPivotLayoutWrapper, SID_OPENDLG_PIVOTTABLE ) SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScTabOpDlgWrapper, SID_OPENDLG_TABOP ) SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScFilterDlgWrapper, SID_FILTER ) @@ -129,7 +129,7 @@ IMPL_CONTROLLER_CHILD_CTOR( ScSolverDlgWrapper, SID_OPENDLG_SOLVE ) IMPL_CONTROLLER_CHILD_CTOR( ScOptSolverDlgWrapper, SID_OPENDLG_OPTSOLVER ) -IMPL_CHILD_CTOR( ScXMLSourceDlgWrapper, SID_MANAGE_XML_SOURCE) +IMPL_CONTROLLER_CHILD_CTOR( ScXMLSourceDlgWrapper, SID_MANAGE_XML_SOURCE) IMPL_CHILD_CTOR( ScPivotLayoutWrapper, SID_OPENDLG_PIVOTTABLE ) diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx index 25d555c76aad..9c7691a1464a 100644 --- a/sc/source/ui/view/tabvwshc.cxx +++ b/sc/source/ui/view/tabvwshc.cxx @@ -167,12 +167,6 @@ VclPtr<SfxModelessDialog> ScTabViewShell::CreateRefDialog( } break; - case SID_MANAGE_XML_SOURCE: - { - pResult = VclPtr<ScXMLSourceDlg>::Create(pB, pCW, pParent, pDoc); - } - break; - case WID_CONDFRMT_REF: { bool bFound = false; @@ -478,6 +472,11 @@ std::unique_ptr<SfxModelessDialogController> ScTabViewShell::CreateRefDialogCont xResult.reset(new ScHighlightChgDlg(pB, pCW, pParent, &GetViewData())); break; } + case SID_MANAGE_XML_SOURCE: + { + xResult.reset(new ScXMLSourceDlg(pB, pCW, pParent, pDoc)); + break; + } } if (xResult) diff --git a/sc/source/ui/xmlsource/xmlsourcedlg.cxx b/sc/source/ui/xmlsource/xmlsourcedlg.cxx index 7a2ef3b8311b..d9d8e0a593d5 100644 --- a/sc/source/ui/xmlsource/xmlsourcedlg.cxx +++ b/sc/source/ui/xmlsource/xmlsourcedlg.cxx @@ -34,9 +34,9 @@ using namespace com::sun::star; namespace { -bool isAttribute(const SvTreeListEntry& rEntry) +bool isAttribute(const weld::TreeView& rControl, const weld::TreeIter& rEntry) { - const ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(rEntry); + const ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(rControl, rEntry); if (!pUserData) return false; @@ -44,24 +44,21 @@ bool isAttribute(const SvTreeListEntry& rEntry) } OUString getXPath( - const SvTreeListBox& rTree, const SvTreeListEntry& rEntry, std::vector<size_t>& rNamespaces) + const weld::TreeView& rTree, const weld::TreeIter& rEntry, std::vector<size_t>& rNamespaces) { OUStringBuffer aBuf; - for (const SvTreeListEntry* p = &rEntry; p; p = rTree.GetParent(p)) + std::unique_ptr<weld::TreeIter> xEntry(rTree.make_iterator(&rEntry)); + do { - const SvLBoxItem* pItem = p->GetFirstItem(SvLBoxItemType::String); - if (!pItem) - continue; - // Collect used namespace. - const ScOrcusXMLTreeParam::EntryData* pData = ScOrcusXMLTreeParam::getUserData(*p); + const ScOrcusXMLTreeParam::EntryData* pData = ScOrcusXMLTreeParam::getUserData(rTree, *xEntry); if (pData) rNamespaces.push_back(pData->mnNamespaceID); - const SvLBoxString* pStr = static_cast<const SvLBoxString*>(pItem); - aBuf.insert(0, pStr->GetText()); - aBuf.insert(0, isAttribute(*p) ? '@' : '/'); + aBuf.insert(0, rTree.get_text(*xEntry, 0)); + aBuf.insert(0, isAttribute(rTree, *xEntry) ? '@' : '/'); } + while (rTree.iter_parent(*xEntry)); return aBuf.makeStringAndClear(); } @@ -69,75 +66,57 @@ OUString getXPath( } ScXMLSourceDlg::ScXMLSourceDlg( - SfxBindings* pB, SfxChildWindow* pCW, vcl::Window* pParent, ScDocument* pDoc) - : ScAnyRefDlg(pB, pCW, pParent, "XMLSourceDialog", - "modules/scalc/ui/xmlsourcedialog.ui") - , mpCurRefEntry(nullptr) + SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent, ScDocument* pDoc) + : ScAnyRefDlgController(pB, pCW, pParent, "modules/scalc/ui/xmlsourcedialog.ui", "XMLSourceDialog") , mpDoc(pDoc) , mbDlgLostFocus(false) -{ - get(mpBtnSelectSource, "selectsource"); - get(mpFtSourceFile, "sourcefile"); - get(mpMapGrid, "mapgrid"); - get(mpLbTree, "tree"); - Size aTreeSize(mpLbTree->LogicToPixel(Size(130, 120), MapMode(MapUnit::MapAppFont))); - mpLbTree->set_width_request(aTreeSize.Width()); - mpLbTree->set_height_request(aTreeSize.Height()); - get(mpRefEdit, "edit"); - mpRefEdit->SetReferences(this, nullptr); - get(mpRefBtn, "ref"); - mpRefBtn->SetReferences(this, mpRefEdit); - get(mpBtnCancel, "cancel"); - get(mpBtnOk, "ok"); - - mpActiveEdit = mpRefEdit; - - maXMLParam.maImgElementDefault = Image(StockImage::Yes, RID_BMP_ELEMENT_DEFAULT); - maXMLParam.maImgElementRepeat = Image(StockImage::Yes, RID_BMP_ELEMENT_REPEAT); - maXMLParam.maImgAttribute = Image(StockImage::Yes, RID_BMP_ELEMENT_ATTRIBUTE); - - Link<Button*,void> aBtnHdl = LINK(this, ScXMLSourceDlg, BtnPressedHdl); - mpBtnSelectSource->SetClickHdl(aBtnHdl); - mpBtnOk->SetClickHdl(aBtnHdl); - mpBtnCancel->SetClickHdl(aBtnHdl); - - Link<Control&,void> aLink2 = LINK(this, ScXMLSourceDlg, GetFocusHdl); - mpRefEdit->SetGetFocusHdl(aLink2); - mpRefBtn->SetGetFocusHdl(aLink2); - - mpLbTree->SetSelectHdl(LINK(this, ScXMLSourceDlg, TreeItemSelectHdl)); - - Link<Edit&,void> aLink = LINK(this, ScXMLSourceDlg, RefModifiedHdl); - mpRefEdit->SetModifyHdl(aLink); - - mpBtnOk->Disable(); + , mxBtnSelectSource(m_xBuilder->weld_button("selectsource")) + , mxFtSourceFile(m_xBuilder->weld_label("sourcefile")) + , mxMapGrid(m_xBuilder->weld_container("mapgrid")) + , mxLbTree(m_xBuilder->weld_tree_view("tree")) + , mxRefEdit(new formula::WeldRefEdit(m_xBuilder->weld_entry("edit"))) + , mxRefBtn(new formula::WeldRefButton(m_xBuilder->weld_button("ref"))) + , mxBtnOk(m_xBuilder->weld_button("ok")) + , mxBtnCancel(m_xBuilder->weld_button("cancel")) + , maCustomCompare(*mxLbTree) + , maCellLinks(maCustomCompare) + , maRangeLinks(maCustomCompare) +{ + mxLbTree->set_size_request(mxLbTree->get_approximate_digit_width() * 40, + mxLbTree->get_height_rows(15)); + mxLbTree->set_selection_mode(SelectionMode::Multiple); + mxRefEdit->SetReferences(this, nullptr); + mxRefBtn->SetReferences(this, mxRefEdit.get()); + + mpActiveEdit = mxRefEdit.get(); + + maXMLParam.maImgElementDefault = RID_BMP_ELEMENT_DEFAULT; + maXMLParam.maImgElementRepeat = RID_BMP_ELEMENT_REPEAT; + maXMLParam.maImgAttribute = RID_BMP_ELEMENT_ATTRIBUTE; + + Link<weld::Button&,void> aBtnHdl = LINK(this, ScXMLSourceDlg, BtnPressedHdl); + mxBtnSelectSource->connect_clicked(aBtnHdl); + mxBtnOk->connect_clicked(aBtnHdl); + mxBtnCancel->connect_clicked(aBtnHdl); + + mxLbTree->connect_changed(LINK(this, ScXMLSourceDlg, TreeItemSelectHdl)); + + Link<formula::WeldRefEdit&,void> aLink = LINK(this, ScXMLSourceDlg, RefModifiedHdl); + mxRefEdit->SetModifyHdl(aLink); + + mxBtnOk->set_sensitive(false); SetNonLinkable(); - mpBtnSelectSource->GrabFocus(); // Initial focus is on the select source button. + mxBtnSelectSource->grab_focus(); // Initial focus is on the select source button. } ScXMLSourceDlg::~ScXMLSourceDlg() { - disposeOnce(); -} - -void ScXMLSourceDlg::dispose() -{ - mpBtnSelectSource.clear(); - mpFtSourceFile.clear(); - mpMapGrid.clear(); - mpLbTree.clear(); - mpRefEdit.clear(); - mpRefBtn.clear(); - mpBtnOk.clear(); - mpBtnCancel.clear(); - mpActiveEdit.clear(); - ScAnyRefDlg::dispose(); } bool ScXMLSourceDlg::IsRefInputMode() const { - return mpActiveEdit != nullptr && mpActiveEdit->IsEnabled(); + return mpActiveEdit != nullptr && mpActiveEdit->GetWidget()->get_sensitive(); } void ScXMLSourceDlg::SetReference(const ScRange& rRange, ScDocument* pDoc) @@ -171,21 +150,21 @@ void ScXMLSourceDlg::SetActive() } else { - GrabFocus(); + m_xDialog->grab_focus(); } RefInputDone(); } -bool ScXMLSourceDlg::Close() +void ScXMLSourceDlg::Close() { - return DoClose(ScXMLSourceDlgWrapper::GetChildWindowId()); + DoClose(ScXMLSourceDlgWrapper::GetChildWindowId()); } void ScXMLSourceDlg::SelectSourceFile() { sfx2::FileDialogHelper aDlgHelper(ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, - FileDialogFlags::NONE, GetFrameWeld()); + FileDialogFlags::NONE, m_xDialog.get()); uno::Reference<ui::dialogs::XFilePicker3> xFilePicker = aDlgHelper.GetFilePicker(); @@ -212,8 +191,7 @@ void ScXMLSourceDlg::SelectSourceFile() // There should only be one file returned from the file picker. maSrcPath = aFiles[0]; - mpFtSourceFile->SetText(maSrcPath); - maHighlightedEntries.clear(); + mxFtSourceFile->set_label(maSrcPath); LoadSourceFileStructure(maSrcPath); } @@ -227,124 +205,100 @@ void ScXMLSourceDlg::LoadSourceFileStructure(const OUString& rPath) if (!mpXMLContext) return; - mpXMLContext->loadXMLStructure(*mpLbTree, maXMLParam); -} - -void ScXMLSourceDlg::HandleGetFocus(const Control* pCtrl) -{ - mpActiveEdit = nullptr; - if (pCtrl == mpRefEdit || pCtrl == mpRefBtn) - mpActiveEdit = mpRefEdit; - - if (mpActiveEdit) - mpActiveEdit->SetSelection(Selection(0, SELECTION_MAX)); + mpXMLContext->loadXMLStructure(*mxLbTree, maXMLParam); } namespace { -class UnhighlightEntry -{ - SvTreeListBox& mrTree; -public: - explicit UnhighlightEntry(SvTreeListBox& rTree) : mrTree(rTree) {} - - void operator() (const SvTreeListEntry* p) - { - SvViewDataEntry* pView = mrTree.GetViewDataEntry(p); - if (!pView) - return; - - pView->SetHighlighted(false); - mrTree.Invalidate(); - } -}; - /** * When the current entry is a direct or indirect child of a mappable * repeat element entry, that entry becomes the reference entry. * Otherwise the reference entry equals the current entry. A reference * entry is the entry that stores mapped cell position. */ -SvTreeListEntry* getReferenceEntry(const SvTreeListBox& rTree, SvTreeListEntry* pCurEntry) +std::unique_ptr<weld::TreeIter> getReferenceEntry(const weld::TreeView& rTree, weld::TreeIter& rCurEntry) { - SvTreeListEntry* pParent = rTree.GetParent(pCurEntry); - SvTreeListEntry* pRefEntry = nullptr; - while (pParent) + std::unique_ptr<weld::TreeIter> xParent(rTree.make_iterator(&rCurEntry)); + bool bParent = rTree.iter_parent(*xParent); + std::unique_ptr<weld::TreeIter> xRefEntry; + while (bParent) { - ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(*pParent); + ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(rTree, *xParent); OSL_ASSERT(pUserData); if (pUserData->meType == ScOrcusXMLTreeParam::ElementRepeat) { // This is a repeat element. - if (pRefEntry) + if (xRefEntry) { // Second repeat element encountered. Not good. - return pCurEntry; + std::unique_ptr<weld::TreeIter> xCurEntry(rTree.make_iterator(&rCurEntry)); + return xCurEntry; } - pRefEntry = pParent; + xRefEntry = rTree.make_iterator(xParent.get()); } - pParent = rTree.GetParent(pParent); + bParent = rTree.iter_parent(*xParent); } - return pRefEntry ? pRefEntry : pCurEntry; -} + if (xRefEntry) + return xRefEntry; + std::unique_ptr<weld::TreeIter> xCurEntry(rTree.make_iterator(&rCurEntry)); + return xCurEntry; } +}; + void ScXMLSourceDlg::TreeItemSelected() { - SvTreeListEntry* pEntry = mpLbTree->GetCurEntry(); - if (!pEntry) + std::unique_ptr<weld::TreeIter> xEntry(mxLbTree->make_iterator()); + if (!mxLbTree->get_cursor(xEntry.get())) return; - if (!maHighlightedEntries.empty()) - { - // Remove highlights from all previously highlighted entries (if any). - std::for_each(maHighlightedEntries.begin(), maHighlightedEntries.end(), UnhighlightEntry(*mpLbTree)); - maHighlightedEntries.clear(); - } + mxLbTree->unselect_all(); + mxLbTree->select(*xEntry); - mpCurRefEntry = getReferenceEntry(*mpLbTree, pEntry); + mxCurRefEntry = getReferenceEntry(*mxLbTree, *xEntry); - ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(*mpCurRefEntry); + ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(*mxLbTree, *mxCurRefEntry); OSL_ASSERT(pUserData); const ScAddress& rPos = pUserData->maLinkedPos; if (rPos.IsValid()) { OUString aStr(rPos.Format(ScRefFlags::ADDR_ABS_3D, mpDoc, mpDoc->GetAddressConvention())); - mpRefEdit->SetRefString(aStr); + mxRefEdit->SetRefString(aStr); } else - mpRefEdit->SetRefString(OUString()); + mxRefEdit->SetRefString(OUString()); switch (pUserData->meType) { case ScOrcusXMLTreeParam::Attribute: - AttributeSelected(*mpCurRefEntry); + AttributeSelected(*mxCurRefEntry); break; case ScOrcusXMLTreeParam::ElementDefault: - DefaultElementSelected(*mpCurRefEntry); + DefaultElementSelected(*mxCurRefEntry); break; case ScOrcusXMLTreeParam::ElementRepeat: - RepeatElementSelected(*mpCurRefEntry); + RepeatElementSelected(*mxCurRefEntry); break; default: ; } } -void ScXMLSourceDlg::DefaultElementSelected(SvTreeListEntry& rEntry) +void ScXMLSourceDlg::DefaultElementSelected(weld::TreeIter& rEntry) { - - if (mpLbTree->GetChildCount(&rEntry) > 0) + if (mxLbTree->iter_has_child(rEntry)) { // Only an element with no child elements (leaf element) can be linked. bool bHasChild = false; - for (SvTreeListEntry* pChild = mpLbTree->FirstChild(&rEntry); pChild; pChild = pChild->NextSibling()) + std::unique_ptr<weld::TreeIter> xChild(mxLbTree->make_iterator(&rEntry)); + mxLbTree->iter_children(*xChild); + do { - ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(*pChild); + ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(*mxLbTree, *xChild); OSL_ASSERT(pUserData); if (pUserData->meType != ScOrcusXMLTreeParam::Attribute) { @@ -353,6 +307,7 @@ void ScXMLSourceDlg::DefaultElementSelected(SvTreeListEntry& rEntry) break; } } + while (mxLbTree->iter_next_sibling(*xChild)); if (bHasChild) { @@ -372,7 +327,7 @@ void ScXMLSourceDlg::DefaultElementSelected(SvTreeListEntry& rEntry) SetSingleLinkable(); } -void ScXMLSourceDlg::RepeatElementSelected(SvTreeListEntry& rEntry) +void ScXMLSourceDlg::RepeatElementSelected(weld::TreeIter& rEntry) { // Check all its parents first. @@ -393,30 +348,26 @@ void ScXMLSourceDlg::RepeatElementSelected(SvTreeListEntry& rEntry) return; } - SvViewDataEntry* p = mpLbTree->GetViewDataEntry(&rEntry); - if (!p->IsHighlighted()) + if (!mxLbTree->is_selected(rEntry)) { // Highlight the entry if not highlighted already. This can happen // when the current entry is a child entry of a repeat element entry. - p->SetHighlighted(true); - mpLbTree->Invalidate(); - maHighlightedEntries.push_back(&rEntry); + mxLbTree->select(rEntry); } SelectAllChildEntries(rEntry); SetRangeLinkable(); } -void ScXMLSourceDlg::AttributeSelected(SvTreeListEntry& rEntry) +void ScXMLSourceDlg::AttributeSelected(weld::TreeIter& rEntry) { // Check all its parent elements and make sure non of them are linked nor // repeat elements. In attribute's case, it's okay to have the immediate // parent element linked (but not range-linked). + std::unique_ptr<weld::TreeIter> xParent(mxLbTree->make_iterator(&rEntry)); + mxLbTree->iter_parent(*xParent); - SvTreeListEntry* pParent = mpLbTree->GetParent(&rEntry); - OSL_ASSERT(pParent); // attribute should have a parent element. - - ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(*pParent); + ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(*mxLbTree, *xParent); OSL_ASSERT(pUserData); if (pUserData->maLinkedPos.IsValid() && pUserData->mbRangeParent) { @@ -436,39 +387,39 @@ void ScXMLSourceDlg::AttributeSelected(SvTreeListEntry& rEntry) void ScXMLSourceDlg::SetNonLinkable() { - mpMapGrid->Disable(); + mxMapGrid->set_sensitive(false); } void ScXMLSourceDlg::SetSingleLinkable() { - mpMapGrid->Enable(); + mxMapGrid->set_sensitive(true); } void ScXMLSourceDlg::SetRangeLinkable() { - mpMapGrid->Enable(); + mxMapGrid->set_sensitive(true); } -void ScXMLSourceDlg::SelectAllChildEntries(SvTreeListEntry& rEntry) +void ScXMLSourceDlg::SelectAllChildEntries(weld::TreeIter& rEntry) { - SvTreeListEntries& rChildren = rEntry.GetChildEntries(); - for (auto const& it : rChildren) + std::unique_ptr<weld::TreeIter> xChild(mxLbTree->make_iterator(&rEntry)); + if (!mxLbTree->iter_children(*xChild)) + return; + do { - SvTreeListEntry& r = *it; - SelectAllChildEntries(r); // select recursively. - SvViewDataEntry* p = mpLbTree->GetViewDataEntry(&r); - p->SetHighlighted(true); - mpLbTree->Invalidate(); - maHighlightedEntries.push_back(&r); - } + SelectAllChildEntries(*xChild); // select recursively. + mxLbTree->select(*xChild); + } while (mxLbTree->iter_next_sibling(*xChild)); } -bool ScXMLSourceDlg::IsParentDirty(SvTreeListEntry* pEntry) const +bool ScXMLSourceDlg::IsParentDirty(weld::TreeIter* pEntry) const { - SvTreeListEntry* pParent = mpLbTree->GetParent(pEntry); - while (pParent) + std::unique_ptr<weld::TreeIter> xParent(mxLbTree->make_iterator(pEntry)); + if (!mxLbTree->iter_parent(*xParent)) + return false; + do { - ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(*pParent); + ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(*mxLbTree, *xParent); assert(pUserData); if (pUserData->maLinkedPos.IsValid()) { @@ -480,16 +431,20 @@ bool ScXMLSourceDlg::IsParentDirty(SvTreeListEntry* pEntry) const // This is a repeat element. return true; } - pParent = mpLbTree->GetParent(pParent); } + while (mxLbTree->iter_parent(*xParent)); return false; } -bool ScXMLSourceDlg::IsChildrenDirty(SvTreeListEntry* pEntry) const +bool ScXMLSourceDlg::IsChildrenDirty(weld::TreeIter* pEntry) const { - for (SvTreeListEntry* pChild = mpLbTree->FirstChild(pEntry); pChild; pChild = pChild->NextSibling()) + std::unique_ptr<weld::TreeIter> xChild(mxLbTree->make_iterator(pEntry)); + if (!mxLbTree->iter_children(*xChild)) + return false; + + do { - ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(*pChild); + ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(*mxLbTree, *xChild); OSL_ASSERT(pUserData); if (pUserData->maLinkedPos.IsValid()) // Already linked. @@ -502,10 +457,10 @@ bool ScXMLSourceDlg::IsChildrenDirty(SvTreeListEntry* pEntry) const if (pUserData->meType == ScOrcusXMLTreeParam::ElementDefault) { // Check recursively. - if (IsChildrenDirty(pChild)) + if (IsChildrenDirty(xChild.get())) return true; } - } + } while (mxLbTree->iter_next_sibling(*xChild)); return false; } @@ -517,18 +472,17 @@ namespace { */ void getFieldLinks( ScOrcusImportXMLParam::RangeLink& rRangeLink, std::vector<size_t>& rNamespaces, - const SvTreeListBox& rTree, const SvTreeListEntry& rEntry) + const weld::TreeView& rTree, const weld::TreeIter& rEntry) { - const SvTreeListEntries& rChildren = rEntry.GetChildEntries(); - if (rChildren.empty()) + std::unique_ptr<weld::TreeIter> xChild(rTree.make_iterator(&rEntry)); + if (!rTree.iter_children(*xChild)) // No more children. We're done. return; - for (auto const& it : rChildren) + do { - const SvTreeListEntry& rChild = *it; - OUString aPath = getXPath(rTree, rChild, rNamespaces); - const ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(rChild); + OUString aPath = getXPath(rTree, *xChild, rNamespaces); + const ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(rTree, *xChild); if (pUserData && pUserData->mbLeafNode) { @@ -538,8 +492,8 @@ void getFieldLinks( } // Walk recursively. - getFieldLinks(rRangeLink, rNamespaces, rTree, rChild); - } + getFieldLinks(rRangeLink, rNamespaces, rTree, *xChild); + } while (rTree.iter_next_sibling(*xChild)); } void removeDuplicates(std::vector<size_t>& rArray) @@ -562,11 +516,10 @@ void ScXMLSourceDlg::OkPressed() // Convert single cell links. { - for (const SvTreeListEntry* pCellLink : maCellLinks) + for (const auto& rEntry : maCellLinks) { - const SvTreeListEntry& rEntry = *pCellLink; - OUString aPath = getXPath(*mpLbTree, rEntry, aParam.maNamespaces); - const ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(rEntry); + OUString aPath = getXPath(*mxLbTree, *rEntry, aParam.maNamespaces); + const ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(*mxLbTree, *rEntry); aParam.maCellLinks.emplace_back( pUserData->maLinkedPos, OUStringToOString(aPath, RTL_TEXTENCODING_UTF8)); @@ -576,16 +529,15 @@ void ScXMLSourceDlg::OkPressed() // Convert range links. For now, an element with range link takes all its // child elements as its fields. { - for (const SvTreeListEntry* pRangeLink : maRangeLinks) + for (const auto& rEntry: maRangeLinks) { - const SvTreeListEntry& rEntry = *pRangeLink; - const ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(rEntry); + const ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(*mxLbTree, *rEntry); ScOrcusImportXMLParam::RangeLink aRangeLink; aRangeLink.maPos = pUserData->maLinkedPos; // Go through all its child elements. - getFieldLinks(aRangeLink, aParam.maNamespaces, *mpLbTree, rEntry); + getFieldLinks(aRangeLink, aParam.maNamespaces, *mxLbTree, *rEntry); aParam.maRangeLinks.push_back(aRangeLink); } @@ -606,17 +558,17 @@ void ScXMLSourceDlg::OkPressed() if (pViewShell) pViewShell->PaintGrid(); - Close(); + m_xDialog->response(RET_OK); } void ScXMLSourceDlg::CancelPressed() { - Close(); + m_xDialog->response(RET_CANCEL); } void ScXMLSourceDlg::RefEditModified() { - OUString aRefStr = mpRefEdit->GetText(); + OUString aRefStr = mxRefEdit->GetText(); // Check if the address is valid. ScAddress aLinkedPos; @@ -625,17 +577,17 @@ void ScXMLSourceDlg::RefEditModified() // TODO: For some unknown reason, setting the ref invalid will hide the text altogether. // Find out how to make this work. -// mpRefEdit->SetRefValid(bValid); +// mxRefEdit->SetRefValid(bValid); if (!bValid) aLinkedPos.SetInvalid(); // Set this address to the current reference entry. - if (!mpCurRefEntry) + if (!mxCurRefEntry) // This should never happen. return; - ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(*mpCurRefEntry); + ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(*mxLbTree, *mxCurRefEntry); if (!pUserData) // This should never happen either. return; @@ -647,44 +599,39 @@ void ScXMLSourceDlg::RefEditModified() if (bRepeatElem) { if (bValid) - maRangeLinks.insert(mpCurRefEntry); + maRangeLinks.insert(mxLbTree->make_iterator(mxCurRefEntry.get())); else - maRangeLinks.erase(mpCurRefEntry); + maRangeLinks.erase(mxCurRefEntry); } else { if (bValid) - maCellLinks.insert(mpCurRefEntry); + maCellLinks.insert(mxLbTree->make_iterator(mxCurRefEntry.get())); else - maCellLinks.erase(mpCurRefEntry); + maCellLinks.erase(mxCurRefEntry); } // Enable the import button only when at least one link exists. bool bHasLink = !maCellLinks.empty() || !maRangeLinks.empty(); - mpBtnOk->Enable(bHasLink); -} - -IMPL_LINK(ScXMLSourceDlg, GetFocusHdl, Control&, rCtrl, void) -{ - HandleGetFocus(&rCtrl); + mxBtnOk->set_sensitive(bHasLink); } -IMPL_LINK(ScXMLSourceDlg, BtnPressedHdl, Button*, pBtn, void) +IMPL_LINK(ScXMLSourceDlg, BtnPressedHdl, weld::Button&, rBtn, void) { - if (pBtn == mpBtnSelectSource) + if (&rBtn == mxBtnSelectSource.get()) SelectSourceFile(); - else if (pBtn == mpBtnOk) + else if (&rBtn == mxBtnOk.get()) OkPressed(); - else if (pBtn == mpBtnCancel) + else if (&rBtn == mxBtnCancel.get()) CancelPressed(); } -IMPL_LINK_NOARG(ScXMLSourceDlg, TreeItemSelectHdl, SvTreeListBox*, void) +IMPL_LINK_NOARG(ScXMLSourceDlg, TreeItemSelectHdl, weld::TreeView&, void) { TreeItemSelected(); } -IMPL_LINK_NOARG(ScXMLSourceDlg, RefModifiedHdl, Edit&, void) +IMPL_LINK_NOARG(ScXMLSourceDlg, RefModifiedHdl, formula::WeldRefEdit&, void) { RefEditModified(); } diff --git a/sc/uiconfig/scalc/ui/xmlsourcedialog.ui b/sc/uiconfig/scalc/ui/xmlsourcedialog.ui index aa153f6a9cc9..b3fca75ef54f 100644 --- a/sc/uiconfig/scalc/ui/xmlsourcedialog.ui +++ b/sc/uiconfig/scalc/ui/xmlsourcedialog.ui @@ -1,24 +1,95 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> +<!-- Generated with glade 3.22.1 --> <interface domain="sc"> <requires lib="gtk+" version="3.18"/> - <requires lib="LibreOffice" version="1.0"/> <object class="GtkImage" id="image1"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="pixbuf">sc/res/file.png</property> + <property name="icon_name">sc/res/file.png</property> + </object> + <object class="GtkTreeStore" id="liststore1"> + <columns> + <!-- column-name expander --> + <column type="GdkPixbuf"/> + <!-- column-name text --> + <column type="gchararray"/> + <!-- column-name id --> + <column type="gchararray"/> + </columns> </object> <object class="GtkDialog" id="XMLSourceDialog"> <property name="can_focus">False</property> <property name="border_width">6</property> <property name="title" translatable="yes" context="xmlsourcedialog|XMLSourceDialog">XML Source</property> <property name="resizable">False</property> + <property name="default_width">0</property> + <property name="default_height">0</property> <property name="type_hint">dialog</property> + <child> + <placeholder/> + </child> <child internal-child="vbox"> <object class="GtkBox" id="dialog-vbox1"> <property name="can_focus">False</property> <property name="orientation">vertical</property> <property name="spacing">12</property> + <child internal-child="action_area"> + <object class="GtkButtonBox" id="dialog-action_area1"> + <property name="can_focus">False</property> + <property name="layout_style">end</property> + <child> + <object class="GtkButton" id="ok"> + <property name="label" translatable="yes" context="xmlsourcedialog|ok">_Import</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="can_default">True</property> + <property name="has_default">True</property> + <property name="receives_default">True</property> + <property name="use_underline">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="cancel"> + <property name="label">gtk-cancel</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkButton" id="help"> + <property name="label">gtk-help</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + <property name="secondary">True</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">end</property> + <property name="position">2</property> + </packing> + </child> <child> <object class="GtkFrame" id="itemframe"> <property name="visible">True</property> @@ -57,8 +128,8 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="hexpand">True</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="xmlsourcedialog|sourcefile">- not set -</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">1</property> @@ -109,21 +180,6 @@ <property name="column_spacing">12</property> <property name="row_homogeneous">True</property> <child> - <object class="vcllo-SvTreeListBox" id="tree:border"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="hexpand">True</property> - <property name="vexpand">True</property> - <child internal-child="selection"> - <object class="GtkTreeSelection" id="Tree List-selection1"/> - </child> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> <object class="GtkGrid" id="mapgrid"> <property name="visible">True</property> <property name="can_focus">False</property> @@ -134,9 +190,9 @@ <object class="GtkLabel" id="label5"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="xmlsourcedialog|label5">Mapped cell:</property> <property name="use_underline">True</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> @@ -145,7 +201,7 @@ </packing> </child> <child> - <object class="foruilo-RefEdit" id="edit"> + <object class="GtkEntry" id="edit"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="width_chars">20</property> @@ -156,7 +212,7 @@ </packing> </child> <child> - <object class="foruilo-RefButton" id="ref"> + <object class="GtkButton" id="ref"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> @@ -172,6 +228,53 @@ <property name="top_attach">0</property> </packing> </child> + <child> + <object class="GtkScrolledWindow"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="shadow_type">in</property> + <child> + <object class="GtkTreeView" id="tree"> + <property name="width_request">-1</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="model">liststore1</property> + <property name="headers_visible">False</property> + <property name="search_column">1</property> + <property name="show_expanders">True</property> + <child internal-child="selection"> + <object class="GtkTreeSelection" id="Macro Library List-selection1"/> + </child> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn2"> + <property name="spacing">6</property> + <child> + <object class="GtkCellRendererPixbuf" id="cellrenderertext4"/> + <attributes> + <attribute name="pixbuf">0</attribute> + </attributes> + </child> + <child> + <object class="GtkCellRendererText" id="cellrenderertext2"/> + <attributes> + <attribute name="text">1</attribute> + </attributes> + </child> + </object> + </child> + </object> + </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> </object> </child> </object> @@ -193,64 +296,6 @@ <property name="position">1</property> </packing> </child> - <child internal-child="action_area"> - <object class="GtkButtonBox" id="dialog-action_area1"> - <property name="can_focus">False</property> - <property name="layout_style">end</property> - <child> - <object class="GtkButton" id="ok"> - <property name="label" translatable="yes" context="xmlsourcedialog|ok">_Import</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="has_default">True</property> - <property name="receives_default">True</property> - <property name="use_underline">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkButton" id="cancel"> - <property name="label">gtk-cancel</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="use_stock">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - <child> - <object class="GtkButton" id="help"> - <property name="label">gtk-help</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="use_stock">True</property> - <property name="yalign">0.55000001192092896</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">2</property> - <property name="secondary">True</property> - </packing> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="pack_type">end</property> - <property name="position">2</property> - </packing> - </child> </object> </child> <action-widgets> diff --git a/solenv/sanitizers/ui/modules/scalc.false b/solenv/sanitizers/ui/modules/scalc.false index dcfc4752be91..1b76ef53568b 100644 --- a/solenv/sanitizers/ui/modules/scalc.false +++ b/solenv/sanitizers/ui/modules/scalc.false @@ -57,6 +57,7 @@ sc/uiconfig/scalc/ui/ttestdialog.ui://GtkButton[@id='variable2-range-button'] bu sc/uiconfig/scalc/ui/ttestdialog.ui://GtkButton[@id='output-range-button'] button-no-label sc/uiconfig/scalc/ui/validationcriteriapage.ui://GtkButton[@id='validref'] no-labelled-by sc/uiconfig/scalc/ui/validationcriteriapage.ui://GtkButton[@id='validref'] button-no-label +sc/uiconfig/scalc/ui/xmlsourcedialog.ui://GtkButton[@id='ref'] button-no-label sc/uiconfig/scalc/ui/ztestdialog.ui://GtkButton[@id='variable1-range-button'] button-no-label sc/uiconfig/scalc/ui/ztestdialog.ui://GtkButton[@id='variable2-range-button'] button-no-label sc/uiconfig/scalc/ui/ztestdialog.ui://GtkButton[@id='output-range-button'] button-no-label diff --git a/solenv/sanitizers/ui/modules/scalc.suppr b/solenv/sanitizers/ui/modules/scalc.suppr index 312079c8a5bf..37dbd6754bf4 100644 --- a/solenv/sanitizers/ui/modules/scalc.suppr +++ b/solenv/sanitizers/ui/modules/scalc.suppr @@ -232,6 +232,6 @@ sc/uiconfig/scalc/ui/validationcriteriapage.ui://GtkButton[@id='validref'] no-la sc/uiconfig/scalc/ui/validationcriteriapage.ui://GtkTextView[@id='minlist'] no-labelled-by sc/uiconfig/scalc/ui/validationcriteriapage.ui://GtkLabel[@id='hintft'] orphan-label sc/uiconfig/scalc/ui/xmlsourcedialog.ui://GtkLabel[@id='sourcefile'] orphan-label -sc/uiconfig/scalc/ui/xmlsourcedialog.ui://vcllo-SvTreeListBox[@id='tree:border'] no-labelled-by +sc/uiconfig/scalc/ui/xmlsourcedialog.ui://GtkTreeView[@id='tree'] no-labelled-by sc/uiconfig/scalc/ui/xmlsourcedialog.ui://GtkLabel[@id='label5'] orphan-label -sc/uiconfig/scalc/ui/xmlsourcedialog.ui://foruilo-RefEdit[@id='edit'] no-labelled-by +sc/uiconfig/scalc/ui/xmlsourcedialog.ui://GtkEntry[@id='edit'] no-labelled-by commit 7d53d5899bc798b49c99d36e4611204c05585915 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Mon Apr 29 09:51:37 2019 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Mon Apr 29 14:31:37 2019 +0200 gtk_tree_model_iter_parent modifies the 1st arg, not 2nd Change-Id: I015022c4dd68f152ef5e56947031ccf4bfaf2b1c Reviewed-on: https://gerrit.libreoffice.org/71516 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index e2024dd6a2c6..1893335fa645 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -7000,7 +7000,6 @@ public: } if (!gtk_tree_model_iter_parent(pModel, &tmp, &iter)) return false; - tmp = iter; if (gtk_tree_model_iter_next(pModel, &tmp)) { rGtkIter.iter = tmp; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits