diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-01-27 16:09:54 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-01-28 09:22:55 +0000 |
commit | f1d83ac45f08270f7f2dd7128056effd0251dc5e (patch) | |
tree | 55d924eaa7f55627039d44458d869ef65130fdf8 /sfx2 | |
parent | 53d3755972bfd3bd2cd650edf91f1483038028c8 (diff) |
loplugin:stringconstant check for unnecessary OUString constructor..
..calls when creating exceptions
Change-Id: I3bc58a5aa4dc6f0508ecb88b3a843b96b8c7ebfe
Reviewed-on: https://gerrit.libreoffice.org/33617
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/appl/imestatuswindow.cxx | 7 | ||||
-rw-r--r-- | sfx2/source/control/thumbnailviewacc.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/dialog/backingcomp.cxx | 14 | ||||
-rw-r--r-- | sfx2/source/doc/DocumentMetadataAccess.cxx | 5 | ||||
-rw-r--r-- | sfx2/source/doc/Metadatable.cxx | 33 | ||||
-rw-r--r-- | sfx2/source/doc/SfxDocumentMetaData.cxx | 90 | ||||
-rw-r--r-- | sfx2/source/notify/globalevents.cxx | 4 |
7 files changed, 72 insertions, 83 deletions
diff --git a/sfx2/source/appl/imestatuswindow.cxx b/sfx2/source/appl/imestatuswindow.cxx index 58c0f15184d2..0fa5823fcb4c 100644 --- a/sfx2/source/appl/imestatuswindow.cxx +++ b/sfx2/source/appl/imestatuswindow.cxx @@ -189,7 +189,7 @@ css::uno::Reference< css::beans::XPropertySet > ImeStatusWindow::getConfig() throw css::lang::DisposedException(); if (!m_xContext.is()) throw css::uno::RuntimeException( - OUString("null comphelper::getProcessServiceFactory"), + "null comphelper::getProcessServiceFactory", nullptr); css::uno::Reference< css::lang::XMultiServiceFactory > xProvider = css::configuration::theDefaultProvider::get( m_xContext ); @@ -208,9 +208,8 @@ css::uno::Reference< css::beans::XPropertySet > ImeStatusWindow::getConfig() css::uno::UNO_QUERY); if (!m_xConfig.is()) throw css::uno::RuntimeException( - OUString( - "null com.sun.star.configuration." - "ConfigurationUpdateAccess"), + "null com.sun.star.configuration." + "ConfigurationUpdateAccess", nullptr); bAdd = true; } diff --git a/sfx2/source/control/thumbnailviewacc.cxx b/sfx2/source/control/thumbnailviewacc.cxx index 32551122c55b..45648edceef7 100644 --- a/sfx2/source/control/thumbnailviewacc.cxx +++ b/sfx2/source/control/thumbnailviewacc.cxx @@ -556,7 +556,7 @@ void ThumbnailViewAcc::ThrowIfDisposed() { SAL_WARN("sfx", "Calling disposed object. Throwing exception:"); throw lang::DisposedException ( - OUString("object has been already disposed"), + "object has been already disposed", static_cast<uno::XWeak*>(this)); } else diff --git a/sfx2/source/dialog/backingcomp.cxx b/sfx2/source/dialog/backingcomp.cxx index db2d583df39b..f242c8731d9e 100644 --- a/sfx2/source/dialog/backingcomp.cxx +++ b/sfx2/source/dialog/backingcomp.cxx @@ -365,12 +365,12 @@ void SAL_CALL BackingComp::attachFrame( /*IN*/ const css::uno::Reference< css::f // check some required states if (m_xFrame.is()) throw css::uno::RuntimeException( - OUString("already attached"), + "already attached", static_cast< ::cppu::OWeakObject* >(this)); if (!xFrame.is()) throw css::uno::RuntimeException( - OUString("invalid frame reference"), + "invalid frame reference", static_cast< ::cppu::OWeakObject* >(this)); if (!m_xWindow.is()) @@ -550,7 +550,7 @@ void SAL_CALL BackingComp::disposing( /*IN*/ const css::lang::EventObject& aEven if (!aEvent.Source.is() || aEvent.Source!=m_xWindow || !m_xWindow.is()) throw css::uno::RuntimeException( - OUString("unexpected source or called twice"), + "unexpected source or called twice", static_cast< ::cppu::OWeakObject* >(this)); m_xWindow.clear(); @@ -616,7 +616,7 @@ void SAL_CALL BackingComp::dispose() void SAL_CALL BackingComp::addEventListener( /*IN*/ const css::uno::Reference< css::lang::XEventListener >& ) { throw css::uno::RuntimeException( - OUString("not supported"), + "not supported", static_cast< ::cppu::OWeakObject* >(this)); } @@ -659,7 +659,7 @@ void SAL_CALL BackingComp::initialize( /*IN*/ const css::uno::Sequence< css::uno if (m_xWindow.is()) throw css::uno::Exception( - OUString("already initialized"), + "already initialized", static_cast< ::cppu::OWeakObject* >(this)); css::uno::Reference< css::awt::XWindow > xParentWindow; @@ -670,7 +670,7 @@ void SAL_CALL BackingComp::initialize( /*IN*/ const css::uno::Sequence< css::uno ) { throw css::uno::Exception( - OUString("wrong or corrupt argument list"), + "wrong or corrupt argument list", static_cast< ::cppu::OWeakObject* >(this)); } @@ -681,7 +681,7 @@ void SAL_CALL BackingComp::initialize( /*IN*/ const css::uno::Sequence< css::uno if (!m_xWindow.is()) throw css::uno::RuntimeException( - OUString("couldn't create component window"), + "couldn't create component window", static_cast< ::cppu::OWeakObject* >(this)); // start listening for window disposing diff --git a/sfx2/source/doc/DocumentMetadataAccess.cxx b/sfx2/source/doc/DocumentMetadataAccess.cxx index 9b805abb39be..fb4376e0b38c 100644 --- a/sfx2/source/doc/DocumentMetadataAccess.cxx +++ b/sfx2/source/doc/DocumentMetadataAccess.cxx @@ -723,9 +723,8 @@ retry: if (rterr.hasValue()) { throw lang::WrappedTargetRuntimeException( - OUString( - "DocumentMetadataAccess::loadMetadataFromStorage: " - "exception"), nullptr, rterr); + "DocumentMetadataAccess::loadMetadataFromStorage: " + "exception", nullptr, rterr); } if (err) { diff --git a/sfx2/source/doc/Metadatable.cxx b/sfx2/source/doc/Metadatable.cxx index 86d2f7eb0d19..fecd4a0472dc 100644 --- a/sfx2/source/doc/Metadatable.cxx +++ b/sfx2/source/doc/Metadatable.cxx @@ -509,8 +509,7 @@ XmlIdRegistryDocument::XmlIdRegistry_Impl::LookupElement( { if (!isValidXmlId(i_rStreamName, i_rIdref)) { - throw lang::IllegalArgumentException(OUString( - "illegal XmlId"), nullptr, 0); + throw lang::IllegalArgumentException("illegal XmlId", nullptr, 0); } const XmlIdList_t * pList( LookupElementList(i_rStreamName, i_rIdref) ); @@ -663,15 +662,13 @@ XmlIdRegistryDocument::TryRegisterMetadatable(Metadatable & i_rObject, if (!isValidXmlId(i_rStreamName, i_rIdref)) { - throw lang::IllegalArgumentException(OUString( - "illegal XmlId"), nullptr, 0); + throw lang::IllegalArgumentException("illegal XmlId", nullptr, 0); } if (i_rObject.IsInContent() ? !isContentFile(i_rStreamName) : !isStylesFile(i_rStreamName)) { - throw lang::IllegalArgumentException(OUString( - "illegal XmlId: wrong stream"), nullptr, 0); + throw lang::IllegalArgumentException("illegal XmlId: wrong stream", nullptr, 0); } OUString old_path; @@ -953,8 +950,7 @@ XmlIdRegistryClipboard::XmlIdRegistry_Impl::LookupEntry( { if (!isValidXmlId(i_rStreamName, i_rIdref)) { - throw lang::IllegalArgumentException(OUString( - "illegal XmlId"), nullptr, 0); + throw lang::IllegalArgumentException("illegal XmlId", nullptr, 0); } const ClipboardXmlIdMap_t::const_iterator iter( m_XmlIdMap.find(i_rIdref) ); @@ -1076,15 +1072,13 @@ XmlIdRegistryClipboard::TryRegisterMetadatable(Metadatable & i_rObject, if (!isValidXmlId(i_rStreamName, i_rIdref)) { - throw lang::IllegalArgumentException(OUString( - "illegal XmlId"), nullptr, 0); + throw lang::IllegalArgumentException("illegal XmlId", nullptr, 0); } if (i_rObject.IsInContent() ? !isContentFile(i_rStreamName) : !isStylesFile(i_rStreamName)) { - throw lang::IllegalArgumentException(OUString( - "illegal XmlId: wrong stream"), nullptr, 0); + throw lang::IllegalArgumentException("illegal XmlId: wrong stream", nullptr, 0); } OUString old_path; @@ -1207,8 +1201,7 @@ XmlIdRegistryClipboard::RegisterCopyClipboard(Metadatable & i_rCopy, if (!isValidXmlId(i_rReference.First, i_rReference.Second)) { - throw lang::IllegalArgumentException(OUString( - "illegal XmlId"), nullptr, 0); + throw lang::IllegalArgumentException("illegal XmlId", nullptr, 0); } if (!i_isLatent) @@ -1297,8 +1290,7 @@ void Metadatable::SetMetadataReference( const css::beans::StringPair & i_rRefere else { throw lang::IllegalArgumentException( - OUString("Metadatable::" - "SetMetadataReference: argument is invalid"), /*this*/nullptr, 0); + "Metadatable::SetMetadataReference: argument is invalid", /*this*/nullptr, 0); } } } @@ -1559,8 +1551,7 @@ MetadatableMixin::getMetadataReference() if (!pObject) { throw uno::RuntimeException( - OUString( - "MetadatableMixin: cannot get core object; not inserted?"), + "MetadatableMixin: cannot get core object; not inserted?", *this); } return pObject->GetMetadataReference(); @@ -1576,8 +1567,7 @@ MetadatableMixin::setMetadataReference( if (!pObject) { throw uno::RuntimeException( - OUString( - "MetadatableMixin: cannot get core object; not inserted?"), + "MetadatableMixin: cannot get core object; not inserted?", *this); } return pObject->SetMetadataReference(i_rReference); @@ -1591,8 +1581,7 @@ void SAL_CALL MetadatableMixin::ensureMetadataReference() if (!pObject) { throw uno::RuntimeException( - OUString( - "MetadatableMixin: cannot get core object; not inserted?"), + "MetadatableMixin: cannot get core object; not inserted?", *this); } return pObject->EnsureMetadataReference(); diff --git a/sfx2/source/doc/SfxDocumentMetaData.cxx b/sfx2/source/doc/SfxDocumentMetaData.cxx index 6870e7fe1867..f519833c05f5 100644 --- a/sfx2/source/doc/SfxDocumentMetaData.cxx +++ b/sfx2/source/doc/SfxDocumentMetaData.cxx @@ -596,8 +596,8 @@ SfxDocumentMetaData::getURLProperties( OUString SAL_CALL getNodeText(const css::uno::Reference<css::xml::dom::XNode>& i_xNode) { - if (!i_xNode.is()) throw css::uno::RuntimeException( - OUString("SfxDocumentMetaData::getNodeText: argument is null"), i_xNode); + if (!i_xNode.is()) + throw css::uno::RuntimeException("SfxDocumentMetaData::getNodeText: argument is null", i_xNode); for (css::uno::Reference<css::xml::dom::XNode> c = i_xNode->getFirstChild(); c.is(); c = c->getNextSibling()) { @@ -674,7 +674,7 @@ SfxDocumentMetaData::setMetaText(const char* i_name, } catch (const css::xml::dom::DOMException & e) { css::uno::Any a(e); throw css::lang::WrappedTargetRuntimeException( - OUString("SfxDocumentMetaData::setMetaText: DOM exception"), + "SfxDocumentMetaData::setMetaText: DOM exception", css::uno::Reference<css::uno::XInterface>(*this), a); } } @@ -806,7 +806,7 @@ SfxDocumentMetaData::setMetaList(const char* i_name, } catch (const css::xml::dom::DOMException & e) { css::uno::Any a(e); throw css::lang::WrappedTargetRuntimeException( - OUString("SfxDocumentMetaData::setMetaList: DOM exception"), + "SfxDocumentMetaData::setMetaList: DOM exception", css::uno::Reference<css::uno::XInterface>(*this), a); } } @@ -956,7 +956,7 @@ SfxDocumentMetaData::updateElement(const char *i_name, } catch (const css::xml::dom::DOMException & e) { css::uno::Any a(e); throw css::lang::WrappedTargetRuntimeException( - OUString("SfxDocumentMetaData::updateElement: DOM exception"), + "SfxDocumentMetaData::updateElement: DOM exception", css::uno::Reference<css::uno::XInterface>(*this), a); } } @@ -1032,9 +1032,9 @@ SfxDocumentMetaData::createDOM() const // throw (css::uno::RuntimeException) css::uno::Reference<css::lang::XMultiComponentFactory> xMsf ( m_xContext->getServiceManager()); css::uno::Reference<css::xml::dom::XDocumentBuilder> xBuilder( css::xml::dom::DocumentBuilder::create(m_xContext) ); css::uno::Reference<css::xml::dom::XDocument> xDoc = xBuilder->newDocument(); - if (!xDoc.is()) throw css::uno::RuntimeException( - OUString("SfxDocumentMetaData::createDOM: " - "cannot create new document"), + if (!xDoc.is()) + throw css::uno::RuntimeException( + "SfxDocumentMetaData::createDOM: cannot create new document", *const_cast<SfxDocumentMetaData*>(this)); return xDoc; } @@ -1043,8 +1043,8 @@ void SAL_CALL SfxDocumentMetaData::checkInit() const // throw (css::uno::RuntimeException) { if (!m_isInitialized) { - throw css::uno::RuntimeException(OUString( - "SfxDocumentMetaData::checkInit: not initialized"), + throw css::uno::RuntimeException( + "SfxDocumentMetaData::checkInit: not initialized", *const_cast<SfxDocumentMetaData*>(this)); } assert(m_xDoc.is() && m_xParent.is()); @@ -1054,8 +1054,8 @@ SfxDocumentMetaData::checkInit() const // throw (css::uno::RuntimeException) void SAL_CALL SfxDocumentMetaData::init( const css::uno::Reference<css::xml::dom::XDocument>& i_xDoc) { - if (!i_xDoc.is()) throw css::uno::RuntimeException( - OUString("SfxDocumentMetaData::init: no DOM tree given"), *this); + if (!i_xDoc.is()) + throw css::uno::RuntimeException("SfxDocumentMetaData::init: no DOM tree given", *this); css::uno::Reference<css::xml::xpath::XXPathAPI> xPath = css::xml::xpath::XPathAPI::create(m_xContext); @@ -1123,7 +1123,7 @@ void SAL_CALL SfxDocumentMetaData::init( } catch (const css::xml::dom::DOMException & e) { css::uno::Any a(e); throw css::lang::WrappedTargetRuntimeException( - OUString("SfxDocumentMetaData::init: DOM exception"), + "SfxDocumentMetaData::init: DOM exception", css::uno::Reference<css::uno::XInterface>(*this), a); } } @@ -1564,9 +1564,10 @@ SfxDocumentMetaData::getAutoloadSecs() void SAL_CALL SfxDocumentMetaData::setAutoloadSecs(::sal_Int32 the_value) { - if (the_value < 0) throw css::lang::IllegalArgumentException( - OUString("SfxDocumentMetaData::setAutoloadSecs: argument is negative"), - *this, 0); + if (the_value < 0) + throw css::lang::IllegalArgumentException( + "SfxDocumentMetaData::setAutoloadSecs: argument is negative", + *this, 0); ::osl::ClearableMutexGuard g(m_aMutex); checkInit(); if (m_AutoloadSecs != the_value) { @@ -1670,9 +1671,10 @@ SfxDocumentMetaData::getEditingCycles() void SAL_CALL SfxDocumentMetaData::setEditingCycles(::sal_Int16 the_value) { - if (the_value < 0) throw css::lang::IllegalArgumentException( - OUString("SfxDocumentMetaData::setEditingCycles: argument is negative"), - *this, 0); + if (the_value < 0) + throw css::lang::IllegalArgumentException( + "SfxDocumentMetaData::setEditingCycles: argument is negative", + *this, 0); OUStringBuffer buf; ::sax::Converter::convertNumber(buf, the_value); setMetaTextAndNotify("meta:editing-cycles", buf.makeStringAndClear()); @@ -1688,9 +1690,10 @@ SfxDocumentMetaData::getEditingDuration() void SAL_CALL SfxDocumentMetaData::setEditingDuration(::sal_Int32 the_value) { - if (the_value < 0) throw css::lang::IllegalArgumentException( - OUString("SfxDocumentMetaData::setEditingDuration: argument is negative"), - *this, 0); + if (the_value < 0) + throw css::lang::IllegalArgumentException( + "SfxDocumentMetaData::setEditingDuration: argument is negative", + *this, 0); setMetaTextAndNotify("meta:editing-duration", durationToText(the_value)); } @@ -1735,8 +1738,8 @@ SfxDocumentMetaData::loadFromStorage( const css::uno::Reference< css::embed::XStorage > & xStorage, const css::uno::Sequence< css::beans::PropertyValue > & Medium) { - if (!xStorage.is()) throw css::lang::IllegalArgumentException( - OUString("SfxDocumentMetaData::loadFromStorage: argument is null"), *this, 0); + if (!xStorage.is()) + throw css::lang::IllegalArgumentException("SfxDocumentMetaData::loadFromStorage: argument is null", *this, 0); ::osl::MutexGuard g(m_aMutex); // open meta data file @@ -1780,9 +1783,10 @@ SfxDocumentMetaData::loadFromStorage( xMsf->createInstanceWithArgumentsAndContext( OUString::createFromAscii(pServiceName), args, m_xContext), css::uno::UNO_QUERY_THROW); - if (!xDocHandler.is()) throw css::uno::RuntimeException( - OUString("SfxDocumentMetaData::loadFromStorage:" - " cannot create XMLOasisMetaImporter service"), *this); + if (!xDocHandler.is()) + throw css::uno::RuntimeException( + "SfxDocumentMetaData::loadFromStorage:" + " cannot create XMLOasisMetaImporter service", *this); css::uno::Reference<css::document::XImporter> xImp (xDocHandler, css::uno::UNO_QUERY_THROW); xImp->setTargetDocument(css::uno::Reference<css::lang::XComponent>(this)); @@ -1790,9 +1794,9 @@ SfxDocumentMetaData::loadFromStorage( try { xParser->parseStream(input); } catch (const css::xml::sax::SAXException &) { - throw css::io::WrongFormatException(OUString( + throw css::io::WrongFormatException( "SfxDocumentMetaData::loadFromStorage:" - " XML parsing exception"), *this); + " XML parsing exception", *this); } // NB: the implementation of XMLOasisMetaImporter calls initialize checkInit(); @@ -1803,9 +1807,9 @@ SfxDocumentMetaData::storeToStorage( const css::uno::Reference< css::embed::XStorage > & xStorage, const css::uno::Sequence< css::beans::PropertyValue > & Medium) { - if (!xStorage.is()) throw css::lang::IllegalArgumentException( - OUString("SfxDocumentMetaData::storeToStorage:" - " argument is null"), *this, 0); + if (!xStorage.is()) + throw css::lang::IllegalArgumentException( + "SfxDocumentMetaData::storeToStorage: argument is null", *this, 0); ::osl::MutexGuard g(m_aMutex); checkInit(); @@ -1866,8 +1870,8 @@ SfxDocumentMetaData::storeToStorage( xTransaction->commit(); } } else { - throw css::io::IOException(OUString( - "SfxDocumentMetaData::storeToStorage: cannot filter"), *this); + throw css::io::IOException( + "SfxDocumentMetaData::storeToStorage: cannot filter", *this); } } @@ -1900,13 +1904,13 @@ SfxDocumentMetaData::loadFromMedium(const OUString & URL, throw; } catch (const css::uno::Exception & e) { throw css::lang::WrappedTargetException( - OUString("SfxDocumentMetaData::loadFromMedium: exception"), + "SfxDocumentMetaData::loadFromMedium: exception", css::uno::Reference<css::uno::XInterface>(*this), css::uno::makeAny(e)); } if (!xStorage.is()) { - throw css::uno::RuntimeException(OUString( - "SfxDocumentMetaData::loadFromMedium: cannot get Storage"), + throw css::uno::RuntimeException( + "SfxDocumentMetaData::loadFromMedium: cannot get Storage", *this); } loadFromStorage(xStorage, md.getAsConstPropertyValueList()); @@ -1926,8 +1930,8 @@ SfxDocumentMetaData::storeToMedium(const OUString & URL, if (!xStorage.is()) { - throw css::uno::RuntimeException(OUString( - "SfxDocumentMetaData::storeToMedium: cannot get Storage"), + throw css::uno::RuntimeException( + "SfxDocumentMetaData::storeToMedium: cannot get Storage", *this); } // set MIME type of the storage @@ -1975,14 +1979,12 @@ void SAL_CALL SfxDocumentMetaData::initialize( const css::uno::Sequence< css::un if (any >>= xDoc) { if (!xDoc.is()) { throw css::lang::IllegalArgumentException( - OUString("SfxDocumentMetaData::" - "initialize: argument is null"), + "SfxDocumentMetaData::initialize: argument is null", *this, static_cast<sal_Int16>(i)); } } else { throw css::lang::IllegalArgumentException( - OUString("SfxDocumentMetaData::" - "initialize: argument must be XDocument"), + "SfxDocumentMetaData::initialize: argument must be XDocument", *this, static_cast<sal_Int16>(i)); } } @@ -2020,7 +2022,7 @@ SfxDocumentMetaData::createClone() } catch (const css::uno::Exception & e) { css::uno::Any a(e); throw css::lang::WrappedTargetRuntimeException( - OUString("SfxDocumentMetaData::createClone: exception"), + "SfxDocumentMetaData::createClone: exception", css::uno::Reference<css::uno::XInterface>(*this), a); } return css::uno::Reference<css::util::XCloneable> (pNew); diff --git a/sfx2/source/notify/globalevents.cxx b/sfx2/source/notify/globalevents.cxx index b4db95ec412a..1402d07b6331 100644 --- a/sfx2/source/notify/globalevents.cxx +++ b/sfx2/source/notify/globalevents.cxx @@ -250,7 +250,7 @@ void SAL_CALL SfxGlobalEvents_Impl::insert( const uno::Any& aElement ) aElement >>= xDoc; if (!xDoc.is()) throw lang::IllegalArgumentException( - OUString("Can not locate at least the model parameter."), + "Can not locate at least the model parameter.", static_cast< container::XSet* >(this), 0); @@ -284,7 +284,7 @@ void SAL_CALL SfxGlobalEvents_Impl::remove( const uno::Any& aElement ) aElement >>= xDoc; if (!xDoc.is()) throw lang::IllegalArgumentException( - OUString("Can not locate at least the model parameter."), + "Can not locate at least the model parameter.", static_cast< container::XSet* >(this), 0); |