summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2013-05-02 10:36:43 +0200
committerNoel Grandin <noelgrandin@gmail.com>2013-05-22 10:44:29 +0000
commit6a043e9c0acff20e1618ca8ec15c21d5d0fd0d37 (patch)
tree2746468845d6f1159e3759ee2cf7a620fca15b6e /filter
parent697a007c61b9cabceb9767fad87cd5822b300452 (diff)
Use the new type-checking Reference constructor to reduce code noise
Also create a Clang compiler plugin to detect such cases. Change-Id: I61ad1a1d6b1c017eeb51f226d2dde0e9bb7f1752 Reviewed-on: https://gerrit.libreoffice.org/4001 Tested-by: LibreOffice gerrit bot <gerrit@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com> Tested-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'filter')
-rw-r--r--filter/source/msfilter/svdfppt.cxx22
-rw-r--r--filter/source/svg/svgexport.cxx20
-rw-r--r--filter/source/svg/svgwriter.cxx15
-rw-r--r--filter/source/xsltdialog/xmlfiltertestdialog.cxx5
4 files changed, 22 insertions, 40 deletions
diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index c82dbfd9e353..e4e1ae13707c 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -7226,8 +7226,7 @@ void CreateTableRows( Reference< XTableRows > xTableRows, const std::set< sal_In
std::set< sal_Int32 >::const_iterator aIter( rRows.begin() );
sal_Int32 nLastPosition( *aIter );
- Reference< XIndexAccess > xIndexAccess( xTableRows, UNO_QUERY_THROW );
- for ( sal_Int32 n = 0; n < xIndexAccess->getCount(); n++ )
+ for ( sal_Int32 n = 0; n < xTableRows->getCount(); n++ )
{
sal_Int32 nHeight;
if ( ++aIter != rRows.end() )
@@ -7239,7 +7238,7 @@ void CreateTableRows( Reference< XTableRows > xTableRows, const std::set< sal_In
nHeight = nTableBottom - nLastPosition;
static const OUString sWidth( "Height" );
- Reference< XPropertySet > xPropSet( xIndexAccess->getByIndex( n ), UNO_QUERY_THROW );
+ Reference< XPropertySet > xPropSet( xTableRows->getByIndex( n ), UNO_QUERY_THROW );
xPropSet->setPropertyValue( sWidth, Any( nHeight ) );
}
}
@@ -7251,8 +7250,7 @@ void CreateTableColumns( Reference< XTableColumns > xTableColumns, const std::se
std::set< sal_Int32 >::const_iterator aIter( rColumns.begin() );
sal_Int32 nLastPosition( *aIter );
- Reference< XIndexAccess > xIndexAccess( xTableColumns, UNO_QUERY_THROW );
- for ( sal_Int32 n = 0; n < xIndexAccess->getCount(); n++ )
+ for ( sal_Int32 n = 0; n < xTableColumns->getCount(); n++ )
{
sal_Int32 nWidth;
if ( ++aIter != rColumns.end() )
@@ -7264,7 +7262,7 @@ void CreateTableColumns( Reference< XTableColumns > xTableColumns, const std::se
nWidth = nTableRight - nLastPosition;
static const OUString sWidth( "Width" );
- Reference< XPropertySet > xPropSet( xIndexAccess->getByIndex( n ), UNO_QUERY_THROW );
+ Reference< XPropertySet > xPropSet( xTableColumns->getByIndex( n ), UNO_QUERY_THROW );
xPropSet->setPropertyValue( sWidth, Any( nWidth ) );
}
}
@@ -7432,7 +7430,6 @@ void ApplyCellLineAttributes( const SdrObject* pLine, Reference< XTable >& xTabl
}
break;
}
- Reference< XCellRange > xCellRange( xTable, UNO_QUERY_THROW );
std::vector< sal_Int32 >::const_iterator aIter( vPositions.begin() );
while( aIter != vPositions.end() )
{
@@ -7447,7 +7444,7 @@ void ApplyCellLineAttributes( const SdrObject* pLine, Reference< XTable >& xTabl
sal_Int32 nFlags = *aIter &~0xffffff;
sal_Int32 nRow = nPosition / nColumns;
sal_Int32 nColumn = nPosition - ( nRow * nColumns );
- Reference< XCell > xCell( xCellRange->getCellByPosition( nColumn, nRow ) );
+ Reference< XCell > xCell( xTable->getCellByPosition( nColumn, nRow ) );
Reference< XPropertySet > xPropSet( xCell, UNO_QUERY_THROW );
if ( nFlags & LinePositionLeft )
@@ -7498,10 +7495,8 @@ SdrObject* SdrPowerPointImport::CreateTable( SdrObject* pGroup, sal_uInt32* pTab
Reference< XTable > xTable( pTable->getTable() );
try
{
- Reference< XColumnRowRange > xColumnRowRange( xTable, UNO_QUERY_THROW );
-
- CreateTableRows( xColumnRowRange->getRows(), aRows, pGroup->GetSnapRect().Bottom() );
- CreateTableColumns( xColumnRowRange->getColumns(), aColumns, pGroup->GetSnapRect().Right() );
+ CreateTableRows( xTable->getRows(), aRows, pGroup->GetSnapRect().Bottom() );
+ CreateTableColumns( xTable->getColumns(), aColumns, pGroup->GetSnapRect().Right() );
sal_Int32 nCellCount = aRows.size() * aColumns.size();
sal_Int32 *pMergedCellIndexTable = new sal_Int32[ nCellCount ];
@@ -7521,8 +7516,7 @@ SdrObject* SdrPowerPointImport::CreateTable( SdrObject* pGroup, sal_uInt32* pTab
sal_Int32 nColumnCount = 0;
if ( GetCellPosition( pObj, aRows, aColumns, nTableIndex, nRow, nRowCount, nColumn, nColumnCount ) )
{
- Reference< XCellRange > xCellRange( xTable, UNO_QUERY_THROW );
- Reference< XCell > xCell( xCellRange->getCellByPosition( nColumn, nRow ) );
+ Reference< XCell > xCell( xTable->getCellByPosition( nColumn, nRow ) );
ApplyCellAttributes( pObj, xCell );
diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx
index 27a7125b0e61..d923b499927a 100644
--- a/filter/source/svg/svgexport.cxx
+++ b/filter/source/svg/svgexport.cxx
@@ -1216,8 +1216,7 @@ void SVGFilter::implExportTextShapeIndex()
{
OUString sTextShapeIdList = mTextShapeIdListMap[xDrawPage].trim();
- Reference< XInterface > xRef( xDrawPage, UNO_QUERY );
- const OUString& rPageId = implGetValidIDFromInterface( xRef );
+ const OUString& rPageId = implGetValidIDFromInterface( xDrawPage );
if( !rPageId.isEmpty() && !sTextShapeIdList.isEmpty() )
{
mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrSlide, rPageId );
@@ -1770,8 +1769,7 @@ sal_Bool SVGFilter::implExportShape( const Reference< XShape >& rxShape )
}
- Reference< XInterface > xRef( rxShape, UNO_QUERY );
- const OUString& rShapeId = implGetValidIDFromInterface( xRef );
+ const OUString& rShapeId = implGetValidIDFromInterface( rxShape );
if( !rShapeId.isEmpty() )
{
mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", rShapeId );
@@ -1836,10 +1834,8 @@ sal_Bool SVGFilter::implCreateObjects()
mCreateOjectsCurrentMasterPage = xMasterPage;
implCreateObjectsFromBackground( xMasterPage );
- Reference< XShapes > xShapes( xMasterPage, UNO_QUERY );
-
- if( xShapes.is() )
- implCreateObjectsFromShapes( xMasterPage, xShapes );
+ if( xMasterPage.is() )
+ implCreateObjectsFromShapes( xMasterPage, xMasterPage );
}
}
@@ -1871,10 +1867,9 @@ sal_Bool SVGFilter::implCreateObjects()
}
}
#endif
- Reference< XShapes > xShapes( xDrawPage, UNO_QUERY );
- if( xShapes.is() )
- implCreateObjectsFromShapes( xDrawPage, xShapes );
+ if( xDrawPage.is() )
+ implCreateObjectsFromShapes( xDrawPage, xDrawPage );
}
}
return sal_True;
@@ -1956,8 +1951,7 @@ sal_Bool SVGFilter::implCreateObjectsFromShape( const Reference< XDrawPage > & r
{
// We create a map of text shape ids.
implRegisterInterface( rxShape );
- Reference< XInterface > xRef( rxShape, UNO_QUERY );
- const OUString& rShapeId = implGetValidIDFromInterface( xRef );
+ const OUString& rShapeId = implGetValidIDFromInterface( rxShape );
if( !rShapeId.isEmpty() )
{
mTextShapeIdListMap[rxPage] += rShapeId;
diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx
index 410215a499aa..d1f3c4a6e39a 100644
--- a/filter/source/svg/svgwriter.cxx
+++ b/filter/source/svg/svgwriter.cxx
@@ -844,8 +844,7 @@ sal_Bool SVGTextWriter::createParagraphEnumeration()
{
if( mrTextShape.is() )
{
- Reference< XInterface > xRef( mrTextShape, UNO_QUERY );
- msShapeId = implGetValidIDFromInterface( xRef );
+ msShapeId = implGetValidIDFromInterface( mrTextShape );
Reference< XEnumerationAccess > xEnumerationAccess( mrTextShape, UNO_QUERY_THROW );
Reference< XEnumeration > xEnumeration( xEnumerationAccess->createEnumeration(), UNO_QUERY_THROW );
@@ -1009,8 +1008,7 @@ sal_Bool SVGTextWriter::nextParagraph()
return sal_False;
}
- Reference< XInterface > xRef( xTextContent, UNO_QUERY );
- const OUString& rParagraphId = implGetValidIDFromInterface( xRef );
+ const OUString& rParagraphId = implGetValidIDFromInterface( xTextContent );
if( !rParagraphId.isEmpty() )
{
mrExport.AddAttribute( XML_NAMESPACE_NONE, "id", rParagraphId );
@@ -1118,8 +1116,7 @@ sal_Bool SVGTextWriter::nextTextPortion()
{
implRegisterInterface( xPortionTextRange );
- Reference< XInterface > xRef( xPortionTextRange, UNO_QUERY );
- const OUString& rTextPortionId = implGetValidIDFromInterface( xRef );
+ const OUString& rTextPortionId = implGetValidIDFromInterface( xPortionTextRange );
if( !rTextPortionId.isEmpty() )
{
msHyperlinkIdList += rTextPortionId;
@@ -1575,8 +1572,7 @@ void SVGTextWriter::implWriteTextPortion( const Point& rPos,
implRegisterInterface( mrCurrentTextParagraph );
// Add the needed info to the BulletListItemMap
- Reference< XInterface > xRef( mrCurrentTextParagraph, UNO_QUERY );
- OUString sId = implGetValidIDFromInterface( xRef );
+ OUString sId = implGetValidIDFromInterface( mrCurrentTextParagraph );
if( !sId.isEmpty() )
{
sId += ".bp";
@@ -1595,8 +1591,7 @@ void SVGTextWriter::implWriteTextPortion( const Point& rPos,
}
}
- Reference< XInterface > xRef( mrCurrentTextPortion, UNO_QUERY );
- const OUString& rTextPortionId = implGetValidIDFromInterface( xRef );
+ const OUString& rTextPortionId = implGetValidIDFromInterface( mrCurrentTextPortion );
if( !rTextPortionId.isEmpty() )
{
mrExport.AddAttribute( XML_NAMESPACE_NONE, "id", rTextPortionId );
diff --git a/filter/source/xsltdialog/xmlfiltertestdialog.cxx b/filter/source/xsltdialog/xmlfiltertestdialog.cxx
index 099aec7933d6..807393253b0b 100644
--- a/filter/source/xsltdialog/xmlfiltertestdialog.cxx
+++ b/filter/source/xsltdialog/xmlfiltertestdialog.cxx
@@ -630,11 +630,10 @@ void XMLFilterTestDialog::import( const OUString& rURL )
aOutputFile.open( osl_File_OpenFlag_Write );
Reference< XOutputStream > xOS( new OSLOutputStreamWrapper( aOutputFile ) );
- Reference< XActiveDataSource > xDocSrc( xWriter, UNO_QUERY );
- xDocSrc->setOutputStream( xOS );
+ xWriter->setOutputStream( xOS );
Sequence< OUString > aFilterUserData( m_pFilterInfo->getFilterUserData() );
- xImporter->importer( aSourceData, Reference<XDocumentHandler>(xWriter, UNO_QUERY_THROW), aFilterUserData );
+ xImporter->importer( aSourceData, xWriter, aFilterUserData );
}
displayXMLFile( aTempFileURL );