[Libreoffice-commits] core.git: 3 commits - include/sfx2 sdext/source sd/source sfx2/source sw/inc sw/qa sw/source writerfilter/source
Michael Stahl
mstahl at redhat.com
Thu Dec 5 04:06:25 PST 2013
include/sfx2/objsh.hxx | 10 ++++-
sd/source/ui/docshell/docshel4.cxx | 5 +-
sd/source/ui/inc/DrawDocShell.hxx | 4 +-
sdext/source/pdfimport/pdfiadaptor.cxx | 14 ++-----
sfx2/source/doc/objstor.cxx | 60 +++++++++++++++++++++++--------
sw/inc/docsh.hxx | 3 +
sw/qa/extras/rtfimport/rtfimport.cxx | 4 +-
sw/source/filter/rtf/swparrtf.cxx | 4 +-
sw/source/ui/app/docsh.cxx | 17 ++++++++
sw/source/ui/uiview/view2.cxx | 7 +++
writerfilter/source/filter/RtfFilter.cxx | 2 -
11 files changed, 96 insertions(+), 34 deletions(-)
New commits:
commit fb9d14f6a6deb00ecd09288e5696e8df7f8f5c0e
Author: Michael Stahl <mstahl at redhat.com>
Date: Thu Dec 5 12:57:01 2013 +0100
RTF: use "InsertMode" insead of "IsNewDoc" for consistency
... with other filters.
Change-Id: I563d6f7713d882b834978699c492a43a70e072cd
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 88df7ad..95a3a09 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -91,8 +91,8 @@ protected:
SvStream* pStream = utl::UcbStreamHelper::CreateStream(getURLFromSrc("/sw/qa/extras/rtfimport/data/") + aFilename, STREAM_WRITE);
uno::Reference<io::XStream> xStream(new utl::OStreamWrapper(*pStream));
aDescriptor[0].Value <<= xStream;
- aDescriptor[1].Name = "IsNewDoc";
- aDescriptor[1].Value <<= sal_False;
+ aDescriptor[1].Name = "InsertMode";
+ aDescriptor[1].Value <<= sal_True;
if (xTextRange.is())
{
aDescriptor[2].Name = "TextInsertModeRange";
diff --git a/sw/source/filter/rtf/swparrtf.cxx b/sw/source/filter/rtf/swparrtf.cxx
index cfbc915..aad6a8d 100644
--- a/sw/source/filter/rtf/swparrtf.cxx
+++ b/sw/source/filter/rtf/swparrtf.cxx
@@ -87,8 +87,8 @@ sal_uLong SwRTFReader::Read( SwDoc &rDoc, const OUString& /*rBaseURL*/, SwPaM& r
aDescriptor[0].Name = "InputStream";
uno::Reference<io::XStream> xStream(new utl::OStreamWrapper(*pStrm));
aDescriptor[0].Value <<= xStream;
- aDescriptor[1].Name = "IsNewDoc";
- aDescriptor[1].Value <<= sal_False;
+ aDescriptor[1].Name = "InsertMode";
+ aDescriptor[1].Value <<= sal_True;
aDescriptor[2].Name = "TextInsertModeRange";
aDescriptor[2].Value <<= xInsertTextRange;
sal_uLong ret(0);
diff --git a/writerfilter/source/filter/RtfFilter.cxx b/writerfilter/source/filter/RtfFilter.cxx
index 54bc27b..6093211 100644
--- a/writerfilter/source/filter/RtfFilter.cxx
+++ b/writerfilter/source/filter/RtfFilter.cxx
@@ -75,7 +75,7 @@ sal_Bool RtfFilter::filter( const uno::Sequence< beans::PropertyValue >& aDescri
{
MediaDescriptor aMediaDesc( aDescriptor );
bool bRepairStorage = aMediaDesc.getUnpackedValueOrDefault( "RepairPackage", false );
- bool bIsNewDoc = aMediaDesc.getUnpackedValueOrDefault( "IsNewDoc", true );
+ bool bIsNewDoc = !aMediaDesc.getUnpackedValueOrDefault("InsertMode", false);
uno::Reference<text::XTextRange> xInsertTextRange = aMediaDesc.getUnpackedValueOrDefault( "TextInsertModeRange", uno::Reference<text::XTextRange>());
#ifdef DEBUG_IMPORT
OUString sURL = aMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_URL(), OUString() );
commit c5138cad87575283cdf0670355f2b2cddae93fc8
Author: Michael Stahl <mstahl at redhat.com>
Date: Thu Dec 5 12:15:15 2013 +0100
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
diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx
index fac2625..de041fbf 100644
--- a/include/sfx2/objsh.hxx
+++ b/include/sfx2/objsh.hxx
@@ -116,6 +116,9 @@ namespace com { namespace sun { namespace star {
namespace lang {
class XComponent;
}
+ namespace text {
+ class XTextRange;
+ }
} } }
typedef sal_uInt32 SfxObjectShellFlags;
@@ -348,7 +351,12 @@ public:
sal_Bool bForceNonModified = sal_False );
sal_Bool SaveCompletedChildren( sal_Bool bSuccess );
- virtual sal_Bool ImportFrom( SfxMedium &rMedium, bool bInsert );
+ /** a very special case to insert at a position in Writer from UNO,
+ via OwnSubFilterService */
+ virtual bool InsertGeneratedStream(SfxMedium& rMedium,
+ css::uno::Reference<css::text::XTextRange> const& xInsertPosition);
+ virtual bool ImportFrom( SfxMedium &rMedium,
+ css::uno::Reference<css::text::XTextRange> const& xInsertPosition);
sal_Bool ExportTo( SfxMedium &rMedium );
// xmlsec05, check with SFX team
diff --git a/sd/source/ui/docshell/docshel4.cxx b/sd/source/ui/docshell/docshel4.cxx
index 04fcf2a..eeae100 100644
--- a/sd/source/ui/docshell/docshel4.cxx
+++ b/sd/source/ui/docshell/docshel4.cxx
@@ -375,9 +375,10 @@ sal_Bool DrawDocShell::LoadFrom( SfxMedium& rMedium )
/**
* load from 3rd party format
*/
-sal_Bool DrawDocShell::ImportFrom( SfxMedium &rMedium, bool bInsert )
+bool DrawDocShell::ImportFrom(SfxMedium &rMedium,
+ uno::Reference<text::XTextRange> const& xInsertPosition)
{
- const sal_Bool bRet=SfxObjectShell::ImportFrom(rMedium, bInsert);
+ const sal_Bool bRet = SfxObjectShell::ImportFrom(rMedium, xInsertPosition);
SfxItemSet* pSet = rMedium.GetItemSet();
if( pSet )
diff --git a/sd/source/ui/inc/DrawDocShell.hxx b/sd/source/ui/inc/DrawDocShell.hxx
index 5278fc6..d4e46fc 100644
--- a/sd/source/ui/inc/DrawDocShell.hxx
+++ b/sd/source/ui/inc/DrawDocShell.hxx
@@ -76,7 +76,9 @@ public:
virtual void Activate( sal_Bool bMDI );
virtual void Deactivate( sal_Bool bMDI );
virtual sal_Bool InitNew( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage );
- virtual sal_Bool ImportFrom( SfxMedium &rMedium, bool bInsert=false );
+ virtual bool ImportFrom(SfxMedium &rMedium,
+ css::uno::Reference<css::text::XTextRange> const& xInsertPosition)
+ SAL_OVERRIDE;
virtual sal_Bool ConvertFrom( SfxMedium &rMedium );
virtual sal_Bool Save();
virtual sal_Bool SaveAsOwnFormat( SfxMedium& rMedium );
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index 125edca..df12f4f 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;
}
diff --git a/sw/inc/docsh.hxx b/sw/inc/docsh.hxx
index 2670603..f8f60bf 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 e4f9533..e96af96 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 ecfaa89..06ea67f 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;
}
}
commit de45a49273542c9046e0cfc2b75c863573eb6c38
Author: Michael Stahl <mstahl at redhat.com>
Date: Thu Dec 5 12:12:34 2013 +0100
sdext: clean up some pointless #ifdefs
Change-Id: Ic23c0ccc45d7a98b3581feab43fc4c8c8aef9013
diff --git a/sdext/source/pdfimport/pdfiadaptor.cxx b/sdext/source/pdfimport/pdfiadaptor.cxx
index b1419af..3ac732c 100644
--- a/sdext/source/pdfimport/pdfiadaptor.cxx
+++ b/sdext/source/pdfimport/pdfiadaptor.cxx
@@ -68,11 +68,11 @@ sal_Bool SAL_CALL PDFIHybridAdaptor::filter( const uno::Sequence< beans::Propert
sal_Int32 nPwPos = -1;
for( sal_Int32 i = 0; i < nAttribs; i++ )
{
- #if OSL_DEBUG_LEVEL > 1
- OUString aVal( "<no string>" );
- pAttribs[i].Value >>= aVal;
- SAL_INFO("sdext.pdfimport", "filter: Attrib: " << pAttribs[i].Name << " = " << aVal << "\n");
- #endif
+ SAL_INFO("sdext.pdfimport", "filter: Attrib: " << pAttribs[i].Name
+ << " = " << (pAttribs[i].Value.has<OUString>()
+ ? pAttribs[i].Value.get<OUString>()
+ : OUString("<no string>"))
+ << "\n");
if ( pAttribs[i].Name == "EmbeddedSubstream" )
pAttribs[i].Value >>= xSubStream;
else if ( pAttribs[i].Name == "Password" )
@@ -178,15 +178,11 @@ sal_Bool SAL_CALL PDFIHybridAdaptor::filter( const uno::Sequence< beans::Propert
bRet = xSubFilter->filter( rFilterData );
}
}
- #if OSL_DEBUG_LEVEL > 1
else
SAL_INFO("sdext.pdfimport", "PDFIAdaptor::filter: no embedded substream set" );
- #endif
}
- #if OSL_DEBUG_LEVEL > 1
else
SAL_INFO("sdext.pdfimport", "PDFIAdaptor::filter: no model set" );
- #endif
return bRet;
}
More information about the Libreoffice-commits
mailing list