summaryrefslogtreecommitdiff
path: root/embeddedobj
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-09-21 11:06:43 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-09-21 15:29:20 +0200
commit3a481dde031ba416ec4ef0351130e26e49417418 (patch)
treeabfec5320c66e8c28b3da01852c531ef4a7ce0eb /embeddedobj
parentac80f048f2bb23651ddc3c6608e9ef24635698d7 (diff)
loplugin:flatten in editeng..extensions
Change-Id: I2b68f5640471ea827c09af1b5a319fb526a53b4b Reviewed-on: https://gerrit.libreoffice.org/42579 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'embeddedobj')
-rw-r--r--embeddedobj/source/commonembedding/embedobj.cxx119
-rw-r--r--embeddedobj/source/commonembedding/persistence.cxx31
-rw-r--r--embeddedobj/source/commonembedding/specialobject.cxx5
-rw-r--r--embeddedobj/source/commonembedding/visobj.cxx9
-rw-r--r--embeddedobj/source/commonembedding/xfactory.cxx150
-rw-r--r--embeddedobj/source/msole/olevisual.cxx9
6 files changed, 146 insertions, 177 deletions
diff --git a/embeddedobj/source/commonembedding/embedobj.cxx b/embeddedobj/source/commonembedding/embedobj.cxx
index f85ce88c133e..d24533a63146 100644
--- a/embeddedobj/source/commonembedding/embedobj.cxx
+++ b/embeddedobj/source/commonembedding/embedobj.cxx
@@ -230,33 +230,30 @@ void OCommonEmbeddedObject::SwitchStateTo_Impl( sal_Int32 nNextState )
throw embed::WrongStateException( "client site not set, yet", *this );
uno::Reference< embed::XInplaceClient > xInplaceClient( m_xClientSite, uno::UNO_QUERY );
- if ( xInplaceClient.is() && xInplaceClient->canInplaceActivate() )
- {
- xInplaceClient->activatingInplace();
+ if ( !xInplaceClient.is() || !xInplaceClient->canInplaceActivate() )
+ throw embed::WrongStateException(); //TODO: can't activate inplace
+ xInplaceClient->activatingInplace();
- uno::Reference< embed::XWindowSupplier > xClientWindowSupplier( xInplaceClient, uno::UNO_QUERY_THROW );
+ uno::Reference< embed::XWindowSupplier > xClientWindowSupplier( xInplaceClient, uno::UNO_QUERY_THROW );
- m_xClientWindow = xClientWindowSupplier->getWindow();
- m_aOwnRectangle = xInplaceClient->getPlacement();
- m_aClipRectangle = xInplaceClient->getClipRectangle();
- awt::Rectangle aRectangleToShow = GetRectangleInterception( m_aOwnRectangle, m_aClipRectangle );
+ m_xClientWindow = xClientWindowSupplier->getWindow();
+ m_aOwnRectangle = xInplaceClient->getPlacement();
+ m_aClipRectangle = xInplaceClient->getClipRectangle();
+ awt::Rectangle aRectangleToShow = GetRectangleInterception( m_aOwnRectangle, m_aClipRectangle );
- // create own window based on the client window
- // place and resize the window according to the rectangles
- uno::Reference< awt::XWindowPeer > xClientWindowPeer( m_xClientWindow, uno::UNO_QUERY_THROW );
+ // create own window based on the client window
+ // place and resize the window according to the rectangles
+ uno::Reference< awt::XWindowPeer > xClientWindowPeer( m_xClientWindow, uno::UNO_QUERY_THROW );
- // dispatch provider may not be provided
- uno::Reference< frame::XDispatchProvider > xContainerDP = xInplaceClient->getInplaceDispatchProvider();
- bool bOk = m_xDocHolder->ShowInplace( xClientWindowPeer, aRectangleToShow, xContainerDP );
- m_nObjectState = nNextState;
- if ( !bOk )
- {
- SwitchStateTo_Impl( embed::EmbedStates::RUNNING );
- throw embed::WrongStateException(); //TODO: can't activate inplace
- }
- }
- else
+ // dispatch provider may not be provided
+ uno::Reference< frame::XDispatchProvider > xContainerDP = xInplaceClient->getInplaceDispatchProvider();
+ bool bOk = m_xDocHolder->ShowInplace( xClientWindowPeer, aRectangleToShow, xContainerDP );
+ m_nObjectState = nNextState;
+ if ( !bOk )
+ {
+ SwitchStateTo_Impl( embed::EmbedStates::RUNNING );
throw embed::WrongStateException(); //TODO: can't activate inplace
+ }
}
else if ( nNextState == embed::EmbedStates::ACTIVE )
{
@@ -296,45 +293,42 @@ void OCommonEmbeddedObject::SwitchStateTo_Impl( sal_Int32 nNextState )
// TODO:
uno::Reference< css::frame::XLayoutManager > xContainerLM =
xInplaceClient->getLayoutManager();
- if ( xContainerLM.is() )
+ if ( !xContainerLM.is() )
+ throw embed::WrongStateException(); //TODO: can't activate UI
+ // dispatch provider may not be provided
+ uno::Reference< frame::XDispatchProvider > xContainerDP = xInplaceClient->getInplaceDispatchProvider();
+
+ // get the container module name
+ OUString aModuleName;
+ try
{
- // dispatch provider may not be provided
- uno::Reference< frame::XDispatchProvider > xContainerDP = xInplaceClient->getInplaceDispatchProvider();
-
- // get the container module name
- OUString aModuleName;
- try
- {
- uno::Reference< embed::XComponentSupplier > xCompSupl( m_xClientSite, uno::UNO_QUERY_THROW );
- uno::Reference< uno::XInterface > xContDoc( xCompSupl->getComponent(), uno::UNO_QUERY_THROW );
-
- uno::Reference< frame::XModuleManager2 > xManager( frame::ModuleManager::create( m_xContext ) );
-
- aModuleName = xManager->identify( xContDoc );
- }
- catch( const uno::Exception& )
- {}
-
- // if currently another object is UIactive it will be deactivated; usually this will activate the LM of
- // the container. Locking the LM will prevent flicker.
- xContainerLM->lock();
- xInplaceClient->activatingUI();
- bool bOk = m_xDocHolder->ShowUI( xContainerLM, xContainerDP, aModuleName );
- xContainerLM->unlock();
-
- if ( bOk )
- {
- m_nObjectState = nNextState;
- m_xDocHolder->ResizeHatchWindow();
- }
- else
- {
- xInplaceClient->deactivatedUI();
- throw embed::WrongStateException(); //TODO: can't activate UI
- }
+ uno::Reference< embed::XComponentSupplier > xCompSupl( m_xClientSite, uno::UNO_QUERY_THROW );
+ uno::Reference< uno::XInterface > xContDoc( xCompSupl->getComponent(), uno::UNO_QUERY_THROW );
+
+ uno::Reference< frame::XModuleManager2 > xManager( frame::ModuleManager::create( m_xContext ) );
+
+ aModuleName = xManager->identify( xContDoc );
+ }
+ catch( const uno::Exception& )
+ {}
+
+ // if currently another object is UIactive it will be deactivated; usually this will activate the LM of
+ // the container. Locking the LM will prevent flicker.
+ xContainerLM->lock();
+ xInplaceClient->activatingUI();
+ bool bOk = m_xDocHolder->ShowUI( xContainerLM, xContainerDP, aModuleName );
+ xContainerLM->unlock();
+
+ if ( bOk )
+ {
+ m_nObjectState = nNextState;
+ m_xDocHolder->ResizeHatchWindow();
}
else
+ {
+ xInplaceClient->deactivatedUI();
throw embed::WrongStateException(); //TODO: can't activate UI
+ }
}
}
else
@@ -368,14 +362,11 @@ void OCommonEmbeddedObject::SwitchStateTo_Impl( sal_Int32 nNextState )
if ( xContainerLM.is() )
bOk = m_xDocHolder->HideUI( xContainerLM );
- if ( bOk )
- {
- m_nObjectState = nNextState;
- m_xDocHolder->ResizeHatchWindow();
- xInplaceClient->deactivatedUI();
- }
- else
+ if ( !bOk )
throw embed::WrongStateException(); //TODO: can't activate UI
+ m_nObjectState = nNextState;
+ m_xDocHolder->ResizeHatchWindow();
+ xInplaceClient->deactivatedUI();
}
}
else
diff --git a/embeddedobj/source/commonembedding/persistence.cxx b/embeddedobj/source/commonembedding/persistence.cxx
index ba5a3fde2c6e..2a5d09bfeb94 100644
--- a/embeddedobj/source/commonembedding/persistence.cxx
+++ b/embeddedobj/source/commonembedding/persistence.cxx
@@ -953,26 +953,23 @@ void SAL_CALL OCommonEmbeddedObject::setPersistentEntry(
if ( m_bWaitSaveCompleted )
{
- if ( nEntryConnectionMode == embed::EntryInitModes::NO_INIT )
- {
- // saveCompleted is expected, handle it accordingly
- if ( m_xNewParentStorage == xStorage && m_aNewEntryName == sEntName )
- {
- saveCompleted( true );
- return;
- }
-
- // if a completely different entry is provided, switch first back to the old persistence in saveCompleted
- // and then switch to the target persistence
- bool bSwitchFurther = ( m_xParentStorage != xStorage || m_aEntryName != sEntName );
- saveCompleted( false );
- if ( !bSwitchFurther )
- return;
- }
- else
+ if ( nEntryConnectionMode != embed::EntryInitModes::NO_INIT )
throw embed::WrongStateException(
"The object waits for saveCompleted() call!",
static_cast< ::cppu::OWeakObject* >(this) );
+ // saveCompleted is expected, handle it accordingly
+ if ( m_xNewParentStorage == xStorage && m_aNewEntryName == sEntName )
+ {
+ saveCompleted( true );
+ return;
+ }
+
+ // if a completely different entry is provided, switch first back to the old persistence in saveCompleted
+ // and then switch to the target persistence
+ bool bSwitchFurther = ( m_xParentStorage != xStorage || m_aEntryName != sEntName );
+ saveCompleted( false );
+ if ( !bSwitchFurther )
+ return;
}
// for now support of this interface is required to allow breaking of links and converting them to normal embedded
diff --git a/embeddedobj/source/commonembedding/specialobject.cxx b/embeddedobj/source/commonembedding/specialobject.cxx
index e6f04fdf5b06..24100fa7465d 100644
--- a/embeddedobj/source/commonembedding/specialobject.cxx
+++ b/embeddedobj/source/commonembedding/specialobject.cxx
@@ -163,10 +163,9 @@ void SAL_CALL OSpecialEmbeddedObject::doVerb( sal_Int32 nVerbID )
{
uno::Reference < ui::dialogs::XExecutableDialog > xDlg( m_xDocHolder->GetComponent(), uno::UNO_QUERY );
- if ( xDlg.is() )
- xDlg->execute();
- else
+ if ( !xDlg.is() )
throw embed::UnreachableStateException();
+ xDlg->execute();
}
else
OCommonEmbeddedObject::doVerb( nVerbID );
diff --git a/embeddedobj/source/commonembedding/visobj.cxx b/embeddedobj/source/commonembedding/visobj.cxx
index 7ed1bdcc029e..431f871fe492 100644
--- a/embeddedobj/source/commonembedding/visobj.cxx
+++ b/embeddedobj/source/commonembedding/visobj.cxx
@@ -193,13 +193,10 @@ embed::VisualRepresentation SAL_CALL OCommonEmbeddedObject::getPreferredVisualRe
"GDIMetaFile",
cppu::UnoType<uno::Sequence< sal_Int8 >>::get() );
- if( xTransferable->isDataFlavorSupported( aDataFlavor ))
- {
- aVisualRepresentation.Data = xTransferable->getTransferData( aDataFlavor );
- aVisualRepresentation.Flavor = aDataFlavor;
- }
- else
+ if( !xTransferable->isDataFlavorSupported( aDataFlavor ))
throw uno::RuntimeException();
+ aVisualRepresentation.Data = xTransferable->getTransferData( aDataFlavor );
+ aVisualRepresentation.Flavor = aDataFlavor;
}
if ( bBackToLoaded )
diff --git a/embeddedobj/source/commonembedding/xfactory.cxx b/embeddedobj/source/commonembedding/xfactory.cxx
index a361190c580f..caf009f80a27 100644
--- a/embeddedobj/source/commonembedding/xfactory.cxx
+++ b/embeddedobj/source/commonembedding/xfactory.cxx
@@ -78,52 +78,49 @@ uno::Reference< uno::XInterface > SAL_CALL OOoEmbeddedObjectFactory::createInsta
throw container::NoSuchElementException();
uno::Reference< uno::XInterface > xResult;
- if ( xStorage->isStorageElement( sEntName ) )
- {
- // the object must be based on storage
- uno::Reference< embed::XStorage > xSubStorage =
- xStorage->openStorageElement( sEntName, embed::ElementModes::READ );
-
- uno::Reference< beans::XPropertySet > xPropSet( xSubStorage, uno::UNO_QUERY_THROW );
-
- OUString aMediaType;
- try {
- uno::Any aAny = xPropSet->getPropertyValue("MediaType");
- aAny >>= aMediaType;
- }
- catch ( const uno::Exception& )
- {
- }
-
- try {
- uno::Reference< lang::XComponent > xComp( xSubStorage, uno::UNO_QUERY );
- if ( xComp.is() )
- xComp->dispose();
- }
- catch ( const uno::Exception& )
- {
- }
- xSubStorage.clear();
-
- uno::Sequence< beans::NamedValue > aObject = m_aConfigHelper.GetObjectPropsByMediaType( aMediaType );
-
- // If the sequence is empty, fall back to the FileFormatVersion=6200 filter, Base only has that.
- if (!aObject.hasElements() && aMediaType == MIMETYPE_OASIS_OPENDOCUMENT_DATABASE_ASCII)
- aObject = m_aConfigHelper.GetObjectPropsByMediaType(MIMETYPE_VND_SUN_XML_BASE_ASCII);
-
- if ( !aObject.getLength() )
- throw io::IOException(); // unexpected mimetype of the storage
-
- xResult.set(static_cast< ::cppu::OWeakObject* > ( new OCommonEmbeddedObject(
- m_xContext,
- aObject ) ),
- uno::UNO_QUERY );
- }
- else
+ if ( !xStorage->isStorageElement( sEntName ) )
{
// the object must be OOo embedded object, if it is not an exception must be thrown
throw io::IOException(); // TODO:
}
+ // the object must be based on storage
+ uno::Reference< embed::XStorage > xSubStorage =
+ xStorage->openStorageElement( sEntName, embed::ElementModes::READ );
+
+ uno::Reference< beans::XPropertySet > xPropSet( xSubStorage, uno::UNO_QUERY_THROW );
+
+ OUString aMediaType;
+ try {
+ uno::Any aAny = xPropSet->getPropertyValue("MediaType");
+ aAny >>= aMediaType;
+ }
+ catch ( const uno::Exception& )
+ {
+ }
+
+ try {
+ uno::Reference< lang::XComponent > xComp( xSubStorage, uno::UNO_QUERY );
+ if ( xComp.is() )
+ xComp->dispose();
+ }
+ catch ( const uno::Exception& )
+ {
+ }
+ xSubStorage.clear();
+
+ uno::Sequence< beans::NamedValue > aObject = m_aConfigHelper.GetObjectPropsByMediaType( aMediaType );
+
+ // If the sequence is empty, fall back to the FileFormatVersion=6200 filter, Base only has that.
+ if (!aObject.hasElements() && aMediaType == MIMETYPE_OASIS_OPENDOCUMENT_DATABASE_ASCII)
+ aObject = m_aConfigHelper.GetObjectPropsByMediaType(MIMETYPE_VND_SUN_XML_BASE_ASCII);
+
+ if ( !aObject.getLength() )
+ throw io::IOException(); // unexpected mimetype of the storage
+
+ xResult.set(static_cast< ::cppu::OWeakObject* > ( new OCommonEmbeddedObject(
+ m_xContext,
+ aObject ) ),
+ uno::UNO_QUERY );
uno::Reference< embed::XEmbedPersist > xPersist( xResult, uno::UNO_QUERY_THROW );
@@ -160,23 +157,20 @@ uno::Reference< uno::XInterface > SAL_CALL OOoEmbeddedObjectFactory::createInsta
uno::Reference< uno::XInterface > xResult;
// find document service name
- if ( !aFilterName.isEmpty() )
- {
- uno::Sequence< beans::NamedValue > aObject = m_aConfigHelper.GetObjectPropsByFilter( aFilterName );
- if ( !aObject.getLength() )
- throw io::IOException(); // unexpected mimetype of the storage
-
-
- xResult.set(static_cast< ::cppu::OWeakObject* > ( new OCommonEmbeddedObject(
- m_xContext,
- aObject ) ),
- uno::UNO_QUERY );
- }
- else
+ if ( aFilterName.isEmpty() )
{
// the object must be OOo embedded object, if it is not an exception must be thrown
throw io::IOException(); // TODO:
}
+ uno::Sequence< beans::NamedValue > aObject = m_aConfigHelper.GetObjectPropsByFilter( aFilterName );
+ if ( !aObject.getLength() )
+ throw io::IOException(); // unexpected mimetype of the storage
+
+
+ xResult.set(static_cast< ::cppu::OWeakObject* > ( new OCommonEmbeddedObject(
+ m_xContext,
+ aObject ) ),
+ uno::UNO_QUERY );
uno::Reference< embed::XEmbedPersist > xPersist( xResult, uno::UNO_QUERY_THROW );
@@ -301,25 +295,22 @@ uno::Reference< uno::XInterface > SAL_CALL OOoEmbeddedObjectFactory::createInsta
OUString aFilterName = m_aConfigHelper.UpdateMediaDescriptorWithFilterName( aTempMedDescr, false );
- if ( !aFilterName.isEmpty() )
- {
- uno::Sequence< beans::NamedValue > aObject = m_aConfigHelper.GetObjectPropsByFilter( aFilterName );
- if ( !aObject.getLength() )
- throw io::IOException(); // unexpected mimetype of the storage
-
-
- xResult.set(static_cast< ::cppu::OWeakObject* > ( new OCommonEmbeddedObject(
- m_xContext,
- aObject,
- aTempMedDescr,
- lObjArgs ) ),
- uno::UNO_QUERY );
- }
- else
+ if ( aFilterName.isEmpty() )
{
// the object must be OOo embedded object, if it is not an exception must be thrown
throw io::IOException(); // TODO:
}
+ uno::Sequence< beans::NamedValue > aObject = m_aConfigHelper.GetObjectPropsByFilter( aFilterName );
+ if ( !aObject.getLength() )
+ throw io::IOException(); // unexpected mimetype of the storage
+
+
+ xResult.set(static_cast< ::cppu::OWeakObject* > ( new OCommonEmbeddedObject(
+ m_xContext,
+ aObject,
+ aTempMedDescr,
+ lObjArgs ) ),
+ uno::UNO_QUERY );
return xResult;
}
@@ -363,22 +354,19 @@ uno::Reference< uno::XInterface > SAL_CALL OOoEmbeddedObjectFactory::createInsta
OUString aFilterName = m_aConfigHelper.UpdateMediaDescriptorWithFilterName( aTempMedDescr, aObject );
- if ( !aFilterName.isEmpty() )
- {
-
- xResult.set(static_cast< ::cppu::OWeakObject* > ( new OCommonEmbeddedObject(
- m_xContext,
- aObject,
- aTempMedDescr,
- lObjArgs ) ),
- uno::UNO_QUERY );
- }
- else
+ if ( aFilterName.isEmpty() )
{
// the object must be OOo embedded object, if it is not an exception must be thrown
throw io::IOException(); // TODO:
}
+ xResult.set(static_cast< ::cppu::OWeakObject* > ( new OCommonEmbeddedObject(
+ m_xContext,
+ aObject,
+ aTempMedDescr,
+ lObjArgs ) ),
+ uno::UNO_QUERY );
+
return xResult;
}
diff --git a/embeddedobj/source/msole/olevisual.cxx b/embeddedobj/source/msole/olevisual.cxx
index ace3ee94aa0f..49e41275c93b 100644
--- a/embeddedobj/source/msole/olevisual.cxx
+++ b/embeddedobj/source/msole/olevisual.cxx
@@ -296,17 +296,14 @@ awt::Size SAL_CALL OleEmbeddedObject::getVisualAreaSize( sal_Int64 nAspect )
#endif
{
// return cached value
- if ( m_bHasCachedSize )
- {
- SAL_WARN_IF( nAspect != m_nCachedAspect, "embeddedobj.ole", "Unexpected aspect is requested!" );
- aResult = m_aCachedSize;
- }
- else
+ if ( !m_bHasCachedSize )
{
throw embed::NoVisualAreaSizeException(
"No size available!",
static_cast< ::cppu::OWeakObject* >(this) );
}
+ SAL_WARN_IF( nAspect != m_nCachedAspect, "embeddedobj.ole", "Unexpected aspect is requested!" );
+ aResult = m_aCachedSize;
}
return aResult;