New loplugin:nestedunnamed

Change-Id: Ifb434589ef08428ce609bc7a40b015d4df13224c
Reviewed-on: https://gerrit.libreoffice.org/50048
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
diff --git a/compilerplugins/clang/nestedunnamed.cxx b/compilerplugins/clang/nestedunnamed.cxx
new file mode 100644
index 0000000..c26f5aa
--- /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 <cassert>

#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<NestedUnnamed>, 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<NamespaceDecl>(p);
            if (outer != nullptr)
            {
                break;
            }
            if (isa<TranslationUnitDecl>(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<NestedUnnamed> 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 8a0f82f..ee67a9a 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 a2225af..47c9fa9 100644
--- a/desktop/source/deployment/registry/component/dp_component.cxx
+++ b/desktop/source/deployment/registry/component/dp_component.cxx
@@ -1099,9 +1099,6 @@ Reference<XComponentContext> 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 e0f03a8..44d3e7a 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<OUString>& rSeq, const OUString& rVal)
{
    for (sal_Int32 i = 0, n = rSeq.getLength(); i < n; ++i)
@@ -249,8 +247,6 @@ bool includes(const uno::Sequence<OUString>& 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 861cfcf..f85756f 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();

    Any aElement;
    for ( sal_Int32 i=0; i < count; ++i )
    {
        css::uno::Reference< css::container::XIndexAccess > xFramesContainer( i_rFrames->getFrames(), css::uno::UNO_QUERY );
        const sal_Int32 count = xFramesContainer->getCount();
        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 );

        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::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 dec5803..b950862 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<sal_Int16>(_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<sal_Int16>(_rParser.GetPort());
        // Don't add last segment as it is the name!
        --nCount;

        sal_Int32 nCount = _rParser.getSegmentCount( false );
        OUStringBuffer aPath;
        for ( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
        {
            aPath.append( '/');
            aPath.append( _rParser.getName( nIndex, false, INetURLObject::DecodeMechanism::NONE ));
        }

        if ( nCount > 0 )
        {
            // Don't add last segment as it is the name!
            --nCount;
            aPath.append( '/' ); // final slash!

            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!

            _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  (                                    );
        }

        _rURL.Arguments  = _rParser.GetParam();
        _rURL.Mark      = _rParser.GetMark( INetURLObject::DecodeMechanism::WithCharset );

        // 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();

        _rParser.SetMark    ( OUString() );
        _rParser.SetParam( OUString() );

        _rURL.Main       = _rParser.GetMainURL( INetURLObject::DecodeMechanism::NONE           );
        _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  (                                    );
    }

    _rURL.Arguments  = _rParser.GetParam();
    _rURL.Mark      = _rParser.GetMark( INetURLObject::DecodeMechanism::WithCharset );

    // 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();

    _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 ed46fdd..2cca296 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<std::string>& 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 0dd3afd..49f9471 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 d9cce4a..d79ffc3 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)
{
    const size_t nOrigLen(sal::static_int_cast<size_t>(i_rStr.getLength()));
    const sal_Char* const pOrig(i_rStr.getStr());
    std::unique_ptr<sal_Char[]> pBuffer(new sal_Char[nOrigLen + 1]);

    /** 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 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<size_t>(i_rStr.getLength()));
        const sal_Char* const pOrig(i_rStr.getStr());
        std::unique_ptr<sal_Char[]> 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<size_t>(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<size_t>(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 153ff8e..7849fd1 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<const SfxBoolItem*>( _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<const SfxBoolItem*>( _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 275c9e4..7fa0076 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<css::uno::Any>(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 299dff9..b0ceabe 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<rendering::ARGBColor> 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<rendering::XColorSpace*>(this), 0);

        uno::Sequence< rendering::RGBColor > aRes(nLen/4);
        rendering::RGBColor* pOut( aRes.getArray() );
        for( std::size_t i=0; i<nLen; i+=4 )
        {
            return rendering::ColorSpaceType::RGB;
            *pOut++ = rendering::RGBColor(pIn[0],pIn[1],pIn[2]);
            pIn += 4;
        }
        virtual uno::Sequence< sal_Int8 > 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<rendering::XColorSpace*>(this), 0);

        uno::Sequence< rendering::ARGBColor > aRes(nLen/4);
        rendering::ARGBColor* pOut( aRes.getArray() );
        for( std::size_t i=0; i<nLen; i+=4 )
        {
            return maComponentTags;
            *pOut++ = rendering::ARGBColor(pIn[3],pIn[0],pIn[1],pIn[2]);
            pIn += 4;
        }
        virtual sal_Int8 SAL_CALL getRenderingIntent(  ) override
        return aRes;
    }
    virtual uno::Sequence< rendering::ARGBColor > 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<rendering::XColorSpace*>(this), 0);

        uno::Sequence< rendering::ARGBColor > aRes(nLen/4);
        rendering::ARGBColor* pOut( aRes.getArray() );
        for( std::size_t i=0; i<nLen; i+=4 )
        {
            return rendering::RenderingIntent::PERCEPTUAL;
            *pOut++ = rendering::ARGBColor(pIn[3],pIn[3]*pIn[0],pIn[3]*pIn[1],pIn[3]*pIn[2]);
            pIn += 4;
        }
        virtual uno::Sequence< beans::PropertyValue > 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<nLen; ++i )
        {
            return uno::Sequence< beans::PropertyValue >();
            *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<nLen; ++i )
        {
            *pColors++ = pIn->Red;
            *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; i<nLen; ++i )
        {
            *pColors++ = pIn->Red/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;
    }
    virtual sal_Int8 SAL_CALL getEndianness(  ) override
    {
        return util::Endianness::LITTLE;
    }
    virtual uno::Sequence<double> SAL_CALL convertFromIntegerColorSpace( const uno::Sequence< sal_Int8 >& deviceColor,
                                                                            const uno::Reference< rendering::XColorSpace >& targetColorSpace ) override
    {
        if( dynamic_cast<OGLColorSpace*>(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<rendering::XColorSpace*>(this), 0);

            uno::Sequence<double> aRes(nLen);
            double* pOut( aRes.getArray() );
            for( std::size_t i=0; i<nLen; i+=4 )
            {
                *pOut++ = vcl::unotools::toDoubleColor(*pIn++);
                *pOut++ = vcl::unotools::toDoubleColor(*pIn++);
                *pOut++ = vcl::unotools::toDoubleColor(*pIn++);
                *pOut++ = vcl::unotools::toDoubleColor(*pIn++);
            }
            return aRes;
        }
        else
        {
            // TODO(P3): if we know anything about target
            // colorspace, this can be greatly sped up
            uno::Sequence<rendering::ARGBColor> aIntermediate(
                convertToARGB(deviceColor));
                convertIntegerToARGB(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<rendering::XColorSpace*>(this), 0);

            uno::Sequence< rendering::RGBColor > aRes(nLen/4);
            rendering::RGBColor* pOut( aRes.getArray() );
            for( std::size_t i=0; i<nLen; i+=4 )
            {
                *pOut++ = rendering::RGBColor(pIn[0],pIn[1],pIn[2]);
                pIn += 4;
            }
            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<rendering::XColorSpace*>(this), 0);

            uno::Sequence< rendering::ARGBColor > aRes(nLen/4);
            rendering::ARGBColor* pOut( aRes.getArray() );
            for( std::size_t i=0; i<nLen; i+=4 )
            {
                *pOut++ = rendering::ARGBColor(pIn[3],pIn[0],pIn[1],pIn[2]);
                pIn += 4;
            }
            return aRes;
        }
        virtual uno::Sequence< rendering::ARGBColor > 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<rendering::XColorSpace*>(this), 0);

            uno::Sequence< rendering::ARGBColor > aRes(nLen/4);
            rendering::ARGBColor* pOut( aRes.getArray() );
            for( std::size_t i=0; i<nLen; i+=4 )
            {
                *pOut++ = rendering::ARGBColor(pIn[3],pIn[3]*pIn[0],pIn[3]*pIn[1],pIn[3]*pIn[2]);
                pIn += 4;
            }
            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<nLen; ++i )
            {
                *pColors++ = pIn->Red;
                *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; i<nLen; ++i )
            {
                *pColors++ = pIn->Red;
                *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; i<nLen; ++i )
            {
                *pColors++ = pIn->Red/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;
        }
        virtual sal_Int8 SAL_CALL getEndianness(  ) override
        {
            return util::Endianness::LITTLE;
        }
        virtual uno::Sequence<double> SAL_CALL convertFromIntegerColorSpace( const uno::Sequence< sal_Int8 >& deviceColor,
                                                                                const uno::Reference< rendering::XColorSpace >& targetColorSpace ) override
        {
            if( dynamic_cast<OGLColorSpace*>(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<rendering::XColorSpace*>(this), 0);

                uno::Sequence<double> aRes(nLen);
                double* pOut( aRes.getArray() );
                for( std::size_t i=0; i<nLen; i+=4 )
                {
                    *pOut++ = vcl::unotools::toDoubleColor(*pIn++);
                    *pOut++ = vcl::unotools::toDoubleColor(*pIn++);
                    *pOut++ = vcl::unotools::toDoubleColor(*pIn++);
                    *pOut++ = vcl::unotools::toDoubleColor(*pIn++);
                }
                return aRes;
            }
            else
            {
                // TODO(P3): if we know anything about target
                // colorspace, this can be greatly sped up
                uno::Sequence<rendering::ARGBColor> aIntermediate(
                    convertIntegerToARGB(deviceColor));
                return targetColorSpace->convertFromARGB(aIntermediate);
            }
        }
        virtual uno::Sequence< sal_Int8 > SAL_CALL convertToIntegerColorSpace( const uno::Sequence< sal_Int8 >& deviceColor,
                                                                                    const uno::Reference< rendering::XIntegerBitmapColorSpace >& targetColorSpace ) override
        {
            if( dynamic_cast<OGLColorSpace*>(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<rendering::ARGBColor> 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<rendering::XColorSpace*>(this), 0);

            uno::Sequence< rendering::RGBColor > aRes(nLen/4);
            rendering::RGBColor* pOut( aRes.getArray() );
            for( std::size_t i=0; i<nLen; i+=4 )
            {
                *pOut++ = rendering::RGBColor(
                    vcl::unotools::toDoubleColor(pIn[0]),
                    vcl::unotools::toDoubleColor(pIn[1]),
                    vcl::unotools::toDoubleColor(pIn[2]));
                pIn += 4;
            }
            return aRes;
        }

        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<rendering::XColorSpace*>(this), 0);

            uno::Sequence< rendering::ARGBColor > aRes(nLen/4);
            rendering::ARGBColor* pOut( aRes.getArray() );
            for( std::size_t i=0; i<nLen; i+=4 )
            {
                *pOut++ = rendering::ARGBColor(
                    vcl::unotools::toDoubleColor(pIn[3]),
                    vcl::unotools::toDoubleColor(pIn[0]),
                    vcl::unotools::toDoubleColor(pIn[1]),
                    vcl::unotools::toDoubleColor(pIn[2]));
                pIn += 4;
            }
            return aRes;
        }

        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<rendering::XColorSpace*>(this), 0);

            uno::Sequence< rendering::ARGBColor > aRes(nLen/4);
            rendering::ARGBColor* pOut( aRes.getArray() );
            for( std::size_t i=0; i<nLen; i+=4 )
            {
                const sal_Int8 nAlpha( pIn[3] );
                *pOut++ = rendering::ARGBColor(
                    vcl::unotools::toDoubleColor(nAlpha),
                    vcl::unotools::toDoubleColor(nAlpha*pIn[0]),
                    vcl::unotools::toDoubleColor(nAlpha*pIn[1]),
                    vcl::unotools::toDoubleColor(nAlpha*pIn[2]));
                pIn += 4;
            }
            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() );

            uno::Sequence< sal_Int8 > aRes(nLen*4);
            sal_Int8* pColors=aRes.getArray();
            for( std::size_t i=0; i<nLen; ++i )
            {
                *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 convertIntegerFromARGB( 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; i<nLen; ++i )
            {
                *pColors++ = vcl::unotools::toByteColor(pIn->Red);
                *pColors++ = vcl::unotools::toByteColor(pIn->Green);
                *pColors++ = vcl::unotools::toByteColor(pIn->Blue);
                *pColors++ = vcl::unotools::toByteColor(pIn->Alpha);
                ++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; i<nLen; ++i )
            {
                *pColors++ = vcl::unotools::toByteColor(pIn->Red/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;
        }

    public:
        OGLColorSpace() :
            maComponentTags(4),
            maBitCounts(4)
        {
            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<uno::Reference<rendering::XIntegerBitmapColorSpace>, OGLColorSpaceHolder>
    {
        uno::Reference<rendering::XIntegerBitmapColorSpace> operator()()
        {
            return new OGLColorSpace();
        }
    };

    uno::Reference<rendering::XIntegerBitmapColorSpace> const &
    getOGLColorSpace()
    {
        return OGLColorSpaceHolder::get();
    }
}
    virtual uno::Sequence< sal_Int8 > SAL_CALL convertToIntegerColorSpace( const uno::Sequence< sal_Int8 >& deviceColor,
                                                                                const uno::Reference< rendering::XIntegerBitmapColorSpace >& targetColorSpace ) override
    {
        if( dynamic_cast<OGLColorSpace*>(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<rendering::ARGBColor> 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<rendering::XColorSpace*>(this), 0);

namespace {
        uno::Sequence< rendering::RGBColor > aRes(nLen/4);
        rendering::RGBColor* pOut( aRes.getArray() );
        for( std::size_t i=0; i<nLen; i+=4 )
        {
            *pOut++ = rendering::RGBColor(
                vcl::unotools::toDoubleColor(pIn[0]),
                vcl::unotools::toDoubleColor(pIn[1]),
                vcl::unotools::toDoubleColor(pIn[2]));
            pIn += 4;
        }
        return aRes;
    }

    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<rendering::XColorSpace*>(this), 0);

        uno::Sequence< rendering::ARGBColor > aRes(nLen/4);
        rendering::ARGBColor* pOut( aRes.getArray() );
        for( std::size_t i=0; i<nLen; i+=4 )
        {
            *pOut++ = rendering::ARGBColor(
                vcl::unotools::toDoubleColor(pIn[3]),
                vcl::unotools::toDoubleColor(pIn[0]),
                vcl::unotools::toDoubleColor(pIn[1]),
                vcl::unotools::toDoubleColor(pIn[2]));
            pIn += 4;
        }
        return aRes;
    }

    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<rendering::XColorSpace*>(this), 0);

        uno::Sequence< rendering::ARGBColor > aRes(nLen/4);
        rendering::ARGBColor* pOut( aRes.getArray() );
        for( std::size_t i=0; i<nLen; i+=4 )
        {
            const sal_Int8 nAlpha( pIn[3] );
            *pOut++ = rendering::ARGBColor(
                vcl::unotools::toDoubleColor(nAlpha),
                vcl::unotools::toDoubleColor(nAlpha*pIn[0]),
                vcl::unotools::toDoubleColor(nAlpha*pIn[1]),
                vcl::unotools::toDoubleColor(nAlpha*pIn[2]));
            pIn += 4;
        }
        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() );

        uno::Sequence< sal_Int8 > aRes(nLen*4);
        sal_Int8* pColors=aRes.getArray();
        for( std::size_t i=0; i<nLen; ++i )
        {
            *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 convertIntegerFromARGB( 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; i<nLen; ++i )
        {
            *pColors++ = vcl::unotools::toByteColor(pIn->Red);
            *pColors++ = vcl::unotools::toByteColor(pIn->Green);
            *pColors++ = vcl::unotools::toByteColor(pIn->Blue);
            *pColors++ = vcl::unotools::toByteColor(pIn->Alpha);
            ++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; i<nLen; ++i )
        {
            *pColors++ = vcl::unotools::toByteColor(pIn->Red/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;
    }

public:
    OGLColorSpace() :
        maComponentTags(4),
        maBitCounts(4)
    {
        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<uno::Reference<rendering::XIntegerBitmapColorSpace>, OGLColorSpaceHolder>
{
    uno::Reference<rendering::XIntegerBitmapColorSpace> operator()()
    {
        return new OGLColorSpace();
    }
};

uno::Reference<rendering::XIntegerBitmapColorSpace> 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<sal_Int8>& data,
diff --git a/slideshow/source/engine/slide/slideimpl.cxx b/slideshow/source/engine/slide/slideimpl.cxx
index c81dfff..ab12145 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<SlideBitmap>( 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() );

        if( findNamedValue( aUserData, maSearchKey ) )
        {
            maSearchKey.Name = "node-type";
            maSearchKey.Value <<= presentation::EffectNodeType::MAIN_SEQUENCE;
            maMainSequence = xChildNode;
        }
    }

        void operator()( const uno::Reference< animations::XAnimationNode >& xChildNode )
        {
            uno::Sequence< beans::NamedValue > aUserData( xChildNode->getUserData() );
    const uno::Reference< animations::XAnimationNode >& getMainSequence() const
    {
        return maMainSequence;
    }

            if( findNamedValue( aUserData, maSearchKey ) )
            {
                maMainSequence = xChildNode;
            }
        }

        const uno::Reference< animations::XAnimationNode >& getMainSequence() const
        {
            return maMainSequence;
        }

    private:
        beans::NamedValue                               maSearchKey;
        uno::Reference< animations::XAnimationNode >    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 7ad8ac0..5280e54 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 b0960e7..7f10e5f 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<FormatInputOutput>& rVec, const char* pName )
diff --git a/svtools/source/uno/wizard/unowizard.cxx b/svtools/source/uno/wizard/unowizard.cxx
index c44c8de..9906d34 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,52 +168,47 @@ 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_rPaths[i].getLength(); ++j )
            {
                if ( i_rPaths[i].getLength() == 0 )
                    throw IllegalArgumentException( OUString(), i_rContext, 2 );

                // page IDs must be in ascending order
                sal_Int16 nPreviousPageID = i_rPaths[i][0];
                for ( sal_Int32 j=1; j<i_rPaths[i].getLength(); ++j )
                if ( i_rPaths[i][j] <= nPreviousPageID )
                {
                    if ( i_rPaths[i][j] <= nPreviousPageID )
                    {
                        throw IllegalArgumentException(
                            "Path " + OUString::number(i)
                            + ": invalid page ID sequence - each page ID must be greater than the previous one.",
                            i_rContext, 2 );
                    }
                    nPreviousPageID = i_rPaths[i][j];
                }
            }

            // if we have one path, that's okay
            if ( i_rPaths.getLength() == 1 )
                return;

            // if we have multiple paths, they must start with the same page id
            const sal_Int16 nFirstPageId = i_rPaths[0][0];
            for ( sal_Int32 i = 0; i < i_rPaths.getLength(); ++i )
            {
                if ( i_rPaths[i][0] != nFirstPageId )
                    throw IllegalArgumentException(
                        "All paths must start with the same page id.",
                        "Path " + OUString::number(i)
                        + ": invalid page ID sequence - each page ID must be greater than the previous one.",
                        i_rContext, 2 );
                }
                nPreviousPageID = i_rPaths[i][j];
            }
        }
    }

        // if we have one path, that's okay
        if ( i_rPaths.getLength() == 1 )
            return;

        // if we have multiple paths, they must start with the same page id
        const sal_Int16 nFirstPageId = i_rPaths[0][0];
        for ( sal_Int32 i = 0; i < i_rPaths.getLength(); ++i )
        {
            if ( i_rPaths[i][0] != nFirstPageId )
                throw IllegalArgumentException(
                    "All paths must start with the same page id.",
                    i_rContext, 2 );
        }
    }

    void SAL_CALL Wizard::initialize( const Sequence< Any >& i_Arguments )
    {
diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.cxx b/svx/source/tbxctrls/tbunosearchcontrollers.cxx
index 4bf9fb6..e41751c 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<SearchToolbarControllersManager,
        theSearchToolbarControllersManager>
{
    class theSearchToolbarControllersManager
        : public rtl::Static<SearchToolbarControllersManager,
            theSearchToolbarControllersManager>
    {
    };
}
};

SearchToolbarControllersManager& SearchToolbarControllersManager::createControllersManager()
{
diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx
index f93e00d..2506285 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 2dc9dd0..90d7ce2 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;
}


namespace
struct MessageBoxTypeInfo
{
    struct MessageBoxTypeInfo
    {
        css::awt::MessageBoxType eType;
        const sal_Char          *pName;
        sal_Int32                nLen;
    };
    css::awt::MessageBoxType eType;
    const sal_Char          *pName;
    sal_Int32                nLen;
};

    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 }
    };
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 4d8f55f..3e29b67c 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 e9cafb0..f81aefd 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<sal_Int8>();
    }


    namespace
    Reference< XCollator > lcl_loadDefaultCollator_throw( const Reference<XComponentContext> & rxContext )
    {
        Reference< XCollator > lcl_loadDefaultCollator_throw( const Reference<XComponentContext> & 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 ];
                // <VOID/> is less than everything else
                if ( !lhs.hasValue() )
                    return m_sortAscending;
                if ( !rhs.hasValue() )
                    return !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 ];
            // <VOID/> 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 );
            }
            // 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;
        };
    }

    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 61acb72..95c07b5 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<unsigned int>(nIndex) << ", colormap len is: "
                        << nPaletteEntryCount);
            nIndex = nSanitizedIndex;
        }

        if (nPaletteEntryCount && bForceToMonoWhileReading)
        {
            return BitmapColor(static_cast<sal_uInt8>(rPalette[nIndex].GetLuminance() >= 255));
        }

        return BitmapColor(nIndex);
        auto nSanitizedIndex = nIndex % nPaletteEntryCount;
        SAL_WARN_IF(nIndex != nSanitizedIndex, "vcl", "invalid colormap index: "
                    << static_cast<unsigned int>(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<sal_uInt8>(rColor.GetLuminance() >= 255));
        return BitmapColor(static_cast<sal_uInt8>(rPalette[nIndex].GetLuminance() >= 255));
    }

    return BitmapColor(nIndex);
}

BitmapColor SanitizeColor(const BitmapColor &rColor, bool bForceToMonoWhileReading)
{
    if (!bForceToMonoWhileReading)
        return rColor;
    return BitmapColor(static_cast<sal_uInt8>(rColor.GetLuminance() >= 255));
}

bool ImplDecodeRLE(sal_uInt8* pBuffer, DIBV5Header const & rHeader, BitmapWriteAccess& rAcc, BitmapPalette& rPalette, bool bForceToMonoWhileReading, bool bRLE4)