From 177afb1ec39d3ac9c66c7dfdc51ef9ad22e7b752 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Fri, 10 Jun 2016 18:55:25 +0200 Subject: Clean up uses of Any::getValue() in extensions Change-Id: I67b9127d8aa67a702086ef5bc61372ae54c2142e --- extensions/source/bibliography/bibconfig.cxx | 3 ++- extensions/source/bibliography/bibload.cxx | 7 +++---- extensions/source/bibliography/datman.cxx | 22 +++++++++++----------- extensions/source/bibliography/general.cxx | 3 +-- extensions/source/bibliography/toolbar.cxx | 17 +++++++---------- 5 files changed, 24 insertions(+), 28 deletions(-) (limited to 'extensions') diff --git a/extensions/source/bibliography/bibconfig.cxx b/extensions/source/bibliography/bibconfig.cxx index a5d9733b8301..3661903d9219 100644 --- a/extensions/source/bibliography/bibconfig.cxx +++ b/extensions/source/bibliography/bibconfig.cxx @@ -25,6 +25,7 @@ #include #include #include +#include #include using namespace ::com::sun::star::uno; @@ -116,7 +117,7 @@ BibConfig::BibConfig() case 5: pValues[nProp] >>= sQueryText ; break; case 6: pValues[nProp] >>= sQueryField; break; case 7: - bShowColumnAssignmentWarning = *static_cast(pValues[nProp].getValue()); + bShowColumnAssignmentWarning = *o3tl::doAccess(pValues[nProp]); break; } } diff --git a/extensions/source/bibliography/bibload.cxx b/extensions/source/bibliography/bibload.cxx index fb36a2f31bda..3bff83b5ea0a 100644 --- a/extensions/source/bibliography/bibload.cxx +++ b/extensions/source/bibliography/bibload.cxx @@ -401,8 +401,7 @@ Reference< sdb::XColumn > BibliographyLoader::GetIdentifierColumn() const Reference< sdb::XColumn > xReturn; if (xColumns.is() && xColumns->hasByName(sIdentifierColumnName)) { - xReturn.set(*static_cast const *>( - xColumns->getByName(sIdentifierColumnName).getValue()), UNO_QUERY); + xReturn.set(xColumns->getByName(sIdentifierColumnName), UNO_QUERY); } return xReturn; } @@ -435,7 +434,7 @@ static OUString lcl_AddProperty(const Reference< XNameAccess >& xColumns, OUString uRet; Reference< sdb::XColumn > xCol; if (xColumns->hasByName(uColumnName)) - xCol.set(*static_cast const *>(xColumns->getByName(uColumnName).getValue()), UNO_QUERY); + xCol.set(xColumns->getByName(uColumnName), UNO_QUERY); if (xCol.is()) uRet = xCol->getString(); return uRet; @@ -461,7 +460,7 @@ Any BibliographyLoader::getByName(const OUString& rName) throw const OUString sIdentifierMapping = pDatMan->GetIdentifierMapping(); Reference< sdb::XColumn > xColumn; if (xColumns->hasByName(sIdentifierMapping)) - xColumn.set(*static_cast const *>(xColumns->getByName(sIdentifierMapping).getValue()), UNO_QUERY); + xColumn.set(xColumns->getByName(sIdentifierMapping), UNO_QUERY); if (xColumn.is()) { do diff --git a/extensions/source/bibliography/datman.cxx b/extensions/source/bibliography/datman.cxx index d9ff7c9d0022..e9541d2ca6ae 100644 --- a/extensions/source/bibliography/datman.cxx +++ b/extensions/source/bibliography/datman.cxx @@ -17,6 +17,9 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include + +#include #include #include #include @@ -134,7 +137,7 @@ Reference< XConnection > getConnection(const Reference< XInterface > & xRowSe if (!xFormProps.is()) return xConn; - xConn.set(*static_cast const *>(xFormProps->getPropertyValue("ActiveConnection").getValue()), UNO_QUERY); + xConn.set(xFormProps->getPropertyValue("ActiveConnection"), UNO_QUERY); if (!xConn.is()) { SAL_INFO("extensions.biblio", "no active connection"); @@ -166,14 +169,13 @@ Reference< XNameAccess > getColumns(const Reference< XForm > & _rxForm) { try { - DBG_ASSERT((*static_cast(xFormProps->getPropertyValue("CommandType").getValue())) == CommandType::TABLE, + DBG_ASSERT(*o3tl::forceAccess(xFormProps->getPropertyValue("CommandType")) == CommandType::TABLE, "::getColumns : invalid form (has no table as data source) !"); OUString sTable; xFormProps->getPropertyValue("Command") >>= sTable; Reference< XNameAccess > xTables = xSupplyTables->getTables(); if (xTables.is() && xTables->hasByName(sTable)) - xSupplyCols.set( - *static_cast const *>(xTables->getByName(sTable).getValue()), UNO_QUERY); + xSupplyCols.set(xTables->getByName(sTable), UNO_QUERY); if (xSupplyCols.is()) xReturn = xSupplyCols->getColumns(); } @@ -1428,7 +1430,7 @@ void BibDataManager::propertyChange(const beans::PropertyChangeEvent& evt) throw if( evt.NewValue.getValueType() == cppu::UnoType::get()) { Reference< io::XDataInputStream > xStream( - *static_cast *>(evt.NewValue.getValue()), UNO_QUERY ); + evt.NewValue, UNO_QUERY ); aUID <<= xStream->readUTF(); } else @@ -1472,13 +1474,12 @@ void BibDataManager::SetMeAsUidListener() if(!theFieldName.isEmpty()) { - Reference< XPropertySet > xPropSet; Any aElement; aElement = xFields->getByName(theFieldName); - xPropSet = *static_cast const *>(aElement.getValue()); + auto xPropSet = o3tl::doAccess>(aElement); - xPropSet->addPropertyChangeListener(FM_PROP_VALUE, this); + (*xPropSet)->addPropertyChangeListener(FM_PROP_VALUE, this); } } @@ -1516,13 +1517,12 @@ void BibDataManager::RemoveMeAsUidListener() if(!theFieldName.isEmpty()) { - Reference< XPropertySet > xPropSet; Any aElement; aElement = xFields->getByName(theFieldName); - xPropSet = *static_cast const *>(aElement.getValue()); + auto xPropSet = o3tl::doAccess>(aElement); - xPropSet->removePropertyChangeListener(FM_PROP_VALUE, this); + (*xPropSet)->removePropertyChangeListener(FM_PROP_VALUE, this); } } diff --git a/extensions/source/bibliography/general.cxx b/extensions/source/bibliography/general.cxx index 7758e4f0e305..f58a7cbea8e1 100644 --- a/extensions/source/bibliography/general.cxx +++ b/extensions/source/bibliography/general.cxx @@ -129,8 +129,7 @@ void BibPosListener::cursorMoved(const lang::EventObject& /*aEvent*/) throw( uno if(xValueAcc.is() && xValueAcc->hasByName(uTypeMapping)) { uno::Any aVal = xValueAcc->getByName(uTypeMapping); - uno::Reference< uno::XInterface > xInt = *static_cast const *>(aVal.getValue()); - uno::Reference< sdb::XColumn > xCol(xInt, UNO_QUERY); + uno::Reference< sdb::XColumn > xCol(aVal, UNO_QUERY); DBG_ASSERT(xCol.is(), "BibPosListener::cursorMoved : invalid column (no sdb::XColumn) !"); if (xCol.is()) { diff --git a/extensions/source/bibliography/toolbar.cxx b/extensions/source/bibliography/toolbar.cxx index 521446ca7515..3cf37e486b03 100644 --- a/extensions/source/bibliography/toolbar.cxx +++ b/extensions/source/bibliography/toolbar.cxx @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -65,10 +66,9 @@ void BibToolBarListener::statusChanged(const css::frame::FeatureStateEvent& rEvt pToolBar->EnableItem(nIndex,rEvt.IsEnabled); css::uno::Any aState=rEvt.State; - if(aState.getValueType()==cppu::UnoType::get()) + if(auto bChecked = o3tl::tryAccess(aState)) { - bool bChecked= *static_cast(aState.getValue()); - pToolBar->CheckItem(nIndex, bChecked); + pToolBar->CheckItem(nIndex, *bChecked); } } @@ -92,12 +92,11 @@ void BibTBListBoxListener::statusChanged(const css::frame::FeatureStateEvent& rE pToolBar->EnableSourceList(rEvt.IsEnabled); Any aState = rEvt.State; - if(aState.getValueType() == cppu::UnoType>::get()) + if(auto pStringSeq = o3tl::tryAccess>(aState)) { pToolBar->UpdateSourceList(false); pToolBar->ClearSourceList(); - Sequence const * pStringSeq = static_cast const *>(aState.getValue()); const OUString* pStringArray = pStringSeq->getConstArray(); sal_uInt32 nCount = pStringSeq->getLength(); @@ -131,11 +130,10 @@ void BibTBQueryMenuListener::statusChanged(const frame::FeatureStateEvent& rEvt) pToolBar->EnableSourceList(rEvt.IsEnabled); uno::Any aState=rEvt.State; - if(aState.getValueType()==cppu::UnoType>::get()) + if(auto pStringSeq = o3tl::tryAccess>(aState)) { pToolBar->ClearFilterMenu(); - Sequence const * pStringSeq = static_cast const *>(aState.getValue()); const OUString* pStringArray = pStringSeq->getConstArray(); sal_uInt32 nCount = pStringSeq->getLength(); @@ -168,10 +166,9 @@ void BibTBEditListener::statusChanged(const frame::FeatureStateEvent& rEvt)throw pToolBar->EnableQuery(rEvt.IsEnabled); uno::Any aState=rEvt.State; - if(aState.getValueType()== ::cppu::UnoType::get()) + if(auto aStr = o3tl::tryAccess(aState)) { - OUString aStr = *static_cast(aState.getValue()); - pToolBar->SetQueryString(aStr); + pToolBar->SetQueryString(*aStr); } } } -- cgit