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 /sw | |
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 'sw')
-rw-r--r-- | sw/inc/docsh.hxx | 3 | ||||
-rw-r--r-- | sw/source/ui/app/docsh.cxx | 17 | ||||
-rw-r--r-- | sw/source/ui/uiview/view2.cxx | 7 |
3 files changed, 26 insertions, 1 deletions
diff --git a/sw/inc/docsh.hxx b/sw/inc/docsh.hxx index 267060338d7a..f8f60bf71684 100644 --- a/sw/inc/docsh.hxx +++ b/sw/inc/docsh.hxx @@ -93,6 +93,9 @@ class SW_DLLPUBLIC SwDocShell: public SfxObjectShell, public SfxListener SW_DLLPRIVATE virtual sal_uInt16 PrepareClose( sal_Bool bUI = sal_True, sal_Bool bForBrowsing = sal_False ); + SW_DLLPRIVATE virtual bool InsertGeneratedStream(SfxMedium& rMedium, + css::uno::Reference<css::text::XTextRange> const& xInsertPosition) + SAL_OVERRIDE; /// Make DocInfo known to the Doc. SW_DLLPRIVATE virtual SfxDocumentInfoDialog* CreateDocumentInfoDialog( diff --git a/sw/source/ui/app/docsh.cxx b/sw/source/ui/app/docsh.cxx index e4f95338416f..e96af964120e 100644 --- a/sw/source/ui/app/docsh.cxx +++ b/sw/source/ui/app/docsh.cxx @@ -106,6 +106,7 @@ #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> #include <unomid.h> +#include <unotextrange.hxx> #include <sfx2/Metadatable.hxx> #include <switerator.hxx> @@ -124,6 +125,22 @@ TYPEINIT2(SwDocShell, SfxObjectShell, SfxListener); SFX_IMPL_OBJECTFACTORY(SwDocShell, SvGlobalName(SO3_SW_CLASSID), SFXOBJECTSHELL_STD_NORMAL|SFXOBJECTSHELL_HASMENU, "swriter" ) +bool SwDocShell::InsertGeneratedStream(SfxMedium & rMedium, + uno::Reference<text::XTextRange> const& xInsertPosition) +{ + SwUnoInternalPaM aPam(*GetDoc()); // must have doc since called from SwView + if (!::sw::XTextRangeToSwPaM(aPam, xInsertPosition)) + return false; + // similar to SwView::InsertMedium + SwReader *pReader(0); + Reader *const pRead = StartConvertFrom(rMedium, &pReader, 0, &aPam); + if (!pRead) + return false; + sal_uLong const nError = pReader->Read(*pRead); + delete pReader; + return 0 == nError; +} + // Prepare loading Reader* SwDocShell::StartConvertFrom(SfxMedium& rMedium, SwReader** ppRdr, SwCrsrShell *pCrsrShell, diff --git a/sw/source/ui/uiview/view2.cxx b/sw/source/ui/uiview/view2.cxx index ecfaa893e602..06ea67fa70d2 100644 --- a/sw/source/ui/uiview/view2.cxx +++ b/sw/source/ui/uiview/view2.cxx @@ -131,6 +131,7 @@ #include <fmthdft.hxx> #include <svx/ofaitem.hxx> #include <unomid.h> +#include <unotextrange.hxx> #include <docstat.hxx> #include <wordcountdialog.hxx> @@ -2150,7 +2151,11 @@ long SwView::InsertMedium( sal_uInt16 nSlotId, SfxMedium* pMedium, sal_Int16 nVe else { ::sw::UndoGuard const ug(pDoc->GetIDocumentUndoRedo()); - nErrno = pDocSh->ImportFrom( *pMedium, true ) ? 0 : ERR_SWG_READ_ERROR; + uno::Reference<text::XTextRange> const xInsertPosition( + SwXTextRange::CreateXTextRange(*pDoc, + *m_pWrtShell->GetCrsr()->GetPoint(), 0)); + nErrno = pDocSh->ImportFrom(*pMedium, xInsertPosition) + ? 0 : ERR_SWG_READ_ERROR; } } |