summaryrefslogtreecommitdiff
path: root/oox/source/ole
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2020-05-26 20:42:08 +0200
committerStephan Bergmann <sbergman@redhat.com>2020-05-26 22:33:02 +0200
commitfe6cce01c88d045a1fcf09acf049c34c22299b02 (patch)
treec118594a43386096bca55179f31b2b61e64dfa48 /oox/source/ole
parentb894a3d7f991dd248dfd8935b31da8bccfd130b2 (diff)
Fix loplugin:simplifypointertobool for libstdc++ std::shared_ptr
...where the get member function is defined on a std::__shared_ptr base class, so loplugin:simplifypointertobool used to miss those until now. (While e.g. using libc++ on macOS found those cases.) 366d08f2f6d4de922f6099c62bb81b49d89e0a68 "new loplugin:simplifypointertobool" was mistaken in breaking isSmartPointerType(const clang::Type* t) out of isSmartPointerType(const Expr* e); c874294ad9fb178df47c66875bfbdec466e39763 "Fix detection of std::unique_ptr/shared_ptr in loplugin:redundantpointerops" had introduced that indivisible two-step algorithm on purpose. The amount of additional hits (on Linux) apparently asked for turning loplugin:simplifypointertobool into a rewriting plugin. Which in turn showed that the naive adivce to just "drop the get()" is not sufficient in places that are not contextually converted to bool, as those places need to be wrapped in a bool(...) functional cast now. If the expression was already wrapped in parentheses, those could be reused as part of the functional cast, but implementing that showed that such cases are not yet found at all by the existing loplugin:simplifypointertobool. Lets leave that TODO for another commit. Besides the changes to compilerplugins/ itself, this change has been generated fully automatically with the rewriting plugin on Linux. Change-Id: I83107d6f634fc9ac232986f49044d7017df83e2a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94888 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Stephan Bergmann <sbergman@redhat.com> Tested-by: Jenkins
Diffstat (limited to 'oox/source/ole')
-rw-r--r--oox/source/ole/axcontrol.cxx6
-rw-r--r--oox/source/ole/olestorage.cxx4
-rw-r--r--oox/source/ole/vbacontrol.cxx28
-rw-r--r--oox/source/ole/vbaproject.cxx2
4 files changed, 20 insertions, 20 deletions
diff --git a/oox/source/ole/axcontrol.cxx b/oox/source/ole/axcontrol.cxx
index 78cc0b76770d..706514baf1c2 100644
--- a/oox/source/ole/axcontrol.cxx
+++ b/oox/source/ole/axcontrol.cxx
@@ -2688,12 +2688,12 @@ ControlModelBase* EmbeddedControl::createModelFromGuid( const OUString& rClassId
OUString EmbeddedControl::getServiceName() const
{
- return mxModel.get() ? mxModel->getServiceName() : OUString();
+ return mxModel ? mxModel->getServiceName() : OUString();
}
bool EmbeddedControl::convertProperties( const Reference< XControlModel >& rxCtrlModel, const ControlConverter& rConv ) const
{
- if( mxModel.get() && rxCtrlModel.is() && !maName.isEmpty() )
+ if( mxModel && rxCtrlModel.is() && !maName.isEmpty() )
{
PropertyMap aPropMap;
aPropMap.setProperty( PROP_Name, maName );
@@ -2715,7 +2715,7 @@ bool EmbeddedControl::convertProperties( const Reference< XControlModel >& rxCtr
void EmbeddedControl::convertFromProperties( const Reference< XControlModel >& rxCtrlModel, const ControlConverter& rConv )
{
- if( mxModel.get() && rxCtrlModel.is() && !maName.isEmpty() )
+ if( mxModel && rxCtrlModel.is() && !maName.isEmpty() )
{
PropertySet aPropSet( rxCtrlModel );
aPropSet.getProperty( maName, PROP_Name );
diff --git a/oox/source/ole/olestorage.cxx b/oox/source/ole/olestorage.cxx
index f5113ebc62c4..82aa1cd79fe8 100644
--- a/oox/source/ole/olestorage.cxx
+++ b/oox/source/ole/olestorage.cxx
@@ -311,13 +311,13 @@ StorageRef OleStorage::implOpenSubStorage( const OUString& rElementName, bool bC
new OLE storage based on a temporary file. All operations are
performed on this clean storage. On committing, the storage will be
completely re-inserted into the parent storage. */
- if( !isReadOnly() && (bCreateMissing || xSubStorage.get()) ) try
+ if( !isReadOnly() && (bCreateMissing || xSubStorage) ) try
{
// create new storage based on a temp file
Reference< XStream > xTempFile( TempFile::create(mxContext), UNO_QUERY_THROW );
StorageRef xTempStorage( new OleStorage( *this, xTempFile, rElementName ) );
// copy existing substorage into temp storage
- if( xSubStorage.get() )
+ if( xSubStorage )
xSubStorage->copyStorageToStorage( *xTempStorage );
// return the temp storage to caller
xSubStorage = xTempStorage;
diff --git a/oox/source/ole/vbacontrol.cxx b/oox/source/ole/vbacontrol.cxx
index c48e701e1dae..d0a5952ba486 100644
--- a/oox/source/ole/vbacontrol.cxx
+++ b/oox/source/ole/vbacontrol.cxx
@@ -279,7 +279,7 @@ ControlModelRef VbaSiteModel::createControlModel( const AxClassTable& rClassTabl
}
}
- if( xCtrlModel.get() )
+ if( xCtrlModel )
{
// user form controls are AWT models
xCtrlModel->setAwtModelMode();
@@ -324,14 +324,14 @@ VbaFormControl::~VbaFormControl()
void VbaFormControl::importModelOrStorage( BinaryInputStream& rInStrm, StorageBase& rStrg, const AxClassTable& rClassTable )
{
- if( !mxSiteModel.get() )
+ if( !mxSiteModel )
return;
if( mxSiteModel->isContainer() )
{
StorageRef xSubStrg = rStrg.openSubStorage( mxSiteModel->getSubStorageName(), false );
OSL_ENSURE( xSubStrg.get(), "VbaFormControl::importModelOrStorage - cannot find storage for embedded control" );
- if( xSubStrg.get() )
+ if( xSubStrg )
importStorage( *xSubStrg, rClassTable );
}
else if( !rInStrm.isEof() )
@@ -344,13 +344,13 @@ void VbaFormControl::importModelOrStorage( BinaryInputStream& rInStrm, StorageBa
OUString VbaFormControl::getControlName() const
{
- return mxSiteModel.get() ? mxSiteModel->getName() : OUString();
+ return mxSiteModel ? mxSiteModel->getName() : OUString();
}
void VbaFormControl::createAndConvert( sal_Int32 nCtrlIndex,
const Reference< XNameContainer >& rxParentNC, const ControlConverter& rConv ) const
{
- if( !(rxParentNC.is() && mxSiteModel.get() && mxCtrlModel.get()) )
+ if( !(rxParentNC.is() && mxSiteModel && mxCtrlModel) )
return;
try
@@ -379,7 +379,7 @@ void VbaFormControl::createAndConvert( sal_Int32 nCtrlIndex,
void VbaFormControl::importControlModel( BinaryInputStream& rInStrm, const AxClassTable& rClassTable )
{
createControlModel( rClassTable );
- if( mxCtrlModel.get() )
+ if( mxCtrlModel )
mxCtrlModel->importBinaryModel( rInStrm );
}
@@ -442,7 +442,7 @@ void VbaFormControl::importStorage( StorageBase& rStrg, const AxClassTable& rCla
if (elem->getControlType() == API_CONTROL_PAGE)
{
VbaSiteModelRef xPageSiteRef = control->mxSiteModel;
- if ( xPageSiteRef.get() )
+ if ( xPageSiteRef )
idToPage[ xPageSiteRef->getId() ] = control;
}
else
@@ -484,7 +484,7 @@ void VbaFormControl::importStorage( StorageBase& rStrg, const AxClassTable& rCla
bool VbaFormControl::convertProperties( const Reference< XControlModel >& rxCtrlModel,
const ControlConverter& rConv, sal_Int32 nCtrlIndex ) const
{
- if( rxCtrlModel.is() && mxSiteModel.get() && mxCtrlModel.get() )
+ if( rxCtrlModel.is() && mxSiteModel && mxCtrlModel )
{
const OUString& rCtrlName = mxSiteModel->getName();
OSL_ENSURE( !rCtrlName.isEmpty(), "VbaFormControl::convertProperties - control without name" );
@@ -524,7 +524,7 @@ bool VbaFormControl::convertProperties( const Reference< XControlModel >& rxCtrl
void VbaFormControl::createControlModel( const AxClassTable& rClassTable )
{
// derived classes may have created their own control model
- if( !mxCtrlModel && mxSiteModel.get() )
+ if( !mxCtrlModel && mxSiteModel )
mxCtrlModel = mxSiteModel->createControlModel( rClassTable );
}
@@ -603,7 +603,7 @@ void VbaFormControl::finalizeEmbeddedControls()
VbaControlNameInserter aInserter( aControlNames );
maControls.forEach( aInserter );
for (auto const& control : maControls)
- if( control->mxCtrlModel.get() && (control->mxCtrlModel->getControlType() == API_CONTROL_GROUPBOX) )
+ if( control->mxCtrlModel && (control->mxCtrlModel->getControlType() == API_CONTROL_GROUPBOX) )
control->maControls.forEach( aInserter );
/* Reprocess the sorted list and collect all option button controls that
@@ -689,13 +689,13 @@ void VbaFormControl::finalizeEmbeddedControls()
void VbaFormControl::moveRelative( const AxPairData& rDistance )
{
- if( mxSiteModel.get() )
+ if( mxSiteModel )
mxSiteModel->moveRelative( rDistance );
}
void VbaFormControl::moveEmbeddedToAbsoluteParent()
{
- if( !(mxSiteModel.get() && !maControls.empty()) )
+ if( !(mxSiteModel && !maControls.empty()) )
return;
// distance to move is equal to position of this control in its parent
@@ -718,8 +718,8 @@ void VbaFormControl::moveEmbeddedToAbsoluteParent()
bool VbaFormControl::compareByTabIndex( const VbaFormControlRef& rxLeft, const VbaFormControlRef& rxRight )
{
// sort controls without model to the end
- sal_Int32 nLeftTabIndex = rxLeft->mxSiteModel.get() ? rxLeft->mxSiteModel->getTabIndex() : SAL_MAX_INT32;
- sal_Int32 nRightTabIndex = rxRight->mxSiteModel.get() ? rxRight->mxSiteModel->getTabIndex() : SAL_MAX_INT32;
+ sal_Int32 nLeftTabIndex = rxLeft->mxSiteModel ? rxLeft->mxSiteModel->getTabIndex() : SAL_MAX_INT32;
+ sal_Int32 nRightTabIndex = rxRight->mxSiteModel ? rxRight->mxSiteModel->getTabIndex() : SAL_MAX_INT32;
return nLeftTabIndex < nRightTabIndex;
}
diff --git a/oox/source/ole/vbaproject.cxx b/oox/source/ole/vbaproject.cxx
index 02b290ed8d1c..3434cb306d66 100644
--- a/oox/source/ole/vbaproject.cxx
+++ b/oox/source/ole/vbaproject.cxx
@@ -491,7 +491,7 @@ void VbaProject::importModulesAndForms( StorageBase& rVbaPrjStrg, const GraphicH
if( elem != "VBA" )
{
StorageRef xSubStrg = rVbaPrjStrg.openSubStorage( elem, false );
- if( xSubStrg.get() ) try
+ if( xSubStrg ) try
{
// resolve module name from storage name (which equals the module stream name)
VbaModule* pModule = maModulesByStrm.get( elem ).get();