diff options
author | Noel Grandin <noel@peralex.com> | 2013-05-02 10:36:43 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2013-05-22 10:44:29 +0000 |
commit | 6a043e9c0acff20e1618ca8ec15c21d5d0fd0d37 (patch) | |
tree | 2746468845d6f1159e3759ee2cf7a620fca15b6e /xmloff | |
parent | Fix exception specifications (diff) | |
download | core-6a043e9c0acff20e1618ca8ec15c21d5d0fd0d37.tar.gz core-6a043e9c0acff20e1618ca8ec15c21d5d0fd0d37.zip |
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 'xmloff')
-rw-r--r-- | xmloff/source/core/DomBuilderContext.cxx | 5 | ||||
-rw-r--r-- | xmloff/source/core/DomExport.cxx | 2 | ||||
-rw-r--r-- | xmloff/source/script/XMLEventExport.cxx | 3 | ||||
-rw-r--r-- | xmloff/source/style/styleexp.cxx | 11 | ||||
-rw-r--r-- | xmloff/source/text/XMLAutoTextEventExport.cxx | 3 | ||||
-rw-r--r-- | xmloff/source/text/XMLTextMarkImportContext.cxx | 5 | ||||
-rw-r--r-- | xmloff/source/text/txtimp.cxx | 11 | ||||
-rw-r--r-- | xmloff/source/text/txtparae.cxx | 10 | ||||
-rw-r--r-- | xmloff/source/text/txtparai.cxx | 18 | ||||
-rw-r--r-- | xmloff/source/xforms/xformsexport.cxx | 2 |
10 files changed, 26 insertions, 44 deletions
diff --git a/xmloff/source/core/DomBuilderContext.cxx b/xmloff/source/core/DomBuilderContext.cxx index 8d02dd45972d..cc6200dc550b 100644 --- a/xmloff/source/core/DomBuilderContext.cxx +++ b/xmloff/source/core/DomBuilderContext.cxx @@ -238,9 +238,8 @@ static Reference<XNode> lcl_createElement( SvXMLImport& rImport, DBG_ASSERT( xElement.is(), "can't create element" ); // add new element to parent and return - Reference<XNode> xNode( xElement, UNO_QUERY_THROW ); - xParent->appendChild( xNode ); - return xNode; + xParent->appendChild( xElement ); + return xElement; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/core/DomExport.cxx b/xmloff/source/core/DomExport.cxx index 7e87c621aba2..ca1190d6eaae 100644 --- a/xmloff/source/core/DomExport.cxx +++ b/xmloff/source/core/DomExport.cxx @@ -129,7 +129,7 @@ void visitNode( DomVisitor& rVisitor, const Reference<XNode>& xNode ) void visit( DomVisitor& rVisitor, const Reference<XDocument>& xDocument ) { - visit( rVisitor, Reference<XNode>( xDocument, UNO_QUERY_THROW ) ); + visit( rVisitor, xDocument ); } void visit( DomVisitor& rVisitor, const Reference<XNode>& xNode ) diff --git a/xmloff/source/script/XMLEventExport.cxx b/xmloff/source/script/XMLEventExport.cxx index e619d96a6db2..4ddde6e61d82 100644 --- a/xmloff/source/script/XMLEventExport.cxx +++ b/xmloff/source/script/XMLEventExport.cxx @@ -106,8 +106,7 @@ void XMLEventExport::Export( Reference<XEventsSupplier> & rSupplier, void XMLEventExport::Export( Reference<XNameReplace> & rReplace, sal_Bool bWhitespace) { - Reference<XNameAccess> xAccess(rReplace, UNO_QUERY); - Export(xAccess, bWhitespace); + Export(rReplace, bWhitespace); } void XMLEventExport::Export( Reference<XNameAccess> & rAccess, diff --git a/xmloff/source/style/styleexp.cxx b/xmloff/source/style/styleexp.cxx index b9ca2ad2e67e..318cc0d1c6f4 100644 --- a/xmloff/source/style/styleexp.cxx +++ b/xmloff/source/style/styleexp.cxx @@ -396,14 +396,13 @@ void XMLStyleExport::exportStyleFamily( if( !xStyleCont.is() ) return; - Reference< XNameAccess > xStyles( xStyleCont, UNO_QUERY ); // If next styles are supported and used styles should be exported only, // the next style may be unused but has to be exported, too. In this case // the names of all exported styles are remembered. boost::scoped_ptr<std::set<OUString> > pExportedStyles(0); sal_Bool bFirstStyle = sal_True; - const uno::Sequence< OUString> aSeq = xStyles->getElementNames(); + const uno::Sequence< OUString> aSeq = xStyleCont->getElementNames(); const OUString* pIter = aSeq.getConstArray(); const OUString* pEnd = pIter + aSeq.getLength(); for(;pIter != pEnd;++pIter) @@ -411,7 +410,7 @@ void XMLStyleExport::exportStyleFamily( Reference< XStyle > xStyle; try { - xStyles->getByName( *pIter ) >>= xStyle; + xStyleCont->getByName( *pIter ) >>= xStyle; } catch(const lang::IndexOutOfBoundsException&) { @@ -428,7 +427,7 @@ void XMLStyleExport::exportStyleFamily( if( !bUsed || xStyle->isInUse() ) { sal_Bool bExported = exportStyle( xStyle, rXMLFamily, rPropMapper, - xStyles,pPrefix ); + xStyleCont,pPrefix ); if( bUsed && bFirstStyle && bExported ) { // If this is the first style, find out whether next styles @@ -464,7 +463,7 @@ void XMLStyleExport::exportStyleFamily( for(;pIter != pEnd;++pIter) { Reference< XStyle > xStyle; - xStyles->getByName( *pIter ) >>= xStyle; + xStyleCont->getByName( *pIter ) >>= xStyle; DBG_ASSERT( xStyle.is(), "Style not found for export!" ); if( xStyle.is() ) @@ -500,7 +499,7 @@ void XMLStyleExport::exportStyleFamily( xStyleCont->getByName( sNextName ) >>= xStyle; DBG_ASSERT( xStyle.is(), "Style not found for export!" ); - if( xStyle.is() && exportStyle( xStyle, rXMLFamily, rPropMapper, xStyles,pPrefix ) ) + if( xStyle.is() && exportStyle( xStyle, rXMLFamily, rPropMapper, xStyleCont, pPrefix ) ) pExportedStyles->insert( sTmp ); } } diff --git a/xmloff/source/text/XMLAutoTextEventExport.cxx b/xmloff/source/text/XMLAutoTextEventExport.cxx index 0212621ad528..5c5041876e18 100644 --- a/xmloff/source/text/XMLAutoTextEventExport.cxx +++ b/xmloff/source/text/XMLAutoTextEventExport.cxx @@ -92,8 +92,7 @@ void XMLAutoTextEventExport::initialize( rArguments[1] >>= xReplace; if (xReplace.is()) { - Reference<XNameAccess> xAccess(xReplace, UNO_QUERY); - xEvents = xAccess; + xEvents = xReplace; } else { diff --git a/xmloff/source/text/XMLTextMarkImportContext.cxx b/xmloff/source/text/XMLTextMarkImportContext.cxx index ae89ab099658..6b538f00fbe6 100644 --- a/xmloff/source/text/XMLTextMarkImportContext.cxx +++ b/xmloff/source/text/XMLTextMarkImportContext.cxx @@ -286,9 +286,6 @@ void XMLTextMarkImportContext::EndElement() // create a file with subsequence // start/end elements - Reference<XTextRange> xInsertionRange( - xInsertionCursor, UNO_QUERY); - bool bImportAsField=((lcl_MarkType)nTmp==TypeFieldmarkEnd && m_rHelper.hasCurrentFieldCtx()); // insert reference @@ -296,7 +293,7 @@ void XMLTextMarkImportContext::EndElement() CreateAndInsertMark(GetImport(), (bImportAsField?sAPI_fieldmark:sAPI_bookmark), m_sBookmarkName, - xInsertionRange, + xInsertionCursor, m_sXmlId) ); if (pRDFaAttributes) { diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx index 4b15efc9acfc..94f91c08a10b 100644 --- a/xmloff/source/text/txtimp.cxx +++ b/xmloff/source/text/txtimp.cxx @@ -1715,25 +1715,24 @@ OUString XMLTextImportHelper::SetStyleAndAttrs( makeAny(rCursor->getString())); // insert the field over it's original text - Reference<XTextRange> xRange(rCursor, UNO_QUERY); Reference<XTextContent> xTextContent(xTmp, UNO_QUERY); - if (m_pImpl->m_xText.is() && xRange.is()) + if (m_pImpl->m_xText.is() && rCursor.is()) { // #i107225# the combined characters need to be inserted first // the selected text has to be removed afterwards - m_pImpl->m_xText->insertTextContent( xRange->getStart(), xTextContent, sal_True ); + m_pImpl->m_xText->insertTextContent( rCursor->getStart(), xTextContent, sal_True ); - if( !xRange->getString().isEmpty() ) + if( !rCursor->getString().isEmpty() ) { try { - uno::Reference< text::XTextCursor > xCrsr = xRange->getText()->createTextCursorByRange( xRange->getStart() ); + uno::Reference< text::XTextCursor > xCrsr = rCursor->getText()->createTextCursorByRange( rCursor->getStart() ); xCrsr->goLeft( 1, true ); uno::Reference< beans::XPropertySet> xCrsrProperties( xCrsr, uno::UNO_QUERY_THROW ); //the hard properties of the removed text need to be applied to the combined characters field pStyle->FillPropertySet( xCrsrProperties ); xCrsr->collapseToEnd(); - xCrsr->gotoRange( xRange->getEnd(), true ); + xCrsr->gotoRange( rCursor->getEnd(), true ); xCrsr->setString( OUString() ); } catch(const uno::Exception&) diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx index 3b5933be9e2f..d6b309b8edf3 100644 --- a/xmloff/source/text/txtparae.cxx +++ b/xmloff/source/text/txtparae.cxx @@ -1605,8 +1605,7 @@ bool XMLTextParagraphExport::collectTextAutoStylesOptimized( sal_Bool bIsProgres { Any aAny = xTables->getByIndex( i ); Reference< XTextTable > xTable = *(Reference<XTextTable>*)aAny.getValue(); - Reference < XTextContent > xTextContent( xTable, uno::UNO_QUERY ); - exportTable( xTextContent, sal_True, sal_True ); + exportTable( xTable, sal_True, sal_True ); } } } @@ -1966,17 +1965,16 @@ void XMLTextParagraphExport::exportParagraph( xPropSet ) >>= sStyle; } - Reference< XInterface > xRef( rTextContent, UNO_QUERY ); - if( xRef.is() ) + if( rTextContent.is() ) { - const OUString& rIdentifier = GetExport().getInterfaceToIdentifierMapper().getIdentifier( xRef ); + const OUString& rIdentifier = GetExport().getInterfaceToIdentifierMapper().getIdentifier( rTextContent ); if( !rIdentifier.isEmpty() ) { // FIXME: this is just temporary until EditEngine // paragraphs implement XMetadatable. // then that must be used and not the mapper, because // when both can be used we get two xml:id! - uno::Reference<rdf::XMetadatable> const xMeta(xRef, + uno::Reference<rdf::XMetadatable> const xMeta(rTextContent, uno::UNO_QUERY); OSL_ENSURE(!xMeta.is(), "paragraph that implements " "XMetadatable used in interfaceToIdentifierMapper?"); diff --git a/xmloff/source/text/txtparai.cxx b/xmloff/source/text/txtparai.cxx index a50aee001901..df7faffbb505 100644 --- a/xmloff/source/text/txtparai.cxx +++ b/xmloff/source/text/txtparai.cxx @@ -786,9 +786,7 @@ void XMLMetaImportContextBase::EndElement() xEndRange) ); xInsertionCursor->gotoRange(m_xStart, sal_True); - const Reference<XTextRange> xInsertionRange(xInsertionCursor, UNO_QUERY); - - InsertMeta(xInsertionRange); + InsertMeta(xInsertionCursor); } SvXMLImportContext * XMLMetaImportContextBase::CreateChildContext( @@ -2004,9 +2002,8 @@ XMLParaContext::~XMLParaContext() if( xIdCursor.is() ) { xIdCursor->gotoRange( xEnd, sal_True ); - Reference< XInterface > xRef( xIdCursor, UNO_QUERY ); GetImport().getInterfaceToIdentifierMapper().registerReference( - m_sXmlId, xRef); + m_sXmlId, xIdCursor); } } @@ -2147,16 +2144,13 @@ XMLParaContext::~XMLParaContext() if( !pHint->GetEnd().is() ) pHint->SetEnd(xEnd); - // convert XCursor to XTextRange - Reference<XTextRange> xRange(xAttrCursor, UNO_QUERY); - // reference name uses rStyleName member // borrow from XMLTextMarkImportContext XMLTextMarkImportContext::CreateAndInsertMark( GetImport(), OUString( "com.sun.star.text.ReferenceMark"), rRefName, - xRange); + xAttrCursor); } } break; @@ -2179,9 +2173,8 @@ XMLParaContext::~XMLParaContext() Reference<beans::XPropertySet> xMark( ((const XMLIndexMarkHint_Impl *)pHint)->GetMark()); Reference<XTextContent> xContent(xMark, UNO_QUERY); - Reference<XTextRange> xRange(xAttrCursor, UNO_QUERY); xTxtImport->GetText()->insertTextContent( - xRange, xContent, sal_True ); + xAttrCursor, xContent, sal_True ); } break; case XML_HINT_TEXT_FRAME: @@ -2196,10 +2189,9 @@ XMLParaContext::~XMLParaContext() /* Core impl. of the unification of drawing objects and Writer fly frames (#i26791#) */ - Reference<XTextRange> xRange(xAttrCursor, UNO_QUERY); if ( pFHint->IsBoundAtChar() ) { - xTextContent->attach( xRange ); + xTextContent->attach( xAttrCursor ); } } /* Consider, that hint can also contain a shape - diff --git a/xmloff/source/xforms/xformsexport.cxx b/xmloff/source/xforms/xformsexport.cxx index 28ba107ab108..170cdd1c025d 100644 --- a/xmloff/source/xforms/xformsexport.cxx +++ b/xmloff/source/xforms/xformsexport.cxx @@ -561,7 +561,7 @@ static void lcl_exportDataType( SvXMLExport& rExport, // export facets lcl_exportDataTypeFacets( rExport, - Reference<XPropertySet>( xType, UNO_QUERY ), + xType, aDataTypeFacetTable ); } |