summaryrefslogtreecommitdiff
path: root/ucbhelper
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2019-06-29 13:19:51 +0300
committerArkadiy Illarionov <qarkai@gmail.com>2019-06-29 13:22:10 +0200
commit195b11b4eed1cabc6090b926901bd17c8c8c9dbd (patch)
tree5843749344b0d579d7009d76e3d82fab766ece64 /ucbhelper
parent8660e439776a61220b1be86e4669692bbfa86085 (diff)
Flatten ContentProviderImplHelper
Change-Id: I0461ccfb2d9a9750b91863d9dee29cc5515201dc Reviewed-on: https://gerrit.libreoffice.org/74868 Tested-by: Jenkins Reviewed-by: Arkadiy Illarionov <qarkai@gmail.com>
Diffstat (limited to 'ucbhelper')
-rw-r--r--ucbhelper/source/provider/providerhelper.cxx208
1 files changed, 97 insertions, 111 deletions
diff --git a/ucbhelper/source/provider/providerhelper.cxx b/ucbhelper/source/provider/providerhelper.cxx
index e4b6d4dab704..52935962f9be 100644
--- a/ucbhelper/source/provider/providerhelper.cxx
+++ b/ucbhelper/source/provider/providerhelper.cxx
@@ -280,47 +280,43 @@ bool ContentProviderImplHelper::renameAdditionalPropertySet(
// Get propertyset registry.
getAdditionalPropertySetRegistry();
- if ( m_pImpl->m_xPropertySetRegistry.is() )
+ if ( !m_pImpl->m_xPropertySetRegistry.is() )
+ return false;
+
+ uno::Reference< container::XNameAccess > xNameAccess(
+ m_pImpl->m_xPropertySetRegistry, uno::UNO_QUERY );
+ if ( !xNameAccess.is() )
+ return false;
+
+ uno::Sequence< OUString > aKeys
+ = xNameAccess->getElementNames();
+ if ( aKeys.hasElements() )
{
- uno::Reference< container::XNameAccess > xNameAccess(
- m_pImpl->m_xPropertySetRegistry, uno::UNO_QUERY );
- if ( xNameAccess.is() )
+ OUString aOldKeyWithSlash = rOldKey;
+ OUString aOldKeyWithoutSlash;
+ if ( !aOldKeyWithSlash.endsWith("/") )
{
- uno::Sequence< OUString > aKeys
- = xNameAccess->getElementNames();
- if ( aKeys.hasElements() )
+ aOldKeyWithSlash += "/";
+ aOldKeyWithoutSlash = rOldKey;
+ }
+ else if ( !rOldKey.isEmpty() )
+ aOldKeyWithoutSlash
+ = rOldKey.copy( 0, rOldKey.getLength() - 1 );
+
+ for ( const OUString& rKey : aKeys )
+ {
+ if ( rKey.startsWith( aOldKeyWithSlash )
+ || rKey == aOldKeyWithoutSlash )
{
- OUString aOldKeyWithSlash = rOldKey;
- OUString aOldKeyWithoutSlash;
- if ( !aOldKeyWithSlash.endsWith("/") )
- {
- aOldKeyWithSlash += "/";
- aOldKeyWithoutSlash = rOldKey;
- }
- else if ( !rOldKey.isEmpty() )
- aOldKeyWithoutSlash
- = rOldKey.copy( 0, rOldKey.getLength() - 1 );
-
- for ( const OUString& rKey : aKeys )
- {
- if ( rKey.startsWith( aOldKeyWithSlash )
- || rKey == aOldKeyWithoutSlash )
- {
- OUString aNewKey
- = rKey.replaceAt(
- 0, rOldKey.getLength(), rNewKey );
- if ( !renameAdditionalPropertySet(
- rKey, aNewKey, false ) )
- return false;
- }
- }
+ OUString aNewKey
+ = rKey.replaceAt(
+ 0, rOldKey.getLength(), rNewKey );
+ if ( !renameAdditionalPropertySet(
+ rKey, aNewKey, false ) )
+ return false;
}
}
- else
- return false;
}
- else
- return false;
}
else
{
@@ -332,13 +328,11 @@ bool ContentProviderImplHelper::renameAdditionalPropertySet(
// Rename property set.
uno::Reference< container::XNamed > xNamed(
xOldSet, uno::UNO_QUERY );
- if ( xNamed.is() )
- {
- // ??? throws no exceptions and has no return value ???
- xNamed->setName( rNewKey );
- }
- else
+ if ( !xNamed.is() )
return false;
+
+ // ??? throws no exceptions and has no return value ???
+ xNamed->setName( rNewKey );
}
}
return true;
@@ -359,47 +353,43 @@ bool ContentProviderImplHelper::copyAdditionalPropertySet(
// Get propertyset registry.
getAdditionalPropertySetRegistry();
- if ( m_pImpl->m_xPropertySetRegistry.is() )
+ if ( !m_pImpl->m_xPropertySetRegistry.is() )
+ return false;
+
+ uno::Reference< container::XNameAccess > xNameAccess(
+ m_pImpl->m_xPropertySetRegistry, uno::UNO_QUERY );
+ if ( !xNameAccess.is() )
+ return false;
+
+ uno::Sequence< OUString > aKeys
+ = xNameAccess->getElementNames();
+ if ( aKeys.hasElements() )
{
- uno::Reference< container::XNameAccess > xNameAccess(
- m_pImpl->m_xPropertySetRegistry, uno::UNO_QUERY );
- if ( xNameAccess.is() )
+ OUString aSrcKeyWithSlash = rSourceKey;
+ OUString aSrcKeyWithoutSlash;
+ if ( !aSrcKeyWithSlash.endsWith("/") )
{
- uno::Sequence< OUString > aKeys
- = xNameAccess->getElementNames();
- if ( aKeys.hasElements() )
+ aSrcKeyWithSlash += "/";
+ aSrcKeyWithoutSlash = rSourceKey;
+ }
+ else if ( !rSourceKey.isEmpty() )
+ aSrcKeyWithoutSlash = rSourceKey.copy(
+ 0, rSourceKey.getLength() - 1 );
+
+ for ( const OUString& rKey : aKeys )
+ {
+ if ( rKey.startsWith(aSrcKeyWithSlash )
+ || rKey == aSrcKeyWithoutSlash )
{
- OUString aSrcKeyWithSlash = rSourceKey;
- OUString aSrcKeyWithoutSlash;
- if ( !aSrcKeyWithSlash.endsWith("/") )
- {
- aSrcKeyWithSlash += "/";
- aSrcKeyWithoutSlash = rSourceKey;
- }
- else if ( !rSourceKey.isEmpty() )
- aSrcKeyWithoutSlash = rSourceKey.copy(
- 0, rSourceKey.getLength() - 1 );
-
- for ( const OUString& rKey : aKeys )
- {
- if ( rKey.startsWith(aSrcKeyWithSlash )
- || rKey == aSrcKeyWithoutSlash )
- {
- OUString aNewKey
- = rKey.replaceAt(
- 0, rSourceKey.getLength(), rTargetKey );
- if ( !copyAdditionalPropertySet(
- rKey, aNewKey, false ) )
- return false;
- }
- }
+ OUString aNewKey
+ = rKey.replaceAt(
+ 0, rSourceKey.getLength(), rTargetKey );
+ if ( !copyAdditionalPropertySet(
+ rKey, aNewKey, false ) )
+ return false;
}
}
- else
- return false;
}
- else
- return false;
}
else
{
@@ -483,54 +473,50 @@ bool ContentProviderImplHelper::removeAdditionalPropertySet(
// Get propertyset registry.
getAdditionalPropertySetRegistry();
- if ( m_pImpl->m_xPropertySetRegistry.is() )
+ if ( !m_pImpl->m_xPropertySetRegistry.is() )
+ return false;
+
+ uno::Reference< container::XNameAccess > xNameAccess(
+ m_pImpl->m_xPropertySetRegistry, uno::UNO_QUERY );
+ if ( !xNameAccess.is() )
+ return false;
+
+ uno::Sequence< OUString > aKeys
+ = xNameAccess->getElementNames();
+ if ( aKeys.hasElements() )
{
- uno::Reference< container::XNameAccess > xNameAccess(
- m_pImpl->m_xPropertySetRegistry, uno::UNO_QUERY );
- if ( xNameAccess.is() )
+ OUString aKeyWithSlash = rKey;
+ OUString aKeyWithoutSlash;
+ if ( !aKeyWithSlash.endsWith("/") )
{
- uno::Sequence< OUString > aKeys
- = xNameAccess->getElementNames();
- if ( aKeys.hasElements() )
+ aKeyWithSlash += "/";
+ aKeyWithoutSlash = rKey;
+ }
+ else if ( !rKey.isEmpty() )
+ aKeyWithoutSlash
+ = rKey.copy( 0, rKey.getLength() - 1 );
+
+ for ( const OUString& rCurrKey : aKeys )
+ {
+ if ( rCurrKey.startsWith(aKeyWithSlash )
+ || rCurrKey == aKeyWithoutSlash )
{
- OUString aKeyWithSlash = rKey;
- OUString aKeyWithoutSlash;
- if ( !aKeyWithSlash.endsWith("/") )
- {
- aKeyWithSlash += "/";
- aKeyWithoutSlash = rKey;
- }
- else if ( !rKey.isEmpty() )
- aKeyWithoutSlash
- = rKey.copy( 0, rKey.getLength() - 1 );
-
- for ( const OUString& rCurrKey : aKeys )
- {
- if ( rCurrKey.startsWith(aKeyWithSlash )
- || rCurrKey == aKeyWithoutSlash )
- {
- if ( !removeAdditionalPropertySet(
- rCurrKey, false ) )
- return false;
- }
- }
+ if ( !removeAdditionalPropertySet(
+ rCurrKey, false ) )
+ return false;
}
}
- else
- return false;
}
- else
- return false;
}
else
{
// Get propertyset registry.
getAdditionalPropertySetRegistry();
- if ( m_pImpl->m_xPropertySetRegistry.is() )
- m_pImpl->m_xPropertySetRegistry->removePropertySet( rKey );
- else
+ if ( !m_pImpl->m_xPropertySetRegistry.is() )
return false;
+
+ m_pImpl->m_xPropertySetRegistry->removePropertySet( rKey );
}
return true;
}