[Libreoffice-commits] core.git: sfx2/source

Julien Nabet serval2412 at yahoo.fr
Fri Jul 26 13:10:54 PDT 2013


 sfx2/source/doc/docfile.cxx   |   47 +-------------------------------------
 sfx2/source/doc/guisaveas.cxx |   51 ++++++++++++------------------------------
 sfx2/source/doc/objmisc.cxx   |    1 
 sfx2/source/doc/objstor.cxx   |    1 
 4 files changed, 17 insertions(+), 83 deletions(-)

New commits:
commit c02b3f8517e159c462a288d82e3b62cc4b2ab682
Author: Julien Nabet <serval2412 at yahoo.fr>
Date:   Fri Jul 26 22:10:15 2013 +0200

    fdo#46037: less occurrences of comphelper/configurationhelper in sfx2/doc
    
    Change-Id: Id1416ae6c1efaa251a979ac67e90b5261f64bd9a

diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index ef2f85e..8a93ef2 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -88,7 +88,6 @@
 
 #include <comphelper/storagehelper.hxx>
 #include <comphelper/mediadescriptor.hxx>
-#include <comphelper/configurationhelper.hxx>
 #include <comphelper/docpasswordhelper.hxx>
 #include <tools/inetmime.hxx>
 #include <unotools/ucblockbytes.hxx>
@@ -141,55 +140,13 @@ static const sal_Int8 LOCK_UI_TRY = 2;
 
 bool IsSystemFileLockingUsed()
 {
-    // check whether system file locking has been used, the default value is false
-    bool bUseSystemLock = false;
-    try
-    {
-
-        uno::Reference< uno::XInterface > xCommonConfig = ::comphelper::ConfigurationHelper::openConfig(
-                            ::comphelper::getProcessComponentContext(),
-                            OUString( "/org.openoffice.Office.Common"  ),
-                            ::comphelper::ConfigurationHelper::E_STANDARD );
-        if ( !xCommonConfig.is() )
-            throw uno::RuntimeException();
-
-        ::comphelper::ConfigurationHelper::readRelativeKey(
-                xCommonConfig,
-                OUString( "Misc/"  ),
-                OUString( "UseDocumentSystemFileLocking"  ) ) >>= bUseSystemLock;
-    }
-    catch( const uno::Exception& )
-    {
-    }
-
-    return bUseSystemLock;
+    return officecfg::Office::Common::Misc::UseDocumentSystemFileLocking::get();
 }
 
 //----------------------------------------------------------------
 bool IsOOoLockFileUsed()
 {
-    // check whether system file locking has been used, the default value is false
-    bool bOOoLockFileUsed = false;
-    try
-    {
-
-        uno::Reference< uno::XInterface > xCommonConfig = ::comphelper::ConfigurationHelper::openConfig(
-                            ::comphelper::getProcessComponentContext(),
-                            OUString( "/org.openoffice.Office.Common"  ),
-                            ::comphelper::ConfigurationHelper::E_STANDARD );
-        if ( !xCommonConfig.is() )
-            throw uno::RuntimeException();
-
-        ::comphelper::ConfigurationHelper::readRelativeKey(
-                xCommonConfig,
-                OUString( "Misc/"  ),
-                OUString( "UseDocumentOOoLockFile"  ) ) >>= bOOoLockFileUsed;
-    }
-    catch( const uno::Exception& )
-    {
-    }
-
-    return bOOoLockFileUsed;
+    return officecfg::Office::Common::Misc::UseDocumentOOoLockFile::get();
 }
 
 bool IsLockingUsed()
diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx
index dcb233a..5afd2c1 100644
--- a/sfx2/source/doc/guisaveas.cxx
+++ b/sfx2/source/doc/guisaveas.cxx
@@ -61,7 +61,6 @@
 #include <tools/debug.hxx>
 #include <tools/urlobj.hxx>
 #include <comphelper/processfactory.hxx>
-#include <comphelper/configurationhelper.hxx>
 #include <comphelper/mimeconfighelper.hxx>
 #include <vcl/msgbox.hxx>
 #include <vcl/window.hxx>
@@ -91,6 +90,8 @@
 
 #include <com/sun/star/frame/Desktop.hpp>
 
+#include <officecfg/Office/Common.hxx>
+
 // flags that specify requested operation
 #define EXPORT_REQUESTED            1
 #define PDFEXPORT_REQUESTED         2
@@ -646,42 +647,20 @@ sal_Int8 ModelData_Impl::CheckSaveAcceptable( sal_Int8 nCurStatus )
 
     if ( nResult != STATUS_NO_ACTION && GetStorable()->hasLocation() )
     {
-        // check whether save is acceptable by the configuration
-        // it is done only for documents that have persistence already
-        uno::Reference< uno::XInterface > xCommonConfig = ::comphelper::ConfigurationHelper::openConfig(
-                            comphelper::getProcessComponentContext(),
-                            OUString( "/org.openoffice.Office.Common" ),
-                            ::comphelper::ConfigurationHelper::E_STANDARD );
-        if ( !xCommonConfig.is() )
-            throw uno::RuntimeException(); // should the saving proceed as usual instead?
-
-        try
-        {
-            sal_Bool bAlwaysSaveAs = sal_False;
-
-            // the saving is acceptable
-            // in case the configuration entry is not set or set to false
-            // or in case of version creation
-            OUString aVersionCommentString = OUString("VersionComment");
-            if ( ( ::comphelper::ConfigurationHelper::readRelativeKey(
-                    xCommonConfig,
-                    OUString( "Save/Document/" ),
-                    OUString( "AlwaysSaveAs" ) ) >>= bAlwaysSaveAs )
-              && bAlwaysSaveAs
-            && GetMediaDescr().find( aVersionCommentString ) == GetMediaDescr().end() )
-            {
-                // notify the user that SaveAs is going to be done
-                Window* pWin = SfxStoringHelper::GetModelWindow( m_xModel );
-                QueryBox aMessageBox( pWin, WB_OK_CANCEL | WB_DEF_OK, SfxResId(STR_NEW_FILENAME_SAVE).toString() );
-                if ( aMessageBox.Execute() == RET_OK )
-                    nResult = STATUS_SAVEAS;
-                else
-                    nResult = STATUS_NO_ACTION;
-            }
-        }
-        catch( const uno::Exception& )
+        // the saving is acceptable
+        // in case the configuration entry is not set or set to false
+        // or in case of version creation
+        OUString aVersionCommentString = OUString("VersionComment");
+        if ( officecfg::Office::Common::Save::Document::AlwaysSaveAs::get()
+          && GetMediaDescr().find( aVersionCommentString ) == GetMediaDescr().end() )
         {
-            // impossibility to get the configuration access means normal saving flow for now
+            // notify the user that SaveAs is going to be done
+            Window* pWin = SfxStoringHelper::GetModelWindow( m_xModel );
+            QueryBox aMessageBox( pWin, WB_OK_CANCEL | WB_DEF_OK, SfxResId(STR_NEW_FILENAME_SAVE).toString() );
+            if ( aMessageBox.Execute() == RET_OK )
+                nResult = STATUS_SAVEAS;
+            else
+                nResult = STATUS_NO_ACTION;
         }
     }
 
diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx
index 71b6763..efc3efe 100644
--- a/sfx2/source/doc/objmisc.cxx
+++ b/sfx2/source/doc/objmisc.cxx
@@ -63,7 +63,6 @@
 #include <com/sun/star/task/ErrorCodeRequest.hpp>
 #include <unotools/securityoptions.hxx>
 
-#include <comphelper/configurationhelper.hxx>
 #include <comphelper/processfactory.hxx>
 #include <comphelper/string.hxx>
 
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index d878cb8..aadb1a9 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -72,7 +72,6 @@
 #include <com/sun/star/document/XDocumentProperties.hpp>
 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
 #include <comphelper/processfactory.hxx>
-#include <comphelper/configurationhelper.hxx>
 #include <comphelper/interaction.hxx>
 #include <svtools/sfxecode.hxx>
 #include <unotools/securityoptions.hxx>


More information about the Libreoffice-commits mailing list