From ba8a70365ef459c967cd8a71a6d48ca53dd341bd Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Tue, 20 Feb 2018 16:03:20 +0100 Subject: New loplugin:nestedunnamed Change-Id: Ifb434589ef08428ce609bc7a40b015d4df13224c Reviewed-on: https://gerrit.libreoffice.org/50048 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- compilerplugins/clang/nestedunnamed.cxx | 75 +++ dbaccess/source/ui/querydesign/QueryDesignView.cxx | 15 +- .../deployment/registry/component/dp_component.cxx | 5 - editeng/qa/unit/core-test.cxx | 24 +- framework/source/services/autorecovery.cxx | 37 +- framework/source/services/urltransformer.cxx | 79 ++- sal/cppunittester/cppunittester.cxx | 4 - sax/source/expatwrap/sax_expat.cxx | 35 +- sdext/source/pdfimport/wrapper/wrapper.cxx | 79 ++- sfx2/source/view/frmload.cxx | 29 +- shell/source/backends/desktopbe/desktopbackend.cxx | 4 - .../source/engine/opengl/TransitionerImpl.cxx | 591 ++++++++++----------- slideshow/source/engine/slide/slideimpl.cxx | 45 +- .../UriSchemeParser_vndDOTsunDOTstarDOTscript.cxx | 4 - svl/qa/unit/svl.cxx | 2 - svtools/source/uno/wizard/unowizard.cxx | 91 ++-- svx/source/tbxctrls/tbunosearchcontrollers.cxx | 11 +- sw/source/core/unocore/unoportenum.cxx | 3 - toolkit/source/awt/vclxtoolkit.cxx | 62 +-- toolkit/source/controls/animatedimages.cxx | 17 +- .../source/controls/grid/sortablegriddatamodel.cxx | 116 ++-- vcl/source/gdi/dibtools.cxx | 40 +- 22 files changed, 667 insertions(+), 701 deletions(-) create mode 100644 compilerplugins/clang/nestedunnamed.cxx diff --git a/compilerplugins/clang/nestedunnamed.cxx b/compilerplugins/clang/nestedunnamed.cxx new file mode 100644 index 000000000000..c26f5aac8efd --- /dev/null +++ b/compilerplugins/clang/nestedunnamed.cxx @@ -0,0 +1,75 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include + +#include "plugin.hxx" + +// Warn about unnamed namespaces nested (directly) within unnamed namespaces. (It can be hard to +// keep track whether a certain spot in a source file is already in an unnamed namespace, so it +// happens that additions to the source add redundant, nested unnamed namespaces.) + +namespace +{ +class NestedUnnamed : public RecursiveASTVisitor, public loplugin::Plugin +{ +public: + explicit NestedUnnamed(loplugin::InstantiationData const& data) + : Plugin(data) + { + } + + void run() override + { + if (compiler.getLangOpts().CPlusPlus) + { + TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); + } + } + + bool VisitNamespaceDecl(NamespaceDecl const* decl) + { + if (ignoreLocation(decl)) + { + return true; + } + if (!decl->isAnonymousNamespace()) + { + return true; + } + NamespaceDecl const* outer; + for (auto p = decl->getLexicalParent();; p = p->getLexicalParent()) + { + outer = dyn_cast(p); + if (outer != nullptr) + { + break; + } + if (isa(p)) + { + return true; + } + } + if (!outer->isAnonymousNamespace()) + { + return true; + } + report(DiagnosticsEngine::Warning, "unnamed namespace directly nested in unnamed namespace", + decl->getLocation()) + << decl->getSourceRange(); + report(DiagnosticsEngine::Note, "outer namespace declared here", outer->getLocation()) + << outer->getSourceRange(); + return true; + } +}; + +loplugin::Plugin::Registration X("nestedunnamed"); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx index 8a0f82fd05d3..ee67a9a69fe2 100644 --- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx +++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx @@ -1685,18 +1685,15 @@ namespace return eErrorCode; } - namespace + OQueryTableWindow* lcl_findColumnInTables( const OUString& _rColumName, const OJoinTableView::OTableWindowMap& _rTabList, OTableFieldDescRef const & _rInfo ) { - OQueryTableWindow* lcl_findColumnInTables( const OUString& _rColumName, const OJoinTableView::OTableWindowMap& _rTabList, OTableFieldDescRef const & _rInfo ) + for (auto const& table : _rTabList) { - for (auto const& table : _rTabList) - { - OQueryTableWindow* pTabWin = static_cast< OQueryTableWindow* >( table.second.get() ); - if ( pTabWin && pTabWin->ExistsField( _rColumName, _rInfo ) ) - return pTabWin; - } - return nullptr; + OQueryTableWindow* pTabWin = static_cast< OQueryTableWindow* >( table.second.get() ); + if ( pTabWin && pTabWin->ExistsField( _rColumName, _rInfo ) ) + return pTabWin; } + return nullptr; } void InsertColumnRef(const OQueryDesignView* _pView, diff --git a/desktop/source/deployment/registry/component/dp_component.cxx b/desktop/source/deployment/registry/component/dp_component.cxx index a2225aff4ce8..47c9fa9fe4f3 100644 --- a/desktop/source/deployment/registry/component/dp_component.cxx +++ b/desktop/source/deployment/registry/component/dp_component.cxx @@ -1099,9 +1099,6 @@ Reference raise_uno_process( } } - -namespace { - void extractComponentData( css::uno::Reference< css::uno::XComponentContext > const & context, css::uno::Reference< css::registry::XRegistryKey > const & registry, @@ -1146,8 +1143,6 @@ void extractComponentData( } } -} - void BackendImpl::ComponentPackageImpl::getComponentInfo( ComponentBackendDb::Data * data, std::vector< css::uno::Reference< css::uno::XInterface > > * factories, diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx index e0f03a8d75d8..44d3e7a7a82d 100644 --- a/editeng/qa/unit/core-test.cxx +++ b/editeng/qa/unit/core-test.cxx @@ -238,8 +238,6 @@ void Test::testConstruction() aEngine.SetText(aParaText); } -namespace { - bool includes(const uno::Sequence& rSeq, const OUString& rVal) { for (sal_Int32 i = 0, n = rSeq.getLength(); i < n; ++i) @@ -249,8 +247,6 @@ bool includes(const uno::Sequence& rSeq, const OUString& rVal) return false; } -} - void Test::testUnoTextFields() { { @@ -814,18 +810,16 @@ void Test::testTabsCopyPaste() CPPUNIT_ASSERT_EQUAL( OUString("sample\ttextfortestingtab\t\ttextfortestingtab\t"), rDoc.GetParaAsString(sal_Int32(0)) ); } -namespace { - class UrlEditEngine : public EditEngine - { - public: - explicit UrlEditEngine(SfxItemPool *pPool) : EditEngine(pPool) {} +class UrlEditEngine : public EditEngine +{ +public: + explicit UrlEditEngine(SfxItemPool *pPool) : EditEngine(pPool) {} - virtual OUString CalcFieldValue( const SvxFieldItem&, sal_Int32, sal_Int32, Color*&, Color*& ) override - { - return OUString("jim@bob.com"); // a sophisticated view of value: - } - }; -} + virtual OUString CalcFieldValue( const SvxFieldItem&, sal_Int32, sal_Int32, Color*&, Color*& ) override + { + return OUString("jim@bob.com"); // a sophisticated view of value: + } +}; // Odd accounting for hyperlink position & size etc. // https://bugzilla.novell.com/show_bug.cgi?id=467459 diff --git a/framework/source/services/autorecovery.cxx b/framework/source/services/autorecovery.cxx index 861cfcffe1d7..f85756fe9016 100644 --- a/framework/source/services/autorecovery.cxx +++ b/framework/source/services/autorecovery.cxx @@ -2683,29 +2683,26 @@ AutoRecovery::TDocumentList::iterator AutoRecovery::impl_searchDocument( Au return pIt; } -namespace +void lcl_changeVisibility( const css::uno::Reference< css::frame::XFramesSupplier >& i_rFrames, bool i_bVisible ) { - void lcl_changeVisibility( const css::uno::Reference< css::frame::XFramesSupplier >& i_rFrames, bool i_bVisible ) - { - css::uno::Reference< css::container::XIndexAccess > xFramesContainer( i_rFrames->getFrames(), css::uno::UNO_QUERY ); - const sal_Int32 count = xFramesContainer->getCount(); + css::uno::Reference< css::container::XIndexAccess > xFramesContainer( i_rFrames->getFrames(), css::uno::UNO_QUERY ); + const sal_Int32 count = xFramesContainer->getCount(); - Any aElement; - for ( sal_Int32 i=0; i < count; ++i ) - { - aElement = xFramesContainer->getByIndex(i); - // check for sub frames - css::uno::Reference< css::frame::XFramesSupplier > xFramesSupp( aElement, css::uno::UNO_QUERY ); - if ( xFramesSupp.is() ) - lcl_changeVisibility( xFramesSupp, i_bVisible ); - - css::uno::Reference< css::frame::XFrame > xFrame( aElement, css::uno::UNO_QUERY ); - if ( !xFrame.is() ) - continue; + Any aElement; + for ( sal_Int32 i=0; i < count; ++i ) + { + aElement = xFramesContainer->getByIndex(i); + // check for sub frames + css::uno::Reference< css::frame::XFramesSupplier > xFramesSupp( aElement, css::uno::UNO_QUERY ); + if ( xFramesSupp.is() ) + lcl_changeVisibility( xFramesSupp, i_bVisible ); + + css::uno::Reference< css::frame::XFrame > xFrame( aElement, css::uno::UNO_QUERY ); + if ( !xFrame.is() ) + continue; - css::uno::Reference< css::awt::XWindow > xWindow( xFrame->getContainerWindow(), UNO_SET_THROW ); - xWindow->setVisible( i_bVisible ); - } + css::uno::Reference< css::awt::XWindow > xWindow( xFrame->getContainerWindow(), UNO_SET_THROW ); + xWindow->setVisible( i_bVisible ); } } diff --git a/framework/source/services/urltransformer.cxx b/framework/source/services/urltransformer.cxx index dec58037d19f..b9508629ed5d 100644 --- a/framework/source/services/urltransformer.cxx +++ b/framework/source/services/urltransformer.cxx @@ -61,56 +61,53 @@ public: virtual OUString SAL_CALL getPresentation( const css::util::URL& aURL, sal_Bool bWithPassword ) override; }; -namespace +void lcl_ParserHelper(INetURLObject& _rParser, css::util::URL& _rURL,bool _bUseIntern) { - void lcl_ParserHelper(INetURLObject& _rParser, css::util::URL& _rURL,bool _bUseIntern) + // Get all information about this URL. + _rURL.Protocol = INetURLObject::GetScheme( _rParser.GetProtocol() ); + _rURL.User = _rParser.GetUser ( INetURLObject::DecodeMechanism::WithCharset ); + _rURL.Password = _rParser.GetPass ( INetURLObject::DecodeMechanism::WithCharset ); + _rURL.Server = _rParser.GetHost ( INetURLObject::DecodeMechanism::WithCharset ); + _rURL.Port = static_cast(_rParser.GetPort()); + + sal_Int32 nCount = _rParser.getSegmentCount( false ); + if ( nCount > 0 ) { - // Get all information about this URL. - _rURL.Protocol = INetURLObject::GetScheme( _rParser.GetProtocol() ); - _rURL.User = _rParser.GetUser ( INetURLObject::DecodeMechanism::WithCharset ); - _rURL.Password = _rParser.GetPass ( INetURLObject::DecodeMechanism::WithCharset ); - _rURL.Server = _rParser.GetHost ( INetURLObject::DecodeMechanism::WithCharset ); - _rURL.Port = static_cast(_rParser.GetPort()); - - sal_Int32 nCount = _rParser.getSegmentCount( false ); - if ( nCount > 0 ) - { - // Don't add last segment as it is the name! - --nCount; - - OUStringBuffer aPath; - for ( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ ) - { - aPath.append( '/'); - aPath.append( _rParser.getName( nIndex, false, INetURLObject::DecodeMechanism::NONE )); - } - - if ( nCount > 0 ) - aPath.append( '/' ); // final slash! + // Don't add last segment as it is the name! + --nCount; - _rURL.Path = aPath.makeStringAndClear(); - _rURL.Name = _rParser.getName( INetURLObject::LAST_SEGMENT, false, INetURLObject::DecodeMechanism::NONE ); - } - else + OUStringBuffer aPath; + for ( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ ) { - _rURL.Path = _rParser.GetURLPath( INetURLObject::DecodeMechanism::NONE ); - _rURL.Name = _rParser.GetName ( ); + aPath.append( '/'); + aPath.append( _rParser.getName( nIndex, false, INetURLObject::DecodeMechanism::NONE )); } - _rURL.Arguments = _rParser.GetParam(); - _rURL.Mark = _rParser.GetMark( INetURLObject::DecodeMechanism::WithCharset ); + if ( nCount > 0 ) + aPath.append( '/' ); // final slash! + + _rURL.Path = aPath.makeStringAndClear(); + _rURL.Name = _rParser.getName( INetURLObject::LAST_SEGMENT, false, INetURLObject::DecodeMechanism::NONE ); + } + else + { + _rURL.Path = _rParser.GetURLPath( INetURLObject::DecodeMechanism::NONE ); + _rURL.Name = _rParser.GetName ( ); + } - // INetURLObject supports only an intelligent method of parsing URL's. So write - // back Complete to have a valid encoded URL in all cases! - _rURL.Complete = _rParser.GetMainURL( INetURLObject::DecodeMechanism::NONE ); - if ( _bUseIntern ) - _rURL.Complete = _rURL.Complete.intern(); + _rURL.Arguments = _rParser.GetParam(); + _rURL.Mark = _rParser.GetMark( INetURLObject::DecodeMechanism::WithCharset ); - _rParser.SetMark ( OUString() ); - _rParser.SetParam( OUString() ); + // INetURLObject supports only an intelligent method of parsing URL's. So write + // back Complete to have a valid encoded URL in all cases! + _rURL.Complete = _rParser.GetMainURL( INetURLObject::DecodeMechanism::NONE ); + if ( _bUseIntern ) + _rURL.Complete = _rURL.Complete.intern(); - _rURL.Main = _rParser.GetMainURL( INetURLObject::DecodeMechanism::NONE ); - } + _rParser.SetMark ( OUString() ); + _rParser.SetParam( OUString() ); + + _rURL.Main = _rParser.GetMainURL( INetURLObject::DecodeMechanism::NONE ); } // XURLTransformer diff --git a/sal/cppunittester/cppunittester.cxx b/sal/cppunittester/cppunittester.cxx index ed46fdd3adc1..2cca296f0c53 100644 --- a/sal/cppunittester/cppunittester.cxx +++ b/sal/cppunittester/cppunittester.cxx @@ -178,8 +178,6 @@ private: } }; -namespace { - struct test_name_compare { explicit test_name_compare(const std::string& rName): @@ -216,8 +214,6 @@ bool addRecursiveTests(const std::vector& test_names, CppUnit::Test return ret; } -} - //Allow the whole uniting testing framework to be run inside a "Protector" //which knows about uno exceptions, so it can print the content of the //exception before falling over and dying diff --git a/sax/source/expatwrap/sax_expat.cxx b/sax/source/expatwrap/sax_expat.cxx index 0dd3afdf7ebb..49f9471b7b03 100644 --- a/sax/source/expatwrap/sax_expat.cxx +++ b/sax/source/expatwrap/sax_expat.cxx @@ -384,27 +384,24 @@ SaxExpatParser::initialize(css::uno::Sequence< css::uno::Any > const& rArguments } } -namespace +class ParserCleanup { - class ParserCleanup +private: + SaxExpatParser_Impl& m_rParser; + Entity& m_rEntity; +public: + ParserCleanup(SaxExpatParser_Impl& rParser, Entity& rEntity) + : m_rParser(rParser) + , m_rEntity(rEntity) { - private: - SaxExpatParser_Impl& m_rParser; - Entity& m_rEntity; - public: - ParserCleanup(SaxExpatParser_Impl& rParser, Entity& rEntity) - : m_rParser(rParser) - , m_rEntity(rEntity) - { - } - ~ParserCleanup() - { - m_rParser.popEntity(); - //XML_ParserFree accepts a null arg - XML_ParserFree(m_rEntity.pParser); - } - }; -} + } + ~ParserCleanup() + { + m_rParser.popEntity(); + //XML_ParserFree accepts a null arg + XML_ParserFree(m_rEntity.pParser); + } +}; /*************** * diff --git a/sdext/source/pdfimport/wrapper/wrapper.cxx b/sdext/source/pdfimport/wrapper/wrapper.cxx index d9cce4a677fc..d79ffc3c99fb 100644 --- a/sdext/source/pdfimport/wrapper/wrapper.cxx +++ b/sdext/source/pdfimport/wrapper/wrapper.cxx @@ -203,59 +203,52 @@ public: void parseLine( const OString& rLine ); }; - -namespace +/** Unescapes line-ending characters in input string. These + characters are encoded as pairs of characters: '\\' 'n', resp. + '\\' 'r'. This function converts them back to '\n', resp. '\r'. + */ +OString lcl_unescapeLineFeeds(const OString& i_rStr) { - - /** Unescapes line-ending characters in input string. These - characters are encoded as pairs of characters: '\\' 'n', resp. - '\\' 'r'. This function converts them back to '\n', resp. '\r'. - */ - OString lcl_unescapeLineFeeds(const OString& i_rStr) + const size_t nOrigLen(sal::static_int_cast(i_rStr.getLength())); + const sal_Char* const pOrig(i_rStr.getStr()); + std::unique_ptr pBuffer(new sal_Char[nOrigLen + 1]); + + const sal_Char* pRead(pOrig); + sal_Char* pWrite(pBuffer.get()); + const sal_Char* pCur(pOrig); + while ((pCur = strchr(pCur, '\\')) != nullptr) { - const size_t nOrigLen(sal::static_int_cast(i_rStr.getLength())); - const sal_Char* const pOrig(i_rStr.getStr()); - std::unique_ptr pBuffer(new sal_Char[nOrigLen + 1]); - - const sal_Char* pRead(pOrig); - sal_Char* pWrite(pBuffer.get()); - const sal_Char* pCur(pOrig); - while ((pCur = strchr(pCur, '\\')) != nullptr) + const sal_Char cNext(pCur[1]); + if (cNext == 'n' || cNext == 'r' || cNext == '\\') { - const sal_Char cNext(pCur[1]); - if (cNext == 'n' || cNext == 'r' || cNext == '\\') - { - const size_t nLen(pCur - pRead); - strncpy(pWrite, pRead, nLen); - pWrite += nLen; - *pWrite = cNext == 'n' ? '\n' : (cNext == 'r' ? '\r' : '\\'); - ++pWrite; - pCur = pRead = pCur + 2; - } - else - { - // Just continue on the next character. The current - // block will be copied the next time it goes through the - // 'if' branch. - ++pCur; - } - } - // maybe there are some data to copy yet - if (sal::static_int_cast(pRead - pOrig) < nOrigLen) - { - const size_t nLen(nOrigLen - (pRead - pOrig)); + const size_t nLen(pCur - pRead); strncpy(pWrite, pRead, nLen); pWrite += nLen; + *pWrite = cNext == 'n' ? '\n' : (cNext == 'r' ? '\r' : '\\'); + ++pWrite; + pCur = pRead = pCur + 2; } - *pWrite = '\0'; - - OString aResult(pBuffer.get()); - return aResult; + else + { + // Just continue on the next character. The current + // block will be copied the next time it goes through the + // 'if' branch. + ++pCur; + } + } + // maybe there are some data to copy yet + if (sal::static_int_cast(pRead - pOrig) < nOrigLen) + { + const size_t nLen(nOrigLen - (pRead - pOrig)); + strncpy(pWrite, pRead, nLen); + pWrite += nLen; } + *pWrite = '\0'; + OString aResult(pBuffer.get()); + return aResult; } - OString Parser::readNextToken() { OSL_PRECOND(m_nCharIndex!=-1,"insufficient input"); diff --git a/sfx2/source/view/frmload.cxx b/sfx2/source/view/frmload.cxx index 153ff8e16a10..7849fd1463c7 100644 --- a/sfx2/source/view/frmload.cxx +++ b/sfx2/source/view/frmload.cxx @@ -305,29 +305,24 @@ OUString SfxFrameLoader_Impl::impl_askForFilter_nothrow( const Reference< XInter return sFilterName; } - -namespace +bool lcl_getDispatchResult( const SfxPoolItem* _pResult ) { - bool lcl_getDispatchResult( const SfxPoolItem* _pResult ) - { - if ( !_pResult ) - return false; + if ( !_pResult ) + return false; - // default must be set to true, because some return values - // can't be checked, but nonetheless indicate "success"! - bool bSuccess = true; + // default must be set to true, because some return values + // can't be checked, but nonetheless indicate "success"! + bool bSuccess = true; - // On the other side some special slots return a boolean state, - // which can be set to FALSE. - const SfxBoolItem *pItem = dynamic_cast( _pResult ); - if ( pItem ) - bSuccess = pItem->GetValue(); + // On the other side some special slots return a boolean state, + // which can be set to FALSE. + const SfxBoolItem *pItem = dynamic_cast( _pResult ); + if ( pItem ) + bSuccess = pItem->GetValue(); - return bSuccess; - } + return bSuccess; } - bool SfxFrameLoader_Impl::impl_createNewDocWithSlotParam( const sal_uInt16 _nSlotID, const Reference< XFrame >& i_rxFrame, const bool i_bHidden ) { diff --git a/shell/source/backends/desktopbe/desktopbackend.cxx b/shell/source/backends/desktopbe/desktopbackend.cxx index 275c9e459c90..7fa007689095 100644 --- a/shell/source/backends/desktopbe/desktopbackend.cxx +++ b/shell/source/backends/desktopbe/desktopbackend.cxx @@ -124,8 +124,6 @@ void Default::setPropertyValue(OUString const &, css::uno::Any const &) static_cast< cppu::OWeakObject * >(this), -1); } -namespace { - OUString xdg_user_dir_lookup (const char *type) { char *config_home; @@ -233,8 +231,6 @@ css::uno::Any xdgDirectoryIfExists(char const * type) { : css::beans::Optional(false, css::uno::Any())); } -} // namespace - css::uno::Any Default::getPropertyValue(OUString const & PropertyName) { if (PropertyName == "TemplatePathVariable") diff --git a/slideshow/source/engine/opengl/TransitionerImpl.cxx b/slideshow/source/engine/opengl/TransitionerImpl.cxx index 299dff9862ab..b0ceabef524b 100644 --- a/slideshow/source/engine/opengl/TransitionerImpl.cxx +++ b/slideshow/source/engine/opengl/TransitionerImpl.cxx @@ -464,358 +464,353 @@ void OGLTransitionerImpl::createTexture( GLuint* texID, CHECK_GL_ERROR(); } -namespace +class OGLColorSpace : public cppu::WeakImplHelper< css::rendering::XIntegerBitmapColorSpace > { - class OGLColorSpace : public cppu::WeakImplHelper< css::rendering::XIntegerBitmapColorSpace > - { - private: - uno::Sequence< sal_Int8 > maComponentTags; - uno::Sequence< sal_Int32 > maBitCounts; +private: + uno::Sequence< sal_Int8 > maComponentTags; + uno::Sequence< sal_Int32 > maBitCounts; - virtual sal_Int8 SAL_CALL getType( ) override + virtual sal_Int8 SAL_CALL getType( ) override + { + return rendering::ColorSpaceType::RGB; + } + virtual uno::Sequence< sal_Int8 > SAL_CALL getComponentTags( ) override + { + return maComponentTags; + } + virtual sal_Int8 SAL_CALL getRenderingIntent( ) override + { + return rendering::RenderingIntent::PERCEPTUAL; + } + virtual uno::Sequence< beans::PropertyValue > SAL_CALL getProperties( ) override + { + return uno::Sequence< beans::PropertyValue >(); + } + virtual uno::Sequence< double > SAL_CALL convertColorSpace( const uno::Sequence< double >& deviceColor, + const uno::Reference< rendering::XColorSpace >& targetColorSpace ) override + { + // TODO(P3): if we know anything about target + // colorspace, this can be greatly sped up + uno::Sequence aIntermediate( + convertToARGB(deviceColor)); + return targetColorSpace->convertFromARGB(aIntermediate); + } + virtual uno::Sequence< rendering::RGBColor > SAL_CALL convertToRGB( const uno::Sequence< double >& deviceColor ) override + { + const double* pIn( deviceColor.getConstArray() ); + const std::size_t nLen( deviceColor.getLength() ); + ENSURE_ARG_OR_THROW2(nLen%4==0, + "number of channels no multiple of 4", + static_cast(this), 0); + + uno::Sequence< rendering::RGBColor > aRes(nLen/4); + rendering::RGBColor* pOut( aRes.getArray() ); + for( std::size_t i=0; i SAL_CALL getComponentTags( ) override + return aRes; + } + virtual uno::Sequence< rendering::ARGBColor > SAL_CALL convertToARGB( const uno::Sequence< double >& deviceColor ) override + { + const double* pIn( deviceColor.getConstArray() ); + const std::size_t nLen( deviceColor.getLength() ); + ENSURE_ARG_OR_THROW2(nLen%4==0, + "number of channels no multiple of 4", + static_cast(this), 0); + + uno::Sequence< rendering::ARGBColor > aRes(nLen/4); + rendering::ARGBColor* pOut( aRes.getArray() ); + for( std::size_t i=0; i SAL_CALL convertToPARGB( const uno::Sequence< double >& deviceColor ) override + { + const double* pIn( deviceColor.getConstArray() ); + const std::size_t nLen( deviceColor.getLength() ); + ENSURE_ARG_OR_THROW2(nLen%4==0, + "number of channels no multiple of 4", + static_cast(this), 0); + + uno::Sequence< rendering::ARGBColor > aRes(nLen/4); + rendering::ARGBColor* pOut( aRes.getArray() ); + for( std::size_t i=0; i SAL_CALL getProperties( ) override + return aRes; + } + virtual uno::Sequence< double > SAL_CALL convertFromRGB( const uno::Sequence< rendering::RGBColor >& rgbColor ) override + { + const rendering::RGBColor* pIn( rgbColor.getConstArray() ); + const std::size_t nLen( rgbColor.getLength() ); + + uno::Sequence< double > aRes(nLen*4); + double* pColors=aRes.getArray(); + for( std::size_t i=0; i(); + *pColors++ = pIn->Red; + *pColors++ = pIn->Green; + *pColors++ = pIn->Blue; + *pColors++ = 1.0; + ++pIn; } - virtual uno::Sequence< double > SAL_CALL convertColorSpace( const uno::Sequence< double >& deviceColor, - const uno::Reference< rendering::XColorSpace >& targetColorSpace ) override + return aRes; + } + virtual uno::Sequence< double > SAL_CALL convertFromARGB( const uno::Sequence< rendering::ARGBColor >& rgbColor ) override + { + const rendering::ARGBColor* pIn( rgbColor.getConstArray() ); + const std::size_t nLen( rgbColor.getLength() ); + + uno::Sequence< double > aRes(nLen*4); + double* pColors=aRes.getArray(); + for( std::size_t i=0; i aIntermediate( - convertToARGB(deviceColor)); - return targetColorSpace->convertFromARGB(aIntermediate); + *pColors++ = pIn->Red; + *pColors++ = pIn->Green; + *pColors++ = pIn->Blue; + *pColors++ = pIn->Alpha; + ++pIn; } - virtual uno::Sequence< rendering::RGBColor > SAL_CALL convertToRGB( const uno::Sequence< double >& deviceColor ) override - { - const double* pIn( deviceColor.getConstArray() ); - const std::size_t nLen( deviceColor.getLength() ); - ENSURE_ARG_OR_THROW2(nLen%4==0, - "number of channels no multiple of 4", - static_cast(this), 0); + return aRes; + } + virtual uno::Sequence< double > SAL_CALL convertFromPARGB( const uno::Sequence< rendering::ARGBColor >& rgbColor ) override + { + const rendering::ARGBColor* pIn( rgbColor.getConstArray() ); + const std::size_t nLen( rgbColor.getLength() ); - uno::Sequence< rendering::RGBColor > aRes(nLen/4); - rendering::RGBColor* pOut( aRes.getArray() ); - for( std::size_t i=0; i SAL_CALL convertToARGB( const uno::Sequence< double >& deviceColor ) override + uno::Sequence< double > aRes(nLen*4); + double* pColors=aRes.getArray(); + for( std::size_t i=0; i(this), 0); - - uno::Sequence< rendering::ARGBColor > aRes(nLen/4); - rendering::ARGBColor* pOut( aRes.getArray() ); - for( std::size_t i=0; iRed/pIn->Alpha; + *pColors++ = pIn->Green/pIn->Alpha; + *pColors++ = pIn->Blue/pIn->Alpha; + *pColors++ = pIn->Alpha; + ++pIn; } - virtual uno::Sequence< rendering::ARGBColor > SAL_CALL convertToPARGB( const uno::Sequence< double >& deviceColor ) override + return aRes; + } + + // XIntegerBitmapColorSpace + virtual sal_Int32 SAL_CALL getBitsPerPixel( ) override + { + return 32; + } + virtual uno::Sequence< sal_Int32 > SAL_CALL getComponentBitCounts( ) override + { + return maBitCounts; + } + virtual sal_Int8 SAL_CALL getEndianness( ) override + { + return util::Endianness::LITTLE; + } + virtual uno::Sequence SAL_CALL convertFromIntegerColorSpace( const uno::Sequence< sal_Int8 >& deviceColor, + const uno::Reference< rendering::XColorSpace >& targetColorSpace ) override + { + if( dynamic_cast(targetColorSpace.get()) ) { - const double* pIn( deviceColor.getConstArray() ); - const std::size_t nLen( deviceColor.getLength() ); + const sal_Int8* pIn( deviceColor.getConstArray() ); + const std::size_t nLen( deviceColor.getLength() ); ENSURE_ARG_OR_THROW2(nLen%4==0, "number of channels no multiple of 4", static_cast(this), 0); - uno::Sequence< rendering::ARGBColor > aRes(nLen/4); - rendering::ARGBColor* pOut( aRes.getArray() ); + uno::Sequence aRes(nLen); + double* pOut( aRes.getArray() ); for( std::size_t i=0; i SAL_CALL convertFromRGB( const uno::Sequence< rendering::RGBColor >& rgbColor ) override + else { - const rendering::RGBColor* pIn( rgbColor.getConstArray() ); - const std::size_t nLen( rgbColor.getLength() ); - - uno::Sequence< double > aRes(nLen*4); - double* pColors=aRes.getArray(); - for( std::size_t i=0; iRed; - *pColors++ = pIn->Green; - *pColors++ = pIn->Blue; - *pColors++ = 1.0; - ++pIn; - } - return aRes; - } - virtual uno::Sequence< double > SAL_CALL convertFromARGB( const uno::Sequence< rendering::ARGBColor >& rgbColor ) override - { - const rendering::ARGBColor* pIn( rgbColor.getConstArray() ); - const std::size_t nLen( rgbColor.getLength() ); - - uno::Sequence< double > aRes(nLen*4); - double* pColors=aRes.getArray(); - for( std::size_t i=0; iRed; - *pColors++ = pIn->Green; - *pColors++ = pIn->Blue; - *pColors++ = pIn->Alpha; - ++pIn; - } - return aRes; - } - virtual uno::Sequence< double > SAL_CALL convertFromPARGB( const uno::Sequence< rendering::ARGBColor >& rgbColor ) override - { - const rendering::ARGBColor* pIn( rgbColor.getConstArray() ); - const std::size_t nLen( rgbColor.getLength() ); - - uno::Sequence< double > aRes(nLen*4); - double* pColors=aRes.getArray(); - for( std::size_t i=0; iRed/pIn->Alpha; - *pColors++ = pIn->Green/pIn->Alpha; - *pColors++ = pIn->Blue/pIn->Alpha; - *pColors++ = pIn->Alpha; - ++pIn; - } - return aRes; - } - - // XIntegerBitmapColorSpace - virtual sal_Int32 SAL_CALL getBitsPerPixel( ) override - { - return 32; - } - virtual uno::Sequence< sal_Int32 > SAL_CALL getComponentBitCounts( ) override - { - return maBitCounts; + // TODO(P3): if we know anything about target + // colorspace, this can be greatly sped up + uno::Sequence aIntermediate( + convertIntegerToARGB(deviceColor)); + return targetColorSpace->convertFromARGB(aIntermediate); } - virtual sal_Int8 SAL_CALL getEndianness( ) override + } + virtual uno::Sequence< sal_Int8 > SAL_CALL convertToIntegerColorSpace( const uno::Sequence< sal_Int8 >& deviceColor, + const uno::Reference< rendering::XIntegerBitmapColorSpace >& targetColorSpace ) override + { + if( dynamic_cast(targetColorSpace.get()) ) { - return util::Endianness::LITTLE; + // it's us, so simply pass-through the data + return deviceColor; } - virtual uno::Sequence SAL_CALL convertFromIntegerColorSpace( const uno::Sequence< sal_Int8 >& deviceColor, - const uno::Reference< rendering::XColorSpace >& targetColorSpace ) override + else { - if( dynamic_cast(targetColorSpace.get()) ) - { - const sal_Int8* pIn( deviceColor.getConstArray() ); - const std::size_t nLen( deviceColor.getLength() ); - ENSURE_ARG_OR_THROW2(nLen%4==0, - "number of channels no multiple of 4", - static_cast(this), 0); - - uno::Sequence aRes(nLen); - double* pOut( aRes.getArray() ); - for( std::size_t i=0; i aIntermediate( - convertIntegerToARGB(deviceColor)); - return targetColorSpace->convertFromARGB(aIntermediate); - } + // TODO(P3): if we know anything about target + // colorspace, this can be greatly sped up + uno::Sequence aIntermediate( + convertIntegerToARGB(deviceColor)); + return targetColorSpace->convertIntegerFromARGB(aIntermediate); } - virtual uno::Sequence< sal_Int8 > SAL_CALL convertToIntegerColorSpace( const uno::Sequence< sal_Int8 >& deviceColor, - const uno::Reference< rendering::XIntegerBitmapColorSpace >& targetColorSpace ) override + } + virtual uno::Sequence< rendering::RGBColor > SAL_CALL convertIntegerToRGB( const uno::Sequence< sal_Int8 >& deviceColor ) override + { + const sal_Int8* pIn( deviceColor.getConstArray() ); + const std::size_t nLen( deviceColor.getLength() ); + ENSURE_ARG_OR_THROW2(nLen%4==0, + "number of channels no multiple of 4", + static_cast(this), 0); + + uno::Sequence< rendering::RGBColor > aRes(nLen/4); + rendering::RGBColor* pOut( aRes.getArray() ); + for( std::size_t i=0; i(targetColorSpace.get()) ) - { - // it's us, so simply pass-through the data - return deviceColor; - } - else - { - // TODO(P3): if we know anything about target - // colorspace, this can be greatly sped up - uno::Sequence aIntermediate( - convertIntegerToARGB(deviceColor)); - return targetColorSpace->convertIntegerFromARGB(aIntermediate); - } - } - virtual uno::Sequence< rendering::RGBColor > SAL_CALL convertIntegerToRGB( const uno::Sequence< sal_Int8 >& deviceColor ) override - { - const sal_Int8* pIn( deviceColor.getConstArray() ); - const std::size_t nLen( deviceColor.getLength() ); - ENSURE_ARG_OR_THROW2(nLen%4==0, - "number of channels no multiple of 4", - static_cast(this), 0); - - uno::Sequence< rendering::RGBColor > aRes(nLen/4); - rendering::RGBColor* pOut( aRes.getArray() ); - for( std::size_t i=0; i SAL_CALL convertIntegerToARGB( const uno::Sequence< sal_Int8 >& deviceColor ) override + virtual uno::Sequence< rendering::ARGBColor > SAL_CALL convertIntegerToARGB( const uno::Sequence< sal_Int8 >& deviceColor ) override + { + const sal_Int8* pIn( deviceColor.getConstArray() ); + const std::size_t nLen( deviceColor.getLength() ); + ENSURE_ARG_OR_THROW2(nLen%4==0, + "number of channels no multiple of 4", + static_cast(this), 0); + + uno::Sequence< rendering::ARGBColor > aRes(nLen/4); + rendering::ARGBColor* pOut( aRes.getArray() ); + for( std::size_t i=0; i(this), 0); - - uno::Sequence< rendering::ARGBColor > aRes(nLen/4); - rendering::ARGBColor* pOut( aRes.getArray() ); - for( std::size_t i=0; i SAL_CALL convertIntegerToPARGB( const uno::Sequence< sal_Int8 >& deviceColor ) override + virtual uno::Sequence< rendering::ARGBColor > SAL_CALL convertIntegerToPARGB( const uno::Sequence< sal_Int8 >& deviceColor ) override + { + const sal_Int8* pIn( deviceColor.getConstArray() ); + const std::size_t nLen( deviceColor.getLength() ); + ENSURE_ARG_OR_THROW2(nLen%4==0, + "number of channels no multiple of 4", + static_cast(this), 0); + + uno::Sequence< rendering::ARGBColor > aRes(nLen/4); + rendering::ARGBColor* pOut( aRes.getArray() ); + for( std::size_t i=0; i(this), 0); - - uno::Sequence< rendering::ARGBColor > aRes(nLen/4); - rendering::ARGBColor* pOut( aRes.getArray() ); - for( std::size_t i=0; i SAL_CALL convertIntegerFromRGB( const uno::Sequence< rendering::RGBColor >& rgbColor ) override - { - const rendering::RGBColor* pIn( rgbColor.getConstArray() ); - const std::size_t nLen( rgbColor.getLength() ); - - uno::Sequence< sal_Int8 > aRes(nLen*4); - sal_Int8* pColors=aRes.getArray(); - for( std::size_t i=0; iRed); - *pColors++ = vcl::unotools::toByteColor(pIn->Green); - *pColors++ = vcl::unotools::toByteColor(pIn->Blue); - *pColors++ = -1; - ++pIn; - } - return aRes; - } + virtual uno::Sequence< sal_Int8 > SAL_CALL convertIntegerFromRGB( const uno::Sequence< rendering::RGBColor >& rgbColor ) override + { + const rendering::RGBColor* pIn( rgbColor.getConstArray() ); + const std::size_t nLen( rgbColor.getLength() ); - virtual uno::Sequence< sal_Int8 > SAL_CALL convertIntegerFromARGB( const uno::Sequence< rendering::ARGBColor >& rgbColor ) override + uno::Sequence< sal_Int8 > aRes(nLen*4); + sal_Int8* pColors=aRes.getArray(); + for( std::size_t i=0; i aRes(nLen*4); - sal_Int8* pColors=aRes.getArray(); - for( std::size_t i=0; iRed); - *pColors++ = vcl::unotools::toByteColor(pIn->Green); - *pColors++ = vcl::unotools::toByteColor(pIn->Blue); - *pColors++ = vcl::unotools::toByteColor(pIn->Alpha); - ++pIn; - } - return aRes; + *pColors++ = vcl::unotools::toByteColor(pIn->Red); + *pColors++ = vcl::unotools::toByteColor(pIn->Green); + *pColors++ = vcl::unotools::toByteColor(pIn->Blue); + *pColors++ = -1; + ++pIn; } + return aRes; + } - virtual uno::Sequence< sal_Int8 > SAL_CALL convertIntegerFromPARGB( const uno::Sequence< rendering::ARGBColor >& rgbColor ) override - { - const rendering::ARGBColor* pIn( rgbColor.getConstArray() ); - const std::size_t nLen( rgbColor.getLength() ); - - uno::Sequence< sal_Int8 > aRes(nLen*4); - sal_Int8* pColors=aRes.getArray(); - for( std::size_t i=0; iRed/pIn->Alpha); - *pColors++ = vcl::unotools::toByteColor(pIn->Green/pIn->Alpha); - *pColors++ = vcl::unotools::toByteColor(pIn->Blue/pIn->Alpha); - *pColors++ = vcl::unotools::toByteColor(pIn->Alpha); - ++pIn; - } - return aRes; - } + virtual uno::Sequence< sal_Int8 > SAL_CALL convertIntegerFromARGB( const uno::Sequence< rendering::ARGBColor >& rgbColor ) override + { + const rendering::ARGBColor* pIn( rgbColor.getConstArray() ); + const std::size_t nLen( rgbColor.getLength() ); - public: - OGLColorSpace() : - maComponentTags(4), - maBitCounts(4) + uno::Sequence< sal_Int8 > aRes(nLen*4); + sal_Int8* pColors=aRes.getArray(); + for( std::size_t i=0; iRed); + *pColors++ = vcl::unotools::toByteColor(pIn->Green); + *pColors++ = vcl::unotools::toByteColor(pIn->Blue); + *pColors++ = vcl::unotools::toByteColor(pIn->Alpha); + ++pIn; } - }; + return aRes; + } - struct OGLColorSpaceHolder : public rtl::StaticWithInit, OGLColorSpaceHolder> + virtual uno::Sequence< sal_Int8 > SAL_CALL convertIntegerFromPARGB( const uno::Sequence< rendering::ARGBColor >& rgbColor ) override { - uno::Reference operator()() + const rendering::ARGBColor* pIn( rgbColor.getConstArray() ); + const std::size_t nLen( rgbColor.getLength() ); + + uno::Sequence< sal_Int8 > aRes(nLen*4); + sal_Int8* pColors=aRes.getArray(); + for( std::size_t i=0; iRed/pIn->Alpha); + *pColors++ = vcl::unotools::toByteColor(pIn->Green/pIn->Alpha); + *pColors++ = vcl::unotools::toByteColor(pIn->Blue/pIn->Alpha); + *pColors++ = vcl::unotools::toByteColor(pIn->Alpha); + ++pIn; } - }; + return aRes; + } - uno::Reference const & - getOGLColorSpace() +public: + OGLColorSpace() : + maComponentTags(4), + maBitCounts(4) { - return OGLColorSpaceHolder::get(); + sal_Int8* pTags = maComponentTags.getArray(); + sal_Int32* pBitCounts = maBitCounts.getArray(); + pTags[0] = rendering::ColorComponentTag::RGB_RED; + pTags[1] = rendering::ColorComponentTag::RGB_GREEN; + pTags[2] = rendering::ColorComponentTag::RGB_BLUE; + pTags[3] = rendering::ColorComponentTag::ALPHA; + + pBitCounts[0] = + pBitCounts[1] = + pBitCounts[2] = + pBitCounts[3] = 8; } -} +}; + +struct OGLColorSpaceHolder : public rtl::StaticWithInit, OGLColorSpaceHolder> +{ + uno::Reference operator()() + { + return new OGLColorSpace(); + } +}; -namespace { +uno::Reference const & +getOGLColorSpace() +{ + return OGLColorSpaceHolder::get(); +} void buildMipmaps( GLint internalFormat, GLsizei width, GLsizei height, GLenum format, @@ -838,8 +833,6 @@ void buildMipmaps( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); } -} - void OGLTransitionerImpl::impl_createTexture( bool useMipmap, uno::Sequence& data, diff --git a/slideshow/source/engine/slide/slideimpl.cxx b/slideshow/source/engine/slide/slideimpl.cxx index c81dfff0d10a..ab1214538af3 100644 --- a/slideshow/source/engine/slide/slideimpl.cxx +++ b/slideshow/source/engine/slide/slideimpl.cxx @@ -688,37 +688,34 @@ SlideBitmapSharedPtr SlideImpl::createCurrentSlideBitmap( const UnoViewSharedPtr return std::make_shared( pBitmap ); } -namespace +class MainSequenceSearcher { - class MainSequenceSearcher +public: + MainSequenceSearcher() { - public: - MainSequenceSearcher() - { - maSearchKey.Name = "node-type"; - maSearchKey.Value <<= presentation::EffectNodeType::MAIN_SEQUENCE; - } - - void operator()( const uno::Reference< animations::XAnimationNode >& xChildNode ) - { - uno::Sequence< beans::NamedValue > aUserData( xChildNode->getUserData() ); + maSearchKey.Name = "node-type"; + maSearchKey.Value <<= presentation::EffectNodeType::MAIN_SEQUENCE; + } - if( findNamedValue( aUserData, maSearchKey ) ) - { - maMainSequence = xChildNode; - } - } + void operator()( const uno::Reference< animations::XAnimationNode >& xChildNode ) + { + uno::Sequence< beans::NamedValue > aUserData( xChildNode->getUserData() ); - const uno::Reference< animations::XAnimationNode >& getMainSequence() const + if( findNamedValue( aUserData, maSearchKey ) ) { - return maMainSequence; + maMainSequence = xChildNode; } + } - private: - beans::NamedValue maSearchKey; - uno::Reference< animations::XAnimationNode > maMainSequence; - }; -} + const uno::Reference< animations::XAnimationNode >& getMainSequence() const + { + return maMainSequence; + } + +private: + beans::NamedValue maSearchKey; + uno::Reference< animations::XAnimationNode > maMainSequence; +}; bool SlideImpl::implPrefetchShow() { diff --git a/stoc/source/uriproc/UriSchemeParser_vndDOTsunDOTstarDOTscript.cxx b/stoc/source/uriproc/UriSchemeParser_vndDOTsunDOTstarDOTscript.cxx index 7ad8ac04a8f9..5280e54164be 100644 --- a/stoc/source/uriproc/UriSchemeParser_vndDOTsunDOTstarDOTscript.cxx +++ b/stoc/source/uriproc/UriSchemeParser_vndDOTsunDOTstarDOTscript.cxx @@ -135,8 +135,6 @@ OUString parsePart( return buf.makeStringAndClear(); } -namespace { - OUString encodeNameOrParamFragment(OUString const & fragment) { static sal_Bool const nameOrParamFragment[] = { false, false, false, false, false, false, false, false, @@ -160,8 +158,6 @@ OUString encodeNameOrParamFragment(OUString const & fragment) { RTL_TEXTENCODING_UTF8); } -} - bool parseSchemeSpecificPart(OUString const & part) { sal_Int32 len = part.getLength(); sal_Int32 i = 0; diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx index b0960e7973fc..7f10e5f0a4e1 100644 --- a/svl/qa/unit/svl.cxx +++ b/svl/qa/unit/svl.cxx @@ -1133,7 +1133,6 @@ void Test::testIsNumberFormat() } } -namespace { struct FormatInputOutput { const char* mpInput; @@ -1141,7 +1140,6 @@ struct FormatInputOutput const char* mpOutput; const sal_uInt32 mnOutputIndex; }; -} void checkSpecificNumberFormats( SvNumberFormatter& rFormatter, const std::vector& rVec, const char* pName ) diff --git a/svtools/source/uno/wizard/unowizard.cxx b/svtools/source/uno/wizard/unowizard.cxx index c44c8de02a8f..9906d34e5ffe 100644 --- a/svtools/source/uno/wizard/unowizard.cxx +++ b/svtools/source/uno/wizard/unowizard.cxx @@ -67,23 +67,19 @@ namespace { namespace WizardButton = css::ui::dialogs::WizardButton; - - namespace + WizardButtonFlags lcl_convertWizardButtonToWZB( const sal_Int16 i_nWizardButton ) { - WizardButtonFlags lcl_convertWizardButtonToWZB( const sal_Int16 i_nWizardButton ) + switch ( i_nWizardButton ) { - switch ( i_nWizardButton ) - { - case WizardButton::NONE: return WizardButtonFlags::NONE; - case WizardButton::NEXT: return WizardButtonFlags::NEXT; - case WizardButton::PREVIOUS: return WizardButtonFlags::PREVIOUS; - case WizardButton::FINISH: return WizardButtonFlags::FINISH; - case WizardButton::CANCEL: return WizardButtonFlags::CANCEL; - case WizardButton::HELP: return WizardButtonFlags::HELP; - } - OSL_FAIL( "lcl_convertWizardButtonToWZB: invalid WizardButton constant!" ); - return WizardButtonFlags::NONE; + case WizardButton::NONE: return WizardButtonFlags::NONE; + case WizardButton::NEXT: return WizardButtonFlags::NEXT; + case WizardButton::PREVIOUS: return WizardButtonFlags::PREVIOUS; + case WizardButton::FINISH: return WizardButtonFlags::FINISH; + case WizardButton::CANCEL: return WizardButtonFlags::CANCEL; + case WizardButton::HELP: return WizardButtonFlags::HELP; } + OSL_FAIL( "lcl_convertWizardButtonToWZB: invalid WizardButton constant!" ); + return WizardButtonFlags::NONE; } typedef ::cppu::ImplInheritanceHelper < ::svt::OGenericUnoDialog @@ -147,8 +143,6 @@ namespace { { } - namespace { - OUString lcl_getHelpURL( const OString& sHelpId ) { OUStringBuffer aBuffer; @@ -161,8 +155,6 @@ namespace { return aBuffer.makeStringAndClear(); } - } - Wizard::~Wizard() { if ( m_pDialog ) @@ -176,53 +168,48 @@ namespace { } } - - namespace + void lcl_checkPaths( const Sequence< Sequence< sal_Int16 > >& i_rPaths, const Reference< XInterface >& i_rContext ) { - void lcl_checkPaths( const Sequence< Sequence< sal_Int16 > >& i_rPaths, const Reference< XInterface >& i_rContext ) + // need at least one path + if ( i_rPaths.getLength() == 0 ) + throw IllegalArgumentException( OUString(), i_rContext, 2 ); + + // each path must be of length 1, at least + for ( sal_Int32 i = 0; i < i_rPaths.getLength(); ++i ) { - // need at least one path - if ( i_rPaths.getLength() == 0 ) + if ( i_rPaths[i].getLength() == 0 ) throw IllegalArgumentException( OUString(), i_rContext, 2 ); - // each path must be of length 1, at least - for ( sal_Int32 i = 0; i < i_rPaths.getLength(); ++i ) + // page IDs must be in ascending order + sal_Int16 nPreviousPageID = i_rPaths[i][0]; + for ( sal_Int32 j=1; j& i_Arguments ) { ::osl::MutexGuard aGuard( m_aMutex ); diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.cxx b/svx/source/tbxctrls/tbunosearchcontrollers.cxx index 4bf9fb6ac898..e41751c6beac 100644 --- a/svx/source/tbxctrls/tbunosearchcontrollers.cxx +++ b/svx/source/tbxctrls/tbunosearchcontrollers.cxx @@ -319,14 +319,11 @@ SearchToolbarControllersManager::SearchToolbarControllersManager() { } -namespace +class theSearchToolbarControllersManager + : public rtl::Static { - class theSearchToolbarControllersManager - : public rtl::Static - { - }; -} +}; SearchToolbarControllersManager& SearchToolbarControllersManager::createControllersManager() { diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx index f93e00d11a1c..2506285ad866 100644 --- a/sw/source/core/unocore/unoportenum.cxx +++ b/sw/source/core/unocore/unoportenum.cxx @@ -225,8 +225,6 @@ namespace } } -namespace -{ class theSwXTextPortionEnumerationUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXTextPortionEnumerationUnoTunnelId > {}; struct SwAnnotationStartPortion_Impl { @@ -306,7 +304,6 @@ namespace } } } -} } diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx index 2dc9dd02eccb..90d7ce2ce2ec 100644 --- a/toolkit/source/awt/vclxtoolkit.cxx +++ b/toolkit/source/awt/vclxtoolkit.cxx @@ -544,46 +544,42 @@ WindowType ImplGetComponentType( const OUString& rServiceName ) return pInf ? pInf->nWinType : WindowType::NONE; } +struct MessageBoxTypeInfo +{ + css::awt::MessageBoxType eType; + const sal_Char *pName; + sal_Int32 nLen; +}; -namespace +static const MessageBoxTypeInfo aMessageBoxTypeInfo[] = { - struct MessageBoxTypeInfo - { - css::awt::MessageBoxType eType; - const sal_Char *pName; - sal_Int32 nLen; - }; + { css::awt::MessageBoxType_MESSAGEBOX, RTL_CONSTASCII_STRINGPARAM("messbox") }, + { css::awt::MessageBoxType_INFOBOX, RTL_CONSTASCII_STRINGPARAM("infobox") }, + { css::awt::MessageBoxType_WARNINGBOX, RTL_CONSTASCII_STRINGPARAM("warningbox") }, + { css::awt::MessageBoxType_ERRORBOX, RTL_CONSTASCII_STRINGPARAM("errorbox") }, + { css::awt::MessageBoxType_QUERYBOX, RTL_CONSTASCII_STRINGPARAM("querybox") }, + { css::awt::MessageBoxType::MessageBoxType_MAKE_FIXED_SIZE, nullptr, 0 } +}; - static const MessageBoxTypeInfo aMessageBoxTypeInfo[] = - { - { css::awt::MessageBoxType_MESSAGEBOX, RTL_CONSTASCII_STRINGPARAM("messbox") }, - { css::awt::MessageBoxType_INFOBOX, RTL_CONSTASCII_STRINGPARAM("infobox") }, - { css::awt::MessageBoxType_WARNINGBOX, RTL_CONSTASCII_STRINGPARAM("warningbox") }, - { css::awt::MessageBoxType_ERRORBOX, RTL_CONSTASCII_STRINGPARAM("errorbox") }, - { css::awt::MessageBoxType_QUERYBOX, RTL_CONSTASCII_STRINGPARAM("querybox") }, - { css::awt::MessageBoxType::MessageBoxType_MAKE_FIXED_SIZE, nullptr, 0 } - }; - - bool lcl_convertMessageBoxType( - rtl::OUString &sType, - css::awt::MessageBoxType eType ) - { - const MessageBoxTypeInfo *pMap = aMessageBoxTypeInfo; - css::awt::MessageBoxType eVal = css::awt::MessageBoxType::MessageBoxType_MAKE_FIXED_SIZE; +bool lcl_convertMessageBoxType( + rtl::OUString &sType, + css::awt::MessageBoxType eType ) +{ + const MessageBoxTypeInfo *pMap = aMessageBoxTypeInfo; + css::awt::MessageBoxType eVal = css::awt::MessageBoxType::MessageBoxType_MAKE_FIXED_SIZE; - while ( pMap->pName ) + while ( pMap->pName ) + { + if ( pMap->eType == eType ) { - if ( pMap->eType == eType ) - { - eVal = eType; - sType = rtl::OUString( pMap->pName, pMap->nLen, RTL_TEXTENCODING_ASCII_US ); - break; - } - pMap++; + eVal = eType; + sType = rtl::OUString( pMap->pName, pMap->nLen, RTL_TEXTENCODING_ASCII_US ); + break; } - - return ( eVal != css::awt::MessageBoxType::MessageBoxType_MAKE_FIXED_SIZE ); + pMap++; } + + return ( eVal != css::awt::MessageBoxType::MessageBoxType_MAKE_FIXED_SIZE ); } static sal_Int32 nVCLToolkitInstanceCount = 0; diff --git a/toolkit/source/controls/animatedimages.cxx b/toolkit/source/controls/animatedimages.cxx index 4d8f55f8ff6e..3e29b67cb01e 100644 --- a/toolkit/source/controls/animatedimages.cxx +++ b/toolkit/source/controls/animatedimages.cxx @@ -131,22 +131,17 @@ public: return aServices; } - - namespace + void lcl_updatePeer( Reference< XWindowPeer > const& i_peer, Reference< XControlModel > const& i_model ) { - void lcl_updatePeer( Reference< XWindowPeer > const& i_peer, Reference< XControlModel > const& i_model ) + const Reference< css::util::XModifyListener > xPeerModify( i_peer, UNO_QUERY ); + if ( xPeerModify.is() ) { - const Reference< css::util::XModifyListener > xPeerModify( i_peer, UNO_QUERY ); - if ( xPeerModify.is() ) - { - EventObject aEvent; - aEvent.Source = i_model; - xPeerModify->modified( aEvent ); - } + EventObject aEvent; + aEvent.Source = i_model; + xPeerModify->modified( aEvent ); } } - sal_Bool SAL_CALL AnimatedImagesControl::setModel( const Reference< XControlModel >& i_rModel ) { const Reference< XAnimatedImages > xOldContainer( getModel(), UNO_QUERY ); diff --git a/toolkit/source/controls/grid/sortablegriddatamodel.cxx b/toolkit/source/controls/grid/sortablegriddatamodel.cxx index e9cafb05b6d8..f81aefd734fd 100644 --- a/toolkit/source/controls/grid/sortablegriddatamodel.cxx +++ b/toolkit/source/controls/grid/sortablegriddatamodel.cxx @@ -209,15 +209,12 @@ public: } }; - namespace - { - template< class STLCONTAINER > - void lcl_clear( STLCONTAINER& i_container ) - { - STLCONTAINER empty; - empty.swap( i_container ); - } - } +template< class STLCONTAINER > +void lcl_clear( STLCONTAINER& i_container ) +{ + STLCONTAINER empty; + empty.swap( i_container ); +} SortableGridDataModel::SortableGridDataModel( Reference< XComponentContext > const & rxContext ) :SortableGridDataModel_Base( m_aMutex ) @@ -296,18 +293,13 @@ public: return css::uno::Sequence(); } - - namespace + Reference< XCollator > lcl_loadDefaultCollator_throw( const Reference & rxContext ) { - Reference< XCollator > lcl_loadDefaultCollator_throw( const Reference & rxContext ) - { - Reference< XCollator > const xCollator = Collator::create( rxContext ); - xCollator->loadDefaultCollator( Application::GetSettings().GetLanguageTag().getLocale(), 0 ); - return xCollator; - } + Reference< XCollator > const xCollator = Collator::create( rxContext ); + xCollator->loadDefaultCollator( Application::GetSettings().GetLanguageTag().getLocale(), 0 ); + return xCollator; } - void SAL_CALL SortableGridDataModel::initialize( const Sequence< Any >& i_arguments ) { ::comphelper::ComponentGuard aGuard( *this, rBHelper ); @@ -381,23 +373,18 @@ public: impl_broadcast( &XGridDataListener::rowsInserted, aEvent, aGuard ); } - - namespace + void lcl_decrementValuesGreaterThan( ::std::vector< ::sal_Int32 > & io_indexMap, sal_Int32 const i_threshold ) { - void lcl_decrementValuesGreaterThan( ::std::vector< ::sal_Int32 > & io_indexMap, sal_Int32 const i_threshold ) + for ( ::std::vector< ::sal_Int32 >::iterator loop = io_indexMap.begin(); + loop != io_indexMap.end(); + ++loop + ) { - for ( ::std::vector< ::sal_Int32 >::iterator loop = io_indexMap.begin(); - loop != io_indexMap.end(); - ++loop - ) - { - if ( *loop >= i_threshold ) - --*loop; - } + if ( *loop >= i_threshold ) + --*loop; } } - void SortableGridDataModel::impl_rebuildIndexesAndNotify( MethodGuard& i_instanceLock ) { OSL_PRECOND( impl_isSorted_nothrow(), "SortableGridDataModel::impl_rebuildIndexesAndNotify: illegal call!" ); @@ -506,47 +493,42 @@ public: { } - - namespace + class CellDataLessComparison { - class CellDataLessComparison + public: + CellDataLessComparison( + ::std::vector< Any > const & i_data, + ::comphelper::IKeyPredicateLess const & i_predicate, + bool const i_sortAscending + ) + :m_data( i_data ) + ,m_predicate( i_predicate ) + ,m_sortAscending( i_sortAscending ) { - public: - CellDataLessComparison( - ::std::vector< Any > const & i_data, - ::comphelper::IKeyPredicateLess const & i_predicate, - bool const i_sortAscending - ) - :m_data( i_data ) - ,m_predicate( i_predicate ) - ,m_sortAscending( i_sortAscending ) - { - } - - bool operator()( sal_Int32 const i_lhs, sal_Int32 const i_rhs ) const - { - Any const & lhs = m_data[ i_lhs ]; - Any const & rhs = m_data[ i_rhs ]; - // is less than everything else - if ( !lhs.hasValue() ) - return m_sortAscending; - if ( !rhs.hasValue() ) - return !m_sortAscending; - - // actually compare - if ( m_sortAscending ) - return m_predicate.isLess( lhs, rhs ); - else - return m_predicate.isLess( rhs, lhs ); - } + } - private: - ::std::vector< Any > const & m_data; - ::comphelper::IKeyPredicateLess const & m_predicate; - bool const m_sortAscending; - }; - } + bool operator()( sal_Int32 const i_lhs, sal_Int32 const i_rhs ) const + { + Any const & lhs = m_data[ i_lhs ]; + Any const & rhs = m_data[ i_rhs ]; + // is less than everything else + if ( !lhs.hasValue() ) + return m_sortAscending; + if ( !rhs.hasValue() ) + return !m_sortAscending; + + // actually compare + if ( m_sortAscending ) + return m_predicate.isLess( lhs, rhs ); + else + return m_predicate.isLess( rhs, lhs ); + } + private: + ::std::vector< Any > const & m_data; + ::comphelper::IKeyPredicateLess const & m_predicate; + bool const m_sortAscending; + }; bool SortableGridDataModel::impl_reIndex_nothrow( ::sal_Int32 const i_columnIndex, bool const i_sortAscending ) { diff --git a/vcl/source/gdi/dibtools.cxx b/vcl/source/gdi/dibtools.cxx index 61acb72dfcb2..95c07b589d8d 100644 --- a/vcl/source/gdi/dibtools.cxx +++ b/vcl/source/gdi/dibtools.cxx @@ -321,35 +321,31 @@ bool ImplReadDIBPalette(SvStream& rIStm, BitmapPalette& rPal, bool bQuad) return rIStm.GetError() == ERRCODE_NONE; } -namespace +BitmapColor SanitizePaletteIndex(sal_uInt8 nIndex, BitmapPalette& rPalette, bool bForceToMonoWhileReading) { - BitmapColor SanitizePaletteIndex(sal_uInt8 nIndex, BitmapPalette& rPalette, bool bForceToMonoWhileReading) + const sal_uInt16 nPaletteEntryCount = rPalette.GetEntryCount(); + if (nPaletteEntryCount && nIndex >= nPaletteEntryCount) { - const sal_uInt16 nPaletteEntryCount = rPalette.GetEntryCount(); - if (nPaletteEntryCount && nIndex >= nPaletteEntryCount) - { - auto nSanitizedIndex = nIndex % nPaletteEntryCount; - SAL_WARN_IF(nIndex != nSanitizedIndex, "vcl", "invalid colormap index: " - << static_cast(nIndex) << ", colormap len is: " - << nPaletteEntryCount); - nIndex = nSanitizedIndex; - } - - if (nPaletteEntryCount && bForceToMonoWhileReading) - { - return BitmapColor(static_cast(rPalette[nIndex].GetLuminance() >= 255)); - } - - return BitmapColor(nIndex); + auto nSanitizedIndex = nIndex % nPaletteEntryCount; + SAL_WARN_IF(nIndex != nSanitizedIndex, "vcl", "invalid colormap index: " + << static_cast(nIndex) << ", colormap len is: " + << nPaletteEntryCount); + nIndex = nSanitizedIndex; } - BitmapColor SanitizeColor(const BitmapColor &rColor, bool bForceToMonoWhileReading) + if (nPaletteEntryCount && bForceToMonoWhileReading) { - if (!bForceToMonoWhileReading) - return rColor; - return BitmapColor(static_cast(rColor.GetLuminance() >= 255)); + return BitmapColor(static_cast(rPalette[nIndex].GetLuminance() >= 255)); } + return BitmapColor(nIndex); +} + +BitmapColor SanitizeColor(const BitmapColor &rColor, bool bForceToMonoWhileReading) +{ + if (!bForceToMonoWhileReading) + return rColor; + return BitmapColor(static_cast(rColor.GetLuminance() >= 255)); } bool ImplDecodeRLE(sal_uInt8* pBuffer, DIBV5Header const & rHeader, BitmapWriteAccess& rAcc, BitmapPalette& rPalette, bool bForceToMonoWhileReading, bool bRLE4) -- cgit