commit 22bc60febdb82502a94b292cb89790c706bf3218
Author: Douglas Mencken <dougmencken@gmail.com>
Date:   Mon Aug 18 05:52:41 2014 -0400

    add possibility to --disable-autorecovery before building
    
    This controls whether to build document auto-recovery feature or not.
    
    Change-Id: I97ce24e21e8e397088c12d829955bb2f2d72d718

diff --git a/config_host.mk.in b/config_host.mk.in
index f438432..064d808 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -104,6 +104,7 @@ export DO_FETCH_TARBALLS=@DO_FETCH_TARBALLS@
 export DPKG=@DPKG@
 export EBOOK_CFLAGS=$(gb_SPACE)@EBOOK_CFLAGS@
 export EBOOK_LIBS=$(gb_SPACE)@EBOOK_LIBS@
+export ENABLE_AUTORECOVERY=@ENABLE_AUTORECOVERY@
 export ENABLE_AVAHI=@ENABLE_AVAHI@
 export ENABLE_CAIRO_CANVAS=@ENABLE_CAIRO_CANVAS@
 export ENABLE_CHART_TESTS=@ENABLE_CHART_TESTS@
diff --git a/configure.ac b/configure.ac
index f4b7659..8015db7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -874,6 +874,11 @@ AC_ARG_ENABLE(pdfimport,
         [Disable building the PDF import feature.])
 )
 
+AC_ARG_ENABLE(autorecovery,
+    AS_HELP_STRING([--disable-autorecovery],
+        [Disable building document auto-recovery feature.])
+)
+
 ###############################################################################
 
 dnl ---------- *** ----------
@@ -10660,6 +10665,17 @@ AC_SUBST(SYSTEM_POPPLER)
 AC_SUBST(POPPLER_CFLAGS)
 AC_SUBST(POPPLER_LIBS)
 
+# auto-recovery feature?
+AC_MSG_CHECKING([whether to build document auto-recovery feature])
+ENABLE_AUTORECOVERY=
+if test -z "$enable_autorecovery" -o "x$enable_autorecovery" = "xyes"; then
+    AC_MSG_RESULT([yes])
+    ENABLE_AUTORECOVERY=TRUE
+else
+    AC_MSG_RESULT([no])
+fi
+AC_SUBST([ENABLE_AUTORECOVERY])
+
 AC_MSG_CHECKING([whether to build the Wiki Publisher extension])
 if test "x$enable_ext_wiki_publisher" = "xyes" -a "x$enable_extension_integration" != "xno" -a "$with_java" != "no"; then
     AC_MSG_RESULT([yes])
diff --git a/desktop/Library_sofficeapp.mk b/desktop/Library_sofficeapp.mk
index be86dd1..f950cfa 100644
--- a/desktop/Library_sofficeapp.mk
+++ b/desktop/Library_sofficeapp.mk
@@ -27,6 +27,7 @@ $(eval $(call gb_Library_use_sdk_api,sofficeapp))
 
 $(eval $(call gb_Library_add_defs,sofficeapp,\
     -DDESKTOP_DLLIMPLEMENTATION \
+    $(if $(filter TRUE,$(ENABLE_AUTORECOVERY)),-DAUTORECOVERY_ON) \
     $(if $(filter WNT,$(OS)),-DENABLE_QUICKSTART_APPLET) \
     $(if $(filter MACOSX,$(OS)),-DENABLE_QUICKSTART_APPLET) \
     $(if $(filter TRUE,$(ENABLE_SYSTRAY_GTK)),-DENABLE_QUICKSTART_APPLET) \
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 0332f90..0086d96 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -39,7 +39,9 @@
 #include <svl/languageoptions.hxx>
 #include <svtools/javacontext.hxx>
 #include <com/sun/star/beans/XPropertySet.hpp>
+#ifdef AUTORECOVERY_ON
 #include <com/sun/star/frame/theAutoRecovery.hpp>
+#endif
 #include <com/sun/star/frame/theGlobalEventBroadcaster.hpp>
 #include <com/sun/star/frame/SessionListener.hpp>
 #include <com/sun/star/frame/XSessionManagerListener.hpp>
@@ -82,7 +84,9 @@
 #include <unotools/configmgr.hxx>
 #include <unotools/moduleoptions.hxx>
 #include <officecfg/Office/Common.hxx>
+#ifdef AUTORECOVERY_ON
 #include <officecfg/Office/Recovery.hxx>
+#endif
 #include <officecfg/Setup.hxx>
 #include <osl/file.hxx>
 #include <osl/process.h>
@@ -1076,8 +1080,12 @@ void Desktop::HandleBootstrapErrors(
 
 bool Desktop::isUIOnSessionShutdownAllowed()
 {
+#ifdef AUTORECOVERY_ON
     return officecfg::Office::Recovery::SessionShutdown::DocumentStoreUIEnabled
         ::get();
+#else
+    return true;
+#endif
 }
 
 
@@ -1097,7 +1105,9 @@ bool Desktop::isUIOnSessionShutdownAllowed()
             Because the user may be logged out last time from it's
             unix session...
 */
-void impl_checkRecoveryState(bool& bCrashed           ,
+
+#ifdef AUTORECOVERY_ON
+void impl_checkRecoveryState(bool& bCrashed,
                              bool& bRecoveryDataExists,
                              bool& bSessionDataExists )
 {
@@ -1109,14 +1119,16 @@ void impl_checkRecoveryState(bool& bCrashed           ,
     bRecoveryDataExists = elements && !session;
     bSessionDataExists = elements && session;
 }
-
+#endif
 
 /*  @short  start the recovery wizard.
 
     @param  bEmergencySave
             differs between EMERGENCY_SAVE and RECOVERY
 */
-bool impl_callRecoveryUI(bool bEmergencySave     ,
+
+#ifdef AUTORECOVERY_ON
+bool impl_callRecoveryUI(bool bEmergencySave,
                          bool bExistsRecoveryData)
 {
     static OUString SERVICENAME_RECOVERYUI("com.sun.star.comp.svx.RecoveryUI");
@@ -1147,20 +1159,25 @@ bool impl_callRecoveryUI(bool bEmergencySave     ,
     aRet >>= bRet;
     return !bEmergencySave || bRet;
 }
+#endif
 
 /*
  * Save all open documents so they will be reopened
  * the next time the application is started
  *
- * returns sal_True if at least one document could be saved...
+ * returns true if at least one document could be saved...
  *
  */
 
 bool Desktop::SaveTasks()
 {
+#ifdef AUTORECOVERY_ON
     return impl_callRecoveryUI(
-        true , // sal_True => force emergency save
+        true , // true => force emergency save
         false);
+#else
+    return false;
+#endif
 }
 
 namespace {
@@ -1262,18 +1279,20 @@ sal_uInt16 Desktop::Exception(sal_uInt16 nError)
     }
 
     bInException = true;
-    const CommandLineArgs& rArgs = GetCommandLineArgs();
 
     // save all modified documents ... if it's allowed doing so.
-    bool bRestart                           = false;
-    bool bAllowRecoveryAndSessionManagement = (
-                                                    ( !rArgs.IsNoRestore()                    ) && // some use cases of office must work without recovery
-                                                    ( !rArgs.IsHeadless()                     ) &&
-                                                    (( nError & EXC_MAJORTYPE ) != EXC_DISPLAY ) && // recovery can't work without UI ... but UI layer seems to be the reason for this crash
-                                                    ( Application::IsInExecute()               )    // crashes during startup and shutdown should be ignored (they indicates a corrupt installation ...)
-                                                  );
-    if ( bAllowRecoveryAndSessionManagement )
+    bool bRestart                = false;
+#ifdef AUTORECOVERY_ON
+    const CommandLineArgs& rArgs = GetCommandLineArgs();
+    bool bAllowRecovery = (
+                            !rArgs.IsNoRestore() && // option to work without recovery
+                            (( nError & EXC_MAJORTYPE ) != EXC_DISPLAY ) && // recovery can't work without UI ... but UI layer seems to be the reason for this crash
+                            ( Application::IsInExecute() ) // crashes during startup and shutdown should be ignored (they indicates a corrupt installation)
+                          );
+    bool bAllowSessionManagement = !rArgs.IsHeadless();
+    if ( bAllowRecovery && bAllowSessionManagement )
         bRestart = SaveTasks();
+#endif
 
     FlushConfiguration();
 
@@ -1520,13 +1539,15 @@ int Desktop::Main()
         SetSplashScreenProgress(50);
 
         // Backing Component
-        bool bCrashed            = false;
         bool bExistsRecoveryData = false;
         bool bExistsSessionData  = false;
 
+#ifdef AUTORECOVERY_ON
         SAL_INFO( "desktop.app", "{ impl_checkRecoveryState" );
+        bool bCrashed = false;
         impl_checkRecoveryState(bCrashed, bExistsRecoveryData, bExistsSessionData);
         SAL_INFO( "desktop.app", "} impl_checkRecoveryState" );
+#endif
 
         OUString pidfileName = rCmdLineArgs.GetPidfileName();
         if ( !pidfileName.isEmpty() )
@@ -2218,12 +2239,6 @@ void Desktop::PreloadConfigurationData()
 
 void Desktop::OpenClients()
 {
-
-    // check if a document has been recovered - if there is one of if a document was loaded by cmdline, no default document
-    // should be created
-    Reference < XComponent > xFirst;
-    bool bRecovery = false;
-
     const CommandLineArgs& rArgs = GetCommandLineArgs();
 
     if (!rArgs.IsQuickstart())
@@ -2302,6 +2317,14 @@ void Desktop::OpenClients()
         }
     }
 
+    bool bAllowSessionManagement = !rArgs.IsHeadless();
+
+#ifdef AUTORECOVERY_ON
+    // check if a document has been recovered - if there is one of if a document was loaded by cmdline, no default document
+    // should be created
+    Reference < XComponent > xFirst;
+    bool bRecovery = false;
+
     // Disable AutoSave feature in case "--norestore" or a similar command line switch is set on the command line.
     // The reason behind: AutoSave/EmergencySave/AutoRecovery share the same data.
     // But the require that all documents, which are saved as backup should exists inside
@@ -2309,9 +2332,9 @@ void Desktop::OpenClients()
     // but no document inside memory corrspond to this data.
     // Furter it's not acceptable to recover such documents without any UI. It can
     // need some time, where the user wont see any results and wait for finishing the office startup ...
-    bool bAllowRecoveryAndSessionManagement = ( !rArgs.IsNoRestore() ) && ( !rArgs.IsHeadless()  );
+    bool bAllowRecovery = !rArgs.IsNoRestore();
 
-    if ( ! bAllowRecoveryAndSessionManagement )
+    if ( ! bAllowRecovery )
     {
         try
         {
@@ -2347,7 +2370,7 @@ void Desktop::OpenClients()
             try
             {
                 bRecovery = impl_callRecoveryUI(
-                    false          , // false => force recovery instead of emergency save
+                    false, // false => force recovery instead of emergency save
                     bExistsRecoveryData);
             }
             catch(const css::uno::Exception& e)
@@ -2355,7 +2378,11 @@ void Desktop::OpenClients()
                 SAL_WARN( "desktop.app", "Error during recovery" << e.Message);
             }
         }
+    }
+#endif
 
+    if ( bAllowSessionManagement )
+    {
         Reference< XSessionManagerListener2 > xSessionListener;
         try
         {
@@ -2368,18 +2395,23 @@ void Desktop::OpenClients()
             SAL_WARN( "desktop.app", "Registration of session listener failed" << e.Message);
         }
 
-        if ( !bExistsRecoveryData && xSessionListener.is() )
+#ifdef AUTORECOVERY_ON
+        if ( bAllowRecovery )
         {
-            // session management
-            try
-            {
-                xSessionListener->doRestore();
-            }
-            catch(const com::sun::star::uno::Exception& e)
+            if ( !bExistsRecoveryData && xSessionListener.is() )
             {
-                SAL_WARN( "desktop.app", "Error in session management" << e.Message);
+                // session management
+                try
+                {
+                    xSessionListener->doRestore();
+                }
+                catch(const com::sun::star::uno::Exception& e)
+                {
+                    SAL_WARN( "desktop.app", "Error in session management" << e.Message);
+                }
             }
         }
+#endif
     }
 
     OfficeIPCThread::EnableRequests();
@@ -2457,6 +2489,7 @@ void Desktop::OpenClients()
         // soffice was started as tray icon ...
         return;
 
+#ifdef AUTORECOVERY_ON
     if ( bRecovery )
     {
         ShowBackingComponent(0);
@@ -2465,6 +2498,9 @@ void Desktop::OpenClients()
     {
         OpenDefault();
     }
+#else
+    OpenDefault();
+#endif
 }
 
 void Desktop::OpenDefault()
diff --git a/framework/Library_fwk.mk b/framework/Library_fwk.mk
index 74e72a9..361c984 100644
--- a/framework/Library_fwk.mk
+++ b/framework/Library_fwk.mk
@@ -27,6 +27,12 @@ $(eval $(call gb_Library_set_include,fwk,\
     $$(INCLUDE) \
 ))
 
+ifeq ($(ENABLE_AUTORECOVERY),TRUE)
+$(eval $(call gb_Library_add_defs,fwk,\
+    -DAUTORECOVERY_ON \
+))
+endif
+
 $(eval $(call gb_Library_set_precompiled_header,fwk,$(SRCDIR)/framework/inc/pch/precompiled_fwk))
 
 $(eval $(call gb_Library_use_external,fwk,boost_headers))
@@ -105,7 +111,7 @@ $(eval $(call gb_Library_add_exception_objects,fwk,\
     framework/source/loadenv/loadenv \
     framework/source/loadenv/targethelper \
     framework/source/services/ContextChangeEventMultiplexer \
-    framework/source/services/autorecovery \
+    $(call gb_Helper_optional,ENABLE_AUTORECOVERY,framework/source/services/autorecovery) \
     framework/source/services/desktop \
     framework/source/services/frame \
     framework/source/services/modulemanager \
diff --git a/framework/inc/properties.h b/framework/inc/properties.h
index 1b0972f..32851ad 100644
--- a/framework/inc/properties.h
+++ b/framework/inc/properties.h
@@ -193,6 +193,7 @@ namespace framework{
 #define UICOMMANDDESCRIPTION_PROPERTIES_IMAGE_ROTATED           4
 #define UICOMMANDDESCRIPTION_PROPERTIES_TOGGLEBUTTON            8
 
+#ifdef AUTORECOVERY_ON
 /** properties for "AutoRecovery" class */
 
 #define AUTORECOVERY_PROPNAME_ASCII_EXISTS_RECOVERYDATA "ExistsRecoveryData"
@@ -208,6 +209,7 @@ namespace framework{
 #define AUTORECOVERY_PROPHANDLE_CRASHED                 2
 
 #define AUTORECOVERY_PROPCOUNT                          3
+#endif
 
 /** properties for Filter config */
 
diff --git a/framework/inc/services.h b/framework/inc/services.h
index 673228c..74e99f4 100644
--- a/framework/inc/services.h
+++ b/framework/inc/services.h
@@ -81,7 +81,9 @@ namespace framework{
 #define IMPLEMENTATIONNAME_ADDONSTOOLBARFACTORY                 DECLARE_ASCII("com.sun.star.comp.framework.AddonsToolBarFactory"    )
 #define IMPLEMENTATIONNAME_TOOLBARSMENUCONTROLLER               DECLARE_ASCII("com.sun.star.comp.framework.ToolBarsMenuController"  )
 #define IMPLEMENTATIONNAME_TOOLBARCONTROLLERFACTORY             DECLARE_ASCII("com.sun.star.comp.framework.ToolBarControllerFactory"    )
+#ifdef AUTORECOVERY_ON
 #define IMPLEMENTATIONNAME_AUTORECOVERY                         DECLARE_ASCII("com.sun.star.comp.framework.AutoRecovery"            )
+#endif
 #define IMPLEMENTATIONNAME_RECENTFILESMENUCONTROLLER            DECLARE_ASCII("com.sun.star.comp.framework.RecentFilesMenuController" )
 #define IMPLEMENTATIONNAME_STATUSBARFACTORY                     DECLARE_ASCII("com.sun.star.comp.framework.StatusBarFactory"        )
 #define IMPLEMENTATIONNAME_STATUSBARCONTROLLERFACTORY           DECLARE_ASCII("com.sun.star.comp.framework.StatusBarControllerFactory" )
diff --git a/framework/source/services/sessionlistener.cxx b/framework/source/services/sessionlistener.cxx
index 5820f21..a690cdf 100644
--- a/framework/source/services/sessionlistener.cxx
+++ b/framework/source/services/sessionlistener.cxx
@@ -28,7 +28,9 @@
 #include <unotools/tempfile.hxx>
 #include <com/sun/star/beans/NamedValue.hpp>
 #include <com/sun/star/beans/PropertyValue.hpp>
+#ifdef AUTORECOVERY_ON
 #include <com/sun/star/frame/theAutoRecovery.hpp>
+#endif
 #include <com/sun/star/frame/Desktop.hpp>
 #include <com/sun/star/frame/FeatureStateEvent.hpp>
 #include <com/sun/star/frame/XDispatch.hpp>
@@ -92,19 +94,25 @@ private:
 
     css::uno::Reference< css::frame::XSessionManagerClient > m_rSessionManager;
 
+#ifdef AUTORECOVERY_ON
     // restore handling
     bool m_bRestored;
+#endif
 
     bool m_bSessionStoreRequested;
 
     bool m_bAllowUserInteractionOnQuit;
     bool m_bTerminated;
 
+#ifdef AUTORECOVERY_ON
     // in case of synchronous call the caller should do saveDone() call himself!
     void StoreSession( bool bAsync );
+#endif
 
+#ifdef AUTORECOVERY_ON
     // let session quietly close the documents, remove lock files, store configuration and etc.
     void QuitSessionQuietly();
+#endif
 
 public:
     SessionListener( const css::uno::Reference< css::uno::XComponentContext >& xContext );
@@ -157,7 +165,9 @@ public:
 
 SessionListener::SessionListener(const css::uno::Reference< css::uno::XComponentContext >& rxContext )
         : m_xContext( rxContext )
+#ifdef AUTORECOVERY_ON
         , m_bRestored( false )
+#endif
         , m_bSessionStoreRequested( false )
         , m_bAllowUserInteractionOnQuit( false )
         , m_bTerminated( false )
@@ -175,6 +185,7 @@ SessionListener::~SessionListener()
     }
 }
 
+#ifdef AUTORECOVERY_ON
 void SessionListener::StoreSession( bool bAsync )
 {
     SAL_INFO("fwk.session", "SessionListener::StoreSession");
@@ -207,7 +218,9 @@ void SessionListener::StoreSession( bool bAsync )
             m_rSessionManager->saveDone(this);
     }
 }
+#endif
 
+#ifdef AUTORECOVERY_ON
 void SessionListener::QuitSessionQuietly()
 {
     SAL_INFO("fwk.session", "SessionListener::QuitSessionQuietly");
@@ -231,6 +244,7 @@ void SessionListener::QuitSessionQuietly()
         SAL_WARN("fwk.session",e.Message);
     }
 }
+#endif
 
 void SAL_CALL SessionListener::disposing(const com::sun::star::lang::EventObject&) throw (RuntimeException, std::exception)
 {
@@ -275,6 +289,7 @@ void SAL_CALL SessionListener::statusChanged(const frame::FeatureStateEvent& eve
     throw (css::uno::RuntimeException, std::exception)
 {
    SAL_INFO("fwk.session", "SessionListener::statusChanged");
+#ifdef AUTORECOVERY_ON
    if ( event.FeatureURL.Complete == "vnd.sun.star.autorecovery:/doSessionRestore" )
     {
         if (event.FeatureDescriptor.equalsAscii("update"))
@@ -283,12 +298,15 @@ void SAL_CALL SessionListener::statusChanged(const frame::FeatureStateEvent& eve
     }
     else if ( event.FeatureURL.Complete == "vnd.sun.star.autorecovery:/doSessionSave" )
     {
+#endif
         if (event.FeatureDescriptor.equalsAscii("stop"))
         {
             if (m_rSessionManager.is())
                 m_rSessionManager->saveDone(this); // done with save
         }
+#ifdef AUTORECOVERY_ON
     }
+#endif
 }
 
 sal_Bool SAL_CALL SessionListener::doRestore()
@@ -296,6 +314,7 @@ sal_Bool SAL_CALL SessionListener::doRestore()
 {
     SAL_INFO("fwk.session", "SessionListener::doRestore");
     osl::MutexGuard g(m_aMutex);
+#ifdef AUTORECOVERY_ON
     m_bRestored = false;
     try {
         css::uno::Reference< frame::XDispatch > xDispatch = css::frame::theAutoRecovery::get( m_xContext );
@@ -314,6 +333,9 @@ sal_Bool SAL_CALL SessionListener::doRestore()
     }
 
     return m_bRestored;
+#else
+    return true;
+#endif
 }
 
 void SAL_CALL SessionListener::doSave( sal_Bool bShutdown, sal_Bool /*bCancelable*/ )
@@ -326,7 +348,11 @@ void SAL_CALL SessionListener::doSave( sal_Bool bShutdown, sal_Bool /*bCancelabl
         if ( m_bAllowUserInteractionOnQuit && m_rSessionManager.is() )
             m_rSessionManager->queryInteraction( static_cast< css::frame::XSessionManagerListener* >( this ) );
         else
+        {
+#ifdef AUTORECOVERY_ON
             StoreSession( true );
+#endif
+        }
     }
     // we don't have anything to do so tell the session manager we're done
     else if( m_rSessionManager.is() )
@@ -345,8 +371,10 @@ void SAL_CALL SessionListener::approveInteraction( sal_Bool bInteractionGranted
         // close the office documents in normal way
         try
         {
+#ifdef AUTORECOVERY_ON
             // first of all let the session be stored to be sure that we lose no information
             StoreSession( false );
+#endif
 
             css::uno::Reference< css::frame::XDesktop2 > xDesktop = css::frame::Desktop::create( m_xContext );
             // honestly: how many implementations of XDesktop will we ever have?
@@ -374,7 +402,9 @@ void SAL_CALL SessionListener::approveInteraction( sal_Bool bInteractionGranted
         }
         catch( const css::uno::Exception& )
         {
+#ifdef AUTORECOVERY_ON
             StoreSession( true );
+#endif
             m_rSessionManager->interactionDone( this );
         }
 
@@ -383,7 +413,9 @@ void SAL_CALL SessionListener::approveInteraction( sal_Bool bInteractionGranted
     }
     else
     {
+#ifdef AUTORECOVERY_ON
         StoreSession( true );
+#endif
     }
 }
 
@@ -399,11 +431,13 @@ void SessionListener::doQuit()
     throw (RuntimeException, std::exception)
 {
     SAL_INFO("fwk.session", "SessionListener::doQuit");
+#ifdef AUTORECOVERY_ON
     if ( m_bSessionStoreRequested && !m_bTerminated )
     {
         // let the session be closed quietly in this case
         QuitSessionQuietly();
     }
+#endif
 }
 
 }
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index b317d8c..5af185f 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -25,7 +25,6 @@ $(eval $(call gb_UnoApi_use_api,offapi,\
     udkapi \
 ))
 
-
 $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/animations,\
 	AnimateColor \
 	AnimateMotion \
@@ -179,7 +178,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/form/runtime,\
 	FormOperations \
 ))
 $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/frame,\
-	AutoRecovery \
+	$(call gb_Helper_optional,ENABLE_AUTORECOVERY,AutoRecovery) \
 	AppDispatchProvider \
 	Bibliography \
 	ContentHandlerFactory \
@@ -199,7 +198,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/frame,\
     StartModule \
     TaskCreator \
 	UICommandDescription \
-	theAutoRecovery \
+	$(call gb_Helper_optional,ENABLE_AUTORECOVERY,theAutoRecovery) \
 	theDesktop \
 	theGlobalEventBroadcaster \
 	theUICommandDescription \
diff --git a/sd/Library_sdui.mk b/sd/Library_sdui.mk
index 60409c0..5121fd2 100644
--- a/sd/Library_sdui.mk
+++ b/sd/Library_sdui.mk
@@ -28,6 +28,12 @@ endif
 
 endif
 
+ifeq ($(ENABLE_AUTORECOVERY),TRUE)
+$(eval $(call gb_Library_add_defs,sdui,\
+    -DAUTORECOVERY_ON \
+))
+endif
+
 $(eval $(call gb_Library_use_custom_headers,sdui,\
 	officecfg/registry \
 ))
diff --git a/sd/source/ui/slideshow/slideshowimpl.cxx b/sd/source/ui/slideshow/slideshowimpl.cxx
index 606f804..717478e 100644
--- a/sd/source/ui/slideshow/slideshowimpl.cxx
+++ b/sd/source/ui/slideshow/slideshowimpl.cxx
@@ -17,7 +17,9 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#ifdef AUTORECOVERY_ON
 #include <com/sun/star/frame/theAutoRecovery.hpp>
+#endif
 #include <com/sun/star/frame/XComponentLoader.hpp>
 #include <com/sun/star/lang/XInitialization.hpp>
 #include <com/sun/star/document/XEventsSupplier.hpp>
@@ -509,7 +511,9 @@ SlideshowImpl::SlideshowImpl( const Reference< XPresentation2 >& xPresentation,
 , mbSlideBorderVisible(false)
 , mbSetOnlineSpelling(false)
 , mbDisposed(false)
+#ifdef AUTORECOVERY_ON
 , mbAutoSaveWasOn(false)
+#endif
 , mbRehearseTimings(false)
 , mbDesignMode(false)
 , mbIsPaused(false)
@@ -546,9 +550,11 @@ SlideshowImpl::SlideshowImpl( const Reference< XPresentation2 >& xPresentation,
 
     SvtSaveOptions aOptions;
 
+#ifdef AUTORECOVERY_ON
         // no autosave during show
     if( aOptions.IsAutoSave() )
         mbAutoSaveWasOn = true;
+#endif
 
     Application::AddEventListener( LINK( this, SlideshowImpl, EventListenerHdl ) );
 
@@ -593,8 +599,10 @@ void SAL_CALL SlideshowImpl::disposing()
     if( mxShow.is() && mpDoc )
         NotifyDocumentEvent( mpDoc, "OnEndPresentation" );
 
+#ifdef AUTORECOVERY_ON
     if( mbAutoSaveWasOn )
         setAutoSaveState( true );
+#endif
 
     if( mnEndShowEvent )
         Application::RemoveUserEvent( mnEndShowEvent );
@@ -2620,9 +2628,10 @@ void SAL_CALL SlideshowImpl::activate() throw (RuntimeException, std::exception)
 
         if( ANIMATIONMODE_SHOW == meAnimationMode )
         {
+#ifdef AUTORECOVERY_ON
             if( mbAutoSaveWasOn )
                 setAutoSaveState( false );
-
+#endif
             if( mpShowWindow )
             {
                 SfxViewFrame* pViewFrame = getViewFrame();
@@ -2667,9 +2676,10 @@ IMPL_LINK_NOARG(SlideshowImpl, deactivateHdl)
 
         if( ANIMATIONMODE_SHOW == meAnimationMode )
         {
+#ifdef AUTORECOVERY_ON
             if( mbAutoSaveWasOn )
                 setAutoSaveState( true );
-
+#endif
             if( mpShowWindow )
             {
                 showChildWindows();
@@ -2737,6 +2747,7 @@ void SlideshowImpl::receiveRequest(SfxRequest& rReq)
     }
 }
 
+#ifdef AUTORECOVERY_ON
 void SlideshowImpl::setAutoSaveState( bool bOn)
 {
     try
@@ -2760,6 +2771,7 @@ void SlideshowImpl::setAutoSaveState( bool bOn)
         OSL_FAIL("sd::SlideshowImpl::setAutoSaveState(), exception caught!");
     }
 }
+#endif
 
 Reference< XDrawPage > SAL_CALL SlideshowImpl::getCurrentSlide() throw (RuntimeException, std::exception)
 {
diff --git a/sd/source/ui/slideshow/slideshowimpl.hxx b/sd/source/ui/slideshow/slideshowimpl.hxx
index 7514fdf..d21efb7 100644
--- a/sd/source/ui/slideshow/slideshowimpl.hxx
+++ b/sd/source/ui/slideshow/slideshowimpl.hxx
@@ -313,7 +313,10 @@ private:
 
     css::uno::Reference< css::presentation::XSlideShow > createSlideShow() const;
 
+#ifdef AUTORECOVERY_ON
     void setAutoSaveState( bool bOn );
+#endif
+
     void gotoPreviousSlide (const bool bSkipAllMainSequenceEffects);
 
     /** Called by PostYieldListener and updateHdl handlers this method is
@@ -361,7 +364,9 @@ private:
     bool            mbSlideBorderVisible;
     bool            mbSetOnlineSpelling;
     bool            mbDisposed;
+#ifdef AUTORECOVERY_ON
     bool            mbAutoSaveWasOn;
+#endif
     bool            mbRehearseTimings;
     bool            mbDesignMode;
     bool            mbIsPaused;
diff --git a/svx/Library_svx.mk b/svx/Library_svx.mk
index ccea64f..5bba891 100644
--- a/svx/Library_svx.mk
+++ b/svx/Library_svx.mk
@@ -36,6 +36,7 @@ $(eval $(call gb_Library_use_custom_headers,svx,\
 $(eval $(call gb_Library_add_defs,svx,\
     -DSVX_DLLIMPLEMENTATION \
     -DBOOST_SPIRIT_USE_OLD_NAMESPACE \
+    $(if $(filter TRUE,$(ENABLE_AUTORECOVERY)),-DAUTORECOVERY_ON) \
 ))
 
 $(eval $(call gb_Library_set_precompiled_header,svx,$(SRCDIR)/svx/inc/pch/precompiled_svx))
@@ -113,7 +114,7 @@ $(eval $(call gb_Library_add_exception_objects,svx,\
     svx/source/dialog/dialcontrol \
     svx/source/dialog/dlgctl3d \
     svx/source/dialog/dlgctrl \
-    svx/source/dialog/docrecovery \
+    $(call gb_Helper_optional,ENABLE_AUTORECOVERY,svx/source/dialog/docrecovery) \
     svx/source/dialog/fntctrl \
     svx/source/dialog/fontlb \
     svx/source/dialog/fontwork \
@@ -238,7 +239,7 @@ $(eval $(call gb_Library_add_exception_objects,svx,\
     svx/source/tbxctrls/tbxcolor \
     svx/source/tbxctrls/tbxdrctl \
     svx/source/tbxctrls/verttexttbxctrl \
-    svx/source/unodraw/recoveryui \
+    $(call gb_Helper_optional,ENABLE_AUTORECOVERY,svx/source/unodraw/recoveryui) \
     svx/source/unodraw/unoctabl \
     svx/source/unodraw/UnoNamespaceMap \
     svx/source/unodraw/unopool \
diff --git a/svx/UIConfig_svx.mk b/svx/UIConfig_svx.mk
index 76e7f12..3a86a5d 100644
--- a/svx/UIConfig_svx.mk
+++ b/svx/UIConfig_svx.mk
@@ -24,10 +24,10 @@ $(eval $(call gb_UIConfig_add_uifiles,svx,\
 	svx/uiconfig/ui/datanavigator \
 	svx/uiconfig/ui/deleteheaderdialog \
 	svx/uiconfig/ui/deletefooterdialog \
-	svx/uiconfig/ui/docrecoverybrokendialog \
-	svx/uiconfig/ui/docrecoveryprogressdialog \
-	svx/uiconfig/ui/docrecoveryrecoverdialog \
-	svx/uiconfig/ui/docrecoverysavedialog \
+	$(call gb_Helper_optional,ENABLE_AUTORECOVERY,svx/uiconfig/ui/docrecoverybrokendialog) \
+	$(call gb_Helper_optional,ENABLE_AUTORECOVERY,svx/uiconfig/ui/docrecoveryprogressdialog) \
+	$(call gb_Helper_optional,ENABLE_AUTORECOVERY,svx/uiconfig/ui/docrecoveryrecoverdialog) \
+	$(call gb_Helper_optional,ENABLE_AUTORECOVERY,svx/uiconfig/ui/docrecoverysavedialog) \
 	svx/uiconfig/ui/extrustiondepthdialog \
 	svx/uiconfig/ui/findreplacedialog \
 	svx/uiconfig/ui/fontworkgallerydialog \
diff --git a/svx/source/dialog/docrecovery.cxx b/svx/source/dialog/docrecovery.cxx
index be7e9da..fea5995 100644
--- a/svx/source/dialog/docrecovery.cxx
+++ b/svx/source/dialog/docrecovery.cxx
@@ -17,6 +17,8 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#ifdef AUTORECOVERY_ON
+
 #include <config_folders.h>
 
 #include <sal/macros.h>
@@ -1326,4 +1328,6 @@ void BrokenRecoveryDialog::impl_askForSavePath()
     }   // namespace DocRecovery
 }   // namespace svx
 
+#endif
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
