diff options
Diffstat (limited to 'svtools/source/misc')
29 files changed, 243 insertions, 3275 deletions
diff --git a/svtools/source/misc/config.src b/svtools/source/misc/config.src deleted file mode 100644 index e11aeb86f402..000000000000 --- a/svtools/source/misc/config.src +++ /dev/null @@ -1,66 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: config.src,v $ - * $Revision: 1.29 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include <svtools/svtools.hrc> - -String STR_WARNING_ITEM -{ - Text [ en-US ] = "Incorrect Version!" ; -}; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/svtools/source/misc/documentlockfile.cxx b/svtools/source/misc/documentlockfile.cxx deleted file mode 100644 index 990f1ba58d73..000000000000 --- a/svtools/source/misc/documentlockfile.cxx +++ /dev/null @@ -1,238 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: documentlockfile.cxx,v $ - * - * $Revision: 1.3.82.1 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_svtools.hxx" - -#include <stdio.h> - -#include <com/sun/star/ucb/XSimpleFileAccess.hpp> -#include <com/sun/star/ucb/XCommandEnvironment.hpp> -#include <com/sun/star/ucb/InsertCommandArgument.hpp> -#include <com/sun/star/ucb/NameClashException.hpp> -#include <com/sun/star/io/WrongFormatException.hpp> - -#include <osl/time.h> -#include <osl/security.hxx> -#include <osl/socket.hxx> - -#include <rtl/string.hxx> -#include <rtl/ustring.hxx> -#include <rtl/strbuf.hxx> -#include <rtl/ustrbuf.hxx> - -#include <comphelper/processfactory.hxx> - -#include <tools/urlobj.hxx> -#include <unotools/bootstrap.hxx> - -#include <ucbhelper/content.hxx> - -#include <svtools/useroptions.hxx> - -#include <svtools/documentlockfile.hxx> - -using namespace ::com::sun::star; - -namespace svt { - -sal_Bool DocumentLockFile::m_bAllowInteraction = sal_True; - -// ---------------------------------------------------------------------- -DocumentLockFile::DocumentLockFile( const ::rtl::OUString& aOrigURL, const uno::Reference< lang::XMultiServiceFactory >& xFactory ) -: LockFileCommon( aOrigURL, xFactory, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".~lock." ) ) ) -{ -} - -// ---------------------------------------------------------------------- -DocumentLockFile::~DocumentLockFile() -{ -} - -// ---------------------------------------------------------------------- -void DocumentLockFile::WriteEntryToStream( uno::Sequence< ::rtl::OUString > aEntry, uno::Reference< io::XOutputStream > xOutput ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - ::rtl::OUStringBuffer aBuffer; - - for ( sal_Int32 nEntryInd = 0; nEntryInd < aEntry.getLength(); nEntryInd++ ) - { - aBuffer.append( EscapeCharacters( aEntry[nEntryInd] ) ); - if ( nEntryInd < aEntry.getLength() - 1 ) - aBuffer.append( (sal_Unicode)',' ); - else - aBuffer.append( (sal_Unicode)';' ); - } - - ::rtl::OString aStringData( ::rtl::OUStringToOString( aBuffer.makeStringAndClear(), RTL_TEXTENCODING_UTF8 ) ); - uno::Sequence< sal_Int8 > aData( (sal_Int8*)aStringData.getStr(), aStringData.getLength() ); - xOutput->writeBytes( aData ); -} - -// ---------------------------------------------------------------------- -sal_Bool DocumentLockFile::CreateOwnLockFile() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - try - { - uno::Reference< io::XStream > xTempFile( - m_xFactory->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.io.TempFile" ) ), - uno::UNO_QUERY_THROW ); - uno::Reference< io::XSeekable > xSeekable( xTempFile, uno::UNO_QUERY_THROW ); - - uno::Reference< io::XInputStream > xInput = xTempFile->getInputStream(); - uno::Reference< io::XOutputStream > xOutput = xTempFile->getOutputStream(); - - if ( !xInput.is() || !xOutput.is() ) - throw uno::RuntimeException(); - - uno::Sequence< ::rtl::OUString > aNewEntry = GenerateOwnEntry(); - WriteEntryToStream( aNewEntry, xOutput ); - xOutput->closeOutput(); - - xSeekable->seek( 0 ); - - uno::Reference < ::com::sun::star::ucb::XCommandEnvironment > xEnv; - ::ucbhelper::Content aTargetContent( m_aURL, xEnv ); - - ucb::InsertCommandArgument aInsertArg; - aInsertArg.Data = xInput; - aInsertArg.ReplaceExisting = sal_False; - uno::Any aCmdArg; - aCmdArg <<= aInsertArg; - aTargetContent.executeCommand( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "insert" ) ), aCmdArg ); - - // try to let the file be hidden if possible - try { - aTargetContent.setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsHidden" ) ), uno::makeAny( sal_True ) ); - } catch( uno::Exception& ) {} - } - catch( ucb::NameClashException& ) - { - return sal_False; - } - - return sal_True; -} - -// ---------------------------------------------------------------------- -uno::Sequence< ::rtl::OUString > DocumentLockFile::GetLockData() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - uno::Reference< io::XInputStream > xInput = OpenStream(); - if ( !xInput.is() ) - throw uno::RuntimeException(); - - const sal_Int32 nBufLen = 32000; - uno::Sequence< sal_Int8 > aBuffer( nBufLen ); - - sal_Int32 nRead = 0; - - nRead = xInput->readBytes( aBuffer, nBufLen ); - xInput->closeInput(); - - if ( nRead == nBufLen ) - throw io::WrongFormatException(); - - sal_Int32 nCurPos = 0; - return ParseEntry( aBuffer, nCurPos ); -} - -// ---------------------------------------------------------------------- -uno::Reference< io::XInputStream > DocumentLockFile::OpenStream() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - uno::Reference< lang::XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory(); - uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess > xSimpleFileAccess( - xFactory->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.ucb.SimpleFileAccess") ), - uno::UNO_QUERY_THROW ); - - // the file can be opened readonly, no locking will be done - return xSimpleFileAccess->openFileRead( m_aURL ); -} - -// ---------------------------------------------------------------------- -sal_Bool DocumentLockFile::OverwriteOwnLockFile() -{ - // allows to overwrite the lock file with the current data - try - { - uno::Reference < ::com::sun::star::ucb::XCommandEnvironment > xEnv; - ::ucbhelper::Content aTargetContent( m_aURL, xEnv ); - - uno::Sequence< ::rtl::OUString > aNewEntry = GenerateOwnEntry(); - - uno::Reference< io::XStream > xStream = aTargetContent.openWriteableStreamNoLock(); - uno::Reference< io::XOutputStream > xOutput = xStream->getOutputStream(); - uno::Reference< io::XTruncate > xTruncate( xOutput, uno::UNO_QUERY_THROW ); - - xTruncate->truncate(); - WriteEntryToStream( aNewEntry, xOutput ); - xOutput->closeOutput(); - } - catch( uno::Exception& ) - { - return sal_False; - } - - return sal_True; -} - -// ---------------------------------------------------------------------- -void DocumentLockFile::RemoveFile() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - // TODO/LATER: the removing is not atomar, is it possible in general to make it atomar? - uno::Sequence< ::rtl::OUString > aNewEntry = GenerateOwnEntry(); - uno::Sequence< ::rtl::OUString > aFileData = GetLockData(); - - if ( aFileData.getLength() < LOCKFILE_ENTRYSIZE ) - throw io::WrongFormatException(); - - if ( !aFileData[LOCKFILE_SYSUSERNAME_ID].equals( aNewEntry[LOCKFILE_SYSUSERNAME_ID] ) - || !aFileData[LOCKFILE_LOCALHOST_ID].equals( aNewEntry[LOCKFILE_LOCALHOST_ID] ) - || !aFileData[LOCKFILE_USERURL_ID].equals( aNewEntry[LOCKFILE_USERURL_ID] ) ) - throw io::IOException(); // not the owner, access denied - - uno::Reference< lang::XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory(); - uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess > xSimpleFileAccess( - xFactory->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.ucb.SimpleFileAccess") ), - uno::UNO_QUERY_THROW ); - xSimpleFileAccess->kill( m_aURL ); -} - -} // namespace svt - diff --git a/svtools/source/misc/ehdl.cxx b/svtools/source/misc/ehdl.cxx index 6e89193f1b6b..4084aa47bc80 100644 --- a/svtools/source/misc/ehdl.cxx +++ b/svtools/source/misc/ehdl.cxx @@ -45,7 +45,7 @@ #include <svtools/ehdl.hxx> #include <svtools/svtdata.hxx> -#include <svtools/svtools.hrc> +#include <svl/svtools.hrc> #include "sfxecode.hxx" //========================================================================= diff --git a/svtools/source/misc/ehdl.src b/svtools/source/misc/ehdl.src index ed32172a92e2..5267d13765c3 100644 --- a/svtools/source/misc/ehdl.src +++ b/svtools/source/misc/ehdl.src @@ -29,7 +29,7 @@ ************************************************************************/ #define __RSC -#include <svtools/svtools.hrc> +#include <svl/svtools.hrc> #include "sfxecode.hxx" // pragma ---------------------------------------------------------------- diff --git a/svtools/source/misc/embedhlp.cxx b/svtools/source/misc/embedhlp.cxx index edddb7c1ab6d..3554f6955171 100644 --- a/svtools/source/misc/embedhlp.cxx +++ b/svtools/source/misc/embedhlp.cxx @@ -32,7 +32,7 @@ #include <svtools/embedhlp.hxx> #include <svtools/filter.hxx> -#include <svtools/svtools.hrc> +#include <svl/svtools.hrc> #include <svtools/svtdata.hxx> #include <comphelper/embeddedobjectcontainer.hxx> @@ -57,6 +57,7 @@ #include <cppuhelper/implbase4.hxx> #include "vcl/svapp.hxx" #include <rtl/logfile.hxx> +#include <vos/mutex.hxx> using namespace com::sun::star; diff --git a/svtools/source/misc/errtxt.src b/svtools/source/misc/errtxt.src index ebd922bfedf7..3ab58ef92dbf 100644 --- a/svtools/source/misc/errtxt.src +++ b/svtools/source/misc/errtxt.src @@ -29,7 +29,7 @@ ************************************************************************/ #define __RSC -#include <svtools/svtools.hrc> +#include <svl/svtools.hrc> #include "sfxecode.hxx" // pragma ---------------------------------------------------------------- Resource RID_ERRCTX diff --git a/svtools/source/misc/flbytes.cxx b/svtools/source/misc/flbytes.cxx deleted file mode 100644 index acf53d9b3e94..000000000000 --- a/svtools/source/misc/flbytes.cxx +++ /dev/null @@ -1,432 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: flbytes.cxx,v $ - * $Revision: 1.6 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_svtools.hxx" -#include <vcl/svapp.hxx> -#include <flbytes.hxx> - -#ifndef _SVSTDARR_ULONGS_DECL -#define _SVSTDARR_ULONGS -#include <svtools/svstdarr.hxx> -#undef _SVSTDARR_ULONGS -#endif - -namespace unnamed_svtools_flbytes {} using namespace unnamed_svtools_flbytes; - // unnamed namespaces don't work well yet - -//============================================================================ -namespace unnamed_svtools_flbytes { - -inline ULONG MyMin( long a, long b ) -{ - return Max( long( Min( a , b ) ), 0L ); -} - -} - -//============================================================================ -// -// SvFillLockBytes -// -//============================================================================ - -TYPEINIT1(SvFillLockBytes, SvLockBytes); - -//============================================================================ -SvFillLockBytes::SvFillLockBytes( SvLockBytes* pLockBytes ) - : xLockBytes( pLockBytes ), - nFilledSize( 0 ), - bTerminated( FALSE ) -{ -} - -//============================================================================ -ErrCode SvFillLockBytes::ReadAt( ULONG nPos, void* pBuffer, ULONG nCount, - ULONG *pRead ) const -{ - if( bTerminated ) - return xLockBytes->ReadAt( nPos, pBuffer, nCount, pRead ); - else - { - ULONG nWanted = nPos + nCount; - if( IsSynchronMode() ) - { - while( nWanted > nFilledSize && !bTerminated ) - Application::Yield(); - return xLockBytes->ReadAt( nPos, pBuffer, nCount, pRead ); - } - else - { - ULONG nRead = MyMin( nCount, long( nFilledSize ) - nPos ); - ULONG nErr = xLockBytes->ReadAt( nPos, pBuffer, nRead, pRead ); - return ( !nCount || nRead == nCount || nErr ) ? - nErr : ERRCODE_IO_PENDING; - } - } -} - -//============================================================================ -ErrCode SvFillLockBytes::WriteAt( ULONG nPos, const void* pBuffer, - ULONG nCount, ULONG *pWritten ) -{ - if( bTerminated ) - return xLockBytes->WriteAt( nPos, pBuffer, nCount, pWritten ); - else - { - ULONG nWanted = nPos + nCount; - if( IsSynchronMode() ) - { - while( nWanted > nFilledSize && !bTerminated ) - Application::Yield(); - return xLockBytes->WriteAt( nPos, pBuffer, nCount, pWritten ); - } - else - { - ULONG nRead = MyMin( nCount, long( nFilledSize ) - nPos ); - ULONG nErr = xLockBytes->WriteAt( nPos, pBuffer, nRead, pWritten ); - return ( !nCount || nRead == nCount || nErr ) ? - nErr : ERRCODE_IO_PENDING; - } - } -} - -//============================================================================ -ErrCode SvFillLockBytes::Flush() const -{ - return xLockBytes->Flush( ); -} - -//============================================================================ -ErrCode SvFillLockBytes::SetSize( ULONG nSize ) -{ - return xLockBytes->SetSize( nSize ); -} - -//============================================================================ -ErrCode SvFillLockBytes::LockRegion( ULONG nPos, ULONG nCount, LockType eType) -{ - return xLockBytes->LockRegion( nPos, nCount, eType ); -} - -//============================================================================ -ErrCode SvFillLockBytes::UnlockRegion( - ULONG nPos, ULONG nCount, LockType eType) -{ - return xLockBytes->UnlockRegion( nPos, nCount, eType ); -} - -//============================================================================ -ErrCode SvFillLockBytes::Stat( - SvLockBytesStat* pStat, SvLockBytesStatFlag eFlag) const -{ - return xLockBytes->Stat( pStat, eFlag ); -} - -//============================================================================ -ErrCode SvFillLockBytes::FillAppend( const void* pBuffer, ULONG nCount, ULONG *pWritten ) -{ - ErrCode nRet = xLockBytes->WriteAt( - nFilledSize, pBuffer, nCount, pWritten ); - nFilledSize += *pWritten; - return nRet; -} - -//============================================================================ -void SvFillLockBytes::Terminate() -{ - bTerminated = TRUE; -} - -//============================================================================ -SV_DECL_IMPL_REF_LIST( SvLockBytes, SvLockBytes* ) - -//============================================================================ -// -// SvSyncLockBytes -// -//============================================================================ - -TYPEINIT1(SvSyncLockBytes, SvOpenLockBytes); - -//============================================================================ -// virtual -ErrCode SvSyncLockBytes::ReadAt(ULONG nPos, void * pBuffer, ULONG nCount, - ULONG * pRead) const -{ - for (ULONG nReadTotal = 0;;) - { - ULONG nReadCount = 0; - ErrCode nError = m_xAsyncLockBytes->ReadAt(nPos, pBuffer, nCount, - &nReadCount); - nReadTotal += nReadCount; - if (nError != ERRCODE_IO_PENDING || !IsSynchronMode()) - { - if (pRead) - *pRead = nReadTotal; - return nError; - } - nPos += nReadCount; - pBuffer = static_cast< sal_Char * >(pBuffer) + nReadCount; - nCount -= nReadCount; - Application::Yield(); - } -} - -//============================================================================ -// virtual -ErrCode SvSyncLockBytes::WriteAt(ULONG nPos, const void * pBuffer, - ULONG nCount, ULONG * pWritten) -{ - for (ULONG nWrittenTotal = 0;;) - { - ULONG nWrittenCount = 0; - ErrCode nError = m_xAsyncLockBytes->WriteAt(nPos, pBuffer, nCount, - &nWrittenCount); - nWrittenTotal += nWrittenCount; - if (nError != ERRCODE_IO_PENDING || !IsSynchronMode()) - { - if (pWritten) - *pWritten = nWrittenTotal; - return nError; - } - nPos += nWrittenCount; - pBuffer = static_cast< sal_Char const * >(pBuffer) + nWrittenCount; - nCount -= nWrittenCount; - Application::Yield(); - } -} - -//============================================================================ -// -// SvCompositeLockBytes -// -//============================================================================ - -struct SvCompositeLockBytes_Impl -{ - SvLockBytesMemberList aLockBytes; - SvULongs aPositions; - SvULongs aOffsets; - BOOL bPending; - ULONG RelativeOffset( ULONG nPos ) const; - ErrCode ReadWrite_Impl( - ULONG nPos, void* pBuffer, ULONG nCount, ULONG* pProcessed, - BOOL bRead ); - SvCompositeLockBytes_Impl() : bPending( FALSE ){} -}; - -//============================================================================ -ULONG SvCompositeLockBytes_Impl::RelativeOffset( ULONG nPos ) const -{ - const SvULongs& rPositions = aPositions; - const SvULongs& rOffsets = aOffsets; - - USHORT nMinPos = 0; - USHORT nListCount = rPositions.Count(); - - // Erster Lockbytes, der bearbeitet werden muss - while( nMinPos + 1 < nListCount && rPositions[ nMinPos + 1 ] <= nPos ) - nMinPos ++; - ULONG nSectionStart = rPositions[ nMinPos ]; - if( nSectionStart > nPos ) - return ULONG_MAX; - return rOffsets[ nMinPos ] + nPos - nSectionStart; -} - -//============================================================================ -ErrCode SvCompositeLockBytes_Impl::ReadWrite_Impl( - ULONG nPos, void* pBuffer, ULONG nCount, ULONG* pProcessed, - BOOL bRead ) -{ - ErrCode nErr = ERRCODE_NONE; - SvULongs& rPositions = aPositions; - SvULongs& rOffsets = aOffsets; - SvLockBytesMemberList& rLockBytes = aLockBytes; - - ULONG nBytes = nCount; - USHORT nListCount = rPositions.Count(); - USHORT nMinPos = 0; - - // Erster Lockbytes, der bearbeitet werden muss - while( nMinPos + 1 < nListCount && rPositions[ nMinPos + 1 ] <= nPos ) - nMinPos ++; - ULONG nSectionStart = rPositions[ nMinPos ]; - - if( nSectionStart > nPos ) - { - // Es wird aus fuehrendem Leerbereich gearbeitet - *pProcessed = 0; - return ERRCODE_IO_CANTREAD; - } - - ULONG nDone; - while( nMinPos < nListCount ) - { - ULONG nToProcess; - ULONG nSectionStop; - if( nMinPos + 1 < nListCount ) - { - nSectionStop = rPositions[ nMinPos + 1 ]; - nToProcess = MyMin( long( nSectionStop ) - nPos, nBytes ); - } - else - { - nToProcess = nBytes; - nSectionStop = 0; - } - ULONG nAbsPos = nPos - nSectionStart + rOffsets[ nMinPos ]; - SvLockBytes* pLB = rLockBytes.GetObject( nMinPos ); - if( bRead ) - nErr = pLB->ReadAt( nAbsPos, pBuffer, nToProcess, &nDone ); - else - nErr = pLB->WriteAt( nAbsPos, pBuffer, nToProcess, &nDone ); - nBytes -= nDone; - if( nErr || nDone < nToProcess || !nBytes ) - { - *pProcessed = nCount - nBytes; - // Wenn aus dem letzten LockBytes nichts mehr gelesen wurde und - // bPending gesetzt ist, Pending zurueck - if( !nDone && nMinPos == nListCount - 1 ) - return bPending ? ERRCODE_IO_PENDING : nErr; - else return nErr; - } - pBuffer = static_cast< sal_Char * >(pBuffer) + nDone; - nPos += nDone; - nSectionStart = nSectionStop; - nMinPos++; - } - return nErr; -} - -//============================================================================ -TYPEINIT1(SvCompositeLockBytes, SvLockBytes); - -//============================================================================ -SvCompositeLockBytes::SvCompositeLockBytes() - : pImpl( new SvCompositeLockBytes_Impl ) -{ -} - -//============================================================================ -SvCompositeLockBytes::~SvCompositeLockBytes() -{ - delete pImpl; -} - -//============================================================================ -void SvCompositeLockBytes::SetIsPending( BOOL bSet ) -{ - pImpl->bPending = bSet; -} - -//============================================================================ -ULONG SvCompositeLockBytes::RelativeOffset( ULONG nPos ) const -{ - return pImpl->RelativeOffset( nPos ); -} - -//============================================================================ -ErrCode SvCompositeLockBytes::ReadAt( - ULONG nPos, void* pBuffer, ULONG nCount, ULONG* pRead ) const -{ - return pImpl->ReadWrite_Impl( nPos, pBuffer, nCount, pRead, TRUE ); -} - -//============================================================================ -ErrCode SvCompositeLockBytes::WriteAt( - ULONG nPos, const void* pBuffer, ULONG nCount, ULONG* pWritten ) -{ - return pImpl->ReadWrite_Impl( - nPos, const_cast< void * >(pBuffer), nCount, pWritten, FALSE ); -} - -//============================================================================ -ErrCode SvCompositeLockBytes::Flush() const -{ - SvLockBytesMemberList& rLockBytes = pImpl->aLockBytes; - ErrCode nErr = ERRCODE_NONE; - for( USHORT nCount = (USHORT)rLockBytes.Count(); !nErr && nCount--; ) - nErr = rLockBytes.GetObject( nCount )->Flush(); - return nErr; -} - -//============================================================================ -ErrCode SvCompositeLockBytes::SetSize( ULONG ) -{ - DBG_ERROR( "not implemented" ); - return ERRCODE_IO_NOTSUPPORTED; -} - -//============================================================================ -ErrCode SvCompositeLockBytes::LockRegion( ULONG, ULONG, LockType ) -{ - DBG_ERROR( "not implemented" ); - return ERRCODE_IO_NOTSUPPORTED; -} - -//============================================================================ -ErrCode SvCompositeLockBytes::UnlockRegion( - ULONG, ULONG, LockType ) -{ - DBG_ERROR( "not implemented" ); - return ERRCODE_IO_NOTSUPPORTED; -} - -//============================================================================ -ErrCode SvCompositeLockBytes::Stat( - SvLockBytesStat* pStat, SvLockBytesStatFlag eFlag) const -{ - USHORT nMax = pImpl->aPositions.Count() - 1; - - SvLockBytesStat aStat; - ErrCode nErr = pImpl->aLockBytes.GetObject( nMax )->Stat( &aStat, eFlag ); - pStat->nSize = pImpl->aPositions[ nMax ] + aStat.nSize; - - return nErr; -} - -//============================================================================ -void SvCompositeLockBytes::Append( - SvLockBytes* pLockBytes, ULONG nPos, ULONG nOffset ) -{ - USHORT nCount = pImpl->aOffsets.Count(); - pImpl->aLockBytes.Insert( pLockBytes, nCount ); - pImpl->aPositions.Insert( nPos, nCount ); - pImpl->aOffsets.Insert( nOffset, nCount ); -} - -//============================================================================ -SvLockBytes* SvCompositeLockBytes::GetLastLockBytes() const -{ - return pImpl->aLockBytes.Count() ? - pImpl->aLockBytes.GetObject( pImpl->aLockBytes.Count() - 1 ) : 0; -} - diff --git a/svtools/source/misc/helpagent.src b/svtools/source/misc/helpagent.src index 3b9e2a450ec1..181583bc8f6d 100644 --- a/svtools/source/misc/helpagent.src +++ b/svtools/source/misc/helpagent.src @@ -29,7 +29,7 @@ ************************************************************************/ #ifndef _SVTOOLS_HRC -#include <svtools/svtools.hrc> +#include <svl/svtools.hrc> #endif Bitmap BMP_HELP_AGENT_IMAGE diff --git a/svtools/source/misc/helpagentwindow.cxx b/svtools/source/misc/helpagentwindow.cxx index 368c55a94ade..51cd7ebfb740 100644 --- a/svtools/source/misc/helpagentwindow.cxx +++ b/svtools/source/misc/helpagentwindow.cxx @@ -39,7 +39,7 @@ #include <svtools/svtdata.hxx> #ifndef _SVTOOLS_HRC -#include <svtools/svtools.hrc> +#include <svl/svtools.hrc> #endif #ifndef _SVT_HELPID_HRC #include <svtools/helpid.hrc> diff --git a/svtools/source/misc/imagemgr.cxx b/svtools/source/misc/imagemgr.cxx index 314242063711..76752b27354e 100644 --- a/svtools/source/misc/imagemgr.cxx +++ b/svtools/source/misc/imagemgr.cxx @@ -55,9 +55,10 @@ #include <rtl/logfile.hxx> #include <unotools/configmgr.hxx> -#include <svtools/svtools.hrc> +#include <svl/svtools.hrc> #include "imagemgr.hrc" #include <svtools/svtdata.hxx> +#include <vos/mutex.hxx> // globals ******************************************************************* diff --git a/svtools/source/misc/imagemgr.src b/svtools/source/misc/imagemgr.src index 0aada34305da..e082398beaa1 100644 --- a/svtools/source/misc/imagemgr.src +++ b/svtools/source/misc/imagemgr.src @@ -29,7 +29,7 @@ ************************************************************************/ // includes ****************************************************************** -#include <svtools/svtools.hrc> +#include <svl/svtools.hrc> #include "imagemgr.hrc" // images ******************************************************************** diff --git a/svtools/source/misc/imap.cxx b/svtools/source/misc/imap.cxx index 9fb60111094e..df7760f7931b 100644 --- a/svtools/source/misc/imap.cxx +++ b/svtools/source/misc/imap.cxx @@ -36,7 +36,7 @@ #include <vcl/mapmod.hxx> #include <vcl/window.hxx> -#include "urihelper.hxx" +#include "svl/urihelper.hxx" #include <svtools/imap.hxx> #include <svtools/imapobj.hxx> #include <svtools/imapcirc.hxx> diff --git a/svtools/source/misc/imap2.cxx b/svtools/source/misc/imap2.cxx index b1e03a574188..1dd10c36c81a 100644 --- a/svtools/source/misc/imap2.cxx +++ b/svtools/source/misc/imap2.cxx @@ -43,7 +43,7 @@ #endif #include <sot/formats.hxx> -#include "urihelper.hxx" +#include "svl/urihelper.hxx" #include <svtools/imap.hxx> #include <svtools/imap.hxx> #include <svtools/imapobj.hxx> diff --git a/svtools/source/misc/inidef.cxx b/svtools/source/misc/inidef.cxx deleted file mode 100644 index bdecd1b833dd..000000000000 --- a/svtools/source/misc/inidef.cxx +++ /dev/null @@ -1,269 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: inidef.cxx,v $ - * $Revision: 1.6 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_svtools.hxx" - - -#include <tools/string.hxx> -#include "inetdef.hxx" -#include "inidef.hxx" - -//======================================================================== - -class SfxStdIniDef_Impl: public SfxIniDefaulter -{ -public: - SfxStdIniDef_Impl( SfxIniDefaultManager *pDefMgr ) - : SfxIniDefaulter( pDefMgr ) - {} - virtual BOOL QueryDefault( String &rValue, const SfxIniEntry &rEntry ); -}; - -//------------------------------------------------------------------------- - -BOOL SfxStdIniDef_Impl::QueryDefault( String &rValue, const SfxIniEntry &rEntry ) -{ - switch ( rEntry.GetKey() ) - { - case SFX_KEY_BROWSERRESTORE: - { - rValue = "1"; - return TRUE; - } - - case SFX_KEY_INET_HOME: - { - if ( System::GetLanguage() == LANGUAGE_GERMAN ) - rValue = "http://www.stardivision.de"; - else - rValue = "http://www.stardivision.com"; - return TRUE; - } - - case SFX_KEY_INET_MEMCACHE: - rValue = "4"; - return TRUE; - - case SFX_KEY_INET_DISKCACHE: - rValue = "2048"; - return TRUE; - - case SFX_KEY_INET_CACHEEXPIRATION: - rValue = "3"; - return TRUE; - - case SFX_KEY_INET_MAXHTTPCONS: - rValue = "4"; - return TRUE; - - case SFX_KEY_INET_MAXFTPCONS: - rValue = "2"; - return TRUE; - -// case SFX_KEY_INET_JAVAMINHEAP: -// rValue = "256"; -// return TRUE; - -// case SFX_KEY_INET_JAVAMAXHEAP: -// rValue = ""; -// return TRUE; - - case SFX_KEY_INET_USERAGENT: - rValue = INET_DEF_CALLERNAME; - return TRUE; - - case SFX_KEY_INET_EXE_JAVASCRIPT: -#ifdef SOLAR_JAVA - rValue = "0"; // noch "0", solange es noch soviel Bugs gibt -#else - rValue = "0"; // immer "0" -#endif - return TRUE; - - case SFX_KEY_INET_EXE_PLUGIN: - rValue = "1"; - return TRUE; - -/* case SFX_KEY_INET_JAVA_ENABLE: -#ifdef SOLAR_JAVA - rValue = "1"; -#else - rValue = "0"; -#endif - return TRUE; */ - -// case SFX_KEY_INET_NETACCESS: -// rValue = "2"; -// return TRUE; - - case SFX_KEY_INET_CHANNELS: - rValue = "1"; - return TRUE; - - case SFX_KEY_BASIC_ENABLE: - rValue = "1"; - return TRUE; - - case SFX_KEY_INET_COOKIES: - rValue = "1"; - return TRUE; - - case SFX_KEY_ICONGRID: - rValue = "100;70;0"; - return TRUE; - - case SFX_KEY_METAFILEPRINT: - rValue = "1"; - return TRUE; - } - - return SfxIniDefaulter::QueryDefault( rValue, rEntry ); -} - -//========================================================================= - -SfxIniDefaultManager::SfxIniDefaultManager() -: _pList( new SfxIniDefaulterList ) -{ - new SfxStdIniDef_Impl( this ); -} - -//------------------------------------------------------------------------- - -SfxIniDefaultManager::~SfxIniDefaultManager() -{ - if ( _pList ) - { - for ( USHORT n = _pList->Count(); n--; ) - delete _pList->GetObject(n); - delete _pList; - } -} - -//------------------------------------------------------------------------- - -BOOL SfxIniDefaultManager::QueryDefault -( - String& rValue, /* out: Default-Wert f"ur 'rEntry' - (Default ist Leerstring) */ - const SfxIniEntry& rEntry // in: Beschreibung des Eintrags -) - -/* [Beschreibung] - - "Uber diese interne Methode besorgt sich der <SfxIniManager> den - Default f"ur einen in 'rEntry' beschriebenen Eintrag. -*/ - -{ - for ( USHORT n = _pList->Count(); n--; ) - if ( _pList->GetObject(n)->QueryDefault( rValue, rEntry ) ) - return TRUE; - return FALSE; -} - -//========================================================================= - -SfxIniDefaulter::SfxIniDefaulter( SfxIniDefaultManager *pManager ) - -/* [Beschreibung] - - Der Ctor dieser Klasse meldet die neue Instanz automatisch am - <SfxiniDefaultManager> 'pManager' an. -*/ - -: _pManager( pManager ) - -{ - pManager->Insert( this ); -} - -//------------------------------------------------------------------------- - -SfxIniDefaulter::~SfxIniDefaulter() - -/* [Beschreibung] - - Der Dtor dieser Klasse meldet die neue Instanz automatisch am - <SfxiniDefaultManager> ab, der im Ctor angegeben wurde. -*/ - -{ - _pManager->Remove( this ); -} - -//------------------------------------------------------------------------- - -BOOL SfxIniDefaulter::QueryDefault -( - String& rValue, /* out: Default-Wert f"ur 'rEntry' - (Default ist Leerstring) */ - const SfxIniEntry& rEntry // in: Beschreibung des Eintrags -) - -/* [Beschreibung] - - Diese virtuelle Methode mu\s "uberladen werden. Sie soll dann in - 'rValue' einen Default-Wert f"ur den in 'rEntry' beschriebenen - ini-Eintrag setzen, falls ihr dieser bekannt ist. - - - [Returnwert] - - TRUE In 'rValue' befindet sich der Default-Wert. - - FALSE F"ur diesen Eintrag ist kein Default-Wert bekannt. - -*/ - -{ - return FALSE; -}; - -//======================================================================== - -SfxIniEntry::SfxIniEntry -( - const String& aGroup, - const String& aKey, - SfxIniGroup eGroup, - SfxIniKey eKey, - USHORT nIndex -) -: _aGroup( aGroup ), - _aKey( aKey ), - _eGroup( eGroup ), - _eKey( eKey ), - _nIndex( nIndex ) -{ -} - - diff --git a/svtools/source/misc/iniman.src b/svtools/source/misc/iniman.src deleted file mode 100644 index afc129318653..000000000000 --- a/svtools/source/misc/iniman.src +++ /dev/null @@ -1,68 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: iniman.src,v $ - * $Revision: 1.27 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include <svtools/svtools.hrc> - -ErrorBox ERRBOX_CHECK_PLZ -{ - BUTTONS = WB_OK ; - Message [ en-US ] = "The ZIP code specified is invalid.\nA ZIP code should begin with a number (or in some cases a letter) and\ncan only contain numbers, letters, spaces and dashes."; -}; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/svtools/source/misc/itemdel.cxx b/svtools/source/misc/itemdel.cxx new file mode 100644 index 000000000000..9db70f852d30 --- /dev/null +++ b/svtools/source/misc/itemdel.cxx @@ -0,0 +1,138 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: itemdel.cxx,v $ + * $Revision: 1.9 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svtools.hxx" + +#include "itemdel.hxx" +#include <vcl/svapp.hxx> +#include <tools/errcode.hxx> +#include <limits.h> + +#include <svtools/svtdata.hxx> +#include <svl/svarray.hxx> +#include <svl/itempool.hxx> + +// STATIC DATA ----------------------------------------------------------- + +DBG_NAME(SfxItemDesruptor_Impl); + +// ----------------------------------------------------------------------- + +class SfxItemDesruptor_Impl +{ + SfxPoolItem *pItem; + Link aLink; + +private: + DECL_LINK( Delete, void * ); + SfxItemDesruptor_Impl( const SfxItemDesruptor_Impl& ); // n.i. + +public: + SfxItemDesruptor_Impl( SfxPoolItem *pItemToDesrupt ); + ~SfxItemDesruptor_Impl(); +}; + +SV_DECL_PTRARR( SfxItemDesruptorList_Impl, SfxItemDesruptor_Impl*, 4, 4 ) + +// ------------------------------------------------------------------------ +SfxItemDesruptor_Impl::SfxItemDesruptor_Impl( SfxPoolItem *pItemToDesrupt ): + pItem(pItemToDesrupt), + aLink( LINK(this, SfxItemDesruptor_Impl, Delete) ) +{ + DBG_CTOR(SfxItemDesruptor_Impl, 0); + + DBG_ASSERT( 0 == pItem->GetRefCount(), "desrupting pooled item" ); + pItem->SetKind( SFX_ITEMS_DELETEONIDLE ); + + // im Idle abarbeiten + GetpApp()->InsertIdleHdl( aLink, 1 ); + + // und in Liste eintragen (damit geflusht werden kann) + SfxItemDesruptorList_Impl* &rpList = ImpSvtData::GetSvtData().pItemDesruptList; + if ( !rpList ) + rpList = new SfxItemDesruptorList_Impl; + const SfxItemDesruptor_Impl *pThis = this; + rpList->Insert( pThis, rpList->Count() ); +} + +// ------------------------------------------------------------------------ +SfxItemDesruptor_Impl::~SfxItemDesruptor_Impl() +{ + DBG_DTOR(SfxItemDesruptor_Impl, 0); + + // aus Idle-Handler austragen + GetpApp()->RemoveIdleHdl( aLink ); + + // und aus Liste austragen + SfxItemDesruptorList_Impl* &rpList = ImpSvtData::GetSvtData().pItemDesruptList; + DBG_ASSERT( rpList, "no DesruptorList" ); + const SfxItemDesruptor_Impl *pThis = this; + if ( rpList ) HACK(warum?) + rpList->Remove( rpList->GetPos(pThis) ); + + // reset RefCount (was set to SFX_ITEMS_SPECIAL before!) + pItem->SetRefCount( 0 ); + //DBG_CHKOBJ( pItem, SfxPoolItem, 0 ); + delete pItem; +} + +// ------------------------------------------------------------------------ +IMPL_LINK( SfxItemDesruptor_Impl, Delete, void *, EMPTYARG ) +{ + {DBG_CHKTHIS(SfxItemDesruptor_Impl, 0);} + delete this; + return 0; +} + +// ------------------------------------------------------------------------ +SfxPoolItem* DeleteItemOnIdle( SfxPoolItem* pItem ) +{ + DBG_ASSERT( 0 == pItem->GetRefCount(), "deleting item in use" ); + new SfxItemDesruptor_Impl( pItem ); + return pItem; +} + +// ------------------------------------------------------------------------ +void DeleteOnIdleItems() +{ + SfxItemDesruptorList_Impl* &rpList + = ImpSvtData::GetSvtData().pItemDesruptList; + if ( rpList ) + { + USHORT n; + while ( 0 != ( n = rpList->Count() ) ) + // Remove ist implizit im Dtor + delete rpList->GetObject( n-1 ); + DELETEZ(rpList); + } +} + + diff --git a/svtools/source/misc/langtab.cxx b/svtools/source/misc/langtab.cxx index 870e6378a216..ef2cedcc50c2 100644 --- a/svtools/source/misc/langtab.cxx +++ b/svtools/source/misc/langtab.cxx @@ -42,10 +42,10 @@ #include <i18npool/lang.h> #include <i18npool/mslangid.hxx> -#include <svtools/svtools.hrc> +#include <svl/svtools.hrc> #include <svtools/svtdata.hxx> #include <svtools/langtab.hxx> -#include <svtools/syslocale.hxx> +#include <unotools/syslocale.hxx> using namespace ::com::sun::star; diff --git a/svtools/source/misc/langtab.src b/svtools/source/misc/langtab.src index 4458d4b0f132..0aa90f8e96b9 100644 --- a/svtools/source/misc/langtab.src +++ b/svtools/source/misc/langtab.src @@ -29,7 +29,7 @@ ************************************************************************/ // include --------------------------------------------------------------- -#include <svtools/svtools.hrc> +#include <svl/svtools.hrc> #define RSC_RESOURCE_USAGE 1 #include <i18npool/lang.h> diff --git a/svtools/source/misc/lockfilecommon.cxx b/svtools/source/misc/lockfilecommon.cxx deleted file mode 100644 index ef2cf89d8572..000000000000 --- a/svtools/source/misc/lockfilecommon.cxx +++ /dev/null @@ -1,276 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: ,v $ - * - * $Revision: $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_svtools.hxx" - -#include <stdio.h> - -#include <com/sun/star/ucb/XSimpleFileAccess.hpp> -#include <com/sun/star/ucb/XCommandEnvironment.hpp> -#include <com/sun/star/ucb/InsertCommandArgument.hpp> -#include <com/sun/star/ucb/NameClashException.hpp> -#include <com/sun/star/io/WrongFormatException.hpp> - -#include <osl/time.h> -#include <osl/security.hxx> -#include <osl/socket.hxx> -#include <osl/file.hxx> - -#include <rtl/string.hxx> -#include <rtl/ustring.hxx> -#include <rtl/strbuf.hxx> -#include <rtl/ustrbuf.hxx> - -#include <comphelper/processfactory.hxx> - -#include <tools/urlobj.hxx> -#include <unotools/bootstrap.hxx> - -#include <ucbhelper/content.hxx> - -#include <svtools/useroptions.hxx> - -#include <svtools/lockfilecommon.hxx> - -using namespace ::com::sun::star; - -namespace svt { - -// ---------------------------------------------------------------------- -LockFileCommon::LockFileCommon( const ::rtl::OUString& aOrigURL, const uno::Reference< lang::XMultiServiceFactory >& xFactory, const ::rtl::OUString& aPrefix ) -: m_xFactory( xFactory ) -{ - if ( !m_xFactory.is() ) - m_xFactory = ::comphelper::getProcessServiceFactory(); - - INetURLObject aDocURL = ResolveLinks( INetURLObject( aOrigURL ) ); - - ::rtl::OUString aShareURLString = aDocURL.GetPartBeforeLastName(); - aShareURLString += aPrefix; - aShareURLString += aDocURL.GetName(); - aShareURLString += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "#" ) ); - m_aURL = INetURLObject( aShareURLString ).GetMainURL( INetURLObject::NO_DECODE ); -} - -// ---------------------------------------------------------------------- -LockFileCommon::~LockFileCommon() -{ -} - -// ---------------------------------------------------------------------- -INetURLObject LockFileCommon::ResolveLinks( const INetURLObject& aDocURL ) -{ - if ( aDocURL.HasError() ) - throw lang::IllegalArgumentException(); - - ::rtl::OUString aURLToCheck = aDocURL.GetMainURL( INetURLObject::NO_DECODE ); - - sal_Bool bNeedsChecking = sal_True; - sal_Int32 nMaxLinkCount = 128; - sal_Int32 nCount = 0; - - while( bNeedsChecking ) - { - bNeedsChecking = sal_False; - - // do not allow too deep links - if ( nCount++ >= nMaxLinkCount ) - throw io::IOException(); - - // there is currently no UCB functionality to resolve the symbolic links; - // since the lock files are used only for local file systems the osl functionality is used directly - - ::osl::FileStatus aStatus( FileStatusMask_Type | FileStatusMask_LinkTargetURL ); - ::osl::DirectoryItem aItem; - if ( ::osl::FileBase::E_None == ::osl::DirectoryItem::get( aURLToCheck, aItem ) - && aItem.is() && ::osl::FileBase::E_None == aItem.getFileStatus( aStatus ) ) - { - if ( aStatus.isValid( FileStatusMask_Type ) - && aStatus.isValid( FileStatusMask_LinkTargetURL ) - && aStatus.getFileType() == ::osl::FileStatus::Link ) - { - aURLToCheck = aStatus.getLinkTargetURL(); - bNeedsChecking = sal_True; - } - } - } - - return INetURLObject( aURLToCheck ); -} - -// ---------------------------------------------------------------------- -uno::Sequence< uno::Sequence< ::rtl::OUString > > LockFileCommon::ParseList( const uno::Sequence< sal_Int8 >& aBuffer ) -{ - sal_Int32 nCurPos = 0; - sal_Int32 nCurEntry = 0; - uno::Sequence< uno::Sequence< ::rtl::OUString > > aResult( 10 ); - - while ( nCurPos < aBuffer.getLength() ) - { - if ( nCurEntry >= aResult.getLength() ) - aResult.realloc( nCurEntry + 10 ); - aResult[nCurEntry] = ParseEntry( aBuffer, nCurPos ); - nCurEntry++; - } - - aResult.realloc( nCurEntry ); - return aResult; -} - -// ---------------------------------------------------------------------- -uno::Sequence< ::rtl::OUString > LockFileCommon::ParseEntry( const uno::Sequence< sal_Int8 >& aBuffer, sal_Int32& io_nCurPos ) -{ - uno::Sequence< ::rtl::OUString > aResult( LOCKFILE_ENTRYSIZE ); - - for ( int nInd = 0; nInd < LOCKFILE_ENTRYSIZE; nInd++ ) - { - aResult[nInd] = ParseName( aBuffer, io_nCurPos ); - if ( io_nCurPos >= aBuffer.getLength() - || ( nInd < LOCKFILE_ENTRYSIZE - 1 && aBuffer[io_nCurPos++] != ',' ) - || ( nInd == LOCKFILE_ENTRYSIZE - 1 && aBuffer[io_nCurPos++] != ';' ) ) - throw io::WrongFormatException(); - } - - return aResult; -} - -// ---------------------------------------------------------------------- -::rtl::OUString LockFileCommon::ParseName( const uno::Sequence< sal_Int8 >& aBuffer, sal_Int32& io_nCurPos ) -{ - ::rtl::OStringBuffer aResult; - sal_Bool bHaveName = sal_False; - sal_Bool bEscape = sal_False; - - while( !bHaveName ) - { - if ( io_nCurPos >= aBuffer.getLength() ) - throw io::WrongFormatException(); - - if ( bEscape ) - { - if ( aBuffer[io_nCurPos] == ',' || aBuffer[io_nCurPos] == ';' || aBuffer[io_nCurPos] == '\\' ) - aResult.append( (sal_Char)aBuffer[io_nCurPos] ); - else - throw io::WrongFormatException(); - - bEscape = sal_False; - io_nCurPos++; - } - else if ( aBuffer[io_nCurPos] == ',' || aBuffer[io_nCurPos] == ';' ) - bHaveName = sal_True; - else - { - if ( aBuffer[io_nCurPos] == '\\' ) - bEscape = sal_True; - else - aResult.append( (sal_Char)aBuffer[io_nCurPos] ); - - io_nCurPos++; - } - } - - return ::rtl::OStringToOUString( aResult.makeStringAndClear(), RTL_TEXTENCODING_UTF8 ); -} - -// ---------------------------------------------------------------------- -::rtl::OUString LockFileCommon::EscapeCharacters( const ::rtl::OUString& aSource ) -{ - ::rtl::OUStringBuffer aBuffer; - const sal_Unicode* pStr = aSource.getStr(); - for ( sal_Int32 nInd = 0; nInd < aSource.getLength() && pStr[nInd] != 0; nInd++ ) - { - if ( pStr[nInd] == '\\' || pStr[nInd] == ';' || pStr[nInd] == ',' ) - aBuffer.append( (sal_Unicode)'\\' ); - aBuffer.append( pStr[nInd] ); - } - - return aBuffer.makeStringAndClear(); -} - -// ---------------------------------------------------------------------- -::rtl::OUString LockFileCommon::GetOOOUserName() -{ - SvtUserOptions aUserOpt; - ::rtl::OUString aName = aUserOpt.GetFirstName(); - if ( aName.getLength() ) - aName += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " " ) ); - aName += aUserOpt.GetLastName(); - - return aName; -} - -// ---------------------------------------------------------------------- -::rtl::OUString LockFileCommon::GetCurrentLocalTime() -{ - ::rtl::OUString aTime; - - TimeValue aSysTime; - if ( osl_getSystemTime( &aSysTime ) ) - { - TimeValue aLocTime; - if ( osl_getLocalTimeFromSystemTime( &aSysTime, &aLocTime ) ) - { - oslDateTime aDateTime; - if ( osl_getDateTimeFromTimeValue( &aLocTime, &aDateTime ) ) - { - char pDateTime[20]; - sprintf( pDateTime, "%02d.%02d.%4d %02d:%02d", aDateTime.Day, aDateTime.Month, aDateTime.Year, aDateTime.Hours, aDateTime.Minutes ); - aTime = ::rtl::OUString::createFromAscii( pDateTime ); - } - } - } - - return aTime; -} - -// ---------------------------------------------------------------------- -uno::Sequence< ::rtl::OUString > LockFileCommon::GenerateOwnEntry() -{ - uno::Sequence< ::rtl::OUString > aResult( LOCKFILE_ENTRYSIZE ); - - aResult[LOCKFILE_OOOUSERNAME_ID] = GetOOOUserName(); - - ::osl::Security aSecurity; - aSecurity.getUserName( aResult[LOCKFILE_SYSUSERNAME_ID] ); - - aResult[LOCKFILE_LOCALHOST_ID] = ::osl::SocketAddr::getLocalHostname(); - - aResult[LOCKFILE_EDITTIME_ID] = GetCurrentLocalTime(); - - ::utl::Bootstrap::locateUserInstallation( aResult[LOCKFILE_USERURL_ID] ); - - - return aResult; -} - -} // namespace svt - diff --git a/svtools/source/misc/makefile.mk b/svtools/source/misc/makefile.mk index a23092e120da..77cf8a41a8bd 100644 --- a/svtools/source/misc/makefile.mk +++ b/svtools/source/misc/makefile.mk @@ -46,11 +46,9 @@ ENABLE_EXCEPTIONS := TRUE SRS1NAME=misc SRC1FILES=\ - config.src \ - iniman.src \ ehdl.src \ - imagemgr.src \ helpagent.src \ + imagemgr.src \ langtab.src SRS2NAME=ehdl @@ -59,33 +57,28 @@ SRC2FILES=\ SLOFILES=\ $(SLO)$/acceleratorexecute.obj \ + $(SLO)$/chartprettypainter.obj \ $(SLO)$/cliplistener.obj \ + $(SLO)$/dialogclosedlistener.obj\ + $(SLO)$/dialogcontrolling.obj \ + $(SLO)$/ehdl.obj \ $(SLO)$/embedhlp.obj \ $(SLO)$/embedtransfer.obj \ + $(SLO)$/helpagentwindow.obj \ $(SLO)$/imagemgr.obj \ $(SLO)$/imageresourceaccess.obj \ - $(SLO)$/templatefoldercache.obj \ - $(SLO)$/transfer.obj \ - $(SLO)$/transfer2.obj \ - $(SLO)$/stringtransfer.obj \ - $(SLO)$/urihelper.obj \ - $(SLO)$/svtaccessiblefactory.obj \ - $(SLO)$/ehdl.obj \ - $(SLO)$/flbytes.obj \ - $(SLO)$/helpagentwindow.obj \ $(SLO)$/imap.obj \ $(SLO)$/imap2.obj \ $(SLO)$/imap3.obj \ - $(SLO)$/ownlist.obj \ - $(SLO)$/vcldata.obj \ - $(SLO)$/restrictedpaths.obj \ - $(SLO)$/dialogclosedlistener.obj\ - $(SLO)$/dialogcontrolling.obj \ - $(SLO)$/chartprettypainter.obj \ - $(SLO)$/lockfilecommon.obj \ - $(SLO)$/sharecontrolfile.obj \ - $(SLO)$/documentlockfile.obj \ - $(SLO)$/langtab.obj + $(SLO)$/itemdel.obj \ + $(SLO)$/langtab.obj \ + $(SLO)$/stringtransfer.obj \ + $(SLO)$/svtaccessiblefactory.obj \ + $(SLO)$/svtdata.obj \ + $(SLO)$/templatefoldercache.obj \ + $(SLO)$/transfer.obj \ + $(SLO)$/transfer2.obj \ + $(SLO)$/wallitem.obj # --- Targets ------------------------------------------------------- diff --git a/svtools/source/misc/ownlist.cxx b/svtools/source/misc/ownlist.cxx deleted file mode 100644 index 346b4ff7251e..000000000000 --- a/svtools/source/misc/ownlist.cxx +++ /dev/null @@ -1,330 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: ownlist.cxx,v $ - * $Revision: 1.6.136.1 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_svtools.hxx" -#include <ctype.h> -#include <stdio.h> -#include <com/sun/star/beans/PropertyValues.hpp> - -#include <svtools/ownlist.hxx> - -using namespace com::sun::star; - -//========================================================================= -//============== SvCommandList ============================================ -//========================================================================= -PRV_SV_IMPL_OWNER_LIST(SvCommandList,SvCommand) - - -static String parseString(const String & rCmd, USHORT * pIndex) -{ - String result; - - if(rCmd.GetChar( *pIndex ) == '\"') { - (*pIndex) ++; - - USHORT begin = *pIndex; - - while(*pIndex < rCmd.Len() && rCmd.GetChar((*pIndex) ++) != '\"') ; - - result = String(rCmd.Copy(begin, *pIndex - begin - 1)); - } - - return result; -} - -static String parseWord(const String & rCmd, USHORT * pIndex) -{ - USHORT begin = *pIndex; - - while(*pIndex < rCmd.Len() && !isspace(rCmd.GetChar(*pIndex)) && rCmd.GetChar(*pIndex) != '=') - (*pIndex) ++; - - return String(rCmd.Copy(begin, *pIndex - begin)); -} - -static void eatSpace(const String & rCmd, USHORT * pIndex) -{ - while(*pIndex < rCmd.Len() && isspace(rCmd.GetChar(*pIndex))) - (*pIndex) ++; -} - - -//========================================================================= -BOOL SvCommandList::AppendCommands -( - const String & rCmd, /* Dieser Text wird in Kommandos umgesetzt */ - USHORT * pEaten /* Anzahl der Zeichen, die gelesen wurden */ -) -/* [Beschreibung] - - Es wird eine Text geparsed und die einzelnen Kommandos werden an - die Liste angeh"angt. - - [R"uckgabewert] - - BOOL TRUE, der Text wurde korrekt geparsed. - FALSE, der Text wurde nicht korrekt geparsed. -*/ -{ - USHORT index = 0; - while(index < rCmd.Len()) - { - - eatSpace(rCmd, &index); - String name = (rCmd.GetChar(index) == '\"') ? parseString(rCmd, &index) : parseWord(rCmd, &index); - - eatSpace(rCmd, &index); - String value; - if(index < rCmd.Len() && rCmd.GetChar(index) == '=') - { - index ++; - - eatSpace(rCmd, &index); - value = (rCmd.GetChar(index) == '\"') ? parseString(rCmd, &index) : parseWord(rCmd, &index); - } - - SvCommand * pCmd = new SvCommand(name, value); - aTypes.Insert(pCmd, LIST_APPEND); - } - - *pEaten = index; - -// USHORT nPos = 0; -// while( nPos < rCmd.Len() ) -// { -// // ein Zeichen ? Dann faengt hier eine Option an -// if( isalpha( rCmd[nPos] ) ) -// { -// String aValue; -// USHORT nStt = nPos; -// register char c; - -// while( nPos < rCmd.Len() && -// ( isalnum(c=rCmd[nPos]) || '-'==c || '.'==c ) ) -// nPos++; - -// String aToken( rCmd.Copy( nStt, nPos-nStt ) ); - -// while( nPos < rCmd.Len() && -// ( !String::IsPrintable( (c=rCmd[nPos]), -// RTL_TEXTENCODING_MS_1252 ) || isspace(c) ) ) -// nPos++; - -// // hat die Option auch einen Wert? -// if( nPos!=rCmd.Len() && '='==c ) -// { -// nPos++; - -// while( nPos < rCmd.Len() && -// ( !String::IsPrintable( (c=rCmd[nPos]), -// RTL_TEXTENCODING_MS_1252 ) || isspace(c) ) ) -// nPos++; - -// if( nPos != rCmd.Len() ) -// { -// USHORT nLen = 0; -// nStt = nPos; -// if( '"' == c ) -// { -// nPos++; nStt++; -// while( nPos < rCmd.Len() && -// '"' != rCmd[nPos] ) -// nPos++, nLen++; -// if( nPos!=rCmd.Len() ) -// nPos++; -// } -// else -// // hier sind wir etwas laxer als der -// // Standard und erlauben alles druckbare -// while( nPos < rCmd.Len() && -// String::IsPrintable( (c=rCmd[nPos]), -// RTL_TEXTENCODING_MS_1252 ) && -// !isspace( c ) ) -// nPos++, nLen++; - -// if( nLen ) -// aValue = rCmd( nStt, nLen ); -// } -// } - -// SvCommand * pCmd = new SvCommand( aToken, aValue ); -// aTypes.Insert( pCmd, LIST_APPEND ); -// } -// else -// // white space un unerwartete Zeichen ignorieren wie -// nPos++; -// } -// *pEaten = nPos; - return TRUE; -} - -//========================================================================= -String SvCommandList::GetCommands() const -/* [Beschreibung] - - Die Kommandos in der Liste werden als Text hintereinander, durch ein - Leerzeichen getrennt geschrieben. Der Text muss nicht genauso - aussehen wie der in <SvCommandList::AppendCommands()> "ubergebene. - - [R"uckgabewert] - - String Die Kommandos werden zur"uckgegeben. -*/ -{ - String aRet; - for( ULONG i = 0; i < aTypes.Count(); i++ ) - { - if( i != 0 ) - aRet += ' '; - SvCommand * pCmd = (SvCommand *)aTypes.GetObject( i ); - aRet += pCmd->GetCommand(); - if( pCmd->GetArgument().Len() ) - { - aRet.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "=\"" ) ); - aRet += pCmd->GetArgument(); - aRet.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "\"" ) ); - } - } - return aRet; -} - -//========================================================================= -SvCommand & SvCommandList::Append -( - const String & rCommand, /* das Kommando */ - const String & rArg /* dasArgument des Kommandos */ -) -/* [Beschreibung] - - Es wird eine Objekt vom Typ SvCommand erzeugt und an die Liste - angeh"angt. - - [R"uckgabewert] - - SvCommand & Das erteugte Objekt wird zur"uckgegeben. -*/ -{ - SvCommand * pCmd = new SvCommand( rCommand, rArg ); - aTypes.Insert( pCmd, LIST_APPEND ); - return *pCmd; -} - -//========================================================================= -SvStream & operator >> -( - SvStream & rStm, /* Stream aus dem gelesen wird */ - SvCommandList & rThis /* Die zu f"ullende Liste */ -) -/* [Beschreibung] - - Die Liste mit ihren Elementen wird gelesen. Das Format ist: - 1. Anzahl der Elemente - 2. Alle Elemente - - [R"uckgabewert] - - SvStream & Der "ubergebene Stream. -*/ -{ - UINT32 nCount = 0; - rStm >> nCount; - if( !rStm.GetError() ) - { - while( nCount-- ) - { - SvCommand * pCmd = new SvCommand(); - rStm >> *pCmd; - rThis.aTypes.Insert( pCmd, LIST_APPEND ); - } - } - return rStm; -} - -//========================================================================= -SvStream & operator << -( - SvStream & rStm, /* Stream in den geschrieben wird */ - const SvCommandList & rThis /* Die zu schreibende Liste */ -) -/* [Beschreibung] - - Die Liste mit ihren Elementen wir geschrieben. Das Format ist: - 1. Anzahl der Elemente - 2. Alle Elemente - - [R"uckgabewert] - - SvStream & Der "ubergebene Stream. -*/ -{ - UINT32 nCount = rThis.aTypes.Count(); - rStm << nCount; - - for( UINT32 i = 0; i < nCount; i++ ) - { - SvCommand * pCmd = (SvCommand *)rThis.aTypes.GetObject( i ); - rStm << *pCmd; - } - return rStm; -} - -BOOL SvCommandList::FillFromSequence( const com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue >& aCommandSequence ) -{ - const sal_Int32 nCount = aCommandSequence.getLength(); - String aCommand, aArg; - ::rtl::OUString aApiArg; - for( sal_Int32 nIndex=0; nIndex<nCount; nIndex++ ) - { - aCommand = aCommandSequence[nIndex].Name; - if( !( aCommandSequence[nIndex].Value >>= aApiArg ) ) - return sal_False; - aArg = aApiArg; - Append( aCommand, aArg ); - } - - return TRUE; -} - -void SvCommandList::FillSequence( com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue >& aCommandSequence ) -{ - const sal_Int32 nCount = Count(); - aCommandSequence.realloc( nCount ); - for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ ) - { - const SvCommand& rCommand = (*this)[ nIndex ]; - aCommandSequence[nIndex].Name = rCommand.GetCommand(); - aCommandSequence[nIndex].Handle = -1; - aCommandSequence[nIndex].Value = uno::makeAny( ::rtl::OUString( rCommand.GetArgument() ) ); - aCommandSequence[nIndex].State = beans::PropertyState_DIRECT_VALUE; - } -} - diff --git a/svtools/source/misc/restrictedpaths.cxx b/svtools/source/misc/restrictedpaths.cxx deleted file mode 100644 index 354e32126680..000000000000 --- a/svtools/source/misc/restrictedpaths.cxx +++ /dev/null @@ -1,217 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: restrictedpaths.cxx,v $ - * $Revision: 1.8 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_svtools.hxx" -#include <svtools/restrictedpaths.hxx> - -#include <algorithm> -#include <osl/process.h> -#include <tools/urlobj.hxx> -#include <unotools/localfilehelper.hxx> -#include <svtools/syslocale.hxx> - -namespace svt -{ - namespace - { - // ---------------------------------------------------------------- - /** retrieves the value of an environment variable - @return <TRUE/> if and only if the retrieved string value is not empty - */ - bool lcl_getEnvironmentValue( const sal_Char* _pAsciiEnvName, ::rtl::OUString& _rValue ) - { - _rValue = ::rtl::OUString(); - ::rtl::OUString sEnvName = ::rtl::OUString::createFromAscii( _pAsciiEnvName ); - osl_getEnvironment( sEnvName.pData, &_rValue.pData ); - return _rValue.getLength() != 0; - } - - //----------------------------------------------------------------- - void lcl_convertStringListToUrls( const String& _rColonSeparatedList, ::std::vector< String >& _rTokens, bool _bFinalSlash ) - { - const sal_Unicode s_cSeparator = - #if defined(WNT) - ';' - #else - ':' - #endif - ; - xub_StrLen nTokens = _rColonSeparatedList.GetTokenCount( s_cSeparator ); - _rTokens.resize( 0 ); _rTokens.reserve( nTokens ); - for ( xub_StrLen i=0; i<nTokens; ++i ) - { - // the current token in the list - String sCurrentToken = _rColonSeparatedList.GetToken( i, s_cSeparator ); - if ( !sCurrentToken.Len() ) - continue; - - INetURLObject aCurrentURL; - - String sURL; - if ( ::utl::LocalFileHelper::ConvertPhysicalNameToURL( sCurrentToken, sURL ) ) - aCurrentURL = INetURLObject( sURL ); - else - { - // smart URL parsing, assuming FILE protocol - aCurrentURL = INetURLObject( sCurrentToken, INET_PROT_FILE ); - } - - if ( _bFinalSlash ) - aCurrentURL.setFinalSlash( ); - else - aCurrentURL.removeFinalSlash( ); - _rTokens.push_back( aCurrentURL.GetMainURL( INetURLObject::NO_DECODE ) ); - } - } - - } - - //===================================================================== - //= CheckURLAllowed - //===================================================================== - struct CheckURLAllowed - { - protected: - #ifdef WNT - SvtSysLocale m_aSysLocale; - #endif - String m_sCheckURL; // the URL to check - bool m_bAllowParent; - public: - inline CheckURLAllowed( const String& _rCheckURL, bool bAllowParent = true ) - :m_sCheckURL( _rCheckURL ), m_bAllowParent( bAllowParent ) - { - #ifdef WNT - // on windows, assume that the relevant file systems are case insensitive, - // thus normalize the URL - m_sCheckURL = m_aSysLocale.GetCharClass().toLower( m_sCheckURL, 0, m_sCheckURL.Len() ); - #endif - } - - bool operator()( const String& _rApprovedURL ) - { - #ifdef WNT - // on windows, assume that the relevant file systems are case insensitive, - // thus normalize the URL - String sApprovedURL( m_aSysLocale.GetCharClass().toLower( _rApprovedURL, 0, _rApprovedURL.Len() ) ); - #else - String sApprovedURL( _rApprovedURL ); - #endif - - xub_StrLen nLenApproved = sApprovedURL.Len(); - xub_StrLen nLenChecked = m_sCheckURL.Len(); - - if ( nLenApproved > nLenChecked ) - { - if ( m_bAllowParent ) - { - if ( sApprovedURL.Search( m_sCheckURL ) == 0 ) - { - if ( ( m_sCheckURL.GetChar( nLenChecked - 1 ) == '/' ) - || ( sApprovedURL.GetChar( nLenChecked ) == '/' ) ) - return true; - } - } - else - { - // just a difference in final slash? - if ( ( nLenApproved == ( nLenChecked + 1 ) ) && - ( sApprovedURL.GetChar( nLenApproved - 1 ) == '/' ) ) - return true; - } - return false; - } - else if ( nLenApproved < nLenChecked ) - { - if ( m_sCheckURL.Search( sApprovedURL ) == 0 ) - { - if ( ( sApprovedURL.GetChar( nLenApproved - 1 ) == '/' ) - || ( m_sCheckURL.GetChar( nLenApproved ) == '/' ) ) - return true; - } - return false; - } - else - { - // strings have equal length - return ( sApprovedURL == m_sCheckURL ); - } - } - }; - - //===================================================================== - //= RestrictedPaths - //===================================================================== - //--------------------------------------------------------------------- - RestrictedPaths::RestrictedPaths() - :m_bFilterIsEnabled( true ) - { - ::rtl::OUString sRestrictedPathList; - if ( lcl_getEnvironmentValue( "RestrictedPath", sRestrictedPathList ) ) - // append a final slash. This ensures that when we later on check - // for unrestricted paths, we don't allow paths like "/home/user35" just because - // "/home/user3" is allowed - with the final slash, we make it "/home/user3/". - lcl_convertStringListToUrls( sRestrictedPathList, m_aUnrestrictedURLs, true ); - } - - RestrictedPaths::~RestrictedPaths() {} - - // -------------------------------------------------------------------- - bool RestrictedPaths::isUrlAllowed( const String& _rURL ) const - { - if ( m_aUnrestrictedURLs.empty() || !m_bFilterIsEnabled ) - return true; - - ::std::vector< String >::const_iterator aApprovedURL = ::std::find_if( - m_aUnrestrictedURLs.begin(), - m_aUnrestrictedURLs.end(), - CheckURLAllowed( _rURL, true ) - ); - - return ( aApprovedURL != m_aUnrestrictedURLs.end() ); - } - - // -------------------------------------------------------------------- - bool RestrictedPaths::isUrlAllowed( const String& _rURL, bool allowParents ) const - { - if ( m_aUnrestrictedURLs.empty() || !m_bFilterIsEnabled ) - return true; - - ::std::vector< String >::const_iterator aApprovedURL = ::std::find_if( - m_aUnrestrictedURLs.begin(), - m_aUnrestrictedURLs.end(), - CheckURLAllowed( _rURL, allowParents ) - ); - - return ( aApprovedURL != m_aUnrestrictedURLs.end() ); - } - -} // namespace svt diff --git a/svtools/source/misc/sharecontrolfile.cxx b/svtools/source/misc/sharecontrolfile.cxx deleted file mode 100644 index dbea89f54bcc..000000000000 --- a/svtools/source/misc/sharecontrolfile.cxx +++ /dev/null @@ -1,376 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: sharecontrolfile.cxx,v $ - * $Revision: 1.6.82.1 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_svtools.hxx" - -#include <stdio.h> - -#include <com/sun/star/ucb/XSimpleFileAccess.hpp> -#include <com/sun/star/ucb/XCommandEnvironment.hpp> -#include <com/sun/star/ucb/XContent.hpp> -#include <com/sun/star/ucb/InsertCommandArgument.hpp> -#include <com/sun/star/ucb/InteractiveIOException.hpp> -#include <com/sun/star/io/WrongFormatException.hpp> - -#include <osl/time.h> -#include <osl/security.hxx> -#include <osl/socket.hxx> - -#include <rtl/string.hxx> -#include <rtl/ustring.hxx> -#include <rtl/strbuf.hxx> -#include <rtl/ustrbuf.hxx> - -#include <comphelper/processfactory.hxx> -#include <ucbhelper/content.hxx> - -#include <tools/urlobj.hxx> -#include <tools/stream.hxx> -#include <unotools/bootstrap.hxx> -#include <unotools/streamwrap.hxx> - -#include <svtools/useroptions.hxx> - -#include <svtools/sharecontrolfile.hxx> - -using namespace ::com::sun::star; - -namespace svt { - -// ---------------------------------------------------------------------- -ShareControlFile::ShareControlFile( const ::rtl::OUString& aOrigURL, const uno::Reference< lang::XMultiServiceFactory >& xFactory ) -: LockFileCommon( aOrigURL, xFactory, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".~sharing." ) ) ) -{ - OpenStream(); - - if ( !IsValid() ) - throw io::NotConnectedException(); -} - -// ---------------------------------------------------------------------- -ShareControlFile::~ShareControlFile() -{ - try - { - Close(); - } - catch( uno::Exception& ) - {} -} - -// ---------------------------------------------------------------------- -void ShareControlFile::OpenStream() -{ - // if it is called outside of constructor the mutex must be locked already - - if ( !m_xStream.is() && m_aURL.getLength() ) - { - uno::Reference< ucb::XCommandEnvironment > xDummyEnv; - ::ucbhelper::Content aContent = ::ucbhelper::Content( m_aURL, xDummyEnv ); - - uno::Reference< ucb::XContentIdentifier > xContId( aContent.get().is() ? aContent.get()->getIdentifier() : 0 ); - if ( !xContId.is() || !xContId->getContentProviderScheme().equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "file" ) ) ) ) - throw io::IOException(); // the implementation supports only local files for now - - uno::Reference< io::XStream > xStream; - - // Currently the locking of the original document is intended to be used. - // That means that the shared file should be accessed only when the original document is locked and only by user who has locked the document. - // TODO/LATER: should the own file locking be used? - - try - { - xStream = aContent.openWriteableStreamNoLock(); - } - catch ( ucb::InteractiveIOException const & e ) - { - if ( e.Code == ucb::IOErrorCode_NOT_EXISTING ) - { - // Create file... - SvMemoryStream aStream(0,0); - uno::Reference< io::XInputStream > xInput( new ::utl::OInputStreamWrapper( aStream ) ); - ucb::InsertCommandArgument aInsertArg; - aInsertArg.Data = xInput; - aInsertArg.ReplaceExisting = sal_False; - aContent.executeCommand( rtl::OUString::createFromAscii( "insert" ), uno::makeAny( aInsertArg ) ); - - // try to let the file be hidden if possible - try { - aContent.setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsHidden" ) ), uno::makeAny( sal_True ) ); - } catch( uno::Exception& ) {} - - // Try to open one more time - xStream = aContent.openWriteableStreamNoLock(); - } - else - throw; - } - - m_xSeekable.set( xStream, uno::UNO_QUERY_THROW ); - m_xInputStream.set( xStream->getInputStream(), uno::UNO_QUERY_THROW ); - m_xOutputStream.set( xStream->getOutputStream(), uno::UNO_QUERY_THROW ); - m_xTruncate.set( m_xOutputStream, uno::UNO_QUERY_THROW ); - m_xStream = xStream; - } -} - -// ---------------------------------------------------------------------- -void ShareControlFile::Close() -{ - // if it is called outside of destructor the mutex must be locked - - if ( m_xStream.is() ) - { - try - { - if ( m_xInputStream.is() ) - m_xInputStream->closeInput(); - if ( m_xOutputStream.is() ) - m_xOutputStream->closeOutput(); - } - catch( uno::Exception& ) - {} - - m_xStream = uno::Reference< io::XStream >(); - m_xInputStream = uno::Reference< io::XInputStream >(); - m_xOutputStream = uno::Reference< io::XOutputStream >(); - m_xSeekable = uno::Reference< io::XSeekable >(); - m_xTruncate = uno::Reference< io::XTruncate >(); - m_aUsersData.realloc( 0 ); - } -} - -// ---------------------------------------------------------------------- -uno::Sequence< uno::Sequence< ::rtl::OUString > > ShareControlFile::GetUsersData() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - if ( !IsValid() ) - throw io::NotConnectedException(); - - if ( !m_aUsersData.getLength() ) - { - sal_Int64 nLength = m_xSeekable->getLength(); - if ( nLength > SAL_MAX_INT32 ) - throw uno::RuntimeException(); - - uno::Sequence< sal_Int8 > aBuffer( (sal_Int32)nLength ); - m_xSeekable->seek( 0 ); - - sal_Int32 nRead = m_xInputStream->readBytes( aBuffer, (sal_Int32)nLength ); - nLength -= nRead; - while ( nLength > 0 ) - { - uno::Sequence< sal_Int8 > aTmpBuf( (sal_Int32)nLength ); - nRead = m_xInputStream->readBytes( aTmpBuf, (sal_Int32)nLength ); - if ( nRead > nLength ) - throw uno::RuntimeException(); - - for ( sal_Int32 nInd = 0; nInd < nRead; nInd++ ) - aBuffer[aBuffer.getLength() - (sal_Int32)nLength + nInd] = aTmpBuf[nInd]; - nLength -= nRead; - } - - m_aUsersData = ParseList( aBuffer ); - } - - return m_aUsersData; -} - -// ---------------------------------------------------------------------- -void ShareControlFile::SetUsersDataAndStore( const uno::Sequence< uno::Sequence< ::rtl::OUString > >& aUsersData ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - if ( !IsValid() ) - throw io::NotConnectedException(); - - if ( !m_xTruncate.is() || !m_xOutputStream.is() || !m_xSeekable.is() ) - throw uno::RuntimeException(); - - m_xTruncate->truncate(); - m_xSeekable->seek( 0 ); - - ::rtl::OUStringBuffer aBuffer; - for ( sal_Int32 nInd = 0; nInd < aUsersData.getLength(); nInd++ ) - { - if ( aUsersData[nInd].getLength() != SHARED_ENTRYSIZE ) - throw lang::IllegalArgumentException(); - - for ( sal_Int32 nEntryInd = 0; nEntryInd < SHARED_ENTRYSIZE; nEntryInd++ ) - { - aBuffer.append( EscapeCharacters( aUsersData[nInd][nEntryInd] ) ); - if ( nEntryInd < SHARED_ENTRYSIZE - 1 ) - aBuffer.append( (sal_Unicode)',' ); - else - aBuffer.append( (sal_Unicode)';' ); - } - } - - ::rtl::OString aStringData( ::rtl::OUStringToOString( aBuffer.makeStringAndClear(), RTL_TEXTENCODING_UTF8 ) ); - uno::Sequence< sal_Int8 > aData( (sal_Int8*)aStringData.getStr(), aStringData.getLength() ); - m_xOutputStream->writeBytes( aData ); - m_aUsersData = aUsersData; -} - -// ---------------------------------------------------------------------- -uno::Sequence< ::rtl::OUString > ShareControlFile::InsertOwnEntry() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - if ( !IsValid() ) - throw io::NotConnectedException(); - - GetUsersData(); - uno::Sequence< ::uno::Sequence< ::rtl::OUString > > aNewData( m_aUsersData.getLength() + 1 ); - uno::Sequence< ::rtl::OUString > aNewEntry = GenerateOwnEntry(); - - sal_Bool bExists = sal_False; - sal_Int32 nNewInd = 0; - for ( sal_Int32 nInd = 0; nInd < m_aUsersData.getLength(); nInd++ ) - { - if ( m_aUsersData[nInd].getLength() == SHARED_ENTRYSIZE ) - { - if ( m_aUsersData[nInd][SHARED_LOCALHOST_ID] == aNewEntry[SHARED_LOCALHOST_ID] - && m_aUsersData[nInd][SHARED_SYSUSERNAME_ID] == aNewEntry[SHARED_SYSUSERNAME_ID] - && m_aUsersData[nInd][SHARED_USERURL_ID] == aNewEntry[SHARED_USERURL_ID] ) - { - if ( !bExists ) - { - aNewData[nNewInd] = aNewEntry; - bExists = sal_True; - } - } - else - { - aNewData[nNewInd] = m_aUsersData[nInd]; - } - - nNewInd++; - } - } - - if ( !bExists ) - aNewData[nNewInd++] = aNewEntry; - - aNewData.realloc( nNewInd ); - SetUsersDataAndStore( aNewData ); - - return aNewEntry; -} - -// ---------------------------------------------------------------------- -bool ShareControlFile::HasOwnEntry() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - if ( !IsValid() ) - { - throw io::NotConnectedException(); - } - - GetUsersData(); - uno::Sequence< ::rtl::OUString > aEntry = GenerateOwnEntry(); - - for ( sal_Int32 nInd = 0; nInd < m_aUsersData.getLength(); ++nInd ) - { - if ( m_aUsersData[nInd].getLength() == SHARED_ENTRYSIZE && - m_aUsersData[nInd][SHARED_LOCALHOST_ID] == aEntry[SHARED_LOCALHOST_ID] && - m_aUsersData[nInd][SHARED_SYSUSERNAME_ID] == aEntry[SHARED_SYSUSERNAME_ID] && - m_aUsersData[nInd][SHARED_USERURL_ID] == aEntry[SHARED_USERURL_ID] ) - { - return true; - } - } - - return false; -} - -// ---------------------------------------------------------------------- -void ShareControlFile::RemoveEntry( const uno::Sequence< ::rtl::OUString >& aArgEntry ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - if ( !IsValid() ) - throw io::NotConnectedException(); - - GetUsersData(); - - uno::Sequence< ::rtl::OUString > aEntry = aArgEntry; - if ( aEntry.getLength() != SHARED_ENTRYSIZE ) - aEntry = GenerateOwnEntry(); - - uno::Sequence< ::uno::Sequence< ::rtl::OUString > > aNewData( m_aUsersData.getLength() + 1 ); - - sal_Int32 nNewInd = 0; - for ( sal_Int32 nInd = 0; nInd < m_aUsersData.getLength(); nInd++ ) - { - if ( m_aUsersData[nInd].getLength() == SHARED_ENTRYSIZE ) - { - if ( m_aUsersData[nInd][SHARED_LOCALHOST_ID] != aEntry[SHARED_LOCALHOST_ID] - || m_aUsersData[nInd][SHARED_SYSUSERNAME_ID] != aEntry[SHARED_SYSUSERNAME_ID] - || m_aUsersData[nInd][SHARED_USERURL_ID] != aEntry[SHARED_USERURL_ID] ) - { - aNewData[nNewInd] = m_aUsersData[nInd]; - nNewInd++; - } - } - } - - aNewData.realloc( nNewInd ); - SetUsersDataAndStore( aNewData ); - - if ( !nNewInd ) - { - // try to remove the file if it is empty - RemoveFile(); - } -} - -// ---------------------------------------------------------------------- -void ShareControlFile::RemoveFile() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - if ( !IsValid() ) - throw io::NotConnectedException(); - - Close(); - - uno::Reference< lang::XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory(); - uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess > xSimpleFileAccess( - xFactory->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.ucb.SimpleFileAccess") ), - uno::UNO_QUERY_THROW ); - xSimpleFileAccess->kill( m_aURL ); -} - -} // namespace svt - diff --git a/svtools/source/misc/vcldata.cxx b/svtools/source/misc/svtdata.cxx index 28b2e833e974..2bc1977e9197 100644 --- a/svtools/source/misc/vcldata.cxx +++ b/svtools/source/misc/svtdata.cxx @@ -6,8 +6,8 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: vcldata.cxx,v $ - * $Revision: 1.10 $ + * $RCSfile: svtdata.cxx,v $ + * $Revision: 1.7 $ * * This file is part of OpenOffice.org. * @@ -30,21 +30,49 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svtools.hxx" -#include <vcl/svapp.hxx> -#include <vcl/settings.hxx> + +#include <map> +#include <tools/resmgr.hxx> +#include <tools/shl.hxx> +#include <vos/process.hxx> #include <svtools/svtdata.hxx> +#include <vcl/svapp.hxx> //============================================================================ // -// class ImpSvtData +// ImpSvtData // //============================================================================ +ImpSvtData::~ImpSvtData() +{ + delete pResMgr; +} + +//============================================================================ +ResMgr * ImpSvtData::GetResMgr(const ::com::sun::star::lang::Locale aLocale) +{ + if (!pResMgr) + { + pResMgr = ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(svt), aLocale ); + } + return pResMgr; +} + ResMgr * ImpSvtData::GetResMgr() { return GetResMgr(Application::GetSettings().GetUILocale()); } +ResMgr * ImpSvtData::GetPatchResMgr(const ::com::sun::star::lang::Locale& aLocale) +{ + if (!pPatchResMgr) + { + pPatchResMgr = ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(svp), aLocale); + } + return pPatchResMgr; +} + ResMgr * ImpSvtData::GetPatchResMgr() { return GetPatchResMgr(Application::GetSettings().GetUILocale()); @@ -55,3 +83,13 @@ SvpResId::SvpResId( USHORT nId ) : { } +//============================================================================ +// static +ImpSvtData & ImpSvtData::GetSvtData() +{ + void ** pAppData = GetAppData(SHL_SVT); + if (!*pAppData) + *pAppData= new ImpSvtData; + return *static_cast<ImpSvtData *>(*pAppData); +} + diff --git a/svtools/source/misc/templatefoldercache.cxx b/svtools/source/misc/templatefoldercache.cxx index 93ed9a7f5c90..348a9638399b 100644 --- a/svtools/source/misc/templatefoldercache.cxx +++ b/svtools/source/misc/templatefoldercache.cxx @@ -45,7 +45,7 @@ #include <vos/refernce.hxx> #include <tools/urlobj.hxx> #include <tools/debug.hxx> -#include <svtools/pathoptions.hxx> +#include <unotools/pathoptions.hxx> #include "comphelper/processfactory.hxx" diff --git a/svtools/source/misc/transfer.cxx b/svtools/source/misc/transfer.cxx index 0bcd00af40aa..4a814637e1af 100644 --- a/svtools/source/misc/transfer.cxx +++ b/svtools/source/misc/transfer.cxx @@ -76,7 +76,7 @@ #include <com/sun/star/frame/XDesktop.hpp> #include <com/sun/star/lang/XInitialization.hpp> -#include "urlbmk.hxx" +#include "svl/urlbmk.hxx" #include "inetimg.hxx" #include <svtools/wmf.hxx> #include <svtools/imap.hxx> diff --git a/svtools/source/misc/transfer2.cxx b/svtools/source/misc/transfer2.cxx index 8dcbbf9d93dc..027dbc31572d 100644 --- a/svtools/source/misc/transfer2.cxx +++ b/svtools/source/misc/transfer2.cxx @@ -50,7 +50,7 @@ #include <com/sun/star/datatransfer/dnd/XDropTargetDragContext.hpp> #endif -#include "urlbmk.hxx" +#include "svl/urlbmk.hxx" #include "inetimg.hxx" #include <svtools/imap.hxx> #include <svtools/transfer.hxx> diff --git a/svtools/source/misc/urihelper.cxx b/svtools/source/misc/urihelper.cxx deleted file mode 100644 index 1ddb4c6dd6f9..000000000000 --- a/svtools/source/misc/urihelper.cxx +++ /dev/null @@ -1,952 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: urihelper.cxx,v $ - * $Revision: 1.22.136.1 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_svtools.hxx" -#include <urihelper.hxx> -#include <com/sun/star/beans/XPropertySet.hpp> -#include "com/sun/star/lang/WrappedTargetRuntimeException.hpp" -#include "com/sun/star/lang/XMultiComponentFactory.hpp" -#include "com/sun/star/ucb/Command.hpp" -#include <com/sun/star/ucb/FileSystemNotation.hpp> -#include "com/sun/star/ucb/IllegalIdentifierException.hpp" -#include "com/sun/star/ucb/UnsupportedCommandException.hpp" -#include "com/sun/star/ucb/XCommandEnvironment.hpp" -#include "com/sun/star/ucb/XCommandProcessor.hpp" -#include "com/sun/star/ucb/XContent.hpp" -#include "com/sun/star/ucb/XContentIdentifierFactory.hpp" -#include "com/sun/star/ucb/XContentProvider.hpp" -#include <com/sun/star/ucb/XContentProviderManager.hpp> -#include "com/sun/star/uno/Any.hxx" -#include "com/sun/star/uno/Exception.hpp" -#include "com/sun/star/uno/Reference.hxx" -#include "com/sun/star/uno/RuntimeException.hpp" -#include "com/sun/star/uno/Sequence.hxx" -#include "com/sun/star/uno/XComponentContext.hpp" -#include "com/sun/star/uno/XInterface.hpp" -#include "com/sun/star/uri/UriReferenceFactory.hpp" -#include "com/sun/star/uri/XUriReference.hpp" -#include "com/sun/star/uri/XUriReferenceFactory.hpp" -#include "cppuhelper/exc_hlp.hxx" -#include "comphelper/processfactory.hxx" -#include "osl/diagnose.h" -#include "rtl/ustrbuf.hxx" -#include "rtl/ustring.h" -#include "rtl/ustring.hxx" -#include "sal/types.h" -#include <tools/debug.hxx> -#include <tools/inetmime.hxx> -#include <ucbhelper/contentbroker.hxx> -#include <unotools/charclass.hxx> -#include "rtl/instance.hxx" - -namespace unnamed_svtools_urihelper {} -using namespace unnamed_svtools_urihelper; - // unnamed namespaces don't work well yet... - -namespace css = com::sun::star; -using namespace com::sun::star; - -//============================================================================ -// -// SmartRel2Abs -// -//============================================================================ - -namespace unnamed_svtools_urihelper { - -inline UniString toUniString(ByteString const & rString) -{ - return UniString(rString, RTL_TEXTENCODING_ISO_8859_1); -} - -inline UniString toUniString(UniString const & rString) -{ - return rString; -} - -template< typename Str > -inline UniString SmartRel2Abs_Impl(INetURLObject const & rTheBaseURIRef, - Str const & rTheRelURIRef, - Link const & rMaybeFileHdl, - bool bCheckFileExists, - bool bIgnoreFragment, - INetURLObject::EncodeMechanism - eEncodeMechanism, - INetURLObject::DecodeMechanism - eDecodeMechanism, - rtl_TextEncoding eCharset, - bool bRelativeNonURIs, - INetURLObject::FSysStyle eStyle) -{ - // Backwards compatibility: - if (rTheRelURIRef.Len() != 0 && rTheRelURIRef.GetChar(0) == '#') - return toUniString(rTheRelURIRef); - - INetURLObject aAbsURIRef; - if (rTheBaseURIRef.HasError()) - aAbsURIRef. - SetSmartURL(rTheRelURIRef, eEncodeMechanism, eCharset, eStyle); - else - { - bool bWasAbsolute; - aAbsURIRef = rTheBaseURIRef.smartRel2Abs(rTheRelURIRef, - bWasAbsolute, - bIgnoreFragment, - eEncodeMechanism, - eCharset, - bRelativeNonURIs, - eStyle); - if (bCheckFileExists - && !bWasAbsolute - && (aAbsURIRef.GetProtocol() == INET_PROT_FILE - || aAbsURIRef.GetProtocol() == INET_PROT_VND_SUN_STAR_WFS)) - { - INetURLObject aNonFileURIRef; - aNonFileURIRef.SetSmartURL(rTheRelURIRef, - eEncodeMechanism, - eCharset, - eStyle); - if (!aNonFileURIRef.HasError() - && aNonFileURIRef.GetProtocol() != INET_PROT_FILE) - { - bool bMaybeFile = false; - if (rMaybeFileHdl.IsSet()) - { - UniString aFilePath(toUniString(rTheRelURIRef)); - bMaybeFile = rMaybeFileHdl.Call(&aFilePath) != 0; - } - if (!bMaybeFile) - aAbsURIRef = aNonFileURIRef; - } - } - } - return aAbsURIRef.GetMainURL(eDecodeMechanism, eCharset); -} - -} - -UniString -URIHelper::SmartRel2Abs(INetURLObject const & rTheBaseURIRef, - ByteString const & rTheRelURIRef, - Link const & rMaybeFileHdl, - bool bCheckFileExists, - bool bIgnoreFragment, - INetURLObject::EncodeMechanism eEncodeMechanism, - INetURLObject::DecodeMechanism eDecodeMechanism, - rtl_TextEncoding eCharset, - bool bRelativeNonURIs, - INetURLObject::FSysStyle eStyle) -{ - return SmartRel2Abs_Impl(rTheBaseURIRef, rTheRelURIRef, rMaybeFileHdl, - bCheckFileExists, bIgnoreFragment, - eEncodeMechanism, eDecodeMechanism, eCharset, - bRelativeNonURIs, eStyle); -} - -UniString -URIHelper::SmartRel2Abs(INetURLObject const & rTheBaseURIRef, - UniString const & rTheRelURIRef, - Link const & rMaybeFileHdl, - bool bCheckFileExists, - bool bIgnoreFragment, - INetURLObject::EncodeMechanism eEncodeMechanism, - INetURLObject::DecodeMechanism eDecodeMechanism, - rtl_TextEncoding eCharset, - bool bRelativeNonURIs, - INetURLObject::FSysStyle eStyle) -{ - return SmartRel2Abs_Impl(rTheBaseURIRef, rTheRelURIRef, rMaybeFileHdl, - bCheckFileExists, bIgnoreFragment, - eEncodeMechanism, eDecodeMechanism, eCharset, - bRelativeNonURIs, eStyle); -} - -//============================================================================ -// -// SetMaybeFileHdl -// -//============================================================================ - -namespace { struct MaybeFileHdl : public rtl::Static< Link, MaybeFileHdl > {}; } - -void URIHelper::SetMaybeFileHdl(Link const & rTheMaybeFileHdl) -{ - MaybeFileHdl::get() = rTheMaybeFileHdl; -} - -//============================================================================ -// -// GetMaybeFileHdl -// -//============================================================================ - -Link URIHelper::GetMaybeFileHdl() -{ - return MaybeFileHdl::get(); -} - -namespace { - -bool isAbsoluteHierarchicalUriReference( - css::uno::Reference< css::uri::XUriReference > const & uriReference) -{ - return uriReference.is() && uriReference->isAbsolute() - && uriReference->isHierarchical() && !uriReference->hasRelativePath(); -} - -// To improve performance, assume that if for any prefix URL of a given -// hierarchical URL either a UCB content cannot be created, or the UCB content -// does not support the getCasePreservingURL command, then this will hold for -// any other prefix URL of the given URL, too: -enum Result { Success, GeneralFailure, SpecificFailure }; - -Result normalizePrefix( - css::uno::Reference< css::ucb::XContentProvider > const & broker, - rtl::OUString const & uri, rtl::OUString * normalized) -{ - OSL_ASSERT(broker.is() && normalized != 0); - css::uno::Reference< css::ucb::XContent > content; - try { - content = broker->queryContent( - css::uno::Reference< css::ucb::XContentIdentifierFactory >( - broker, css::uno::UNO_QUERY_THROW)->createContentIdentifier( - uri)); - } catch (css::ucb::IllegalIdentifierException &) {} - if (!content.is()) { - return GeneralFailure; - } - try { - #if OSL_DEBUG_LEVEL > 0 - bool ok = - #endif - (css::uno::Reference< css::ucb::XCommandProcessor >( - content, css::uno::UNO_QUERY_THROW)->execute( - css::ucb::Command( - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( - "getCasePreservingURL")), - -1, css::uno::Any()), - 0, - css::uno::Reference< css::ucb::XCommandEnvironment >()) - >>= *normalized); - OSL_ASSERT(ok); - } catch (css::uno::RuntimeException &) { - throw; - } catch (css::ucb::UnsupportedCommandException &) { - return GeneralFailure; - } catch (css::uno::Exception &) { - return SpecificFailure; - } - return Success; -} - -rtl::OUString normalize( - css::uno::Reference< css::ucb::XContentProvider > const & broker, - css::uno::Reference< css::uri::XUriReferenceFactory > const & uriFactory, - rtl::OUString const & uriReference) -{ - // normalizePrefix can potentially fail (a typically example being a file - // URL that denotes a non-existing resource); in such a case, try to - // normalize as long a prefix of the given URL as possible (i.e., normalize - // all the existing directories within the path): - rtl::OUString normalized; - sal_Int32 n = uriReference.indexOf('#'); - normalized = n == -1 ? uriReference : uriReference.copy(0, n); - switch (normalizePrefix(broker, normalized, &normalized)) { - case Success: - return n == -1 ? normalized : normalized + uriReference.copy(n); - case GeneralFailure: - return uriReference; - case SpecificFailure: - default: - break; - } - css::uno::Reference< css::uri::XUriReference > ref( - uriFactory->parse(uriReference)); - if (!isAbsoluteHierarchicalUriReference(ref)) { - return uriReference; - } - sal_Int32 count = ref->getPathSegmentCount(); - if (count < 2) { - return uriReference; - } - rtl::OUStringBuffer head(ref->getScheme()); - head.append(static_cast< sal_Unicode >(':')); - if (ref->hasAuthority()) { - head.appendAscii(RTL_CONSTASCII_STRINGPARAM("//")); - head.append(ref->getAuthority()); - } - for (sal_Int32 i = count - 1; i > 0; --i) { - rtl::OUStringBuffer buf(head); - for (sal_Int32 j = 0; j < i; ++j) { - buf.append(static_cast< sal_Unicode >('/')); - buf.append(ref->getPathSegment(j)); - } - normalized = buf.makeStringAndClear(); - if (normalizePrefix(broker, normalized, &normalized) != SpecificFailure) - { - buf.append(normalized); - css::uno::Reference< css::uri::XUriReference > preRef( - uriFactory->parse(normalized)); - if (!isAbsoluteHierarchicalUriReference(preRef)) { - // This could only happen if something is inconsistent: - break; - } - sal_Int32 preCount = preRef->getPathSegmentCount(); - // normalizePrefix may have added or removed a final slash: - if (preCount != i) { - if (preCount == i - 1) { - buf.append(static_cast< sal_Unicode >('/')); - } else if (preCount - 1 == i && buf.getLength() > 0 - && buf.charAt(buf.getLength() - 1) == '/') - { - buf.setLength(buf.getLength() - 1); - } else { - // This could only happen if something is inconsistent: - break; - } - } - for (sal_Int32 j = i; j < count; ++j) { - buf.append(static_cast< sal_Unicode >('/')); - buf.append(ref->getPathSegment(j)); - } - if (ref->hasQuery()) { - buf.append(static_cast< sal_Unicode >('?')); - buf.append(ref->getQuery()); - } - if (ref->hasFragment()) { - buf.append(static_cast< sal_Unicode >('#')); - buf.append(ref->getFragment()); - } - return buf.makeStringAndClear(); - } - } - return uriReference; -} - -} - -css::uno::Reference< css::uri::XUriReference > -URIHelper::normalizedMakeRelative( - css::uno::Reference< css::uno::XComponentContext > const & context, - rtl::OUString const & baseUriReference, rtl::OUString const & uriReference) -{ - OSL_ASSERT(context.is()); - css::uno::Reference< css::lang::XMultiComponentFactory > componentFactory( - context->getServiceManager()); - if (!componentFactory.is()) { - throw css::uno::RuntimeException( - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( - "component context has no service manager")), - css::uno::Reference< css::uno::XInterface >()); - } - css::uno::Sequence< css::uno::Any > args(2); - args[0] <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Local")); - args[1] <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Office")); - css::uno::Reference< css::ucb::XContentProvider > broker; - try { - broker = css::uno::Reference< css::ucb::XContentProvider >( - componentFactory->createInstanceWithArgumentsAndContext( - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.ucb.UniversalContentBroker")), - args, context), - css::uno::UNO_QUERY_THROW); - } catch (css::uno::RuntimeException &) { - throw; - } catch (css::uno::Exception &) { - css::uno::Any exception(cppu::getCaughtException()); - throw css::lang::WrappedTargetRuntimeException( - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( - "creating com.sun.star.ucb.UniversalContentBroker failed")), - css::uno::Reference< css::uno::XInterface >(), - exception); - } - css::uno::Reference< css::uri::XUriReferenceFactory > uriFactory( - css::uri::UriReferenceFactory::create(context)); - return uriFactory->makeRelative( - uriFactory->parse(normalize(broker, uriFactory, baseUriReference)), - uriFactory->parse(normalize(broker, uriFactory, uriReference)), true, - true, false); -} - -rtl::OUString URIHelper::simpleNormalizedMakeRelative( - rtl::OUString const & baseUriReference, rtl::OUString const & uriReference) -{ - com::sun::star::uno::Reference< com::sun::star::uri::XUriReference > rel( - URIHelper::normalizedMakeRelative( - com::sun::star::uno::Reference< - com::sun::star::uno::XComponentContext >( - (com::sun::star::uno::Reference< - com::sun::star::beans::XPropertySet >( - comphelper::getProcessServiceFactory(), - com::sun::star::uno::UNO_QUERY_THROW)-> - getPropertyValue( - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("DefaultContext")))), - com::sun::star::uno::UNO_QUERY_THROW), - baseUriReference, uriReference)); - return rel.is() ? rel->getUriReference() : uriReference; -} - -//============================================================================ -// -// FindFirstURLInText -// -//============================================================================ - -namespace unnamed_svtools_urihelper { - -inline xub_StrLen nextChar(UniString const & rStr, xub_StrLen nPos) -{ - return INetMIME::isHighSurrogate(rStr.GetChar(nPos)) - && rStr.Len() - nPos >= 2 - && INetMIME::isLowSurrogate(rStr.GetChar(nPos + 1)) ? - nPos + 2 : nPos + 1; -} - -bool isBoundary1(CharClass const & rCharClass, UniString const & rStr, - xub_StrLen nPos, xub_StrLen nEnd) -{ - if (nPos == nEnd) - return true; - if (rCharClass.isLetterNumeric(rStr, nPos)) - return false; - switch (rStr.GetChar(nPos)) - { - case '$': - case '%': - case '&': - case '-': - case '/': - case '@': - case '\\': - return false; - default: - return true; - } -} - -bool isBoundary2(CharClass const & rCharClass, UniString const & rStr, - xub_StrLen nPos, xub_StrLen nEnd) -{ - if (nPos == nEnd) - return true; - if (rCharClass.isLetterNumeric(rStr, nPos)) - return false; - switch (rStr.GetChar(nPos)) - { - case '!': - case '#': - case '$': - case '%': - case '&': - case '\'': - case '*': - case '+': - case '-': - case '/': - case '=': - case '?': - case '@': - case '^': - case '_': - case '`': - case '{': - case '|': - case '}': - case '~': - return false; - default: - return true; - } -} - -bool checkWChar(CharClass const & rCharClass, UniString const & rStr, - xub_StrLen * pPos, xub_StrLen * pEnd, bool bBackslash = false, - bool bPipe = false) -{ - sal_Unicode c = rStr.GetChar(*pPos); - if (INetMIME::isUSASCII(c)) - { - static sal_uInt8 const aMap[128] - = { 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 0, 0, 4, 4, 4, 1, // !"#$%&' - 1, 1, 1, 1, 1, 4, 1, 4, // ()*+,-./ - 4, 4, 4, 4, 4, 4, 4, 4, // 01234567 - 4, 4, 1, 1, 0, 1, 0, 1, // 89:;<=>? - 4, 4, 4, 4, 4, 4, 4, 4, // @ABCDEFG - 4, 4, 4, 4, 4, 4, 4, 4, // HIJKLMNO - 4, 4, 4, 4, 4, 4, 4, 4, // PQRSTUVW - 4, 4, 4, 1, 2, 1, 0, 1, // XYZ[\]^_ - 0, 4, 4, 4, 4, 4, 4, 4, // `abcdefg - 4, 4, 4, 4, 4, 4, 4, 4, // hijklmno - 4, 4, 4, 4, 4, 4, 4, 4, // pqrstuvw - 4, 4, 4, 0, 3, 0, 1, 0 }; // xyz{|}~ - switch (aMap[c]) - { - default: // not uric - return false; - - case 1: // uric - ++(*pPos); - return true; - - case 2: // "\" - if (bBackslash) - { - *pEnd = ++(*pPos); - return true; - } - else - return false; - - case 3: // "|" - if (bPipe) - { - *pEnd = ++(*pPos); - return true; - } - else - return false; - - case 4: // alpha, digit, "$", "%", "&", "-", "/", "@" (see - // isBoundary1) - *pEnd = ++(*pPos); - return true; - } - } - else if (rCharClass.isLetterNumeric(rStr, *pPos)) - { - *pEnd = *pPos = nextChar(rStr, *pPos); - return true; - } - else - return false; -} - -sal_uInt32 scanDomain(UniString const & rStr, xub_StrLen * pPos, - xub_StrLen nEnd) -{ - sal_Unicode const * pBuffer = rStr.GetBuffer(); - sal_Unicode const * p = pBuffer + *pPos; - sal_uInt32 nLabels = INetURLObject::scanDomain(p, pBuffer + nEnd, false); - *pPos = sal::static_int_cast< xub_StrLen >(p - pBuffer); - return nLabels; -} - -} - -UniString -URIHelper::FindFirstURLInText(UniString const & rText, - xub_StrLen & rBegin, - xub_StrLen & rEnd, - CharClass const & rCharClass, - INetURLObject::EncodeMechanism eMechanism, - rtl_TextEncoding eCharset, - INetURLObject::FSysStyle eStyle) -{ - if (!(rBegin <= rEnd && rEnd <= rText.Len())) - return UniString(); - - // Search for the first substring of [rBegin..rEnd[ that matches any of the - // following productions (for which the appropriate style bit is set in - // eStyle, if applicable). - // - // 1st Production (known scheme): - // \B1 <one of the known schemes, except file> ":" 1*wchar ["#" 1*wchar] - // \B1 - // - // 2nd Production (file): - // \B1 "FILE:" 1*(wchar / "\" / "|") ["#" 1*wchar] \B1 - // - // 3rd Production (ftp): - // \B1 "FTP" 2*("." label) ["/" *wchar] ["#" 1*wchar] \B1 - // - // 4th Production (http): - // \B1 "WWW" 2*("." label) ["/" *wchar] ["#" 1*wchar] \B1 - // - // 5th Production (mailto): - // \B2 local-part "@" domain \B1 - // - // 6th Production (UNC file): - // \B1 "\\" domain "\" *(wchar / "\") \B1 - // - // 7th Production (DOS file): - // \B1 ALPHA ":\" *(wchar / "\") \B1 - // - // 8th Production (Unix-like DOS file): - // \B1 ALPHA ":/" *(wchar / "\") \B1 - // - // The productions use the following auxiliary rules. - // - // local-part = atom *("." atom) - // atom = 1*(alphanum / "!" / "#" / "$" / "%" / "&" / "'" / "*" / "+" - // / "-" / "/" / "=" / "?" / "^" / "_" / "`" / "{" / "|" / "}" - // / "~") - // domain = label *("." label) - // label = alphanum [*(alphanum / "-") alphanum] - // alphanum = ALPHA / DIGIT - // wchar = <any uric character (ignoring the escaped rule), or "%", or - // a letter or digit (according to rCharClass)> - // - // "\B1" (boundary 1) stands for the beginning or end of the block of text, - // or a character that is neither (a) a letter or digit (according to - // rCharClass), nor (b) any of "$", "%", "&", "-", "/", "@", or "\". - // (FIXME: What was the rationale for this set of punctuation characters?) - // - // "\B2" (boundary 2) stands for the beginning or end of the block of text, - // or a character that is neither (a) a letter or digit (according to - // rCharClass), nor (b) any of "!", "#", "$", "%", "&", "'", "*", "+", "-", - // "/", "=", "?", "@", "^", "_", "`", "{", "|", "}", or "~" (i.e., an RFC - // 822 <atom> character, or "@" from \B1's set above). - // - // Productions 1--4, and 6--8 try to find a maximum-length match, but they - // stop at the first <wchar> character that is a "\B1" character which is - // only followed by "\B1" characters (taking "\" and "|" characters into - // account appropriately). Production 5 simply tries to find a maximum- - // length match. - // - // Productions 1--4 use the given eMechanism and eCharset. Productions 5--9 - // use ENCODE_ALL. - // - // Productions 6--9 are only applicable if the FSYS_DOS bit is set in - // eStyle. - - bool bBoundary1 = true; - bool bBoundary2 = true; - for (xub_StrLen nPos = rBegin; nPos != rEnd; nPos = nextChar(rText, nPos)) - { - sal_Unicode c = rText.GetChar(nPos); - if (bBoundary1) - { - if (INetMIME::isAlpha(c)) - { - xub_StrLen i = nPos; - INetProtocol eScheme - = INetURLObject::CompareProtocolScheme(UniString(rText, i, - rEnd)); - if (eScheme == INET_PROT_FILE) // 2nd - { - while (rText.GetChar(i++) != ':') ; - xub_StrLen nPrefixEnd = i; - xub_StrLen nUriEnd = i; - while (i != rEnd - && checkWChar(rCharClass, rText, &i, &nUriEnd, true, - true)) ; - if (i != nPrefixEnd && rText.GetChar(i) == '#') - { - ++i; - while (i != rEnd - && checkWChar(rCharClass, rText, &i, &nUriEnd)) ; - } - if (nUriEnd != nPrefixEnd - && isBoundary1(rCharClass, rText, nUriEnd, rEnd)) - { - INetURLObject aUri(UniString(rText, nPos, - nUriEnd - nPos), - INET_PROT_FILE, eMechanism, eCharset, - eStyle); - if (!aUri.HasError()) - { - rBegin = nPos; - rEnd = nUriEnd; - return - aUri.GetMainURL(INetURLObject::DECODE_TO_IURI); - } - } - } - else if (eScheme != INET_PROT_NOT_VALID) // 1st - { - while (rText.GetChar(i++) != ':') ; - xub_StrLen nPrefixEnd = i; - xub_StrLen nUriEnd = i; - while (i != rEnd - && checkWChar(rCharClass, rText, &i, &nUriEnd)) ; - if (i != nPrefixEnd && rText.GetChar(i) == '#') - { - ++i; - while (i != rEnd - && checkWChar(rCharClass, rText, &i, &nUriEnd)) ; - } - if (nUriEnd != nPrefixEnd - && (isBoundary1(rCharClass, rText, nUriEnd, rEnd) - || rText.GetChar(nUriEnd) == '\\')) - { - INetURLObject aUri(UniString(rText, nPos, - nUriEnd - nPos), - INET_PROT_HTTP, eMechanism, - eCharset); - if (!aUri.HasError()) - { - rBegin = nPos; - rEnd = nUriEnd; - return - aUri.GetMainURL(INetURLObject::DECODE_TO_IURI); - } - } - } - - // 3rd, 4th: - i = nPos; - sal_uInt32 nLabels = scanDomain(rText, &i, rEnd); - if (nLabels >= 3 - && rText.GetChar(nPos + 3) == '.' - && (((rText.GetChar(nPos) == 'w' - || rText.GetChar(nPos) == 'W') - && (rText.GetChar(nPos + 1) == 'w' - || rText.GetChar(nPos + 1) == 'W') - && (rText.GetChar(nPos + 2) == 'w' - || rText.GetChar(nPos + 2) == 'W')) - || ((rText.GetChar(nPos) == 'f' - || rText.GetChar(nPos) == 'F') - && (rText.GetChar(nPos + 1) == 't' - || rText.GetChar(nPos + 1) == 'T') - && (rText.GetChar(nPos + 2) == 'p' - || rText.GetChar(nPos + 2) == 'P')))) - // (note that rText.GetChar(nPos + 3) is guaranteed to be - // valid) - { - xub_StrLen nUriEnd = i; - if (i != rEnd && rText.GetChar(i) == '/') - { - nUriEnd = ++i; - while (i != rEnd - && checkWChar(rCharClass, rText, &i, &nUriEnd)) ; - } - if (i != rEnd && rText.GetChar(i) == '#') - { - ++i; - while (i != rEnd - && checkWChar(rCharClass, rText, &i, &nUriEnd)) ; - } - if (isBoundary1(rCharClass, rText, nUriEnd, rEnd) - || rText.GetChar(nUriEnd) == '\\') - { - INetURLObject aUri(UniString(rText, nPos, - nUriEnd - nPos), - INET_PROT_HTTP, eMechanism, - eCharset); - if (!aUri.HasError()) - { - rBegin = nPos; - rEnd = nUriEnd; - return - aUri.GetMainURL(INetURLObject::DECODE_TO_IURI); - } - } - } - - if ((eStyle & INetURLObject::FSYS_DOS) != 0 && rEnd - nPos >= 3 - && rText.GetChar(nPos + 1) == ':' - && (rText.GetChar(nPos + 2) == '/' - || rText.GetChar(nPos + 2) == '\\')) // 7th, 8th - { - i = nPos + 3; - xub_StrLen nUriEnd = i; - while (i != rEnd - && checkWChar(rCharClass, rText, &i, &nUriEnd)) ; - if (isBoundary1(rCharClass, rText, nUriEnd, rEnd)) - { - INetURLObject aUri(UniString(rText, nPos, - nUriEnd - nPos), - INET_PROT_FILE, - INetURLObject::ENCODE_ALL, - RTL_TEXTENCODING_UTF8, - INetURLObject::FSYS_DOS); - if (!aUri.HasError()) - { - rBegin = nPos; - rEnd = nUriEnd; - return - aUri.GetMainURL(INetURLObject::DECODE_TO_IURI); - } - } - } - } - else if ((eStyle & INetURLObject::FSYS_DOS) != 0 && rEnd - nPos >= 2 - && rText.GetChar(nPos) == '\\' - && rText.GetChar(nPos + 1) == '\\') // 6th - { - xub_StrLen i = nPos + 2; - sal_uInt32 nLabels = scanDomain(rText, &i, rEnd); - if (nLabels >= 1 && i != rEnd && rText.GetChar(i) == '\\') - { - xub_StrLen nUriEnd = ++i; - while (i != rEnd - && checkWChar(rCharClass, rText, &i, &nUriEnd, - true)) ; - if (isBoundary1(rCharClass, rText, nUriEnd, rEnd)) - { - INetURLObject aUri(UniString(rText, nPos, - nUriEnd - nPos), - INET_PROT_FILE, - INetURLObject::ENCODE_ALL, - RTL_TEXTENCODING_UTF8, - INetURLObject::FSYS_DOS); - if (!aUri.HasError()) - { - rBegin = nPos; - rEnd = nUriEnd; - return - aUri.GetMainURL(INetURLObject::DECODE_TO_IURI); - } - } - } - } - } - if (bBoundary2 && INetMIME::isAtomChar(c)) // 5th - { - bool bDot = false; - for (xub_StrLen i = nPos + 1; i != rEnd; ++i) - { - sal_Unicode c2 = rText.GetChar(i); - if (INetMIME::isAtomChar(c2)) - bDot = false; - else if (bDot) - break; - else if (c2 == '.') - bDot = true; - else - { - if (c2 == '@') - { - ++i; - sal_uInt32 nLabels = scanDomain(rText, &i, rEnd); - if (nLabels >= 1 - && isBoundary1(rCharClass, rText, i, rEnd)) - { - INetURLObject aUri(UniString(rText, nPos, i - nPos), - INET_PROT_MAILTO, - INetURLObject::ENCODE_ALL); - if (!aUri.HasError()) - { - rBegin = nPos; - rEnd = i; - return aUri.GetMainURL( - INetURLObject::DECODE_TO_IURI); - } - } - } - break; - } - } - } - bBoundary1 = isBoundary1(rCharClass, rText, nPos, rEnd); - bBoundary2 = isBoundary2(rCharClass, rText, nPos, rEnd); - } - rBegin = rEnd; - return UniString(); -} - -//============================================================================ -// -// removePassword -// -//============================================================================ - -UniString -URIHelper::removePassword(UniString const & rURI, - INetURLObject::EncodeMechanism eEncodeMechanism, - INetURLObject::DecodeMechanism eDecodeMechanism, - rtl_TextEncoding eCharset) -{ - INetURLObject aObj(rURI, eEncodeMechanism, eCharset); - return aObj.HasError() ? - rURI : - String(aObj.GetURLNoPass(eDecodeMechanism, eCharset)); -} - -//============================================================================ -// -// queryFSysStyle -// -//============================================================================ - -INetURLObject::FSysStyle URIHelper::queryFSysStyle(UniString const & rFileUrl, - bool bAddConvenienceStyles) - throw (uno::RuntimeException) -{ - ::ucbhelper::ContentBroker const * pBroker = ::ucbhelper::ContentBroker::get(); - uno::Reference< ucb::XContentProviderManager > xManager; - if (pBroker) - xManager = pBroker->getContentProviderManagerInterface(); - uno::Reference< beans::XPropertySet > xProperties; - if (xManager.is()) - xProperties - = uno::Reference< beans::XPropertySet >( - xManager->queryContentProvider(rFileUrl), uno::UNO_QUERY); - sal_Int32 nNotation = ucb::FileSystemNotation::UNKNOWN_NOTATION; - if (xProperties.is()) - try - { - xProperties->getPropertyValue(rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( - "FileSystemNotation"))) - >>= nNotation; - } - catch (beans::UnknownPropertyException const &) {} - catch (lang::WrappedTargetException const &) {} - - // The following code depends on the fact that the - // com::sun::star::ucb::FileSystemNotation constants range from UNKNOWN to - // MAC, without any holes. The table below has two entries per notation, - // the first is used if bAddConvenienceStyles == false, while the second - // is used if bAddConvenienceStyles == true: - static INetURLObject::FSysStyle const aMap[][2] - = { { INetURLObject::FSysStyle(0), - INetURLObject::FSYS_DETECT }, - // UNKNOWN - { INetURLObject::FSYS_UNX, - INetURLObject::FSysStyle(INetURLObject::FSYS_VOS - | INetURLObject::FSYS_UNX) }, - // UNIX - { INetURLObject::FSYS_DOS, - INetURLObject::FSysStyle(INetURLObject::FSYS_VOS - | INetURLObject::FSYS_UNX - | INetURLObject::FSYS_DOS) }, - // DOS - { INetURLObject::FSYS_MAC, - INetURLObject::FSysStyle(INetURLObject::FSYS_VOS - | INetURLObject::FSYS_UNX - | INetURLObject::FSYS_MAC) } }; - return aMap[nNotation < ucb::FileSystemNotation::UNKNOWN_NOTATION - || nNotation > ucb::FileSystemNotation::MAC_NOTATION ? - 0 : - nNotation - - ucb::FileSystemNotation::UNKNOWN_NOTATION] - [bAddConvenienceStyles]; -} diff --git a/svtools/source/misc/iniprop.cxx b/svtools/source/misc/wallitem.cxx index 16e0e5bc48a7..6ceb414db003 100644 --- a/svtools/source/misc/iniprop.cxx +++ b/svtools/source/misc/wallitem.cxx @@ -6,8 +6,8 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: iniprop.cxx,v $ - * $Revision: 1.4 $ + * $RCSfile: wallitem.cxx,v $ + * $Revision: 1.10 $ * * This file is part of OpenOffice.org. * @@ -30,18 +30,39 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svtools.hxx" +#include <cppuhelper/weak.hxx> +#include <com/sun/star/io/XOutputStream.hpp> +#include <com/sun/star/io/XActiveDataSource.hpp> +#include <com/sun/star/io/XActiveDataControl.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <comphelper/processfactory.hxx> -#include "iniprop.hxx" +#include <tools/stream.hxx> +#include <tools/debug.hxx> +#include <tools/string.hxx> +#include <tools/urlobj.hxx> +#include <tools/stream.hxx> +#include <tools/color.hxx> -//------------------------------------------------------------------------- +#include <vcl/graph.hxx> +#include <vcl/svapp.hxx> +#include <vcl/wrkwin.hxx> +#include <vcl/gradient.hxx> +#include <vcl/cvtgrf.hxx> -TYPEINIT1(SfxAppIniManagerProperty, ApplicationProperty); +#include "wallitem.hxx" +#include <svl/cntwall.hxx> -//------------------------------------------------------------------------- +// ----------------------------------------------------------------------- -SfxAppIniManagerProperty::~SfxAppIniManagerProperty() +//static +void SfxBrushItemLink::Set( SfxBrushItemLink* pLink ) { + SfxBrushItemLink** ppLink = (SfxBrushItemLink**)GetAppData(SHL_BRUSHITEM); + if( !*ppLink ) + *ppLink = pLink; + else + delete pLink; } - |