23#include <com/sun/star/io/XInputStream.hpp>
24#include <com/sun/star/uno/XComponentContext.hpp>
49 OUString aTypeName = aMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_TYPENAME, OUString() );
50 uno::Reference< io::XInputStream > xInStream ( aMediaDesc[MediaDescriptor::PROP_INPUTSTREAM], uno::UNO_QUERY );
51 if ( !xInStream.is() )
59 if ( !pInStrm || pInStrm->
GetError() )
62 bool bIsDetected =
false;
64 if ( aTypeName ==
"writer_Rich_Text_Format" )
69 else if ( aTypeName ==
"writer_MS_WinWord_5" )
74 if (pInStrm->
ReadBytes(nBuffer, nBufSize) < nBufSize)
77 bIsDetected = (nBuffer[0] == 0x9B && nBuffer[1] == 0xA5 && nBuffer[2] == 0x21)
78 || (nBuffer[0] == 0x9C && nBuffer[1] == 0xA5 && nBuffer[2] == 0x21)
79 || (nBuffer[0] == 0xDB && nBuffer[1] == 0xA5 && nBuffer[2] == 0x2D)
80 || (nBuffer[0] == 0xDC && nBuffer[1] == 0xA5 && nBuffer[2] == 0x65);
95 if ( !aStorage->GetError() )
97 bIsDetected = aStorage->IsContained(
"WordDocument" );
98 if ( bIsDetected && aTypeName.startsWith(
"writer_MS_Word_97" ) )
100 bIsDetected = ( aStorage->IsContained(
"0Table") || aStorage->IsContained(
"1Table") );
104 if ( bIsDetected && aTypeName ==
"writer_MS_Word_97_Vorlage" )
120 = aStorage->OpenSotStream(
"WordDocument", StreamMode::STD_READ);
121 xWordDocument->Seek(10);
122 if (xWordDocument->Tell() == 10)
125 xWordDocument->ReadUChar(aBits1);
127 bIsDetected = ((aBits1 & 0x01) == 0x01);
149 return "com.sun.star.comp.writer.FormatDetector";
161 return {
"com.sun.star.frame.ExtendedTypeDetection",
"com.sun.star.text.FormatDetector",
"com.sun.star.text.W4WFormatDetector" };
164extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
166 css::uno::Sequence<css::uno::Any>
const &)
constexpr OUStringLiteral sServiceName
OUString getExtension(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
void setStreamToLoadFrom(const css::uno::Reference< css::io::XInputStream > &xInputStream, bool bIsReadOnly)
void UseInteractionHandler(bool)
sal_uInt64 Seek(sal_uInt64 nPos)
std::size_t ReadBytes(void *pData, std::size_t nSize)
sal_uInt64 remainingSize()
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual OUString SAL_CALL getImplementationName() override
virtual OUString SAL_CALL detect(css::uno::Sequence< css::beans::PropertyValue > &lDescriptor) override
virtual ~SwFilterDetect() override
virtual sal_Bool SAL_CALL supportsService(const OUString &sServiceName) override
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
TOOLS_DLLPUBLIC OString read_uInt8s_ToOString(SvStream &rStrm, std::size_t nUnits)
#define STREAM_SEEK_TO_BEGIN
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_writer_FormatDetector_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)