diff options
author | Michael Stahl <mstahl@redhat.com> | 2013-12-05 12:15:15 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2013-12-05 13:00:27 +0100 |
commit | c5138cad87575283cdf0670355f2b2cddae93fc8 (patch) | |
tree | 2cd071d5cf900636b87bd6ee47f1351fa4f18e8d /sfx2 | |
parent | de45a49273542c9046e0cfc2b75c863573eb6c38 (diff) |
fdo#68724: sw: fix crash on Insert->File with Hybrid PDF
This is an unfortunate combination of 2 special cases:
- the Hybrid PDF has its own XFilter implementation to extract the
embedded ODF document
- Writer needs to create a SwReader with SwPaM for Insert
Since the PDF XFilter uses a special service in sfx2 to implement
the import, handling this requires a new method in SfxObjectShell
that calls back into Writer to create the properly setup SwReader.
Change-Id: Ie85f3bfa322bfe883c479e1cb198a8bf0cbbac23
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/doc/objstor.cxx | 60 |
1 files changed, 45 insertions, 15 deletions
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index 125edca36a7f..df12f4f976a0 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -66,6 +66,7 @@ #include <com/sun/star/io/XTruncate.hpp> #include <com/sun/star/util/XModifiable.hpp> #include <com/sun/star/security/DocumentDigitalSignatures.hpp> +#include <com/sun/star/text/XTextRange.hpp> #include <com/sun/star/xml/crypto/CipherID.hpp> #include <com/sun/star/xml/crypto/DigestID.hpp> @@ -548,7 +549,7 @@ sal_Bool SfxObjectShell::DoInitNew( SfxMedium* pMed ) sal_Bool SfxObjectShell::ImportFromGeneratedStream_Impl( const uno::Reference< io::XStream >& xStream, - const uno::Sequence< beans::PropertyValue >& aMediaDescr ) + const uno::Sequence< beans::PropertyValue >& rMediaDescr ) { if ( !xStream.is() ) return sal_False; @@ -572,22 +573,38 @@ sal_Bool SfxObjectShell::ImportFromGeneratedStream_Impl( pMedium->SetStorage_Impl( xStorage ); SfxAllItemSet aSet( SFX_APP()->GetPool() ); - TransformParameters( SID_OPENDOC, aMediaDescr, aSet ); + TransformParameters( SID_OPENDOC, rMediaDescr, aSet ); pMedium->GetItemSet()->Put( aSet ); pMedium->CanDisposeStorage_Impl( sal_False ); + uno::Reference<text::XTextRange> xInsertTextRange; + for (sal_Int32 i = 0; i < rMediaDescr.getLength(); ++i) + { + if (rMediaDescr[i].Name == "TextInsertModeRange") + { + rMediaDescr[i].Value >>= xInsertTextRange; + } + } - // allow the subfilter to reinit the model - if ( pImp->m_bIsInit ) - pImp->m_bIsInit = sal_False; - - if ( LoadOwnFormat( *pMedium ) ) + if (xInsertTextRange.is()) + { + bResult = InsertGeneratedStream(*pMedium, xInsertTextRange); + } + else { - bHasName = sal_True; - if ( !IsReadOnly() && IsLoadReadonly() ) - SetReadOnlyUI(); - bResult = sal_True; - OSL_ENSURE( pImp->m_xDocStorage == xStorage, "Wrong storage is used!\n" ); + // allow the subfilter to reinit the model + if ( pImp->m_bIsInit ) + pImp->m_bIsInit = sal_False; + + if ( LoadOwnFormat( *pMedium ) ) + { + bHasName = sal_True; + if ( !IsReadOnly() && IsLoadReadonly() ) + SetReadOnlyUI(); + + bResult = sal_True; + OSL_ENSURE( pImp->m_xDocStorage == xStorage, "Wrong storage is used!\n" ); + } } // now the medium can be disconnected from the storage @@ -748,7 +765,7 @@ sal_Bool SfxObjectShell::DoLoad( SfxMedium *pMed ) { bSetProperty = false; } - bOk = ImportFrom( *pMedium, false ); + bOk = ImportFrom(*pMedium, 0); if(bSetProperty) { try @@ -2160,7 +2177,8 @@ sal_Bool SfxObjectShell::ConvertFrom return sal_False; } -sal_Bool SfxObjectShell::ImportFrom( SfxMedium& rMedium, bool bInsert ) +bool SfxObjectShell::ImportFrom(SfxMedium& rMedium, + css::uno::Reference<css::text::XTextRange> const& xInsertPosition) { OUString aFilterName( rMedium.GetFilter()->GetFilterName() ); @@ -2242,10 +2260,13 @@ sal_Bool SfxObjectShell::ImportFrom( SfxMedium& rMedium, bool bInsert ) aArgs[nEnd-1].Value <<= rMedium.GetBaseURL(); } - if ( bInsert ) { + if (xInsertPosition.is()) { aArgs.realloc( ++nEnd ); aArgs[nEnd-1].Name = "InsertMode"; aArgs[nEnd-1].Value <<= (sal_Bool) sal_True; + aArgs.realloc( ++nEnd ); + aArgs[nEnd-1].Name = "TextInsertModeRange"; + aArgs[nEnd-1].Value <<= xInsertPosition; } // #i119492# During loading, some OLE objects like chart will be set @@ -3603,6 +3624,15 @@ void SfxObjectShell::UpdateLinks() bool SfxObjectShell::LoadExternal( SfxMedium& ) { // Not implemented. It's an error if the code path ever comes here. + assert(false); + return false; +} + +bool SfxObjectShell::InsertGeneratedStream(SfxMedium&, + uno::Reference<text::XTextRange> const&) +{ + // Not implemented. It's an error if the code path ever comes here. + assert(false); return false; } |