[Libreoffice-commits] core.git: Branch 'libreoffice-4-3' - 11 commits - basic/source external/coinmp external/cppunit external/freetype external/glew external/lcms2 external/python3 jvmfwk/plugins sal/cppunittester sw/CppunitTest_sw_macros_test.mk sw/qa sw/source

Michael Stahl mstahl at redhat.com
Mon May 26 02:50:54 PDT 2014


 basic/source/inc/namecont.hxx                       |    4 
 basic/source/inc/scriptcont.hxx                     |    1 
 basic/source/uno/namecont.cxx                       |   97 +++++++++++++-------
 basic/source/uno/scriptcont.cxx                     |    6 +
 external/coinmp/ExternalProject_coinmp.mk           |    2 
 external/cppunit/CPPUNIT_PLUGIN_EXPORT.patch.0      |   11 ++
 external/cppunit/ExternalProject_cppunit.mk         |   10 +-
 external/cppunit/UnpackedTarball_cppunit.mk         |    2 
 external/cppunit/enable-win32-debug.patch           |   18 +++
 external/freetype/ExternalProject_freetype.mk       |    2 
 external/glew/ExternalProject_glew.mk               |    2 
 external/lcms2/ExternalProject_lcms2.mk             |    2 
 external/python3/ExternalProject_python3.mk         |    3 
 jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx |   67 ++++++++++---
 sal/cppunittester/cppunittester.cxx                 |    1 
 sw/CppunitTest_sw_macros_test.mk                    |   62 ++++++------
 sw/qa/core/data/odt/fdo68983.odt                    |binary
 sw/qa/core/macros-test.cxx                          |   52 +++++++++-
 sw/qa/extras/ooxmlexport/data/fdo79008.docx         |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx            |   10 ++
 sw/qa/extras/ww8export/data/fdo77454.doc            |binary
 sw/qa/extras/ww8export/ww8export.cxx                |   24 ++++
 sw/source/filter/ww8/wrtw8esh.cxx                   |   18 ++-
 sw/source/filter/ww8/ww8graf.cxx                    |   33 ++++--
 24 files changed, 319 insertions(+), 108 deletions(-)

New commits:
commit 82e3391c0eaf63bc315b649036dd0ab149bf3b5f
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon May 26 11:39:06 2014 +0200

    externals: do not use "v110_xp" when building with MSVC 2012 and SDK 8.0
    
    Change-Id: I40bc9e4c31e270f29cc145b5d2f3544cad586bf7
    (cherry picked from commit 09c0a96eb3ea8d48e99ed50ae7d13d23f70a0c6c)

diff --git a/external/coinmp/ExternalProject_coinmp.mk b/external/coinmp/ExternalProject_coinmp.mk
index 71e1982..b483d45 100644
--- a/external/coinmp/ExternalProject_coinmp.mk
+++ b/external/coinmp/ExternalProject_coinmp.mk
@@ -20,7 +20,7 @@ $(call gb_ExternalProject_get_state_target,coinmp,build) :
 			/p:Configuration=$(if $(MSVC_USE_DEBUG_RUNTIME),Debug,Release) \
 			/p:Platform=Win32 \
 			$(if $(filter 100,$(VCVER)),/p:PlatformToolset=v100 /p:VisualStudioVersion=10.0) \
-			$(if $(filter 110,$(VCVER)),/p:PlatformToolset=v110_xp /p:VisualStudioVersion=11.0) \
+			$(if $(filter 110,$(VCVER)),/p:PlatformToolset=$(if $(filter 80,$(WINDOWS_SDK_VERSION)),v110,v110_xp) /p:VisualStudioVersion=11.0) \
 	,CoinMP/MSVisualStudio/v9)
 
 else
diff --git a/external/cppunit/ExternalProject_cppunit.mk b/external/cppunit/ExternalProject_cppunit.mk
index 30a5905..2f3217d 100644
--- a/external/cppunit/ExternalProject_cppunit.mk
+++ b/external/cppunit/ExternalProject_cppunit.mk
@@ -16,7 +16,9 @@ $(eval $(call gb_ExternalProject_register_targets,cppunit,\
 ifeq ($(OS)$(COM),WNTMSC)
 $(call gb_ExternalProject_get_state_target,cppunit,build) :
 	$(call gb_ExternalProject_run,build,\
-	    PROFILEFLAGS="$(if $(MSVC_USE_DEBUG_RUNTIME),Debug,Release) $(if $(filter 110,$(VCVER)),/p:PlatformToolset=v110_xp /p:VisualStudioVersion=11.0)" \
+	    PROFILEFLAGS="$(if $(MSVC_USE_DEBUG_RUNTIME),Debug,Release) \
+			$(if $(filter 110,$(VCVER)),/p:PlatformToolset=$(if $(filter 80,$(WINDOWS_SDK_VERSION)),v110,v110_xp) \
+				/p:VisualStudioVersion=11.0)" \
 		&& msbuild.exe cppunit_dll.vcxproj /p:Configuration=$${PROFILEFLAGS}  \
 		&& cd ../DllPlugInTester \
 		&& msbuild.exe DllPlugInTester.vcxproj /p:Configuration=$${PROFILEFLAGS} \
diff --git a/external/freetype/ExternalProject_freetype.mk b/external/freetype/ExternalProject_freetype.mk
index 17f2a5d..0c1c513 100644
--- a/external/freetype/ExternalProject_freetype.mk
+++ b/external/freetype/ExternalProject_freetype.mk
@@ -18,7 +18,7 @@ $(call gb_ExternalProject_get_state_target,freetype,build) :
 	$(call gb_ExternalProject_run,build,\
 		cd ../builds/win32/vc2010/ && \
 		msbuild.exe freetype.vcxproj /p:Configuration=$(if $(MSVC_USE_DEBUG_RUNTIME),Debug,Release) \
-		$(if $(filter 110,$(VCVER)),/p:PlatformToolset=v110_xp /p:VisualStudioVersion=11.0) \
+		$(if $(filter 110,$(VCVER)),/p:PlatformToolset=$(if $(filter 80,$(WINDOWS_SDK_VERSION)),v110,v110_xp) /p:VisualStudioVersion=11.0) \
 	,objs)
 else
 $(call gb_ExternalProject_get_state_target,freetype,build) :
diff --git a/external/glew/ExternalProject_glew.mk b/external/glew/ExternalProject_glew.mk
index 79b4a58..918d275 100644
--- a/external/glew/ExternalProject_glew.mk
+++ b/external/glew/ExternalProject_glew.mk
@@ -17,7 +17,7 @@ ifeq ($(COM),MSC)
 $(call gb_ExternalProject_get_state_target,glew,build) :
 	$(call gb_ExternalProject_run,build,\
 		msbuild.exe glew_shared.vcxproj /p:Configuration=$(if $(MSVC_USE_DEBUG_RUNTIME),Debug,Release) \
-		$(if $(filter 110,$(VCVER)),/p:PlatformToolset=v110_xp /p:VisualStudioVersion=11.0) \
+		$(if $(filter 110,$(VCVER)),/p:PlatformToolset=$(if $(filter 80,$(WINDOWS_SDK_VERSION)),v110,v110_xp) /p:VisualStudioVersion=11.0) \
 	,build/vc10)
 
 else
diff --git a/external/lcms2/ExternalProject_lcms2.mk b/external/lcms2/ExternalProject_lcms2.mk
index 1636bae..82664ae 100644
--- a/external/lcms2/ExternalProject_lcms2.mk
+++ b/external/lcms2/ExternalProject_lcms2.mk
@@ -20,7 +20,7 @@ $(call gb_ExternalProject_get_state_target,lcms2,build):
 		MSBuild.exe lcms2_DLL.vcxproj \
 			/p:Configuration=$(if $(MSVC_USE_DEBUG_RUNTIME),Debug,Release) \
 			/p:Platform=Win32 /p:TargetName=lcms2 \
-			$(if $(filter 110,$(VCVER)),/p:PlatformToolset=v110_xp /p:VisualStudioVersion=11.0) \
+			$(if $(filter 110,$(VCVER)),/p:PlatformToolset=$(if $(filter 80,$(WINDOWS_SDK_VERSION)),v110,v110_xp) /p:VisualStudioVersion=11.0) \
 	,Projects/VC2010/lcms2_DLL)
 else
 $(call gb_ExternalProject_get_state_target,lcms2,build):
diff --git a/external/python3/ExternalProject_python3.mk b/external/python3/ExternalProject_python3.mk
index 0bbd9b5..42c3dff 100644
--- a/external/python3/ExternalProject_python3.mk
+++ b/external/python3/ExternalProject_python3.mk
@@ -37,7 +37,8 @@ $(call gb_ExternalProject_get_state_target,python3,build) :
 			/p:Platform=$(if $(filter INTEL,$(CPUNAME)),Win32,x64) \
 			$(if $(filter 100,$(VCVER)), \
 				/ToolsVersion:4.0, \
-				/p:PlatformToolset=v110_xp /p:VisualStudioVersion=11.0) \
+				/p:PlatformToolset=$(if $(filter 80,$(WINDOWS_SDK_VERSION)),v110,v110_xp) \
+				/p:VisualStudioVersion=11.0) \
 		&& cd $(EXTERNAL_WORKDIR) \
 		&& ln -s PCbuild LO_lib \
 	,PCBuild)
commit 0fe1835dd0cf7c6ca077278acc6bd1bfe79294bd
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Sat May 24 13:39:59 2014 +0100

    cppunit: always compile with debugging symbols on windows.
    
    Also cleanup some makefile pieces and give better error warnings.
    
    Change-Id: I9f20d60f26d5828f60664941946c266c7d166f32
    (cherry picked from commit 02638a0865271959e7a424622088eb502721e24c)

diff --git a/external/cppunit/ExternalProject_cppunit.mk b/external/cppunit/ExternalProject_cppunit.mk
index 9a163e7..30a5905 100644
--- a/external/cppunit/ExternalProject_cppunit.mk
+++ b/external/cppunit/ExternalProject_cppunit.mk
@@ -13,15 +13,13 @@ $(eval $(call gb_ExternalProject_register_targets,cppunit,\
 	build \
 ))
 
-
 ifeq ($(OS)$(COM),WNTMSC)
 $(call gb_ExternalProject_get_state_target,cppunit,build) :
 	$(call gb_ExternalProject_run,build,\
-		msbuild.exe cppunit_dll.vcxproj /p:Configuration=$(if $(MSVC_USE_DEBUG_RUNTIME),Debug,Release) \
-		$(if $(filter 110,$(VCVER)),/p:PlatformToolset=v110_xp /p:VisualStudioVersion=11.0) \
+	    PROFILEFLAGS="$(if $(MSVC_USE_DEBUG_RUNTIME),Debug,Release) $(if $(filter 110,$(VCVER)),/p:PlatformToolset=v110_xp /p:VisualStudioVersion=11.0)" \
+		&& msbuild.exe cppunit_dll.vcxproj /p:Configuration=$${PROFILEFLAGS}  \
 		&& cd ../DllPlugInTester \
-		&& msbuild.exe DllPlugInTester.vcxproj /p:Configuration=$(if $(MSVC_USE_DEBUG_RUNTIME),Debug,Release) \
-		$(if $(filter 110,$(VCVER)),/p:PlatformToolset=v110_xp /p:VisualStudioVersion=11.0) \
+		&& msbuild.exe DllPlugInTester.vcxproj /p:Configuration=$${PROFILEFLAGS} \
 	,src/cppunit)
 else
 
diff --git a/external/cppunit/UnpackedTarball_cppunit.mk b/external/cppunit/UnpackedTarball_cppunit.mk
index a46e9bf..fbae41b 100644
--- a/external/cppunit/UnpackedTarball_cppunit.mk
+++ b/external/cppunit/UnpackedTarball_cppunit.mk
@@ -17,6 +17,7 @@ $(eval $(call gb_UnpackedTarball_add_patches,cppunit,\
 	external/cppunit/unix.patch \
 	external/cppunit/wundef.patch \
 	external/cppunit/CPPUNIT_PLUGIN_EXPORT.patch.0 \
+	external/cppunit/enable-win32-debug.patch \
 ))
 ifeq ($(DISABLE_DYNLOADING),TRUE)
 $(eval $(call gb_UnpackedTarball_add_patches,cppunit,\
diff --git a/external/cppunit/enable-win32-debug.patch b/external/cppunit/enable-win32-debug.patch
new file mode 100644
index 0000000..661bb4b
--- /dev/null
+++ b/external/cppunit/enable-win32-debug.patch
@@ -0,0 +1,18 @@
+--- misc/cppunit-1.13.1/src/cppunit/cppunit_dll.vcxproj
++++ misc/build/cppunit-1.13.1/src/cppunit/cppunit_dll.vcxproj
+@@ -107,7 +107,6 @@
+       <SuppressStartupBanner>true</SuppressStartupBanner>
+       <WarningLevel>Level3</WarningLevel>
+       <RuntimeTypeInfo>true</RuntimeTypeInfo>
+-      <DebugInformationFormat>OldStyle</DebugInformationFormat>
+       <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+       <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;CPPUNIT_BUILD_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+       <AssemblerListingLocation>.\ReleaseDll\</AssemblerListingLocation>
+@@ -138,6 +137,7 @@
+     <Link>
+       <SuppressStartupBanner>true</SuppressStartupBanner>
+       <LinkDLL>true</LinkDLL>
++      <GenerateDebugInformation>true</GenerateDebugInformation>
+       <SubSystem>Console</SubSystem>
+       <OutputFile>.\ReleaseDll\cppunit_dll.dll</OutputFile>
+       <ImportLibrary>.\ReleaseDll\cppunit_dll.lib</ImportLibrary>
diff --git a/sal/cppunittester/cppunittester.cxx b/sal/cppunittester/cppunittester.cxx
index 7ac8ab5..b42bf3a 100644
--- a/sal/cppunittester/cppunittester.cxx
+++ b/sal/cppunittester/cppunittester.cxx
@@ -214,6 +214,7 @@ public:
                 std::cerr << "please check your PATH variable and re-autogen.\n";
             }
 #endif
+            std::cerr << "Path is '" << getenv("PATH") << "'\n";
             return false;
         }
 #endif
commit 6f1d52af84c91e297933f27eba5b8019d993d707
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Thu May 22 14:28:20 2014 +0200

    Adapt CppUnit to our CPPUNIT_PLUGIN_EXPORT
    
    ...which mentions extern "C", so CppUnit's TestPlugInSignature must reflect
    that.  It is a bit odd how CPPUNIT_PLUGIN_EXPORT needs to be passed into
    CppUnit, so probably best to keep this as a local patch for now.  (Clang's
    -fsanitize=undefined complained about the mismatch.)
    
    Change-Id: Ied179a1afe82ceb04de4739c14cf8fadff31b80f
    (cherry picked from commit 77ad60af119ab23a0bfadb3e5a0c4433fe97835b)

diff --git a/external/cppunit/CPPUNIT_PLUGIN_EXPORT.patch.0 b/external/cppunit/CPPUNIT_PLUGIN_EXPORT.patch.0
new file mode 100644
index 0000000..a764be9
--- /dev/null
+++ b/external/cppunit/CPPUNIT_PLUGIN_EXPORT.patch.0
@@ -0,0 +1,11 @@
+--- include/cppunit/plugin/TestPlugIn.h
++++ include/cppunit/plugin/TestPlugIn.h
+@@ -111,7 +111,7 @@
+ /*! \brief Type of the function exported by a plug-in.
+  * \ingroup WritingTestPlugIn
+  */
+-typedef CppUnitTestPlugIn *(*TestPlugInSignature)();
++extern "C" { typedef CppUnitTestPlugIn *(*TestPlugInSignature)(); }
+ 
+ 
+ /*! \brief Implements the function exported by the test plug-in
diff --git a/external/cppunit/UnpackedTarball_cppunit.mk b/external/cppunit/UnpackedTarball_cppunit.mk
index 86dc77d..a46e9bf 100644
--- a/external/cppunit/UnpackedTarball_cppunit.mk
+++ b/external/cppunit/UnpackedTarball_cppunit.mk
@@ -16,6 +16,7 @@ $(eval $(call gb_UnpackedTarball_add_patches,cppunit,\
 	external/cppunit/windows.patch \
 	external/cppunit/unix.patch \
 	external/cppunit/wundef.patch \
+	external/cppunit/CPPUNIT_PLUGIN_EXPORT.patch.0 \
 ))
 ifeq ($(DISABLE_DYNLOADING),TRUE)
 $(eval $(call gb_UnpackedTarball_add_patches,cppunit,\
commit 9f504936095411fcefdb65b6e09bd557068af20f
Author: Michael Stahl <mstahl at redhat.com>
Date:   Sat May 24 18:02:31 2014 +0200

    fdo#77454: fix WW8 import/export of negative image crop
    
    The negative crop values were imported as large positive values, which
    caused the image to be rendered with 1 pixel width after commit
    2e5167528f7566dd9b000e50fc1610b7bf99132a.
    
    Change-Id: I0e01b9d9a05d90e868699832085a06ba5aab7e54
    (cherry picked from commit 6d431ffb682d0e64b75b6267f369822ff0b0617e)

diff --git a/sw/qa/extras/ww8export/data/fdo77454.doc b/sw/qa/extras/ww8export/data/fdo77454.doc
new file mode 100644
index 0000000..4e2d7b2
Binary files /dev/null and b/sw/qa/extras/ww8export/data/fdo77454.doc differ
diff --git a/sw/qa/extras/ww8export/ww8export.cxx b/sw/qa/extras/ww8export/ww8export.cxx
index d014dba..5857559 100644
--- a/sw/qa/extras/ww8export/ww8export.cxx
+++ b/sw/qa/extras/ww8export/ww8export.cxx
@@ -17,6 +17,7 @@
 #include <com/sun/star/view/XViewSettingsSupplier.hpp>
 #include <com/sun/star/table/ShadowFormat.hpp>
 #include <com/sun/star/table/TableBorder2.hpp>
+#include <com/sun/star/text/GraphicCrop.hpp>
 
 class Test : public SwModelTestBase
 {
@@ -150,6 +151,29 @@ DECLARE_WW8EXPORT_TEST(testCharacterBorder, "charborder.odt")
     }
 }
 
+DECLARE_WW8EXPORT_TEST(testFdo77454, "fdo77454.doc")
+{
+    {
+        // check negative crops round-trip
+        text::GraphicCrop const crop =
+            getProperty<text::GraphicCrop>(getShape(1), "GraphicCrop");
+        CPPUNIT_ASSERT_EQUAL(sal_Int32( -439), crop.Left);
+        CPPUNIT_ASSERT_EQUAL(sal_Int32(-7040), crop.Right);
+        CPPUNIT_ASSERT_EQUAL(sal_Int32( -220), crop.Top);
+        CPPUNIT_ASSERT_EQUAL(sal_Int32(-7040), crop.Bottom);
+    }
+
+    {
+        // check positive crops round-trip
+        text::GraphicCrop const crop =
+            getProperty<text::GraphicCrop>(getShape(2), "GraphicCrop");
+        CPPUNIT_ASSERT_EQUAL(sal_Int32(  326), crop.Left);
+        CPPUNIT_ASSERT_EQUAL(sal_Int32( 1208), crop.Right);
+        CPPUNIT_ASSERT(abs(sal_Int32(1635) -  crop.Top) <= 2);
+        CPPUNIT_ASSERT(abs(sal_Int32(  95) - crop.Bottom) <= 2);
+    }
+}
+
 DECLARE_WW8EXPORT_TEST(testFdo59530, "fdo59530.doc")
 {
     // See ooxmlexport's testFdo38244().
diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx
index 858a721..a06a244 100644
--- a/sw/source/filter/ww8/wrtw8esh.cxx
+++ b/sw/source/filter/ww8/wrtw8esh.cxx
@@ -2209,9 +2209,19 @@ sal_Int32 SwBasicEscherEx::ToFract16(sal_Int32 nVal, sal_uInt32 nMax) const
 {
     if (nMax)
     {
-        sal_Int32 nMSVal = (nVal / 65536) * nMax;
-        nMSVal += (nVal * 65536 ) / nMax;
-        return nMSVal;
+        if (nVal >= 0)
+        {
+            sal_Int32 nMSVal = (nVal / 65536) * nMax;
+            nMSVal += (nVal * 65536) / nMax;
+            return nMSVal;
+        } else {
+            // negative fraction does not have "-0", fractional part is always
+            // positive:  -0.4 represented as -1 + 0.6
+            sal_Int32 const nDiv = (nVal / sal_Int32(nMax)) - 1;
+            sal_uInt32 nMSVal = (nDiv << 16) & 0xffff0000;
+            nMSVal += (nVal * 65536) / sal_Int32(nMax) + (-nDiv * 65536);
+            return nMSVal;
+        }
     }
     return 0;
 }
diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx
index b4f28ab..ec4bf38 100644
--- a/sw/source/filter/ww8/ww8graf.cxx
+++ b/sw/source/filter/ww8/ww8graf.cxx
@@ -1972,6 +1972,13 @@ void SwWW8ImplReader::MapWrapIntoFlyFmt(SvxMSDffImportRec* pRecord,
     }
 }
 
+static sal_Int32 lcl_ConvertCrop(sal_uInt32 const nCrop, sal_Int32 const nSize)
+{
+    // cast to sal_Int32 to handle negative crop properly
+    return ((static_cast<sal_Int32>(nCrop) >> 16) * nSize)
+              + (((nCrop & 0xffff) * nSize) >> 16) ;
+}
+
 void
 SwWW8ImplReader::SetAttributesAtGrfNode(SvxMSDffImportRec const*const pRecord,
     SwFrmFmt *pFlyFmt, WW8_FSPA *pF )
@@ -1994,23 +2001,23 @@ SwWW8ImplReader::SetAttributesAtGrfNode(SvxMSDffImportRec const*const pRecord,
             pRecord->nCropFromLeft || pRecord->nCropFromRight )
         {
             SwCropGrf aCrop;            // Cropping is stored in 'fixed floats'
-                                        // 16.16 (it est fraction times total
+                                        // 16.16 (fraction times total
             if( pRecord->nCropFromTop ) //        image width or height resp.)
-                aCrop.SetTop( static_cast< sal_Int32 >(
-                (   ( (pRecord->nCropFromTop    >> 16   ) * rHeight )
-                  + (((pRecord->nCropFromTop    & 0xffff) * rHeight ) >> 16) )));
+            {
+                aCrop.SetTop(lcl_ConvertCrop(pRecord->nCropFromTop, rHeight));
+            }
             if( pRecord->nCropFromBottom )
-                aCrop.SetBottom( static_cast< sal_Int32 >(
-                (   ( (pRecord->nCropFromBottom >> 16   ) * rHeight )
-                  + (((pRecord->nCropFromBottom & 0xffff) * rHeight ) >> 16) )));
+            {
+                aCrop.SetBottom(lcl_ConvertCrop(pRecord->nCropFromBottom, rHeight));
+            }
             if( pRecord->nCropFromLeft )
-                aCrop.SetLeft( static_cast< sal_Int32 >(
-                (   ( (pRecord->nCropFromLeft   >> 16   ) * rWidth  )
-                  + (((pRecord->nCropFromLeft   & 0xffff) * rWidth  ) >> 16) )));
+            {
+                aCrop.SetLeft(lcl_ConvertCrop(pRecord->nCropFromLeft, rWidth));
+            }
             if( pRecord->nCropFromRight )
-                aCrop.SetRight( static_cast< sal_Int32 >(
-                (   ( (pRecord->nCropFromRight  >> 16   ) * rWidth  )
-                  + (((pRecord->nCropFromRight  & 0xffff) * rWidth  ) >> 16) )));
+            {
+                aCrop.SetRight(lcl_ConvertCrop(pRecord->nCropFromRight,rWidth));
+            }
 
             pGrfNd->SetAttr( aCrop );
         }
commit 76da556f3c058559e1bb2cc7e8aa15687f0703af
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri May 23 00:01:45 2014 +0200

    jvmfwk: generalize (and fix) the do_msvcr71_magic to Oracle JRE 7
    
    With just the Oracle JRE installed, it is not possible to load the
    "jvm.dll" directly, because the required MSVC runtime DLL is not
    found (unless some other software happens to install it system-wide),
    as described in http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7184978
    
    There was a hack "do_msvcr71_magic" to manually load the runtime that
    is bundled with Oracle JRE 6 and this generalizes that to work with the
    MSVCR100.DLL that is bundled with Oracle JRE 7 as well.
    
    An additional adaption of the virtual addresses in the file is done,
    and it's a mystery whether it even worked before without that.
    
    This issue was not user-visible before because LO releases 3.5 - 4.2
    bundle the MSVCR100.DLL themselves.
    
    Change-Id: If61565df80ff8a68472a76000ab5b10d6c78e11c
    (cherry picked from commit 831c8e02ca4640ddc7fb4966c0026f99b6e6296a)

diff --git a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx
index 266cdc6..ef91401 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx
+++ b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx
@@ -449,20 +449,20 @@ javaPluginError jfw_plugin_getJavaInfoByPath(
 // think it should be, do nothing, and just let the implicit loading
 // that happens when loading the JVM take care of it.
 
-static void load_msvcr71(LPCWSTR jvm_dll)
+static void load_msvcr(LPCWSTR jvm_dll, wchar_t const* msvcr)
 {
-    wchar_t msvcr71_dll[MAX_PATH];
+    wchar_t msvcr_dll[MAX_PATH];
     wchar_t *slash;
 
     if (wcslen(jvm_dll) > MAX_PATH - 15)
         return;
 
-    wcscpy(msvcr71_dll, jvm_dll);
+    wcscpy(msvcr_dll, jvm_dll);
 
     // First check if msvcr71.dll is in the same folder as jvm.dll. It
     // normally isn't, at least up to 1.6.0_22, but who knows if it
     // might be in the future.
-    slash = wcsrchr(msvcr71_dll, L'\\');
+    slash = wcsrchr(msvcr_dll, L'\\');
 
     if (!slash)
     {
@@ -470,27 +470,27 @@ static void load_msvcr71(LPCWSTR jvm_dll)
         return;
     }
 
-    wcscpy(slash+1, L"msvcr71.dll");
-    if (LoadLibraryW(msvcr71_dll))
+    wcscpy(slash+1, msvcr);
+    if (LoadLibraryW(msvcr_dll))
         return;
 
     // Then check if msvcr71.dll is in the parent folder of where
     // jvm.dll is. That is currently (1.6.0_22) as far as I know the
     // normal case.
     *slash = 0;
-    slash = wcsrchr(msvcr71_dll, L'\\');
+    slash = wcsrchr(msvcr_dll, L'\\');
 
     if (!slash)
         return;
 
-    wcscpy(slash+1, L"msvcr71.dll");
-    LoadLibraryW(msvcr71_dll);
+    wcscpy(slash+1, msvcr);
+    LoadLibraryW(msvcr_dll);
 }
 
 // Check if the jvm DLL imports msvcr71.dll, and in that case try
 // loading it explicitly. In case something goes wrong, do nothing,
 // and just let the implicit loading try to take care of it.
-static void do_msvcr71_magic(rtl_uString *jvm_dll)
+static void do_msvcr_magic(rtl_uString *jvm_dll)
 {
     rtl_uString* Module(0);
     struct stat st;
@@ -524,18 +524,51 @@ static void do_msvcr71_magic(rtl_uString *jvm_dll)
 
     IMAGE_NT_HEADERS *nt_hdr = (IMAGE_NT_HEADERS *) ((char *)dos_hdr + dos_hdr->e_lfanew);
 
+    DWORD importsVA = nt_hdr->OptionalHeader
+            .DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress;
+    // first determine Virtual-to-File-address mapping for the section
+    // that contains the import directory
+    IMAGE_SECTION_HEADER *sections = IMAGE_FIRST_SECTION(nt_hdr);
+    ptrdiff_t VAtoPhys = -1;
+    for (int i = 0; i < nt_hdr->FileHeader.NumberOfSections; ++i)
+    {
+        if (sections->VirtualAddress <= importsVA &&
+            importsVA < sections->VirtualAddress + sections->SizeOfRawData)
+        {
+            VAtoPhys = sections->PointerToRawData - sections->VirtualAddress;
+            break;
+        }
+        ++sections;
+    }
+    if (-1 == VAtoPhys) // not found?
+    {
+        free(dos_hdr);
+        return;
+    }
     IMAGE_IMPORT_DESCRIPTOR *imports =
-        (IMAGE_IMPORT_DESCRIPTOR *) ((char *) dos_hdr + nt_hdr->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress);
+        (IMAGE_IMPORT_DESCRIPTOR *) ((char *) dos_hdr + importsVA + VAtoPhys);
 
     while (imports <= (IMAGE_IMPORT_DESCRIPTOR *) ((char *) dos_hdr + st.st_size - sizeof (IMAGE_IMPORT_DESCRIPTOR)) &&
            imports->Name != 0 &&
-           imports->Name < (DWORD) st.st_size)
+           imports->Name + VAtoPhys < (DWORD) st.st_size)
     {
-        // Intentional use of sizeof("msvcr71.dll") here to include the terminating zero byte
-        if (strnicmp((char *) dos_hdr + imports->Name, "msvcr71.dll", sizeof("msvcr71.dll")) == 0)
+        static struct { char const * name; wchar_t const * wname; } msvcrts[] =
         {
-            load_msvcr71(reinterpret_cast<LPCWSTR>(Module->buffer));
-            break;
+            { "msvcr71.dll" , L"msvcr71.dll"  },
+            { "msvcr100.dll", L"msvcr100.dll" },
+        };
+        char const* importName = (char *) dos_hdr + imports->Name + VAtoPhys;
+        for (size_t i = 0; i < SAL_N_ELEMENTS(msvcrts); ++i)
+        {
+            if (0 == strnicmp(importName,
+                // Intentional strlen() + 1 here to include terminating zero
+                        msvcrts[i].name, strlen(msvcrts[i].name) + 1))
+            {
+                load_msvcr(reinterpret_cast<LPCWSTR>(Module->buffer),
+                        msvcrts[i].wname);
+                free(dos_hdr);
+                return;
+            }
         }
         imports++;
     }
@@ -584,7 +617,7 @@ javaPluginError jfw_plugin_startJavaVirtualMachine(
                                    SAL_LOADMODULE_GLOBAL | SAL_LOADMODULE_NOW)) == 0 )
 #else
 #if defined(WNT)
-    do_msvcr71_magic(sRuntimeLib.pData);
+    do_msvcr_magic(sRuntimeLib.pData);
 #endif
     if ((moduleRt = osl_loadModule(sRuntimeLib.pData, SAL_LOADMODULE_DEFAULT)) == 0)
 #endif
commit 55b197700b1ceb2e64b5f7c2bb227afbcad525b6
Author: Dinesh Patil <dinesh.patil at synerzip.com>
Date:   Wed May 21 19:32:54 2014 +0530

    fdo#79008 Crash: File getting crash while saving in LO
    
    File is getting crashed while saving in LO, as it tries
    to access the value of vector after erasing that value.
    Code changed to access the vector value first and
    then erase that value from vector.
    
    Change-Id: I29369b7582fdbd7363d0e6fdae091a30c79a747d
    Reviewed-on: https://gerrit.libreoffice.org/9433
    Tested-by: Michael Stahl <mstahl at redhat.com>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    (cherry picked from commit ed3fd76b65b2a281effea55b8a55101a8b740aec)

diff --git a/sw/qa/extras/ooxmlexport/data/fdo79008.docx b/sw/qa/extras/ooxmlexport/data/fdo79008.docx
new file mode 100644
index 0000000..2b17587
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fdo79008.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 608f11f..ff3e138 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -3115,6 +3115,16 @@ DECLARE_OOXMLEXPORT_TEST(testfdo76589 , "fdo76589.docx")
     assertXPath ( pXmlDoc, "/w:numbering/w:abstractNum[1]/w:lvl[1]/w:lvlText","val","%1" );
 }
 
+DECLARE_OOXMLEXPORT_TEST(testfdo79008, "fdo79008.docx")
+{
+    /* File getting crash while saving in LO.
+     * Checking if document.xml file is getting created after fix
+     */
+    xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+    if (!pXmlDoc)
+        return;
+}
+
 DECLARE_OOXMLEXPORT_TEST(testAuthorPropertySdt, "author-property.docx")
 {
     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx
index 0e0b141..858a721 100644
--- a/sw/source/filter/ww8/wrtw8esh.cxx
+++ b/sw/source/filter/ww8/wrtw8esh.cxx
@@ -1134,8 +1134,8 @@ void MSWord_SdrAttrIter::SetCharSet(const EECharAttrib& rAttr, bool bStart)
            std::find( aChrTxtAtrArr.begin(), aChrTxtAtrArr.end(), &rAttr );
         if ( it != aChrTxtAtrArr.end() )
         {
-            aChrTxtAtrArr.erase( it );
             aChrSetArr.erase( aChrSetArr.begin() + (it - aChrTxtAtrArr.begin()) );
+            aChrTxtAtrArr.erase( it );
         }
     }
 }
commit 309bd58c9721495fe9aeeb0a9be9726cf5f748f8
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu May 22 14:21:03 2014 +0200

    sw: why the heck is that #ifdef'd out?
    
    Change-Id: I213ad0f0ab853aec5cb523474218dfad2c44d11b
    (cherry picked from commit b01b171fbfdda4e40ef1fec696589f8981518b93)

diff --git a/sw/qa/core/macros-test.cxx b/sw/qa/core/macros-test.cxx
index f5565bc..faa97c5 100644
--- a/sw/qa/core/macros-test.cxx
+++ b/sw/qa/core/macros-test.cxx
@@ -56,9 +56,7 @@ class SwMacrosTest : public test::BootstrapFixture, public unotest::MacrosTest
 public:
     SwMacrosTest();
 
-#if !defined MACOSX && !defined WNT
     void createFileURL(const OUString& aFileBase, const OUString& aFileExtension, OUString& rFilePath);
-#endif
 
     virtual void setUp() SAL_OVERRIDE;
     virtual void tearDown() SAL_OVERRIDE;
@@ -86,7 +84,6 @@ private:
     OUString m_aBaseString;
 };
 
-#if !defined MACOSX && !defined WNT
 void SwMacrosTest::createFileURL(const OUString& aFileBase, const OUString& aFileExtension, OUString& rFilePath)
 {
     OUString aSep("/");
@@ -95,7 +92,6 @@ void SwMacrosTest::createFileURL(const OUString& aFileBase, const OUString& aFil
     aBuffer.append(aSep).append(aFileBase).append(aFileExtension);
     rFilePath = aBuffer.makeStringAndClear();
 }
-#endif
 
 #if 0
 
commit b54ea3af01ca6767dbcd289f7fd8715358f7fbe7
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu May 22 13:23:25 2014 +0200

    sw: use xsec_xmlsec.windows on WNT
    
    Change-Id: I9cb9bce9d30230d48daf2f1deccaf52014b79296
    (cherry picked from commit 3e69b7bcd3e4a9cb1a29360c905e7fba96365999)

diff --git a/sw/CppunitTest_sw_macros_test.mk b/sw/CppunitTest_sw_macros_test.mk
index 7b68eff..a33fe67 100644
--- a/sw/CppunitTest_sw_macros_test.mk
+++ b/sw/CppunitTest_sw_macros_test.mk
@@ -98,7 +98,7 @@ $(eval $(call gb_CppunitTest_use_components,sw_macros_test,\
 	unoxml/source/rdf/unordf \
 	unoxml/source/service/unoxml \
 	xmloff/util/xo \
-	xmlsecurity/util/xsec_xmlsec \
+	xmlsecurity/util/$(if $(filter WNT,$(OS)),xsec_xmlsec.windows,xsec_xmlsec) \
 ))
 
 $(eval $(call gb_CppunitTest_use_configuration,sw_macros_test))
commit 0aaae094c65660e3c9e7f02a71ae7e3845984532
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed May 21 22:26:05 2014 +0200

    fdo#68983: basic: if the library is not loaded fully, copy source storage
    
    Also fixes fdo#42899 and fdo#67685 in a different way; the previous fix
    for fdo#42899 caused the problem with password-protected libraries for
    which the password is not known: only the binary representation of the
    BAISC module was stored, not the source code; by simply copying from the
    source storage the problem can be avoided.
    
    It would be possible to ask for the password when storing, but that
    would not work when non-interactive (called via API).
    
    An alternative fix would be to pass in the
    SfxObjectShell::IsSetModifyEnabled() flag and actually reset the BASIC
    library's modify flag correctly, but that requires adding a
    parameter to XStorageBasedLibraryContainer::storeLibrariesToStorage().
    
    (regression from af34774d260a68fc02cd78ba90dd8d4afaf1a2a4 )
    
    Change-Id: I4701401f35171139fc2fe8d225d13d4e533091a0
    (cherry picked from commit 5246fa262450f686674850c53df666422f441c86)

diff --git a/basic/source/inc/namecont.hxx b/basic/source/inc/namecont.hxx
index 109835a..6355549 100644
--- a/basic/source/inc/namecont.hxx
+++ b/basic/source/inc/namecont.hxx
@@ -582,7 +582,9 @@ private:
     bool mbReadOnlyLink;
     bool mbPreload;
 
+protected:
     bool mbPasswordProtected;
+private:
     bool mbPasswordVerified;
     bool mbDoc50Password;
     OUString maPassword;
@@ -702,6 +704,8 @@ public:
     }
 
 protected:
+    virtual bool isLoadedStorable();
+
     virtual bool SAL_CALL isLibraryElementValid( ::com::sun::star::uno::Any aElement ) const = 0;
 };
 
diff --git a/basic/source/inc/scriptcont.hxx b/basic/source/inc/scriptcont.hxx
index ea09a91..0a331b9 100644
--- a/basic/source/inc/scriptcont.hxx
+++ b/basic/source/inc/scriptcont.hxx
@@ -154,6 +154,7 @@ class SfxScriptLibrary : public SfxLibrary, public SfxScriptLibrary_BASE
         const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler ) SAL_OVERRIDE;
     virtual void storeResourcesToStorage( const ::com::sun::star::uno::Reference
         < ::com::sun::star::embed::XStorage >& xStorage ) SAL_OVERRIDE;
+    virtual bool isLoadedStorable() SAL_OVERRIDE;
 
 public:
     SfxScriptLibrary
diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx
index c3329d1..52d3494f 100644
--- a/basic/source/uno/namecont.cxx
+++ b/basic/source/uno/namecont.cxx
@@ -1909,8 +1909,6 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
 
         if( pImplLib->implIsModified() || bComplete )
         {
-// For the moment don't copy storage (as an optimisation )
-// but instead always write to storage from memory.
 // Testing pImplLib->implIsModified() is not reliable,
 // IMHO the value of pImplLib->implIsModified() should
 // reflect whether the library ( in-memory ) model
@@ -1921,9 +1919,14 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
 // temp storage when saving ( and later sets the root storage of the
 // library container ) and similar madness in dbaccess means some surgery
 // is required to make it possible to successfully use this optimisation
-#if 0
+// It would be possible to do the implSetModified() call below only
+// conditionally, but that would require an additional boolean to be
+// passed in via the XStorageBasedDocument::storeLibrariesToStorage()...
+// fdo#68983: If there's a password and the password is not known, only
+// copying the storage works!
             // Can we simply copy the storage?
-            if( !mbOldInfoFormat && !pImplLib->implIsModified() && !mbOasis2OOoFormat && xSourceLibrariesStor.is() )
+            if (!mbOldInfoFormat && !pImplLib->isLoadedStorable() &&
+                !mbOasis2OOoFormat && xSourceLibrariesStor.is())
             {
                 try
                 {
@@ -1936,7 +1939,6 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
                 }
             }
             else
-#endif
             {
                 uno::Reference< embed::XStorage > xLibraryStor;
                 if( bStorage )
@@ -3037,6 +3039,11 @@ SfxLibrary::SfxLibrary( ModifiableHelper& _rModifiable, const Type& aType,
 {
 }
 
+bool SfxLibrary::isLoadedStorable()
+{
+    return mbLoaded && (!mbPasswordProtected || mbPasswordVerified);
+}
+
 void SfxLibrary::implSetModified( bool _bIsModified )
 {
     if ( mbIsModified == _bIsModified )
diff --git a/basic/source/uno/scriptcont.cxx b/basic/source/uno/scriptcont.cxx
index 574af68..1606bfc 100644
--- a/basic/source/uno/scriptcont.cxx
+++ b/basic/source/uno/scriptcont.cxx
@@ -1259,6 +1259,12 @@ SfxScriptLibrary::SfxScriptLibrary( ModifiableHelper& _rModifiable,
 {
 }
 
+bool SfxScriptLibrary::isLoadedStorable()
+{
+    // note: mbLoadedSource can only be true for password-protected lib!
+    return SfxLibrary::isLoadedStorable() && (!mbPasswordProtected || mbLoadedSource);
+}
+
 // Provide modify state including resources
 bool SfxScriptLibrary::isModified( void )
 {
diff --git a/sw/CppunitTest_sw_macros_test.mk b/sw/CppunitTest_sw_macros_test.mk
index 385e0c1..7b68eff 100644
--- a/sw/CppunitTest_sw_macros_test.mk
+++ b/sw/CppunitTest_sw_macros_test.mk
@@ -66,35 +66,39 @@ $(eval $(call gb_CppunitTest_use_api,sw_macros_test,\
 $(eval $(call gb_CppunitTest_use_ure,sw_macros_test))
 
 $(eval $(call gb_CppunitTest_use_components,sw_macros_test,\
-    basic/util/sb \
-    comphelper/util/comphelp \
-    configmgr/source/configmgr \
-    dbaccess/util/dba \
-    filter/source/config/cache/filterconfig1 \
-    forms/util/frm \
-    framework/util/fwk \
-    i18npool/util/i18npool \
-    oox/util/oox \
-    package/source/xstor/xstor \
-    package/util/package2 \
-    sax/source/expatwrap/expwrap \
-    sw/util/sw \
-    sw/util/swd \
-    sw/util/msword \
-    sw/util/vbaswobj \
-    scripting/source/basprov/basprov \
-    scripting/util/scriptframe \
-    sfx2/util/sfx \
-    sot/util/sot \
-    svl/source/fsstor/fsstorage \
-    svtools/util/svt \
-    toolkit/util/tk \
-    ucb/source/core/ucb1 \
-    ucb/source/ucp/file/ucpfile1 \
-    ucb/source/ucp/tdoc/ucptdoc1 \
-    unotools/util/utl \
-    unoxml/source/rdf/unordf \
-    unoxml/source/service/unoxml \
+	basic/util/sb \
+	embeddedobj/util/embobj \
+	comphelper/util/comphelp \
+	configmgr/source/configmgr \
+	dbaccess/util/dba \
+	filter/source/config/cache/filterconfig1 \
+	filter/source/storagefilterdetect/storagefd \
+	forms/util/frm \
+	framework/util/fwk \
+	i18npool/util/i18npool \
+	oox/util/oox \
+	package/source/xstor/xstor \
+	package/util/package2 \
+	sax/source/expatwrap/expwrap \
+	scripting/source/basprov/basprov \
+	scripting/util/scriptframe \
+	sfx2/util/sfx \
+	sot/util/sot \
+	svl/source/fsstor/fsstorage \
+	svtools/util/svt \
+	sw/util/msword \
+	sw/util/sw \
+	sw/util/swd \
+	sw/util/vbaswobj \
+	toolkit/util/tk \
+	ucb/source/core/ucb1 \
+	ucb/source/ucp/file/ucpfile1 \
+	ucb/source/ucp/tdoc/ucptdoc1 \
+	unotools/util/utl \
+	unoxml/source/rdf/unordf \
+	unoxml/source/service/unoxml \
+	xmloff/util/xo \
+	xmlsecurity/util/xsec_xmlsec \
 ))
 
 $(eval $(call gb_CppunitTest_use_configuration,sw_macros_test))
diff --git a/sw/qa/core/data/odt/fdo68983.odt b/sw/qa/core/data/odt/fdo68983.odt
new file mode 100644
index 0000000..01df104
Binary files /dev/null and b/sw/qa/core/data/odt/fdo68983.odt differ
diff --git a/sw/qa/core/macros-test.cxx b/sw/qa/core/macros-test.cxx
index d8ad141..f5565bc 100644
--- a/sw/qa/core/macros-test.cxx
+++ b/sw/qa/core/macros-test.cxx
@@ -20,7 +20,11 @@
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/frame/Desktop.hpp>
 #include <com/sun/star/frame/XComponentLoader.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
 #include <com/sun/star/document/MacroExecMode.hpp>
+#include <com/sun/star/document/XEmbeddedScripts.hpp>
+#include <com/sun/star/script/XLibraryContainer.hpp>
+#include <com/sun/star/script/XLibraryContainerPassword.hpp>
 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
 #include <com/sun/star/drawing/XShapes.hpp>
 #include <com/sun/star/drawing/XShape.hpp>
@@ -35,6 +39,7 @@
 #include <comphelper/processfactory.hxx>
 
 #include <basic/sbxdef.hxx>
+#include <unotools/tempfile.hxx>
 
 #include <doc.hxx>
 #include "docsh.hxx"
@@ -63,6 +68,7 @@ public:
     void testVba();
 #endif
     void testFdo55289();
+    void testFdo68983();
     CPPUNIT_TEST_SUITE(SwMacrosTest);
 #if !defined(MACOSX) && !defined(WNT)
     //enable this test if you want to play with star basic macros in unit tests
@@ -71,6 +77,7 @@ public:
     CPPUNIT_TEST(testVba);
 #endif
     CPPUNIT_TEST(testFdo55289);
+    CPPUNIT_TEST(testFdo68983);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -190,6 +197,47 @@ void SwMacrosTest::testFdo55289()
     xShapeContent->attach(xEnd);
 }
 
+void SwMacrosTest::testFdo68983()
+{
+    const OUString aFileNameBase("StarBasic.");
+    OUString aFileName;
+    createFileURL("fdo68983.", "odt", aFileName);
+    Reference< com::sun::star::lang::XComponent > xComponent =
+        loadFromDesktop(aFileName, "com.sun.star.text.TextDocument");
+
+    CPPUNIT_ASSERT_MESSAGE("Failed to load StarBasic.ods", xComponent.is());
+
+    Reference< frame::XStorable > xDocStorable(xComponent, UNO_QUERY_THROW);
+    CPPUNIT_ASSERT(xDocStorable.is());
+
+    utl::TempFile aTempFile;
+    aTempFile.EnableKillingFile();
+    Sequence<beans::PropertyValue> desc(1);
+    desc[0].Name = "FilterName";
+    desc[0].Value <<= OUString("writer8");
+    xDocStorable->storeAsURL(aTempFile.GetURL(), desc);
+
+    Reference<util::XCloseable>(xComponent, UNO_QUERY_THROW)->close(false);
+
+    // re-load
+    xComponent = loadFromDesktop(aTempFile.GetURL(), "com.sun.star.text.TextDocument");
+
+    // check that password-protected library survived store and re-load
+    Reference<document::XEmbeddedScripts> xDocScr(xComponent, UNO_QUERY_THROW);
+    Reference<script::XStorageBasedLibraryContainer> xStorBasLib(xDocScr->getBasicLibraries());
+    Reference<script::XLibraryContainer> xBasLib(xStorBasLib, UNO_QUERY_THROW);
+    Reference<script::XLibraryContainerPassword> xBasLibPwd(xStorBasLib, UNO_QUERY_THROW);
+    CPPUNIT_ASSERT(xBasLibPwd->isLibraryPasswordProtected("Library1"));
+    CPPUNIT_ASSERT(xBasLibPwd->verifyLibraryPassword("Library1", "foo"));
+    xBasLib->loadLibrary("Library1");
+    CPPUNIT_ASSERT(xBasLib->isLibraryLoaded("Library1"));
+
+    // close
+    Reference<util::XCloseable> xDocCloseable(xComponent, UNO_QUERY_THROW);
+    xDocCloseable->close(false);
+}
+
+
 SwMacrosTest::SwMacrosTest()
       : m_aBaseString("/sw/qa/core/data")
 {
commit 22cf5c7f745b9b7645bdfc881de229731417aad6
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed May 21 19:43:46 2014 +0200

    Revert "fdo#67685 open xSourceLibrariesStor only when needed"
    
    This reverts commit fc9080a0c60f263d00eb71111fcda72b3c0a2ebb.
    
    This bug was apparently introduced by
    af34774d260a68fc02cd78ba90dd8d4afaf1a2a4, which will be reverted
    in the next commit.
    
    Change-Id: I81ccb5bf9cc7e29fbf1e66d02f38268ee1fd1d0c
    (cherry picked from commit 5ca4b9d51046b9b6a36b91c9abd0cc1e7c04b480)

diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx
index bc5f796..c3329d1 100644
--- a/basic/source/uno/namecont.cxx
+++ b/basic/source/uno/namecont.cxx
@@ -1860,6 +1860,21 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
             DBG_UNHANDLED_EXCEPTION();
             return;
         }
+
+        // open the source storage which might be used to copy yet-unmodified libraries
+        try
+        {
+            if ( mxStorage->hasByName( maLibrariesDir ) || bInplaceStorage )
+            {
+                xSourceLibrariesStor = mxStorage->openStorageElement( maLibrariesDir,
+                                                   bInplaceStorage ? embed::ElementModes::READWRITE : embed::ElementModes::READ );
+            }
+        }
+        catch( const uno::Exception& )
+        {
+            DBG_UNHANDLED_EXCEPTION();
+            return;
+        }
     }
 
     int iArray = 0;
@@ -1988,21 +2003,6 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
     // then we need to clean up the temporary storage we used for this
     if ( bInplaceStorage && !sTempTargetStorName.isEmpty() )
     {
-        // open the source storage which might be used to copy yet-unmodified libraries
-        try
-        {
-            if ( mxStorage->hasByName( maLibrariesDir ) || bInplaceStorage )
-            {
-                xSourceLibrariesStor = mxStorage->openStorageElement( maLibrariesDir,
-                                                   bInplaceStorage ? embed::ElementModes::READWRITE : embed::ElementModes::READ );
-            }
-        }
-        catch( const uno::Exception& )
-        {
-            DBG_UNHANDLED_EXCEPTION();
-            return;
-        }
-
         SAL_WARN_IF(
             !xSourceLibrariesStor.is(), "basic",
             ("SfxLibrariesContainer::storeLibraries_impl: unexpected: we should"
commit 25ad7c5f94be3535fcf73c0f325e864c82a084cc
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue May 20 22:37:12 2014 +0200

    fdo#68983: Revert "remove #if 0 block (from ...
    
    ... af34774d260a68fc02cd78ba90dd8d4afaf1a2a4)"
    
    This reverts commit cbd1a89676f39135ed2e9c47d20475b2053289b9.
    
    Conflicts:
    	basic/source/uno/namecont.cxx
    
    Change-Id: I665f2e875c6b339ad718ca53fd0e54328efaeaff
    (cherry picked from commit 0e21019e0d61911b4c0ddef07691e9f9f6384cba)

diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx
index 8898781..bc5f796 100644
--- a/basic/source/uno/namecont.cxx
+++ b/basic/source/uno/namecont.cxx
@@ -1894,29 +1894,57 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
 
         if( pImplLib->implIsModified() || bComplete )
         {
-            {
-            uno::Reference< embed::XStorage > xLibraryStor;
-            if( bStorage )
+// For the moment don't copy storage (as an optimisation )
+// but instead always write to storage from memory.
+// Testing pImplLib->implIsModified() is not reliable,
+// IMHO the value of pImplLib->implIsModified() should
+// reflect whether the library ( in-memory ) model
+// is in sync with the library container's own storage. Currently
+// whenever the library model is written to *any* storage
+// pImplLib->implSetModified( sal_False ) is called
+// The way the code works, especially the way that sfx uses
+// temp storage when saving ( and later sets the root storage of the
+// library container ) and similar madness in dbaccess means some surgery
+// is required to make it possible to successfully use this optimisation
+#if 0
+            // Can we simply copy the storage?
+            if( !mbOldInfoFormat && !pImplLib->implIsModified() && !mbOasis2OOoFormat && xSourceLibrariesStor.is() )
             {
                 try
                 {
-                    xLibraryStor = xTargetLibrariesStor->openStorageElement(
-                                                                        rLib.aName,
-                                                                        embed::ElementModes::READWRITE );
+                    xSourceLibrariesStor->copyElementTo( rLib.aName, xTargetLibrariesStor, rLib.aName );
                 }
-                catch(const uno::Exception& )
+                catch( const uno::Exception& )
                 {
-                    #if OSL_DEBUG_LEVEL > 0
-                    Any aError( ::cppu::getCaughtException() );
-                    SAL_WARN(
-                        "basic",
-                        "couldn't create sub storage for library \""
-                            << rLib.aName << "\". Exception: "
-                            << comphelper::anyToString(aError));
-                    #endif
-                    throw;
+                    DBG_UNHANDLED_EXCEPTION();
+                    // TODO: error handling?
                 }
             }
+            else
+#endif
+            {
+                uno::Reference< embed::XStorage > xLibraryStor;
+                if( bStorage )
+                {
+                    try
+                    {
+                        xLibraryStor = xTargetLibrariesStor->openStorageElement(
+                                                                        rLib.aName,
+                                                                        embed::ElementModes::READWRITE );
+                    }
+                    catch(const uno::Exception& )
+                    {
+                        #if OSL_DEBUG_LEVEL > 0
+                        Any aError( ::cppu::getCaughtException() );
+                        SAL_WARN(
+                            "basic",
+                            "couldn't create sub storage for library \""
+                                << rLib.aName << "\". Exception: "
+                                << comphelper::anyToString(aError));
+                        #endif
+                        throw;
+                    }
+                }
 
                 // Maybe lib is not loaded?!
                 if( bComplete )


More information about the Libreoffice-commits mailing list