rpms/openoffice.org/devel openoffice.org-3.2.0.oooXXXXX.embeddedobj.outplace.readonly.os.dispatch.patch, NONE, 1.1 openoffice.org.spec, 1.2122, 1.2123
Caolan McNamara
caolanm at fedoraproject.org
Thu Jan 14 12:08:09 UTC 2010
Author: caolanm
Update of /cvs/pkgs/rpms/openoffice.org/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv15458
Modified Files:
openoffice.org.spec
Added Files:
openoffice.org-3.2.0.oooXXXXX.embeddedobj.outplace.readonly.os.dispatch.patch
Log Message:
Resolves: rhbz#550043 dispatch outplace objects as ro documents to OS (caolanm)
openoffice.org-3.2.0.oooXXXXX.embeddedobj.outplace.readonly.os.dispatch.patch:
inc/oleembobj.hxx | 2
msole/oleembed.cxx | 186 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
msole/olemisc.cxx | 3
3 files changed, 190 insertions(+), 1 deletion(-)
--- NEW FILE openoffice.org-3.2.0.oooXXXXX.embeddedobj.outplace.readonly.os.dispatch.patch ---
diff -ru embeddedobj.orig/source/inc/oleembobj.hxx embeddedobj/source/inc/oleembobj.hxx
--- embeddedobj.orig/source/inc/oleembobj.hxx 2010-01-13 11:16:43.000000000 +0000
+++ embeddedobj/source/inc/oleembobj.hxx 2010-01-14 11:28:29.000000000 +0000
@@ -189,6 +189,8 @@
::rtl::OUString m_aTempURL;
+ ::rtl::OUString m_aTempDumpURL;
+
// STAMPIT solution
// the following member is used during verb execution to detect whether the verb execution modifies the object
VerbExecutionController m_aVerbExecutionController;
diff -ru embeddedobj.orig/source/msole/oleembed.cxx embeddedobj/source/msole/oleembed.cxx
--- embeddedobj.orig/source/msole/oleembed.cxx 2010-01-13 11:16:43.000000000 +0000
+++ embeddedobj/source/msole/oleembed.cxx 2010-01-14 11:50:43.000000000 +0000
@@ -49,10 +49,17 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/frame/XLoadable.hpp>
#include <com/sun/star/document/XStorageBasedDocument.hpp>
+#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/system/XSystemShellExecute.hpp>
+#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
+#include <com/sun/star/document/XTypeDetection.hpp>
#include <rtl/logfile.hxx>
#include <cppuhelper/interfacecontainer.h>
#include <comphelper/mimeconfighelper.hxx>
+#include <comphelper/storagehelper.hxx>
#include <targetstatecontrol.hxx>
@@ -677,6 +684,164 @@
return m_nObjectState;
}
+namespace
+{
+ bool lcl_CopyStream(uno::Reference<io::XInputStream> xIn, uno::Reference<io::XOutputStream> xOut)
+ {
+ const sal_Int32 nChunkSize = 4096;
+ uno::Sequence< sal_Int8 > aData(nChunkSize);
+ sal_Int32 nTotalRead = 0;
+ sal_Int32 nRead;
+ do
+ {
+ nRead = xIn->readBytes(aData, nChunkSize);
+ nTotalRead += nRead;
+ xOut->writeBytes(aData);
+ } while (nRead == nChunkSize);
+ return nTotalRead != 0;
+ }
+
+ //Dump the objects content to a tempfile, just the "CONTENTS" stream if
+ //there is one for non-compound documents, otherwise the whole content.
+ //
+ //On success a file is returned which must be removed by the caller
+ uno::Reference <beans::XPropertySet> lcl_DumpObject(::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xFactory,
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > xObjectStream)
+ {
+ uno::Reference < beans::XPropertySet > xNativeTempFile(
+ xFactory->createInstance(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.io.TempFile"))), uno::UNO_QUERY_THROW);
+ uno::Reference < io::XStream > xStream(xNativeTempFile, uno::UNO_QUERY_THROW);
+
+ uno::Sequence< uno::Any > aArgs( 2 );
+ aArgs[0] <<= xObjectStream;
+ aArgs[1] <<= (sal_Bool)sal_True; // do not create copy
+ uno::Reference< container::XNameContainer > xNameContainer(
+ xFactory->createInstanceWithArguments(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.embed.OLESimpleStorage")),
+ aArgs ), uno::UNO_QUERY_THROW );
+
+ uno::Reference< io::XStream > xCONTENTS;
+ xNameContainer->getByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CONTENTS"))) >>= xCONTENTS;
+
+ sal_Bool bCopied = xCONTENTS.is() && lcl_CopyStream(xCONTENTS->getInputStream(), xStream->getOutputStream());
+
+ uno::Reference< io::XSeekable > xSeekableStor(xObjectStream, uno::UNO_QUERY);
+ if (xSeekableStor.is())
+ xSeekableStor->seek(0);
+
+ if (!bCopied)
+ bCopied = lcl_CopyStream(xObjectStream->getInputStream(), xStream->getOutputStream());
+
+ if (bCopied)
+ {
+ xNativeTempFile->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RemoveFile")),
+ uno::makeAny(sal_False));
+ uno::Reference< io::XSeekable > xSeekableTemp(xObjectStream, uno::UNO_QUERY);
+ if (xSeekableTemp.is())
+ xSeekableTemp->seek(0);
+ }
+ else
+ {
+ xNativeTempFile->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RemoveFile")),
+ uno::makeAny(sal_True));
+ xNativeTempFile = uno::Reference<beans::XPropertySet>();
+ }
+
+ return xNativeTempFile;
+ }
+
+ //Given a file try and figure out from our type-detection system what type
+ //of suffix this type typically uses
+ ::rtl::OUString lcl_GetExtFromTypeDetect( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xFactory,
+ uno::Reference< io::XInputStream > xInputStream )
+ {
+ if ( !xInputStream.is() )
+ throw uno::RuntimeException();
+
+ uno::Reference< document::XTypeDetection > xTypeDetection(
+ xFactory->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.document.TypeDetection")),
+ uno::UNO_QUERY_THROW );
+
+ uno::Sequence< beans::PropertyValue > aArgs( 2 );
+ aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("URL" ));
+ aArgs[0].Value <<= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("file:///tmp/outplacedata"));
+ aArgs[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("InputStream"));
+ aArgs[1].Value <<= xInputStream;
+
+ ::rtl::OUString aTypeName = xTypeDetection->queryTypeByDescriptor( aArgs, sal_True );
+
+ ::rtl::OUString sExt;
+
+ if ( aTypeName.getLength() )
+ {
+ // get the default filter name for the type
+ uno::Reference< container::XNameAccess > xNameAccess( xTypeDetection, uno::UNO_QUERY_THROW );
+ uno::Sequence< beans::PropertyValue > aTypes;
+
+ if ( xNameAccess.is() && ( xNameAccess->getByName( aTypeName ) >>= aTypes ) )
+ {
+ for ( sal_Int32 nInd = 0; nInd < aTypes.getLength(); nInd++ )
+ {
+ uno::Sequence< ::rtl::OUString > lExtensions;
+ if ( aTypes[nInd].Name.equalsAscii( "Extensions" ) && ( aTypes[nInd].Value >>= lExtensions ) )
+ {
+ if (lExtensions.getLength())
+ sExt = lExtensions[0];
+ break;
+ }
+ }
+ }
+ }
+
+ //Not really a useful type
+ if (sExt == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("txt")))
+ sExt = ::rtl::OUString();
+
+ return sExt;
+ }
+
+ //See lcl_DumpObject, does the same, except assigns a type-detected suffix
+ //to the file if its a type that OOo knows about in order to help out the
+ //systems type detection mechanism
+ ::rtl::OUString lcl_DumpObjectToSuffixed(::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xFactory,
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > xObjectStream)
+ {
+ uno::Reference <beans::XPropertySet> xDumpFile = lcl_DumpObject(xFactory, xObjectStream);
+ if (!xDumpFile.is())
+ return rtl::OUString();
+
+ rtl::OUString sUrl;
+ uno::Any aUrl = xDumpFile->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Uri")));
+ aUrl >>= sUrl;
+
+ uno::Reference< document::XTypeDetection > xTypeDetection(
+ xFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.TypeDetection"))),
+ uno::UNO_QUERY);
+
+ uno::Reference<io::XStream> xStream(xDumpFile, uno::UNO_QUERY_THROW);
+
+ rtl::OUString sExt = lcl_GetExtFromTypeDetect(xFactory, xStream->getInputStream());
+
+ xDumpFile = uno::Reference <beans::XPropertySet>();
+
+ uno::Reference<ucb::XSimpleFileAccess> xSimpleFileAccess(
+ xFactory->createInstance(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.SimpleFileAccess"))),
+ uno::UNO_QUERY_THROW);
+
+ rtl::OUString sFinalUrl = sUrl;
+ if (sExt.getLength())
+ {
+ sFinalUrl = sFinalUrl + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".")) + sExt;
+ xSimpleFileAccess->move(sUrl, sFinalUrl);
+ }
+ xSimpleFileAccess->setReadOnly(sFinalUrl, sal_True);
+
+ return sFinalUrl;
+ }
+}
+
//----------------------------------------------
void SAL_CALL OleEmbeddedObject::doVerb( sal_Int32 nVerbID )
throw ( lang::IllegalArgumentException,
@@ -795,7 +960,26 @@
throw embed::UnreachableStateException();
}
else
- throw embed::UnreachableStateException();
+ {
+ if ( nVerbID == embed::EmbedVerbs::MS_OLEVERB_OPEN )
+ {
+ //Make a RO copy and see if the OS can find something to at
+ //display the content
+ if (!m_aTempDumpURL.getLength())
+ m_aTempDumpURL = lcl_DumpObjectToSuffixed(m_xFactory, m_xObjectStream);
+ if (m_aTempDumpURL.getLength())
+ {
+ uno::Reference< system::XSystemShellExecute > xSystemShellExecute( m_xFactory->createInstance(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.system.SystemShellExecute"))),
+ uno::UNO_QUERY_THROW);
+ xSystemShellExecute->execute(m_aTempDumpURL, ::rtl::OUString(), system::SystemShellExecuteFlags::DEFAULTS);
+ }
+ else
+ throw embed::UnreachableStateException();
+ }
+ else
+ throw embed::UnreachableStateException();
+ }
}
}
diff -ru embeddedobj.orig/source/msole/olemisc.cxx embeddedobj/source/msole/olemisc.cxx
--- embeddedobj.orig/source/msole/olemisc.cxx 2010-01-13 11:16:43.000000000 +0000
+++ embeddedobj/source/msole/olemisc.cxx 2010-01-14 11:29:37.000000000 +0000
@@ -161,6 +161,9 @@
if ( m_aTempURL.getLength() )
KillFile_Impl( m_aTempURL, m_xFactory );
+
+ if ( m_aTempDumpURL.getLength() )
+ KillFile_Impl( m_aTempDumpURL, m_xFactory );
}
//------------------------------------------------------
Index: openoffice.org.spec
===================================================================
RCS file: /cvs/pkgs/rpms/openoffice.org/devel/openoffice.org.spec,v
retrieving revision 1.2122
retrieving revision 1.2123
diff -u -p -r1.2122 -r1.2123
--- openoffice.org.spec 13 Jan 2010 15:04:53 -0000 1.2122
+++ openoffice.org.spec 14 Jan 2010 12:08:09 -0000 1.2123
@@ -1,6 +1,6 @@
%define oootag OOO320
%define ooomilestone 9
-%define rh_rpm_release 3
+%define rh_rpm_release 4
# rhbz#465664 jar-repacking breaks help by reordering META-INF/MANIFEST.MF
%define __jar_repack %{nil}
@@ -128,6 +128,7 @@ Patch52: openoffice.org-3.2.0.ooo107834.
Patch53: openoffice.org-3.3.0.ooo108047.writerfilter.safer-field-context-handling.patch
Patch54: openoffice.org-3.3.0.ooo108246.svx.check-for-possible-out-of-bounds-index.patch
Patch55: workspace.sw33bf02.patch
+Patch56: openoffice.org-3.2.0.oooXXXXX.embeddedobj.outplace.readonly.os.dispatch.patch
%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
%define instdir %{_libdir}
@@ -1683,6 +1684,7 @@ cp -p %{SOURCE5} external/unowinreg/unow
%patch53 -p1 -b .ooo108047.writerfilter.safer-field-context-handling.patch
%patch54 -p1 -b .ooo108246.svx.check-for-possible-out-of-bounds-index.patch
%patch55 -p1 -b .workspace.sw33bf02.patch
+%patch56 -p0 -b .oooXXXXX.embeddedobj.outplace.readonly.os.dispatch.patch
%build
echo build start time is `date`, diskspace: `df -h . | tail -n 1`
@@ -4165,6 +4167,9 @@ fi
%endif
%changelog
+* Thu Jan 14 2010 Caolán McNamara <caolanm at redhat.com> - 1:3.2.0-9.4
+- Resolves: rhbz#550043 dispatch outplace objects as ro documents to OS (caolanm)
+
* Wed Jan 13 2010 Caolán McNamara <caolanm at redhat.com> - 1:3.2.0-9.3
- Resolves: rhbz#553929 [abrt] crash in ColorConfigCtrl_Impl::ScrollHdl
(dtardon)
More information about the scm-commits
mailing list