1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SwXMLTextBlocks1.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
33 #include <com/sun/star/embed/ElementModes.hpp>
34 #include <com/sun/star/embed/XTransactedObject.hpp>
35 #include <svtools/macitem.hxx>
36 #include <svtools/unoevent.hxx>
37 #include <sfx2/docfile.hxx>
38 #include <unotools/streamwrap.hxx>
39 #include <comphelper/processfactory.hxx>
40 #include <com/sun/star/xml/sax/InputSource.hpp>
41 #include <com/sun/star/io/XActiveDataSource.hpp>
42 #include <com/sun/star/xml/sax/XParser.hpp>
43 #include <com/sun/star/document/XStorageBasedDocument.hpp>
48 #include <shellio.hxx>
49 #include <SwXMLTextBlocks.hxx>
50 #include <SwXMLBlockImport.hxx>
51 #include <SwXMLBlockExport.hxx>
52 #include <swevent.hxx>
57 #define STREAM_STGREAD ( STREAM_READ | STREAM_SHARE_DENYWRITE | STREAM_NOCREATE )
58 #define STREAM_STGWRITE ( STREAM_READ | STREAM_WRITE | STREAM_SHARE_DENYWRITE )
60 sal_Char __FAR_DATA XMLN_BLOCKLIST
[] = "BlockList.xml";
62 using namespace ::com::sun::star
;
63 using namespace ::com::sun::star::uno
;
64 using namespace ::com::sun::star::container
;
65 using ::rtl::OUString
;
67 using ::xmloff::token::XML_BLOCK_LIST
;
68 using ::xmloff::token::XML_UNFORMATTED_TEXT
;
69 using ::xmloff::token::GetXMLToken
;
71 ULONG
SwXMLTextBlocks::GetDoc( USHORT nIdx
)
73 String
aFolderName ( GetPackageName ( nIdx
) );
75 if (!IsOnlyTextBlock ( nIdx
) )
79 xRoot
= xBlkRoot
->openStorageElement( aFolderName
, embed::ElementModes::READ
);
80 xMedium
= new SfxMedium(xRoot
, GetBaseURL());
81 SwReader
aReader(*xMedium
,aFolderName
, pDoc
);
82 ReadXML
->SetBlockMode( sal_True
);
83 aReader
.Read( *ReadXML
);
84 ReadXML
->SetBlockMode( sal_False
);
85 // Ole objects fails to display when inserted into document
86 // because the ObjectReplacement folder ( and contents are missing )
87 rtl::OUString
sObjReplacements( RTL_CONSTASCII_USTRINGPARAM( "ObjectReplacements" ) );
88 if ( xRoot
->hasByName( sObjReplacements
) )
90 uno::Reference
< document::XStorageBasedDocument
> xDocStor( pDoc
->GetDocShell()->GetModel(), uno::UNO_QUERY_THROW
);
91 uno::Reference
< embed::XStorage
> xStr( xDocStor
->getDocumentStorage() );
94 xRoot
->copyElementTo( sObjReplacements
, xStr
, sObjReplacements
);
95 uno::Reference
< embed::XTransactedObject
> xTrans( xStr
, uno::UNO_QUERY
);
101 catch( uno::Exception
& )
109 String aStreamName
= aFolderName
+ (OUString
) String::CreateFromAscii(".xml");
112 xRoot
= xBlkRoot
->openStorageElement( aFolderName
, embed::ElementModes::READ
);
113 uno::Reference
< io::XStream
> xStream
= xRoot
->openStreamElement( aStreamName
, embed::ElementModes::READ
);
115 uno::Reference
< lang::XMultiServiceFactory
> xServiceFactory
=
116 comphelper::getProcessServiceFactory();
117 ASSERT( xServiceFactory
.is(), "XMLReader::Read: got no service manager" );
118 if( !xServiceFactory
.is() )
120 // Throw an exception ?
123 xml::sax::InputSource aParserInput
;
124 aParserInput
.sSystemId
= aNames
[ nIdx
] ->aPackageName
;
126 aParserInput
.aInputStream
= xStream
->getInputStream();
129 uno::Reference
< XInterface
> xXMLParser
= xServiceFactory
->createInstance(
130 OUString::createFromAscii("com.sun.star.xml.sax.Parser") );
131 ASSERT( xXMLParser
.is(),
132 "XMLReader::Read: com.sun.star.xml.sax.Parser service missing" );
133 if( !xXMLParser
.is() )
135 // Maybe throw an exception?
140 // uno::Reference< xml::sax::XDocumentHandler > xFilter = new SwXMLTextBlockImport( *this, aCur, sal_True );
141 uno::Reference
< xml::sax::XDocumentHandler
> xFilter
= new SwXMLTextBlockImport( xServiceFactory
, *this, aCur
, sal_True
);
143 // connect parser and filter
144 uno::Reference
< xml::sax::XParser
> xParser( xXMLParser
, UNO_QUERY
);
145 xParser
->setDocumentHandler( xFilter
);
150 xParser
->parseStream( aParserInput
);
152 catch( xml::sax::SAXParseException
& )
156 catch( xml::sax::SAXException
& )
160 catch( io::IOException
& )
165 bInfoChanged
= FALSE
;
168 catch( uno::Exception
& )
177 // event description for autotext events; this constant should really be
178 // taken from unocore/unoevents.cxx or ui/unotxt.cxx
179 const struct SvEventDescription aAutotextEvents
[] =
181 { SW_EVENT_START_INS_GLOSSARY
, "OnInsertStart" },
182 { SW_EVENT_END_INS_GLOSSARY
, "OnInsertDone" },
186 ULONG
SwXMLTextBlocks::GetMacroTable( USHORT nIdx
,
187 SvxMacroTableDtor
& rMacroTbl
,
188 sal_Bool bFileAlreadyOpen
)
190 // set current auto text
192 aShort
= aNames
[ nIdx
]->aShort
;
193 aLong
= aNames
[ nIdx
]->aLong
;
194 aPackageName
= aNames
[ nIdx
]->aPackageName
;
198 // open stream in proper sub-storage
199 if( !bFileAlreadyOpen
)
202 nRet
= OpenFile ( TRUE
);
208 xRoot
= xBlkRoot
->openStorageElement( aPackageName
, embed::ElementModes::READ
);
209 long nTmp
= SOT_FORMATSTR_ID_STARWRITER_60
;
210 sal_Bool bOasis
= ( SotStorage::GetVersion( xRoot
) > nTmp
);
212 OUString sStreamName
= OUString::createFromAscii("atevent.xml");
213 uno::Reference
< io::XStream
> xDocStream
= xRoot
->openStreamElement(
214 sStreamName
, embed::ElementModes::READ
);
215 DBG_ASSERT(xDocStream
.is(), "Can't create stream");
216 if ( xDocStream
.is() )
218 uno::Reference
<io::XInputStream
> xInputStream
= xDocStream
->getInputStream();
220 // prepare ParserInputSrouce
221 xml::sax::InputSource aParserInput
;
222 aParserInput
.sSystemId
= aName
;
223 aParserInput
.aInputStream
= xInputStream
;
225 // get service factory
226 uno::Reference
< lang::XMultiServiceFactory
> xServiceFactory
=
227 comphelper::getProcessServiceFactory();
228 if ( xServiceFactory
.is() )
232 OUString
sParserService( RTL_CONSTASCII_USTRINGPARAM(
233 "com.sun.star.xml.sax.Parser" ) );
234 uno::Reference
< xml::sax::XParser
> xParser(
235 xServiceFactory
->createInstance(sParserService
),
237 DBG_ASSERT( xParser
.is(), "Can't create parser" );
240 // create descriptor and reference to it. Either
241 // both or neither must be kept because of the
242 // reference counting!
243 SvMacroTableEventDescriptor
* pDescriptor
=
244 new SvMacroTableEventDescriptor(aAutotextEvents
);
245 uno::Reference
<XNameReplace
> xReplace
= pDescriptor
;
246 Sequence
<Any
> aFilterArguments( 1 );
247 aFilterArguments
[0] <<= xReplace
;
250 OUString
sFilterComponent( OUString::createFromAscii(
252 ? "com.sun.star.comp.Writer.XMLOasisAutotextEventsImporter"
253 : "com.sun.star.comp.Writer.XMLAutotextEventsImporter"));
254 uno::Reference
< xml::sax::XDocumentHandler
> xFilter(
255 xServiceFactory
->createInstanceWithArguments(
256 sFilterComponent
, aFilterArguments
),
258 DBG_ASSERT( xFilter
.is(),
259 "can't instantiate atevents filter");
262 // connect parser and filter
263 xParser
->setDocumentHandler( xFilter
);
265 // connect model and filter
266 uno::Reference
<document::XImporter
> xImporter( xFilter
,
269 // we don't need a model
270 // xImporter->setTargetDocument( xModelComponent );
275 xParser
->parseStream( aParserInput
);
277 catch( xml::sax::SAXParseException
& )
279 // workaround for #83452#: SetSize doesn't work
280 // nRet = ERR_SWG_READ_ERROR;
282 catch( xml::sax::SAXException
& )
284 nRet
= ERR_SWG_READ_ERROR
;
286 catch( io::IOException
& )
288 nRet
= ERR_SWG_READ_ERROR
;
291 // and finally, copy macro into table
293 pDescriptor
->copyMacrosIntoTable(rMacroTbl
);
296 nRet
= ERR_SWG_READ_ERROR
;
299 nRet
= ERR_SWG_READ_ERROR
;
303 nRet
= ERR_SWG_READ_ERROR
;
306 nRet
= ERR_SWG_READ_ERROR
;
308 catch( uno::Exception
& )
310 nRet
= ERR_SWG_READ_ERROR
;
314 nRet
= ERR_SWG_READ_ERROR
;
321 ULONG
SwXMLTextBlocks::GetBlockText( const String
& rShort
, String
& rText
)
324 sal_Bool bTextOnly
= sal_True
;
326 GeneratePackageName ( rShort
, aFolderName
);
327 String aStreamName
= aFolderName
+ (OUString
) String::CreateFromAscii(".xml");
332 xRoot
= xBlkRoot
->openStorageElement( aFolderName
, embed::ElementModes::READ
);
333 uno::Reference
< container::XNameAccess
> xAccess( xRoot
, uno::UNO_QUERY
);
334 if ( !xAccess
->hasByName( aStreamName
) || !xRoot
->isStreamElement( aStreamName
) )
336 bTextOnly
= sal_False
;
337 aStreamName
= String::CreateFromAscii("content.xml");
340 uno::Reference
< io::XStream
> xContents
= xRoot
->openStreamElement( aStreamName
, embed::ElementModes::READ
);
341 uno::Reference
< lang::XMultiServiceFactory
> xServiceFactory
=
342 comphelper::getProcessServiceFactory();
343 ASSERT( xServiceFactory
.is(), "XMLReader::Read: got no service manager" );
344 if( !xServiceFactory
.is() )
346 // Throw an exception ?
349 xml::sax::InputSource aParserInput
;
350 aParserInput
.sSystemId
= aName
;
351 aParserInput
.aInputStream
= xContents
->getInputStream();
354 uno::Reference
< XInterface
> xXMLParser
= xServiceFactory
->createInstance(
355 OUString::createFromAscii("com.sun.star.xml.sax.Parser") );
356 ASSERT( xXMLParser
.is(),
357 "XMLReader::Read: com.sun.star.xml.sax.Parser service missing" );
358 if( !xXMLParser
.is() )
360 // Maybe throw an exception?
365 // uno::Reference< xml::sax::XDocumentHandler > xFilter = new SwXMLTextBlockImport( *this, rText, bTextOnly );
366 uno::Reference
< xml::sax::XDocumentHandler
> xFilter
= new SwXMLTextBlockImport( xServiceFactory
, *this, rText
, bTextOnly
);
368 // connect parser and filter
369 uno::Reference
< xml::sax::XParser
> xParser( xXMLParser
, UNO_QUERY
);
370 xParser
->setDocumentHandler( xFilter
);
375 xParser
->parseStream( aParserInput
);
377 catch( xml::sax::SAXParseException
& )
381 catch( xml::sax::SAXException
& )
385 catch( io::IOException
& )
392 catch ( uno::Exception
& )
394 ASSERT( sal_False
, "Tried to open non-existent folder or stream!");
400 ULONG
SwXMLTextBlocks::PutBlockText( const String
& rShort
, const String
& ,
401 const String
& rText
, const String
& rPackageName
)
405 if (xBlkRoot->IsContained ( rPackageName ) )
407 xBlkRoot->Remove ( rPackageName );
408 xBlkRoot->Commit ( );
411 String
aFolderName( rPackageName
);
412 String aStreamName
= aFolderName
+ (OUString
) String::CreateFromAscii(".xml");
414 uno::Reference
< lang::XMultiServiceFactory
> xServiceFactory
=
415 comphelper::getProcessServiceFactory();
416 ASSERT( xServiceFactory
.is(),
417 "XMLReader::Read: got no service manager" );
418 if( !xServiceFactory
.is() )
420 // Throw an exception ?
423 uno::Reference
< XInterface
> xWriter (xServiceFactory
->createInstance(
424 OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.sax.Writer"))));
425 DBG_ASSERT(xWriter
.is(),"com.sun.star.xml.sax.Writer service missing");
430 xRoot
= xBlkRoot
->openStorageElement( aFolderName
, embed::ElementModes::WRITE
);
431 uno::Reference
< io::XStream
> xDocStream
= xRoot
->openStreamElement( aStreamName
,
432 embed::ElementModes::WRITE
| embed::ElementModes::TRUNCATE
);
434 uno::Reference
< beans::XPropertySet
> xSet( xDocStream
, uno::UNO_QUERY
);
435 String
aPropName( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM("MediaType") ) );
436 OUString
aMime ( RTL_CONSTASCII_USTRINGPARAM ( "text/xml") );
439 xSet
->setPropertyValue( aPropName
, aAny
);
440 uno::Reference
< io::XOutputStream
> xOut
= xDocStream
->getOutputStream();
441 uno::Reference
<io::XActiveDataSource
> xSrc(xWriter
, uno::UNO_QUERY
);
442 xSrc
->setOutputStream(xOut
);
444 uno::Reference
<xml::sax::XDocumentHandler
> xHandler(xWriter
,
448 // SwXMLTextBlockExport aExp(*this, GetXMLToken ( XML_UNFORMATTED_TEXT ), xHandler);
449 SwXMLTextBlockExport
aExp( xServiceFactory
, *this, GetXMLToken ( XML_UNFORMATTED_TEXT
), xHandler
);
451 aExp
.exportDoc( rText
);
453 uno::Reference
< embed::XTransactedObject
> xTrans( xRoot
, uno::UNO_QUERY
);
457 if (! (nFlags
& SWXML_NOROOTCOMMIT
) )
459 uno::Reference
< embed::XTransactedObject
> xTmpTrans( xBlkRoot
, uno::UNO_QUERY
);
460 if ( xTmpTrans
.is() )
464 catch ( uno::Exception
& )
466 nRes
= ERR_SWG_WRITE_ERROR
;
471 //TODO/LATER: error handling
473 ULONG nErr = xBlkRoot->GetError();
475 if( nErr == SVSTREAM_DISK_FULL )
476 nRes = ERR_W4W_WRITE_FULL;
477 else if( nErr != SVSTREAM_OK )
478 nRes = ERR_SWG_WRITE_ERROR;
480 if( !nRes
) // damit ueber GetText & nCur aufs Doc zugegriffen
481 MakeBlockText( rText
);
486 void SwXMLTextBlocks::ReadInfo( void )
490 const OUString
sDocName( RTL_CONSTASCII_USTRINGPARAM( XMLN_BLOCKLIST
) );
491 uno::Reference
< container::XNameAccess
> xAccess( xBlkRoot
, uno::UNO_QUERY
);
492 if ( xAccess
.is() && xAccess
->hasByName( sDocName
) && xBlkRoot
->isStreamElement( sDocName
) )
494 uno::Reference
< lang::XMultiServiceFactory
> xServiceFactory
=
495 comphelper::getProcessServiceFactory();
496 ASSERT( xServiceFactory
.is(),
497 "XMLReader::Read: got no service manager" );
498 if( !xServiceFactory
.is() )
500 // Throw an exception ?
503 xml::sax::InputSource aParserInput
;
504 aParserInput
.sSystemId
= sDocName
;
506 uno::Reference
< io::XStream
> xDocStream
= xBlkRoot
->openStreamElement( sDocName
, embed::ElementModes::READ
);
507 aParserInput
.aInputStream
= xDocStream
->getInputStream();
510 uno::Reference
< XInterface
> xXMLParser
= xServiceFactory
->createInstance(
511 OUString::createFromAscii("com.sun.star.xml.sax.Parser") );
512 ASSERT( xXMLParser
.is(),
513 "XMLReader::Read: com.sun.star.xml.sax.Parser service missing" );
514 if( !xXMLParser
.is() )
516 // Maybe throw an exception?
521 // uno::Reference< xml::sax::XDocumentHandler > xFilter = new SwXMLBlockListImport( *this );
522 uno::Reference
< xml::sax::XDocumentHandler
> xFilter
= new SwXMLBlockListImport( xServiceFactory
, *this );
524 // connect parser and filter
525 uno::Reference
< xml::sax::XParser
> xParser( xXMLParser
, UNO_QUERY
);
526 xParser
->setDocumentHandler( xFilter
);
531 xParser
->parseStream( aParserInput
);
533 catch( xml::sax::SAXParseException
& )
537 catch( xml::sax::SAXException
& )
541 catch( io::IOException
& )
547 catch ( uno::Exception
& )
551 void SwXMLTextBlocks::WriteInfo( void )
553 if ( xBlkRoot
.is() || 0 == OpenFile ( FALSE
) )
555 uno::Reference
< lang::XMultiServiceFactory
> xServiceFactory
=
556 comphelper::getProcessServiceFactory();
557 DBG_ASSERT( xServiceFactory
.is(),
558 "XMLReader::Read: got no service manager" );
559 if( !xServiceFactory
.is() )
561 // Throw an exception ?
564 uno::Reference
< XInterface
> xWriter (xServiceFactory
->createInstance(
565 OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.sax.Writer"))));
566 DBG_ASSERT(xWriter
.is(),"com.sun.star.xml.sax.Writer service missing");
567 OUString
sDocName( RTL_CONSTASCII_USTRINGPARAM( XMLN_BLOCKLIST
) );
570 if ( xBlkRoot->IsContained( sDocName) )
572 xBlkRoot->Remove ( sDocName );
579 uno::Reference
< io::XStream
> xDocStream
= xBlkRoot
->openStreamElement( sDocName
,
580 embed::ElementModes::WRITE
| embed::ElementModes::TRUNCATE
);
582 uno::Reference
< beans::XPropertySet
> xSet( xDocStream
, uno::UNO_QUERY
);
583 String
aPropName( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM("MediaType") ) );
584 OUString
aMime ( RTL_CONSTASCII_USTRINGPARAM ( "text/xml") );
587 xSet
->setPropertyValue( aPropName
, aAny
);
588 uno::Reference
< io::XOutputStream
> xOut
= xDocStream
->getOutputStream();
589 uno::Reference
<io::XActiveDataSource
> xSrc(xWriter
, uno::UNO_QUERY
);
590 xSrc
->setOutputStream(xOut
);
592 uno::Reference
<xml::sax::XDocumentHandler
> xHandler(xWriter
, uno::UNO_QUERY
);
595 // SwXMLBlockListExport aExp(*this, OUString::createFromAscii(XMLN_BLOCKLIST), xHandler);
596 SwXMLBlockListExport
aExp( xServiceFactory
, *this, OUString::createFromAscii(XMLN_BLOCKLIST
), xHandler
);
598 aExp
.exportDoc( XML_BLOCK_LIST
);
600 uno::Reference
< embed::XTransactedObject
> xTrans( xBlkRoot
, uno::UNO_QUERY
);
604 catch ( uno::Exception
& )
608 bInfoChanged
= FALSE
;
613 ULONG
SwXMLTextBlocks::SetMacroTable(
615 const SvxMacroTableDtor
& rMacroTbl
,
616 sal_Bool bFileAlreadyOpen
)
618 // set current autotext
619 aShort
= aNames
[ nIdx
]->aShort
;
620 aLong
= aNames
[ nIdx
]->aLong
;
621 aPackageName
= aNames
[ nIdx
]->aPackageName
;
623 // start XML autotext event export
626 uno::Reference
< lang::XMultiServiceFactory
> xServiceFactory
=
627 comphelper::getProcessServiceFactory();
628 ASSERT( xServiceFactory
.is(),
629 "XML autotext event write:: got no service manager" );
630 if( !xServiceFactory
.is() )
631 return ERR_SWG_WRITE_ERROR
;
634 uno::Reference
< lang::XComponent
> xModelComp(
635 pDoc
->GetDocShell()->GetModel(), UNO_QUERY
);
636 ASSERT( xModelComp
.is(), "XMLWriter::Write: got no model" );
637 if( !xModelComp
.is() )
638 return ERR_SWG_WRITE_ERROR
;
640 // open stream in proper sub-storage
641 if( !bFileAlreadyOpen
)
643 CloseFile(); // close (it may be open in read-only-mode)
644 nRes
= OpenFile ( FALSE
);
651 xRoot
= xBlkRoot
->openStorageElement( aPackageName
, embed::ElementModes::WRITE
);
652 OUString
sStreamName( RTL_CONSTASCII_USTRINGPARAM("atevent.xml") );
653 long nTmp
= SOT_FORMATSTR_ID_STARWRITER_60
;
654 sal_Bool bOasis
= ( SotStorage::GetVersion( xRoot
) > nTmp
);
656 uno::Reference
< io::XStream
> xDocStream
= xRoot
->openStreamElement( sStreamName
,
657 embed::ElementModes::WRITE
| embed::ElementModes::TRUNCATE
);
659 uno::Reference
< beans::XPropertySet
> xSet( xDocStream
, uno::UNO_QUERY
);
660 String
aPropName( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM("MediaType") ) );
661 OUString
aMime ( RTL_CONSTASCII_USTRINGPARAM ( "text/xml") );
664 xSet
->setPropertyValue( aPropName
, aAny
);
665 uno::Reference
< io::XOutputStream
> xOutputStream
= xDocStream
->getOutputStream();
668 uno::Reference
< io::XActiveDataSource
> xSaxWriter(
669 xServiceFactory
->createInstance(
670 OUString::createFromAscii("com.sun.star.xml.sax.Writer") ),
672 ASSERT( xSaxWriter
.is(), "can't instantiate XML writer" );
673 if( xSaxWriter
.is() )
676 // connect XML writer to output stream
677 xSaxWriter
->setOutputStream( xOutputStream
);
678 uno::Reference
<xml::sax::XDocumentHandler
> xDocHandler(
679 xSaxWriter
, UNO_QUERY
);
681 // construct events object
682 uno::Reference
<XNameAccess
> xEvents
=
683 new SvMacroTableEventDescriptor(rMacroTbl
,aAutotextEvents
);
685 // prepare arguments (prepend doc handler to given arguments)
686 Sequence
<Any
> aParams(2);
687 aParams
[0] <<= xDocHandler
;
688 aParams
[1] <<= xEvents
;
690 // get filter component
691 uno::Reference
< document::XExporter
> xExporter(
692 xServiceFactory
->createInstanceWithArguments(
693 OUString::createFromAscii(
695 ? "com.sun.star.comp.Writer.XMLOasisAutotextEventsExporter"
696 : "com.sun.star.comp.Writer.XMLAutotextEventsExporter"),
697 aParams
), UNO_QUERY
);
698 ASSERT( xExporter
.is(),
699 "can't instantiate export filter component" );
702 // connect model and filter
703 xExporter
->setSourceDocument( xModelComp
);
706 Sequence
<beans::PropertyValue
> aFilterProps( 0 );
707 uno::Reference
< document::XFilter
> xFilter( xExporter
,
709 xFilter
->filter( aFilterProps
);
712 nRes
= ERR_SWG_WRITE_ERROR
;
715 nRes
= ERR_SWG_WRITE_ERROR
;
717 // finally, commit stream, sub-storage and storage
718 uno::Reference
< embed::XTransactedObject
> xTmpTrans( xRoot
, uno::UNO_QUERY
);
719 if ( xTmpTrans
.is() )
722 if ( !bFileAlreadyOpen
)
724 uno::Reference
< embed::XTransactedObject
> xTrans( xBlkRoot
, uno::UNO_QUERY
);
731 catch ( uno::Exception
& )
733 nRes
= ERR_SWG_WRITE_ERROR
;
736 if( !bFileAlreadyOpen
)
740 nRes
= ERR_SWG_WRITE_ERROR
;