summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2013-12-17 10:23:30 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-12-17 10:25:22 +0000
commitcd6a7ec9623e68e0fd301fe74e6b03962508ab9e (patch)
tree557445f51a226e0ec6c8c73ec9bd3daf79ca3b63
parentb95f4fad1acc01857cdc83af23506a4bce6c4ccd (diff)
avoid negative offsets to OUString::copy
Change-Id: I0a62f8a38694a4a7662fe376aaabc35dca817d33 (cherry picked from commit c2f0845931b7cb1007d54173c2633c44123a137c)
-rw-r--r--svx/source/gallery2/galmisc.cxx20
1 files changed, 16 insertions, 4 deletions
diff --git a/svx/source/gallery2/galmisc.cxx b/svx/source/gallery2/galmisc.cxx
index b1214d5f96e4..fca950f8660f 100644
--- a/svx/source/gallery2/galmisc.cxx
+++ b/svx/source/gallery2/galmisc.cxx
@@ -199,10 +199,22 @@ OUString GetReducedString( const INetURLObject& rURL, sal_Int32 nMaxLen )
if( aPath.getLength() > nMaxLen )
{
- aReduced = aPath.copy( 0, nMaxLen - aName.getLength() - 4 );
- aReduced += "...";
- aReduced += OUString(aDelimiter);
- aReduced += aName;
+ sal_Int32 nPathPrefixLen = nMaxLen - aName.getLength() - 4;
+
+ if (nPathPrefixLen >= 0)
+ {
+ aReduced = aPath.copy(0, nPathPrefixLen);
+ aReduced += "...";
+ aReduced += OUString(aDelimiter);
+ aReduced += aName;
+ }
+ else
+ {
+ aReduced += "...";
+ aReduced += OUString(aDelimiter);
+ aReduced += "...";
+ aReduced += aName.copy( aName.getLength() - (nMaxLen - 7) );
+ }
}
else
aReduced = aPath;