[Libreoffice-commits] .: Branch 'feature/calc-xml-source' - 1343 commits - accessibility/Library_acc.mk accessibility/prj accessibility/source android/Bootstrap android/experimental android/qa android/sdremote autodoc/source autogen.sh avmedia/Library_avmedia.mk avmedia/prj avmedia/source basctl/Library_basctl.mk basctl/prj basctl/source basegfx/inc basegfx/source basic/CppunitTest_basic_scanner.mk basic/inc basic/Library_sb.mk basic/prj basic/source berkeleydb/db-4.7.25-mingw.patch berkeleydb/db-4.7.25.NC-mingw32hack.patch berkeleydb/db-4.7.25.patch berkeleydb/db-aix.patch berkeleydb/makefile.mk berkeleydb/prj berkeleydb/README bin/distro-install-clean-up bin/distro-install-desktop-integration bin/distro-install-file-lists bin/distro-install-sdk binfilter bin/get_config_variables bin/lo-commit-stat bin/lo-generate-source-tarball bin/lo-pack-sources boost/boost_1_44_0-clang-warnings.patch boost/boost.6397.warnings.patch boost/prj bridges/inc bridges/Makefile bridges/source bridges/test ca iro/cairo cairo/cairo-1.10.2.android.patch cairo/cairo-1.10.2.configure_ac.patch cairo/cairo-1.10.2.ios.patch cairo/cairo-1.10.2.no-atsui.patch cairo/cairo-1.10.2-oldfontconfig.patch cairo/cairo-1.10.2.patch cairo/cairo-1.10.2.wntmsc.patch cairo/cairo.dlsym.lcdfilter.patch cairo/ExternalPackage_cairo.mk cairo/ExternalPackage_pixman.mk cairo/ExternalProject_cairo.mk cairo/ExternalProject_pixman.mk cairo/Makefile cairo/Module_cairo.mk cairo/pixman cairo/pixman-0.24.4.android.patch cairo/pixman-0.24.4.patch cairo/prj cairo/UnpackedTarball_cairo.mk cairo/UnpackedTarball_pixman.mk canvas/inc canvas/source chart2/AllLangResTarget_chartcontroller.mk chart2/Library_chartcontroller.mk chart2/prj chart2/source cli_ure/source codemaker/Executable_cppumaker.mk codemaker/Executable_javamaker.mk codemaker/inc codemaker/prj codemaker/source codemaker/StaticLibrary_codemaker_cpp.mk codemaker/StaticLibrary_codemaker_java.mk codemaker/StaticLibrary_codemaker.mk comphelper/source compilerplugi ns/clang config_host.mk.in config_host.mk.source configure.ac connectivity/AllLangResTarget_hsqldb.mk connectivity/CppunitTest_connectivity_ado.mk connectivity/inc connectivity/Library_flat.mk connectivity/Library_mork.mk connectivity/Module_connectivity.mk connectivity/prj connectivity/qa connectivity/source cosv/inc cppcanvas/source cppuhelper/inc cppuhelper/source cppu/source cpputools/Module_cpputools.mk cpputools/StaticLibrary_uno.mk crashrep/prj cross_tail_build/prj cui/source cui/uiconfig cui/UI_cui.mk cui/util curl/ExternalPackage_curl.mk curl/prj dbaccess/AllLangResTarget_dbu.mk dbaccess/Library_dbu.mk dbaccess/prj dbaccess/source desktop/inc desktop/Library_deploymentmisc.mk desktop/Library_deployment.mk desktop/Library_migrationoo2.mk desktop/Library_migrationoo3.mk desktop/Library_sofficeapp.mk desktop/Makefile desktop/Module_desktop.mk desktop/prj desktop/qa desktop/scripts desktop/source desktop/test desktop/uiconfig desktop/UI_deployment.mk desktop/unx desktop /util desktop/win32 dictionaries distro-configs/LibreOfficeAndroid.conf distro-configs/LibreOfficeAndroidX86.conf distro-configs/LibreOfficeiOS.conf distro-configs/LibreOfficeLinux.conf distro-configs/LibreOfficeMacOSX.conf distro-configs/LibreOfficeMinGW.conf distro-configs/LibreOfficeOpenBSD.conf distro-configs/LibreOfficeWin32.conf distro-configs/OxygenOfficeLinux.conf distro-configs/OxygenOfficeWin32.conf download drawinglayer/source dtrans/source editeng/inc editeng/prj editeng/source embeddedobj/source epm/prj expat/expat-2.1.0.patch expat/Module_expat.mk expat/README expat/StaticLibrary_ascii_expat_xmlparse.mk expat/StaticLibrary_expat.mk expat/StaticLibrary_expat_x64.mk expat/StaticLibrary_expat_xmlparse.mk expat/StaticLibrary_expat_xmltok.mk expat/UnpackedTarball_expat.mk extensions/AllLangResTarget_updchk.mk extensions/Executable_pluginapp.bin.mk extensions/Library_abp.mk extensions/Library_npsoplugin.mk extensions/Library_pl.mk extensions/Library_res.mk extensions /Module_extensions.mk extensions/prj extensions/source extensions/StaticLibrary_plugcon.mk external/gdiplus external/mingw-dlls external/prj extras/Module_extras.mk extras/source extras/Zip_gallrulers.mk extras/Zip_gallsystem.mk filter/AllLangResTarget_xsltdlg.mk filter/Configuration_filter.mk filter/inc filter/Library_egi.mk filter/Library_eme.mk filter/Library_epb.mk filter/Library_epg.mk filter/Library_epp.mk filter/Library_eps.mk filter/Library_ept.mk filter/Library_era.mk filter/Library_eti.mk filter/Library_exp.mk filter/Library_filterconfig.mk filter/Library_flash.mk filter/Library_icd.mk filter/Library_icg.mk filter/Library_idx.mk filter/Library_ime.mk filter/Library_ipb.mk filter/Library_ipd.mk filter/Library_ips.mk filter/Library_ipt.mk filter/Library_ipx.mk filter/Library_ira.mk filter/Library_itg.mk filter/Library_iti.mk filter/Library_msfilter.mk filter/Library_pdffilter.mk filter/Library_placeware.mk filter/Library_svgfilter.mk filter/Library_t602filter.mk filt er/Library_xmlfa.mk filter/Library_xmlfd.mk filter/Library_xsltdlg.mk filter/Library_xsltfilter.mk filter/Module_filter.mk filter/prj filter/qa filter/source filter/uiconfig filter/UI_xsltdlg.mk fontconfig/ExternalProject_fontconfig.mk fontconfig/fontconfig-2.8.0.patch fontconfig/prj forms/prj forms/qa forms/source formula/Library_for.mk formula/source fpicker/Library_fps.mk fpicker/prj fpicker/source framework/AllLangResTarget_fwe.mk framework/dtd framework/inc framework/JunitTest_framework_complex.mk framework/JunitTest_framework_unoapi.mk framework/Library_fwe.mk framework/Library_fwi.mk framework/Library_fwk.mk framework/Library_fwl.mk framework/Library_fwm.mk framework/Library_lomenubar.mk framework/Module_framework.mk framework/Package_inc.mk framework/prj framework/qa framework/source framework/uiconfig framework/util freetype/ExternalProject_freetype.mk freetype/prj g .gitignore .gitmodules graphite/prj helpcompiler/Library_helplinker.mk helpcompiler/prj helpcompiler /source helpcontent2 hunspell/prj hyphen/prj i18npool/CppunitTest_i18npool_test_languagetag.mk i18npool/CppunitTest_i18npool_test_textsearch.mk i18npool/inc i18npool/Library_i18nsearch.mk i18npool/Module_i18npool.mk i18npool/prj i18npool/qa i18npool/source icon-themes/galaxy icon-themes/tango_testing icu/icu4c-android.patch icu/makefile.mk idlc/Executable_idlc.mk idlc/inc idlc/source idl/source instsetoo_native/inc_ooohelppack instsetoo_native/inc_ooolangpack instsetoo_native/inc_openoffice instsetoo_native/inc_sdkoo instsetoo_native/inc_ure instsetoo_native/prj instsetoo_native/util ios/experimental javaunohelper/source jpeg/StaticLibrary_jpeg.mk jvmfwk/source l10ntools/Executable_cfgex.mk l10ntools/Executable_gsicheck.mk l10ntools/Executable_helpex.mk l10ntools/Executable_localize.mk l10ntools/Executable_propex.mk l10ntools/Executable_renewpo.mk l10ntools/Executable_transex3.mk l10ntools/Executable_treex.mk l10ntools/Executable_uiex.mk l10ntools/Executable_ulfex.mk l10ntoo ls/Executable_xrmex.mk l10ntools/inc l10ntools/Module_l10ntools.mk l10ntools/Package_scripts.mk l10ntools/prj l10ntools/README l10ntools/scripts l10ntools/source l10ntools/StaticLibrary_transex.mk l10ntools/workbench lcms2/ExternalPackage_lcms2.mk lcms2/ExternalProject_lcms2.mk lcms2/Makefile lcms2/makefile.mk lcms2/Module_lcms2.mk lcms2/prj lcms2/UnpackedTarball_lcms2.mk libcdr/ExternalProject_libcdr.mk libexttextcat/android.patch libexttextcat/ExternalPackage_exttextcat.mk libexttextcat/ExternalProject_exttextcat.mk libexttextcat/Makefile libexttextcat/makefile.mk libexttextcat/Module_libexttextcat.mk libexttextcat/prj libexttextcat/StaticLibrary_exttextcat.mk libexttextcat/UnpackedTarball_exttextcat.mk libexttextcat/Zip_fingerprint.mk liblangtag/ExternalPackage_langtag_data.mk liblangtag/ExternalPackage_langtag.mk liblangtag/ExternalProject_langtag.mk liblangtag/liblangtag-0.4.0-configure-atomic-cflag-pollution.patch liblangtag/liblangtag-0.4.0-msc-configure.patch liblang tag/liblangtag-0.4.0-msvcprojects.patch liblangtag/liblangtag-0.4.0-ppc.patch liblangtag/liblangtag-0.4.0-windows.patch liblangtag/liblangtag-0.4.0-xmlDocCopyNode.patch liblangtag/Makefile liblangtag/makefile.mk liblangtag/Module_liblangtag.mk liblangtag/prj liblangtag/README liblangtag/UnpackedTarball_langtag.mk liblangtag/Zip_liblangtag_data.mk liborcus/ExternalProject_liborcus.mk liborcus/liborcus_0.1.0-link-with-Boost.System.patch liborcus/liborcus_0.1.0-warnings.patch liborcus/Package_liborcus.mk liborcus/UnpackedTarball_orcus.mk Library_merged.mk librelogo/Addons.xcu librelogo/ChangeLog librelogo/Configuration_librelogo.mk librelogo/description-en.txt librelogo/description-hu.txt librelogo/description.xml librelogo/Extension_librelogo.mk librelogo/help librelogo/icons librelogo/LibreLogo librelogo/LibreLogoDummy.py librelogo/Makefile librelogo/make.py librelogo/META-INF librelogo/Module_librelogo.mk librelogo/Office librelogo/prj librelogo/pythonpath librelogo/README l ibrelogo/source libvisio/ExternalProject_libvisio.mk libwpd/ExternalProject_libwpd.mk lingucomponent/Library_MacOSXSpell.mk lingucomponent/source linguistic/inc linguistic/source linguistic/workben lotuswordpro/Library_lwpft.mk lotuswordpro/source lpsolve/ccc.static lpsolve/ExternalPackage_lpsolve.mk lpsolve/ExternalProject_lpsolve.mk lpsolve/lp_solve_5.5.patch lpsolve/lp_solve_5.5-windows.patch lpsolve/Makefile lpsolve/makefile.mk lpsolve/Module_lpsolve.mk lpsolve/prj lpsolve/UnpackedTarball_lpsolve.mk m4/ax_boost_system.m4 Makefile.top migrationanalysis/no_localization migrationanalysis/prj migrationanalysis/README migrationanalysis/Read_Me.odt migrationanalysis/src migrationanalysis/util Module_cross_tail_build.mk Module_tail_build.mk more_fonts/ExternalPackage_opensans.mk more_fonts/ExternalPackage_ptserif.mk more_fonts/ExternalPackage_sourcecode.mk more_fonts/ExternalPackage_sourcesans.mk more_fonts/Module_more_fonts.mk more_fonts/UnpackedTarball_opensans.mk more_fonts/ UnpackedTarball_ptserif.mk more_fonts/UnpackedTarball_sourcecode.mk more_fonts/UnpackedTarball_sourcesans.mk moz/makefile.mk mysqlc/source mythes/ExternalProject_mythes.mk mythes/prj nlpsolver/Extension_nlpsolver.mk nlpsolver/help nlpsolver/prj np_sdk/Module_np_sdk.mk np_sdk/mozsrc np_sdk/Package_inc.mk np_sdk/Package_mozilla_inc.mk np_sdk/Package_npapi.mk np_sdk/StaticLibrary_nputils.mk odk/cfgWin.js odk/configure.pl odk/docs odk/examples odk/inc odk/index.html odk/pack odk/setsdkenv_unix odk/setsdkenv_unix.csh.in odk/setsdkenv_unix.sh.in odk/setsdkenv_windows.bat odk/setsdkenv_windows.template odk/setsdkname.bat odk/settings odk/source odk/util offapi/com offapi/org offapi/type_reference offapi/UnoApi_offapi.mk officecfg/Configuration_officecfg.mk officecfg/Makefile officecfg/prj officecfg/registry officecfg/util ooo.lst.in oox/inc oox/Library_oox.mk oox/source openldap/prj package/source padmin/source postgresql/libpq-parallel-build.patch postgresql/postgresql-9.1.1-autor econf.patch postgresql/postgresql-9.1.1-libreoffice.patch postgresql/postgresql-9.2.1-autoreconf.patch postgresql/postgresql-9.2.1-libreoffice.patch postgresql/postgresql-libs-leak.patch postgresql/postgresql-moz-ldap.patch postgresql/prj postgresql/UnpackedTarball_postgresql.mk postprocess/packcomponents postprocess/packconfig postprocess/packregistry postprocess/prj postprocess/signing python3/ExternalPackage_python3.mk python3/ExternalProject_python3.mk python3/i100492-freebsd.patch.2 python3/Makefile python3/Module_python3.mk python3/Package_python3_mk.mk python3/prj python3/python-3.3.0-aix.patch.1 python3/python-3.3.0-darwin.patch.1 python3/python-3.3.0-i42553.patch.2 python3/python-3.3.0-msvc2012.patch.1 python3/python-3.3.0-msvc-disable.patch.1 python3/python-3.3.0-msvc-x64.patch.1 python3/python-3.3.0-ssl.patch.1 python3/pyversion.Makefile python3/README python3/UnpackedTarball_python3.mk python/makefile.mk python/prj python/Python-2.6.1-cross.berkeleydb.patch pyuno /source qadevOOo/Jar_OOoRunner.mk qadevOOo/runner qadevOOo/testdocs qadevOOo/tests readlicense_oo/CustomTarget_readme.mk readlicense_oo/html readlicense_oo/odt readlicense_oo/prj readlicense_oo/txt README.Android README.cross redland/raptor redland/rasqal redland/redland regexp/inc regexp/Library_regexp.mk regexp/Makefile regexp/Module_regexp.mk regexp/Package_inc.mk regexp/prj regexp/README regexp/source reportbuilder/java reportdesign/inc reportdesign/prj reportdesign/source RepositoryExternal.mk RepositoryFixes.mk Repository.mk RepositoryModule_ooo.mk rsc/source sal/android sal/cpprt sal/cppunittester sal/CppunitTest_Module_DLL.mk sal/CppunitTest_sal_rtl_textenc.mk sal/inc sal/Library_sal.mk sal/Makefile sal/Module_sal.mk sal/osl sal/Package_inc.mk sal/qa sal/rtl sal/test sal/textenc sal/typesconfig sal/util sal/workben sax/Library_expwrap.mk sax/source scaddins/prj sc/AllLangResTarget_sc.mk sccomp/Library_solver.mk sccomp/prj sccomp/source sc/CppunitTest_sc_tablesheetsob j.mk sc/inc sc/Library_scfilt.mk sc/Library_sc.mk scp2/CustomTarget_langmacros.mk scp2/inc scp2/InstallModule_binfilter.mk scp2/InstallModule_ooo.mk scp2/InstallScript_setup_osl.mk scp2/macros scp2/Module_scp2.mk scp2/prj scp2/source sc/prj sc/qa scripting/examples scripting/Library_dlgprov.mk scripting/source sc/sdi sc/source sc/uiconfig sc/UI_scalc.mk sd/AllLangResTarget_sd.mk sdext/Configuration_presenter.mk sdext/CppunitTest_pdfimport.mk sdext/CustomTarget_presenter.mk sdext/Extension_pdfimport.mk sdext/Extension_presenter.mk sdext/Library_pdfimport.mk sdext/Library_presenter.mk sdext/Module_sdext.mk sdext/Package_pdfimport_xcu.mk sdext/Package_pdfimport_xpdfimport.mk sdext/prj sdext/Rdb_pdfimport.mk sdext/Rdb_presenter.mk sdext/source sdext/StaticLibrary_pdfimport_s.mk sd/Library_sd.mk sd/Library_sdui.mk sd/prj sd/source setup_native/prj setup_native/scripts setup_native/source sfx2/AllLangResTarget_sfx2.mk sfx2/inc sfx2/prj sfx2/qa sfx2/source shell/CustomTarget_shlxth dl_res.mk shell/inc shell/Library_losessioninstall.mk shell/Library_ooofilt.mk shell/Library_ooofilt_x64.mk shell/Library_propertyhdl.mk shell/Library_propertyhdl_x64.mk shell/Library_recentfile.mk shell/Library_shlxthdl.mk shell/Library_shlxthdl_x64.mk shell/Module_shell.mk shell/prj shell/source shell/StaticLibrary_shlxthandler_common.mk shell/StaticLibrary_shlxthandler_common_x64.mk shell/StaticLibrary_xmlparser.mk shell/StaticLibrary_xmlparser_x64.mk slideshow/source smoketest/data solenv/bin solenv/gbuild solenv/inc solenv/Makefile solenv/src solver/README solver.README sot/inc sot/Library_sot.mk sot/Package_inc.mk sot/qa sot/source starmath/CppunitTest_starmath_qa_cppunit.mk starmath/inc starmath/Library_sm.mk starmath/Module_starmath.mk starmath/prj starmath/qa starmath/source stoc/test svgio/inc svgio/Library_svgio.mk svgio/Module_svgio.mk svgio/Package_inc.mk svgio/source svgio/svgio.component svl/CppunitTest_svl_urihelper.mk svl/inc svl/Library_svl.mk svl/prj svl/q a svl/source svtools/AllLangResTarget_svt.mk svtools/bmpmaker svtools/Executable_bmp.mk svtools/Executable_bmpsum.mk svtools/Executable_g2g.mk svtools/inc svtools/JunitTest_svtools_unoapi.mk svtools/langsupport svtools/Library_hatchwindowfactory.mk svtools/Library_svt.mk svtools/Module_svtools.mk svtools/Package_inc.mk svtools/prj svtools/qa svtools/source svtools/uiconfig svtools/UI_svt.mk svtools/util svx/AllLangResTarget_svx.mk svx/inc svx/Library_textconversiondlgs.mk svx/prj svx/source sw/AllLangResTarget_sw.mk sw/CppunitTest_sw_subsequent_odfexport.mk sw/CppunitTest_sw_subsequent_odfimport.mk sw/CppunitTest_sw_subsequent_ooxmlexport.mk sw/CppunitTest_sw_subsequent_rtfexport.mk sw/CppunitTest_sw_subsequent_rtfimport.mk sw/CppunitTest_sw_subsequent_ww8export.mk swext/Extension_wiki-publisher.mk swext/mediawiki swext/prj sw/inc sw/Library_swui.mk sw/prj sw/qa sw/sdi sw/source sw/uiconfig sw/UI_swriter.mk sysui/desktop sysui/prj sysui/source sysui/util tail_build/prj test/ source toolkit/AllLangResTarget_tk.mk toolkit/inc toolkit/Library_tk.mk toolkit/Package_inc.mk toolkit/qa toolkit/source tools/inc tools/source translations udkapi/com unodevtools/source unotest/source unotools/inc unotools/Library_utl.mk unotools/source unoxml/qa unoxml/source unusedcode.easy unusedcode.exclude unusedcode.README ure/source uui/Library_uui.mk uui/prj uui/source vbahelper/source vcl/android vcl/aqua vcl/generic vcl/inc vcl/ios vcl/Library_desktop_detector.mk vcl/Library_vcl.mk vcl/Library_vclplug_gen.mk vcl/Library_vclplug_gtk3.mk vcl/Library_vclplug_gtk.mk vcl/Module_vcl.mk vcl/Package_inc.mk vcl/prj vcl/qa vcl/source vcl/uiconfig vcl/unx vcl/win vcl/WinResTarget_vcl.mk vcl/workben wizards/AllLangResTarget_wzi.mk wizards/com wizards/prj wizards/Pyuno_commonwizards.mk writerfilter/CustomTarget_source.mk writerfilter/inc writerfilter/Library_writerfilter.mk writerfilter/qa writerfilter/source xmerge/source xmlhelp/Library_ucpchelp1.mk xmlhelp/Makefile xmlhelp/ prj xmlhelp/source xmlhelp/util xmloff/dtd xmloff/inc xmloff/JunitTest_xmloff_unoapi.mk xmloff/Library_xof.mk xmloff/Module_xmloff.mk xmloff/Package_inc.mk xmloff/qa xmloff/source xmloff/util xmloff/xml xmlscript/source xmlsecurity/Library_xsec_xmlsec.mk xmlsecurity/prj xmlsecurity/source xmlsecurity/test_docs xmlsecurity/tools xpdf/README zlib/prj zlib/StaticLibrary_zlib.mk
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Nov 27 19:05:50 PST 2012
Rebased ref, commits from common ancestor:
commit d60ad97838c1c4bff61b460a276ae86b5e69c74f
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Tue Nov 27 22:01:07 2012 -0500
Get it to build after the rebase.
Change-Id: I86bc4fb6aa4158f0efc3ab765841abcea9063693
diff --git a/sc/Library_scfilt.mk b/sc/Library_scfilt.mk
index c25ecb1..bdb99ca 100644
--- a/sc/Library_scfilt.mk
+++ b/sc/Library_scfilt.mk
@@ -222,7 +222,6 @@ $(eval $(call gb_Library_add_exception_objects,scfilt,\
sc/source/filter/oox/worksheetsettings \
sc/source/filter/orcus/orcusfiltersimpl \
sc/source/filter/orcus/interface \
- sc/source/filter/orcus/orcusxml \
sc/source/filter/orcus/xmlcontext \
))
diff --git a/sc/source/core/tool/orcusxml.cxx b/sc/source/core/tool/orcusxml.cxx
index b3cbd46..c4a7b77 100644
--- a/sc/source/core/tool/orcusxml.cxx
+++ b/sc/source/core/tool/orcusxml.cxx
@@ -10,6 +10,7 @@
#include "orcusxml.hxx"
#include "svtools/treelistbox.hxx"
+#include "svtools/treelistentry.hxx"
#include "rtl/strbuf.hxx"
ScOrcusXMLTreeParam::EntryData::EntryData(EntryType eType) :
diff --git a/sc/source/filter/orcus/xmlcontext.cxx b/sc/source/filter/orcus/xmlcontext.cxx
index c62d39b..337d107 100644
--- a/sc/source/filter/orcus/xmlcontext.cxx
+++ b/sc/source/filter/orcus/xmlcontext.cxx
@@ -13,6 +13,7 @@
#include "document.hxx"
#include "svtools/treelistbox.hxx"
+#include "svtools/treelistentry.hxx"
#define __ORCUS_STATIC_LIB
#include <orcus/spreadsheet/import_interface.hpp>
diff --git a/sc/source/ui/xmlsource/xmlsourcedlg.cxx b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
index 38a1d09..7a3afd4 100644
--- a/sc/source/ui/xmlsource/xmlsourcedlg.cxx
+++ b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
@@ -20,6 +20,7 @@
#include "unotools/pathoptions.hxx"
#include "tools/urlobj.hxx"
#include "svtools/svlbitm.hxx"
+#include "svtools/treelistentry.hxx"
#include "sfx2/objsh.hxx"
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
diff --git a/svtools/inc/svtools/treelistentry.hxx b/svtools/inc/svtools/treelistentry.hxx
index ef33942..dfea265 100644
--- a/svtools/inc/svtools/treelistentry.hxx
+++ b/svtools/inc/svtools/treelistentry.hxx
@@ -72,6 +72,9 @@ public:
bool HasChildListPos() const;
sal_uLong GetChildListPos() const;
+ SvTreeListEntries& GetChildEntries();
+ const SvTreeListEntries& GetChildEntries() const;
+
void Clone(SvTreeListEntry* pSource);
size_t ItemCount() const;
diff --git a/svtools/source/contnr/treelistentry.cxx b/svtools/source/contnr/treelistentry.cxx
index 198c78e..5a97b09 100644
--- a/svtools/source/contnr/treelistentry.cxx
+++ b/svtools/source/contnr/treelistentry.cxx
@@ -97,6 +97,16 @@ sal_uLong SvTreeListEntry::GetChildListPos() const
return ( nListPos & 0x7fffffff );
}
+SvTreeListEntries& SvTreeListEntry::GetChildEntries()
+{
+ return maChildren;
+}
+
+const SvTreeListEntries& SvTreeListEntry::GetChildEntries() const
+{
+ return maChildren;
+}
+
void SvTreeListEntry::Clone(SvTreeListEntry* pSource)
{
nListPos &= 0x80000000;
commit 90d679522618afafaf2ba22bf83031351ae13352
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Mon Nov 26 15:07:01 2012 -0500
Add preliminary icons for use in XML tree from Alexander Wilms.
Change-Id: I69ac622bd9ada7dccfbeda7a2a8c3cfd7717dace
diff --git a/icon-themes/galaxy/sc/res/xml_attribute.png b/icon-themes/galaxy/sc/res/xml_attribute.png
new file mode 100644
index 0000000..013bd4b
Binary files /dev/null and b/icon-themes/galaxy/sc/res/xml_attribute.png differ
diff --git a/icon-themes/galaxy/sc/res/xml_element.png b/icon-themes/galaxy/sc/res/xml_element.png
new file mode 100644
index 0000000..cda4265
Binary files /dev/null and b/icon-themes/galaxy/sc/res/xml_element.png differ
diff --git a/icon-themes/galaxy/sc/res/xml_element_repeat.png b/icon-themes/galaxy/sc/res/xml_element_repeat.png
new file mode 100644
index 0000000..fe90995
Binary files /dev/null and b/icon-themes/galaxy/sc/res/xml_element_repeat.png differ
diff --git a/sc/source/ui/src/xmlsourcedlg.src b/sc/source/ui/src/xmlsourcedlg.src
index d90b498..009fc96 100644
--- a/sc/source/ui/src/xmlsourcedlg.src
+++ b/sc/source/ui/src/xmlsourcedlg.src
@@ -82,19 +82,19 @@ ModelessDialog RID_SCDLG_XML_SOURCE
Image IMG_ELEMENT_DEFAULT
{
- ImageBitmap = Bitmap { File = "page.png" ; };
+ ImageBitmap = Bitmap { File = "xml_element.png" ; };
MaskColor = STD_MASKCOLOR ;
};
Image IMG_ELEMENT_REPEAT
{
- ImageBitmap = Bitmap { File = "pages.png" ; };
+ ImageBitmap = Bitmap { File = "xml_element_repeat.png" ; };
MaskColor = STD_MASKCOLOR ;
};
Image IMG_ELEMENT_ATTRIBUTE
{
- ImageBitmap = Bitmap { File = "time.png" ; };
+ ImageBitmap = Bitmap { File = "xml_attribute.png" ; };
MaskColor = STD_MASKCOLOR ;
};
commit 5bc044b843513112c05779370cca30f5f5ee40cb
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Wed Nov 21 21:19:58 2012 -0500
Use the method from orcus to get the short version of xml namespace name.
Change-Id: I5d64ae380982c09f53dacb1eac721430674e9a31
diff --git a/sc/inc/orcusxml.hxx b/sc/inc/orcusxml.hxx
index 87be8a2..36c41dd 100644
--- a/sc/inc/orcusxml.hxx
+++ b/sc/inc/orcusxml.hxx
@@ -76,8 +76,6 @@ struct ScOrcusImportXMLParam
std::vector<size_t> maNamespaces;
CellLinksType maCellLinks;
RangeLinksType maRangeLinks;
-
- SC_DLLPUBLIC static rtl::OString getShortNamespaceName(size_t nIndex);
};
#endif
diff --git a/sc/source/core/tool/orcusxml.cxx b/sc/source/core/tool/orcusxml.cxx
index cef0333..b3cbd46 100644
--- a/sc/source/core/tool/orcusxml.cxx
+++ b/sc/source/core/tool/orcusxml.cxx
@@ -28,12 +28,4 @@ const ScOrcusXMLTreeParam::EntryData* ScOrcusXMLTreeParam::getUserData(const SvT
ScOrcusImportXMLParam::CellLink::CellLink(const ScAddress& rPos, const OString& rPath) :
maPos(rPos), maPath(rPath) {}
-OString ScOrcusImportXMLParam::getShortNamespaceName(size_t nIndex)
-{
- OStringBuffer aBuf;
- aBuf.append("ns");
- aBuf.append(static_cast<sal_Int32>(nIndex));
- return aBuf.makeStringAndClear();
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/orcus/xmlcontext.cxx b/sc/source/filter/orcus/xmlcontext.cxx
index 3ad6951..c62d39b 100644
--- a/sc/source/filter/orcus/xmlcontext.cxx
+++ b/sc/source/filter/orcus/xmlcontext.cxx
@@ -21,6 +21,8 @@
#include <orcus/orcus_xml.hpp>
#include <orcus/global.hpp>
+#include <string>
+
namespace {
ScOrcusXMLTreeParam::EntryData& setUserDataToEntry(
@@ -43,17 +45,9 @@ OUString toString(const orcus::xml_structure_tree::entity_name& entity, const or
OUStringBuffer aBuf;
if (entity.ns)
{
- // Namespace exists. Namespaces are displayed as ns0, ns1, ns2, ....
- size_t index = walker.get_xmlns_index(entity.ns);
- if (index == orcus::xml_structure_tree::walker::index_not_found)
- // This namespace doesn't exist in this context. Something has gone wrong.
- aBuf.append("???");
- else
- {
- OString aName = ScOrcusImportXMLParam::getShortNamespaceName(index);
- aBuf.append(OUString(aName.getStr(), aName.getLength(), RTL_TEXTENCODING_UTF8));
- }
-
+ // Namespace exists. Use the short version of the xml namespace name for display.
+ std::string aShortName = walker.get_xmlns_short_name(entity.ns);
+ aBuf.appendAscii(aShortName.c_str());
aBuf.append(':');
}
aBuf.append(OUString(entity.name.get(), entity.name.size(), RTL_TEXTENCODING_UTF8));
@@ -212,8 +206,8 @@ public:
if (nsid == orcus::XMLNS_UNKNOWN_ID)
return;
- OString aAlias = ScOrcusImportXMLParam::getShortNamespaceName(index);
- mrFilter.set_namespace_alias(aAlias.getStr(), nsid);
+ std::string alias = mrNsRepo.get_short_name(index);
+ mrFilter.set_namespace_alias(alias.c_str(), nsid);
}
};
commit 443a2d6c22eaa937c1496c2a5ecd0f840017e466
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Wed Nov 21 15:21:41 2012 -0500
Correctly handle xml namespaces when importing xml content.
But it's still not working. I need to dig some more.
Change-Id: I06d4d70e1a4234b031741a496f2651d016c35ecc
diff --git a/sc/inc/orcusxml.hxx b/sc/inc/orcusxml.hxx
index c3a981d..87be8a2 100644
--- a/sc/inc/orcusxml.hxx
+++ b/sc/inc/orcusxml.hxx
@@ -29,6 +29,7 @@ struct ScOrcusXMLTreeParam
/** Custom data stored with each tree item. */
struct EntryData
{
+ size_t mnNamespaceID; /// numerical ID for xml namespace
EntryType meType;
ScAddress maLinkedPos; /// linked cell position (invalid if unlinked)
bool mbRangeParent:1;
@@ -72,8 +73,11 @@ struct ScOrcusImportXMLParam
typedef std::vector<CellLink> CellLinksType;
typedef std::vector<RangeLink> RangeLinksType;
+ std::vector<size_t> maNamespaces;
CellLinksType maCellLinks;
RangeLinksType maRangeLinks;
+
+ SC_DLLPUBLIC static rtl::OString getShortNamespaceName(size_t nIndex);
};
#endif
diff --git a/sc/source/core/tool/orcusxml.cxx b/sc/source/core/tool/orcusxml.cxx
index 3f3c93c..cef0333 100644
--- a/sc/source/core/tool/orcusxml.cxx
+++ b/sc/source/core/tool/orcusxml.cxx
@@ -10,6 +10,7 @@
#include "orcusxml.hxx"
#include "svtools/treelistbox.hxx"
+#include "rtl/strbuf.hxx"
ScOrcusXMLTreeParam::EntryData::EntryData(EntryType eType) :
meType(eType), maLinkedPos(ScAddress::INITIALIZE_INVALID), mbRangeParent(false), mbLeafNode(true) {}
@@ -27,4 +28,12 @@ const ScOrcusXMLTreeParam::EntryData* ScOrcusXMLTreeParam::getUserData(const SvT
ScOrcusImportXMLParam::CellLink::CellLink(const ScAddress& rPos, const OString& rPath) :
maPos(rPos), maPath(rPath) {}
+OString ScOrcusImportXMLParam::getShortNamespaceName(size_t nIndex)
+{
+ OStringBuffer aBuf;
+ aBuf.append("ns");
+ aBuf.append(static_cast<sal_Int32>(nIndex));
+ return aBuf.makeStringAndClear();
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/orcus/xmlcontext.cxx b/sc/source/filter/orcus/xmlcontext.cxx
index 86865cd..3ad6951 100644
--- a/sc/source/filter/orcus/xmlcontext.cxx
+++ b/sc/source/filter/orcus/xmlcontext.cxx
@@ -31,6 +31,13 @@ ScOrcusXMLTreeParam::EntryData& setUserDataToEntry(
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)
{
OUStringBuffer aBuf;
@@ -43,9 +50,10 @@ OUString toString(const orcus::xml_structure_tree::entity_name& entity, const or
aBuf.append("???");
else
{
- aBuf.append("ns");
- aBuf.append(static_cast<sal_Int32>(index));
+ OString aName = ScOrcusImportXMLParam::getShortNamespaceName(index);
+ aBuf.append(OUString(aName.getStr(), aName.getLength(), RTL_TEXTENCODING_UTF8));
}
+
aBuf.append(':');
}
aBuf.append(OUString(entity.name.get(), entity.name.size(), RTL_TEXTENCODING_UTF8));
@@ -66,6 +74,8 @@ void populateTree(
*pEntry, rParam.maUserDataStore,
bRepeat ? ScOrcusXMLTreeParam::ElementRepeat : ScOrcusXMLTreeParam::ElementDefault);
+ setEntityNameToUserData(rEntryData, rElemName, rWalker);
+
if (bRepeat)
{
// Recurring elements use different icon.
@@ -84,13 +94,16 @@ void populateTree(
orcus::xml_structure_tree::entity_names_type::const_iterator itEnd = aNames.end();
for (; it != itEnd; ++it)
{
- orcus::xml_structure_tree::entity_name aAttrName = *it;
- SvTreeListEntry* pAttr = rTreeCtrl.InsertEntry(toString(aAttrName, rWalker), pEntry);
+ const orcus::xml_structure_tree::entity_name& rAttrName = *it;
+ SvTreeListEntry* pAttr = rTreeCtrl.InsertEntry(toString(rAttrName, rWalker), pEntry);
if (!pAttr)
continue;
- setUserDataToEntry(*pAttr, rParam.maUserDataStore, ScOrcusXMLTreeParam::Attribute);
+ ScOrcusXMLTreeParam::EntryData& rAttrData =
+ setUserDataToEntry(*pAttr, rParam.maUserDataStore, ScOrcusXMLTreeParam::Attribute);
+ setEntityNameToUserData(rAttrData, rAttrName, rWalker);
+
rTreeCtrl.SetExpandedEntryBmp(pAttr, rParam.maImgAttribute);
rTreeCtrl.SetCollapsedEntryBmp(pAttr, rParam.maImgAttribute);
}
@@ -183,6 +196,30 @@ bool ScOrcusXMLContextImpl::loadXMLStructure(SvTreeListBox& rTreeCtrl, ScOrcusXM
return true;
}
+namespace {
+
+class SetNamespaceAlias : std::unary_function<size_t, void>
+{
+ orcus::orcus_xml& mrFilter;
+ orcus::xmlns_repository& mrNsRepo;
+public:
+ SetNamespaceAlias(orcus::orcus_xml& filter, orcus::xmlns_repository& repo) :
+ mrFilter(filter), mrNsRepo(repo) {}
+
+ void operator() (size_t index)
+ {
+ orcus::xmlns_id_t nsid = mrNsRepo.get_identifier(index);
+ if (nsid == orcus::XMLNS_UNKNOWN_ID)
+ return;
+
+ OString aAlias = ScOrcusImportXMLParam::getShortNamespaceName(index);
+ mrFilter.set_namespace_alias(aAlias.getStr(), nsid);
+ }
+};
+
+
+}
+
bool ScOrcusXMLContextImpl::importXML(const ScOrcusImportXMLParam& rParam)
{
ScOrcusFactory aFactory(mrDoc);
@@ -192,8 +229,11 @@ bool ScOrcusXMLContextImpl::importXML(const ScOrcusImportXMLParam& rParam)
{
orcus::orcus_xml filter(maNsRepo, &aFactory, NULL);
- // Set cell links.
+ // Define all used namespaces.
+ std::for_each(rParam.maNamespaces.begin(), rParam.maNamespaces.end(), SetNamespaceAlias(filter, maNsRepo));
+
{
+ // Set cell links.
ScOrcusImportXMLParam::CellLinksType::const_iterator it = rParam.maCellLinks.begin();
ScOrcusImportXMLParam::CellLinksType::const_iterator itEnd = rParam.maCellLinks.end();
for (; it != itEnd; ++it)
@@ -208,8 +248,8 @@ bool ScOrcusXMLContextImpl::importXML(const ScOrcusImportXMLParam& rParam)
}
}
- // Set range links.
{
+ // Set range links.
ScOrcusImportXMLParam::RangeLinksType::const_iterator it = rParam.maRangeLinks.begin();
ScOrcusImportXMLParam::RangeLinksType::const_iterator itEnd = rParam.maRangeLinks.end();
for (; it != itEnd; ++it)
diff --git a/sc/source/ui/xmlsource/xmlsourcedlg.cxx b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
index 5019306..38a1d09 100644
--- a/sc/source/ui/xmlsource/xmlsourcedlg.cxx
+++ b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
@@ -39,7 +39,8 @@ bool isAttribute(const SvTreeListEntry& rEntry)
return pUserData->meType == ScOrcusXMLTreeParam::Attribute;
}
-OUString getXPath(const SvTreeListBox& rTree, const SvTreeListEntry& rEntry)
+OUString getXPath(
+ const SvTreeListBox& rTree, const SvTreeListEntry& rEntry, std::vector<size_t>& rNamespaces)
{
OUStringBuffer aBuf;
for (const SvTreeListEntry* p = &rEntry; p; p = rTree.GetParent(p))
@@ -48,6 +49,11 @@ OUString getXPath(const SvTreeListBox& rTree, const SvTreeListEntry& rEntry)
if (!pItem)
continue;
+ // Collect used namespace.
+ const ScOrcusXMLTreeParam::EntryData* pData = ScOrcusXMLTreeParam::getUserData(*p);
+ 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) ? '@' : '/');
@@ -428,7 +434,9 @@ namespace {
/**
* Pick only the leaf elements.
*/
-void getFieldLinks(ScOrcusImportXMLParam::RangeLink& rRangeLink, const SvTreeListBox& rTree, const SvTreeListEntry& rEntry)
+void getFieldLinks(
+ ScOrcusImportXMLParam::RangeLink& rRangeLink, std::vector<size_t>& rNamespaces,
+ const SvTreeListBox& rTree, const SvTreeListEntry& rEntry)
{
const SvTreeListEntries& rChildren = rEntry.GetChildEntries();
if (rChildren.empty())
@@ -439,7 +447,7 @@ void getFieldLinks(ScOrcusImportXMLParam::RangeLink& rRangeLink, const SvTreeLis
for (; it != itEnd; ++it)
{
const SvTreeListEntry& rChild = *it;
- OUString aPath = getXPath(rTree, rChild);
+ OUString aPath = getXPath(rTree, rChild, rNamespaces);
const ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(rChild);
if (pUserData && pUserData->mbLeafNode)
@@ -450,10 +458,17 @@ void getFieldLinks(ScOrcusImportXMLParam::RangeLink& rRangeLink, const SvTreeLis
}
// Walk recursively.
- getFieldLinks(rRangeLink, rTree, rChild);
+ getFieldLinks(rRangeLink, rNamespaces, rTree, rChild);
}
}
+void removeDuplicates(std::vector<size_t>& rArray)
+{
+ std::sort(rArray.begin(), rArray.end());
+ std::vector<size_t>::iterator it = std::unique(rArray.begin(), rArray.end());
+ rArray.erase(it, rArray.end());
+}
+
}
void ScXMLSourceDlg::OkPressed()
@@ -471,7 +486,7 @@ void ScXMLSourceDlg::OkPressed()
for (; it != itEnd; ++it)
{
const SvTreeListEntry& rEntry = **it;
- OUString aPath = getXPath(maLbTree, rEntry);
+ OUString aPath = getXPath(maLbTree, rEntry, aParam.maNamespaces);
const ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(rEntry);
aParam.maCellLinks.push_back(
@@ -493,14 +508,16 @@ void ScXMLSourceDlg::OkPressed()
aRangeLink.maPos = pUserData->maLinkedPos;
// Go through all its child elements.
- getFieldLinks(aRangeLink, maLbTree, rEntry);
+ getFieldLinks(aRangeLink, aParam.maNamespaces, maLbTree, rEntry);
aParam.maRangeLinks.push_back(aRangeLink);
}
}
- // Now do the import.
+ // Remove duplicate namespace IDs.
+ removeDuplicates(aParam.maNamespaces);
+ // Now do the import.
mpXMLContext->importXML(aParam);
// Don't forget to broadcast the change.
commit 43fe627e97a3eb635ce0fa89a82fab678c382cf8
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Wed Nov 21 12:01:51 2012 -0500
Display XML namespace IDs in the tree.
Change-Id: I7223b6ac750a5c96ce9638b490eeae109ed854ef
diff --git a/sc/source/filter/orcus/xmlcontext.cxx b/sc/source/filter/orcus/xmlcontext.cxx
index cc8eccd..86865cd 100644
--- a/sc/source/filter/orcus/xmlcontext.cxx
+++ b/sc/source/filter/orcus/xmlcontext.cxx
@@ -31,13 +31,33 @@ ScOrcusXMLTreeParam::EntryData& setUserDataToEntry(
return rStore.back();
}
+OUString toString(const orcus::xml_structure_tree::entity_name& entity, const orcus::xml_structure_tree::walker& walker)
+{
+ OUStringBuffer aBuf;
+ if (entity.ns)
+ {
+ // Namespace exists. Namespaces are displayed as ns0, ns1, ns2, ....
+ size_t index = walker.get_xmlns_index(entity.ns);
+ if (index == orcus::xml_structure_tree::walker::index_not_found)
+ // This namespace doesn't exist in this context. Something has gone wrong.
+ aBuf.append("???");
+ else
+ {
+ aBuf.append("ns");
+ aBuf.append(static_cast<sal_Int32>(index));
+ }
+ aBuf.append(':');
+ }
+ aBuf.append(OUString(entity.name.get(), entity.name.size(), RTL_TEXTENCODING_UTF8));
+ return aBuf.makeStringAndClear();
+}
+
void populateTree(
SvTreeListBox& rTreeCtrl, orcus::xml_structure_tree::walker& rWalker,
const orcus::xml_structure_tree::entity_name& rElemName, bool bRepeat,
SvTreeListEntry* pParent, ScOrcusXMLTreeParam& rParam)
{
- OUString aName(rElemName.name.get(), rElemName.name.size(), RTL_TEXTENCODING_UTF8);
- SvTreeListEntry* pEntry = rTreeCtrl.InsertEntry(aName, pParent);
+ SvTreeListEntry* pEntry = rTreeCtrl.InsertEntry(toString(rElemName, rWalker), pParent);
if (!pEntry)
// Can this ever happen!?
return;
@@ -65,8 +85,7 @@ void populateTree(
for (; it != itEnd; ++it)
{
orcus::xml_structure_tree::entity_name aAttrName = *it;
- SvTreeListEntry* pAttr = rTreeCtrl.InsertEntry(
- OUString(aAttrName.name.get(), aAttrName.name.size(), RTL_TEXTENCODING_UTF8), pEntry);
+ SvTreeListEntry* pAttr = rTreeCtrl.InsertEntry(toString(aAttrName, rWalker), pEntry);
if (!pAttr)
continue;
commit bbebcba58d2c7c5bc54f09f1d27dd009747c9f5a
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Wed Nov 21 10:58:24 2012 -0500
Adjusted for the orcus interface change on the master branch.
Change-Id: Ie99a1f90c55abf41f9f069fe26f19ed2f4370ae1
diff --git a/sc/source/filter/orcus/xmlcontext.cxx b/sc/source/filter/orcus/xmlcontext.cxx
index 9e0dbba..cc8eccd 100644
--- a/sc/source/filter/orcus/xmlcontext.cxx
+++ b/sc/source/filter/orcus/xmlcontext.cxx
@@ -171,7 +171,7 @@ bool ScOrcusXMLContextImpl::importXML(const ScOrcusImportXMLParam& rParam)
const char* path = aSysPath.getStr();
try
{
- orcus::orcus_xml filter(&aFactory, NULL);
+ orcus::orcus_xml filter(maNsRepo, &aFactory, NULL);
// Set cell links.
{
commit afb9e8c3940e8852673c5e0c9f5c34a8bc0bbbc1
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Mon Nov 19 17:14:43 2012 -0500
Store the xml namespace repository with the context.
We need persistent xml namespaces between loading the structure and
importing the content.
Change-Id: I4b56a7e952ab89b93ea2590c8f0d6b5cb141f039
diff --git a/sc/inc/orcusfilters.hxx b/sc/inc/orcusfilters.hxx
index ee8d3f8..bcf8881 100644
--- a/sc/inc/orcusfilters.hxx
+++ b/sc/inc/orcusfilters.hxx
@@ -46,9 +46,9 @@ class ScOrcusXMLContext
public:
virtual ~ScOrcusXMLContext() {}
- virtual bool loadXMLStructure(SvTreeListBox& rTreeCtrl, ScOrcusXMLTreeParam& rParam) const = 0;
+ virtual bool loadXMLStructure(SvTreeListBox& rTreeCtrl, ScOrcusXMLTreeParam& rParam) = 0;
- virtual bool importXML(const ScOrcusImportXMLParam& rParam) const = 0;
+ virtual bool importXML(const ScOrcusImportXMLParam& rParam) = 0;
};
#endif
diff --git a/sc/source/filter/inc/orcusfiltersimpl.hxx b/sc/source/filter/inc/orcusfiltersimpl.hxx
index 0b6ffa6..673da91 100644
--- a/sc/source/filter/inc/orcusfiltersimpl.hxx
+++ b/sc/source/filter/inc/orcusfiltersimpl.hxx
@@ -12,6 +12,8 @@
#include "orcusfilters.hxx"
+#include <orcus/xml_namespace.hpp>
+
class ScOrcusFiltersImpl : public ScOrcusFilters
{
public:
@@ -26,13 +28,16 @@ class ScOrcusXMLContextImpl : public ScOrcusXMLContext
{
ScDocument& mrDoc;
rtl::OUString maPath;
+
+ orcus::xmlns_repository maNsRepo; /// XML namespace repository for this context.
+
public:
ScOrcusXMLContextImpl(ScDocument& rDoc, const rtl::OUString& rPath);
virtual ~ScOrcusXMLContextImpl();
- virtual bool loadXMLStructure(SvTreeListBox& rTreeCtrl, ScOrcusXMLTreeParam& rParam) const;
+ virtual bool loadXMLStructure(SvTreeListBox& rTreeCtrl, ScOrcusXMLTreeParam& rParam);
- virtual bool importXML(const ScOrcusImportXMLParam& rParam) const;
+ virtual bool importXML(const ScOrcusImportXMLParam& rParam);
};
#endif
diff --git a/sc/source/filter/orcus/xmlcontext.cxx b/sc/source/filter/orcus/xmlcontext.cxx
index d32a55c..9e0dbba 100644
--- a/sc/source/filter/orcus/xmlcontext.cxx
+++ b/sc/source/filter/orcus/xmlcontext.cxx
@@ -124,7 +124,7 @@ ScOrcusXMLContextImpl::ScOrcusXMLContextImpl(ScDocument& rDoc, const OUString& r
ScOrcusXMLContextImpl::~ScOrcusXMLContextImpl() {}
-bool ScOrcusXMLContextImpl::loadXMLStructure(SvTreeListBox& rTreeCtrl, ScOrcusXMLTreeParam& rParam) const
+bool ScOrcusXMLContextImpl::loadXMLStructure(SvTreeListBox& rTreeCtrl, ScOrcusXMLTreeParam& rParam)
{
rParam.maUserDataStore.clear();
@@ -138,8 +138,7 @@ bool ScOrcusXMLContextImpl::loadXMLStructure(SvTreeListBox& rTreeCtrl, ScOrcusXM
if (aStrm.empty())
return false;
- orcus::xmlns_repository repo; // xml namespace repository.
- orcus::xmlns_context cxt = repo.create_context();
+ orcus::xmlns_context cxt = maNsRepo.create_context();
orcus::xml_structure_tree aXmlTree(cxt);
try
{
@@ -165,7 +164,7 @@ bool ScOrcusXMLContextImpl::loadXMLStructure(SvTreeListBox& rTreeCtrl, ScOrcusXM
return true;
}
-bool ScOrcusXMLContextImpl::importXML(const ScOrcusImportXMLParam& rParam) const
+bool ScOrcusXMLContextImpl::importXML(const ScOrcusImportXMLParam& rParam)
{
ScOrcusFactory aFactory(mrDoc);
OString aSysPath = ScOrcusFiltersImpl::toSystemPath(maPath);
commit eb2a353e60ac16d861451f85537ee3e71b9dd976
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Mon Nov 19 16:56:24 2012 -0500
Method description.
Change-Id: I754ef846c3bc2d032a818dce6c223da89b3f8ccd
diff --git a/sc/inc/orcusfilters.hxx b/sc/inc/orcusfilters.hxx
index dd9778d..ee8d3f8 100644
--- a/sc/inc/orcusfilters.hxx
+++ b/sc/inc/orcusfilters.hxx
@@ -29,6 +29,15 @@ public:
virtual bool importCSV(ScDocument& rDoc, const rtl::OUString& rPath) const = 0;
+ /**
+ * Create a context for XML file. The context object stores session
+ * information for each unique XML file. You must create a new context
+ * for each XML file, and never to re-use the same context for multiple
+ * XML files.
+ *
+ * The caller is responsible for deleting the instance returned from this
+ * method when it's done.
+ */
virtual ScOrcusXMLContext* createXMLContext(ScDocument& rDoc, const rtl::OUString& rPath) const = 0;
};
commit 2315ff18579b8f7f3d2130c0d1f31368242ca7fe
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Mon Nov 19 16:45:55 2012 -0500
Separate the XML part of orcus filters into own class.
Along with other reorganization of the orcus interface code...
This XML context object will be used to store data specific to each
loaded XML file, such as XML stream, namespace repository and so on.
Change-Id: I21c43ab0026954c5d52f4985a169934f8fb9f704
diff --git a/sc/Library_scfilt.mk b/sc/Library_scfilt.mk
index 18e302a..c25ecb1 100644
--- a/sc/Library_scfilt.mk
+++ b/sc/Library_scfilt.mk
@@ -221,7 +221,9 @@ $(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/interface \
sc/source/filter/orcus/orcusxml \
+ sc/source/filter/orcus/xmlcontext \
))
ifeq ($(SYSTEM_ZLIB),YES)
diff --git a/sc/inc/orcusfilters.hxx b/sc/inc/orcusfilters.hxx
index 1b94f67..dd9778d 100644
--- a/sc/inc/orcusfilters.hxx
+++ b/sc/inc/orcusfilters.hxx
@@ -17,6 +17,7 @@ class SvTreeListBox;
class Image;
struct ScOrcusXMLTreeParam;
struct ScOrcusImportXMLParam;
+class ScOrcusXMLContext;
/**
* Collection of orcus filter wrappers.
@@ -28,11 +29,17 @@ public:
virtual bool importCSV(ScDocument& rDoc, const rtl::OUString& rPath) const = 0;
- virtual bool loadXMLStructure(
- const rtl::OUString& rPath, SvTreeListBox& rTreeCtrl, ScOrcusXMLTreeParam& rParam) const = 0;
+ virtual ScOrcusXMLContext* createXMLContext(ScDocument& rDoc, const rtl::OUString& rPath) const = 0;
+};
+
+class ScOrcusXMLContext
+{
+public:
+ virtual ~ScOrcusXMLContext() {}
+
+ virtual bool loadXMLStructure(SvTreeListBox& rTreeCtrl, ScOrcusXMLTreeParam& rParam) const = 0;
- virtual bool importXML(
- ScDocument& rDoc, const rtl::OUString& rPath, const ScOrcusImportXMLParam& rParam) const = 0;
+ virtual bool importXML(const ScOrcusImportXMLParam& rParam) const = 0;
};
#endif
diff --git a/sc/source/filter/inc/orcusfiltersimpl.hxx b/sc/source/filter/inc/orcusfiltersimpl.hxx
index f2d2703..0b6ffa6 100644
--- a/sc/source/filter/inc/orcusfiltersimpl.hxx
+++ b/sc/source/filter/inc/orcusfiltersimpl.hxx
@@ -15,13 +15,24 @@
class ScOrcusFiltersImpl : public ScOrcusFilters
{
public:
+ static rtl::OString toSystemPath(const rtl::OUString& rPath);
+
virtual bool importCSV(ScDocument& rDoc, const rtl::OUString& rPath) const;
- virtual bool loadXMLStructure(
- const rtl::OUString& rPath, SvTreeListBox& rTreeCtrl, ScOrcusXMLTreeParam& rParam) const;
+ virtual ScOrcusXMLContext* createXMLContext(ScDocument& rDoc, const rtl::OUString& rPath) const;
+};
+
+class ScOrcusXMLContextImpl : public ScOrcusXMLContext
+{
+ ScDocument& mrDoc;
+ rtl::OUString maPath;
+public:
+ ScOrcusXMLContextImpl(ScDocument& rDoc, const rtl::OUString& rPath);
+ virtual ~ScOrcusXMLContextImpl();
+
+ virtual bool loadXMLStructure(SvTreeListBox& rTreeCtrl, ScOrcusXMLTreeParam& rParam) const;
- virtual bool importXML(
- ScDocument& rDoc, const rtl::OUString& rPath, const ScOrcusImportXMLParam& rParam) const;
+ virtual bool importXML(const ScOrcusImportXMLParam& rParam) const;
};
#endif
diff --git a/sc/source/filter/inc/orcusinterface.hxx b/sc/source/filter/inc/orcusinterface.hxx
new file mode 100644
index 0000000..e2c9c08
--- /dev/null
+++ b/sc/source/filter/inc/orcusinterface.hxx
@@ -0,0 +1,63 @@
+/* -*- 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/.
+ */
+
+#ifndef __SC_ORCUSINTERFACE_HXX__
+#define __SC_ORCUSINTERFACE_HXX__
+
+#include "address.hxx"
+
+#define __ORCUS_STATIC_LIB
+#include <orcus/spreadsheet/import_interface.hpp>
+
+#include <boost/ptr_container/ptr_vector.hpp>
+
+class ScDocument;
+class ScOrcusSheet;
+
+class ScOrcusFactory : public orcus::spreadsheet::iface::import_factory
+{
+ ScDocument& mrDoc;
+ boost::ptr_vector<ScOrcusSheet> maSheets;
+
+public:
+ ScOrcusFactory(ScDocument& rDoc);
+
+ virtual orcus::spreadsheet::iface::import_sheet* append_sheet(const char *sheet_name, size_t sheet_name_length);
+ virtual orcus::spreadsheet::iface::import_sheet* get_sheet(const char *sheet_name, size_t sheet_name_length);
+ virtual orcus::spreadsheet::iface::import_shared_strings* get_shared_strings();
+ virtual orcus::spreadsheet::iface::import_styles* get_styles();
+};
+
+class ScOrcusSheet : public orcus::spreadsheet::iface::import_sheet
+{
+ ScDocument& mrDoc;
+ SCTAB mnTab;
+public:
+ ScOrcusSheet(ScDocument& rDoc, SCTAB nTab);
+
+ // Orcus import interface
+ virtual void set_auto(orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, const char* p, size_t n);
+ virtual void set_format(orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, size_t xf_index);
+ virtual void set_formula(orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, orcus::spreadsheet::formula_grammar_t grammar, const char* p, size_t n);
+ virtual void set_formula_result(orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, const char* p, size_t n);
+ virtual void set_shared_formula(
+ orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, orcus::spreadsheet::formula_grammar_t grammar, size_t sindex,
+ const char* p_formula, size_t n_formula);
+ virtual void set_shared_formula(
+ orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, orcus::spreadsheet::formula_grammar_t grammar, size_t sindex,
+ const char* p_formula, size_t n_formula, const char* p_range, size_t n_range);
+ virtual void set_shared_formula(orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, size_t sindex);
+ virtual void set_string(orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, size_t sindex);
+ virtual void set_value(orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, double value);
+
+ SCTAB getIndex() const { return mnTab; }
+};
+
+#endif
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx
new file mode 100644
index 0000000..d22c208
--- /dev/null
+++ b/sc/source/filter/orcus/interface.cxx
@@ -0,0 +1,121 @@
+/* -*- 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 "orcusinterface.hxx"
+
+#include "document.hxx"
+
+using orcus::spreadsheet::row_t;
+using orcus::spreadsheet::col_t;
+using orcus::spreadsheet::formula_grammar_t;
+
+ScOrcusFactory::ScOrcusFactory(ScDocument& rDoc) : mrDoc(rDoc) {}
+
+orcus::spreadsheet::iface::import_sheet* ScOrcusFactory::append_sheet(const char* sheet_name, size_t sheet_name_length)
+{
+ OUString aTabName(sheet_name, sheet_name_length, RTL_TEXTENCODING_UTF8);
+ if (!mrDoc.InsertTab(SC_TAB_APPEND, aTabName))
+ return NULL;
+
+ SCTAB nTab = mrDoc.GetTableCount() - 1;
+ maSheets.push_back(new ScOrcusSheet(mrDoc, nTab));
+ return &maSheets.back();
+}
+
+class FindSheetByIndex : std::unary_function<ScOrcusSheet, bool>
+{
+ SCTAB mnTab;
+public:
+ FindSheetByIndex(SCTAB nTab) : mnTab(nTab) {}
+ bool operator() (const ScOrcusSheet& rSheet) const
+ {
+ return rSheet.getIndex() == mnTab;
+ }
+};
+
+orcus::spreadsheet::iface::import_sheet* ScOrcusFactory::get_sheet(const char* sheet_name, size_t sheet_name_length)
+{
+ OUString aTabName(sheet_name, sheet_name_length, RTL_TEXTENCODING_UTF8);
+ SCTAB nTab = -1;
+ if (!mrDoc.GetTable(aTabName, nTab))
+ // Sheet by that name not found.
+ return NULL;
+
+ // See if we already have an orcus sheet instance by that index.
+ boost::ptr_vector<ScOrcusSheet>::iterator it =
+ std::find_if(maSheets.begin(), maSheets.end(), FindSheetByIndex(nTab));
+
+ if (it != maSheets.end())
+ // We already have one. Return it.
+ return &(*it);
+
+ // Create a new orcus sheet instance for this.
+ maSheets.push_back(new ScOrcusSheet(mrDoc, nTab));
+ return &maSheets.back();
+}
+
+orcus::spreadsheet::iface::import_shared_strings* ScOrcusFactory::get_shared_strings()
+{
+ // We don't support it yet.
+ return NULL;
+}
+
+orcus::spreadsheet::iface::import_styles* ScOrcusFactory::get_styles()
+{
+ // We don't support it yet.
+ return NULL;
+}
+
+ScOrcusSheet::ScOrcusSheet(ScDocument& rDoc, SCTAB nTab) :
+ mrDoc(rDoc), mnTab(nTab) {}
+
+void ScOrcusSheet::set_auto(row_t row, col_t col, const char* p, size_t n)
+{
+ OUString aVal(p, n, RTL_TEXTENCODING_UTF8);
+ mrDoc.SetString(col, row, mnTab, aVal);
+}
+
+void ScOrcusSheet::set_format(row_t /*row*/, col_t /*col*/, size_t /*xf_index*/)
+{
+}
+
+void ScOrcusSheet::set_formula(
+ row_t /*row*/, col_t /*col*/, formula_grammar_t /*grammar*/, const char* /*p*/, size_t /*n*/)
+{
+}
+
+void ScOrcusSheet::set_formula_result(row_t /*row*/, col_t /*col*/, const char* /*p*/, size_t /*n*/)
+{
+}
+
+void ScOrcusSheet::set_shared_formula(
+ row_t /*row*/, col_t /*col*/, formula_grammar_t /*grammar*/, size_t /*sindex*/,
+ const char* /*p_formula*/, size_t /*n_formula*/)
+{
+}
+
+void ScOrcusSheet::set_shared_formula(
+ row_t /*row*/, col_t /*col*/, formula_grammar_t /*grammar*/, size_t /*sindex*/,
+ const char* /*p_formula*/, size_t /*n_formula*/, const char* /*p_range*/, size_t /*n_range*/)
+{
+}
+
+void ScOrcusSheet::set_shared_formula(row_t /*row*/, col_t /*col*/, size_t /*sindex*/)
+{
+}
+
+void ScOrcusSheet::set_string(row_t /*row*/, col_t /*col*/, size_t /*sindex*/)
+{
+}
+
+void ScOrcusSheet::set_value(row_t /*row*/, col_t /*col*/, double /*value*/)
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/orcus/orcusfiltersimpl.cxx b/sc/source/filter/orcus/orcusfiltersimpl.cxx
index 3fa23e1..0f1c329 100644
--- a/sc/source/filter/orcus/orcusfiltersimpl.cxx
+++ b/sc/source/filter/orcus/orcusfiltersimpl.cxx
@@ -8,187 +8,29 @@
*/
#include "orcusfiltersimpl.hxx"
+#include "orcusinterface.hxx"
#include "document.hxx"
-#include "orcusxml.hxx"
#include "tools/urlobj.hxx"
-#include "svtools/treelistbox.hxx"
#define __ORCUS_STATIC_LIB
#include <orcus/spreadsheet/import_interface.hpp>
#include <orcus/orcus_csv.hpp>
-#include <orcus/xml_structure_tree.hpp>
-#include <orcus/xml_namespace.hpp>
-#include <orcus/orcus_xml.hpp>
#include <orcus/global.hpp>
-#include <boost/ptr_container/ptr_vector.hpp>
-
-using orcus::spreadsheet::row_t;
-using orcus::spreadsheet::col_t;
-using orcus::spreadsheet::formula_grammar_t;
-
#ifdef WNT
#define SYSTEM_PATH INetURLObject::FSYS_DOS
#else
#define SYSTEM_PATH INetURLObject::FSYS_UNX
#endif
-namespace {
-
-OString toSystemPath(const OUString& rPath)
+OString ScOrcusFiltersImpl::toSystemPath(const OUString& rPath)
{
INetURLObject aURL(rPath);
return rtl::OUStringToOString(aURL.getFSysPath(SYSTEM_PATH), RTL_TEXTENCODING_UTF8);
}
-class ScOrcusSheet;
-
-class ScOrcusFactory : public orcus::spreadsheet::iface::import_factory
-{
- ScDocument& mrDoc;
- boost::ptr_vector<ScOrcusSheet> maSheets;
-
-public:
- ScOrcusFactory(ScDocument& rDoc);
-
- virtual orcus::spreadsheet::iface::import_sheet* append_sheet(const char *sheet_name, size_t sheet_name_length);
- virtual orcus::spreadsheet::iface::import_sheet* get_sheet(const char *sheet_name, size_t sheet_name_length);
- virtual orcus::spreadsheet::iface::import_shared_strings* get_shared_strings();
- virtual orcus::spreadsheet::iface::import_styles* get_styles();
-};
-
-class ScOrcusSheet : public orcus::spreadsheet::iface::import_sheet
-{
- ScDocument& mrDoc;
- SCTAB mnTab;
-public:
- ScOrcusSheet(ScDocument& rDoc, SCTAB nTab);
-
- // Orcus import interface
- virtual void set_auto(row_t row, col_t col, const char* p, size_t n);
- virtual void set_format(row_t row, col_t col, size_t xf_index);
- virtual void set_formula(row_t row, col_t col, formula_grammar_t grammar, const char* p, size_t n);
- virtual void set_formula_result(row_t row, col_t col, const char* p, size_t n);
- virtual void set_shared_formula(
- row_t row, col_t col, formula_grammar_t grammar, size_t sindex,
- const char* p_formula, size_t n_formula);
- virtual void set_shared_formula(
- row_t row, col_t col, formula_grammar_t grammar, size_t sindex,
- const char* p_formula, size_t n_formula, const char* p_range, size_t n_range);
- virtual void set_shared_formula(row_t row, col_t col, size_t sindex);
- virtual void set_string(row_t row, col_t col, size_t sindex);
- virtual void set_value(row_t row, col_t col, double value);
-
- SCTAB getIndex() const { return mnTab; }
-};
-
-ScOrcusFactory::ScOrcusFactory(ScDocument& rDoc) : mrDoc(rDoc) {}
-
-orcus::spreadsheet::iface::import_sheet* ScOrcusFactory::append_sheet(const char* sheet_name, size_t sheet_name_length)
-{
- OUString aTabName(sheet_name, sheet_name_length, RTL_TEXTENCODING_UTF8);
- if (!mrDoc.InsertTab(SC_TAB_APPEND, aTabName))
- return NULL;
-
- SCTAB nTab = mrDoc.GetTableCount() - 1;
- maSheets.push_back(new ScOrcusSheet(mrDoc, nTab));
- return &maSheets.back();
-}
-
-class FindSheetByIndex : std::unary_function<ScOrcusSheet, bool>
-{
- SCTAB mnTab;
-public:
- FindSheetByIndex(SCTAB nTab) : mnTab(nTab) {}
- bool operator() (const ScOrcusSheet& rSheet) const
- {
- return rSheet.getIndex() == mnTab;
- }
-};
-
-orcus::spreadsheet::iface::import_sheet* ScOrcusFactory::get_sheet(const char* sheet_name, size_t sheet_name_length)
-{
- OUString aTabName(sheet_name, sheet_name_length, RTL_TEXTENCODING_UTF8);
- SCTAB nTab = -1;
- if (!mrDoc.GetTable(aTabName, nTab))
- // Sheet by that name not found.
- return NULL;
-
- // See if we already have an orcus sheet instance by that index.
- boost::ptr_vector<ScOrcusSheet>::iterator it =
- std::find_if(maSheets.begin(), maSheets.end(), FindSheetByIndex(nTab));
-
- if (it != maSheets.end())
- // We already have one. Return it.
- return &(*it);
-
- // Create a new orcus sheet instance for this.
- maSheets.push_back(new ScOrcusSheet(mrDoc, nTab));
- return &maSheets.back();
-}
-
-orcus::spreadsheet::iface::import_shared_strings* ScOrcusFactory::get_shared_strings()
-{
- // We don't support it yet.
- return NULL;
-}
-
-orcus::spreadsheet::iface::import_styles* ScOrcusFactory::get_styles()
-{
- // We don't support it yet.
- return NULL;
-}
-
-ScOrcusSheet::ScOrcusSheet(ScDocument& rDoc, SCTAB nTab) :
- mrDoc(rDoc), mnTab(nTab) {}
-
-void ScOrcusSheet::set_auto(row_t row, col_t col, const char* p, size_t n)
-{
- OUString aVal(p, n, RTL_TEXTENCODING_UTF8);
- mrDoc.SetString(col, row, mnTab, aVal);
-}
-
-void ScOrcusSheet::set_format(row_t /*row*/, col_t /*col*/, size_t /*xf_index*/)
-{
-}
-
-void ScOrcusSheet::set_formula(
- row_t /*row*/, col_t /*col*/, formula_grammar_t /*grammar*/, const char* /*p*/, size_t /*n*/)
-{
-}
-
-void ScOrcusSheet::set_formula_result(row_t /*row*/, col_t /*col*/, const char* /*p*/, size_t /*n*/)
-{
-}
-
-void ScOrcusSheet::set_shared_formula(
- row_t /*row*/, col_t /*col*/, formula_grammar_t /*grammar*/, size_t /*sindex*/,
- const char* /*p_formula*/, size_t /*n_formula*/)
-{
-}
-
-void ScOrcusSheet::set_shared_formula(
- row_t /*row*/, col_t /*col*/, formula_grammar_t /*grammar*/, size_t /*sindex*/,
- const char* /*p_formula*/, size_t /*n_formula*/, const char* /*p_range*/, size_t /*n_range*/)
-{
-}
-
-void ScOrcusSheet::set_shared_formula(row_t /*row*/, col_t /*col*/, size_t /*sindex*/)
-{
-}
-
-void ScOrcusSheet::set_string(row_t /*row*/, col_t /*col*/, size_t /*sindex*/)
-{
-}
-
-void ScOrcusSheet::set_value(row_t /*row*/, col_t /*col*/, double /*value*/)
-{
-}
-
-} // anonymous namespace
-
bool ScOrcusFiltersImpl::importCSV(ScDocument& rDoc, const OUString& rPath) const
{
ScOrcusFactory aFactory(rDoc);
@@ -209,202 +51,9 @@ bool ScOrcusFiltersImpl::importCSV(ScDocument& rDoc, const OUString& rPath) cons
return true;
}
-namespace {
-
-ScOrcusXMLTreeParam::EntryData& setUserDataToEntry(
- SvTreeListEntry& rEntry, ScOrcusXMLTreeParam::UserDataStoreType& rStore, ScOrcusXMLTreeParam::EntryType eType)
-{
- rStore.push_back(new ScOrcusXMLTreeParam::EntryData(eType));
- rEntry.SetUserData(&rStore.back());
- return rStore.back();
-}
-
-void populateTree(
- SvTreeListBox& rTreeCtrl, orcus::xml_structure_tree::walker& rWalker,
- const orcus::xml_structure_tree::entity_name& rElemName, bool bRepeat,
- SvTreeListEntry* pParent, ScOrcusXMLTreeParam& rParam)
-{
- OUString aName(rElemName.name.get(), rElemName.name.size(), RTL_TEXTENCODING_UTF8);
- SvTreeListEntry* pEntry = rTreeCtrl.InsertEntry(aName, pParent);
- if (!pEntry)
- // Can this ever happen!?
- return;
-
- ScOrcusXMLTreeParam::EntryData& rEntryData = setUserDataToEntry(
- *pEntry, rParam.maUserDataStore,
- bRepeat ? ScOrcusXMLTreeParam::ElementRepeat : ScOrcusXMLTreeParam::ElementDefault);
-
- if (bRepeat)
- {
- // Recurring elements use different icon.
- rTreeCtrl.SetExpandedEntryBmp(pEntry, rParam.maImgElementRepeat);
- rTreeCtrl.SetCollapsedEntryBmp(pEntry, rParam.maImgElementRepeat);
- }
-
- if (pParent)
- rTreeCtrl.Expand(pParent);
-
- orcus::xml_structure_tree::entity_names_type aNames;
-
- // Insert attributes.
- rWalker.get_attributes(aNames);
- orcus::xml_structure_tree::entity_names_type::const_iterator it = aNames.begin();
- orcus::xml_structure_tree::entity_names_type::const_iterator itEnd = aNames.end();
- for (; it != itEnd; ++it)
- {
- orcus::xml_structure_tree::entity_name aAttrName = *it;
- SvTreeListEntry* pAttr = rTreeCtrl.InsertEntry(
- OUString(aAttrName.name.get(), aAttrName.name.size(), RTL_TEXTENCODING_UTF8), pEntry);
-
- if (!pAttr)
- continue;
-
- setUserDataToEntry(*pAttr, rParam.maUserDataStore, ScOrcusXMLTreeParam::Attribute);
- rTreeCtrl.SetExpandedEntryBmp(pAttr, rParam.maImgAttribute);
- rTreeCtrl.SetCollapsedEntryBmp(pAttr, rParam.maImgAttribute);
- }
- rTreeCtrl.Expand(pEntry);
-
- rWalker.get_children(aNames);
-
- // Non-leaf if it has child elements, leaf otherwise.
- rEntryData.mbLeafNode = aNames.empty();
-
- // Insert child elements recursively.
- for (it = aNames.begin(), itEnd = aNames.end(); it != itEnd; ++it)
- {
- orcus::xml_structure_tree::element aElem = rWalker.descend(*it);
- populateTree(rTreeCtrl, rWalker, *it, aElem.repeat, pEntry, rParam);
- rWalker.ascend();
- }
-}
-
-class TreeUpdateSwitch
-{
- SvTreeListBox& mrTreeCtrl;
-public:
- TreeUpdateSwitch(SvTreeListBox& rTreeCtrl) : mrTreeCtrl(rTreeCtrl)
- {
- mrTreeCtrl.SetUpdateMode(false);
- }
-
- ~TreeUpdateSwitch()
- {
- mrTreeCtrl.SetUpdateMode(true);
- }
-};
-
-}
-
-bool ScOrcusFiltersImpl::loadXMLStructure(
- const rtl::OUString& rPath, SvTreeListBox& rTreeCtrl, ScOrcusXMLTreeParam& rParam) const
-{
- rParam.maUserDataStore.clear();
-
- OString aSysPath = toSystemPath(rPath);
- const char* path = aSysPath.getStr();
-
- // TODO: Use our own stream loading call instead of one from orcus.
- std::string aStrm;
- orcus::load_file_content(path, aStrm);
-
- if (aStrm.empty())
- return false;
-
- orcus::xmlns_repository repo; // xml namespace repository.
- orcus::xmlns_context cxt = repo.create_context();
- orcus::xml_structure_tree aXmlTree(cxt);
- try
- {
- aXmlTree.parse(&aStrm[0], aStrm.size());
-
- TreeUpdateSwitch aSwitch(rTreeCtrl);
- rTreeCtrl.Clear();
- rTreeCtrl.SetDefaultCollapsedEntryBmp(rParam.maImgElementDefault);
- rTreeCtrl.SetDefaultExpandedEntryBmp(rParam.maImgElementDefault);
-
- orcus::xml_structure_tree::walker aWalker = aXmlTree.get_walker();
-
- // Root element.
- orcus::xml_structure_tree::element aElem = aWalker.root();
- populateTree(rTreeCtrl, aWalker, aElem.name, aElem.repeat, NULL, rParam);
- }
- catch (const std::exception&)
- {
- // Parsing of this XML file failed.
- return false;
- }
-
- return true;
-}
-
-namespace {
-
-class InsertFieldPath : std::unary_function<OString, void>
-{
- orcus::orcus_xml& mrFilter;
-public:
- InsertFieldPath(orcus::orcus_xml& rFilter) : mrFilter(rFilter) {}
- void operator() (const OString& rPath)
- {
- mrFilter.append_field_link(rPath.getStr());
- }
-};
-
-}
-
-bool ScOrcusFiltersImpl::importXML(
- ScDocument& rDoc, const rtl::OUString& rPath, const ScOrcusImportXMLParam& rParam) const
+ScOrcusXMLContext* ScOrcusFiltersImpl::createXMLContext(ScDocument& rDoc, const rtl::OUString& rPath) const
{
- ScOrcusFactory aFactory(rDoc);
- OString aSysPath = toSystemPath(rPath);
- const char* path = aSysPath.getStr();
- try
- {
- orcus::orcus_xml filter(&aFactory, NULL);
-
- // Set cell links.
- {
- ScOrcusImportXMLParam::CellLinksType::const_iterator it = rParam.maCellLinks.begin();
- ScOrcusImportXMLParam::CellLinksType::const_iterator itEnd = rParam.maCellLinks.end();
- for (; it != itEnd; ++it)
- {
- const ScOrcusImportXMLParam::CellLink& rLink = *it;
- OUString aTabName;
- rDoc.GetName(rLink.maPos.Tab(), aTabName);
- filter.set_cell_link(
- rLink.maPath.getStr(),
- rtl::OUStringToOString(aTabName, RTL_TEXTENCODING_UTF8).getStr(),
- rLink.maPos.Row(), rLink.maPos.Col());
- }
- }
-
- // Set range links.
- {
- ScOrcusImportXMLParam::RangeLinksType::const_iterator it = rParam.maRangeLinks.begin();
- ScOrcusImportXMLParam::RangeLinksType::const_iterator itEnd = rParam.maRangeLinks.end();
- for (; it != itEnd; ++it)
- {
- const ScOrcusImportXMLParam::RangeLink& rLink = *it;
- OUString aTabName;
- rDoc.GetName(rLink.maPos.Tab(), aTabName);
- filter.start_range(
- rtl::OUStringToOString(aTabName, RTL_TEXTENCODING_UTF8).getStr(),
- rLink.maPos.Row(), rLink.maPos.Col());
-
- std::for_each(rLink.maFieldPaths.begin(), rLink.maFieldPaths.end(), InsertFieldPath(filter));
-
- filter.commit_range();
- }
- }
-
- filter.read_file(path);
- }
- catch (const std::exception&)
- {
- return false;
- }
- return true;
+ return new ScOrcusXMLContextImpl(rDoc, rPath);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/orcus/xmlcontext.cxx b/sc/source/filter/orcus/xmlcontext.cxx
new file mode 100644
index 0000000..d32a55c
--- /dev/null
+++ b/sc/source/filter/orcus/xmlcontext.cxx
@@ -0,0 +1,221 @@
+/* -*- 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 "orcusfiltersimpl.hxx"
+#include "orcusinterface.hxx"
+#include "orcusxml.hxx"
+#include "document.hxx"
+
+#include "svtools/treelistbox.hxx"
+
+#define __ORCUS_STATIC_LIB
+#include <orcus/spreadsheet/import_interface.hpp>
+#include <orcus/xml_structure_tree.hpp>
+#include <orcus/xml_namespace.hpp>
+#include <orcus/orcus_xml.hpp>
+#include <orcus/global.hpp>
+
+namespace {
+
+ScOrcusXMLTreeParam::EntryData& setUserDataToEntry(
+ SvTreeListEntry& rEntry, ScOrcusXMLTreeParam::UserDataStoreType& rStore, ScOrcusXMLTreeParam::EntryType eType)
+{
+ rStore.push_back(new ScOrcusXMLTreeParam::EntryData(eType));
+ rEntry.SetUserData(&rStore.back());
+ return rStore.back();
+}
+
+void populateTree(
+ SvTreeListBox& rTreeCtrl, orcus::xml_structure_tree::walker& rWalker,
+ const orcus::xml_structure_tree::entity_name& rElemName, bool bRepeat,
+ SvTreeListEntry* pParent, ScOrcusXMLTreeParam& rParam)
+{
+ OUString aName(rElemName.name.get(), rElemName.name.size(), RTL_TEXTENCODING_UTF8);
+ SvTreeListEntry* pEntry = rTreeCtrl.InsertEntry(aName, pParent);
+ if (!pEntry)
+ // Can this ever happen!?
+ return;
+
+ ScOrcusXMLTreeParam::EntryData& rEntryData = setUserDataToEntry(
+ *pEntry, rParam.maUserDataStore,
+ bRepeat ? ScOrcusXMLTreeParam::ElementRepeat : ScOrcusXMLTreeParam::ElementDefault);
+
+ if (bRepeat)
+ {
+ // Recurring elements use different icon.
+ rTreeCtrl.SetExpandedEntryBmp(pEntry, rParam.maImgElementRepeat);
+ rTreeCtrl.SetCollapsedEntryBmp(pEntry, rParam.maImgElementRepeat);
+ }
+
+ if (pParent)
+ rTreeCtrl.Expand(pParent);
+
+ orcus::xml_structure_tree::entity_names_type aNames;
+
+ // Insert attributes.
+ rWalker.get_attributes(aNames);
+ orcus::xml_structure_tree::entity_names_type::const_iterator it = aNames.begin();
+ orcus::xml_structure_tree::entity_names_type::const_iterator itEnd = aNames.end();
+ for (; it != itEnd; ++it)
+ {
+ orcus::xml_structure_tree::entity_name aAttrName = *it;
+ SvTreeListEntry* pAttr = rTreeCtrl.InsertEntry(
+ OUString(aAttrName.name.get(), aAttrName.name.size(), RTL_TEXTENCODING_UTF8), pEntry);
+
+ if (!pAttr)
+ continue;
+
+ setUserDataToEntry(*pAttr, rParam.maUserDataStore, ScOrcusXMLTreeParam::Attribute);
+ rTreeCtrl.SetExpandedEntryBmp(pAttr, rParam.maImgAttribute);
+ rTreeCtrl.SetCollapsedEntryBmp(pAttr, rParam.maImgAttribute);
+ }
+ rTreeCtrl.Expand(pEntry);
+
+ rWalker.get_children(aNames);
+
+ // Non-leaf if it has child elements, leaf otherwise.
+ rEntryData.mbLeafNode = aNames.empty();
+
+ // Insert child elements recursively.
+ for (it = aNames.begin(), itEnd = aNames.end(); it != itEnd; ++it)
+ {
+ orcus::xml_structure_tree::element aElem = rWalker.descend(*it);
+ populateTree(rTreeCtrl, rWalker, *it, aElem.repeat, pEntry, rParam);
+ rWalker.ascend();
+ }
+}
+
+class TreeUpdateSwitch
+{
+ SvTreeListBox& mrTreeCtrl;
+public:
+ TreeUpdateSwitch(SvTreeListBox& rTreeCtrl) : mrTreeCtrl(rTreeCtrl)
+ {
+ mrTreeCtrl.SetUpdateMode(false);
+ }
+
+ ~TreeUpdateSwitch()
+ {
+ mrTreeCtrl.SetUpdateMode(true);
+ }
+};
+
+class InsertFieldPath : std::unary_function<OString, void>
+{
+ orcus::orcus_xml& mrFilter;
+public:
+ InsertFieldPath(orcus::orcus_xml& rFilter) : mrFilter(rFilter) {}
+ void operator() (const OString& rPath)
+ {
+ mrFilter.append_field_link(rPath.getStr());
+ }
+};
+
+}
+
+ScOrcusXMLContextImpl::ScOrcusXMLContextImpl(ScDocument& rDoc, const OUString& rPath) :
+ ScOrcusXMLContext(), mrDoc(rDoc), maPath(rPath) {}
+
+ScOrcusXMLContextImpl::~ScOrcusXMLContextImpl() {}
+
+bool ScOrcusXMLContextImpl::loadXMLStructure(SvTreeListBox& rTreeCtrl, ScOrcusXMLTreeParam& rParam) const
+{
+ rParam.maUserDataStore.clear();
+
+ OString aSysPath = ScOrcusFiltersImpl::toSystemPath(maPath);
+ const char* path = aSysPath.getStr();
+
+ // TODO: Use our own stream loading call instead of one from orcus.
+ std::string aStrm;
+ orcus::load_file_content(path, aStrm);
+
+ if (aStrm.empty())
+ return false;
+
+ orcus::xmlns_repository repo; // xml namespace repository.
+ orcus::xmlns_context cxt = repo.create_context();
+ orcus::xml_structure_tree aXmlTree(cxt);
+ try
+ {
+ aXmlTree.parse(&aStrm[0], aStrm.size());
+
+ TreeUpdateSwitch aSwitch(rTreeCtrl);
+ rTreeCtrl.Clear();
+ rTreeCtrl.SetDefaultCollapsedEntryBmp(rParam.maImgElementDefault);
+ rTreeCtrl.SetDefaultExpandedEntryBmp(rParam.maImgElementDefault);
+
+ orcus::xml_structure_tree::walker aWalker = aXmlTree.get_walker();
+
+ // Root element.
+ orcus::xml_structure_tree::element aElem = aWalker.root();
+ populateTree(rTreeCtrl, aWalker, aElem.name, aElem.repeat, NULL, rParam);
+ }
+ catch (const std::exception&)
+ {
+ // Parsing of this XML file failed.
+ return false;
+ }
+
+ return true;
+}
+
+bool ScOrcusXMLContextImpl::importXML(const ScOrcusImportXMLParam& rParam) const
+{
+ ScOrcusFactory aFactory(mrDoc);
+ OString aSysPath = ScOrcusFiltersImpl::toSystemPath(maPath);
+ const char* path = aSysPath.getStr();
+ try
+ {
+ orcus::orcus_xml filter(&aFactory, NULL);
+
+ // Set cell links.
+ {
+ ScOrcusImportXMLParam::CellLinksType::const_iterator it = rParam.maCellLinks.begin();
+ ScOrcusImportXMLParam::CellLinksType::const_iterator itEnd = rParam.maCellLinks.end();
+ for (; it != itEnd; ++it)
+ {
+ const ScOrcusImportXMLParam::CellLink& rLink = *it;
+ OUString aTabName;
+ mrDoc.GetName(rLink.maPos.Tab(), aTabName);
+ filter.set_cell_link(
+ rLink.maPath.getStr(),
+ rtl::OUStringToOString(aTabName, RTL_TEXTENCODING_UTF8).getStr(),
+ rLink.maPos.Row(), rLink.maPos.Col());
+ }
+ }
+
+ // Set range links.
+ {
+ ScOrcusImportXMLParam::RangeLinksType::const_iterator it = rParam.maRangeLinks.begin();
+ ScOrcusImportXMLParam::RangeLinksType::const_iterator itEnd = rParam.maRangeLinks.end();
+ for (; it != itEnd; ++it)
+ {
+ const ScOrcusImportXMLParam::RangeLink& rLink = *it;
+ OUString aTabName;
+ mrDoc.GetName(rLink.maPos.Tab(), aTabName);
+ filter.start_range(
+ rtl::OUStringToOString(aTabName, RTL_TEXTENCODING_UTF8).getStr(),
+ rLink.maPos.Row(), rLink.maPos.Col());
+
+ std::for_each(rLink.maFieldPaths.begin(), rLink.maFieldPaths.end(), InsertFieldPath(filter));
+
+ filter.commit_range();
+ }
+ }
+
+ filter.read_file(path);
+ }
+ catch (const std::exception&)
+ {
+ return false;
+ }
+ return true;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/xmlsourcedlg.hxx b/sc/source/ui/inc/xmlsourcedlg.hxx
index e16b52a..1540b29 100644
--- a/sc/source/ui/inc/xmlsourcedlg.hxx
+++ b/sc/source/ui/inc/xmlsourcedlg.hxx
@@ -23,6 +23,7 @@
class ScDocument;
class ScRange;
+class ScOrcusXMLContext;
class ScXMLSourceTree : public SvTreeListBox
{
@@ -55,6 +56,8 @@ class ScXMLSourceDlg : public ScAnyRefDlg
std::set<const SvTreeListEntry*> maCellLinks;
std::set<const SvTreeListEntry*> maRangeLinks;
+ boost::scoped_ptr<ScOrcusXMLContext> mpXMLContext;
+
ScDocument* mpDoc;
formula::RefEdit* mpActiveEdit;
diff --git a/sc/source/ui/xmlsource/xmlsourcedlg.cxx b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
index fa85970..5019306 100644
--- a/sc/source/ui/xmlsource/xmlsourcedlg.cxx
+++ b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
@@ -208,7 +208,11 @@ void ScXMLSourceDlg::LoadSourceFileStructure(const OUString& rPath)
if (!pOrcus)
return;
- pOrcus->loadXMLStructure(rPath, maLbTree, maXMLParam);
+ mpXMLContext.reset(pOrcus->createXMLContext(*mpDoc, rPath));
+ if (!mpXMLContext)
+ return;
+
+ mpXMLContext->loadXMLStructure(maLbTree, maXMLParam);
}
void ScXMLSourceDlg::HandleGetFocus(Control* pCtrl)
@@ -454,6 +458,9 @@ void getFieldLinks(ScOrcusImportXMLParam::RangeLink& rRangeLink, const SvTreeLis
void ScXMLSourceDlg::OkPressed()
{
+ if (!mpXMLContext)
+ return;
+
// Begin import.
ScOrcusImportXMLParam aParam;
@@ -493,11 +500,8 @@ void ScXMLSourceDlg::OkPressed()
}
// Now do the import.
- ScOrcusFilters* pOrcus = ScFormatFilter::Get().GetOrcusFilters();
- if (!pOrcus)
- return;
- pOrcus->importXML(*mpDoc, maSrcPath, aParam);
+ mpXMLContext->importXML(aParam);
// Don't forget to broadcast the change.
SfxObjectShell* pShell = mpDoc->GetDocumentShell();
commit e82b02734c343eea70ac7a00ce507d8e3e08161d
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Mon Nov 19 15:47:10 2012 -0500
Get it to build after updating liborcus from latest master.
Change-Id: Ie9cace11bf869777ff0986d38e856e68ad8fdb57
diff --git a/sc/source/filter/orcus/orcusfiltersimpl.cxx b/sc/source/filter/orcus/orcusfiltersimpl.cxx
index 2584770..3fa23e1 100644
--- a/sc/source/filter/orcus/orcusfiltersimpl.cxx
+++ b/sc/source/filter/orcus/orcusfiltersimpl.cxx
@@ -311,8 +311,9 @@ bool ScOrcusFiltersImpl::loadXMLStructure(
if (aStrm.empty())
return false;
- orcus::xmlns_repository aNsRepo; // xml namespace repository.
- orcus::xml_structure_tree aXmlTree(aNsRepo);
+ orcus::xmlns_repository repo; // xml namespace repository.
+ orcus::xmlns_context cxt = repo.create_context();
+ orcus::xml_structure_tree aXmlTree(cxt);
try
{
aXmlTree.parse(&aStrm[0], aStrm.size());
commit 02ca6e7491c55ce51df8c66db9d520c39f62f9f0
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Thu Nov 15 19:28:23 2012 -0500
Now I can remove this ugly const_cast.
Change-Id: Ifc4d0028d334bd6fa9dfdea86543b5eaf25313e0
diff --git a/sc/source/ui/xmlsource/xmlsourcedlg.cxx b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
index 08cf7cc..fa85970 100644
--- a/sc/source/ui/xmlsource/xmlsourcedlg.cxx
+++ b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
@@ -42,7 +42,7 @@ bool isAttribute(const SvTreeListEntry& rEntry)
OUString getXPath(const SvTreeListBox& rTree, const SvTreeListEntry& rEntry)
{
OUStringBuffer aBuf;
- for (SvTreeListEntry* p = const_cast<SvTreeListEntry*>(&rEntry); p; p = rTree.GetParent(p))
+ for (const SvTreeListEntry* p = &rEntry; p; p = rTree.GetParent(p))
{
const SvLBoxItem* pItem = p->GetFirstItem(SV_ITEM_ID_LBOXSTRING);
if (!pItem)
commit 84a3712ad23bef307a463d920762aa88dc963f37
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Tue Nov 13 17:07:18 2012 -0500
Enable the 'Import' button only when linked data exists.
It makes no sense to allow import if there is no link specified.
Change-Id: I3ff4bfa7fd78c79a2c4ee74c7a1a34d2b7a2d1c4
diff --git a/sc/source/ui/xmlsource/xmlsourcedlg.cxx b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
index dd1ab74..08cf7cc 100644
--- a/sc/source/ui/xmlsource/xmlsourcedlg.cxx
+++ b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
@@ -104,8 +104,10 @@ ScXMLSourceDlg::ScXMLSourceDlg(
aLink = LINK(this, ScXMLSourceDlg, RefModifiedHdl);
maRefEdit.SetModifyHdl(aLink);
+ maBtnOk.Disable();
+
SetNonLinkable();
- maBtnSelectSource.GrabFocus();
+ maBtnSelectSource.GrabFocus(); // Initial focus is on the select source button.
}
ScXMLSourceDlg::~ScXMLSourceDlg()
@@ -559,6 +561,10 @@ void ScXMLSourceDlg::RefEditModified()
else
maCellLinks.erase(pEntry);
}
+
+ // Enable the import button only when at least one link exists.
+ bool bHasLink = !maCellLinks.empty() || !maRangeLinks.empty();
+ maBtnOk.Enable(bHasLink);
}
IMPL_LINK(ScXMLSourceDlg, GetFocusHdl, Control*, pCtrl)
commit 37a755b12f6856277f49b62bc03092e059738a0f
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Tue Nov 13 15:57:35 2012 -0500
Set initial focus to the 'Open XML source' button.
This helps with keyboard-only navigation in this dialog.
Change-Id: Ie3d580ba921c93ae256ad0a503615de7a037323a
diff --git a/sc/source/ui/xmlsource/xmlsourcedlg.cxx b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
index 68e819e..dd1ab74 100644
--- a/sc/source/ui/xmlsource/xmlsourcedlg.cxx
+++ b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
@@ -105,6 +105,7 @@ ScXMLSourceDlg::ScXMLSourceDlg(
maRefEdit.SetModifyHdl(aLink);
SetNonLinkable();
+ maBtnSelectSource.GrabFocus();
}
ScXMLSourceDlg::~ScXMLSourceDlg()
commit 35362a20ed9ce3a1864a489314a6dcafda6bf28e
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Tue Nov 13 15:54:52 2012 -0500
Just call it "XML Source" in the menu for now.
Change-Id: Ic802bd38e976df52ad5216820187ef1334eac5a6
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
index 0d636ad..64ffb88 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
@@ -1206,7 +1206,7 @@
</node>
<node oor:name=".uno:ManageXMLSource" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
- <value xml:lang="en-US">Manage ~XML Source...</value>
+ <value xml:lang="en-US">~XML Source...</value>
</prop>
</node>
<node oor:name=".uno:DataSort" oor:op="replace">
commit 7009efbbd3d141cffcf2b6dd18bd4dd64d4151af
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Tue Nov 13 15:36:14 2012 -0500
Setting a reference via ref picker should update the link ref data.
Change-Id: Ie1559e1ece8d57b09e68676f88991c67ff8db03e
diff --git a/sc/source/ui/xmlsource/xmlsourcedlg.cxx b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
index f9c2c13..68e819e 100644
--- a/sc/source/ui/xmlsource/xmlsourcedlg.cxx
+++ b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
@@ -127,6 +127,8 @@ void ScXMLSourceDlg::SetReference(const ScRange& rRange, ScDocument* pDoc)
OUString aStr;
rRange.aStart.Format(aStr, SCA_ABS_3D, pDoc, pDoc->GetAddressConvention());
mpActiveEdit->SetRefString(aStr);
+
+ RefEditModified();
}
void ScXMLSourceDlg::Deactivate()
commit f025c1f2debe134c5084c00a4b416660dd46fd3d
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Tue Nov 13 15:15:53 2012 -0500
Broadcast and re-paint when the XML import is complete.
Change-Id: I8bf7a3331a24d39ce327264cd43ccb5910ce1251
diff --git a/sc/source/ui/xmlsource/xmlsourcedlg.cxx b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
index 5f3a6e1..f9c2c13 100644
--- a/sc/source/ui/xmlsource/xmlsourcedlg.cxx
+++ b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
@@ -15,10 +15,12 @@
#include "orcusfilters.hxx"
#include "filter.hxx"
#include "reffact.hxx"
+#include "tabvwsh.hxx"
#include "unotools/pathoptions.hxx"
#include "tools/urlobj.hxx"
#include "svtools/svlbitm.hxx"
+#include "sfx2/objsh.hxx"
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
@@ -485,12 +487,22 @@ void ScXMLSourceDlg::OkPressed()
}
}
+ // Now do the import.
ScOrcusFilters* pOrcus = ScFormatFilter::Get().GetOrcusFilters();
if (!pOrcus)
return;
pOrcus->importXML(*mpDoc, maSrcPath, aParam);
+ // Don't forget to broadcast the change.
+ SfxObjectShell* pShell = mpDoc->GetDocumentShell();
+ pShell->Broadcast(SfxSimpleHint(FID_DATACHANGED));
+
+ // Repaint the grid to force repaint the cell values.
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ pViewShell->PaintGrid();
+
Close();
}
commit 1b02bcc2dc88c1fa4f6e7828dfca8afb0437bb64
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Fri Nov 9 23:04:29 2012 -0500
Remove debug statements.
Change-Id: I3e3d4863bef27e91b95f9e6cbe5c2daa81ece0b2
diff --git a/sc/source/filter/orcus/orcusfiltersimpl.cxx b/sc/source/filter/orcus/orcusfiltersimpl.cxx
index ba3701a..2584770 100644
--- a/sc/source/filter/orcus/orcusfiltersimpl.cxx
+++ b/sc/source/filter/orcus/orcusfiltersimpl.cxx
@@ -113,11 +113,8 @@ orcus::spreadsheet::iface::import_sheet* ScOrcusFactory::get_sheet(const char* s
OUString aTabName(sheet_name, sheet_name_length, RTL_TEXTENCODING_UTF8);
SCTAB nTab = -1;
if (!mrDoc.GetTable(aTabName, nTab))
- {
// Sheet by that name not found.
- fprintf(stdout, "ScOrcusFactory::get_sheet: no such sheet!!! (%s)\n", rtl::OUStringToOString(aTabName, RTL_TEXTENCODING_UTF8).getStr());
return NULL;
- }
// See if we already have an orcus sheet instance by that index.
boost::ptr_vector<ScOrcusSheet>::iterator it =
@@ -349,7 +346,6 @@ public:
InsertFieldPath(orcus::orcus_xml& rFilter) : mrFilter(rFilter) {}
void operator() (const OString& rPath)
{
- fprintf(stdout, "InsertFieldPath::(): field path = '%s'\n", rPath.getStr());
mrFilter.append_field_link(rPath.getStr());
}
};
diff --git a/sc/source/ui/xmlsource/xmlsourcedlg.cxx b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
index 62d2f40..5f3a6e1 100644
--- a/sc/source/ui/xmlsource/xmlsourcedlg.cxx
+++ b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
@@ -125,8 +125,6 @@ void ScXMLSourceDlg::SetReference(const ScRange& rRange, ScDocument* pDoc)
OUString aStr;
rRange.aStart.Format(aStr, SCA_ABS_3D, pDoc, pDoc->GetAddressConvention());
mpActiveEdit->SetRefString(aStr);
-
- fprintf(stdout, "ScXMLSourceDlg::SetReference: ref str = '%s'\n", rtl::OUStringToOString(aStr, RTL_TEXTENCODING_UTF8).getStr());
}
void ScXMLSourceDlg::Deactivate()
@@ -431,9 +429,8 @@ void getFieldLinks(ScOrcusImportXMLParam::RangeLink& rRangeLink, const SvTreeLis
{
const SvTreeListEntry& rChild = *it;
OUString aPath = getXPath(rTree, rChild);
-
const ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(rChild);
- fprintf(stdout, "getFieldLinks: path = '%s' leaf = %d\n", rtl::OUStringToOString(aPath, RTL_TEXTENCODING_UTF8).getStr(), pUserData->mbLeafNode);
+
if (pUserData && pUserData->mbLeafNode)
{
if (!aPath.isEmpty())
@@ -510,8 +507,6 @@ void ScXMLSourceDlg::RefEditModified()
ScAddress aLinkedPos;
sal_uInt16 nRes = aLinkedPos.Parse(aRefStr, mpDoc, mpDoc->GetAddressConvention());
bool bValid = (nRes & SCA_VALID) == SCA_VALID;
- fprintf(stdout, "ScXMLSourceDlg::RefEditModified: ref str = '%s' valid = %d\n",
- rtl::OUStringToOString(aRefStr, RTL_TEXTENCODING_UTF8).getStr(), bValid);
// TODO: For some unknown reason, setting the ref invalid will hide the text altogether.
// Find out how to make this work.
commit 8209cfe4d366a92c384f6ebd597e360ae7f7c626
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Fri Nov 9 22:10:54 2012 -0500
Register range links to orcus_xml too.
But range links fail to import. Looks like sheet names are corrupted.
I need to debug this...
Change-Id: If2aeb3b81db65749f05edfbdd2f3388be4f2539c
diff --git a/sc/inc/orcusxml.hxx b/sc/inc/orcusxml.hxx
index 1a0b192..c3a981d 100644
--- a/sc/inc/orcusxml.hxx
+++ b/sc/inc/orcusxml.hxx
@@ -31,7 +31,8 @@ struct ScOrcusXMLTreeParam
{
EntryType meType;
ScAddress maLinkedPos; /// linked cell position (invalid if unlinked)
- bool mbRangeParent;
+ bool mbRangeParent:1;
+ bool mbLeafNode:1; /// Leaf if it has no child elements. Child Attributes don't count.
SC_DLLPUBLIC EntryData(EntryType eType);
};
diff --git a/sc/source/core/tool/orcusxml.cxx b/sc/source/core/tool/orcusxml.cxx
index 5ad41de..3f3c93c 100644
--- a/sc/source/core/tool/orcusxml.cxx
+++ b/sc/source/core/tool/orcusxml.cxx
@@ -12,7 +12,7 @@
#include "svtools/treelistbox.hxx"
ScOrcusXMLTreeParam::EntryData::EntryData(EntryType eType) :
- meType(eType), maLinkedPos(ScAddress::INITIALIZE_INVALID), mbRangeParent(false) {}
+ meType(eType), maLinkedPos(ScAddress::INITIALIZE_INVALID), mbRangeParent(false), mbLeafNode(true) {}
ScOrcusXMLTreeParam::EntryData* ScOrcusXMLTreeParam::getUserData(SvTreeListEntry& rEntry)
{
diff --git a/sc/source/filter/orcus/orcusfiltersimpl.cxx b/sc/source/filter/orcus/orcusfiltersimpl.cxx
index 2ced6b5..ba3701a 100644
--- a/sc/source/filter/orcus/orcusfiltersimpl.cxx
+++ b/sc/source/filter/orcus/orcusfiltersimpl.cxx
@@ -113,8 +113,11 @@ orcus::spreadsheet::iface::import_sheet* ScOrcusFactory::get_sheet(const char* s
OUString aTabName(sheet_name, sheet_name_length, RTL_TEXTENCODING_UTF8);
SCTAB nTab = -1;
if (!mrDoc.GetTable(aTabName, nTab))
+ {
// Sheet by that name not found.
+ fprintf(stdout, "ScOrcusFactory::get_sheet: no such sheet!!! (%s)\n", rtl::OUStringToOString(aTabName, RTL_TEXTENCODING_UTF8).getStr());
return NULL;
+ }
// See if we already have an orcus sheet instance by that index.
boost::ptr_vector<ScOrcusSheet>::iterator it =
@@ -211,11 +214,12 @@ bool ScOrcusFiltersImpl::importCSV(ScDocument& rDoc, const OUString& rPath) cons
namespace {
-void setUserDataToEntry(
+ScOrcusXMLTreeParam::EntryData& setUserDataToEntry(
SvTreeListEntry& rEntry, ScOrcusXMLTreeParam::UserDataStoreType& rStore, ScOrcusXMLTreeParam::EntryType eType)
{
rStore.push_back(new ScOrcusXMLTreeParam::EntryData(eType));
rEntry.SetUserData(&rStore.back());
+ return rStore.back();
}
void populateTree(
@@ -229,7 +233,7 @@ void populateTree(
// Can this ever happen!?
return;
- setUserDataToEntry(
+ ScOrcusXMLTreeParam::EntryData& rEntryData = setUserDataToEntry(
*pEntry, rParam.maUserDataStore,
bRepeat ? ScOrcusXMLTreeParam::ElementRepeat : ScOrcusXMLTreeParam::ElementDefault);
@@ -266,6 +270,9 @@ void populateTree(
rWalker.get_children(aNames);
+ // Non-leaf if it has child elements, leaf otherwise.
+ rEntryData.mbLeafNode = aNames.empty();
+
// Insert child elements recursively.
for (it = aNames.begin(), itEnd = aNames.end(); it != itEnd; ++it)
{
@@ -333,6 +340,22 @@ bool ScOrcusFiltersImpl::loadXMLStructure(
return true;
}
+namespace {
+
+class InsertFieldPath : std::unary_function<OString, void>
+{
+ orcus::orcus_xml& mrFilter;
+public:
+ InsertFieldPath(orcus::orcus_xml& rFilter) : mrFilter(rFilter) {}
+ void operator() (const OString& rPath)
+ {
+ fprintf(stdout, "InsertFieldPath::(): field path = '%s'\n", rPath.getStr());
+ mrFilter.append_field_link(rPath.getStr());
+ }
+};
+
+}
+
bool ScOrcusFiltersImpl::importXML(
ScDocument& rDoc, const rtl::OUString& rPath, const ScOrcusImportXMLParam& rParam) const
{
@@ -344,18 +367,38 @@ bool ScOrcusFiltersImpl::importXML(
orcus::orcus_xml filter(&aFactory, NULL);
// Set cell links.
- ScOrcusImportXMLParam::CellLinksType::const_iterator it = rParam.maCellLinks.begin();
- ScOrcusImportXMLParam::CellLinksType::const_iterator itEnd = rParam.maCellLinks.end();
+ {
+ ScOrcusImportXMLParam::CellLinksType::const_iterator it = rParam.maCellLinks.begin();
+ ScOrcusImportXMLParam::CellLinksType::const_iterator itEnd = rParam.maCellLinks.end();
+ for (; it != itEnd; ++it)
+ {
+ const ScOrcusImportXMLParam::CellLink& rLink = *it;
+ OUString aTabName;
+ rDoc.GetName(rLink.maPos.Tab(), aTabName);
+ filter.set_cell_link(
+ rLink.maPath.getStr(),
+ rtl::OUStringToOString(aTabName, RTL_TEXTENCODING_UTF8).getStr(),
+ rLink.maPos.Row(), rLink.maPos.Col());
+ }
+ }
- for (; it != itEnd; ++it)
+ // Set range links.
{
- const ScOrcusImportXMLParam::CellLink& rLink = *it;
- OUString aTabName;
- rDoc.GetName(rLink.maPos.Tab(), aTabName);
- filter.set_cell_link(
- rLink.maPath.getStr(),
- rtl::OUStringToOString(aTabName, RTL_TEXTENCODING_UTF8).getStr(),
- rLink.maPos.Row(), rLink.maPos.Col());
+ ScOrcusImportXMLParam::RangeLinksType::const_iterator it = rParam.maRangeLinks.begin();
+ ScOrcusImportXMLParam::RangeLinksType::const_iterator itEnd = rParam.maRangeLinks.end();
+ for (; it != itEnd; ++it)
+ {
+ const ScOrcusImportXMLParam::RangeLink& rLink = *it;
+ OUString aTabName;
+ rDoc.GetName(rLink.maPos.Tab(), aTabName);
+ filter.start_range(
+ rtl::OUStringToOString(aTabName, RTL_TEXTENCODING_UTF8).getStr(),
+ rLink.maPos.Row(), rLink.maPos.Col());
+
+ std::for_each(rLink.maFieldPaths.begin(), rLink.maFieldPaths.end(), InsertFieldPath(filter));
+
+ filter.commit_range();
+ }
}
filter.read_file(path);
diff --git a/sc/source/ui/xmlsource/xmlsourcedlg.cxx b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
index 7821b9b..62d2f40 100644
--- a/sc/source/ui/xmlsource/xmlsourcedlg.cxx
+++ b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
@@ -414,26 +414,79 @@ bool ScXMLSourceDlg::IsChildrenDirty(SvTreeListEntry* pEntry) const
return false;
}
+namespace {
+
+/**
+ * Pick only the leaf elements.
+ */
+void getFieldLinks(ScOrcusImportXMLParam::RangeLink& rRangeLink, const SvTreeListBox& rTree, const SvTreeListEntry& rEntry)
+{
+ const SvTreeListEntries& rChildren = rEntry.GetChildEntries();
+ if (rChildren.empty())
+ // No more children. We're done.
+ return;
+
+ SvTreeListEntries::const_iterator it = rChildren.begin(), itEnd = rChildren.end();
+ for (; it != itEnd; ++it)
+ {
+ const SvTreeListEntry& rChild = *it;
+ OUString aPath = getXPath(rTree, rChild);
+
+ const ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(rChild);
+ fprintf(stdout, "getFieldLinks: path = '%s' leaf = %d\n", rtl::OUStringToOString(aPath, RTL_TEXTENCODING_UTF8).getStr(), pUserData->mbLeafNode);
+ if (pUserData && pUserData->mbLeafNode)
+ {
+ if (!aPath.isEmpty())
+ // XPath should never be empty anyway, but it won't hurt to check...
+ rRangeLink.maFieldPaths.push_back(rtl::OUStringToOString(aPath, RTL_TEXTENCODING_UTF8));
+ }
+
+ // Walk recursively.
+ getFieldLinks(rRangeLink, rTree, rChild);
+ }
+}
+
+}
+
void ScXMLSourceDlg::OkPressed()
{
// Begin import.
ScOrcusImportXMLParam aParam;
- std::set<const SvTreeListEntry*>::const_iterator it = maCellLinks.begin(), itEnd = maCellLinks.end();
- for (; it != itEnd; ++it)
+ // Convert single cell links.
{
- const SvTreeListEntry& rEntry = **it;
- OUString aPath = getXPath(maLbTree, rEntry);
- const ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(rEntry);
- ScAddress aPos = pUserData->maLinkedPos;
-
- aParam.maCellLinks.push_back(
- ScOrcusImportXMLParam::CellLink(
- aPos, rtl::OUStringToOString(aPath, RTL_TEXTENCODING_UTF8)));
+ std::set<const SvTreeListEntry*>::const_iterator it = maCellLinks.begin(), itEnd = maCellLinks.end();
+ for (; it != itEnd; ++it)
+ {
+ const SvTreeListEntry& rEntry = **it;
+ OUString aPath = getXPath(maLbTree, rEntry);
+ const ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(rEntry);
+
+ aParam.maCellLinks.push_back(
+ ScOrcusImportXMLParam::CellLink(
+ pUserData->maLinkedPos, rtl::OUStringToOString(aPath, RTL_TEXTENCODING_UTF8)));
+ }
}
- // TODO: Process range links.
+ // Convert range links. For now, an element with range link takes all its
+ // child elements as its fields.
+ {
+ std::set<const SvTreeListEntry*>::const_iterator it = maRangeLinks.begin(), itEnd = maRangeLinks.end();
+ for (; it != itEnd; ++it)
+ {
+ const SvTreeListEntry& rEntry = **it;
+ const ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(rEntry);
+
+ ScOrcusImportXMLParam::RangeLink aRangeLink;
+ aRangeLink.maPos = pUserData->maLinkedPos;
+
+ // Go through all its child elements.
+ getFieldLinks(aRangeLink, maLbTree, rEntry);
+
+ aParam.maRangeLinks.push_back(aRangeLink);
+ }
+ }
ScOrcusFilters* pOrcus = ScFormatFilter::Get().GetOrcusFilters();
if (!pOrcus)
commit 0ad6039682461f8275948988facb6dfc159acbca
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Fri Nov 9 17:25:02 2012 -0500
Implement the required get_sheet() interface method.
Now we can import single-linked elements.
Change-Id: I0e2f2fd618bf6dadfcc18e8b96e235e3c08f443b
diff --git a/sc/source/filter/orcus/orcusfiltersimpl.cxx b/sc/source/filter/orcus/orcusfiltersimpl.cxx
index 9b2244b..2ced6b5 100644
--- a/sc/source/filter/orcus/orcusfiltersimpl.cxx
+++ b/sc/source/filter/orcus/orcusfiltersimpl.cxx
@@ -66,6 +66,7 @@ class ScOrcusSheet : public orcus::spreadsheet::iface::import_sheet
public:
ScOrcusSheet(ScDocument& rDoc, SCTAB nTab);
+ // Orcus import interface
virtual void set_auto(row_t row, col_t col, const char* p, size_t n);
virtual void set_format(row_t row, col_t col, size_t xf_index);
virtual void set_formula(row_t row, col_t col, formula_grammar_t grammar, const char* p, size_t n);
@@ -79,6 +80,8 @@ public:
virtual void set_shared_formula(row_t row, col_t col, size_t sindex);
virtual void set_string(row_t row, col_t col, size_t sindex);
virtual void set_value(row_t row, col_t col, double value);
+
+ SCTAB getIndex() const { return mnTab; }
};
ScOrcusFactory::ScOrcusFactory(ScDocument& rDoc) : mrDoc(rDoc) {}
@@ -94,10 +97,36 @@ orcus::spreadsheet::iface::import_sheet* ScOrcusFactory::append_sheet(const char
return &maSheets.back();
}
-orcus::spreadsheet::iface::import_sheet* ScOrcusFactory::get_sheet(const char* /*sheet_name*/, size_t /*sheet_name_length*/)
+class FindSheetByIndex : std::unary_function<ScOrcusSheet, bool>
{
- // TODO: Implement this.
- return NULL;
+ SCTAB mnTab;
+public:
+ FindSheetByIndex(SCTAB nTab) : mnTab(nTab) {}
+ bool operator() (const ScOrcusSheet& rSheet) const
+ {
+ return rSheet.getIndex() == mnTab;
+ }
+};
+
+orcus::spreadsheet::iface::import_sheet* ScOrcusFactory::get_sheet(const char* sheet_name, size_t sheet_name_length)
+{
+ OUString aTabName(sheet_name, sheet_name_length, RTL_TEXTENCODING_UTF8);
+ SCTAB nTab = -1;
+ if (!mrDoc.GetTable(aTabName, nTab))
+ // Sheet by that name not found.
+ return NULL;
+
+ // See if we already have an orcus sheet instance by that index.
+ boost::ptr_vector<ScOrcusSheet>::iterator it =
+ std::find_if(maSheets.begin(), maSheets.end(), FindSheetByIndex(nTab));
+
+ if (it != maSheets.end())
+ // We already have one. Return it.
+ return &(*it);
+
+ // Create a new orcus sheet instance for this.
+ maSheets.push_back(new ScOrcusSheet(mrDoc, nTab));
+ return &maSheets.back();
}
orcus::spreadsheet::iface::import_shared_strings* ScOrcusFactory::get_shared_strings()
commit 6deed4a1cb101ecf48ce1ded5a881a7704fb6cab
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Fri Nov 9 17:05:49 2012 -0500
Set all single cell links to orcus_xml, and start reading the file.
Alas, data won't get imported because I haven't implemented get_sheet()
interface method.
Change-Id: Id53b2c68b2fdf4c03fa6d6de25dd7762a51bd610
diff --git a/sc/inc/orcusxml.hxx b/sc/inc/orcusxml.hxx
index 2baac69..1a0b192 100644
--- a/sc/inc/orcusxml.hxx
+++ b/sc/inc/orcusxml.hxx
@@ -57,19 +57,22 @@ struct ScOrcusImportXMLParam
struct CellLink
{
ScAddress maPos;
- rtl::OUString maPath;
+ rtl::OString maPath;
- CellLink(const ScAddress& rPos, const rtl::OUString& rPath);
+ CellLink(const ScAddress& rPos, const rtl::OString& rPath);
};
struct RangeLink
{
ScAddress maPos;
- std::vector<rtl::OUString> maFieldPaths;
+ std::vector<rtl::OString> maFieldPaths;
};
- std::vector<CellLink> maCellLinks;
- std::vector<RangeLink> maRangeLinks;
+ typedef std::vector<CellLink> CellLinksType;
+ typedef std::vector<RangeLink> RangeLinksType;
+
+ CellLinksType maCellLinks;
+ RangeLinksType maRangeLinks;
};
#endif
diff --git a/sc/source/core/tool/orcusxml.cxx b/sc/source/core/tool/orcusxml.cxx
index fb74fec..5ad41de 100644
--- a/sc/source/core/tool/orcusxml.cxx
+++ b/sc/source/core/tool/orcusxml.cxx
@@ -24,7 +24,7 @@ const ScOrcusXMLTreeParam::EntryData* ScOrcusXMLTreeParam::getUserData(const SvT
return static_cast<const ScOrcusXMLTreeParam::EntryData*>(rEntry.GetUserData());
}
-ScOrcusImportXMLParam::CellLink::CellLink(const ScAddress& rPos, const OUString& rPath) :
+ScOrcusImportXMLParam::CellLink::CellLink(const ScAddress& rPos, const OString& rPath) :
maPos(rPos), maPath(rPath) {}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/orcus/orcusfiltersimpl.cxx b/sc/source/filter/orcus/orcusfiltersimpl.cxx
index e7a2ef9..9b2244b 100644
--- a/sc/source/filter/orcus/orcusfiltersimpl.cxx
+++ b/sc/source/filter/orcus/orcusfiltersimpl.cxx
@@ -20,6 +20,7 @@
#include <orcus/orcus_csv.hpp>
#include <orcus/xml_structure_tree.hpp>
#include <orcus/xml_namespace.hpp>
+#include <orcus/orcus_xml.hpp>
#include <orcus/global.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
@@ -36,6 +37,12 @@ using orcus::spreadsheet::formula_grammar_t;
namespace {
+OString toSystemPath(const OUString& rPath)
+{
+ INetURLObject aURL(rPath);
+ return rtl::OUStringToOString(aURL.getFSysPath(SYSTEM_PATH), RTL_TEXTENCODING_UTF8);
+}
+
class ScOrcusSheet;
class ScOrcusFactory : public orcus::spreadsheet::iface::import_factory
@@ -156,8 +163,7 @@ void ScOrcusSheet::set_value(row_t /*row*/, col_t /*col*/, double /*value*/)
bool ScOrcusFiltersImpl::importCSV(ScDocument& rDoc, const OUString& rPath) const
{
ScOrcusFactory aFactory(rDoc);
- INetURLObject aURL(rPath);
- OString aSysPath = rtl::OUStringToOString(aURL.getFSysPath(SYSTEM_PATH), RTL_TEXTENCODING_UTF8);
+ OString aSysPath = toSystemPath(rPath);
const char* path = aSysPath.getStr();
try
@@ -262,8 +268,7 @@ bool ScOrcusFiltersImpl::loadXMLStructure(
{
rParam.maUserDataStore.clear();
- INetURLObject aURL(rPath);
- OString aSysPath = rtl::OUStringToOString(aURL.getFSysPath(SYSTEM_PATH), RTL_TEXTENCODING_UTF8);
+ OString aSysPath = toSystemPath(rPath);
const char* path = aSysPath.getStr();
// TODO: Use our own stream loading call instead of one from orcus.
@@ -302,6 +307,34 @@ bool ScOrcusFiltersImpl::loadXMLStructure(
bool ScOrcusFiltersImpl::importXML(
ScDocument& rDoc, const rtl::OUString& rPath, const ScOrcusImportXMLParam& rParam) const
{
+ ScOrcusFactory aFactory(rDoc);
+ OString aSysPath = toSystemPath(rPath);
+ const char* path = aSysPath.getStr();
+ try
+ {
+ orcus::orcus_xml filter(&aFactory, NULL);
+
+ // Set cell links.
+ ScOrcusImportXMLParam::CellLinksType::const_iterator it = rParam.maCellLinks.begin();
+ ScOrcusImportXMLParam::CellLinksType::const_iterator itEnd = rParam.maCellLinks.end();
+
+ for (; it != itEnd; ++it)
+ {
+ const ScOrcusImportXMLParam::CellLink& rLink = *it;
+ OUString aTabName;
+ rDoc.GetName(rLink.maPos.Tab(), aTabName);
+ filter.set_cell_link(
+ rLink.maPath.getStr(),
+ rtl::OUStringToOString(aTabName, RTL_TEXTENCODING_UTF8).getStr(),
+ rLink.maPos.Row(), rLink.maPos.Col());
+ }
+
+ filter.read_file(path);
+ }
+ catch (const std::exception&)
+ {
+ return false;
+ }
return true;
}
diff --git a/sc/source/ui/xmlsource/xmlsourcedlg.cxx b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
index c490d2e..7821b9b 100644
--- a/sc/source/ui/xmlsource/xmlsourcedlg.cxx
+++ b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
@@ -428,10 +428,9 @@ void ScXMLSourceDlg::OkPressed()
const ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(rEntry);
ScAddress aPos = pUserData->maLinkedPos;
- fprintf(stdout, "ScXMLSourceDlg::OkPressed: linked to (col=%d,row=%d) path = '%s'\n",
- aPos.Col(), aPos.Row(), rtl::OUStringToOString(aPath, RTL_TEXTENCODING_UTF8).getStr());
-
- aParam.maCellLinks.push_back(ScOrcusImportXMLParam::CellLink(aPos, aPath));
+ aParam.maCellLinks.push_back(
+ ScOrcusImportXMLParam::CellLink(
+ aPos, rtl::OUStringToOString(aPath, RTL_TEXTENCODING_UTF8)));
}
// TODO: Process range links.
commit 8ce4daeb543c5f3fc1f79765168a5d32d13a3fd0
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Fri Nov 9 16:46:22 2012 -0500
Not a good idea to close the dialog first then start the import.
Because that leads to a crash.
Change-Id: I7ca7d94e1164a44bbef9e9b41e3f8c5bcf113c22
diff --git a/sc/source/ui/xmlsource/xmlsourcedlg.cxx b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
index 6260589..c490d2e 100644
--- a/sc/source/ui/xmlsource/xmlsourcedlg.cxx
+++ b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
@@ -436,13 +436,13 @@ void ScXMLSourceDlg::OkPressed()
// TODO: Process range links.
- Close();
-
ScOrcusFilters* pOrcus = ScFormatFilter::Get().GetOrcusFilters();
if (!pOrcus)
return;
pOrcus->importXML(*mpDoc, maSrcPath, aParam);
+
+ Close();
}
void ScXMLSourceDlg::CancelPressed()
commit 53570054efeb550d1145becf539ef863c0b3371d
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Fri Nov 9 15:21:36 2012 -0500
Press 'Import' in the dialog to start importing XML.
For now, the dialog only calls importXML() when the Import button
is pressed, and the importXML() function still does nothing.
Change-Id: I3427d343f88ba2a9b076ffc0ee4bcc44055d7717
diff --git a/sc/inc/orcusfilters.hxx b/sc/inc/orcusfilters.hxx
index 019441c..1b94f67 100644
--- a/sc/inc/orcusfilters.hxx
+++ b/sc/inc/orcusfilters.hxx
@@ -16,6 +16,7 @@ class ScDocument;
class SvTreeListBox;
class Image;
struct ScOrcusXMLTreeParam;
+struct ScOrcusImportXMLParam;
/**
* Collection of orcus filter wrappers.
@@ -29,6 +30,9 @@ public:
virtual bool loadXMLStructure(
const rtl::OUString& rPath, SvTreeListBox& rTreeCtrl, ScOrcusXMLTreeParam& rParam) const = 0;
+
+ virtual bool importXML(
+ ScDocument& rDoc, const rtl::OUString& rPath, const ScOrcusImportXMLParam& rParam) const = 0;
};
#endif
diff --git a/sc/inc/orcusxml.hxx b/sc/inc/orcusxml.hxx
index a133b78..2baac69 100644
--- a/sc/inc/orcusxml.hxx
+++ b/sc/inc/orcusxml.hxx
@@ -14,6 +14,7 @@
#include "address.hxx"
#include "vcl/image.hxx"
+#include <vector>
#include <boost/ptr_container/ptr_vector.hpp>
class SvTreeListEntry;
@@ -48,6 +49,27 @@ struct ScOrcusXMLTreeParam
UserDataStoreType maUserDataStore;
static SC_DLLPUBLIC EntryData* getUserData(SvTreeListEntry& rEntry);
+ static SC_DLLPUBLIC const EntryData* getUserData(const SvTreeListEntry& rEntry);
+};
+
+struct ScOrcusImportXMLParam
+{
+ struct CellLink
+ {
+ ScAddress maPos;
+ rtl::OUString maPath;
+
+ CellLink(const ScAddress& rPos, const rtl::OUString& rPath);
+ };
+
+ struct RangeLink
+ {
+ ScAddress maPos;
+ std::vector<rtl::OUString> maFieldPaths;
+ };
+
+ std::vector<CellLink> maCellLinks;
+ std::vector<RangeLink> maRangeLinks;
};
#endif
diff --git a/sc/source/core/tool/orcusxml.cxx b/sc/source/core/tool/orcusxml.cxx
index 8d5d91b..fb74fec 100644
--- a/sc/source/core/tool/orcusxml.cxx
+++ b/sc/source/core/tool/orcusxml.cxx
@@ -19,4 +19,12 @@ ScOrcusXMLTreeParam::EntryData* ScOrcusXMLTreeParam::getUserData(SvTreeListEntry
return static_cast<ScOrcusXMLTreeParam::EntryData*>(rEntry.GetUserData());
}
+const ScOrcusXMLTreeParam::EntryData* ScOrcusXMLTreeParam::getUserData(const SvTreeListEntry& rEntry)
+{
+ return static_cast<const ScOrcusXMLTreeParam::EntryData*>(rEntry.GetUserData());
+}
+
+ScOrcusImportXMLParam::CellLink::CellLink(const ScAddress& rPos, const OUString& rPath) :
+ maPos(rPos), maPath(rPath) {}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/inc/orcusfiltersimpl.hxx b/sc/source/filter/inc/orcusfiltersimpl.hxx
index 956e940..f2d2703 100644
--- a/sc/source/filter/inc/orcusfiltersimpl.hxx
+++ b/sc/source/filter/inc/orcusfiltersimpl.hxx
@@ -19,6 +19,9 @@ public:
virtual bool loadXMLStructure(
const rtl::OUString& rPath, SvTreeListBox& rTreeCtrl, ScOrcusXMLTreeParam& rParam) const;
+
+ virtual bool importXML(
+ ScDocument& rDoc, const rtl::OUString& rPath, const ScOrcusImportXMLParam& rParam) const;
};
#endif
diff --git a/sc/source/filter/orcus/orcusfiltersimpl.cxx b/sc/source/filter/orcus/orcusfiltersimpl.cxx
index 0549156..e7a2ef9 100644
--- a/sc/source/filter/orcus/orcusfiltersimpl.cxx
+++ b/sc/source/filter/orcus/orcusfiltersimpl.cxx
@@ -299,4 +299,10 @@ bool ScOrcusFiltersImpl::loadXMLStructure(
return true;
}
+bool ScOrcusFiltersImpl::importXML(
+ ScDocument& rDoc, const rtl::OUString& rPath, const ScOrcusImportXMLParam& rParam) const
+{
+ return true;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/xmlsourcedlg.hxx b/sc/source/ui/inc/xmlsourcedlg.hxx
index 058058a..e16b52a 100644
--- a/sc/source/ui/inc/xmlsourcedlg.hxx
+++ b/sc/source/ui/inc/xmlsourcedlg.hxx
@@ -18,6 +18,7 @@
#include "anyrefdg.hxx"
#include "orcusxml.hxx"
+#include <set>
#include <boost/scoped_ptr.hpp>
class ScDocument;
@@ -51,6 +52,8 @@ class ScXMLSourceDlg : public ScAnyRefDlg
rtl::OUString maSrcPath;
ScOrcusXMLTreeParam maXMLParam;
+ std::set<const SvTreeListEntry*> maCellLinks;
+ std::set<const SvTreeListEntry*> maRangeLinks;
ScDocument* mpDoc;
@@ -94,11 +97,13 @@ private:
void OkPressed();
void CancelPressed();
+ void RefEditModified();
DECL_LINK(GetFocusHdl, Control*);
DECL_LINK(LoseFocusHdl, Control*);
DECL_LINK(BtnPressedHdl, Button*);
DECL_LINK(TreeItemSelectHdl, void*);
+ DECL_LINK(RefModifiedHdl, void*);
};
#endif
diff --git a/sc/source/ui/src/xmlsourcedlg.src b/sc/source/ui/src/xmlsourcedlg.src
index 99d6f56..d90b498 100644
--- a/sc/source/ui/src/xmlsourcedlg.src
+++ b/sc/source/ui/src/xmlsourcedlg.src
@@ -76,7 +76,7 @@ ModelessDialog RID_SCDLG_XML_SOURCE
{
Pos = MAP_APPFONT ( 216 , 66 ) ;
Size = MAP_APPFONT ( 13 , 15 ) ;
- TabStop = FALSE ;
+ TabStop = TRUE ;
QuickHelpText [ en-US ] = "Shrink" ;
};
@@ -106,6 +106,7 @@ ModelessDialog RID_SCDLG_XML_SOURCE
OKButton BTN_OK
{
+ Text [ en-US ] = "~Import" ;
Pos = MAP_APPFONT ( 139 , 181 ) ;
Size = MAP_APPFONT ( 50 , 14 ) ;
};
diff --git a/sc/source/ui/xmlsource/xmlsourcedlg.cxx b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
index 2fd452d..6260589 100644
--- a/sc/source/ui/xmlsource/xmlsourcedlg.cxx
+++ b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
@@ -18,6 +18,7 @@
#include "unotools/pathoptions.hxx"
#include "tools/urlobj.hxx"
+#include "svtools/svlbitm.hxx"
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
@@ -25,6 +26,35 @@
using namespace com::sun::star;
+namespace {
+
+bool isAttribute(const SvTreeListEntry& rEntry)
+{
+ const ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(rEntry);
+ if (!pUserData)
+ return false;
+
+ return pUserData->meType == ScOrcusXMLTreeParam::Attribute;
+}
+
+OUString getXPath(const SvTreeListBox& rTree, const SvTreeListEntry& rEntry)
+{
+ OUStringBuffer aBuf;
+ for (SvTreeListEntry* p = const_cast<SvTreeListEntry*>(&rEntry); p; p = rTree.GetParent(p))
+ {
+ const SvLBoxItem* pItem = p->GetFirstItem(SV_ITEM_ID_LBOXSTRING);
+ if (!pItem)
+ continue;
+
+ const SvLBoxString* pStr = static_cast<const SvLBoxString*>(pItem);
+ aBuf.insert(0, pStr->GetText());
+ aBuf.insert(0, isAttribute(*p) ? '@' : '/');
+ }
+
+ return aBuf.makeStringAndClear();
+}
+
+}
ScXMLSourceTree::ScXMLSourceTree(Window* pParent, const ResId& rResId) :
SvTreeListBox(pParent, rResId) {}
@@ -69,6 +99,9 @@ ScXMLSourceDlg::ScXMLSourceDlg(
aLink = LINK(this, ScXMLSourceDlg, TreeItemSelectHdl);
maLbTree.SetSelectHdl(aLink);
+ aLink = LINK(this, ScXMLSourceDlg, RefModifiedHdl);
+ maRefEdit.SetModifyHdl(aLink);
+
SetNonLinkable();
}
@@ -93,17 +126,7 @@ void ScXMLSourceDlg::SetReference(const ScRange& rRange, ScDocument* pDoc)
rRange.aStart.Format(aStr, SCA_ABS_3D, pDoc, pDoc->GetAddressConvention());
mpActiveEdit->SetRefString(aStr);
- // Set this address to currently selected tree item.
- SvTreeListEntry* pEntry = maLbTree.GetCurEntry();
- if (!pEntry)
- return;
-
- ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(*pEntry);
- if (!pUserData)
- return;
-
- pUserData->maLinkedPos = rRange.aStart;
- pUserData->mbRangeParent = pUserData->meType == ScOrcusXMLTreeParam::ElementRepeat;
+ fprintf(stdout, "ScXMLSourceDlg::SetReference: ref str = '%s'\n", rtl::OUStringToOString(aStr, RTL_TEXTENCODING_UTF8).getStr());
}
void ScXMLSourceDlg::Deactivate()
@@ -312,7 +335,7 @@ void ScXMLSourceDlg::AttributeSelected(SvTreeListEntry& rEntry)
return;
}
- if (IsParentDirty(pParent))
+ if (IsParentDirty(&rEntry))
{
SetNonLinkable();
return;
@@ -393,8 +416,33 @@ bool ScXMLSourceDlg::IsChildrenDirty(SvTreeListEntry* pEntry) const
void ScXMLSourceDlg::OkPressed()
{
- // Store the xml link data to document.
+ // Begin import.
+
+ ScOrcusImportXMLParam aParam;
+
+ std::set<const SvTreeListEntry*>::const_iterator it = maCellLinks.begin(), itEnd = maCellLinks.end();
+ for (; it != itEnd; ++it)
+ {
+ const SvTreeListEntry& rEntry = **it;
+ OUString aPath = getXPath(maLbTree, rEntry);
+ const ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(rEntry);
+ ScAddress aPos = pUserData->maLinkedPos;
+
+ fprintf(stdout, "ScXMLSourceDlg::OkPressed: linked to (col=%d,row=%d) path = '%s'\n",
+ aPos.Col(), aPos.Row(), rtl::OUStringToOString(aPath, RTL_TEXTENCODING_UTF8).getStr());
+
+ aParam.maCellLinks.push_back(ScOrcusImportXMLParam::CellLink(aPos, aPath));
+ }
+
+ // TODO: Process range links.
+
Close();
+
+ ScOrcusFilters* pOrcus = ScFormatFilter::Get().GetOrcusFilters();
+ if (!pOrcus)
+ return;
+
+ pOrcus->importXML(*mpDoc, maSrcPath, aParam);
}
void ScXMLSourceDlg::CancelPressed()
@@ -402,6 +450,55 @@ void ScXMLSourceDlg::CancelPressed()
Close();
}
+void ScXMLSourceDlg::RefEditModified()
+{
+ OUString aRefStr = maRefEdit.GetText();
+
+ // Check if the address is valid.
+ ScAddress aLinkedPos;
+ sal_uInt16 nRes = aLinkedPos.Parse(aRefStr, mpDoc, mpDoc->GetAddressConvention());
+ bool bValid = (nRes & SCA_VALID) == SCA_VALID;
+ fprintf(stdout, "ScXMLSourceDlg::RefEditModified: ref str = '%s' valid = %d\n",
+ rtl::OUStringToOString(aRefStr, RTL_TEXTENCODING_UTF8).getStr(), bValid);
+
+ // TODO: For some unknown reason, setting the ref invalid will hide the text altogether.
+ // Find out how to make this work.
+// maRefEdit.SetRefValid(bValid);
+
+ if (!bValid)
+ aLinkedPos.SetInvalid();
+
+ // Set this address to currently selected tree item.
+ SvTreeListEntry* pEntry = maLbTree.GetCurEntry();
+ if (!pEntry)
+ // This should never happen.
+ return;
+
+ ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(*pEntry);
+ if (!pUserData)
+ // This should never happen either.
+ return;
+
+ bool bRepeatElem = pUserData->meType == ScOrcusXMLTreeParam::ElementRepeat;
+ pUserData->maLinkedPos = aLinkedPos;
+ pUserData->mbRangeParent = aLinkedPos.IsValid() && bRepeatElem;
+
+ if (bRepeatElem)
+ {
+ if (bValid)
+ maRangeLinks.insert(pEntry);
+ else
+ maRangeLinks.erase(pEntry);
+ }
+ else
+ {
+ if (bValid)
+ maCellLinks.insert(pEntry);
+ else
+ maCellLinks.erase(pEntry);
+ }
+}
+
IMPL_LINK(ScXMLSourceDlg, GetFocusHdl, Control*, pCtrl)
{
HandleGetFocus(pCtrl);
@@ -431,4 +528,10 @@ IMPL_LINK_NOARG(ScXMLSourceDlg, TreeItemSelectHdl)
return 0;
}
+IMPL_LINK_NOARG(ScXMLSourceDlg, RefModifiedHdl)
+{
+ RefEditModified();
+ return 0;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 8060a1778c58cbddfaf62cc1c7d07b8bd69184f0
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Wed Nov 7 22:27:35 2012 -0500
Handler methods for OK and Cancel.
Change-Id: I8637543dc10ade3e75205031581eeaadd1b7ca4d
diff --git a/sc/source/ui/inc/xmlsourcedlg.hxx b/sc/source/ui/inc/xmlsourcedlg.hxx
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list