loplugin:constmethod in comphelper,ucbhelper

Change-Id: I27a860fbbedd2174c60c199af18cae76e02abc25
Reviewed-on: https://gerrit.libreoffice.org/43759
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2017-10-24 13:02:58 +02:00
parent 80a30219c4
commit 57c5f98083
20 changed files with 52 additions and 43 deletions

View File

@@ -226,12 +226,12 @@ OUString EmbeddedObjectContainer::CreateUniqueObjectName()
return aStr; return aStr;
} }
uno::Sequence < OUString > EmbeddedObjectContainer::GetObjectNames() uno::Sequence < OUString > EmbeddedObjectContainer::GetObjectNames() const
{ {
return comphelper::mapKeysToSequence(pImpl->maObjectContainer); return comphelper::mapKeysToSequence(pImpl->maObjectContainer);
} }
bool EmbeddedObjectContainer::HasEmbeddedObjects() bool EmbeddedObjectContainer::HasEmbeddedObjects() const
{ {
return pImpl->maObjectContainer.size() != 0; return pImpl->maObjectContainer.size() != 0;
} }
@@ -247,7 +247,7 @@ bool EmbeddedObjectContainer::HasEmbeddedObject( const OUString& rName )
return xAccess->hasByName(rName); return xAccess->hasByName(rName);
} }
bool EmbeddedObjectContainer::HasEmbeddedObject( const uno::Reference < embed::XEmbeddedObject >& xObj ) bool EmbeddedObjectContainer::HasEmbeddedObject( const uno::Reference < embed::XEmbeddedObject >& xObj ) const
{ {
for( const auto& rObj : pImpl->maObjectContainer ) for( const auto& rObj : pImpl->maObjectContainer )
{ {
@@ -266,7 +266,7 @@ bool EmbeddedObjectContainer::HasInstantiatedEmbeddedObject( const OUString& rNa
return ( aIt != pImpl->maObjectContainer.end() ); return ( aIt != pImpl->maObjectContainer.end() );
} }
OUString EmbeddedObjectContainer::GetEmbeddedObjectName( const css::uno::Reference < css::embed::XEmbeddedObject >& xObj ) OUString EmbeddedObjectContainer::GetEmbeddedObjectName( const css::uno::Reference < css::embed::XEmbeddedObject >& xObj ) const
{ {
for( const auto& rObj : pImpl->maObjectContainer ) for( const auto& rObj : pImpl->maObjectContainer )
{ {

View File

@@ -1653,7 +1653,7 @@ namespace
} }
} }
bool empty() bool empty() const
{ {
return maPackedFileEntryVector.empty(); return maPackedFileEntryVector.empty();
} }
@@ -1940,7 +1940,7 @@ namespace comphelper
return bDidPop; return bDidPop;
} }
bool BackupFileHelper::isPopPossibleExtensionInfo() bool BackupFileHelper::isPopPossibleExtensionInfo() const
{ {
bool bPopPossible(false); bool bPopPossible(false);

View File

@@ -712,7 +712,7 @@ void SyntaxHighlighter::getHighlightPortions(const OUString& rLine,
m_tokenizer->getHighlightPortions( rLine, portions ); m_tokenizer->getHighlightPortions( rLine, portions );
} }
HighlighterLanguage SyntaxHighlighter::GetLanguage() HighlighterLanguage SyntaxHighlighter::GetLanguage() const
{ {
return m_tokenizer->aLanguage; return m_tokenizer->aLanguage;
} }

View File

@@ -149,7 +149,7 @@ namespace comphelper
} }
PropertyState OPropertyStateContainer::getPropertyStateByHandle( sal_Int32 _nHandle ) PropertyState OPropertyStateContainer::getPropertyStateByHandle( sal_Int32 _nHandle ) const
{ {
// simply compare the current and the default value // simply compare the current and the default value
Any aCurrentValue; getFastPropertyValue( aCurrentValue, _nHandle ); Any aCurrentValue; getFastPropertyValue( aCurrentValue, _nHandle );

View File

@@ -68,7 +68,7 @@ class OFOPXMLHelper_Impl
public: public:
css::uno::Sequence< css::uno::Sequence< css::beans::StringPair > > const & GetParsingResult(); css::uno::Sequence< css::uno::Sequence< css::beans::StringPair > > const & GetParsingResult() const;
explicit OFOPXMLHelper_Impl( sal_uInt16 nFormat ); // must not be created directly explicit OFOPXMLHelper_Impl( sal_uInt16 nFormat ); // must not be created directly
@@ -269,7 +269,7 @@ OFOPXMLHelper_Impl::OFOPXMLHelper_Impl( sal_uInt16 nFormat )
{ {
} }
uno::Sequence< uno::Sequence< beans::StringPair > > const & OFOPXMLHelper_Impl::GetParsingResult() uno::Sequence< uno::Sequence< beans::StringPair > > const & OFOPXMLHelper_Impl::GetParsingResult() const
{ {
if ( m_aElementsSeq.size() ) if ( m_aElementsSeq.size() )
throw uno::RuntimeException(); // the parsing has still not finished! throw uno::RuntimeException(); // the parsing has still not finished!

View File

@@ -1010,16 +1010,25 @@ LanguageTag::ImplPtr LanguageTag::registerImpl() const
} }
LanguageTag::ImplPtr const & LanguageTag::getImpl() const LanguageTagImpl const * LanguageTag::getImpl() const
{ {
if (!mpImpl) if (!mpImpl)
{ {
mpImpl = registerImpl(); mpImpl = registerImpl();
syncVarsFromRawImpl(); syncVarsFromRawImpl();
} }
return mpImpl; return mpImpl.get();
} }
LanguageTagImpl * LanguageTag::getImpl()
{
if (!mpImpl)
{
mpImpl = registerImpl();
syncVarsFromRawImpl();
}
return mpImpl.get();
}
void LanguageTag::resetVars() void LanguageTag::resetVars()
{ {
@@ -1277,8 +1286,7 @@ bool LanguageTagImpl::synCanonicalize()
void LanguageTag::syncFromImpl() void LanguageTag::syncFromImpl()
{ {
ImplPtr xImpl = getImpl(); LanguageTagImpl* pImpl = getImpl();
LanguageTagImpl* pImpl = xImpl.get();
bool bRegister = ((mbInitializedBcp47 && maBcp47 != pImpl->maBcp47) || bool bRegister = ((mbInitializedBcp47 && maBcp47 != pImpl->maBcp47) ||
(mbInitializedLangID && mnLangID != pImpl->mnLangID)); (mbInitializedLangID && mnLangID != pImpl->mnLangID));
SAL_INFO_IF( bRegister, "i18nlangtag", SAL_INFO_IF( bRegister, "i18nlangtag",
@@ -1829,7 +1837,7 @@ OUString const & LanguageTagImpl::getLanguage() const
OUString LanguageTag::getLanguage() const OUString LanguageTag::getLanguage() const
{ {
ImplPtr pImpl = getImpl(); LanguageTagImpl const* pImpl = getImpl();
if (pImpl->mbCachedLanguage) if (pImpl->mbCachedLanguage)
return pImpl->maCachedLanguage; return pImpl->maCachedLanguage;
OUString aRet( pImpl->getLanguage()); OUString aRet( pImpl->getLanguage());
@@ -1851,7 +1859,7 @@ OUString const & LanguageTagImpl::getScript() const
OUString LanguageTag::getScript() const OUString LanguageTag::getScript() const
{ {
ImplPtr pImpl = getImpl(); LanguageTagImpl const* pImpl = getImpl();
if (pImpl->mbCachedScript) if (pImpl->mbCachedScript)
return pImpl->maCachedScript; return pImpl->maCachedScript;
OUString aRet( pImpl->getScript()); OUString aRet( pImpl->getScript());
@@ -1887,7 +1895,7 @@ OUString const & LanguageTagImpl::getCountry() const
OUString LanguageTag::getCountry() const OUString LanguageTag::getCountry() const
{ {
ImplPtr pImpl = getImpl(); LanguageTagImpl const* pImpl = getImpl();
if (pImpl->mbCachedCountry) if (pImpl->mbCachedCountry)
return pImpl->maCachedCountry; return pImpl->maCachedCountry;
OUString aRet( pImpl->getCountry()); OUString aRet( pImpl->getCountry());
@@ -1915,7 +1923,7 @@ OUString const & LanguageTagImpl::getVariants() const
OUString LanguageTag::getVariants() const OUString LanguageTag::getVariants() const
{ {
ImplPtr pImpl = getImpl(); LanguageTagImpl const * pImpl = getImpl();
if (pImpl->mbCachedVariants) if (pImpl->mbCachedVariants)
return pImpl->maCachedVariants; return pImpl->maCachedVariants;
OUString aRet( pImpl->getVariants()); OUString aRet( pImpl->getVariants());

View File

@@ -39,7 +39,7 @@ namespace comphelper
bool mbInit; bool mbInit;
SlaveData ( ChainablePropertySet *pSlave); SlaveData ( ChainablePropertySet *pSlave);
bool IsInit () { return mbInit;} bool IsInit () const { return mbInit;}
void SetInit ( bool bInit) { mbInit = bInit; } void SetInit ( bool bInit) { mbInit = bInit; }
}; };
} }

View File

@@ -137,7 +137,7 @@ namespace comphelper
* isPopPossibleExtensionInfo is the specialized version for ExtensionInfo * isPopPossibleExtensionInfo is the specialized version for ExtensionInfo
*/ */
bool isPopPossible(); bool isPopPossible();
bool isPopPossibleExtensionInfo(); bool isPopPossibleExtensionInfo() const;
/** tries to execute a restore. Will overwrite the base file /** tries to execute a restore. Will overwrite the base file
* in that case and take one version off the 'stack' of copies. * in that case and take one version off the 'stack' of copies.

View File

@@ -80,18 +80,18 @@ public:
OUString CreateUniqueObjectName(); OUString CreateUniqueObjectName();
// get a list of object names that have been added so far // get a list of object names that have been added so far
css::uno::Sequence < OUString > GetObjectNames(); css::uno::Sequence < OUString > GetObjectNames() const;
// check for existence of objects at all // check for existence of objects at all
bool HasEmbeddedObjects(); bool HasEmbeddedObjects() const;
// check existence of an object - either by identity or by name // check existence of an object - either by identity or by name
bool HasEmbeddedObject( const OUString& ); bool HasEmbeddedObject( const OUString& );
bool HasEmbeddedObject( const css::uno::Reference < css::embed::XEmbeddedObject >& ); bool HasEmbeddedObject( const css::uno::Reference < css::embed::XEmbeddedObject >& ) const;
bool HasInstantiatedEmbeddedObject( const OUString& ); bool HasInstantiatedEmbeddedObject( const OUString& );
// get the object name of an object - this is the persist name if the object has persistence // get the object name of an object - this is the persist name if the object has persistence
OUString GetEmbeddedObjectName( const css::uno::Reference < css::embed::XEmbeddedObject >& ); OUString GetEmbeddedObjectName( const css::uno::Reference < css::embed::XEmbeddedObject >& ) const;
// retrieve an embedded object by name that either has been added already or is available in the container storage // retrieve an embedded object by name that either has been added already or is available in the container storage
css::uno::Reference<css::embed::XEmbeddedObject> GetEmbeddedObject(const OUString&, OUString const* pBaseURL = nullptr); css::uno::Reference<css::embed::XEmbeddedObject> GetEmbeddedObject(const OUString&, OUString const* pBaseURL = nullptr);

View File

@@ -74,14 +74,14 @@ namespace comphelper
<p>Already implemented by this base class, no need to override</p> <p>Already implemented by this base class, no need to override</p>
@precond <arg>_nHandle</arg> is a valid property handle @precond <arg>_nHandle</arg> is a valid property handle
*/ */
css::beans::PropertyState getPropertyStateByHandle( sal_Int32 _nHandle ); css::beans::PropertyState getPropertyStateByHandle( sal_Int32 _nHandle ) const;
/** set the property denoted by the given handle to its default value /** set the property denoted by the given handle to its default value
<p>Already implemented by this base class, no need to override</p> <p>Already implemented by this base class, no need to override</p>
@precond <arg>_nHandle</arg> is a valid property handle @precond <arg>_nHandle</arg> is a valid property handle
*/ */
void setPropertyToDefaultByHandle( sal_Int32 _nHandle ); void setPropertyToDefaultByHandle( sal_Int32 _nHandle );
/** get the default value for the property denoted by the given handle /** get the default value for the property denoted by the given handle

View File

@@ -88,7 +88,7 @@ namespace comphelper
css::uno::Reference< css::uno::XComponentContext > m_xContext; css::uno::Reference< css::uno::XComponentContext > m_xContext;
protected: protected:
const css::uno::Reference< css::uno::XComponentContext >& getComponentContext() const css::uno::Reference< css::uno::XComponentContext >& getComponentContext() const
{ {
return m_xContext; return m_xContext;
} }

View File

@@ -45,7 +45,7 @@ public:
void resetInterceptions(); void resetInterceptions();
void resetErrorStates(); void resetErrorStates();
bool wasWriteError() { return (m_bUsed && m_bHandledByMySelf);} bool wasWriteError() const { return (m_bUsed && m_bHandledByMySelf);}
private: private:
css::uno::Reference< css::task::XInteractionHandler > m_xAuxiliaryHandler; css::uno::Reference< css::task::XInteractionHandler > m_xAuxiliaryHandler;

View File

@@ -81,7 +81,7 @@ public:
void getHighlightPortions( const OUString& rLine, void getHighlightPortions( const OUString& rLine,
std::vector<HighlightPortion>& pPortions ) const; std::vector<HighlightPortion>& pPortions ) const;
HighlighterLanguage GetLanguage(); HighlighterLanguage GetLanguage() const;
}; };
#endif #endif

View File

@@ -544,7 +544,8 @@ private:
mutable bool mbInitializedLangID : 1; mutable bool mbInitializedLangID : 1;
bool mbIsFallback : 1; bool mbIsFallback : 1;
ImplPtr const & getImpl() const; LanguageTagImpl* getImpl();
LanguageTagImpl const* getImpl() const;
ImplPtr registerImpl() const; ImplPtr registerImpl() const;
void syncFromImpl(); void syncFromImpl();
void syncVarsFromRawImpl() const; void syncVarsFromRawImpl() const;

View File

@@ -663,7 +663,7 @@ public:
bool bMajorVersion = false, bool bMajorVersion = false,
const OUString & rCommentVersion = OUString( ), const OUString & rCommentVersion = OUString( ),
OUString* pResultURL = nullptr, OUString* pResultURL = nullptr,
const OUString & rDocumentId = OUString( ) ); const OUString & rDocumentId = OUString( ) ) const;
/** /**
* This method lock the resource. * This method lock the resource.

View File

@@ -548,7 +548,7 @@ public:
// XAuthFallback // XAuthFallback
virtual void SAL_CALL setCode( const OUString& code ) override; virtual void SAL_CALL setCode( const OUString& code ) override;
/// @throws css::uno::RuntimeException /// @throws css::uno::RuntimeException
const OUString& SAL_CALL getCode(); const OUString& SAL_CALL getCode() const;
}; };

View File

@@ -259,7 +259,7 @@ public:
* @param rEvt is a property change event. * @param rEvt is a property change event.
*/ */
void propertyChanged( void propertyChanged(
const css::beans::PropertyChangeEvent& rEvt ); const css::beans::PropertyChangeEvent& rEvt ) const;
/** /**
* This method should be called by the data supplier for the result set * This method should be called by the data supplier for the result set
@@ -283,7 +283,7 @@ public:
* @return a sequence of properties. * @return a sequence of properties.
*/ */
const css::uno::Sequence< css::beans::Property >& const css::uno::Sequence< css::beans::Property >&
getProperties(); getProperties() const;
/** /**
* This method returns the environment to use for interactions, progress * This method returns the environment to use for interactions, progress
@@ -292,7 +292,7 @@ public:
* @return an environment or an empty reference. * @return an environment or an empty reference.
*/ */
const css::uno::Reference< css::ucb::XCommandEnvironment >& const css::uno::Reference< css::ucb::XCommandEnvironment >&
getEnvironment(); getEnvironment() const;
}; };

View File

@@ -174,7 +174,7 @@ public:
const OUString& getURL() const; const OUString& getURL() const;
Reference< XContent > getContent(); Reference< XContent > getContent();
Reference< XCommandProcessor > getCommandProcessor(); Reference< XCommandProcessor > getCommandProcessor();
Reference< XComponentContext > const & getComponentContext() Reference< XComponentContext > const & getComponentContext() const
{ assert(m_xCtx.is()); return m_xCtx; } { assert(m_xCtx.is()); return m_xCtx; }
Any executeCommand( const Command& rCommand ); Any executeCommand( const Command& rCommand );
@@ -944,7 +944,7 @@ bool Content::transferContent( const Content& rSourceContent,
bool bMajorVersion, bool bMajorVersion,
const OUString & rVersionComment, const OUString & rVersionComment,
OUString* pResultURL, OUString* pResultURL,
const OUString & rDocumentId ) const OUString & rDocumentId ) const
{ {
Reference< XUniversalContentBroker > pBroker( Reference< XUniversalContentBroker > pBroker(
UniversalContentBroker::create( m_xImpl->getComponentContext() ) ); UniversalContentBroker::create( m_xImpl->getComponentContext() ) );

View File

@@ -784,7 +784,7 @@ void SAL_CALL InteractionAuthFallback::setCode( const OUString& code )
m_aCode = code; m_aCode = code;
} }
const OUString& SAL_CALL InteractionAuthFallback::getCode( ) const OUString& SAL_CALL InteractionAuthFallback::getCode() const
{ {
return m_aCode; return m_aCode;
} }

View File

@@ -88,7 +88,7 @@ class PropertySetInfo :
private: private:
bool queryProperty( bool queryProperty(
const OUString& aName, beans::Property& rProp ); const OUString& aName, beans::Property& rProp ) const;
public: public:
PropertySetInfo( PropertySetInfo(
@@ -1362,7 +1362,7 @@ void SAL_CALL ResultSet::removeVetoableChangeListener(
// Non-interface methods. // Non-interface methods.
void ResultSet::propertyChanged( const beans::PropertyChangeEvent& rEvt ) void ResultSet::propertyChanged( const beans::PropertyChangeEvent& rEvt ) const
{ {
if ( !m_pImpl->m_pPropertyChangeListeners ) if ( !m_pImpl->m_pPropertyChangeListeners )
return; return;
@@ -1427,14 +1427,14 @@ void ResultSet::rowCountFinal()
} }
const uno::Sequence< beans::Property >& ResultSet::getProperties() const uno::Sequence< beans::Property >& ResultSet::getProperties() const
{ {
return m_pImpl->m_aProperties; return m_pImpl->m_aProperties;
} }
const uno::Reference< css::ucb::XCommandEnvironment >& const uno::Reference< css::ucb::XCommandEnvironment >&
ResultSet::getEnvironment() ResultSet::getEnvironment() const
{ {
return m_pImpl->m_xEnv; return m_pImpl->m_xEnv;
} }
@@ -1537,7 +1537,7 @@ sal_Bool SAL_CALL PropertySetInfo::hasPropertyByName(
bool PropertySetInfo::queryProperty( bool PropertySetInfo::queryProperty(
const OUString& aName, beans::Property& rProp ) const OUString& aName, beans::Property& rProp ) const
{ {
sal_Int32 nCount = m_pProps->getLength(); sal_Int32 nCount = m_pProps->getLength();
const beans::Property* pProps = m_pProps->getConstArray(); const beans::Property* pProps = m_pProps->getConstArray();