summaryrefslogtreecommitdiff
path: root/oox
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 /oox
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 'oox')
-rw-r--r--oox/source/drawingml/chart/converterbase.cxx9
-rw-r--r--oox/source/drawingml/textfield.cxx9
-rw-r--r--oox/source/drawingml/textparagraph.cxx7
-rw-r--r--oox/source/drawingml/textrun.cxx8
-rw-r--r--oox/source/export/drawingml.cxx2
-rw-r--r--oox/source/export/shapes.cxx8
-rw-r--r--oox/source/helper/containerhelper.cxx3
7 files changed, 19 insertions, 27 deletions
diff --git a/oox/source/drawingml/chart/converterbase.cxx b/oox/source/drawingml/chart/converterbase.cxx
index e36ecf1def58..fde8d67d9009 100644
--- a/oox/source/drawingml/chart/converterbase.cxx
+++ b/oox/source/drawingml/chart/converterbase.cxx
@@ -24,6 +24,7 @@
#include <com/sun/star/chart/XAxisZSupplier.hpp>
#include <com/sun/star/chart/XChartDocument.hpp>
#include <com/sun/star/chart/XSecondAxisTitleSupplier.hpp>
+#include <com/sun/star/chart2/XChartDocument.hpp>
#include <com/sun/star/chart2/RelativePosition.hpp>
#include <com/sun/star/chart2/RelativeSize.hpp>
#include <com/sun/star/chart2/XTitle2.hpp>
@@ -88,7 +89,7 @@ void TitleLayoutInfo::convertTitlePos( ConverterRoot& rRoot, const Reference< cs
if( mxTitle.is() && mpGetShape ) try
{
// try to get the title shape
- Reference< XShape > xTitleShape( mpGetShape( rxChart1Doc ), UNO_SET_THROW );
+ Reference< XShape > xTitleShape = mpGetShape( rxChart1Doc );
// get title rotation angle, needed for correction of position of top-left edge
double fAngle = mxTitle->getTextRotation();
// convert the position
@@ -181,8 +182,7 @@ ConverterData::ConverterData(
// lock the model to suppress internal updates during conversion
try
{
- Reference< XModel > xModel( mxDoc, UNO_QUERY_THROW );
- xModel->lockControllers();
+ mxDoc->lockControllers();
}
catch( Exception& )
{
@@ -202,8 +202,7 @@ ConverterData::~ConverterData()
// unlock the model
try
{
- Reference< XModel > xModel( mxDoc, UNO_QUERY_THROW );
- xModel->unlockControllers();
+ mxDoc->unlockControllers();
}
catch( Exception& )
{
diff --git a/oox/source/drawingml/textfield.cxx b/oox/source/drawingml/textfield.cxx
index 95f5e24f7fb6..bf566bae218e 100644
--- a/oox/source/drawingml/textfield.cxx
+++ b/oox/source/drawingml/textfield.cxx
@@ -138,8 +138,7 @@ sal_Int32 TextField::insertAt(
try
{
PropertyMap aioBulletList;
- Reference< XTextRange > xStart( xAt, UNO_QUERY );
- Reference< XPropertySet > xProps( xStart, UNO_QUERY);
+ Reference< XPropertySet > xProps( xAt, UNO_QUERY);
PropertySet aPropSet( xProps );
maTextParagraphProperties.pushToPropSet( &rFilterBase, xProps, aioBulletList, NULL, sal_True, 18 );
@@ -168,15 +167,15 @@ sal_Int32 TextField::insertAt(
}
else
{
- xText->insertString( xStart, " ", sal_False );
+ xText->insertString( xAt, " ", sal_False );
}
- xText->insertTextContent( xStart, xContent, sal_False );
+ xText->insertTextContent( xAt, xContent, sal_False );
}
}
}
else
{
- xText->insertString( xStart, getText(), sal_False );
+ xText->insertString( xAt, getText(), sal_False );
}
}
catch( const Exception& )
diff --git a/oox/source/drawingml/textparagraph.cxx b/oox/source/drawingml/textparagraph.cxx
index 4679858f0bc4..c4e82b31ff04 100644
--- a/oox/source/drawingml/textparagraph.cxx
+++ b/oox/source/drawingml/textparagraph.cxx
@@ -51,7 +51,6 @@ void TextParagraph::insertAt(
{
try {
sal_Int32 nParagraphSize = 0;
- Reference< XTextRange > xStart( xAt, UNO_QUERY );
sal_Int16 nLevel = maProperties.getLevel();
@@ -72,14 +71,14 @@ void TextParagraph::insertAt(
if( !bFirst )
{
- xText->insertControlCharacter( xStart, ControlCharacter::APPEND_PARAGRAPH, sal_False );
+ xText->insertControlCharacter( xAt, ControlCharacter::APPEND_PARAGRAPH, sal_False );
xAt->gotoEnd( sal_True );
}
sal_Int32 nCharHeight = 0;
if ( maRuns.begin() == maRuns.end() )
{
- PropertySet aPropSet( xStart );
+ PropertySet aPropSet( xAt );
TextCharacterProperties aTextCharacterProps( aTextCharacterStyle );
aTextCharacterProps.assignUsed( maEndProperties );
@@ -103,7 +102,7 @@ void TextParagraph::insertAt(
xAt->gotoEnd( sal_True );
PropertyMap aioBulletList;
- Reference< XPropertySet > xProps( xStart, UNO_QUERY);
+ Reference< XPropertySet > xProps( xAt, UNO_QUERY);
float fCharacterSize = nCharHeight > 0 ? GetFontHeight( nCharHeight ) : 18;
if ( pTextParagraphStyle.get() )
{
diff --git a/oox/source/drawingml/textrun.cxx b/oox/source/drawingml/textrun.cxx
index 6193cf0c244b..c4648c205d8d 100644
--- a/oox/source/drawingml/textrun.cxx
+++ b/oox/source/drawingml/textrun.cxx
@@ -116,7 +116,7 @@ sal_Int32 TextRun::insertAt(
if ( nIndex >= getText().getLength() )
break;
- xStart = Reference< XTextRange >( xAt, UNO_QUERY );
+ xStart = xAt;
aPropSet = PropertySet( xStart );
aTextCharacterProps.pushToPropSet( aPropSet, rFilterBase );
}
@@ -136,8 +136,7 @@ sal_Int32 TextRun::insertAt(
PropertySet aFieldProps( xField );
aFieldProps.setProperties( maTextCharacterProperties.maHyperlinkPropertyMap );
aFieldProps.setProperty( PROP_Representation, getText() );
- Reference< XTextContent > xContent( xField, UNO_QUERY);
- xText->insertTextContent( xStart, xContent, sal_False );
+ xText->insertTextContent( xStart, xField, sal_False );
xTextFieldCursor->gotoEnd( sal_True );
@@ -146,8 +145,7 @@ sal_Int32 TextRun::insertAt(
if ( !maTextCharacterProperties.moUnderline.has() )
aTextCharacterProps.moUnderline.set( XML_sng );
- Reference< XTextRange > xFieldRange( xTextFieldCursor, UNO_QUERY );
- PropertySet aFieldTextPropSet( xFieldRange );
+ PropertySet aFieldTextPropSet( xTextFieldCursor );
aTextCharacterProps.pushToPropSet( aFieldTextPropSet, rFilterBase );
oox::core::TextField aTextField;
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index b0831125c346..6f28d9286066 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -843,7 +843,7 @@ void DrawingML::WriteRunProperties( Reference< XPropertySet > rRun, sal_Bool bIs
Reference< XTextField > rXTextField;
GET( rXTextField, TextField );
if( rXTextField.is() )
- rXPropSet.set( rXTextField, UNO_QUERY );
+ rRun.set( rXTextField, UNO_QUERY );
}
// field properties starts here
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 75a5b596ea91..c487d2dddf36 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -1178,9 +1178,8 @@ void ShapeExport::WriteTable( Reference< XShape > rXShape )
mpFS->startElementNS( XML_a, XML_tbl, FSEND );
mpFS->singleElementNS( XML_a, XML_tblPr, FSEND );
- Reference< XColumnRowRange > xColumnRowRange( xTable, UNO_QUERY_THROW );
- Reference< container::XIndexAccess > xColumns( xColumnRowRange->getColumns(), UNO_QUERY_THROW );
- Reference< container::XIndexAccess > xRows( xColumnRowRange->getRows(), UNO_QUERY_THROW );
+ Reference< container::XIndexAccess > xColumns( xTable->getColumns(), UNO_QUERY_THROW );
+ Reference< container::XIndexAccess > xRows( xTable->getRows(), UNO_QUERY_THROW );
sal_uInt16 nRowCount = static_cast< sal_uInt16 >( xRows->getCount() );
sal_uInt16 nColumnCount = static_cast< sal_uInt16 >( xColumns->getCount() );
@@ -1197,7 +1196,6 @@ void ShapeExport::WriteTable( Reference< XShape > rXShape )
mpFS->endElementNS( XML_a, XML_tblGrid );
- Reference< XCellRange > xCellRange( xTable, UNO_QUERY_THROW );
for( sal_Int32 nRow = 0; nRow < nRowCount; nRow++ )
{
Reference< XPropertySet > xRowPropSet( xRows->getByIndex( nRow ), UNO_QUERY_THROW );
@@ -1209,7 +1207,7 @@ void ShapeExport::WriteTable( Reference< XShape > rXShape )
for( sal_Int32 nColumn = 0; nColumn < nColumnCount; nColumn++ )
{
- Reference< XMergeableCell > xCell( xCellRange->getCellByPosition( nColumn, nRow ), UNO_QUERY_THROW );
+ Reference< XMergeableCell > xCell( xTable->getCellByPosition( nColumn, nRow ), UNO_QUERY_THROW );
if ( !xCell->isMerged() )
{
mpFS->startElementNS( XML_a, XML_tc, FSEND );
diff --git a/oox/source/helper/containerhelper.cxx b/oox/source/helper/containerhelper.cxx
index 0686395010e2..bc2f76ffae1c 100644
--- a/oox/source/helper/containerhelper.cxx
+++ b/oox/source/helper/containerhelper.cxx
@@ -124,8 +124,7 @@ OUString ContainerHelper::insertByUnusedName(
OSL_ENSURE( rxNameContainer.is(), "ContainerHelper::insertByUnusedName - missing XNameContainer interface" );
// find an unused name
- Reference< XNameAccess > xNameAccess( rxNameContainer, UNO_QUERY );
- OUString aNewName = getUnusedName( xNameAccess, rSuggestedName, cSeparator );
+ OUString aNewName = getUnusedName( rxNameContainer, rSuggestedName, cSeparator );
// rename existing object
if( bRenameOldExisting && rxNameContainer->hasByName( rSuggestedName ) )