diff options
Diffstat (limited to 'sw/source')
34 files changed, 880 insertions, 249 deletions
diff --git a/sw/source/core/attr/hints.cxx b/sw/source/core/attr/hints.cxx index a1757429305b..6fce2c4a59f5 100644 --- a/sw/source/core/attr/hints.cxx +++ b/sw/source/core/attr/hints.cxx @@ -181,11 +181,14 @@ SfxPoolItem* SwMsgPoolItem::Clone( SfxItemPool* ) const * hole aus der Default-Attribut Tabelle ueber den Which-Wert * das entsprechende default Attribut. * Ist keines vorhanden, returnt ein 0-Pointer !!! - * inline (hintids.hxx) im PRODUCT. + * Used to be inlined (hintids.hxx) in PRODUCT. ******************************************************************************/ -#ifndef PRODUCT - - +#ifdef PRODUCT +const SfxPoolItem* GetDfltAttr( USHORT nWhich ) +{ + return aAttrTab[ nWhich - POOLATTR_BEGIN ]; +} +#else const SfxPoolItem* GetDfltAttr( USHORT nWhich ) { ASSERT_ID( nWhich < POOLATTR_END && nWhich >= POOLATTR_BEGIN, @@ -195,7 +198,6 @@ const SfxPoolItem* GetDfltAttr( USHORT nWhich ) ASSERT( pHt, "GetDfltFmtAttr(): Dflt == 0" ); return pHt; } - #endif diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx index 1086760db6ec..57d87d6ae4f4 100644 --- a/sw/source/core/docnode/section.cxx +++ b/sw/source/core/docnode/section.cxx @@ -1340,7 +1340,7 @@ void SwIntrnlSectRefLink::DataChanged( const String& rMimeType, break; case FORMAT_RTF: - pRead = ReadRtf; + pRead = SwReaderWriter::GetReader( READER_WRITER_RTF ); break; case FORMAT_FILE: diff --git a/sw/source/core/edit/edglss.cxx b/sw/source/core/edit/edglss.cxx index 259de63d225c..f1d781e4080b 100644 --- a/sw/source/core/edit/edglss.cxx +++ b/sw/source/core/edit/edglss.cxx @@ -315,7 +315,7 @@ BOOL SwEditShell::GetSelectedText( String &rBuf, int nHndlParaBrk ) aStream.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN ); #endif WriterRef xWrt; - SwIoSystem::GetWriter( String::CreateFromAscii( FILTER_TEXT ), String(), xWrt ); + SwReaderWriter::GetWriter( String::CreateFromAscii( FILTER_TEXT ), String(), xWrt ); if( xWrt.Is() ) { // Selektierte Bereiche in ein ASCII Dokument schreiben diff --git a/sw/source/core/inc/pamtyp.hxx b/sw/source/core/inc/pamtyp.hxx index 1bc775a4f396..2bf2b46dd066 100644 --- a/sw/source/core/inc/pamtyp.hxx +++ b/sw/source/core/inc/pamtyp.hxx @@ -59,7 +59,7 @@ const SwTxtAttr* GetBkwrdTxtHint( const SwpHints&, USHORT&, xub_StrLen ); BOOL GoNext(SwNode* pNd, SwIndex * pIdx, USHORT nMode ); BOOL GoPrevious(SwNode* pNd, SwIndex * pIdx, USHORT nMode ); -SwCntntNode* GoNextNds( SwNodeIndex * pIdx, BOOL ); +SW_DLLPUBLIC SwCntntNode* GoNextNds( SwNodeIndex * pIdx, BOOL ); SwCntntNode* GoPreviousNds( SwNodeIndex * pIdx, BOOL ); // --------- Funktionsdefinitionen fuer die SwCrsrShell -------------- diff --git a/sw/source/core/inc/tblrwcl.hxx b/sw/source/core/inc/tblrwcl.hxx index c8f473eb63a6..b9a614455edf 100644 --- a/sw/source/core/inc/tblrwcl.hxx +++ b/sw/source/core/inc/tblrwcl.hxx @@ -77,7 +77,7 @@ void _InsTblBox( SwDoc* pDoc, SwTableNode* pTblNd, SwTableLine* pLine, SwTableBoxFmt* pBoxFrmFmt, SwTableBox* pBox, USHORT nInsPos, USHORT nCnt = 1 ); -void _DeleteBox( SwTable& rTbl, SwTableBox* pBox, SwUndo* pUndo = 0, +SW_DLLPUBLIC void _DeleteBox( SwTable& rTbl, SwTableBox* pBox, SwUndo* pUndo = 0, BOOL bCalcNewSize = TRUE, const BOOL bCorrBorder = TRUE, SwShareBoxFmts* pShareFmts = 0 ); diff --git a/sw/source/core/sw3io/sw3convert.cxx b/sw/source/core/sw3io/sw3convert.cxx index c3c726b07275..5dea22089355 100644 --- a/sw/source/core/sw3io/sw3convert.cxx +++ b/sw/source/core/sw3io/sw3convert.cxx @@ -216,7 +216,7 @@ static OldFormats aOldGetSetExpFmt30[] = { NF_NUMERIC_START, 0 } // Tabellenende }; -void sw3io_ConvertFromOldField( SwDoc& rDoc, USHORT& rWhich, +SW_DLLPUBLIC void sw3io_ConvertFromOldField( SwDoc& rDoc, USHORT& rWhich, USHORT& rSubType, ULONG &rFmt, USHORT nVersion ) { @@ -323,7 +323,7 @@ void sw3io_ConvertFromOldField( SwDoc& rDoc, USHORT& rWhich, } } } -void sw3io_ConvertToOldField( const SwField* pFld, USHORT& rWhich, +SW_DLLPUBLIC void sw3io_ConvertToOldField( const SwField* pFld, USHORT& rWhich, ULONG& rFmt, ULONG nFFVersion ) { const OldFormats *pOldFmt = 0L; diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index c9da7ef96296..e798d6851ee6 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -284,7 +284,7 @@ void SwXTextCursor::getTextFromPam(SwPaM& aCrsr, OUString& rBuffer) #endif WriterRef xWrt; // TODO/MBA: looks like a BaseURL doesn't make sense here - SwIoSystem::GetWriter( C2S(FILTER_TEXT_DLG), String(), xWrt ); + SwReaderWriter::GetWriter( C2S(FILTER_TEXT_DLG), String(), xWrt ); if( xWrt.Is() ) { SwWriter aWriter( aStream, aCrsr ); diff --git a/sw/source/filter/basflt/fltini.cxx b/sw/source/filter/basflt/fltini.cxx index 131fca689dbc..05b1bb4eb97a 100644 --- a/sw/source/filter/basflt/fltini.cxx +++ b/sw/source/filter/basflt/fltini.cxx @@ -53,12 +53,8 @@ #include <pam.hxx> #include <shellio.hxx> #include <errhdl.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif -#ifndef _WDOCSH_HXX #include <wdocsh.hxx> -#endif #include <fltini.hxx> #include <hints.hxx> #include <frmatr.hxx> @@ -70,22 +66,57 @@ #include <frmfmt.hxx> #include <numrule.hxx> #include <ndtxt.hxx> -#ifndef _SWFLTOPT_HXX #include <swfltopt.hxx> -#endif #include <swerror.h> - -#ifndef _IODETECT_CXX -#include <iodetect.cxx> -#endif +#include <osl/module.hxx> using namespace utl; using rtl::OUString; using namespace com::sun::star::uno; -SwRead ReadRtf = 0, ReadAscii = 0, /*ReadSwg = 0, ReadSw3 = 0,*/ +SwRead ReadAscii = 0, /*ReadSwg = 0, ReadSw3 = 0,*/ ReadHTML = 0, ReadXML = 0; +Reader* GetRTFReader(); +Reader* GetWW8Reader(); + +// Note: if editing, please don't forget to modify also the enum +// ReaderWriterEnum and aFilterDetect in shellio.hxx +SwReaderWriterEntry aReaderWriter[] = +{ + SwReaderWriterEntry( &::GetRTFReader, &::GetRTFWriter, TRUE ), + SwReaderWriterEntry( 0, &::GetASCWriter, FALSE ), + SwReaderWriterEntry( &::GetWW8Reader, &::GetWW8Writer, TRUE ), + SwReaderWriterEntry( &::GetWW8Reader, &::GetWW8Writer, TRUE ), + SwReaderWriterEntry( &::GetRTFReader, &::GetRTFWriter, TRUE ), + SwReaderWriterEntry( 0, &::GetHTMLWriter, TRUE ), + SwReaderWriterEntry( 0, 0, TRUE ), + SwReaderWriterEntry( &::GetWW8Reader, 0, TRUE ), + SwReaderWriterEntry( 0, &::GetXMLWriter, TRUE ), + SwReaderWriterEntry( 0, &::GetASCWriter, TRUE ), + SwReaderWriterEntry( 0, &::GetASCWriter, TRUE ) +}; + +Reader* SwReaderWriterEntry::GetReader() +{ + if ( pReader ) + return pReader; + else if ( fnGetReader ) + { + pReader = (*fnGetReader)(); + return pReader; + } + return NULL; +} + +void SwReaderWriterEntry::GetWriter( const String& rNm, const String& rBaseURL, WriterRef& xWrt ) const +{ + if ( fnGetWriter ) + (*fnGetWriter)( rNm, rBaseURL, xWrt ); + else + xWrt = WriterRef(0); +} + /*SwRead SwGetReaderSw3() // SW_DLLPUBLIC { return ReadSw3; @@ -101,89 +132,75 @@ bool IsDocShellRegistered() return 0 != SwDocShell::_GetInterface(); } -inline void _SetFltPtr( USHORT& rPos, SwRead pReader - , const sal_Char* -#if OSL_DEBUG_LEVEL > 1 - pNm -#endif - /* pNm optimiert der Compiler weg, wird nur in der nicht PRODUCT benoetigt! */ - ) +inline void _SetFltPtr( USHORT rPos, SwRead pReader ) { -#if OSL_DEBUG_LEVEL > 1 - ASSERT( !strcmp( aReaderWriter[ rPos ].pName, pNm ), "falscher Filter" ); - (void) pNm; -#endif - aReaderWriter[ rPos++ ].pReader = pReader; + aReaderWriter[ rPos ].pReader = pReader; } void _InitFilter() { - SwRead pWW8Rd = new WW8Reader; - - USHORT nCnt = 0; - _SetFltPtr( nCnt, (ReadRtf = new RtfReader), FILTER_RTF ); - _SetFltPtr( nCnt, (ReadAscii = new AsciiReader), FILTER_BAS ); - _SetFltPtr( nCnt, pWW8Rd, sWW6 ); - _SetFltPtr( nCnt, pWW8Rd, FILTER_WW8 ); - _SetFltPtr( nCnt, ReadRtf, sRtfWH ); - _SetFltPtr( nCnt, (ReadHTML = new HTMLReader), sHTML); - _SetFltPtr( nCnt, new WW1Reader, sWW1 ); - _SetFltPtr( nCnt, pWW8Rd, sWW5 ); - _SetFltPtr( nCnt, (ReadXML = new XMLReader), FILTER_XML ); + _SetFltPtr( READER_WRITER_BAS, (ReadAscii = new AsciiReader) ); + _SetFltPtr( READER_WRITER_HTML, (ReadHTML = new HTMLReader) ); + _SetFltPtr( READER_WRITER_WW1, new WW1Reader ); + _SetFltPtr( READER_WRITER_XML, (ReadXML = new XMLReader) ); #ifdef NEW_WW97_EXPORT - aReaderWriter[ 8-3 ].fnGetWriter = &::GetWW8Writer; - aReaderWriter[ 9-3 ].fnGetWriter = &::GetWW8Writer; + aReaderWriter[ READER_WRITER_WW1 ].fnGetWriter = &::GetWW8Writer; + aReaderWriter[ READER_WRITER_WW5 ].fnGetWriter = &::GetWW8Writer; #endif - _SetFltPtr( nCnt, ReadAscii, FILTER_TEXT_DLG ); - _SetFltPtr( nCnt, ReadAscii, FILTER_TEXT ); - - ASSERT( MAXFILTER == nCnt, "Anzahl Filter ungleich der Definierten" ); + _SetFltPtr( READER_WRITER_TEXT_DLG, ReadAscii ); + _SetFltPtr( READER_WRITER_TEXT, ReadAscii ); } - - - void _FinitFilter() { // die Reader vernichten for( USHORT n = 0; n < MAXFILTER; ++n ) { - SwIoDetect& rIo = aReaderWriter[n]; - if( rIo.bDelReader && rIo.pReader ) - delete rIo.pReader; + SwReaderWriterEntry& rEntry = aReaderWriter[n]; + if( rEntry.bDelReader && rEntry.pReader ) + delete rEntry.pReader, rEntry.pReader = NULL; } } /* */ -void SwIoSystem::GetWriter( const String& rFltName, const String& rBaseURL, WriterRef& xRet ) +namespace SwReaderWriter { + +Reader* GetReader( ReaderWriterEnum eReader ) +{ + return aReaderWriter[eReader].GetReader(); +} + +void GetWriter( const String& rFltName, const String& rBaseURL, WriterRef& xRet ) { for( USHORT n = 0; n < MAXFILTER; ++n ) - if( aReaderWriter[n].IsFilter( rFltName ) ) + if( aFilterDetect[n].IsFilter( rFltName ) ) { aReaderWriter[n].GetWriter( rFltName, rBaseURL, xRet ); break; } } - -SwRead SwIoSystem::GetReader( const String& rFltName ) +SwRead GetReader( const String& rFltName ) { SwRead pRead = 0; for( USHORT n = 0; n < MAXFILTER; ++n ) - if( aReaderWriter[n].IsFilter( rFltName ) ) + if( aFilterDetect[n].IsFilter( rFltName ) ) { pRead = aReaderWriter[n].GetReader(); // fuer einige Reader noch eine Sonderbehandlung: - pRead->SetFltName( rFltName ); + if ( pRead ) + pRead->SetFltName( rFltName ); break; } return pRead; } +} // namespace SwReaderWriter + /* */ /////////////// die Storage Reader/Writer //////////////////////////////// @@ -937,4 +954,57 @@ void SwAsciiOptions::WriteUserData( String& rStr ) rStr += ','; } +extern "C" { static void SAL_CALL thisModule() {} } + +static oslGenericFunction GetMswordLibSymbol( const char *pSymbol ) +{ + static ::osl::Module aModule; + if ( aModule.is() || + aModule.loadRelative( &thisModule, + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SVLIBRARY( "msword" ) ) ) ) ) + { + return aModule.getFunctionSymbol( ::rtl::OUString::createFromAscii( pSymbol ) ); + } + + return NULL; +} + +Reader* GetRTFReader() +{ + FnGetReader pFunction = reinterpret_cast<FnGetReader>( GetMswordLibSymbol( "ImportRTF" ) ); + + if ( pFunction ) + return (*pFunction)(); + + return NULL; +} + +void GetRTFWriter( const String& rFltName, const String& rBaseURL, WriterRef& xRet ) +{ + FnGetWriter pFunction = reinterpret_cast<FnGetWriter>( GetMswordLibSymbol( "ExportRTF" ) ); + + if ( pFunction ) + (*pFunction)( rFltName, rBaseURL, xRet ); + else + xRet = WriterRef(0); +} + +Reader* GetWW8Reader() +{ + FnGetReader pFunction = reinterpret_cast<FnGetReader>( GetMswordLibSymbol( "ImportDOC" ) ); + + if ( pFunction ) + return (*pFunction)(); + + return NULL; +} + +void GetWW8Writer( const String& rFltName, const String& rBaseURL, WriterRef& xRet ) +{ + FnGetWriter pFunction = reinterpret_cast<FnGetWriter>( GetMswordLibSymbol( "ExportDOC" ) ); + if ( pFunction ) + (*pFunction)( rFltName, rBaseURL, xRet ); + else + xRet = WriterRef(0); +} diff --git a/sw/source/filter/basflt/iodetect.cxx b/sw/source/filter/basflt/iodetect.cxx new file mode 100644 index 000000000000..71d5bddd7dc5 --- /dev/null +++ b/sw/source/filter/basflt/iodetect.cxx @@ -0,0 +1,595 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: iodetect.cxx,v $ + * $Revision: 1.31 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sw.hxx" + +#include <iodetect.hxx> + +#include <errhdl.hxx> +#include <osl/endian.h> +#include <sot/storage.hxx> +#include <svtools/parhtml.hxx> +#include <tools/urlobj.hxx> + +bool IsDocShellRegistered(); + +SwIoDetect aFilterDetect[] = +{ + SwIoDetect( FILTER_RTF, STRING_LEN ), + SwIoDetect( FILTER_BAS, STRING_LEN ), + SwIoDetect( sWW6, STRING_LEN ), + SwIoDetect( FILTER_WW8, STRING_LEN ), + SwIoDetect( sRtfWH, STRING_LEN ), + SwIoDetect( sHTML, 4 ), + SwIoDetect( sWW1, STRING_LEN ), + SwIoDetect( sWW5, STRING_LEN ), + SwIoDetect( FILTER_XML, 4 ), + SwIoDetect( FILTER_TEXT_DLG, 8 ), + SwIoDetect( FILTER_TEXT, 4 ) +}; + +const sal_Char* SwIoDetect::IsReader(const sal_Char* pHeader, ULONG nLen_, + const String & /*rFileName*/, const String& /*rUserData*/) const +{ + // Filter erkennung + struct W1_FIB + { + SVBT16 wIdent; // 0x0 int magic number + SVBT16 nFib; // 0x2 FIB version written + SVBT16 nProduct; // 0x4 product version written by + SVBT16 nlocale; // 0x6 language stamp---localized version; + SVBT16 pnNext; // 0x8 + SVBT16 fFlags; + + USHORT nFibGet() { return SVBT16ToShort(nFib); } + USHORT wIdentGet() { return SVBT16ToShort(wIdent); } + USHORT fFlagsGet() { return SVBT16ToShort(fFlags); } + // SVBT16 fComplex :1;// 0004 when 1, file is in complex, fast-saved format. + BOOL fComplexGet() { return static_cast< BOOL >((fFlagsGet() >> 2) & 1); } + }; + + int bRet = FALSE; + rtl::OString aName( pName ); + if ( sHTML == aName ) + bRet = HTMLParser::IsHTMLFormat( pHeader, TRUE, RTL_TEXTENCODING_DONTKNOW ); + else if ( FILTER_RTF == aName ) + bRet = 0 == strncmp( "{\\rtf", pHeader, 5 ); + else if ( sWW5 == aName ) + { + W1_FIB *pW1Header = (W1_FIB*)pHeader; + if (pW1Header->wIdentGet() == 0xA5DC && pW1Header->nFibGet() == 0x65) + bRet = true; /*WW5*/ + else if (pW1Header->wIdentGet() == 0xA5DB && pW1Header->nFibGet() == 0x2D) + bRet = true; /*WW2*/ + } + else if ( sWW1 == aName ) + { + bRet = (( ((W1_FIB*)pHeader)->wIdentGet() == 0xA59C + && ((W1_FIB*)pHeader)->nFibGet() == 0x21) + && ((W1_FIB*)pHeader)->fComplexGet() == 0); + } + else if ( FILTER_TEXT == aName ) + bRet = SwIoSystem::IsDetectableText(pHeader, nLen_); + else if ( FILTER_TEXT_DLG == aName) + bRet = SwIoSystem::IsDetectableText( pHeader, nLen_, 0, 0, 0, true); + return bRet ? pName : 0; +} + +const String SwIoSystem::GetSubStorageName( const SfxFilter& rFltr ) +{ + /* bei den StorageFiltern noch den SubStorageNamen setzen */ + const String& rUserData = rFltr.GetUserData(); + if( rUserData.EqualsAscii(FILTER_XML) || + rUserData.EqualsAscii(FILTER_XMLV) || + rUserData.EqualsAscii(FILTER_XMLVW) ) + return String::CreateFromAscii( + RTL_CONSTASCII_STRINGPARAM( "content.xml" )); + if( rUserData.EqualsAscii(sWW6) || rUserData.EqualsAscii(FILTER_WW8) ) + return String::CreateFromAscii( + RTL_CONSTASCII_STRINGPARAM( "WordDocument" )); + return String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "" )); +} + +const SfxFilter* SwIoSystem::GetFilterOfFormat(const String& rFmtNm, + const SfxFilterContainer* pCnt) +{ + SfxFilterContainer aCntSw( String::CreateFromAscii( sSWRITER ) ); + SfxFilterContainer aCntSwWeb( String::CreateFromAscii( sSWRITERWEB ) ); + const SfxFilterContainer* pFltCnt = pCnt ? pCnt : ( IsDocShellRegistered() ? &aCntSw : &aCntSwWeb ); + + do { + if( pFltCnt ) + { + SfxFilterMatcher aMatcher( pFltCnt->GetName() ); + SfxFilterMatcherIter aIter( &aMatcher ); + const SfxFilter* pFilter = aIter.First(); + while ( pFilter ) + { + if( pFilter->GetUserData() == rFmtNm ) + return pFilter; + pFilter = aIter.Next(); + } + } + if( pCnt || pFltCnt == &aCntSwWeb ) + break; + pFltCnt = &aCntSwWeb; + } while( TRUE ); + return 0; +} + +BOOL SwIoSystem::IsValidStgFilter( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& rStg, const SfxFilter& rFilter) +{ + BOOL bRet = FALSE; + try + { + ULONG nStgFmtId = SotStorage::GetFormatID( rStg ); + bRet = rStg->isStreamElement( ::rtl::OUString::createFromAscii("content.xml") ); + if ( bRet ) + bRet = ( nStgFmtId && ( rFilter.GetFormat() == nStgFmtId ) ); + } + catch ( com::sun::star::uno::Exception& ) + { + } + + return bRet; +} + +BOOL SwIoSystem::IsValidStgFilter(SotStorage& rStg, const SfxFilter& rFilter) +{ + ULONG nStgFmtId = rStg.GetFormat(); + /*#i8409# We cannot trust the clipboard id anymore :-(*/ + if( rFilter.GetUserData().EqualsAscii(FILTER_WW8) || + rFilter.GetUserData().EqualsAscii(sWW6) ) + { + nStgFmtId = 0; + } + + BOOL bRet = SVSTREAM_OK == rStg.GetError() && + ( !nStgFmtId || rFilter.GetFormat() == nStgFmtId ) && + ( rStg.IsContained( SwIoSystem::GetSubStorageName( rFilter )) ); + if( bRet ) + { + /* Bug 53445 - es gibt Excel Docs ohne ClipBoardId! */ + /* Bug 62703 - und auch WinWord Docs ohne ClipBoardId! */ + if( rFilter.GetUserData().EqualsAscii(FILTER_WW8) || + rFilter.GetUserData().EqualsAscii(sWW6) ) + { + bRet = !((rStg.IsContained( String::CreateFromAscii("0Table" )) || + rStg.IsContained( String::CreateFromAscii("1Table" ))) ^ + rFilter.GetUserData().EqualsAscii(FILTER_WW8)); + if (bRet && !rFilter.IsAllowedAsTemplate()) + { + SotStorageStreamRef xRef = + rStg.OpenSotStream(String::CreateFromAscii("WordDocument"), + STREAM_STD_READ | STREAM_NOCREATE ); + xRef->Seek(10); + BYTE nByte; + *xRef >> nByte; + bRet = !(nByte & 1); + } + } + // else if( !rFilter.GetUserData().EqualsAscii(sCExcel) ) + // bRet = rFilter.GetFormat() == nStgFmtId; + } + return bRet; +} + +void TerminateBuffer(sal_Char *pBuffer, ULONG nBytesRead, ULONG nBufferLen) +{ + ASSERT(nBytesRead <= nBufferLen - 2, + "what you read must be less than the max + null termination"); + ASSERT(!(nBufferLen & 0x00000001), "nMaxReadBuf must be an even number"); + if (nBytesRead <= nBufferLen - 2) + { + pBuffer[nBytesRead] = '\0'; + pBuffer[nBytesRead+1] = '\0'; + if (nBytesRead & 0x00000001) + pBuffer[nBytesRead+2] = '\0'; + } +} + +/* Feststellen ob das File in dem entsprechenden Format vorliegt. */ +/* Z.z werden nur unsere eigene Filter unterstuetzt */ +BOOL SwIoSystem::IsFileFilter( SfxMedium& rMedium, const String& rFmtName, + const SfxFilter** ppFilter ) +{ + BOOL bRet = FALSE; + + SfxFilterContainer aCntSw( String::CreateFromAscii( sSWRITER ) ); + SfxFilterContainer aCntSwWeb( String::CreateFromAscii( 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 ) + { + if( pFltr->GetUserData() == rFmtName ) + { + const String& rUserData = pFltr->GetUserData(); + if( 'C' == *rUserData.GetBuffer() ) + { + if ( xStor.is() ) + bRet = IsValidStgFilter( xStor, *pFltr ); + else if ( xStg.Is() ) + bRet = xStg.Is() && IsValidStgFilter( *xStg, *pFltr ); + bRet = bRet && (pFltr->GetUserData() == rFmtName); + } + else if( !xStg.Is() && !xStor.is() ) + { + SvStream* pStrm = rMedium.GetInStream(); + if( pStrm && !pStrm->GetError() ) + { + sal_Char aBuffer[4098]; + const ULONG nMaxRead = sizeof(aBuffer) - 2; + ULONG nBytesRead = pStrm->Read(aBuffer, nMaxRead); + pStrm->Seek(STREAM_SEEK_TO_BEGIN); + TerminateBuffer(aBuffer, nBytesRead, sizeof(aBuffer)); + for (USHORT i = 0; i < MAXFILTER; ++i) + { + if (aFilterDetect[i].IsFilter(rFmtName)) + { + bRet = 0 != aFilterDetect[i].IsReader( aBuffer, nBytesRead, + rMedium.GetPhysicalName(), rUserData ); + break; + } + } + } + } + + if( bRet && ppFilter ) + *ppFilter = pFltr; + } + + pFltr = aIter.Next(); + } + + return bRet; +} + +/* die Methode stellt fest, von welchem Typ der stream (File) ist. */ +/* Es wird versucht, eine dem Filter entsprechende Byte-Folge zu finden. */ +/* Wird kein entsprechender gefunden, wird zur Zeit der ASCII-Reader */ +/* returnt !! Der Returnwert ist der interne Filtername! */ +/* rPrefFltName ist der interne Name des Filters, den der Benutzer im */ +/* Open-Dialog eingestellt hat. */ +const SfxFilter* SwIoSystem::GetFileFilter(const String& rFileName, + const String& rPrefFltName, SfxMedium* pMedium) +{ + SfxFilterContainer aCntSw( String::CreateFromAscii( sSWRITER ) ); + SfxFilterContainer aCntSwWeb( String::CreateFromAscii( sSWRITERWEB ) ); + const SfxFilterContainer* pFCntnr = IsDocShellRegistered() ? &aCntSw : &aCntSwWeb; + + if( !pFCntnr ) + return 0; + + SfxFilterMatcher aMatcher( pFCntnr->GetName() ); + SfxFilterMatcherIter aIter( &aMatcher ); + const SfxFilter* pFilter = aIter.First(); + if ( !pFilter ) + return 0; + + if( pMedium ? ( pMedium->IsStorage() || SotStorage::IsStorageFile( pMedium->GetInStream() ) ) : SotStorage::IsStorageFile( rFileName ) ) + { + // package storage or OLEStorage based format + SotStorageRef xStg; + BOOL bDeleteMedium = FALSE; + if (!pMedium ) + { + INetURLObject aObj; + aObj.SetSmartProtocol( INET_PROT_FILE ); + aObj.SetSmartURL( rFileName ); + pMedium = new SfxMedium( aObj.GetMainURL( INetURLObject::NO_DECODE ), STREAM_STD_READ, FALSE ); + bDeleteMedium = TRUE; + } + + // templates should not get precedence over "normal" filters (#i35508, #i33168) + const SfxFilter* pTemplateFilter = 0; + const SfxFilter* pOldFilter = pFCntnr->GetFilter4FilterName( rPrefFltName ); + BOOL bLookForTemplate = pOldFilter && pOldFilter->IsOwnTemplateFormat(); + if ( pMedium->IsStorage() ) + { + com::sun::star::uno::Reference < com::sun::star::embed::XStorage > xStor = pMedium->GetStorage(); + if ( xStor.is() ) + { + while ( pFilter ) + { + if( 'C' == *pFilter->GetUserData().GetBuffer() && IsValidStgFilter( xStor, *pFilter ) ) + { + if ( pFilter->IsOwnTemplateFormat() && !bLookForTemplate ) + // found template filter; maybe there's a "normal" one also + pTemplateFilter = pFilter; + else + return pFilter; + } + + pFilter = aIter.Next(); + } + + // there's only a template filter that could be found + if ( pTemplateFilter ) + pFilter = pTemplateFilter; + } + } + else + { + SvStream* pStream = pMedium->GetInStream(); + if ( pStream && SotStorage::IsStorageFile(pStream) ) + xStg = new SotStorage( pStream, FALSE ); + + if( xStg.Is() && ( xStg->GetError() == SVSTREAM_OK ) ) + { + while ( pFilter ) + { + if( 'C' == *pFilter->GetUserData().GetBuffer() && IsValidStgFilter( *xStg, *pFilter ) ) + { + if ( pFilter->IsOwnTemplateFormat() && !bLookForTemplate ) + // found template filter; maybe there's a "normal" one also + pTemplateFilter = pFilter; + else + return pFilter; + } + + pFilter = aIter.Next(); + } + + // there's only a template filter that could be found + if ( pTemplateFilter ) + pFilter = pTemplateFilter; + + } + } + + return pFilter; + } + + sal_Char aBuffer[4098]; + const ULONG nMaxRead = sizeof(aBuffer) - 2; + ULONG nBytesRead = 0; + if (pMedium) + { + SvStream* pIStrm = pMedium->GetInStream(); + if( !pIStrm || SVSTREAM_OK != pIStrm->GetError() ) + return 0; + ULONG nCurrPos = pIStrm->Tell(); + nBytesRead = pIStrm->Read(aBuffer, nMaxRead); + pIStrm->Seek( nCurrPos ); + } + /* + else + { + SvFileStream aStrm( rFileName, STREAM_READ ); + + // ohne FileName oder ohne Stream gibts nur den ANSI-Filter + if( !rFileName.Len() || SVSTREAM_OK != aStrm.GetError() ) + return 0; + + nBytesRead = aStrm.Read(aBuffer, nMaxRead); + aStrm.Close(); + }*/ + + TerminateBuffer(aBuffer, nBytesRead, sizeof(aBuffer)); + + + /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ + /* suche nach dem bestimmten Filter, falls kein entsprechender */ + /* gefunden wird, so wird der ASCII-Filter returnt. */ + /* Gibt es Filter ohne einen Identifizierungs-String, so werden diese */ + /* nie erkannt und es wird auch der ASCII-Filter returnt. */ + /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ + { + const SfxFilter* pFilterTmp = 0; + const sal_Char* pNm; + for( USHORT n = 0; n < MAXFILTER; ++n ) + { + String sEmptyUserData; + pNm = aFilterDetect[n].IsReader(aBuffer, nBytesRead, rFileName, sEmptyUserData); + pFilterTmp = pNm ? SwIoSystem::GetFilterOfFormat(String::CreateFromAscii(pNm), pFCntnr) : 0; + if (pNm && pFilterTmp) + { + return pFilterTmp; + } + } + } + + /* Ok, bis jetzt kein Filter gefunden, also befrage mal die */ + /* "WORD 4 WORD" Filter */ + if( rFileName.Len() ) + { + if( pMedium ) + pMedium->CloseInStream(); + + } + return SwIoSystem::GetTextFilter( aBuffer, nBytesRead); +} + +bool SwIoSystem::IsDetectableText(const sal_Char* pBuf, ULONG &rLen, + CharSet *pCharSet, bool *pSwap, LineEnd *pLineEnd, bool bEncodedFilter) +{ + bool bSwap = false; + CharSet eCharSet = RTL_TEXTENCODING_DONTKNOW; + bool bLE = true; + ULONG nHead=0; + /*See if its a known unicode type*/ + if (rLen >= 2) + { + if (rLen > 2 && BYTE(pBuf[0]) == 0xEF && BYTE(pBuf[1]) == 0xBB && + BYTE(pBuf[2]) == 0xBF) + { + eCharSet = RTL_TEXTENCODING_UTF8; + nHead = 3; + } + else if (BYTE(pBuf[0]) == 0xFE && BYTE(pBuf[1]) == 0xFF) + { + eCharSet = RTL_TEXTENCODING_UCS2; + bLE = false; + nHead = 2; + } + else if (BYTE(pBuf[1]) == 0xFE && BYTE(pBuf[0]) == 0xFF) + { + eCharSet = RTL_TEXTENCODING_UCS2; + nHead = 2; + } + pBuf+=nHead; + rLen-=nHead; + } + + bool bCR = false, bLF = false, bNoNormalChar = false, + bIsBareUnicode = false; + + if (eCharSet != RTL_TEXTENCODING_DONTKNOW) + { + String sWork; + sal_Unicode *pNewBuf = sWork.AllocBuffer( static_cast< xub_StrLen >(rLen)); + sal_Size nNewLen; + if (eCharSet != RTL_TEXTENCODING_UCS2) + { + nNewLen = rLen; + rtl_TextToUnicodeConverter hConverter = + rtl_createTextToUnicodeConverter(eCharSet); + rtl_TextToUnicodeContext hContext = + rtl_createTextToUnicodeContext(hConverter); + + sal_Size nCntBytes; + sal_uInt32 nInfo; + nNewLen = rtl_convertTextToUnicode( hConverter, hContext, pBuf, + rLen, pNewBuf, nNewLen, + (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_DEFAULT | + RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_DEFAULT | + RTL_TEXTTOUNICODE_FLAGS_INVALID_DEFAULT), &nInfo, &nCntBytes); + + rtl_destroyTextToUnicodeContext(hConverter, hContext); + rtl_destroyTextToUnicodeConverter(hConverter); + } + else + { + nNewLen = rLen/2; + memcpy(pNewBuf, pBuf, rLen); +#ifdef OSL_LITENDIAN + bool bNativeLE = true; +#else + bool bNativeLE = false; +#endif + if (bLE != bNativeLE) + { + bSwap = true; + sal_Char* pF = (sal_Char*)pNewBuf; + sal_Char* pN = pF+1; + for(xub_StrLen n = 0; n < nNewLen; ++n, pF+=2, pN+=2) + { + sal_Char c = *pF; + *pF = *pN; + *pN = c; + } + } + } + + sWork.ReleaseBufferAccess( static_cast< xub_StrLen >(nNewLen) ); + pNewBuf = sWork.GetBufferAccess(); + + for (ULONG nCnt = 0; nCnt < nNewLen; ++nCnt, ++pNewBuf) + { + switch (*pNewBuf) + { + case 0xA: + bLF = true; + break; + case 0xD: + bCR = true; + break; + default: + break; + } + } + } + else + { + for( ULONG nCnt = 0; nCnt < rLen; ++nCnt, ++pBuf ) + { + switch (*pBuf) + { + case 0x0: + if( nCnt + 1 < rLen && !*(pBuf+1) ) + return 0; + bIsBareUnicode = true; + break; + case 0xA: + bLF = true; + break; + case 0xD: + bCR = true; + break; + case 0xC: + case 0x1A: + case 0x9: + break; + default: + if (0x20 > (BYTE)*pBuf) + bNoNormalChar = true; + break; + } + } + } + + LineEnd eSysLE = GetSystemLineEnd(); + LineEnd eLineEnd; + if (!bCR && !bLF) + eLineEnd = eSysLE; + else + eLineEnd = bCR ? ( bLF ? LINEEND_CRLF : LINEEND_CR ) : LINEEND_LF; + + if (pCharSet) + *pCharSet = eCharSet; + if (pSwap) + *pSwap = bSwap; + if (pLineEnd) + *pLineEnd = eLineEnd; + + return bEncodedFilter || (!bIsBareUnicode && eSysLE == eLineEnd); +} + +const SfxFilter* SwIoSystem::GetTextFilter( const sal_Char* pBuf, ULONG nLen) +{ + bool bAuto = IsDetectableText(pBuf, nLen); + const sal_Char* pNm = bAuto ? FILTER_TEXT : FILTER_TEXT_DLG; + return SwIoSystem::GetFilterOfFormat( String::CreateFromAscii(pNm), 0 ); +} diff --git a/sw/source/filter/basflt/makefile.mk b/sw/source/filter/basflt/makefile.mk index 480cbfe7f3ec..b2f848d33189 100644 --- a/sw/source/filter/basflt/makefile.mk +++ b/sw/source/filter/basflt/makefile.mk @@ -50,10 +50,11 @@ SLOFILES = \ $(SLO)$/docfact.obj \ $(SLO)$/fltini.obj \ $(SLO)$/shellio.obj \ - + $(SLO)$/iodetect.obj EXCEPTIONSFILES = \ - $(SLO)$/fltini.obj + $(SLO)$/fltini.obj \ + $(SLO)$/iodetect.obj # --- Tagets ------------------------------------------------------- diff --git a/sw/source/filter/inc/fltini.hxx b/sw/source/filter/inc/fltini.hxx index 17d886e99f7a..9d1f69e0d45b 100644 --- a/sw/source/filter/inc/fltini.hxx +++ b/sw/source/filter/inc/fltini.hxx @@ -56,16 +56,6 @@ class WW1Reader : public Reader virtual ULONG Read(SwDoc &, const String& rBaseURL, SwPaM &,const String &); }; -class WW8Reader : public StgReader -{ - virtual ULONG Read(SwDoc &, const String& rBaseURL, SwPaM &,const String &); -public: - virtual int GetReaderType(); - - virtual BOOL HasGlossaries() const; - virtual BOOL ReadGlossaries( SwTextBlocks&, BOOL bSaveRelFiles ) const; -}; - class XMLReader : public Reader { virtual ULONG Read(SwDoc &, const String& rBaseURL, SwPaM &,const String &); @@ -91,7 +81,7 @@ void GetWW8Writer( const String&, const String&, WriterRef& ); // verarbeiten jetzt aber relative Werte bezogen auf das LR-Space-Item. // Das hat zur Folge, das bei allen Absaetzen die EInzuege der NumRule vom // Absatz-Einzug abgezogen werden muss. -class SwRelNumRuleSpaces +class SW_DLLPUBLIC SwRelNumRuleSpaces { SwNumRuleTbl* pNumRuleTbl; // Liste aller benannten NumRules BOOL bNewDoc; @@ -115,7 +105,7 @@ public: #define SW_SV_BRUSH_INVALID 5 // Get size of fly (if 'automatic' in WW) and check if not too small -void CalculateFlySize(SfxItemSet& rFlySet, const SwNodeIndex& rAnchor, +SW_DLLPUBLIC void CalculateFlySize(SfxItemSet& rFlySet, const SwNodeIndex& rAnchor, SwTwips nPageWidth); #endif diff --git a/sw/source/filter/inc/fltshell.hxx b/sw/source/filter/inc/fltshell.hxx index e1390f21fa1c..3daf237e860d 100644 --- a/sw/source/filter/inc/fltshell.hxx +++ b/sw/source/filter/inc/fltshell.hxx @@ -82,16 +82,16 @@ public: BOOL bCopied; BOOL bConsumedByField; - SwFltStackEntry(const SwPosition & rStartPos, SfxPoolItem* pHt ); - SwFltStackEntry(const SwFltStackEntry& rEntry); - ~SwFltStackEntry(); + SW_DLLPUBLIC SwFltStackEntry(const SwPosition & rStartPos, SfxPoolItem* pHt ); + SW_DLLPUBLIC SwFltStackEntry(const SwFltStackEntry& rEntry); + SW_DLLPUBLIC ~SwFltStackEntry(); void SetStartPos(const SwPosition & rStartPos); - void SetEndPos( const SwPosition & rEndPos); - BOOL MakeRegion(SwDoc* pDoc, SwPaM& rRegion, BOOL bCheck ); + SW_DLLPUBLIC void SetEndPos( const SwPosition & rEndPos); + SW_DLLPUBLIC BOOL MakeRegion(SwDoc* pDoc, SwPaM& rRegion, BOOL bCheck ); }; -class SwFltControlStack +class SW_DLLPUBLIC SwFltControlStack { typedef std::deque<SwFltStackEntry*> Entries; typedef Entries::iterator myEIter; @@ -144,7 +144,7 @@ public: void DeleteAndDestroy(Entries::size_type nCnt); }; -class SwFltAnchor : public SfxPoolItem +class SW_DLLPUBLIC SwFltAnchor : public SfxPoolItem { SwFrmFmt* pFrmFmt; public: @@ -157,7 +157,7 @@ public: SwFrmFmt* GetFrmFmt() { return pFrmFmt; } }; -class SwFltRedline : public SfxPoolItem +class SW_DLLPUBLIC SwFltRedline : public SfxPoolItem { public: DateTime aStamp; @@ -194,7 +194,7 @@ public: virtual SfxPoolItem* Clone(SfxItemPool* = 0) const; }; -class SwFltBookmark : public SfxPoolItem +class SW_DLLPUBLIC SwFltBookmark : public SfxPoolItem { friend class SwFltShell; // darf aName und aVal uebersetzen long nHandle; @@ -220,7 +220,7 @@ public: long GetHandle() const { return nHandle; } }; -class SwFltTOX : public SfxPoolItem +class SW_DLLPUBLIC SwFltTOX : public SfxPoolItem { SwTOXBase* pTOXBase; USHORT nCols; @@ -608,7 +608,7 @@ public: const String& GetBaseURL() const { return sBaseURL; } }; -void UpdatePageDescs(SwDoc &rDoc, sal_uInt16 nInPageDescOffset); +SW_DLLPUBLIC void UpdatePageDescs(SwDoc &rDoc, sal_uInt16 nInPageDescOffset); #endif diff --git a/sw/source/filter/inc/wrt_fn.hxx b/sw/source/filter/inc/wrt_fn.hxx index 804b8bfbddd2..cafba9a86a90 100644 --- a/sw/source/filter/inc/wrt_fn.hxx +++ b/sw/source/filter/inc/wrt_fn.hxx @@ -42,8 +42,8 @@ class SfxItemSet; typedef Writer& (*FnAttrOut)( Writer&, const SfxPoolItem& ); typedef FnAttrOut SwAttrFnTab[ POOLATTR_END - POOLATTR_BEGIN ]; -Writer& Out( const SwAttrFnTab, const SfxPoolItem&, Writer& ); -Writer& Out_SfxItemSet( const SwAttrFnTab, Writer&, const SfxItemSet&, +SW_DLLPUBLIC Writer& Out( const SwAttrFnTab, const SfxPoolItem&, Writer& ); +SW_DLLPUBLIC Writer& Out_SfxItemSet( const SwAttrFnTab, Writer&, const SfxItemSet&, BOOL bDeep, BOOL bTstForDefault = TRUE ); @@ -61,7 +61,7 @@ RES_NODE_END typedef Writer& (*FnNodeOut)( Writer&, SwCntntNode& ); typedef FnNodeOut SwNodeFnTab[ RES_NODE_END - RES_NODE_BEGIN ]; -Writer& Out( const SwNodeFnTab, SwNode&, Writer & rWrt ); +SW_DLLPUBLIC Writer& Out( const SwNodeFnTab, SwNode&, Writer & rWrt ); diff --git a/sw/source/filter/inc/wrtswtbl.hxx b/sw/source/filter/inc/wrtswtbl.hxx index 4f58ca9cf536..8b851561292e 100644 --- a/sw/source/filter/inc/wrtswtbl.hxx +++ b/sw/source/filter/inc/wrtswtbl.hxx @@ -236,7 +236,7 @@ SV_DECL_PTRARR_SORT_DEL( SwWriteTableCols, SwWriteTableColPtr, 5, 5 ) //----------------------------------------------------------------------- -class SwWriteTable +class SW_DLLPUBLIC SwWriteTable { protected: SwWriteTableCols aCols; // alle Spalten diff --git a/sw/source/filter/makefile.mk b/sw/source/filter/makefile.mk index 0bde189fe6e7..0f8e016588cd 100644 --- a/sw/source/filter/makefile.mk +++ b/sw/source/filter/makefile.mk @@ -51,10 +51,8 @@ SUBLIBS= \ $(SLB)$/ascii.lib \ $(SLB)$/basflt.lib \ $(SLB)$/html.lib \ - $(SLB)$/rtf.lib \ $(SLB)$/writer.lib \ $(SLB)$/ww1.lib \ - $(SLB)$/ww8.lib \ $(SLB)$/xml.lib # ----------------------------------------------------------- diff --git a/sw/source/filter/rtf/makefile.mk b/sw/source/filter/rtf/makefile.mk index 20ce4fe38ad5..8c06c4bec352 100644 --- a/sw/source/filter/rtf/makefile.mk +++ b/sw/source/filter/rtf/makefile.mk @@ -38,6 +38,7 @@ TARGET=rtf .INCLUDE : $(PRJ)$/inc$/swpre.mk .INCLUDE : settings.mk +MAKING_LIBMSWORD=TRUE .INCLUDE : $(PRJ)$/inc$/sw.mk .IF "$(mydebug)" != "" diff --git a/sw/source/filter/rtf/swparrtf.cxx b/sw/source/filter/rtf/swparrtf.cxx index d2a83b6e8664..8d2b6853c85a 100644 --- a/sw/source/filter/rtf/swparrtf.cxx +++ b/sw/source/filter/rtf/swparrtf.cxx @@ -140,6 +140,11 @@ inline const SvxLRSpaceItem& GetLRSpace(const SfxItemSet& rSet,BOOL bInP=TRUE) /* */ +extern "C" SAL_DLLPUBLIC_EXPORT Reader* SAL_CALL ImportRTF() +{ + return new RtfReader(); +} + // Aufruf fuer die allg. Reader-Schnittstelle ULONG RtfReader::Read( SwDoc &rDoc, const String& rBaseURL, SwPaM &rPam, const String &) { diff --git a/sw/source/filter/rtf/swparrtf.hxx b/sw/source/filter/rtf/swparrtf.hxx index 96cb38ae9195..0829bc56dd32 100644 --- a/sw/source/filter/rtf/swparrtf.hxx +++ b/sw/source/filter/rtf/swparrtf.hxx @@ -81,6 +81,11 @@ class SwNodeNum; class SwTxtNode; struct SvxRTFPictureType; +class RtfReader: public Reader +{ + virtual ULONG Read( SwDoc &, const String& rBaseURL, SwPaM &,const String &); +}; + class SwNodeIdx : public SvxNodeIdx { SwNodeIndex aIdx; diff --git a/sw/source/filter/rtf/wrtrtf.cxx b/sw/source/filter/rtf/wrtrtf.cxx index fb6d40acb71f..90fdd48e5fe0 100644 --- a/sw/source/filter/rtf/wrtrtf.cxx +++ b/sw/source/filter/rtf/wrtrtf.cxx @@ -1744,7 +1744,7 @@ RTFSaveData::~RTFSaveData() rWrt.bOutSection = bOldOutSection; } -void GetRTFWriter( const String& rFltName, const String& rBaseURL, WriterRef& xRet ) +extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL ExportRTF( const String& rFltName, const String& rBaseURL, WriterRef& xRet ) { xRet = new SwRTFWriter( rFltName, rBaseURL ); } diff --git a/sw/source/filter/ww1/fltshell.cxx b/sw/source/filter/ww1/fltshell.cxx index 56ed6052903a..754eb862a343 100644 --- a/sw/source/filter/ww1/fltshell.cxx +++ b/sw/source/filter/ww1/fltshell.cxx @@ -638,6 +638,92 @@ const SfxPoolItem* SwFltControlStack::GetFmtAttr(const SwPosition& rPos, USHORT return &pNd->GetAttr(nWhich); } +void SwFltControlStack::Delete(const SwPaM &rPam) +{ + const SwPosition *pStt = rPam.Start(), *pEnd = rPam.End(); + + if( !rPam.HasMark() || *pStt >= *pEnd ) + return; + + SwNodeIndex aStartNode(pStt->nNode, -1); + USHORT nStartIdx = pStt->nContent.GetIndex(); + SwNodeIndex aEndNode(pEnd->nNode, -1); + USHORT nEndIdx = pEnd->nContent.GetIndex(); + + //We don't support deleting content that is over one node, or removing a node. + ASSERT(aEndNode == aStartNode, "nodes must be the same, or this method extended"); + if (aEndNode != aStartNode) + return; + + for (USHORT nSize = static_cast< USHORT >(Count()); nSize > 0;) + { + SwFltStackEntry* pEntry = (*this)[--nSize]; + + bool bEntryStartAfterSelStart = + (pEntry->nMkNode == aStartNode && pEntry->nMkCntnt >= nStartIdx); + + bool bEntryStartBeforeSelEnd = + (pEntry->nMkNode == aEndNode && pEntry->nMkCntnt <= nEndIdx); + + bool bEntryEndAfterSelStart = false; + bool bEntryEndBeforeSelEnd = false; + if (!pEntry->bLocked) + { + bEntryEndAfterSelStart = + (pEntry->nPtNode == aStartNode && pEntry->nPtCntnt >= nStartIdx); + + bEntryEndBeforeSelEnd = + (pEntry->nPtNode == aEndNode && pEntry->nPtCntnt <= nEndIdx); + } + + bool bTotallyContained = false; + if ( + bEntryStartAfterSelStart && bEntryStartBeforeSelEnd && + bEntryEndAfterSelStart && bEntryEndBeforeSelEnd + ) + { + bTotallyContained = true; + } + + if (bTotallyContained) + { + //after start, before end, delete + DeleteAndDestroy(nSize); + continue; + } + + xub_StrLen nCntntDiff = nEndIdx - nStartIdx; + + //to be adjusted + if (bEntryStartAfterSelStart) + { + if (bEntryStartBeforeSelEnd) + { + //move start to new start + pEntry->nMkNode = aStartNode; + pEntry->nMkCntnt = nStartIdx; + } + else + pEntry->nMkCntnt = pEntry->nMkCntnt - nCntntDiff; + } + + if (bEntryEndAfterSelStart) + { + if (bEntryEndBeforeSelEnd) + { + pEntry->nPtNode = aStartNode; + pEntry->nPtCntnt = nStartIdx; + } + else + pEntry->nPtCntnt = pEntry->nPtCntnt - nCntntDiff; + } + + //That's what locked is, end equal to start, and nPtCntnt is invalid + if (pEntry->bLocked) + pEntry->nPtNode = pEntry->nMkNode; + } +} + //------ hier stehen die Methoden von SwFltAnchor ----------- SwFltAnchor::SwFltAnchor(SwFrmFmt* pFmt) : SfxPoolItem(RES_FLTR_ANCHOR), pFrmFmt(pFmt) diff --git a/sw/source/filter/ww8/makefile.mk b/sw/source/filter/ww8/makefile.mk index 7f59944c1454..6697ceaec4b1 100644 --- a/sw/source/filter/ww8/makefile.mk +++ b/sw/source/filter/ww8/makefile.mk @@ -38,6 +38,7 @@ TARGET=ww8 .INCLUDE : $(PRJ)$/inc$/swpre.mk .INCLUDE : settings.mk +MAKING_LIBMSWORD=TRUE .INCLUDE : $(PRJ)$/inc$/sw.mk .IF "$(mydebug)" != "" diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index 96ec05af396c..b32d26fcfe9d 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -38,11 +38,7 @@ #include <com/sun/star/embed/XStorage.hpp> #include <unotools/ucbstreamhelper.hxx> - -#ifndef __SGI_STL_ALGORITHM #include <algorithm> -#endif - #include <hintids.hxx> #include <string.h> // memcpy() @@ -88,9 +84,7 @@ #include <fltini.hxx> #include <swmodule.hxx> #include <section.hxx> -#ifndef _SWFLTOPT_HXX #include <swfltopt.hxx> -#endif #include <fmtinfmt.hxx> #include <txtinet.hxx> #include <fmturl.hxx> @@ -99,18 +93,14 @@ #include <svtools/imapobj.hxx> #include <tools/urlobj.hxx> #include <mdiexp.hxx> // Progress -#ifndef _STATSTR_HRC #include <statstr.hrc> // ResId fuer Statusleiste -#endif #include <fmtline.hxx> #include <fmtfsize.hxx> #include <comphelper/extract.hxx> #include "writerhelper.hxx" #include "writerwordglue.hxx" -#ifndef IDOCUMENTBOOKMARKACCESS_HXX_INCLUDED #include <IDocumentBookmarkAccess.hxx> -#endif #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> #include <com/sun/star/document/XDocumentProperties.hpp> @@ -3044,7 +3034,7 @@ SwWW8Writer::~SwWW8Writer() delete pOleMap; } -void GetWW8Writer( const String& rFltName, const String& rBaseURL, WriterRef& xRet ) +extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL ExportDOC( const String& rFltName, const String& rBaseURL, WriterRef& xRet ) { xRet = new SwWW8Writer( rFltName, rBaseURL ); } diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 62437a16aa6a..23c7b6133f81 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -49,13 +49,9 @@ #include <svtools/docpasswdrequest.hxx> #include <hintids.hxx> -#ifndef _SVX_TSTPITEM_HXX //autogen #include <svx/tstpitem.hxx> -#endif #include <svx/cscoitem.hxx> -#ifndef _SVX_SVDOBJ_HXX #include <svx/svdobj.hxx> -#endif #include <svx/svdpage.hxx> #include <svx/paperinf.hxx> #include <svx/lrspitem.hxx> // SvxLRSpaceItem @@ -98,15 +94,11 @@ #include <section.hxx> #include <docsh.hxx> #include <docufld.hxx> -#ifndef _SWFLTOPT_HXX #include <swfltopt.hxx> -#endif #include <viewsh.hxx> #include <shellres.hxx> #include <mdiexp.hxx> // Progress -#ifndef _STATSTR_HRC #include <statstr.hrc> // ResId fuer Statusleiste -#endif #include <swerror.h> // ERR_WW8_... #include <swunodef.hxx> #include <unodraw.hxx> @@ -1060,92 +1052,6 @@ const SfxPoolItem* SwWW8FltControlStack::GetStackAttr(const SwPosition& rPos, return 0; } -void SwFltControlStack::Delete(const SwPaM &rPam) -{ - const SwPosition *pStt = rPam.Start(), *pEnd = rPam.End(); - - if( !rPam.HasMark() || *pStt >= *pEnd ) - return; - - SwNodeIndex aStartNode(pStt->nNode, -1); - USHORT nStartIdx = pStt->nContent.GetIndex(); - SwNodeIndex aEndNode(pEnd->nNode, -1); - USHORT nEndIdx = pEnd->nContent.GetIndex(); - - //We don't support deleting content that is over one node, or removing a node. - ASSERT(aEndNode == aStartNode, "nodes must be the same, or this method extended"); - if (aEndNode != aStartNode) - return; - - for (USHORT nSize = static_cast< USHORT >(Count()); nSize > 0;) - { - SwFltStackEntry* pEntry = (*this)[--nSize]; - - bool bEntryStartAfterSelStart = - (pEntry->nMkNode == aStartNode && pEntry->nMkCntnt >= nStartIdx); - - bool bEntryStartBeforeSelEnd = - (pEntry->nMkNode == aEndNode && pEntry->nMkCntnt <= nEndIdx); - - bool bEntryEndAfterSelStart = false; - bool bEntryEndBeforeSelEnd = false; - if (!pEntry->bLocked) - { - bEntryEndAfterSelStart = - (pEntry->nPtNode == aStartNode && pEntry->nPtCntnt >= nStartIdx); - - bEntryEndBeforeSelEnd = - (pEntry->nPtNode == aEndNode && pEntry->nPtCntnt <= nEndIdx); - } - - bool bTotallyContained = false; - if ( - bEntryStartAfterSelStart && bEntryStartBeforeSelEnd && - bEntryEndAfterSelStart && bEntryEndBeforeSelEnd - ) - { - bTotallyContained = true; - } - - if (bTotallyContained) - { - //after start, before end, delete - DeleteAndDestroy(nSize); - continue; - } - - xub_StrLen nCntntDiff = nEndIdx - nStartIdx; - - //to be adjusted - if (bEntryStartAfterSelStart) - { - if (bEntryStartBeforeSelEnd) - { - //move start to new start - pEntry->nMkNode = aStartNode; - pEntry->nMkCntnt = nStartIdx; - } - else - pEntry->nMkCntnt = pEntry->nMkCntnt - nCntntDiff; - } - - if (bEntryEndAfterSelStart) - { - if (bEntryEndBeforeSelEnd) - { - pEntry->nPtNode = aStartNode; - pEntry->nPtCntnt = nStartIdx; - } - else - pEntry->nPtCntnt = pEntry->nPtCntnt - nCntntDiff; - } - - //That's what locked is, end equal to start, and nPtCntnt is invalid - if (pEntry->bLocked) - pEntry->nPtNode = pEntry->nMkNode; - } -} - bool SwWW8FltRefStack::IsFtnEdnBkmField(const SwFmtFld& rFmtFld, USHORT& rBkmNo) { const SwField* pFld = rFmtFld.GetFld(); @@ -4761,6 +4667,11 @@ ULONG SwWW8ImplReader::LoadDoc( SwPaM& rPaM,WW8Glossary *pGloss) return nErrRet; } +extern "C" SAL_DLLPUBLIC_EXPORT Reader* SAL_CALL ImportDOC() +{ + return new WW8Reader(); +} + ULONG WW8Reader::Read(SwDoc &rDoc, const String& rBaseURL, SwPaM &rPam, const String & /* FileName */) { USHORT nOldBuffSize = 32768; diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx index d2bb67b78f1d..69113966b5b6 100644 --- a/sw/source/filter/ww8/ww8par.hxx +++ b/sw/source/filter/ww8/ww8par.hxx @@ -156,6 +156,16 @@ SV_DECL_PTRARR_DEL(WW8LFOInfos,WW8LFOInfo_Ptr,16,16) // SV_DECL_PTRARR_SORT_DEL(WW8AuthorInfos, WW8AuthorInfo_Ptr,16,16) SV_DECL_PTRARR_SORT_DEL(WW8OleMaps, WW8OleMap_Ptr,16,16) +class WW8Reader : public StgReader +{ + virtual ULONG Read(SwDoc &, const String& rBaseURL, SwPaM &,const String &); +public: + virtual int GetReaderType(); + + virtual BOOL HasGlossaries() const; + virtual BOOL ReadGlossaries( SwTextBlocks&, BOOL bSaveRelFiles ) const; +}; + struct WW8OleMap { sal_uInt32 mnWWid; diff --git a/sw/source/ui/app/docsh.cxx b/sw/source/ui/app/docsh.cxx index 659ef01562d1..498c10133954 100644 --- a/sw/source/ui/app/docsh.cxx +++ b/sw/source/ui/app/docsh.cxx @@ -206,7 +206,7 @@ Reader* SwDocShell::StartConvertFrom(SfxMedium& rMedium, SwReader** ppRdr, return 0; } String aFileName( rMedium.GetName() ); - SwRead pRead = SwIoSystem::GetReader( pFlt->GetUserData() ); + SwRead pRead = SwReaderWriter::GetReader( pFlt->GetUserData() ); if( !pRead ) return 0; @@ -602,7 +602,7 @@ BOOL SwDocShell::ConvertTo( SfxMedium& rMedium ) return FALSE; WriterRef xWriter; - SwIoSystem::GetWriter( pFlt->GetUserData(), rMedium.GetBaseURL( true ), xWriter ); + SwReaderWriter::GetWriter( pFlt->GetUserData(), rMedium.GetBaseURL( true ), xWriter ); if( !xWriter.Is() ) { // Der Filter ist nicht vorhanden InfoBox( 0, diff --git a/sw/source/ui/app/mainwn.cxx b/sw/source/ui/app/mainwn.cxx index dafe7bab08fd..815269e82044 100644 --- a/sw/source/ui/app/mainwn.cxx +++ b/sw/source/ui/app/mainwn.cxx @@ -33,7 +33,7 @@ - +#include <mdiexp.hxx> #include <tools/shl.hxx> #include <tools/string.hxx> #ifndef _SVARRAY_HXX diff --git a/sw/source/ui/dbui/mmlayoutpage.cxx b/sw/source/ui/dbui/mmlayoutpage.cxx index b831fc410396..44c2aeeb6220 100644 --- a/sw/source/ui/dbui/mmlayoutpage.cxx +++ b/sw/source/ui/dbui/mmlayoutpage.cxx @@ -72,12 +72,10 @@ #include <osl/file.hxx> #include <unoprnms.hxx> - #include <mmlayoutpage.hrc> #include <dbui.hrc> #include <unomid.h> - using namespace osl; using namespace svt; using namespace ::com::sun::star; @@ -132,7 +130,7 @@ SwMailMergeLayoutPage::SwMailMergeLayoutPage( SwMailMergeWizard* _pParent) : const SfxFilter *pSfxFlt = SwIoSystem::GetFilterOfFormat( - String::CreateFromAscii( GetFILTER_XML() ), + String::CreateFromAscii( FILTER_XML ), SwDocShell::Factory().GetFilterContainer() ); //save the current document into a temporary file { diff --git a/sw/source/ui/dbui/mmoutputpage.cxx b/sw/source/ui/dbui/mmoutputpage.cxx index 803ef93b9cdc..4a5884a9daeb 100644 --- a/sw/source/ui/dbui/mmoutputpage.cxx +++ b/sw/source/ui/dbui/mmoutputpage.cxx @@ -778,7 +778,7 @@ IMPL_LINK(SwMailMergeOutputPage, SaveOutputHdl_Impl, PushButton*, pButton) INetURLObject(), utl::TempFile::CreateTempName(), URIHelper::GetMaybeFileHdl()); const SfxFilter *pSfxFlt = SwIoSystem::GetFilterOfFormat( - String::CreateFromAscii( GetFILTER_XML() ), + String::CreateFromAscii( FILTER_XML ), SwDocShell::Factory().GetFilterContainer() ); uno::Sequence< beans::PropertyValue > aValues(1); @@ -1093,7 +1093,7 @@ IMPL_LINK(SwMailMergeOutputPage, SendDocumentsHdl_Impl, PushButton*, pButton) SfxFilterMatcher aMatcher( pFilterContainer->GetName() ); SfxFilterMatcherIter aIter( &aMatcher ); const SfxFilter* pFilter = aIter.First(); - String sFilterUserData( String::CreateFromAscii(GetFILTER_WW8())); + String sFilterUserData( String::CreateFromAscii( FILTER_WW8 )); while ( pFilter ) { if( pFilter->GetUserData() == sFilterUserData && pFilter->CanExport() ) @@ -1180,7 +1180,7 @@ IMPL_LINK(SwMailMergeOutputPage, SendDocumentsHdl_Impl, PushButton*, pButton) INetURLObject(), utl::TempFile::CreateTempName(), URIHelper::GetMaybeFileHdl()); const SfxFilter *pTargetSfxFlt = SwIoSystem::GetFilterOfFormat( - String::CreateFromAscii( GetFILTER_XML() ), + String::CreateFromAscii( FILTER_XML ), SwDocShell::Factory().GetFilterContainer() ); uno::Sequence< beans::PropertyValue > aValues(1); diff --git a/sw/source/ui/dochdl/gloshdl.cxx b/sw/source/ui/dochdl/gloshdl.cxx index a8ee568b7520..c98b76476c10 100644 --- a/sw/source/ui/dochdl/gloshdl.cxx +++ b/sw/source/ui/dochdl/gloshdl.cxx @@ -920,7 +920,7 @@ BOOL SwGlossaryHdl::ImportGlossaries( const String& rName ) { SwTextBlocks *pGlossary; pMed->SetFilter( pFilter ); - Reader* pR = SwIoSystem::GetReader( pFilter->GetUserData() ); + Reader* pR = SwReaderWriter::GetReader( pFilter->GetUserData() ); if( pR && 0 != ( pGlossary = pCurGrp ? pCurGrp : rStatGlossaries.GetGroupDoc(aCurGrp)) ) { diff --git a/sw/source/ui/dochdl/swdtflvr.cxx b/sw/source/ui/dochdl/swdtflvr.cxx index 301c5722a73c..d575b1bf6917 100644 --- a/sw/source/ui/dochdl/swdtflvr.cxx +++ b/sw/source/ui/dochdl/swdtflvr.cxx @@ -1704,7 +1704,7 @@ int SwTransferable::_PasteFileContent( TransferableDataHelper& rData, { pStream = &xStrm; if( SOT_FORMAT_RTF == nFmt ) - pRead = ReadRtf; + pRead = SwReaderWriter::GetReader( READER_WRITER_RTF ); else if( !pRead ) { pRead = ReadHTML; diff --git a/sw/source/ui/misc/glossary.cxx b/sw/source/ui/misc/glossary.cxx index 3d40ce80c918..3399ecb4e752 100644 --- a/sw/source/ui/misc/glossary.cxx +++ b/sw/source/ui/misc/glossary.cxx @@ -680,7 +680,7 @@ IMPL_LINK( SwGlossaryDlg, MenuHdl, Menu *, pMn ) SvtPathOptions aPathOpt; xFP->setDisplayDirectory(aPathOpt.GetWorkPath() ); - String sWW8( C2S(GetFILTER_WW8()) ); + String sWW8( C2S( FILTER_WW8 ) ); uno::Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY); SfxFilterMatcher aMatcher( String::CreateFromAscii(SwDocShell::Factory().GetShortName()) ); diff --git a/sw/source/ui/ribbar/makefile.mk b/sw/source/ui/ribbar/makefile.mk index 9c2f4bb79763..fa0b6a9488df 100644 --- a/sw/source/ui/ribbar/makefile.mk +++ b/sw/source/ui/ribbar/makefile.mk @@ -52,7 +52,6 @@ SRC1FILES = \ SLOFILES = \ $(SLO)$/inputwin.obj \ $(SLO)$/tbxanchr.obj \ - $(SLO)$/tbxmgr.obj \ $(SLO)$/conrect.obj \ $(SLO)$/conform.obj \ $(SLO)$/conpoly.obj \ diff --git a/sw/source/ui/uiview/srcview.cxx b/sw/source/ui/uiview/srcview.cxx index ea42b91fd9b9..fe585e068aa4 100644 --- a/sw/source/ui/uiview/srcview.cxx +++ b/sw/source/ui/uiview/srcview.cxx @@ -71,43 +71,21 @@ #include <sfx2/sfxhtml.hxx> #include <swtypes.hxx> #include <swmodule.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif -#ifndef _WDOCSH_HXX #include <wdocsh.hxx> -#endif -#ifndef _SRCVIEW_HXX #include <srcview.hxx> -#endif #include <viewfunc.hxx> #include <doc.hxx> -#ifndef _ITEMDEF_HXX #include <itemdef.hxx> -#endif #include <shellio.hxx> -#ifndef _CMDID_H #include <cmdid.h> // FN_ ... -#endif -#ifndef _HELPID_H #include <helpid.h> -#endif -#ifndef _GLOBALS_HRC #include <globals.hrc> -#endif -#ifndef _SHELLS_HRC #include <shells.hrc> -#endif -#ifndef _POPUP_HRC #include <popup.hrc> -#endif -#ifndef _WEB_HRC #include <web.hrc> -#endif -#ifndef _VIEW_HRC #include <view.hrc> -#endif #include <com/sun/star/ui/dialogs/XFilePicker.hpp> #include <com/sun/star/ui/dialogs/XFilterManager.hpp> #include <sfx2/filedlghelper.hxx> @@ -130,8 +108,9 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::ui::dialogs; using namespace ::com::sun::star::i18n; using namespace ::com::sun::star::lang; -using ::rtl::OUString; using namespace ::sfx2; +using ::rtl::OUString; +using ::com::sun::star::util::SearchOptions; #define SWSRCVIEWFLAGS ( SFX_VIEW_MAXIMIZE_FIRST| \ diff --git a/sw/source/ui/uno/swdet2.cxx b/sw/source/ui/uno/swdet2.cxx index ed7f3d5d6298..aedd6e0f6c68 100644 --- a/sw/source/ui/uno/swdet2.cxx +++ b/sw/source/ui/uno/swdet2.cxx @@ -38,17 +38,12 @@ #include <sfx2/docfile.hxx> #include <sfx2/app.hxx> #include <svtools/sfxecode.hxx> -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif #include <svtools/parhtml.hxx> #include <sot/clsids.hxx> -#include <shellio.hxx> - -#undef _DLL_ +#include <iodetect.hxx> #include <swdetect.hxx> -#include "iodetect.cxx" #include <app.hrc> #include <web.hrc> @@ -58,16 +53,11 @@ #include <unomid.h> - -USHORT AutoDetec( const String& FileName, USHORT & rVersion ); - bool IsDocShellRegistered() { return SvtModuleOptions().IsWriter(); } -extern const char __FAR_DATA sHTML[]; - //------------------------------------------------------------------------- ULONG SwFilterDetect::DetectFilter( SfxMedium& rMedium, const SfxFilter** ppFilter ) |