summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-01-04 16:45:34 +0000
committerCaolán McNamara <caolanm@redhat.com>2012-01-05 09:18:21 +0000
commitef17be8b006737c078a59635ae334a03301727ea (patch)
treebe3d9cfbee5e1b5d1b78297734c6c80c6b25b507
parenta37484060c63138e869937ca518c723b36c1893d (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.
-rw-r--r--svx/inc/svx/xmleohlp.hxx5
-rw-r--r--svx/source/xml/xmleohlp.cxx78
-rw-r--r--svx/source/xml/xmlgrhlp.cxx21
-rw-r--r--sw/inc/cmdid.h6
-rw-r--r--sw/source/core/unocore/unoframe.cxx4
5 files changed, 59 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 d18bfb52ec91..e3555467f43a 100644
--- a/svx/source/xml/xmlgrhlp.cxx
+++ b/svx/source/xml/xmlgrhlp.cxx
@@ -50,6 +50,7 @@
#include "svtools/filter.hxx"
#include "svx/xmlgrhlp.hxx"
+#include "svx/xmleohlp.hxx"
#include <algorithm>
@@ -434,29 +435,19 @@ sal_Bool SvXMLGraphicHelper::ImplGetStreamNames( const ::rtl::OUString& rURLStr,
if( aURLStr.Len() )
{
aURLStr = aURLStr.GetToken( comphelper::string::getTokenCount(aURLStr, ':') - 1, ':' );
+
const sal_uInt32 nTokenCount = comphelper::string::getTokenCount(aURLStr, '/');
if( 1 == nTokenCount )
{
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 );
}
}
}