Kaydet (Commit) 08a943fc authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Get rid of trivial comphelper::query_interface wrapper

Change-Id: I2b9dafd2a34d055dcd8b8c4d894be30dc821d3be
üst 4592d27d
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include "ado/AConnection.hxx" #include "ado/AConnection.hxx"
#include "ado/AResultSet.hxx" #include "ado/AResultSet.hxx"
#include <comphelper/property.hxx> #include <comphelper/property.hxx>
#include <comphelper/uno3.hxx>
#include <osl/thread.h> #include <osl/thread.h>
#include <cppuhelper/typeprovider.hxx> #include <cppuhelper/typeprovider.hxx>
#include <cppuhelper/queryinterface.hxx> #include <cppuhelper/queryinterface.hxx>
...@@ -182,8 +181,9 @@ void OStatement_Base::clearMyResultSet () throw (SQLException) ...@@ -182,8 +181,9 @@ void OStatement_Base::clearMyResultSet () throw (SQLException)
try try
{ {
Reference<XCloseable> xCloseable; Reference<XCloseable> xCloseable(
if ( ::comphelper::query_interface( m_xResultSet.get(), xCloseable ) ) m_xResultSet.get(), css::uno::UNO_QUERY);
if ( xCloseable.is() )
xCloseable->close(); xCloseable->close();
} }
catch( const DisposedException& ) { } catch( const DisposedException& ) { }
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#include "odbc/OResultSet.hxx" #include "odbc/OResultSet.hxx"
#include <comphelper/property.hxx> #include <comphelper/property.hxx>
#include "odbc/OTools.hxx" #include "odbc/OTools.hxx"
#include <comphelper/uno3.hxx>
#include <osl/thread.h> #include <osl/thread.h>
#include <com/sun/star/sdbc/ResultSetConcurrency.hpp> #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
#include <com/sun/star/sdbc/ResultSetType.hpp> #include <com/sun/star/sdbc/ResultSetType.hpp>
...@@ -226,8 +225,9 @@ void OStatement_Base::clearMyResultSet() ...@@ -226,8 +225,9 @@ void OStatement_Base::clearMyResultSet()
try try
{ {
Reference<XCloseable> xCloseable; Reference<XCloseable> xCloseable(
if ( ::comphelper::query_interface( m_xResultSet.get(), xCloseable ) ) m_xResultSet.get(), css::uno::UNO_QUERY);
if ( xCloseable.is() )
xCloseable->close(); xCloseable->close();
} }
catch( const DisposedException& ) { } catch( const DisposedException& ) { }
......
...@@ -40,7 +40,7 @@ OComponentEventThread::OComponentEventThread( ::cppu::OComponentHelper* pCompImp ...@@ -40,7 +40,7 @@ OComponentEventThread::OComponentEventThread( ::cppu::OComponentHelper* pCompImp
// Hold a reference of the Control // Hold a reference of the Control
{ {
InterfaceRef xIFace(static_cast<XWeak*>(pCompImpl)); InterfaceRef xIFace(static_cast<XWeak*>(pCompImpl));
query_interface(xIFace, m_xComp); m_xComp.set(xIFace, css::uno::UNO_QUERY);
} }
// and add us at the Control // and add us at the Control
...@@ -189,7 +189,8 @@ void OComponentEventThread::run() ...@@ -189,7 +189,8 @@ void OComponentEventThread::run()
// the mutex is locked. // the mutex is locked.
Reference<XControl> xControl; Reference<XControl> xControl;
if ( xControlAdapter.is() ) if ( xControlAdapter.is() )
query_interface(xControlAdapter->queryAdapted(), xControl); xControl.set(
xControlAdapter->queryAdapted(), css::uno::UNO_QUERY);
if( xComp.is() ) if( xComp.is() )
processEvent( pCompImpl, pEvt.get(), xControl, bFlag ); processEvent( pCompImpl, pEvt.get(), xControl, bFlag );
......
...@@ -1748,8 +1748,8 @@ void OBoundControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, co ...@@ -1748,8 +1748,8 @@ void OBoundControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, co
} }
// Check if we and the given model have a common ancestor (up to the forms collection) // Check if we and the given model have a common ancestor (up to the forms collection)
Reference<XChild> xCont; Reference<XChild> xCont(
query_interface(static_cast<XWeak*>(this), xCont); static_cast<XWeak*>(this), css::uno::UNO_QUERY);
Reference< XInterface > xMyTopLevel = xCont->getParent(); Reference< XInterface > xMyTopLevel = xCont->getParent();
while (xMyTopLevel.is()) while (xMyTopLevel.is())
{ {
......
...@@ -509,8 +509,9 @@ Reference< XNumberFormatsSupplier > OFormattedModel::calcFormatsSupplier() const ...@@ -509,8 +509,9 @@ Reference< XNumberFormatsSupplier > OFormattedModel::calcFormatsSupplier() const
Reference<XNumberFormatsSupplier> OFormattedModel::calcFormFormatsSupplier() const Reference<XNumberFormatsSupplier> OFormattedModel::calcFormFormatsSupplier() const
{ {
Reference<XChild> xMe; Reference<XChild> xMe(
query_interface(static_cast<XWeak*>(const_cast<OFormattedModel*>(this)), xMe); static_cast<XWeak*>(const_cast<OFormattedModel*>(this)),
css::uno::UNO_QUERY);
// By this we make sure that we get the right object even when aggregating // By this we make sure that we get the right object even when aggregating
DBG_ASSERT(xMe.is(), "OFormattedModel::calcFormFormatsSupplier : I should have a content interface !"); DBG_ASSERT(xMe.is(), "OFormattedModel::calcFormFormatsSupplier : I should have a content interface !");
// Iterate through until we reach a StartForm (starting with an own Parent) // Iterate through until we reach a StartForm (starting with an own Parent)
......
...@@ -55,17 +55,17 @@ InterfaceRef OFormattedFieldWrapper::createFormattedFieldWrapper(const ::com::su ...@@ -55,17 +55,17 @@ InterfaceRef OFormattedFieldWrapper::createFormattedFieldWrapper(const ::com::su
if (bActAsFormatted) if (bActAsFormatted)
{ {
// instantiate an FormattedModel // instantiate an FormattedModel
InterfaceRef xFormattedModel;
// (instantiate it directly ..., as the OFormattedModel isn't // (instantiate it directly ..., as the OFormattedModel isn't
// registered for any service names anymore) // registered for any service names anymore)
OFormattedModel* pModel = new OFormattedModel(pRef->m_xContext); OFormattedModel* pModel = new OFormattedModel(pRef->m_xContext);
query_interface(static_cast<XWeak*>(pModel), xFormattedModel); InterfaceRef xFormattedModel(
static_cast<XWeak*>(pModel), css::uno::UNO_QUERY);
pRef->m_xAggregate = Reference<XAggregation> (xFormattedModel, UNO_QUERY); pRef->m_xAggregate = Reference<XAggregation> (xFormattedModel, UNO_QUERY);
OSL_ENSURE(pRef->m_xAggregate.is(), "the OFormattedModel didn't have an XAggregation interface !"); OSL_ENSURE(pRef->m_xAggregate.is(), "the OFormattedModel didn't have an XAggregation interface !");
// _before_ setting the delegator, give it to the member references // _before_ setting the delegator, give it to the member references
query_interface(xFormattedModel, pRef->m_xFormattedPart); pRef->m_xFormattedPart.set(xFormattedModel, css::uno::UNO_QUERY);
pRef->m_pEditPart = rtl::Reference< OEditModel >(new OEditModel(pRef->m_xContext)); pRef->m_pEditPart = rtl::Reference< OEditModel >(new OEditModel(pRef->m_xContext));
} }
...@@ -98,7 +98,8 @@ Reference< XCloneable > SAL_CALL OFormattedFieldWrapper::createClone() throw (Ru ...@@ -98,7 +98,8 @@ Reference< XCloneable > SAL_CALL OFormattedFieldWrapper::createClone() throw (Ru
xRef->m_xAggregate = Reference< XAggregation >(xClone, UNO_QUERY); xRef->m_xAggregate = Reference< XAggregation >(xClone, UNO_QUERY);
OSL_ENSURE(xRef->m_xAggregate.is(), "invalid aggregate cloned !"); OSL_ENSURE(xRef->m_xAggregate.is(), "invalid aggregate cloned !");
query_interface( Reference< XInterface >(xClone.get() ), xRef->m_xFormattedPart); xRef->m_xFormattedPart.set(
Reference< XInterface >(xClone.get()), css::uno::UNO_QUERY);
if ( m_pEditPart.is() ) if ( m_pEditPart.is() )
{ {
...@@ -217,8 +218,8 @@ void SAL_CALL OFormattedFieldWrapper::write(const Reference<XObjectOutputStream> ...@@ -217,8 +218,8 @@ void SAL_CALL OFormattedFieldWrapper::write(const Reference<XObjectOutputStream>
// for this we transfer the current props of the formatted part to the edit part // for this we transfer the current props of the formatted part to the edit part
Reference<XPropertySet> xFormatProps(m_xFormattedPart, UNO_QUERY); Reference<XPropertySet> xFormatProps(m_xFormattedPart, UNO_QUERY);
Reference<XPropertySet> xEditProps; Reference<XPropertySet> xEditProps(
query_interface(static_cast<XWeak*>(m_pEditPart.get()), xEditProps); static_cast<XWeak*>(m_pEditPart.get()), css::uno::UNO_QUERY);
Locale aAppLanguage = Application::GetSettings().GetUILanguageTag().getLocale(); Locale aAppLanguage = Application::GetSettings().GetUILanguageTag().getLocale();
dbtools::TransferFormComponentProperties(xFormatProps, xEditProps, aAppLanguage); dbtools::TransferFormComponentProperties(xFormatProps, xEditProps, aAppLanguage);
...@@ -317,7 +318,7 @@ void OFormattedFieldWrapper::ensureAggregate() ...@@ -317,7 +318,7 @@ void OFormattedFieldWrapper::ensureAggregate()
{ {
// arghhh ... instantiate it directly ... it's dirty, but we really need this aggregate // arghhh ... instantiate it directly ... it's dirty, but we really need this aggregate
OEditModel* pModel = new OEditModel(m_xContext); OEditModel* pModel = new OEditModel(m_xContext);
query_interface(static_cast<XWeak*>(pModel), xEditModel); xEditModel.set(static_cast<XWeak*>(pModel), css::uno::UNO_QUERY);
} }
m_xAggregate = Reference<XAggregation> (xEditModel, UNO_QUERY); m_xAggregate = Reference<XAggregation> (xEditModel, UNO_QUERY);
......
...@@ -149,8 +149,8 @@ void ORadioButtonModel::SetSiblingPropsTo(const OUString& rPropName, const Any& ...@@ -149,8 +149,8 @@ void ORadioButtonModel::SetSiblingPropsTo(const OUString& rPropName, const Any&
Reference<XIndexAccess> xIndexAccess(getParent(), UNO_QUERY); Reference<XIndexAccess> xIndexAccess(getParent(), UNO_QUERY);
if (xIndexAccess.is()) if (xIndexAccess.is())
{ {
Reference<XPropertySet> xMyProps; Reference<XPropertySet> xMyProps(
query_interface(static_cast<XWeak*>(this), xMyProps); static_cast<XWeak*>(this), css::uno::UNO_QUERY);
OUString sCurrentGroup; OUString sCurrentGroup;
sal_Int32 nNumSiblings = xIndexAccess->getCount(); sal_Int32 nNumSiblings = xIndexAccess->getCount();
for (sal_Int32 i=0; i<nNumSiblings; ++i) for (sal_Int32 i=0; i<nNumSiblings; ++i)
...@@ -226,8 +226,8 @@ void ORadioButtonModel::setControlSource() ...@@ -226,8 +226,8 @@ void ORadioButtonModel::setControlSource()
this->getPropertyValue(PROPERTY_GROUP_NAME) >>= sGroupName; this->getPropertyValue(PROPERTY_GROUP_NAME) >>= sGroupName;
this->getPropertyValue(PROPERTY_NAME) >>= sName; this->getPropertyValue(PROPERTY_NAME) >>= sName;
Reference<XPropertySet> xMyProps; Reference<XPropertySet> xMyProps(
query_interface(static_cast<XWeak*>(this), xMyProps); static_cast<XWeak*>(this), css::uno::UNO_QUERY);
for (sal_Int32 i=0; i<xIndexAccess->getCount(); ++i) for (sal_Int32 i=0; i<xIndexAccess->getCount(); ++i)
{ {
Reference<XPropertySet> xSiblingProperties(*static_cast<InterfaceRef const *>(xIndexAccess->getByIndex(i).getValue()), UNO_QUERY); Reference<XPropertySet> xSiblingProperties(*static_cast<InterfaceRef const *>(xIndexAccess->getByIndex(i).getValue()), UNO_QUERY);
......
...@@ -738,7 +738,7 @@ namespace frm ...@@ -738,7 +738,7 @@ namespace frm
{ {
Reference<XChild> xChild( xIfc, UNO_QUERY ); Reference<XChild> xChild( xIfc, UNO_QUERY );
xIfc = xChild->getParent(); xIfc = xChild->getParent();
query_interface(xIfc, xModel); xModel.set(xIfc, css::uno::UNO_QUERY);
} }
// Search for the Object shell by iterating over all Object shells // Search for the Object shell by iterating over all Object shells
......
...@@ -180,31 +180,6 @@ namespace comphelper ...@@ -180,31 +180,6 @@ namespace comphelper
} }
return _rxOut.is(); return _rxOut.is();
} }
/** ask for an iface of an object
usage:<br/>
Reference<XFoo> xFoo;<br/>
if (query_interface(xAnything, xFoo))<br/>
....
*/
template <class iface>
bool query_interface(const InterfaceRef& _rxObject, ::com::sun::star::uno::Reference<iface>& _rxOut)
{
_rxOut = static_cast<iface*>(NULL);
if (_rxObject.is())
{
::com::sun::star::uno::Any aCheck = _rxObject->queryInterface(
cppu::UnoType<iface>::get());
if(aCheck.hasValue())
{
_rxOut = *static_cast<const ::com::sun::star::uno::Reference<iface>*>(aCheck.getValue());
return _rxOut.is();
}
}
return false;
}
} // namespace comphelper } // namespace comphelper
......
...@@ -431,7 +431,8 @@ namespace ...@@ -431,7 +431,8 @@ namespace
sReturn = sCurrentIndex; sReturn = sCurrentIndex;
// travel up // travel up
if (::comphelper::query_interface(Reference< XInterface >(xParent),xChild)) xChild.set(xParent, css::uno::UNO_QUERY);
if (xChild.is())
xParent = Reference< ::com::sun::star::container::XIndexAccess>(xChild->getParent(), UNO_QUERY); xParent = Reference< ::com::sun::star::container::XIndexAccess>(xChild->getParent(), UNO_QUERY);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment