rpms/openoffice.org/devel workspace.dr72.patch, NONE, 1.1 workspace.kso32fixes.patch, NONE, 1.1 openoffice.org.spec, 1.1979, 1.1980 openoffice.org-2.2.0.ooo63159.sal.dtype.patch, 1.4, NONE openoffice.org-3.1.0.ooo92645.oox.msxmldecryptimpl.patch, 1.1, NONE

Caolan McNamara caolanm at fedoraproject.org
Thu Aug 13 11:17:30 UTC 2009


Author: caolanm

Update of /cvs/pkgs/rpms/openoffice.org/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv11766

Modified Files:
	openoffice.org.spec 
Added Files:
	workspace.dr72.patch workspace.kso32fixes.patch 
Removed Files:
	openoffice.org-2.2.0.ooo63159.sal.dtype.patch 
	openoffice.org-3.1.0.ooo92645.oox.msxmldecryptimpl.patch 
Log Message:
rename to accepted upstream workspaces

workspace.dr72.patch:
 prj/build.lst                |    2 
 source/core/filterdetect.cxx |  244 +++++++++++++++++++++++++++++++++++++++----
 util/makefile.mk             |    3 
 3 files changed, 226 insertions(+), 23 deletions(-)

--- NEW FILE workspace.dr72.patch ---
diff -ru oox.orig/prj/build.lst oox/prj/build.lst
--- oox.orig/prj/build.lst	2009-06-25 12:29:27.000000000 +0100
+++ oox/prj/build.lst	2009-06-26 11:02:26.000000000 +0100
@@ -1,4 +1,4 @@
-oox	oox : vos cppu cppuhelper comphelper sal offapi sax basegfx tools BOOST:boost NULL
+oox	oox : vos cppu cppuhelper comphelper sal offapi sax basegfx tools BOOST:boost OPENSSL:openssl NULL
 oox	oox				usr1	-   all	oox_mkout NULL
 oox	oox\prj				get	-   all	oox_prj NULL
 oox	oox\source\token		nmake	-   all	oox_token NULL
diff -ru oox.orig/source/core/filterdetect.cxx oox/source/core/filterdetect.cxx
--- oox.orig/source/core/filterdetect.cxx	2009-06-25 12:30:35.000000000 +0100
+++ oox/source/core/filterdetect.cxx	2009-06-26 11:01:15.000000000 +0100
@@ -37,12 +37,20 @@
 #include <com/sun/star/xml/sax/XFastContextHandler.hpp>
 #include <com/sun/star/xml/sax/XFastParser.hpp>
 
+#include <com/sun/star/io/XTempFile.hpp>
+
 #include <comphelper/mediadescriptor.hxx>
 #include <cppuhelper/implbase1.hxx>
 #include <cppuhelper/implbase2.hxx>
 
+#include <rtl/digest.h>
+#include <openssl/evp.h>
+
 #include "oox/helper/attributelist.hxx"
 #include "oox/helper/zipstorage.hxx"
+#include "oox/helper/olestorage.hxx"
+#include "oox/helper/binaryinputstream.hxx"
+#include "oox/helper/binaryoutputstream.hxx"
 #include "oox/core/fasttokenhandler.hxx"
 #include "oox/core/namespaces.hxx"
 #include "tokens.hxx"
@@ -317,6 +325,97 @@
 {
 }
 
+/*
+ * Derive Key
+ */
+void DeriveKey(const sal_uInt8 *pHash, sal_uInt32 cbHash, sal_uInt8 *keyDerived, sal_uInt32 cbRequiredKeyLength)
+{
+    sal_uInt8 aBuffer[64];
+
+    memset(aBuffer, 0x36, sizeof(aBuffer));
+    for (sal_uInt32 i = 0; i < cbHash; ++i)
+        aBuffer[i] ^= pHash[i];
+
+    rtlDigest aDigest;
+    rtlDigestError aError;
+
+    aDigest = rtl_digest_create(rtl_Digest_AlgorithmSHA1);
+    aError = rtl_digest_update(aDigest, aBuffer, sizeof(aBuffer));
+    sal_uInt8 X1[RTL_DIGEST_LENGTH_SHA1];
+    aError = rtl_digest_get(aDigest, X1, RTL_DIGEST_LENGTH_SHA1);
+    rtl_digest_destroy(aDigest);
+
+    memset(aBuffer, 0x5C, sizeof(aBuffer));
+    for (sal_uInt32 i = 0; i < cbHash; ++i)
+        aBuffer[i] ^= pHash[i];
+
+    aDigest = rtl_digest_create(rtl_Digest_AlgorithmSHA1);
+    aError = rtl_digest_update(aDigest, aBuffer, sizeof(aBuffer));
+    sal_uInt8 X2[RTL_DIGEST_LENGTH_SHA1];
+    aError = rtl_digest_get(aDigest, X2, RTL_DIGEST_LENGTH_SHA1);
+    rtl_digest_destroy(aDigest);
+
+    if (cbRequiredKeyLength > RTL_DIGEST_LENGTH_SHA1)
+    {
+        memcpy(keyDerived+RTL_DIGEST_LENGTH_SHA1, X2, cbRequiredKeyLength-RTL_DIGEST_LENGTH_SHA1);
+        cbRequiredKeyLength=RTL_DIGEST_LENGTH_SHA1;
+    }
+    memcpy(keyDerived, X1, cbRequiredKeyLength);
+}
+
+/*
+ * Generate an encryption key
+ */
+
+void GenerateEncryptionKey(sal_uInt32 SaltSize, const sal_uInt8 *Salt, const rtl::OUString &rPassword,
+    sal_uInt8 *key, sal_uInt32 cbRequiredKeyLength)
+{
+    size_t nBufferSize = (SaltSize + (rPassword.getLength() * sizeof(sal_uInt16)));
+    sal_uInt8 *pBuffer = new sal_uInt8[nBufferSize];
+
+    memcpy(pBuffer, Salt, SaltSize);
+
+    sal_uInt8 *pPasswordLoc = pBuffer+SaltSize;
+    sal_Int32 nLen = rPassword.getLength();
+    const sal_Unicode *pStr = rPassword.getStr();
+
+    for (sal_Int32 i = 0; i < nLen; ++i, ++pStr)
+    {
+        *pPasswordLoc++ = (*pStr & 0x00FF);
+        *pPasswordLoc++ = ((*pStr & 0xFF00) >> 8);
+    }
+
+    rtlDigest aDigest = rtl_digest_create(rtl_Digest_AlgorithmSHA1);
+    rtlDigestError aError;
+    aError = rtl_digest_update(aDigest, pBuffer, nBufferSize);
+    delete [] pBuffer;
+    size_t nHashSize = RTL_DIGEST_LENGTH_SHA1+sizeof(sal_uInt32);
+    sal_uInt8 aHash[nHashSize];
+    aError = rtl_digest_get(aDigest, aHash+sizeof(sal_uInt32), RTL_DIGEST_LENGTH_SHA1);
+    rtl_digest_destroy(aDigest);
+
+    for (sal_uInt32 i = 0; i < 50000; ++i)
+    {
+        aHash[0] = (i & 0x000000FF);
+        aHash[1] = (i & 0x0000FF00) >> 8;
+        aHash[2] = (i & 0x00FF0000) >> 16;
+        aHash[3] = (i & 0xFF000000) >> 24;
+        aDigest = rtl_digest_create(rtl_Digest_AlgorithmSHA1);
+        aError = rtl_digest_update(aDigest, aHash, nHashSize);
+        aError = rtl_digest_get(aDigest, aHash+sizeof(sal_uInt32), RTL_DIGEST_LENGTH_SHA1);
+        rtl_digest_destroy(aDigest);
+    }
+
+    memmove(aHash, aHash+sizeof(sal_uInt32), RTL_DIGEST_LENGTH_SHA1);
+    memset(aHash+RTL_DIGEST_LENGTH_SHA1, 0, sizeof(sal_uInt32));
+    aDigest = rtl_digest_create(rtl_Digest_AlgorithmSHA1);
+    aError = rtl_digest_update(aDigest, aHash, nHashSize);
+    aError = rtl_digest_get(aDigest, aHash, RTL_DIGEST_LENGTH_SHA1);
+    rtl_digest_destroy(aDigest);
+
+    DeriveKey(aHash, RTL_DIGEST_LENGTH_SHA1, key, cbRequiredKeyLength);
+}
+
 // com.sun.star.document.XExtendedFilterDetect interface ----------------------
 
 OUString SAL_CALL FilterDetect::detect( Sequence< PropertyValue >& lDescriptor ) throw( RuntimeException )
@@ -325,31 +424,134 @@
 
     if( mxFactory.is() ) try
     {
-        Reference< XFastParser > xParser( mxFactory->createInstance(
-            CREATE_OUSTRING( "com.sun.star.xml.sax.FastParser" ) ), UNO_QUERY_THROW );
-
-        xParser->setFastDocumentHandler( new FilterDetectDocHandler( aFilter ) );
-        xParser->setTokenHandler( new FastTokenHandler );
-
-        xParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/package/2006/relationships" ), NMSP_PACKAGE_RELATIONSHIPS );
-        xParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/officeDocument/2006/relationships" ), NMSP_RELATIONSHIPS );
-        xParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/package/2006/content-types" ), NMSP_CONTENT_TYPES );
-
         MediaDescriptor aDescriptor( lDescriptor );
         aDescriptor.addInputStream();
         Reference< XInputStream > xInputStream( aDescriptor[ MediaDescriptor::PROP_INPUTSTREAM() ], UNO_QUERY_THROW );
-        StorageRef xStorage( new ZipStorage( mxFactory, xInputStream ) );
+        StorageRef xZipStorage( new ZipStorage( mxFactory, xInputStream ) );
 
-        // Parse _rels/.rels to get the target path.
-        InputSource aParserInput;
-        aParserInput.sSystemId = CREATE_OUSTRING( "_rels/.rels" );
-        aParserInput.aInputStream = xStorage->openInputStream( aParserInput.sSystemId );
-        xParser->parseStream( aParserInput );
-
-        // Parse [Content_Types].xml to determine the content type of the part at the target path.
-        aParserInput.sSystemId = CREATE_OUSTRING( "[Content_Types].xml" );
-        aParserInput.aInputStream = xStorage->openInputStream( aParserInput.sSystemId );
-        xParser->parseStream( aParserInput );
+        if (xZipStorage->isStorage())
+        {
+            Reference< XFastParser > xParser( mxFactory->createInstance(
+                CREATE_OUSTRING( "com.sun.star.xml.sax.FastParser" ) ), UNO_QUERY_THROW );
+
+            xParser->setFastDocumentHandler( new FilterDetectDocHandler( aFilter ) );
+            xParser->setTokenHandler( new FastTokenHandler );
+
+            xParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/package/2006/relationships" ), NMSP_PACKAGE_RELATIONSHIPS );
+            xParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/officeDocument/2006/relationships" ), NMSP_RELATIONSHIPS );
+            xParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/package/2006/content-types" ), NMSP_CONTENT_TYPES );
+
+            // Parse _rels/.rels to get the target path.
+            InputSource aParserInput;
+            aParserInput.sSystemId = CREATE_OUSTRING( "_rels/.rels" );
+            aParserInput.aInputStream = xZipStorage->openInputStream( aParserInput.sSystemId );
+            xParser->parseStream( aParserInput );
+
+            // Parse [Content_Types].xml to determine the content type of the part at the target path.
+            aParserInput.sSystemId = CREATE_OUSTRING( "[Content_Types].xml" );
+            aParserInput.aInputStream = xZipStorage->openInputStream( aParserInput.sSystemId );
+            xParser->parseStream( aParserInput );
+        }
+        else
+        {
+            StorageRef xOLEStorage ( new OleStorage( mxFactory, xInputStream, false ) );
+            if (xOLEStorage->isStorage())
+            {
+                Reference< XInputStream > xEncryptionInfo = xOLEStorage->openInputStream( CREATE_OUSTRING( "EncryptionInfo") );
+                Reference< XInputStream > xEncryptedPackage = xOLEStorage->openInputStream( CREATE_OUSTRING( "EncryptedPackage") );
+                BinaryXInputStream aInfo(xEncryptionInfo, true);
+                aInfo.skip(0x00000008);
+                sal_uInt32 EncryptionHeaderSize = aInfo.readuInt32();
+                aInfo.skip(0x00000008);
+                sal_uInt32 AlgID = aInfo.readuInt32();
+                sal_uInt32 AlgIDHash = aInfo.readuInt32();
+                sal_uInt32 KeySize = aInfo.readuInt32();
+                aInfo.skip(EncryptionHeaderSize-0x00000014);
+                sal_uInt32 SaltSize = aInfo.readuInt32();
+                sal_uInt8 Salt[16];
+                aInfo.readMemory(Salt, 16);
+                sal_uInt8 EncryptedVerifier[16];
+                aInfo.readMemory(EncryptedVerifier, 16);
+                sal_uInt32 VerifierHashSize = aInfo.readuInt32();
+                sal_uInt8 EncryptedVerifierHash[32];
+                aInfo.readMemory(EncryptedVerifierHash, 32);
+
+                bool bCorrectPassword = false;
+                //aes128 && sha1 && expected hash size
+                bool bImplemented = ((AlgID == 0x0000660E) && (AlgIDHash == 0x00008004) && (VerifierHashSize == 0x14));
+
+                if (bImplemented)
+                {
+                    sal_uInt8 cbRequiredKeyLength = KeySize/8;
+                    sal_uInt8 *key = new sal_uInt8[cbRequiredKeyLength];
+                    //VelvetSweatshop is the default .xlsx "protection" password, so out-of-the-box we should
+                    //be able to open those immediately. For other passwords we need to pass down that data, or query
+                    //for it, however its normall done, to here.
+                    //Unlike other formats, we can't really detect what's inside this wrapper until *after* 
+                    //decryption
+                    GenerateEncryptionKey(SaltSize, Salt, CREATE_OUSTRING("VelvetSweatshop"), key, cbRequiredKeyLength);
+
+                    EVP_CIPHER_CTX aes_ctx;
+                    int outlen=0;
+
+                    EVP_CIPHER_CTX_init(&aes_ctx);
+                    EVP_DecryptInit_ex(&aes_ctx, EVP_aes_128_ecb(), NULL, key, NULL);
+                    EVP_CIPHER_CTX_set_padding(&aes_ctx, 0);
+                    sal_uInt8 Verifier[16]= {0};
+                    /*int*/ EVP_DecryptUpdate(&aes_ctx, Verifier, &outlen, EncryptedVerifier, sizeof(EncryptedVerifier));
+                    EVP_CIPHER_CTX_cleanup(&aes_ctx);
+
+                    EVP_CIPHER_CTX_init(&aes_ctx);
+                    EVP_DecryptInit_ex(&aes_ctx, EVP_aes_128_ecb(), NULL, key, NULL);
+                    EVP_CIPHER_CTX_set_padding(&aes_ctx, 0);
+                    sal_uInt8 VerifierHash[32] = {0};
+                    /*int*/ EVP_DecryptUpdate(&aes_ctx, VerifierHash, &outlen, EncryptedVerifierHash, sizeof(EncryptedVerifierHash));
+                    EVP_CIPHER_CTX_cleanup(&aes_ctx);
+
+                    rtlDigest aDigest = rtl_digest_create(rtl_Digest_AlgorithmSHA1);
+                    rtlDigestError aError = rtl_digest_update(aDigest, Verifier, sizeof(Verifier));
+                    sal_uInt8 sha1Hash[RTL_DIGEST_LENGTH_SHA1];
+                    aError = rtl_digest_get(aDigest, sha1Hash, RTL_DIGEST_LENGTH_SHA1);
+                    rtl_digest_destroy(aDigest);
+
+                    bCorrectPassword = memcmp(sha1Hash, VerifierHash, RTL_DIGEST_LENGTH_SHA1) == 0;
+
+                    if (bCorrectPassword)
+                    {
+                        Reference<XTempFile> xTemp(
+                            mxFactory->createInstance(CREATE_OUSTRING("com.sun.star.io.TempFile")),
+                              UNO_QUERY_THROW);
+                        BinaryXInputStream aEncryptedPackage(xEncryptedPackage, true);
+                        BinaryXOutputStream aDecryptedPackage(xTemp->getOutputStream(), true);
+
+                        EVP_CIPHER_CTX_init(&aes_ctx);
+                        EVP_DecryptInit_ex(&aes_ctx, EVP_aes_128_ecb(), NULL, key, NULL);
+                        EVP_CIPHER_CTX_set_padding(&aes_ctx, 0);
+
+                        sal_uInt8 inbuf[1024];
+                        sal_uInt8 outbuf[1024];
+                        sal_Int32 inlen;
+                        aEncryptedPackage.skip(sizeof(sal_uInt64)); /*decrypted size*/
+                        while ((inlen = aEncryptedPackage.readMemory(inbuf, sizeof(inbuf))))
+                        {
+                            /*int*/ EVP_DecryptUpdate(&aes_ctx, outbuf, &outlen, inbuf, inlen);
+                            aDecryptedPackage.writeMemory(outbuf, outlen);
+                        }
+                        EVP_DecryptFinal_ex(&aes_ctx, outbuf, &outlen);
+                        aDecryptedPackage.writeMemory(outbuf, outlen);
+
+                        EVP_CIPHER_CTX_cleanup(&aes_ctx);
+                        delete [] key;
+
+                        aDecryptedPackage.seekToStart();
+                        xTemp->getOutputStream()->flush();
+                        aDescriptor[ MediaDescriptor::PROP_INPUTSTREAM() ] <<= xTemp;
+                        aDescriptor >> lDescriptor;
+                        aFilter = detect( lDescriptor );
+                    }
+                }
+            }
+        }
     }
     catch ( const Exception& )
     {
diff -ru oox.orig/util/makefile.mk oox/util/makefile.mk
--- oox.orig/util/makefile.mk	2009-06-25 12:30:40.000000000 +0100
+++ oox/util/makefile.mk	2009-06-25 16:35:08.000000000 +0100
@@ -73,7 +73,8 @@
 		$(RTLLIB)		\
 		$(SALLIB)		\
 		$(BASEGFXLIB)	\
-		$(SAXLIB)
+		$(SAXLIB) \
+		$(OPENSSLLIB)
 
 SHL1DEF=    $(MISC)$/$(SHL1TARGET).def
 SHL1LIBS=   $(LIB1TARGET)

workspace.kso32fixes.patch:
 openoffice.org/sal/osl/unx/file_impl.hxx |   18 ++++++++
 sal/osl/unx/file.cxx                     |   64 ++++++++++++++++++++++++++++++
 sal/osl/unx/file_stat.cxx                |   66 +++++++++++++++++++++++++++++--
 3 files changed, 145 insertions(+), 3 deletions(-)

--- NEW FILE workspace.kso32fixes.patch ---
Index: sal/osl/unx/file.cxx
===================================================================
RCS file: /cvs/porting/sal/osl/unx/file.cxx,v
retrieving revision 1.10
diff -u -p -r1.10 file.cxx
--- openoffice.org.orig/sal/osl/unx/file.cxx	8 Sep 2005 14:53:53 -0000	1.10
+++ openoffice.org/sal/osl/unx/file.cxx	18 Jan 2006 14:38:41 -0000
@@ -156,6 +156,42 @@
 
 #endif
 
+#ifdef _DIRENT_HAVE_D_TYPE
+#include "file_impl.hxx"
+	oslDirectoryItemImpl* oslDirectoryItemImpl_CreateNew( rtl_uString* _ustrFilePath, bool _bHasDType, unsigned char _DType )
+	{
+		oslDirectoryItemImpl *pItemObject = (oslDirectoryItemImpl*) malloc( sizeof( oslDirectoryItemImpl ) );
+		pItemObject->RefCount = 1;
+		pItemObject->bHasType = _bHasDType;
+		pItemObject->DType = _DType;
+		pItemObject->ustrFilePath = _ustrFilePath;
+
+		return pItemObject;
+	}
+
+	void oslDirectoryItemImpl_Destroy( oslDirectoryItemImpl* pItem )
+	{
+		if( pItem->ustrFilePath ) {
+			rtl_uString_release( pItem->ustrFilePath );
+			pItem->ustrFilePath = NULL;
+		}
+		free( pItem );
+	}
+
+	void oslDirectoryItemImpl_acquire( oslDirectoryItemImpl* pItem )
+	{
+		pItem->RefCount ++;
+	}
+
+	void oslDirectoryItemImpl_release( oslDirectoryItemImpl* pItem )
+	{
+		pItem->RefCount --;
+
+		if( pItem->RefCount <= 0 )
+			oslDirectoryItemImpl_Destroy( pItem );
+	}
+#endif
+
 #if OSL_DEBUG_LEVEL > 1
 
 	extern void debug_ustring(rtl_uString*);
@@ -484,8 +520,14 @@
 	osl_systemPathMakeAbsolutePath(pDirImpl->ustrPath, ustrFileName, &ustrFilePath);
     rtl_uString_release( ustrFileName );
 
+#ifdef _DIRENT_HAVE_D_TYPE
+    if(*pItem)
+      oslDirectoryItemImpl_release( ( oslDirectoryItemImpl* )( *pItem ) );
+    *pItem = (oslDirectoryItem) oslDirectoryItemImpl_CreateNew( ustrFilePath, true, pEntry->d_type );
+#else
     /* use path as directory item */
     *pItem = (oslDirectoryItem) ustrFilePath;
+#endif
 
     return osl_File_E_None;
 }
@@ -514,7 +556,11 @@
 
 	if (0 == access_u(ustrSystemPath, F_OK))
 	{
+#ifdef _DIRENT_HAVE_D_TYPE
+		*pItem = (oslDirectoryItem) oslDirectoryItemImpl_CreateNew( ustrSystemPath, false );
+#else
 		*pItem = (oslDirectoryItem)ustrSystemPath;
+#endif
 		osl_error = osl_File_E_None;
 	}
 	else
@@ -532,12 +578,21 @@
 
 oslFileError osl_acquireDirectoryItem( oslDirectoryItem Item )
 {
+#ifdef _DIRENT_HAVE_D_TYPE
+	oslDirectoryItemImpl* pImpl = (oslDirectoryItemImpl*) Item;
+#else
     rtl_uString* ustrFilePath = (rtl_uString *) Item;
+#endif
 
     OSL_ASSERT( Item );
 
+#ifdef _DIRENT_HAVE_D_TYPE
+	if( pImpl )
+		oslDirectoryItemImpl_acquire( pImpl );
+#else
     if( ustrFilePath )
         rtl_uString_acquire( ustrFilePath );
+#endif
 
     return osl_File_E_None;
 }
@@ -548,12 +603,21 @@
 
 oslFileError osl_releaseDirectoryItem( oslDirectoryItem Item )
 {
+#ifdef _DIRENT_HAVE_D_TYPE
+	oslDirectoryItemImpl* pImpl = (oslDirectoryItemImpl*) Item;
+#else
     rtl_uString* ustrFilePath = (rtl_uString *) Item;
+#endif
 
     OSL_ASSERT( Item );
 
+#ifdef _DIRENT_HAVE_D_TYPE
+	if( pImpl )
+		oslDirectoryItemImpl_release( pImpl );
+#else
     if( ustrFilePath )
         rtl_uString_release( ustrFilePath );
+#endif
 
     return osl_File_E_None;
 }
Index: sal/osl/unx/file_stat.cxx
===================================================================
RCS file: /cvs/porting/sal/osl/unx/file_stat.cxx,v
retrieving revision 1.6
diff -u -p -r1.6 file_stat.cxx
--- openoffice.org.orig/sal/osl/unx/file_stat.cxx	8 Sep 2005 14:56:14 -0000	1.6
+++ openoffice.org/sal/osl/unx/file_stat.cxx	18 Jan 2006 14:38:41 -0000
@@ -42,6 +42,7 @@
 #ifndef _UNISTD_H
 #include <unistd.h>
 #endif
+#include <dirent.h>
 #include <osl/file.h>
 
 #ifndef _ERRNO_H
@@ -56,6 +57,9 @@
 #include "file_path_helper.hxx"
 #include "file_error_transl.h"
 
+#ifdef _DIRENT_HAVE_D_TYPE
+#include "file_impl.hxx"
+#endif
 
 namespace /* private */
 {
@@ -223,9 +227,19 @@
 	
 	/* we only need to call stat or lstat if one of the 
        following flags is set */
+#ifdef _DIRENT_HAVE_D_TYPE
+	inline bool is_stat_call_necessary(sal_uInt32 field_mask, oslDirectoryItemImpl *pImpl)
+#else
 	inline bool is_stat_call_necessary(sal_uInt32 field_mask)
+#endif
 	{
-		return ((field_mask & osl_FileStatus_Mask_Type) ||
+		return (
+/* on linux the dirent might have d_type */
+#ifdef _DIRENT_HAVE_D_TYPE
+				((field_mask & osl_FileStatus_Mask_Type) && (!pImpl->bHasType || pImpl->DType == DT_UNKNOWN)) ||
+#else
+				(field_mask & osl_FileStatus_Mask_Type) ||
+#endif
 				(field_mask & osl_FileStatus_Mask_Attributes) ||
 				(field_mask & osl_FileStatus_Mask_CreationTime) ||
 				(field_mask & osl_FileStatus_Mask_AccessTime) ||
@@ -254,7 +268,11 @@
     	if ((NULL == Item) || (NULL == pStat))
         	return osl_File_E_INVAL;
 							
+#ifdef _DIRENT_HAVE_D_TYPE
+		file_path = rtl::OUString(reinterpret_cast<rtl_uString*>(((oslDirectoryItemImpl* ) Item)->ustrFilePath));
+#else
 		file_path = rtl::OUString(reinterpret_cast<rtl_uString*>(Item));    
+#endif
 
 		OSL_ASSERT(file_path.getLength() > 0);
 		
@@ -285,10 +303,18 @@
 #else
 	struct stat file_stat;
 #endif
-	if (is_stat_call_necessary(uFieldMask) && (0 != osl::lstat(file_path, file_stat)))
+
+#ifdef _DIRENT_HAVE_D_TYPE
+	oslDirectoryItemImpl* pImpl = (oslDirectoryItemImpl*) Item;
+	bool bStatNeeded = is_stat_call_necessary(uFieldMask, pImpl);
+#else
+	bool bStatNeeded = is_stat_call_necessary(uFieldMask);
+#endif
+
+	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 +331,40 @@
 				return osl_error;
 		}
     }
+#ifdef _DIRENT_HAVE_D_TYPE
+    else if (uFieldMask & osl_FileStatus_Mask_Type)
+    {
+		OSL_ASSERT(pImpl->bHasType);
+
+		switch(pImpl->DType)
+		{
+		case DT_LNK:
+			pStat->eType = osl_File_Type_Link;              
+			break;
+		case DT_DIR:
+			pStat->eType = osl_File_Type_Directory;       
+			break;
+		case DT_REG:
+			pStat->eType = osl_File_Type_Regular;
+			break;
+		case DT_FIFO:
+			pStat->eType = osl_File_Type_Fifo;
+			break;
+		case DT_SOCK:
+			pStat->eType = osl_File_Type_Socket;
+			break;
+		case DT_CHR:
+		case DT_BLK:
+			pStat->eType = osl_File_Type_Special;
+			break;
+		default:
+			OSL_ASSERT(0);
+			pStat->eType = osl_File_Type_Unknown;
+		}
+
+       pStat->uValidFields |= osl_FileStatus_Mask_Type;
+	}
+#endif
 			
     if (uFieldMask & osl_FileStatus_Mask_FileURL)
     {
Index: sal/osl/unx/file_impl.hxx
===================================================================
--- /dev/null	2006-01-10 21:26:33.568399000 +0100
+++ openoffice.org/sal/osl/unx/file_impl.hxx	2006-01-17 20:05:30.000000000 +0100
@@ -0,0 +1,18 @@
+#ifdef __cplusplus
+extern "C" {
+#endif
+typedef struct
+{
+	rtl_uString* ustrFilePath;       /* holds native file name */
+	unsigned char DType;
+	bool bHasType;
+	sal_uInt32 RefCount;
+} oslDirectoryItemImpl;
+
+	oslDirectoryItemImpl* oslDirectoryItemImpl_CreateNew( rtl_uString* _ustrFilePath, bool _bHasDType, unsigned char _DType=0 );
+	void oslDirectoryItemImpl_Destroy( oslDirectoryItemImpl* pItem );
+	void oslDirectoryItemImpl_acquire( oslDirectoryItemImpl* pItem );
+	void oslDirectoryItemImpl_release( oslDirectoryItemImpl* pItem );
+#ifdef __cplusplus
+} /* extern "C" */
+#endif


Index: openoffice.org.spec
===================================================================
RCS file: /cvs/pkgs/rpms/openoffice.org/devel/openoffice.org.spec,v
retrieving revision 1.1979
retrieving revision 1.1980
diff -u -p -r1.1979 -r1.1980
--- openoffice.org.spec	11 Aug 2009 13:59:59 -0000	1.1979
+++ openoffice.org.spec	13 Aug 2009 11:17:29 -0000	1.1980
@@ -88,7 +88,7 @@ Patch11: openoffice.org-2.0.3.rh127576.g
 %endif
 Patch12: openoffice.org-2.2.0.ooo74188.sw.cursorinsideglyph.patch
 Patch13: ooo-build.ooo68717.gstreamer.video.patch
-Patch14: openoffice.org-2.2.0.ooo63159.sal.dtype.patch
+Patch14: workspace.kso32fixes.patch
 Patch15: openoffice.org-2.2.0.ooo76393.sal.dynamicsection.patch
 Patch16: openoffice.org-2.2.1.ooo7065.sw.titlepagedialog.patch
 Patch17: openoffice.org-2.3.0.ooo76649.httpencoding.patch
@@ -148,7 +148,7 @@ Patch70: workspace.calc51.patch
 Patch71: openoffice.org-2.0.0.ooo46270.svx.search-dialog.no-find-all-in-draw.patch
 Patch72: openoffice.org-3.1.0.ooo102920.i18npool.utf16bustage.patch
 Patch73: workspace.cmcfixes60.patch
-Patch74: openoffice.org-3.1.0.ooo92645.oox.msxmldecryptimpl.patch
+Patch74: workspace.dr72.patch
 Patch75: workspace.vcl103.patch
 Patch76: workspace.cmcfixes61.patch
 Patch77: workspace.os132.patch
@@ -1626,7 +1626,7 @@ cat %{PATCH11} >> svtools/source/dialogs
 %endif
 %patch12 -p1 -b .ooo74188.sw.cursorinsideglyph.patch
 %patch13 -p0 -b .ooo68717.gstreamer.video.patch
-%patch14 -p1 -b .ooo63159.sal.dtype.patch
+%patch14 -p1 -b .workspace.kso32fixes.patch
 %patch15 -p1 -b .ooo76393.sal.dynamicsection.patch
 %patch16 -p1 -b .ooo7065.sw.titlepagedialog.patch
 %patch17 -p1 -b .ooo76649.httpencoding.patch
@@ -1686,7 +1686,7 @@ cat %{PATCH11} >> svtools/source/dialogs
 %patch71 -p0 -b .ooo46270.svx.search-dialog.no-find-all-in-draw.patch
 %patch72 -p0 -b .ooo102920.i18npool.utf16bustage.patch
 %patch73 -p0 -b .workspace.cmcfixes60.patch
-%patch74 -p0 -b .ooo92645.oox.msxmldecryptimpl.patch
+%patch74 -p0 -b .workspace.dr72.patch
 %patch75 -p0 -b .workspace.vcl103.patch
 %patch76 -p0 -b .workspace.cmcfixes61.patch
 %patch77 -p0 -b .workspace.os132.patch


--- openoffice.org-2.2.0.ooo63159.sal.dtype.patch DELETED ---


--- openoffice.org-3.1.0.ooo92645.oox.msxmldecryptimpl.patch DELETED ---




More information about the fedora-extras-commits mailing list