Kaydet (Commit) 4b7bdef4 authored tarafından Maxim Monastirsky's avatar Maxim Monastirsky

sw: iodetect is not a part of the type detector anymore

and remove now unused IsFileFilter method.

Change-Id: I6b4559fdf6442b6baa869b2949142f8fc8c52f30
Reviewed-on: https://gerrit.libreoffice.org/9223Reviewed-by: 's avatarMaxim Monastirsky <momonasmon@gmail.com>
Tested-by: 's avatarMaxim Monastirsky <momonasmon@gmail.com>
üst dddd9b41
...@@ -65,7 +65,6 @@ $(eval $(call gb_Library_use_libraries,sw,\ ...@@ -65,7 +65,6 @@ $(eval $(call gb_Library_use_libraries,sw,\
svt \ svt \
svx \ svx \
svxcore \ svxcore \
swd \
tk \ tk \
tl \ tl \
ucbhelper \ ucbhelper \
...@@ -479,6 +478,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\ ...@@ -479,6 +478,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
sw/source/filter/ascii/wrtasc \ sw/source/filter/ascii/wrtasc \
sw/source/filter/basflt/docfact \ sw/source/filter/basflt/docfact \
sw/source/filter/basflt/fltini \ sw/source/filter/basflt/fltini \
sw/source/filter/basflt/iodetect \
sw/source/filter/basflt/shellio \ sw/source/filter/basflt/shellio \
sw/source/filter/html/SwAppletImpl \ sw/source/filter/html/SwAppletImpl \
sw/source/filter/html/css1atr \ sw/source/filter/html/css1atr \
......
...@@ -23,19 +23,12 @@ $(eval $(call gb_Library_set_componentfile,swd,sw/util/swd)) ...@@ -23,19 +23,12 @@ $(eval $(call gb_Library_set_componentfile,swd,sw/util/swd))
$(eval $(call gb_Library_set_include,swd,\ $(eval $(call gb_Library_set_include,swd,\
$$(INCLUDE) \ $$(INCLUDE) \
-I$(SRCDIR)/sw/inc \
-I$(SRCDIR)/sw/source/core/inc \
-I$(SRCDIR)/sw/source/filter/inc \
)) ))
$(eval $(call gb_Library_use_external,swd,boost_headers)) $(eval $(call gb_Library_use_external,swd,boost_headers))
$(eval $(call gb_Library_use_sdk_api,swd)) $(eval $(call gb_Library_use_sdk_api,swd))
$(eval $(call gb_Library_add_defs,swd,\
-DSWD_DLLIMPLEMENTATION \
))
$(eval $(call gb_Library_use_libraries,swd,\ $(eval $(call gb_Library_use_libraries,swd,\
comphelper \ comphelper \
cppu \ cppu \
...@@ -43,14 +36,12 @@ $(eval $(call gb_Library_use_libraries,swd,\ ...@@ -43,14 +36,12 @@ $(eval $(call gb_Library_use_libraries,swd,\
sal \ sal \
sfx \ sfx \
sot \ sot \
svt \
tl \ tl \
utl \ utl \
$(gb_UWINAPI) \ $(gb_UWINAPI) \
)) ))
$(eval $(call gb_Library_add_exception_objects,swd,\ $(eval $(call gb_Library_add_exception_objects,swd,\
sw/source/filter/basflt/iodetect \
sw/source/ui/uno/detreg \ sw/source/ui/uno/detreg \
sw/source/ui/uno/swdetect \ sw/source/ui/uno/swdetect \
)) ))
......
...@@ -62,7 +62,6 @@ $(eval $(call gb_Library_use_libraries,swui,\ ...@@ -62,7 +62,6 @@ $(eval $(call gb_Library_use_libraries,swui,\
svx \ svx \
svxcore \ svxcore \
sw \ sw \
swd \
tk \ tk \
tl \ tl \
ucbhelper \ ucbhelper \
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include <sfx2/docfilt.hxx> #include <sfx2/docfilt.hxx>
#include <sfx2/docfile.hxx> #include <sfx2/docfile.hxx>
#include <sfx2/fcontnr.hxx> #include <sfx2/fcontnr.hxx>
#include <swddllapi.h> #include <swdllapi.h>
#define FILTER_RTF "RTF" ///< RTF filter #define FILTER_RTF "RTF" ///< RTF filter
#define sRtfWH "WH_RTF" #define sRtfWH "WH_RTF"
...@@ -76,7 +76,7 @@ enum ReaderWriterEnum { ...@@ -76,7 +76,7 @@ enum ReaderWriterEnum {
MAXFILTER MAXFILTER
}; };
extern SWD_DLLPUBLIC SwIoDetect aFilterDetect[]; extern SwIoDetect aFilterDetect[];
/** The following class is a wrapper for basic i/o functions of Writer 3.0. /** The following class is a wrapper for basic i/o functions of Writer 3.0.
Everything is static. All filter names mentioned are Writer-internal Everything is static. All filter names mentioned are Writer-internal
...@@ -87,33 +87,24 @@ class SwIoSystem ...@@ -87,33 +87,24 @@ class SwIoSystem
{ {
public: public:
/// find for an internal format name the corresponding filter entry /// find for an internal format name the corresponding filter entry
SWD_DLLPUBLIC static const SfxFilter* SW_DLLPUBLIC static const SfxFilter*
GetFilterOfFormat( const OUString& rFormat, GetFilterOfFormat( const OUString& rFormat,
const SfxFilterContainer* pCnt = 0 ); const SfxFilterContainer* pCnt = 0 );
/** Detect for the given file which filter should be used. The filter name /** Detect for the given file which filter should be used. The filter name
is returned. If no filter could be found, the name of the ASCII filter is returned. If no filter could be found, the name of the ASCII filter
is returned! */ is returned! */
SWD_DLLPUBLIC static const SfxFilter* static const SfxFilter* GetFileFilter( const OUString& rFileName, const OUString& rPrefFltName, SfxMedium* pMedium = 0 );
GetFileFilter( const OUString& rFileName,
const OUString& rPrefFltName,
SfxMedium* pMedium = 0 );
/** Detect whether the given file is in the given format.
For now, only our own filters are supported! */
static bool IsFileFilter(SfxMedium& rMedium, const OUString& rFmtName);
static bool IsValidStgFilter( SotStorage& , const SfxFilter& ); static bool IsValidStgFilter( SotStorage& , const SfxFilter& );
static bool IsValidStgFilter( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& rStg, const SfxFilter& rFilter); static bool IsValidStgFilter( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& rStg, const SfxFilter& rFilter);
SWD_DLLPUBLIC static bool static bool IsDetectableText( const sal_Char* pBuf, sal_uLong &rLen,
IsDetectableText( const sal_Char* pBuf, sal_uLong &rLen,
rtl_TextEncoding *pCharSet=0, bool *pSwap=0, LineEnd *pLineEnd=0, bool bEncodedFilter = false ); rtl_TextEncoding *pCharSet=0, bool *pSwap=0, LineEnd *pLineEnd=0, bool bEncodedFilter = false );
static const SfxFilter* GetTextFilter( const sal_Char* pBuf, sal_uLong nLen ); static const SfxFilter* GetTextFilter( const sal_Char* pBuf, sal_uLong nLen );
SWD_DLLPUBLIC static const OUString static const OUString GetSubStorageName( const SfxFilter& rFltr );
GetSubStorageName( const SfxFilter& rFltr );
}; };
#endif #endif
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* 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/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_SW_INC_SWDDLLAPI_H
#define INCLUDED_SW_INC_SWDDLLAPI_H
#include <sal/types.h>
#if defined(SWD_DLLIMPLEMENTATION)
#define SWD_DLLPUBLIC SAL_DLLPUBLIC_EXPORT
#else
#define SWD_DLLPUBLIC SAL_DLLPUBLIC_IMPORT
#endif
#endif // INCLUDED_SW_INC_SWDDLLAPI_H
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -195,77 +195,6 @@ void TerminateBuffer(sal_Char *pBuffer, sal_uLong nBytesRead, sal_uLong nBufferL ...@@ -195,77 +195,6 @@ void TerminateBuffer(sal_Char *pBuffer, sal_uLong nBytesRead, sal_uLong nBufferL
} }
} }
// Check if the file fits the corresponding format
// Currently we only support our own filters
bool SwIoSystem::IsFileFilter(SfxMedium& rMedium, const OUString& rFmtName)
{
bool bRet = false;
SfxFilterContainer aCntSw( OUString(sSWRITER) );
SfxFilterContainer aCntSwWeb( OUString(sSWRITERWEB) );
const SfxFilterContainer& rFltContainer = IsDocShellRegistered() ? aCntSw : aCntSwWeb;
com::sun::star::uno::Reference < com::sun::star::embed::XStorage > xStor;
SotStorageRef xStg;
if (rMedium.IsStorage())
xStor = rMedium.GetStorage();
else
{
SvStream* pStream = rMedium.GetInStream();
if ( pStream && SotStorage::IsStorageFile(pStream) )
xStg = new SotStorage( pStream, false );
}
SfxFilterMatcher aMatcher( rFltContainer.GetName() );
SfxFilterMatcherIter aIter( aMatcher );
const SfxFilter* pFltr = aIter.First();
while ( pFltr )
{
const OUString& rUserData = pFltr->GetUserData();
if (rUserData.equals(rFmtName))
{
if( 'C' == rUserData[0] )
{
if ( xStor.is() )
bRet = IsValidStgFilter( xStor, *pFltr );
else if ( xStg.Is() )
bRet = IsValidStgFilter( *xStg, *pFltr );
}
else if( !xStg.Is() && !xStor.is() )
{
SvStream* pStrm = rMedium.GetInStream();
if( pStrm && !pStrm->GetError() )
{
sal_Char aBuffer[4098];
const sal_uLong nMaxRead = sizeof(aBuffer) - 2;
sal_uLong nBytesRead = pStrm->Read(aBuffer, nMaxRead);
pStrm->Seek(STREAM_SEEK_TO_BEGIN);
TerminateBuffer(aBuffer, nBytesRead, sizeof(aBuffer));
for (sal_uInt16 i = 0; i < MAXFILTER; ++i)
{
if (aFilterDetect[i].IsFilter(rFmtName))
{
OUString sFilter(aFilterDetect[i].IsReader(aBuffer, nBytesRead));
bRet = !sFilter.isEmpty();
break;
}
}
}
}
//The same underlying filter can appear multiple times in the
//filter list, e.g. CWW8 filter twice, once for .doc and once for
//.dot. We just care here if its either, not enforce that it's
//both which would be a bit of an odd requirement
if (bRet)
break;
}
pFltr = aIter.Next();
}
return bRet;
}
// Check the type of the stream (file) by searching for corresponding set of bytes. // Check the type of the stream (file) by searching for corresponding set of bytes.
// If no known type is found, return ASCII for now! // If no known type is found, return ASCII for now!
// Returns the internal FilterName. // Returns the internal FilterName.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment