summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2016-06-09 14:46:17 +0200
committerCaolán McNamara <caolanm@redhat.com>2016-06-10 13:30:21 +0000
commit237032205be4abb7cc7feda3ab642b4abfd5486a (patch)
tree0828312763b29a372359754d7fc0f7a3e6aa647b
parenta73629cf36a484d58aba74057bacdf04d4728599 (diff)
tdf#100257 - Data : XML Source does not work
Revert "sc: boost::ptr_vector->std::vector" This reverts commit 280553e30f4ddc932838f98a9efaac03a988a0df. Reviewed-on: https://gerrit.libreoffice.org/26106 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com> (cherry picked from commit d6a6f587a852ba5c993c658b6b6432a65207f5b7) sc: eeek, a boost::ptr_vector! take it off! take it off! (cherry picked from commit 741077bf1cdb0c9240ee3e90f07a42bef5bb7a8f) Change-Id: Ia50c9cf7902e2e830c6e7f7a13c8f04341556e6c Reviewed-on: https://gerrit.libreoffice.org/26150 Reviewed-by: Noel Grandin <noelgrandin@gmail.com> Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com> (cherry picked from commit 895468d7388ee17ba33804f19bad52933312ae5d) Reviewed-on: https://gerrit.libreoffice.org/26160 Reviewed-by: Eike Rathke <erack@redhat.com> (cherry picked from commit 49b2548231a4eaf3f1304d15b0bb3f050ac99b49) Reviewed-on: https://gerrit.libreoffice.org/26163 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sc/inc/orcusxml.hxx5
-rw-r--r--sc/source/filter/orcus/xmlcontext.cxx27
2 files changed, 21 insertions, 11 deletions
diff --git a/sc/inc/orcusxml.hxx b/sc/inc/orcusxml.hxx
index e16029cf815c..9d803ef20122 100644
--- a/sc/inc/orcusxml.hxx
+++ b/sc/inc/orcusxml.hxx
@@ -15,6 +15,7 @@
#include <vcl/image.hxx>
#include <vector>
+#include <memory>
class SvTreeListEntry;
@@ -37,7 +38,7 @@ struct ScOrcusXMLTreeParam
SC_DLLPUBLIC EntryData(EntryType eType);
};
- typedef std::vector<EntryData> EntryDataVec;
+ typedef std::vector<std::unique_ptr<EntryData>> UserDataStoreType;
Image maImgElementDefault;
Image maImgElementRepeat;
@@ -47,7 +48,7 @@ struct ScOrcusXMLTreeParam
* Store all custom data instances since the tree control doesn't manage
* the life cycle of user datas.
*/
- EntryDataVec maUserDataStore;
+ UserDataStoreType m_UserDataStore;
static SC_DLLPUBLIC EntryData* getUserData(SvTreeListEntry& rEntry);
static SC_DLLPUBLIC const EntryData* getUserData(const SvTreeListEntry& rEntry);
diff --git a/sc/source/filter/orcus/xmlcontext.cxx b/sc/source/filter/orcus/xmlcontext.cxx
index 618b0ce2416d..fbddf7f63b25 100644
--- a/sc/source/filter/orcus/xmlcontext.cxx
+++ b/sc/source/filter/orcus/xmlcontext.cxx
@@ -15,6 +15,7 @@
#include <svtools/treelistbox.hxx>
#include <svtools/treelistentry.hxx>
#include <ucbhelper/content.hxx>
+#include <o3tl/make_unique.hxx>
#include <orcus/spreadsheet/import_interface.hpp>
#include <orcus/xml_structure_tree.hpp>
@@ -34,11 +35,18 @@ using namespace com::sun::star;
namespace {
ScOrcusXMLTreeParam::EntryData& setUserDataToEntry(
- SvTreeListEntry& rEntry, ScOrcusXMLTreeParam::EntryDataVec& rStore, ScOrcusXMLTreeParam::EntryType eType)
+ SvTreeListEntry& rEntry, ScOrcusXMLTreeParam::UserDataStoreType& rStore, ScOrcusXMLTreeParam::EntryType eType)
{
- rStore.push_back(ScOrcusXMLTreeParam::EntryData(eType));
- rEntry.SetUserData(&rStore.back());
- return rStore.back();
+ rStore.push_back(o3tl::make_unique<ScOrcusXMLTreeParam::EntryData>(eType));
+ rEntry.SetUserData(rStore.back().get());
+ return *rStore.back();
+}
+
+void setEntityNameToUserData(
+ ScOrcusXMLTreeParam::EntryData& rEntryData,
+ const orcus::xml_structure_tree::entity_name& entity, const orcus::xml_structure_tree::walker& walker)
+{
+ rEntryData.mnNamespaceID = walker.get_xmlns_index(entity.ns);
}
OUString toString(const orcus::xml_structure_tree::entity_name& entity, const orcus::xml_structure_tree::walker& walker)
@@ -66,9 +74,10 @@ void populateTree(
return;
ScOrcusXMLTreeParam::EntryData& rEntryData = setUserDataToEntry(
- *pEntry, rParam.maUserDataStore,
+ *pEntry, rParam.m_UserDataStore,
bRepeat ? ScOrcusXMLTreeParam::ElementRepeat : ScOrcusXMLTreeParam::ElementDefault);
- rEntryData.mnNamespaceID = rWalker.get_xmlns_index(rElemName.ns);
+
+ setEntityNameToUserData(rEntryData, rElemName, rWalker);
if (bRepeat)
{
@@ -95,8 +104,8 @@ void populateTree(
continue;
ScOrcusXMLTreeParam::EntryData& rAttrData =
- setUserDataToEntry(*pAttr, rParam.maUserDataStore, ScOrcusXMLTreeParam::Attribute);
- rAttrData.mnNamespaceID = rWalker.get_xmlns_index(rAttrName.ns);
+ setUserDataToEntry(*pAttr, rParam.m_UserDataStore, ScOrcusXMLTreeParam::Attribute);
+ setEntityNameToUserData(rAttrData, rAttrName, rWalker);
rTreeCtrl.SetExpandedEntryBmp(pAttr, rParam.maImgAttribute);
rTreeCtrl.SetCollapsedEntryBmp(pAttr, rParam.maImgAttribute);
@@ -172,7 +181,7 @@ ScOrcusXMLContextImpl::~ScOrcusXMLContextImpl() {}
bool ScOrcusXMLContextImpl::loadXMLStructure(SvTreeListBox& rTreeCtrl, ScOrcusXMLTreeParam& rParam)
{
- rParam.maUserDataStore.clear();
+ rParam.m_UserDataStore.clear();
std::string aStrm;
loadContentFromURL(maPath, aStrm);