diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-01-28 16:24:09 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-01-29 07:11:04 +0100 |
commit | 98e60805613ab6ea19c03c34c0f36d00374dab73 (patch) | |
tree | fb8249445f7ccb3005b5942e7bb495b671033b8e | |
parent | 4cff06065ebfe884d8661b790db76f15203f2549 (diff) |
loplugin:flatten in stoc..store
Change-Id: Ib8c86179a3d13852cbb02b389b6103aca5456dba
Reviewed-on: https://gerrit.libreoffice.org/67013
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | stoc/source/corereflection/criface.cxx | 33 | ||||
-rw-r--r-- | stoc/source/defaultregistry/defaultregistry.cxx | 18 | ||||
-rw-r--r-- | stoc/source/implementationregistration/implreg.cxx | 492 | ||||
-rw-r--r-- | stoc/source/invocation/invocation.cxx | 28 | ||||
-rw-r--r-- | stoc/source/javavm/javavm.cxx | 196 | ||||
-rw-r--r-- | stoc/source/proxy_factory/proxyfac.cxx | 26 | ||||
-rw-r--r-- | stoc/source/security/access_controller.cxx | 94 | ||||
-rw-r--r-- | stoc/source/security/permissions.cxx | 102 | ||||
-rw-r--r-- | stoc/source/servicemanager/servicemanager.cxx | 54 | ||||
-rw-r--r-- | store/source/storcach.cxx | 58 |
10 files changed, 548 insertions, 553 deletions
diff --git a/stoc/source/corereflection/criface.cxx b/stoc/source/corereflection/criface.cxx index c37108081fbe..041272a51a28 100644 --- a/stoc/source/corereflection/criface.cxx +++ b/stoc/source/corereflection/criface.cxx @@ -295,23 +295,24 @@ void IdlAttributeFieldImpl::set( const Any & rObj, const Any & rValue ) void IdlAttributeFieldImpl::checkException( uno_Any * exception, Reference< XInterface > const & context) const { - if (exception != nullptr) { - Any e; - uno_any_destruct(&e, reinterpret_cast< uno_ReleaseFunc >(cpp_release)); - uno_type_any_constructAndConvert( - &e, exception->pData, exception->pType, - getReflection()->getUno2Cpp().get()); - uno_any_destruct(exception, nullptr); - if (!e.isExtractableTo( - cppu::UnoType<RuntimeException>::get())) - { - throw WrappedTargetRuntimeException( - "non-RuntimeException occurred when accessing an" - " interface type attribute", - context, e); - } - cppu::throwException(e); + if (exception == nullptr) + return; + + Any e; + uno_any_destruct(&e, reinterpret_cast< uno_ReleaseFunc >(cpp_release)); + uno_type_any_constructAndConvert( + &e, exception->pData, exception->pType, + getReflection()->getUno2Cpp().get()); + uno_any_destruct(exception, nullptr); + if (!e.isExtractableTo( + cppu::UnoType<RuntimeException>::get())) + { + throw WrappedTargetRuntimeException( + "non-RuntimeException occurred when accessing an" + " interface type attribute", + context, e); } + cppu::throwException(e); } diff --git a/stoc/source/defaultregistry/defaultregistry.cxx b/stoc/source/defaultregistry/defaultregistry.cxx index 90153bb123e8..a8a8418b80b5 100644 --- a/stoc/source/defaultregistry/defaultregistry.cxx +++ b/stoc/source/defaultregistry/defaultregistry.cxx @@ -188,19 +188,19 @@ NestedKeyImpl::NestedKeyImpl( const OUString& rKeyName, void NestedKeyImpl::computeChanges() { Guard< Mutex > aGuard( m_xRegistry->m_mutex ); - if ( m_state != m_xRegistry->m_state ) - { - Reference<XRegistryKey> rootKey(m_xRegistry->m_localReg->getRootKey()); + if ( m_state == m_xRegistry->m_state ) + return; - Reference<XRegistryKey> tmpKey = rootKey->openKey(m_name); + Reference<XRegistryKey> rootKey(m_xRegistry->m_localReg->getRootKey()); - if ( tmpKey.is() ) - { - m_localKey = rootKey->openKey(m_name); - } + Reference<XRegistryKey> tmpKey = rootKey->openKey(m_name); - m_state = m_xRegistry->m_state; + if ( tmpKey.is() ) + { + m_localKey = rootKey->openKey(m_name); } + + m_state = m_xRegistry->m_state; } diff --git a/stoc/source/implementationregistration/implreg.cxx b/stoc/source/implementationregistration/implreg.cxx index f3c686f776c4..ede4e6f050b4 100644 --- a/stoc/source/implementationregistration/implreg.cxx +++ b/stoc/source/implementationregistration/implreg.cxx @@ -100,74 +100,74 @@ void deleteAllLinkReferences(const Reference < XSimpleRegistry >& xReg, Reference < XRegistryKey > xKey = xSource->openKey( slash_UNO_slash_REGISTRY_LINKS ); - if (xKey.is() && (xKey->getValueType() == RegistryValueType_ASCIILIST)) - { - Sequence<OUString> linkNames = xKey->getAsciiListValue(); + if (!(xKey.is() && (xKey->getValueType() == RegistryValueType_ASCIILIST))) + return; - if (linkNames.getLength()) - { - const OUString* pLinkNames = linkNames.getConstArray(); + Sequence<OUString> linkNames = xKey->getAsciiListValue(); - OUString aLinkName; - OUString aLinkParent; - Reference < XRegistryKey > xLinkParent; - const sal_Unicode* pTmpName = nullptr; - const sal_Unicode* pShortName = nullptr; - sal_Int32 sEnd = 0; + if (!linkNames.getLength()) + return; - for (sal_Int32 i = 0; i < linkNames.getLength(); i++) - { - aLinkName = pLinkNames[i]; + const OUString* pLinkNames = linkNames.getConstArray(); - pTmpName = aLinkName.getStr(); + OUString aLinkName; + OUString aLinkParent; + Reference < XRegistryKey > xLinkParent; + const sal_Unicode* pTmpName = nullptr; + const sal_Unicode* pShortName = nullptr; + sal_Int32 sEnd = 0; - if (pTmpName[0] != L'/') - continue; + for (sal_Int32 i = 0; i < linkNames.getLength(); i++) + { + aLinkName = pLinkNames[i]; - sal_Int32 nIndex = rtl_ustr_indexOfChar( pTmpName, '%' ); - if ( nIndex == -1 ) - pShortName = nullptr; - else - pShortName = pTmpName+nIndex; + pTmpName = aLinkName.getStr(); - while (pShortName && pShortName[1] == L'%') - { - nIndex = rtl_ustr_indexOfChar( pShortName+2, '%' ); - if ( nIndex == -1 ) - pShortName = nullptr; - else - pShortName += nIndex+2; - } + if (pTmpName[0] != L'/') + continue; - if (pShortName) - { - aLinkName = aLinkName.copy(0, pShortName - pTmpName); - } + sal_Int32 nIndex = rtl_ustr_indexOfChar( pTmpName, '%' ); + if ( nIndex == -1 ) + pShortName = nullptr; + else + pShortName = pTmpName+nIndex; - xReg->getRootKey()->deleteLink(aLinkName); + while (pShortName && pShortName[1] == L'%') + { + nIndex = rtl_ustr_indexOfChar( pShortName+2, '%' ); + if ( nIndex == -1 ) + pShortName = nullptr; + else + pShortName += nIndex+2; + } - sEnd = aLinkName.lastIndexOf( '/' ); + if (pShortName) + { + aLinkName = aLinkName.copy(0, pShortName - pTmpName); + } - aLinkParent = aLinkName.copy(0, sEnd); + xReg->getRootKey()->deleteLink(aLinkName); - while(!aLinkParent.isEmpty()) - { - xLinkParent = xReg->getRootKey()->openKey(aLinkParent); + sEnd = aLinkName.lastIndexOf( '/' ); - if (xLinkParent.is() && (xLinkParent->getKeyNames().getLength() == 0)) - { - aLinkName = aLinkParent; + aLinkParent = aLinkName.copy(0, sEnd); - xReg->getRootKey()->deleteKey(aLinkParent); + while(!aLinkParent.isEmpty()) + { + xLinkParent = xReg->getRootKey()->openKey(aLinkParent); - sEnd = aLinkName.lastIndexOf( '/' ); + if (xLinkParent.is() && (xLinkParent->getKeyNames().getLength() == 0)) + { + aLinkName = aLinkParent; - aLinkParent = aLinkName.copy(0, sEnd); - } else - { - break; - } - } + xReg->getRootKey()->deleteKey(aLinkParent); + + sEnd = aLinkName.lastIndexOf( '/' ); + + aLinkParent = aLinkName.copy(0, sEnd); + } else + { + break; } } } @@ -304,55 +304,49 @@ void createUniqueSubEntry(const Reference < XRegistryKey > & xSuperKey, const OUString& value) // throw ( InvalidRegistryException, RuntimeException ) { - if (xSuperKey.is()) + if (!xSuperKey.is()) + return; + + if (xSuperKey->getValueType() == RegistryValueType_ASCIILIST) { -// try -// { - if (xSuperKey->getValueType() == RegistryValueType_ASCIILIST) - { - sal_Int32 length = 0; - bool bReady = false; + sal_Int32 length = 0; + bool bReady = false; - Sequence<OUString> implEntries = xSuperKey->getAsciiListValue(); - length = implEntries.getLength(); + Sequence<OUString> implEntries = xSuperKey->getAsciiListValue(); + length = implEntries.getLength(); - for (sal_Int32 i = 0; !bReady && (i < length); i++) - { - bReady = (implEntries.getConstArray()[i] == value); - } + for (sal_Int32 i = 0; !bReady && (i < length); i++) + { + bReady = (implEntries.getConstArray()[i] == value); + } - if (bReady) - { - Sequence<OUString> implEntriesNew(length); - implEntriesNew.getArray()[0] = value; + if (bReady) + { + Sequence<OUString> implEntriesNew(length); + implEntriesNew.getArray()[0] = value; - for (sal_Int32 i=0, j=1; i < length; i++) - { - if (implEntries.getConstArray()[i] != value) - implEntriesNew.getArray()[j++] = implEntries.getConstArray()[i]; - } - xSuperKey->setAsciiListValue(implEntriesNew); - } else + for (sal_Int32 i=0, j=1; i < length; i++) { - Sequence<OUString> implEntriesNew(length+1); - implEntriesNew.getArray()[0] = value; - - for (sal_Int32 i = 0; i < length; i++) - { - implEntriesNew.getArray()[i+1] = implEntries.getConstArray()[i]; - } - xSuperKey->setAsciiListValue(implEntriesNew); + if (implEntries.getConstArray()[i] != value) + implEntriesNew.getArray()[j++] = implEntries.getConstArray()[i]; } + xSuperKey->setAsciiListValue(implEntriesNew); } else { - Sequence<OUString> implEntriesNew { value }; + Sequence<OUString> implEntriesNew(length+1); + implEntriesNew.getArray()[0] = value; + for (sal_Int32 i = 0; i < length; i++) + { + implEntriesNew.getArray()[i+1] = implEntries.getConstArray()[i]; + } xSuperKey->setAsciiListValue(implEntriesNew); } -// } -// catch(InvalidRegistryException&) -// { -// } + } else + { + Sequence<OUString> implEntriesNew { value }; + + xSuperKey->setAsciiListValue(implEntriesNew); } } @@ -606,29 +600,29 @@ void prepareUserKeys(const Reference < XSimpleRegistry >& xDest, } } - if (! hasSubKeys) - { - OUString keyName(xKey->getKeyName().copy(xUnoKey->getKeyName().getLength())); + if (hasSubKeys) + return; - Reference < XRegistryKey > xRootKey = xDest->getRootKey(); - if (bRegister) + OUString keyName(xKey->getKeyName().copy(xUnoKey->getKeyName().getLength())); + + Reference < XRegistryKey > xRootKey = xDest->getRootKey(); + if (bRegister) + { + createUniqueSubEntry(xRootKey->createKey(keyName), implName); + } + else + { + Reference< XRegistryKey > rKey = xRootKey->openKey(keyName); + if( rKey.is() ) { - createUniqueSubEntry(xRootKey->createKey(keyName), implName); + deleteSubEntry(rKey, implName); + xRootKey->deleteKey(keyName); } - else - { - Reference< XRegistryKey > rKey = xRootKey->openKey(keyName); - if( rKey.is() ) - { - deleteSubEntry(rKey, implName); - xRootKey->deleteKey(keyName); - } - OUString path = keyName.copy(0, keyName.lastIndexOf('/')); - if( !path.isEmpty() ) - { - deletePathIfPossible(xRootKey, path); - } + OUString path = keyName.copy(0, keyName.lastIndexOf('/')); + if( !path.isEmpty() ) + { + deletePathIfPossible(xRootKey, path); } } } @@ -888,108 +882,108 @@ void insert_singletons( { // singletons Reference< registry::XRegistryKey > xKey( xImplKey->openKey( "UNO/SINGLETONS" ) ); - if (xKey.is() && xKey->isValid()) + if (!(xKey.is() && xKey->isValid())) + return; + + OUString implname( xImplKey->getKeyName().copy( sizeof ("/IMPLEMENTATIONS/") -1 ) ); + // singleton entries + Sequence< Reference< registry::XRegistryKey > > xSingletons_section( xKey->openKeys() ); + Reference< registry::XRegistryKey > const * p = xSingletons_section.getConstArray(); + for ( sal_Int32 nPos = xSingletons_section.getLength(); nPos--; ) { - OUString implname( xImplKey->getKeyName().copy( sizeof ("/IMPLEMENTATIONS/") -1 ) ); - // singleton entries - Sequence< Reference< registry::XRegistryKey > > xSingletons_section( xKey->openKeys() ); - Reference< registry::XRegistryKey > const * p = xSingletons_section.getConstArray(); - for ( sal_Int32 nPos = xSingletons_section.getLength(); nPos--; ) + Reference< registry::XRegistryKey > const & xSingleton = p[ nPos ]; + OUString singleton_name( + xSingleton->getKeyName().copy( + implname.getLength() + sizeof ("/IMPLEMENTATIONS//UNO/SINGLETONS/") -1 ) ); + OUString service_name( xSingleton->getStringValue() ); + + OUString keyname( "/SINGLETONS/" + singleton_name ); + Reference< registry::XRegistryKey > xKey2( xDest->getRootKey()->openKey( keyname ) ); + if (xKey2.is() && xKey2->isValid()) { - Reference< registry::XRegistryKey > const & xSingleton = p[ nPos ]; - OUString singleton_name( - xSingleton->getKeyName().copy( - implname.getLength() + sizeof ("/IMPLEMENTATIONS//UNO/SINGLETONS/") -1 ) ); - OUString service_name( xSingleton->getStringValue() ); - - OUString keyname( "/SINGLETONS/" + singleton_name ); - Reference< registry::XRegistryKey > xKey2( xDest->getRootKey()->openKey( keyname ) ); - if (xKey2.is() && xKey2->isValid()) + try { - try + OUString existing_name( xKey2->getStringValue() ); + if ( existing_name != service_name ) { - OUString existing_name( xKey2->getStringValue() ); - if ( existing_name != service_name ) + Reference< container::XHierarchicalNameAccess > xTDMgr; + OUString the_tdmgr = + "/singletons/com.sun.star.reflection.theTypeDescriptionManager"; + xContext->getValueByName( the_tdmgr ) >>= xTDMgr; + if (! xTDMgr.is()) + { + throw RuntimeException( "cannot get singleton " + the_tdmgr ); + } + try { - Reference< container::XHierarchicalNameAccess > xTDMgr; - OUString the_tdmgr = - "/singletons/com.sun.star.reflection.theTypeDescriptionManager"; - xContext->getValueByName( the_tdmgr ) >>= xTDMgr; - if (! xTDMgr.is()) + Reference< reflection::XServiceTypeDescription > xExistingService_td; + xTDMgr->getByHierarchicalName( existing_name ) >>= xExistingService_td; + if (! xExistingService_td.is()) { - throw RuntimeException( "cannot get singleton " + the_tdmgr ); + throw RuntimeException( "cannot get service type description: " + existing_name ); } - try - { - Reference< reflection::XServiceTypeDescription > xExistingService_td; - xTDMgr->getByHierarchicalName( existing_name ) >>= xExistingService_td; - if (! xExistingService_td.is()) - { - throw RuntimeException( "cannot get service type description: " + existing_name ); - } - // everything's fine if existing service entry supports the one - // to be registered - if (! is_supported_service( service_name, xExistingService_td )) - { - throw registry::CannotRegisterImplementationException( - "existing singleton service (" + singleton_name + "=" + existing_name + ") " - " does not support given one: " + service_name); - } - } - catch (const container::NoSuchElementException & exc) + // everything's fine if existing service entry supports the one + // to be registered + if (! is_supported_service( service_name, xExistingService_td )) { - css::uno::Any anyEx = cppu::getCaughtException(); - throw css::lang::WrappedTargetRuntimeException( - "cannot get service type description: " + exc.Message, - nullptr, anyEx ); + throw registry::CannotRegisterImplementationException( + "existing singleton service (" + singleton_name + "=" + existing_name + ") " + " does not support given one: " + service_name); } } - } - catch (registry::InvalidValueException &) - { - // repair - xKey2->setStringValue( service_name ); + catch (const container::NoSuchElementException & exc) + { + css::uno::Any anyEx = cppu::getCaughtException(); + throw css::lang::WrappedTargetRuntimeException( + "cannot get service type description: " + exc.Message, + nullptr, anyEx ); + } } } - else + catch (registry::InvalidValueException &) { - // insert singleton entry - xKey2 = xDest->getRootKey()->createKey( keyname ); + // repair xKey2->setStringValue( service_name ); } + } + else + { + // insert singleton entry + xKey2 = xDest->getRootKey()->createKey( keyname ); + xKey2->setStringValue( service_name ); + } - Reference< registry::XRegistryKey > xRegisteredImplNames( - xKey2->openKey( "REGISTERED_BY" ) ); - if (!xRegisteredImplNames.is() || !xRegisteredImplNames->isValid()) - { - // create - xRegisteredImplNames = xKey2->createKey( "REGISTERED_BY" ); - } + Reference< registry::XRegistryKey > xRegisteredImplNames( + xKey2->openKey( "REGISTERED_BY" ) ); + if (!xRegisteredImplNames.is() || !xRegisteredImplNames->isValid()) + { + // create + xRegisteredImplNames = xKey2->createKey( "REGISTERED_BY" ); + } - Sequence< OUString > implnames; - try - { - implnames = xRegisteredImplNames->getAsciiListValue(); - } - catch (registry::InvalidValueException &) - { - } - // check implname is already in - sal_Int32 nPos_implnames = implnames.getLength(); - OUString const * pImplnames = implnames.getConstArray(); - while (nPos_implnames--) - { - if (implname == pImplnames[ nPos_implnames ]) - break; - } - if (nPos_implnames < 0) - { - // append and write back - implnames.realloc( implnames.getLength() +1 ); - implnames[ implnames.getLength() -1 ] = implname; - xRegisteredImplNames->setAsciiListValue( implnames ); - } + Sequence< OUString > implnames; + try + { + implnames = xRegisteredImplNames->getAsciiListValue(); + } + catch (registry::InvalidValueException &) + { + } + // check implname is already in + sal_Int32 nPos_implnames = implnames.getLength(); + OUString const * pImplnames = implnames.getConstArray(); + while (nPos_implnames--) + { + if (implname == pImplnames[ nPos_implnames ]) + break; + } + if (nPos_implnames < 0) + { + // append and write back + implnames.realloc( implnames.getLength() +1 ); + implnames[ implnames.getLength() -1 ] = implname; + xRegisteredImplNames->setAsciiListValue( implnames ); } } } @@ -1583,39 +1577,39 @@ void ImplementationRegistration::doRevoke( const OUString& locationUrl) // throw ( InvalidRegistryException, RuntimeException ) { - if( xDest.is() ) - { - std::vector<OUString> aNames; + if( !xDest.is() ) + return; - Reference < XRegistryKey > xRootKey( xDest->getRootKey() ); + std::vector<OUString> aNames; - Reference < XRegistryKey > xKey = - xRootKey->openKey( slash_IMPLEMENTATIONS ); - if (xKey.is() && xKey->isValid()) - { - deleteAllImplementations(xDest, xKey, locationUrl, aNames); - } + Reference < XRegistryKey > xRootKey( xDest->getRootKey() ); - xKey = xRootKey->openKey( slash_SERVICES ); - if (xKey.is()) - { - for (auto const& name : aNames) - { - deleteAllServiceEntries(xDest, xKey, name); - } - } + Reference < XRegistryKey > xKey = + xRootKey->openKey( slash_IMPLEMENTATIONS ); + if (xKey.is() && xKey->isValid()) + { + deleteAllImplementations(xDest, xKey, locationUrl, aNames); + } - xKey = xRootKey->openKey( "/SINGLETONS" ); - if (xKey.is() && xKey->isValid()) + xKey = xRootKey->openKey( slash_SERVICES ); + if (xKey.is()) + { + for (auto const& name : aNames) { - delete_all_singleton_entries( xKey, aNames ); + deleteAllServiceEntries(xDest, xKey, name); } + } - if (xRootKey.is()) - xRootKey->closeKey(); - if (xKey.is() && xKey->isValid() ) - xKey->closeKey(); + xKey = xRootKey->openKey( "/SINGLETONS" ); + if (xKey.is() && xKey->isValid()) + { + delete_all_singleton_entries( xKey, aNames ); } + + if (xRootKey.is()) + xRootKey->closeKey(); + if (xKey.is() && xKey->isValid() ) + xKey->closeKey(); } void ImplementationRegistration::doRegister( @@ -1634,46 +1628,46 @@ void ImplementationRegistration::doRegister( createTemporarySimpleRegistry( xSMgr, xCtx ); Reference < XRegistryKey > xSourceKey; - if (xAct.is() && xReg.is() && xDest.is()) + if (!(xAct.is() && xReg.is() && xDest.is())) + return; + + try { - try - { - xReg->open(OUString() /* in mem */, false, true); + xReg->open(OUString() /* in mem */, false, true); - { // only necessary for deleting the temporary variable of rootkey - xSourceKey = xReg->getRootKey()->createKey( slash_IMPLEMENTATIONS ); - } + { // only necessary for deleting the temporary variable of rootkey + xSourceKey = xReg->getRootKey()->createKey( slash_IMPLEMENTATIONS ); + } - bool bSuccess = - xAct->writeRegistryInfo(xSourceKey, implementationLoaderUrl, locationUrl); - if ( !bSuccess ) - { - throw CannotRegisterImplementationException( - "ImplementationRegistration::doRegistration() component registration signaled failure" ); - } + bool bSuccess = + xAct->writeRegistryInfo(xSourceKey, implementationLoaderUrl, locationUrl); + if ( !bSuccess ) + { + throw CannotRegisterImplementationException( + "ImplementationRegistration::doRegistration() component registration signaled failure" ); + } - prepareRegistry(xDest, xSourceKey, implementationLoaderUrl, registeredLocationUrl, xCtx); + prepareRegistry(xDest, xSourceKey, implementationLoaderUrl, registeredLocationUrl, xCtx); - xSourceKey->closeKey(); + xSourceKey->closeKey(); - xSourceKey = xReg->getRootKey(); - Reference < XRegistryKey > xDestKey = xDest->getRootKey(); - stoc_impreg::mergeKeys( xDestKey, xSourceKey ); - xDestKey->closeKey(); - xSourceKey->closeKey(); + xSourceKey = xReg->getRootKey(); + Reference < XRegistryKey > xDestKey = xDest->getRootKey(); + stoc_impreg::mergeKeys( xDestKey, xSourceKey ); + xDestKey->closeKey(); + xSourceKey->closeKey(); - // Cleanup Source registry. - if ( xSourceKey->isValid() ) - xSourceKey->closeKey(); - } - catch(CannotRegisterImplementationException&) - { - if ( xSourceKey->isValid() ) - xSourceKey->closeKey(); - // and throw again - throw; - } + // Cleanup Source registry. + if ( xSourceKey->isValid() ) + xSourceKey->closeKey(); + } + catch(CannotRegisterImplementationException&) + { + if ( xSourceKey->isValid() ) + xSourceKey->closeKey(); + // and throw again + throw; } } diff --git a/stoc/source/invocation/invocation.cxx b/stoc/source/invocation/invocation.cxx index 271b90651400..34c93c5cb781 100644 --- a/stoc/source/invocation/invocation.cxx +++ b/stoc/source/invocation/invocation.cxx @@ -947,22 +947,22 @@ void Invocation_Impl::fillInfoForMethod rInfo.aType = aReturnType; Sequence<ParamInfo> aParamInfos = xMethod->getParameterInfos(); sal_Int32 nParamCount = aParamInfos.getLength(); - if( nParamCount > 0 ) - { - const ParamInfo* pInfo = aParamInfos.getConstArray(); + if( nParamCount <= 0 ) + return; - rInfo.aParamTypes.realloc( nParamCount ); - Type* pParamTypes = rInfo.aParamTypes.getArray(); - rInfo.aParamModes.realloc( nParamCount ); - ParamMode* pParamModes = rInfo.aParamModes.getArray(); + const ParamInfo* pInfo = aParamInfos.getConstArray(); - for( sal_Int32 i = 0 ; i < nParamCount ; i++ ) - { - Reference< XIdlClass > xParamClass = pInfo[i].aType; - Type aParamType( xParamClass->getTypeClass(), xParamClass->getName() ); - pParamTypes[ i ] = aParamType; - pParamModes[ i ] = pInfo[i].aMode; - } + rInfo.aParamTypes.realloc( nParamCount ); + Type* pParamTypes = rInfo.aParamTypes.getArray(); + rInfo.aParamModes.realloc( nParamCount ); + ParamMode* pParamModes = rInfo.aParamModes.getArray(); + + for( sal_Int32 i = 0 ; i < nParamCount ; i++ ) + { + Reference< XIdlClass > xParamClass = pInfo[i].aType; + Type aParamType( xParamClass->getTypeClass(), xParamClass->getName() ); + pParamTypes[ i ] = aParamType; + pParamModes[ i ] = pInfo[i].aMode; } } diff --git a/stoc/source/javavm/javavm.cxx b/stoc/source/javavm/javavm.cxx index c46499cfab83..cd6cba4b7ba6 100644 --- a/stoc/source/javavm/javavm.cxx +++ b/stoc/source/javavm/javavm.cxx @@ -1134,121 +1134,121 @@ void SAL_CALL JavaVirtualMachine::elementReplaced( xVirtualMachine = m_xUnoVirtualMachine->getVirtualMachine(); } } - if (xVirtualMachine.is()) + if (!xVirtualMachine.is()) + return; + + try { - try + jvmaccess::VirtualMachine::AttachGuard aAttachGuard( + xVirtualMachine); + JNIEnv * pJNIEnv = aAttachGuard.getEnvironment(); + + // call java.lang.System.setProperty + // String setProperty( String key, String value) + jclass jcSystem= pJNIEnv->FindClass("java/lang/System"); + if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException("JNI:FindClass java/lang/System", nullptr); + jmethodID jmSetProps= pJNIEnv->GetStaticMethodID( jcSystem, "setProperty","(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"); + if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException("JNI:GetStaticMethodID java.lang.System.setProperty", nullptr); + + jstring jsPropName= pJNIEnv->NewString( reinterpret_cast<jchar const *>(aPropertyName.getStr()), aPropertyName.getLength()); + if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException("JNI:NewString", nullptr); + + // remove the property if it does not have a value ( user left the dialog field empty) + // or if the port is set to 0 + aPropertyValue= aPropertyValue.trim(); + if( aPropertyValue.isEmpty() || + ( ( aPropertyName == "ftp.proxyPort" || aPropertyName == "http.proxyPort" /*|| aPropertyName == "socksProxyPort"*/ ) && aPropertyValue == "0" ) + ) { - jvmaccess::VirtualMachine::AttachGuard aAttachGuard( - xVirtualMachine); - JNIEnv * pJNIEnv = aAttachGuard.getEnvironment(); - - // call java.lang.System.setProperty - // String setProperty( String key, String value) - jclass jcSystem= pJNIEnv->FindClass("java/lang/System"); - if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException("JNI:FindClass java/lang/System", nullptr); - jmethodID jmSetProps= pJNIEnv->GetStaticMethodID( jcSystem, "setProperty","(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"); - if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException("JNI:GetStaticMethodID java.lang.System.setProperty", nullptr); - - jstring jsPropName= pJNIEnv->NewString( reinterpret_cast<jchar const *>(aPropertyName.getStr()), aPropertyName.getLength()); - if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException("JNI:NewString", nullptr); + // call java.lang.System.getProperties + jmethodID jmGetProps= pJNIEnv->GetStaticMethodID( jcSystem, "getProperties","()Ljava/util/Properties;"); + if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException("JNI:GetStaticMethodID java.lang.System.getProperties", nullptr); + jobject joProperties= pJNIEnv->CallStaticObjectMethod( jcSystem, jmGetProps); + if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException("JNI:CallStaticObjectMethod java.lang.System.getProperties", nullptr); + // call java.util.Properties.remove + jclass jcProperties= pJNIEnv->FindClass("java/util/Properties"); + if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException("JNI:FindClass java/util/Properties", nullptr); + jmethodID jmRemove= pJNIEnv->GetMethodID( jcProperties, "remove", "(Ljava/lang/Object;)Ljava/lang/Object;"); + if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException("JNI:GetMethodID java.util.Properties.remove", nullptr); + pJNIEnv->CallObjectMethod( joProperties, jmRemove, jsPropName); - // remove the property if it does not have a value ( user left the dialog field empty) - // or if the port is set to 0 - aPropertyValue= aPropertyValue.trim(); - if( aPropertyValue.isEmpty() || - ( ( aPropertyName == "ftp.proxyPort" || aPropertyName == "http.proxyPort" /*|| aPropertyName == "socksProxyPort"*/ ) && aPropertyValue == "0" ) - ) + // special case for ftp.nonProxyHosts and http.nonProxyHosts. The office only + // has a value for two java properties + if (!aPropertyName2.isEmpty()) { - // call java.lang.System.getProperties - jmethodID jmGetProps= pJNIEnv->GetStaticMethodID( jcSystem, "getProperties","()Ljava/util/Properties;"); - if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException("JNI:GetStaticMethodID java.lang.System.getProperties", nullptr); - jobject joProperties= pJNIEnv->CallStaticObjectMethod( jcSystem, jmGetProps); - if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException("JNI:CallStaticObjectMethod java.lang.System.getProperties", nullptr); - // call java.util.Properties.remove - jclass jcProperties= pJNIEnv->FindClass("java/util/Properties"); - if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException("JNI:FindClass java/util/Properties", nullptr); - jmethodID jmRemove= pJNIEnv->GetMethodID( jcProperties, "remove", "(Ljava/lang/Object;)Ljava/lang/Object;"); - if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException("JNI:GetMethodID java.util.Properties.remove", nullptr); - pJNIEnv->CallObjectMethod( joProperties, jmRemove, jsPropName); - - // special case for ftp.nonProxyHosts and http.nonProxyHosts. The office only - // has a value for two java properties - if (!aPropertyName2.isEmpty()) - { - jstring jsPropName2= pJNIEnv->NewString( reinterpret_cast<jchar const *>(aPropertyName2.getStr()), aPropertyName2.getLength()); - if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException("JNI:NewString", nullptr); - pJNIEnv->CallObjectMethod( joProperties, jmRemove, jsPropName2); - } + jstring jsPropName2= pJNIEnv->NewString( reinterpret_cast<jchar const *>(aPropertyName2.getStr()), aPropertyName2.getLength()); + if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException("JNI:NewString", nullptr); + pJNIEnv->CallObjectMethod( joProperties, jmRemove, jsPropName2); } - else + } + else + { + // Change the Value of the property + jstring jsPropValue= pJNIEnv->NewString( reinterpret_cast<jchar const *>(aPropertyValue.getStr()), aPropertyValue.getLength()); + if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException("JNI:NewString", nullptr); + pJNIEnv->CallStaticObjectMethod( jcSystem, jmSetProps, jsPropName, jsPropValue); + if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException("JNI:CallStaticObjectMethod java.lang.System.setProperty", nullptr); + + // special case for ftp.nonProxyHosts and http.nonProxyHosts. The office only + // has a value for two java properties + if (!aPropertyName2.isEmpty()) { - // Change the Value of the property - jstring jsPropValue= pJNIEnv->NewString( reinterpret_cast<jchar const *>(aPropertyValue.getStr()), aPropertyValue.getLength()); + jstring jsPropName2= pJNIEnv->NewString( reinterpret_cast<jchar const *>(aPropertyName2.getStr()), aPropertyName2.getLength()); + if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException("JNI:NewString", nullptr); + jsPropValue= pJNIEnv->NewString( reinterpret_cast<jchar const *>(aPropertyValue.getStr()), aPropertyValue.getLength()); if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException("JNI:NewString", nullptr); - pJNIEnv->CallStaticObjectMethod( jcSystem, jmSetProps, jsPropName, jsPropValue); + pJNIEnv->CallStaticObjectMethod( jcSystem, jmSetProps, jsPropName2, jsPropValue); if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException("JNI:CallStaticObjectMethod java.lang.System.setProperty", nullptr); - - // special case for ftp.nonProxyHosts and http.nonProxyHosts. The office only - // has a value for two java properties - if (!aPropertyName2.isEmpty()) - { - jstring jsPropName2= pJNIEnv->NewString( reinterpret_cast<jchar const *>(aPropertyName2.getStr()), aPropertyName2.getLength()); - if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException("JNI:NewString", nullptr); - jsPropValue= pJNIEnv->NewString( reinterpret_cast<jchar const *>(aPropertyValue.getStr()), aPropertyValue.getLength()); - if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException("JNI:NewString", nullptr); - pJNIEnv->CallStaticObjectMethod( jcSystem, jmSetProps, jsPropName2, jsPropValue); - if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException("JNI:CallStaticObjectMethod java.lang.System.setProperty", nullptr); - } } + } - // If the settings for Security and NetAccess changed then we have to notify the SandboxSecurity - // SecurityManager - // call System.getSecurityManager() - if (bSecurityChanged) + // If the settings for Security and NetAccess changed then we have to notify the SandboxSecurity + // SecurityManager + // call System.getSecurityManager() + if (bSecurityChanged) + { + jmethodID jmGetSecur= pJNIEnv->GetStaticMethodID( jcSystem,"getSecurityManager","()Ljava/lang/SecurityManager;"); + if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException("JNI:GetStaticMethodID java.lang.System.getSecurityManager", nullptr); + jobject joSecur= pJNIEnv->CallStaticObjectMethod( jcSystem, jmGetSecur); + if (joSecur != nullptr) { - jmethodID jmGetSecur= pJNIEnv->GetStaticMethodID( jcSystem,"getSecurityManager","()Ljava/lang/SecurityManager;"); - if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException("JNI:GetStaticMethodID java.lang.System.getSecurityManager", nullptr); - jobject joSecur= pJNIEnv->CallStaticObjectMethod( jcSystem, jmGetSecur); - if (joSecur != nullptr) - { - // Make sure the SecurityManager is our SandboxSecurity - // FindClass("com.sun.star.lib.sandbox.SandboxSecurityManager" only worked at the first time - // this code was executed. Maybe it is a security feature. However, all attempts to debug the - // SandboxSecurity class (maybe the VM invokes checkPackageAccess) failed. + // Make sure the SecurityManager is our SandboxSecurity + // FindClass("com.sun.star.lib.sandbox.SandboxSecurityManager" only worked at the first time + // this code was executed. Maybe it is a security feature. However, all attempts to debug the + // SandboxSecurity class (maybe the VM invokes checkPackageAccess) failed. // jclass jcSandboxSec= pJNIEnv->FindClass("com.sun.star.lib.sandbox.SandboxSecurity"); // if(pJNIEnv->ExceptionOccurred()) throw RuntimeException("JNI:FindClass com.sun.star.lib.sandbox.SandboxSecurity"); // jboolean bIsSand= pJNIEnv->IsInstanceOf( joSecur, jcSandboxSec); - // The SecurityManagers class Name must be com.sun.star.lib.sandbox.SandboxSecurity - jclass jcSec= pJNIEnv->GetObjectClass( joSecur); - jclass jcClass= pJNIEnv->FindClass("java/lang/Class"); - if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException("JNI:FindClass java.lang.Class", nullptr); - jmethodID jmName= pJNIEnv->GetMethodID( jcClass,"getName","()Ljava/lang/String;"); - if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException("JNI:GetMethodID java.lang.Class.getName", nullptr); - jstring jsClass= static_cast<jstring>(pJNIEnv->CallObjectMethod( jcSec, jmName)); - const jchar* jcharName= pJNIEnv->GetStringChars( jsClass, nullptr); - OUString sName(reinterpret_cast<sal_Unicode const *>(jcharName)); - bool bIsSandbox; - bIsSandbox = sName == "com.sun.star.lib.sandbox.SandboxSecurity"; - pJNIEnv->ReleaseStringChars( jsClass, jcharName); - - if (bIsSandbox) - { - // call SandboxSecurity.reset - jmethodID jmReset= pJNIEnv->GetMethodID( jcSec,"reset","()V"); - if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException("JNI:GetMethodID com.sun.star.lib.sandbox.SandboxSecurity.reset", nullptr); - pJNIEnv->CallVoidMethod( joSecur, jmReset); - if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException("JNI:CallVoidMethod com.sun.star.lib.sandbox.SandboxSecurity.reset", nullptr); - } + // The SecurityManagers class Name must be com.sun.star.lib.sandbox.SandboxSecurity + jclass jcSec= pJNIEnv->GetObjectClass( joSecur); + jclass jcClass= pJNIEnv->FindClass("java/lang/Class"); + if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException("JNI:FindClass java.lang.Class", nullptr); + jmethodID jmName= pJNIEnv->GetMethodID( jcClass,"getName","()Ljava/lang/String;"); + if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException("JNI:GetMethodID java.lang.Class.getName", nullptr); + jstring jsClass= static_cast<jstring>(pJNIEnv->CallObjectMethod( jcSec, jmName)); + const jchar* jcharName= pJNIEnv->GetStringChars( jsClass, nullptr); + OUString sName(reinterpret_cast<sal_Unicode const *>(jcharName)); + bool bIsSandbox; + bIsSandbox = sName == "com.sun.star.lib.sandbox.SandboxSecurity"; + pJNIEnv->ReleaseStringChars( jsClass, jcharName); + + if (bIsSandbox) + { + // call SandboxSecurity.reset + jmethodID jmReset= pJNIEnv->GetMethodID( jcSec,"reset","()V"); + if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException("JNI:GetMethodID com.sun.star.lib.sandbox.SandboxSecurity.reset", nullptr); + pJNIEnv->CallVoidMethod( joSecur, jmReset); + if(pJNIEnv->ExceptionOccurred()) throw css::uno::RuntimeException("JNI:CallVoidMethod com.sun.star.lib.sandbox.SandboxSecurity.reset", nullptr); } } } - catch (jvmaccess::VirtualMachine::AttachGuard::CreationException &) - { - css::uno::Any anyEx = cppu::getCaughtException(); - throw css::lang::WrappedTargetRuntimeException( - "jvmaccess::VirtualMachine::AttachGuard::CreationException", - static_cast< cppu::OWeakObject * >(this), anyEx ); - } + } + catch (jvmaccess::VirtualMachine::AttachGuard::CreationException &) + { + css::uno::Any anyEx = cppu::getCaughtException(); + throw css::lang::WrappedTargetRuntimeException( + "jvmaccess::VirtualMachine::AttachGuard::CreationException", + static_cast< cppu::OWeakObject * >(this), anyEx ); } } diff --git a/stoc/source/proxy_factory/proxyfac.cxx b/stoc/source/proxy_factory/proxyfac.cxx index b85ed4907b9c..d00eb20f2331 100644 --- a/stoc/source/proxy_factory/proxyfac.cxx +++ b/stoc/source/proxy_factory/proxyfac.cxx @@ -192,19 +192,19 @@ static void binuno_proxy_free( static void binuno_proxy_acquire( uno_Interface * pUnoI ) { binuno_Proxy * that = static_cast< binuno_Proxy * >( pUnoI ); - if (osl_atomic_increment( &that->m_nRefCount ) == 1) - { - // rebirth of zombie - uno_ExtEnvironment * uno_env = - that->m_root->m_factory->m_uno_env.get()->pExtEnv; - OSL_ASSERT( uno_env != nullptr ); - (*uno_env->registerProxyInterface)( - uno_env, reinterpret_cast< void ** >( &pUnoI ), binuno_proxy_free, - that->m_oid.pData, - reinterpret_cast< typelib_InterfaceTypeDescription * >( - that->m_typeDescr.get() ) ); - OSL_ASSERT( that == static_cast< binuno_Proxy * >( pUnoI ) ); - } + if (osl_atomic_increment( &that->m_nRefCount ) != 1) + return; + + // rebirth of zombie + uno_ExtEnvironment * uno_env = + that->m_root->m_factory->m_uno_env.get()->pExtEnv; + OSL_ASSERT( uno_env != nullptr ); + (*uno_env->registerProxyInterface)( + uno_env, reinterpret_cast< void ** >( &pUnoI ), binuno_proxy_free, + that->m_oid.pData, + reinterpret_cast< typelib_InterfaceTypeDescription * >( + that->m_typeDescr.get() ) ); + OSL_ASSERT( that == static_cast< binuno_Proxy * >( pUnoI ) ); } diff --git a/stoc/source/security/access_controller.cxx b/stoc/source/security/access_controller.cxx index 9ddca3b1e076..38bf046a4032 100644 --- a/stoc/source/security/access_controller.cxx +++ b/stoc/source/security/access_controller.cxx @@ -386,19 +386,19 @@ AccessController::AccessController( Reference< XComponentContext > const & xComp } // switch on caching for DYNAMIC_ONLY and ON (shareable multi-user process) - if (ON == m_mode || DYNAMIC_ONLY == m_mode) + if (!(ON == m_mode || DYNAMIC_ONLY == m_mode)) + return; + + sal_Int32 cacheSize = 0; // multi-user cache size + if (! (m_xComponentContext->getValueByName( + "/services/" SERVICE_NAME "/user-cache-size" ) >>= cacheSize)) { - sal_Int32 cacheSize = 0; // multi-user cache size - if (! (m_xComponentContext->getValueByName( - "/services/" SERVICE_NAME "/user-cache-size" ) >>= cacheSize)) - { - cacheSize = 128; // reasonable default? - } + cacheSize = 128; // reasonable default? + } #ifdef __CACHE_DIAGNOSE - cacheSize = 2; + cacheSize = 2; #endif - m_user2permissions.setSize( cacheSize ); - } + m_user2permissions.setSize( cacheSize ); } void AccessController::disposing() @@ -495,53 +495,53 @@ void AccessController::checkAndClearPostPoned() std::unique_ptr< t_rec_vec > rec( static_cast< t_rec_vec * >( m_rec.getData() ) ); m_rec.setData( nullptr ); // takeover ownership OSL_ASSERT(rec); - if (rec) + if (!rec) + return; + + t_rec_vec const& vec = *rec; + switch (m_mode) { - t_rec_vec const& vec = *rec; - switch (m_mode) + case SINGLE_USER: + { + OSL_ASSERT( m_singleUser_init ); + for (const auto & p : vec) { - case SINGLE_USER: + OSL_ASSERT( m_singleUserId == p.first ); + m_singleUserPermissions.checkPermission( p.second ); + } + break; + } + case SINGLE_DEFAULT_USER: + { + OSL_ASSERT( m_defaultPerm_init ); + for (const auto & p : vec) { - OSL_ASSERT( m_singleUser_init ); - for (const auto & p : vec) - { - OSL_ASSERT( m_singleUserId == p.first ); - m_singleUserPermissions.checkPermission( p.second ); - } - break; + OSL_ASSERT( p.first.isEmpty() ); // default-user + m_defaultPermissions.checkPermission( p.second ); } - case SINGLE_DEFAULT_USER: + break; + } + case ON: + { + for (const auto & p : vec) { - OSL_ASSERT( m_defaultPerm_init ); - for (const auto & p : vec) + PermissionCollection const * pPermissions; + // lookup policy for user { - OSL_ASSERT( p.first.isEmpty() ); // default-user - m_defaultPermissions.checkPermission( p.second ); + MutexGuard guard( m_mutex ); + pPermissions = m_user2permissions.lookup( p.first ); } - break; - } - case ON: - { - for (const auto & p : vec) + OSL_ASSERT( pPermissions ); + if (pPermissions) { - PermissionCollection const * pPermissions; - // lookup policy for user - { - MutexGuard guard( m_mutex ); - pPermissions = m_user2permissions.lookup( p.first ); - } - OSL_ASSERT( pPermissions ); - if (pPermissions) - { - pPermissions->checkPermission( p.second ); - } + pPermissions->checkPermission( p.second ); } - break; - } - default: - OSL_FAIL( "### this should never be called in this ac mode!" ); - break; } + break; + } + default: + OSL_FAIL( "### this should never be called in this ac mode!" ); + break; } } diff --git a/stoc/source/security/permissions.cxx b/stoc/source/security/permissions.cxx index d8a4ac9b0c70..d871956c1817 100644 --- a/stoc/source/security/permissions.cxx +++ b/stoc/source/security/permissions.cxx @@ -140,28 +140,28 @@ SocketPermission::SocketPermission( // separate host from portrange sal_Int32 colon = m_host.indexOf( ':' ); - if (colon >= 0) // port [range] given + if (colon < 0) // port [range] not given + return; + + sal_Int32 minus = m_host.indexOf( '-', colon +1 ); + if (minus < 0) { - sal_Int32 minus = m_host.indexOf( '-', colon +1 ); - if (minus < 0) - { - m_lowerPort = m_upperPort = m_host.copy( colon +1 ).toInt32(); - } - else if (minus == (colon +1)) // -N - { - m_upperPort = m_host.copy( minus +1 ).toInt32(); - } - else if (minus == (m_host.getLength() -1)) // N- - { - m_lowerPort = m_host.copy( colon +1, m_host.getLength() -1 -colon -1 ).toInt32(); - } - else // A-B - { - m_lowerPort = m_host.copy( colon +1, minus - colon -1 ).toInt32(); - m_upperPort = m_host.copy( minus +1 ).toInt32(); - } - m_host = m_host.copy( 0, colon ); + m_lowerPort = m_upperPort = m_host.copy( colon +1 ).toInt32(); + } + else if (minus == (colon +1)) // -N + { + m_upperPort = m_host.copy( minus +1 ).toInt32(); + } + else if (minus == (m_host.getLength() -1)) // N- + { + m_lowerPort = m_host.copy( colon +1, m_host.getLength() -1 -colon -1 ).toInt32(); + } + else // A-B + { + m_lowerPort = m_host.copy( colon +1, minus - colon -1 ).toInt32(); + m_upperPort = m_host.copy( minus +1 ).toInt32(); } + m_host = m_host.copy( 0, colon ); } inline bool SocketPermission::resolveHost() const @@ -301,40 +301,40 @@ FilePermission::FilePermission( , m_url( perm.URL ) , m_allFiles( perm.URL == "<<ALL FILES>>" ) { - if (! m_allFiles) + if ( m_allFiles) + return; + + if ( m_url == "*" ) { - if ( m_url == "*" ) - { - OUStringBuffer buf( 64 ); - buf.append( getWorkingDir() ); - buf.append( "/*" ); - m_url = buf.makeStringAndClear(); - } - else if ( m_url == "-" ) - { - OUStringBuffer buf( 64 ); - buf.append( getWorkingDir() ); - buf.append( "/-" ); - m_url = buf.makeStringAndClear(); - } - else if (!m_url.startsWith("file:///")) - { - // relative path - OUString out; - oslFileError rc = ::osl_getAbsoluteFileURL( - getWorkingDir().pData, perm.URL.pData, &out.pData ); - m_url = (osl_File_E_None == rc ? out : perm.URL); // fallback - } + OUStringBuffer buf( 64 ); + buf.append( getWorkingDir() ); + buf.append( "/*" ); + m_url = buf.makeStringAndClear(); + } + else if ( m_url == "-" ) + { + OUStringBuffer buf( 64 ); + buf.append( getWorkingDir() ); + buf.append( "/-" ); + m_url = buf.makeStringAndClear(); + } + else if (!m_url.startsWith("file:///")) + { + // relative path + OUString out; + oslFileError rc = ::osl_getAbsoluteFileURL( + getWorkingDir().pData, perm.URL.pData, &out.pData ); + m_url = (osl_File_E_None == rc ? out : perm.URL); // fallback + } #ifdef _WIN32 - // correct win drive letters - if (9 < m_url.getLength() && '|' == m_url[ 9 ]) // file:///X| - { - static OUString s_colon = ":"; - // common case in API is a ':' (sal), so convert '|' to ':' - m_url = m_url.replaceAt( 9, 1, s_colon ); - } -#endif + // correct win drive letters + if (9 < m_url.getLength() && '|' == m_url[ 9 ]) // file:///X| + { + static OUString s_colon = ":"; + // common case in API is a ':' (sal), so convert '|' to ':' + m_url = m_url.replaceAt( 9, 1, s_colon ); } +#endif } bool FilePermission::implies( Permission const & perm ) const diff --git a/stoc/source/servicemanager/servicemanager.cxx b/stoc/source/servicemanager/servicemanager.cxx index 39ea85c5a833..d6eac9b1ccf0 100644 --- a/stoc/source/servicemanager/servicemanager.cxx +++ b/stoc/source/servicemanager/servicemanager.cxx @@ -316,20 +316,20 @@ public: void OServiceManager_Listener::disposing(const EventObject & rEvt ) { Reference<XSet > x( xSMgr ); - if( x.is() ) + if( !x.is() ) + return; + + try { - try - { - x->remove( Any( &rEvt.Source, cppu::UnoType<XInterface>::get()) ); - } - catch( const IllegalArgumentException & ) - { - OSL_FAIL( "IllegalArgumentException caught" ); - } - catch( const NoSuchElementException & ) - { - OSL_FAIL( "NoSuchElementException caught" ); - } + x->remove( Any( &rEvt.Source, cppu::UnoType<XInterface>::get()) ); + } + catch( const IllegalArgumentException & ) + { + OSL_FAIL( "IllegalArgumentException caught" ); + } + catch( const NoSuchElementException & ) + { + OSL_FAIL( "NoSuchElementException caught" ); } } @@ -1161,24 +1161,24 @@ void OServiceManager::remove( const Any & Element ) //remove from the service map Reference<XServiceInfo > xSF( Reference<XServiceInfo >::query( xEle ) ); - if( xSF.is() ) + if( !xSF.is() ) + return; + + Sequence< OUString > aServiceNames = xSF->getSupportedServiceNames(); + const OUString * pArray = aServiceNames.getConstArray(); + for( sal_Int32 i = 0; i < aServiceNames.getLength(); i++ ) { - Sequence< OUString > aServiceNames = xSF->getSupportedServiceNames(); - const OUString * pArray = aServiceNames.getConstArray(); - for( sal_Int32 i = 0; i < aServiceNames.getLength(); i++ ) - { - pair<HashMultimap_OWString_Interface::iterator, HashMultimap_OWString_Interface::iterator> p = - m_ServiceMap.equal_range( pArray[i] ); + pair<HashMultimap_OWString_Interface::iterator, HashMultimap_OWString_Interface::iterator> p = + m_ServiceMap.equal_range( pArray[i] ); - while( p.first != p.second ) + while( p.first != p.second ) + { + if( xEle == (*p.first).second ) { - if( xEle == (*p.first).second ) - { - m_ServiceMap.erase( p.first ); - break; - } - ++p.first; + m_ServiceMap.erase( p.first ); + break; } + ++p.first; } } } diff --git a/store/source/storcach.cxx b/store/source/storcach.cxx index 3fdf60ec13a0..76a0c6d185c8 100644 --- a/store/source/storcach.cxx +++ b/store/source/storcach.cxx @@ -220,42 +220,42 @@ void PageCache::rescale_Impl (std::size_t new_size) std::size_t new_bytes = new_size * sizeof(Entry*); Entry ** new_table = static_cast<Entry**>(std::malloc(new_bytes)); - if (new_table != nullptr) - { - Entry ** old_table = m_hash_table; - std::size_t old_size = m_hash_size; + if (new_table == nullptr) + return; - SAL_INFO( - "store", - "ave chain length: " << (m_hash_entries >> m_hash_shift) - << ", total entries: " << m_hash_entries << " [old_size: " - << old_size << " new_size: " << new_size << "]"); + Entry ** old_table = m_hash_table; + std::size_t old_size = m_hash_size; - memset (new_table, 0, new_bytes); + SAL_INFO( + "store", + "ave chain length: " << (m_hash_entries >> m_hash_shift) + << ", total entries: " << m_hash_entries << " [old_size: " + << old_size << " new_size: " << new_size << "]"); - m_hash_table = new_table; - m_hash_size = new_size; - m_hash_shift = highbit(m_hash_size) - 1; + memset (new_table, 0, new_bytes); - std::size_t i; - for (i = 0; i < old_size; i++) + m_hash_table = new_table; + m_hash_size = new_size; + m_hash_shift = highbit(m_hash_size) - 1; + + std::size_t i; + for (i = 0; i < old_size; i++) + { + Entry * curr = old_table[i]; + while (curr != nullptr) { - Entry * curr = old_table[i]; - while (curr != nullptr) - { - Entry * next = curr->m_pNext; - int index = hash_index_Impl(curr->m_nOffset); - curr->m_pNext = m_hash_table[index]; - m_hash_table[index] = curr; - curr = next; - } - old_table[i] = nullptr; + Entry * next = curr->m_pNext; + int index = hash_index_Impl(curr->m_nOffset); + curr->m_pNext = m_hash_table[index]; + m_hash_table[index] = curr; + curr = next; } - if (old_table != m_hash_table_0) - { + old_table[i] = nullptr; + } + if (old_table != m_hash_table_0) + { - std::free (old_table); - } + std::free (old_table); } } |