summaryrefslogtreecommitdiff
path: root/sw/source/filter
diff options
context:
space:
mode:
authorDaniel Vogelheim <dvo@openoffice.org>2001-03-02 20:02:30 +0000
committerDaniel Vogelheim <dvo@openoffice.org>2001-03-02 20:02:30 +0000
commit3bdcf48d28f8b025054eb0b29efaa268172c65d4 (patch)
treeb3903b52ac76a761a219c3bb21fe21e954e5163b /sw/source/filter
parent1bbad2c3d33ab96c108253a4a9c062541829b30a (diff)
- changed: content and styles are written as separate streams
Diffstat (limited to 'sw/source/filter')
-rw-r--r--sw/source/filter/xml/swxml.cxx371
-rw-r--r--sw/source/filter/xml/wrtxml.cxx180
-rw-r--r--sw/source/filter/xml/xmlexp.cxx96
-rw-r--r--sw/source/filter/xml/xmlexp.hxx6
-rw-r--r--sw/source/filter/xml/xmlimp.cxx91
-rw-r--r--sw/source/filter/xml/xmlimp.hxx6
6 files changed, 495 insertions, 255 deletions
diff --git a/sw/source/filter/xml/swxml.cxx b/sw/source/filter/xml/swxml.cxx
index 1fbff0a1e4a8..42de41cec039 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.15 $
+ * $Revision: 1.16 $
*
- * last change: $Author: mtg $ $Date: 2001-02-28 12:41:01 $
+ * last change: $Author: dvo $ $Date: 2001-03-02 21:02:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -139,6 +139,165 @@ int XMLReader::GetReaderType()
return SW_STORAGE_READER | SW_STREAM_READER;
}
+/// read a component (file + filter version)
+sal_Int32 ReadThroughComponent(
+ Reference<io::XInputStream> xInputStream,
+ Reference<XComponent> xModelComponent,
+ Reference<lang::XMultiServiceFactory> & rFactory,
+ const sal_Char* pFilterName,
+ Sequence<Any> rFilterArguments,
+ const OUString& rName,
+
+ // parameters for special modes
+ sal_Bool bBlockMode,
+ Reference<XTextRange> & rInsertTextRange,
+ sal_Bool bFormatsOnly,
+ sal_uInt16 nStyleFamilyMask,
+ sal_Bool bMergeStyles)
+{
+ DBG_ASSERT(xInputStream.is(), "input stream missing");
+ DBG_ASSERT(xModelComponent.is(), "document missing");
+ DBG_ASSERT(rFactory.is(), "factory missing");
+ DBG_ASSERT(NULL != pFilterName,"I need a service name for the component!");
+
+ // prepare ParserInputSrouce
+ xml::sax::InputSource aParserInput;
+ aParserInput.sSystemId = rName;
+ aParserInput.aInputStream = xInputStream;
+
+ // get parser
+ Reference< xml::sax::XParser > xParser(
+ rFactory->createInstance(
+ OUString::createFromAscii("com.sun.star.xml.sax.Parser") ),
+ UNO_QUERY );
+ DBG_ASSERT( xParser.is(), "Can't create parser" );
+ if( !xParser.is() )
+ return ERR_SWG_READ_ERROR;
+
+ // get filter
+ Reference< xml::sax::XDocumentHandler > xFilter(
+ rFactory->createInstanceWithArguments(
+ OUString::createFromAscii(pFilterName), rFilterArguments),
+ UNO_QUERY );
+ DBG_ASSERT( xFilter.is(), "Can't instantiate filter component." );
+ if( !xFilter.is() )
+ return ERR_SWG_READ_ERROR;
+
+ // connect parser and filter
+ xParser->setDocumentHandler( xFilter );
+
+ // connect model and filter
+ Reference < XImporter > xImporter( xFilter, UNO_QUERY );
+ xImporter->setTargetDocument( xModelComponent );
+
+ // prepare filter for special modes
+ if( bBlockMode || bFormatsOnly || rInsertTextRange.is() )
+ {
+ Reference<XUnoTunnel> xFilterTunnel( xFilter, UNO_QUERY );
+ if (xFilterTunnel.is())
+ {
+ SwXMLImport* pFilter = (SwXMLImport *)xFilterTunnel->getSomething(
+ SwXMLImport::getUnoTunnelId() );
+
+ if ( NULL != pFilter )
+ {
+ if ( bFormatsOnly )
+ pFilter->setStyleInsertMode( nStyleFamilyMask,
+ !bMergeStyles );
+
+ if ( rInsertTextRange.is() )
+ pFilter->setTextInsertMode( rInsertTextRange );
+
+ if ( bBlockMode )
+ pFilter->setBlockMode();
+ }
+ }
+ }
+
+ // finally, parser the stream
+ try
+ {
+ xParser->parseStream( aParserInput );
+ }
+ catch( xml::sax::SAXParseException& r )
+ {
+ String sErr( String::CreateFromInt32( r.LineNumber ));
+ sErr += ',';
+ sErr += String::CreateFromInt32( r.ColumnNumber );
+
+ return *new StringErrorInfo( ERR_FORMAT_ROWCOL, sErr,
+ ERRCODE_BUTTON_OK | ERRCODE_MSG_ERROR );
+ }
+// catch( xml::sax::SAXParseException& r )
+// {
+// return ERR_SWG_READ_ERROR;
+// }
+ catch( xml::sax::SAXException& )
+ {
+ return ERR_SWG_READ_ERROR;
+ }
+ catch( io::IOException& )
+ {
+ return ERR_SWG_READ_ERROR;
+ }
+
+ // success!
+ return 0;
+}
+
+/// read a component (storage version)
+sal_Int32 ReadThroughComponent(
+ SvStorage* pStorage,
+ Reference<XComponent> xModelComponent,
+ const sal_Char* pStreamName,
+ const sal_Char* pCompatibilityStreamName,
+ Reference<lang::XMultiServiceFactory> & rFactory,
+ const sal_Char* pFilterName,
+ Sequence<Any> rFilterArguments,
+ const OUString& rName,
+
+ // parameters for special modes
+ sal_Bool bBlockMode,
+ Reference<XTextRange> & rInsertTextRange,
+ sal_Bool bFormatsOnly,
+ sal_uInt16 nStyleFamilyMask,
+ sal_Bool bMergeStyles)
+{
+ DBG_ASSERT(NULL != pStorage, "Need storage!");
+ DBG_ASSERT(NULL != pStreamName, "Please, please, give me a name!");
+
+ // open stream (and set parser input)
+ OUString sStreamName = OUString::createFromAscii(pStreamName);
+ if (! pStorage->IsStream(sStreamName))
+ {
+ // stream name not found! Then try the compatibility name.
+
+ // do we even have an alternative name?
+ if ( NULL == pCompatibilityStreamName )
+ return ERR_SWG_READ_ERROR;
+
+ // if so, does the stream exist?
+ sStreamName = OUString::createFromAscii(pCompatibilityStreamName);
+ if (! pStorage->IsStream(sStreamName) )
+ return ERR_SWG_READ_ERROR;
+ }
+
+ // get input stream
+ SvStorageStreamRef xEventsStream;
+ xEventsStream = pStorage->OpenStream( sStreamName,
+ STREAM_READ | STREAM_NOCREATE );
+ xEventsStream->SetBufferSize( 16*1024 );
+ Reference<io::XInputStream> xInputStream =
+ new utl::OInputStreamWrapper( *xEventsStream );
+
+ // read from the stream
+ return ReadThroughComponent(
+ xInputStream, xModelComponent, rFactory, pFilterName, rFilterArguments,
+ rName, bBlockMode, rInsertTextRange, bFormatsOnly,
+ nStyleFamilyMask, bMergeStyles);
+}
+
+
sal_uInt32 XMLReader::Read( SwDoc &rDoc, SwPaM &rPaM, const String & rName )
{
// Get service factory
@@ -155,11 +314,10 @@ sal_uInt32 XMLReader::Read( SwDoc &rDoc, SwPaM &rPaM, const String & rName )
SvXMLGraphicHelper *pGraphicHelper = 0;
Reference< document::XEmbeddedObjectResolver > xObjectResolver;
SvXMLEmbeddedObjectHelper *pObjectHelper = 0;
- SvStorageStreamRef xDocStream;
-
- xml::sax::InputSource aParserInput;
- aParserInput.sSystemId = rName;
+ // get the input stream (storage or stream)
+ SvStorageStreamRef xDocStream;
+ Reference<io::XInputStream> xInputStream;
SvStorage *pStorage = 0;
if( pMedium )
pStorage = pMedium->GetStorage();
@@ -186,7 +344,7 @@ sal_uInt32 XMLReader::Read( SwDoc &rDoc, SwPaM &rPaM, const String & rName )
xDocStream = pStorage->OpenStream( sDocName,
STREAM_READ | STREAM_NOCREATE );
xDocStream->SetBufferSize( 16*1024 );
- aParserInput.aInputStream = new utl::OInputStreamWrapper( *xDocStream );
+ xInputStream = new utl::OInputStreamWrapper( *xDocStream );
}
else if( pMedium )
{
@@ -210,70 +368,36 @@ sal_uInt32 XMLReader::Read( SwDoc &rDoc, SwPaM &rPaM, const String & rName )
Reference< io::XOutputStream > xPipeOutput( xPipe, UNO_QUERY );
xSource->setOutputStream( xPipeOutput );
- aParserInput.aInputStream = Reference< io::XInputStream >( xPipe,
- UNO_QUERY );
+ xInputStream = Reference< io::XInputStream >( xPipe, UNO_QUERY );
}
else
{
pStrm->SetBufferSize( 16*1024 );
- aParserInput.aInputStream = new utl::OInputStreamWrapper( *pStrm );
+ xInputStream = new utl::OInputStreamWrapper( *pStrm );
}
- // get parser
- Reference< xml::sax::XParser > xParser(
- xServiceFactory->createInstance(
- OUString::createFromAscii("com.sun.star.xml.sax.Parser") ),
- UNO_QUERY );
- ASSERT( xParser.is(),
- "XMLReader::Read: com.sun.star.xml.sax.Parser service missing" );
- if( !xParser.is() )
- return ERR_SWG_READ_ERROR;
-
- // get filter
- Sequence < Any > aArgs( 2 );
- Any *pArgs = aArgs.getArray();
- *pArgs++ <<= xGraphicResolver;
- *pArgs++ <<= xObjectResolver;
- Reference< xml::sax::XDocumentHandler > xFilter(
- xServiceFactory->createInstanceWithArguments(
- OUString::createFromAscii("com.sun.star.office.sax.importer.Writer"),
- aArgs ),
- UNO_QUERY );
- ASSERT( xFilter.is(),
- "XMLReader::Read: com.sun.star.xml.sax.importer.Writer service missing" );
- if( !xFilter.is() )
- return ERR_SWG_READ_ERROR;
-
- // connect parser and filter
- xParser->setDocumentHandler( xFilter );
-
- // Get model
+ // Get the docshell, the model, and finally the model's component
SwDocShell *pDocSh = rDoc.GetDocShell();
ASSERT( pDocSh, "XMLReader::Read: got no doc shell" );
if( !pDocSh )
return ERR_SWG_READ_ERROR;
-
Reference< lang::XComponent > xModelComp( pDocSh->GetModel(), UNO_QUERY );
ASSERT( xModelComp.is(),
"XMLReader::Read: got no model" );
if( !xModelComp.is() )
return ERR_SWG_READ_ERROR;
- // connect model and filter
- Reference < XImporter > xImporter( xFilter, UNO_QUERY );
- xImporter->setTargetDocument( xModelComp );
+ // prepare filter arguments
+ Sequence<Any> aFilterArgs( 2 );
+ Any *pArgs = aFilterArgs.getArray();
+ *pArgs++ <<= xGraphicResolver;
+ *pArgs++ <<= xObjectResolver;
+ Sequence<Any> aEmptyArgs( 0 );
- Reference<XUnoTunnel> xFilterTunnel;
- SwXMLImport *pFilter = 0;
- if( aOpt.IsFmtsOnly() || bInsertMode || IsBlockMode() )
- {
- xFilterTunnel = Reference<XUnoTunnel>( xFilter, UNO_QUERY );
- pFilter = (SwXMLImport *)xFilterTunnel->getSomething(
- SwXMLImport::getUnoTunnelId() );
- }
+ // prepare for special modes
+ sal_uInt16 nStyleFamilyMask = 0U;
if( aOpt.IsFmtsOnly() )
{
- sal_uInt16 nStyleFamilyMask = 0U;
if( aOpt.IsFrmFmts() )
nStyleFamilyMask |= SFX_STYLE_FAMILY_FRAME;
if( aOpt.IsPageDescs() )
@@ -282,22 +406,12 @@ sal_uInt32 XMLReader::Read( SwDoc &rDoc, SwPaM &rPaM, const String & rName )
nStyleFamilyMask |= (SFX_STYLE_FAMILY_CHAR|SFX_STYLE_FAMILY_PARA);
if( aOpt.IsNumRules() )
nStyleFamilyMask |= SFX_STYLE_FAMILY_PSEUDO;
-
- ASSERT( pFilter, "There is the filter?" );
- pFilter->setStyleInsertMode( nStyleFamilyMask, !aOpt.IsMerge() );
- }
- else if( bInsertMode )
- {
- Reference < XTextRange > xTextRange =
- SwXTextRange::CreateTextRangeFromPosition( &rDoc, *rPaM.GetPoint(),
- 0 );
- ASSERT( pFilter, "There is the filter?" );
- pFilter->setTextInsertMode( xTextRange );
}
- else if( IsBlockMode() )
+ Reference<XTextRange> xInsertTextRange = NULL;
+ if( bInsertMode )
{
- ASSERT( pFilter, "There is the filter?" );
- pFilter->setBlockMode();
+ xInsertTextRange = SwXTextRange::CreateTextRangeFromPosition(
+ &rDoc, *rPaM.GetPoint(), 0 );
}
aOpt.ResetAllFmtsOnly();
@@ -305,96 +419,53 @@ sal_uInt32 XMLReader::Read( SwDoc &rDoc, SwPaM &rPaM, const String & rName )
rDoc.AddLink(); // prevent deletion
sal_uInt32 nRet = 0;
- // parse
- if( xSource.is() )
+ if ( NULL != pStorage )
{
- Reference< io::XActiveDataControl > xSourceControl( xSource, UNO_QUERY );
- xSourceControl->start();
+ // read storage streams
+
+ ReadThroughComponent(
+ pStorage, xModelComp, "content.xml", "Content.xml", xServiceFactory,
+ "com.sun.star.comp.Writer.XMLContentImporter",
+ aFilterArgs, rName, IsBlockMode(), xInsertTextRange,
+ aOpt.IsFmtsOnly(), nStyleFamilyMask, !aOpt.IsMerge() );
+
+ ReadThroughComponent(
+ pStorage, xModelComp, "styles.xml", "", xServiceFactory,
+ "com.sun.star.comp.Writer.XMLStylesImporter",
+ aFilterArgs, rName, IsBlockMode(), xInsertTextRange,
+ aOpt.IsFmtsOnly(), nStyleFamilyMask, !aOpt.IsMerge() );
+
+ ReadThroughComponent(
+ pStorage, xModelComp, "meta.xml", "Meta.xml", xServiceFactory,
+ "com.sun.star.comp.Writer.XMLMetaImporter",
+ aEmptyArgs, rName, IsBlockMode(), xInsertTextRange,
+ aOpt.IsFmtsOnly(), nStyleFamilyMask, !aOpt.IsMerge() );
+
+ if (IsBlockMode())
+ ReadThroughComponent(
+ pStorage, xModelComp, "atevents.xml", "AutoTextEvents.xml",
+ xServiceFactory,
+ "com.sun.star.comp.Writer.XMLAutotextEventsImporter",
+ aEmptyArgs, rName, IsBlockMode(), xInsertTextRange,
+ aOpt.IsFmtsOnly(), nStyleFamilyMask, !aOpt.IsMerge() );
}
- try
- {
- xParser->parseStream( aParserInput );
- }
- catch( xml::sax::SAXParseException& r )
- {
- String sErr( String::CreateFromInt32( r.LineNumber ));
- sErr += ',';
- sErr += String::CreateFromInt32( r.ColumnNumber );
-
- nRet = *new StringErrorInfo( ERR_FORMAT_ROWCOL, sErr,
- ERRCODE_BUTTON_OK | ERRCODE_MSG_ERROR );
- }
- catch( xml::sax::SAXException& r )
- {
- nRet = ERR_SWG_READ_ERROR;
- }
- catch( io::IOException& r )
- {
- nRet = ERR_SWG_READ_ERROR;
- }
-
- // import autotext events
- if ((NULL != pStorage) && IsBlockMode())
+ else
{
- OUString sStreamName(RTL_CONSTASCII_USTRINGPARAM(
- "AutoTextEvents.xml"));
- OUString sServiceName(RTL_CONSTASCII_USTRINGPARAM(
- "com.sun.star.office.sax.importer.AutoTextEventReader"));
-
- // prepare ParserInputSrouce
- xml::sax::InputSource aEventsParserInput;
- aEventsParserInput.sSystemId = rName;
-
- // open stream (and set parser input)
- SvStorageStreamRef xEventsStream;
- xEventsStream = pStorage->OpenStream( sStreamName,
- STREAM_READ | STREAM_NOCREATE );
- xEventsStream->SetBufferSize( 16*1024 );
- aEventsParserInput.aInputStream =
- new utl::OInputStreamWrapper( *xEventsStream );
-
- // get parser
- Reference< xml::sax::XParser > xEventsParser(
- xServiceFactory->createInstance(
- OUString::createFromAscii("com.sun.star.xml.sax.Parser") ),
- UNO_QUERY );
- ASSERT( xEventsParser.is(),
- "Can't create parser" );
- if( !xEventsParser.is() )
- return ERR_SWG_READ_ERROR;
-
- // get filter
- Sequence < Any > aArgs( 0 );
- Reference< xml::sax::XDocumentHandler > xEventsFilter(
- xServiceFactory->createInstance(sServiceName), UNO_QUERY );
- ASSERT( xEventsFilter.is(),
- "Can't instantiate auto text events reader." );
- if( !xEventsFilter.is() )
- return ERR_SWG_READ_ERROR;
-
- // connect parser and filter
- xEventsParser->setDocumentHandler( xEventsFilter );
-
- // connect model and filter
- Reference < XImporter > xEventsImporter( xEventsFilter, UNO_QUERY );
- xEventsImporter->setTargetDocument( xModelComp );
+ // read plain file
- try
+ // parse
+ if( xSource.is() )
{
- xEventsParser->parseStream( aEventsParserInput );
- }
- catch( xml::sax::SAXParseException& r )
- {
- nRet = ERR_SWG_READ_ERROR;
- }
- catch( xml::sax::SAXException& r )
- {
- nRet = ERR_SWG_READ_ERROR;
- }
- catch( io::IOException& r )
- {
- nRet = ERR_SWG_READ_ERROR;
+ Reference< io::XActiveDataControl > xSourceControl( xSource,
+ UNO_QUERY );
+ xSourceControl->start();
}
+
+ ReadThroughComponent(
+ xInputStream, xModelComp, xServiceFactory,
+ "com.sun.star.comp.Writer.XMLImporter",
+ aFilterArgs, rName, IsBlockMode(), xInsertTextRange,
+ aOpt.IsFmtsOnly(), nStyleFamilyMask, !aOpt.IsMerge() );
}
if( pGraphicHelper )
diff --git a/sw/source/filter/xml/wrtxml.cxx b/sw/source/filter/xml/wrtxml.cxx
index b4e0a8e9aa80..d61b8954bb1b 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.17 $
+ * $Revision: 1.18 $
*
- * last change: $Author: dvo $ $Date: 2001-03-01 15:47:53 $
+ * last change: $Author: dvo $ $Date: 2001-03-02 21:02:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -128,30 +128,21 @@ __EXPORT SwXMLWriter::~SwXMLWriter()
{
}
+
+/// export through an XML exporter component (output stream version)
sal_uInt32 WriteThroughComponent(
- SvStorage* pStorage,
+ Reference<io::XOutputStream> xOutputStream,
Reference<XComponent> xComponent,
- const sal_Char* pStreamName,
Reference<lang::XMultiServiceFactory> & rFactory,
const sal_Char* pComponentName,
const Sequence<Any> & rArguments,
- const Sequence<beans::PropertyValue> & rMediaDesc)
+ const Sequence<beans::PropertyValue> & rMediaDesc,
+ sal_Bool bBlockMode)
{
- ASSERT(NULL != pStorage, "Need storage!");
+ ASSERT(xOutputStream.is(), "I really need an output stream!");
ASSERT(xComponent.is(), "Need component!");
- ASSERT(NULL != pStreamName, "Need stream name!");
ASSERT(NULL != pComponentName, "Need component name!");
- Reference< io::XOutputStream > xOutputStream;
- SvStorageStreamRef xDocStream;
-
- // open stream, etc.
- OUString sStreamName = OUString::createFromAscii(pStreamName);
- xDocStream = pStorage->OpenStream( sStreamName,
- STREAM_WRITE | STREAM_SHARE_DENYWRITE );
- xDocStream->SetBufferSize( 16*1024 );
- xOutputStream = new utl::OOutputStreamWrapper( *xDocStream );
-
// get component
Reference< io::XActiveDataSource > xSaxWriter(
rFactory->createInstance(
@@ -180,6 +171,20 @@ sal_uInt32 WriteThroughComponent(
if( !xExporter.is() )
return ERR_SWG_WRITE_ERROR;
+ // set block mode (if appropriate)
+ if( bBlockMode )
+ {
+ Reference<XUnoTunnel> xFilterTunnel( xExporter, UNO_QUERY );
+ if (xFilterTunnel.is())
+ {
+ SwXMLExport *pFilter = (SwXMLExport *)xFilterTunnel->getSomething(
+ SwXMLExport::getUnoTunnelId() );
+ if (NULL != pFilter)
+ pFilter->setBlockMode();
+ }
+ }
+
+
// connect model and filter
xExporter->setSourceDocument( xComponent );
@@ -187,11 +192,48 @@ sal_uInt32 WriteThroughComponent(
Reference < XFilter > xFilter( xExporter, UNO_QUERY );
xFilter->filter( rMediaDesc );
+ return 0;
+}
+
+/// export through an XML exporter component (storage version)
+sal_uInt32 WriteThroughComponent(
+ SvStorage* pStorage,
+ Reference<XComponent> xComponent,
+ const sal_Char* pStreamName,
+ Reference<lang::XMultiServiceFactory> & rFactory,
+ const sal_Char* pComponentName,
+ const Sequence<Any> & rArguments,
+ const Sequence<beans::PropertyValue> & rMediaDesc,
+ sal_Bool bBlockMode)
+{
+ ASSERT(NULL != pStorage, "Need storage!");
+ ASSERT(NULL != pStreamName, "Need stream name!");
+
+ Reference< io::XOutputStream > xOutputStream;
+ SvStorageStreamRef xDocStream;
+
+ // open stream
+ OUString sStreamName = OUString::createFromAscii(pStreamName);
+ xDocStream = pStorage->OpenStream( sStreamName,
+ STREAM_WRITE | STREAM_SHARE_DENYWRITE );
+ if (! xDocStream.Is())
+ return ERR_SWG_WRITE_ERROR;
+ DBG_ASSERT(xDocStream.Is(), "Can't create output stream in package!");
+
+ // set buffer and create outputstream
+ xDocStream->SetBufferSize( 16*1024 );
+ xOutputStream = new utl::OOutputStreamWrapper( *xDocStream );
+
+ // write the stuff
+ sal_Int32 nRet = WriteThroughComponent(
+ xOutputStream, xComponent, rFactory,
+ pComponentName, rArguments, rMediaDesc, bBlockMode);
+
// finally, commit stream.
- if( xDocStream.Is() )
+ if( 0 == nRet )
xDocStream->Commit();
- return 0;
+ return nRet;
}
sal_uInt32 SwXMLWriter::_Write()
@@ -214,6 +256,8 @@ sal_uInt32 SwXMLWriter::_Write()
if( pStg )
{
+ // export graphics and objects only in packages
+
pGraphicHelper = SvXMLGraphicHelper::Create( *pStg,
GRAPHICHELPER_MODE_WRITE,
sal_False );
@@ -228,47 +272,17 @@ sal_uInt32 SwXMLWriter::_Write()
sal_False );
xObjectResolver = pObjectHelper;
}
-
- OUString sDocName( RTL_CONSTASCII_USTRINGPARAM( "Content.xml" ) );
- xDocStream = pStg->OpenStream( sDocName,
- STREAM_WRITE | STREAM_SHARE_DENYWRITE );
- xDocStream->SetBufferSize( 16*1024 );
- xOut = new utl::OOutputStreamWrapper( *xDocStream );
}
- else
- {
- xOut = new utl::OOutputStreamWrapper( *pStrm );
- }
-
- // get writer
- Reference< io::XActiveDataSource > xWriter(
- xServiceFactory->createInstance(
- OUString::createFromAscii("com.sun.star.xml.sax.Writer") ),
- UNO_QUERY );
- ASSERT( xWriter.is(),
- "SwXMLWriter::Write: com.sun.star.xml.sax.Writer service missing" );
- if(!xWriter.is())
- return ERR_SWG_WRITE_ERROR;
- // connect writer and output stream
- xWriter->setOutputStream( xOut );
- // get filter
- Reference< xml::sax::XDocumentHandler > xHandler( xWriter, UNO_QUERY );
- Sequence < Any > aArgs( 3 );
- Any *pArgs = aArgs.getArray();
- *pArgs++ <<= xHandler;
+ // filter arguments
+ // - graphics + object resolver for styles + content
+ // - else empty
+ Sequence < Any > aFilterArgs( 2 );
+ Any *pArgs = aFilterArgs.getArray();
*pArgs++ <<= xGraphicResolver;
*pArgs++ <<= xObjectResolver;
- Reference< document::XExporter > xExporter(
- xServiceFactory->createInstanceWithArguments(
- OUString::createFromAscii("com.sun.star.office.sax.exporter.Writer"),
- aArgs ),
- UNO_QUERY );
- ASSERT( xExporter.is(),
- "XMLReader::Read: com.sun.star.xml.sax.exporter.Writer service missing" );
- if( !xExporter.is() )
- return ERR_SWG_WRITE_ERROR;
+ Sequence < Any > aEmptyArgs( 0 );
//Get model
Reference< lang::XComponent > xModelComp(
@@ -277,12 +291,10 @@ sal_uInt32 SwXMLWriter::_Write()
if( !xModelComp.is() )
return ERR_SWG_WRITE_ERROR;
- // connect model and filter
- xExporter->setSourceDocument( xModelComp );
-
PutNumFmtFontsInAttrPool();
PutEditEngFontsInAttrPool();
+ // properties
Sequence < PropertyValue > aProps( pOrigFileName ? 1 : 0 );
if( pOrigFileName )
{
@@ -291,35 +303,40 @@ sal_uInt32 SwXMLWriter::_Write()
(pProps++)->Value <<= OUString( *pOrigFileName );
}
- if( bBlock )
+ // export sub streams for package, else full stream into a file
+ if (NULL != pStg)
{
- Reference<XUnoTunnel> xFilterTunnel( xExporter, UNO_QUERY );
- SwXMLExport *pFilter = (SwXMLExport *)xFilterTunnel->getSomething(
- SwXMLExport::getUnoTunnelId() );
- pFilter->setBlockMode();
- }
+ WriteThroughComponent(
+ pStg, xModelComp, "content.xml", xServiceFactory,
+ "com.sun.star.comp.Writer.XMLContentExporter",
+ aFilterArgs, aProps, bBlock );
- Reference < XFilter > xFilter( xExporter, UNO_QUERY );
- xFilter->filter( aProps );
+ WriteThroughComponent(
+ pStg, xModelComp, "styles.xml", xServiceFactory,
+ "com.sun.star.comp.Writer.XMLStylesExporter",
+ aFilterArgs, aProps, bBlock );
- if( xDocStream.Is() )
- xDocStream->Commit();
+ WriteThroughComponent(
+ pStg, xModelComp, "meta.xml", xServiceFactory,
+ "com.sun.star.comp.Writer.XMLMetaExporter",
+ aEmptyArgs, aProps, bBlock );
- // export sub streams for: auto text events, meta data
- Sequence < Any > aEmptyArgs( 0 );
- if (NULL != pStg)
- {
// export auto text events (if in block mode)
if ( bBlock )
WriteThroughComponent(
- pStg, xModelComp, "AutoTextEvents.xml", xServiceFactory,
- "com.sun.star.office.sax.exporter.AutoTextEventWriter",
- aEmptyArgs, aProps );
-
+ pStg, xModelComp, "atevents.xml", xServiceFactory,
+ "com.sun.star.comp.Writer.XMLAutotextEventsExporter",
+ aEmptyArgs, aProps, bBlock );
+ }
+ else
+ {
+ // create single stream and do full export
+ Reference<io::XOutputStream> xOut =
+ new utl::OOutputStreamWrapper( *pStrm );
WriteThroughComponent(
- pStg, xModelComp, "Meta.xml", xServiceFactory,
- "com.sun.star.office.sax.exporter.MetaInformation",
- aEmptyArgs, aProps );
+ xOut, xModelComp, xServiceFactory,
+ "com.sun.star.comp.Writer.XMLExporter",
+ aEmptyArgs, aProps, bBlock );
}
if( pGraphicHelper )
@@ -368,11 +385,14 @@ void GetXMLWriter( const String& rName, WriterRef& xRet )
Source Code Control System - Header
- $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/xml/wrtxml.cxx,v 1.17 2001-03-01 15:47:53 dvo Exp $
+ $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/xml/wrtxml.cxx,v 1.18 2001-03-02 21:02:30 dvo Exp $
Source Code Control System - Update
$Log: not supported by cvs2svn $
+ Revision 1.17 2001/03/01 15:47:53 dvo
+ - #84291# fixed: assertion removed (it's legal for the asserted condition to occur)
+
Revision 1.16 2001/02/13 17:54:54 dvo
- changed: in wrtxml.cxx substreams now use common code
- added: document classes for global, label, etc. documents
diff --git a/sw/source/filter/xml/xmlexp.cxx b/sw/source/filter/xml/xmlexp.cxx
index dfb65e7a1f67..0560f902ae76 100644
--- a/sw/source/filter/xml/xmlexp.cxx
+++ b/sw/source/filter/xml/xmlexp.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: xmlexp.cxx,v $
*
- * $Revision: 1.26 $
+ * $Revision: 1.27 $
*
- * last change: $Author: mib $ $Date: 2001-03-02 16:49:56 $
+ * last change: $Author: dvo $ $Date: 2001-03-02 21:02:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -191,8 +191,8 @@ void SwXMLExport::SetCurPaM( SwPaM& rPaM, sal_Bool bWhole, sal_Bool bTabOnly )
}
#endif
-SwXMLExport::SwXMLExport() :
- SvXMLExport( MAP_INCH, sXML_text ),
+SwXMLExport::SwXMLExport(sal_uInt16 nExportFlags) :
+ SvXMLExport( MAP_INCH, sXML_text, nExportFlags ),
#ifdef XML_CORE_API
pCurPaM( 0 ),
pOrigPaM( &rPaM ),
@@ -484,27 +484,103 @@ void SwXMLExport::_ExportContent()
#endif
}
+
+//
+// uno component registration
+// helper functions for export service(s)
+//
+
+OUString SAL_CALL SwXMLExport_getImplementationName() throw()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.comp.Writer.XMLExporter" ) );
+}
+
Sequence< OUString > SAL_CALL SwXMLExport_getSupportedServiceNames()
throw()
{
- const OUString aServiceName(
- RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.office.sax.exporter.Writer" ) );
+ const OUString aServiceName(SwXMLExport_getImplementationName());
const Sequence< OUString > aSeq( &aServiceName, 1 );
return aSeq;
}
-OUString SAL_CALL SwXMLExport_getImplementationName() throw()
+Reference< XInterface > SAL_CALL SwXMLExport_createInstance(
+ const Reference< XMultiServiceFactory > & rSMgr)
+ throw( Exception )
{
- return OUString( RTL_CONSTASCII_USTRINGPARAM( "SwXMLExport" ) );
+ return (cppu::OWeakObject*)new SwXMLExport(EXPORT_ALL);
}
-Reference< XInterface > SAL_CALL SwXMLExport_createInstance(
+OUString SAL_CALL SwXMLExportStyles_getImplementationName() throw()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.comp.Writer.XMLStylesExporter" ) );
+}
+
+Sequence< OUString > SAL_CALL SwXMLExportStyles_getSupportedServiceNames()
+ throw()
+{
+ const OUString aServiceName(SwXMLExportStyles_getImplementationName());
+ const Sequence< OUString > aSeq( &aServiceName, 1 );
+ return aSeq;
+}
+
+Reference< XInterface > SAL_CALL SwXMLExportStyles_createInstance(
const Reference< XMultiServiceFactory > & rSMgr)
throw( Exception )
{
- return (cppu::OWeakObject*)new SwXMLExport;
+ return (cppu::OWeakObject*)new SwXMLExport(
+ EXPORT_STYLES | EXPORT_MASTERSTYLES | EXPORT_AUTOSTYLES |
+ EXPORT_FONTDECLS );
}
+OUString SAL_CALL SwXMLExportContent_getImplementationName() throw()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.comp.Writer.XMLContentExporter" ) );
+}
+
+Sequence< OUString > SAL_CALL SwXMLExportContent_getSupportedServiceNames()
+ throw()
+{
+ const OUString aServiceName(SwXMLExportContent_getImplementationName());
+ const Sequence< OUString > aSeq( &aServiceName, 1 );
+ return aSeq;
+}
+
+Reference< XInterface > SAL_CALL SwXMLExportContent_createInstance(
+ const Reference< XMultiServiceFactory > & rSMgr)
+ throw( Exception )
+{
+ return (cppu::OWeakObject*)new SwXMLExport(
+ EXPORT_AUTOSTYLES | EXPORT_CONTENT | EXPORT_SCRIPTS |
+ EXPORT_FONTDECLS );
+}
+
+OUString SAL_CALL SwXMLExportMeta_getImplementationName() throw()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.comp.Writer.XMLMetaExporter" ) );
+}
+
+Sequence< OUString > SAL_CALL SwXMLExportMeta_getSupportedServiceNames()
+ throw()
+{
+ const OUString aServiceName(SwXMLExportMeta_getImplementationName());
+ const Sequence< OUString > aSeq( &aServiceName, 1 );
+ return aSeq;
+}
+
+Reference< XInterface > SAL_CALL SwXMLExportMeta_createInstance(
+ const Reference< XMultiServiceFactory > & rSMgr)
+ throw( Exception )
+{
+ return (cppu::OWeakObject*)new SwXMLExport(EXPORT_META);
+}
+
+
+
+
const Sequence< sal_Int8 > & SwXMLExport::getUnoTunnelId() throw()
{
static Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId();
diff --git a/sw/source/filter/xml/xmlexp.hxx b/sw/source/filter/xml/xmlexp.hxx
index c481ee3f5631..13096de0331f 100644
--- a/sw/source/filter/xml/xmlexp.hxx
+++ b/sw/source/filter/xml/xmlexp.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: xmlexp.hxx,v $
*
- * $Revision: 1.15 $
+ * $Revision: 1.16 $
*
- * last change: $Author: mib $ $Date: 2001-01-22 12:31:45 $
+ * last change: $Author: dvo $ $Date: 2001-03-02 21:02:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -162,7 +162,7 @@ protected:
public:
- SwXMLExport();
+ SwXMLExport(sal_uInt16 nExportFlags = EXPORT_ALL);
#ifdef XML_CORE_API
SwXMLExport( const ::com::sun::star::uno::Reference<
::com::sun::star::frame::XModel > & rModel,
diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx
index ad9203ac405d..3250cd6abb9c 100644
--- a/sw/source/filter/xml/xmlimp.cxx
+++ b/sw/source/filter/xml/xmlimp.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: xmlimp.cxx,v $
*
- * $Revision: 1.20 $
+ * $Revision: 1.21 $
*
- * last change: $Author: dvo $ $Date: 2001-02-14 16:35:00 $
+ * last change: $Author: dvo $ $Date: 2001-03-02 21:02:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -306,7 +306,8 @@ SvXMLImportContext *SwXMLImport::CreateContext(
return pContext;
}
-SwXMLImport::SwXMLImport() :
+SwXMLImport::SwXMLImport(sal_uInt16 nImportFlags) :
+ SvXMLImport( nImportFlags ),
bLoadDoc( sal_True ),
bInsert( sal_False ),
bBlock( sal_False ),
@@ -731,23 +732,95 @@ void SwXMLImport::ShowProgress( sal_Int32 nPercent )
}
}
+
+//
+// UNO component registration helper functions
+//
+
+OUString SAL_CALL SwXMLImport_getImplementationName() throw()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.comp.Writer.XMLImporter" ) );
+}
+
uno::Sequence< OUString > SAL_CALL SwXMLImport_getSupportedServiceNames()
throw()
{
- const OUString aServiceName(
- RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.office.sax.importer.Writer" ) );
+ const OUString aServiceName( SwXMLImport_getImplementationName() );
const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
return aSeq;
}
-OUString SAL_CALL SwXMLImport_getImplementationName() throw()
+uno::Reference< uno::XInterface > SAL_CALL SwXMLImport_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
+ throw( uno::Exception )
{
- return OUString( RTL_CONSTASCII_USTRINGPARAM( "SwXMLImport" ) );
+ return (cppu::OWeakObject*)new SwXMLImport(IMPORT_ALL);
}
-uno::Reference< uno::XInterface > SAL_CALL SwXMLImport_createInstance(
+OUString SAL_CALL SwXMLImportStyles_getImplementationName() throw()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.comp.Writer.XMLStylesImporter" ) );
+}
+
+uno::Sequence< OUString > SAL_CALL SwXMLImportStyles_getSupportedServiceNames()
+ throw()
+{
+ const OUString aServiceName( SwXMLImportStyles_getImplementationName() );
+ const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
+ return aSeq;
+}
+
+uno::Reference< uno::XInterface > SAL_CALL SwXMLImportStyles_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
+ throw( uno::Exception )
+{
+ return (cppu::OWeakObject*)new SwXMLImport(
+ IMPORT_STYLES | IMPORT_MASTERSTYLES | IMPORT_AUTOSTYLES |
+ IMPORT_FONTDECLS );
+}
+
+OUString SAL_CALL SwXMLImportContent_getImplementationName() throw()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.comp.Writer.XMLContentImporter" ) );
+}
+
+uno::Sequence< OUString > SAL_CALL SwXMLImportContent_getSupportedServiceNames()
+ throw()
+{
+ const OUString aServiceName( SwXMLImportContent_getImplementationName() );
+ const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
+ return aSeq;
+}
+
+uno::Reference< uno::XInterface > SAL_CALL SwXMLImportContent_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
+ throw( uno::Exception )
+{
+ return (cppu::OWeakObject*)new SwXMLImport(
+ IMPORT_AUTOSTYLES | IMPORT_CONTENT | IMPORT_SCRIPTS |
+ IMPORT_FONTDECLS );
+}
+
+OUString SAL_CALL SwXMLImportMeta_getImplementationName() throw()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.comp.Writer.XMLMetaImporter" ) );
+}
+
+uno::Sequence< OUString > SAL_CALL SwXMLImportMeta_getSupportedServiceNames()
+ throw()
+{
+ const OUString aServiceName( SwXMLImportMeta_getImplementationName() );
+ const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
+ return aSeq;
+}
+
+uno::Reference< uno::XInterface > SAL_CALL SwXMLImportMeta_createInstance(
const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
throw( uno::Exception )
{
- return (cppu::OWeakObject*)new SwXMLImport;
+ return (cppu::OWeakObject*)new SwXMLImport( IMPORT_META );
}
diff --git a/sw/source/filter/xml/xmlimp.hxx b/sw/source/filter/xml/xmlimp.hxx
index e3f6f49c1465..554da4f1deb1 100644
--- a/sw/source/filter/xml/xmlimp.hxx
+++ b/sw/source/filter/xml/xmlimp.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: xmlimp.hxx,v $
*
- * $Revision: 1.13 $
+ * $Revision: 1.14 $
*
- * last change: $Author: mib $ $Date: 2001-01-18 12:39:02 $
+ * last change: $Author: dvo $ $Date: 2001-03-02 21:02:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -136,7 +136,7 @@ protected:
public:
- SwXMLImport();
+ SwXMLImport(sal_uInt16 nImportFlags = IMPORT_ALL);
#ifdef XML_CORE_API
SwXMLImport( SwDoc& rDoc, const SwPaM& rPaM, sal_Bool bLoadDoc,
sal_Bool bInsertMode, sal_uInt16 nStyleFamMask,