sc/source/filter/excel/xestream.cxx |   11 +++++++++++
 1 file changed, 11 insertions(+)

New commits:
commit 95cb9a01bfacf7d9f03194b0710ca3c249bb62fb
Author:     Paris Oplopoios <paris.oplopo...@collabora.com>
AuthorDate: Wed Nov 9 13:43:46 2022 +0200
Commit:     Jan Holesovsky <ke...@collabora.com>
CommitDate: Wed Nov 9 16:01:13 2022 +0100

    Get ScViewData through the current doc shell in headless mode
    
    When using --convert-to, ScDocShell::GetViewData() would return nullptr
    so we now get the ScViewData through an alternative route.
    
    Change-Id: Ie71a4a1077b3c63c0aadd394fc0d966e679e8803
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142480
    Tested-by: Jenkins
    Reviewed-by: Jan Holesovsky <ke...@collabora.com>

diff --git a/sc/source/filter/excel/xestream.cxx 
b/sc/source/filter/excel/xestream.cxx
index 0ee697dfeba8..33e6fa2a8838 100644
--- a/sc/source/filter/excel/xestream.cxx
+++ b/sc/source/filter/excel/xestream.cxx
@@ -56,6 +56,7 @@
 #include <sfx2/app.hxx>
 
 #include <docsh.hxx>
+#include <tabvwsh.hxx>
 #include <viewdata.hxx>
 #include <excdoc.hxx>
 
@@ -1050,6 +1051,16 @@ bool XclExpXmlStream::exportDocument()
     // Get the viewsettings before processing
     if( ScDocShell::GetViewData() )
         ScDocShell::GetViewData()->WriteExtOptions( mpRoot->GetExtDocOptions() 
);
+    else
+    {
+        // Try to get ScViewData through the current ScDocShell
+        ScTabViewShell* pTabViewShell = pShell->GetBestViewShell( false );
+        if ( pTabViewShell )
+        {
+            ScViewData* pViewData = &pTabViewShell->GetViewData();
+            pViewData->WriteExtOptions( mpRoot->GetExtDocOptions() );
+        }
+    }
 
     OUString const workbook = "xl/workbook.xml";
     const char* pWorkbookContentType = nullptr;

Reply via email to