summaryrefslogtreecommitdiff
path: root/sw/source/core/graphic/ndgrf.cxx
diff options
context:
space:
mode:
authorMatteo Casalin <matteo.casalin@yahoo.com>2013-10-05 16:58:37 +0200
committerMatteo Casalin <matteo.casalin@yahoo.com>2013-10-05 19:44:40 +0200
commitf37bb5d4426948cacc6928d501de01844adbc8f1 (patch)
tree562cf3d01f3d6445b5a0e18ab71d1b0f4b03b383 /sw/source/core/graphic/ndgrf.cxx
parent74c7539c091a9b6781eae7d3f07d45546499d3b6 (diff)
String to OUString + use return instead of reference args
Change-Id: I0c0857b4b4ac87586675e8540ef5135dbce82b5c
Diffstat (limited to 'sw/source/core/graphic/ndgrf.cxx')
-rw-r--r--sw/source/core/graphic/ndgrf.cxx68
1 files changed, 33 insertions, 35 deletions
diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx
index c35d084d5fbd..439d9929736c 100644
--- a/sw/source/core/graphic/ndgrf.cxx
+++ b/sw/source/core/graphic/ndgrf.cxx
@@ -466,40 +466,42 @@ sal_Bool SwGrfNode::ImportGraphic( SvStream& rStrm )
namespace
{
-void lcl_GetStreamStorageNames( String aUserData,
- String& rStrmName,
- String& rStorName )
+struct StreamAndStorageNames
{
- rStorName.Erase();
- rStrmName.Erase();
+ OUString sStream;
+ OUString sStorage;
+};
- if( !aUserData.Len() )
- return;
+StreamAndStorageNames lcl_GetStreamStorageNames( OUString aUserData )
+{
+ StreamAndStorageNames aNames;
+ if( aUserData.isEmpty() )
+ return aNames;
- String aProt( "vnd.sun.star.Package:" );
- if( 0 == aUserData.CompareTo( aProt, aProt.Len() ) )
+ const OUString aProt( "vnd.sun.star.Package:" );
+ if (aUserData.startsWith(aProt))
{
// 6.0 (XML) Package
- xub_StrLen nPos = aUserData.Search( '/' );
- if( STRING_NOTFOUND == nPos )
+ const sal_Int32 nPos = aUserData.indexOf('/');
+ if (nPos<0)
{
- rStrmName = aUserData.Copy( aProt.Len() );
+ aNames.sStream = aUserData.copy(aProt.getLength());
}
else
{
- xub_StrLen nPathStart = aProt.Len();
- if( 0 == aUserData.CompareToAscii( "./", 2 ) )
+ sal_Int32 nPathStart = aProt.getLength();
+ if (aUserData.startsWith("./"))
nPathStart += 2;
- rStorName = aUserData.Copy( nPathStart, nPos-nPathStart );
- rStrmName = aUserData.Copy( nPos+1 );
+ aNames.sStorage = aUserData.copy( nPathStart, nPos-nPathStart );
+ aNames.sStream = aUserData.copy( nPos+1 );
}
}
else
{
OSL_FAIL( "<lcl_GetStreamStorageNames(..)> - unknown graphic URL type. Code for handling 3.1 - 5.2 storages has been deleted by issue i53025." );
}
- OSL_ENSURE( STRING_NOTFOUND == rStrmName.Search( '/' ),
- "invalid graphic stream name" );
+ OSL_ENSURE( aNames.sStream.indexOf('/')<0, "invalid graphic stream name" );
+ return aNames;
}
}
@@ -554,10 +556,9 @@ short SwGrfNode::SwapIn( sal_Bool bWaitForData )
{
try
{
- String aStrmName, aPicStgName;
- lcl_GetStreamStorageNames( maGrfObj.GetUserData(), aStrmName, aPicStgName );
- uno::Reference < embed::XStorage > refPics = _GetDocSubstorageOrRoot( aPicStgName );
- SvStream* pStrm = _GetStreamForEmbedGrf( refPics, aStrmName );
+ const StreamAndStorageNames aNames = lcl_GetStreamStorageNames( maGrfObj.GetUserData() );
+ uno::Reference < embed::XStorage > refPics = _GetDocSubstorageOrRoot( aNames.sStorage );
+ SvStream* pStrm = _GetStreamForEmbedGrf( refPics, aNames.sStream );
if ( pStrm )
{
if ( ImportGraphic( *pStrm ) )
@@ -816,12 +817,11 @@ void SwGrfNode::DelStreamName()
{
try
{
- String aPicStgName, aStrmName;
- lcl_GetStreamStorageNames( maGrfObj.GetUserData(), aStrmName, aPicStgName );
+ const StreamAndStorageNames aNames = lcl_GetStreamStorageNames( maGrfObj.GetUserData() );
uno::Reference < embed::XStorage > refPics = xDocStg;
- if ( aPicStgName.Len() )
- refPics = xDocStg->openStorageElement( aPicStgName, embed::ElementModes::READWRITE );
- refPics->removeElement( aStrmName );
+ if ( !aNames.sStorage.isEmpty() )
+ refPics = xDocStg->openStorageElement( aNames.sStorage, embed::ElementModes::READWRITE );
+ refPics->removeElement( aNames.sStream );
uno::Reference < embed::XTransactedObject > xTrans( refPics, uno::UNO_QUERY );
if ( xTrans.is() )
xTrans->commit();
@@ -923,10 +923,9 @@ SwCntntNode* SwGrfNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const
{
try
{
- String aStrmName, aPicStgName;
- lcl_GetStreamStorageNames( maGrfObj.GetUserData(), aStrmName, aPicStgName );
- uno::Reference < embed::XStorage > refPics = _GetDocSubstorageOrRoot( aPicStgName );
- SvStream* pStrm = _GetStreamForEmbedGrf( refPics, aStrmName );
+ const StreamAndStorageNames aNames = lcl_GetStreamStorageNames( maGrfObj.GetUserData() );
+ uno::Reference < embed::XStorage > refPics = _GetDocSubstorageOrRoot( aNames.sStorage );
+ SvStream* pStrm = _GetStreamForEmbedGrf( refPics, aNames.sStream );
if ( pStrm )
{
const OUString aURL(maGrfObj.GetUserData());
@@ -1003,10 +1002,9 @@ IMPL_LINK( SwGrfNode, SwapGraphic, GraphicObject*, pGrfObj )
{
try
{
- String aStrmName, aPicStgName;
- lcl_GetStreamStorageNames( maGrfObj.GetUserData(), aStrmName, aPicStgName );
- uno::Reference < embed::XStorage > refPics = _GetDocSubstorageOrRoot( aPicStgName );
- SvStream* pStrm = _GetStreamForEmbedGrf( refPics, aStrmName );
+ const StreamAndStorageNames aNames = lcl_GetStreamStorageNames( maGrfObj.GetUserData() );
+ uno::Reference < embed::XStorage > refPics = _GetDocSubstorageOrRoot( aNames.sStorage );
+ SvStream* pStrm = _GetStreamForEmbedGrf( refPics, aNames.sStream );
if ( pStrm )
{
if( pGrfObj->IsInSwapOut() )