[Libreoffice-commits] core.git: Branch 'feature/drawinglayercore' - vcl/source

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Mon Feb 15 09:03:17 UTC 2021


Rebased ref, commits from common ancestor:
commit 52284530ca32fb7eb24f30b7beb22f65c711d836
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Mon Feb 15 17:49:34 2021 +0900
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Mon Feb 15 18:02:25 2021 +0900

    vcl: clean-up code used for loading of external graphic filters
    
    All graphic filters have been moved into vcl, so there is no need
    to load an external library that contained graphic filters, so
    this code can be removed.
    
    Change-Id: Iac4f8dd78464e142f50837a55edd2d25720b8c13

diff --git a/vcl/source/filter/FilterConfigCache.cxx b/vcl/source/filter/FilterConfigCache.cxx
index 411d44a5801d..482b8fed2ca0 100644
--- a/vcl/source/filter/FilterConfigCache.cxx
+++ b/vcl/source/filter/FilterConfigCache.cxx
@@ -55,39 +55,18 @@ const char* FilterConfigCache::FilterConfigCacheEntry::InternalVectorFilterNameL
     IMP_EPS, EXP_EPS, nullptr
 };
 
-const char* FilterConfigCache::FilterConfigCacheEntry::ExternalPixelFilterNameList[] =
-{
-   nullptr
-};
-
 void FilterConfigCache::FilterConfigCacheEntry::CreateFilterName( const OUString& rUserDataEntry )
 {
-    bIsPixelFormat = bIsInternalFilter = false;
+    bIsPixelFormat = false;
     sFilterName = rUserDataEntry;
     const char** pPtr;
-    for ( pPtr = InternalPixelFilterNameList; *pPtr && !bIsInternalFilter; pPtr++ )
+    for ( pPtr = InternalPixelFilterNameList; *pPtr; pPtr++ )
     {
         if ( sFilterName.equalsIgnoreAsciiCaseAscii( *pPtr ) )
         {
-            bIsInternalFilter = true;
             bIsPixelFormat = true;
         }
     }
-    for ( pPtr = InternalVectorFilterNameList; *pPtr && !bIsInternalFilter; pPtr++ )
-    {
-        if ( sFilterName.equalsIgnoreAsciiCaseAscii( *pPtr ) )
-            bIsInternalFilter = true;
-    }
-    if ( !bIsInternalFilter )
-    {
-        for ( pPtr = ExternalPixelFilterNameList; *pPtr && !bIsPixelFormat; pPtr++ )
-        {
-            if ( sFilterName.equalsIgnoreAsciiCaseAscii( *pPtr ) )
-                bIsPixelFormat = true;
-        }
-        sExternalFilterName = sFilterName;
-        sFilterName = SVLIBRARY("gie");
-    }
 }
 
 OUString FilterConfigCache::FilterConfigCacheEntry::GetShortName()
@@ -400,21 +379,6 @@ OUString FilterConfigCache::GetImportFilterTypeName( sal_uInt16 nFormat )
     return OUString();
 }
 
-OUString FilterConfigCache::GetExternalFilterName(sal_uInt16 nFormat, bool bExport)
-{
-    if (bExport)
-    {
-        if (nFormat < aExport.size())
-            return aExport[nFormat].sExternalFilterName;
-    }
-    else
-    {
-        if (nFormat < aImport.size())
-            return aImport[nFormat].sExternalFilterName;
-    }
-    return OUString();
-}
-
 OUString FilterConfigCache::GetImportWildcard(sal_uInt16 nFormat, sal_Int32 nEntry)
 {
     OUString aWildcard( GetImportFormatExtension( nFormat, nEntry ) );
@@ -423,11 +387,6 @@ OUString FilterConfigCache::GetImportWildcard(sal_uInt16 nFormat, sal_Int32 nEnt
     return aWildcard;
 }
 
-bool FilterConfigCache::IsImportInternalFilter( sal_uInt16 nFormat )
-{
-    return (nFormat < aImport.size()) && aImport[ nFormat ].bIsInternalFilter;
-}
-
 OUString FilterConfigCache::GetExportFilterName( sal_uInt16 nFormat )
 {
     if( nFormat < aExport.size() )
@@ -526,11 +485,6 @@ OUString FilterConfigCache::GetExportWildcard( sal_uInt16 nFormat, sal_Int32 nEn
     return aWildcard;
 }
 
-bool FilterConfigCache::IsExportInternalFilter( sal_uInt16 nFormat )
-{
-    return (nFormat < aExport.size()) && aExport[ nFormat ].bIsInternalFilter;
-}
-
 bool FilterConfigCache::IsExportPixelFormat( sal_uInt16 nFormat )
 {
     return (nFormat < aExport.size()) && aExport[ nFormat ].bIsPixelFormat;
diff --git a/vcl/source/filter/FilterConfigCache.hxx b/vcl/source/filter/FilterConfigCache.hxx
index 4860bbc6f38b..e6b0258bf803 100644
--- a/vcl/source/filter/FilterConfigCache.hxx
+++ b/vcl/source/filter/FilterConfigCache.hxx
@@ -32,7 +32,6 @@ class FilterConfigCache
         OUString sType;
         std::vector< OUString > lExtensionList;
         OUString sUIName;
-        OUString sExternalFilterName;
 
         OUString sMediaType;
         OUString sFilterType;
@@ -41,7 +40,6 @@ class FilterConfigCache
 
         // user data
         OUString        sFilterName;
-        bool        bIsInternalFilter   : 1;
         bool        bIsPixelFormat      : 1;
 
         void            CreateFilterName( const OUString& rUserDataEntry );
@@ -49,7 +47,6 @@ class FilterConfigCache
 
         static const char* InternalPixelFilterNameList[];
         static const char* InternalVectorFilterNameList[];
-        static const char* ExternalPixelFilterNameList[];
     };
 
 
@@ -77,7 +74,6 @@ public:
     OUString    GetImportWildcard( sal_uInt16 nFormat, sal_Int32 nEntry );
     OUString    GetImportFilterType( sal_uInt16 nFormat );
     OUString    GetImportFilterTypeName( sal_uInt16 nFormat );
-    OUString    GetExternalFilterName(sal_uInt16 nFormat, bool bExport);
 
 
     bool    IsImportInternalFilter( sal_uInt16 nFormat );
diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx
index 43851e9a56b5..782fa735da8a 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -599,131 +599,6 @@ static Graphic ImpGetScaledGraphic( const Graphic& rGraphic, FilterConfigItem& r
     return aGraphic;
 }
 
-static OUString ImpCreateFullFilterPath( const OUString& rPath, std::u16string_view rFilterName )
-{
-    OUString aPathURL;
-
-    ::osl::FileBase::getFileURLFromSystemPath( rPath, aPathURL );
-    aPathURL += "/";
-
-    OUString aSystemPath;
-    ::osl::FileBase::getSystemPathFromFileURL( aPathURL, aSystemPath );
-    aSystemPath += rFilterName;
-
-    return aSystemPath;
-}
-
-namespace {
-
-class ImpFilterLibCache;
-
-struct ImpFilterLibCacheEntry
-{
-    ImpFilterLibCacheEntry* mpNext;
-#ifndef DISABLE_DYNLOADING
-    osl::Module             maLibrary;
-#endif
-    OUString                maFiltername;
-    OUString                maFormatName;
-    PFilterCall             mpfnImport;
-
-    ImpFilterLibCacheEntry(const OUString& rPathname, const OUString& rFiltername, const OUString& rFormatName);
-    bool                    operator==( std::u16string_view rFiltername ) const { return maFiltername == rFiltername; }
-
-    PFilterCall             GetImportFunction();
-};
-
-}
-
-ImpFilterLibCacheEntry::ImpFilterLibCacheEntry( const OUString& rPathname, const OUString& rFiltername, const OUString& rFormatName ) :
-        mpNext          ( nullptr ),
-#ifndef DISABLE_DYNLOADING
-        maLibrary       ( rPathname ),
-#endif
-        maFiltername    ( rFiltername ),
-        maFormatName    ( rFormatName ),
-        mpfnImport      ( nullptr )
-{
-#ifdef DISABLE_DYNLOADING
-    (void) rPathname;
-#endif
-}
-
-PFilterCall ImpFilterLibCacheEntry::GetImportFunction()
-{
-    return nullptr;
-}
-
-namespace {
-
-class ImpFilterLibCache
-{
-    ImpFilterLibCacheEntry* mpFirst;
-    ImpFilterLibCacheEntry* mpLast;
-
-public:
-                            ImpFilterLibCache();
-                            ~ImpFilterLibCache();
-
-    ImpFilterLibCacheEntry* GetFilter( const OUString& rFilterPath, const OUString& rFiltername, const OUString& rFormatName );
-};
-
-}
-
-ImpFilterLibCache::ImpFilterLibCache() :
-    mpFirst     ( nullptr ),
-    mpLast      ( nullptr )
-{
-}
-
-ImpFilterLibCache::~ImpFilterLibCache()
-{
-    ImpFilterLibCacheEntry* pEntry = mpFirst;
-    while( pEntry )
-    {
-        ImpFilterLibCacheEntry* pNext = pEntry->mpNext;
-        delete pEntry;
-        pEntry = pNext;
-    }
-}
-
-ImpFilterLibCacheEntry* ImpFilterLibCache::GetFilter(const OUString& rFilterPath, const OUString& rFilterName, const OUString& rFormatName)
-{
-    ImpFilterLibCacheEntry* pEntry = mpFirst;
-
-    while( pEntry )
-    {
-        if( *pEntry == rFilterName && pEntry->maFormatName == rFormatName )
-            break;
-        else
-            pEntry = pEntry->mpNext;
-    }
-    if( !pEntry )
-    {
-        OUString aPhysicalName( ImpCreateFullFilterPath( rFilterPath, rFilterName ) );
-        pEntry = new ImpFilterLibCacheEntry(aPhysicalName, rFilterName, rFormatName );
-#ifndef DISABLE_DYNLOADING
-        if ( pEntry->maLibrary.is() )
-#endif
-        {
-            if( !mpFirst )
-                mpFirst = mpLast = pEntry;
-            else
-                mpLast = mpLast->mpNext = pEntry;
-        }
-#ifndef DISABLE_DYNLOADING
-        else
-        {
-            delete pEntry;
-            pEntry = nullptr;
-        }
-#endif
-    }
-    return pEntry;
-};
-
-namespace { struct Cache : public rtl::Static<ImpFilterLibCache, Cache> {}; }
-
 GraphicFilter::GraphicFilter( bool bConfig )
     : bUseConfig(bConfig)
 {
@@ -1149,13 +1024,11 @@ Graphic GraphicFilter::ImportUnloadedGraphic(SvStream& rIStream, sal_uInt64 size
         nStreamLength = sizeLimit;
 
     OUString aFilterName = pConfig->GetImportFilterName(nFormat);
-    OUString aExternalFilterName = pConfig->GetExternalFilterName(nFormat, false);
 
     std::unique_ptr<sal_uInt8[]> pGraphicContent;
     sal_Int32 nGraphicContentSize = 0;
 
     // read graphic
-    if (pConfig->IsImportInternalFilter(nFormat))
     {
         if (aFilterName.equalsIgnoreAsciiCase(IMP_GIF))
         {
@@ -1294,36 +1167,6 @@ Graphic GraphicFilter::ImportUnloadedGraphic(SvStream& rIStream, sal_uInt64 size
             nStatus = ERRCODE_GRFILTER_FILTERERROR;
         }
     }
-    else
-    {
-        ImpFilterLibCacheEntry* pFilter = nullptr;
-
-        if (!aFilterPath.isEmpty())
-        {
-            // find first filter in filter paths
-            ImpFilterLibCache &rCache = Cache::get();
-            sal_Int32 nIdx{0};
-            do {
-                pFilter = rCache.GetFilter(aFilterPath.getToken(0, ';', nIdx), aFilterName, aExternalFilterName);
-            } while (nIdx>=0 && pFilter==nullptr);
-        }
-
-        if( !pFilter )
-            nStatus = ERRCODE_GRFILTER_FILTERERROR;
-        else
-        {
-            PFilterCall pFunc = pFilter->GetImportFunction();
-
-            if (!pFunc)
-                nStatus = ERRCODE_GRFILTER_FILTERERROR;
-            else
-            {
-                OUString aShortName;
-                if (nFormat != GRFILTER_FORMAT_DONTKNOW)
-                    aShortName = GetImportFormatShortName(nFormat).toAsciiUpperCase();
-            }
-        }
-    }
 
     if (nStatus == ERRCODE_NONE && eLinkType != GfxLinkType::NONE)
     {
@@ -1741,7 +1584,6 @@ ErrCode GraphicFilter::ImportGraphic( Graphic& rGraphic, const OUString& rPath,
                                      WmfExternal const *pExtHeader )
 {
     OUString aFilterName;
-    OUString aExternalFilterName;
     sal_uLong  nStreamBegin;
     ErrCode nStatus;
     GfxLinkType eLinkType = GfxLinkType::NONE;
@@ -1783,7 +1625,6 @@ ErrCode GraphicFilter::ImportGraphic( Graphic& rGraphic, const OUString& rPath,
             *pDeterminedFormat = nFormat;
 
         aFilterName = pConfig->GetImportFilterName( nFormat );
-        aExternalFilterName = pConfig->GetExternalFilterName(nFormat, false);
     }
     else
     {
@@ -1794,7 +1635,6 @@ ErrCode GraphicFilter::ImportGraphic( Graphic& rGraphic, const OUString& rPath,
     }
 
     // read graphic
-    if ( pConfig->IsImportInternalFilter( nFormat ) )
     {
         if (aFilterName.equalsIgnoreAsciiCase(IMP_GIF))
         {
@@ -1891,35 +1731,6 @@ ErrCode GraphicFilter::ImportGraphic( Graphic& rGraphic, const OUString& rPath,
         else
             nStatus = ERRCODE_GRFILTER_FILTERERROR;
     }
-    else
-    {
-        ImpFilterLibCacheEntry* pFilter = nullptr;
-
-        if (!aFilterPath.isEmpty())
-        {
-            // find first filter in filter paths
-            ImpFilterLibCache &rCache = Cache::get();
-            sal_Int32 nIdx{0};
-            do {
-                pFilter = rCache.GetFilter(aFilterPath.getToken(0, ';', nIdx), aFilterName, aExternalFilterName);
-            } while (nIdx>=0 && pFilter==nullptr);
-        }
-
-        if( !pFilter )
-            nStatus = ERRCODE_GRFILTER_FILTERERROR;
-        else
-        {
-            PFilterCall pFunc = pFilter->GetImportFunction();
-
-            if( !pFunc )
-                nStatus = ERRCODE_GRFILTER_FILTERERROR;
-            else
-            {
-                if( !(*pFunc)( rIStream, rGraphic, nullptr ) )
-                    nStatus = ERRCODE_GRFILTER_FORMATERROR;
-            }
-        }
-    }
 
     if( nStatus == ERRCODE_NONE && ( eLinkType != GfxLinkType::NONE ) && !rGraphic.GetReaderContext() && !bLinkSet )
     {
@@ -2055,7 +1866,6 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, const OUString& r
         nStatus = ERRCODE_GRFILTER_IOERROR;
     if( ERRCODE_NONE == nStatus )
     {
-        if ( pConfig->IsExportInternalFilter( nFormat ) )
         {
             if( aFilterName.equalsIgnoreAsciiCase( EXP_BMP ) )
             {


More information about the Libreoffice-commits mailing list