[Libreoffice-commits] .: 7 commits - filter/inc filter/source sc/source sd/source svx/workben sw/source tools/inc tools/source vcl/generic

Caolán McNamara caolan at kemper.freedesktop.org
Fri Jan 13 08:47:10 PST 2012


 filter/inc/filter/msfilter/msdffimp.hxx  |    4 -
 filter/source/msfilter/msdffimp.cxx      |  117 +++++++++++++------------------
 filter/source/msfilter/svdfppt.cxx       |   13 ++-
 sc/source/ui/dbgui/scuiasciiopt.cxx      |    4 -
 sc/source/ui/docshell/impex.cxx          |   85 +++++++++++++++++++++-
 sc/source/ui/inc/impex.hxx               |   53 ++++++++++++++
 sd/source/filter/ppt/pptinanimations.cxx |    4 -
 svx/workben/msview/xmlconfig.cxx         |    3 
 sw/source/filter/ww1/w1class.cxx         |    7 -
 sw/source/filter/ww8/ww8scan.cxx         |   14 ---
 tools/inc/tools/stream.hxx               |   91 ++++++------------------
 tools/source/stream/stream.cxx           |   87 -----------------------
 vcl/generic/fontmanager/fontcache.cxx    |    4 -
 vcl/generic/fontmanager/fontconfig.cxx   |   16 ++--
 vcl/generic/fontmanager/fontmanager.cxx  |   12 +--
 vcl/generic/fontmanager/helper.cxx       |   12 +--
 16 files changed, 253 insertions(+), 273 deletions(-)

New commits:
commit 17fe34ec569f3e14f35f3958cc5885a00bd6cff9
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Jan 13 16:38:27 2012 +0000

    here calc, take ownership of this foul monstrosity only you use
    
    SvStream::ReadCsvLine doesn't need to be a member of Stream and the subcomment
    about what's wrong with the method is longer than the body of the method.
    
    Only used by calc, so can go into calc.
    
    foul monstrosity back

diff --git a/sc/source/ui/dbgui/scuiasciiopt.cxx b/sc/source/ui/dbgui/scuiasciiopt.cxx
index fdb1fa8..834d0cc 100644
--- a/sc/source/ui/dbgui/scuiasciiopt.cxx
+++ b/sc/source/ui/dbgui/scuiasciiopt.cxx
@@ -476,7 +476,7 @@ bool ScImportAsciiDlg::GetLine( sal_uLong nLine, String &rText )
                 bRet = false;
                 break;
             }
-            mpDatStream->ReadCsvLine( rText, !bFixed, maFieldSeparators,
+            ReadCsvLine(*mpDatStream, rText, !bFixed, maFieldSeparators,
                     mcTextSep);
             mnStreamPos = mpDatStream->Tell();
             mpRowPosArray[++mnRowPosCount] = mnStreamPos;
@@ -494,7 +494,7 @@ bool ScImportAsciiDlg::GetLine( sal_uLong nLine, String &rText )
     else
     {
         Seek( mpRowPosArray[nLine]);
-        mpDatStream->ReadCsvLine( rText, !bFixed, maFieldSeparators, mcTextSep);
+        ReadCsvLine(*mpDatStream, rText, !bFixed, maFieldSeparators, mcTextSep);
         mnStreamPos = mpDatStream->Tell();
     }
 
diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index a10ab39..b7922b3 100644
--- a/sc/source/ui/docshell/impex.cxx
+++ b/sc/source/ui/docshell/impex.cxx
@@ -1180,7 +1180,7 @@ sal_Bool ScImportExport::ExtText2Doc( SvStream& rStrm )
 
     while(--nSkipLines>0)
     {
-        rStrm.ReadCsvLine( aLine, !bFixed, rSeps, cStr); // content is ignored
+        ReadCsvLine(rStrm, aLine, !bFixed, rSeps, cStr); // content is ignored
         if ( rStrm.IsEof() )
             break;
     }
@@ -1203,7 +1203,7 @@ sal_Bool ScImportExport::ExtText2Doc( SvStream& rStrm )
     {
         for( ;; )
         {
-            rStrm.ReadCsvLine( aLine, !bFixed, rSeps, cStr);
+            ReadCsvLine(rStrm, aLine, !bFixed, rSeps, cStr);
             if ( rStrm.IsEof() )
                 break;
 
@@ -2109,4 +2109,85 @@ ScFormatFilterPlugin &ScFormatFilter::Get()
     return *plugin;
 }
 
+// Precondition: pStr is guaranteed to be non-NULL and points to a 0-terminated
+// array.
+inline const sal_Unicode* lcl_UnicodeStrChr( const sal_Unicode* pStr,
+        sal_Unicode c )
+{
+    while (*pStr)
+    {
+        if (*pStr == c)
+            return pStr;
+        ++pStr;
+    }
+    return 0;
+}
+
+void ReadCsvLine(SvStream &rStream, String& rStr, sal_Bool bEmbeddedLineBreak,
+        const String& rFieldSeparators, sal_Unicode cFieldQuote,
+        sal_Bool bAllowBackslashEscape)
+{
+    rStream.ReadUniOrByteStringLine(rStr, rStream.GetStreamCharSet());
+
+    if (bEmbeddedLineBreak)
+    {
+        const sal_Unicode* pSeps = rFieldSeparators.GetBuffer();
+
+        // See if the separator(s) include tab.
+        bool bTabSep = lcl_UnicodeStrChr(pSeps, '\t') != NULL;
+
+        xub_StrLen nLastOffset = 0;
+        xub_StrLen nQuotes = 0;
+        while (!rStream.IsEof() && rStr.Len() < STRING_MAXLEN)
+        {
+            bool bBackslashEscaped = false;
+            const sal_Unicode *p, *pStart;
+            p = pStart = rStr.GetBuffer();
+            p += nLastOffset;
+            while (*p)
+            {
+                if (nQuotes)
+                {
+                    if (bTabSep && *p == '\t' && (nQuotes % 2) != 0)
+                    {
+                        // When tab-delimited, tab char ends quoted sequence
+                        // even if we haven't reached the end quote.  Doing
+                        // this helps keep mal-formed rows from damaging
+                        // other, well-formed rows.
+                        nQuotes = 0;
+                        break;
+                    }
+
+                    if (*p == cFieldQuote && !bBackslashEscaped)
+                        ++nQuotes;
+                    else if (bAllowBackslashEscape)
+                    {
+                        if (*p == '\\')
+                            bBackslashEscaped = !bBackslashEscaped;
+                        else
+                            bBackslashEscaped = false;
+                    }
+                }
+                else if (*p == cFieldQuote && (p == pStart ||
+                            lcl_UnicodeStrChr( pSeps, p[-1])))
+                    nQuotes = 1;
+                // A quote character inside a field content does not start
+                // a quote.
+                ++p;
+            }
+
+            if (nQuotes % 2 == 0)
+                break;
+            else
+            {
+                nLastOffset = rStr.Len();
+                String aNext;
+                rStream.ReadUniOrByteStringLine(aNext, rStream.GetStreamCharSet());
+                rStr += sal_Unicode(_LF);
+                rStr += aNext;
+            }
+        }
+    }
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/impex.hxx b/sc/source/ui/inc/impex.hxx
index 302cf4e..8ccfdd9 100644
--- a/sc/source/ui/inc/impex.hxx
+++ b/sc/source/ui/inc/impex.hxx
@@ -189,6 +189,59 @@ public:
     }
 };
 
+/** Read a CSV (comma separated values) data line using
+    ReadUniOrByteStringLine().
+
+    @param bEmbeddedLineBreak
+    If sal_True and a line-break occurs inside a field of data,
+    a line feed LF '\n' and the next line are appended. Repeats
+    until a line-break is not in a field. A field is determined
+    by delimiting rFieldSeparators and optionally surrounded by
+    a pair of cFieldQuote characters. For a line-break to be
+    within a field, the field content MUST be surrounded by
+    cFieldQuote characters, and the opening cFieldQuote MUST be
+    at the very start of a line or follow right behind a field
+    separator with no extra characters in between. Anything,
+    including field separators and escaped quotes (by doubling
+    them, or preceding them with a backslash if
+    bAllowBackslashEscape==sal_True) may appear in a quoted
+    field.
+
+    If bEmbeddedLineBreak==sal_False, nothing is parsed and the
+    string returned is simply one ReadUniOrByteStringLine().
+
+    @param rFieldSeparators
+    A list of characters that each may act as a field separator.
+
+    @param cFieldQuote
+    The quote character used.
+
+    @param bAllowBackslashEscape
+    If sal_True, an embedded quote character inside a quoted
+    field may also be escaped with a preceding backslash.
+    Normally, quotes are escaped by doubling them.
+
+    check Stream::good() to detect IO problems during read
+
+    @ATTENTION
+    Note that the string returned may be truncated even inside
+    a quoted field if STRING_MAXLEN was reached. There
+    currently is no way to exactly determine the conditions,
+    whether this was at a line end, or whether open quotes
+    would have closed the field before the line end, as even a
+    ReadUniOrByteStringLine() may return prematurely but the
+    stream was positioned ahead until the real end of line.
+    Additionally, due to character encoding conversions, string
+    length and bytes read don't necessarily match, and
+    resyncing to a previous position matching the string's
+    length isn't always possible. As a result, a logical line
+    with embedded line breaks and more than STRING_MAXLEN
+    characters will be spoiled, and a subsequent ReadCsvLine()
+    may start under false preconditions.
+  */
+SC_DLLPUBLIC void ReadCsvLine(SvStream &rStream, String& rStr, sal_Bool bEmbeddedLineBreak,
+        const String& rFieldSeparators, sal_Unicode cFieldQuote,
+        sal_Bool bAllowBackslashEscape = sal_False);
 
 #endif
 
diff --git a/tools/inc/tools/stream.hxx b/tools/inc/tools/stream.hxx
index 85d5f12..4f06610 100644
--- a/tools/inc/tools/stream.hxx
+++ b/tools/inc/tools/stream.hxx
@@ -432,60 +432,6 @@ public:
     sal_Bool        WriteUniOrByteChar( sal_Unicode ch )
                     { return WriteUniOrByteChar( ch, GetStreamCharSet() ); }
 
-                /** Read a CSV (comma separated values) data line using
-                    ReadUniOrByteStringLine().
-
-                    @param bEmbeddedLineBreak
-                    If sal_True and a line-break occurs inside a field of data,
-                    a line feed LF '\n' and the next line are appended. Repeats
-                    until a line-break is not in a field. A field is determined
-                    by delimiting rFieldSeparators and optionally surrounded by
-                    a pair of cFieldQuote characters. For a line-break to be
-                    within a field, the field content MUST be surrounded by
-                    cFieldQuote characters, and the opening cFieldQuote MUST be
-                    at the very start of a line or follow right behind a field
-                    separator with no extra characters in between. Anything,
-                    including field separators and escaped quotes (by doubling
-                    them, or preceding them with a backslash if
-                    bAllowBackslashEscape==sal_True) may appear in a quoted
-                    field.
-
-                    If bEmbeddedLineBreak==sal_False, nothing is parsed and the
-                    string returned is simply one ReadUniOrByteStringLine().
-
-                    @param rFieldSeparators
-                    A list of characters that each may act as a field separator.
-
-                    @param cFieldQuote
-                    The quote character used.
-
-                    @param bAllowBackslashEscape
-                    If sal_True, an embedded quote character inside a quoted
-                    field may also be escaped with a preceding backslash.
-                    Normally, quotes are escaped by doubling them.
-
-                    check Stream::good() to detect IO problems during read
-
-                    @ATTENTION
-                    Note that the string returned may be truncated even inside
-                    a quoted field if STRING_MAXLEN was reached. There
-                    currently is no way to exactly determine the conditions,
-                    whether this was at a line end, or whether open quotes
-                    would have closed the field before the line end, as even a
-                    ReadUniOrByteStringLine() may return prematurely but the
-                    stream was positioned ahead until the real end of line.
-                    Additionally, due to character encoding conversions, string
-                    length and bytes read don't necessarily match, and
-                    resyncing to a previous position matching the string's
-                    length isn't always possible. As a result, a logical line
-                    with embedded line breaks and more than STRING_MAXLEN
-                    characters will be spoiled, and a subsequent ReadCsvLine()
-                    may start under false preconditions.
-                  */
-    void            ReadCsvLine( String& rStr, sal_Bool bEmbeddedLineBreak,
-                        const String& rFieldSeparators, sal_Unicode cFieldQuote,
-                        sal_Bool bAllowBackslashEscape = sal_False);
-
     void            SetBufferSize( sal_uInt16 nBufSize );
     sal_uInt16  GetBufferSize() const { return nBufSize; }
 
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index 8c0efb6..fea6025 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -1019,93 +1019,6 @@ sal_Bool SvStream::StartReadingUnicodeText( rtl_TextEncoding eReadBomCharSet )
 
 /*************************************************************************
 |*
-|*    Stream::ReadCsvLine()
-|*
-*************************************************************************/
-
-// Precondition: pStr is guaranteed to be non-NULL and points to a 0-terminated
-// array.
-inline const sal_Unicode* lcl_UnicodeStrChr( const sal_Unicode* pStr,
-        sal_Unicode c )
-{
-    while (*pStr)
-    {
-        if (*pStr == c)
-            return pStr;
-        ++pStr;
-    }
-    return 0;
-}
-
-void SvStream::ReadCsvLine( String& rStr, sal_Bool bEmbeddedLineBreak,
-        const String& rFieldSeparators, sal_Unicode cFieldQuote,
-        sal_Bool bAllowBackslashEscape)
-{
-    ReadUniOrByteStringLine(rStr, GetStreamCharSet());
-
-    if (bEmbeddedLineBreak)
-    {
-        const sal_Unicode* pSeps = rFieldSeparators.GetBuffer();
-
-        // See if the separator(s) include tab.
-        bool bTabSep = lcl_UnicodeStrChr(pSeps, '\t') != NULL;
-
-        xub_StrLen nLastOffset = 0;
-        xub_StrLen nQuotes = 0;
-        while (!IsEof() && rStr.Len() < STRING_MAXLEN)
-        {
-            bool bBackslashEscaped = false;
-            const sal_Unicode *p, *pStart;
-            p = pStart = rStr.GetBuffer();
-            p += nLastOffset;
-            while (*p)
-            {
-                if (nQuotes)
-                {
-                    if (bTabSep && *p == '\t' && (nQuotes % 2) != 0)
-                    {
-                        // When tab-delimited, tab char ends quoted sequence
-                        // even if we haven't reached the end quote.  Doing
-                        // this helps keep mal-formed rows from damaging
-                        // other, well-formed rows.
-                        nQuotes = 0;
-                        break;
-                    }
-
-                    if (*p == cFieldQuote && !bBackslashEscaped)
-                        ++nQuotes;
-                    else if (bAllowBackslashEscape)
-                    {
-                        if (*p == '\\')
-                            bBackslashEscaped = !bBackslashEscaped;
-                        else
-                            bBackslashEscaped = false;
-                    }
-                }
-                else if (*p == cFieldQuote && (p == pStart ||
-                            lcl_UnicodeStrChr( pSeps, p[-1])))
-                    nQuotes = 1;
-                // A quote character inside a field content does not start
-                // a quote.
-                ++p;
-            }
-
-            if (nQuotes % 2 == 0)
-                break;
-            else
-            {
-                nLastOffset = rStr.Len();
-                String aNext;
-                ReadUniOrByteStringLine(aNext, GetStreamCharSet());
-                rStr += sal_Unicode(_LF);
-                rStr += aNext;
-            }
-        }
-    }
-}
-
-/*************************************************************************
-|*
 |*    Stream::SeekRel()
 |*
 *************************************************************************/
commit e5ac3524f2d72bf3113c571de105f8aa52a558d2
Author: Christina Rossmanith <ChrRossmanith at web.de>
Date:   Fri Jan 13 16:28:52 2012 +0000

    Replace getLength() with isEmpty() in vcl/generic/fontmanager

diff --git a/vcl/generic/fontmanager/fontcache.cxx b/vcl/generic/fontmanager/fontcache.cxx
index 616799a..2e9ab9b 100644
--- a/vcl/generic/fontmanager/fontcache.cxx
+++ b/vcl/generic/fontmanager/fontcache.cxx
@@ -176,7 +176,7 @@ void FontCache::flush()
                 for( ::std::list< int >::const_iterator name_it = (*it)->m_aAliases.begin(); name_it != (*it)->m_aAliases.end(); ++name_it )
                 {
                     const OUString& rAdd( pAtoms->getString( ATOM_FAMILYNAME, *name_it ) );
-                    if( rAdd.getLength() )
+                    if( !rAdd.isEmpty() )
                     {
                         aLine.append(';');
                         aLine.append(OUStringToOString(rAdd, RTL_TEXTENCODING_UTF8));
@@ -233,7 +233,7 @@ void FontCache::flush()
                         break;
                     default: break;
                 }
-                if( (*it)->m_aStyleName.getLength() )
+                if( !(*it)->m_aStyleName.isEmpty() )
                 {
                     aLine.append(';');
                     aLine.append(OUStringToOString((*it)->m_aStyleName, RTL_TEXTENCODING_UTF8));
diff --git a/vcl/generic/fontmanager/fontconfig.cxx b/vcl/generic/fontmanager/fontconfig.cxx
index eb0e9b6..a5d1c15 100644
--- a/vcl/generic/fontmanager/fontconfig.cxx
+++ b/vcl/generic/fontmanager/fontconfig.cxx
@@ -773,7 +773,7 @@ bool PrintFontManager::Substitute( FontSelectPattern &rPattern, rtl::OUString& r
     FcPatternAddString(pPattern, FC_FAMILY, pTargetNameUtf8);
 
     const rtl::OString aLangAttrib = MsLangId::convertLanguageToIsoByteString(rPattern.meLanguage);
-    if( aLangAttrib.getLength() )
+    if( !aLangAttrib.isEmpty() )
     {
         const FcChar8* pLangAttribUtf8;
         if (aLangAttrib.equalsIgnoreAsciiCase(OString(RTL_CONSTASCII_STRINGPARAM("pa-in"))))
@@ -784,7 +784,7 @@ bool PrintFontManager::Substitute( FontSelectPattern &rPattern, rtl::OUString& r
     }
 
     // Add required Unicode characters, if any
-    if ( rMissingCodes.getLength() )
+    if ( !rMissingCodes.isEmpty() )
     {
        FcCharSet *unicodes = FcCharSetCreate();
        for( sal_Int32 nStrIndex = 0; nStrIndex < rMissingCodes.getLength(); )
@@ -889,7 +889,7 @@ bool PrintFontManager::Substitute( FontSelectPattern &rPattern, rtl::OUString& r
             }
 
             // update rMissingCodes by removing resolved unicodes
-            if( rMissingCodes.getLength() > 0 )
+            if( !rMissingCodes.isEmpty() )
             {
                 sal_uInt32* pRemainingCodes = (sal_uInt32*)alloca( rMissingCodes.getLength() * sizeof(sal_uInt32) );
                 int nRemainingLen = 0;
@@ -954,7 +954,7 @@ ImplFontOptions* PrintFontManager::getFontOptions(
     boost::unordered_map< rtl::OString, rtl::OString, rtl::OStringHash >::const_iterator aI = rWrapper.m_aLocalizedToCanonical.find(sFamily);
     if (aI != rWrapper.m_aLocalizedToCanonical.end())
         sFamily = aI->second;
-    if( sFamily.getLength() )
+    if( !sFamily.isEmpty() )
         FcPatternAddString(pPattern, FC_FAMILY, (FcChar8*)sFamily.getStr());
 
     addtopattern(pPattern, rInfo.m_eItalic, rInfo.m_eWeight, rInfo.m_eWidth, rInfo.m_ePitch);
@@ -1021,22 +1021,22 @@ bool PrintFontManager::matchFont( FastPrintFontInfo& rInfo, const com::sun::star
 
     OString aLangAttrib;
     // populate pattern with font characteristics
-    if( rLocale.Language.getLength() )
+    if( !rLocale.Language.isEmpty() )
     {
         OUStringBuffer aLang(6);
         aLang.append( rLocale.Language );
-        if( rLocale.Country.getLength() )
+        if( !rLocale.Country.isEmpty() )
         {
             aLang.append( sal_Unicode('-') );
             aLang.append( rLocale.Country );
         }
         aLangAttrib = OUStringToOString( aLang.makeStringAndClear(), RTL_TEXTENCODING_UTF8 );
     }
-    if( aLangAttrib.getLength() )
+    if( !aLangAttrib.isEmpty() )
         FcPatternAddString(pPattern, FC_LANG, (FcChar8*)aLangAttrib.getStr());
 
     OString aFamily = OUStringToOString( rInfo.m_aFamilyName, RTL_TEXTENCODING_UTF8 );
-    if( aFamily.getLength() )
+    if( !aFamily.isEmpty() )
         FcPatternAddString(pPattern, FC_FAMILY, (FcChar8*)aFamily.getStr());
 
     addtopattern(pPattern, rInfo.m_eItalic, rInfo.m_eWeight, rInfo.m_eWidth, rInfo.m_ePitch);
diff --git a/vcl/generic/fontmanager/fontmanager.cxx b/vcl/generic/fontmanager/fontmanager.cxx
index 5e20b91..578cc23 100644
--- a/vcl/generic/fontmanager/fontmanager.cxx
+++ b/vcl/generic/fontmanager/fontmanager.cxx
@@ -613,7 +613,7 @@ bool PrintFontManager::PrintFont::readAfmMetrics( const OString& rFileName, Mult
     if( ! m_nFamilyName )
     {
         aFamily = OStringToOUString( pInfo->gfi->familyName, RTL_TEXTENCODING_ISO_8859_1 );
-        if( ! aFamily.getLength() )
+        if( aFamily.isEmpty() )
         {
             aFamily = OStringToOUString( pInfo->gfi->fontName, RTL_TEXTENCODING_ISO_8859_1 );
             sal_Int32 nIndex  = 0;
@@ -627,7 +627,7 @@ bool PrintFontManager::PrintFont::readAfmMetrics( const OString& rFileName, Mult
 
     // style name: if fullname begins with family name
     // interpret the rest of fullname as style
-    if( ! m_aStyleName.getLength() && pInfo->gfi->fullName && *pInfo->gfi->fullName )
+    if( m_aStyleName.isEmpty() && pInfo->gfi->fullName && *pInfo->gfi->fullName )
     {
         OUString aFullName( OStringToOUString( pInfo->gfi->fullName, RTL_TEXTENCODING_ISO_8859_1 ) );
         if( aFullName.indexOf( aFamily ) == 0 )
@@ -1494,7 +1494,7 @@ void PrintFontManager::analyzeTrueTypeFamilyName( void* pTTFont, ::std::list< OU
         }
         DisposeNameRecords( pNameRecords, nNameRecords );
     }
-    if( aFamily.getLength() )
+    if( !aFamily.isEmpty() )
     {
         rNames.push_front( aFamily );
         for( ::std::set< OUString >::const_iterator it = aSet.begin(); it != aSet.end(); ++it )
@@ -1545,7 +1545,7 @@ bool PrintFontManager::analyzeTrueTypeFile( PrintFont* pFont ) const
         }
         for( ::std::list< OUString >::iterator it = aNames.begin(); it != aNames.end(); ++it )
         {
-            if( it->getLength() )
+            if( !it->isEmpty() )
             {
                 int nAlias = m_pAtoms->getAtom( ATOM_FAMILYNAME, *it, sal_True );
                 if( nAlias != pFont->m_nFamilyName )
@@ -1720,7 +1720,7 @@ void PrintFontManager::initialize()
 
     // search for the fonts in SAL_PRIVATE_FONTPATH first; those are
     // the fonts installed with the office
-    if( rSalPrivatePath.getLength() )
+    if( !rSalPrivatePath.isEmpty() )
     {
         OString aPath = rtl::OUStringToOString( rSalPrivatePath, aEncoding );
         const bool bAreFCSubstitutionsEnabled = AreFCSubstitutionsEnabled();
@@ -1729,7 +1729,7 @@ void PrintFontManager::initialize()
         {
             OString aToken = aPath.getToken( 0, ';', nIndex );
             normPath( aToken );
-            if (!aToken.getLength())
+            if ( aToken.isEmpty() )
             {
                 continue;
             }
diff --git a/vcl/generic/fontmanager/helper.cxx b/vcl/generic/fontmanager/helper.cxx
index b35ab24..85a3490 100644
--- a/vcl/generic/fontmanager/helper.cxx
+++ b/vcl/generic/fontmanager/helper.cxx
@@ -157,7 +157,7 @@ void psp::getPrinterPathList( std::list< OUString >& rPathList, const char* pSub
     do
     {
         OString aDir( aPath.getToken( 0, ':', nIndex ) );
-        if( ! aDir.getLength() )
+        if( aDir.isEmpty() )
             continue;
 
         if( pSubDir )
@@ -201,14 +201,14 @@ OUString psp::getFontPath()
 {
     static OUString aPath;
 
-    if( ! aPath.getLength() )
+    if (aPath.isEmpty())
     {
         OUStringBuffer aPathBuffer( 512 );
 
         OUString aConfigPath( getOfficePath( psp::ConfigPath ) );
         OUString aInstallationRootPath( getOfficePath( psp::InstallationRootPath ) );
         OUString aUserPath( getOfficePath( psp::UserPath ) );
-        if( aConfigPath.getLength() )
+        if( !aConfigPath.isEmpty() )
         {
             // #i53530# Path from CustomDataUrl will completely
             // replace net and user paths if the path exists
@@ -225,16 +225,16 @@ OUString psp::getFontPath()
                 aPathBuffer.appendAscii("/share/fonts");
             }
         }
-        if( aConfigPath.getLength() == 0 )
+        if( aConfigPath.isEmpty() )
         {
-            if( aInstallationRootPath.getLength() )
+            if( !aInstallationRootPath.isEmpty() )
             {
                 aPathBuffer.append( aInstallationRootPath );
                 aPathBuffer.appendAscii( "/share/fonts/truetype;");
                 aPathBuffer.append( aInstallationRootPath );
                 aPathBuffer.appendAscii( "/share/fonts/type1;" );
             }
-            if( aUserPath.getLength() )
+            if( !aUserPath.isEmpty() )
             {
                 aPathBuffer.append( aUserPath );
                 aPathBuffer.appendAscii( "/user/fonts" );
commit 8ca94d31d1d6317e182ecdf360f744f70640cbfc
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Jan 13 16:08:31 2012 +0000

    simply MSDFFReadZString and friends

diff --git a/filter/inc/filter/msfilter/msdffimp.hxx b/filter/inc/filter/msfilter/msdffimp.hxx
index 4e4021d..35bfb09 100644
--- a/filter/inc/filter/msfilter/msdffimp.hxx
+++ b/filter/inc/filter/msfilter/msdffimp.hxx
@@ -588,7 +588,7 @@ public:
     bool SeekToRec( SvStream& rSt, sal_uInt16 nRecId, sal_uLong nMaxFilePos, DffRecordHeader* pRecHd = NULL, sal_uLong nSkipCount = 0 ) const;
     bool SeekToRec2( sal_uInt16 nRecId1, sal_uInt16 nRecId2, sal_uLong nMaxFilePos, DffRecordHeader* pRecHd = NULL, sal_uLong nSkipCount = 0 ) const;
 
-    static rtl::OUString MSDFFReadZString( SvStream& rIn, sal_uLong nMaxLen, bool bUniCode = sal_False );
+    static rtl::OUString MSDFFReadZString(SvStream& rIn, sal_uInt32 nMaxLen, bool bUniCode = sal_False);
 
     static bool ReadCommonRecordHeader(DffRecordHeader& rRec, SvStream& rIn)
         SAL_WARN_UNUSED_RESULT;
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index 361fe74..7c4284f 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -3744,7 +3744,7 @@ rtl::OUString SvxMSDffManager::ReadDffString(SvStream& rSt, DffRecordHeader aStr
     else if ( aStrHd.nRecType == DFF_PST_TextBytesAtom || aStrHd.nRecType == DFF_PST_TextCharsAtom )
     {
         bool bUniCode=aStrHd.nRecType==DFF_PST_TextCharsAtom;
-        sal_uLong nBytes = aStrHd.nRecLen;
+        sal_uInt32 nBytes = aStrHd.nRecLen;
         aRet = MSDFFReadZString( rSt, nBytes, bUniCode );
         if( !bUniCode )
         {
@@ -4006,31 +4006,17 @@ bool SvxMSDffManager::ReadObjText(SvStream& rSt, SdrObject* pObj)
 
 //static
 rtl::OUString SvxMSDffManager::MSDFFReadZString(SvStream& rIn,
-    sal_uLong nRecLen, bool bUniCode)
+    sal_uInt32 nLen, bool bUniCode)
 {
-    sal_uInt16 nLen = (sal_uInt16)nRecLen;
     if (!nLen)
         return rtl::OUString();
 
     String sBuf;
 
     if( bUniCode )
-    {
-        nLen >>= 1;
-
-        sal_Unicode* pBuf = sBuf.AllocBuffer(nLen);
-        rIn.Read( (sal_Char*)pBuf, nLen << 1 );
-#ifdef OSL_BIGENDIAN
-        for( sal_uInt16 n = 0; n < nLen; ++n, ++pBuf )
-            *pBuf = SWAPSHORT( *pBuf );
-#endif // ifdef OSL_BIGENDIAN
-    }
+        sBuf = read_LEuInt16s_ToOUString(rIn, nLen/2);
     else
-    {
-        boost::scoped_array<sal_Char> xBuffer(new sal_Char[nLen]);
-        nLen = rIn.Read(xBuffer.get(), nLen);
-        sBuf = rtl::OUString(xBuffer.get(), nLen, RTL_TEXTENCODING_MS_1252);
-    }
+        sBuf = read_uInt8s_ToOUString(rIn, nLen, RTL_TEXTENCODING_MS_1252);
 
     return sBuf.EraseTrailingChars( 0 );
 }
diff --git a/sw/source/filter/ww1/w1class.cxx b/sw/source/filter/ww1/w1class.cxx
index c1630ca..ff4a643 100644
--- a/sw/source/filter/ww1/w1class.cxx
+++ b/sw/source/filter/ww1/w1class.cxx
@@ -84,10 +84,9 @@ String Ww1PlainText::GetText( sal_uLong ulOffset, sal_uLong nLen ) const
     sal_Size nPos = ulFilePos+ulOffset;
 
     bool bSeekOk = rFib.GetStream().Seek(nPos) == nPos;
-    rtl::OString a8BitStr = bSeekOk ?
-        read_uInt8s_ToOString(rFib.GetStream(), nLen) :
-        rtl::OString();
-    return rtl::OStringToOUString(a8BitStr, RTL_TEXTENCODING_MS_1252);
+    return bSeekOk ?
+        read_uInt8s_ToOUString(rFib.GetStream(), nLen, RTL_TEXTENCODING_MS_1252) :
+        rtl::OUString();
 }
 
 ///////////////////////////////////////////////////////////////// Style
diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
index ea3e65c..be9b8d4 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -1963,10 +1963,7 @@ xub_StrLen WW8ScannerBase::WW8ReadString( SvStream& rStrm, String& rStr,
         if( bIsUnicode )
             rStr.Append(String(read_LEuInt16s_ToOUString(rStrm, nLen)));
         else
-        {
-            rtl::OString aByteStr = read_uInt8s_ToOString(rStrm, nLen);
-            rStr.Append(String(rtl::OStringToOUString(aByteStr, eEnc)));
-        }
+            rStr.Append(String(read_uInt8s_ToOUString(rStrm, nLen, eEnc)));
         nTotalRead  += nLen;
         nAktStartCp += nLen;
         if ( nTotalRead != rStr.Len() )
diff --git a/tools/inc/tools/stream.hxx b/tools/inc/tools/stream.hxx
index df94910..85d5f12 100644
--- a/tools/inc/tools/stream.hxx
+++ b/tools/inc/tools/stream.hxx
@@ -541,13 +541,22 @@ TOOLS_DLLPUBLIC SvStream& endlu( SvStream& rStr );
 /// call endlu() if eStreamCharSet==RTL_TEXTECODING_UNICODE otherwise endl()
 TOOLS_DLLPUBLIC SvStream& endlub( SvStream& rStr );
 
-//Attempt to read nLen 8bit units to an OString, returned rtl::OString's length
-//is number of units successfully read
-TOOLS_DLLPUBLIC rtl::OString read_uInt8s_ToOString(SvStream& rStrm, sal_Size nLen);
+//Attempt to read nUnits 8bit units to an OString, returned rtl::OString's
+//length is number of units successfully read
+TOOLS_DLLPUBLIC rtl::OString read_uInt8s_ToOString(SvStream& rStrm,
+    sal_Size nUnits);
+
+//Attempt to read nUnits 8bit units to an OUString
+TOOLS_DLLPUBLIC inline rtl::OUString read_uInt8s_ToOUString(SvStream& rStrm,
+    sal_Size nUnits, rtl_TextEncoding eEnc)
+{
+    return rtl::OStringToOUString(read_uInt8s_ToOString(rStrm, nUnits), eEnc);
+}
 
-//Attempt to read nLen little endian 16bit units to an OUString, returned
+//Attempt to read nUnits little endian 16bit units to an OUString, returned
 //rtl::OUString's length is number of units successfully read
-TOOLS_DLLPUBLIC rtl::OUString read_LEuInt16s_ToOUString(SvStream& rStrm, sal_Size nLen);
+TOOLS_DLLPUBLIC rtl::OUString read_LEuInt16s_ToOUString(SvStream& rStrm,
+    sal_Size nUnits);
 
 //Attempt to read 8bit units to an OString until a zero terminator is
 //encountered, returned rtl::OString's length is number of units *definitely*
@@ -563,16 +572,18 @@ TOOLS_DLLPUBLIC rtl::OUString read_zeroTerminated_uInt8s_ToOUString(SvStream& rS
 //Attempt to read a pascal-style length (of type prefix) prefixed sequence of
 //8bit units to an OString, returned rtl::OString's length is number of units
 //successfully read.
-template<typename prefix> rtl::OString read_lenPrefixed_uInt8s_ToOString(SvStream& rStrm)
+template<typename prefix>
+rtl::OString read_lenPrefixed_uInt8s_ToOString(SvStream& rStrm)
 {
-    prefix nLen = 0;
-    rStrm >> nLen;
-    return read_uInt8s_ToOString(rStrm, nLen);
+    prefix nUnits = 0;
+    rStrm >> nUnits;
+    return read_uInt8s_ToOString(rStrm, nUnits);
 }
 
 //Attempt to read a pascal-style length (of type prefix) prefixed sequence of
 //8bit units to an OUString
-template<typename prefix> rtl::OUString read_lenPrefixed_uInt8s_ToOUString(SvStream& rStrm,
+template<typename prefix>
+rtl::OUString read_lenPrefixed_uInt8s_ToOUString(SvStream& rStrm,
     rtl_TextEncoding eEnc)
 {
     return rtl::OStringToOUString(read_lenPrefixed_uInt8s_ToOString<prefix>(rStrm), eEnc);
@@ -589,12 +600,12 @@ template<typename prefix> sal_Size write_lenPrefixed_uInt8s_FromOString(SvStream
         "string too long for prefix count to fit in output type");
 
     sal_Size nWritten = 0;
-    prefix nLen = std::min<sal_Size>(rStr.getLength(), std::numeric_limits<prefix>::max());
-    rStrm << nLen;
+    prefix nUnits = std::min<sal_Size>(rStr.getLength(), std::numeric_limits<prefix>::max());
+    rStrm << nUnits;
     if (rStrm.good())
     {
         nWritten += sizeof(prefix);
-        nWritten += rStrm.Write(rStr.getStr(), nLen);
+        nWritten += rStrm.Write(rStr.getStr(), nUnits);
     }
     return nWritten;
 }
commit 5b6586127828b211303b961df66531865abe5ba2
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Jan 13 15:42:29 2012 +0000

    these are length prefixed strings

diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
index 56981ac..ea3e65c 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -1964,7 +1964,6 @@ xub_StrLen WW8ScannerBase::WW8ReadString( SvStream& rStrm, String& rStr,
             rStr.Append(String(read_LEuInt16s_ToOUString(rStrm, nLen)));
         else
         {
-            // Alloc method automatically sets Zero at the end
             rtl::OString aByteStr = read_uInt8s_ToOString(rStrm, nLen);
             rStr.Append(String(rtl::OStringToOUString(aByteStr, eEnc)));
         }
@@ -3867,9 +3866,7 @@ void WW8ReadSTTBF(bool bVer8, SvStream& rStrm, sal_uInt32 nStart, sal_Int32 nLen
                     rArray.push_back(read_LEuInt16_PascalString(rStrm));
                 else
                 {
-                    sal_uInt8 nBChar(0);
-                    rStrm >> nBChar;
-                    rtl::OString aTmp = read_uInt8s_ToOString(rStrm, nBChar);
+                    rtl::OString aTmp = read_lenPrefixed_uInt8s_ToOString<sal_uInt8>(rStrm);
                     rArray.push_back(rtl::OStringToOUString(aTmp, eCS));
                 }
 
@@ -3900,9 +3897,7 @@ void WW8ReadSTTBF(bool bVer8, SvStream& rStrm, sal_uInt32 nStart, sal_Int32 nLen
                         pValueArray->push_back(read_LEuInt16_PascalString(rStrm));
                     else
                     {
-                        sal_uInt8 nBChar(0);
-                        rStrm >> nBChar;
-                        rtl::OString aTmp = read_uInt8s_ToOString(rStrm, nBChar);
+                        rtl::OString aTmp = read_lenPrefixed_uInt8s_ToOString<sal_uInt8>(rStrm);
                         pValueArray->push_back(rtl::OStringToOUString(aTmp, eCS));
                     }
                 }
commit a55ae5fde1cbd8c29f8aa3a66a4d362355a3062c
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Jan 13 15:09:23 2012 +0000

    just return the read string here instead of passing one in by ref

diff --git a/filter/inc/filter/msfilter/msdffimp.hxx b/filter/inc/filter/msfilter/msdffimp.hxx
index f41fcd3..4e4021d 100644
--- a/filter/inc/filter/msfilter/msdffimp.hxx
+++ b/filter/inc/filter/msfilter/msdffimp.hxx
@@ -588,7 +588,7 @@ public:
     bool SeekToRec( SvStream& rSt, sal_uInt16 nRecId, sal_uLong nMaxFilePos, DffRecordHeader* pRecHd = NULL, sal_uLong nSkipCount = 0 ) const;
     bool SeekToRec2( sal_uInt16 nRecId1, sal_uInt16 nRecId2, sal_uLong nMaxFilePos, DffRecordHeader* pRecHd = NULL, sal_uLong nSkipCount = 0 ) const;
 
-    static void MSDFFReadZString( SvStream& rIn, String& rStr, sal_uLong nMaxLen, bool bUniCode = sal_False );
+    static rtl::OUString MSDFFReadZString( SvStream& rIn, sal_uLong nMaxLen, bool bUniCode = sal_False );
 
     static bool ReadCommonRecordHeader(DffRecordHeader& rRec, SvStream& rIn)
         SAL_WARN_UNUSED_RESULT;
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index 80e4ecb..361fe74 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -3745,7 +3745,7 @@ rtl::OUString SvxMSDffManager::ReadDffString(SvStream& rSt, DffRecordHeader aStr
     {
         bool bUniCode=aStrHd.nRecType==DFF_PST_TextCharsAtom;
         sal_uLong nBytes = aStrHd.nRecLen;
-        MSDFFReadZString( rSt, aRet, nBytes, bUniCode );
+        aRet = MSDFFReadZString( rSt, nBytes, bUniCode );
         if( !bUniCode )
         {
             for ( xub_StrLen n = 0; n < nBytes; n++ )
@@ -4005,36 +4005,34 @@ bool SvxMSDffManager::ReadObjText(SvStream& rSt, SdrObject* pObj)
 }
 
 //static
-void SvxMSDffManager::MSDFFReadZString( SvStream& rIn, String& rStr,
-                                    sal_uLong nRecLen, bool bUniCode )
+rtl::OUString SvxMSDffManager::MSDFFReadZString(SvStream& rIn,
+    sal_uLong nRecLen, bool bUniCode)
 {
     sal_uInt16 nLen = (sal_uInt16)nRecLen;
-    if( nLen )
-    {
-        String sBuf;
+    if (!nLen)
+        return rtl::OUString();
 
-        if( bUniCode )
-        {
-            nLen >>= 1;
+    String sBuf;
+
+    if( bUniCode )
+    {
+        nLen >>= 1;
 
-            sal_Unicode* pBuf = sBuf.AllocBuffer(nLen);
-            rIn.Read( (sal_Char*)pBuf, nLen << 1 );
+        sal_Unicode* pBuf = sBuf.AllocBuffer(nLen);
+        rIn.Read( (sal_Char*)pBuf, nLen << 1 );
 #ifdef OSL_BIGENDIAN
-            for( sal_uInt16 n = 0; n < nLen; ++n, ++pBuf )
-                *pBuf = SWAPSHORT( *pBuf );
+        for( sal_uInt16 n = 0; n < nLen; ++n, ++pBuf )
+            *pBuf = SWAPSHORT( *pBuf );
 #endif // ifdef OSL_BIGENDIAN
-        }
-        else
-        {
-            boost::scoped_array<sal_Char> xBuffer(new sal_Char[nLen]);
-            nLen = rIn.Read(xBuffer.get(), nLen);
-            sBuf = rtl::OUString(xBuffer.get(), nLen, RTL_TEXTENCODING_MS_1252);
-        }
-
-        rStr = sBuf.EraseTrailingChars( 0 );
     }
     else
-        rStr.Erase();
+    {
+        boost::scoped_array<sal_Char> xBuffer(new sal_Char[nLen]);
+        nLen = rIn.Read(xBuffer.get(), nLen);
+        sBuf = rtl::OUString(xBuffer.get(), nLen, RTL_TEXTENCODING_MS_1252);
+    }
+
+    return sBuf.EraseTrailingChars( 0 );
 }
 
 SdrObject* SvxMSDffManager::ImportFontWork( SvStream& rStCt, SfxItemSet& rSet, Rectangle& rBoundRect ) const
@@ -4046,9 +4044,9 @@ SdrObject* SvxMSDffManager::ImportFontWork( SvStream& rStCt, SfxItemSet& rSet, R
 
     ((SvxMSDffManager*)this)->mnFix16Angle = 0; // we don't want to use this property in future
     if ( SeekToContent( DFF_Prop_gtextUNICODE, rStCt ) )
-        MSDFFReadZString( rStCt, aObjectText, GetPropertyValue( DFF_Prop_gtextUNICODE ), sal_True );
+        aObjectText = MSDFFReadZString( rStCt, GetPropertyValue( DFF_Prop_gtextUNICODE ), sal_True );
     if ( SeekToContent( DFF_Prop_gtextFont, rStCt ) )
-        MSDFFReadZString( rStCt, aFontName, GetPropertyValue( DFF_Prop_gtextFont ), sal_True );
+        aFontName = MSDFFReadZString( rStCt, GetPropertyValue( DFF_Prop_gtextFont ), sal_True );
     if ( GetPropertyValue( DFF_Prop_gtextFStrikethrough, 0 ) & 0x2000 )
     {
         // Text ist senkrecht formatiert, Box Kippen
@@ -4193,7 +4191,7 @@ SdrObject* SvxMSDffManager::ImportGraphic( SvStream& rSt, SfxItemSet& rSet, cons
     {
         Graphic aGraf;  // be sure this graphic is deleted before swapping out
         if( SeekToContent( DFF_Prop_pibName, rSt ) )
-            MSDFFReadZString( rSt, aFileName, GetPropertyValue( DFF_Prop_pibName ), sal_True );
+            aFileName = MSDFFReadZString( rSt, GetPropertyValue( DFF_Prop_pibName ), sal_True );
 
         //   UND, ODER folgendes:
         if( !( eFlags & mso_blipflagDoNotSave ) ) // Grafik embedded
@@ -4717,7 +4715,7 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r
                             SvxFontItem aLatin(EE_CHAR_FONTINFO), aAsian(EE_CHAR_FONTINFO_CJK), aComplex(EE_CHAR_FONTINFO_CTL);
                             GetDefaultFonts( aLatin, aAsian, aComplex );
 
-                            MSDFFReadZString( rSt, aFontName, GetPropertyValue( DFF_Prop_gtextFont ), sal_True );
+                            aFontName = MSDFFReadZString( rSt, GetPropertyValue( DFF_Prop_gtextFont ), sal_True );
                             aSet.Put( SvxFontItem( aLatin.GetFamily(), aFontName, aLatin.GetStyleName(),
                                         PITCH_DONTKNOW, RTL_TEXTENCODING_DONTKNOW, EE_CHAR_FONTINFO ));
                             aSet.Put( SvxFontItem( aLatin.GetFamily(), aFontName, aLatin.GetStyleName(),
@@ -4740,7 +4738,7 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r
 
                         if ( SeekToContent( DFF_Prop_gtextUNICODE, rSt ) )
                         {
-                            MSDFFReadZString( rSt, aObjectText, GetPropertyValue( DFF_Prop_gtextUNICODE ), sal_True );
+                            aObjectText = MSDFFReadZString( rSt, GetPropertyValue( DFF_Prop_gtextUNICODE ), sal_True );
                             ReadObjText( aObjectText, pRet );
                         }
 
diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index 5e57266..11e84a9 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -188,7 +188,7 @@ SvStream& operator>>( SvStream& rIn, PptCurrentUserAtom& rAtom )
             >> rAtom.nMajorVersion
             >> rAtom.nMinorVersion
             >> nPad;
-        SvxMSDffManager::MSDFFReadZString( rIn, rAtom.aCurrentUser, nUserNameLen, sal_True );
+        rAtom.aCurrentUser = SvxMSDffManager::MSDFFReadZString( rIn, nUserNameLen, sal_True );
     }
     aHd.SeekToEndOfRecord( rIn );
     return rIn;
@@ -562,7 +562,7 @@ sal_Bool SdrEscherImport::ReadString( String& rStr ) const
             || aStrHd.nRecType == PPT_PST_CString);
         bRet=sal_True;
         sal_uLong nBytes = aStrHd.nRecLen;
-        MSDFFReadZString( rStCtrl, rStr, nBytes, bUniCode );
+        rStr = MSDFFReadZString( rStCtrl, nBytes, bUniCode );
         aStrHd.SeekToEndOfRecord( rStCtrl );
     }
     else
@@ -2675,8 +2675,8 @@ void ImportComment10( SvxMSDffManager& rMan, SvStream& rStCtrl, SdrPage* pPage,
         {
             case PPT_PST_CString :
             {
-                String aString;
-                SvxMSDffManager::MSDFFReadZString( rStCtrl, aString, aCommentHd.nRecLen, sal_True );
+                rtl::OUString aString = SvxMSDffManager::MSDFFReadZString( rStCtrl,
+                    aCommentHd.nRecLen, sal_True );
                 switch ( aCommentHd.nRecInstance )
                 {
                     case 0 : sAuthor = aString;     break;
@@ -3149,7 +3149,10 @@ void SdrEscherImport::ImportHeaderFooterContainer( DffRecordHeader& rHd, HeaderF
             case PPT_PST_CString :
             {
                 if ( aHd.nRecInstance < 4 )
-                    MSDFFReadZString( rStCtrl, rE.pPlaceholder[ aHd.nRecInstance ], aHd.nRecLen, sal_True );
+                {
+                    rE.pPlaceholder[ aHd.nRecInstance ] = MSDFFReadZString( rStCtrl,
+                        aHd.nRecLen, sal_True );
+                }
             }
             break;
         }
diff --git a/sd/source/filter/ppt/pptinanimations.cxx b/sd/source/filter/ppt/pptinanimations.cxx
index 658f46f..7ed1de1 100644
--- a/sd/source/filter/ppt/pptinanimations.cxx
+++ b/sd/source/filter/ppt/pptinanimations.cxx
@@ -2830,9 +2830,7 @@ bool AnimationImporter::importAttributeValue( const Atom* pAtom, Any& rAny )
                 {
                     if ( ( nRecLen & 1 ) && ( nRecLen > 1 ) )
                     {
-                        String aString;
-                        mpPPTImport->MSDFFReadZString( mrStCtrl, aString, nRecLen - 1, sal_True );
-                        rtl::OUString aOUString( aString );
+                        rtl::OUString aOUString = mpPPTImport->MSDFFReadZString( mrStCtrl, nRecLen - 1, sal_True );
                         rAny <<= aOUString;
 
                         bOk = true;
diff --git a/svx/workben/msview/xmlconfig.cxx b/svx/workben/msview/xmlconfig.cxx
index 9c63385..b7611d1 100644
--- a/svx/workben/msview/xmlconfig.cxx
+++ b/svx/workben/msview/xmlconfig.cxx
@@ -451,8 +451,7 @@ rtl::OUString ElementConfig::dump_uint( SvStream& rStream, sal_Size& nLength )
 
 rtl::OUString ElementConfig::dump_unistring( SvStream& rStream, sal_Size& nLength )
 {
-    String aString;
-    SvxMSDffManager::MSDFFReadZString( rStream, aString, nLength, sal_True );
+    String aString = SvxMSDffManager::MSDFFReadZString( rStream, nLength, sal_True );
     nLength = 0;
     return aString;
 }
commit 4a68a5f32bcc815b116063e6c047397ed9a3e241
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Jan 13 14:48:35 2012 +0000

    return status never checked

diff --git a/filter/inc/filter/msfilter/msdffimp.hxx b/filter/inc/filter/msfilter/msdffimp.hxx
index 9dabeb0..f41fcd3 100644
--- a/filter/inc/filter/msfilter/msdffimp.hxx
+++ b/filter/inc/filter/msfilter/msdffimp.hxx
@@ -639,7 +639,7 @@ public:
     static sal_Bool     MakeContentStream( SotStorage * pStor, const GDIMetaFile & );
     static sal_Bool     ConvertToOle2( SvStream& rStm, sal_uInt32 nLen, const GDIMetaFile*,
                                 const SotStorageRef & rDest );
-    static bool ReadDffString(SvStream& rSt, String& rTxt, DffRecordHeader aStrHd = DffRecordHeader());
+    static rtl::OUString ReadDffString(SvStream& rSt, DffRecordHeader aStrHd = DffRecordHeader());
     static bool ReadObjText(SvStream& rSt, SdrObject* pObj);
 
     void SetModel(SdrModel* pModel, long nApplicationScale);
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index f79b0d2..80e4ecb 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -3736,23 +3736,22 @@ Color SvxMSDffManager::MSO_CLR_ToColor( sal_uInt32 nColorCode, sal_uInt16 nConte
     return aColor;
 }
 
-bool SvxMSDffManager::ReadDffString(SvStream& rSt, String& rTxt, DffRecordHeader aStrHd)
+rtl::OUString SvxMSDffManager::ReadDffString(SvStream& rSt, DffRecordHeader aStrHd)
 {
-    bool bRet=sal_False;
+    String aRet;
     if( aStrHd.nRecType == 0x0 && !ReadCommonRecordHeader(aStrHd, rSt) )
         rSt.Seek( aStrHd.nFilePos );
     else if ( aStrHd.nRecType == DFF_PST_TextBytesAtom || aStrHd.nRecType == DFF_PST_TextCharsAtom )
     {
         bool bUniCode=aStrHd.nRecType==DFF_PST_TextCharsAtom;
-        bRet=sal_True;
         sal_uLong nBytes = aStrHd.nRecLen;
-        MSDFFReadZString( rSt, rTxt, nBytes, bUniCode );
+        MSDFFReadZString( rSt, aRet, nBytes, bUniCode );
         if( !bUniCode )
         {
             for ( xub_StrLen n = 0; n < nBytes; n++ )
             {
-                if( rTxt.GetChar( n ) == 0x0B )
-                    rTxt.SetChar( n, ' ' );     // Weicher Umbruch
+                if( aRet.GetChar( n ) == 0x0B )
+                    aRet.SetChar( n, ' ' );     // Weicher Umbruch
                 // TODO: Zeilenumbruch im Absatz via Outliner setzen.
             }
         }
@@ -3760,7 +3759,7 @@ bool SvxMSDffManager::ReadDffString(SvStream& rSt, String& rTxt, DffRecordHeader
     }
     else
         aStrHd.SeekToBegOfRecord( rSt );
-    return bRet;
+    return aRet;
 }
 
 // sj: I just want to set a string for a text object that may contain multiple
@@ -3881,7 +3880,7 @@ bool SvxMSDffManager::ReadObjText(SvStream& rSt, SdrObject* pObj)
                         //case TextSpecInfoAtom
                         case DFF_PST_TextBytesAtom:
                         case DFF_PST_TextCharsAtom:
-                            ReadDffString(rSt, aText, aHd);
+                            aText = ReadDffString(rSt, aHd);
                             break;
                         case DFF_PST_TextRulerAtom               :
                         {
commit ccd716371c0611726f60519fe4ec3465ceac6db0
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Jan 13 14:36:06 2012 +0000

    convert some archaic strings

diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index bd6ff45..f79b0d2 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -601,7 +601,7 @@ void DffPropertyReader::ReadPropSet( SvStream& rIn, void* pClientData ) const
 
 #ifdef DBG_CUSTOMSHAPE
 
-    String aURLStr;
+    rtl::OUString aURLStr;
 
     if( ::utl::LocalFileHelper::ConvertPhysicalNameToURL( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("d:\\ashape.dbg")), aURLStr ) )
     {
@@ -1091,19 +1091,19 @@ void SvxMSDffManager::SolveSolver( const SvxMSDffSolverContainer& rSolver )
                             {
                                 if ( nN )
                                 {
-                                    String aPropName( RTL_CONSTASCII_USTRINGPARAM( "EndShape" ) );
+                                    rtl::OUString aPropName( RTL_CONSTASCII_USTRINGPARAM( "EndShape" ) );
                                     aAny <<= aXShape;
                                     SetPropValue( aAny, xPropSet, aPropName, sal_True );
-                                    aPropName  = String( RTL_CONSTASCII_USTRINGPARAM( "EndGluePointIndex" ) );
+                                    aPropName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "EndGluePointIndex" ) );
                                     aAny <<= nId;
                                     SetPropValue( aAny, xPropSet, aPropName, sal_True );
                                 }
                                 else
                                 {
-                                    String aPropName( RTL_CONSTASCII_USTRINGPARAM( "StartShape" ) );
+                                    rtl::OUString aPropName( RTL_CONSTASCII_USTRINGPARAM( "StartShape" ) );
                                     aAny <<= aXShape;
                                     SetPropValue( aAny, xPropSet, aPropName, sal_True );
-                                    aPropName = String( RTL_CONSTASCII_USTRINGPARAM( "StartGluePointIndex" ) );
+                                    aPropName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StartGluePointIndex" ) );
                                     aAny <<= nId;
                                     SetPropValue( aAny, xPropSet, aPropName, sal_True );
                                 }
@@ -1126,7 +1126,7 @@ void SvxMSDffManager::SolveSolver( const SvxMSDffSolverContainer& rSolver )
 static basegfx::B2DPolygon GetLineArrow( const sal_Int32 nLineWidth, const MSO_LineEnd eLineEnd,
     const MSO_LineEndWidth eLineWidth, const MSO_LineEndLength eLineLenght,
     sal_Int32& rnArrowWidth, sal_Bool& rbArrowCenter,
-    String& rsArrowName, sal_Bool bScaleArrow )
+    rtl::OUString& rsArrowName, sal_Bool bScaleArrow )
 {
     basegfx::B2DPolygon aRetval;
     double      fLineWidth = nLineWidth < 70 ? 70.0 : nLineWidth;
@@ -1154,6 +1154,7 @@ static basegfx::B2DPolygon GetLineArrow( const sal_Int32 nLineWidth, const MSO_L
     }
 
     rbArrowCenter = sal_False;
+    rtl::OUStringBuffer aArrowName;
     switch ( eLineEnd )
     {
         case mso_lineArrowEnd :
@@ -1164,7 +1165,7 @@ static basegfx::B2DPolygon GetLineArrow( const sal_Int32 nLineWidth, const MSO_L
             aTriangle.append(basegfx::B2DPoint( 0.0, fLenghtMul * fLineWidth ));
             aTriangle.setClosed(true);
             aRetval = aTriangle;
-            rsArrowName = String( RTL_CONSTASCII_STRINGPARAM( "msArrowEnd " ), RTL_TEXTENCODING_UTF8 );
+            aArrowName.appendAscii(RTL_CONSTASCII_STRINGPARAM("msArrowEnd "));
         }
         break;
 
@@ -1193,7 +1194,7 @@ static basegfx::B2DPolygon GetLineArrow( const sal_Int32 nLineWidth, const MSO_L
             aTriangle.append(basegfx::B2DPoint( 0.0, fLenghtMul * fLineWidth * 0.91 ));
             aTriangle.setClosed(true);
             aRetval = aTriangle;
-            rsArrowName = String( RTL_CONSTASCII_STRINGPARAM( "msArrowOpenEnd " ), RTL_TEXTENCODING_UTF8 );
+            aArrowName.appendAscii(RTL_CONSTASCII_STRINGPARAM("msArrowOpenEnd "));
         }
         break;
         case mso_lineArrowStealthEnd :
@@ -1205,7 +1206,7 @@ static basegfx::B2DPolygon GetLineArrow( const sal_Int32 nLineWidth, const MSO_L
             aTriangle.append(basegfx::B2DPoint( 0.0, fLenghtMul * fLineWidth ));
             aTriangle.setClosed(true);
             aRetval = aTriangle;
-            rsArrowName = String( RTL_CONSTASCII_STRINGPARAM( "msArrowStealthEnd " ), RTL_TEXTENCODING_UTF8 );
+            aArrowName.appendAscii(RTL_CONSTASCII_STRINGPARAM("msArrowStealthEnd "));
         }
         break;
         case mso_lineArrowDiamondEnd :
@@ -1218,7 +1219,7 @@ static basegfx::B2DPolygon GetLineArrow( const sal_Int32 nLineWidth, const MSO_L
             aTriangle.setClosed(true);
             aRetval = aTriangle;
             rbArrowCenter = sal_True;
-            rsArrowName = String( RTL_CONSTASCII_STRINGPARAM( "msArrowDiamondEnd " ), RTL_TEXTENCODING_UTF8 );
+            aArrowName.appendAscii(RTL_CONSTASCII_STRINGPARAM("msArrowDiamondEnd "));
         }
         break;
         case mso_lineArrowOvalEnd :
@@ -1227,12 +1228,13 @@ static basegfx::B2DPolygon GetLineArrow( const sal_Int32 nLineWidth, const MSO_L
                                 (sal_Int32)( fWidthMul * fLineWidth * 0.50 ),
                                     (sal_Int32)( fLenghtMul * fLineWidth * 0.50 ), 0, 3600 ).getB2DPolygon();
             rbArrowCenter = sal_True;
-            rsArrowName = String( RTL_CONSTASCII_STRINGPARAM( "msArrowOvalEnd " ), RTL_TEXTENCODING_UTF8 );
+            aArrowName.appendAscii(RTL_CONSTASCII_STRINGPARAM("msArrowOvalEnd "));
         }
         break;
         default: break;
     }
-    rsArrowName.Append( String::CreateFromInt32( nLineNumber ) );
+    aArrowName.append(nLineNumber);
+    rsArrowName = aArrowName.makeStringAndClear();
     rnArrowWidth = (sal_Int32)( fLineWidth * fWidthMul );
 
     return aRetval;
@@ -1315,10 +1317,10 @@ void DffPropertyReader::ApplyLineAttributes( SfxItemSet& rSet, const MSO_SPT eSh
                 break;
             }
 
-            rSet.Put( XLineDashItem( String(), XDash( eDash, nDots, nDotLen, nDashes, nDashLen, nDistance ) ) );
+            rSet.Put( XLineDashItem( rtl::OUString(), XDash( eDash, nDots, nDotLen, nDashes, nDashLen, nDistance ) ) );
             rSet.Put( XLineStyleItem( XLINE_DASH ) );
         }
-        rSet.Put( XLineColorItem( String(), rManager.MSO_CLR_ToColor( GetPropertyValue( DFF_Prop_lineColor ), DFF_Prop_lineColor ) ) );
+        rSet.Put( XLineColorItem( rtl::OUString(), rManager.MSO_CLR_ToColor( GetPropertyValue( DFF_Prop_lineColor ), DFF_Prop_lineColor ) ) );
         if ( IsProperty( DFF_Prop_lineOpacity ) )
         {
             double nTrans = GetPropertyValue(DFF_Prop_lineOpacity, 0x10000);
@@ -1356,7 +1358,7 @@ void DffPropertyReader::ApplyLineAttributes( SfxItemSet& rSet, const MSO_SPT eSh
 
                 sal_Int32   nArrowWidth;
                 sal_Bool    bArrowCenter;
-                String      aArrowName;
+                rtl::OUString aArrowName;
                 basegfx::B2DPolygon aPoly(GetLineArrow( nLineWidth, eLineEnd, eWidth, eLenght, nArrowWidth, bArrowCenter, aArrowName, bScaleArrows ));
 
                 rSet.Put( XLineStartWidthItem( nArrowWidth ) );
@@ -1374,7 +1376,7 @@ void DffPropertyReader::ApplyLineAttributes( SfxItemSet& rSet, const MSO_SPT eSh
 
                 sal_Int32   nArrowWidth;
                 sal_Bool    bArrowCenter;
-                String      aArrowName;
+                rtl::OUString aArrowName;
                 basegfx::B2DPolygon aPoly(GetLineArrow( nLineWidth, eLineEnd, eWidth, eLenght, nArrowWidth, bArrowCenter, aArrowName, bScaleArrows ));
 
                 rSet.Put( XLineEndWidthItem( nArrowWidth ) );
@@ -1395,7 +1397,7 @@ void DffPropertyReader::ApplyLineAttributes( SfxItemSet& rSet, const MSO_SPT eSh
                     {
                         XDash aNew( rOldDash );
                         aNew.SetDashStyle( eNewStyle );
-                        rSet.Put( XLineDashItem( XubString(), aNew ) );
+                        rSet.Put( XLineDashItem( rtl::OUString(), aNew ) );
                     }
                 }
             }
@@ -1591,7 +1593,7 @@ void ApplyRectangularGradientAsBitmap( const SvxMSDffManager& rManager, SvStream
 
             XOBitmap aXBmp( aBitmap, XBITMAP_STRETCH );
             rSet.Put( XFillBmpTileItem( sal_False ) );
-            rSet.Put( XFillBitmapItem( String(), aXBmp ) );
+            rSet.Put( XFillBitmapItem( rtl::OUString(), aXBmp ) );
         }
     }
 }
@@ -1711,7 +1713,7 @@ void DffPropertyReader::ApplyFillAttributes( SvStream& rIn, SfxItemSet& rSet, co
             XGradient aGrad( aCol2, aCol1, eGrad, nAngle, nFocusX, nFocusY );
             aGrad.SetStartIntens( 100 );
             aGrad.SetEndIntens( 100 );
-            rSet.Put( XFillGradientItem( String(), aGrad ) );
+            rSet.Put( XFillGradientItem( rtl::OUString(), aGrad ) );
         }
         else if ( eXFill == XFILL_BITMAP )
         {
@@ -1748,13 +1750,13 @@ void DffPropertyReader::ApplyFillAttributes( SvStream& rIn, SfxItemSet& rSet, co
                            aXOBitmap.SetBackgroundColor( aCol2 );
                            aXOBitmap.Array2Bitmap();
                         }
-                        rSet.Put( XFillBitmapItem( String(), aXOBitmap ) );
+                        rSet.Put( XFillBitmapItem( rtl::OUString(), aXOBitmap ) );
                     }
                     else if ( eMSO_FillType == mso_fillTexture )
                     {
                         XOBitmap aXBmp( aBmp, XBITMAP_STRETCH );
                         rSet.Put( XFillBmpTileItem( sal_True ) );
-                        rSet.Put( XFillBitmapItem( String(), aXBmp ) );
+                        rSet.Put( XFillBitmapItem( rtl::OUString(), aXBmp ) );
                         rSet.Put( XFillBmpSizeXItem( GetPropertyValue( DFF_Prop_fillWidth, 0 ) / 360 ) );
                         rSet.Put( XFillBmpSizeYItem( GetPropertyValue( DFF_Prop_fillHeight, 0 ) / 360 ) );
                         rSet.Put( XFillBmpSizeLogItem( sal_True ) );
@@ -1762,7 +1764,7 @@ void DffPropertyReader::ApplyFillAttributes( SvStream& rIn, SfxItemSet& rSet, co
                     else
                     {
                         XOBitmap aXBmp( aBmp, XBITMAP_STRETCH );
-                        rSet.Put( XFillBitmapItem( String(), aXBmp ) );
+                        rSet.Put( XFillBitmapItem( rtl::OUString(), aXBmp ) );
                         rSet.Put( XFillBmpTileItem( sal_False ) );
                     }
                 }
@@ -2943,7 +2945,7 @@ void DffPropertyReader::ApplyAttributes( SvStream& rIn, SfxItemSet& rSet, const
             break;
 
             case DFF_Prop_fillColor :
-                rSet.Put( XFillColorItem( String(), rManager.MSO_CLR_ToColor( nContent, DFF_Prop_fillColor ) ) );
+                rSet.Put( XFillColorItem( rtl::OUString(), rManager.MSO_CLR_ToColor( nContent, DFF_Prop_fillColor ) ) );
             break;
 
             // ShadowStyle
@@ -2963,7 +2965,7 @@ void DffPropertyReader::ApplyAttributes( SvStream& rIn, SfxItemSet& rSet, const
             }
             break;
             case DFF_Prop_shadowColor :
-                rSet.Put( SdrShadowColorItem( String(), rManager.MSO_CLR_ToColor( nContent, DFF_Prop_shadowColor ) ) );
+                rSet.Put( SdrShadowColorItem( rtl::OUString(), rManager.MSO_CLR_ToColor( nContent, DFF_Prop_shadowColor ) ) );
             break;
             case DFF_Prop_shadowOpacity :
                 rSet.Put( SdrShadowTransparenceItem( (sal_uInt16)( ( 0x10000 - nContent ) / 655 ) ) );
@@ -5660,7 +5662,7 @@ SdrObject* SvxMSDffManager::ProcessObj(SvStream& rSt,
             SfxItemState eState = aSet.GetItemState( XATTR_FILLCOLOR,
                                                      sal_False, &pPoolItem );
             if( SFX_ITEM_DEFAULT == eState )
-                aSet.Put( XFillColorItem( String(),
+                aSet.Put( XFillColorItem( rtl::OUString(),
                           Color( mnDefaultColor ) ) );
             pObj->SetMergedItemSet(aSet);
         }
@@ -6732,7 +6734,7 @@ sal_Bool SvxMSDffManager::GetBLIPDirect( SvStream& rBLIPStream, Graphic& rData,
             case 0x7a8 : aFileName.Append( String( RTL_CONSTASCII_USTRINGPARAM( ".bmp" ) ) ); break;
         }
 
-        String aURLStr;
+        rtl::OUString aURLStr;
         if( ::utl::LocalFileHelper::ConvertPhysicalNameToURL( Application::GetAppFileName(), aURLStr ) )
         {
             INetURLObject aURL( aURLStr );


More information about the Libreoffice-commits mailing list