Hi *, On Mon, Jan 23, 2012 at 10:59:28AM +0100, Andre Fischer wrote: > In the future, I may have to do more to disable coinmp: disable > building the solver. At the moment the solver dialog still opens > but does not do much.
Currently, ".uno:SolverDialog" is allways enabled. A solution is to disable SID_OPENDLG_OPTSOLVER in ScCellShell::GetState if there are no Solver components installed. See attached patch, which I only tested on Linux. I'll open an issue for this task. Regards -- Ariel Constenla-Haile La Plata, Argentina
From 7693c71c901a5e76a8c1cb2e3b2fb27aa669fc20 Mon Sep 17 00:00:00 2001 From: Ariel Constenla-Haile <[email protected]> Date: Wed, 25 Jan 2012 12:19:03 -0300 Subject: [PATCH] Disable Tools - Solver when there are no Solver Components --- sc/inc/solverutil.hxx | 49 +++++++ sc/source/core/tool/makefile.mk | 6 +- sc/source/core/tool/solverutil.cxx | 239 +++++++++++++++++++++++++++++++ sc/source/ui/inc/solverutil.hxx | 46 ------ sc/source/ui/miscdlgs/makefile.mk | 3 - sc/source/ui/miscdlgs/optsolver.cxx | 2 +- sc/source/ui/miscdlgs/solveroptions.cxx | 2 +- sc/source/ui/miscdlgs/solverutil.cxx | 225 ----------------------------- sc/source/ui/view/cellsh.cxx | 22 +++ 9 files changed, 316 insertions(+), 278 deletions(-) create mode 100644 sc/inc/solverutil.hxx create mode 100644 sc/source/core/tool/solverutil.cxx delete mode 100644 sc/source/ui/inc/solverutil.hxx delete mode 100644 sc/source/ui/miscdlgs/solverutil.cxx diff --git a/sc/inc/solverutil.hxx b/sc/inc/solverutil.hxx new file mode 100644 index 0000000..cfe3903 --- /dev/null +++ b/sc/inc/solverutil.hxx @@ -0,0 +1,49 @@ +/************************************************************** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + *************************************************************/ + + + +#ifndef SC_SOLVERUTIL_HXX +#define SC_SOLVERUTIL_HXX + +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/uno/Sequence.hxx> + +#include "scdllapi.h" + +namespace com { namespace sun { namespace star { + namespace beans { struct PropertyValue; } + namespace sheet { class XSolver; } +} } } + + +class ScSolverUtil +{ +public: + static SC_DLLPUBLIC bool HasImplementations(); + static SC_DLLPUBLIC void GetImplementations( com::sun::star::uno::Sequence<rtl::OUString>& rImplNames, + com::sun::star::uno::Sequence<rtl::OUString>& rDescriptions ); + static SC_DLLPUBLIC com::sun::star::uno::Reference<com::sun::star::sheet::XSolver> GetSolver( const rtl::OUString& rImplName ); + static SC_DLLPUBLIC com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> GetDefaults( const rtl::OUString& rImplName ); +}; + +#endif + diff --git a/sc/source/core/tool/makefile.mk b/sc/source/core/tool/makefile.mk index 1d3b40c..2daef64 100644 --- a/sc/source/core/tool/makefile.mk +++ b/sc/source/core/tool/makefile.mk @@ -106,7 +106,8 @@ SLOFILES = \ $(SLO)$/unitconv.obj \ $(SLO)$/userlist.obj \ $(SLO)$/viewopti.obj \ - $(SLO)$/zforauto.obj + $(SLO)$/zforauto.obj \ + $(SLO)$/solverutil.obj EXCEPTIONSFILES= \ $(SLO)$/addincol.obj \ @@ -129,7 +130,8 @@ EXCEPTIONSFILES= \ $(SLO)$/queryparam.obj \ $(SLO)$/reftokenhelper.obj \ $(SLO)$/stringutil.obj \ - $(SLO)$/token.obj + $(SLO)$/token.obj \ + $(SLO)$/solverutil.obj # [kh] POWERPC compiler problem .IF "$(OS)$(COM)$(CPUNAME)"=="LINUXGCCPOWERPC" diff --git a/sc/source/core/tool/solverutil.cxx b/sc/source/core/tool/solverutil.cxx new file mode 100644 index 0000000..7609e4f --- /dev/null +++ b/sc/source/core/tool/solverutil.cxx @@ -0,0 +1,239 @@ +/************************************************************** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + *************************************************************/ + + + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sc.hxx" + +//------------------------------------------------------------------ + +#include "solverutil.hxx" + +#include <com/sun/star/container/XContentEnumerationAccess.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XSingleComponentFactory.hpp> +#include <com/sun/star/lang/XSingleServiceFactory.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/sheet/XSolver.hpp> +#include <com/sun/star/sheet/XSolverDescription.hpp> + +#include <comphelper/processfactory.hxx> + +using namespace com::sun::star; + +//------------------------------------------------------------------ + +#define SCSOLVER_SERVICE "com.sun.star.sheet.Solver" + +uno::Reference<sheet::XSolver> lcl_CreateSolver( const uno::Reference<uno::XInterface>& xIntFac, + const uno::Reference<uno::XComponentContext>& xCtx ) +{ + uno::Reference<sheet::XSolver> xSolver; + + uno::Reference<lang::XSingleComponentFactory> xCFac( xIntFac, uno::UNO_QUERY ); + uno::Reference<lang::XSingleServiceFactory> xFac( xIntFac, uno::UNO_QUERY ); + if ( xCFac.is() ) + { + try + { + uno::Reference<uno::XInterface> xInterface = xCFac->createInstanceWithContext(xCtx); + xSolver = uno::Reference<sheet::XSolver>( xInterface, uno::UNO_QUERY ); + } + catch(uno::Exception&) + { + } + } + if ( !xSolver.is() && xFac.is() ) + { + try + { + uno::Reference<uno::XInterface> xInterface = xFac->createInstance(); + xSolver = uno::Reference<sheet::XSolver>( xInterface, uno::UNO_QUERY ); + } + catch(uno::Exception&) + { + } + } + + return xSolver; +} + + +// static +bool ScSolverUtil::HasImplementations() +{ + uno::Sequence<rtl::OUString> aImplNames; + uno::Sequence<rtl::OUString> aDescriptions; + GetImplementations( aImplNames, aDescriptions ); + + return aImplNames.getLength(); +} + +// static +void ScSolverUtil::GetImplementations( uno::Sequence<rtl::OUString>& rImplNames, + uno::Sequence<rtl::OUString>& rDescriptions ) +{ + rImplNames.realloc(0); // clear + rDescriptions.realloc(0); + sal_Int32 nCount = 0; + + uno::Reference<uno::XComponentContext> xCtx; + uno::Reference<lang::XMultiServiceFactory> xMSF = comphelper::getProcessServiceFactory(); + uno::Reference<beans::XPropertySet> xPropset(xMSF, uno::UNO_QUERY); + try + { + xPropset->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext"))) >>= xCtx; + } + catch ( uno::Exception & ) + { + } + + uno::Reference<container::XContentEnumerationAccess> xEnAc( xMSF, uno::UNO_QUERY ); + if ( xCtx.is() && xEnAc.is() ) + { + uno::Reference<container::XEnumeration> xEnum = + xEnAc->createContentEnumeration( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SCSOLVER_SERVICE )) ); + if ( xEnum.is() ) + { + while ( xEnum->hasMoreElements() ) + { + uno::Any aAny = xEnum->nextElement(); + uno::Reference<uno::XInterface> xIntFac; + aAny >>= xIntFac; + if ( xIntFac.is() ) + { + uno::Reference<lang::XServiceInfo> xInfo( xIntFac, uno::UNO_QUERY ); + if ( xInfo.is() ) + { + rtl::OUString sName = xInfo->getImplementationName(); + rtl::OUString sDescription; + + uno::Reference<sheet::XSolver> xSolver = lcl_CreateSolver( xIntFac, xCtx ); + if ( xSolver.is() ) + { + uno::Reference<sheet::XSolverDescription> xDesc( xSolver, uno::UNO_QUERY ); + if ( xDesc.is() ) + sDescription = xDesc->getComponentDescription(); + + if ( !sDescription.getLength() ) + sDescription = sName; // use implementation name if no description available + + rImplNames.realloc( nCount+1 ); + rImplNames[nCount] = sName; + rDescriptions.realloc( nCount+1 ); + rDescriptions[nCount] = sDescription; + ++nCount; + } + } + } + } + } + } +} + +// static +uno::Reference<sheet::XSolver> ScSolverUtil::GetSolver( const rtl::OUString& rImplName ) +{ + uno::Reference<sheet::XSolver> xSolver; + + uno::Reference<uno::XComponentContext> xCtx; + uno::Reference<lang::XMultiServiceFactory> xMSF = comphelper::getProcessServiceFactory(); + uno::Reference<beans::XPropertySet> xPropset(xMSF, uno::UNO_QUERY); + try + { + xPropset->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext"))) >>= xCtx; + } + catch ( uno::Exception & ) + { + } + + uno::Reference<container::XContentEnumerationAccess> xEnAc( xMSF, uno::UNO_QUERY ); + if ( xCtx.is() && xEnAc.is() ) + { + uno::Reference<container::XEnumeration> xEnum = + xEnAc->createContentEnumeration( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SCSOLVER_SERVICE )) ); + if ( xEnum.is() ) + { + while ( xEnum->hasMoreElements() && !xSolver.is() ) + { + uno::Any aAny = xEnum->nextElement(); + uno::Reference<uno::XInterface> xIntFac; + aAny >>= xIntFac; + if ( xIntFac.is() ) + { + uno::Reference<lang::XServiceInfo> xInfo( xIntFac, uno::UNO_QUERY ); + if ( xInfo.is() ) + { + rtl::OUString sName = xInfo->getImplementationName(); + if ( sName == rImplName ) + xSolver = lcl_CreateSolver( xIntFac, xCtx ); + } + } + } + } + } + + OSL_ENSURE( xSolver.is(), "can't get solver" ); + return xSolver; +} + +// static +uno::Sequence<beans::PropertyValue> ScSolverUtil::GetDefaults( const rtl::OUString& rImplName ) +{ + uno::Sequence<beans::PropertyValue> aDefaults; + + uno::Reference<sheet::XSolver> xSolver = GetSolver( rImplName ); + uno::Reference<beans::XPropertySet> xPropSet( xSolver, uno::UNO_QUERY ); + if ( !xPropSet.is() ) + { + // no XPropertySet - no options + return aDefaults; + } + + // fill maProperties + + uno::Reference<beans::XPropertySetInfo> xInfo = xPropSet->getPropertySetInfo(); + OSL_ENSURE( xInfo.is(), "can't get property set info" ); + if ( !xInfo.is() ) + return aDefaults; + + uno::Sequence<beans::Property> aPropSeq = xInfo->getProperties(); + const sal_Int32 nSize = aPropSeq.getLength(); + aDefaults.realloc(nSize); + sal_Int32 nValid = 0; + for (sal_Int32 nPos=0; nPos<nSize; ++nPos) + { + const beans::Property& rProp = aPropSeq[nPos]; + uno::Any aValue = xPropSet->getPropertyValue( rProp.Name ); + uno::TypeClass eClass = aValue.getValueTypeClass(); + // only use properties of supported types + if ( eClass == uno::TypeClass_BOOLEAN || eClass == uno::TypeClass_LONG || eClass == uno::TypeClass_DOUBLE ) + aDefaults[nValid++] = beans::PropertyValue( rProp.Name, -1, aValue, beans::PropertyState_DIRECT_VALUE ); + } + aDefaults.realloc(nValid); + + //! get user-visible names, sort by them + + return aDefaults; +} + diff --git a/sc/source/ui/inc/solverutil.hxx b/sc/source/ui/inc/solverutil.hxx deleted file mode 100644 index 610d1d6..0000000 --- a/sc/source/ui/inc/solverutil.hxx +++ /dev/null @@ -1,46 +0,0 @@ -/************************************************************** - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - *************************************************************/ - - - -#ifndef SC_SOLVERUTIL_HXX -#define SC_SOLVERUTIL_HXX - -#include <com/sun/star/uno/Reference.hxx> -#include <com/sun/star/uno/Sequence.hxx> - -namespace com { namespace sun { namespace star { - namespace beans { struct PropertyValue; } - namespace sheet { class XSolver; } -} } } - - -class ScSolverUtil -{ -public: - static void GetImplementations( com::sun::star::uno::Sequence<rtl::OUString>& rImplNames, - com::sun::star::uno::Sequence<rtl::OUString>& rDescriptions ); - static com::sun::star::uno::Reference<com::sun::star::sheet::XSolver> GetSolver( const rtl::OUString& rImplName ); - static com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> GetDefaults( const rtl::OUString& rImplName ); -}; - -#endif - diff --git a/sc/source/ui/miscdlgs/makefile.mk b/sc/source/ui/miscdlgs/makefile.mk index 0219a08..5b654b6 100644 --- a/sc/source/ui/miscdlgs/makefile.mk +++ b/sc/source/ui/miscdlgs/makefile.mk @@ -50,7 +50,6 @@ SLOFILES = \ $(SLO)$/solvrdlg.obj \ $(SLO)$/optsolver.obj \ $(SLO)$/solveroptions.obj \ - $(SLO)$/solverutil.obj \ $(SLO)$/mvtabdlg.obj \ $(SLO)$/groupdlg.obj \ $(SLO)$/tabopdlg.obj \ @@ -81,7 +80,6 @@ EXCEPTIONSFILES = \ $(SLO)$/optsolver.obj \ $(SLO)$/solveroptions.obj \ $(SLO)$/crnrdlg.obj \ - $(SLO)$/solverutil.obj \ $(SLO)$/protectiondlg.obj \ $(SLO)$/retypepassdlg.obj @@ -103,7 +101,6 @@ LIB1OBJFILES = \ $(SLO)$/solvrdlg.obj \ $(SLO)$/optsolver.obj \ $(SLO)$/solveroptions.obj \ - $(SLO)$/solverutil.obj \ $(SLO)$/tabopdlg.obj \ $(SLO)$/anyrefdg.obj \ $(SLO)$/crnrdlg.obj \ diff --git a/sc/source/ui/miscdlgs/optsolver.cxx b/sc/source/ui/miscdlgs/optsolver.cxx index 7a11c09..432d3aa 100644 --- a/sc/source/ui/miscdlgs/optsolver.cxx +++ b/sc/source/ui/miscdlgs/optsolver.cxx @@ -44,7 +44,7 @@ #include "convuno.hxx" #include "unonames.hxx" #include "solveroptions.hxx" -#include "solverutil.hxx" +#include <solverutil.hxx> #include "optsolver.hrc" #include "optsolver.hxx" diff --git a/sc/source/ui/miscdlgs/solveroptions.cxx b/sc/source/ui/miscdlgs/solveroptions.cxx index a61732f..1d30982 100644 --- a/sc/source/ui/miscdlgs/solveroptions.cxx +++ b/sc/source/ui/miscdlgs/solveroptions.cxx @@ -31,7 +31,7 @@ #include "scresid.hxx" #include "global.hxx" #include "miscuno.hxx" -#include "solverutil.hxx" +#include <solverutil.hxx> #include <rtl/math.hxx> #include <vcl/msgbox.hxx> diff --git a/sc/source/ui/miscdlgs/solverutil.cxx b/sc/source/ui/miscdlgs/solverutil.cxx deleted file mode 100644 index abd3599..0000000 --- a/sc/source/ui/miscdlgs/solverutil.cxx +++ /dev/null @@ -1,225 +0,0 @@ -/************************************************************** - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - *************************************************************/ - - - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sc.hxx" - -//------------------------------------------------------------------ - -#include "solverutil.hxx" - -#include <com/sun/star/container/XContentEnumerationAccess.hpp> -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/lang/XSingleComponentFactory.hpp> -#include <com/sun/star/lang/XSingleServiceFactory.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/beans/PropertyValue.hpp> -#include <com/sun/star/sheet/XSolver.hpp> -#include <com/sun/star/sheet/XSolverDescription.hpp> - -#include <comphelper/processfactory.hxx> - -using namespace com::sun::star; - -//------------------------------------------------------------------ - -#define SCSOLVER_SERVICE "com.sun.star.sheet.Solver" - -uno::Reference<sheet::XSolver> lcl_CreateSolver( const uno::Reference<uno::XInterface>& xIntFac, - const uno::Reference<uno::XComponentContext>& xCtx ) -{ - uno::Reference<sheet::XSolver> xSolver; - - uno::Reference<lang::XSingleComponentFactory> xCFac( xIntFac, uno::UNO_QUERY ); - uno::Reference<lang::XSingleServiceFactory> xFac( xIntFac, uno::UNO_QUERY ); - if ( xCFac.is() ) - { - try - { - uno::Reference<uno::XInterface> xInterface = xCFac->createInstanceWithContext(xCtx); - xSolver = uno::Reference<sheet::XSolver>( xInterface, uno::UNO_QUERY ); - } - catch(uno::Exception&) - { - } - } - if ( !xSolver.is() && xFac.is() ) - { - try - { - uno::Reference<uno::XInterface> xInterface = xFac->createInstance(); - xSolver = uno::Reference<sheet::XSolver>( xInterface, uno::UNO_QUERY ); - } - catch(uno::Exception&) - { - } - } - - return xSolver; -} - -// static -void ScSolverUtil::GetImplementations( uno::Sequence<rtl::OUString>& rImplNames, - uno::Sequence<rtl::OUString>& rDescriptions ) -{ - rImplNames.realloc(0); // clear - rDescriptions.realloc(0); - sal_Int32 nCount = 0; - - uno::Reference<uno::XComponentContext> xCtx; - uno::Reference<lang::XMultiServiceFactory> xMSF = comphelper::getProcessServiceFactory(); - uno::Reference<beans::XPropertySet> xPropset(xMSF, uno::UNO_QUERY); - try - { - xPropset->getPropertyValue(rtl::OUString::createFromAscii("DefaultContext")) >>= xCtx; - } - catch ( uno::Exception & ) - { - } - - uno::Reference<container::XContentEnumerationAccess> xEnAc( xMSF, uno::UNO_QUERY ); - if ( xCtx.is() && xEnAc.is() ) - { - uno::Reference<container::XEnumeration> xEnum = - xEnAc->createContentEnumeration( rtl::OUString::createFromAscii(SCSOLVER_SERVICE) ); - if ( xEnum.is() ) - { - while ( xEnum->hasMoreElements() ) - { - uno::Any aAny = xEnum->nextElement(); - uno::Reference<uno::XInterface> xIntFac; - aAny >>= xIntFac; - if ( xIntFac.is() ) - { - uno::Reference<lang::XServiceInfo> xInfo( xIntFac, uno::UNO_QUERY ); - if ( xInfo.is() ) - { - rtl::OUString sName = xInfo->getImplementationName(); - rtl::OUString sDescription; - - uno::Reference<sheet::XSolver> xSolver = lcl_CreateSolver( xIntFac, xCtx ); - uno::Reference<sheet::XSolverDescription> xDesc( xSolver, uno::UNO_QUERY ); - if ( xDesc.is() ) - sDescription = xDesc->getComponentDescription(); - - if ( !sDescription.getLength() ) - sDescription = sName; // use implementation name if no description available - - rImplNames.realloc( nCount+1 ); - rImplNames[nCount] = sName; - rDescriptions.realloc( nCount+1 ); - rDescriptions[nCount] = sDescription; - ++nCount; - } - } - } - } - } -} - -// static -uno::Reference<sheet::XSolver> ScSolverUtil::GetSolver( const rtl::OUString& rImplName ) -{ - uno::Reference<sheet::XSolver> xSolver; - - uno::Reference<uno::XComponentContext> xCtx; - uno::Reference<lang::XMultiServiceFactory> xMSF = comphelper::getProcessServiceFactory(); - uno::Reference<beans::XPropertySet> xPropset(xMSF, uno::UNO_QUERY); - try - { - xPropset->getPropertyValue(rtl::OUString::createFromAscii("DefaultContext")) >>= xCtx; - } - catch ( uno::Exception & ) - { - } - - uno::Reference<container::XContentEnumerationAccess> xEnAc( xMSF, uno::UNO_QUERY ); - if ( xCtx.is() && xEnAc.is() ) - { - uno::Reference<container::XEnumeration> xEnum = - xEnAc->createContentEnumeration( rtl::OUString::createFromAscii(SCSOLVER_SERVICE) ); - if ( xEnum.is() ) - { - while ( xEnum->hasMoreElements() && !xSolver.is() ) - { - uno::Any aAny = xEnum->nextElement(); - uno::Reference<uno::XInterface> xIntFac; - aAny >>= xIntFac; - if ( xIntFac.is() ) - { - uno::Reference<lang::XServiceInfo> xInfo( xIntFac, uno::UNO_QUERY ); - if ( xInfo.is() ) - { - rtl::OUString sName = xInfo->getImplementationName(); - if ( sName == rImplName ) - xSolver = lcl_CreateSolver( xIntFac, xCtx ); - } - } - } - } - } - - OSL_ENSURE( xSolver.is(), "can't get solver" ); - return xSolver; -} - -// static -uno::Sequence<beans::PropertyValue> ScSolverUtil::GetDefaults( const rtl::OUString& rImplName ) -{ - uno::Sequence<beans::PropertyValue> aDefaults; - - uno::Reference<sheet::XSolver> xSolver = GetSolver( rImplName ); - uno::Reference<beans::XPropertySet> xPropSet( xSolver, uno::UNO_QUERY ); - if ( !xPropSet.is() ) - { - // no XPropertySet - no options - return aDefaults; - } - - // fill maProperties - - uno::Reference<beans::XPropertySetInfo> xInfo = xPropSet->getPropertySetInfo(); - OSL_ENSURE( xInfo.is(), "can't get property set info" ); - if ( !xInfo.is() ) - return aDefaults; - - uno::Sequence<beans::Property> aPropSeq = xInfo->getProperties(); - const sal_Int32 nSize = aPropSeq.getLength(); - aDefaults.realloc(nSize); - sal_Int32 nValid = 0; - for (sal_Int32 nPos=0; nPos<nSize; ++nPos) - { - const beans::Property& rProp = aPropSeq[nPos]; - uno::Any aValue = xPropSet->getPropertyValue( rProp.Name ); - uno::TypeClass eClass = aValue.getValueTypeClass(); - // only use properties of supported types - if ( eClass == uno::TypeClass_BOOLEAN || eClass == uno::TypeClass_LONG || eClass == uno::TypeClass_DOUBLE ) - aDefaults[nValid++] = beans::PropertyValue( rProp.Name, -1, aValue, beans::PropertyState_DIRECT_VALUE ); - } - aDefaults.realloc(nValid); - - //! get user-visible names, sort by them - - return aDefaults; -} - diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx index 4acc8d3..1ce310d 100644 --- a/sc/source/ui/view/cellsh.cxx +++ b/sc/source/ui/view/cellsh.cxx @@ -60,6 +60,7 @@ #include "scabstdlg.hxx" #include "dociter.hxx" #include "postit.hxx" +#include "solverutil.hxx" //------------------------------------------------------------------ @@ -987,6 +988,27 @@ void ScCellShell::GetState(SfxItemSet &rSet) } break; + case SID_OPENDLG_OPTSOLVER: + { + bool bHasSolver = ScSolverUtil::HasImplementations(); + if ( bHasSolver ) + { + SfxViewFrame* pViewFrame = ( pTabViewShell ? pTabViewShell->GetViewFrame() : NULL ); + if ( pViewFrame && pViewFrame->HasChildWindow( nWhich ) ) + { + SfxChildWindow* pChild = pViewFrame->GetChildWindow( nWhich ); + Window* pWin = ( pChild ? pChild->GetWindow() : NULL ); + if ( pWin && !pWin->IsVisible() ) + { + bHasSolver = false; + } + } + } + if ( !bHasSolver ) + rSet.DisableItem( nWhich ); + } + break; + } // switch ( nWitch ) nWhich = aIter.NextWhich(); } // while ( nWitch ) -- 1.7.7.6
pgp17UgCV6PmL.pgp
Description: PGP signature
