summaryrefslogtreecommitdiff
path: root/forms
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 /forms
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 'forms')
-rw-r--r--forms/source/component/FormattedField.cxx10
-rw-r--r--forms/source/component/navigationbar.cxx14
-rw-r--r--forms/source/component/scrollbar.cxx4
-rw-r--r--forms/source/component/spinbutton.cxx4
-rw-r--r--forms/source/misc/InterfaceContainer.cxx3
-rw-r--r--forms/source/xforms/model.cxx2
-rw-r--r--forms/source/xforms/model_ui.cxx6
-rw-r--r--forms/source/xforms/submission.cxx2
-rw-r--r--forms/source/xforms/submission/replace.cxx4
9 files changed, 21 insertions, 28 deletions
diff --git a/forms/source/component/FormattedField.cxx b/forms/source/component/FormattedField.cxx
index ca3142566205..fc3fd0f5356f 100644
--- a/forms/source/component/FormattedField.cxx
+++ b/forms/source/component/FormattedField.cxx
@@ -867,8 +867,7 @@ void OFormattedModel::write(const Reference<XObjectOutputStream>& _rxOutStream)
// and to be a little bit more compatible we make the following section skippable
{
- Reference< XDataOutputStream > xOut(_rxOutStream, UNO_QUERY);
- OStreamSection aDownCompat(xOut);
+ OStreamSection aDownCompat(_rxOutStream);
// a sub version within the skippable block
_rxOutStream->writeShort(0x0000);
@@ -881,7 +880,7 @@ void OFormattedModel::write(const Reference<XObjectOutputStream>& _rxOutStream)
}
{
- OStreamSection aDownCompat2(xOut);
+ OStreamSection aDownCompat2(_rxOutStream);
switch (aEffectiveValue.getValueType().getTypeClass())
{
case TypeClass_STRING:
@@ -943,8 +942,7 @@ void OFormattedModel::read(const Reference<XObjectInputStream>& _rxInStream) thr
if (nVersion == 0x0003)
{ // since version 3 there is a "skippable" block at this position
- Reference< XDataInputStream > xIn(_rxInStream, UNO_QUERY);
- OStreamSection aDownCompat(xIn);
+ OStreamSection aDownCompat(_rxInStream);
sal_Int16 nSubVersion = _rxInStream->readShort();
(void)nSubVersion;
@@ -952,7 +950,7 @@ void OFormattedModel::read(const Reference<XObjectInputStream>& _rxInStream) thr
// version 0 and higher : the "effective value" property
Any aEffectiveValue;
{
- OStreamSection aDownCompat2(xIn);
+ OStreamSection aDownCompat2(_rxInStream);
switch (_rxInStream->readShort())
{
case 0: // String
diff --git a/forms/source/component/navigationbar.cxx b/forms/source/component/navigationbar.cxx
index 2138caf56b41..9d1ac5fc40dc 100644
--- a/forms/source/component/navigationbar.cxx
+++ b/forms/source/component/navigationbar.cxx
@@ -225,14 +225,13 @@ namespace frm
{
// open a section for compatibility - if we later on write additional members,
// then older versions can skip them
- Reference< XDataOutputStream > xDataOut( _rxOutStream, UNO_QUERY );
- OStreamSection aEnsureBlockCompat( xDataOut );
+ OStreamSection aEnsureBlockCompat( _rxOutStream );
// base class
OControlModel::write( _rxOutStream );
{
- OStreamSection aEnsureCompat( xDataOut );
+ OStreamSection aEnsureCompat( _rxOutStream );
// determine which properties are not void and need to be written
sal_Int32 nNonVoids = 0;
if ( m_aTabStop.hasValue() )
@@ -270,7 +269,7 @@ namespace frm
}
{
- OStreamSection aEnsureCompat( xDataOut );
+ OStreamSection aEnsureCompat( _rxOutStream );
::comphelper::operator<<( _rxOutStream, getFont() );
}
@@ -297,14 +296,13 @@ namespace frm
//------------------------------------------------------------------
void SAL_CALL ONavigationBarModel::read( const Reference< XObjectInputStream >& _rxInStream ) throw ( IOException, RuntimeException )
{
- Reference< XDataInputStream > xDataIn( _rxInStream, UNO_QUERY );
- OStreamSection aEnsureBlockCompat( xDataIn );
+ OStreamSection aEnsureBlockCompat( _rxInStream );
// base class
OControlModel::read( _rxInStream );
{
- OStreamSection aEnsureCompat( xDataIn );
+ OStreamSection aEnsureCompat( _rxInStream );
// determine which properties were non-void
sal_Int32 nNonVoids = _rxInStream->readLong( );
@@ -331,7 +329,7 @@ namespace frm
}
{
- OStreamSection aEnsureCompat( xDataIn );
+ OStreamSection aEnsureCompat( _rxInStream );
FontDescriptor aFont;
::comphelper::operator>>( _rxInStream, aFont );
setFont( aFont );
diff --git a/forms/source/component/scrollbar.cxx b/forms/source/component/scrollbar.cxx
index fbab6e7ad2e0..e0ecb47fd5a5 100644
--- a/forms/source/component/scrollbar.cxx
+++ b/forms/source/component/scrollbar.cxx
@@ -250,7 +250,7 @@ namespace frm
OBoundControlModel::write( _rxOutStream );
::osl::MutexGuard aGuard( m_aMutex );
- OStreamSection aSection( Reference< XDataOutputStream >( _rxOutStream, UNO_QUERY ) );
+ OStreamSection aSection( _rxOutStream );
// version
_rxOutStream->writeShort( 0x0001 );
@@ -268,7 +268,7 @@ namespace frm
// version
{
- OStreamSection aSection( Reference< XDataInputStream >( _rxInStream, UNO_QUERY ) );
+ OStreamSection aSection( _rxInStream );
sal_uInt16 nVersion = _rxInStream->readShort();
if ( nVersion == 0x0001 )
diff --git a/forms/source/component/spinbutton.cxx b/forms/source/component/spinbutton.cxx
index 1faa874f7bab..70237f38b09d 100644
--- a/forms/source/component/spinbutton.cxx
+++ b/forms/source/component/spinbutton.cxx
@@ -206,7 +206,7 @@ namespace frm
OBoundControlModel::write( _rxOutStream );
::osl::MutexGuard aGuard( m_aMutex );
- OStreamSection aSection( Reference< XDataOutputStream >( _rxOutStream, UNO_QUERY ) );
+ OStreamSection aSection( _rxOutStream );
// version
_rxOutStream->writeShort( 0x0001 );
@@ -224,7 +224,7 @@ namespace frm
// version
{
- OStreamSection aSection( Reference< XDataInputStream >( _rxInStream, UNO_QUERY ) );
+ OStreamSection aSection( _rxInStream );
sal_uInt16 nVersion = _rxInStream->readShort();
if ( nVersion == 0x0001 )
diff --git a/forms/source/misc/InterfaceContainer.cxx b/forms/source/misc/InterfaceContainer.cxx
index 3a1361db17cc..9996a7d7b729 100644
--- a/forms/source/misc/InterfaceContainer.cxx
+++ b/forms/source/misc/InterfaceContainer.cxx
@@ -262,8 +262,7 @@ void OInterfaceContainer::disposing()
// revoke event knittings
if ( m_xEventAttacher.is() )
{
- Reference< XInterface > xIfc( xSet, UNO_QUERY );
- m_xEventAttacher->detach( i - 1, xIfc );
+ m_xEventAttacher->detach( i - 1, xSet );
m_xEventAttacher->removeEntry( i - 1 );
}
diff --git a/forms/source/xforms/model.cxx b/forms/source/xforms/model.cxx
index 60863373746e..8a27b2efe4fe 100644
--- a/forms/source/xforms/model.cxx
+++ b/forms/source/xforms/model.cxx
@@ -159,7 +159,7 @@ EvaluationContext Model::getEvaluationContext()
xElement = Reference<XNode>(
xInstance->createElement( "instanceData" ),
UNO_QUERY_THROW );
- Reference<XNode>( xInstance, UNO_QUERY_THROW)->appendChild( xElement );
+ xInstance->appendChild( xElement );
}
OSL_ENSURE( xElement.is() &&
diff --git a/forms/source/xforms/model_ui.cxx b/forms/source/xforms/model_ui.cxx
index 39c269087710..7e28623c5a2f 100644
--- a/forms/source/xforms/model_ui.cxx
+++ b/forms/source/xforms/model_ui.cxx
@@ -669,7 +669,7 @@ Model::XNode_t Model::renameNode( const XNode_t& xNode,
// replace node
Reference<XNode> xParent = xNode->getParentNode();
xParent->removeChild( xNode );
- xNew = xParent->appendChild( Reference<XNode>( xAttr, UNO_QUERY ) );
+ xNew = xParent->appendChild( xAttr );
}
else
{
@@ -790,9 +790,7 @@ static OUString lcl_serializeForDisplay( const Reference<XNodeList>& xNodes )
Reference<XDocument> xDocument( getDocumentBuilder()->newDocument() );
Reference<XDocumentFragment> xFragment(
xDocument->createDocumentFragment() );
- Reference<XNode> xNode( xFragment, UNO_QUERY );
OSL_ENSURE( xFragment.is(), "xFragment" );
- OSL_ENSURE( xNode.is(), "xNode" );
sal_Int32 nAttributeNodes = 0;
@@ -824,7 +822,7 @@ static OUString lcl_serializeForDisplay( const Reference<XNodeList>& xNodes )
}
// append node
- xNode->appendChild( xDocument->importNode( xCurrent, sal_True ) );
+ xFragment->appendChild( xDocument->importNode( xCurrent, sal_True ) );
}
OSL_ENSURE( ( nAttributeNodes == 0 ) || ( nAttributeNodes == nLength ),
"lcl_serializeForDisplay: mixed attribute and non-attribute nodes?" );
diff --git a/forms/source/xforms/submission.cxx b/forms/source/xforms/submission.cxx
index a9dd5348627e..cc4f53ccf48e 100644
--- a/forms/source/xforms/submission.cxx
+++ b/forms/source/xforms/submission.cxx
@@ -666,7 +666,7 @@ Reference< XDocumentFragment > Submission::createSubmissionDocument(const Refere
aListItem = Reference< XNode >(
(Reference< XDocument >(aListItem, UNO_QUERY))->getDocumentElement(), UNO_QUERY);
// copy relevant nodes from instance into fragment
- _cloneNodes(*getModelImpl(), Reference< XNode >(aFragment, UNO_QUERY), aListItem, bRemoveWSNodes);
+ _cloneNodes(*getModelImpl(), aFragment, aListItem, bRemoveWSNodes);
}
}
return aFragment;
diff --git a/forms/source/xforms/submission/replace.cxx b/forms/source/xforms/submission/replace.cxx
index 18da787de5f0..24391c062cd2 100644
--- a/forms/source/xforms/submission/replace.cxx
+++ b/forms/source/xforms/submission/replace.cxx
@@ -85,8 +85,8 @@ CSubmission::SubmissionResult CSubmission::replace(const OUString& aReplace, con
Reference< XElement > oldRoot = aDocument->getDocumentElement();
Reference< XElement > newRoot = aNewDocument->getDocumentElement();
- Reference< XNode > aImportedNode = aDocument->importNode(Reference< XNode >(newRoot, UNO_QUERY_THROW), sal_True);
- Reference< XNode >(aDocument, UNO_QUERY_THROW)->replaceChild(aImportedNode, Reference< XNode >(oldRoot, UNO_QUERY_THROW));
+ Reference< XNode > aImportedNode = aDocument->importNode(newRoot, sal_True);
+ aDocument->replaceChild(aImportedNode, oldRoot);
return CSubmission::SUCCESS;
} else {
return CSubmission::UNKNOWN_ERROR;