11#include <bitmaps.hlst>
12#include <document.hxx>
22#include <com/sun/star/ui/dialogs/XFilePicker3.hpp>
23#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
24#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
43 std::unique_ptr<weld::TreeIter> xEntry(rTree.
make_iterator(&rEntry));
49 rNamespaces.push_back(
pData->mnNamespaceID);
52 std::u16string_view sSeparator;
53 if (isAttribute(rTree, *xEntry))
61 return aBuf.makeStringAndClear();
70 , mbDlgLostFocus(false)
71 , mxBtnSelectSource(m_xBuilder->weld_button(
"selectsource"))
72 , mxFtSourceFile(m_xBuilder->weld_label(
"sourcefile"))
73 , mxMapGrid(m_xBuilder->weld_container(
"mapgrid"))
74 , mxLbTree(m_xBuilder->weld_tree_view(
"tree"))
75 , mxRefEdit(new
formula::RefEdit(m_xBuilder->weld_entry(
"edit")))
76 , mxRefBtn(new
formula::RefButton(m_xBuilder->weld_button(
"ref")))
77 , mxBtnOk(m_xBuilder->weld_button(
"ok"))
78 , mxBtnCancel(m_xBuilder->weld_button(
"cancel"))
79 , maCustomCompare(*mxLbTree)
80 , maCellLinks(maCustomCompare)
81 , maRangeLinks(maCustomCompare)
85 mxLbTree->set_selection_mode(SelectionMode::Multiple);
97 mxBtnOk->connect_clicked(aBtnHdl);
159 DoClose(ScXMLSourceDlgWrapper::GetChildWindowId());
168 uno::Reference<ui::dialogs::XFilePicker3> xFilePicker = aDlgHelper.
GetFilePicker();
172 aURL.removeSegment();
173 aURL.removeFinalSlash();
175 xFilePicker->setDisplayDirectory(aPath);
177 if (xFilePicker->execute() != ui::dialogs::ExecutableDialogResults::OK)
181 uno::Sequence<OUString> aFiles = xFilePicker->getSelectedFiles();
182 if (!aFiles.hasElements())
214 std::unique_ptr<weld::TreeIter> xParent(rTree.
make_iterator(&rCurEntry));
216 std::unique_ptr<weld::TreeIter> xRefEntry;
220 OSL_ASSERT(pUserData);
232 std::unique_ptr<weld::TreeIter> xCurEntry(rTree.
make_iterator(&rCurEntry));
240 std::unique_ptr<weld::TreeIter> xEntry(
mxLbTree->make_iterator());
241 if (!
mxLbTree->get_cursor(xEntry.get()))
250 OSL_ASSERT(pUserData);
261 switch (pUserData->
meType)
279 if (
mxLbTree->iter_has_child(rEntry))
282 bool bHasChild =
false;
283 std::unique_ptr<weld::TreeIter> xChild(
mxLbTree->make_iterator(&rEntry));
284 (void)
mxLbTree->iter_children(*xChild);
288 OSL_ASSERT(pUserData);
296 while (
mxLbTree->iter_next_sibling(*xChild));
351 std::unique_ptr<weld::TreeIter> xParent(
mxLbTree->make_iterator(&rEntry));
355 OSL_ASSERT(pUserData);
389 std::unique_ptr<weld::TreeIter> xChild(
mxLbTree->make_iterator(&rEntry));
390 if (!
mxLbTree->iter_children(*xChild))
396 }
while (
mxLbTree->iter_next_sibling(*xChild));
401 std::unique_ptr<weld::TreeIter> xParent(
mxLbTree->make_iterator(pEntry));
402 if (!
mxLbTree->iter_parent(*xParent))
414 while (
mxLbTree->iter_parent(*xParent));
420 std::unique_ptr<weld::TreeIter> xChild(
mxLbTree->make_iterator(pEntry));
421 if (!
mxLbTree->iter_children(*xChild))
427 OSL_ASSERT(pUserData);
438 }
while (
mxLbTree->iter_next_sibling(*xChild));
452 OUString aPath = getXPath(rTree, rEntry, rNamespaces);
462 if (pUserData->
mbLeafNode && !aPath.isEmpty())
467 std::unique_ptr<weld::TreeIter> xChild(rTree.
make_iterator(&rEntry));
476 getFieldLinks(rRangeLink, rNamespaces, rTree, *xChild);
481void removeDuplicates(std::vector<size_t>& rArray)
483 std::sort(rArray.begin(), rArray.end());
484 std::vector<size_t>::iterator it = std::unique(rArray.begin(), rArray.end());
485 rArray.erase(it, rArray.end());
538 pShell->Broadcast(
SfxHint(SfxHintId::ScDataChanged));
602 mxBtnOk->set_sensitive(bHasLink);
607 if (&rBtn == mxBtnSelectSource.get())
609 else if (&rBtn == mxBtnOk.get())
611 else if (&rBtn == mxBtnCancel.get())
Reference< XExecutableDialog > m_xDialog
SC_DLLPUBLIC void Format(OStringBuffer &r, ScRefFlags nFlags, const ScDocument *pDocument=nullptr, const Details &rDetails=detailsOOOa1) const
SC_DLLPUBLIC ScRefFlags Parse(const OUString &, const ScDocument &, const Details &rDetails=detailsOOOa1, ExternalInfo *pExtInfo=nullptr, const css::uno::Sequence< css::sheet::ExternalLinkInfo > *pExternalLinks=nullptr, sal_Int32 *pSheetEndPos=nullptr, const OUString *pErrRef=nullptr)
SC_DLLPUBLIC formula::FormulaGrammar::AddressConvention GetAddressConvention() const
SfxObjectShell * GetDocumentShell() const
Collection of orcus filter wrappers.
virtual std::unique_ptr< ScOrcusXMLContext > createXMLContext(ScDocument &rDoc, const OUString &rPath) const =0
Create a context for XML file.
virtual void RefInputStart(formula::RefEdit *pEdit, formula::RefButton *pButton=nullptr) override
virtual void RefInputDone(bool bForced=false) override
bool DoClose(sal_uInt16 nId)
static ScTabViewShell * GetActiveViewShell()
std::set< std::unique_ptr< weld::TreeIter >, CustomCompare > maRangeLinks
std::unique_ptr< formula::RefButton > mxRefBtn
std::unique_ptr< weld::Button > mxBtnCancel
bool IsChildrenDirty(const weld::TreeIter *pEntry) const
std::set< std::unique_ptr< weld::TreeIter >, CustomCompare > maCellLinks
ScXMLSourceDlg(SfxBindings *pB, SfxChildWindow *pCW, weld::Window *pParent, ScDocument *pDoc)
formula::RefEdit * mpActiveEdit
virtual void Close() override
std::unique_ptr< weld::TreeView > mxLbTree
virtual bool IsRefInputMode() const override
virtual void Deactivate() override
void SelectAllChildEntries(const weld::TreeIter &rEntry)
std::unique_ptr< weld::Button > mxBtnSelectSource
virtual ~ScXMLSourceDlg() override
void RepeatElementSelected(const weld::TreeIter &rEntry)
void LoadSourceFileStructure(const OUString &rPath)
std::unique_ptr< weld::Button > mxBtnOk
virtual void SetReference(const ScRange &rRange, ScDocument &rDoc) override
std::unique_ptr< formula::RefEdit > mxRefEdit
bool IsParentDirty(const weld::TreeIter *pEntry) const
Check if any of its parents is linked or repeated.
std::unique_ptr< ScOrcusXMLContext > mpXMLContext
ScOrcusXMLTreeParam maXMLParam
virtual void SetActive() override
std::unique_ptr< weld::Label > mxFtSourceFile
void DefaultElementSelected(const weld::TreeIter &rEntry)
void AttributeSelected(const weld::TreeIter &rEntry)
std::unique_ptr< weld::Container > mxMapGrid
std::unique_ptr< weld::TreeIter > mxCurRefEntry
const css::uno::Reference< css::ui::dialogs::XFilePicker3 > & GetFilePicker() const
void SetContext(Context _eNewContext)
virtual std::unique_ptr< TreeIter > make_iterator(const TreeIter *pOrig=nullptr) const=0
virtual OUString get_text(int row, int col=-1) const=0
virtual bool iter_next_sibling(TreeIter &rIter) const=0
virtual bool iter_parent(TreeIter &rIter) const=0
virtual bool iter_children(TreeIter &rIter) const=0
#define LINK(Instance, Class, Member)
std::unique_ptr< sal_Int32[]> pData
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
std::vector< OString > maRowGroups
std::vector< OString > maFieldPaths
std::vector< RangeLink > maRangeLinks
std::vector< CellLink > maCellLinks
std::vector< size_t > maNamespaces
Custom data stored with each tree item.
bool mbRangeParent
linked cell position (invalid if unlinked)
EntryType meType
numerical ID for xml namespace
static EntryData * getUserData(const weld::TreeView &rControl, const weld::TreeIter &rEntry)
OUString maImgElementRepeat
OUString maImgElementDefault
IMPL_LINK(ScXMLSourceDlg, BtnPressedHdl, weld::Button &, rBtn, void)
IMPL_LINK_NOARG(ScXMLSourceDlg, TreeItemSelectHdl, weld::TreeView &, void)