Kaydet (Commit) f37bb5d4 authored tarafından Matteo Casalin's avatar Matteo Casalin

String to OUString + use return instead of reference args

Change-Id: I0c0857b4b4ac87586675e8540ef5135dbce82b5c
üst 74c7539c
...@@ -466,40 +466,42 @@ sal_Bool SwGrfNode::ImportGraphic( SvStream& rStrm ) ...@@ -466,40 +466,42 @@ sal_Bool SwGrfNode::ImportGraphic( SvStream& rStrm )
namespace namespace
{ {
void lcl_GetStreamStorageNames( String aUserData, struct StreamAndStorageNames
String& rStrmName,
String& rStorName )
{ {
rStorName.Erase(); OUString sStream;
rStrmName.Erase(); OUString sStorage;
};
if( !aUserData.Len() ) StreamAndStorageNames lcl_GetStreamStorageNames( OUString aUserData )
return; {
StreamAndStorageNames aNames;
if( aUserData.isEmpty() )
return aNames;
String aProt( "vnd.sun.star.Package:" ); const OUString aProt( "vnd.sun.star.Package:" );
if( 0 == aUserData.CompareTo( aProt, aProt.Len() ) ) if (aUserData.startsWith(aProt))
{ {
// 6.0 (XML) Package // 6.0 (XML) Package
xub_StrLen nPos = aUserData.Search( '/' ); const sal_Int32 nPos = aUserData.indexOf('/');
if( STRING_NOTFOUND == nPos ) if (nPos<0)
{ {
rStrmName = aUserData.Copy( aProt.Len() ); aNames.sStream = aUserData.copy(aProt.getLength());
} }
else else
{ {
xub_StrLen nPathStart = aProt.Len(); sal_Int32 nPathStart = aProt.getLength();
if( 0 == aUserData.CompareToAscii( "./", 2 ) ) if (aUserData.startsWith("./"))
nPathStart += 2; nPathStart += 2;
rStorName = aUserData.Copy( nPathStart, nPos-nPathStart ); aNames.sStorage = aUserData.copy( nPathStart, nPos-nPathStart );
rStrmName = aUserData.Copy( nPos+1 ); aNames.sStream = aUserData.copy( nPos+1 );
} }
} }
else else
{ {
OSL_FAIL( "<lcl_GetStreamStorageNames(..)> - unknown graphic URL type. Code for handling 3.1 - 5.2 storages has been deleted by issue i53025." ); 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( '/' ), OSL_ENSURE( aNames.sStream.indexOf('/')<0, "invalid graphic stream name" );
"invalid graphic stream name" ); return aNames;
} }
} }
...@@ -554,10 +556,9 @@ short SwGrfNode::SwapIn( sal_Bool bWaitForData ) ...@@ -554,10 +556,9 @@ short SwGrfNode::SwapIn( sal_Bool bWaitForData )
{ {
try try
{ {
String aStrmName, aPicStgName; const StreamAndStorageNames aNames = lcl_GetStreamStorageNames( maGrfObj.GetUserData() );
lcl_GetStreamStorageNames( maGrfObj.GetUserData(), aStrmName, aPicStgName ); uno::Reference < embed::XStorage > refPics = _GetDocSubstorageOrRoot( aNames.sStorage );
uno::Reference < embed::XStorage > refPics = _GetDocSubstorageOrRoot( aPicStgName ); SvStream* pStrm = _GetStreamForEmbedGrf( refPics, aNames.sStream );
SvStream* pStrm = _GetStreamForEmbedGrf( refPics, aStrmName );
if ( pStrm ) if ( pStrm )
{ {
if ( ImportGraphic( *pStrm ) ) if ( ImportGraphic( *pStrm ) )
...@@ -816,12 +817,11 @@ void SwGrfNode::DelStreamName() ...@@ -816,12 +817,11 @@ void SwGrfNode::DelStreamName()
{ {
try try
{ {
String aPicStgName, aStrmName; const StreamAndStorageNames aNames = lcl_GetStreamStorageNames( maGrfObj.GetUserData() );
lcl_GetStreamStorageNames( maGrfObj.GetUserData(), aStrmName, aPicStgName );
uno::Reference < embed::XStorage > refPics = xDocStg; uno::Reference < embed::XStorage > refPics = xDocStg;
if ( aPicStgName.Len() ) if ( !aNames.sStorage.isEmpty() )
refPics = xDocStg->openStorageElement( aPicStgName, embed::ElementModes::READWRITE ); refPics = xDocStg->openStorageElement( aNames.sStorage, embed::ElementModes::READWRITE );
refPics->removeElement( aStrmName ); refPics->removeElement( aNames.sStream );
uno::Reference < embed::XTransactedObject > xTrans( refPics, uno::UNO_QUERY ); uno::Reference < embed::XTransactedObject > xTrans( refPics, uno::UNO_QUERY );
if ( xTrans.is() ) if ( xTrans.is() )
xTrans->commit(); xTrans->commit();
...@@ -923,10 +923,9 @@ SwCntntNode* SwGrfNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const ...@@ -923,10 +923,9 @@ SwCntntNode* SwGrfNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const
{ {
try try
{ {
String aStrmName, aPicStgName; const StreamAndStorageNames aNames = lcl_GetStreamStorageNames( maGrfObj.GetUserData() );
lcl_GetStreamStorageNames( maGrfObj.GetUserData(), aStrmName, aPicStgName ); uno::Reference < embed::XStorage > refPics = _GetDocSubstorageOrRoot( aNames.sStorage );
uno::Reference < embed::XStorage > refPics = _GetDocSubstorageOrRoot( aPicStgName ); SvStream* pStrm = _GetStreamForEmbedGrf( refPics, aNames.sStream );
SvStream* pStrm = _GetStreamForEmbedGrf( refPics, aStrmName );
if ( pStrm ) if ( pStrm )
{ {
const OUString aURL(maGrfObj.GetUserData()); const OUString aURL(maGrfObj.GetUserData());
...@@ -1003,10 +1002,9 @@ IMPL_LINK( SwGrfNode, SwapGraphic, GraphicObject*, pGrfObj ) ...@@ -1003,10 +1002,9 @@ IMPL_LINK( SwGrfNode, SwapGraphic, GraphicObject*, pGrfObj )
{ {
try try
{ {
String aStrmName, aPicStgName; const StreamAndStorageNames aNames = lcl_GetStreamStorageNames( maGrfObj.GetUserData() );
lcl_GetStreamStorageNames( maGrfObj.GetUserData(), aStrmName, aPicStgName ); uno::Reference < embed::XStorage > refPics = _GetDocSubstorageOrRoot( aNames.sStorage );
uno::Reference < embed::XStorage > refPics = _GetDocSubstorageOrRoot( aPicStgName ); SvStream* pStrm = _GetStreamForEmbedGrf( refPics, aNames.sStream );
SvStream* pStrm = _GetStreamForEmbedGrf( refPics, aStrmName );
if ( pStrm ) if ( pStrm )
{ {
if( pGrfObj->IsInSwapOut() ) if( pGrfObj->IsInSwapOut() )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment