diff options
author | thb <thb@openoffice.org> | 2010-01-07 13:07:30 +0100 |
---|---|---|
committer | thb <thb@openoffice.org> | 2010-01-07 13:07:30 +0100 |
commit | b2960f768b727ba6ed8217d3482e635fd0d1bdd7 (patch) | |
tree | 9e604fce4d985968d8a08450805b13e7d90377d0 | |
parent | 3faab003ceeebd990b543252c015defe66e74679 (diff) | |
parent | fed92864b28a32bee9d7cd8bfffd5a4b523e18d4 (diff) |
eraser01: merge with DEV300 m68
477 files changed, 17389 insertions, 10561 deletions
diff --git a/bridges/prj/build.lst b/bridges/prj/build.lst index 430c49e8a849..c6e342520672 100644 --- a/bridges/prj/build.lst +++ b/bridges/prj/build.lst @@ -21,6 +21,7 @@ br bridges\source\cpp_uno\gcc3_linux_s390x nmake - u br_gccl3x br_unotypes br_i br bridges\source\cpp_uno\gcc3_linux_sparc nmake - u br_gccl3s br_unotypes br_cppuno_shared br_inc NULL br bridges\source\cpp_uno\gcc3_linux_arm nmake - u br_gccl3r br_unotypes NULL br bridges\source\cpp_uno\gcc3_linux_ia64 nmake - u br_gccl3a br_unotypes NULL +br bridges\source\cpp_uno\gcc3_linux_hppa nmake - u br_gccl3h br_unotypes NULL br bridges\source\cpp_uno\gcc3_macosx_intel nmake - u br_gcc3macoxi br_cppuno_shared br_unotypes br_inc NULL br bridges\source\cpp_uno\gcc3_macosx_powerpc nmake - u br_gcc3macoxp br_cppuno_shared br_unotypes br_inc NULL br bridges\source\cpp_uno\cc50_solaris_sparc nmake - u br_cc50sols br_unotypes br_cppuno_shared br_inc NULL diff --git a/bridges/source/cpp_uno/gcc3_linux_arm/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_linux_arm/uno2cpp.cxx index b365bdb8aee1..f59a16b2ac38 100644 --- a/bridges/source/cpp_uno/gcc3_linux_arm/uno2cpp.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_arm/uno2cpp.cxx @@ -45,7 +45,17 @@ #include <stdio.h> #include <string.h> -#if defined(__ARM_EABI__) && !defined(__SOFTFP__) +/* + * Based on http://gcc.gnu.org/PR41443 + * References to __SOFTFP__ are incorrect for EABI; the __SOFTFP__ code + * should be used for *soft-float ABI* whether or not VFP is enabled, + * and __SOFTFP__ does specifically mean soft-float not soft-float ABI. + * + * Changing the conditionals to __SOFTFP__ || __ARM_EABI__ then + * -mfloat-abi=softfp should work. -mfloat-abi=hard won't; that would + * need both a new macro to identify the hard-VFP ABI. + */ +#if !defined(__ARM_EABI__) && !defined(__SOFTFP__) #error Not Implemented /* @@ -103,7 +113,7 @@ namespace arm void MapReturn(long r0, long r1, typelib_TypeClass eReturnType, void *pRegisterReturn) { -#ifndef __SOFTFP__ +#if !defined(__ARM_EABI__) && !defined(__SOFTFP__) register float fret asm("f0"); register double dret asm("f0"); #endif @@ -128,14 +138,14 @@ void MapReturn(long r0, long r1, typelib_TypeClass eReturnType, void *pRegisterR *(unsigned char*)pRegisterReturn = (unsigned char)r0; break; case typelib_TypeClass_FLOAT: -#ifdef __SOFTFP__ +#if defined(__ARM_EABI__) || defined(__SOFTFP__) ((long*)pRegisterReturn)[0] = r0; #else *(float*)pRegisterReturn = fret; #endif break; case typelib_TypeClass_DOUBLE: -#ifdef __SOFTFP__ +#if defined(__ARM_EABI__) || defined(__SOFTFP__) ((long*)pRegisterReturn)[1] = r1; ((long*)pRegisterReturn)[0] = r0; #else diff --git a/bridges/source/cpp_uno/gcc3_linux_hppa/call.cxx b/bridges/source/cpp_uno/gcc3_linux_hppa/call.cxx new file mode 100644 index 000000000000..cd30e224bef5 --- /dev/null +++ b/bridges/source/cpp_uno/gcc3_linux_hppa/call.cxx @@ -0,0 +1,145 @@ +/************************************************************************* + * + * 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: uno2cpp.cxx,v $ + * $Revision: 1.2 $ + * + * 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 <malloc.h> +#include <rtl/alloc.h> + +#include <com/sun/star/uno/genfunc.hxx> +#include "com/sun/star/uno/RuntimeException.hpp" +#include <uno/data.h> + +#include <bridges/cpp_uno/shared/bridge.hxx> +#include <bridges/cpp_uno/shared/types.hxx> +#include <bridges/cpp_uno/shared/unointerfaceproxy.hxx> +#include <bridges/cpp_uno/shared/vtables.hxx> + +#include "share.hxx" + +#include <stdio.h> +#include <string.h> + +using namespace ::rtl; +using namespace ::com::sun::star::uno; + +void MapReturn(sal_uInt32 ret0, sal_uInt32 ret1, typelib_TypeDescription *pReturnTypeDescr, bool bRegisterReturn, sal_uInt32 *pRegisterReturn) +{ + register float fret asm("fr4"); + register double dret asm("fr4"); + + switch (pReturnTypeDescr->eTypeClass) + { + case typelib_TypeClass_HYPER: + case typelib_TypeClass_UNSIGNED_HYPER: + pRegisterReturn[1] = ret1; + case typelib_TypeClass_LONG: + case typelib_TypeClass_UNSIGNED_LONG: + case typelib_TypeClass_ENUM: + case typelib_TypeClass_CHAR: + case typelib_TypeClass_SHORT: + case typelib_TypeClass_UNSIGNED_SHORT: + case typelib_TypeClass_BOOLEAN: + case typelib_TypeClass_BYTE: + pRegisterReturn[0] = ret0; + break; + case typelib_TypeClass_FLOAT: + *(float*)pRegisterReturn = fret; + break; + case typelib_TypeClass_DOUBLE: + *(double*)pRegisterReturn = dret; + break; + case typelib_TypeClass_STRUCT: + case typelib_TypeClass_EXCEPTION: + { + if (bRegisterReturn) + { + pRegisterReturn[0] = ret0; + pRegisterReturn[1] = ret1; + } + break; + } + default: + break; + } +} + +//Moved callVirtual into this .cxx so that I can do this and get gcc to not +//touch r28 without having to learn any more pa-risc assembly than is +//strictly necessary +register sal_uInt32 r28 __asm__("%r28"); + +void callVirtualMethod(void * pThis, sal_uInt32 nVtableIndex, + void * pRegisterReturn, typelib_TypeDescription *pReturnTypeDescr, bool bRegisterReturn, + sal_uInt32 *pStack, sal_uInt32 nStack, sal_uInt32 *pGPR, double *pFPR) __attribute__((noinline)); + +void callVirtualMethod(void * pThis, sal_uInt32 nVtableIndex, + void * pRegisterReturn, typelib_TypeDescription *pReturnTypeDescr, bool bRegisterReturn, + sal_uInt32 *pStack, sal_uInt32 nStack, sal_uInt32 *pGPR, double *pFPR) +{ + register sal_uInt32* sp __asm__("%r30"); + + sal_uInt32 pMethod = *((sal_uInt32*)pThis); + pMethod += 4 * nVtableIndex; + pMethod = *((sal_uInt32 *)pMethod); + +#ifdef CMC_DEBUG + fprintf(stderr, "this is %p\n", pGPR[0]); + for (int i = 0; i < hppa::MAX_GPR_REGS ; ++i) + fprintf(stderr, "normal reg %d is %d %x\n", i, pGPR[i], pGPR[i]); + + for (int i = 0; i < hppa::MAX_SSE_REGS ; ++i) + fprintf(stderr, "float reg %d is %x\n", i, pFPR[i]); + + for (int i = 0; i < nStack; ++i) + fprintf(stderr, "stack bytes are %x\n", pStack[i]); +#endif + + //Always reserve 4 slots, and align to 8 bytes + sal_uInt32 nStackBytes = ( ( nStack + 4 + 1 ) >> 1 ) * 8; + __builtin_alloca(nStackBytes); + sal_uInt32 *stack = sp-8; + int o = -5; + for (sal_uInt32 i = 0; i < nStack; ++i, --o) + stack[o] = pStack[i]; + + typedef int (* FunctionCall )( sal_uInt32, sal_uInt32, sal_uInt32, sal_uInt32 ); + FunctionCall pFunc = (FunctionCall)pMethod; + + asm volatile("fldd %0, %%fr4" : : "m"(pFPR[0]) : "fr4"); + asm volatile("fldd %0, %%fr5" : : "m"(pFPR[1]) : "fr5"); + asm volatile("fldd %0, %%fr6" : : "m"(pFPR[2]) : "fr6"); + asm volatile("fldd %0, %%fr7" : : "m"(pFPR[3]) : "fr7"); + asm volatile("ldw %0, %%r28" : : "m"(pRegisterReturn) : "r28"); + (*pFunc)(pGPR[0], pGPR[1], pGPR[2], pGPR[3]); + + register sal_uInt32 r29 __asm__("%r29"); + MapReturn(r28, r29, pReturnTypeDescr, bRegisterReturn, (sal_uInt32*)pRegisterReturn); +} + +/* vi:set tabstop=4 shiftwidth=4 expandtab: */ diff --git a/bridges/source/cpp_uno/gcc3_linux_hppa/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_linux_hppa/cpp2uno.cxx new file mode 100644 index 000000000000..a78d7694c798 --- /dev/null +++ b/bridges/source/cpp_uno/gcc3_linux_hppa/cpp2uno.cxx @@ -0,0 +1,728 @@ +/************************************************************************* + * + * 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: cpp2uno.cxx,v $ + * $Revision: 1.2 $ + * + * 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 <malloc.h> +#include <hash_map> + +#include <rtl/alloc.h> +#include <osl/mutex.hxx> + +#include <com/sun/star/uno/genfunc.hxx> +#include "com/sun/star/uno/RuntimeException.hpp" +#include <uno/data.h> +#include <typelib/typedescription.hxx> + +#include "bridges/cpp_uno/shared/bridge.hxx" +#include "bridges/cpp_uno/shared/cppinterfaceproxy.hxx" +#include "bridges/cpp_uno/shared/types.hxx" +#include "bridges/cpp_uno/shared/vtablefactory.hxx" + +#include "share.hxx" + +#include <dlfcn.h> + + +using namespace ::osl; +using namespace ::rtl; +using namespace ::com::sun::star::uno; + +namespace +{ + + static typelib_TypeClass cpp2uno_call( + bridges::cpp_uno::shared::CppInterfaceProxy* pThis, + const typelib_TypeDescription * pMemberTypeDescr, + typelib_TypeDescriptionReference * pReturnTypeRef, + sal_Int32 nParams, typelib_MethodParameter * pParams, + long r8, void ** gpreg, double *fpreg, void ** ovrflw, + sal_Int64 * pRegisterReturn /* space for register return */ ) + { + void ** startovrflw; + int nregs = 0; //number of words passed in registers + +#ifdef CMC_DEBUG + fprintf(stderr, "cpp2uno_call\n"); +#endif + // return + typelib_TypeDescription * pReturnTypeDescr = 0; + if (pReturnTypeRef) + TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef ); + + void * pUnoReturn = 0; + // complex return ptr: if != 0 && != pUnoReturn, reconversion need + void * pCppReturn = 0; + + if (pReturnTypeDescr) + { + if (hppa::isRegisterReturn(pReturnTypeRef)) + { +#ifdef CMC_DEBUG + fprintf(stderr, "simple return\n"); +#endif + pUnoReturn = pRegisterReturn; // direct way for simple types + } + else + { +#ifdef CMC_DEBUG + fprintf(stderr, "complex return via r8\n"); +#endif + pCppReturn = (void *)r8; + + pUnoReturn = (bridges::cpp_uno::shared::relatesToInterfaceType( pReturnTypeDescr ) + ? alloca( pReturnTypeDescr->nSize ) + : pCppReturn); // direct way + } + } + // pop this + gpreg++; + fpreg++; + nregs++; + + // stack space + OSL_ENSURE( sizeof(void *) == sizeof(sal_Int32), "### unexpected size!" ); + // parameters + void ** pUnoArgs = (void **)alloca( 4 * sizeof(void *) * nParams ); + void ** pCppArgs = pUnoArgs + nParams; + // indizes of values this have to be converted (interface conversion + // cpp<=>uno) + sal_Int32 * pTempIndizes = (sal_Int32 *)(pUnoArgs + (2 * nParams)); + // type descriptions for reconversions + typelib_TypeDescription ** ppTempParamTypeDescr = + (typelib_TypeDescription **)(pUnoArgs + (3 * nParams)); + + sal_Int32 nTempIndizes = 0; + bool bOverFlowUsed = false; + for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos ) + { + const typelib_MethodParameter & rParam = pParams[nPos]; + typelib_TypeDescription * pParamTypeDescr = 0; + TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef ); + + if (!rParam.bOut && bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr )) + { + switch (pParamTypeDescr->eTypeClass) + { + case typelib_TypeClass_DOUBLE: + if (nregs < hppa::MAX_WORDS_IN_REGS && (nregs & 1)) + { + gpreg++; + fpreg++; + nregs++; + } + if (nregs < hppa::MAX_WORDS_IN_REGS-1) + { + fpreg++; + pCppArgs[nPos] = pUnoArgs[nPos] = fpreg; + gpreg+=2; + fpreg+=2; + nregs+=2; + } + else + { + if ((startovrflw-ovrflw) & 4) + ovrflw--; + pCppArgs[nPos] = pUnoArgs[nPos] = ((char*)ovrflw - 4); + bOverFlowUsed = true; + } + if (bOverFlowUsed) ovrflw-=2; + break; + case typelib_TypeClass_FLOAT: + if (nregs < hppa::MAX_WORDS_IN_REGS) + { + pCppArgs[nPos] = pUnoArgs[nPos] = fpreg; + gpreg++; + fpreg++; + nregs++; + } + else + { + pCppArgs[nPos] = pUnoArgs[nPos] = ovrflw; + bOverFlowUsed = true; + } + if (bOverFlowUsed) ovrflw--; + break; + case typelib_TypeClass_HYPER: + case typelib_TypeClass_UNSIGNED_HYPER: + if (nregs < hppa::MAX_WORDS_IN_REGS && (nregs & 1)) + { + gpreg++; + fpreg++; + nregs++; + } + if (nregs < hppa::MAX_WORDS_IN_REGS-1) + { + pCppArgs[nPos] = pUnoArgs[nPos] = gpreg; + gpreg+=2; + fpreg+=2; + nregs+=2; + } + else + { + if ((startovrflw-ovrflw) & 4) + ovrflw--; + pCppArgs[nPos] = pUnoArgs[nPos] = ((char*)ovrflw - 4); + bOverFlowUsed = true; + } + if (bOverFlowUsed) ovrflw-=2; + break; + case typelib_TypeClass_BYTE: + case typelib_TypeClass_BOOLEAN: + if (nregs < hppa::MAX_WORDS_IN_REGS) + { + pCppArgs[nPos] = pUnoArgs[nPos] = ((char*)gpreg + 3); + gpreg++; + fpreg++; + nregs++; + } + else + { + pCppArgs[nPos] = pUnoArgs[nPos] = ((char*)ovrflw+3); + bOverFlowUsed = true; + } + if (bOverFlowUsed) ovrflw--; + break; + case typelib_TypeClass_CHAR: + case typelib_TypeClass_SHORT: + case typelib_TypeClass_UNSIGNED_SHORT: + if (nregs < hppa::MAX_WORDS_IN_REGS) + { + pCppArgs[nPos] = pUnoArgs[nPos] = ((char*)gpreg+2); + gpreg++; + fpreg++; + nregs++; + } + else + { + pCppArgs[nPos] = pUnoArgs[nPos] = ((char*)ovrflw+2); + bOverFlowUsed = true; + } + if (bOverFlowUsed) ovrflw--; + break; + case typelib_TypeClass_ENUM: + case typelib_TypeClass_LONG: + case typelib_TypeClass_UNSIGNED_LONG: + default: + if (nregs < hppa::MAX_WORDS_IN_REGS) + { + pCppArgs[nPos] = pUnoArgs[nPos] = gpreg; + gpreg++; + fpreg++; + nregs++; + } + else + { + pCppArgs[nPos] = pUnoArgs[nPos] = ovrflw; + bOverFlowUsed = true; + } + if (bOverFlowUsed) ovrflw--; + break; + } + // no longer needed + TYPELIB_DANGER_RELEASE( pParamTypeDescr ); + } + else // ptr to complex value | ref + { + void *pCppStack; + + if (nregs < hppa::MAX_WORDS_IN_REGS) + { + pCppArgs[nPos] = pCppStack = *gpreg; + gpreg++; + fpreg++; + nregs++; + } + else + { + pCppArgs[nPos] = pCppStack = *ovrflw; + bOverFlowUsed = true; + } + if (bOverFlowUsed) ovrflw--; + + if (! rParam.bIn) // is pure out + { + // uno out is unconstructed mem! + pUnoArgs[nPos] = alloca( pParamTypeDescr->nSize ); + pTempIndizes[nTempIndizes] = nPos; + // will be released at reconversion + ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr; + } + // is in/inout + else if (bridges::cpp_uno::shared::relatesToInterfaceType( + pParamTypeDescr )) + { + uno_copyAndConvertData( pUnoArgs[nPos] = alloca( pParamTypeDescr->nSize ), + pCppStack, pParamTypeDescr, + pThis->getBridge()->getCpp2Uno() ); + pTempIndizes[nTempIndizes] = nPos; // has to be reconverted + // will be released at reconversion + ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr; + } + else // direct way + { + pUnoArgs[nPos] = pCppStack; + // no longer needed + TYPELIB_DANGER_RELEASE( pParamTypeDescr ); + } + } + } + + // ExceptionHolder + uno_Any aUnoExc; // Any will be constructed by callee + uno_Any * pUnoExc = &aUnoExc; + +#ifdef CMC_DEBUG + fprintf(stderr, "before dispatch\n"); +#endif + // invoke uno dispatch call + (*pThis->getUnoI()->pDispatcher)( + pThis->getUnoI(), pMemberTypeDescr, pUnoReturn, pUnoArgs, &pUnoExc ); + +#ifdef CMC_DEBUG + fprintf(stderr, "after dispatch\n"); +#endif + + // in case an exception occured... + if (pUnoExc) + { + // destruct temporary in/inout params + for ( ; nTempIndizes--; ) + { + sal_Int32 nIndex = pTempIndizes[nTempIndizes]; + + if (pParams[nIndex].bIn) // is in/inout => was constructed + uno_destructData( pUnoArgs[nIndex], + ppTempParamTypeDescr[nTempIndizes], 0 ); + TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndizes] ); + } + if (pReturnTypeDescr) + TYPELIB_DANGER_RELEASE( pReturnTypeDescr ); + + CPPU_CURRENT_NAMESPACE::raiseException( &aUnoExc, + pThis->getBridge()->getUno2Cpp() ); // has to destruct the any + // is here for dummy + return typelib_TypeClass_VOID; + } + else // else no exception occured... + { + // temporary params + for ( ; nTempIndizes--; ) + { + sal_Int32 nIndex = pTempIndizes[nTempIndizes]; + typelib_TypeDescription * pParamTypeDescr = + ppTempParamTypeDescr[nTempIndizes]; + + if (pParams[nIndex].bOut) // inout/out + { + // convert and assign + uno_destructData( pCppArgs[nIndex], pParamTypeDescr, + cpp_release ); + uno_copyAndConvertData( pCppArgs[nIndex], pUnoArgs[nIndex], + pParamTypeDescr, pThis->getBridge()->getUno2Cpp() ); + } + // destroy temp uno param + uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 ); + + TYPELIB_DANGER_RELEASE( pParamTypeDescr ); + } + // return + if (pCppReturn) // has complex return + { + if (pUnoReturn != pCppReturn) // needs reconversion + { + uno_copyAndConvertData( pCppReturn, pUnoReturn, + pReturnTypeDescr, pThis->getBridge()->getUno2Cpp() ); + // destroy temp uno return + uno_destructData( pUnoReturn, pReturnTypeDescr, 0 ); + } + // complex return ptr is set to eax + *(void **)pRegisterReturn = pCppReturn; + } + if (pReturnTypeDescr) + { + typelib_TypeClass eRet = + (typelib_TypeClass)pReturnTypeDescr->eTypeClass; + TYPELIB_DANGER_RELEASE( pReturnTypeDescr ); + return eRet; + } + else + return typelib_TypeClass_VOID; + } + } + + + //===================================================================== + static typelib_TypeClass cpp_mediate( + sal_Int32 nFunctionIndex, sal_Int32 nVtableOffset, + void ** gpreg, double* fpreg, + long sp, long r8, + sal_Int64 * pRegisterReturn /* space for register return */ ) + + { + void ** ovrflw = (void**)(sp); +#ifdef CMC_DEBUG + fprintf(stderr, "cpp_mediate with\n"); + fprintf(stderr, "%x %x\n", nFunctionIndex, nVtableOffset); + fprintf(stderr, "and %x %x\n", (long)(ovrflw[0]), (long)(ovrflw[-1])); + fprintf(stderr, "and %x %x\n", (long)(ovrflw[-2]), (long)(ovrflw[-3])); + fprintf(stderr, "and %x %x\n", (long)(ovrflw[-4]), (long)(ovrflw[-5])); + fprintf(stderr, "and %x %x\n", (long)(ovrflw[-6]), (long)(ovrflw[-7])); + fprintf(stderr, "and %x %x\n", (long)(ovrflw[-8]), (long)(ovrflw[-9])); + fprintf(stderr, "and %x %x\n", (long)(ovrflw[-10]), (long)(ovrflw[-11])); + fprintf(stderr, "and %x %x\n", (long)(ovrflw[-12]), (long)(ovrflw[-13])); + fprintf(stderr, "and %x %x\n", (long)(ovrflw[-14]), (long)(ovrflw[-15])); +#endif + OSL_ENSURE( sizeof(sal_Int32)==sizeof(void *), "### unexpected!" ); + + // gpreg: [ret *], this, [other gpr params] + // fpreg: [fpr params] + // ovrflw: [gpr or fpr params (properly aligned)] + + void * pThis; + if (nFunctionIndex & 0x80000000 ) + { + nFunctionIndex &= 0x7fffffff; + pThis = gpreg[1]; +#ifdef CMC_DEBUG + fprintf(stderr, "pThis is gpreg[1]\n"); +#endif + } + else + { + pThis = gpreg[0]; +#ifdef CMC_DEBUG + fprintf(stderr, "pThis is gpreg[0]\n"); +#endif + } + + pThis = static_cast< char * >(pThis) - nVtableOffset; + + bridges::cpp_uno::shared::CppInterfaceProxy * pCppI = + bridges::cpp_uno::shared::CppInterfaceProxy::castInterfaceToProxy( + pThis); + + typelib_InterfaceTypeDescription * pTypeDescr = pCppI->getTypeDescr(); + + OSL_ENSURE( nFunctionIndex < pTypeDescr->nMapFunctionIndexToMemberIndex, + "### illegal vtable index!" ); + if (nFunctionIndex >= pTypeDescr->nMapFunctionIndexToMemberIndex) + { + throw RuntimeException( + OUString::createFromAscii("illegal vtable index!"), + (XInterface *)pCppI ); + } + + // determine called method + OSL_ENSURE( nFunctionIndex < pTypeDescr->nMapFunctionIndexToMemberIndex, + "### illegal vtable index!" ); + sal_Int32 nMemberPos = + pTypeDescr->pMapFunctionIndexToMemberIndex[nFunctionIndex]; + OSL_ENSURE( nMemberPos < pTypeDescr->nAllMembers, + "### illegal member index!" ); + + TypeDescription aMemberDescr( pTypeDescr->ppAllMembers[nMemberPos] ); + + typelib_TypeClass eRet; + switch (aMemberDescr.get()->eTypeClass) + { + case typelib_TypeClass_INTERFACE_ATTRIBUTE: + { + if (pTypeDescr->pMapMemberIndexToFunctionIndex[nMemberPos] == + nFunctionIndex) + { + // is GET method + eRet = cpp2uno_call( + pCppI, aMemberDescr.get(), + ((typelib_InterfaceAttributeTypeDescription *)aMemberDescr.get())->pAttributeTypeRef, + 0, 0, // no params + r8, gpreg, fpreg, ovrflw, pRegisterReturn ); + } + else + { + // is SET method + typelib_MethodParameter aParam; + aParam.pTypeRef = + ((typelib_InterfaceAttributeTypeDescription *)aMemberDescr.get())->pAttributeTypeRef; + aParam.bIn = sal_True; + aParam.bOut = sal_False; + + eRet = cpp2uno_call( + pCppI, aMemberDescr.get(), + 0, // indicates void return + 1, &aParam, + r8, gpreg, fpreg, ovrflw, pRegisterReturn ); + } + break; + } + case typelib_TypeClass_INTERFACE_METHOD: + { + // is METHOD + switch (nFunctionIndex) + { + case 1: // acquire() + pCppI->acquireProxy(); // non virtual call! + eRet = typelib_TypeClass_VOID; + break; + case 2: // release() + pCppI->releaseProxy(); // non virtual call! + eRet = typelib_TypeClass_VOID; + break; + case 0: // queryInterface() opt + { + typelib_TypeDescription * pTD = 0; + TYPELIB_DANGER_GET(&pTD, + reinterpret_cast<Type *>(gpreg[1])->getTypeLibType()); + if (pTD) + { + XInterface * pInterface = 0; + (*pCppI->getBridge()->getCppEnv()->getRegisteredInterface)( + pCppI->getBridge()->getCppEnv(), + (void **)&pInterface, pCppI->getOid().pData, + (typelib_InterfaceTypeDescription *)pTD ); + + if (pInterface) + { + ::uno_any_construct( + reinterpret_cast< uno_Any * >( r8 ), + &pInterface, pTD, cpp_acquire ); + pInterface->release(); + TYPELIB_DANGER_RELEASE( pTD ); + *(void **)pRegisterReturn = (void*)r8; + eRet = typelib_TypeClass_ANY; + break; + } + TYPELIB_DANGER_RELEASE( pTD ); + } + } // else perform queryInterface() + default: + eRet = cpp2uno_call( + pCppI, aMemberDescr.get(), + ((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->pReturnTypeRef, + ((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->nParams, + ((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->pParams, + r8, gpreg, fpreg, ovrflw, pRegisterReturn ); + } + break; + } + default: + { + throw RuntimeException( + OUString::createFromAscii("no member description found!"), + (XInterface *)pCppI ); + // is here for dummy + eRet = typelib_TypeClass_VOID; + } + } + + return eRet; + } +} + +//======================================================================= +/** + * is called on incoming vtable calls + * (called by asm snippets) + */ + +sal_Int64 cpp_vtable_call( sal_uInt32 in0, sal_uInt32 in1, sal_uInt32 in2, sal_uInt32 in3, sal_uInt32 firstonstack ) +{ + register sal_Int32 r21 asm("r21"); + register sal_Int32 r22 asm("r22"); + register sal_Int32 r28 asm("r28"); + sal_Int32 functionIndex = r21; + sal_Int32 vtableOffset = r22; + sal_Int32 r8 = r28; + + long sp = (long)&firstonstack; + + sal_uInt32 gpreg[hppa::MAX_GPR_REGS]; + gpreg[0] = in0; + gpreg[1] = in1; + gpreg[2] = in2; + gpreg[3] = in3; + + float fpreg[hppa::MAX_SSE_REGS]; //todo + register float f0 asm("fr4"); fpreg[0] = f0; + register float f1 asm("fr5"); fpreg[1] = f1; + register float f2 asm("fr6"); fpreg[2] = f2; + register float f3 asm("fr7"); fpreg[3] = f3; + + double dpreg[hppa::MAX_SSE_REGS]; //todo + register double d0 asm("fr4"); dpreg[0] = d0; + register double d1 asm("fr5"); dpreg[1] = d1; + register double d2 asm("fr6"); dpreg[2] = d2; + register double d3 asm("fr7"); dpreg[3] = d3; + + +#ifdef CMC_DEBUG + fprintf(stderr, "got to cpp_vtable_call with %x %x\n", functionIndex, vtableOffset); + for (int i = 0; i < hppa::MAX_GPR_REGS; ++i) + fprintf(stderr, "reg %d is %d %x\n", i, gpreg[i], gpreg[i]); + for (int i = 0; i < hppa::MAX_SSE_REGS; ++i) + fprintf(stderr, "float reg %d is %f %x\n", i, fpreg[i], ((long*)fpreg)[i]); + for (int i = 0; i < 4; ++i) + fprintf(stderr, "double reg %d is %f %llx\n", i, dpreg[i], ((long long*)dpreg)[i]); +#endif + + sal_Int64 nRegReturn; + + typelib_TypeClass aType = + cpp_mediate( functionIndex, vtableOffset, (void**)gpreg, dpreg, sp, r8, &nRegReturn); + + switch( aType ) + { + case typelib_TypeClass_FLOAT: + f0 = (*((float*)&nRegReturn)); + break; + case typelib_TypeClass_DOUBLE: + d0 = (*((double*)&nRegReturn)); + break; + default: + break; + } + + return nRegReturn; +} + + +namespace +{ + const int codeSnippetSize = 44; + +# define unldil(v) (((v & 0x7c) << 14) | ((v & 0x180) << 7) | ((v & 0x3) << 12) | ((v & 0xffe00) >> 8) | ((v & 0x100000) >> 20)) +# define L21(v) unldil(((unsigned long)(v) >> 11) & 0x1fffff) //Left 21 bits +# define R11(v) (((unsigned long)(v) & 0x7FF) << 1) //Right 11 bits + + unsigned char *codeSnippet(unsigned char* code, sal_Int32 functionIndex, + sal_Int32 vtableOffset, bool bHasHiddenParam) + { + if (bHasHiddenParam) + functionIndex |= 0x80000000; + + unsigned char * p = code; + *(unsigned long*)&p[0] = 0xeaa00000; // b,l 0x8,r21 + *(unsigned long*)&p[4] = 0xd6a01c1e; // depwi 0,31,2,r21 + *(unsigned long*)&p[8] = 0x4aa10040; // ldw 32(r21),r1 + + *(unsigned long*)&p[12] = 0x22A00000 | L21(functionIndex); // ldil L<functionIndex>,r21 + *(unsigned long*)&p[16] = 0x36B50000 | R11(functionIndex); // ldo R<functionIndex>,r21 + + *(unsigned long*)&p[20] = 0x22C00000 | L21(vtableOffset); // ldil L<vtableOffset>,r22 + *(unsigned long*)&p[24] = 0x36D60000 | R11(vtableOffset); // ldo R<vtableOffset>,r22 + + *(unsigned long*)&p[28] = 0x0c201094; // ldw 0(r1),r20 + *(unsigned long*)&p[32] = 0xea80c000; // bv r0(r20) + *(unsigned long*)&p[36] = 0x0c281093; // ldw 4(r1),r19 + *(unsigned long*)&p[40] = ((unsigned long)(cpp_vtable_call) & ~2); + + return code + codeSnippetSize; + } +} + +struct bridges::cpp_uno::shared::VtableFactory::Slot { void * fn; }; + +bridges::cpp_uno::shared::VtableFactory::Slot * +bridges::cpp_uno::shared::VtableFactory::mapBlockToVtable(void * block) +{ + return static_cast< Slot * >(block) + 2; +} + +sal_Size bridges::cpp_uno::shared::VtableFactory::getBlockSize( + sal_Int32 slotCount) +{ + return (slotCount + 2) * sizeof (Slot) + slotCount * codeSnippetSize; +} + +bridges::cpp_uno::shared::VtableFactory::Slot * +bridges::cpp_uno::shared::VtableFactory::initializeBlock( + void * block, sal_Int32 slotCount) +{ + Slot * slots = mapBlockToVtable(block); + slots[-2].fn = 0; + slots[-1].fn = 0; + return slots + slotCount; +} + +unsigned char * bridges::cpp_uno::shared::VtableFactory::addLocalFunctions( + Slot ** slots, unsigned char * code, sal_PtrDiff writetoexecdiff, + typelib_InterfaceTypeDescription const * type, sal_Int32 functionOffset, + sal_Int32 functionCount, sal_Int32 vtableOffset) +{ + (*slots) -= functionCount; + Slot * s = *slots; + for (sal_Int32 i = 0; i < type->nMembers; ++i) + { + typelib_TypeDescription * member = 0; + TYPELIB_DANGER_GET(&member, type->ppMembers[i]); + OSL_ASSERT(member != 0); + switch (member->eTypeClass) + { + case typelib_TypeClass_INTERFACE_ATTRIBUTE: + // Getter: + (s++)->fn = code + writetoexecdiff; + code = codeSnippet(code, functionOffset++, vtableOffset, false); + // Setter: + if (!reinterpret_cast< + typelib_InterfaceAttributeTypeDescription * >( + member)->bReadOnly) + { + (s++)->fn = code + writetoexecdiff; + code = codeSnippet(code, functionOffset++, vtableOffset, false); + } + break; + case typelib_TypeClass_INTERFACE_METHOD: + { + (s++)->fn = code + writetoexecdiff; + code = codeSnippet(code, functionOffset++, vtableOffset, false); + break; + } + default: + OSL_ASSERT(false); + break; + } + TYPELIB_DANGER_RELEASE(member); + } + return code; +} + +void bridges::cpp_uno::shared::VtableFactory::flushCode( + unsigned char const *beg, unsigned char const *end) +{ + void *p = (void*)((size_t)beg & ~31); + size_t stride = 32; + while (p < end) + { + asm volatile("fdc (%0)\n\t" + "sync\n\t" + "fic,m %1(%%sr4, %0)\n\t" + "sync" : "+r"(p) : "r"(stride) : "memory"); + } +} + +/* vi:set tabstop=4 shiftwidth=4 expandtab: */ diff --git a/bridges/source/cpp_uno/gcc3_linux_hppa/except.cxx b/bridges/source/cpp_uno/gcc3_linux_hppa/except.cxx new file mode 100644 index 000000000000..8242bacaedc6 --- /dev/null +++ b/bridges/source/cpp_uno/gcc3_linux_hppa/except.cxx @@ -0,0 +1,337 @@ +/************************************************************************* + * + * 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: except.cxx,v $ + * $Revision: 1.2 $ + * + * 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 <stdio.h> +#include <string.h> +#include <dlfcn.h> +#include <cxxabi.h> +#include <hash_map> + +#include <rtl/strbuf.hxx> +#include <rtl/ustrbuf.hxx> +#include <osl/diagnose.h> +#include <osl/mutex.hxx> + +#include <com/sun/star/uno/genfunc.hxx> +#include "com/sun/star/uno/RuntimeException.hpp" +#include <typelib/typedescription.hxx> +#include <uno/any2.h> + +#include "share.hxx" + + +using namespace ::std; +using namespace ::osl; +using namespace ::rtl; +using namespace ::com::sun::star::uno; +using namespace ::__cxxabiv1; + +extern sal_Int32 * pHack; +extern sal_Int32 nHack; + +namespace CPPU_CURRENT_NAMESPACE +{ + void dummy_can_throw_anything( char const * ) + { + } + + //=================================================================== + static OUString toUNOname( char const * p ) SAL_THROW( () ) + { +#if OSL_DEBUG_LEVEL > 1 + char const * start = p; +#endif + + // example: N3com3sun4star4lang24IllegalArgumentExceptionE + + OUStringBuffer buf( 64 ); + OSL_ASSERT( 'N' == *p ); + ++p; // skip N + + while ('E' != *p) + { + // read chars count + long n = (*p++ - '0'); + while ('0' <= *p && '9' >= *p) + { + n *= 10; + n += (*p++ - '0'); + } + buf.appendAscii( p, n ); + p += n; + if ('E' != *p) + buf.append( (sal_Unicode)'.' ); + } + +#if OSL_DEBUG_LEVEL > 1 + OUString ret( buf.makeStringAndClear() ); + OString c_ret( OUStringToOString( ret, RTL_TEXTENCODING_ASCII_US ) ); + fprintf( stderr, "> toUNOname(): %s => %s\n", start, c_ret.getStr() ); + return ret; +#else + return buf.makeStringAndClear(); +#endif + } + + //===================================================================== + class RTTI + { + typedef hash_map< OUString, type_info *, OUStringHash > t_rtti_map; + + Mutex m_mutex; + t_rtti_map m_rttis; + t_rtti_map m_generatedRttis; + + void * m_hApp; + + public: + RTTI() SAL_THROW( () ); + ~RTTI() SAL_THROW( () ); + + type_info * getRTTI(typelib_CompoundTypeDescription *) SAL_THROW( () ); + }; + //____________________________________________________________________ + RTTI::RTTI() SAL_THROW( () ) + : m_hApp( dlopen( 0, RTLD_LAZY ) ) + { + } + //____________________________________________________________________ + RTTI::~RTTI() SAL_THROW( () ) + { + dlclose( m_hApp ); + } + + //____________________________________________________________________ + type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr ) SAL_THROW( () ) + { + type_info * rtti; + + OUString const & unoName = *(OUString const *)&pTypeDescr->aBase.pTypeName; + + MutexGuard guard( m_mutex ); + t_rtti_map::const_iterator iRttiFind( m_rttis.find( unoName ) ); + if (iRttiFind == m_rttis.end()) + { + // RTTI symbol + OStringBuffer buf( 64 ); + buf.append( RTL_CONSTASCII_STRINGPARAM("_ZTIN") ); + sal_Int32 index = 0; + do + { + OUString token( unoName.getToken( 0, '.', index ) ); + buf.append( token.getLength() ); + OString c_token( OUStringToOString( token, RTL_TEXTENCODING_ASCII_US ) ); + buf.append( c_token ); + } + while (index >= 0); + buf.append( 'E' ); + + OString symName( buf.makeStringAndClear() ); + rtti = (type_info *)dlsym( m_hApp, symName.getStr() ); + + if (rtti) + { + pair< t_rtti_map::iterator, bool > insertion( + m_rttis.insert( t_rtti_map::value_type( unoName, rtti ) ) ); + OSL_ENSURE( insertion.second, "### inserting new rtti failed?!" ); + } + else + { + // try to lookup the symbol in the generated rtti map + t_rtti_map::const_iterator iFind( m_generatedRttis.find( unoName ) ); + if (iFind == m_generatedRttis.end()) + { + // we must generate it ! + // symbol and rtti-name is nearly identical, + // the symbol is prefixed with _ZTI + char const * rttiName = symName.getStr() +4; +#if OSL_DEBUG_LEVEL > 1 + fprintf( stderr,"generated rtti for %s\n", rttiName ); +#endif + if (pTypeDescr->pBaseTypeDescription) + { + // ensure availability of base + type_info * base_rtti = getRTTI( + (typelib_CompoundTypeDescription *)pTypeDescr->pBaseTypeDescription ); + rtti = new __si_class_type_info( + strdup( rttiName ), (__class_type_info *)base_rtti ); + } + else + { + // this class has no base class + rtti = new __class_type_info( strdup( rttiName ) ); + } + + pair< t_rtti_map::iterator, bool > insertion( + m_generatedRttis.insert( t_rtti_map::value_type( unoName, rtti ) ) ); + OSL_ENSURE( insertion.second, "### inserting new generated rtti failed?!" ); + } + else // taking already generated rtti + { + rtti = iFind->second; + } + } + } + else + { + rtti = iRttiFind->second; + } + + return rtti; + } + + //------------------------------------------------------------------ + static void deleteException( void * pExc ) + { + __cxa_exception const * header = ((__cxa_exception const *)pExc - 1); + typelib_TypeDescription * pTD = 0; + OUString unoName( toUNOname( header->exceptionType->name() ) ); + ::typelib_typedescription_getByName( &pTD, unoName.pData ); + OSL_ENSURE( pTD, "### unknown exception type! leaving out destruction => leaking!!!" ); + if (pTD) + { + ::uno_destructData( pExc, pTD, cpp_release ); + ::typelib_typedescription_release( pTD ); + } + } + + //================================================================== + void raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp ) + { +#if OSL_DEBUG_LEVEL > 1 + OString cstr( + OUStringToOString( + *reinterpret_cast< OUString const * >( &pUnoExc->pType->pTypeName ), + RTL_TEXTENCODING_ASCII_US ) ); + fprintf( stderr, "> uno exception occured: %s\n", cstr.getStr() ); +#endif + void * pCppExc; + type_info * rtti; + + { + // construct cpp exception object + typelib_TypeDescription * pTypeDescr = 0; + TYPELIB_DANGER_GET( &pTypeDescr, pUnoExc->pType ); + OSL_ASSERT( pTypeDescr ); + if (! pTypeDescr) + { + throw RuntimeException( + OUString( RTL_CONSTASCII_USTRINGPARAM("cannot get typedescription for type ") ) + + *reinterpret_cast< OUString const * >( &pUnoExc->pType->pTypeName ), + Reference< XInterface >() ); + } + + pCppExc = __cxa_allocate_exception( pTypeDescr->nSize ); + ::uno_copyAndConvertData( pCppExc, pUnoExc->pData, pTypeDescr, pUno2Cpp ); + + // destruct uno exception + ::uno_any_destruct( pUnoExc, 0 ); + // avoiding locked counts + static RTTI * s_rtti = 0; + if (! s_rtti) + { + MutexGuard guard( Mutex::getGlobalMutex() ); + if (! s_rtti) + { +#ifdef LEAK_STATIC_DATA + s_rtti = new RTTI(); +#else + static RTTI rtti_data; + s_rtti = &rtti_data; +#endif + } + } + rtti = (type_info *)s_rtti->getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); + TYPELIB_DANGER_RELEASE( pTypeDescr ); + OSL_ENSURE( rtti, "### no rtti for throwing exception!" ); + if (! rtti) + { + throw RuntimeException( + OUString( RTL_CONSTASCII_USTRINGPARAM("no rtti for type ") ) + + *reinterpret_cast< OUString const * >( &pUnoExc->pType->pTypeName ), + Reference< XInterface >() ); + } + } + + + __cxa_throw( pCppExc, rtti, deleteException ); + } + + static void* getAdjustedPtr(__cxa_exception* header) + { + return header->adjustedPtr; + } + + //=================================================================== + void fillUnoException( __cxa_exception * header, uno_Any * pUnoExc, uno_Mapping * pCpp2Uno ) + { + if (! header) + { + RuntimeException aRE( + OUString( RTL_CONSTASCII_USTRINGPARAM("no exception header!") ), + Reference< XInterface >() ); + Type const & rType = ::getCppuType( &aRE ); + uno_type_any_constructAndConvert( pUnoExc, &aRE, rType.getTypeLibType(), pCpp2Uno ); +#if OSL_DEBUG_LEVEL > 0 + OString cstr( OUStringToOString( aRE.Message, RTL_TEXTENCODING_ASCII_US ) ); + OSL_ENSURE( 0, cstr.getStr() ); +#endif + return; + } + + typelib_TypeDescription * pExcTypeDescr = 0; + OUString unoName( toUNOname( header->exceptionType->name() ) ); +#if OSL_DEBUG_LEVEL > 1 + OString cstr_unoName( OUStringToOString( unoName, RTL_TEXTENCODING_ASCII_US ) ); + fprintf( stderr, "> c++ exception occured: %s\n", cstr_unoName.getStr() ); +#endif + typelib_typedescription_getByName( &pExcTypeDescr, unoName.pData ); + if (0 == pExcTypeDescr) + { + RuntimeException aRE( + OUString( RTL_CONSTASCII_USTRINGPARAM("exception type not found: ") ) + unoName, + Reference< XInterface >() ); + Type const & rType = ::getCppuType( &aRE ); + uno_type_any_constructAndConvert( pUnoExc, &aRE, rType.getTypeLibType(), pCpp2Uno ); +#if OSL_DEBUG_LEVEL > 0 + OString cstr( OUStringToOString( aRE.Message, RTL_TEXTENCODING_ASCII_US ) ); + OSL_ENSURE( 0, cstr.getStr() ); +#endif + } + else + { + // construct uno exception any + uno_any_constructAndConvert( pUnoExc, getAdjustedPtr(header), pExcTypeDescr, pCpp2Uno ); + typelib_typedescription_release( pExcTypeDescr ); + } + } +} + +/* vi:set tabstop=4 shiftwidth=4 expandtab: */ diff --git a/bridges/source/cpp_uno/gcc3_linux_hppa/makefile.mk b/bridges/source/cpp_uno/gcc3_linux_hppa/makefile.mk new file mode 100644 index 000000000000..fcdcea72454f --- /dev/null +++ b/bridges/source/cpp_uno/gcc3_linux_hppa/makefile.mk @@ -0,0 +1,86 @@ +#************************************************************************* +# +# 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: makefile.mk,v $ +# +# $Revision: 1.2 $ +# +# 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. +# +#************************************************************************* + +PRJ=..$/..$/.. + +PRJNAME=bridges +TARGET=gcc3_uno +LIBTARGET=no +ENABLE_EXCEPTIONS=TRUE +NO_BSYMBOLIC=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +# --- Files -------------------------------------------------------- + +.IF "$(COM)$(OS)$(CPU)" == "GCCLINUXH" + +.IF "$(cppu_no_leak)" == "" +CFLAGS += -DLEAK_STATIC_DATA +.ENDIF + +CFLAGSCXX += -fno-omit-frame-pointer + +NOOPTFILES= \ + $(SLO)$/cpp2uno.obj \ + $(SLO)$/except.obj \ + $(SLO)$/uno2cpp.obj \ + $(SLO)$/call.obj + +CFLAGSNOOPT=-O0 + +SLOFILES= \ + $(SLO)$/cpp2uno.obj \ + $(SLO)$/except.obj \ + $(SLO)$/uno2cpp.obj \ + $(SLO)$/call.obj + +SHL1TARGET= $(TARGET) + +SHL1DEF=$(MISC)$/$(SHL1TARGET).def +SHL1IMPLIB=i$(TARGET) +SHL1VERSIONMAP=..$/..$/bridge_exports.map +SHL1RPATH=URELIB + +SHL1OBJS = $(SLOFILES) +SHL1LIBS = $(SLB)$/cpp_uno_shared.lib + +SHL1STDLIBS= \ + $(CPPULIB) \ + $(SALLIB) + +.ENDIF + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk diff --git a/bridges/source/cpp_uno/gcc3_linux_hppa/share.hxx b/bridges/source/cpp_uno/gcc3_linux_hppa/share.hxx new file mode 100644 index 000000000000..eedfdf75da8d --- /dev/null +++ b/bridges/source/cpp_uno/gcc3_linux_hppa/share.hxx @@ -0,0 +1,102 @@ +/************************************************************************* + * + * 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: share.hxx,v $ + * $Revision: 1.2 $ + * + * 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 "uno/mapping.h" + +#include <typeinfo> +#include <exception> +#include <cstddef> + +namespace CPPU_CURRENT_NAMESPACE +{ + + void dummy_can_throw_anything( char const * ); + + +// ----- following decl from libstdc++-v3/libsupc++/unwind-cxx.h and unwind.h + +struct _Unwind_Exception +{ + unsigned exception_class __attribute__((__mode__(__DI__))); + void * exception_cleanup; + unsigned private_1 __attribute__((__mode__(__word__))); + unsigned private_2 __attribute__((__mode__(__word__))); +} __attribute__((__aligned__)); + +struct __cxa_exception +{ + ::std::type_info *exceptionType; + void (*exceptionDestructor)(void *); + + ::std::unexpected_handler unexpectedHandler; + ::std::terminate_handler terminateHandler; + + __cxa_exception *nextException; + + int handlerCount; + + int handlerSwitchValue; + const unsigned char *actionRecord; + const unsigned char *languageSpecificData; + void *catchTemp; + void *adjustedPtr; + + _Unwind_Exception unwindHeader; +}; + +extern "C" void *__cxa_allocate_exception( + std::size_t thrown_size ) throw(); +extern "C" void __cxa_throw ( + void *thrown_exception, std::type_info *tinfo, void (*dest) (void *) ) __attribute__((noreturn)); + +struct __cxa_eh_globals +{ + __cxa_exception *caughtExceptions; + unsigned int uncaughtExceptions; +}; +extern "C" __cxa_eh_globals *__cxa_get_globals () throw(); + +// ----- + +//================================================================================================== +void raiseException( + uno_Any * pUnoExc, uno_Mapping * pUno2Cpp ); +//================================================================================================== +void fillUnoException( + __cxa_exception * header, uno_Any *, uno_Mapping * pCpp2Uno ); +} + + +namespace hppa +{ + enum hppalimits { MAX_WORDS_IN_REGS = 4, MAX_GPR_REGS = 4, MAX_SSE_REGS = 4 }; + + bool isRegisterReturn( typelib_TypeDescriptionReference *pTypeRef ); +} diff --git a/bridges/source/cpp_uno/gcc3_linux_hppa/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_linux_hppa/uno2cpp.cxx new file mode 100644 index 000000000000..a342568d5bf8 --- /dev/null +++ b/bridges/source/cpp_uno/gcc3_linux_hppa/uno2cpp.cxx @@ -0,0 +1,524 @@ +/************************************************************************* + * + * 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: uno2cpp.cxx,v $ + * $Revision: 1.2 $ + * + * 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 <malloc.h> +#include <rtl/alloc.h> + +#include <com/sun/star/uno/genfunc.hxx> +#include "com/sun/star/uno/RuntimeException.hpp" +#include <uno/data.h> + +#include <bridges/cpp_uno/shared/bridge.hxx> +#include <bridges/cpp_uno/shared/types.hxx> +#include <bridges/cpp_uno/shared/unointerfaceproxy.hxx> +#include <bridges/cpp_uno/shared/vtables.hxx> + +#include "share.hxx" + +#include <stdio.h> +#include <string.h> + +using namespace ::rtl; +using namespace ::com::sun::star::uno; + +void callVirtualMethod(void * pThis, sal_uInt32 nVtableIndex, + void * pRegisterReturn, typelib_TypeDescription *pReturnTypeDescr, bool bRegisterReturn, + sal_uInt32 *pStack, sal_uInt32 nStack, sal_uInt32 *pGPR, double *pFPR); + +#define INSERT_INT32( pSV, nr, pGPR, pDS, bOverFlow )\ + if (nr < hppa::MAX_WORDS_IN_REGS) \ + { \ + pGPR[nr++] = *reinterpret_cast<sal_uInt32 *>( pSV ); \ + } \ + else \ + bOverFlow = true; \ + if (bOverFlow) \ + *pDS++ = *reinterpret_cast<sal_uInt32 *>( pSV ); + +#define INSERT_INT64( pSV, nr, pGPR, pDS, pStart, bOverFlow )\ + if ( (nr < hppa::MAX_WORDS_IN_REGS) && (nr % 2) ) \ + { \ + ++nr; \ + } \ + if ( nr < hppa::MAX_WORDS_IN_REGS ) \ + { \ + pGPR[nr++] = *reinterpret_cast<sal_uInt32 *>( pSV ); \ + pGPR[nr++] = *(reinterpret_cast<sal_uInt32 *>( pSV ) + 1); \ + } \ + else \ + bOverFlow = true; \ + if ( bOverFlow ) \ + { \ + if ( (pDS - pStart) % 2) \ + ++pDS; \ + *pDS++ = reinterpret_cast<sal_uInt32 *>( pSV )[1]; \ + *pDS++ = reinterpret_cast<sal_uInt32 *>( pSV )[0]; \ + } + +#define INSERT_FLOAT( pSV, nr, pFPR, pDS, bOverFlow ) \ + if (nr < hppa::MAX_WORDS_IN_REGS) \ + { \ + sal_uInt32 *pDouble = (sal_uInt32 *)&(pFPR[nr++]); \ + pDouble[0] = *reinterpret_cast<sal_uInt32 *>( pSV ); \ + } \ + else \ + bOverFlow = true; \ + if (bOverFlow) \ + *pDS++ = *reinterpret_cast<sal_uInt32 *>( pSV ); + +#define INSERT_DOUBLE( pSV, nr, pFPR, pDS, pStart, bOverFlow ) \ + if ( (nr < hppa::MAX_WORDS_IN_REGS) && (nr % 2) ) \ + { \ + ++nr; \ + } \ + if ( nr < hppa::MAX_WORDS_IN_REGS ) \ + { \ + sal_uInt32 *pDouble = (sal_uInt32 *)&(pFPR[nr+1]); \ + pDouble[0] = *reinterpret_cast<sal_uInt32 *>( pSV ); \ + pDouble[1] = *(reinterpret_cast<sal_uInt32 *>( pSV ) + 1); \ + nr+=2; \ + } \ + else \ + bOverFlow = true; \ + if ( bOverFlow ) \ + { \ + if ( (pDS - pStart) % 2) \ + ++pDS; \ + *pDS++ = reinterpret_cast<sal_uInt32 *>( pSV )[1]; \ + *pDS++ = reinterpret_cast<sal_uInt32 *>( pSV )[0]; \ + } + +#define INSERT_INT16( pSV, nr, pGPR, pDS, bOverFlow ) \ + if ( nr < hppa::MAX_WORDS_IN_REGS ) \ + pGPR[nr++] = *reinterpret_cast<sal_uInt16 *>( pSV ); \ + else \ + bOverFlow = true; \ + if (bOverFlow) \ + *pDS++ = *reinterpret_cast<sal_uInt16 *>( pSV ); + +#define INSERT_INT8( pSV, nr, pGPR, pDS, bOverFlow ) \ + if ( nr < hppa::MAX_WORDS_IN_REGS ) \ + pGPR[nr++] = *reinterpret_cast<sal_uInt8 *>( pSV ); \ + else \ + bOverFlow = true; \ + if (bOverFlow) \ + *pDS++ = *reinterpret_cast<sal_uInt8 *>( pSV ); + +namespace hppa +{ + bool is_complex_struct(const typelib_TypeDescription * type) + { + const typelib_CompoundTypeDescription * p + = reinterpret_cast< const typelib_CompoundTypeDescription * >(type); + for (sal_Int32 i = 0; i < p->nMembers; ++i) + { + if (p->ppTypeRefs[i]->eTypeClass == typelib_TypeClass_STRUCT || + p->ppTypeRefs[i]->eTypeClass == typelib_TypeClass_EXCEPTION) + { + typelib_TypeDescription * t = 0; + TYPELIB_DANGER_GET(&t, p->ppTypeRefs[i]); + bool b = is_complex_struct(t); + TYPELIB_DANGER_RELEASE(t); + if (b) { + return true; + } + } + else if (!bridges::cpp_uno::shared::isSimpleType(p->ppTypeRefs[i]->eTypeClass)) + return true; + } + if (p->pBaseTypeDescription != 0) + return is_complex_struct(&p->pBaseTypeDescription->aBase); + return false; + } + + bool isRegisterReturn( typelib_TypeDescriptionReference *pTypeRef ) + { + if (bridges::cpp_uno::shared::isSimpleType(pTypeRef)) + return true; + else if (pTypeRef->eTypeClass == typelib_TypeClass_STRUCT || pTypeRef->eTypeClass == typelib_TypeClass_EXCEPTION) + { + typelib_TypeDescription * pTypeDescr = 0; + TYPELIB_DANGER_GET( &pTypeDescr, pTypeRef ); + + /* If the struct is larger than 8 bytes, then there is a buffer at r8 to stick the return value into */ + bool bRet = pTypeDescr->nSize <= 8 && !is_complex_struct(pTypeDescr); + + TYPELIB_DANGER_RELEASE( pTypeDescr ); + return bRet; + } + return false; + } +} + + +namespace { +//======================================================================= +static void cpp_call( + bridges::cpp_uno::shared::UnoInterfaceProxy * pThis, + bridges::cpp_uno::shared::VtableSlot aVtableSlot, + typelib_TypeDescriptionReference * pReturnTypeRef, + sal_Int32 nParams, typelib_MethodParameter * pParams, + void * pUnoReturn, void * pUnoArgs[], uno_Any ** ppUnoExc ) +{ + // max space for: [complex ret ptr], values|ptr ... + sal_uInt32 * pStack = (sal_uInt32 *)__builtin_alloca( + sizeof(sal_Int32) + ((nParams+2) * sizeof(sal_Int64)) ); + sal_uInt32 * pStackStart = pStack; + + sal_uInt32 pGPR[hppa::MAX_GPR_REGS]; + double pFPR[hppa::MAX_SSE_REGS]; + sal_uInt32 nRegs=0; + + // return + typelib_TypeDescription * pReturnTypeDescr = 0; + TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef ); + OSL_ENSURE( pReturnTypeDescr, "### expected return type description!" ); + + void * pCppReturn = 0; // if != 0 && != pUnoReturn, needs reconversion + bool bOverFlow = false; + bool bRegisterReturn = true; + + if (pReturnTypeDescr) + { + + bRegisterReturn = hppa::isRegisterReturn(pReturnTypeRef); + if (bRegisterReturn) + pCppReturn = pUnoReturn; // direct way for simple types + else + { + // complex return via ptr + pCppReturn = (bridges::cpp_uno::shared::relatesToInterfaceType( pReturnTypeDescr ) + ? __builtin_alloca( pReturnTypeDescr->nSize ) + : pUnoReturn); // direct way + } + } + // push this + void * pAdjustedThisPtr = reinterpret_cast< void ** >(pThis->getCppI()) + + aVtableSlot.offset; + INSERT_INT32( &pAdjustedThisPtr, nRegs, pGPR, pStack, bOverFlow ); + + // stack space + OSL_ENSURE( sizeof(void *) == sizeof(sal_Int32), "### unexpected size!" ); + // args + void ** pCppArgs = (void **)alloca( 3 * sizeof(void *) * nParams ); + // indizes of values this have to be converted (interface conversion cpp<=>uno) + sal_Int32 * pTempIndizes = (sal_Int32 *)(pCppArgs + nParams); + // type descriptions for reconversions + typelib_TypeDescription ** ppTempParamTypeDescr = (typelib_TypeDescription **)(pCppArgs + (2 * nParams)); + + sal_Int32 nTempIndizes = 0; + + for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos ) + { + const typelib_MethodParameter & rParam = pParams[nPos]; + typelib_TypeDescription * pParamTypeDescr = 0; + TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef ); + + if (!rParam.bOut && bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr )) + { + uno_copyAndConvertData( pCppArgs[nPos] = alloca(8), pUnoArgs[nPos], + pParamTypeDescr, pThis->getBridge()->getUno2Cpp() ); + + switch (pParamTypeDescr->eTypeClass) + { + case typelib_TypeClass_HYPER: + case typelib_TypeClass_UNSIGNED_HYPER: +#ifdef CMC_DEBUG + fprintf(stderr, "hyper is %llx\n", *((long long*)pCppArgs[nPos])); +#endif + INSERT_INT64( pCppArgs[nPos], nRegs, pGPR, pStack, pStackStart, bOverFlow ); + break; + case typelib_TypeClass_LONG: + case typelib_TypeClass_UNSIGNED_LONG: + case typelib_TypeClass_ENUM: +#ifdef CMC_DEBUG + fprintf(stderr, "long is %x\n", pCppArgs[nPos]); +#endif + INSERT_INT32( pCppArgs[nPos], nRegs, pGPR, pStack, bOverFlow ); + break; + case typelib_TypeClass_SHORT: + case typelib_TypeClass_CHAR: + case typelib_TypeClass_UNSIGNED_SHORT: + INSERT_INT16( pCppArgs[nPos], nRegs, pGPR, pStack, bOverFlow ); + break; + case typelib_TypeClass_BOOLEAN: + case typelib_TypeClass_BYTE: + INSERT_INT8( pCppArgs[nPos], nRegs, pGPR, pStack, bOverFlow ); + break; + case typelib_TypeClass_FLOAT: + INSERT_FLOAT( pCppArgs[nPos], nRegs, pFPR, pStack, bOverFlow ); + break; + case typelib_TypeClass_DOUBLE: + INSERT_DOUBLE( pCppArgs[nPos], nRegs, pFPR, pStack, pStackStart, bOverFlow ); + break; + default: + break; + } + // no longer needed + TYPELIB_DANGER_RELEASE( pParamTypeDescr ); + } + else // ptr to complex value | ref + { + if (! rParam.bIn) // is pure out + { + // cpp out is constructed mem, uno out is not! + uno_constructData( + pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ), + pParamTypeDescr ); + pTempIndizes[nTempIndizes] = nPos; // default constructed for cpp call + // will be released at reconversion + ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr; + } + // is in/inout + else if (bridges::cpp_uno::shared::relatesToInterfaceType( pParamTypeDescr )) + { + uno_copyAndConvertData( + pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ), + pUnoArgs[nPos], pParamTypeDescr, pThis->getBridge()->getUno2Cpp() ); + + pTempIndizes[nTempIndizes] = nPos; // has to be reconverted + // will be released at reconversion + ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr; + } + else // direct way + { + pCppArgs[nPos] = pUnoArgs[nPos]; + // no longer needed + TYPELIB_DANGER_RELEASE( pParamTypeDescr ); + } + INSERT_INT32( &(pCppArgs[nPos]), nRegs, pGPR, pStack, bOverFlow ); + } + } + + try + { + callVirtualMethod( + pAdjustedThisPtr, aVtableSlot.index, + pCppReturn, pReturnTypeDescr, bRegisterReturn, + pStackStart, + (pStack - pStackStart), pGPR, pFPR); + + // NO exception occured... + *ppUnoExc = 0; + + // reconvert temporary params + for ( ; nTempIndizes--; ) + { + sal_Int32 nIndex = pTempIndizes[nTempIndizes]; + typelib_TypeDescription * pParamTypeDescr = ppTempParamTypeDescr[nTempIndizes]; + + if (pParams[nIndex].bIn) + { + if (pParams[nIndex].bOut) // inout + { + uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 ); // destroy uno value + uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr, + pThis->getBridge()->getCpp2Uno() ); + } + } + else // pure out + { + uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr, + pThis->getBridge()->getCpp2Uno() ); + } + // destroy temp cpp param => cpp: every param was constructed + uno_destructData( pCppArgs[nIndex], pParamTypeDescr, cpp_release ); + + TYPELIB_DANGER_RELEASE( pParamTypeDescr ); + } + // return value + if (pCppReturn && pUnoReturn != pCppReturn) + { + uno_copyAndConvertData( pUnoReturn, pCppReturn, pReturnTypeDescr, + pThis->getBridge()->getCpp2Uno() ); + uno_destructData( pCppReturn, pReturnTypeDescr, cpp_release ); + } + } + catch (...) + { + // fill uno exception + fillUnoException( CPPU_CURRENT_NAMESPACE::__cxa_get_globals()->caughtExceptions, *ppUnoExc, pThis->getBridge()->getCpp2Uno() ); + + // temporary params + for ( ; nTempIndizes--; ) + { + sal_Int32 nIndex = pTempIndizes[nTempIndizes]; + // destroy temp cpp param => cpp: every param was constructed + uno_destructData( pCppArgs[nIndex], ppTempParamTypeDescr[nTempIndizes], cpp_release ); + TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndizes] ); + } + + // return type + if (pReturnTypeDescr) + TYPELIB_DANGER_RELEASE( pReturnTypeDescr ); + } +} +} + +namespace bridges { namespace cpp_uno { namespace shared { + +void unoInterfaceProxyDispatch( + uno_Interface * pUnoI, const typelib_TypeDescription * pMemberDescr, + void * pReturn, void * pArgs[], uno_Any ** ppException ) +{ + // is my surrogate + bridges::cpp_uno::shared::UnoInterfaceProxy * pThis + = static_cast< bridges::cpp_uno::shared::UnoInterfaceProxy * >(pUnoI); +#if OSL_DEBUG_LEVEL > 0 + typelib_InterfaceTypeDescription * pTypeDescr = pThis->pTypeDescr; +#endif + + switch (pMemberDescr->eTypeClass) + { + case typelib_TypeClass_INTERFACE_ATTRIBUTE: + { +#if OSL_DEBUG_LEVEL > 0 + // determine vtable call index + sal_Int32 nMemberPos = ((typelib_InterfaceMemberTypeDescription *)pMemberDescr)->nPosition; + OSL_ENSURE( nMemberPos < pTypeDescr->nAllMembers, "### member pos out of range!" ); +#endif + + VtableSlot aVtableSlot( + getVtableSlot( + reinterpret_cast<typelib_InterfaceAttributeTypeDescription const *> + (pMemberDescr))); + + if (pReturn) + { + // dependent dispatch + cpp_call( + pThis, aVtableSlot, + ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef, + 0, 0, // no params + pReturn, pArgs, ppException ); + } + else + { + // is SET + typelib_MethodParameter aParam; + aParam.pTypeRef = + ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef; + aParam.bIn = sal_True; + aParam.bOut = sal_False; + + typelib_TypeDescriptionReference * pReturnTypeRef = 0; + OUString aVoidName( RTL_CONSTASCII_USTRINGPARAM("void") ); + typelib_typedescriptionreference_new( + &pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData ); + + // dependent dispatch + aVtableSlot.index += 1; + cpp_call( + pThis, aVtableSlot, // get, then set method + pReturnTypeRef, + 1, &aParam, + pReturn, pArgs, ppException ); + + typelib_typedescriptionreference_release( pReturnTypeRef ); + } + + break; + } + case typelib_TypeClass_INTERFACE_METHOD: + { +#if OSL_DEBUG_LEVEL > 0 + // determine vtable call index + sal_Int32 nMemberPos = ((typelib_InterfaceMemberTypeDescription *)pMemberDescr)->nPosition; + OSL_ENSURE( nMemberPos < pTypeDescr->nAllMembers, "### member pos out of range!" ); +#endif + + VtableSlot aVtableSlot( + getVtableSlot( + reinterpret_cast<typelib_InterfaceMethodTypeDescription const *> + (pMemberDescr))); + + switch (aVtableSlot.index) + { + // standard calls + case 1: // acquire uno interface + (*pUnoI->acquire)( pUnoI ); + *ppException = 0; + break; + case 2: // release uno interface + (*pUnoI->release)( pUnoI ); + *ppException = 0; + break; + case 0: // queryInterface() opt + { + typelib_TypeDescription * pTD = 0; + TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( pArgs[0] )->getTypeLibType() ); + if (pTD) + { + uno_Interface * pInterface = 0; + (*pThis->getBridge()->getUnoEnv()->getRegisteredInterface)( + pThis->getBridge()->getUnoEnv(), + (void **)&pInterface, pThis->oid.pData, (typelib_InterfaceTypeDescription *)pTD ); + + if (pInterface) + { + ::uno_any_construct( + reinterpret_cast< uno_Any * >( pReturn ), + &pInterface, pTD, 0 ); + (*pInterface->release)( pInterface ); + TYPELIB_DANGER_RELEASE( pTD ); + *ppException = 0; + break; + } + + TYPELIB_DANGER_RELEASE( pTD ); + } + } // else perform queryInterface() + default: + // dependent dispatch + cpp_call( + pThis, aVtableSlot, + ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pReturnTypeRef, + ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->nParams, + ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pParams, + pReturn, pArgs, ppException ); + } + break; + } + default: + { + ::com::sun::star::uno::RuntimeException aExc( + OUString( RTL_CONSTASCII_USTRINGPARAM("illegal member type description!") ), + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >() ); + + Type const & rExcType = ::getCppuType( &aExc ); + // binary identical null reference + ::uno_type_any_construct( *ppException, &aExc, rExcType.getTypeLibType(), 0 ); + } + } +} + +} } } + +/* vi:set tabstop=4 shiftwidth=4 expandtab: */ diff --git a/bridges/source/cpp_uno/gcc3_linux_ia64/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_linux_ia64/uno2cpp.cxx index 35b16d882632..d1d98f222738 100644 --- a/bridges/source/cpp_uno/gcc3_linux_ia64/uno2cpp.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_ia64/uno2cpp.cxx @@ -91,6 +91,31 @@ void MapReturn(const ia64::RegReturn &rRet, double dret, typelib_TypeDescription namespace ia64 { + bool is_complex_struct(const typelib_TypeDescription * type) + { + const typelib_CompoundTypeDescription * p + = reinterpret_cast< const typelib_CompoundTypeDescription * >(type); + for (sal_Int32 i = 0; i < p->nMembers; ++i) + { + if (p->ppTypeRefs[i]->eTypeClass == typelib_TypeClass_STRUCT || + p->ppTypeRefs[i]->eTypeClass == typelib_TypeClass_EXCEPTION) + { + typelib_TypeDescription * t = 0; + TYPELIB_DANGER_GET(&t, p->ppTypeRefs[i]); + bool b = is_complex_struct(t); + TYPELIB_DANGER_RELEASE(t); + if (b) { + return true; + } + } + else if (!bridges::cpp_uno::shared::isSimpleType(p->ppTypeRefs[i]->eTypeClass)) + return true; + } + if (p->pBaseTypeDescription != 0) + return is_complex_struct(&p->pBaseTypeDescription->aBase); + return false; + } + bool is_complex_struct( typelib_TypeDescriptionReference *pTypeRef ) { if (pTypeRef->eTypeClass == typelib_TypeClass_STRUCT || pTypeRef->eTypeClass == typelib_TypeClass_EXCEPTION) @@ -98,7 +123,7 @@ namespace ia64 typelib_TypeDescription * pTypeDescr = 0; TYPELIB_DANGER_GET( &pTypeDescr, pTypeRef ); - bool bRet = bridges::cpp_uno::shared::relatesToInterfaceType( pTypeDescr ); + bool bRet = is_complex_struct( pTypeDescr ); TYPELIB_DANGER_RELEASE( pTypeDescr ); return bRet; diff --git a/bridges/source/cpp_uno/gcc3_linux_m68k/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_linux_m68k/cpp2uno.cxx index 0581b52f0c8d..1d63ebde491f 100644 --- a/bridges/source/cpp_uno/gcc3_linux_m68k/cpp2uno.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_m68k/cpp2uno.cxx @@ -256,7 +256,7 @@ namespace // destroy temp uno return uno_destructData( pUnoReturn, pReturnTypeDescr, 0 ); } - // complex return ptr is set to eax + // complex return ptr is set to return reg *(void **)pRegisterReturn = pCppReturn; } if (pReturnTypeDescr) diff --git a/bridges/source/cpp_uno/gcc3_linux_m68k/makefile.mk b/bridges/source/cpp_uno/gcc3_linux_m68k/makefile.mk index 32d4b0d27dc9..8371d653a25b 100644 --- a/bridges/source/cpp_uno/gcc3_linux_m68k/makefile.mk +++ b/bridges/source/cpp_uno/gcc3_linux_m68k/makefile.mk @@ -61,8 +61,7 @@ CFLAGSNOOPT=-O0 SLOFILES= \ $(SLO)$/cpp2uno.obj \ $(SLO)$/except.obj \ - $(SLO)$/uno2cpp.obj \ - $(SLO)$/m68khelper.obj + $(SLO)$/uno2cpp.obj SHL1TARGET= $(TARGET) @@ -83,6 +82,3 @@ SHL1STDLIBS= \ # --- Targets ------------------------------------------------------ .INCLUDE : target.mk - -$(SLO)$/%.obj: %.s - $(CXX) -c -o $(SLO)$/$(@:b).o $< -fPIC ; touch $@ diff --git a/bridges/source/cpp_uno/gcc3_linux_s390x/except.cxx b/bridges/source/cpp_uno/gcc3_linux_s390x/except.cxx index 6141efd7964a..e474dce7268c 100644 --- a/bridges/source/cpp_uno/gcc3_linux_s390x/except.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_s390x/except.cxx @@ -33,6 +33,7 @@ #include "precompiled_bridges.hxx" #include <stdio.h> +#include <string.h> #include <dlfcn.h> #include <cxxabi.h> #include <hash_map> diff --git a/bridges/source/cpp_uno/gcc3_linux_x86-64/abi.cxx b/bridges/source/cpp_uno/gcc3_linux_x86-64/abi.cxx index 2aeaf9423859..ad0faa1a01aa 100644 --- a/bridges/source/cpp_uno/gcc3_linux_x86-64/abi.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/abi.cxx @@ -229,6 +229,7 @@ classify_argument( typelib_TypeDescriptionReference *pTypeRef, enum x86_64_reg_c for ( sal_Int32 nMember = 0; nMember < pStruct->nMembers; ++nMember ) { typelib_TypeDescriptionReference *pTypeInStruct = pStruct->ppTypeRefs[ nMember ]; + rByteOffset = pStruct->pMemberOffsets[ nMember ]; int num = classify_argument( pTypeInStruct, subclasses, rByteOffset ); @@ -243,9 +244,6 @@ classify_argument( typelib_TypeDescriptionReference *pTypeRef, enum x86_64_reg_c int pos = rByteOffset / 8; classes[i + pos] = merge_classes( subclasses[i], classes[i + pos] ); } - - if ( pTypeInStruct->eTypeClass != typelib_TypeClass_STRUCT ) - rByteOffset = pStruct->pMemberOffsets[ nMember ]; } TYPELIB_DANGER_RELEASE( pTypeDescr ); @@ -332,7 +330,7 @@ bool x86_64::return_in_hidden_param( typelib_TypeDescriptionReference *pTypeRef return examine_argument( pTypeRef, true, g, s ) == 0; } -void x86_64::fill_struct( typelib_TypeDescriptionReference *pTypeRef, void * const *pGPR, void * const *pSSE, void *pStruct ) +void x86_64::fill_struct( typelib_TypeDescriptionReference *pTypeRef, const sal_uInt64 *pGPR, const double *pSSE, void *pStruct ) { enum x86_64_reg_class classes[MAX_CLASSES]; int offset = 0; @@ -346,12 +344,12 @@ void x86_64::fill_struct( typelib_TypeDescriptionReference *pTypeRef, void * con { case X86_64_INTEGER_CLASS: case X86_64_INTEGERSI_CLASS: - *pStructAlign++ = *reinterpret_cast<sal_uInt64 *>( *pGPR++ ); + *pStructAlign++ = *pGPR++; break; case X86_64_SSE_CLASS: case X86_64_SSESF_CLASS: case X86_64_SSEDF_CLASS: - *pStructAlign++ = *reinterpret_cast<sal_uInt64 *>( *pSSE++ ); + *pStructAlign++ = *reinterpret_cast<const sal_uInt64 *>( pSSE++ ); break; default: break; diff --git a/bridges/source/cpp_uno/gcc3_linux_x86-64/abi.hxx b/bridges/source/cpp_uno/gcc3_linux_x86-64/abi.hxx index 5fffe680c28a..c5b7d94d2e01 100644 --- a/bridges/source/cpp_uno/gcc3_linux_x86-64/abi.hxx +++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/abi.hxx @@ -63,7 +63,7 @@ bool examine_argument( typelib_TypeDescriptionReference *pTypeRef, bool bInRetur */ bool return_in_hidden_param( typelib_TypeDescriptionReference *pTypeRef ); -void fill_struct( typelib_TypeDescriptionReference *pTypeRef, void * const *pGPR, void * const *pSSE, void *pStruct ); +void fill_struct( typelib_TypeDescriptionReference *pTypeRef, const sal_uInt64* pGPR, const double* pSSE, void *pStruct ); } // namespace x86_64 diff --git a/bridges/source/cpp_uno/gcc3_linux_x86-64/call.s b/bridges/source/cpp_uno/gcc3_linux_x86-64/call.s index 736230705d5a..a0572ef61641 100644 --- a/bridges/source/cpp_uno/gcc3_linux_x86-64/call.s +++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/call.s @@ -43,6 +43,9 @@ privateSnippetExecutor: je .Lfloat movq -144(%rbp), %rax # Return value (int case) + movq -136(%rbp), %rdx # Return value (int case) + movq -144(%rbp), %xmm0 # Return value (int case) + movq -136(%rbp), %xmm1 # Return value (int case) jmp .Lfinish .Lfloat: movlpd -144(%rbp), %xmm0 # Return value (float/double case) diff --git a/bridges/source/cpp_uno/gcc3_linux_x86-64/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_linux_x86-64/cpp2uno.cxx index 5fb2bd7e12a3..fd612d0f6391 100644 --- a/bridges/source/cpp_uno/gcc3_linux_x86-64/cpp2uno.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/cpp2uno.cxx @@ -126,7 +126,10 @@ static typelib_TypeClass cpp2uno_call( int nUsedGPR = 0; int nUsedSSE = 0; - bool bFitsRegisters = x86_64::examine_argument( rParam.pTypeRef, false, nUsedGPR, nUsedSSE ); +#if OSL_DEBUG_LEVEL > 0 + bool bFitsRegisters = +#endif + x86_64::examine_argument( rParam.pTypeRef, false, nUsedGPR, nUsedSSE ); if ( !rParam.bOut && bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr ) ) // value { // Simple types must fit exactly one register on x86_64 @@ -159,28 +162,7 @@ static typelib_TypeClass cpp2uno_call( else // struct <= 16 bytes || ptr to complex value || ref { void *pCppStack; - char pTmpStruct[16]; - - if ( bFitsRegisters && !rParam.bOut && - ( pParamTypeDescr->eTypeClass == typelib_TypeClass_STRUCT || - pParamTypeDescr->eTypeClass == typelib_TypeClass_EXCEPTION ) ) - { - if ( ( nr_gpr + nUsedGPR <= x86_64::MAX_GPR_REGS ) && ( nr_fpr + nUsedSSE <= x86_64::MAX_SSE_REGS ) ) - { - x86_64::fill_struct( rParam.pTypeRef, gpreg, fpreg, pTmpStruct ); -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "nUsedGPR == %d, nUsedSSE == %d, pTmpStruct[0] == 0x%x, pTmpStruct[1] == 0x%x, **gpreg == 0x%lx\n", - nUsedGPR, nUsedSSE, pTmpStruct[0], pTmpStruct[1], *(sal_uInt64*)*gpreg ); -#endif - - pCppArgs[nPos] = pCppStack = reinterpret_cast<void *>( pTmpStruct ); - gpreg += nUsedGPR; - fpreg += nUsedSSE; - } - else - pCppArgs[nPos] = pCppStack = *ovrflw++; - } - else if ( nr_gpr < x86_64::MAX_GPR_REGS ) + if ( nr_gpr < x86_64::MAX_GPR_REGS ) { pCppArgs[nPos] = pCppStack = *gpreg++; nr_gpr++; diff --git a/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx index 7199794409a8..23c40121afb7 100644 --- a/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx @@ -53,13 +53,13 @@ using namespace ::com::sun::star::uno; //================================================================================================== static void callVirtualMethod(void * pThis, sal_uInt32 nVtableIndex, - void * pRegisterReturn, typelib_TypeDescription * pReturnTypeDescr, bool bSimpleReturn, + void * pRegisterReturn, typelib_TypeDescriptionReference * pReturnTypeRef, bool bSimpleReturn, sal_uInt64 *pStack, sal_uInt32 nStack, sal_uInt64 *pGPR, sal_uInt32 nGPR, double *pFPR, sal_uInt32 nFPR) __attribute__((noinline)); static void callVirtualMethod(void * pThis, sal_uInt32 nVtableIndex, - void * pRegisterReturn, typelib_TypeDescription * pReturnTypeDescr, bool bSimpleReturn, + void * pRegisterReturn, typelib_TypeDescriptionReference * pReturnTypeRef, bool bSimpleReturn, sal_uInt64 *pStack, sal_uInt32 nStack, sal_uInt64 *pGPR, sal_uInt32 nGPR, double *pFPR, sal_uInt32 nFPR) @@ -113,6 +113,7 @@ static void callVirtualMethod(void * pThis, sal_uInt32 nVtableIndex, sal_uInt64 rax; sal_uInt64 rdx; double xmm0; + double xmm1; asm volatile ( @@ -147,13 +148,14 @@ static void callVirtualMethod(void * pThis, sal_uInt32 nVtableIndex, "movq %%rax, %4\n\t" "movq %%rdx, %5\n\t" "movsd %%xmm0, %6\n\t" + "movsd %%xmm1, %7\n\t" : : "m" ( pMethod ), "m" ( pGPR ), "m" ( pFPR ), "m" ( nFPR ), - "m" ( rax ), "m" ( rdx ), "m" ( xmm0 ) + "m" ( rax ), "m" ( rdx ), "m" ( xmm0 ), "m" ( xmm1 ) : "rax", "rdi", "rsi", "rdx", "rcx", "r8", "r9", "r11" ); - switch (pReturnTypeDescr->eTypeClass) + switch (pReturnTypeRef->eTypeClass) { case typelib_TypeClass_HYPER: case typelib_TypeClass_UNSIGNED_HYPER: @@ -179,12 +181,17 @@ static void callVirtualMethod(void * pThis, sal_uInt32 nVtableIndex, break; default: { - sal_Int32 const nRetSize = pReturnTypeDescr->nSize; + sal_Int32 const nRetSize = pReturnTypeRef->pType->nSize; if (bSimpleReturn && nRetSize <= 16 && nRetSize > 0) { - if (nRetSize > 8) - static_cast<sal_uInt64 *>(pRegisterReturn)[1] = rdx; - static_cast<sal_uInt64 *>(pRegisterReturn)[0] = rax; + sal_uInt64 longs[2]; + longs[0] = rax; + longs[1] = rdx; + + double doubles[2]; + doubles[0] = xmm0; + doubles[1] = xmm1; + x86_64::fill_struct( pReturnTypeRef, &longs[0], &doubles[0], pRegisterReturn); } break; } @@ -367,7 +374,7 @@ static void cpp_call( { callVirtualMethod( pAdjustedThisPtr, aVtableSlot.index, - pCppReturn, pReturnTypeDescr, bSimpleReturn, + pCppReturn, pReturnTypeRef, bSimpleReturn, pStackStart, ( pStack - pStackStart ), pGPR, nGPR, pFPR, nFPR ); diff --git a/bridges/source/cpp_uno/gcc3_macosx_powerpc/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_macosx_powerpc/uno2cpp.cxx index 0f0fdbf351ca..e3f4d36e3962 100644 --- a/bridges/source/cpp_uno/gcc3_macosx_powerpc/uno2cpp.cxx +++ b/bridges/source/cpp_uno/gcc3_macosx_powerpc/uno2cpp.cxx @@ -110,6 +110,9 @@ static void callVirtualMethod( /* set up a pointer to the stack parameter area */ __asm__ ( "addi %0,r1,24" : "=r" (p) : /* no inputs */ ); + // #i94421#, work around compiler error: + volatile long * pCopy = p; + (void) pCopy; // avoid warning about unused variable // never called // if (! pAdjustedThisPtr )CPPU_CURRENT_NAMESPACE::dummy_can_throw_anything("xxx"); // address something diff --git a/bridges/source/cpp_uno/gcc3_os2_intel/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_os2_intel/cpp2uno.cxx index d4584227cdc1..d6589b8d86cf 100644 --- a/bridges/source/cpp_uno/gcc3_os2_intel/cpp2uno.cxx +++ b/bridges/source/cpp_uno/gcc3_os2_intel/cpp2uno.cxx @@ -163,7 +163,8 @@ static typelib_TypeClass cpp2uno_call( (*pThis->getUnoI()->pDispatcher)( pThis->getUnoI(), pMemberTypeDescr, pUnoReturn, pUnoArgs, &pUnoExc ); #if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, ">cpp2uno_call pUnoExc %x\n", pUnoExc); + if (pUnoExc != NULL) + fprintf( stderr, ">cpp2uno_call pUnoExc %x\n", pUnoExc); #endif // in case an exception occured... diff --git a/bridges/source/cpp_uno/mingw_intel/call.s b/bridges/source/cpp_uno/mingw_intel/call.s index b4a9ba031cf5..47327d9a4650 100644 --- a/bridges/source/cpp_uno/mingw_intel/call.s +++ b/bridges/source/cpp_uno/mingw_intel/call.s @@ -1,7 +1,6 @@ .text .globl _privateSnippetExecutorGeneral - .type _privateSnippetExecutorGeneral,@function _privateSnippetExecutorGeneral: .LFBg: movl %esp,%ecx @@ -19,10 +18,9 @@ _privateSnippetExecutorGeneral: leave ret .LFEg: - .size _privateSnippetExecutorGeneral,.-_privateSnippetExecutorGeneral + .long .-_privateSnippetExecutorGeneral .globl _privateSnippetExecutorVoid - .type _privateSnippetExecutorVoid,@function _privateSnippetExecutorVoid: .LFBv: movl %esp,%ecx @@ -38,10 +36,9 @@ _privateSnippetExecutorVoid: leave ret .LFEv: - .size _privateSnippetExecutorVoid,.-_privateSnippetExecutorVoid + .long .-_privateSnippetExecutorVoid .globl _privateSnippetExecutorHyper - .type _privateSnippetExecutorHyper,@function _privateSnippetExecutorHyper: .LFBh: movl %esp,%ecx @@ -60,10 +57,9 @@ _privateSnippetExecutorHyper: leave ret .LFEh: - .size _privateSnippetExecutorHyper,.-_privateSnippetExecutorHyper + .long .-_privateSnippetExecutorHyper .globl _privateSnippetExecutorFloat - .type _privateSnippetExecutorFloat,@function _privateSnippetExecutorFloat: .LFBf: movl %esp,%ecx @@ -81,10 +77,9 @@ _privateSnippetExecutorFloat: leave ret .LFEf: - .size _privateSnippetExecutorFloat,.-_privateSnippetExecutorFloat + .long .-_privateSnippetExecutorFloat .globl _privateSnippetExecutorDouble - .type _privateSnippetExecutorDouble,@function _privateSnippetExecutorDouble: .LFBd: movl %esp,%ecx @@ -102,10 +97,9 @@ _privateSnippetExecutorDouble: leave ret .LFEd: - .size _privateSnippetExecutorDouble,.-_privateSnippetExecutorDouble + .long .-_privateSnippetExecutorDouble .globl _privateSnippetExecutorClass - .type _privateSnippetExecutorClass,@function _privateSnippetExecutorClass: .LFBc: movl %esp,%ecx @@ -123,9 +117,9 @@ _privateSnippetExecutorClass: leave ret $4 .LFEc: - .size _privateSnippetExecutorClass,.-_privateSnippetExecutorClass + .long .-_privateSnippetExecutorClass - .section .eh_frame,"a",@progbits + .section .eh_frame,"dr" .Lframe1: .long .LECIE1-.LSCIE1 # length .LSCIE1: @@ -265,4 +259,3 @@ _privateSnippetExecutorClass: .uleb128 5 .align 4 .LEFDEc: - .section .note.GNU-stack,"",@progbits diff --git a/bridges/source/cpp_uno/mingw_intel/except.cxx b/bridges/source/cpp_uno/mingw_intel/except.cxx index a529dc00d48b..5285b709b7b5 100644 --- a/bridges/source/cpp_uno/mingw_intel/except.cxx +++ b/bridges/source/cpp_uno/mingw_intel/except.cxx @@ -32,6 +32,7 @@ #include "precompiled_bridges.hxx" #include <stdio.h> +#include <string.h> #include <cxxabi.h> #include <hash_map> diff --git a/bridges/source/cpp_uno/mingw_intel/makefile.mk b/bridges/source/cpp_uno/mingw_intel/makefile.mk index 823c3888516b..242d21617d5e 100644 --- a/bridges/source/cpp_uno/mingw_intel/makefile.mk +++ b/bridges/source/cpp_uno/mingw_intel/makefile.mk @@ -47,11 +47,17 @@ ENABLE_EXCEPTIONS=TRUE .IF "$(cppu_no_leak)" == "" CFLAGS += -DLEAK_STATIC_DATA .ENDIF +.IF "$(EXCEPTIONS)" == "sjlj" +CFLAGS += -DBROKEN_ALLOCA +.ENDIF # In case someone enabled the non-standard -fomit-frame-pointer which does not # work with the .cxx sources in this directory: CFLAGSCXX += -fno-omit-frame-pointer +NOOPTFILES= \ + $(SLO)$/uno2cpp.obj + CFLAGSNOOPT=-O0 SLOFILES= \ diff --git a/bridges/source/cpp_uno/mingw_intel/uno2cpp.cxx b/bridges/source/cpp_uno/mingw_intel/uno2cpp.cxx index 0c12fac5c93f..f6b6a1c6511d 100644 --- a/bridges/source/cpp_uno/mingw_intel/uno2cpp.cxx +++ b/bridges/source/cpp_uno/mingw_intel/uno2cpp.cxx @@ -44,10 +44,6 @@ #include "share.hxx" #include "smallstruct.hxx" -#ifdef __MINGW32__ -#define BROKEN_ALLOCA -#endif - using namespace ::rtl; using namespace ::com::sun::star::uno; diff --git a/bridges/source/cpp_uno/shared/vtablefactory.cxx b/bridges/source/cpp_uno/shared/vtablefactory.cxx index 34e5f9635974..3784f3959594 100644 --- a/bridges/source/cpp_uno/shared/vtablefactory.cxx +++ b/bridges/source/cpp_uno/shared/vtablefactory.cxx @@ -272,7 +272,7 @@ bool VtableFactory::createBlock(Block &block, sal_Int32 slotCount) const char *tmpfname = new char[aTmpName.getLength()+1]; strncpy(tmpfname, aTmpName.getStr(), aTmpName.getLength()+1); if ((block.fd = mkstemp(tmpfname)) == -1) - perror("creation of executable memory area failed"); + perror("creation of executable memory area failed"); if (block.fd == -1) { delete[] tmpfname; @@ -280,7 +280,13 @@ bool VtableFactory::createBlock(Block &block, sal_Int32 slotCount) const } unlink(tmpfname); delete[] tmpfname; - ftruncate(block.fd, block.size); + if (ftruncate(block.fd, block.size) == -1) + { + perror("truncation of executable memory area failed"); + close(block.fd); + block.fd = -1; + break; + } block.start = mmap(NULL, block.size, PROT_READ | PROT_WRITE, MAP_SHARED, block.fd, 0); if (block.start== MAP_FAILED) { block.start = 0; diff --git a/bridges/source/jni_uno/jni_java2uno.cxx b/bridges/source/jni_uno/jni_java2uno.cxx index 03c7ef9fbc64..b3b4e5ab8b06 100644 --- a/bridges/source/jni_uno/jni_java2uno.cxx +++ b/bridges/source/jni_uno/jni_java2uno.cxx @@ -41,10 +41,6 @@ #include <algorithm> -#ifdef __MINGW32__ -#define BROKEN_ALLOCA -#endif - using namespace ::rtl; namespace jni_uno diff --git a/bridges/source/jni_uno/jni_uno2java.cxx b/bridges/source/jni_uno/jni_uno2java.cxx index d9ad7f92b124..50c551427959 100644 --- a/bridges/source/jni_uno/jni_uno2java.cxx +++ b/bridges/source/jni_uno/jni_uno2java.cxx @@ -40,10 +40,6 @@ #include "jni_bridge.h" -#ifdef __MINGW32__ -#define BROKEN_ALLOCA -#endif - using namespace ::std; using namespace ::rtl; diff --git a/bridges/source/jni_uno/makefile.mk b/bridges/source/jni_uno/makefile.mk index 36f6ffbde5b9..d020eb7e91a1 100644 --- a/bridges/source/jni_uno/makefile.mk +++ b/bridges/source/jni_uno/makefile.mk @@ -47,6 +47,12 @@ nojava: # --- Files -------------------------------------------------------- +.IF "$(GUI)$(COM)" == "WNTGCC" +.IF "$(EXCEPTIONS)" == "sjlj" +CFLAGS += -DBROKEN_ALLOCA +.ENDIF +.ENDIF + SLOFILES= \ $(SLO)$/jni_info.obj \ $(SLO)$/jni_data.obj \ diff --git a/bridges/source/remote/static/proxy.cxx b/bridges/source/remote/static/proxy.cxx index 6f07ba95d6ff..6cfd9c11e9fb 100644 --- a/bridges/source/remote/static/proxy.cxx +++ b/bridges/source/remote/static/proxy.cxx @@ -30,12 +30,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_bridges.hxx" -#if OSL_DEBUG_LEVEL == 0 -# ifndef NDEBUG -# define NDEBUG -# endif -#endif -#include <assert.h> #include <sal/alloca.h> #include <bridges/remote/proxy.hxx> #include <bridges/remote/context.h> @@ -84,7 +78,7 @@ void acquireRemote2UnoProxy( uno_Interface *pThis ) freeRemote2UnoProxy, p->m_sOid.pData, p->m_pType ); - assert( (uno_Interface *)p == pThis ); + OSL_ASSERT( (uno_Interface *)p == pThis ); } } diff --git a/bridges/source/remote/static/remote.cxx b/bridges/source/remote/static/remote.cxx index 1cb26b4ccd9c..ed8b1dbc9d59 100644 --- a/bridges/source/remote/static/remote.cxx +++ b/bridges/source/remote/static/remote.cxx @@ -30,12 +30,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_bridges.hxx" -#if OSL_DEBUG_LEVEL == 0 -# ifndef NDEBUG -# define NDEBUG -# endif -#endif -#include <assert.h> #include <bridges/remote/remote.hxx> #include <bridges/remote/counter.hxx> @@ -90,7 +84,7 @@ void acquireRemote2RemoteStub( remote_Interface *pThis ) freeRemote2RemoteStub, p->m_sOid.pData, p->m_pType ); - assert( (remote_Interface *)p == pThis ); + OSL_ASSERT( (remote_Interface *)p == pThis ); } } diff --git a/bridges/source/remote/urp/urp_environment.cxx b/bridges/source/remote/urp/urp_environment.cxx index fd0c56ba4376..1afab0633fd4 100644 --- a/bridges/source/remote/urp/urp_environment.cxx +++ b/bridges/source/remote/urp/urp_environment.cxx @@ -342,10 +342,13 @@ static void SAL_CALL RemoteEnvironment_thisDispose( uno_Environment *pEnvRemote pImpl->m_pReader = 0; } - ::osl::MutexGuard guard2( ::osl::Mutex::getGlobalMutex() ); - if( ! g_bStaticDestructorsCalled ) + bool bReleaseStubs = false; + { + ::osl::MutexGuard guard2( ::osl::Mutex::getGlobalMutex() ); + bReleaseStubs = !g_bStaticDestructorsCalled; + } + if( bReleaseStubs ) { - // delete the stubs releaseStubs( pEnvRemote ); } } diff --git a/bridges/source/remote/urp/urp_log.hxx b/bridges/source/remote/urp/urp_log.hxx index c7811faf51e9..6c96ea0dbffc 100644 --- a/bridges/source/remote/urp/urp_log.hxx +++ b/bridges/source/remote/urp/urp_log.hxx @@ -29,7 +29,7 @@ ************************************************************************/ namespace bridges_urp { -#ifndef PRODUCT +#ifdef DBG_UTIL #define BRIDGES_URP_PROT #endif diff --git a/bridges/test/com/sun/star/lib/TestBed.java b/bridges/test/com/sun/star/lib/TestBed.java index 7242b56438f0..5e2c5e7859c8 100644 --- a/bridges/test/com/sun/star/lib/TestBed.java +++ b/bridges/test/com/sun/star/lib/TestBed.java @@ -130,7 +130,7 @@ public final class TestBed { throws com.sun.star.uno.Exception { XConnector connector = Connector.create(context); - XBridgeFactory factory = (XBridgeFactory) UnoRuntime.queryInterface( + XBridgeFactory factory = UnoRuntime.queryInterface( XBridgeFactory.class, context.getServiceManager().createInstanceWithContext( "com.sun.star.bridge.BridgeFactory", context)); @@ -169,7 +169,7 @@ public final class TestBed { = Bootstrap.createInitialComponentContext(null); XAcceptor acceptor = Acceptor.create(context); XBridgeFactory factory - = (XBridgeFactory) UnoRuntime.queryInterface( + = UnoRuntime.queryInterface( XBridgeFactory.class, context.getServiceManager().createInstanceWithContext( "com.sun.star.bridge.BridgeFactory", context)); diff --git a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug107753_Test.java b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug107753_Test.java index a2c4122d3017..2c7e314afc82 100644 --- a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug107753_Test.java +++ b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug107753_Test.java @@ -68,22 +68,19 @@ public final class Bug107753_Test extends ComplexTestCase { protected boolean run(XComponentContext context) throws Throwable { boolean success = true; - XTransport transport = (XTransport) UnoRuntime.queryInterface( + XTransport transport = UnoRuntime.queryInterface( XTransport.class, getBridge(context).getInstance("Transport")); Object obj1a = new XType1() {}; - XType1 obj1b = (XType1) UnoRuntime.queryInterface(XType1.class, - obj1a); + XType1 obj1b = UnoRuntime.queryInterface(XType1.class, obj1a); success &= test("obj1a == obj1b", obj1a == obj1b); Object obj2a = new XType2() {}; - XType2 obj2b = (XType2) UnoRuntime.queryInterface(XType2.class, - obj2a); + XType2 obj2b = UnoRuntime.queryInterface(XType2.class, obj2a); success &= test("obj2a == obj2b", obj2a == obj2b); Object obj3a = transport.getType1(); - XType1 obj3b = (XType1) UnoRuntime.queryInterface(XType1.class, - obj3a); + XType1 obj3b = UnoRuntime.queryInterface(XType1.class, obj3a); success &= test( "obj3a != obj3b; only meaningful as long as different proxy" + " instances are used for different UNO interfaces of one UNO" @@ -91,8 +88,7 @@ public final class Bug107753_Test extends ComplexTestCase { obj3a != obj3b); Object obj4a = transport.getType2(); - XType2 obj4b = (XType2) UnoRuntime.queryInterface(XType2.class, - obj4a); + XType2 obj4b = UnoRuntime.queryInterface(XType2.class, obj4a); success &= test( "obj4a != obj4b; only meaningful as long as different proxy" + " instances are used for different UNO interfaces of one UNO" diff --git a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug108825_Test.java b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug108825_Test.java index 6e9d97f7034d..0585e1c8f650 100644 --- a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug108825_Test.java +++ b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug108825_Test.java @@ -68,7 +68,7 @@ public final class Bug108825_Test extends ComplexTestCase { } protected boolean run(XComponentContext context) throws Throwable { - XTest test = (XTest) UnoRuntime.queryInterface( + XTest test = UnoRuntime.queryInterface( XTest.class, getBridge(context).getInstance("Test")); // Send the XObject that is held on the server side amidst two // dummies that are not held on the server side; then wait for the diff --git a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug110892_Test.java b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug110892_Test.java index 76bd9d37a10c..1a537895b0ed 100644 --- a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug110892_Test.java +++ b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug110892_Test.java @@ -71,7 +71,7 @@ public final class Bug110892_Test extends ComplexTestCase { } protected boolean run(XComponentContext context) throws Throwable { - XTest test = (XTest) UnoRuntime.queryInterface( + XTest test = UnoRuntime.queryInterface( XTest.class, getBridge(context).getInstance("Test")); test.start(new ClientObject()); synchronized (lock) { diff --git a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug111153_Test.java b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug111153_Test.java index d1f09509d9a3..40eccdba2cc6 100644 --- a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug111153_Test.java +++ b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug111153_Test.java @@ -63,7 +63,7 @@ public final class Bug111153_Test extends ComplexTestCase { } protected boolean run(XComponentContext context) throws Throwable { - XTransport t = (XTransport) UnoRuntime.queryInterface( + XTransport t = UnoRuntime.queryInterface( XTransport.class, getBridge(context).getInstance("Transport")); XDerived d = new XDerived() {}; t.setDerived(d); diff --git a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug51323_Test.java b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug51323_Test.java index 32bfe9d832a3..247bf65ba185 100644 --- a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug51323_Test.java +++ b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug51323_Test.java @@ -67,7 +67,7 @@ public final class Bug51323_Test extends ComplexTestCase { protected boolean run(XComponentContext context) throws Throwable { XConnection connection = Connector.create(context).connect(getConnectionDescription()); - XBridgeFactory factory = (XBridgeFactory) UnoRuntime.queryInterface( + XBridgeFactory factory = UnoRuntime.queryInterface( XBridgeFactory.class, context.getServiceManager().createInstanceWithContext( "com.sun.star.bridge.BridgeFactory", context)); diff --git a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug92174_Test.java b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug92174_Test.java index 292dabde4758..13b61447c320 100644 --- a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug92174_Test.java +++ b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug92174_Test.java @@ -55,7 +55,7 @@ public final class Bug92174_Test extends ComplexTestCase { } protected boolean run(XComponentContext context) throws Throwable { - XTransport t = (XTransport) UnoRuntime.queryInterface( + XTransport t = UnoRuntime.queryInterface( XTransport.class, getBridge(context).getInstance("Transport")); t.setDerived(new XDerived() { public void fn() {} diff --git a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug97697_Test.java b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug97697_Test.java index f235ccfd6475..2fdd457f0dcb 100644 --- a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug97697_Test.java +++ b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug97697_Test.java @@ -72,7 +72,7 @@ public final class Bug97697_Test extends ComplexTestCase { } protected boolean run(XComponentContext context) throws Throwable { - XTransport transport = (XTransport) UnoRuntime.queryInterface( + XTransport transport = UnoRuntime.queryInterface( XTransport.class, getBridge(context).getInstance("Transport")); try { transport.getAny(); diff --git a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug98508_Test.java b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug98508_Test.java index b713deaa352e..79e373014c4a 100644 --- a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug98508_Test.java +++ b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug98508_Test.java @@ -76,7 +76,7 @@ public final class Bug98508_Test extends ComplexTestCase { protected boolean run(XComponentContext context) throws Throwable { Test98508Interface ifc - = (Test98508Interface) UnoRuntime.queryInterface( + = UnoRuntime.queryInterface( Test98508Interface.class, getBridge(context).getInstance("")); try { diff --git a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/MethodIdTest.java b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/MethodIdTest.java index c22811502e14..407164c66c7f 100755 --- a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/MethodIdTest.java +++ b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/MethodIdTest.java @@ -64,7 +64,7 @@ public final class MethodIdTest extends ComplexTestCase { } protected boolean run(XComponentContext context) throws Throwable { - XTest t = (XTest) UnoRuntime.queryInterface( + XTest t = UnoRuntime.queryInterface( XTest.class, getBridge(context).getInstance("Test")); return t.f129() == 129; } diff --git a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/PolyStructTest.java b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/PolyStructTest.java index 2f17041a52fb..1c9e387ddb32 100644 --- a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/PolyStructTest.java +++ b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/PolyStructTest.java @@ -61,7 +61,7 @@ public final class PolyStructTest extends ComplexTestCase { } protected boolean run(XComponentContext context) throws Throwable { - TestTransport t = (TestTransport) UnoRuntime.queryInterface( + TestTransport t = UnoRuntime.queryInterface( TestTransport.class, getBridge(context).getInstance("")); assertEquals( diff --git a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/StopMessageDispatcherTest.java b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/StopMessageDispatcherTest.java index 7590a89fdd0e..37fb8ffee05b 100644 --- a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/StopMessageDispatcherTest.java +++ b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/StopMessageDispatcherTest.java @@ -63,7 +63,7 @@ public final class StopMessageDispatcherTest extends ComplexTestCase { } protected boolean run(XComponentContext context) throws Throwable { - XTest test = (XTest) UnoRuntime.queryInterface( + XTest test = UnoRuntime.queryInterface( XTest.class, getBridge(context).getInstance("Test")); Thread[] threads = new Thread[101]; int n = Thread.enumerate(threads); diff --git a/bridges/test/java_uno/acquire/TestAcquire.java b/bridges/test/java_uno/acquire/TestAcquire.java index 7d54c00d480d..e219b3adbf72 100644 --- a/bridges/test/java_uno/acquire/TestAcquire.java +++ b/bridges/test/java_uno/acquire/TestAcquire.java @@ -71,7 +71,7 @@ public final class TestAcquire { private static void execClient(XComponentContext context, String url) throws Exception { - XTest test = (XTest) UnoRuntime.queryInterface( + XTest test = UnoRuntime.queryInterface( XTest.class, UnoUrlResolver.create(context).resolve(url)); WaitUnreachable u; @@ -184,7 +184,7 @@ public final class TestAcquire { throws Exception { XAcceptor acceptor = Acceptor.create(context); - XBridgeFactory factory = (XBridgeFactory) UnoRuntime.queryInterface( + XBridgeFactory factory = UnoRuntime.queryInterface( XBridgeFactory.class, context.getServiceManager().createInstanceWithContext( "com.sun.star.bridge.BridgeFactory", context)); diff --git a/bridges/test/java_uno/any/TestRemote.java b/bridges/test/java_uno/any/TestRemote.java index db33efc139e9..ec533054579d 100644 --- a/bridges/test/java_uno/any/TestRemote.java +++ b/bridges/test/java_uno/any/TestRemote.java @@ -49,7 +49,7 @@ public final class TestRemote { } protected boolean run(XComponentContext context) throws Throwable { - XTransport transport = (XTransport) UnoRuntime.queryInterface( + XTransport transport = UnoRuntime.queryInterface( XTransport.class, getBridge(context).getInstance("Transport")); return TestAny.test(transport, true); } diff --git a/bridges/test/java_uno/equals/TestEquals.java b/bridges/test/java_uno/equals/TestEquals.java index 31b735473c9b..38c9500629e3 100644 --- a/bridges/test/java_uno/equals/TestEquals.java +++ b/bridges/test/java_uno/equals/TestEquals.java @@ -91,10 +91,10 @@ public final class TestEquals { } protected boolean run(XComponentContext context) throws Throwable { - XTestFrame f = (XTestFrame) UnoRuntime.queryInterface( + XTestFrame f = UnoRuntime.queryInterface( XTestFrame.class, getBridge(context).getInstance("TestFrame")); XAcceptor acceptor = Acceptor.create(context); - XBridgeFactory factory = (XBridgeFactory) UnoRuntime.queryInterface( + XBridgeFactory factory = UnoRuntime.queryInterface( XBridgeFactory.class, context.getServiceManager().createInstanceWithContext( "com.sun.star.bridge.BridgeFactory", context)); @@ -160,17 +160,15 @@ public final class TestEquals { public void run() { try { Object test1Aa = object1; - XBase test1Ab = (XBase) - UnoRuntime.queryInterface( - XBase.class, test1Aa); - XDerived test1Ac = (XDerived) + XBase test1Ab = UnoRuntime.queryInterface( + XBase.class, test1Aa); + XDerived test1Ac = UnoRuntime.queryInterface( XDerived.class, test1Aa); Object test2Aa = object2; - XBase test2Ab = (XBase) - UnoRuntime.queryInterface( - XBase.class, test2Aa); - XDerived test2Ac = (XDerived) + XBase test2Ab = UnoRuntime.queryInterface( + XBase.class, test2Aa); + XDerived test2Ac = UnoRuntime.queryInterface( XDerived.class, test2Aa); @@ -182,16 +180,14 @@ public final class TestEquals { null, params); XMultiComponentFactory factory = context.getServiceManager(); - XImplementationLoader loader - = (XImplementationLoader) + XImplementationLoader loader = UnoRuntime.queryInterface( XImplementationLoader.class, factory.createInstanceWithContext( "com.sun.star.loader." + "SharedLibrary", context)); - XSingleComponentFactory factory2 - = (XSingleComponentFactory) + XSingleComponentFactory factory2 = UnoRuntime.queryInterface( XSingleComponentFactory.class, loader.activate( @@ -199,7 +195,7 @@ public final class TestEquals { + "testequals.impl", "", "../lib/testequals.uno", null)); - XTestInterface test = (XTestInterface) + XTestInterface test = UnoRuntime.queryInterface( XTestInterface.class, factory2.createInstanceWithContext( @@ -211,17 +207,15 @@ public final class TestEquals { PROTOCOL_DESCRIPTION); Object test1Ba = test.get(INSTANCE1); - XBase test1Bb = (XBase) - UnoRuntime.queryInterface( - XBase.class, test1Ba); - XDerived test1Bc = (XDerived) + XBase test1Bb = UnoRuntime.queryInterface( + XBase.class, test1Ba); + XDerived test1Bc = UnoRuntime.queryInterface( XDerived.class, test1Ba); Object test2Ba = test.get(INSTANCE2); - XBase test2Bb = (XBase) - UnoRuntime.queryInterface( - XBase.class, test2Ba); - XDerived test2Bc = (XDerived) + XBase test2Bb = UnoRuntime.queryInterface( + XBase.class, test2Ba); + XDerived test2Bc = UnoRuntime.queryInterface( XDerived.class, test2Ba); diff --git a/bridges/test/java_uno/nativethreadpool/Relay.java b/bridges/test/java_uno/nativethreadpool/Relay.java index b7e304c4a3c9..03cf6795c596 100644 --- a/bridges/test/java_uno/nativethreadpool/Relay.java +++ b/bridges/test/java_uno/nativethreadpool/Relay.java @@ -63,7 +63,7 @@ public final class Relay implements XRelay, XSource { final XAcceptor acceptor = Acceptor.create(context); final XBridgeFactory factory; try { - factory = (XBridgeFactory) UnoRuntime.queryInterface( + factory = UnoRuntime.queryInterface( XBridgeFactory.class, context.getServiceManager().createInstanceWithContext( "com.sun.star.bridge.BridgeFactory", context)); diff --git a/bridges/test/testclient.cxx b/bridges/test/testclient.cxx index df5ac58d1a2d..ce870bc19ea9 100644 --- a/bridges/test/testclient.cxx +++ b/bridges/test/testclient.cxx @@ -32,11 +32,6 @@ #include "precompiled_bridges.hxx" #include <string.h> -#if OSL_DEBUG_LEVEL == 0 -#undef NDEBUG -#define NDEBUG -#endif -#include <assert.h> #include <osl/time.h> #include <osl/mutex.hxx> @@ -193,10 +188,10 @@ int main( int argc, char *argv[] ) { // test the factory Reference < XBridge > rBridge2 = rFactory->getBridge( OUString( RTL_CONSTASCII_USTRINGPARAM("bla blub")) ); - assert( rBridge2.is() ); - assert( rBridge2->getDescription() == rBridge->getDescription( ) ); - assert( rBridge2->getName() == rBridge->getName() ); - assert( rBridge2 == rBridge ); + OSL_ASSERT( rBridge2.is() ); + OSL_ASSERT( rBridge2->getDescription() == rBridge->getDescription( ) ); + OSL_ASSERT( rBridge2->getName() == rBridge->getName() ); + OSL_ASSERT( rBridge2 == rBridge ); } @@ -230,7 +225,7 @@ int main( int argc, char *argv[] ) } Reference < XBridge > rBridge = rFactory->getBridge( OUString( RTL_CONSTASCII_USTRINGPARAM("bla blub")) ); -// assert( ! rBridge.is() ); +// OSL_ASSERT( ! rBridge.is() ); } } diff --git a/bridges/test/testclient.java b/bridges/test/testclient.java index 244264fa8686..e1733bbc8b10 100644 --- a/bridges/test/testclient.java +++ b/bridges/test/testclient.java @@ -121,7 +121,7 @@ public class testclient XConnector xConnector = - ( XConnector ) UnoRuntime.queryInterface( XConnector.class , x ); + UnoRuntime.queryInterface( XConnector.class , x ); XConnection xConnection = xConnector.connect(args[0]); @@ -138,7 +138,7 @@ public class testclient System.out.println( "after building bridge" ); // Object rInitialObject = m_bridge.mapInterfaceFrom(rootOid, XInterface.class); -// XTestFactory rFactory = (XTestFactory ) +// XTestFactory rFactory = // UnoRuntime.queryInterface(XTestFactory.class,rInitialObject ); // XCallMe callMerFactory-> diff --git a/bridges/test/testcomp.cxx b/bridges/test/testcomp.cxx index 432a32f2a554..90a07ab31f43 100644 --- a/bridges/test/testcomp.cxx +++ b/bridges/test/testcomp.cxx @@ -30,11 +30,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_bridges.hxx" -#if OSL_DEBUG_LEVEL == 0 -#undef NDEBUG -#define NDEBUG -#endif -#include <assert.h> #include <string.h> #include <stdlib.h> #include <osl/time.h> @@ -598,7 +593,7 @@ void testException( const Reference < XCallMe > &r ) { try { r->call( OUString( RTL_CONSTASCII_USTRINGPARAM("dummy")) , -1 ); - assert( ! "no exception flown !" ); + OSL_ASSERT( ! "no exception flown !" ); } catch( TestBridgeException & e ) { @@ -606,11 +601,11 @@ void testException( const Reference < XCallMe > &r ) } catch( Exception & e ) { - assert( ! "only base class of exception could be catched!" ); + OSL_ASSERT( ! "only base class of exception could be catched!" ); } catch(...) { - assert(! "wrong unknown exception !" ); + OSL_ASSERT(! "wrong unknown exception !" ); } } diff --git a/bridges/test/testoffice.cxx b/bridges/test/testoffice.cxx index bae00be6caaa..bf5b470d7185 100644 --- a/bridges/test/testoffice.cxx +++ b/bridges/test/testoffice.cxx @@ -30,10 +30,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_bridges.hxx" -#if OSL_DEBUG_LEVEL == 0 -#define NDEBUG -#endif -#include <assert.h> #include <osl/time.h> #include <osl/mutex.hxx> @@ -96,7 +92,7 @@ void testPipe( const Reference < XMultiServiceFactory > & rSmgr ) rSmgr->createInstance( OUString::createFromAscii( "com.sun.star.io.Pipe" ) ), UNO_QUERY ); - assert( rOut.is() ); + OSL_ASSERT( rOut.is() ); { Sequence < sal_Int8 > seq( 10 ); @@ -115,7 +111,7 @@ void testPipe( const Reference < XMultiServiceFactory > & rSmgr ) if( ! ( 42 == seq.getArray()[0] ) ) printf( "wrong element in sequence\n" ); -// assert( 0 ); +// OSL_ASSERT( 0 ); } } #include<stdio.h> @@ -155,7 +151,7 @@ void testDocument( const Reference < XMultiServiceFactory > & rSmgr ) rSmgr->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop" ))), UNO_QUERY ); - assert( rLoader.is() ); + OSL_ASSERT( rLoader.is() ); sal_Char *urls[] = { "private:factory/swriter", diff --git a/bridges/test/testsameprocess.cxx b/bridges/test/testsameprocess.cxx index cf67d2484cb3..1cfc44078376 100644 --- a/bridges/test/testsameprocess.cxx +++ b/bridges/test/testsameprocess.cxx @@ -30,11 +30,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_bridges.hxx" -#if OSL_DEBUG_LEVEL == 0 -#undef NDEBUG -#define NDEBUG -#endif -#include <assert.h> #include <osl/time.h> #include <osl/mutex.hxx> @@ -201,7 +196,7 @@ int main( int argc, char *argv[] ) Reference < XBridge > rBridge = rFactory->getBridge( OUString( RTL_CONSTASCII_USTRINGPARAM("bla blub")) ); - assert( ! rBridge.is() ); + OSL_ASSERT( ! rBridge.is() ); } catch( Exception & ) diff --git a/cli_ure/prj/build.lst b/cli_ure/prj/build.lst index 007a01aec93f..268240c4597b 100644 --- a/cli_ure/prj/build.lst +++ b/cli_ure/prj/build.lst @@ -1,4 +1,4 @@ -ure cli_ure : cppu cppuhelper sal codemaker stoc udkapi tools NULL +ure cli_ure : cppu cppuhelper sal codemaker stoc udkapi bridges NULL ure cli_ure usr1 - all ure_mkout NULL ure cli_ure\inc nmake - all ure_inc NULL ure cli_ure\version nmake - all ure_source_version ure_inc NULL diff --git a/cli_ure/qa/climaker/makefile.mk b/cli_ure/qa/climaker/makefile.mk index cde3f4066142..a5b0af914f29 100644 --- a/cli_ure/qa/climaker/makefile.mk +++ b/cli_ure/qa/climaker/makefile.mk @@ -41,7 +41,7 @@ CLIMAKER*=$(WRAPCMD) $(BIN)$/climaker #----- compile .java files ----------------------------------------- -JARFILES = sandbox.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar +JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar JAVAFILES = ClimakerTestCase.java JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) diff --git a/cli_ure/source/native/path.cxx b/cli_ure/source/native/path.cxx index 075a3cdb75bd..9ef17010b0d2 100644 --- a/cli_ure/source/native/path.cxx +++ b/cli_ure/source/native/path.cxx @@ -38,7 +38,7 @@ #include <windows.h> #include "sal/types.h" -#include "tools/pathutils.hxx" +//#include "tools/pathutils.hxx" namespace cli_ure { diff --git a/cli_ure/unotypes/makefile.mk b/cli_ure/unotypes/makefile.mk index 7f9952488d44..0f4d4760e5a6 100644 --- a/cli_ure/unotypes/makefile.mk +++ b/cli_ure/unotypes/makefile.mk @@ -58,7 +58,7 @@ CLIMAKERFLAGS += --verbose #When changing the assembly version then this must also be done in scp2 $(OUT)$/bin$/cli_uretypes.dll : $(BIN)$/climaker.exe $(SOLARBINDIR)$/types.rdb $(BIN)$/cliureversion.mk - $(WRAPCMD) $(BIN)$/climaker.exe $(CLIMAKERFLAGS) \ + $(subst,$(SOLARBINDIR)$/climaker,$(BIN)$/climaker $(CLIMAKER)) $(CLIMAKERFLAGS) \ --out $@ \ --keyfile $(BIN)$/cliuno.snk \ --assembly-version $(CLI_URETYPES_NEW_VERSION) \ diff --git a/cli_ure/version/version.txt b/cli_ure/version/version.txt index a5b40dde8d0c..4676c40d4c95 100644 --- a/cli_ure/version/version.txt +++ b/cli_ure/version/version.txt @@ -29,23 +29,23 @@ # #************************************************************************* -CLI_URETYPES_NEW_VERSION=1.0.2.0 -CLI_URETYPES_OLD_VERSION=1.0.0.0-1.0.1.0 -CLI_URETYPES_POLICY_VERSION=2.0.0.0 +CLI_URETYPES_NEW_VERSION=1.0.4.0 +CLI_URETYPES_OLD_VERSION=1.0.0.0-1.0.3.0 +CLI_URETYPES_POLICY_VERSION=4.0.0.0 CLI_URETYPES_POLICY_ASSEMBLY=policy.1.0.cli_uretypes -CLI_BASETYPES_NEW_VERSION=1.0.13.0 -CLI_BASETYPES_OLD_VERSION=1.0.0.0-1.0.12.0 -CLI_BASETYPES_POLICY_VERSION=13.0.0.0 +CLI_BASETYPES_NEW_VERSION=1.0.15.0 +CLI_BASETYPES_OLD_VERSION=1.0.0.0-1.0.14.0 +CLI_BASETYPES_POLICY_VERSION=15.0.0.0 CLI_BASETYPES_POLICY_ASSEMBLY=policy.1.0.cli_basetypes -CLI_URE_NEW_VERSION=1.0.16.0 -CLI_URE_OLD_VERSION=1.0.0.0-1.0.15.0 -CLI_URE_POLICY_VERSION=16.0.0.0 +CLI_URE_NEW_VERSION=1.0.18.0 +CLI_URE_OLD_VERSION=1.0.0.0-1.0.17.0 +CLI_URE_POLICY_VERSION=18.0.0.0 CLI_URE_POLICY_ASSEMBLY=policy.1.0.cli_ure -CLI_CPPUHELPER_NEW_VERSION=1.0.16.0 -CLI_CPPUHELPER_OLD_VERSION=1.0.0.0-1.0.15.0 -CLI_CPPUHELPER_POLICY_VERSION=16.0.0.0 +CLI_CPPUHELPER_NEW_VERSION=1.0.18.0 +CLI_CPPUHELPER_OLD_VERSION=1.0.0.0-1.0.17.0 +CLI_CPPUHELPER_POLICY_VERSION=18.0.0.0 CLI_CPPUHELPER_POLICY_ASSEMBLY=policy.1.0.cli_cppuhelper diff --git a/codemaker/test/cppumaker/makefile.mk b/codemaker/test/cppumaker/makefile.mk index bab3dcbb30ea..1bc926dc0fe0 100644 --- a/codemaker/test/cppumaker/makefile.mk +++ b/codemaker/test/cppumaker/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -43,7 +43,7 @@ INCPRE += $(MISC)$/$(TARGET)$/inc SHL1TARGET = $(TARGET) SHL1OBJS = $(SLO)$/test_codemaker_cppumaker.obj -SHL1STDLIBS = $(CPPULIB) $(CPPUNITLIB) $(SALLIB) +SHL1STDLIBS = $(CPPULIB) $(CPPUNITLIB) $(SALLIB) $(TESTSHL2LIB) SHL1VERSIONMAP = version.map SHL1IMPLIB = i$(SHL1TARGET) DEF1NAME = $(SHL1TARGET) diff --git a/codemaker/test/cppumaker/test_codemaker_cppumaker.cxx b/codemaker/test/cppumaker/test_codemaker_cppumaker.cxx index 2f5c75fc1d92..9cd3dc70d3fd 100644 --- a/codemaker/test/cppumaker/test_codemaker_cppumaker.cxx +++ b/codemaker/test/cppumaker/test_codemaker_cppumaker.cxx @@ -369,7 +369,7 @@ #include "com/sun/star/uno/Any.hxx" #include "com/sun/star/uno/Type.hxx" #include "com/sun/star/uno/TypeClass.hpp" -#include "cppunit/simpleheader.hxx" +#include "testshl/simpleheader.hxx" #include "rtl/ustring.h" #include "rtl/ustring.hxx" diff --git a/cppu/inc/uno/lbnames.h b/cppu/inc/uno/lbnames.h index 27a6f1094a0a..481180fda953 100644 --- a/cppu/inc/uno/lbnames.h +++ b/cppu/inc/uno/lbnames.h @@ -46,12 +46,9 @@ #endif /* (_MSC_VER < 1000) */ /* sunpro cc */ #elif defined (__SUNPRO_CC) -#if (__SUNPRO_CC < 0x500) -#error "sunpro cc must be at least 5.x" -provoking error here, because PP ignores #error -#elif (__SUNPRO_CC < 0x600) +#if ((__SUNPRO_CC >= 0x5000 && __SUNPRO_CC < 0x6000) || (__SUNPRO_CC >= 0x500 && __SUNPRO_CC < 0x600)) #define TMP_CPPU_ENV sunpro5 -#else +#elif #error "sunpro cc version must be 5.x" provoking error here, because PP ignores #error #endif /* defined (__SUNPRO_CC) */ diff --git a/cppu/prj/build.lst b/cppu/prj/build.lst index a0caa14cbd9d..a22ca9ec8b66 100644 --- a/cppu/prj/build.lst +++ b/cppu/prj/build.lst @@ -8,4 +8,5 @@ cu cppu\source\cppu nmake - all cu_cppu cu_inc NULL cu cppu\source\helper\purpenv nmake - all cu_helper_purpenv cu_inc NULL cu cppu\source\UnsafeBridge nmake - all cu_UnsafeBridge cu_inc NULL cu cppu\source\AffineBridge nmake - all cu_AffineBridge cu_inc NULL -cu cppu\util nmake - all cu_util cu_thpool cu_typelib cu_cppu cu_uno cu_helper_purpenv cu_UnsafeBridge cu_AffineBridge NULL +cu cppu\source\LogBridge nmake - all cu_LogBridge cu_inc NULL +cu cppu\util nmake - all cu_util cu_thpool cu_typelib cu_cppu cu_uno cu_helper_purpenv cu_UnsafeBridge cu_AffineBridge cu_LogBridge NULL diff --git a/cppu/prj/d.lst b/cppu/prj/d.lst index 3355b6dc2c52..411a51cf2518 100644 --- a/cppu/prj/d.lst +++ b/cppu/prj/d.lst @@ -67,5 +67,8 @@ mkdir: %_DEST%\inc%_EXT%\uno ..\%__SRC%\bin\affine_u*.dll %_DEST%\bin%_EXT%\* ..\%__SRC%\lib\libaffine_uno_uno.* %_DEST%\lib%_EXT%\* +..\%__SRC%\bin\log_u*.dll %_DEST%\bin%_EXT%\* +..\%__SRC%\lib\liblog_uno_uno.* %_DEST%\lib%_EXT%\* + linklib: libuno_cppu.*.* linklib: libuno_purpenvhelper*.*.* diff --git a/cppu/qa/makefile.mk b/cppu/qa/makefile.mk index 4051dd6d82ec..8b720c832cf4 100644 --- a/cppu/qa/makefile.mk +++ b/cppu/qa/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -43,28 +43,28 @@ INCPRE += $(MISC)$/$(TARGET)$/inc SHL1TARGET = $(TARGET)_any SHL1OBJS = $(SLO)$/test_any.obj -SHL1STDLIBS = $(CPPULIB) $(CPPUNITLIB) $(SALLIB) +SHL1STDLIBS = $(CPPULIB) $(CPPUNITLIB) $(TESTSHL2LIB) $(SALLIB) SHL1VERSIONMAP = version.map SHL1IMPLIB = i$(SHL1TARGET) DEF1NAME = $(SHL1TARGET) SHL2TARGET = $(TARGET)_unotype SHL2OBJS = $(SLO)$/test_unotype.obj -SHL2STDLIBS = $(CPPULIB) $(CPPUNITLIB) $(SALLIB) +SHL2STDLIBS = $(CPPULIB) $(CPPUNITLIB) $(TESTSHL2LIB) $(SALLIB) SHL2VERSIONMAP = version.map SHL2IMPLIB = i$(SHL2TARGET) DEF2NAME = $(SHL2TARGET) SHL3TARGET = $(TARGET)_reference SHL3OBJS = $(SLO)$/test_reference.obj -SHL3STDLIBS = $(CPPULIB) $(CPPUNITLIB) $(SALLIB) +SHL3STDLIBS = $(CPPULIB) $(CPPUNITLIB) $(TESTSHL2LIB) $(SALLIB) SHL3VERSIONMAP = version.map SHL3IMPLIB = i$(SHL3TARGET) DEF3NAME = $(SHL3TARGET) SHL4TARGET = $(TARGET)_recursion SHL4OBJS = $(SLO)$/test_recursion.obj -SHL4STDLIBS = $(CPPULIB) $(CPPUNITLIB) $(SALLIB) +SHL4STDLIBS = $(CPPULIB) $(CPPUNITLIB) $(TESTSHL2LIB) $(SALLIB) SHL4VERSIONMAP = version.map SHL4IMPLIB = i$(SHL4TARGET) DEF4NAME = $(SHL4TARGET) @@ -92,7 +92,7 @@ $(MISC)$/$(TARGET)$/types.urd: types.idl $(IDLC) -O$(MISC)$/$(TARGET) -I$(SOLARIDLDIR) -cid -we $< test .PHONY: $(SHL1TARGETN) $(SHL2TARGETN) $(SHL3TARGETN) $(SHL4TARGETN) - testshl2 $(SHL1TARGETN) - testshl2 $(SHL2TARGETN) - testshl2 $(SHL3TARGETN) - testshl2 $(SHL4TARGETN)
\ No newline at end of file + $(TESTSHL2) $(SHL1TARGETN) + $(TESTSHL2) $(SHL2TARGETN) + $(TESTSHL2) $(SHL3TARGETN) + $(TESTSHL2) $(SHL4TARGETN) diff --git a/cppu/qa/test_any.cxx b/cppu/qa/test_any.cxx index cad91661926f..785af529e51a 100644 --- a/cppu/qa/test_any.cxx +++ b/cppu/qa/test_any.cxx @@ -58,7 +58,7 @@ #include "com/sun/star/uno/Sequence.hxx" #include "com/sun/star/uno/Type.hxx" #include "com/sun/star/uno/XInterface.hpp" -#include "cppunit/simpleheader.hxx" +#include "testshl/simpleheader.hxx" #include "osl/diagnose.h" #include "osl/interlck.h" #include "rtl/string.h" diff --git a/cppu/qa/test_recursion.cxx b/cppu/qa/test_recursion.cxx index 6ae70c44d003..60853776662b 100644 --- a/cppu/qa/test_recursion.cxx +++ b/cppu/qa/test_recursion.cxx @@ -31,7 +31,7 @@ #include "precompiled_cppu.hxx" #include "sal/config.h" -#include "cppunit/simpleheader.hxx" +#include "testshl/simpleheader.hxx" #include "sal/types.h" #include "Rec.hpp" diff --git a/cppu/qa/test_reference.cxx b/cppu/qa/test_reference.cxx index afb12654a124..8bb793c655e4 100644 --- a/cppu/qa/test_reference.cxx +++ b/cppu/qa/test_reference.cxx @@ -35,7 +35,7 @@ #include "Interface1.hpp" -#include "cppunit/simpleheader.hxx" +#include "testshl/simpleheader.hxx" #include "rtl/ustring.hxx" #include "sal/types.h" diff --git a/cppu/qa/test_unotype.cxx b/cppu/qa/test_unotype.cxx index 0068dcedd463..ad457d516fa2 100644 --- a/cppu/qa/test_unotype.cxx +++ b/cppu/qa/test_unotype.cxx @@ -47,7 +47,7 @@ #include "com/sun/star/uno/XComponentContext.hpp" #include "com/sun/star/uno/XInterface.hpp" #include "cppu/unotype.hxx" -#include "cppunit/simpleheader.hxx" +#include "testshl/simpleheader.hxx" #include "rtl/ustring.h" #include "rtl/ustring.hxx" #include "sal/types.h" diff --git a/cppu/source/LogBridge/LogBridge.cxx b/cppu/source/LogBridge/LogBridge.cxx new file mode 100644 index 000000000000..6bb32e4f0666 --- /dev/null +++ b/cppu/source/LogBridge/LogBridge.cxx @@ -0,0 +1,280 @@ +/************************************************************************* + * + * 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: LogBridge.cxx,v $ + * $Revision: 1.5 $ + * + * 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_cppu.hxx" + +#include "osl/mutex.hxx" +#include "osl/thread.h" +#include "uno/dispatcher.h" +#include "typelib/typedescription.hxx" +#include "cppu/helper/purpenv/Environment.hxx" +#include "cppu/helper/purpenv/Mapping.hxx" +#include "cppu/EnvDcp.hxx" +#include "rtl/logfile.hxx" +#include "uno/environment.hxx" +#include <com/sun/star/uno/Type.hxx> +#include <hash_map> +#include <memory> + +namespace +{ +class LogBridge : public cppu::Enterable +{ + osl::Mutex m_mutex; + sal_Int32 m_count; + oslThreadIdentifier m_threadId; + + virtual ~LogBridge(void); + +public: + explicit LogBridge(void); + + virtual void v_callInto_v(uno_EnvCallee * pCallee, va_list * pParam); + virtual void v_callOut_v (uno_EnvCallee * pCallee, va_list * pParam); + + virtual void v_enter(void); + virtual void v_leave(void); + + virtual int v_isValid(rtl::OUString * pReason); +}; + +LogBridge::LogBridge(void) + : m_count (0) + ,m_threadId(0) +{ +} + +LogBridge::~LogBridge(void) +{ + OSL_ASSERT(m_count >= 0); +} + +void LogBridge::v_callInto_v(uno_EnvCallee * pCallee, va_list * pParam) +{ + enter(); + pCallee(pParam); + leave(); +} + +void LogBridge::v_callOut_v(uno_EnvCallee * pCallee, va_list * pParam) +{ + OSL_ASSERT(m_count > 0); + + -- m_count; + pCallee(pParam); + ++ m_count; + + if (!m_threadId) + m_threadId = osl_getThreadIdentifier(NULL); +} + +void LogBridge::v_enter(void) +{ + m_mutex.acquire(); + + OSL_ASSERT(m_count >= 0); + + if (m_count == 0) + m_threadId = osl_getThreadIdentifier(NULL); + + ++ m_count; +} + +void LogBridge::v_leave(void) +{ + OSL_ASSERT(m_count > 0); + + -- m_count; + if (!m_count) + m_threadId = 0; + + + m_mutex.release(); +} + +int LogBridge::v_isValid(rtl::OUString * pReason) +{ + int result = 1; + + result = m_count > 0; + if (!result) + *pReason = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("not entered")); + + else + { + result = m_threadId == osl_getThreadIdentifier(NULL); + + if (!result) + *pReason = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("wrong thread")); + } + + if (result) + *pReason = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OK")); + + return result; +} + + void traceValue(typelib_TypeDescriptionReference* _pTypeRef,void* pArg) + { + switch(_pTypeRef->eTypeClass) + { + case typelib_TypeClass_STRING: + { + const ::rtl::OString sValue( ::rtl::OUStringToOString(*static_cast< ::rtl::OUString*>(pArg),osl_getThreadTextEncoding())); + rtl_logfile_trace( "%s", sValue.getStr()); + } + break; + case typelib_TypeClass_BOOLEAN: + rtl_logfile_trace( "%d", *static_cast<sal_Bool*>(pArg)); + break; + case typelib_TypeClass_BYTE: + rtl_logfile_trace( "%d", *static_cast<sal_Int8*>(pArg)); + break; + case typelib_TypeClass_CHAR: + rtl_logfile_trace( "%c", *static_cast<sal_Char*>(pArg)); + break; + case typelib_TypeClass_SHORT: + case typelib_TypeClass_UNSIGNED_SHORT: + rtl_logfile_trace( "%d", *static_cast<sal_Int16*>(pArg)); + break; + case typelib_TypeClass_LONG: + case typelib_TypeClass_UNSIGNED_LONG: + case typelib_TypeClass_ENUM: + rtl_logfile_trace( "%d", *static_cast<sal_Int32*>(pArg)); + break; + case typelib_TypeClass_HYPER: + case typelib_TypeClass_UNSIGNED_HYPER: + rtl_logfile_trace( "%d", *static_cast<sal_Int64*>(pArg)); + break; + case typelib_TypeClass_FLOAT: + rtl_logfile_trace( "%f", *static_cast<float*>(pArg)); + break; + case typelib_TypeClass_DOUBLE: + rtl_logfile_trace( "%f", *static_cast<double*>(pArg)); + break; + case typelib_TypeClass_TYPE: + { + const ::rtl::OString sValue( ::rtl::OUStringToOString(((com::sun::star::uno::Type*)pArg)->getTypeName(),osl_getThreadTextEncoding())); + rtl_logfile_trace( "%s", sValue.getStr()); + } + break; + case typelib_TypeClass_ANY: + if ( static_cast<uno_Any*>(pArg)->pData ) + traceValue(static_cast<uno_Any*>(pArg)->pType,static_cast<uno_Any*>(pArg)->pData); + else + rtl_logfile_trace( "void"); + break; + case typelib_TypeClass_EXCEPTION: + rtl_logfile_trace( "exception"); + break; + case typelib_TypeClass_INTERFACE: + { + const ::rtl::OString sValue( ::rtl::OUStringToOString(_pTypeRef->pTypeName,osl_getThreadTextEncoding())); + rtl_logfile_trace( "%s 0x%p", sValue.getStr(),pArg); + } + break; + case typelib_TypeClass_VOID: + rtl_logfile_trace( "void"); + break; + default: + rtl_logfile_trace( "0x%p", pArg); + break; + } // switch(pParams[i].pTypeRef->eTypeClass) + } +} + +void LogProbe( + bool pre, + void * /*pThis*/, + void * /*pContext*/, + typelib_TypeDescriptionReference * pReturnTypeRef, + typelib_MethodParameter * pParams, + sal_Int32 nParams, + typelib_TypeDescription const * pMemberType, + void * pReturn, + void * pArgs[], + uno_Any ** ppException ) +{ + static ::std::auto_ptr< ::rtl::Logfile> pLogger; + ::rtl::OString sTemp; + if ( pMemberType && pMemberType->pTypeName ) + sTemp = ::rtl::OUStringToOString(pMemberType->pTypeName,RTL_TEXTENCODING_ASCII_US); + if ( pre ) + { + rtl_logfile_longTrace( "{ LogBridge () %s", sTemp.getStr() ); + if ( nParams ) + { + rtl_logfile_trace( "\n| : ( LogBridge "); + for(sal_Int32 i = 0;i < nParams;++i) + { + if ( i > 0 ) + rtl_logfile_trace( ","); + traceValue(pParams[i].pTypeRef,pArgs[i]); + + } + rtl_logfile_trace( ")"); + } // if ( nParams ) + rtl_logfile_trace( "\n"); + } + else if ( !pre ) + { + rtl_logfile_longTrace( "} LogBridge () %s",sTemp.getStr()); + if ( ppException && *ppException ) + { + rtl_logfile_trace( " excption occured : "); + typelib_TypeDescription * pElementTypeDescr = 0; + TYPELIB_DANGER_GET( &pElementTypeDescr, (*ppException)->pType ); + const ::rtl::OString sValue( ::rtl::OUStringToOString(pElementTypeDescr->pTypeName,osl_getThreadTextEncoding())); + rtl_logfile_trace( "%s", sValue.getStr()); + TYPELIB_DANGER_RELEASE( pElementTypeDescr ); + } + else if ( pReturnTypeRef ) + { + rtl_logfile_trace( " return : "); + traceValue(pReturnTypeRef,pReturn); + } // if ( pReturn && pReturnTypeRef ) + + rtl_logfile_trace( "\n"); + } +} + +extern "C" void SAL_DLLPUBLIC_EXPORT SAL_CALL uno_initEnvironment(uno_Environment * pEnv) + SAL_THROW_EXTERN_C() +{ + cppu::helper::purpenv::Environment_initWithEnterable(pEnv, new LogBridge()); +} + +extern "C" void SAL_DLLPUBLIC_EXPORT SAL_CALL uno_ext_getMapping(uno_Mapping ** ppMapping, + uno_Environment * pFrom, + uno_Environment * pTo ) +{ + cppu::helper::purpenv::createMapping(ppMapping, pFrom, pTo,LogProbe); +} diff --git a/cppu/source/LogBridge/makefile.mk b/cppu/source/LogBridge/makefile.mk new file mode 100644 index 000000000000..c7bc5e5172f6 --- /dev/null +++ b/cppu/source/LogBridge/makefile.mk @@ -0,0 +1,48 @@ +#************************************************************************* +# +# 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: makefile.mk,v $ +# +# $Revision: 1.4 $ +# +# 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. +# +#************************************************************************* + +PRJ := ..$/.. +PRJNAME := cppu +TARGET := LogBridge + +ENABLE_EXCEPTIONS := TRUE +NO_BSYMBOLIC := TRUE +USE_DEFFILE := FALSE + + +.INCLUDE: settings.mk + + +SLOFILES := $(SLO)$/LogBridge.obj + + +.INCLUDE: target.mk + diff --git a/cppu/util/extra.mk b/cppu/util/extra.mk index dc06e9284e72..3aac0524218b 100644 --- a/cppu/util/extra.mk +++ b/cppu/util/extra.mk @@ -72,6 +72,21 @@ SHL4DEF := empty.def SHL4OBJS := $(SLO)$/AffineBridge.obj SHL4RPATH := URELIB + +SHL5TARGET := log_uno_uno +SHL5IMPLIB := i$(SHL5TARGET) +SHL5STDLIBS := $(purpenv_helper_LIB) $(SALLIB) $(CPPULIB) +SHL5OBJS := $(SLO)$/LogBridge.obj + +.IF "$(GUI)"=="OS2" +SHL5VERSIONMAP=unsafe_os2.map +SHL5DEF=$(MISC)$/$(SHL5TARGET).def +DEF5NAME=LogMapping.def +.ELSE +SHL5DEF := empty.def +.ENDIF +SHL5RPATH := URELIB + # --- Targets ------------------------------------------------------ .INCLUDE : target.mk diff --git a/cppuhelper/inc/cppuhelper/weak.hxx b/cppuhelper/inc/cppuhelper/weak.hxx index f4b9c38d2215..9072ba6f6240 100644 --- a/cppuhelper/inc/cppuhelper/weak.hxx +++ b/cppuhelper/inc/cppuhelper/weak.hxx @@ -67,6 +67,12 @@ protected: */ virtual ~OWeakObject() SAL_THROW( (::com::sun::star::uno::RuntimeException) ); + /** disposes and resets m_pWeakConnectionPoint + @precond + m_refCount equals 0 + */ + void disposeWeakConnectionPoint(); + /** reference count. @attention diff --git a/cppuhelper/qa/ifcontainer/cppu_ifcontainer.cxx b/cppuhelper/qa/ifcontainer/cppu_ifcontainer.cxx index ddbc3f7c6f82..cfcfebf246e6 100644 --- a/cppuhelper/qa/ifcontainer/cppu_ifcontainer.cxx +++ b/cppuhelper/qa/ifcontainer/cppu_ifcontainer.cxx @@ -28,7 +28,7 @@ * ************************************************************************/ -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> #include "com/sun/star/lang/XEventListener.hpp" #include "cppuhelper/interfacecontainer.hxx" diff --git a/cppuhelper/qa/ifcontainer/makefile.mk b/cppuhelper/qa/ifcontainer/makefile.mk index dd6c13fea52c..624bc797a64b 100644 --- a/cppuhelper/qa/ifcontainer/makefile.mk +++ b/cppuhelper/qa/ifcontainer/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -41,7 +41,7 @@ ENABLE_EXCEPTIONS=TRUE # BEGIN ---------------------------------------------------------------- -# auto generated Target:joblist by codegen.pl +# auto generated Target:joblist by codegen.pl SHL1OBJS= \ $(SLO)$/cppu_ifcontainer.obj SHL1TARGET= cppu_ifcontainer @@ -49,6 +49,7 @@ SHL1STDLIBS=\ $(CPPUHELPERLIB) \ $(SALLIB) \ $(CPPULIB) \ + $(TESTSHL2LIB)\ $(CPPUNITLIB) SHL1IMPLIB= i$(SHL1TARGET) DEF1NAME =$(SHL1TARGET) diff --git a/cppuhelper/qa/propertysetmixin/makefile.mk b/cppuhelper/qa/propertysetmixin/makefile.mk index b081274d8e99..2ad56c05ff1c 100644 --- a/cppuhelper/qa/propertysetmixin/makefile.mk +++ b/cppuhelper/qa/propertysetmixin/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -54,7 +54,7 @@ INCPRE += -I$(MISC)$/$(TARGET)$/inc SHL1TARGET = $(TARGET) SHL1OBJS = $(SLO)$/test_propertysetmixin.obj -SHL1STDLIBS = $(CPPULIB) $(CPPUHELPERLIB) $(CPPUNITLIB) $(SALLIB) +SHL1STDLIBS = $(CPPULIB) $(CPPUHELPERLIB) $(CPPUNITLIB) $(SALLIB) $(TESTSHL2LIB) SHL1IMPLIB = i$(SHL1TARGET) DEF1NAME = $(SHL1TARGET) diff --git a/cppuhelper/qa/propertysetmixin/test_propertysetmixin.cxx b/cppuhelper/qa/propertysetmixin/test_propertysetmixin.cxx index 5336b60ae68a..ecb7220d110d 100644 --- a/cppuhelper/qa/propertysetmixin/test_propertysetmixin.cxx +++ b/cppuhelper/qa/propertysetmixin/test_propertysetmixin.cxx @@ -64,7 +64,7 @@ #include "com/sun/star/uno/XComponentContext.hpp" #include "cppuhelper/implbase1.hxx" #include "cppuhelper/servicefactory.hxx" -#include "cppunit/simpleheader.hxx" +#include "testshl/simpleheader.hxx" #include "osl/mutex.hxx" #include "osl/thread.h" #include "rtl/ref.hxx" diff --git a/cppuhelper/qa/unourl/cppu_unourl.cxx b/cppuhelper/qa/unourl/cppu_unourl.cxx index 21af4b8d1364..f80388d5d122 100644 --- a/cppuhelper/qa/unourl/cppu_unourl.cxx +++ b/cppuhelper/qa/unourl/cppu_unourl.cxx @@ -28,7 +28,7 @@ * ************************************************************************/ -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> #include "cppuhelper/unourl.hxx" #include "rtl/malformeduriexception.hxx" diff --git a/cppuhelper/qa/unourl/makefile.mk b/cppuhelper/qa/unourl/makefile.mk index a611b135c7e9..a999532c5b4a 100644 --- a/cppuhelper/qa/unourl/makefile.mk +++ b/cppuhelper/qa/unourl/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -41,7 +41,7 @@ ENABLE_EXCEPTIONS=TRUE # BEGIN ---------------------------------------------------------------- -# auto generated Target:joblist by codegen.pl +# auto generated Target:joblist by codegen.pl SHL1OBJS= \ $(SLO)$/cppu_unourl.obj SHL1TARGET= cppu_unourl @@ -49,6 +49,7 @@ SHL1STDLIBS=\ $(CPPUHELPERLIB) \ $(SALLIB) \ $(CPPULIB) \ + $(TESTSHL2LIB)\ $(CPPUNITLIB) SHL1IMPLIB= i$(SHL1TARGET) DEF1NAME =$(SHL1TARGET) diff --git a/cppuhelper/qa/weak/makefile.mk b/cppuhelper/qa/weak/makefile.mk index 95f1697ef7be..bb0072b4d0f3 100644 --- a/cppuhelper/qa/weak/makefile.mk +++ b/cppuhelper/qa/weak/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -41,7 +41,7 @@ DLLPRE = # no leading "lib" on .so files SHL1TARGET = $(TARGET) SHL1OBJS = $(SLO)$/test_weak.obj -SHL1STDLIBS = $(CPPULIB) $(CPPUHELPERLIB) $(CPPUNITLIB) $(SALLIB) +SHL1STDLIBS = $(CPPULIB) $(CPPUHELPERLIB) $(CPPUNITLIB) $(SALLIB) $(TESTSHL2LIB) SHL1VERSIONMAP = version.map SHL1IMPLIB = i$(SHL1TARGET) DEF1NAME = $(SHL1TARGET) @@ -53,4 +53,4 @@ SLOFILES = $(SHL1OBJS) ALLTAR: test test .PHONY: $(SHL1TARGETN) - testshl2 $(SHL1TARGETN) + $(TESTSHL2) $(SHL1TARGETN) diff --git a/cppuhelper/qa/weak/test_weak.cxx b/cppuhelper/qa/weak/test_weak.cxx index 98bbb6527276..0cf128d519d6 100644 --- a/cppuhelper/qa/weak/test_weak.cxx +++ b/cppuhelper/qa/weak/test_weak.cxx @@ -41,7 +41,7 @@ #include "com/sun/star/uno/XWeak.hpp" #include "cppuhelper/implbase1.hxx" #include "cppuhelper/weak.hxx" -#include "cppunit/simpleheader.hxx" +#include "testshl/simpleheader.hxx" #include "rtl/ref.hxx" #include "sal/types.h" diff --git a/cppuhelper/source/cc5_solaris_sparc.map b/cppuhelper/source/cc5_solaris_sparc.map index 0c3f1c556d64..0961c6830d1f 100755 --- a/cppuhelper/source/cc5_solaris_sparc.map +++ b/cppuhelper/source/cc5_solaris_sparc.map @@ -379,3 +379,8 @@ UDK_3.6 { # OOo 3.0 __1cEcppuSOPropertySetHelper2t5B6Mrn0ATOBroadcastHelperVar4n0AbIOMultiTypeInterfaceContainerHelper_nDcomDsunEstarDunoEType___pn0AWIEventNotificationHook_b_v_; __1cEcppuSOPropertySetHelper2t6Mrn0ATOBroadcastHelperVar4n0AbIOMultiTypeInterfaceContainerHelper_nDcomDsunEstarDunoEType___pn0AWIEventNotificationHook_b_v_; } UDK_3.5; + +UDK_3.7 { # OOo 3.3 + global: + __1cEcppuLOWeakObjectbAdisposeWeakConnectionPoint6M_v_; +} UDK_3.6; diff --git a/cppuhelper/source/component.cxx b/cppuhelper/source/component.cxx index d94614703be5..728f6815c309 100644 --- a/cppuhelper/source/component.cxx +++ b/cppuhelper/source/component.cxx @@ -90,6 +90,10 @@ void OComponentHelper::release() throw() { if (! rBHelper.bDisposed) { + // *before* again incrementing our ref count, ensure that our weak connection point + // will not create references to us anymore (via XAdapter::queryAdapted) + disposeWeakConnectionPoint(); + Reference<XInterface > xHoldAlive( *this ); // First dispose try diff --git a/cppuhelper/source/gcc3.map b/cppuhelper/source/gcc3.map index 819c3e046b30..9348e91525c0 100644 --- a/cppuhelper/source/gcc3.map +++ b/cppuhelper/source/gcc3.map @@ -373,3 +373,9 @@ UDK_3.5 { # OOo 3.0 _ZN4cppu18OPropertySetHelperC1ERNS_19OBroadcastHelperVarINS_34OMultiTypeInterfaceContainerHelperEN3com3sun4star3uno4TypeEEEPNS_22IEventNotificationHookEb; _ZN4cppu18OPropertySetHelperC2ERNS_19OBroadcastHelperVarINS_34OMultiTypeInterfaceContainerHelperEN3com3sun4star3uno4TypeEEEPNS_22IEventNotificationHookEb; } UDK_3.4; + +UDK_3.6 { # OOo 3.3 + global: + _ZN4cppu11OWeakObject26disposeWeakConnectionPointEv; +} UDK_3.5; + diff --git a/cppuhelper/source/implbase.cxx b/cppuhelper/source/implbase.cxx index 9caa4ca93615..acf05724c71b 100644 --- a/cppuhelper/source/implbase.cxx +++ b/cppuhelper/source/implbase.cxx @@ -247,6 +247,8 @@ void WeakComponentImplHelperBase::release() throw () { if (osl_decrementInterlockedCount( &m_refCount ) == 0) { + // ensure no other references are created, via the weak connection point, from now on + disposeWeakConnectionPoint(); // restore reference count: osl_incrementInterlockedCount( &m_refCount ); if (! rBHelper.bDisposed) { @@ -381,6 +383,8 @@ void WeakAggComponentImplHelperBase::release() OWeakAggObject::release(); } else if (osl_decrementInterlockedCount( &m_refCount ) == 0) { + // ensure no other references are created, via the weak connection point, from now on + disposeWeakConnectionPoint(); // restore reference count: osl_incrementInterlockedCount( &m_refCount ); if (! rBHelper.bDisposed) { diff --git a/cppuhelper/source/interfacecontainer.cxx b/cppuhelper/source/interfacecontainer.cxx index 88f25e192e49..cc5b7708f1d8 100644 --- a/cppuhelper/source/interfacecontainer.cxx +++ b/cppuhelper/source/interfacecontainer.cxx @@ -40,13 +40,6 @@ #include <hash_map> -#if OSL_DEBUG_LEVEL == 0 -# ifndef NDEBUG -# define NDEBUG -# endif -#endif -#include <assert.h> - #include <com/sun/star/lang/XEventListener.hpp> diff --git a/cppuhelper/source/msvc_win32_intel.map b/cppuhelper/source/msvc_win32_intel.map index a90ec88f3ca3..c999ae200ac2 100644 --- a/cppuhelper/source/msvc_win32_intel.map +++ b/cppuhelper/source/msvc_win32_intel.map @@ -271,3 +271,8 @@ UDK_3.5 { # OOo 3.0 global: ??0OPropertySetHelper@cppu@@QAE@AAU?$OBroadcastHelperVar@VOMultiTypeInterfaceContainerHelper@cppu@@VType@uno@star@sun@com@@@1@PAVIEventNotificationHook@1@_N@Z; } UDK_3.4; + +UDK_3.6 { # OOo 3.3 + global: + ?disposeWeakConnectionPoint@OWeakObject@cppu@@IAEXXZ; +} UDK_3.5; diff --git a/cppuhelper/source/shlib.cxx b/cppuhelper/source/shlib.cxx index db5d91124a14..2008d27f5310 100644 --- a/cppuhelper/source/shlib.cxx +++ b/cppuhelper/source/shlib.cxx @@ -315,7 +315,26 @@ static OUString getLibEnv(OUString const & aModulePath, } if (!pEnv->is() && pEnvTypeName) + { *pSourceEnv_name = OUString::createFromAscii(pEnvTypeName); + const char * pUNO_ENV_LOG = ::getenv( "UNO_ENV_LOG" ); + if (pUNO_ENV_LOG && rtl_str_getLength(pUNO_ENV_LOG) ) + { + OString implName(OUStringToOString(cImplName, RTL_TEXTENCODING_ASCII_US)); + OString aEnv( pUNO_ENV_LOG ); + sal_Int32 nIndex = 0; + do + { + const OString aStr( aEnv.getToken( 0, ';', nIndex ) ); + if ( aStr.equals(implName) ) + { + *pSourceEnv_name += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(":log")); + break; + } + } while( nIndex != -1 ); + } + + } return aExcMsg; } diff --git a/cppuhelper/source/tdmgr.cxx b/cppuhelper/source/tdmgr.cxx index 306ace09d592..6f2aa70ea2d5 100644 --- a/cppuhelper/source/tdmgr.cxx +++ b/cppuhelper/source/tdmgr.cxx @@ -688,17 +688,17 @@ static void SAL_CALL typelib_callback( catch (container::NoSuchElementException & exc) { (void) exc; // avoid warning about unused variable - OSL_ENSURE( - 0, OUStringToOString( - OUString( RTL_CONSTASCII_USTRINGPARAM( - "typelibrary type not available: ") ) + + OSL_TRACE( + "typelibrary type not available: %s", + OUStringToOString( exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() ); } catch (Exception & exc) { (void) exc; // avoid warning about unused variable - OSL_ENSURE( - 0, OUStringToOString( + OSL_TRACE( + "%s", + OUStringToOString( exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() ); } } diff --git a/cppuhelper/source/weak.cxx b/cppuhelper/source/weak.cxx index c4055eba4f8a..b518d2526e3b 100644 --- a/cppuhelper/source/weak.cxx +++ b/cppuhelper/source/weak.cxx @@ -216,25 +216,31 @@ void SAL_CALL OWeakObject::release() throw() if (osl_decrementInterlockedCount( &m_refCount ) == 0) { // notify/clear all weak-refs before object's dtor is executed // (which may check weak-refs to this object): - if (m_pWeakConnectionPoint != 0) { - OWeakConnectionPoint * const p = m_pWeakConnectionPoint; - m_pWeakConnectionPoint = 0; - try { - p->dispose(); - } - catch (RuntimeException const& exc) { - OSL_ENSURE( - false, OUStringToOString( - exc.Message, RTL_TEXTENCODING_ASCII_US ).getStr() ); - static_cast<void>(exc); - } - p->release(); - } + disposeWeakConnectionPoint(); // destroy object: delete this; } } +void OWeakObject::disposeWeakConnectionPoint() +{ + OSL_PRECOND( m_refCount == 0, "OWeakObject::disposeWeakConnectionPoint: only to be called with a ref count of 0!" ); + if (m_pWeakConnectionPoint != 0) { + OWeakConnectionPoint * const p = m_pWeakConnectionPoint; + m_pWeakConnectionPoint = 0; + try { + p->dispose(); + } + catch (RuntimeException const& exc) { + OSL_ENSURE( + false, OUStringToOString( + exc.Message, RTL_TEXTENCODING_ASCII_US ).getStr() ); + static_cast<void>(exc); + } + p->release(); + } +} + OWeakObject::~OWeakObject() SAL_THROW( (RuntimeException) ) { } diff --git a/cppuhelper/test/testidlclass.cxx b/cppuhelper/test/testidlclass.cxx index 8784f59d79e3..89b2d6411e77 100644 --- a/cppuhelper/test/testidlclass.cxx +++ b/cppuhelper/test/testidlclass.cxx @@ -30,11 +30,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_cppuhelper.hxx" -#if OSL_DEBUG_LEVEL == 0 -#undef NDEBUG -#define NDEBUG -#endif -#include <assert.h> #include <cppuhelper/stdidlclass.hxx> @@ -65,18 +60,18 @@ void testidlclass( const Reference < XMultiServiceFactory > &rSMgr) (XServiceInfo * ) 0 ); - assert( r.is() ); + OSL_ASSERT( r.is() ); { // test the xidlclassprovider interface ! Reference< XIdlClassProvider > rProv( r , UNO_QUERY ); - assert( rProv.is() ); + OSL_ASSERT( rProv.is() ); { Sequence < Reference < XIdlClass > > seq = rProv->getIdlClasses(); // is always one - assert( seq.getLength() == 1 ); + OSL_ASSERT( seq.getLength() == 1 ); // test the weak reference rProv->getIdlClasses(); @@ -89,7 +84,7 @@ void testidlclass( const Reference < XMultiServiceFactory > &rSMgr) } - assert( r->getName() == sImplName ); + OSL_ASSERT( r->getName() == sImplName ); // test equals Reference < XIdlClass > r2 = @@ -101,18 +96,18 @@ void testidlclass( const Reference < XMultiServiceFactory > &rSMgr) (XServiceInfo * ) 0 ); // test for implementation name - assert( r2->equals( r ) ); + OSL_ASSERT( r2->equals( r ) ); Sequence < Reference < XIdlClass > > seqIdlClass = r->getInterfaces(); //TODO ! // one idl class for one interface // this test fails, if core reflection fails ! -// assert( 1 == seqIdlClass.getLength() ); +// OSL_ASSERT( 1 == seqIdlClass.getLength() ); // Reference < XIdlClass > rIdlInterface = seqIdlClass.getArray()[0]; // check for IdlClass interface returned by Core Reflection -// assert( rIdlInterface.is() ); +// OSL_ASSERT( rIdlInterface.is() ); diff --git a/cppuhelper/test/testproptyphlp.cxx b/cppuhelper/test/testproptyphlp.cxx index e798f86cab54..d3b17ed3e83a 100644 --- a/cppuhelper/test/testproptyphlp.cxx +++ b/cppuhelper/test/testproptyphlp.cxx @@ -34,12 +34,6 @@ #include <com/sun/star/beans/Property.hpp> -#if OSL_DEBUG_LEVEL == 0 -#undef NDEBUG -#define NDEBUG -#endif -#include <assert.h> - using namespace ::com::sun::star::uno; using namespace ::cppu; @@ -51,27 +45,27 @@ void testPropertyTypeHelper() sal_Int32 i; convertPropertyValue( i , a ); - assert( 25 == i ); + OSL_ASSERT( 25 == i ); sal_Int16 i16; convertPropertyValue( i16 , a ); - assert( 25 == i16 ); + OSL_ASSERT( 25 == i16 ); sal_Int8 i8; convertPropertyValue( i8 , a ); - assert( 25 == i8 ); + OSL_ASSERT( 25 == i8 ); sal_uInt32 i32; convertPropertyValue( i32 , a ); - assert( 25 == i32 ); + OSL_ASSERT( 25 == i32 ); double d; convertPropertyValue( d , a ); - assert( 25. == d ); + OSL_ASSERT( 25. == d ); float f; convertPropertyValue( f , a ); - assert( 25. == f ); + OSL_ASSERT( 25. == f ); ::com::sun::star::beans::Property prop; @@ -83,11 +77,11 @@ void testPropertyTypeHelper() ::com::sun::star::beans::Property prop2; convertPropertyValue( prop2 , a ); - assert( prop.Handle == prop2.Handle && prop.Name == prop2.Name && prop.Attributes == prop2.Attributes ); + OSL_ASSERT( prop.Handle == prop2.Handle && prop.Name == prop2.Name && prop.Attributes == prop2.Attributes ); ::rtl::OUString ow; a <<= prop.Name; convertPropertyValue( ow , a ); - assert( ow == prop.Name ); + OSL_ASSERT( ow == prop.Name ); } diff --git a/cpputools/source/regcomplazy/regcomplazy.cxx b/cpputools/source/regcomplazy/regcomplazy.cxx index 69fd77446156..abcb2c187c08 100755 --- a/cpputools/source/regcomplazy/regcomplazy.cxx +++ b/cpputools/source/regcomplazy/regcomplazy.cxx @@ -131,6 +131,8 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) sBuffer.append(pBuffer, readSize); } } + fclose(fDescr); + fDescr = 0; // just to be sure noone tries to use the file ever after } OString sDescr = sBuffer.makeStringAndClear(); diff --git a/idlc/inc/idlc/options.hxx b/idlc/inc/idlc/options.hxx index e55dc961903b..11bc0fe4d657 100644 --- a/idlc/inc/idlc/options.hxx +++ b/idlc/inc/idlc/options.hxx @@ -69,11 +69,15 @@ public: const StringVector& getInputFiles() const { return m_inputFiles; } bool readStdin() const { return m_stdin; } + bool verbose() const { return m_verbose; } + bool quiet() const { return m_quiet; } protected: ::rtl::OString m_program; StringVector m_inputFiles; bool m_stdin; + bool m_verbose; + bool m_quiet; OptionMap m_options; }; diff --git a/idlc/source/idlcmain.cxx b/idlc/source/idlcmain.cxx index 1ce3a9fa05b0..68c1ae7cf5a5 100644 --- a/idlc/source/idlcmain.cxx +++ b/idlc/source/idlcmain.cxx @@ -56,11 +56,12 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) sal_Int32 nErrors = 0; if (options.readStdin()) { - fprintf( - stdout, "%s: compile stdin...\n", - options.getProgramName().getStr()); + if ( !options.quiet() ) + fprintf( + stdout, "%s: Compiling stdin\n", + options.getProgramName().getStr()); nErrors = compileFile(0); - if (idlc()->getWarningCount() > 0) { + if ( ( idlc()->getWarningCount() > 0 ) && !options.quiet() ) { fprintf( stdout, "%s: detected %lu warnings compiling stdin\n", options.getProgramName().getStr(), @@ -85,16 +86,23 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) idlc()->reset(); } StringVector const & files = options.getInputFiles(); + if ( options.verbose() ) + { + fprintf( stdout, "%s: compiling %i source files ... \n", + options.getProgramName().getStr(), (int)files.size() ); + fflush( stdout ); + } for (StringVector::const_iterator i(files.begin()); i != files.end() && nErrors == 0; ++i) { OString sysFileName( convertToAbsoluteSystemPath(*i) ); - fprintf(stdout, "%s: compile '%s' ... \n", - options.getProgramName().getStr(), (*i).getStr()); + if ( !options.quiet() ) + fprintf(stdout, "Compiling: %s\n", + (*i).getStr()); nErrors = compileFile(&sysFileName); - if ( idlc()->getWarningCount() ) + if ( idlc()->getWarningCount() && !options.quiet() ) fprintf(stdout, "%s: detected %lu warnings compiling file '%s'\n", options.getProgramName().getStr(), sal::static_int_cast< unsigned long >( @@ -128,15 +136,16 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) if ( nErrors > 0 ) { - fprintf(stdout, "%s: detected %ld errors%s", + fprintf(stderr, "%s: detected %ld errors%s", options.getProgramName().getStr(), sal::static_int_cast< long >(nErrors), options.prepareVersion().getStr()); } else { - fprintf(stdout, "%s: returned successful%s", - options.getProgramName().getStr(), - options.prepareVersion().getStr()); + if ( options.verbose() ) + fprintf(stdout, "%s: returned successful%s", + options.getProgramName().getStr(), + options.prepareVersion().getStr()); } return nErrors; } diff --git a/idlc/source/options.cxx b/idlc/source/options.cxx index 6bfbcc9e443e..963ddafda8d0 100644 --- a/idlc/source/options.cxx +++ b/idlc/source/options.cxx @@ -37,7 +37,7 @@ using namespace rtl; -Options::Options(): m_stdin(false) +Options::Options(): m_stdin(false), m_verbose(false), m_quiet(false) { } @@ -190,6 +190,22 @@ sal_Bool Options::initOptions(int ac, char* av[], sal_Bool bCmdFile) } else throw IllegalArgument(OString(av[j]) + ", please check your input"); break; + case 'v': + if ( 0 == strcmp( &av[j][1], "verbose" ) ) + { + m_verbose = true; + } + else + throw IllegalArgument(OString(av[j]) + ", please check your input"); + break; + case 'q': + if ( 0 == strcmp( &av[j][1], "quiet" ) ) + { + m_quiet = true; + } + else + throw IllegalArgument(OString(av[j]) + ", please check your input"); + break; case 'w': if (av[j][2] == 'e' && av[j][3] == '\0') { if (m_options.count("-we") == 0) diff --git a/io/inc/makefile.mk b/io/inc/makefile.mk index 7a15edc58216..ce9aa9036c6a 100644 --- a/io/inc/makefile.mk +++ b/io/inc/makefile.mk @@ -36,16 +36,18 @@ TARGET=inc # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk - +.IF "$(L10N_framework)"=="" # --- Files -------------------------------------------------------- # --- Targets ------------------------------------------------------- +.ENDIF # L10N_framework .INCLUDE : target.mk - +.IF "$(L10N_framework)"=="" .IF "$(ENABLE_PCH)"!="" ALLTAR : \ $(SLO)$/precompiled.pch \ $(SLO)$/precompiled_ex.pch .ENDIF # "$(ENABLE_PCH)"!="" +.ENDIF # L10N_framework diff --git a/io/source/TextInputStream/makefile.mk b/io/source/TextInputStream/makefile.mk index fcca36f0e576..1fb5aa33743a 100644 --- a/io/source/TextInputStream/makefile.mk +++ b/io/source/TextInputStream/makefile.mk @@ -37,6 +37,7 @@ ENABLE_EXCEPTIONS=TRUE # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk +.IF "$(L10N_framework)"=="" DLLPRE = SLOFILES= \ @@ -59,5 +60,6 @@ SHL1RPATH= URELIB DEF1NAME= $(SHL1TARGET) # --- Targets ------------------------------------------------------ +.ENDIF # L10N_framework .INCLUDE : target.mk diff --git a/io/source/TextOutputStream/makefile.mk b/io/source/TextOutputStream/makefile.mk index 5359458ad8b4..7a4c0d6ba37f 100644 --- a/io/source/TextOutputStream/makefile.mk +++ b/io/source/TextOutputStream/makefile.mk @@ -37,6 +37,7 @@ ENABLE_EXCEPTIONS=TRUE # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk +.IF "$(L10N_framework)"=="" DLLPRE = # ------------------------------------------------------------------ @@ -60,5 +61,6 @@ SHL1RPATH= URELIB DEF1NAME= $(SHL1TARGET) # --- Targets ------------------------------------------------------ +.ENDIF # L10N_framework .INCLUDE : target.mk diff --git a/io/source/acceptor/makefile.mk b/io/source/acceptor/makefile.mk index b537b2087078..843f26296dae 100644 --- a/io/source/acceptor/makefile.mk +++ b/io/source/acceptor/makefile.mk @@ -40,6 +40,7 @@ COMPRDB=$(SOLARBINDIR)$/udkapi.rdb # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk +.IF "$(L10N_framework)"=="" DLLPRE = # ------------------------------------------------------------------ @@ -71,4 +72,6 @@ SHL1DEF= $(MISC)$/$(SHL1TARGET).def DEF1NAME= $(SHL1TARGET) # --- Targets ------------------------------------------------------ +.ENDIF # L10N_framework + .INCLUDE : target.mk diff --git a/io/source/connector/makefile.mk b/io/source/connector/makefile.mk index d726ac4c87c7..471f6b9d258f 100644 --- a/io/source/connector/makefile.mk +++ b/io/source/connector/makefile.mk @@ -40,6 +40,7 @@ COMPRDB=$(SOLARBINDIR)$/udkapi.rdb # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk +.IF "$(L10N_framework)"=="" DLLPRE = # ------------------------------------------------------------------ @@ -71,5 +72,6 @@ SHL1DEF= $(MISC)$/$(SHL1TARGET).def DEF1NAME= $(SHL1TARGET) # --- Targets ------------------------------------------------------ +.ENDIF # L10N_framework .INCLUDE : target.mk diff --git a/io/source/stm/makefile.mk b/io/source/stm/makefile.mk index e4b8ad326b1d..43b6f2566ddf 100644 --- a/io/source/stm/makefile.mk +++ b/io/source/stm/makefile.mk @@ -32,6 +32,7 @@ PRJ=..$/.. PRJNAME=io TARGET = streams.uno + ENABLE_EXCEPTIONS=TRUE NO_BSYMBOLIC=TRUE COMP1TYPELIST = stm @@ -39,6 +40,7 @@ COMPRDB=$(SOLARBINDIR)$/udkapi.rdb # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk +.IF "$(L10N_framework)"=="" DLLPRE = # --- Files -------------------------------------------------------- UNOUCRDEP=$(SOLARBINDIR)$/udkapi.rdb @@ -73,5 +75,7 @@ DEF1NAME= $(SHL1TARGET) # --- Targets ------------------------------------------------------ +.ENDIF # L10N_framework + .INCLUDE : target.mk diff --git a/io/source/stm/omark.cxx b/io/source/stm/omark.cxx index 69ccf08fce6a..29d326170ff1 100644 --- a/io/source/stm/omark.cxx +++ b/io/source/stm/omark.cxx @@ -49,12 +49,6 @@ #include <osl/mutex.hxx> #include <rtl/ustrbuf.hxx> -#if OSL_DEBUG_LEVEL == 0 -# ifndef NDEBUG -# define NDEBUG -# endif -#endif -#include <assert.h> #include <string.h> @@ -632,7 +626,7 @@ sal_Int32 OMarkableInputStream::readBytes(Sequence< sal_Int8 >& aData, sal_Int32 sal_Int32 nToRead = nBytesToRead - ( m_pBuffer->getSize() - m_nCurrentPos ); nRead = m_input->readBytes( aData , nToRead ); - assert( aData.getLength() == nRead ); + OSL_ASSERT( aData.getLength() == nRead ); try { @@ -650,7 +644,7 @@ sal_Int32 OMarkableInputStream::readBytes(Sequence< sal_Int8 >& aData, sal_Int32 } } - assert( m_pBuffer->getSize() - m_nCurrentPos >= nBytesToRead ); + OSL_ASSERT( m_pBuffer->getSize() - m_nCurrentPos >= nBytesToRead ); m_pBuffer->readAt( m_nCurrentPos , aData , nBytesToRead ); diff --git a/io/test/makefile.mk b/io/test/makefile.mk index af032ba8efb1..b7acf670684f 100644 --- a/io/test/makefile.mk +++ b/io/test/makefile.mk @@ -41,6 +41,7 @@ ENABLE_EXCEPTIONS=TRUE # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk +.IF "$(L10N_framework)"=="" # --- Files -------------------------------------------------------- OBJFILES= $(OBJ)$/testcomponent.obj \ @@ -90,5 +91,6 @@ $(BIN)$/applicat.rdb: $(SOLARBINDIR)$/udkapi.rdb rm -f $@ regmerge $@ / $? +.ENDIF # L10N_framework .INCLUDE : target.mk diff --git a/io/test/stm/datatest.cxx b/io/test/stm/datatest.cxx index 3de10d5fe63e..b7515b3c5417 100644 --- a/io/test/stm/datatest.cxx +++ b/io/test/stm/datatest.cxx @@ -55,10 +55,6 @@ #include <osl/conditn.hxx> #include <osl/mutex.hxx> -#if OSL_DEBUG_LEVEL == 0 -#define NDEBUG -#endif -#include <assert.h> #include <string.h> using namespace ::rtl; @@ -209,13 +205,13 @@ sal_Int32 ODataStreamTest::test( rSource = Reference< XActiveDataSource > ( x, UNO_QUERY ); } - assert( rPipeInput.is() ); - assert( rPipeOutput.is() ); + OSL_ASSERT( rPipeInput.is() ); + OSL_ASSERT( rPipeOutput.is() ); rSink->setInputStream( rPipeInput ); rSource->setOutputStream( rPipeOutput ); - assert( rSink->getInputStream().is() ); - assert( rSource->getOutputStream().is() ); + OSL_ASSERT( rSink->getInputStream().is() ); + OSL_ASSERT( rSource->getOutputStream().is() ); if( 1 == hTestHandle ) { testSimple( rInput , rOutput ); @@ -778,10 +774,10 @@ sal_Int32 OObjectStreamTest::test( const OUString& TestName, Reference <XOutputStream > markableOutput( x , UNO_QUERY ); Reference <XActiveDataSource > markableSource( x , UNO_QUERY ); - assert( markableInput.is() ); - assert( markableOutput.is() ); - assert( markableSink.is() ); - assert( markableSource.is() ); + OSL_ASSERT( markableInput.is() ); + OSL_ASSERT( markableOutput.is() ); + OSL_ASSERT( markableSink.is() ); + OSL_ASSERT( markableSource.is() ); markableSink->setInputStream( rPipeInput ); markableSource->setOutputStream( rPipeOutput ); @@ -799,14 +795,14 @@ sal_Int32 OObjectStreamTest::test( const OUString& TestName, rSource = Reference <XActiveDataSource>( x, UNO_QUERY ); } - assert( rPipeInput.is() ); - assert( rPipeOutput.is() ); + OSL_ASSERT( rPipeInput.is() ); + OSL_ASSERT( rPipeOutput.is() ); rSink->setInputStream( markableInput ); rSource->setOutputStream( markableOutput ); - assert( rSink->getInputStream().is() ); - assert( rSource->getOutputStream().is() ); + OSL_ASSERT( rSink->getInputStream().is() ); + OSL_ASSERT( rSource->getOutputStream().is() ); if( 1 + DATASTREAM_TEST_MAX_HANDLE == hTestHandle ) { testObject( rOutput , rInput); diff --git a/io/test/stm/makefile.mk b/io/test/stm/makefile.mk index cb5f6b0c803a..01d334edb998 100644 --- a/io/test/stm/makefile.mk +++ b/io/test/stm/makefile.mk @@ -37,6 +37,7 @@ ENABLE_EXCEPTIONS=TRUE # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk +.IF "$(L10N_framework)"=="" # --- Files -------------------------------------------------------- UNOUCRDEP=$(SOLARBINDIR)$/udkapi.rdb UNOUCRRDB=$(SOLARBINDIR)$/udkapi.rdb @@ -97,5 +98,6 @@ DEF1EXPORTFILE= exports.dxp # --- Targets ------------------------------------------------------ +.ENDIF # L10N_framework .INCLUDE : target.mk diff --git a/io/test/stm/marktest.cxx b/io/test/stm/marktest.cxx index 88d52a09c891..20e4015ffa1f 100644 --- a/io/test/stm/marktest.cxx +++ b/io/test/stm/marktest.cxx @@ -46,12 +46,6 @@ #include <osl/conditn.hxx> #include <osl/mutex.hxx> -#if OSL_DEBUG_LEVEL == 0 -#define NDEBUG -#endif -#include <assert.h> -#include <string.h> - using namespace ::rtl; using namespace ::osl; using namespace ::cppu; @@ -159,8 +153,8 @@ sal_Int32 OMarkableOutputStreamTest::test( Reference< XOutputStream > rOutput( TestObject , UNO_QUERY ); - assert( rPipeInput.is() ); - assert( rOutput.is() ); + OSL_ASSERT( rPipeInput.is() ); + OSL_ASSERT( rOutput.is() ); if( 1 == hTestHandle ) { // checks usual streaming testSimple( rOutput , rPipeInput ); @@ -526,8 +520,8 @@ sal_Int32 OMarkableInputStreamTest::test( Reference < XInputStream > rInput( TestObject , UNO_QUERY ); - assert( rPipeOutput.is() ); - assert( rInput.is() ); + OSL_ASSERT( rPipeOutput.is() ); + OSL_ASSERT( rInput.is() ); if( 1 == hTestHandle ) { // checks usual streaming testSimple( rPipeOutput , rInput ); diff --git a/javaunohelper/com/sun/star/comp/helper/Bootstrap.java b/javaunohelper/com/sun/star/comp/helper/Bootstrap.java index c5037b2f1566..d80b8a6b9df0 100644 --- a/javaunohelper/com/sun/star/comp/helper/Bootstrap.java +++ b/javaunohelper/com/sun/star/comp/helper/Bootstrap.java @@ -67,7 +67,7 @@ import java.util.Random; Other services can be inserted into the service manager by using its XSet interface: <pre> - XSet xSet = (XSet)UnoRuntime.queryInterface( XSet.class, aMultiComponentFactory ); + XSet xSet = UnoRuntime.queryInterface( XSet.class, aMultiComponentFactory ); // insert the service manager xSet.insert( aSingleComponentFactory ); </pre> @@ -108,20 +108,20 @@ public class Bootstrap { static public XComponentContext createInitialComponentContext( Hashtable context_entries ) throws Exception { - XImplementationLoader xImpLoader = (XImplementationLoader)UnoRuntime.queryInterface( + XImplementationLoader xImpLoader = UnoRuntime.queryInterface( XImplementationLoader.class, new JavaLoader() ); // Get the factory of the ServiceManager - XSingleComponentFactory smgr_fac = (XSingleComponentFactory)UnoRuntime.queryInterface( + XSingleComponentFactory smgr_fac = UnoRuntime.queryInterface( XSingleComponentFactory.class, xImpLoader.activate( "com.sun.star.comp.servicemanager.ServiceManager", null, null, null ) ); // Create an instance of the ServiceManager - XMultiComponentFactory xSMgr = (XMultiComponentFactory)UnoRuntime.queryInterface( + XMultiComponentFactory xSMgr = UnoRuntime.queryInterface( XMultiComponentFactory.class, smgr_fac.createInstanceWithContext( null ) ); // post init loader - XInitialization xInit = (XInitialization)UnoRuntime.queryInterface( + XInitialization xInit = UnoRuntime.queryInterface( XInitialization.class, xImpLoader ); Object[] args = new Object [] { xSMgr }; xInit.initialize( args ); @@ -137,12 +137,12 @@ public class Bootstrap { XComponentContext xContext = new ComponentContext( context_entries, null ); // post init smgr - xInit = (XInitialization)UnoRuntime.queryInterface( + xInit = UnoRuntime.queryInterface( XInitialization.class, xSMgr ); args = new Object [] { null, xContext }; // no registry, default context xInit.initialize( args ); - XSet xSet = (XSet)UnoRuntime.queryInterface( XSet.class, xSMgr ); + XSet xSet = UnoRuntime.queryInterface( XSet.class, xSMgr ); // insert the service manager xSet.insert( smgr_fac ); // and basic jurt factories @@ -159,7 +159,7 @@ public class Bootstrap { */ static public XMultiServiceFactory createSimpleServiceManager() throws Exception { - return (XMultiServiceFactory)UnoRuntime.queryInterface( + return UnoRuntime.queryInterface( XMultiServiceFactory.class, createInitialComponentContext( null ).getServiceManager() ); } @@ -206,7 +206,7 @@ public class Bootstrap { NativeLibraryLoader.loadLibrary( Bootstrap.class.getClassLoader(), "juh" ); m_loaded_juh = true; } - return (XComponentContext)UnoRuntime.queryInterface( + return UnoRuntime.queryInterface( XComponentContext.class, cppuhelper_bootstrap( ini_file, pairs, Bootstrap.class.getClassLoader() ) ); @@ -283,7 +283,7 @@ public class Bootstrap { try { // try to connect to office Object context = xUrlResolver.resolve( sConnect ); - xContext = (XComponentContext) UnoRuntime.queryInterface( + xContext = UnoRuntime.queryInterface( XComponentContext.class, context); if ( xContext == null ) throw new BootstrapException( "no component context!" ); diff --git a/javaunohelper/com/sun/star/comp/helper/ComponentContext.java b/javaunohelper/com/sun/star/comp/helper/ComponentContext.java index 938cc0543901..1c3df0d4844b 100644 --- a/javaunohelper/com/sun/star/comp/helper/ComponentContext.java +++ b/javaunohelper/com/sun/star/comp/helper/ComponentContext.java @@ -101,7 +101,7 @@ public class ComponentContext implements XComponentContext, XComponent { o = ((ComponentContextEntry)o).m_value; } - m_xSMgr = (XMultiComponentFactory)UnoRuntime.queryInterface( + m_xSMgr = UnoRuntime.queryInterface( XMultiComponentFactory.class, o ); } if (m_xSMgr != null) @@ -114,7 +114,7 @@ public class ComponentContext implements XComponentContext, XComponent } // listen for delegate - XComponent xComp = (XComponent)UnoRuntime.queryInterface( + XComponent xComp = UnoRuntime.queryInterface( XComponent.class, m_xDelegate ); if (xComp != null) { @@ -154,7 +154,7 @@ public class ComponentContext implements XComponentContext, XComponent else { XSingleComponentFactory xCompFac = - (XSingleComponentFactory)UnoRuntime.queryInterface( + UnoRuntime.queryInterface( XSingleComponentFactory.class, entry.m_lateInit ); if (xCompFac != null) { @@ -185,7 +185,7 @@ public class ComponentContext implements XComponentContext, XComponent else // inited in the meantime { // dispose fresh service instance - XComponent xComp = (XComponent)UnoRuntime.queryInterface( + XComponent xComp = UnoRuntime.queryInterface( XComponent.class, xInstance ); if (xComp != null) { @@ -253,7 +253,7 @@ public class ComponentContext implements XComponentContext, XComponent o = ((ComponentContextEntry)o).m_value; } - XComponent xComp = (XComponent)UnoRuntime.queryInterface( XComponent.class, o ); + XComponent xComp = UnoRuntime.queryInterface( XComponent.class, o ); if (xComp != null) { if (name.equals( TDMGR_NAME )) @@ -272,7 +272,7 @@ public class ComponentContext implements XComponentContext, XComponent // smgr if (m_bDisposeSMgr) { - XComponent xComp = (XComponent)UnoRuntime.queryInterface( + XComponent xComp = UnoRuntime.queryInterface( XComponent.class, m_xSMgr ); if (xComp != null) { diff --git a/javaunohelper/com/sun/star/comp/helper/RegistryServiceFactory.java b/javaunohelper/com/sun/star/comp/helper/RegistryServiceFactory.java index 4b5db3753da3..9523fbba7716 100644 --- a/javaunohelper/com/sun/star/comp/helper/RegistryServiceFactory.java +++ b/javaunohelper/com/sun/star/comp/helper/RegistryServiceFactory.java @@ -124,7 +124,7 @@ public class RegistryServiceFactory { Object obj = createRegistryServiceFactory( writeRegistryFile, readRegistryFile, readOnly, RegistryServiceFactory.class.getClassLoader() ); - return (XMultiServiceFactory) UnoRuntime.queryInterface( + return UnoRuntime.queryInterface( XMultiServiceFactory.class, obj ); } diff --git a/javaunohelper/com/sun/star/comp/helper/SharedLibraryLoader.java b/javaunohelper/com/sun/star/comp/helper/SharedLibraryLoader.java index eda51f8cb1f7..a1bf4d3a168c 100644 --- a/javaunohelper/com/sun/star/comp/helper/SharedLibraryLoader.java +++ b/javaunohelper/com/sun/star/comp/helper/SharedLibraryLoader.java @@ -85,7 +85,7 @@ public class SharedLibraryLoader { XMultiServiceFactory smgr, XRegistryKey regKey ) { - return (XSingleServiceFactory) UnoRuntime.queryInterface( + return UnoRuntime.queryInterface( XSingleServiceFactory.class, component_getFactory( DEFAULT_LIBRARY, DEFAULT_IMPLEMENTATION, smgr, regKey, @@ -110,7 +110,7 @@ public class SharedLibraryLoader { XMultiServiceFactory smgr, XRegistryKey regKey ) { - return (XSingleServiceFactory) UnoRuntime.queryInterface( + return UnoRuntime.queryInterface( XSingleServiceFactory.class, component_getFactory( libName, impName, smgr, regKey, diff --git a/javaunohelper/com/sun/star/comp/juhtest/SmoketestCommandEnvironment.java b/javaunohelper/com/sun/star/comp/juhtest/SmoketestCommandEnvironment.java index cafa7e0a412d..a508a209ad2c 100644 --- a/javaunohelper/com/sun/star/comp/juhtest/SmoketestCommandEnvironment.java +++ b/javaunohelper/com/sun/star/comp/juhtest/SmoketestCommandEnvironment.java @@ -119,7 +119,6 @@ class InteractionImpl implements com.sun.star.task.XInteractionHandler if (approve) { com.sun.star.task.XInteractionApprove xApprove = - (com.sun.star.task.XInteractionApprove) UnoRuntime.queryInterface(com.sun.star.task.XInteractionApprove.class, conts[i]); if (xApprove != null) xApprove.select(); @@ -129,7 +128,6 @@ class InteractionImpl implements com.sun.star.task.XInteractionHandler else if (abort) { com.sun.star.task.XInteractionAbort xAbort = - (com.sun.star.task.XInteractionAbort) UnoRuntime.queryInterface(com.sun.star.task.XInteractionAbort.class, conts[i]); if (xAbort != null) xAbort.select(); diff --git a/javaunohelper/com/sun/star/lib/uno/helper/Factory.java b/javaunohelper/com/sun/star/lib/uno/helper/Factory.java index 6eb261ff0eb8..5842c8eaf7f4 100644 --- a/javaunohelper/com/sun/star/lib/uno/helper/Factory.java +++ b/javaunohelper/com/sun/star/lib/uno/helper/Factory.java @@ -210,7 +210,7 @@ public class Factory throws com.sun.star.uno.Exception { Object inst = instantiate( xContext ); - XInitialization xInit = (XInitialization)UnoRuntime.queryInterface( + XInitialization xInit = UnoRuntime.queryInterface( XInitialization.class, inst ); if (null == xInit) { diff --git a/javaunohelper/com/sun/star/lib/uno/helper/InterfaceContainer.java b/javaunohelper/com/sun/star/lib/uno/helper/InterfaceContainer.java index 44a6be5e5f7a..d7bc61cbcbad 100644 --- a/javaunohelper/com/sun/star/lib/uno/helper/InterfaceContainer.java +++ b/javaunohelper/com/sun/star/lib/uno/helper/InterfaceContainer.java @@ -715,7 +715,7 @@ public class InterfaceContainer implements Cloneable try { Object o= aIt.next(); - XEventListener evtListener= (XEventListener) UnoRuntime.queryInterface( + XEventListener evtListener= UnoRuntime.queryInterface( XEventListener.class, o); if( evtListener != null ) evtListener.disposing( evt ); diff --git a/javaunohelper/com/sun/star/lib/uno/helper/PropertySet.java b/javaunohelper/com/sun/star/lib/uno/helper/PropertySet.java index b4b2d02ab148..d77c1600def3 100644 --- a/javaunohelper/com/sun/star/lib/uno/helper/PropertySet.java +++ b/javaunohelper/com/sun/star/lib/uno/helper/PropertySet.java @@ -671,7 +671,7 @@ XMultiPropertySet // We try to get an XInterface of setVal and set an XInterface type. if (setVal instanceof XInterface) { - XInterface xint= (XInterface) UnoRuntime.queryInterface(XInterface.class, setVal); + XInterface xint= UnoRuntime.queryInterface(XInterface.class, setVal); if (xint != null) convObj= new Any(new Type(XInterface.class), xint); } diff --git a/javaunohelper/com/sun/star/lib/uno/helper/PropertySetMixin.java b/javaunohelper/com/sun/star/lib/uno/helper/PropertySetMixin.java index af33c5ea3ee9..40c69a90f8a6 100644 --- a/javaunohelper/com/sun/star/lib/uno/helper/PropertySetMixin.java +++ b/javaunohelper/com/sun/star/lib/uno/helper/PropertySetMixin.java @@ -143,13 +143,13 @@ public final class PropertySetMixin { idlClass = getReflection(type.getTypeName()); XTypeDescription ifc; try { - ifc = (XTypeDescription) UnoRuntime.queryInterface( + ifc = UnoRuntime.queryInterface( XTypeDescription.class, - (((XHierarchicalNameAccess) UnoRuntime.queryInterface( - XHierarchicalNameAccess.class, - context.getValueByName( - "/singletons/com.sun.star.reflection." - + "theTypeDescriptionManager"))). + (UnoRuntime.queryInterface( + XHierarchicalNameAccess.class, + context.getValueByName( + "/singletons/com.sun.star.reflection." + + "theTypeDescriptionManager")). getByHierarchicalName(type.getTypeName()))); } catch (NoSuchElementException e) { throw new RuntimeException( @@ -585,7 +585,7 @@ public final class PropertySetMixin { private XIdlClass getReflection(String typeName) { XIdlReflection refl; try { - refl = (XIdlReflection) UnoRuntime.queryInterface( + refl = UnoRuntime.queryInterface( XIdlReflection.class, context.getServiceManager().createInstanceWithContext( "com.sun.star.reflection.CoreReflection", context)); @@ -599,8 +599,7 @@ public final class PropertySetMixin { try { return refl.forName(typeName); } finally { - XComponent comp = (XComponent) UnoRuntime.queryInterface( - XComponent.class, refl); + XComponent comp = UnoRuntime.queryInterface(XComponent.class, refl); if (comp != null) { comp.dispose(); } @@ -610,9 +609,8 @@ public final class PropertySetMixin { private void initProperties( XTypeDescription type, HashMap map, ArrayList handleNames, HashSet seen) { - XInterfaceTypeDescription2 ifc = (XInterfaceTypeDescription2) - UnoRuntime.queryInterface( - XInterfaceTypeDescription2.class, resolveTypedefs(type)); + XInterfaceTypeDescription2 ifc = UnoRuntime.queryInterface( + XInterfaceTypeDescription2.class, resolveTypedefs(type)); if (seen.add(ifc.getName())) { XTypeDescription[] bases = ifc.getBaseTypes(); for (int i = 0; i < bases.length; ++i) { @@ -622,11 +620,10 @@ public final class PropertySetMixin { for (int i = 0; i < members.length; ++i) { if (members[i].getTypeClass() == TypeClass.INTERFACE_ATTRIBUTE) { - XInterfaceAttributeTypeDescription2 attr - = ((XInterfaceAttributeTypeDescription2) - UnoRuntime.queryInterface( - XInterfaceAttributeTypeDescription2.class, - members[i])); + XInterfaceAttributeTypeDescription2 attr = + UnoRuntime.queryInterface( + XInterfaceAttributeTypeDescription2.class, + members[i]); short attrAttribs = 0; if (attr.isBound()) { attrAttribs |= PropertyAttribute.BOUND; @@ -685,7 +682,7 @@ public final class PropertySetMixin { break; } attrAttribs |= n; - t = ((XStructTypeDescription) UnoRuntime.queryInterface( + t = (UnoRuntime.queryInterface( XStructTypeDescription.class, t)). getTypeArguments()[0]; } @@ -747,14 +744,14 @@ public final class PropertySetMixin { object, illegalArgumentPosition); } - XIdlField2 f = (XIdlField2) UnoRuntime.queryInterface( + XIdlField2 f = UnoRuntime.queryInterface( XIdlField2.class, idlClass.getField(name)); Object[] o = new Object[] { new Any(type, UnoRuntime.queryInterface(type, object)) }; Object v = wrapValue( value, - ((XIdlField2) UnoRuntime.queryInterface( - XIdlField2.class, idlClass.getField(name))).getType(), + UnoRuntime.queryInterface( + XIdlField2.class, idlClass.getField(name)).getType(), (p.property.Attributes & PropertyAttribute.MAYBEAMBIGUOUS) != 0, isAmbiguous, (p.property.Attributes & PropertyAttribute.MAYBEDEFAULT) != 0, @@ -807,7 +804,7 @@ public final class PropertySetMixin { if (p == null) { throw new UnknownPropertyException(name, object); } - XIdlField2 field = (XIdlField2) UnoRuntime.queryInterface( + XIdlField2 field = UnoRuntime.queryInterface( XIdlField2.class, idlClass.getField(name)); Object value; try { @@ -848,12 +845,12 @@ public final class PropertySetMixin { XIdlClass ambiguous = getReflection(typeName); try { isAmbiguous = AnyConverter.toBoolean( - ((XIdlField2) UnoRuntime.queryInterface( + UnoRuntime.queryInterface( XIdlField2.class, - ambiguous.getField("IsAmbiguous"))).get(value)); - value = ((XIdlField2) UnoRuntime.queryInterface( - XIdlField2.class, - ambiguous.getField("Value"))).get(value); + ambiguous.getField("IsAmbiguous")).get(value)); + value = UnoRuntime.queryInterface( + XIdlField2.class, + ambiguous.getField("Value")).get(value); } catch (com.sun.star.lang.IllegalArgumentException e) { throw new RuntimeException( "unexpected" @@ -867,12 +864,12 @@ public final class PropertySetMixin { XIdlClass defaulted = getReflection(typeName); try { isDefaulted = AnyConverter.toBoolean( - ((XIdlField2) UnoRuntime.queryInterface( + UnoRuntime.queryInterface( XIdlField2.class, - defaulted.getField("IsDefaulted"))).get(value)); - value = ((XIdlField2) UnoRuntime.queryInterface( - XIdlField2.class, - defaulted.getField("Value"))).get(value); + defaulted.getField("IsDefaulted")).get(value)); + value = UnoRuntime.queryInterface( + XIdlField2.class, + defaulted.getField("Value")).get(value); } catch (com.sun.star.lang.IllegalArgumentException e) { throw new RuntimeException( "unexpected" @@ -886,16 +883,16 @@ public final class PropertySetMixin { XIdlClass optional = getReflection(typeName); try { boolean present = AnyConverter.toBoolean( - ((XIdlField2) UnoRuntime.queryInterface( + UnoRuntime.queryInterface( XIdlField2.class, - optional.getField("IsPresent"))).get(value)); + optional.getField("IsPresent")).get(value)); if (!present) { value = Any.VOID; break; } - value = ((XIdlField2) UnoRuntime.queryInterface( - XIdlField2.class, - optional.getField("Value"))).get(value); + value = UnoRuntime.queryInterface( + XIdlField2.class, + optional.getField("Value")).get(value); } catch (com.sun.star.lang.IllegalArgumentException e) { throw new RuntimeException( "unexpected" @@ -932,15 +929,15 @@ public final class PropertySetMixin { Object[] strct = new Object[1]; type.createObject(strct); try { - XIdlField2 field = (XIdlField2) UnoRuntime.queryInterface( + XIdlField2 field = UnoRuntime.queryInterface( XIdlField2.class, type.getField("Value")); field.set( strct, wrapValue( value, field.getType(), false, false, wrapDefaulted, isDefaulted, wrapOptional)); - ((XIdlField2) UnoRuntime.queryInterface( - XIdlField2.class, type.getField("IsAmbiguous"))).set( + UnoRuntime.queryInterface( + XIdlField2.class, type.getField("IsAmbiguous")).set( strct, new Boolean(isAmbiguous)); } catch (com.sun.star.lang.IllegalArgumentException e) { throw new RuntimeException( @@ -959,15 +956,15 @@ public final class PropertySetMixin { Object[] strct = new Object[1]; type.createObject(strct); try { - XIdlField2 field = (XIdlField2) UnoRuntime.queryInterface( + XIdlField2 field = UnoRuntime.queryInterface( XIdlField2.class, type.getField("Value")); field.set( strct, wrapValue( value, field.getType(), wrapAmbiguous, isAmbiguous, false, false, wrapOptional)); - ((XIdlField2) UnoRuntime.queryInterface( - XIdlField2.class, type.getField("IsDefaulted"))).set( + UnoRuntime.queryInterface( + XIdlField2.class, type.getField("IsDefaulted")).set( strct, new Boolean(isDefaulted)); } catch (com.sun.star.lang.IllegalArgumentException e) { throw new RuntimeException( @@ -986,11 +983,11 @@ public final class PropertySetMixin { type.createObject(strct); boolean present = !AnyConverter.isVoid(value); try { - ((XIdlField2) UnoRuntime.queryInterface( - XIdlField2.class, type.getField("IsPresent"))).set( + UnoRuntime.queryInterface( + XIdlField2.class, type.getField("IsPresent")).set( strct, new Boolean(present)); if (present) { - XIdlField2 field = (XIdlField2) UnoRuntime.queryInterface( + XIdlField2 field = UnoRuntime.queryInterface( XIdlField2.class, type.getField("Value")); field.set( strct, @@ -1018,9 +1015,8 @@ public final class PropertySetMixin { private static XTypeDescription resolveTypedefs(XTypeDescription type) { while (type.getTypeClass() == TypeClass.TYPEDEF) { - type = ((XIndirectTypeDescription) UnoRuntime.queryInterface( - XIndirectTypeDescription.class, type)). - getReferencedType(); + type = UnoRuntime.queryInterface( + XIndirectTypeDescription.class, type).getReferencedType(); } return type; } diff --git a/javaunohelper/test/com/sun/star/comp/helper/Bootstrap_Test.java b/javaunohelper/test/com/sun/star/comp/helper/Bootstrap_Test.java index 9c330539e620..b94b85771d8d 100644 --- a/javaunohelper/test/com/sun/star/comp/helper/Bootstrap_Test.java +++ b/javaunohelper/test/com/sun/star/comp/helper/Bootstrap_Test.java @@ -62,7 +62,7 @@ public class Bootstrap_Test { "no /singletons/com.sun.star.reflection.theTypeDescriptionManager!" ); } - XMultiServiceFactory msf = (XMultiServiceFactory)UnoRuntime.queryInterface( + XMultiServiceFactory msf = UnoRuntime.queryInterface( XMultiServiceFactory.class, xContext.getServiceManager() ); String services[] = msf.getAvailableServiceNames(); System.out.println("Available services are:"); @@ -74,7 +74,7 @@ public class Bootstrap_Test { for ( int i=0; i<services.length; i++ ) System.out.println(services[i]); - XComponent xComp = (XComponent)UnoRuntime.queryInterface( + XComponent xComp = UnoRuntime.queryInterface( XComponent.class, xContext ); xComp.dispose(); diff --git a/javaunohelper/test/com/sun/star/comp/helper/ComponentContext_Test.java b/javaunohelper/test/com/sun/star/comp/helper/ComponentContext_Test.java index 1188f8752135..f88864f2d3ba 100644 --- a/javaunohelper/test/com/sun/star/comp/helper/ComponentContext_Test.java +++ b/javaunohelper/test/com/sun/star/comp/helper/ComponentContext_Test.java @@ -88,7 +88,7 @@ public class ComponentContext_Test { System.err.println( "### bootstrap context test failed: 2!" ); } - XComponent xComp = (XComponent)UnoRuntime.queryInterface( + XComponent xComp = UnoRuntime.queryInterface( XComponent.class, xInitialContext ); xComp.dispose(); } diff --git a/javaunohelper/test/com/sun/star/comp/helper/SharedLibraryLoader_Test.java b/javaunohelper/test/com/sun/star/comp/helper/SharedLibraryLoader_Test.java index d12e1accf797..fc4c2c06f463 100644 --- a/javaunohelper/test/com/sun/star/comp/helper/SharedLibraryLoader_Test.java +++ b/javaunohelper/test/com/sun/star/comp/helper/SharedLibraryLoader_Test.java @@ -91,7 +91,7 @@ public class SharedLibraryLoader_Test { if ( ! test_getSharedLibraryLoaderFactory() ) return false; - sharedLibraryLoader = (XImplementationLoader) UnoRuntime.queryInterface( + sharedLibraryLoader = UnoRuntime.queryInterface( XImplementationLoader.class, sharedLibraryLoaderFactory.createInstance() ); System.out.print("Test - "); @@ -115,11 +115,11 @@ public class SharedLibraryLoader_Test { System.err.println("- get the native ServiceManger factory"); XSingleServiceFactory aSMgrFac = - (XSingleServiceFactory) UnoRuntime.queryInterface( XSingleServiceFactory.class, + UnoRuntime.queryInterface( XSingleServiceFactory.class, sharedLibraryLoader.activate(NATIVE_SERVICE_MANAGER_IMP_NAME, null, NATIVE_SERVICE_MANAGER_LIB_NAME, null)); System.err.println("- instantiate the native ServiceManger"); - nativeServiceManager = (XMultiServiceFactory) UnoRuntime.queryInterface( XMultiServiceFactory.class, aSMgrFac.createInstance() ); + nativeServiceManager = UnoRuntime.queryInterface( XMultiServiceFactory.class, aSMgrFac.createInstance() ); System.out.print("Test - "); System.out.println(nativeServiceManager == null? "failed" : "successfull"); @@ -141,12 +141,12 @@ public class SharedLibraryLoader_Test { System.err.println("- get factory of the Registry"); XSingleServiceFactory aRegFac = - (XSingleServiceFactory) UnoRuntime.queryInterface( XSingleServiceFactory.class, + UnoRuntime.queryInterface( XSingleServiceFactory.class, sharedLibraryLoader.activate(NATIVE_REGISTRY_IMP_NAME, null, NATIVE_REGISTRY_LIB_NAME, null) ); System.err.println("- instantiate the Registry"); simpleRegistry = - (XSimpleRegistry) UnoRuntime.queryInterface( XSimpleRegistry.class, aRegFac.createInstance() ); + UnoRuntime.queryInterface( XSimpleRegistry.class, aRegFac.createInstance() ); System.out.print("Test - "); System.out.println(simpleRegistry == null? "failed" : "successfull"); System.out.println("*******************************************************************"); diff --git a/javaunohelper/test/com/sun/star/lib/uno/helper/ComponentBase_Test.java b/javaunohelper/test/com/sun/star/lib/uno/helper/ComponentBase_Test.java index 1629920ad481..46e7f60b7def 100644 --- a/javaunohelper/test/com/sun/star/lib/uno/helper/ComponentBase_Test.java +++ b/javaunohelper/test/com/sun/star/lib/uno/helper/ComponentBase_Test.java @@ -67,9 +67,9 @@ public class ComponentBase_Test comp.addEventListener(obj1); comp.addEventListener(obj2); comp.addEventListener(obj3); - comp.addEventListener((XEventListener) UnoRuntime.queryInterface(XEventListener.class, proxyObj1Weak1)); - comp.addEventListener((XEventListener) UnoRuntime.queryInterface(XEventListener.class, proxyObj3Weak2)); - comp.addEventListener((XEventListener) UnoRuntime.queryInterface(XEventListener.class, proxyObj3TypeProv)); + comp.addEventListener(UnoRuntime.queryInterface(XEventListener.class, proxyObj1Weak1)); + comp.addEventListener(UnoRuntime.queryInterface(XEventListener.class, proxyObj3Weak2)); + comp.addEventListener(UnoRuntime.queryInterface(XEventListener.class, proxyObj3TypeProv)); obj1.nDisposingCalled = 0; obj2.nDisposingCalled = 0; obj3.nDisposingCalled = 0; diff --git a/javaunohelper/test/com/sun/star/lib/uno/helper/Factory_Test.java b/javaunohelper/test/com/sun/star/lib/uno/helper/Factory_Test.java index 2732fa54331a..732db947b97a 100644 --- a/javaunohelper/test/com/sun/star/lib/uno/helper/Factory_Test.java +++ b/javaunohelper/test/com/sun/star/lib/uno/helper/Factory_Test.java @@ -120,7 +120,7 @@ public class Factory_Test //============================================================================================== static void service_info_test( Object inst ) { - XServiceInfo xInfo = (XServiceInfo)UnoRuntime.queryInterface( XServiceInfo.class, inst ); + XServiceInfo xInfo = UnoRuntime.queryInterface( XServiceInfo.class, inst ); if (! xInfo.getImplementationName().equals( m_impl_name )) { @@ -159,7 +159,7 @@ public class Factory_Test // bootstrap service manager XMultiServiceFactory xMgr = RegistryServiceFactory.create( rdb ); - XPropertySet xProps = (XPropertySet)UnoRuntime.queryInterface( + XPropertySet xProps = UnoRuntime.queryInterface( XPropertySet.class, xMgr ); XComponentContext xContext = (XComponentContext)AnyConverter.toObject( new Type( XComponentContext.class ), xProps.getPropertyValue( "DefaultContext" ) ); @@ -172,7 +172,7 @@ public class Factory_Test new Type( XSimpleRegistry.class ), xProps.getPropertyValue( "Registry" ) ); // register impl XImplementationRegistration xImpReg = - (XImplementationRegistration)UnoRuntime.queryInterface( + UnoRuntime.queryInterface( XImplementationRegistration.class, xContext.getServiceManager().createInstanceWithContext( "com.sun.star.registry.ImplementationRegistration", xContext ) ); @@ -196,7 +196,7 @@ public class Factory_Test m_supported_services[ nPos ], xContext ) ); } - XComponent xComp = (XComponent)UnoRuntime.queryInterface( XComponent.class, xContext ); + XComponent xComp = UnoRuntime.queryInterface( XComponent.class, xContext ); xComp.dispose(); } catch (Exception exc) diff --git a/jurt/com/sun/star/comp/bridgefactory/BridgeFactory.java b/jurt/com/sun/star/comp/bridgefactory/BridgeFactory.java index 819ef024acfa..6dd90b3dd590 100644 --- a/jurt/com/sun/star/comp/bridgefactory/BridgeFactory.java +++ b/jurt/com/sun/star/comp/bridgefactory/BridgeFactory.java @@ -134,7 +134,7 @@ public class BridgeFactory implements XBridgeFactory/*, XEventListener*/ { if (hasName) { IBridge iBridges[] = UnoRuntime.getBridges(); for(int i = 0; i < iBridges.length; ++ i) { - XBridge xBridge = (XBridge)UnoRuntime.queryInterface(XBridge.class, iBridges[i]); + XBridge xBridge = UnoRuntime.queryInterface(XBridge.class, iBridges[i]); if(xBridge != null) { if(xBridge.getName().equals(sName)) @@ -148,7 +148,7 @@ public class BridgeFactory implements XBridgeFactory/*, XEventListener*/ { try { IBridge iBridge = UnoRuntime.getBridgeByName("java", context, "remote", context, hasName ? new Object[]{sProtocol, aConnection, anInstanceProvider, sName} : new Object[]{sProtocol, aConnection, anInstanceProvider}); - xBridge = (XBridge)UnoRuntime.queryInterface(XBridge.class, iBridge); + xBridge = UnoRuntime.queryInterface(XBridge.class, iBridge); } catch(Exception exception) { throw new com.sun.star.lang.IllegalArgumentException(exception.getMessage()); @@ -171,7 +171,7 @@ public class BridgeFactory implements XBridgeFactory/*, XEventListener*/ { IBridge iBridges[] = UnoRuntime.getBridges(); for(int i = 0; i < iBridges.length; ++ i) { - xBridge = (XBridge)UnoRuntime.queryInterface(XBridge.class, iBridges[i]); + xBridge = UnoRuntime.queryInterface(XBridge.class, iBridges[i]); if(xBridge != null) { if(xBridge.getName().equals(sName)) @@ -199,7 +199,7 @@ public class BridgeFactory implements XBridgeFactory/*, XEventListener*/ { IBridge iBridges[] = UnoRuntime.getBridges(); for(int i = 0; i < iBridges.length; ++ i) { - XBridge xBridge = (XBridge)UnoRuntime.queryInterface(XBridge.class, iBridges[i]); + XBridge xBridge = UnoRuntime.queryInterface(XBridge.class, iBridges[i]); if(xBridge != null) vector.addElement(xBridge); diff --git a/jurt/com/sun/star/comp/loader/FactoryHelper.java b/jurt/com/sun/star/comp/loader/FactoryHelper.java index 451e387eb7d6..83c1c567509f 100644 --- a/jurt/com/sun/star/comp/loader/FactoryHelper.java +++ b/jurt/com/sun/star/comp/loader/FactoryHelper.java @@ -174,7 +174,7 @@ public class FactoryHelper { { if (xContext != null) { - return (XMultiServiceFactory)UnoRuntime.queryInterface( + return UnoRuntime.queryInterface( XMultiServiceFactory.class, xContext.getServiceManager() ); } else @@ -302,7 +302,7 @@ public class FactoryHelper { Object instance = _constructor.newInstance( args ); if (bInitCall) { - XInitialization xInitialization = (XInitialization)UnoRuntime.queryInterface( + XInitialization xInitialization = UnoRuntime.queryInterface( XInitialization.class, instance ); if (xInitialization != null) { diff --git a/jurt/com/sun/star/comp/loader/JavaLoader.java b/jurt/com/sun/star/comp/loader/JavaLoader.java index 3565be7031a3..cf0d9995d7f6 100644 --- a/jurt/com/sun/star/comp/loader/JavaLoader.java +++ b/jurt/com/sun/star/comp/loader/JavaLoader.java @@ -102,7 +102,7 @@ public class JavaLoader implements XImplementationLoader, { if (m_xMacroExpander == null) { - XPropertySet xProps = (XPropertySet) + XPropertySet xProps = UnoRuntime.queryInterface( XPropertySet.class, multiServiceFactory ); if (xProps == null) diff --git a/jurt/com/sun/star/comp/servicemanager/ServiceManager.java b/jurt/com/sun/star/comp/servicemanager/ServiceManager.java index adb0c54c7e28..b791c6501a36 100644 --- a/jurt/com/sun/star/comp/servicemanager/ServiceManager.java +++ b/jurt/com/sun/star/comp/servicemanager/ServiceManager.java @@ -158,7 +158,7 @@ public class ServiceManager implements XMultiServiceFactory, if (loaderObj == null) throw new com.sun.star.uno.Exception("Can get an instance of com.sun.star.loader.Java"); - return (XImplementationLoader) UnoRuntime.queryInterface( XImplementationLoader.class, loaderObj ); + return UnoRuntime.queryInterface( XImplementationLoader.class, loaderObj ); } /** @@ -380,7 +380,7 @@ public class ServiceManager implements XMultiServiceFactory, Object fac = queryServiceFactory( rServiceSpecifier ); if (fac != null) { - XSingleComponentFactory xCompFac = (XSingleComponentFactory)UnoRuntime.queryInterface( + XSingleComponentFactory xCompFac = UnoRuntime.queryInterface( XSingleComponentFactory.class, fac ); if (xCompFac != null) { @@ -388,7 +388,7 @@ public class ServiceManager implements XMultiServiceFactory, } else { - XSingleServiceFactory xServiceFac = (XSingleServiceFactory)UnoRuntime.queryInterface( + XSingleServiceFactory xServiceFac = UnoRuntime.queryInterface( XSingleServiceFactory.class, fac ); if (xServiceFac != null) { @@ -422,7 +422,7 @@ public class ServiceManager implements XMultiServiceFactory, Object fac = queryServiceFactory( rServiceSpecifier ); if (fac != null) { - XSingleComponentFactory xCompFac = (XSingleComponentFactory)UnoRuntime.queryInterface( + XSingleComponentFactory xCompFac = UnoRuntime.queryInterface( XSingleComponentFactory.class, fac ); if (xCompFac != null) { @@ -430,7 +430,7 @@ public class ServiceManager implements XMultiServiceFactory, } else { - XSingleServiceFactory xServiceFac = (XSingleServiceFactory)UnoRuntime.queryInterface( + XSingleServiceFactory xServiceFac = UnoRuntime.queryInterface( XSingleServiceFactory.class, fac ); if (xServiceFac != null) { @@ -528,7 +528,7 @@ public class ServiceManager implements XMultiServiceFactory, if (object == null) throw new com.sun.star.uno.RuntimeException("The parameter must not been null"); - XServiceInfo xServiceInfo = (XServiceInfo) UnoRuntime.queryInterface(XServiceInfo.class, object); + XServiceInfo xServiceInfo = UnoRuntime.queryInterface(XServiceInfo.class, object); if (xServiceInfo != null) { return UnoRuntime.areSame(factoriesByImplNames.get(xServiceInfo.getImplementationName()), object); @@ -552,7 +552,7 @@ public class ServiceManager implements XMultiServiceFactory, if (object == null) throw new com.sun.star.lang.IllegalArgumentException(); XServiceInfo xServiceInfo = - (XServiceInfo) UnoRuntime.queryInterface(XServiceInfo.class, object); + UnoRuntime.queryInterface(XServiceInfo.class, object); if (xServiceInfo == null) throw new com.sun.star.lang.IllegalArgumentException( @@ -606,7 +606,7 @@ public class ServiceManager implements XMultiServiceFactory, ); XServiceInfo xServiceInfo = - (XServiceInfo) UnoRuntime.queryInterface(XServiceInfo.class, object); + UnoRuntime.queryInterface(XServiceInfo.class, object); if (xServiceInfo == null) throw new com.sun.star.lang.IllegalArgumentException( @@ -614,7 +614,7 @@ public class ServiceManager implements XMultiServiceFactory, ); XSingleServiceFactory xSingleServiceFactory = - (XSingleServiceFactory) UnoRuntime.queryInterface(XSingleServiceFactory.class, object); + UnoRuntime.queryInterface(XSingleServiceFactory.class, object); if (xSingleServiceFactory == null) throw new com.sun.star.lang.IllegalArgumentException( diff --git a/jurt/com/sun/star/comp/urlresolver/UrlResolver.java b/jurt/com/sun/star/comp/urlresolver/UrlResolver.java index cabd51d42404..6c63ccbd8490 100644 --- a/jurt/com/sun/star/comp/urlresolver/UrlResolver.java +++ b/jurt/com/sun/star/comp/urlresolver/UrlResolver.java @@ -102,7 +102,7 @@ public class UrlResolver { Object rootObject = null; XBridgeFactory xBridgeFactory= null; try { - xBridgeFactory = (XBridgeFactory)UnoRuntime.queryInterface(XBridgeFactory.class, + xBridgeFactory = UnoRuntime.queryInterface(XBridgeFactory.class, _xMultiServiceFactory.createInstance("com.sun.star.bridge.BridgeFactory")); } catch (com.sun.star.uno.Exception e) { throw new com.sun.star.uno.RuntimeException(e.getMessage()); @@ -117,7 +117,7 @@ public class UrlResolver { throw new com.sun.star.uno.RuntimeException(e.getMessage()); } - XConnector connector_xConnector = (XConnector)UnoRuntime.queryInterface(XConnector.class, connector); + XConnector connector_xConnector = UnoRuntime.queryInterface(XConnector.class, connector); // connect to the server XConnection xConnection = connector_xConnector.connect(conDcp); diff --git a/jurt/com/sun/star/uno/WeakReference.java b/jurt/com/sun/star/uno/WeakReference.java index 3c954efe1cf9..fc3b6f8100ba 100644 --- a/jurt/com/sun/star/uno/WeakReference.java +++ b/jurt/com/sun/star/uno/WeakReference.java @@ -61,7 +61,7 @@ public class WeakReference Object weakImpl= obj.get(); if (weakImpl != null) { - XWeak weak= (XWeak) UnoRuntime.queryInterface(XWeak.class, weakImpl); + XWeak weak= UnoRuntime.queryInterface(XWeak.class, weakImpl); if (weak != null) { XAdapter adapter= (XAdapter) weak.queryAdapter(); @@ -77,7 +77,7 @@ public class WeakReference */ public WeakReference(Object obj) { - XWeak weak= (XWeak) UnoRuntime.queryInterface(XWeak.class, obj); + XWeak weak= UnoRuntime.queryInterface(XWeak.class, obj); if (weak != null) { XAdapter adapter= (XAdapter) weak.queryAdapter(); diff --git a/jurt/demo/com/sun/star/demo/DemoServer.java b/jurt/demo/com/sun/star/demo/DemoServer.java index 8715215dcc70..5b0b8201f274 100644 --- a/jurt/demo/com/sun/star/demo/DemoServer.java +++ b/jurt/demo/com/sun/star/demo/DemoServer.java @@ -92,12 +92,12 @@ public class DemoServer { ServiceManager serviceManager = new ServiceManager(); serviceManager.addFactories(neededServices); - XAcceptor xAcceptor = (XAcceptor)UnoRuntime.queryInterface(XAcceptor.class, serviceManager.createInstance("com.sun.star.connection.Acceptor")); + XAcceptor xAcceptor = UnoRuntime.queryInterface(XAcceptor.class, serviceManager.createInstance("com.sun.star.connection.Acceptor")); System.err.println("waiting for connect..."); XConnection xConnection = xAcceptor.accept(conDcp); - XBridgeFactory xBridgeFactory = (XBridgeFactory)UnoRuntime.queryInterface(XBridgeFactory.class, serviceManager.createInstance("com.sun.star.bridge.BridgeFactory")); + XBridgeFactory xBridgeFactory = UnoRuntime.queryInterface(XBridgeFactory.class, serviceManager.createInstance("com.sun.star.bridge.BridgeFactory")); XBridge xBridge = xBridgeFactory.createBridge(conDcp + ";" + protDcp, protDcp, xConnection, new InstanceProvider()); } diff --git a/jurt/demo/com/sun/star/demo/TestOffice.java b/jurt/demo/com/sun/star/demo/TestOffice.java index 811889898c48..7b86c8e2dd7e 100644 --- a/jurt/demo/com/sun/star/demo/TestOffice.java +++ b/jurt/demo/com/sun/star/demo/TestOffice.java @@ -76,7 +76,7 @@ public class TestOffice { { byte bytes[][] = new byte[1][]; - XInputStream rIn = (XInputStream)UnoRuntime.queryInterface(XInputStream.class, rOut); + XInputStream rIn = UnoRuntime.queryInterface(XInputStream.class, rOut); if(rIn.available() != 10) System.err.println("wrong bytes available\n"); @@ -90,11 +90,11 @@ public class TestOffice { static void testWriter(XComponent rCmp) throws IOException { - XTextDocument rTextDoc = (XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, rCmp); + XTextDocument rTextDoc = UnoRuntime.queryInterface(XTextDocument.class, rCmp); - XText rText = (XText)UnoRuntime.queryInterface(XText.class, rTextDoc.getText()); - XTextCursor rCursor = (XTextCursor)UnoRuntime.queryInterface(XTextCursor.class, rText.createTextCursor()); - XTextRange rRange = (XTextRange)UnoRuntime.queryInterface(XTextRange.class, rCursor); + XText rText = UnoRuntime.queryInterface(XText.class, rTextDoc.getText()); + XTextCursor rCursor = UnoRuntime.queryInterface(XTextCursor.class, rText.createTextCursor()); + XTextRange rRange = UnoRuntime.queryInterface(XTextRange.class, rCursor); byte pcText[] = new byte[1024]; pcText[0] = 0; @@ -112,7 +112,7 @@ public class TestOffice { } static void testDocument(XMultiServiceFactory rSmgr) throws com.sun.star.uno.Exception, IOException { - XComponentLoader rLoader = (XComponentLoader)UnoRuntime.queryInterface(XComponentLoader.class, rSmgr.createInstance("com.sun.star.frame.Desktop")); + XComponentLoader rLoader = UnoRuntime.queryInterface(XComponentLoader.class, rSmgr.createInstance("com.sun.star.frame.Desktop")); String urls[] = new String[] { "private:factory/swriter", @@ -148,13 +148,13 @@ public class TestOffice { } static void doSomething(Object r) throws com.sun.star.uno.Exception, IOException { - XNamingService rName = (XNamingService)UnoRuntime.queryInterface(XNamingService.class, r); + XNamingService rName = UnoRuntime.queryInterface(XNamingService.class, r); if(rName != null) { System.err.println("got the remote naming service !"); Object rXsmgr = rName.getRegisteredObject("StarOffice.ServiceManager"); - XMultiServiceFactory rSmgr = (XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, rXsmgr); + XMultiServiceFactory rSmgr = UnoRuntime.queryInterface(XMultiServiceFactory.class, rXsmgr); if(rSmgr != null) { System.err.println("got the remote service manager !"); // testPipe(rSmgr); @@ -183,7 +183,7 @@ public class TestOffice { smgr.addFactories(neededServices); Object resolver = smgr.createInstance("com.sun.star.bridge.UnoUrlResolver" ); - XUnoUrlResolver resolver_xUnoUrlResolver = (XUnoUrlResolver)UnoRuntime.queryInterface(XUnoUrlResolver.class, resolver); + XUnoUrlResolver resolver_xUnoUrlResolver = UnoRuntime.queryInterface(XUnoUrlResolver.class, resolver); Object rInitialObject = resolver_xUnoUrlResolver.resolve(argv[0]); diff --git a/jurt/test/com/sun/star/comp/bridgefactory/BridgeFactory_Test.java b/jurt/test/com/sun/star/comp/bridgefactory/BridgeFactory_Test.java index 8c6722c9f69a..a5fdccf613f8 100644 --- a/jurt/test/com/sun/star/comp/bridgefactory/BridgeFactory_Test.java +++ b/jurt/test/com/sun/star/comp/bridgefactory/BridgeFactory_Test.java @@ -75,7 +75,7 @@ public final class BridgeFactory_Test extends ComplexTestCase { assure("", UnoRuntime.areSame(xBridge, xBridges[0])); // dispose the bridge - XComponent xComponent = (XComponent)UnoRuntime.queryInterface(XComponent.class, xBridge); + XComponent xComponent = UnoRuntime.queryInterface(XComponent.class, xBridge); xComponent.dispose(); @@ -103,7 +103,7 @@ public final class BridgeFactory_Test extends ComplexTestCase { && UnoRuntime.areSame(xBridge_new, xBridges[0])); // dispose the new bridge - XComponent xComponent_new = (XComponent)UnoRuntime.queryInterface(XComponent.class, xBridge_new); + XComponent xComponent_new = UnoRuntime.queryInterface(XComponent.class, xBridge_new); xComponent_new.dispose(); } } diff --git a/jurt/test/com/sun/star/lib/uno/bridges/java_remote/java_remote_bridge_Test.java b/jurt/test/com/sun/star/lib/uno/bridges/java_remote/java_remote_bridge_Test.java index 8e71d51a0c6f..ffef8f7664a0 100644 --- a/jurt/test/com/sun/star/lib/uno/bridges/java_remote/java_remote_bridge_Test.java +++ b/jurt/test/com/sun/star/lib/uno/bridges/java_remote/java_remote_bridge_Test.java @@ -132,17 +132,17 @@ public final class java_remote_bridge_Test extends ComplexTestCase { proxyBXInterface[i] = (XInterface) bridgeB.getInstance(name); // map object: - proxyBTestInterface[i] = (TestInterface) UnoRuntime.queryInterface( + proxyBTestInterface[i] = UnoRuntime.queryInterface( TestInterface.class, proxyBXInterface[i]); proxyBTestInterface[i].function(); // remap object once: - TestInterface remapped = (TestInterface) UnoRuntime.queryInterface( + TestInterface remapped = UnoRuntime.queryInterface( TestInterface.class, proxyBXInterface[i]); remapped.function(); // remap object twice: - remapped = (TestInterface) UnoRuntime.queryInterface( + remapped = UnoRuntime.queryInterface( TestInterface.class, proxyBXInterface[i]); remapped.function(); } diff --git a/jurt/workbench/com/sun/star/comp/urlresolver/UrlResolver_Test.java b/jurt/workbench/com/sun/star/comp/urlresolver/UrlResolver_Test.java index 5e3110d140fa..94686e7135fd 100644 --- a/jurt/workbench/com/sun/star/comp/urlresolver/UrlResolver_Test.java +++ b/jurt/workbench/com/sun/star/comp/urlresolver/UrlResolver_Test.java @@ -58,19 +58,19 @@ public class UrlResolver_Test Object initialObject = urlResolver.resolve( "uno:socket,host=localhost,port=8100;urp;StarOffice.ServiceManager" ); - XMultiComponentFactory xOfficeFactory= (XMultiComponentFactory) UnoRuntime.queryInterface( + XMultiComponentFactory xOfficeFactory= UnoRuntime.queryInterface( XMultiComponentFactory.class, initialObject ); // retrieve the component context (it's not yet exported from the office) // Query for the XPropertySet interface. - XPropertySet xProperySet = ( XPropertySet ) UnoRuntime.queryInterface( + XPropertySet xProperySet = UnoRuntime.queryInterface( XPropertySet.class, xOfficeFactory); // Get the default context from the office server. Object oDefaultContext = xProperySet.getPropertyValue( "DefaultContext" ); // Query for the interface XComponentContext. - XComponentContext xOfficeComponentContext = ( XComponentContext ) UnoRuntime.queryInterface( + XComponentContext xOfficeComponentContext = UnoRuntime.queryInterface( XComponentContext.class, oDefaultContext ); // now create the desktop service diff --git a/jvmfwk/distributions/OpenOfficeorg/javavendors_freebsd.xml b/jvmfwk/distributions/OpenOfficeorg/javavendors_freebsd.xml index 020c11b4973e..2dd5fe35f555 100644 --- a/jvmfwk/distributions/OpenOfficeorg/javavendors_freebsd.xml +++ b/jvmfwk/distributions/OpenOfficeorg/javavendors_freebsd.xml @@ -7,13 +7,13 @@ <vendorInfos> <vendor name="Sun Microsystems Inc."> - <minVersion>1.3.1</minVersion> + <minVersion>1.5.0</minVersion> </vendor> <vendor name="The FreeBSD Foundation"> <minVersion>1.6.0</minVersion> </vendor> <vendor name="Free Software Foundation, Inc."> - <minVersion>1.4.2</minVersion> + <minVersion>1.5.0</minVersion> </vendor> </vendorInfos> diff --git a/jvmfwk/distributions/OpenOfficeorg/javavendors_os2.xml b/jvmfwk/distributions/OpenOfficeorg/javavendors_os2.xml index 372254d4ee71..2de585472b86 100644 --- a/jvmfwk/distributions/OpenOfficeorg/javavendors_os2.xml +++ b/jvmfwk/distributions/OpenOfficeorg/javavendors_os2.xml @@ -7,10 +7,10 @@ <vendorInfos> <vendor name="Sun Microsystems Inc."> - <minVersion>1.5.0</minVersion> + <minVersion>1.4.2</minVersion> </vendor> <vendor name="IBM Corporation"> - <minVersion>1.5.0</minVersion> + <minVersion>1.4.2</minVersion> </vendor> </vendorInfos> diff --git a/jvmfwk/plugins/sunmajor/javaenvsetup/javaldx.cxx b/jvmfwk/plugins/sunmajor/javaenvsetup/javaldx.cxx index 1a6f99f65ba4..19130d23ae7e 100755 --- a/jvmfwk/plugins/sunmajor/javaenvsetup/javaldx.cxx +++ b/jvmfwk/plugins/sunmajor/javaenvsetup/javaldx.cxx @@ -106,7 +106,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) errcode = jfw_existJRE(pInfo, &bExist); if (errcode == JFW_E_NONE) { - if (false == findAndSelect(&pInfo)) + if (!bExist && !findAndSelect(&pInfo)) return -1; } else diff --git a/jvmfwk/plugins/sunmajor/pluginlib/otherjre.cxx b/jvmfwk/plugins/sunmajor/pluginlib/otherjre.cxx index c80d1c091571..b59a30f887d2 100644 --- a/jvmfwk/plugins/sunmajor/pluginlib/otherjre.cxx +++ b/jvmfwk/plugins/sunmajor/pluginlib/otherjre.cxx @@ -65,11 +65,15 @@ char const* const* OtherInfo::getJavaExePaths(int * size) char const* const* OtherInfo::getRuntimePaths(int * size) { static char const* ar[]= { -#if defined(WNT) || defined(OS2) +#if defined(WNT) "/bin/client/jvm.dll", "/bin/hotspot/jvm.dll", "/bin/classic/jvm.dll", "/bin/jrockit/jvm.dll" +#elif defined(OS2) + "/bin/classic/jvm.dll", + "/bin/client/jvm.dll", + "/bin/hotspot/jvm.dll" #elif UNX #ifdef MACOSX "/../../../JavaVM" diff --git a/jvmfwk/plugins/sunmajor/pluginlib/sunjre.cxx b/jvmfwk/plugins/sunmajor/pluginlib/sunjre.cxx index fec7d0b60136..247c5092ab44 100644 --- a/jvmfwk/plugins/sunmajor/pluginlib/sunjre.cxx +++ b/jvmfwk/plugins/sunmajor/pluginlib/sunjre.cxx @@ -74,8 +74,6 @@ char const* const* SunInfo::getRuntimePaths(int * size) "/bin/classic/jvm.dll" #elif defined(OS2) "/bin/classic/jvm.dll", - "/bin/client/jvm.dll", - "/bin/hotspot/jvm.dll" #elif UNX "/lib/" JFW_PLUGIN_ARCH "/client/libjvm.so", "/lib/" JFW_PLUGIN_ARCH "/server/libjvm.so", diff --git a/jvmfwk/plugins/sunmajor/pluginlib/sunversion.cxx b/jvmfwk/plugins/sunmajor/pluginlib/sunversion.cxx index f3586af32bb5..56972ea0e66f 100644 --- a/jvmfwk/plugins/sunmajor/pluginlib/sunversion.cxx +++ b/jvmfwk/plugins/sunmajor/pluginlib/sunversion.cxx @@ -159,7 +159,7 @@ bool SunVersion::init(const char *szVersion) { //1.4.1_01-, 1.4.1_01a, the numerical part may only be 2 chars. int len = pCur - pLast; - if (len != 2) + if (len > 2) return false; //we've got the update: 01, 02 etc strncpy(buf, pLast, len); diff --git a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx index 66496afa5611..a823d551af88 100644 --- a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx +++ b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx @@ -65,6 +65,7 @@ using namespace rtl; using namespace osl; using namespace std; +#define CHAR_POINTER(oustr) ::rtl::OUStringToOString(oustr,RTL_TEXTENCODING_UTF8).pData->buffer #define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) ) #ifdef WNT #define HKEY_SUN_JRE L"Software\\JavaSoft\\Java Runtime Environment" @@ -241,9 +242,9 @@ FileHandleReader::readLine(rtl::OString * pLine) { if (m_nIndex == m_nSize) { - sal_uInt64 nRead; + sal_uInt64 nRead = 0; switch (osl_readFile( - m_aGuard.getHandle(), m_aBuffer, BUFFER_SIZE, &nRead)) + m_aGuard.getHandle(), m_aBuffer, sizeof(m_aBuffer), &nRead)) { case osl_File_E_PIPE: //HACK! for windows nRead = 0; @@ -256,8 +257,8 @@ FileHandleReader::readLine(rtl::OString * pLine) m_nIndex = 0; m_nSize = static_cast< int >(nRead); break; - case osl_File_E_INTR: - continue; + case osl_File_E_INTR: + continue; default: return RESULT_ERROR; @@ -449,7 +450,11 @@ bool getJavaProps(const OUString & exePath, rs = stdoutReader.readLine( & aLine); if (rs != FileHandleReader::RESULT_OK) break; + JFW_TRACE2(OString("[Java framework] line:\" ") + + aLine + OString(" \".\n")); OUString sLine = decodeOutput(aLine); + JFW_TRACE2(OString("[Java framework] line:\" ") + + OString( CHAR_POINTER(sLine)) + OString(" \".\n")); sLine = sLine.trim(); if (sLine.getLength() == 0) continue; @@ -483,19 +488,21 @@ bool getJavaProps(const OUString & exePath, */ rtl::OUString decodeOutput(const rtl::OString& s) { - OUString sEncoded = OStringToOUString(s, RTL_TEXTENCODING_ASCII_US); OUStringBuffer buff(512); sal_Int32 nIndex = 0; do { - OUString aToken = sEncoded.getToken( 0, ' ', nIndex ); + OString aToken = s.getToken( 0, ' ', nIndex ); if (aToken.getLength()) { - sal_Unicode value = (sal_Unicode) aToken.toInt32(); + sal_Unicode value = (sal_Unicode)(aToken.toInt32()); buff.append(value); } } while (nIndex >= 0); - return buff.makeStringAndClear(); + + OUString sDecoded(buff.makeStringAndClear()); + JFW_TRACE2(sDecoded); + return sDecoded; } @@ -743,6 +750,7 @@ vector<Reference<VendorBase> > getAllJREInfos() #ifdef UNX createJavaInfoDirScan(vecInfos); #endif + bubbleSortVersion(vecInfos); return vecInfos; } @@ -1114,6 +1122,15 @@ bool makeDriveLetterSame(OUString * fileURL) } #ifdef UNX +#ifdef SOLARIS + +void createJavaInfoDirScan(vector<rtl::Reference<VendorBase> >& vecInfos) +{ + JFW_TRACE2(OUSTR("\n[Java framework] Checking \"/usr/jdk/latest\"\n")); + getJREInfoByPath(OUSTR("file:////usr/jdk/latest"), vecInfos); +} + +#else void createJavaInfoDirScan(vector<rtl::Reference<VendorBase> >& vecInfos) { OUString excMessage = OUSTR("[Java framework] sunjavaplugin: " @@ -1236,5 +1253,6 @@ void createJavaInfoDirScan(vector<rtl::Reference<VendorBase> >& vecInfos) } } } -#endif +#endif // ifdef SOLARIS +#endif // ifdef UNX } diff --git a/jvmfwk/plugins/sunmajor/pluginlib/vendorbase.hxx b/jvmfwk/plugins/sunmajor/pluginlib/vendorbase.hxx index 680a1be74f41..b1be7cefc1a9 100644 --- a/jvmfwk/plugins/sunmajor/pluginlib/vendorbase.hxx +++ b/jvmfwk/plugins/sunmajor/pluginlib/vendorbase.hxx @@ -70,9 +70,11 @@ namespace jfw_plugin #define JFW_PLUGIN_ARCH "ia64" #elif defined M68K #define JFW_PLUGIN_ARCH "m68k" -#else // SPARC, INTEL, POWERPC, MIPS, ARM, IA64, M68K +#elif defined HPPA +#define JFW_PLUGIN_ARCH "parisc" +#else // SPARC, INTEL, POWERPC, MIPS, ARM, IA64, M68K, HPPA #error unknown plattform -#endif // SPARC, INTEL, POWERPC, MIPS, ARM +#endif // SPARC, INTEL, POWERPC, MIPS, ARM, IA64, M68K, HPPA class MalformedVersionException diff --git a/offapi/com/sun/star/accessibility/AccessibleEventId.idl b/offapi/com/sun/star/accessibility/AccessibleEventId.idl index 2a876af40885..d848f84cb322 100644 --- a/offapi/com/sun/star/accessibility/AccessibleEventId.idl +++ b/offapi/com/sun/star/accessibility/AccessibleEventId.idl @@ -367,6 +367,22 @@ published constants AccessibleEventId old and new accessible objects representing the table summary. */ const short TABLE_SUMMARY_CHANGED = 31; + + /** Constant used to indicate that a list box entry has been expanded. + <member>AccessibleEventObject::OldValue</member> is empty. + <member>AccessibleEventObject::NewValue</member> contains the expanded list box entry. + + @since OOo 3.2 + */ + const short LISTBOX_ENTRY_EXPANDED = 32; + + /** Constant used to indicate that a list box entry has been collapsed. + <member>AccessibleEventObject::OldValue</member> is empty. + <member>AccessibleEventObject::NewValue</member> contains the collapsed list box entry. + + @since OOo 3.2 + */ + const short LISTBOX_ENTRY_COLLAPSED = 33; }; }; }; }; }; diff --git a/offapi/com/sun/star/awt/MouseWheelBehavior.idl b/offapi/com/sun/star/awt/MouseWheelBehavior.idl new file mode 100644 index 000000000000..5a5d03a4c2e8 --- /dev/null +++ b/offapi/com/sun/star/awt/MouseWheelBehavior.idl @@ -0,0 +1,61 @@ +/************************************************************************* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2009 by Sun Microsystems, Inc. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* 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. +************************************************************************/ +
+#ifndef __com_sun_star_awt_MouseWheelBehavior_idl__ +#define __com_sun_star_awt_MouseWheelBehavior_idl__ + +//============================================================================= + +module com { module sun { module star { module awt { + +//============================================================================= + +/** describes the scroll behavior of the mouse wheel for a control + @since OOo 3.2 + */ +constants MouseWheelBehavior +{ + /** defines that the mouse wheel cannot be used to scroll through the control's content + */ + const short SCROLL_DISABLED = 0; + + /** defines that the mouse can only be used to scroll through the control's content if it currently + has the focus. + */ + const short SCROLL_FOCUS_ONLY = 1; + + /** defines that the mouse can be used to scroll through the control's content, no matter whether or not + it has the focus, as long as the mouse pointer is over the control. + */ + const short SCROLL_ALWAYS = 2; +}; + +//============================================================================= + +}; }; }; }; + +//============================================================================= + +#endif diff --git a/offapi/com/sun/star/awt/UnoControlComboBoxModel.idl b/offapi/com/sun/star/awt/UnoControlComboBoxModel.idl index d33d8f4d71ea..29328056f480 100644 --- a/offapi/com/sun/star/awt/UnoControlComboBoxModel.idl +++ b/offapi/com/sun/star/awt/UnoControlComboBoxModel.idl @@ -220,6 +220,14 @@ published service UnoControlComboBoxModel @since OOo 3.1 */ [optional, property] short WritingMode; + + /** defines how the mouse wheel can be used to scroll through the control's content. + + <p>Usually, the mouse wheel scrool through the control's entry list. Using this property, + and one of the <type>MouseWheelBehavior</type> constants, you can control under which circumstances + this is possible.</p> + */ + [optional, property] short MouseWheelBehavior; }; //============================================================================= diff --git a/offapi/com/sun/star/awt/UnoControlCurrencyFieldModel.idl b/offapi/com/sun/star/awt/UnoControlCurrencyFieldModel.idl index 0aa722943e2d..17f72a2be100 100644 --- a/offapi/com/sun/star/awt/UnoControlCurrencyFieldModel.idl +++ b/offapi/com/sun/star/awt/UnoControlCurrencyFieldModel.idl @@ -254,6 +254,14 @@ published service UnoControlCurrencyFieldModel @since OOo 3.1 */ [optional, property] short WritingMode; + + /** defines how the mouse wheel can be used to scroll through the control's content. + + <p>Usually, the mouse wheel spins the numeric value displayed in the control. Using this property, + and one of the <type>MouseWheelBehavior</type> constants, you can control under which circumstances + this is possible.</p> + */ + [optional, property] short MouseWheelBehavior; }; //============================================================================= diff --git a/offapi/com/sun/star/awt/UnoControlDateFieldModel.idl b/offapi/com/sun/star/awt/UnoControlDateFieldModel.idl index a636f2f5f6a5..d14f602e817a 100644 --- a/offapi/com/sun/star/awt/UnoControlDateFieldModel.idl +++ b/offapi/com/sun/star/awt/UnoControlDateFieldModel.idl @@ -266,6 +266,14 @@ published service UnoControlDateFieldModel @since OOo 3.1 */ [optional, property] short WritingMode; + + /** defines how the mouse wheel can be used to scroll through the control's content. + + <p>Usually, the mouse wheel spins the numeric value displayed in the control. Using this property, + and one of the <type>MouseWheelBehavior</type> constants, you can control under which circumstances + this is possible.</p> + */ + [optional, property] short MouseWheelBehavior; }; //============================================================================= diff --git a/offapi/com/sun/star/awt/UnoControlFormattedFieldModel.idl b/offapi/com/sun/star/awt/UnoControlFormattedFieldModel.idl index 346c76b6d41a..1575e1f6d6a6 100644 --- a/offapi/com/sun/star/awt/UnoControlFormattedFieldModel.idl +++ b/offapi/com/sun/star/awt/UnoControlFormattedFieldModel.idl @@ -299,6 +299,14 @@ published service UnoControlFormattedFieldModel @since OOo 3.1 */ [optional, property] short WritingMode; + + /** defines how the mouse wheel can be used to scroll through the control's content. + + <p>Usually, the mouse wheel spins the numeric value displayed in the control. Using this property, + and one of the <type>MouseWheelBehavior</type> constants, you can control under which circumstances + this is possible.</p> + */ + [optional, property] short MouseWheelBehavior; }; //============================================================================= diff --git a/offapi/com/sun/star/awt/UnoControlListBoxModel.idl b/offapi/com/sun/star/awt/UnoControlListBoxModel.idl index 239a00e967f6..56c50b74fe04 100644 --- a/offapi/com/sun/star/awt/UnoControlListBoxModel.idl +++ b/offapi/com/sun/star/awt/UnoControlListBoxModel.idl @@ -203,6 +203,14 @@ published service UnoControlListBoxModel @since OOo 3.1 */ [optional, property] short WritingMode; + + /** defines how the mouse wheel can be used to scroll through the control's content. + + <p>Usually, the mouse wheel scrool through the control's entry list. Using this property, + and one of the <type>MouseWheelBehavior</type> constants, you can control under which circumstances + this is possible.</p> + */ + [optional, property] short MouseWheelBehavior; }; //============================================================================= diff --git a/offapi/com/sun/star/awt/UnoControlNumericFieldModel.idl b/offapi/com/sun/star/awt/UnoControlNumericFieldModel.idl index 914c3ed5d6f4..4846980a974c 100644 --- a/offapi/com/sun/star/awt/UnoControlNumericFieldModel.idl +++ b/offapi/com/sun/star/awt/UnoControlNumericFieldModel.idl @@ -242,6 +242,14 @@ published service UnoControlNumericFieldModel @since OOo 3.1 */ [optional, property] short WritingMode; + + /** defines how the mouse wheel can be used to scroll through the control's content. + + <p>Usually, the mouse wheel spins the numeric value displayed in the control. Using this property, + and one of the <type>MouseWheelBehavior</type> constants, you can control under which circumstances + this is possible.</p> + */ + [optional, property] short MouseWheelBehavior; }; //============================================================================= diff --git a/offapi/com/sun/star/awt/UnoControlPatternFieldModel.idl b/offapi/com/sun/star/awt/UnoControlPatternFieldModel.idl index cccb61cb5487..b3bb7691e333 100644 --- a/offapi/com/sun/star/awt/UnoControlPatternFieldModel.idl +++ b/offapi/com/sun/star/awt/UnoControlPatternFieldModel.idl @@ -201,6 +201,14 @@ published service UnoControlPatternFieldModel @since OOo 3.1 */ [optional, property] short WritingMode; + + /** defines how the mouse wheel can be used to scroll through the control's content. + + <p>Usually, the mouse wheel spins the numeric value displayed in the control. Using this property, + and one of the <type>MouseWheelBehavior</type> constants, you can control under which circumstances + this is possible.</p> + */ + [optional, property] short MouseWheelBehavior; }; //============================================================================= diff --git a/offapi/com/sun/star/awt/UnoControlSpinButtonModel.idl b/offapi/com/sun/star/awt/UnoControlSpinButtonModel.idl index f4170c5a4fd2..696fb5255785 100644 --- a/offapi/com/sun/star/awt/UnoControlSpinButtonModel.idl +++ b/offapi/com/sun/star/awt/UnoControlSpinButtonModel.idl @@ -169,6 +169,14 @@ service UnoControlSpinButtonModel is specified with this property.</p> */ [property] long RepeatDelay; + + /** defines how the mouse wheel can be used to scroll through the control's content. + + <p>Usually, the mouse wheel spins the numeric value displayed in the control. Using this property, + and one of the <type>MouseWheelBehavior</type> constants, you can control under which circumstances + this is possible.</p> + */ + [optional, property] short MouseWheelBehavior; }; //============================================================================= diff --git a/offapi/com/sun/star/awt/UnoControlTimeFieldModel.idl b/offapi/com/sun/star/awt/UnoControlTimeFieldModel.idl index 7b4bbcb5e8fe..79bed704660f 100644 --- a/offapi/com/sun/star/awt/UnoControlTimeFieldModel.idl +++ b/offapi/com/sun/star/awt/UnoControlTimeFieldModel.idl @@ -246,6 +246,14 @@ published service UnoControlTimeFieldModel @since OOo 3.1 */ [optional, property] short WritingMode; + + /** defines how the mouse wheel can be used to scroll through the control's content. + + <p>Usually, the mouse wheel spins the numeric value displayed in the control. Using this property, + and one of the <type>MouseWheelBehavior</type> constants, you can control under which circumstances + this is possible.</p> + */ + [optional, property] short MouseWheelBehavior; }; //============================================================================= diff --git a/offapi/com/sun/star/awt/XTopWindow2.idl b/offapi/com/sun/star/awt/XTopWindow2.idl new file mode 100644 index 000000000000..0cc289d42b17 --- /dev/null +++ b/offapi/com/sun/star/awt/XTopWindow2.idl @@ -0,0 +1,76 @@ +/************************************************************************* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2009 by Sun Microsystems, Inc. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* 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. +************************************************************************/ + +#ifndef __com_sun_star_awt_XTopWindow2_idl__ +#define __com_sun_star_awt_XTopWindow2_idl__ + +#include <com/sun/star/awt/XTopWindow.idl> +#include <com/sun/star/lang/IndexOutOfBoundsException.idl> + +//============================================================================= + +module com { module sun { module star { module awt { + +//============================================================================= + +/** extends XTopWindow with additional functionality + */ +interface XTopWindow2 : XTopWindow +{ + /** controls whether the window is currently maximized + */ + [attribute] boolean IsMaximized; + + /** controls whether the window is currently minimized + */ + [attribute] boolean IsMinimized; + + /** controls on which display the window is shown. + + <p>When retrieving this property, in case the window is positioned on multiple displays, + the number returned will be of the display containing the upper left pixel of the frame + area (that is of the client area on system decorated windows, or the frame area of + undecorated resp. owner decorated windows).</p> + + @throws ::com::sun::star::lang::IndexOutOfBoundsException + if you attempt to set this property to a value which does not correspond to the number + of an existing screen. + + @see com::sun::star::awt::DisplayAccess + @see com::sun::star::awt::DisplayInfo + */ + [attribute] long Display + { + set raises (::com::sun::star::lang::IndexOutOfBoundsException); + }; +}; + +//============================================================================= + +}; }; }; }; + +//============================================================================= + +#endif diff --git a/offapi/com/sun/star/awt/grid/DefaultGridColumnModel.idl b/offapi/com/sun/star/awt/grid/DefaultGridColumnModel.idl new file mode 100644 index 000000000000..67e5b7572de3 --- /dev/null +++ b/offapi/com/sun/star/awt/grid/DefaultGridColumnModel.idl @@ -0,0 +1,54 @@ +/************************************************************************* + * + * 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: UnoControlEdit.idl,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. + * + ************************************************************************/ +#ifndef __com_sun_star_awt_DefaultGridColumnModel_idl__ +#define __com_sun_star_awt_DefaultGridColumnModel_idl__ + +#ifndef __com_sun_star_awt_grid_XGridColumnModel_idl__ +#include <com/sun/star/awt/grid/XGridColumnModel.idl> +#endif + +//============================================================================= + + module com { module sun { module star { module awt { module grid { + +//============================================================================= + +/** If you do not want to implement the <type>XGridColumnModel</type> yourself, use this service. + */ +service DefaultGridColumnModel +{ + interface com::sun::star::awt::grid::XGridColumnModel; +}; + +//============================================================================= + +}; }; }; };}; + +#endif diff --git a/offapi/com/sun/star/awt/grid/DefaultGridDataModel.idl b/offapi/com/sun/star/awt/grid/DefaultGridDataModel.idl new file mode 100644 index 000000000000..40a77668887c --- /dev/null +++ b/offapi/com/sun/star/awt/grid/DefaultGridDataModel.idl @@ -0,0 +1,54 @@ +/************************************************************************* + * + * 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: UnoControlEdit.idl,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. + * + ************************************************************************/ +#ifndef __com_sun_star_awt_DefaultGridDataModel_idl__ +#define __com_sun_star_awt_DefaultGridDataModel_idl__ + +#ifndef __com_sun_star_awt_grid_XGridDataModel_idl__ +#include <com/sun/star/awt/grid/XGridDataModel.idl> +#endif + +//============================================================================= + + module com { module sun { module star { module awt { module grid { + +//============================================================================= + +/** If you do not want to implement the <type>XGridDataModel</type> yourself, use this service. + */ +service DefaultGridDataModel +{ + interface com::sun::star::awt::grid::XGridDataModel; +}; + +//============================================================================= + +}; }; }; };}; + +#endif diff --git a/offapi/com/sun/star/awt/grid/GridColumn.idl b/offapi/com/sun/star/awt/grid/GridColumn.idl new file mode 100644 index 000000000000..90db6f82b258 --- /dev/null +++ b/offapi/com/sun/star/awt/grid/GridColumn.idl @@ -0,0 +1,54 @@ +/************************************************************************* + * + * 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: UnoControlEdit.idl,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. + * + ************************************************************************/ +#ifndef __com_sun_star_awt_GridColumn_idl__ +#define __com_sun_star_awt_GridColumn_idl__ + +#ifndef __com_sun_star_awt_grid_XGridColumn_idl__ +#include <com/sun/star/awt/grid/XGridColumn.idl> +#endif + +//============================================================================= + + module com { module sun { module star { module awt { module grid { + +//============================================================================= + +/** Represents a column as used by the <type>DefaultGridColumnModel</type> + */ +service GridColumn +{ + interface com::sun::star::awt::grid::XGridColumn; +}; + +//============================================================================= + +}; }; }; };}; + +#endif diff --git a/offapi/com/sun/star/awt/grid/GridColumnEvent.idl b/offapi/com/sun/star/awt/grid/GridColumnEvent.idl new file mode 100644 index 000000000000..c6c5ac646cdf --- /dev/null +++ b/offapi/com/sun/star/awt/grid/GridColumnEvent.idl @@ -0,0 +1,79 @@ +/************************************************************************* + * + * 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: ActionEvent.idl,v $ + * $Revision: 1.11 $ + * + * 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. + * + ************************************************************************/ +#ifndef __com_sun_star_awt_grid_GridColumnEvent_idl__ +#define __com_sun_star_awt_grid_GridColumnEvent_idl__ + +#ifndef __com_sun_star_lang_EventObject_idl__ +#include <com/sun/star/lang/EventObject.idl> +#endif + +#ifndef __com_sun_star_awt_grid_XGridColumn_idl__ +#include <com/sun/star/awt/grid/XGridColumn.idl> +#endif + +//============================================================================= + +module com { module sun { module star { module awt { module grid { + +//============================================================================= + +/** An event used by a <type>XGridColumnModel</type> to notify changes in the column + model to the <type>XGridControl</type>. + You usually need to fill this event only if you implement the <type>XGridColumnModel</type> + yourself. + + @see XGridColumnModel + @see XGridControl + @see XGridColumnListener + */ +struct GridColumnEvent: com::sun::star::lang::EventObject +{ + /** Contains the property name of the changed value **/ + string valueName; + + /** Contains the old value **/ + any oldValue; + + /** Contains the new value **/ + any newValue; + + /** Contains the index of the changed column**/ + long index; + + /** Contains the changed column**/ + XGridColumn column; + //------------------------------------------------------------------------- +}; + +//============================================================================= + +}; }; }; }; }; + +#endif diff --git a/offapi/com/sun/star/awt/grid/GridControlEvent.idl b/offapi/com/sun/star/awt/grid/GridControlEvent.idl new file mode 100644 index 000000000000..87b3a9064387 --- /dev/null +++ b/offapi/com/sun/star/awt/grid/GridControlEvent.idl @@ -0,0 +1,57 @@ +/************************************************************************* + * + * 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: ActionEvent.idl,v $ + * $Revision: 1.11 $ + * + * 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. + * + ************************************************************************/ +#ifndef __com_sun_star_awt_GridControlEvent_idl__ +#define __com_sun_star_awt_GridControlEvent_idl__ + +#ifndef __com_sun_star_lang_EventObject_idl__ +#include <com/sun/star/lang/EventObject.idl> +#endif + + +//============================================================================= + +module com { module sun { module star { module awt { module grid { + +//============================================================================= + + +struct GridControlEvent: com::sun::star::lang::EventObject +{ + //------------------------------------------------------------------------- + + string ActionCommand; + +}; + +//============================================================================= + +}; }; }; }; }; + +#endif diff --git a/offapi/com/sun/star/awt/grid/GridDataEvent.idl b/offapi/com/sun/star/awt/grid/GridDataEvent.idl new file mode 100644 index 000000000000..a4ff1a58d5c7 --- /dev/null +++ b/offapi/com/sun/star/awt/grid/GridDataEvent.idl @@ -0,0 +1,82 @@ +/************************************************************************* + * + * 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: ActionEvent.idl,v $ + * $Revision: 1.11 $ + * + * 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. + * + ************************************************************************/ +#ifndef __com_sun_star_awt_grid_GridDataEvent_idl__ +#define __com_sun_star_awt_grid_GridDataEvent_idl__ + +#ifndef __com_sun_star_lang_EventObject_idl__ +#include <com/sun/star/lang/EventObject.idl> +#endif + + +//============================================================================= + +module com { module sun { module star { module awt { module grid { + +//============================================================================= + +/** An event used by a <type>XGridDataModel</type> to notify changes in the data + model to the <type>XGridControl</type>. + You usually need to fill this event only if you implement the <type>XGridDataModel</type> + yourself. + + @see XGridDataModel + @see XGridControl + @see XGridDataListener + */ +struct GridDataEvent: com::sun::star::lang::EventObject +{ + //------------------------------------------------------------------------- + + /** Contains the property name of the changed value **/ + string valueName; + + /** Contains the old value **/ + any oldValue; + + /** Contains the new value **/ + any newValue; + + /** Contains the index of the changed row**/ + long index; + + /** Contains the header name of the changed row**/ + string headerName; + + /** Contains the changed row**/ + sequence<string> rowData; + + +}; + +//============================================================================= + +}; }; }; }; }; + +#endif diff --git a/offapi/com/sun/star/awt/grid/GridSelectionEvent.idl b/offapi/com/sun/star/awt/grid/GridSelectionEvent.idl new file mode 100644 index 000000000000..a2ec28361ca0 --- /dev/null +++ b/offapi/com/sun/star/awt/grid/GridSelectionEvent.idl @@ -0,0 +1,71 @@ +/************************************************************************* + * + * 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: ActionEvent.idl,v $ + * $Revision: 1.11 $ + * + * 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. + * + ************************************************************************/ +#ifndef __com_sun_star_awt_GridSelectionEvent_idl__ +#define __com_sun_star_awt_GridSelectionEvent_idl__ + +#ifndef __com_sun_star_lang_EventObject_idl__ +#include <com/sun/star/lang/EventObject.idl> +#endif + +#ifndef __com_sun_star_awt_grid_SelectionEventType_idl__ +#include <com/sun/star/awt/grid/SelectionEventType.idl> +#endif + +//============================================================================= + +module com { module sun { module star { module awt { module grid { + +//============================================================================= + +/** An event used by a <type>XGridControl</type> to notify changes in the selection. + + @see XGridControl + @see XGridSelectionListener + */ +struct GridSelectionEvent: com::sun::star::lang::EventObject +{ + //------------------------------------------------------------------------- + + /** Contains the x coordinate of the selected cell**/ + long x; + + /** Contains the y coordinate of the selected cell**/ + long y; + + /** Contains the action <type>SelectionEventType</types> that was performed **/ + SelectionEventType action; + +}; + +//============================================================================= + +}; }; }; }; }; + +#endif diff --git a/offapi/com/sun/star/awt/grid/ScrollBarMode.idl b/offapi/com/sun/star/awt/grid/ScrollBarMode.idl new file mode 100644 index 000000000000..579ca0bab1ae --- /dev/null +++ b/offapi/com/sun/star/awt/grid/ScrollBarMode.idl @@ -0,0 +1,73 @@ +/************************************************************************* + * + * 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: AdjustmentType.idl,v $ + * $Revision: 1.7 $ + * + * 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. + * + ************************************************************************/ +#ifndef __com_sun_star_awt_grid_ScrollBarMode_idl__ +#define __com_sun_star_awt_grid_ScrollBarMode_idl__ + + +//============================================================================= + +module com { module sun { module star { module awt { module grid { + +//============================================================================= + +/** specifies the adjustment type. + */ +enum ScrollBarMode +{ + //------------------------------------------------------------------------- + + /** adjustment is originated by a line jump. + + <p>A line jump can, for example, be caused by a click on + one of the pointer buttons.</p> + */ + AUTO, + + //------------------------------------------------------------------------- + + /** adjustment is originated by a page jump. + + <p>A page jump can, for example, be caused by a click in the + background area of the scrollbar (neither one of the pointer + buttons, nor the thumb).</p> + */ + ON, + + OFF + + + +}; + +//============================================================================= + +}; }; }; }; }; + +#endif diff --git a/offapi/com/sun/star/awt/grid/SelectionEventType.idl b/offapi/com/sun/star/awt/grid/SelectionEventType.idl new file mode 100644 index 000000000000..4d8aa7fc0cdb --- /dev/null +++ b/offapi/com/sun/star/awt/grid/SelectionEventType.idl @@ -0,0 +1,63 @@ +/************************************************************************* + * + * 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: AdjustmentType.idl,v $ + * $Revision: 1.7 $ + * + * 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. + * + ************************************************************************/ +#ifndef __com_sun_star_awt_grid_SelectionEventType_idl__ +#define __com_sun_star_awt_grid_SelectionEventType_idl__ + + +//============================================================================= + +module com { module sun { module star { module awt { module grid { + +//============================================================================= + +/** specifies the type of a selection event, as used by + <type>GridSelectionEvent</type>. + */ +enum SelectionEventType +{ + //------------------------------------------------------------------------- + + /** This value indicates that a selection was added to the grid control + */ + ADD, + + //------------------------------------------------------------------------- + + /** This value indicates that a selection was removed from the grid control + */ + REMOVE + +}; + +//============================================================================= + +}; }; }; }; }; + +#endif diff --git a/offapi/com/sun/star/awt/grid/UnoControlGrid.idl b/offapi/com/sun/star/awt/grid/UnoControlGrid.idl new file mode 100644 index 000000000000..d45bf024afb1 --- /dev/null +++ b/offapi/com/sun/star/awt/grid/UnoControlGrid.idl @@ -0,0 +1,84 @@ +/************************************************************************* + * + * 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: UnoControlEdit.idl,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. + * + ************************************************************************/ +#ifndef __com_sun_star_awt_UnoControlGrid_idl__ +#define __com_sun_star_awt_UnoControlGrid_idl__ + +#ifndef __com_sun_star_awt_UnoControl_idl__ +#include <com/sun/star/awt/UnoControl.idl> +#endif + +#ifndef __com_sun_star_awt_grid_XGridControl_idl__ +#include <com/sun/star/awt/grid/XGridControl.idl> +#endif + +//============================================================================= + + module com { module sun { module star { module awt { module grid { + +//============================================================================= + +//============================================================================= + +/** A control that displays a set of tabular data. + + <p> + <h4>The Column Model</h4> + <p>The horizontal structure of the grid is defined by the <type>XGridColumnModel</type> implemented in <type>DefaultGridColumnModel</type> + The <type>XGridColumn</type> implemented in <typeGridColumn</type> describes the properties and behavior of a single column. Use the <member>XGridColumnModel::addColumn()</member> to add a column to the column model. + </p> + <p> + <h4>The Data Model</h4> + <p> All row data are stored in the <type>XGridDataModel</type>. + Use the <type>DefaultGridDataModel</type> to add <member>XGridDataModel::addRow()</member> or remove <member>XGridDataModel::removeRow()</member> rows. + </p> + + <p>The column and data model must be set at the <member>UnoControlGridModel::ColumnModel</member> and <member>UnoControlGridModel::GridDataModel</member> properties.</p> + + <h4>Selection</h4> + <p>If you are interested in knowing when the selection changes implement a + <type>XGridSelectionListener</type> and add the instance with the method + <member>XGridSelection::addSelectionListener()</member>. + You than will be notified for any selection change. + + The <type>XGridSelection</type> interface provides a bunch of methods to set and get selection for the grid control. + </p> + */ +service UnoControlGrid +{ + service com::sun::star::awt::UnoControl; + + interface com::sun::star::awt::grid::XGridControl; +}; + +//============================================================================= + +}; }; }; };}; + +#endif diff --git a/offapi/com/sun/star/awt/grid/UnoControlGridModel.idl b/offapi/com/sun/star/awt/grid/UnoControlGridModel.idl new file mode 100644 index 000000000000..eabe7515fb5c --- /dev/null +++ b/offapi/com/sun/star/awt/grid/UnoControlGridModel.idl @@ -0,0 +1,101 @@ +/************************************************************************* + * + * 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: UnoControlEditModel.idl,v $ + * $Revision: 1.16 $ + * + * 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. + * + ************************************************************************/ +#ifndef __com_sun_star_awt_grid_UnoControlGridModel_idl__ +#define __com_sun_star_awt_grid_UnoControlGridModel_idl__ + +#include <com/sun/star/awt/grid/XGridColumnModel.idl> + +#include <com/sun/star/awt/grid/XGridDataModel.idl> + +#include <com/sun/star/awt/grid/ScrollBarMode.idl> + +#include <com/sun/star/awt/UnoControlModel.idl> + +#include <com/sun/star/view/SelectionType.idl> + +//============================================================================= + +module com { module sun { module star { module awt { module grid { + +//============================================================================= + +/** specifies the standard model of a <type>UnoControlGridModel</type>. + */ +service UnoControlGridModel +{ + /** specifies the standard model of an <type scope="com::sun::star::awt">UnoControl</type>. */ + service com::sun::star::awt::UnoControlModel; + + /** Specifies whether the grid control should display a special header column. + <p>The default value is <FALSE/></p> + */ + [property] boolean ShowRowHeader; + + /** Specifies whether the grid control should display a title row. + <p>The default value is <TRUE/></p> + */ + [property] boolean ShowColumnHeader; + + /** Specifies the <type>XGridColumnModel</type> that is providing the column structure. + + <p>You can implement your own instance of <type>XGridColumnModel</type> or use + the <type>DefaultGridColumnModel</type>. + */ + [property] XGridColumnModel ColumnModel; + + /** Specifies the <type>XGridDataModel</type> that is providing the hierarchical data. + + <p>You can implement your own instance of <type>XGridDataModel</type> or use + the <type>DefaultGridDataModel</type>. + */ + [property] XGridDataModel DataModel; + + /** Specifies the vertical scrollbar mode. + <p>The default value is <FALSE/></p> + */ + [property] boolean HScroll; + + /** Specifies the horizontal scrollbar mode. + <p>The default value is <FALSE/></p> + */ + [property] boolean VScroll; + + /** Specifies the selection mode that is enabled for this grid control. + <p>The default value is <member scope="com::sun::star::view">SelectionType::SINGLE</member></p> + */ + [property] ::com::sun::star::view::SelectionType SelectionModel; + +}; + +//============================================================================= + +}; }; }; }; }; + +#endif diff --git a/offapi/com/sun/star/awt/grid/XGridCell.idl b/offapi/com/sun/star/awt/grid/XGridCell.idl new file mode 100644 index 000000000000..40f55109e24c --- /dev/null +++ b/offapi/com/sun/star/awt/grid/XGridCell.idl @@ -0,0 +1,59 @@ +/************************************************************************* + * + * 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: XListBox.idl,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. + * + ************************************************************************/ +#ifndef __com_sun_star_awt_grid_XGridCell_idl__ +#define __com_sun_star_awt_grid_XGridCell_idl__ + +#ifndef __com_sun_star_uno_XInterface_idl__ +#include <com/sun/star/uno/XInterface.idl> +#endif + + + +//============================================================================= + +module com { module sun { module star { module awt { module grid { + +//============================================================================= + +interface XGridCell: com::sun::star::uno::XInterface +{ + + [attribute] string Value; + + [attribute] boolean Editable; + + [attribute] any Data; +}; + +//============================================================================= + +}; }; }; }; }; + +#endif diff --git a/offapi/com/sun/star/awt/grid/XGridCellRenderer.idl b/offapi/com/sun/star/awt/grid/XGridCellRenderer.idl new file mode 100644 index 000000000000..88fd77697876 --- /dev/null +++ b/offapi/com/sun/star/awt/grid/XGridCellRenderer.idl @@ -0,0 +1,56 @@ +/************************************************************************* + * + * 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: XListBox.idl,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. + * + ************************************************************************/ +#ifndef __com_sun_star_awt_grid_XGridCellRenderer_idl__ +#define __com_sun_star_awt_grid_XGridCellRenderer_idl__ + +#ifndef __com_sun_star_uno_XInterface_idl__ +#include <com/sun/star/uno/XInterface.idl> +#endif + +//============================================================================= + +module com { module sun { module star { module awt { module grid { + +//============================================================================= + +/** gives access to the items of a list box and makes it possible to + register item and action event listeners. + */ +interface XGridCellRenderer: com::sun::star::uno::XInterface +{ + //------------------------------------------------------------------------- + +}; + +//============================================================================= + +}; }; }; }; }; + +#endif diff --git a/offapi/com/sun/star/awt/grid/XGridColumn.idl b/offapi/com/sun/star/awt/grid/XGridColumn.idl new file mode 100644 index 000000000000..741af231ed03 --- /dev/null +++ b/offapi/com/sun/star/awt/grid/XGridColumn.idl @@ -0,0 +1,72 @@ +/************************************************************************* + * + * 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: XGridColumn.idl,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. + * + ************************************************************************/ +#ifndef __com_sun_star_awt_grid_XGridColumn_idl__ +#define __com_sun_star_awt_grid_XGridColumn_idl__ + +#ifndef __com_sun_star_uno_XInterface_idl__ +#include <com/sun/star/uno/XInterface.idl> +#endif + +//============================================================================= + +module com { module sun { module star { module awt { module grid { + +//============================================================================= + +/** The <type>XGridColumn</types> defines the properties and behavior of a column in a grid control + */ +interface XGridColumn: com::sun::star::uno::XInterface +{ + /** Specifies the an idendifier of the colomn.**/ + [attribute] any Identifier; + + /** Specifies the default column witdth. **/ + [attribute] long ColumnWidth; + /* + [attribute] long PreferredWidth; + + [attribute] long MinWidth; + + [attribute] long MaxWidth; + + [attribute] boolean Resizable; + */ + + /** A title is displayed in the colum header row if <method>UnoControlGridModel::ShowRowHeader</method> is set to <true/>**/ + [attribute] string Title; + + +}; + +//============================================================================= + +}; }; }; }; }; + +#endif diff --git a/offapi/com/sun/star/awt/grid/XGridColumnListener.idl b/offapi/com/sun/star/awt/grid/XGridColumnListener.idl new file mode 100644 index 000000000000..09a2b602e800 --- /dev/null +++ b/offapi/com/sun/star/awt/grid/XGridColumnListener.idl @@ -0,0 +1,74 @@ +/************************************************************************* + * + * 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: XListBox.idl,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. + * + ************************************************************************/ +#ifndef __com_sun_star_awt_grid_XGridColumnListener_idl__ +#define __com_sun_star_awt_grid_XGridColumnListener_idl__ + +#ifndef __com_sun_star_uno_XInterface_idl__ +#include <com/sun/star/uno/XInterface.idl> +#endif + +#ifndef __com_sun_star_awt_grid_GridColumnEvent_idl__ +#include <com/sun/star/awt/grid/GridColumnEvent.idl> +#endif + +//============================================================================= + +module com { module sun { module star { module awt { module grid { + +//============================================================================= + +/** An instance of this interface is used by the <type>XGridColumnModel</type> to + get notifications about column model changes. + + <p>Usually you must not implement this interface yourself, but you must notify it correctly if + you implement the <type>XGridColumnModel</type> yourself</p>. + */ +interface XGridColumnListener: com::sun::star::uno::XInterface +{ + /** + Invoked after a column was added to the column model. + */ + void columnAdded( [in] GridColumnEvent event ); + + /** + Invoked after a column was removed from the column model. + */ + void columnRemoved( [in] GridColumnEvent event ); + + /** + Invoked after a column was modified. + */ + void columnChanged( [in] GridColumnEvent event ); +}; +//============================================================================= + +}; }; }; }; }; + +#endif diff --git a/offapi/com/sun/star/awt/grid/XGridColumnModel.idl b/offapi/com/sun/star/awt/grid/XGridColumnModel.idl new file mode 100644 index 000000000000..f4cf2a7a3694 --- /dev/null +++ b/offapi/com/sun/star/awt/grid/XGridColumnModel.idl @@ -0,0 +1,116 @@ +/************************************************************************* + * + * 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: XListBox.idl,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. + * + ************************************************************************/ +#ifndef __com_sun_star_awt_grid_XGridColumnModel_idl__ +#define __com_sun_star_awt_grid_XGridColumnModel_idl__ + +#include <com/sun/star/uno/XInterface.idl> + +#include <com/sun/star/awt/grid/XGridColumn.idl> +#include <com/sun/star/awt/grid/XGridColumnListener.idl> + +//============================================================================= + +module com { module sun { module star { module awt { module grid { + +//============================================================================= + +/** An instance of this interface is used by the <type>UnoControlGrid</type> to + retrieve the column structure that is displayed in the actual control. + + If you do not need your own model implementation, you can also use the <type>DefaultGridColumnModel</type>. +*/ +interface XGridColumnModel: com::sun::star::uno::XInterface +{ + /** Specifies whether column selection is allowed + */ + [attribute] boolean ColumnSelectionAllowed; + + /** Returns the number of columns. + @returns + the number of columns. + */ + long getColumnCount(); + + /** Adds a column to the model. + @param column + the column to add to the model. + + @returns + the index of new created column. + */ + long addColumn( [in] XGridColumn column ); + + /* + long getSelectedCount(); + + sequence<XGridColumn> getSelectedColumns(); + + sequence<long> getSelectedIndex(); + + */ + + /** Returns all columns of the model. + @returns + all columns associated with the model in a sequence of <type>XGridColumn</type>. + */ + sequence<XGridColumn> getColumns(); + + /** Returns a specific column. + @param index + the position of the reuquested column. + @returns + the requested column. + */ + XGridColumn getColumn( [in] long index); + + /* + long getTotalColumnWidth(); + */ + + /** Adds a listener for the <type>GridColumnEvent</type> posted after the grid changes. + @param Listener + the listener to add. + */ + [oneway] void addColumnListener( [in] XGridColumnListener listener); + + //------------------------------------------------------------------------- + + /** Removes a listener previously added with <method>addColumnListener()</method>. + @param Listener + the listener to remove. + */ + [oneway] void removeColumnListener( [in] XGridColumnListener listener); +}; + +//============================================================================= + +}; }; }; }; }; + +#endif diff --git a/offapi/com/sun/star/awt/grid/XGridControl.idl b/offapi/com/sun/star/awt/grid/XGridControl.idl new file mode 100644 index 000000000000..fc7c23c720a1 --- /dev/null +++ b/offapi/com/sun/star/awt/grid/XGridControl.idl @@ -0,0 +1,78 @@ +/************************************************************************* + * + * 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: XListBox.idl,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. + * + ************************************************************************/ +#ifndef __com_sun_star_awt_grid_XGridControl_idl__ +#define __com_sun_star_awt_grid_XGridControl_idl__ + +#include <com/sun/star/awt/grid/XGridSelection.idl> +#include <com/sun/star/awt/grid/XGridColumnModel.idl> +#include <com/sun/star/awt/grid/XGridDataModel.idl> +#include <com/sun/star/awt/XMouseListener.idl> + +//============================================================================= + +module com { module sun { module star { module awt { module grid { + +//============================================================================= + +/** An interface to a control that displays a tabular data. + + @see UnoControlGrid + */ +interface XGridControl: XGridSelection +{ + /** Specifies the <type>XGridColumnModel</type> of the control. + */ + [attribute] XGridColumnModel ColumnModel; + + /** Specifies the <type>XGridDataModel</type> of the control. + */ + [attribute] XGridDataModel DataModel; + + + /** Converting + */ + + long getItemIndexAtPoint( [in] long x, [in] long y); + + /** registers a listener for mouse events. + */ + //[oneway] void addMouseListener( [in] com::sun::star::awt::XMouseListener listener ); + + /** unregisters a listener for mouse events. + */ + //[oneway] void removeMouseListener( [in] com::sun::star::awt::XMouseListener listener ); + +}; + +//============================================================================= + +}; }; }; }; }; + +#endif diff --git a/offapi/com/sun/star/awt/grid/XGridControlListener.idl b/offapi/com/sun/star/awt/grid/XGridControlListener.idl new file mode 100644 index 000000000000..c7fa1fd41e2f --- /dev/null +++ b/offapi/com/sun/star/awt/grid/XGridControlListener.idl @@ -0,0 +1,52 @@ +/************************************************************************* + * + * 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: XListBox.idl,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. + * + ************************************************************************/ +#ifndef __com_sun_star_awt_grid_XGridControlListener_idl__ +#define __com_sun_star_awt_grid_XGridControlListener_idl__ + +#ifndef __com_sun_star_uno_XInterface_idl__ +#include <com/sun/star/uno/XInterface.idl> +#endif + +//============================================================================= + +module com { module sun { module star { module awt { module grid { + +//============================================================================= + +interface XGridControlListener: com::sun::star::uno::XInterface +{ + +}; + +//============================================================================= + +}; }; }; }; }; + +#endif diff --git a/offapi/com/sun/star/awt/grid/XGridDataListener.idl b/offapi/com/sun/star/awt/grid/XGridDataListener.idl new file mode 100644 index 000000000000..ce6479496034 --- /dev/null +++ b/offapi/com/sun/star/awt/grid/XGridDataListener.idl @@ -0,0 +1,76 @@ +/************************************************************************* + * + * 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: XListBox.idl,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. + * + ************************************************************************/ +#ifndef __com_sun_star_awt_grid_XGridDataListener_idl__ +#define __com_sun_star_awt_grid_XGridDataListener_idl__ + +#ifndef __com_sun_star_awt_grid_GridDataEvent_idl__ +#include <com/sun/star/awt/grid/GridDataEvent.idl> +#endif + +#ifndef __com_sun_star_lang_XEventListener_idl__ +#include <com/sun/star/lang/XEventListener.idl> +#endif + +//============================================================================= + +module com { module sun { module star { module awt { module grid { + +//============================================================================= + +/** An instance of this interface is used by the <type>XGridDataModel</type> to + get notifications about data model changes. + + <p>Usually you must not implement this interface yourself, but you must notify it correctly if + you implement the <type>XGridDataModel</type> yourself</p>. + */ +interface XGridDataListener: com::sun::star::lang::XEventListener +{ + + /** + Invoked after a row was added to the data model. + */ + void rowAdded( [in] GridDataEvent Event ); + + /** + Invoked after a row was added to the data model. + */ + void rowRemoved( [in] GridDataEvent Event ); + + /** + Invoked after a row was added to the data model. + */ + void dataChanged( [in] GridDataEvent Event ); +}; + +//============================================================================= + +}; }; }; }; }; + +#endif diff --git a/offapi/com/sun/star/awt/grid/XGridDataModel.idl b/offapi/com/sun/star/awt/grid/XGridDataModel.idl new file mode 100644 index 000000000000..17e224fa6b41 --- /dev/null +++ b/offapi/com/sun/star/awt/grid/XGridDataModel.idl @@ -0,0 +1,110 @@ +/************************************************************************* + * + * 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: XListBox.idl,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. + * + ************************************************************************/ +#ifndef __com_sun_star_awt_grid_XGridDataModel_idl__ +#define __com_sun_star_awt_grid_XGridDataModel_idl__ + + +#include <com/sun/star/lang/XComponent.idl> +#include <com/sun/star/awt/grid/XGridDataListener.idl> + + +//============================================================================= + +module com { module sun { module star { module awt { module grid { + +//============================================================================= +/** An instance of this interface is used by the <type>UnoControlGrid</type> to + retrieve the content data that is displayed in the actual control. + + If you do not need your own model implementation, you can also use the <type>DefaultGridDataModel</type>. +*/ +interface XGridDataModel: ::com::sun::star::lang::XComponent +{ + /** Specifies the height of each row. + */ + [attribute] long RowHeight; + + /** Contains the row header. + */ + [attribute] sequence< string > RowHeaders; + + /** Returns the content of each row. + */ + [attribute,readonly] sequence< sequence< string > > Data; + + /** Returns the number of rows in in the model. + @returns + the number of rows. + */ + long getRowCount(); + + /** Adds a row to the model. + + @param headername + specifies the name of the row. + @param data + the content of the row. + */ + void addRow( [in] string headername, [in] sequence< string > data ); + + /** Removes a row from the model. + + @param index + the index of the row that should be removed. + */ + void removeRow( [in] long index); + + /** Removes all rows from the model. + */ + void removeAll(); + + //------------------------------------------------------------------------- + + /** Adds a listener for the <type>GridDataEvent</type> posted after the grid changes. + @param Listener + the listener to add. + */ + [oneway] void addDataListener( [in] XGridDataListener listener); + + //------------------------------------------------------------------------- + + /** Removes a listener previously added with <method>addDataListener()</method>. + @param Listener + the listener to remove. + */ + [oneway] void removeDataListener( [in] XGridDataListener listener); + +}; + +//============================================================================= + +}; }; }; };}; + +#endif diff --git a/offapi/com/sun/star/awt/grid/XGridSelection.idl b/offapi/com/sun/star/awt/grid/XGridSelection.idl new file mode 100644 index 000000000000..b567b7570ddc --- /dev/null +++ b/offapi/com/sun/star/awt/grid/XGridSelection.idl @@ -0,0 +1,126 @@ +/************************************************************************* + * + * 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: XListBox.idl,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. + * + ************************************************************************/ +#ifndef __com_sun_star_awt_grid_XGridSelection_idl__ +#define __com_sun_star_awt_grid_XGridSelection_idl__ + +#include <com/sun/star/uno/XInterface.idl> +#include <com/sun/star/awt/grid/XGridSelectionListener.idl> +#include <com/sun/star/view/SelectionType.idl> + +//============================================================================= + +module com { module sun { module star { module awt { module grid { + +//============================================================================= + +/** This interfaces provides access to the selection of row for <type>UnoControlGrid</type>. + */ +interface XGridSelection: com::sun::star::uno::XInterface +{ + /** Returns the lowest index of the selection. + @returns + the lowest index. + */ + long getMinSelectionIndex(); + + /** Returns the highest index of the selection. + @returns + the highest index. + */ + long getMaxSelectionIndex(); + + /** Adds a selection intervall. + @param start + the start row index. + @param length + the number of rows to be selected. + */ + [oneway] void insertIndexIntervall( [in] long start, [in] long length); + + /** Removes a selection intervall. + @param start + the start row index. + @param length + the number of rows to be selected. + */ + [oneway] void removeIndexIntervall( [in] long start, [in] long length); + + /** Returns the indicies of all selected rows. + @returns + a sequence of indicies. + */ + sequence< long > getSelection(); + + /** Returns whether rows are selected. + @returns + <true/> if rows are selected otherwise <false/>. + */ + boolean isSelectionEmpty(); + + /** Returns whether a specific row is selected. + @param + the index of a row. + @returns + <true/> if row are selected otherwise <false/>. + */ + boolean isSelectedIndex( [in] long index); + + /** Marks a row as selected. + @param + the index of a row. + */ + [oneway] void selectRow( [in] long y); + + /* + [oneway] void selectColumn( [in] long x); + */ + + /** Adds a listener for the <type>GridSelectionEvent</type> posted after the grid changes. + @param Listener + the listener to add. + */ + [oneway] void addSelectionListener( [in] XGridSelectionListener listener); + + //------------------------------------------------------------------------- + + /** Removes a listener previously added with <method>addSelectionListener()</method>. + @param Listener + the listener to remove. + */ + [oneway] void removeSelectionListener( [in] XGridSelectionListener listener); + + +}; + +//============================================================================= + +}; }; }; }; }; + +#endif diff --git a/offapi/com/sun/star/awt/grid/XGridSelectionListener.idl b/offapi/com/sun/star/awt/grid/XGridSelectionListener.idl new file mode 100644 index 000000000000..eba8d794d3c0 --- /dev/null +++ b/offapi/com/sun/star/awt/grid/XGridSelectionListener.idl @@ -0,0 +1,66 @@ +/************************************************************************* + * + * 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: XListBox.idl,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. + * + ************************************************************************/ +#ifndef __com_sun_star_awt_grid_XGridSelectionListener_idl__ +#define __com_sun_star_awt_grid_XGridSelectionListener_idl__ + +#ifndef __com_sun_star_lang_XEventListener_idl__ +#include <com/sun/star/lang/XEventListener.idl> +#endif + +#ifndef __com_sun_star_awt_grid_GridSelectionEvent_idl__ +#include <com/sun/star/awt/grid/GridSelectionEvent.idl> +#endif + +//============================================================================= + +module com { module sun { module star { module awt { module grid { + +//============================================================================= + +/** An instance of this interface is used by the <type>XGridSelection</type> to + get notifications about selection changes. + + <p>Usually you must not implement this interface yourself, but you must notify it correctly if + you implement the <type>XGridSelection</type> yourself</p>. + */ +interface XGridSelectionListener: com::sun::star::lang::XEventListener +{ + //------------------------------------------------------------------------- + /** Invoked after a selection was changed. + */ + [oneway] void selectionChanged( [in] GridSelectionEvent gridSelectionEvent); + +}; + +//============================================================================= + +}; }; }; }; }; + +#endif diff --git a/offapi/com/sun/star/awt/grid/makefile.mk b/offapi/com/sun/star/awt/grid/makefile.mk new file mode 100644 index 000000000000..124ca44edd09 --- /dev/null +++ b/offapi/com/sun/star/awt/grid/makefile.mk @@ -0,0 +1,68 @@ +#************************************************************************* +# +# 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: makefile.mk,v $ +# +# $Revision: 1.3 $ +# +# 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. +# +#************************************************************************* + +PRJ=..$/..$/..$/..$/.. + +PRJNAME=api + +TARGET=cssawtgrid +PACKAGE=com$/sun$/star$/awt$/grid + +# --- Settings ----------------------------------------------------- + +.INCLUDE : $(PRJ)$/util$/makefile.pmk + +# ------------------------------------------------------------------------ +IDLFILES=\ + GridColumnEvent.idl\ + GridControlEvent.idl\ + GridDataEvent.idl\ + SelectionEventType.idl\ + GridSelectionEvent.idl\ + XGridControlListener.idl\ + XGridSelectionListener.idl\ + XGridSelection.idl\ + XGridColumn.idl\ + XGridColumnListener.idl\ + XGridDataListener.idl\ + XGridCell.idl\ + XGridCellRenderer.idl\ + DefaultGridDataModel.idl\ + XGridDataModel.idl\ + XGridColumnModel.idl\ + ScrollBarMode.idl\ + XGridControl.idl\ + UnoControlGrid.idl\ + UnoControlGridModel.idl +# ------------------------------------------------------------------ + +.INCLUDE : target.mk +.INCLUDE : $(PRJ)$/util$/target.pmk diff --git a/offapi/com/sun/star/awt/makefile.mk b/offapi/com/sun/star/awt/makefile.mk index ff4d827a298b..dd2e9857124c 100644 --- a/offapi/com/sun/star/awt/makefile.mk +++ b/offapi/com/sun/star/awt/makefile.mk @@ -127,6 +127,7 @@ IDLFILES=\ MessageBoxCommand.idl\ MouseButton.idl\ MouseEvent.idl\ + MouseWheelBehavior.idl\ PaintEvent.idl\ Point.idl\ PopupMenuDirection.idl\ @@ -304,6 +305,7 @@ IDLFILES=\ XToggleButton.idl\ XToolkit.idl\ XTopWindow.idl\ + XTopWindow2.idl\ XTopWindowListener.idl\ XUnitConversion.idl\ XUnoControlContainer.idl\ diff --git a/offapi/com/sun/star/awt/tree/XTreeDataModelListener.idl b/offapi/com/sun/star/awt/tree/XTreeDataModelListener.idl index 81e98b301954..8ea308f69a6f 100644 --- a/offapi/com/sun/star/awt/tree/XTreeDataModelListener.idl +++ b/offapi/com/sun/star/awt/tree/XTreeDataModelListener.idl @@ -62,7 +62,7 @@ interface XTreeDataModelListener: com::sun::star::lang::XEventListener Example: the name of a file has changed, but it is in the same location in the file system. To indicate the root has changed, <member>TreeDataModelEvent::Nodes</member> will contain - the root node and and <member>TreeDataModelEvent::ParentNode</member will be empty. + the root node and <member>TreeDataModelEvent::ParentNode</member> will be empty. */ void treeNodesChanged( [in] TreeDataModelEvent Event ); diff --git a/offapi/com/sun/star/chart/BubbleDiagram.idl b/offapi/com/sun/star/chart/BubbleDiagram.idl new file mode 100644 index 000000000000..23a1088db9e6 --- /dev/null +++ b/offapi/com/sun/star/chart/BubbleDiagram.idl @@ -0,0 +1,69 @@ +/************************************************************************* + * + * 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: BubbleDiagram.idl,v $ + * $Revision: 1.10 $ + * + * 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. + * + ************************************************************************/ +#ifndef __com_sun_star_chart_BubbleDiagram_idl__ +#define __com_sun_star_chart_BubbleDiagram_idl__ + +#ifndef __com_sun_star_chart_Diagram_idl__ +#include <com/sun/star/chart/Diagram.idl> +#endif + +#ifndef __com_sun_star_chart_ChartAxisXSupplier_idl__ +#include <com/sun/star/chart/ChartAxisXSupplier.idl> +#endif + +#ifndef __com_sun_star_chart_ChartTwoAxisYSupplier_idl__ +#include <com/sun/star/chart/ChartTwoAxisYSupplier.idl> +#endif + +#ifndef __com_sun_star_chart_ChartStatistics_idl__ +#include <com/sun/star/chart/ChartStatistics.idl> +#endif + +//============================================================================= + + module com { module sun { module star { module chart { + +//============================================================================= + +/** a service for bubble diagrams. @since OOo 3.2 + */ +published service BubbleDiagram +{ + service com::sun::star::chart::Diagram; + service com::sun::star::chart::ChartAxisXSupplier; + service com::sun::star::chart::ChartTwoAxisYSupplier; + [optional] service com::sun::star::chart::ChartStatistics; +}; + +//============================================================================= + +}; }; }; }; + +#endif diff --git a/offapi/com/sun/star/chart/FilledNetDiagram.idl b/offapi/com/sun/star/chart/FilledNetDiagram.idl new file mode 100644 index 000000000000..64fba52e3339 --- /dev/null +++ b/offapi/com/sun/star/chart/FilledNetDiagram.idl @@ -0,0 +1,72 @@ +/************************************************************************* + * + * 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: FilledNetDiagram.idl,v $ + * $Revision: 1.10 $ + * + * 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. + * + ************************************************************************/ +#ifndef __com_sun_star_chart_FilledNetDiagram_idl__ +#define __com_sun_star_chart_FilledNetDiagram_idl__ + +#ifndef __com_sun_star_chart_Diagram_idl__ +#include <com/sun/star/chart/Diagram.idl> +#endif + +#ifndef __com_sun_star_chart_StackableDiagram_idl__ +#include <com/sun/star/chart/StackableDiagram.idl> +#endif + +#ifndef __com_sun_star_chart_ChartAxisXSupplier_idl__ +#include <com/sun/star/chart/ChartAxisXSupplier.idl> +#endif + +#ifndef __com_sun_star_chart_ChartAxisYSupplier_idl__ +#include <com/sun/star/chart/ChartAxisYSupplier.idl> +#endif + + +//============================================================================= + + module com { module sun { module star { module chart { + +//============================================================================= + +/** specifies filled net diagrams. @since OOo 3.2 + + <p>Net diagrams are also known as radar diagrams.</p> + */ +published service FilledNetDiagram +{ + service com::sun::star::chart::Diagram; + service com::sun::star::chart::ChartAxisXSupplier; + service com::sun::star::chart::ChartAxisYSupplier; + service com::sun::star::chart::StackableDiagram; +}; + +//============================================================================= + +}; }; }; }; + +#endif diff --git a/offapi/com/sun/star/chart/makefile.mk b/offapi/com/sun/star/chart/makefile.mk index 359f07a15224..781c78d08177 100644 --- a/offapi/com/sun/star/chart/makefile.mk +++ b/offapi/com/sun/star/chart/makefile.mk @@ -46,6 +46,7 @@ IDLFILES=\ AccessibleChartDocumentView.idl\ AreaDiagram.idl\ BarDiagram.idl\ + BubbleDiagram.idl\ Chart3DBarProperties.idl\ ChartArea.idl\ ChartAxis.idl\ @@ -90,6 +91,7 @@ IDLFILES=\ Diagram.idl\ Dim3DDiagram.idl\ DonutDiagram.idl\ + FilledNetDiagram.idl\ LineDiagram.idl\ MissingValueTreatment.idl\ NetDiagram.idl\ diff --git a/offapi/com/sun/star/chart2/XDataSeries.idl b/offapi/com/sun/star/chart2/XDataSeries.idl index 206dac223578..eeebc966511c 100644 --- a/offapi/com/sun/star/chart2/XDataSeries.idl +++ b/offapi/com/sun/star/chart2/XDataSeries.idl @@ -58,22 +58,28 @@ module chart2 */ interface XDataSeries : ::com::sun::star::uno::XInterface { - /** set the coordinate system in which this series should be - represented. - */ -// void setCoordinateSystem( [in] XCoordinateSystem aCoordSystem ); - /** @returns the element at the specified index. - @param Index - specifies the position in the array. The first index is 0. + @param nIndex + specifies the index of the data point within the series. The first index is 0. @throws com::sun::star::lang::IndexOutOfBoundException if the index is not valid. */ ::com::sun::star::beans::XPropertySet getDataPointByIndex( [in] long nIndex ) raises( ::com::sun::star::lang::IndexOutOfBoundsException ); + + /** the formatting of the specified data point is cleared + + @param nIndex + specifies the index of the data point within the series. The first index is 0. + */ + void resetDataPoint( [in] long nIndex ); + + /** all data point formattings are cleared + */ + void resetAllDataPoints(); }; } ; // chart2 diff --git a/offapi/com/sun/star/chart2/XDefaultSizeTransmitter.idl b/offapi/com/sun/star/chart2/XDefaultSizeTransmitter.idl new file mode 100644 index 000000000000..a834bb310eda --- /dev/null +++ b/offapi/com/sun/star/chart2/XDefaultSizeTransmitter.idl @@ -0,0 +1,67 @@ +/************************************************************************* + * + * 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: XDefaultSizeTransmitter.idl,v $ + * $Revision: 1.3 $ + * + * 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. + * + ************************************************************************/ +#ifndef com_sun_star_chart2_xdefaultsizetransmitter_idl +#define com_sun_star_chart2_xdefaultsizetransmitter_idl + +#ifndef __com_sun_star_uno_XInterface_idl__ +#include <com/sun/star/uno/XInterface.idl> +#endif + +#ifndef __com_sun_star_awt_Size_idl__ +#include <com/sun/star/awt/Size.idl> +#endif + +module com +{ +module sun +{ +module star +{ +module chart2 +{ + +/** Allows to set a default size. This size will be used in case no further informations are available. + */ +interface XDefaultSizeTransmitter : ::com::sun::star::uno::XInterface +{ + /** set a default size + @param aSize_100TH_MM + specifies a size in hundredth mm. + */ + void setDefaultSize( [in] ::com::sun::star::awt::Size aSize_100TH_MM ); +}; + +} ; // chart2 +} ; // com +} ; // sun +} ; // star + + +#endif diff --git a/offapi/com/sun/star/chart2/makefile.mk b/offapi/com/sun/star/chart2/makefile.mk index d82862c69268..700ecc633d7a 100644 --- a/offapi/com/sun/star/chart2/makefile.mk +++ b/offapi/com/sun/star/chart2/makefile.mk @@ -85,6 +85,7 @@ IDLFILES= \ XDataInterpreter.idl \ XDataSeries.idl \ XDataSeriesContainer.idl \ + XDefaultSizeTransmitter.idl \ XDiagram.idl \ XDiagramProvider.idl \ XFastPropertyState.idl \ diff --git a/offapi/com/sun/star/deployment/XPackage.idl b/offapi/com/sun/star/deployment/XPackage.idl index 4847f09090a2..36799875eee1 100644 --- a/offapi/com/sun/star/deployment/XPackage.idl +++ b/offapi/com/sun/star/deployment/XPackage.idl @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: XPackage.idl,v $ - * $Revision: 1.14 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -102,6 +99,25 @@ interface XPackage com::sun::star::ucb::CommandFailedException, com::sun::star::ucb::CommandAbortedException); + /** checks if the dependencies for this package are still satisfied + + After updateing the OpenOffice.org, some dependencies for packages might + no longer be satisfied. + + @since OOo 3.2.0 + + @param xCmdEnv + command environment for error handling and other interaction. + + @return + true - all dependencies are satisfied + false - at least one dependency failed. + */ + boolean checkDependencies( + [in] com::sun::star::ucb::XCommandEnvironment xCmdEnv ) + raises (DeploymentException, + com::sun::star::ucb::CommandFailedException); + /** determines whether the package is currently is registered, i.e. whether it is active. diff --git a/offapi/com/sun/star/deployment/ui/UpdateRequiredDialog.idl b/offapi/com/sun/star/deployment/ui/UpdateRequiredDialog.idl new file mode 100644 index 000000000000..761070eb7443 --- /dev/null +++ b/offapi/com/sun/star/deployment/ui/UpdateRequiredDialog.idl @@ -0,0 +1,54 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2009 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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. + * + ************************************************************************/ + +#if ! defined INCLUDED_com_sun_star_deployment_ui_UpdateRequiredDialog_idl +#define INCLUDED_com_sun_star_deployment_ui_UpdateRequiredDialog_idl + +#include <com/sun/star/ui/dialogs/XExecutableDialog.idl> +#include <com/sun/star/awt/XWindow.idl> + + +module com { module sun { module star { module deployment { module ui { + +/** The <type>UpdateRequiredDialog</type> is used to show a list of extensions not compatible with this office version. + + @since OOo 3.2.0 +*/ +service UpdateRequiredDialog : com::sun::star::ui::dialogs::XExecutableDialog +{ + /** Create a GUI using the specific parent window and focus on the + given context. + + @param xParent + parent window + */ + create(); +}; + +}; }; }; }; }; + +#endif diff --git a/offapi/com/sun/star/deployment/ui/makefile.mk b/offapi/com/sun/star/deployment/ui/makefile.mk index d91d20001bb5..f733c762a80c 100644 --- a/offapi/com/sun/star/deployment/ui/makefile.mk +++ b/offapi/com/sun/star/deployment/ui/makefile.mk @@ -39,8 +39,9 @@ PACKAGE = com$/sun$/star$/deployment$/ui .INCLUDE : $(PRJ)$/util$/makefile.pmk IDLFILES = \ - PackageManagerDialog.idl \ - LicenseDialog.idl + PackageManagerDialog.idl \ + LicenseDialog.idl \ + UpdateRequiredDialog.idl .INCLUDE : target.mk .INCLUDE : $(PRJ)$/util$/target.pmk diff --git a/offapi/com/sun/star/document/DocumentEvent.idl b/offapi/com/sun/star/document/DocumentEvent.idl index 1391f9becaf5..0b5b2cd5a205 100644 --- a/offapi/com/sun/star/document/DocumentEvent.idl +++ b/offapi/com/sun/star/document/DocumentEvent.idl @@ -52,6 +52,7 @@ module com { module sun { module star { module document { anymore.</p> @see XDocumentEventBroadcaster + @since OpenOffice.org 3.1 */ struct DocumentEvent : ::com::sun::star::lang::EventObject { diff --git a/offapi/com/sun/star/document/MediaDescriptor.idl b/offapi/com/sun/star/document/MediaDescriptor.idl index 7fb3698f90b7..49c9cf285b3a 100644 --- a/offapi/com/sun/star/document/MediaDescriptor.idl +++ b/offapi/com/sun/star/document/MediaDescriptor.idl @@ -84,6 +84,12 @@ module com { module sun { module star { module document { published service MediaDescriptor { //------------------------------------------------------------------------- + /** May be set by filters or detection services if user has choosen to + abort loading/saving, e.g. while entering a password. + */ + [optional,property] boolean Aborted; + + //------------------------------------------------------------------------- /** document is a template <p> diff --git a/offapi/com/sun/star/document/PDFDialog.idl b/offapi/com/sun/star/document/PDFDialog.idl new file mode 100644 index 000000000000..91d2628e3eab --- /dev/null +++ b/offapi/com/sun/star/document/PDFDialog.idl @@ -0,0 +1,67 @@ +/************************************************************************* + * + * 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:$ + * $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. + * + ************************************************************************/ +#ifndef __com_sun_star_document_PDFDialog_idl__ +#define __com_sun_star_document_PDFDialog_idl__ + +#ifndef __com_sun_star_ui_dialogs_FilterOptionsDialog_idl__ +#include <com/sun/star/ui/dialogs/FilterOptionsDialog.idl> +#endif + +//============================================================================= + +module com { module sun { module star { module document { + +//============================================================================= + +/** This service is for a PDFDialog + */ +service PDFDialog +{ + service com::sun::star::ui::dialogs::FilterOptionsDialog; + + //------------------------------------------------------------------------- + /** PDFDialog options can be set as sequence of + com.sun.star.beans.PropertyValue at the FilterData property of the + MediaDescriptor. The PropertyValues which are supported within the + sequence are described in the registry at Office.Common/Filter/PDF/Export + + The source of this registry can be found in following file: + "officecfg/registry/schema/org/openoffice/Office/Common.xcs" + */ + + //------------------------------------------------------------------------- +}; + +//============================================================================= + +}; }; }; }; + +#endif + diff --git a/offapi/com/sun/star/document/XDocumentEventBroadcaster.idl b/offapi/com/sun/star/document/XDocumentEventBroadcaster.idl index 596adf722ea8..5780d3f92bbf 100644 --- a/offapi/com/sun/star/document/XDocumentEventBroadcaster.idl +++ b/offapi/com/sun/star/document/XDocumentEventBroadcaster.idl @@ -61,6 +61,7 @@ interface XDocumentEventListener; anymore.</p> @see DocumentEvent + @since OpenOffice.org 3.1 */ interface XDocumentEventBroadcaster { diff --git a/offapi/com/sun/star/document/XDocumentEventListener.idl b/offapi/com/sun/star/document/XDocumentEventListener.idl index 345e320cecae..b98d81a73251 100644 --- a/offapi/com/sun/star/document/XDocumentEventListener.idl +++ b/offapi/com/sun/star/document/XDocumentEventListener.idl @@ -50,6 +50,7 @@ module com { module sun { module star { module document { anymore.</p> @see XDocumentEventBroadcaster + @since OpenOffice.org 3.1 */ interface XDocumentEventListener : ::com::sun::star::lang::XEventListener { diff --git a/offapi/com/sun/star/document/makefile.mk b/offapi/com/sun/star/document/makefile.mk index f196d99fe095..3bc2db2f9e46 100644 --- a/offapi/com/sun/star/document/makefile.mk +++ b/offapi/com/sun/star/document/makefile.mk @@ -71,6 +71,7 @@ IDLFILES=\ OfficeDocument.idl\ OleEmbeddedServerRegistration.idl\ OwnLockOnDocumentRequest.idl\ + PDFDialog.idl\ PrinterIndependentLayout.idl\ RedlineDisplayType.idl \ Settings.idl\ @@ -105,7 +106,7 @@ IDLFILES=\ XLinkTargetSupplier.idl\ XMimeTypeInfo.idl\ XOOXMLDocumentPropertiesImporter.idl\ - XRedlinesSupplier.idl \ + XRedlinesSupplier.idl \ XScriptInvocationContext.idl\ XStandaloneDocumentInfo.idl\ XStorageBasedDocument.idl\ diff --git a/offapi/com/sun/star/drawing/FillProperties.idl b/offapi/com/sun/star/drawing/FillProperties.idl index 47749376a7d5..9aaedfed601f 100644 --- a/offapi/com/sun/star/drawing/FillProperties.idl +++ b/offapi/com/sun/star/drawing/FillProperties.idl @@ -70,21 +70,21 @@ module com { module sun { module star { module drawing { published service FillProperties { //------------------------------------------------------------------------- - /** This enumeration selects the style with which the area will be filled. + /** This enumeration selects the style the area will be filled with. */ - [property] com::sun::star::drawing::FillStyle FillStyle; + [property] FillStyle FillStyle; //------------------------------------------------------------------------- - /** If the <type>FillStyle</type> is set to <const>FillStyle::SOLID</const>, - this is the color used. + /** If the property <member>FillStyle</member> is set to <const> + FillStyle::SOLID</const>, this is the color used. */ [property] com::sun::star::util::Color FillColor; //------------------------------------------------------------------------- /** This is the transparence of the filled area. - <p>This property is only valid if <type>FillStyle</type> is set to - <const>FillStyle::SOLID</const>. + <p>This property is only valid if the property <member>FillStyle + </member> is set to <const>FillStyle::SOLID</const>. */ [property] short FillTransparence; @@ -103,117 +103,168 @@ published service FillProperties [optional, property] com::sun::star::awt::Gradient FillTransparenceGradient; //------------------------------------------------------------------------- - /** If the <type>FillStyle</type> is set to <const>FillStyle::GRADIENT</const>, this - is the name of the used fill gradient style. + /** If the property <member>FillStyle</member> is set to <const> + FillStyle::GRADIENT</const>, this is the name of the used fill + gradient style. */ [property] string FillGradientName; //------------------------------------------------------------------------- - /** If the <type>FillStyle</type> is set to <const>FillStyle::GRADIENT</const>, this - describes the gradient used. + /** If the property <member>FillStyle</member> is set to <const> + FillStyle::GRADIENT</const>, this describes the gradient used. */ [optional, property] com::sun::star::awt::Gradient FillGradient; //------------------------------------------------------------------------- - /** If the <type>FillStyle</type> is set to <const>FillStyle::GRADIENT</const>, this - is the name of the used fill hatch style. + /** If the property <member>FillStyle</member> is set to <const> + FillStyle::HATCH</const>, this is the name of the used fill hatch + style. */ [property] string FillHatchName; //------------------------------------------------------------------------- - /** If the <type>FillStyle</type> is set to <const>FillStyle::HATCH</const>, this - describes the hatch used. + /** If the property <member>FillStyle</member> is set to <const> + FillStyle::HATCH</const>, this describes the hatch used. */ - [optional, property] com::sun::star::drawing::Hatch FillHatch; + [optional, property] Hatch FillHatch; //------------------------------------------------------------------------- - /** If the <type>FillStyle</type> is set to <const>FillStyle::BITMAP</const>, this is - the name of the used fill bitmap style. + /** if this is <TRUE/>, the transparent background of a + hatch filled area is drawn in the current background color. + */ + [property] boolean FillBackground; + + //------------------------------------------------------------------------- + /** If the property <memebr>FillStyle</member> is set to <const> + FillStyle::BITMAP</const>, this is the name of the used fill bitmap + style. */ [property] string FillBitmapName; //------------------------------------------------------------------------- - /** If the <type>FillStyle</type> is set to <const>FillStyle::BITMAP</const>, this is - the bitmap used. + /** If the property <member>FillStyle</member> is set to <const> + FillStyle::BITMAP</const>, this is the bitmap used. */ [optional, property] com::sun::star::awt::XBitmap FillBitmap; //------------------------------------------------------------------------- - /** If the <type>FillStyle</type> is set to <const>FillStyle::BITMAP</const>, this is - a URL to the bitmap used. + /** If the property <member>FillStyle</member> is set to <const> + FillStyle::BITMAP</const>, this is a URL to the bitmap used. */ [optional, property] string FillBitmapURL; //------------------------------------------------------------------------- /** This is the horizontal offset where the tile starts. - <p>It is given in percent in relation to the width of the bitmap. + <p>It is given in percent in relation to the width of the bitmap.</p> */ - [property] short FillBitmapOffsetX; + [property] short FillBitmapPositionOffsetX; //------------------------------------------------------------------------- /** This is the vertical offset where the tile starts. - It is given in percent in relation to the width of the bitmap. + <p>It is given in percent in relation to the height of the bitmap.</p> */ - [property] short FillBitmapOffsetY; + [property] short FillBitmapPositionOffsetY; //------------------------------------------------------------------------- /** Every second line of tiles is moved the given percent of the witdh of the bitmap. */ - [property] short FillBitmapPositionOffsetX; + [property] short FillBitmapOffsetX; //------------------------------------------------------------------------- /** Every second row of tiles is moved the given percent of the - width of the bitmap. + height of the bitmap. */ - [property] short FillBitmapPositionOffsetY; + [property] short FillBitmapOffsetY; //------------------------------------------------------------------------- /** The RectanglePoint specifies the position inside of the bitmap to use as the top left position for rendering. */ - [property] com::sun::star::drawing::RectanglePoint FillBitmapRectanglePoint; + [property] RectanglePoint FillBitmapRectanglePoint; //------------------------------------------------------------------------- - /** specifies if the size is given in percentage or - as an absolute value. + /** specifies if the size is given in percentage or as an absolute value. - <p>If this is <TRUE/>, the properties FillBitmapSizeX - and FillBitmapSizeY contain the size of the tile in percent - of the size of the original bitmap. If this - is <FALSE/>, the size of the tile is specified - with 1/100th mm. + <p>If this is <TRUE/>, the properties <member>FillBitmapSizeX</member> + and <member>FillBitmapSizeY</member> contain the size of the tile in + percent of the size of the original bitmap. If this is <FALSE/>, the + size of the tile is specified with 1/100th mm. */ [property] boolean FillBitmapLogicalSize; //------------------------------------------------------------------------- /** This is the width of the tile for filling. - <p>Depending on the property FillBitmapLogicalSize, this is - either relative or absolute. + <p>Depending on the property <member>FillBitmapLogicalSize</member>, + this is either relative or absolute. */ [property] long FillBitmapSizeX; //------------------------------------------------------------------------- /** This is the height of the tile for filling. - <p>Depending on the property FillBitmapLogicalSize, this - is either relative or absolute. + <p>Depending on the property <member>FillBitmapLogicalSize</member>, + this is either relative or absolute. */ [property] long FillBitmapSizeY; //------------------------------------------------------------------------- /** this enum selects how a area is filled with a single bitmap. + + <p>This property corresponds to the properties <member> + FillBitmapStretch</member> and <member>FillBitmapTile</member>.</p> + + <p>If set to <const>BitmapMode::REPEAT</const>, the property + FillBitmapStretch is set to <FALSE/>, and the property FillBitmapTile + is set to <TRUE/>.</p> + + <p>If set to <const>BitmapMode::STRETCH</const>, the property + FillBitmapStretch is set to <TRUE/>, and the property FillBitmapTile + is set to <FALSE/>.</p> + + <p>If set to <const>BitmapMode::NO_REPEAT</const>, both properties + FillBitmapStretch and FillBitmapTile are set to <FALSE/>.</p> */ - [property] com::sun::star::drawing::BitmapMode FillBitmapMode; + [property] BitmapMode FillBitmapMode; //------------------------------------------------------------------------- - /** if this is <TRUE/>, the transparent background of a - hatch filled area is drawn in the current background color - */ - [property] boolean FillBackground; + /** if set, the fill bitmap is stretched to fill the area of the shape. + + <p>This property should not be used anymore and is included here for + completeness. The <member>FillBitmapMode</member> property can be used + instead to set all supported bitmap modes.</p> + + <p>If set to <TRUE/>, the value of the FillBitmapMode property changes + to <const>BitmapMode::STRETCH</const>. BUT: behaviour is undefined, if + the property <member>FillBitmapTile</member> is <TRUE/> too.</p> + + <p>If set to <FALSE/>, the value of the FillBitmapMode property + changes to <const>BitmapMode::REPEAT</const> or <const> + BitmapMode::NO_REPEAT</const>, depending on the current value of the + <member>FillBitmapTile</member> property.</p> + */ + [optional, property] boolean FillBitmapStretch; + + //------------------------------------------------------------------------- + /** if set, the fill bitmap is repeated to fill the area of the shape. + + <p>This property should not be used anymore and is included here for + completeness. The <member>FillBitmapMode</member> property can be used + instead to set all supported bitmap modes.</p> + + <p>If set to <TRUE/>, the value of the FillBitmapMode property changes + to <const>BitmapMode::REPEAT</const>. BUT: behaviour is undefined, if + the property <member>FillBitmapStretch</member> is <TRUE/> too.</p> + + <p>If set to <FALSE/>, the value of the FillBitmapMode property + changes to <const>BitmapMode::STRETCH</const> or <const> + BitmapMode::NO_REPEAT</const>, depending on the current value of the + <member>FillBitmapStretch</member> property.</p> + */ + [optional, property] boolean FillBitmapTile; //------------------------------------------------------------------------- }; diff --git a/offapi/com/sun/star/drawing/framework/XPane2.idl b/offapi/com/sun/star/drawing/framework/XPane2.idl new file mode 100644 index 000000000000..d1b646f73a31 --- /dev/null +++ b/offapi/com/sun/star/drawing/framework/XPane2.idl @@ -0,0 +1,79 @@ +/************************************************************************* + * + * 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: XPane.idl,v $ + * $Revision: 1.4 $ + * + * 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. + * + ************************************************************************/ + +#ifndef __com_sun_star_drawing_framework_XPane2_idl__ +#define __com_sun_star_drawing_framework_XPane2_idl__ + +#ifndef __com_sun_star_accessibility_XAccessible_idl__ +#include <com/sun/star/accessibility/XAccessible.idl> +#endif + +module com { module sun { module star { module drawing { module framework { + +/** An extension of the XPane interface that adds support for + a) showing and hiding the windows that internally belong to the pane and + b) setting the accessibility object. + This is typically an optional interface. +*/ +interface XPane2 +{ + /** Return whether all windows that are used to implement the pane are + visible. + @Returns <TRUE> when all windows of the pane are visible. + */ + boolean isVisible (); + + /** Hide or show the pane. If there is more than one window used to + implement the pane then it is left to the implementation if one, + some, or all windows are hidden or shown as long as the pane becomes + hidden or visible. + @param bIsVisible + When <TRUE> then show the pane. Hide it otherwise. + */ + void setVisible ([in] boolean bIsVisible); + + /** Set the accessibility object for the pane. When there is more than + one window used to implement the pane then the given accessibility + object is usually set at the topmost window. However, the details + are implementation dependent. + @param xAccessible + May be an empty reference. + */ + void setAccessible ([in] ::com::sun::star::accessibility::XAccessible xAccessible); + + /** Return the accessibility object that is currently associated with + the windows that implement the pane. + */ + ::com::sun::star::accessibility::XAccessible getAccessible (); +}; + +}; }; }; }; }; // ::com::sun::star::drawing::framework + +#endif diff --git a/offapi/com/sun/star/drawing/framework/makefile.mk b/offapi/com/sun/star/drawing/framework/makefile.mk index 9b6706ad14d6..b5dd8cbcc936 100644 --- a/offapi/com/sun/star/drawing/framework/makefile.mk +++ b/offapi/com/sun/star/drawing/framework/makefile.mk @@ -62,6 +62,7 @@ IDLFILES= \ XControllerManager.idl \ XModuleController.idl \ XPane.idl \ + XPane2.idl \ XPaneBorderPainter.idl \ XRelocatableResource.idl \ XResource.idl \ diff --git a/offapi/com/sun/star/embed/Storage.idl b/offapi/com/sun/star/embed/Storage.idl index b7c85707cf7f..70e91a66e765 100644 --- a/offapi/com/sun/star/embed/Storage.idl +++ b/offapi/com/sun/star/embed/Storage.idl @@ -347,6 +347,19 @@ service Storage </p> */ [property, optional, readonly] boolean HasEncryptedEntries; + + // ----------------------------------------------------------------------- + /** allows to detect if the storage contains nonencrypted entries. + + <p> + In case it is set to <TRUE/> the storage itself and/or a tree of + substorages contains nonencrypted streams. Usually in case this + property is supported the implementation supports + <type>XEncryptionProtectedSource</type> interface. + </p> + */ + [property, optional, readonly] boolean HasNonEncryptedEntries; + }; //============================================================================ diff --git a/offapi/com/sun/star/form/XErrorListener.idl b/offapi/com/sun/star/form/XErrorListener.idl index 3865f8093d8b..9d9905d643f3 100644 --- a/offapi/com/sun/star/form/XErrorListener.idl +++ b/offapi/com/sun/star/form/XErrorListener.idl @@ -54,6 +54,7 @@ <p>Please do <em><b>not</b></em> use anymore, this interface is superseeded by <type scope="com::sun::star::sdb">XSQLErrorListener</type>.</p> +@since foo @deprecated */ published interface XErrorListener: com::sun::star::lang::XEventListener diff --git a/offapi/com/sun/star/frame/XSessionManagerListener2.idl b/offapi/com/sun/star/frame/XSessionManagerListener2.idl new file mode 100644 index 000000000000..51e8643e459a --- /dev/null +++ b/offapi/com/sun/star/frame/XSessionManagerListener2.idl @@ -0,0 +1,56 @@ +/************************************************************************* + * + * 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: XSessionManagerListener.idl,v $ + * $Revision: 1.4 $ + * + * 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. + * + ************************************************************************/ +#ifndef __com_sun_star_frame_XSessionManagerListener2_idl__ +#define __com_sun_star_frame_XSessionManagerListener2_idl__ + +#ifndef __com_sun_star_lang_XEventListener_idl__ +#include <com/sun/star/lang/XEventListener.idl> +#endif + +#ifndef __com_sun_star_frame_XSessionManagerListener_idl__ +#include <com/sun/star/frame/XSessionManagerListener.idl> +#endif +//============================================================================= + +module com { module sun { module star { module frame { + + interface XSessionManagerListener2 : XSessionManagerListener + { + /** doQuit gets called when the session manager has decided + the application should quit. Under these circumstances bringing up + further UI will usually be impossible and must be avoided. + */ + [oneway] void doQuit(); + }; + +}; }; }; }; + + +#endif diff --git a/offapi/com/sun/star/frame/makefile.mk b/offapi/com/sun/star/frame/makefile.mk index 789a0f6e499e..0d0650a701fb 100644 --- a/offapi/com/sun/star/frame/makefile.mk +++ b/offapi/com/sun/star/frame/makefile.mk @@ -142,6 +142,7 @@ IDLFILES=\ XRecordableDispatch.idl\ XSessionManagerClient.idl\ XSessionManagerListener.idl\ + XSessionManagerListener2.idl\ XStatusListener.idl\ XStatusbarController.idl\ XStorable.idl\ diff --git a/offapi/com/sun/star/linguistic2/Dictionary.idl b/offapi/com/sun/star/linguistic2/Dictionary.idl index 4687db6af15b..38f97b9df435 100644 --- a/offapi/com/sun/star/linguistic2/Dictionary.idl +++ b/offapi/com/sun/star/linguistic2/Dictionary.idl @@ -57,7 +57,7 @@ module com { module sun { module star { module linguistic2 { @see com::sun::star::linguistic2::DictionaryList @see com::sun::star::linguistic2::XSearchableDictionaryList - @since OOo 3.01 + @since OOo 3.0.1 */ service Dictionary { diff --git a/offapi/com/sun/star/linguistic2/LinguServiceEventFlags.idl b/offapi/com/sun/star/linguistic2/LinguServiceEventFlags.idl index 7f4d6d3a1524..8da91044d97c 100644 --- a/offapi/com/sun/star/linguistic2/LinguServiceEventFlags.idl +++ b/offapi/com/sun/star/linguistic2/LinguServiceEventFlags.idl @@ -62,7 +62,7 @@ published constants LinguServiceEventFlags //------------------------------------------------------------------------- /** Request new proofreading of the document - @since OOo 3.01 + @since OOo 3.0.1 */ const short PROOFREAD_AGAIN = 8; diff --git a/offapi/com/sun/star/linguistic2/ProofreadingResult.idl b/offapi/com/sun/star/linguistic2/ProofreadingResult.idl index d00a4ed8f8fb..b2334f7c4539 100644 --- a/offapi/com/sun/star/linguistic2/ProofreadingResult.idl +++ b/offapi/com/sun/star/linguistic2/ProofreadingResult.idl @@ -58,7 +58,7 @@ interface XProofreader; //============================================================================= /** holds the results from proofreading a sentence. - @since OOo 3.01 + @since OOo 3.0.1 */ struct ProofreadingResult { diff --git a/offapi/com/sun/star/linguistic2/SingleProofreadingError.idl b/offapi/com/sun/star/linguistic2/SingleProofreadingError.idl index b16ca8711d6e..851e0f8b8c64 100644 --- a/offapi/com/sun/star/linguistic2/SingleProofreadingError.idl +++ b/offapi/com/sun/star/linguistic2/SingleProofreadingError.idl @@ -45,7 +45,7 @@ module com { module sun { module star { module linguistic2 { //============================================================================= /** holds a single error found by the proofreader. - @since OOo 3.01 + @since OOo 3.0.1 */ struct SingleProofreadingError { diff --git a/offapi/com/sun/star/linguistic2/XProofreader.idl b/offapi/com/sun/star/linguistic2/XProofreader.idl index be7e34483239..d330a40c4e11 100644 --- a/offapi/com/sun/star/linguistic2/XProofreader.idl +++ b/offapi/com/sun/star/linguistic2/XProofreader.idl @@ -65,7 +65,7 @@ module com { module sun { module star { module linguistic2 { //============================================================================= /** API for proofreading a text - @since OOo 3.01 + @since OOo 3.0.1 */ interface XProofreader: com::sun::star::linguistic2::XSupportedLocales { diff --git a/offapi/com/sun/star/linguistic2/XProofreadingIterator.idl b/offapi/com/sun/star/linguistic2/XProofreadingIterator.idl index b1536cc3b5be..51da34d0fa6f 100644 --- a/offapi/com/sun/star/linguistic2/XProofreadingIterator.idl +++ b/offapi/com/sun/star/linguistic2/XProofreadingIterator.idl @@ -61,7 +61,7 @@ module com { module sun { module star { module linguistic2 { //============================================================================= /** API for the proofreading iterator that mediates between the document and the proofreader. - @since OOo 3.01 + @since OOo 3.0.1 */ interface XProofreadingIterator: com::sun::star::uno::XInterface { diff --git a/offapi/com/sun/star/linguistic2/XSearchableDictionary.idl b/offapi/com/sun/star/linguistic2/XSearchableDictionary.idl index ddbb8a273255..d52b8b00bb3d 100644 --- a/offapi/com/sun/star/linguistic2/XSearchableDictionary.idl +++ b/offapi/com/sun/star/linguistic2/XSearchableDictionary.idl @@ -60,7 +60,7 @@ interface XSearchableDictionary : com::sun::star::linguistic2::XDictionary @see <type scope="com::sun::star::linguistic2">XDictionaryEntry</type> @see <type scope="com::sun::star::linguistic2">XSearchableDictionaryList</type> - @since OOo 3.01 + @since OOo 3.0.1 */ sequence< com::sun::star::linguistic2::XDictionaryEntry > searchSimilarEntries( [in] string aWord ); diff --git a/offapi/com/sun/star/linguistic2/XSetSpellAlternatives.idl b/offapi/com/sun/star/linguistic2/XSetSpellAlternatives.idl index 8407fbe566c0..0637a9847e51 100644 --- a/offapi/com/sun/star/linguistic2/XSetSpellAlternatives.idl +++ b/offapi/com/sun/star/linguistic2/XSetSpellAlternatives.idl @@ -55,7 +55,7 @@ interface XSetSpellAlternatives : com::sun::star::uno::XInterface /** set the list of suggestions to be returned. - @since OOo 3.01 + @since OOo 3.0.1 */ void setAlternatives( [in] sequence< string > aAlternatives ); @@ -64,7 +64,7 @@ interface XSetSpellAlternatives : com::sun::star::uno::XInterface set the type of error found. @see <tyoe scope="com::sun::star::linguistic2">SpellFailure</type> - @since OOo 3.01 + @since OOo 3.0.1 */ void setFailureType( [in] short nFailureType ); diff --git a/offapi/com/sun/star/logging/DocumentIOLogRing.idl b/offapi/com/sun/star/logging/DocumentIOLogRing.idl new file mode 100644 index 000000000000..a395ecff172e --- /dev/null +++ b/offapi/com/sun/star/logging/DocumentIOLogRing.idl @@ -0,0 +1,66 @@ +/************************************************************************* + * + * 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: DocumentIOLogRing.idl,v $ + * $Revision: 1.3 $ + * + * 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. + * + ************************************************************************/ + +#ifndef __com_sun_star_logging_DocumentIOLogRing_idl__ +#define __com_sun_star_logging_DocumentIOLogRing_idl__ + +#ifndef __com_sun_star_lang_IllegalArgumentException_idl__ +#include <com/sun/star/lang/IllegalArgumentException.idl> +#endif +#ifndef __com_sun_star_beans_NamedValue_idl__ +#include <com/sun/star/beans/NamedValue.idl> +#endif + +//============================================================================= + +module com { module sun { module star { module logging { + +interface XSimpleLogRing; + +//============================================================================= + +/** This singleton is intended to log the IO events related to loading/storing + of documents. + + <p> + Please do not use the singleton without communication with source owner! + </p> + + @since OOo 3.2 + */ +singleton DocumentIOLogRing : XSimpleLogRing; + +//============================================================================= + +}; }; }; }; + +//============================================================================= + +#endif diff --git a/offapi/com/sun/star/logging/SimpleLogRing.idl b/offapi/com/sun/star/logging/SimpleLogRing.idl new file mode 100644 index 000000000000..2e6fe010a092 --- /dev/null +++ b/offapi/com/sun/star/logging/SimpleLogRing.idl @@ -0,0 +1,72 @@ +/************************************************************************* + * + * 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: SimpleLogRing.idl,v $ + * $Revision: 1.3 $ + * + * 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. + * + ************************************************************************/ + +#ifndef __com_sun_star_logging_SimpleLogRing_idl__ +#define __com_sun_star_logging_SimpleLogRing_idl__ + +#ifndef __com_sun_star_lang_IllegalArgumentException_idl__ +#include <com/sun/star/lang/IllegalArgumentException.idl> +#endif +#ifndef __com_sun_star_beans_NamedValue_idl__ +#include <com/sun/star/beans/NamedValue.idl> +#endif + +//============================================================================= + +module com { module sun { module star { module logging { + +interface XSimpleLogRing; + +//============================================================================= + +/** This service allows to log the events in a ring of specified size. + + @since OOo 3.2 + */ +service SimpleLogRing : XSimpleLogRing +{ + /** creates a ring of default size - 256 messages + */ + create(); + + /** creates a ring of specified size + @param nSize + the number of messages in a ring + */ + createWithSize( [in] long nSize ); +}; + +//============================================================================= + +}; }; }; }; + +//============================================================================= + +#endif diff --git a/offapi/com/sun/star/logging/XSimpleLogRing.idl b/offapi/com/sun/star/logging/XSimpleLogRing.idl new file mode 100644 index 000000000000..e3bd1b4929dc --- /dev/null +++ b/offapi/com/sun/star/logging/XSimpleLogRing.idl @@ -0,0 +1,77 @@ +/************************************************************************* + * + * 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: XSimpleLogRing.idl,v $ + * $Revision: 1.3 $ + * + * 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. + * + ************************************************************************/ + +#ifndef __com_sun_star_logging_XSimpleLogRing_idl__ +#define __com_sun_star_logging_XSimpleLogRing_idl__ + +#ifndef __com_sun_star_uno_XInterface_idl__ +#include <com/sun/star/uno/XInterface.idl> +#endif + +//============================================================================= + +module com { module sun { module star { module logging { + +//============================================================================= + +/** a simple log ring allowing to collect a limited number of last events + + <p> + The intention of this interface is to provide a simple possibility + for developer to collect the most important events without affecting + the performance. For this reasons the messages related API is quite + simple, the strings should be produced by the preprocessor mainly. + </p> + + @since OOo 3.2 + */ +interface XSimpleLogRing +{ + /** allows to add a message to the logger + */ + void logString( [in] string aMessage ); + + /** allows to get the collected messages from the logger + + <p> + It is up to logger implementation to provide only the limited + number of last messages. + </p> + */ + sequence< string > getCollectedLog(); +}; + +//============================================================================= + +}; }; }; }; + +//============================================================================= + +#endif diff --git a/offapi/com/sun/star/logging/makefile.mk b/offapi/com/sun/star/logging/makefile.mk index 2a92ba29cd3a..6686b04ae37a 100644 --- a/offapi/com/sun/star/logging/makefile.mk +++ b/offapi/com/sun/star/logging/makefile.mk @@ -40,17 +40,20 @@ PACKAGE := com$/sun$/star$/logging IDLFILES = \ ConsoleHandler.idl\ CsvLogFormatter.idl\ + DocumentIOLogRing.idl\ FileHandler.idl\ LoggerPool.idl\ LogLevel.idl\ LogRecord.idl\ PlainTextFormatter.idl\ + SimpleLogRing.idl\ XConsoleHandler.idl\ XCsvLogFormatter.idl\ XLogFormatter.idl\ XLogger.idl\ XLoggerPool.idl\ - XLogHandler.idl + XLogHandler.idl\ + XSimpleLogRing.idl .INCLUDE: target.mk .INCLUDE: $(PRJ)$/util$/target.pmk diff --git a/offapi/com/sun/star/modules.idl b/offapi/com/sun/star/modules.idl index 4a0f4efcd12c..81bcb46f06a0 100644 --- a/offapi/com/sun/star/modules.idl +++ b/offapi/com/sun/star/modules.idl @@ -78,9 +78,6 @@ module chart {}; */ module chart2 {}; -/// Non-JDBC conform database interfaces <b>(deprecated)</d> -module data {}; - /// Access to the tree of configuration data. module configuration {}; @@ -90,6 +87,9 @@ module datatransfer {}; /// Office document related interfaces. module document {}; +/// Office document content related interfaces. +module office {}; + /// Drawing and shape specific interfaces. module drawing {}; diff --git a/offapi/com/sun/star/office/XAnnotation.idl b/offapi/com/sun/star/office/XAnnotation.idl new file mode 100644 index 000000000000..ff7c4127bb82 --- /dev/null +++ b/offapi/com/sun/star/office/XAnnotation.idl @@ -0,0 +1,105 @@ +/************************************************************************* + * + * 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: XGalleryItem.idl,v $ + * $Revision: 1.4 $ + * + * 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. + * + ************************************************************************/ + +#ifndef __com_sun_star_office_XAnnotation_idl__ +#define __com_sun_star_office_XAnnotation_idl__ + +#ifndef __com_sun_star_beans_XPropertySet_idl__ +#include <com/sun/star/beans/XPropertySet.idl> +#endif + +#ifndef __com_sun_star_beans_XMultiPropertySet_idl__ +#include <com/sun/star/beans/XMultiPropertySet.idl> +#endif + +#ifndef __com_sun_star_util_DateTime_idl__ +#include <com/sun/star/util/DateTime.idl> +#endif + +#ifndef __com_sun_star_text_XText_idl__ +#include <com/sun/star/text/XText.idl> +#endif + +#ifndef __com_sun_star_geometry_RealPoint2D_idl__ +#include <com/sun/star/geometry/RealPoint2D.idl> +#endif + +#ifndef __com_sun_star_geometry_RealSize2D_idl__ +#include <com/sun/star/geometry/RealSize2D.idl> +#endif + +#ifndef __com_sun_star_lang_XComponent_idl__ +#include <com/sun/star/lang/XComponent.idl> +#endif + +//============================================================================= + +module com { module sun { module star { module office { + +//============================================================================= + +/** This interface gives access to an annotation inside a document. + */ +interface XAnnotation +{ + /** All attributes are also available as properties. */ + interface ::com::sun::star::beans::XPropertySet; + + /** manages the lifetime of this annotation, should only be used + by the owner of the annotation which should be the document itself. */ + interface ::com::sun::star::lang::XComponent; + + /** a reference to the document content this annotation is anchored to. */ + [attribute, readonly] any Anchor; + + /** this is an optional position that gives the user interface a hint where + the annotation should be rendered. This could be an offset to the + annotations anchor. */ + [attribute] ::com::sun::star::geometry::RealPoint2D Position; + + /** this is an optional size that gives the user interface a hint how + large the annotation should be rendered. */ + [attribute] ::com::sun::star::geometry::RealSize2D Size; + + /** stores the full name of the author who created this annotation. */ + [attribute] string Author; + + /** stores the date and time this annotation was last edited. */ + [attribute] ::com::sun::star::util::DateTime DateTime; + + /** gives access to the annotations text. */ + [attribute, readonly] ::com::sun::star::text::XText TextRange; +}; + +//============================================================================= + +}; }; }; }; + +#endif diff --git a/offapi/com/sun/star/office/XAnnotationAccess.idl b/offapi/com/sun/star/office/XAnnotationAccess.idl new file mode 100644 index 000000000000..074312ef6fec --- /dev/null +++ b/offapi/com/sun/star/office/XAnnotationAccess.idl @@ -0,0 +1,75 @@ +/************************************************************************* + * + * 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: XGalleryItem.idl,v $ + * $Revision: 1.4 $ + * + * 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. + * + ************************************************************************/ + +#ifndef __com_sun_star_office_XAnnotationAccess_idl__ +#define __com_sun_star_office_XAnnotationAccess_idl__ + +#ifndef __com_sun_star_office_XAnnotationEnumeration_idl__ +#include <com/sun/star/office/XAnnotationEnumeration.idl> +#endif + +#ifndef __com_sun_star_lang_IllegalArgumentException_idl__ +#include <com/sun/star/office/IllegalArgumentException.idl> +#endif + +#ifndef __com_sun_star_office_XAnnotation_idl__ +#include <com/sun/star/office/XAnnotation.idl> +#endif + +//============================================================================= + +module com { module sun { module star { module office { + +//============================================================================= + +/** This interface gives access to the annotation for a document content. + */ +interface XAnnotationAccess +{ + /** creates a new annotation and inserts it into the document content. + */ + XAnnotation createAndInsertAnnotation(); + + /** removes the annotation from this document content. + */ + void removeAnnotation( [in] XAnnotation annotation ) raises ( com::sun::star::lang::IllegalArgumentException ); + + /** @returns + a new enumeration object for this annotation container. + It returns NULL if there are no objects in this container. + */ + XAnnotationEnumeration createAnnotationEnumeration(); +}; + +//============================================================================= + +}; }; }; }; + +#endif diff --git a/offapi/com/sun/star/office/XAnnotationEnumeration.idl b/offapi/com/sun/star/office/XAnnotationEnumeration.idl new file mode 100644 index 000000000000..e81666e0b698 --- /dev/null +++ b/offapi/com/sun/star/office/XAnnotationEnumeration.idl @@ -0,0 +1,74 @@ +/************************************************************************* + * + * 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: XEnumeration.idl,v $ + * $Revision: 1.12 $ + * + * 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. + * + ************************************************************************/ +#ifndef __com_sun_star_office_XAnnotationEnumeration_idl__ +#define __com_sun_star_office_XAnnotationEnumeration_idl__ + +#ifndef __com_sun_star_office_XAnnotation_idl__ +#include <com/sun/star/office/XAnnotation.idl> +#endif + +#ifndef __com_sun_star_container_NoSuchElementException_idl__ +#include <com/sun/star/container/NoSuchElementException.idl> +#endif + +//============================================================================= + +module com { module sun { module star { module office { + +//============================================================================= + +/** An enumeration for a set of annotations. + */ +interface XAnnotationEnumeration +{ + //------------------------------------------------------------------------- + + /** tests whether this enumeration contains more elements. + */ + boolean hasMoreElements(); + + //------------------------------------------------------------------------- + + /** @returns + the next element of this enumeration. + + @throws NoSuchElementException + if no more elements exist. + */ + XAnnotation nextElement() + raises( com::sun::star::container::NoSuchElementException ); + +}; + +//============================================================================= + +}; }; }; }; + +#endif diff --git a/offapi/com/sun/star/office/makefile.mk b/offapi/com/sun/star/office/makefile.mk new file mode 100644 index 000000000000..404c23c45e32 --- /dev/null +++ b/offapi/com/sun/star/office/makefile.mk @@ -0,0 +1,51 @@ +#************************************************************************* +# +# 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: makefile.mk,v $ +# +# $Revision: 1.5 $ +# +# 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. +# +#************************************************************************* + +PRJ=..$/..$/..$/.. +PRJNAME=offapi +TARGET=cssoffice +PACKAGE=com$/sun$/star$/office + +# --- Settings ----------------------------------------------------- + +.INCLUDE : $(PRJ)$/util$/makefile.pmk + +# ------------------------------------------------------------------------ + +IDLFILES=\ + XAnnotation.idl\ + XAnnotationEnumeration.idl\ + XAnnotationAccess.idl + +# ------------------------------------------------------------------ + +.INCLUDE : target.mk +.INCLUDE : $(PRJ)$/util$/target.pmk diff --git a/offapi/com/sun/star/presentation/XSlideShow.idl b/offapi/com/sun/star/presentation/XSlideShow.idl index 0d6065f1b0ed..ca3a614f8d86 100644 --- a/offapi/com/sun/star/presentation/XSlideShow.idl +++ b/offapi/com/sun/star/presentation/XSlideShow.idl @@ -99,6 +99,25 @@ interface XSlideShow : ::com::sun::star::uno::XInterface */ boolean nextEffect(); + /** Undo the last effect in the main sequence of the slideshow.<p> + + The current slide is displayed as if the last user-triggered effect + has never been triggered. If there is no previous effect on the + current slide then slideEnded(true) is called at the registered + XSlideShowListener objects, which can then trigger a change to the + previous slide. Note that this command is executed asynchronously. + Multiple calls to update() may be necessary to complete its execution. + If there is currently no slideshow running, this method does + nothing.<p> + + @return <TRUE/>, if the previous effect was successfully + triggered. This method returns <FALSE/>, if there is no show + running, the first effect on the first slide was not yet + triggered, or the implementation failed to trigger the previous + effect. + */ + boolean previousEffect(); + /** Start a shape-intrinsic animation or activity.<p> This method starts an animation or activity intrinsic to the @@ -151,8 +170,24 @@ interface XSlideShow : ::com::sun::star::uno::XInterface a different slide, this will still work but will not have any performance improvements </li> + <li>name: SkipAllMainSequenceEffects, value: boolean. + When <TRUE/> then all main sequence effects on the new slide + are triggered. This is typically used when going back one + effect leads to the previous slide. On that slide all + effects have to be shown in order to continue the backward + travelling. + When <FALSE/>, the default, then no main sequence effect is + triggered. + </li> + <li>name: SkipSlideTransition, value: boolean. + When <TRUE/> then the slide transition animation, if there + is any, is not displayed. This is typically used when going + back one effect leads to the previous slide. Typically used + together with SkipAllMainSequenceEffects also being <TRUE/>. + When <FALSE/>, the default, then the slide transition + effect, if it exists, is played. + </li> </ul> - */ void displaySlide( [in] ::com::sun::star::drawing::XDrawPage xSlide, diff --git a/offapi/com/sun/star/presentation/XSlideShowController.idl b/offapi/com/sun/star/presentation/XSlideShowController.idl index 9476604a2c77..8ddc9931e163 100644 --- a/offapi/com/sun/star/presentation/XSlideShowController.idl +++ b/offapi/com/sun/star/presentation/XSlideShowController.idl @@ -121,6 +121,14 @@ interface XSlideShowController //------------------------------------------------------------------------- + /** undo the last effects that where triggered by a generic trigger. + <p>If there is no previous effect that can be undone then the + previous slide will be displayed. + */ + void gotoPreviousEffect(); + + //------------------------------------------------------------------------- + /** goto and display first slide */ void gotoFirstSlide(); diff --git a/offapi/com/sun/star/presentation/XSlideShowListener.idl b/offapi/com/sun/star/presentation/XSlideShowListener.idl index 90b7dec18e84..46786eabc03c 100644 --- a/offapi/com/sun/star/presentation/XSlideShowListener.idl +++ b/offapi/com/sun/star/presentation/XSlideShowListener.idl @@ -65,8 +65,12 @@ interface XSlideShowListener : ::com::sun::star::animations::XAnimationListener /** Notify that the current slide has ended, e.g. the user has clicked on the slide. Calling displaySlide() twice will not issue this event. + @param reverse + For the default order (forward) this flag is <FALSE/>. + When the main sequence was traversed in reverse order then this + flag is <TRUE/>. */ - void slideEnded(); + void slideEnded( [in] boolean reverse ); /** Notifies that a hyperlink has been clicked. @param hyperLink hyperlink URL diff --git a/offapi/com/sun/star/rdf/BlankNode.idl b/offapi/com/sun/star/rdf/BlankNode.idl index f0534d68c441..e0ad2bb94a4e 100644 --- a/offapi/com/sun/star/rdf/BlankNode.idl +++ b/offapi/com/sun/star/rdf/BlankNode.idl @@ -62,7 +62,7 @@ service BlankNode : XBlankNode another node that already exists in some repository. That may or may not be what you want. If you want to create a new blank node that is guaranteed to be unique, - use <method>XRepository::createBlankNode</method> instead. + use <member>XRepository::createBlankNode</member> instead. <p> @param NodeID diff --git a/offapi/com/sun/star/rdf/FileFormat.idl b/offapi/com/sun/star/rdf/FileFormat.idl index f22ad9265039..d83b4bc66363 100644 --- a/offapi/com/sun/star/rdf/FileFormat.idl +++ b/offapi/com/sun/star/rdf/FileFormat.idl @@ -41,13 +41,13 @@ module com { module sun { module star { module rdf { <p> These constants are mainly for use with - <method>XRepository::importGraph</method> - and <method>XRepository::exportGraph</method>. + <member>XRepository::importGraph</member> + and <member>XRepository::exportGraph</member>. </p> <p> - Note that these are integers because UNO IDL does not permit string - constants. + Note that these are integers because UNO IDL does not permit + <atom>string</atom> constants. </p> @since OOo 3.0 diff --git a/offapi/com/sun/star/rdf/Statement.idl b/offapi/com/sun/star/rdf/Statement.idl index 9d8692154755..18bb46bfb70e 100644 --- a/offapi/com/sun/star/rdf/Statement.idl +++ b/offapi/com/sun/star/rdf/Statement.idl @@ -43,7 +43,7 @@ module com { module sun { module star { module rdf { //============================================================================= /** represents a RDF statement, or triple. - @since OOo 3.0 + @since OOo 3.2 @see XRepository */ @@ -52,7 +52,7 @@ struct Statement /// the subject of the RDF statement. XResource Subject; /// the predicate of the RDF statement. - XResource Predicate; + XURI Predicate; /// the object of the RDF statement. XNode Object; /// the named graph that contains this statement, or <NULL/>. diff --git a/offapi/com/sun/star/rdf/URI.idl b/offapi/com/sun/star/rdf/URI.idl index 2ccb100cac4f..8a4888c4efb7 100644 --- a/offapi/com/sun/star/rdf/URI.idl +++ b/offapi/com/sun/star/rdf/URI.idl @@ -58,7 +58,7 @@ service URI : XURI /** creates an URI RDF node. @param Value - the URI, represented as string. + the URI, represented as <atom>string</atom>. @throws com::sun::star::lang::IllegalArgumentException if the argument does not represent a valid URI @@ -70,10 +70,11 @@ service URI : XURI /** creates an URI RDF node from namespace prefix and local name. @param Namespace - the namespace prefix of the URI, represented as string. + the namespace prefix of the URI, represented as + <atom>string</atom>. @param LocalName - the local name of the URI, represented as string. + the local name of the URI, represented as <atom>string</atom>. @throws com::sun::star::lang::IllegalArgumentException if the arguments do not represent a valid URI diff --git a/offapi/com/sun/star/rdf/URIs.idl b/offapi/com/sun/star/rdf/URIs.idl index 23a3ef3f7f62..19a49b4919a6 100644 --- a/offapi/com/sun/star/rdf/URIs.idl +++ b/offapi/com/sun/star/rdf/URIs.idl @@ -41,23 +41,103 @@ module com { module sun { module star { module rdf { /** Constants to specify some well-known URIs. <p> - These constants are mainly for use with - <method>URI::createKnown</method>. + These constants are for use with <member>URI::createKnown</member>. </p> - @since OOo 3.0 + @since OOo 3.2 @see URI::createKnown */ constants URIs { -// /// http://www.w3.org/2001/XMLSchema#NCName -//FIXME: XMLSchema-datatypes is preferred to XMLSchema in this context??? - /// http://www.w3.org/2001/XMLSchema-datatypes#NCName - const short XSD_NCNAME = 1; + const short XSD_NCNAME = 1; /// http://www.w3.org/2001/XMLSchema-datatypes#string - const short XSD_STRING = 2; + const short XSD_STRING = 2; + /// http://www.w3.org/2001/XMLSchema-datatypes#normalizedString + const short XSD_NORMALIZEDSTRING = 3; + /// http://www.w3.org/2001/XMLSchema-datatypes#boolean + const short XSD_BOOLEAN = 4; + /// http://www.w3.org/2001/XMLSchema-datatypes#decimal + const short XSD_DECIMAL = 5; + /// http://www.w3.org/2001/XMLSchema-datatypes#float + const short XSD_FLOAT = 6; + /// http://www.w3.org/2001/XMLSchema-datatypes#double + const short XSD_DOUBLE = 7; + /// http://www.w3.org/2001/XMLSchema-datatypes#integer + const short XSD_INTEGER = 8; + /// http://www.w3.org/2001/XMLSchema-datatypes#nonNegativeInteger + const short XSD_NONNEGATIVEINTEGER = 9; + /// http://www.w3.org/2001/XMLSchema-datatypes#positiveInteger + const short XSD_POSITIVEINTEGER = 10; + /// http://www.w3.org/2001/XMLSchema-datatypes#nonPositiveInteger + const short XSD_NONPOSITIVEINTEGER = 11; + /// http://www.w3.org/2001/XMLSchema-datatypes#negativeInteger + const short XSD_NEGATIVEINTEGER = 12; + /// http://www.w3.org/2001/XMLSchema-datatypes#long + const short XSD_LONG = 13; + /// http://www.w3.org/2001/XMLSchema-datatypes#int + const short XSD_INT = 14; + /// http://www.w3.org/2001/XMLSchema-datatypes#short + const short XSD_SHORT = 15; + /// http://www.w3.org/2001/XMLSchema-datatypes#byte + const short XSD_BYTE = 16; + /// http://www.w3.org/2001/XMLSchema-datatypes#unsignedLong + const short XSD_UNSIGNEDLONG = 17; + /// http://www.w3.org/2001/XMLSchema-datatypes#unsignedInt + const short XSD_UNSIGNEDINT = 18; + /// http://www.w3.org/2001/XMLSchema-datatypes#unsignedShort + const short XSD_UNSIGNEDSHORT = 19; + /// http://www.w3.org/2001/XMLSchema-datatypes#unsignedByte + const short XSD_UNSIGNEDBYTE = 20; + /// http://www.w3.org/2001/XMLSchema-datatypes#hexBinary + const short XSD_HEXBINARY = 21; + /// http://www.w3.org/2001/XMLSchema-datatypes#base64Binary + const short XSD_BASE64BINARY = 22; + /// http://www.w3.org/2001/XMLSchema-datatypes#dateTime + const short XSD_DATETIME = 23; + /// http://www.w3.org/2001/XMLSchema-datatypes#time + const short XSD_TIME = 24; + /// http://www.w3.org/2001/XMLSchema-datatypes#date + const short XSD_DATE = 25; + /// http://www.w3.org/2001/XMLSchema-datatypes#gYearMonth + const short XSD_GYEARMONTH = 26; + /// http://www.w3.org/2001/XMLSchema-datatypes#gYear + const short XSD_GYEAR = 27; + /// http://www.w3.org/2001/XMLSchema-datatypes#gMonthDay + const short XSD_GMONTHDAY = 28; + /// http://www.w3.org/2001/XMLSchema-datatypes#gDay + const short XSD_GDAY = 29; + /// http://www.w3.org/2001/XMLSchema-datatypes#gMonth + const short XSD_GMONTH = 30; + /// http://www.w3.org/2001/XMLSchema-datatypes#anyURI + const short XSD_ANYURI = 31; + /// http://www.w3.org/2001/XMLSchema-datatypes#token + const short XSD_TOKEN = 32; + /// http://www.w3.org/2001/XMLSchema-datatypes#language + const short XSD_LANGUAGE = 33; + /// http://www.w3.org/2001/XMLSchema-datatypes#NMTOKEN + const short XSD_NMTOKEN = 34; + /// http://www.w3.org/2001/XMLSchema-datatypes#Name + const short XSD_NAME = 35; + /// http://www.w3.org/2001/XMLSchema-datatypes#duration + const short XSD_DURATION = 36; + /// http://www.w3.org/2001/XMLSchema-datatypes#QName + const short XSD_QNAME = 37; + /// http://www.w3.org/2001/XMLSchema-datatypes#NOTATION + const short XSD_NOTATION = 38; + /// http://www.w3.org/2001/XMLSchema-datatypes#NMTOKENS + const short XSD_NMTOKENS = 39; + /// http://www.w3.org/2001/XMLSchema-datatypes#ID + const short XSD_ID = 40; + /// http://www.w3.org/2001/XMLSchema-datatypes#IDREF + const short XSD_IDREF = 41; + /// http://www.w3.org/2001/XMLSchema-datatypes#IDREFS + const short XSD_IDREFS = 42; + /// http://www.w3.org/2001/XMLSchema-datatypes#ENTITY + const short XSD_ENTITY = 43; + /// http://www.w3.org/2001/XMLSchema-datatypes#ENTITIES + const short XSD_ENTITIES = 44; /// http://www.w3.org/1999/02/22-rdf-syntax-ns#type const short RDF_TYPE = 1000; @@ -71,56 +151,179 @@ constants URIs const short RDF_PROPERTY = 1004; /// http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement const short RDF_STATEMENT = 1005; + /// http://www.w3.org/1999/02/22-rdf-syntax-ns#value + const short RDF_VALUE = 1006; + /// http://www.w3.org/1999/02/22-rdf-syntax-ns#first + const short RDF_FIRST = 1007; + /// http://www.w3.org/1999/02/22-rdf-syntax-ns#rest + const short RDF_REST = 1008; + /// http://www.w3.org/1999/02/22-rdf-syntax-ns#nil + const short RDF_NIL = 1009; + /// http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral + const short RDF_XMLLITERAL = 1010; + /// http://www.w3.org/1999/02/22-rdf-syntax-ns#Alt + const short RDF_ALT = 1011; + /// http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag + const short RDF_BAG = 1012; + /// http://www.w3.org/1999/02/22-rdf-syntax-ns#List + const short RDF_LIST = 1013; + /// http://www.w3.org/1999/02/22-rdf-syntax-ns#Seq + const short RDF_SEQ = 1014; + /// http://www.w3.org/1999/02/22-rdf-syntax-ns#_1 + const short RDF_1 = 1015; + /* hmm... that's a lot of potential constants: + _n where n is a decimal integer greater than zero with no leading zeros. + */ /// http://www.w3.org/2000/01/rdf-schema#comment - const short RDFS_COMMENT = 1100; + const short RDFS_COMMENT = 1100; /// http://www.w3.org/2000/01/rdf-schema#label - const short RDFS_LABEL = 1101; + const short RDFS_LABEL = 1101; /// http://www.w3.org/2000/01/rdf-schema#domain - const short RDFS_DOMAIN = 1102; + const short RDFS_DOMAIN = 1102; /// http://www.w3.org/2000/01/rdf-schema#range - const short RDFS_RANGE = 1103; + const short RDFS_RANGE = 1103; /// http://www.w3.org/2000/01/rdf-schema#subClassOf - const short RDFS_SUBCLASSOF = 1104; + const short RDFS_SUBCLASSOF = 1104; /// http://www.w3.org/2000/01/rdf-schema#Literal - const short RDFS_LITERAL = 1105; + const short RDFS_LITERAL = 1105; + /// http://www.w3.org/2000/01/rdf-schema#member + const short RDFS_MEMBER = 1106; + /// http://www.w3.org/2000/01/rdf-schema#subPropertyOf + const short RDFS_SUBPROPERTYOF = 1107; + /// http://www.w3.org/2000/01/rdf-schema#isDefinedBy + const short RDFS_ISDEFINEDBY = 1108; + /// http://www.w3.org/2000/01/rdf-schema#seeAlso + const short RDFS_SEEALSO = 1109; + /// http://www.w3.org/2000/01/rdf-schema#Resource + const short RDFS_RESOURCE = 1110; + /// http://www.w3.org/2000/01/rdf-schema#Class + const short RDFS_CLASS = 1111; + /// http://www.w3.org/2000/01/rdf-schema#Datatype + const short RDFS_DATATYPE = 1112; + /// http://www.w3.org/2000/01/rdf-schema#Container + const short RDFS_CONTAINER = 1113; + /// http://www.w3.org/2000/01/rdf-schema#ContainerMembershipProperty + const short RDFS_CONTAINERMEMBERSHIPPROPERTY = 1114; /// http://www.w3.org/2002/07/owl#Class - const short OWL_CLASS = 1200; + const short OWL_CLASS = 1200; /// http://www.w3.org/2002/07/owl#ObjectProperty - const short OWL_OBJECTPROPERTY = 1201; + const short OWL_OBJECTPROPERTY = 1201; /// http://www.w3.org/2002/07/owl#DatatypeProperty - const short OWL_DATATYPEPROPERTY = 1202; + const short OWL_DATATYPEPROPERTY = 1202; /// http://www.w3.org/2002/07/owl#FunctionalProperty - const short OWL_FUNCTIONALPROPERTY = 1203; + const short OWL_FUNCTIONALPROPERTY = 1203; + /// http://www.w3.org/2002/07/owl#Thing + const short OWL_THING = 1204; + /// http://www.w3.org/2002/07/owl#Nothing + const short OWL_NOTHING = 1205; + /// http://www.w3.org/2002/07/owl#Individual + const short OWL_INDIVIDUAL = 1206; + /// http://www.w3.org/2002/07/owl#equivalentClass + const short OWL_EQUIVALENTCLASS = 1207; + /// http://www.w3.org/2002/07/owl#equivalentProperty + const short OWL_EQUIVALENTPROPERTY = 1208; + /// http://www.w3.org/2002/07/owl#sameAs + const short OWL_SAMEAS = 1209; + /// http://www.w3.org/2002/07/owl#differentFrom + const short OWL_DIFFERENTFROM = 1210; + /// http://www.w3.org/2002/07/owl#AllDifferent + const short OWL_ALLDIFFERENT = 1211; + /// http://www.w3.org/2002/07/owl#distinctMembers + const short OWL_DISTINCTMEMBERS = 1212; + /// http://www.w3.org/2002/07/owl#inverseOf + const short OWL_INVERSEOF = 1213; + /// http://www.w3.org/2002/07/owl#TransitiveProperty + const short OWL_TRANSITIVEPROPERTY = 1214; + /// http://www.w3.org/2002/07/owl#SymmetricProperty + const short OWL_SYMMETRICPROPERTY = 1215; + /// http://www.w3.org/2002/07/owl#InverseFunctionalProperty + const short OWL_INVERSEFUNCTIONALPROPERTY = 1216; + /// http://www.w3.org/2002/07/owl#Restriction + const short OWL_RESTRICTION = 1217; + /// http://www.w3.org/2002/07/owl#onProperty + const short OWL_ONPROPERTY = 1218; + /// http://www.w3.org/2002/07/owl#allValuesFrom + const short OWL_ALLVALUESFROM = 1219; + /// http://www.w3.org/2002/07/owl#someValuesFrom + const short OWL_SOMEVALUESFROM = 1220; + /// http://www.w3.org/2002/07/owl#minCardinality + const short OWL_MINCARDINALITY = 1221; + /// http://www.w3.org/2002/07/owl#maxCardinality + const short OWL_MAXCARDINALITY = 1222; + /// http://www.w3.org/2002/07/owl#cardinality + const short OWL_CARDINALITY = 1223; + /// http://www.w3.org/2002/07/owl#Ontology + const short OWL_ONTOLOGY = 1224; + /// http://www.w3.org/2002/07/owl#imports + const short OWL_IMPORTS = 1225; + /// http://www.w3.org/2002/07/owl#versionInfo + const short OWL_VERSIONINFO = 1226; + /// http://www.w3.org/2002/07/owl#priorVersion + const short OWL_PRIORVERSION = 1227; + /// http://www.w3.org/2002/07/owl#backwardCompatibleWith + const short OWL_BACKWARDCOMPATIBLEWITH = 1228; + /// http://www.w3.org/2002/07/owl#incompatibleWith + const short OWL_INCOMPATIBLEWITH = 1229; + /// http://www.w3.org/2002/07/owl#DeprecatedClass + const short OWL_DEPRECATEDCLASS = 1230; + /// http://www.w3.org/2002/07/owl#DeprecatedProperty + const short OWL_DEPRECATEDPROPERTY = 1231; + /// http://www.w3.org/2002/07/owl#AnnotationProperty + const short OWL_ANNOTATIONPROPERTY = 1232; + /// http://www.w3.org/2002/07/owl#OntologyProperty + const short OWL_ONTOLOGYPROPERTY = 1233; + /// http://www.w3.org/2002/07/owl#oneOf + const short OWL_ONEOF = 1234; + /// http://www.w3.org/2002/07/owl#dataRange + const short OWL_DATARANGE = 1235; + /// http://www.w3.org/2002/07/owl#disjointWith + const short OWL_DISJOINTWITH = 1236; + /// http://www.w3.org/2002/07/owl#unionOf + const short OWL_UNIONOF = 1237; + /// http://www.w3.org/2002/07/owl#complementOf + const short OWL_COMPLEMENTOF = 1238; + /// http://www.w3.org/2002/07/owl#intersectionOf + const short OWL_INTERSECTIONOF = 1239; + /// http://www.w3.org/2002/07/owl#hasValue + const short OWL_HASVALUE = 1240; - /// http://docs.oasis-open.org/opendocument/meta/package/common#hasPart - const short PKG_HASPART = 2000; - /// http://docs.oasis-open.org/opendocument/meta/package/common#idref + /// http://docs.oasis-open.org/ns/office/1.2/meta/pkg#hasPart + const short PKG_HASPART = 2000; +/* REMOVED + /// http://docs.oasis-open.org/ns/office/1.2/meta/pkg#idref const short PKG_IDREF = 2001; - /// http://docs.oasis-open.org/opendocument/meta/package/common#path + /// http://docs.oasis-open.org/ns/office/1.2/meta/pkg#path const short PKG_PATH = 2002; - /// http://docs.oasis-open.org/opendocument/meta/package/common#mimeType - const short PKG_MIMETYPE = 2003; - /// http://docs.oasis-open.org/opendocument/meta/package/common#Package - const short PKG_PACKAGE = 2004; - /// http://docs.oasis-open.org/opendocument/meta/package/common#Element - const short PKG_ELEMENT = 2005; - /// http://docs.oasis-open.org/opendocument/meta/package/common#File - const short PKG_FILE = 2006; - - /// http://docs.oasis-open.org/opendocument/meta/package/odf#prefix +*/ + /// http://docs.oasis-open.org/ns/office/1.2/meta/pkg#mimeType + const short PKG_MIMETYPE = 2003; + /// http://docs.oasis-open.org/ns/office/1.2/meta/pkg#Package + const short PKG_PACKAGE = 2004; + /// http://docs.oasis-open.org/ns/office/1.2/meta/pkg#Element + const short PKG_ELEMENT = 2005; + /// http://docs.oasis-open.org/ns/office/1.2/meta/pkg#File + const short PKG_FILE = 2006; + /// http://docs.oasis-open.org/ns/office/1.2/meta/pkg#MetadataFile + const short PKG_METADATAFILE = 2007; + /// http://docs.oasis-open.org/ns/office/1.2/meta/pkg#Document + const short PKG_DOCUMENT = 2008; + + /// http://docs.oasis-open.org/ns/office/1.2/meta/odf#prefix const short ODF_PREFIX = 2100; - /// http://docs.oasis-open.org/opendocument/meta/package/odf#suffix + /// http://docs.oasis-open.org/ns/office/1.2/meta/odf#suffix const short ODF_SUFFIX = 2101; - /// http://docs.oasis-open.org/opendocument/meta/package/odf#Element + /// http://docs.oasis-open.org/ns/office/1.2/meta/odf#Element const short ODF_ELEMENT = 2102; - /// http://docs.oasis-open.org/opendocument/meta/package/odf#ContentFile + /// http://docs.oasis-open.org/ns/office/1.2/meta/odf#ContentFile const short ODF_CONTENTFILE = 2103; - /// http://docs.oasis-open.org/opendocument/meta/package/odf#StylesFile + /// http://docs.oasis-open.org/ns/office/1.2/meta/odf#StylesFile const short ODF_STYLESFILE = 2104; - /// http://docs.oasis-open.org/opendocument/meta/package/odf#MetadataFile +/* REMOVED + /// http://docs.oasis-open.org/ns/office/1.2/meta/odf#MetadataFile const short ODF_METADATAFILE = 2105; +*/ /// urn:oasis:names:tc:opendocument:xmlns:text:1.0meta-field // const short TEXT_META_FIELD = 3000; diff --git a/offapi/com/sun/star/rdf/XDocumentMetadataAccess.idl b/offapi/com/sun/star/rdf/XDocumentMetadataAccess.idl index 6eda7bf0da0e..9c82d75546a3 100644 --- a/offapi/com/sun/star/rdf/XDocumentMetadataAccess.idl +++ b/offapi/com/sun/star/rdf/XDocumentMetadataAccess.idl @@ -55,6 +55,10 @@ #include <com/sun/star/io/IOException.idl> #endif +#ifndef __com_sun_star_io_XInputStream_idl__ +#include <com/sun/star/io/XInputStream.idl> +#endif + #ifndef __com_sun_star_datatransfer_UnsupportedFlavorException_idl__ #include <com/sun/star/datatransfer/UnsupportedFlavorException.idl> #endif @@ -63,8 +67,8 @@ #include <com/sun/star/embed/XStorage.idl> #endif -#ifndef __com_sun_star_io_XInputStream_idl__ -#include <com/sun/star/io/XInputStream.idl> +#ifndef __com_sun_star_task_XInteractionHandler_idl__ +#include <com/sun/star/task/XInteractionHandler.idl> #endif #ifndef __com_sun_star_rdf_FileFormat_idl__ @@ -100,20 +104,15 @@ module com { module sun { module star { module rdf { the content and the RDF metadata of an ODF document. The main idea is to make querying and manipulating the data in the metadata manifest easier. - Among other things, the metadata manifest contains a mapping between ODF - elements (in the "content.xml" and "styles.xml" streams) and URIs. - Such a mapping works by associating the XML ID of the ODF element with - the URI by an RDF statement of the form: - <code>URI pkg:idref XmlId.</code> </p> <p> - Note that this interface inherits from <type>XResource</type>: the - UUID of the package is the string value of the RDF node. - This is so that you can easily make RDF statements about the package. + Note that this interface inherits from <type>XURI</type>: the + base URI of the document is the string value of the RDF node. + This is so that you can easily make RDF statements about the document. </p> - @since OOo 3.0 + @since OOo 3.2 @see XDocumentRepository */ @@ -123,33 +122,22 @@ interface XDocumentMetadataAccess interface XRepositorySupplier; //------------------------------------------------------------------------- - /** get the UUID for the ODF package. + /** get the unique ODF element with the given metadata reference. - @returns - a universally unique ID that identifies this ODF package - */ - string getPackageUUID(); - - //------------------------------------------------------------------------- - /** get the unique ODF element with the given XML ID. - - @param XmlId - an XML ID, comprising the stream name and the "xml:id" attribute. - For example: "content.xml#foo-element-1" + @param MetadataReference + a metadata reference, comprising the stream name and the XML ID + For example: Pair("content.xml", "foo-element-1") @returns - the ODF element with the given XML ID if it exists, else <NULL/> + the ODF element with the given metadata references if it exists, + else <NULL/> */ - XMetadatable getElementByXmlId([in] string XmlId); + XMetadatable getElementByMetadataReference( + [in] com::sun::star::beans::StringPair MetadataReference); //------------------------------------------------------------------------- /** get the ODF element that corresponds to an URI. - <p> - Convenience method that uses the mapping established in the - "manifest.rdf" to locate the ODF element corresponding to an URI. - </p> - @param URI an URI that may identify an ODF element @@ -163,94 +151,6 @@ interface XDocumentMetadataAccess raises( com::sun::star::lang::IllegalArgumentException ); //------------------------------------------------------------------------- - /** find the URI that is associated with an ODF element in the manifest. - - @param Element - the ODF element for which the URI should be returned - - @returns - the URI associated with the element, or <NULL/> - - @throws com::sun::star::lang::IllegalArgumentException - if the given Element is <NULL/> - */ - XURI getURIForElement([in] XMetadatable Element) - raises( com::sun::star::lang::IllegalArgumentException ); - - //------------------------------------------------------------------------- - /** create an URI for an ODF element. - - <p> - Convenience method that generates an URI for the given ODF element, - and inserts a mapping between the URI and the XML ID of the ODF element - into the manifest. - If the element does not have a XML ID yet, a new XML ID will be - generated. - If an URI for the element already exists, it will be returned. - </p> - - @param Element - the ODF element for which an URI should be created. - - @returns - the URI associated with the element - - @throws com::sun::star::lang::IllegalArgumentException - if the given Element is <NULL/> - */ - XURI getOrCreateURIForElement([in] XMetadatable Element) - raises( com::sun::star::lang::IllegalArgumentException ); - - //------------------------------------------------------------------------- - /** establish mapping between an ODF Element and an URI in the manifest. - - <p> - This method Convenience method that generates an URI for the given - ODF element, and inserts a mapping between the URI and the XML ID - of the ODF element into the manifest. - If the element does not have a XML ID yet, a new XML ID will be - generated. - If there already exists an URI for the element, the mapping will not - be changed, and an - <type scope="com::sun::star::container">ElementExistException</type> - will be thrown. - </p> - - <p> - Note that the mapping maintained by this method is a one-to-one - mapping, even though the specification technically permits - mapping an XML ID to multiple URIs. - </p> - - @param Element - the ODF element with which an URI should be associated - - @param URI - the URI which should be associated with the Element - - @throws com::sun::star::lang::IllegalArgumentException - if any argument is <NULL/> - - @throws com::sun::star::container::ElementExistException - if either the URI or the XML ID of the Element is already mapped - */ - void createMappingForElement([in] XMetadatable Element, [in] XURI URI) - raises( com::sun::star::lang::IllegalArgumentException, - com::sun::star::container::ElementExistException ); - - //------------------------------------------------------------------------- - /** removes mapping for an ODF element from the manifest. - - @param Element - the ODF element for which the mapping should be removed - - @throws com::sun::star::lang::IllegalArgumentException - if the given Element is <NULL/> - */ - void removeMappingForElement([in] XMetadatable Element) - raises( com::sun::star::lang::IllegalArgumentException ); - - //------------------------------------------------------------------------- /** get the names of all metadata files with a given type. @param Type @@ -272,8 +172,8 @@ interface XDocumentMetadataAccess <p> This convenience method does the following: <ul> - <li>create a new graph with the given GraphName in the repository</li> - <li>insert the required statements declaring the new graph to be a + <li>create a new graph with the given name in the repository</li> + <li>insert statements declaring the new graph to be a metadata file into the manifest graph</li> <li>insert statements declaring <code>rdf:type</code> properties for the new graph into the manifest graph</li> @@ -281,24 +181,23 @@ interface XDocumentMetadataAccess </p> @param FileName - the name of the stream in the ODF package where the graph will + the name of the stream in the ODF storage where the graph will be stored - @param GraphName - the name of the graph that is to be created - @param Types a list of types that will be inserted as <code>rdf:type</code> properties for the graph + @returns + the name of the new graph + @throws com::sun::star::lang::IllegalArgumentException - if the given GraphName is <NULL/>, or the FileName is invalid + if the FileName is invalid @throws com::sun::star::container::ElementExistException - if a graph with the given GraphName, or a stream with the given - FileName, already exists + if a stream with the given FileName already exists */ - void addMetadataFile([in] string FileName, [in] XURI GraphName, + XURI addMetadataFile([in] string FileName, [in] sequence<XURI> Types ) raises( com::sun::star::lang::IllegalArgumentException, com::sun::star::container::ElementExistException ); @@ -309,19 +208,18 @@ interface XDocumentMetadataAccess <p> This convenience method does the following: - <li>import the given file into a graph with the given GraphName + <li>import the given file into a graph with the given name in the repository</li> - <li>insert the required statements declaring the new graph to be a + <li>insert statements declaring the new graph to be a metadata file into the manifest graph</li> + <li>insert statements declaring <code>rdf:type</code> properties + for the new graph into the manifest graph</li> </p> @param FileName - the name of the stream in the ODF package where the graph will + the name of the stream in the ODF storage where the graph will be stored - @param GraphName - the name of the graph that is to be created - @param BaseURI a base URI to resolve relative URI references @@ -329,8 +227,11 @@ interface XDocumentMetadataAccess a list of types that will be inserted as <code>rdf:type</code> properties for the graph + @returns + the name of the new graph + @throws com::sun::star::lang::IllegalArgumentException - if the given stream or the GraphName is <NULL/>, + if the given stream is <NULL/>, or BaseURI is <NULL/> and the format requires use of a base URI, or the FileName is invalid @@ -338,8 +239,7 @@ interface XDocumentMetadataAccess if the format requested is unknown or not supported @throws com::sun::star::container::ElementExistException - if a graph with the given GraphName, or a stream with the given - FileName, already exists + if a stream with the given FileName already exists @throws ParseException if the input does not conform to the specified file format. @@ -349,9 +249,9 @@ interface XDocumentMetadataAccess @see FileFormat */ - void importMetadataFile( [in] /*FileFormat*/ short Format, + XURI importMetadataFile( [in] /*FileFormat*/ short Format, [in] com::sun::star::io::XInputStream InStream, - [in] string FileName, [in] XURI GraphName, [in] XURI BaseURI, + [in] string FileName, [in] XURI BaseURI, [in] sequence<XURI> Types ) raises( com::sun::star::lang::IllegalArgumentException, com::sun::star::datatransfer::UnsupportedFlavorException, @@ -398,7 +298,7 @@ interface XDocumentMetadataAccess </p> @param FileName - the name of the stream in the ODF package + the name of the stream in the ODF storage @throws com::sun::star::lang::IllegalArgumentException if the FileName is invalid @@ -415,12 +315,11 @@ interface XDocumentMetadataAccess <p> This convenience method removes the statements declaring a - content or styles file from the manifest graph, as well as - all mappings that refer to the file. + content or styles file from the manifest graph. </p> @param FileName - the name of the stream in the ODF package + the name of the stream in the ODF storage @throws com::sun::star::lang::IllegalArgumentException if the FileName is invalid @@ -447,22 +346,35 @@ interface XDocumentMetadataAccess In this case, the document metadata will be default initialized. </p> + <p> + If an InteractionHandler argument is given, it will be used for + error reporting. Otherwise, errors will be reported as exceptions. + </p> + @param Storage - a storage, representing e.g. an ODF package file + a storage, representing e.g. an ODF package file, or sub-document @param BaseURI a base URI to resolve relative URI references + <p>N.B.: when loading from an ODF package, the base URI is not the + URI of the package, but the URI of the directory in the package + that contains the metadata.rdf</p> + + @param InteractionHandler + an InteractionHandler, used for error reporting @throws com::sun::star::lang::IllegalArgumentException if any argument is <NULL/> + + @throws com::sun::star::lang::WrappedTargetException + if an error occurs while loading and no InteractionHandler given */ -//FIXME: how to do error handling??? this thing must be able to report any number of errors in any number of streams... XInteractionHandler??? void loadMetadataFromStorage( [in] com::sun::star::embed::XStorage Storage, - [in] XURI BaseURI) - raises( com::sun::star::lang::IllegalArgumentException ); -// com::sun::star::io::IOException, -// com::sun::star::); + [in] XURI BaseURI, + [in] com::sun::star::task::XInteractionHandler InteractionHandler ) + raises( com::sun::star::lang::IllegalArgumentException, + com::sun::star::lang::WrappedTargetException ); //------------------------------------------------------------------------- /** store document metadata to a storage. @@ -474,28 +386,29 @@ interface XDocumentMetadataAccess <p> Note that to be stored correctly, a named graph must have a complete - entry in the manifest graph, with a <code>pkg:path</code> property - that denotes a legal stream name. + entry in the manifest graph. </p> @param Storage - a storage, representing e.g. an ODF package file + a storage, representing e.g. an ODF package file, or sub-document @throws com::sun::star::lang::IllegalArgumentException - if any argument is <NULL/> + if Storage argument is <NULL/> + + @throws com::sun::star::lang::WrappedTargetException + if an error occurs while loading */ -//FIXME error handling void storeMetadataToStorage( - [in] com::sun::star::embed::XStorage Storage) - raises( com::sun::star::lang::IllegalArgumentException ); -// com::sun::star::io::IOException, -// com::sun::star:: ); + [in] com::sun::star::embed::XStorage Storage ) + raises( com::sun::star::lang::IllegalArgumentException, + com::sun::star::lang::WrappedTargetException ); -//FIXME error handling for these? -//Note: any errors when accessing individual streams in the medium (including the manifest) will not be reported to the caller unless an XInteractionHandler is supplied. //------------------------------------------------------------------------- /** loads document metadata from a medium. + <p>If the Medium contains an InteractionHandler, it will be used for + error reporting.</p> + @param Medium the <type>com::sun::star::document::MediaDescriptor</type> representing the source @@ -504,18 +417,14 @@ interface XDocumentMetadataAccess if the argument does not contain a URL or Stream property @throws com::sun::star::lang::WrappedTargetException - if thrown when trying to access the medium - - @throws com::sun::star::io::IOException - if thrown when trying to access the medium + if an error occurs while loading @see com::sun::star::document::MediaDescriptor */ void loadMetadataFromMedium( [in] sequence < com::sun::star::beans::PropertyValue > Medium ) raises( com::sun::star::lang::IllegalArgumentException, - com::sun::star::lang::WrappedTargetException, - com::sun::star::io::IOException ); + com::sun::star::lang::WrappedTargetException ); //------------------------------------------------------------------------- /** stores document metadata to a medium. @@ -528,18 +437,14 @@ interface XDocumentMetadataAccess if the argument does not contain a URL or Stream property @throws com::sun::star::lang::WrappedTargetException - if thrown when trying to access the medium - - @throws com::sun::star::io::IOException - if thrown when trying to access the medium + if an error occurs while storing @see com::sun::star::document::MediaDescriptor */ void storeMetadataToMedium( [in] sequence < com::sun::star::beans::PropertyValue > Medium ) raises( com::sun::star::lang::IllegalArgumentException, - com::sun::star::lang::WrappedTargetException, - com::sun::star::io::IOException ); + com::sun::star::lang::WrappedTargetException ); }; diff --git a/offapi/com/sun/star/rdf/XDocumentRepository.idl b/offapi/com/sun/star/rdf/XDocumentRepository.idl index bd7f6d2259b6..d9131291d81a 100644 --- a/offapi/com/sun/star/rdf/XDocumentRepository.idl +++ b/offapi/com/sun/star/rdf/XDocumentRepository.idl @@ -31,10 +31,6 @@ #ifndef __com_sun_star_rdf_XDocumentRepository_idl__ #define __com_sun_star_rdf_XDocumentRepository_idl__ -#ifndef __com_sun_star_text_XTextRange_idl__ -#include <com/sun/star/text/XTextRange.idl> -#endif - #ifndef __com_sun_star_rdf_XMetadatable_idl__ #include <com/sun/star/rdf/XMetadatable.idl> #endif @@ -58,7 +54,7 @@ module com { module sun { module star { module rdf { which is stored as RDFa. </p> - @since OOo 3.0 + @since OOo 3.2 @see XRepositorySupplier @see XDocumentMetadataAccess @@ -73,22 +69,30 @@ interface XDocumentRepository : XRepository <p> This method will do the following steps: <ol> - <li>Remove all RDFa statements that involve the Object parameter from - the repository</li> + <li>Remove all previously set RDFa statements for the Object parameter + from the repository</li> <li>If the RDFaContent parameter is the empty <atom>string</atom>, + for every Predicate in the given list of Predicates, add the following RDF statement to an unspecified named graph: <ul> - <li><code>Subject Predicate XLiteral(Object->getText())</code></li> + <li><code>Subject Predicate + XLiteral(Object->getText()^^RDFaDatatype)</code></li> </ul> </li> <li>If the RDFaContent parameter is not the empty <atom>string</atom>, - add the following RDF statements to an unspecified named graph: + for every Predicate in the given list of Predicates, + add the following RDF statement to an unspecified named graph: <ul> <li> <code>Subject Predicate XLiteral(RDFaContent^^RDFaDatatype)</code> </li> + </ul> + Further, add the following RDF statement to the same unspecified + named graph: + <ul> <li> - <code>Subject rdfs:label XLiteral(Object->getText())</code></li> + <code>Subject rdfs:label XLiteral(Object->getText())</code> + </li> </ul> </li> </ol> @@ -97,22 +101,22 @@ interface XDocumentRepository : XRepository <p> RDFa statements are handled specially because they are not logically part of any named graph in the repository. - Also, they have rather unusual semantics. - Also, just using <method>XNamedGraph::addStatement</method> - for this would be ambiguous: - if the object is a XMetadatable, do we insert the object itself (URI) - or its literal content (RDFa)? + Also, they have rather unusual semantics; + just using <member>XNamedGraph::addStatement</member> would be + ambiguous: + if the object is a <type>XMetadatable</type>, do we insert + the object itself (URI) or its literal content (RDFa)? </p> -//FIXME: updates??? @param Subject - the subject of the RDF triple. + the subject of the RDF triple(s). - @param Predicate - the predicate of the RDF triple. + @param Predicates + the predicates of the RDF triple(s). @param Object - the object of the RDF triple is the text content of this parameter. + the object of the RDF triple(s) is the text content of this + parameter. @param RDFaContent the <code>rdfa:content</code> attribute (may be the empty @@ -122,16 +126,16 @@ interface XDocumentRepository : XRepository the <code>rdfa:datatype</code> attribute (may be <NULL/>) @throws com::sun::star::lang::IllegalArgumentException - if any parameter is <NULL/>, + if any parameter is <NULL/>, Predicates is empty, or Object is of a type that can not have RDFa metadata attached. @throws RepositoryException if an error occurs when accessing the repository. */ void setStatementRDFa( - [in] XURI Subject, - [in] XURI Predicate, - [in] com::sun::star::text::XTextRange Object, + [in] XResource Subject, + [in] sequence<XURI> Predicates, + [in] XMetadatable Object, [in] string RDFaContent, [in] XURI RDFaDatatype) raises( com::sun::star::lang::IllegalArgumentException, @@ -146,7 +150,7 @@ interface XDocumentRepository : XRepository part of any graph. </p> - @param Object + @param Element the element whose RDFa statement(s) should be removed @throws com::sun::star::lang::IllegalArgumentException @@ -156,7 +160,7 @@ interface XDocumentRepository : XRepository @throws RepositoryException if an error occurs when accessing the repository. */ - void removeStatementRDFa([in] com::sun::star::text::XTextRange Object) + void removeStatementRDFa([in] XMetadatable Element) raises( com::sun::star::lang::IllegalArgumentException, RepositoryException ); @@ -170,13 +174,14 @@ interface XDocumentRepository : XRepository <ul> <li>if the element has no RDFa meta-data attributes: the empty sequence.</li> - <li>if the element has RDFa meta-data attributes, + <li>if the element has RDFa meta-data attributes: and no <code>rdfa:content</code> attached: - a sequence with a single element: the RDFa-statement</li> + a sequence with the RDFa-statements corresponding to the + attributes</li> <li>if the element has RDFa meta-data attributes, and also <code>rdfa:content</code> attached: - a sequence with 2 elements: first the RDFa-statement, - then the RDFa-labels-statement</li> + a sequence with the RDFa-statements corresponding to the + attributes, including the RDFa-labels-statement</li> </ul> @throws com::sun::star::lang::IllegalArgumentException @@ -198,7 +203,7 @@ interface XDocumentRepository : XRepository <p> This method exists because RDFa statements are not part of any named graph, and thus they cannot be enumerated with - <method>XNamedGraph::getStatements</method>. + <member>XNamedGraph::getStatements</member>. </p> <p> @@ -230,7 +235,7 @@ interface XDocumentRepository : XRepository */ com::sun::star::container::XEnumeration/*<Statement>*/ getStatementsRDFa( [in] XResource Subject, - [in] XResource Predicate, + [in] XURI Predicate, [in] XNode Object) raises( RepositoryException ); diff --git a/offapi/com/sun/star/rdf/XMetadatable.idl b/offapi/com/sun/star/rdf/XMetadatable.idl index 9c702cfc4db7..19b25f8b58a0 100644 --- a/offapi/com/sun/star/rdf/XMetadatable.idl +++ b/offapi/com/sun/star/rdf/XMetadatable.idl @@ -35,8 +35,12 @@ #include <com/sun/star/lang/IllegalArgumentException.idl> #endif -#ifndef __com_sun_star_rdf_XResource_idl__ -#include <com/sun/star/rdf/XResource.idl> +#ifndef __com_sun_star_beans_StringPair_idl__ +#include <com/sun/star/beans/StringPair.idl> +#endif + +#ifndef __com_sun_star_rdf_XURI_idl__ +#include <com/sun/star/rdf/XURI.idl> #endif @@ -50,42 +54,52 @@ module com { module sun { module star { module rdf { <p> To make using ODF elements as part of RDF statements more convenient, - this interface inherits from XRDFResource. + this interface inherits from <type>XURI</type>. + The URI is constructed by concatenating the URI of the document, the + stream name, a fragment separator, and the XML ID. + </p> + + <p> + Note that using the <type>XURI</type> interface on an instance of + <type>XMetadatable</type> may have the side effect of creating a metadata + reference for the instance. </p> - @since OOo 3.0 + @since OOo 3.2 - @see XRDFRepository + @see XRepository + @see XDocumentMetadataAccess */ -interface XMetadatable : XResource +interface XMetadatable : XURI { //------------------------------------------------------------------------- - /** an XML ID, comprising the stream name and the xml:id attribute. + /** a metadata reference, comprising the stream name and the XML ID. <p> - Note that this ID must be unique for the ODF document. - This implies that the xml:id part must be unique for every stream. - The ID may be omitted, in which case the value is the empty string. - For Example: "content.xml#foo-element-1" + Note that this metadata reference must be unique for the ODF document. + This implies that the XML ID part must be unique for every stream. + A pair of two empty strings signifies "no metadata reference". + For example: Pair("content.xml", "foo-element-1") </p> @throws com::sun::star::lang::IllegalArgumentException - if the given XmlId is invalid, or not unique + if the given metadata reference is invalid, or not unique */ - [attribute] string XmlId { + [attribute] com::sun::star::beans::StringPair MetadataReference { set raises ( com::sun::star::lang::IllegalArgumentException ); }; //------------------------------------------------------------------------- - /** creates an XML ID for this object, if necessary. + /** creates a metadata reference for this object, if necessary. <p> - If this object already has an XML ID, do nothing; - otherwise, create a fresh, unique XML ID and assign it to the - XmlId attribute. + If this object already has a metadata reference, do nothing; + otherwise, create metadata reference with a fresh, unique XML ID + and assign it to the MetadataReference attribute. </p> */ - void ensureXmlId(); + void ensureMetadataReference(); + }; //============================================================================= diff --git a/offapi/com/sun/star/rdf/XNamedGraph.idl b/offapi/com/sun/star/rdf/XNamedGraph.idl index be7b67448e9f..33c09cdfceee 100644 --- a/offapi/com/sun/star/rdf/XNamedGraph.idl +++ b/offapi/com/sun/star/rdf/XNamedGraph.idl @@ -67,13 +67,13 @@ module com { module sun { module star { module rdf { <p> Note that instances may be destroyed via - <method>XRepository::destroyGraph</method>. - If a graph is destroyed, subsequent calls to <method>addStatement</method>, - <method>removeStatement</method> will fail with an + <member>XRepository::destroyGraph</member>. + If a graph is destroyed, subsequent calls to <member>addStatement</member>, + <member>removeStatements</member> will fail with an <type scope="com::sun::star::container">NoSuchElementException</type>. </p> - @since OOo 3.0 + @since OOo 3.2 @see XRepository */ @@ -134,7 +134,7 @@ interface XNamedGraph : XURI if an error occurs when accessing the repository. */ void addStatement([in] XResource Subject, - [in] XResource Predicate, + [in] XURI Predicate, [in] XNode Object) raises( com::sun::star::lang::IllegalArgumentException, com::sun::star::container::NoSuchElementException, @@ -172,7 +172,7 @@ interface XNamedGraph : XURI if an error occurs when accessing the repository. */ void removeStatements([in] XResource Subject, - [in] XResource Predicate, + [in] XURI Predicate, [in] XNode Object) raises( com::sun::star::container::NoSuchElementException, RepositoryException ); @@ -217,7 +217,7 @@ interface XNamedGraph : XURI */ com::sun::star::container::XEnumeration/*<Statement>*/ getStatements( [in] XResource Subject, - [in] XResource Predicate, + [in] XURI Predicate, [in] XNode Object) raises( com::sun::star::container::NoSuchElementException, RepositoryException ); diff --git a/offapi/com/sun/star/rdf/XQuerySelectResult.idl b/offapi/com/sun/star/rdf/XQuerySelectResult.idl index 9148b6b0db85..1d9641edf37d 100644 --- a/offapi/com/sun/star/rdf/XQuerySelectResult.idl +++ b/offapi/com/sun/star/rdf/XQuerySelectResult.idl @@ -51,7 +51,7 @@ module com { module sun { module star { module rdf { each being a list of bindings for the above variables</li> </ol> Note that each query result retrieved via - <method scope="com::sun::star::container">XEnumeration::nextElement</method> + <member scope="com::sun::star::container">XEnumeration::nextElement</member> has the type <type dim="[]">XNode</type>, the length of the sequence being the same as the number of query variables. </p> diff --git a/offapi/com/sun/star/rdf/XRepository.idl b/offapi/com/sun/star/rdf/XRepository.idl index 3c75b50b206f..6f6e12a2ea5b 100644 --- a/offapi/com/sun/star/rdf/XRepository.idl +++ b/offapi/com/sun/star/rdf/XRepository.idl @@ -126,7 +126,7 @@ module com { module sun { module star { module rdf { </p> - @since OOo 3.0 + @since OOo 3.2 @see XRepositorySupplier @see XDocumentRepository @@ -369,7 +369,7 @@ interface XRepository */ com::sun::star::container::XEnumeration/*<Statement>*/ getStatements( [in] XResource Subject, - [in] XResource Predicate, + [in] XURI Predicate, [in] XNode Object) raises( RepositoryException ); @@ -385,7 +385,7 @@ interface XRepository </p> @param Query - the SPARQL query string + the SPARQL query <atom>string</atom> @returns an enumeration, containing @@ -396,7 +396,7 @@ interface XRepository </ol> @throws QueryException - if the query string is malformed, or evaluation fails + if the query is malformed, or evaluation fails @throws RepositoryException if an error occurs when accessing the repository. @@ -416,14 +416,14 @@ interface XRepository </p> @param Query - the SPARQL query string + the SPARQL query <atom>string</atom> @returns an iterator over the query result graph, represented as an enumeration of <type>Statement</type> @throws QueryException - if the query string is malformed, or evaluation fails + if the query is malformed, or evaluation fails @throws RepositoryException if an error occurs when accessing the repository. @@ -444,13 +444,13 @@ interface XRepository </p> @param Query - the SPARQL query string + the SPARQL query <atom>string</atom> @returns the boolean query result @throws QueryException - if the query string is malformed, or evaluation fails + if the query is malformed, or evaluation fails @throws RepositoryException if an error occurs when accessing the repository. diff --git a/offapi/com/sun/star/sdb/application/XCopyTableWizard.idl b/offapi/com/sun/star/sdb/application/XCopyTableWizard.idl index 01f6fc783201..8a9bbf52b052 100644 --- a/offapi/com/sun/star/sdb/application/XCopyTableWizard.idl +++ b/offapi/com/sun/star/sdb/application/XCopyTableWizard.idl @@ -130,6 +130,14 @@ interface XCopyTableWizard : ::com::sun::star::ui::dialogs::XExecutableDialog set raises ( ::com::sun::star::lang::IllegalArgumentException ); }; + /** specifies that the first row should be used to identify column names. + + <p>This attribute is ignored when the source defines the column names which isn't the case when only a part of a table should be copied + e.g. in the RTF format or in the HTML format. + </p> + */ + [attribute] boolean UseHeaderLineAsColumnNames; + /** adds a listener which is to be notified of progress in the copy operation */ void addCopyTableListener( [in] XCopyTableListener Listener ); diff --git a/offapi/com/sun/star/security/DocumentSignatureInformation.idl b/offapi/com/sun/star/security/DocumentSignatureInformation.idl index da418ebac2d4..4ed6d972705c 100644 --- a/offapi/com/sun/star/security/DocumentSignatureInformation.idl +++ b/offapi/com/sun/star/security/DocumentSignatureInformation.idl @@ -59,6 +59,25 @@ struct DocumentSignatureInformation <type scope="com::sun::star::security">CertificateValidity</type>. */ long CertificateStatus; + /* indicates what content of a document is signed. + <p> + This value can be ignored when this struct is returned as part of + a macro signature validation. + As of OpenOffice.org 3.2 and ODF 1.2 the document signature comprises + all files except the signature file itself. + Signatures in OOo 2.x were only + applied to the files in the root of the document, except mimetype, the + Pictures and ObjectReplacements/Objects folder. That is, macros + were not part of the document signature. + OOo 3.0 signed everthing, execept mimetype and the META-INF folder. + <p> + If PartialDocumentSignature is true, then the signature was created by OOo + with a version less then 3.2. In this case, not all files are signed. The + signature can still be regarded as valid, as long as SignatureIsValid is true + and the certificate could be validated. However, users should be notified about + the fact, that not everything in this document is signed. + */ + boolean PartialDocumentSignature; }; diff --git a/offapi/com/sun/star/sheet/DatabaseRange.idl b/offapi/com/sun/star/sheet/DatabaseRange.idl index b613b4eb74cd..eb2fe13d0262 100644 --- a/offapi/com/sun/star/sheet/DatabaseRange.idl +++ b/offapi/com/sun/star/sheet/DatabaseRange.idl @@ -160,7 +160,7 @@ published service DatabaseRange @see com::sun::star::sheet::FormulaToken @see com::sun::star::sheet::FormulaMapGroupSpecialOffset::DB_AREA - @since OOo 2.x + @since OOo 3.0 */ [optional, readonly, property] long TokenIndex; }; diff --git a/offapi/com/sun/star/sheet/FilterFormulaParser.idl b/offapi/com/sun/star/sheet/FilterFormulaParser.idl new file mode 100644 index 000000000000..ed1a1d073e29 --- /dev/null +++ b/offapi/com/sun/star/sheet/FilterFormulaParser.idl @@ -0,0 +1,55 @@ +/************************************************************************* + * + * 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: FilterFormulaParser.idl,v $ + * $Revision: 1.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. + * + ************************************************************************/ + +#ifndef __com_sun_star_sheet_FilterFormulaParser_idl__ +#define __com_sun_star_sheet_FilterFormulaParser_idl__ + +#include <com/sun/star/sheet/XFilterFormulaParser.idl> +#include <com/sun/star/lang/XComponent.idl> + +//============================================================================= + +module com { module sun { module star { module sheet { + +//============================================================================= + +/** A service used to implement parsing and printing formula strings in a + specific formula language. + */ +service FilterFormulaParser : XFilterFormulaParser +{ +}; + +//============================================================================= + +}; }; }; }; + +#endif + diff --git a/offapi/com/sun/star/sheet/FilterOperator2.idl b/offapi/com/sun/star/sheet/FilterOperator2.idl new file mode 100644 index 000000000000..94935979c8f5 --- /dev/null +++ b/offapi/com/sun/star/sheet/FilterOperator2.idl @@ -0,0 +1,164 @@ +/************************************************************************* + * + * 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: FilterOperator2.idl,v $ + * $Revision: 1.7 $ + * + * 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. + * + ************************************************************************/ + +#ifndef __com_sun_star_sheet_FilterOperator2_idl__ +#define __com_sun_star_sheet_FilterOperator2_idl__ + +//============================================================================= + +module com { module sun { module star { module sheet { + +//============================================================================= + +/** specifies the type of a single condition in a filter descriptor. + + <p>This constants group extends the <type>FilterOperator</type> enum by + additional filter operators.</p> + + @since OOo 3.2 + */ +published constants FilterOperator2 +{ + + //------------------------------------------------------------------------- + + /** selects empty entries. + */ + const long EMPTY = 0; + + //------------------------------------------------------------------------- + + /** selects non-empty entries. + */ + const long NOT_EMPTY = 1; + + //------------------------------------------------------------------------- + + /** value has to be equal to the specified value. + */ + const long EQUAL = 2; + + //------------------------------------------------------------------------- + + /** value must not be equal to the specified value. + */ + const long NOT_EQUAL = 3; + + //------------------------------------------------------------------------- + + /** value has to be greater than the specified value. + */ + const long GREATER = 4; + + //------------------------------------------------------------------------- + + /** value has to be greater than or equal to the specified value. + */ + const long GREATER_EQUAL = 5; + + //------------------------------------------------------------------------- + + /** value has to be less than the specified value. + */ + const long LESS = 6; + + //------------------------------------------------------------------------- + + /** value has to be less than or equal to the specified value. + */ + const long LESS_EQUAL = 7; + + //------------------------------------------------------------------------- + + /** selects a specified number of entries with the greatest values. + */ + const long TOP_VALUES = 8; + + //------------------------------------------------------------------------- + + /** selects a specified percentage of entries with the greatest values. + */ + const long TOP_PERCENT = 9; + + //------------------------------------------------------------------------- + + /** selects a specified number of entries with the lowest values. + */ + const long BOTTOM_VALUES = 10; + + //------------------------------------------------------------------------- + + /** selects a specified percentage of entries with the lowest values. + */ + const long BOTTOM_PERCENT = 11; + + //------------------------------------------------------------------------- + + /** selects contains entries. + */ + const long CONTAINS = 12; + + //------------------------------------------------------------------------- + + /** selects does-not-contain entries. + */ + const long DOES_NOT_CONTAIN = 13; + + //------------------------------------------------------------------------- + + /** selects begins-with entries. + */ + const long BEGINS_WITH = 14; + + //------------------------------------------------------------------------- + + /** selects does-not-begin-with entries. + */ + const long DOES_NOT_BEGIN_WITH = 15; + //------------------------------------------------------------------------- + + /** selects ends-with entries. + */ + const long ENDS_WITH = 16; + + //------------------------------------------------------------------------- + + /** selects does-not-end-with entries. + */ + const long DOES_NOT_END_WITH = 17; + +}; + +//============================================================================= + +}; }; }; }; + +#endif + diff --git a/offapi/com/sun/star/sheet/FormulaParser.idl b/offapi/com/sun/star/sheet/FormulaParser.idl index ba38acf791b0..2f8be7e8ee9b 100644 --- a/offapi/com/sun/star/sheet/FormulaParser.idl +++ b/offapi/com/sun/star/sheet/FormulaParser.idl @@ -37,9 +37,6 @@ #ifndef __com_sun_star_sheet_XFormulaParser_idl__ #include <com/sun/star/sheet/XFormulaParser.idl> #endif -#ifndef __com_sun_star_table_CellAddress_idl__ -#include <com/sun/star/table/CellAddress.idl> -#endif #ifndef __com_sun_star_sheet_FormulaOpCodeMapEntry_idl__ #include <com/sun/star/sheet/FormulaOpCodeMapEntry.idl> #endif @@ -65,10 +62,6 @@ service FormulaParser // ------------------------------------------------------------------------ - [property] com::sun::star::table::CellAddress ReferencePosition; - - // ------------------------------------------------------------------------ - /** specifies whether to use English parser and formatter. <p>Note: When changing this, an already existing <member>OpCodeMap diff --git a/offapi/com/sun/star/sheet/NamedRange.idl b/offapi/com/sun/star/sheet/NamedRange.idl index 65c14dc2fcdf..c6f97c0f09e2 100644 --- a/offapi/com/sun/star/sheet/NamedRange.idl +++ b/offapi/com/sun/star/sheet/NamedRange.idl @@ -84,7 +84,7 @@ published service NamedRange @see com::sun::star::sheet::FormulaToken @see com::sun::star::sheet::FormulaMapGroupSpecialOffset::NAME - @since OOo 2.x + @since OOo 3.0 */ [optional, readonly, property] long TokenIndex; diff --git a/offapi/com/sun/star/sheet/TableFilterField2.idl b/offapi/com/sun/star/sheet/TableFilterField2.idl new file mode 100644 index 000000000000..1cf50ddd547b --- /dev/null +++ b/offapi/com/sun/star/sheet/TableFilterField2.idl @@ -0,0 +1,106 @@ +/************************************************************************* + * + * 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: TableFilterField2.idl,v $ + * $Revision: 1.7 $ + * + * 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. + * + ************************************************************************/ + +#ifndef __com_sun_star_sheet_TableFilterField2_idl__ +#define __com_sun_star_sheet_TableFilterField2_idl__ + + +#ifndef __com_sun_star_sheet_FilterConnection_idl__ +#include <com/sun/star/sheet/FilterConnection.idl> +#endif + +#ifndef __com_sun_star_sheet_FilterOperator2_idl__ +#include <com/sun/star/sheet/FilterOperator2.idl> +#endif + +//============================================================================= + +module com { module sun { module star { module sheet { + +//============================================================================= + +/** describes a single condition in a filter descriptor. + + <p>This struct has the <type>FilterOperator2</type> constants group as + member, whereas the <type>TableFilterField</type> struct uses the + <type>FilterOperator</type> enum.</p> + + @see com::sun::star::sheet::SheetFilterDescriptor + @since OOo 3.2 + */ +published struct TableFilterField2 +{ + //------------------------------------------------------------------------- + + /** specifies how the condition is connected to the previous condition. + */ + com::sun::star::sheet::FilterConnection Connection; + + //------------------------------------------------------------------------- + + /** specifies which field (column) is used for the condition. + */ + long Field; + + //------------------------------------------------------------------------- + + /** specifies the type of the condition as defined in + <type>FilterOperator2</type>. + */ + long Operator; + + //------------------------------------------------------------------------- + + /** selects whether the <member>TableFilterField2::NumericValue</member> + or the <member>TableFilterField2::StringValue</member> is used. + */ + boolean IsNumeric; + + //------------------------------------------------------------------------- + + /** specifies a numeric value for the condition. + */ + double NumericValue; + + //------------------------------------------------------------------------- + + /** specifies a string value for the condition. + */ + string StringValue; + +}; + +//============================================================================= + +}; }; }; }; + + +#endif + diff --git a/offapi/com/sun/star/sheet/XFilterFormulaParser.idl b/offapi/com/sun/star/sheet/XFilterFormulaParser.idl new file mode 100644 index 000000000000..300a0981d09d --- /dev/null +++ b/offapi/com/sun/star/sheet/XFilterFormulaParser.idl @@ -0,0 +1,62 @@ +/************************************************************************* + * + * 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: XFilterFormulaParser.idl,v $ + * $Revision: 1.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. + * + ************************************************************************/ + +#ifndef __com_sun_star_sheet_XFilterFormulaParser_idl__ +#define __com_sun_star_sheet_XFilterFormulaParser_idl__ + +#include <com/sun/star/sheet/XFormulaParser.idl> + +//============================================================================= + +module com { module sun { module star { module sheet { + +//============================================================================= + +/** Extends the interface <type>XFormulaParser</type> by an attribute that + specifies the namespace URL of the supported formula language. + */ +interface XFilterFormulaParser : XFormulaParser +{ + //------------------------------------------------------------------------- + + /** Specifies the namespace URL of the formula language supported by this + implementation. + */ + [attribute, readonly] string SupportedNamespace; + + //------------------------------------------------------------------------- +}; + +//============================================================================= + +}; }; }; }; + +#endif + diff --git a/offapi/com/sun/star/sheet/XFormulaParser.idl b/offapi/com/sun/star/sheet/XFormulaParser.idl index b4c02cea3bd1..de78f00f02dd 100644 --- a/offapi/com/sun/star/sheet/XFormulaParser.idl +++ b/offapi/com/sun/star/sheet/XFormulaParser.idl @@ -31,13 +31,9 @@ #ifndef __com_sun_star_sheet_XFormulaParser_idl__ #define __com_sun_star_sheet_XFormulaParser_idl__ -#ifndef __com_sun_star_uno_XInterface_idl__ #include <com/sun/star/uno/XInterface.idl> -#endif - -#ifndef __com_sun_star_sheet_FormulaToken_idl__ #include <com/sun/star/sheet/FormulaToken.idl> -#endif +#include <com/sun/star/table/CellAddress.idl> //============================================================================= @@ -53,13 +49,17 @@ interface XFormulaParser /** parses a formula into a sequence of tokens. */ - sequence< FormulaToken > parseFormula( [in] string aFormula ); + sequence< FormulaToken > parseFormula( + [in] string aFormula, + [in] ::com::sun::star::table::CellAddress aReferencePos ); //------------------------------------------------------------------------- /** converts a formula into a string. */ - string printFormula( [in] sequence< FormulaToken > aTokens ); + string printFormula( + [in] sequence< FormulaToken > aTokens, + [in] ::com::sun::star::table::CellAddress aReferencePos ); }; diff --git a/offapi/com/sun/star/sheet/XSheetFilterDescriptor2.idl b/offapi/com/sun/star/sheet/XSheetFilterDescriptor2.idl new file mode 100644 index 000000000000..cc26a73c1674 --- /dev/null +++ b/offapi/com/sun/star/sheet/XSheetFilterDescriptor2.idl @@ -0,0 +1,79 @@ +/************************************************************************* + * + * 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: XSheetFilterDescriptor2.idl,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. + * + ************************************************************************/ + +#ifndef __com_sun_star_sheet_XSheetFilterDescriptor2_idl__ +#define __com_sun_star_sheet_XSheetFilterDescriptor2_idl__ + +#ifndef __com_sun_star_sheet_TableFilterField2_idl__ +#include <com/sun/star/sheet/TableFilterField2.idl> +#endif + +#ifndef __com_sun_star_uno_XInterface_idl__ +#include <com/sun/star/uno/XInterface.idl> +#endif + +//============================================================================= + +module com { module sun { module star { module sheet { + +//============================================================================= + +/** provides access to a collection of filter conditions (filter fields). + + <p>This interface uses the <type>TableFilterField2</type> struct, + whereas the <type>XSheetFilterDescriptor</type> interface uses the + <type>TableFilterField</type> struct.</p> + + @see com::sun::star::sheet::SheetFilterDescriptor + @since OOo 3.2 + */ +published interface XSheetFilterDescriptor2: com::sun::star::uno::XInterface +{ + //------------------------------------------------------------------------- + + /** returns the collection of filter fields. + */ + sequence< com::sun::star::sheet::TableFilterField2 > getFilterFields2(); + + //------------------------------------------------------------------------- + + /** sets a new collection of filter fields. + */ + void setFilterFields2( + [in] sequence< com::sun::star::sheet::TableFilterField2 > aFilterFields ); + +}; + +//============================================================================= + +}; }; }; }; + +#endif + diff --git a/offapi/com/sun/star/sheet/makefile.mk b/offapi/com/sun/star/sheet/makefile.mk index f6ca0810604e..468e96b9860b 100644 --- a/offapi/com/sun/star/sheet/makefile.mk +++ b/offapi/com/sun/star/sheet/makefile.mk @@ -137,7 +137,9 @@ IDLFILES=\ FillDirection.idl\ FillMode.idl\ FilterConnection.idl\ + FilterFormulaParser.idl\ FilterOperator.idl\ + FilterOperator2.idl\ FormulaLanguage.idl\ FormulaMapGroup.idl\ FormulaMapGroupSpecialOffset.idl\ @@ -219,6 +221,7 @@ IDLFILES=\ TableConditionalEntryEnumeration.idl\ TableConditionalFormat.idl\ TableFilterField.idl\ + TableFilterField2.idl\ TableOperationMode.idl\ TablePageBreakData.idl\ TablePageStyle.idl\ @@ -274,6 +277,7 @@ IDLFILES=\ XExternalSheetCache.idl\ XExternalSheetName.idl\ XFillAcrossSheet.idl\ + XFilterFormulaParser.idl\ XFormulaOpCodeMapper.idl\ XFormulaParser.idl\ XFormulaQuery.idl\ @@ -315,6 +319,7 @@ IDLFILES=\ XSheetConditionalEntries.idl\ XSheetConditionalEntry.idl\ XSheetFilterDescriptor.idl\ + XSheetFilterDescriptor2.idl\ XSheetFilterable.idl\ XSheetFilterableEx.idl\ XSheetLinkable.idl\ diff --git a/offapi/com/sun/star/style/ParagraphProperties.idl b/offapi/com/sun/star/style/ParagraphProperties.idl index eff5c91aa645..23574e24dd18 100644 --- a/offapi/com/sun/star/style/ParagraphProperties.idl +++ b/offapi/com/sun/star/style/ParagraphProperties.idl @@ -448,6 +448,15 @@ published service ParagraphProperties */ [optional, property] string ListId; + //------------------------------------------------------------------------- + /** specifies the outline level to which the paragraph belongs + + @since OOo 3.1 + + <p>Value 0 indicates that the paragraph belongs to the body text.</p> + <p>Values [1..10] indicates that the paragraph belongs to the corresponding outline level.</p> + */ + [optional, property] short OutlineLevel; }; //============================================================================= diff --git a/offapi/com/sun/star/style/Style.idl b/offapi/com/sun/star/style/Style.idl index a3492e492130..0965f849576d 100644 --- a/offapi/com/sun/star/style/Style.idl +++ b/offapi/com/sun/star/style/Style.idl @@ -165,7 +165,7 @@ published service Style </ul> - @since OOo 2.0.1. + @since OOo 2.0.1 */ [optional, property] sequence< com::sun::star::beans::NamedValue > ParaStyleConditions; diff --git a/offapi/com/sun/star/task/DocumentMSPasswordRequest.idl b/offapi/com/sun/star/task/DocumentMSPasswordRequest.idl new file mode 100644 index 000000000000..717e590c12ba --- /dev/null +++ b/offapi/com/sun/star/task/DocumentMSPasswordRequest.idl @@ -0,0 +1,67 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright IBM Corporation 2009. + * Copyright 2009 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: DocumentMSPasswordRequest.idl,v $ + * $Revision: 1.0 $ + * + * 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. + * + ************************************************************************/ +#ifndef __com_sun_star_task_DocumentMSPasswordRequest_idl__ +#define __com_sun_star_task_DocumentMSPasswordRequest_idl__ + +#ifndef __com_sun_star_task_PasswordRequest_idl__ +#include <com/sun/star/task/PasswordRequest.idl> +#endif + + +//============================================================================= + +module com { module sun { module star { module task { + +//============================================================================= +/** this request specifies the mode in which the password for Microsoft Office file format encryption should be asked + + <P> + It is supported by <type>InteractionHandler</type> service, and can + be used to interact for a document password. Continuations for using with + the mentioned service are Abort and Approve. + </P> + + @since OOo 3.2 +*/ +published exception DocumentMSPasswordRequest: PasswordRequest +{ + //------------------------------------------------------------------------- + /** the name of the document + */ + string Name; + +}; + +//============================================================================= + +}; }; }; }; + +#endif diff --git a/offapi/com/sun/star/task/DocumentMacroConfirmationRequest2.idl b/offapi/com/sun/star/task/DocumentMacroConfirmationRequest2.idl new file mode 100644 index 000000000000..422f1ab2a9d0 --- /dev/null +++ b/offapi/com/sun/star/task/DocumentMacroConfirmationRequest2.idl @@ -0,0 +1,83 @@ +/************************************************************************* + * + * 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: DocumentMacroConfirmationRequest.idl,v $ + * $Revision: 1.3 $ + * + * 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. + * + ************************************************************************/ + +#ifndef __com_sun_star_task_DocumentMacroConfirmationRequest2_idl__ +#define __com_sun_star_task_DocumentMacroConfirmationRequest2_idl__ + +#include <com/sun/star/task/ClassifiedInteractionRequest.idl> +#include <com/sun/star/embed/XStorage.idl> +#include <com/sun/star/security/DocumentSignatureInformation.idl> + + +//============================================================================= + +module com { module sun { module star { module task { + +//============================================================================= + +/** describes the request to approve or deny the execution of macros contained in + a document. + */ +exception DocumentMacroConfirmationRequest2 : ClassifiedInteractionRequest +{ + /** specifies the URL of the document which contains macros whose execution + should be approved or rejected. + */ + string DocumentURL; + + /** refers to the zip-storage related to the last commited version of the + document. + + This storage is necessary e.g. for displaying the existing signatures to + the user, to allow him a decision whether or not to trust those signatures + and thus the signed macros. + + @see ::com::sun::star::security::XDocumentDigitalSignatures::showScriptingContentSignatures + */ + ::com::sun::star::embed::XStorage + DocumentZipStorage; + + /** contains informations about the ODF version of the document + */ + string DocumentVersion; + + /** contains informations about the signatures in the document + */ + sequence< ::com::sun::star::security::DocumentSignatureInformation > + DocumentSignatureInformation; +}; + +//============================================================================= + +}; }; }; }; + +//============================================================================= + +#endif diff --git a/offapi/com/sun/star/task/XUrlContainer.idl b/offapi/com/sun/star/task/XUrlContainer.idl new file mode 100644 index 000000000000..93839e68fb07 --- /dev/null +++ b/offapi/com/sun/star/task/XUrlContainer.idl @@ -0,0 +1,92 @@ +/************************************************************************* + * + * 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: XPasswordContainer.idl,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. + * + ************************************************************************/ +#ifndef __com_sun_star_task_XUrlContainer_idl__ +#define __com_sun_star_task_XUrlContainer_idl__ + +#ifndef __com_sun_star_uno_XInterface_idl__ +#include <com/sun/star/uno/XInterface.idl> +#endif + +#ifndef __com_sun_star_task_XInteractionHandler_idl__ +#include <com/sun/star/task/XInteractionHandler.idl> +#endif + + +//============================================================================= + +module com { module sun { module star { module task { + +//============================================================================= +/** Allows to store and retrieve URLs. URLs can be stored persistently or + until end of OOo session. +*/ +/*published*/ interface XUrlContainer : com::sun::star::uno::XInterface +{ + //------------------------------------------------------------------------- + /** Add a URL to the container. + + @param Url URL to add to the container + @param MakePersistent indicates whether the URL shall be stored + persistently or just in memory (until end of + OOo session) + */ + void addUrl( [in] string Url, [in] boolean MakePersistent ); + + //------------------------------------------------------------------------- + /** Lookup a URL in the container. + + @param Url URL to lookup. + @returns Best matched URL or empty string. + */ + string findUrl( [in] string Url ); + + //------------------------------------------------------------------------- + /** Remove a URL from the container. + + @param Url URL to remove. + */ + void removeUrl( [in] string Url ); + + //------------------------------------------------------------------------- + /** Get all URLs. + + @param OnlyPersistent Only URLs taht are stored persistently shall + be returned. + @returns List of URLs. + */ + sequence<string> getUrls( [in] boolean OnlyPersistent ); + +}; + +//============================================================================= + +}; }; }; }; + +#endif diff --git a/offapi/com/sun/star/task/makefile.mk b/offapi/com/sun/star/task/makefile.mk index 366d531fc847..dc54f6fd3883 100644 --- a/offapi/com/sun/star/task/makefile.mk +++ b/offapi/com/sun/star/task/makefile.mk @@ -3,6 +3,7 @@ # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # Copyright 2008 by Sun Microsystems, Inc. +# Copyright IBM Corporation 2009. # # OpenOffice.org - a multi-platform office productivity suite # @@ -44,7 +45,9 @@ PACKAGE=com$/sun$/star$/task IDLFILES=\ ClassifiedInteractionRequest.idl\ DocumentMacroConfirmationRequest.idl\ + DocumentMacroConfirmationRequest2.idl\ DocumentPasswordRequest.idl\ + DocumentMSPasswordRequest.idl\ ErrorCodeRequest.idl\ ErrorCodeIOException.idl\ FutureDocumentVersionProductUpdateRequest.idl\ @@ -77,7 +80,8 @@ IDLFILES=\ XStatusIndicatorSupplier.idl\ XAbortChannel.idl\ XInteractionRequestStringResolver.idl\ - InteractionRequestStringResolver.idl + InteractionRequestStringResolver.idl\ + XUrlContainer.idl # ------------------------------------------------------------------ diff --git a/offapi/com/sun/star/text/BaseFrameProperties.idl b/offapi/com/sun/star/text/BaseFrameProperties.idl index 792cac35f583..eadf841134e3 100644 --- a/offapi/com/sun/star/text/BaseFrameProperties.idl +++ b/offapi/com/sun/star/text/BaseFrameProperties.idl @@ -354,6 +354,26 @@ published service BaseFrameProperties */ [optional, property, maybevoid] com::sun::star::awt::Size LayoutSize; + //------------------------------------------------------------------------- + /** contains short title for the object + + <p>This short title is visible as an alternative tag in HTML format. + Accessibility tools can read this text.</p> + + @since OOo 3.2 + */ + [optional, property] string Title; + + //------------------------------------------------------------------------- + /** contains description for the object + + <p>The long description text can be entered to describe a object in + more detail to users with screen reader software. The description is + visible as an alternative tag for accessibility tools.</p> + + @since OOo 3.2 + */ + [optional, property] string Description; }; //============================================================================= diff --git a/offapi/com/sun/star/text/DocumentSettings.idl b/offapi/com/sun/star/text/DocumentSettings.idl index 43fd5eff8f40..171a5caebb9f 100644 --- a/offapi/com/sun/star/text/DocumentSettings.idl +++ b/offapi/com/sun/star/text/DocumentSettings.idl @@ -129,8 +129,6 @@ published service DocumentSettings /** specifies if the former (till OpenOffice.org 1.1) or the new line spacing formatting is applied. - @since OOo 2.0.0 - <p>This property controls how a set line spacing at a paragraph influences the formatting of the text lines and the spacing between paragraphs. @@ -144,14 +142,13 @@ published service DocumentSettings a proportional line spacing is only applied below a text line and it's always added to the paragraph spacing between two paragraphs.</p> + @since OOo 2.0.0 */ [optional, property] boolean UseFormerLineSpacing; // ------------------------------------------------------------ /** specifies if paragraph and table spacing is added at the bottom of table cells - @since OOo 2.0.0 - <p>This property controls, if the spacing of the last paragraph respectively table of a table cell is added at the bottom of this table cells @@ -162,14 +159,13 @@ published service DocumentSettings the spacing of the last paragraph respectively table of a table cell isn't added at the bottom of this table cell.</p> + @since OOo 2.0.0 */ [optional, property] boolean AddParaSpacingToTableCells; // ------------------------------------------------------------ /** specifies if the former (till OpenOffice.org 1.1) or the new object positioning is applied. - @since OOo 2.0.0 - <p>This property controls how floating screen objects (Writer fly frames and drawing objects are positioned. If <TRUE/>, the object positioning till OpenOffice.org 1.1 is @@ -181,6 +177,7 @@ published service DocumentSettings its vertical position, doesn't include the lower spacing and the line spacing of the previous paragraph.</p> + @since OOo 2.0.0 */ [optional, property] boolean UseFormerObjectPositioning; @@ -188,8 +185,6 @@ published service DocumentSettings /** specifies if the text wrap of floating screen objects are considered in a specified way in the positioning algorithm. - @since OOo 2.0.0 - <p>This property controls how floating screen objects (Writer fly frames and drawing objects) are positioned. If <TRUE/>, the object positioning algorithm will consider @@ -199,6 +194,7 @@ published service DocumentSettings If <FALSE/> (default value), the former object positioning algorithm (known from OpenOffice.org 1.1) is applied.</p> + @since OOo 2.0.0 */ [optional, property] boolean ConsiderTextWrapOnObjPos; diff --git a/offapi/com/sun/star/text/InContentMetadata.idl b/offapi/com/sun/star/text/InContentMetadata.idl new file mode 100644 index 000000000000..7a7a20adc877 --- /dev/null +++ b/offapi/com/sun/star/text/InContentMetadata.idl @@ -0,0 +1,81 @@ +/************************************************************************* + * + * 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: TextField.idl,v $ + * $Revision: 1.11 $ + * + * 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. + * + ************************************************************************/ + +#ifndef __com_sun_star_text_InContentMetadata_idl__ +#define __com_sun_star_text_InContentMetadata_idl__ + +#ifndef __com_sun_star_container_XEnumerationAccess_idl__ +#include <com/sun/star/container/XEnumerationAccess.idl> +#endif + +#ifndef __com_sun_star_text_TextContent_idl__ +#include <com/sun/star/text/TextContent.idl> +#endif + +#ifndef __com_sun_star_rdf_XMetadatable_idl__ +#include <com/sun/star/rdf/XMetadatable.idl> +#endif + + +//============================================================================= + +module com { module sun { module star { module text { + +//============================================================================= + +/** is a <type>TextContent</type> that can be used to attach RDF metadata + to a range of text. + + @since OOo 3.2 + */ +service InContentMetadata +{ + //------------------------------------------------------------------------- + /** None of the properties of <type>TextContent</type> are + supported. */ + service com::sun::star::text::TextContent; + + //------------------------------------------------------------------------- + /** The <type>InContentMetadata</type> can have RDF metadata attached. */ + interface com::sun::star::rdf::XMetadatable; + + //------------------------------------------------------------------------- + /** The <type>TextContent</type>s that are contained in the + annotated range of text can be enumerated. */ + interface com::sun::star::container::XEnumerationAccess; + +}; + + +//============================================================================= + +}; }; }; }; + +#endif diff --git a/offapi/com/sun/star/text/NumberingLevel.idl b/offapi/com/sun/star/text/NumberingLevel.idl index 987dfa53f565..46b014d9cd71 100644 --- a/offapi/com/sun/star/text/NumberingLevel.idl +++ b/offapi/com/sun/star/text/NumberingLevel.idl @@ -201,8 +201,6 @@ published service NumberingLevel /** position and space mode - @since OOo 3.0 - <p> Specifies the position and space mode of the numbering level. For valid values see com::sun::star::text::PositionAndSpaceMode. @@ -211,53 +209,55 @@ published service NumberingLevel If it equals LABEL_ALIGNMENT, properties Adjust, LabelFollowedBy, ListtabStopPosition, FirstLineIndent, IndentAt are used. </p> + + @since OOo 3.0 */ [optional, property] short PositionAndSpaceMode; /** character following the list label - @since OOo 3.0 - <p> Specifies the character following the list label. For valid values see com::sun::star::text::LabelFollow. Only of relevance, if PositionAndSpaceMode equals LABEL_ALIGNMENT. </p> + + @since OOo 3.0 */ [optional, property] short LabelFollowedBy; /** list tab position - @since OOo 3.0 - <p> Specifies the position of the list tab stop - only non-negative values are allowed. Only of relevance, if PositionAndSpaceMode equals LABEL_ALIGNMENT and LabelFollowedBy equal LABELFOLLOW_LISTTAB </p> + + @since OOo 3.0 */ [optional, property] long ListtabStopPosition; /** additional line indent for the first text line - @since OOo 3.0 - <p> Specifies the first line indent. Only of relevance, if PositionAndSpaceMode equals LABEL_ALIGNMENT. </p> + + @since OOo 3.0 */ [optional, property] long FirstLineIndent; /** indentation of the text lines - @since OOo 3.0 - <p> Specifies the indent of the text lines Only of relevance, if PositionAndSpaceMode equals LABEL_ALIGNMENT. </p> + + @since OOo 3.0 */ [optional, property] long IndentAt; }; diff --git a/offapi/com/sun/star/text/ReferenceFieldPart.idl b/offapi/com/sun/star/text/ReferenceFieldPart.idl index c58679fada90..2ac96da25ee2 100644 --- a/offapi/com/sun/star/text/ReferenceFieldPart.idl +++ b/offapi/com/sun/star/text/ReferenceFieldPart.idl @@ -88,8 +88,6 @@ published constants ReferenceFieldPart /** The numbering label and depending of the reference field context numbering lables of superior list levels of the reference are displayed. - @since OOo 3.0 - <p>This option is only valid, if the source of the reference is a bookmark or a set reference.</p> <p>The contents of the list label of the paragraph, at which the bookmark respectively the set reference starts - named "referenced item" in the following - is displayed. To unambiguous @@ -102,23 +100,23 @@ published constants ReferenceFieldPart be the level of the most superior level, then no list label content of superior levels greater or equal than X are added. If the referenced item isn't numbered, nothing is displayed.</p> + + @since OOo 3.0 */ const short NUMBER = 8; //------------------------------------------------------------------------- /** The numbering label of the reference is displayed. - @since OOo 3.0 - <p>This option is only valid, if the source of the reference is a bookmark or a set reference.</p> <p>The contents of the list label of the paragraph, at which the bookmark respectively the set reference starts, is displayed. If this paragraph isn't numbered, nothing is displayed.</p> + + @since OOo 3.0 */ const short NUMBER_NO_CONTEXT = 9; //------------------------------------------------------------------------- /** The numbering label and numbering lables of superior list levels of the reference are displayed. - @since OOo 3.0 - <p>This option is only valid, if the source of the reference is a bookmark or a set reference.</p> <p>The contents of the list label of the paragraph, at which the bookmark respectively the set reference starts - named "referenced item" in the following - is displayed and the contents @@ -128,6 +126,8 @@ published constants ReferenceFieldPart be the level of the most superior level, then no list label content of superior levels greater or equal than X are added. If the referenced item is numbered nothing is displayed.</p> + + @since OOo 3.0 */ const short NUMBER_FULL_CONTEXT = 10; }; diff --git a/offapi/com/sun/star/text/TextPortion.idl b/offapi/com/sun/star/text/TextPortion.idl index 10b1cc05175d..d4ab79f88323 100644 --- a/offapi/com/sun/star/text/TextPortion.idl +++ b/offapi/com/sun/star/text/TextPortion.idl @@ -31,18 +31,10 @@ #define __com_sun_star_text_TextPortion_idl__ -#ifndef __com_sun_star_style_ParagraphProperties_idl__ -#include <com/sun/star/style/ParagraphProperties.idl> -#endif - #ifndef __com_sun_star_beans_XTolerantMultiPropertySet_idl__ #include <com/sun/star/beans/XTolerantMultiPropertySet.idl> #endif -#ifndef __com_sun_star_style_CharacterProperties_idl__ -#include <com/sun/star/style/CharacterProperties.idl> -#endif - #ifndef __com_sun_star_container_XContentEnumerationAccess_idl__ #include <com/sun/star/container/XContentEnumerationAccess.idl> #endif @@ -50,10 +42,20 @@ #ifndef __com_sun_star_text_TextRange_idl__ #include <com/sun/star/text/TextRange.idl> #endif + #ifndef __com_sun_star_text_XTextContent_idl__ #include <com/sun/star/text/XTextContent.idl> #endif +#ifndef __com_sun_star_text_XTextField_idl__ +#include <com/sun/star/text/XTextField.idl> +#endif + +#ifndef __com_sun_star_text_XFootnote_idl__ +#include <com/sun/star/text/XFootnote.idl> +#endif + + //============================================================================= module com { module sun { module star { module text { @@ -61,65 +63,116 @@ module com { module sun { module star { module text { //============================================================================= /** A TextPortion is a piece of text within a paragraph that does not contain changes of its attributes inside. - <p>It is created by an enumaration implemented in a paragraph service. - It is used to export the content of the paragraph to an external document format.</p> + <p> + It is created by an enumeration implemented in a paragraph service. + It may be used to export the content of the paragraph to an external + document format. + </p> + + @see com::sun::star::text::TextPortionEnumeration + @see com::sun::star::text::XTextPortionEnumeration */ published service TextPortion { - service com::sun::star::text::TextRange; + service ::com::sun::star::text::TextRange; //------------------------------------------------------------------------- /** contains text frames, graphic objects, embedded objects or - shapes that are anchored at or as character. + shapes that are anchored at or as character. @see com.sun.star.text.TextFrame @see com.sun.star.text.TextGraphicObject */ - [optional] interface ::com::sun::star::container::XContentEnumerationAccess; + [optional] + interface ::com::sun::star::container::XContentEnumerationAccess; //------------------------------------------------------------------------- /** gives access to a sequence of properties. @since OOo 2.0.0 */ - [optional] interface ::com::sun::star::beans::XTolerantMultiPropertySet; + [optional] + interface ::com::sun::star::beans::XTolerantMultiPropertySet; //------------------------------------------------------------------------- /** contains the type of the text portion. + <p> Valid content type names are:</p> - <UL> - <LI><P>Text - string content</P> - <LI><P>TextField - TextField content</P> - <LI><P>TextContent - text content - supplied via the interface XContentEnumerationAccess</P> - <LI><P>Footnote - a footnote or an endnote</P> - <LI><P>ControlCharacter - a control character</P> - <LI><P>ReferenceMark - a reference mark </P> - <LI><P>DocumentIndexMark - a document index mark</P> - <LI><P>Bookmark - a bookmark</P> - <LI><P>Redline - a redline portion which is a result of the change tracking feature.</P> - <LI><P>Ruby - a ruby attribute which is used in Asian text</P> - <LI><P>Frame - a frame.</P> - </UL> - <p>The text portions for reference marks and document index marks are generated twice for - each mark since they may include string content.</p> + <dl> + <dt>Text</dt><dd>string content</dd> + <dt>TextField</dt><dd>a text field</dd> + <dt>TextContent</dt><dd>text content - supplied via the + interface <type scope="com::sun::star::container"> + XContentEnumerationAccess</type></dd> + <dt>ControlCharacter</dt><dd>a control character</dd> + <dt>Footnote</dt><dd>a footnote or an endnote</dd> + <dt>ReferenceMark</dt><dd>a reference mark</dd> + <dt>DocumentIndexMark</dt><dd>a document index mark</dd> + <dt>Bookmark</dt><dd>a bookmark</dd> + <dt>Redline</dt><dd>a redline portion which is a result + of the change tracking feature</dd> + <dt>Ruby</dt><dd>a ruby attribute which is used in Asian text</dd> + <dt>Frame</dt><dd>a frame</dd> + <dt>SoftPageBreak</dt><dd>a soft page break</dd> + <dt>InContentMetadata</dt><dd>a text range with attached metadata</dd> + </dl> + <p>For Reference marks, document index marks, etc., 2 text portions + will be generated, one for the start position and one for the + end position.</p> */ [readonly, property] string TextPortionType; //------------------------------------------------------------------------- - /** returns the control character if the text portion contains a ControlCharacter*/ + /** contains the control character of a text portion of type + ControlCharacter. + @deprecated type ControlCharacter no longer implemented + */ [readonly, property] short ControlCharacter; //------------------------------------------------------------------------- - /** contains the bookmark if the portion is of the type */ - [optional, property] com::sun::star::text::XTextContent Bookmark; + /** contains the bookmark of a text portion of type Bookmark. */ + [optional, readonly, property] + ::com::sun::star::text::XTextContent Bookmark; //------------------------------------------------------------------------- - /** determines whether the portion is a point only.*/ - [optional, property] boolean IsCollapsed; + /** contains the document index mark of a text portion of type + DocumentIndexMark. */ + [optional, readonly, property] + ::com::sun::star::text::XTextContent DocumentIndexMark; //------------------------------------------------------------------------- - /** determines whether the portion is a start portion if two portions are needed to include an - object (i.e. DocmentIndexMark)*/ - [optional, property] boolean IsStart; + /** contains the bookmark of a text portion of type ReferenceMark. */ + [optional, readonly, property] + ::com::sun::star::text::XTextContent ReferenceMark; + + //------------------------------------------------------------------------- + /** contains the footnote of a text portion of type Footnote. */ + [optional, readonly, property] + ::com::sun::star::text::XFootnote Footnote; + + //------------------------------------------------------------------------- + /** contains the text field of a text portion of type TextField. */ + [optional, readonly, property] + ::com::sun::star::text::XTextField TextField; + + //------------------------------------------------------------------------- + /** contains the text range of a text portion of type InContentMetadata. + @since OOo 3.2 + */ + [optional, readonly, property] + ::com::sun::star::text::XTextContent InContentMetadata; + + //------------------------------------------------------------------------- + /** contains whether the portion is a point only. */ + [optional, readonly, property] boolean IsCollapsed; + + //------------------------------------------------------------------------- + /** contains whether the portion is the start of the portion. + + <p>This is used for portions which are represented by + 2 TextPortion objects (e.g., DocmentIndexMark).</p> + */ + [optional, readonly, property] boolean IsStart; + }; //============================================================================= diff --git a/offapi/com/sun/star/text/ViewSettings.idl b/offapi/com/sun/star/text/ViewSettings.idl index f9e356f64732..88d87ccb4798 100644 --- a/offapi/com/sun/star/text/ViewSettings.idl +++ b/offapi/com/sun/star/text/ViewSettings.idl @@ -342,14 +342,18 @@ published service ViewSettings [optional, property] boolean ShowNonprintingCharacters; //------------------------------------------------------------------------- /** metric unit of the horizontal ruler + + <p>Uses values <type scope="com::sun::star::awt">FieldUnit</type></p> + @since OOo 3.1.0 - <p>Uses values from com::sun::star::awt::FieldUnit</p> */ [optional, property] long HorizontalRulerMetric; //------------------------------------------------------------------------- /** metric unit of the vertical ruler + + <p>Uses values from <type scope="com::sun::star::awt">FieldUnit</type></p> + @since OOo 3.1.0 - <p>Uses values from com::sun::star::awt::FieldUnit</p> */ [optional, property] long VerticalRulerMetric; }; diff --git a/offapi/com/sun/star/text/XMultiTextMarkup.idl b/offapi/com/sun/star/text/XMultiTextMarkup.idl index 661038152bb4..f380797d0eb8 100644 --- a/offapi/com/sun/star/text/XMultiTextMarkup.idl +++ b/offapi/com/sun/star/text/XMultiTextMarkup.idl @@ -68,8 +68,8 @@ interface XMultiTextMarkup @param aMarkups a sequence of single text markups. - @see som::sun::star:text::XTextMarkup - @see som::sun::star:text::TextMarkupType + @see com::sun::star::text::XTextMarkup + @see com::sun::star::text::TextMarkupType */ void commitMultiTextMarkup( diff --git a/offapi/com/sun/star/text/XTextTable.idl b/offapi/com/sun/star/text/XTextTable.idl index 88cffcaa60f7..a2161a2a0cbc 100644 --- a/offapi/com/sun/star/text/XTextTable.idl +++ b/offapi/com/sun/star/text/XTextTable.idl @@ -59,7 +59,7 @@ /** manages a text table. - @see som::sun::star:text::TextTable + @see com::sun::star::text::TextTable @see com::sun::star::text::Cell */ published interface XTextTable: com::sun::star::text::XTextContent diff --git a/offapi/com/sun/star/text/fieldmaster/Bibliography.idl b/offapi/com/sun/star/text/fieldmaster/Bibliography.idl index a43e9e16e7c6..9fc3dbdf0e43 100644 --- a/offapi/com/sun/star/text/fieldmaster/Bibliography.idl +++ b/offapi/com/sun/star/text/fieldmaster/Bibliography.idl @@ -37,7 +37,7 @@ //============================================================================= -module com { module sun { module star { module text { module FieldMaster { +module com { module sun { module star { module text { module fieldmaster { //============================================================================= /** specifies service of a Bibliography field master. diff --git a/offapi/com/sun/star/text/fieldmaster/DDE.idl b/offapi/com/sun/star/text/fieldmaster/DDE.idl index 82049858eea7..1f1da82de47a 100644 --- a/offapi/com/sun/star/text/fieldmaster/DDE.idl +++ b/offapi/com/sun/star/text/fieldmaster/DDE.idl @@ -36,7 +36,7 @@ //============================================================================= -module com { module sun { module star { module text { module FieldMaster { +module com { module sun { module star { module text { module fieldmaster { //============================================================================= /** specifies service of a DDE field master. diff --git a/offapi/com/sun/star/text/fieldmaster/Database.idl b/offapi/com/sun/star/text/fieldmaster/Database.idl index 95ce53e6fe42..d8554d7b4d69 100644 --- a/offapi/com/sun/star/text/fieldmaster/Database.idl +++ b/offapi/com/sun/star/text/fieldmaster/Database.idl @@ -36,7 +36,7 @@ //============================================================================= -module com { module sun { module star { module text { module FieldMaster { +module com { module sun { module star { module text { module fieldmaster { //============================================================================= /** specifies service of a Database field master. @@ -85,7 +85,7 @@ published service Database //------------------------------------------------------------------------ /** contains the DataColumnName but it enables the fieldmaster and its depending fields to work without setting DataSourceName, DataTableName and CommandType - @since OOo 2.x + @since OOo 2.3 */ [optional, property] string Name; diff --git a/offapi/com/sun/star/text/fieldmaster/SetExpression.idl b/offapi/com/sun/star/text/fieldmaster/SetExpression.idl index 1407f29906c4..1e5f1e783a6a 100644 --- a/offapi/com/sun/star/text/fieldmaster/SetExpression.idl +++ b/offapi/com/sun/star/text/fieldmaster/SetExpression.idl @@ -36,7 +36,7 @@ //============================================================================= -module com { module sun { module star { module text { module FieldMaster { +module com { module sun { module star { module text { module fieldmaster { //============================================================================= /** Specifies the service of a set expression field master. diff --git a/offapi/com/sun/star/text/fieldmaster/User.idl b/offapi/com/sun/star/text/fieldmaster/User.idl index 305682b75156..c973c8ba8ffa 100644 --- a/offapi/com/sun/star/text/fieldmaster/User.idl +++ b/offapi/com/sun/star/text/fieldmaster/User.idl @@ -36,7 +36,7 @@ //============================================================================= -module com { module sun { module star { module text { module FieldMaster { +module com { module sun { module star { module text { module fieldmaster { //============================================================================= /** Specifies the service of a user field master. diff --git a/offapi/com/sun/star/text/makefile.mk b/offapi/com/sun/star/text/makefile.mk index 18ad6abbe2a1..c018c9479049 100644 --- a/offapi/com/sun/star/text/makefile.mk +++ b/offapi/com/sun/star/text/makefile.mk @@ -107,6 +107,7 @@ IDLFILES=\ HorizontalAdjust.idl\ HypertextDocument.idl\ IllustrationsIndex.idl\ + InContentMetadata.idl\ InvalidTextContentException.idl\ LabelFollow.idl\ LineNumberingProperties.idl\ diff --git a/offapi/com/sun/star/text/textfield/MetadataField.idl b/offapi/com/sun/star/text/textfield/MetadataField.idl new file mode 100644 index 000000000000..f82276213527 --- /dev/null +++ b/offapi/com/sun/star/text/textfield/MetadataField.idl @@ -0,0 +1,102 @@ +/************************************************************************* + * + * 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: MetadataField.idl,v $ + * $Revision: 1.12 $ + * + * 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. + * + ************************************************************************/ + +#ifndef __com_sun_star_text_textfield_MetadataField_idl__ +#define __com_sun_star_text_textfield_MetadataField_idl__ + +#ifndef __com_sun_star_container_XEnumerationAccess_idl__ +#include <com/sun/star/container/XEnumerationAccess.idl> +#endif + +#ifndef __com_sun_star_text_TextField_idl__ +#include <com/sun/star/text/TextField.idl> +#endif + +#ifndef __com_sun_star_text_XText_idl__ +#include <com/sun/star/text/XText.idl> +#endif + +#ifndef __com_sun_star_rdf_XMetadatable_idl__ +#include <com/sun/star/rdf/XMetadatable.idl> +#endif + + +//============================================================================= + +module com { module sun { module star { module text { module textfield { + +//============================================================================= +/** is a <type>TextField</type> whose content is specified by RDF metadata. + + @since OOo 3.2 + + @see com::sun::star::rdf +*/ +service MetadataField +{ + //------------------------------------------------------------------------- + /** None of the properties of <type>TextContent</type> are + supported. */ + service com::sun::star::text::TextField; + + //------------------------------------------------------------------------- + /** The <type>MetadataField</type> can have RDF metadata attached. */ + interface com::sun::star::rdf::XMetadatable; + + //------------------------------------------------------------------------- + /** Allows for insertion of text content into, and creating cursors + that are bound within, the <type>MetadataField</type>. */ + interface com::sun::star::text::XText; + + //------------------------------------------------------------------------- + /** The <type>TextContent</type>s that are contained in the + <type>MetadataField</type> can be enumerated. */ + interface com::sun::star::container::XEnumerationAccess; + + //------------------------------------------------------------------------- + /** this is the number format for this field. + @see com::sun::star::util::NumberFormatter + */ + [optional, property] long NumberFormat; + + //------------------------------------------------------------------------- + /** determines whether changes in language attributes at the + position of the text field also change the number format + as appropriate for this language. + */ + [optional, property] boolean IsFixedLanguage; +}; + +//============================================================================= + +}; }; }; }; }; + +#endif + diff --git a/offapi/com/sun/star/text/textfield/makefile.mk b/offapi/com/sun/star/text/textfield/makefile.mk index 46506a4eff8c..0defebd69dfc 100644 --- a/offapi/com/sun/star/text/textfield/makefile.mk +++ b/offapi/com/sun/star/text/textfield/makefile.mk @@ -70,6 +70,7 @@ IDLFILES=\ InputUser.idl\ JumpEdit.idl\ Macro.idl\ + MetadataField.idl\ PageCount.idl\ PageNumber.idl\ ParagraphCount.idl\ diff --git a/offapi/com/sun/star/ucb/URLAuthenticationRequest.idl b/offapi/com/sun/star/ucb/URLAuthenticationRequest.idl new file mode 100644 index 000000000000..1b19830df81e --- /dev/null +++ b/offapi/com/sun/star/ucb/URLAuthenticationRequest.idl @@ -0,0 +1,58 @@ +/************************************************************************* + * + * 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: AuthenticationRequest.idl,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. + * + ************************************************************************/ +#ifndef __com_sun_star_ucb_URLAuthenticationRequest_idl__ +#define __com_sun_star_ucb_URLAuthenticationRequest_idl__ + +#ifndef __com_sun_star_ucb_AuthenticationRequest_idl__ +#include <com/sun/star/ucb/AuthenticationRequest.idl> +#endif + + +//============================================================================= + +module com { module sun { module star { module ucb { + +//============================================================================= +/** An error specifing lack of correct authentication data (e.g., to log into + an account). +*/ +/*published*/ exception URLAuthenticationRequest : AuthenticationRequest +{ + //------------------------------------------------------------------------- + /** The URL for which authentication is requested. + */ + string URL; +}; + +//============================================================================= + +}; }; }; }; + +#endif diff --git a/offapi/com/sun/star/ucb/XInteractionSupplyAuthentication2.idl b/offapi/com/sun/star/ucb/XInteractionSupplyAuthentication2.idl new file mode 100644 index 000000000000..a3c4bdb3d5f3 --- /dev/null +++ b/offapi/com/sun/star/ucb/XInteractionSupplyAuthentication2.idl @@ -0,0 +1,79 @@ +/************************************************************************* + * + * 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: XInteractionSupplyAuthentication.idl,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. + * + ************************************************************************/ +#ifndef __com_sun_star_ucb_XInteractionSupplyAuthentication2_idl__ +#define __com_sun_star_ucb_XInteractionSupplyAuthentication2_idl__ + +#ifndef __com_sun_star_ucb_XInteractionSupplyAuthentication_idl__ +#include <com/sun/star/ucb/XInteractionSupplyAuthentication.idl> +#endif + + + +//============================================================================= + +module com { module sun { module star { module ucb { + +//============================================================================= +/** An interaction continuation handing back some authentication data. + + <p> This continuation is typically used in conjunction with + <type>AuthenticationRequest</type>. </p> +*/ +/*published*/ interface XInteractionSupplyAuthentication2 : XInteractionSupplyAuthentication +{ + //------------------------------------------------------------------------- + /** Specifies if 'system credentials' can be obtained and used by the issuer + of the authentiction request. + + @param Default + Returns the default behavior for system credentials handling (to be + initially displayed to the user). + + @returns + <true/> if the issuer is able to obtain and use system credentials. + <false/> otherwise. + */ + boolean canUseSystemCredentials( [out] boolean Default ); + + //------------------------------------------------------------------------- + /** Set a new 'use system credentials' value to hand back. + + @param UseSystemCredentials + <true/> means the request issuer shall obtain and use system credentials. + */ + void setUseSystemCredentials( [in] boolean UseSystemCredentials ); + +}; + +//============================================================================= + +}; }; }; }; + +#endif diff --git a/offapi/com/sun/star/ucb/makefile.mk b/offapi/com/sun/star/ucb/makefile.mk index 2cf5394dcaf4..19320b716634 100644 --- a/offapi/com/sun/star/ucb/makefile.mk +++ b/offapi/com/sun/star/ucb/makefile.mk @@ -45,6 +45,7 @@ IDLFILES=\ AlreadyInitializedException.idl\ AnyCompareFactory.idl\ AuthenticationRequest.idl\ + URLAuthenticationRequest.idl\ CachedContentResultSet.idl\ CachedContentResultSetFactory.idl\ CachedContentResultSetStub.idl\ @@ -99,7 +100,7 @@ IDLFILES=\ FTPContent.idl\ FTPContentProvider.idl\ GlobalTransferCommandArgument.idl\ - GIOContentProvider.idl\ + GIOContentProvider.idl\ GnomeVFSContentProvider.idl\ GnomeVFSDocumentContent.idl\ GnomeVFSFolderContent.idl\ @@ -142,125 +143,126 @@ IDLFILES=\ LockType.idl\ MissingInputStreamException.idl\ MissingPropertiesException.idl\ - NameClash.idl\ - NameClashException.idl\ - NameClashResolveRequest.idl\ - NumberedSortingInfo.idl\ - ODMAContent.idl\ - ODMAContentProvider.idl\ - OpenCommandArgument.idl\ - OpenCommandArgument2.idl\ - OpenMode.idl\ - OutgoingMessageState.idl\ - PackageContentProvider.idl\ - PackageFolderContent.idl\ - PackageStreamContent.idl\ - PersistentPropertySet.idl\ - PostCommandArgument.idl\ - PostCommandArgument2.idl\ - Priority.idl\ - PropertiesManager.idl\ - PropertySetRegistry.idl\ - PropertyValueInfo.idl\ - PropertyValueState.idl\ - RecipientInfo.idl\ - RememberAuthentication.idl\ - RemoteAccessContentProvider.idl\ - RemoteContentProviderAcceptor.idl\ - RemoteContentProviderChangeAction.idl\ - RemoteContentProviderChangeEvent.idl\ - RemoteProxyContentProvider.idl\ - ResultSetException.idl\ + NameClash.idl\ + NameClashException.idl\ + NameClashResolveRequest.idl\ + NumberedSortingInfo.idl\ + ODMAContent.idl\ + ODMAContentProvider.idl\ + OpenCommandArgument.idl\ + OpenCommandArgument2.idl\ + OpenMode.idl\ + OutgoingMessageState.idl\ + PackageContentProvider.idl\ + PackageFolderContent.idl\ + PackageStreamContent.idl\ + PersistentPropertySet.idl\ + PostCommandArgument.idl\ + PostCommandArgument2.idl\ + Priority.idl\ + PropertiesManager.idl\ + PropertySetRegistry.idl\ + PropertyValueInfo.idl\ + PropertyValueState.idl\ + RecipientInfo.idl\ + RememberAuthentication.idl\ + RemoteAccessContentProvider.idl\ + RemoteContentProviderAcceptor.idl\ + RemoteContentProviderChangeAction.idl\ + RemoteContentProviderChangeEvent.idl\ + RemoteProxyContentProvider.idl\ + ResultSetException.idl\ Rule.idl\ - RuleAction.idl\ - RuleOperator.idl\ - RuleSet.idl\ - RuleTerm.idl\ - SearchCommandArgument.idl\ - SearchCriterium.idl\ - SearchInfo.idl\ - SearchRecursion.idl\ - SendInfo.idl\ - SendMediaTypes.idl\ - ServiceNotFoundException.idl\ - SimpleFileAccess.idl\ - SortedDynamicResultSetFactory.idl\ - SortingInfo.idl\ - Store.idl\ - SynchronizePolicy.idl\ - TransferCommandOperation.idl\ - TransferInfo.idl\ - TransferResult.idl\ + RuleAction.idl\ + RuleOperator.idl\ + RuleSet.idl\ + RuleTerm.idl\ + SearchCommandArgument.idl\ + SearchCriterium.idl\ + SearchInfo.idl\ + SearchRecursion.idl\ + SendInfo.idl\ + SendMediaTypes.idl\ + ServiceNotFoundException.idl\ + SimpleFileAccess.idl\ + SortedDynamicResultSetFactory.idl\ + SortingInfo.idl\ + Store.idl\ + SynchronizePolicy.idl\ + TransferCommandOperation.idl\ + TransferInfo.idl\ + TransferResult.idl\ TransientDocumentsContentProvider.idl\ TransientDocumentsRootContent.idl\ TransientDocumentsDocumentContent.idl\ TransientDocumentsFolderContent.idl\ TransientDocumentsStreamContent.idl\ - UniversalContentBroker.idl\ - UnsupportedCommandException.idl\ - UnsupportedDataSinkException.idl\ - UnsupportedNameClashException.idl\ - UnsupportedOpenModeException.idl\ - VerificationMode.idl\ - WebDAVContentProvider.idl\ - WebDAVDocumentContent.idl\ - WebDAVFolderContent.idl\ - WelcomeDynamicResultSetStruct.idl\ - XAnyCompare.idl\ - XAnyCompareFactory.idl\ - XCachedContentResultSetFactory.idl\ - XCachedContentResultSetStubFactory.idl\ - XCachedDynamicResultSetFactory.idl\ - XCachedDynamicResultSetStubFactory.idl\ - XCommandEnvironment.idl\ - XCommandInfo.idl\ - XCommandInfoChangeListener.idl\ - XCommandInfoChangeNotifier.idl\ - XCommandProcessor.idl\ - XCommandProcessor2.idl\ - XContent.idl\ - XContentAccess.idl\ - XContentCreator.idl\ - XContentEventListener.idl\ - XContentIdentifier.idl\ - XContentIdentifierFactory.idl\ - XContentIdentifierMapping.idl\ - XContentProvider.idl\ - XContentProviderFactory.idl\ - XContentProviderManager.idl\ - XContentProviderSupplier.idl\ - XContentTransmitter.idl\ - XDataContainer.idl\ - XDynamicResultSet.idl\ - XDynamicResultSetListener.idl\ - XFetchProvider.idl\ - XFetchProviderForContentAccess.idl\ - XFileIdentifierConverter.idl\ - XInteractionCookieHandling.idl\ - XInteractionHandlerSupplier.idl\ - XInteractionReplaceExistingData.idl\ - XInteractionSupplyAuthentication.idl\ - XInteractionSupplyName.idl\ - XParameterizedContentProvider.idl\ - XPersistentPropertySet.idl\ - XProgressHandler.idl\ - XPropertyMatcher.idl\ - XPropertyMatcherFactory.idl\ - XPropertySetRegistry.idl\ - XPropertySetRegistryFactory.idl\ - XRecycler.idl\ - XRemoteContentProviderAcceptor.idl\ - XRemoteContentProviderActivator.idl\ - XRemoteContentProviderChangeListener.idl\ - XRemoteContentProviderChangeNotifier.idl\ - XRemoteContentProviderConnectionControl.idl\ - XRemoteContentProviderDistributor.idl\ - XRemoteContentProviderDoneListener.idl\ - XRemoteContentProviderSupplier.idl\ - XSimpleFileAccess.idl\ - XSimpleFileAccess2.idl\ - XSimpleFileAccess3.idl\ - XSortedDynamicResultSetFactory.idl\ + UniversalContentBroker.idl\ + UnsupportedCommandException.idl\ + UnsupportedDataSinkException.idl\ + UnsupportedNameClashException.idl\ + UnsupportedOpenModeException.idl\ + VerificationMode.idl\ + WebDAVContentProvider.idl\ + WebDAVDocumentContent.idl\ + WebDAVFolderContent.idl\ + WelcomeDynamicResultSetStruct.idl\ + XAnyCompare.idl\ + XAnyCompareFactory.idl\ + XCachedContentResultSetFactory.idl\ + XCachedContentResultSetStubFactory.idl\ + XCachedDynamicResultSetFactory.idl\ + XCachedDynamicResultSetStubFactory.idl\ + XCommandEnvironment.idl\ + XCommandInfo.idl\ + XCommandInfoChangeListener.idl\ + XCommandInfoChangeNotifier.idl\ + XCommandProcessor.idl\ + XCommandProcessor2.idl\ + XContent.idl\ + XContentAccess.idl\ + XContentCreator.idl\ + XContentEventListener.idl\ + XContentIdentifier.idl\ + XContentIdentifierFactory.idl\ + XContentIdentifierMapping.idl\ + XContentProvider.idl\ + XContentProviderFactory.idl\ + XContentProviderManager.idl\ + XContentProviderSupplier.idl\ + XContentTransmitter.idl\ + XDataContainer.idl\ + XDynamicResultSet.idl\ + XDynamicResultSetListener.idl\ + XFetchProvider.idl\ + XFetchProviderForContentAccess.idl\ + XFileIdentifierConverter.idl\ + XInteractionCookieHandling.idl\ + XInteractionHandlerSupplier.idl\ + XInteractionReplaceExistingData.idl\ + XInteractionSupplyAuthentication.idl\ + XInteractionSupplyAuthentication2.idl\ + XInteractionSupplyName.idl\ + XParameterizedContentProvider.idl\ + XPersistentPropertySet.idl\ + XProgressHandler.idl\ + XPropertyMatcher.idl\ + XPropertyMatcherFactory.idl\ + XPropertySetRegistry.idl\ + XPropertySetRegistryFactory.idl\ + XRecycler.idl\ + XRemoteContentProviderAcceptor.idl\ + XRemoteContentProviderActivator.idl\ + XRemoteContentProviderChangeListener.idl\ + XRemoteContentProviderChangeNotifier.idl\ + XRemoteContentProviderConnectionControl.idl\ + XRemoteContentProviderDistributor.idl\ + XRemoteContentProviderDoneListener.idl\ + XRemoteContentProviderSupplier.idl\ + XSimpleFileAccess.idl\ + XSimpleFileAccess2.idl\ + XSimpleFileAccess3.idl\ + XSortedDynamicResultSetFactory.idl\ XSourceInitialization.idl\ XWebDAVCommandEnvironment.idl \ CertificateValidationRequest.idl diff --git a/offapi/com/sun/star/ui/dialogs/FilePicker.idl b/offapi/com/sun/star/ui/dialogs/FilePicker.idl index b2f4d8ed258c..c15ab0287631 100644 --- a/offapi/com/sun/star/ui/dialogs/FilePicker.idl +++ b/offapi/com/sun/star/ui/dialogs/FilePicker.idl @@ -60,6 +60,11 @@ module com { module sun { module star { module ui { module dialogs { //============================================================================= /** A FilePicker. + It is <strong>NOT</strong> recommended to cache a reference to a file + picker instance. Due to restrictions by the underlying system there can + be specific limitations possible. To overcome these problems it' + s recommended to create a new instance on demand. + @see XFilePicker */ diff --git a/offapi/com/sun/star/util/Duration.idl b/offapi/com/sun/star/util/Duration.idl new file mode 100644 index 000000000000..39f3ca8114ce --- /dev/null +++ b/offapi/com/sun/star/util/Duration.idl @@ -0,0 +1,104 @@ +/************************************************************************* + * + * 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: DateTime.idl,v $ + * $Revision: 1.7 $ + * + * 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. + * + ************************************************************************/ + +#ifndef __com_sun_star_util_Duration_idl__ +#define __com_sun_star_util_Duration_idl__ + + +//======================================================================== + +module com { module sun { module star { module util { + +//======================================================================== + +/** represents a duration. + + <p> + A duration is the difference of 2 <type>DateTime</type>s. + </p> + + <p> + Note that there are no constraints on the ranges of the members, + except that every member must be non-negative: + for example, a Duration of 400 Days is valid. + </p> + + @since OOo 3.3 + */ +struct Duration +{ + //-------------------------------------------------------------------- + /** explicit sign bit. + */ + boolean Negative; + + //-------------------------------------------------------------------- + /** contains the years. + */ + unsigned short Years; + + //-------------------------------------------------------------------- + /** contains the months. + */ + unsigned short Months; + + //-------------------------------------------------------------------- + /** contains the days. + */ + unsigned short Days; + + //-------------------------------------------------------------------- + /** contains the hours. + */ + unsigned short Hours; + + //-------------------------------------------------------------------- + /** contains the minutes. + */ + unsigned short Minutes; + + //-------------------------------------------------------------------- + /** contains the seconds. + */ + unsigned short Seconds; + + //-------------------------------------------------------------------- + /** contains the hundredth seconds. + */ + unsigned short HundredthSeconds; + +}; + +//======================================================================== + +}; }; }; }; + +#endif + diff --git a/offapi/com/sun/star/util/makefile.mk b/offapi/com/sun/star/util/makefile.mk index 44fbdf9065b2..e5f9aab136c3 100644 --- a/offapi/com/sun/star/util/makefile.mk +++ b/offapi/com/sun/star/util/makefile.mk @@ -53,6 +53,7 @@ IDLFILES=\ DateTime.idl\ DateTimeRange.idl\ DiskFullException.idl\ + Duration.idl\ ElementChange.idl \ Endianness.idl \ FileIOException.idl\ diff --git a/offapi/com/sun/star/xml/crypto/XSecurityEnvironment.idl b/offapi/com/sun/star/xml/crypto/XSecurityEnvironment.idl index 6fc5e45430f2..1d1d32bf17a8 100644 --- a/offapi/com/sun/star/xml/crypto/XSecurityEnvironment.idl +++ b/offapi/com/sun/star/xml/crypto/XSecurityEnvironment.idl @@ -78,14 +78,26 @@ interface XSecurityEnvironment : com::sun::star::uno::XInterface com::sun::star::security::XCertificate createCertificateFromAscii( [in] string asciiCertificate ) raises( com::sun::star::uno::SecurityException ) ; /** - * Verify a certificate. - * - * The method provides a way to verify a certificate. - * - * The validation status will returned as a bit-wise long, please refer to - * CertificateValidity definition. + Verify a certificate. + + The method provides a way to verify a certificate. + @param xEECertificate + The certificate which is to be validated. + + @param intermediateCertificates + Additional certificates which can be used by the method in constructing + the certificate chain. The root certificate may also be contained. However, + the implementation must check if the root certificate is indeed trusted by + the user. + All entries of the sequence must be non-null references. + + @return + The validation status will returned as a bit-wise long, please refer to + CertificateValidity definition. */ - long verifyCertificate( [in] com::sun::star::security::XCertificate xCertificate ) raises( com::sun::star::uno::SecurityException ) ; + long verifyCertificate( [in] com::sun::star::security::XCertificate xEECertificate, + [in] sequence< com::sun::star::security::XCertificate > intermediateCertificates) + raises( com::sun::star::uno::SecurityException ) ; /** * Get a certificate characters. diff --git a/offapi/com/sun/star/xml/sax/XFastSAXSerializable.idl b/offapi/com/sun/star/xml/sax/XFastSAXSerializable.idl new file mode 100644 index 000000000000..de5f8df99397 --- /dev/null +++ b/offapi/com/sun/star/xml/sax/XFastSAXSerializable.idl @@ -0,0 +1,102 @@ +/************************************************************************* + * + * 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: XSAXSerializable.idl,v $ + * $Revision: 1.3 $ + * + * 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. + * + ************************************************************************/ + +#ifndef __com_sun_star_xml_sax_XFastSAXSerializable_idl__ +#define __com_sun_star_xml_sax_XFastSAXSerializable_idl__ + +#ifndef __com_sun_star_xml_sax_XFastDocumentHandler_idl__ +#include <com/sun/star/xml/sax/XFastDocumentHandler.idl> +#endif + +#ifndef __com_sun_star_xml_sax_XFastTokenHandler_idl__ +#include <com/sun/star/xml/sax/XFastTokenHandler.idl> +#endif + +#ifndef __com_sun_star_beans_StringPair_idl__ +#include <com/sun/star/beans/StringPair.idl> +#endif + +#ifndef __com_sun_star_beans_Pair_idl__ +#include <com/sun/star/beans/Pair.idl> +#endif + +module com { module sun { module star { module xml { module sax { + +//============================================================================= +/** serializes a DOM tree by generating FastSAX events. + + <p> + </p> + + @since OOo 3.1 + +*/ +interface XFastSAXSerializable +{ + + //------------------------------------------------------------------------- + /** serializes an object (e.g. a DOM tree) that represents an XML document + by generating fast SAX events. + + @param handler + the SAX event handler that should receive the generated events + @param tokenHandler + the fast SAX token handler that is used to translate names + @param namespaces + a list of namespace declarations that will be added to the root + element node of the XML document + <p> + This is necessary mostly because the DOM implementation does + not permit attaching namespaces declarations directly to nodes, + which may lead to duplicate namespace declarations on export, + and thus larger documents. + Note that the first part of each tuple is the prefix, + e.g. "office", and the second is the numeric namespace identifier. + </p> + @param registerNamespaces + a list of namespace url / namespace token pairs. you need + to register all namespace in order to have them recognized + during export. Namespace tokens must be greater than + FastToken::NAMESPACE. + </p> + + @throws com::sun::star::xml::sax::SAXException + if serializing the XML document fails + */ + void fastSerialize([in] sax::XFastDocumentHandler handler, + [in] sax::XFastTokenHandler tokenHandler, + [in] sequence< beans::StringPair > namespaces, + [in] sequence< beans::Pair<string, long> > registerNamespaces) + raises( com::sun::star::xml::sax::SAXException ); +}; + +}; }; }; }; }; + +#endif diff --git a/offapi/com/sun/star/xml/sax/XFastShapeContextHandler.idl b/offapi/com/sun/star/xml/sax/XFastShapeContextHandler.idl index 3def460ed435..c125e55ddd2e 100644 --- a/offapi/com/sun/star/xml/sax/XFastShapeContextHandler.idl +++ b/offapi/com/sun/star/xml/sax/XFastShapeContextHandler.idl @@ -32,7 +32,7 @@ #include <com/sun/star/xml/sax/XFastContextHandler.idl> #include <com/sun/star/drawing/XShape.idl> -#include <com/sun/star/drawing/XShapes.idl> +#include <com/sun/star/drawing/XDrawPage.idl> #include <com/sun/star/frame/XModel.idl> #include <com/sun/star/io/XInputStream.idl> @@ -50,7 +50,7 @@ module com { module sun { module star { module xml { module sax { interface XFastShapeContextHandler: com::sun::star::xml::sax::XFastContextHandler { [attribute, readonly] com::sun::star::drawing::XShape Shape; - [attribute] com::sun::star::drawing::XShapes Shapes; + [attribute] com::sun::star::drawing::XDrawPage DrawPage; [attribute] com::sun::star::frame::XModel Model; [attribute] com::sun::star::io::XInputStream InputStream; [attribute] string RelationFragmentPath; diff --git a/offapi/com/sun/star/xml/sax/makefile.mk b/offapi/com/sun/star/xml/sax/makefile.mk index 2fe672ffb219..87319dca8a9a 100644 --- a/offapi/com/sun/star/xml/sax/makefile.mk +++ b/offapi/com/sun/star/xml/sax/makefile.mk @@ -58,6 +58,7 @@ IDLFILES=\ XFastParser.idl\ XFastDocumentHandler.idl\ XFastContextHandler.idl\ + XFastSAXSerializable.idl\ XFastSerializer.idl\ XFastShapeContextHandler.idl\ XFastTokenHandler.idl\ diff --git a/offapi/prj/build.lst b/offapi/prj/build.lst index 094ca718a124..6ddea0190596 100644 --- a/offapi/prj/build.lst +++ b/offapi/prj/build.lst @@ -1,4 +1,4 @@ -oa offapi : udkapi solenv NULL +oa offapi : udkapi idlc solenv NULL oa offapi usr1 - all oa_mkout NULL oa offapi\com\sun\star\script nmake - all oa_script oa_embed NULL oa offapi\com\sun\star\script\browse nmake - all oa_sfbrowse NULL @@ -7,6 +7,7 @@ oa offapi\com\sun\star\auth nmake - all oa_auth NULL oa offapi\com\sun\star\accessibility nmake - all oa_accessibility oa_awt NULL oa offapi\com\sun\star\awt nmake - all oa_awt NULL oa offapi\com\sun\star\awt\tree nmake - all oa_awttree NULL +oa offapi\com\sun\star\awt\grid nmake - all oa_awtgrid NULL oa offapi\com\sun\star\chart nmake - all oa_chart NULL oa offapi\com\sun\star\chart2 nmake - all oa_chart2 NULL oa offapi\com\sun\star\chart2\data nmake - all oa_chart2_data NULL @@ -102,5 +103,6 @@ oa offapi\com\sun\star\xml\wrapper nmake - all oa_wrapper oa_sax NULL oa offapi\com\sun\star\geometry nmake - all oa_geometry NULL oa offapi\com\sun\star\rendering nmake - all oa_rendering oa_geometry NULL oa offapi\com\sun\star\rdf nmake - all oa_rdf oa_datatransfer oa_text NULL +oa offapi\com\sun\star\office nmake - all oa_office oa_text NULL
oa offapi\drafts\com\sun\star\form nmake - all oa_drafts_form NULL -oa offapi\util nmake - all oa_util oa_auth oa_awt oa_awttree oa_chart oa_chart2 oa_chart2_data oa_config oa_configbootstrap oa_configbackend oa_configbackend_xml oa_datatrans_clip oa_datatrans_dnd oa_datatransfer oa_docu oa_draw oa_draw_framework oa_embed oa_fcomp oa_finsp oa_fcontr oa_fieldmaster oa_form oa_xforms oa_formula oa_frame oa_i18n oa_inst oa_ldap oa_ling2 oa_logging oa_mail oa_media oa_mozilla oa_packages oa_manifest oa_zippackage oa_plug oa_pres oa_animations oa_putil oa_resrc oa_sax oa_xml_input oa_scan oa_sdb oa_sdbtools oa_sdbapp oa_sdbc oa_sdbcx oa_setup oa_sheet oa_style oa_svg oa_sync oa_sync2 oa_system oa_table oa_task oa_text oa_textfield oa_docinfo oa_ucb oa_view oa_xml oa_xml_dom oa_xml_xpath oa_xml_views oa_xml_events oa_image oa_xsd oa_inspection oa_ui oa_ui_dialogs oa_accessibility oa_form_binding oa_form_validation oa_form_submission oa_fruntime oa_geometry oa_rendering oa_sfprovider oa_sfbrowse oa_drafts_form oa_deployment oa_deploymenttest oa_deployment_ui oa_frame_status oa_gallery oa_graphic oa_security oa_crypto_sax oa_crypto oa_csax oa_wrapper oa_script oa_smarttags oa_report oa_reportins oa_reportmeta oa_rdf oa_oooimprovement NULL +oa offapi\util nmake - all oa_util oa_auth oa_awt oa_awttree oa_awtgrid oa_chart oa_chart2 oa_chart2_data oa_config oa_configbootstrap oa_configbackend oa_configbackend_xml oa_datatrans_clip oa_datatrans_dnd oa_datatransfer oa_docu oa_draw oa_draw_framework oa_embed oa_fcomp oa_finsp oa_fcontr oa_fieldmaster oa_form oa_xforms oa_formula oa_frame oa_i18n oa_inst oa_ldap oa_ling2 oa_logging oa_mail oa_media oa_mozilla oa_packages oa_manifest oa_zippackage oa_plug oa_pres oa_animations oa_putil oa_resrc oa_sax oa_xml_input oa_scan oa_sdb oa_sdbtools oa_sdbapp oa_sdbc oa_sdbcx oa_setup oa_sheet oa_style oa_svg oa_sync oa_sync2 oa_system oa_table oa_task oa_text oa_textfield oa_docinfo oa_ucb oa_view oa_xml oa_xml_dom oa_xml_xpath oa_xml_views oa_xml_events oa_image oa_xsd oa_inspection oa_ui oa_ui_dialogs oa_accessibility oa_form_binding oa_form_validation oa_form_submission oa_fruntime oa_geometry oa_rendering oa_sfprovider oa_sfbrowse oa_drafts_form oa_deployment oa_deploymenttest oa_deployment_ui oa_frame_status oa_gallery oa_graphic oa_security oa_crypto_sax oa_crypto oa_csax oa_wrapper oa_script oa_smarttags oa_report oa_reportins oa_reportmeta oa_rdf oa_oooimprovement oa_office NULL diff --git a/offapi/prj/d.lst b/offapi/prj/d.lst index f0ec9d7549e7..9532cd773c6f 100644 --- a/offapi/prj/d.lst +++ b/offapi/prj/d.lst @@ -12,6 +12,7 @@ mkdir: %COMMON_DEST%\idl%_EXT%\com\sun\star\animations mkdir: %COMMON_DEST%\idl%_EXT%\com\sun\star\auth mkdir: %COMMON_DEST%\idl%_EXT%\com\sun\star\awt mkdir: %COMMON_DEST%\idl%_EXT%\com\sun\star\awt\tree +mkdir: %COMMON_DEST%\idl%_EXT%\com\sun\star\awt\grid mkdir: %COMMON_DEST%\idl%_EXT%\com\sun\star\chart mkdir: %COMMON_DEST%\idl%_EXT%\com\sun\star\chart2 mkdir: %COMMON_DEST%\idl%_EXT%\com\sun\star\chart2\data @@ -127,6 +128,7 @@ mkdir: %COMMON_DEST%\idl%_EXT%\drafts\com\sun\star\form ..\com\sun\star\auth\*.idl %COMMON_DEST%\idl%_EXT%\com\sun\star\auth ..\com\sun\star\awt\*.idl %COMMON_DEST%\idl%_EXT%\com\sun\star\awt ..\com\sun\star\awt\tree\*.idl %COMMON_DEST%\idl%_EXT%\com\sun\star\awt\tree +..\com\sun\star\awt\grid\*.idl %COMMON_DEST%\idl%_EXT%\com\sun\star\awt\grid ..\com\sun\star\chart\*.idl %COMMON_DEST%\idl%_EXT%\com\sun\star\chart ..\com\sun\star\chart2\*.idl %COMMON_DEST%\idl%_EXT%\com\sun\star\chart2 ..\com\sun\star\chart2\data\*.idl %COMMON_DEST%\idl%_EXT%\com\sun\star\chart2\data diff --git a/offapi/type_reference/typelibrary_history.txt b/offapi/type_reference/typelibrary_history.txt index e21ecd344ee4..70f0e1d0cb35 100644 --- a/offapi/type_reference/typelibrary_history.txt +++ b/offapi/type_reference/typelibrary_history.txt @@ -141,3 +141,10 @@ to maybevoid and deprecate. They should be removed in a future version. The implementation will never return them. +25/02/09 (MST, JSC): TaskID=i96209 + rename module css.text.FieldMaster to css.text.fieldmaster. + the implementation handles both variants. + +15/05/09 (MST, JSC): TaskID=i101965 + fix read-only status of properties of css.text.TextPortion + diff --git a/offapi/type_reference/types.rdb b/offapi/type_reference/types.rdb Binary files differindex 237e399cd6d3..f9a30cdbbd53 100644 --- a/offapi/type_reference/types.rdb +++ b/offapi/type_reference/types.rdb diff --git a/offapi/util/checknewapi.pl b/offapi/util/checknewapi.pl index 9c810d695461..e3141cda0737 100755 --- a/offapi/util/checknewapi.pl +++ b/offapi/util/checknewapi.pl @@ -6,23 +6,25 @@ # Copyright (c) 2005 Sun Microsystems, Inc. # -if($#ARGV != 2) +if($#ARGV != 3) { - die "usage: checknewapi <new_type_library> <reference_type_library> <buildinfodescr>\n"; + die "usage: checknewapi <new_type_library> <reference_type_library> <buildinfodescr> <fullpath_regview>\n"; } -e "$ARGV[0]" || die "ERROR: type library \"$ARGV[0]\" does not exist\n"; -e "$ARGV[1]" || die "ERROR: reference type library \"$ARGV[1]\" does not exist\n"; +-e "$ARGV[3]" || die "ERROR: invalid path to the regview tool \"$ARGV[3]\", please specify the full qualified path\n"; # debug flag $DEBUG = 0; $main::buildinfo = "$ARGV[2]"; +$main::regview = "$ARGV[3]"; %{$main::reftypes} = (); %{$main::currenttypes} = (); %{$main::removedtypes} = (); -open ( FILEIN, "regview \"$ARGV[0]\" |" ) || die "could not use content of current typelibrary \"$ARGV[0]\", regview doesn't work\n"; +open ( FILEIN, "$main::regview \"$ARGV[0]\" |" ) || die "could not use content of current typelibrary \"$ARGV[0]\", regview doesn't work\n"; if ($DEBUG == 1) { @@ -74,7 +76,7 @@ while (<FILEIN>) close( FILEIN ); close( CURRENT ); -open ( FILEIN, "regview \"$ARGV[1]\" |" ) || die "could not use content of reference type library \"$ARGV[1]\", regview doesn't work\n"; +open ( FILEIN, "$main::regview \"$ARGV[1]\" |" ) || die "could not use content of reference type library \"$ARGV[1]\", regview doesn't work\n"; if ($DEBUG == 1) { diff --git a/offapi/util/makefile.mk b/offapi/util/makefile.mk index 6e4a41503a56..d3157dac31df 100644 --- a/offapi/util/makefile.mk +++ b/offapi/util/makefile.mk @@ -45,6 +45,7 @@ UNOIDLDBFILES= \ $(UCR)$/cssauth.db \ $(UCR)$/cssawt.db \ $(UCR)$/cssawttree.db \ + $(UCR)$/cssawtgrid.db \ $(UCR)$/csschart.db \ $(UCR)$/csschart2.db \ $(UCR)$/csschart2data.db \ @@ -143,6 +144,7 @@ UNOIDLDBFILES= \ $(UCR)$/cssreport.db \ $(UCR)$/cssrptins.db \ $(UCR)$/cssrptmeta.db \ + $(UCR)$/cssoffice.db \ $(UCR)$/cssrdf.db @@ -152,6 +154,7 @@ REGISTRYCHECKFLAG=$(MISC)$/registrycheck.flag UNOTYPE_STATISTICS=$(MISC)$/unotype_statistics.txt +REGVIEWTOOL=$(SOLARBINDIR)$/regview$(EXECPOST) # --- Targets ------------------------------------------------------ @@ -161,14 +164,14 @@ ALLTAR : $(UCR)$/types.db \ $(UNOTYPE_STATISTICS) $(UCR)$/types.db : $(UCR)$/offapi.db $(SOLARBINDIR)$/udkapi.rdb - -$(RM) $(REGISTRYCHECKFLAG) - $(GNUCOPY) -f $(UCR)$/offapi.db $@ - $(REGMERGE) $@ / $(SOLARBINDIR)$/udkapi.rdb + @-$(RM) $(REGISTRYCHECKFLAG) + @$(GNUCOPY) -f $(UCR)$/offapi.db $@ + $(COMMAND_ECHO)$(REGMERGE) $@ / $(SOLARBINDIR)$/udkapi.rdb $(OUT)$/ucrdoc$/types_doc.db : $(OUT)$/ucrdoc$/offapi_doc.db $(SOLARBINDIR)$/udkapi_doc.rdb - -$(RM) $(REGISTRYCHECKFLAG) - $(GNUCOPY) -f $(OUT)$/ucrdoc$/offapi_doc.db $@ - $(REGMERGE) $@ / $(SOLARBINDIR)$/udkapi_doc.rdb + @-$(RM) $(REGISTRYCHECKFLAG) + @$(GNUCOPY) -f $(OUT)$/ucrdoc$/offapi_doc.db $@ + $(COMMAND_ECHO)$(REGMERGE) $@ / $(SOLARBINDIR)$/udkapi_doc.rdb #JSC: The type library has changed, all temporary not checked types are removed # and will be check from now on. @@ -183,6 +186,6 @@ $(REGISTRYCHECKFLAG) : $(UCR)$/types.db $(OUT)$/ucrdoc$/types_doc.db #JSC: new target to prepare some UNO type statistics, the ouput will be later used # for versioning of UNO cli type libraries $(UNOTYPE_STATISTICS) : $(REGISTRYCHECKFLAG) - $(AUGMENT_LIBRARY_PATH) $(PERL) checknewapi.pl $(UCR)$/types.db $(REFERENCE_RDB) "$(RSCREVISION)" > $@ + $(AUGMENT_LIBRARY_PATH) $(PERL) checknewapi.pl $(UCR)$/types.db $(REFERENCE_RDB) "$(RSCREVISION)" "$(REGVIEWTOOL)" > $@ .INCLUDE : target.mk diff --git a/offapi/util/target.pmk b/offapi/util/target.pmk index 08912b011857..63804f3e554a 100644 --- a/offapi/util/target.pmk +++ b/offapi/util/target.pmk @@ -30,8 +30,8 @@ #************************************************************************* $(OUT)$/misc$/$(TARGET).idls: makefile.mk - -$(RM) $@ - $(TYPE) $(mktmp $(foreach,i,$(IDLFILES) $(PACKAGE)$/$i)) >>$@ + $(COMMAND_ECHO)-$(RM) $@ + $(COMMAND_ECHO)$(TYPE) $(mktmp $(foreach,i,$(IDLFILES) $(PACKAGE)$/$i)) >>$@ ALLTAR: $(OUT)$/misc$/$(TARGET).idls diff --git a/offuh/prj/d.lst b/offuh/prj/d.lst index a18d037a4c2f..bedbc8d112d4 100644 --- a/offuh/prj/d.lst +++ b/offuh/prj/d.lst @@ -7,6 +7,7 @@ mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\auth mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\accessibility mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\awt mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\awt\tree +mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\awt\grid mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\beans mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\bridge mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\bridge\oleautomation @@ -50,6 +51,7 @@ mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\lang mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\linguistic2 mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\logging mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\oooimprovement +mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\office mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\mail mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\media mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\packages @@ -139,6 +141,8 @@ mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\rdf ..\%__SRC%\inc\offuh\com\sun\star\awt\*.hpp %_DEST%\inc%_EXT%\offuh\com\sun\star\awt\*.hpp ..\%__SRC%\inc\offuh\com\sun\star\awt\tree\*.hdl %_DEST%\inc%_EXT%\offuh\com\sun\star\awt\tree\*.hdl ..\%__SRC%\inc\offuh\com\sun\star\awt\tree\*.hpp %_DEST%\inc%_EXT%\offuh\com\sun\star\awt\tree\*.hpp +..\%__SRC%\inc\offuh\com\sun\star\awt\grid\*.hdl %_DEST%\inc%_EXT%\offuh\com\sun\star\awt\grid\*.hdl +..\%__SRC%\inc\offuh\com\sun\star\awt\grid\*.hpp %_DEST%\inc%_EXT%\offuh\com\sun\star\awt\grid\*.hpp ..\%__SRC%\inc\offuh\com\sun\star\beans\*.hdl %_DEST%\inc%_EXT%\offuh\com\sun\star\beans\*.hdl ..\%__SRC%\inc\offuh\com\sun\star\beans\*.hpp %_DEST%\inc%_EXT%\offuh\com\sun\star\beans\*.hpp ..\%__SRC%\inc\offuh\com\sun\star\bridge\*.hdl %_DEST%\inc%_EXT%\offuh\com\sun\star\bridge\*.hdl @@ -223,6 +227,8 @@ mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\rdf ..\%__SRC%\inc\offuh\com\sun\star\linguistic2\*.hpp %_DEST%\inc%_EXT%\offuh\com\sun\star\linguistic2\*.hpp ..\%__SRC%\inc\offuh\com\sun\star\logging\*.hdl %_DEST%\inc%_EXT%\offuh\com\sun\star\logging\*.hdl ..\%__SRC%\inc\offuh\com\sun\star\logging\*.hpp %_DEST%\inc%_EXT%\offuh\com\sun\star\logging\*.hpp +..\%__SRC%\inc\offuh\com\sun\star\office\*.hpp %_DEST%\inc%_EXT%\offuh\com\sun\star\office\*.hpp
+..\%__SRC%\inc\offuh\com\sun\star\office\*.hdl %_DEST%\inc%_EXT%\offuh\com\sun\star\office\*.hdl
..\%__SRC%\inc\offuh\com\sun\star\oooimprovement\*.hdl %_DEST%\inc%_EXT%\offuh\com\sun\star\oooimprovement\*.hdl ..\%__SRC%\inc\offuh\com\sun\star\oooimprovement\*.hpp %_DEST%\inc%_EXT%\offuh\com\sun\star\oooimprovement\*.hpp ..\%__SRC%\inc\offuh\com\sun\star\mail\*.hpp %_DEST%\inc%_EXT%\offuh\com\sun\star\mail\*.hpp @@ -368,4 +374,3 @@ mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\rdf ..\%__SRC%\inc\offuh\com\sun\star\rdf\*.hpp %_DEST%\inc%_EXT%\offuh\com\sun\star\rdf\*.hpp ..\%__SRC%\inc\offuh\com\sun\star\rdf\*.hdl %_DEST%\inc%_EXT%\offuh\com\sun\star\rdf\*.hdl - diff --git a/pyuno/prj/d.lst b/pyuno/prj/d.lst index 16631ada6fbd..5fe7400a8d58 100644 --- a/pyuno/prj/d.lst +++ b/pyuno/prj/d.lst @@ -16,6 +16,7 @@ mkdir: %_DEST%\lib%_EXT%\pyuno ..\%__SRC%\bin\uno.py %_DEST%\bin%_EXT%\pyuno\uno.py ..\%__SRC%\bin\pyuno_services.rdb %_DEST%\bin%_EXT%\pyuno_services.rdb ..\%__SRC%\bin\pyuno.pyd %_DEST%\bin%_EXT%\pyuno.pyd +..\%__SRC%\bin\pyuno.dll %_DEST%\bin%_EXT%\pyuno.dll ..\%__SRC%\bin\pythonl*.dll %_DEST%\bin%_EXT%\pythonl*.dll ..\%__SRC%\misc\pyunorc %_DEST%\lib%_EXT%\pyunorc diff --git a/pyuno/source/loader/makefile.mk b/pyuno/source/loader/makefile.mk index 67fbe81e482e..f9f00e4f13ae 100644 --- a/pyuno/source/loader/makefile.mk +++ b/pyuno/source/loader/makefile.mk @@ -37,12 +37,12 @@ ENABLE_EXCEPTIONS=TRUE # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk - +.IF "$(L10N_framework)"=="" DLLPRE = #------------------------------------------------------------------- -.IF "$(OS)$(CPU)$(COMEX)" == "SOLARISS4" +.IF "$(OS)$(COMEX)" == "SOLARIS4" # no -Bdirect for SunWS CC DIRECT = $(LINKFLAGSDEFS) .ENDIF @@ -101,18 +101,16 @@ COMPONENTS= \ ALL : ALLTAR \ $(DLLDEST)$/pythonloader.py \ $(DLLDEST)$/pyuno_services.rdb +.ENDIF # L10N_framework .INCLUDE : target.mk - +.IF "$(L10N_framework)"=="" $(DLLDEST)$/%.py: %.py cp $? $@ $(DLLDEST)$/pyuno_services.rdb : makefile.mk $(DLLDEST)$/$(DLLPRE)$(TARGET)$(DLLPOST) -rm -f $@ $(DLLDEST)$/pyuno_services.tmp $(DLLDEST)$/pyuno_services.rdb -.IF "$(GUI)$(COM)"=="WNTGCC" - cd $(DLLDEST) && sh -c "export PATH='$(PATH):$(OUT)$/bin'; regcomp -register -r pyuno_services.tmp -wop $(foreach,i,$(COMPONENTS) -c $(i))" -.ELSE cd $(DLLDEST) && $(REGCOMP) -register -r pyuno_services.tmp -wop $(foreach,i,$(COMPONENTS) -c $(i)) -.ENDIF # "$(GUI)$(COM)"=="WNTGCC" cd $(DLLDEST) && mv pyuno_services.tmp pyuno_services.rdb +.ENDIF # L10N_framework diff --git a/pyuno/source/loader/pyuno_loader.cxx b/pyuno/source/loader/pyuno_loader.cxx index a6ceb8c4e160..bed549bca19f 100644 --- a/pyuno/source/loader/pyuno_loader.cxx +++ b/pyuno/source/loader/pyuno_loader.cxx @@ -30,7 +30,6 @@ #include <pyuno/pyuno.hxx> -#include <osl/module.hxx> #include <osl/process.h> #include <osl/file.h> #include <osl/thread.h> @@ -116,27 +115,6 @@ Sequence< OUString > getSupportedServiceNames() return Sequence< OUString > ( &serviceName, 1 ); } -static OUString getLibDir() -{ - static OUString *pLibDir; - if( !pLibDir ) - { - osl::MutexGuard guard( osl::Mutex::getGlobalMutex() ); - if( ! pLibDir ) - { - static OUString libDir; - - if( osl::Module::getUrlFromAddress( - reinterpret_cast< oslGenericFunction >(getLibDir) , libDir ) ) - { - libDir = OUString( libDir.getStr(), libDir.lastIndexOf('/' ) ); - } - pLibDir = &libDir; - } - } - return *pLibDir; -} - static void setPythonHome ( const OUString & pythonHome ) { OUString systemPythonHome; @@ -190,16 +168,13 @@ Reference< XInterface > CreateInstance( const Reference< XComponentContext > & c { OUString pythonPath; OUString pythonHome; - OUString path = getLibDir(); - if( path.getLength() ) - { - path += OUString( RTL_CONSTASCII_USTRINGPARAM( "/" SAL_CONFIGFILE("pythonloader.uno" ))); - rtl::Bootstrap bootstrap(path); + OUString path( RTL_CONSTASCII_USTRINGPARAM( "$OOO_BASE_DIR/program/" SAL_CONFIGFILE("pythonloader.uno" ))); + rtl::Bootstrap::expandMacros(path); //TODO: detect failure + rtl::Bootstrap bootstrap(path); - // look for pythonhome - bootstrap.getFrom( OUString( RTL_CONSTASCII_USTRINGPARAM( "PYUNO_LOADER_PYTHONHOME") ), pythonHome ); - bootstrap.getFrom( OUString( RTL_CONSTASCII_USTRINGPARAM( "PYUNO_LOADER_PYTHONPATH" ) ) , pythonPath ); - } + // look for pythonhome + bootstrap.getFrom( OUString( RTL_CONSTASCII_USTRINGPARAM( "PYUNO_LOADER_PYTHONHOME") ), pythonHome ); + bootstrap.getFrom( OUString( RTL_CONSTASCII_USTRINGPARAM( "PYUNO_LOADER_PYTHONPATH" ) ) , pythonPath ); // pythonhome+pythonpath must be set before Py_Initialize(), otherwise there appear warning on the console // sadly, there is no api for setting the pythonpath, we have to use the environment variable diff --git a/pyuno/source/module/makefile.mk b/pyuno/source/module/makefile.mk index 94de195e750f..2928d29668aa 100644 --- a/pyuno/source/module/makefile.mk +++ b/pyuno/source/module/makefile.mk @@ -39,9 +39,10 @@ LINKFLAGSDEFS = # do not fail with missing symbols # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk +.IF "$(L10N_framework)"=="" #------------------------------------------------------------------- -.IF "$(OS)$(CPU)$(COMEX)" == "SOLARISS4" +.IF "$(OS)$(COMEX)" == "SOLARIS4" # no -Bdirect for SunWS CC DIRECT = $(LINKFLAGSDEFS) .ENDIF @@ -56,6 +57,9 @@ EXTRA_FRAMEWORK_FLAG=-framework Python # pyuno.so even on Mac OS X, because it is a python module PYUNO_MODULE=$(DLLDEST)$/pyuno.so PYUNORC=pyunorc +.ELIF "$(GUI)" == "OS2" +.INCLUDE : pyversion.mk +PYUNORC=pyuno.ini .ELSE .INCLUDE : pyversion.mk PYUNORC=pyuno.ini @@ -125,10 +129,11 @@ ALLTAR : \ $(DLLDEST)$/unohelper.py \ $(PYUNO_MODULE) \ $(MISC)$/$(PYUNORC) +.ENDIF .ENDIF .INCLUDE : target.mk - +.IF "$(L10N_framework)"=="" $(DLLDEST)$/%.py: %.py cp $? $@ @@ -160,4 +165,5 @@ $(MISC)$/$(PYUNORC) : pyuno $(MISC)$/pyuno.flt : pyuno.flt -rm -f $@ cat $? > $@ +.ENDIF # L10N_framework diff --git a/pyuno/source/module/pyuno_gc.cxx b/pyuno/source/module/pyuno_gc.cxx index 513c14a99378..1e0ca08ff954 100644 --- a/pyuno/source/module/pyuno_gc.cxx +++ b/pyuno/source/module/pyuno_gc.cxx @@ -43,6 +43,12 @@ public: }; StaticDestructorGuard guard; +static bool isAfterUnloadOrPy_Finalize() +{ + return g_destructorsOfStaticObjectsHaveBeenCalled || + !Py_IsInitialized(); +} + class GCThread : public ::osl::Thread { PyObject *mPyObject; @@ -64,7 +70,7 @@ GCThread::GCThread( PyInterpreterState *interpreter, PyObject * object ) : void GCThread::run() { // otherwise we crash here, when main has been left already - if( g_destructorsOfStaticObjectsHaveBeenCalled ) + if( isAfterUnloadOrPy_Finalize() ) return; try { @@ -100,7 +106,7 @@ void GCThread::onTerminated() void decreaseRefCount( PyInterpreterState *interpreter, PyObject *object ) { // otherwise we crash in the last after main ... - if( g_destructorsOfStaticObjectsHaveBeenCalled ) + if( isAfterUnloadOrPy_Finalize() ) return; // delegate to a new thread, because there does not seem diff --git a/pyuno/zipcore/makefile.mk b/pyuno/zipcore/makefile.mk index f46106dc8afe..a820c1a59f4f 100755 --- a/pyuno/zipcore/makefile.mk +++ b/pyuno/zipcore/makefile.mk @@ -36,7 +36,7 @@ TARGET=zipcore LIBTARGET=NO .INCLUDE : settings.mk - +.IF "$(L10N_framework)"=="" UWINAPILIB = .IF "$(SYSTEM_PYTHON)" == "YES" || "$(GUI)" == "OS2" @@ -74,6 +74,7 @@ APP1RPATH = BRAND OBJFILES = $(OBJ)$/python.obj .ENDIF + .INCLUDE: target.mk ALLTAR: \ @@ -129,3 +130,7 @@ $(DESTROOT)$/bin$/python$(EXECPOST) : $(SOLARBINDIR)$/python$(EXECPOST) .ENDIF .ENDIF +.ELSE +ivo: + $(ECHO) +.ENDIF # L10N_framework diff --git a/pyuno/zipcore/python.cxx b/pyuno/zipcore/python.cxx index 2e0e1ea0acb4..80765830d056 100644 --- a/pyuno/zipcore/python.cxx +++ b/pyuno/zipcore/python.cxx @@ -206,7 +206,7 @@ int wmain(int argc, wchar_t ** argv, wchar_t **) { MultiByteToWideChar(CP_ACP, 0, argv[i], -1, buff, nNeededWStrBuffSize); buff[nNeededWStrBuffSize] = 0; cp = encode(cp, buff); - delete buff; + delete [] buff; #else cp = encode(cp, argv[i]); #endif @@ -235,9 +235,9 @@ int wmain(int argc, wchar_t ** argv, wchar_t **) { exit(EXIT_FAILURE); } if (n != 0) { - delete orig; + delete [] orig; } - delete value; + delete [] value; n = GetEnvironmentVariableW(L"PYTHONPATH", NULL, 0); if (n == 0) { if (GetLastError() != ERROR_ENVVAR_NOT_FOUND) { @@ -276,9 +276,9 @@ int wmain(int argc, wchar_t ** argv, wchar_t **) { exit(EXIT_FAILURE); } if (n != 0) { - delete orig; + delete [] orig; } - delete value; + delete [] value; if (!SetEnvironmentVariableW(L"PYTHONHOME", pythonhome)) { exit(EXIT_FAILURE); } diff --git a/rdbmaker/inc/codemaker/dependency.hxx b/rdbmaker/inc/codemaker/dependency.hxx index c0fff9da7c7d..648564d8f50b 100644 --- a/rdbmaker/inc/codemaker/dependency.hxx +++ b/rdbmaker/inc/codemaker/dependency.hxx @@ -154,7 +154,6 @@ public: sal_Bool insert(const ::rtl::OString& type, const ::rtl::OString& depend, sal_uInt16); TypeUsingSet getDependencies(const ::rtl::OString& type); - sal_Bool lookupDependency(const ::rtl::OString& type, const ::rtl::OString& depend, sal_uInt16); sal_Bool hasDependencies(const ::rtl::OString& type); void setGenerated(const ::rtl::OString& type, sal_uInt16 genFlag=CODEGEN_DEFAULT); diff --git a/rdbmaker/inc/codemaker/global.hxx b/rdbmaker/inc/codemaker/global.hxx index df1f588f5ffc..26133477dfa0 100644 --- a/rdbmaker/inc/codemaker/global.hxx +++ b/rdbmaker/inc/codemaker/global.hxx @@ -75,10 +75,6 @@ typedef ::std::set< ::rtl::OString, LessString > StringSet; ::rtl::OString makeTempName(); const ::rtl::OString inGlobalSet(const ::rtl::OUString & r); -inline const ::rtl::OString inGlobalSet(sal_Char* p) -{ - return inGlobalSet( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(p) ) ); -} ::rtl::OUString convertToFileUrl(const ::rtl::OString& fileName); diff --git a/rdbmaker/source/codemaker/dependency.cxx b/rdbmaker/source/codemaker/dependency.cxx index 091b379aa298..692184a8be3f 100644 --- a/rdbmaker/source/codemaker/dependency.cxx +++ b/rdbmaker/source/codemaker/dependency.cxx @@ -100,35 +100,6 @@ TypeUsingSet TypeDependency::getDependencies(const OString& type) return TypeUsingSet(); } -sal_Bool TypeDependency::lookupDependency(const OString& type, const OString& depend, sal_uInt16 use) -{ - sal_Bool ret = sal_False; - - if (type.getLength() > 0 && depend.getLength() > 0) - { - if (m_pImpl->m_dependencies.count(type) > 0) - { - TypeUsingSet::const_iterator iter = m_pImpl->m_dependencies[type].begin(); - - while (iter != m_pImpl->m_dependencies[type].end()) - { - if (depend == (*iter).m_type && - (use & (*iter).m_use)) - { - ret = sal_True; - break; - } - iter++; - } - } else - { - ret = sal_False; - } - } - - return ret; -} - sal_Bool TypeDependency::hasDependencies(const OString& type) { if (type.getLength() > 0) diff --git a/registry/source/keyimpl.cxx b/registry/source/keyimpl.cxx index f8de7e20b148..b41fbbb5ada9 100644 --- a/registry/source/keyimpl.cxx +++ b/registry/source/keyimpl.cxx @@ -365,6 +365,7 @@ RegError ORegKey::setValue(const OUString& valueName, RegValueType vType, RegVal return REG_SET_VALUE_FAILED; } + //rValue.flush(); rtl_freeMemory(pBuffer); return REG_NO_ERROR; } @@ -423,6 +424,7 @@ RegError ORegKey::setLongListValue(const OUString& valueName, sal_Int32* pValueL return REG_SET_VALUE_FAILED; } + //rValue.flush(); rtl_freeMemory(pBuffer); return REG_NO_ERROR; } @@ -490,6 +492,7 @@ RegError ORegKey::setStringListValue(const OUString& valueName, sal_Char** pValu return REG_SET_VALUE_FAILED; } + //rValue.flush(); rtl_freeMemory(pBuffer); return REG_NO_ERROR; } @@ -557,6 +560,7 @@ RegError ORegKey::setUnicodeListValue(const OUString& valueName, sal_Unicode** p return REG_SET_VALUE_FAILED; } + //rValue.flush(); rtl_freeMemory(pBuffer); return REG_NO_ERROR; } diff --git a/registry/source/regimpl.cxx b/registry/source/regimpl.cxx index 86165b42bd1d..b9edca734232 100644 --- a/registry/source/regimpl.cxx +++ b/registry/source/regimpl.cxx @@ -550,6 +550,7 @@ RegError ORegistry::closeRegistry() if (m_file.isValid()) { closeKey(m_openKeyTable[ROOT]); + m_file.flush(); m_file.close(); m_isOpen = sal_False; return REG_NO_ERROR; @@ -847,6 +848,7 @@ RegError ORegistry::eraseKey(ORegKey* pKey, const OUString& keyName) { return REG_DELETE_KEY_FAILED; } + //sFile.flush(); // set flag deleted !!! ((ORegKey*)hOldKey)->setDeleted(sal_True); @@ -892,6 +894,7 @@ RegError ORegistry::deleteSubkeysAndValues(ORegKey* pKey) { return REG_DELETE_VALUE_FAILED; } + //((OStoreFile&)pKey->getStoreFile()).flush(); } _err = rStoreDir.next(iter); @@ -1062,6 +1065,7 @@ RegError ORegistry::loadAndSaveValue(ORegKey* pTargetKey, { return REG_VALUE_NOT_EXISTS; } + //pSourceKey->getStoreFile().flush(); pBuffer = (sal_uInt8*)rtl_allocateMemory(VALUE_HEADERSIZE); @@ -1133,6 +1137,7 @@ RegError ORegistry::loadAndSaveValue(ORegKey* pTargetKey, rtl_freeMemory(pBuffer); return REG_INVALID_VALUE; } + //rTargetFile.flush(); if (rwBytes != nSize) { @@ -1477,6 +1482,20 @@ RegError ORegistry::dumpRegistry(RegKeyHandle hKey) const return REG_NO_ERROR; } +RegError ORegistry::flush() +{ + REG_GUARD(m_mutex); + + if (m_file.isValid()) + { + m_file.flush(); + return REG_NO_ERROR; + } else + { + return REG_REGISTRY_NOT_EXISTS; + } +} + //********************************************************************* // dumpValue() diff --git a/registry/source/regimpl.hxx b/registry/source/regimpl.hxx index c32dcf3527df..32baf9cc6ed5 100644 --- a/registry/source/regimpl.hxx +++ b/registry/source/regimpl.hxx @@ -113,6 +113,8 @@ public: RegError dumpRegistry(RegKeyHandle hKey) const; + RegError flush(); + ~ORegistry(); sal_Bool isReadOnly() const diff --git a/registry/source/registry.cxx b/registry/source/registry.cxx index cb145b3910c2..139646f7cdc7 100644 --- a/registry/source/registry.cxx +++ b/registry/source/registry.cxx @@ -430,6 +430,8 @@ static RegError REGISTRY_CALLTYPE mergeKey(RegHandle hReg, */ _ret = pKey->closeKey(pNewKey); + if (_ret == REG_NO_ERROR ) + _ret = pReg->flush(); return _ret; } diff --git a/registry/test/testmerge.cxx b/registry/test/testmerge.cxx index 7cff15412745..efea89caf837 100644 --- a/registry/test/testmerge.cxx +++ b/registry/test/testmerge.cxx @@ -320,42 +320,42 @@ void test_merge() Value = new sal_uInt8[valueSize]; REG_ENSURE(!key1.getValue(OUString::createFromAscii("/MergeKey1/MK1SubKey2/KeyWithStringValue"), (RegValue)Value), "testMerge error 76.a)"); REG_ENSURE(strcmp((const sal_Char*)Value, sValue) == 0, "testMerge error 76.b)"); - delete(Value); + delete [] Value; REG_ENSURE(!key1.getValueInfo(OUString::createFromAscii("/MergeKey1/MK1SubKey3/KeyWithUnicodeValue"), &valueType, &valueSize), "testMerge error 77"); REG_ENSURE(valueType == RG_VALUETYPE_UNICODE && valueSize == (wValue.getLength()+1)*sizeof(sal_Unicode), "testMerge error 78"); Value = new sal_uInt8[valueSize]; REG_ENSURE(!key1.getValue(OUString::createFromAscii("/MergeKey1/MK1SubKey3/KeyWithUnicodeValue"), (RegValue)Value), "testMerge error 78.a)"); REG_ENSURE(wValue.equals( (const sal_Unicode*)Value ), "testMerge error 78.b)"); - delete(Value); + delete [] Value; REG_ENSURE(!key1.getValueInfo(OUString::createFromAscii("/MergeKey1/MK1SubKey4/KeyWithBinaryValue"), &valueType, &valueSize), "testMerge error 79"); REG_ENSURE(valueType == RG_VALUETYPE_BINARY && valueSize == 27, "testMerge error 80"); Value = new sal_uInt8[valueSize]; REG_ENSURE(!key1.getValue(OUString::createFromAscii("/MergeKey1/MK1SubKey4/KeyWithBinaryValue"), (RegValue)Value), "testMerge error 80.a)"); REG_ENSURE(strcmp((const sal_Char*)Value, "abcdefghijklmnopqrstuvwxyz") == 0, "testMerge error 80.b)"); - delete(Value); + delete [] Value; REG_ENSURE(!key1.getValueInfo(OUString::createFromAscii("/MergeKey2/MK2SubKey1/KeyWithBinaryValue"), &valueType, &valueSize), "testMerge error 81"); REG_ENSURE(valueType == RG_VALUETYPE_BINARY && valueSize == 11, "testMerge error 82"); Value = new sal_uInt8[valueSize]; REG_ENSURE(!key1.getValue(OUString::createFromAscii("/MergeKey2/MK2SubKey1/KeyWithBinaryValue"), (RegValue)Value), "testMerge error 82.a)"); REG_ENSURE(strcmp((const sal_Char*)Value, "1234567890") == 0, "testMerge error 82.b)"); - delete(Value); + delete [] Value; REG_ENSURE(!key1.getValueInfo(OUString::createFromAscii("/MergeKey2/MK2SubKey2/KeyWithUnicodeValue"), &valueType, &valueSize), "testMerge error 83"); REG_ENSURE(valueType == RG_VALUETYPE_UNICODE&& valueSize == (wValue.getLength()+1)*sizeof(sal_Unicode), "testMerge error 84"); Value = new sal_uInt8[valueSize]; REG_ENSURE(!key1.getValue(OUString::createFromAscii("/MergeKey2/MK2SubKey2/KeyWithUnicodeValue"), (RegValue)Value), "testMerge error 84.a)"); REG_ENSURE(wValue.equals( (const sal_Unicode*)Value ), "testMerge error 84.b)"); - delete(Value); + delete [] Value; REG_ENSURE(!key1.getValueInfo(OUString::createFromAscii("/MergeKey2/MK2SubKey3/KeyWithStringValue"), &valueType, &valueSize), "testMerge error 85"); REG_ENSURE(valueType == RG_VALUETYPE_STRING && valueSize == strlen(sValue)+1, "testMerge error 86"); Value = new sal_uInt8[valueSize]; REG_ENSURE(!key1.getValue(OUString::createFromAscii("/MergeKey2/MK2SubKey3/KeyWithStringValue"), (RegValue)Value), "testMerge error 86.a)"); REG_ENSURE(strcmp((const sal_Char*)Value, sValue) == 0, "testMerge error 86.b)"); - delete(Value); + delete [] Value; REG_ENSURE(!key1.getValueInfo(OUString::createFromAscii("/MergeKey2/MK2SubKey4/KeyWithLongValue"), &valueType, &valueSize), "testMerge error 87"); REG_ENSURE(valueType == RG_VALUETYPE_LONG && valueSize == sizeof(sal_Int32), "testMerge error 88"); @@ -372,21 +372,21 @@ void test_merge() Value = new sal_uInt8[valueSize]; REG_ENSURE(!key1.getValue(OUString::createFromAscii("/MergeKey1u2/MK1SubKey12/KeyWithStringValue"), (RegValue)Value), "testMerge error 92.a)"); REG_ENSURE(strcmp((const sal_Char*)Value, sValue) == 0, "testMerge error 92.b)"); - delete(Value); + delete [] Value; REG_ENSURE(!key1.getValueInfo(OUString::createFromAscii("/MergeKey1u2/MK1SubKey13/KeyWithUnicodeValue"), &valueType, &valueSize), "testMerge error 93"); REG_ENSURE(valueType == RG_VALUETYPE_UNICODE && valueSize == (wValue.getLength()+1)*sizeof(sal_Unicode), "testMerge error 94"); Value = new sal_uInt8[valueSize]; REG_ENSURE(!key1.getValue(OUString::createFromAscii("/MergeKey1u2/MK1SubKey13/KeyWithUnicodeValue"), (RegValue)Value), "testMerge error 94.a)"); REG_ENSURE(wValue.equals( (const sal_Unicode*)Value ), "testMerge error 94.b)"); - delete(Value); + delete [] Value; REG_ENSURE(!key1.getValueInfo(OUString::createFromAscii("/MergeKey1u2/MK2SubKey21/KeyWithBinaryValue"), &valueType, &valueSize), "testMerge error 95"); REG_ENSURE(valueType == RG_VALUETYPE_BINARY && valueSize == 19, "testMerge error 96"); Value = new sal_uInt8[valueSize]; REG_ENSURE(!key1.getValue(OUString::createFromAscii("/MergeKey1u2/MK2SubKey21/KeyWithBinaryValue"), (RegValue)Value), "testMerge error 96.a)"); REG_ENSURE(strcmp((const sal_Char*)Value, "a1b2c3d4e5f6g7h8i9") == 0, "testMerge error 96.b)"); - delete(Value); + delete [] Value; REG_ENSURE(!key1.getValueInfo(OUString::createFromAscii("/MergeKey1u2/MK2SubKey22/KeyWithLongValue"), &valueType, &valueSize), "testMerge error 97"); REG_ENSURE(valueType == RG_VALUETYPE_LONG && valueSize == sizeof(sal_Int32), "testMerge error 98"); @@ -398,7 +398,7 @@ void test_merge() Value = new sal_uInt8[valueSize]; REG_ENSURE(!key1.getValue(OUString::createFromAscii("/MergeKey1u2/MK2SubKey23/KeyWithStringValue"), (RegValue)Value), "testMerge error 100.a)"); REG_ENSURE(strcmp((const sal_Char*)Value, sValue) == 0, "testMerge error 100.b)"); - delete(Value); + delete [] Value; REG_ENSURE(!key1.getValueInfo(OUString::createFromAscii("/MergeKey1u2/MK12SubKey1u2/KeyWithLongValue"), &valueType, &valueSize), "testMerge error 101"); REG_ENSURE(valueType == RG_VALUETYPE_LONG && valueSize == sizeof(sal_Int32), "testMerge error 102"); @@ -416,7 +416,7 @@ void test_merge() REG_ENSURE(!myRegistry->destroy( OUString::createFromAscii("merge2.rdb") ), "test_registry_CppApi error 12"); REG_ENSURE(!myRegistry->destroy( OUString() ), "test_registry_CppApi error 13"); - delete(myRegistry); + delete myRegistry; cout << "test_merge() Ok!\n"; return; diff --git a/remotebridges/source/bridge/makefile.mk b/remotebridges/source/bridge/makefile.mk index ef02b1bcebc9..75b5f3a6152e 100644 --- a/remotebridges/source/bridge/makefile.mk +++ b/remotebridges/source/bridge/makefile.mk @@ -38,6 +38,7 @@ COMP1TYPELIST = remotebridge # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk +.IF "$(L10N_framework)"=="" DLLPRE = # ------------------------------------------------------------------ @@ -61,6 +62,7 @@ SHL1DEF= $(MISC)$/$(SHL1TARGET).def SHL1RPATH= URELIB DEF1NAME= $(SHL1TARGET) +.ENDIF # L10N_framework # --- Targets ------------------------------------------------------ .INCLUDE : target.mk diff --git a/remotebridges/source/dynamicloader/makefile.mk b/remotebridges/source/dynamicloader/makefile.mk index 1a4364c74062..95a80e107ffb 100755 --- a/remotebridges/source/dynamicloader/makefile.mk +++ b/remotebridges/source/dynamicloader/makefile.mk @@ -39,6 +39,7 @@ COMP1TYPELIST = dynamicloader # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk +.IF "$(L10N_framework)"=="" DLLPRE = # ------------------------------------------------------------------ @@ -65,6 +66,7 @@ SHL1DEF=$(MISC)$/$(SHL1TARGET).def DEF1NAME= $(SHL1TARGET) +.ENDIF # L10N_framework # --- Targets ------------------------------------------------------ diff --git a/remotebridges/source/factory/makefile.mk b/remotebridges/source/factory/makefile.mk index 280ed38829f8..97eb02415a47 100644 --- a/remotebridges/source/factory/makefile.mk +++ b/remotebridges/source/factory/makefile.mk @@ -38,6 +38,7 @@ COMP1TYPELIST = brdgfctr # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk +.IF "$(L10N_framework)"=="" DLLPRE = # ------------------------------------------------------------------ @@ -61,6 +62,7 @@ SHL1DEF= $(MISC)$/$(SHL1TARGET).def SHL1RPATH= URELIB DEF1NAME= $(SHL1TARGET) +.ENDIF # L10N_framework # --- Targets ------------------------------------------------------ diff --git a/remotebridges/source/unourl_resolver/makefile.mk b/remotebridges/source/unourl_resolver/makefile.mk index bb005dc167c4..81f8b1c67609 100644 --- a/remotebridges/source/unourl_resolver/makefile.mk +++ b/remotebridges/source/unourl_resolver/makefile.mk @@ -38,6 +38,7 @@ COMP1TYPELIST = uuresolver # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk +.IF "$(L10N_framework)"=="" DLLPRE = # ------------------------------------------------------------------ @@ -60,6 +61,7 @@ SHL1DEF= $(MISC)$/$(SHL1TARGET).def SHL1RPATH= URELIB DEF1NAME= $(SHL1TARGET) +.ENDIF # L10N_framework # --- Targets ------------------------------------------------------ diff --git a/ridljar/com/sun/star/uno/UnoRuntime.java b/ridljar/com/sun/star/uno/UnoRuntime.java index dcf7ff42b10c..28ee8fb1e2bd 100644 --- a/ridljar/com/sun/star/uno/UnoRuntime.java +++ b/ridljar/com/sun/star/uno/UnoRuntime.java @@ -179,8 +179,9 @@ public class UnoRuntime { * otherwise <code>null</code> * @see #queryInterface(Type, Object) */ - public static Object queryInterface(Class zInterface, Object object) { - return queryInterface(new Type(zInterface), object); + @SuppressWarnings("unchecked") + public static <T> T queryInterface(Class<T> zInterface, Object object) { + return (T) queryInterface(new Type(zInterface), object); } /** diff --git a/ridljar/test/com/sun/star/uno/UnoRuntime_Test.java b/ridljar/test/com/sun/star/uno/UnoRuntime_Test.java index 06af7828039e..a9eef19b0a64 100644 --- a/ridljar/test/com/sun/star/uno/UnoRuntime_Test.java +++ b/ridljar/test/com/sun/star/uno/UnoRuntime_Test.java @@ -54,7 +54,7 @@ public final class UnoRuntime_Test extends ComplexTestCase { // Test if a delegator object has the same OID as its creator: Test4 test4 = new Test4(); - Ifc ifc = (Ifc) UnoRuntime.queryInterface(Ifc.class, test4); + Ifc ifc = UnoRuntime.queryInterface(Ifc.class, test4); assure( "Test4", UnoRuntime.generateOid(test4).equals(UnoRuntime.generateOid(ifc))); @@ -64,19 +64,19 @@ public final class UnoRuntime_Test extends ComplexTestCase { // Test if a query for an interface which is not supported returns null: assure( "Test1", - (Ifc) UnoRuntime.queryInterface(Ifc.class, new Test1()) == null); + UnoRuntime.queryInterface(Ifc.class, new Test1()) == null); // Test if a query for an interface which is supported through // IQueryInterface succeeds: assure( "Test2", - (Ifc) UnoRuntime.queryInterface(Ifc.class, new Test2()) != null); + UnoRuntime.queryInterface(Ifc.class, new Test2()) != null); // Test if a query for an interface which is directly supported (through // inheritance) succeeds: assure( "Test3", - (Ifc) UnoRuntime.queryInterface(Ifc.class, new Test3()) != null); + UnoRuntime.queryInterface(Ifc.class, new Test3()) != null); } public void test_areSame() { diff --git a/sal/inc/osl/diagnose.h b/sal/inc/osl/diagnose.h index cd5fd5b6ed6d..908d5a10bbfb 100644 --- a/sal/inc/osl/diagnose.h +++ b/sal/inc/osl/diagnose.h @@ -80,6 +80,26 @@ pfunc_osl_printDetailedDebugMessage SAL_CALL osl_setDetailedDebugMessageFunc( pf #define OSL_THIS_FILE __FILE__ +/* the macro OSL_THIS_FUNC is intended to be an office internal macro for now */ +#ifdef __func__ +#define OSL_THIS_FUNC __func__ +#elifdef __PRETTY_FUNCTION__ +#define OSL_THIS_FUNC __PRETTY_FUNCTION__ +#elifdef __FUNCTION__ +#define OSL_THIS_FUNC __FUNCTION__ +#else +#define OSL_THIS_FUNC " " +#endif + +/* the macro OSL_TO_STRING is intended to be an office internal macro for now */ +#define OSL_TO_STRING( x ) #x + +/* the macro OSL_MACRO_VALUE_TO_STRING is intended to be an office internal macro for now */ +#define OSL_MACRO_VALUE_TO_STRING( x ) OSL_TO_STRING( x ) + +/* the macro OSL_LOG_PREFIX is intended to be an office internal macro for now */ +#define OSL_LOG_PREFIX OSL_THIS_FILE ":" OSL_THIS_FUNC ":" OSL_MACRO_VALUE_TO_STRING( __LINE__ ) "; " + #define OSL_DEBUG_ONLY(s) _OSL_DEBUG_ONLY(s) #define OSL_TRACE _OSL_TRACE #define OSL_ASSERT(c) _OSL_ASSERT(c, OSL_THIS_FILE, __LINE__) diff --git a/sal/inc/rtl/logfile.h b/sal/inc/rtl/logfile.h index 232232a4c3ed..66789d92426e 100644 --- a/sal/inc/rtl/logfile.h +++ b/sal/inc/rtl/logfile.h @@ -67,6 +67,14 @@ void SAL_CALL rtl_logfile_trace( const sal_Char* pszFormat, ... ); */ void SAL_CALL rtl_logfile_longTrace(char const * format, ...); +/** Return if a log file is written. + + @return true if a log file is written + + @since UDK 3.2.11 +*/ +sal_Bool SAL_CALL rtl_logfile_hasLogFile( void ); + #ifdef __cplusplus } #endif diff --git a/sal/inc/rtl/logfile.hxx b/sal/inc/rtl/logfile.hxx index 7ce33f3ea28a..5eae13b62952 100644 --- a/sal/inc/rtl/logfile.hxx +++ b/sal/inc/rtl/logfile.hxx @@ -189,12 +189,19 @@ namespace rtl #define RTL_LOGFILE_PRODUCT_TRACE( string ) \ rtl_logfile_longTrace( "| : %s\n", string ) -#define RTL_LOGFILE_PRODUCT_CONTEXT( instance, name ) \ - ::rtl::Logfile instance( name ) #define RTL_LOGFILE_PRODUCT_TRACE1( frmt, arg1 ) \ rtl_logfile_longTrace( "| : " ); \ rtl_logfile_trace( frmt, arg1 ); \ rtl_logfile_trace( "\n" ) +#define RTL_LOGFILE_PRODUCT_CONTEXT( instance, name ) \ + ::rtl::Logfile instance( name ) +#define RTL_LOGFILE_PRODUCT_CONTEXT_TRACE1( instance, frmt, arg1 ) \ + rtl_logfile_longTrace( "| %s : ", \ + instance.getName() ); \ + rtl_logfile_trace( frmt, arg1 ); \ + rtl_logfile_trace( "\n" ) +#define RTL_LOGFILE_HASLOGFILE() \ + rtl_logfile_hasLogFile() #endif diff --git a/sal/inc/rtl/math.h b/sal/inc/rtl/math.h index 4d72bcaa39d1..fed06e511b26 100644 --- a/sal/inc/rtl/math.h +++ b/sal/inc/rtl/math.h @@ -434,6 +434,42 @@ double SAL_CALL rtl_math_log1p(double fValue) SAL_THROW_EXTERN_C(); */ double SAL_CALL rtl_math_atanh(double fValue) SAL_THROW_EXTERN_C(); +/** Returns values of the Errorfunction erf. + + erf is part of the C99 standard, but not provided by some compilers. + + @param fValue + The value x in the term erf(x). + */ +double SAL_CALL rtl_math_erf(double fValue) SAL_THROW_EXTERN_C(); + +/** Returns values of the complement Errorfunction erfc. + + erfc is part of the C99 standard, but not provided by some compilers. + + @param fValue + The value x in the term erfc(x). + */ +double SAL_CALL rtl_math_erfc(double fValue) SAL_THROW_EXTERN_C(); + +/** Returns values of the inverse hyperbolic sine. + + asinh is part of the C99 standard, but not provided by some compilers. + + @param fValue + The value x in the term asinh(x). + */ +double SAL_CALL rtl_math_asinh(double fValue) SAL_THROW_EXTERN_C(); + +/** Returns values of the inverse hyperbolic cosine. + + acosh is part of the C99 standard, but not provided by some compilers. + + @param fValue + The value x in the term acosh(x). + */ +double SAL_CALL rtl_math_acosh(double fValue) SAL_THROW_EXTERN_C(); + #if defined __cplusplus } #endif /* __cplusplus */ diff --git a/sal/inc/rtl/math.hxx b/sal/inc/rtl/math.hxx index b61cf9b9806f..5760340cc6a4 100644 --- a/sal/inc/rtl/math.hxx +++ b/sal/inc/rtl/math.hxx @@ -221,6 +221,35 @@ inline double atanh(double fValue) return rtl_math_atanh(fValue); } +/** A wrapper around rtl_math_erf. + */ +inline double erf(double fValue) +{ + return rtl_math_erf(fValue); +} + +/** A wrapper around rtl_math_erfc. + */ +inline double erfc(double fValue) +{ + return rtl_math_erfc(fValue); +} + +/** A wrapper around rtl_math_asinh. + */ +inline double asinh(double fValue) +{ + return rtl_math_asinh(fValue); +} + +/** A wrapper around rtl_math_acosh. + */ +inline double acosh(double fValue) +{ + return rtl_math_acosh(fValue); +} + + /** Test equality of two values with an accuracy of the magnitude of the given values scaled by 2^-48 (4 bits roundoff stripped). diff --git a/sal/inc/sal/types.h b/sal/inc/sal/types.h index 23c7529eed26..eec07286f2c5 100644 --- a/sal/inc/sal/types.h +++ b/sal/inc/sal/types.h @@ -124,10 +124,17 @@ typedef unsigned char sal_uInt8; #define SAL_CONST_INT64(x) x##ll #define SAL_CONST_UINT64(x) x##ull + #ifdef __MINGW32__ + #define SAL_PRIdINT64 "I64d" + #define SAL_PRIuUINT64 "I64u" + #define SAL_PRIxUINT64 "I64x" + #define SAL_PRIXUINT64 "I64X" + #else #define SAL_PRIdINT64 "lld" #define SAL_PRIuUINT64 "llu" #define SAL_PRIxUINT64 "llx" #define SAL_PRIXUINT64 "llX" + #endif #else #error "Could not find 64-bit type, add support for your architecture" #endif @@ -170,7 +177,7 @@ typedef void * sal_Handle; /* printf-style conversion specification length modifiers for size_t and ptrdiff_t (most platforms support C99, MSC has its own extension) */ -#if defined _MSC_VER +#if defined(_MSC_VER) || defined(__MINGW32__) #define SAL_PRI_SIZET "I" #define SAL_PRI_PTRDIFFT "I" #else diff --git a/sal/inc/systools/win32/snprintf.h b/sal/inc/systools/win32/snprintf.h index 254726e2f37b..79441f032fee 100644 --- a/sal/inc/systools/win32/snprintf.h +++ b/sal/inc/systools/win32/snprintf.h @@ -1,4 +1,4 @@ -#ifndef _SMPRINTF_H +#ifndef _SNPRINTF_H #define _SNPRINTF_H #if !defined(_WIN32) @@ -77,4 +77,4 @@ _SNPRINTF_DLLIMPORT int __cdecl vsnprintf( char *buffer, size_t count, const cha } #endif -#endif /* _SMPRINTF_H */ +#endif /* _SNPRINTF_H */ diff --git a/sal/osl/all/makefile.mk b/sal/osl/all/makefile.mk index 6bed1c53cfaa..bbb46b89d44e 100644 --- a/sal/osl/all/makefile.mk +++ b/sal/osl/all/makefile.mk @@ -57,18 +57,20 @@ CXXFLAGS+= $(LFS_CFLAGS) SLOFILES= \ $(SLO)$/utility.obj\ - $(SLO)$/readline.obj\ $(SLO)$/filepath.obj\ $(SLO)$/debugbase.obj\ $(SLO)$/loadmodulerelative.obj +# $(SLO)$/readline.obj\ + #.IF "$(UPDATER)"=="YES" OBJFILES= \ $(OBJ)$/utility.obj\ - $(OBJ)$/readline.obj\ $(OBJ)$/filepath.obj\ $(OBJ)$/debugbase.obj\ $(OBJ)$/loadmodulerelative.obj + +# $(OBJ)$/readline.obj\ #.ENDIF # --- Targets ------------------------------------------------------ diff --git a/sal/osl/all/readline.c b/sal/osl/all/readline.c deleted file mode 100644 index 9fc4bced83aa..000000000000 --- a/sal/osl/all/readline.c +++ /dev/null @@ -1,311 +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: readline.c,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. - * - ************************************************************************/ - -#include <osl/diagnose.h> -#include <osl/file.h> -#include <rtl/byteseq.h> -#include <rtl/alloc.h> - - -/* Test cases: - - 1. A file without line ends - 2. A file with lines longer than the initial buffer size - 3. An empty file - 4. -*/ - -/** Some defines -*/ -#define CR 0x0D -#define LF 0x0A - -#define INITIAL_BUFF_SIZE 80 -#define BUFFER_GROW_FACTOR 2 -#define READ_BLOCK_SIZE (INITIAL_BUFF_SIZE - 1) - -/** Helper data and function -*/ - -struct _Buffer -{ - sal_Char* m_pMem; - sal_uInt64 m_Capacity; /* elements possible in buffer */ - sal_uInt64 m_Size; /* elements actually in buffer */ - sal_uInt64 m_ActiveSectionStart; /* buffer was lastly filled from here to - (m_Size - 1) */ -}; - -typedef struct _Buffer Buffer; - - -/** Allocate the memory of the buffer - @Returns sal_True on succes -*/ -static sal_Bool AllocateBuffer(Buffer* pBuffer, sal_uInt64 Capacity) -{ - sal_Bool rc = sal_False; - - OSL_ASSERT(pBuffer); - - pBuffer->m_pMem = (sal_Char*)rtl_allocateZeroMemory((sal_uInt32)Capacity); - if (pBuffer->m_pMem) - { - pBuffer->m_Capacity = Capacity; - pBuffer->m_Size = 0; - pBuffer->m_ActiveSectionStart = 0; - rc = sal_True; - } - - return rc; -} - -/** Release the memory occupied by the buffer -*/ -static void FreeBuffer(Buffer* pBuffer) -{ - OSL_ASSERT(pBuffer); - - rtl_freeMemory(pBuffer->m_pMem); - pBuffer->m_pMem = 0; - pBuffer->m_Capacity = 0; - pBuffer->m_Size = 0; - pBuffer->m_ActiveSectionStart = 0; -} - -/** Grow the buffer by the specified factor (usually doubling - the buffer size) - In case of failure, growing the buffer, the original buffer - stays untouched - - @Returns sal_True on success -*/ -static sal_Bool GrowBuffer(Buffer* pBuffer, size_t factor) -{ - sal_Bool rc = sal_False; - void* p; - - OSL_ASSERT(pBuffer); - - p = rtl_reallocateMemory( - pBuffer->m_pMem, (sal_uInt32)(pBuffer->m_Capacity * factor)); - if (p) - { - pBuffer->m_pMem = (sal_Char*)p; - pBuffer->m_Capacity *= factor; - rc = sal_True; - } - - return rc; -} - -/** Read n bytes from file into buffer, - grow the buffer if necessary - - @Returns osl_File_E_None on success else - an error code -*/ -static oslFileError ReadFromFile(oslFileHandle hFile, Buffer* pBuffer, sal_uInt64 Requested, sal_uInt64* pRead) -{ - oslFileError rc; - - OSL_ASSERT(pBuffer); - OSL_ASSERT(hFile); - OSL_ASSERT(pRead); - - if (((pBuffer->m_Size + Requested) > pBuffer->m_Capacity) && - !GrowBuffer(pBuffer, BUFFER_GROW_FACTOR)) - return osl_File_E_NOMEM; - - pBuffer->m_ActiveSectionStart = pBuffer->m_Size; - - rc = osl_readFile( - hFile, - pBuffer->m_pMem + pBuffer->m_ActiveSectionStart, - Requested, - pRead); - - if (osl_File_E_None == rc) - pBuffer->m_Size += *pRead; - - return rc; -} - -/** Makes a sequence from the given buffer and release the memory - occupied by the buffer -*/ -static void MakeSequenceFreeBuffer(sal_Sequence** ppSequence, Buffer* pBuffer, sal_uInt64 Length) -{ - OSL_ASSERT(ppSequence); - OSL_ASSERT(pBuffer); - OSL_ASSERT(Length <= pBuffer->m_Capacity); - - rtl_byte_sequence_constructFromArray(ppSequence, (sal_Int8*)pBuffer->m_pMem, (sal_Int32)Length); - FreeBuffer(pBuffer); -} - -/** Handle occurence of LF character: - construct a sequence from buffer - correct file pointer (maybe we have read more than necessary) - - @Returns osl_File_E_None on success else - an error code -*/ -static oslFileError HandleLFFreeBuffer(oslFileHandle hFile, sal_Sequence** ppSequence, Buffer* pBuffer, sal_uInt64 Pos) -{ - sal_Int64 offset = 0; - oslFileError rc = osl_File_E_None; - - OSL_ASSERT(hFile); - OSL_ASSERT(pBuffer); - OSL_ASSERT(LF == pBuffer->m_pMem[Pos]); - - /* correct file pointer pos in case we have read to far */ - offset = pBuffer->m_Size - (Pos + 1); - rc = osl_setFilePos(hFile, osl_Pos_Current, -offset); - - if (osl_File_E_None == rc) - MakeSequenceFreeBuffer(ppSequence, pBuffer, Pos); - else - FreeBuffer(pBuffer); - - return rc; -} - -/** Handle occurence of CR character - construct a sequence from buffer - correct file pointer (maybe we have read more than necessary) - - @Returns osl_File_E_None on success else - an error code -*/ -static oslFileError HandleCRFreeBuffer(oslFileHandle hFile, sal_Sequence** ppSequence, Buffer* pBuffer, sal_uInt64 Pos) -{ - sal_Int64 offset = 0; - sal_uInt64 nread = 0; - oslFileError rc = osl_File_E_None; - - OSL_ASSERT(hFile); - OSL_ASSERT(pBuffer); - OSL_ASSERT(CR == pBuffer->m_pMem[Pos]); - - if (Pos == (pBuffer->m_Size - 1)) - { - /* only need to check if the next byte is a LF - that's why reading only one byte from file */ - rc = ReadFromFile(hFile, pBuffer, 1, &nread); - - if (osl_File_E_None != rc) - { - FreeBuffer(pBuffer); - return rc; - } - else if (0 == nread) - { - MakeSequenceFreeBuffer(ppSequence, pBuffer, Pos); - return osl_File_E_None; - } - } - - if (LF == pBuffer->m_pMem[Pos + 1]) - Pos++; - - /* correct the file pointer */ - offset = pBuffer->m_Size - (Pos + 1); - rc = osl_setFilePos(hFile, osl_Pos_Current, -offset); - - if (osl_File_E_None == rc) - MakeSequenceFreeBuffer(ppSequence, pBuffer, Pos - 1); - else - FreeBuffer(pBuffer); - - return rc; -} - -/*************************************************************************** - osl_readLine (platform independent) - Reads a line from given file. The new line delimiter(s) are NOT returned! - Valid line ends: \n, \r\n or \r - - @param Handle [in] Handle to an open file. - @param ppSequence [in/out] a pointer to a valid sequence. - - @return osl_File_E_None on success otherwise one of the following errorcodes:<p> - - osl_File_E_INVAL the format of the parameters was not valid<br> - osl_File_E_NOMEM the necessary memory could not be allocated -****************************************************************************/ - -oslFileError SAL_CALL osl_readLine(oslFileHandle Handle, sal_Sequence** ppSeq) -{ - oslFileError rc; - sal_uInt64 nread = 0; - Buffer line_buffer; - sal_uInt64 pos; - - OSL_PRECOND(Handle, "invalid handle"); - OSL_PRECOND(ppSeq, "invalid parameter detected"); - - if (!AllocateBuffer(&line_buffer, INITIAL_BUFF_SIZE)) - return osl_File_E_NOMEM; - - for(;;) - { - rc = ReadFromFile(Handle, &line_buffer, READ_BLOCK_SIZE, &nread); - - if (osl_File_E_None != rc) - { - FreeBuffer(&line_buffer); - return rc; - } - else if (0 == nread) - { - /* EOF */ - nread = line_buffer.m_Size; - MakeSequenceFreeBuffer(ppSeq, &line_buffer, nread); - if (0 < nread) - return osl_File_E_None; - else - return osl_File_E_AGAIN; - } - - /* scan buffer for line end */ - for (pos = line_buffer.m_ActiveSectionStart; pos < line_buffer.m_Size; pos++) - { - switch(line_buffer.m_pMem[pos]) - { - case LF: - return HandleLFFreeBuffer(Handle, ppSeq, &line_buffer, pos); - case CR: - return HandleCRFreeBuffer(Handle, ppSeq, &line_buffer, pos); - } - } - } /* end for */ -} diff --git a/sal/osl/os2/debug.c b/sal/osl/os2/debug.c index 67fc7a1e709f..78a2df07056e 100644 --- a/sal/osl/os2/debug.c +++ b/sal/osl/os2/debug.c @@ -1,3 +1,33 @@ +/************************************************************************* + * + * 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:$ + * $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. + * + ************************************************************************/ + /* *@@sourcefile debug.c: * this file contains debugging functions for the @@ -27,20 +57,15 @@ */ /* - * This file Copyright (C) 1992-99 Ulrich Mller, + * This file Copyright (C) 1992-99 Ulrich M�ller, * Kim Rasmussen, * Marc Fiammante, * John Currier, * Anthony Cruise. * This file is part of the "XWorkplace helpers" source package. - * This is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation, in version 2 as it comes in the - * "COPYING" file of the XWorkplace main distribution. - * This program 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 General Public License for more details. + * + * 2009-06-15 published under LGPL3 with Ulrich M�ller permission. + * */ //#define DEBUG_SYMDUMP // enable to dump sym file to log @@ -1484,7 +1509,7 @@ void dbgPrintVariables(FILE *LogFile, // in: text log file to write to (PVOID)stackofs, func_name); fprintf(LogFile, " Offset Name Type Value \n"); - fprintf(LogFile, " \n"); + fprintf(LogFile, " ������ �������������������� ��������������������������������� �����������������\n"); } // If it's one of the simple types @@ -1880,7 +1905,7 @@ VOID dbgPrintStack(FILE *LogFile, // in: text log file to write to fprintf(LogFile, "\n\nCall stack:\n"); fprintf(LogFile, " Source Line Nearest\n"); fprintf(LogFile, " EBP Address Module Obj# File Numbr Public Symbol\n"); - fprintf(LogFile, " - -\n"); + fprintf(LogFile, " �������� ��������- �������� ���� ������������ ����� ������������-\n"); do { diff --git a/sal/osl/os2/except.c b/sal/osl/os2/except.c index e1ae9fb7bd06..0dd2a35d1fcd 100644 --- a/sal/osl/os2/except.c +++ b/sal/osl/os2/except.c @@ -1,3 +1,32 @@ +/************************************************************************* + * + * 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:$ + * $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. + * + ************************************************************************/ /* *@@sourcefile except.c: @@ -178,7 +207,7 @@ * exception handling DLL, available at Hobbes). * * If not explicitly stated otherwise, the code has been written - * by me, Ulrich Mller. + * by me, Ulrich M�ller. * * Note: Version numbering in this file relates to XWorkplace version * numbering. @@ -187,7 +216,7 @@ */ /* - * This file Copyright (C) 1992-99 Ulrich Mller, + * This file Copyright (C) 1992-99 Ulrich M�ller, * Monte Copeland, * Roman Stangl, * Kim Rasmussen, @@ -195,14 +224,9 @@ * John Currier, * Anthony Cruise. * This file is part of the "XWorkplace helpers" source package. - * This is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation, in version 2 as it comes in the - * "COPYING" file of the XWorkplace main distribution. - * This program 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 General Public License for more details. + * + * 2009-06-15 published under LGPL3 with Ulrich M�ller permission. + * */ #define OS2EMX_PLAIN_CHAR diff --git a/sal/osl/os2/helpers/debug.h b/sal/osl/os2/helpers/debug.h index be35be3d3326..b03508b70379 100644 --- a/sal/osl/os2/helpers/debug.h +++ b/sal/osl/os2/helpers/debug.h @@ -1,3 +1,32 @@ +/************************************************************************* + * + * 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:$ + * $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. + * + ************************************************************************/ /* *@@sourcefile debug.h: @@ -21,19 +50,14 @@ * Anthony Cruise (EXCEPT3.ZIP package for a generic * exception handling DLL, available at Hobbes). * - * This file Copyright (C) 1992-99 Ulrich Mller, + * This file Copyright (C) 1992-99 Ulrich M�ller, * Kim Rasmussen, * Marc Fiammante, * John Currier, * Anthony Cruise. - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, in version 2 as it comes in the COPYING - * file of the XFolder main distribution. - * This program 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 General Public License for more details. + * + * 2009-06-15 published under LGPL3 with Ulrich M�ller permission. + * */ #ifndef DEBUG_HEADER_INCLUDED diff --git a/sal/osl/os2/helpers/dosh.h b/sal/osl/os2/helpers/dosh.h index d2e936a57447..518f979fd4de 100644 --- a/sal/osl/os2/helpers/dosh.h +++ b/sal/osl/os2/helpers/dosh.h @@ -1,28 +1,39 @@ - -/* - *@@sourcefile dosh.h: - * header file for dosh.c. See remarks there. +/************************************************************************* * - * Note: Version numbering in this file relates to XWorkplace version - * numbering. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - *@@include #define INCL_DOSPROCESS - *@@include #define INCL_DOSDEVIOCTL // for doshQueryDiskParams only - *@@include #include <os2.h> - *@@include #include "helpers\dosh.h" - */ + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile:$ + * $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. + * + ************************************************************************/ -/* This file Copyright (C) 1997-2001 Ulrich Mller, +/* This file Copyright (C) 1997-2006 Ulrich M�ller, * Dmitry A. Steklenev. * This file is part of the "XWorkplace helpers" source package. - * This is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation, in version 2 as it comes in the - * "COPYING" file of the XWorkplace main distribution. - * This program 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 General Public License for more details. + * + * 2009-06-15 published under LGPL3 with Ulrich M�ller permission. + * */ #if __cplusplus @@ -32,886 +43,10 @@ extern "C" { #ifndef DOSH_HEADER_INCLUDED #define DOSH_HEADER_INCLUDED - /* ****************************************************************** - * - * Wrappers - * - ********************************************************************/ - - // if DOSH_STANDARDWRAPPERS is #define'd before including dosh.h, - // all the following Dos* API calls are redirected to the dosh* - // counterparts - - #ifdef DOSH_STANDARDWRAPPERS - - #ifdef INCL_DOSPROCESS - - APIRET XWPENTRY doshSleep(ULONG msec); - #define DosSleep(a) doshSleep((a)) - - #endif - - #ifdef INCL_DOSSEMAPHORES - - APIRET XWPENTRY doshCreateMutexSem(PSZ pszName, - PHMTX phmtx, - ULONG flAttr, - BOOL32 fState); - #define DosCreateMutexSem(a, b, c, d) doshCreateMutexSem((a), (b), (c), (d)) - - APIRET XWPENTRY doshRequestMutexSem(HMTX hmtx, ULONG ulTimeout); - #define DosRequestMutexSem(h, t) doshRequestMutexSem((h), (t)) - - APIRET XWPENTRY doshReleaseMutexSem(HMTX hmtx); - #define DosReleaseMutexSem(h) doshReleaseMutexSem((h)) - - #endif - - #ifdef INCL_DOSEXCEPTIONS - - APIRET XWPENTRY doshSetExceptionHandler(PEXCEPTIONREGISTRATIONRECORD pERegRec); - #define DosSetExceptionHandler(a) doshSetExceptionHandler((a)) - - APIRET XWPENTRY doshUnsetExceptionHandler(PEXCEPTIONREGISTRATIONRECORD pERegRec); - #define DosUnsetExceptionHandler(a) doshUnsetExceptionHandler((a)) - - #endif - - #endif - - /* ****************************************************************** - * - * Miscellaneous - * - ********************************************************************/ - - CHAR doshGetChar(VOID); - - BOOL doshQueryShiftState(VOID); - - ULONG doshIsWarp4(VOID); - - PSZ doshQuerySysErrorMsg(APIRET arc); - - ULONG doshQuerySysUptime(VOID); - - /* ****************************************************************** - * - * Memory helpers - * - ********************************************************************/ - - PVOID doshMalloc(ULONG cb, - APIRET *parc); - - APIRET doshAllocArray(ULONG c, - ULONG cbArrayItem, - PBYTE *ppv, - PULONG pcbAllocated); - - PVOID doshAllocSharedMem(ULONG ulSize, - const char* pcszName); - - PVOID doshRequestSharedMem(PCSZ pcszName); - - /* ****************************************************************** - * - * Drive helpers - * - ********************************************************************/ - - APIRET doshIsFixedDisk(ULONG ulLogicalDrive, - PBOOL pfFixed); - - #ifdef INCL_DOSDEVIOCTL - - // #pragma pack(1) - - /* - * DRIVEPARAMS: - * structure used for doshQueryDiskParams. - * removed this, we can directly use BIOSPARAMETERBLOCK - * V0.9.13 (2001-06-14) [umoeller] - */ - - /* typedef struct _DRIVEPARAMS - { - BIOSPARAMETERBLOCK bpb; - // BIOS parameter block. This is the first sector - // (at byte 0) in each partition. This is defined - // in the OS2 headers as follows: - - typedef struct _BIOSPARAMETERBLOCK { - 0 USHORT usBytesPerSector; - // Number of bytes per sector. - 2 BYTE bSectorsPerCluster; - // Number of sectors per cluster. - 3 USHORT usReservedSectors; - // Number of reserved sectors. - 5 BYTE cFATs; - // Number of FATs. - 6 USHORT cRootEntries; - // Number of root directory entries. - 8 USHORT cSectors; - // Number of sectors. - 10 BYTE bMedia; - // Media descriptor. - 11 USHORT usSectorsPerFAT; - // Number of secctors per FAT. - 13 USHORT usSectorsPerTrack; - // Number of sectors per track. - 15 USHORT cHeads; - // Number of heads. - 17 ULONG cHiddenSectors; - // Number of hidden sectors. - 21 ULONG cLargeSectors; - // Number of large sectors. - 25 BYTE abReserved[6]; - // Reserved. - 31 USHORT cCylinders; - // Number of cylinders defined for the physical - // device. - 33 BYTE bDeviceType; - // Physical layout of the specified device. - 34 USHORT fsDeviceAttr; - // A bit field that returns flag information - // about the specified drive. - } BIOSPARAMETERBLOCK; - - // removed the following fields... these are already - // in the extended BPB structure, as defined in the - // Toolkit's BIOSPARAMETERBLOCK struct. Checked this, - // the definition is the same for the Toolkit 3 and 4.5. - - USHORT usCylinders; - // no. of cylinders - UCHAR ucDeviceType; - // device type; according to the IBM Control - // Program Reference (see DSK_GETDEVICEPARAMS), - // this value can be: - // -- 0: 48 TPI low-density diskette drive - // -- 1: 96 TPI high-density diskette drive - // -- 2: 3.5-inch 720KB diskette drive - // -- 3: 8-Inch single-density diskette drive - // -- 4: 8-Inch double-density diskette drive - // -- 5: Fixed disk - // -- 6: Tape drive - // -- 7: Other (includes 1.44MB 3.5-inch diskette drive - // and CD-ROMs) - // -- 8: R/W optical disk - // -- 9: 3.5-inch 4.0MB diskette drive (2.88MB formatted) - USHORT usDeviceAttrs; - // DEVATTR_* flags - } DRIVEPARAMS, *PDRIVEPARAMS; - #pragma pack() */ - - APIRET doshQueryDiskParams(ULONG ulLogicalDrive, - PBIOSPARAMETERBLOCK pdp); - - BYTE doshQueryDriveType(ULONG ulLogicalDrive, - PBIOSPARAMETERBLOCK pdp, - BOOL fFixed); - - APIRET XWPENTRY doshHasAudioCD(ULONG ulLogicalDrive, - HFILE hfDrive, - BOOL fMixedModeCD, - PBOOL pfAudio); - - #endif - - VOID XWPENTRY doshEnumDrives(PSZ pszBuffer, - PCSZ pcszFileSystem, - BOOL fSkipRemoveables); - typedef VOID XWPENTRY DOSHENUMDRIVES(PSZ pszBuffer, - PCSZ pcszFileSystem, - BOOL fSkipRemoveables); - typedef DOSHENUMDRIVES *PDOSHENUMDRIVES; - CHAR doshQueryBootDrive(VOID); - #define ERROR_AUDIO_CD_ROM 10000 - - #define DRVFL_MIXEDMODECD 0x0001 - #define DRVFL_TOUCHFLOPPIES 0x0002 - #define DRVFL_CHECKEAS 0x0004 - #define DRVFL_CHECKLONGNAMES 0x0008 - - APIRET doshAssertDrive(ULONG ulLogicalDrive, - ULONG fl); - - #ifdef INCL_DOSDEVIOCTL - - /* - *@@ XDISKINFO: - * - *@@added V0.9.16 (2002-01-13) [umoeller] - */ - - typedef struct _XDISKINFO - { - CHAR cDriveLetter; // drive letter - CHAR cLogicalDrive; // logical drive no. - - BOOL fPresent; // if FALSE, drive does not exist - - // the following are only valid if fPresent == TRUE - - BIOSPARAMETERBLOCK bpb; - // 0x00 USHORT usBytesPerSector; - // 0x02 BYTE bSectorsPerCluster; - // 0x03 USHORT usReservedSectors; - // 0x05 BYTE cFATs; - // 0x06 USHORT cRootEntries; - // 0x08 USHORT cSectors; - // 0x0a BYTE bMedia; - // 0x0b USHORT usSectorsPerFAT; - // 0x0d USHORT usSectorsPerTrack; - // 0x0f USHORT cHeads; - // 0x11 ULONG cHiddenSectors; - // 0x15 ULONG cLargeSectors; - // 0x19 BYTE abReserved[6]; - // 0x1a USHORT cCylinders; - // 0x1c BYTE bDeviceType; - #ifndef DEVTYPE_48TPI - #define DEVTYPE_48TPI 0x0000 - #define DEVTYPE_96TPI 0x0001 - #define DEVTYPE_35 0x0002 - #define DEVTYPE_8SD 0x0003 - #define DEVTYPE_8DD 0x0004 - #define DEVTYPE_FIXED 0x0005 - #define DEVTYPE_TAPE 0x0006 - #endif - #define DEVTYPE_OTHER 0x0007 - // includes 1.44 3.5" floppy - #define DEVTYPE_RWOPTICAL 0x0008 - #define DEVTYPE_35_288MB 0x0009 - // 0x1d USHORT fsDeviceAttr; - #define DEVATTR_REMOVEABLE 0x0001 - // drive is removeable - #define DEVATTR_CHANGELINE 0x0002 - // device can determine whether media has - // been removed since last I/O operation - #define DEVATTR_GREATER16MB 0x0004 - // physical device driver supports physical - // addresses > 16 MB - #define DEVATTR_PARTITIONALREMOVEABLE 0x0008 - // undocumented flag; set for ZIP drives - - BYTE bType; - // do not change these codes, XWorkplace relies - // on them too to parse WPDisk data - #define DRVTYPE_HARDDISK 0 - #define DRVTYPE_FLOPPY 1 - #define DRVTYPE_TAPE 2 - #define DRVTYPE_VDISK 3 - #define DRVTYPE_CDROM 4 - #define DRVTYPE_LAN 5 - #define DRVTYPE_PARTITIONABLEREMOVEABLE 6 - #define DRVTYPE_UNKNOWN 255 - - ULONG flDevice; - // any combination of the following: - #define DFL_REMOTE 0x0001 - // drive is remote (not local) - #define DFL_FIXED 0x0002 - // drive is fixed; otherwise it is removeable! - // always set for harddisks and zip drives - #define DFL_PARTITIONABLEREMOVEABLE 0x0004 - // set for zip drives; - // in that case, DFL_FIXED is set also - #define DFL_BOOTDRIVE 0x0008 - // drive was booted from - - // media flags: - - #define DFL_MEDIA_PRESENT 0x1000 - // media is present in drive; - // -- always set for harddisks, - // unless the file system is not - // understood - // -- always set for remove drives - // -- always set for A: and B: - // -- set for CD-ROMS only if data - // CD-ROM is inserted - #define DFL_AUDIO_CD 0x2000 - // set for CD-ROMs only, if an audio CD - // is currently inserted; in that case, - // DFL_MEDIA_PRESENT is _not_ set - #define DFL_SUPPORTS_EAS 0x4000 - // drive supports extended attributes - // (assumption based on DosFSCtl, - // might not be correct for remote drives; - // reports correctly for FAT32 though) - #define DFL_SUPPORTS_LONGNAMES 0x8000 - // drive supports long names; this does not - // necessarily mean that we support all IFS - // characters also - - // the following are only valid if DFL_MEDIA_PRESENT is set; - // they are always set for drives A: and B: - - CHAR szFileSystem[30]; - // e.g. "FAT" or "HPFS" or "JFS" or "CDFS" - - LONG lFileSystem; - // do not change these codes, XWorkplace relies - // on them too to parse WPDisk data - #define FSYS_UNKNOWN 0 - // drive not formatted, or unknown file system - #define FSYS_FAT 1 - #define FSYS_HPFS_JFS 2 - #define FSYS_CDFS 3 - #define FSYS_CDWFS 6 // not used by WPS! - // added V0.9.19 (2002-04-25) [umoeller] - #define FSYS_TVFS 7 // not used by WPS! - #define FSYS_FAT32_EXT2 8 // not used by WPS! - #define FSYS_RAMFS 9 // not used by WPS! - #define FSYS_REMOTE 10 - // NOTE: if this has a negative value, this is - // the APIRET code from DosQueryFSAttach - - // error codes for various operations - APIRET arcIsFixedDisk, - arcQueryDiskParams, - arcQueryMedia, - arcOpenLongnames; - - } XDISKINFO, *PXDISKINFO; - - APIRET doshGetDriveInfo(ULONG ulLogicalDrive, - ULONG fl, - PXDISKINFO pdi); - - #endif - - APIRET doshSetLogicalMap(ULONG ulLogicalDrive); - - APIRET XWPENTRY doshQueryDiskSize(ULONG ulLogicalDrive, double *pdSize); - typedef APIRET XWPENTRY DOSHQUERYDISKSIZE(ULONG ulLogicalDrive, double *pdSize); - typedef DOSHQUERYDISKSIZE *PDOSHQUERYDISKSIZE; - - APIRET XWPENTRY doshQueryDiskFree(ULONG ulLogicalDrive, double *pdFree); - typedef APIRET XWPENTRY DOSHQUERYDISKFREE(ULONG ulLogicalDrive, double *pdFree); - typedef DOSHQUERYDISKFREE *PDOSHQUERYDISKFREE; - - APIRET XWPENTRY doshQueryDiskFSType(ULONG ulLogicalDrive, PSZ pszBuf, ULONG cbBuf); - typedef APIRET XWPENTRY DOSHQUERYDISKFSTYPE(ULONG ulLogicalDrive, PSZ pszBuf, ULONG cbBuf); - typedef DOSHQUERYDISKFSTYPE *PDOSHQUERYDISKFSTYPE; - - APIRET doshQueryDiskLabel(ULONG ulLogicalDrive, - PSZ pszVolumeLabel); - - APIRET doshSetDiskLabel(ULONG ulLogicalDrive, - PSZ pszNewLabel); - - /* ****************************************************************** - * - * Module handling helpers - * - ********************************************************************/ - - APIRET doshQueryProcAddr(PCSZ pcszModuleName, - ULONG ulOrdinal, - PFN *ppfn); - - /* - *@@ RESOLVEFUNCTION: - * one of these structures each define - * a single function import to doshResolveImports. - * - *@@added V0.9.3 (2000-04-25) [umoeller] - */ - - typedef struct _RESOLVEFUNCTION - { - const char *pcszFunctionName; - PFN *ppFuncAddress; - } RESOLVEFUNCTION, *PRESOLVEFUNCTION; - - typedef const struct _RESOLVEFUNCTION *PCRESOLVEFUNCTION; - - APIRET doshResolveImports(PCSZ pcszModuleName, - HMODULE *phmod, - PCRESOLVEFUNCTION paResolves, - ULONG cResolves); - - /* ****************************************************************** - * - * Performance Counters (CPU Load) - * - ********************************************************************/ - - #define CMD_PERF_INFO 0x41 - #define CMD_KI_ENABLE 0x60 - #define CMD_KI_DISABLE 0x61 - #ifndef CMD_KI_RDCNT - #define CMD_KI_RDCNT 0x63 - typedef APIRET APIENTRY FNDOSPERFSYSCALL(ULONG ulCommand, - ULONG ulParm1, - ULONG ulParm2, - ULONG ulParm3); - typedef FNDOSPERFSYSCALL *PFNDOSPERFSYSCALL; - #endif - - typedef struct _CPUUTIL - { - ULONG ulTimeLow; // low 32 bits of time stamp - ULONG ulTimeHigh; // high 32 bits of time stamp - ULONG ulIdleLow; // low 32 bits of idle time - ULONG ulIdleHigh; // high 32 bits of idle time - ULONG ulBusyLow; // low 32 bits of busy time - ULONG ulBusyHigh; // high 32 bits of busy time - ULONG ulIntrLow; // low 32 bits of interrupt time - ULONG ulIntrHigh; // high 32 bits of interrupt time - } CPUUTIL, *PCPUUTIL; - - // macro to convert 8-byte (low, high) time value to double - #define LL2F(high, low) (4294967296.0*(high)+(low)) - - /* - *@@ DOSHPERFSYS: - * structure used with doshPerfOpen. - * - *@@added V0.9.7 (2000-12-02) [umoeller] - *@@changed V0.9.9 (2001-03-14) [umoeller]: added interrupt load - */ - - typedef struct _DOSHPERFSYS - { - // output: no. of processors on the system - ULONG cProcessors; - // output: one CPU load for each CPU - PLONG palLoads; - - // output: one CPU interrupt load for each CPU - PLONG palIntrs; - - // each of the following ptrs points to an array of cProcessors items - PCPUUTIL paCPUUtils; // CPUUTIL structures - double *padBusyPrev; // previous "busy" calculations - double *padTimePrev; // previous "time" calculations - double *padIntrPrev; // previous "intr" calculations - - // private stuff - HMODULE hmod; - BOOL fInitialized; - PFNDOSPERFSYSCALL pDosPerfSysCall; - } DOSHPERFSYS, *PDOSHPERFSYS; - - APIRET doshPerfOpen(PDOSHPERFSYS *ppPerfSys); - - APIRET doshPerfGet(PDOSHPERFSYS pPerfSys); - - APIRET doshPerfClose(PDOSHPERFSYS *ppPerfSys); - - /* ****************************************************************** - * - * File name parsing - * - ********************************************************************/ - - APIRET doshGetDriveSpec(PCSZ pcszFullFile, - PSZ pszDrive, - PULONG pulDriveLen, - PBOOL pfIsUNC); - - PSZ doshGetExtension(PCSZ pcszFilename); - - /* ****************************************************************** - * - * File helpers - * - ********************************************************************/ - - BOOL doshIsFileOnFAT(const char* pcszFileName); - - APIRET doshIsValidFileName(const char* pcszFile, - BOOL fFullyQualified); - - BOOL doshMakeRealName(PSZ pszTarget, PSZ pszSource, CHAR cReplace, BOOL fIsFAT); - - APIRET doshQueryFileSize(HFILE hFile, - PULONG pulSize); - - APIRET doshQueryPathSize(PCSZ pcszFile, - PULONG pulSize); - - APIRET doshQueryPathAttr(const char* pcszFile, - PULONG pulAttr); - - APIRET doshSetPathAttr(const char* pcszFile, - ULONG ulAttr); - - /* ****************************************************************** - * - * XFILEs - * - ********************************************************************/ - - /* - *@@ XFILE: - * - *@@added V0.9.16 (2001-10-19) [umoeller] - */ - - typedef struct _XFILE - { - HFILE hf; - - PSZ pszFilename; // as given to doshOpen - ULONG flOpenMode; // as given to doshOpen - - ULONG cbInitial, // intial file size on open (can be 0 if new) - cbCurrent; // current file size (raised with each write) - - PBYTE pbCache; // if != NULL, cached data from doshReadAt - ULONG cbCache, // size of data in cbCache - ulReadFrom; // file offset where pbCache was read from - } XFILE, *PXFILE; - - #define XOPEN_READ_EXISTING 0x0001 - #define XOPEN_READWRITE_EXISTING 0x0002 - #define XOPEN_READWRITE_APPEND 0x0003 - #define XOPEN_READWRITE_NEW 0x0004 - #define XOPEN_ACCESS_MASK 0xffff - - #define XOPEN_BINARY 0x10000000 - - APIRET doshOpen(PCSZ pcszFilename, - ULONG flOpenMode, - PULONG pcbFile, - PXFILE *ppFile); - - #define DRFL_NOCACHE 0x0001 - #define DRFL_FAILIFLESS 0x0002 - - APIRET doshReadAt(PXFILE pFile, - ULONG ulOffset, - PULONG pcb, - PBYTE pbData, - ULONG fl); - - APIRET doshWrite(PXFILE pFile, - ULONG cb, - PCSZ pbData); - - APIRET doshWriteAt(PXFILE pFile, - ULONG ulOffset, - ULONG cb, - PCSZ pbData); - - APIRET doshWriteLogEntry(PXFILE pFile, - const char* pcszFormat, - ...); - - APIRET doshClose(PXFILE *ppFile); - - APIRET doshReadText(PXFILE pFile, - PSZ* ppszContent, - PULONG pcbRead); - - APIRET doshLoadTextFile(PCSZ pcszFile, - PSZ* ppszContent, - PULONG pcbRead); - - PSZ doshCreateBackupFileName(const char* pszExisting); - - APIRET doshCreateTempFileName(PSZ pszTempFileName, - PCSZ pcszDir, - PCSZ pcszPrefix, - PCSZ pcszExt); - - APIRET doshWriteTextFile(const char* pszFile, - const char* pszContent, - PULONG pulWritten, - PSZ pszBackup); - - - /* ****************************************************************** - * - * Directory helpers - * - ********************************************************************/ - - BOOL doshQueryDirExist(PCSZ pcszDir); - - APIRET doshCreatePath(PCSZ pcszPath, - BOOL fHidden); - - APIRET doshQueryCurrentDir(PSZ pszBuf); - - APIRET doshSetCurrentDir(PCSZ pcszDir); - - #define DOSHDELDIR_RECURSE 0x0001 - #define DOSHDELDIR_DELETEFILES 0x0002 - - APIRET doshDeleteDir(PCSZ pcszDir, - ULONG flFlags, - PULONG pulDirs, - PULONG pulFiles); - - APIRET doshCanonicalize(PCSZ pcszFileIn, - PSZ pszFileOut, - ULONG cbFileOut); - - /* ****************************************************************** - * - * Process helpers - * - ********************************************************************/ - - ULONG XWPENTRY doshMyPID(VOID); - typedef ULONG XWPENTRY DOSHMYPID(VOID); - typedef DOSHMYPID *PDOSHMYPID; - - ULONG XWPENTRY doshMyTID(VOID); - typedef ULONG XWPENTRY DOSHMYTID(VOID); - typedef DOSHMYTID *PDOSHMYTID; - - APIRET doshExecVIO(PCSZ pcszExecWithArgs, - PLONG plExitCode); - - APIRET doshQuickStartSession(PCSZ pcszPath, - PCSZ pcszParams, - BOOL fForeground, - USHORT usPgmCtl, - BOOL fWait, - PULONG pulSID, - PPID ppid, - PUSHORT pusReturn); - - APIRET doshSearchPath(PCSZ pcszPath, - PCSZ pcszFile, - PSZ pszExecutable, - ULONG cbExecutable); - - APIRET doshFindExecutable(PCSZ pcszCommand, - PSZ pszExecutable, - ULONG cbExecutable, - PCSZ *papcszExtensions, - ULONG cExtensions); - - /******************************************************************** - * - * Partition functions - * - ********************************************************************/ - - /* - *@@ LVMINFO: - * informational structure created by - * doshQueryLVMInfo. - * - *@@added V0.9.9 (2001-04-07) [umoeller] - */ - - typedef struct _LVMINFO - { - HMODULE hmodLVM; - - } LVMINFO, *PLVMINFO; - - /* #define DOSH_PARTITIONS_LIMIT 10 - - #define PAR_UNUSED 0x00 // Unused - #define PAR_FAT12SMALL 0x01 // DOS FAT 12-bit < 10 Mb - #define PAR_XENIXROOT 0x02 // XENIX root - #define PAR_XENIXUSER 0x03 // XENIX user - #define PAR_FAT16SMALL 0x04 // DOS FAT 16-bit < 32 Mb - #define PAR_EXTENDED 0x05 // Extended partition - #define PAR_FAT16BIG 0x06 // DOS FAT 16-bit > 32 Mb - #define PAR_HPFS 0x07 // OS/2 HPFS - #define PAR_AIXBOOT 0x08 // AIX bootable partition - #define PAR_AIXDATA 0x09 // AIX bootable partition - #define PAR_BOOTMANAGER 0x0A // OS/2 Boot Manager - #define PAR_WINDOWS95 0x0B // Windows 95 32-bit FAT - #define PAR_WINDOWS95LB 0x0C // Windows 95 32-bit FAT with LBA - #define PAR_VFAT16BIG 0x0E // LBA VFAT (same as 06h but using LBA-mode) - #define PAR_VFAT16EXT 0x0F // LBA VFAT (same as 05h but using LBA-mode) - #define PAR_OPUS 0x10 // OPUS - #define PAR_HID12SMALL 0x11 // OS/2 hidden DOS FAT 12-bit - #define PAR_COMPAQDIAG 0x12 // Compaq diagnostic - #define PAR_HID16SMALL 0x14 // OS/2 hidden DOS FAT 16-bit - #define PAR_HID16BIG 0x16 // OS/2 hidden DOS FAT 16-bit - #define PAR_HIDHPFS 0x17 // OS/2 hidden HPFS - #define PAR_WINDOWSSWP 0x18 // AST Windows Swap File - #define PAR_NECDOS 0x24 // NEC MS-DOS 3.x - #define PAR_THEOS 0x38 // THEOS - #define PAR_VENIX 0x40 // VENIX - #define PAR_RISCBOOT 0x41 // Personal RISC boot - #define PAR_SFS 0x42 // SFS - #define PAR_ONTRACK 0x50 // Ontrack - #define PAR_ONTRACKEXT 0x51 // Ontrack extended partition - #define PAR_CPM 0x52 // CP/M - #define PAR_UNIXSYSV 0x63 // UNIX SysV/386 - #define PAR_NOVELL_64 0x64 // Novell - #define PAR_NOVELL_65 0x65 // Novell - #define PAR_NOVELL_67 0x67 // Novell - #define PAR_NOVELL_68 0x68 // Novell - #define PAR_NOVELL_69 0x69 // Novell - #define PAR_PCIX 0x75 // PCIX - #define PAR_MINIX 0x80 // MINIX - #define PAR_LINUX 0x81 // Linux - #define PAR_LINUXSWAP 0x82 // Linux Swap Partition - #define PAR_LINUXFILE 0x83 // Linux File System - #define PAR_FREEBSD 0xA5 // FreeBSD - #define PAR_BBT 0xFF // BBT - */ - - // one-byte alignment - #pragma pack(1) - - /* - *@@ PAR_INFO: - * partition table - */ - - typedef struct _PAR_INFO - { - BYTE bBootFlag; // 0=not active, 80H = active (boot this partition - BYTE bBeginHead; // partition begins at this head... - USHORT rBeginSecCyl; // ...and this sector and cylinder (see below) - BYTE bFileSysCode; // file system type - BYTE bEndHead; // partition ends at this head... - USHORT bEndSecCyl; // ...and this sector and cylinder (see below) - ULONG lBeginAbsSec; // partition begins at this absolute sector # - ULONG lTotalSects; // total sectors in this partition - } PAR_INFO, *PPAR_INFO; - - /* - *@@ MBR_INFO: - * master boot record table. - * This has the four primary partitions. - */ - - typedef struct _MBR_INFO // MBR - { - BYTE aBootCode[0x1BE]; // abBootCode master boot executable code - PAR_INFO sPrtnInfo[4]; // primary partition entries - USHORT wPrtnTblSig; // partition table signature (aa55H) - } MBR_INFO, *PMBR_INFO; - - /* - *@@ SYS_INFO: - * - */ - - typedef struct _SYS_INFO - { - BYTE startable; - BYTE unknown[3]; - BYTE bootable; - BYTE name[8]; - BYTE reservd[3]; - } SYS_INFO, *PSYS_INFO; - - /* - *@@ SYE_INFO: - * - */ - - typedef struct _SYE_INFO - { - BYTE bootable; - BYTE name[8]; - } SYE_INFO, *PSYE_INFO; - - /* - *@@ EXT_INFO: - * - */ - - typedef struct _EXT_INFO - { - BYTE aBootCode[0x18A]; // abBootCode master boot executable code - SYE_INFO sBmNames[4]; // System Names - BYTE bReserved[16]; // reserved - PAR_INFO sPrtnInfo[4]; // partitioms entrys - USHORT wPrtnTblSig; // partition table signature (aa55H) - } EXT_INFO, *PEXT_INFO; - - typedef struct _PARTITIONINFO *PPARTITIONINFO; - - /* - *@@ PARTITIONINFO: - * informational structure returned - * by doshGetPartitionsList. One of - * these items is created for each - * bootable partition. - */ - - typedef struct _PARTITIONINFO - { - BYTE bDisk; // drive number - CHAR cLetter; // probable drive letter or ' ' if none - BYTE bFSType; // file system type - PCSZ pcszFSType; // file system name (as returned by - // doshType2FSName, can be NULL!) - BOOL fPrimary; // primary partition? - BOOL fBootable; // bootable by Boot Manager? - CHAR szBootName[21]; // Boot Manager name, if (fBootable) - // extended for LVM names V0.9.20 (2002-08-10) [umoeller] - ULONG ulSize; // size MBytes - PPARTITIONINFO pNext; // next info or NULL if last - } PARTITIONINFO; - - UINT doshQueryDiskCount(VOID); - - APIRET doshReadSector(USHORT disk, - void *buff, - USHORT head, - USHORT cylinder, - USHORT sector); - - // restore original alignment - #pragma pack() - - const char* doshType2FSName(unsigned char bFSType); - - APIRET doshGetBootManager(USHORT *pusDisk, - USHORT *pusPart, - PAR_INFO *BmInfo); - - typedef struct _PARTITIONSLIST - { - PLVMINFO pLVMInfo; // != NULL if LVM is installed - - // partitions array - PPARTITIONINFO pPartitionInfo; - USHORT cPartitions; - } PARTITIONSLIST, *PPARTITIONSLIST; - - APIRET doshGetPartitionsList(PPARTITIONSLIST *ppList, - PUSHORT pusContext); - - APIRET doshFreePartitionsList(PPARTITIONSLIST ppList); - - APIRET doshQueryLVMInfo(PLVMINFO *ppLVMInfo); - - APIRET doshReadLVMPartitions(PLVMINFO pInfo, - PPARTITIONINFO *ppPartitionInfo, - PUSHORT pcPartitions); - - VOID doshFreeLVMInfo(PLVMINFO pInfo); - - /* ****************************************************************** - * - * Wildcard matching - * - ********************************************************************/ - - BOOL doshMatchCase(PCSZ pcszMask, - PCSZ pcszName); - - BOOL doshMatchCaseNoPath(const char *pcszMask, - const char *pcszName); - - BOOL doshMatch(PCSZ pcszMask, - PCSZ pcszName); - #endif #if __cplusplus } #endif - diff --git a/sal/osl/os2/helpers/except.h b/sal/osl/os2/helpers/except.h index 6a898ba84c99..b2d6b17ca702 100644 --- a/sal/osl/os2/helpers/except.h +++ b/sal/osl/os2/helpers/except.h @@ -1,3 +1,32 @@ +/************************************************************************* + * + * 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:$ + * $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. + * + ************************************************************************/ /* *@@sourcefile except.h: @@ -15,15 +44,10 @@ */ /* - * Copyright (C) 1999-2000 Ulrich Mller. - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, in version 2 as it comes in the COPYING - * file of the XFolder main distribution. - * This program 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 General Public License for more details. + * Copyright (C) 1999-2000 Ulrich M�ller. + * + * 2009-06-15 published under LGPL3 with Ulrich M�ller permission. + * */ #if __cplusplus diff --git a/sal/osl/os2/helpers/setup.h b/sal/osl/os2/helpers/setup.h index 015d93019f21..6c02d8b655fb 100644 --- a/sal/osl/os2/helpers/setup.h +++ b/sal/osl/os2/helpers/setup.h @@ -1,3 +1,35 @@ +/************************************************************************* + * + * 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:$ + * $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. + * + * 2009-06-15 published under LGPL3 with Ulrich M�ller permission. + * + * + ************************************************************************/ /* * setup.h: diff --git a/sal/osl/os2/module.c b/sal/osl/os2/module.c index c8c9731a95ed..901c029429c4 100644 --- a/sal/osl/os2/module.c +++ b/sal/osl/os2/module.c @@ -109,7 +109,7 @@ oslModule SAL_CALL osl_loadModule(rtl_uString *ustrModuleName, sal_Int32 nRtldMo pModule = (oslModule)hModule; else { - sal_Char szError[ 120 ]; + sal_Char szError[ PATH_MAX*2 ]; sprintf( szError, "Module: %s; rc: %d;\nReason: %s;\n" "Please contact technical support and report above informations.\n\n", buffer, rc, szErrorMessage ); diff --git a/sal/osl/os2/process.c b/sal/osl/os2/process.c index 793be57950b6..a3408ddbf7d0 100644 --- a/sal/osl/os2/process.c +++ b/sal/osl/os2/process.c @@ -551,7 +551,8 @@ oslProcessError SAL_CALL osl_psz_executeProcess(sal_Char *pszImageName, { for (i = first; pszArguments[i] != NULL; i++) n += strlen(pszArguments[i]) + 1; - args = (sal_Char*)malloc(n); + // YD DosStartSession requires low-mem buffers! + args = (sal_Char*)_tmalloc(n); *args = '\0'; for (i = first; pszArguments[i] != NULL; i++) { @@ -567,7 +568,8 @@ oslProcessError SAL_CALL osl_psz_executeProcess(sal_Char *pszImageName, { for (i = 0; pszEnvironments[i] != NULL; i++) n += strlen(pszEnvironments[i]) + 1; - envs = (sal_Char*)malloc(n + 1); + // YD DosStartSession requires low-mem buffers! + envs = (sal_Char*)_tmalloc(n + 1); pStr = (sal_Char*)envs; for (i = 0; pszEnvironments[i] != NULL; i++) { @@ -660,9 +662,9 @@ oslProcessError SAL_CALL osl_psz_executeProcess(sal_Char *pszImageName, if(envs) - free(envs); + _tfree(envs); if(args) - free(args); + _tfree(args); if( rc != NO_ERROR ) return osl_Process_E_Unknown; diff --git a/sal/osl/os2/util.c b/sal/osl/os2/util.c index 4dd08c00aed3..217c71878838 100644 --- a/sal/osl/os2/util.c +++ b/sal/osl/os2/util.c @@ -32,11 +32,6 @@ -extern sal_Bool osl_getEtherAddr(sal_Char* pszAddr, sal_uInt16 BufferSize) -{ - return sal_False; -} - extern sal_Bool osl_getEthernetAddress( sal_uInt8 * pTargetAddress ) { return sal_False; diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx index 9296cb1ef966..e02485cdf4ce 100644 --- a/sal/osl/unx/file.cxx +++ b/sal/osl/unx/file.cxx @@ -31,1142 +31,996 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sal.hxx" - -/************************************************************************ - * ToDo - * - * Fix osl_getCanonicalName - * - * - Fix: check for corresponding struct sizes in exported functions - * - check size/use of oslDirectory - * - check size/use of oslDirectoryItem - * - check size/use of oslFileStatus - * - check size/use of oslVolumeDeviceHandle - * - check size/use of oslVolumeInfo - * - check size/use of oslFileHandle - ***********************************************************************/ - -#include <algorithm> -#include <limits> -#include "system.h" -#include <rtl/alloc.h> - #include "osl/file.hxx" +#include "osl/diagnose.h" +#include "rtl/alloc.h" -#include <sal/types.h> -#include <osl/thread.h> -#include <osl/diagnose.h> +#include "system.h" #include "file_error_transl.h" -#include <osl/time.h> - -#ifndef _FILE_URL_H_ #include "file_url.h" -#endif - -#include "file_path_helper.hxx" -#include "uunxapi.hxx" - -#include <sys/mman.h> - -#ifdef HAVE_STATFS_H -#undef HAVE_STATFS_H -#endif +#include <algorithm> +#include <limits> -#ifndef _STRING_H #include <string.h> -#endif - -#if defined(SOLARIS) -#include <sys/mnttab.h> -#include <sys/statvfs.h> -#define HAVE_STATFS_H -#include <sys/fs/ufs_quota.h> -static const sal_Char* MOUNTTAB="/etc/mnttab"; - -#elif defined(LINUX) -#include <mntent.h> -#include <sys/vfs.h> -#define HAVE_STATFS_H -#include <sys/quota.h> -#include <ctype.h> -static const sal_Char* MOUNTTAB="/etc/mtab"; - -#elif defined(NETBSD) || defined(FREEBSD) -#include <sys/param.h> -#include <sys/ucred.h> -#include <sys/mount.h> -#include <ufs/ufs/quota.h> -#include <ctype.h> -#define HAVE_STATFS_H -/* No mounting table on *BSD - * This information is stored only in the kernel. */ -/* static const sal_Char* MOUNTTAB="/etc/mtab"; */ - -#elif defined(IRIX) -#include <mntent.h> -#include <sys/mount.h> -#include <sys/statvfs.h> -#define HAVE_STATFS_H -#include <sys/quota.h> -#include <ctype.h> -static const sal_Char* MOUNTTAB="/etc/mtab"; +#include <pthread.h> +#include <sys/mman.h> -#elif defined(MACOSX) -#include <ufs/ufs/quota.h> -#include <ctype.h> -// static const sal_Char* MOUNTTAB="/etc/mtab"; +#if defined(MACOSX) #include <sys/param.h> #include <sys/mount.h> -#define HAVE_STATFS_H #define HAVE_O_EXLOCK // add MACOSX Time Value - #define TimeValue CFTimeValue #include <CoreFoundation/CoreFoundation.h> #undef TimeValue -#endif - -#if OSL_DEBUG_LEVEL > 1 - - extern void debug_ustring(rtl_uString*); - -#endif - +#endif /* MACOSX */ #ifdef DEBUG_OSL_FILE +# define OSL_FILE_TRACE 0 ? (void)(0) : osl_trace # define PERROR( a, b ) perror( a ); fprintf( stderr, b ) #else +# define OSL_FILE_TRACE 1 ? (void)(0) : osl_trace # define PERROR( a, b ) #endif -extern "C" oslFileHandle osl_createFileHandleFromFD( int fd ); - -/****************************************************************************** +/******************************************************************* * - * Data Type Definition + * FileHandle_Impl interface * - ******************************************************************************/ - -#if 0 -/* FIXME: reintroducing this may save some extra bytes per Item */ -typedef struct + ******************************************************************/ +struct FileHandle_Impl { - rtl_uString* ustrFileName; /* holds native file name */ - rtl_uString* ustrDirPath; /* holds native dir path */ - sal_uInt32 RefCount; -} oslDirectoryItemImpl; -#endif + pthread_mutex_t m_mutex; + rtl_String * m_strFilePath; /* holds native file path */ + int m_fd; -typedef struct -{ - rtl_uString* ustrPath; /* holds native directory path */ - DIR* pDirStruct; -} oslDirectoryImpl; + /** State + */ + enum StateBits + { + STATE_SEEKABLE = 1, /* default */ + STATE_READABLE = 2, /* default */ + STATE_WRITEABLE = 4, /* open() sets, write() requires, else osl_File_E_BADF */ + STATE_MODIFIED = 8 /* write() sets, flush() resets */ + }; + int m_state; + sal_uInt64 m_size; /* file size */ + off_t m_offset; /* physical offset from begin of file */ + off_t m_fileptr; /* logical offset from begin of file */ -typedef struct -{ - rtl_uString* ustrFilePath; /* holds native file path */ - int fd; - sal_Bool bLocked; -} oslFileHandleImpl; + off_t m_bufptr; /* buffer offset from begin of file */ + size_t m_buflen; /* buffer filled [0, m_bufsiz - 1] */ + size_t m_bufsiz; + sal_uInt8 * m_buffer; -typedef struct _oslVolumeDeviceHandleImpl -{ - sal_Char pszMountPoint[PATH_MAX]; - sal_Char pszFilePath[PATH_MAX]; - sal_Char pszDevice[PATH_MAX]; - sal_Char ident[4]; - sal_uInt32 RefCount; -} oslVolumeDeviceHandleImpl; + explicit FileHandle_Impl (int fd, char const * path = "<anon>"); + ~FileHandle_Impl(); + static void* operator new (size_t n); + static void operator delete (void * p, size_t); -/****************************************************************************** - * - * static members - * - *****************************************************************************/ + static size_t getpagesize(); -static const char * pFileLockEnvVar = (char *) -1; + sal_uInt64 getPos() const; + oslFileError setPos (sal_uInt64 uPos); + sal_uInt64 getSize() const; + oslFileError setSize (sal_uInt64 uSize); -/****************************************************************************** - * - * C-String Function Declarations - * - *****************************************************************************/ + oslFileError readAt ( + off_t nOffset, + void * pBuffer, + size_t nBytesRequested, + sal_uInt64 * pBytesRead); -static oslFileError osl_psz_getVolumeInformation(const sal_Char* , oslVolumeInfo* pInfo, sal_uInt32 uFieldMask); -static oslFileError osl_psz_removeFile(const sal_Char* pszPath); -static oslFileError osl_psz_createDirectory(const sal_Char* pszPath); -static oslFileError osl_psz_removeDirectory(const sal_Char* pszPath); -static oslFileError osl_psz_copyFile(const sal_Char* pszPath, const sal_Char* pszDestPath); -static oslFileError osl_psz_moveFile(const sal_Char* pszPath, const sal_Char* pszDestPath); -static oslFileError osl_psz_setFileAttributes(const sal_Char* pszFilePath, sal_uInt64 uAttributes); -static oslFileError osl_psz_setFileTime(const sal_Char* strFilePath, const TimeValue* pCreationTime, const TimeValue* pLastAccessTime, const TimeValue* pLastWriteTime); + oslFileError writeAt ( + off_t nOffset, + void const * pBuffer, + size_t nBytesToWrite, + sal_uInt64 * pBytesWritten); + oslFileError readFileAt ( + off_t nOffset, + void * pBuffer, + size_t nBytesRequested, + sal_uInt64 * pBytesRead); -/****************************************************************************** - * - * Static Module Utility Function Declarations - * - *****************************************************************************/ + oslFileError writeFileAt ( + off_t nOffset, + void const * pBuffer, + size_t nBytesToWrite, + sal_uInt64 * pBytesWritten); -static oslFileError oslDoCopy(const sal_Char* pszSourceFileName, const sal_Char* pszDestFileName, mode_t nMode, size_t nSourceSize, int DestFileExists); -static oslFileError oslChangeFileModes(const sal_Char* pszFileName, mode_t nMode, time_t nAcTime, time_t nModTime, uid_t nUID, gid_t nGID); -static int oslDoCopyLink(const sal_Char* pszSourceFileName, const sal_Char* pszDestFileName); -static int oslDoCopyFile(const sal_Char* pszSourceFileName, const sal_Char* pszDestFileName, size_t nSourceSize, mode_t mode); -static oslFileError oslDoMoveFile(const sal_Char* pszPath, const sal_Char* pszDestPath); -static rtl_uString* oslMakeUStrFromPsz(const sal_Char* pszStr,rtl_uString** uStr); + oslFileError readLineAt ( + off_t nOffset, + sal_Sequence ** ppSequence, + sal_uInt64 * pBytesRead); -/****************************************************************************** - * - * Non-Static Utility Function Declarations - * - *****************************************************************************/ + oslFileError writeSequence_Impl ( + sal_Sequence ** ppSequence, + size_t * pnOffset, + const void * pBuffer, + size_t nBytes); -extern "C" int UnicodeToText( char *, size_t, const sal_Unicode *, sal_Int32 ); -extern "C" int TextToUnicode( - const char* text, size_t text_buffer_size, sal_Unicode* unic_text, sal_Int32 unic_text_buffer_size); + oslFileError syncFile(); -/****************************************************************************** - * - * 'removeable device' aka floppy functions - * - *****************************************************************************/ + /** Buffer cache / allocator. + */ + class Allocator + { + rtl_cache_type * m_cache; + size_t m_bufsiz; -static oslVolumeDeviceHandle osl_isFloppyDrive(const sal_Char* pszPath); -static oslFileError osl_mountFloppy(oslVolumeDeviceHandle hFloppy); -static oslFileError osl_unmountFloppy(oslVolumeDeviceHandle hFloppy); + Allocator (Allocator const &); + Allocator & operator= (Allocator const &); + public: + static Allocator & get(); -#if defined(SOLARIS) -static sal_Bool osl_isFloppyMounted(sal_Char* pszPath, sal_Char* pszMountPath); -static sal_Bool osl_getFloppyMountEntry(const sal_Char* pszPath, sal_Char* pBuffer); -static sal_Bool osl_checkFloppyPath(sal_Char* pszPath, sal_Char* pszFilePath, sal_Char* pszDevicePath); -#endif + void allocate (sal_uInt8 ** ppBuffer, size_t * pnSize); + void deallocate (sal_uInt8 * pBuffer); -#if defined(LINUX) -static sal_Bool osl_isFloppyMounted(oslVolumeDeviceHandleImpl* pDevice); -static sal_Bool osl_getFloppyMountEntry(const sal_Char* pszPath, oslVolumeDeviceHandleImpl* pItem); -#endif - - -#if defined(IRIX) -static sal_Bool osl_isFloppyMounted(oslVolumeDeviceHandleImpl* pDevice); -static sal_Bool osl_getFloppyMountEntry(const sal_Char* pszPath, oslVolumeDeviceHandleImpl* pItem); -#endif + protected: + Allocator(); + ~Allocator(); + }; -#ifdef DEBUG_OSL_FILE -static void osl_printFloppyHandle(oslVolumeDeviceHandleImpl* hFloppy); -#endif + /** Guard. + */ + class Guard + { + pthread_mutex_t * m_mutex; -#ifdef MACOSX + public: + explicit Guard(pthread_mutex_t * pMutex); + ~Guard(); + }; +}; /******************************************************************* - * adjustLockFlags + * + * FileHandle_Impl implementation + * ******************************************************************/ -/* The AFP implementation of MacOS X 10.4 treats O_EXLOCK in a way - * that makes it impossible for OOo to create a backup copy of the - * file it keeps opened. OTOH O_SHLOCK for AFP behaves as desired by - * the OOo file handling, so we need to check the path of the file - * for the filesystem name. - */ - -static int adjustLockFlags(const char * path, int flags) +FileHandle_Impl::Allocator & +FileHandle_Impl::Allocator::get() { - struct statfs s; + static Allocator g_aBufferAllocator; + return g_aBufferAllocator; +} - if( 0 <= statfs( path, &s ) ) +FileHandle_Impl::Allocator::Allocator() + : m_cache (0), + m_bufsiz (0) +{ + size_t const pagesize = FileHandle_Impl::getpagesize(); + if (size_t(-1) != pagesize) { - if( 0 == strncmp("afpfs", s.f_fstypename, 5) ) - { - flags &= ~O_EXLOCK; - flags |= O_SHLOCK; - } - else
- {
- /* Needed flags to allow opening a webdav file */
- flags &= ~( O_EXLOCK | O_SHLOCK );
- }
+ m_cache = rtl_cache_create ( + "osl_file_buffer_cache", pagesize, 0, 0, 0, 0, 0, 0, 0); + if (0 != m_cache) + m_bufsiz = pagesize; } - - return flags; +} +FileHandle_Impl::Allocator::~Allocator() +{ + rtl_cache_destroy (m_cache), m_cache = 0; } -#endif - - -/******************************************************************* - * osl_openDirectory - ******************************************************************/ +void FileHandle_Impl::Allocator::allocate (sal_uInt8 ** ppBuffer, size_t * pnSize) +{ + OSL_PRECOND((0 != ppBuffer) && (0 != pnSize), "FileHandle_Impl::Allocator::allocate(): contract violation"); + *ppBuffer = static_cast< sal_uInt8* >(rtl_cache_alloc(m_cache)), *pnSize = m_bufsiz; +} +void FileHandle_Impl::Allocator::deallocate (sal_uInt8 * pBuffer) +{ + if (0 != pBuffer) + rtl_cache_free (m_cache, pBuffer); +} -oslFileError SAL_CALL osl_openDirectory(rtl_uString* ustrDirectoryURL, oslDirectory* pDirectory) +FileHandle_Impl::Guard::Guard(pthread_mutex_t * pMutex) + : m_mutex (pMutex) { - rtl_uString* ustrSystemPath = NULL; - oslFileError eRet; + OSL_PRECOND (m_mutex != 0, "FileHandle_Impl::Guard::Guard(): null pointer."); + (void) pthread_mutex_lock (m_mutex); // ignoring EINVAL ... +} +FileHandle_Impl::Guard::~Guard() +{ + OSL_PRECOND (m_mutex != 0, "FileHandle_Impl::Guard::~Guard(): null pointer."); + (void) pthread_mutex_unlock (m_mutex); +} - char path[PATH_MAX]; +FileHandle_Impl::FileHandle_Impl (int fd, char const * path) + : m_strFilePath (0), + m_fd (fd), + m_state (STATE_SEEKABLE | STATE_READABLE), + m_size (0), + m_offset (0), + m_fileptr (0), + m_bufptr (-1), + m_buflen (0), + m_bufsiz (0), + m_buffer (0) +{ + (void) pthread_mutex_init(&m_mutex, 0); + rtl_string_newFromStr (&m_strFilePath, path); + Allocator::get().allocate (&m_buffer, &m_bufsiz); + if (0 != m_buffer) + memset (m_buffer, 0, m_bufsiz); +} +FileHandle_Impl::~FileHandle_Impl() +{ + Allocator::get().deallocate (m_buffer), m_buffer = 0; + rtl_string_release (m_strFilePath), m_strFilePath = 0; + (void) pthread_mutex_destroy(&m_mutex); // ignoring EBUSY ... +} - OSL_ASSERT(ustrDirectoryURL && (ustrDirectoryURL->length > 0)); - OSL_ASSERT(pDirectory); +void* FileHandle_Impl::operator new (size_t n) +{ + return rtl_allocateMemory(n); +} +void FileHandle_Impl::operator delete (void * p, size_t) +{ + rtl_freeMemory(p); +} - if (0 == ustrDirectoryURL->length ) - return osl_File_E_INVAL; +size_t FileHandle_Impl::getpagesize() +{ +#if defined(FREEBSD) || defined(NETBSD) || defined(MACOSX) + return sal::static_int_cast< size_t >(::getpagesize()); +#else /* POSIX */ + return sal::static_int_cast< size_t >(::sysconf(_SC_PAGESIZE)); +#endif /* xBSD || POSIX */ +} - /* convert file URL to system path */ - eRet = osl_getSystemPathFromFileURL_Ex(ustrDirectoryURL, &ustrSystemPath, sal_False); +sal_uInt64 FileHandle_Impl::getPos() const +{ + return sal::static_int_cast< sal_uInt64 >(m_fileptr); +} - if( osl_File_E_None != eRet ) - return eRet; +oslFileError FileHandle_Impl::setPos (sal_uInt64 uPos) +{ + OSL_FILE_TRACE("FileHandle_Impl::setPos(%d, %lld) => %lld", m_fd, getPos(), uPos); + m_fileptr = sal::static_int_cast< off_t >(uPos); + return osl_File_E_None; +} - osl_systemPathRemoveSeparator(ustrSystemPath); +sal_uInt64 FileHandle_Impl::getSize() const +{ + off_t const bufend = std::max((off_t)(0), m_bufptr) + m_buflen; + return std::max(m_size, sal::static_int_cast< sal_uInt64 >(bufend)); +} - /* convert unicode path to text */ - if ( UnicodeToText( path, PATH_MAX, ustrSystemPath->buffer, ustrSystemPath->length ) -#ifdef MACOSX - && macxp_resolveAlias( path, PATH_MAX ) == 0 -#endif /* MACOSX */ - ) +oslFileError FileHandle_Impl::setSize (sal_uInt64 uSize) +{ + off_t const nSize = sal::static_int_cast< off_t >(uSize); + if (-1 == ftruncate (m_fd, nSize)) { - /* open directory */ - DIR *pdir = opendir( path ); + /* Failure. Save original result. Try fallback algorithm */ + oslFileError result = oslTranslateFileError (OSL_FET_ERROR, errno); - if( pdir ) + /* Check against current size. Fail upon 'shrink' */ + if (uSize <= getSize()) { - /* create and initialize impl structure */ - oslDirectoryImpl* pDirImpl = (oslDirectoryImpl*) rtl_allocateMemory( sizeof(oslDirectoryImpl) ); + /* Failure upon 'shrink'. Return original result */ + return (result); + } - if( pDirImpl ) - { - pDirImpl->pDirStruct = pdir; - pDirImpl->ustrPath = ustrSystemPath; + /* Save current position */ + off_t const nCurPos = (off_t)lseek (m_fd, (off_t)0, SEEK_CUR); + if (nCurPos == (off_t)(-1)) + return (result); - *pDirectory = (oslDirectory) pDirImpl; - return osl_File_E_None; - } - else - { - errno = ENOMEM; - closedir( pdir ); - } - } - else + /* Try 'expand' via 'lseek()' and 'write()' */ + if (-1 == lseek (m_fd, (off_t)(nSize - 1), SEEK_SET)) + return (result); + + if (-1 == write (m_fd, (char*)"", (size_t)1)) { - /* should be removed by optimizer in product version */ - PERROR( "osl_openDirectory", path ); + /* Failure. Restore saved position */ + (void) lseek (m_fd, (off_t)(nCurPos), SEEK_SET); + return (result); } - } - rtl_uString_release( ustrSystemPath ); + /* Success. Restore saved position */ + if (-1 == lseek (m_fd, (off_t)nCurPos, SEEK_SET)) + return (result); + } - return oslTranslateFileError(OSL_FET_ERROR, errno); + OSL_FILE_TRACE("osl_setFileSize(%d, %lld) => %ld", m_fd, getSize(), nSize); + m_size = sal::static_int_cast< sal_uInt64 >(nSize); + return osl_File_E_None; } -/****************************************************************************/ -/* osl_closeDirectory */ -/****************************************************************************/ - -oslFileError SAL_CALL osl_closeDirectory( oslDirectory Directory ) +oslFileError FileHandle_Impl::readAt ( + off_t nOffset, + void * pBuffer, + size_t nBytesRequested, + sal_uInt64 * pBytesRead) { - oslDirectoryImpl* pDirImpl = (oslDirectoryImpl*) Directory; - oslFileError err = osl_File_E_None; + OSL_PRECOND((m_state & STATE_SEEKABLE), "FileHandle_Impl::readAt(): not seekable"); + if (!(m_state & STATE_SEEKABLE)) + return osl_File_E_SPIPE; - OSL_ASSERT( Directory ); + OSL_PRECOND((m_state & STATE_READABLE), "FileHandle_Impl::readAt(): not readable"); + if (!(m_state & STATE_READABLE)) + return osl_File_E_BADF; - if( NULL == pDirImpl ) - return osl_File_E_INVAL; +#if defined(LINUX) || defined(SOLARIS) - /* close directory */ - if( closedir( pDirImpl->pDirStruct ) ) + ssize_t nBytes = ::pread (m_fd, pBuffer, nBytesRequested, nOffset); + if ((-1 == nBytes) && (EOVERFLOW == errno)) { - err = oslTranslateFileError(OSL_FET_ERROR, errno); + /* Some 'pread()'s fail with EOVERFLOW when reading at (or past) + * end-of-file, different from 'lseek() + read()' behaviour. + * Returning '0 bytes read' and 'osl_File_E_None' instead. + */ + nBytes = 0; } + if (-1 == nBytes) + return oslTranslateFileError (OSL_FET_ERROR, errno); - /* cleanup members */ - rtl_uString_release( pDirImpl->ustrPath ); - - rtl_freeMemory( pDirImpl ); - - return err; -} - -/********************************************** - * osl_readdir_impl_ - * - * readdir wrapper, filters out "." and ".." - * on request - *********************************************/ - -static struct dirent* osl_readdir_impl_(DIR* pdir, sal_Bool bFilterLocalAndParentDir) -{ - struct dirent* pdirent; +#else /* !(LINUX || SOLARIS) */ - while ((pdirent = readdir(pdir)) != NULL) + if (nOffset != m_offset) { - if (bFilterLocalAndParentDir && - ((0 == strcmp(pdirent->d_name, ".")) || (0 == strcmp(pdirent->d_name, "..")))) - continue; - else - break; + if (-1 == ::lseek (m_fd, nOffset, SEEK_SET)) + return oslTranslateFileError (OSL_FET_ERROR, errno); + m_offset = nOffset; } - return pdirent; -} - -/**************************************************************************** - * osl_getNextDirectoryItem - ***************************************************************************/ + ssize_t nBytes = ::read (m_fd, pBuffer, nBytesRequested); + if (-1 == nBytes) + return oslTranslateFileError (OSL_FET_ERROR, errno); + m_offset += nBytes; -oslFileError SAL_CALL osl_getNextDirectoryItem(oslDirectory Directory, oslDirectoryItem* pItem, sal_uInt32 /*uHint*/) -{ - oslDirectoryImpl* pDirImpl = (oslDirectoryImpl*)Directory; - rtl_uString* ustrFileName = NULL; - rtl_uString* ustrFilePath = NULL; - struct dirent* pEntry; +#endif /* !(LINUX || SOLARIS) */ - OSL_ASSERT(Directory); - OSL_ASSERT(pItem); + OSL_FILE_TRACE("FileHandle_Impl::readAt(%d, %lld, %ld)", m_fd, nOffset, nBytes); + *pBytesRead = nBytes; + return osl_File_E_None; +} - if ((NULL == Directory) || (NULL == pItem)) - return osl_File_E_INVAL; +oslFileError FileHandle_Impl::writeAt ( + off_t nOffset, + void const * pBuffer, + size_t nBytesToWrite, + sal_uInt64 * pBytesWritten) +{ + OSL_PRECOND((m_state & STATE_SEEKABLE), "FileHandle_Impl::writeAt(): not seekable"); + if (!(m_state & STATE_SEEKABLE)) + return osl_File_E_SPIPE; - pEntry = osl_readdir_impl_(pDirImpl->pDirStruct, sal_True); + OSL_PRECOND((m_state & STATE_WRITEABLE), "FileHandle_Impl::writeAt(): not writeable"); + if (!(m_state & STATE_WRITEABLE)) + return osl_File_E_BADF; - if (NULL == pEntry) - return osl_File_E_NOENT; +#if defined(LINUX) || defined(SOLARIS) + ssize_t nBytes = ::pwrite (m_fd, pBuffer, nBytesToWrite, nOffset); + if (-1 == nBytes) + return oslTranslateFileError (OSL_FET_ERROR, errno); -#if defined(MACOSX) +#else /* !(LINUX || SOLARIS) */ - // convert decomposed filename to precomposed unicode - char composed_name[BUFSIZ]; - CFMutableStringRef strRef = CFStringCreateMutable (NULL, 0 ); - CFStringAppendCString( strRef, pEntry->d_name, kCFStringEncodingUTF8 ); //UTF8 is default on Mac OSX - CFStringNormalize( strRef, kCFStringNormalizationFormC ); - CFStringGetCString( strRef, composed_name, BUFSIZ, kCFStringEncodingUTF8 ); - CFRelease( strRef ); - rtl_string2UString( &ustrFileName, composed_name, strlen( composed_name), - osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS ); - -#else // not MACOSX - /* convert file name to unicode */ - rtl_string2UString( &ustrFileName, pEntry->d_name, strlen( pEntry->d_name ), - osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS ); - OSL_ASSERT(ustrFileName != 0); + if (nOffset != m_offset) + { + if (-1 == ::lseek (m_fd, nOffset, SEEK_SET)) + return oslTranslateFileError (OSL_FET_ERROR, errno); + m_offset = nOffset; + } -#endif + ssize_t nBytes = ::write (m_fd, pBuffer, nBytesToWrite); + if (-1 == nBytes) + return oslTranslateFileError (OSL_FET_ERROR, errno); + m_offset += nBytes; - osl_systemPathMakeAbsolutePath(pDirImpl->ustrPath, ustrFileName, &ustrFilePath); - rtl_uString_release( ustrFileName ); +#endif /* !(LINUX || SOLARIS) */ - /* use path as directory item */ - *pItem = (oslDirectoryItem) ustrFilePath; + OSL_FILE_TRACE("FileHandle_Impl::writeAt(%d, %lld, %ld)", m_fd, nOffset, nBytes); + m_size = std::max (m_size, sal::static_int_cast< sal_uInt64 >(nOffset + nBytes)); + *pBytesWritten = nBytes; return osl_File_E_None; } -/****************************************************************************/ -/* osl_getDirectoryItem */ -/****************************************************************************/ - -oslFileError SAL_CALL osl_getDirectoryItem( rtl_uString* ustrFileURL, oslDirectoryItem* pItem ) +oslFileError FileHandle_Impl::readFileAt ( + off_t nOffset, + void * pBuffer, + size_t nBytesRequested, + sal_uInt64 * pBytesRead) { - rtl_uString* ustrSystemPath = NULL; - oslFileError osl_error = osl_File_E_INVAL; - - OSL_ASSERT(ustrFileURL); - OSL_ASSERT(pItem); - - if (0 == ustrFileURL->length || NULL == pItem) - return osl_File_E_INVAL; - - osl_error = osl_getSystemPathFromFileURL_Ex(ustrFileURL, &ustrSystemPath, sal_False); - - if (osl_File_E_None != osl_error) - return osl_error; - - osl_systemPathRemoveSeparator(ustrSystemPath); - - if (0 == access_u(ustrSystemPath, F_OK)) + if (0 == (m_state & STATE_SEEKABLE)) { - *pItem = (oslDirectoryItem)ustrSystemPath; - osl_error = osl_File_E_None; + // not seekable (pipe) + ssize_t nBytes = ::read (m_fd, pBuffer, nBytesRequested); + if (-1 == nBytes) + return oslTranslateFileError (OSL_FET_ERROR, errno); + *pBytesRead = nBytes; + return osl_File_E_None; } - else + else if (0 == m_buffer) { - osl_error = oslTranslateFileError(OSL_FET_ERROR, errno); - rtl_uString_release(ustrSystemPath); + // not buffered + return readAt (nOffset, pBuffer, nBytesRequested, pBytesRead); } - return osl_error; -} + else + { + sal_uInt8 * buffer = static_cast<sal_uInt8*>(pBuffer); + for (*pBytesRead = 0; nBytesRequested > 0; ) + { + off_t const bufptr = (nOffset / m_bufsiz) * m_bufsiz; + size_t const bufpos = (nOffset % m_bufsiz); + if (bufptr != m_bufptr) + { + // flush current buffer + oslFileError result = syncFile(); + if (result != osl_File_E_None) + return (result); + m_bufptr = -1, m_buflen = 0; -/****************************************************************************/ -/* osl_acquireDirectoryItem */ -/****************************************************************************/ + if (nBytesRequested >= m_bufsiz) + { + // buffer too small, read through from file + sal_uInt64 uDone = 0; + result = readAt (nOffset, &(buffer[*pBytesRead]), nBytesRequested, &uDone); + if (result != osl_File_E_None) + return (result); -oslFileError osl_acquireDirectoryItem( oslDirectoryItem Item ) -{ - rtl_uString* ustrFilePath = (rtl_uString *) Item; + nBytesRequested -= uDone, *pBytesRead += uDone; + return osl_File_E_None; + } - OSL_ASSERT( Item ); + // update buffer (pointer) + sal_uInt64 uDone = 0; + result = readAt (bufptr, m_buffer, m_bufsiz, &uDone); + if (result != osl_File_E_None) + return (result); + m_bufptr = bufptr, m_buflen = uDone; + } + if (bufpos >= m_buflen) + { + // end of file + return osl_File_E_None; + } - if( ustrFilePath ) - rtl_uString_acquire( ustrFilePath ); + size_t const bytes = std::min (m_buflen - bufpos, nBytesRequested); + OSL_FILE_TRACE("FileHandle_Impl::readFileAt(%d, %lld, %ld)", m_fd, nOffset, bytes); - return osl_File_E_None; + memcpy (&(buffer[*pBytesRead]), &(m_buffer[bufpos]), bytes); + nBytesRequested -= bytes, *pBytesRead += bytes, nOffset += bytes; + } + return osl_File_E_None; + } } -/****************************************************************************/ -/* osl_releaseDirectoryItem */ -/****************************************************************************/ - -oslFileError osl_releaseDirectoryItem( oslDirectoryItem Item ) +oslFileError FileHandle_Impl::writeFileAt ( + off_t nOffset, + void const * pBuffer, + size_t nBytesToWrite, + sal_uInt64 * pBytesWritten) { - rtl_uString* ustrFilePath = (rtl_uString *) Item; - - OSL_ASSERT( Item ); - - if( ustrFilePath ) - rtl_uString_release( ustrFilePath ); - - return osl_File_E_None; -} + if (0 == (m_state & STATE_SEEKABLE)) + { + // not seekable (pipe) + ssize_t nBytes = ::write (m_fd, pBuffer, nBytesToWrite); + if (-1 == nBytes) + return oslTranslateFileError (OSL_FET_ERROR, errno); + *pBytesWritten = nBytes; + return osl_File_E_None; + } + else if (0 == m_buffer) + { + // not buffered + return writeAt (nOffset, pBuffer, nBytesToWrite, pBytesWritten); + } + else + { + sal_uInt8 const * buffer = static_cast<sal_uInt8 const *>(pBuffer); + for (*pBytesWritten = 0; nBytesToWrite > 0; ) + { + off_t const bufptr = (nOffset / m_bufsiz) * m_bufsiz; + size_t const bufpos = (nOffset % m_bufsiz); + if (bufptr != m_bufptr) + { + // flush current buffer + oslFileError result = syncFile(); + if (result != osl_File_E_None) + return (result); + m_bufptr = -1, m_buflen = 0; -/**************************************************************************** - * osl_createFileHandleFromFD - ***************************************************************************/ + if (nBytesToWrite >= m_bufsiz) + { + // buffer to small, write through to file + sal_uInt64 uDone = 0; + result = writeAt (nOffset, &(buffer[*pBytesWritten]), nBytesToWrite, &uDone); + if (result != osl_File_E_None) + return (result); + if (uDone != nBytesToWrite) + return osl_File_E_IO; + + nBytesToWrite -= uDone, *pBytesWritten += uDone; + return osl_File_E_None; + } -oslFileHandle osl_createFileHandleFromFD( int fd ) -{ - oslFileHandleImpl* pHandleImpl = NULL; + // update buffer (pointer) + sal_uInt64 uDone = 0; + result = readAt (bufptr, m_buffer, m_bufsiz, &uDone); + if (result != osl_File_E_None) + return (result); + m_bufptr = bufptr, m_buflen = uDone; + } - if ( fd >= 0 ) - { - pHandleImpl = (oslFileHandleImpl*) rtl_allocateMemory( sizeof(oslFileHandleImpl) ); + size_t const bytes = std::min (m_bufsiz - bufpos, nBytesToWrite); + OSL_FILE_TRACE("FileHandle_Impl::writeFileAt(%d, %lld, %ld)", m_fd, nOffset, bytes); - if( pHandleImpl ) - { - pHandleImpl->ustrFilePath = NULL; - rtl_uString_new( &pHandleImpl->ustrFilePath ); - pHandleImpl->fd = fd; + memcpy (&(m_buffer[bufpos]), &(buffer[*pBytesWritten]), bytes); + nBytesToWrite -= bytes, *pBytesWritten += bytes, nOffset += bytes; - /* FIXME: it should be detected whether the file has been locked */ - pHandleImpl->bLocked = sal_True; + m_buflen = std::max(m_buflen, bufpos + bytes); + m_state |= STATE_MODIFIED; } + return osl_File_E_None; } - - return (oslFileHandle)pHandleImpl; } - -/**************************************************************************** - * osl_openFile - ***************************************************************************/ - -#ifdef HAVE_O_EXLOCK -#define OPEN_WRITE_FLAGS ( O_RDWR | O_EXLOCK | O_NONBLOCK ) -#define OPEN_CREATE_FLAGS ( O_CREAT | O_EXCL | O_RDWR | O_EXLOCK | O_NONBLOCK ) -#else -#define OPEN_WRITE_FLAGS ( O_RDWR ) -#define OPEN_CREATE_FLAGS ( O_CREAT | O_EXCL | O_RDWR ) -#endif - -oslFileError osl_openFile( rtl_uString* ustrFileURL, oslFileHandle* pHandle, sal_uInt32 uFlags ) +oslFileError FileHandle_Impl::readLineAt ( + off_t nOffset, + sal_Sequence ** ppSequence, + sal_uInt64 * pBytesRead) { - oslFileHandleImpl* pHandleImpl = NULL; - oslFileError eRet; - rtl_uString* ustrFilePath = NULL; - - char buffer[PATH_MAX]; - int fd; - int mode = S_IRUSR | S_IRGRP | S_IROTH; - int flags = O_RDONLY; + oslFileError result = osl_File_E_None; - struct flock aflock; - - /* locking the complete file */ - aflock.l_type = 0; - aflock.l_whence = SEEK_SET; - aflock.l_start = 0; - aflock.l_len = 0; - - OSL_ASSERT( ustrFileURL ); - OSL_ASSERT( pHandle ); + off_t bufptr = nOffset / m_bufsiz * m_bufsiz; + if (bufptr != m_bufptr) + { + /* flush current buffer */ + result = syncFile(); + if (result != osl_File_E_None) + return (result); - if( ( 0 == ustrFileURL->length ) ) - return osl_File_E_INVAL; + /* update buffer (pointer) */ + sal_uInt64 uDone = 0; + result = readAt (bufptr, m_buffer, m_bufsiz, &uDone); + if (result != osl_File_E_None) + return (result); - /* convert file URL to system path */ - eRet = osl_getSystemPathFromFileURL( ustrFileURL, &ustrFilePath ); + m_bufptr = bufptr, m_buflen = uDone; + } - if( osl_File_E_None != eRet ) - return eRet; + static int const LINE_STATE_BEGIN = 0; + static int const LINE_STATE_CR = 1; + static int const LINE_STATE_LF = 2; - osl_systemPathRemoveSeparator(ustrFilePath); + size_t bufpos = nOffset - m_bufptr, curpos = bufpos, dstpos = 0; + int state = (bufpos >= m_buflen) ? LINE_STATE_LF : LINE_STATE_BEGIN; - /* convert unicode path to text */ - if( UnicodeToText( buffer, PATH_MAX, ustrFilePath->buffer, ustrFilePath->length ) -#ifdef MACOSX - && macxp_resolveAlias( buffer, PATH_MAX ) == 0 -#endif /* MACOSX */ - ) + for ( ; state != LINE_STATE_LF; ) { - /* we do not open devices or such here */ - if( !( uFlags & osl_File_OpenFlag_Create ) ) + if (curpos >= m_buflen) { - struct stat aFileStat; - - if( 0 > stat( buffer, &aFileStat ) ) + /* buffer examined */ + if (0 < (curpos - bufpos)) { - PERROR( "osl_openFile", buffer ); - eRet = oslTranslateFileError(OSL_FET_ERROR, errno ); + /* flush buffer to sequence */ + result = writeSequence_Impl ( + ppSequence, &dstpos, &(m_buffer[bufpos]), curpos - bufpos); + if (result != osl_File_E_None) + return (result); + *pBytesRead += curpos - bufpos, nOffset += curpos - bufpos; } - else if( !S_ISREG( aFileStat.st_mode ) ) + bufptr = nOffset / m_bufsiz * m_bufsiz; + if (bufptr != m_bufptr) { - eRet = osl_File_E_INVAL; + /* update buffer (pointer) */ + sal_uInt64 uDone = 0; + result = readAt (bufptr, m_buffer, m_bufsiz, &uDone); + if (result != osl_File_E_None) + return (result); + m_bufptr = bufptr, m_buflen = uDone; } - } - if( osl_File_E_None == eRet ) + bufpos = nOffset - m_bufptr, curpos = bufpos; + if (bufpos >= m_buflen) + break; + } + switch (state) { - /* - * set flags and mode - */ - - if ( uFlags & osl_File_OpenFlag_Write ) - { - mode |= S_IWUSR | S_IWGRP | S_IWOTH; - flags = OPEN_WRITE_FLAGS; -#ifdef MACOSX - flags = adjustLockFlags(buffer, flags); -#endif - aflock.l_type = F_WRLCK; - } - - if ( uFlags & osl_File_OpenFlag_Create ) + case LINE_STATE_CR: + state = LINE_STATE_LF; + switch (m_buffer[curpos]) { - mode |= S_IWUSR | S_IWGRP | S_IWOTH; - flags = OPEN_CREATE_FLAGS; -#ifdef MACOSX - flags = adjustLockFlags(buffer, flags); -#endif + case 0x0A: /* CRLF */ + /* eat current char */ + curpos++; + break; + default: /* single CR */ + /* keep current char */ + break; } - - sal_Bool bNeedsLock = ( ( uFlags & osl_File_OpenFlag_NoLock ) == 0 ); - if ( !bNeedsLock ) + break; + default: + /* determine next state */ + switch (m_buffer[curpos]) { -#ifdef MACOSX - flags &= ~O_EXLOCK; - flags &= ~O_SHLOCK; -#endif + case 0x0A: /* single LF */ + state = LINE_STATE_LF; + break; + case 0x0D: /* CR */ + state = LINE_STATE_CR; + break; + default: /* advance to next char */ + curpos++; + break; } - - /* open the file */ - fd = open( buffer, flags, mode ); - if ( fd >= 0 ) + if (state != LINE_STATE_BEGIN) { - sal_Bool bLocked = sal_False; - if( bNeedsLock ) - { -#ifndef HAVE_O_EXLOCK - /* check if file lock is enabled and clear l_type member of flock otherwise */ - if( (char *) -1 == pFileLockEnvVar ) - { - /* FIXME: this is not MT safe */ - pFileLockEnvVar = getenv("SAL_ENABLE_FILE_LOCKING"); - - if( NULL == pFileLockEnvVar) - pFileLockEnvVar = getenv("STAR_ENABLE_FILE_LOCKING"); - } -#else - /* disable range based locking */ - pFileLockEnvVar = NULL; - - /* remove the NONBLOCK flag again */ - flags = fcntl(fd, F_GETFL, NULL); - flags &= ~O_NONBLOCK; - if( 0 > fcntl(fd, F_GETFL, flags) ) - { - close(fd); - return oslTranslateFileError(OSL_FET_ERROR, errno); - } -#endif - if( NULL == pFileLockEnvVar ) - aflock.l_type = 0; - - /* lock the file if flock.l_type is set */ -#ifdef MACOSX
- bLocked = ( F_WRLCK != aflock.l_type );
- if (!bLocked)
- {
- /* Mac OSX returns ENOTSUP for webdav drives. We should try read lock */
- if ( 0 == flock( fd, LOCK_EX | LOCK_NB ) || errno == ENOTSUP )
- bLocked = ( errno != ENOTSUP ) || ( 0 == flock( fd, LOCK_SH | LOCK_NB ) || errno == ENOTSUP );
- }
-#else /* MACOSX */
- bLocked = ( F_WRLCK != aflock.l_type || -1 != fcntl( fd, F_SETLK, &aflock ) );
-#endif /* MACOSX */
- - } - - if ( !bNeedsLock || bLocked ) - { - /* allocate memory for impl structure */ - pHandleImpl = (oslFileHandleImpl*) rtl_allocateMemory( sizeof(oslFileHandleImpl) ); - if( pHandleImpl ) - { - pHandleImpl->ustrFilePath = ustrFilePath; - pHandleImpl->fd = fd; - pHandleImpl->bLocked = bLocked; - - *pHandle = (oslFileHandle) pHandleImpl; - - return osl_File_E_None; - } - else - { - errno = ENOMEM; - } - } - - close( fd ); + /* store (and eat) the newline char */ + m_buffer[curpos] = 0x0A, curpos++; + + /* flush buffer to sequence */ + result = writeSequence_Impl ( + ppSequence, &dstpos, &(m_buffer[bufpos]), curpos - bufpos - 1); + if (result != osl_File_E_None) + return (result); + *pBytesRead += curpos - bufpos, nOffset += curpos - bufpos; } - - PERROR( "osl_openFile", buffer ); - eRet = oslTranslateFileError(OSL_FET_ERROR, errno ); + break; } } - else - eRet = osl_File_E_INVAL; - rtl_uString_release( ustrFilePath ); - return eRet; + result = writeSequence_Impl (ppSequence, &dstpos, 0, 0); + if (result != osl_File_E_None) + return (result); + if (0 < dstpos) + return osl_File_E_None; + if (bufpos >= m_buflen) + return osl_File_E_AGAIN; + return osl_File_E_None; } -/****************************************************************************/ -/* osl_closeFile */ -/****************************************************************************/ - -oslFileError osl_closeFile( oslFileHandle Handle ) +oslFileError FileHandle_Impl::writeSequence_Impl ( + sal_Sequence ** ppSequence, + size_t * pnOffset, + const void * pBuffer, + size_t nBytes) { - oslFileHandleImpl* pHandleImpl = (oslFileHandleImpl *) Handle; - oslFileError eRet = osl_File_E_INVAL; - - OSL_ASSERT( Handle ); - - if( pHandleImpl ) + sal_Int32 nElements = *pnOffset + nBytes; + if (!*ppSequence) { - rtl_uString_release( pHandleImpl->ustrFilePath ); - - /* release file lock if locking is enabled */ - if( pFileLockEnvVar ) - { - struct flock aflock; - - aflock.l_type = F_UNLCK; - aflock.l_whence = SEEK_SET; - aflock.l_start = 0; - aflock.l_len = 0; - - if ( pHandleImpl->bLocked ) - { - /* FIXME: check if file is really locked ? */ - - /* release the file share lock on this file */ -#ifdef MACOSX
- /* Mac OSX will return ENOTSUP for webdav drives. We should ignore the error */
- if ( 0 != flock( pHandleImpl->fd, LOCK_UN | LOCK_NB ) && errno != ENOTSUP )
-#else /* MACOSX */
- if( -1 == fcntl( pHandleImpl->fd, F_SETLK, &aflock ) )
-#endif /* MACOSX */
- { - PERROR( "osl_closeFile", "unlock failed" ); - } - } - } - - if( 0 > close( pHandleImpl->fd ) ) - { - eRet = oslTranslateFileError(OSL_FET_ERROR, errno ); - } - else - eRet = osl_File_E_None; - - rtl_freeMemory( pHandleImpl ); + /* construct sequence */ + rtl_byte_sequence_constructNoDefault(ppSequence, nElements); } - - return eRet; -} - -/****************************************************************************/ -/* osl_isEndOfFile */ -/****************************************************************************/ - -oslFileError SAL_CALL osl_isEndOfFile( oslFileHandle Handle, sal_Bool *pIsEOF ) -{ - oslFileHandleImpl* pHandleImpl = (oslFileHandleImpl *) Handle; - oslFileError eRet = osl_File_E_INVAL; - - if ( pHandleImpl) + else if (nElements != (*ppSequence)->nElements) { - long curPos = lseek( pHandleImpl->fd, 0, SEEK_CUR ); - - if ( curPos >= 0 ) - { - long endPos = lseek( pHandleImpl->fd, 0, SEEK_END ); - - if ( endPos >= 0 ) - { - *pIsEOF = ( curPos == endPos ); - curPos = lseek( pHandleImpl->fd, curPos, SEEK_SET ); - - if ( curPos >= 0 ) - eRet = osl_File_E_None; - else - eRet = oslTranslateFileError(OSL_FET_ERROR, errno ); - } - else - eRet = oslTranslateFileError(OSL_FET_ERROR, errno ); - } - else - eRet = oslTranslateFileError(OSL_FET_ERROR, errno ); + /* resize sequence */ + rtl_byte_sequence_realloc(ppSequence, nElements); } - - return eRet; + if (*ppSequence != 0) + { + /* fill sequence */ + memcpy(&((*ppSequence)->elements[*pnOffset]), pBuffer, nBytes), *pnOffset += nBytes; + } + return (*ppSequence != 0) ? osl_File_E_None : osl_File_E_NOMEM; } - -/****************************************************************************/ -/* osl_moveFile */ -/****************************************************************************/ - -oslFileError osl_moveFile( rtl_uString* ustrFileURL, rtl_uString* ustrDestURL ) +oslFileError FileHandle_Impl::syncFile() { - char srcPath[PATH_MAX]; - char destPath[PATH_MAX]; - oslFileError eRet; - - OSL_ASSERT( ustrFileURL ); - OSL_ASSERT( ustrDestURL ); - - /* convert source url to system path */ - eRet = FileURLToPath( srcPath, PATH_MAX, ustrFileURL ); - if( eRet != osl_File_E_None ) - return eRet; - - /* convert destination url to system path */ - eRet = FileURLToPath( destPath, PATH_MAX, ustrDestURL ); - if( eRet != osl_File_E_None ) - return eRet; - -#ifdef MACOSX - if ( macxp_resolveAlias( srcPath, PATH_MAX ) != 0 || macxp_resolveAlias( destPath, PATH_MAX ) != 0 ) - return oslTranslateFileError( OSL_FET_ERROR, errno ); -#endif/* MACOSX */ - - return oslDoMoveFile( srcPath, destPath ); + oslFileError result = osl_File_E_None; + if (m_state & STATE_MODIFIED) + { + sal_uInt64 uDone = 0; + result = writeAt (m_bufptr, m_buffer, m_buflen, &uDone); + if (result != osl_File_E_None) + return (result); + if (uDone != m_buflen) + return osl_File_E_IO; + m_state &= ~STATE_MODIFIED; + } + return (result); } -/****************************************************************************/ -/* osl_copyFile */ -/****************************************************************************/ - -oslFileError osl_copyFile( rtl_uString* ustrFileURL, rtl_uString* ustrDestURL ) +/**************************************************************************** + * osl_createFileHandleFromFD + ***************************************************************************/ +extern "C" oslFileHandle osl_createFileHandleFromFD( int fd ) { - char srcPath[PATH_MAX]; - char destPath[PATH_MAX]; - oslFileError eRet; - - OSL_ASSERT( ustrFileURL ); - OSL_ASSERT( ustrDestURL ); + if (-1 == fd) + return 0; // EINVAL - /* convert source url to system path */ - eRet = FileURLToPath( srcPath, PATH_MAX, ustrFileURL ); - if( eRet != osl_File_E_None ) - return eRet; + struct stat aFileStat; + if (-1 == fstat (fd, &aFileStat)) + return 0; // EBADF - /* convert destination url to system path */ - eRet = FileURLToPath( destPath, PATH_MAX, ustrDestURL ); - if( eRet != osl_File_E_None ) - return eRet; + FileHandle_Impl * pImpl = new FileHandle_Impl (fd); + if (0 == pImpl) + return 0; // ENOMEM -#ifdef MACOSX - if ( macxp_resolveAlias( srcPath, PATH_MAX ) != 0 || macxp_resolveAlias( destPath, PATH_MAX ) != 0 ) - return oslTranslateFileError( OSL_FET_ERROR, errno ); -#endif/* MACOSX */ + // assume writeable + pImpl->m_state |= FileHandle_Impl::STATE_WRITEABLE; + if (!S_ISREG(aFileStat.st_mode)) + { + /* not a regular file, mark not seekable */ + pImpl->m_state &= ~FileHandle_Impl::STATE_SEEKABLE; + } + else + { + /* regular file, init current size */ + pImpl->m_size = sal::static_int_cast< sal_uInt64 >(aFileStat.st_size); + } - return osl_psz_copyFile( srcPath, destPath ); + OSL_FILE_TRACE("osl_createFileHandleFromFD(%d, writeable) => %s", + pImpl->m_fd, rtl_string_getStr(pImpl->m_strFilePath)); + return (oslFileHandle)(pImpl); } -/****************************************************************************/ -/* osl_removeFile */ -/****************************************************************************/ - -oslFileError osl_removeFile( rtl_uString* ustrFileURL ) +/******************************************************************* + * osl_file_adjustLockFlags + ******************************************************************/ +static int osl_file_adjustLockFlags (const char * path, int flags) { - char path[PATH_MAX]; - oslFileError eRet; - - OSL_ASSERT( ustrFileURL ); - - /* convert file url to system path */ - eRet = FileURLToPath( path, PATH_MAX, ustrFileURL ); - if( eRet != osl_File_E_None ) - return eRet; - #ifdef MACOSX - if ( macxp_resolveAlias( path, PATH_MAX ) != 0 ) - return oslTranslateFileError( OSL_FET_ERROR, errno ); -#endif/* MACOSX */ + /* + * The AFP implementation of MacOS X 10.4 treats O_EXLOCK in a way + * that makes it impossible for OOo to create a backup copy of the + * file it keeps opened. OTOH O_SHLOCK for AFP behaves as desired by + * the OOo file handling, so we need to check the path of the file + * for the filesystem name. + */ + struct statfs s; + if( 0 <= statfs( path, &s ) ) + { + if( 0 == strncmp("afpfs", s.f_fstypename, 5) ) + { + flags &= ~O_EXLOCK; + flags |= O_SHLOCK; + } + else + { + /* Needed flags to allow opening a webdav file */ + flags &= ~(O_EXLOCK | O_SHLOCK | O_NONBLOCK); + } + } +#endif /* MACOSX */ - return osl_psz_removeFile( path ); + (void) path; + return flags; } -/****************************************************************************/ -/* osl_getVolumeInformation */ -/****************************************************************************/ - -oslFileError osl_getVolumeInformation( rtl_uString* ustrDirectoryURL, oslVolumeInfo* pInfo, sal_uInt32 uFieldMask ) +/**************************************************************************** + * osl_file_queryLocking + ***************************************************************************/ +struct Locking_Impl { - char path[PATH_MAX]; - oslFileError eRet; - - OSL_ASSERT( ustrDirectoryURL ); - OSL_ASSERT( pInfo ); - - /* convert directory url to system path */ - eRet = FileURLToPath( path, PATH_MAX, ustrDirectoryURL ); - if( eRet != osl_File_E_None ) - return eRet; - -#ifdef MACOSX - if ( macxp_resolveAlias( path, PATH_MAX ) != 0 ) - return oslTranslateFileError( OSL_FET_ERROR, errno ); -#endif/* MACOSX */ - - return osl_psz_getVolumeInformation( path, pInfo, uFieldMask); -} - -/****************************************************************************/ -/* osl_createDirectory */ -/****************************************************************************/ - -oslFileError osl_createDirectory( rtl_uString* ustrDirectoryURL ) + int m_enabled; + Locking_Impl() : m_enabled(0) + { +#ifndef HAVE_O_EXLOCK + m_enabled = ((getenv("SAL_ENABLE_FILE_LOCKING") != 0) || (getenv("STAR_ENABLE_FILE_LOCKING") != 0)); +#endif /* HAVE_O_EXLOCK */ + } +}; +static int osl_file_queryLocking (sal_uInt32 uFlags) { - char path[PATH_MAX]; - oslFileError eRet; - - OSL_ASSERT( ustrDirectoryURL ); - - /* convert directory url to system path */ - eRet = FileURLToPath( path, PATH_MAX, ustrDirectoryURL ); - if( eRet != osl_File_E_None ) - return eRet; - -#ifdef MACOSX - if ( macxp_resolveAlias( path, PATH_MAX ) != 0 ) - return oslTranslateFileError( OSL_FET_ERROR, errno ); -#endif/* MACOSX */ - - return osl_psz_createDirectory( path ); + if (!(uFlags & osl_File_OpenFlag_NoLock)) + { + if ((uFlags & osl_File_OpenFlag_Write) || (uFlags & osl_File_OpenFlag_Create)) + { + static Locking_Impl g_locking; + return (g_locking.m_enabled != 0); + } + } + return 0; } -/****************************************************************************/ -/* osl_removeDirectory */ -/****************************************************************************/ +/**************************************************************************** + * osl_openFile + ***************************************************************************/ +#ifdef HAVE_O_EXLOCK +#define OPEN_WRITE_FLAGS ( O_RDWR | O_EXLOCK | O_NONBLOCK ) +#define OPEN_CREATE_FLAGS ( O_CREAT | O_EXCL | O_RDWR | O_EXLOCK | O_NONBLOCK ) +#else +#define OPEN_WRITE_FLAGS ( O_RDWR ) +#define OPEN_CREATE_FLAGS ( O_CREAT | O_EXCL | O_RDWR ) +#endif -oslFileError osl_removeDirectory( rtl_uString* ustrDirectoryURL ) +oslFileError +SAL_CALL osl_openFile( rtl_uString* ustrFileURL, oslFileHandle* pHandle, sal_uInt32 uFlags ) { - char path[PATH_MAX]; oslFileError eRet; - OSL_ASSERT( ustrDirectoryURL ); + if ((ustrFileURL == 0) || (ustrFileURL->length == 0) || (pHandle == 0)) + return osl_File_E_INVAL; - /* convert directory url to system path */ - eRet = FileURLToPath( path, PATH_MAX, ustrDirectoryURL ); - if( eRet != osl_File_E_None ) + /* convert file URL to system path */ + char buffer[PATH_MAX]; + eRet = FileURLToPath (buffer, sizeof(buffer), ustrFileURL); + if (eRet != osl_File_E_None) return eRet; - #ifdef MACOSX - if ( macxp_resolveAlias( path, PATH_MAX ) != 0 ) - return oslTranslateFileError( OSL_FET_ERROR, errno ); -#endif/* MACOSX */ - - return osl_psz_removeDirectory( path ); -} - -//############################################# -int path_make_parent(sal_Unicode* path) -{ - int i = rtl_ustr_lastIndexOfChar(path, '/'); + if (macxp_resolveAlias (buffer, sizeof(buffer)) != 0) + return oslTranslateFileError (OSL_FET_ERROR, errno); +#endif /* MACOSX */ - if (i > 0) + /* set mode and flags */ + int mode = S_IRUSR | S_IRGRP | S_IROTH; + int flags = O_RDONLY; + if (uFlags & osl_File_OpenFlag_Write) + { + mode |= S_IWUSR | S_IWGRP | S_IWOTH; + flags = OPEN_WRITE_FLAGS; + } + if (uFlags & osl_File_OpenFlag_Create) { - *(path + i) = 0; - return i; + mode |= S_IWUSR | S_IWGRP | S_IWOTH; + flags = OPEN_CREATE_FLAGS; + } + if (uFlags & osl_File_OpenFlag_NoLock) + { +#ifdef HAVE_O_EXLOCK + flags &= ~(O_EXLOCK | O_SHLOCK | O_NONBLOCK); +#endif /* HAVE_O_EXLOCK */ } else - return 0; -} + { + flags = osl_file_adjustLockFlags (buffer, flags); + } -//############################################# -int create_dir_with_callback( - sal_Unicode* directory_path, - oslDirectoryCreationCallbackFunc aDirectoryCreationCallbackFunc, - void* pData) -{ - int mode = S_IRWXU | S_IRWXG | S_IRWXO; + /* open the file */ + int fd = open( buffer, flags, mode ); + if (-1 == fd) + return oslTranslateFileError (OSL_FET_ERROR, errno); - if (osl::mkdir(directory_path, mode) == 0) + /* reset O_NONBLOCK flag */ + if (flags & O_NONBLOCK) { - if (aDirectoryCreationCallbackFunc) + int f = fcntl (fd, F_GETFL, 0); + if (-1 == f) + { + eRet = oslTranslateFileError (OSL_FET_ERROR, errno); + (void) close(fd); + return eRet; + } + if (-1 == fcntl (fd, F_SETFL, (f & ~O_NONBLOCK))) { - rtl::OUString url; - osl::FileBase::getFileURLFromSystemPath(directory_path, url); - aDirectoryCreationCallbackFunc(pData, url.pData); + eRet = oslTranslateFileError (OSL_FET_ERROR, errno); + (void) close(fd); + return eRet; } - return 0; } - return errno; -} - -//############################################# -oslFileError create_dir_recursively_( - sal_Unicode* dir_path, - oslDirectoryCreationCallbackFunc aDirectoryCreationCallbackFunc, - void* pData) -{ - OSL_PRECOND((rtl_ustr_getLength(dir_path) > 0) && ((dir_path + (rtl_ustr_getLength(dir_path) - 1)) != (dir_path + rtl_ustr_lastIndexOfChar(dir_path, '/'))), \ - "Path must not end with a slash"); - - int native_err = create_dir_with_callback( - dir_path, aDirectoryCreationCallbackFunc, pData); - - if (native_err == 0) - return osl_File_E_None; - if (native_err != ENOENT) - return oslTranslateFileError(OSL_FET_ERROR, native_err); - - // we step back until '/a_dir' at maximum because - // we should get an error unequal ENOENT when - // we try to create 'a_dir' at '/' and would so - // return before - int pos = path_make_parent(dir_path); - - oslFileError osl_error = create_dir_recursively_( - dir_path, aDirectoryCreationCallbackFunc, pData); - - if (osl_File_E_None != osl_error) - return osl_error; - - dir_path[pos] = '/'; - - return create_dir_recursively_(dir_path, aDirectoryCreationCallbackFunc, pData); -} - -//####################################### -oslFileError SAL_CALL osl_createDirectoryPath( - rtl_uString* aDirectoryUrl, - oslDirectoryCreationCallbackFunc aDirectoryCreationCallbackFunc, - void* pData) -{ - if (aDirectoryUrl == NULL) + /* get file status (mode, size) */ + struct stat aFileStat; + if (-1 == fstat (fd, &aFileStat)) + { + eRet = oslTranslateFileError (OSL_FET_ERROR, errno); + (void) close(fd); + return eRet; + } + if (!S_ISREG(aFileStat.st_mode)) + { + /* we only open regular files here */ + (void) close(fd); return osl_File_E_INVAL; + } - rtl::OUString sys_path; - oslFileError osl_error = osl_getSystemPathFromFileURL_Ex( - aDirectoryUrl, &sys_path.pData, sal_False); - - if (osl_error != osl_File_E_None) - return osl_error; + if (osl_file_queryLocking (uFlags)) + { +#ifdef MACOSX + if (-1 == flock (fd, LOCK_EX | LOCK_NB)) + { + /* Mac OSX returns ENOTSUP for webdav drives. We should try read lock */ + if ((errno != ENOTSUP) || ((-1 == flock (fd, LOCK_SH | LOCK_NB)) && (errno != ENOTSUP))) + { + eRet = oslTranslateFileError (OSL_FET_ERROR, errno); + (void) close(fd); + return eRet; + } + } +#else /* F_SETLK */ + { + struct flock aflock; - osl::systemPathRemoveSeparator(sys_path); + aflock.l_type = F_WRLCK; + aflock.l_whence = SEEK_SET; + aflock.l_start = 0; + aflock.l_len = 0; - // const_cast because sys_path is a local copy which we want to modify inplace instead of - // coyp it into another buffer on the heap again - return create_dir_recursively_(sys_path.pData->buffer, aDirectoryCreationCallbackFunc, pData); -} + if (-1 == fcntl (fd, F_SETLK, &aflock)) + { + eRet = oslTranslateFileError (OSL_FET_ERROR, errno); + (void) close(fd); + return eRet; + } + } +#endif /* F_SETLK */ + } -/****************************************************************************/ -/* osl_getCanonicalName */ -/****************************************************************************/ + /* allocate memory for impl structure */ + FileHandle_Impl * pImpl = new FileHandle_Impl (fd, buffer); + if (!pImpl) + { + eRet = oslTranslateFileError (OSL_FET_ERROR, ENOMEM); + (void) close(fd); + return eRet; + } + if (flags & O_RDWR) + pImpl->m_state |= FileHandle_Impl::STATE_WRITEABLE; + pImpl->m_size = sal::static_int_cast< sal_uInt64 >(aFileStat.st_size); -oslFileError osl_getCanonicalName( rtl_uString* ustrFileURL, rtl_uString** pustrValidURL ) -{ - OSL_ENSURE(sal_False, "osl_getCanonicalName not implemented"); + OSL_TRACE("osl_openFile(%d, %s) => %s", pImpl->m_fd, + flags & O_RDWR ? "writeable":"readonly", + rtl_string_getStr(pImpl->m_strFilePath)); - rtl_uString_newFromString(pustrValidURL, ustrFileURL); + *pHandle = (oslFileHandle)(pImpl); return osl_File_E_None; } - /****************************************************************************/ -/* osl_setFileAttributes */ +/* osl_closeFile */ /****************************************************************************/ - -oslFileError osl_setFileAttributes( rtl_uString* ustrFileURL, sal_uInt64 uAttributes ) +oslFileError +SAL_CALL osl_closeFile( oslFileHandle Handle ) { - char path[PATH_MAX]; - oslFileError eRet; + FileHandle_Impl* pImpl = static_cast<FileHandle_Impl*>(Handle); - OSL_ASSERT( ustrFileURL ); + if ((pImpl == 0) || (pImpl->m_fd < 0)) + return osl_File_E_INVAL; - /* convert file url to system path */ - eRet = FileURLToPath( path, PATH_MAX, ustrFileURL ); - if( eRet != osl_File_E_None ) - return eRet; + (void) pthread_mutex_lock (&(pImpl->m_mutex)); -#ifdef MACOSX - if ( macxp_resolveAlias( path, PATH_MAX ) != 0 ) - return oslTranslateFileError( OSL_FET_ERROR, errno ); -#endif/* MACOSX */ + /* close(2) implicitly (and unconditionally) unlocks */ + OSL_TRACE("osl_closeFile(%d) => %s", pImpl->m_fd, rtl_string_getStr(pImpl->m_strFilePath)); + oslFileError result = pImpl->syncFile(); + if (result != osl_File_E_None) + { + /* close, ignoring double failure */ + (void) close (pImpl->m_fd); + } + else if (-1 == close (pImpl->m_fd)) + { + /* translate error code */ + result = oslTranslateFileError (OSL_FET_ERROR, errno); + } - return osl_psz_setFileAttributes( path, uAttributes ); + (void) pthread_mutex_unlock (&(pImpl->m_mutex)); + delete pImpl; + return (result); } -/****************************************************************************/ -/* osl_setFileTime */ -/****************************************************************************/ - -oslFileError osl_setFileTime( rtl_uString* ustrFileURL, const TimeValue* pCreationTime, - const TimeValue* pLastAccessTime, const TimeValue* pLastWriteTime ) +/************************************************ + * osl_syncFile + ***********************************************/ +oslFileError +SAL_CALL osl_syncFile(oslFileHandle Handle) { - char path[PATH_MAX]; - oslFileError eRet; + FileHandle_Impl* pImpl = static_cast<FileHandle_Impl*>(Handle); - OSL_ASSERT( ustrFileURL ); + if ((0 == pImpl) || (-1 == pImpl->m_fd)) + return osl_File_E_INVAL; - /* convert file url to system path */ - eRet = FileURLToPath( path, PATH_MAX, ustrFileURL ); - if( eRet != osl_File_E_None ) - return eRet; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); -#ifdef MACOSX - if ( macxp_resolveAlias( path, PATH_MAX ) != 0 ) - return oslTranslateFileError( OSL_FET_ERROR, errno ); -#endif/* MACOSX */ + OSL_TRACE("osl_syncFile(%d)", pImpl->m_fd); + oslFileError result = pImpl->syncFile(); + if (result != osl_File_E_None) + return (result); + if (-1 == fsync (pImpl->m_fd)) + return oslTranslateFileError (OSL_FET_ERROR, errno); - return osl_psz_setFileTime( path, pCreationTime, pLastAccessTime, pLastWriteTime ); + return osl_File_E_None; } -/****************************************************************************** - * - * Exported Module Functions - * (independent of C or Unicode Strings) - * - *****************************************************************************/ - /******************************************* osl_mapFile ********************************************/ @@ -1179,9 +1033,9 @@ SAL_CALL osl_mapFile ( sal_uInt32 uFlags ) { - oslFileHandleImpl* pHandleImpl = (oslFileHandleImpl*)Handle; + FileHandle_Impl* pImpl = static_cast<FileHandle_Impl*>(Handle); - if ((0 == pHandleImpl) || (-1 == pHandleImpl->fd) || (0 == ppAddr)) + if ((0 == pImpl) || (-1 == pImpl->m_fd) || (0 == ppAddr)) return osl_File_E_INVAL; *ppAddr = 0; @@ -1195,7 +1049,7 @@ SAL_CALL osl_mapFile ( return osl_File_E_OVERFLOW; off_t const nOffset = sal::static_int_cast< off_t >(uOffset); - void* p = mmap(NULL, nLength, PROT_READ, MAP_SHARED, pHandleImpl->fd, nOffset); + void* p = mmap(NULL, nLength, PROT_READ, MAP_SHARED, pImpl->m_fd, nOffset); if (MAP_FAILED == p) return oslTranslateFileError(OSL_FET_ERROR, errno); *ppAddr = p; @@ -1203,11 +1057,7 @@ SAL_CALL osl_mapFile ( if (uFlags & osl_File_MapFlag_RandomAccess) { // Determine memory pagesize. -#if defined(FREEBSD) || defined(NETBSD) || defined(MACOSX) - size_t const nPageSize = getpagesize(); -#else /* POSIX */ - size_t const nPageSize = sysconf(_SC_PAGESIZE); -#endif /* xBSD || POSIX */ + size_t const nPageSize = FileHandle_Impl::getpagesize(); if (size_t(-1) != nPageSize) { /* @@ -1256,64 +1106,86 @@ SAL_CALL osl_unmapFile (void* pAddr, sal_uInt64 uLength) } /******************************************* - osl_readFile + osl_readLine ********************************************/ - -oslFileError osl_readFile(oslFileHandle Handle, void* pBuffer, sal_uInt64 uBytesRequested, sal_uInt64* pBytesRead) +oslFileError +SAL_CALL osl_readLine ( + oslFileHandle Handle, + sal_Sequence ** ppSequence) { - ssize_t nBytes = 0; - oslFileHandleImpl* pHandleImpl = (oslFileHandleImpl*)Handle; + FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle); - if ((0 == pHandleImpl) || (pHandleImpl->fd < 0) || (0 == pBuffer) || (0 == pBytesRead)) + if ((0 == pImpl) || (-1 == pImpl->m_fd) || (0 == ppSequence)) return osl_File_E_INVAL; + sal_uInt64 uBytesRead = 0; - nBytes = read( - pHandleImpl->fd, pBuffer, - ((uBytesRequested - <= static_cast< size_t >(std::numeric_limits< ssize_t >::max())) - ? static_cast< size_t >(uBytesRequested) - : static_cast< size_t >(std::numeric_limits< ssize_t >::max()))); - - if (-1 == nBytes) - return oslTranslateFileError(OSL_FET_ERROR, errno); - - *pBytesRead = nBytes; - return osl_File_E_None; + // read at current fileptr; fileptr += uBytesRead; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); + oslFileError result = pImpl->readLineAt ( + pImpl->m_fileptr, ppSequence, &uBytesRead); + if (result == osl_File_E_None) + pImpl->m_fileptr += uBytesRead; + return (result); } /******************************************* - osl_writeFile + osl_readFile ********************************************/ - -oslFileError osl_writeFile(oslFileHandle Handle, const void* pBuffer, sal_uInt64 uBytesToWrite, sal_uInt64* pBytesWritten) +oslFileError +SAL_CALL osl_readFile ( + oslFileHandle Handle, + void * pBuffer, + sal_uInt64 uBytesRequested, + sal_uInt64 * pBytesRead) { - ssize_t nBytes = 0; - oslFileHandleImpl* pHandleImpl = (oslFileHandleImpl*)Handle; + FileHandle_Impl* pImpl = static_cast<FileHandle_Impl*>(Handle); - OSL_ASSERT(pHandleImpl); - OSL_ASSERT(pBuffer); - OSL_ASSERT(pBytesWritten); - - if ((0 == pHandleImpl) || (0 == pBuffer) || (0 == pBytesWritten)) + if ((0 == pImpl) || (-1 == pImpl->m_fd) || (0 == pBuffer) || (0 == pBytesRead)) return osl_File_E_INVAL; - OSL_ASSERT(pHandleImpl->fd >= 0); + static sal_uInt64 const g_limit_ssize_t = std::numeric_limits< ssize_t >::max(); + if (g_limit_ssize_t < uBytesRequested) + return osl_File_E_OVERFLOW; + size_t const nBytesRequested = sal::static_int_cast< size_t >(uBytesRequested); - if (pHandleImpl->fd < 0) - return osl_File_E_INVAL; + // read at current fileptr; fileptr += *pBytesRead; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); + oslFileError result = pImpl->readFileAt ( + pImpl->m_fileptr, pBuffer, nBytesRequested, pBytesRead); + if (result == osl_File_E_None) + pImpl->m_fileptr += *pBytesRead; + return (result); +} - nBytes = write( - pHandleImpl->fd, pBuffer, - ((uBytesToWrite - <= static_cast< size_t >(std::numeric_limits< ssize_t >::max())) - ? static_cast< size_t >(uBytesToWrite) - : static_cast< size_t >(std::numeric_limits< ssize_t >::max()))); +/******************************************* + osl_writeFile +********************************************/ +oslFileError +SAL_CALL osl_writeFile ( + oslFileHandle Handle, + const void * pBuffer, + sal_uInt64 uBytesToWrite, + sal_uInt64 * pBytesWritten) +{ + FileHandle_Impl* pImpl = static_cast<FileHandle_Impl*>(Handle); - if (-1 == nBytes) - return oslTranslateFileError(OSL_FET_ERROR, errno); + if ((0 == pImpl) || (-1 == pImpl->m_fd) || (0 == pBuffer) || (0 == pBytesWritten)) + return osl_File_E_INVAL; + if (0 == (pImpl->m_state & FileHandle_Impl::STATE_WRITEABLE)) + return osl_File_E_BADF; - *pBytesWritten = nBytes; - return osl_File_E_None; + static sal_uInt64 const g_limit_ssize_t = std::numeric_limits< ssize_t >::max(); + if (g_limit_ssize_t < uBytesToWrite) + return osl_File_E_OVERFLOW; + size_t const nBytesToWrite = sal::static_int_cast< size_t >(uBytesToWrite); + + // write at current fileptr; fileptr += *pBytesWritten; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); + oslFileError result = pImpl->writeFileAt ( + pImpl->m_fileptr, pBuffer, nBytesToWrite, pBytesWritten); + if (result == osl_File_E_None) + pImpl->m_fileptr += *pBytesWritten; + return (result); } /******************************************* @@ -1327,10 +1199,12 @@ SAL_CALL osl_readFileAt ( sal_uInt64 uBytesRequested, sal_uInt64* pBytesRead) { - oslFileHandleImpl* pHandleImpl = (oslFileHandleImpl*)Handle; + FileHandle_Impl* pImpl = static_cast<FileHandle_Impl*>(Handle); - if ((0 == pHandleImpl) || (pHandleImpl->fd < 0) || (0 == pBuffer) || (0 == pBytesRead)) + if ((0 == pImpl) || (-1 == pImpl->m_fd) || (0 == pBuffer) || (0 == pBytesRead)) return osl_File_E_INVAL; + if (0 == (pImpl->m_state & FileHandle_Impl::STATE_SEEKABLE)) + return osl_File_E_SPIPE; static sal_uInt64 const g_limit_off_t = std::numeric_limits< off_t >::max(); if (g_limit_off_t < uOffset) @@ -1342,35 +1216,9 @@ SAL_CALL osl_readFileAt ( return osl_File_E_OVERFLOW; size_t const nBytesRequested = sal::static_int_cast< size_t >(uBytesRequested); -#if defined(LINUX) || defined(SOLARIS) - - ssize_t nBytes = ::pread(pHandleImpl->fd, pBuffer, nBytesRequested, nOffset); - if ((-1 == nBytes) && (EOVERFLOW == errno)) - { - /* - * Workaround for 'pread()' failure at end-of-file: - * - * Some 'pread()'s fail with EOVERFLOW when reading at (or past) - * end-of-file, different from 'lseek() + read()' behaviour. - * Returning '0 bytes read' and 'osl_File_E_None' instead. - */ - nBytes = 0; - } - -#else /* LINUX || SOLARIS */ - - if (-1 == ::lseek (pHandleImpl->fd, nOffset, SEEK_SET)) - return oslTranslateFileError(OSL_FET_ERROR, errno); - - ssize_t nBytes = ::read(pHandleImpl->fd, pBuffer, nBytesRequested); - -#endif /* LINUX || SOLARIS */ - - if (-1 == nBytes) - return oslTranslateFileError(OSL_FET_ERROR, errno); - - *pBytesRead = nBytes; - return osl_File_E_None; + // read at specified fileptr + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); + return pImpl->readFileAt (nOffset, pBuffer, nBytesRequested, pBytesRead); } /******************************************* @@ -1384,10 +1232,14 @@ SAL_CALL osl_writeFileAt ( sal_uInt64 uBytesToWrite, sal_uInt64* pBytesWritten) { - oslFileHandleImpl* pHandleImpl = (oslFileHandleImpl*)Handle; + FileHandle_Impl* pImpl = static_cast<FileHandle_Impl*>(Handle); - if ((0 == pHandleImpl) || (pHandleImpl->fd < 0) || (0 == pBuffer) || (0 == pBytesWritten)) + if ((0 == pImpl) || (-1 == pImpl->m_fd) || (0 == pBuffer) || (0 == pBytesWritten)) return osl_File_E_INVAL; + if (0 == (pImpl->m_state & FileHandle_Impl::STATE_SEEKABLE)) + return osl_File_E_SPIPE; + if (0 == (pImpl->m_state & FileHandle_Impl::STATE_WRITEABLE)) + return osl_File_E_BADF; static sal_uInt64 const g_limit_off_t = std::numeric_limits< off_t >::max(); if (g_limit_off_t < uOffset) @@ -1399,2285 +1251,127 @@ SAL_CALL osl_writeFileAt ( return osl_File_E_OVERFLOW; size_t const nBytesToWrite = sal::static_int_cast< size_t >(uBytesToWrite); -#if defined(LINUX) || defined(SOLARIS) - - ssize_t nBytes = ::pwrite(pHandleImpl->fd, pBuffer, nBytesToWrite, nOffset); + // write at specified fileptr + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); + return pImpl->writeFileAt (nOffset, pBuffer, nBytesToWrite, pBytesWritten); +} -#else /* LINUX || SOLARIS */ +/****************************************************************************/ +/* osl_isEndOfFile */ +/****************************************************************************/ +oslFileError +SAL_CALL osl_isEndOfFile( oslFileHandle Handle, sal_Bool *pIsEOF ) +{ + FileHandle_Impl* pImpl = static_cast<FileHandle_Impl*>(Handle); - if (-1 == ::lseek(pHandleImpl->fd, nOffset, SEEK_SET)) - return oslTranslateFileError(OSL_FET_ERROR, errno); + if ((0 == pImpl) || (-1 == pImpl->m_fd) || (0 == pIsEOF)) + return osl_File_E_INVAL; - ssize_t nBytes = ::write(pHandleImpl->fd, pBuffer, nBytesToWrite); + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); + *pIsEOF = (pImpl->getPos() == pImpl->getSize()); + return osl_File_E_None; +} -#endif /* LINUX || SOLARIS */ +/************************************************ + * osl_getFilePos + ***********************************************/ +oslFileError +SAL_CALL osl_getFilePos( oslFileHandle Handle, sal_uInt64* pPos ) +{ + FileHandle_Impl* pImpl = static_cast<FileHandle_Impl*>(Handle); - if (-1 == nBytes) - return oslTranslateFileError(OSL_FET_ERROR, errno); + if ((0 == pImpl) || (-1 == pImpl->m_fd) || (0 == pPos)) + return osl_File_E_INVAL; - *pBytesWritten = nBytes; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); + *pPos = pImpl->getPos(); return osl_File_E_None; } /******************************************* osl_setFilePos ********************************************/ - -oslFileError osl_setFilePos( oslFileHandle Handle, sal_uInt32 uHow, sal_Int64 uPos ) +oslFileError +SAL_CALL osl_setFilePos (oslFileHandle Handle, sal_uInt32 uHow, sal_Int64 uOffset) { - oslFileHandleImpl* pHandleImpl=0; - int nRet=0; - off_t nOffset=0; + FileHandle_Impl* pImpl = static_cast<FileHandle_Impl*>(Handle); - pHandleImpl = (oslFileHandleImpl*) Handle; - if ( pHandleImpl == 0 ) - { + if ((0 == pImpl) || (-1 == pImpl->m_fd)) return osl_File_E_INVAL; - } - if ( pHandleImpl->fd < 0 ) - { - return osl_File_E_INVAL; - } - - /* FIXME mfe: setFilePos: Do we have any runtime function to determine LONG_MAX? */ - if ( uPos > LONG_MAX ) - { + static sal_Int64 const g_limit_off_t = std::numeric_limits< off_t >::max(); + if (g_limit_off_t < uOffset) return osl_File_E_OVERFLOW; - } - - nOffset=(off_t)uPos; + off_t nPos = 0, nOffset = sal::static_int_cast< off_t >(uOffset); + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); switch(uHow) { case osl_Pos_Absolut: - nOffset = lseek(pHandleImpl->fd,nOffset,SEEK_SET); + if (0 > nOffset) + return osl_File_E_INVAL; break; case osl_Pos_Current: - nOffset = lseek(pHandleImpl->fd,nOffset,SEEK_CUR); + nPos = sal::static_int_cast< off_t >(pImpl->getPos()); + if ((0 > nOffset) && (-1*nOffset > nPos)) + return osl_File_E_INVAL; + if (g_limit_off_t < nPos + nOffset) + return osl_File_E_OVERFLOW; break; case osl_Pos_End: - nOffset = lseek(pHandleImpl->fd,nOffset,SEEK_END); + nPos = sal::static_int_cast< off_t >(pImpl->getSize()); + if ((0 > nOffset) && (-1*nOffset > nPos)) + return osl_File_E_INVAL; + if (g_limit_off_t < nPos + nOffset) + return osl_File_E_OVERFLOW; break; default: return osl_File_E_INVAL; } - if ( nOffset < 0 ) - { - nRet=errno; - return oslTranslateFileError(OSL_FET_ERROR, nRet); - } - - return osl_File_E_None; -} - -/************************************************ - * osl_getFilePos - ***********************************************/ - -oslFileError osl_getFilePos( oslFileHandle Handle, sal_uInt64* pPos ) -{ - oslFileHandleImpl* pHandleImpl=0; - off_t nOffset=0; - int nRet=0; - - pHandleImpl = (oslFileHandleImpl*) Handle; - if ( pHandleImpl == 0 || pPos == 0) - { - return osl_File_E_INVAL; - } - - if ( pHandleImpl->fd < 0 ) - { - return osl_File_E_INVAL; - } - - nOffset = lseek(pHandleImpl->fd,0,SEEK_CUR); - - if (nOffset < 0) - { - nRet =errno; - - /* *pPos =0; */ - - return oslTranslateFileError(OSL_FET_ERROR, nRet); - } - - *pPos=nOffset; - - return osl_File_E_None; + return pImpl->setPos (nPos + nOffset); } /**************************************************************************** * osl_getFileSize ****************************************************************************/ - -oslFileError osl_getFileSize( oslFileHandle Handle, sal_uInt64* pSize ) +oslFileError +SAL_CALL osl_getFileSize( oslFileHandle Handle, sal_uInt64* pSize ) { - oslFileHandleImpl* pHandleImpl=(oslFileHandleImpl*) Handle; - if (pHandleImpl == 0) - return osl_File_E_INVAL; + FileHandle_Impl* pImpl = static_cast<FileHandle_Impl*>(Handle); - struct stat file_stat; - if (fstat(pHandleImpl->fd, &file_stat) == -1) - return oslTranslateFileError(OSL_FET_ERROR, errno); + if ((0 == pImpl) || (-1 == pImpl->m_fd) || (0 == pSize)) + return osl_File_E_INVAL; - *pSize = file_stat.st_size; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); + *pSize = pImpl->getSize(); return osl_File_E_None; } /************************************************ * osl_setFileSize ***********************************************/ - -oslFileError osl_setFileSize( oslFileHandle Handle, sal_uInt64 uSize ) +oslFileError +SAL_CALL osl_setFileSize( oslFileHandle Handle, sal_uInt64 uSize ) { - oslFileHandleImpl* pHandleImpl=0; - off_t nOffset=0; - - pHandleImpl = (oslFileHandleImpl*) Handle; - if ( pHandleImpl == 0 ) - { - return osl_File_E_INVAL; - } + FileHandle_Impl* pImpl = static_cast<FileHandle_Impl*>(Handle); - if ( pHandleImpl->fd < 0 ) - { + if ((0 == pImpl) || (-1 == pImpl->m_fd)) return osl_File_E_INVAL; - } + if (0 == (pImpl->m_state & FileHandle_Impl::STATE_WRITEABLE)) + return osl_File_E_BADF; - /* FIXME: mfe: setFileSize: Do we have any runtime function to determine LONG_MAX? */ - if ( uSize > LONG_MAX ) - { + static sal_uInt64 const g_limit_off_t = std::numeric_limits< off_t >::max(); + if (g_limit_off_t < uSize) return osl_File_E_OVERFLOW; - } - - nOffset = (off_t)uSize; - if (ftruncate (pHandleImpl->fd, nOffset) < 0) - { - /* Failure. Try fallback algorithm */ - oslFileError result; - struct stat aStat; - off_t nCurPos; - /* Save original result */ - result = oslTranslateFileError (OSL_FET_ERROR, errno); - PERROR("ftruncate", "Try osl_setFileSize [fallback]\n"); - - /* Check against current size. Fail upon 'shrink' */ - if (fstat (pHandleImpl->fd, &aStat) < 0) - { - PERROR("ftruncate: fstat", "Out osl_setFileSize [error]\n"); - return (result); - } - if ((0 <= nOffset) && (nOffset <= aStat.st_size)) - { - /* Failure upon 'shrink'. Return original result */ - return (result); - } - - /* Save current position */ - nCurPos = (off_t)lseek (pHandleImpl->fd, (off_t)0, SEEK_CUR); - if (nCurPos == (off_t)(-1)) - { - PERROR("ftruncate: lseek", "Out osl_setFileSize [error]\n"); - return (result); - } - - /* Try 'expand' via 'lseek()' and 'write()' */ - if (lseek (pHandleImpl->fd, (off_t)(nOffset - 1), SEEK_SET) < 0) - { - PERROR("ftruncate: lseek", "Out osl_setFileSize [error]\n"); - return (result); - } - if (write (pHandleImpl->fd, (char*)"", (size_t)1) < 0) - { - /* Failure. Restore saved position */ - PERROR("ftruncate: write", "Out osl_setFileSize [error]\n"); - if (lseek (pHandleImpl->fd, (off_t)nCurPos, SEEK_SET) < 0) - { -#ifdef DEBUG_OSL_FILE - perror("ftruncate: lseek"); -#endif /* DEBUG_OSL_FILE */ - } - return (result); - } - - /* Success. Restore saved position */ - if (lseek (pHandleImpl->fd, (off_t)nCurPos, SEEK_SET) < 0) - { - PERROR("ftruncate: lseek", "Out osl_setFileSize [error]"); - return (result); - } - } - - return (osl_File_E_None); -} - -/*###############################################*/ -oslFileError SAL_CALL osl_syncFile(oslFileHandle Handle) -{ - oslFileHandleImpl* handle_impl = (oslFileHandleImpl*)Handle; - - if (handle_impl == 0) - return osl_File_E_INVAL; - - if (fsync(handle_impl->fd) == -1) - return oslTranslateFileError(OSL_FET_ERROR, errno); - - return osl_File_E_None; -} - -/****************************************************************************** - * - * C-String Versions of Exported Module Functions - * - *****************************************************************************/ - -#ifdef HAVE_STATFS_H - -#if defined(FREEBSD) || defined(NETBSD) || defined(MACOSX) -# define __OSL_STATFS_STRUCT struct statfs -# define __OSL_STATFS(dir, sfs) statfs((dir), (sfs)) -# define __OSL_STATFS_BLKSIZ(a) ((sal_uInt64)((a).f_bsize)) -# define __OSL_STATFS_TYPENAME(a) ((a).f_fstypename) -# define __OSL_STATFS_ISREMOTE(a) (((a).f_type & MNT_LOCAL) == 0) - -/* always return true if queried for the properties of - the file system. If you think this is wrong under any - of the target platforms fix it!!!! */ -# define __OSL_STATFS_IS_CASE_SENSITIVE_FS(a) (1) -# define __OSL_STATFS_IS_CASE_PRESERVING_FS(a) (1) -#endif /* FREEBSD || NETBSD || MACOSX */ - -#if defined(LINUX) -# define __OSL_NFS_SUPER_MAGIC 0x6969 -# define __OSL_SMB_SUPER_MAGIC 0x517B -# define __OSL_MSDOS_SUPER_MAGIC 0x4d44 -# define __OSL_NTFS_SUPER_MAGIC 0x5346544e -# define __OSL_STATFS_STRUCT struct statfs -# define __OSL_STATFS(dir, sfs) statfs((dir), (sfs)) -# define __OSL_STATFS_BLKSIZ(a) ((sal_uInt64)((a).f_bsize)) -# define __OSL_STATFS_IS_NFS(a) (__OSL_NFS_SUPER_MAGIC == (a).f_type) -# define __OSL_STATFS_IS_SMB(a) (__OSL_SMB_SUPER_MAGIC == (a).f_type) -# define __OSL_STATFS_ISREMOTE(a) (__OSL_STATFS_IS_NFS((a)) || __OSL_STATFS_IS_SMB((a))) -# define __OSL_STATFS_IS_CASE_SENSITIVE_FS(a) ((__OSL_MSDOS_SUPER_MAGIC != (a).f_type) && (__OSL_NTFS_SUPER_MAGIC != (a).f_type)) -# define __OSL_STATFS_IS_CASE_PRESERVING_FS(a) ((__OSL_MSDOS_SUPER_MAGIC != (a).f_type)) -#endif /* LINUX */ - -#if defined(SOLARIS) || defined(IRIX) -# define __OSL_STATFS_STRUCT struct statvfs -# define __OSL_STATFS(dir, sfs) statvfs((dir), (sfs)) -# define __OSL_STATFS_BLKSIZ(a) ((sal_uInt64)((a).f_frsize)) -# define __OSL_STATFS_TYPENAME(a) ((a).f_basetype) -# define __OSL_STATFS_ISREMOTE(a) (rtl_str_compare((a).f_basetype, "nfs") == 0) - -/* always return true if queried for the properties of - the file system. If you think this is wrong under any - of the target platforms fix it!!!! */ -# define __OSL_STATFS_IS_CASE_SENSITIVE_FS(a) (1) -# define __OSL_STATFS_IS_CASE_PRESERVING_FS(a) (1) -#endif /* SOLARIS || IRIX*/ - -# define __OSL_STATFS_INIT(a) (memset(&(a), 0, sizeof(__OSL_STATFS_STRUCT))) - -#else /* no statfs available */ - -# define __OSL_STATFS_STRUCT struct dummy {int i;} -# define __OSL_STATFS_INIT(a) ((void)0) -# define __OSL_STATFS(dir, sfs) (1) -# define __OSL_STATFS_ISREMOTE(sfs) (0) -# define __OSL_STATFS_IS_CASE_SENSITIVE_FS(a) (1) -# define __OSL_STATFS_IS_CASE_PRESERVING_FS(a) (1) -#endif /* HAVE_STATFS_H */ - - -static oslFileError osl_psz_getVolumeInformation ( - const sal_Char* pszDirectory, oslVolumeInfo* pInfo, sal_uInt32 uFieldMask) -{ - __OSL_STATFS_STRUCT sfs; - - if (!pInfo) - return osl_File_E_INVAL; - - __OSL_STATFS_INIT(sfs); - - pInfo->uValidFields = 0; - pInfo->uAttributes = 0; - - if ((__OSL_STATFS(pszDirectory, &sfs)) < 0) - { - oslFileError result = oslTranslateFileError(OSL_FET_ERROR, errno); + oslFileError result = pImpl->syncFile(); + if (result != osl_File_E_None) return (result); - } - - /* FIXME: how to detect the kind of storage (fixed, cdrom, ...) */ - if (uFieldMask & osl_VolumeInfo_Mask_Attributes) - { - if (__OSL_STATFS_ISREMOTE(sfs)) - pInfo->uAttributes |= osl_Volume_Attribute_Remote; - - pInfo->uValidFields |= osl_VolumeInfo_Mask_Attributes; - } - - if (uFieldMask & osl_VolumeInfo_Mask_FileSystemCaseHandling) - { - if (__OSL_STATFS_IS_CASE_SENSITIVE_FS(sfs)) - pInfo->uAttributes |= osl_Volume_Attribute_Case_Sensitive; - - if (__OSL_STATFS_IS_CASE_PRESERVING_FS(sfs)) - pInfo->uAttributes |= osl_Volume_Attribute_Case_Is_Preserved; - - pInfo->uValidFields |= osl_VolumeInfo_Mask_Attributes; - } - - pInfo->uTotalSpace = 0; - pInfo->uFreeSpace = 0; - pInfo->uUsedSpace = 0; - -#if defined(__OSL_STATFS_BLKSIZ) - - if ((uFieldMask & osl_VolumeInfo_Mask_TotalSpace) || - (uFieldMask & osl_VolumeInfo_Mask_UsedSpace)) - { - pInfo->uTotalSpace = __OSL_STATFS_BLKSIZ(sfs); - pInfo->uTotalSpace *= (sal_uInt64)(sfs.f_blocks); - pInfo->uValidFields |= osl_VolumeInfo_Mask_TotalSpace; - } - - if ((uFieldMask & osl_VolumeInfo_Mask_FreeSpace) || - (uFieldMask & osl_VolumeInfo_Mask_UsedSpace)) - { - pInfo->uFreeSpace = __OSL_STATFS_BLKSIZ(sfs); - - if (getuid() == 0) - pInfo->uFreeSpace *= (sal_uInt64)(sfs.f_bfree); - else - pInfo->uFreeSpace *= (sal_uInt64)(sfs.f_bavail); - - pInfo->uValidFields |= osl_VolumeInfo_Mask_FreeSpace; - } - -#endif /* __OSL_STATFS_BLKSIZ */ - - if ((pInfo->uValidFields & osl_VolumeInfo_Mask_TotalSpace) && - (pInfo->uValidFields & osl_VolumeInfo_Mask_FreeSpace )) - { - pInfo->uUsedSpace = pInfo->uTotalSpace - pInfo->uFreeSpace; - pInfo->uValidFields |= osl_VolumeInfo_Mask_UsedSpace; - } - - pInfo->uMaxNameLength = 0; - if (uFieldMask & osl_VolumeInfo_Mask_MaxNameLength) - { - long nLen = pathconf(pszDirectory, _PC_NAME_MAX); - if (nLen > 0) - { - pInfo->uMaxNameLength = (sal_uInt32)nLen; - pInfo->uValidFields |= osl_VolumeInfo_Mask_MaxNameLength; - } - } - - pInfo->uMaxPathLength = 0; - if (uFieldMask & osl_VolumeInfo_Mask_MaxPathLength) - { - long nLen = pathconf (pszDirectory, _PC_PATH_MAX); - if (nLen > 0) - { - pInfo->uMaxPathLength = (sal_uInt32)nLen; - pInfo->uValidFields |= osl_VolumeInfo_Mask_MaxPathLength; - } - } - -#if defined(__OSL_STATFS_TYPENAME) - - if (uFieldMask & osl_VolumeInfo_Mask_FileSystemName) - { - rtl_string2UString( - &(pInfo->ustrFileSystemName), - __OSL_STATFS_TYPENAME(sfs), - rtl_str_getLength(__OSL_STATFS_TYPENAME(sfs)), - osl_getThreadTextEncoding(), - OUSTRING_TO_OSTRING_CVTFLAGS); - OSL_ASSERT(pInfo->ustrFileSystemName != 0); - - pInfo->uValidFields |= osl_VolumeInfo_Mask_FileSystemName; - } - -#endif /* __OSL_STATFS_TYPENAME */ - - if (uFieldMask & osl_VolumeInfo_Mask_DeviceHandle) - { - /* FIXME: check also entries in mntent for the device - and fill it with correct values */ - - *pInfo->pDeviceHandle = osl_isFloppyDrive(pszDirectory); - - if (*pInfo->pDeviceHandle) - { - pInfo->uValidFields |= osl_VolumeInfo_Mask_DeviceHandle; - pInfo->uAttributes |= osl_Volume_Attribute_Removeable; - pInfo->uValidFields |= osl_VolumeInfo_Mask_Attributes; - } - } - return osl_File_E_None; -} - -/************************************* - * osl_psz_setFileAttributes - ************************************/ - -static oslFileError osl_psz_setFileAttributes( const sal_Char* pszFilePath, sal_uInt64 uAttributes ) -{ - oslFileError osl_error = osl_File_E_None; - mode_t nNewMode = 0; - - OSL_ENSURE(!(osl_File_Attribute_Hidden & uAttributes), "osl_File_Attribute_Hidden doesn't work under Unix"); - - if (uAttributes & osl_File_Attribute_OwnRead) - nNewMode |= S_IRUSR; - - if (uAttributes & osl_File_Attribute_OwnWrite) - nNewMode|=S_IWUSR; - - if (uAttributes & osl_File_Attribute_OwnExe) - nNewMode|=S_IXUSR; - - if (uAttributes & osl_File_Attribute_GrpRead) - nNewMode|=S_IRGRP; - - if (uAttributes & osl_File_Attribute_GrpWrite) - nNewMode|=S_IWGRP; - - if (uAttributes & osl_File_Attribute_GrpExe) - nNewMode|=S_IXGRP; - - if (uAttributes & osl_File_Attribute_OthRead) - nNewMode|=S_IROTH; - - if (uAttributes & osl_File_Attribute_OthWrite) - nNewMode|=S_IWOTH; - - if (uAttributes & osl_File_Attribute_OthExe) - nNewMode|=S_IXOTH; - - if (chmod(pszFilePath, nNewMode) < 0) - osl_error = oslTranslateFileError(OSL_FET_ERROR, errno); + pImpl->m_bufptr = -1, pImpl->m_buflen = 0; - return osl_error; + return pImpl->setSize (uSize); } - -/****************************************** - * osl_psz_setFileTime - *****************************************/ - -static oslFileError osl_psz_setFileTime( const sal_Char* pszFilePath, - const TimeValue* /*pCreationTime*/, - const TimeValue* pLastAccessTime, - const TimeValue* pLastWriteTime ) -{ - int nRet=0; - struct utimbuf aTimeBuffer; - struct stat aFileStat; -#ifdef DEBUG_OSL_FILE - struct tm* pTM=0; -#endif - - nRet = lstat(pszFilePath,&aFileStat); - - if ( nRet < 0 ) - { - nRet=errno; - return oslTranslateFileError(OSL_FET_ERROR, nRet); - } - -#ifdef DEBUG_OSL_FILE - fprintf(stderr,"File Times are (in localtime):\n"); - pTM=localtime(&aFileStat.st_ctime); - fprintf(stderr,"CreationTime is '%s'\n",asctime(pTM)); - pTM=localtime(&aFileStat.st_atime); - fprintf(stderr,"AccessTime is '%s'\n",asctime(pTM)); - pTM=localtime(&aFileStat.st_mtime); - fprintf(stderr,"Modification is '%s'\n",asctime(pTM)); - - fprintf(stderr,"File Times are (in UTC):\n"); - fprintf(stderr,"CreationTime is '%s'\n",ctime(&aFileStat.st_ctime)); - fprintf(stderr,"AccessTime is '%s'\n",ctime(&aTimeBuffer.actime)); - fprintf(stderr,"Modification is '%s'\n",ctime(&aTimeBuffer.modtime)); -#endif - - if ( pLastAccessTime != 0 ) - { - aTimeBuffer.actime=pLastAccessTime->Seconds; - } - else - { - aTimeBuffer.actime=aFileStat.st_atime; - } - - if ( pLastWriteTime != 0 ) - { - aTimeBuffer.modtime=pLastWriteTime->Seconds; - } - else - { - aTimeBuffer.modtime=aFileStat.st_mtime; - } - - /* mfe: Creation time not used here! */ - -#ifdef DEBUG_OSL_FILE - fprintf(stderr,"File Times are (in localtime):\n"); - pTM=localtime(&aFileStat.st_ctime); - fprintf(stderr,"CreationTime now '%s'\n",asctime(pTM)); - pTM=localtime(&aTimeBuffer.actime); - fprintf(stderr,"AccessTime now '%s'\n",asctime(pTM)); - pTM=localtime(&aTimeBuffer.modtime); - fprintf(stderr,"Modification now '%s'\n",asctime(pTM)); - - fprintf(stderr,"File Times are (in UTC):\n"); - fprintf(stderr,"CreationTime now '%s'\n",ctime(&aFileStat.st_ctime)); - fprintf(stderr,"AccessTime now '%s'\n",ctime(&aTimeBuffer.actime)); - fprintf(stderr,"Modification now '%s'\n",ctime(&aTimeBuffer.modtime)); -#endif - - nRet=utime(pszFilePath,&aTimeBuffer); - if ( nRet < 0 ) - { - nRet=errno; - return oslTranslateFileError(OSL_FET_ERROR, nRet); - } - - return osl_File_E_None; -} - - -/***************************************** - * osl_psz_removeFile - ****************************************/ - -static oslFileError osl_psz_removeFile( const sal_Char* pszPath ) -{ - int nRet=0; - struct stat aStat; - - nRet = lstat(pszPath,&aStat); - if ( nRet < 0 ) - { - nRet=errno; - return oslTranslateFileError(OSL_FET_ERROR, nRet); - } - - if ( S_ISDIR(aStat.st_mode) ) - { - return osl_File_E_ISDIR; - } - - nRet = unlink(pszPath); - if ( nRet < 0 ) - { - nRet=errno; - return oslTranslateFileError(OSL_FET_ERROR, nRet); - } - - return osl_File_E_None; -} - -/***************************************** - * osl_psz_createDirectory - ****************************************/ - -static oslFileError osl_psz_createDirectory( const sal_Char* pszPath ) -{ - int nRet=0; - int mode = S_IRWXU | S_IRWXG | S_IRWXO; - - nRet = mkdir(pszPath,mode); - - if ( nRet < 0 ) - { - nRet=errno; - return oslTranslateFileError(OSL_FET_ERROR, nRet); - } - - return osl_File_E_None; -} - -/***************************************** - * osl_psz_removeDirectory - ****************************************/ - -static oslFileError osl_psz_removeDirectory( const sal_Char* pszPath ) -{ - int nRet=0; - - nRet = rmdir(pszPath); - - if ( nRet < 0 ) - { - nRet=errno; - return oslTranslateFileError(OSL_FET_ERROR, nRet); - } - - return osl_File_E_None; -} - -/***************************************** - * oslDoMoveFile - ****************************************/ - -static oslFileError oslDoMoveFile( const sal_Char* pszPath, const sal_Char* pszDestPath) -{ - oslFileError tErr=osl_File_E_invalidError; - - tErr = osl_psz_moveFile(pszPath,pszDestPath); - if ( tErr == osl_File_E_None ) - { - return tErr; - } - - if ( tErr != osl_File_E_XDEV ) - { - return tErr; - } - - tErr=osl_psz_copyFile(pszPath,pszDestPath); - - if ( tErr != osl_File_E_None ) - { - oslFileError tErrRemove; - tErrRemove=osl_psz_removeFile(pszDestPath); - return tErr; - } - - tErr=osl_psz_removeFile(pszPath); - - return tErr; -} - -/***************************************** - * osl_psz_moveFile - ****************************************/ - -static oslFileError osl_psz_moveFile(const sal_Char* pszPath, const sal_Char* pszDestPath) -{ - - int nRet = 0; - - nRet = rename(pszPath,pszDestPath); - - if ( nRet < 0 ) - { - nRet=errno; - return oslTranslateFileError(OSL_FET_ERROR, nRet); - } - - return osl_File_E_None; -} - -/***************************************** - * osl_psz_copyFile - ****************************************/ - -static oslFileError osl_psz_copyFile( const sal_Char* pszPath, const sal_Char* pszDestPath ) -{ - time_t nAcTime=0; - time_t nModTime=0; - uid_t nUID=0; - gid_t nGID=0; - int nRet=0; - mode_t nMode=0; - struct stat aFileStat; - oslFileError tErr=osl_File_E_invalidError; - size_t nSourceSize=0; - int DestFileExists=1; - - /* mfe: does the source file really exists? */ - nRet = lstat(pszPath,&aFileStat); - - if ( nRet < 0 ) - { - nRet=errno; - return oslTranslateFileError(OSL_FET_ERROR, nRet); - } - - /* mfe: we do only copy files here! */ - if ( S_ISDIR(aFileStat.st_mode) ) - { - return osl_File_E_ISDIR; - } - - nSourceSize=(size_t)aFileStat.st_size; - nMode=aFileStat.st_mode; - nAcTime=aFileStat.st_atime; - nModTime=aFileStat.st_mtime; - nUID=aFileStat.st_uid; - nGID=aFileStat.st_gid; - - nRet = stat(pszDestPath,&aFileStat); - if ( nRet < 0 ) - { - nRet=errno; - - if ( nRet == ENOENT ) - { - DestFileExists=0; - } -/* return oslTranslateFileError(nRet);*/ - } - - /* mfe: the destination file must not be a directory! */ - if ( nRet == 0 && S_ISDIR(aFileStat.st_mode) ) - { - return osl_File_E_ISDIR; - } - else - { - /* mfe: file does not exists or is no dir */ - } - - tErr = oslDoCopy(pszPath,pszDestPath,nMode,nSourceSize,DestFileExists); - - if ( tErr != osl_File_E_None ) - { - return tErr; - } - - /* - * mfe: ignore return code - * since only the success of the copy is - * important - */ - oslChangeFileModes(pszDestPath,nMode,nAcTime,nModTime,nUID,nGID); - - return tErr; -} - - -/****************************************************************************** - * - * Utility Functions - * - *****************************************************************************/ - -/***************************************** - * oslDoCopy - ****************************************/ - -#define TMP_DEST_FILE_EXTENSION ".osl-tmp" - -static oslFileError oslDoCopy(const sal_Char* pszSourceFileName, const sal_Char* pszDestFileName, mode_t nMode, size_t nSourceSize, int DestFileExists) -{ - int nRet=0; - sal_Char pszTmpDestFile[PATH_MAX]; - size_t size_tmp_dest_buff = sizeof(pszTmpDestFile); - - /* Quick fix for #106048, the whole copy file function seems - to be erroneous anyway and needs to be rewritten. - Besides osl_copyFile is currently not used from OO/SO code. - */ - memset(pszTmpDestFile, 0, size_tmp_dest_buff); - - if ( DestFileExists ) - { - strncpy(pszTmpDestFile, pszDestFileName, size_tmp_dest_buff - 1); - - if ((strlen(pszTmpDestFile) + strlen(TMP_DEST_FILE_EXTENSION)) >= size_tmp_dest_buff) - return osl_File_E_NAMETOOLONG; - - strncat(pszTmpDestFile, TMP_DEST_FILE_EXTENSION, strlen(TMP_DEST_FILE_EXTENSION)); - - /* FIXME: what if pszTmpDestFile already exists? */ - /* with getcanonical??? */ - nRet=rename(pszDestFileName,pszTmpDestFile); - } - - /* mfe: should be S_ISREG */ - if ( !S_ISLNK(nMode) ) - { - /* copy SourceFile to DestFile */ - nRet = oslDoCopyFile(pszSourceFileName,pszDestFileName,nSourceSize, nMode); - } - /* mfe: OK redundant at the moment */ - else if ( S_ISLNK(nMode) ) - { - nRet = oslDoCopyLink(pszSourceFileName,pszDestFileName); - } - else - { - /* mfe: what to do here? */ - nRet=ENOSYS; - } - - if ( nRet > 0 && DestFileExists == 1 ) - { - unlink(pszDestFileName); - rename(pszTmpDestFile,pszDestFileName); - } - - if ( nRet > 0 ) - { - return oslTranslateFileError(OSL_FET_ERROR, nRet); - } - - if ( DestFileExists == 1 ) - { - unlink(pszTmpDestFile); - } - - return osl_File_E_None; -} - -/***************************************** - * oslChangeFileModes - ****************************************/ - -static oslFileError oslChangeFileModes( const sal_Char* pszFileName, mode_t nMode, time_t nAcTime, time_t nModTime, uid_t nUID, gid_t nGID) -{ - int nRet=0; - struct utimbuf aTimeBuffer; - - nRet = chmod(pszFileName,nMode); - if ( nRet < 0 ) - { - nRet=errno; - return oslTranslateFileError(OSL_FET_ERROR, nRet); - } - - aTimeBuffer.actime=nAcTime; - aTimeBuffer.modtime=nModTime; - nRet=utime(pszFileName,&aTimeBuffer); - if ( nRet < 0 ) - { - nRet=errno; - return oslTranslateFileError(OSL_FET_ERROR, nRet); - } - - if ( nUID != getuid() ) - { - nUID=getuid(); - } - - nRet=chown(pszFileName,nUID,nGID); - if ( nRet < 0 ) - { - nRet=errno; - - /* mfe: do not return an error here! */ - /* return oslTranslateFileError(nRet);*/ - } - - return osl_File_E_None; -} - -/***************************************** - * oslDoCopyLink - ****************************************/ - -static int oslDoCopyLink(const sal_Char* pszSourceFileName, const sal_Char* pszDestFileName) -{ - int nRet=0; - - /* mfe: if dest file is symbolic link remove the link and place the file instead (hro says so) */ - /* mfe: if source is a link copy the link and not the file it points to (hro says so) */ - sal_Char pszLinkContent[PATH_MAX]; - - pszLinkContent[0] = '\0'; - - nRet = readlink(pszSourceFileName,pszLinkContent,PATH_MAX); - - if ( nRet < 0 ) - { - nRet=errno; - return nRet; - } - else - pszLinkContent[ nRet ] = 0; - - nRet = symlink(pszLinkContent,pszDestFileName); - - if ( nRet < 0 ) - { - nRet=errno; - return nRet; - } - - return 0; -} - -/***************************************** - * oslDoCopyFile - ****************************************/ - -static int oslDoCopyFile(const sal_Char* pszSourceFileName, const sal_Char* pszDestFileName, size_t nSourceSize, mode_t mode) -{ - int SourceFileFD=0; - int DestFileFD=0; - int nRet=0; - void* pSourceFile=0; - - SourceFileFD=open(pszSourceFileName,O_RDONLY); - if ( SourceFileFD < 0 ) - { - nRet=errno; - return nRet; - } - - DestFileFD=open(pszDestFileName, O_WRONLY | O_CREAT, mode); - - if ( DestFileFD < 0 ) - { - nRet=errno; - close(SourceFileFD); - return nRet; - } - - /* HACK: because memory mapping fails on various - platforms if the size of the source file is 0 byte */ - if (0 == nSourceSize) - { - close(SourceFileFD); - close(DestFileFD); - return 0; - } - - /* FIXME doCopy: fall back code for systems not having mmap */ - /* mmap file -- open dest file -- write once -- fsync it */ - pSourceFile=mmap(0,nSourceSize,PROT_READ,MAP_PRIVATE,SourceFileFD,0); - - if ( pSourceFile == MAP_FAILED ) - { - /* it's important to set nRet before the hack - otherwise errno may be changed by lstat */ - nRet = errno; - close(SourceFileFD); - close(DestFileFD); - - return nRet; - } - - nRet = write(DestFileFD,pSourceFile,nSourceSize); - - /* #112584# if 'write' could not write the requested number of bytes - we have to fail of course; because it's not exactly specified if 'write' - sets errno if less than requested byte could be written we set nRet - explicitly to ENOSPC */ - if ((nRet < 0) || (nRet != sal::static_int_cast< int >(nSourceSize))) - { - if (nRet < 0) - nRet = errno; - else - nRet = ENOSPC; - - close(SourceFileFD); - close(DestFileFD); - munmap((char*)pSourceFile,nSourceSize); - return nRet; - } - - nRet = munmap((char*)pSourceFile,nSourceSize); - if ( nRet < 0 ) - { - nRet=errno; - close(SourceFileFD); - close(DestFileFD); - return nRet; - } - - close(SourceFileFD); - - // Removed call to 'fsync' again (#112584#) and instead - // evaluate the return value of 'close' in order to detect - // and report ENOSPC and other erronous conditions on close - if (close(DestFileFD) == -1) - return errno; - else - return 0; -} - -/***************************************** - * oslMakeUStrFromPsz - ****************************************/ - -static rtl_uString* oslMakeUStrFromPsz(const sal_Char* pszStr, rtl_uString** ustrValid) -{ - rtl_string2UString( - ustrValid, - pszStr, - rtl_str_getLength( pszStr ), - osl_getThreadTextEncoding(), - OUSTRING_TO_OSTRING_CVTFLAGS ); - OSL_ASSERT(*ustrValid != 0); - - return *ustrValid; -} - -/***************************************************************************** - * UnicodeToText - * converting unicode to text manually saves us the penalty of a temporary - * rtl_String object. - ****************************************************************************/ - -int UnicodeToText( char * buffer, size_t bufLen, const sal_Unicode * uniText, sal_Int32 uniTextLen ) -{ - rtl_UnicodeToTextConverter hConverter; - sal_uInt32 nInfo; - sal_Size nSrcChars, nDestBytes; - - /* stolen from rtl/string.c */ - hConverter = rtl_createUnicodeToTextConverter( osl_getThreadTextEncoding() ); - - nDestBytes = rtl_convertUnicodeToText( hConverter, 0, uniText, uniTextLen, - buffer, bufLen, - OUSTRING_TO_OSTRING_CVTFLAGS | RTL_UNICODETOTEXT_FLAGS_FLUSH, - &nInfo, &nSrcChars ); - - rtl_destroyUnicodeToTextConverter( hConverter ); - - if( nInfo & RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL ) - { - errno = EOVERFLOW; - return 0; - } - - /* ensure trailing '\0' */ - buffer[nDestBytes] = '\0'; - - return nDestBytes; -} - -/***************************************************************************** - TextToUnicode - - @param text - The text to convert. - - @param text_buffer_size - The number of characters. - - @param unic_text - The unicode buffer. - - @param unic_text_buffer_size - The size in characters of the unicode buffer. - - ****************************************************************************/ - -int TextToUnicode( - const char* text, - size_t text_buffer_size, - sal_Unicode* unic_text, - sal_Int32 unic_text_buffer_size) -{ - rtl_TextToUnicodeConverter hConverter; - sal_uInt32 nInfo; - sal_Size nSrcChars; - sal_Size nDestBytes; - - /* stolen from rtl/string.c */ - hConverter = rtl_createTextToUnicodeConverter(osl_getThreadTextEncoding()); - - nDestBytes = rtl_convertTextToUnicode(hConverter, - 0, - text, text_buffer_size, - unic_text, unic_text_buffer_size, - OSTRING_TO_OUSTRING_CVTFLAGS | RTL_TEXTTOUNICODE_FLAGS_FLUSH, - &nInfo, &nSrcChars); - - rtl_destroyTextToUnicodeConverter(hConverter); - - if (nInfo & RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL) - { - errno = EOVERFLOW; - return 0; - } - - /* ensure trailing '\0' */ - unic_text[nDestBytes] = '\0'; - - return nDestBytes; -} - -/****************************************************************************** - * - * GENERIC FLOPPY FUNCTIONS - * - *****************************************************************************/ - - -/***************************************** - * osl_unmountVolumeDevice - ****************************************/ - -oslFileError osl_unmountVolumeDevice( oslVolumeDeviceHandle Handle ) -{ - oslFileError tErr = osl_File_E_NOSYS; - - tErr = osl_unmountFloppy(Handle); - - /* Perhaps current working directory is set to mount point */ - - if ( tErr ) - { - sal_Char *pszHomeDir = getenv("HOME"); - - if ( pszHomeDir && strlen( pszHomeDir ) && 0 == chdir( pszHomeDir ) ) - { - /* try again */ - - tErr = osl_unmountFloppy(Handle); - - OSL_ENSURE( tErr, "osl_unmountvolumeDevice: CWD was set to volume mount point" ); - } - } - - return tErr; -} - -/***************************************** - * osl_automountVolumeDevice - ****************************************/ - -oslFileError osl_automountVolumeDevice( oslVolumeDeviceHandle Handle ) -{ - oslFileError tErr = osl_File_E_NOSYS; - - tErr = osl_mountFloppy(Handle); - - return tErr; -} - -/***************************************** - * osl_getVolumeDeviceMountPath - ****************************************/ - -oslFileError osl_getVolumeDeviceMountPath( oslVolumeDeviceHandle Handle, rtl_uString **pstrPath ) -{ - oslVolumeDeviceHandleImpl* pItem = (oslVolumeDeviceHandleImpl*) Handle; - sal_Char Buffer[PATH_MAX]; - - Buffer[0] = '\0'; - - if ( pItem == 0 || pstrPath == 0 ) - { - return osl_File_E_INVAL; - } - - if ( pItem->ident[0] != 'O' || pItem->ident[1] != 'V' || pItem->ident[2] != 'D' || pItem->ident[3] != 'H' ) - { - return osl_File_E_INVAL; - } - -#ifdef DEBUG_OSL_FILE - fprintf(stderr,"Handle is:\n"); - osl_printFloppyHandle(pItem); -#endif - - snprintf(Buffer, sizeof(Buffer), "file://%s", pItem->pszMountPoint); - -#ifdef DEBUG_OSL_FILE - fprintf(stderr,"Mount Point is: '%s'\n",Buffer); -#endif - - oslMakeUStrFromPsz(Buffer, pstrPath); - - return osl_File_E_None; -} - -/***************************************** - * osl_acquireVolumeDeviceHandle - ****************************************/ - -oslFileError SAL_CALL osl_acquireVolumeDeviceHandle( oslVolumeDeviceHandle Handle ) -{ - oslVolumeDeviceHandleImpl* pItem =(oslVolumeDeviceHandleImpl*) Handle; - - if ( pItem == 0 ) - { - return osl_File_E_INVAL; - } - - if ( pItem->ident[0] != 'O' || pItem->ident[1] != 'V' || pItem->ident[2] != 'D' || pItem->ident[3] != 'H' ) - { - return osl_File_E_INVAL; - } - - ++pItem->RefCount; - - return osl_File_E_None; -} - -/***************************************** - * osl_releaseVolumeDeviceHandle - ****************************************/ - -oslFileError osl_releaseVolumeDeviceHandle( oslVolumeDeviceHandle Handle ) -{ - oslVolumeDeviceHandleImpl* pItem =(oslVolumeDeviceHandleImpl*) Handle; - - if ( pItem == 0 ) - { - return osl_File_E_INVAL; - } - - if ( pItem->ident[0] != 'O' || pItem->ident[1] != 'V' || pItem->ident[2] != 'D' || pItem->ident[3] != 'H' ) - { - return osl_File_E_INVAL; - } - - --pItem->RefCount; - - if ( pItem->RefCount == 0 ) - { - rtl_freeMemory(pItem); - } - - return osl_File_E_None; -} - -#ifndef MACOSX - -/***************************************** - * osl_newVolumeDeviceHandleImpl - ****************************************/ - -static oslVolumeDeviceHandleImpl* osl_newVolumeDeviceHandleImpl() -{ - oslVolumeDeviceHandleImpl* pHandle; - const size_t nSizeOfHandle = sizeof(oslVolumeDeviceHandleImpl); - - pHandle = (oslVolumeDeviceHandleImpl*) rtl_allocateMemory (nSizeOfHandle); - if (pHandle != NULL) - { - pHandle->ident[0] = 'O'; - pHandle->ident[1] = 'V'; - pHandle->ident[2] = 'D'; - pHandle->ident[3] = 'H'; - pHandle->pszMountPoint[0] = '\0'; - pHandle->pszFilePath[0] = '\0'; - pHandle->pszDevice[0] = '\0'; - pHandle->RefCount = 1; - } - return pHandle; -} - -/***************************************** - * osl_freeVolumeDeviceHandleImpl - ****************************************/ - -static void osl_freeVolumeDeviceHandleImpl (oslVolumeDeviceHandleImpl* pHandle) -{ - if (pHandle != NULL) - rtl_freeMemory (pHandle); -} -#endif - -/****************************************************************************** - * - * SOLARIS FLOPPY FUNCTIONS - * - *****************************************************************************/ - -#if defined(SOLARIS) -/* compare a given devicename with the typical device names on a Solaris box */ -static sal_Bool -osl_isAFloppyDevice (const char* pDeviceName) -{ - const char* pFloppyDevice [] = { - "/dev/fd", "/dev/rfd", - "/dev/diskette", "/dev/rdiskette", - "/vol/dev/diskette", "/vol/dev/rdiskette" - }; - - int i; - for (i = 0; i < (sizeof(pFloppyDevice)/sizeof(pFloppyDevice[0])); i++) - { - if (strncmp(pDeviceName, pFloppyDevice[i], strlen(pFloppyDevice[i])) == 0) - return sal_True; - } - return sal_False; -} - -/* compare two directories whether the first may be a parent of the second. this - * does not realpath() resolving */ -static sal_Bool -osl_isAParentDirectory (const char* pParentDir, const char* pSubDir) -{ - return strncmp(pParentDir, pSubDir, strlen(pParentDir)) == 0; -} - -/* the name of the routine is obviously silly. But anyway create a - * oslVolumeDeviceHandle with correct mount point, device name and a resolved filepath - * only if pszPath points to file or directory on a floppy */ -static oslVolumeDeviceHandle -osl_isFloppyDrive(const sal_Char* pszPath) -{ - FILE* pMountTab; - struct mnttab aMountEnt; - oslVolumeDeviceHandleImpl* pHandle; - - if ((pHandle = osl_newVolumeDeviceHandleImpl()) == NULL) - { - return NULL; - } - if (realpath(pszPath, pHandle->pszFilePath) == NULL) - { - osl_freeVolumeDeviceHandleImpl (pHandle); - return NULL; - } - if ((pMountTab = fopen (MOUNTTAB, "r")) == NULL) - { - osl_freeVolumeDeviceHandleImpl (pHandle); - return NULL; - } - - while (getmntent(pMountTab, &aMountEnt) == 0) - { - const char *pMountPoint = aMountEnt.mnt_mountp; - const char *pDevice = aMountEnt.mnt_special; - if ( osl_isAParentDirectory (aMountEnt.mnt_mountp, pHandle->pszFilePath) - && osl_isAFloppyDevice (aMountEnt.mnt_special)) - { - /* skip the last item for it is the name of the disk */ - char * pc = strrchr( aMountEnt.mnt_special, '/' ); - - if ( NULL != pc ) - { - int len = pc - aMountEnt.mnt_special; - - strncpy( pHandle->pszDevice, aMountEnt.mnt_special, len ); - pHandle->pszDevice[len] = '\0'; - } - else - { - /* #106048 use save str functions to avoid buffer overflows */ - memset(pHandle->pszDevice, 0, sizeof(pHandle->pszDevice)); - strncpy(pHandle->pszDevice, aMountEnt.mnt_special, sizeof(pHandle->pszDevice) - 1); - } - - /* remember the mount point */ - memset(pHandle->pszMountPoint, 0, sizeof(pHandle->pszMountPoint)); - strncpy(pHandle->pszMountPoint, aMountEnt.mnt_mountp, sizeof(pHandle->pszMountPoint) - 1); - - fclose (pMountTab); - return pHandle; - } - } - - fclose (pMountTab); - osl_freeVolumeDeviceHandleImpl (pHandle); - return NULL; -} - -static oslFileError osl_mountFloppy(oslVolumeDeviceHandle hFloppy) -{ - FILE* pMountTab; - struct mnttab aMountEnt; - oslVolumeDeviceHandleImpl* pHandle = (oslVolumeDeviceHandleImpl*) hFloppy; - - int nRet=0; - sal_Char pszCmd[512] = ""; - - if ( pHandle == 0 ) - return osl_File_E_INVAL; - - /* FIXME: don't know what this is good for */ - if ( pHandle->ident[0] != 'O' || pHandle->ident[1] != 'V' || pHandle->ident[2] != 'D' || pHandle->ident[3] != 'H' ) - return osl_File_E_INVAL; - - snprintf(pszCmd, sizeof(pszCmd), "eject -q %s > /dev/null 2>&1", pHandle->pszDevice); - - nRet = system( pszCmd ); - - switch ( WEXITSTATUS(nRet) ) - { - case 0: - { - /* lookup the device in mount tab again */ - if ((pMountTab = fopen (MOUNTTAB, "r")) == NULL) - return osl_File_E_BUSY; - - while (getmntent(pMountTab, &aMountEnt) == 0) - { - const char *pMountPoint = aMountEnt.mnt_mountp; - const char *pDevice = aMountEnt.mnt_special; - if ( 0 == strncmp( pHandle->pszDevice, aMountEnt.mnt_special, strlen(pHandle->pszDevice) ) ) - { - memset(pHandle->pszMountPoint, 0, sizeof(pHandle->pszMountPoint)); - strncpy (pHandle->pszMountPoint, aMountEnt.mnt_mountp, sizeof(pHandle->pszMountPoint) - 1); - - fclose (pMountTab); - return osl_File_E_None; - } - } - - fclose (pMountTab); - return osl_File_E_BUSY; - } - //break; // break not necessary here, see return statements before - - case 1: - return osl_File_E_BUSY; - - default: - break; - } - - return osl_File_E_BUSY; -} - -static oslFileError osl_unmountFloppy(oslVolumeDeviceHandle hFloppy) -{ -// FILE* pMountTab; -// struct mnttab aMountEnt; - oslVolumeDeviceHandleImpl* pHandle = (oslVolumeDeviceHandleImpl*) hFloppy; - - int nRet=0; - sal_Char pszCmd[512] = ""; - - if ( pHandle == 0 ) - return osl_File_E_INVAL; - - /* FIXME: don't know what this is good for */ - if ( pHandle->ident[0] != 'O' || pHandle->ident[1] != 'V' || pHandle->ident[2] != 'D' || pHandle->ident[3] != 'H' ) - return osl_File_E_INVAL; - - snprintf(pszCmd, sizeof(pszCmd), "eject %s > /dev/null 2>&1", pHandle->pszDevice); - - nRet = system( pszCmd ); - - switch ( WEXITSTATUS(nRet) ) - { - case 0: - { - FILE* pMountTab; - struct mnttab aMountEnt; - - /* lookup if device is still in mount tab */ - if ((pMountTab = fopen (MOUNTTAB, "r")) == NULL) - return osl_File_E_BUSY; - - while (getmntent(pMountTab, &aMountEnt) == 0) - { - const char *pMountPoint = aMountEnt.mnt_mountp; - const char *pDevice = aMountEnt.mnt_special; - if ( 0 == strncmp( pHandle->pszDevice, aMountEnt.mnt_special, strlen(pHandle->pszDevice) ) ) - { - fclose (pMountTab); - return osl_File_E_BUSY; - } - } - - fclose (pMountTab); - pHandle->pszMountPoint[0] = 0; - return osl_File_E_None; - } - - //break; //break not necessary, see return statements before - - case 1: - return osl_File_E_NODEV; - - case 4: - pHandle->pszMountPoint[0] = 0; - return osl_File_E_None; - - default: - break; - } - - return osl_File_E_BUSY; -} - -#endif /* SOLARIS */ - -/****************************************************************************** - * - * LINUX FLOPPY FUNCTIONS - * - *****************************************************************************/ - -#if defined(LINUX) -static oslVolumeDeviceHandle -osl_isFloppyDrive (const sal_Char* pszPath) -{ - oslVolumeDeviceHandleImpl* pItem = osl_newVolumeDeviceHandleImpl(); - if (osl_getFloppyMountEntry(pszPath, pItem)) - return (oslVolumeDeviceHandle) pItem; - - osl_freeVolumeDeviceHandleImpl (pItem); - return 0; -} -#endif /* LINUX */ - -#if defined(LINUX) -static oslFileError osl_mountFloppy(oslVolumeDeviceHandle hFloppy) -{ - sal_Bool bRet = sal_False; - oslVolumeDeviceHandleImpl* pItem=0; - int nRet; - sal_Char pszCmd[PATH_MAX]; - const sal_Char* pszMountProg = "mount"; - sal_Char* pszSuDo = 0; - sal_Char* pszTmp = 0; - - pszCmd[0] = '\0'; - -#ifdef TRACE_OSL_FILE - fprintf(stderr,"In osl_mountFloppy\n"); -#endif - - pItem = (oslVolumeDeviceHandleImpl*) hFloppy; - - if ( pItem == 0 ) - { -#ifdef TRACE_OSL_FILE - fprintf(stderr,"Out osl_mountFloppy [pItem == 0]\n"); -#endif - - return osl_File_E_INVAL; - } - - if ( pItem->ident[0] != 'O' || pItem->ident[1] != 'V' || pItem->ident[2] != 'D' || pItem->ident[3] != 'H' ) - { -#ifdef TRACE_OSL_FILE - fprintf(stderr,"Out osl_mountFloppy [invalid handle]\n"); -#endif - return osl_File_E_INVAL; - } - - bRet = osl_isFloppyMounted(pItem); - if ( bRet == sal_True ) - { -#ifdef DEBUG_OSL_FILE - fprintf(stderr,"detected mounted floppy at '%s'\n",pItem->pszMountPoint); -#endif - return osl_File_E_BUSY; - } - - /* mfe: we can't use the mount(2) system call!!! */ - /* even if we are root */ - /* since mtab is not updated!!! */ - /* but we need it to be updated */ - /* some "magic" must be done */ - -/* nRet = mount(pItem->pszDevice,pItem->pszMountPoint,0,0,0); */ -/* if ( nRet != 0 ) */ -/* { */ -/* nRet=errno; */ -/* #ifdef DEBUG_OSL_FILE */ -/* perror("mount"); */ -/* #endif */ -/* } */ - - pszTmp = getenv("SAL_MOUNT_MOUNTPROG"); - if ( pszTmp != 0 ) - { - pszMountProg=pszTmp; - } - - pszTmp=getenv("SAL_MOUNT_SU_DO"); - if ( pszTmp != 0 ) - { - pszSuDo=pszTmp; - } - - if ( pszSuDo != 0 ) - { - snprintf(pszCmd, sizeof(pszCmd), "%s %s %s %s",pszSuDo,pszMountProg,pItem->pszDevice,pItem->pszMountPoint); - } - else - { - snprintf(pszCmd, sizeof(pszCmd), "%s %s",pszMountProg,pItem->pszMountPoint); - } - - -#ifdef DEBUG_OSL_FILE - fprintf(stderr,"executing '%s'\n",pszCmd); -#endif - - nRet = system(pszCmd); - -#ifdef DEBUG_OSL_FILE - fprintf(stderr,"call returned '%i'\n",nRet); - fprintf(stderr,"exit status is '%i'\n", WEXITSTATUS(nRet)); -#endif - - - switch ( WEXITSTATUS(nRet) ) - { - case 0: - nRet=0; - break; - - case 2: - nRet=EPERM; - break; - - case 4: - nRet=ENOENT; - break; - - case 8: - nRet=EINTR; - break; - - case 16: - nRet=EPERM; - break; - - case 32: - nRet=EBUSY; - break; - - case 64: - nRet=EAGAIN; - break; - - default: - nRet=EBUSY; - break; - } - - return ((0 == nRet) ? oslTranslateFileError(OSL_FET_SUCCESS, nRet) : oslTranslateFileError(OSL_FET_ERROR, nRet)); -} -#endif /* LINUX */ - - -#if defined(LINUX) -static oslFileError osl_unmountFloppy(oslVolumeDeviceHandle hFloppy) -{ - oslVolumeDeviceHandleImpl* pItem=0; - int nRet=0; - sal_Char pszCmd[PATH_MAX]; - sal_Char* pszTmp = 0; - sal_Char* pszSuDo = 0; - const sal_Char* pszUmountProg = "umount"; - - pszCmd[0] = '\0'; - -#ifdef TRACE_OSL_FILE - fprintf(stderr,"In osl_unmountFloppy\n"); -#endif - - pItem = (oslVolumeDeviceHandleImpl*) hFloppy; - - if ( pItem == 0 ) - { -#ifdef TRACE_OSL_FILE - fprintf(stderr,"Out osl_unmountFloppy [pItem==0]\n"); -#endif - return osl_File_E_INVAL; - } - - if ( pItem->ident[0] != 'O' || pItem->ident[1] != 'V' || pItem->ident[2] != 'D' || pItem->ident[3] != 'H' ) - { -#ifdef TRACE_OSL_FILE - fprintf(stderr,"Out osl_unmountFloppy [invalid handle]\n"); -#endif - return osl_File_E_INVAL; - } - - /* mfe: we can't use the umount(2) system call!!! */ - /* even if we are root */ - /* since mtab is not updated!!! */ - /* but we need it to be updated */ - /* some "magic" must be done */ - -/* nRet=umount(pItem->pszDevice); */ -/* if ( nRet != 0 ) */ -/* { */ -/* nRet = errno; */ - -/* #ifdef DEBUG_OSL_FILE */ -/* perror("mount"); */ -/* #endif */ -/* } */ - - - pszTmp = getenv("SAL_MOUNT_UMOUNTPROG"); - if ( pszTmp != 0 ) - { - pszUmountProg=pszTmp; - } - - pszTmp = getenv("SAL_MOUNT_SU_DO"); - if ( pszTmp != 0 ) - { - pszSuDo=pszTmp; - } - - if ( pszSuDo != 0 ) - { - snprintf(pszCmd, sizeof(pszCmd), "%s %s %s",pszSuDo,pszUmountProg,pItem->pszMountPoint); - } - else - { - snprintf(pszCmd, sizeof(pszCmd), "%s %s",pszUmountProg,pItem->pszMountPoint); - } - - -#ifdef DEBUG_OSL_FILE - fprintf(stderr,"executing '%s'\n",pszCmd); -#endif - - nRet = system(pszCmd); - -#ifdef DEBUG_OSL_FILE - fprintf(stderr,"call returned '%i'\n",nRet); - fprintf(stderr,"exit status is '%i'\n", WEXITSTATUS(nRet)); -#endif - - switch ( WEXITSTATUS(nRet) ) - { - case 0: - nRet=0; - break; - - default: - nRet=EBUSY; - break; - } - -#ifdef TRACE_OSL_FILE - fprintf(stderr,"Out osl_unmountFloppy [ok]\n"); -#endif - - return ((0 == nRet) ? oslTranslateFileError(OSL_FET_SUCCESS, nRet) : oslTranslateFileError(OSL_FET_ERROR, nRet)); - -/* return osl_File_E_None;*/ -} - -#endif /* LINUX */ - -#if defined(LINUX) -static sal_Bool -osl_getFloppyMountEntry(const sal_Char* pszPath, oslVolumeDeviceHandleImpl* pItem) -{ - struct mntent* pMountEnt; - FILE* pMountTab; - - pMountTab = setmntent (MOUNTTAB, "r"); - if (pMountTab == 0) - return sal_False; - - while ((pMountEnt = getmntent(pMountTab)) != 0) - { - if ( strncmp(pMountEnt->mnt_dir, pszPath, strlen(pMountEnt->mnt_dir)) == 0 - && strncmp(pMountEnt->mnt_fsname, "/dev/fd", strlen("/dev/fd")) == 0) - { - memset(pItem->pszMountPoint, 0, sizeof(pItem->pszMountPoint)); - strncpy(pItem->pszMountPoint, pMountEnt->mnt_dir, sizeof(pItem->pszMountPoint) - 1); - - memset(pItem->pszFilePath, 0, sizeof(pItem->pszFilePath)); - strncpy(pItem->pszFilePath, pMountEnt->mnt_dir, sizeof(pItem->pszFilePath) - 1); - - memset(pItem->pszDevice, 0, sizeof(pItem->pszDevice)); - strncpy(pItem->pszDevice, pMountEnt->mnt_fsname, sizeof(pItem->pszDevice) - 1); - - endmntent (pMountTab); - return sal_True; - } - } - - endmntent (pMountTab); - return sal_False; -} -#endif /* LINUX */ - -#if defined(LINUX) -static sal_Bool -osl_isFloppyMounted (oslVolumeDeviceHandleImpl* pDevice) -{ - oslVolumeDeviceHandleImpl aItem; - - if ( osl_getFloppyMountEntry (pDevice->pszMountPoint, &aItem) - && strcmp (aItem.pszMountPoint, pDevice->pszMountPoint) == 0 - && strcmp (aItem.pszDevice, pDevice->pszDevice) == 0) - { - return sal_True; - } - return sal_False; -} -#endif /* LINUX */ - -/****************************************************************************** - * - * IRIX FLOPPY FUNCTIONS - * - *****************************************************************************/ - -#if defined(IRIX) -static oslVolumeDeviceHandle osl_isFloppyDrive(const sal_Char* pszPath) -{ - oslVolumeDeviceHandleImpl* pItem = osl_newVolumeDeviceHandleImpl (); - sal_Bool bRet = sal_False; - -#ifdef TRACE_OSL_FILE - fprintf(stderr,"In osl_isFloppyDrive\n"); -#endif - - bRet=osl_getFloppyMountEntry(pszPath,pItem); - - if ( bRet == sal_False ) - { -#ifdef TRACE_OSL_FILE - fprintf(stderr,"Out osl_isFloppyDrive [not a floppy]\n"); -#endif - rtl_freeMemory(pItem); - return 0; - } - - -#ifdef DEBUG_OSL_FILE - osl_printFloppyHandle(pItem); -#endif -#ifdef TRACE_OSL_FILE - fprintf(stderr,"Out osl_isFloppyDrive [ok]\n"); -#endif - - return (oslVolumeDeviceHandle) pItem; -} - - -static oslFileError osl_mountFloppy(oslVolumeDeviceHandle hFloppy) -{ - sal_Bool bRet = sal_False; - oslVolumeDeviceHandleImpl* pItem=0; - int nRet; - sal_Char pszCmd[PATH_MAX]; - sal_Char* pszMountProg = "mount"; - sal_Char* pszSuDo = 0; - sal_Char* pszTmp = 0; - - pszCmd[0] = '\0'; - -#ifdef TRACE_OSL_FILE - fprintf(stderr,"In osl_mountFloppy\n"); -#endif - - pItem = (oslVolumeDeviceHandleImpl*) hFloppy; - - if ( pItem == 0 ) - { -#ifdef TRACE_OSL_FILE - fprintf(stderr,"Out osl_mountFloppy [pItem == 0]\n"); -#endif - - return osl_File_E_INVAL; - } - - if ( pItem->ident[0] != 'O' || pItem->ident[1] != 'V' || pItem->ident[2] != 'D' || pItem->ident[3] != 'H' ) - { -#ifdef TRACE_OSL_FILE - fprintf(stderr,"Out osl_mountFloppy [invalid handle]\n"); -#endif - return osl_File_E_INVAL; - } - - bRet = osl_isFloppyMounted(pItem); - if ( bRet == sal_True ) - { -#ifdef DEBUG_OSL_FILE - fprintf(stderr,"detected mounted floppy at '%s'\n",pItem->pszMountPoint); -#endif - return osl_File_E_BUSY; - } - - /* mfe: we can't use the mount(2) system call!!! */ - /* even if we are root */ - /* since mtab is not updated!!! */ - /* but we need it to be updated */ - /* some "magic" must be done */ - -/* nRet = mount(pItem->pszDevice,pItem->pszMountPoint,0,0,0); */ -/* if ( nRet != 0 ) */ -/* { */ -/* nRet=errno; */ -/* #ifdef DEBUG_OSL_FILE */ -/* perror("mount"); */ -/* #endif */ -/* } */ - - pszTmp = getenv("SAL_MOUNT_MOUNTPROG"); - if ( pszTmp != 0 ) - { - pszMountProg=pszTmp; - } - - pszTmp=getenv("SAL_MOUNT_SU_DO"); - if ( pszTmp != 0 ) - { - pszSuDo=pszTmp; - } - - if ( pszSuDo != 0 ) - { - snprintf(pszCmd, sizeof(pszCmd), "%s %s %s %s",pszSuDo,pszMountProg,pItem->pszDevice,pItem->pszMountPoint); - } - else - { - snprintf(pszCmd, sizeof(pszCmd), "%s %s",pszMountProg,pItem->pszMountPoint); - } - - -#ifdef DEBUG_OSL_FILE - fprintf(stderr,"executing '%s'\n",pszCmd); -#endif - - nRet = system(pszCmd); - -#ifdef DEBUG_OSL_FILE - fprintf(stderr,"call returned '%i'\n",nRet); - fprintf(stderr,"exit status is '%i'\n", WEXITSTATUS(nRet)); -#endif - - - switch ( WEXITSTATUS(nRet) ) - { - case 0: - nRet=0; - break; - - case 2: - nRet=EPERM; - break; - - case 4: - nRet=ENOENT; - break; - - case 8: - nRet=EINTR; - break; - - case 16: - nRet=EPERM; - break; - - case 32: - nRet=EBUSY; - break; - - case 64: - nRet=EAGAIN; - break; - - default: - nRet=EBUSY; - break; - } - - return ((0 == nRet) ? oslTranslateFileError(OSL_FET_SUCCESS, nRet) : oslTranslateFileError(OSL_FET_ERROR, nRet)); -} - -static oslFileError osl_unmountFloppy(oslVolumeDeviceHandle hFloppy) -{ - oslVolumeDeviceHandleImpl* pItem=0; - int nRet=0; - sal_Char pszCmd[PATH_MAX]; - sal_Char* pszTmp = 0; - sal_Char* pszSuDo = 0; - sal_Char* pszUmountProg = "umount"; - - pszCmd[0] = '\0'; - -#ifdef TRACE_OSL_FILE - fprintf(stderr,"In osl_unmountFloppy\n"); -#endif - - pItem = (oslVolumeDeviceHandleImpl*) hFloppy; - - if ( pItem == 0 ) - { -#ifdef TRACE_OSL_FILE - fprintf(stderr,"Out osl_unmountFloppy [pItem==0]\n"); -#endif - return osl_File_E_INVAL; - } - - if ( pItem->ident[0] != 'O' || pItem->ident[1] != 'V' || pItem->ident[2] != 'D' || pItem->ident[3] != 'H' ) - { -#ifdef TRACE_OSL_FILE - fprintf(stderr,"Out osl_unmountFloppy [invalid handle]\n"); -#endif - return osl_File_E_INVAL; - } - - /* mfe: we can't use the umount(2) system call!!! */ - /* even if we are root */ - /* since mtab is not updated!!! */ - /* but we need it to be updated */ - /* some "magic" must be done */ - -/* nRet=umount(pItem->pszDevice); */ -/* if ( nRet != 0 ) */ -/* { */ -/* nRet = errno; */ - -/* #ifdef DEBUG_OSL_FILE */ -/* perror("mount"); */ -/* #endif */ -/* } */ - - - pszTmp = getenv("SAL_MOUNT_UMOUNTPROG"); - if ( pszTmp != 0 ) - { - pszUmountProg=pszTmp; - } - - pszTmp = getenv("SAL_MOUNT_SU_DO"); - if ( pszTmp != 0 ) - { - pszSuDo=pszTmp; - } - - if ( pszSuDo != 0 ) - { - snprintf(pszCmd, sizeof(pszCmd), "%s %s %s",pszSuDo,pszUmountProg,pItem->pszMountPoint); - } - else - { - snprintf(pszCmd, sizeof(pszCmd), "%s %s",pszUmountProg,pItem->pszMountPoint); - } - - -#ifdef DEBUG_OSL_FILE - fprintf(stderr,"executing '%s'\n",pszCmd); -#endif - - nRet = system(pszCmd); - -#ifdef DEBUG_OSL_FILE - fprintf(stderr,"call returned '%i'\n",nRet); - fprintf(stderr,"exit status is '%i'\n", WEXITSTATUS(nRet)); -#endif - - switch ( WEXITSTATUS(nRet) ) - { - case 0: - nRet=0; - break; - - default: - nRet=EBUSY; - break; - } - -#ifdef TRACE_OSL_FILE - fprintf(stderr,"Out osl_unmountFloppy [ok]\n"); -#endif - - return ((0 == nRet) ? oslTranslateFileError(OSL_FET_SUCCESS, nRet) : oslTranslateFileError(OSL_FET_ERROR, nRet)); - -/* return osl_File_E_None;*/ -} - -static sal_Bool osl_getFloppyMountEntry(const sal_Char* pszPath, oslVolumeDeviceHandleImpl* pItem) -{ - struct mntent* pMountEnt=0; - sal_Char buffer[PATH_MAX]; - FILE* mntfile=0; - int nRet=0; - - buffer[0] = '\0'; - - mntfile = setmntent(MOUNTTAB,"r"); - -#ifdef TRACE_OSL_FILE - fprintf(stderr,"In osl_getFloppyMountEntry\n"); -#endif - - memset(buffer, 0, sizeof(buffer)); - strncpy(buffer, pszPath, sizeof(buffer) - 1); - -#ifdef DEBUG_OSL_FILE - fprintf(stderr,"Checking mount of %s\n",buffer); -#endif - - - if ( mntfile == 0 ) - { - nRet=errno; -#ifdef DEBUG_OSL_FILE - perror("mounttab"); -#endif -#ifdef TRACE_OSL_FILE - fprintf(stderr,"Out osl_getFloppyMountEntry [mntfile]\n"); -#endif - return sal_False; - } - - pMountEnt=getmntent(mntfile); - while ( pMountEnt != 0 ) - { -#ifdef DEBUG_OSL_FILE -/* fprintf(stderr,"mnt_fsname : %s\n",pMountEnt->mnt_fsname); */ -/* fprintf(stderr,"mnt_dir : %s\n",pMountEnt->mnt_dir); */ -/* fprintf(stderr,"mnt_type : %s\n",pMountEnt->mnt_type);*/ -#endif - if ( strcmp(pMountEnt->mnt_dir,buffer) == 0 && - strncmp(pMountEnt->mnt_fsname,"/dev/fd",strlen("/dev/fd")) == 0 ) - { - - memset(pItem->pszMountPoint, 0, sizeof(pItem->pszMountPoint)); - strncpy(pItem->pszMountPoint, pMountEnt->mnt_dir, sizeof(pItem->pszMountPoint) - 1); - - memset(pItem->pszFilePath, 0, sizeof(pItem->pszFilePath)); - strncpy(pItem->pszFilePath, pMountEnt->mnt_dir, sizeof(pItem->pszFilePath) - 1); - - memset(pItem->pszDevice, 0, sizeof(pItem->pszDevice)); - strncpy(pItem->pszDevice, pMountEnt->mnt_fsname, sizeof(pItem->pszDevice) - 1); - - fclose(mntfile); -#ifdef DEBUG_OSL_FILE - fprintf(stderr,"Mount Point found '%s'\n",pItem->pszMountPoint); -#endif -#ifdef TRACE_OSL_FILE - fprintf(stderr,"Out osl_getFloppyMountEntry [found]\n"); -#endif - return sal_True; - } -#ifdef DEBUG_OSL_FILE -/* fprintf(stderr,"=================\n");*/ -#endif - pMountEnt=getmntent(mntfile); - } - -#ifdef TRACE_OSL_FILE - fprintf(stderr,"Out osl_getFloppyMountEntry [not found]\n"); -#endif - - fclose(mntfile); - return sal_False; -} - -static sal_Bool osl_isFloppyMounted(oslVolumeDeviceHandleImpl* pDevice) -{ - sal_Char buffer[PATH_MAX]; - oslVolumeDeviceHandleImpl* pItem=0; - sal_Bool bRet=0; - - buffer[0] = '\0'; - -#ifdef TRACE_OSL_FILE - fprintf(stderr,"In osl_isFloppyMounted\n"); -#endif - - pItem = osl_newVolumeDeviceHandleImpl (); - if ( pItem == 0 ) - return osl_File_E_NOMEM; - - memset(buffer, 0, sizeof(buffer)); - strncpy(buffer, pDevice->pszMountPoint, sizeof(buffer) - 1); - -#ifdef DEBUG_OSL_FILE - fprintf(stderr,"Checking mount of %s\n",buffer); -#endif - - bRet = osl_getFloppyMountEntry(buffer,pItem); - - if ( bRet == sal_False ) - { -#ifdef TRACE_OSL_FILE - fprintf(stderr,"Out osl_isFloppyMounted [not mounted]\n"); -#endif - return sal_False; - } - - if (strcmp(pItem->pszMountPoint, pDevice->pszMountPoint) == 0 && - strcmp(pItem->pszDevice,pDevice->pszDevice) == 0) - { -#ifdef TRACE_OSL_FILE - fprintf(stderr,"Out osl_isFloppyMounted [is mounted]\n"); -#endif - rtl_freeMemory(pItem); - return sal_True; - } - -#ifdef TRACE_OSL_FILE - fprintf(stderr,"Out osl_isFloppyMounted [may be EBUSY]\n"); -#endif - - rtl_freeMemory(pItem); - return sal_False; -} -#endif /* IRIX */ - - -/* NetBSD floppy functions have to be added here. Until we have done that, - * we use the MACOSX definitions for nonexistent floppy. - * */ - -/****************************************************************************** - * - * MAC OS X FLOPPY FUNCTIONS - * - *****************************************************************************/ - -#if (defined(MACOSX) || defined(NETBSD) || defined(FREEBSD)) -static oslVolumeDeviceHandle osl_isFloppyDrive(const sal_Char* pszPath) -{ - return NULL; -} -#endif /* MACOSX */ - -#if ( defined(MACOSX) || defined(NETBSD) || defined(FREEBSD)) -static oslFileError osl_mountFloppy(oslVolumeDeviceHandle hFloppy) -{ - return osl_File_E_BUSY; -} -#endif /* MACOSX */ - -#if ( defined(MACOSX) || defined(NETBSD) || defined(FREEBSD)) -static oslFileError osl_unmountFloppy(oslVolumeDeviceHandle hFloppy) -{ - return osl_File_E_BUSY; -} -#endif /* MACOSX */ - -#if ( defined(NETBSD) || defined(FREEBSD) ) -static sal_Bool osl_getFloppyMountEntry(const sal_Char* pszPath, oslVolumeDeviceHandleImpl* pItem) -{ - return sal_False; -} -#endif /* NETBSD || FREEBSD */ - -#if ( defined(NETBSD) || defined(FREEBSD) ) -static sal_Bool osl_isFloppyMounted(oslVolumeDeviceHandleImpl* pDevice) -{ - return sal_False; -} -#endif /* NETBSD || FREEBSD */ - - -#ifdef DEBUG_OSL_FILE -static void osl_printFloppyHandle(oslVolumeDeviceHandleImpl* pItem) -{ - if (pItem == 0 ) - { - fprintf(stderr,"NULL Handle\n"); - return; - } - if ( pItem->ident[0] != 'O' || pItem->ident[1] != 'V' || pItem->ident[2] != 'D' || pItem->ident[3] != 'H' ) - { -#ifdef TRACE_OSL_FILE - fprintf(stderr,"Invalid Handle]\n"); -#endif - return; - } - - - fprintf(stderr,"MountPoint : '%s'\n",pItem->pszMountPoint); - fprintf(stderr,"FilePath : '%s'\n",pItem->pszFilePath); - fprintf(stderr,"Device : '%s'\n",pItem->pszDevice); - - return; -} -#endif - diff --git a/sal/osl/unx/file_impl.hxx b/sal/osl/unx/file_impl.hxx new file mode 100644 index 000000000000..db85b00cbfef --- /dev/null +++ b/sal/osl/unx/file_impl.hxx @@ -0,0 +1,57 @@ +/************************************************************************* + * + * 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: $ + * $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. + * + ************************************************************************/ + +#ifndef INCLUDED_FILE_IMPL_HXX +#define INCLUDED_FILE_IMPL_HXX + +#include "osl/file.h" +#include <stddef.h> + +struct DirectoryItem_Impl +{ + sal_Int32 m_RefCount; + + rtl_uString * m_ustrFilePath; /* holds native file name */ + unsigned char m_DType; + + explicit DirectoryItem_Impl( + rtl_uString * ustrFilePath, unsigned char DType = 0); + ~DirectoryItem_Impl(); + + static void * operator new(size_t n); + static void operator delete (void * p, size_t); + + void acquire(); /* @see osl_acquireDirectoryItem() */ + void release(); /* @see osl_releaseDirectoryItem() */ + + oslFileType getFileType() const; +}; + +#endif /* INCLUDED_FILE_IMPL_HXX */ diff --git a/sal/osl/unx/file_misc.cxx b/sal/osl/unx/file_misc.cxx new file mode 100644 index 000000000000..b9b2b6a23c7d --- /dev/null +++ b/sal/osl/unx/file_misc.cxx @@ -0,0 +1,1100 @@ +/************************************************************************* + * + * 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 + * + * 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 "osl/file.hxx" + +#include "osl/diagnose.h" +#include "osl/thread.h" +#include <osl/signal.h> +#include "rtl/alloc.h" + +#include "system.h" +#include "file_impl.hxx" +#include "file_error_transl.h" +#include "file_path_helper.hxx" +#include "file_url.h" +#include "uunxapi.hxx" + +#include <sys/types.h> +#include <errno.h> +#include <dirent.h> +#include <limits.h> +#include <stdio.h> +#include <string.h> +#include <unistd.h> +#include <sys/stat.h> +#include <sys/mman.h> + +#include <algorithm> + +/************************************************************************ + * ToDo + * + * - Fix: check for corresponding struct sizes in exported functions + * - check size/use of oslDirectory + * - check size/use of oslDirectoryItem + ***********************************************************************/ +/****************************************************************************** + * + * Data Type Definition + * + ******************************************************************************/ + +typedef struct +{ + rtl_uString* ustrPath; /* holds native directory path */ + DIR* pDirStruct; +} oslDirectoryImpl; + +#if 0 +/* FIXME: reintroducing this may save some extra bytes per Item */ +typedef struct +{ + rtl_uString* ustrFileName; /* holds native file name */ + rtl_uString* ustrDirPath; /* holds native dir path */ + sal_uInt32 RefCount; +} oslDirectoryItemImpl; +#endif + +DirectoryItem_Impl::DirectoryItem_Impl( + rtl_uString * ustrFilePath, unsigned char DType) + : m_RefCount (1), + m_ustrFilePath (ustrFilePath), + m_DType (DType) +{ + if (m_ustrFilePath != 0) + rtl_uString_acquire(m_ustrFilePath); +} +DirectoryItem_Impl::~DirectoryItem_Impl() +{ + if (m_ustrFilePath != 0) + rtl_uString_release(m_ustrFilePath); +} + +void * DirectoryItem_Impl::operator new(size_t n) +{ + return rtl_allocateMemory(n); +} +void DirectoryItem_Impl::operator delete(void * p, size_t) +{ + rtl_freeMemory(p); +} + +void DirectoryItem_Impl::acquire() +{ + ++m_RefCount; +} +void DirectoryItem_Impl::release() +{ + if (0 == --m_RefCount) + delete this; +} + +oslFileType DirectoryItem_Impl::getFileType() const +{ + switch (m_DType) + { +#ifdef _DIRENT_HAVE_D_TYPE + case DT_LNK: + return osl_File_Type_Link; + case DT_DIR: + return osl_File_Type_Directory; + case DT_REG: + return osl_File_Type_Regular; + case DT_FIFO: + return osl_File_Type_Fifo; + case DT_SOCK: + return osl_File_Type_Socket; + case DT_CHR: + case DT_BLK: + return osl_File_Type_Special; +#endif /* _DIRENT_HAVE_D_TYPE */ + default: + break; + } + return osl_File_Type_Unknown; +} + +/****************************************************************************** + * + * C-String Function Declarations + * + *****************************************************************************/ + +static oslFileError osl_psz_createDirectory(const sal_Char* pszPath); +static oslFileError osl_psz_removeDirectory(const sal_Char* pszPath); + +/******************************************************************* + * osl_openDirectory + ******************************************************************/ + +oslFileError SAL_CALL osl_openDirectory(rtl_uString* ustrDirectoryURL, oslDirectory* pDirectory) +{ + rtl_uString* ustrSystemPath = NULL; + oslFileError eRet; + + char path[PATH_MAX]; + + if ((0 == ustrDirectoryURL) || (0 == ustrDirectoryURL->length) || (0 == pDirectory)) + return osl_File_E_INVAL; + + /* convert file URL to system path */ + eRet = osl_getSystemPathFromFileURL_Ex(ustrDirectoryURL, &ustrSystemPath, sal_False); + + if( osl_File_E_None != eRet ) + return eRet; + + osl_systemPathRemoveSeparator(ustrSystemPath); + + /* convert unicode path to text */ + if ( UnicodeToText( path, PATH_MAX, ustrSystemPath->buffer, ustrSystemPath->length ) +#ifdef MACOSX + && macxp_resolveAlias( path, PATH_MAX ) == 0 +#endif /* MACOSX */ + ) + { + /* open directory */ + DIR *pdir = opendir( path ); + + if( pdir ) + { + /* create and initialize impl structure */ + oslDirectoryImpl* pDirImpl = (oslDirectoryImpl*) rtl_allocateMemory( sizeof(oslDirectoryImpl) ); + + if( pDirImpl ) + { + pDirImpl->pDirStruct = pdir; + pDirImpl->ustrPath = ustrSystemPath; + + *pDirectory = (oslDirectory) pDirImpl; + return osl_File_E_None; + } + else + { + errno = ENOMEM; + closedir( pdir ); + } + } + else + { +#ifdef DEBUG_OSL_FILE + perror ("osl_openDirectory"); fprintf (stderr, path); +#endif + } + } + + rtl_uString_release( ustrSystemPath ); + + return oslTranslateFileError(OSL_FET_ERROR, errno); +} + +/****************************************************************************/ +/* osl_closeDirectory */ +/****************************************************************************/ + +oslFileError SAL_CALL osl_closeDirectory( oslDirectory Directory ) +{ + oslDirectoryImpl* pDirImpl = (oslDirectoryImpl*) Directory; + oslFileError err = osl_File_E_None; + + OSL_ASSERT( Directory ); + + if( NULL == pDirImpl ) + return osl_File_E_INVAL; + + /* close directory */ + if( closedir( pDirImpl->pDirStruct ) ) + { + err = oslTranslateFileError(OSL_FET_ERROR, errno); + } + + /* cleanup members */ + rtl_uString_release( pDirImpl->ustrPath ); + + rtl_freeMemory( pDirImpl ); + + return err; +} + +/********************************************** + * osl_readdir_impl_ + * + * readdir wrapper, filters out "." and ".." + * on request + *********************************************/ + +static struct dirent* osl_readdir_impl_(DIR* pdir, sal_Bool bFilterLocalAndParentDir) +{ + struct dirent* pdirent; + + while ((pdirent = readdir(pdir)) != NULL) + { + if (bFilterLocalAndParentDir && + ((0 == strcmp(pdirent->d_name, ".")) || (0 == strcmp(pdirent->d_name, "..")))) + continue; + else + break; + } + + return pdirent; +} + +/**************************************************************************** + * osl_getNextDirectoryItem + ***************************************************************************/ + +oslFileError SAL_CALL osl_getNextDirectoryItem(oslDirectory Directory, oslDirectoryItem* pItem, sal_uInt32 /*uHint*/) +{ + oslDirectoryImpl* pDirImpl = (oslDirectoryImpl*)Directory; + rtl_uString* ustrFileName = NULL; + rtl_uString* ustrFilePath = NULL; + struct dirent* pEntry; + + OSL_ASSERT(Directory); + OSL_ASSERT(pItem); + + if ((NULL == Directory) || (NULL == pItem)) + return osl_File_E_INVAL; + + pEntry = osl_readdir_impl_(pDirImpl->pDirStruct, sal_True); + + if (NULL == pEntry) + return osl_File_E_NOENT; + + +#if defined(MACOSX) + + // convert decomposed filename to precomposed unicode + char composed_name[BUFSIZ]; + CFMutableStringRef strRef = CFStringCreateMutable (NULL, 0 ); + CFStringAppendCString( strRef, pEntry->d_name, kCFStringEncodingUTF8 ); //UTF8 is default on Mac OSX + CFStringNormalize( strRef, kCFStringNormalizationFormC ); + CFStringGetCString( strRef, composed_name, BUFSIZ, kCFStringEncodingUTF8 ); + CFRelease( strRef ); + rtl_string2UString( &ustrFileName, composed_name, strlen( composed_name), + osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS ); + +#else // not MACOSX + /* convert file name to unicode */ + rtl_string2UString( &ustrFileName, pEntry->d_name, strlen( pEntry->d_name ), + osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS ); + OSL_ASSERT(ustrFileName != 0); + +#endif + + osl_systemPathMakeAbsolutePath(pDirImpl->ustrPath, ustrFileName, &ustrFilePath); + rtl_uString_release( ustrFileName ); + + DirectoryItem_Impl * pImpl = static_cast< DirectoryItem_Impl* >(*pItem); + if (0 != pImpl) + { + pImpl->release(), pImpl = 0; + } +#ifdef _DIRENT_HAVE_D_TYPE + pImpl = new DirectoryItem_Impl(ustrFilePath, pEntry->d_type); +#else + pImpl = new DirectoryItem_Impl(ustrFilePath); +#endif /* _DIRENT_HAVE_D_TYPE */ + *pItem = pImpl; + rtl_uString_release( ustrFilePath ); + + return osl_File_E_None; +} + +/****************************************************************************/ +/* osl_getDirectoryItem */ +/****************************************************************************/ + +oslFileError SAL_CALL osl_getDirectoryItem( rtl_uString* ustrFileURL, oslDirectoryItem* pItem ) +{ + rtl_uString* ustrSystemPath = NULL; + oslFileError osl_error = osl_File_E_INVAL; + + OSL_ASSERT(ustrFileURL); + OSL_ASSERT(pItem); + + if (0 == ustrFileURL->length || NULL == pItem) + return osl_File_E_INVAL; + + osl_error = osl_getSystemPathFromFileURL_Ex(ustrFileURL, &ustrSystemPath, sal_False); + if (osl_File_E_None != osl_error) + return osl_error; + + osl_systemPathRemoveSeparator(ustrSystemPath); + + if (-1 == access_u(ustrSystemPath, F_OK)) + { + osl_error = oslTranslateFileError(OSL_FET_ERROR, errno); + } + else + { + *pItem = new DirectoryItem_Impl(ustrSystemPath); + } + rtl_uString_release(ustrSystemPath); + + return osl_error; +} + + +/****************************************************************************/ +/* osl_acquireDirectoryItem */ +/****************************************************************************/ + +oslFileError SAL_CALL osl_acquireDirectoryItem( oslDirectoryItem Item ) +{ + DirectoryItem_Impl * pImpl = static_cast< DirectoryItem_Impl* >(Item); + if (0 == pImpl) + return osl_File_E_INVAL; + + pImpl->acquire(); + return osl_File_E_None; +} + +/****************************************************************************/ +/* osl_releaseDirectoryItem */ +/****************************************************************************/ + +oslFileError SAL_CALL osl_releaseDirectoryItem( oslDirectoryItem Item ) +{ + DirectoryItem_Impl * pImpl = static_cast< DirectoryItem_Impl* >(Item); + if (0 == pImpl) + return osl_File_E_INVAL; + + pImpl->release(); + return osl_File_E_None; +} + +/****************************************************************************/ +/* osl_createDirectory */ +/****************************************************************************/ + +oslFileError SAL_CALL osl_createDirectory( rtl_uString* ustrDirectoryURL ) +{ + char path[PATH_MAX]; + oslFileError eRet; + + OSL_ASSERT( ustrDirectoryURL ); + + /* convert directory url to system path */ + eRet = FileURLToPath( path, PATH_MAX, ustrDirectoryURL ); + if( eRet != osl_File_E_None ) + return eRet; + +#ifdef MACOSX + if ( macxp_resolveAlias( path, PATH_MAX ) != 0 ) + return oslTranslateFileError( OSL_FET_ERROR, errno ); +#endif/* MACOSX */ + + return osl_psz_createDirectory( path ); +} + +/****************************************************************************/ +/* osl_removeDirectory */ +/****************************************************************************/ + +oslFileError SAL_CALL osl_removeDirectory( rtl_uString* ustrDirectoryURL ) +{ + char path[PATH_MAX]; + oslFileError eRet; + + OSL_ASSERT( ustrDirectoryURL ); + + /* convert directory url to system path */ + eRet = FileURLToPath( path, PATH_MAX, ustrDirectoryURL ); + if( eRet != osl_File_E_None ) + return eRet; + +#ifdef MACOSX + if ( macxp_resolveAlias( path, PATH_MAX ) != 0 ) + return oslTranslateFileError( OSL_FET_ERROR, errno ); +#endif/* MACOSX */ + + return osl_psz_removeDirectory( path ); +} + +/***************************************** + * osl_psz_createDirectory + ****************************************/ + +static oslFileError osl_psz_createDirectory( const sal_Char* pszPath ) +{ + int nRet=0; + int mode = S_IRWXU | S_IRWXG | S_IRWXO; + + nRet = mkdir(pszPath,mode); + + if ( nRet < 0 ) + { + nRet=errno; + return oslTranslateFileError(OSL_FET_ERROR, nRet); + } + + return osl_File_E_None; +} + +/***************************************** + * osl_psz_removeDirectory + ****************************************/ + +static oslFileError osl_psz_removeDirectory( const sal_Char* pszPath ) +{ + int nRet=0; + + nRet = rmdir(pszPath); + + if ( nRet < 0 ) + { + nRet=errno; + return oslTranslateFileError(OSL_FET_ERROR, nRet); + } + + return osl_File_E_None; +} + +/****************************************************************************/ +/* osl_createDirectoryPath */ +/****************************************************************************/ + +static int path_make_parent(sal_Unicode* path) +{ + int i = rtl_ustr_lastIndexOfChar(path, '/'); + + if (i > 0) + { + *(path + i) = 0; + return i; + } + else + return 0; +} + +static int create_dir_with_callback( + sal_Unicode* directory_path, + oslDirectoryCreationCallbackFunc aDirectoryCreationCallbackFunc, + void* pData) +{ + int mode = S_IRWXU | S_IRWXG | S_IRWXO; + + if (osl::mkdir(directory_path, mode) == 0) + { + if (aDirectoryCreationCallbackFunc) + { + rtl::OUString url; + osl::FileBase::getFileURLFromSystemPath(directory_path, url); + aDirectoryCreationCallbackFunc(pData, url.pData); + } + return 0; + } + return errno; +} + +static oslFileError create_dir_recursively_( + sal_Unicode* dir_path, + oslDirectoryCreationCallbackFunc aDirectoryCreationCallbackFunc, + void* pData) +{ + OSL_PRECOND((rtl_ustr_getLength(dir_path) > 0) && ((dir_path + (rtl_ustr_getLength(dir_path) - 1)) != (dir_path + rtl_ustr_lastIndexOfChar(dir_path, '/'))), \ + "Path must not end with a slash"); + + int native_err = create_dir_with_callback( + dir_path, aDirectoryCreationCallbackFunc, pData); + + if (native_err == 0) + return osl_File_E_None; + + if (native_err != ENOENT) + return oslTranslateFileError(OSL_FET_ERROR, native_err); + + // we step back until '/a_dir' at maximum because + // we should get an error unequal ENOENT when + // we try to create 'a_dir' at '/' and would so + // return before + int pos = path_make_parent(dir_path); + + oslFileError osl_error = create_dir_recursively_( + dir_path, aDirectoryCreationCallbackFunc, pData); + + if (osl_File_E_None != osl_error) + return osl_error; + + dir_path[pos] = '/'; + + return create_dir_recursively_(dir_path, aDirectoryCreationCallbackFunc, pData); +} + +oslFileError SAL_CALL osl_createDirectoryPath( + rtl_uString* aDirectoryUrl, + oslDirectoryCreationCallbackFunc aDirectoryCreationCallbackFunc, + void* pData) +{ + if (aDirectoryUrl == NULL) + return osl_File_E_INVAL; + + rtl::OUString sys_path; + oslFileError osl_error = osl_getSystemPathFromFileURL_Ex( + aDirectoryUrl, &sys_path.pData, sal_False); + + if (osl_error != osl_File_E_None) + return osl_error; + + osl::systemPathRemoveSeparator(sys_path); + + // const_cast because sys_path is a local copy which we want to modify inplace instead of + // coyp it into another buffer on the heap again + return create_dir_recursively_(sys_path.pData->buffer, aDirectoryCreationCallbackFunc, pData); +} + +/****************************************************************************** + * + * C-String Function Declarations + * + *****************************************************************************/ + +static oslFileError osl_psz_removeFile(const sal_Char* pszPath); +static oslFileError osl_psz_copyFile(const sal_Char* pszPath, const sal_Char* pszDestPath); +static oslFileError osl_psz_moveFile(const sal_Char* pszPath, const sal_Char* pszDestPath); + + +/****************************************************************************** + * + * Static Module Utility Function Declarations + * + *****************************************************************************/ + +static oslFileError oslDoCopy(const sal_Char* pszSourceFileName, const sal_Char* pszDestFileName, mode_t nMode, size_t nSourceSize, int DestFileExists); +static oslFileError oslChangeFileModes(const sal_Char* pszFileName, mode_t nMode, time_t nAcTime, time_t nModTime, uid_t nUID, gid_t nGID); +static int oslDoCopyLink(const sal_Char* pszSourceFileName, const sal_Char* pszDestFileName); +static int oslDoCopyFile(const sal_Char* pszSourceFileName, const sal_Char* pszDestFileName, size_t nSourceSize, mode_t mode); +static oslFileError oslDoMoveFile(const sal_Char* pszPath, const sal_Char* pszDestPath); + +/****************************************************************************/ +/* osl_moveFile */ +/****************************************************************************/ + +oslFileError SAL_CALL osl_moveFile( rtl_uString* ustrFileURL, rtl_uString* ustrDestURL ) +{ + char srcPath[PATH_MAX]; + char destPath[PATH_MAX]; + oslFileError eRet; + + OSL_ASSERT( ustrFileURL ); + OSL_ASSERT( ustrDestURL ); + + /* convert source url to system path */ + eRet = FileURLToPath( srcPath, PATH_MAX, ustrFileURL ); + if( eRet != osl_File_E_None ) + return eRet; + + /* convert destination url to system path */ + eRet = FileURLToPath( destPath, PATH_MAX, ustrDestURL ); + if( eRet != osl_File_E_None ) + return eRet; + +#ifdef MACOSX + if ( macxp_resolveAlias( srcPath, PATH_MAX ) != 0 || macxp_resolveAlias( destPath, PATH_MAX ) != 0 ) + return oslTranslateFileError( OSL_FET_ERROR, errno ); +#endif/* MACOSX */ + + return oslDoMoveFile( srcPath, destPath ); +} + +/****************************************************************************/ +/* osl_copyFile */ +/****************************************************************************/ + +oslFileError SAL_CALL osl_copyFile( rtl_uString* ustrFileURL, rtl_uString* ustrDestURL ) +{ + char srcPath[PATH_MAX]; + char destPath[PATH_MAX]; + oslFileError eRet; + + OSL_ASSERT( ustrFileURL ); + OSL_ASSERT( ustrDestURL ); + + /* convert source url to system path */ + eRet = FileURLToPath( srcPath, PATH_MAX, ustrFileURL ); + if( eRet != osl_File_E_None ) + return eRet; + + /* convert destination url to system path */ + eRet = FileURLToPath( destPath, PATH_MAX, ustrDestURL ); + if( eRet != osl_File_E_None ) + return eRet; + +#ifdef MACOSX + if ( macxp_resolveAlias( srcPath, PATH_MAX ) != 0 || macxp_resolveAlias( destPath, PATH_MAX ) != 0 ) + return oslTranslateFileError( OSL_FET_ERROR, errno ); +#endif/* MACOSX */ + + return osl_psz_copyFile( srcPath, destPath ); +} + +/****************************************************************************/ +/* osl_removeFile */ +/****************************************************************************/ + +oslFileError SAL_CALL osl_removeFile( rtl_uString* ustrFileURL ) +{ + char path[PATH_MAX]; + oslFileError eRet; + + OSL_ASSERT( ustrFileURL ); + + /* convert file url to system path */ + eRet = FileURLToPath( path, PATH_MAX, ustrFileURL ); + if( eRet != osl_File_E_None ) + return eRet; + +#ifdef MACOSX + if ( macxp_resolveAlias( path, PATH_MAX ) != 0 ) + return oslTranslateFileError( OSL_FET_ERROR, errno ); +#endif/* MACOSX */ + + return osl_psz_removeFile( path ); +} + +/****************************************************************************** + * + * Utility Functions + * + *****************************************************************************/ + +/***************************************** + * oslDoMoveFile + ****************************************/ + +static oslFileError oslDoMoveFile( const sal_Char* pszPath, const sal_Char* pszDestPath) +{ + oslFileError tErr=osl_File_E_invalidError; + + tErr = osl_psz_moveFile(pszPath,pszDestPath); + if ( tErr == osl_File_E_None ) + { + return tErr; + } + + if ( tErr != osl_File_E_XDEV ) + { + return tErr; + } + + tErr=osl_psz_copyFile(pszPath,pszDestPath); + + if ( tErr != osl_File_E_None ) + { + oslFileError tErrRemove; + tErrRemove=osl_psz_removeFile(pszDestPath); + return tErr; + } + + tErr=osl_psz_removeFile(pszPath); + + return tErr; +} + +/***************************************** + * osl_psz_removeFile + ****************************************/ +static oslFileError osl_psz_removeFile( const sal_Char* pszPath ) +{ + int nRet=0; + struct stat aStat; + + nRet = lstat(pszPath,&aStat); + if ( nRet < 0 ) + { + nRet=errno; + return oslTranslateFileError(OSL_FET_ERROR, nRet); + } + + if ( S_ISDIR(aStat.st_mode) ) + { + return osl_File_E_ISDIR; + } + + nRet = unlink(pszPath); + if ( nRet < 0 ) + { + nRet=errno; + return oslTranslateFileError(OSL_FET_ERROR, nRet); + } + + return osl_File_E_None; +} + +/***************************************** + * osl_psz_moveFile + ****************************************/ + +static oslFileError osl_psz_moveFile(const sal_Char* pszPath, const sal_Char* pszDestPath) +{ + + int nRet = 0; + + nRet = rename(pszPath,pszDestPath); + + if ( nRet < 0 ) + { + nRet=errno; + return oslTranslateFileError(OSL_FET_ERROR, nRet); + } + + return osl_File_E_None; +} + +/***************************************** + * osl_psz_copyFile + ****************************************/ + +static oslFileError osl_psz_copyFile( const sal_Char* pszPath, const sal_Char* pszDestPath ) +{ + time_t nAcTime=0; + time_t nModTime=0; + uid_t nUID=0; + gid_t nGID=0; + int nRet=0; + mode_t nMode=0; + struct stat aFileStat; + oslFileError tErr=osl_File_E_invalidError; + size_t nSourceSize=0; + int DestFileExists=1; + + /* mfe: does the source file really exists? */ + nRet = lstat(pszPath,&aFileStat); + + if ( nRet < 0 ) + { + nRet=errno; + return oslTranslateFileError(OSL_FET_ERROR, nRet); + } + + /* mfe: we do only copy files here! */ + if ( S_ISDIR(aFileStat.st_mode) ) + { + return osl_File_E_ISDIR; + } + + nSourceSize=(size_t)aFileStat.st_size; + nMode=aFileStat.st_mode; + nAcTime=aFileStat.st_atime; + nModTime=aFileStat.st_mtime; + nUID=aFileStat.st_uid; + nGID=aFileStat.st_gid; + + nRet = stat(pszDestPath,&aFileStat); + if ( nRet < 0 ) + { + nRet=errno; + + if ( nRet == ENOENT ) + { + DestFileExists=0; + } +/* return oslTranslateFileError(nRet);*/ + } + + /* mfe: the destination file must not be a directory! */ + if ( nRet == 0 && S_ISDIR(aFileStat.st_mode) ) + { + return osl_File_E_ISDIR; + } + else + { + /* mfe: file does not exists or is no dir */ + } + + tErr = oslDoCopy(pszPath,pszDestPath,nMode,nSourceSize,DestFileExists); + + if ( tErr != osl_File_E_None ) + { + return tErr; + } + + /* + * mfe: ignore return code + * since only the success of the copy is + * important + */ + oslChangeFileModes(pszDestPath,nMode,nAcTime,nModTime,nUID,nGID); + + return tErr; +} + + +/****************************************************************************** + * + * Utility Functions + * + *****************************************************************************/ + +/***************************************** + * oslDoCopy + ****************************************/ + +#define TMP_DEST_FILE_EXTENSION ".osl-tmp" + +static oslFileError oslDoCopy(const sal_Char* pszSourceFileName, const sal_Char* pszDestFileName, mode_t nMode, size_t nSourceSize, int DestFileExists) +{ + int nRet=0; + sal_Char pszTmpDestFile[PATH_MAX]; + size_t size_tmp_dest_buff = sizeof(pszTmpDestFile); + + /* Quick fix for #106048, the whole copy file function seems + to be erroneous anyway and needs to be rewritten. + Besides osl_copyFile is currently not used from OO/SO code. + */ + memset(pszTmpDestFile, 0, size_tmp_dest_buff); + + if ( DestFileExists ) + { + strncpy(pszTmpDestFile, pszDestFileName, size_tmp_dest_buff - 1); + + if ((strlen(pszTmpDestFile) + strlen(TMP_DEST_FILE_EXTENSION)) >= size_tmp_dest_buff) + return osl_File_E_NAMETOOLONG; + + strncat(pszTmpDestFile, TMP_DEST_FILE_EXTENSION, strlen(TMP_DEST_FILE_EXTENSION)); + + /* FIXME: what if pszTmpDestFile already exists? */ + /* with getcanonical??? */ + nRet=rename(pszDestFileName,pszTmpDestFile); + } + + /* mfe: should be S_ISREG */ + if ( !S_ISLNK(nMode) ) + { + /* copy SourceFile to DestFile */ + nRet = oslDoCopyFile(pszSourceFileName,pszDestFileName,nSourceSize, nMode); + } + /* mfe: OK redundant at the moment */ + else if ( S_ISLNK(nMode) ) + { + nRet = oslDoCopyLink(pszSourceFileName,pszDestFileName); + } + else + { + /* mfe: what to do here? */ + nRet=ENOSYS; + } + + if ( nRet > 0 && DestFileExists == 1 ) + { + unlink(pszDestFileName); + rename(pszTmpDestFile,pszDestFileName); + } + + if ( nRet > 0 ) + { + return oslTranslateFileError(OSL_FET_ERROR, nRet); + } + + if ( DestFileExists == 1 ) + { + unlink(pszTmpDestFile); + } + + return osl_File_E_None; +} + +/***************************************** + * oslChangeFileModes + ****************************************/ + +static oslFileError oslChangeFileModes( const sal_Char* pszFileName, mode_t nMode, time_t nAcTime, time_t nModTime, uid_t nUID, gid_t nGID) +{ + int nRet=0; + struct utimbuf aTimeBuffer; + + nRet = chmod(pszFileName,nMode); + if ( nRet < 0 ) + { + nRet=errno; + return oslTranslateFileError(OSL_FET_ERROR, nRet); + } + + aTimeBuffer.actime=nAcTime; + aTimeBuffer.modtime=nModTime; + nRet=utime(pszFileName,&aTimeBuffer); + if ( nRet < 0 ) + { + nRet=errno; + return oslTranslateFileError(OSL_FET_ERROR, nRet); + } + + if ( nUID != getuid() ) + { + nUID=getuid(); + } + + nRet=chown(pszFileName,nUID,nGID); + if ( nRet < 0 ) + { + nRet=errno; + + /* mfe: do not return an error here! */ + /* return oslTranslateFileError(nRet);*/ + } + + return osl_File_E_None; +} + +/***************************************** + * oslDoCopyLink + ****************************************/ + +static int oslDoCopyLink(const sal_Char* pszSourceFileName, const sal_Char* pszDestFileName) +{ + int nRet=0; + + /* mfe: if dest file is symbolic link remove the link and place the file instead (hro says so) */ + /* mfe: if source is a link copy the link and not the file it points to (hro says so) */ + sal_Char pszLinkContent[PATH_MAX]; + + pszLinkContent[0] = '\0'; + + nRet = readlink(pszSourceFileName,pszLinkContent,PATH_MAX); + + if ( nRet < 0 ) + { + nRet=errno; + return nRet; + } + else + pszLinkContent[ nRet ] = 0; + + nRet = symlink(pszLinkContent,pszDestFileName); + + if ( nRet < 0 ) + { + nRet=errno; + return nRet; + } + + return 0; +} + +/***************************************** + * oslDoCopyFile + ****************************************/ + +static int oslDoCopyFile(const sal_Char* pszSourceFileName, const sal_Char* pszDestFileName, size_t nSourceSize, mode_t mode) +{ + int SourceFileFD=0; + int DestFileFD=0; + int nRet=0; + + SourceFileFD=open(pszSourceFileName,O_RDONLY); + if ( SourceFileFD < 0 ) + { + nRet=errno; + return nRet; + } + + // read and lseek are used to check the possibility to access the data + // not a nice solution, but it allows to avoid a crash in case it is an opened samba file + // generally, reading of one byte should not affect the performance + char nCh; + if ( 1 != read( SourceFileFD, &nCh, 1 ) + || -1 == lseek( SourceFileFD, 0, SEEK_SET ) ) + { + nRet = errno; + (void) close( SourceFileFD ); + return nRet; + } + + DestFileFD=open(pszDestFileName, O_WRONLY | O_CREAT, mode); + + if ( DestFileFD < 0 ) + { + nRet=errno; + close(SourceFileFD); + return nRet; + } + + /* HACK: because memory mapping fails on various + platforms if the size of the source file is 0 byte */ + if (0 == nSourceSize) + { + close(SourceFileFD); + close(DestFileFD); + return 0; + } + + size_t nWritten = 0; + size_t nRemains = nSourceSize; + + /* mmap file -- open dest file -- write -- fsync it at the end */ + void* pSourceFile = mmap( 0, nSourceSize, PROT_READ, MAP_SHARED, SourceFileFD, 0 ); + if ( pSourceFile != MAP_FAILED ) + { + nWritten = write( DestFileFD, pSourceFile, nSourceSize ); + nRemains -= nWritten; + munmap( (char*)pSourceFile, nSourceSize ); + } + + if ( nRemains ) + { + /* mmap has problems, try the direct streaming */ + char pBuffer[32000]; + size_t nRead = 0; + + nRemains = nSourceSize; + + if ( -1 != lseek( SourceFileFD, 0, SEEK_SET ) + && -1 != lseek( DestFileFD, 0, SEEK_SET ) ) + { + do + { + nRead = 0; + nWritten = 0; + + size_t nToRead = std::min( (size_t)32000, nRemains ); + nRead = read( SourceFileFD, pBuffer, nToRead ); + if ( (size_t)-1 != nRead ) + nWritten = write( DestFileFD, pBuffer, nRead ); + + if ( (size_t)-1 != nWritten ) + nRemains -= nWritten; + } + while( nRemains && (size_t)-1 != nRead && nRead == nWritten ); + } + } + + if ( nRemains ) + { + if ( errno ) + nRet = errno; + else + nRet = ENOSPC; + } + + close( SourceFileFD ); + if ( close( DestFileFD ) == -1 && nRet == 0 ) + nRet = errno; + + return nRet; +} + diff --git a/sal/osl/unx/file_path_helper.cxx b/sal/osl/unx/file_path_helper.cxx index 0f6ad9e216ad..434a5a516e5c 100644 --- a/sal/osl/unx/file_path_helper.cxx +++ b/sal/osl/unx/file_path_helper.cxx @@ -125,16 +125,6 @@ } /****************************************** - * osl_systemPathIsAbsolutePath - *****************************************/ - - sal_Bool SAL_CALL osl_systemPathIsAbsolutePath(const rtl_uString* pustrPath) - { - OSL_PRECOND(pustrPath, "osl_systemPathIsAbsolutePath: Invalid parameter"); - return (!osl_systemPathIsRelativePath(pustrPath)); - } - - /****************************************** osl_systemPathMakeAbsolutePath *****************************************/ diff --git a/sal/osl/unx/file_path_helper.h b/sal/osl/unx/file_path_helper.h index 17c6f0b71fba..3a89077e5633 100644 --- a/sal/osl/unx/file_path_helper.h +++ b/sal/osl/unx/file_path_helper.h @@ -105,23 +105,6 @@ const rtl_uString* pustrPath); /****************************************** - osl_systemPathIsAbsolutePath - Returns true if the given path is an - absolute path and so starts with a '/' - - @param pustrPath [in] a system path - pustrPath must not be NULL - - @returns sal_True if the given path - start's with a separator else - sal_False will be returned - - *****************************************/ - - sal_Bool SAL_CALL osl_systemPathIsAbsolutePath( - const rtl_uString* pustrPath); - - /****************************************** osl_systemPathMakeAbsolutePath Append a relative path to a base path diff --git a/sal/osl/unx/file_path_helper.hxx b/sal/osl/unx/file_path_helper.hxx index ee38c14648c2..2a1d74687493 100644 --- a/sal/osl/unx/file_path_helper.hxx +++ b/sal/osl/unx/file_path_helper.hxx @@ -106,25 +106,6 @@ namespace osl } /****************************************** - systemPathIsAbsolutePath - Returns true if the given path is an - absolute path and so starts with a '/' - - @param pustrPath [in] a system path - pustrPath must not be NULL - - @returns sal_True if the given path - start's with a separator else - sal_False will be returned - - *****************************************/ - - inline bool systemPathIsAbsolutePath(const rtl::OUString& Path) - { - return osl_systemPathIsAbsolutePath(Path.pData); - } - - /****************************************** systemPathMakeAbsolutePath Append a relative path to a base path diff --git a/sal/osl/unx/file_stat.cxx b/sal/osl/unx/file_stat.cxx index ec8cead84620..d56c2a1fad6a 100644 --- a/sal/osl/unx/file_stat.cxx +++ b/sal/osl/unx/file_stat.cxx @@ -31,31 +31,20 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sal.hxx" -#ifndef _TYPES_H -#include <sys/types.h> -#endif +#include "osl/file.h" -#ifndef _LIMITS_H +#include "system.h" +#include <sys/types.h> +#include <dirent.h> +#include <errno.h> #include <limits.h> -#endif - -#ifndef _UNISTD_H #include <unistd.h> -#endif -#include <osl/file.h> - -#ifndef _ERRNO_H -#include <errno.h> -#endif - -#include <rtl/string.hxx> -#ifndef _OSL_UUNXAPI_H_ -#include "uunxapi.hxx" -#endif -#include "file_path_helper.hxx" +#include "file_impl.hxx" #include "file_error_transl.h" - +#include "file_path_helper.hxx" +#include "file_url.h" +#include "uunxapi.hxx" namespace /* private */ { @@ -223,9 +212,10 @@ namespace /* private */ /* we only need to call stat or lstat if one of the following flags is set */ - inline bool is_stat_call_necessary(sal_uInt32 field_mask) + inline bool is_stat_call_necessary(sal_uInt32 field_mask, oslFileType file_type = osl_File_Type_Unknown) { - return ((field_mask & osl_FileStatus_Mask_Type) || + return ( + ((field_mask & osl_FileStatus_Mask_Type) && (file_type == osl_File_Type_Unknown)) || (field_mask & osl_FileStatus_Mask_Attributes) || (field_mask & osl_FileStatus_Mask_CreationTime) || (field_mask & osl_FileStatus_Mask_AccessTime) || @@ -249,20 +239,18 @@ namespace /* private */ return osl_File_E_None; } - inline oslFileError setup_osl_getFileStatus(oslDirectoryItem Item, oslFileStatus* pStat, rtl::OUString& file_path) + inline oslFileError setup_osl_getFileStatus( + DirectoryItem_Impl * pImpl, oslFileStatus* pStat, rtl::OUString& file_path) { - if ((NULL == Item) || (NULL == pStat)) + if ((NULL == pImpl) || (NULL == pStat)) return osl_File_E_INVAL; - file_path = rtl::OUString(reinterpret_cast<rtl_uString*>(Item)); - + file_path = rtl::OUString(pImpl->m_ustrFilePath); OSL_ASSERT(file_path.getLength() > 0); - if (file_path.getLength() <= 0) return osl_File_E_INVAL; pStat->uValidFields = 0; - return osl_File_E_None; } @@ -275,8 +263,10 @@ namespace /* private */ oslFileError SAL_CALL osl_getFileStatus(oslDirectoryItem Item, oslFileStatus* pStat, sal_uInt32 uFieldMask) { + DirectoryItem_Impl * pImpl = static_cast< DirectoryItem_Impl* >(Item); + rtl::OUString file_path; - oslFileError osl_error = setup_osl_getFileStatus(Item, pStat, file_path); + oslFileError osl_error = setup_osl_getFileStatus(pImpl, pStat, file_path); if (osl_File_E_None != osl_error) return osl_error; @@ -285,10 +275,12 @@ oslFileError SAL_CALL osl_getFileStatus(oslDirectoryItem Item, oslFileStatus* pS #else struct stat file_stat; #endif - if (is_stat_call_necessary(uFieldMask) && (0 != osl::lstat(file_path, file_stat))) + + bool bStatNeeded = is_stat_call_necessary(uFieldMask, pImpl->getFileType()); + if (bStatNeeded && (0 != osl::lstat(file_path, file_stat))) return oslTranslateFileError(OSL_FET_ERROR, errno); - if (is_stat_call_necessary(uFieldMask)) + if (bStatNeeded) { // we set all these attributes because it's cheap set_file_type(file_stat, pStat); @@ -305,6 +297,13 @@ oslFileError SAL_CALL osl_getFileStatus(oslDirectoryItem Item, oslFileStatus* pS return osl_error; } } +#ifdef _DIRENT_HAVE_D_TYPE + else if (uFieldMask & osl_FileStatus_Mask_Type) + { + pStat->eType = pImpl->getFileType(); + pStat->uValidFields |= osl_FileStatus_Mask_Type; + } +#endif /* _DIRENT_HAVE_D_TYPE */ if (uFieldMask & osl_FileStatus_Mask_FileURL) { @@ -322,3 +321,175 @@ oslFileError SAL_CALL osl_getFileStatus(oslDirectoryItem Item, oslFileStatus* pS return osl_File_E_None; } +/****************************************************************************/ +/* osl_setFileAttributes */ +/****************************************************************************/ + +static oslFileError osl_psz_setFileAttributes( const sal_Char* pszFilePath, sal_uInt64 uAttributes ) +{ + oslFileError osl_error = osl_File_E_None; + mode_t nNewMode = 0; + + OSL_ENSURE(!(osl_File_Attribute_Hidden & uAttributes), "osl_File_Attribute_Hidden doesn't work under Unix"); + + if (uAttributes & osl_File_Attribute_OwnRead) + nNewMode |= S_IRUSR; + + if (uAttributes & osl_File_Attribute_OwnWrite) + nNewMode|=S_IWUSR; + + if (uAttributes & osl_File_Attribute_OwnExe) + nNewMode|=S_IXUSR; + + if (uAttributes & osl_File_Attribute_GrpRead) + nNewMode|=S_IRGRP; + + if (uAttributes & osl_File_Attribute_GrpWrite) + nNewMode|=S_IWGRP; + + if (uAttributes & osl_File_Attribute_GrpExe) + nNewMode|=S_IXGRP; + + if (uAttributes & osl_File_Attribute_OthRead) + nNewMode|=S_IROTH; + + if (uAttributes & osl_File_Attribute_OthWrite) + nNewMode|=S_IWOTH; + + if (uAttributes & osl_File_Attribute_OthExe) + nNewMode|=S_IXOTH; + + if (chmod(pszFilePath, nNewMode) < 0) + osl_error = oslTranslateFileError(OSL_FET_ERROR, errno); + + return osl_error; +} + +oslFileError SAL_CALL osl_setFileAttributes( rtl_uString* ustrFileURL, sal_uInt64 uAttributes ) +{ + char path[PATH_MAX]; + oslFileError eRet; + + OSL_ASSERT( ustrFileURL ); + + /* convert file url to system path */ + eRet = FileURLToPath( path, PATH_MAX, ustrFileURL ); + if( eRet != osl_File_E_None ) + return eRet; + +#ifdef MACOSX + if ( macxp_resolveAlias( path, PATH_MAX ) != 0 ) + return oslTranslateFileError( OSL_FET_ERROR, errno ); +#endif/* MACOSX */ + + return osl_psz_setFileAttributes( path, uAttributes ); +} + +/****************************************************************************/ +/* osl_setFileTime */ +/****************************************************************************/ + +static oslFileError osl_psz_setFileTime ( + const sal_Char* pszFilePath, + const TimeValue* /*pCreationTime*/, + const TimeValue* pLastAccessTime, + const TimeValue* pLastWriteTime ) +{ + int nRet=0; + struct utimbuf aTimeBuffer; + struct stat aFileStat; +#ifdef DEBUG_OSL_FILE + struct tm* pTM=0; +#endif + + nRet = lstat(pszFilePath,&aFileStat); + + if ( nRet < 0 ) + { + nRet=errno; + return oslTranslateFileError(OSL_FET_ERROR, nRet); + } + +#ifdef DEBUG_OSL_FILE + fprintf(stderr,"File Times are (in localtime):\n"); + pTM=localtime(&aFileStat.st_ctime); + fprintf(stderr,"CreationTime is '%s'\n",asctime(pTM)); + pTM=localtime(&aFileStat.st_atime); + fprintf(stderr,"AccessTime is '%s'\n",asctime(pTM)); + pTM=localtime(&aFileStat.st_mtime); + fprintf(stderr,"Modification is '%s'\n",asctime(pTM)); + + fprintf(stderr,"File Times are (in UTC):\n"); + fprintf(stderr,"CreationTime is '%s'\n",ctime(&aFileStat.st_ctime)); + fprintf(stderr,"AccessTime is '%s'\n",ctime(&aTimeBuffer.actime)); + fprintf(stderr,"Modification is '%s'\n",ctime(&aTimeBuffer.modtime)); +#endif + + if ( pLastAccessTime != 0 ) + { + aTimeBuffer.actime=pLastAccessTime->Seconds; + } + else + { + aTimeBuffer.actime=aFileStat.st_atime; + } + + if ( pLastWriteTime != 0 ) + { + aTimeBuffer.modtime=pLastWriteTime->Seconds; + } + else + { + aTimeBuffer.modtime=aFileStat.st_mtime; + } + + /* mfe: Creation time not used here! */ + +#ifdef DEBUG_OSL_FILE + fprintf(stderr,"File Times are (in localtime):\n"); + pTM=localtime(&aFileStat.st_ctime); + fprintf(stderr,"CreationTime now '%s'\n",asctime(pTM)); + pTM=localtime(&aTimeBuffer.actime); + fprintf(stderr,"AccessTime now '%s'\n",asctime(pTM)); + pTM=localtime(&aTimeBuffer.modtime); + fprintf(stderr,"Modification now '%s'\n",asctime(pTM)); + + fprintf(stderr,"File Times are (in UTC):\n"); + fprintf(stderr,"CreationTime now '%s'\n",ctime(&aFileStat.st_ctime)); + fprintf(stderr,"AccessTime now '%s'\n",ctime(&aTimeBuffer.actime)); + fprintf(stderr,"Modification now '%s'\n",ctime(&aTimeBuffer.modtime)); +#endif + + nRet=utime(pszFilePath,&aTimeBuffer); + if ( nRet < 0 ) + { + nRet=errno; + return oslTranslateFileError(OSL_FET_ERROR, nRet); + } + + return osl_File_E_None; +} + +oslFileError SAL_CALL osl_setFileTime ( + rtl_uString* ustrFileURL, + const TimeValue* pCreationTime, + const TimeValue* pLastAccessTime, + const TimeValue* pLastWriteTime ) +{ + char path[PATH_MAX]; + oslFileError eRet; + + OSL_ASSERT( ustrFileURL ); + + /* convert file url to system path */ + eRet = FileURLToPath( path, PATH_MAX, ustrFileURL ); + if( eRet != osl_File_E_None ) + return eRet; + +#ifdef MACOSX + if ( macxp_resolveAlias( path, PATH_MAX ) != 0 ) + return oslTranslateFileError( OSL_FET_ERROR, errno ); +#endif/* MACOSX */ + + return osl_psz_setFileTime( path, pCreationTime, pLastAccessTime, pLastWriteTime ); +} diff --git a/sal/osl/unx/file_url.cxx b/sal/osl/unx/file_url.cxx index 602e8a98beac..1bcd2afb4505 100644 --- a/sal/osl/unx/file_url.cxx +++ b/sal/osl/unx/file_url.cxx @@ -30,45 +30,31 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sal.hxx" + +#include "file_url.h" + #include "system.h" -#ifndef _LIMITS_H #include <limits.h> -#endif - -#ifndef _ERRNO_H #include <errno.h> -#endif - -#ifndef _STRINGS_H #include <strings.h> -#endif - -#ifndef _UNISTD_H #include <unistd.h> -#endif -#include <osl/file.h> + +#include "osl/file.hxx" #include <osl/security.h> -#include <rtl/uri.h> #include <osl/diagnose.h> +#include <osl/thread.h> +#include <osl/process.h> + +#include <rtl/uri.h> #include <rtl/ustring.hxx> #include <rtl/ustrbuf.h> +#include "rtl/textcvt.h" -#ifndef _OSL_TREAD_H_ -#include <osl/thread.h> -#endif -#include <osl/file.hxx> -#include <osl/process.h> #include "file_error_transl.h" - -#ifndef _FILE_URL_H_ -#include "file_url.h" -#endif #include "file_path_helper.hxx" -#ifndef _OSL_UUNXAPI_HXX_ #include "uunxapi.hxx" -#endif /*************************************************** @@ -84,16 +70,14 @@ so this code should be consolidated. **************************************************/ +/************************************************************************ + * ToDo + * + * Fix osl_getCanonicalName + * + ***********************************************************************/ - -/*************************************************** - * forward - **************************************************/ - -extern "C" int UnicodeToText(char *, size_t, const sal_Unicode *, sal_Int32); -extern "C" int TextToUnicode(const char* text, size_t text_buffer_size, sal_Unicode* unic_text, sal_Int32 unic_text_buffer_size); - /*************************************************** * namespace directives **************************************************/ @@ -151,6 +135,18 @@ static sal_Bool findWrongUsage( const sal_Unicode *path, sal_Int32 len ) */ /****************************************************************************/ +/* osl_getCanonicalName */ +/****************************************************************************/ + +oslFileError SAL_CALL osl_getCanonicalName( rtl_uString* ustrFileURL, rtl_uString** pustrValidURL ) +{ + OSL_ENSURE(0, "osl_getCanonicalName not implemented"); + + rtl_uString_newFromString(pustrValidURL, ustrFileURL); + return osl_File_E_None; +} + +/****************************************************************************/ /* osl_getSystemPathFromFileURL */ /****************************************************************************/ @@ -462,39 +458,6 @@ namespace /* private */ /********************************************* ********************************************/ - sal_Unicode* ustrcpy(const sal_Unicode* s, sal_Unicode* d) - { - const sal_Unicode* sc = s; - sal_Unicode* dc = d; - - while ((*dc++ = *sc++)) - /**/; - - return d; - } - - /********************************************* - - ********************************************/ - - sal_Unicode* ustrncpy(const sal_Unicode* s, sal_Unicode* d, unsigned int n) - { - const sal_Unicode* sc = s; - sal_Unicode* dc = d; - unsigned int i = n; - - while (i--) - *dc++ = *sc++; - - if (n) - *dc = 0; - - return d; - } - - /********************************************* - - ********************************************/ sal_Unicode* ustrchrcat(const sal_Unicode chr, sal_Unicode* d) { @@ -504,17 +467,6 @@ namespace /* private */ return d; } - /********************************************* - - ********************************************/ - - sal_Unicode* ustrcat(const sal_Unicode* s, sal_Unicode* d) - { - sal_Unicode* dc = ustrtoend(d); - ustrcpy(s, dc); - return d; - } - /****************************************************** * ******************************************************/ @@ -528,18 +480,6 @@ namespace /* private */ } /****************************************************** - * Ensure that the given string has the specified last - * character if necessary append it - ******************************************************/ - - sal_Unicode* _strensurelast(sal_Unicode* pStr, sal_Unicode Chr) - { - if (!_islastchr(pStr, Chr)) - ustrchrcat(Chr, pStr); - return pStr; - } - - /****************************************************** * Remove the last part of a path, a path that has * only a '/' or no '/' at all will be returned * unmodified @@ -906,3 +846,120 @@ oslFileError FileURLToPath(char * buffer, size_t bufLen, rtl_uString* ustrFileUR return osl_error; } + +/***************************************************************************** + * UnicodeToText + ****************************************************************************/ + +namespace /* private */ +{ + class UnicodeToTextConverter_Impl + { + rtl_UnicodeToTextConverter m_converter; + + UnicodeToTextConverter_Impl() + : m_converter (rtl_createUnicodeToTextConverter (osl_getThreadTextEncoding())) + {} + + ~UnicodeToTextConverter_Impl() + { + rtl_destroyUnicodeToTextConverter (m_converter); + } + public: + static UnicodeToTextConverter_Impl & getInstance() + { + static UnicodeToTextConverter_Impl g_theConverter; + return g_theConverter; + } + + sal_Size convert( + sal_Unicode const * pSrcBuf, sal_Size nSrcChars, sal_Char * pDstBuf, sal_Size nDstBytes, + sal_uInt32 nFlags, sal_uInt32 * pInfo, sal_Size * pSrcCvtChars) + { + OSL_ASSERT(m_converter != 0); + return rtl_convertUnicodeToText ( + m_converter, 0, pSrcBuf, nSrcChars, pDstBuf, nDstBytes, nFlags, pInfo, pSrcCvtChars); + } + }; +} // end namespace private + +int UnicodeToText( char * buffer, size_t bufLen, const sal_Unicode * uniText, sal_Int32 uniTextLen ) +{ + sal_uInt32 nInfo = 0; + sal_Size nSrcChars = 0; + + sal_Size nDestBytes = UnicodeToTextConverter_Impl::getInstance().convert ( + uniText, uniTextLen, buffer, bufLen, + OUSTRING_TO_OSTRING_CVTFLAGS | RTL_UNICODETOTEXT_FLAGS_FLUSH, &nInfo, &nSrcChars); + + if( nInfo & RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL ) + { + errno = EOVERFLOW; + return 0; + } + + /* ensure trailing '\0' */ + buffer[nDestBytes] = '\0'; + return nDestBytes; +} + +/***************************************************************************** + * TextToUnicode + ****************************************************************************/ + +namespace /* private */ +{ + class TextToUnicodeConverter_Impl + { + rtl_TextToUnicodeConverter m_converter; + + TextToUnicodeConverter_Impl() + : m_converter (rtl_createTextToUnicodeConverter (osl_getThreadTextEncoding())) + {} + + ~TextToUnicodeConverter_Impl() + { + rtl_destroyTextToUnicodeConverter (m_converter); + } + + public: + static TextToUnicodeConverter_Impl & getInstance() + { + static TextToUnicodeConverter_Impl g_theConverter; + return g_theConverter; + } + + sal_Size convert( + sal_Char const * pSrcBuf, sal_Size nSrcBytes, sal_Unicode * pDstBuf, sal_Size nDstChars, + sal_uInt32 nFlags, sal_uInt32 * pInfo, sal_Size * pSrcCvtBytes) + { + OSL_ASSERT(m_converter != 0); + return rtl_convertTextToUnicode ( + m_converter, 0, pSrcBuf, nSrcBytes, pDstBuf, nDstChars, nFlags, pInfo, pSrcCvtBytes); + } + }; +} // end namespace private + +int TextToUnicode( + const char* text, + size_t text_buffer_size, + sal_Unicode* unic_text, + sal_Int32 unic_text_buffer_size) +{ + sal_uInt32 nInfo = 0; + sal_Size nSrcChars = 0; + + sal_Size nDestBytes = TextToUnicodeConverter_Impl::getInstance().convert( + text, text_buffer_size, unic_text, unic_text_buffer_size, + OSTRING_TO_OUSTRING_CVTFLAGS | RTL_TEXTTOUNICODE_FLAGS_FLUSH, &nInfo, &nSrcChars); + + if (nInfo & RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL) + { + errno = EOVERFLOW; + return 0; + } + + /* ensure trailing '\0' */ + unic_text[nDestBytes] = '\0'; + return nDestBytes; +} diff --git a/sal/osl/unx/file_url.h b/sal/osl/unx/file_url.h index 4d89239567c5..721bc9d3d698 100644 --- a/sal/osl/unx/file_url.h +++ b/sal/osl/unx/file_url.h @@ -28,43 +28,45 @@ * ************************************************************************/ - /*************************************************** - * Internal header file, declares all functions - * that are not part of the offical API and are - * not defined in the osl header files - **************************************************/ +#ifndef INCLUDED_FILE_URL_H +#define INCLUDED_FILE_URL_H - #ifndef _FILE_URL_H_ - #define _FILE_URL_H_ +#include "osl/file.h" - #ifndef _FILE_H_ - #include <osl/file.h> - #endif +#ifdef __cplusplus +extern "C" +{ +#endif - #ifdef __cplusplus - extern "C" - { - #endif +/************************************************** + * osl_getSystemPathFromFileURL_Ex + *************************************************/ - /************************************************** - * _osl_getSystemPathFromFileURL - *************************************************/ +#define FURL_ALLOW_RELATIVE sal_True +#define FURL_DENY_RELATIVE sal_False - #define FURL_ALLOW_RELATIVE sal_True - #define FURL_DENY_RELATIVE sal_False +oslFileError osl_getSystemPathFromFileURL_Ex(rtl_uString *ustrFileURL, rtl_uString **pustrSystemPath, sal_Bool bAllowRelative); - oslFileError osl_getSystemPathFromFileURL_Ex(rtl_uString *ustrFileURL, rtl_uString **pustrSystemPath, sal_Bool bAllowRelative); +/************************************************** + * FileURLToPath + *************************************************/ - /************************************************** - * FileURLToPath - *************************************************/ +oslFileError FileURLToPath(char * buffer, size_t bufLen, rtl_uString* ustrFileURL); - oslFileError FileURLToPath(char * buffer, size_t bufLen, rtl_uString* ustrFileURL); +/*************************************************** + * UnicodeToText + **************************************************/ +int UnicodeToText(char * buffer, size_t bufLen, const sal_Unicode * uniText, sal_Int32 uniTextLen); - #ifdef __cplusplus - } - #endif +/*************************************************** + * TextToUniCode + **************************************************/ +int TextToUnicode(const char* text, size_t text_buffer_size, sal_Unicode* unic_text, sal_Int32 unic_text_buffer_size); - #endif /* #define _FILE_URL_H_ */ +#ifdef __cplusplus +} +#endif + +#endif /* #define INCLUDED_FILE_URL_H */ diff --git a/sal/osl/unx/file_volume.cxx b/sal/osl/unx/file_volume.cxx new file mode 100644 index 000000000000..a3b7109123b7 --- /dev/null +++ b/sal/osl/unx/file_volume.cxx @@ -0,0 +1,1570 @@ +/************************************************************************* + * + * 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 + * + * 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 "osl/file.h" + +#include "osl/diagnose.h" +#include "osl/thread.h" +#include "rtl/alloc.h" + +#include "file_error_transl.h" +#include "file_url.h" +#include "system.h" + +#include <errno.h> +#include <limits.h> +#include <stdio.h> +#include <string.h> +#include <unistd.h> +#include <sys/wait.h> + +#ifdef HAVE_STATFS_H +#undef HAVE_STATFS_H +#endif + +#if defined(SOLARIS) + +#include <sys/mnttab.h> +#include <sys/statvfs.h> +#define HAVE_STATFS_H +#include <sys/fs/ufs_quota.h> +static const sal_Char* MOUNTTAB="/etc/mnttab"; + +#elif defined(LINUX) + +#include <mntent.h> +#include <sys/vfs.h> +#define HAVE_STATFS_H +#include <sys/quota.h> +//#include <ctype.h> +static const sal_Char* MOUNTTAB="/etc/mtab"; + +#elif defined(NETBSD) || defined(FREEBSD) + +#include <sys/param.h> +#include <sys/ucred.h> +#include <sys/mount.h> +#include <ufs/ufs/quota.h> +//#include <ctype.h> +#define HAVE_STATFS_H + +/* No mounting table on *BSD + * This information is stored only in the kernel. */ +/* static const sal_Char* MOUNTTAB="/etc/mtab"; */ + +#elif defined(IRIX) + +#include <mntent.h> +#include <sys/mount.h> +#include <sys/statvfs.h> +#define HAVE_STATFS_H +#include <sys/quota.h> +//#include <ctype.h> +static const sal_Char* MOUNTTAB="/etc/mtab"; + +#elif defined(MACOSX) + +#include <ufs/ufs/quota.h> +//#include <ctype.h> +#include <sys/param.h> +#include <sys/mount.h> +#define HAVE_STATFS_H +// static const sal_Char* MOUNTTAB="/etc/mtab"; + +#endif /* HAVE_STATFS_H */ + +/************************************************************************ + * ToDo + * + * - Fix: check for corresponding struct sizes in exported functions + * - check size/use of oslVolumeDeviceHandle + * - check size/use of oslVolumeInfo + ***********************************************************************/ +/****************************************************************************** + * + * Data Type Definition + * + ******************************************************************************/ + +typedef struct _oslVolumeDeviceHandleImpl +{ + sal_Char pszMountPoint[PATH_MAX]; + sal_Char pszFilePath[PATH_MAX]; + sal_Char pszDevice[PATH_MAX]; + sal_Char ident[4]; + sal_uInt32 RefCount; +} oslVolumeDeviceHandleImpl; + +/****************************************************************************** + * + * 'removeable device' aka floppy functions + * + *****************************************************************************/ + +static oslVolumeDeviceHandle osl_isFloppyDrive(const sal_Char* pszPath); +static oslFileError osl_mountFloppy(oslVolumeDeviceHandle hFloppy); +static oslFileError osl_unmountFloppy(oslVolumeDeviceHandle hFloppy); + +#if defined(SOLARIS) +static sal_Bool osl_isFloppyMounted(sal_Char* pszPath, sal_Char* pszMountPath); +static sal_Bool osl_getFloppyMountEntry(const sal_Char* pszPath, sal_Char* pBuffer); +static sal_Bool osl_checkFloppyPath(sal_Char* pszPath, sal_Char* pszFilePath, sal_Char* pszDevicePath); +#endif /* SOLARIS */ + +#if defined(LINUX) +static sal_Bool osl_isFloppyMounted(oslVolumeDeviceHandleImpl* pDevice); +static sal_Bool osl_getFloppyMountEntry(const sal_Char* pszPath, oslVolumeDeviceHandleImpl* pItem); +#endif /* LINUX */ + + +#if defined(IRIX) +static sal_Bool osl_isFloppyMounted(oslVolumeDeviceHandleImpl* pDevice); +static sal_Bool osl_getFloppyMountEntry(const sal_Char* pszPath, oslVolumeDeviceHandleImpl* pItem); +#endif /* IRIX */ + +#ifdef DEBUG_OSL_FILE +static void osl_printFloppyHandle(oslVolumeDeviceHandleImpl* hFloppy); +#endif /* DEBUG_OSL_FILE */ + +/****************************************************************************** + * + * C-String Function Declarations + * + *****************************************************************************/ + +static oslFileError osl_psz_getVolumeInformation(const sal_Char* , oslVolumeInfo* pInfo, sal_uInt32 uFieldMask); + +/****************************************************************************/ +/* osl_getVolumeInformation */ +/****************************************************************************/ + +oslFileError osl_getVolumeInformation( rtl_uString* ustrDirectoryURL, oslVolumeInfo* pInfo, sal_uInt32 uFieldMask ) +{ + char path[PATH_MAX]; + oslFileError eRet; + + OSL_ASSERT( ustrDirectoryURL ); + OSL_ASSERT( pInfo ); + + /* convert directory url to system path */ + eRet = FileURLToPath( path, PATH_MAX, ustrDirectoryURL ); + if( eRet != osl_File_E_None ) + return eRet; + +#ifdef MACOSX + if ( macxp_resolveAlias( path, PATH_MAX ) != 0 ) + return oslTranslateFileError( OSL_FET_ERROR, errno ); +#endif/* MACOSX */ + + return osl_psz_getVolumeInformation( path, pInfo, uFieldMask); +} + +/****************************************************************************** + * + * C-String Versions of Exported Module Functions + * + *****************************************************************************/ + +#ifdef HAVE_STATFS_H + +#if defined(FREEBSD) || defined(NETBSD) || defined(MACOSX) +# define __OSL_STATFS_STRUCT struct statfs +# define __OSL_STATFS(dir, sfs) statfs((dir), (sfs)) +# define __OSL_STATFS_BLKSIZ(a) ((sal_uInt64)((a).f_bsize)) +# define __OSL_STATFS_TYPENAME(a) ((a).f_fstypename) +# define __OSL_STATFS_ISREMOTE(a) (((a).f_type & MNT_LOCAL) == 0) + +/* always return true if queried for the properties of + the file system. If you think this is wrong under any + of the target platforms fix it!!!! */ +# define __OSL_STATFS_IS_CASE_SENSITIVE_FS(a) (1) +# define __OSL_STATFS_IS_CASE_PRESERVING_FS(a) (1) +#endif /* FREEBSD || NETBSD || MACOSX */ + +#if defined(LINUX) +# define __OSL_NFS_SUPER_MAGIC 0x6969 +# define __OSL_SMB_SUPER_MAGIC 0x517B +# define __OSL_MSDOS_SUPER_MAGIC 0x4d44 +# define __OSL_NTFS_SUPER_MAGIC 0x5346544e +# define __OSL_STATFS_STRUCT struct statfs +# define __OSL_STATFS(dir, sfs) statfs((dir), (sfs)) +# define __OSL_STATFS_BLKSIZ(a) ((sal_uInt64)((a).f_bsize)) +# define __OSL_STATFS_IS_NFS(a) (__OSL_NFS_SUPER_MAGIC == (a).f_type) +# define __OSL_STATFS_IS_SMB(a) (__OSL_SMB_SUPER_MAGIC == (a).f_type) +# define __OSL_STATFS_ISREMOTE(a) (__OSL_STATFS_IS_NFS((a)) || __OSL_STATFS_IS_SMB((a))) +# define __OSL_STATFS_IS_CASE_SENSITIVE_FS(a) ((__OSL_MSDOS_SUPER_MAGIC != (a).f_type) && (__OSL_NTFS_SUPER_MAGIC != (a).f_type)) +# define __OSL_STATFS_IS_CASE_PRESERVING_FS(a) ((__OSL_MSDOS_SUPER_MAGIC != (a).f_type)) +#endif /* LINUX */ + +#if defined(SOLARIS) || defined(IRIX) +# define __OSL_STATFS_STRUCT struct statvfs +# define __OSL_STATFS(dir, sfs) statvfs((dir), (sfs)) +# define __OSL_STATFS_BLKSIZ(a) ((sal_uInt64)((a).f_frsize)) +# define __OSL_STATFS_TYPENAME(a) ((a).f_basetype) +# define __OSL_STATFS_ISREMOTE(a) (rtl_str_compare((a).f_basetype, "nfs") == 0) + +/* always return true if queried for the properties of + the file system. If you think this is wrong under any + of the target platforms fix it!!!! */ +# define __OSL_STATFS_IS_CASE_SENSITIVE_FS(a) (1) +# define __OSL_STATFS_IS_CASE_PRESERVING_FS(a) (1) +#endif /* SOLARIS || IRIX*/ + +# define __OSL_STATFS_INIT(a) (memset(&(a), 0, sizeof(__OSL_STATFS_STRUCT))) + +#else /* no statfs available */ + +# define __OSL_STATFS_STRUCT struct dummy {int i;} +# define __OSL_STATFS_INIT(a) ((void)0) +# define __OSL_STATFS(dir, sfs) (1) +# define __OSL_STATFS_ISREMOTE(sfs) (0) +# define __OSL_STATFS_IS_CASE_SENSITIVE_FS(a) (1) +# define __OSL_STATFS_IS_CASE_PRESERVING_FS(a) (1) +#endif /* HAVE_STATFS_H */ + + +static oslFileError osl_psz_getVolumeInformation ( + const sal_Char* pszDirectory, oslVolumeInfo* pInfo, sal_uInt32 uFieldMask) +{ + __OSL_STATFS_STRUCT sfs; + + if (!pInfo) + return osl_File_E_INVAL; + + __OSL_STATFS_INIT(sfs); + + pInfo->uValidFields = 0; + pInfo->uAttributes = 0; + + if ((__OSL_STATFS(pszDirectory, &sfs)) < 0) + { + oslFileError result = oslTranslateFileError(OSL_FET_ERROR, errno); + return (result); + } + + /* FIXME: how to detect the kind of storage (fixed, cdrom, ...) */ + if (uFieldMask & osl_VolumeInfo_Mask_Attributes) + { + if (__OSL_STATFS_ISREMOTE(sfs)) + pInfo->uAttributes |= osl_Volume_Attribute_Remote; + + pInfo->uValidFields |= osl_VolumeInfo_Mask_Attributes; + } + + if (uFieldMask & osl_VolumeInfo_Mask_FileSystemCaseHandling) + { + if (__OSL_STATFS_IS_CASE_SENSITIVE_FS(sfs)) + pInfo->uAttributes |= osl_Volume_Attribute_Case_Sensitive; + + if (__OSL_STATFS_IS_CASE_PRESERVING_FS(sfs)) + pInfo->uAttributes |= osl_Volume_Attribute_Case_Is_Preserved; + + pInfo->uValidFields |= osl_VolumeInfo_Mask_Attributes; + } + + pInfo->uTotalSpace = 0; + pInfo->uFreeSpace = 0; + pInfo->uUsedSpace = 0; + +#if defined(__OSL_STATFS_BLKSIZ) + + if ((uFieldMask & osl_VolumeInfo_Mask_TotalSpace) || + (uFieldMask & osl_VolumeInfo_Mask_UsedSpace)) + { + pInfo->uTotalSpace = __OSL_STATFS_BLKSIZ(sfs); + pInfo->uTotalSpace *= (sal_uInt64)(sfs.f_blocks); + pInfo->uValidFields |= osl_VolumeInfo_Mask_TotalSpace; + } + + if ((uFieldMask & osl_VolumeInfo_Mask_FreeSpace) || + (uFieldMask & osl_VolumeInfo_Mask_UsedSpace)) + { + pInfo->uFreeSpace = __OSL_STATFS_BLKSIZ(sfs); + + if (getuid() == 0) + pInfo->uFreeSpace *= (sal_uInt64)(sfs.f_bfree); + else + pInfo->uFreeSpace *= (sal_uInt64)(sfs.f_bavail); + + pInfo->uValidFields |= osl_VolumeInfo_Mask_FreeSpace; + } + +#endif /* __OSL_STATFS_BLKSIZ */ + + if ((pInfo->uValidFields & osl_VolumeInfo_Mask_TotalSpace) && + (pInfo->uValidFields & osl_VolumeInfo_Mask_FreeSpace )) + { + pInfo->uUsedSpace = pInfo->uTotalSpace - pInfo->uFreeSpace; + pInfo->uValidFields |= osl_VolumeInfo_Mask_UsedSpace; + } + + pInfo->uMaxNameLength = 0; + if (uFieldMask & osl_VolumeInfo_Mask_MaxNameLength) + { + long nLen = pathconf(pszDirectory, _PC_NAME_MAX); + if (nLen > 0) + { + pInfo->uMaxNameLength = (sal_uInt32)nLen; + pInfo->uValidFields |= osl_VolumeInfo_Mask_MaxNameLength; + } + } + + pInfo->uMaxPathLength = 0; + if (uFieldMask & osl_VolumeInfo_Mask_MaxPathLength) + { + long nLen = pathconf (pszDirectory, _PC_PATH_MAX); + if (nLen > 0) + { + pInfo->uMaxPathLength = (sal_uInt32)nLen; + pInfo->uValidFields |= osl_VolumeInfo_Mask_MaxPathLength; + } + } + +#if defined(__OSL_STATFS_TYPENAME) + + if (uFieldMask & osl_VolumeInfo_Mask_FileSystemName) + { + rtl_string2UString( + &(pInfo->ustrFileSystemName), + __OSL_STATFS_TYPENAME(sfs), + rtl_str_getLength(__OSL_STATFS_TYPENAME(sfs)), + osl_getThreadTextEncoding(), + OUSTRING_TO_OSTRING_CVTFLAGS); + OSL_ASSERT(pInfo->ustrFileSystemName != 0); + + pInfo->uValidFields |= osl_VolumeInfo_Mask_FileSystemName; + } + +#endif /* __OSL_STATFS_TYPENAME */ + + if (uFieldMask & osl_VolumeInfo_Mask_DeviceHandle) + { + /* FIXME: check also entries in mntent for the device + and fill it with correct values */ + + *pInfo->pDeviceHandle = osl_isFloppyDrive(pszDirectory); + + if (*pInfo->pDeviceHandle) + { + pInfo->uValidFields |= osl_VolumeInfo_Mask_DeviceHandle; + pInfo->uAttributes |= osl_Volume_Attribute_Removeable; + pInfo->uValidFields |= osl_VolumeInfo_Mask_Attributes; + } + } + return osl_File_E_None; +} + +/****************************************************************************** + * + * GENERIC FLOPPY FUNCTIONS + * + *****************************************************************************/ + + +/***************************************** + * osl_unmountVolumeDevice + ****************************************/ + +oslFileError osl_unmountVolumeDevice( oslVolumeDeviceHandle Handle ) +{ + oslFileError tErr = osl_File_E_NOSYS; + + tErr = osl_unmountFloppy(Handle); + + /* Perhaps current working directory is set to mount point */ + + if ( tErr ) + { + sal_Char *pszHomeDir = getenv("HOME"); + + if ( pszHomeDir && strlen( pszHomeDir ) && 0 == chdir( pszHomeDir ) ) + { + /* try again */ + + tErr = osl_unmountFloppy(Handle); + + OSL_ENSURE( tErr, "osl_unmountvolumeDevice: CWD was set to volume mount point" ); + } + } + + return tErr; +} + +/***************************************** + * osl_automountVolumeDevice + ****************************************/ + +oslFileError osl_automountVolumeDevice( oslVolumeDeviceHandle Handle ) +{ + oslFileError tErr = osl_File_E_NOSYS; + + tErr = osl_mountFloppy(Handle); + + return tErr; +} + +/***************************************** + * osl_getVolumeDeviceMountPath + ****************************************/ +static rtl_uString* oslMakeUStrFromPsz(const sal_Char* pszStr, rtl_uString** ustrValid) +{ + rtl_string2UString( + ustrValid, + pszStr, + rtl_str_getLength( pszStr ), + osl_getThreadTextEncoding(), + OUSTRING_TO_OSTRING_CVTFLAGS ); + OSL_ASSERT(*ustrValid != 0); + + return *ustrValid; +} + +oslFileError osl_getVolumeDeviceMountPath( oslVolumeDeviceHandle Handle, rtl_uString **pstrPath ) +{ + oslVolumeDeviceHandleImpl* pItem = (oslVolumeDeviceHandleImpl*) Handle; + sal_Char Buffer[PATH_MAX]; + + Buffer[0] = '\0'; + + if ( pItem == 0 || pstrPath == 0 ) + { + return osl_File_E_INVAL; + } + + if ( pItem->ident[0] != 'O' || pItem->ident[1] != 'V' || pItem->ident[2] != 'D' || pItem->ident[3] != 'H' ) + { + return osl_File_E_INVAL; + } + +#ifdef DEBUG_OSL_FILE + fprintf(stderr,"Handle is:\n"); + osl_printFloppyHandle(pItem); +#endif + + snprintf(Buffer, sizeof(Buffer), "file://%s", pItem->pszMountPoint); + +#ifdef DEBUG_OSL_FILE + fprintf(stderr,"Mount Point is: '%s'\n",Buffer); +#endif + + oslMakeUStrFromPsz(Buffer, pstrPath); + + return osl_File_E_None; +} + +/***************************************** + * osl_acquireVolumeDeviceHandle + ****************************************/ + +oslFileError SAL_CALL osl_acquireVolumeDeviceHandle( oslVolumeDeviceHandle Handle ) +{ + oslVolumeDeviceHandleImpl* pItem =(oslVolumeDeviceHandleImpl*) Handle; + + if ( pItem == 0 ) + { + return osl_File_E_INVAL; + } + + if ( pItem->ident[0] != 'O' || pItem->ident[1] != 'V' || pItem->ident[2] != 'D' || pItem->ident[3] != 'H' ) + { + return osl_File_E_INVAL; + } + + ++pItem->RefCount; + + return osl_File_E_None; +} + +/***************************************** + * osl_releaseVolumeDeviceHandle + ****************************************/ + +oslFileError osl_releaseVolumeDeviceHandle( oslVolumeDeviceHandle Handle ) +{ + oslVolumeDeviceHandleImpl* pItem =(oslVolumeDeviceHandleImpl*) Handle; + + if ( pItem == 0 ) + { + return osl_File_E_INVAL; + } + + if ( pItem->ident[0] != 'O' || pItem->ident[1] != 'V' || pItem->ident[2] != 'D' || pItem->ident[3] != 'H' ) + { + return osl_File_E_INVAL; + } + + --pItem->RefCount; + + if ( pItem->RefCount == 0 ) + { + rtl_freeMemory(pItem); + } + + return osl_File_E_None; +} + +#ifndef MACOSX + +/***************************************** + * osl_newVolumeDeviceHandleImpl + ****************************************/ + +static oslVolumeDeviceHandleImpl* osl_newVolumeDeviceHandleImpl() +{ + oslVolumeDeviceHandleImpl* pHandle; + const size_t nSizeOfHandle = sizeof(oslVolumeDeviceHandleImpl); + + pHandle = (oslVolumeDeviceHandleImpl*) rtl_allocateMemory (nSizeOfHandle); + if (pHandle != NULL) + { + pHandle->ident[0] = 'O'; + pHandle->ident[1] = 'V'; + pHandle->ident[2] = 'D'; + pHandle->ident[3] = 'H'; + pHandle->pszMountPoint[0] = '\0'; + pHandle->pszFilePath[0] = '\0'; + pHandle->pszDevice[0] = '\0'; + pHandle->RefCount = 1; + } + return pHandle; +} + +/***************************************** + * osl_freeVolumeDeviceHandleImpl + ****************************************/ + +static void osl_freeVolumeDeviceHandleImpl (oslVolumeDeviceHandleImpl* pHandle) +{ + if (pHandle != NULL) + rtl_freeMemory (pHandle); +} +#endif + +/****************************************************************************** + * + * SOLARIS FLOPPY FUNCTIONS + * + *****************************************************************************/ + +#if defined(SOLARIS) +/* compare a given devicename with the typical device names on a Solaris box */ +static sal_Bool +osl_isAFloppyDevice (const char* pDeviceName) +{ + const char* pFloppyDevice [] = { + "/dev/fd", "/dev/rfd", + "/dev/diskette", "/dev/rdiskette", + "/vol/dev/diskette", "/vol/dev/rdiskette" + }; + + int i; + for (i = 0; i < (sizeof(pFloppyDevice)/sizeof(pFloppyDevice[0])); i++) + { + if (strncmp(pDeviceName, pFloppyDevice[i], strlen(pFloppyDevice[i])) == 0) + return sal_True; + } + return sal_False; +} + +/* compare two directories whether the first may be a parent of the second. this + * does not realpath() resolving */ +static sal_Bool +osl_isAParentDirectory (const char* pParentDir, const char* pSubDir) +{ + return strncmp(pParentDir, pSubDir, strlen(pParentDir)) == 0; +} + +/* the name of the routine is obviously silly. But anyway create a + * oslVolumeDeviceHandle with correct mount point, device name and a resolved filepath + * only if pszPath points to file or directory on a floppy */ +static oslVolumeDeviceHandle +osl_isFloppyDrive(const sal_Char* pszPath) +{ + FILE* pMountTab; + struct mnttab aMountEnt; + oslVolumeDeviceHandleImpl* pHandle; + + if ((pHandle = osl_newVolumeDeviceHandleImpl()) == NULL) + { + return NULL; + } + if (realpath(pszPath, pHandle->pszFilePath) == NULL) + { + osl_freeVolumeDeviceHandleImpl (pHandle); + return NULL; + } + if ((pMountTab = fopen (MOUNTTAB, "r")) == NULL) + { + osl_freeVolumeDeviceHandleImpl (pHandle); + return NULL; + } + + while (getmntent(pMountTab, &aMountEnt) == 0) + { + const char *pMountPoint = aMountEnt.mnt_mountp; + const char *pDevice = aMountEnt.mnt_special; + if ( osl_isAParentDirectory (aMountEnt.mnt_mountp, pHandle->pszFilePath) + && osl_isAFloppyDevice (aMountEnt.mnt_special)) + { + /* skip the last item for it is the name of the disk */ + char * pc = strrchr( aMountEnt.mnt_special, '/' ); + + if ( NULL != pc ) + { + int len = pc - aMountEnt.mnt_special; + + strncpy( pHandle->pszDevice, aMountEnt.mnt_special, len ); + pHandle->pszDevice[len] = '\0'; + } + else + { + /* #106048 use save str functions to avoid buffer overflows */ + memset(pHandle->pszDevice, 0, sizeof(pHandle->pszDevice)); + strncpy(pHandle->pszDevice, aMountEnt.mnt_special, sizeof(pHandle->pszDevice) - 1); + } + + /* remember the mount point */ + memset(pHandle->pszMountPoint, 0, sizeof(pHandle->pszMountPoint)); + strncpy(pHandle->pszMountPoint, aMountEnt.mnt_mountp, sizeof(pHandle->pszMountPoint) - 1); + + fclose (pMountTab); + return pHandle; + } + } + + fclose (pMountTab); + osl_freeVolumeDeviceHandleImpl (pHandle); + return NULL; +} + +static oslFileError osl_mountFloppy(oslVolumeDeviceHandle hFloppy) +{ + FILE* pMountTab; + struct mnttab aMountEnt; + oslVolumeDeviceHandleImpl* pHandle = (oslVolumeDeviceHandleImpl*) hFloppy; + + int nRet=0; + sal_Char pszCmd[512] = ""; + + if ( pHandle == 0 ) + return osl_File_E_INVAL; + + /* FIXME: don't know what this is good for */ + if ( pHandle->ident[0] != 'O' || pHandle->ident[1] != 'V' || pHandle->ident[2] != 'D' || pHandle->ident[3] != 'H' ) + return osl_File_E_INVAL; + + snprintf(pszCmd, sizeof(pszCmd), "eject -q %s > /dev/null 2>&1", pHandle->pszDevice); + + nRet = system( pszCmd ); + + switch ( WEXITSTATUS(nRet) ) + { + case 0: + { + /* lookup the device in mount tab again */ + if ((pMountTab = fopen (MOUNTTAB, "r")) == NULL) + return osl_File_E_BUSY; + + while (getmntent(pMountTab, &aMountEnt) == 0) + { + const char *pMountPoint = aMountEnt.mnt_mountp; + const char *pDevice = aMountEnt.mnt_special; + if ( 0 == strncmp( pHandle->pszDevice, aMountEnt.mnt_special, strlen(pHandle->pszDevice) ) ) + { + memset(pHandle->pszMountPoint, 0, sizeof(pHandle->pszMountPoint)); + strncpy (pHandle->pszMountPoint, aMountEnt.mnt_mountp, sizeof(pHandle->pszMountPoint) - 1); + + fclose (pMountTab); + return osl_File_E_None; + } + } + + fclose (pMountTab); + return osl_File_E_BUSY; + } + //break; // break not necessary here, see return statements before + + case 1: + return osl_File_E_BUSY; + + default: + break; + } + + return osl_File_E_BUSY; +} + +static oslFileError osl_unmountFloppy(oslVolumeDeviceHandle hFloppy) +{ +// FILE* pMountTab; +// struct mnttab aMountEnt; + oslVolumeDeviceHandleImpl* pHandle = (oslVolumeDeviceHandleImpl*) hFloppy; + + int nRet=0; + sal_Char pszCmd[512] = ""; + + if ( pHandle == 0 ) + return osl_File_E_INVAL; + + /* FIXME: don't know what this is good for */ + if ( pHandle->ident[0] != 'O' || pHandle->ident[1] != 'V' || pHandle->ident[2] != 'D' || pHandle->ident[3] != 'H' ) + return osl_File_E_INVAL; + + snprintf(pszCmd, sizeof(pszCmd), "eject %s > /dev/null 2>&1", pHandle->pszDevice); + + nRet = system( pszCmd ); + + switch ( WEXITSTATUS(nRet) ) + { + case 0: + { + FILE* pMountTab; + struct mnttab aMountEnt; + + /* lookup if device is still in mount tab */ + if ((pMountTab = fopen (MOUNTTAB, "r")) == NULL) + return osl_File_E_BUSY; + + while (getmntent(pMountTab, &aMountEnt) == 0) + { + const char *pMountPoint = aMountEnt.mnt_mountp; + const char *pDevice = aMountEnt.mnt_special; + if ( 0 == strncmp( pHandle->pszDevice, aMountEnt.mnt_special, strlen(pHandle->pszDevice) ) ) + { + fclose (pMountTab); + return osl_File_E_BUSY; + } + } + + fclose (pMountTab); + pHandle->pszMountPoint[0] = 0; + return osl_File_E_None; + } + + //break; //break not necessary, see return statements before + + case 1: + return osl_File_E_NODEV; + + case 4: + pHandle->pszMountPoint[0] = 0; + return osl_File_E_None; + + default: + break; + } + + return osl_File_E_BUSY; +} + +#endif /* SOLARIS */ + +/****************************************************************************** + * + * LINUX FLOPPY FUNCTIONS + * + *****************************************************************************/ + +#if defined(LINUX) +static oslVolumeDeviceHandle +osl_isFloppyDrive (const sal_Char* pszPath) +{ + oslVolumeDeviceHandleImpl* pItem = osl_newVolumeDeviceHandleImpl(); + if (osl_getFloppyMountEntry(pszPath, pItem)) + return (oslVolumeDeviceHandle) pItem; + + osl_freeVolumeDeviceHandleImpl (pItem); + return 0; +} +#endif /* LINUX */ + +#if defined(LINUX) +static oslFileError osl_mountFloppy(oslVolumeDeviceHandle hFloppy) +{ + sal_Bool bRet = sal_False; + oslVolumeDeviceHandleImpl* pItem=0; + int nRet; + sal_Char pszCmd[PATH_MAX]; + const sal_Char* pszMountProg = "mount"; + sal_Char* pszSuDo = 0; + sal_Char* pszTmp = 0; + + pszCmd[0] = '\0'; + +#ifdef TRACE_OSL_FILE + fprintf(stderr,"In osl_mountFloppy\n"); +#endif + + pItem = (oslVolumeDeviceHandleImpl*) hFloppy; + + if ( pItem == 0 ) + { +#ifdef TRACE_OSL_FILE + fprintf(stderr,"Out osl_mountFloppy [pItem == 0]\n"); +#endif + + return osl_File_E_INVAL; + } + + if ( pItem->ident[0] != 'O' || pItem->ident[1] != 'V' || pItem->ident[2] != 'D' || pItem->ident[3] != 'H' ) + { +#ifdef TRACE_OSL_FILE + fprintf(stderr,"Out osl_mountFloppy [invalid handle]\n"); +#endif + return osl_File_E_INVAL; + } + + bRet = osl_isFloppyMounted(pItem); + if ( bRet == sal_True ) + { +#ifdef DEBUG_OSL_FILE + fprintf(stderr,"detected mounted floppy at '%s'\n",pItem->pszMountPoint); +#endif + return osl_File_E_BUSY; + } + + /* mfe: we can't use the mount(2) system call!!! */ + /* even if we are root */ + /* since mtab is not updated!!! */ + /* but we need it to be updated */ + /* some "magic" must be done */ + +/* nRet = mount(pItem->pszDevice,pItem->pszMountPoint,0,0,0); */ +/* if ( nRet != 0 ) */ +/* { */ +/* nRet=errno; */ +/* #ifdef DEBUG_OSL_FILE */ +/* perror("mount"); */ +/* #endif */ +/* } */ + + pszTmp = getenv("SAL_MOUNT_MOUNTPROG"); + if ( pszTmp != 0 ) + { + pszMountProg=pszTmp; + } + + pszTmp=getenv("SAL_MOUNT_SU_DO"); + if ( pszTmp != 0 ) + { + pszSuDo=pszTmp; + } + + if ( pszSuDo != 0 ) + { + snprintf(pszCmd, sizeof(pszCmd), "%s %s %s %s",pszSuDo,pszMountProg,pItem->pszDevice,pItem->pszMountPoint); + } + else + { + snprintf(pszCmd, sizeof(pszCmd), "%s %s",pszMountProg,pItem->pszMountPoint); + } + + +#ifdef DEBUG_OSL_FILE + fprintf(stderr,"executing '%s'\n",pszCmd); +#endif + + nRet = system(pszCmd); + +#ifdef DEBUG_OSL_FILE + fprintf(stderr,"call returned '%i'\n",nRet); + fprintf(stderr,"exit status is '%i'\n", WEXITSTATUS(nRet)); +#endif + + + switch ( WEXITSTATUS(nRet) ) + { + case 0: + nRet=0; + break; + + case 2: + nRet=EPERM; + break; + + case 4: + nRet=ENOENT; + break; + + case 8: + nRet=EINTR; + break; + + case 16: + nRet=EPERM; + break; + + case 32: + nRet=EBUSY; + break; + + case 64: + nRet=EAGAIN; + break; + + default: + nRet=EBUSY; + break; + } + + return ((0 == nRet) ? oslTranslateFileError(OSL_FET_SUCCESS, nRet) : oslTranslateFileError(OSL_FET_ERROR, nRet)); +} +#endif /* LINUX */ + + +#if defined(LINUX) +static oslFileError osl_unmountFloppy(oslVolumeDeviceHandle hFloppy) +{ + oslVolumeDeviceHandleImpl* pItem=0; + int nRet=0; + sal_Char pszCmd[PATH_MAX]; + sal_Char* pszTmp = 0; + sal_Char* pszSuDo = 0; + const sal_Char* pszUmountProg = "umount"; + + pszCmd[0] = '\0'; + +#ifdef TRACE_OSL_FILE + fprintf(stderr,"In osl_unmountFloppy\n"); +#endif + + pItem = (oslVolumeDeviceHandleImpl*) hFloppy; + + if ( pItem == 0 ) + { +#ifdef TRACE_OSL_FILE + fprintf(stderr,"Out osl_unmountFloppy [pItem==0]\n"); +#endif + return osl_File_E_INVAL; + } + + if ( pItem->ident[0] != 'O' || pItem->ident[1] != 'V' || pItem->ident[2] != 'D' || pItem->ident[3] != 'H' ) + { +#ifdef TRACE_OSL_FILE + fprintf(stderr,"Out osl_unmountFloppy [invalid handle]\n"); +#endif + return osl_File_E_INVAL; + } + + /* mfe: we can't use the umount(2) system call!!! */ + /* even if we are root */ + /* since mtab is not updated!!! */ + /* but we need it to be updated */ + /* some "magic" must be done */ + +/* nRet=umount(pItem->pszDevice); */ +/* if ( nRet != 0 ) */ +/* { */ +/* nRet = errno; */ + +/* #ifdef DEBUG_OSL_FILE */ +/* perror("mount"); */ +/* #endif */ +/* } */ + + + pszTmp = getenv("SAL_MOUNT_UMOUNTPROG"); + if ( pszTmp != 0 ) + { + pszUmountProg=pszTmp; + } + + pszTmp = getenv("SAL_MOUNT_SU_DO"); + if ( pszTmp != 0 ) + { + pszSuDo=pszTmp; + } + + if ( pszSuDo != 0 ) + { + snprintf(pszCmd, sizeof(pszCmd), "%s %s %s",pszSuDo,pszUmountProg,pItem->pszMountPoint); + } + else + { + snprintf(pszCmd, sizeof(pszCmd), "%s %s",pszUmountProg,pItem->pszMountPoint); + } + + +#ifdef DEBUG_OSL_FILE + fprintf(stderr,"executing '%s'\n",pszCmd); +#endif + + nRet = system(pszCmd); + +#ifdef DEBUG_OSL_FILE + fprintf(stderr,"call returned '%i'\n",nRet); + fprintf(stderr,"exit status is '%i'\n", WEXITSTATUS(nRet)); +#endif + + switch ( WEXITSTATUS(nRet) ) + { + case 0: + nRet=0; + break; + + default: + nRet=EBUSY; + break; + } + +#ifdef TRACE_OSL_FILE + fprintf(stderr,"Out osl_unmountFloppy [ok]\n"); +#endif + + return ((0 == nRet) ? oslTranslateFileError(OSL_FET_SUCCESS, nRet) : oslTranslateFileError(OSL_FET_ERROR, nRet)); + +/* return osl_File_E_None;*/ +} + +#endif /* LINUX */ + +#if defined(LINUX) +static sal_Bool +osl_getFloppyMountEntry(const sal_Char* pszPath, oslVolumeDeviceHandleImpl* pItem) +{ + struct mntent* pMountEnt; + FILE* pMountTab; + + pMountTab = setmntent (MOUNTTAB, "r"); + if (pMountTab == 0) + return sal_False; + + while ((pMountEnt = getmntent(pMountTab)) != 0) + { + if ( strncmp(pMountEnt->mnt_dir, pszPath, strlen(pMountEnt->mnt_dir)) == 0 + && strncmp(pMountEnt->mnt_fsname, "/dev/fd", strlen("/dev/fd")) == 0) + { + memset(pItem->pszMountPoint, 0, sizeof(pItem->pszMountPoint)); + strncpy(pItem->pszMountPoint, pMountEnt->mnt_dir, sizeof(pItem->pszMountPoint) - 1); + + memset(pItem->pszFilePath, 0, sizeof(pItem->pszFilePath)); + strncpy(pItem->pszFilePath, pMountEnt->mnt_dir, sizeof(pItem->pszFilePath) - 1); + + memset(pItem->pszDevice, 0, sizeof(pItem->pszDevice)); + strncpy(pItem->pszDevice, pMountEnt->mnt_fsname, sizeof(pItem->pszDevice) - 1); + + endmntent (pMountTab); + return sal_True; + } + } + + endmntent (pMountTab); + return sal_False; +} +#endif /* LINUX */ + +#if defined(LINUX) +static sal_Bool +osl_isFloppyMounted (oslVolumeDeviceHandleImpl* pDevice) +{ + oslVolumeDeviceHandleImpl aItem; + + if ( osl_getFloppyMountEntry (pDevice->pszMountPoint, &aItem) + && strcmp (aItem.pszMountPoint, pDevice->pszMountPoint) == 0 + && strcmp (aItem.pszDevice, pDevice->pszDevice) == 0) + { + return sal_True; + } + return sal_False; +} +#endif /* LINUX */ + +/****************************************************************************** + * + * IRIX FLOPPY FUNCTIONS + * + *****************************************************************************/ + +#if defined(IRIX) +static oslVolumeDeviceHandle osl_isFloppyDrive(const sal_Char* pszPath) +{ + oslVolumeDeviceHandleImpl* pItem = osl_newVolumeDeviceHandleImpl (); + sal_Bool bRet = sal_False; + +#ifdef TRACE_OSL_FILE + fprintf(stderr,"In osl_isFloppyDrive\n"); +#endif + + bRet=osl_getFloppyMountEntry(pszPath,pItem); + + if ( bRet == sal_False ) + { +#ifdef TRACE_OSL_FILE + fprintf(stderr,"Out osl_isFloppyDrive [not a floppy]\n"); +#endif + rtl_freeMemory(pItem); + return 0; + } + + +#ifdef DEBUG_OSL_FILE + osl_printFloppyHandle(pItem); +#endif +#ifdef TRACE_OSL_FILE + fprintf(stderr,"Out osl_isFloppyDrive [ok]\n"); +#endif + + return (oslVolumeDeviceHandle) pItem; +} + + +static oslFileError osl_mountFloppy(oslVolumeDeviceHandle hFloppy) +{ + sal_Bool bRet = sal_False; + oslVolumeDeviceHandleImpl* pItem=0; + int nRet; + sal_Char pszCmd[PATH_MAX]; + sal_Char* pszMountProg = "mount"; + sal_Char* pszSuDo = 0; + sal_Char* pszTmp = 0; + + pszCmd[0] = '\0'; + +#ifdef TRACE_OSL_FILE + fprintf(stderr,"In osl_mountFloppy\n"); +#endif + + pItem = (oslVolumeDeviceHandleImpl*) hFloppy; + + if ( pItem == 0 ) + { +#ifdef TRACE_OSL_FILE + fprintf(stderr,"Out osl_mountFloppy [pItem == 0]\n"); +#endif + + return osl_File_E_INVAL; + } + + if ( pItem->ident[0] != 'O' || pItem->ident[1] != 'V' || pItem->ident[2] != 'D' || pItem->ident[3] != 'H' ) + { +#ifdef TRACE_OSL_FILE + fprintf(stderr,"Out osl_mountFloppy [invalid handle]\n"); +#endif + return osl_File_E_INVAL; + } + + bRet = osl_isFloppyMounted(pItem); + if ( bRet == sal_True ) + { +#ifdef DEBUG_OSL_FILE + fprintf(stderr,"detected mounted floppy at '%s'\n",pItem->pszMountPoint); +#endif + return osl_File_E_BUSY; + } + + /* mfe: we can't use the mount(2) system call!!! */ + /* even if we are root */ + /* since mtab is not updated!!! */ + /* but we need it to be updated */ + /* some "magic" must be done */ + +/* nRet = mount(pItem->pszDevice,pItem->pszMountPoint,0,0,0); */ +/* if ( nRet != 0 ) */ +/* { */ +/* nRet=errno; */ +/* #ifdef DEBUG_OSL_FILE */ +/* perror("mount"); */ +/* #endif */ +/* } */ + + pszTmp = getenv("SAL_MOUNT_MOUNTPROG"); + if ( pszTmp != 0 ) + { + pszMountProg=pszTmp; + } + + pszTmp=getenv("SAL_MOUNT_SU_DO"); + if ( pszTmp != 0 ) + { + pszSuDo=pszTmp; + } + + if ( pszSuDo != 0 ) + { + snprintf(pszCmd, sizeof(pszCmd), "%s %s %s %s",pszSuDo,pszMountProg,pItem->pszDevice,pItem->pszMountPoint); + } + else + { + snprintf(pszCmd, sizeof(pszCmd), "%s %s",pszMountProg,pItem->pszMountPoint); + } + + +#ifdef DEBUG_OSL_FILE + fprintf(stderr,"executing '%s'\n",pszCmd); +#endif + + nRet = system(pszCmd); + +#ifdef DEBUG_OSL_FILE + fprintf(stderr,"call returned '%i'\n",nRet); + fprintf(stderr,"exit status is '%i'\n", WEXITSTATUS(nRet)); +#endif + + + switch ( WEXITSTATUS(nRet) ) + { + case 0: + nRet=0; + break; + + case 2: + nRet=EPERM; + break; + + case 4: + nRet=ENOENT; + break; + + case 8: + nRet=EINTR; + break; + + case 16: + nRet=EPERM; + break; + + case 32: + nRet=EBUSY; + break; + + case 64: + nRet=EAGAIN; + break; + + default: + nRet=EBUSY; + break; + } + + return ((0 == nRet) ? oslTranslateFileError(OSL_FET_SUCCESS, nRet) : oslTranslateFileError(OSL_FET_ERROR, nRet)); +} + +static oslFileError osl_unmountFloppy(oslVolumeDeviceHandle hFloppy) +{ + oslVolumeDeviceHandleImpl* pItem=0; + int nRet=0; + sal_Char pszCmd[PATH_MAX]; + sal_Char* pszTmp = 0; + sal_Char* pszSuDo = 0; + sal_Char* pszUmountProg = "umount"; + + pszCmd[0] = '\0'; + +#ifdef TRACE_OSL_FILE + fprintf(stderr,"In osl_unmountFloppy\n"); +#endif + + pItem = (oslVolumeDeviceHandleImpl*) hFloppy; + + if ( pItem == 0 ) + { +#ifdef TRACE_OSL_FILE + fprintf(stderr,"Out osl_unmountFloppy [pItem==0]\n"); +#endif + return osl_File_E_INVAL; + } + + if ( pItem->ident[0] != 'O' || pItem->ident[1] != 'V' || pItem->ident[2] != 'D' || pItem->ident[3] != 'H' ) + { +#ifdef TRACE_OSL_FILE + fprintf(stderr,"Out osl_unmountFloppy [invalid handle]\n"); +#endif + return osl_File_E_INVAL; + } + + /* mfe: we can't use the umount(2) system call!!! */ + /* even if we are root */ + /* since mtab is not updated!!! */ + /* but we need it to be updated */ + /* some "magic" must be done */ + +/* nRet=umount(pItem->pszDevice); */ +/* if ( nRet != 0 ) */ +/* { */ +/* nRet = errno; */ + +/* #ifdef DEBUG_OSL_FILE */ +/* perror("mount"); */ +/* #endif */ +/* } */ + + + pszTmp = getenv("SAL_MOUNT_UMOUNTPROG"); + if ( pszTmp != 0 ) + { + pszUmountProg=pszTmp; + } + + pszTmp = getenv("SAL_MOUNT_SU_DO"); + if ( pszTmp != 0 ) + { + pszSuDo=pszTmp; + } + + if ( pszSuDo != 0 ) + { + snprintf(pszCmd, sizeof(pszCmd), "%s %s %s",pszSuDo,pszUmountProg,pItem->pszMountPoint); + } + else + { + snprintf(pszCmd, sizeof(pszCmd), "%s %s",pszUmountProg,pItem->pszMountPoint); + } + + +#ifdef DEBUG_OSL_FILE + fprintf(stderr,"executing '%s'\n",pszCmd); +#endif + + nRet = system(pszCmd); + +#ifdef DEBUG_OSL_FILE + fprintf(stderr,"call returned '%i'\n",nRet); + fprintf(stderr,"exit status is '%i'\n", WEXITSTATUS(nRet)); +#endif + + switch ( WEXITSTATUS(nRet) ) + { + case 0: + nRet=0; + break; + + default: + nRet=EBUSY; + break; + } + +#ifdef TRACE_OSL_FILE + fprintf(stderr,"Out osl_unmountFloppy [ok]\n"); +#endif + + return ((0 == nRet) ? oslTranslateFileError(OSL_FET_SUCCESS, nRet) : oslTranslateFileError(OSL_FET_ERROR, nRet)); + +/* return osl_File_E_None;*/ +} + +static sal_Bool osl_getFloppyMountEntry(const sal_Char* pszPath, oslVolumeDeviceHandleImpl* pItem) +{ + struct mntent* pMountEnt=0; + sal_Char buffer[PATH_MAX]; + FILE* mntfile=0; + int nRet=0; + + buffer[0] = '\0'; + + mntfile = setmntent(MOUNTTAB,"r"); + +#ifdef TRACE_OSL_FILE + fprintf(stderr,"In osl_getFloppyMountEntry\n"); +#endif + + memset(buffer, 0, sizeof(buffer)); + strncpy(buffer, pszPath, sizeof(buffer) - 1); + +#ifdef DEBUG_OSL_FILE + fprintf(stderr,"Checking mount of %s\n",buffer); +#endif + + + if ( mntfile == 0 ) + { + nRet=errno; +#ifdef DEBUG_OSL_FILE + perror("mounttab"); +#endif +#ifdef TRACE_OSL_FILE + fprintf(stderr,"Out osl_getFloppyMountEntry [mntfile]\n"); +#endif + return sal_False; + } + + pMountEnt=getmntent(mntfile); + while ( pMountEnt != 0 ) + { +#ifdef DEBUG_OSL_FILE +/* fprintf(stderr,"mnt_fsname : %s\n",pMountEnt->mnt_fsname); */ +/* fprintf(stderr,"mnt_dir : %s\n",pMountEnt->mnt_dir); */ +/* fprintf(stderr,"mnt_type : %s\n",pMountEnt->mnt_type);*/ +#endif + if ( strcmp(pMountEnt->mnt_dir,buffer) == 0 && + strncmp(pMountEnt->mnt_fsname,"/dev/fd",strlen("/dev/fd")) == 0 ) + { + + memset(pItem->pszMountPoint, 0, sizeof(pItem->pszMountPoint)); + strncpy(pItem->pszMountPoint, pMountEnt->mnt_dir, sizeof(pItem->pszMountPoint) - 1); + + memset(pItem->pszFilePath, 0, sizeof(pItem->pszFilePath)); + strncpy(pItem->pszFilePath, pMountEnt->mnt_dir, sizeof(pItem->pszFilePath) - 1); + + memset(pItem->pszDevice, 0, sizeof(pItem->pszDevice)); + strncpy(pItem->pszDevice, pMountEnt->mnt_fsname, sizeof(pItem->pszDevice) - 1); + + fclose(mntfile); +#ifdef DEBUG_OSL_FILE + fprintf(stderr,"Mount Point found '%s'\n",pItem->pszMountPoint); +#endif +#ifdef TRACE_OSL_FILE + fprintf(stderr,"Out osl_getFloppyMountEntry [found]\n"); +#endif + return sal_True; + } +#ifdef DEBUG_OSL_FILE +/* fprintf(stderr,"=================\n");*/ +#endif + pMountEnt=getmntent(mntfile); + } + +#ifdef TRACE_OSL_FILE + fprintf(stderr,"Out osl_getFloppyMountEntry [not found]\n"); +#endif + + fclose(mntfile); + return sal_False; +} + +static sal_Bool osl_isFloppyMounted(oslVolumeDeviceHandleImpl* pDevice) +{ + sal_Char buffer[PATH_MAX]; + oslVolumeDeviceHandleImpl* pItem=0; + sal_Bool bRet=0; + + buffer[0] = '\0'; + +#ifdef TRACE_OSL_FILE + fprintf(stderr,"In osl_isFloppyMounted\n"); +#endif + + pItem = osl_newVolumeDeviceHandleImpl (); + if ( pItem == 0 ) + return osl_File_E_NOMEM; + + memset(buffer, 0, sizeof(buffer)); + strncpy(buffer, pDevice->pszMountPoint, sizeof(buffer) - 1); + +#ifdef DEBUG_OSL_FILE + fprintf(stderr,"Checking mount of %s\n",buffer); +#endif + + bRet = osl_getFloppyMountEntry(buffer,pItem); + + if ( bRet == sal_False ) + { +#ifdef TRACE_OSL_FILE + fprintf(stderr,"Out osl_isFloppyMounted [not mounted]\n"); +#endif + return sal_False; + } + + if (strcmp(pItem->pszMountPoint, pDevice->pszMountPoint) == 0 && + strcmp(pItem->pszDevice,pDevice->pszDevice) == 0) + { +#ifdef TRACE_OSL_FILE + fprintf(stderr,"Out osl_isFloppyMounted [is mounted]\n"); +#endif + rtl_freeMemory(pItem); + return sal_True; + } + +#ifdef TRACE_OSL_FILE + fprintf(stderr,"Out osl_isFloppyMounted [may be EBUSY]\n"); +#endif + + rtl_freeMemory(pItem); + return sal_False; +} +#endif /* IRIX */ + + +/* NetBSD floppy functions have to be added here. Until we have done that, + * we use the MACOSX definitions for nonexistent floppy. + * */ + +/****************************************************************************** + * + * MAC OS X FLOPPY FUNCTIONS + * + *****************************************************************************/ + +#if (defined(MACOSX) || defined(NETBSD) || defined(FREEBSD)) +static oslVolumeDeviceHandle osl_isFloppyDrive(const sal_Char* pszPath) +{ + return NULL; +} +#endif /* MACOSX */ + +#if ( defined(MACOSX) || defined(NETBSD) || defined(FREEBSD)) +static oslFileError osl_mountFloppy(oslVolumeDeviceHandle hFloppy) +{ + return osl_File_E_BUSY; +} +#endif /* MACOSX */ + +#if ( defined(MACOSX) || defined(NETBSD) || defined(FREEBSD)) +static oslFileError osl_unmountFloppy(oslVolumeDeviceHandle hFloppy) +{ + return osl_File_E_BUSY; +} +#endif /* MACOSX */ + +#if ( defined(NETBSD) || defined(FREEBSD) ) +static sal_Bool osl_getFloppyMountEntry(const sal_Char* pszPath, oslVolumeDeviceHandleImpl* pItem) +{ + return sal_False; +} +#endif /* NETBSD || FREEBSD */ + +#if ( defined(NETBSD) || defined(FREEBSD) ) +static sal_Bool osl_isFloppyMounted(oslVolumeDeviceHandleImpl* pDevice) +{ + return sal_False; +} +#endif /* NETBSD || FREEBSD */ + + +#ifdef DEBUG_OSL_FILE +static void osl_printFloppyHandle(oslVolumeDeviceHandleImpl* pItem) +{ + if (pItem == 0 ) + { + fprintf(stderr,"NULL Handle\n"); + return; + } + if ( pItem->ident[0] != 'O' || pItem->ident[1] != 'V' || pItem->ident[2] != 'D' || pItem->ident[3] != 'H' ) + { +#ifdef TRACE_OSL_FILE + fprintf(stderr,"Invalid Handle]\n"); +#endif + return; + } + + + fprintf(stderr,"MountPoint : '%s'\n",pItem->pszMountPoint); + fprintf(stderr,"FilePath : '%s'\n",pItem->pszFilePath); + fprintf(stderr,"Device : '%s'\n",pItem->pszDevice); + + return; +} +#endif diff --git a/sal/osl/unx/makefile.mk b/sal/osl/unx/makefile.mk index 1717d836e647..eac4c24cdfa9 100644 --- a/sal/osl/unx/makefile.mk +++ b/sal/osl/unx/makefile.mk @@ -55,7 +55,8 @@ CXXFLAGS+= $(LFS_CFLAGS) # --- Files -------------------------------------------------------- -SLOFILES= $(SLO)$/conditn.obj \ +SLOFILES= \ + $(SLO)$/conditn.obj \ $(SLO)$/diagnose.obj \ $(SLO)$/semaphor.obj \ $(SLO)$/socket.obj \ @@ -68,20 +69,23 @@ SLOFILES= $(SLO)$/conditn.obj \ $(SLO)$/security.obj \ $(SLO)$/profile.obj \ $(SLO)$/time.obj \ - $(SLO)$/file.obj \ $(SLO)$/signal.obj \ $(SLO)$/pipe.obj \ $(SLO)$/system.obj \ $(SLO)$/util.obj \ $(SLO)$/tempfile.obj\ + $(SLO)$/file.obj \ + $(SLO)$/file_misc.obj\ $(SLO)$/file_url.obj\ $(SLO)$/file_error_transl.obj\ $(SLO)$/file_path_helper.obj\ + $(SLO)$/file_stat.obj \ + $(SLO)$/file_volume.obj \ $(SLO)$/uunxapi.obj\ $(SLO)$/process_impl.obj\ - $(SLO)$/file_stat.obj \ $(SLO)$/salinit.obj + #.IF "$(UPDATER)"=="YES" OBJFILES= $(OBJ)$/conditn.obj \ $(OBJ)$/diagnose.obj \ @@ -96,18 +100,20 @@ OBJFILES= $(OBJ)$/conditn.obj \ $(OBJ)$/security.obj \ $(OBJ)$/profile.obj \ $(OBJ)$/time.obj \ - $(OBJ)$/file.obj \ $(OBJ)$/signal.obj \ $(OBJ)$/pipe.obj \ $(OBJ)$/system.obj \ $(OBJ)$/util.obj \ $(OBJ)$/tempfile.obj\ + $(OBJ)$/file.obj \ + $(OBJ)$/file_misc.obj\ $(OBJ)$/file_url.obj\ $(OBJ)$/file_error_transl.obj\ $(OBJ)$/file_path_helper.obj\ + $(OBJ)$/file_stat.obj \ + $(OBJ)$/file_volume.obj \ $(OBJ)$/uunxapi.obj\ $(OBJ)$/process_impl.obj\ - $(OBJ)$/file_stat.obj \ $(OBJ)$/salinit.obj #.ENDIF diff --git a/sal/osl/unx/process.c b/sal/osl/unx/process.c index a163436031d2..a1f47cdf76a5 100644 --- a/sal/osl/unx/process.c +++ b/sal/osl/unx/process.c @@ -466,7 +466,7 @@ static void ChildStatusProc(void *pData) if ((pid = fork()) == 0) { /* Child */ - close(channel[0]); + if (channel[0] != -1) close(channel[0]); if ((data.m_uid != (uid_t)-1) && ((data.m_uid != getuid()) || (data.m_gid != getgid()))) { @@ -500,32 +500,32 @@ static void ChildStatusProc(void *pData) /* Connect std IO to pipe ends */ /* Write end of stdInput not used in child process */ - close( stdInput[1] ); + if (stdInput[1] != -1) close( stdInput[1] ); /* Read end of stdOutput not used in child process */ - close( stdOutput[0] ); + if (stdOutput[0] != -1) close( stdOutput[0] ); /* Read end of stdError not used in child process */ - close( stdError[0] ); + if (stdError[0] != -1) close( stdError[0] ); /* Redirect pipe ends to std IO */ if ( stdInput[0] != STDIN_FILENO ) { dup2( stdInput[0], STDIN_FILENO ); - close( stdInput[0] ); + if (stdInput[0] != -1) close( stdInput[0] ); } if ( stdOutput[1] != STDOUT_FILENO ) { dup2( stdOutput[1], STDOUT_FILENO ); - close( stdOutput[1] ); + if (stdOutput[1] != -1) close( stdOutput[1] ); } if ( stdError[1] != STDERR_FILENO ) { dup2( stdError[1], STDERR_FILENO ); - close( stdError[1] ); + if (stdError[1] != -1) close( stdError[1] ); } pid=execv(data.m_pszArgs[0], (sal_Char **)data.m_pszArgs); @@ -539,7 +539,7 @@ static void ChildStatusProc(void *pData) /* if we reach here, something went wrong */ write(channel[1], &errno, sizeof(errno)); - close(channel[1]); + if (channel[1] != -1) close(channel[1]); _exit(255); } @@ -547,12 +547,12 @@ static void ChildStatusProc(void *pData) { /* Parent */ int status; - close(channel[1]); + if (channel[1] != -1) close(channel[1]); /* Close unused pipe ends */ - close( stdInput[0] ); - close( stdOutput[1] ); - close( stdError[1] ); + if (stdInput[0] != -1) close( stdInput[0] ); + if (stdOutput[1] != -1) close( stdOutput[1] ); + if (stdError[1] != -1) close( stdError[1] ); while (((i = read(channel[0], &status, sizeof(status))) < 0)) { @@ -560,7 +560,7 @@ static void ChildStatusProc(void *pData) break; } - close(channel[0]); + if (channel[0] != -1) close(channel[0]); if ((pid > 0) && (i == 0)) @@ -646,9 +646,21 @@ static void ChildStatusProc(void *pData) if ( pdata->m_pErrorRead ) *pdata->m_pErrorRead = NULL; - close( stdInput[1] ); - close( stdOutput[0] ); - close( stdError[0] ); + if (stdInput[1] != -1) close( stdInput[1] ); + if (stdOutput[0] != -1) close( stdOutput[0] ); + if (stdError[0] != -1) close( stdError[0] ); + + //if pid > 0 then a process was created, even if it later failed + //e.g. bash searching for a command to execute, and we still + //need to clean it up to avoid "defunct" processes + if (pid > 0) + { + pid_t child_pid; + do + { + child_pid = waitpid(pid, &status, 0); + } while ( 0 > child_pid && EINTR == errno ); + } /* notify (and unblock) parent thread */ osl_setCondition(pdata->m_started); @@ -1112,15 +1124,6 @@ struct osl_procStat unsigned long nswap; /* ? */ unsigned long cnswap; /* ? */ - /* from 'statm' */ - long size; /* numbers of pages in memory */ - long resident; /* number of resident pages */ - long share; /* number of shared pages */ - long trs; /* text resident size */ - long lrs; /* library resident size */ - long drs; /* data resident size */ - long dt; /* ditry pages */ - /* from 'status' */ int ruid; /* real uid */ int euid; /* effective uid */ @@ -1143,9 +1146,10 @@ struct osl_procStat osl_getProcStat *********************************************/ -void osl_getProcStat(pid_t pid, struct osl_procStat* procstat) +sal_Bool osl_getProcStat(pid_t pid, struct osl_procStat* procstat) { int fd = 0; + sal_Bool bRet = sal_False; char name[PATH_MAX + 1]; snprintf(name, sizeof(name), "/proc/%u/stat", pid); @@ -1154,11 +1158,13 @@ void osl_getProcStat(pid_t pid, struct osl_procStat* procstat) char* tmp=0; char prstatbuf[512]; memset(prstatbuf,0,512); - read(fd,prstatbuf,511); + bRet = read(fd,prstatbuf,511) == 511; close(fd); /*printf("%s\n\n",prstatbuf);*/ + if (!bRet) + return sal_False; tmp = strrchr(prstatbuf, ')'); *tmp = '\0'; @@ -1186,57 +1192,35 @@ void osl_getProcStat(pid_t pid, struct osl_procStat* procstat) &procstat->wchan, &procstat->nswap, &procstat->cnswap ); } -} - -/********************************************** - osl_getProcStatm - *********************************************/ - -void osl_getProcStatm(pid_t pid, struct osl_procStat* procstat) -{ - int fd = 0; - char name[PATH_MAX + 1]; - snprintf(name, sizeof(name), "/proc/%u/statm", pid); - - if ((fd = open(name,O_RDONLY)) >=0 ) - { - char prstatmbuf[512]; - memset(prstatmbuf,0,512); - read(fd,prstatmbuf,511); - - close(fd); - - /* printf("\n\n%s\n\n",prstatmbuf);*/ - - sscanf(prstatmbuf,"%li %li %li %li %li %li %li", - &procstat->size, &procstat->resident, &procstat->share, - &procstat->trs, &procstat->lrs, &procstat->drs, - &procstat->dt - ); - } + return bRet; } /********************************************** osl_getProcStatus *********************************************/ -void osl_getProcStatus(pid_t pid, struct osl_procStat* procstat) +sal_Bool osl_getProcStatus(pid_t pid, struct osl_procStat* procstat) { int fd = 0; char name[PATH_MAX + 1]; snprintf(name, sizeof(name), "/proc/%u/status", pid); + sal_Bool bRet = sal_False; + if ((fd = open(name,O_RDONLY)) >=0 ) { char* tmp=0; char prstatusbuf[512]; memset(prstatusbuf,0,512); - read(fd,prstatusbuf,511); + bRet = read(fd,prstatusbuf,511) == 511; close(fd); /* printf("\n\n%s\n\n",prstatusbuf);*/ + if (!bRet) + return sal_False; + tmp = strstr(prstatusbuf,"Uid:"); if(tmp) { @@ -1278,6 +1262,7 @@ void osl_getProcStatus(pid_t pid, struct osl_procStat* procstat) ); } } + return bRet; } #endif @@ -1427,56 +1412,54 @@ oslProcessError SAL_CALL osl_getProcessInfo(oslProcess Process, oslProcessData F #elif defined(LINUX) -/* int fd = 0;*/ - struct osl_procStat procstat; - memset(&procstat,0,sizeof(procstat)); + if ( (Fields & osl_Process_CPUTIMES) || (Fields & osl_Process_HEAPUSAGE) ) + { + struct osl_procStat procstat; + memset(&procstat,0,sizeof(procstat)); - osl_getProcStat(pid, &procstat); - osl_getProcStatm(pid, &procstat); - osl_getProcStatus(pid, &procstat); + if ( (Fields & osl_Process_CPUTIMES) && osl_getProcStat(pid, &procstat) ) + { + /* + * mfe: + * We calculate only time of the process proper. + * Threads are processes, we do not consider their time here! + * (For this, cutime and cstime should be used, it seems not + * to work in 2.0.36) + */ + + long clktck; + unsigned long hz; + unsigned long userseconds; + unsigned long systemseconds; + + clktck = sysconf(_SC_CLK_TCK); + if (clktck < 0) { + return osl_Process_E_Unknown; + } + hz = (unsigned long) clktck; - if ( Fields & osl_Process_CPUTIMES) - { - /* - * mfe: - * We calculate only time of the process proper. - * Threads are processes, we do not consider their time here! - * (For this, cutime and cstime should be used, it seems not - * to work in 2.0.36) - */ - - long clktck; - unsigned long hz; - unsigned long userseconds; - unsigned long systemseconds; - - clktck = sysconf(_SC_CLK_TCK); - if (clktck < 0) { - return osl_Process_E_Unknown; - } - hz = (unsigned long) clktck; + userseconds = procstat.utime/hz; + systemseconds = procstat.stime/hz; - userseconds = procstat.utime/hz; - systemseconds = procstat.stime/hz; + pInfo->UserTime.Seconds = userseconds; + pInfo->UserTime.Nanosec = procstat.utime - (userseconds * hz); + pInfo->SystemTime.Seconds = systemseconds; + pInfo->SystemTime.Nanosec = procstat.stime - (systemseconds * hz); - pInfo->UserTime.Seconds = userseconds; - pInfo->UserTime.Nanosec = procstat.utime - (userseconds * hz); - pInfo->SystemTime.Seconds = systemseconds; - pInfo->SystemTime.Nanosec = procstat.stime - (systemseconds * hz); + pInfo->Fields |= osl_Process_CPUTIMES; + } - pInfo->Fields |= osl_Process_CPUTIMES; - } + if ( (Fields & osl_Process_HEAPUSAGE) && osl_getProcStatus(pid, &procstat) ) + { + /* + * mfe: + * vm_data (found in status) shows the size of the data segment + * it a rough approximation of the core heap size + */ + pInfo->HeapUsage = procstat.vm_data*1024; - if (Fields & osl_Process_HEAPUSAGE) - { - /* - * mfe: - * vm_data (found in status) shows the size of the data segment - * it a rough approximation of the core heap size - */ - pInfo->HeapUsage = procstat.vm_data*1024; - - pInfo->Fields |= osl_Process_HEAPUSAGE; + pInfo->Fields |= osl_Process_HEAPUSAGE; + } } return (pInfo->Fields == Fields) ? osl_Process_E_None : osl_Process_E_Unknown; diff --git a/sal/osl/unx/security.c b/sal/osl/unx/security.c index 53dd452e220b..5b601ee138a9 100644 --- a/sal/osl/unx/security.c +++ b/sal/osl/unx/security.c @@ -801,7 +801,14 @@ sal_Bool SAL_CALL osl_getConfigDir(oslSecurity Security, rtl_uString **pustrDire static sal_Bool SAL_CALL osl_psz_getConfigDir(oslSecurity Security, sal_Char* pszDirectory, sal_uInt32 nMax) { - return (osl_psz_getHomeDir(Security, pszDirectory, nMax)); + sal_Char *pStr = getenv("XDG_CONFIG_HOME"); + + if ((pStr == NULL) || (strlen(pStr) == 0) || + (access(pStr, 0) != 0)) + return (osl_psz_getHomeDir(Security, pszDirectory, nMax)); + + strncpy(pszDirectory, pStr, nMax); + return sal_True; } #else diff --git a/sal/osl/unx/signal.c b/sal/osl/unx/signal.c index 77633dd81269..35884e11c9ba 100644 --- a/sal/osl/unx/signal.c +++ b/sal/osl/unx/signal.c @@ -46,6 +46,7 @@ #ifdef LINUX #include <execinfo.h> +#include <link.h> #define INCLUDE_BACKTRACE #define STACKTYPE "Linux" #endif @@ -392,6 +393,88 @@ static int fputs_xml( const char *string, FILE *stream ) #define REPORTENV_PARAM "-crashreportenv:" +#if defined SAL_ENABLE_CRASH_REPORT && defined INCLUDE_BACKTRACE && \ + defined LINUX + +typedef struct +{ + const char *name; + ElfW(Off) offset; +} dynamic_entry; + +static int +callback(struct dl_phdr_info *info, size_t size, void *data) +{ + const ElfW(Phdr) *pDynamic = NULL; + + if (size == sizeof(struct dl_phdr_info)) + { + int i; + for (i = 0; i < info->dlpi_phnum; ++i) + { + if (info->dlpi_phdr[i].p_type == PT_DYNAMIC) + { + pDynamic = &(info->dlpi_phdr[i]); + break; + } + } + } + + if (pDynamic) + { + char buffer[100]; + int len; + char exe[PATH_MAX]; + const char *dsoname = info->dlpi_name; + + dynamic_entry* entry = (dynamic_entry*)data; + + if (strcmp(dsoname, "") == 0) + { + snprintf(buffer, sizeof(buffer), "/proc/%d/exe", getpid()); + if ((len = readlink(buffer, exe, PATH_MAX)) != -1) + { + exe[len] = '\0'; + dsoname = exe; + } + } + + if (strcmp(dsoname, entry->name) == 0) + { + entry->offset = pDynamic->p_offset; + return 1; + } + } + return 0; +} + +/* Get the location of the .dynamic section offset for the given elf file. + * i.e. same as the "Offset" value shown for DYNAMIC from readelf -l foo + * + * We want to know this value so that if the binaries have been modifed + * by prelink then we can still process the call stack on server side + * by comparing this value to that of an "un-prelinked but known to be + * otherwise equivalent" version of those binaries and adjust the call + * stack addresses by the differences between .dynamic addresses so as + * to be able to map the prelinked addresses back to the unprelinked + * addresses + * + * cmc@openoffice.org + */ +static ElfW(Off) +dynamic_section_offset(const char *name) +{ + dynamic_entry entry; + + entry.name = name; + entry.offset = 0; + + dl_iterate_phdr(callback, &entry); + + return entry.offset; +} +#endif + static int ReportCrash( int Signal ) { #ifdef SAL_ENABLE_CRASH_REPORT @@ -572,6 +655,11 @@ static int ReportCrash( int Signal ) if ( dl_info.dli_fbase && dl_info.dli_fname ) { +#ifdef LINUX + ElfW(Off) dynamic_offset = dynamic_section_offset(dl_info.dli_fname); + fprintf( stackout, " 0x%" SAL_PRI_SIZET "x:", dynamic_offset); +#endif + fprintf( stackout, " %s + 0x%" SAL_PRI_PTRDIFFT "x", dl_info.dli_fname, (char*)stackframes[iFrame] - (char*)dl_info.dli_fbase @@ -583,6 +671,10 @@ static int ReportCrash( int Signal ) if ( dli_fdir ) fprintf( xmlout, " path=\"%s\"", dli_fdir ); + +#ifdef LINUX + fprintf( xmlout, " dynamicoffset=\"0x%" SAL_PRI_SIZET "x\"", dynamic_offset ); +#endif } else fprintf( stackout, " ????????" ); diff --git a/sal/osl/unx/util.c b/sal/osl/unx/util.c index c0b9e3c5aa09..66746fd3ff44 100644 --- a/sal/osl/unx/util.c +++ b/sal/osl/unx/util.c @@ -51,11 +51,10 @@ static int osl_getHWAddr(const char *ifname, char* hard_addr); static int osl_checkAddr(const char* addr); -static char* osl_decodeEtherAddr(const char *ptr, char* buff); /*****************************************************************************/ -/* osl_getEtherAddr */ +/* osl_getEthernetAddress */ /*****************************************************************************/ sal_Bool SAL_CALL osl_getEthernetAddress( sal_uInt8 * pAddr ) @@ -124,68 +123,6 @@ sal_Bool SAL_CALL osl_getEthernetAddress( sal_uInt8 * pAddr ) } -extern sal_Bool osl_getEtherAddr(sal_Char* pszAddr, sal_uInt16 BufferSize) -{ - char buff[1024]; - char hard_addr[64]; - struct ifconf ifc; - struct ifreq *ifr; - int i; - int so; - - (void) BufferSize; /* unused */ - - if ( pszAddr == 0 ) - { - return sal_False; - } - - - /* - * All we need is ... a network file descriptor. - * Normally, this is a very socket. - */ - - so = socket(AF_INET, SOCK_DGRAM, 0); - - - /* - * The first thing we have to do, get the interface configuration. - * It is a list of attached/configured interfaces - */ - - ifc.ifc_len = sizeof(buff); - ifc.ifc_buf = buff; - if ( ioctl(so, SIOCGIFCONF, &ifc) < 0 ) - { -/* fprintf(stderr, "SIOCGIFCONF: %s\n", strerror(errno));*/ - close(so); - return sal_False; - } - - close(so); - - /* - * For each of the interfaces in the interface list, - * try to get the hardware address - */ - - ifr = ifc.ifc_req; - for ( i = ifc.ifc_len / sizeof(struct ifreq) ; --i >= 0 ; ifr++ ) - { - int nRet=0; - nRet = osl_getHWAddr(ifr->ifr_name,hard_addr); - if ( nRet > 0 ) - { - osl_decodeEtherAddr(hard_addr,pszAddr); - return sal_True; - } - } - - return sal_False; -} - - /*****************************************************************************/ /* osl_getHWAddr */ /*****************************************************************************/ @@ -285,18 +222,6 @@ static int osl_checkAddr(const char* addr) } -/*****************************************************************************/ -/* osl_decodeEtherAddr */ -/*****************************************************************************/ - -static char* osl_decodeEtherAddr(const char *ptr, char* buff) -{ - sprintf(buff, "%02X:%02X:%02X:%02X:%02X:%02X", - (ptr[0] & 0377), (ptr[1] & 0377), (ptr[2] & 0377), - (ptr[3] & 0377), (ptr[4] & 0377), (ptr[5] & 0377)); - return(buff); -} - #if defined (SPARC) #if defined (SOLARIS) && !defined(__sparcv8plus) && !defined(__sparcv9) diff --git a/sal/osl/w32/MAKEFILE.MK b/sal/osl/w32/MAKEFILE.MK index e6a33854366d..cd52ef549c8d 100644 --- a/sal/osl/w32/MAKEFILE.MK +++ b/sal/osl/w32/MAKEFILE.MK @@ -78,6 +78,10 @@ SLOFILES= $(SLO)$/conditn.obj \ $(SLO)$/pipe.obj \ $(SLO)$/util.obj \ $(SLO)$/file.obj\ + $(SLO)$/file_dirvol.obj\ + $(SLO)$/file_error.obj\ + $(SLO)$/file_url.obj\ + $(SLO)$/tempfile.obj\ $(SLO)$/path_helper.obj\ $(SLO)$/procimpl.obj \ $(SLO)$/salinit.obj @@ -101,6 +105,10 @@ OBJFILES= $(OBJ)$/conditn.obj \ $(OBJ)$/pipe.obj \ $(OBJ)$/util.obj \ $(OBJ)$/file.obj\ + $(OBJ)$/file_dirvol.obj\ + $(OBJ)$/file_error.obj\ + $(OBJ)$/file_url.obj\ + $(OBJ)$/tempfile.obj\ $(OBJ)$/path_helper.obj\ $(OBJ)$/procimpl.obj \ $(OBJ)$/salinit.obj diff --git a/sal/osl/w32/conditn.c b/sal/osl/w32/conditn.c index c87d161137b4..7af4398284be 100644 --- a/sal/osl/w32/conditn.c +++ b/sal/osl/w32/conditn.c @@ -107,8 +107,7 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, while ( 1 ) { /* Only wake up if a SendMessage call to the threads message loop is detected */ - - switch( MsgWaitForMultipleObjects( 1, &(HANDLE)Condition, FALSE, timeout, QS_SENDMESSAGE ) ) + switch( MsgWaitForMultipleObjects( 1, (HANDLE *)(&Condition), FALSE, timeout, QS_SENDMESSAGE ) ) { case WAIT_OBJECT_0 + 1: { diff --git a/sal/osl/w32/diagnose.c b/sal/osl/w32/diagnose.c index af1b67eff5ac..b2d22808dcd7 100644 --- a/sal/osl/w32/diagnose.c +++ b/sal/osl/w32/diagnose.c @@ -73,6 +73,7 @@ void SAL_CALL osl_breakDebug(void) void SAL_CALL osl_trace(const sal_Char* lpszFormat, ...) { va_list args; + int written = 0; va_start(args, lpszFormat); @@ -90,7 +91,11 @@ void SAL_CALL osl_trace(const sal_Char* lpszFormat, ...) { sal_Char szMessage[512]; szMessage[sizeof(szMessage)-1] = 0; - _vsnprintf( szMessage, sizeof(szMessage) -1, lpszFormat, args ); + written = _vsnprintf( szMessage, sizeof(szMessage) - 2, lpszFormat, args ); + if ( written == -1 ) + written = sizeof(szMessage) - 2; + szMessage[ written++ ] = '\n'; + szMessage[ written ] = 0; OutputDebugString( szMessage ); } diff --git a/sal/osl/w32/dllentry.c b/sal/osl/w32/dllentry.c index 11928a3b6458..ac47b1ac6050 100644 --- a/sal/osl/w32/dllentry.c +++ b/sal/osl/w32/dllentry.c @@ -255,7 +255,7 @@ void do_cleanup( void ) */ -#ifdef PRODUCT +#ifndef DBG_UTIL __try #endif { @@ -267,7 +267,7 @@ void do_cleanup( void ) rtl_cache_fini(); rtl_arena_fini(); } -#ifdef PRODUCT +#ifndef DBG_UTIL __except( EXCEPTION_EXECUTE_HANDLER ) { } diff --git a/sal/osl/w32/file.cxx b/sal/osl/w32/file.cxx index 6e8eb570f84c..60c51cfb3a73 100644 --- a/sal/osl/w32/file.cxx +++ b/sal/osl/w32/file.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: file.cxx,v $ - * $Revision: 1.19 $ + * $Revision: 1.0 $ * * This file is part of OpenOffice.org. * @@ -34,26 +34,19 @@ #define UNICODE #define _UNICODE #define _WIN32_WINNT 0x0500 -#include "systools\win32\uwinapi.h" +#include "systools/win32/uwinapi.h" -#include "path_helper.hxx" +#include "osl/file.hxx" -#include "sal/types.h" +#include "file_url.h" +#include "file_error.h" -#include "osl/file.hxx" #include "osl/diagnose.h" -#include "rtl/ustring.hxx" #include "rtl/alloc.h" -#include "rtl/tencinfo.h" -#include "osl/thread.h" -#include "osl/mutex.h" #include "rtl/byteseq.h" -#include "osl/time.h" -//#include <rtl/logfile.h> -#include <stdio.h> +#include "rtl/ustring.hxx" -#define WIN32_LEAN_AND_MEAN -#include <windows.h> +#include <stdio.h> #include <tchar.h> #ifdef __MINGW32__ @@ -61,2635 +54,751 @@ #include <ctype.h> #endif -#include <malloc.h> #include <algorithm> #include <limits> #ifdef max /* conflict w/ std::numeric_limits<T>::max() */ #undef max #endif - -//##################################################### -// BEGIN global -//##################################################### - -extern "C" oslMutex g_CurrentDirectoryMutex; /* Initialized in dllentry.c */ -oslMutex g_CurrentDirectoryMutex; - -//##################################################### -extern "C" BOOL TimeValueToFileTime(const TimeValue *cpTimeVal, FILETIME *pFTime) -{ - SYSTEMTIME BaseSysTime; - FILETIME BaseFileTime; - FILETIME FTime; - __int64 localTime; - BOOL fSuccess = FALSE; - - BaseSysTime.wYear = 1970; - BaseSysTime.wMonth = 1; - BaseSysTime.wDayOfWeek = 0; - BaseSysTime.wDay = 1; - BaseSysTime.wHour = 0; - BaseSysTime.wMinute = 0; - BaseSysTime.wSecond = 0; - BaseSysTime.wMilliseconds = 0; - - if (cpTimeVal==NULL) - return fSuccess; - - if ( SystemTimeToFileTime(&BaseSysTime, &BaseFileTime) ) - { - __int64 timeValue; - localTime=cpTimeVal->Seconds*(__int64)10000000+cpTimeVal->Nanosec/100; - *(__int64 *)&FTime=localTime; - fSuccess = 0 <= (timeValue= *((__int64 *)&BaseFileTime) + *((__int64 *) &FTime)); - if (fSuccess) - *(__int64 *)pFTime=timeValue; - } - return fSuccess; -} - -//##################################################### -extern "C" BOOL FileTimeToTimeValue(const FILETIME *cpFTime, TimeValue *pTimeVal) -{ - SYSTEMTIME BaseSysTime; - FILETIME BaseFileTime; - BOOL fSuccess = FALSE; /* Assume failure */ - - BaseSysTime.wYear = 1970; - BaseSysTime.wMonth = 1; - BaseSysTime.wDayOfWeek = 0; - BaseSysTime.wDay = 1; - BaseSysTime.wHour = 0; - BaseSysTime.wMinute = 0; - BaseSysTime.wSecond = 0; - BaseSysTime.wMilliseconds = 0; - - if ( SystemTimeToFileTime(&BaseSysTime, &BaseFileTime) ) - { - __int64 Value; - - fSuccess = 0 <= (Value = *((__int64 *)cpFTime) - *((__int64 *)&BaseFileTime)); - - if ( fSuccess ) - { - pTimeVal->Seconds = (unsigned long) (Value / 10000000L); - pTimeVal->Nanosec = (unsigned long)((Value % 10000000L) * 100); - } - } - return fSuccess; -} - -//##################################################### -extern "C" oslFileHandle SAL_CALL osl_createFileHandleFromOSHandle(HANDLE hFile) -{ - if ( IsValidHandle(hFile) ) - return (oslFileHandle)hFile; - else - return NULL; -} - -//##################################################### -// End global -//##################################################### - - -using namespace osl; - -#define ELEMENTS_OF_ARRAY(arr) (sizeof(arr)/(sizeof((arr)[0]))) - -// Allocate n number of t's on the stack return a pointer to it in p -#ifdef __MINGW32__ -#define STACK_ALLOC(p, t, n) (p) = reinterpret_cast<t*>(_alloca((n)*sizeof(t))); -#else -#define STACK_ALLOC(p, t, n) __try {(p) = reinterpret_cast<t*>(_alloca((n)*sizeof(t)));} \ - __except(EXCEPTION_EXECUTE_HANDLER) {(p) = NULL;} -#endif - -#if OSL_DEBUG_LEVEL > 0 -#define OSL_ENSURE_FILE( cond, msg, file ) ( (cond) ? (void)0 : _osl_warnFile( msg, file ) ) -#else -#define OSL_ENSURE_FILE( cond, msg, file ) ((void)0) +#ifdef min +#undef min #endif -#define PATHTYPE_ERROR 0 -#define PATHTYPE_RELATIVE 1 -#define PATHTYPE_ABSOLUTE_UNC 2 -#define PATHTYPE_ABSOLUTE_LOCAL 3 -#define PATHTYPE_MASK_TYPE 0xFF -#define PATHTYPE_IS_VOLUME 0x0100 -#define PATHTYPE_IS_SERVER 0x0200 - -#define VALIDATEPATH_NORMAL 0x0000 -#define VALIDATEPATH_ALLOW_WILDCARDS 0x0001 -#define VALIDATEPATH_ALLOW_ELLIPSE 0x0002 -#define VALIDATEPATH_ALLOW_RELATIVE 0x0004 -#define VALIDATEPATH_ALLOW_UNC 0x0008 - -#define WSTR_SYSTEM_ROOT_PATH L"\\\\.\\" - -typedef struct { - UINT uType; - - union { - WIN32_FIND_DATA FindData; - TCHAR cDriveString[MAX_PATH]; - }; - TCHAR szFullPath[MAX_PATH]; - BOOL bFullPathNormalized; - int nRefCount; -}DirectoryItem_Impl; - -#define DIRECTORYTYPE_LOCALROOT 0 -#define DIRECTORYTYPE_NETROOT 1 -#define DIRECTORYTYPE_NETRESORCE 2 -#define DIRECTORYTYPE_FILESYSTEM 3 - -#define DIRECTORYITEM_DRIVE 0 -#define DIRECTORYITEM_FILE 1 -#define DIRECTORYITEM_SERVER 2 - -typedef struct { - UINT uType; - union { - HANDLE hDirectory; - HANDLE hEnumDrives; - }; - TCHAR szDirectoryPath[MAX_PATH]; -} Directory_Impl; - -/* Different types of paths */ -typedef enum _PATHTYPE +//################################################################## +// File handle implementation +//################################################################## +struct FileHandle_Impl { - PATHTYPE_SYNTAXERROR = 0, - PATHTYPE_NETROOT, - PATHTYPE_NETSERVER, - PATHTYPE_VOLUME, - PATHTYPE_FILE -} PATHTYPE; - + CRITICAL_SECTION m_mutex; + HANDLE m_hFile; -namespace /* private */ -{ - // forward - void _osl_warnFile(const char*, rtl_uString*); - oslFileError SAL_CALL _osl_getFileURLFromSystemPath(rtl_uString* , rtl_uString**); - DWORD WINAPI IsValidFilePath(rtl_uString*, LPCTSTR*, DWORD, rtl_uString**); - HANDLE WINAPI OpenLogicalDrivesEnum(void); - BOOL WINAPI EnumLogicalDrives(HANDLE, LPTSTR); - BOOL WINAPI CloseLogicalDrivesEnum(HANDLE); - HANDLE WINAPI OpenDirectory(LPCTSTR); - BOOL WINAPI CloseDirectory(HANDLE); - BOOL WINAPI EnumDirectory(HANDLE, LPWIN32_FIND_DATA); - DWORD WINAPI GetCaseCorrectPathName(LPCTSTR, LPTSTR, DWORD); - oslFileError SAL_CALL _osl_getSystemPathFromFileURL(rtl_uString*, rtl_uString**, sal_Bool); - - /* OS error to errno values mapping table */ - struct errentry { - unsigned long oscode; /* OS return value */ - int errnocode; /* System V error code */ + /** State + */ + enum StateBits + { + STATE_SEEKABLE = 1, /* open() sets, iff regular file */ + STATE_READABLE = 2, /* open() sets, read() requires */ + STATE_WRITEABLE = 4, /* open() sets, write() requires */ + STATE_MODIFIED = 8 /* write() sets, flush() resets */ }; + int m_state; - struct errentry errtable[] = { - { ERROR_SUCCESS, osl_File_E_None }, /* 0 */ - { ERROR_INVALID_FUNCTION, osl_File_E_INVAL }, /* 1 */ - { ERROR_FILE_NOT_FOUND, osl_File_E_NOENT }, /* 2 */ - { ERROR_PATH_NOT_FOUND, osl_File_E_NOENT }, /* 3 */ - { ERROR_TOO_MANY_OPEN_FILES, osl_File_E_MFILE }, /* 4 */ - { ERROR_ACCESS_DENIED, osl_File_E_ACCES }, /* 5 */ - { ERROR_INVALID_HANDLE, osl_File_E_BADF }, /* 6 */ - { ERROR_ARENA_TRASHED, osl_File_E_NOMEM }, /* 7 */ - { ERROR_NOT_ENOUGH_MEMORY, osl_File_E_NOMEM }, /* 8 */ - { ERROR_INVALID_BLOCK, osl_File_E_NOMEM }, /* 9 */ - { ERROR_BAD_ENVIRONMENT, osl_File_E_2BIG }, /* 10 */ - { ERROR_BAD_FORMAT, osl_File_E_NOEXEC }, /* 11 */ - { ERROR_INVALID_ACCESS, osl_File_E_INVAL }, /* 12 */ - { ERROR_INVALID_DATA, osl_File_E_INVAL }, /* 13 */ - { ERROR_INVALID_DRIVE, osl_File_E_NOENT }, /* 15 */ - { ERROR_CURRENT_DIRECTORY, osl_File_E_ACCES }, /* 16 */ - { ERROR_NOT_SAME_DEVICE, osl_File_E_XDEV }, /* 17 */ - { ERROR_NO_MORE_FILES, osl_File_E_NOENT }, /* 18 */ - { ERROR_NOT_READY, osl_File_E_NOTREADY }, /* 21 */ - { ERROR_LOCK_VIOLATION, osl_File_E_ACCES }, /* 33 */ - { ERROR_BAD_NETPATH, osl_File_E_NOENT }, /* 53 */ - { ERROR_NETWORK_ACCESS_DENIED, osl_File_E_ACCES }, /* 65 */ - { ERROR_BAD_NET_NAME, osl_File_E_NOENT }, /* 67 */ - { ERROR_FILE_EXISTS, osl_File_E_EXIST }, /* 80 */ - { ERROR_CANNOT_MAKE, osl_File_E_ACCES }, /* 82 */ - { ERROR_FAIL_I24, osl_File_E_ACCES }, /* 83 */ - { ERROR_INVALID_PARAMETER, osl_File_E_INVAL }, /* 87 */ - { ERROR_NO_PROC_SLOTS, osl_File_E_AGAIN }, /* 89 */ - { ERROR_DRIVE_LOCKED, osl_File_E_ACCES }, /* 108 */ - { ERROR_BROKEN_PIPE, osl_File_E_PIPE }, /* 109 */ - { ERROR_DISK_FULL, osl_File_E_NOSPC }, /* 112 */ - { ERROR_INVALID_TARGET_HANDLE, osl_File_E_BADF }, /* 114 */ - { ERROR_INVALID_HANDLE, osl_File_E_INVAL }, /* 124 */ - { ERROR_WAIT_NO_CHILDREN, osl_File_E_CHILD }, /* 128 */ - { ERROR_CHILD_NOT_COMPLETE, osl_File_E_CHILD }, /* 129 */ - { ERROR_DIRECT_ACCESS_HANDLE, osl_File_E_BADF }, /* 130 */ - { ERROR_NEGATIVE_SEEK, osl_File_E_INVAL }, /* 131 */ - { ERROR_SEEK_ON_DEVICE, osl_File_E_ACCES }, /* 132 */ - { ERROR_DIR_NOT_EMPTY, osl_File_E_NOTEMPTY }, /* 145 */ - { ERROR_NOT_LOCKED, osl_File_E_ACCES }, /* 158 */ - { ERROR_BAD_PATHNAME, osl_File_E_NOENT }, /* 161 */ - { ERROR_MAX_THRDS_REACHED, osl_File_E_AGAIN }, /* 164 */ - { ERROR_LOCK_FAILED, osl_File_E_ACCES }, /* 167 */ - { ERROR_ALREADY_EXISTS, osl_File_E_EXIST }, /* 183 */ - { ERROR_FILENAME_EXCED_RANGE, osl_File_E_NOENT }, /* 206 */ - { ERROR_NESTING_NOT_ALLOWED, osl_File_E_AGAIN }, /* 215 */ - { ERROR_DIRECTORY, osl_File_E_NOENT }, /* 267 */ - { ERROR_NOT_ENOUGH_QUOTA, osl_File_E_NOMEM }, /* 1816 */ - { ERROR_UNEXP_NET_ERR, osl_File_E_NETWORK } /* 59 */ - }; + sal_uInt64 m_size; /* file size */ + LONGLONG m_offset; /* physical offset from begin of file */ + LONGLONG m_filepos; /* logical offset from begin of file */ - /* The following two constants must be the minimum and maximum - values in the (contiguous) range of osl_File_E_xec Failure errors. */ - #define MIN_EXEC_ERROR ERROR_INVALID_STARTING_CODESEG - #define MAX_EXEC_ERROR ERROR_INFLOOP_IN_RELOC_CHAIN + LONGLONG m_bufptr; /* buffer offset from begin of file */ + SIZE_T m_buflen; /* buffer filled [0, m_bufsiz - 1] */ - /* These are the low and high value in the range of errors that are - access violations */ - #define MIN_EACCES_RANGE ERROR_WRITE_PROTECT - #define MAX_EACCES_RANGE ERROR_SHARING_BUFFER_EXCEEDED + SIZE_T m_bufsiz; + sal_uInt8 * m_buffer; - //##################################################### - oslFileError MapError(DWORD dwError) - { - for (int i = 0; i < ELEMENTS_OF_ARRAY(errtable); ++i ) - { - if (dwError == errtable[i].oscode) - return static_cast<oslFileError>(errtable[i].errnocode); - } + explicit FileHandle_Impl (HANDLE hFile); + ~FileHandle_Impl(); - /* The error code wasn't in the table. We check for a range of - osl_File_E_ACCES errors or exec failure errors (ENOEXEC). - Otherwise osl_File_E_INVAL is returned. */ - if ( dwError >= MIN_EACCES_RANGE && dwError <= MAX_EACCES_RANGE) - return osl_File_E_ACCES; - else if ( dwError >= MIN_EXEC_ERROR && dwError <= MAX_EXEC_ERROR) - return osl_File_E_NOEXEC; - else - return osl_File_E_INVAL; - } - - //##################################################### - oslFileError SAL_CALL osl_openLocalRoot( - rtl_uString *strDirectoryPath, oslDirectory *pDirectory) - { - rtl_uString *strSysPath = NULL; - oslFileError error; - - if ( !pDirectory ) - return osl_File_E_INVAL; + static void* operator new(size_t n); + static void operator delete(void * p, size_t); + static SIZE_T getpagesize(); - *pDirectory = NULL; + sal_uInt64 getPos() const; + oslFileError setPos (sal_uInt64 uPos); - error = _osl_getSystemPathFromFileURL( strDirectoryPath, &strSysPath, sal_False ); + sal_uInt64 getSize() const; + oslFileError setSize (sal_uInt64 uPos); - if ( osl_File_E_None == error ) - { - Directory_Impl *pDirImpl; + oslFileError readAt ( + LONGLONG nOffset, + void * pBuffer, + DWORD nBytesRequested, + sal_uInt64 * pBytesRead); - pDirImpl = reinterpret_cast<Directory_Impl*>(rtl_allocateMemory( sizeof(Directory_Impl))); - _tcscpy( pDirImpl->szDirectoryPath, reinterpret_cast<LPCTSTR>(rtl_uString_getStr(strSysPath)) ); + oslFileError writeAt ( + LONGLONG nOffset, + void const * pBuffer, + DWORD nBytesToWrite, + sal_uInt64 * pBytesWritten); - /* Append backslash if neccessary */ + oslFileError readFileAt ( + LONGLONG nOffset, + void * pBuffer, + sal_uInt64 uBytesRequested, + sal_uInt64 * pBytesRead); - /* @@@ToDo - use function ensure backslash - */ - if ( pDirImpl->szDirectoryPath[_tcslen(pDirImpl->szDirectoryPath) - 1] != L'\\' ) - _tcscat( pDirImpl->szDirectoryPath, L"\\" ); + oslFileError writeFileAt ( + LONGLONG nOffset, + void const * pBuffer, + sal_uInt64 uBytesToWrite, + sal_uInt64 * pBytesWritten); - pDirImpl->uType = DIRECTORYTYPE_LOCALROOT; - pDirImpl->hEnumDrives = OpenLogicalDrivesEnum(); + oslFileError readLineAt ( + LONGLONG nOffset, + sal_Sequence ** ppSequence, + sal_uInt64 * pBytesRead); - /* @@@ToDo - Use IsValidHandle(...) - */ - if ( pDirImpl->hEnumDrives != INVALID_HANDLE_VALUE ) - { - *pDirectory = (oslDirectory)pDirImpl; - error = osl_File_E_None; - } - else - { - if ( pDirImpl ) - rtl_freeMemory(pDirImpl); + oslFileError writeSequence_Impl ( + sal_Sequence ** ppSequence, + SIZE_T * pnOffset, + const void * pBuffer, + SIZE_T nBytes); - error = MapError( GetLastError() ); - } + oslFileError syncFile(); - rtl_uString_release( strSysPath ); - } - return error; - } - - //##################################################### - oslFileError SAL_CALL osl_openFileDirectory( - rtl_uString *strDirectoryPath, oslDirectory *pDirectory) + /** Buffer cache / allocator. + */ + class Allocator { - // MT: Done in osl_openDirectory! -// rtl_uString *strSysPath = NULL; - oslFileError error; - - //MT: Not done in osl_openNetworkServer, why here? - if ( !pDirectory ) - return osl_File_E_INVAL; - - *pDirectory = NULL; - - // MT: Done in osl_openDirectory! -// error = _osl_getSystemPathFromFileURL( strDirectoryPath, &strSysPath, sal_False ); -// if ( osl_File_E_None == error ) - { - Directory_Impl *pDirImpl; - - pDirImpl = reinterpret_cast<Directory_Impl*>(rtl_allocateMemory(sizeof(Directory_Impl))); - _tcscpy( pDirImpl->szDirectoryPath, reinterpret_cast<LPCTSTR>(rtl_uString_getStr(strDirectoryPath)) ); - - /* Append backslash if neccessary */ + rtl_cache_type * m_cache; + SIZE_T m_bufsiz; - /* @@@ToDo - use function ensure backslash - */ - if ( pDirImpl->szDirectoryPath[_tcslen(pDirImpl->szDirectoryPath) - 1] != L'\\' ) - _tcscat( pDirImpl->szDirectoryPath, L"\\" ); - // MT: ??? - // GetCaseCorrectPathName( pDirImpl->szDirectoryPath, pDirImpl->szDirectoryPath, sizeof(pDirImpl->szDirectoryPath) ); + Allocator (Allocator const &); + Allocator & operator= (Allocator const &); - pDirImpl->uType = DIRECTORYTYPE_FILESYSTEM; - pDirImpl->hDirectory = OpenDirectory( pDirImpl->szDirectoryPath ); + public: + static Allocator & get(); - if ( pDirImpl->hDirectory ) - { - *pDirectory = (oslDirectory)pDirImpl; - error = osl_File_E_None; - } - else - { - if ( pDirImpl ) - rtl_freeMemory(pDirImpl); - - error = MapError( GetLastError() ); - } + void allocate (sal_uInt8 ** ppBuffer, SIZE_T * pnSize); + void deallocate (sal_uInt8 * pBuffer); -// rtl_uString_release( strSysPath ); - } - return error; - } - - typedef struct tagDIRECTORY - { - HANDLE hFind; - WIN32_FIND_DATA aFirstData; - } DIRECTORY, *PDIRECTORY, FAR *LPDIRECTORY; + protected: + Allocator(); + ~Allocator(); + }; - //##################################################### - HANDLE WINAPI OpenDirectory(LPCTSTR lpszPath) + /** Guard. + */ + class Guard { - LPDIRECTORY pDirectory = (LPDIRECTORY)HeapAlloc(GetProcessHeap(), 0, sizeof(DIRECTORY)); + LPCRITICAL_SECTION m_mutex; - if (pDirectory) - { - TCHAR szFileMask[MAX_PATH]; - int nLen; + public: + explicit Guard(LPCRITICAL_SECTION pMutex); + ~Guard(); + }; +}; - _tcscpy( szFileMask, lpszPath ); - nLen = _tcslen( szFileMask ); +FileHandle_Impl::Allocator & +FileHandle_Impl::Allocator::get() +{ + static Allocator g_aBufferAllocator; + return g_aBufferAllocator; +} - if (nLen && szFileMask[nLen-1] != '\\') - _tcscat(szFileMask, TEXT("\\*.*")); - else - _tcscat(szFileMask, TEXT("*.*")); +FileHandle_Impl::Allocator::Allocator() + : m_cache (0), + m_bufsiz (0) +{ + SIZE_T const pagesize = FileHandle_Impl::getpagesize(); + m_cache = rtl_cache_create ( + "osl_file_buffer_cache", pagesize, 0, 0, 0, 0, 0, 0, 0); + if (0 != m_cache) + m_bufsiz = pagesize; +} - pDirectory->hFind = FindFirstFile(szFileMask, &pDirectory->aFirstData); +FileHandle_Impl::Allocator::~Allocator() +{ + rtl_cache_destroy(m_cache), m_cache = 0; +} - if (!IsValidHandle(pDirectory->hFind)) - { - if ( GetLastError() != ERROR_NO_MORE_FILES ) - { - HeapFree(GetProcessHeap(), 0, pDirectory); - pDirectory = NULL; - } - } - } - return (HANDLE)pDirectory; - } +void FileHandle_Impl::Allocator::allocate (sal_uInt8 ** ppBuffer, SIZE_T * pnSize) +{ + OSL_PRECOND((0 != ppBuffer) && (0 != pnSize), "FileHandle_Impl::Allocator::allocate(): contract violation"); + *ppBuffer = static_cast< sal_uInt8* >(rtl_cache_alloc(m_cache)), *pnSize = m_bufsiz; +} - //##################################################### - BOOL WINAPI CloseDirectory(HANDLE hDirectory) - { - BOOL fSuccess = FALSE; - LPDIRECTORY pDirectory = (LPDIRECTORY)hDirectory; +void FileHandle_Impl::Allocator::deallocate (sal_uInt8 * pBuffer) +{ + if (0 != pBuffer) + rtl_cache_free (m_cache, pBuffer); +} - if (pDirectory) - { - if (IsValidHandle(pDirectory->hFind)) - fSuccess = FindClose(pDirectory->hFind); +FileHandle_Impl::Guard::Guard(LPCRITICAL_SECTION pMutex) + : m_mutex (pMutex) +{ + OSL_PRECOND (m_mutex != 0, "FileHandle_Impl::Guard::Guard(): null pointer."); + ::EnterCriticalSection (m_mutex); +} +FileHandle_Impl::Guard::~Guard() +{ + OSL_PRECOND (m_mutex != 0, "FileHandle_Impl::Guard::~Guard(): null pointer."); + ::LeaveCriticalSection (m_mutex); +} - fSuccess = HeapFree(GetProcessHeap(), 0, pDirectory) && fSuccess; - } - else - SetLastError(ERROR_INVALID_HANDLE); +FileHandle_Impl::FileHandle_Impl(HANDLE hFile) + : m_hFile (hFile), + m_state (STATE_READABLE | STATE_WRITEABLE), + m_size (0), + m_offset (0), + m_filepos (0), + m_bufptr (-1), + m_buflen (0), + m_bufsiz (0), + m_buffer (0) +{ + ::InitializeCriticalSection (&m_mutex); + Allocator::get().allocate (&m_buffer, &m_bufsiz); + if (m_buffer != 0) + memset (m_buffer, 0, m_bufsiz); +} - return fSuccess; - } +FileHandle_Impl::~FileHandle_Impl() +{ + Allocator::get().deallocate (m_buffer), m_buffer = 0; + ::DeleteCriticalSection (&m_mutex); +} - //##################################################### - BOOL WINAPI EnumDirectory(HANDLE hDirectory, LPWIN32_FIND_DATA pFindData) - { - BOOL fSuccess = FALSE; - LPDIRECTORY pDirectory = (LPDIRECTORY)hDirectory; +void * FileHandle_Impl::operator new(size_t n) +{ + return rtl_allocateMemory(n); +} - if ( pDirectory ) - { - BOOL fValid; +void FileHandle_Impl::operator delete(void * p, size_t) +{ + rtl_freeMemory(p); +} - do - { - if ( pDirectory->aFirstData.cFileName[0] ) - { - *pFindData = pDirectory->aFirstData; - fSuccess = TRUE; - pDirectory->aFirstData.cFileName[0] = 0; - } - else if ( IsValidHandle( pDirectory->hFind ) ) - fSuccess = FindNextFile( pDirectory->hFind, pFindData ); - else - { - fSuccess = FALSE; - SetLastError( ERROR_NO_MORE_FILES ); - } +SIZE_T FileHandle_Impl::getpagesize() +{ + SYSTEM_INFO info; + ::GetSystemInfo (&info); + return sal::static_int_cast< SIZE_T >(info.dwPageSize); +} - fValid = fSuccess && _tcscmp( TEXT("."), pFindData->cFileName ) != 0 && _tcscmp( TEXT(".."), pFindData->cFileName ) != 0; +sal_uInt64 FileHandle_Impl::getPos() const +{ + return sal::static_int_cast< sal_uInt64 >(m_filepos); +} - } while( fSuccess && !fValid ); - } - else - SetLastError( ERROR_INVALID_HANDLE ); +oslFileError FileHandle_Impl::setPos (sal_uInt64 uPos) +{ + m_filepos = sal::static_int_cast< LONGLONG >(uPos); + return osl_File_E_None; +} - return fSuccess; - } +sal_uInt64 FileHandle_Impl::getSize() const +{ + LONGLONG bufend = std::max((LONGLONG)(0), m_bufptr) + m_buflen; + return std::max(m_size, sal::static_int_cast< sal_uInt64 >(bufend)); +} - //##################################################### - oslFileError SAL_CALL osl_openNetworkServer(rtl_uString *strSysDirPath, oslDirectory *pDirectory) - { - NETRESOURCEW aNetResource; - HANDLE hEnum; - DWORD dwError; +oslFileError FileHandle_Impl::setSize (sal_uInt64 uSize) +{ + LARGE_INTEGER nDstPos; nDstPos.QuadPart = sal::static_int_cast< LONGLONG >(uSize); + if (!::SetFilePointerEx(m_hFile, nDstPos, 0, FILE_BEGIN)) + return oslTranslateFileError( GetLastError() ); - ZeroMemory( &aNetResource, sizeof(aNetResource) ); + if (!::SetEndOfFile(m_hFile)) + return oslTranslateFileError( GetLastError() ); + m_size = uSize; - aNetResource.lpRemoteName = reinterpret_cast<LPWSTR>(strSysDirPath->buffer); + nDstPos.QuadPart = m_offset; + if (!::SetFilePointerEx(m_hFile, nDstPos, 0, FILE_BEGIN)) + return oslTranslateFileError( GetLastError() ); - dwError = WNetOpenEnumW( - RESOURCE_GLOBALNET, - RESOURCETYPE_DISK, - RESOURCEUSAGE_CONNECTABLE | RESOURCEUSAGE_CONTAINER, - &aNetResource, - &hEnum ); + return osl_File_E_None; +} - if ( ERROR_SUCCESS == dwError ) - { - Directory_Impl *pDirImpl; +oslFileError FileHandle_Impl::readAt ( + LONGLONG nOffset, + void * pBuffer, + DWORD nBytesRequested, + sal_uInt64 * pBytesRead) +{ + OSL_PRECOND(m_state & STATE_SEEKABLE, "FileHandle_Impl::readAt(): not seekable"); + if (!(m_state & STATE_SEEKABLE)) + return osl_File_E_SPIPE; - pDirImpl = reinterpret_cast<Directory_Impl*>(rtl_allocateMemory(sizeof(Directory_Impl))); - pDirImpl->uType = DIRECTORYTYPE_NETROOT; - pDirImpl->hDirectory = hEnum; - *pDirectory = (oslDirectory)pDirImpl; - } - return MapError( dwError ); - } + OSL_PRECOND(m_state & STATE_READABLE, "FileHandle_Impl::readAt(): not readable"); + if (!(m_state & STATE_READABLE)) + return osl_File_E_BADF; - //##################################################### - oslFileError SAL_CALL osl_getNextNetResource( - oslDirectory Directory, - oslDirectoryItem *pItem, - sal_uInt32 uHint ) + if (nOffset != m_offset) { - Directory_Impl *pDirImpl = (Directory_Impl *)Directory; - DirectoryItem_Impl *pItemImpl = NULL; - BYTE buffer[16384]; - LPNETRESOURCEW lpNetResource = (LPNETRESOURCEW)buffer; - DWORD dwError, dwCount, dwBufSize; - - uHint = uHint; /* to get no warning */ - - if ( !pItem ) - return osl_File_E_INVAL; - - *pItem = NULL; - - if ( !pDirImpl ) - return osl_File_E_INVAL; - - dwCount = 1; - dwBufSize = sizeof(buffer); - dwError = WNetEnumResource( pDirImpl->hDirectory, &dwCount, lpNetResource, &dwBufSize ); - - switch ( dwError ) - { - case NO_ERROR: - case ERROR_MORE_DATA: - { - pItemImpl = reinterpret_cast<DirectoryItem_Impl*>(rtl_allocateMemory(sizeof(DirectoryItem_Impl))); - if ( !pItemImpl ) - return osl_File_E_NOMEM; - - ZeroMemory( pItemImpl, sizeof(DirectoryItem_Impl) ); - pItemImpl->uType = DIRECTORYITEM_DRIVE; - osl_acquireDirectoryItem( (oslDirectoryItem)pItemImpl ); - - wcscpy( pItemImpl->cDriveString, lpNetResource->lpRemoteName ); - - *pItem = pItemImpl; - } - return osl_File_E_None; - case ERROR_NO_MORE_ITEMS: - return osl_File_E_NOENT; - default: - return MapError( dwError ); - } + LARGE_INTEGER liOffset; liOffset.QuadPart = nOffset; + if (!::SetFilePointerEx(m_hFile, liOffset, 0, FILE_BEGIN)) + return oslTranslateFileError( GetLastError() ); + m_offset = nOffset; } - //##################################################### - oslFileError SAL_CALL osl_getNextDrive( - oslDirectory Directory, oslDirectoryItem *pItem, sal_uInt32 uHint ) - { - Directory_Impl *pDirImpl = (Directory_Impl *)Directory; - DirectoryItem_Impl *pItemImpl = NULL; - BOOL fSuccess; - - uHint = uHint; /* avoid warnings */ - - if ( !pItem ) - return osl_File_E_INVAL; - - *pItem = NULL; - - if ( !pDirImpl ) - return osl_File_E_INVAL; + DWORD dwDone = 0; + if (!::ReadFile(m_hFile, pBuffer, nBytesRequested, &dwDone, 0)) + return oslTranslateFileError( GetLastError() ); + m_offset += dwDone; - pItemImpl = reinterpret_cast<DirectoryItem_Impl*>(rtl_allocateMemory(sizeof(DirectoryItem_Impl))); - if ( !pItemImpl ) - return osl_File_E_NOMEM; + *pBytesRead = dwDone; + return osl_File_E_None; +} +oslFileError FileHandle_Impl::writeAt ( + LONGLONG nOffset, + void const * pBuffer, + DWORD nBytesToWrite, + sal_uInt64 * pBytesWritten) +{ + OSL_PRECOND(m_state & STATE_SEEKABLE, "FileHandle_Impl::writeAt(): not seekable"); + if (!(m_state & STATE_SEEKABLE)) + return osl_File_E_SPIPE; - ZeroMemory( pItemImpl, sizeof(DirectoryItem_Impl) ); - pItemImpl->uType = DIRECTORYITEM_DRIVE; - osl_acquireDirectoryItem( (oslDirectoryItem)pItemImpl ); - fSuccess = EnumLogicalDrives( pDirImpl->hEnumDrives, pItemImpl->cDriveString ); + OSL_PRECOND(m_state & STATE_WRITEABLE, "FileHandle_Impl::writeAt(): not writeable"); + if (!(m_state & STATE_WRITEABLE)) + return osl_File_E_BADF; - if ( fSuccess ) - { - *pItem = pItemImpl; - return osl_File_E_None; - } - else - { - rtl_freeMemory( pItemImpl ); - return MapError( GetLastError() ); - } - } - - //##################################################### - oslFileError SAL_CALL osl_getNextFileItem( - oslDirectory Directory, oslDirectoryItem *pItem, sal_uInt32 uHint) + if (nOffset != m_offset) { - Directory_Impl *pDirImpl = (Directory_Impl *)Directory; - DirectoryItem_Impl *pItemImpl = NULL; - BOOL fFound; - - uHint = uHint; /* avoid warnings */ - - if ( !pItem ) - return osl_File_E_INVAL; - - *pItem = NULL; - - if ( !pDirImpl ) - return osl_File_E_INVAL; - - pItemImpl = reinterpret_cast<DirectoryItem_Impl*>(rtl_allocateMemory(sizeof(DirectoryItem_Impl))); - if ( !pItemImpl ) - return osl_File_E_NOMEM; - - memset( pItemImpl, 0, sizeof(DirectoryItem_Impl) ); - fFound = EnumDirectory( pDirImpl->hDirectory, &pItemImpl->FindData ); - - if ( fFound ) - { - pItemImpl->uType = DIRECTORYITEM_FILE; - pItemImpl->nRefCount = 1; - _tcscpy( pItemImpl->szFullPath, pDirImpl->szDirectoryPath ); - _tcscat( pItemImpl->szFullPath, pItemImpl->FindData.cFileName ); - pItemImpl->bFullPathNormalized = FALSE; - *pItem = (oslDirectoryItem)pItemImpl; - return osl_File_E_None; - } - else - { - rtl_freeMemory( pItemImpl ); - return MapError( GetLastError() ); - } + LARGE_INTEGER liOffset; liOffset.QuadPart = nOffset; + if (!::SetFilePointerEx (m_hFile, liOffset, 0, FILE_BEGIN)) + return oslTranslateFileError( GetLastError() ); + m_offset = nOffset; } - //##################################################### - oslFileError SAL_CALL osl_getDriveInfo( - oslDirectoryItem Item, oslFileStatus *pStatus, sal_uInt32 uFieldMask) - { - DirectoryItem_Impl *pItemImpl = (DirectoryItem_Impl *)Item; - TCHAR cDrive[3] = TEXT("A:"); - TCHAR cRoot[4] = TEXT("A:\\"); - - if ( !pItemImpl ) - return osl_File_E_INVAL; - - pStatus->uValidFields = 0; - - cDrive[0] = pItemImpl->cDriveString[0]; - cRoot[0] = pItemImpl->cDriveString[0]; - - if ( uFieldMask & osl_FileStatus_Mask_FileName ) - { - if ( pItemImpl->cDriveString[0] == '\\' && - pItemImpl->cDriveString[1] == '\\' ) - { - LPCWSTR lpFirstBkSlash = wcschr( &pItemImpl->cDriveString[2], '\\' ); - - if ( lpFirstBkSlash && lpFirstBkSlash[1] ) - { - LPCWSTR lpLastBkSlash = wcschr( &lpFirstBkSlash[1], '\\' ); - - if ( lpLastBkSlash ) - rtl_uString_newFromStr_WithLength( &pStatus->ustrFileName, reinterpret_cast<const sal_Unicode*>(&lpFirstBkSlash[1]), lpLastBkSlash - lpFirstBkSlash - 1 ); - else - rtl_uString_newFromStr( &pStatus->ustrFileName, reinterpret_cast<const sal_Unicode*>(&lpFirstBkSlash[1]) ); - pStatus->uValidFields |= osl_FileStatus_Mask_FileName; - } - } - else switch ( GetDriveType( cRoot ) ) - { - case DRIVE_REMOTE: - { - TCHAR szBuffer[1024]; - DWORD dwBufsize = ELEMENTS_OF_ARRAY(szBuffer); - DWORD dwResult = WNetGetConnection( cDrive, szBuffer, &dwBufsize ); - - if ( NO_ERROR == dwResult ) - { - TCHAR szFileName[ELEMENTS_OF_ARRAY(szBuffer) + 16]; - - swprintf( szFileName, L"%s [%s]", cDrive, szBuffer ); - rtl_uString_newFromStr( &pStatus->ustrFileName, reinterpret_cast<const sal_Unicode*>(szFileName) ); - } - else - rtl_uString_newFromStr( &pStatus->ustrFileName, reinterpret_cast<const sal_Unicode*>(cDrive) ); - } - pStatus->uValidFields |= osl_FileStatus_Mask_FileName; - break; - case DRIVE_FIXED: - { - TCHAR szVolumeNameBuffer[1024]; - - if ( GetVolumeInformation( cRoot, szVolumeNameBuffer, ELEMENTS_OF_ARRAY(szVolumeNameBuffer), NULL, NULL, NULL, NULL, 0 ) ) - { - TCHAR szFileName[ELEMENTS_OF_ARRAY(szVolumeNameBuffer) + 16]; - - swprintf( szFileName, L"%s [%s]", cDrive, szVolumeNameBuffer ); - rtl_uString_newFromStr( &pStatus->ustrFileName, reinterpret_cast<const sal_Unicode*>(szFileName) ); - } - else - rtl_uString_newFromStr( &pStatus->ustrFileName, reinterpret_cast<const sal_Unicode*>(cDrive) ); - } - pStatus->uValidFields |= osl_FileStatus_Mask_FileName; - break; - case DRIVE_CDROM: - case DRIVE_REMOVABLE: - pStatus->uValidFields |= osl_FileStatus_Mask_FileName; - rtl_uString_newFromStr( &pStatus->ustrFileName, reinterpret_cast<const sal_Unicode*>(cRoot) ); - break; - case DRIVE_UNKNOWN: - default: - break; - } - } + DWORD dwDone = 0; + if (!::WriteFile(m_hFile, pBuffer, nBytesToWrite, &dwDone, 0)) + return oslTranslateFileError( GetLastError() ); + m_offset += dwDone; - pStatus->eType = osl_File_Type_Volume; - pStatus->uValidFields |= osl_FileStatus_Mask_Type; + m_size = std::max(m_size, sal::static_int_cast< sal_uInt64 >(m_offset)); - if ( uFieldMask & osl_FileStatus_Mask_FileURL ) - { - rtl_uString *ustrSystemPath = NULL; + *pBytesWritten = dwDone; + return osl_File_E_None; +} - rtl_uString_newFromStr( &ustrSystemPath, reinterpret_cast<const sal_Unicode*>(pItemImpl->cDriveString) ); - osl_getFileURLFromSystemPath( ustrSystemPath, &pStatus->ustrFileURL ); - rtl_uString_release( ustrSystemPath ); - pStatus->uValidFields |= osl_FileStatus_Mask_FileURL; - } - return osl_File_E_None; - } +oslFileError FileHandle_Impl::readFileAt ( + LONGLONG nOffset, + void * pBuffer, + sal_uInt64 uBytesRequested, + sal_uInt64 * pBytesRead) +{ + static sal_uInt64 const g_limit_dword = std::numeric_limits< DWORD >::max(); + if (g_limit_dword < uBytesRequested) + return osl_File_E_OVERFLOW; + DWORD nBytesRequested = sal::static_int_cast< DWORD >(uBytesRequested); - //##################################################### - oslFileError SAL_CALL osl_getServerInfo( - oslDirectoryItem Item, oslFileStatus *pStatus, sal_uInt32 uFieldMask ) + if (0 == (m_state & STATE_SEEKABLE)) { - DirectoryItem_Impl *pItemImpl = (DirectoryItem_Impl *)Item; - - if ( !pItemImpl ) - return osl_File_E_INVAL; - - pStatus->uValidFields = 0; - - // pStatus->uValidFields |= osl_FileStatus_Mask_FileName; - - // if ( _tcscmp( pItemImpl->FindData.cFileName, TEXT(".") ) == 0 ) - // rtl_uString_newFromAscii( &pStatus->ustrFileName, "/" ); - // else - // rtl_uString_newFromStr( &pStatus->ustrFileName, pItemImpl->FindData.cFileName ); - - pStatus->eType = osl_File_Type_Directory; - pStatus->uValidFields |= osl_FileStatus_Mask_Type; - - if ( uFieldMask & osl_FileStatus_Mask_FileURL ) - { - rtl_uString *ustrSystemPath = NULL; - - rtl_uString_newFromStr( &ustrSystemPath, reinterpret_cast<const sal_Unicode*>(pItemImpl->szFullPath) ); - osl_getFileURLFromSystemPath( ustrSystemPath, &pStatus->ustrFileURL ); - rtl_uString_release( ustrSystemPath ); - pStatus->uValidFields |= osl_FileStatus_Mask_FileURL; - } + // not seekable (pipe) + DWORD dwDone = 0; + if (!::ReadFile(m_hFile, pBuffer, nBytesRequested, &dwDone, 0)) + return oslTranslateFileError( GetLastError() ); + *pBytesRead = dwDone; return osl_File_E_None; } - - typedef struct tagDRIVEENUM { - LPCTSTR lpIdent; - TCHAR cBuffer[/*('Z' - 'A' + 1) * sizeof("A:\\") + 1*/256]; - LPCTSTR lpCurrent; - } DRIVEENUM, * PDRIVEENUM, FAR * LPDRIVEENUM; - - //##################################################### - HANDLE WINAPI OpenLogicalDrivesEnum(void) + else if (0 == m_buffer) { - LPDRIVEENUM pEnum = NULL; - - pEnum = (LPDRIVEENUM)HeapAlloc( GetProcessHeap(), 0, sizeof(DRIVEENUM) ); - - if ( pEnum ) - { - DWORD dwNumCopied = GetLogicalDriveStrings( (sizeof(pEnum->cBuffer) - 1) / sizeof(TCHAR), pEnum->cBuffer ); - - if ( dwNumCopied && dwNumCopied < sizeof(pEnum->cBuffer) / sizeof(TCHAR) ) - { - pEnum->lpCurrent = pEnum->cBuffer; - pEnum->lpIdent = L"tagDRIVEENUM"; - } - else - { - HeapFree( GetProcessHeap(), 0, pEnum ); - pEnum = NULL; - } - } - return pEnum ? (HANDLE)pEnum : INVALID_HANDLE_VALUE; + // not buffered + return readAt (nOffset, pBuffer, nBytesRequested, pBytesRead); } - - //##################################################### - BOOL WINAPI EnumLogicalDrives(HANDLE hEnum, LPTSTR lpBuffer) - { - BOOL fSuccess = FALSE; - LPDRIVEENUM pEnum = (LPDRIVEENUM)hEnum; - - if ( pEnum ) - { - int nLen = _tcslen( pEnum->lpCurrent ); - - if ( nLen ) - { - CopyMemory( lpBuffer, pEnum->lpCurrent, (nLen + 1) * sizeof(TCHAR) ); - pEnum->lpCurrent += nLen + 1; - fSuccess = TRUE; - } - else - SetLastError( ERROR_NO_MORE_FILES ); - } - else - SetLastError( ERROR_INVALID_HANDLE ); - - return fSuccess; - } - - //##################################################### - BOOL WINAPI CloseLogicalDrivesEnum(HANDLE hEnum) - { - BOOL fSuccess = FALSE; - LPDRIVEENUM pEnum = (LPDRIVEENUM)hEnum; - - if ( pEnum ) - { - HeapFree( GetProcessHeap(), 0, pEnum ); - fSuccess = TRUE; - } - else - SetLastError( ERROR_INVALID_HANDLE ); - - return fSuccess; - } - - //##################################################### - //Undocumented in SHELL32.DLL ordinal 35 - BOOL WINAPI PathRemoveFileSpec(LPTSTR lpPath) - { - BOOL fSuccess = FALSE; // Assume failure - LPTSTR lpLastBkSlash = _tcsrchr( lpPath, '\\' ); - LPTSTR lpLastSlash = _tcsrchr( lpPath, '/' ); - LPTSTR lpLastDelimiter = lpLastSlash > lpLastBkSlash ? lpLastSlash : lpLastBkSlash; - - if ( lpLastDelimiter ) - { - if ( 0 == *(lpLastDelimiter + 1) ) - { - if ( lpLastDelimiter > lpPath && *(lpLastDelimiter - 1) != ':' ) - { - *lpLastDelimiter = 0; - fSuccess = TRUE; - } - } - else - { - *(++lpLastDelimiter) = 0; - fSuccess = TRUE; - } - } - return fSuccess; - } - - //##################################################### - // Undocumented in SHELL32.DLL ordinal 32 - LPTSTR WINAPI PathAddBackslash(LPTSTR lpPath) - { - LPTSTR lpEndPath = NULL; - - if ( lpPath ) - { - int nLen = _tcslen(lpPath); - - if ( !nLen || lpPath[nLen-1] != '\\' && lpPath[nLen-1] != '/' && nLen < MAX_PATH - 1 ) - { - lpEndPath = lpPath + nLen; - *lpEndPath++ = '\\'; - *lpEndPath = 0; - } - } - return lpEndPath; - } - -#if 1 - //##################################################### - // Same as GetLongPathName but also 95/NT4 - DWORD WINAPI GetCaseCorrectPathNameEx( - LPCTSTR lpszShortPath, // file name - LPTSTR lpszLongPath, // path buffer - DWORD cchBuffer, // size of path buffer - DWORD nSkipLevels - ) + else { -// log file doesn't work, because initialization of rtl log init() calls this method... -// RTL_LOGFILE_TRACE1( "SAL: GetCaseCorrectPathNameEx: %s (Skip:%n)", lpszShortPath,nSkipLevels ); - - TCHAR szPath[MAX_PATH]; - BOOL fSuccess; - - cchBuffer = cchBuffer; /* avoid warnings */ - - _tcscpy( szPath, lpszShortPath ); - - fSuccess = PathRemoveFileSpec( szPath ); - - if ( fSuccess ) + sal_uInt8 * buffer = static_cast< sal_uInt8* >(pBuffer); + for (*pBytesRead = 0; nBytesRequested > 0; ) { - int nLen = _tcslen( szPath ); - LPCTSTR lpszFileSpec = lpszShortPath + nLen; - BOOL bSkipThis; - - if ( 0 == _tcscmp( lpszFileSpec, TEXT("..") ) ) - { - bSkipThis = TRUE; - nSkipLevels += 1; - } - else if ( - 0 == _tcscmp( lpszFileSpec, TEXT(".") ) || - 0 == _tcscmp( lpszFileSpec, TEXT("\\") ) || - 0 == _tcscmp( lpszFileSpec, TEXT("/") ) - ) - { - bSkipThis = TRUE; - } - else if ( nSkipLevels ) - { - bSkipThis = TRUE; - nSkipLevels--; - } - else - bSkipThis = FALSE; + LONGLONG const bufptr = (nOffset / m_bufsiz) * m_bufsiz; + SIZE_T const bufpos = (nOffset % m_bufsiz); - GetCaseCorrectPathNameEx( szPath, szPath, MAX_PATH, nSkipLevels ); - - PathAddBackslash( szPath ); - - /* Analyze parent if not only a trailing backslash was cutted but a real file spec */ - if ( !bSkipThis ) + if (bufptr != m_bufptr) { - WIN32_FIND_DATA aFindFileData; - HANDLE hFind = FindFirstFile( lpszShortPath, &aFindFileData ); + // flush current buffer + oslFileError result = syncFile(); + if (result != osl_File_E_None) + return (result); + m_bufptr = -1, m_buflen = 0; - if ( IsValidHandle(hFind) ) + if (nBytesRequested >= m_bufsiz) { - _tcscat( szPath, aFindFileData.cFileName[0] ? aFindFileData.cFileName : aFindFileData.cAlternateFileName ); - - FindClose( hFind ); + // buffer too small, read through from file + sal_uInt64 uDone = 0; + result = readAt (nOffset, &(buffer[*pBytesRead]), nBytesRequested, &uDone); + if (result != osl_File_E_None) + return (result); + + nBytesRequested -= sal::static_int_cast< DWORD >(uDone), *pBytesRead += uDone; + return osl_File_E_None; } - else - return 0; - } - } - else - { - /* File specification can't be removed therefore the short path is either a drive - or a network share. If still levels to skip are left, the path specification - tries to travel below the file system root */ - if ( nSkipLevels ) - return 0; - - _tcsupr( szPath ); - } - - _tcscpy( lpszLongPath, szPath ); - - return _tcslen( lpszLongPath ); - } -#endif - -#if 0 - inline size_t wcstoupper( LPWSTR lpStr ) - { - size_t nLen = wcslen( lpStr ); - - for ( LPWSTR p = lpStr; p < lpStr + nLen; p++ ) - { - *p = towupper(*p); - } - - return nLen; - } -#endif - - //##################################################### - DWORD WINAPI GetCaseCorrectPathName( - LPCTSTR lpszShortPath, // file name - LPTSTR lpszLongPath, // path buffer - DWORD cchBuffer // size of path buffer - ) -#if 0 - { - /* Special handling for "\\.\" as system root */ - if ( lpszShortPath && 0 == wcscmp( lpszShortPath, WSTR_SYSTEM_ROOT_PATH ) ) - { - if ( cchBuffer >= ELEMENTS_OF_ARRAY(WSTR_SYSTEM_ROOT_PATH) ) - { - wcscpy( lpszLongPath, WSTR_SYSTEM_ROOT_PATH ); - return ELEMENTS_OF_ARRAY(WSTR_SYSTEM_ROOT_PATH) - 1; + // update buffer (pointer) + sal_uInt64 uDone = 0; + result = readAt (bufptr, m_buffer, m_bufsiz, &uDone); + if (result != osl_File_E_None) + return (result); + m_bufptr = bufptr, m_buflen = sal::static_int_cast< SIZE_T >(uDone); } - else - return ELEMENTS_OF_ARRAY(WSTR_SYSTEM_ROOT_PATH); - } - else - { - DWORD nSrcLen = wcslen( lpszShortPath ); - - if ( cchBuffer > nSrcLen ) + if (bufpos >= m_buflen) { - wcscpy( lpszLongPath, lpszShortPath ); - wcstoupper( lpszLongPath ); + // end of file + return osl_File_E_None; } - else - nSrcLen++; - return nSrcLen; + SIZE_T const bytes = std::min(m_buflen - bufpos, nBytesRequested); + memcpy (&(buffer[*pBytesRead]), &(m_buffer[bufpos]), bytes); + nBytesRequested -= bytes, *pBytesRead += bytes, nOffset += bytes; } + return osl_File_E_None; } -#else - { - /* Special handling for "\\.\" as system root */ - if ( lpszShortPath && 0 == wcscmp( lpszShortPath, WSTR_SYSTEM_ROOT_PATH ) ) - { - if ( cchBuffer >= ELEMENTS_OF_ARRAY(WSTR_SYSTEM_ROOT_PATH) ) - { - wcscpy( lpszLongPath, WSTR_SYSTEM_ROOT_PATH ); - return ELEMENTS_OF_ARRAY(WSTR_SYSTEM_ROOT_PATH) - 1; - } - else - return ELEMENTS_OF_ARRAY(WSTR_SYSTEM_ROOT_PATH) - 1; - } - else - return GetCaseCorrectPathNameEx( lpszShortPath, lpszLongPath, cchBuffer, 0 ); - } - -#endif - - //##################################################### - #define CHARSET_SEPARATOR TEXT("\\/") - - BOOL WINAPI IsValidFilePathComponent( - LPCTSTR lpComponent, LPCTSTR *lppComponentEnd, DWORD dwFlags) - { - LPCTSTR lpComponentEnd = NULL; - LPCTSTR lpCurrent = lpComponent; - BOOL fValid = TRUE; /* Assume success */ - TCHAR cLast = 0; - - /* Path component length must not exceed MAX_PATH */ - - while ( !lpComponentEnd && lpCurrent && lpCurrent - lpComponent < MAX_PATH ) - { - switch ( *lpCurrent ) - { - /* Both backslash and slash determine the end of a path component */ - case '\0': - case '/': - case '\\': - switch ( cLast ) - { - /* Component must not end with '.' or blank and can't be empty */ - - case '.': - if ( dwFlags & VALIDATEPATH_ALLOW_ELLIPSE ) - { - if ( 1 == lpCurrent - lpComponent ) - { - /* Current directory is O.K. */ - lpComponentEnd = lpCurrent; - break; - } - else if ( 2 == lpCurrent - lpComponent && '.' == *lpComponent ) - { - /* Parent directory is O.K. */ - lpComponentEnd = lpCurrent; - break; - } - } - case 0: - case ' ': - lpComponentEnd = lpCurrent - 1; - fValid = FALSE; - break; - default: - lpComponentEnd = lpCurrent; - break; - } - break; - /* '?' and '*' are valid wildcards but not valid file name characters */ - case '?': - case '*': - if ( dwFlags & VALIDATEPATH_ALLOW_WILDCARDS ) - break; - /* The following characters are reserved */ - case '<': - case '>': - case '\"': - case '|': - case ':': - lpComponentEnd = lpCurrent; - fValid = FALSE; - break; - default: - /* Characters below ASCII 32 are not allowed */ - if ( *lpCurrent < ' ' ) - { - lpComponentEnd = lpCurrent; - fValid = FALSE; - } - break; - } - cLast = *lpCurrent++; - } - - /* If we don't reached the end of the component the length of the component was to long - ( See condition of while loop ) */ - if ( !lpComponentEnd ) - { - fValid = FALSE; - lpComponentEnd = lpCurrent; - } - - /* Test wether the component specifies a device name what is not allowed */ - - // MT: PERFORMANCE: - // This is very expensive. A lot of calls to _tcsicmp. - // in SRC6870m71 67.000 calls of this method while empty office start result into more than 1.500.00 calls of _tcsicmp! - // Possible optimizations - // - Array should be const static - // - Sorted array, use binary search - // - More intelligent check for com1-9, lpt1-9 - // Maybe make szComponent upper case, don't search case intensitive - // Talked to HRO: Could be removed. Shouldn't be used in OOo, and if used for something like a filename, it will lead to an error anyway. - /* - if ( fValid ) - { - LPCTSTR alpDeviceNames[] = - { - TEXT("CON"), - TEXT("PRN"), - TEXT("AUX"), - TEXT("CLOCK$"), - TEXT("NUL"), - TEXT("LPT1"), - TEXT("LPT2"), - TEXT("LPT3"), - TEXT("LPT4"), - TEXT("LPT5"), - TEXT("LPT6"), - TEXT("LPT7"), - TEXT("LPT8"), - TEXT("LPT9"), - TEXT("COM1"), - TEXT("COM2"), - TEXT("COM3"), - TEXT("COM4"), - TEXT("COM5"), - TEXT("COM6"), - TEXT("COM7"), - TEXT("COM8"), - TEXT("COM9") - }; - - TCHAR szComponent[MAX_PATH]; - int nComponentLength; - LPCTSTR lpDot; - int i; - - // A device name with an extension is also invalid - lpDot = _tcschr( lpComponent, '.' ); - - if ( !lpDot || lpDot > lpComponentEnd ) - nComponentLength = lpComponentEnd - lpComponent; - else - nComponentLength = lpDot - lpComponent; - - _tcsncpy( szComponent, lpComponent, nComponentLength ); - szComponent[nComponentLength] = 0; - - for ( i = 0; i < sizeof( alpDeviceNames ) / sizeof(LPCTSTR); i++ ) - { - if ( 0 == _tcsicmp( szComponent, alpDeviceNames[i] ) ) - { - lpComponentEnd = lpComponent; - fValid = FALSE; - break; - } - } - } - */ - - if ( fValid ) - { - // Empty components are not allowed - if ( lpComponentEnd - lpComponent < 1 ) - fValid = FALSE; - - // If we reached the end of the string NULL is returned - else if ( !*lpComponentEnd ) - lpComponentEnd = NULL; - - } - - if ( lppComponentEnd ) - *lppComponentEnd = lpComponentEnd; +} - return fValid; - } +oslFileError FileHandle_Impl::writeFileAt ( + LONGLONG nOffset, + void const * pBuffer, + sal_uInt64 uBytesToWrite, + sal_uInt64 * pBytesWritten) +{ + static sal_uInt64 const g_limit_dword = std::numeric_limits< DWORD >::max(); + if (g_limit_dword < uBytesToWrite) + return osl_File_E_OVERFLOW; + DWORD nBytesToWrite = sal::static_int_cast< DWORD >(uBytesToWrite); - //##################################################### - DWORD WINAPI IsValidFilePath(rtl_uString *path, LPCTSTR *lppError, DWORD dwFlags, rtl_uString **corrected) + if (0 == (m_state & STATE_SEEKABLE)) { - LPCTSTR lpszPath = reinterpret_cast< LPCTSTR >(path->buffer); - LPCTSTR lpComponent; - BOOL fValid = TRUE; - DWORD dwPathType = PATHTYPE_ERROR; - - if ( dwFlags & VALIDATEPATH_ALLOW_RELATIVE ) - dwFlags |= VALIDATEPATH_ALLOW_ELLIPSE; - - if ( !lpszPath ) - { - fValid = FALSE; - lpComponent = lpszPath; - } - - /* Test for UNC path notation */ - if ( 2 == _tcsspn( lpszPath, CHARSET_SEPARATOR ) ) - { - /* Place the pointer behind the leading to backslashes */ - - lpComponent = lpszPath + 2; - - fValid = IsValidFilePathComponent( lpComponent, &lpComponent, VALIDATEPATH_ALLOW_ELLIPSE ); - - /* So far we have a valid servername. Now let's see if we also have a network resource */ - - dwPathType = PATHTYPE_ABSOLUTE_UNC; - - if ( fValid ) - { - if ( lpComponent && !*++lpComponent ) - lpComponent = NULL; - - if ( !lpComponent ) - { - #if 0 - /* We only have a Server specification what is invalid */ - - lpComponent = lpszPath; - fValid = FALSE; - #else - dwPathType |= PATHTYPE_IS_SERVER; - #endif - } - else - { - /* Now test the network resource */ - - fValid = IsValidFilePathComponent( lpComponent, &lpComponent, 0 ); - - /* If we now reached the end of the path, everything is O.K. */ - - - if ( fValid && (!lpComponent || lpComponent && !*++lpComponent ) ) - { - lpComponent = NULL; - dwPathType |= PATHTYPE_IS_VOLUME; - } - } - } - } - - /* Local path verification. Must start with <drive>: */ - else if ( _istalpha( lpszPath[0] ) && ':' == lpszPath[1] ) - { - /* Place pointer behind correct drive specification */ - - lpComponent = lpszPath + 2; - - if ( 1 == _tcsspn( lpComponent, CHARSET_SEPARATOR ) ) - lpComponent++; - else if ( *lpComponent ) - fValid = FALSE; - - dwPathType = PATHTYPE_ABSOLUTE_LOCAL; - - /* Now we are behind the backslash or it was a simple drive without backslash */ - - if ( fValid && !*lpComponent ) - { - lpComponent = NULL; - dwPathType |= PATHTYPE_IS_VOLUME; - } - } - - /* Can be a relative path */ - else if ( dwFlags & VALIDATEPATH_ALLOW_RELATIVE ) - { - lpComponent = lpszPath; - - /* Relative path can start with a backslash */ - - if ( 1 == _tcsspn( lpComponent, CHARSET_SEPARATOR ) ) - { - lpComponent++; - if ( !*lpComponent ) - lpComponent = NULL; - } - - dwPathType = PATHTYPE_RELATIVE; - } - - /* Anything else is an error */ - else - { - fValid = FALSE; - lpComponent = lpszPath; - } - - /* Now validate each component of the path */ - while ( fValid && lpComponent ) - { - // Correct path by merging consecutive slashes: - if (*lpComponent == '\\' && corrected != NULL) { - sal_Int32 i = lpComponent - lpszPath; - rtl_uString_newReplaceStrAt(corrected, path, i, 1, NULL); - //TODO: handle out-of-memory - lpszPath = reinterpret_cast< LPCTSTR >((*corrected)->buffer); - lpComponent = lpszPath + i; - } - - fValid = IsValidFilePathComponent( lpComponent, &lpComponent, dwFlags ); - - if ( fValid && lpComponent ) - { - lpComponent++; - - /* If the string behind the backslash is empty, we've done */ - - if ( !*lpComponent ) - lpComponent = NULL; - } - } - - if ( fValid && _tcslen( lpszPath ) >= MAX_PATH ) - { - fValid = FALSE; - lpComponent = lpszPath + MAX_PATH; - } - - if ( lppError ) - *lppError = lpComponent; - - return fValid ? dwPathType : PATHTYPE_ERROR; + // not seekable (pipe) + DWORD dwDone = 0; + if (!::WriteFile(m_hFile, pBuffer, nBytesToWrite, &dwDone, 0)) + return oslTranslateFileError( GetLastError() ); + *pBytesWritten = dwDone; + return osl_File_E_None; } - - //##################################################### - bool is_floppy_drive(const rtl::OUString& path); - - //##################################################### - struct Component + else if (0 == m_buffer) { - Component() : - begin_(0), end_(0) - {} - - bool isPresent() const - { return (static_cast<sal_Int32>(end_ - begin_) > 0); } - - const sal_Unicode* begin_; - const sal_Unicode* end_; - }; - - //##################################################### - struct UNCComponents - { - Component server_; - Component share_; - Component resource_; - }; - - //##################################################### - const wchar_t UNC_PREFIX[] = L"\\\\"; - const wchar_t BACKSLASH = '\\'; - const wchar_t SLASH = '/'; - - bool is_UNC_path(const sal_Unicode* path) - { return (0 == wcsncmp(UNC_PREFIX, reinterpret_cast<LPCWSTR>(path), ELEMENTS_OF_ARRAY(UNC_PREFIX) - 1)); } - - //##################################################### - bool is_UNC_path(const rtl::OUString& path) - { return is_UNC_path(path.getStr()); } - - //##################################################### - void parse_UNC_path(const sal_Unicode* path, UNCComponents* puncc) - { - OSL_PRECOND(is_UNC_path(path), "Precondition violated: No UNC path"); - OSL_PRECOND(rtl_ustr_indexOfChar(path, SLASH) != -1, "Path must not contain slashes"); - - const sal_Unicode* pend = path + rtl_ustr_getLength(path); - const sal_Unicode* ppos = path + 2; - - puncc->server_.begin_ = ppos; - while ((ppos < pend) && (*ppos != BACKSLASH)) - ppos++; - - puncc->server_.end_ = ppos; - - if (BACKSLASH == *ppos) - { - puncc->share_.begin_ = ++ppos; - while ((ppos < pend) && (*ppos != BACKSLASH)) - ppos++; - - puncc->share_.end_ = ppos; - - if (BACKSLASH == *ppos) - { - puncc->resource_.begin_ = ++ppos; - while (ppos < pend) - ppos++; - - puncc->resource_.end_ = ppos; - } - } - - OSL_POSTCOND(puncc->server_.isPresent() && puncc->share_.isPresent(), \ - "Postcondition violated: Invalid UNC path detected"); + // not buffered + return writeAt(nOffset, pBuffer, nBytesToWrite, pBytesWritten); } - - //##################################################### - void parse_UNC_path(const rtl::OUString& path, UNCComponents* puncc) - { parse_UNC_path(path.getStr(), puncc); } - - //##################################################### - bool is_volume_mount_point(const rtl::OUString& path) + else { - rtl::OUString p(path); - osl::systemPathRemoveSeparator(p); - - bool is_volume_root = false; - - if (!is_floppy_drive(p)) + sal_uInt8 const * buffer = static_cast< sal_uInt8 const* >(pBuffer); + for (*pBytesWritten = 0; nBytesToWrite > 0; ) { - DWORD fattr = GetFileAttributes(reinterpret_cast<LPCTSTR>(p.getStr())); - - if ((INVALID_FILE_ATTRIBUTES != fattr) && - (FILE_ATTRIBUTE_REPARSE_POINT & fattr)) + LONGLONG const bufptr = (nOffset / m_bufsiz) * m_bufsiz; + SIZE_T const bufpos = (nOffset % m_bufsiz); + if (bufptr != m_bufptr) { - WIN32_FIND_DATA find_data; - HANDLE h_find = FindFirstFile(reinterpret_cast<LPCTSTR>(p.getStr()), &find_data); + // flush current buffer + oslFileError result = syncFile(); + if (result != osl_File_E_None) + return (result); + m_bufptr = -1, m_buflen = 0; - if (IsValidHandle(h_find) && - (FILE_ATTRIBUTE_REPARSE_POINT & find_data.dwFileAttributes) && - (IO_REPARSE_TAG_MOUNT_POINT == find_data.dwReserved0)) + if (nBytesToWrite >= m_bufsiz) { - is_volume_root = true; + // buffer too small, write through to file + sal_uInt64 uDone = 0; + result = writeAt (nOffset, &(buffer[*pBytesWritten]), nBytesToWrite, &uDone); + if (result != osl_File_E_None) + return (result); + if (uDone != nBytesToWrite) + return osl_File_E_IO; + + nBytesToWrite -= sal::static_int_cast< DWORD >(uDone), *pBytesWritten += uDone; + return osl_File_E_None; } - if (IsValidHandle(h_find)) - FindClose(h_find); - } - } - return is_volume_root; - } - - //##################################################### - // Has the given path a parent or are we already there, - // e.g. 'c:\' or '\\server\share\'? - bool has_path_parent(const sal_Unicode* path) - { - bool has_parent = false; - - if (is_UNC_path(path)) - { - UNCComponents unc_comp; - parse_UNC_path(path, &unc_comp); - has_parent = unc_comp.resource_.isPresent(); - } - else - { - has_parent = !osl::systemPathIsLogicalDrivePattern(path); - } - return has_parent; - } - - //##################################################### - // @see bool has_path_parent(const sal_Unicode* path) - bool has_path_parent(const rtl::OUString& path) - { return has_path_parent(path.getStr()); } - - //##################################################### - bool path_get_parent(rtl::OUString& path) - { - OSL_PRECOND(path.lastIndexOf(SLASH) == -1, "Path must not have slashes"); - if (!has_path_parent(path)) - { - sal_Int32 i = path.lastIndexOf(BACKSLASH); - if (-1 < i) - { - path = rtl::OUString(path.getStr(), i); - return true; + // update buffer (pointer) + sal_uInt64 uDone = 0; + result = readAt (bufptr, m_buffer, m_bufsiz, &uDone); + if (result != osl_File_E_None) + return (result); + m_bufptr = bufptr, m_buflen = sal::static_int_cast< SIZE_T >(uDone); } - } - return false; - } - //############################################# - /* Cut off the last part of the given path to - get the parent only, e.g. 'c:\dir\subdir' -> - 'c:\dir' or '\\share\sub\dir' -> '\\share\sub' - @return The position where the path has been cut - off (this is the posistion of the last backslash). - If there are no more parents 0 will be returned, - e.g. 'c:\' or '\\Share' have no more parents */ - int path_make_parent(sal_Unicode* path) - { - OSL_PRECOND(rtl_ustr_indexOfChar(path, SLASH) != -1, "Path must not contain slashes"); - OSL_PRECOND(has_path_parent(path), "Path must have a parent"); - - sal_Unicode* pos_last_backslash = path + rtl_ustr_lastIndexOfChar(path, BACKSLASH); - *pos_last_backslash = 0; - return (pos_last_backslash - path); - } - - //##################################################### - void path_travel_to_volume_root(const rtl::OUString& system_path, rtl::OUString& volume_root) - { - rtl::OUString sys_path(system_path); - - while(!is_volume_mount_point(sys_path) && path_get_parent(sys_path)) - /**/; - - volume_root = sys_path; - osl_systemPathEnsureSeparator(&volume_root.pData); - } - - //##################################################### - inline bool is_floppy_A_present() - { return (GetLogicalDrives() & 1); } - - //##################################################### - inline bool is_floppy_B_present() - { return (GetLogicalDrives() & 2); } - - //##################################################### - // determines if a volume mount point shows to a floppy - // disk by comparing the unique volume names - const LPWSTR FLOPPY_A = L"A:\\"; - const LPWSTR FLOPPY_B = L"B:\\"; - - bool is_floppy_volume_mount_point(const rtl::OUString& path) - { - rtl::OUString p(path); - osl_systemPathEnsureSeparator(&p.pData); + SIZE_T const bytes = std::min(m_bufsiz - bufpos, nBytesToWrite); + memcpy (&(m_buffer[bufpos]), &(buffer[*pBytesWritten]), bytes); + nBytesToWrite -= bytes, *pBytesWritten += bytes, nOffset += bytes; - TCHAR vn[51]; - if (GetVolumeNameForVolumeMountPoint(reinterpret_cast<LPCTSTR>(p.getStr()), vn, ELEMENTS_OF_ARRAY(vn))) - { - TCHAR vnfloppy[51]; - if (is_floppy_A_present() && - GetVolumeNameForVolumeMountPoint(FLOPPY_A, vnfloppy, ELEMENTS_OF_ARRAY(vnfloppy)) && - (0 == wcscmp(vn, vnfloppy))) - return true; - - if (is_floppy_B_present() && - GetVolumeNameForVolumeMountPoint(FLOPPY_B, vnfloppy, ELEMENTS_OF_ARRAY(vnfloppy)) && - (0 == wcscmp(vn, vnfloppy))) - return true; - } - return false; - } - - //################################################ - // we must take into account that even a floppy - // drive may be mounted to a directory so checking - // for the drive letter alone is not sufficient - // we must compare the unique volume name with - // that of the available floppy disks - LPCWSTR FLOPPY_DRV_LETTERS = TEXT("AaBb"); - - bool is_floppy_drive(const rtl::OUString& path) - { - const sal_Unicode* pf = path.getStr(); - const sal_Unicode* ps = path.getStr() + 1; - return ((wcschr(FLOPPY_DRV_LETTERS, *pf) && (L':' == *ps)) || - is_floppy_volume_mount_point(path)); - } - - //############################################# - UINT get_volume_mount_point_drive_type(const rtl::OUString& path) - { - if (0 == path.getLength()) - return GetDriveType(NULL); - - rtl::OUString p(path); - osl_systemPathEnsureSeparator(&p.pData); - - TCHAR vn[51]; - if (GetVolumeNameForVolumeMountPoint(reinterpret_cast<LPCTSTR>(p.getStr()), vn, ELEMENTS_OF_ARRAY(vn))) - return GetDriveType(vn); - - return DRIVE_NO_ROOT_DIR; - } - - //############################################# - oslFileError osl_get_drive_type(const rtl::OUString& path, oslVolumeInfo* pInfo) - { - // GetDriveType fails on empty volume mount points - // see Knowledge Base Q244089 - UINT drive_type; - if (is_volume_mount_point(path)) - drive_type = get_volume_mount_point_drive_type(path); - else - drive_type = GetDriveType(reinterpret_cast<LPCTSTR>(path.getStr())); - - if (DRIVE_NO_ROOT_DIR == drive_type) - return MapError(ERROR_INVALID_DRIVE); - - pInfo->uValidFields |= osl_VolumeInfo_Mask_Attributes; - - switch (drive_type) - { - case DRIVE_CDROM: - pInfo->uAttributes |= osl_Volume_Attribute_CompactDisc | osl_Volume_Attribute_Removeable; - break; - case DRIVE_REMOVABLE: - pInfo->uAttributes |= osl_Volume_Attribute_Removeable; - if (is_floppy_drive(path)) - pInfo->uAttributes |= osl_Volume_Attribute_FloppyDisk; - break; - case DRIVE_FIXED: - pInfo->uAttributes |= osl_Volume_Attribute_FixedDisk; - break; - case DRIVE_RAMDISK: - pInfo->uAttributes |= osl_Volume_Attribute_RAMDisk; - break; - case DRIVE_REMOTE: - pInfo->uAttributes |= osl_Volume_Attribute_Remote; - break; - case DRIVE_UNKNOWN: - pInfo->uAttributes = 0; - break; - default: - pInfo->uValidFields &= ~osl_VolumeInfo_Mask_Attributes; - pInfo->uAttributes = 0; - break; + m_buflen = std::max(m_buflen, bufpos + bytes); + m_state |= STATE_MODIFIED; } return osl_File_E_None; } +} - //############################################# - inline bool is_volume_space_info_request(sal_uInt32 field_mask) - { - return (field_mask & - (osl_VolumeInfo_Mask_TotalSpace | - osl_VolumeInfo_Mask_UsedSpace | - osl_VolumeInfo_Mask_FreeSpace)); - } +oslFileError FileHandle_Impl::readLineAt ( + LONGLONG nOffset, + sal_Sequence ** ppSequence, + sal_uInt64 * pBytesRead) +{ + oslFileError result = osl_File_E_None; - //############################################# - void get_volume_space_information(const rtl::OUString& path, oslVolumeInfo *pInfo) + LONGLONG bufptr = (nOffset / m_bufsiz) * m_bufsiz; + if (bufptr != m_bufptr) { - BOOL ret = GetDiskFreeSpaceEx( - reinterpret_cast<LPCTSTR>(path.getStr()), - (PULARGE_INTEGER)&pInfo->uFreeSpace, - (PULARGE_INTEGER)&pInfo->uTotalSpace, - NULL); - - if (ret) - { - pInfo->uUsedSpace = pInfo->uTotalSpace - pInfo->uFreeSpace; - pInfo->uValidFields |= osl_VolumeInfo_Mask_TotalSpace | - osl_VolumeInfo_Mask_UsedSpace | - osl_VolumeInfo_Mask_FreeSpace; - } - } + /* flush current buffer */ + result = syncFile(); + if (result != osl_File_E_None) + return (result); - //############################################# - inline bool is_filesystem_attributes_request(sal_uInt32 field_mask) - { - return (field_mask & - (osl_VolumeInfo_Mask_MaxNameLength | - osl_VolumeInfo_Mask_MaxPathLength | - osl_VolumeInfo_Mask_FileSystemName | - osl_VolumeInfo_Mask_FileSystemCaseHandling)); - } + /* update buffer (pointer) */ + sal_uInt64 uDone = 0; + result = readAt (bufptr, m_buffer, m_bufsiz, &uDone); + if (result != osl_File_E_None) + return (result); - //############################################# - inline bool is_drivetype_request(sal_uInt32 field_mask) - { - return (field_mask & osl_VolumeInfo_Mask_Attributes); + m_bufptr = bufptr, m_buflen = sal::static_int_cast< SIZE_T >(uDone); } - //############################################# - oslFileError get_filesystem_attributes(const rtl::OUString& path, sal_uInt32 field_mask, oslVolumeInfo* pInfo) - { - pInfo->uAttributes = 0; - - oslFileError osl_error = osl_File_E_None; + static int const LINE_STATE_BEGIN = 0; + static int const LINE_STATE_CR = 1; + static int const LINE_STATE_LF = 2; - // osl_get_drive_type must be called first because - // this function resets osl_VolumeInfo_Mask_Attributes - // on failure - if (is_drivetype_request(field_mask)) - osl_error = osl_get_drive_type(path, pInfo); + SIZE_T bufpos = sal::static_int_cast< SIZE_T >(nOffset - m_bufptr), curpos = bufpos, dstpos = 0; + int state = (bufpos >= m_buflen) ? LINE_STATE_LF : LINE_STATE_BEGIN; - if ((osl_File_E_None == osl_error) && is_filesystem_attributes_request(field_mask)) + for ( ; state != LINE_STATE_LF; ) + { + if (curpos >= m_buflen) { - WCHAR vn[MAX_PATH]; - WCHAR fsn[MAX_PATH]; - DWORD serial; - DWORD mcl; - DWORD flags; - - if (GetVolumeInformation(reinterpret_cast<LPCTSTR>(path.getStr()), vn, MAX_PATH, &serial, &mcl, &flags, fsn, MAX_PATH)) + /* buffer examined */ + if (0 < (curpos - bufpos)) { - pInfo->uValidFields |= osl_VolumeInfo_Mask_MaxNameLength; - pInfo->uMaxNameLength = mcl; - - pInfo->uValidFields |= osl_VolumeInfo_Mask_MaxPathLength; - pInfo->uMaxPathLength = MAX_PATH; - - pInfo->uValidFields |= osl_VolumeInfo_Mask_FileSystemName; - rtl_uString_newFromStr(&pInfo->ustrFileSystemName, reinterpret_cast<const sal_Unicode*>(fsn)); - - // volumes (even NTFS) will always be considered case - // insensitive because the Win32 API is not able to - // deal with case sensitive volumes see M$ Knowledge Base - // article 100625 that's why we never set the attribute - // osl_Volume_Attribute_Case_Sensitive - - if (flags & FS_CASE_IS_PRESERVED) - pInfo->uAttributes |= osl_Volume_Attribute_Case_Is_Preserved; - - pInfo->uValidFields |= osl_VolumeInfo_Mask_Attributes; + /* flush buffer to sequence */ + result = writeSequence_Impl ( + ppSequence, &dstpos, &(m_buffer[bufpos]), curpos - bufpos); + if (result != osl_File_E_None) + return (result); + *pBytesRead += curpos - bufpos, nOffset += curpos - bufpos; } - } - return osl_error; - } - //############################################# - // Create the specified directory and call the - // user specified callback function. On success - // the function returns ERROR_SUCCESS else a - // Win32 error code. - DWORD create_dir_with_callback( - sal_Unicode* dir_path, - oslDirectoryCreationCallbackFunc aDirectoryCreationCallbackFunc, - void* pData) - { - if (CreateDirectory(reinterpret_cast<LPCTSTR>(dir_path), NULL)) - { - if (aDirectoryCreationCallbackFunc) + bufptr = nOffset / m_bufsiz * m_bufsiz; + if (bufptr != m_bufptr) { - rtl::OUString url; - FileBase::getFileURLFromSystemPath(dir_path, url); - aDirectoryCreationCallbackFunc(pData, url.pData); + /* update buffer (pointer) */ + sal_uInt64 uDone = 0; + result = readAt (bufptr, m_buffer, m_bufsiz, &uDone); + if (result != osl_File_E_None) + return (result); + m_bufptr = bufptr, m_buflen = sal::static_int_cast< SIZE_T >(uDone); } - return ERROR_SUCCESS; - } - return GetLastError(); - } - - //############################################# - DWORD create_dir_recursively_( - sal_Unicode* dir_path, - oslDirectoryCreationCallbackFunc aDirectoryCreationCallbackFunc, - void* pData) - { - OSL_PRECOND(rtl_ustr_getLength(dir_path) > 0 && (rtl_ustr_lastIndexOfChar(dir_path, BACKSLASH) != rtl_ustr_getLength(dir_path) - 1), \ - "Path must not end with a backslash"); - - DWORD w32_error = create_dir_with_callback( - dir_path, aDirectoryCreationCallbackFunc, pData); - - if (w32_error == ERROR_SUCCESS) - return ERROR_SUCCESS; - - if ((w32_error != ERROR_PATH_NOT_FOUND) || !has_path_parent(dir_path)) - return w32_error; - - int pos = path_make_parent(dir_path); - - w32_error = create_dir_recursively_( - dir_path, aDirectoryCreationCallbackFunc, pData); - if (ERROR_SUCCESS != w32_error) - return w32_error; - - dir_path[pos] = BACKSLASH; - - return create_dir_recursively_( - dir_path, aDirectoryCreationCallbackFunc, pData); - } - - //##################################################### - // Temp file - //##################################################### - - - //##################################################### - oslFileError osl_setup_base_directory_impl_( - rtl_uString* pustrDirectoryURL, - rtl_uString** ppustr_base_dir) - { - rtl_uString* dir_url = 0; - rtl_uString* dir = 0; - oslFileError error = osl_File_E_None; - - if (pustrDirectoryURL) - rtl_uString_assign(&dir_url, pustrDirectoryURL); - else - error = osl_getTempDirURL(&dir_url); - - if (osl_File_E_None == error) - { - error = _osl_getSystemPathFromFileURL(dir_url, &dir, sal_False); - rtl_uString_release(dir_url); - } - - if (osl_File_E_None == error ) - { - rtl_uString_assign(ppustr_base_dir, dir); - rtl_uString_release(dir); - } - - return error; - } - - //##################################################### - oslFileError osl_setup_createTempFile_impl_( - rtl_uString* pustrDirectoryURL, - oslFileHandle* pHandle, - rtl_uString** ppustrTempFileURL, - rtl_uString** ppustr_base_dir, - sal_Bool* b_delete_on_close) - { - oslFileError osl_error; - - OSL_PRECOND(((0 != pHandle) || (0 != ppustrTempFileURL)), "Invalid parameter!"); - - if ((0 == pHandle) && (0 == ppustrTempFileURL)) - { - osl_error = osl_File_E_INVAL; - } - else - { - osl_error = osl_setup_base_directory_impl_( - pustrDirectoryURL, ppustr_base_dir); - - *b_delete_on_close = (sal_Bool)(0 == ppustrTempFileURL); - } - - return osl_error; - } - - //##################################################### - oslFileError osl_win32_GetTempFileName_impl_( - rtl_uString* base_directory, LPWSTR temp_file_name) - { - oslFileError osl_error = osl_File_E_None; - - if (0 == GetTempFileNameW( - reinterpret_cast<LPCWSTR>(rtl_uString_getStr(base_directory)), - L"", - 0, - temp_file_name)) - { - osl_error = MapError(GetLastError()); - } - - return osl_error; - } - - //##################################################### - sal_Bool osl_win32_CreateFile_impl_( - LPCWSTR file_name, sal_Bool b_delete_on_close, oslFileHandle* p_handle) - { - DWORD flags = FILE_ATTRIBUTE_NORMAL; - HANDLE hFile; - - OSL_ASSERT(p_handle); - - if (b_delete_on_close) - flags |= FILE_FLAG_DELETE_ON_CLOSE; - - hFile = CreateFileW( - file_name, - GENERIC_READ | GENERIC_WRITE, - 0, - NULL, - TRUNCATE_EXISTING, - flags, - NULL); - - if (IsValidHandle(hFile)) - *p_handle = (oslFileHandle)hFile; - - return (sal_Bool)IsValidHandle(hFile); - } - - //############################################# - oslFileError osl_createTempFile_impl_( - rtl_uString* base_directory, - LPWSTR tmp_name, - sal_Bool b_delete_on_close, - oslFileHandle* pHandle, - rtl_uString** ppustrTempFileURL) - { - oslFileError osl_error; - - do - { - osl_error = osl_win32_GetTempFileName_impl_(base_directory, tmp_name); - - /* if file could not be opened try again */ - - if ((osl_File_E_None != osl_error) || (0 == pHandle) || - osl_win32_CreateFile_impl_(tmp_name, b_delete_on_close, pHandle)) + bufpos = sal::static_int_cast< SIZE_T >(nOffset - m_bufptr), curpos = bufpos; + if (bufpos >= m_buflen) break; - - } while(1); // try until success - - if ((osl_File_E_None == osl_error) && !b_delete_on_close) - { - rtl_uString* pustr = 0; - rtl_uString_newFromStr(&pustr, reinterpret_cast<const sal_Unicode*>(tmp_name)); - osl_getFileURLFromSystemPath(pustr, ppustrTempFileURL); - rtl_uString_release(pustr); } - - return osl_error; - } - - //##################################################### - // End Temp file - //##################################################### - - - //############################################# - sal_Bool _osl_decodeURL( rtl_String* strUTF8, rtl_uString** pstrDecodedURL ) - { - sal_Char *pBuffer; - const sal_Char *pSrcEnd; - const sal_Char *pSrc; - sal_Char *pDest; - sal_Int32 nSrcLen; - sal_Bool bValidEncoded = sal_True; /* Assume success */ - - /* The resulting decoded string length is shorter or equal to the source length */ - - nSrcLen = rtl_string_getLength(strUTF8); - pBuffer = reinterpret_cast<sal_Char*>(rtl_allocateMemory(nSrcLen + 1)); - - pDest = pBuffer; - pSrc = rtl_string_getStr(strUTF8); - pSrcEnd = pSrc + nSrcLen; - - /* Now decode the URL what should result in an UTF8 string */ - while ( bValidEncoded && pSrc < pSrcEnd ) + switch (state) { - switch ( *pSrc ) + case LINE_STATE_CR: + state = LINE_STATE_LF; + switch (m_buffer[curpos]) { - case '%': - { - sal_Char aToken[3]; - sal_Char aChar; - - pSrc++; - aToken[0] = *pSrc++; - aToken[1] = *pSrc++; - aToken[2] = 0; - - aChar = (sal_Char)strtoul( aToken, NULL, 16 ); - - /* The chars are path delimiters and must not be encoded */ - - if ( 0 == aChar || '\\' == aChar || '/' == aChar || ':' == aChar ) - bValidEncoded = sal_False; - else - *pDest++ = aChar; - } + case 0x0A: /* CRLF */ + /* eat current char */ + curpos++; break; - default: - *pDest++ = *pSrc++; + default: /* single CR */ + /* keep current char */ break; } - } - - *pDest++ = 0; - - if ( bValidEncoded ) { - rtl_string2UString( pstrDecodedURL, pBuffer, rtl_str_getLength(pBuffer), RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS ); - OSL_ASSERT(*pstrDecodedURL != 0); - } - - rtl_freeMemory( pBuffer ); - - return bValidEncoded; - } - - //############################################# - void _osl_encodeURL( rtl_uString *strURL, rtl_String **pstrEncodedURL ) - { - /* Encode non ascii characters within the URL */ - - rtl_String *strUTF8 = NULL; - sal_Char *pszEncodedURL; - const sal_Char *pURLScan; - sal_Char *pURLDest; - sal_Int32 nURLScanLen; - sal_Int32 nURLScanCount; - - rtl_uString2String( &strUTF8, rtl_uString_getStr( strURL ), rtl_uString_getLength( strURL ), RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS ); - - pszEncodedURL = (sal_Char*) rtl_allocateMemory( (rtl_string_getLength( strUTF8 ) * 3 + 1) * sizeof(sal_Char) ); - - pURLDest = pszEncodedURL; - pURLScan = rtl_string_getStr( strUTF8 ); - nURLScanLen = rtl_string_getLength( strUTF8 ); - nURLScanCount = 0; - - while ( nURLScanCount < nURLScanLen ) - { - sal_Char cCurrent = *pURLScan; - - switch ( cCurrent ) + break; + default: + /* determine next state */ + switch (m_buffer[curpos]) { - default: - if (!( ( cCurrent >= 'a' && cCurrent <= 'z' ) || ( cCurrent >= 'A' && cCurrent <= 'Z' ) || ( cCurrent >= '0' && cCurrent <= '9' ) ) ) - { - sprintf( pURLDest, "%%%02X", (unsigned char)cCurrent ); - pURLDest += 3; - break; - } - case '!': - case '\'': - case '(': - case ')': - case '*': - case '-': - case '.': - case '_': - case '~': - case '$': - case '&': - case '+': - case ',': - case '=': - case '@': - case ':': - case '/': - case '\\': - case '|': - *pURLDest++ = cCurrent; + case 0x0A: /* single LF */ + state = LINE_STATE_LF; break; - case 0: + case 0x0D: /* CR */ + state = LINE_STATE_CR; + break; + default: /* advance to next char */ + curpos++; break; } - - pURLScan++; - nURLScanCount++; - } - - - *pURLDest = 0; - - rtl_string_release( strUTF8 ); - rtl_string_newFromStr( pstrEncodedURL, pszEncodedURL ); - rtl_freeMemory( pszEncodedURL ); - } - - //############################################# - oslFileError SAL_CALL _osl_getSystemPathFromFileURL( rtl_uString *strURL, rtl_uString **pustrPath, sal_Bool bAllowRelative ) - { - rtl_String *strUTF8 = NULL; - rtl_uString *strDecodedURL = NULL; - rtl_uString *strTempPath = NULL; - const sal_Unicode *pDecodedURL; - sal_uInt32 nDecodedLen; - sal_Bool bValidEncoded; - oslFileError nError = osl_File_E_INVAL; /* Assume failure */ - - /* If someone hasn't encoded the complete URL we convert it to UTF8 now to prevent from - having a mixed encoded URL later */ - - rtl_uString2String( &strUTF8, rtl_uString_getStr( strURL ), rtl_uString_getLength( strURL ), RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS ); - - /* If the length of strUTF8 and strURL differs it indicates that the URL was not correct encoded */ - - OSL_ENSURE_FILE( - strUTF8->length == strURL->length || - 0 != rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( strURL->buffer, strURL->length, "file:\\\\", 7 ) - ,"osl_getSystemPathFromFileURL: \"%s\" is not encoded !!!", strURL ); - - bValidEncoded = _osl_decodeURL( strUTF8, &strDecodedURL ); - - /* Release the encoded UTF8 string */ - - rtl_string_release( strUTF8 ); - - - if ( bValidEncoded ) - { - /* Replace backslashes and pipes */ - - rtl_uString_newReplace( &strDecodedURL, strDecodedURL, '/', '\\' ); - rtl_uString_newReplace( &strDecodedURL, strDecodedURL, '|', ':' ); - - pDecodedURL = rtl_uString_getStr( strDecodedURL ); - nDecodedLen = rtl_uString_getLength( strDecodedURL ); - - /* Must start with "file://" */ - - if ( 0 == rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pDecodedURL, nDecodedLen, "file:\\\\", 7 ) ) - { - sal_uInt32 nSkip; - - if ( 0 == rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pDecodedURL, nDecodedLen, "file:\\\\\\", 8 ) ) - nSkip = 8; - else if ( - 0 == rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pDecodedURL, nDecodedLen, "file:\\\\localhost\\", 17 ) || - 0 == rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pDecodedURL, nDecodedLen, "file:\\\\127.0.0.1\\", 17 ) - ) - nSkip = 17; - else - nSkip = 5; - - /* Indicates local root */ - if ( nDecodedLen == nSkip ) - rtl_uString_newFromStr_WithLength( &strTempPath, reinterpret_cast<const sal_Unicode*>(WSTR_SYSTEM_ROOT_PATH), ELEMENTS_OF_ARRAY(WSTR_SYSTEM_ROOT_PATH) - 1 ); - else - rtl_uString_newFromStr_WithLength( &strTempPath, pDecodedURL + nSkip, nDecodedLen - nSkip ); - - if ( IsValidFilePath( strTempPath, NULL, VALIDATEPATH_ALLOW_ELLIPSE, &strTempPath ) ) - nError = osl_File_E_None; - } - else if ( bAllowRelative ) /* This maybe a relative file URL */ - { - rtl_uString_assign( &strTempPath, strDecodedURL ); - - if ( IsValidFilePath( strTempPath, NULL, VALIDATEPATH_ALLOW_RELATIVE | VALIDATEPATH_ALLOW_ELLIPSE, &strTempPath ) ) - nError = osl_File_E_None; - } - /* - else - OSL_ENSURE_FILE( !nError, "osl_getSystemPathFromFileURL: \"%s\" is not an absolute FileURL !!!", strURL ); - */ - - } - - if ( strDecodedURL ) - rtl_uString_release( strDecodedURL ); - - if ( osl_File_E_None == nError ) - rtl_uString_assign( pustrPath, strTempPath ); - - if ( strTempPath ) - rtl_uString_release( strTempPath ); - - /* - OSL_ENSURE_FILE( !nError, "osl_getSystemPathFromFileURL: \"%s\" is not a FileURL !!!", strURL ); - */ - - return nError; - } - - //############################################# - oslFileError SAL_CALL _osl_getFileURLFromSystemPath( rtl_uString* strPath, rtl_uString** pstrURL ) - { - oslFileError nError = osl_File_E_INVAL; /* Assume failure */ - rtl_uString *strTempURL = NULL; - DWORD dwPathType = PATHTYPE_ERROR; - - if (strPath) - dwPathType = IsValidFilePath(strPath, NULL, VALIDATEPATH_ALLOW_RELATIVE, NULL); - - if (dwPathType) - { - rtl_uString *strTempPath = NULL; - - /* Replace backslashes */ - - rtl_uString_newReplace( &strTempPath, strPath, '\\', '/' ); - - switch ( dwPathType & PATHTYPE_MASK_TYPE ) + if (state != LINE_STATE_BEGIN) { - case PATHTYPE_RELATIVE: - rtl_uString_assign( &strTempURL, strTempPath ); - nError = osl_File_E_None; - break; - case PATHTYPE_ABSOLUTE_UNC: - rtl_uString_newFromAscii( &strTempURL, "file:" ); - rtl_uString_newConcat( &strTempURL, strTempURL, strTempPath ); - nError = osl_File_E_None; - break; - case PATHTYPE_ABSOLUTE_LOCAL: - rtl_uString_newFromAscii( &strTempURL, "file:///" ); - rtl_uString_newConcat( &strTempURL, strTempURL, strTempPath ); - nError = osl_File_E_None; - break; - default: - break; + /* store (and eat) the newline char */ + m_buffer[curpos] = 0x0A, curpos++; + + /* flush buffer to sequence */ + result = writeSequence_Impl ( + ppSequence, &dstpos, &(m_buffer[bufpos]), curpos - bufpos - 1); + if (result != osl_File_E_None) + return (result); + *pBytesRead += curpos - bufpos, nOffset += curpos - bufpos; } - - /* Release temp path */ - - rtl_uString_release( strTempPath ); - } - - if ( osl_File_E_None == nError ) - { - rtl_String *strEncodedURL = NULL; - - /* Encode the URL */ - - _osl_encodeURL( strTempURL, &strEncodedURL ); - - /* Provide URL via unicode string */ - - rtl_string2UString( pstrURL, rtl_string_getStr(strEncodedURL), rtl_string_getLength(strEncodedURL), RTL_TEXTENCODING_ASCII_US, OUSTRING_TO_OSTRING_CVTFLAGS ); - OSL_ASSERT(*pstrURL != 0); - rtl_string_release( strEncodedURL ); - } - - /* Release temp URL */ - - if ( strTempURL ) - rtl_uString_release( strTempURL ); - - /* - OSL_ENSURE_FILE( !nError, "osl_getFileURLFromSystemPath: \"%s\" is not a systemPath !!!", strPath ); - */ - - return nError; - } - -#if OSL_DEBUG_LEVEL > 0 - - //##################################################### - void _osl_warnFile( const char *message, rtl_uString *ustrFile ) - { - char szBuffer[2048]; - - if (ustrFile) - { - rtl_String *strFile = NULL; - - rtl_uString2String( &strFile, rtl_uString_getStr( ustrFile ), rtl_uString_getLength( ustrFile ), osl_getThreadTextEncoding(), OUSTRING_TO_OSTRING_CVTFLAGS ); - snprintf( szBuffer, sizeof(szBuffer), message, strFile->buffer ); - rtl_string_release( strFile ); - - message = szBuffer; + break; } - OSL_ENSURE( 0, message ); - } - -#endif // OSL_DEBUG_LEVEL > 0 - -} // end namespace private - - -//##################################################### -// Exported OSL API -//##################################################### - - -//############################################# -oslFileError SAL_CALL osl_getVolumeInformation( - rtl_uString *ustrURL, oslVolumeInfo *pInfo, sal_uInt32 uFieldMask ) -{ - if (!pInfo) - return osl_File_E_INVAL; - - rtl::OUString system_path; - oslFileError error = _osl_getSystemPathFromFileURL(ustrURL, &system_path.pData, sal_False); - - if (osl_File_E_None != error) - return error; - - rtl::OUString volume_root; - path_travel_to_volume_root(system_path, volume_root); - - pInfo->uValidFields = 0; - - if ((error = get_filesystem_attributes(volume_root, uFieldMask, pInfo)) != osl_File_E_None) - return error; - - if (is_volume_space_info_request(uFieldMask)) - get_volume_space_information(volume_root, pInfo); - - if (uFieldMask & osl_VolumeInfo_Mask_DeviceHandle) - { - pInfo->uValidFields |= osl_VolumeInfo_Mask_DeviceHandle; - osl_getFileURLFromSystemPath(volume_root.pData, (rtl_uString**)&pInfo->pDeviceHandle); } + result = writeSequence_Impl (ppSequence, &dstpos, 0, 0); + if (result != osl_File_E_None) + return (result); + if (0 < dstpos) + return osl_File_E_None; + if (bufpos >= m_buflen) + return osl_File_E_AGAIN; return osl_File_E_None; } - -//############################################# -oslFileError SAL_CALL osl_createDirectoryPath( - rtl_uString* aDirectoryUrl, - oslDirectoryCreationCallbackFunc aDirectoryCreationCallbackFunc, - void* pData) -{ - if (aDirectoryUrl == NULL) - return osl_File_E_INVAL; - - rtl::OUString sys_path; - oslFileError osl_error = - _osl_getSystemPathFromFileURL(aDirectoryUrl, &sys_path.pData, sal_False); - - if (osl_error != osl_File_E_None) - return osl_error; - - systemPathRemoveSeparator(sys_path); - - // const_cast because sys_path is a local copy - // which we want to modify inplace instead of - // coyp it into another buffer on the heap again - return MapError(create_dir_recursively_( - sys_path.pData->buffer, aDirectoryCreationCallbackFunc, pData)); -} - -//############################################# -oslFileError SAL_CALL osl_createTempFile( - rtl_uString* pustrDirectoryURL, - oslFileHandle* pHandle, - rtl_uString** ppustrTempFileURL) +oslFileError FileHandle_Impl::writeSequence_Impl ( + sal_Sequence ** ppSequence, + SIZE_T * pnOffset, + const void * pBuffer, + SIZE_T nBytes) { - rtl_uString* base_directory = 0; - LPWSTR tmp_name; - sal_Bool b_delete_on_close; - oslFileError osl_error; - - osl_error = osl_setup_createTempFile_impl_( - pustrDirectoryURL, - pHandle, - ppustrTempFileURL, - &base_directory, - &b_delete_on_close); - - if (osl_File_E_None != osl_error) - return osl_error; - - /* allocate enough space on the stack */ - STACK_ALLOC(tmp_name, WCHAR, (rtl_uString_getLength(base_directory) + MAX_PATH)); - - if (tmp_name) + sal_Int32 nElements = *pnOffset + nBytes; + if (!*ppSequence) { - osl_createTempFile_impl_( - base_directory, - tmp_name, - b_delete_on_close, - pHandle, - ppustrTempFileURL); + /* construct sequence */ + rtl_byte_sequence_constructNoDefault(ppSequence, nElements); } - else // stack alloc failed + else if (nElements != (*ppSequence)->nElements) { - osl_error = osl_File_E_NOMEM; + /* resize sequence */ + rtl_byte_sequence_realloc(ppSequence, nElements); } - - if (base_directory) - rtl_uString_release(base_directory); - - return osl_error; -} - -//############################################# -oslFileError SAL_CALL osl_getTempDirURL(rtl_uString** pustrTempDir) -{ - WCHAR szBuffer[MAX_PATH]; - LPWSTR lpBuffer = szBuffer; - DWORD nBufferLength = ELEMENTS_OF_ARRAY(szBuffer) - 1; - - DWORD nLength; - oslFileError error; - - do - { - nLength = GetTempPathW( ELEMENTS_OF_ARRAY(szBuffer), lpBuffer ); - if ( nLength > nBufferLength ) - { - nLength++; - lpBuffer = reinterpret_cast<WCHAR*>(alloca( sizeof(WCHAR) * nLength )); - nBufferLength = nLength - 1; - } - } while ( nLength > nBufferLength ); - - if ( nLength ) + if (*ppSequence != 0) { - rtl_uString *ustrTempPath = NULL; - - if ( '\\' == lpBuffer[nLength-1] ) - lpBuffer[nLength-1] = 0; - - rtl_uString_newFromStr( &ustrTempPath, reinterpret_cast<const sal_Unicode*>(lpBuffer) ); - - error = osl_getFileURLFromSystemPath( ustrTempPath, pustrTempDir ); - - rtl_uString_release( ustrTempPath ); + /* fill sequence */ + memcpy(&((*ppSequence)->elements[*pnOffset]), pBuffer, nBytes), *pnOffset += nBytes; } - else - error = MapError( GetLastError() ); + return (*ppSequence != 0) ? osl_File_E_None : osl_File_E_NOMEM; +} - return error; +oslFileError FileHandle_Impl::syncFile() +{ + oslFileError result = osl_File_E_None; + if (m_state & STATE_MODIFIED) + { + sal_uInt64 uDone = 0; + result = writeAt (m_bufptr, m_buffer, m_buflen, &uDone); + if (result != osl_File_E_None) + return (result); + if (uDone != m_buflen) + return osl_File_E_IO; + m_state &= ~STATE_MODIFIED; + } + return (result); } //################################################################## -// File handling functions +// File I/O functions //################################################################## - -//############################################# -oslFileError SAL_CALL osl_openFile( - rtl_uString *strPath, oslFileHandle *pHandle, sal_uInt32 uFlags ) +extern "C" oslFileHandle +SAL_CALL osl_createFileHandleFromOSHandle ( + HANDLE hFile, + sal_uInt32 uFlags) { - rtl_uString *strSysPath = NULL; - oslFileError error = _osl_getSystemPathFromFileURL( strPath, &strSysPath, sal_False ); + if ( !IsValidHandle(hFile) ) + return 0; // EINVAL - if ( osl_File_E_None == error ) + FileHandle_Impl * pImpl = new FileHandle_Impl(hFile); + if (pImpl == 0) { - DWORD dwAccess = 0, dwShare = FILE_SHARE_READ, dwCreation = 0, dwAttributes = 0; - HANDLE hFile; - - if ( uFlags & osl_File_OpenFlag_Read ) - dwAccess |= GENERIC_READ; - - if ( uFlags & osl_File_OpenFlag_Write ) - dwAccess |= GENERIC_WRITE; - else - dwShare |= FILE_SHARE_WRITE; - - if ( uFlags & osl_File_OpenFlag_NoLock ) - dwShare |= FILE_SHARE_WRITE; - - if ( uFlags & osl_File_OpenFlag_Create ) - dwCreation |= CREATE_NEW; - else - dwCreation |= OPEN_EXISTING; - - hFile = CreateFileW( reinterpret_cast<LPCWSTR>(rtl_uString_getStr( strSysPath )), dwAccess, dwShare, NULL, dwCreation, dwAttributes, NULL ); - - *pHandle = osl_createFileHandleFromOSHandle( hFile ); - - if ( !IsValidHandle( hFile ) ) - error = MapError( GetLastError() ); - - rtl_uString_release( strSysPath ); + // cleanup and fail + (void) ::CloseHandle(hFile); + return 0; // ENOMEM } - return error; -} - -//############################################# -oslFileError SAL_CALL osl_syncFile(oslFileHandle Handle) -{ - if (!IsValidHandle((HANDLE)Handle)) - return osl_File_E_INVAL; - - if (!FlushFileBuffers((HANDLE)Handle)) - return MapError(GetLastError()); - - return osl_File_E_None; -} + /* check for regular file */ + if (FILE_TYPE_DISK == GetFileType(hFile)) + { + /* mark seekable */ + pImpl->m_state |= FileHandle_Impl::STATE_SEEKABLE; -//############################################# -oslFileError SAL_CALL osl_closeFile(oslFileHandle Handle) -{ - oslFileError error; - HANDLE hFile = (HANDLE)Handle; + /* init current size */ + LARGE_INTEGER uSize = { 0, 0 }; + (void) ::GetFileSizeEx(hFile, &uSize); + pImpl->m_size = (sal::static_int_cast<sal_uInt64>(uSize.HighPart) << 32) + uSize.LowPart; + } - if ( IsValidHandle(hFile) ) - error = CloseHandle( hFile ) ? osl_File_E_None : MapError( GetLastError() ); - else - error = osl_File_E_INVAL; + if (!(uFlags & osl_File_OpenFlag_Read)) + pImpl->m_state &= ~FileHandle_Impl::STATE_READABLE; + if (!(uFlags & osl_File_OpenFlag_Write)) + pImpl->m_state &= ~FileHandle_Impl::STATE_WRITEABLE; - return error; + OSL_POSTCOND( + (uFlags & osl_File_OpenFlag_Read) || (uFlags & osl_File_OpenFlag_Write), + "osl_createFileHandleFromOSHandle(): missing read/write access flags"); + return (oslFileHandle)(pImpl); } //############################################# -oslFileError SAL_CALL osl_isEndOfFile(oslFileHandle Handle, sal_Bool *pIsEOF) +oslFileError +SAL_CALL osl_openFile( + rtl_uString * strPath, + oslFileHandle * pHandle, + sal_uInt32 uFlags ) { - oslFileError error = osl_File_E_INVAL; - HANDLE hFile = (HANDLE)Handle; - - if ( IsValidHandle(hFile) ) - { - LONG lDistanceToMove, lDistanceToMoveHigh; - sal_uInt64 nCurPos; - - /* Return value INVALID_SET_FILE_POINTER is no error indication and LastError could - be set from previous IO call */ - - SetLastError( NOERROR ); + rtl_uString * strSysPath = 0; + oslFileError result = _osl_getSystemPathFromFileURL( strPath, &strSysPath, sal_False ); + if (result != osl_File_E_None) + return (result); - lDistanceToMoveHigh = 0; - lDistanceToMove = SetFilePointer( hFile, 0, &lDistanceToMoveHigh, FILE_CURRENT ); + DWORD dwAccess = GENERIC_READ, dwShare = FILE_SHARE_READ, dwCreation = 0, dwAttributes = 0; - error = MapError( GetLastError() ); - - if ( osl_File_E_None == error ) - { - nCurPos = (sal_uInt64)lDistanceToMove + ((sal_uInt64)lDistanceToMoveHigh << 32); + if ( uFlags & osl_File_OpenFlag_Write ) + dwAccess |= GENERIC_WRITE; + else + dwShare |= FILE_SHARE_WRITE; - lDistanceToMoveHigh = 0; - lDistanceToMove = SetFilePointer( hFile, 0, &lDistanceToMoveHigh, FILE_END ); + if ( uFlags & osl_File_OpenFlag_NoLock ) + dwShare |= FILE_SHARE_WRITE; - error = MapError( GetLastError() ); + if ( uFlags & osl_File_OpenFlag_Create ) + dwCreation |= CREATE_NEW; + else + dwCreation |= OPEN_EXISTING; - if ( osl_File_E_None == error ) - { - sal_uInt64 nEndPos = (sal_uInt64)lDistanceToMove + ((sal_uInt64)lDistanceToMoveHigh << 32); + HANDLE hFile = CreateFileW( + reinterpret_cast<LPCWSTR>(rtl_uString_getStr( strSysPath )), + dwAccess, dwShare, NULL, dwCreation, dwAttributes, NULL ); - *pIsEOF = (sal_Bool)(nEndPos == nCurPos); + // @@@ ERROR HANDLING @@@ + if ( !IsValidHandle( hFile ) ) + result = oslTranslateFileError( GetLastError() ); - lDistanceToMoveHigh = (LONG)(nCurPos >> 32); - SetFilePointer( hFile, (LONG)(nCurPos & 0xFFFFFFFF), &lDistanceToMoveHigh, FILE_BEGIN ); + *pHandle = osl_createFileHandleFromOSHandle (hFile, uFlags | osl_File_OpenFlag_Read); - error = MapError( GetLastError() ); - } - } - } - return error; + rtl_uString_release( strSysPath ); + return (result); } //############################################# -oslFileError SAL_CALL osl_setFilePos(oslFileHandle Handle, sal_uInt32 uHow, sal_Int64 uPos) +oslFileError +SAL_CALL osl_syncFile(oslFileHandle Handle) { - HANDLE hFile = (HANDLE)Handle; - if (!IsValidHandle(hFile)) + FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle); + if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile)) return osl_File_E_INVAL; - DWORD dwMoveMethod = 0; - switch ( uHow ) - { - case osl_Pos_Current: - dwMoveMethod = FILE_CURRENT; - break; - case osl_Pos_End: - dwMoveMethod = FILE_END; - break; - case osl_Pos_Absolut: - default: - dwMoveMethod = FILE_BEGIN; - break; - } - - LONG nOffsetLo = sal::static_int_cast<LONG>(uPos & 0xFFFFFFFF); - LONG nOffsetHi = sal::static_int_cast<LONG>(uPos >> 32); - - SetLastError(0); - DWORD dwPosLo = SetFilePointer( hFile, nOffsetLo, &nOffsetHi, dwMoveMethod ); - if (INVALID_SET_FILE_POINTER == dwPosLo) - { - DWORD dwError = GetLastError(); - if (NO_ERROR != dwError) - return MapError( dwError ); - } - return osl_File_E_None; -} - -//############################################# -oslFileError SAL_CALL osl_getFilePos(oslFileHandle Handle, sal_uInt64 *pPos) -{ - oslFileError error; - HANDLE hFile = (HANDLE)Handle; - - if ( IsValidHandle(hFile) ) - { - LONG lDistanceToMove, lDistanceToMoveHigh; - - /* Return value INVALID_SET_FILE_POINTER is no error indication and LastError could - be set from previous IO call */ + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); - SetLastError( NOERROR ); + oslFileError result = pImpl->syncFile(); + if (result != osl_File_E_None) + return result; - lDistanceToMoveHigh = 0; - lDistanceToMove = SetFilePointer( hFile, 0, &lDistanceToMoveHigh, FILE_CURRENT ); + if (!FlushFileBuffers(pImpl->m_hFile)) + return oslTranslateFileError(GetLastError()); - error = MapError( GetLastError() ); - - if ( osl_File_E_None == error ) - *pPos = (sal_uInt64)lDistanceToMove + ((sal_uInt64)lDistanceToMoveHigh << 32); - } - else - error = osl_File_E_INVAL; - - return error; + return osl_File_E_None; } //############################################# -oslFileError SAL_CALL osl_getFileSize(oslFileHandle Handle, sal_uInt64 *pSize) +oslFileError +SAL_CALL osl_closeFile(oslFileHandle Handle) { - HANDLE hFile = (HANDLE)Handle; - if ( !IsValidHandle(hFile) ) + FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle); + if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile)) return osl_File_E_INVAL; - DWORD nSize = GetFileSize(hFile, NULL); - if (nSize == INVALID_FILE_SIZE) + ::EnterCriticalSection (&(pImpl->m_mutex)); + + oslFileError result = pImpl->syncFile(); + if (result != osl_File_E_None) { - DWORD nError = GetLastError(); - if (nError != NO_ERROR) - return MapError(nError); + /* ignore double failure */ + (void)::CloseHandle(pImpl->m_hFile); } - - *pSize = (sal_uInt64)(nSize); - return osl_File_E_None; -} - -oslFileError SAL_CALL osl_setFileSize(oslFileHandle Handle, sal_uInt64 uSize) -{ - oslFileError error = error = osl_setFilePos( Handle, osl_Pos_Absolut, uSize ); - if ( osl_File_E_None == error ) + else if (!::CloseHandle(pImpl->m_hFile)) { - if ( !SetEndOfFile( (HANDLE)Handle ) ) - error = MapError( osl_File_E_None ); + /* translate error code */ + result = oslTranslateFileError( GetLastError() ); } - return error; + ::LeaveCriticalSection (&(pImpl->m_mutex)); + delete pImpl; + return (result); } //############################################# -oslFileError SAL_CALL osl_mapFile( +oslFileError +SAL_CALL osl_mapFile( oslFileHandle Handle, void** ppAddr, sal_uInt64 uLength, @@ -2710,8 +819,8 @@ oslFileError SAL_CALL osl_mapFile( } }; - HANDLE hFile = (HANDLE)(Handle); - if (!IsValidHandle(hFile) || (0 == ppAddr)) + FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle); + if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == ppAddr)) return osl_File_E_INVAL; *ppAddr = 0; @@ -2727,16 +836,16 @@ oslFileError SAL_CALL osl_mapFile( if (VER_PLATFORM_WIN32_NT != osinfo.dwPlatformId) return osl_File_E_NOSYS; // Unsupported - FileMapping aMap( ::CreateFileMapping (hFile, NULL, SEC_COMMIT | PAGE_READONLY, 0, 0, NULL) ); + FileMapping aMap( ::CreateFileMapping (pImpl->m_hFile, NULL, SEC_COMMIT | PAGE_READONLY, 0, 0, NULL) ); if (!IsValidHandle(aMap.m_handle)) - return MapError( GetLastError() ); + return oslTranslateFileError( GetLastError() ); DWORD const dwOffsetHi = sal::static_int_cast<DWORD>(uOffset >> 32); DWORD const dwOffsetLo = sal::static_int_cast<DWORD>(uOffset & 0xFFFFFFFF); *ppAddr = ::MapViewOfFile( aMap.m_handle, FILE_MAP_READ, dwOffsetHi, dwOffsetLo, nLength ); if (0 == *ppAddr) - return MapError( GetLastError() ); + return oslTranslateFileError( GetLastError() ); if (uFlags & osl_File_MapFlag_RandomAccess) { @@ -2770,977 +879,319 @@ oslFileError SAL_CALL osl_mapFile( } //############################################# -oslFileError SAL_CALL osl_unmapFile(void* pAddr, sal_uInt64 /* uLength */) +oslFileError +SAL_CALL osl_unmapFile(void* pAddr, sal_uInt64 /* uLength */) { if (0 == pAddr) return osl_File_E_INVAL; if (!::UnmapViewOfFile (pAddr)) - return MapError( GetLastError() ); + return oslTranslateFileError( GetLastError() ); return osl_File_E_None; } //############################################# -oslFileError SAL_CALL osl_readFile( - oslFileHandle Handle, - void *pBuffer, - sal_uInt64 uBytesRequested, - sal_uInt64 *pBytesRead ) +oslFileError +SAL_CALL osl_readLine( + oslFileHandle Handle, + sal_Sequence ** ppSequence) { - oslFileError error; - HANDLE hFile = (HANDLE)Handle; - - if ( IsValidHandle(hFile) ) - { - DWORD dwBytesToRead = (DWORD)uBytesRequested; - DWORD dwBytesRead; + FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle); + if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == ppSequence)) + return osl_File_E_INVAL; + sal_uInt64 uBytesRead = 0; + + // read at current filepos; filepos += uBytesRead; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); + oslFileError result = pImpl->readLineAt ( + pImpl->m_filepos, ppSequence, &uBytesRead); + if (result == osl_File_E_None) + pImpl->m_filepos += uBytesRead; + return (result); +} - if ( ReadFile( hFile, pBuffer, dwBytesToRead, &dwBytesRead, NULL ) ) - { - *pBytesRead = (sal_uInt64)dwBytesRead; - error = osl_File_E_None; - } - else - error = MapError( GetLastError() ); - } - else - error = osl_File_E_INVAL; +//############################################# +oslFileError +SAL_CALL osl_readFile( + oslFileHandle Handle, + void * pBuffer, + sal_uInt64 uBytesRequested, + sal_uInt64 * pBytesRead) +{ + FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle); + if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == pBuffer) || (0 == pBytesRead)) + return osl_File_E_INVAL; - return error; + // read at current filepos; filepos += *pBytesRead; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); + oslFileError result = pImpl->readFileAt ( + pImpl->m_filepos, pBuffer, uBytesRequested, pBytesRead); + if (result == osl_File_E_None) + pImpl->m_filepos += *pBytesRead; + return (result); } //############################################# -oslFileError SAL_CALL osl_writeFile( +oslFileError +SAL_CALL osl_writeFile( oslFileHandle Handle, - const void *pBuffer, - sal_uInt64 uBytesToWrite, - sal_uInt64 *pBytesWritten ) + const void * pBuffer, + sal_uInt64 uBytesToWrite, + sal_uInt64 * pBytesWritten ) { - oslFileError error; - HANDLE hFile = (HANDLE)Handle; + FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle); - if ( IsValidHandle(hFile) ) - { - DWORD dwBytesToWrite = (DWORD)uBytesToWrite; - DWORD dwBytesWritten; - - if ( WriteFile( hFile, pBuffer, dwBytesToWrite, &dwBytesWritten, NULL ) ) - { - *pBytesWritten = (sal_uInt64)dwBytesWritten; - error = osl_File_E_None; - } - else - error = MapError( GetLastError() ); - } - else - error = osl_File_E_INVAL; + if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == pBuffer) || (0 == pBytesWritten)) + return osl_File_E_INVAL; - return error; + // write at current filepos; filepos += *pBytesWritten; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); + oslFileError result = pImpl->writeFileAt ( + pImpl->m_filepos, pBuffer, uBytesToWrite, pBytesWritten); + if (result == osl_File_E_None) + pImpl->m_filepos += *pBytesWritten; + return (result); } //############################################# -oslFileError SAL_CALL osl_readFileAt( +oslFileError +SAL_CALL osl_readFileAt( oslFileHandle Handle, sal_uInt64 uOffset, void* pBuffer, sal_uInt64 uBytesRequested, sal_uInt64* pBytesRead) { - HANDLE hFile = (HANDLE)(Handle); - if (!IsValidHandle(hFile) || (0 == pBuffer)) - return osl_File_E_INVAL; + FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle); - static sal_uInt64 const g_limit_dword = std::numeric_limits< DWORD >::max(); - if (g_limit_dword < uBytesRequested) - return osl_File_E_OVERFLOW; - DWORD const dwBytes = sal::static_int_cast< DWORD >(uBytesRequested); - - if (0 == pBytesRead) + if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == pBuffer) || (0 == pBytesRead)) return osl_File_E_INVAL; - *pBytesRead = 0; - - oslFileError error = osl_setFilePos(Handle, osl_Pos_Absolut, uOffset); - if (osl_File_E_None != error) - return error; + if (0 == (pImpl->m_state & FileHandle_Impl::STATE_SEEKABLE)) + return osl_File_E_SPIPE; - DWORD dwDone = 0; - if (!::ReadFile(hFile, pBuffer, dwBytes, &dwDone, NULL)) - return MapError( GetLastError() ); + static sal_uInt64 const g_limit_longlong = std::numeric_limits< LONGLONG >::max(); + if (g_limit_longlong < uOffset) + return osl_File_E_OVERFLOW; + LONGLONG const nOffset = sal::static_int_cast< LONGLONG >(uOffset); - *pBytesRead = dwDone; - return osl_File_E_None; + // read at specified fileptr + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); + return pImpl->readFileAt (nOffset, pBuffer, uBytesRequested, pBytesRead); } //############################################# -oslFileError SAL_CALL osl_writeFileAt( +oslFileError +SAL_CALL osl_writeFileAt( oslFileHandle Handle, sal_uInt64 uOffset, const void* pBuffer, sal_uInt64 uBytesToWrite, sal_uInt64* pBytesWritten) { - HANDLE hFile = (HANDLE)(Handle); - if (!IsValidHandle(hFile) || (0 == pBuffer)) - return osl_File_E_INVAL; - - static sal_uInt64 const g_limit_dword = std::numeric_limits< DWORD >::max(); - if (g_limit_dword < uBytesToWrite) - return osl_File_E_OVERFLOW; - DWORD const dwBytes = sal::static_int_cast< DWORD >(uBytesToWrite); + FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle); - if (0 == pBytesWritten) + if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == pBuffer) || (0 == pBytesWritten)) return osl_File_E_INVAL; - *pBytesWritten = 0; - - oslFileError error = osl_setFilePos(Handle, osl_Pos_Absolut, uOffset); - if (osl_File_E_None != error) - return error; + if (0 == (pImpl->m_state & FileHandle_Impl::STATE_SEEKABLE)) + return osl_File_E_SPIPE; - DWORD dwDone = 0; - if (!::WriteFile(hFile, pBuffer, dwBytes, &dwDone, NULL)) - return MapError( GetLastError() ); + static sal_uInt64 const g_limit_longlong = std::numeric_limits< LONGLONG >::max(); + if (g_limit_longlong < uOffset) + return osl_File_E_OVERFLOW; + LONGLONG const nOffset = sal::static_int_cast< LONGLONG >(uOffset); - *pBytesWritten = dwDone; - return osl_File_E_None; + // write at specified fileptr + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); + return pImpl->writeFileAt (nOffset, pBuffer, uBytesToWrite, pBytesWritten); } //############################################# -oslFileError SAL_CALL osl_removeFile( rtl_uString* strPath ) +oslFileError +SAL_CALL osl_isEndOfFile (oslFileHandle Handle, sal_Bool *pIsEOF) { - rtl_uString *strSysPath = NULL; - oslFileError error = _osl_getSystemPathFromFileURL( strPath, &strSysPath, sal_False ); - - if ( osl_File_E_None == error ) - { - if ( DeleteFile( reinterpret_cast<LPCTSTR>(rtl_uString_getStr( strSysPath )) ) ) - error = osl_File_E_None; - else - error = MapError( GetLastError() ); + FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle); - rtl_uString_release( strSysPath ); - } - return error; -} - -//############################################# -#define osl_File_CopyRecursive 0x0001 -#define osl_File_CopyOverwrite 0x0002 - -oslFileError SAL_CALL osl_copyFile( rtl_uString* strPath, rtl_uString *strDestPath ) -{ - rtl_uString *strSysPath = NULL, *strSysDestPath = NULL; - oslFileError error = _osl_getSystemPathFromFileURL( strPath, &strSysPath, sal_False ); - - if ( osl_File_E_None == error ) - error = _osl_getSystemPathFromFileURL( strDestPath, &strSysDestPath, sal_False ); - - if ( osl_File_E_None == error ) - { - if ( CopyFile( reinterpret_cast<LPCTSTR>(rtl_uString_getStr( strSysPath )), reinterpret_cast<LPCTSTR>(rtl_uString_getStr( strSysDestPath )), FALSE ) ) - error = osl_File_E_None; - else - error = MapError( GetLastError() ); - } - - if ( strSysPath ) - rtl_uString_release( strSysPath ); - if ( strSysDestPath ) - rtl_uString_release( strSysDestPath ); + if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == pIsEOF)) + return osl_File_E_INVAL; - return error; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); + *pIsEOF = (pImpl->getPos() == pImpl->getSize()); + return osl_File_E_None; } //############################################# -oslFileError SAL_CALL osl_moveFile( rtl_uString* strPath, rtl_uString *strDestPath ) +oslFileError +SAL_CALL osl_getFilePos(oslFileHandle Handle, sal_uInt64 *pPos) { - rtl_uString *strSysPath = NULL, *strSysDestPath = NULL; - oslFileError error = _osl_getSystemPathFromFileURL( strPath, &strSysPath, sal_False ); - - if ( osl_File_E_None == error ) - error = _osl_getSystemPathFromFileURL( strDestPath, &strSysDestPath, sal_False ); - - if ( osl_File_E_None == error ) - { - if ( MoveFileEx( reinterpret_cast<LPCTSTR>(rtl_uString_getStr( strSysPath )), reinterpret_cast<LPCTSTR>(rtl_uString_getStr( strSysDestPath )), MOVEFILE_COPY_ALLOWED | MOVEFILE_WRITE_THROUGH | MOVEFILE_REPLACE_EXISTING ) ) - error = osl_File_E_None; - else - error = MapError( GetLastError() ); - } - - if ( strSysPath ) - rtl_uString_release( strSysPath ); - if ( strSysDestPath ) - rtl_uString_release( strSysDestPath ); + FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle); + if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == pPos)) + return osl_File_E_INVAL; - return error; + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); + *pPos = pImpl->getPos(); + return osl_File_E_None; } //############################################# -oslFileError SAL_CALL osl_setFileAttributes( - rtl_uString *ustrFileURL, - sal_uInt64 uAttributes ) +oslFileError +SAL_CALL osl_setFilePos(oslFileHandle Handle, sal_uInt32 uHow, sal_Int64 uOffset) { - oslFileError error; - rtl_uString *ustrSysPath = NULL; - DWORD dwFileAttributes; - BOOL fSuccess; - - // Converts the normalized path into a systempath - error = _osl_getSystemPathFromFileURL( ustrFileURL, &ustrSysPath, sal_False ); - - if ( osl_File_E_None != error ) - return error; + FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle); + if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile)) + return osl_File_E_INVAL; - dwFileAttributes = GetFileAttributes( reinterpret_cast<LPCTSTR>(rtl_uString_getStr(ustrSysPath)) ); + static sal_Int64 const g_limit_longlong = std::numeric_limits< LONGLONG >::max(); + if (g_limit_longlong < uOffset) + return osl_File_E_OVERFLOW; + LONGLONG nPos = 0, nOffset = sal::static_int_cast< LONGLONG >(uOffset); - if ( (DWORD)-1 != dwFileAttributes ) + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); + switch (uHow) { - dwFileAttributes &= ~(FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN); + case osl_Pos_Absolut: + if (0 > nOffset) + return osl_File_E_INVAL; + break; - if ( uAttributes & osl_File_Attribute_ReadOnly ) - dwFileAttributes |= FILE_ATTRIBUTE_READONLY; + case osl_Pos_Current: + nPos = sal::static_int_cast< LONGLONG >(pImpl->getPos()); + if ((0 > nOffset) && (-1*nOffset > nPos)) + return osl_File_E_INVAL; + if (g_limit_longlong < nPos + nOffset) + return osl_File_E_OVERFLOW; + break; - if ( uAttributes & osl_File_Attribute_Hidden ) - dwFileAttributes |= FILE_ATTRIBUTE_HIDDEN; + case osl_Pos_End: + nPos = sal::static_int_cast< LONGLONG >(pImpl->getSize()); + if ((0 > nOffset) && (-1*nOffset > nPos)) + return osl_File_E_INVAL; + if (g_limit_longlong < nPos + nOffset) + return osl_File_E_OVERFLOW; + break; - fSuccess = SetFileAttributes( reinterpret_cast<LPCTSTR>(rtl_uString_getStr(ustrSysPath)), dwFileAttributes ); + default: + return osl_File_E_INVAL; } - else - fSuccess = FALSE; - - if ( !fSuccess ) - error = MapError( GetLastError() ); - rtl_uString_release( ustrSysPath ); - - return error; + return pImpl->setPos (nPos + nOffset); } -//##################################################### -oslFileError SAL_CALL osl_setFileTime( - rtl_uString *filePath, - const TimeValue *aCreationTime, - const TimeValue *aLastAccessTime, - const TimeValue *aLastWriteTime) +//############################################# +oslFileError +SAL_CALL osl_getFileSize (oslFileHandle Handle, sal_uInt64 *pSize) { - oslFileError error; - rtl_uString *sysPath=NULL; - FILETIME *lpCreationTime=NULL; - FILETIME *lpLastAccessTime=NULL; - FILETIME *lpLastWriteTime=NULL; - FILETIME ftCreationTime; - FILETIME ftLastAccessTime; - FILETIME ftLastWriteTime; - HANDLE hFile; - BOOL fSuccess; - - - error=_osl_getSystemPathFromFileURL(filePath, &sysPath, sal_False); - - if (error==osl_File_E_INVAL) - return error; - - hFile=CreateFileW(reinterpret_cast<LPCWSTR>(rtl_uString_getStr(sysPath)), GENERIC_WRITE, 0, NULL , OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - rtl_uString_release(sysPath); + FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle); - if (hFile==INVALID_HANDLE_VALUE) - return osl_File_E_NOENT; - - if (TimeValueToFileTime(aCreationTime, &ftCreationTime)) - lpCreationTime=&ftCreationTime; - - if (TimeValueToFileTime(aLastAccessTime, &ftLastAccessTime)) - lpLastAccessTime=&ftLastAccessTime; - - if (TimeValueToFileTime(aLastWriteTime, &ftLastWriteTime)) - lpLastWriteTime=&ftLastWriteTime; - - fSuccess=SetFileTime(hFile, lpCreationTime, lpLastAccessTime, lpLastWriteTime); - - CloseHandle(hFile); - - if (!fSuccess) + if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == pSize)) return osl_File_E_INVAL; - else - return osl_File_E_None; + + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); + *pSize = pImpl->getSize(); + return osl_File_E_None; } -//##################################################### -oslFileError SAL_CALL osl_getFileStatus( - oslDirectoryItem Item, - oslFileStatus *pStatus, - sal_uInt32 uFieldMask ) +//############################################# +oslFileError +SAL_CALL osl_setFileSize (oslFileHandle Handle, sal_uInt64 uSize) { - DirectoryItem_Impl *pItemImpl = (DirectoryItem_Impl *)Item; - - if ( !pItemImpl ) - return osl_File_E_INVAL; - - switch ( pItemImpl->uType ) - { - case DIRECTORYITEM_DRIVE: - return osl_getDriveInfo( Item, pStatus, uFieldMask ); - case DIRECTORYITEM_SERVER: - return osl_getServerInfo( Item, pStatus, uFieldMask ); - default: - break; - } - - if ( uFieldMask & osl_FileStatus_Mask_Validate ) - { - HANDLE hFind = FindFirstFile( pItemImpl->szFullPath, &pItemImpl->FindData ); - - if ( hFind != INVALID_HANDLE_VALUE ) - FindClose( hFind ); - else - return MapError( GetLastError() ); + FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle); - uFieldMask &= ~ osl_FileStatus_Mask_Validate; - } - - /* If no fields to retrieve left ignore pStatus */ - if ( !uFieldMask ) - return osl_File_E_None; - - /* Otherwise, this must be a valid pointer */ - if ( !pStatus ) - return osl_File_E_INVAL; - - if ( pStatus->uStructSize != sizeof(oslFileStatus) ) + if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile)) return osl_File_E_INVAL; + if (0 == (pImpl->m_state & FileHandle_Impl::STATE_WRITEABLE)) + return osl_File_E_BADF; - pStatus->uValidFields = 0; - - /* File time stamps */ - - if ( (uFieldMask & osl_FileStatus_Mask_ModifyTime) && - FileTimeToTimeValue( &pItemImpl->FindData.ftLastWriteTime, &pStatus->aModifyTime ) ) - pStatus->uValidFields |= osl_FileStatus_Mask_ModifyTime; - - if ( (uFieldMask & osl_FileStatus_Mask_AccessTime) && - FileTimeToTimeValue( &pItemImpl->FindData.ftLastAccessTime, &pStatus->aAccessTime ) ) - pStatus->uValidFields |= osl_FileStatus_Mask_AccessTime; - - if ( (uFieldMask & osl_FileStatus_Mask_CreationTime) && - FileTimeToTimeValue( &pItemImpl->FindData.ftCreationTime, &pStatus->aCreationTime ) ) - pStatus->uValidFields |= osl_FileStatus_Mask_CreationTime; - - /* Most of the fields are already set, regardless of requiered fields */ - - rtl_uString_newFromStr( &pStatus->ustrFileName, reinterpret_cast<const sal_Unicode*>(pItemImpl->FindData.cFileName) ); - pStatus->uValidFields |= osl_FileStatus_Mask_FileName; - - if ((FILE_ATTRIBUTE_REPARSE_POINT & pItemImpl->FindData.dwFileAttributes) && - (IO_REPARSE_TAG_MOUNT_POINT == pItemImpl->FindData.dwReserved0)) - pStatus->eType = osl_File_Type_Volume; - else if (pItemImpl->FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - pStatus->eType = osl_File_Type_Directory; - else - pStatus->eType = osl_File_Type_Regular; - - pStatus->uValidFields |= osl_FileStatus_Mask_Type; - - pStatus->uAttributes = pItemImpl->FindData.dwFileAttributes; - pStatus->uValidFields |= osl_FileStatus_Mask_Attributes; - - pStatus->uFileSize = (sal_uInt64)pItemImpl->FindData.nFileSizeLow + ((sal_uInt64)pItemImpl->FindData.nFileSizeHigh << 32); - pStatus->uValidFields |= osl_FileStatus_Mask_FileSize; - - if ( uFieldMask & osl_FileStatus_Mask_LinkTargetURL ) - { - rtl_uString *ustrFullPath = NULL; - - rtl_uString_newFromStr( &ustrFullPath, reinterpret_cast<const sal_Unicode*>(pItemImpl->szFullPath) ); - osl_getFileURLFromSystemPath( ustrFullPath, &pStatus->ustrLinkTargetURL ); - rtl_uString_release( ustrFullPath ); - - pStatus->uValidFields |= osl_FileStatus_Mask_LinkTargetURL; - } - - if ( uFieldMask & osl_FileStatus_Mask_FileURL ) - { - rtl_uString *ustrFullPath = NULL; - + static sal_uInt64 const g_limit_longlong = std::numeric_limits< LONGLONG >::max(); + if (g_limit_longlong < uSize) + return osl_File_E_OVERFLOW; - if ( !pItemImpl->bFullPathNormalized ) - { - GetCaseCorrectPathName( pItemImpl->szFullPath, pItemImpl->szFullPath, sizeof(pItemImpl->szFullPath) ); - pItemImpl->bFullPathNormalized = TRUE; - } - rtl_uString_newFromStr( &ustrFullPath, reinterpret_cast<const sal_Unicode*>(pItemImpl->szFullPath) ); - osl_getFileURLFromSystemPath( ustrFullPath, &pStatus->ustrFileURL ); - rtl_uString_release( ustrFullPath ); - pStatus->uValidFields |= osl_FileStatus_Mask_FileURL; - } + FileHandle_Impl::Guard lock (&(pImpl->m_mutex)); + oslFileError result = pImpl->syncFile(); + if (result != osl_File_E_None) + return (result); + pImpl->m_bufptr = -1, pImpl->m_buflen = 0; - return osl_File_E_None; + return pImpl->setSize (uSize); } //################################################################## -// directory handling functions +// File handling functions //################################################################## - -//##################################################### -oslFileError SAL_CALL osl_createDirectory(rtl_uString* strPath) +//############################################# +oslFileError SAL_CALL osl_removeFile( rtl_uString* strPath ) { rtl_uString *strSysPath = NULL; oslFileError error = _osl_getSystemPathFromFileURL( strPath, &strSysPath, sal_False ); if ( osl_File_E_None == error ) { - if ( CreateDirectoryW( reinterpret_cast<LPCWSTR>(rtl_uString_getStr( strSysPath )), NULL ) ) + if ( DeleteFile( reinterpret_cast<LPCTSTR>(rtl_uString_getStr( strSysPath )) ) ) error = osl_File_E_None; -/*@@@ToDo - The else case is a hack because the ucb or the webtop had some - problems with the error code that CreateDirectory returns in - case the path is only a logical drive, should be removed! -*/ else - { - const sal_Unicode *pBuffer = rtl_uString_getStr( strSysPath ); - sal_Int32 nLen = rtl_uString_getLength( strSysPath ); - - if ( - ( pBuffer[0] >= 'A' && pBuffer[0] <= 'Z' || - pBuffer[0] >= 'a' && pBuffer[0] <= 'z' ) && - pBuffer[1] == ':' && ( nLen ==2 || nLen == 3 && pBuffer[2] == '\\' ) - ) - SetLastError( ERROR_ALREADY_EXISTS ); - - error = MapError( GetLastError() ); - } + error = oslTranslateFileError( GetLastError() ); rtl_uString_release( strSysPath ); } return error; } -//##################################################### -oslFileError SAL_CALL osl_removeDirectory(rtl_uString* strPath) +//############################################# +#define osl_File_CopyRecursive 0x0001 +#define osl_File_CopyOverwrite 0x0002 + +oslFileError SAL_CALL osl_copyFile( rtl_uString* strPath, rtl_uString *strDestPath ) { - rtl_uString *strSysPath = NULL; + rtl_uString *strSysPath = NULL, *strSysDestPath = NULL; oslFileError error = _osl_getSystemPathFromFileURL( strPath, &strSysPath, sal_False ); if ( osl_File_E_None == error ) - { - if ( RemoveDirectory( reinterpret_cast<LPCTSTR>(rtl_uString_getStr( strSysPath )) ) ) - error = osl_File_E_None; - else - error = MapError( GetLastError() ); - - rtl_uString_release( strSysPath ); - } - return error; -} - -//##################################################### -oslFileError SAL_CALL osl_openDirectory(rtl_uString *strDirectoryPath, oslDirectory *pDirectory) -{ - oslFileError error; + error = _osl_getSystemPathFromFileURL( strDestPath, &strSysDestPath, sal_False ); - if ( 0 == rtl_ustr_ascii_compareIgnoreAsciiCase( strDirectoryPath->buffer, "file:///" ) ) - error = osl_openLocalRoot( strDirectoryPath, pDirectory ); - else + if ( osl_File_E_None == error ) { - rtl_uString *strSysDirectoryPath = NULL; -// WCHAR szCorrectedPathName[MAX_PATH]; - DWORD dwPathType; - - error = _osl_getSystemPathFromFileURL( strDirectoryPath, &strSysDirectoryPath, sal_False ); + LPCTSTR src = reinterpret_cast<LPCTSTR>(rtl_uString_getStr( strSysPath )); + LPCTSTR dst = reinterpret_cast<LPCTSTR>(rtl_uString_getStr( strSysDestPath )); - if ( osl_File_E_None != error ) - return error; - - // MT Perform05 - /* - if ( GetCaseCorrectPathName( strSysDirectoryPath->buffer, szCorrectedPathName, MAX_PATH ) ) - { - rtl_uString_newFromStr( &strSysDirectoryPath, szCorrectedPathName ); - } - */ - - dwPathType = IsValidFilePath( strSysDirectoryPath, NULL, VALIDATEPATH_NORMAL, NULL ); - - if ( dwPathType & PATHTYPE_IS_SERVER ) - { - error = osl_openNetworkServer( strSysDirectoryPath, pDirectory ); - } + if ( CopyFile( src, dst, FALSE ) ) + error = osl_File_E_None; else - error = osl_openFileDirectory( strSysDirectoryPath, pDirectory ); - - rtl_uString_release( strSysDirectoryPath ); + error = oslTranslateFileError( GetLastError() ); } - return error; -} - -//##################################################### -oslFileError SAL_CALL osl_getNextDirectoryItem(oslDirectory Directory, oslDirectoryItem *pItem, sal_uInt32 uHint) -{ - Directory_Impl *pDirImpl = (Directory_Impl *)Directory; - - /* Assume failure */ - - if ( !pItem ) - return osl_File_E_INVAL; - - *pItem = NULL; - - if ( !pDirImpl ) - return osl_File_E_INVAL; - - switch ( pDirImpl->uType ) - { - case DIRECTORYTYPE_LOCALROOT: - return osl_getNextDrive( Directory, pItem, uHint ); - case DIRECTORYTYPE_NETROOT: - return osl_getNextNetResource( Directory, pItem, uHint ); - case DIRECTORYTYPE_FILESYSTEM: - return osl_getNextFileItem( Directory, pItem, uHint ); - default: - return osl_File_E_INVAL; - } -} - -//##################################################### -oslFileError SAL_CALL osl_closeDirectory(oslDirectory Directory) -{ - Directory_Impl *pDirImpl = (Directory_Impl *)Directory; - oslFileError eError = osl_File_E_INVAL; - - if ( pDirImpl ) - { - switch ( pDirImpl->uType ) - { - case DIRECTORYTYPE_FILESYSTEM: - eError = CloseDirectory( pDirImpl->hDirectory ) ? osl_File_E_None : MapError( GetLastError() ); - break; - case DIRECTORYTYPE_LOCALROOT: - eError = CloseLogicalDrivesEnum( pDirImpl->hEnumDrives ) ? osl_File_E_None : MapError( GetLastError() ); - break; - case DIRECTORYTYPE_NETROOT: - { - DWORD err = WNetCloseEnum(pDirImpl->hDirectory); - eError = (err == NO_ERROR) ? osl_File_E_None : MapError(err); - } - break; - default: - OSL_ENSURE( 0, "Invalid directory type" ); - break; - } - - rtl_freeMemory(pDirImpl); - } - return eError; -} - -//##################################################### -oslFileError SAL_CALL osl_getDirectoryItem(rtl_uString *strFilePath, oslDirectoryItem *pItem) -{ - oslFileError error = osl_File_E_None; - rtl_uString* strSysFilePath = NULL; - PATHTYPE type = PATHTYPE_FILE; - DWORD dwPathType; -// TCHAR szCorrectedPathName[MAX_PATH]; - - /* Assume failure */ - - if ( !pItem ) - return osl_File_E_INVAL; - - *pItem = NULL; - - - error = _osl_getSystemPathFromFileURL( strFilePath, &strSysFilePath, sal_False ); - - if ( osl_File_E_None != error ) - return error; - - // MT: I can't imagine a case where this is good for! - /* - if ( GetCaseCorrectPathName( strSysFilePath->buffer, szCorrectedPathName, MAX_PATH ) ) - { - rtl_uString_newFromStr( &strSysFilePath, szCorrectedPathName ); - } - */ - - dwPathType = IsValidFilePath( strSysFilePath, NULL, VALIDATEPATH_NORMAL, NULL ); - - if ( dwPathType & PATHTYPE_IS_VOLUME ) - type = PATHTYPE_VOLUME; - else if ( dwPathType & PATHTYPE_IS_SERVER ) - type = PATHTYPE_NETSERVER; - else - type = PATHTYPE_FILE; - - switch ( type ) - { - case PATHTYPE_NETSERVER: - { - DirectoryItem_Impl* pItemImpl = - reinterpret_cast<DirectoryItem_Impl*>(rtl_allocateMemory(sizeof(DirectoryItem_Impl))); - - if ( !pItemImpl ) - error = osl_File_E_NOMEM; - - if ( osl_File_E_None == error ) - { - ZeroMemory( pItemImpl, sizeof(DirectoryItem_Impl) ); - pItemImpl->uType = DIRECTORYITEM_SERVER; - osl_acquireDirectoryItem( (oslDirectoryItem)pItemImpl ); - - _tcscpy( pItemImpl->szFullPath, reinterpret_cast<LPCTSTR>(strSysFilePath->buffer) ); - - // Assign a title anyway - { - int iSrc = 2; - int iDst = 0; - - while( iSrc < strSysFilePath->length && strSysFilePath->buffer[iSrc] && strSysFilePath->buffer[iSrc] != '\\' ) - { - pItemImpl->FindData.cFileName[iDst++] = strSysFilePath->buffer[iSrc++]; - } - } - - *pItem = pItemImpl; - } - } - break; - case PATHTYPE_VOLUME: - { - DirectoryItem_Impl* pItemImpl = - reinterpret_cast<DirectoryItem_Impl*>(rtl_allocateMemory(sizeof(DirectoryItem_Impl))); - - if ( !pItemImpl ) - error = osl_File_E_NOMEM; - - if ( osl_File_E_None == error ) - { - ZeroMemory( pItemImpl, sizeof(DirectoryItem_Impl) ); - pItemImpl->uType = DIRECTORYITEM_DRIVE; - - osl_acquireDirectoryItem( (oslDirectoryItem)pItemImpl ); - - _tcscpy( pItemImpl->cDriveString, reinterpret_cast<LPCTSTR>(strSysFilePath->buffer) ); - pItemImpl->cDriveString[0] = _toupper( pItemImpl->cDriveString[0] ); - - if ( pItemImpl->cDriveString[_tcslen(pItemImpl->cDriveString) - 1] != '\\' ) - _tcscat( pItemImpl->cDriveString, TEXT( "\\" ) ); - - *pItem = pItemImpl; - } - } - break; - case PATHTYPE_SYNTAXERROR: - case PATHTYPE_NETROOT: - case PATHTYPE_FILE: - { - HANDLE hFind; - WIN32_FIND_DATA aFindData; - - if ( strSysFilePath->length > 0 && strSysFilePath->buffer[strSysFilePath->length - 1] == '\\' ) - rtl_uString_newFromStr_WithLength( &strSysFilePath, strSysFilePath->buffer, strSysFilePath->length - 1 ); - - hFind = FindFirstFile( reinterpret_cast<LPCTSTR>(rtl_uString_getStr(strSysFilePath)), &aFindData ); - - if ( hFind != INVALID_HANDLE_VALUE ) - { - DirectoryItem_Impl *pItemImpl = - reinterpret_cast<DirectoryItem_Impl*>(rtl_allocateMemory(sizeof(DirectoryItem_Impl))); - - ZeroMemory( pItemImpl, sizeof(DirectoryItem_Impl) ); - osl_acquireDirectoryItem( (oslDirectoryItem)pItemImpl ); - - CopyMemory( &pItemImpl->FindData, &aFindData, sizeof(WIN32_FIND_DATA) ); - _tcscpy( pItemImpl->szFullPath, reinterpret_cast<LPCTSTR>(rtl_uString_getStr(strSysFilePath)) ); - - // MT: This costs 600ms startup time on fast v60x! - // GetCaseCorrectPathName( pItemImpl->szFullPath, pItemImpl->szFullPath, sizeof(pItemImpl->szFullPath) ); - - pItemImpl->uType = DIRECTORYITEM_FILE; - *pItem = pItemImpl; - FindClose( hFind ); - } - else - error = MapError( GetLastError() ); - } - break; - } - - if ( strSysFilePath ) - rtl_uString_release( strSysFilePath ); + if ( strSysPath ) + rtl_uString_release( strSysPath ); + if ( strSysDestPath ) + rtl_uString_release( strSysDestPath ); return error; } -//##################################################### -oslFileError SAL_CALL osl_acquireDirectoryItem( oslDirectoryItem Item ) -{ - DirectoryItem_Impl *pItemImpl = (DirectoryItem_Impl *)Item; - - if ( !pItemImpl ) - return osl_File_E_INVAL; - - pItemImpl->nRefCount++; - return osl_File_E_None; -} - -//##################################################### -oslFileError SAL_CALL osl_releaseDirectoryItem( oslDirectoryItem Item ) -{ - DirectoryItem_Impl *pItemImpl = (DirectoryItem_Impl *)Item; - - if ( !pItemImpl ) - return osl_File_E_INVAL; - - if ( ! --pItemImpl->nRefCount ) - rtl_freeMemory( pItemImpl ); - return osl_File_E_None; -} - -//##################################################### -oslFileError SAL_CALL osl_unmountVolumeDevice( oslVolumeDeviceHandle Handle ) -{ - if ( Handle ) - return osl_File_E_None; - else - return osl_File_E_INVAL; -} - -//##################################################### -oslFileError SAL_CALL osl_automountVolumeDevice( oslVolumeDeviceHandle Handle ) -{ - if ( Handle ) - return osl_File_E_None; - else - return osl_File_E_INVAL; -} - -//##################################################### -oslFileError SAL_CALL osl_acquireVolumeDeviceHandle( oslVolumeDeviceHandle Handle ) -{ - if ( Handle ) - { - rtl_uString_acquire( (rtl_uString *)Handle ); - return osl_File_E_None; - } - else - return osl_File_E_INVAL; -} - -//##################################################### -oslFileError SAL_CALL osl_releaseVolumeDeviceHandle( oslVolumeDeviceHandle Handle ) -{ - if ( Handle ) - { - rtl_uString_release( (rtl_uString *)Handle ); - return osl_File_E_None; - } - else - return osl_File_E_INVAL; -} - -//##################################################### -oslFileError SAL_CALL osl_getVolumeDeviceMountPath( oslVolumeDeviceHandle Handle, rtl_uString **pstrPath ) -{ - if ( Handle && pstrPath ) - { - rtl_uString_assign( pstrPath, (rtl_uString *)Handle ); - return osl_File_E_None; - } - else - return osl_File_E_INVAL; -} - - -//################################################################## -// FileURL functions -//################################################################## - - -//##################################################### -oslFileError SAL_CALL osl_getFileURLFromSystemPath( - rtl_uString* ustrPath, rtl_uString** pustrURL ) -{ - return _osl_getFileURLFromSystemPath( ustrPath, pustrURL ); -} - -//##################################################### -oslFileError SAL_CALL osl_getSystemPathFromFileURL( - rtl_uString *ustrURL, rtl_uString **pustrPath) -{ - return _osl_getSystemPathFromFileURL( ustrURL, pustrPath, sal_True ); -} - -//##################################################### -oslFileError SAL_CALL osl_searchFileURL( - rtl_uString *ustrFileName, - rtl_uString *ustrSystemSearchPath, - rtl_uString **pustrPath) +//############################################# +oslFileError SAL_CALL osl_moveFile( rtl_uString* strPath, rtl_uString *strDestPath ) { - rtl_uString *ustrUNCPath = NULL; - rtl_uString *ustrSysPath = NULL; - oslFileError error; - - /* First try to interpret the file name as an URL even a relative one */ - error = _osl_getSystemPathFromFileURL( ustrFileName, &ustrUNCPath, sal_True ); + rtl_uString *strSysPath = NULL, *strSysDestPath = NULL; + oslFileError error = _osl_getSystemPathFromFileURL( strPath, &strSysPath, sal_False ); - /* So far we either have an UNC path or something invalid - Now create a system path */ if ( osl_File_E_None == error ) - error = _osl_getSystemPathFromFileURL( ustrUNCPath, &ustrSysPath, sal_True ); + error = _osl_getSystemPathFromFileURL( strDestPath, &strSysDestPath, sal_False ); if ( osl_File_E_None == error ) { - DWORD nBufferLength; - DWORD dwResult; - LPTSTR lpBuffer = NULL; - LPTSTR lpszFilePart; + LPCTSTR src = reinterpret_cast<LPCTSTR>(rtl_uString_getStr( strSysPath )); + LPCTSTR dst = reinterpret_cast<LPCTSTR>(rtl_uString_getStr( strSysDestPath )); - /* Repeat calling SearchPath ... - Start with MAX_PATH for the buffer. In most cases this - will be enough and does not force the loop to runtwice */ - dwResult = MAX_PATH; - - do - { - /* If search path is empty use a NULL pointer instead according to MSDN documentation of SearchPath */ - LPCTSTR lpszSearchPath = ustrSystemSearchPath && ustrSystemSearchPath->length ? reinterpret_cast<LPCTSTR>(ustrSystemSearchPath->buffer) : NULL; - LPCTSTR lpszSearchFile = reinterpret_cast<LPCTSTR>(ustrSysPath->buffer); - - /* Allocate space for buffer according to previous returned count of required chars */ - /* +1 is not neccessary if we follow MSDN documentation but for robustness we do so */ - nBufferLength = dwResult + 1; - lpBuffer = lpBuffer ? - reinterpret_cast<LPTSTR>(rtl_reallocateMemory(lpBuffer, nBufferLength * sizeof(TCHAR))) : - reinterpret_cast<LPTSTR>(rtl_allocateMemory(nBufferLength * sizeof(TCHAR))); - - dwResult = SearchPath( lpszSearchPath, lpszSearchFile, NULL, nBufferLength, lpBuffer, &lpszFilePart ); - } while ( dwResult && dwResult >= nBufferLength ); - - /* ... until an error occures or buffer is large enough. - dwResult == nBufferLength can not happen according to documentation but lets be robust ;-) */ - - if ( dwResult ) - { - rtl_uString_newFromStr( &ustrSysPath, reinterpret_cast<const sal_Unicode*>(lpBuffer) ); - error = osl_getFileURLFromSystemPath( ustrSysPath, pustrPath ); - } + if ( MoveFileEx( src, dst, MOVEFILE_COPY_ALLOWED | MOVEFILE_WRITE_THROUGH | MOVEFILE_REPLACE_EXISTING ) ) + error = osl_File_E_None; else - { - WIN32_FIND_DATA aFindFileData; - HANDLE hFind; - - /* Somthing went wrong, perhaps the path was absolute */ - error = MapError( GetLastError() ); - - hFind = FindFirstFile( reinterpret_cast<LPCTSTR>(ustrSysPath->buffer), &aFindFileData ); - - if ( IsValidHandle(hFind) ) - { - error = osl_getFileURLFromSystemPath( ustrSysPath, pustrPath ); - FindClose( hFind ); - } - } - - rtl_freeMemory( lpBuffer ); + error = oslTranslateFileError( GetLastError() ); } - if ( ustrSysPath ) - rtl_uString_release( ustrSysPath ); - - if ( ustrUNCPath ) - rtl_uString_release( ustrUNCPath ); + if ( strSysPath ) + rtl_uString_release( strSysPath ); + if ( strSysDestPath ) + rtl_uString_release( strSysDestPath ); return error; } - -//##################################################### - -oslFileError SAL_CALL osl_getAbsoluteFileURL( rtl_uString* ustrBaseURL, rtl_uString* ustrRelativeURL, rtl_uString** pustrAbsoluteURL ) -{ - oslFileError eError; - rtl_uString *ustrRelSysPath = NULL; - rtl_uString *ustrBaseSysPath = NULL; - - if ( ustrBaseURL && ustrBaseURL->length ) - { - eError = _osl_getSystemPathFromFileURL( ustrBaseURL, &ustrBaseSysPath, sal_False ); - OSL_ENSURE( osl_File_E_None == eError, "osl_getAbsoluteFileURL called with relative or invalid base URL" ); - - eError = _osl_getSystemPathFromFileURL( ustrRelativeURL, &ustrRelSysPath, sal_True ); - } - else - { - eError = _osl_getSystemPathFromFileURL( ustrRelativeURL, &ustrRelSysPath, sal_False ); - OSL_ENSURE( osl_File_E_None == eError, "osl_getAbsoluteFileURL called with empty base URL and/or invalid relative URL" ); - } - - if ( !eError ) - { - TCHAR szBuffer[MAX_PATH]; - TCHAR szCurrentDir[MAX_PATH]; - LPTSTR lpFilePart = NULL; - DWORD dwResult; - -/*@@@ToDo - Bad, bad hack, this only works if the base path - really exists which is not necessary according - to RFC2396 - The whole FileURL implementation should be merged - with the rtl/uri class. -*/ - if ( ustrBaseSysPath ) - { - osl_acquireMutex( g_CurrentDirectoryMutex ); - - GetCurrentDirectory( MAX_PATH, szCurrentDir ); - SetCurrentDirectory( reinterpret_cast<LPCTSTR>(ustrBaseSysPath->buffer) ); - } - - dwResult = GetFullPathName( reinterpret_cast<LPCTSTR>(ustrRelSysPath->buffer), MAX_PATH, szBuffer, &lpFilePart ); - - if ( ustrBaseSysPath ) - { - SetCurrentDirectory( szCurrentDir ); - - osl_releaseMutex( g_CurrentDirectoryMutex ); - } - - if ( dwResult ) - { - if ( dwResult >= MAX_PATH ) - eError = osl_File_E_INVAL; - else - { - rtl_uString *ustrAbsSysPath = NULL; - - rtl_uString_newFromStr( &ustrAbsSysPath, reinterpret_cast<const sal_Unicode*>(szBuffer) ); - - eError = osl_getFileURLFromSystemPath( ustrAbsSysPath, pustrAbsoluteURL ); - - if ( ustrAbsSysPath ) - rtl_uString_release( ustrAbsSysPath ); - } - } - else - eError = MapError( GetLastError() ); - } - - if ( ustrBaseSysPath ) - rtl_uString_release( ustrBaseSysPath ); - - if ( ustrRelSysPath ) - rtl_uString_release( ustrRelSysPath ); - - return eError; -} - -//##################################################### -oslFileError SAL_CALL osl_getCanonicalName( rtl_uString *strRequested, rtl_uString **strValid ) -{ - rtl_uString_newFromString(strValid, strRequested); - return osl_File_E_None; -} diff --git a/sal/osl/w32/file_dirvol.cxx b/sal/osl/w32/file_dirvol.cxx new file mode 100644 index 000000000000..5ea839ae215d --- /dev/null +++ b/sal/osl/w32/file_dirvol.cxx @@ -0,0 +1,1777 @@ +/************************************************************************* + * + * 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: file.cxx,v $ + * $Revision: 1.19 $ + * + * 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. + * + ************************************************************************/ + +#define UNICODE +#define _UNICODE +#define _WIN32_WINNT_0x0500 +#include "systools/win32/uwinapi.h" + +#include "osl/file.h" + +#include "file_url.h" +#include "file_error.h" +#include "path_helper.hxx" + +#include "osl/diagnose.h" +#include "osl/time.h" +#include "rtl/alloc.h" +#include "rtl/ustring.hxx" + +#include <tchar.h> +#ifdef __MINGW32__ +#include <ctype.h> +#endif + +//##################################################### +#define ELEMENTS_OF_ARRAY(arr) (sizeof(arr)/(sizeof((arr)[0]))) + +static const wchar_t UNC_PREFIX[] = L"\\\\"; +static const wchar_t BACKSLASH = '\\'; +static const wchar_t SLASH = '/'; + +//##################################################### +extern "C" BOOL TimeValueToFileTime(const TimeValue *cpTimeVal, FILETIME *pFTime) +{ + SYSTEMTIME BaseSysTime; + FILETIME BaseFileTime; + FILETIME FTime; + __int64 localTime; + BOOL fSuccess = FALSE; + + BaseSysTime.wYear = 1970; + BaseSysTime.wMonth = 1; + BaseSysTime.wDayOfWeek = 0; + BaseSysTime.wDay = 1; + BaseSysTime.wHour = 0; + BaseSysTime.wMinute = 0; + BaseSysTime.wSecond = 0; + BaseSysTime.wMilliseconds = 0; + + if (cpTimeVal==NULL) + return fSuccess; + + if ( SystemTimeToFileTime(&BaseSysTime, &BaseFileTime) ) + { + __int64 timeValue; + localTime=cpTimeVal->Seconds*(__int64)10000000+cpTimeVal->Nanosec/100; + *(__int64 *)&FTime=localTime; + fSuccess = 0 <= (timeValue= *((__int64 *)&BaseFileTime) + *((__int64 *) &FTime)); + if (fSuccess) + *(__int64 *)pFTime=timeValue; + } + return fSuccess; +} + +//##################################################### +extern "C" BOOL FileTimeToTimeValue(const FILETIME *cpFTime, TimeValue *pTimeVal) +{ + SYSTEMTIME BaseSysTime; + FILETIME BaseFileTime; + BOOL fSuccess = FALSE; /* Assume failure */ + + BaseSysTime.wYear = 1970; + BaseSysTime.wMonth = 1; + BaseSysTime.wDayOfWeek = 0; + BaseSysTime.wDay = 1; + BaseSysTime.wHour = 0; + BaseSysTime.wMinute = 0; + BaseSysTime.wSecond = 0; + BaseSysTime.wMilliseconds = 0; + + if ( SystemTimeToFileTime(&BaseSysTime, &BaseFileTime) ) + { + __int64 Value; + + fSuccess = 0 <= (Value = *((__int64 *)cpFTime) - *((__int64 *)&BaseFileTime)); + + if ( fSuccess ) + { + pTimeVal->Seconds = (unsigned long) (Value / 10000000L); + pTimeVal->Nanosec = (unsigned long)((Value % 10000000L) * 100); + } + } + return fSuccess; +} + +//##################################################### +namespace /* private */ +{ + //##################################################### + struct Component + { + Component() : + begin_(0), end_(0) + {} + + bool isPresent() const + { return (static_cast<sal_IntPtr>(end_ - begin_) > 0); } + + const sal_Unicode* begin_; + const sal_Unicode* end_; + }; + + //##################################################### + struct UNCComponents + { + Component server_; + Component share_; + Component resource_; + }; + + //##################################################### + inline bool is_UNC_path(const sal_Unicode* path) + { return (0 == wcsncmp(UNC_PREFIX, reinterpret_cast<LPCWSTR>(path), ELEMENTS_OF_ARRAY(UNC_PREFIX) - 1)); } + + //##################################################### + inline bool is_UNC_path(const rtl::OUString& path) + { return is_UNC_path(path.getStr()); } + + //##################################################### + void parse_UNC_path(const sal_Unicode* path, UNCComponents* puncc) + { + OSL_PRECOND(is_UNC_path(path), "Precondition violated: No UNC path"); + OSL_PRECOND(rtl_ustr_indexOfChar(path, SLASH) != -1, "Path must not contain slashes"); + + const sal_Unicode* pend = path + rtl_ustr_getLength(path); + const sal_Unicode* ppos = path + 2; + + puncc->server_.begin_ = ppos; + while ((ppos < pend) && (*ppos != BACKSLASH)) + ppos++; + + puncc->server_.end_ = ppos; + + if (BACKSLASH == *ppos) + { + puncc->share_.begin_ = ++ppos; + while ((ppos < pend) && (*ppos != BACKSLASH)) + ppos++; + + puncc->share_.end_ = ppos; + + if (BACKSLASH == *ppos) + { + puncc->resource_.begin_ = ++ppos; + while (ppos < pend) + ppos++; + + puncc->resource_.end_ = ppos; + } + } + + OSL_POSTCOND(puncc->server_.isPresent() && puncc->share_.isPresent(), \ + "Postcondition violated: Invalid UNC path detected"); + } + + //##################################################### + void parse_UNC_path(const rtl::OUString& path, UNCComponents* puncc) + { parse_UNC_path(path.getStr(), puncc); } + + + //##################################################### + bool has_path_parent(const sal_Unicode* path) + { + // Has the given path a parent or are we already there, + // e.g. 'c:\' or '\\server\share\'? + + bool has_parent = false; + if (is_UNC_path(path)) + { + UNCComponents unc_comp; + parse_UNC_path(path, &unc_comp); + has_parent = unc_comp.resource_.isPresent(); + } + else + { + has_parent = !osl::systemPathIsLogicalDrivePattern(path); + } + return has_parent; + } + + //##################################################### + inline bool has_path_parent(const rtl::OUString& path) + { return has_path_parent(path.getStr()); } + +} // end namespace private + +//##################################################### +// volume handling functions +//##################################################### + +//##################################################### +oslFileError SAL_CALL osl_unmountVolumeDevice( oslVolumeDeviceHandle Handle ) +{ + if ( Handle ) + return osl_File_E_None; + else + return osl_File_E_INVAL; +} + +//##################################################### +oslFileError SAL_CALL osl_automountVolumeDevice( oslVolumeDeviceHandle Handle ) +{ + if ( Handle ) + return osl_File_E_None; + else + return osl_File_E_INVAL; +} + +//##################################################### +oslFileError SAL_CALL osl_acquireVolumeDeviceHandle( oslVolumeDeviceHandle Handle ) +{ + if ( Handle ) + { + rtl_uString_acquire( (rtl_uString *)Handle ); + return osl_File_E_None; + } + else + return osl_File_E_INVAL; +} + +//##################################################### +oslFileError SAL_CALL osl_releaseVolumeDeviceHandle( oslVolumeDeviceHandle Handle ) +{ + if ( Handle ) + { + rtl_uString_release( (rtl_uString *)Handle ); + return osl_File_E_None; + } + else + return osl_File_E_INVAL; +} + +//##################################################### +oslFileError SAL_CALL osl_getVolumeDeviceMountPath( oslVolumeDeviceHandle Handle, rtl_uString **pstrPath ) +{ + if ( Handle && pstrPath ) + { + rtl_uString_assign( pstrPath, (rtl_uString *)Handle ); + return osl_File_E_None; + } + else + return osl_File_E_INVAL; +} + +//################################################################## +// directory handling functions +//################################################################## + +#define DIRECTORYITEM_DRIVE 0 +#define DIRECTORYITEM_FILE 1 +#define DIRECTORYITEM_SERVER 2 + +struct DirectoryItem_Impl +{ + UINT uType; + union { + WIN32_FIND_DATA FindData; + TCHAR cDriveString[MAX_PATH]; + }; + TCHAR szFullPath[MAX_PATH]; + BOOL bFullPathNormalized; + int nRefCount; +}; + +//##################################################### + +#define DIRECTORYTYPE_LOCALROOT 0 +#define DIRECTORYTYPE_NETROOT 1 +#define DIRECTORYTYPE_NETRESORCE 2 +#define DIRECTORYTYPE_FILESYSTEM 3 + +struct Directory_Impl +{ + UINT uType; + union { + HANDLE hDirectory; + HANDLE hEnumDrives; + }; + TCHAR szDirectoryPath[MAX_PATH]; +}; + +//##################################################### + +typedef struct tagDRIVEENUM +{ + LPCTSTR lpIdent; + TCHAR cBuffer[/*('Z' - 'A' + 1) * sizeof("A:\\") + 1*/256]; + LPCTSTR lpCurrent; +} DRIVEENUM, * PDRIVEENUM, FAR * LPDRIVEENUM; + +//##################################################### + +static HANDLE WINAPI OpenLogicalDrivesEnum(void) +{ + LPDRIVEENUM pEnum = (LPDRIVEENUM)HeapAlloc( GetProcessHeap(), 0, sizeof(DRIVEENUM) ); + if ( pEnum ) + { + DWORD dwNumCopied = GetLogicalDriveStrings( (sizeof(pEnum->cBuffer) - 1) / sizeof(TCHAR), pEnum->cBuffer ); + + if ( dwNumCopied && dwNumCopied < sizeof(pEnum->cBuffer) / sizeof(TCHAR) ) + { + pEnum->lpCurrent = pEnum->cBuffer; + pEnum->lpIdent = L"tagDRIVEENUM"; + } + else + { + HeapFree( GetProcessHeap(), 0, pEnum ); + pEnum = NULL; + } + } + return pEnum ? (HANDLE)pEnum : INVALID_HANDLE_VALUE; +} + +//##################################################### +static BOOL WINAPI EnumLogicalDrives(HANDLE hEnum, LPTSTR lpBuffer) +{ + BOOL fSuccess = FALSE; + LPDRIVEENUM pEnum = (LPDRIVEENUM)hEnum; + + if ( pEnum ) + { + int nLen = _tcslen( pEnum->lpCurrent ); + + if ( nLen ) + { + CopyMemory( lpBuffer, pEnum->lpCurrent, (nLen + 1) * sizeof(TCHAR) ); + pEnum->lpCurrent += nLen + 1; + fSuccess = TRUE; + } + else + SetLastError( ERROR_NO_MORE_FILES ); + } + else + SetLastError( ERROR_INVALID_HANDLE ); + + return fSuccess; +} + +//##################################################### +static BOOL WINAPI CloseLogicalDrivesEnum(HANDLE hEnum) +{ + BOOL fSuccess = FALSE; + LPDRIVEENUM pEnum = (LPDRIVEENUM)hEnum; + + if ( pEnum ) + { + HeapFree( GetProcessHeap(), 0, pEnum ); + fSuccess = TRUE; + } + else + SetLastError( ERROR_INVALID_HANDLE ); + + return fSuccess; +} + +//##################################################### +typedef struct tagDIRECTORY +{ + HANDLE hFind; + WIN32_FIND_DATA aFirstData; +} DIRECTORY, *PDIRECTORY, FAR *LPDIRECTORY; + +//##################################################### +static HANDLE WINAPI OpenDirectory(LPCTSTR lpszPath) +{ + LPDIRECTORY pDirectory = (LPDIRECTORY)HeapAlloc(GetProcessHeap(), 0, sizeof(DIRECTORY)); + + if (pDirectory) + { + TCHAR szFileMask[MAX_PATH]; + int nLen; + + _tcscpy( szFileMask, lpszPath ); + nLen = _tcslen( szFileMask ); + + if (nLen && szFileMask[nLen-1] != '\\') + _tcscat(szFileMask, TEXT("\\*.*")); + else + _tcscat(szFileMask, TEXT("*.*")); + + pDirectory->hFind = FindFirstFile(szFileMask, &pDirectory->aFirstData); + + if (!IsValidHandle(pDirectory->hFind)) + { + if ( GetLastError() != ERROR_NO_MORE_FILES ) + { + HeapFree(GetProcessHeap(), 0, pDirectory); + pDirectory = NULL; + } + } + } + return (HANDLE)pDirectory; +} + +//##################################################### +BOOL WINAPI EnumDirectory(HANDLE hDirectory, LPWIN32_FIND_DATA pFindData) +{ + BOOL fSuccess = FALSE; + LPDIRECTORY pDirectory = (LPDIRECTORY)hDirectory; + + if ( pDirectory ) + { + BOOL fValid; + + do + { + if ( pDirectory->aFirstData.cFileName[0] ) + { + *pFindData = pDirectory->aFirstData; + fSuccess = TRUE; + pDirectory->aFirstData.cFileName[0] = 0; + } + else if ( IsValidHandle( pDirectory->hFind ) ) + fSuccess = FindNextFile( pDirectory->hFind, pFindData ); + else + { + fSuccess = FALSE; + SetLastError( ERROR_NO_MORE_FILES ); + } + + fValid = fSuccess && _tcscmp( TEXT("."), pFindData->cFileName ) != 0 && _tcscmp( TEXT(".."), pFindData->cFileName ) != 0; + + } while( fSuccess && !fValid ); + } + else + SetLastError( ERROR_INVALID_HANDLE ); + + return fSuccess; +} + +//##################################################### +static BOOL WINAPI CloseDirectory(HANDLE hDirectory) +{ + BOOL fSuccess = FALSE; + LPDIRECTORY pDirectory = (LPDIRECTORY)hDirectory; + + if (pDirectory) + { + if (IsValidHandle(pDirectory->hFind)) + fSuccess = FindClose(pDirectory->hFind); + + fSuccess = HeapFree(GetProcessHeap(), 0, pDirectory) && fSuccess; + } + else + SetLastError(ERROR_INVALID_HANDLE); + + return fSuccess; +} + +//##################################################### +static oslFileError osl_openLocalRoot( + rtl_uString *strDirectoryPath, oslDirectory *pDirectory) +{ + rtl_uString *strSysPath = NULL; + oslFileError error; + + if ( !pDirectory ) + return osl_File_E_INVAL; + + *pDirectory = NULL; + + error = _osl_getSystemPathFromFileURL( strDirectoryPath, &strSysPath, sal_False ); + if ( osl_File_E_None == error ) + { + Directory_Impl *pDirImpl; + + pDirImpl = reinterpret_cast<Directory_Impl*>(rtl_allocateMemory( sizeof(Directory_Impl))); + _tcscpy( pDirImpl->szDirectoryPath, reinterpret_cast<LPCTSTR>(rtl_uString_getStr(strSysPath)) ); + + /* Append backslash if neccessary */ + + /* @@@ToDo + use function ensure backslash + */ + if ( pDirImpl->szDirectoryPath[_tcslen(pDirImpl->szDirectoryPath) - 1] != L'\\' ) + _tcscat( pDirImpl->szDirectoryPath, L"\\" ); + + pDirImpl->uType = DIRECTORYTYPE_LOCALROOT; + pDirImpl->hEnumDrives = OpenLogicalDrivesEnum(); + + /* @@@ToDo + Use IsValidHandle(...) + */ + if ( pDirImpl->hEnumDrives != INVALID_HANDLE_VALUE ) + { + *pDirectory = (oslDirectory)pDirImpl; + error = osl_File_E_None; + } + else + { + if ( pDirImpl ) + rtl_freeMemory(pDirImpl); + + error = oslTranslateFileError( GetLastError() ); + } + + rtl_uString_release( strSysPath ); + } + return error; +} + +//##################################################### +static oslFileError SAL_CALL osl_openFileDirectory( + rtl_uString *strDirectoryPath, oslDirectory *pDirectory) +{ + oslFileError error = osl_File_E_None; + + if ( !pDirectory ) + return osl_File_E_INVAL; + *pDirectory = NULL; + + Directory_Impl *pDirImpl = reinterpret_cast<Directory_Impl*>(rtl_allocateMemory(sizeof(Directory_Impl))); + _tcscpy( pDirImpl->szDirectoryPath, reinterpret_cast<LPCTSTR>(rtl_uString_getStr(strDirectoryPath)) ); + + /* Append backslash if neccessary */ + + /* @@@ToDo + use function ensure backslash + */ + if ( pDirImpl->szDirectoryPath[_tcslen(pDirImpl->szDirectoryPath) - 1] != L'\\' ) + _tcscat( pDirImpl->szDirectoryPath, L"\\" ); + + pDirImpl->uType = DIRECTORYTYPE_FILESYSTEM; + pDirImpl->hDirectory = OpenDirectory( pDirImpl->szDirectoryPath ); + + if ( !pDirImpl->hDirectory ) + { + error = oslTranslateFileError( GetLastError() ); + + rtl_freeMemory(pDirImpl), pDirImpl = 0; + } + + *pDirectory = (oslDirectory)(pDirImpl); + return error; +} + +//##################################################### +static oslFileError SAL_CALL osl_openNetworkServer( + rtl_uString *strSysDirPath, oslDirectory *pDirectory) +{ + NETRESOURCEW aNetResource; + HANDLE hEnum; + DWORD dwError; + + ZeroMemory( &aNetResource, sizeof(aNetResource) ); + + aNetResource.lpRemoteName = reinterpret_cast<LPWSTR>(strSysDirPath->buffer); + + dwError = WNetOpenEnumW( + RESOURCE_GLOBALNET, + RESOURCETYPE_DISK, + RESOURCEUSAGE_CONNECTABLE | RESOURCEUSAGE_CONTAINER, + &aNetResource, + &hEnum ); + + if ( ERROR_SUCCESS == dwError ) + { + Directory_Impl *pDirImpl; + + pDirImpl = reinterpret_cast<Directory_Impl*>(rtl_allocateMemory(sizeof(Directory_Impl))); + pDirImpl->uType = DIRECTORYTYPE_NETROOT; + pDirImpl->hDirectory = hEnum; + *pDirectory = (oslDirectory)pDirImpl; + } + return oslTranslateFileError( dwError ); +} + +//############################################# +static DWORD create_dir_with_callback( + rtl_uString * dir_path, + oslDirectoryCreationCallbackFunc aDirectoryCreationCallbackFunc, + void* pData) +{ + // Create the specified directory and call the + // user specified callback function. On success + // the function returns ERROR_SUCCESS else a Win32 error code. + + if (CreateDirectory(reinterpret_cast<LPCTSTR>(dir_path->buffer), NULL)) + { + if (aDirectoryCreationCallbackFunc) + { + rtl::OUString url; + _osl_getFileURLFromSystemPath(dir_path, &(url.pData)); + aDirectoryCreationCallbackFunc(pData, url.pData); + } + return ERROR_SUCCESS; + } + return GetLastError(); +} + +//############################################# +static int path_make_parent(sal_Unicode* path) +{ + /* Cut off the last part of the given path to + get the parent only, e.g. 'c:\dir\subdir' -> + 'c:\dir' or '\\share\sub\dir' -> '\\share\sub' + @return The position where the path has been cut + off (this is the posistion of the last backslash). + If there are no more parents 0 will be returned, + e.g. 'c:\' or '\\Share' have no more parents */ + + OSL_PRECOND(rtl_ustr_indexOfChar(path, SLASH) != -1, "Path must not contain slashes"); + OSL_PRECOND(has_path_parent(path), "Path must have a parent"); + + sal_Unicode* pos_last_backslash = path + rtl_ustr_lastIndexOfChar(path, BACKSLASH); + *pos_last_backslash = 0; + return (pos_last_backslash - path); +} + +//############################################# +static DWORD create_dir_recursively_( + rtl_uString * dir_path, + oslDirectoryCreationCallbackFunc aDirectoryCreationCallbackFunc, + void* pData) +{ + OSL_PRECOND( + rtl_ustr_lastIndexOfChar_WithLength(dir_path->buffer, dir_path->length, BACKSLASH) != dir_path->length, + "Path must not end with a backslash"); + + DWORD w32_error = create_dir_with_callback( + dir_path, aDirectoryCreationCallbackFunc, pData); + if (w32_error == ERROR_SUCCESS) + return ERROR_SUCCESS; + + if ((w32_error != ERROR_PATH_NOT_FOUND) || !has_path_parent(dir_path->buffer)) + return w32_error; + + int pos = path_make_parent(dir_path->buffer); // dir_path->buffer[pos] = 0, restore below + + w32_error = create_dir_recursively_( + dir_path, aDirectoryCreationCallbackFunc, pData); + + dir_path->buffer[pos] = BACKSLASH; // restore + + if (ERROR_SUCCESS != w32_error) + return w32_error; + + return create_dir_recursively_(dir_path, aDirectoryCreationCallbackFunc, pData); +} + +//############################################# +oslFileError SAL_CALL osl_createDirectoryPath( + rtl_uString* aDirectoryUrl, + oslDirectoryCreationCallbackFunc aDirectoryCreationCallbackFunc, + void* pData) +{ + if (aDirectoryUrl == NULL) + return osl_File_E_INVAL; + + rtl::OUString sys_path; + oslFileError osl_error = + _osl_getSystemPathFromFileURL(aDirectoryUrl, &sys_path.pData, sal_False); + + if (osl_error != osl_File_E_None) + return osl_error; + + osl::systemPathRemoveSeparator(sys_path); + + // const_cast because sys_path is a local copy + // which we want to modify inplace instead of + // coyp it into another buffer on the heap again + return oslTranslateFileError(create_dir_recursively_( + sys_path.pData, aDirectoryCreationCallbackFunc, pData)); +} + +//##################################################### +oslFileError SAL_CALL osl_createDirectory(rtl_uString* strPath) +{ + rtl_uString *strSysPath = NULL; + oslFileError error = _osl_getSystemPathFromFileURL( strPath, &strSysPath, sal_False ); + + if ( osl_File_E_None == error ) + { + if ( CreateDirectoryW( reinterpret_cast<LPCWSTR>(rtl_uString_getStr( strSysPath )), NULL ) ) + error = osl_File_E_None; +/*@@@ToDo + The else case is a hack because the ucb or the webtop had some + problems with the error code that CreateDirectory returns in + case the path is only a logical drive, should be removed! +*/ + else + { + const sal_Unicode *pBuffer = rtl_uString_getStr( strSysPath ); + sal_Int32 nLen = rtl_uString_getLength( strSysPath ); + + if ( + ( ( pBuffer[0] >= 'A' && pBuffer[0] <= 'Z' ) || + ( pBuffer[0] >= 'a' && pBuffer[0] <= 'z' ) ) && + pBuffer[1] == ':' && ( nLen ==2 || ( nLen == 3 && pBuffer[2] == '\\' ) ) + ) + SetLastError( ERROR_ALREADY_EXISTS ); + + error = oslTranslateFileError( GetLastError() ); + } + + rtl_uString_release( strSysPath ); + } + return error; +} + +//##################################################### +oslFileError SAL_CALL osl_removeDirectory(rtl_uString* strPath) +{ + rtl_uString *strSysPath = NULL; + oslFileError error = _osl_getSystemPathFromFileURL( strPath, &strSysPath, sal_False ); + + if ( osl_File_E_None == error ) + { + if ( RemoveDirectory( reinterpret_cast<LPCTSTR>(rtl_uString_getStr( strSysPath )) ) ) + error = osl_File_E_None; + else + error = oslTranslateFileError( GetLastError() ); + + rtl_uString_release( strSysPath ); + } + return error; +} + +//##################################################### +oslFileError SAL_CALL osl_openDirectory(rtl_uString *strDirectoryPath, oslDirectory *pDirectory) +{ + oslFileError error; + + if ( 0 == rtl_ustr_ascii_compareIgnoreAsciiCase( strDirectoryPath->buffer, "file:///" ) ) + error = osl_openLocalRoot( strDirectoryPath, pDirectory ); + else + { + rtl_uString *strSysDirectoryPath = NULL; + DWORD dwPathType; + + error = _osl_getSystemPathFromFileURL( strDirectoryPath, &strSysDirectoryPath, sal_False ); + + if ( osl_File_E_None != error ) + return error; + + dwPathType = IsValidFilePath( strSysDirectoryPath, NULL, VALIDATEPATH_NORMAL, NULL ); + + if ( dwPathType & PATHTYPE_IS_SERVER ) + { + error = osl_openNetworkServer( strSysDirectoryPath, pDirectory ); + } + else + error = osl_openFileDirectory( strSysDirectoryPath, pDirectory ); + + rtl_uString_release( strSysDirectoryPath ); + } + return error; +} + +//##################################################### +static oslFileError SAL_CALL osl_getNextNetResource( + oslDirectory Directory, oslDirectoryItem *pItem, sal_uInt32 uHint ) +{ + Directory_Impl *pDirImpl = (Directory_Impl *)Directory; + DirectoryItem_Impl *pItemImpl = NULL; + BYTE buffer[16384]; + LPNETRESOURCEW lpNetResource = (LPNETRESOURCEW)buffer; + DWORD dwError, dwCount, dwBufSize; + + uHint = uHint; /* to get no warning */ + + if ( !pItem ) + return osl_File_E_INVAL; + *pItem = NULL; + + if ( !pDirImpl ) + return osl_File_E_INVAL; + + dwCount = 1; + dwBufSize = sizeof(buffer); + dwError = WNetEnumResource( pDirImpl->hDirectory, &dwCount, lpNetResource, &dwBufSize ); + + switch ( dwError ) + { + case NO_ERROR: + case ERROR_MORE_DATA: + { + pItemImpl = reinterpret_cast<DirectoryItem_Impl*>(rtl_allocateMemory(sizeof(DirectoryItem_Impl))); + if ( !pItemImpl ) + return osl_File_E_NOMEM; + + ZeroMemory( pItemImpl, sizeof(DirectoryItem_Impl) ); + pItemImpl->uType = DIRECTORYITEM_DRIVE; + osl_acquireDirectoryItem( (oslDirectoryItem)pItemImpl ); + + wcscpy( pItemImpl->cDriveString, lpNetResource->lpRemoteName ); + + *pItem = pItemImpl; + } + return osl_File_E_None; + case ERROR_NO_MORE_ITEMS: + return osl_File_E_NOENT; + default: + return oslTranslateFileError( dwError ); + } +} + +//##################################################### +static oslFileError SAL_CALL osl_getNextDrive( + oslDirectory Directory, oslDirectoryItem *pItem, sal_uInt32 uHint ) +{ + Directory_Impl *pDirImpl = (Directory_Impl *)Directory; + DirectoryItem_Impl *pItemImpl = NULL; + BOOL fSuccess; + + uHint = uHint; /* avoid warnings */ + + if ( !pItem ) + return osl_File_E_INVAL; + *pItem = NULL; + + if ( !pDirImpl ) + return osl_File_E_INVAL; + + pItemImpl = reinterpret_cast<DirectoryItem_Impl*>(rtl_allocateMemory(sizeof(DirectoryItem_Impl))); + if ( !pItemImpl ) + return osl_File_E_NOMEM; + + ZeroMemory( pItemImpl, sizeof(DirectoryItem_Impl) ); + pItemImpl->uType = DIRECTORYITEM_DRIVE; + osl_acquireDirectoryItem( (oslDirectoryItem)pItemImpl ); + fSuccess = EnumLogicalDrives( pDirImpl->hEnumDrives, pItemImpl->cDriveString ); + + if ( fSuccess ) + { + *pItem = pItemImpl; + return osl_File_E_None; + } + else + { + rtl_freeMemory( pItemImpl ); + return oslTranslateFileError( GetLastError() ); + } +} + +//##################################################### +static oslFileError SAL_CALL osl_getNextFileItem( + oslDirectory Directory, oslDirectoryItem *pItem, sal_uInt32 uHint) +{ + Directory_Impl *pDirImpl = (Directory_Impl *)Directory; + DirectoryItem_Impl *pItemImpl = NULL; + BOOL fFound; + + uHint = uHint; /* avoid warnings */ + + if ( !pItem ) + return osl_File_E_INVAL; + *pItem = NULL; + + if ( !pDirImpl ) + return osl_File_E_INVAL; + + pItemImpl = reinterpret_cast<DirectoryItem_Impl*>(rtl_allocateMemory(sizeof(DirectoryItem_Impl))); + if ( !pItemImpl ) + return osl_File_E_NOMEM; + + memset( pItemImpl, 0, sizeof(DirectoryItem_Impl) ); + fFound = EnumDirectory( pDirImpl->hDirectory, &pItemImpl->FindData ); + + if ( fFound ) + { + pItemImpl->uType = DIRECTORYITEM_FILE; + pItemImpl->nRefCount = 1; + _tcscpy( pItemImpl->szFullPath, pDirImpl->szDirectoryPath ); + _tcscat( pItemImpl->szFullPath, pItemImpl->FindData.cFileName ); + pItemImpl->bFullPathNormalized = FALSE; + *pItem = (oslDirectoryItem)pItemImpl; + return osl_File_E_None; + } + else + { + rtl_freeMemory( pItemImpl ); + return oslTranslateFileError( GetLastError() ); + } +} + +//##################################################### +oslFileError SAL_CALL osl_getNextDirectoryItem( + oslDirectory Directory, oslDirectoryItem *pItem, sal_uInt32 uHint) +{ + Directory_Impl *pDirImpl = (Directory_Impl *)Directory; + + /* Assume failure */ + + if ( !pItem ) + return osl_File_E_INVAL; + *pItem = NULL; + + if ( !pDirImpl ) + return osl_File_E_INVAL; + + switch ( pDirImpl->uType ) + { + case DIRECTORYTYPE_LOCALROOT: + return osl_getNextDrive( Directory, pItem, uHint ); + case DIRECTORYTYPE_NETROOT: + return osl_getNextNetResource( Directory, pItem, uHint ); + case DIRECTORYTYPE_FILESYSTEM: + return osl_getNextFileItem( Directory, pItem, uHint ); + default: + return osl_File_E_INVAL; + } +} + +//##################################################### +oslFileError SAL_CALL osl_closeDirectory(oslDirectory Directory) +{ + Directory_Impl *pDirImpl = (Directory_Impl *)Directory; + oslFileError eError = osl_File_E_INVAL; + + if ( pDirImpl ) + { + switch ( pDirImpl->uType ) + { + case DIRECTORYTYPE_FILESYSTEM: + eError = CloseDirectory( pDirImpl->hDirectory ) ? osl_File_E_None : oslTranslateFileError( GetLastError() ); + break; + case DIRECTORYTYPE_LOCALROOT: + eError = CloseLogicalDrivesEnum( pDirImpl->hEnumDrives ) ? osl_File_E_None : oslTranslateFileError( GetLastError() ); + break; + case DIRECTORYTYPE_NETROOT: + { + DWORD err = WNetCloseEnum(pDirImpl->hDirectory); + eError = (err == NO_ERROR) ? osl_File_E_None : oslTranslateFileError(err); + } + break; + default: + OSL_ENSURE( 0, "Invalid directory type" ); + break; + } + + rtl_freeMemory(pDirImpl); + } + return eError; +} + +//##################################################### +/* Different types of paths */ +typedef enum _PATHTYPE +{ + PATHTYPE_SYNTAXERROR = 0, + PATHTYPE_NETROOT, + PATHTYPE_NETSERVER, + PATHTYPE_VOLUME, + PATHTYPE_FILE +} PATHTYPE; + +oslFileError SAL_CALL osl_getDirectoryItem(rtl_uString *strFilePath, oslDirectoryItem *pItem) +{ + oslFileError error = osl_File_E_None; + rtl_uString* strSysFilePath = NULL; + PATHTYPE type = PATHTYPE_FILE; + DWORD dwPathType; + + /* Assume failure */ + + if ( !pItem ) + return osl_File_E_INVAL; + + *pItem = NULL; + + + error = _osl_getSystemPathFromFileURL( strFilePath, &strSysFilePath, sal_False ); + + if ( osl_File_E_None != error ) + return error; + + dwPathType = IsValidFilePath( strSysFilePath, NULL, VALIDATEPATH_NORMAL, NULL ); + + if ( dwPathType & PATHTYPE_IS_VOLUME ) + type = PATHTYPE_VOLUME; + else if ( dwPathType & PATHTYPE_IS_SERVER ) + type = PATHTYPE_NETSERVER; + else + type = PATHTYPE_FILE; + + switch ( type ) + { + case PATHTYPE_NETSERVER: + { + DirectoryItem_Impl* pItemImpl = + reinterpret_cast<DirectoryItem_Impl*>(rtl_allocateMemory(sizeof(DirectoryItem_Impl))); + + if ( !pItemImpl ) + error = osl_File_E_NOMEM; + + if ( osl_File_E_None == error ) + { + ZeroMemory( pItemImpl, sizeof(DirectoryItem_Impl) ); + pItemImpl->uType = DIRECTORYITEM_SERVER; + + osl_acquireDirectoryItem( (oslDirectoryItem)pItemImpl ); + + _tcscpy( pItemImpl->szFullPath, reinterpret_cast<LPCTSTR>(strSysFilePath->buffer) ); + + // Assign a title anyway + { + int iSrc = 2; + int iDst = 0; + + while( iSrc < strSysFilePath->length && strSysFilePath->buffer[iSrc] && strSysFilePath->buffer[iSrc] != '\\' ) + { + pItemImpl->FindData.cFileName[iDst++] = strSysFilePath->buffer[iSrc++]; + } + } + + *pItem = pItemImpl; + } + } + break; + case PATHTYPE_VOLUME: + { + DirectoryItem_Impl* pItemImpl = + reinterpret_cast<DirectoryItem_Impl*>(rtl_allocateMemory(sizeof(DirectoryItem_Impl))); + + if ( !pItemImpl ) + error = osl_File_E_NOMEM; + + if ( osl_File_E_None == error ) + { + ZeroMemory( pItemImpl, sizeof(DirectoryItem_Impl) ); + pItemImpl->uType = DIRECTORYITEM_DRIVE; + + osl_acquireDirectoryItem( (oslDirectoryItem)pItemImpl ); + + _tcscpy( pItemImpl->cDriveString, reinterpret_cast<LPCTSTR>(strSysFilePath->buffer) ); + pItemImpl->cDriveString[0] = _toupper( pItemImpl->cDriveString[0] ); + + if ( pItemImpl->cDriveString[_tcslen(pItemImpl->cDriveString) - 1] != '\\' ) + _tcscat( pItemImpl->cDriveString, TEXT( "\\" ) ); + + *pItem = pItemImpl; + } + } + break; + case PATHTYPE_SYNTAXERROR: + case PATHTYPE_NETROOT: + case PATHTYPE_FILE: + { + HANDLE hFind; + WIN32_FIND_DATA aFindData; + + if ( strSysFilePath->length > 0 && strSysFilePath->buffer[strSysFilePath->length - 1] == '\\' ) + rtl_uString_newFromStr_WithLength( &strSysFilePath, strSysFilePath->buffer, strSysFilePath->length - 1 ); + + hFind = FindFirstFile( reinterpret_cast<LPCTSTR>(rtl_uString_getStr(strSysFilePath)), &aFindData ); + + if ( hFind != INVALID_HANDLE_VALUE ) + { + DirectoryItem_Impl *pItemImpl = + reinterpret_cast<DirectoryItem_Impl*>(rtl_allocateMemory(sizeof(DirectoryItem_Impl))); + + ZeroMemory( pItemImpl, sizeof(DirectoryItem_Impl) ); + osl_acquireDirectoryItem( (oslDirectoryItem)pItemImpl ); + + CopyMemory( &pItemImpl->FindData, &aFindData, sizeof(WIN32_FIND_DATA) ); + _tcscpy( pItemImpl->szFullPath, reinterpret_cast<LPCTSTR>(rtl_uString_getStr(strSysFilePath)) ); + + // MT: This costs 600ms startup time on fast v60x! + // GetCaseCorrectPathName( pItemImpl->szFullPath, pItemImpl->szFullPath, sizeof(pItemImpl->szFullPath) ); + + pItemImpl->uType = DIRECTORYITEM_FILE; + *pItem = pItemImpl; + FindClose( hFind ); + } + else + error = oslTranslateFileError( GetLastError() ); + } + break; + } + + if ( strSysFilePath ) + rtl_uString_release( strSysFilePath ); + + return error; +} + +//##################################################### +oslFileError SAL_CALL osl_acquireDirectoryItem( oslDirectoryItem Item ) +{ + DirectoryItem_Impl *pItemImpl = (DirectoryItem_Impl *)Item; + + if ( !pItemImpl ) + return osl_File_E_INVAL; + + pItemImpl->nRefCount++; + return osl_File_E_None; +} + +//##################################################### +oslFileError SAL_CALL osl_releaseDirectoryItem( oslDirectoryItem Item ) +{ + DirectoryItem_Impl *pItemImpl = (DirectoryItem_Impl *)Item; + + if ( !pItemImpl ) + return osl_File_E_INVAL; + + if ( ! --pItemImpl->nRefCount ) + rtl_freeMemory( pItemImpl ); + return osl_File_E_None; +} + +//##################################################### +// volume / file info handling functions +//##################################################### + +//##################################################### +static inline bool is_floppy_A_present() +{ return (GetLogicalDrives() & 1); } + +//##################################################### +static inline bool is_floppy_B_present() +{ return (GetLogicalDrives() & 2); } + +//##################################################### +bool is_floppy_volume_mount_point(const rtl::OUString& path) +{ + // determines if a volume mount point shows to a floppy + // disk by comparing the unique volume names + static const LPCWSTR FLOPPY_A = L"A:\\"; + static const LPCWSTR FLOPPY_B = L"B:\\"; + + rtl::OUString p(path); + osl::systemPathEnsureSeparator(p); + + TCHAR vn[51]; + if (GetVolumeNameForVolumeMountPoint(reinterpret_cast<LPCTSTR>(p.getStr()), vn, ELEMENTS_OF_ARRAY(vn))) + { + TCHAR vnfloppy[51]; + if (is_floppy_A_present() && + GetVolumeNameForVolumeMountPoint(FLOPPY_A, vnfloppy, ELEMENTS_OF_ARRAY(vnfloppy)) && + (0 == wcscmp(vn, vnfloppy))) + return true; + + if (is_floppy_B_present() && + GetVolumeNameForVolumeMountPoint(FLOPPY_B, vnfloppy, ELEMENTS_OF_ARRAY(vnfloppy)) && + (0 == wcscmp(vn, vnfloppy))) + return true; + } + return false; +} + +//################################################ +static bool is_floppy_drive(const rtl::OUString& path) +{ + static const LPCWSTR FLOPPY_DRV_LETTERS = TEXT("AaBb"); + + // we must take into account that even a floppy + // drive may be mounted to a directory so checking + // for the drive letter alone is not sufficient + // we must compare the unique volume name with + // that of the available floppy disks + + const sal_Unicode* pszPath = path.getStr(); + return ((wcschr(FLOPPY_DRV_LETTERS, pszPath[0]) && (L':' == pszPath[1])) || is_floppy_volume_mount_point(path)); +} + +//##################################################### +static bool is_volume_mount_point(const rtl::OUString& path) +{ + rtl::OUString p(path); + osl::systemPathRemoveSeparator(p); + + bool is_volume_root = false; + + if (!is_floppy_drive(p)) + { + DWORD fattr = GetFileAttributes(reinterpret_cast<LPCTSTR>(p.getStr())); + + if ((INVALID_FILE_ATTRIBUTES != fattr) && + (FILE_ATTRIBUTE_REPARSE_POINT & fattr)) + { + WIN32_FIND_DATA find_data; + HANDLE h_find = FindFirstFile(reinterpret_cast<LPCTSTR>(p.getStr()), &find_data); + + if (IsValidHandle(h_find) && + (FILE_ATTRIBUTE_REPARSE_POINT & find_data.dwFileAttributes) && + (IO_REPARSE_TAG_MOUNT_POINT == find_data.dwReserved0)) + { + is_volume_root = true; + } + if (IsValidHandle(h_find)) + FindClose(h_find); + } + } + return is_volume_root; +} + +//############################################# +static UINT get_volume_mount_point_drive_type(const rtl::OUString& path) +{ + if (0 == path.getLength()) + return GetDriveType(NULL); + + rtl::OUString p(path); + osl::systemPathEnsureSeparator(p); + + TCHAR vn[51]; + if (GetVolumeNameForVolumeMountPoint(reinterpret_cast<LPCTSTR>(p.getStr()), vn, ELEMENTS_OF_ARRAY(vn))) + return GetDriveType(vn); + + return DRIVE_NO_ROOT_DIR; +} + +//############################################# +static inline bool is_drivetype_request(sal_uInt32 field_mask) +{ + return (field_mask & osl_VolumeInfo_Mask_Attributes); +} + +//############################################# +static oslFileError osl_get_drive_type( + const rtl::OUString& path, oslVolumeInfo* pInfo) +{ + // GetDriveType fails on empty volume mount points + // see Knowledge Base Q244089 + UINT drive_type; + if (is_volume_mount_point(path)) + drive_type = get_volume_mount_point_drive_type(path); + else + drive_type = GetDriveType(reinterpret_cast<LPCTSTR>(path.getStr())); + + if (DRIVE_NO_ROOT_DIR == drive_type) + return oslTranslateFileError(ERROR_INVALID_DRIVE); + + pInfo->uValidFields |= osl_VolumeInfo_Mask_Attributes; + + switch (drive_type) + { + case DRIVE_CDROM: + pInfo->uAttributes |= osl_Volume_Attribute_CompactDisc | osl_Volume_Attribute_Removeable; + break; + case DRIVE_REMOVABLE: + pInfo->uAttributes |= osl_Volume_Attribute_Removeable; + if (is_floppy_drive(path)) + pInfo->uAttributes |= osl_Volume_Attribute_FloppyDisk; + break; + case DRIVE_FIXED: + pInfo->uAttributes |= osl_Volume_Attribute_FixedDisk; + break; + case DRIVE_RAMDISK: + pInfo->uAttributes |= osl_Volume_Attribute_RAMDisk; + break; + case DRIVE_REMOTE: + pInfo->uAttributes |= osl_Volume_Attribute_Remote; + break; + case DRIVE_UNKNOWN: + pInfo->uAttributes = 0; + break; + default: + pInfo->uValidFields &= ~osl_VolumeInfo_Mask_Attributes; + pInfo->uAttributes = 0; + break; + } + return osl_File_E_None; +} + +//############################################# +static inline bool is_volume_space_info_request(sal_uInt32 field_mask) +{ + return (field_mask & + (osl_VolumeInfo_Mask_TotalSpace | + osl_VolumeInfo_Mask_UsedSpace | + osl_VolumeInfo_Mask_FreeSpace)); +} + +//############################################# +static void get_volume_space_information( + const rtl::OUString& path, oslVolumeInfo *pInfo) +{ + BOOL ret = GetDiskFreeSpaceEx( + reinterpret_cast<LPCTSTR>(path.getStr()), + (PULARGE_INTEGER)&(pInfo->uFreeSpace), + (PULARGE_INTEGER)&(pInfo->uTotalSpace), + NULL); + + if (ret) + { + pInfo->uUsedSpace = pInfo->uTotalSpace - pInfo->uFreeSpace; + pInfo->uValidFields |= osl_VolumeInfo_Mask_TotalSpace | + osl_VolumeInfo_Mask_UsedSpace | + osl_VolumeInfo_Mask_FreeSpace; + } +} + +//############################################# +static inline bool is_filesystem_attributes_request(sal_uInt32 field_mask) +{ + return (field_mask & + (osl_VolumeInfo_Mask_MaxNameLength | + osl_VolumeInfo_Mask_MaxPathLength | + osl_VolumeInfo_Mask_FileSystemName | + osl_VolumeInfo_Mask_FileSystemCaseHandling)); +} + +//############################################# +static oslFileError get_filesystem_attributes( + const rtl::OUString& path, sal_uInt32 field_mask, oslVolumeInfo* pInfo) +{ + pInfo->uAttributes = 0; + + // osl_get_drive_type must be called first because + // this function resets osl_VolumeInfo_Mask_Attributes + // on failure + if (is_drivetype_request(field_mask)) + { + oslFileError osl_error = osl_get_drive_type(path, pInfo); + if (osl_File_E_None != osl_error) + return osl_error; + } + if (is_filesystem_attributes_request(field_mask)) + { + WCHAR vn[MAX_PATH]; + WCHAR fsn[MAX_PATH]; + DWORD serial; + DWORD mcl; + DWORD flags; + + LPCTSTR pszPath = reinterpret_cast<LPCTSTR>(path.getStr()); + if (GetVolumeInformation(pszPath, vn, MAX_PATH, &serial, &mcl, &flags, fsn, MAX_PATH)) + { + pInfo->uValidFields |= osl_VolumeInfo_Mask_MaxNameLength; + pInfo->uMaxNameLength = mcl; + + pInfo->uValidFields |= osl_VolumeInfo_Mask_MaxPathLength; + pInfo->uMaxPathLength = MAX_PATH; + + pInfo->uValidFields |= osl_VolumeInfo_Mask_FileSystemName; + rtl_uString_newFromStr(&pInfo->ustrFileSystemName, reinterpret_cast<const sal_Unicode*>(fsn)); + + // volumes (even NTFS) will always be considered case + // insensitive because the Win32 API is not able to + // deal with case sensitive volumes see M$ Knowledge Base + // article 100625 that's why we never set the attribute + // osl_Volume_Attribute_Case_Sensitive + + if (flags & FS_CASE_IS_PRESERVED) + pInfo->uAttributes |= osl_Volume_Attribute_Case_Is_Preserved; + + pInfo->uValidFields |= osl_VolumeInfo_Mask_Attributes; + } + } + return osl_File_E_None; +} + +//##################################################### +static bool path_get_parent(rtl::OUString& path) +{ + OSL_PRECOND(path.lastIndexOf(SLASH) == -1, "Path must not have slashes"); + + if (!has_path_parent(path)) + { + sal_Int32 i = path.lastIndexOf(BACKSLASH); + if (-1 < i) + { + path = rtl::OUString(path.getStr(), i); + return true; + } + } + return false; +} + +//##################################################### +static void path_travel_to_volume_root(const rtl::OUString& system_path, rtl::OUString& volume_root) +{ + rtl::OUString sys_path(system_path); + + while(!is_volume_mount_point(sys_path) && path_get_parent(sys_path)) + /**/; + + volume_root = sys_path; + osl::systemPathEnsureSeparator(volume_root); +} + +//############################################# +oslFileError SAL_CALL osl_getVolumeInformation( + rtl_uString *ustrURL, oslVolumeInfo *pInfo, sal_uInt32 uFieldMask ) +{ + if (!pInfo) + return osl_File_E_INVAL; + + rtl::OUString system_path; + oslFileError error = _osl_getSystemPathFromFileURL(ustrURL, &system_path.pData, sal_False); + + if (osl_File_E_None != error) + return error; + + rtl::OUString volume_root; + path_travel_to_volume_root(system_path, volume_root); + + pInfo->uValidFields = 0; + + if ((error = get_filesystem_attributes(volume_root, uFieldMask, pInfo)) != osl_File_E_None) + return error; + + if (is_volume_space_info_request(uFieldMask)) + get_volume_space_information(volume_root, pInfo); + + if (uFieldMask & osl_VolumeInfo_Mask_DeviceHandle) + { + pInfo->uValidFields |= osl_VolumeInfo_Mask_DeviceHandle; + osl_getFileURLFromSystemPath(volume_root.pData, (rtl_uString**)&pInfo->pDeviceHandle); + } + + return osl_File_E_None; +} + +//##################################################### +static oslFileError SAL_CALL osl_getDriveInfo( + oslDirectoryItem Item, oslFileStatus *pStatus, sal_uInt32 uFieldMask) +{ + DirectoryItem_Impl *pItemImpl = (DirectoryItem_Impl *)Item; + TCHAR cDrive[3] = TEXT("A:"); + TCHAR cRoot[4] = TEXT("A:\\"); + + if ( !pItemImpl ) + return osl_File_E_INVAL; + + pStatus->uValidFields = 0; + + cDrive[0] = pItemImpl->cDriveString[0]; + cRoot[0] = pItemImpl->cDriveString[0]; + + if ( uFieldMask & osl_FileStatus_Mask_FileName ) + { + if ( pItemImpl->cDriveString[0] == '\\' && pItemImpl->cDriveString[1] == '\\' ) + { + LPCWSTR lpFirstBkSlash = wcschr( &pItemImpl->cDriveString[2], '\\' ); + + if ( lpFirstBkSlash && lpFirstBkSlash[1] ) + { + LPCWSTR lpLastBkSlash = wcschr( &lpFirstBkSlash[1], '\\' ); + + if ( lpLastBkSlash ) + rtl_uString_newFromStr_WithLength( &pStatus->ustrFileName, reinterpret_cast<const sal_Unicode*>(&lpFirstBkSlash[1]), lpLastBkSlash - lpFirstBkSlash - 1 ); + else + rtl_uString_newFromStr( &pStatus->ustrFileName, reinterpret_cast<const sal_Unicode*>(&lpFirstBkSlash[1]) ); + pStatus->uValidFields |= osl_FileStatus_Mask_FileName; + } + } + else switch ( GetDriveType( cRoot ) ) + { + case DRIVE_REMOTE: + { + TCHAR szBuffer[1024]; + DWORD const dwBufsizeConst = ELEMENTS_OF_ARRAY(szBuffer); + DWORD dwBufsize = dwBufsizeConst; + + DWORD dwResult = WNetGetConnection( cDrive, szBuffer, &dwBufsize ); + if ( NO_ERROR == dwResult ) + { + TCHAR szFileName[dwBufsizeConst + 16]; + + swprintf( szFileName, L"%s [%s]", cDrive, szBuffer ); + rtl_uString_newFromStr( &pStatus->ustrFileName, reinterpret_cast<const sal_Unicode*>(szFileName) ); + } + else + rtl_uString_newFromStr( &pStatus->ustrFileName, reinterpret_cast<const sal_Unicode*>(cDrive) ); + } + pStatus->uValidFields |= osl_FileStatus_Mask_FileName; + break; + case DRIVE_FIXED: + { + TCHAR szVolumeNameBuffer[1024]; + DWORD const dwBufsizeConst = ELEMENTS_OF_ARRAY(szVolumeNameBuffer); + + if ( GetVolumeInformation( cRoot, szVolumeNameBuffer, dwBufsizeConst, NULL, NULL, NULL, NULL, 0 ) ) + { + TCHAR szFileName[dwBufsizeConst + 16]; + + swprintf( szFileName, L"%s [%s]", cDrive, szVolumeNameBuffer ); + rtl_uString_newFromStr( &pStatus->ustrFileName, reinterpret_cast<const sal_Unicode*>(szFileName) ); + } + else + rtl_uString_newFromStr( &pStatus->ustrFileName, reinterpret_cast<const sal_Unicode*>(cDrive) ); + } + pStatus->uValidFields |= osl_FileStatus_Mask_FileName; + break; + case DRIVE_CDROM: + case DRIVE_REMOVABLE: + pStatus->uValidFields |= osl_FileStatus_Mask_FileName; + rtl_uString_newFromStr( &pStatus->ustrFileName, reinterpret_cast<const sal_Unicode*>(cRoot) ); + break; + case DRIVE_UNKNOWN: + default: + break; + } + } + + pStatus->eType = osl_File_Type_Volume; + pStatus->uValidFields |= osl_FileStatus_Mask_Type; + + if ( uFieldMask & osl_FileStatus_Mask_FileURL ) + { + rtl_uString *ustrSystemPath = NULL; + + rtl_uString_newFromStr( &ustrSystemPath, reinterpret_cast<const sal_Unicode*>(pItemImpl->cDriveString) ); + osl_getFileURLFromSystemPath( ustrSystemPath, &pStatus->ustrFileURL ); + rtl_uString_release( ustrSystemPath ); + pStatus->uValidFields |= osl_FileStatus_Mask_FileURL; + } + return osl_File_E_None; +} + +//##################################################### +static oslFileError SAL_CALL osl_getServerInfo( + oslDirectoryItem Item, oslFileStatus *pStatus, sal_uInt32 uFieldMask ) +{ + DirectoryItem_Impl *pItemImpl = (DirectoryItem_Impl *)Item; + if ( !pItemImpl ) + return osl_File_E_INVAL; + + pStatus->uValidFields = 0; + + // pStatus->uValidFields |= osl_FileStatus_Mask_FileName; + + // if ( _tcscmp( pItemImpl->FindData.cFileName, TEXT(".") ) == 0 ) + // rtl_uString_newFromAscii( &pStatus->ustrFileName, "/" ); + // else + // rtl_uString_newFromStr( &pStatus->ustrFileName, pItemImpl->FindData.cFileName ); + + pStatus->eType = osl_File_Type_Directory; + pStatus->uValidFields |= osl_FileStatus_Mask_Type; + + if ( uFieldMask & osl_FileStatus_Mask_FileURL ) + { + rtl_uString *ustrSystemPath = NULL; + + rtl_uString_newFromStr( &ustrSystemPath, reinterpret_cast<const sal_Unicode*>(pItemImpl->szFullPath) ); + osl_getFileURLFromSystemPath( ustrSystemPath, &pStatus->ustrFileURL ); + rtl_uString_release( ustrSystemPath ); + pStatus->uValidFields |= osl_FileStatus_Mask_FileURL; + } + return osl_File_E_None; +} + +//############################################# +oslFileError SAL_CALL osl_getFileStatus( + oslDirectoryItem Item, + oslFileStatus *pStatus, + sal_uInt32 uFieldMask ) +{ + DirectoryItem_Impl *pItemImpl = (DirectoryItem_Impl *)Item; + + if ( !pItemImpl ) + return osl_File_E_INVAL; + + switch ( pItemImpl->uType ) + { + case DIRECTORYITEM_DRIVE: + return osl_getDriveInfo( Item, pStatus, uFieldMask ); + case DIRECTORYITEM_SERVER: + return osl_getServerInfo( Item, pStatus, uFieldMask ); + default: + break; + } + + if ( uFieldMask & osl_FileStatus_Mask_Validate ) + { + HANDLE hFind = FindFirstFile( pItemImpl->szFullPath, &pItemImpl->FindData ); + + if ( hFind != INVALID_HANDLE_VALUE ) + FindClose( hFind ); + else + return oslTranslateFileError( GetLastError() ); + + uFieldMask &= ~ osl_FileStatus_Mask_Validate; + } + + /* If no fields to retrieve left ignore pStatus */ + if ( !uFieldMask ) + return osl_File_E_None; + + /* Otherwise, this must be a valid pointer */ + if ( !pStatus ) + return osl_File_E_INVAL; + + if ( pStatus->uStructSize != sizeof(oslFileStatus) ) + return osl_File_E_INVAL; + + pStatus->uValidFields = 0; + + /* File time stamps */ + + if ( (uFieldMask & osl_FileStatus_Mask_ModifyTime) && + FileTimeToTimeValue( &pItemImpl->FindData.ftLastWriteTime, &pStatus->aModifyTime ) ) + pStatus->uValidFields |= osl_FileStatus_Mask_ModifyTime; + + if ( (uFieldMask & osl_FileStatus_Mask_AccessTime) && + FileTimeToTimeValue( &pItemImpl->FindData.ftLastAccessTime, &pStatus->aAccessTime ) ) + pStatus->uValidFields |= osl_FileStatus_Mask_AccessTime; + + if ( (uFieldMask & osl_FileStatus_Mask_CreationTime) && + FileTimeToTimeValue( &pItemImpl->FindData.ftCreationTime, &pStatus->aCreationTime ) ) + pStatus->uValidFields |= osl_FileStatus_Mask_CreationTime; + + /* Most of the fields are already set, regardless of requiered fields */ + + rtl_uString_newFromStr( &pStatus->ustrFileName, reinterpret_cast<const sal_Unicode*>(pItemImpl->FindData.cFileName) ); + pStatus->uValidFields |= osl_FileStatus_Mask_FileName; + + if ((FILE_ATTRIBUTE_REPARSE_POINT & pItemImpl->FindData.dwFileAttributes) && + (IO_REPARSE_TAG_MOUNT_POINT == pItemImpl->FindData.dwReserved0)) + pStatus->eType = osl_File_Type_Volume; + else if (pItemImpl->FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + pStatus->eType = osl_File_Type_Directory; + else + pStatus->eType = osl_File_Type_Regular; + + pStatus->uValidFields |= osl_FileStatus_Mask_Type; + + pStatus->uAttributes = pItemImpl->FindData.dwFileAttributes; + pStatus->uValidFields |= osl_FileStatus_Mask_Attributes; + + pStatus->uFileSize = (sal_uInt64)pItemImpl->FindData.nFileSizeLow + ((sal_uInt64)pItemImpl->FindData.nFileSizeHigh << 32); + pStatus->uValidFields |= osl_FileStatus_Mask_FileSize; + + if ( uFieldMask & osl_FileStatus_Mask_LinkTargetURL ) + { + rtl_uString *ustrFullPath = NULL; + + rtl_uString_newFromStr( &ustrFullPath, reinterpret_cast<const sal_Unicode*>(pItemImpl->szFullPath) ); + osl_getFileURLFromSystemPath( ustrFullPath, &pStatus->ustrLinkTargetURL ); + rtl_uString_release( ustrFullPath ); + + pStatus->uValidFields |= osl_FileStatus_Mask_LinkTargetURL; + } + + if ( uFieldMask & osl_FileStatus_Mask_FileURL ) + { + rtl_uString *ustrFullPath = NULL; + + + if ( !pItemImpl->bFullPathNormalized ) + { + GetCaseCorrectPathName( pItemImpl->szFullPath, pItemImpl->szFullPath, sizeof(pItemImpl->szFullPath) ); + pItemImpl->bFullPathNormalized = TRUE; + } + rtl_uString_newFromStr( &ustrFullPath, reinterpret_cast<const sal_Unicode*>(pItemImpl->szFullPath) ); + osl_getFileURLFromSystemPath( ustrFullPath, &pStatus->ustrFileURL ); + rtl_uString_release( ustrFullPath ); + pStatus->uValidFields |= osl_FileStatus_Mask_FileURL; + } + + return osl_File_E_None; +} + +//##################################################### +// file attributes handling functions +//##################################################### + +//############################################# +oslFileError SAL_CALL osl_setFileAttributes( + rtl_uString *ustrFileURL, + sal_uInt64 uAttributes ) +{ + oslFileError error; + rtl_uString *ustrSysPath = NULL; + DWORD dwFileAttributes; + BOOL fSuccess; + + // Converts the normalized path into a systempath + error = _osl_getSystemPathFromFileURL( ustrFileURL, &ustrSysPath, sal_False ); + + if ( osl_File_E_None != error ) + return error; + + dwFileAttributes = GetFileAttributes( reinterpret_cast<LPCTSTR>(rtl_uString_getStr(ustrSysPath)) ); + + if ( (DWORD)-1 != dwFileAttributes ) + { + dwFileAttributes &= ~(FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN); + + if ( uAttributes & osl_File_Attribute_ReadOnly ) + dwFileAttributes |= FILE_ATTRIBUTE_READONLY; + + if ( uAttributes & osl_File_Attribute_Hidden ) + dwFileAttributes |= FILE_ATTRIBUTE_HIDDEN; + + fSuccess = SetFileAttributes( reinterpret_cast<LPCTSTR>(rtl_uString_getStr(ustrSysPath)), dwFileAttributes ); + } + else + fSuccess = FALSE; + + if ( !fSuccess ) + error = oslTranslateFileError( GetLastError() ); + + rtl_uString_release( ustrSysPath ); + + return error; +} + +//##################################################### +oslFileError SAL_CALL osl_setFileTime( + rtl_uString *filePath, + const TimeValue *aCreationTime, + const TimeValue *aLastAccessTime, + const TimeValue *aLastWriteTime) +{ + oslFileError error; + rtl_uString *sysPath=NULL; + FILETIME *lpCreationTime=NULL; + FILETIME *lpLastAccessTime=NULL; + FILETIME *lpLastWriteTime=NULL; + FILETIME ftCreationTime; + FILETIME ftLastAccessTime; + FILETIME ftLastWriteTime; + HANDLE hFile; + BOOL fSuccess; + + + error=_osl_getSystemPathFromFileURL(filePath, &sysPath, sal_False); + + if (error==osl_File_E_INVAL) + return error; + + hFile=CreateFileW(reinterpret_cast<LPCWSTR>(rtl_uString_getStr(sysPath)), GENERIC_WRITE, 0, NULL , OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + rtl_uString_release(sysPath); + + if (hFile==INVALID_HANDLE_VALUE) + return osl_File_E_NOENT; + + if (TimeValueToFileTime(aCreationTime, &ftCreationTime)) + lpCreationTime=&ftCreationTime; + + if (TimeValueToFileTime(aLastAccessTime, &ftLastAccessTime)) + lpLastAccessTime=&ftLastAccessTime; + + if (TimeValueToFileTime(aLastWriteTime, &ftLastWriteTime)) + lpLastWriteTime=&ftLastWriteTime; + + fSuccess=SetFileTime(hFile, lpCreationTime, lpLastAccessTime, lpLastWriteTime); + + CloseHandle(hFile); + + if (!fSuccess) + return osl_File_E_INVAL; + else + return osl_File_E_None; +} diff --git a/sal/osl/w32/file_error.c b/sal/osl/w32/file_error.c new file mode 100644 index 000000000000..3942420eb8da --- /dev/null +++ b/sal/osl/w32/file_error.c @@ -0,0 +1,154 @@ +/************************************************************************* + * + * 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: file_error.c,v $ + * $Revision: 1.0 $ + * + * 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. + * + ************************************************************************/ + +#define UNICODE +#define _UNICODE +#define _WIN32_WINNT_0x0500 +#include "systools/win32/uwinapi.h" + +#include "file_error.h" + +#include "osl/diagnose.h" +#include "osl/thread.h" + +/* OS error to oslFileError values mapping table */ +struct osl_file_error_entry +{ + unsigned long oscode; /* OS return value */ + int errnocode; /* oslFileError code */ +}; + +static const struct osl_file_error_entry errtable[] = { + { ERROR_SUCCESS, osl_File_E_None }, /* 0 */ + { ERROR_INVALID_FUNCTION, osl_File_E_INVAL }, /* 1 */ + { ERROR_FILE_NOT_FOUND, osl_File_E_NOENT }, /* 2 */ + { ERROR_PATH_NOT_FOUND, osl_File_E_NOENT }, /* 3 */ + { ERROR_TOO_MANY_OPEN_FILES, osl_File_E_MFILE }, /* 4 */ + { ERROR_ACCESS_DENIED, osl_File_E_ACCES }, /* 5 */ + { ERROR_INVALID_HANDLE, osl_File_E_BADF }, /* 6 */ + { ERROR_ARENA_TRASHED, osl_File_E_NOMEM }, /* 7 */ + { ERROR_NOT_ENOUGH_MEMORY, osl_File_E_NOMEM }, /* 8 */ + { ERROR_INVALID_BLOCK, osl_File_E_NOMEM }, /* 9 */ + { ERROR_BAD_ENVIRONMENT, osl_File_E_2BIG }, /* 10 */ + { ERROR_BAD_FORMAT, osl_File_E_NOEXEC }, /* 11 */ + { ERROR_INVALID_ACCESS, osl_File_E_INVAL }, /* 12 */ + { ERROR_INVALID_DATA, osl_File_E_INVAL }, /* 13 */ + { ERROR_INVALID_DRIVE, osl_File_E_NOENT }, /* 15 */ + { ERROR_CURRENT_DIRECTORY, osl_File_E_ACCES }, /* 16 */ + { ERROR_NOT_SAME_DEVICE, osl_File_E_XDEV }, /* 17 */ + { ERROR_NO_MORE_FILES, osl_File_E_NOENT }, /* 18 */ + { ERROR_NOT_READY, osl_File_E_NOTREADY }, /* 21 */ + { ERROR_LOCK_VIOLATION, osl_File_E_ACCES }, /* 33 */ + { ERROR_BAD_NETPATH, osl_File_E_NOENT }, /* 53 */ + { ERROR_NETWORK_ACCESS_DENIED, osl_File_E_ACCES }, /* 65 */ + { ERROR_BAD_NET_NAME, osl_File_E_NOENT }, /* 67 */ + { ERROR_FILE_EXISTS, osl_File_E_EXIST }, /* 80 */ + { ERROR_CANNOT_MAKE, osl_File_E_ACCES }, /* 82 */ + { ERROR_FAIL_I24, osl_File_E_ACCES }, /* 83 */ + { ERROR_INVALID_PARAMETER, osl_File_E_INVAL }, /* 87 */ + { ERROR_NO_PROC_SLOTS, osl_File_E_AGAIN }, /* 89 */ + { ERROR_DRIVE_LOCKED, osl_File_E_ACCES }, /* 108 */ + { ERROR_BROKEN_PIPE, osl_File_E_PIPE }, /* 109 */ + { ERROR_DISK_FULL, osl_File_E_NOSPC }, /* 112 */ + { ERROR_INVALID_TARGET_HANDLE, osl_File_E_BADF }, /* 114 */ + { ERROR_INVALID_HANDLE, osl_File_E_INVAL }, /* 124 */ + { ERROR_WAIT_NO_CHILDREN, osl_File_E_CHILD }, /* 128 */ + { ERROR_CHILD_NOT_COMPLETE, osl_File_E_CHILD }, /* 129 */ + { ERROR_DIRECT_ACCESS_HANDLE, osl_File_E_BADF }, /* 130 */ + { ERROR_NEGATIVE_SEEK, osl_File_E_INVAL }, /* 131 */ + { ERROR_SEEK_ON_DEVICE, osl_File_E_ACCES }, /* 132 */ + { ERROR_DIR_NOT_EMPTY, osl_File_E_NOTEMPTY }, /* 145 */ + { ERROR_NOT_LOCKED, osl_File_E_ACCES }, /* 158 */ + { ERROR_BAD_PATHNAME, osl_File_E_NOENT }, /* 161 */ + { ERROR_MAX_THRDS_REACHED, osl_File_E_AGAIN }, /* 164 */ + { ERROR_LOCK_FAILED, osl_File_E_ACCES }, /* 167 */ + { ERROR_ALREADY_EXISTS, osl_File_E_EXIST }, /* 183 */ + { ERROR_FILENAME_EXCED_RANGE, osl_File_E_NOENT }, /* 206 */ + { ERROR_NESTING_NOT_ALLOWED, osl_File_E_AGAIN }, /* 215 */ + { ERROR_DIRECTORY, osl_File_E_NOENT }, /* 267 */ + { ERROR_NOT_ENOUGH_QUOTA, osl_File_E_NOMEM }, /* 1816 */ + { ERROR_UNEXP_NET_ERR, osl_File_E_NETWORK } /* 59 */ +}; + +/* The following two constants must be the minimum and maximum + values in the (contiguous) range of osl_File_E_xec Failure errors. +*/ +#define MIN_EXEC_ERROR ERROR_INVALID_STARTING_CODESEG +#define MAX_EXEC_ERROR ERROR_INFLOOP_IN_RELOC_CHAIN + +/* These are the low and high value in the range of errors that are + access violations +*/ +#define MIN_EACCES_RANGE ERROR_WRITE_PROTECT +#define MAX_EACCES_RANGE ERROR_SHARING_BUFFER_EXCEEDED + +oslFileError oslTranslateFileError (/*DWORD*/ unsigned long dwError) +{ + static const int n = sizeof(errtable)/sizeof(errtable[0]); + + int i; + for (i = 0; i < n; ++i ) + { + if (dwError == errtable[i].oscode) + return (oslFileError)(errtable[i].errnocode); + } + + /* The error code wasn't in the table. We check for a range of + osl_File_E_ACCES errors or exec failure errors (ENOEXEC). + Otherwise osl_File_E_INVAL is returned. + */ + if ( (dwError >= MIN_EACCES_RANGE) && (dwError <= MAX_EACCES_RANGE) ) + return osl_File_E_ACCES; + else if ( (dwError >= MIN_EXEC_ERROR) && (dwError <= MAX_EXEC_ERROR) ) + return osl_File_E_NOEXEC; + else + return osl_File_E_INVAL; +} + +//##################################################### +#if OSL_DEBUG_LEVEL > 0 +void _osl_warnFile( const char *message, rtl_uString *ustrFile ) +{ + char szBuffer[2048]; + + if (ustrFile) + { + rtl_String *strFile = NULL; + + rtl_uString2String( &strFile, rtl_uString_getStr( ustrFile ), rtl_uString_getLength( ustrFile ), + osl_getThreadTextEncoding(), OUSTRING_TO_OSTRING_CVTFLAGS ); + snprintf( szBuffer, sizeof(szBuffer), message, strFile->buffer ); + rtl_string_release( strFile ); + + message = szBuffer; + } + OSL_ENSURE( 0, message ); +} +#endif /* OSL_DEBUG_LEVEL */ diff --git a/sal/osl/w32/file_error.h b/sal/osl/w32/file_error.h new file mode 100644 index 000000000000..caebbdb1c560 --- /dev/null +++ b/sal/osl/w32/file_error.h @@ -0,0 +1,54 @@ +/************************************************************************* + * + * 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: file_error.h,v $ + * $Revision: 1.0 $ + * + * 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. + * + ************************************************************************/ + +#ifndef INCLUDED_OSL_FILE_ERROR_H +#define INCLUDED_OSL_FILE_ERROR_H + +#include "osl/file.h" +#include "rtl/ustring.h" + +#ifdef __cplusplus +extern "C" { +#endif + +oslFileError oslTranslateFileError (/*DWORD*/ unsigned long dwError); + +#if OSL_DEBUG_LEVEL > 0 +void _osl_warnFile (const char * message, rtl_uString * ustrFile); +#define OSL_ENSURE_FILE( cond, msg, file ) ( (cond) ? (void)0 : _osl_warnFile( msg, file ) ) +#else +#define OSL_ENSURE_FILE( cond, msg, file ) ((void)0) +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* INCLUDED_OSL_FILE_ERROR_H */ diff --git a/sal/osl/w32/file_url.cxx b/sal/osl/w32/file_url.cxx new file mode 100644 index 000000000000..968c4bccc95e --- /dev/null +++ b/sal/osl/w32/file_url.cxx @@ -0,0 +1,1013 @@ +/************************************************************************* + * + * 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: file_url.cxx,v $ + * $Revision: 1.0 $ + * + * 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. + * + ************************************************************************/ + +#define UNICODE +#define _UNICODE +#define _WIN32_WINNT_0x0500 +#include "systools/win32/uwinapi.h" + +#include "file_url.h" +#include "file_error.h" + +#include "rtl/alloc.h" +#include "osl/diagnose.h" +#include "osl/file.h" +#include "osl/mutex.h" + +#include <stdio.h> +#include <tchar.h> + +#if OSL_DEBUG_LEVEL > 0 +#define OSL_ENSURE_FILE( cond, msg, file ) ( (cond) ? (void)0 : _osl_warnFile( msg, file ) ) +#else +#define OSL_ENSURE_FILE( cond, msg, file ) ((void)0) +#endif + +#define ELEMENTS_OF_ARRAY(arr) (sizeof(arr)/(sizeof((arr)[0]))) + +//################################################################## +// FileURL functions +//################################################################## + +extern "C" oslMutex g_CurrentDirectoryMutex; /* Initialized in dllentry.c */ +oslMutex g_CurrentDirectoryMutex = 0; + +//##################################################### +static BOOL IsValidFilePathComponent( + LPCTSTR lpComponent, LPCTSTR *lppComponentEnd, DWORD dwFlags) +{ + LPCTSTR lpComponentEnd = NULL; + LPCTSTR lpCurrent = lpComponent; + BOOL fValid = TRUE; /* Assume success */ + TCHAR cLast = 0; + + /* Path component length must not exceed MAX_PATH */ + + while ( !lpComponentEnd && lpCurrent && lpCurrent - lpComponent < MAX_PATH ) + { + switch ( *lpCurrent ) + { + /* Both backslash and slash determine the end of a path component */ + case '\0': + case '/': + case '\\': + switch ( cLast ) + { + /* Component must not end with '.' or blank and can't be empty */ + + case '.': + if ( dwFlags & VALIDATEPATH_ALLOW_ELLIPSE ) + { + if ( 1 == lpCurrent - lpComponent ) + { + /* Current directory is O.K. */ + lpComponentEnd = lpCurrent; + break; + } + else if ( 2 == lpCurrent - lpComponent && '.' == *lpComponent ) + { + /* Parent directory is O.K. */ + lpComponentEnd = lpCurrent; + break; + } + } + case 0: + case ' ': + lpComponentEnd = lpCurrent - 1; + fValid = FALSE; + break; + default: + lpComponentEnd = lpCurrent; + break; + } + break; + /* '?' and '*' are valid wildcards but not valid file name characters */ + case '?': + case '*': + if ( dwFlags & VALIDATEPATH_ALLOW_WILDCARDS ) + break; + /* The following characters are reserved */ + case '<': + case '>': + case '\"': + case '|': + case ':': + lpComponentEnd = lpCurrent; + fValid = FALSE; + break; + default: + /* Characters below ASCII 32 are not allowed */ + if ( *lpCurrent < ' ' ) + { + lpComponentEnd = lpCurrent; + fValid = FALSE; + } + break; + } + cLast = *lpCurrent++; + } + + /* If we don't reached the end of the component the length of the component was to long + ( See condition of while loop ) */ + if ( !lpComponentEnd ) + { + fValid = FALSE; + lpComponentEnd = lpCurrent; + } + + /* Test wether the component specifies a device name what is not allowed */ + + // MT: PERFORMANCE: + // This is very expensive. A lot of calls to _tcsicmp. + // in SRC6870m71 67.000 calls of this method while empty office start result into more than 1.500.00 calls of _tcsicmp! + // Possible optimizations + // - Array should be const static + // - Sorted array, use binary search + // - More intelligent check for com1-9, lpt1-9 + // Maybe make szComponent upper case, don't search case intensitive + // Talked to HRO: Could be removed. Shouldn't be used in OOo, and if used for something like a filename, it will lead to an error anyway. + /* + if ( fValid ) + { + LPCTSTR alpDeviceNames[] = + { + TEXT("CON"), + TEXT("PRN"), + TEXT("AUX"), + TEXT("CLOCK$"), + TEXT("NUL"), + TEXT("LPT1"), + TEXT("LPT2"), + TEXT("LPT3"), + TEXT("LPT4"), + TEXT("LPT5"), + TEXT("LPT6"), + TEXT("LPT7"), + TEXT("LPT8"), + TEXT("LPT9"), + TEXT("COM1"), + TEXT("COM2"), + TEXT("COM3"), + TEXT("COM4"), + TEXT("COM5"), + TEXT("COM6"), + TEXT("COM7"), + TEXT("COM8"), + TEXT("COM9") + }; + + TCHAR szComponent[MAX_PATH]; + int nComponentLength; + LPCTSTR lpDot; + int i; + + // A device name with an extension is also invalid + lpDot = _tcschr( lpComponent, '.' ); + + if ( !lpDot || lpDot > lpComponentEnd ) + nComponentLength = lpComponentEnd - lpComponent; + else + nComponentLength = lpDot - lpComponent; + + _tcsncpy( szComponent, lpComponent, nComponentLength ); + szComponent[nComponentLength] = 0; + + for ( i = 0; i < sizeof( alpDeviceNames ) / sizeof(LPCTSTR); i++ ) + { + if ( 0 == _tcsicmp( szComponent, alpDeviceNames[i] ) ) + { + lpComponentEnd = lpComponent; + fValid = FALSE; + break; + } + } + } + */ + + if ( fValid ) + { + // Empty components are not allowed + if ( lpComponentEnd - lpComponent < 1 ) + fValid = FALSE; + + // If we reached the end of the string NULL is returned + else if ( !*lpComponentEnd ) + lpComponentEnd = NULL; + + } + + if ( lppComponentEnd ) + *lppComponentEnd = lpComponentEnd; + + return fValid; +} + +//##################################################### +#define CHARSET_SEPARATOR TEXT("\\/") + +DWORD IsValidFilePath(rtl_uString *path, LPCTSTR *lppError, DWORD dwFlags, rtl_uString **corrected) +{ + LPCTSTR lpszPath = reinterpret_cast< LPCTSTR >(path->buffer); + LPCTSTR lpComponent; + BOOL fValid = TRUE; + DWORD dwPathType = PATHTYPE_ERROR; + + if ( dwFlags & VALIDATEPATH_ALLOW_RELATIVE ) + dwFlags |= VALIDATEPATH_ALLOW_ELLIPSE; + + if ( !lpszPath ) + { + fValid = FALSE; + lpComponent = lpszPath; + } + + /* Test for UNC path notation */ + if ( 2 == _tcsspn( lpszPath, CHARSET_SEPARATOR ) ) + { + /* Place the pointer behind the leading to backslashes */ + + lpComponent = lpszPath + 2; + + fValid = IsValidFilePathComponent( lpComponent, &lpComponent, VALIDATEPATH_ALLOW_ELLIPSE ); + + /* So far we have a valid servername. Now let's see if we also have a network resource */ + + dwPathType = PATHTYPE_ABSOLUTE_UNC; + + if ( fValid ) + { + if ( lpComponent && !*++lpComponent ) + lpComponent = NULL; + + if ( !lpComponent ) + { + #if 0 + /* We only have a Server specification what is invalid */ + + lpComponent = lpszPath; + fValid = FALSE; + #else + dwPathType |= PATHTYPE_IS_SERVER; + #endif + } + else + { + /* Now test the network resource */ + + fValid = IsValidFilePathComponent( lpComponent, &lpComponent, 0 ); + + /* If we now reached the end of the path, everything is O.K. */ + + + if ( fValid && (!lpComponent || lpComponent && !*++lpComponent ) ) + { + lpComponent = NULL; + dwPathType |= PATHTYPE_IS_VOLUME; + } + } + } + } + + /* Local path verification. Must start with <drive>: */ + else if ( _istalpha( lpszPath[0] ) && ':' == lpszPath[1] ) + { + /* Place pointer behind correct drive specification */ + + lpComponent = lpszPath + 2; + + if ( 1 == _tcsspn( lpComponent, CHARSET_SEPARATOR ) ) + lpComponent++; + else if ( *lpComponent ) + fValid = FALSE; + + dwPathType = PATHTYPE_ABSOLUTE_LOCAL; + + /* Now we are behind the backslash or it was a simple drive without backslash */ + + if ( fValid && !*lpComponent ) + { + lpComponent = NULL; + dwPathType |= PATHTYPE_IS_VOLUME; + } + } + + /* Can be a relative path */ + else if ( dwFlags & VALIDATEPATH_ALLOW_RELATIVE ) + { + lpComponent = lpszPath; + + /* Relative path can start with a backslash */ + + if ( 1 == _tcsspn( lpComponent, CHARSET_SEPARATOR ) ) + { + lpComponent++; + if ( !*lpComponent ) + lpComponent = NULL; + } + + dwPathType = PATHTYPE_RELATIVE; + } + + /* Anything else is an error */ + else + { + fValid = FALSE; + lpComponent = lpszPath; + } + + /* Now validate each component of the path */ + while ( fValid && lpComponent ) + { + // Correct path by merging consecutive slashes: + if (*lpComponent == '\\' && corrected != NULL) { + sal_Int32 i = lpComponent - lpszPath; + rtl_uString_newReplaceStrAt(corrected, path, i, 1, NULL); + //TODO: handle out-of-memory + lpszPath = reinterpret_cast< LPCTSTR >((*corrected)->buffer); + lpComponent = lpszPath + i; + } + + fValid = IsValidFilePathComponent( lpComponent, &lpComponent, dwFlags ); + + if ( fValid && lpComponent ) + { + lpComponent++; + + /* If the string behind the backslash is empty, we've done */ + + if ( !*lpComponent ) + lpComponent = NULL; + } + } + + if ( fValid && _tcslen( lpszPath ) >= MAX_PATH ) + { + fValid = FALSE; + lpComponent = lpszPath + MAX_PATH; + } + + if ( lppError ) + *lppError = lpComponent; + + return fValid ? dwPathType : PATHTYPE_ERROR; +} + +//############################################# +//##################################################### +//Undocumented in SHELL32.DLL ordinal 35 +static BOOL PathRemoveFileSpec(LPTSTR lpPath) +{ + BOOL fSuccess = FALSE; // Assume failure + LPTSTR lpLastBkSlash = _tcsrchr( lpPath, '\\' ); + LPTSTR lpLastSlash = _tcsrchr( lpPath, '/' ); + LPTSTR lpLastDelimiter = lpLastSlash > lpLastBkSlash ? lpLastSlash : lpLastBkSlash; + + if ( lpLastDelimiter ) + { + if ( 0 == *(lpLastDelimiter + 1) ) + { + if ( lpLastDelimiter > lpPath && *(lpLastDelimiter - 1) != ':' ) + { + *lpLastDelimiter = 0; + fSuccess = TRUE; + } + } + else + { + *(++lpLastDelimiter) = 0; + fSuccess = TRUE; + } + } + return fSuccess; +} + +//##################################################### +// Undocumented in SHELL32.DLL ordinal 32 +static LPTSTR PathAddBackslash(LPTSTR lpPath) +{ + LPTSTR lpEndPath = NULL; + + if ( lpPath ) + { + int nLen = _tcslen(lpPath); + + if ( !nLen || lpPath[nLen-1] != '\\' && lpPath[nLen-1] != '/' && nLen < MAX_PATH - 1 ) + { + lpEndPath = lpPath + nLen; + *lpEndPath++ = '\\'; + *lpEndPath = 0; + } + } + return lpEndPath; +} + +//##################################################### +// Same as GetLongPathName but also 95/NT4 +static DWORD GetCaseCorrectPathNameEx( + LPCTSTR lpszShortPath, // file name + LPTSTR lpszLongPath, // path buffer + DWORD cchBuffer, // size of path buffer + DWORD nSkipLevels +) +{ + TCHAR szPath[MAX_PATH]; + BOOL fSuccess; + + cchBuffer = cchBuffer; /* avoid warnings */ + + _tcscpy( szPath, lpszShortPath ); + + fSuccess = PathRemoveFileSpec( szPath ); + + if ( fSuccess ) + { + int nLen = _tcslen( szPath ); + LPCTSTR lpszFileSpec = lpszShortPath + nLen; + BOOL bSkipThis; + + if ( 0 == _tcscmp( lpszFileSpec, TEXT("..") ) ) + { + bSkipThis = TRUE; + nSkipLevels += 1; + } + else if ( + 0 == _tcscmp( lpszFileSpec, TEXT(".") ) || + 0 == _tcscmp( lpszFileSpec, TEXT("\\") ) || + 0 == _tcscmp( lpszFileSpec, TEXT("/") ) + ) + { + bSkipThis = TRUE; + } + else if ( nSkipLevels ) + { + bSkipThis = TRUE; + nSkipLevels--; + } + else + bSkipThis = FALSE; + + GetCaseCorrectPathNameEx( szPath, szPath, MAX_PATH, nSkipLevels ); + + PathAddBackslash( szPath ); + + /* Analyze parent if not only a trailing backslash was cutted but a real file spec */ + if ( !bSkipThis ) + { + WIN32_FIND_DATA aFindFileData; + HANDLE hFind = FindFirstFile( lpszShortPath, &aFindFileData ); + + if ( IsValidHandle(hFind) ) + { + _tcscat( szPath, aFindFileData.cFileName[0] ? aFindFileData.cFileName : aFindFileData.cAlternateFileName ); + + FindClose( hFind ); + } + else + return 0; + } + } + else + { + /* File specification can't be removed therefore the short path is either a drive + or a network share. If still levels to skip are left, the path specification + tries to travel below the file system root */ + if ( nSkipLevels ) + return 0; + + _tcsupr( szPath ); + } + + _tcscpy( lpszLongPath, szPath ); + + return _tcslen( lpszLongPath ); +} + +//##################################################### +#define WSTR_SYSTEM_ROOT_PATH L"\\\\.\\" + +DWORD GetCaseCorrectPathName( + LPCTSTR lpszShortPath, // file name + LPTSTR lpszLongPath, // path buffer + DWORD cchBuffer // size of path buffer +) +{ + /* Special handling for "\\.\" as system root */ + if ( lpszShortPath && 0 == wcscmp( lpszShortPath, WSTR_SYSTEM_ROOT_PATH ) ) + { + if ( cchBuffer >= ELEMENTS_OF_ARRAY(WSTR_SYSTEM_ROOT_PATH) ) + { + wcscpy( lpszLongPath, WSTR_SYSTEM_ROOT_PATH ); + return ELEMENTS_OF_ARRAY(WSTR_SYSTEM_ROOT_PATH) - 1; + } + else + { + return ELEMENTS_OF_ARRAY(WSTR_SYSTEM_ROOT_PATH) - 1; + } + } + else + { + return GetCaseCorrectPathNameEx( lpszShortPath, lpszLongPath, cchBuffer, 0 ); + } +} + +//############################################# +static sal_Bool _osl_decodeURL( rtl_String* strUTF8, rtl_uString** pstrDecodedURL ) +{ + sal_Char *pBuffer; + const sal_Char *pSrcEnd; + const sal_Char *pSrc; + sal_Char *pDest; + sal_Int32 nSrcLen; + sal_Bool bValidEncoded = sal_True; /* Assume success */ + + /* The resulting decoded string length is shorter or equal to the source length */ + + nSrcLen = rtl_string_getLength(strUTF8); + pBuffer = reinterpret_cast<sal_Char*>(rtl_allocateMemory(nSrcLen + 1)); + + pDest = pBuffer; + pSrc = rtl_string_getStr(strUTF8); + pSrcEnd = pSrc + nSrcLen; + + /* Now decode the URL what should result in an UTF8 string */ + while ( bValidEncoded && pSrc < pSrcEnd ) + { + switch ( *pSrc ) + { + case '%': + { + sal_Char aToken[3]; + sal_Char aChar; + + pSrc++; + aToken[0] = *pSrc++; + aToken[1] = *pSrc++; + aToken[2] = 0; + + aChar = (sal_Char)strtoul( aToken, NULL, 16 ); + + /* The chars are path delimiters and must not be encoded */ + + if ( 0 == aChar || '\\' == aChar || '/' == aChar || ':' == aChar ) + bValidEncoded = sal_False; + else + *pDest++ = aChar; + } + break; + default: + *pDest++ = *pSrc++; + break; + } + } + + *pDest++ = 0; + + if ( bValidEncoded ) + { + rtl_string2UString( pstrDecodedURL, pBuffer, rtl_str_getLength(pBuffer), RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS ); + OSL_ASSERT(*pstrDecodedURL != 0); + } + + rtl_freeMemory( pBuffer ); + + return bValidEncoded; +} + +//############################################# +static void _osl_encodeURL( rtl_uString *strURL, rtl_String **pstrEncodedURL ) +{ + /* Encode non ascii characters within the URL */ + + rtl_String *strUTF8 = NULL; + sal_Char *pszEncodedURL; + const sal_Char *pURLScan; + sal_Char *pURLDest; + sal_Int32 nURLScanLen; + sal_Int32 nURLScanCount; + + rtl_uString2String( &strUTF8, rtl_uString_getStr( strURL ), rtl_uString_getLength( strURL ), RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS ); + + pszEncodedURL = (sal_Char*) rtl_allocateMemory( (rtl_string_getLength( strUTF8 ) * 3 + 1) * sizeof(sal_Char) ); + + pURLDest = pszEncodedURL; + pURLScan = rtl_string_getStr( strUTF8 ); + nURLScanLen = rtl_string_getLength( strUTF8 ); + nURLScanCount = 0; + + while ( nURLScanCount < nURLScanLen ) + { + sal_Char cCurrent = *pURLScan; + switch ( cCurrent ) + { + default: + if (!( ( cCurrent >= 'a' && cCurrent <= 'z' ) || ( cCurrent >= 'A' && cCurrent <= 'Z' ) || ( cCurrent >= '0' && cCurrent <= '9' ) ) ) + { + sprintf( pURLDest, "%%%02X", (unsigned char)cCurrent ); + pURLDest += 3; + break; + } + case '!': + case '\'': + case '(': + case ')': + case '*': + case '-': + case '.': + case '_': + case '~': + case '$': + case '&': + case '+': + case ',': + case '=': + case '@': + case ':': + case '/': + case '\\': + case '|': + *pURLDest++ = cCurrent; + break; + case 0: + break; + } + + pURLScan++; + nURLScanCount++; + } + + *pURLDest = 0; + + rtl_string_release( strUTF8 ); + rtl_string_newFromStr( pstrEncodedURL, pszEncodedURL ); + rtl_freeMemory( pszEncodedURL ); +} + +//############################################# +#define WSTR_SYSTEM_ROOT_PATH L"\\\\.\\" + +oslFileError _osl_getSystemPathFromFileURL( rtl_uString *strURL, rtl_uString **pustrPath, sal_Bool bAllowRelative ) +{ + rtl_String *strUTF8 = NULL; + rtl_uString *strDecodedURL = NULL; + rtl_uString *strTempPath = NULL; + const sal_Unicode *pDecodedURL; + sal_uInt32 nDecodedLen; + sal_Bool bValidEncoded; + oslFileError nError = osl_File_E_INVAL; /* Assume failure */ + + /* If someone hasn't encoded the complete URL we convert it to UTF8 now to prevent from + having a mixed encoded URL later */ + + rtl_uString2String( &strUTF8, rtl_uString_getStr( strURL ), rtl_uString_getLength( strURL ), RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS ); + + /* If the length of strUTF8 and strURL differs it indicates that the URL was not correct encoded */ + + OSL_ENSURE_FILE( + strUTF8->length == strURL->length || + 0 != rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( strURL->buffer, strURL->length, "file:\\\\", 7 ) + ,"osl_getSystemPathFromFileURL: \"%s\" is not encoded !!!", strURL ); + + bValidEncoded = _osl_decodeURL( strUTF8, &strDecodedURL ); + + /* Release the encoded UTF8 string */ + rtl_string_release( strUTF8 ); + + if ( bValidEncoded ) + { + /* Replace backslashes and pipes */ + + rtl_uString_newReplace( &strDecodedURL, strDecodedURL, '/', '\\' ); + rtl_uString_newReplace( &strDecodedURL, strDecodedURL, '|', ':' ); + + pDecodedURL = rtl_uString_getStr( strDecodedURL ); + nDecodedLen = rtl_uString_getLength( strDecodedURL ); + + /* Must start with "file://" */ + if ( 0 == rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pDecodedURL, nDecodedLen, "file:\\\\", 7 ) ) + { + sal_uInt32 nSkip; + + if ( 0 == rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pDecodedURL, nDecodedLen, "file:\\\\\\", 8 ) ) + nSkip = 8; + else if ( + 0 == rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pDecodedURL, nDecodedLen, "file:\\\\localhost\\", 17 ) || + 0 == rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pDecodedURL, nDecodedLen, "file:\\\\127.0.0.1\\", 17 ) + ) + nSkip = 17; + else + nSkip = 5; + + /* Indicates local root */ + if ( nDecodedLen == nSkip ) + rtl_uString_newFromStr_WithLength( &strTempPath, reinterpret_cast<const sal_Unicode*>(WSTR_SYSTEM_ROOT_PATH), ELEMENTS_OF_ARRAY(WSTR_SYSTEM_ROOT_PATH) - 1 ); + else + rtl_uString_newFromStr_WithLength( &strTempPath, pDecodedURL + nSkip, nDecodedLen - nSkip ); + + if ( IsValidFilePath( strTempPath, NULL, VALIDATEPATH_ALLOW_ELLIPSE, &strTempPath ) ) + nError = osl_File_E_None; + } + else if ( bAllowRelative ) /* This maybe a relative file URL */ + { + rtl_uString_assign( &strTempPath, strDecodedURL ); + + if ( IsValidFilePath( strTempPath, NULL, VALIDATEPATH_ALLOW_RELATIVE | VALIDATEPATH_ALLOW_ELLIPSE, &strTempPath ) ) + nError = osl_File_E_None; + } + /* + else + OSL_ENSURE_FILE( !nError, "osl_getSystemPathFromFileURL: \"%s\" is not an absolute FileURL !!!", strURL ); + */ + + } + + if ( strDecodedURL ) + rtl_uString_release( strDecodedURL ); + + if ( osl_File_E_None == nError ) + rtl_uString_assign( pustrPath, strTempPath ); + + if ( strTempPath ) + rtl_uString_release( strTempPath ); + + /* + OSL_ENSURE_FILE( !nError, "osl_getSystemPathFromFileURL: \"%s\" is not a FileURL !!!", strURL ); + */ + + return nError; +} + +//############################################# +oslFileError _osl_getFileURLFromSystemPath( rtl_uString* strPath, rtl_uString** pstrURL ) +{ + oslFileError nError = osl_File_E_INVAL; /* Assume failure */ + rtl_uString *strTempURL = NULL; + DWORD dwPathType = PATHTYPE_ERROR; + + if (strPath) + dwPathType = IsValidFilePath(strPath, NULL, VALIDATEPATH_ALLOW_RELATIVE, NULL); + + if (dwPathType) + { + rtl_uString *strTempPath = NULL; + + /* Replace backslashes */ + rtl_uString_newReplace( &strTempPath, strPath, '\\', '/' ); + + switch ( dwPathType & PATHTYPE_MASK_TYPE ) + { + case PATHTYPE_RELATIVE: + rtl_uString_assign( &strTempURL, strTempPath ); + nError = osl_File_E_None; + break; + case PATHTYPE_ABSOLUTE_UNC: + rtl_uString_newFromAscii( &strTempURL, "file:" ); + rtl_uString_newConcat( &strTempURL, strTempURL, strTempPath ); + nError = osl_File_E_None; + break; + case PATHTYPE_ABSOLUTE_LOCAL: + rtl_uString_newFromAscii( &strTempURL, "file:///" ); + rtl_uString_newConcat( &strTempURL, strTempURL, strTempPath ); + nError = osl_File_E_None; + break; + default: + break; + } + + /* Release temp path */ + rtl_uString_release( strTempPath ); + } + + if ( osl_File_E_None == nError ) + { + rtl_String *strEncodedURL = NULL; + + /* Encode the URL */ + _osl_encodeURL( strTempURL, &strEncodedURL ); + + /* Provide URL via unicode string */ + rtl_string2UString( pstrURL, rtl_string_getStr(strEncodedURL), rtl_string_getLength(strEncodedURL), RTL_TEXTENCODING_ASCII_US, OUSTRING_TO_OSTRING_CVTFLAGS ); + OSL_ASSERT(*pstrURL != 0); + rtl_string_release( strEncodedURL ); + } + + /* Release temp URL */ + if ( strTempURL ) + rtl_uString_release( strTempURL ); + + /* + OSL_ENSURE_FILE( !nError, "osl_getFileURLFromSystemPath: \"%s\" is not a systemPath !!!", strPath ); + */ + return nError; +} + +//##################################################### +oslFileError SAL_CALL osl_getFileURLFromSystemPath( + rtl_uString* ustrPath, rtl_uString** pustrURL ) +{ + return _osl_getFileURLFromSystemPath( ustrPath, pustrURL ); +} + +//##################################################### +oslFileError SAL_CALL osl_getSystemPathFromFileURL( + rtl_uString *ustrURL, rtl_uString **pustrPath) +{ + return _osl_getSystemPathFromFileURL( ustrURL, pustrPath, sal_True ); +} + +//##################################################### +oslFileError SAL_CALL osl_searchFileURL( + rtl_uString *ustrFileName, + rtl_uString *ustrSystemSearchPath, + rtl_uString **pustrPath) +{ + rtl_uString *ustrUNCPath = NULL; + rtl_uString *ustrSysPath = NULL; + oslFileError error; + + /* First try to interpret the file name as an URL even a relative one */ + error = _osl_getSystemPathFromFileURL( ustrFileName, &ustrUNCPath, sal_True ); + + /* So far we either have an UNC path or something invalid + Now create a system path */ + if ( osl_File_E_None == error ) + error = _osl_getSystemPathFromFileURL( ustrUNCPath, &ustrSysPath, sal_True ); + + if ( osl_File_E_None == error ) + { + DWORD nBufferLength; + DWORD dwResult; + LPTSTR lpBuffer = NULL; + LPTSTR lpszFilePart; + + /* Repeat calling SearchPath ... + Start with MAX_PATH for the buffer. In most cases this + will be enough and does not force the loop to runtwice */ + dwResult = MAX_PATH; + + do + { + /* If search path is empty use a NULL pointer instead according to MSDN documentation of SearchPath */ + LPCTSTR lpszSearchPath = ustrSystemSearchPath && ustrSystemSearchPath->length ? reinterpret_cast<LPCTSTR>(ustrSystemSearchPath->buffer) : NULL; + LPCTSTR lpszSearchFile = reinterpret_cast<LPCTSTR>(ustrSysPath->buffer); + + /* Allocate space for buffer according to previous returned count of required chars */ + /* +1 is not neccessary if we follow MSDN documentation but for robustness we do so */ + nBufferLength = dwResult + 1; + lpBuffer = lpBuffer ? + reinterpret_cast<LPTSTR>(rtl_reallocateMemory(lpBuffer, nBufferLength * sizeof(TCHAR))) : + reinterpret_cast<LPTSTR>(rtl_allocateMemory(nBufferLength * sizeof(TCHAR))); + + dwResult = SearchPath( lpszSearchPath, lpszSearchFile, NULL, nBufferLength, lpBuffer, &lpszFilePart ); + } while ( dwResult && dwResult >= nBufferLength ); + + /* ... until an error occures or buffer is large enough. + dwResult == nBufferLength can not happen according to documentation but lets be robust ;-) */ + + if ( dwResult ) + { + rtl_uString_newFromStr( &ustrSysPath, reinterpret_cast<const sal_Unicode*>(lpBuffer) ); + error = osl_getFileURLFromSystemPath( ustrSysPath, pustrPath ); + } + else + { + WIN32_FIND_DATA aFindFileData; + HANDLE hFind; + + /* Somthing went wrong, perhaps the path was absolute */ + error = oslTranslateFileError( GetLastError() ); + + hFind = FindFirstFile( reinterpret_cast<LPCTSTR>(ustrSysPath->buffer), &aFindFileData ); + + if ( IsValidHandle(hFind) ) + { + error = osl_getFileURLFromSystemPath( ustrSysPath, pustrPath ); + FindClose( hFind ); + } + } + + rtl_freeMemory( lpBuffer ); + } + + if ( ustrSysPath ) + rtl_uString_release( ustrSysPath ); + + if ( ustrUNCPath ) + rtl_uString_release( ustrUNCPath ); + + return error; +} + +//##################################################### + +oslFileError SAL_CALL osl_getAbsoluteFileURL( rtl_uString* ustrBaseURL, rtl_uString* ustrRelativeURL, rtl_uString** pustrAbsoluteURL ) +{ + oslFileError eError; + rtl_uString *ustrRelSysPath = NULL; + rtl_uString *ustrBaseSysPath = NULL; + + if ( ustrBaseURL && ustrBaseURL->length ) + { + eError = _osl_getSystemPathFromFileURL( ustrBaseURL, &ustrBaseSysPath, sal_False ); + OSL_ENSURE( osl_File_E_None == eError, "osl_getAbsoluteFileURL called with relative or invalid base URL" ); + + eError = _osl_getSystemPathFromFileURL( ustrRelativeURL, &ustrRelSysPath, sal_True ); + } + else + { + eError = _osl_getSystemPathFromFileURL( ustrRelativeURL, &ustrRelSysPath, sal_False ); + OSL_ENSURE( osl_File_E_None == eError, "osl_getAbsoluteFileURL called with empty base URL and/or invalid relative URL" ); + } + + if ( !eError ) + { + TCHAR szBuffer[MAX_PATH]; + TCHAR szCurrentDir[MAX_PATH]; + LPTSTR lpFilePart = NULL; + DWORD dwResult; + +/*@@@ToDo + Bad, bad hack, this only works if the base path + really exists which is not necessary according + to RFC2396 + The whole FileURL implementation should be merged + with the rtl/uri class. +*/ + if ( ustrBaseSysPath ) + { + osl_acquireMutex( g_CurrentDirectoryMutex ); + + GetCurrentDirectory( MAX_PATH, szCurrentDir ); + SetCurrentDirectory( reinterpret_cast<LPCTSTR>(ustrBaseSysPath->buffer) ); + } + + dwResult = GetFullPathName( reinterpret_cast<LPCTSTR>(ustrRelSysPath->buffer), MAX_PATH, szBuffer, &lpFilePart ); + + if ( ustrBaseSysPath ) + { + SetCurrentDirectory( szCurrentDir ); + + osl_releaseMutex( g_CurrentDirectoryMutex ); + } + + if ( dwResult ) + { + if ( dwResult >= MAX_PATH ) + eError = osl_File_E_INVAL; + else + { + rtl_uString *ustrAbsSysPath = NULL; + + rtl_uString_newFromStr( &ustrAbsSysPath, reinterpret_cast<const sal_Unicode*>(szBuffer) ); + + eError = osl_getFileURLFromSystemPath( ustrAbsSysPath, pustrAbsoluteURL ); + + if ( ustrAbsSysPath ) + rtl_uString_release( ustrAbsSysPath ); + } + } + else + eError = oslTranslateFileError( GetLastError() ); + } + + if ( ustrBaseSysPath ) + rtl_uString_release( ustrBaseSysPath ); + + if ( ustrRelSysPath ) + rtl_uString_release( ustrRelSysPath ); + + return eError; +} + +//##################################################### +oslFileError SAL_CALL osl_getCanonicalName( rtl_uString *strRequested, rtl_uString **strValid ) +{ + rtl_uString_newFromString(strValid, strRequested); + return osl_File_E_None; +} diff --git a/sal/osl/w32/file_url.h b/sal/osl/w32/file_url.h new file mode 100644 index 000000000000..af23203fa0a7 --- /dev/null +++ b/sal/osl/w32/file_url.h @@ -0,0 +1,95 @@ +/************************************************************************* + * + * 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: file_url.h,v $ + * $Revision: 1.0 $ + * + * 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. + * + ************************************************************************/ + +#ifndef INCLUDED_OSL_FILE_URL_H +#define INCLUDED_OSL_FILE_URL_H + +#include "sal/types.h" +#include "rtl/ustring.h" +#include "osl/file.h" + +#ifdef _MSC_VER +#pragma warning(push,1) +#endif + +#define WINDOWS_LEAN_AND_MEAN +#include <windows.h> + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define PATHTYPE_ERROR 0 +#define PATHTYPE_RELATIVE 1 +#define PATHTYPE_ABSOLUTE_UNC 2 +#define PATHTYPE_ABSOLUTE_LOCAL 3 +#define PATHTYPE_MASK_TYPE 0xFF +#define PATHTYPE_IS_VOLUME 0x0100 +#define PATHTYPE_IS_SERVER 0x0200 + +#define VALIDATEPATH_NORMAL 0x0000 +#define VALIDATEPATH_ALLOW_WILDCARDS 0x0001 +#define VALIDATEPATH_ALLOW_ELLIPSE 0x0002 +#define VALIDATEPATH_ALLOW_RELATIVE 0x0004 +#define VALIDATEPATH_ALLOW_UNC 0x0008 + +DWORD IsValidFilePath ( + rtl_uString * path, + LPCTSTR * lppError, + DWORD dwFlags, + rtl_uString ** corrected +); + +DWORD GetCaseCorrectPathName ( + LPCTSTR lpszShortPath, // file name + LPTSTR lpszLongPath, // path buffer + DWORD cchBuffer // size of path buffer +); + +oslFileError _osl_getSystemPathFromFileURL ( + rtl_uString * strURL, + rtl_uString ** pustrPath, + sal_Bool bAllowRelative +); + +oslFileError _osl_getFileURLFromSystemPath ( + rtl_uString * strPath, + rtl_uString ** pstrURL +); + +#ifdef __cplusplus +} +#endif + +#endif /* INCLUDED_OSL_FILE_URL_H */ diff --git a/sal/osl/w32/procimpl.cxx b/sal/osl/w32/procimpl.cxx index 512cd3551f47..379caeb5affc 100644 --- a/sal/osl/w32/procimpl.cxx +++ b/sal/osl/w32/procimpl.cxx @@ -59,7 +59,7 @@ #include <string> //################################################# -extern "C" oslFileHandle SAL_CALL osl_createFileHandleFromOSHandle( HANDLE hFile ); +extern "C" oslFileHandle SAL_CALL osl_createFileHandleFromOSHandle( HANDLE hFile, sal_uInt32 uFlags ); //################################################# const sal_Unicode NAME_VALUE_SEPARATOR = TEXT('='); @@ -576,13 +576,13 @@ oslProcessError SAL_CALL osl_executeProcess_WithRedirectedIO( WaitForSingleObject(pProcImpl->m_hProcess, INFINITE); if (pProcessInputWrite) - *pProcessInputWrite = osl_createFileHandleFromOSHandle(hInputWrite); + *pProcessInputWrite = osl_createFileHandleFromOSHandle(hInputWrite, osl_File_OpenFlag_Write); if (pProcessOutputRead) - *pProcessOutputRead = osl_createFileHandleFromOSHandle(hOutputRead); + *pProcessOutputRead = osl_createFileHandleFromOSHandle(hOutputRead, osl_File_OpenFlag_Read); if (pProcessErrorRead) - *pProcessErrorRead = osl_createFileHandleFromOSHandle(hErrorRead); + *pProcessErrorRead = osl_createFileHandleFromOSHandle(hErrorRead, osl_File_OpenFlag_Read); return osl_Process_E_None; } diff --git a/sal/osl/w32/tempfile.cxx b/sal/osl/w32/tempfile.cxx new file mode 100644 index 000000000000..6c591eae8972 --- /dev/null +++ b/sal/osl/w32/tempfile.cxx @@ -0,0 +1,279 @@ +/************************************************************************* + * + * 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: file.cxx,v $ + * $Revision: 1.0 $ + * + * 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. + * + ************************************************************************/ + +#define UNICODE +#define _UNICODE +#define _WIN32_WINNT_0x0500 +#include "systools/win32/uwinapi.h" + +#include "osl/file.h" + +#include "file_error.h" +#include "file_url.h" + +#include "osl/diagnose.h" + +#include <malloc.h> +#include <tchar.h> + +//##################################################### +#define ELEMENTS_OF_ARRAY(arr) (sizeof(arr)/(sizeof((arr)[0]))) + +// Allocate n number of t's on the stack return a pointer to it in p +#ifdef __MINGW32__ +#define STACK_ALLOC(p, t, n) (p) = reinterpret_cast<t*>(_alloca((n)*sizeof(t))); +#else +#define STACK_ALLOC(p, t, n) __try {(p) = reinterpret_cast<t*>(_alloca((n)*sizeof(t)));} \ + __except(EXCEPTION_EXECUTE_HANDLER) {(p) = 0;} +#endif + +extern "C" oslFileHandle SAL_CALL osl_createFileHandleFromOSHandle(HANDLE hFile, sal_uInt32 uFlags); + +//##################################################### +// Temp file functions +//##################################################### + +static oslFileError osl_setup_base_directory_impl_( + rtl_uString* pustrDirectoryURL, + rtl_uString** ppustr_base_dir) +{ + rtl_uString* dir_url = 0; + rtl_uString* dir = 0; + oslFileError error = osl_File_E_None; + + if (pustrDirectoryURL) + rtl_uString_assign(&dir_url, pustrDirectoryURL); + else + error = osl_getTempDirURL(&dir_url); + + if (osl_File_E_None == error) + { + error = _osl_getSystemPathFromFileURL(dir_url, &dir, sal_False); + rtl_uString_release(dir_url); + } + + if (osl_File_E_None == error ) + { + rtl_uString_assign(ppustr_base_dir, dir); + rtl_uString_release(dir); + } + + return error; +} + +//##################################################### +static oslFileError osl_setup_createTempFile_impl_( + rtl_uString* pustrDirectoryURL, + oslFileHandle* pHandle, + rtl_uString** ppustrTempFileURL, + rtl_uString** ppustr_base_dir, + sal_Bool* b_delete_on_close) +{ + oslFileError osl_error; + + OSL_PRECOND(((0 != pHandle) || (0 != ppustrTempFileURL)), "Invalid parameter!"); + + if ((0 == pHandle) && (0 == ppustrTempFileURL)) + { + osl_error = osl_File_E_INVAL; + } + else + { + osl_error = osl_setup_base_directory_impl_( + pustrDirectoryURL, ppustr_base_dir); + + *b_delete_on_close = (sal_Bool)(0 == ppustrTempFileURL); + } + + return osl_error; +} + +//##################################################### +static oslFileError osl_win32_GetTempFileName_impl_( + rtl_uString* base_directory, LPWSTR temp_file_name) +{ + oslFileError osl_error = osl_File_E_None; + + if (0 == GetTempFileNameW( + reinterpret_cast<LPCWSTR>(rtl_uString_getStr(base_directory)), + L"", + 0, + temp_file_name)) + { + osl_error = oslTranslateFileError(GetLastError()); + } + + return osl_error; +} + +//##################################################### +static sal_Bool osl_win32_CreateFile_impl_( + LPCWSTR file_name, sal_Bool b_delete_on_close, oslFileHandle* p_handle) +{ + DWORD flags = FILE_ATTRIBUTE_NORMAL; + HANDLE hFile; + + OSL_ASSERT(p_handle); + + if (b_delete_on_close) + flags |= FILE_FLAG_DELETE_ON_CLOSE; + + hFile = CreateFileW( + file_name, + GENERIC_READ | GENERIC_WRITE, + 0, + NULL, + TRUNCATE_EXISTING, + flags, + NULL); + + // @@@ ERROR HANDLING @@@ + if (IsValidHandle(hFile)) + *p_handle = osl_createFileHandleFromOSHandle(hFile, osl_File_OpenFlag_Read | osl_File_OpenFlag_Write); + + return (sal_Bool)IsValidHandle(hFile); +} + +//############################################# +static oslFileError osl_createTempFile_impl_( + rtl_uString* base_directory, + LPWSTR tmp_name, + sal_Bool b_delete_on_close, + oslFileHandle* pHandle, + rtl_uString** ppustrTempFileURL) +{ + oslFileError osl_error; + + do + { + osl_error = osl_win32_GetTempFileName_impl_(base_directory, tmp_name); + + /* if file could not be opened try again */ + + if ((osl_File_E_None != osl_error) || (0 == pHandle) || + osl_win32_CreateFile_impl_(tmp_name, b_delete_on_close, pHandle)) + break; + + } while(1); // try until success + + if ((osl_File_E_None == osl_error) && !b_delete_on_close) + { + rtl_uString* pustr = 0; + rtl_uString_newFromStr(&pustr, reinterpret_cast<const sal_Unicode*>(tmp_name)); + osl_getFileURLFromSystemPath(pustr, ppustrTempFileURL); + rtl_uString_release(pustr); + } + + return osl_error; +} + +//############################################# +oslFileError SAL_CALL osl_createTempFile( + rtl_uString* pustrDirectoryURL, + oslFileHandle* pHandle, + rtl_uString** ppustrTempFileURL) +{ + rtl_uString* base_directory = 0; + LPWSTR tmp_name; + sal_Bool b_delete_on_close; + oslFileError osl_error; + + osl_error = osl_setup_createTempFile_impl_( + pustrDirectoryURL, + pHandle, + ppustrTempFileURL, + &base_directory, + &b_delete_on_close); + + if (osl_File_E_None != osl_error) + return osl_error; + + /* allocate enough space on the stack */ + STACK_ALLOC(tmp_name, WCHAR, (rtl_uString_getLength(base_directory) + MAX_PATH)); + + if (tmp_name) + { + osl_createTempFile_impl_( + base_directory, + tmp_name, + b_delete_on_close, + pHandle, + ppustrTempFileURL); + } + else // stack alloc failed + { + osl_error = osl_File_E_NOMEM; + } + + if (base_directory) + rtl_uString_release(base_directory); + + return osl_error; +} + +//############################################# +oslFileError SAL_CALL osl_getTempDirURL(rtl_uString** pustrTempDir) +{ + WCHAR szBuffer[MAX_PATH]; + LPWSTR lpBuffer = szBuffer; + DWORD nBufferLength = ELEMENTS_OF_ARRAY(szBuffer) - 1; + + DWORD nLength; + oslFileError error; + + do + { + nLength = GetTempPathW( ELEMENTS_OF_ARRAY(szBuffer), lpBuffer ); + if ( nLength > nBufferLength ) + { + nLength++; + lpBuffer = reinterpret_cast<WCHAR*>(alloca( sizeof(WCHAR) * nLength )); + nBufferLength = nLength - 1; + } + } while ( nLength > nBufferLength ); + + if ( nLength ) + { + rtl_uString *ustrTempPath = NULL; + + if ( '\\' == lpBuffer[nLength-1] ) + lpBuffer[nLength-1] = 0; + + rtl_uString_newFromStr( &ustrTempPath, reinterpret_cast<const sal_Unicode*>(lpBuffer) ); + + error = osl_getFileURLFromSystemPath( ustrTempPath, pustrTempDir ); + + rtl_uString_release( ustrTempPath ); + } + else + error = oslTranslateFileError( GetLastError() ); + + return error; +} diff --git a/sal/osl/w32/util.c b/sal/osl/w32/util.c index a952de1dba8c..34c7b7ada53d 100644 --- a/sal/osl/w32/util.c +++ b/sal/osl/w32/util.c @@ -32,15 +32,6 @@ -extern sal_Bool osl_getEtherAddr(sal_Char* pszAddr, sal_uInt16 BufferSize) -{ - /* avoid warnings */ - pszAddr = pszAddr; - BufferSize = BufferSize; - - return sal_False; -} - extern sal_Bool SAL_CALL osl_getEthernetAddress( sal_uInt8 *pAddr ) { pAddr = pAddr; /* avoid warnings */ diff --git a/sal/qa/ByteSequence/ByteSequence.cxx b/sal/qa/ByteSequence/ByteSequence.cxx index 16283a48da92..f1105298deaf 100644 --- a/sal/qa/ByteSequence/ByteSequence.cxx +++ b/sal/qa/ByteSequence/ByteSequence.cxx @@ -36,7 +36,7 @@ #include <rtl/byteseq.hxx> -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> using namespace rtl; diff --git a/sal/qa/ByteSequence/makefile.mk b/sal/qa/ByteSequence/makefile.mk index a2ecbd5ccef1..0f1b88ac6e6a 100644 --- a/sal/qa/ByteSequence/makefile.mk +++ b/sal/qa/ByteSequence/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -47,17 +47,10 @@ CXXFLAGS+= $(LFS_CFLAGS) #----------------------------------- OStringBuffer ----------------------------------- SHL1OBJS= \ - $(SLO)$/ByteSequence.obj + $(SLO)$/ByteSequence.obj SHL1TARGET= rtl_ByteSequence -SHL1STDLIBS=\ - $(SALLIB) -.IF "$(GUI)" == "WNT" || "$(GUI)" == "OS2" -SHL1STDLIBS+= $(SOLARLIBDIR)$/cppunit.lib -.ENDIF -.IF "$(GUI)" == "UNX" -SHL1STDLIBS+=$(SOLARLIBDIR)$/libcppunit$(DLLPOSTFIX).a -.ENDIF +SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL1IMPLIB= i$(SHL1TARGET) # SHL1DEF= $(MISC)$/$(SHL1TARGET).def @@ -70,9 +63,7 @@ SHL1VERSIONMAP = $(PRJ)$/qa$/export.map SHL2OBJS= \ $(SLO)$/rtl_old_testbyteseq.obj SHL2TARGET= rtl_old_testbyteseq -SHL2STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) +SHL2STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL2IMPLIB= i$(SHL2TARGET) diff --git a/sal/qa/ByteSequence/rtl_old_testbyteseq.cxx b/sal/qa/ByteSequence/rtl_old_testbyteseq.cxx index 1c49a316c537..2cea6fa3a878 100644 --- a/sal/qa/ByteSequence/rtl_old_testbyteseq.cxx +++ b/sal/qa/ByteSequence/rtl_old_testbyteseq.cxx @@ -42,7 +42,7 @@ using namespace ::rtl; -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> namespace rtl_testbyteseq diff --git a/sal/qa/OStringBuffer/makefile.mk b/sal/qa/OStringBuffer/makefile.mk index be0f891cf8fc..d20c011a552e 100644 --- a/sal/qa/OStringBuffer/makefile.mk +++ b/sal/qa/OStringBuffer/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -56,16 +56,7 @@ SHL1OBJS= \ $(SLO)$/rtl_String_Utils.obj SHL1TARGET= rtl_OStringBuffer -SHL1STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) - -# .IF "$(GUI)" == "WNT" -# SHL1STDLIBS+= $(SOLARLIBDIR)$/cppunit.lib -# .ENDIF -# .IF "$(GUI)" == "UNX" -# SHL1STDLIBS+=$(SOLARLIBDIR)$/libcppunit$(DLLPOSTFIX).a -# .ENDIF +SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL1IMPLIB= i$(SHL1TARGET) # SHL1DEF= $(MISC)$/$(SHL1TARGET).def diff --git a/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx b/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx index df97eccf751e..2b3bbfd6caa3 100644 --- a/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx +++ b/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx @@ -38,7 +38,7 @@ #include <rtl/strbuf.hxx> -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> using namespace rtl; diff --git a/sal/qa/osl/condition/makefile.mk b/sal/qa/osl/condition/makefile.mk index fd58c9e633a3..586908e93032 100644 --- a/sal/qa/osl/condition/makefile.mk +++ b/sal/qa/osl/condition/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -44,19 +44,12 @@ CFLAGS+= $(LFS_CFLAGS) CXXFLAGS+= $(LFS_CFLAGS) # BEGIN ---------------------------------------------------------------- -# auto generated Target:Condition by codegen.pl +# auto generated Target:Condition by codegen.pl SHL1OBJS= \ $(SLO)$/osl_Condition.obj SHL1TARGET= osl_Condition -SHL1STDLIBS=\ - $(SALLIB) -.IF "$(GUI)" == "WNT" || "$(GUI)" == "OS2" -SHL1STDLIBS+= $(SOLARLIBDIR)$/cppunit.lib -.ENDIF -.IF "$(GUI)" == "UNX" -SHL1STDLIBS+=$(SOLARLIBDIR)$/libcppunit$(DLLPOSTFIX).a -.ENDIF +SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL1IMPLIB= i$(SHL1TARGET) diff --git a/sal/qa/osl/condition/osl_Condition_Const.h b/sal/qa/osl/condition/osl_Condition_Const.h index c04261176ee6..608bd38e3a64 100644 --- a/sal/qa/osl/condition/osl_Condition_Const.h +++ b/sal/qa/osl/condition/osl_Condition_Const.h @@ -59,7 +59,7 @@ #include <unistd.h> #endif -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> #define OSLTEST_DECLARE_USTRING( str_name, str_value ) \ ::rtl::OUString a##str_name = rtl::OUString::createFromAscii( str_value ) diff --git a/sal/qa/osl/file/makefile.mk b/sal/qa/osl/file/makefile.mk index 7c6d1232c1a0..0d83a06b7124 100644 --- a/sal/qa/osl/file/makefile.mk +++ b/sal/qa/osl/file/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -47,15 +47,7 @@ CXXFLAGS+= $(LFS_CFLAGS) SHL1OBJS= \ $(SLO)$/osl_File.obj SHL1TARGET= osl_File -SHL1STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) -# .IF "$(GUI)" == "WNT" -# SHL1STDLIBS+= $(SOLARLIBDIR)$/cppunit.lib -# .ENDIF -# .IF "$(GUI)" == "UNX" -# SHL1STDLIBS+=$(SOLARLIBDIR)$/libcppunit$(DLLPOSTFIX).a -# .ENDIF +SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL1IMPLIB= i$(SHL1TARGET) @@ -66,13 +58,7 @@ SHL1VERSIONMAP = $(PRJ)$/qa$/export.map SHL2OBJS=$(SLO)$/test_cpy_wrt_file.obj SHL2TARGET=tcwf -SHL2STDLIBS=$(SALLIB) -.IF "$(GUI)" == "WNT" || "$(GUI)" == "OS2" -SHL2STDLIBS+=$(SOLARLIBDIR)$/cppunit.lib -.ENDIF -.IF "$(GUI)" == "UNX" -SHL2STDLIBS+=$(SOLARLIBDIR)$/libcppunit$(DLLPOSTFIX).a -.ENDIF +SHL2STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL2IMPLIB=i$(SHL2TARGET) SHL2DEF=$(MISC)$/$(SHL2TARGET).def SHL2VERSIONMAP = $(PRJ)$/qa$/export.map @@ -85,9 +71,7 @@ DEF2NAME =$(SHL2TARGET) SHL3OBJS= \ $(SLO)$/osl_old_test_file.obj SHL3TARGET= osl_old_test_file -SHL3STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) +SHL3STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL3IMPLIB= i$(SHL3TARGET) diff --git a/sal/qa/osl/file/osl_File.cxx b/sal/qa/osl/file/osl_File.cxx index 3a44c565d162..a1cb3fa54e9e 100644 --- a/sal/qa/osl/file/osl_File.cxx +++ b/sal/qa/osl/file/osl_File.cxx @@ -44,7 +44,7 @@ #include <osl/file.hxx> #include <osl_File_Const.h> -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> // #ifdef WNT // # define UNICODE diff --git a/sal/qa/osl/file/osl_old_test_file.cxx b/sal/qa/osl/file/osl_old_test_file.cxx index 18be1d38e40c..64258b8e9006 100644 --- a/sal/qa/osl/file/osl_old_test_file.cxx +++ b/sal/qa/osl/file/osl_old_test_file.cxx @@ -51,7 +51,7 @@ #define TEST_VOLUME "c:/" #endif -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> namespace osl_test_file { diff --git a/sal/qa/osl/file/test_cpy_wrt_file.cxx b/sal/qa/osl/file/test_cpy_wrt_file.cxx index 6c4986f485b3..05910ea3ddd7 100755 --- a/sal/qa/osl/file/test_cpy_wrt_file.cxx +++ b/sal/qa/osl/file/test_cpy_wrt_file.cxx @@ -31,7 +31,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sal.hxx" -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> #include <osl/file.hxx> #include <osl/thread.h> #include <rtl/ustring.hxx> diff --git a/sal/qa/osl/module/makefile.mk b/sal/qa/osl/module/makefile.mk index d3500d267020..40f597bdbbc7 100644 --- a/sal/qa/osl/module/makefile.mk +++ b/sal/qa/osl/module/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -48,7 +48,7 @@ CXXFLAGS+= $(LFS_CFLAGS) # --- test dll ------------------------------------------------------ SHL1TARGET = Module_DLL SHL1OBJS = $(SLO)$/osl_Module_DLL.obj -SHL1STDLIBS = $(SALLIB) +SHL1STDLIBS = $(SALLIB) SHL1IMPLIB = i$(SHL1TARGET) SHL1DEF = $(MISC)$/$(SHL1TARGET).def DEF1NAME = $(SHL1TARGET) @@ -59,21 +59,16 @@ SHL1VERSIONMAP = export_dll.map SHL2OBJS= $(SLO)$/osl_Module.obj SHL2TARGET= osl_Module -SHL2STDLIBS= $(SALLIB) +SHL2STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) .IF "$(GUI)" == "WNT" -SHL2STDLIBS+= $(SOLARLIBDIR)$/cppunit.lib SHL2STDLIBS+=i$(SHL2TARGET).lib .ENDIF -.IF "$(GUI)" == "OS2" -SHL2STDLIBS+= $(SOLARLIBDIR)$/cppunit.lib -.ENDIF .IF "$(GUI)" == "UNX" -SHL2STDLIBS+=$(SOLARLIBDIR)$/libcppunit$(DLLPOSTFIX).a APP3STDLIBS+=-l$(SHL2TARGET) .ENDIF -SHL2DEPN= $(SHL1OBJS) +SHL2DEPN= $(SHL1OBJS) SHL2IMPLIB= i$(SHL2TARGET) SHL2DEF= $(MISC)$/$(SHL2TARGET).def diff --git a/sal/qa/osl/module/osl_Module_Const.h b/sal/qa/osl/module/osl_Module_Const.h index beeb4a800a11..ad954b5cb4ad 100644 --- a/sal/qa/osl/module/osl_Module_Const.h +++ b/sal/qa/osl/module/osl_Module_Const.h @@ -37,7 +37,7 @@ #include <osl/module.hxx> #include <osl/file.hxx> -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> #if ( defined UNX ) || ( defined OS2 ) //Unix # include <unistd.h> diff --git a/sal/qa/osl/module/osl_Module_DLL.cxx b/sal/qa/osl/module/osl_Module_DLL.cxx index ed7874eb11b5..46610f35f22c 100644 --- a/sal/qa/osl/module/osl_Module_DLL.cxx +++ b/sal/qa/osl/module/osl_Module_DLL.cxx @@ -33,7 +33,7 @@ #include <stdio.h> #include <sal/types.h> -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> extern "C" sal_Bool SAL_CALL firstfunc( sal_Bool bRes ) { diff --git a/sal/qa/osl/mutex/makefile.mk b/sal/qa/osl/mutex/makefile.mk index 44c5b6b46f7f..7c8cfeb39037 100755 --- a/sal/qa/osl/mutex/makefile.mk +++ b/sal/qa/osl/mutex/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -44,22 +44,16 @@ CFLAGS+= $(LFS_CFLAGS) CXXFLAGS+= $(LFS_CFLAGS) # BEGIN ---------------------------------------------------------------- -# auto generated Target:Socket by codegen.pl +# auto generated Target:Socket by codegen.pl SHL1OBJS= \ $(SLO)$/osl_Mutex.obj SHL1TARGET= osl_Mutex -SHL1STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) +SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) .IF "$(GUI)" == "WNT" SHL1STDLIBS += $(WS2_32LIB) .ENDIF -.IF "$(GUI)" == "OS2" -SHL1STDLIBS += $(SOLARLIBDIR)$/cppunit.lib -.ENDIF - .IF "$(GUI)" == "UNX" SHL1STDLIBS += -ldl -lnsl .ENDIF diff --git a/sal/qa/osl/mutex/osl_Mutex_Const.h b/sal/qa/osl/mutex/osl_Mutex_Const.h index 789b9e91c007..a13f40ab9605 100755 --- a/sal/qa/osl/mutex/osl_Mutex_Const.h +++ b/sal/qa/osl/mutex/osl_Mutex_Const.h @@ -49,7 +49,7 @@ #endif #include <osl/time.h> -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> #ifdef UNX #include <unistd.h> diff --git a/sal/qa/osl/pipe/makefile.mk b/sal/qa/osl/pipe/makefile.mk index 636bdde7de82..3d0df14bbd69 100644 --- a/sal/qa/osl/pipe/makefile.mk +++ b/sal/qa/osl/pipe/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -44,21 +44,12 @@ CFLAGS+= $(LFS_CFLAGS) CXXFLAGS+= $(LFS_CFLAGS) # BEGIN ---------------------------------------------------------------- -# auto generated Target:Pipe by codegen.pl +# auto generated Target:Pipe by codegen.pl SHL1OBJS= \ $(SLO)$/osl_Pipe.obj SHL1TARGET= osl_Pipe -SHL1STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) - -#.IF "$(GUI)" == "WNT" -#SHL1STDLIBS+= $(SOLARLIBDIR)$/cppunit.lib -#.ENDIF -#.IF "$(GUI)" == "UNX" -#SHL1STDLIBS+=$(SOLARLIBDIR)$/libcppunit$(DLLPOSTFIX).a -#.ENDIF +SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL1IMPLIB= i$(SHL1TARGET) # SHL1DEF= $(MISC)$/$(SHL1TARGET).def diff --git a/sal/qa/osl/pipe/osl_Pipe.cxx b/sal/qa/osl/pipe/osl_Pipe.cxx index 4f0da4ea686e..c2b2ae740527 100644 --- a/sal/qa/osl/pipe/osl_Pipe.cxx +++ b/sal/qa/osl/pipe/osl_Pipe.cxx @@ -35,7 +35,7 @@ // include files //------------------------------------------------------------------------ -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> #include <sal/types.h> #include <rtl/ustring.hxx> diff --git a/sal/qa/osl/process/makefile.mk b/sal/qa/osl/process/makefile.mk index 17f6ab46bd5a..32e97f3c162d 100644 --- a/sal/qa/osl/process/makefile.mk +++ b/sal/qa/osl/process/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -45,7 +45,7 @@ CFLAGS+= $(LFS_CFLAGS) CXXFLAGS+= $(LFS_CFLAGS) # BEGIN ---------------------------------------------------------------- -# auto generated Target:testjob by codegen.pl +# auto generated Target:testjob by codegen.pl .IF "$(GUI)" == "WNT" CFLAGS+=/Ob1 @@ -55,17 +55,7 @@ SHL1OBJS= \ $(SLO)$/osl_Thread.obj SHL1TARGET= osl_Thread -SHL1STDLIBS=\ - $(SALLIB) -.IF "$(GUI)" == "WNT" || "$(GUI)" == "OS2" -SHL1STDLIBS+= $(SOLARLIBDIR)$/cppunit.lib -.ENDIF -.IF "$(GUI)" == "UNX" -SHL1STDLIBS+=$(SOLARLIBDIR)$/libcppunit$(DLLPOSTFIX).a -# .IF "$(OS)" == "SOLARIS" -# SHL1STDLIBS += -lrt -laio -# .ENDIF -.ENDIF +SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL1IMPLIB= i$(SHL1TARGET) @@ -82,14 +72,7 @@ SHL1VERSIONMAP = $(PRJ)$/qa$/export.map SHL2OBJS=$(SLO)$/osl_process.obj SHL2TARGET=osl_process -SHL2STDLIBS=$(SALLIB) - -.IF "$(GUI)" == "WNT" || "$(GUI)" == "OS2" -SHL2STDLIBS+=$(SOLARLIBDIR)$/cppunit.lib -.ENDIF -.IF "$(GUI)" == "UNX" -SHL2STDLIBS+=$(SOLARLIBDIR)$/libcppunit$(DLLPOSTFIX).a -.ENDIF +SHL2STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL2IMPLIB=i$(SHL2TARGET) SHL2DEF=$(MISC)$/$(SHL2TARGET).def @@ -98,7 +81,7 @@ DEF2EXPORTFILE=export.exp # END ------------------------------------------------------------------ -OBJ3FILES=$(OBJ)$/osl_process_child.obj +OBJ3FILES=$(OBJ)$/osl_process_child.obj APP3TARGET=osl_process_child APP3OBJS=$(OBJ3FILES) diff --git a/sal/qa/osl/process/osl_Thread.cxx b/sal/qa/osl/process/osl_Thread.cxx index 9f666acc9659..88f796b6728c 100644 --- a/sal/qa/osl/process/osl_Thread.cxx +++ b/sal/qa/osl/process/osl_Thread.cxx @@ -52,7 +52,7 @@ #endif #include <osl/time.h> -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> using namespace osl; using namespace rtl; diff --git a/sal/qa/osl/process/osl_process.cxx b/sal/qa/osl/process/osl_process.cxx index 7fb794925ed2..a0fe5182daa1 100644 --- a/sal/qa/osl/process/osl_process.cxx +++ b/sal/qa/osl/process/osl_process.cxx @@ -31,7 +31,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sal.hxx" -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> #include <osl/process.h> #include <osl/file.hxx> #include <osl/thread.h> diff --git a/sal/qa/osl/profile/makefile.mk b/sal/qa/osl/profile/makefile.mk index d685655feb86..482bc69276a2 100644 --- a/sal/qa/osl/profile/makefile.mk +++ b/sal/qa/osl/profile/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -48,9 +48,7 @@ SHL1OBJS= \ $(SLO)$/osl_old_testprofile.obj SHL1TARGET= osl_old_testprofile -SHL1STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) +SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL1IMPLIB= i$(SHL1TARGET) DEF1NAME =$(SHL1TARGET) @@ -61,7 +59,7 @@ SHL1VERSIONMAP = $(PRJ)$/qa$/export.map #------------------------------- All object files ------------------------------- # do this here, so we get right dependencies SLOFILES=\ - $(SHL1OBJS) + $(SHL1OBJS) # --- Targets ------------------------------------------------------ diff --git a/sal/qa/osl/profile/osl_old_testprofile.cxx b/sal/qa/osl/profile/osl_old_testprofile.cxx index d5a6b3d92468..27e4cbe6b35b 100644 --- a/sal/qa/osl/profile/osl_old_testprofile.cxx +++ b/sal/qa/osl/profile/osl_old_testprofile.cxx @@ -40,7 +40,7 @@ #include <stdio.h> #include <osl/profile.h> -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> //================================================================================================== // ----------------------------------------------------------------------------- diff --git a/sal/qa/osl/security/makefile.mk b/sal/qa/osl/security/makefile.mk index 5896f1b6108d..6bcc6fc9f6d3 100755 --- a/sal/qa/osl/security/makefile.mk +++ b/sal/qa/osl/security/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -44,23 +44,15 @@ CFLAGS+= $(LFS_CFLAGS) CXXFLAGS+= $(LFS_CFLAGS) # BEGIN ---------------------------------------------------------------- -# auto generated Target:Security by codegen.pl +# auto generated Target:Security by codegen.pl SHL1OBJS= \ $(SLO)$/osl_Security.obj SHL1TARGET= osl_Security -SHL1STDLIBS=\ - $(SALLIB) +SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) .IF "$(GUI)" == "WNT" -SHL1STDLIBS+= $(SOLARLIBDIR)$/cppunit.lib SHL1STDLIBS+= $(ADVAPI32LIB) .ENDIF -.IF "$(GUI)" == "OS2" -SHL1STDLIBS+= $(SOLARLIBDIR)$/cppunit.lib -.ENDIF -.IF "$(GUI)" == "UNX" -SHL1STDLIBS+=$(SOLARLIBDIR)$/libcppunit$(DLLPOSTFIX).a -.ENDIF SHL1IMPLIB= i$(SHL1TARGET) SHL1DEF= $(MISC)$/$(SHL1TARGET).def diff --git a/sal/qa/osl/security/osl_Security_Const.h b/sal/qa/osl/security/osl_Security_Const.h index 428d6bb30fc6..ca08e3025b38 100755 --- a/sal/qa/osl/security/osl_Security_Const.h +++ b/sal/qa/osl/security/osl_Security_Const.h @@ -57,7 +57,7 @@ #include <pwd.h> #endif -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> // LLA: #include <testshl2/cmdlinebits.hxx> diff --git a/sal/qa/osl/semaphore/makefile.mk b/sal/qa/osl/semaphore/makefile.mk index d5ad5e532626..a8918dcfb12b 100644 --- a/sal/qa/osl/semaphore/makefile.mk +++ b/sal/qa/osl/semaphore/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -44,19 +44,12 @@ CFLAGS+= $(LFS_CFLAGS) CXXFLAGS+= $(LFS_CFLAGS) # BEGIN ---------------------------------------------------------------- -# auto generated Target:Semaphore by codegen.pl +# auto generated Target:Semaphore by codegen.pl SHL1OBJS= \ $(SLO)$/osl_Semaphore.obj SHL1TARGET= osl_Semaphore -SHL1STDLIBS=\ - $(SALLIB) -.IF "$(GUI)" == "WNT" || "$(GUI)" == "OS2" -SHL1STDLIBS+= $(SOLARLIBDIR)$/cppunit.lib -.ENDIF -.IF "$(GUI)" == "UNX" -SHL1STDLIBS+=$(SOLARLIBDIR)$/libcppunit$(DLLPOSTFIX).a -.ENDIF +SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL1IMPLIB= i$(SHL1TARGET) diff --git a/sal/qa/osl/semaphore/osl_Semaphore_Const.h b/sal/qa/osl/semaphore/osl_Semaphore_Const.h index f1aafa3a6244..c9f1149674f4 100644 --- a/sal/qa/osl/semaphore/osl_Semaphore_Const.h +++ b/sal/qa/osl/semaphore/osl_Semaphore_Const.h @@ -51,7 +51,7 @@ #endif #include <osl/time.h> -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> #ifdef UNX #include <unistd.h> diff --git a/sal/qa/osl/socket/makefile.mk b/sal/qa/osl/socket/makefile.mk index 5bcb252d187a..134bcadb55aa 100755 --- a/sal/qa/osl/socket/makefile.mk +++ b/sal/qa/osl/socket/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -44,22 +44,18 @@ CFLAGS+= $(LFS_CFLAGS) CXXFLAGS+= $(LFS_CFLAGS) # BEGIN ---------------------------------------------------------------- -# auto generated Target:Socket by codegen.pl +# auto generated Target:Socket by codegen.pl SHL1OBJS= \ $(SLO)$/osl_Socket.obj SHL1TARGET=osl_SocketOld -SHL1STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) +SHL1STDLIBS= $(SALLIB) $CPPUNITLIB) $(TESTSHL2LIB) .IF "$(GUI)" == "WNT" -#SHL1STDLIBS+= $(SOLARLIBDIR)$/cppunit.lib SHL1STDLIBS+= $(WS2_32LIB) .ENDIF .IF "$(GUI)" == "UNX" -#SHL1STDLIBS+=$(SOLARLIBDIR)$/libcppunit$(DLLPOSTFIX).a SHL1STDLIBS+= -ldl -lnsl .ENDIF @@ -75,9 +71,7 @@ SHL1VERSIONMAP = $(PRJ)$/qa$/export.map SHL2OBJS= \ $(SLO)$/osl_Socket_tests.obj SHL2TARGET= osl_Socket_tests -SHL2STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) +SHL2STDLIBS= $(SALLIB) $CPPUNITLIB) $(TESTSHL2LIB) SHL2IMPLIB= i$(SHL2TARGET) DEF2NAME= $(SHL2TARGET) @@ -86,15 +80,13 @@ SHL2VERSIONMAP = $(PRJ)$/qa$/export.map # END -------------------------------------------------------------- # BEGIN ---------------------------------------------------------------- -# auto generated Target:Socket by codegen.pl +# auto generated Target:Socket by codegen.pl SHL3OBJS= \ $(SLO)$/sockethelper.obj \ $(SLO)$/osl_StreamSocket.obj SHL3TARGET= osl_StreamSocket -SHL3STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) +SHL3STDLIBS= $(SALLIB) $CPPUNITLIB) $(TESTSHL2LIB) .IF "$(GUI)" == "WNT" SHL3STDLIBS += $(WS2_32LIB) @@ -111,15 +103,13 @@ SHL3VERSIONMAP = $(PRJ)$/qa$/export.map # END ------------------------------------------------------------------ # BEGIN ---------------------------------------------------------------- -# auto generated Target:Socket by codegen.pl +# auto generated Target:Socket by codegen.pl SHL4OBJS= \ $(SLO)$/sockethelper.obj \ $(SLO)$/osl_DatagramSocket.obj SHL4TARGET= osl_DatagramSocket -SHL4STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) +SHL4STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) .IF "$(GUI)" == "WNT" SHL4STDLIBS += $(WS2_32LIB) @@ -136,15 +126,13 @@ SHL4VERSIONMAP = $(PRJ)$/qa$/export.map # END ------------------------------------------------------------------ # BEGIN ---------------------------------------------------------------- -# auto generated Target:Socket by codegen.pl +# auto generated Target:Socket by codegen.pl SHL5OBJS= \ $(SLO)$/sockethelper.obj \ $(SLO)$/osl_SocketAddr.obj SHL5TARGET= osl_SocketAddr -SHL5STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) +SHL5STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) .IF "$(GUI)" == "WNT" SHL5STDLIBS += $(WS2_32LIB) @@ -161,15 +149,13 @@ SHL5VERSIONMAP = $(PRJ)$/qa$/export.map # END ------------------------------------------------------------------ # BEGIN ---------------------------------------------------------------- -# auto generated Target:Socket by codegen.pl +# auto generated Target:Socket by codegen.pl SHL6OBJS= \ $(SLO)$/sockethelper.obj \ $(SLO)$/osl_Socket2.obj SHL6TARGET= osl_Socket2 -SHL6STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) +SHL6STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) .IF "$(GUI)" == "WNT" SHL6STDLIBS += $(WS2_32LIB) @@ -186,15 +172,13 @@ SHL6VERSIONMAP = $(PRJ)$/qa$/export.map # END ------------------------------------------------------------------ # BEGIN ---------------------------------------------------------------- -# auto generated Target:Socket by codegen.pl +# auto generated Target:Socket by codegen.pl SHL7OBJS= \ $(SLO)$/sockethelper.obj \ $(SLO)$/osl_ConnectorSocket.obj SHL7TARGET= osl_ConnectorSocket -SHL7STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) +SHL7STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) .IF "$(GUI)" == "WNT" SHL7STDLIBS += $(WS2_32LIB) @@ -211,15 +195,13 @@ SHL7VERSIONMAP = $(PRJ)$/qa$/export.map # END ------------------------------------------------------------------ # BEGIN ---------------------------------------------------------------- -# auto generated Target:Socket by codegen.pl +# auto generated Target:Socket by codegen.pl SHL8OBJS= \ $(SLO)$/sockethelper.obj \ $(SLO)$/osl_AcceptorSocket.obj SHL8TARGET= osl_AcceptorSocket -SHL8STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) +SHL8STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) .IF "$(GUI)" == "WNT" SHL8STDLIBS += $(WS2_32LIB) diff --git a/sal/qa/osl/socket/osl_AcceptorSocket.cxx b/sal/qa/osl/socket/osl_AcceptorSocket.cxx index 002e27efbd0e..6325385b62ee 100644 --- a/sal/qa/osl/socket/osl_AcceptorSocket.cxx +++ b/sal/qa/osl/socket/osl_AcceptorSocket.cxx @@ -61,7 +61,7 @@ // include files //------------------------------------------------------------------------ -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> #include "osl_Socket_Const.h" #include "sockethelper.hxx" diff --git a/sal/qa/osl/socket/osl_ConnectorSocket.cxx b/sal/qa/osl/socket/osl_ConnectorSocket.cxx index e3f4ad3e5bea..52c1b12b687e 100644 --- a/sal/qa/osl/socket/osl_ConnectorSocket.cxx +++ b/sal/qa/osl/socket/osl_ConnectorSocket.cxx @@ -61,7 +61,7 @@ // include files //------------------------------------------------------------------------ -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> #include "osl_Socket_Const.h" #include "sockethelper.hxx" diff --git a/sal/qa/osl/socket/osl_DatagramSocket.cxx b/sal/qa/osl/socket/osl_DatagramSocket.cxx index 4e714d0b655b..4cf27a90ad90 100644 --- a/sal/qa/osl/socket/osl_DatagramSocket.cxx +++ b/sal/qa/osl/socket/osl_DatagramSocket.cxx @@ -61,7 +61,7 @@ // include files //------------------------------------------------------------------------ -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> //#include "osl_Socket_Const.h" #include "sockethelper.hxx" diff --git a/sal/qa/osl/socket/osl_Socket.cxx b/sal/qa/osl/socket/osl_Socket.cxx index 20f2a80d04da..ccc87ee23a1d 100755 --- a/sal/qa/osl/socket/osl_Socket.cxx +++ b/sal/qa/osl/socket/osl_Socket.cxx @@ -66,7 +66,7 @@ #include <osl_Socket_Const_orig.h> #endif -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> using namespace osl; using namespace rtl; diff --git a/sal/qa/osl/socket/osl_Socket2.cxx b/sal/qa/osl/socket/osl_Socket2.cxx index 29a7924c5503..a7b0ecfa1ef7 100644 --- a/sal/qa/osl/socket/osl_Socket2.cxx +++ b/sal/qa/osl/socket/osl_Socket2.cxx @@ -61,7 +61,7 @@ // include files //------------------------------------------------------------------------ -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> //#include "osl_Socket_Const.h" #include "sockethelper.hxx" diff --git a/sal/qa/osl/socket/osl_SocketAddr.cxx b/sal/qa/osl/socket/osl_SocketAddr.cxx index e9db614bade8..63ca58f67936 100644 --- a/sal/qa/osl/socket/osl_SocketAddr.cxx +++ b/sal/qa/osl/socket/osl_SocketAddr.cxx @@ -61,7 +61,7 @@ // include files //------------------------------------------------------------------------ -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> //#include "osl_Socket_Const.h" #include "sockethelper.hxx" diff --git a/sal/qa/osl/socket/osl_Socket_tests.cxx b/sal/qa/osl/socket/osl_Socket_tests.cxx index 3122b27b1f1a..7f0fb5bbe87e 100644 --- a/sal/qa/osl/socket/osl_Socket_tests.cxx +++ b/sal/qa/osl/socket/osl_Socket_tests.cxx @@ -36,7 +36,7 @@ //------------------------------------------------------------------------ #include <osl_Socket_Const.h> -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> #include <osl/socket.hxx> //------------------------------------------------------------------------ // helper functions diff --git a/sal/qa/osl/socket/osl_StreamSocket.cxx b/sal/qa/osl/socket/osl_StreamSocket.cxx index 0d5a1e54739f..9769d13adb0f 100644 --- a/sal/qa/osl/socket/osl_StreamSocket.cxx +++ b/sal/qa/osl/socket/osl_StreamSocket.cxx @@ -61,7 +61,7 @@ // include files //------------------------------------------------------------------------ -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> //#include "osl_Socket_Const.h" #include "sockethelper.hxx" diff --git a/sal/qa/osl/socket/sockethelper.cxx b/sal/qa/osl/socket/sockethelper.cxx index c10ebcb2c8ca..681858f15dc1 100644 --- a/sal/qa/osl/socket/sockethelper.cxx +++ b/sal/qa/osl/socket/sockethelper.cxx @@ -32,7 +32,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sal.hxx" #include "sockethelper.hxx" -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> //------------------------------------------------------------------------ // Ip version definition diff --git a/sal/qa/osl/thread/makefile.mk b/sal/qa/osl/thread/makefile.mk index e74400ba6aff..86551fc6771b 100644 --- a/sal/qa/osl/thread/makefile.mk +++ b/sal/qa/osl/thread/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -41,7 +41,7 @@ DLLPRE = # no leading "lib" on .so files SHL1TARGET = $(TARGET) SHL1OBJS = $(SLO)$/test_thread.obj -SHL1STDLIBS = $(CPPUNITLIB) $(SALLIB) +SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL1VERSIONMAP = version.map SHL1IMPLIB = i$(SHL1TARGET) DEF1NAME = $(SHL1TARGET) diff --git a/sal/qa/osl/thread/test_thread.cxx b/sal/qa/osl/thread/test_thread.cxx index 59c857c82b2f..21fd2e297fe0 100644 --- a/sal/qa/osl/thread/test_thread.cxx +++ b/sal/qa/osl/thread/test_thread.cxx @@ -33,7 +33,7 @@ #include "sal/config.h" -#include "cppunit/simpleheader.hxx" +#include "testshl/simpleheader.hxx" #include "osl/conditn.hxx" #include "osl/thread.hxx" #include "osl/time.h" diff --git a/sal/qa/rtl/alloc/makefile.mk b/sal/qa/rtl/alloc/makefile.mk index 4fad638942fb..ce88442a5574 100755 --- a/sal/qa/rtl/alloc/makefile.mk +++ b/sal/qa/rtl/alloc/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -45,20 +45,12 @@ CFLAGS+= $(LFS_CFLAGS) CXXFLAGS+= $(LFS_CFLAGS) # BEGIN ---------------------------------------------------------------- -# auto generated Target:jobfile by codegen.pl +# auto generated Target:jobfile by codegen.pl SHL1OBJS= \ $(SLO)$/rtl_alloc.obj SHL1TARGET= rtl_Alloc -SHL1STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) -# .IF "$(GUI)" == "WNT" -# SHL1STDLIBS+= $(SOLARLIBDIR)$/cppunit.lib -# .ENDIF -# .IF "$(GUI)" == "UNX" -# SHL1STDLIBS+=$(SOLARLIBDIR)$/libcppunit$(DLLPOSTFIX).a -# .ENDIF +SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL1IMPLIB= i$(SHL1TARGET) # SHL1DEF= $(MISC)$/$(SHL1TARGET).def diff --git a/sal/qa/rtl/alloc/rtl_alloc.cxx b/sal/qa/rtl/alloc/rtl_alloc.cxx index 75173f3aaf86..ae9a1e9e9587 100755 --- a/sal/qa/rtl/alloc/rtl_alloc.cxx +++ b/sal/qa/rtl/alloc/rtl_alloc.cxx @@ -34,7 +34,7 @@ // autogenerated file with codegen.pl #include <rtl/alloc.h> -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> namespace rtl_alloc { diff --git a/sal/qa/rtl/bootstrap/makefile.mk b/sal/qa/rtl/bootstrap/makefile.mk index ff47fa6c78d2..a492af8dd3c5 100644 --- a/sal/qa/rtl/bootstrap/makefile.mk +++ b/sal/qa/rtl/bootstrap/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -55,14 +55,12 @@ CFLAGS+= $(LFS_CFLAGS) CXXFLAGS+= $(LFS_CFLAGS) # BEGIN ---------------------------------------------------------------- -# auto generated Target:joblist by codegen.pl +# auto generated Target:joblist by codegen.pl SHL1OBJS= \ $(SLO)$/rtl_Bootstrap.obj SHL1TARGET= rtl_Bootstrap -SHL1STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) +SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL1IMPLIB= i$(SHL1TARGET) # SHL1DEF= $(MISC)$/$(SHL1TARGET).def @@ -72,7 +70,7 @@ DEF1NAME =$(SHL1TARGET) SHL1VERSIONMAP= $(PRJ)$/qa$/export.map # END ------------------------------------------------------------------ -OBJ2FILES=$(OBJ)$/bootstrap_process.obj +OBJ2FILES=$(OBJ)$/bootstrap_process.obj APP2TARGET=bootstrap_process APP2OBJS=$(OBJ2FILES) diff --git a/sal/qa/rtl/bootstrap/rtl_Bootstrap.cxx b/sal/qa/rtl/bootstrap/rtl_Bootstrap.cxx index 85efcfa55b34..520c1298030f 100644 --- a/sal/qa/rtl/bootstrap/rtl_Bootstrap.cxx +++ b/sal/qa/rtl/bootstrap/rtl_Bootstrap.cxx @@ -39,9 +39,9 @@ #include <stdlib.h> #include <algorithm> // STL -#include "cppunit/stringhelper.hxx" +#include "testshl/stringhelper.hxx" -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> //#include "stringhelper.hxx" //#include "valueequal.hxx" #include <rtl/bootstrap.hxx> diff --git a/sal/qa/rtl/cipher/makefile.mk b/sal/qa/rtl/cipher/makefile.mk index c8d508f8b9ef..fc7a975651f5 100644 --- a/sal/qa/rtl/cipher/makefile.mk +++ b/sal/qa/rtl/cipher/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -45,14 +45,12 @@ CFLAGS+= $(LFS_CFLAGS) CXXFLAGS+= $(LFS_CFLAGS) # BEGIN ---------------------------------------------------------------- -# auto generated Target:joblist by codegen.pl +# auto generated Target:joblist by codegen.pl SHL1OBJS= \ $(SLO)$/rtl_cipher.obj SHL1TARGET= rtl_cipher -SHL1STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) +SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL1IMPLIB= i$(SHL1TARGET) # SHL1DEF= $(MISC)$/$(SHL1TARGET).def diff --git a/sal/qa/rtl/cipher/rtl_cipher.cxx b/sal/qa/rtl/cipher/rtl_cipher.cxx index c51344cdc83e..a55f4a20d6fe 100644 --- a/sal/qa/rtl/cipher/rtl_cipher.cxx +++ b/sal/qa/rtl/cipher/rtl_cipher.cxx @@ -32,7 +32,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sal.hxx" -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> #include <rtl/strbuf.hxx> #include <rtl/cipher.h> diff --git a/sal/qa/rtl/crc32/makefile.mk b/sal/qa/rtl/crc32/makefile.mk index aa24d698ea30..8b1ee4a6f350 100755 --- a/sal/qa/rtl/crc32/makefile.mk +++ b/sal/qa/rtl/crc32/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -45,19 +45,12 @@ CFLAGS+= $(LFS_CFLAGS) CXXFLAGS+= $(LFS_CFLAGS) # BEGIN ---------------------------------------------------------------- -# auto generated Target:jobfile by codegen.pl +# auto generated Target:jobfile by codegen.pl SHL1OBJS= \ $(SLO)$/rtl_crc32.obj SHL1TARGET= rtl_crc32 -SHL1STDLIBS=\ - $(SALLIB) -.IF "$(GUI)" == "WNT" || "$(GUI)" == "OS2" -SHL1STDLIBS+= $(SOLARLIBDIR)$/cppunit.lib -.ENDIF -.IF "$(GUI)" == "UNX" -SHL1STDLIBS+=$(SOLARLIBDIR)$/libcppunit$(DLLPOSTFIX).a -.ENDIF +SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL1IMPLIB= i$(SHL1TARGET) # SHL1DEF= $(MISC)$/$(SHL1TARGET).def diff --git a/sal/qa/rtl/crc32/rtl_crc32.cxx b/sal/qa/rtl/crc32/rtl_crc32.cxx index fa5870c9c8dd..09f492376ba2 100755 --- a/sal/qa/rtl/crc32/rtl_crc32.cxx +++ b/sal/qa/rtl/crc32/rtl_crc32.cxx @@ -33,7 +33,7 @@ #include "precompiled_sal.hxx" // autogenerated file with codegen.pl -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> #include <rtl/crc.h> namespace rtl_CRC32 diff --git a/sal/qa/rtl/digest/makefile.mk b/sal/qa/rtl/digest/makefile.mk index a80835047d8b..7786522901ee 100644 --- a/sal/qa/rtl/digest/makefile.mk +++ b/sal/qa/rtl/digest/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -48,12 +48,10 @@ CXXFLAGS+= $(LFS_CFLAGS) #----------------------------------- OStringBuffer ----------------------------------- SHL1OBJS= \ - $(SLO)$/rtl_digest.obj + $(SLO)$/rtl_digest.obj SHL1TARGET= rtl_digest -SHL1STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) +SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL1IMPLIB= i$(SHL1TARGET) DEF1NAME= $(SHL1TARGET) diff --git a/sal/qa/rtl/digest/rtl_digest.cxx b/sal/qa/rtl/digest/rtl_digest.cxx index 151b01f8994c..9f8dd3f24542 100644 --- a/sal/qa/rtl/digest/rtl_digest.cxx +++ b/sal/qa/rtl/digest/rtl_digest.cxx @@ -31,7 +31,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sal.hxx" -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> #include <rtl/digest.h> #include <rtl/ustring.hxx> diff --git a/sal/qa/rtl/doublelock/makefile.mk b/sal/qa/rtl/doublelock/makefile.mk index 7ee93688eff2..b46518fb2e68 100644 --- a/sal/qa/rtl/doublelock/makefile.mk +++ b/sal/qa/rtl/doublelock/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -45,7 +45,7 @@ CFLAGS+= $(LFS_CFLAGS) CXXFLAGS+= $(LFS_CFLAGS) # BEGIN ---------------------------------------------------------------- -# auto generated Target:testjob by codegen.pl +# auto generated Target:testjob by codegen.pl .IF "$(GUI)" == "WNT" CFLAGS+=/Ob1 @@ -55,9 +55,7 @@ SHL1OBJS= \ $(SLO)$/rtl_doublelocking.obj SHL1TARGET= rtl_doublelocking -SHL1STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) +SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL1IMPLIB= i$(SHL1TARGET) DEF1NAME =$(SHL1TARGET) diff --git a/sal/qa/rtl/doublelock/rtl_doublelocking.cxx b/sal/qa/rtl/doublelock/rtl_doublelocking.cxx index 2f3f004dbabc..cbcc334d3134 100644 --- a/sal/qa/rtl/doublelock/rtl_doublelocking.cxx +++ b/sal/qa/rtl/doublelock/rtl_doublelocking.cxx @@ -46,7 +46,7 @@ #include <rtl/instance.hxx> -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> // ----------------------------------------------------------------------------- #define CONST_TEST_STRING "gregorian" diff --git a/sal/qa/rtl/locale/makefile.mk b/sal/qa/rtl/locale/makefile.mk index 6ad4991bcfd9..8e4710c5ac6b 100644 --- a/sal/qa/rtl/locale/makefile.mk +++ b/sal/qa/rtl/locale/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -45,14 +45,12 @@ CFLAGS+= $(LFS_CFLAGS) CXXFLAGS+= $(LFS_CFLAGS) # BEGIN ---------------------------------------------------------------- -# auto generated Target:locale by codegen.pl +# auto generated Target:locale by codegen.pl SHL1OBJS= \ $(SLO)$/rtl_locale.obj SHL1TARGET= rtl_locale -SHL1STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) +SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL1IMPLIB= i$(SHL1TARGET) # SHL1DEF= $(MISC)$/$(SHL1TARGET).def diff --git a/sal/qa/rtl/locale/rtl_locale.cxx b/sal/qa/rtl/locale/rtl_locale.cxx index 91fb285db98a..c677259038f3 100644 --- a/sal/qa/rtl/locale/rtl_locale.cxx +++ b/sal/qa/rtl/locale/rtl_locale.cxx @@ -33,7 +33,7 @@ #include "precompiled_sal.hxx" // autogenerated file with codegen.pl -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> #include <rtl/locale.hxx> #include <osl/thread.h> diff --git a/sal/qa/rtl/logfile/makefile.mk b/sal/qa/rtl/logfile/makefile.mk index 23a5979237d9..da70d7533fa0 100644 --- a/sal/qa/rtl/logfile/makefile.mk +++ b/sal/qa/rtl/logfile/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -47,9 +47,7 @@ CXXFLAGS+= $(LFS_CFLAGS) SHL1OBJS= \ $(SLO)$/rtl_logfile.obj SHL1TARGET= rtl_logfile -SHL1STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) +SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL1IMPLIB= i$(SHL1TARGET) DEF1NAME =$(SHL1TARGET) diff --git a/sal/qa/rtl/logfile/rtl_logfile.cxx b/sal/qa/rtl/logfile/rtl_logfile.cxx index 9ed83adf9c09..d589cfb2bf04 100644 --- a/sal/qa/rtl/logfile/rtl_logfile.cxx +++ b/sal/qa/rtl/logfile/rtl_logfile.cxx @@ -46,7 +46,7 @@ #endif #include <rtl/logfile.hxx> -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> // #ifndef _OSL_MODULE_HXX_ // #include <osl/module.hxx> diff --git a/sal/qa/rtl/math/makefile.mk b/sal/qa/rtl/math/makefile.mk index 14e8cec2ec9c..5db3ffdd2028 100644 --- a/sal/qa/rtl/math/makefile.mk +++ b/sal/qa/rtl/math/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -48,17 +48,10 @@ CXXFLAGS+= $(LFS_CFLAGS) #----------------------------------- OStringBuffer ----------------------------------- SHL1OBJS= \ - $(SLO)$/test_rtl_math.obj + $(SLO)$/test_rtl_math.obj SHL1TARGET= rtl_math -SHL1STDLIBS=\ - $(SALLIB) -.IF "$(GUI)" == "WNT" || "$(GUI)" == "OS2" -SHL1STDLIBS+= $(SOLARLIBDIR)$/cppunit.lib -.ENDIF -.IF "$(GUI)" == "UNX" -SHL1STDLIBS+=$(SOLARLIBDIR)$/libcppunit$(DLLPOSTFIX).a -.ENDIF +SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL1IMPLIB= i$(SHL1TARGET) # SHL1DEF= $(MISC)$/$(SHL1TARGET).def @@ -71,9 +64,7 @@ SHL1VERSIONMAP = $(PRJ)$/qa$/export.map SHL2OBJS= \ $(SLO)$/rtl_math.obj SHL2TARGET= rtl_math2 -SHL2STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) +SHL2STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL2IMPLIB= i$(SHL2TARGET) DEF2NAME= $(SHL2TARGET) @@ -90,14 +81,12 @@ SHL2VERSIONMAP = $(PRJ)$/qa$/export.map # SHL3OBJS= \ # $(SLO)$/rtl_old_testint64.obj # SHL3TARGET= rtl_old_testint64 -# SHL3STDLIBS=\ -# $(SALLIB) \ -# $(CPPUNITLIB) -# +# SHL3STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) +# # SHL3IMPLIB= i$(SHL3TARGET) # DEF3NAME= $(SHL3TARGET) # SHL3VERSIONMAP = $(PRJ)$/qa$/export.map -# +# #------------------------------- All object files ------------------------------- # do this here, so we get right dependencies diff --git a/sal/qa/rtl/math/rtl_math.cxx b/sal/qa/rtl/math/rtl_math.cxx index 34d851b4f2e7..a9c16541e524 100644 --- a/sal/qa/rtl/math/rtl_math.cxx +++ b/sal/qa/rtl/math/rtl_math.cxx @@ -37,7 +37,7 @@ #endif #include <math.h> -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> #include <rtl/math.h> #include <rtl/string.hxx> diff --git a/sal/qa/rtl/math/rtl_old_testint64.cxx b/sal/qa/rtl/math/rtl_old_testint64.cxx index e0059b200db6..923c464186f3 100644 --- a/sal/qa/rtl/math/rtl_old_testint64.cxx +++ b/sal/qa/rtl/math/rtl_old_testint64.cxx @@ -49,7 +49,7 @@ // #define TEST_ENSURE(c, m) OSL_VERIFY(c) // #endif -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> // ----------------------------------------------------------------------------- namespace rtl_math diff --git a/sal/qa/rtl/ostring/makefile.mk b/sal/qa/rtl/ostring/makefile.mk index 279697313cf1..d2c6049afcbc 100644 --- a/sal/qa/rtl/ostring/makefile.mk +++ b/sal/qa/rtl/ostring/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -45,14 +45,12 @@ CFLAGS+= $(LFS_CFLAGS) CXXFLAGS+= $(LFS_CFLAGS) # BEGIN ---------------------------------------------------------------- -# auto generated Target:joblist by codegen.pl +# auto generated Target:joblist by codegen.pl SHL1OBJS= \ $(SLO)$/rtl_OString2.obj SHL1TARGET= rtl_OString2 -SHL1STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) +SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL1IMPLIB= i$(SHL1TARGET) # SHL1DEF= $(MISC)$/$(SHL1TARGET).def @@ -68,9 +66,7 @@ SHL2OBJS= \ $(SLO)$/rtl_str.obj SHL2TARGET= rtl_str -SHL2STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) +SHL2STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL2IMPLIB= i$(SHL2TARGET) DEF2NAME =$(SHL2TARGET) @@ -82,9 +78,7 @@ SHL3OBJS= \ $(SLO)$/rtl_string.obj SHL3TARGET= rtl_string -SHL3STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) +SHL3STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL3IMPLIB= i$(SHL3TARGET) DEF3NAME =$(SHL3TARGET) diff --git a/sal/qa/rtl/ostring/rtl_OString2.cxx b/sal/qa/rtl/ostring/rtl_OString2.cxx index 8421346f84a7..2ff2ca6b434b 100644 --- a/sal/qa/rtl/ostring/rtl_OString2.cxx +++ b/sal/qa/rtl/ostring/rtl_OString2.cxx @@ -34,7 +34,7 @@ // autogenerated file with codegen.pl // There exist some more test code in sal/qa/rtl_strings/rtl_OString.cxx -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> #include "valueequal.hxx" namespace rtl_OString diff --git a/sal/qa/rtl/ostring/rtl_str.cxx b/sal/qa/rtl/ostring/rtl_str.cxx index 5e34b034bffb..6ce43ae0bb9b 100644 --- a/sal/qa/rtl/ostring/rtl_str.cxx +++ b/sal/qa/rtl/ostring/rtl_str.cxx @@ -31,7 +31,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sal.hxx" -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> namespace rtl_str { diff --git a/sal/qa/rtl/ostring/rtl_string.cxx b/sal/qa/rtl/ostring/rtl_string.cxx index 549555d0e10a..a1fc88037f51 100644 --- a/sal/qa/rtl/ostring/rtl_string.cxx +++ b/sal/qa/rtl/ostring/rtl_string.cxx @@ -31,7 +31,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sal.hxx" -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> namespace rtl_string { diff --git a/sal/qa/rtl/oustring/makefile.mk b/sal/qa/rtl/oustring/makefile.mk index dedaa650107d..40e4ba4a0b58 100644 --- a/sal/qa/rtl/oustring/makefile.mk +++ b/sal/qa/rtl/oustring/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -45,14 +45,12 @@ CFLAGS+= $(LFS_CFLAGS) CXXFLAGS+= $(LFS_CFLAGS) # BEGIN ---------------------------------------------------------------- -# auto generated Target:joblist by codegen.pl +# auto generated Target:joblist by codegen.pl SHL1OBJS= \ $(SLO)$/rtl_OUString2.obj SHL1TARGET= rtl_OUString2 -SHL1STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) +SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL1IMPLIB= i$(SHL1TARGET) # SHL1DEF= $(MISC)$/$(SHL1TARGET).def @@ -68,9 +66,7 @@ SHL2OBJS= \ $(SLO)$/rtl_ustr.obj SHL2TARGET= rtl_ustr -SHL2STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) +SHL2STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL2IMPLIB= i$(SHL2TARGET) DEF2NAME =$(SHL2TARGET) diff --git a/sal/qa/rtl/oustring/rtl_OUString2.cxx b/sal/qa/rtl/oustring/rtl_OUString2.cxx index 9606ae0859c3..8632a159ab85 100644 --- a/sal/qa/rtl/oustring/rtl_OUString2.cxx +++ b/sal/qa/rtl/oustring/rtl_OUString2.cxx @@ -38,7 +38,7 @@ #include <algorithm> // STL -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> #include "stringhelper.hxx" #include "valueequal.hxx" diff --git a/sal/qa/rtl/oustring/rtl_ustr.cxx b/sal/qa/rtl/oustring/rtl_ustr.cxx index 5cc28ea1f389..43610d0461f4 100644 --- a/sal/qa/rtl/oustring/rtl_ustr.cxx +++ b/sal/qa/rtl/oustring/rtl_ustr.cxx @@ -31,7 +31,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sal.hxx" -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> /** print a UNI_CODE file name. */ diff --git a/sal/qa/rtl/oustringbuffer/makefile.mk b/sal/qa/rtl/oustringbuffer/makefile.mk index 9737d998a768..a910d7222773 100644 --- a/sal/qa/rtl/oustringbuffer/makefile.mk +++ b/sal/qa/rtl/oustringbuffer/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -45,14 +45,12 @@ CFLAGS+= $(LFS_CFLAGS) CXXFLAGS+= $(LFS_CFLAGS) # BEGIN ---------------------------------------------------------------- -# auto generated Target:joblist by codegen.pl +# auto generated Target:joblist by codegen.pl SHL1OBJS= \ $(SLO)$/rtl_OUStringBuffer2.obj SHL1TARGET= rtl_OUStringBuffer2 -SHL1STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) +SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL1IMPLIB= i$(SHL1TARGET) # SHL1DEF= $(MISC)$/$(SHL1TARGET).def diff --git a/sal/qa/rtl/oustringbuffer/rtl_OUStringBuffer2.cxx b/sal/qa/rtl/oustringbuffer/rtl_OUStringBuffer2.cxx index d259e63174f8..febaa2a9d552 100644 --- a/sal/qa/rtl/oustringbuffer/rtl_OUStringBuffer2.cxx +++ b/sal/qa/rtl/oustringbuffer/rtl_OUStringBuffer2.cxx @@ -31,7 +31,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sal.hxx" -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> #include "stringhelper.hxx" #include <rtl/ustrbuf.hxx> #include <rtl/uri.hxx> diff --git a/sal/qa/rtl/process/makefile.mk b/sal/qa/rtl/process/makefile.mk index c1f5d9cad7eb..ac8d66e24b7d 100644 --- a/sal/qa/rtl/process/makefile.mk +++ b/sal/qa/rtl/process/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -45,14 +45,12 @@ CFLAGS+= $(LFS_CFLAGS) CXXFLAGS+= $(LFS_CFLAGS) # BEGIN ---------------------------------------------------------------- -# auto generated Target:joblist by codegen.pl +# auto generated Target:joblist by codegen.pl SHL1OBJS= \ $(SLO)$/rtl_Process.obj SHL1TARGET= rtl_Process -SHL1STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) +SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL1IMPLIB= i$(SHL1TARGET) # SHL1DEF= $(MISC)$/$(SHL1TARGET).def @@ -62,7 +60,7 @@ DEF1NAME =$(SHL1TARGET) SHL1VERSIONMAP= $(PRJ)$/qa$/export.map # END ------------------------------------------------------------------ -OBJ3FILES=$(OBJ)$/child_process.obj +OBJ3FILES=$(OBJ)$/child_process.obj APP3TARGET=child_process APP3OBJS=$(OBJ3FILES) @@ -74,7 +72,7 @@ APP3OBJS=$(OBJ3FILES) #.ENDIF APP3STDLIBS=$(SALLIB) -OBJ4FILES=$(OBJ)$/child_process_id.obj +OBJ4FILES=$(OBJ)$/child_process_id.obj APP4TARGET=child_process_id APP4OBJS=$(OBJ4FILES) diff --git a/sal/qa/rtl/process/rtl_Process.cxx b/sal/qa/rtl/process/rtl_Process.cxx index 78360186fea7..e14d52905c32 100644 --- a/sal/qa/rtl/process/rtl_Process.cxx +++ b/sal/qa/rtl/process/rtl_Process.cxx @@ -36,7 +36,7 @@ #include <string.h> #include <sal/types.h> -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> #include <rtl/ustring.hxx> #include <rtl/string.hxx> #include <rtl/process.h> diff --git a/sal/qa/rtl/random/makefile.mk b/sal/qa/rtl/random/makefile.mk index 61cd9b676351..0fc2e5e5a7f8 100644 --- a/sal/qa/rtl/random/makefile.mk +++ b/sal/qa/rtl/random/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -45,14 +45,12 @@ CFLAGS+= $(LFS_CFLAGS) CXXFLAGS+= $(LFS_CFLAGS) # BEGIN ---------------------------------------------------------------- -# auto generated Target:job by codegen.pl +# auto generated Target:job by codegen.pl SHL1OBJS= \ $(SLO)$/rtl_random.obj SHL1TARGET= rtl_Random -SHL1STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) +SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL1IMPLIB= i$(SHL1TARGET) DEF1NAME =$(SHL1TARGET) diff --git a/sal/qa/rtl/random/rtl_random.cxx b/sal/qa/rtl/random/rtl_random.cxx index 7e3c56115b33..ae3845bd16b9 100644 --- a/sal/qa/rtl/random/rtl_random.cxx +++ b/sal/qa/rtl/random/rtl_random.cxx @@ -35,7 +35,7 @@ #include <algorithm> // STL -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> #include <rtl/random.h> namespace rtl_random diff --git a/sal/qa/rtl/strings/makefile.mk b/sal/qa/rtl/strings/makefile.mk index 16abc6b7e118..8b2a62b82d13 100644 --- a/sal/qa/rtl/strings/makefile.mk +++ b/sal/qa/rtl/strings/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -49,7 +49,7 @@ SHL1OBJS := \ $(SLO)$/test_oustring_endswith.obj \ $(SLO)$/test_oustring_noadditional.obj SHL1IMPLIB := i$(SHL1TARGET) -SHL1STDLIBS := $(CPPUNITLIB) $(SALLIB) +SHL1STDLIBS := $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL1VERSIONMAP := $(PRJ)$/qa$/export.map DEF1NAME := $(SHL1TARGET) diff --git a/sal/qa/rtl/strings/test_oustring_compare.cxx b/sal/qa/rtl/strings/test_oustring_compare.cxx index a19c3360145c..582dd6a21b7a 100644 --- a/sal/qa/rtl/strings/test_oustring_compare.cxx +++ b/sal/qa/rtl/strings/test_oustring_compare.cxx @@ -31,7 +31,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sal.hxx" -#include "cppunit/simpleheader.hxx" +#include "testshl/simpleheader.hxx" #include "rtl/string.h" #include "rtl/ustring.hxx" diff --git a/sal/qa/rtl/strings/test_oustring_convert.cxx b/sal/qa/rtl/strings/test_oustring_convert.cxx index b579da99ee27..e1219c3024d6 100644 --- a/sal/qa/rtl/strings/test_oustring_convert.cxx +++ b/sal/qa/rtl/strings/test_oustring_convert.cxx @@ -31,7 +31,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sal.hxx" -#include "cppunit/simpleheader.hxx" +#include "testshl/simpleheader.hxx" #include "rtl/strbuf.hxx" #include "rtl/string.hxx" #include "rtl/ustring.hxx" diff --git a/sal/qa/rtl/strings/test_oustring_endswith.cxx b/sal/qa/rtl/strings/test_oustring_endswith.cxx index 83714ff6fe71..467878697fd2 100644 --- a/sal/qa/rtl/strings/test_oustring_endswith.cxx +++ b/sal/qa/rtl/strings/test_oustring_endswith.cxx @@ -31,7 +31,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sal.hxx" -#include "cppunit/simpleheader.hxx" +#include "testshl/simpleheader.hxx" #include "rtl/strbuf.hxx" #include "rtl/string.h" #include "rtl/string.hxx" diff --git a/sal/qa/rtl/strings/test_oustring_noadditional.cxx b/sal/qa/rtl/strings/test_oustring_noadditional.cxx index 26db4917f096..dd30871b7622 100644 --- a/sal/qa/rtl/strings/test_oustring_noadditional.cxx +++ b/sal/qa/rtl/strings/test_oustring_noadditional.cxx @@ -31,6 +31,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sal.hxx" -#include "cppunit/simpleheader.hxx" +#include "testshl/simpleheader.hxx" NOADDITIONAL; diff --git a/sal/qa/rtl/strings/test_oustringbuffer_utf32.cxx b/sal/qa/rtl/strings/test_oustringbuffer_utf32.cxx index ca05cbf514b7..71fb6def0b31 100644 --- a/sal/qa/rtl/strings/test_oustringbuffer_utf32.cxx +++ b/sal/qa/rtl/strings/test_oustringbuffer_utf32.cxx @@ -31,7 +31,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sal.hxx" -#include "cppunit/simpleheader.hxx" +#include "testshl/simpleheader.hxx" #include "rtl/ustrbuf.hxx" #include "rtl/ustring.h" #include "rtl/ustring.hxx" diff --git a/sal/qa/rtl/textenc/makefile.mk b/sal/qa/rtl/textenc/makefile.mk index c2b9a836ab3b..31f700b7b96a 100644 --- a/sal/qa/rtl/textenc/makefile.mk +++ b/sal/qa/rtl/textenc/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -47,9 +47,7 @@ CXXFLAGS+= $(LFS_CFLAGS) SHL1OBJS= \ $(SLO)$/rtl_textcvt.obj SHL1TARGET= rtl_textcvt -SHL1STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) +SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL1IMPLIB= i$(SHL1TARGET) DEF1NAME =$(SHL1TARGET) @@ -65,9 +63,7 @@ SHL1VERSIONMAP = $(PRJ)$/qa$/export.map SHL2OBJS= \ $(SLO)$/rtl_tencinfo.obj SHL2TARGET= rtl_tencinfo -SHL2STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) +SHL2STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL2IMPLIB= i$(SHL2TARGET) DEF2NAME =$(SHL2TARGET) diff --git a/sal/qa/rtl/textenc/rtl_tencinfo.cxx b/sal/qa/rtl/textenc/rtl_tencinfo.cxx index 8f5fa28defda..2bc3f930af42 100644 --- a/sal/qa/rtl/textenc/rtl_tencinfo.cxx +++ b/sal/qa/rtl/textenc/rtl_tencinfo.cxx @@ -36,7 +36,7 @@ #include <osl/thread.h> #include <rtl/tencinfo.h> -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> // ----------------------------------------------------------------------------- diff --git a/sal/qa/rtl/textenc/rtl_textcvt.cxx b/sal/qa/rtl/textenc/rtl_textcvt.cxx index 0e4a1a306949..2129815a6779 100644 --- a/sal/qa/rtl/textenc/rtl_textcvt.cxx +++ b/sal/qa/rtl/textenc/rtl_textcvt.cxx @@ -36,7 +36,7 @@ #include <cstddef> #include <cstring> -#include "cppunit/simpleheader.hxx" +#include "testshl/simpleheader.hxx" #include "rtl/string.hxx" #include "rtl/tencinfo.h" #include "rtl/textcvt.h" diff --git a/sal/qa/rtl/uri/makefile.mk b/sal/qa/rtl/uri/makefile.mk index 95ba01debd1e..2c536da484d7 100644 --- a/sal/qa/rtl/uri/makefile.mk +++ b/sal/qa/rtl/uri/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -47,9 +47,7 @@ CXXFLAGS+= $(LFS_CFLAGS) SHL1OBJS= \ $(SLO)$/rtl_Uri.obj SHL1TARGET= rtl_uri_simple -SHL1STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) +SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL1IMPLIB= i$(SHL1TARGET) DEF1NAME =$(SHL1TARGET) @@ -61,9 +59,7 @@ SHL1VERSIONMAP = $(PRJ)$/qa$/export.map SHL2OBJS= \ $(SLO)$/rtl_testuri.obj SHL2TARGET= rtl_Uri -SHL2STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) +SHL2STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL2IMPLIB= i$(SHL2TARGET) DEF2NAME =$(SHL2TARGET) diff --git a/sal/qa/rtl/uri/rtl_Uri.cxx b/sal/qa/rtl/uri/rtl_Uri.cxx index 794074e18d0f..cc27f956b573 100644 --- a/sal/qa/rtl/uri/rtl_Uri.cxx +++ b/sal/qa/rtl/uri/rtl_Uri.cxx @@ -38,7 +38,7 @@ #include <osl/thread.h> #include <osl/file.hxx> -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> // ----------------------------------------------------------------------------- diff --git a/sal/qa/rtl/uri/rtl_testuri.cxx b/sal/qa/rtl/uri/rtl_testuri.cxx index 956c5ccbaacb..4d1d80830dd3 100644 --- a/sal/qa/rtl/uri/rtl_testuri.cxx +++ b/sal/qa/rtl/uri/rtl_testuri.cxx @@ -39,7 +39,7 @@ #include "rtl/ustring.h" #include "rtl/ustring.hxx" -#include "cppunit/simpleheader.hxx" +#include "testshl/simpleheader.hxx" #include <cstddef> #include <stdio.h> diff --git a/sal/qa/rtl/uuid/makefile.mk b/sal/qa/rtl/uuid/makefile.mk index ed780dd82ec1..554c2034d0cd 100644 --- a/sal/qa/rtl/uuid/makefile.mk +++ b/sal/qa/rtl/uuid/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -45,14 +45,12 @@ CFLAGS+= $(LFS_CFLAGS) CXXFLAGS+= $(LFS_CFLAGS) # BEGIN ---------------------------------------------------------------- -# auto generated Target:joblist by codegen.pl +# auto generated Target:joblist by codegen.pl SHL1OBJS= \ $(SLO)$/rtl_Uuid.obj SHL1TARGET= rtl_Uuid -SHL1STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) +SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL1IMPLIB= i$(SHL1TARGET) # SHL1DEF= $(MISC)$/$(SHL1TARGET).def diff --git a/sal/qa/rtl/uuid/rtl_Uuid.cxx b/sal/qa/rtl/uuid/rtl_Uuid.cxx index 508a1127b60e..a77c4e8d90de 100644 --- a/sal/qa/rtl/uuid/rtl_Uuid.cxx +++ b/sal/qa/rtl/uuid/rtl_Uuid.cxx @@ -34,7 +34,7 @@ #include <math.h> #include <stdio.h> -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> #include <rtl/uuid.h> #include <rtl/ustring.h> #include <rtl/ustring.hxx> diff --git a/sal/qa/rtl_strings/makefile.mk b/sal/qa/rtl_strings/makefile.mk index 4cd99ba3aec9..166ef568debc 100644 --- a/sal/qa/rtl_strings/makefile.mk +++ b/sal/qa/rtl_strings/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -44,15 +44,13 @@ CFLAGS+= $(LFS_CFLAGS) CXXFLAGS+= $(LFS_CFLAGS) # BEGIN ---------------------------------------------------------------- -# auto generated Target:FileBase by codegen.pl +# auto generated Target:FileBase by codegen.pl SHL1OBJS= \ $(SLO)$/rtl_String_Utils.obj \ $(SLO)$/rtl_OString.obj SHL1TARGET= rtl_OString -SHL1STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) +SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL1IMPLIB= i$(SHL1TARGET) # SHL1DEF= $(MISC)$/$(SHL1TARGET).def @@ -65,15 +63,13 @@ SHL1VERSIONMAP = $(PRJ)$/qa$/export.map # END ------------------------------------------------------------------ # BEGIN ---------------------------------------------------------------- -# auto generated Target:FileBase by codegen.pl +# auto generated Target:FileBase by codegen.pl SHL2OBJS= \ $(SLO)$/rtl_String_Utils.obj \ $(SLO)$/rtl_OUString.obj SHL2TARGET= rtl_OUString -SHL2STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) +SHL2STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL2IMPLIB= i$(SHL2TARGET) # SHL2DEF= $(MISC)$/$(SHL2TARGET).def @@ -86,22 +82,13 @@ SHL2VERSIONMAP = $(PRJ)$/qa$/export.map # END ------------------------------------------------------------------ # BEGIN ---------------------------------------------------------------- -# auto generated Target:FileBase by codegen.pl +# auto generated Target:FileBase by codegen.pl SHL3OBJS= \ $(SLO)$/rtl_String_Utils.obj \ $(SLO)$/rtl_OUStringBuffer.obj SHL3TARGET= rtl_OUStringBuffer -SHL3STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) - -# .IF "$(GUI)" == "WNT" -# SHL3STDLIBS+= $(SOLARLIBDIR)$/cppunit.lib -# .ENDIF -# .IF "$(GUI)" == "UNX" -# SHL3STDLIBS+=$(SOLARLIBDIR)$/libcppunit$(DLLPOSTFIX).a -# .ENDIF +SHL3STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL3IMPLIB= i$(SHL3TARGET) # SHL3DEF= $(MISC)$/$(SHL3TARGET).def @@ -115,12 +102,10 @@ SHL3VERSIONMAP = $(PRJ)$/qa$/export.map # BEGIN ---------------------------------------------------------------- SHL4OBJS= \ - $(SLO)$/rtl_old_teststrbuf.obj + $(SLO)$/rtl_old_teststrbuf.obj SHL4TARGET= rtl_old_teststrbuf -SHL4STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) +SHL4STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL4IMPLIB= i$(SHL4TARGET) DEF4NAME =$(SHL4TARGET) @@ -130,12 +115,10 @@ SHL4VERSIONMAP = $(PRJ)$/qa$/export.map # BEGIN ---------------------------------------------------------------- SHL5OBJS= \ - $(SLO)$/rtl_old_testowstring.obj + $(SLO)$/rtl_old_testowstring.obj SHL5TARGET= rtl_old_testowstring -SHL5STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) +SHL5STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL5IMPLIB= i$(SHL5TARGET) DEF5NAME =$(SHL5TARGET) @@ -145,12 +128,10 @@ SHL5VERSIONMAP = $(PRJ)$/qa$/export.map # BEGIN ---------------------------------------------------------------- SHL6OBJS= \ - $(SLO)$/rtl_old_testostring.obj + $(SLO)$/rtl_old_testostring.obj SHL6TARGET= rtl_old_testostring -SHL6STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) +SHL6STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL6IMPLIB= i$(SHL6TARGET) DEF6NAME =$(SHL6TARGET) diff --git a/sal/qa/rtl_strings/rtl_old_testostring.cxx b/sal/qa/rtl_strings/rtl_old_testostring.cxx index 6c481914127d..329eb71c7dc5 100644 --- a/sal/qa/rtl_strings/rtl_old_testostring.cxx +++ b/sal/qa/rtl_strings/rtl_old_testostring.cxx @@ -48,7 +48,7 @@ #include <rtl/string.hxx> #endif -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> #define TEST_ENSURE(c, m) CPPUNIT_ASSERT_MESSAGE((m), (c)) diff --git a/sal/qa/rtl_strings/rtl_old_testowstring.cxx b/sal/qa/rtl_strings/rtl_old_testowstring.cxx index 6741deb06e84..938ec01f5fff 100644 --- a/sal/qa/rtl_strings/rtl_old_testowstring.cxx +++ b/sal/qa/rtl_strings/rtl_old_testowstring.cxx @@ -61,7 +61,7 @@ #include <rtl/locale.hxx> -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> #define TEST_ENSURE(c, m) CPPUNIT_ASSERT_MESSAGE((m), (c)) // #if OSL_DEBUG_LEVEL > 0 diff --git a/sal/qa/rtl_strings/rtl_old_teststrbuf.cxx b/sal/qa/rtl_strings/rtl_old_teststrbuf.cxx index 7f6a54478697..c277517d57b2 100644 --- a/sal/qa/rtl_strings/rtl_old_teststrbuf.cxx +++ b/sal/qa/rtl_strings/rtl_old_teststrbuf.cxx @@ -53,7 +53,7 @@ #include <rtl/ustrbuf.hxx> #endif -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> using namespace rtl; diff --git a/sal/qa/sal/makefile.mk b/sal/qa/sal/makefile.mk index ebf7aa314ab7..61f279e226eb 100644 --- a/sal/qa/sal/makefile.mk +++ b/sal/qa/sal/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -39,7 +39,7 @@ ENABLE_EXCEPTIONS := TRUE SHL1TARGET = $(TARGET)_types SHL1OBJS = $(SLO)$/test_types.obj -SHL1STDLIBS = $(CPPUNITLIB) $(SALLIB) +SHL1STDLIBS = $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL1VERSIONMAP = version.map SHL1IMPLIB = i$(SHL1TARGET) DEF1NAME = $(SHL1TARGET) diff --git a/sal/qa/sal/test_types.cxx b/sal/qa/sal/test_types.cxx index fff05cb08106..5d72175bb8db 100644 --- a/sal/qa/sal/test_types.cxx +++ b/sal/qa/sal/test_types.cxx @@ -35,7 +35,7 @@ #include <stdio.h> // C99 snprintf not necessarily in <cstdio> #include <string.h> // wntmsci10 does not know <cstring> std::strcmp -#include "cppunit/simpleheader.hxx" +#include "testshl/simpleheader.hxx" #include "sal/types.h" namespace { diff --git a/sal/qa/systools/makefile.mk b/sal/qa/systools/makefile.mk index cde5b71c215c..035bef25c34a 100644 --- a/sal/qa/systools/makefile.mk +++ b/sal/qa/systools/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -47,15 +47,12 @@ CXXFLAGS+= $(LFS_CFLAGS) CFLAGS+=/Ob0 # BEGIN ---------------------------------------------------------------- -# auto generated Target:joblist by codegen.pl +# auto generated Target:joblist by codegen.pl SHL1OBJS= \ $(SLO)$/test_comtools.obj SHL1TARGET= test_comtools -SHL1STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB)\ - uuid.lib +SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) uuid.lib SHL1IMPLIB= i$(SHL1TARGET) # SHL1DEF= $(MISC)$/$(SHL1TARGET).def diff --git a/sal/qa/systools/test_comtools.cxx b/sal/qa/systools/test_comtools.cxx index 1957d62d54f2..c61ff435d235 100644 --- a/sal/qa/systools/test_comtools.cxx +++ b/sal/qa/systools/test_comtools.cxx @@ -33,7 +33,7 @@ #include "precompiled_sal.hxx" // autogenerated file with codegen.pl -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> #include <systools/win32/comtools.hxx> class COMObject : public IUnknown diff --git a/sal/qa/testHelperFunctions/makefile.mk b/sal/qa/testHelperFunctions/makefile.mk index 0064cabef952..33c43f259081 100644 --- a/sal/qa/testHelperFunctions/makefile.mk +++ b/sal/qa/testHelperFunctions/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -49,9 +49,7 @@ SHL1OBJS= \ $(SLO)$/testHelperFunctions2.obj SHL1TARGET= testHelperFunctions -SHL1STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) +SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL1IMPLIB= i$(SHL1TARGET) DEF1NAME =$(SHL1TARGET) diff --git a/sal/qa/testHelperFunctions/testHelperFunctions.cxx b/sal/qa/testHelperFunctions/testHelperFunctions.cxx index 9272433d2e1f..9d96d91939ec 100644 --- a/sal/qa/testHelperFunctions/testHelperFunctions.cxx +++ b/sal/qa/testHelperFunctions/testHelperFunctions.cxx @@ -38,7 +38,7 @@ #include "stringhelper.hxx" -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> // void isJaBloed() // { diff --git a/sal/qa/testHelperFunctions/testHelperFunctions2.cxx b/sal/qa/testHelperFunctions/testHelperFunctions2.cxx index 9ddc1031d7fa..1adae36ade2a 100644 --- a/sal/qa/testHelperFunctions/testHelperFunctions2.cxx +++ b/sal/qa/testHelperFunctions/testHelperFunctions2.cxx @@ -31,7 +31,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sal.hxx" -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> #include "stringhelper.hxx" namespace testOfHelperFunctions diff --git a/sal/rtl/source/logfile.cxx b/sal/rtl/source/logfile.cxx index 9bd0a939513b..476dea11393d 100644 --- a/sal/rtl/source/logfile.cxx +++ b/sal/rtl/source/logfile.cxx @@ -250,3 +250,8 @@ extern "C" void SAL_CALL rtl_logfile_longTrace(char const * format, ...) { va_end(args); } } + +extern "C" sal_Bool SAL_CALL rtl_logfile_hasLogFile( void ) { + init(); + return g_buffer != 0; +} diff --git a/sal/rtl/source/macro.hxx b/sal/rtl/source/macro.hxx index a007d9e1cdab..2f0b723d236a 100644 --- a/sal/rtl/source/macro.hxx +++ b/sal/rtl/source/macro.hxx @@ -94,6 +94,8 @@ this is inserted for the case that the preprocessor ignores error # define THIS_ARCH "IA64" #elif defined M68K # define THIS_ARCH "M68K" +#elif defined HPPA +# define THIS_ARCH "HPPA" #endif #if ! defined THIS_ARCH diff --git a/sal/rtl/source/math.cxx b/sal/rtl/source/math.cxx index 3f41d5a9c105..a255ca21b13a 100644 --- a/sal/rtl/source/math.cxx +++ b/sal/rtl/source/math.cxx @@ -79,6 +79,130 @@ static double getN10Exp( int nExp ) return 1.0; } +/** Approximation algorithm for erf for 0 < x < 0.65. */ +void lcl_Erf0065( double x, double& fVal ) +{ + static const double pn[] = { + 1.12837916709551256, + 1.35894887627277916E-1, + 4.03259488531795274E-2, + 1.20339380863079457E-3, + 6.49254556481904354E-5 + }; + static const double qn[] = { + 1.00000000000000000, + 4.53767041780002545E-1, + 8.69936222615385890E-2, + 8.49717371168693357E-3, + 3.64915280629351082E-4 + }; + double fPSum = 0.0; + double fQSum = 0.0; + double fXPow = 1.0; + for ( unsigned int i = 0; i <= 4; ++i ) + { + fPSum += pn[i]*fXPow; + fQSum += qn[i]*fXPow; + fXPow *= x*x; + } + fVal = x * fPSum / fQSum; +} + +/** Approximation algorithm for erfc for 0.65 < x < 6.0. */ +void lcl_Erfc0600( double x, double& fVal ) +{ + double fPSum = 0.0; + double fQSum = 0.0; + double fXPow = 1.0; + const double *pn; + const double *qn; + + if ( x < 2.2 ) + { + static const double pn22[] = { + 9.99999992049799098E-1, + 1.33154163936765307, + 8.78115804155881782E-1, + 3.31899559578213215E-1, + 7.14193832506776067E-2, + 7.06940843763253131E-3 + }; + static const double qn22[] = { + 1.00000000000000000, + 2.45992070144245533, + 2.65383972869775752, + 1.61876655543871376, + 5.94651311286481502E-1, + 1.26579413030177940E-1, + 1.25304936549413393E-2 + }; + pn = pn22; + qn = qn22; + } + else /* if ( x < 6.0 ) this is true, but the compiler does not know */ + { + static const double pn60[] = { + 9.99921140009714409E-1, + 1.62356584489366647, + 1.26739901455873222, + 5.81528574177741135E-1, + 1.57289620742838702E-1, + 2.25716982919217555E-2 + }; + static const double qn60[] = { + 1.00000000000000000, + 2.75143870676376208, + 3.37367334657284535, + 2.38574194785344389, + 1.05074004614827206, + 2.78788439273628983E-1, + 4.00072964526861362E-2 + }; + pn = pn60; + qn = qn60; + } + + for ( unsigned int i = 0; i < 6; ++i ) + { + fPSum += pn[i]*fXPow; + fQSum += qn[i]*fXPow; + fXPow *= x; + } + fQSum += qn[6]*fXPow; + fVal = exp( -1.0*x*x )* fPSum / fQSum; +} + +/** Approximation algorithm for erfc for 6.0 < x < 26.54 (but used for all + x > 6.0). */ +void lcl_Erfc2654( double x, double& fVal ) +{ + static const double pn[] = { + 5.64189583547756078E-1, + 8.80253746105525775, + 3.84683103716117320E1, + 4.77209965874436377E1, + 8.08040729052301677 + }; + static const double qn[] = { + 1.00000000000000000, + 1.61020914205869003E1, + 7.54843505665954743E1, + 1.12123870801026015E2, + 3.73997570145040850E1 + }; + + double fPSum = 0.0; + double fQSum = 0.0; + double fXPow = 1.0; + + for ( unsigned int i = 0; i <= 4; ++i ) + { + fPSum += pn[i]*fXPow; + fQSum += qn[i]*fXPow; + fXPow /= x*x; + } + fVal = exp(-1.0*x*x)*fPSum / (x*fQSum); +} namespace { @@ -991,3 +1115,129 @@ double SAL_CALL rtl_math_atanh( double fValue ) SAL_THROW_EXTERN_C() { return 0.5 * rtl_math_log1p( 2.0 * fValue / (1.0-fValue) ); } + + +/** Parent error function (erf) that calls different algorithms based on the + value of x. It takes care of cases where x is negative as erf is an odd + function i.e. erf(-x) = -erf(x). + + Kramer, W., and Blomquist, F., 2000, Algorithms with Guaranteed Error Bounds + for the Error Function and the Complementary Error Function + + http://www.math.uni-wuppertal.de/wrswt/literatur_en.html + + @author Kohei Yoshida <kohei@openoffice.org> + + @see #i55735# + */ +double SAL_CALL rtl_math_erf( double x ) SAL_THROW_EXTERN_C() +{ + if( x == 0.0 ) + return 0.0; + + bool bNegative = false; + if ( x < 0.0 ) + { + x = fabs( x ); + bNegative = true; + } + + double fErf = 1.0; + if ( x < 1.0e-10 ) + fErf = (double) (x*1.1283791670955125738961589031215452L); + else if ( x < 0.65 ) + lcl_Erf0065( x, fErf ); + else + fErf = 1.0 - rtl_math_erfc( x ); + + if ( bNegative ) + fErf *= -1.0; + + return fErf; +} + + +/** Parent complementary error function (erfc) that calls different algorithms + based on the value of x. It takes care of cases where x is negative as erfc + satisfies relationship erfc(-x) = 2 - erfc(x). See the comment for Erf(x) + for the source publication. + + @author Kohei Yoshida <kohei@openoffice.org> + + @see #i55735#, moved from module scaddins (#i97091#) + + */ +double SAL_CALL rtl_math_erfc( double x ) SAL_THROW_EXTERN_C() +{ + if ( x == 0.0 ) + return 1.0; + + bool bNegative = false; + if ( x < 0.0 ) + { + x = fabs( x ); + bNegative = true; + } + + double fErfc = 0.0; + if ( x >= 0.65 ) + { + if ( x < 6.0 ) + lcl_Erfc0600( x, fErfc ); + else + lcl_Erfc2654( x, fErfc ); + } + else + fErfc = 1.0 - rtl_math_erf( x ); + + if ( bNegative ) + fErfc = 2.0 - fErfc; + + return fErfc; +} + +/** improved accuracy of asinh for |x| large and for x near zero + @see #i97605# + */ +double SAL_CALL rtl_math_asinh( double fX ) SAL_THROW_EXTERN_C() +{ + double fSign = 1.0; + if ( fX == 0.0 ) + return 0.0; + else + { + if ( fX < 0.0 ) + { + fX = - fX; + fSign = -1.0; + } + if ( fX < 0.125 ) + return fSign * rtl_math_log1p( fX + fX*fX / (1.0 + sqrt( 1.0 + fX*fX))); + else if ( fX < 1.25e7 ) + return fSign * log( fX + sqrt( 1.0 + fX*fX)); + else + return fSign * log( 2.0*fX); + } +} + +/** improved accuracy of acosh for x large and for x near 1 + @see #i97605# + */ +double SAL_CALL rtl_math_acosh( double fX ) SAL_THROW_EXTERN_C() +{ + volatile double fZ = fX - 1.0; + if ( fX < 1.0 ) + { + double fResult; + ::rtl::math::setNan( &fResult ); + return fResult; + } + else if ( fX == 1.0 ) + return 0.0; + else if ( fX < 1.1 ) + return rtl_math_log1p( fZ + sqrt( fZ*fZ + 2.0*fZ)); + else if ( fX < 1.25e7 ) + return log( fX + sqrt( fX*fX - 1.0)); + else + return log( 2.0*fX); +} diff --git a/sal/systools/win32/uwinapi/makefile.mk b/sal/systools/win32/uwinapi/makefile.mk index 1e6c419a0c92..52a8561588c2 100644 --- a/sal/systools/win32/uwinapi/makefile.mk +++ b/sal/systools/win32/uwinapi/makefile.mk @@ -48,7 +48,6 @@ CXXFLAGS+= $(LFS_CFLAGS) .IF "$(GUI)"=="WNT" .IF "$(COM)"=="GCC" -CDEFS+=-UWINVER -DWINVER=0x0500 CFLAGSCXX+=-Wno-unused-parameter -Wno-return-type .ENDIF @@ -143,7 +142,9 @@ STDSHL= .IF "$(COM)"=="GCC" SHL1STDLIBS=\ -lmingw32 \ - -lgcc + $(MINGW_LIBGCC) +MINGWSSTDOBJ= +MINGWSSTDENDOBJ= .ELSE SHL1STDLIBS=\ unicows.lib diff --git a/sal/typesconfig/typesconfig.c b/sal/typesconfig/typesconfig.c index 932d80fd979a..c9d6ede62cb7 100644 --- a/sal/typesconfig/typesconfig.c +++ b/sal/typesconfig/typesconfig.c @@ -163,7 +163,7 @@ int check( TestFunc func, Type eT, void* p ) |* Letzte Aenderung |* *************************************************************************/ -#if defined(IA64) || defined(ARM32) +#if defined(IA64) || defined(ARM32) || defined(HPPA) int forceerror() { diff --git a/sal/util/makefile.mk b/sal/util/makefile.mk index f56e6f88f058..bc8026aa860f 100644 --- a/sal/util/makefile.mk +++ b/sal/util/makefile.mk @@ -113,6 +113,10 @@ SHL1STDLIBS= \ $(COMDLG32LIB)\ $(USER32LIB)\ $(OLE32LIB) +.IF "$(COM)"=="GCC" +MINGWSSTDOBJ= +MINGWSSTDENDOBJ= +.ENDIF .ENDIF # WNT .IF "$(GUI)"=="UNX" diff --git a/sal/util/sal.map b/sal/util/sal.map index 03af5c114aa1..d5faa563ae3f 100755 --- a/sal/util/sal.map +++ b/sal/util/sal.map @@ -588,6 +588,15 @@ UDK_3.9 { # OOo 3.1 rtl_math_atanh; } UDK_3.8; +UDK_3.10 { # OOo 3.2 + global: + rtl_logfile_hasLogFile; + rtl_math_erf; + rtl_math_erfc; + rtl_math_asinh; + rtl_math_acosh; +} UDK_3.9; + PRIVATE_1.0 { global: osl_detail_ObjectRegistry_storeAddresses; diff --git a/sal/workben/makefile.mk b/sal/workben/makefile.mk index 05afbbb223ea..5f20dd07bd4a 100644 --- a/sal/workben/makefile.mk +++ b/sal/workben/makefile.mk @@ -35,9 +35,10 @@ PRJNAME=sal TARGET=workben LIBTARGET=NO TARGETTYPE=CUI -ENABLE_EXCEPTIONS=TRUE +#ENABLE_EXCEPTIONS=TRUE +NO_DEFAULT_STL=YES -TESTAPP=test_osl_getVolInfo +#TESTAPP=test_osl_getVolInfo #TESTAPP=test_osl_joinProcess #TESTAPP=getlocaleinfotest #TESTAPP=test_osl_joinProcess @@ -45,6 +46,7 @@ TESTAPP=test_osl_getVolInfo #TESTAPP=salstattest #TESTAPP=saldyntest +TESTAPP=t_readline #TESTAPP=t_cipher #TESTAPP=t_digest #TESTAPP=t_random @@ -174,6 +176,23 @@ DEF1EXPORTFILE=export.exp .ENDIF # salstattest # +# t_readline +# +.IF "$(TESTAPP)" == "t_readline" + +CFILES= t_readline.c +OBJFILES= $(OBJ)$/t_readline.obj + +APP1TARGET= t_readline +APP1OBJS= $(OBJFILES) +APP1STDLIBS=$(SALLIB) +APP1DEPN= $(SLB)$/sal.lib + +APP1RPATH=UREBIN + +.ENDIF # t_readline + +# # t_cipher # .IF "$(TESTAPP)" == "t_cipher" diff --git a/sal/workben/t_layer.c b/sal/workben/t_layer.c deleted file mode 100644 index 5ceeb7ce21e3..000000000000 --- a/sal/workben/t_layer.c +++ /dev/null @@ -1,314 +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: t_layer.c,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. - * - ************************************************************************/ - -#include <sal/types.h> -#include <rtl/alloc.h> -#include <osl/diagnose.h> -#include <osl/interlck.h> -#ifndef _OSL_ISOCKET_H_ -#include <osl/isocket.h> -#endif - -/*======================================================================== - * - * osl/debug.c - * - *======================================================================*/ -/* - * __osl_debug_create. - */ -static oslSocketResult SAL_CALL __osl_debug_create ( - oslSocketDescriptor *socket, - oslAddrFamily family, - oslSocketType type, - oslProtocol protocol) -{ - oslSocketResult result; - - if (!(socket->m_lower)) - { - oslSocketDescriptor *lower; - lower = osl_socket_createSocketLayer (osl_socket_getSocketMethods()); - osl_socket_pushSocketLayer (socket, lower); - } - - result = (socket->m_lower->m_methods->m_create)( - socket->m_lower, family, type, protocol); - if (!(result == osl_Socket_Ok)) - return (result); - - if (!(socket->m_private)) - { - /* ... */ - } - return (osl_Socket_Ok); -} - -/* - * __osl_debug_delete. - */ -static void SAL_CALL __osl_debug_delete (oslSocketDescriptor *socket) -{ - if (socket->m_private) - { - /* ... */ - } - if (socket->m_lower) - { - (socket->m_lower->m_methods->m_delete)(socket->m_lower); - osl_socket_deleteSocketLayer (socket->m_lower); - } -} - -/* - * __osl_debug_getOption. - */ -static oslSocketResult SAL_CALL __osl_debug_getOption ( - oslSocketDescriptor *socket, - oslSocketOptionLevel level, - oslSocketOption option, - void *buffer, - sal_uInt32 length) -{ - if (level == osl_Socket_LevelSocketLayer) - { - /* ... */ - return (osl_Socket_Ok); - } - - return (socket->m_lower->m_methods->m_getoption)( - socket->m_lower, level, option, buffer, length); -} - -/* - * __osl_debug_setOption. - */ -static oslSocketResult SAL_CALL __osl_debug_setOption ( - oslSocketDescriptor *socket, - oslSocketOptionLevel level, - oslSocketOption option, - const void *buffer, - sal_uInt32 length) -{ - if (level == osl_Socket_LevelSocketLayer) - { - /* ... */ - return (osl_Socket_Ok); - } - - return (socket->m_lower->m_methods->m_setoption)( - socket->m_lower, level, option, buffer, length); -} - -/* - * __osl_debug_accept. - */ -static oslSocketDescriptor* SAL_CALL __osl_debug_accept ( - oslSocketDescriptor *socket, oslSocketAddr *fromaddr) -{ - oslSocketDescriptor *lower; - lower = (socket->m_lower->m_methods->m_accept)(socket->m_lower, fromaddr); - if (lower) - { - oslSocketDescriptor *upper; - upper = osl_socket_createSocketLayer (socket->m_methods); - osl_socket_pushSocketLayer (upper, lower); - return (upper); - } - return ((oslSocketDescriptor*)NULL); -} - -/* - * __osl_debug_connect. - */ -static oslSocketResult SAL_CALL __osl_debug_connect ( - oslSocketDescriptor *socket, oslSocketAddr addr) -{ - return (socket->m_lower->m_methods->m_connect)(socket->m_lower, addr); -} - -/* - * __osl_debug_close. - */ -static void SAL_CALL __osl_debug_close (oslSocketDescriptor *socket) -{ - (socket->m_lower->m_methods->m_close)(socket->m_lower); -} - -/* - * __osl_shutdown. - */ -static void SAL_CALL __osl_debug_shutdown ( - oslSocketDescriptor *socket, oslSocketDirection direction) -{ - (socket->m_lower->m_methods->m_shutdown)(socket->m_lower, direction); -} - -/* - * __osl_debug_methods. - */ -static oslSocketMethods __osl_debug_methods = -{ - NULL /* initialized on demand */ -}; - -/* - * osl_debug_getSocketMethods. - */ -const oslSocketMethods* SAL_CALL osl_debug_getSocketMethods (void) -{ - static oslInterlockedCount nonce = 0; - if (osl_incrementInterlockedCount (&nonce) == 1) - { - const oslSocketMethods *methods = osl_socket_getDefaultSocketMethods(); - __osl_debug_methods = *methods; - - __osl_debug_methods.m_create = __osl_debug_create; - __osl_debug_methods.m_delete = __osl_debug_delete; - - __osl_debug_methods.m_getoption = __osl_debug_getOption; - __osl_debug_methods.m_setoption = __osl_debug_setOption; - - __osl_debug_methods.m_accept = __osl_debug_accept; - __osl_debug_methods.m_connect = __osl_debug_connect; - __osl_debug_methods.m_close = __osl_debug_close; - - __osl_debug_methods.m_shutdown = __osl_debug_shutdown; - - osl_incrementInterlockedCount (&nonce); - } - - osl_decrementInterlockedCount (&nonce); - return (&__osl_debug_methods); -} - -/*======================================================================== - * - * osl/socket.c (physical, bottom layer). - * - *======================================================================*/ -#if 0 /* NYI */ - -static oslSocketResult SAL_CALL __osl_socket_create ( - oslSocketDescriptor *socket, - oslAddrFamily family, - oslSocketType type, - oslProtocol protocol) -{ -#if OSL_DEBUG_LEVEL > 1 - const oslSocketMethods *debug = osl_debug_getSocketMethods(); - if (!(socket->m_upper || socket->m_upper->m_methods == debug)) - { - oslSocketDescriptor *upper; - - upper = osl_socket_createSocketLayer (debug); - osl_socket_pushSocketLayer (upper, socket); - - return (upper->m_methods->m_create)(upper, family, type, protocol); - } -#endif /* OSL_DEBUG_LEVEL */ - if (!(socket->m_private)) - { - /* ... */ - socket->m_private = osl_createSocket (family, type, protocol); - } - return (osl_Socket_Ok); -} - -#endif /* NYI */ - -/*======================================================================== - * - * main. - * - *======================================================================*/ -int SAL_CALL main (int argc, char **argv) -{ - oslSocketDescriptor *socket; - - socket = osl_socket_createSocketLayer (osl_debug_getSocketMethods()); - if (socket) - { - oslSocketDescriptor *connection; - oslSocketResult result; - oslSocketAddr addr, from; - sal_Int32 option = 1; - - result = osl_socket_create ( - socket, - osl_Socket_FamilyInet, - osl_Socket_TypeStream, - osl_Socket_ProtocolIp); - OSL_ASSERT(result == osl_Socket_Ok); - - result = osl_socket_setOption ( - socket, - osl_Socket_LevelSocket, - osl_Socket_OptionReuseAddr, - &option, sizeof(option)); - OSL_ASSERT(result == osl_Socket_Ok); - - addr = osl_createEmptySocketAddr (osl_Socket_FamilyInet); - osl_setInetPortOfSocketAddr (addr, 7777); - - result = osl_socket_bind (socket, addr); - OSL_ASSERT(result == osl_Socket_Ok); - - result = osl_socket_listen (socket, 1); - OSL_ASSERT(result == osl_Socket_Ok); - - connection = osl_socket_accept (socket, &from); - if (connection) - { - sal_Char buffer[1024]; - sal_Int32 k, n = sizeof(buffer); - oslSocketMsgFlag flag = osl_Socket_MsgNormal; - - while ((k = osl_socket_recv (connection, buffer, n, flag)) > 0) - { - if (osl_socket_send (connection, buffer, k, flag) < 0) - break; - } - - osl_socket_close (connection); - osl_socket_delete (connection); - - osl_socket_deleteSocketLayer (connection); - } - - osl_socket_close (socket); - osl_socket_delete (socket); - - osl_socket_deleteSocketLayer (socket); - } - - return 0; -} - diff --git a/sal/workben/t_readline.c b/sal/workben/t_readline.c new file mode 100644 index 000000000000..9cbc7d39cf20 --- /dev/null +++ b/sal/workben/t_readline.c @@ -0,0 +1,58 @@ +/* + * t_readline.c + */ + +#include "osl/file.h" + +#include "osl/diagnose.h" +#include "rtl/ustring.h" +#include "rtl/byteseq.h" + +#include <stdio.h> + +/* main */ +int main (int argc, char ** argv) +{ + if (argc > 1) + { + oslFileError result; + oslFileHandle hFile = 0; + + rtl_uString * pSystemPath = 0; + rtl_uString * pFileUrl = 0; + + rtl_uString_newFromAscii (&pSystemPath, argv[1]); + + result = osl_getFileURLFromSystemPath (pSystemPath, &pFileUrl); + rtl_uString_release (pSystemPath), pSystemPath = 0; + if (result != osl_File_E_None) + return (result); + + result = osl_openFile (pFileUrl, &hFile, osl_File_OpenFlag_Read); + rtl_uString_release (pFileUrl), pFileUrl = 0; + if (result == osl_File_E_None) + { + sal_Sequence * pBuffer = 0; + for ( ;; ) + { + sal_Int32 i, n; + + result = osl_readLine (hFile, &pBuffer); + if (result != osl_File_E_None) + break; +#if 0 + if (pBuffer->elements[0] == 0) + /* @@@ cannot distinguish empty line from EOF @@@ */ + break; +#endif + for (i = 0, n = pBuffer->nElements; i < n; i++) + printf ("%c", (char)(pBuffer->elements[i])); + printf("\n"); + } + + rtl_byte_sequence_release (pBuffer), pBuffer = 0; + (void) osl_closeFile (hFile); + } + } + return 0; +} diff --git a/sal/workben/t_tls.c b/sal/workben/t_tls.c deleted file mode 100644 index 2f82bee0a11f..000000000000 --- a/sal/workben/t_tls.c +++ /dev/null @@ -1,257 +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: t_tls.c,v $ - * $Revision: 1.5 $ - * - * 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 <sal/types.h> -#include <rtl/alloc.h> -#include <rtl/ustring.h> -#include <osl/diagnose.h> -#include <osl/file.h> -#include <osl/interlck.h> -#ifndef _OSL_ISOCKET_H_ -#include <osl/isocket.h> -#endif - -#ifndef _OSL_TLS_H_ -#include <osl/tls.h> -#endif - -#include <string.h> -#include <stdio.h> - -/*======================================================================== - * - * Internals. - * - *======================================================================*/ -void SAL_CALL __rtl_sequence_release (sal_Sequence *value) -{ - if (value) - { - if (osl_decrementInterlockedCount (&(value->nRefCount)) == 0) - rtl_freeMemory (value); - } -} - -void SAL_CALL __rtl_sequence_new (sal_Sequence **value, sal_Int32 length) -{ - if (value) - { - __rtl_sequence_release (*value); - - *value = (sal_Sequence*)rtl_allocateMemory ( - SAL_SEQUENCE_HEADER_SIZE + length); - - (*value)->nRefCount = 1; - (*value)->nElements = 0; - } -} - -void load_sequence (sal_Sequence **ppSequence, const sal_Char *name) -{ - oslFileError result; - rtl_uString *pName, *pPath; - - if (ppSequence) - { - __rtl_sequence_release (*ppSequence); - *ppSequence = NULL; - } - - pName = NULL; - rtl_uString_newFromAscii (&pName, name); - - pPath = NULL; - result = osl_searchNormalizedPath (pName, NULL, &pPath); - if (result == osl_File_E_None) - { - oslFileHandle hFile; - - result = osl_openFile (pPath, &hFile, osl_File_OpenFlag_Read); - if (result == osl_File_E_None) - { - sal_uInt64 nSize = 0, nRead = 0; - - osl_setFilePos (hFile, osl_Pos_End, 0); - osl_getFilePos (hFile, &nSize); - osl_setFilePos (hFile, osl_Pos_Absolut, 0); - - __rtl_sequence_new (ppSequence, (sal_Int32)nSize); - - osl_readFile (hFile, (*ppSequence)->elements, nSize, &nRead); - (*ppSequence)->nElements = (sal_Int32)nRead; - } - osl_closeFile (hFile); - - rtl_uString_release (pPath); - } - - rtl_uString_release (pName); -} - -/*======================================================================== - * - * main. - * - *======================================================================*/ -int SAL_CALL main (int argc, char **argv) -{ - static const sal_Char p[] = "GET / HTTP/1.0\015\012\015\012"; - oslSocketDescriptor *socket; - - - socket = osl_socket_createSocketLayer (osl_tls_getSocketMethods()); - if (socket) - { - oslSocketAddr target; - oslSocketResult result; - oslSocketMsgFlag flag = osl_Socket_MsgNormal; - rtl_uString *dotted = NULL; - - - rtl_uString_newFromAscii (&dotted, argv[1]); - target = osl_createInetSocketAddr (dotted, 443); - rtl_uString_release (dotted); - - result = osl_socket_create ( - socket, - osl_Socket_FamilyInet, - osl_Socket_TypeStream, - osl_Socket_ProtocolIp); - OSL_ASSERT(result == osl_Socket_Ok); - - result = osl_socket_connect (socket, target); - osl_destroySocketAddr (target); - OSL_ASSERT(result == osl_Socket_Ok); - - result = osl_socket_connect_handshake (socket, target); - OSL_ASSERT(result == osl_Socket_Ok); - - if (osl_socket_send (socket, p, strlen(p), flag) > 0) - { - sal_Char buffer[1024]; - sal_Int32 k, n = sizeof(buffer); - - while ((k = osl_socket_recv (socket, buffer, n, flag)) > 0) - fwrite (buffer, 1, k, stdout); - } - - osl_socket_shutdown (socket, osl_Socket_DirReadWrite); - osl_socket_close (socket); - - osl_socket_delete (socket); - osl_socket_deleteSocketLayer (socket); - } - - - socket = osl_socket_createSocketLayer (osl_tls_getSocketMethods()); - if (socket) - { - oslSocketDescriptor *connection; - oslSocketResult result; - oslSocketAddr addr, from; - sal_Int32 option = 1; - sal_Sequence *data = NULL; - - - result = osl_socket_create ( - socket, - osl_Socket_FamilyInet, - osl_Socket_TypeStream, - osl_Socket_ProtocolIp); - OSL_ASSERT(result == osl_Socket_Ok); - - result = osl_socket_setOption ( - socket, - osl_Socket_LevelSocket, - osl_Socket_OptionReuseAddr, - &option, sizeof(option)); - OSL_ASSERT(result == osl_Socket_Ok); - - addr = osl_createEmptySocketAddr (osl_Socket_FamilyInet); - osl_setInetPortOfSocketAddr (addr, 7777); - - result = osl_socket_bind (socket, addr); - OSL_ASSERT(result == osl_Socket_Ok); - - load_sequence (&data, "s_cert.der"); - if (data && data->nElements) - { - result = osl_socket_setOption ( - socket, - osl_Socket_LevelTLS, - osl_Socket_OptionCertificate, - data->elements, data->nElements); - OSL_ASSERT(result == osl_Socket_Ok); - } - - load_sequence (&data, "s_pkey.der"); - if (data && data->nElements) - { - result = osl_socket_setOption ( - socket, - osl_Socket_LevelTLS, - osl_Socket_OptionPrivateKey, - data->elements, data->nElements); - OSL_ASSERT(result == osl_Socket_Ok); - } - __rtl_sequence_release (data); - - result = osl_socket_listen (socket, 1); - OSL_ASSERT(result == osl_Socket_Ok); - - connection = osl_socket_accept (socket, &from); - if (connection) - { - sal_Char buffer[1024]; - sal_Int32 k, n = sizeof(buffer); - oslSocketMsgFlag flag = osl_Socket_MsgNormal; - - result = osl_socket_accept_handshake (connection, from); - OSL_ASSERT(result == osl_Socket_Ok); - - while ((k = osl_socket_recv (connection, buffer, n, flag)) > 0) - { - if (osl_socket_send (connection, buffer, k, flag) < 0) - break; - } - - osl_socket_close (connection); - - osl_socket_delete (connection); - osl_socket_deleteSocketLayer (connection); - } - - osl_socket_delete (socket); - osl_socket_deleteSocketLayer (socket); - } - - return 0; -} - diff --git a/sal/workben/t_zip.c b/sal/workben/t_zip.c deleted file mode 100644 index 42bb819f0256..000000000000 --- a/sal/workben/t_zip.c +++ /dev/null @@ -1,183 +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: t_zip.c,v $ - * $Revision: 1.5 $ - * - * 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 <sal/types.h> -#include <rtl/ustring.h> -#include <osl/diagnose.h> -#include <osl/thread.h> -#ifndef _OSL_ZSOCKET_H_ -#include <osl/zsocket.h> -#endif - -#include <stdio.h> - -/*======================================================================== - * - * internals. - * - *======================================================================*/ -void SAL_CALL clientSocketReader (void *pData) -{ - oslSocketDescriptor *socket; - - socket = (oslSocketDescriptor*)pData; - if (socket) - { - sal_Char buffer[128]; - sal_Int32 k, n = sizeof(buffer); - oslSocketMsgFlag flag = osl_Socket_MsgNormal; - - while ((k = osl_socket_recv (socket, buffer, n, flag)) > 0) - { - fwrite (buffer, 1, k, stdout); - fflush (stdout); - } - } -} - -/*======================================================================== - * - * main. - * - *======================================================================*/ -int SAL_CALL main (int argc, char **argv) -{ - oslSocketDescriptor *socket; - - socket = osl_socket_createSocketLayer (osl_zlib_getSocketMethods()); - if (socket) - { - oslSocketAddr addr = 0; - oslSocketResult result; - - result = osl_socket_create ( - socket, - osl_Socket_FamilyInet, - osl_Socket_TypeStream, - osl_Socket_ProtocolIp); - OSL_ASSERT(result == osl_Socket_Ok); - - if (argc > 1) - { - rtl_uString *host = 0; - - rtl_uString_newFromAscii (&host, argv[1]); - addr = osl_resolveHostname (host); - rtl_uString_release (host); - } - - if (addr) - { - sal_Char buffer[128]; - sal_Int32 k, n = sizeof(buffer); - oslSocketMsgFlag flag = osl_Socket_MsgNormal; - oslThread reader; - - osl_setInetPortOfSocketAddr (addr, 7777); - - result = osl_socket_connect (socket, addr); - OSL_ASSERT(result == osl_Socket_Ok); - - result = osl_socket_connect_handshake (socket, addr); - osl_destroySocketAddr (addr); - OSL_ASSERT(result == osl_Socket_Ok); - - reader = osl_createSuspendedThread (clientSocketReader, socket); - OSL_ASSERT(reader); - osl_resumeThread (reader); - - while ((k = fread (buffer, 1, n, stdin)) > 0) - { - if (osl_socket_send (socket, buffer, k, flag) < 0) - break; - } - - osl_socket_shutdown (socket, osl_Socket_DirReadWrite); - osl_socket_close (socket); - - osl_joinWithThread (reader); - osl_destroyThread (reader); - } - else - { - oslSocketDescriptor *connection; - oslSocketAddr from = 0; - sal_Int32 option = 1; - - addr = osl_createEmptySocketAddr (osl_Socket_FamilyInet); - osl_setInetPortOfSocketAddr (addr, 7777); - - result = osl_socket_setOption ( - socket, - osl_Socket_LevelSocket, - osl_Socket_OptionReuseAddr, - &option, sizeof(option)); - OSL_ASSERT(result == osl_Socket_Ok); - - result = osl_socket_bind (socket, addr); - osl_destroySocketAddr (addr); - OSL_ASSERT(result == osl_Socket_Ok); - - result = osl_socket_listen (socket, 1); - OSL_ASSERT(result == osl_Socket_Ok); - - connection = osl_socket_accept (socket, &from); - if (connection) - { - sal_Char buffer[64]; - sal_Int32 k, n = sizeof(buffer); - oslSocketMsgFlag flag = osl_Socket_MsgNormal; - - result = osl_socket_accept_handshake (connection, from); - osl_destroySocketAddr (from); - OSL_ASSERT(result == osl_Socket_Ok); - - while ((k = osl_socket_recv (connection, buffer, n, flag)) > 0) - { - if (osl_socket_send (connection, buffer, k, flag) < 0) - break; - } - - osl_socket_close (connection); - - osl_socket_delete (connection); - osl_socket_deleteSocketLayer (connection); - } - - osl_socket_close (socket); - } - - osl_socket_delete (socket); - osl_socket_deleteSocketLayer (socket); - } - - return 0; -} - diff --git a/salhelper/qa/makefile.mk b/salhelper/qa/makefile.mk index 9987b3a276cd..4589338a5316 100644 --- a/salhelper/qa/makefile.mk +++ b/salhelper/qa/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -39,7 +39,7 @@ ENABLE_EXCEPTIONS := TRUE SHL1TARGET = $(TARGET) SHL1OBJS = $(SLO)$/test_api.obj -SHL1STDLIBS = $(CPPUNITLIB) $(SALLIB) $(SALHELPERLIB) +SHL1STDLIBS = $(CPPUNITLIB) $(SALLIB) $(SALHELPERLIB) $(TESTSHL2LIB) SHL1IMPLIB = i$(SHL1TARGET) SHL1VERSIONMAP = version.map DEF1NAME = $(SHL1TARGET) @@ -51,4 +51,4 @@ SLOFILES = $(SHL1OBJS) ALLTAR: test test .PHONY: $(SHL1TARGETN) - cd $(SHL1TARGETN:d) && testshl2 $(SHL1TARGETN:f) + cd $(SHL1TARGETN:d) && $(TESTSHL2) $(SHL1TARGETN:f) diff --git a/salhelper/qa/test_api.cxx b/salhelper/qa/test_api.cxx index 9957f6a56cf1..83df7ec084c6 100644 --- a/salhelper/qa/test_api.cxx +++ b/salhelper/qa/test_api.cxx @@ -59,7 +59,7 @@ std::type_info const & getSimpleReferenceObjectTypeInfo() } -#include "cppunit/simpleheader.hxx" +#include "testshl/simpleheader.hxx" #include "osl/mutex.hxx" #include "salhelper/condition.hxx" #include "salhelper/dynload.hxx" diff --git a/stoc/prj/build.lst b/stoc/prj/build.lst index 4748ffcff26f..2550563c8c34 100644 --- a/stoc/prj/build.lst +++ b/stoc/prj/build.lst @@ -21,4 +21,4 @@ tc stoc\source\typeconv nmake - all tc_tcv tc_stserv tc_nservice tc_inc NULL tc stoc\source\javavm nmake - all tc_jvm tc_inc NULL tc stoc\source\javaloader nmake - all tc_jvload tc_inc NULL tc stoc\source\uriproc nmake - all tc_uriproc tc_stserv tc_inc NULL -tc stoc\util nmake - all tc_util tc_boot tc_stserv tc_tcv tc_uriproc tc_smgr tc_inc tc_sreg tc_defr tc_ireg tc_regtd tc_tdmng NULL +tc stoc\util nmake - all tc_util tc_boot tc_stserv tc_tcv tc_uriproc tc_smgr tc_inc tc_sreg tc_defr tc_ireg tc_regtd tc_tdmng tc_sec NULL diff --git a/stoc/source/inspect/introspection.cxx b/stoc/source/inspect/introspection.cxx index 011fafe9d6e9..518c6029ddd2 100644 --- a/stoc/source/inspect/introspection.cxx +++ b/stoc/source/inspect/introspection.cxx @@ -43,6 +43,7 @@ #endif #include <osl/diagnose.h> #include <osl/mutex.hxx> +#include <osl/thread.h> #include <cppuhelper/queryinterface.hxx> #include <cppuhelper/weak.hxx> #include <cppuhelper/component.hxx> @@ -1421,28 +1422,29 @@ Sequence< Reference<XIdlMethod> > ImplIntrospectionAccess::getMethods(sal_Int32 if( nConcept & MethodConcepts ) pDestMethods[ iDest++ ] = pSourceMethods[ i ]; - /* - // Methode mit Concepts ausgeben - const XIdlMethodRef& rxMethod = pSourceMethods[ i ]; - OUString aMethName = rxMethod->getName(); - String aNameStr = OOUStringToString(aMethName, CHARSET_SYSTEM); - String ConceptStr; - if( nConcept & DANGEROUS ) - ConceptStr += "DANGEROUS |"; - if( nConcept & PROPERTY ) - ConceptStr += "PROPERTY |"; - if( nConcept & LISTENER ) - ConceptStr += "LISTENER |"; - if( nConcept & ENUMERATION ) - ConceptStr += "ENUMERATION |"; - if( nConcept & NAMECONTAINER ) - ConceptStr += "NAMECONTAINER |"; - if( nConcept & INDEXCONTAINER ) - ConceptStr += "INDEXCONTAINER |"; - if( nConcept & NORMAL_IMPL ) - ConceptStr += "NORMAL_IMPL |"; - printf( "Method %ld: %s, Concepts = %s\n", i, aNameStr.GetStr(), ConceptStr.GetStr() ); - */ + #if OSL_DEBUG_LEVEL > 0 + static bool debug = false; + if ( debug ) + { + // Methode mit Concepts ausgeben + const Reference< XIdlMethod >& rxMethod = pSourceMethods[ i ]; + ::rtl::OString aNameStr = ::rtl::OUStringToOString( rxMethod->getName(), osl_getThreadTextEncoding() ); + ::rtl::OString ConceptStr; + if( nConcept & MethodConcept::DANGEROUS ) + ConceptStr += "DANGEROUS |"; + if( nConcept & MethodConcept::PROPERTY ) + ConceptStr += "PROPERTY |"; + if( nConcept & MethodConcept::LISTENER ) + ConceptStr += "LISTENER |"; + if( nConcept & MethodConcept::ENUMERATION ) + ConceptStr += "ENUMERATION |"; + if( nConcept & MethodConcept::NAMECONTAINER ) + ConceptStr += "NAMECONTAINER |"; + if( nConcept & MethodConcept::INDEXCONTAINER ) + ConceptStr += "INDEXCONTAINER |"; + OSL_TRACE( "Method %ld: %s, Concepts = %s", i, aNameStr.getStr(), ConceptStr.getStr() ); + } + #endif } // Auf die richtige Laenge bringen diff --git a/stoc/test/javavm/testapplet/TestApplet.java b/stoc/test/javavm/testapplet/TestApplet.java index 07467cc54c0f..55916cff784b 100644 --- a/stoc/test/javavm/testapplet/TestApplet.java +++ b/stoc/test/javavm/testapplet/TestApplet.java @@ -5,7 +5,6 @@ import java.io.IOException; import java.net.URL; import java.io.InputStream; import java.net.MalformedURLException; -import com.sun.star.lib.sandbox.*; /* * TestApplet.java * diff --git a/stoc/test/javavm/testapplet/makefile.mk b/stoc/test/javavm/testapplet/makefile.mk index 706180655f06..da5a21e4f166 100644 --- a/stoc/test/javavm/testapplet/makefile.mk +++ b/stoc/test/javavm/testapplet/makefile.mk @@ -40,7 +40,7 @@ TARGET = TestApplet #.INCLUDE : $(PRJ)$/util$/makefile.pmk .INCLUDE : settings.mk # Files -------------------------------------------------------- -JARFILES = sandbox.jar ridl.jar jurt.jar unoil.jar +JARFILES = ridl.jar jurt.jar unoil.jar JAVAFILES= $(subst,$(CLASSDIR)$/$(PACKAGE)$/, $(subst,.class,.java $(JAVACLASSFILES))) diff --git a/stoc/test/javavm/testcomponent/TestComponent.java b/stoc/test/javavm/testcomponent/TestComponent.java index a0fb1d01a858..5622ba087d7a 100644 --- a/stoc/test/javavm/testcomponent/TestComponent.java +++ b/stoc/test/javavm/testcomponent/TestComponent.java @@ -4,7 +4,7 @@ import com.sun.star.uno.*; import com.sun.star.registry.XRegistryKey; import java.io.*; import java.net.*; -import com.sun.star.lib.sandbox.*; +//import com.sun.star.lib.sandbox.*; /** This component implements XTypeProvider for use with StarBasic. @@ -74,10 +74,11 @@ public class TestComponent implements XServiceInfo, XTypeProvider }catch( IOException e) { String s= e.getMessage(); System.out.println(s); - }catch( SandboxSecurityException sse) { + }/*catch( SandboxSecurityException sse) { String s= sse.getMessage(); System.out.println("s"); } +*/ return __serviceName; } diff --git a/stoc/test/javavm/testcomponent/makefile.mk b/stoc/test/javavm/testcomponent/makefile.mk index 68f3f5bd6431..9fcd390b02a1 100644 --- a/stoc/test/javavm/testcomponent/makefile.mk +++ b/stoc/test/javavm/testcomponent/makefile.mk @@ -40,7 +40,7 @@ TARGET = JavaTestComponent #.INCLUDE : $(PRJ)$/util$/makefile.pmk .INCLUDE : settings.mk # Files -------------------------------------------------------- -JARFILES = sandbox.jar ridl.jar jurt.jar unoil.jar +JARFILES = ridl.jar jurt.jar unoil.jar CUSTOMMANIFESTFILE= manifest diff --git a/stoc/test/uriproc/makefile.mk b/stoc/test/uriproc/makefile.mk index 85e3a294f434..78b54bb2a5a2 100644 --- a/stoc/test/uriproc/makefile.mk +++ b/stoc/test/uriproc/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -56,7 +56,7 @@ UNOTYPES = \ SHL1TARGET = $(TARGET) SHL1OBJS = $(SLO)$/test_uriproc.obj -SHL1STDLIBS = $(CPPULIB) $(CPPUHELPERLIB) $(CPPUNITLIB) $(SALLIB) +SHL1STDLIBS = $(CPPULIB) $(CPPUHELPERLIB) $(CPPUNITLIB) $(SALLIB) $(TESTSHL2LIB) SHL1VERSIONMAP = version.map SHL1IMPLIB = i$(SHL1TARGET) DEF1NAME = $(SHL1TARGET) diff --git a/stoc/test/uriproc/test_uriproc.cxx b/stoc/test/uriproc/test_uriproc.cxx index f1032276eb89..71f92e504d64 100644 --- a/stoc/test/uriproc/test_uriproc.cxx +++ b/stoc/test/uriproc/test_uriproc.cxx @@ -47,7 +47,7 @@ #include "com/sun/star/uri/XVndSunStarScriptUrlReference.hpp" #include "com/sun/star/util/XMacroExpander.hpp" #include "cppuhelper/servicefactory.hxx" -#include "cppunit/simpleheader.hxx" +#include "testshl/simpleheader.hxx" #include "osl/diagnose.h" #include "osl/thread.h" #include "rtl/string.h" diff --git a/store/source/lockbyte.cxx b/store/source/lockbyte.cxx index a38aa768908d..a03628bfb740 100644 --- a/store/source/lockbyte.cxx +++ b/store/source/lockbyte.cxx @@ -297,7 +297,7 @@ struct FileHandle if (result == osl_File_E_EXIST) { // Already existing (O_CREAT | O_EXCL). - result = osl_openFile (aFileUrl.pData, &m_handle, osl_File_OpenFlag_Write); + result = osl_openFile (aFileUrl.pData, &m_handle, osl_File_OpenFlag_Read | osl_File_OpenFlag_Write); if ((result == osl_File_E_None) && (eAccessMode == store_AccessCreate)) { // Truncate existing file. diff --git a/store/source/stordata.hxx b/store/source/stordata.hxx index 1b6c74c371fd..4610bac425fd 100644 --- a/store/source/stordata.hxx +++ b/store/source/stordata.hxx @@ -93,7 +93,7 @@ struct OStoreDataPageData : public store::OStorePageData { base::m_aGuard.m_nMagic = store::htonl(self::theTypeId); base::m_aDescr.m_nUsed = store::htons(self::thePageSize); - memset (m_pData, 0, capacity()); + if (capacity()) memset (m_pData, 0, capacity()); } /** guard (external representation). diff --git a/store/workben/makefile.mk b/store/workben/makefile.mk index 334585710522..4b58d26409a0 100644 --- a/store/workben/makefile.mk +++ b/store/workben/makefile.mk @@ -93,11 +93,12 @@ APP3STDLIBS= $(STOREDBGLIB) APP3STDLIBS+= $(SALLIB) APP3DEPN= $(STOREDBGLIB) - APP4TARGET= t_store - APP4OBJS= $(OBJ)$/t_store.obj - APP4STDLIBS= $(STORELIB) - APP4STDLIBS+= $(SALLIB) - APP4DEPN= $(SLB)$/store.lib +APP4TARGET= t_store +APP4OBJS= $(OBJ)$/t_store.obj +APP4STDLIBS= $(STORELIB) +APP4STDLIBS+= $(SALLIB) +APP4DEPN= $(SLB)$/store.lib +APP4RPATH= UREBIN APP5TARGET= t_leak APP5OBJS= $(OBJ)$/t_leak.obj diff --git a/udkapi/util/target.pmk b/udkapi/util/target.pmk index f6e7bc9beb3c..2a01738e7eb7 100644 --- a/udkapi/util/target.pmk +++ b/udkapi/util/target.pmk @@ -30,8 +30,8 @@ #************************************************************************* $(OUT)$/misc$/$(TARGET).idls: makefile.mk - -$(RM) $@ - $(TYPE) $(mktmp $(foreach,i,$(IDLFILES) $(PACKAGE)$/$i)) >>$@ + $(COMMAND_ECHO)-$(RM) $@ + $(COMMAND_ECHO)$(TYPE) $(mktmp $(foreach,i,$(IDLFILES) $(PACKAGE)$/$i)) >>$@ ALLTAR: $(OUT)$/misc$/$(TARGET).idls diff --git a/unoil/climaker/makefile.mk b/unoil/climaker/makefile.mk index 991a79b9b1a8..c72291afa489 100644 --- a/unoil/climaker/makefile.mk +++ b/unoil/climaker/makefile.mk @@ -69,7 +69,7 @@ RDB = $(SOLARBINDIR)$/offapi.rdb EXTRA_RDB = $(SOLARBINDIR)$/udkapi.rdb $(BIN)/cli_oootypes.dll : $(RDB) $(EXTRA_RDB) version.txt - $(WRAPCMD) $(SOLARBINDIR)$/climaker.exe $(CLIMAKERFLAGS) \ + $(CLIMAKER) $(CLIMAKERFLAGS) \ --out $@ \ --assembly-version $(CLI_OOOTYPES_NEW_VERSION) \ --assembly-company "OpenOffice.org" \ diff --git a/unoil/climaker/version.txt b/unoil/climaker/version.txt index bdab589b865d..4824a36ed3eb 100644 --- a/unoil/climaker/version.txt +++ b/unoil/climaker/version.txt @@ -29,8 +29,8 @@ # #************************************************************************* -CLI_OOOTYPES_NEW_VERSION=1.0.2.0 -CLI_OOOTYPES_OLD_VERSION=1.0.0.0-1.0.1.0 -CLI_OOOTYPES_POLICY_VERSION=2.0.0.0 +CLI_OOOTYPES_NEW_VERSION=1.0.4.0 +CLI_OOOTYPES_OLD_VERSION=1.0.0.0-1.0.3.0 +CLI_OOOTYPES_POLICY_VERSION=4.0.0.0 CLI_OOOTYPES_POLICY_ASSEMBLY=policy.1.0.cli_oootypes diff --git a/ure/source/README b/ure/source/README index 6528c58a537a..eec7dc4177b7 100644 --- a/ure/source/README +++ b/ure/source/README @@ -81,6 +81,7 @@ Linux x86, Solaris x86, and Solaris SPARC: /opt/openoffice.org/ure/lib/liburp_uno.so [private] /opt/openoffice.org/ure/lib/libunsafe_uno_uno.so [private] /opt/openoffice.org/ure/lib/libaffine_uno_uno.so [private] +/opt/openoffice.org/ure/lib/liblog_uno_uno.so [private] /opt/openoffice.org/ure/lib/libjpipe.so [private] /opt/openoffice.org/ure/lib/libjuh.so [private] /opt/openoffice.org/ure/lib/libjuhx.so [private] @@ -142,6 +143,7 @@ Program Files\URE\bin\cli_uno.dll [private] Program Files\URE\bin\urp_uno.dll [private] Program Files\URE\bin\unsafe_uno_uno.dll [private] Program Files\URE\bin\affine_uno_uno.dll [private] +Program Files\URE\bin\log_uno_uno.dll [private] Program Files\URE\bin\jpipe.dll [private] Program Files\URE\bin\juh.dll [private] Program Files\URE\bin\juhx.dll [private] diff --git a/ure/source/makefile.mk b/ure/source/makefile.mk index 17dbdb322de2..9736ca597aed 100644 --- a/ure/source/makefile.mk +++ b/ure/source/makefile.mk @@ -35,7 +35,7 @@ TARGET := $(PRJNAME) .INCLUDE: settings.mk -.IF "$(OS)" == "WNT" +.IF "$(OS)" == "WNT" || "$(OS)" == "OS2" MY_RC = .ini .ELSE MY_RC = rc diff --git a/ure/source/uretest/JavaClient.java b/ure/source/uretest/JavaClient.java index e7b6a6ed54d2..fbb35a910c96 100644 --- a/ure/source/uretest/JavaClient.java +++ b/ure/source/uretest/JavaClient.java @@ -50,7 +50,7 @@ public final class JavaClient { if (manager == null) { throw new NullPointerException("no service manager"); } - XBridgeFactory factory = (XBridgeFactory) UnoRuntime.queryInterface( + XBridgeFactory factory = UnoRuntime.queryInterface( XBridgeFactory.class, manager.createInstanceWithContext( "com.sun.star.bridge.BridgeFactory", context)); @@ -63,11 +63,9 @@ public final class JavaClient { Connector.create(context).connect( url.getConnectionAndParametersAsString()), null); - Data d = - ((XServer) UnoRuntime.queryInterface( - XServer.class, bridge.getInstance(url.getRootOid()))).getData(); - ((XComponent) UnoRuntime.queryInterface(XComponent.class, bridge)). - dispose(); + Data d = UnoRuntime.queryInterface( + XServer.class, bridge.getInstance(url.getRootOid())).getData(); + UnoRuntime.queryInterface(XComponent.class, bridge).dispose(); if (!d.m1.equals("Hello") || d.m2 != 42) { throw new RuntimeException("Data object contains bad values"); } diff --git a/xml2cmp/source/xcd/filebuff.cxx b/xml2cmp/source/xcd/filebuff.cxx index e958c274b552..8035d697ae4d 100644 --- a/xml2cmp/source/xcd/filebuff.cxx +++ b/xml2cmp/source/xcd/filebuff.cxx @@ -59,11 +59,7 @@ LoadXmlFile( Buffer & o_rBuffer, // Read file: aXmlFile.read(o_rBuffer.Data(), (int) nBufferSize); -#ifdef OS2 // YD eof&fail are set, so check for fail&bad - bool ret = aXmlFile.fail() != 0; -#else bool ret = aXmlFile.good() != 0; -#endif aXmlFile.close(); return ret; } diff --git a/xml2cmp/source/xcd/xmlelem.cxx b/xml2cmp/source/xcd/xmlelem.cxx index 4b642e1d30cc..aa80459ccead 100644 --- a/xml2cmp/source/xcd/xmlelem.cxx +++ b/xml2cmp/source/xcd/xmlelem.cxx @@ -36,15 +36,6 @@ #include <parse.hxx> #include <cr_html.hxx> -#if OSL_DEBUG_LEVEL == 0 -# ifndef NDEBUG -# define NDEBUG -# endif -#endif -#include <assert.h> - - - XmlElement::XmlElement( const char * i_sName ) : sName(i_sName) { @@ -160,7 +151,6 @@ ListElement::Write2Html( HtmlCreator & io_rHC ) const XmlElement * ListElement::Create_and_Add_NewElement() { - assert(fCreateNewElement != 0); XmlElement * pNew = (*fCreateNewElement)(Name()); Children().push_back( pNew ); return pNew; |