diff options
author | László Németh <nemeth@numbertext.org> | 2019-02-07 19:44:11 +0100 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2019-02-07 21:03:40 +0100 |
commit | 70ab6ff7c22ce850c9041bfeeeaba7038011a0a7 (patch) | |
tree | 3358f174af587f1260b39007b5947cdfc3c427df /sc/source | |
parent | 66850d9efb00407b7930500d0ebc6febdb03fa8c (diff) |
tdf#122594 OLE import in DOCX: show selected sheet
of an embedded XLSX OLE object, instead of showing
always the first sheet.
Change-Id: I583a17dc8a3cd06ee15fbbb950328f0b9b164a63
Reviewed-on: https://gerrit.libreoffice.org/67516
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/filter/oox/workbookhelper.cxx | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/sc/source/filter/oox/workbookhelper.cxx b/sc/source/filter/oox/workbookhelper.cxx index 87b5fe016e39..5aa60f2f932e 100644 --- a/sc/source/filter/oox/workbookhelper.cxx +++ b/sc/source/filter/oox/workbookhelper.cxx @@ -20,6 +20,7 @@ #include <workbookhelper.hxx> #include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/container/XIndexContainer.hpp> #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> #include <com/sun/star/sheet/XDatabaseRanges.hpp> @@ -29,6 +30,7 @@ #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> #include <com/sun/star/document/XDocumentProperties.hpp> #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> +#include <com/sun/star/document/XViewDataSupplier.hpp> #include <osl/thread.h> #include <oox/helper/progressbar.hxx> #include <oox/helper/propertyset.hxx> @@ -71,6 +73,7 @@ #include <editutil.hxx> #include <editeng/editstat.hxx> #include <unotools/charclass.hxx> +#include <ViewSettingsSequenceDefines.hxx> #include <memory> @@ -84,6 +87,7 @@ using namespace ::com::sun::star::sheet; using namespace ::com::sun::star::style; using namespace ::com::sun::star::table; using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; using ::oox::core::FilterBase; using ::oox::core::FragmentHandler; @@ -715,6 +719,38 @@ void WorkbookHelper::finalizeWorkbookImport() aCalcConfig.meStringRefAddressSyntax = formula::FormulaGrammar::CONV_A1_XL_A1; getScDocument().SetCalcConfig(aCalcConfig); } + + // set selected sheet + Reference<XViewDataSupplier> xViewDataSupplier(getDocument(), UNO_QUERY); + if (xViewDataSupplier.is()) + { + Reference<XIndexAccess> xIndexAccess(xViewDataSupplier->getViewData()); + if (xIndexAccess.is() && xIndexAccess->getCount() > 0) + { + Sequence< PropertyValue > aSeq; + if (xIndexAccess->getByIndex(0) >>= aSeq) + { + sal_Int32 nCount (aSeq.getLength()); + for (sal_Int32 i = 0; i < nCount; ++i) + { + OUString sName(aSeq[i].Name); + if (sName == SC_ACTIVETABLE) + { + OUString sTabName; + if(aSeq[i].Value >>= sTabName) + { + SCTAB nTab(0); + if (getScDocument().GetTable(sTabName, nTab)) + { + getScDocument().SetVisibleTab(nTab); + i = nCount; + } + } + } + } + } + } + } } // document model ------------------------------------------------------------- |