[Libreoffice-commits] core.git: 2 commits - scripting/source sfx2/source
Stephan Bergmann
sbergman at redhat.com
Wed Feb 15 14:17:55 UTC 2017
scripting/source/provider/MasterScriptProvider.cxx | 22 ++-------------------
sfx2/source/appl/imestatuswindow.cxx | 7 ------
sfx2/source/doc/guisaveas.cxx | 17 +++-------------
sfx2/source/doc/objstor.cxx | 12 +----------
sfx2/source/view/ipclient.cxx | 21 +++++---------------
5 files changed, 16 insertions(+), 63 deletions(-)
New commits:
commit c27586115d1df8b80cece6b03e333803c1a15b19
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Tue Feb 14 16:10:10 2017 +0100
Some simplifications, using UNO_QUERY_THROW
Change-Id: I705e4e7e8446a503e3ef0e2828a22554f94585c6
Reviewed-on: https://gerrit.libreoffice.org/34259
Tested-by: Stephan Bergmann <sbergman at redhat.com>
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/scripting/source/provider/MasterScriptProvider.cxx b/scripting/source/provider/MasterScriptProvider.cxx
index c469ba3..e1599be 100644
--- a/scripting/source/provider/MasterScriptProvider.cxx
+++ b/scripting/source/provider/MasterScriptProvider.cxx
@@ -473,12 +473,7 @@ MasterScriptProvider::insertByName( const OUString& aName, const Any& aElement )
{
if ( m_xMSPPkg.is() )
{
- Reference< container::XNameContainer > xCont( m_xMSPPkg, UNO_QUERY );
- if ( !xCont.is() )
- {
- throw RuntimeException(
- "PackageMasterScriptProvider doesn't implement XNameContainer" );
- }
+ Reference< container::XNameContainer > xCont( m_xMSPPkg, UNO_QUERY_THROW );
xCont->insertByName( aName, aElement );
}
else
@@ -552,12 +547,7 @@ MasterScriptProvider::removeByName( const OUString& Name )
{
if ( m_xMSPPkg.is() )
{
- Reference< container::XNameContainer > xCont( m_xMSPPkg, UNO_QUERY );
- if ( !xCont.is() )
- {
- throw RuntimeException(
- "PackageMasterScriptProvider doesn't implement XNameContainer" );
- }
+ Reference< container::XNameContainer > xCont( m_xMSPPkg, UNO_QUERY_THROW );
xCont->removeByName( Name );
}
else
@@ -651,13 +641,7 @@ MasterScriptProvider::hasByName( const OUString& aName )
{
if ( m_xMSPPkg.is() )
{
- Reference< container::XNameContainer > xCont( m_xMSPPkg, UNO_QUERY );
- if ( !xCont.is() )
- {
- throw RuntimeException(
- "PackageMasterScriptProvider doesn't implement XNameContainer" );
- }
-
+ Reference< container::XNameContainer > xCont( m_xMSPPkg, UNO_QUERY_THROW );
result = xCont->hasByName( aName );
}
// If this is a document provider then we shouldn't
commit 8b3a9d3055d261a3ba16932bf7f361e0ca5c77c2
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Tue Feb 14 16:10:07 2017 +0100
Some simplifications, using UNO_QUERY_THROW
Change-Id: Ida366e40ade98443019d3c312ae19864f93c9e5e
Reviewed-on: https://gerrit.libreoffice.org/34258
Tested-by: Stephan Bergmann <sbergman at redhat.com>
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/sfx2/source/appl/imestatuswindow.cxx b/sfx2/source/appl/imestatuswindow.cxx
index 4d46add..0e5bb44 100644
--- a/sfx2/source/appl/imestatuswindow.cxx
+++ b/sfx2/source/appl/imestatuswindow.cxx
@@ -205,12 +205,7 @@ css::uno::Reference< css::beans::XPropertySet > ImeStatusWindow::getConfig()
xProvider->createInstanceWithArguments(
"com.sun.star.configuration.ConfigurationUpdateAccess",
aArgs),
- css::uno::UNO_QUERY);
- if (!m_xConfig.is())
- throw css::uno::RuntimeException(
- "null com.sun.star.configuration."
- "ConfigurationUpdateAccess",
- nullptr);
+ css::uno::UNO_QUERY_THROW);
bAdd = true;
}
xConfig = m_xConfig;
diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx
index b465b54..8f08c35 100644
--- a/sfx2/source/doc/guisaveas.cxx
+++ b/sfx2/source/doc/guisaveas.cxx
@@ -395,9 +395,7 @@ uno::Reference< frame::XStorable > const & ModelData_Impl::GetStorable()
{
if ( !m_xStorable.is() )
{
- m_xStorable.set( m_xModel, uno::UNO_QUERY );
- if ( !m_xStorable.is() )
- throw uno::RuntimeException();
+ m_xStorable.set( m_xModel, uno::UNO_QUERY_THROW );
}
return m_xStorable;
@@ -408,9 +406,7 @@ uno::Reference< frame::XStorable2 > const & ModelData_Impl::GetStorable2()
{
if ( !m_xStorable2.is() )
{
- m_xStorable2.set( m_xModel, uno::UNO_QUERY );
- if ( !m_xStorable2.is() )
- throw uno::RuntimeException();
+ m_xStorable2.set( m_xModel, uno::UNO_QUERY_THROW );
}
return m_xStorable2;
@@ -1274,10 +1270,7 @@ uno::Reference< container::XNameAccess > const & SfxStoringHelper::GetFilterConf
if ( !m_xFilterCFG.is() )
{
m_xFilterCFG.set( comphelper::getProcessServiceFactory()->createInstance("com.sun.star.document.FilterFactory"),
- uno::UNO_QUERY );
-
- if ( !m_xFilterCFG.is() )
- throw uno::RuntimeException();
+ uno::UNO_QUERY_THROW );
}
return m_xFilterCFG;
@@ -1288,9 +1281,7 @@ uno::Reference< container::XContainerQuery > const & SfxStoringHelper::GetFilter
{
if ( !m_xFilterQuery.is() )
{
- m_xFilterQuery.set( GetFilterConfiguration(), uno::UNO_QUERY );
- if ( !m_xFilterQuery.is() )
- throw uno::RuntimeException();
+ m_xFilterQuery.set( GetFilterConfiguration(), uno::UNO_QUERY_THROW );
}
return m_xFilterQuery;
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index 92ad923..1bf7099 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -232,11 +232,7 @@ bool SfxObjectShell::PutURLContentsToVersionStream_Impl(
throw uno::RuntimeException();
uno::Reference< io::XOutputStream > xOutStream = xVerStream->getOutputStream();
- uno::Reference< io::XTruncate > xTrunc( xOutStream, uno::UNO_QUERY );
-
- DBG_ASSERT( xTrunc.is(), "The output stream must exist and implement XTruncate interface!\n" );
- if ( !xTrunc.is() )
- throw RuntimeException();
+ uno::Reference< io::XTruncate > xTrunc( xOutStream, uno::UNO_QUERY_THROW );
uno::Reference< io::XInputStream > xTmpInStream =
::comphelper::OStorageHelper::GetInputStreamFromURL(
@@ -1345,11 +1341,7 @@ bool SfxObjectShell::SaveTo_Impl
try
{
- uno::Reference< beans::XPropertySet > xProps( rMedium.GetStorage(), uno::UNO_QUERY );
- DBG_ASSERT( xProps.is(), "The storage implementation must implement XPropertySet!" );
- if ( !xProps.is() )
- throw uno::RuntimeException();
-
+ uno::Reference< beans::XPropertySet > xProps( rMedium.GetStorage(), uno::UNO_QUERY_THROW );
xProps->setPropertyValue("MediaType",
uno::makeAny( aDataFlavor.MimeType ) );
}
diff --git a/sfx2/source/view/ipclient.cxx b/sfx2/source/view/ipclient.cxx
index 41d6092..f35b41a 100644
--- a/sfx2/source/view/ipclient.cxx
+++ b/sfx2/source/view/ipclient.cxx
@@ -214,9 +214,7 @@ void SAL_CALL SfxInPlaceClient_Impl::saveObject()
return;
// the common persistence is supported by objects and links
- uno::Reference< embed::XCommonEmbedPersist > xPersist( m_xObject, uno::UNO_QUERY );
- if ( !xPersist.is() )
- throw uno::RuntimeException();
+ uno::Reference< embed::XCommonEmbedPersist > xPersist( m_xObject, uno::UNO_QUERY_THROW );
uno::Reference< frame::XFrame > xFrame;
uno::Reference< task::XStatusIndicator > xStatusIndicator;
@@ -363,9 +361,7 @@ void SAL_CALL SfxInPlaceClient_Impl::deactivatedUI()
uno::Reference< css::frame::XLayoutManager > SAL_CALL SfxInPlaceClient_Impl::getLayoutManager()
{
- uno::Reference < beans::XPropertySet > xFrame( GetFrame(), uno::UNO_QUERY );
- if ( !xFrame.is() )
- throw uno::RuntimeException();
+ uno::Reference < beans::XPropertySet > xFrame( GetFrame(), uno::UNO_QUERY_THROW );
uno::Reference< css::frame::XLayoutManager > xMan;
try
@@ -436,8 +432,8 @@ void SAL_CALL SfxInPlaceClient_Impl::scrollObject( const awt::Size& /*aOffset*/
void SAL_CALL SfxInPlaceClient_Impl::changedPlacement( const awt::Rectangle& aPosRect )
{
- uno::Reference< embed::XInplaceObject > xInplace( m_xObject, uno::UNO_QUERY );
- if ( !xInplace.is() || !m_pClient || !m_pClient->GetEditWin() || !m_pClient->GetViewShell() )
+ uno::Reference< embed::XInplaceObject > xInplace( m_xObject, uno::UNO_QUERY_THROW );
+ if ( !m_pClient || !m_pClient->GetEditWin() || !m_pClient->GetViewShell() )
throw uno::RuntimeException();
// check if the change is at least one pixel in size
@@ -493,10 +489,7 @@ uno::Reference< util::XCloseable > SAL_CALL SfxInPlaceClient_Impl::getComponent(
throw uno::RuntimeException();
// all the components must implement XCloseable
- uno::Reference< util::XCloseable > xComp( pDocShell->GetModel(), uno::UNO_QUERY );
- if ( !xComp.is() )
- throw uno::RuntimeException();
-
+ uno::Reference< util::XCloseable > xComp( pDocShell->GetModel(), uno::UNO_QUERY_THROW );
return xComp;
}
@@ -526,9 +519,7 @@ void SfxInPlaceClient_Impl::SizeHasChanged()
|| m_xObject->getCurrentState() == embed::EmbedStates::UI_ACTIVE ) )
{
// only possible in active states
- uno::Reference< embed::XInplaceObject > xInplace( m_xObject, uno::UNO_QUERY );
- if ( !xInplace.is() )
- throw uno::RuntimeException();
+ uno::Reference< embed::XInplaceObject > xInplace( m_xObject, uno::UNO_QUERY_THROW );
if ( m_bResizeNoScale )
{
More information about the Libreoffice-commits
mailing list