diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2013-07-26 23:28:59 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@suse.cz> | 2013-07-31 13:28:29 +0000 |
commit | 78c5a2ce8c2d4967d954fceaf9b7707ec56a3d7b (patch) | |
tree | d9e476ed1b0fe6f6e17a0a940db4d1f6fa16c90f /sfx2 | |
parent | a8c403a1f8298cede274f315e367f799d4fb0f32 (diff) |
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@suse.cz>
Tested-by: Luboš Luňák <l.lunak@suse.cz>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/dialog/templdlg.cxx | 1 | ||||
-rw-r--r-- | sfx2/source/view/viewfrm.cxx | 78 |
2 files changed, 30 insertions, 49 deletions
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx index 73c9f8705b5e..203f2006b74a 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 d027b7d8b311..0a9b20520d3a 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); } //------------------------------------------------------------------------- |