summaryrefslogtreecommitdiff
path: root/embeddedobj/source
diff options
context:
space:
mode:
authorKurt Zenker <kz@openoffice.org>2006-04-26 13:23:04 +0000
committerKurt Zenker <kz@openoffice.org>2006-04-26 13:23:04 +0000
commit407ac222c2f87ef3bc329eb345d37911abfba252 (patch)
tree74c82fb6eb94581de5a9b01d6726c7f1a0afbe45 /embeddedobj/source
parent2b0651acfcaaeb024637cdc77cd1e4f51f2a3753 (diff)
INTEGRATION: CWS fwk37 (1.26.8); FILE MERGED
2006/04/07 13:36:37 mav 1.26.8.3: #b6404500# introduce workaround for 50 OLE objects created by SO6 2006/04/05 14:26:58 mav 1.26.8.2: RESYNC: (1.26-1.27); FILE MERGED 2006/03/29 09:00:34 mav 1.26.8.1: #b6404500# introduce workaround for 50 OLE objects created by SO6
Diffstat (limited to 'embeddedobj/source')
-rw-r--r--embeddedobj/source/msole/olepersist.cxx76
1 files changed, 73 insertions, 3 deletions
diff --git a/embeddedobj/source/msole/olepersist.cxx b/embeddedobj/source/msole/olepersist.cxx
index d080e8cb1c93..dadd1038a24d 100644
--- a/embeddedobj/source/msole/olepersist.cxx
+++ b/embeddedobj/source/msole/olepersist.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: olepersist.cxx,v $
*
- * $Revision: 1.27 $
+ * $Revision: 1.28 $
*
- * last change: $Author: obo $ $Date: 2006-03-24 13:08:20 $
+ * last change: $Author: kz $ $Date: 2006-04-26 14:23:04 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -95,6 +95,7 @@
#include <rtl/logfile.hxx>
#include <comphelper/storagehelper.hxx>
+#include <comphelper/classids.hxx>
#include <olecomponent.hxx>
@@ -774,7 +775,8 @@ sal_Bool OleEmbeddedObject::HasVisReplInStream()
//------------------------------------------------------
uno::Reference< io::XStream > OleEmbeddedObject::TryToRetrieveCachedVisualRepresentation_Impl(
- const uno::Reference< io::XStream >& xStream )
+ const uno::Reference< io::XStream >& xStream,
+ sal_Bool bAllowToRepair50 )
throw ()
{
uno::Reference< io::XStream > xResult;
@@ -828,6 +830,74 @@ uno::Reference< io::XStream > OleEmbeddedObject::TryToRetrieveCachedVisualRepres
{}
}
}
+
+ try
+ {
+ if ( bAllowToRepair50 && !xResult.is() )
+ {
+ ::rtl::OUString aOrigContName( RTL_CONSTASCII_USTRINGPARAM( "Ole-Object" ) );
+ if ( xNameContainer->hasByName( aOrigContName ) )
+ {
+ uno::Reference< embed::XClassifiedObject > xClassified( xNameContainer, uno::UNO_QUERY_THROW );
+ uno::Sequence< sal_Int8 > aClassID;
+ if ( ClassIDsEqual( xClassified->getClassID(), GetSequenceClassID( SO3_OUT_CLASSID ) ) )
+ {
+ // this is an OLE object wrongly stored in 5.0 format
+ // this object must be repaired since SO7 has done it
+
+ uno::Reference< io::XOutputStream > xOutputStream = xStream->getOutputStream();
+ uno::Reference< io::XTruncate > xTruncate( xOutputStream, uno::UNO_QUERY_THROW );
+
+ uno::Reference< io::XInputStream > xOrigInputStream;
+ if ( ( xNameContainer->getByName( aOrigContName ) >>= xOrigInputStream )
+ && xOrigInputStream.is() )
+ {
+ // the provided input stream must be based on temporary medium and must be independent
+ // from the stream the storage is based on
+ uno::Reference< io::XSeekable > xOrigSeekable( xOrigInputStream, uno::UNO_QUERY );
+ if ( xOrigSeekable.is() )
+ xOrigSeekable->seek( 0 );
+
+ uno::Reference< lang::XComponent > xNameContDisp( xNameContainer, uno::UNO_QUERY_THROW );
+ xNameContDisp->dispose(); // free the original stream
+
+ xTruncate->truncate();
+ ::comphelper::OStorageHelper::CopyInputToOutput( xOrigInputStream, xOutputStream );
+ xOutputStream->flush();
+
+ if ( xStream == m_xObjectStream )
+ {
+ if ( m_aTempURL.getLength() )
+ {
+ // this is the own stream, so the temporary URL must be cleaned if it exists
+ KillFile_Impl( m_aTempURL, m_xFactory );
+ m_aTempURL = ::rtl::OUString();
+ }
+
+#ifdef WNT
+ // retry to create the component after recovering
+ GetRidOfComponent();
+
+ try
+ {
+ CreateOleComponentAndLoad_Impl( NULL );
+ m_aClassID = m_pOleComponent->GetCLSID(); // was not set during consruction
+ }
+ catch( uno::Exception& )
+ {
+ GetRidOfComponent();
+ }
+#endif
+ }
+
+ xResult = TryToRetrieveCachedVisualRepresentation_Impl( xStream, sal_False );
+ }
+ }
+ }
+ }
+ }
+ catch( uno::Exception& )
+ {}
}
}