summaryrefslogtreecommitdiff
path: root/filter/source/placeware
diff options
context:
space:
mode:
Diffstat (limited to 'filter/source/placeware')
-rw-r--r--filter/source/placeware/Base64Codec.cxx207
-rw-r--r--filter/source/placeware/Base64Codec.hxx47
-rw-r--r--filter/source/placeware/exporter.cxx516
-rw-r--r--filter/source/placeware/exporter.hxx60
-rw-r--r--filter/source/placeware/exports.dxp3
-rw-r--r--filter/source/placeware/filter.cxx217
-rw-r--r--filter/source/placeware/makefile.mk67
-rw-r--r--filter/source/placeware/placeware.xml45
-rw-r--r--filter/source/placeware/tempfile.cxx189
-rw-r--r--filter/source/placeware/tempfile.hxx48
-rw-r--r--filter/source/placeware/uno.cxx110
-rw-r--r--filter/source/placeware/zip.cxx332
-rw-r--r--filter/source/placeware/zip.hxx62
-rw-r--r--filter/source/placeware/zipfile.hxx91
14 files changed, 1994 insertions, 0 deletions
diff --git a/filter/source/placeware/Base64Codec.cxx b/filter/source/placeware/Base64Codec.cxx
new file mode 100644
index 000000000000..624be24dc256
--- /dev/null
+++ b/filter/source/placeware/Base64Codec.cxx
@@ -0,0 +1,207 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_filter.hxx"
+#include "Base64Codec.hxx"
+#include <rtl/ustrbuf.hxx>
+#include <osl/diagnose.h>
+using namespace rtl;
+using namespace osl;
+using namespace com::sun::star;
+
+const
+ sal_Char aBase64EncodeTable[] =
+ { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
+ 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
+ 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/' };
+
+const
+ sal_uInt8 aBase64DecodeTable[] =
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0-15
+
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 16-31
+
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 62, 0, 0, 0, 63, // 32-47
+// + /
+
+ 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 0, 0, 0, 0, 0, 0, // 48-63
+// 0 1 2 3 4 5 6 7 8 9 =
+
+ 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, // 64-79
+// A B C D E F G H I J K L M N O
+
+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0, 0, 0, 0, 0, // 80-95
+// P Q R S T U V W X Y Z
+
+ 0, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, // 96-111
+// a b c d e f g h i j k l m n o
+
+ 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 0, 0, 0, 0, 0, // 112-127
+// p q r s t u v w x y z
+
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+
+
+void ThreeByteToFourByte (const sal_uInt8* pBuffer, const sal_Int32 nStart, const sal_Int32 nFullLen, rtl::OUStringBuffer& sBuffer)
+{
+ sal_Int32 nLen(nFullLen - nStart);
+ if (nLen > 3)
+ nLen = 3;
+ if (nLen == 0)
+ {
+ sBuffer.setLength(0);
+ return;
+ }
+
+ sal_Int32 nBinaer;
+ switch (nLen)
+ {
+ case 1:
+ {
+ nBinaer = ((sal_uInt8)pBuffer[nStart + 0]) << 16;
+ }
+ break;
+ case 2:
+ {
+ nBinaer = (((sal_uInt8)pBuffer[nStart + 0]) << 16) +
+ (((sal_uInt8)pBuffer[nStart + 1]) << 8);
+ }
+ break;
+ default:
+ {
+ nBinaer = (((sal_uInt8)pBuffer[nStart + 0]) << 16) +
+ (((sal_uInt8)pBuffer[nStart + 1]) << 8) +
+ ((sal_uInt8)pBuffer[nStart + 2]);
+ }
+ break;
+ }
+
+ sBuffer.appendAscii("====");
+
+ sal_uInt8 nIndex = static_cast< sal_uInt8 >((nBinaer & 0xFC0000) >> 18);
+ sBuffer.setCharAt(0, aBase64EncodeTable [nIndex]);
+
+ nIndex = static_cast< sal_uInt8 >((nBinaer & 0x3F000) >> 12);
+ sBuffer.setCharAt(1, aBase64EncodeTable [nIndex]);
+ if (nLen == 1)
+ return;
+
+ nIndex = static_cast< sal_uInt8 >((nBinaer & 0xFC0) >> 6);
+ sBuffer.setCharAt(2, aBase64EncodeTable [nIndex]);
+ if (nLen == 2)
+ return;
+
+ nIndex = static_cast< sal_uInt8 >((nBinaer & 0x3F));
+ sBuffer.setCharAt(3, aBase64EncodeTable [nIndex]);
+}
+
+void Base64Codec::encodeBase64(rtl::OUStringBuffer& aStrBuffer, const uno::Sequence < sal_Int8 >& aPass)
+{
+ sal_Int32 i(0);
+ sal_Int32 nBufferLength(aPass.getLength());
+ const sal_Int8* pBuffer = aPass.getConstArray();
+ while (i < nBufferLength)
+ {
+ rtl::OUStringBuffer sBuffer;
+ ThreeByteToFourByte ((const sal_uInt8*)pBuffer, i, nBufferLength, sBuffer);
+ aStrBuffer.append(sBuffer);
+ i += 3;
+ }
+}
+
+const rtl::OUString s2equal(RTL_CONSTASCII_USTRINGPARAM("=="));
+const rtl::OUString s1equal(RTL_CONSTASCII_USTRINGPARAM("="));
+#if 0
+void FourByteToThreeByte (sal_uInt8* pBuffer, sal_Int32& nLength, const sal_Int32 nStart, const rtl::OUString& sString)
+{
+ nLength = 0;
+ sal_Int32 nLen (sString.getLength());
+
+ if (nLen != 4)
+ {
+ return;
+ }
+
+
+ if (sString.indexOf(s2equal) == 2)
+ nLength = 1;
+ else if (sString.indexOf(s1equal) == 3)
+ nLength = 2;
+ else
+ nLength = 3;
+
+ sal_Int32 nBinaer ((aBase64DecodeTable [sString [0]] << 18) +
+ (aBase64DecodeTable [sString [1]] << 12) +
+ (aBase64DecodeTable [sString [2]] << 6) +
+ (aBase64DecodeTable [sString [3]]));
+
+ sal_uInt8 OneByte = static_cast< sal_uInt8 >((nBinaer & 0xFF0000) >> 16);
+ pBuffer[nStart + 0] = (sal_uInt8)OneByte;
+
+ if (nLength == 1)
+ return;
+
+ OneByte = static_cast< sal_uInt8 >((nBinaer & 0xFF00) >> 8);
+ pBuffer[nStart + 1] = (sal_uInt8)OneByte;
+
+ if (nLength == 2)
+ return;
+
+ OneByte = static_cast< sal_uInt8 >(nBinaer & 0xFF);
+ pBuffer[nStart + 2] = (sal_uInt8)OneByte;
+}
+
+void Base64Codec::decodeBase64(uno::Sequence< sal_uInt8 >& aBuffer, const rtl::OUString& sBuffer)
+{
+ sal_Int32 nFirstLength((sBuffer.getLength() / 4) * 3);
+ sal_uInt8* pBuffer = new sal_uInt8[nFirstLength];
+ sal_Int32 nSecondLength(0);
+ sal_Int32 nLength(0);
+ sal_Int32 i = 0;
+ sal_Int32 k = 0;
+ while (i < sBuffer.getLength())
+ {
+ FourByteToThreeByte (pBuffer, nLength, k, sBuffer.copy(i, 4));
+ nSecondLength += nLength;
+ nLength = 0;
+ i += 4;
+ k += 3;
+ }
+ aBuffer = uno::Sequence<sal_uInt8>(pBuffer, nSecondLength);
+ delete[] pBuffer;
+}
+#endif
diff --git a/filter/source/placeware/Base64Codec.hxx b/filter/source/placeware/Base64Codec.hxx
new file mode 100644
index 000000000000..125b944876a9
--- /dev/null
+++ b/filter/source/placeware/Base64Codec.hxx
@@ -0,0 +1,47 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * 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 _BASE64_CODEC_HXX
+#define _BASE64_CODEC_HXX
+
+#include <com/sun/star/uno/Sequence.hxx>
+
+namespace rtl
+{
+class OUString;
+class OUStringBuffer;
+}
+
+class Base64Codec
+{
+public:
+ static void encodeBase64(rtl::OUStringBuffer& aStrBuffer, const com::sun::star::uno::Sequence<sal_Int8>& aPass);
+#if 0
+ static void decodeBase64(com::sun::star::uno::Sequence<sal_uInt8>& aPass, const rtl::OUString& sBuffer);
+#endif
+};
+#endif
diff --git a/filter/source/placeware/exporter.cxx b/filter/source/placeware/exporter.cxx
new file mode 100644
index 000000000000..964bc618af5d
--- /dev/null
+++ b/filter/source/placeware/exporter.cxx
@@ -0,0 +1,516 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_filter.hxx"
+#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
+#ifndef _COM_SUN_STAR_PRESENTATION_PRESENTATIONPAGE_HPP_
+#include <com/sun/star/presentation/XPresentationPage.hpp>
+#endif
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/document/XFilter.hpp>
+#include <com/sun/star/text/XText.hpp>
+#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/task/XStatusIndicatorFactory.hpp>
+#include <rtl/ustrbuf.hxx>
+#include <rtl/string.hxx>
+#include <osl/diagnose.h>
+
+#include <vector>
+
+#include "exporter.hxx"
+#include "Base64Codec.hxx"
+#include "zip.hxx"
+#include "tempfile.hxx"
+
+using rtl::OUString;
+using rtl::OString;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::drawing;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::document;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::text;
+using namespace ::std;
+
+using com::sun::star::beans::PropertyValue;
+using com::sun::star::beans::XPropertySet;
+using com::sun::star::presentation::XPresentationPage;
+using com::sun::star::task::XStatusIndicator;
+
+// -----------------------------------------------------------------------------
+
+PlaceWareExporter::PlaceWareExporter(const Reference< XMultiServiceFactory > &rxMSF)
+: mxMSF( rxMSF )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+PlaceWareExporter::~PlaceWareExporter()
+{
+}
+
+// -----------------------------------------------------------------------------
+class PageEntry
+{
+private:
+ TempFile maTempFile;
+ rtl::OUString maName;
+ rtl::OUString maTitle;
+ rtl::OUString maNotes;
+ rtl::OUString maURL;
+
+public:
+ PageEntry();
+ ~PageEntry();
+
+ OUString getTempURL() { return maTempFile.getFileURL(); }
+
+ void setName( const rtl::OUString& rName ) { maName = rName; }
+ const rtl::OUString& getName() const { return maName; }
+
+ void setTitle( const rtl::OUString& rTitle ) { maTitle = rTitle; }
+ const rtl::OUString& getTitle() const { return maTitle; }
+
+ void setNotes( const rtl::OUString& rNotes ) { maNotes = rNotes; }
+ const rtl::OUString& getNotes() const { return maNotes; }
+
+ void setURL( const rtl::OUString& rURL ) { maURL = rURL; }
+ const rtl::OUString& getURL() const { return maURL; }
+};
+
+PageEntry::PageEntry()
+: maTempFile( TempFile::createTempFileURL() )
+{
+}
+
+PageEntry::~PageEntry()
+{
+}
+
+
+static void encodeFile( osl::File& rSourceFile, Reference< XOutputStream >& xOutputStream ) throw( ::com::sun::star::uno::Exception )
+{
+ if( xOutputStream.is() )
+ {
+ sal_uInt64 nTemp( 0 );
+
+ osl::File::RC nRC = rSourceFile.setPos( osl_Pos_End, 0 );
+ if( osl::File::E_None == nRC )
+ {
+ nRC = rSourceFile.getPos( nTemp );
+ if( osl::File::E_None == nRC )
+ {
+ nRC = rSourceFile.setPos( osl_Pos_Absolut, 0 );
+ }
+ }
+
+ sal_Int32 nLen = static_cast<sal_Int32>(nTemp);
+
+ if( osl::File::E_None != nRC )
+ throw IOException();
+
+ sal_Int32 nBufferSize = 3*1024; // !!! buffer size must be a factor of 3 for base64 to work
+ Sequence< sal_Int8 > aInBuffer( nBufferSize < nLen ? nBufferSize : nLen );
+ void* pInBuffer = aInBuffer.getArray();
+
+ Sequence< sal_Int8 > aOutBuffer;
+ sal_Int32 nRead;
+ while( nLen )
+ {
+ nRC = rSourceFile.read( pInBuffer, aInBuffer.getLength(), nTemp );
+
+ if( (nRC != osl::File::E_None) || (0 == nTemp) )
+ throw IOException();
+
+ nRead = static_cast<sal_Int32>( nTemp );
+
+ if( nRead < aInBuffer.getLength() )
+ {
+ aInBuffer.realloc( nRead );
+ pInBuffer = aInBuffer.getArray();
+ }
+
+ nLen -= nRead;
+
+ rtl::OUStringBuffer aStrBuffer;
+ Base64Codec::encodeBase64( aStrBuffer, aInBuffer );
+
+ sal_Int32 nCount = aStrBuffer.getLength();
+
+ if( aOutBuffer.getLength() != nCount )
+ aOutBuffer.realloc( nCount );
+
+ sal_Int8* pBytes = aOutBuffer.getArray();
+ const sal_Unicode* pUnicode = aStrBuffer.getStr();
+
+ while( nCount-- )
+ {
+ // since base64 is always ascii, we can cast safely
+ *pBytes++ = static_cast<sal_Int8>(*pUnicode++);
+ }
+
+ xOutputStream->writeBytes( aOutBuffer );
+ }
+ }
+}
+
+static OString convertString( OUString aInput )
+{
+ OString aRet( aInput.getStr(), aInput.getLength(), RTL_TEXTENCODING_ASCII_US );
+ aRet = aRet.replace( '\r', ' ' );
+ aRet = aRet.replace( '\n', ' ' );
+
+ return aRet;
+}
+
+static void createSlideFile( Reference< XComponent > xDoc, ZipFile& rZipFile, const rtl::OUString& rURL, vector< PageEntry* >& rPageEntries ) throw( ::com::sun::star::uno::Exception )
+{
+ OString aInfo;
+
+ const OString aNewLine( "\r\n" );
+ OUString aTemp;
+
+ Reference< XDocumentPropertiesSupplier > xDPS( xDoc, UNO_QUERY );
+ Reference< XDocumentProperties > xDocProps( xDPS->getDocumentProperties() );
+
+ aTemp = xDocProps->getTitle();
+ if( 0 == aTemp.getLength() )
+ {
+ sal_Int32 nPos1 = rURL.lastIndexOf( (sal_Unicode)'/' );
+ if( -1 != nPos1 )
+ {
+ sal_Int32 nPos2 = rURL.lastIndexOf( (sal_Unicode)'.' );
+ if( nPos2 > nPos1 )
+ {
+ aTemp = rURL.copy( nPos1 + 1, nPos2 - nPos1 - 1 );
+ }
+ else
+ {
+ aTemp = rURL.copy( nPos1 + 1 );
+ }
+ }
+ else
+ {
+ aTemp = rURL;
+ }
+ }
+
+ aInfo += OString( "SlideSetName: " );
+ aInfo += convertString( aTemp );
+ aInfo += aNewLine;
+
+ aTemp = xDocProps->getAuthor();
+
+ if( aTemp.getLength() )
+ {
+ aInfo += OString( "PresenterName: " );
+ aInfo += convertString( aTemp );
+ aInfo += aNewLine;
+ }
+
+ vector< PageEntry* >::iterator aIter( rPageEntries.begin() );
+ vector< PageEntry* >::iterator aEnd( rPageEntries.end() );
+ while( aIter != aEnd )
+ {
+ PageEntry* pEntry = (*aIter++);
+
+ aInfo += OString( "slide: " );
+ if( pEntry->getTitle().getLength() )
+ {
+ aInfo += convertString( pEntry->getTitle() );
+ }
+ else
+ {
+ aInfo += convertString( pEntry->getName() );
+ }
+ aInfo += aNewLine;
+
+ aInfo += OString( "type: gif");
+ aInfo += aNewLine;
+
+ aInfo += OString( "url: " );
+ aInfo += convertString( pEntry->getURL() );
+ aInfo += aNewLine;
+
+
+ if( pEntry->getNotes().getLength() )
+ {
+ aInfo += OString( "notes: " );
+ aInfo += convertString( pEntry->getNotes() );
+ aInfo += aNewLine;
+ }
+ }
+
+ TempFile aInfoFile( TempFile::createTempFileURL() );
+
+ osl::File::RC nRC;
+ sal_uInt64 nTemp;
+
+ nRC = aInfoFile.open( OpenFlag_Write );
+ if( osl::File::E_None == nRC )
+ {
+ nRC = aInfoFile.write( aInfo.getStr(), aInfo.getLength(), nTemp );
+ if( osl::File::E_None == nRC )
+ {
+ nRC = aInfoFile.setPos( osl_Pos_Absolut, 0 );
+ if( osl::File::E_None == nRC )
+ {
+ nRC = aInfoFile.close();
+ }
+ }
+ }
+
+ if( (osl::File::E_None != nRC) || !rZipFile.addFile( aInfoFile, OString( RTL_CONSTASCII_STRINGPARAM("slides.txt") ) ))
+ throw IOException();
+}
+
+//#define PLACEWARE_DEBUG 1
+
+sal_Bool PlaceWareExporter::doExport( Reference< XComponent > xDoc, Reference < XOutputStream > xOutputStream,
+ const rtl::OUString& rURL, Reference < XInterface > /* xHandler */, Reference < XStatusIndicator >& xStatusIndicator )
+{
+ sal_Bool bRet = sal_False;
+
+ mxGraphicExporter = Reference< XExporter >::query( mxMSF->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.GraphicExportFilter") ) ) );
+ Reference< XDrawPagesSupplier > xDrawPagesSupplier(xDoc, UNO_QUERY);
+ if(!xDrawPagesSupplier.is())
+ return sal_False;
+
+ Reference< XIndexAccess > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY );
+ if(!xDrawPages.is())
+ return sal_False;
+
+ if(xStatusIndicator.is())
+ {
+ xStatusIndicator->start(OUString( RTL_CONSTASCII_USTRINGPARAM( "PlaceWare:" )),xDrawPages->getCount());
+ }
+
+ Reference< XDrawPage > xDrawPage;
+
+ osl::File::RC nRC;
+
+#ifndef PLACEWARE_DEBUG
+ TempFile aTempFile( TempFile::createTempFileURL() );
+ nRC = aTempFile.open( osl_File_OpenFlag_Write|osl_File_OpenFlag_Read );
+ OUString aURL( aTempFile.getFileURL() );
+#else
+ OUString aURL( RTL_CONSTASCII_USTRINGPARAM("file:///e:/test.zip") );
+ osl::File::remove( aURL );
+ osl::File aTempFile( aURL );
+ nRC = aTempFile.open( osl_File_OpenFlag_Create|osl_File_OpenFlag_Write|osl_File_OpenFlag_Read );
+#endif
+
+ if( osl::File::E_None != nRC )
+ return sal_False;
+
+ vector< PageEntry* > aPageEntries;
+
+ // Create new package...
+ try
+ {
+ ZipFile aZipFile(aTempFile);
+
+ // export slides as gifs and collect information for slides
+
+ const sal_Int32 nPageCount = xDrawPages->getCount();
+ sal_Int32 nPage;
+
+ for( nPage = 0; nPage < nPageCount; nPage++)
+ {
+ xDrawPages->getByIndex(nPage) >>= xDrawPage;
+
+ if( !xDrawPage.is() )
+ continue;
+
+ PageEntry* pEntry = exportPage( xDrawPage );
+ aPageEntries.push_back( pEntry );
+
+ OUString aName( RTL_CONSTASCII_USTRINGPARAM("i") );
+ aName += OUString::valueOf( nPage );
+ aName += OUString( RTL_CONSTASCII_USTRINGPARAM(".gif") );
+ pEntry->setURL( aName );
+
+ if(xStatusIndicator.is())
+ {
+ xStatusIndicator->setValue( nPage + 1 );
+ }
+ }
+
+ // create the slide.txt file
+
+ createSlideFile( xDoc, aZipFile, rURL, aPageEntries );
+
+ // add gifs to zip
+ vector< PageEntry* >::iterator aIter( aPageEntries.begin() );
+ vector< PageEntry* >::iterator aEnd( aPageEntries.end() );
+ while( aIter != aEnd )
+ {
+ PageEntry* pEntry = (*aIter++);
+
+ osl::File aFile(pEntry->getTempURL() );
+ const OUString aTemp( pEntry->getURL() );
+
+ if( (osl::File::E_None != nRC) || !aZipFile.addFile( aFile, OString( aTemp.getStr(), aTemp.getLength(), RTL_TEXTENCODING_ASCII_US ) ) )
+ throw IOException();
+ }
+
+ if(!aZipFile.close())
+ throw IOException();
+
+ encodeFile( aTempFile, xOutputStream );
+
+ bRet = sal_True;
+ }
+ catch ( RuntimeException const & )
+ {
+ }
+ catch ( Exception const & )
+ {
+ }
+
+ vector< PageEntry* >::iterator aIter( aPageEntries.begin() );
+ vector< PageEntry* >::iterator aEnd( aPageEntries.end() );
+ while( aIter != aEnd )
+ {
+ delete (*aIter++);
+ }
+
+ if( xStatusIndicator.is() )
+ xStatusIndicator->end();
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+PageEntry* PlaceWareExporter::exportPage( Reference< XDrawPage >&xDrawPage )
+{
+ Reference< XComponent > xComp( xDrawPage, UNO_QUERY );
+
+ PageEntry* pEntry = new PageEntry();
+
+ // get page name
+ Reference< XNamed > xNamed( xDrawPage, UNO_QUERY );
+ if( xNamed.is() )
+ pEntry->setName( xNamed->getName() );
+
+ // get title text from title presentation shape if available
+ const OUString szTitleTextShape( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.TitleTextShape") );
+ const OUString szIsEmptyPresObj( RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") );
+
+ sal_Int32 nShapeCount = xDrawPage->getCount();
+ sal_Int32 nShape;
+ for( nShape = 0; nShape < nShapeCount; nShape++ )
+ {
+ Reference< XShape > xShape;
+ xDrawPage->getByIndex( nShape ) >>= xShape;
+
+ if( xShape.is() && xShape->getShapeType() == szTitleTextShape )
+ {
+ Reference< XPropertySet > xPropSet( xShape, UNO_QUERY );
+ if( xPropSet.is() )
+ {
+ sal_Bool bIsEmpty = true;
+ xPropSet->getPropertyValue( szIsEmptyPresObj ) >>= bIsEmpty;
+
+ if( !bIsEmpty )
+ {
+ Reference< XText > xText( xShape, UNO_QUERY );
+ if( xText.is() )
+ {
+ pEntry->setTitle( xText->getString() );
+ }
+ }
+ }
+ break;
+ }
+ }
+
+ // get notes text if available
+ Reference< XPresentationPage > xPresPage( xDrawPage, UNO_QUERY );
+ if( xPresPage.is() )
+ {
+ Reference< XDrawPage > xNotesPage( xPresPage->getNotesPage() );
+
+ const OUString szNotesShape( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.NotesShape") );
+
+ nShapeCount = xNotesPage->getCount();
+ for( nShape = 0; nShape < nShapeCount; nShape++ )
+ {
+ Reference< XShape > xShape;
+ xNotesPage->getByIndex( nShape ) >>= xShape;
+
+ if( xShape.is() && (xShape->getShapeType() == szNotesShape) )
+ {
+ Reference< XPropertySet > xPropSet( xShape, UNO_QUERY );
+ if( xPropSet.is() )
+ {
+ sal_Bool bIsEmpty = true;
+ xPropSet->getPropertyValue( szIsEmptyPresObj ) >>= bIsEmpty;
+
+ if( !bIsEmpty )
+ {
+ Reference< XText > xText( xShape, UNO_QUERY );
+ if( xText.is() )
+ {
+ pEntry->setNotes( xText->getString() );
+ }
+ }
+ }
+ break;
+ }
+ }
+ }
+
+ // create the gif
+ Reference< XFilter > xFilter( mxGraphicExporter, UNO_QUERY );
+
+ Sequence< PropertyValue > aFilterData( 2 );
+ aFilterData[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM("Width") );
+ aFilterData[0].Value <<= (sal_Int32)704;
+ aFilterData[1].Name = OUString( RTL_CONSTASCII_USTRINGPARAM("Translucent") );
+ aFilterData[1].Value <<= (sal_Bool)sal_False;
+
+ Sequence< PropertyValue > aDescriptor( 3 );
+ aDescriptor[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM("FilterName") );
+ aDescriptor[0].Value <<= OUString( RTL_CONSTASCII_USTRINGPARAM("GIF") );
+ aDescriptor[1].Name = OUString( RTL_CONSTASCII_USTRINGPARAM("URL") );
+ aDescriptor[1].Value <<= OUString( pEntry->getTempURL() );
+ aDescriptor[2].Name = OUString( RTL_CONSTASCII_USTRINGPARAM("FilterData") );
+ aDescriptor[2].Value <<= aFilterData;
+ mxGraphicExporter->setSourceDocument( xComp );
+ xFilter->filter( aDescriptor );
+
+ return pEntry;
+}
diff --git a/filter/source/placeware/exporter.hxx b/filter/source/placeware/exporter.hxx
new file mode 100644
index 000000000000..d52519cfcb4e
--- /dev/null
+++ b/filter/source/placeware/exporter.hxx
@@ -0,0 +1,60 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * 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 _PLACEWARE_EXPORTER_HXX
+#define _PLACEWARE_EXPORTER_HXX
+
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/io/XOutputStream.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/document/XExporter.hpp>
+#include <com/sun/star/drawing/XDrawPage.hpp>
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#include <com/sun/star/task/XStatusIndicator.hpp>
+
+class PageEntry;
+
+class PlaceWareExporter
+{
+public:
+ PlaceWareExporter( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxMSF );
+ ~PlaceWareExporter();
+
+ sal_Bool doExport( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xDoc,
+ ::com::sun::star::uno::Reference < ::com::sun::star::io::XOutputStream > xOutputStream,
+ const rtl::OUString& rURL,
+ ::com::sun::star::uno::Reference < ::com::sun::star::uno::XInterface > xHandler,
+ ::com::sun::star::uno::Reference < ::com::sun::star::task::XStatusIndicator >& rxStatusIndicator );
+
+private:
+ PageEntry* exportPage( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >&xDrawPage );
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF;
+ ::com::sun::star::uno::Reference< ::com::sun::star::document::XExporter > mxGraphicExporter;
+ ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > mxInteractionHandler;
+};
+
+#endif
diff --git a/filter/source/placeware/exports.dxp b/filter/source/placeware/exports.dxp
new file mode 100644
index 000000000000..9630d7e06768
--- /dev/null
+++ b/filter/source/placeware/exports.dxp
@@ -0,0 +1,3 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
diff --git a/filter/source/placeware/filter.cxx b/filter/source/placeware/filter.cxx
new file mode 100644
index 000000000000..b38927d793d6
--- /dev/null
+++ b/filter/source/placeware/filter.cxx
@@ -0,0 +1,217 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_filter.hxx"
+#include <com/sun/star/document/XFilter.hpp>
+#include <com/sun/star/document/XExporter.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <cppuhelper/implbase4.hxx>
+
+#include "exporter.hxx"
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+
+using ::rtl::OUString;
+using ::com::sun::star::lang::XComponent;
+using ::com::sun::star::beans::PropertyValue;
+using ::com::sun::star::io::XOutputStream;
+using ::com::sun::star::task::XStatusIndicator;
+
+namespace pwp {
+
+// -----------------------------------------------------------------------------
+
+class PlaceWareExportFilter : public cppu::WeakImplHelper4
+<
+ com::sun::star::document::XFilter,
+ com::sun::star::document::XExporter,
+ com::sun::star::lang::XInitialization,
+ com::sun::star::lang::XServiceInfo
+>
+{
+ Reference< XComponent > mxDoc;
+ Reference< XMultiServiceFactory > mxMSF;
+
+public:
+ PlaceWareExportFilter( const Reference< XMultiServiceFactory > &rxMSF);
+
+ // XFilter
+ virtual sal_Bool SAL_CALL filter( const Sequence< PropertyValue >& aDescriptor ) throw(RuntimeException);
+ virtual void SAL_CALL cancel( ) throw (RuntimeException);
+
+ // XExporter
+ virtual void SAL_CALL setSourceDocument( const Reference< XComponent >& xDoc ) throw(IllegalArgumentException, RuntimeException);
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const Sequence< Any >& aArguments ) throw(Exception, RuntimeException);
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName() throw(RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(RuntimeException);
+ virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException);
+};
+
+// -----------------------------------------------------------------------------
+
+PlaceWareExportFilter::PlaceWareExportFilter(const Reference< XMultiServiceFactory > &rxMSF)
+: mxMSF( rxMSF )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool SAL_CALL PlaceWareExportFilter::filter( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
+ throw (RuntimeException)
+{
+ sal_Int32 nLength = aDescriptor.getLength();
+ const PropertyValue * pValue = aDescriptor.getConstArray();
+ OUString sFileName, sURL;
+ Reference < XInterface > xInteractionHandler;
+ Reference < XOutputStream > xOutputStream;
+ Reference < XStatusIndicator > xStatusIndicator;
+ for ( sal_Int32 i = 0 ; i < nLength; i++)
+ {
+ if ( pValue[i].Name.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "OutputStream" ) ) )
+ {
+ pValue[i].Value >>= xOutputStream;
+ }
+ else if( pValue[i].Name.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "URL" ) ) )
+ {
+ pValue[i].Value >>= sURL;
+ }
+ else if( pValue[i].Name.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "InteractionHandler" ) ) )
+ {
+ pValue[i].Value >>= xInteractionHandler;
+ }
+ else if ( pValue[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "StatusIndicator" ) ) )
+ {
+ pValue[i].Value >>= xStatusIndicator;
+ }
+ }
+ if ( !xOutputStream.is() )
+ {
+ OSL_ASSERT ( 0 );
+ return sal_False;
+ }
+
+ PlaceWareExporter aExporter( mxMSF );
+ return aExporter.doExport( mxDoc, xOutputStream, sURL, xInteractionHandler, xStatusIndicator );
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL PlaceWareExportFilter::cancel( )
+ throw (RuntimeException)
+{
+}
+
+// -----------------------------------------------------------------------------
+
+// XExporter
+void SAL_CALL PlaceWareExportFilter::setSourceDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc )
+ throw (::com::sun::star::lang::IllegalArgumentException, RuntimeException)
+{
+ mxDoc = xDoc;
+}
+
+// -----------------------------------------------------------------------------
+
+// XInitialization
+void SAL_CALL PlaceWareExportFilter::initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& /* aArguments */ )
+ throw (Exception, RuntimeException)
+{
+}
+
+// -----------------------------------------------------------------------------
+
+OUString PlaceWareExportFilter_getImplementationName ()
+ throw (RuntimeException)
+{
+ return OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Impress.PlaceWareExportFilter" ) );
+}
+
+// -----------------------------------------------------------------------------
+
+#define SERVICE_NAME "com.sun.star.document.ExportFilter"
+
+sal_Bool SAL_CALL PlaceWareExportFilter_supportsService( const OUString& ServiceName )
+ throw (RuntimeException)
+{
+ return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME ) );
+}
+
+// -----------------------------------------------------------------------------
+
+Sequence< OUString > SAL_CALL PlaceWareExportFilter_getSupportedServiceNames( )
+ throw (RuntimeException)
+{
+ Sequence < OUString > aRet(1);
+ OUString* pArray = aRet.getArray();
+ pArray[0] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
+ return aRet;
+}
+#undef SERVICE_NAME
+
+// -----------------------------------------------------------------------------
+
+Reference< XInterface > SAL_CALL PlaceWareExportFilter_createInstance( const Reference< XMultiServiceFactory > & rSMgr)
+ throw( Exception )
+{
+ return (cppu::OWeakObject*) new PlaceWareExportFilter( rSMgr );
+}
+
+// -----------------------------------------------------------------------------
+
+// XServiceInfo
+OUString SAL_CALL PlaceWareExportFilter::getImplementationName( )
+ throw (RuntimeException)
+{
+ return PlaceWareExportFilter_getImplementationName();
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool SAL_CALL PlaceWareExportFilter::supportsService( const OUString& rServiceName )
+ throw (RuntimeException)
+{
+ return PlaceWareExportFilter_supportsService( rServiceName );
+}
+
+// -----------------------------------------------------------------------------
+
+::com::sun::star::uno::Sequence< OUString > SAL_CALL PlaceWareExportFilter::getSupportedServiceNames( )
+ throw (RuntimeException)
+{
+ return PlaceWareExportFilter_getSupportedServiceNames();
+}
+
+// -----------------------------------------------------------------------------
+
+}
diff --git a/filter/source/placeware/makefile.mk b/filter/source/placeware/makefile.mk
new file mode 100644
index 000000000000..3238193c52ae
--- /dev/null
+++ b/filter/source/placeware/makefile.mk
@@ -0,0 +1,67 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..
+PRJNAME=filter
+TARGET=placeware
+USE_DEFFILE= TRUE
+ENABLE_EXCEPTIONS=TRUE
+COMP1TYPELIST=$(TARGET)
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files -------------------------------------
+
+SLOFILES= $(SLO)$/zip.obj \
+ $(SLO)$/filter.obj \
+ $(SLO)$/uno.obj \
+ $(SLO)$/exporter.obj \
+ $(SLO)$/Base64Codec.obj \
+ $(SLO)$/tempfile.obj
+
+# --- Library -----------------------------------
+
+SHL1TARGET=$(TARGET)$(DLLPOSTFIX)
+
+SHL1STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALLIB)
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+
+SHL1DEPN=
+SHL1IMPLIB= i$(TARGET)
+SHL1LIBS= $(SLB)$/$(TARGET).lib
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
diff --git a/filter/source/placeware/placeware.xml b/filter/source/placeware/placeware.xml
new file mode 100644
index 000000000000..472abd18617f
--- /dev/null
+++ b/filter/source/placeware/placeware.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE module-description PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "module-description.dtd">
+<module-description xmlns:xlink="http://www.w3.org/1999/xlink">
+ <module-name> placeware </module-name>
+ <component-description>
+ <author> Christian Lippka </author>
+ <name> com.sun.star.comp.Impress.PlaceWareExportFilter </name>
+ <description>
+ This service implements a filter to export com.sun.star.presentation.PresentationDocument into the
+ PlaceWare slide set format.
+ </description>
+ <loader-name> com.sun.star.loader.SharedLibrary </loader-name>
+ <language> C++ </language>
+ <status value="beta"/>
+ <supported-service> com.sun.star.document.ExportFilter </supported-service>
+ <service-dependency> ... </service-dependency>
+ <type> com.sun.star.document.XFilter </type>
+ <type> com.sun.star.document.XExporter </type>
+ <type> com.sun.star.lang.XInitialization </type>
+ <type> com.sun.star.lang.XServiceInfo </type>
+ <type> com.sun.star.container.XNamed </type>
+ <type> com.sun.star.beans.PropertyValue </type>
+ <type> com.sun.star.beans.XPropertySet </type>
+ <type> com.sun.star.drawing.XDrawPagesSupplier </type>
+ <type> com.sun.star.presentation.XPresentationPage </type>
+ <type> com.sun.star.container.XIndexAccess </type>
+ <type> com.sun.star.text.XText </type>
+ <type> com.sun.star.document.XDocumentPropertiesSupplier </type>
+ <type> com.sun.star.document.XDocumentProperties </type>
+ <type> com.sun.star.lang.XComponent </type>
+ <type> com.sun.star.drawing.XDrawPage </type>
+ <type> com.sun.star.task.XInteractionHandler </type>
+ <type> com.sun.star.lang.XSingleServiceFactory </type>
+ <type> com.sun.star.uno.XAggregation </type>
+ <type> com.sun.star.uno.XWeak </type>
+ <type> com.sun.star.uno.XComponentContext </type>
+ <type> com.sun.star.uno.TypeClass </type>
+ </component-description>
+ <project-build-dependency> cppuhelper </project-build-dependency>
+ <project-build-dependency> cppu </project-build-dependency>
+ <project-build-dependency> sal </project-build-dependency>
+ <runtime-module-dependency> cppuhelper2$(COM) </runtime-module-dependency>
+ <runtime-module-dependency> cppu2 </runtime-module-dependency>
+ <runtime-module-dependency> sal2 </runtime-module-dependency>
+</module-description>
diff --git a/filter/source/placeware/tempfile.cxx b/filter/source/placeware/tempfile.cxx
new file mode 100644
index 000000000000..46c01e80d4a4
--- /dev/null
+++ b/filter/source/placeware/tempfile.cxx
@@ -0,0 +1,189 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_filter.hxx"
+
+
+#include <osl/file.h>
+
+#if defined( UNX) || defined(OS2)
+
+#include <stdio.h>
+#include <string.h>
+#include <osl/thread.h>
+
+oslFileError SAL_CALL my_getTempDirURL( rtl_uString** pustrTempDir )
+{
+ const char *pValue = getenv( "TEMP" );
+
+ if ( !pValue )
+ {
+ pValue = getenv( "TMP" );
+#if defined(SOLARIS) || defined (LINUX)
+ if ( !pValue )
+ pValue = P_tmpdir;
+#endif
+ }
+
+ if ( pValue )
+ {
+ oslFileError error;
+ rtl_uString *ustrTempPath = NULL;
+
+ rtl_string2UString( &ustrTempPath, pValue, strlen( pValue ), osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS );
+ error = osl_getFileURLFromSystemPath( ustrTempPath, pustrTempDir );
+ rtl_uString_release( ustrTempPath );
+
+ return error;
+ }
+ else
+ return osl_File_E_NOENT;
+}
+#else
+
+#ifdef NDEBUG
+# define NO_DEBUG_CRT
+#endif
+
+#ifndef _WIN32_WINNT
+# define _WIN32_WINNT 0x0400
+# define _CTYPE_DISABLE_MACROS /* wg. dynamischer C-Runtime MH */
+#endif
+
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <malloc.h>
+
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+
+#define elementsof(arr) (sizeof(arr)/sizeof(arr[0]))
+
+oslFileError SAL_CALL my_getTempDirURL( rtl_uString** pustrTempDir )
+{
+ WCHAR szBuffer[MAX_PATH];
+ LPWSTR lpBuffer = szBuffer;
+ DWORD nBufferLength = elementsof(szBuffer) - 1;
+
+ DWORD nLength;
+ oslFileError error;
+
+ do
+ {
+ nLength = GetTempPathW( elementsof(szBuffer), lpBuffer );
+ if ( nLength > nBufferLength )
+ {
+ nLength++;
+ lpBuffer = (LPWSTR)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 = GetLastError() == ERROR_SUCCESS ? osl_File_E_None : osl_File_E_INVAL;
+
+ return error;
+}
+#endif
+
+#include "tempfile.hxx"
+
+using namespace rtl;
+
+TempFile::TempFile( const OUString& rTempFileURL )
+:osl::File( rTempFileURL ), maURL( rTempFileURL )
+{
+}
+
+TempFile::~TempFile()
+{
+ close();
+
+ if( maURL.getLength() )
+ osl::File::remove( maURL );
+}
+
+OUString TempFile::createTempFileURL()
+{
+ OUString aTempFileURL;
+
+ const sal_uInt32 nRadix = 26;
+
+ OUString aTempDirURL;
+ /* oslFileError nRC = */ my_getTempDirURL( &aTempDirURL.pData );
+
+ static sal_uInt32 u = osl_getGlobalTimer();
+ for ( sal_uInt32 nOld = u; ++u != nOld; )
+ {
+ u %= (nRadix*nRadix*nRadix);
+ OUString aTmp( aTempDirURL );
+ if( aTmp.getStr()[ aTmp.getLength() - 1 ] != sal_Unicode( '/' ) )
+ aTmp += OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ));
+ aTmp += OUString::valueOf( (sal_Int32) (unsigned) u, nRadix );
+ aTmp += OUString::createFromAscii( ".tmp" );
+
+ osl::File aFile( aTmp );
+ osl::FileBase::RC err = aFile.open(osl_File_OpenFlag_Create);
+ if ( err == FileBase::E_None )
+ {
+ aTempFileURL = aTmp;
+ aFile.close();
+ break;
+ }
+ else if ( err != FileBase::E_EXIST )
+ {
+ // if f.e. name contains invalid chars stop trying to create files
+ break;
+ }
+ }
+
+ return aTempFileURL;
+}
+
+OUString TempFile::getFileURL()
+{
+ return maURL;
+}
diff --git a/filter/source/placeware/tempfile.hxx b/filter/source/placeware/tempfile.hxx
new file mode 100644
index 000000000000..d1f8335b38d5
--- /dev/null
+++ b/filter/source/placeware/tempfile.hxx
@@ -0,0 +1,48 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * 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 _PLACEWARE_TEMPFILE_HXX_
+#define _PLACEWARE_TEMPFILE_HXX_
+
+#include <osl/file.hxx>
+#include <rtl/ustring.hxx>
+
+class TempFile : public osl::File
+{
+public:
+ TempFile( const rtl::OUString& aURL );
+ ~TempFile();
+
+ static rtl::OUString createTempFileURL();
+ rtl::OUString getFileURL();
+
+private:
+ rtl::OUString maURL;
+};
+
+
+#endif
diff --git a/filter/source/placeware/uno.cxx b/filter/source/placeware/uno.cxx
new file mode 100644
index 000000000000..c11b4392a1b4
--- /dev/null
+++ b/filter/source/placeware/uno.cxx
@@ -0,0 +1,110 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_filter.hxx"
+
+#include <stdio.h>
+
+#include <osl/mutex.hxx>
+#include <osl/thread.h>
+#include <cppuhelper/factory.hxx>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+
+using namespace ::rtl;
+using namespace ::cppu;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::registry;
+
+namespace pwp {
+extern OUString PlaceWareExportFilter_getImplementationName() throw ( RuntimeException );
+extern sal_Bool SAL_CALL PlaceWareExportFilter_supportsService( const OUString& ServiceName ) throw ( RuntimeException );
+extern Sequence< OUString > SAL_CALL PlaceWareExportFilter_getSupportedServiceNames() throw ( RuntimeException );
+extern Reference< XInterface > SAL_CALL PlaceWareExportFilter_createInstance( const Reference< XMultiServiceFactory > & rSMgr) throw ( Exception );
+}
+
+using namespace ::pwp;
+
+extern "C"
+{
+//==================================================================================================
+void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** /* ppEnv */ )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+//==================================================================================================
+sal_Bool SAL_CALL component_writeInfo(
+ void * /* pServiceManager */, void * pRegistryKey )
+{
+ if (pRegistryKey)
+ {
+ try
+ {
+ Reference< XRegistryKey > xNewKey(
+ reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey( PlaceWareExportFilter_getImplementationName() ) );
+ xNewKey = xNewKey->createKey( OUString::createFromAscii( "/UNO/SERVICES" ) );
+
+ const Sequence< OUString > & rSNL = PlaceWareExportFilter_getSupportedServiceNames();
+ const OUString * pArray = rSNL.getConstArray();
+ for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
+ xNewKey->createKey( pArray[nPos] );
+
+ return sal_True;
+ }
+ catch (InvalidRegistryException &)
+ {
+ OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
+ }
+ }
+ return sal_False;
+}
+//==================================================================================================
+void * SAL_CALL component_getFactory(
+ const sal_Char * pImplName, void * pServiceManager, void * /* pRegistryKey */ )
+{
+ void * pRet = 0;
+
+ OUString implName = OUString::createFromAscii( pImplName );
+ if ( pServiceManager && implName.equals(PlaceWareExportFilter_getImplementationName()) )
+ {
+ Reference< XSingleServiceFactory > xFactory( createSingleFactory(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
+ OUString::createFromAscii( pImplName ),
+ PlaceWareExportFilter_createInstance, PlaceWareExportFilter_getSupportedServiceNames() ) );
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+}
+}
diff --git a/filter/source/placeware/zip.cxx b/filter/source/placeware/zip.cxx
new file mode 100644
index 000000000000..494ce2e576c4
--- /dev/null
+++ b/filter/source/placeware/zip.cxx
@@ -0,0 +1,332 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_filter.hxx"
+
+/*
+#include <tools/datetime.hxx>
+*/
+#include <osl/diagnose.h>
+#include <rtl/crc.h>
+
+#include "zip.hxx"
+#include "zipfile.hxx"
+
+using namespace rtl;
+
+/** this struct describes one entry in a zip file */
+struct ZipEntry
+{
+ OString name; /* the name we used */
+ sal_Int32 offset; /* where the header starts */
+ sal_Int32 endOffset; /* where the file data ends */
+ sal_Int32 crc;
+ sal_Int32 modTime; /* dos mod time & date */
+ sal_Int32 fileLen; /* file size, in bytes */
+};
+
+/** put one byte inside this stream */
+static osl::File::RC putC( unsigned char c, osl::File& rFile )
+{
+ sal_uInt64 nBytesWritten;
+ osl::File::RC nRC = rFile.write( &c, 1, nBytesWritten );
+
+ OSL_ASSERT( nBytesWritten == 1 );
+ return nRC;
+}
+
+/** write a short to the ZipFile */
+void ZipFile::writeShort( sal_Int16 s)
+{
+ if( !isError() )
+ {
+ mnRC = putC( static_cast< unsigned char >( s & 0xff ), mrFile );
+ if( !isError() )
+ mnRC = putC( static_cast< unsigned char >( (s >> 8) & 0xff ), mrFile );
+ }
+}
+
+/** write a long to the ZipFile */
+
+void ZipFile::writeLong( sal_Int32 l )
+{
+ if( !isError() )
+ {
+ mnRC = putC( static_cast< unsigned char >( l & 0xff ), mrFile);
+ if( !isError() )
+ {
+ mnRC = putC( static_cast< unsigned char >( (l >> 8) & 0xff ), mrFile);
+ if( !isError() )
+ {
+ mnRC = putC( static_cast< unsigned char >( (l >> 16) & 0xff ), mrFile);
+ if( !isError() )
+ {
+ mnRC = putC( static_cast< unsigned char >( (l >> 24) & 0xff ), mrFile);
+ }
+ }
+ }
+ }
+}
+
+/** copy the zipentries file to the zipfile and updates the crc of that zipentry */
+void ZipFile::copyAndCRC(ZipEntry *e, osl::File& rFile)
+{
+ char buf[2048];
+ sal_uInt64 n, nWritten;
+
+ e->crc = rtl_crc32( 0, 0L, 0 );
+
+ while( !isError() )
+ {
+ mnRC = rFile.read( buf, sizeof(buf), n );
+ if(n == 0)
+ break;
+
+ if( !isError() )
+ {
+ sal_uInt32 nTemp = static_cast<sal_uInt32>(n);
+ e->crc = rtl_crc32( e->crc, (const void *) buf, nTemp );
+ mnRC = mrFile.write( buf, n, nWritten );
+ OSL_ASSERT( n == nWritten );
+ }
+ }
+
+ if( !isError() )
+ {
+ sal_uInt64 nPosition = 0;
+ mnRC = mrFile.getPos( nPosition );
+ if( !isError() )
+ {
+ e->endOffset = static_cast< sal_Int32 >( nPosition );
+ }
+ }
+}
+
+/** write a yet empty local header for a zipentry to the zipfile */
+void ZipFile::writeDummyLocalHeader(ZipEntry *e)
+{
+ sal_Int32 len = zf_lfhSIZE + e->name.getLength();
+ sal_Int32 i;
+
+ sal_uInt64 nPosition = 0;
+ mnRC = mrFile.getPos( nPosition );
+ if( !isError() )
+ {
+ e->offset = static_cast< sal_Int32 >( nPosition );
+
+ for (i = 0; (i < len) && !isError(); ++i)
+ mnRC = putC(0, mrFile);
+ }
+}
+
+/** write the local header for a zipentry to the zipfile */
+void ZipFile::writeLocalHeader(ZipEntry *e)
+{
+ TimeValue aTime;
+ osl_getSystemTime( &aTime );
+
+ oslDateTime aDate;
+ osl_getDateTimeFromTimeValue( &aTime, &aDate );
+
+ e->modTime = ((aDate.Year - 1980) << 25) | (aDate.Month << 21) | (aDate.Day << 16) |
+ (aDate.Hours << 11) | (aDate.Minutes << 5) | (aDate.Seconds >> 1);
+
+ e->fileLen = e->endOffset - e->offset - zf_lfhSIZE - e->name.getLength();
+
+ if(!isError())
+ {
+ mnRC = mrFile.setPos( Pos_Absolut, e->offset );
+
+ writeLong(zf_LFHSIGValue); // magic number
+ writeShort(zf_Vers(1, 0)); // extract version
+ writeShort(0); // flags
+ writeShort(zf_compNone); // compression method
+ writeLong(e->modTime); // file mod date & time
+ writeLong(e->crc); // file crc
+ writeLong(e->fileLen); // compressed size
+ writeLong(e->fileLen); // uncompressed size
+ writeShort((sal_Int16) e->name.getLength()); // name length
+ writeShort(0); // extra length field
+
+ if( !isError() )
+ {
+ sal_uInt64 nWritten;
+ mnRC = mrFile.write( e->name.getStr(), e->name.getLength(), nWritten ); // file name
+ OSL_ASSERT( nWritten == (sal_uInt64)e->name.getLength() );
+ if( !isError() )
+ {
+ mnRC = mrFile.setPos( Pos_Absolut, e->endOffset );
+ }
+ }
+ }
+}
+
+/* write a zipentry in the central dir to the zipfile */
+void ZipFile::writeCentralDir(ZipEntry *e)
+{
+ writeLong(zf_CDHSIGValue); // magic number
+ writeShort(zf_Vers(1, 0)); // version made by
+ writeShort(zf_Vers(1, 0)); // vers to extract
+ writeShort(0); // flags
+ writeShort(zf_compNone); // compression method
+ writeLong(e->modTime); // file mod time & date
+ writeLong(e->crc);
+ writeLong(e->fileLen); // compressed file size
+ writeLong(e->fileLen); // uncompressed file size
+ writeShort((sal_Int16) e->name.getLength()); // name length
+ writeShort(0); // extra field length
+ writeShort(0); // file comment length
+ writeShort(0); // disk number start
+ writeShort(0); // internal file attributes
+ writeLong(0); // external file attributes
+ writeLong(e->offset); // offset w.r.t disk
+ if( !isError() )
+ {
+ sal_uInt64 nWritten;
+ mrFile.write( e->name.getStr(), e->name.getLength(), nWritten ); // file name
+ OSL_ASSERT( nWritten == (sal_uInt64)e->name.getLength() );
+ }
+}
+
+/* write the end of the central dir to the zipfile */
+void ZipFile::writeEndCentralDir(sal_Int32 nCdOffset, sal_Int32 nCdSize)
+{
+ writeLong(zf_ECDSIGValue); // magic number
+ writeShort(0); // disk num
+ writeShort(0); // disk with central dir
+ writeShort( static_cast< sal_Int16 >( maEntries.size() ) ); // number of file entries
+ writeShort( static_cast< sal_Int16 >( maEntries.size() ) ); // number of file entries
+ writeLong(nCdSize); // central dir size
+ writeLong(nCdOffset);
+ writeShort(0); // comment len
+}
+
+
+/****************************************************************
+ * The exported functions
+ ****************************************************************/
+
+/* Create a zip file for writing, return a handle for it.
+ * RETURNS: A new zip-file output object, or NULL if it failed, in
+ * which case *errMsgBuffer will contain an error message string. */
+ZipFile::ZipFile(osl::File& rFile )
+: mrFile( rFile ), mbOpen( true ), mnRC( osl::File::E_None )
+{
+}
+
+ZipFile::~ZipFile()
+{
+ if( mbOpen )
+ close();
+}
+
+/* Add a file to this zip with the given name.
+ * RETURNS: true if successful, else false. If false, the caller should
+ * call zip_Close() and delete the bum zip file.
+*/
+bool ZipFile::addFile( osl::File& rFile, const OString& rName )
+{
+ OSL_ASSERT( mbOpen );
+
+ if( !mbOpen )
+ return false;
+
+ OSL_ASSERT( 0 != rName.getLength() );
+
+ if(0 == rName.getLength())
+ return false;
+
+ mnRC = rFile.open( osl_File_OpenFlag_Read );
+
+ if( !isError() )
+ {
+ ZipEntry *e = new ZipEntry;
+ e->name = rName;
+ maEntries.push_back(e);
+
+ writeDummyLocalHeader(e);
+ if( !isError() )
+ {
+ copyAndCRC(e, rFile);
+ if(!isError())
+ {
+ writeLocalHeader(e);
+ }
+ }
+
+ rFile.close();
+ }
+
+ return !isError();
+}
+
+/* Finish up the zip file, close it, and deallocate the zip file object.
+ * RETURNS: true if successful, else false.
+*/
+bool ZipFile::close()
+{
+ OSL_ASSERT( mbOpen );
+
+ if( !mbOpen )
+ return false;
+
+ if( !isError() )
+ {
+ sal_uInt64 nCdOffset;
+ mrFile.getPos( nCdOffset );
+
+ std::vector< ZipEntry* >::iterator aIter( maEntries.begin() );
+ while((aIter != maEntries.end()) && !isError())
+ {
+ writeCentralDir( (*aIter++) );
+ }
+
+ if( !isError() )
+ {
+ sal_uInt64 nCdSize;
+ mrFile.getPos( nCdSize );
+
+ nCdSize -= nCdOffset;
+
+ if( !isError() )
+ {
+ writeEndCentralDir(static_cast<sal_Int32>(nCdOffset), static_cast<sal_Int32>(nCdSize));
+ }
+ }
+ }
+
+ std::vector< ZipEntry* >::iterator aIter( maEntries.begin() );
+ while( aIter != maEntries.end() )
+ {
+ delete (*aIter++);
+ }
+
+ mbOpen = false;
+
+ return !isError();
+}
diff --git a/filter/source/placeware/zip.hxx b/filter/source/placeware/zip.hxx
new file mode 100644
index 000000000000..b43ed32b8e7d
--- /dev/null
+++ b/filter/source/placeware/zip.hxx
@@ -0,0 +1,62 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * 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 <sal/types.h>
+#include <rtl/string.hxx>
+#include <osl/file.hxx>
+
+#include <vector>
+
+struct ZipEntry;
+
+class ZipFile
+{
+public:
+ ZipFile( osl::File& rFile );
+ ~ZipFile();
+
+ bool addFile( osl::File& rFile, const rtl::OString& rName );
+ bool close();
+
+private:
+ void writeShort( sal_Int16 s);
+ void writeLong( sal_Int32 l );
+
+ void copyAndCRC( ZipEntry *e, osl::File& rFile );
+ void writeDummyLocalHeader(ZipEntry *e);
+ void writeLocalHeader(ZipEntry *e);
+ void writeCentralDir(ZipEntry *e);
+ void writeEndCentralDir(sal_Int32 nCdOffset, sal_Int32 nCdSize);
+
+private:
+ bool isError() const { return osl::File::E_None != mnRC; }
+
+ osl::File& mrFile; /* file we're writing to */
+ bool mbOpen;
+ osl::File::RC mnRC;
+ std::vector<ZipEntry*> maEntries;
+};
diff --git a/filter/source/placeware/zipfile.hxx b/filter/source/placeware/zipfile.hxx
new file mode 100644
index 000000000000..33d9c1d1d587
--- /dev/null
+++ b/filter/source/placeware/zipfile.hxx
@@ -0,0 +1,91 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+/* Local file head offsets. The header is followed by the filename and
+ possibly the extra field. */
+#define zf_lfhSig 0
+#define zf_lfhExVers 4
+#define zf_lfhFlags 6
+#define zf_lfhComp 8
+#define zf_lfhModTime 10
+#define zf_lfhModDate 12
+#define zf_lfhCRC 14
+#define zf_lfhCompSize 18
+#define zf_lfhUncompSize 22
+#define zf_lfhNameLen 26
+#define zf_lfhExtraLen 28
+#define zf_lfhSIZE 30 /* total size of header */
+
+/* We don't write data descriptors. */
+
+/* Central dir file header offsets. Each entry is followed by the filename,
+ optional extra field, and file comment. */
+#define zf_cdhSig 0
+#define zf_cdhVers 4
+#define zf_cdhExVers 6
+#define zf_cdhFlags 8
+#define zf_cdhComp 10
+#define zf_cdhTime 12
+#define zf_cdhDate 14
+#define zf_cdhCRC 16
+#define zf_cdhCompSize 20
+#define zf_cdhUncompSize 24
+#define zf_cdhNameLen 28
+#define zf_cdhExtraLen 30
+#define zf_cdhCommentLen 32
+#define zf_cdhDiskNum 34
+#define zf_cdhIFAttrs 36
+#define zf_cdhEFAttrs 38
+#define zf_cdhLHOffset 42
+#define zf_cdhSIZE 46 /* total size of header */
+
+/* End of central dir record offsets. It is followed by the zipfile
+ comment. */
+#define zf_ecdSig 0
+#define zf_ecdDiskNum 4
+#define zf_ecdDirDiskNum 6
+#define zf_ecdNumEntries 8
+#define zf_ecdTotalEntries 10
+#define zf_ecdDirSize 12
+#define zf_ecdDirOffset 16
+#define zf_ecdCommentLen 20
+#define zf_ecdSIZE 22 /* total size */
+
+/* Magic constants to put in these structures. */
+#define zf_LFHSIGValue 0x04034b50
+#define zf_CDHSIGValue 0x02014b50
+#define zf_ECDSIGValue 0x06054b50
+
+/* OS values for upper byte of version field. */
+#define zf_osUnix 3
+
+/* Encode a major,minor version in a byte. */
+#define zf_Vers(major,minor) ((major) * 10 + (minor))
+
+/* Compression values. */
+#define zf_compNone 0
+