[Libreoffice-commits] .: 7 commits - cairo/cairo cairo/cairo-1.10.2.patch clucene/CustomTarget_source.mk clucene/patches cppcanvas/source editeng/qa filter/source gdk-pixbuf/gdk-pixbuf-2.23.0-win32.patch glib/glib-2.28.1-win32.patch hwpfilter/source i18npool/CppunitTest_i18npool_test_breakiterator.mk i18npool/qa libgsf/libgsf-1.14.19.windows.patch libpng/libpng-1.5.1.patch moz/makefile.mk neon/neon.patch nss/nss.patch nss/prj package/Library_package2.mk package/source RepositoryExternal.mk RepositoryFixes.mk Repository.mk RepositoryModule_ooo.mk sal/cppunittester sal/inc sc/qa sdext/source shell/inc shell/source solenv/gbuild solenv/inc test/source tools/prj tools/source unotest/Library_unobootstrapprotector.mk unotest/Module_unotest.mk unotest/source zlib/CustomTarget_source.mk zlib/Makefile zlib/makefile.mk zlib/make_patched_header.pl zlib/Module_zlib.mk zlib/Package_source.mk zlib/patches zlib/prj zlib/StaticLibrary_zlib.mk zlib/zlib-1.2.5.patch

Caolán McNamara caolan at kemper.freedesktop.org
Fri Apr 13 05:15:55 PDT 2012


 Repository.mk                                                      |    2 
 RepositoryExternal.mk                                              |    4 
 RepositoryFixes.mk                                                 |    7 
 RepositoryModule_ooo.mk                                            |    1 
 cairo/cairo-1.10.2.patch                                           |   44 ---
 cairo/cairo/makefile.mk                                            |    5 
 clucene/CustomTarget_source.mk                                     |    1 
 clucene/patches/clucene-internal-zlib.patch                        |   15 -
 cppcanvas/source/mtfrenderer/emfplus.cxx                           |   48 ++--
 editeng/qa/unit/core-test.cxx                                      |    2 
 filter/source/flash/swfwriter1.cxx                                 |    6 
 gdk-pixbuf/gdk-pixbuf-2.23.0-win32.patch                           |    2 
 glib/glib-2.28.1-win32.patch                                       |   24 --
 hwpfilter/source/hgzip.h                                           |    5 
 hwpfilter/source/hiodev.cxx                                        |    5 
 i18npool/CppunitTest_i18npool_test_breakiterator.mk                |    1 
 i18npool/qa/cppunit/test_breakiterator.cxx                         |   34 --
 libgsf/libgsf-1.14.19.windows.patch                                |    4 
 libpng/libpng-1.5.1.patch                                          |   48 ----
 moz/makefile.mk                                                    |    6 
 neon/neon.patch                                                    |    9 
 nss/nss.patch                                                      |   14 -
 nss/prj/build.lst                                                  |    2 
 package/Library_package2.mk                                        |    6 
 package/source/zipapi/Deflater.cxx                                 |    4 
 package/source/zipapi/Inflater.cxx                                 |    4 
 sal/cppunittester/cppunittester.cxx                                |   10 
 sal/inc/cppunittester/protectorfactory.hxx                         |    9 
 sc/qa/extras/sccellrangeobj.cxx                                    |    7 
 sc/qa/extras/scdatabaserangeobj.cxx                                |    7 
 sc/qa/extras/scdatapilotfieldobj.cxx                               |    7 
 sc/qa/extras/scdatapilottableobj.cxx                               |    7 
 sc/qa/extras/scnamedrangeobj.cxx                                   |    7 
 sc/qa/extras/scnamedrangesobj.cxx                                  |    7 
 sc/qa/extras/sctablesheetsobj.cxx                                  |    7 
 sdext/source/pdfimport/pdfparse/pdfentries.cxx                     |    4 
 sdext/source/pdfimport/test/tests.cxx                              |    4 
 sdext/source/pdfimport/xpdfwrapper/pnghelper.cxx                   |    5 
 shell/inc/internal/zipfile.hxx                                     |    4 
 shell/source/win32/ooofilereader/makefile.mk                       |    4 
 shell/source/win32/shlxthandler/columninfo/makefile.mk             |    4 
 shell/source/win32/shlxthandler/infotips/makefile.mk               |    4 
 shell/source/win32/shlxthandler/makefile.mk                        |    8 
 shell/source/win32/shlxthandler/ooofilt/makefile.mk                |    8 
 shell/source/win32/shlxthandler/prophdl/makefile.mk                |    4 
 shell/source/win32/shlxthandler/propsheets/makefile.mk             |    4 
 shell/source/win32/shlxthandler/util/makefile.mk                   |    4 
 shell/source/win32/zipfile/makefile.mk                             |    4 
 solenv/gbuild/CppunitTest.mk                                       |    5 
 solenv/inc/libs.mk                                                 |    6 
 test/source/bootstrapfixture.cxx                                   |   13 -
 tools/prj/build.lst                                                |    2 
 tools/source/zcodec/zcodec.cxx                                     |    6 
 unotest/Library_unobootstrapprotector.mk                           |   53 ++++
 unotest/Module_unotest.mk                                          |    1 
 unotest/source/cpp/bootstrapfixturebase.cxx                        |   26 --
 unotest/source/cpp/unobootstrapprotector/unobootstrapprotector.cxx |  114 ++++++++++
 unotest/source/cpp/unoexceptionprotector/unoexceptionprotector.cxx |   25 --
 zlib/CustomTarget_source.mk                                        |   53 ++++
 zlib/Makefile                                                      |   11 
 zlib/Module_zlib.mk                                                |   36 +++
 zlib/Package_source.mk                                             |   38 +++
 zlib/StaticLibrary_zlib.mk                                         |   70 ++++++
 zlib/make_patched_header.pl                                        |   66 -----
 zlib/makefile.mk                                                   |   75 ------
 zlib/patches/minizip-null.patch                                    |   12 +
 zlib/patches/zlib-1.2.5-gentoo.patch                               |   12 +
 zlib/patches/zlib-1.2.5-minizip-fixuncrypt.patch                   |   14 +
 zlib/patches/zlib-1.2.5-zip64.patch                                |   59 +++++
 zlib/prj/build.lst                                                 |    5 
 zlib/prj/d.lst                                                     |   11 
 zlib/prj/makefile.mk                                               |    1 
 zlib/zlib-1.2.5.patch                                              |   67 -----
 73 files changed, 564 insertions(+), 649 deletions(-)

New commits:
commit 35fb870b5f4382b8e589b29c72f2623c6b2fd0c0
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Apr 13 12:28:03 2012 +0100

    fix crash on invalid/missing pen

diff --git a/cppcanvas/source/mtfrenderer/emfplus.cxx b/cppcanvas/source/mtfrenderer/emfplus.cxx
index 2e67d9f..8409d7f 100644
--- a/cppcanvas/source/mtfrenderer/emfplus.cxx
+++ b/cppcanvas/source/mtfrenderer/emfplus.cxx
@@ -902,7 +902,7 @@ namespace cppcanvas
             } else {
                 rState.isFillColorSet = true;
                 // extract UseBrush
-                EMFPBrush* brush = (EMFPBrush*) aObjects [brushIndexOrColor];
+                EMFPBrush* brush = (EMFPBrush*) aObjects [brushIndexOrColor & 0xff];
                 EMFP_DEBUG (printf ("EMF+\tbrush fill slot: %u (type: %u)\n", (unsigned int)brushIndexOrColor, (unsigned int)brush->GetType ()));
 
                 // give up in case something wrong happened
@@ -1356,31 +1356,37 @@ namespace cppcanvas
                         EMFP_DEBUG (printf ("EMF+\tpen: %u\n", (unsigned int)penIndex));
 
                         EMFPPath* path = (EMFPPath*) aObjects [flags & 0xff];
-                        EMFPPen* pen = (EMFPPen*) aObjects [penIndex];
+                        EMFPPen* pen = (EMFPPen*) aObjects [penIndex & 0xff];
 
-                        rState.isFillColorSet = false;
-                        rState.isLineColorSet = true;
-                        rState.lineColor = ::vcl::unotools::colorToDoubleSequence (pen->GetColor (),
-                                                                                   rCanvas->getUNOCanvas ()->getDevice()->getDeviceColorSpace());
-                        ::basegfx::B2DPolyPolygon& polygon (path->GetPolygon (*this));
+                        SAL_WARN_IF( !pen, "cppcanvas", "EmfPlusRecordTypeDrawPath missing pen" );
+                        SAL_WARN_IF( !path, "cppcanvas", "EmfPlusRecordTypeDrawPath missing path" );
 
-                        polygon.transform( rState.mapModeTransform );
-                        rendering::StrokeAttributes aStrokeAttributes;
+                        if (pen && path)
+                        {
+                            rState.isFillColorSet = false;
+                            rState.isLineColorSet = true;
+                            rState.lineColor = ::vcl::unotools::colorToDoubleSequence (pen->GetColor (),
+                                                                                       rCanvas->getUNOCanvas ()->getDevice()->getDeviceColorSpace());
+                            ::basegfx::B2DPolyPolygon& polygon (path->GetPolygon (*this));
 
-                        pen->SetStrokeAttributes (aStrokeAttributes, *this, rState);
+                            polygon.transform( rState.mapModeTransform );
+                            rendering::StrokeAttributes aStrokeAttributes;
 
-                        ActionSharedPtr pPolyAction(
-                            internal::PolyPolyActionFactory::createPolyPolyAction(
-                                polygon, rFactoryParms.mrCanvas, rState, aStrokeAttributes ) );
+                            pen->SetStrokeAttributes (aStrokeAttributes, *this, rState);
 
-                        if( pPolyAction )
-                        {
-                            maActions.push_back(
-                                MtfAction(
-                                    pPolyAction,
-                                    rFactoryParms.mrCurrActionIndex ) );
+                            ActionSharedPtr pPolyAction(
+                                internal::PolyPolyActionFactory::createPolyPolyAction(
+                                    polygon, rFactoryParms.mrCanvas, rState, aStrokeAttributes ) );
 
-                            rFactoryParms.mrCurrActionIndex += pPolyAction->getActionCount()-1;
+                            if( pPolyAction )
+                            {
+                                maActions.push_back(
+                                    MtfAction(
+                                        pPolyAction,
+                                        rFactoryParms.mrCurrActionIndex ) );
+
+                                rFactoryParms.mrCurrActionIndex += pPolyAction->getActionCount()-1;
+                            }
                         }
                         break;
                     }
commit 830724367d69bd4e223713d720c695e2b84a2ca0
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Apr 13 12:23:46 2012 +0100

    fix busted indent

diff --git a/cppcanvas/source/mtfrenderer/emfplus.cxx b/cppcanvas/source/mtfrenderer/emfplus.cxx
index 53e58df..2e67d9f 100644
--- a/cppcanvas/source/mtfrenderer/emfplus.cxx
+++ b/cppcanvas/source/mtfrenderer/emfplus.cxx
@@ -1369,19 +1369,19 @@ namespace cppcanvas
 
                         pen->SetStrokeAttributes (aStrokeAttributes, *this, rState);
 
-            ActionSharedPtr pPolyAction(
-                internal::PolyPolyActionFactory::createPolyPolyAction(
-                    polygon, rFactoryParms.mrCanvas, rState, aStrokeAttributes ) );
-
-            if( pPolyAction )
-            {
-                maActions.push_back(
-                    MtfAction(
-                        pPolyAction,
-                        rFactoryParms.mrCurrActionIndex ) );
-
-                rFactoryParms.mrCurrActionIndex += pPolyAction->getActionCount()-1;
-            }
+                        ActionSharedPtr pPolyAction(
+                            internal::PolyPolyActionFactory::createPolyPolyAction(
+                                polygon, rFactoryParms.mrCanvas, rState, aStrokeAttributes ) );
+
+                        if( pPolyAction )
+                        {
+                            maActions.push_back(
+                                MtfAction(
+                                    pPolyAction,
+                                    rFactoryParms.mrCurrActionIndex ) );
+
+                            rFactoryParms.mrCurrActionIndex += pPolyAction->getActionCount()-1;
+                        }
                         break;
                     }
                 case EmfPlusRecordTypeDrawImagePoints:
commit f95b73e6f405be676df6662585f7c73d8a9e12e6
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Apr 13 12:01:22 2012 +0100

    move terminate to fixture decorator

diff --git a/sc/qa/extras/sccellrangeobj.cxx b/sc/qa/extras/sccellrangeobj.cxx
index 2152a2d..20a5c3a 100644
--- a/sc/qa/extras/sccellrangeobj.cxx
+++ b/sc/qa/extras/sccellrangeobj.cxx
@@ -135,16 +135,9 @@ void ScCellRangeObj::setUp()
 void ScCellRangeObj::tearDown()
 {
     if (nTest == NUMBER_OF_TESTS)
-    {
         closeDocument(mxComponent);
-    }
 
     UnoApiTest::tearDown();
-
-    if (nTest == NUMBER_OF_TESTS)
-    {
-        mxDesktop->terminate();
-    }
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(ScCellRangeObj);
diff --git a/sc/qa/extras/scdatabaserangeobj.cxx b/sc/qa/extras/scdatabaserangeobj.cxx
index 03cf4d5..1f66f50 100644
--- a/sc/qa/extras/scdatabaserangeobj.cxx
+++ b/sc/qa/extras/scdatabaserangeobj.cxx
@@ -88,16 +88,9 @@ void ScDatabaseRangeObj::setUp()
 void ScDatabaseRangeObj::tearDown()
 {
     if (nTest == NUMBER_OF_TESTS)
-    {
         closeDocument(mxComponent);
-    }
 
     UnoApiTest::tearDown();
-
-    if (nTest == NUMBER_OF_TESTS)
-    {
-        mxDesktop->terminate();
-    }
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(ScDatabaseRangeObj);
diff --git a/sc/qa/extras/scdatapilotfieldobj.cxx b/sc/qa/extras/scdatapilotfieldobj.cxx
index ff67e46..8e10a16 100644
--- a/sc/qa/extras/scdatapilotfieldobj.cxx
+++ b/sc/qa/extras/scdatapilotfieldobj.cxx
@@ -102,16 +102,9 @@ void ScDataPilotFieldObj::setUp()
 void ScDataPilotFieldObj::tearDown()
 {
     if (nTest == NUMBER_OF_TESTS)
-    {
         closeDocument(mxComponent);
-    }
 
     UnoApiTest::tearDown();
-
-    if (nTest == NUMBER_OF_TESTS)
-    {
-        mxDesktop->terminate();
-    }
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(ScDataPilotFieldObj);
diff --git a/sc/qa/extras/scdatapilottableobj.cxx b/sc/qa/extras/scdatapilottableobj.cxx
index 18a26d0..99067b2 100644
--- a/sc/qa/extras/scdatapilottableobj.cxx
+++ b/sc/qa/extras/scdatapilottableobj.cxx
@@ -164,16 +164,9 @@ void ScDataPilotTableObj::setUp()
 void ScDataPilotTableObj::tearDown()
 {
     if (nTest == NUMBER_OF_TESTS)
-    {
         closeDocument(mxComponent);
-    }
 
     UnoApiTest::tearDown();
-
-    if (nTest == NUMBER_OF_TESTS)
-    {
-        mxDesktop->terminate();
-    }
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(ScDataPilotTableObj);
diff --git a/sc/qa/extras/scnamedrangeobj.cxx b/sc/qa/extras/scnamedrangeobj.cxx
index cdc1f49..a9f971f 100644
--- a/sc/qa/extras/scnamedrangeobj.cxx
+++ b/sc/qa/extras/scnamedrangeobj.cxx
@@ -118,16 +118,9 @@ void ScNamedRangeObj::setUp()
 void ScNamedRangeObj::tearDown()
 {
     if (nTest == NUMBER_OF_TESTS)
-    {
         closeDocument(mxComponent);
-    }
 
     UnoApiTest::tearDown();
-
-    if (nTest == NUMBER_OF_TESTS)
-    {
-        mxDesktop->terminate();
-    }
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(ScNamedRangeObj);
diff --git a/sc/qa/extras/scnamedrangesobj.cxx b/sc/qa/extras/scnamedrangesobj.cxx
index 7a44bf1..c118d08 100644
--- a/sc/qa/extras/scnamedrangesobj.cxx
+++ b/sc/qa/extras/scnamedrangesobj.cxx
@@ -89,16 +89,9 @@ void ScNamedRangesObj::setUp()
 void ScNamedRangesObj::tearDown()
 {
     if (nTest == NUMBER_OF_TESTS)
-    {
         closeDocument(mxComponent);
-    }
 
     UnoApiTest::tearDown();
-
-    if (nTest == NUMBER_OF_TESTS)
-    {
-        mxDesktop->terminate();
-    }
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(ScNamedRangesObj);
diff --git a/sc/qa/extras/sctablesheetsobj.cxx b/sc/qa/extras/sctablesheetsobj.cxx
index 8b0b5e9..2d7de74 100644
--- a/sc/qa/extras/sctablesheetsobj.cxx
+++ b/sc/qa/extras/sctablesheetsobj.cxx
@@ -117,16 +117,9 @@ void ScTableSheetsObj::setUp()
 void ScTableSheetsObj::tearDown()
 {
     if (nTest == NUMBER_OF_TESTS)
-    {
         closeDocument(mxComponent);
-    }
 
     UnoApiTest::tearDown();
-
-    if (nTest == NUMBER_OF_TESTS)
-    {
-        mxDesktop->terminate();
-    }
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(ScTableSheetsObj);
commit 426a159314b0a2a0f7596cc494ac3ec6a1f0b2d7
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Apr 13 11:45:34 2012 +0100

    need to register static library

diff --git a/Repository.mk b/Repository.mk
index 52dee49..1e42341 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -570,6 +570,7 @@ $(eval $(call gb_Helper_register_static_libraries,PLAINLIBS, \
     $(if $(filter $(OS),WNT), \
         odma_lib \
     ) \
+	z \
 ))
 
 ifeq ($(OS),WNT)
commit e9b74b802b80fdae7ec9fef24d6c6d18cd4d4968
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Apr 13 11:33:00 2012 +0100

    needs to be the dir name not the output lib name

diff --git a/RepositoryModule_ooo.mk b/RepositoryModule_ooo.mk
index b538f21..def8356 100644
--- a/RepositoryModule_ooo.mk
+++ b/RepositoryModule_ooo.mk
@@ -139,7 +139,7 @@ $(eval $(call gb_Module_add_moduledirs,ooo,\
     xmloff \
     xmlreader \
     xmlscript \
-    z \
+    zlib \
 ))
 
 ifneq ($(SOLAR_JAVA),)
commit 8d7e8a0a3b9a4a4f7b805e91674b79a4cca7cf72
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Apr 13 11:13:19 2012 +0100

    setup/teardown default component context once before/after all tests
    
    avoids the problems of dangling uno singletons invalidated after the first
    dispose and the chain of other singletons that don't expect to need to
    re-initialize, etc.
    
    reenable editeng cppunit test
    
    inherit i18npool cppunit test from unotest base
    
    drop LibreOfficeProtector, do "throwable" work in setUp/tearDown not
    in ctors/dtors

diff --git a/Repository.mk b/Repository.mk
index 2bf19b6..52dee49 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -406,6 +406,7 @@ $(eval $(call gb_Helper_register_libraries,PLAINLIBS_OOO, \
     ucpchelp1 \
     ucphier1 \
     ucppkg1 \
+    unobootstrapprotector \
     unoexceptionprotector \
     unopkgapp \
     unotest \
diff --git a/RepositoryFixes.mk b/RepositoryFixes.mk
index 76516eb..d07d791 100644
--- a/RepositoryFixes.mk
+++ b/RepositoryFixes.mk
@@ -41,6 +41,7 @@ gb_Library_FILENAMES := $(patsubst purpenvhelper:libpurpen%,purpenvhelper:libuno
 gb_Library_FILENAMES := $(patsubst salhelper:libsalhelper%,salhelper:libuno_salhelper%,$(gb_Library_FILENAMES))
 gb_Library_FILENAMES := $(patsubst ucbhelper:libucbhelper%,ucbhelper:libucbhelper4%,$(gb_Library_FILENAMES))
 ifneq ($(OS),ANDROID)
+gb_Library_FILENAMES := $(patsubst unobootstrapprotector:libuno%,unobootstrapprotector:uno%,$(gb_Library_FILENAMES))
 gb_Library_FILENAMES := $(patsubst unoexceptionprotector:libuno%,unoexceptionprotector:uno%,$(gb_Library_FILENAMES))
 endif
 gb_Library_FILENAMES := $(patsubst unsafe_uno:libunsafe_uno%,unsafe_uno:libunsafe_uno_uno%,$(gb_Library_FILENAMES))
diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx
index 61db59f..fc5828f 100644
--- a/editeng/qa/unit/core-test.cxx
+++ b/editeng/qa/unit/core-test.cxx
@@ -55,7 +55,7 @@ public:
     void testConstruction();
 
     CPPUNIT_TEST_SUITE(Test);
-//    CPPUNIT_TEST(testConstruction);
+    CPPUNIT_TEST(testConstruction);
     CPPUNIT_TEST_SUITE_END();
 
 private:
diff --git a/i18npool/CppunitTest_i18npool_test_breakiterator.mk b/i18npool/CppunitTest_i18npool_test_breakiterator.mk
index b9e972c..62100a0 100644
--- a/i18npool/CppunitTest_i18npool_test_breakiterator.mk
+++ b/i18npool/CppunitTest_i18npool_test_breakiterator.mk
@@ -37,6 +37,7 @@ $(eval $(call gb_CppunitTest_use_libraries,i18npool_test_breakiterator,\
 	cppu \
 	cppuhelper \
 	sal \
+	unotest \
     $(gb_STDLIBS) \
 ))
 
diff --git a/i18npool/qa/cppunit/test_breakiterator.cxx b/i18npool/qa/cppunit/test_breakiterator.cxx
index 7a70f01..14051d4 100644
--- a/i18npool/qa/cppunit/test_breakiterator.cxx
+++ b/i18npool/qa/cppunit/test_breakiterator.cxx
@@ -35,14 +35,11 @@
 #include <cppuhelper/compbase1.hxx>
 #include <cppuhelper/bootstrap.hxx>
 #include <cppuhelper/basemutex.hxx>
-#include "cppunit/TestAssert.h"
-#include "cppunit/TestFixture.h"
-#include "cppunit/extensions/HelperMacros.h"
-#include "cppunit/plugin/TestPlugIn.h"
 #include <com/sun/star/i18n/XBreakIterator.hpp>
 #include <com/sun/star/i18n/CharacterIteratorMode.hpp>
 #include <com/sun/star/i18n/ScriptType.hpp>
 #include <com/sun/star/i18n/WordType.hpp>
+#include <unotest/bootstrapfixturebase.hxx>
 
 #include <rtl/strbuf.hxx>
 
@@ -50,12 +47,9 @@
 
 using namespace ::com::sun::star;
 
-class TestBreakIterator : public CppUnit::TestFixture
+class TestBreakIterator : public test::BootstrapFixtureBase
 {
 public:
-    TestBreakIterator();
-    ~TestBreakIterator();
-
     virtual void setUp();
     virtual void tearDown();
 
@@ -72,11 +66,7 @@ public:
     CPPUNIT_TEST(testAsian);
     CPPUNIT_TEST(testThai);
     CPPUNIT_TEST_SUITE_END();
-
 private:
-    uno::Reference<uno::XComponentContext> m_xContext;
-    uno::Reference<lang::XMultiComponentFactory> m_xFactory;
-    uno::Reference<lang::XMultiServiceFactory> m_xMSF;
     uno::Reference<i18n::XBreakIterator> m_xBreak;
 };
 
@@ -327,27 +317,17 @@ void TestBreakIterator::testThai()
 #endif
 }
 
-TestBreakIterator::TestBreakIterator()
-{
-    m_xContext = cppu::defaultBootstrap_InitialComponentContext();
-    m_xFactory = m_xContext->getServiceManager();
-    m_xMSF = uno::Reference<lang::XMultiServiceFactory>(m_xFactory, uno::UNO_QUERY_THROW);
-    m_xBreak = uno::Reference< i18n::XBreakIterator >(m_xMSF->createInstance(
-        ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.i18n.BreakIterator"))),
-        uno::UNO_QUERY_THROW);
-}
-
 void TestBreakIterator::setUp()
 {
-}
-
-TestBreakIterator::~TestBreakIterator()
-{
-    uno::Reference< lang::XComponent >(m_xContext, uno::UNO_QUERY_THROW)->dispose();
+    BootstrapFixtureBase::setUp();
+    m_xBreak = uno::Reference< i18n::XBreakIterator >(m_xSFactory->createInstance(
+        "com.sun.star.i18n.BreakIterator"), uno::UNO_QUERY_THROW);
 }
 
 void TestBreakIterator::tearDown()
 {
+    BootstrapFixtureBase::tearDown();
+    m_xBreak.clear();
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(TestBreakIterator);
diff --git a/sal/cppunittester/cppunittester.cxx b/sal/cppunittester/cppunittester.cxx
index ba21dac..22ac029 100644
--- a/sal/cppunittester/cppunittester.cxx
+++ b/sal/cppunittester/cppunittester.cxx
@@ -180,7 +180,7 @@ SAL_IMPLEMENT_MAIN() {
 #endif
 
     boost::ptr_vector<osl::Module> modules;
-    cppunittester::LibreOfficeProtector *throw_protector = 0;
+    CppUnit::Protector *throw_protector = 0;
     CppUnit::TestResult result;
     std::string args;
     std::string testlib;
@@ -231,14 +231,8 @@ SAL_IMPLEMENT_MAIN() {
         index+=3;
     }
 
-    bool ok = false;
     ProtectedFixtureFunctor tests(testlib, args, result);
-    //if the unoprotector was given on the command line, use it to catch
-    //and report the error message of exceptions
-    if (throw_protector)
-        ok = throw_protector->protect(tests);
-    else
-        ok = tests.run();
+    bool ok = tests.run();
 
     return ok ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/sal/inc/cppunittester/protectorfactory.hxx b/sal/inc/cppunittester/protectorfactory.hxx
index 093eb5f..b666412 100644
--- a/sal/inc/cppunittester/protectorfactory.hxx
+++ b/sal/inc/cppunittester/protectorfactory.hxx
@@ -38,16 +38,9 @@
 
 namespace cppunittester
 {
-    class LibreOfficeProtector : public CppUnit::Protector
-    {
-    public:
-        virtual bool protect(CppUnit::Functor const & functor) = 0;
-        using CppUnit::Protector::protect;
-    };
-
     // The type of CppUnit::Protector factory functions that can be plugged into
     // cppunittester:
-    extern "C" typedef LibreOfficeProtector * SAL_CALL ProtectorFactory();
+    extern "C" typedef CppUnit::Protector * SAL_CALL ProtectorFactory();
 }
 
 #ifdef DISABLE_DYNLOADING
diff --git a/solenv/gbuild/CppunitTest.mk b/solenv/gbuild/CppunitTest.mk
index 6f6b325..258fc52 100644
--- a/solenv/gbuild/CppunitTest.mk
+++ b/solenv/gbuild/CppunitTest.mk
@@ -68,8 +68,9 @@ $(if $(URE),\
 	"-env:UNO_SERVICES=$(foreach item,$(UNO_SERVICES),$(call gb_Helper_make_url,$(item)))") \
     $(foreach dir,URE_INTERNAL_LIB_DIR LO_LIB_DIR,\
 	    -env:$(dir)=$(call gb_Helper_make_url,$(gb_CppunitTest_LIBDIR))) \
-    --protector unoexceptionprotector$(gb_Library_DLLEXT) unoexceptionprotector) \
-$(ARGS)
+    --protector unoexceptionprotector$(gb_Library_DLLEXT) unoexceptionprotector \
+    --protector unobootstrapprotector$(gb_Library_DLLEXT) unobootstrapprotector \
+ ) $(ARGS)
 endef
 
 .PHONY : $(call gb_CppunitTest_get_clean_target,%)
diff --git a/test/source/bootstrapfixture.cxx b/test/source/bootstrapfixture.cxx
index 284dbf7..edb7b63 100644
--- a/test/source/bootstrapfixture.cxx
+++ b/test/source/bootstrapfixture.cxx
@@ -62,6 +62,12 @@ test::BootstrapFixture::BootstrapFixture( bool bAssertOnDialog, bool bNeedUCB )
     : m_bNeedUCB( bNeedUCB )
     , m_bAssertOnDialog( bAssertOnDialog )
 {
+}
+
+void test::BootstrapFixture::setUp()
+{
+    test::BootstrapFixtureBase::setUp();
+
     // force locale (and resource files loaded) to en-US
     const LanguageType eLang=LANGUAGE_ENGLISH_US;
 
@@ -69,11 +75,7 @@ test::BootstrapFixture::BootstrapFixture( bool bAssertOnDialog, bool bNeedUCB )
     MsLangId::convertLanguageToIsoNames(eLang, aLang, aCountry);
     lang::Locale aLocale(aLang, aCountry, rtl::OUString());
     ResMgr::SetDefaultLocale( aLocale );
-}
 
-void test::BootstrapFixture::setUp()
-{
-    test::BootstrapFixtureBase::setUp();
     if (m_bNeedUCB)
     {
         // initialise UCB-Broker
@@ -96,9 +98,8 @@ void test::BootstrapFixture::setUp()
     aLocalOptions.SetUILocaleConfigString( aLangISO );
 
     InitVCL(m_xSFactory);
-    if (Application::IsHeadlessModeRequested()) {
+    if (Application::IsHeadlessModeRequested())
         Application::EnableHeadlessMode(true);
-    }
 
     if( m_bAssertOnDialog )
         ErrorHandler::RegisterDisplay( aBasicErrorFunc );
diff --git a/tools/prj/build.lst b/tools/prj/build.lst
index fb086f2..ee68035 100644
--- a/tools/prj/build.lst
+++ b/tools/prj/build.lst
@@ -1,3 +1,3 @@
-tl tools : cppu external offapi ZLIB:zlib EXPAT:expat basegfx comphelper i18npool unotest NULL
+tl tools : cppu external offapi ZLIB:zlib EXPAT:expat basegfx comphelper i18npool NULL
 tl tools\prj nmake - all tl_prj NULL
 # tl	tools\qa					nmake	-	all	tl_qa tl_utl NULL
diff --git a/unotest/Library_unobootstrapprotector.mk b/unotest/Library_unobootstrapprotector.mk
new file mode 100644
index 0000000..26b7a2c
--- /dev/null
+++ b/unotest/Library_unobootstrapprotector.mk
@@ -0,0 +1,53 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# Version: MPL 1.1 / GPLv3+ / LGPLv3+
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License or as specified alternatively below. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# Major Contributor(s):
+# Copyright (C) 2012 Matúš Kukan <matus.kukan at gmail.com> (initial developer)
+#
+# All Rights Reserved.
+#
+# For minor contributions see the git repository.
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+# instead of those above.
+
+$(eval $(call gb_Library_Library,unobootstrapprotector))
+
+$(eval $(call gb_Library_use_package,unobootstrapprotector,unotest_inc))
+
+$(eval $(call gb_Library_use_api,unobootstrapprotector,\
+	udkapi \
+	offapi \
+))
+
+$(eval $(call gb_Library_use_libraries,unobootstrapprotector,\
+	comphelper \
+	cppu \
+	cppuhelper \
+	sal \
+	$(gb_STDLIBS) \
+))
+
+$(eval $(call gb_Library_use_externals,unobootstrapprotector,\
+	cppunit \
+))
+
+$(eval $(call gb_Library_add_exception_objects,unobootstrapprotector,\
+	unotest/source/cpp/unobootstrapprotector/unobootstrapprotector \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/unotest/Module_unotest.mk b/unotest/Module_unotest.mk
index fc9f18c..6980b6e 100644
--- a/unotest/Module_unotest.mk
+++ b/unotest/Module_unotest.mk
@@ -28,6 +28,7 @@
 $(eval $(call gb_Module_Module,unotest))
 
 $(eval $(call gb_Module_add_targets,unotest,\
+	Library_unobootstrapprotector \
 	Library_unoexceptionprotector \
 	Library_unotest \
     Package_inc \
diff --git a/unotest/source/cpp/bootstrapfixturebase.cxx b/unotest/source/cpp/bootstrapfixturebase.cxx
index 0c7c841..5ce1a06 100644
--- a/unotest/source/cpp/bootstrapfixturebase.cxx
+++ b/unotest/source/cpp/bootstrapfixturebase.cxx
@@ -44,7 +44,7 @@ using namespace ::com::sun::star;
 // heavy lifting is deferred until setUp. setUp and tearDown are interleaved
 // between the tests as you might expect.
 test::BootstrapFixtureBase::BootstrapFixtureBase()
-    : m_aSrcRootURL(RTL_CONSTASCII_USTRINGPARAM("file://")), m_aSolverRootURL( m_aSrcRootURL )
+    : m_aSrcRootURL("file://"), m_aSolverRootURL( m_aSrcRootURL )
 {
 #ifndef ANDROID
     const char* pSrcRoot = getenv( "SRC_ROOT" );
@@ -74,46 +74,38 @@ test::BootstrapFixtureBase::~BootstrapFixtureBase()
 
 ::rtl::OUString test::BootstrapFixtureBase::getURLFromSrc( const char *pPath )
 {
-  return m_aSrcRootURL + rtl::OUString::createFromAscii( pPath );
+    return m_aSrcRootURL + rtl::OUString::createFromAscii( pPath );
 }
 
 ::rtl::OUString test::BootstrapFixtureBase::getPathFromSrc( const char *pPath )
 {
-  return m_aSrcRootPath + rtl::OUString::createFromAscii( pPath );
+    return m_aSrcRootPath + rtl::OUString::createFromAscii( pPath );
 }
 
 ::rtl::OUString test::BootstrapFixtureBase::getURLFromSolver( const char *pPath )
 {
-  return m_aSolverRootURL + rtl::OUString::createFromAscii( pPath );
+    return m_aSolverRootURL + rtl::OUString::createFromAscii( pPath );
 }
 
 ::rtl::OUString test::BootstrapFixtureBase::getPathFromSolver( const char *pPath )
 {
-  return m_aSolverRootPath + rtl::OUString::createFromAscii( pPath );
+    return m_aSolverRootPath + rtl::OUString::createFromAscii( pPath );
 }
 
 void test::BootstrapFixtureBase::setUp()
 {
     // set UserInstallation to user profile dir in test/user-template
     rtl::Bootstrap aDefaultVars;
-    rtl::OUString sUserInstallURL = m_aSolverRootURL + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/unittest" ) );
-    aDefaultVars.set( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("UserInstallation") ),
-                         sUserInstallURL);
+    rtl::OUString sUserInstallURL = m_aSolverRootURL + rtl::OUString("/unittest");
+    aDefaultVars.set(rtl::OUString("UserInstallation"), sUserInstallURL);
 
-    m_xContext = cppu::defaultBootstrap_InitialComponentContext();
+    m_xContext = comphelper::getProcessComponentContext();
     m_xFactory = m_xContext->getServiceManager();
-    m_xSFactory = uno::Reference<lang::XMultiServiceFactory> (m_xFactory, uno::UNO_QUERY_THROW);
-
-    // Without this we're crashing because callees are using
-    // getProcessServiceFactory.  In general those should be removed in favour
-    // of retaining references to the root ServiceFactory as its passed around
-    comphelper::setProcessServiceFactory(m_xSFactory);
+    m_xSFactory = uno::Reference<lang::XMultiServiceFactory>(m_xFactory, uno::UNO_QUERY_THROW);
 }
 
 void test::BootstrapFixtureBase::tearDown()
 {
-    //    uno::Reference< lang::XComponent >(m_xContext, uno::UNO_QUERY_THROW)->dispose();
 }
 
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/unotest/source/cpp/unobootstrapprotector/unobootstrapprotector.cxx b/unotest/source/cpp/unobootstrapprotector/unobootstrapprotector.cxx
new file mode 100644
index 0000000..cb0983a
--- /dev/null
+++ b/unotest/source/cpp/unobootstrapprotector/unobootstrapprotector.cxx
@@ -0,0 +1,114 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2011 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/config.h"
+#include "sal/precppunit.hxx"
+
+#include <limits>
+#include <string>
+#include <iostream>
+
+#include "boost/noncopyable.hpp"
+#include "com/sun/star/uno/Any.hxx"
+#include "com/sun/star/uno/Exception.hpp"
+
+#include <cppuhelper/bootstrap.hxx>
+#include <ucbhelper/contentbroker.hxx>
+#include <comphelper/processfactory.hxx>
+
+#include <com/sun/star/lang/Locale.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+#include "cppuhelper/exc_hlp.hxx"
+#include "cppunit/Message.h"
+#include "osl/thread.h"
+#include "rtl/string.hxx"
+#include "rtl/ustring.h"
+#include "rtl/ustring.hxx"
+#include "sal/types.h"
+
+#include "protectorfactory.hxx"
+
+namespace {
+
+using namespace com::sun::star;
+
+//cppunit calls instantiates a new TextFixture for each test and calls setUp
+//and tearDown on that for every test in a fixture
+//
+//We basically need to call dispose on our root component context context to
+//shut down cleanly in the right order.
+//
+//But we can't setup and tear down the root component context for
+//every test because all the uno singletons will be invalid after
+//the first dispose. So lets setup the default context once before
+//all tests are run, and tear it down once after all have finished
+
+class Prot : public CppUnit::Protector, private boost::noncopyable
+{
+public:
+    Prot();
+
+    virtual ~Prot();
+
+    virtual bool protect(
+        CppUnit::Functor const & functor,
+        CppUnit::ProtectorContext const & context);
+private:
+    uno::Reference<uno::XComponentContext> m_xContext;
+};
+
+
+Prot::Prot()
+{
+    m_xContext = cppu::defaultBootstrap_InitialComponentContext();
+
+    uno::Reference<lang::XMultiComponentFactory> xFactory = m_xContext->getServiceManager();
+    uno::Reference<lang::XMultiServiceFactory> xSFactory(xFactory, uno::UNO_QUERY_THROW);
+
+    comphelper::setProcessServiceFactory(xSFactory);
+}
+
+bool Prot::protect(
+    CppUnit::Functor const & functor, CppUnit::ProtectorContext const &)
+{
+    return functor();
+}
+
+Prot::~Prot()
+{
+    uno::Reference< lang::XComponent >(m_xContext, uno::UNO_QUERY_THROW)->dispose();
+}
+
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT CppUnit::Protector * SAL_CALL unobootstrapprotector()
+{
+    return new Prot;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/unotest/source/cpp/unoexceptionprotector/unoexceptionprotector.cxx b/unotest/source/cpp/unoexceptionprotector/unoexceptionprotector.cxx
index 3829bd1..6f1f679 100644
--- a/unotest/source/cpp/unoexceptionprotector/unoexceptionprotector.cxx
+++ b/unotest/source/cpp/unoexceptionprotector/unoexceptionprotector.cxx
@@ -59,7 +59,7 @@ std::string convert(rtl::OUString const & s16) {
          : static_cast< std::string::size_type >(s8.getLength())));
 }
 
-class Prot : public cppunittester::LibreOfficeProtector, private boost::noncopyable
+class Prot : public CppUnit::Protector, private boost::noncopyable
 {
 public:
     Prot() {}
@@ -69,8 +69,6 @@ public:
     virtual bool protect(
         CppUnit::Functor const & functor,
         CppUnit::ProtectorContext const & context);
-
-    virtual bool protect(CppUnit::Functor const & functor);
 };
 
 bool Prot::protect(
@@ -93,27 +91,6 @@ bool Prot::protect(
     return false;
 }
 
-bool Prot::protect(CppUnit::Functor const & functor)
-{
-    bool bRet = false;
-    try
-    {
-        bRet = functor();
-    } catch (const css::uno::Exception &e)
-    {
-        css::uno::Any a(cppu::getCaughtException());
-        std::cerr
-            << convert(rtl::OUString(
-                        RTL_CONSTASCII_USTRINGPARAM(
-                            "An uncaught exception of type "))
-                        + a.getValueTypeName())
-            << std::endl << "Exception Message was: " << convert(e.Message)
-            << std::endl;
-        throw;
-    }
-    return bRet;
-}
-
 }
 
 extern "C" SAL_DLLPUBLIC_EXPORT CppUnit::Protector * SAL_CALL
commit 452af5f4522e750627d0c0ac9fbc794aeb1f1f8f
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Apr 12 16:05:31 2012 +0100

    gbuildize internal zlib
    
    and stick headers into the solver in the same hierarchy as is "standard"
    so we don't have to patch so much, similiarly rename to libz

diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk
index 10dc633..c0a3dd2 100644
--- a/RepositoryExternal.mk
+++ b/RepositoryExternal.mk
@@ -90,12 +90,12 @@ endef
 else # !SYSTEM_ZLIB
 
 $(eval $(call gb_Helper_register_static_libraries,PLAINLIBS, \
-	zlib \
+	z \
 ))
 
 define gb_LinkTarget__use_zlib
 $(call gb_LinkTarget_use_static_libraries,$(1),\
-	zlib \
+	z \
 )
 
 endef
diff --git a/RepositoryFixes.mk b/RepositoryFixes.mk
index 06495c0..76516eb 100644
--- a/RepositoryFixes.mk
+++ b/RepositoryFixes.mk
@@ -53,7 +53,7 @@ gb_Library_DLLFILENAMES := $(patsubst icuuc:icuuc%,icuuc:icuuc40%,$(gb_Library_D
 gb_Library_DLLFILENAMES := $(patsubst log_uno:log_uno%,log_uno:log_uno_uno%,$(gb_Library_DLLFILENAMES))
 gb_Library_DLLFILENAMES := $(patsubst ucbhelper:ucbhelper%,ucbhelper:ucbhelper4%,$(gb_Library_DLLFILENAMES))
 gb_Library_DLLFILENAMES := $(patsubst unsafe_uno:unsafe_uno%,unsafe_uno:unsafe_uno_uno%,$(gb_Library_DLLFILENAMES))
-gb_Library_DLLFILENAMES := $(patsubst z:z%,z:zlib%,$(gb_Library_DLLFILENAMES))
+gb_Library_DLLFILENAMES := $(patsubst z:z%,z:z%,$(gb_Library_DLLFILENAMES))
 
 gb_Library_FILENAMES := $(patsubst sb:isb%,sb:basic%,$(gb_Library_FILENAMES))
 gb_Library_FILENAMES := $(patsubst sfx:isfx%,sfx:sfx%,$(gb_Library_FILENAMES))
@@ -73,7 +73,7 @@ gb_Library_FILENAMES := $(patsubst rdf:irdf%,rdf:librdf.dll$(gb_Library_IARCEXT)
 gb_Library_FILENAMES := $(patsubst ssl:issl%,ssl:ssl%,$(gb_Library_FILENAMES))
 gb_Library_FILENAMES := $(patsubst xml2:ixml2%,xml2:libxml2$(gb_Library_IARCEXT),$(gb_Library_FILENAMES))
 gb_Library_FILENAMES := $(patsubst xslt:ixslt%,xslt:libxslt$(gb_Library_IARCEXT),$(gb_Library_FILENAMES))
-gb_Library_FILENAMES := $(patsubst z:iz%,z:zlib%,$(gb_Library_FILENAMES))
+gb_Library_FILENAMES := $(patsubst z:iz%,z:z%,$(gb_Library_FILENAMES))
 
 
 # Libraries not provided by mingw(-w64), available only in the Windows
@@ -108,7 +108,7 @@ gb_Library_FILENAMES := $(patsubst xmlsec1:ixmlsec1%,xmlsec1:libxmlsec%,$(gb_Lib
 gb_Library_FILENAMES := $(patsubst xmlsec1-mscrypto:ixmlsec1-mscrypto%,xmlsec1-mscrypto:libxmlsec-mscrypto%,$(gb_Library_FILENAMES))
 gb_Library_FILENAMES := $(patsubst xmlsec1-nss:ixmlsec1-nss%,xmlsec1-nss:libxmlsec-nss%,$(gb_Library_FILENAMES))
 gb_Library_FILENAMES := $(patsubst xslt:ixslt%,xslt:libxslt%,$(gb_Library_FILENAMES))
-gb_Library_FILENAMES := $(patsubst z:z%,z:zlib%,$(gb_Library_FILENAMES))
+gb_Library_FILENAMES := $(patsubst z:z%,z:z%,$(gb_Library_FILENAMES))
 
 
 # change the names of all import libraries that don't have an "i" prefix as in our standard naming schema
diff --git a/RepositoryModule_ooo.mk b/RepositoryModule_ooo.mk
index ea5d5ab..b538f21 100644
--- a/RepositoryModule_ooo.mk
+++ b/RepositoryModule_ooo.mk
@@ -139,6 +139,7 @@ $(eval $(call gb_Module_add_moduledirs,ooo,\
     xmloff \
     xmlreader \
     xmlscript \
+    z \
 ))
 
 ifneq ($(SOLAR_JAVA),)
diff --git a/cairo/cairo-1.10.2.patch b/cairo/cairo-1.10.2.patch
index d13c1e4..2234383 100644
--- a/cairo/cairo-1.10.2.patch
+++ b/cairo/cairo-1.10.2.patch
@@ -38,7 +38,7 @@
  DEFAULT_CFLAGS += -I. -I$(top_srcdir)
  DEFAULT_CFLAGS += $(PIXMAN_CFLAGS) $(LIBPNG_CFLAGS) $(ZLIB_CFLAGS)
 +DEFAULT_CFLAGS += $(SOLARINC)
-+DEFAULT_CFLAGS += -I$(SOLARVER)/$(INPATH)/inc/zlib -I$(SOLARVER)/$(INPATH)/inc/external/libpng -DZLIB_FIX -DDISABLE_SOME_FLOATING_POINT=1
++DEFAULT_CFLAGS += -I$(SOLARVER)/$(INPATH)/inc/external/libpng -DDISABLE_SOME_FLOATING_POINT=1
  
  CAIRO_CFLAGS = $(DEFAULT_CFLAGS) $(CFLAGS)
  
@@ -189,20 +189,6 @@
  
  			cairo_cv_xml_use=$use_xml
  			cairo_cv_xml_cache_vars=" BASE REQUIRES CFLAGS NONPKGCONFIG_CFLAGS LIBS NONPKGCONFIG_LIBS NONPKGCONFIG_EXTRA_LIBS"
---- misc/cairo-1.10.2/src/cairo-deflate-stream.c	2010-06-18 13:47:12.000000000 +0200
-+++ misc/build/cairo-1.10.2/src/cairo-deflate-stream.c	2010-06-18 13:47:12.000000000 +0200
-@@ -37,7 +37,11 @@
- #include "cairoint.h"
- #include "cairo-error-private.h"
- #include "cairo-output-stream-private.h"
-+#ifdef ZLIB_FIX
-+#include <zlib/zlib.h>
-+#else
- #include <zlib.h>
-+#endif
- 
- #define BUFFER_SIZE 16384
- 
 --- misc/cairo-1.10.2/src/cairo-output-stream.c	2010-07-12 10:57:03.000000000 +0200
 +++ misc/build/cairo-1.10.2/src/cairo-output-stream.c	2010-07-12 10:57:03.000000000 +0200
 @@ -313,7 +313,11 @@
@@ -217,34 +203,6 @@
      decimal_point_len = strlen (decimal_point);
  
      assert (decimal_point_len != 0);
---- misc/cairo-1.10.2/src/cairo-pdf-surface.c	2010-12-25 15:21:34.000000000 +0100
-+++ misc/build/cairo-1.10.2/src/cairo-pdf-surface.c	2010-12-25 15:21:34.000000000 +0100
-@@ -57,7 +57,11 @@
- #include "cairo-type3-glyph-surface-private.h"
- 
- #include <time.h>
-+#ifdef ZLIB_FIX
-+#include <zlib/zlib.h>
-+#else
- #include <zlib.h>
-+#endif
- 
- /* Issues:
-  *
---- misc/cairo-1.10.2/src/cairo-ps-surface.c	2010-12-25 15:21:34.000000000 +0100
-+++ misc/build/cairo-1.10.2/src/cairo-ps-surface.c	2010-12-25 15:21:34.000000000 +0100
-@@ -72,7 +72,11 @@
- #include <stdio.h>
- #include <ctype.h>
- #include <time.h>
-+#ifdef ZLIB_FIX
-+#include <zlib/zlib.h>
-+#else
- #include <zlib.h>
-+#endif
- #include <errno.h>
- 
- #define DEBUG_PS 0
 --- misc/cairo-1.10.2/src/cairo-ft-font.c	2010-12-25 15:21:34.000000000 +0100
 +++ misc/build/cairo-1.10.2/src/cairo-ft-font.c	2010-12-25 15:21:34.000000000 +0100
 @@ -534,16 +534,16 @@
diff --git a/cairo/cairo/makefile.mk b/cairo/cairo/makefile.mk
index 16a89bf..51854dc 100644
--- a/cairo/cairo/makefile.mk
+++ b/cairo/cairo/makefile.mk
@@ -70,12 +70,7 @@ cairo_LDFLAGS=-L$(SOLARVER)$/$(INPATH)$/lib
 
 cairo_CPPFLAGS=
 
-.IF "$(SYSTEM_ZLIB)"!="YES"
-cairo_CPPFLAGS+=-I$(SOLARINCDIR)$/external$/zlib
-cairo_COMPRESS=z_compress
-.ELSE
 cairo_COMPRESS=compress
-.ENDIF
 cairo_CPPFLAGS+=$(INCLUDE)
 
 .IF "$(OS)"=="WNT"
diff --git a/clucene/CustomTarget_source.mk b/clucene/CustomTarget_source.mk
index 474d1b8..a93b595 100644
--- a/clucene/CustomTarget_source.mk
+++ b/clucene/CustomTarget_source.mk
@@ -61,7 +61,6 @@ $(CLSO)/done : $(cl_FIXED_TARFILE_LOCATION) \
 	$(call gb_Helper_abbreviate_dirs, \
 	mkdir -p $(dir $@) && cd $(dir $@) && \
 	$(GNUTAR) -x -z $(STRIP_COMPONENTS)=1 -f $< && \
-	$(GNUPATCH) -p0 < $(SRCDIR)/clucene/patches/clucene-internal-zlib.patch && \
 	$(GNUPATCH) -p0 < $(SRCDIR)/clucene/patches/clucene-warnings.patch && \
 	$(GNUPATCH) -p0 < $(SRCDIR)/clucene/patches/clucene-gcc-atomics.patch && \
 	$(GNUPATCH) -p0 < $(SRCDIR)/clucene/patches/clucene-debug.patch && \
diff --git a/clucene/patches/clucene-internal-zlib.patch b/clucene/patches/clucene-internal-zlib.patch
deleted file mode 100644
index 6667926..0000000
--- a/clucene/patches/clucene-internal-zlib.patch
+++ /dev/null
@@ -1,15 +0,0 @@
---- src/shared/CLucene/util/Misc.cpp	2012-02-17 15:33:09.217891100 +0000
-+++ src/shared/CLucene/util/Misc.cpp	2012-02-17 15:38:10.836597500 +0000
-@@ -34,7 +34,11 @@
- #include "CLucene/util/dirent.h" //if we have dirent, then the native one will be used
- 
- //for zlib...
--#include "zlib.h"
-+#ifdef SYSTEM_ZLIB
-+#include <zlib.h>
-+#else
-+#include <external/zlib/zlib.h>
-+#endif
- #if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__)
- #  include <fcntl.h>
- #  include <io.h>
diff --git a/filter/source/flash/swfwriter1.cxx b/filter/source/flash/swfwriter1.cxx
index 3f20b6c..0151fa1 100644
--- a/filter/source/flash/swfwriter1.cxx
+++ b/filter/source/flash/swfwriter1.cxx
@@ -41,13 +41,7 @@
 #include <vcl/graphictools.hxx>
 #include <vcl/rendergraphicrasterizer.hxx>
 
-#ifndef _ZLIB_H
-#ifdef SYSTEM_ZLIB
 #include <zlib.h>
-#else
-#include <external/zlib/zlib.h>
-#endif
-#endif
 
 #include <vcl/salbtype.hxx>
 #include <basegfx/polygon/b2dpolygon.hxx>
diff --git a/gdk-pixbuf/gdk-pixbuf-2.23.0-win32.patch b/gdk-pixbuf/gdk-pixbuf-2.23.0-win32.patch
index 142ea34..37a3d08 100644
--- a/gdk-pixbuf/gdk-pixbuf-2.23.0-win32.patch
+++ b/gdk-pixbuf/gdk-pixbuf-2.23.0-win32.patch
@@ -208,7 +208,7 @@
 +GLIB_LIB = $(OUTDIR)\lib\glib-2.0.lib $(OUTDIR)\lib\gobject-2.0.lib  $(OUTDIR)\lib\gmodule-2.0.lib  $(OUTDIR)\lib\gio-2.0.lib $(OUTDIR)\lib\gthread-2.0.lib	
 +LIBJPEG_LIB = $(OUTDIR)\lib\jpeg.lib
 +LIBPNG_LIB = $(OUTDIR)\lib\libpng.lib
-+ZLIB_LIB = $(OUTDIR)\lib\zlib.lib
++ZLIB_LIB = $(OUTDIR)\lib\z.lib
 +GDIPLUS_LIB = gdiplus.lib
  
 -!INCLUDE $(TOP)/glib/build/win32/make.msc
diff --git a/glib/glib-2.28.1-win32.patch b/glib/glib-2.28.1-win32.patch
index 3089f93..f45b46f 100644
--- a/glib/glib-2.28.1-win32.patch
+++ b/glib/glib-2.28.1-win32.patch
@@ -73,26 +73,17 @@
  !IFDEF ZLIB
  ZLIB_CFLAGS = -I $(ZLIB)
 -ZLIB_LIBS = $(ZLIB)\projects\visualc6\Win32_LIB_Release\zlib.lib
-+ZLIB_LIBS = $(OUTDIR)\lib\zlib.lib
++ZLIB_LIBS = $(OUTDIR)\lib\z.lib
  !ELSE
 -ZLIB_CFLAGS = -I $(DEVTOP)\include
 -ZLIB_LIBS = $(DEVTOP)\lib\zdll.lib
-+ZLIB_CFLAGS = -I $(OUTDIR)\inc\external\zlib
-+ZLIB_LIBS = $(OUTDIR)\lib\zlib.lib
++ZLIB_CFLAGS = -I $(OUTDIR)\inc\external
++ZLIB_LIBS = $(OUTDIR)\lib\z.lib
  !ENDIF
  
  ################
 --- misc/glib-2.28.1/gio/gzlibcompressor.c	2011-02-11 16:23:12.000000000 +0100
 +++ misc/build/glib-2.28.1/gio/gzlibcompressor.c	2011-03-07 10:33:19.559189800 +0100
-@@ -25,7 +25,7 @@
- #include "gzlibcompressor.h"
- 
- #include <errno.h>
--#include <zlib.h>
-+#include <zlib/zlib.h>
- #include <string.h>
- 
- #include "gfileinfo.h"
 @@ -64,8 +64,10 @@
  
    GZlibCompressorFormat format;
@@ -115,15 +106,6 @@
    if (compressor->format != G_ZLIB_COMPRESSOR_FORMAT_GZIP ||
 --- misc/glib-2.28.1/gio/gzlibdecompressor.c	2011-03-07 09:13:41.324890400 +0100
 +++ misc/build/glib-2.28.1/gio/gzlibdecompressor.c	2011-03-04 11:28:39.712480200 +0100
-@@ -25,7 +25,7 @@
- #include "gzlibdecompressor.h"
- 
- #include <errno.h>
--#include <zlib.h>
-+#include <zlib/zlib.h>
- #include <string.h>
- 
- #include "gfileinfo.h"
 @@ -76,7 +76,7 @@
  g_zlib_decompressor_set_gzheader (GZlibDecompressor *decompressor)
  {
diff --git a/hwpfilter/source/hgzip.h b/hwpfilter/source/hgzip.h
index c8b2cbe..600d8f1 100644
--- a/hwpfilter/source/hgzip.h
+++ b/hwpfilter/source/hgzip.h
@@ -29,12 +29,7 @@
 #ifndef _HWPGZIP_H_
 #define _HWPGZIP_H_
 
-// DVO: add zlib/ prefix
-#ifdef SYSTEM_ZLIB
 #include <zlib.h>
-#else
-#include "zlib/zlib.h"
-#endif
 
 class HStream;
 /**
diff --git a/hwpfilter/source/hiodev.cxx b/hwpfilter/source/hiodev.cxx
index 20b368a..e8b45d6 100644
--- a/hwpfilter/source/hiodev.cxx
+++ b/hwpfilter/source/hiodev.cxx
@@ -28,12 +28,7 @@
 
 #include <stdio.h>
 #include <errno.h>
-// DVO: add zlib/ prefix
-#ifdef SYSTEM_ZLIB
 #include <zlib.h>
-#else
-#include <zlib/zlib.h>
-#endif
 #ifdef WIN32
 # include <io.h>
 #else
diff --git a/libgsf/libgsf-1.14.19.windows.patch b/libgsf/libgsf-1.14.19.windows.patch
index 56c10c5..98e0a8f 100644
--- a/libgsf/libgsf-1.14.19.windows.patch
+++ b/libgsf/libgsf-1.14.19.windows.patch
@@ -55,7 +55,7 @@
 +
 +.INCLUDE : settings.mk
 +
-+CFLAGS+= -I.. -I$(SOLARINCDIR)$/external$/glib-2.0 -I$(SOLARINCDIR)$/external$/zlib -I$(SOLARINCDIR)$/external
++CFLAGS+= -I.. -I$(SOLARINCDIR)$/external$/glib-2.0 -I$(SOLARINCDIR)$/external
 +
 +# --- Files -------------------------------------
 +
@@ -115,7 +115,7 @@
 +    gobject-2.0.lib \
 +    glib-2.0.lib \
 +    intl.lib \
-+    zlib.lib \
++    z.lib \
 +	Advapi32.lib
 +
 +
diff --git a/libpng/libpng-1.5.1.patch b/libpng/libpng-1.5.1.patch
index ebae94a..58f7011 100644
--- a/libpng/libpng-1.5.1.patch
+++ b/libpng/libpng-1.5.1.patch
@@ -231,51 +231,3 @@
 +#define PNG_iTXt_SUPPORTED
 +/* end of options */
 +#endif /* PNGLCONF_H */
---- misc/libpng-1.5.1/pngstruct.h	2011-02-03 05:58:17.000000000 +0100
-+++ misc/build/libpng-1.5.1/pngstruct.h	2011-03-24 21:47:23.380397048 +0100
-@@ -24,7 +24,15 @@
-  * in this structure and is required for decompressing the LZ compressed
-  * data in PNG files.
-  */
-+/* WTF, surely this should depend explicitly on whether using the system or
-+ * internal zlib, not on OS... But yeah, so maybe MacOSX, iOS and Android are the only OSes for which
-+ * we use a system zlib but internal libpng, at least by default.
-+ */
-+#if defined MACOSX || defined IOS || defined ANDROID
- #include "zlib.h"
-+#else
-+#include <external/zlib/zlib.h>
-+#endif
- 
- struct png_struct_def
- {
---- misc/libpng-1.5.1/pngtest.c	2011-02-03 05:58:17.000000000 +0100
-+++ misc/build/libpng-1.5.1/pngtest.c	2011-03-24 21:47:23.380397048 +0100
-@@ -31,7 +31,12 @@
-  * of files at once by typing "pngtest -m file1.png file2.png ..."
-  */
-
-+#if defined MACOSX || defined IOS || defined ANDROID
- #include "zlib.h"
-+#else
-+#include <external/zlib/zlib.h>
-+#endif
-+
- #include "png.h"
- /* Copied from pngpriv.h but only used in error messages below. */
- #ifndef PNG_ZBUF_SIZE
---- misc/libpng-1.5.1/pngvalid.c	2011-02-03 05:58:17.000000000 +0100
-+++ misc/build/libpng-1.5.1/pngvalid.c	2011-03-24 21:47:23.381397048 +0100
-@@ -51,7 +51,11 @@
- #define PNG_READ_16BIT_SUPPORTED
- #endif
-
--#include "zlib.h"   /* For crc32 */
-+#if defined MACOSX || defined IOS || defined ANDROID
-+#include "zlib.h"
-+#else
-+#include <external/zlib/zlib.h>
-+#endif
-
- #include <float.h>  /* For floating point constants */
- #include <stdlib.h> /* For malloc */
diff --git a/moz/makefile.mk b/moz/makefile.mk
index 13db91f..6b31556 100644
--- a/moz/makefile.mk
+++ b/moz/makefile.mk
@@ -220,16 +220,14 @@ MOZDIR=$(MISC)$/build$/seamonkey
 MOZTARGET=$(OS)$(COM)$(CPU)
 
 .IF "$(GUI)"=="WNT"
+#for moz to link to our static lz if necessary
+SYSTEM_ZLIB:="YES"
 # "Our" build environment uses "NO" for the environment variable that
 # indicate if system libraries should be used, the mozilla build uses
 # "" in this case. This conflicts (at least for W32) with mozilla (1.7b)
 # because it disables the library checks for msvc so that
 # --without-system-* is not evaluated. To build the included libraries
 # the affected variables have to be empty and not NO.
-.IF "$(SYSTEM_ZLIB)"=="NO"
-SYSTEM_ZLIB:=
-.EXPORT : SYSTEM_ZLIB
-.ENDIF
 .IF "$(SYSTEM_JPEG)"=="NO"
 SYSTEM_JPEG:=
 .EXPORT : SYSTEM_JPEG
diff --git a/neon/neon.patch b/neon/neon.patch
index b7a3f85..cbb2db1 100644
--- a/neon/neon.patch
+++ b/neon/neon.patch
@@ -492,7 +492,7 @@
 +#endif
 --- misc/neon-0.29.5/src/makefile.mk	2011-02-03 10:32:38.000000000 +0100
 +++ misc/build/neon-0.29.5/src/makefile.mk	2011-02-03 10:26:19.000000000 +0100
-@@ -1,1 +1,96 @@
+@@ -1,1 +1,89 @@
 -dummy
 +PRJ=..$/..$/..$/..$/..
 +
@@ -523,13 +523,6 @@
 +CFLAGS+= $(OPENSSL_CFLAGS)
 +.ENDIF
 +
-+.IF "$(SYSTEM_ZLIB)" == "YES"
-+CFLAGS+=-DSYSTEM_ZLIB
-+.ELSE
-+ZLIBINCDIR=external$/zlib
-+CFLAGS+=-I$(SOLARINCDIR)$/$(ZLIBINCDIR)
-+.ENDIF
-+
 +SLOFILES= \
 +        $(SLO)$/ne_207.obj \
 +        $(SLO)$/ne_acl3744.obj \
diff --git a/nss/nss.patch b/nss/nss.patch
index 6930e67..3764cc4 100644
--- a/nss/nss.patch
+++ b/nss/nss.patch
@@ -67,20 +67,6 @@
  LDFLAGS			+= $(ARCHFLAG)
  
  # INCLUDES += -I/usr/include -Y/usr/include/linux
-@@ -158,8 +161,13 @@
- #
- CPU_TAG = _$(CPU_ARCH)
- 
-+ifeq ($(SYSTEM_ZLIB),YES)  
-+# Currently (3.12.4) only the tools modutil and signtool are linked with libz
-+# If USE_SYSTEM_ZLIB is not set then the tools link statically libzlib.a which
-+# is also build in nss.
- USE_SYSTEM_ZLIB = 1
- ZLIB_LIBS = -lz
-+endif
- 
- # The -rpath '$$ORIGIN' linker option instructs this library to search for its
- # dependencies in the same directory where it resides.
 --- misc/nss-3.12.8/mozilla/security/coreconf/SunOS5.mk	2009-06-11 02:55:32.000000000 +0200
 +++ misc/build/nss-3.12.8/mozilla/security/coreconf/SunOS5.mk	2010-06-11 16:35:54.985571182 +0200
 @@ -89,8 +89,12 @@
diff --git a/nss/prj/build.lst b/nss/prj/build.lst
index 14963ff..23cea65 100644
--- a/nss/prj/build.lst
+++ b/nss/prj/build.lst
@@ -1,3 +1,3 @@
-ns	nss	: solenv NULL
+ns	nss	: solenv ZLIB:zlib NULL
 ns	nss						nmake	-	usr1	ns_mkout NULL
 ns	nss						nmake	-	all	ns_nss NULL
diff --git a/package/Library_package2.mk b/package/Library_package2.mk
index 223e280..fcb7b62 100644
--- a/package/Library_package2.mk
+++ b/package/Library_package2.mk
@@ -88,10 +88,4 @@ $(eval $(call gb_Library_add_exception_objects,package2,\
 	package/source/zippackage/ZipPackageStream \
 ))
 
-ifeq ($(SYSTEM_ZLIB),YES)
-$(eval $(call gb_Library_add_defs,package2,\
-	-DSYSTEM_ZLIB \
-))
-endif
-
 # vim: set noet sw=4 ts=4:
diff --git a/package/source/zipapi/Deflater.cxx b/package/source/zipapi/Deflater.cxx
index 75d9d39..3333c0d 100644
--- a/package/source/zipapi/Deflater.cxx
+++ b/package/source/zipapi/Deflater.cxx
@@ -27,11 +27,7 @@
  ************************************************************************/
 
 #include <package/Deflater.hxx>
-#ifdef SYSTEM_ZLIB
 #include <zlib.h>
-#else
-#include <external/zlib/zlib.h>
-#endif
 #include <com/sun/star/packages/zip/ZipConstants.hpp>
 #include <string.h> // for memset
 
diff --git a/package/source/zipapi/Inflater.cxx b/package/source/zipapi/Inflater.cxx
index 2149e59..b83eea0 100644
--- a/package/source/zipapi/Inflater.cxx
+++ b/package/source/zipapi/Inflater.cxx
@@ -27,11 +27,7 @@
  ************************************************************************/
 
 #include <package/Inflater.hxx>
-#ifdef SYSTEM_ZLIB
 #include <zlib.h>
-#else
-#include <external/zlib/zlib.h>
-#endif
 #include <string.h> // for memset
 
 using namespace com::sun::star::uno;
diff --git a/sdext/source/pdfimport/pdfparse/pdfentries.cxx b/sdext/source/pdfimport/pdfparse/pdfentries.cxx
index 9c36cf8..14ff3b9 100644
--- a/sdext/source/pdfimport/pdfparse/pdfentries.cxx
+++ b/sdext/source/pdfimport/pdfparse/pdfentries.cxx
@@ -36,11 +36,7 @@
 #include <rtl/digest.h>
 #include <rtl/cipher.h>
 #include <rtl/memory.h>
-#ifdef SYSTEM_ZLIB
 #include "zlib.h"
-#else
-#include <zlib/zlib.h>
-#endif
 
 #include <math.h>
 #include <map>
diff --git a/sdext/source/pdfimport/test/tests.cxx b/sdext/source/pdfimport/test/tests.cxx
index ab4e5fc..f77c82e 100644
--- a/sdext/source/pdfimport/test/tests.cxx
+++ b/sdext/source/pdfimport/test/tests.cxx
@@ -32,11 +32,7 @@
 
 #define BASEGFX_STATICLIBRARY
 
-#ifdef SYSTEM_ZLIB
 #include "zlib.h"
-#else
-#include <zlib/zlib.h>
-#endif
 
 #include "outputwrap.hxx"
 #include "contentsink.hxx"
diff --git a/sdext/source/pdfimport/xpdfwrapper/pnghelper.cxx b/sdext/source/pdfimport/xpdfwrapper/pnghelper.cxx
index 71b0c89..aee3a70 100644
--- a/sdext/source/pdfimport/xpdfwrapper/pnghelper.cxx
+++ b/sdext/source/pdfimport/xpdfwrapper/pnghelper.cxx
@@ -32,12 +32,7 @@
 #include "pnghelper.hxx"
 #include <sal/macros.h>
 
-#ifdef SYSTEM_ZLIB
 #include "zlib.h"
-#else
-#define ZLIB_INTERNAL 1
-#include <zlib/zlib.h>
-#endif
 
 using namespace pdfi;
 
diff --git a/shell/inc/internal/zipfile.hxx b/shell/inc/internal/zipfile.hxx
index 24fba65..7b11941 100644
--- a/shell/inc/internal/zipfile.hxx
+++ b/shell/inc/internal/zipfile.hxx
@@ -33,11 +33,7 @@
 #define _WINDOWS
 #endif
 
-#ifdef SYSTEM_ZLIB
 #include <zlib.h>
-#else
-#include <external/zlib/zlib.h>
-#endif
 
 #include <string>
 #include <vector>
diff --git a/shell/source/win32/ooofilereader/makefile.mk b/shell/source/win32/ooofilereader/makefile.mk
index b26e10a..6b9d1ef 100644
--- a/shell/source/win32/ooofilereader/makefile.mk
+++ b/shell/source/win32/ooofilereader/makefile.mk
@@ -47,10 +47,6 @@ CFLAGS_X64+=-wd4710 -wd4711 -wd4514 -wd4619 -wd4217 -wd4820
 .ENDIF
 CDEFS_X64+=-U_WIN32_IE -D_WIN32_IE=0x501 -U_WIN32_WINNT -D_WIN32_WINNT=0x0501
 
-.IF "$(SYSTEM_ZLIB)" == "YES"
-CDEFS += -DSYSTEM_ZLIB
-.END
-
 # --- Files --------------------------------------------------------
 
 
diff --git a/shell/source/win32/shlxthandler/columninfo/makefile.mk b/shell/source/win32/shlxthandler/columninfo/makefile.mk
index 7157f8f..31c019f 100644
--- a/shell/source/win32/shlxthandler/columninfo/makefile.mk
+++ b/shell/source/win32/shlxthandler/columninfo/makefile.mk
@@ -42,10 +42,6 @@ CFLAGS+=-wd4710 -wd4711 -wd4514 -wd4619 -wd4217 -wd4820
 .ENDIF
 CDEFS+=-U_WIN32_IE -D_WIN32_IE=0x501 -U_WIN32_WINNT -D_WIN32_WINNT=0x0501
 
-.IF "$(SYSTEM_ZLIB)" == "YES"
-CDEFS += -DSYSTEM_ZLIB
-.END
-
 # --- Files --------------------------------------------------------
 
 SLOFILES=$(SLO)$/columninfo.obj
diff --git a/shell/source/win32/shlxthandler/infotips/makefile.mk b/shell/source/win32/shlxthandler/infotips/makefile.mk
index 38126a5..e7caf3a 100644
--- a/shell/source/win32/shlxthandler/infotips/makefile.mk
+++ b/shell/source/win32/shlxthandler/infotips/makefile.mk
@@ -42,10 +42,6 @@ CFLAGS+=-wd4710 -wd4711 -wd4514 -wd4619 -wd4217 -wd4820
 .ENDIF
 CDEFS+=-U_WIN32_IE -D_WIN32_IE=0x501 -U_WIN32_WINNT -D_WIN32_WINNT=0x0501
 
-.IF "$(SYSTEM_ZLIB)" == "YES"
-CDEFS += -DSYSTEM_ZLIB
-.END
-
 # --- Files --------------------------------------------------------
 
 SLOFILES=$(SLO)$/$(TARGET).obj
diff --git a/shell/source/win32/shlxthandler/makefile.mk b/shell/source/win32/shlxthandler/makefile.mk
index 81c3515..b15f0ee 100644
--- a/shell/source/win32/shlxthandler/makefile.mk
+++ b/shell/source/win32/shlxthandler/makefile.mk
@@ -59,10 +59,6 @@ CDEFS+=-DDONT_HAVE_GDIPLUS
 
 CDEFS+=-U_WIN32_IE -D_WIN32_IE=0x501 -U_WIN32_WINNT -D_WIN32_WINNT=0x0501
 
-.IF "$(SYSTEM_ZLIB)" == "YES"
-CDEFS += -DSYSTEM_ZLIB
-.END
-
 # --- Files --------------------------------------------------------
 
 SLOFILES=$(SLO)$/classfactory.obj\
@@ -82,7 +78,7 @@ SHL1STDLIBS=$(ZLIB3RDLIB) $(MINIZIP3RDLIB) $(EXPAT3RDLIB) $(COMCTL32LIB)
 SHL1LIBS=
 .ELSE
 SHL1STDLIBS=
-SHL1LIBS=$(SOLARLIBDIR)$/zlib.lib\
+SHL1LIBS=$(SOLARLIBDIR)$/$(ZLIB3RDLIB)\
     $(SOLARLIBDIR)$/expat_xmlparse.lib\
     $(SOLARLIBDIR)$/expat_xmltok.lib
 .ENDIF
@@ -132,7 +128,7 @@ SLOFILES_X64= \
     $(SLO_X64)$/stream_helper.obj\
 
 SHL1TARGET_X64=$(TARGET)
-SHL1LIBS_X64=$(SOLARLIBDIR_X64)$/zlib.lib\
+SHL1LIBS_X64=$(SOLARLIBDIR_X64)$/$(ZLIB3RDLIB)\
     $(SOLARLIBDIR_X64)$/expat_xmlparse.lib\
     $(SOLARLIBDIR_X64)$/expat_xmltok.lib
 
diff --git a/shell/source/win32/shlxthandler/ooofilt/makefile.mk b/shell/source/win32/shlxthandler/ooofilt/makefile.mk
index afb2988..2ccf2ca 100644
--- a/shell/source/win32/shlxthandler/ooofilt/makefile.mk
+++ b/shell/source/win32/shlxthandler/ooofilt/makefile.mk
@@ -46,10 +46,6 @@ CFLAGS+=-wd4710 -wd4711 -wd4514 -wd4619 -wd4217 -wd4820
 .ENDIF
 CDEFS+=-U_WIN32_IE -D_WIN32_IE=0x501 -U_WIN32_WINNT -D_WIN32_WINNT=0x0501
 
-.IF "$(SYSTEM_ZLIB)" == "YES"
-CDEFS += -DSYSTEM_ZLIB
-.END
-
 # --- Files --------------------------------------------------------
 
 SLOFILES=$(SLO)$/ooofilt.obj\
@@ -62,7 +58,7 @@ SHL1STDLIBS=$(ZLIB3RDLIB) $(MINIZIP3RDLIB) $(EXPAT3RDLIB)
 SHL1LIBS=
 .ELSE
 SHL1STDLIBS=
-SHL1LIBS=$(SOLARLIBDIR)$/zlib.lib\
+SHL1LIBS=$(SOLARLIBDIR)$/$(ZLIB3RDLIB)\
     $(SOLARLIBDIR)$/expat_xmlparse.lib\
     $(SOLARLIBDIR)$/expat_xmltok.lib
 .ENDIF
@@ -108,7 +104,7 @@ SLOFILES_X64=$(SLO_X64)$/ooofilt.obj\
 
 SHL1TARGET_X64=$(TARGET)
 
-SHL1LIBS_X64=$(SOLARLIBDIR_X64)$/zlib.lib\
+SHL1LIBS_X64=$(SOLARLIBDIR_X64)$/$(ZLIB3RDLIB)\
     $(SOLARLIBDIR_X64)$/expat_xmlparse.lib\
     $(SOLARLIBDIR_X64)$/expat_xmltok.lib
 
diff --git a/shell/source/win32/shlxthandler/prophdl/makefile.mk b/shell/source/win32/shlxthandler/prophdl/makefile.mk
index 8a6813a..56355e1 100644
--- a/shell/source/win32/shlxthandler/prophdl/makefile.mk
+++ b/shell/source/win32/shlxthandler/prophdl/makefile.mk
@@ -67,7 +67,7 @@ SHL1STDLIBS=$(ZLIB3RDLIB) $(MINIZIP3RDLIB) $(EXPAT3RDLIB) $(COMCTL32LIB)
 SHL1LIBS=
 .ELSE
 SHL1STDLIBS=
-SHL1LIBS=$(SOLARLIBDIR)$/zlib.lib\
+SHL1LIBS=$(SOLARLIBDIR)$/$(ZLIB3RDLIB)\
     $(SOLARLIBDIR)$/expat_xmlparse.lib\
     $(SOLARLIBDIR)$/expat_xmltok.lib
 .ENDIF
@@ -115,7 +115,7 @@ SLOFILES_X64= \
     $(SLO_X64)$/stream_helper.obj\
 
 SHL1TARGET_X64=$(TARGET)
-SHL1LIBS_X64=$(SOLARLIBDIR_X64)$/zlib.lib\
+SHL1LIBS_X64=$(SOLARLIBDIR_X64)$/$(ZLIB3RDLIB)\
     $(SOLARLIBDIR_X64)$/expat_xmlparse.lib\
     $(SOLARLIBDIR_X64)$/expat_xmltok.lib
 
diff --git a/shell/source/win32/shlxthandler/propsheets/makefile.mk b/shell/source/win32/shlxthandler/propsheets/makefile.mk
index 08adff7..68c65b2 100644
--- a/shell/source/win32/shlxthandler/propsheets/makefile.mk
+++ b/shell/source/win32/shlxthandler/propsheets/makefile.mk
@@ -44,10 +44,6 @@ CFLAGS_X64+=-wd4710 -wd4711 -wd4514 -wd4619 -wd4217 -wd4820
 CDEFS_X64+=-U_WIN32_WINNT -D_WIN32_WINNT=0x0501 -U_WIN32_IE -D_WIN32_IE=0x501
 .ENDIF
 
-.IF "$(SYSTEM_ZLIB)" == "YES"
-CDEFS += -DSYSTEM_ZLIB
-.END
-
 # --- Files --------------------------------------------------------
 
 SLOFILES=$(SLO)$/propsheets.obj\
diff --git a/shell/source/win32/shlxthandler/util/makefile.mk b/shell/source/win32/shlxthandler/util/makefile.mk
index e2b7a82..f2edb7f 100644
--- a/shell/source/win32/shlxthandler/util/makefile.mk
+++ b/shell/source/win32/shlxthandler/util/makefile.mk
@@ -47,10 +47,6 @@ CFLAGS_X64+=-wd4710 -wd4711 -wd4514 -wd4619 -wd4217 -wd4820
 .ENDIF
 CDEFS_X64+=-U_WIN32_IE -D_WIN32_IE=0x501 -U_WIN32_WINNT -D_WIN32_WINNT=0x0501
 
-.IF "$(SYSTEM_ZLIB)" == "YES"
-CDEFS += -DSYSTEM_ZLIB
-.END
-
 # --- Files --------------------------------------------------------
 
 SLOFILES=$(SLO)$/fileextensions.obj\
diff --git a/shell/source/win32/zipfile/makefile.mk b/shell/source/win32/zipfile/makefile.mk
index 0e165dd..5d2d162 100644
--- a/shell/source/win32/zipfile/makefile.mk
+++ b/shell/source/win32/zipfile/makefile.mk
@@ -35,10 +35,6 @@ EXTERNAL_WARNINGS_NOT_ERRORS := TRUE
 
 .INCLUDE :  settings.mk
 
-.IF "$(SYSTEM_ZLIB)" == "YES"
-CDEFS += -DSYSTEM_ZLIB
-.END
-
 # --- Files --------------------------------------------------------
 
 
diff --git a/solenv/inc/libs.mk b/solenv/inc/libs.mk
index 3adeb01..4b536fd 100644
--- a/solenv/inc/libs.mk
+++ b/solenv/inc/libs.mk
@@ -193,11 +193,7 @@ EXPATASCII3RDLIB=-lexpat
 EXPAT3RDLIB=-lexpat_xmlparse -lexpat_xmltok
 EXPATASCII3RDLIB=-lascii_expat_xmlparse -lexpat_xmltok
 .ENDIF
-.IF "$(SYSTEM_ZLIB)"=="YES"
 ZLIB3RDLIB=-lz
-.ELSE
-ZLIB3RDLIB=-lzlib
-.ENDIF
 .IF "$(SYSTEM_MINIZIP)"=="YES"
 MINIZIP3RDLIB=$(MINIZIP_LIBS)
 .ELSE
@@ -467,7 +463,7 @@ LNGLIB=ilng.lib
 CLUCENELIB=iclucene.lib
 EXPAT3RDLIB=expat_xmltok.lib expat_xmlparse.lib
 EXPATASCII3RDLIB=expat_xmltok.lib ascii_expat_xmlparse.lib
-ZLIB3RDLIB=zlib.lib
+ZLIB3RDLIB=z.lib
 JPEG3RDLIB=jpeglib.lib
 NEON3RDLIB=ineon.lib
 BERKELEYLIB=libdb47.lib
diff --git a/tools/source/zcodec/zcodec.cxx b/tools/source/zcodec/zcodec.cxx
index 46d3f24..45429dc 100644
--- a/tools/source/zcodec/zcodec.cxx
+++ b/tools/source/zcodec/zcodec.cxx
@@ -27,13 +27,7 @@
  ************************************************************************/
 
 #include <tools/stream.hxx>
-#ifndef _ZLIB_H
-#ifdef SYSTEM_ZLIB
 #include "zlib.h"
-#else
-#include "zlib/zlib.h"
-#endif
-#endif
 #include <tools/zcodec.hxx>
 #include <rtl/crc.h>
 #include <osl/endian.h>
diff --git a/zlib/CustomTarget_source.mk b/zlib/CustomTarget_source.mk
new file mode 100644
index 0000000..e051ab0
--- /dev/null
+++ b/zlib/CustomTarget_source.mk
@@ -0,0 +1,53 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+# Version: MPL 1.1 / GPLv3+ / LGPLv3+
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License or as specified alternatively below. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# Major Contributor(s):
+# Copyright (C) 2012 Red Hat, Inc., Caolán McNamara <caolanm at redhat.com>
+#  (initial developer)
+# Copyright (C) 2012 Red Hat, Inc., David Tardon <dtardon at redhat.com>
+#
+# All Rights Reserved.
+#
+# For minor contributions see the git repository.
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+# instead of those above.
+
+$(eval $(call gb_CustomTarget_CustomTarget,zlib/source))
+
+ZLSO := $(call gb_CustomTarget_get_workdir,zlib/source)
+
+$(call gb_CustomTarget_get_target,zlib/source) : $(ZLSO)/done
+
+# FIXME: do not hardcode the path here
+ifeq ($(OS_FOR_BUILD),WNT)
+zl_FIXED_TARFILE_LOCATION := $(shell cygpath -u $(TARFILE_LOCATION))/c735eab2d659a96e5a594c9e8541ad63-zlib-1.2.5.tar.gz
+else
+zl_FIXED_TARFILE_LOCATION := $(TARFILE_LOCATION)/c735eab2d659a96e5a594c9e8541ad63-zlib-1.2.5.tar.gz
+endif
+
+$(ZLSO)/done : $(zl_FIXED_TARFILE_LOCATION)
+	$(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),TAR,1)
+	$(call gb_Helper_abbreviate_dirs, \
+	mkdir -p $(dir $@) && cd $(dir $@) && \
+	$(GNUTAR) -x -z $(STRIP_COMPONENTS)=1 -f $< && \
+    $(GNUPATCH) -p1 < $(SRCDIR)/zlib/patches/zlib-1.2.5-gentoo.patch && \
+    $(GNUPATCH) -p1 < $(SRCDIR)/zlib/patches/minizip-null.patch && \
+    $(GNUPATCH) -p1 < $(SRCDIR)/zlib/patches/zlib-1.2.5-minizip-fixuncrypt.patch && \
+    $(GNUPATCH) -p1 < $(SRCDIR)/zlib/patches/zlib-1.2.5-zip64.patch )
+	touch $@
+
+# vim: set noet sw=4 ts=4:
diff --git a/zlib/Makefile b/zlib/Makefile
new file mode 100644
index 0000000..5f46a97
--- /dev/null
+++ b/zlib/Makefile
@@ -0,0 +1,11 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+
+EXTERNAL_WARNINGS_NOT_ERRORS := TRUE
+export EXTERNAL_WARNINGS_NOT_ERRORS
+
+module_directory:=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
+
+include $(module_directory)/../solenv/gbuild/partial_build.mk
+
+# vim: set noet sw=4 ts=4:
diff --git a/zlib/Module_zlib.mk b/zlib/Module_zlib.mk
new file mode 100644
index 0000000..42c1e5d
--- /dev/null
+++ b/zlib/Module_zlib.mk
@@ -0,0 +1,36 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+# Version: MPL 1.1 / GPLv3+ / LGPLv3+
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License or as specified alternatively below. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# Major Contributor(s):
+# Copyright (C) 2012 Red Hat, Inc., Caolán McNamara <caolanm at redhat.com>
+#  (initial developer)
+#
+# All Rights Reserved.
+#
+# For minor contributions see the git repository.
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+# instead of those above.
+
+$(eval $(call gb_Module_Module,zlib))
+
+$(eval $(call gb_Module_add_targets,zlib,\
+    CustomTarget_source \
+    StaticLibrary_zlib \
+    Package_source \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/zlib/Package_source.mk b/zlib/Package_source.mk
new file mode 100644
index 0000000..3479f08
--- /dev/null
+++ b/zlib/Package_source.mk
@@ -0,0 +1,38 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+# Version: MPL 1.1 / GPLv3+ / LGPLv3+
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License or as specified alternatively below. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# Major Contributor(s):
+# Copyright (C) 2012 Red Hat, Inc., Caolán McNamara <caolanm at redhat.com>
+#  (initial developer)
+# Copyright (C) 2012 Red Hat, Inc., David Tardon <dtardon at redhat.com>
+#
+# All Rights Reserved.
+#
+# For minor contributions see the git repository.
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+# instead of those above.
+
+$(eval $(call gb_Package_Package,zlib_source,$(call gb_CustomTarget_get_workdir,zlib/source)))
+
+$(call gb_Package_get_preparation_target,zlib_source) : $(call gb_CustomTarget_get_target,zlib/source)
+
+$(eval $(call gb_Package_add_file,zlib_source,inc/external/zconf.h,zconf.h))
+$(eval $(call gb_Package_add_file,zlib_source,inc/external/zlib.h,zlib.h))
+$(eval $(call gb_Package_add_file,zlib_source,inc/external/minizip/unzip.h,contrib/minizip/unzip.h))
+$(eval $(call gb_Package_add_file,zlib_source,inc/external/minizip/ioapi.h,contrib/minizip/ioapi.h))
+
+# vim: set noet sw=4 ts=4:
diff --git a/zlib/StaticLibrary_zlib.mk b/zlib/StaticLibrary_zlib.mk
new file mode 100644
index 0000000..bb862d6
--- /dev/null
+++ b/zlib/StaticLibrary_zlib.mk
@@ -0,0 +1,70 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+# Version: MPL 1.1 / GPLv3+ / LGPLv3+
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License or as specified alternatively below. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# Major Contributor(s):
+# Copyright (C) 2012 Red Hat, Inc., Caolán McNamara <caolanm at redhat.com>
+#  (initial developer)
+#
+# All Rights Reserved.
+#
+# For minor contributions see the git repository.
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+# instead of those above.
+
+$(eval $(call gb_StaticLibrary_StaticLibrary,z))
+
+$(eval $(call gb_StaticLibrary_use_package,z,zlib_source))
+
+$(eval $(call gb_StaticLibrary_set_warnings_not_errors,zlib))
+
+$(eval $(call gb_StaticLibrary_set_include,z,\
+	$$(INCLUDE) \
+))
+
+$(eval $(call gb_StaticLibrary_add_defs,z,\
+    $(LFS_CFLAGS) \
+))
+
+# zlib does not depend on sal nor needs uwinapi here
+$(eval $(call gb_StaticLibrary_use_libraries,z,\
+    $(filter-out uwinapi,$(gb_STDLIBS)) \
+))
+
+ifeq ($(OS),LINUX)
+$(eval $(call gb_StaticLibrary_use_libraries,z,\
+    m \
+    pthread \
+))
+endif
+
+$(eval $(call gb_StaticLibrary_add_generated_cobjects,z,\
+	CustomTarget/zlib/source/adler32 \
+	CustomTarget/zlib/source/compress \
+	CustomTarget/zlib/source/deflate \
+	CustomTarget/zlib/source/crc32 \
+	CustomTarget/zlib/source/inffast \
+	CustomTarget/zlib/source/inflate \
+	CustomTarget/zlib/source/inftrees \
+	CustomTarget/zlib/source/trees \
+	CustomTarget/zlib/source/zutil \
+	,$(if $(filter TRUE,$(EXTERNAL_WARNINGS_NOT_ERRORS)),\
+		$(filter-out $(gb_CFLAGS_WERROR),$(CFLAGS)),\
+		$(CFLAGS)) \
+	 $(gb_COMPILEROPTFLAGS) \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/zlib/make_patched_header.pl b/zlib/make_patched_header.pl
deleted file mode 100755
index 41dbdc5..0000000
--- a/zlib/make_patched_header.pl
+++ /dev/null
@@ -1,66 +0,0 @@
-:
-eval 'exec perl -S $0 ${1+"$@"}'
-    if 0;
-#*************************************************************************
-#
-# 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.
-#
-#*************************************************************************
-#
-# make_patched_header - make patched header
-#
-
-use strict;
-use File::Basename;
-use File::Path;
-use Carp;
-
-my $patched_file = shift @ARGV;
-$patched_file =~ s/\\/\//g;
-my $module = shift @ARGV;
-my $patch_dir = dirname($patched_file);
-my $orig_file = $patched_file;
-$orig_file =~ s/\/patched\//\//;
-
-if (!-f $orig_file) { carp("Cannot find file $orig_file\n"); };
-if (!-d $patch_dir) {
-    mkpath($patch_dir, 0, 0775);
-    if (!-d $patch_dir) {("mkdir: could not create directory $patch_dir\n"); };
-};
-
-open(PATCHED_FILE, ">$patched_file") or carp("Cannot open file $patched_file\n");
-open(ORIG_FILE, "<$orig_file") or carp("Cannot open file $orig_file\n");
-foreach (<ORIG_FILE>) {
-    if (/#include\s*"(\w+\.h\w*)"/) {
-        my $include = $1;
-        s/#include "$include"/#include <$module\/$include>/g;
-    };
-    print PATCHED_FILE $_;
-};
-close PATCHED_FILE;
-close ORIG_FILE;
-
-exit(0);
-
-
diff --git a/zlib/makefile.mk b/zlib/makefile.mk
deleted file mode 100644
index 6165ccc..0000000
--- a/zlib/makefile.mk
+++ /dev/null
@@ -1,75 +0,0 @@
-#*************************************************************************
-#
-# 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=zlib
-TARGET=zlib
-
-.IF "$(GUI)" == "UNX"
-.IF "$(SYSTEM_ZLIB)" == "YES"
-all:
-    @echo "An already available installation of zlib should exist on your system."
-    @echo "Therefore the version provided here does not need to be built in addition."
-.ENDIF
-.ENDIF
-
-# --- Settings -----------------------------------------------------
-
-.INCLUDE :	settings.mk
-
-# --- Files --------------------------------------------------------
-
-TARFILE_NAME=zlib-1.2.5
-TARFILE_MD5=c735eab2d659a96e5a594c9e8541ad63
-
-PATCH_FILES=zlib-1.2.5.patch
-ADDITIONAL_FILES=makefile.mk
-
-#relative to CONFIGURE_DIR
-
-BUILD_DIR=$(CONFIGURE_DIR)
-BUILD_ACTION=dmake $(MFLAGS) $(CALLMACROS)
-
-OUT2INC= \
-    zlib.h \
-    zconf.h \
-    contrib$/minizip$/unzip.h \
-    contrib$/minizip$/ioapi.h
-
-PATCHED_HEADERS=$(INCCOM)$/patched$/zlib.h
-
-# --- Targets ------------------------------------------------------
-
-.INCLUDE : set_ext.mk
-.INCLUDE :	target.mk
-.INCLUDE :	tg_ext.mk
-
-ALLTAR: $(PATCHED_HEADERS)
-
-$(PATCHED_HEADERS) : $(PACKAGE_DIR)$/$(PREDELIVER_FLAG_FILE)
-    @$(PERL) make_patched_header.pl $@ $(PRJNAME)
diff --git a/zlib/patches/minizip-null.patch b/zlib/patches/minizip-null.patch
new file mode 100644
index 0000000..bffe207
--- /dev/null
+++ b/zlib/patches/minizip-null.patch
@@ -0,0 +1,12 @@
+diff -up zlib-1.2.5/contrib/minizip/unzip.c.pom zlib-1.2.5/contrib/minizip/unzip.c
+--- zlib-1.2.5/contrib/minizip/unzip.c.pom	2010-02-15 12:59:40.000000000 +0100
++++ zlib-1.2.5/contrib/minizip/unzip.c	2011-04-06 12:06:04.000000000 +0200
+@@ -1145,7 +1145,7 @@ extern int ZEXPORT unzGetCurrentFileInfo
+                                                 szFileName,fileNameBufferSize,
+                                                 extraField,extraFieldBufferSize,
+                                                 szComment,commentBufferSize);
+-    if (err==UNZ_OK)
++    if (pfile_info && err==UNZ_OK)
+     {
+         pfile_info->version = file_info64.version;
+         pfile_info->version_needed = file_info64.version_needed;
diff --git a/zlib/patches/zlib-1.2.5-gentoo.patch b/zlib/patches/zlib-1.2.5-gentoo.patch
new file mode 100644
index 0000000..82c7f39
--- /dev/null
+++ b/zlib/patches/zlib-1.2.5-gentoo.patch
@@ -0,0 +1,12 @@
+diff -up zlib-1.2.5/zlib.h.pom zlib-1.2.5/zlib.h
+--- zlib-1.2.5/zlib.h.pom	2010-04-20 06:12:48.000000000 +0200
++++ zlib-1.2.5/zlib.h	2010-06-16 13:08:59.000000000 +0200
+@@ -1578,7 +1578,7 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF(
+ #  define gzoffset gzoffset64
+ #  define adler32_combine adler32_combine64
+ #  define crc32_combine crc32_combine64
+-#  ifdef _LARGEFILE64_SOURCE
++#  ifndef _LARGEFILE64_SOURCE
+      ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
+      ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int));
+      ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile));
diff --git a/zlib/patches/zlib-1.2.5-minizip-fixuncrypt.patch b/zlib/patches/zlib-1.2.5-minizip-fixuncrypt.patch
new file mode 100644
index 0000000..d113879
--- /dev/null
+++ b/zlib/patches/zlib-1.2.5-minizip-fixuncrypt.patch
@@ -0,0 +1,14 @@
+diff -up zlib-1.2.5/contrib/minizip/unzip.c.fixuncrypt zlib-1.2.5/contrib/minizip/unzip.c
+--- zlib-1.2.5/contrib/minizip/unzip.c.fixuncrypt	2011-11-11 12:13:56.335867758 -0500
++++ zlib-1.2.5/contrib/minizip/unzip.c	2011-11-11 12:14:01.747799372 -0500
+@@ -68,10 +68,6 @@
+ #include <stdlib.h>
+ #include <string.h>
+ 
+-#ifndef NOUNCRYPT
+-        #define NOUNCRYPT
+-#endif
+-
+ #include "zlib.h"
+ #include "unzip.h"
+ 
diff --git a/zlib/patches/zlib-1.2.5-zip64.patch b/zlib/patches/zlib-1.2.5-zip64.patch
new file mode 100644
index 0000000..2bc94de
--- /dev/null
+++ b/zlib/patches/zlib-1.2.5-zip64.patch
@@ -0,0 +1,59 @@
+diff -ru zlib-1.2.5/contrib/minizip/ioapi.c zlib-1.2.5-patch/contrib/minizip/ioapi.c
+--- zlib-1.2.5/contrib/minizip/ioapi.c	2010-01-04 12:31:24.000000000 -0500
++++ zlib-1.2.5-patch/contrib/minizip/ioapi.c	2011-07-05 15:47:48.263474587 -0400
+@@ -47,7 +47,7 @@
+     else
+     {
+         uLong tell_uLong = (*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream);
+-        if ((tell_uLong) == ((uLong)-1))
++        if ((tell_uLong) == MAXU32)
+             return (ZPOS64_T)-1;
+         else
+             return tell_uLong;
+diff -ru zlib-1.2.5/contrib/minizip/ioapi.h zlib-1.2.5-patch/contrib/minizip/ioapi.h
+--- zlib-1.2.5/contrib/minizip/ioapi.h	2010-02-15 06:59:40.000000000 -0500
++++ zlib-1.2.5-patch/contrib/minizip/ioapi.h	2011-07-05 15:48:36.281546917 -0400
+@@ -85,6 +85,8 @@
+ typedef uint64_t ZPOS64_T;
+ #else
+ 
++/* Maximum unsigned 32-bit value used as placeholder for zip64 */
++#define MAXU32 0xffffffff
+ 
+ #if defined(_MSC_VER) || defined(__BORLANDC__)
+ typedef unsigned __int64 ZPOS64_T;
+diff -ru zlib-1.2.5/contrib/minizip/unzip.c zlib-1.2.5-patch/contrib/minizip/unzip.c
+--- zlib-1.2.5/contrib/minizip/unzip.c	2010-02-15 06:59:40.000000000 -0500
++++ zlib-1.2.5-patch/contrib/minizip/unzip.c	2011-07-05 15:50:31.409310349 -0400
+@@ -1040,26 +1040,26 @@
+             {
+                                                         uLong uL;
+ 
+-                                                                if(file_info.uncompressed_size == (ZPOS64_T)(unsigned long)-1)
++                                                                if(file_info.uncompressed_size == MAXU32)
+                                                                 {
+                                                                         if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK)
+                                                                                         err=UNZ_ERRNO;
+                                                                 }
+ 
+-                                                                if(file_info.compressed_size == (ZPOS64_T)(unsigned long)-1)
++                                                                if(file_info.compressed_size == MAXU32)
+                                                                 {
+                                                                         if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK)
+                                                                                   err=UNZ_ERRNO;
+                                                                 }
+ 
+-                                                                if(file_info_internal.offset_curfile == (ZPOS64_T)(unsigned long)-1)
++                                                                if(file_info_internal.offset_curfile == MAXU32)
+                                                                 {
+                                                                         /* Relative Header offset */
+                                                                         if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK)
+                                                                                 err=UNZ_ERRNO;
+                                                                 }
+ 
+-                                                                if(file_info.disk_num_start == (unsigned long)-1)
++                                                                if(file_info.disk_num_start == MAXU32)
+                                                                 {
+                                                                         /* Disk Start Number */
+                                                                         if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)
+
diff --git a/zlib/prj/build.lst b/zlib/prj/build.lst
index 8ef73d9..2eb61b4 100644
--- a/zlib/prj/build.lst
+++ b/zlib/prj/build.lst
@@ -1,2 +1,3 @@
-zl	zlib	:	soltools NULL
-zl	zlib						nmake	-	all	zl_mkout NULL
+cl	zlib : soltools NULL
+cl	zlib			usr1	-   all	zl_mkout NULL
+cl	zlib\prj		nmake	-   all	zl_prj NULL
diff --git a/zlib/prj/d.lst b/zlib/prj/d.lst
index ef40caf..e69de29 100644
--- a/zlib/prj/d.lst
+++ b/zlib/prj/d.lst
@@ -1,11 +0,0 @@
-mkdir: %_DEST%\inc\external\zlib
-mkdir: %_DEST%\lib\x64
-
-..\%__SRC%\inc\patched\zlib.h %_DEST%\inc\external\zlib\zlib.h
-..\%__SRC%\inc\zconf.h %_DEST%\inc\external\zlib\zconf.h
-
-..\%__SRC%\lib\libzlib.a %_DEST%\lib\libzlib.a
-..\%__SRC%\slb\zlib.lib %_DEST%\lib\zlib.lib
-..\%__SRC%\slb\zlib.lin %_DEST%\lib\zlib.lin
-..\%__SRC%\slb\x64\zlib.lib %_DEST%\lib\x64\zlib.lib
-..\%__SRC%\slb\x64\zlib.lin %_DEST%\lib\x64\zlib.lin
diff --git a/zlib/prj/makefile.mk b/zlib/prj/makefile.mk
new file mode 100644
index 0000000..0997622
--- /dev/null
+++ b/zlib/prj/makefile.mk
@@ -0,0 +1 @@
+.INCLUDE : gbuildbridge.mk
diff --git a/zlib/zlib-1.2.5.patch b/zlib/zlib-1.2.5.patch
deleted file mode 100644
index 3389b88..0000000
--- a/zlib/zlib-1.2.5.patch
+++ /dev/null
@@ -1,67 +0,0 @@
---- misc/zlib-1.2.5/makefile.mk	Fri Mar 14 10:17:06 2008
-+++ misc/build/zlib-1.2.5/makefile.mk	Fri Mar 14 10:16:56 2008
-@@ -1 +1,63 @@
--dummy
-+#*************************************************************************
-+#
-+#   Copyright according the GNU Public License.
-+#
-+#*************************************************************************
-+
-+PRJ=..$/..$/..$/..
-+
-+PRJNAME=zlib
-+TARGET=zlib
-+LIBTARGET=NO
-+EXTERNAL_WARNINGS_NOT_ERRORS=TRUE
-+
-+# --- Settings -----------------------------------------------------
-+
-+.INCLUDE :  settings.mk
-+
-+# --- Files --------------------------------------------------------
-+
-+INCEXT=contrib$/minizip
-+
-+SLOFILES=	$(SLO)$/adler32.obj		\
-+			$(SLO)$/compress.obj	\
-+			$(SLO)$/deflate.obj		\
-+			$(SLO)$/crc32.obj		\
-+			$(SLO)$/inffast.obj		\
-+			$(SLO)$/inflate.obj		\
-+			$(SLO)$/inftrees.obj	\
-+			$(SLO)$/trees.obj		\
-+			$(SLO)$/zutil.obj
-+
-+
-+LIB1TARGET=$(SLB)$/$(TARGET).lib
-+LIB1ARCHIV=$(LB)$/lib$(TARGET).a
-+LIB1OBJFILES=$(SLOFILES)
-+
-+.IF "$(BUILD_X64)"!=""
-+SLOFILES_X64=	$(SLO_X64)$/adler32.obj		\
-+			$(SLO_X64)$/compress.obj	\
-+			$(SLO_X64)$/deflate.obj		\
-+			$(SLO_X64)$/crc32.obj		\
-+			$(SLO_X64)$/inffast.obj		\
-+			$(SLO_X64)$/inflate.obj		\
-+			$(SLO_X64)$/inftrees.obj	\
-+			$(SLO_X64)$/trees.obj		\
-+			$(SLO_X64)$/zutil.obj
-+
-+LIB1TARGET_X64=$(SLB_X64)$/$(TARGET).lib
-+LIB1OBJFILES_X64=$(SLOFILES_X64)
-+.ENDIF # "$(BUILD_X64)"!=""
-+
-+
-+# --- Targets ------------------------------------------------------
-+
-+$(MISC)$/%.c : contrib$/minizip$/%.c
-+	@echo ------------------------------
-+	@echo Making: $@
-+    @$(COPY) $< $@
-+
-+.INCLUDE :  set_wntx64.mk
-+.INCLUDE :  target.mk
-+.INCLUDE :  tg_wntx64.mk
-+


More information about the Libreoffice-commits mailing list