From 89dd3f80685c66883b6ed4efbf369f5aa2dc292e Mon Sep 17 00:00:00 2001
From: Noel Grandin <noel@peralex.com>
Date: Thu, 9 Apr 2015 15:24:21 +0200
Subject: convert SfxObjectCreateMode to scoped enum

and fix some dodgy usage in /sc in the process

Change-Id: Ia2bee267df31aba431fc8cb81195bb83e5b64deb
---
 sc/source/core/tool/progress.cxx   |  2 +-
 sc/source/filter/xml/xmlwrap.cxx   | 10 +++++-----
 sc/source/ui/app/transobj.cxx      |  2 +-
 sc/source/ui/docshell/arealink.cxx |  2 +-
 sc/source/ui/docshell/docsh.cxx    | 12 ++++++------
 sc/source/ui/docshell/docsh4.cxx   |  4 ++--
 sc/source/ui/docshell/docsh6.cxx   |  4 ++--
 sc/source/ui/docshell/tablink.cxx  |  4 ++--
 sc/source/ui/unoobj/confuno.cxx    |  2 +-
 sc/source/ui/unoobj/docuno.cxx     |  6 +++---
 sc/source/ui/view/tabvwsh4.cxx     |  8 ++++----
 sc/source/ui/view/viewfun5.cxx     |  2 +-
 12 files changed, 29 insertions(+), 29 deletions(-)

(limited to 'sc/source')

diff --git a/sc/source/core/tool/progress.cxx b/sc/source/core/tool/progress.cxx
index c428447b4163..ed5dcdcc2ccd 100644
--- a/sc/source/core/tool/progress.cxx
+++ b/sc/source/core/tool/progress.cxx
@@ -95,7 +95,7 @@ ScProgress::ScProgress( SfxObjectShell* pObjSh, const OUString& rText,
 
         pProgress = NULL;
     }
-    else if ( pObjSh && ( pObjSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED ||
+    else if ( pObjSh && ( pObjSh->GetCreateMode() == SfxObjectCreateMode::EMBEDDED ||
                           pObjSh->GetProgress() ||
                           lcl_HasControllersLocked(*pObjSh) ) )
     {
diff --git a/sc/source/filter/xml/xmlwrap.cxx b/sc/source/filter/xml/xmlwrap.cxx
index dee1722a6cd3..b2ee358a1fec 100644
--- a/sc/source/filter/xml/xmlwrap.cxx
+++ b/sc/source/filter/xml/xmlwrap.cxx
@@ -385,7 +385,7 @@ bool ScXMLImportWrapper::Import( sal_uInt8 nMode, ErrCode& rError )
 
     // TODO/LATER: do not do it for embedded links
     OUString aName;
-    if (SFX_CREATE_MODE_EMBEDDED == mrDocShell.GetCreateMode())
+    if (SfxObjectCreateMode::EMBEDDED == mrDocShell.GetCreateMode())
     {
         if ( pMedium && pMedium->GetItemSet() )
         {
@@ -404,7 +404,7 @@ bool ScXMLImportWrapper::Import( sal_uInt8 nMode, ErrCode& rError )
         }
     }
 
-    if (mrDocShell.GetCreateMode() == SFX_CREATE_MODE_ORGANIZER)
+    if (mrDocShell.GetCreateMode() == SfxObjectCreateMode::ORGANIZER)
         xInfoSet->setPropertyValue("OrganizerMode", uno::makeAny(true));
 
     xInfoSet->setPropertyValue( "SourceStorage", uno::Any( xStorage ) );
@@ -520,7 +520,7 @@ bool ScXMLImportWrapper::Import( sal_uInt8 nMode, ErrCode& rError )
     sal_uInt32 nDocRetval(0);
     if ((nMode & CONTENT) == CONTENT)
     {
-        if (mrDocShell.GetCreateMode() == SFX_CREATE_MODE_INTERNAL)
+        if (mrDocShell.GetCreateMode() == SfxObjectCreateMode::INTERNAL)
             // We only need to import content for external link cache document.
             xInfoSet->setPropertyValue(SC_UNO_ODS_IMPORT_STYLES, uno::makeAny(false));
 
@@ -807,7 +807,7 @@ bool ScXMLImportWrapper::Export(bool bStylesOnly)
         xInfoSet->setPropertyValue( sPropName, uno::makeAny( aBaseURL ) );
 
         // TODO/LATER: do not do it for embedded links
-        if( SFX_CREATE_MODE_EMBEDDED == pObjSh->GetCreateMode() )
+        if( SfxObjectCreateMode::EMBEDDED == pObjSh->GetCreateMode() )
         {
             OUString aName("dummyObjectName");
             if ( pMedium && pMedium->GetItemSet() )
@@ -825,7 +825,7 @@ bool ScXMLImportWrapper::Export(bool bStylesOnly)
             }
         }
 
-        bool bMetaRet(pObjSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED);
+        bool bMetaRet(pObjSh->GetCreateMode() == SfxObjectCreateMode::EMBEDDED);
         bool bStylesRet (false);
         bool bDocRet(false);
         bool bSettingsRet(false);
diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx
index df4435a3014e..c8d3de3c6b14 100644
--- a/sc/source/ui/app/transobj.cxx
+++ b/sc/source/ui/app/transobj.cxx
@@ -736,7 +736,7 @@ SfxObjectShell* ScTransferObj::SetDrawClipDoc( bool bAnyOle )
     if (bAnyOle)
     {
         ScGlobal::pDrawClipDocShellRef =
-                        new ScDocShellRef(new ScDocShell(SFX_CREATE_MODE_INTERNAL));      // there must be a ref
+                        new ScDocShellRef(new ScDocShell(SFXMODEL_EMBEDDED_OBJECT | SFXMODEL_DISABLE_EMBEDDED_SCRIPTS));      // there must be a ref
         (*ScGlobal::pDrawClipDocShellRef)->DoInitNew(NULL);
         return *ScGlobal::pDrawClipDocShellRef;
     }
diff --git a/sc/source/ui/docshell/arealink.cxx b/sc/source/ui/docshell/arealink.cxx
index d1d550078b8e..c98146080c2f 100644
--- a/sc/source/ui/docshell/arealink.cxx
+++ b/sc/source/ui/docshell/arealink.cxx
@@ -254,7 +254,7 @@ bool ScAreaLink::Refresh( const OUString& rNewFile, const OUString& rNewFilter,
     SfxMedium* pMed = ScDocumentLoader::CreateMedium( aNewUrl, pFilter, aOptions);
 
     // aRef->DoClose() will be closed explicitly, but it is still more safe to use SfxObjectShellLock here
-    ScDocShell* pSrcShell = new ScDocShell(SFX_CREATE_MODE_INTERNAL);
+    ScDocShell* pSrcShell = new ScDocShell(SFXMODEL_EMBEDDED_OBJECT | SFXMODEL_DISABLE_EMBEDDED_SCRIPTS);
     SfxObjectShellLock aRef = pSrcShell;
     pSrcShell->DoLoad(pMed);
 
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 959837b6dc76..ce2e040869b7 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -274,7 +274,7 @@ void ScDocShell::BeforeXMLLoading()
 
 void ScDocShell::AfterXMLLoading(bool bRet)
 {
-    if (GetCreateMode() != SFX_CREATE_MODE_ORGANIZER)
+    if (GetCreateMode() != SfxObjectCreateMode::ORGANIZER)
     {
         UpdateLinks();
         // don't prevent establishing of listeners anymore
@@ -444,7 +444,7 @@ bool ScDocShell::LoadXML( SfxMedium* pLoadMedium, const ::com::sun::star::uno::R
     bool bRet = false;
     ErrCode nError = ERRCODE_NONE;
     aDocument.EnableAdjustHeight(false);
-    if (GetCreateMode() == SFX_CREATE_MODE_ORGANIZER)
+    if (GetCreateMode() == SfxObjectCreateMode::ORGANIZER)
         bRet = aImport.Import(ScXMLImportWrapper::STYLES, nError);
     else
         bRet = aImport.Import(ScXMLImportWrapper::ALL, nError);
@@ -517,7 +517,7 @@ bool ScDocShell::SaveXML( SfxMedium* pSaveMedium, const ::com::sun::star::uno::R
 
     ScXMLImportWrapper aImport(*this, pSaveMedium, xStor);
     bool bRet(false);
-    if (GetCreateMode() != SFX_CREATE_MODE_ORGANIZER)
+    if (GetCreateMode() != SfxObjectCreateMode::ORGANIZER)
         bRet = aImport.Export(false);
     else
         bRet = aImport.Export(true);
@@ -1575,7 +1575,7 @@ ScDocShell::PrepareSaveGuard::PrepareSaveGuard( ScDocShell& rDocShell )
             mrDocShell.aDocument.MarkUsedExternalReferences();  // Mark tables of external references to be written.
         }
     }
-    if (mrDocShell.GetCreateMode()== SFX_CREATE_MODE_STANDARD)
+    if (mrDocShell.GetCreateMode()== SfxObjectCreateMode::STANDARD)
         mrDocShell.SfxObjectShell::SetVisArea( Rectangle() );   // "Normally" worked on => no VisArea.
 }
 
@@ -2192,7 +2192,7 @@ bool ScDocShell::ConvertTo( SfxMedium &rMed )
 
     if (pAutoStyleList)
         pAutoStyleList->ExecuteAllNow(); // Execute template timeouts now
-    if (GetCreateMode()== SFX_CREATE_MODE_STANDARD)
+    if (GetCreateMode()== SfxObjectCreateMode::STANDARD)
         SfxObjectShell::SetVisArea( Rectangle() ); // Edited normally -> no VisArea
 
     OSL_ENSURE( rMed.GetFilter(), "Filter == 0" );
@@ -2698,7 +2698,7 @@ ScDocShell::ScDocShell( const sal_uInt64 i_nSfxCreationFlags ) :
 {
     SetPool( &SC_MOD()->GetPool() );
 
-    bIsInplace = (GetCreateMode() == SFX_CREATE_MODE_EMBEDDED);
+    bIsInplace = (GetCreateMode() == SfxObjectCreateMode::EMBEDDED);
     //  Will be reset if not in place
 
     pDocFunc = CreateDocFunc();
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index c2077f7eb6d1..d9b73555cf3e 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -1888,7 +1888,7 @@ void ScDocShell::Draw( OutputDevice* pDev, const JobSetup & /* rSetup */, sal_uI
 Rectangle ScDocShell::GetVisArea( sal_uInt16 nAspect ) const
 {
     SfxObjectCreateMode eShellMode = GetCreateMode();
-    if ( eShellMode == SFX_CREATE_MODE_ORGANIZER )
+    if ( eShellMode == SfxObjectCreateMode::ORGANIZER )
     {
         //  ohne Inhalte wissen wir auch nicht, wie gross die Inhalte sind
         //  leeres Rechteck zurueckgeben, das wird dann nach dem Laden berechnet
@@ -1913,7 +1913,7 @@ Rectangle ScDocShell::GetVisArea( sal_uInt16 nAspect ) const
         SnapVisArea( aArea );
         return aArea;
     }
-    else if( nAspect == ASPECT_CONTENT && eShellMode != SFX_CREATE_MODE_EMBEDDED )
+    else if( nAspect == ASPECT_CONTENT && eShellMode != SfxObjectCreateMode::EMBEDDED )
     {
         //  Visarea holen wie nach Load
 
diff --git a/sc/source/ui/docshell/docsh6.cxx b/sc/source/ui/docshell/docsh6.cxx
index 92b6e2a5dc8e..3918dbc929df 100644
--- a/sc/source/ui/docshell/docsh6.cxx
+++ b/sc/source/ui/docshell/docsh6.cxx
@@ -171,7 +171,7 @@ void ScDocShell::SetVisAreaOrSize( const Rectangle& rVisArea, bool bModifyStart
 
 bool ScDocShell::IsOle()
 {
-    return (GetCreateMode() == SFX_CREATE_MODE_EMBEDDED);
+    return (GetCreateMode() == SfxObjectCreateMode::EMBEDDED);
 }
 
 void ScDocShell::UpdateOle( const ScViewData* pViewData, bool bSnapSize )
@@ -179,7 +179,7 @@ void ScDocShell::UpdateOle( const ScViewData* pViewData, bool bSnapSize )
     //  wenn's gar nicht Ole ist, kann man sich die Berechnungen sparen
     //  (VisArea wird dann beim Save wieder zurueckgesetzt)
 
-    if (GetCreateMode() == SFX_CREATE_MODE_STANDARD)
+    if (GetCreateMode() == SfxObjectCreateMode::STANDARD)
         return;
 
     OSL_ENSURE(pViewData,"pViewData==0 bei ScDocShell::UpdateOle");
diff --git a/sc/source/ui/docshell/tablink.cxx b/sc/source/ui/docshell/tablink.cxx
index c669e6b69829..b744295fa13a 100644
--- a/sc/source/ui/docshell/tablink.cxx
+++ b/sc/source/ui/docshell/tablink.cxx
@@ -200,7 +200,7 @@ bool ScTableLink::Refresh(const OUString& rNewFile, const OUString& rNewFilter,
         pMed->UseInteractionHandler(true);    // enable the filter options dialog
 
     // aRef->DoClose() will be called explicitly, but it is still more safe to use SfxObjectShellLock here
-    ScDocShell* pSrcShell = new ScDocShell(SFX_CREATE_MODE_INTERNAL);
+    ScDocShell* pSrcShell = new ScDocShell(SFXMODEL_EMBEDDED_OBJECT | SFXMODEL_DISABLE_EMBEDDED_SCRIPTS);
     SfxObjectShellLock aRef = pSrcShell;
     pSrcShell->DoLoad(pMed);
 
@@ -532,7 +532,7 @@ ScDocumentLoader::ScDocumentLoader( const OUString& rFileName,
     if ( bWithInteraction )
         pMedium->UseInteractionHandler( true ); // to enable the filter options dialog
 
-    pDocShell = new ScDocShell( SFX_CREATE_MODE_INTERNAL );
+    pDocShell = new ScDocShell( SFXMODEL_EMBEDDED_OBJECT | SFXMODEL_DISABLE_EMBEDDED_SCRIPTS );
     aRef = pDocShell;
 
     ScDocument& rDoc = pDocShell->GetDocument();
diff --git a/sc/source/ui/unoobj/confuno.cxx b/sc/source/ui/unoobj/confuno.cxx
index 6d0ceb731c8a..c7f19d4f4b93 100644
--- a/sc/source/ui/unoobj/confuno.cxx
+++ b/sc/source/ui/unoobj/confuno.cxx
@@ -184,7 +184,7 @@ void SAL_CALL ScDocumentConfiguration::setPropertyValue(
             if ( aValue >>= sPrinterName )
             {
                 // #i75610# if the name is empty, do nothing (don't create any printer)
-                if ( !sPrinterName.isEmpty() && pDocShell->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED )
+                if ( !sPrinterName.isEmpty() && pDocShell->GetCreateMode() != SfxObjectCreateMode::EMBEDDED )
                 {
                     SfxPrinter* pPrinter = pDocShell->GetPrinter();
                     if (pPrinter)
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index f2d62cfbe539..20ffa3309d3b 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -1854,7 +1854,7 @@ uno::Reference< container::XIndexAccess > SAL_CALL ScModelObj::getViewData(  )
     if( !xRet.is() )
     {
         SolarMutexGuard aGuard;
-        if (pDocShell && pDocShell->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED)
+        if (pDocShell && pDocShell->GetCreateMode() == SfxObjectCreateMode::EMBEDDED)
         {
             uno::Reference < container::XIndexContainer > xCont = document::IndexedPropertyValues::create( ::comphelper::getProcessComponentContext() );
             xRet.set( xCont, uno::UNO_QUERY_THROW );
@@ -2209,7 +2209,7 @@ uno::Any SAL_CALL ScModelObj::getPropertyValue( const OUString& aPropertyName )
         }
         else if ( aString == "InternalDocument" )
         {
-            ScUnoHelpFunctions::SetBoolInAny( aRet, (pDocShell->GetCreateMode() == SFX_CREATE_MODE_INTERNAL) );
+            ScUnoHelpFunctions::SetBoolInAny( aRet, (pDocShell->GetCreateMode() == SfxObjectCreateMode::INTERNAL) );
         }
         else if ( aString == SC_UNO_INTEROPGRABBAG )
         {
@@ -2251,7 +2251,7 @@ css::uno::Reference<css::uno::XInterface> ScModelObj::create(
         // there should be no data provider, so that own data is used
         bool bCreate =
             ! ( nType == SC_SERVICE_CHDATAPROV &&
-                ( pDocShell->GetCreateMode() == SFX_CREATE_MODE_INTERNAL ));
+                ( pDocShell->GetCreateMode() == SfxObjectCreateMode::INTERNAL ));
         // this should never happen, i.e. the temporary document should never be
         // loaded, because this unlinks the data
         OSL_ASSERT( bCreate );
diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx
index a90605d795a8..b62648ec3840 100644
--- a/sc/source/ui/view/tabvwsh4.cxx
+++ b/sc/source/ui/view/tabvwsh4.cxx
@@ -323,7 +323,7 @@ bool ScTabViewShell::PrepareClose(bool bUI)
 void ScTabViewShell::UpdateOleZoom()
 {
     ScDocShell* pDocSh = GetViewData().GetDocShell();
-    if ( pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
+    if ( pDocSh->GetCreateMode() == SfxObjectCreateMode::EMBEDDED )
     {
         //TODO/LATER: is there a difference between the two GetVisArea methods?
         Size aObjSize = ((const SfxObjectShell*)pDocSh)->GetVisArea().GetSize();
@@ -1473,7 +1473,7 @@ void ScTabViewShell::Construct( sal_uInt8 nForceDesignMode )
     bool bFirstView = !pFirst
           || (pFirst == GetViewFrame() && !SfxViewFrame::GetNext(*pFirst,pDocSh));
 
-    if ( pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
+    if ( pDocSh->GetCreateMode() == SfxObjectCreateMode::EMBEDDED )
     {
         //TODO/LATER: is there a difference between the two GetVisArea methods?
         Rectangle aVisArea = ((const SfxObjectShell*)pDocSh)->GetVisArea();
@@ -1552,7 +1552,7 @@ void ScTabViewShell::Construct( sal_uInt8 nForceDesignMode )
             rDoc.SetLayoutRTL( 0, ScGlobal::IsSystemRTL() );
 
             // append additional sheets (not for OLE object)
-            if ( pDocSh->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED )
+            if ( pDocSh->GetCreateMode() != SfxObjectCreateMode::EMBEDDED )
             {
                 // Get the customized initial tab count
                 const ScDefaultsOptions& rOpt = SC_MOD()->GetDefaultsOptions();
@@ -1568,7 +1568,7 @@ void ScTabViewShell::Construct( sal_uInt8 nForceDesignMode )
         // ReadExtOptions is now in Activate
 
         //  Link-Update nicht verschachteln
-        if ( pDocSh->GetCreateMode() != SFX_CREATE_MODE_INTERNAL &&
+        if ( pDocSh->GetCreateMode() != SfxObjectCreateMode::INTERNAL &&
              pDocSh->IsUpdateEnabled() )  // #105575#; update only in the first creation of the ViewShell
         {
             // Check if there are any external data.
diff --git a/sc/source/ui/view/viewfun5.cxx b/sc/source/ui/view/viewfun5.cxx
index ef3b99c30ee8..626c4ff3bbfb 100644
--- a/sc/source/ui/view/viewfun5.cxx
+++ b/sc/source/ui/view/viewfun5.cxx
@@ -129,7 +129,7 @@ bool ScViewFunc::PasteDataFormat( SotClipboardFormatId nFormatId,
                 SfxMedium* pMedium = new SfxMedium( xStore, OUString() );
 
                 //  TODO/LATER: is it a problem that we don't support binary formats here?
-                ScDocShellRef xDocShRef = new ScDocShell(SFX_CREATE_MODE_EMBEDDED);
+                ScDocShellRef xDocShRef = new ScDocShell(SFXMODEL_STANDARD);
                 if (xDocShRef->DoLoad(pMedium))
                 {
                     ScDocument& rSrcDoc = xDocShRef->GetDocument();
-- 
cgit