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

Julien Nabet serval2412 at yahoo.fr
Wed Jul 31 06:28:50 PDT 2013


 sfx2/source/dialog/templdlg.cxx |    1 
 sfx2/source/view/viewfrm.cxx    |   78 +++++++++++++++-------------------------
 2 files changed, 30 insertions(+), 49 deletions(-)

New commits:
commit 78c5a2ce8c2d4967d954fceaf9b7707ec56a3d7b
Author: Julien Nabet <serval2412 at yahoo.fr>
Date:   Fri Jul 26 23:28:59 2013 +0200

    fdo#46037: no more comphelper/configurationhelper in sfx2/view
    
    Change-Id: Iba139247f3515c834d8abcfd4322964dbc3abca4
    Reviewed-on: https://gerrit.libreoffice.org/5134
    Reviewed-by: Luboš Luňák <l.lunak at suse.cz>
    Tested-by: Luboš Luňák <l.lunak at suse.cz>

diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index 73c9f87..203f200 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -62,7 +62,6 @@
 #include "appdata.hxx"
 #include <sfx2/viewfrm.hxx>
 
-#include <comphelper/configurationhelper.hxx>
 #include <comphelper/string.hxx>
 
 using namespace ::com::sun::star;
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index d027b7d..0a9b205 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -94,7 +94,7 @@
 
 #include <comphelper/processfactory.hxx>
 #include <comphelper/configuration.hxx>
-#include "officecfg/Office/Common.hxx"
+#include <officecfg/Office/Common.hxx>
 
 #include <boost/optional.hpp>
 
@@ -2330,62 +2330,44 @@ void SfxViewFrame::ExecView_Impl
 */
 sal_Bool impl_maxOpenDocCountReached()
 {
-    try
-    {
-        css::uno::Reference< css::uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
-        css::uno::Any aVal = ::comphelper::ConfigurationHelper::readDirectKey(
-                                xContext,
-                                OUString("org.openoffice.Office.Common/"),
-                                OUString("Misc"),
-                                OUString("MaxOpenDocuments"),
-                                ::comphelper::ConfigurationHelper::E_READONLY);
-
-        // NIL means: count of allowed documents = infinite !
-        if ( ! aVal.hasValue())
-            return sal_False;
-
-        sal_Int32 nOpenDocs = 0;
-        sal_Int32 nMaxDocs  = 0;
-        aVal >>= nMaxDocs;
+    css::uno::Reference< css::uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
+    boost::optional<sal_Int32> x(officecfg::Office::Common::Misc::MaxOpenDocuments::get(xContext));
+    // NIL means: count of allowed documents = infinite !
+    if (!x)
+        return sal_False;
+    sal_Int32 nMaxDocs(x.get());
+    sal_Int32 nOpenDocs = 0;
 
-        css::uno::Reference< css::frame::XDesktop2 >  xDesktop = css::frame::Desktop::create(xContext);
-        css::uno::Reference< css::container::XIndexAccess > xCont   (xDesktop->getFrames()                 , css::uno::UNO_QUERY_THROW);
+    css::uno::Reference< css::frame::XDesktop2 >  xDesktop = css::frame::Desktop::create(xContext);
+    css::uno::Reference< css::container::XIndexAccess > xCont(xDesktop->getFrames(), css::uno::UNO_QUERY_THROW);
 
-        sal_Int32 c = xCont->getCount();
-        sal_Int32 i = 0;
+    sal_Int32 c = xCont->getCount();
+    sal_Int32 i = 0;
 
-        for (i=0; i<c; ++i)
+    for (i=0; i<c; ++i)
+    {
+        try
         {
-            try
-            {
-                css::uno::Reference< css::frame::XFrame > xFrame;
-                xCont->getByIndex(i) >>= xFrame;
-                if ( ! xFrame.is())
-                    continue;
+            css::uno::Reference< css::frame::XFrame > xFrame;
+            xCont->getByIndex(i) >>= xFrame;
+            if ( ! xFrame.is())
+                continue;
 
-                // a) do not count the help window
-                if ( xFrame->getName() == "OFFICE_HELP_TASK" )
-                    continue;
+            // a) do not count the help window
+            if ( xFrame->getName() == "OFFICE_HELP_TASK" )
+                continue;
 
-                // b) count all other frames
-                ++nOpenDocs;
-            }
-            catch(const css::uno::Exception&)
-                // A IndexOutOfBoundException can happen in multithreaded
-                // environments, where any other thread can change this
-                // container !
-                { continue; }
+            // b) count all other frames
+            ++nOpenDocs;
         }
-
-        return (nOpenDocs >= nMaxDocs);
+        catch(const css::uno::Exception&)
+            // A IndexOutOfBoundException can happen in multithreaded
+            // environments, where any other thread can change this
+            // container !
+            { continue; }
     }
-    catch(const css::uno::Exception&)
-        {}
 
-    // Any internal error is no reason to stop opening documents !
-    // Limitation of opening documents is a special "nice to  have" feature.
-    // Otherwhise it can happen, that NO document will be opened ...
-    return sal_False;
+    return (nOpenDocs >= nMaxDocs);
 }
 
 //-------------------------------------------------------------------------


More information about the Libreoffice-commits mailing list