1*190118d0SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*190118d0SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*190118d0SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*190118d0SAndrew Rist * distributed with this work for additional information 6*190118d0SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*190118d0SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*190118d0SAndrew Rist * "License"); you may not use this file except in compliance 9*190118d0SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*190118d0SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*190118d0SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*190118d0SAndrew Rist * software distributed under the License is distributed on an 15*190118d0SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*190118d0SAndrew Rist * KIND, either express or implied. See the License for the 17*190118d0SAndrew Rist * specific language governing permissions and limitations 18*190118d0SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*190118d0SAndrew Rist *************************************************************/ 21*190118d0SAndrew Rist 22*190118d0SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_editeng.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir /** this file implements an export of a selected EditEngine content into 28cdf0e10cSrcweir a xml stream. See editeng/source/inc/xmledit.hxx for interface */ 29cdf0e10cSrcweir #include <com/sun/star/ucb/XAnyCompareFactory.hpp> 30cdf0e10cSrcweir #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> 31cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 32cdf0e10cSrcweir #include <com/sun/star/io/XActiveDataSource.hpp> 33cdf0e10cSrcweir #include <tools/debug.hxx> 34cdf0e10cSrcweir #include <svl/itemprop.hxx> 35cdf0e10cSrcweir #include <svl/brdcst.hxx> 36cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx> 37cdf0e10cSrcweir #include <sot/storage.hxx> 38cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 39cdf0e10cSrcweir #include <xmloff/xmluconv.hxx> 40cdf0e10cSrcweir #include <xmloff/xmlnmspe.hxx> 41cdf0e10cSrcweir #include <xmloff/nmspmap.hxx> 42cdf0e10cSrcweir #include <xmloff/xmlmetae.hxx> 43cdf0e10cSrcweir #include <cppuhelper/implbase4.hxx> 44cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 45cdf0e10cSrcweir #include <unotools/streamwrap.hxx> 46cdf0e10cSrcweir #include <xmloff/xmlexp.hxx> 47cdf0e10cSrcweir #include <editeng/unoedsrc.hxx> 48cdf0e10cSrcweir #include <editeng/unofored.hxx> 49cdf0e10cSrcweir #include <editeng/unotext.hxx> 50cdf0e10cSrcweir #include <editeng/unoprnms.hxx> 51cdf0e10cSrcweir #include <editeng/unofield.hxx> 52cdf0e10cSrcweir #include <editeng/editeng.hxx> 53cdf0e10cSrcweir #include "editsource.hxx" 54cdf0e10cSrcweir #include <editeng/unonrule.hxx> 55cdf0e10cSrcweir #include <editeng/unoipset.hxx> 56cdf0e10cSrcweir 57cdf0e10cSrcweir using namespace com::sun::star; 58cdf0e10cSrcweir using namespace com::sun::star::container; 59cdf0e10cSrcweir using namespace com::sun::star::document; 60cdf0e10cSrcweir using namespace com::sun::star::uno; 61cdf0e10cSrcweir using namespace com::sun::star::awt; 62cdf0e10cSrcweir using namespace com::sun::star::lang; 63cdf0e10cSrcweir using namespace com::sun::star::xml::sax; 64cdf0e10cSrcweir using namespace ::rtl; 65cdf0e10cSrcweir using namespace cppu; 66cdf0e10cSrcweir 67cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////// 68cdf0e10cSrcweir 69cdf0e10cSrcweir class SvxEditEngineSourceImpl; 70cdf0e10cSrcweir 71cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////// 72cdf0e10cSrcweir 73cdf0e10cSrcweir class SvxEditEngineSourceImpl 74cdf0e10cSrcweir { 75cdf0e10cSrcweir private: 76cdf0e10cSrcweir oslInterlockedCount maRefCount; 77cdf0e10cSrcweir 78cdf0e10cSrcweir EditEngine* mpEditEngine; 79cdf0e10cSrcweir SvxTextForwarder* mpTextForwarder; 80cdf0e10cSrcweir 81cdf0e10cSrcweir ~SvxEditEngineSourceImpl(); 82cdf0e10cSrcweir 83cdf0e10cSrcweir public: 84cdf0e10cSrcweir SvxEditEngineSourceImpl( EditEngine* pEditEngine ); 85cdf0e10cSrcweir 86cdf0e10cSrcweir void SAL_CALL acquire(); 87cdf0e10cSrcweir void SAL_CALL release(); 88cdf0e10cSrcweir 89cdf0e10cSrcweir SvxTextForwarder* GetTextForwarder(); 90cdf0e10cSrcweir }; 91cdf0e10cSrcweir 92cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////// 93cdf0e10cSrcweir 94cdf0e10cSrcweir 95cdf0e10cSrcweir //------------------------------------------------------------------------ 96cdf0e10cSrcweir 97cdf0e10cSrcweir SvxEditEngineSourceImpl::SvxEditEngineSourceImpl( EditEngine* pEditEngine ) 98cdf0e10cSrcweir : maRefCount(0), 99cdf0e10cSrcweir mpEditEngine( pEditEngine ), 100cdf0e10cSrcweir mpTextForwarder(NULL) 101cdf0e10cSrcweir { 102cdf0e10cSrcweir } 103cdf0e10cSrcweir 104cdf0e10cSrcweir //------------------------------------------------------------------------ 105cdf0e10cSrcweir 106cdf0e10cSrcweir SvxEditEngineSourceImpl::~SvxEditEngineSourceImpl() 107cdf0e10cSrcweir { 108cdf0e10cSrcweir delete mpTextForwarder; 109cdf0e10cSrcweir } 110cdf0e10cSrcweir 111cdf0e10cSrcweir //------------------------------------------------------------------------ 112cdf0e10cSrcweir 113cdf0e10cSrcweir void SAL_CALL SvxEditEngineSourceImpl::acquire() 114cdf0e10cSrcweir { 115cdf0e10cSrcweir osl_incrementInterlockedCount( &maRefCount ); 116cdf0e10cSrcweir } 117cdf0e10cSrcweir 118cdf0e10cSrcweir //------------------------------------------------------------------------ 119cdf0e10cSrcweir 120cdf0e10cSrcweir void SAL_CALL SvxEditEngineSourceImpl::release() 121cdf0e10cSrcweir { 122cdf0e10cSrcweir if( ! osl_decrementInterlockedCount( &maRefCount ) ) 123cdf0e10cSrcweir delete this; 124cdf0e10cSrcweir } 125cdf0e10cSrcweir 126cdf0e10cSrcweir //------------------------------------------------------------------------ 127cdf0e10cSrcweir 128cdf0e10cSrcweir SvxTextForwarder* SvxEditEngineSourceImpl::GetTextForwarder() 129cdf0e10cSrcweir { 130cdf0e10cSrcweir if (!mpTextForwarder) 131cdf0e10cSrcweir mpTextForwarder = new SvxEditEngineForwarder( *mpEditEngine ); 132cdf0e10cSrcweir 133cdf0e10cSrcweir return mpTextForwarder; 134cdf0e10cSrcweir } 135cdf0e10cSrcweir 136cdf0e10cSrcweir // -------------------------------------------------------------------- 137cdf0e10cSrcweir // SvxTextEditSource 138cdf0e10cSrcweir // -------------------------------------------------------------------- 139cdf0e10cSrcweir 140cdf0e10cSrcweir SvxEditEngineSource::SvxEditEngineSource( EditEngine* pEditEngine ) 141cdf0e10cSrcweir { 142cdf0e10cSrcweir mpImpl = new SvxEditEngineSourceImpl( pEditEngine ); 143cdf0e10cSrcweir mpImpl->acquire(); 144cdf0e10cSrcweir } 145cdf0e10cSrcweir 146cdf0e10cSrcweir // -------------------------------------------------------------------- 147cdf0e10cSrcweir 148cdf0e10cSrcweir SvxEditEngineSource::SvxEditEngineSource( SvxEditEngineSourceImpl* pImpl ) 149cdf0e10cSrcweir { 150cdf0e10cSrcweir mpImpl = pImpl; 151cdf0e10cSrcweir mpImpl->acquire(); 152cdf0e10cSrcweir } 153cdf0e10cSrcweir 154cdf0e10cSrcweir //------------------------------------------------------------------------ 155cdf0e10cSrcweir 156cdf0e10cSrcweir SvxEditEngineSource::~SvxEditEngineSource() 157cdf0e10cSrcweir { 158cdf0e10cSrcweir mpImpl->release(); 159cdf0e10cSrcweir } 160cdf0e10cSrcweir 161cdf0e10cSrcweir //------------------------------------------------------------------------ 162cdf0e10cSrcweir 163cdf0e10cSrcweir SvxEditSource* SvxEditEngineSource::Clone() const 164cdf0e10cSrcweir { 165cdf0e10cSrcweir return new SvxEditEngineSource( mpImpl ); 166cdf0e10cSrcweir } 167cdf0e10cSrcweir 168cdf0e10cSrcweir //------------------------------------------------------------------------ 169cdf0e10cSrcweir 170cdf0e10cSrcweir SvxTextForwarder* SvxEditEngineSource::GetTextForwarder() 171cdf0e10cSrcweir { 172cdf0e10cSrcweir return mpImpl->GetTextForwarder(); 173cdf0e10cSrcweir } 174cdf0e10cSrcweir 175cdf0e10cSrcweir //------------------------------------------------------------------------ 176cdf0e10cSrcweir 177cdf0e10cSrcweir void SvxEditEngineSource::UpdateData() 178cdf0e10cSrcweir { 179cdf0e10cSrcweir } 180cdf0e10cSrcweir 181cdf0e10cSrcweir class SvxSimpleUnoModel : public cppu::WeakAggImplHelper4< 182cdf0e10cSrcweir ::com::sun::star::frame::XModel, 183cdf0e10cSrcweir ::com::sun::star::ucb::XAnyCompareFactory, 184cdf0e10cSrcweir ::com::sun::star::style::XStyleFamiliesSupplier, 185cdf0e10cSrcweir ::com::sun::star::lang::XMultiServiceFactory > 186cdf0e10cSrcweir { 187cdf0e10cSrcweir public: 188cdf0e10cSrcweir SvxSimpleUnoModel(); 189cdf0e10cSrcweir virtual ~SvxSimpleUnoModel(); 190cdf0e10cSrcweir 191cdf0e10cSrcweir 192cdf0e10cSrcweir // XMultiServiceFactory 193cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstance( const ::rtl::OUString& aServiceSpecifier ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); 194cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithArguments( const ::rtl::OUString& ServiceSpecifier, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Arguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); 195cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAvailableServiceNames( ) throw(::com::sun::star::uno::RuntimeException); 196cdf0e10cSrcweir 197cdf0e10cSrcweir // XStyleFamiliesSupplier 198cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getStyleFamilies( ) throw(::com::sun::star::uno::RuntimeException); 199cdf0e10cSrcweir 200cdf0e10cSrcweir // XAnyCompareFactory 201cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XAnyCompare > SAL_CALL createAnyCompareByName( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException); 202cdf0e10cSrcweir 203cdf0e10cSrcweir // XModel 204cdf0e10cSrcweir virtual sal_Bool SAL_CALL attachResource( const ::rtl::OUString& aURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs ) throw (::com::sun::star::uno::RuntimeException); 205cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getURL( ) throw (::com::sun::star::uno::RuntimeException); 206cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getArgs( ) throw (::com::sun::star::uno::RuntimeException); 207cdf0e10cSrcweir virtual void SAL_CALL connectController( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& xController ) throw (::com::sun::star::uno::RuntimeException); 208cdf0e10cSrcweir virtual void SAL_CALL disconnectController( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& xController ) throw (::com::sun::star::uno::RuntimeException); 209cdf0e10cSrcweir virtual void SAL_CALL lockControllers( ) throw (::com::sun::star::uno::RuntimeException); 210cdf0e10cSrcweir virtual void SAL_CALL unlockControllers( ) throw (::com::sun::star::uno::RuntimeException); 211cdf0e10cSrcweir virtual sal_Bool SAL_CALL hasControllersLocked( ) throw (::com::sun::star::uno::RuntimeException); 212cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > SAL_CALL getCurrentController( ) throw (::com::sun::star::uno::RuntimeException); 213cdf0e10cSrcweir virtual void SAL_CALL setCurrentController( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& xController ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); 214cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getCurrentSelection( ) throw (::com::sun::star::uno::RuntimeException); 215cdf0e10cSrcweir 216cdf0e10cSrcweir // XComponent 217cdf0e10cSrcweir virtual void SAL_CALL dispose( ) throw (::com::sun::star::uno::RuntimeException); 218cdf0e10cSrcweir virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); 219cdf0e10cSrcweir virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); 220cdf0e10cSrcweir 221cdf0e10cSrcweir }; 222cdf0e10cSrcweir 223cdf0e10cSrcweir SvxSimpleUnoModel::SvxSimpleUnoModel() 224cdf0e10cSrcweir { 225cdf0e10cSrcweir } 226cdf0e10cSrcweir 227cdf0e10cSrcweir SvxSimpleUnoModel::~SvxSimpleUnoModel() 228cdf0e10cSrcweir { 229cdf0e10cSrcweir } 230cdf0e10cSrcweir 231cdf0e10cSrcweir // XMultiServiceFactory ( SvxFmMSFactory ) 232cdf0e10cSrcweir uno::Reference< uno::XInterface > SAL_CALL SvxSimpleUnoModel::createInstance( const OUString& aServiceSpecifier ) 233cdf0e10cSrcweir throw(uno::Exception, uno::RuntimeException) 234cdf0e10cSrcweir { 235cdf0e10cSrcweir if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.NumberingRules" ) ) ) 236cdf0e10cSrcweir { 237cdf0e10cSrcweir return uno::Reference< uno::XInterface >( 238cdf0e10cSrcweir SvxCreateNumRule(), uno::UNO_QUERY ); 239cdf0e10cSrcweir } 240cdf0e10cSrcweir if ( (0 == aServiceSpecifier.reverseCompareToAsciiL( 241cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.textfield.DateTime"))) 242cdf0e10cSrcweir || (0 == aServiceSpecifier.reverseCompareToAsciiL( 243cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.TextField.DateTime"))) 244cdf0e10cSrcweir ) 245cdf0e10cSrcweir { 246cdf0e10cSrcweir return (::cppu::OWeakObject * )new SvxUnoTextField( ID_EXT_DATEFIELD ); 247cdf0e10cSrcweir } 248cdf0e10cSrcweir 249cdf0e10cSrcweir return SvxUnoTextCreateTextField( aServiceSpecifier ); 250cdf0e10cSrcweir 251cdf0e10cSrcweir } 252cdf0e10cSrcweir 253cdf0e10cSrcweir uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL SvxSimpleUnoModel::createInstanceWithArguments( const ::rtl::OUString& ServiceSpecifier, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) 254cdf0e10cSrcweir { 255cdf0e10cSrcweir return createInstance( ServiceSpecifier ); 256cdf0e10cSrcweir } 257cdf0e10cSrcweir 258cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL SvxSimpleUnoModel::getAvailableServiceNames( ) throw(::com::sun::star::uno::RuntimeException) 259cdf0e10cSrcweir { 260cdf0e10cSrcweir Sequence< OUString > aSeq; 261cdf0e10cSrcweir return aSeq; 262cdf0e10cSrcweir } 263cdf0e10cSrcweir 264cdf0e10cSrcweir // XAnyCompareFactory 265cdf0e10cSrcweir uno::Reference< com::sun::star::ucb::XAnyCompare > SAL_CALL SvxSimpleUnoModel::createAnyCompareByName( const OUString& PropertyName ) 266cdf0e10cSrcweir throw(uno::RuntimeException) 267cdf0e10cSrcweir { 268cdf0e10cSrcweir (void)PropertyName; 269cdf0e10cSrcweir return SvxCreateNumRuleCompare(); 270cdf0e10cSrcweir } 271cdf0e10cSrcweir 272cdf0e10cSrcweir // XStyleFamiliesSupplier 273cdf0e10cSrcweir uno::Reference< container::XNameAccess > SAL_CALL SvxSimpleUnoModel::getStyleFamilies( ) 274cdf0e10cSrcweir throw(uno::RuntimeException) 275cdf0e10cSrcweir { 276cdf0e10cSrcweir uno::Reference< container::XNameAccess > xStyles; 277cdf0e10cSrcweir return xStyles; 278cdf0e10cSrcweir } 279cdf0e10cSrcweir 280cdf0e10cSrcweir // XModel 281cdf0e10cSrcweir sal_Bool SAL_CALL SvxSimpleUnoModel::attachResource( const ::rtl::OUString& aURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs ) throw (::com::sun::star::uno::RuntimeException) 282cdf0e10cSrcweir { 283cdf0e10cSrcweir (void)aURL; 284cdf0e10cSrcweir (void)aArgs; 285cdf0e10cSrcweir return sal_False; 286cdf0e10cSrcweir } 287cdf0e10cSrcweir 288cdf0e10cSrcweir ::rtl::OUString SAL_CALL SvxSimpleUnoModel::getURL( ) throw (::com::sun::star::uno::RuntimeException) 289cdf0e10cSrcweir { 290cdf0e10cSrcweir OUString aStr; 291cdf0e10cSrcweir return aStr; 292cdf0e10cSrcweir } 293cdf0e10cSrcweir 294cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL SvxSimpleUnoModel::getArgs( ) throw (::com::sun::star::uno::RuntimeException) 295cdf0e10cSrcweir { 296cdf0e10cSrcweir Sequence< beans::PropertyValue > aSeq; 297cdf0e10cSrcweir return aSeq; 298cdf0e10cSrcweir } 299cdf0e10cSrcweir 300cdf0e10cSrcweir void SAL_CALL SvxSimpleUnoModel::connectController( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& ) throw (::com::sun::star::uno::RuntimeException) 301cdf0e10cSrcweir { 302cdf0e10cSrcweir } 303cdf0e10cSrcweir 304cdf0e10cSrcweir void SAL_CALL SvxSimpleUnoModel::disconnectController( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& ) throw (::com::sun::star::uno::RuntimeException) 305cdf0e10cSrcweir { 306cdf0e10cSrcweir } 307cdf0e10cSrcweir 308cdf0e10cSrcweir void SAL_CALL SvxSimpleUnoModel::lockControllers( ) throw (::com::sun::star::uno::RuntimeException) 309cdf0e10cSrcweir { 310cdf0e10cSrcweir } 311cdf0e10cSrcweir 312cdf0e10cSrcweir void SAL_CALL SvxSimpleUnoModel::unlockControllers( ) throw (::com::sun::star::uno::RuntimeException) 313cdf0e10cSrcweir { 314cdf0e10cSrcweir } 315cdf0e10cSrcweir 316cdf0e10cSrcweir sal_Bool SAL_CALL SvxSimpleUnoModel::hasControllersLocked( ) throw (::com::sun::star::uno::RuntimeException) 317cdf0e10cSrcweir { 318cdf0e10cSrcweir return sal_True; 319cdf0e10cSrcweir } 320cdf0e10cSrcweir 321cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > SAL_CALL SvxSimpleUnoModel::getCurrentController( ) throw (::com::sun::star::uno::RuntimeException) 322cdf0e10cSrcweir { 323cdf0e10cSrcweir uno::Reference< frame::XController > xRet; 324cdf0e10cSrcweir return xRet; 325cdf0e10cSrcweir } 326cdf0e10cSrcweir 327cdf0e10cSrcweir void SAL_CALL SvxSimpleUnoModel::setCurrentController( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException) 328cdf0e10cSrcweir { 329cdf0e10cSrcweir } 330cdf0e10cSrcweir 331cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL SvxSimpleUnoModel::getCurrentSelection( ) throw (::com::sun::star::uno::RuntimeException) 332cdf0e10cSrcweir { 333cdf0e10cSrcweir uno::Reference< XInterface > xRet; 334cdf0e10cSrcweir return xRet; 335cdf0e10cSrcweir } 336cdf0e10cSrcweir 337cdf0e10cSrcweir 338cdf0e10cSrcweir // XComponent 339cdf0e10cSrcweir void SAL_CALL SvxSimpleUnoModel::dispose( ) throw (::com::sun::star::uno::RuntimeException) 340cdf0e10cSrcweir { 341cdf0e10cSrcweir } 342cdf0e10cSrcweir 343cdf0e10cSrcweir void SAL_CALL SvxSimpleUnoModel::addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& ) throw (::com::sun::star::uno::RuntimeException) 344cdf0e10cSrcweir { 345cdf0e10cSrcweir } 346cdf0e10cSrcweir 347cdf0e10cSrcweir void SAL_CALL SvxSimpleUnoModel::removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& ) throw (::com::sun::star::uno::RuntimeException) 348cdf0e10cSrcweir { 349cdf0e10cSrcweir } 350cdf0e10cSrcweir 351cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////// 352cdf0e10cSrcweir 353cdf0e10cSrcweir class SvxXMLTextExportComponent : public SvXMLExport 354cdf0e10cSrcweir { 355cdf0e10cSrcweir public: 356cdf0e10cSrcweir // #110680# 357cdf0e10cSrcweir SvxXMLTextExportComponent( 358cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory, 359cdf0e10cSrcweir EditEngine* pEditEngine, 360cdf0e10cSrcweir const ESelection& rSel, 361cdf0e10cSrcweir const ::rtl::OUString& rFileName, 362cdf0e10cSrcweir const com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler > & xHandler ); 363cdf0e10cSrcweir 364cdf0e10cSrcweir ~SvxXMLTextExportComponent(); 365cdf0e10cSrcweir 366cdf0e10cSrcweir // methods without content: 367cdf0e10cSrcweir virtual void _ExportAutoStyles(); 368cdf0e10cSrcweir virtual void _ExportMasterStyles(); 369cdf0e10cSrcweir virtual void _ExportContent(); 370cdf0e10cSrcweir 371cdf0e10cSrcweir private: 372cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::text::XText > mxText; 373cdf0e10cSrcweir EditEngine* mpEditEngine; 374cdf0e10cSrcweir ESelection maSelection; 375cdf0e10cSrcweir }; 376cdf0e10cSrcweir 377cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////// 378cdf0e10cSrcweir 379cdf0e10cSrcweir // #110680# 380cdf0e10cSrcweir SvxXMLTextExportComponent::SvxXMLTextExportComponent( 381cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory, 382cdf0e10cSrcweir EditEngine* pEditEngine, 383cdf0e10cSrcweir const ESelection& rSel, 384cdf0e10cSrcweir const ::rtl::OUString& rFileName, 385cdf0e10cSrcweir const com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler > & xHandler) 386cdf0e10cSrcweir : SvXMLExport( xServiceFactory, rFileName, xHandler, ((frame::XModel*)new SvxSimpleUnoModel()), MAP_CM ), 387cdf0e10cSrcweir mpEditEngine( pEditEngine ), 388cdf0e10cSrcweir maSelection( rSel ) 389cdf0e10cSrcweir { 390cdf0e10cSrcweir SvxEditEngineSource aEditSource( pEditEngine ); 391cdf0e10cSrcweir 392cdf0e10cSrcweir static const SfxItemPropertyMapEntry SvxXMLTextExportComponentPropertyMap[] = 393cdf0e10cSrcweir { 394cdf0e10cSrcweir SVX_UNOEDIT_CHAR_PROPERTIES, 395cdf0e10cSrcweir SVX_UNOEDIT_FONT_PROPERTIES, 396cdf0e10cSrcweir // SVX_UNOEDIT_OUTLINER_PROPERTIES, 397cdf0e10cSrcweir {MAP_CHAR_LEN(UNO_NAME_NUMBERING_RULES), EE_PARA_NUMBULLET, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexReplace>*)0), 0, 0 }, 398cdf0e10cSrcweir {MAP_CHAR_LEN(UNO_NAME_NUMBERING), EE_PARA_BULLETSTATE,&::getBooleanCppuType(), 0, 0 }, 399cdf0e10cSrcweir {MAP_CHAR_LEN(UNO_NAME_NUMBERING_LEVEL), EE_PARA_OUTLLEVEL, &::getCppuType((const sal_Int16*)0), 0, 0 }, 400cdf0e10cSrcweir SVX_UNOEDIT_PARA_PROPERTIES, 401cdf0e10cSrcweir {0,0,0,0,0,0} 402cdf0e10cSrcweir }; 403cdf0e10cSrcweir static SvxItemPropertySet aSvxXMLTextExportComponentPropertySet( SvxXMLTextExportComponentPropertyMap, EditEngine::GetGlobalItemPool() ); 404cdf0e10cSrcweir 405cdf0e10cSrcweir SvxUnoText* pUnoText = new SvxUnoText( &aEditSource, &aSvxXMLTextExportComponentPropertySet, mxText ); 406cdf0e10cSrcweir pUnoText->SetSelection( rSel ); 407cdf0e10cSrcweir mxText = pUnoText; 408cdf0e10cSrcweir 409cdf0e10cSrcweir setExportFlags( EXPORT_AUTOSTYLES|EXPORT_CONTENT ); 410cdf0e10cSrcweir } 411cdf0e10cSrcweir 412cdf0e10cSrcweir SvxXMLTextExportComponent::~SvxXMLTextExportComponent() 413cdf0e10cSrcweir { 414cdf0e10cSrcweir } 415cdf0e10cSrcweir 416cdf0e10cSrcweir void SvxWriteXML( EditEngine& rEditEngine, SvStream& rStream, const ESelection& rSel ) 417cdf0e10cSrcweir { 418cdf0e10cSrcweir try 419cdf0e10cSrcweir { 420cdf0e10cSrcweir do 421cdf0e10cSrcweir { 422cdf0e10cSrcweir // create service factory 423cdf0e10cSrcweir 424cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory> xServiceFactory( ::comphelper::getProcessServiceFactory() ); 425cdf0e10cSrcweir 426cdf0e10cSrcweir if( !xServiceFactory.is() ) 427cdf0e10cSrcweir { 428cdf0e10cSrcweir DBG_ERROR( "got no service manager" ); 429cdf0e10cSrcweir break; 430cdf0e10cSrcweir } 431cdf0e10cSrcweir 432cdf0e10cSrcweir // create document handler 433cdf0e10cSrcweir 434cdf0e10cSrcweir uno::Reference< uno::XInterface > xWriter( xServiceFactory->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.xml.sax.Writer" ) ) ) ); 435cdf0e10cSrcweir 436cdf0e10cSrcweir if( !xWriter.is() ) 437cdf0e10cSrcweir { 438cdf0e10cSrcweir DBG_ERROR( "com.sun.star.xml.sax.Writer service missing" ); 439cdf0e10cSrcweir break; 440cdf0e10cSrcweir } 441cdf0e10cSrcweir 442cdf0e10cSrcweir uno::Reference<xml::sax::XDocumentHandler> xHandler( xWriter, uno::UNO_QUERY ); 443cdf0e10cSrcweir 444cdf0e10cSrcweir // create output stream and active data source 445cdf0e10cSrcweir uno::Reference<io::XOutputStream> xOut( new utl::OOutputStreamWrapper( rStream ) ); 446cdf0e10cSrcweir 447cdf0e10cSrcweir /* testcode 448cdf0e10cSrcweir const OUString aURL( RTL_CONSTASCII_USTRINGPARAM( "file:///e:/test.xml" ) ); 449cdf0e10cSrcweir SfxMedium aMedium( aURL, STREAM_WRITE | STREAM_TRUNC, sal_True ); 450cdf0e10cSrcweir aMedium.IsRemote(); 451cdf0e10cSrcweir uno::Reference<io::XOutputStream> xOut( new utl::OOutputStreamWrapper( *aMedium.GetOutStream() ) ); 452cdf0e10cSrcweir */ 453cdf0e10cSrcweir 454cdf0e10cSrcweir 455cdf0e10cSrcweir uno::Reference<io::XActiveDataSource> xMetaSrc( xWriter, uno::UNO_QUERY ); 456cdf0e10cSrcweir xMetaSrc->setOutputStream( xOut ); 457cdf0e10cSrcweir 458cdf0e10cSrcweir // export text 459cdf0e10cSrcweir const OUString aName; 460cdf0e10cSrcweir 461cdf0e10cSrcweir // #110680# 462cdf0e10cSrcweir // SvxXMLTextExportComponent aExporter( &rEditEngine, rSel, aName, xHandler ); 463cdf0e10cSrcweir SvxXMLTextExportComponent aExporter( xServiceFactory, &rEditEngine, rSel, aName, xHandler ); 464cdf0e10cSrcweir 465cdf0e10cSrcweir aExporter.exportDoc(); 466cdf0e10cSrcweir 467cdf0e10cSrcweir /* testcode 468cdf0e10cSrcweir aMedium.Commit(); 469cdf0e10cSrcweir */ 470cdf0e10cSrcweir 471cdf0e10cSrcweir } 472cdf0e10cSrcweir while( 0 ); 473cdf0e10cSrcweir } 474cdf0e10cSrcweir catch( uno::Exception& ) 475cdf0e10cSrcweir { 476cdf0e10cSrcweir DBG_ERROR("exception during xml export"); 477cdf0e10cSrcweir } 478cdf0e10cSrcweir } 479cdf0e10cSrcweir 480cdf0e10cSrcweir // methods without content: 481cdf0e10cSrcweir void SvxXMLTextExportComponent::_ExportAutoStyles() 482cdf0e10cSrcweir { 483cdf0e10cSrcweir UniReference< XMLTextParagraphExport > xTextExport( GetTextParagraphExport() ); 484cdf0e10cSrcweir 485cdf0e10cSrcweir xTextExport->collectTextAutoStyles( mxText ); 486cdf0e10cSrcweir xTextExport->exportTextAutoStyles(); 487cdf0e10cSrcweir } 488cdf0e10cSrcweir 489cdf0e10cSrcweir void SvxXMLTextExportComponent::_ExportContent() 490cdf0e10cSrcweir { 491cdf0e10cSrcweir UniReference< XMLTextParagraphExport > xTextExport( GetTextParagraphExport() ); 492cdf0e10cSrcweir 493cdf0e10cSrcweir xTextExport->exportText( mxText ); 494cdf0e10cSrcweir } 495cdf0e10cSrcweir 496cdf0e10cSrcweir void SvxXMLTextExportComponent::_ExportMasterStyles() {} 497