diff options
Diffstat (limited to 'editeng/source/xml')
-rw-r--r-- | editeng/source/xml/editsource.hxx | 46 | ||||
-rw-r--r-- | editeng/source/xml/xmltxtexp.cxx | 358 | ||||
-rw-r--r-- | editeng/source/xml/xmltxtimp.cxx | 254 |
3 files changed, 658 insertions, 0 deletions
diff --git a/editeng/source/xml/editsource.hxx b/editeng/source/xml/editsource.hxx new file mode 100644 index 000000000..51d5fc968 --- /dev/null +++ b/editeng/source/xml/editsource.hxx @@ -0,0 +1,46 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_EDITENG_SOURCE_XML_EDITSOURCE_HXX +#define INCLUDED_EDITENG_SOURCE_XML_EDITSOURCE_HXX + +#include <editeng/unoedsrc.hxx> + +class EditEngine; +class SvxEditEngineSourceImpl; + +class SvxEditEngineSource : public SvxEditSource +{ +public: + explicit SvxEditEngineSource( EditEngine* pEditEngine ); + virtual ~SvxEditEngineSource() override; + + virtual std::unique_ptr<SvxEditSource> Clone() const override; + virtual SvxTextForwarder* GetTextForwarder() override; + virtual void UpdateData() override; + +private: + explicit SvxEditEngineSource( SvxEditEngineSourceImpl* pImpl ); + + rtl::Reference<SvxEditEngineSourceImpl> mxImpl; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/source/xml/xmltxtexp.cxx b/editeng/source/xml/xmltxtexp.cxx new file mode 100644 index 000000000..f5303cd7b --- /dev/null +++ b/editeng/source/xml/xmltxtexp.cxx @@ -0,0 +1,358 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + + +/** this file implements an export of a selected EditEngine content into + a xml stream. See editeng/source/inc/xmledit.hxx for interface */ +#include <memory> +#include <com/sun/star/ucb/XAnyCompareFactory.hpp> +#include <com/sun/star/style/XStyleFamiliesSupplier.hpp> +#include <com/sun/star/lang/Locale.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/xml/sax/Writer.hpp> +#include <com/sun/star/frame/XModel.hpp> +#include <svl/itemprop.hxx> +#include <com/sun/star/uno/Sequence.hxx> +#include <xmloff/xmlmetae.hxx> +#include <comphelper/processfactory.hxx> +#include <tools/diagnose_ex.h> +#include <unotools/streamwrap.hxx> +#include <xmloff/xmlexp.hxx> +#include <editeng/unoedsrc.hxx> +#include <editeng/unofored.hxx> +#include <editeng/unotext.hxx> +#include <editeng/unoprnms.hxx> +#include <editeng/unofield.hxx> +#include <editeng/editeng.hxx> +#include "editsource.hxx" +#include <editxml.hxx> +#include <editeng/unonrule.hxx> +#include <editeng/unoipset.hxx> +#include <unomodel.hxx> + +using namespace com::sun::star; +using namespace com::sun::star::container; +using namespace com::sun::star::document; +using namespace com::sun::star::uno; +using namespace com::sun::star::awt; +using namespace com::sun::star::lang; +using namespace com::sun::star::xml::sax; +using namespace cppu; + +class SvxEditEngineSourceImpl; + +class SvxEditEngineSourceImpl : public salhelper::SimpleReferenceObject +{ +private: + EditEngine* mpEditEngine; + std::unique_ptr<SvxTextForwarder> mpTextForwarder; + + virtual ~SvxEditEngineSourceImpl() override; + +public: + explicit SvxEditEngineSourceImpl( EditEngine* pEditEngine ); + + SvxTextForwarder* GetTextForwarder(); +}; + +SvxEditEngineSourceImpl::SvxEditEngineSourceImpl( EditEngine* pEditEngine ) +: mpEditEngine( pEditEngine ) +{ +} + +SvxEditEngineSourceImpl::~SvxEditEngineSourceImpl() +{ +} + +SvxTextForwarder* SvxEditEngineSourceImpl::GetTextForwarder() +{ + if (!mpTextForwarder) + mpTextForwarder.reset( new SvxEditEngineForwarder( *mpEditEngine ) ); + + return mpTextForwarder.get(); +} + +// SvxTextEditSource +SvxEditEngineSource::SvxEditEngineSource( EditEngine* pEditEngine ) + : mxImpl( new SvxEditEngineSourceImpl( pEditEngine ) ) +{ +} + +SvxEditEngineSource::SvxEditEngineSource( SvxEditEngineSourceImpl* pImpl ) + : mxImpl(pImpl) +{ +} + +SvxEditEngineSource::~SvxEditEngineSource() +{ +} + +std::unique_ptr<SvxEditSource> SvxEditEngineSource::Clone() const +{ + return std::unique_ptr<SvxEditSource>(new SvxEditEngineSource( mxImpl.get() )); +} + +SvxTextForwarder* SvxEditEngineSource::GetTextForwarder() +{ + return mxImpl->GetTextForwarder(); +} + + +void SvxEditEngineSource::UpdateData() +{ +} + + +SvxSimpleUnoModel::SvxSimpleUnoModel() +{ +} + +// XMultiServiceFactory ( SvxFmMSFactory ) +uno::Reference< uno::XInterface > SAL_CALL SvxSimpleUnoModel::createInstance( const OUString& aServiceSpecifier ) +{ + if( aServiceSpecifier == "com.sun.star.text.NumberingRules" ) + { + return uno::Reference< uno::XInterface >( + SvxCreateNumRule(), uno::UNO_QUERY ); + } + if ( aServiceSpecifier == "com.sun.star.text.textfield.DateTime" + || aServiceSpecifier == "com.sun.star.text.TextField.DateTime" + ) + { + return static_cast<cppu::OWeakObject *>(new SvxUnoTextField( text::textfield::Type::DATE )); + } + + if( aServiceSpecifier == "com.sun.star.text.TextField.URL" ) + { + return static_cast<cppu::OWeakObject *>(new SvxUnoTextField(text::textfield::Type::URL)); + } + + return SvxUnoTextCreateTextField( aServiceSpecifier ); + +} + +uno::Reference< css::uno::XInterface > SAL_CALL SvxSimpleUnoModel::createInstanceWithArguments( const OUString& ServiceSpecifier, const css::uno::Sequence< css::uno::Any >& ) +{ + return createInstance( ServiceSpecifier ); +} + +Sequence< OUString > SAL_CALL SvxSimpleUnoModel::getAvailableServiceNames( ) +{ + Sequence< OUString > aSeq; + return aSeq; +} + +// XAnyCompareFactory +uno::Reference< css::ucb::XAnyCompare > SAL_CALL SvxSimpleUnoModel::createAnyCompareByName( const OUString& ) +{ + return SvxCreateNumRuleCompare(); +} + +// XStyleFamiliesSupplier +uno::Reference< container::XNameAccess > SAL_CALL SvxSimpleUnoModel::getStyleFamilies( ) +{ + uno::Reference< container::XNameAccess > xStyles; + return xStyles; +} + +// XModel +sal_Bool SAL_CALL SvxSimpleUnoModel::attachResource( const OUString&, const css::uno::Sequence< css::beans::PropertyValue >& ) +{ + return false; +} + +OUString SAL_CALL SvxSimpleUnoModel::getURL( ) +{ + return OUString(); +} + +css::uno::Sequence< css::beans::PropertyValue > SAL_CALL SvxSimpleUnoModel::getArgs( ) +{ + Sequence< beans::PropertyValue > aSeq; + return aSeq; +} + +void SAL_CALL SvxSimpleUnoModel::connectController( const css::uno::Reference< css::frame::XController >& ) +{ +} + +void SAL_CALL SvxSimpleUnoModel::disconnectController( const css::uno::Reference< css::frame::XController >& ) +{ +} + +void SAL_CALL SvxSimpleUnoModel::lockControllers( ) +{ +} + +void SAL_CALL SvxSimpleUnoModel::unlockControllers( ) +{ +} + +sal_Bool SAL_CALL SvxSimpleUnoModel::hasControllersLocked( ) +{ + return true; +} + +css::uno::Reference< css::frame::XController > SAL_CALL SvxSimpleUnoModel::getCurrentController( ) +{ + uno::Reference< frame::XController > xRet; + return xRet; +} + +void SAL_CALL SvxSimpleUnoModel::setCurrentController( const css::uno::Reference< css::frame::XController >& ) +{ +} + +css::uno::Reference< css::uno::XInterface > SAL_CALL SvxSimpleUnoModel::getCurrentSelection( ) +{ + uno::Reference< XInterface > xRet; + return xRet; +} + + +// XComponent +void SAL_CALL SvxSimpleUnoModel::dispose( ) +{ +} + +void SAL_CALL SvxSimpleUnoModel::addEventListener( const css::uno::Reference< css::lang::XEventListener >& ) +{ +} + +void SAL_CALL SvxSimpleUnoModel::removeEventListener( const css::uno::Reference< css::lang::XEventListener >& ) +{ +} + +namespace { + +class SvxXMLTextExportComponent : public SvXMLExport +{ +public: + SvxXMLTextExportComponent( + const css::uno::Reference< css::uno::XComponentContext >& rContext, + EditEngine* pEditEngine, + const ESelection& rSel, + const OUString& rFileName, + const css::uno::Reference< css::xml::sax::XDocumentHandler >& rHandler ); + + // methods without content: + virtual void ExportAutoStyles_() override; + virtual void ExportMasterStyles_() override; + virtual void ExportContent_() override; + +private: + css::uno::Reference< css::text::XText > mxText; +}; + +} + +SvxXMLTextExportComponent::SvxXMLTextExportComponent( + const css::uno::Reference< css::uno::XComponentContext >& xContext, + EditEngine* pEditEngine, + const ESelection& rSel, + const OUString& rFileName, + const css::uno::Reference< css::xml::sax::XDocumentHandler > & xHandler) +: SvXMLExport( xContext, "", rFileName, xHandler, static_cast<frame::XModel*>(new SvxSimpleUnoModel()), FieldUnit::CM, + SvXMLExportFlags::OASIS | SvXMLExportFlags::AUTOSTYLES | SvXMLExportFlags::CONTENT ) +{ + SvxEditEngineSource aEditSource( pEditEngine ); + + static const SfxItemPropertyMapEntry SvxXMLTextExportComponentPropertyMap[] = + { + SVX_UNOEDIT_CHAR_PROPERTIES, + SVX_UNOEDIT_FONT_PROPERTIES, + { OUString(UNO_NAME_NUMBERING_RULES), EE_PARA_NUMBULLET, cppu::UnoType<css::container::XIndexReplace>::get(), 0, 0 }, + { OUString(UNO_NAME_NUMBERING), EE_PARA_BULLETSTATE,cppu::UnoType<bool>::get(), 0, 0 }, + { OUString(UNO_NAME_NUMBERING_LEVEL), EE_PARA_OUTLLEVEL, ::cppu::UnoType<sal_Int16>::get(), 0, 0 }, + SVX_UNOEDIT_PARA_PROPERTIES, + { OUString(), 0, css::uno::Type(), 0, 0 } + }; + static SvxItemPropertySet aSvxXMLTextExportComponentPropertySet( SvxXMLTextExportComponentPropertyMap, EditEngine::GetGlobalItemPool() ); + + SvxUnoText* pUnoText = new SvxUnoText( &aEditSource, &aSvxXMLTextExportComponentPropertySet, mxText ); + pUnoText->SetSelection( rSel ); + mxText = pUnoText; + +} + +void SvxWriteXML( EditEngine& rEditEngine, SvStream& rStream, const ESelection& rSel ) +{ + try + { + do + { + // create service factory + uno::Reference<uno::XComponentContext> xContext( ::comphelper::getProcessComponentContext() ); + + // create document handler + uno::Reference< xml::sax::XWriter > xWriter = xml::sax::Writer::create( xContext ); + + // create output stream and active data source + uno::Reference<io::XOutputStream> xOut( new utl::OOutputStreamWrapper( rStream ) ); + +/* testcode + const OUString aURL( "file:///e:/test.xml" ); + SvFileStream aStream(aURL, StreamMode::WRITE | StreamMode::TRUNC); + xOut = new utl::OOutputStreamWrapper(aStream); +*/ + + + xWriter->setOutputStream( xOut ); + + // export text + const OUString aName; + + // SvxXMLTextExportComponent aExporter( &rEditEngine, rSel, aName, xHandler ); + uno::Reference< xml::sax::XDocumentHandler > xHandler(xWriter, UNO_QUERY_THROW); + rtl::Reference< SvxXMLTextExportComponent > xExporter( new SvxXMLTextExportComponent( xContext, &rEditEngine, rSel, aName, xHandler ) ); + + xExporter->exportDoc(); + +/* testcode + aStream.Close(); +*/ + + } + while( false ); + } + catch( const uno::Exception& ) + { + TOOLS_WARN_EXCEPTION("editeng", "exception during xml export"); + } +} + +// methods without content: +void SvxXMLTextExportComponent::ExportAutoStyles_() +{ + rtl::Reference< XMLTextParagraphExport > xTextExport( GetTextParagraphExport() ); + + xTextExport->collectTextAutoStyles( mxText ); + xTextExport->exportTextAutoStyles(); +} + +void SvxXMLTextExportComponent::ExportContent_() +{ + rtl::Reference< XMLTextParagraphExport > xTextExport( GetTextParagraphExport() ); + + xTextExport->exportText( mxText ); +} + +void SvxXMLTextExportComponent::ExportMasterStyles_() {} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/source/xml/xmltxtimp.cxx b/editeng/source/xml/xmltxtimp.cxx new file mode 100644 index 000000000..6497ac2e9 --- /dev/null +++ b/editeng/source/xml/xmltxtimp.cxx @@ -0,0 +1,254 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <com/sun/star/text/XText.hpp> +#include <comphelper/processfactory.hxx> +#include <unotools/streamwrap.hxx> +#include <svl/itemprop.hxx> +#include <xmloff/xmlimp.hxx> +#include <xmloff/xmlictxt.hxx> +#include <xmloff/xmltoken.hxx> +#include <xmloff/xmlnmspe.hxx> +#include <xmloff/xmlstyle.hxx> +#include "editsource.hxx" +#include <editxml.hxx> +#include <editdoc.hxx> +#include <editeng/editeng.hxx> +#include <editeng/unotext.hxx> +#include <editeng/unoprnms.hxx> +#include <editeng/unoipset.hxx> +#include <cassert> +#include <unomodel.hxx> + +using namespace com::sun::star; +using namespace com::sun::star::document; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::xml::sax; +using namespace com::sun::star::text; +using namespace cppu; +using namespace xmloff::token; + +namespace { + +class SvxXMLTextImportContext : public SvXMLImportContext +{ +public: + SvxXMLTextImportContext( SvXMLImport& rImport, const uno::Reference< XText >& xText ); + + virtual SvXMLImportContextRef CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference< XAttributeList >& xAttrList ) override; + virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( + sal_Int32 nElement, + const uno::Reference< xml::sax::XFastAttributeList >& xAttrList) override; + virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {} + +private: + const uno::Reference< XText > mxText; +}; + +} + +SvxXMLTextImportContext::SvxXMLTextImportContext( SvXMLImport& rImport, const uno::Reference< XText >& xText ) +: SvXMLImportContext( rImport ), mxText( xText ) +{ +} + +css::uno::Reference< css::xml::sax::XFastContextHandler > SvxXMLTextImportContext::createFastChildContext( + sal_Int32 nElement, + const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/) +{ + SvXMLImportContext* pContext = nullptr; + if(nElement == XML_ELEMENT(OFFICE, XML_BODY )) + { + pContext = new SvxXMLTextImportContext( GetImport(), mxText ); + } + else if( nElement == XML_ELEMENT(OFFICE, XML_AUTOMATIC_STYLES ) ) + { + pContext = new SvXMLStylesContext( GetImport() ); + GetImport().GetTextImport()->SetAutoStyles( static_cast<SvXMLStylesContext*>(pContext) ); + } + return pContext; +} + +SvXMLImportContextRef SvxXMLTextImportContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference< XAttributeList >& xAttrList ) +{ + SvXMLImportContext* pContext = nullptr; + if(XML_NAMESPACE_OFFICE == nPrefix && IsXMLToken( rLocalName, XML_BODY ) ) + { + // dealt with in createFastChildContext + } + else if( XML_NAMESPACE_OFFICE == nPrefix && IsXMLToken( rLocalName, XML_AUTOMATIC_STYLES ) ) + { + // dealt with in createFastChildContext + } + else + { + pContext = GetImport().GetTextImport()->CreateTextChildContext( GetImport(), nPrefix, rLocalName, xAttrList ); + } + + return pContext; +} + +namespace { + +class SvxXMLXTextImportComponent : public SvXMLImport +{ +public: + SvxXMLXTextImportComponent( + const css::uno::Reference< css::uno::XComponentContext >& rContext, + const uno::Reference< XText > & rText ); + + virtual SvXMLImportContext* CreateFastContext(sal_Int32 nElement, + const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList >& xAttrList ) override; + +private: + const uno::Reference< XText > mxText; +}; + +} + +SvXMLImportContext *SvxXMLXTextImportComponent::CreateFastContext( + sal_Int32 nElement, + const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/) +{ + SvXMLImportContext* pContext = nullptr; + + if(nElement == XML_ELEMENT(OFFICE, XML_DOCUMENT_CONTENT ) ) + { + pContext = new SvxXMLTextImportContext( *this, mxText ); + } + + return pContext; +} + +SvxXMLXTextImportComponent::SvxXMLXTextImportComponent( + const css::uno::Reference< css::uno::XComponentContext >& xContext, + const uno::Reference< XText > & xText ) +: SvXMLImport(xContext, ""), + mxText( xText ) +{ + GetTextImport()->SetCursor( mxText->createTextCursor() ); + SvXMLImport::setTargetDocument(new SvxSimpleUnoModel); +} + +EditPaM SvxReadXML( EditEngine& rEditEngine, SvStream& rStream, const ESelection& rSel ) +{ + SvxEditEngineSource aEditSource( &rEditEngine ); + + static const SfxItemPropertyMapEntry SvxXMLTextImportComponentPropertyMap[] = + { + SVX_UNOEDIT_CHAR_PROPERTIES, + SVX_UNOEDIT_FONT_PROPERTIES, +// bullets & numbering props, tdf#128046 + { OUString(UNO_NAME_NUMBERING_RULES), EE_PARA_NUMBULLET, cppu::UnoType<css::container::XIndexReplace>::get(), 0, 0 }, + { OUString(UNO_NAME_NUMBERING), EE_PARA_BULLETSTATE,cppu::UnoType<bool>::get(), 0, 0 }, + { OUString(UNO_NAME_NUMBERING_LEVEL), EE_PARA_OUTLLEVEL, ::cppu::UnoType<sal_Int16>::get(), 0, 0 }, + SVX_UNOEDIT_PARA_PROPERTIES, + { OUString(), 0, css::uno::Type(), 0, 0 } + }; + static SvxItemPropertySet aSvxXMLTextImportComponentPropertySet( SvxXMLTextImportComponentPropertyMap, EditEngine::GetGlobalItemPool() ); + + assert(!rSel.HasRange()); + //get the initial para count before paste + sal_uInt32 initialParaCount = rEditEngine.GetEditDoc().Count(); + //insert para breaks before inserting the copied text + rEditEngine.InsertParaBreak( rEditEngine.CreateSelection( rSel ).Max() ); + rEditEngine.InsertParaBreak( rEditEngine.CreateSelection( rSel ).Max() ); + + // Init return PaM. + EditPaM aPaM( rEditEngine.CreateSelection( rSel ).Max()); + + ESelection aSel(rSel.nStartPara+1, 0, rSel.nEndPara+1, 0); + uno::Reference<text::XText > xParent; + SvxUnoText* pUnoText = new SvxUnoText( &aEditSource, &aSvxXMLTextImportComponentPropertySet, xParent ); + pUnoText->SetSelection( aSel ); + uno::Reference<text::XText > xText( pUnoText ); + + try + { + do + { + uno::Reference<uno::XComponentContext> xContext( ::comphelper::getProcessComponentContext() ); + + uno::Reference<io::XInputStream> xInputStream = new utl::OInputStreamWrapper( rStream ); + +/* testcode + const OUString aURL( "file:///e:/test.xml" ); + SfxMedium aMedium( aURL, StreamMode::READ | STREAM_NOCREATE, sal_True ); + uno::Reference<io::XOutputStream> xOut( new utl::OOutputStreamWrapper( *aMedium.GetOutStream() ) ); + + aMedium.GetInStream()->Seek( 0 ); + uno::Reference< io::XActiveDataSource > xSource( aMedium.GetDataSource() ); + + if( !xSource.is() ) + { + OSL_FAIL( "got no data source from medium" ); + break; + } + + uno::Reference< XInterface > xPipe( Pipe::create(comphelper::getComponentContext(xServiceFactory)), UNO_QUERY ); + + // connect pipe's output stream to the data source + xSource->setOutputStream( uno::Reference< io::XOutputStream >::query( xPipe ) ); + + xml::sax::InputSource aParserInput; + aParserInput.aInputStream.set( xPipe, UNO_QUERY ); + aParserInput.sSystemId = aMedium.GetName(); + + + if( xSource.is() ) + { + uno::Reference< io::XActiveDataControl > xSourceControl( xSource, UNO_QUERY ); + xSourceControl->start(); + } + +*/ + + // uno::Reference< XDocumentHandler > xHandler( new SvxXMLXTextImportComponent( xText ) ); + rtl::Reference< SvxXMLXTextImportComponent > xImport( new SvxXMLXTextImportComponent( xContext, xText ) ); + + xml::sax::InputSource aParserInput; + aParserInput.aInputStream = xInputStream; +// aParserInput.sSystemId = aMedium.GetName(); + xImport->parseStream( aParserInput ); + } + while(false); + + //remove the extra para breaks + EditDoc& pDoc = rEditEngine.GetEditDoc(); + rEditEngine.ParaAttribsToCharAttribs( pDoc.GetObject( rSel.nEndPara ) ); + rEditEngine.ConnectParagraphs( pDoc.GetObject( rSel.nEndPara ), + pDoc.GetObject( rSel.nEndPara + 1 ), true ); + rEditEngine.ParaAttribsToCharAttribs( pDoc.GetObject( pDoc.Count() - initialParaCount + aSel.nEndPara - 2 ) ); + rEditEngine.ConnectParagraphs( pDoc.GetObject( pDoc.Count() - initialParaCount + aSel.nEndPara - 2 ), + pDoc.GetObject( pDoc.Count() - initialParaCount + aSel.nEndPara -1 ), true ); + + // The final join is to be returned. + aPaM = rEditEngine.ConnectParagraphs( pDoc.GetObject( pDoc.Count() - initialParaCount + aSel.nEndPara - 2 ), + pDoc.GetObject( pDoc.Count() - initialParaCount + aSel.nEndPara -1 ), true ); + } + catch( const uno::Exception& ) + { + } + + return aPaM; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |