diff options
Diffstat (limited to 'tools/source')
25 files changed, 550 insertions, 2498 deletions
diff --git a/tools/source/fsys/dirent.cxx b/tools/source/fsys/dirent.cxx index a188569868e1..ea3db76c5c07 100644 --- a/tools/source/fsys/dirent.cxx +++ b/tools/source/fsys/dirent.cxx @@ -331,6 +331,7 @@ ByteString ImplCutPath( const ByteString& rStr, sal_uInt16 nMax, char cAccDel ) return aCutPath; } +#if defined(WNT) /************************************************************************* |* |* DirEntry::ImpParseOs2Name() @@ -402,9 +403,15 @@ FSysError DirEntry::ImpParseOs2Name( const ByteString& rPfad, FSysPathStyle eSty else { // liegt ein anderes Drive auf dem Stack? - if ( aStack.Count() && - COMPARE_EQUAL != aStack.Bottom()->aName.CompareIgnoreCaseToAscii(aName) ) - aStack.Clear(); + if ( aStack.Count() ) + { + rtl::OString aThis(aStack.Bottom()->aName); + aThis = aThis.toAsciiLowerCase(); + rtl::OString aOther(aName); + aOther = aOther.toAsciiLowerCase(); + if (aThis.compareTo(aOther) != 0) + aStack.Clear(); + } // liegt jetzt nichts mehr auf dem Stack? if ( !aStack.Count() ) @@ -502,6 +509,7 @@ FSysError DirEntry::ImpParseOs2Name( const ByteString& rPfad, FSysPathStyle eSty aName = rPfad; return nErr; } +#endif /************************************************************************* |* @@ -662,7 +670,6 @@ DirEntry::DirEntry( const String& rInitName, FSysPathStyle eStyle ) } #ifdef DBG_UTIL - // ASF nur bei Default eStyle, nicht z.B. aus MakeShortName() if( eStyle == FSYS_STYLE_HOST && aTmpName.Search( "://" ) != STRING_NOTFOUND ) { @@ -709,7 +716,6 @@ DirEntry::DirEntry( const ByteString& rInitName, FSysPathStyle eStyle ) } #ifdef DBG_UTIL else - // ASF nur bei Default eStyle, nicht z.B. aus MakeShortName() if( eStyle == FSYS_STYLE_HOST && rInitName.Search( "://" ) != STRING_NOTFOUND ) { @@ -1129,31 +1135,6 @@ String DirEntry::CutName( FSysPathStyle eStyle ) /************************************************************************* |* -|* DirEntry::NameCompare -|* -|* Beschreibung Vergleich nur die Namen (ohne Pfad, aber mit Gross/Klein) -|* -*************************************************************************/ - -StringCompare DirEntry::NameCompare( const DirEntry &rWith ) const -{ - ByteString aThisName; - ByteString aParameterName; - -#ifdef UNX - aThisName = aName; - aParameterName = rWith.aName; -#else - aThisName = ByteString(aName).ToLowerAscii(); - aParameterName = ByteString(rWith.aName).ToLowerAscii(); -#endif - - return aThisName.CompareTo( aParameterName ); -} - - -/************************************************************************* -|* |* DirEntry::operator==() |* *************************************************************************/ @@ -1369,31 +1350,6 @@ void DirEntry::SetExtension( const String& rExtension, char cSep ) /************************************************************************* |* -|* DirEntry::CutExtension() -|* -*************************************************************************/ - -String DirEntry::CutExtension( char cSep ) -{ - DBG_CHKTHIS( DirEntry, ImpCheckDirEntry ); - - const char *p0 = ( aName.GetBuffer() ); - const char *p1 = p0 + aName.Len() - 1; - while ( p1 >= p0 && *p1 != cSep ) - p1--; - - if ( p1 >= p0 ) - { - // es wurde ein cSep an der Position p1 gefunden - aName.Erase( static_cast< xub_StrLen >(p1-p0) ); - return String(p1 + 1, osl_getThreadTextEncoding()); - } - - return String(); -} - -/************************************************************************* -|* |* DirEntry::SetName() |* *************************************************************************/ @@ -1728,6 +1684,7 @@ const DirEntry &DirEntry::operator[]( sal_uInt16 nParentLevel ) const return *pRes; } +#if !defined(WNT) /************************************************************************* |* |* DirEntry::ImpParseUnixName() @@ -1843,200 +1800,12 @@ FSysError DirEntry::ImpParseUnixName( const ByteString& rPfad, FSysPathStyle eSt return FSYS_ERR_OK; } - -/************************************************************************* -|* -|* DirEntry::MakeShortName() -|* -*************************************************************************/ - -ErrCode CreateEntry_Impl( const DirEntry &rPath, DirEntryKind eKind ) -{ - // versuchen, anzulegen (ausser bei FSYS_KIND_ALL) - ErrCode eErr = ERRCODE_NONE; - if ( FSYS_KIND_FILE == eKind ) - { - SvFileStream aStream( rPath.GetFull(), STREAM_STD_WRITE ); - aStream.WriteLine( "" ); - eErr = aStream.GetError(); - } - else if ( FSYS_KIND_ALL != eKind ) - eErr = rPath.MakeDir() ? ERRCODE_NONE : ERRCODE_IO_UNKNOWN; - - // erfolgreich? - if ( !rPath.Exists() ) - eErr = ERRCODE_IO_UNKNOWN; // Doch was schiefgegangen ? - - // ggf. wieder l"oschen - if ( FSYS_KIND_NONE == eKind ) - rPath.Kill(); - - // Fehlercode zur?ckliefern - return eErr; -} - -sal_Bool IsValidEntry_Impl( const DirEntry &rPath, - const String &rLongName, - DirEntryKind eKind, - sal_Bool bIsShortened, - sal_Bool bUseDelim ) -{ - // Parameter-Pr"uefung - DBG_ASSERT( eKind == FSYS_KIND_NONE || eKind == FSYS_KIND_ALL || - eKind == FSYS_KIND_FILE || eKind == FSYS_KIND_DIR, - "invalid entry-kind" ); - - // Alle von MSDOS erreichbaren FSYS_STYLES muessen den - // MSDOS Filenamenanforderungen genuegen. Sonst wird probiert, - // ob sich eine Datei des gewuenschten Names anlegen laesst. - FSysPathStyle eStyle = DirEntry::GetPathStyle( rPath.GetDevice().GetName() ); - DirEntry aPath(rPath); - DirEntry aName(rLongName, eStyle); - if ( !aName.IsValid() || aName.Level() != 1 ) - return sal_False; - aPath += aName; - if ( 1 == aPath.Level() ) - return sal_False; - - // Pfad-Trenner sind nicht erlaubt (bei ungek"urzten auch nicht FSYS_SHORTNAME_DELIMITER) - char cDelim = bUseDelim == 2 ? FSYS_SHORTNAME_DELIMITER : char(0); - if ( - rLongName.Search(DirEntry::GetAccessDelimiter()) != STRING_NOTFOUND || - (!bIsShortened && rLongName.Search(cDelim) != STRING_NOTFOUND) - ) - { - return sal_False; - } - - // MI: Abfrage nach 'CON:' etc. wird jetzt in Exists() mitgemacht - if ( aPath.Exists() ) - return sal_False; - - return (ERRCODE_NONE == CreateEntry_Impl( aPath, eKind )); -} - -//------------------------------------------------------------------------- +#endif #define MAX_EXT_MAX 250 #define MAX_LEN_MAX 255 #define INVALID_CHARS_DEF "\\/\"':|^<>?*" -sal_Bool DirEntry::MakeShortName( const String& rLongName, DirEntryKind eKind, - sal_Bool bUseDelim, FSysPathStyle eStyle ) -{ - String aLongName(rLongName); - - // Alle '#' aus den Dateinamen entfernen, weil das INetURLObject - // damit Probleme hat. Siehe auch #51246# - aLongName.EraseAllChars( '#' ); - ByteString bLongName(aLongName, osl_getThreadTextEncoding()); - - // Auf Novell-Servern (wegen der rottigen Clients) nur 7bit ASCII - - // bei FSYS_KIND_ALL den alten Namen merken und abh"angen (rename) - ByteString aOldName; - if ( FSYS_KIND_ALL == eKind ) - { - aOldName = ByteString(CutName(), osl_getThreadTextEncoding()); - aOldName = CMP_LOWER(aOldName); - } - - // ist der Langname direkt verwendbar? - if ( IsValidEntry_Impl( *this, aLongName, eKind, sal_False, bUseDelim ) ) - { - operator+=( DirEntry(aLongName) ); - return sal_True; - } - - // max L"angen feststellen - sal_uInt16 nMaxExt, nMaxLen; - if ( FSYS_STYLE_DETECT == eStyle ) - eStyle = DirEntry::GetPathStyle( GetDevice().GetName() ); - ByteString aInvalidChars; - nMaxExt = MAX_EXT_MAX; - nMaxLen = MAX_LEN_MAX; - aInvalidChars = INVALID_CHARS_DEF; - - // Extension abschneiden und kuerzen - ByteString aExt; - ByteString aFName = bLongName; - DirEntry aUnparsed; - aUnparsed.aName = bLongName; - aExt = ByteString(aUnparsed.CutExtension(), osl_getThreadTextEncoding()); - aFName = aUnparsed.aName; - if ( aExt.Len() > nMaxExt ) - { - char c = aExt.GetChar( aExt.Len() - 1 ); - aExt.Erase(nMaxExt-1); - aExt += c; - } - - // ausser auf einem FAT-System geh"ort die Extension zur - // Maxl"ange. Muss also vorher mit dem Punkt abgezogen werden. - nMaxLen -= ( aExt.Len() + 1 ); - - // Name k"urzen - ByteString aSName; - for ( const char *pc = aFName.GetBuffer(); aSName.Len() < nMaxLen && *pc; ++pc ) - { - if ( STRING_NOTFOUND == aInvalidChars.Search( *pc ) && - (unsigned char) *pc >= (unsigned char) 32 && - ( !aSName.Len() || *pc != ' ' || aSName.GetChar(aSName.Len()-1) != ' ' ) ) - aSName += *pc; - } - aSName.EraseTrailingChars(); - - // HRO: #74246# Also cut leading spaces - aSName.EraseLeadingChars(); - - if ( !aSName.Len() ) - aSName = "noname"; - - // kommt dabei der alte Name raus? - ByteString aNewName = aSName; - if ( aExt.Len() ) - ( aNewName += '.' ) += aExt; - operator+=( DirEntry(String(aNewName, osl_getThreadTextEncoding())) ); - if ( FSYS_KIND_ALL == eKind && CMP_LOWER(aName) == aOldName ) - if ( FSYS_KIND_ALL == eKind && CMP_LOWER(ByteString(GetName(), osl_getThreadTextEncoding())) == aOldName ) - return sal_True; - - // kann der gek"urzte Name direkt verwendet werden? - if ( !Exists() && (ERRCODE_NONE == CreateEntry_Impl( *this, eKind )) ) - return sal_True; - - // darf '?##' verwendet werden, um eindeutigen Name zu erzeugen? - if ( bUseDelim ) - { - // eindeutigen Namen per '?##' erzeugen - aSName.Erase( nMaxLen-3 ); - if ( bUseDelim != 2 ) - aSName += FSYS_SHORTNAME_DELIMITER; - for ( int n = 1; n < 99; ++n ) - { - // Name zusammensetzen - ByteString aTmpStr( aSName ); - aTmpStr += ByteString::CreateFromInt32(n); - if ( aExt.Len() ) - ( aTmpStr += '.' ) += aExt; - - // noch nicht vorhanden? - SetName( String(aTmpStr, osl_getThreadTextEncoding()) ); - - if ( !Exists() ) - { - // Fehler setzen !!! - nError = CreateEntry_Impl( *this, eKind ); - return (ERRCODE_NONE == nError); - } - } - } - - // keine ## mehr frei / ?## soll nicht verwendet werden - nError = ERRCODE_IO_ALREADYEXISTS; - return sal_False; -} - /************************************************************************* |* |* DirEntry::CreatePath() diff --git a/tools/source/fsys/tdir.cxx b/tools/source/fsys/tdir.cxx index 6d16a5ed605a..db811f35e76b 100644 --- a/tools/source/fsys/tdir.cxx +++ b/tools/source/fsys/tdir.cxx @@ -386,27 +386,6 @@ sal_uInt16 Dir::Scan( sal_uInt16 nCount ) |* *************************************************************************/ -Dir::Dir( const DirEntry& rDirEntry, DirEntryKind nKindFlags, FSysSort nSort, ... ): - DirEntry( rDirEntry ), - pReader( 0 ) -{ - DBG_CTOR( Dir, NULL ); - - Construct( nKindFlags ); - - std::va_list pArgs; - va_start( pArgs, nSort ); - ImpSetSort( pArgs, nSort ); - - Reset(); -} - -/************************************************************************* -|* -|* Dir::Dir() -|* -*************************************************************************/ - Dir::Dir( const DirEntry& rDirEntry, DirEntryKind nKindFlags ): DirEntry( rDirEntry ), pReader( 0 ) @@ -419,24 +398,6 @@ Dir::Dir( const DirEntry& rDirEntry, DirEntryKind nKindFlags ): /************************************************************************* |* -|* Dir::Dir() -|* -*************************************************************************/ - -Dir::Dir(): - pReader( 0 ) -{ - DBG_CTOR( Dir, NULL ); - - pLst = NULL; - pSortLst = NULL; - pStatLst = NULL; - eAttrMask = FSYS_KIND_ALL; - aNameMask = String("*", osl_getThreadTextEncoding()); -} - -/************************************************************************* -|* |* Dir::~Dir() |* *************************************************************************/ @@ -587,19 +548,6 @@ FSysError Dir::ImpSetSort( std::va_list pArgs, int nFirstSort ) /************************************************************************* |* -|* Dir::SetSort() -|* -*************************************************************************/ - -FSysError Dir::SetSort( FSysSort nSort, ... ) -{ - std::va_list pArgs; - va_start( pArgs, nSort ); - return ImpSetSort( pArgs, nSort ); -} - -/************************************************************************* -|* |* Dir::operator[]() |* *************************************************************************/ diff --git a/tools/source/fsys/tempfile.cxx b/tools/source/fsys/tempfile.cxx index 078e91834975..b6a4b1e2b70e 100644 --- a/tools/source/fsys/tempfile.cxx +++ b/tools/source/fsys/tempfile.cxx @@ -267,37 +267,4 @@ String TempFile::GetName() const return aTmp; } -String TempFile::SetTempNameBaseDirectory( const String &rBaseName ) -{ - String aName( rBaseName ); - - ::rtl::OUString& rTempNameBase_Impl = TempNameBase_Impl::get(); - - FileBase::RC err= Directory::create( aName ); - if ( err == FileBase::E_None || err == FileBase::E_EXIST ) - { - rTempNameBase_Impl = aName; - rTempNameBase_Impl += String( '/' ); - - TempFile aBase( NULL, sal_True ); - if ( aBase.IsValid() ) - rTempNameBase_Impl = aBase.pImp->aName; - } - - rtl::OUString aTmp; - aTmp = rTempNameBase_Impl; - return aTmp; -} - -String TempFile::GetTempNameBaseDirectory() -{ - ::rtl::OUString& rTempNameBase_Impl = TempNameBase_Impl::get(); - if ( !rTempNameBase_Impl.getLength() ) - rTempNameBase_Impl = GetSystemTempDir_Impl(); - - rtl::OUString aTmp; - aTmp = rTempNameBase_Impl; - return aTmp; -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/tools/source/fsys/unx.cxx b/tools/source/fsys/unx.cxx index b04a2e64904a..0adc7ce8fa03 100644 --- a/tools/source/fsys/unx.cxx +++ b/tools/source/fsys/unx.cxx @@ -44,7 +44,7 @@ extern "C" int mntctl( int cmd, size_t size, char* buf ); #elif defined(NETBSD) #include <sys/mount.h> #elif defined(FREEBSD) || defined(MACOSX) || defined(OPENBSD) || \ - defined(DRAGONFLY) + defined(DRAGONFLY) || defined(IOS) struct mnttab { char *mnt_dir; @@ -85,7 +85,7 @@ struct mymnttab #if defined(NETBSD) || defined(FREEBSD) || defined(MACOSX) || \ - defined(OPENBSD) || defined(DRAGONFLY) + defined(OPENBSD) || defined(DRAGONFLY) || defined(IOS) sal_Bool GetMountEntry(dev_t /* dev */, struct mymnttab * /* mytab */ ) { DBG_WARNING( "Sorry, not implemented: GetMountEntry" ); @@ -478,7 +478,7 @@ const char *TempDirImpl( char *pBuf ) |* *************************************************************************/ -FSysPathStyle DirEntry::GetPathStyle( const String & ) +FSysPathStyle DirEntry::GetPathStyle() { return FSYS_STYLE_UNX; } @@ -521,17 +521,4 @@ void FileStat::SetDateTime( const String& rFileName, } } -//========================================================================= - -ErrCode FileStat::QueryDiskSpace( const String &, BigInt &, BigInt & ) -{ - return ERRCODE_IO_NOTSUPPORTED; -} - -//========================================================================= - -void FSysEnableSysErrorBox( sal_Bool ) -{ -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx index 6a855d7d85c8..bf3cf2e95a4d 100644 --- a/tools/source/fsys/urlobj.cxx +++ b/tools/source/fsys/urlobj.cxx @@ -2909,29 +2909,6 @@ bool INetURLObject::parseHostOrNetBiosName( } //============================================================================ -// static -rtl::OUString INetURLObject::encodeHostPort(rtl::OUString const & rTheHostPort, - bool bOctets, - EncodeMechanism eMechanism, - rtl_TextEncoding eCharset) -{ - sal_Int32 nPort = rTheHostPort.getLength(); - if (nPort != 0) - { - sal_Int32 i = nPort - 1; - while (i != 0 && INetMIME::isDigit(rTheHostPort.getStr()[i])) - --i; - if (rTheHostPort.getStr()[i] == ':') - nPort = i; - } - rtl::OUString aResult(encodeText(rTheHostPort.copy(0, nPort), bOctets, - PART_HOST_EXTRA, '%', eMechanism, eCharset, - true)); - aResult += rTheHostPort.copy(nPort); - return aResult; -} - -//============================================================================ bool INetURLObject::setHost(rtl::OUString const & rTheHost, bool bOctets, EncodeMechanism eMechanism, rtl_TextEncoding eCharset) @@ -3706,31 +3683,6 @@ bool INetURLObject::setFragment(rtl::OUString const & rTheFragment, } //============================================================================ -INetURLObject::FTPType INetURLObject::getFTPType() const -{ - if (m_eScheme == INET_PROT_FTP - && m_aPath.getLength() >= RTL_CONSTASCII_LENGTH(";type=") + 1 - && rtl::OUString(m_aAbsURIRef).copy( - m_aPath.getEnd() - (RTL_CONSTASCII_LENGTH(";type=") + 1), - RTL_CONSTASCII_LENGTH(";type=")).equalsIgnoreAsciiCaseAscii(";type=")) - switch (m_aAbsURIRef.charAt(m_aPath.getEnd())) - { - case 'A': - case 'a': - return FTP_TYPE_A; - - case 'D': - case 'd': - return FTP_TYPE_D; - - case 'I': - case 'i': - return FTP_TYPE_I; - } - return FTP_TYPE_NONE; -} - -//============================================================================ bool INetURLObject::hasDosVolume(FSysStyle eStyle) const { sal_Unicode const * p = m_aAbsURIRef.getStr() + m_aPath.getBegin(); @@ -3743,33 +3695,6 @@ bool INetURLObject::hasDosVolume(FSysStyle eStyle) const } //============================================================================ -sal_uInt32 INetURLObject::getIMAPUID() const -{ - if (m_eScheme == INET_PROT_IMAP - && m_aPath.getLength() >= RTL_CONSTASCII_LENGTH("/;uid=") + 1) - { - sal_Unicode const * pBegin = m_aAbsURIRef.getStr() - + m_aPath.getBegin() - + RTL_CONSTASCII_LENGTH("/;uid="); - sal_Unicode const * pEnd = pBegin + m_aPath.getLength(); - sal_Unicode const * p = pEnd; - while (p > pBegin && INetMIME::isDigit(p[-1])) - --p; - if (p < pEnd && *--p != '0' - && rtl::OUString(m_aAbsURIRef).copy( - p - RTL_CONSTASCII_LENGTH("/;uid=") - m_aAbsURIRef.getStr(), - RTL_CONSTASCII_LENGTH("/;uid=")).equalsIgnoreAsciiCaseAscii("/;uid=") - ) - { - sal_uInt32 nUID; - if (INetMIME::scanUnsigned(p, pEnd, false, nUID)) - return nUID; - } - } - return 0; -} - -//============================================================================ // static rtl::OUString INetURLObject::encodeText(sal_Unicode const * pBegin, sal_Unicode const * pEnd, bool bOctets, @@ -4369,22 +4294,6 @@ bool INetURLObject::hasPassword() const } //============================================================================ -void INetURLObject::makeAuthCanonic() -{ - if (m_eScheme == INET_PROT_IMAP && m_aAuth.getLength() == 1 - && m_aAbsURIRef.charAt(m_aAuth.getBegin()) == '*') - { - lcl_Erase(m_aAbsURIRef, m_aAuth.getBegin() - - RTL_CONSTASCII_LENGTH(";AUTH="), - RTL_CONSTASCII_LENGTH(";AUTH=*")); - sal_Int32 nDelta = m_aAuth.clear() - RTL_CONSTASCII_LENGTH(";AUTH="); - m_aPath += nDelta; - m_aQuery += nDelta; - m_aFragment += nDelta; - } -} - -//============================================================================ rtl::OUString INetURLObject::GetHostPort(DecodeMechanism eMechanism, rtl_TextEncoding eCharset) { @@ -4441,33 +4350,6 @@ bool INetURLObject::SetPort(sal_uInt32 nThePort) } //============================================================================ -void INetURLObject::makePortCanonic() -{ - if (m_aPort.isPresent()) - { - sal_Unicode const * p = m_aAbsURIRef.getStr() + m_aPort.getBegin(); - sal_Unicode const * pEnd = p + m_aPort.getLength(); - sal_uInt32 nThePort; - if (INetMIME::scanUnsigned(p, pEnd, true, nThePort) && p == pEnd) - { - sal_Int32 nDelta; - if (nThePort != 0 && nThePort == getSchemeInfo().m_nDefaultPort) - { - lcl_Erase(m_aAbsURIRef, m_aPort.getBegin() - 1, - m_aPort.getLength() + 1); - nDelta = m_aPort.clear() - 1; - } - else - nDelta = m_aPort.set(m_aAbsURIRef, - rtl::OUString::valueOf(sal_Int64(nThePort))); - m_aPath += nDelta; - m_aQuery += nDelta; - m_aFragment += nDelta; - } - } -} - -//============================================================================ sal_Int32 INetURLObject::getSegmentCount(bool bIgnoreFinalSlash) const { if (!checkHierarchical()) @@ -5137,19 +5019,6 @@ rtl::OUString INetURLObject::getFSysPath(FSysStyle eStyle, } //============================================================================ -bool INetURLObject::HasMsgId() const -{ - if (m_eScheme != INET_PROT_POP3) - return false; - sal_Unicode const * p = m_aAbsURIRef.getStr() + m_aPath.getBegin(); - sal_Unicode const * pEnd = p + m_aPath.getLength(); - for (; p < pEnd; ++p) - if (*p == '<') - return true; - return false; -} - -//============================================================================ rtl::OUString INetURLObject::GetMsgId(DecodeMechanism eMechanism, rtl_TextEncoding eCharset) const { @@ -5593,14 +5462,6 @@ void INetURLObject::SetName(rtl::OUString const & rTheName, } //============================================================================ -rtl::OUString INetURLObject::CutName(DecodeMechanism eMechanism, - rtl_TextEncoding eCharset) -{ - rtl::OUString aTheName(getName(LAST_SEGMENT, true, eMechanism, eCharset)); - return removeSegment(LAST_SEGMENT, true) ? aTheName : rtl::OUString(); -} - -//============================================================================ void INetURLObject::SetExtension(rtl::OUString const & rTheExtension, EncodeMechanism eMechanism, rtl_TextEncoding eCharset) diff --git a/tools/source/fsys/wntmsc.cxx b/tools/source/fsys/wntmsc.cxx index fa18aa46fcf1..ab783b45a161 100644 --- a/tools/source/fsys/wntmsc.cxx +++ b/tools/source/fsys/wntmsc.cxx @@ -114,7 +114,7 @@ int closedir( DIR *pDir ) |* *************************************************************************/ -FSysPathStyle DirEntry::GetPathStyle( const String & ) +FSysPathStyle DirEntry::GetPathStyle() { return FSYS_STYLE_NTFS; } @@ -872,42 +872,4 @@ const char* TempDirImpl( char *pBuf ) return pBuf; } -//======================================================================= - -ErrCode FileStat::QueryDiskSpace( const String &rPath, - BigInt &rFreeBytes, BigInt &rTotalBytes ) -{ - DWORD nSectorsPerCluster; /* address of sectors per cluster */ - DWORD nBytesPerSector; /* address of bytes per sector */ - DWORD nFreeClusters; /* address of number of free clusters */ - DWORD nClusters; /* address of total number of clusters */ - - ByteString aVol( DirEntry(rPath).ImpGetTopPtr()->GetName(), osl_getThreadTextEncoding()); - bool bOK = GetDiskFreeSpace( aVol.GetBuffer(), - &nSectorsPerCluster, &nBytesPerSector, - &nFreeClusters, &nClusters ); - if ( !bOK ) - return Sys2SolarError_Impl( GetLastError() ); - - BigInt aBytesPerCluster( BigInt(nSectorsPerCluster) * - BigInt(nBytesPerSector) ); - rFreeBytes = aBytesPerCluster * BigInt(nFreeClusters); - rTotalBytes = aBytesPerCluster * BigInt(nClusters); - return 0; -} - -//========================================================================= - -void FSysEnableSysErrorBox( sal_Bool bEnable ) -{ // Preserve other Bits!! - sal_uInt32 nErrorMode = SetErrorMode( bEnable ? 0 : SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX ); - if ( bEnable ) - nErrorMode &= ~(SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX); - else - nErrorMode |= (SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX); - SetErrorMode( nErrorMode ); -} - - - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/tools/source/fsys/wntmsc.hxx b/tools/source/fsys/wntmsc.hxx index ba88e4eaf020..43b700fe17be 100644 --- a/tools/source/fsys/wntmsc.hxx +++ b/tools/source/fsys/wntmsc.hxx @@ -34,8 +34,8 @@ #ifndef ICC #include <io.h> #endif -#include <sys\types.h> -#include <sys\stat.h> +#include <sys/types.h> +#include <sys/stat.h> #include <direct.h> #include <windows.h> diff --git a/tools/source/generic/b3dtrans.cxx b/tools/source/generic/b3dtrans.cxx index 4af4b3edcb85..1f731e1fd387 100644 --- a/tools/source/generic/b3dtrans.cxx +++ b/tools/source/generic/b3dtrans.cxx @@ -182,16 +182,6 @@ void B3dTransformationSet::Reset() |* \************************************************************************/ -void B3dTransformationSet::SetObjectTrans(const basegfx::B3DHomMatrix& rObj) -{ - maObjectTrans = rObj; - - mbObjectToDeviceValid = sal_False; - mbInvTransObjectToEyeValid = sal_False; - - PostSetObjectTrans(); -} - void B3dTransformationSet::PostSetObjectTrans() { // Zuweisen und Inverse bestimmen @@ -217,17 +207,6 @@ void B3dTransformationSet::SetOrientation( basegfx::B3DPoint aVRP, basegfx::B3DV PostSetOrientation(); } -void B3dTransformationSet::SetOrientation(basegfx::B3DHomMatrix& mOrient) -{ - maOrientation = mOrient; - - mbInvTransObjectToEyeValid = sal_False; - mbObjectToDeviceValid = sal_False; - mbWorldToViewValid = sal_False; - - PostSetOrientation(); -} - void B3dTransformationSet::PostSetOrientation() { // Zuweisen und Inverse bestimmen @@ -254,13 +233,6 @@ const basegfx::B3DHomMatrix& B3dTransformationSet::GetProjection() return maProjection; } -const basegfx::B3DHomMatrix& B3dTransformationSet::GetInvProjection() -{ - if(!mbProjectionValid) - CalcViewport(); - return maInvProjection; -} - void B3dTransformationSet::PostSetProjection() { // Zuweisen und Inverse bestimmen @@ -274,22 +246,6 @@ void B3dTransformationSet::PostSetProjection() /************************************************************************* |* -|* Texturtransformation -|* -\************************************************************************/ - -void B3dTransformationSet::SetTexture(const basegfx::B2DHomMatrix& rTxt) -{ - maTexture = rTxt; - PostSetTexture(); -} - -void B3dTransformationSet::PostSetTexture() -{ -} - -/************************************************************************* -|* |* Viewport-Transformation |* \************************************************************************/ @@ -425,17 +381,6 @@ void B3dTransformationSet::SetRatio(double fNew) } } -void B3dTransformationSet::SetRatioMode(Base3DRatio eNew) -{ - if(meRatio != eNew) - { - meRatio = eNew; - mbProjectionValid = sal_False; - mbObjectToDeviceValid = sal_False; - mbWorldToViewValid = sal_False; - } -} - void B3dTransformationSet::SetDeviceRectangle(double fL, double fR, double fB, double fT, sal_Bool bBroadCastChange) { @@ -456,61 +401,10 @@ void B3dTransformationSet::SetDeviceRectangle(double fL, double fR, double fB, d } } -void B3dTransformationSet::SetDeviceVolume(const basegfx::B3DRange& rVol, sal_Bool bBroadCastChange) -{ - SetDeviceRectangle(rVol.getMinX(), rVol.getMaxX(), rVol.getMinY(), rVol.getMaxY(), bBroadCastChange); - SetFrontClippingPlane(rVol.getMinZ()); - SetBackClippingPlane(rVol.getMaxZ()); -} - void B3dTransformationSet::DeviceRectangleChange() { } -void B3dTransformationSet::GetDeviceRectangle(double &fL, double &fR, double& fB, double& fT) -{ - fL = mfLeftBound; - fR = mfRightBound; - fB = mfBottomBound; - fT = mfTopBound; - - mbProjectionValid = sal_False; - mbObjectToDeviceValid = sal_False; - mbWorldToViewValid = sal_False; -} - -basegfx::B3DRange B3dTransformationSet::GetDeviceVolume() -{ - basegfx::B3DRange aRet; - - aRet.expand(basegfx::B3DTuple(mfLeftBound, mfBottomBound, mfNearBound)); - aRet.expand(basegfx::B3DTuple(mfRightBound, mfTopBound, mfFarBound)); - - return aRet; -} - -void B3dTransformationSet::SetFrontClippingPlane(double fF) -{ - if(mfNearBound != fF) - { - mfNearBound = fF; - mbProjectionValid = sal_False; - mbObjectToDeviceValid = sal_False; - mbWorldToViewValid = sal_False; - } -} - -void B3dTransformationSet::SetBackClippingPlane(double fB) -{ - if(mfFarBound != fB) - { - mfFarBound = fB; - mbProjectionValid = sal_False; - mbObjectToDeviceValid = sal_False; - mbWorldToViewValid = sal_False; - } -} - void B3dTransformationSet::SetPerspective(sal_Bool bNew) { if(mbPerspective != bNew) @@ -539,13 +433,6 @@ void B3dTransformationSet::PostSetViewport() { } -const Rectangle& B3dTransformationSet::GetLogicalViewportBounds() -{ - if(!mbProjectionValid) - CalcViewport(); - return maSetBound; -} - const basegfx::B3DVector& B3dTransformationSet::GetScale() { if(!mbProjectionValid) @@ -577,13 +464,6 @@ void B3dTransformationSet::CalcMatObjectToDevice() mbObjectToDeviceValid = sal_True; } -const basegfx::B3DHomMatrix& B3dTransformationSet::GetObjectToDevice() -{ - if(!mbObjectToDeviceValid) - CalcMatObjectToDevice(); - return maObjectToDevice; -} - void B3dTransformationSet::CalcMatInvTransObjectToEye() { maInvTransObjectToEye = maObjectTrans; @@ -602,25 +482,6 @@ void B3dTransformationSet::CalcMatInvTransObjectToEye() mbInvTransObjectToEyeValid = sal_True; } -const basegfx::B3DHomMatrix& B3dTransformationSet::GetInvTransObjectToEye() -{ - if(!mbInvTransObjectToEyeValid) - CalcMatInvTransObjectToEye(); - return maInvTransObjectToEye; -} - -basegfx::B3DHomMatrix B3dTransformationSet::GetMatFromObjectToView() -{ - basegfx::B3DHomMatrix aFromObjectToView = GetObjectToDevice(); - - const basegfx::B3DVector& rScale(GetScale()); - aFromObjectToView.scale(rScale.getX(), rScale.getY(), rScale.getZ()); - const basegfx::B3DVector& rTranslate(GetTranslate()); - aFromObjectToView.translate(rTranslate.getX(), rTranslate.getY(), rTranslate.getZ()); - - return aFromObjectToView; -} - void B3dTransformationSet::CalcMatFromWorldToView() { maMatFromWorldToView = maOrientation; @@ -636,20 +497,6 @@ void B3dTransformationSet::CalcMatFromWorldToView() mbWorldToViewValid = sal_True; } -const basegfx::B3DHomMatrix& B3dTransformationSet::GetMatFromWorldToView() -{ - if(!mbWorldToViewValid) - CalcMatFromWorldToView(); - return maMatFromWorldToView; -} - -const basegfx::B3DHomMatrix& B3dTransformationSet::GetInvMatFromWorldToView() -{ - if(!mbWorldToViewValid) - CalcMatFromWorldToView(); - return maInvMatFromWorldToView; -} - /************************************************************************* |* |* Direkter Zugriff auf verschiedene Transformationen @@ -670,128 +517,6 @@ const basegfx::B3DPoint B3dTransformationSet::EyeToWorldCoor(const basegfx::B3DP return aVec; } -const basegfx::B3DPoint B3dTransformationSet::EyeToViewCoor(const basegfx::B3DPoint& rVec) -{ - basegfx::B3DPoint aVec(rVec); - aVec *= GetProjection(); - aVec *= GetScale(); - aVec += GetTranslate(); - return aVec; -} - -const basegfx::B3DPoint B3dTransformationSet::ViewToEyeCoor(const basegfx::B3DPoint& rVec) -{ - basegfx::B3DPoint aVec(rVec); - aVec -= GetTranslate(); - aVec = aVec / GetScale(); - aVec *= GetInvProjection(); - return aVec; -} - -const basegfx::B3DPoint B3dTransformationSet::WorldToViewCoor(const basegfx::B3DPoint& rVec) -{ - basegfx::B3DPoint aVec(rVec); - aVec *= GetMatFromWorldToView(); - return aVec; -} - -const basegfx::B3DPoint B3dTransformationSet::ViewToWorldCoor(const basegfx::B3DPoint& rVec) -{ - basegfx::B3DPoint aVec(rVec); - aVec *= GetInvMatFromWorldToView(); - return aVec; -} - -const basegfx::B3DPoint B3dTransformationSet::DeviceToViewCoor(const basegfx::B3DPoint& rVec) -{ - basegfx::B3DPoint aVec(rVec); - aVec *= GetScale(); - aVec += GetTranslate(); - return aVec; -} - -const basegfx::B3DPoint B3dTransformationSet::ViewToDeviceCoor(const basegfx::B3DPoint& rVec) -{ - basegfx::B3DPoint aVec(rVec); - aVec -= GetTranslate(); - aVec = aVec / GetScale(); - return aVec; -} - -const basegfx::B3DPoint B3dTransformationSet::ObjectToWorldCoor(const basegfx::B3DPoint& rVec) -{ - basegfx::B3DPoint aVec(rVec); - aVec *= GetObjectTrans(); - return aVec; -} - -const basegfx::B3DPoint B3dTransformationSet::WorldToObjectCoor(const basegfx::B3DPoint& rVec) -{ - basegfx::B3DPoint aVec(rVec); - aVec *= GetInvObjectTrans(); - return aVec; -} - -const basegfx::B3DPoint B3dTransformationSet::ObjectToViewCoor(const basegfx::B3DPoint& rVec) -{ - basegfx::B3DPoint aVec(rVec); - aVec *= GetObjectTrans(); - aVec *= GetMatFromWorldToView(); - return aVec; -} - -const basegfx::B3DPoint B3dTransformationSet::ViewToObjectCoor(const basegfx::B3DPoint& rVec) -{ - basegfx::B3DPoint aVec(rVec); - aVec *= GetInvMatFromWorldToView(); - aVec *= GetInvObjectTrans(); - return aVec; -} - -const basegfx::B3DPoint B3dTransformationSet::ObjectToEyeCoor(const basegfx::B3DPoint& rVec) -{ - basegfx::B3DPoint aVec(rVec); - aVec *= GetObjectTrans(); - aVec *= GetOrientation(); - return aVec; -} - -const basegfx::B3DPoint B3dTransformationSet::EyeToObjectCoor(const basegfx::B3DPoint& rVec) -{ - basegfx::B3DPoint aVec(rVec); - aVec *= GetInvOrientation(); - aVec *= GetInvObjectTrans(); - return aVec; -} - -const basegfx::B3DPoint B3dTransformationSet::DeviceToEyeCoor(const basegfx::B3DPoint& rVec) -{ - basegfx::B3DPoint aVec(rVec); - aVec *= GetInvProjection(); - return aVec; -} - -const basegfx::B3DPoint B3dTransformationSet::EyeToDeviceCoor(const basegfx::B3DPoint& rVec) -{ - basegfx::B3DPoint aVec(rVec); - aVec *= GetProjection(); - return aVec; -} - -const basegfx::B3DPoint B3dTransformationSet::InvTransObjectToEye(const basegfx::B3DPoint& rVec) -{ - basegfx::B3DPoint aVec(rVec); - aVec *= GetInvTransObjectToEye(); - return aVec; -} - -const basegfx::B2DPoint B3dTransformationSet::TransTextureCoor(const basegfx::B2DPoint& rVec) -{ - basegfx::B2DPoint aVec(rVec); - aVec *= GetTexture(); - return aVec; -} - /************************************************************************* |* |* Konstruktor B3dViewport @@ -811,18 +536,6 @@ B3dViewport::~B3dViewport() { } -void B3dViewport::SetVRP(const basegfx::B3DPoint& rNewVRP) -{ - aVRP = rNewVRP; - CalcOrientation(); -} - -void B3dViewport::SetVPN(const basegfx::B3DVector& rNewVPN) -{ - aVPN = rNewVPN; - CalcOrientation(); -} - void B3dViewport::SetVUV(const basegfx::B3DVector& rNewVUV) { aVUV = rNewVUV; @@ -869,81 +582,6 @@ B3dCamera::~B3dCamera() { } -void B3dCamera::SetPosition(const basegfx::B3DPoint& rNewPos) -{ - if(rNewPos != aPosition) - { - // Zuweisen - aCorrectedPosition = aPosition = rNewPos; - - // Neuberechnung - CalcNewViewportValues(); - } -} - -void B3dCamera::SetLookAt(const basegfx::B3DVector& rNewLookAt) -{ - if(rNewLookAt != aLookAt) - { - // Zuweisen - aLookAt = rNewLookAt; - - // Neuberechnung - CalcNewViewportValues(); - } -} - -void B3dCamera::SetPositionAndLookAt(const basegfx::B3DPoint& rNewPos, const basegfx::B3DVector& rNewLookAt) -{ - if(rNewPos != aPosition || rNewLookAt != aLookAt) - { - // Zuweisen - aPosition = rNewPos; - aLookAt = rNewLookAt; - - // Neuberechnung - CalcNewViewportValues(); - } -} - -void B3dCamera::SetFocalLength(double fLen) -{ - if(fLen != fFocalLength) - { - // Zuweisen - if(fLen < 5.0) - fLen = 5.0; - fFocalLength = fLen; - - // Neuberechnung - CalcNewViewportValues(); - } -} - -void B3dCamera::SetBankAngle(double fAngle) -{ - if(fAngle != fBankAngle) - { - // Zuweisen - fBankAngle = fAngle; - - // Neuberechnung - CalcNewViewportValues(); - } -} - -void B3dCamera::SetUseFocalLength(sal_Bool bNew) -{ - if(bNew != (sal_Bool)bUseFocalLength) - { - // Zuweisen - bUseFocalLength = bNew; - - // Neuberechnung - CalcNewViewportValues(); - } -} - void B3dCamera::DeviceRectangleChange() { // call parent diff --git a/tools/source/generic/bigint.cxx b/tools/source/generic/bigint.cxx index 4392e56d5e44..2312f3c5eeaf 100644 --- a/tools/source/generic/bigint.cxx +++ b/tools/source/generic/bigint.cxx @@ -855,75 +855,6 @@ BigInt& BigInt::operator/=( const BigInt& rVal ) // ----------------------------------------------------------------------- -void BigInt::DivMod( const BigInt& rVal, BigInt& rMod ) -{ - if ( !rVal.bIsBig ) - { - if ( rVal.nVal == 0 ) - { - OSL_FAIL( "BigInt::operator/ --> divide by zero" ); - return; - } - - if ( !bIsBig ) - { - // wir bewegen uns im ungefaehrlichem Bereich - rMod = BigInt( nVal % rVal.nVal ); - nVal /= rVal.nVal; - return; - } - - if ( rVal.nVal == 1 ) - { - rMod = BigInt( (long)0 ); - return; - } - - if ( rVal.nVal == -1 ) - { - rMod = BigInt( (long)0 ); - bIsNeg = !bIsNeg; - return; - } - - if ( rVal.nVal <= (long)0xFFFF && rVal.nVal >= -(long)0xFFFF ) - { - // ein BigInt durch ein sal_uInt16 teilen - sal_uInt16 nTmp; - if ( rVal.nVal < 0 ) - { - nTmp = (sal_uInt16) -rVal.nVal; - bIsNeg = !bIsNeg; - } - else - nTmp = (sal_uInt16) rVal.nVal; - - Div( nTmp, nTmp ); - rMod = BigInt( (long)nTmp ); - Normalize(); - return; - } - } - - if ( ABS_IsLess( rVal ) ) - { - rMod = *this; - *this = BigInt( (long)0 ); - return; - } - - // BigInt durch BigInt teilen - BigInt aTmp1, aTmp2; - aTmp1.MakeBigInt( *this ); - aTmp2.MakeBigInt( rVal ); - aTmp1.DivLong(aTmp2, *this); - Normalize(); - aTmp1.ModLong(aTmp2, rMod); // nicht optimal - rMod.Normalize(); -} - -// ----------------------------------------------------------------------- - BigInt& BigInt::operator%=( const BigInt& rVal ) { if ( !rVal.bIsBig ) diff --git a/tools/source/generic/config.cxx b/tools/source/generic/config.cxx index 6c533459f2a7..2075bf49e300 100644 --- a/tools/source/generic/config.cxx +++ b/tools/source/generic/config.cxx @@ -45,6 +45,7 @@ #include <tools/debug.hxx> #include <tools/config.hxx> #include <osl/security.h> +#include <rtl/strbuf.hxx> #define MAXBUFLEN 1024 // Fuer Buffer bei VOS-Funktionen @@ -1188,13 +1189,15 @@ sal_uInt16 Config::GetKeyCount() const ByteString Config::GetKeyName( sal_uInt16 nKey ) const { #ifdef DBG_UTIL - ByteString aTraceStr( "Config::GetKeyName( " ); - aTraceStr += ByteString::CreateFromInt32(nKey); - aTraceStr += " ) from "; - aTraceStr += GetGroup(); - aTraceStr += " in "; - aTraceStr += ByteString( maFileName, RTL_TEXTENCODING_UTF8 ); - OSL_TRACE( "%s", aTraceStr.GetBuffer() ); + rtl::OStringBuffer aTraceStr( + RTL_CONSTASCII_STRINGPARAM("Config::GetKeyName( ")); + aTraceStr.append(static_cast<sal_Int32>(nKey)); + aTraceStr.append(RTL_CONSTASCII_STRINGPARAM(" ) from ")); + aTraceStr.append(GetGroup()); + aTraceStr.append(RTL_CONSTASCII_STRINGPARAM(" in ")); + aTraceStr.append(rtl::OUStringToOString( + maFileName, RTL_TEXTENCODING_UTF8)); + OSL_TRACE("%s", aTraceStr.getStr()); #endif // Key suchen und Name zurueckgeben @@ -1223,13 +1226,15 @@ ByteString Config::GetKeyName( sal_uInt16 nKey ) const ByteString Config::ReadKey( sal_uInt16 nKey ) const { #ifdef DBG_UTIL - ByteString aTraceStr( "Config::ReadKey( " ); - aTraceStr += ByteString::CreateFromInt32( nKey ); - aTraceStr += " ) from "; - aTraceStr += GetGroup(); - aTraceStr += " in "; - aTraceStr += ByteString( maFileName, RTL_TEXTENCODING_UTF8 ); - OSL_TRACE( "%s", aTraceStr.GetBuffer() ); + rtl::OStringBuffer aTraceStr( + RTL_CONSTASCII_STRINGPARAM("Config::ReadKey( ")); + aTraceStr.append(static_cast<sal_Int32>(nKey)); + aTraceStr.append(RTL_CONSTASCII_STRINGPARAM(" ) from ")); + aTraceStr.append(GetGroup()); + aTraceStr.append(RTL_CONSTASCII_STRINGPARAM(" in ")); + aTraceStr.append(rtl::OUStringToOString(maFileName, + RTL_TEXTENCODING_UTF8)); + OSL_TRACE("%s", aTraceStr.getStr()); #endif // Key suchen und Value zurueckgeben diff --git a/tools/source/inet/inetmime.cxx b/tools/source/inet/inetmime.cxx index 78032e7d376e..d1178f29253e 100644 --- a/tools/source/inet/inetmime.cxx +++ b/tools/source/inet/inetmime.cxx @@ -492,18 +492,6 @@ bool INetMIME::isIMAPAtomChar(sal_uInt32 nChar) //============================================================================ // static -sal_uInt32 INetMIME::getDigit(int nWeight) -{ - DBG_ASSERT(nWeight >= 0 && nWeight < 10, - "INetMIME::getDigit(): Bad weight"); - - static const sal_Char aDigits[16] - = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }; - return aDigits[nWeight]; -} - -//============================================================================ -// static sal_uInt32 INetMIME::getHexDigit(int nWeight) { DBG_ASSERT(nWeight >= 0 && nWeight < 16, @@ -517,40 +505,6 @@ sal_uInt32 INetMIME::getHexDigit(int nWeight) //============================================================================ // static -sal_uInt32 INetMIME::getBase64Digit(int nWeight) -{ - DBG_ASSERT(nWeight >= 0 && nWeight < 64, - "INetMIME::getBase64Digit(): Bad weight"); - - static const sal_Char aDigits[64] - = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', - 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', - 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/' }; - return aDigits[nWeight]; -} - -//============================================================================ -// static -bool INetMIME::equalIgnoreCase(const sal_Char * pBegin1, - const sal_Char * pEnd1, - const sal_Char * pBegin2, - const sal_Char * pEnd2) -{ - DBG_ASSERT(pBegin1 && pBegin1 <= pEnd1 && pBegin2 && pBegin2 <= pEnd2, - "INetMIME::equalIgnoreCase(): Bad sequences"); - - if (pEnd1 - pBegin1 != pEnd2 - pBegin2) - return false; - while (pBegin1 != pEnd1) - if (toUpperCase(*pBegin1++) != toUpperCase(*pBegin2++)) - return false; - return true; -} - -//============================================================================ -// static bool INetMIME::equalIgnoreCase(const sal_Char * pBegin1, const sal_Char * pEnd1, const sal_Char * pString2) @@ -583,35 +537,6 @@ bool INetMIME::equalIgnoreCase(const sal_Unicode * pBegin1, //============================================================================ // static -const sal_Char * INetMIME::skipLinearWhiteSpace(const sal_Char * pBegin, - const sal_Char * pEnd) -{ - DBG_ASSERT(pBegin && pBegin <= pEnd, - "INetMIME::skipLinearWhiteSpace(): Bad sequence"); - - while (pBegin != pEnd) - switch (*pBegin) - { - case '\t': - case ' ': - ++pBegin; - break; - - case 0x0D: // CR - if (startsWithLineFolding(pBegin, pEnd)) - pBegin += 3; - else - return pBegin; - break; - - default: - return pBegin; - } - return pBegin; -} - -//============================================================================ -// static const sal_Unicode * INetMIME::skipLinearWhiteSpace(const sal_Unicode * pBegin, const sal_Unicode * pEnd) { @@ -842,26 +767,6 @@ const sal_Unicode * INetMIME::skipQuotedString(const sal_Unicode * pBegin, //============================================================================ // static -const sal_Char * INetMIME::scanAtom(const sal_Char * pBegin, - const sal_Char * pEnd) -{ - while (pBegin != pEnd && isAtomChar(*pBegin)) - ++pBegin; - return pBegin; -} - -//============================================================================ -// static -const sal_Unicode * INetMIME::scanAtom(const sal_Unicode * pBegin, - const sal_Unicode * pEnd) -{ - while (pBegin != pEnd && isAtomChar(*pBegin)) - ++pBegin; - return pBegin; -} - -//============================================================================ -// static bool INetMIME::scanUnsigned(const sal_Char *& rBegin, const sal_Char * pEnd, bool bLeadingZeroes, sal_uInt32 & rValue) { @@ -909,127 +814,6 @@ bool INetMIME::scanUnsigned(const sal_Unicode *& rBegin, //============================================================================ // static -bool INetMIME::scanUnsignedHex(const sal_Char *& rBegin, - const sal_Char * pEnd, bool bLeadingZeroes, - sal_uInt32 & rValue) -{ - sal_uInt64 nTheValue = 0; - const sal_Char * p = rBegin; - for ( p = rBegin; p != pEnd; ++p) - { - int nWeight = getHexWeight(*p); - if (nWeight < 0) - break; - nTheValue = nTheValue << 4 | nWeight; - if (nTheValue > std::numeric_limits< sal_uInt32 >::max()) - return false; - } - if (nTheValue == 0 && (p == rBegin || (!bLeadingZeroes && p - rBegin != 1))) - return false; - rBegin = p; - rValue = sal_uInt32(nTheValue); - return true; -} - -//============================================================================ -// static -bool INetMIME::scanUnsignedHex(const sal_Unicode *& rBegin, - const sal_Unicode * pEnd, bool bLeadingZeroes, - sal_uInt32 & rValue) -{ - sal_uInt64 nTheValue = 0; - const sal_Unicode * p = rBegin; - for ( ; p != pEnd; ++p) - { - int nWeight = getHexWeight(*p); - if (nWeight < 0) - break; - nTheValue = nTheValue << 4 | nWeight; - if (nTheValue > std::numeric_limits< sal_uInt32 >::max()) - return false; - } - if (nTheValue == 0 && (p == rBegin || (!bLeadingZeroes && p - rBegin != 1))) - return false; - rBegin = p; - rValue = sal_uInt32(nTheValue); - return true; -} - -//============================================================================ -// static -const sal_Char * INetMIME::scanQuotedBlock(const sal_Char * pBegin, - const sal_Char * pEnd, - sal_uInt32 nOpening, - sal_uInt32 nClosing, - sal_Size & rLength, - bool & rModify) -{ - DBG_ASSERT(pBegin && pBegin <= pEnd, - "INetMIME::scanQuotedBlock(): Bad sequence"); - - if (pBegin != pEnd && static_cast< unsigned char >(*pBegin) == nOpening) - { - ++rLength; - ++pBegin; - while (pBegin != pEnd) - if (static_cast< unsigned char >(*pBegin) == nClosing) - { - ++rLength; - return ++pBegin; - } - else - { - sal_uInt32 c = *pBegin++; - switch (c) - { - case 0x0D: // CR - if (pBegin != pEnd && *pBegin == 0x0A) // LF - if (pEnd - pBegin >= 2 && isWhiteSpace(pBegin[1])) - { - ++rLength; - rModify = true; - pBegin += 2; - } - else - { - rLength += 3; - rModify = true; - ++pBegin; - } - else - ++rLength; - break; - - case '\\': - ++rLength; - if (pBegin != pEnd) - { - if (startsWithLineBreak(pBegin, pEnd) - && (pEnd - pBegin < 3 - || !isWhiteSpace(pBegin[2]))) - { - rLength += 3; - rModify = true; - pBegin += 2; - } - else - ++pBegin; - } - break; - - default: - ++rLength; - if (!isUSASCII(c)) - rModify = true; - break; - } - } - } - return pBegin; -} - -//============================================================================ -// static const sal_Unicode * INetMIME::scanQuotedBlock(const sal_Unicode * pBegin, const sal_Unicode * pEnd, sal_uInt32 nOpening, @@ -1767,14 +1551,6 @@ rtl_TextEncoding INetMIME::getCharsetEncoding(sal_Char const * pBegin, //============================================================================ // static -rtl_TextEncoding INetMIME::getCharsetEncoding(sal_Unicode const * pBegin, - sal_Unicode const * pEnd) -{ - return getCharsetEncoding_Impl(pBegin, pEnd); -} - -//============================================================================ -// static INetMIMECharsetList_Impl * INetMIME::createPreferredCharsetList(rtl_TextEncoding eEncoding) { @@ -2170,80 +1946,6 @@ void INetMIME::writeUTF8(INetMIMEOutputSink & rSink, sal_uInt32 nChar) //============================================================================ // static -void INetMIME::writeUnsigned(INetMIMEOutputSink & rSink, sal_uInt32 nValue, - int nMinDigits) -{ - sal_Char aBuffer[10]; - // max unsigned 32 bit value (4294967295) has 10 places - sal_Char * p = aBuffer; - for (; nValue > 0; nValue /= 10) - *p++ = sal_Char(getDigit(nValue % 10)); - nMinDigits -= p - aBuffer; - while (nMinDigits-- > 0) - rSink << '0'; - while (p != aBuffer) - rSink << *--p; -} - -//============================================================================ -// static -void INetMIME::writeDateTime(INetMIMEOutputSink & rSink, - const DateTime & rUTC) -{ - static const sal_Char aDay[7][3] - = { { 'M', 'o', 'n' }, - { 'T', 'u', 'e' }, - { 'W', 'e', 'd' }, - { 'T', 'h', 'u' }, - { 'F', 'r', 'i' }, - { 'S', 'a', 't' }, - { 'S', 'u', 'n' } }; - const sal_Char * pTheDay = aDay[rUTC.GetDayOfWeek()]; - rSink.write(pTheDay, pTheDay + 3); - rSink << ", "; - writeUnsigned(rSink, rUTC.GetDay()); - rSink << ' '; - static const sal_Char aMonth[12][3] - = { { 'J', 'a', 'n' }, - { 'F', 'e', 'b' }, - { 'M', 'a', 'r' }, - { 'A', 'p', 'r' }, - { 'M', 'a', 'y' }, - { 'J', 'u', 'n' }, - { 'J', 'u', 'l' }, - { 'A', 'u', 'g' }, - { 'S', 'e', 'p' }, - { 'O', 'c', 't' }, - { 'N', 'o', 'v' }, - { 'D', 'e', 'c' } }; - const sal_Char * pTheMonth = aMonth[rUTC.GetMonth() - 1]; - rSink.write(pTheMonth, pTheMonth + 3); - rSink << ' '; - writeUnsigned(rSink, rUTC.GetYear()); - rSink << ' '; - writeUnsigned(rSink, rUTC.GetHour(), 2); - rSink << ':'; - writeUnsigned(rSink, rUTC.GetMin(), 2); - rSink << ':'; - writeUnsigned(rSink, rUTC.GetSec(), 2); - rSink << " +0000"; -} - -//============================================================================ -// static -void INetMIME::writeHeaderFieldBody(INetMIMEOutputSink & rSink, - HeaderFieldType eType, - const ByteString & rBody, - rtl_TextEncoding ePreferredEncoding, - bool bInitialSpace) -{ - writeHeaderFieldBody(rSink, eType, - UniString(rBody, RTL_TEXTENCODING_UTF8), - ePreferredEncoding, bInitialSpace); -} - -//============================================================================ -// static void INetMIME::writeHeaderFieldBody(INetMIMEOutputSink & rSink, HeaderFieldType eType, const UniString & rBody, diff --git a/tools/source/inet/inetmsg.cxx b/tools/source/inet/inetmsg.cxx index 2fc9f5fcb8e3..1645e9ba7aea 100644 --- a/tools/source/inet/inetmsg.cxx +++ b/tools/source/inet/inetmsg.cxx @@ -34,6 +34,7 @@ #include <tools/inetmsg.hxx> #include <tools/inetstrm.hxx> #include <rtl/instance.hxx> +#include <rtl/strbuf.hxx> #include <stdio.h> @@ -63,7 +64,6 @@ inline sal_Unicode ascii_toLowerCase( sal_Unicode ch ) * *=====================================================================*/ #define CONSTASCII_STRINGPARAM(a) (a), RTL_TEXTENCODING_ASCII_US -#define HEADERFIELD INetMessageHeader /* * ~INetMessage. @@ -79,10 +79,10 @@ INetMessage::~INetMessage (void) void INetMessage::ListCleanup_Impl (void) { // Cleanup. - sal_uIntPtr i, n = m_aHeaderList.Count(); + sal_uIntPtr i, n = m_aHeaderList.size(); for (i = 0; i < n; i++) - delete ((HEADERFIELD*)(m_aHeaderList.GetObject(i))); - m_aHeaderList.Clear(); + delete m_aHeaderList[ i ]; + m_aHeaderList.clear(); } /* @@ -99,8 +99,8 @@ void INetMessage::ListCopy (const INetMessage &rMsg) sal_uIntPtr i, n = rMsg.GetHeaderCount(); for (i = 0; i < n; i++) { - HEADERFIELD *p = (HEADERFIELD*)(rMsg.m_aHeaderList.GetObject(i)); - m_aHeaderList.Insert (new HEADERFIELD(*p), LIST_APPEND); + INetMessageHeader *p = rMsg.m_aHeaderList[ i ]; + m_aHeaderList.push_back( new INetMessageHeader(*p) ); } } } @@ -125,20 +125,6 @@ void INetMessage::SetHeaderField_Impl ( * SetHeaderField. */ sal_uIntPtr INetMessage::SetHeaderField ( - const UniString& rName, const UniString& rValue, sal_uIntPtr nIndex) -{ - sal_uIntPtr nResult = nIndex; - SetHeaderField_Impl ( - INetMIME::HEADER_FIELD_TEXT, - ByteString (rName, RTL_TEXTENCODING_ASCII_US), rValue, - nResult); - return nResult; -} - -/* - * SetHeaderField. - */ -sal_uIntPtr INetMessage::SetHeaderField ( const INetMessageHeader &rHeader, sal_uIntPtr nIndex) { sal_uIntPtr nResult = nIndex; @@ -155,11 +141,11 @@ SvStream& INetMessage::operator<< (SvStream& rStrm) const rStrm << static_cast<sal_uInt32>(m_nDocSize); rStrm.WriteByteString (m_aDocName, RTL_TEXTENCODING_UTF8); - sal_uIntPtr i, n = m_aHeaderList.Count(); + sal_uIntPtr i, n = m_aHeaderList.size(); rStrm << static_cast<sal_uInt32>(n); for (i = 0; i < n; i++) - rStrm << *((HEADERFIELD *)(m_aHeaderList.GetObject(i))); + rStrm << *( m_aHeaderList[ i ] ); return rStrm; } @@ -187,9 +173,9 @@ SvStream& INetMessage::operator>> (SvStream& rStrm) for (i = 0; i < n; i++) { - HEADERFIELD *p = new HEADERFIELD(); + INetMessageHeader *p = new INetMessageHeader(); rStrm >> *p; - m_aHeaderList.Insert (p, LIST_APPEND); + m_aHeaderList.push_back( p ); } // Done. @@ -198,34 +184,6 @@ SvStream& INetMessage::operator>> (SvStream& rStrm) /*======================================================================= * - * INetMessageHeaderIterator Implementation. - * - *=====================================================================*/ -INetMessageHeaderIterator::INetMessageHeaderIterator ( - const INetMessage& rMsg, const UniString& rHdrName) -{ - sal_uIntPtr i, n = rMsg.GetHeaderCount(); - for (i = 0; i < n; i++) - { - if (rHdrName.CompareIgnoreCaseToAscii (rMsg.GetHeaderName(i)) == 0) - { - UniString *pValue = new UniString (rMsg.GetHeaderValue(i)); - aValueList.Insert (pValue, LIST_APPEND); - } - } - nValueCount = aValueList.Count(); -} - -INetMessageHeaderIterator::~INetMessageHeaderIterator (void) -{ - sal_uIntPtr i, n = aValueList.Count(); - for (i = 0; i < n; i++) - delete ((UniString*)(aValueList.GetObject(i))); - aValueList.Clear(); -} - -/*======================================================================= - * * INetRFC822Message Implementation. * *=====================================================================*/ @@ -324,13 +282,8 @@ INetRFC822Message::~INetRFC822Message (void) } /* - * <Generate|Parse>DateField and local helper functions. - * - * GenerateDateField. - * Generates a String from Date and Time objects in format: - * Wkd, 00 Mon 0000 00:00:00 [GMT] (rfc822, rfc1123) + * ParseDateField and local helper functions. * - * ParseDateField. * Parses a String in (implied) GMT format into class Date and Time objects. * Four formats are accepted: * @@ -349,62 +302,6 @@ static const sal_Char *months[12] = "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; -static const sal_Char *wkdays[7] = -{ - "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" -}; - -/* - * GenerateDateField. - */ -sal_Bool INetRFC822Message::GenerateDateField ( - const DateTime& rDateTime, UniString& rDateFieldW) -{ - // Check arguments. - if (!rDateTime.IsValid() || - (rDateTime.GetSec() > 59) || - (rDateTime.GetMin() > 59) || - (rDateTime.GetHour() > 23) ) return sal_False; - - // Prepare output string. - ByteString rDateField; - - // Insert Date. - rDateField += wkdays[(sal_uInt16)(rDateTime.GetDayOfWeek())]; - rDateField += ", "; - - sal_uInt16 nNum = rDateTime.GetDay(); - if (nNum < 10) rDateField += '0'; - rDateField += ByteString::CreateFromInt32(nNum); - rDateField += ' '; - - rDateField += months[(sal_uInt16)(rDateTime.GetMonth() - 1)]; - rDateField += ' '; - - rDateField += ByteString::CreateFromInt32(rDateTime.GetYear()); - rDateField += ' '; - - // Insert Time. - nNum = rDateTime.GetHour(); - if (nNum < 10) rDateField += '0'; - rDateField += ByteString::CreateFromInt32(nNum); - rDateField += ':'; - - nNum = rDateTime.GetMin(); - if (nNum < 10) rDateField += '0'; - rDateField += ByteString::CreateFromInt32(nNum); - rDateField += ':'; - - nNum = rDateTime.GetSec(); - if (nNum < 10) rDateField += '0'; - rDateField += ByteString::CreateFromInt32(nNum); - rDateField += " GMT"; - - // Done. - rDateFieldW = UniString (rDateField, RTL_TEXTENCODING_ASCII_US); - return sal_True; -} - /* * ParseDateField and local helper functions. */ @@ -761,7 +658,7 @@ sal_uIntPtr INetRFC822Message::SetHeaderField ( case INETMSG_RFC822_OK: pData = pStop; SetHeaderField_Impl ( - HEADERFIELD (HDR(nIdx), rHeader.GetValue()), + INetMessageHeader (HDR(nIdx), rHeader.GetValue()), m_nIndex[nIdx]); nNewIndex = m_nIndex[nIdx]; break; @@ -776,129 +673,6 @@ sal_uIntPtr INetRFC822Message::SetHeaderField ( } /* - * Specific Set-Methods. - */ -void INetRFC822Message::SetBCC (const UniString& rBCC) -{ - SetHeaderField_Impl ( - INetMIME::HEADER_FIELD_ADDRESS, - HDR(INETMSG_RFC822_BCC), rBCC, - m_nIndex[INETMSG_RFC822_BCC]); -} - -void INetRFC822Message::SetCC (const UniString& rCC) -{ - SetHeaderField_Impl ( - INetMIME::HEADER_FIELD_ADDRESS, - HDR(INETMSG_RFC822_CC), rCC, - m_nIndex[INETMSG_RFC822_CC]); -} - -void INetRFC822Message::SetComments (const UniString& rComments) -{ - SetHeaderField_Impl ( - INetMIME::HEADER_FIELD_TEXT, - HDR(INETMSG_RFC822_COMMENTS), rComments, - m_nIndex[INETMSG_RFC822_COMMENTS]); -} - -void INetRFC822Message::SetDate (const UniString& rDate) -{ - SetHeaderField_Impl ( - INetMIME::HEADER_FIELD_STRUCTURED, - HDR(INETMSG_RFC822_DATE), rDate, - m_nIndex[INETMSG_RFC822_DATE]); -} - -void INetRFC822Message::SetFrom (const UniString& rFrom) -{ - SetHeaderField_Impl ( - INetMIME::HEADER_FIELD_ADDRESS, - HDR(INETMSG_RFC822_FROM), rFrom, - m_nIndex[INETMSG_RFC822_FROM]); -} - -void INetRFC822Message::SetInReplyTo (const UniString& rInReplyTo) -{ - SetHeaderField_Impl ( - INetMIME::HEADER_FIELD_ADDRESS, // ??? MESSAGE_ID ??? - HDR(INETMSG_RFC822_IN_REPLY_TO), rInReplyTo, - m_nIndex[INETMSG_RFC822_IN_REPLY_TO]); -} - -void INetRFC822Message::SetKeywords (const UniString& rKeywords) -{ - SetHeaderField_Impl ( - INetMIME::HEADER_FIELD_PHRASE, - HDR(INETMSG_RFC822_KEYWORDS), rKeywords, - m_nIndex[INETMSG_RFC822_KEYWORDS]); -} - -void INetRFC822Message::SetMessageID (const UniString& rMessageID) -{ - SetHeaderField_Impl ( - INetMIME::HEADER_FIELD_MESSAGE_ID, - HDR(INETMSG_RFC822_MESSAGE_ID), rMessageID, - m_nIndex[INETMSG_RFC822_MESSAGE_ID]); -} - -void INetRFC822Message::SetReferences (const UniString& rReferences) -{ - SetHeaderField_Impl ( - INetMIME::HEADER_FIELD_MESSAGE_ID, - HDR(INETMSG_RFC822_REFERENCES), rReferences, - m_nIndex[INETMSG_RFC822_REFERENCES]); -} - -void INetRFC822Message::SetReplyTo (const UniString& rReplyTo) -{ - SetHeaderField_Impl ( - INetMIME::HEADER_FIELD_ADDRESS, - HDR(INETMSG_RFC822_REPLY_TO), rReplyTo, - m_nIndex[INETMSG_RFC822_REPLY_TO]); -} - -void INetRFC822Message::SetReturnPath (const UniString& rReturnPath) -{ - SetHeaderField_Impl ( - INetMIME::HEADER_FIELD_ADDRESS, - HDR(INETMSG_RFC822_RETURN_PATH), rReturnPath, - m_nIndex[INETMSG_RFC822_RETURN_PATH]); -} - -void INetRFC822Message::SetReturnReceiptTo (const UniString& rValue) -{ - SetHeaderField_Impl ( - INetMIME::HEADER_FIELD_ADDRESS, - HDR(INETMSG_RFC822_RETURN_RECEIPT_TO), rValue, - m_nIndex[INETMSG_RFC822_RETURN_RECEIPT_TO]); -} - -void INetRFC822Message::SetSender (const UniString& rSender) -{ - SetHeaderField_Impl ( - INetMIME::HEADER_FIELD_ADDRESS, - HDR(INETMSG_RFC822_SENDER), rSender, - m_nIndex[INETMSG_RFC822_SENDER]); -} - -void INetRFC822Message::SetSubject (const UniString& rSubject) -{ - SetHeaderField_Impl ( - INetMIME::HEADER_FIELD_TEXT, - HDR(INETMSG_RFC822_SUBJECT), rSubject, - m_nIndex[INETMSG_RFC822_SUBJECT]); -} - -void INetRFC822Message::SetTo (const UniString& rTo) -{ - SetHeaderField_Impl ( - INetMIME::HEADER_FIELD_ADDRESS, - HDR(INETMSG_RFC822_TO), rTo, - m_nIndex[INETMSG_RFC822_TO]); -} - -/* * operator<< */ SvStream& INetRFC822Message::operator<< (SvStream& rStrm) const @@ -982,7 +756,6 @@ enum _ImplINetMIMEMessageHeaderState INetMIMEMessage::INetMIMEMessage (void) : INetRFC822Message (), pParent (NULL), - nNumChildren (0), bHeaderParsed (sal_False) { for (sal_uInt16 i = 0; i < INETMSG_MIME_NUMHDR; i++) @@ -1030,9 +803,10 @@ INetMIMEMessage::~INetMIMEMessage (void) */ void INetMIMEMessage::CleanupImp (void) { - INetMIMEMessage *pChild = NULL; - while ((pChild = (INetMIMEMessage *)(aChildren.Remove())) != NULL) - if (pChild->pParent == this) delete pChild; + for( size_t i = 0, n = aChildren.size(); i < n; ++i ) { + delete aChildren[ i ]; + } + aChildren.clear(); } /* @@ -1042,24 +816,22 @@ void INetMIMEMessage::CopyImp (const INetMIMEMessage& rMsg) { bHeaderParsed = rMsg.bHeaderParsed; - sal_uInt16 i; + size_t i; for (i = 0; i < INETMSG_MIME_NUMHDR; i++) m_nIndex[i] = rMsg.m_nIndex[i]; m_aBoundary = rMsg.m_aBoundary; - nNumChildren = rMsg.nNumChildren; - for (i = 0; i < rMsg.aChildren.Count(); i++) + for (i = 0; i < rMsg.aChildren.size(); i++) { - INetMIMEMessage *pChild = - (INetMIMEMessage *)(rMsg.aChildren.GetObject (i)); + INetMIMEMessage *pChild = rMsg.aChildren[ i ]; if (pChild->pParent == &rMsg) { pChild = pChild->CreateMessage (*pChild); pChild->pParent = this; } - aChildren.Insert (pChild, LIST_APPEND); + aChildren.push_back( pChild ); } } @@ -1207,7 +979,7 @@ sal_uIntPtr INetMIMEMessage::SetHeaderField ( case INETMSG_MIME_OK: pData = pStop; SetHeaderField_Impl ( - HEADERFIELD (MIMEHDR(nIdx), rHeader.GetValue()), + INetMessageHeader (MIMEHDR(nIdx), rHeader.GetValue()), m_nIndex[nIdx]); nNewIndex = m_nIndex[nIdx]; break; @@ -1233,14 +1005,6 @@ void INetMIMEMessage::SetMIMEVersion (const UniString& rVersion) m_nIndex[INETMSG_MIME_VERSION]); } -void INetMIMEMessage::SetContentDescription (const String& rDescription) -{ - SetHeaderField_Impl ( - INetMIME::HEADER_FIELD_TEXT, - MIMEHDR(INETMSG_MIME_CONTENT_DESCRIPTION), rDescription, - m_nIndex[INETMSG_MIME_CONTENT_DESCRIPTION]); -} - void INetMIMEMessage::SetContentDisposition (const String& rDisposition) { SetHeaderField_Impl ( @@ -1249,14 +1013,6 @@ void INetMIMEMessage::SetContentDisposition (const String& rDisposition) m_nIndex[INETMSG_MIME_CONTENT_DISPOSITION]); } -void INetMIMEMessage::SetContentID (const String& rID) -{ - SetHeaderField_Impl ( - INetMIME::HEADER_FIELD_TEXT, - MIMEHDR(INETMSG_MIME_CONTENT_ID), rID, - m_nIndex[INETMSG_MIME_CONTENT_ID]); -} - void INetMIMEMessage::SetContentType (const String& rType) { SetHeaderField_Impl ( @@ -1388,202 +1144,8 @@ sal_Bool INetMIMEMessage::AttachChild ( if (IsContainer() /*&& rChildMsg.GetContentType().Len() */) { if (bOwner) rChildMsg.pParent = this; - aChildren.Insert (&rChildMsg, LIST_APPEND); - nNumChildren = aChildren.Count(); - - return sal_True; - } - return sal_False; -} - -/* - * DetachChild. - */ -sal_Bool INetMIMEMessage::DetachChild ( - sal_uIntPtr nIndex, INetMIMEMessage& rChildMsg) const -{ - if (IsContainer()) - { - // Check document stream. - if (GetDocumentLB() == NULL) return sal_False; - SvStream *pDocStrm = new SvStream (GetDocumentLB()); - - // Initialize message buffer. - char pMsgBuffer[1024]; - char *pMsgRead, *pMsgWrite; - pMsgRead = pMsgWrite = pMsgBuffer; - - // Initialize message parser stream. - INetMIMEMessageStream *pMsgStrm = NULL; - - // Check for "multipart/uvw" or "message/xyz". - if (IsMultipart()) - { - // Multipart message body. Initialize multipart delimiters. - ByteString aDelim ("--"); - aDelim += GetMultipartBoundary(); - ByteString aClose = aDelim; - aClose += "--"; - - // Initialize line buffer. - SvMemoryStream aLineBuf; - - // Initialize control variables. - INetMessageStreamState eState = INETMSG_EOL_SCR; - int nCurIndex = -1; - - // Go! - while (nCurIndex < (int)(nIndex + 1)) - { - if ((pMsgRead - pMsgWrite) > 0) - { - // Bytes still in buffer. - if (eState == INETMSG_EOL_FCR) - { - // Check for 2nd line break character. - if ((*pMsgWrite == '\r') || (*pMsgWrite == '\n')) - aLineBuf << *pMsgWrite++; - - // Check current index. - if (nCurIndex == (int)nIndex) - { - // Found requested part. - if (pMsgStrm == NULL) - { - // Create message parser stream. - pMsgStrm = new INetMIMEMessageStream; - pMsgStrm->SetTargetMessage (&rChildMsg); - } - - // Put message down-stream. - int status = pMsgStrm->Write ( - (const sal_Char *) aLineBuf.GetData(), aLineBuf.Tell()); - if (status != INETSTREAM_STATUS_OK) - { - // Cleanup. - delete pDocStrm; - delete pMsgStrm; - - // Finish. - return (!(status == INETSTREAM_STATUS_OK)); - } - } - - // Reset to <Begin-of-Line>. - aLineBuf.Seek (STREAM_SEEK_TO_BEGIN); - eState = INETMSG_EOL_SCR; - } - else if ((*pMsgWrite == '\r') || (*pMsgWrite == '\n')) - { - /* - * Found any line break character. - * Compare buffered line with part/close delimiter. - * Increment current part index upon match. - */ - sal_uInt16 nLen = (sal_uInt16)(aLineBuf.Tell() & 0xffff); - if (nLen == aDelim.Len()) - { - if (aDelim.CompareTo ((const sal_Char *) aLineBuf.GetData(), nLen) - == COMPARE_EQUAL) nCurIndex++; - } - else if (nLen == aClose.Len()) - { - if (aClose.CompareTo ((const sal_Char *) aLineBuf.GetData(), nLen) - == COMPARE_EQUAL) nCurIndex++; - } - aLineBuf << *pMsgWrite++; - eState = INETMSG_EOL_FCR; - } - else - { - // Insert into line buffer. - aLineBuf << *pMsgWrite; - } - } - else - { - // Buffer empty. Reset to <Begin-of-Buffer>. - pMsgRead = pMsgWrite = pMsgBuffer; - - // Read document stream. - sal_uIntPtr nRead = pDocStrm->Read ( - pMsgBuffer, sizeof (pMsgBuffer)); - if (nRead > 0) - { - // Set read pointer. - pMsgRead += nRead; - } - else - { - // Premature end. - if (pMsgStrm) - { - // Assume end of requested part. - nCurIndex++; - } - else - { - // Requested part not found. - delete pDocStrm; - return sal_False; - } - } - } - } // while (nCurIndex < (nIndex + 1)) - } - else - { - // Encapsulated message body. Create message parser stream. - pMsgStrm = new INetMIMEMessageStream; - pMsgStrm->SetTargetMessage (&rChildMsg); - - // Initialize control variables. - INetMessageStreamState eState = INETMSG_EOL_BEGIN; - - // Go. - while (eState == INETMSG_EOL_BEGIN) - { - if ((pMsgRead - pMsgWrite) > 0) - { - // Bytes still in buffer. Put message down-stream. - int status = pMsgStrm->Write ( - pMsgBuffer, (pMsgRead - pMsgWrite)); - if (status != INETSTREAM_STATUS_OK) - { - // Cleanup. - delete pDocStrm; - delete pMsgStrm; - - // Finish. - return (!(status == INETSTREAM_STATUS_ERROR)); - } - pMsgWrite = pMsgBuffer + (pMsgRead - pMsgWrite); - } - else - { - // Buffer empty. Reset to <Begin-of-Buffer>. - pMsgRead = pMsgWrite = pMsgBuffer; - - // Read document stream. - sal_uIntPtr nRead = pDocStrm->Read ( - pMsgBuffer, sizeof (pMsgBuffer)); - if (nRead > 0) - { - // Set read pointer. - pMsgRead += nRead; - } - else - { - // Mark we're done. - eState = INETMSG_EOL_DONE; - } - } - } // while (eState == INETMSG_EOL_BEGIN) - } + aChildren.push_back( &rChildMsg ); - // Done. - if (pDocStrm) delete pDocStrm; - if (pMsgStrm) delete pMsgStrm; return sal_True; } return sal_False; @@ -1604,7 +1166,7 @@ SvStream& INetMIMEMessage::operator<< (SvStream& rStrm) const #else rStrm.WriteByteString (m_aBoundary); #endif - rStrm << static_cast<sal_uInt32>(nNumChildren); + rStrm << static_cast<sal_uInt32>(aChildren.size()); return rStrm; } @@ -1629,7 +1191,6 @@ SvStream& INetMIMEMessage::operator>> (SvStream& rStrm) rStrm.ReadByteString (m_aBoundary); #endif rStrm >> nTemp; - nNumChildren = nTemp; return rStrm; } diff --git a/tools/source/inet/inetstrm.cxx b/tools/source/inet/inetstrm.cxx index 07d404b090ad..7a04ea24af20 100644 --- a/tools/source/inet/inetstrm.cxx +++ b/tools/source/inet/inetstrm.cxx @@ -173,48 +173,6 @@ int INetIStream::Read (sal_Char *pData, sal_uIntPtr nSize) return GetData (pData, nSize); } -/* - * Decode64. - */ -void INetIStream::Decode64 (SvStream& rIn, SvStream& rOut) -{ - INetMessage aMsg; - aMsg.SetDocumentLB(new SvAsyncLockBytes(&rOut, sal_False)); - - INetMessageDecode64Stream_Impl aStream (8192); - aStream.SetTargetMessage (&aMsg); - - sal_Char* pBuf = new sal_Char[8192]; - - int nRead = 0; - while ((nRead = rIn.Read (pBuf, 8192)) > 0) - aStream.Write( pBuf, nRead ); - aStream.Write ("\r\n", 2); - - delete[] pBuf; -} - -/* - * Encode64. - */ -void INetIStream::Encode64 (SvStream& rIn, SvStream& rOut) -{ - INetMessage aMsg; - aMsg.SetDocumentLB ( - new SvLockBytes (&rIn, sal_False)); - - INetMessageEncode64Stream_Impl aStream (8192); - aStream.SetSourceMessage (&aMsg); - - sal_Char* pBuf = new sal_Char[8192]; - - int nRead = 0; - while ((nRead = aStream.Read (pBuf, 8192)) > 0) - rOut.Write( pBuf, nRead ); - - delete[] pBuf; -} - /*========================================================================= * * INetOStream Implementation. @@ -1621,7 +1579,6 @@ int INetMIMEMessageStream::PutMsgLine (const sal_Char *pData, sal_uIntPtr nSize) if( !pChildStrm ) { // Encapsulated message. - pMsg->SetChildCount( pMsg->GetChildCount() + 1); INetMIMEMessage* pNewMessage = new INetMIMEMessage; pNewMessage->SetDocumentLB ( new SvAsyncLockBytes(new SvCacheStream, sal_False)); @@ -1731,7 +1688,6 @@ int INetMIMEMessageStream::PutMsgLine (const sal_Char *pData, sal_uIntPtr nSize) != COMPARE_EQUAL ) { // Encapsulated message. - pMsg->SetChildCount(pMsg->GetChildCount() + 1); INetMIMEMessage* pNewMessage = new INetMIMEMessage; pNewMessage->SetDocumentLB ( diff --git a/tools/source/memtools/table.cxx b/tools/source/memtools/table.cxx index 75119ba6f142..e9c2239b1c82 100644 --- a/tools/source/memtools/table.cxx +++ b/tools/source/memtools/table.cxx @@ -257,45 +257,6 @@ sal_Bool Table::IsKeyValid( sal_uIntPtr nKey ) const // ----------------------------------------------------------------------- -sal_uIntPtr Table::GetUniqueKey( sal_uIntPtr nStartKey ) const -{ - DBG_ASSERT( (nStartKey > 1) && (nStartKey < 0xFFFFFFFF), - "Table::GetUniqueKey() - nStartKey == 0 or nStartKey >= 0xFFFFFFFF" ); - - if ( !nCount ) - return nStartKey; - - sal_uIntPtr nLastKey = (sal_uIntPtr)Container::GetObject( (nCount*2)-2 ); - if ( nLastKey < nStartKey ) - return nStartKey; - else - { - if ( nLastKey < 0xFFFFFFFE ) - return nLastKey+1; - else - { - sal_uIntPtr nPos; - sal_uIntPtr nTempPos = ImplGetIndex( nStartKey, &nPos ); - if ( nTempPos != TABLE_ENTRY_NOTFOUND ) - nPos = nTempPos; - nLastKey = (sal_uIntPtr)Container::GetObject( nPos ); - if ( nStartKey < nLastKey ) - return nStartKey; - while ( nLastKey < 0xFFFFFFFE ) - { - nPos += 2; - nLastKey++; - if ( nLastKey != (sal_uIntPtr)Container::GetObject( nPos ) ) - return nLastKey; - } - } - } - - return 0; -} - -// ----------------------------------------------------------------------- - sal_uIntPtr Table::SearchKey( sal_uIntPtr nKey, sal_uIntPtr* pPos ) const { *pPos = 0; diff --git a/tools/source/rc/isofallback.cxx b/tools/source/rc/isofallback.cxx index e2a82a865b94..2fae5cfc9eee 100644 --- a/tools/source/rc/isofallback.cxx +++ b/tools/source/rc/isofallback.cxx @@ -42,7 +42,7 @@ bool GetIsoFallback(rtl::OString& rLanguage) sal_Int32 nSepPos = rLanguage.indexOf('-'); if (nSepPos == -1) { - if (rLanguage == rtl::OString(RTL_CONSTASCII_STRINGPARAM("en"))) + if (rLanguage.equalsL(RTL_CONSTASCII_STRINGPARAM("en"))) { // en -> "" rLanguage = rtl::OString(); diff --git a/tools/source/rc/resmgr.cxx b/tools/source/rc/resmgr.cxx index d4b7225a22d4..8b53ebb81823 100644 --- a/tools/source/rc/resmgr.cxx +++ b/tools/source/rc/resmgr.cxx @@ -590,19 +590,20 @@ InternalResMgr::~InternalResMgr() { SvFileStream aStm( UniString( pLogFile, RTL_TEXTENCODING_ASCII_US ), STREAM_WRITE ); aStm.Seek( STREAM_SEEK_TO_END ); - ByteString aLine( "FileName: " ); - aLine.Append( ByteString( OUStringToOString( aFileName, RTL_TEXTENCODING_UTF8 ) ) ); - aStm.WriteLine( aLine ); + rtl::OStringBuffer aLine(RTL_CONSTASCII_STRINGPARAM("FileName: ")); + aLine.append(rtl::OUStringToOString(aFileName, + RTL_TEXTENCODING_UTF8)); + aStm.WriteLine(aLine.makeStringAndClear()); for( boost::unordered_map<sal_uInt64, int>::const_iterator it = pResUseDump->begin(); it != pResUseDump->end(); ++it ) { sal_uInt64 nKeyId = it->first; - aLine.Assign( "Type/Id: " ); - aLine.Append( ByteString::CreateFromInt32( sal::static_int_cast< sal_Int32 >((nKeyId >> 32) & 0xFFFFFFFF) ) ); - aLine.Append( '/' ); - aLine.Append( ByteString::CreateFromInt32( sal::static_int_cast< sal_Int32 >(nKeyId & 0xFFFFFFFF) ) ); - aStm.WriteLine( aLine ); + aLine.append(RTL_CONSTASCII_STRINGPARAM("Type/Id: ")); + aLine.append(sal::static_int_cast< sal_Int32 >((nKeyId >> 32) & 0xFFFFFFFF)); + aLine.append('/'); + aLine.append(sal::static_int_cast< sal_Int32 >(nKeyId & 0xFFFFFFFF)); + aStm.WriteLine(aLine.makeStringAndClear()); } } } @@ -817,31 +818,37 @@ void ResMgr::RscError_Impl( const sal_Char* pMessage, ResMgr* pResMgr, ResMgr* pNewResMgr = new ResMgr( pImp ); - ByteString aStr = OUStringToOString( pResMgr->GetFileName(), RTL_TEXTENCODING_UTF8 ); - if ( aStr.Len() ) - aStr += '\n'; + rtl::OStringBuffer aStr(rtl::OUStringToOString(pResMgr->GetFileName(), + RTL_TEXTENCODING_UTF8)); - aStr.Append( "Class: " ); - aStr.Append( ByteString( GetTypeRes_Impl( ResId( nRT, *pNewResMgr ) ), RTL_TEXTENCODING_UTF8 ) ); - aStr.Append( ", Id: " ); - aStr.Append( ByteString::CreateFromInt32( (long)nId ) ); - aStr.Append( ". " ); - aStr.Append( pMessage ); + if (aStr.getLength()) + aStr.append('\n'); - aStr.Append( "\nResource Stack\n" ); + aStr.append(RTL_CONSTASCII_STRINGPARAM("Class: ")); + aStr.append(rtl::OUStringToOString(GetTypeRes_Impl(ResId(nRT, *pNewResMgr)), + RTL_TEXTENCODING_UTF8)); + aStr.append(RTL_CONSTASCII_STRINGPARAM(", Id: ")); + aStr.append(static_cast<sal_Int32>(nId)); + aStr.append(RTL_CONSTASCII_STRINGPARAM(". ")); + aStr.append(pMessage); + + aStr.append(RTL_CONSTASCII_STRINGPARAM("\nResource Stack\n")); while( nDepth > 0 ) { - aStr.Append( "Class: " ); - aStr.Append( ByteString( GetTypeRes_Impl( ResId( rResStack[nDepth].pResource->GetRT(), *pNewResMgr ) ), RTL_TEXTENCODING_UTF8 ) ); - aStr.Append( ", Id: " ); - aStr.Append( ByteString::CreateFromInt32( (long)rResStack[nDepth].pResource->GetId() ) ); + aStr.append(RTL_CONSTASCII_STRINGPARAM("Class: ")); + aStr.append(rtl::OUStringToOString(GetTypeRes_Impl( + ResId(rResStack[nDepth].pResource->GetRT(), *pNewResMgr)), + RTL_TEXTENCODING_UTF8)); + aStr.append(RTL_CONSTASCII_STRINGPARAM(", Id: ")); + aStr.append(static_cast<sal_Int32>( + rResStack[nDepth].pResource->GetId())); nDepth--; } // clean up delete pNewResMgr; - OSL_FAIL( aStr.GetBuffer() ); + OSL_FAIL(aStr.getStr()); } #endif @@ -1207,15 +1214,18 @@ sal_Bool ResMgr::GetResource( const ResId& rId, const Resource* pResObj ) if( pFallbackResMgr ) { pTop->Flags |= RC_FALLBACK_DOWN; - #ifdef DBG_UTIL - ByteString aMess( "found resource " ); - aMess.Append( ByteString::CreateFromInt32( nId ) ); - aMess.Append( " in fallback " ); - aMess.Append( ByteString( OUStringToOString( pFallbackResMgr->GetFileName(), osl_getThreadTextEncoding() ) ) ); - aMess.Append( "\n" ); - RscError_Impl( aMess.GetBuffer(), - this, nRT, nId, aStack, nCurStack-1 ); - #endif +#ifdef DBG_UTIL + rtl::OStringBuffer aMess( + RTL_CONSTASCII_STRINGPARAM("found resource ")); + aMess.append(static_cast<sal_Int32>(nId)); + aMess.append(RTL_CONSTASCII_STRINGPARAM(" in fallback ")); + aMess.append(rtl::OUStringToOString( + pFallbackResMgr->GetFileName(), + osl_getThreadTextEncoding())); + aMess.append('\n'); + RscError_Impl(aMess.getStr(), + this, nRT, nId, aStack, nCurStack-1); +#endif } else { diff --git a/tools/source/ref/errinf.cxx b/tools/source/ref/errinf.cxx index 9ad9b71dcba3..9a3dece87cf9 100644 --- a/tools/source/ref/errinf.cxx +++ b/tools/source/ref/errinf.cxx @@ -34,6 +34,7 @@ #include <tools/debug.hxx> #include <tools/errinf.hxx> #include <tools/string.hxx> +#include <rtl/strbuf.hxx> class ErrorHandler; @@ -429,30 +430,33 @@ sal_Bool SimpleErrorHandler::CreateString( const ErrorInfo *pInfo, String &rStr, sal_uInt16 &) const { sal_uIntPtr nId = pInfo->GetErrorCode(); - ByteString aStr; - aStr="Id "; - aStr+=ByteString::CreateFromInt32(nId); - aStr+=" only handled by SimpleErrorHandler"; - aStr+="\nErrorCode: "; - aStr+=ByteString::CreateFromInt32(nId & ((1L << ERRCODE_CLASS_SHIFT) - 1 )); - aStr+="\nErrorClass: "; - aStr+=ByteString::CreateFromInt32((nId & ERRCODE_CLASS_MASK) >> ERRCODE_CLASS_SHIFT); - aStr+="\nErrorArea: "; - aStr+=ByteString::CreateFromInt32((nId & ERRCODE_ERROR_MASK & - ~((1 << ERRCODE_AREA_SHIFT ) -1 ) ) >> ERRCODE_AREA_SHIFT); + rtl::OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM("Id ")); + aStr.append(static_cast<sal_Int32>(nId)); + aStr.append(RTL_CONSTASCII_STRINGPARAM( + " only handled by SimpleErrorHandler")); + aStr.append(RTL_CONSTASCII_STRINGPARAM("\nErrorCode: ")); + aStr.append(static_cast<sal_Int32>( + nId & ((1L << ERRCODE_CLASS_SHIFT) - 1 ))); + aStr.append(RTL_CONSTASCII_STRINGPARAM("\nErrorClass: ")); + aStr.append(static_cast<sal_Int32>( + (nId & ERRCODE_CLASS_MASK) >> ERRCODE_CLASS_SHIFT)); + aStr.append(RTL_CONSTASCII_STRINGPARAM("\nErrorArea: ")); + aStr.append(static_cast<sal_Int32>((nId & ERRCODE_ERROR_MASK & + ~((1 << ERRCODE_AREA_SHIFT ) -1 ) ) >> ERRCODE_AREA_SHIFT)); DynamicErrorInfo *pDyn=PTR_CAST(DynamicErrorInfo,pInfo); if(pDyn) { - aStr+="\nDId "; - aStr+=ByteString::CreateFromInt32((sal_uIntPtr)*pDyn); + aStr.append(RTL_CONSTASCII_STRINGPARAM("\nDId ")); + aStr.append(static_cast<sal_Int32>(*pDyn)); } StandardErrorInfo *pStd=PTR_CAST(StandardErrorInfo,pInfo); if(pStd) { - aStr+="\nXId "; - aStr+=ByteString::CreateFromInt32(pStd->GetExtendedErrorCode()); + aStr.append(RTL_CONSTASCII_STRINGPARAM("\nXId ")); + aStr.append(static_cast<sal_Int32>(pStd->GetExtendedErrorCode())); } - rStr = String( aStr, RTL_TEXTENCODING_ASCII_US ); + rStr = rtl::OStringToOUString(aStr.makeStringAndClear(), + RTL_TEXTENCODING_ASCII_US); return sal_True; } diff --git a/tools/source/ref/globname.cxx b/tools/source/ref/globname.cxx index 05c7709931e6..e7f30b9d50df 100644 --- a/tools/source/ref/globname.cxx +++ b/tools/source/ref/globname.cxx @@ -33,6 +33,8 @@ #include <stdio.h> #include <string.h> +#include <rtl/strbuf.hxx> + #include <tools/stream.hxx> #include <tools/globname.hxx> @@ -208,10 +210,10 @@ sal_Bool SvGlobalName::operator < ( const SvGlobalName & rObj ) const else if( Data2_a == Data2_b ) { sal_uInt32 Data1_a; - memcpy(&Data1_a, pImp->szData+4, sizeof(sal_uInt32)); + memcpy(&Data1_a, pImp->szData, sizeof(sal_uInt32)); sal_uInt32 Data1_b; - memcpy(&Data1_b, rObj.pImp->szData+4, sizeof(sal_uInt32)); + memcpy(&Data1_b, rObj.pImp->szData, sizeof(sal_uInt32)); return Data1_a < Data1_b; } @@ -262,8 +264,9 @@ void SvGlobalName::MakeFromMemory( void * pData ) *************************************************************************/ sal_Bool SvGlobalName::MakeId( const String & rIdStr ) { - ByteString aStr( rIdStr, RTL_TEXTENCODING_ASCII_US ); - sal_Char * pStr = (sal_Char *)aStr.GetBuffer(); + rtl::OString aStr(rtl::OUStringToOString(rIdStr, + RTL_TEXTENCODING_ASCII_US)); + const sal_Char *pStr = aStr.getStr(); if( rIdStr.Len() == 36 && '-' == pStr[ 8 ] && '-' == pStr[ 13 ] && '-' == pStr[ 18 ] && '-' == pStr[ 23 ] ) @@ -342,29 +345,29 @@ sal_Bool SvGlobalName::MakeId( const String & rIdStr ) *************************************************************************/ String SvGlobalName::GetctorName() const { - ByteString aRet; + rtl::OStringBuffer aStrBuffer; sal_Char buf[ 20 ]; sal_uInt32 Data1; memcpy(&Data1, pImp->szData, sizeof(sal_uInt32)); sprintf( buf, "0x%8.8" SAL_PRIXUINT32, Data1 ); - aRet += buf; + aStrBuffer.append(buf); sal_uInt16 i; for( i = 4; i < 8; i += 2 ) { - aRet += ','; + aStrBuffer.append(','); sal_uInt16 Data2; memcpy(&Data2, pImp->szData+i, sizeof(sal_uInt16)); sprintf( buf, "0x%4.4X", Data2 ); - aRet += buf; + aStrBuffer.append(buf); } for( i = 8; i < 16; i++ ) { - aRet += ','; + aStrBuffer.append(','); sprintf( buf, "0x%2.2x", pImp->szData[ i ] ); - aRet += buf; + aStrBuffer.append(buf); } - return String( aRet, RTL_TEXTENCODING_ASCII_US ); + return rtl::OStringToOUString(aStrBuffer.makeStringAndClear(), RTL_TEXTENCODING_ASCII_US); } /************************************************************************* @@ -372,35 +375,35 @@ String SvGlobalName::GetctorName() const *************************************************************************/ String SvGlobalName::GetHexName() const { - ByteString aRet; + rtl::OStringBuffer aHexBuffer; sal_Char buf[ 10 ]; sal_uInt32 Data1; memcpy(&Data1, pImp->szData, sizeof(sal_uInt32)); sprintf( buf, "%8.8" SAL_PRIXUINT32, Data1 ); - aRet += buf; - aRet += '-'; + aHexBuffer.append(buf); + aHexBuffer.append('-'); sal_uInt16 i ; for( i = 4; i < 8; i += 2 ) { sal_uInt16 Data2; memcpy(&Data2, pImp->szData+i, sizeof(sal_uInt16)); sprintf( buf, "%4.4X", Data2 ); - aRet += buf; - aRet += '-'; + aHexBuffer.append(buf); + aHexBuffer.append('-'); } for( i = 8; i < 10; i++ ) { sprintf( buf, "%2.2x", pImp->szData[ i ] ); - aRet += buf; + aHexBuffer.append(buf); } - aRet += '-'; + aHexBuffer.append('-'); for( i = 10; i < 16; i++ ) { sprintf( buf, "%2.2x", pImp->szData[ i ] ); - aRet += buf; + aHexBuffer.append(buf); } - return String( aRet, RTL_TEXTENCODING_ASCII_US ); + return rtl::OStringToOUString(aHexBuffer.makeStringAndClear(), RTL_TEXTENCODING_ASCII_US); } /************** SvGlobalNameList ****************************************/ diff --git a/tools/source/ref/pstm.cxx b/tools/source/ref/pstm.cxx index 75781b427c89..51692e966848 100644 --- a/tools/source/ref/pstm.cxx +++ b/tools/source/ref/pstm.cxx @@ -31,6 +31,7 @@ #include <tools/debug.hxx> #include <tools/pstm.hxx> +#include <rtl/strbuf.hxx> #define STOR_NO_OPTIMIZE @@ -152,11 +153,12 @@ SvPersistStream& operator >> ( SvPersistStream & rStm, #ifdef DBG_UTIL if( nObjLen + nObjPos != rStm.Tell() ) { - ByteString aStr( "false list len: read = " ); - aStr += ByteString::CreateFromInt32( (long)(rStm.Tell() - nObjPos) ); - aStr += ", should = "; - aStr += ByteString::CreateFromInt64(nObjLen); - OSL_FAIL( aStr.GetBuffer() ); + rtl::OStringBuffer aStr( + RTL_CONSTASCII_STRINGPARAM("false list len: read = ")); + aStr.append(static_cast<sal_Int64>(rStm.Tell() - nObjPos)); + aStr.append(RTL_CONSTASCII_STRINGPARAM(", should = ")); + aStr.append(static_cast<sal_Int64>(nObjLen)); + OSL_FAIL(aStr.getStr()); } #else (void)nObjLen; @@ -760,10 +762,11 @@ sal_uInt32 SvPersistStream::ReadObj if( !pFunc ) { #ifdef DBG_UTIL - ByteString aStr( "no class with id: " ); - aStr += ByteString::CreateFromInt32( nClassId ); - aStr += " registered"; - DBG_WARNING( aStr.GetBuffer() ); + rtl::OStringBuffer aStr( + RTL_CONSTASCII_STRINGPARAM("no class with id: " )); + aStr.append(static_cast<sal_Int32>(nClassId)); + aStr.append(RTL_CONSTASCII_STRINGPARAM(" registered")); + DBG_WARNING(aStr.getStr()); #else (void)nObjLen; #endif @@ -788,11 +791,12 @@ sal_uInt32 SvPersistStream::ReadObj #ifdef DBG_UTIL if( nObjLen + nObjPos != Tell() ) { - ByteString aStr( "false object len: read = " ); - aStr += ByteString::CreateFromInt32( (long)(Tell() - nObjPos) ); - aStr += ", should = "; - aStr += ByteString::CreateFromInt32( nObjLen ); - OSL_FAIL( aStr.GetBuffer() ); + rtl::OStringBuffer aStr( + RTL_CONSTASCII_STRINGPARAM("false object len: read = ")); + aStr.append(static_cast<sal_Int64>((long)(Tell() - nObjPos))); + aStr.append(RTL_CONSTASCII_STRINGPARAM(", should = ")); + aStr.append(static_cast<sal_Int32>(nObjLen)); + OSL_FAIL(aStr.getStr()); } #endif rpObj->RestoreNoDelete(); diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx index bf0c2f49b24c..2917776e6212 100644 --- a/tools/source/stream/stream.cxx +++ b/tools/source/stream/stream.cxx @@ -43,6 +43,7 @@ #include <tools/solar.h> + #define SWAPNIBBLES(c) \ unsigned char nSwapTmp=c; \ nSwapTmp <<= 4; \ @@ -372,13 +373,6 @@ sal_Size SvStream::GetData( void* pData, sal_Size nSize ) else return 0; } -ErrCode SvStream::SetLockBytes( SvLockBytesRef& rLB ) -{ - xLockBytes = rLB; - RefreshBuffer(); - return ERRCODE_NONE; -} - //======================================================================== sal_Size SvStream::PutData( const void* pData, sal_Size nSize ) @@ -719,6 +713,15 @@ sal_Bool SvStream::ReadLine( ByteString& rStr ) return bEnd; } +sal_Bool SvStream::ReadLine( rtl::OString& rStr ) +{ + ByteString aFoo; + sal_Bool ret; + ret = ReadLine(aFoo); + rStr = aFoo; + return ret; +} + sal_Bool SvStream::ReadUniStringLine( String& rStr ) { sal_Unicode buf[256+1]; @@ -939,14 +942,6 @@ sal_Bool SvStream::WriteLines( const ByteString& rStr ) return (sal_Bool)(nError == SVSTREAM_OK); } -sal_Bool SvStream::WriteUniStringLines( const String& rStr ) -{ - String aStr( rStr ); - aStr.ConvertLineEnd( eLineDelimiter ); - WriteUniStringLine( aStr ); - return nError == SVSTREAM_OK; -} - /************************************************************************* |* |* Stream::WriteUniOrByteChar() @@ -1802,6 +1797,18 @@ sal_Size SvStream::Seek( sal_Size nFilePos ) return nBufFilePos + nBufActualPos; } +//probably not as inefficient as it looks seeing as STREAM_SEEK_TO_END in the +//Seek backends is nomally special cased feel free to make this virtual and add +//good implementations for SvFileStream etc +sal_Size SvStream::remainingSize() +{ + sal_Size nCurr = Tell(); + sal_Size nEnd = Seek(STREAM_SEEK_TO_END); + sal_Size nMaxAvailable = nEnd-nCurr; + Seek(nCurr); + return nMaxAvailable; +} + /************************************************************************* |* |* Stream::Flush() @@ -1824,91 +1831,6 @@ void SvStream::Flush() FlushData(); } - -/************************************************************************* -|* -|* Stream::PutBack() -|* -*************************************************************************/ - -/* - 4 Faelle : - - 1. Datenzeiger steht mitten im Puffer (nBufActualPos >= 1) - 2. Datenzeiger auf Position 0, Puffer ist voll - 3. Datenzeiger auf Position 0, Puffer ist teilweise gefuellt - 4. Datenzeiger auf Position 0, Puffer ist leer -> Fehler! -*/ - -SvStream& SvStream::PutBack( char aCh ) -{ - // wenn kein Buffer oder Zurueckscrollen nicht moeglich -> Fehler - if( !pRWBuf || !nBufActualLen || ( !nBufActualPos && !nBufFilePos ) ) - { - // 4. Fall - SetError( SVSTREAM_GENERALERROR ); - return *this; - } - - // Flush() (Phys. Flushen aber nicht notwendig, deshalb selbst schreiben) - if( bIsConsistent && bIsDirty ) - { - SeekPos( nBufFilePos ); - if( nCryptMask ) - CryptAndWriteBuffer( pRWBuf, nBufActualLen ); - else - PutData( pRWBuf, nBufActualLen ); - bIsDirty = sal_False; - } - bIsConsistent = sal_False; // Puffer enthaelt jetzt TRASH - if( nBufActualPos ) - { - // 1. Fall - nBufActualPos--; - pBufPos--; - *pBufPos = aCh; - nBufFree++; - } - else // Puffer muss verschoben werden - { - // Ist Puffer am Anschlag ? - if( nBufSize == nBufActualLen ) - { - // 2. Fall - memmove( pRWBuf+1, pRWBuf, nBufSize-1 ); - // nBufFree behaelt den Wert! - } - else - { - // 3. Fall -> Puffer vergroessern - memmove( pRWBuf+1, pRWBuf, (sal_uInt16)nBufActualLen ); - nBufActualLen++; - nBufFree++; - } - nBufFilePos--; - *pRWBuf = aCh; - } - eIOMode = STREAM_IO_DONTKNOW; - bIsEof = sal_False; - return *this; -} - -/************************************************************************* -|* -|* Stream::EatWhite() -|* -*************************************************************************/ - -void SvStream::EatWhite() -{ - char aCh; - Read(&aCh, sizeof(char) ); - while( !bIsEof && isspace((int)aCh) ) //( aCh == ' ' || aCh == '\t' ) ) - Read(&aCh, sizeof(char) ); - if( !bIsEof ) // konnte das letzte Char gelesen werden ? - SeekRel( -1L ); -} - /************************************************************************* |* |* Stream::RefreshBuffer() diff --git a/tools/source/stream/strmunx.cxx b/tools/source/stream/strmunx.cxx index 1e8b75c5fe37..9c84eeae54f8 100644 --- a/tools/source/stream/strmunx.cxx +++ b/tools/source/stream/strmunx.cxx @@ -48,6 +48,7 @@ // class FileBase #include <osl/file.hxx> #include <rtl/instance.hxx> +#include <rtl/strbuf.hxx> using namespace osl; @@ -226,7 +227,8 @@ static sal_uInt32 GetSvError( int nErrno ) { EBADF, SVSTREAM_INVALID_HANDLE }, #if defined(RS6000) || defined(ALPHA) || defined(NETBSD) || \ defined(FREEBSD) || defined(MACOSX) || defined(OPENBSD) || \ - defined(__FreeBSD_kernel__) || defined (AIX) || defined(DRAGONFLY) + defined(__FreeBSD_kernel__) || defined (AIX) || defined(DRAGONFLY) || \ + defined(IOS) { EDEADLK, SVSTREAM_LOCKING_VIOLATION }, #else { EDEADLOCK, SVSTREAM_LOCKING_VIOLATION }, @@ -354,11 +356,13 @@ sal_uInt16 SvFileStream::IsA() const sal_Size SvFileStream::GetData( void* pData, sal_Size nSize ) { #ifdef DBG_UTIL - ByteString aTraceStr( "SvFileStream::GetData(): " ); - aTraceStr += ByteString::CreateFromInt64(nSize); - aTraceStr += " Bytes from "; - aTraceStr += ByteString(aFilename, osl_getThreadTextEncoding()); - OSL_TRACE( "%s", aTraceStr.GetBuffer() ); + rtl::OStringBuffer aTraceStr( + RTL_CONSTASCII_STRINGPARAM("SvFileStream::GetData(): ")); + aTraceStr.append(static_cast<sal_Int64>(nSize)); + aTraceStr.append(RTL_CONSTASCII_STRINGPARAM(" Bytes from ")); + aTraceStr.append(rtl::OUStringToOString(aFilename, + osl_getThreadTextEncoding())); + OSL_TRACE("%s", aTraceStr.getStr()); #endif int nRead = 0; @@ -380,11 +384,13 @@ sal_Size SvFileStream::GetData( void* pData, sal_Size nSize ) sal_Size SvFileStream::PutData( const void* pData, sal_Size nSize ) { #ifdef DBG_UTIL - ByteString aTraceStr( "SvFileStrean::PutData: " ); - aTraceStr += ByteString::CreateFromInt64(nSize); - aTraceStr += " Bytes to "; - aTraceStr += ByteString(aFilename, osl_getThreadTextEncoding()); - OSL_TRACE( "%s", aTraceStr.GetBuffer() ); + rtl::OStringBuffer aTraceStr( + RTL_CONSTASCII_STRINGPARAM("SvFileStream::PutData(): ")); + aTraceStr.append(static_cast<sal_Int64>(nSize)); + aTraceStr.append(RTL_CONSTASCII_STRINGPARAM(" Bytes to ")); + aTraceStr.append(rtl::OUStringToOString(aFilename, + osl_getThreadTextEncoding())); + OSL_TRACE("%s", aTraceStr.getStr()); #endif int nWrite = 0; diff --git a/tools/source/string/strcvt.cxx b/tools/source/string/strcvt.cxx index 54169c3c0716..c7519bdc6df5 100644 --- a/tools/source/string/strcvt.cxx +++ b/tools/source/string/strcvt.cxx @@ -169,61 +169,6 @@ struct Impl1ByteConvertTabData Impl1ByteConvertTabData* mpNext; }; -// ======================================================================= - -sal_Unicode* ImplGet1ByteUnicodeTab( rtl_TextEncoding eTextEncoding ) -{ -#ifndef BOOTSTRAP - TOOLSINDATA* pToolsData = ImplGetToolsInData(); -#else - TOOLSINDATA* pToolsData = 0x0; -#endif - Impl1ByteUnicodeTabData* pTab = pToolsData->mpFirstUniTabData; - - while ( pTab ) - { - if ( pTab->meTextEncoding == eTextEncoding ) - return pTab->maUniTab; - pTab = pTab->mpNext; - } - - // get TextEncodingInfo - rtl_TextEncodingInfo aTextEncInfo; - aTextEncInfo.StructSize = sizeof( aTextEncInfo ); - rtl_getTextEncodingInfo( eTextEncoding, &aTextEncInfo ); - - if ( aTextEncInfo.MaximumCharSize == 1 ) - { - pTab = new Impl1ByteUnicodeTabData; - pTab->meTextEncoding = eTextEncoding; - pTab->mpNext = pToolsData->mpFirstUniTabData; - - rtl_TextToUnicodeConverter hConverter; - sal_uInt32 nInfo; - sal_Size nSrcBytes; - sal_Size nDestChars; - hConverter = rtl_createTextToUnicodeConverter( eTextEncoding ); - nDestChars = rtl_convertTextToUnicode( hConverter, 0, - (const sal_Char*)aImplByteTab, 256, - pTab->maUniTab, 256, - RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_MAPTOPRIVATE | - RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_DEFAULT | - RTL_TEXTTOUNICODE_FLAGS_INVALID_DEFAULT, - &nInfo, &nSrcBytes ); - rtl_destroyTextToUnicodeConverter( hConverter ); - - if ( (nSrcBytes != 256) || (nDestChars != 256) ) - delete pTab; - else - { - pToolsData->mpFirstUniTabData = pTab; - return pTab->maUniTab; - } - } - - return NULL; -} - // ----------------------------------------------------------------------- static sal_uChar* ImplGet1ByteConvertTab( rtl_TextEncoding eSrcTextEncoding, diff --git a/tools/source/string/strimp.cxx b/tools/source/string/strimp.cxx index 21065f999958..2f79410a9c19 100644 --- a/tools/source/string/strimp.cxx +++ b/tools/source/string/strimp.cxx @@ -691,52 +691,6 @@ STRING& STRING::Insert( const STRING& rStr, xub_StrLen nIndex ) // ----------------------------------------------------------------------- -STRING& STRING::Insert( const STRING& rStr, xub_StrLen nPos, xub_StrLen nLen, - xub_StrLen nIndex ) -{ - DBG_CHKTHIS( STRING, DBGCHECKSTRING ); - DBG_CHKOBJ( &rStr, STRING, DBGCHECKSTRING ); - - // Stringlaenge ermitteln - if ( nPos > rStr.mpData->mnLen ) - nLen = 0; - else - { - // Laenge korrigieren, wenn noetig - sal_Int32 nMaxLen = rStr.mpData->mnLen-nPos; - if ( nLen > nMaxLen ) - nLen = static_cast< xub_StrLen >(nMaxLen); - } - - // Ueberlauf abfangen - sal_Int32 nCopyLen = ImplGetCopyLen( mpData->mnLen, nLen ); - - // Ist der einzufuegende String ein Leerstring - if ( !nCopyLen ) - return *this; - - // Index groesser als Laenge - if ( nIndex > mpData->mnLen ) - nIndex = static_cast< xub_StrLen >(mpData->mnLen); - - // Neue Laenge ermitteln und neuen String anlegen - STRINGDATA* pNewData = ImplAllocData( mpData->mnLen+nCopyLen ); - - // String kopieren - memcpy( pNewData->maStr, mpData->maStr, nIndex*sizeof( STRCODE ) ); - memcpy( pNewData->maStr+nIndex, rStr.mpData->maStr+nPos, nCopyLen*sizeof( STRCODE ) ); - memcpy( pNewData->maStr+nIndex+nCopyLen, mpData->maStr+nIndex, - (mpData->mnLen-nIndex)*sizeof( STRCODE ) ); - - // Alte Daten loeschen und Neue zuweisen - STRING_RELEASE((STRING_TYPE *)mpData); - mpData = pNewData; - - return *this; -} - -// ----------------------------------------------------------------------- - STRING& STRING::Insert( const STRCODE* pCharStr, xub_StrLen nIndex ) { DBG_CHKTHIS( STRING, DBGCHECKSTRING ); @@ -1061,30 +1015,6 @@ STRING& STRING::EraseAllChars( STRCODE c ) // ----------------------------------------------------------------------- -STRING& STRING::Reverse() -{ - DBG_CHKTHIS( STRING, DBGCHECKSTRING ); - - if ( !mpData->mnLen ) - return *this; - - // Daten kopieren, wenn noetig - ImplCopyData(); - - // Reverse - sal_Int32 nCount = mpData->mnLen / 2; - for ( sal_Int32 i = 0; i < nCount; ++i ) - { - STRCODE cTemp = mpData->maStr[i]; - mpData->maStr[i] = mpData->maStr[mpData->mnLen-i-1]; - mpData->maStr[mpData->mnLen-i-1] = cTemp; - } - - return *this; -} - -// ----------------------------------------------------------------------- - STRING& STRING::ToLowerAscii() { DBG_CHKTHIS( STRING, DBGCHECKSTRING ); @@ -1279,36 +1209,6 @@ StringCompare STRING::CompareTo( const STRCODE* pCharStr, xub_StrLen nLen ) cons // ----------------------------------------------------------------------- -StringCompare STRING::CompareIgnoreCaseToAscii( const STRING& rStr, - xub_StrLen nLen ) const -{ - DBG_CHKTHIS( STRING, DBGCHECKSTRING ); - DBG_CHKOBJ( &rStr, STRING, DBGCHECKSTRING ); - - // Auf Gleichheit der Pointer testen - if ( mpData == rStr.mpData ) - return COMPARE_EQUAL; - - // Maximale Laenge ermitteln - if ( mpData->mnLen < nLen ) - nLen = static_cast< xub_StrLen >(mpData->mnLen+1); - if ( rStr.mpData->mnLen < nLen ) - nLen = static_cast< xub_StrLen >(rStr.mpData->mnLen+1); - - // String vergleichen - sal_Int32 nCompare = ImplStringICompareWithoutZero( mpData->maStr, rStr.mpData->maStr, nLen ); - - // Rueckgabewert anpassen - if ( nCompare == 0 ) - return COMPARE_EQUAL; - else if ( nCompare < 0 ) - return COMPARE_LESS; - else - return COMPARE_GREATER; -} - -// ----------------------------------------------------------------------- - StringCompare STRING::CompareIgnoreCaseToAscii( const STRCODE* pCharStr, xub_StrLen nLen ) const { @@ -1419,41 +1319,6 @@ sal_Bool STRING::Equals( const STRCODE* pCharStr, xub_StrLen nIndex, xub_StrLen // ----------------------------------------------------------------------- -sal_Bool STRING::EqualsIgnoreCaseAscii( const STRING& rStr, xub_StrLen nIndex, xub_StrLen nLen ) const -{ - DBG_CHKTHIS( STRING, DBGCHECKSTRING ); - DBG_CHKOBJ( &rStr, STRING, DBGCHECKSTRING ); - - // Are there enough codes for comparing? - if ( nIndex > mpData->mnLen ) - return (rStr.mpData->mnLen == 0); - sal_Int32 nMaxLen = mpData->mnLen-nIndex; - if ( nMaxLen < nLen ) - { - if ( rStr.mpData->mnLen != nMaxLen ) - return sal_False; - nLen = static_cast< xub_StrLen >(nMaxLen); - } - - // String vergleichen - return (ImplStringICompareWithoutZero( mpData->maStr+nIndex, rStr.mpData->maStr, nLen ) == 0); -} - -// ----------------------------------------------------------------------- - -sal_Bool STRING::EqualsIgnoreCaseAscii( const STRCODE* pCharStr, xub_StrLen nIndex, xub_StrLen nLen ) const -{ - DBG_CHKTHIS( STRING, DBGCHECKSTRING ); - - // Are there enough codes for comparing? - if ( nIndex > mpData->mnLen ) - return (*pCharStr == 0); - - return (ImplStringICompare( mpData->maStr+nIndex, pCharStr, nLen ) == 0); -} - -// ----------------------------------------------------------------------- - xub_StrLen STRING::Match( const STRING& rStr ) const { DBG_CHKTHIS( STRING, DBGCHECKSTRING ); @@ -1482,32 +1347,6 @@ xub_StrLen STRING::Match( const STRING& rStr ) const // ----------------------------------------------------------------------- -xub_StrLen STRING::Match( const STRCODE* pCharStr ) const -{ - DBG_CHKTHIS( STRING, DBGCHECKSTRING ); - - // Ist dieser String leer - if ( !mpData->mnLen ) - return STRING_MATCH; - - // Suche bis Stringende nach dem ersten nicht uebereinstimmenden Zeichen - const STRCODE* pStr = mpData->maStr; - xub_StrLen i = 0; - while ( i < mpData->mnLen ) - { - // Stimmt das Zeichen nicht ueberein, dann abbrechen - if ( *pStr != *pCharStr ) - return i; - ++pStr, - ++pCharStr, - ++i; - } - - return STRING_MATCH; -} - -// ----------------------------------------------------------------------- - xub_StrLen STRING::Search( STRCODE c, xub_StrLen nIndex ) const { DBG_CHKTHIS( STRING, DBGCHECKSTRING ); @@ -1642,86 +1481,6 @@ xub_StrLen STRING::SearchBackward( STRCODE c, xub_StrLen nIndex ) const // ----------------------------------------------------------------------- -xub_StrLen STRING::SearchChar( const STRCODE* pChars, xub_StrLen nIndex ) const -{ - DBG_CHKTHIS( STRING, DBGCHECKSTRING ); - - sal_Int32 nLen = mpData->mnLen; - const STRCODE* pStr = mpData->maStr; - pStr += nIndex; - while ( nIndex < nLen ) - { - STRCODE c = *pStr; - const STRCODE* pCompStr = pChars; - while ( *pCompStr ) - { - if ( *pCompStr == c ) - return nIndex; - ++pCompStr; - } - ++pStr, - ++nIndex; - } - - return STRING_NOTFOUND; -} - -// ----------------------------------------------------------------------- - -xub_StrLen STRING::SearchCharBackward( const STRCODE* pChars, xub_StrLen nIndex ) const -{ - DBG_CHKTHIS( STRING, DBGCHECKSTRING ); - - if ( nIndex > mpData->mnLen ) - nIndex = (xub_StrLen)mpData->mnLen; - - const STRCODE* pStr = mpData->maStr; - pStr += nIndex; - - while ( nIndex ) - { - nIndex--; - pStr--; - - STRCODE c =*pStr; - const STRCODE* pCompStr = pChars; - while ( *pCompStr ) - { - if ( *pCompStr == c ) - return nIndex; - ++pCompStr; - } - } - - return STRING_NOTFOUND; -} - -// ----------------------------------------------------------------------- - -xub_StrLen STRING::SearchAndReplace( STRCODE c, STRCODE cRep, xub_StrLen nIndex ) -{ - DBG_CHKTHIS( STRING, DBGCHECKSTRING ); - - sal_Int32 nLen = mpData->mnLen; - const STRCODE* pStr = mpData->maStr; - pStr += nIndex; - while ( nIndex < nLen ) - { - if ( *pStr == c ) - { - ImplCopyData(); - mpData->maStr[nIndex] = cRep; - return nIndex; - } - ++pStr, - ++nIndex; - } - - return STRING_NOTFOUND; -} - -// ----------------------------------------------------------------------- - xub_StrLen STRING::SearchAndReplace( const STRING& rStr, const STRING& rRepStr, xub_StrLen nIndex ) { @@ -1923,141 +1682,6 @@ STRING STRING::GetToken( xub_StrLen nToken, STRCODE cTok, xub_StrLen& rIndex ) c // ----------------------------------------------------------------------- -xub_StrLen STRING::GetQuotedTokenCount( const STRING& rQuotedPairs, STRCODE cTok ) const -{ - DBG_CHKTHIS( STRING, DBGCHECKSTRING ); - DBG_CHKOBJ( &rQuotedPairs, STRING, DBGCHECKSTRING ); - DBG_ASSERT( !(rQuotedPairs.Len()%2), "String::GetQuotedTokenCount() - QuotedString%2 != 0" ); - DBG_ASSERT( rQuotedPairs.Search(cTok) == STRING_NOTFOUND, "String::GetQuotedTokenCount() - cTok in QuotedString" ); - - // Leerer String: TokenCount per Definition 0 - if ( !mpData->mnLen ) - return 0; - - xub_StrLen nTokCount = 1; - sal_Int32 nLen = mpData->mnLen; - xub_StrLen nQuotedLen = rQuotedPairs.Len(); - STRCODE cQuotedEndChar = 0; - const STRCODE* pQuotedStr = rQuotedPairs.mpData->maStr; - const STRCODE* pStr = mpData->maStr; - sal_Int32 nIndex = 0; - while ( nIndex < nLen ) - { - STRCODE c = *pStr; - if ( cQuotedEndChar ) - { - // Ende des Quotes erreicht ? - if ( c == cQuotedEndChar ) - cQuotedEndChar = 0; - } - else - { - // Ist das Zeichen ein Quote-Anfang-Zeichen ? - xub_StrLen nQuoteIndex = 0; - while ( nQuoteIndex < nQuotedLen ) - { - if ( pQuotedStr[nQuoteIndex] == c ) - { - cQuotedEndChar = pQuotedStr[nQuoteIndex+1]; - break; - } - else - nQuoteIndex += 2; - } - - // Stimmt das Tokenzeichen ueberein, dann erhoehe TokCount - if ( c == cTok ) - ++nTokCount; - } - - ++pStr, - ++nIndex; - } - - return nTokCount; -} - -// ----------------------------------------------------------------------- - -STRING STRING::GetQuotedToken( xub_StrLen nToken, const STRING& rQuotedPairs, - STRCODE cTok, xub_StrLen& rIndex ) const -{ - DBG_CHKTHIS( STRING, DBGCHECKSTRING ); - DBG_CHKOBJ( &rQuotedPairs, STRING, DBGCHECKSTRING ); - DBG_ASSERT( !(rQuotedPairs.Len()%2), "String::GetQuotedToken() - QuotedString%2 != 0" ); - DBG_ASSERT( rQuotedPairs.Search(cTok) == STRING_NOTFOUND, "String::GetQuotedToken() - cTok in QuotedString" ); - - const STRCODE* pStr = mpData->maStr; - const STRCODE* pQuotedStr = rQuotedPairs.mpData->maStr; - STRCODE cQuotedEndChar = 0; - xub_StrLen nQuotedLen = rQuotedPairs.Len(); - xub_StrLen nLen = (xub_StrLen)mpData->mnLen; - xub_StrLen nTok = 0; - xub_StrLen nFirstChar = rIndex; - xub_StrLen i = nFirstChar; - - // Bestimme die Token-Position und Laenge - pStr += i; - while ( i < nLen ) - { - STRCODE c = *pStr; - if ( cQuotedEndChar ) - { - // Ende des Quotes erreicht ? - if ( c == cQuotedEndChar ) - cQuotedEndChar = 0; - } - else - { - // Ist das Zeichen ein Quote-Anfang-Zeichen ? - xub_StrLen nQuoteIndex = 0; - while ( nQuoteIndex < nQuotedLen ) - { - if ( pQuotedStr[nQuoteIndex] == c ) - { - cQuotedEndChar = pQuotedStr[nQuoteIndex+1]; - break; - } - else - nQuoteIndex += 2; - } - - // Stimmt das Tokenzeichen ueberein, dann erhoehe TokCount - if ( c == cTok ) - { - ++nTok; - - if ( nTok == nToken ) - nFirstChar = i+1; - else - { - if ( nTok > nToken ) - break; - } - } - } - - ++pStr, - ++i; - } - - if ( nTok >= nToken ) - { - if ( i < nLen ) - rIndex = i+1; - else - rIndex = STRING_NOTFOUND; - return Copy( nFirstChar, i-nFirstChar ); - } - else - { - rIndex = STRING_NOTFOUND; - return STRING(); - } -} - -// ----------------------------------------------------------------------- - STRCODE* STRING::GetBufferAccess() { DBG_CHKTHIS( STRING, DBGCHECKSTRING ); diff --git a/tools/source/string/tstring.cxx b/tools/source/string/tstring.cxx index c7a5f380fb72..b89a51ba7cdc 100644 --- a/tools/source/string/tstring.cxx +++ b/tools/source/string/tstring.cxx @@ -38,7 +38,6 @@ #include <rtl/alloc.h> #include <rtl/memory.h> #include <rtl/tencinfo.h> -#include <rtl/instance.hxx> #include <tools/string.hxx> #include <impstrg.hxx> @@ -104,45 +103,6 @@ ByteString ByteString::CreateFromInt32( sal_Int32 n, sal_Int16 nRadix ) // ----------------------------------------------------------------------- -ByteString ByteString::CreateFromInt64( sal_Int64 n, sal_Int16 nRadix ) -{ - sal_Char aBuf[RTL_STR_MAX_VALUEOFINT64]; - BOOST_STATIC_ASSERT(RTL_STR_MAX_VALUEOFINT64 <= STRING_MAXLEN); - return ByteString( - aBuf, - static_cast< xub_StrLen >(rtl_str_valueOfInt64( aBuf, n, nRadix )) ); -} - -// ----------------------------------------------------------------------- - -ByteString ByteString::CreateFromFloat( float f ) -{ - sal_Char aBuf[RTL_STR_MAX_VALUEOFFLOAT]; - BOOST_STATIC_ASSERT(RTL_STR_MAX_VALUEOFFLOAT <= STRING_MAXLEN); - return ByteString( - aBuf, static_cast< xub_StrLen >(rtl_str_valueOfFloat( aBuf, f )) ); -} - -// ----------------------------------------------------------------------- - -ByteString ByteString::CreateFromDouble( double d ) -{ - sal_Char aBuf[RTL_STR_MAX_VALUEOFDOUBLE]; - BOOST_STATIC_ASSERT(RTL_STR_MAX_VALUEOFDOUBLE <= STRING_MAXLEN); - return ByteString( - aBuf, static_cast< xub_StrLen >(rtl_str_valueOfDouble( aBuf, d )) ); -} - -// ----------------------------------------------------------------------- - -namespace { struct Empty : public rtl::Static< const ByteString, Empty> {}; } -const ByteString& ByteString::EmptyString() -{ - return Empty::get(); -} - -// ----------------------------------------------------------------------- - sal_Int32 ByteString::ToInt32() const { DBG_CHKTHIS( ByteString, DbgCheckByteString ); @@ -161,26 +121,6 @@ sal_Int64 ByteString::ToInt64() const // ----------------------------------------------------------------------- -float ByteString::ToFloat() const -{ - DBG_CHKTHIS( ByteString, DbgCheckByteString ); - - OSL_FAIL("ByteString::ToFloat unusable"); - return 0; -} - -// ----------------------------------------------------------------------- - -double ByteString::ToDouble() const -{ - DBG_CHKTHIS( ByteString, DbgCheckByteString ); - - OSL_FAIL("ByteString::ToDouble unusable"); - return 0; -} - -// ----------------------------------------------------------------------- - sal_Bool ByteString::IsLowerAscii() const { DBG_CHKTHIS( ByteString, DbgCheckByteString ); diff --git a/tools/source/string/tustring.cxx b/tools/source/string/tustring.cxx index 5edd160b5d69..9ef026f6cce8 100644 --- a/tools/source/string/tustring.cxx +++ b/tools/source/string/tustring.cxx @@ -155,4 +155,350 @@ double UniString::ToDouble() const return rtl_ustr_toDouble( mpData->maStr ); } +// ----------------------------------------------------------------------- + +xub_StrLen STRING::SearchChar( const STRCODE* pChars, xub_StrLen nIndex ) const +{ + DBG_CHKTHIS( STRING, DBGCHECKSTRING ); + + sal_Int32 nLen = mpData->mnLen; + const STRCODE* pStr = mpData->maStr; + pStr += nIndex; + while ( nIndex < nLen ) + { + STRCODE c = *pStr; + const STRCODE* pCompStr = pChars; + while ( *pCompStr ) + { + if ( *pCompStr == c ) + return nIndex; + ++pCompStr; + } + ++pStr, + ++nIndex; + } + + return STRING_NOTFOUND; +} + +// ----------------------------------------------------------------------- + +xub_StrLen STRING::SearchAndReplace( STRCODE c, STRCODE cRep, xub_StrLen nIndex ) +{ + DBG_CHKTHIS( STRING, DBGCHECKSTRING ); + + sal_Int32 nLen = mpData->mnLen; + const STRCODE* pStr = mpData->maStr; + pStr += nIndex; + while ( nIndex < nLen ) + { + if ( *pStr == c ) + { + ImplCopyData(); + mpData->maStr[nIndex] = cRep; + return nIndex; + } + ++pStr, + ++nIndex; + } + + return STRING_NOTFOUND; +} + +// ----------------------------------------------------------------------- + +STRING& STRING::Reverse() +{ + DBG_CHKTHIS( STRING, DBGCHECKSTRING ); + + if ( !mpData->mnLen ) + return *this; + + // Daten kopieren, wenn noetig + ImplCopyData(); + + // Reverse + sal_Int32 nCount = mpData->mnLen / 2; + for ( sal_Int32 i = 0; i < nCount; ++i ) + { + STRCODE cTemp = mpData->maStr[i]; + mpData->maStr[i] = mpData->maStr[mpData->mnLen-i-1]; + mpData->maStr[mpData->mnLen-i-1] = cTemp; + } + + return *this; +} + +// ----------------------------------------------------------------------- + +xub_StrLen STRING::Match( const STRCODE* pCharStr ) const +{ + DBG_CHKTHIS( STRING, DBGCHECKSTRING ); + + // Ist dieser String leer + if ( !mpData->mnLen ) + return STRING_MATCH; + + // Suche bis Stringende nach dem ersten nicht uebereinstimmenden Zeichen + const STRCODE* pStr = mpData->maStr; + xub_StrLen i = 0; + while ( i < mpData->mnLen ) + { + // Stimmt das Zeichen nicht ueberein, dann abbrechen + if ( *pStr != *pCharStr ) + return i; + ++pStr, + ++pCharStr, + ++i; + } + + return STRING_MATCH; +} + +// ----------------------------------------------------------------------- + +STRING& STRING::Insert( const STRING& rStr, xub_StrLen nPos, xub_StrLen nLen, + xub_StrLen nIndex ) +{ + DBG_CHKTHIS( STRING, DBGCHECKSTRING ); + DBG_CHKOBJ( &rStr, STRING, DBGCHECKSTRING ); + + // Stringlaenge ermitteln + if ( nPos > rStr.mpData->mnLen ) + nLen = 0; + else + { + // Laenge korrigieren, wenn noetig + sal_Int32 nMaxLen = rStr.mpData->mnLen-nPos; + if ( nLen > nMaxLen ) + nLen = static_cast< xub_StrLen >(nMaxLen); + } + + // Ueberlauf abfangen + sal_Int32 nCopyLen = ImplGetCopyLen( mpData->mnLen, nLen ); + + // Ist der einzufuegende String ein Leerstring + if ( !nCopyLen ) + return *this; + + // Index groesser als Laenge + if ( nIndex > mpData->mnLen ) + nIndex = static_cast< xub_StrLen >(mpData->mnLen); + + // Neue Laenge ermitteln und neuen String anlegen + STRINGDATA* pNewData = ImplAllocData( mpData->mnLen+nCopyLen ); + + // String kopieren + memcpy( pNewData->maStr, mpData->maStr, nIndex*sizeof( STRCODE ) ); + memcpy( pNewData->maStr+nIndex, rStr.mpData->maStr+nPos, nCopyLen*sizeof( STRCODE ) ); + memcpy( pNewData->maStr+nIndex+nCopyLen, mpData->maStr+nIndex, + (mpData->mnLen-nIndex)*sizeof( STRCODE ) ); + + // Alte Daten loeschen und Neue zuweisen + STRING_RELEASE((STRING_TYPE *)mpData); + mpData = pNewData; + + return *this; +} + +// ----------------------------------------------------------------------- + +xub_StrLen STRING::GetQuotedTokenCount( const STRING& rQuotedPairs, STRCODE cTok ) const +{ + DBG_CHKTHIS( STRING, DBGCHECKSTRING ); + DBG_CHKOBJ( &rQuotedPairs, STRING, DBGCHECKSTRING ); + DBG_ASSERT( !(rQuotedPairs.Len()%2), "String::GetQuotedTokenCount() - QuotedString%2 != 0" ); + DBG_ASSERT( rQuotedPairs.Search(cTok) == STRING_NOTFOUND, "String::GetQuotedTokenCount() - cTok in QuotedString" ); + + // Leerer String: TokenCount per Definition 0 + if ( !mpData->mnLen ) + return 0; + + xub_StrLen nTokCount = 1; + sal_Int32 nLen = mpData->mnLen; + xub_StrLen nQuotedLen = rQuotedPairs.Len(); + STRCODE cQuotedEndChar = 0; + const STRCODE* pQuotedStr = rQuotedPairs.mpData->maStr; + const STRCODE* pStr = mpData->maStr; + sal_Int32 nIndex = 0; + while ( nIndex < nLen ) + { + STRCODE c = *pStr; + if ( cQuotedEndChar ) + { + // Ende des Quotes erreicht ? + if ( c == cQuotedEndChar ) + cQuotedEndChar = 0; + } + else + { + // Ist das Zeichen ein Quote-Anfang-Zeichen ? + xub_StrLen nQuoteIndex = 0; + while ( nQuoteIndex < nQuotedLen ) + { + if ( pQuotedStr[nQuoteIndex] == c ) + { + cQuotedEndChar = pQuotedStr[nQuoteIndex+1]; + break; + } + else + nQuoteIndex += 2; + } + + // Stimmt das Tokenzeichen ueberein, dann erhoehe TokCount + if ( c == cTok ) + ++nTokCount; + } + + ++pStr, + ++nIndex; + } + + return nTokCount; +} + +// ----------------------------------------------------------------------- + +STRING STRING::GetQuotedToken( xub_StrLen nToken, const STRING& rQuotedPairs, + STRCODE cTok, xub_StrLen& rIndex ) const +{ + DBG_CHKTHIS( STRING, DBGCHECKSTRING ); + DBG_CHKOBJ( &rQuotedPairs, STRING, DBGCHECKSTRING ); + DBG_ASSERT( !(rQuotedPairs.Len()%2), "String::GetQuotedToken() - QuotedString%2 != 0" ); + DBG_ASSERT( rQuotedPairs.Search(cTok) == STRING_NOTFOUND, "String::GetQuotedToken() - cTok in QuotedString" ); + + const STRCODE* pStr = mpData->maStr; + const STRCODE* pQuotedStr = rQuotedPairs.mpData->maStr; + STRCODE cQuotedEndChar = 0; + xub_StrLen nQuotedLen = rQuotedPairs.Len(); + xub_StrLen nLen = (xub_StrLen)mpData->mnLen; + xub_StrLen nTok = 0; + xub_StrLen nFirstChar = rIndex; + xub_StrLen i = nFirstChar; + + // Bestimme die Token-Position und Laenge + pStr += i; + while ( i < nLen ) + { + STRCODE c = *pStr; + if ( cQuotedEndChar ) + { + // Ende des Quotes erreicht ? + if ( c == cQuotedEndChar ) + cQuotedEndChar = 0; + } + else + { + // Ist das Zeichen ein Quote-Anfang-Zeichen ? + xub_StrLen nQuoteIndex = 0; + while ( nQuoteIndex < nQuotedLen ) + { + if ( pQuotedStr[nQuoteIndex] == c ) + { + cQuotedEndChar = pQuotedStr[nQuoteIndex+1]; + break; + } + else + nQuoteIndex += 2; + } + + // Stimmt das Tokenzeichen ueberein, dann erhoehe TokCount + if ( c == cTok ) + { + ++nTok; + + if ( nTok == nToken ) + nFirstChar = i+1; + else + { + if ( nTok > nToken ) + break; + } + } + } + + ++pStr, + ++i; + } + + if ( nTok >= nToken ) + { + if ( i < nLen ) + rIndex = i+1; + else + rIndex = STRING_NOTFOUND; + return Copy( nFirstChar, i-nFirstChar ); + } + else + { + rIndex = STRING_NOTFOUND; + return STRING(); + } +} + +// ----------------------------------------------------------------------- + +sal_Bool STRING::EqualsIgnoreCaseAscii( const STRING& rStr, xub_StrLen nIndex, xub_StrLen nLen ) const +{ + DBG_CHKTHIS( STRING, DBGCHECKSTRING ); + DBG_CHKOBJ( &rStr, STRING, DBGCHECKSTRING ); + + // Are there enough codes for comparing? + if ( nIndex > mpData->mnLen ) + return (rStr.mpData->mnLen == 0); + sal_Int32 nMaxLen = mpData->mnLen-nIndex; + if ( nMaxLen < nLen ) + { + if ( rStr.mpData->mnLen != nMaxLen ) + return sal_False; + nLen = static_cast< xub_StrLen >(nMaxLen); + } + + // String vergleichen + return (ImplStringICompareWithoutZero( mpData->maStr+nIndex, rStr.mpData->maStr, nLen ) == 0); +} + +// ----------------------------------------------------------------------- + +sal_Bool STRING::EqualsIgnoreCaseAscii( const STRCODE* pCharStr, xub_StrLen nIndex, xub_StrLen nLen ) const +{ + DBG_CHKTHIS( STRING, DBGCHECKSTRING ); + + // Are there enough codes for comparing? + if ( nIndex > mpData->mnLen ) + return (*pCharStr == 0); + + return (ImplStringICompare( mpData->maStr+nIndex, pCharStr, nLen ) == 0); +} + +// ----------------------------------------------------------------------- + +StringCompare STRING::CompareIgnoreCaseToAscii( const STRING& rStr, + xub_StrLen nLen ) const +{ + DBG_CHKTHIS( STRING, DBGCHECKSTRING ); + DBG_CHKOBJ( &rStr, STRING, DBGCHECKSTRING ); + + // Auf Gleichheit der Pointer testen + if ( mpData == rStr.mpData ) + return COMPARE_EQUAL; + + // Maximale Laenge ermitteln + if ( mpData->mnLen < nLen ) + nLen = static_cast< xub_StrLen >(mpData->mnLen+1); + if ( rStr.mpData->mnLen < nLen ) + nLen = static_cast< xub_StrLen >(rStr.mpData->mnLen+1); + + // String vergleichen + sal_Int32 nCompare = ImplStringICompareWithoutZero( mpData->maStr, rStr.mpData->maStr, nLen ); + + // Rueckgabewert anpassen + if ( nCompare == 0 ) + return COMPARE_EQUAL; + else if ( nCompare < 0 ) + return COMPARE_LESS; + else + return COMPARE_GREATER; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |