diff options
author | Michael Brauer <mib@openoffice.org> | 2002-06-24 11:24:50 +0000 |
---|---|---|
committer | Michael Brauer <mib@openoffice.org> | 2002-06-24 11:24:50 +0000 |
commit | 7b9871a3d44c287a4dc88fc6040592d599458b21 (patch) | |
tree | 2d9bd695e823ac8343ab9db3bc5c0f79bb37932b | |
parent | e2365c03d3a85c8dd9cf6e72463c2001afb48f6d (diff) |
#99667#: Removed historic, non working flat 5.2 XML filter
-rw-r--r-- | sw/source/filter/xml/swxml.cxx | 174 | ||||
-rw-r--r-- | sw/source/filter/xml/wrtxml.cxx | 182 | ||||
-rw-r--r-- | sw/source/filter/xml/wrtxml.hxx | 12 |
3 files changed, 129 insertions, 239 deletions
diff --git a/sw/source/filter/xml/swxml.cxx b/sw/source/filter/xml/swxml.cxx index 03efc280b2c7..993a09a2c9a3 100644 --- a/sw/source/filter/xml/swxml.cxx +++ b/sw/source/filter/xml/swxml.cxx @@ -2,9 +2,9 @@ * * $RCSfile: swxml.cxx,v $ * - * $Revision: 1.44 $ + * $Revision: 1.45 $ * - * last change: $Author: mtg $ $Date: 2002-01-29 15:42:20 $ + * last change: $Author: mib $ $Date: 2002-06-24 12:24:50 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -171,7 +171,7 @@ XMLReader::XMLReader() int XMLReader::GetReaderType() { - return SW_STORAGE_READER | SW_STREAM_READER; + return SW_STORAGE_READER; } /// read a component (file + filter version) @@ -424,65 +424,22 @@ sal_uInt32 XMLReader::Read( SwDoc &rDoc, SwPaM &rPaM, const String & rName ) pStorage = pMedium->GetStorage(); else pStorage = pStg; + + ASSERT( pStorage, "XML Reader can only read from storage" ); if( !pStorage ) - { - if( pMedium ) - { - // if there is a medium and if this medium has a load environment, - // we get an active data source from the medium. - pMedium->GetInStream()->Seek( 0 ); - xSource = pMedium->GetDataSource(); - ASSERT( xSource.is(), "XMLReader:: got no data source from medium" ); - if( !xSource.is() ) - return ERR_SWG_READ_ERROR; - - // get a pipe for connecting the data source to the parser - xPipe = xServiceFactory->createInstance( - OUString::createFromAscii("com.sun.star.io.Pipe") ); - ASSERT( xPipe.is(), - "XMLReader::Read: com.sun.star.io.Pipe service missing" ); - if( !xPipe.is() ) - return ERR_SWG_READ_ERROR; - - // connect pipe's output stream to the data source - Reference< io::XOutputStream > xPipeOutput( xPipe, UNO_QUERY ); - xSource->setOutputStream( xPipeOutput ); - - xInputStream = Reference< io::XInputStream >( xPipe, UNO_QUERY ); - } - else - { - pStrm->SetBufferSize( 16*1024 ); - xInputStream = new utl::OInputStreamWrapper( *pStrm ); - } - } + return ERR_SWG_READ_ERROR; - if( pStorage ) - { - pGraphicHelper = SvXMLGraphicHelper::Create( *pStorage, - GRAPHICHELPER_MODE_READ, - sal_False ); - } - else - { - pGraphicHelper = SvXMLGraphicHelper::Create( GRAPHICHELPER_MODE_READ ); - } + pGraphicHelper = SvXMLGraphicHelper::Create( *pStorage, + GRAPHICHELPER_MODE_READ, + sal_False ); xGraphicResolver = pGraphicHelper; SvPersist *pPersist = rDoc.GetPersist(); if( pPersist ) { - if( pStorage ) - pObjectHelper = SvXMLEmbeddedObjectHelper::Create( + pObjectHelper = SvXMLEmbeddedObjectHelper::Create( *pStorage, *pPersist, EMBEDDEDOBJECTHELPER_MODE_READ, sal_False ); -#if SUPD > 632 - else - pObjectHelper = SvXMLEmbeddedObjectHelper::Create( - *pPersist, - EMBEDDEDOBJECTHELPER_MODE_READ ); -#endif - xObjectResolver = pObjectHelper; } @@ -617,83 +574,60 @@ sal_uInt32 XMLReader::Read( SwDoc &rDoc, SwPaM &rPaM, const String & rName ) // force redline mode to "none" rDoc.SetRedlineMode_intern( REDLINE_NONE ); - - if ( NULL != pStorage ) + sal_uInt32 nWarn = 0; + sal_uInt32 nWarn2 = 0; + // read storage streams + if( !(IsOrganizerMode() || IsBlockMode() || aOpt.IsFmtsOnly() || + bInsertMode) ) { - sal_uInt32 nWarn = 0; - sal_uInt32 nWarn2 = 0; - // read storage streams - if( !(IsOrganizerMode() || IsBlockMode() || aOpt.IsFmtsOnly() || - bInsertMode) ) - { - nWarn = ReadThroughComponent( - pStorage, xModelComp, "meta.xml", "Meta.xml", xServiceFactory, - "com.sun.star.comp.Writer.XMLMetaImporter", - aEmptyArgs, rName, sal_False, IsBlockMode(), xInsertTextRange, - aOpt.IsFmtsOnly(), nStyleFamilyMask, aOpt.IsMerge(), - sal_False ); - - nWarn2 = ReadThroughComponent( - pStorage, xModelComp, "settings.xml", NULL, xServiceFactory, - "com.sun.star.comp.Writer.XMLSettingsImporter", - aFilterArgs, rName, sal_False, IsBlockMode(), xInsertTextRange, - aOpt.IsFmtsOnly(), nStyleFamilyMask, aOpt.IsMerge(), - IsOrganizerMode() ); - } + nWarn = ReadThroughComponent( + pStorage, xModelComp, "meta.xml", "Meta.xml", xServiceFactory, + "com.sun.star.comp.Writer.XMLMetaImporter", + aEmptyArgs, rName, sal_False, IsBlockMode(), xInsertTextRange, + aOpt.IsFmtsOnly(), nStyleFamilyMask, aOpt.IsMerge(), + sal_False ); - nRet = ReadThroughComponent( - pStorage, xModelComp, "styles.xml", NULL, xServiceFactory, - "com.sun.star.comp.Writer.XMLStylesImporter", - aFilterArgs, rName, sal_True, IsBlockMode(), xInsertTextRange, + nWarn2 = ReadThroughComponent( + pStorage, xModelComp, "settings.xml", NULL, xServiceFactory, + "com.sun.star.comp.Writer.XMLSettingsImporter", + aFilterArgs, rName, sal_False, IsBlockMode(), xInsertTextRange, aOpt.IsFmtsOnly(), nStyleFamilyMask, aOpt.IsMerge(), IsOrganizerMode() ); + } - if( !nRet && !(IsOrganizerMode() || aOpt.IsFmtsOnly()) ) - nRet = ReadThroughComponent( - pStorage, xModelComp, "content.xml", "Content.xml", xServiceFactory, - "com.sun.star.comp.Writer.XMLContentImporter", - aFilterArgs, rName, sal_True, IsBlockMode(), xInsertTextRange, - aOpt.IsFmtsOnly(), nStyleFamilyMask, aOpt.IsMerge(), - sal_False ); + nRet = ReadThroughComponent( + pStorage, xModelComp, "styles.xml", NULL, xServiceFactory, + "com.sun.star.comp.Writer.XMLStylesImporter", + aFilterArgs, rName, sal_True, IsBlockMode(), xInsertTextRange, + aOpt.IsFmtsOnly(), nStyleFamilyMask, aOpt.IsMerge(), + IsOrganizerMode() ); - if( !(IsOrganizerMode() || IsBlockMode() || bInsertMode || - aOpt.IsFmtsOnly() ) ) - { - OUString sStreamName( RTL_CONSTASCII_USTRINGPARAM("layout-cache") ); - SvStorageStreamRef xStrm = pStorage->OpenStream( sStreamName, - STREAM_READ | STREAM_NOCREATE ); - if( xStrm.Is() && !xStrm->GetError() ) - { - xStrm->SetBufferSize( 16*1024 ); - rDoc.ReadLayoutCache( *xStrm ); - } - } - if( !nRet ) + if( !nRet && !(IsOrganizerMode() || aOpt.IsFmtsOnly()) ) + nRet = ReadThroughComponent( + pStorage, xModelComp, "content.xml", "Content.xml", xServiceFactory, + "com.sun.star.comp.Writer.XMLContentImporter", + aFilterArgs, rName, sal_True, IsBlockMode(), xInsertTextRange, + aOpt.IsFmtsOnly(), nStyleFamilyMask, aOpt.IsMerge(), + sal_False ); + + if( !(IsOrganizerMode() || IsBlockMode() || bInsertMode || + aOpt.IsFmtsOnly() ) ) + { + OUString sStreamName( RTL_CONSTASCII_USTRINGPARAM("layout-cache") ); + SvStorageStreamRef xStrm = pStorage->OpenStream( sStreamName, + STREAM_READ | STREAM_NOCREATE ); + if( xStrm.Is() && !xStrm->GetError() ) { - if( nWarn ) - nRet = nWarn; - else if( nWarn2 ) - nRet = nWarn2; + xStrm->SetBufferSize( 16*1024 ); + rDoc.ReadLayoutCache( *xStrm ); } } - else + if( !nRet ) { - // read plain file - - // parse - if( xSource.is() ) - { - Reference< io::XActiveDataControl > xSourceControl( xSource, - UNO_QUERY ); - xSourceControl->start(); - } - - nRet = ReadThroughComponent( - xInputStream, xModelComp, aEmptyStr, xServiceFactory, - "com.sun.star.comp.Writer.XMLImporter", - aFilterArgs, rName, sal_True, IsBlockMode(), xInsertTextRange, - aOpt.IsFmtsOnly(), nStyleFamilyMask, aOpt.IsMerge(), - IsOrganizerMode(), sal_False ); + if( nWarn ) + nRet = nWarn; + else if( nWarn2 ) + nRet = nWarn2; } aOpt.ResetAllFmtsOnly(); diff --git a/sw/source/filter/xml/wrtxml.cxx b/sw/source/filter/xml/wrtxml.cxx index 2c598751d5de..d5e0862ce243 100644 --- a/sw/source/filter/xml/wrtxml.cxx +++ b/sw/source/filter/xml/wrtxml.cxx @@ -2,9 +2,9 @@ * * $RCSfile: wrtxml.cxx,v $ * - * $Revision: 1.38 $ + * $Revision: 1.39 $ * - * last change: $Author: dvo $ $Date: 2001-11-08 19:06:46 $ + * last change: $Author: mib $ $Date: 2002-06-24 12:24:50 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -138,8 +138,7 @@ using namespace ::com::sun::star::lang; #define LOGFILE_AUTHOR "mb93740" -SwXMLWriter::SwXMLWriter( sal_Bool bPl ) : - bPlain( bPl ) +SwXMLWriter::SwXMLWriter() { } @@ -167,33 +166,19 @@ sal_uInt32 SwXMLWriter::_Write() Reference< document::XEmbeddedObjectResolver > xObjectResolver; SvXMLEmbeddedObjectHelper *pObjectHelper = 0; - if( pStg ) - { - pGraphicHelper = SvXMLGraphicHelper::Create( *pStg, - GRAPHICHELPER_MODE_WRITE, - sal_False ); - } - else - { - pGraphicHelper = SvXMLGraphicHelper::Create( GRAPHICHELPER_MODE_WRITE ); - } + ASSERT( pStg, "Where is my storage?" ); + pGraphicHelper = SvXMLGraphicHelper::Create( *pStg, + GRAPHICHELPER_MODE_WRITE, + sal_False ); xGraphicResolver = pGraphicHelper; SvPersist *pPersist = pDoc->GetPersist(); if( pPersist ) { - if( pStg ) - pObjectHelper = SvXMLEmbeddedObjectHelper::Create( - *pStg, *pPersist, - EMBEDDEDOBJECTHELPER_MODE_WRITE, - sal_False ); -#if SUPD > 632 - else - pObjectHelper = SvXMLEmbeddedObjectHelper::Create( - *pPersist, - EMBEDDEDOBJECTHELPER_MODE_WRITE ); -#endif - + pObjectHelper = SvXMLEmbeddedObjectHelper::Create( + *pStg, *pPersist, + EMBEDDEDOBJECTHELPER_MODE_WRITE, + sal_False ); xObjectResolver = pObjectHelper; } @@ -257,7 +242,7 @@ sal_uInt32 SwXMLWriter::_Write() } } } - catch( const RuntimeException& e ) + catch( const RuntimeException& ) { xStatusIndicator = 0; } @@ -348,97 +333,84 @@ sal_uInt32 SwXMLWriter::_Write() sal_Bool bWarn = sal_False, bErr = sal_False; String sWarnFile, sErrFile; - if (NULL != pStg) + if( !bOrganizerMode && !bBlock && + SFX_CREATE_MODE_EMBEDDED != pDoc->GetDocShell()->GetCreateMode() ) { - if( !bOrganizerMode && !bBlock && - SFX_CREATE_MODE_EMBEDDED != pDoc->GetDocShell()->GetCreateMode() ) - { - if( !WriteThroughComponent( - xModelComp, "meta.xml", xServiceFactory, - "com.sun.star.comp.Writer.XMLMetaExporter", - aEmptyArgs, aProps, sal_True ) ) - { - bWarn = sal_True; - sWarnFile = String( RTL_CONSTASCII_STRINGPARAM("meta.xml"), - RTL_TEXTENCODING_ASCII_US ); - } - } - if( !WriteThroughComponent( - xModelComp, "styles.xml", xServiceFactory, - "com.sun.star.comp.Writer.XMLStylesExporter", - aFilterArgs, aProps, sal_False ) ) + xModelComp, "meta.xml", xServiceFactory, + "com.sun.star.comp.Writer.XMLMetaExporter", + aEmptyArgs, aProps, sal_True ) ) { - bErr = sal_True; - sErrFile = String( RTL_CONSTASCII_STRINGPARAM("styles.xml"), - RTL_TEXTENCODING_ASCII_US ); + bWarn = sal_True; + sWarnFile = String( RTL_CONSTASCII_STRINGPARAM("meta.xml"), + RTL_TEXTENCODING_ASCII_US ); } + } - if( !bErr ) + if( !WriteThroughComponent( + xModelComp, "styles.xml", xServiceFactory, + "com.sun.star.comp.Writer.XMLStylesExporter", + aFilterArgs, aProps, sal_False ) ) + { + bErr = sal_True; + sErrFile = String( RTL_CONSTASCII_STRINGPARAM("styles.xml"), + RTL_TEXTENCODING_ASCII_US ); + } + + if( !bErr ) + { + if( !bBlock ) { - if( !bBlock ) + if( !WriteThroughComponent( + xModelComp, "settings.xml", xServiceFactory, + "com.sun.star.comp.Writer.XMLSettingsExporter", + aEmptyArgs, aProps, sal_False ) ) { - if( !WriteThroughComponent( - xModelComp, "settings.xml", xServiceFactory, - "com.sun.star.comp.Writer.XMLSettingsExporter", - aEmptyArgs, aProps, sal_False ) ) + if( !bWarn ) { - if( !bWarn ) - { - bWarn = sal_True; - sWarnFile = String( RTL_CONSTASCII_STRINGPARAM("settings.xml"), - RTL_TEXTENCODING_ASCII_US ); - } + bWarn = sal_True; + sWarnFile = String( RTL_CONSTASCII_STRINGPARAM("settings.xml"), + RTL_TEXTENCODING_ASCII_US ); } } } + } - if( !bOrganizerMode && !bErr ) + if( !bOrganizerMode && !bErr ) + { + if( !WriteThroughComponent( + xModelComp, "content.xml", xServiceFactory, + "com.sun.star.comp.Writer.XMLContentExporter", + aFilterArgs, aProps, sal_False ) ) { - if( !WriteThroughComponent( - xModelComp, "content.xml", xServiceFactory, - "com.sun.star.comp.Writer.XMLContentExporter", - aFilterArgs, aProps, sal_False ) ) - { - bErr = sal_True; - sErrFile = String( RTL_CONSTASCII_STRINGPARAM("content.xml"), - RTL_TEXTENCODING_ASCII_US ); - } + bErr = sal_True; + sErrFile = String( RTL_CONSTASCII_STRINGPARAM("content.xml"), + RTL_TEXTENCODING_ASCII_US ); } + } - if( pDoc->GetRootFrm() && pDoc->GetDocStat().nPage > 1 && - !(bOrganizerMode || bBlock || bErr) ) - { + if( pDoc->GetRootFrm() && pDoc->GetDocStat().nPage > 1 && + !(bOrganizerMode || bBlock || bErr) ) + { // DBG_ASSERT( !pDoc->GetDocStat().bModified, // "doc stat is modified!" ); - OUString sStreamName( RTL_CONSTASCII_USTRINGPARAM("layout-cache") ); - SvStorageStreamRef xStrm = pStg->OpenStream( sStreamName, - STREAM_WRITE | STREAM_SHARE_DENYWRITE ); - DBG_ASSERT(xStrm.Is(), "Can't create output stream in package!"); - if( xStrm.Is() ) - { - xStrm->SetSize( 0 ); - String aPropName( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM("MediaType") ) ); - OUString aMime( RTL_CONSTASCII_USTRINGPARAM("appication/binary") ); - uno::Any aAny; - aAny <<= aMime; - xStrm->SetProperty( aPropName, aAny ); - xStrm->SetBufferSize( 16*1024 ); - pDoc->WriteLayoutCache( *xStrm ); - xStrm->Commit(); - } + OUString sStreamName( RTL_CONSTASCII_USTRINGPARAM("layout-cache") ); + SvStorageStreamRef xStrm = pStg->OpenStream( sStreamName, + STREAM_WRITE | STREAM_SHARE_DENYWRITE ); + DBG_ASSERT(xStrm.Is(), "Can't create output stream in package!"); + if( xStrm.Is() ) + { + xStrm->SetSize( 0 ); + String aPropName( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM("MediaType") ) ); + OUString aMime( RTL_CONSTASCII_USTRINGPARAM("appication/binary") ); + uno::Any aAny; + aAny <<= aMime; + xStrm->SetProperty( aPropName, aAny ); + xStrm->SetBufferSize( 16*1024 ); + pDoc->WriteLayoutCache( *xStrm ); + xStrm->Commit(); } } - else - { - // create single stream and do full export - Reference<io::XOutputStream> xOut = - new utl::OOutputStreamWrapper( *pStrm ); - bErr = !WriteThroughComponent( - xOut, xModelComp, xServiceFactory, - "com.sun.star.comp.Writer.XMLExporter", - aFilterArgs, aProps ); - } if( pGraphicHelper ) SvXMLGraphicHelper::Destroy( pGraphicHelper ); @@ -482,11 +454,6 @@ sal_uInt32 SwXMLWriter::_Write() return 0; } -sal_uInt32 SwXMLWriter::WriteStream() -{ - return _Write(); -} - sal_uInt32 SwXMLWriter::WriteStorage() { return _Write(); @@ -500,11 +467,6 @@ sal_uInt32 SwXMLWriter::Write( SwPaM& rPaM, SfxMedium& rMed, : ((Writer *)this)->Write( rPaM, *rMed.GetOutStream(), pFileName ); } -sal_Bool SwXMLWriter::IsStgWriter() const -{ - return !bPlain; -} - sal_Bool SwXMLWriter::WriteThroughComponent( const Reference<XComponent> & xComponent, const sal_Char* pStreamName, @@ -649,7 +611,7 @@ sal_Bool SwXMLWriter::WriteThroughComponent( void GetXMLWriter( const String& rName, WriterRef& xRet ) { - xRet = new SwXMLWriter( rName.EqualsAscii( FILTER_XMLP ) ); + xRet = new SwXMLWriter(); } // ----------------------------------------------------------------------- diff --git a/sw/source/filter/xml/wrtxml.hxx b/sw/source/filter/xml/wrtxml.hxx index a86491076906..28a7011ef1f1 100644 --- a/sw/source/filter/xml/wrtxml.hxx +++ b/sw/source/filter/xml/wrtxml.hxx @@ -2,9 +2,9 @@ * * $RCSfile: wrtxml.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: mib $ $Date: 2001-05-07 06:01:50 $ + * last change: $Author: mib $ $Date: 2002-06-24 12:24:50 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -81,24 +81,18 @@ namespace com { namespace sun { namespace start { class SwXMLWriter : public StgWriter { - sal_Bool bPlain; - sal_uInt32 _Write(); protected: - virtual sal_uInt32 WriteStream(); virtual sal_uInt32 WriteStorage(); public: - SwXMLWriter( sal_Bool bPl ); + SwXMLWriter(); virtual ~SwXMLWriter(); virtual ULONG Write( SwPaM&, SfxMedium&, const String* = 0 ); - virtual sal_Bool IsStgWriter() const; - - private: // helper methods to write XML streams |