diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-01-04 16:45:34 +0000 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-01-05 15:16:18 +0100 |
commit | 3e146690d527d1c736685640e9f11172c7d087ba (patch) | |
tree | 27b1210be19252ea01011432ca21f3655bb6ec89 | |
parent | 8d4d879eaadfdabf9ec00a223750dce20f95e158 (diff) |
Resolves: fdo#43867 collection of problems causing loss of ole2 previews
a) factor out part of SvXMLEmbeddedObjectHelper::ImplGetStorageNames as
splitObjectURL to reuse in SvXMLGraphicHelper::ImplGetStreamNames to get better
url splitting logic to handle "./ObjectReplacements/foo"
b) FN_UNO_REPLACEMENT_GRAPHIC_URL and FN_UNO_GRAPHIC ids collide
urls incorrectly treated as graphics
c) imported preview images for objects set on a temporary
svt::EmbeddedObjectRef *copy* of the object, not the real object.
(cherry picked from commit ef17be8b006737c078a59635ae334a03301727ea)
Signed-off-by: Michael Stahl <mstahl@redhat.com>
Conflicts:
svx/source/xml/xmlgrhlp.cxx
-rw-r--r-- | svx/inc/svx/xmleohlp.hxx | 5 | ||||
-rw-r--r-- | svx/source/xml/xmleohlp.cxx | 78 | ||||
-rw-r--r-- | svx/source/xml/xmlgrhlp.cxx | 20 | ||||
-rw-r--r-- | sw/inc/cmdid.h | 6 | ||||
-rw-r--r-- | sw/source/core/unocore/unoframe.cxx | 4 |
5 files changed, 58 insertions, 55 deletions
diff --git a/svx/inc/svx/xmleohlp.hxx b/svx/inc/svx/xmleohlp.hxx index 88d965133367..247038bcdfdf 100644 --- a/svx/inc/svx/xmleohlp.hxx +++ b/svx/inc/svx/xmleohlp.hxx @@ -145,6 +145,11 @@ public: // XNameAccess virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw (::com::sun::star::uno::RuntimeException); virtual sal_Bool SAL_CALL hasElements( ) throw (::com::sun::star::uno::RuntimeException); + + + static void splitObjectURL(::rtl::OUString aURLNoPar, + ::rtl::OUString& rContainerStorageName, + ::rtl::OUString& rObjectStorageName); }; #endif diff --git a/svx/source/xml/xmleohlp.cxx b/svx/source/xml/xmleohlp.cxx index 83bf4648fec5..f20158c4662e 100644 --- a/svx/source/xml/xmleohlp.cxx +++ b/svx/source/xml/xmleohlp.cxx @@ -206,6 +206,48 @@ void SAL_CALL SvXMLEmbeddedObjectHelper::disposing() Flush(); } + +void SvXMLEmbeddedObjectHelper::splitObjectURL(::rtl::OUString aURLNoPar, + ::rtl::OUString& rContainerStorageName, + ::rtl::OUString& rObjectStorageName) +{ + DBG_ASSERT( '#' != aURLNoPar[0], "invalid object URL" ); + + sal_Int32 _nPos = aURLNoPar.lastIndexOf( '/' ); + if( -1 == _nPos ) + { + rContainerStorageName = ::rtl::OUString(); + rObjectStorageName = aURLNoPar; + } + else + { + //eliminate 'superfluous' slashes at start and end + //#i103076# load objects with all allowed xlink:href syntaxes + { + //eliminate './' at start + sal_Int32 nStart = 0; + sal_Int32 nCount = aURLNoPar.getLength(); + if( 0 == aURLNoPar.compareToAscii( "./", 2 ) ) + { + nStart = 2; + nCount -= 2; + } + + //eliminate '/' at end + sal_Int32 nEnd = aURLNoPar.lastIndexOf( '/' ); + if( nEnd == aURLNoPar.getLength()-1 && nEnd != (nStart-1) ) + nCount--; + + aURLNoPar = aURLNoPar.copy( nStart, nCount ); + } + + _nPos = aURLNoPar.lastIndexOf( '/' ); + if( _nPos >= 0 ) + rContainerStorageName = aURLNoPar.copy( 0, _nPos ); + rObjectStorageName = aURLNoPar.copy( _nPos+1 ); + } +} + // ----------------------------------------------------------------------------- sal_Bool SvXMLEmbeddedObjectHelper::ImplGetStorageNames( @@ -308,41 +350,7 @@ sal_Bool SvXMLEmbeddedObjectHelper::ImplGetStorageNames( } else { - DBG_ASSERT( '#' != aURLNoPar[0], "invalid object URL" ); - - sal_Int32 _nPos = aURLNoPar.lastIndexOf( '/' ); - if( -1 == _nPos ) - { - rContainerStorageName = ::rtl::OUString(); - rObjectStorageName = aURLNoPar; - } - else - { - //eliminate 'superfluous' slashes at start and end - //#i103076# load objects with all allowed xlink:href syntaxes - { - //eliminate './' at start - sal_Int32 nStart = 0; - sal_Int32 nCount = aURLNoPar.getLength(); - if( 0 == aURLNoPar.compareToAscii( "./", 2 ) ) - { - nStart = 2; - nCount -= 2; - } - - //eliminate '/' at end - sal_Int32 nEnd = aURLNoPar.lastIndexOf( '/' ); - if( nEnd == aURLNoPar.getLength()-1 && nEnd != (nStart-1) ) - nCount--; - - aURLNoPar = aURLNoPar.copy( nStart, nCount ); - } - - _nPos = aURLNoPar.lastIndexOf( '/' ); - if( _nPos >= 0 ) - rContainerStorageName = aURLNoPar.copy( 0, _nPos ); - rObjectStorageName = aURLNoPar.copy( _nPos+1 ); - } + splitObjectURL(aURLNoPar, rContainerStorageName, rObjectStorageName); } if( -1 != rContainerStorageName.indexOf( '/' ) ) diff --git a/svx/source/xml/xmlgrhlp.cxx b/svx/source/xml/xmlgrhlp.cxx index 110618f53e04..2f57a9e09d39 100644 --- a/svx/source/xml/xmlgrhlp.cxx +++ b/svx/source/xml/xmlgrhlp.cxx @@ -49,6 +49,7 @@ #include "svtools/filter.hxx" #include "svx/xmlgrhlp.hxx" +#include "svx/xmleohlp.hxx" #include <algorithm> @@ -439,23 +440,12 @@ sal_Bool SvXMLGraphicHelper::ImplGetStreamNames( const ::rtl::OUString& rURLStr, { rPictureStorageName = String( RTL_CONSTASCII_USTRINGPARAM( XML_GRAPHICSTORAGE_NAME ) ); rPictureStreamName = aURLStr; - bRet = sal_True; - } - else if( 2 == nTokenCount ) - { - rPictureStorageName = aURLStr.GetToken( 0, '/' ); - - DBG_ASSERT( rPictureStorageName.getLength() && - rPictureStorageName.getStr()[ 0 ] != '#', - "invalid relative URL" ); - - rPictureStreamName = aURLStr.GetToken( 1, '/' ); - bRet = sal_True; } else - { - SAL_WARN("svx", "SvXMLGraphicHelper::ImplInsertGraphicURL: invalid scheme: " << rURLStr); - } + SvXMLEmbeddedObjectHelper::splitObjectURL(aURLStr, rPictureStorageName, rPictureStreamName); + + bRet = !rPictureStreamName.isEmpty(); + SAL_WARN_IF(!bRet, "svx", "SvXMLGraphicHelper::ImplInsertGraphicURL: invalid scheme: " << rURLStr); } return bRet; diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h index 33c287bec513..7802db719670 100644 --- a/sw/inc/cmdid.h +++ b/sw/inc/cmdid.h @@ -842,10 +842,10 @@ included in c-context files, so c++ style stuff will cause problems. #define FN_UNO_COMPONENT (FN_EXTRA2 + 97) #define FN_WORDCOUNT_DIALOG (FN_EXTRA2 + 98) -#define FN_XFORMS_DESIGN_MODE (FN_EXTRA2 + 100) +#define FN_XFORMS_DESIGN_MODE (FN_EXTRA2 + 99) -#define FN_UNO_PARA_STYLE_CONDITIONS (FN_EXTRA2 + 101) -#define FN_UNO_GRAPHIC (FN_EXTRA2 + 102) +#define FN_UNO_PARA_STYLE_CONDITIONS (FN_EXTRA2 + 100) +#define FN_UNO_GRAPHIC (FN_EXTRA2 + 101) #define FN_UNO_REPLACEMENT_GRAPHIC_URL (FN_EXTRA2 + 102) #define FN_UNO_CELL_ROW_SPAN (FN_EXTRA2 + 103) diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index 2091ac628f0f..141dabfbe537 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -1211,10 +1211,10 @@ void SwXFrame::setPropertyValue(const :: OUString& rPropertyName, const :: uno:: if ( pOleNode ) { - svt::EmbeddedObjectRef xObj = pOleNode->GetOLEObj().GetObject(); + svt::EmbeddedObjectRef &rObj = pOleNode->GetOLEObj().GetObject(); ::rtl::OUString aMediaType; - xObj.SetGraphic( aGraphic, aMediaType ); + rObj.SetGraphic( aGraphic, aMediaType ); } } } |