libreofficekit/source/gtk/lokdocview.cxx |    8 +++++++-
 sc/qa/unit/helper/qahelper.cxx           |    1 -
 sc/qa/unit/ucalc.cxx                     |    1 -
 sc/qa/unit/ucalc_copypaste.cxx           |    2 --
 sc/qa/unit/ucalc_formula.cxx             |    3 ---
 sc/qa/unit/ucalc_sharedformula.cxx       |    1 -
 sc/source/ui/docshell/docsh.cxx          |   29 ++++++++++-------------------
 sc/source/ui/docshell/docsh2.cxx         |   23 ++++++++++-------------
 sc/source/ui/inc/docsh.hxx               |    3 ---
 9 files changed, 27 insertions(+), 44 deletions(-)

New commits:
commit f947788617e06ac175a5cccb20a6bd0d0a7a88ed
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Fri Oct 21 10:15:13 2022 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Fri Oct 21 12:17:35 2022 +0200

    sc: remove SetIsInUcalc.
    
    it seems it's no longer needed
    
    Change-Id: I346a12a150659ddde218a895d140c9087989d516
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141613
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx
index e377ef7630c4..40cc56859c4f 100644
--- a/sc/qa/unit/helper/qahelper.cxx
+++ b/sc/qa/unit/helper/qahelper.cxx
@@ -938,7 +938,6 @@ void ScSimpleBootstrapFixture::setUp()
     m_xDocShell
         = new ScDocShell(SfxModelFlags::EMBEDDED_OBJECT | 
SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS
                          | SfxModelFlags::DISABLE_DOCUMENT_RECOVERY);
-    m_xDocShell->SetIsInUcalc();
     m_xDocShell->DoInitUnitTest();
 
     m_pDoc = &m_xDocShell->GetDocument();
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 325b3ffbeca3..12a70a1db4dd 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -331,7 +331,6 @@ void Test::getNewDocShell( ScDocShellRef& rDocShellRef )
         SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS |
         SfxModelFlags::DISABLE_DOCUMENT_RECOVERY);
 
-    rDocShellRef->SetIsInUcalc();
     rDocShellRef->DoInitUnitTest();
 }
 
diff --git a/sc/qa/unit/ucalc_copypaste.cxx b/sc/qa/unit/ucalc_copypaste.cxx
index 497a309461ab..ab3572ce05f5 100644
--- a/sc/qa/unit/ucalc_copypaste.cxx
+++ b/sc/qa/unit/ucalc_copypaste.cxx
@@ -10131,7 +10131,6 @@ void TestCopyPaste::testCopyPasteFormulasExternalDoc()
     m_xDocShell->DoLoad(pMedium);
 
     ScDocShellRef xExtDocSh = new ScDocShell;
-    xExtDocSh->SetIsInUcalc();
     OUString const aExtDocName("file:///extdata.fake");
     SfxMedium* pMed = new SfxMedium(aExtDocName, StreamMode::STD_READWRITE);
     xExtDocSh->DoLoad(pMed);
@@ -10189,7 +10188,6 @@ void TestCopyPaste::testCopyPasteReferencesExternalDoc()
     m_xDocShell->DoLoad(pMedium);
 
     ScDocShellRef xExtDocSh = new ScDocShell;
-    xExtDocSh->SetIsInUcalc();
     OUString aExtDocName("file:///extdata.fake");
     SfxMedium* pMed = new SfxMedium(aExtDocName, StreamMode::STD_READWRITE);
     xExtDocSh->DoLoad(pMed);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 337028bfbd4f..311765a6afde 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -6814,7 +6814,6 @@ void TestFormula::testFormulaMatrixResultUpdate()
 void TestFormula::testExternalRef()
 {
     ScDocShellRef xExtDocSh = new ScDocShell;
-    xExtDocSh->SetIsInUcalc();
     OUString aExtDocName("file:///extdata.fake");
     OUString aExtSh1Name("Data1");
     OUString aExtSh2Name("Data2");
@@ -6989,7 +6988,6 @@ void TestFormula::testExternalRef()
 void TestFormula::testExternalRangeName()
 {
     ScDocShellRef xExtDocSh = new ScDocShell;
-    xExtDocSh->SetIsInUcalc();
     OUString const aExtDocName("file:///extdata.fake");
     SfxMedium* pMed = new SfxMedium(aExtDocName, StreamMode::STD_READWRITE);
     xExtDocSh->DoLoad(pMed);
@@ -7101,7 +7099,6 @@ static void testExtRefConcat(ScDocument* pDoc, 
ScDocument& rExtDoc)
 void TestFormula::testExternalRefFunctions()
 {
     ScDocShellRef xExtDocSh = new ScDocShell;
-    xExtDocSh->SetIsInUcalc();
     OUString aExtDocName("file:///extdata.fake");
     SfxMedium* pMed = new SfxMedium(aExtDocName, StreamMode::STD_READWRITE);
     xExtDocSh->DoLoad(pMed);
diff --git a/sc/qa/unit/ucalc_sharedformula.cxx 
b/sc/qa/unit/ucalc_sharedformula.cxx
index e82d21dc3b03..11d4132ec80d 100644
--- a/sc/qa/unit/ucalc_sharedformula.cxx
+++ b/sc/qa/unit/ucalc_sharedformula.cxx
@@ -843,7 +843,6 @@ void 
TestSharedFormula::testSharedFormulasRefUpdateExternal()
 
     // Launch an external document shell.
     ScDocShellRef xExtDocSh = new ScDocShell;
-    xExtDocSh->SetIsInUcalc();
 
     SfxMedium* pMed = new SfxMedium("file:///extdata.fake", 
StreamMode::STD_READWRITE);
     xExtDocSh->DoLoad(pMed);
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 6cbbc2f57222..cb5c9e11606e 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -602,23 +602,20 @@ bool ScDocShell::Load( SfxMedium& rMedium )
             m_pDocument->GetStyleSheetPool()->CreateStandardStyles();
             m_pDocument->UpdStlShtPtrsFrmNms();
 
-            if (!m_bUcalcTest)
-            {
-                /* Create styles that are imported through Orcus */
+            /* Create styles that are imported through Orcus */
 
-                OUString aURL("$BRAND_BASE_DIR/" LIBO_SHARE_FOLDER 
"/calc/styles.xml");
-                rtl::Bootstrap::expandMacros(aURL);
+            OUString aURL("$BRAND_BASE_DIR/" LIBO_SHARE_FOLDER 
"/calc/styles.xml");
+            rtl::Bootstrap::expandMacros(aURL);
 
-                OUString aPath;
-                osl::FileBase::getSystemPathFromFileURL(aURL, aPath);
+            OUString aPath;
+            osl::FileBase::getSystemPathFromFileURL(aURL, aPath);
 
-                ScOrcusFilters* pOrcus = 
ScFormatFilter::Get().GetOrcusFilters();
+            ScOrcusFilters* pOrcus = ScFormatFilter::Get().GetOrcusFilters();
 
-                if (pOrcus)
-                {
-                    pOrcus->importODS_Styles(*m_pDocument, aPath);
-                    m_pDocument->GetStyleSheetPool()->setAllParaStandard();
-                }
+            if (pOrcus)
+            {
+                pOrcus->importODS_Styles(*m_pDocument, aPath);
+                m_pDocument->GetStyleSheetPool()->setAllParaStandard();
             }
 
             bRet = LoadXML( &rMedium, nullptr );
@@ -2884,7 +2881,6 @@ ScDocShell::ScDocShell( const SfxModelFlags 
i_nSfxCreationFlags, const std::shar
     m_bIsInUndo       ( false ),
     m_bDocumentModifiedPending( false ),
     m_bUpdateEnabled  ( true ),
-    m_bUcalcTest     ( false ),
     m_bAreasChangedNeedBroadcast( false ),
     m_nDocumentLock   ( 0 ),
     m_nCanUpdate (css::document::UpdateDocMode::ACCORDING_TO_CONFIG)
@@ -3399,11 +3395,6 @@ bool ScDocShell::GetProtectionHash( /*out*/ 
css::uno::Sequence< sal_Int8 > &rPas
     return bRes;
 }
 
-void ScDocShell::SetIsInUcalc()
-{
-    m_bUcalcTest = true;
-}
-
 void ScDocShell::RegisterAutomationWorkbookObject(css::uno::Reference< 
ooo::vba::excel::XWorkbook > const& xWorkbook)
 {
     mxAutomationWorkbookObject = xWorkbook;
diff --git a/sc/source/ui/docshell/docsh2.cxx b/sc/source/ui/docshell/docsh2.cxx
index 04faa6e75342..cf77e01774e5 100644
--- a/sc/source/ui/docshell/docsh2.cxx
+++ b/sc/source/ui/docshell/docsh2.cxx
@@ -63,22 +63,19 @@ bool ScDocShell::InitNew( const uno::Reference < 
embed::XStorage >& xStor )
         pStyleSheetPool->CreateStandardStyles();
         m_pDocument->UpdStlShtPtrsFrmNms();
 
-        if (!m_bUcalcTest)
-        {
-            /* Create styles that are imported through Orcus */
+        /* Create styles that are imported through Orcus */
 
-            OUString aURL("$BRAND_BASE_DIR/" LIBO_SHARE_FOLDER 
"/calc/styles.xml");
-            rtl::Bootstrap::expandMacros(aURL);
+        OUString aURL("$BRAND_BASE_DIR/" LIBO_SHARE_FOLDER "/calc/styles.xml");
+        rtl::Bootstrap::expandMacros(aURL);
 
-            OUString aPath;
-            osl::FileBase::getSystemPathFromFileURL(aURL, aPath);
+        OUString aPath;
+        osl::FileBase::getSystemPathFromFileURL(aURL, aPath);
 
-            ScOrcusFilters* pOrcus = ScFormatFilter::Get().GetOrcusFilters();
-            if (pOrcus)
-            {
-                pOrcus->importODS_Styles(*m_pDocument, aPath);
-                pStyleSheetPool->setAllParaStandard();
-            }
+        ScOrcusFilters* pOrcus = ScFormatFilter::Get().GetOrcusFilters();
+        if (pOrcus)
+        {
+            pOrcus->importODS_Styles(*m_pDocument, aPath);
+            pStyleSheetPool->setAllParaStandard();
         }
     }
 
diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx
index 95bd297efadb..7830984145c9 100644
--- a/sc/source/ui/inc/docsh.hxx
+++ b/sc/source/ui/inc/docsh.hxx
@@ -94,7 +94,6 @@ class SC_DLLPUBLIC ScDocShell final: public SfxObjectShell, 
public SfxListener
     bool                m_bIsInUndo:1;
     bool                m_bDocumentModifiedPending:1;
     bool                m_bUpdateEnabled:1;
-    bool                m_bUcalcTest:1; // avoid loading the styles in the 
ucalc test
     bool                m_bAreasChangedNeedBroadcast:1;
     sal_uInt16          m_nDocumentLock;
     sal_Int16           m_nCanUpdate;  // stores the UpdateDocMode from 
loading a document till update links
@@ -429,8 +428,6 @@ public:
 
     void SnapVisArea( tools::Rectangle& rRect ) const;
 
-    void SetIsInUcalc();
-
     void RegisterAutomationWorkbookObject(css::uno::Reference< 
ooo::vba::excel::XWorkbook > const& xWorkbook);
 };
 
commit 84552eaf8c50b46ab2c98ad70b6473b4db31baee
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Fri Oct 21 10:37:23 2022 +0200
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Fri Oct 21 12:17:23 2022 +0200

    documentLoadWithOptions takes URLs
    
    m_aDocPath is set in lok_doc_view_set_property from data
    coming from gtv_application_open's calls to g_file_get_path.
    So the path is not a proper file URL, which is expected by
    documentLoadWithOptions. Some Linux paths can happen to be
    able to convert to absolute URL in rtl::Uri::convertRelToAbs,
    but not all, and not e.g. Windows paths.
    
    Change-Id: I0a17cb84000603336a6809b0179bbda3d54aec23
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141579
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index eb06f2608520..0486d16e9213 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -2349,7 +2349,13 @@ openDocumentInThread (gpointer data)
     }
 
     priv->m_pOffice->pClass->registerCallback(priv->m_pOffice, 
globalCallbackWorker, pDocView);
-    priv->m_pDocument = priv->m_pOffice->pClass->documentLoadWithOptions( 
priv->m_pOffice, priv->m_aDocPath.c_str(), "en-US" );
+    std::string url = priv->m_aDocPath;
+    if (gchar* pURL = g_filename_to_uri(url.c_str(), nullptr, nullptr))
+    {
+        url = pURL;
+        g_free(pURL);
+    }
+    priv->m_pDocument = priv->m_pOffice->pClass->documentLoadWithOptions( 
priv->m_pOffice, url.c_str(), "en-US" );
     if ( !priv->m_pDocument )
     {
         char *pError = priv->m_pOffice->pClass->getError( priv->m_pOffice );

Reply via email to