[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-4.2' - 26 commits - connectivity/source dbaccess/source external/openssl filter/Configuration_filter.mk framework/source include/sfx2 mysqlc/source sc/source sd/source sfx2/source svl/source svx/source sw/qa sw/source toolkit/source vcl/source vcl/win writerfilter/source

Caolán McNamara caolanm at redhat.com
Tue Jun 10 13:11:55 PDT 2014


 connectivity/source/drivers/firebird/Tables.cxx    |   18 ---
 connectivity/source/drivers/firebird/Tables.hxx    |    7 -
 dbaccess/source/ui/browser/brwctrlr.cxx            |   18 ++-
 external/openssl/CVE-2010-5298.patch               |   21 +++
 external/openssl/CVE-2013-4353.patch               |   21 +++
 external/openssl/CVE-2013-6449.patch               |  111 +++++++++++++++++++++
 external/openssl/CVE-2013-6450.patch               |   85 ++++++++++++++++
 external/openssl/CVE-2014-0195.patch               |   36 ++++++
 external/openssl/CVE-2014-0198.patch               |   33 ++++++
 external/openssl/CVE-2014-0221.patch               |   34 ++++++
 external/openssl/CVE-2014-0224.patch               |   88 ++++++++++++++++
 external/openssl/CVE-2014-3470.patch               |   26 ++++
 external/openssl/UnpackedTarball_openssl.mk        |    9 +
 filter/Configuration_filter.mk                     |   16 +--
 framework/source/uielement/toolbarmanager.cxx      |   16 ++-
 include/sfx2/app.hxx                               |    3 
 include/sfx2/templdlg.hxx                          |   19 ---
 mysqlc/source/mysqlc_connection.cxx                |    4 
 sc/source/core/inc/interpre.hxx                    |   48 +++++++++
 sc/source/core/tool/interpr1.cxx                   |   54 +++++-----
 sc/source/ui/condformat/condformatdlg.cxx          |   10 +
 sc/source/ui/inc/condformatdlg.hxx                 |    1 
 sc/source/ui/view/formatsh.cxx                     |   17 ++-
 sd/source/ui/func/fuinsert.cxx                     |    8 +
 sd/source/ui/view/drviews1.cxx                     |   14 ++
 sd/source/ui/view/drviews2.cxx                     |   18 +++
 sd/source/ui/view/drviews3.cxx                     |   29 ++++-
 sd/source/ui/view/drviews4.cxx                     |    6 +
 sd/source/ui/view/drviews7.cxx                     |   29 +++--
 sd/source/ui/view/drviewsb.cxx                     |    6 +
 sd/source/ui/view/drviewsf.cxx                     |   38 ++++---
 sd/source/ui/view/outlnvsh.cxx                     |    8 -
 sd/source/ui/view/viewshe3.cxx                     |   10 -
 sfx2/source/appl/appmisc.cxx                       |   11 --
 sfx2/source/dialog/templdlg.cxx                    |   41 +++----
 sfx2/source/inc/templdgi.hxx                       |   16 ---
 svl/source/numbers/zforfind.cxx                    |   11 --
 svx/source/svdraw/svdedtv.cxx                      |   23 ++++
 svx/source/svdraw/svdograf.cxx                     |    2 
 sw/qa/core/data/rtf/pass/fdo79384.rtf              |    6 +
 sw/qa/extras/ooxmlexport/data/fdo69649.docx        |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx           |   13 ++
 sw/qa/extras/ooxmlimport/data/fdo69649.docx        |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx           |   17 +++
 sw/qa/extras/rtfimport/data/fdo79384.rtf           |    9 +
 sw/qa/extras/rtfimport/rtfimport.cxx               |    8 +
 sw/source/core/unocore/unoframe.cxx                |    1 
 sw/source/ui/app/docst.cxx                         |   11 +-
 sw/source/ui/fmtui/tmpdlg.cxx                      |    7 +
 sw/source/ui/uno/SwXDocumentSettings.cxx           |    1 
 toolkit/source/awt/vclxwindows.cxx                 |    4 
 vcl/source/fontsubset/sft.cxx                      |   23 +++-
 vcl/source/window/toolbox2.cxx                     |    8 +
 vcl/win/source/gdi/salbmp.cxx                      |   38 ++++---
 writerfilter/source/dmapper/DomainMapper_Impl.cxx  |   87 +++++++++++++++-
 writerfilter/source/dmapper/DomainMapper_Impl.hxx  |    4 
 writerfilter/source/dmapper/ModelEventListener.cxx |   10 -
 writerfilter/source/rtftok/rtfdocumentimpl.cxx     |   60 +++++++++--
 writerfilter/source/rtftok/rtfdocumentimpl.hxx     |    4 
 59 files changed, 1040 insertions(+), 236 deletions(-)

New commits:
commit 6132f01bce5c9bc5b00c99c290b4cc9d72e39922
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu May 29 11:16:47 2014 +0100

    Resolves: fdo#79360 impress hangs on using sidebar new style
    
    because those styles are "pseudo-styles" and a new one cannot be
    added. The possibility is supposed to be disabled, and it is
    disabled in the floating stylelist. The old code assumes there
    can only be one of these stylelists and when a stylelist
    queries if the "new" should be disabled the callback asks
    the stylelist what family is selected, but only asks the floating one.
    
    So, floating closed, sidebar open, the new is not disabled.
    Implement the ancient TODO now that we have to. Instead of asking
    the stylelist what family is selected, query the frame for what
    is the current SID_STYLE_FAMILY as set by whatever is the active
    stylelist.
    
    What's disturbing is the SID_STYLE_FAMILY values are not SfxStyleFamily, but
    indexes that have to be mapped to SfxStyleFamily. I bet there are a pile of
    bugs around that, especially with little islands of different conversion
    codesites
    
    (cherry picked from commit 7a211e834fc271d3f28d7f8c49197c925242d862)
    
    Conflicts:
    	sfx2/source/appl/appmisc.cxx
    
    convert from NId to FamilyId instead of FamilyId to NId
    
    should be equivalent for comparison purposes
    
    (cherry picked from commit f48f5138ecedd3bb9ec0b454b9fe216001610156)
    
    remove unused virtual method, slim this down initially
    
    (cherry picked from commit fa551c422426962194b6bff4234f12eb5bdf57ca)
    
    (cherry picked from commit 3988f17d14ee28b4bb117ca9961708ad3a867fb1)
    
    Conflicts:
    	sd/source/ui/view/drviewsf.cxx
    	sfx2/source/appl/appmisc.cxx
    	sfx2/source/dialog/templdlg.cxx
    	sfx2/source/inc/templdgi.hxx
    	sw/source/core/uibase/app/docst.cxx
    
    Change-Id: I85c8032d7c26ae6eea245685748f89b2a860e767
    Reviewed-on: https://gerrit.libreoffice.org/9573
    Tested-by: David Tardon <dtardon at redhat.com>
    Reviewed-by: David Tardon <dtardon at redhat.com>

diff --git a/include/sfx2/app.hxx b/include/sfx2/app.hxx
index 6827ce6..ad48f2e 100644
--- a/include/sfx2/app.hxx
+++ b/include/sfx2/app.hxx
@@ -171,9 +171,6 @@ public:
     SfxTemplateDialog*          GetTemplateDialog();
     Window*                     GetTopWindow() const;
 
-    // TODO/CLEANUP: make currently selected family a view property and so we don't need to query the status from the "TemplateCommon"
-    ISfxTemplateCommon*         GetCurrentTemplateCommon( SfxBindings& );
-
     // members
     SfxFilterMatcher&           GetFilterMatcher();
     SfxProgress*                GetProgress() const;
diff --git a/include/sfx2/templdlg.hxx b/include/sfx2/templdlg.hxx
index 7373c23..ca494c6 100644
--- a/include/sfx2/templdlg.hxx
+++ b/include/sfx2/templdlg.hxx
@@ -30,20 +30,7 @@
 
 class SfxTemplateDialog_Impl;
 
-// class ISfxTemplateCommon ----------------------------------------------
-
-class ISfxTemplateCommon
-{
-public:
-    virtual SfxStyleFamily GetActualFamily() const = 0;
-    virtual OUString GetSelectedEntry() const = 0;
-
-protected:
-    ~ISfxTemplateCommon() {}
-};
-
 // class SfxTemplateDialog -----------------------------------------------
-
 class SfxTemplateDialog : public SfxDockingWindow
 {
 private:
@@ -63,8 +50,12 @@ public:
 
     virtual void                Update();
 
-    ISfxTemplateCommon*         GetISfxTemplateCommon();
     void                        SetParagraphFamily();
+
+    // converts from SFX_STYLE_FAMILY Ids to 1-5
+    static sal_uInt16 SFX2_DLLPUBLIC SfxFamilyIdToNId(SfxStyleFamily nFamily);
+    // converts from 1-5 to SFX_STYLE_FAMILY Ids
+    static SfxStyleFamily SFX2_DLLPUBLIC NIdToSfxFamilyId(sal_uInt16 nId);
 };
 
 // class SfxTemplateDialogWrapper ----------------------------------------
diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx
index 3ddb49a..e357a44 100644
--- a/sc/source/ui/view/formatsh.cxx
+++ b/sc/source/ui/view/formatsh.cxx
@@ -213,9 +213,12 @@ void ScFormatShell::GetStyleState( SfxItemSet& rSet )
 
             case SID_STYLE_UPDATE_BY_EXAMPLE:
             {
-                ISfxTemplateCommon* pDesigner = SFX_APP()->
-                        GetCurrentTemplateCommon(pTabViewShell->GetViewFrame()->GetBindings());
-                bool bPage = pDesigner && SFX_STYLE_FAMILY_PAGE == pDesigner->GetActualFamily();
+                SfxPoolItem* pItem = NULL;
+                pTabViewShell->GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pItem);
+                SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem);
+
+                bool bPage = pFamilyItem && SFX_STYLE_FAMILY_PAGE == SfxTemplateDialog::NIdToSfxFamilyId(pFamilyItem->GetValue());
+                delete pItem;
 
                 if ( bProtected || bPage )
                     rSet.DisableItem( nSlotId );
@@ -227,9 +230,11 @@ void ScFormatShell::GetStyleState( SfxItemSet& rSet )
             case SID_STYLE_HIDE:
             case SID_STYLE_SHOW:
             {
-                ISfxTemplateCommon* pDesigner = SFX_APP()->
-                        GetCurrentTemplateCommon(pTabViewShell->GetViewFrame()->GetBindings());
-                bool bPage = pDesigner && SFX_STYLE_FAMILY_PAGE == pDesigner->GetActualFamily();
+                SfxPoolItem* pItem = NULL;
+                pTabViewShell->GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pItem);
+                SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem);
+                bool bPage = pFamilyItem && SFX_STYLE_FAMILY_PAGE == SfxTemplateDialog::NIdToSfxFamilyId(pFamilyItem->GetValue());
+                delete pItem;
 
                 if ( bProtected && !bPage )
                     rSet.DisableItem( nSlotId );
diff --git a/sd/source/ui/view/drviewsf.cxx b/sd/source/ui/view/drviewsf.cxx
index 6ed5dbc..785f09d 100644
--- a/sd/source/ui/view/drviewsf.cxx
+++ b/sd/source/ui/view/drviewsf.cxx
@@ -485,30 +485,41 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet )
 
             case SID_STYLE_WATERCAN:
             {
-                ISfxTemplateCommon* pTemplateCommon = SFX_APP()->GetCurrentTemplateCommon(GetViewFrame()->GetBindings());
-                if (pTemplateCommon && pTemplateCommon->GetActualFamily() == SD_STYLE_FAMILY_PSEUDO)
+                SfxPoolItem* pItem = NULL;
+                GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pItem);
+                SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem);
+                if (pFamilyItem && SfxTemplateDialog::NIdToSfxFamilyId(pFamilyItem->GetValue()) == SD_STYLE_FAMILY_PSEUDO)
                     rSet.Put(SfxBoolItem(nWhich,sal_False));
                 else
                 {
                     SfxBoolItem aItem(nWhich, SD_MOD()->GetWaterCan());
                     aAllSet.Put( aItem, aItem.Which());
                 }
+                delete pItem;
             }
             break;
 
             case SID_STYLE_NEW:
             {
-                ISfxTemplateCommon* pTemplateCommon = SFX_APP()->GetCurrentTemplateCommon(GetViewFrame()->GetBindings());
-                if (pTemplateCommon && pTemplateCommon->GetActualFamily() == SD_STYLE_FAMILY_PSEUDO)
+                SfxPoolItem* pItem = NULL;
+                GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pItem);
+                SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem);
+                if (pFamilyItem && SfxTemplateDialog::NIdToSfxFamilyId(pFamilyItem->GetValue()) == SD_STYLE_FAMILY_PSEUDO)
+                {
                     rSet.DisableItem(nWhich);
+                }
+                delete pItem;
             }
             break;
 
             case SID_STYLE_DRAGHIERARCHIE:
             {
-                ISfxTemplateCommon* pTemplateCommon = SFX_APP()->GetCurrentTemplateCommon(GetViewFrame()->GetBindings());
-                if (pTemplateCommon && pTemplateCommon->GetActualFamily() == SD_STYLE_FAMILY_PSEUDO)
+                SfxPoolItem* pItem = NULL;
+                GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pItem);
+                SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem);
+                if (pFamilyItem && SfxTemplateDialog::NIdToSfxFamilyId(pFamilyItem->GetValue()) == SD_STYLE_FAMILY_PSEUDO)
                     rSet.DisableItem(nWhich);
+                delete pItem;
             }
             break;
 
@@ -516,14 +527,17 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet )
             {
                 // It is not possible to create PseudoStyleSheets 'by Example';
                 // normal style sheets need a selected object for that
-                ISfxTemplateCommon* pTemplCommon = SFX_APP()->GetCurrentTemplateCommon(GetViewFrame()->GetBindings());
-                if (pTemplCommon)
+
+                SfxPoolItem* pItem = NULL;
+                GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pItem);
+                SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem);
+                if (pFamilyItem)
                 {
-                    if (pTemplCommon->GetActualFamily() == SD_STYLE_FAMILY_PSEUDO)
+                    if (SfxTemplateDialog::NIdToSfxFamilyId(pFamilyItem->GetValue()) == SD_STYLE_FAMILY_PSEUDO)
                     {
                         rSet.DisableItem(nWhich);
                     }
-                    else if (pTemplCommon->GetActualFamily() == SD_STYLE_FAMILY_GRAPHICS)
+                    else if (SfxTemplateDialog::NIdToSfxFamilyId(pFamilyItem->GetValue()) == SD_STYLE_FAMILY_GRAPHICS)
                     {
                         if (!mpDrawView->AreObjectsMarked())
                         {
@@ -531,7 +545,7 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet )
                         }
                     }
                 }
-                // if there is no (yet) a designer, we have to go back into the
+                // if there is no (yet) a style designer, we have to go back into the
                 // view state; an actual set family can not be considered
                 else
                 {
@@ -540,7 +554,7 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet )
                         rSet.DisableItem(nWhich);
                     }
                 }
-
+                delete pItem;
             }
             break;
 
diff --git a/sd/source/ui/view/outlnvsh.cxx b/sd/source/ui/view/outlnvsh.cxx
index 94a5d04..92d293d 100644
--- a/sd/source/ui/view/outlnvsh.cxx
+++ b/sd/source/ui/view/outlnvsh.cxx
@@ -1571,9 +1571,10 @@ void OutlineViewShell::GetAttrState( SfxItemSet& rSet )
 
             case SID_STYLE_EDIT:
             {
-                ISfxTemplateCommon* pTmplCommon = SFX_APP()->GetCurrentTemplateCommon(GetViewFrame()->GetBindings());
-
-                if (pTmplCommon && pTmplCommon->GetActualFamily() == SD_STYLE_FAMILY_PSEUDO)
+                SfxPoolItem* pItem = NULL;
+                GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pItem);
+                SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem);
+                if (pFamilyItem && SfxTemplateDialog::NIdToSfxFamilyId(pFamilyItem->GetValue()) == SD_STYLE_FAMILY_PSEUDO)
                 {
                     SfxItemSet aSet(*rSet.GetPool(), SID_STATUS_LAYOUT, SID_STATUS_LAYOUT);
                     GetStatusBarState(aSet);
@@ -1584,6 +1585,7 @@ void OutlineViewShell::GetAttrState( SfxItemSet& rSet )
                         rSet.DisableItem(nWhich);
                     }
                 }
+                delete pItem;
             }
             break;
 
diff --git a/sd/source/ui/view/viewshe3.cxx b/sd/source/ui/view/viewshe3.cxx
index 3c2b5d0..8e967d4 100644
--- a/sd/source/ui/view/viewshe3.cxx
+++ b/sd/source/ui/view/viewshe3.cxx
@@ -72,6 +72,7 @@
 
 #include <svx/svxids.hrc>
 #include <sfx2/request.hxx>
+#include <sfx2/templdlg.hxx>
 #include <svl/aeitem.hxx>
 #include <basic/sbstar.hxx>
 
@@ -102,17 +103,12 @@ void  ViewShell::GetMenuState( SfxItemSet &rSet )
                 if( pStyleSheet )
                 {
                     SfxStyleFamily eFamily = pStyleSheet->GetFamily();
-                    if(eFamily == SD_STYLE_FAMILY_GRAPHICS)
-                        nFamily = 2;
-                    else if(eFamily == SD_STYLE_FAMILY_CELL )
-                        nFamily = 3;
-                    else // SD_STYLE_FAMILY_PSEUDO
-                        nFamily = 5;
-
+                    nFamily = SfxTemplateDialog::SfxFamilyIdToNId(eFamily);
                     GetDocSh()->SetStyleFamily(nFamily);
                 }
             }
         }
+
         rSet.Put(SfxUInt16Item(SID_STYLE_FAMILY, nFamily ));
     }
 
diff --git a/sfx2/source/appl/appmisc.cxx b/sfx2/source/appl/appmisc.cxx
index 8b8c88c..63b9259 100644
--- a/sfx2/source/appl/appmisc.cxx
+++ b/sfx2/source/appl/appmisc.cxx
@@ -141,17 +141,6 @@ SfxModule* SfxApplication::GetModule_Impl()
     }
 }
 
-ISfxTemplateCommon* SfxApplication::GetCurrentTemplateCommon( SfxBindings& rBindings )
-{
-    if( pAppData_Impl->pTemplateCommon )
-        return pAppData_Impl->pTemplateCommon;
-    SfxChildWindow *pChild = rBindings.GetWorkWindow_Impl()->GetChildWindow_Impl(
-        SfxTemplateDialogWrapper::GetChildWindowId() );
-    if ( pChild )
-        return ((SfxTemplateDialog*) pChild->GetWindow())->GetISfxTemplateCommon();
-    return 0;
-}
-
 sal_Bool  SfxApplication::IsDowning() const { return pAppData_Impl->bDowning; }
 SfxDispatcher* SfxApplication::GetAppDispatcher_Impl() { return pAppData_Impl->pAppDispat; }
 SfxSlotPool& SfxApplication::GetAppSlotPool_Impl() const { return *pAppData_Impl->pSlotPool; }
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index 11b430c..d11a267 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -149,18 +149,11 @@ SfxTemplateDialog::SfxTemplateDialog
     pImpl->updateNonFamilyImages();
 }
 
-//-------------------------------------------------------------------------
-
 SfxTemplateDialog::~SfxTemplateDialog()
 {
     delete pImpl;
 }
 
-ISfxTemplateCommon* SfxTemplateDialog::GetISfxTemplateCommon()
-{
-    return pImpl->GetISfxTemplateCommon();
-}
-
 void SfxTemplateDialog::SetParagraphFamily()
 {
     // first select the paragraph family
@@ -169,8 +162,6 @@ void SfxTemplateDialog::SetParagraphFamily()
     pImpl->SetAutomaticFilter();
 }
 
-// ------------------------------------------------------------------------
-
 void SfxTemplateDialog::DataChanged( const DataChangedEvent& _rDCEvt )
 {
     if ( ( DATACHANGED_SETTINGS == _rDCEvt.GetType() ) &&
@@ -252,8 +243,8 @@ sal_Int8 DropListBox_Impl::AcceptDrop( const AcceptDropEvent& rEvt )
     {
         // special case: page styles are allowed to create new styles by example
         // but not allowed to be created by drag and drop
-        if( pDialog->nActFamily == SfxCommonTemplateDialog_Impl::SfxFamilyIdToNId( SFX_STYLE_FAMILY_PAGE ) ||
-                pDialog->bNewByExampleDisabled )
+        if (pDialog->GetActualFamily() == SFX_STYLE_FAMILY_PAGE ||
+                pDialog->bNewByExampleDisabled)
             return DND_ACTION_NONE;
         else
             return DND_ACTION_COPY;
@@ -834,7 +825,6 @@ SvTreeListEntry* FillBox_Impl(SvTreeListBox *pBox,
 
 SfxCommonTemplateDialog_Impl::SfxCommonTemplateDialog_Impl( SfxBindings* pB, Window* pW, bool ) :
     mbIgnoreSelect( false ),
-    aISfxTemplateCommon     ( this ),
     pBindings               ( pB ),
     pWindow                 ( pW ),
     pModule                 ( NULL ),
@@ -885,7 +875,7 @@ SfxCommonTemplateDialog_Impl::SfxCommonTemplateDialog_Impl( SfxBindings* pB, Win
 sal_uInt16 SfxCommonTemplateDialog_Impl::StyleNrToInfoOffset(sal_uInt16 nId)
 {
     const SfxStyleFamilyItem *pItem = pStyleFamilies->at( nId );
-    return SfxFamilyIdToNId(pItem->GetFamily())-1;
+    return SfxTemplateDialog::SfxFamilyIdToNId(pItem->GetFamily())-1;
 }
 
 //-------------------------------------------------------------------------
@@ -982,7 +972,7 @@ void SfxCommonTemplateDialog_Impl::ReadResource()
     for( ; nCount--; )
     {
         const SfxStyleFamilyItem *pItem = pStyleFamilies->at( nCount );
-        sal_uInt16 nId = SfxFamilyIdToNId( pItem->GetFamily() );
+        sal_uInt16 nId = SfxTemplateDialog::SfxFamilyIdToNId( pItem->GetFamily() );
         InsertFamilyItem( nId, pItem );
     }
 
@@ -1075,9 +1065,7 @@ SfxCommonTemplateDialog_Impl::~SfxCommonTemplateDialog_Impl()
         m_pDeletionWatcher->signal();
 }
 
-//-------------------------------------------------------------------------
-
-sal_uInt16 SfxCommonTemplateDialog_Impl::SfxFamilyIdToNId( SfxStyleFamily nFamily )
+sal_uInt16 SfxTemplateDialog::SfxFamilyIdToNId(SfxStyleFamily nFamily)
 {
     switch ( nFamily )
     {
@@ -1090,6 +1078,19 @@ sal_uInt16 SfxCommonTemplateDialog_Impl::SfxFamilyIdToNId( SfxStyleFamily nFamil
     }
 }
 
+SfxStyleFamily SfxTemplateDialog::NIdToSfxFamilyId(sal_uInt16 nId)
+{
+    switch (nId)
+    {
+        case 1: return SFX_STYLE_FAMILY_CHAR;
+        case 2: return SFX_STYLE_FAMILY_PARA;
+        case 3: return SFX_STYLE_FAMILY_FRAME;
+        case 4: return SFX_STYLE_FAMILY_PAGE;
+        case 5: return SFX_STYLE_FAMILY_PSEUDO;
+        default: return SFX_STYLE_FAMILY_ALL;
+    }
+}
+
 void SfxCommonTemplateDialog_Impl::SetAutomaticFilter()
 {
     sal_uInt16 nCount = aFilterLb.GetEntryCount();
@@ -1115,7 +1116,7 @@ const SfxStyleFamilyItem *SfxCommonTemplateDialog_Impl::GetFamilyItem_Impl() con
     for(size_t i = 0; i < nCount; ++i)
     {
         const SfxStyleFamilyItem *pItem = pStyleFamilies->at( i );
-        sal_uInt16 nId = SfxFamilyIdToNId(pItem->GetFamily());
+        sal_uInt16 nId = SfxTemplateDialog::SfxFamilyIdToNId(pItem->GetFamily());
         if(nId == nActFamily)
             return pItem;
     }
@@ -2544,7 +2545,7 @@ void SfxTemplateDialog_Impl::updateFamilyImages()
     for( ; nLoop--; )
     {
         const SfxStyleFamilyItem *pItem = pStyleFamilies->at( nLoop );
-        sal_uInt16 nId = SfxFamilyIdToNId( pItem->GetFamily() );
+        sal_uInt16 nId = SfxTemplateDialog::SfxFamilyIdToNId( pItem->GetFamily() );
         m_aActionTbL.SetItemImage( nId, pItem->GetImage() );
     }
 }
@@ -2942,7 +2943,7 @@ sal_Int8    DropToolBox_Impl::AcceptDrop( const AcceptDropEvent& rEvt )
     }
     // special case: page styles are allowed to create new styles by example
     // but not allowed to be created by drag and drop
-    if ( nItemId != SfxCommonTemplateDialog_Impl::SfxFamilyIdToNId( SFX_STYLE_FAMILY_PAGE )&&
+    if ( nItemId != SfxTemplateDialog::SfxFamilyIdToNId( SFX_STYLE_FAMILY_PAGE )&&
         IsDropFormatSupported( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ) &&
         !rParent.bNewByExampleDisabled )
     {
diff --git a/sfx2/source/inc/templdgi.hxx b/sfx2/source/inc/templdgi.hxx
index 844acdb..e51cb94 100644
--- a/sfx2/source/inc/templdgi.hxx
+++ b/sfx2/source/inc/templdgi.hxx
@@ -95,18 +95,6 @@ private:
     class DeletionWatcher;
     friend class DeletionWatcher;
     bool mbIgnoreSelect;
-    class ISfxTemplateCommon_Impl : public ISfxTemplateCommon
-    {
-    private:
-        SfxCommonTemplateDialog_Impl* pDialog;
-    public:
-        ISfxTemplateCommon_Impl( SfxCommonTemplateDialog_Impl* pDialogP ) : pDialog( pDialogP ) {}
-        virtual ~ISfxTemplateCommon_Impl() {}
-        virtual SfxStyleFamily GetActualFamily() const { return pDialog->GetActualFamily(); }
-        virtual OUString GetSelectedEntry() const { return pDialog->GetSelectedEntry(); }
-    };
-
-    ISfxTemplateCommon_Impl     aISfxTemplateCommon;
 
     void    ReadResource();
     void    ClearResource();
@@ -242,7 +230,6 @@ public:
     virtual void        EnableHide( sal_Bool b = sal_True )  { bCanHide = b; }
     virtual void        EnableShow( sal_Bool b = sal_True )  { bCanShow = b; }
 
-    ISfxTemplateCommon* GetISfxTemplateCommon() { return &aISfxTemplateCommon; }
     Window*             GetWindow() { return pWindow; }
 
     void                EnableTreeDrag( sal_Bool b = sal_True );
@@ -263,9 +250,6 @@ public:
     // normaly for derivates from SvTreeListBoxes, but in this case the dialog handles context menus
     virtual PopupMenu*  CreateContextMenu( void );
 
-    // converts from SFX_STYLE_FAMILY Ids to 1-5
-    static sal_uInt16       SfxFamilyIdToNId( SfxStyleFamily nFamily );
-
     void                SetAutomaticFilter();
 };
 
diff --git a/sw/source/ui/app/docst.cxx b/sw/source/ui/app/docst.cxx
index ff0a01f..4c05499 100644
--- a/sw/source/ui/app/docst.cxx
+++ b/sw/source/ui/app/docst.cxx
@@ -99,9 +99,14 @@ void  SwDocShell::StateStyleSheet(SfxItemSet& rSet, SwWrtShell* pSh)
     else
     {
         SfxViewFrame* pFrame = pShell->GetView().GetViewFrame();
-        const ISfxTemplateCommon* pCommon = SFX_APP()->GetCurrentTemplateCommon(pFrame->GetBindings());
-        if( pCommon )
-            nActualFamily = static_cast< sal_uInt16 >(pCommon->GetActualFamily());
+        SfxPoolItem* pItem = NULL;
+        pFrame->GetBindings().QueryState(SID_STYLE_FAMILY, pItem);
+        SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem);
+        if (pFamilyItem)
+        {
+            nActualFamily = static_cast<sal_uInt16>(SfxTemplateDialog::NIdToSfxFamilyId(pFamilyItem->GetValue()));
+        }
+        delete pItem;
     }
 
     while (nWhich)
commit f7bb919ab014eb29fe77e287abf6eaf6c85750ce
Author: Armin Le Grand <alg at apache.org>
Date:   Mon Feb 17 15:48:54 2014 +0000

    Resolves: fdo#78404 #i123468# Added SdrEndTextEdit before replacing...
    
    EmptyPresObj, also secured ReplaceObjectAtView to check for active TextEdit,
    assert this and make an emergency correction
    
    (cherry picked from commit 623cd778689bd0851652b2db00b24c308dfb657a)
    
    Conflicts:
    	svx/source/svdraw/svdedtv.cxx
    
    (cherry picked from commit 3b729ab35b5064dcd21f125dfd0aa7d7e709fd9f)
    
    Change-Id: I0e9ae1b1cd84e04c37c4de38aca7752804782384
    Reviewed-on: https://gerrit.libreoffice.org/9482
    Tested-by: David Tardon <dtardon at redhat.com>
    Reviewed-by: David Tardon <dtardon at redhat.com>

diff --git a/sd/source/ui/func/fuinsert.cxx b/sd/source/ui/func/fuinsert.cxx
index 15eb9f1..1606c33 100644
--- a/sd/source/ui/func/fuinsert.cxx
+++ b/sd/source/ui/func/fuinsert.cxx
@@ -348,6 +348,14 @@ void FuInsertOLE::DoExecute( SfxRequest& rReq )
                     pPage->InsertPresObj( pOleObj, ePresObjKind );
                     pOleObj->SetUserCall(pPickObj->GetUserCall());
                 }
+
+                // #i123468# we need to end text edit before replacing the object. There cannot yet
+                // being text typed (else it would not be an EmptyPresObj anymore), but it may be
+                // in text edit mode
+                if (mpView->IsTextEdit())
+                {
+                    mpView->SdrEndTextEdit();
+                }
             }
 
             bool bRet = true;
diff --git a/svx/source/svdraw/svdedtv.cxx b/svx/source/svdraw/svdedtv.cxx
index a872d42..602bf19 100644
--- a/svx/source/svdraw/svdedtv.cxx
+++ b/svx/source/svdraw/svdedtv.cxx
@@ -33,6 +33,7 @@
 #include "svx/svdglob.hxx"
 #include <svx/e3dsceneupdater.hxx>
 #include <rtl/strbuf.hxx>
+#include <svx/svdview.hxx>
 
 // #i13033#
 #include <clonelist.hxx>
@@ -987,6 +988,28 @@ sal_Bool SdrEditView::InsertObjectAtView(SdrObject* pObj, SdrPageView& rPV, sal_
 
 void SdrEditView::ReplaceObjectAtView(SdrObject* pOldObj, SdrPageView& rPV, SdrObject* pNewObj, sal_Bool bMark)
 {
+    if(IsTextEdit())
+    {
+#ifdef DBG_UTIL
+        if(pOldObj && dynamic_cast< SdrTextObj* >(pOldObj) && static_cast< SdrTextObj* >(pOldObj)->IsTextEditActive())
+        {
+            OSL_ENSURE(false, "OldObject is in TextEdit mode, this has to be ended before replacing it usnig SdrEndTextEdit (!)");
+        }
+
+        if(pNewObj && dynamic_cast< SdrTextObj* >(pNewObj) && static_cast< SdrTextObj* >(pNewObj)->IsTextEditActive())
+        {
+            OSL_ENSURE(false, "NewObject is in TextEdit mode, this has to be ended before replacing it usnig SdrEndTextEdit (!)");
+        }
+#endif
+
+        // #i123468# emergency repair situation, needs to cast up to a class derived from
+        // this one; (aw080 has a mechanism for that and the view hierarchy is secured to
+        // always be a SdrView)
+        SdrView *pSdrView = dynamic_cast<SdrView*>(this);
+        if (pSdrView)
+            pSdrView->SdrEndTextEdit();
+    }
+
     SdrObjList* pOL=pOldObj->GetObjList();
     const bool bUndo = IsUndoEnabled();
     if( bUndo  )
commit 6765956f6e67b1c835719ac043b88641b55ea725
Author: David Tardon <dtardon at redhat.com>
Date:   Mon Jun 9 11:53:00 2014 +0200

    rhbz#1105376 move FlatODF filter config to right place
    
    This has been broken since 3.3(!), when the old XSLT based import/export
    was replaced by a library.
    
    Change-Id: Id335f296c5a0e2c15d1748f8a14ac8d4001e1d15
    (cherry picked from commit 6e299a555dc03982f6e03434f2726ca440fcee53)
    Reviewed-on: https://gerrit.libreoffice.org/9691
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/filter/Configuration_filter.mk b/filter/Configuration_filter.mk
index 847db50..fe84350 100644
--- a/filter/Configuration_filter.mk
+++ b/filter/Configuration_filter.mk
@@ -318,6 +318,7 @@ $(call filter_Configuration_add_types,fcfg_langpack,fcfg_writer_types.xcu,filter
 	writer_MS_Word_95_Vorlage \
 	writer_MS_Word_97 \
 	writer_MS_Word_97_Vorlage \
+	writer_ODT_FlatXML \
 	writer_Rich_Text_Format \
 	writer_StarOffice_XML_Writer \
 	writer_WordPerfect_Document \
@@ -378,6 +379,7 @@ $(call filter_Configuration_add_filters,fcfg_langpack,fcfg_writer_filters.xcu,fi
 	MS_Word_95_Vorlage \
 	MS_Word_97 \
 	MS_Word_97_Vorlage \
+	ODT_FlatXML \
 	Rich_Text_Format \
 	StarOffice_XML__Writer_ \
 	WordPerfect \
@@ -511,6 +513,7 @@ $(call filter_Configuration_add_ui_filters,fcfg_langpack,filter/source/config/fr
 # fcfg_calc
 $(call filter_Configuration_add_types,fcfg_langpack,fcfg_calc_types.xcu,filter/source/config/fragments/types,\
 	calc_DIF \
+	calc_ODS_FlatXML \
 	generic_HTML \
 	generic_Text \
 	calc_Lotus \
@@ -542,6 +545,7 @@ $(call filter_Configuration_add_types,fcfg_langpack,fcfg_calc_types.xcu,filter/s
 $(call filter_Configuration_add_filters,fcfg_langpack,fcfg_calc_filters.xcu,filter/source/config/fragments/filters,\
 	DIF \
 	HTML__StarCalc_ \
+	ODS_FlatXML \
 	Lotus \
 	QPro \
 	MS_Excel_4_0 \
@@ -592,6 +596,7 @@ $(call filter_Configuration_add_ui_filters,fcfg_langpack,filter/source/config/fr
 
 # fcfg_draw
 $(call filter_Configuration_add_types,fcfg_langpack,fcfg_draw_types.xcu,filter/source/config/fragments/types,\
+	draw_ODG_FlatXML \
 	draw_StarOffice_XML_Draw \
 	draw_StarOffice_XML_Draw_Template \
 	pdf_Portable_Document_Format \
@@ -606,6 +611,7 @@ $(call filter_Configuration_add_types,fcfg_langpack,fcfg_draw_types.xcu,filter/s
 )
 
 $(call filter_Configuration_add_filters,fcfg_langpack,fcfg_draw_filters.xcu,filter/source/config/fragments/filters,\
+	ODG_FlatXML \
 	StarOffice_XML__Draw_ \
 	draw_StarOffice_XML_Draw_Template \
 	draw_pdf_Export \
@@ -633,6 +639,7 @@ $(call filter_Configuration_add_types,fcfg_langpack,fcfg_impress_types.xcu,filte
 	impress_MS_PowerPoint_97 \
 	impress_MS_PowerPoint_97_AutoPlay \
 	impress_MS_PowerPoint_97_Vorlage \
+	impress_ODP_FlatXML \
 	impress_StarOffice_XML_Impress \
 	impress_StarOffice_XML_Impress_Template \
 	pdf_Portable_Document_Format \
@@ -654,6 +661,7 @@ $(call filter_Configuration_add_filters,fcfg_langpack,fcfg_impress_filters.xcu,f
 	MS_PowerPoint_97_AutoPlay \
 	MS_PowerPoint_97_Vorlage \
 	impress_StarOffice_XML_Draw \
+	ODP_FlatXML \
 	StarOffice_XML__Impress_ \
 	impress_StarOffice_XML_Impress_Template \
 	impress_pdf_Export \
@@ -953,11 +961,7 @@ $(call filter_Configuration_add_internal_filters,fcfg_langpack,fcfg_internalgrap
 
 # fcfg_xslt
 $(call filter_Configuration_add_types,fcfg_langpack,fcfg_xslt_types.xcu,filter/source/config/fragments/types,\
-	calc_ODS_FlatXML \
-	draw_ODG_FlatXML \
-	impress_ODP_FlatXML \
 	writer_DocBook_File \
-	writer_ODT_FlatXML \
 	XHTML_File \
 	Unified_Office_Format_text \
 	Unified_Office_Format_spreadsheet \
@@ -966,10 +970,6 @@ $(call filter_Configuration_add_types,fcfg_langpack,fcfg_xslt_types.xcu,filter/s
 
 $(call filter_Configuration_add_filters,fcfg_langpack,fcfg_xslt_filters.xcu,filter/source/config/fragments/filters,\
 	DocBook_File \
-	ODG_FlatXML \
-	ODP_FlatXML \
-	ODS_FlatXML \
-	ODT_FlatXML \
 	XHTML_Calc_File \
 	XHTML_Draw_File \
 	XHTML_Impress_File \
commit 4f026ec48dc6ccf8630af1cdffb633fe9892258d
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Jun 5 16:41:02 2014 +0100

    Resolves: fdo#79021 cannot delete ListBox from inside its own Select handler
    
    Change-Id: I884e617b112397697a702216b62d0c1e17aae536
    (cherry picked from commit b0a9f33a9b3018dcfb471641bde7c29a6e62f394)
    (cherry picked from commit 268c4907a04959ca546c5e2ecf469d4d297293b9)
    Reviewed-on: https://gerrit.libreoffice.org/9656
    Tested-by: David Tardon <dtardon at redhat.com>
    Reviewed-by: David Tardon <dtardon at redhat.com>

diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index 907c1b6..2f5e6f8 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -235,6 +235,16 @@ IMPL_LINK(ScCondFormatList, ColFormatTypeHdl, ListBox*, pBox)
 
 IMPL_LINK(ScCondFormatList, TypeListHdl, ListBox*, pBox)
 {
+    //Resolves: fdo#79021 At this point we are still inside the ListBox Select.
+    //If we call maEntries.replace here then the pBox will be deleted before it
+    //has finished Select and will crash on accessing its deleted this. So Post
+    //to do the real work after the Select has completed
+    Application::PostUserEvent(LINK(this, ScCondFormatList, AfterTypeListHdl), pBox);
+    return 0;
+}
+
+IMPL_LINK(ScCondFormatList, AfterTypeListHdl, ListBox*, pBox)
+{
     EntryContainer::iterator itr = maEntries.begin();
     for(; itr != maEntries.end(); ++itr)
     {
diff --git a/sc/source/ui/inc/condformatdlg.hxx b/sc/source/ui/inc/condformatdlg.hxx
index 6baf33d..721397a 100644
--- a/sc/source/ui/inc/condformatdlg.hxx
+++ b/sc/source/ui/inc/condformatdlg.hxx
@@ -79,6 +79,7 @@ public:
     DECL_LINK( EntrySelectHdl, ScCondFrmtEntry* );
 
     DECL_LINK( TypeListHdl, ListBox*);
+    DECL_LINK( AfterTypeListHdl, ListBox*);
     DECL_LINK( ColFormatTypeHdl, ListBox*);
 };
 
commit 02b40ee517830a6bcde795e1fe0eb880b3e7cc65
Author: Eike Rathke <erack at redhat.com>
Date:   Fri Jun 6 13:31:03 2014 +0200

    resolved fdo#79719 recognize ##-MMM-## as date even if ambiguous
    
    Force ##-MMM-## to be ##-MMM-#### if the first number is a day value.
    
    Note that the previous implementation of
    (bDay1 && bDay2 && ((bYear1 && !bYear2) || (!bYear1 && bYear2)))
    never matched anyway as the detection of bDay1 and bDay2 were changed to
    only yield true if bYear1==false or bYear2==false.
    
    Change-Id: If6bb6d3e1757015552eaa81c1f58d53c0794846e
    (cherry picked from commit a6992cd0d7c085ba05877e6f68ac0650dd09010f)
    Reviewed-on: https://gerrit.libreoffice.org/9665
    Tested-by: David Tardon <dtardon at redhat.com>
    Reviewed-by: David Tardon <dtardon at redhat.com>

diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx
index 9c8bb1c..2302540 100644
--- a/svl/source/numbers/zforfind.cxx
+++ b/svl/source/numbers/zforfind.cxx
@@ -1152,14 +1152,9 @@ bool ImpSvNumberInputScan::MayBeMonthDate()
                 }
                 else if (bDay1 && bDay2)
                 {
-                    if (bYear1 && !bYear2)
-                    {
-                        nMayBeMonthDate = 3;    // yy-month-dd
-                    }
-                    else if (!bYear1 && bYear2)
-                    {
-                        nMayBeMonthDate = 2;    // dd-month-yy
-                    }
+                    // Ambiguous ##-MMM-## date, but some big vendor's database
+                    // reports write this crap, assume this always to be
+                    nMayBeMonthDate = 2;        // dd-month-yy
                 }
             }
         }
commit cac38ba47f6ac541dded4f985e2b6dded2841705
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Jun 5 16:34:08 2014 +0200

    unify the handling of string position arguments, fdo#75971 related
    
    Only two text functions had the full set of checks as introduced by the
    fix for fdo#75971. Let all text functions check their arguments in the
    same way. Additionally this will ease a transition to accept string
    lengths >64k in spreadsheet functions as now we have only one place that
    checks for SAL_MAX_UINT16 instead of having that scattered all over the
    place.
    
    (cherry picked from commit 14ce27cc045bd9bcbbfa3eac56cd99f2be08de1f)
    
    Conflicts:
    	sc/source/core/tool/interpr1.cxx
    
    Change-Id: I454e617a59d0b3c2ca725047e7f8c7370bc0bb1f
    Reviewed-on: https://gerrit.libreoffice.org/9657
    Tested-by: David Tardon <dtardon at redhat.com>
    Reviewed-by: David Tardon <dtardon at redhat.com>

diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index cc67580..aa2dd73 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -365,6 +365,24 @@ void ScErrCell();                                       // special handling for
 void SetMaxIterationCount(sal_uInt16 n);
 inline void CurFmtToFuncFmt()
     { nFuncFmtType = nCurFmtType; nFuncFmtIndex = nCurFmtIndex; }
+
+/** Check if a double is suitable as string position or length argument.
+
+    If fVal is Inf or NaN it is changed to -1, if it is less than 0 it is
+    sanitized to 0, if it is greater than some implementation defined max
+    string length it is sanitized to that max.
+
+    @return TRUE if double value fVal is suitable as string argument and was
+            not sanitized.
+            FALSE if not and fVal was adapted.
+ */
+inline bool CheckStringPositionArgument( double & fVal );
+
+/** Obtain a double suitable as string position or length argument.
+    Returns -1 if the number is Inf or NaN or less than 0 or greater than some
+    implementation defined max string length. */
+inline double GetStringPositionArgument();
+
 // Check for String overflow of rResult+rAdd and set error and erase rResult
 // if so. Return true if ok, false if overflow
 inline bool CheckStringResultLen( OUString& rResult, const OUString& rAdd );
@@ -900,6 +918,36 @@ inline bool ScInterpreter::MustHaveParamCountMin( short nAct, short nMin )
     return false;
 }
 
+inline bool ScInterpreter::CheckStringPositionArgument( double & fVal )
+{
+    if (!rtl::math::isFinite( fVal))
+    {
+        fVal = -1.0;
+        return false;
+    }
+    else if (fVal < 0.0)
+    {
+        fVal = 0.0;
+        return false;
+    }
+    else if (fVal > SAL_MAX_UINT16)
+    {
+        fVal = static_cast<double>(SAL_MAX_UINT16);
+        return false;
+    }
+    return true;
+}
+
+inline double ScInterpreter::GetStringPositionArgument()
+{
+    double fVal = rtl::math::approxFloor( GetDouble());
+    if (!CheckStringPositionArgument( fVal))
+    {
+        fVal = -1.0;
+    }
+    return fVal;
+}
+
 inline bool ScInterpreter::CheckStringResultLen( OUString& rResult, const OUString& rAdd )
 {
     if ( (sal_uLong) rResult.getLength() + rAdd.getLength() > STRING_MAXLEN )
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index c4e6c56..758ce15 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -7673,11 +7673,10 @@ void ScInterpreter::ScReplace()
     if ( MustHaveParamCount( GetByte(), 4 ) )
     {
         OUString aNewStr = GetString().getString();
-        double fCount = ::rtl::math::approxFloor( GetDouble());
-        double fPos   = ::rtl::math::approxFloor( GetDouble());
+        double fCount = GetStringPositionArgument();
+        double fPos   = GetStringPositionArgument();
         OUString aOldStr = GetString().getString();
-        if (fPos < 1.0 || fPos > static_cast<double>(STRING_MAXLEN)
-                || fCount < 0.0 || fCount > static_cast<double>(STRING_MAXLEN))
+        if (fPos < 1.0 || fCount < 0.0)
             PushIllegalArgument();
         else
         {
@@ -7800,8 +7799,8 @@ void ScInterpreter::ScLeft()
         sal_Int32 n;
         if (nParamCount == 2)
         {
-            double nVal = ::rtl::math::approxFloor(GetDouble());
-            if ( rtl::math::isNan(nVal) || nVal < 0.0 || nVal > STRING_MAXLEN )
+            double nVal = GetStringPositionArgument();
+            if (nVal < 0.0)
             {
                 PushIllegalArgument();
                 return ;
@@ -7908,8 +7907,8 @@ void ScInterpreter::ScRightB()
         sal_Int32 n;
         if (nParamCount == 2)
         {
-            double nVal = ::rtl::math::approxFloor(GetDouble());
-            if ( rtl::math::isNan(nVal) || nVal < 0.0 || nVal > STRING_MAXLEN )
+            double nVal = GetStringPositionArgument();
+            if ( nVal < 0.0 )
             {
                 PushIllegalArgument();
                 return ;
@@ -7959,8 +7958,8 @@ void ScInterpreter::ScLeftB()
         sal_Int32 n;
         if (nParamCount == 2)
         {
-            double nVal = ::rtl::math::approxFloor(GetDouble());
-            if ( nVal < 0.0 || nVal > STRING_MAXLEN )
+            double nVal = GetStringPositionArgument();
+            if ( nVal < 0.0 )
             {
                 PushIllegalArgument();
                 return ;
@@ -7978,10 +7977,10 @@ void ScInterpreter::ScMidB()
 {
     if ( MustHaveParamCount( GetByte(), 3 ) )
     {
-        double fAnz    = ::rtl::math::approxFloor(GetDouble());
-        double fAnfang = ::rtl::math::approxFloor(GetDouble());
+        double fAnz    = GetStringPositionArgument();
+        double fAnfang = GetStringPositionArgument();
         OUString aStr = GetString().getString();
-        if (fAnfang < 1.0 || fAnz < 0.0 || fAnfang > double(STRING_MAXLEN) || fAnz > double(STRING_MAXLEN))
+        if (fAnfang < 1.0 || fAnz < 0.0)
             PushIllegalArgument();
         else
         {
@@ -8002,8 +8001,8 @@ void ScInterpreter::ScRight()
         sal_Int32 n;
         if (nParamCount == 2)
         {
-            double nVal = ::rtl::math::approxFloor(GetDouble());
-            if ( nVal < 0.0 || nVal > STRING_MAXLEN )
+            double nVal = GetStringPositionArgument();
+            if (nVal < 0.0)
             {
                 PushIllegalArgument();
                 return ;
@@ -8029,8 +8028,15 @@ void ScInterpreter::ScSearch()
         double fAnz;
         if (nParamCount == 3)
         {
-            fAnz = ::rtl::math::approxFloor(GetDouble());
-            if (fAnz > double(STRING_MAXLEN))
+            // This should use GetStringPositionArgument() but old versions up
+            // to LibreOffice 4.2.5 allowed and ignored 0 and negative values.
+            // It is unnecessary to break existing documents that "rely" on
+            // that behavior. Though ODFF constrains Start to be >=1.
+            /* TODO: fix this and possibly break those broken documents? */
+            fAnz = rtl::math::approxFloor( GetDouble());
+            if (fAnz < 1.0)
+                fAnz = 1.0;
+            else if (!CheckStringPositionArgument( fAnz))
             {
                 PushIllegalArgument();
                 return;
@@ -8064,10 +8070,10 @@ void ScInterpreter::ScMid()
 {
     if ( MustHaveParamCount( GetByte(), 3 ) )
     {
-        double fAnz    = ::rtl::math::approxFloor(GetDouble());
-        double fAnfang = ::rtl::math::approxFloor(GetDouble());
+        double fAnz    = GetStringPositionArgument();
+        double fAnfang = GetStringPositionArgument();
         OUString aStr = GetString().getString();
-        if (fAnfang < 1.0 || fAnz < 0.0 || fAnfang > double(STRING_MAXLEN) || fAnz > double(STRING_MAXLEN))
+        if (fAnfang < 1.0 || fAnz < 0.0)
             PushIllegalArgument();
         else
         {
@@ -8162,8 +8168,8 @@ void ScInterpreter::ScSubstitute()
         sal_Int32 nAnz;
         if (nParamCount == 4)
         {
-            double fAnz = ::rtl::math::approxFloor(GetDouble());
-            if( fAnz < 1 || fAnz > STRING_MAXLEN )
+            double fAnz = GetStringPositionArgument();
+            if( fAnz < 1 )
             {
                 PushIllegalArgument();
                 return;
@@ -8212,11 +8218,11 @@ void ScInterpreter::ScRept()
 {
     if ( MustHaveParamCount( GetByte(), 2 ) )
     {
-        double fAnz = ::rtl::math::approxFloor(GetDouble());
+        double fAnz = GetStringPositionArgument();
         OUString aStr = GetString().getString();
         if ( fAnz < 0.0 )
             PushIllegalArgument();
-        else if ( fAnz * aStr.getLength() > STRING_MAXLEN )
+        else if ( fAnz * aStr.getLength() > SAL_MAX_UINT16 )
         {
             PushError( errStringOverflow );
         }
commit 584febd23a22cf829b69b519d9522005f37bbae2
Author: Oliver-Rainer Wittmann <orw at apache.org>
Date:   Fri Jun 6 12:07:49 2014 +0000

    Resolves: #i125000# check last status of newly created...
    
    <Gdiplus::Bitmap> instance before using it.
    
    (cherry picked from commit b127235917610b9c68e19df29bb39af496906569)
    
    Change-Id: I97364cf963424b0e8d0b52b3c995bd4defdca067
    (cherry picked from commit adb1bb21f804c62004f31ad5473d4cf447436b9b)
    (cherry picked from commit e0c9b690074cd476b03169397cbf1969f2239c1e)
    Reviewed-on: https://gerrit.libreoffice.org/9670
    Tested-by: David Tardon <dtardon at redhat.com>
    Reviewed-by: David Tardon <dtardon at redhat.com>

diff --git a/vcl/win/source/gdi/salbmp.cxx b/vcl/win/source/gdi/salbmp.cxx
index f0e1509..3ba430d 100644
--- a/vcl/win/source/gdi/salbmp.cxx
+++ b/vcl/win/source/gdi/salbmp.cxx
@@ -331,24 +331,32 @@ Gdiplus::Bitmap* WinSalBitmap::ImplCreateGdiPlusBitmap()
 
         if(pRetval)
         {
-            sal_uInt8* pSrcRGB(pRGB->mpBits);
-            const sal_uInt32 nExtraRGB(pRGB->mnScanlineSize - (nW * 3));
-            const bool bTopDown(pRGB->mnFormat & BMP_FORMAT_TOP_DOWN);
-            const Gdiplus::Rect aAllRect(0, 0, nW, nH);
-            Gdiplus::BitmapData aGdiPlusBitmapData;
-            pRetval->LockBits(&aAllRect, Gdiplus::ImageLockModeWrite, PixelFormat24bppRGB, &aGdiPlusBitmapData);
-
-            // copy data to Gdiplus::Bitmap; format is BGR here in both cases, so memcpy is possible
-            for(sal_uInt32 y(0); y < nH; y++)
+            if ( pRetval->GetLastStatus() == Gdiplus::Ok )
             {
-                const sal_uInt32 nYInsert(bTopDown ? y : nH - y - 1);
-                sal_uInt8* targetPixels = (sal_uInt8*)aGdiPlusBitmapData.Scan0 + (nYInsert * aGdiPlusBitmapData.Stride);
+                sal_uInt8* pSrcRGB(pRGB->mpBits);
+                const sal_uInt32 nExtraRGB(pRGB->mnScanlineSize - (nW * 3));
+                const bool bTopDown(pRGB->mnFormat & BMP_FORMAT_TOP_DOWN);
+                const Gdiplus::Rect aAllRect(0, 0, nW, nH);
+                Gdiplus::BitmapData aGdiPlusBitmapData;
+                pRetval->LockBits(&aAllRect, Gdiplus::ImageLockModeWrite, PixelFormat24bppRGB, &aGdiPlusBitmapData);
+
+                // copy data to Gdiplus::Bitmap; format is BGR here in both cases, so memcpy is possible
+                for(sal_uInt32 y(0); y < nH; y++)
+                {
+                    const sal_uInt32 nYInsert(bTopDown ? y : nH - y - 1);
+                    sal_uInt8* targetPixels = (sal_uInt8*)aGdiPlusBitmapData.Scan0 + (nYInsert * aGdiPlusBitmapData.Stride);
 
-                memcpy(targetPixels, pSrcRGB, nW * 3);
-                pSrcRGB += nW * 3 + nExtraRGB;
-            }
+                    memcpy(targetPixels, pSrcRGB, nW * 3);
+                    pSrcRGB += nW * 3 + nExtraRGB;
+                }
 
-            pRetval->UnlockBits(&aGdiPlusBitmapData);
+                pRetval->UnlockBits(&aGdiPlusBitmapData);
+            }
+            else
+            {
+                delete pRetval;
+                pRetval = NULL;
+            }
         }
     }
 
commit ddcae0154bb23fc489f5761ef95a83e5a436ce84
Author: Elie Roux <elie.roux at telecom-bretagne.eu>
Date:   Sun Jun 8 22:28:18 2014 +0200

    fix fdo#40073 : look for translated frame styles
    
    LO was looking for untranslated frame styles,
    while at this step, the style list contains only the
    translated ones.
    
    Change-Id: I36173fc871582f974184fc95bb4d1a82cd3de783
    Reviewed-on: https://gerrit.libreoffice.org/9683
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    Tested-by: Michael Stahl <mstahl at redhat.com>
    (cherry picked from commit 6f6673c5d1b4e6ea4982621f2817eb5d5dc10377)
    Signed-off-by: Michael Stahl <mstahl at redhat.com>

diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx
index 43520a7..e2093aa 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -616,6 +616,7 @@ bool SwFrameProperties_Impl::AnyToItemSet(SwDoc *pDoc, SfxItemSet& rSet, SfxItem
     {
         OUString sStyle;
         *pStyleName >>= sStyle;
+        SwStyleNameMapper::FillUIName(sStyle, sStyle, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT, true);
         pStyle = (SwDocStyleSheet*)pDoc->GetDocShell()->GetStyleSheetPool()->Find(sStyle,
                                                     SFX_STYLE_FAMILY_FRAME);
     }
commit 8b877bf7da1c1cf656f2a6a58b95583ef127ac7f
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Mon Jun 9 08:31:54 2014 +0200

    fdo#79786 implement getFormOperations for data grid (table view)
    
    Change-Id: I704057b25ca11633ba62fbb834bd2e6095f348f3
    Reviewed-on: https://gerrit.libreoffice.org/9687
    Tested-by: David Tardon <dtardon at redhat.com>
    Reviewed-by: David Tardon <dtardon at redhat.com>

diff --git a/dbaccess/source/ui/browser/brwctrlr.cxx b/dbaccess/source/ui/browser/brwctrlr.cxx
index f1e2780..a919939 100644
--- a/dbaccess/source/ui/browser/brwctrlr.cxx
+++ b/dbaccess/source/ui/browser/brwctrlr.cxx
@@ -43,6 +43,7 @@
 #include <com/sun/star/form/XSubmit.hpp>
 #include <com/sun/star/form/XSubmitListener.hpp>
 #include <com/sun/star/form/runtime/XFormController.hpp>
+#include <com/sun/star/form/runtime/FormOperations.hpp>
 #include <com/sun/star/sdb/CommandType.hpp>
 #include <com/sun/star/sdb/ErrorCondition.hpp>
 #include <com/sun/star/sdb/ParametersRequest.hpp>
@@ -93,6 +94,7 @@ using namespace ::com::sun::star::sdbcx;
 using namespace ::com::sun::star::task;
 using namespace ::com::sun::star::beans;
 using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::form::runtime;
 using namespace ::com::sun::star::form;
 using namespace ::com::sun::star::util;
 using namespace ::com::sun::star::lang;
@@ -258,8 +260,7 @@ SbaXDataBrowserController::FormControllerImpl::~FormControllerImpl()
 
 Reference< runtime::XFormOperations > SAL_CALL SbaXDataBrowserController::FormControllerImpl::getFormOperations() throw (RuntimeException)
 {
-    SAL_WARN("dbaccess.ui", "SbaXDataBrowserController::FormControllerImpl::getFormOperations: not supported!" );
-    return NULL;
+    return FormOperations::createWithFormController( m_pOwner->m_xContext, this );
 }
 
 Reference< ::com::sun::star::awt::XControl >  SbaXDataBrowserController::FormControllerImpl::getCurrentControl(void) throw( RuntimeException )
commit 26d1dccab78a136a6b92674fbf3edbe2ff0c8586
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Jun 6 12:46:05 2014 +0100

    various recent openssl CVEs
    
    Change-Id: Ib8989682690a73e5d09fb06617ad9d0938d76ccc
    Reviewed-on: https://gerrit.libreoffice.org/9666
    Tested-by: Michael Stahl <mstahl at redhat.com>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>

diff --git a/external/openssl/CVE-2010-5298.patch b/external/openssl/CVE-2010-5298.patch
new file mode 100644
index 0000000..55251b3
--- /dev/null
+++ b/external/openssl/CVE-2010-5298.patch
@@ -0,0 +1,21 @@
+From: Ben Laurie <ben at links.org>
+Date: Wed, 23 Apr 2014 06:24:03 +0000 (+0100)
+Subject: Fix use after free.
+X-Git-Url: https://git.openssl.org/gitweb/b/?p=openssl.git;a=commitdiff_plain;h=94d1f4b
+
+Fix use after free.
+---
+
+diff --git a/a/ssl/s3_pkt.c b/b/ssl/s3_pkt.c
+index b9e45c7..d601a18 100644
+--- a/a/ssl/s3_pkt.c
++++ b/b/ssl/s3_pkt.c
+@@ -1334,7 +1334,7 @@ start:
+ 				{
+ 				s->rstate=SSL_ST_READ_HEADER;
+ 				rr->off=0;
+-				if (s->mode & SSL_MODE_RELEASE_BUFFERS)
++				if (s->mode & SSL_MODE_RELEASE_BUFFERS && s->s3->rbuf.left == 0)
+ 					ssl3_release_read_buffer(s);
+ 				}
+ 			}
diff --git a/external/openssl/CVE-2013-4353.patch b/external/openssl/CVE-2013-4353.patch
new file mode 100644
index 0000000..be7cf4c
--- /dev/null
+++ b/external/openssl/CVE-2013-4353.patch
@@ -0,0 +1,21 @@
+Fix for TLS record tampering bug. A carefully crafted invalid 
+handshake could crash OpenSSL with a NULL pointer exception.
+Thanks to Anton Johansson for reporting this issues.
+(CVE-2013-4353)
+diff --git a/a/ssl/s3_both.c b/b/ssl/s3_both.c
+index 1e5dcab..53b9390 100644
+--- a/a/ssl/s3_both.c
++++ b/b/ssl/s3_both.c
+@@ -210,7 +210,11 @@ static void ssl3_take_mac(SSL *s)
+ 	{
+ 	const char *sender;
+ 	int slen;
+-
++	/* If no new cipher setup return immediately: other functions will
++	 * set the appropriate error.
++	 */
++	if (s->s3->tmp.new_cipher == NULL)
++		return;
+ 	if (s->state & SSL_ST_CONNECT)
+ 		{
+ 		sender=s->method->ssl3_enc->server_finished_label;
diff --git a/external/openssl/CVE-2013-6449.patch b/external/openssl/CVE-2013-6449.patch
new file mode 100644
index 0000000..3da0646
--- /dev/null
+++ b/external/openssl/CVE-2013-6449.patch
@@ -0,0 +1,111 @@
+Use version in SSL_METHOD not SSL structure.
+
+When deciding whether to use TLS 1.2 PRF and record hash algorithms
+use the version number in the corresponding SSL_METHOD structure
+instead of the SSL structure. The SSL structure version is sometimes
+inaccurate. Note: OpenSSL 1.0.2 and later effectively do this already.
+(CVE-2013-6449)
+
+Also preventively check EVP errors for handshake digests.
+
+diff --git a/a/ssl/s3_lib.c b/b/ssl/s3_lib.c
+index bf832bb..c4ef273 100644
+--- a/a/ssl/s3_lib.c
++++ b/b/ssl/s3_lib.c
+@@ -4286,7 +4286,7 @@ need to go to SSL_ST_ACCEPT.
+ long ssl_get_algorithm2(SSL *s)
+ 	{
+ 	long alg2 = s->s3->tmp.new_cipher->algorithm2;
+-	if (TLS1_get_version(s) >= TLS1_2_VERSION &&
++	if (s->method->version == TLS1_2_VERSION &&
+ 	    alg2 == (SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF))
+ 		return SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256;
+ 	return alg2;
+diff --git a/a/ssl/s3_both.c b/b/ssl/s3_both.c
+index ead01c8..1e5dcab 100644
+--- a/a/ssl/s3_both.c
++++ b/b/ssl/s3_both.c
+@@ -161,6 +161,8 @@ int ssl3_send_finished(SSL *s, int a, int b, const char *sender, int slen)
+ 
+ 		i=s->method->ssl3_enc->final_finish_mac(s,
+ 			sender,slen,s->s3->tmp.finish_md);
++		if (i == 0)
++			return 0;
+ 		s->s3->tmp.finish_md_len = i;
+ 		memcpy(p, s->s3->tmp.finish_md, i);
+ 		p+=i;
+diff --git a/a/ssl/s3_pkt.c b/b/ssl/s3_pkt.c
+index 804291e..c4bc4e7 100644
+--- a/a/ssl/s3_pkt.c
++++ b/b/ssl/s3_pkt.c
+@@ -335,7 +335,7 @@ fprintf(stderr, "Record type=%d, Length=%d\n", rr->type, rr->length);
+ 			if (version != s->version)
+ 				{
+ 				SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_WRONG_VERSION_NUMBER);
+-                                if ((s->version & 0xFF00) == (version & 0xFF00))
++                                if ((s->version & 0xFF00) == (version & 0xFF00) && !s->enc_write_ctx && !s->write_hash)
+                                 	/* Send back error using their minor version number :-) */
+ 					s->version = (unsigned short)version;
+ 				al=SSL_AD_PROTOCOL_VERSION;
+@@ -1459,8 +1459,14 @@ int ssl3_do_change_cipher_spec(SSL *s)
+ 		slen=s->method->ssl3_enc->client_finished_label_len;
+ 		}
+ 
+-	s->s3->tmp.peer_finish_md_len = s->method->ssl3_enc->final_finish_mac(s,
++	i = s->method->ssl3_enc->final_finish_mac(s,
+ 		sender,slen,s->s3->tmp.peer_finish_md);
++	if (i == 0)
++		{
++		SSLerr(SSL_F_SSL3_DO_CHANGE_CIPHER_SPEC, ERR_R_INTERNAL_ERROR);
++		return 0;
++		}
++	s->s3->tmp.peer_finish_md_len = i;
+ 
+ 	return(1);
+ 	}
+diff --git a/a/ssl/s3_srvr.c b/b/ssl/s3_srvr.c
+index e5a8b3f..52efed3 100644
+--- a/a/ssl/s3_srvr.c
++++ b/b/ssl/s3_srvr.c
+@@ -958,7 +958,8 @@ int ssl3_get_client_hello(SSL *s)
+ 	    (s->version != DTLS1_VERSION && s->client_version < s->version))
+ 		{
+ 		SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_WRONG_VERSION_NUMBER);
+-		if ((s->client_version>>8) == SSL3_VERSION_MAJOR)
++		if ((s->client_version>>8) == SSL3_VERSION_MAJOR && 
++			!s->enc_write_ctx && !s->write_hash)
+ 			{
+ 			/* similar to ssl3_get_record, send alert using remote version number */
+ 			s->version = s->client_version;
+diff --git a/a/ssl/t1_enc.c b/b/ssl/t1_enc.c
+index 809ad2e..72015f5 100644
+--- a/a/ssl/t1_enc.c
++++ b/b/ssl/t1_enc.c
+@@ -915,18 +915,19 @@ int tls1_final_finish_mac(SSL *s,
+ 		if (mask & ssl_get_algorithm2(s))
+ 			{
+ 			int hashsize = EVP_MD_size(md);
+-			if (hashsize < 0 || hashsize > (int)(sizeof buf - (size_t)(q-buf)))
++			EVP_MD_CTX *hdgst = s->s3->handshake_dgst[idx];
++			if (!hdgst || hashsize < 0 || hashsize > (int)(sizeof buf - (size_t)(q-buf)))
+ 				{
+ 				/* internal error: 'buf' is too small for this cipersuite! */
+ 				err = 1;
+ 				}
+ 			else
+ 				{
+-				EVP_MD_CTX_copy_ex(&ctx,s->s3->handshake_dgst[idx]);
+-				EVP_DigestFinal_ex(&ctx,q,&i);
+-				if (i != (unsigned int)hashsize) /* can't really happen */
++				if (!EVP_MD_CTX_copy_ex(&ctx, hdgst) ||
++					!EVP_DigestFinal_ex(&ctx,q,&i) ||
++					(i != (unsigned int)hashsize))
+ 					err = 1;
+-				q+=i;
++				q+=hashsize;
+ 				}
+ 			}
+ 		}
+-- 
+1.8.3.1
+
diff --git a/external/openssl/CVE-2013-6450.patch b/external/openssl/CVE-2013-6450.patch
new file mode 100644
index 0000000..ba45785
--- /dev/null
+++ b/external/openssl/CVE-2013-6450.patch
@@ -0,0 +1,85 @@
+Fix DTLS retransmission from previous session.
+
+For DTLS we might need to retransmit messages from the previous session
+so keep a copy of write context in DTLS retransmission buffers instead
+of replacing it after sending CCS. CVE-2013-6450.
+
+diff --git a/a/ssl/d1_both.c b/b/ssl/d1_both.c
+index 65ec001..7a5596a 100644
+--- a/a/ssl/d1_both.c
++++ b/b/ssl/d1_both.c
+@@ -214,6 +214,12 @@ dtls1_hm_fragment_new(unsigned long frag_len, int reassembly)
+ static void
+ dtls1_hm_fragment_free(hm_fragment *frag)
+ 	{
++
++	if (frag->msg_header.is_ccs)
++		{
++		EVP_CIPHER_CTX_free(frag->msg_header.saved_retransmit_state.enc_write_ctx);
++		EVP_MD_CTX_destroy(frag->msg_header.saved_retransmit_state.write_hash);
++		}
+ 	if (frag->fragment) OPENSSL_free(frag->fragment);
+ 	if (frag->reassembly) OPENSSL_free(frag->reassembly);
+ 	OPENSSL_free(frag);
+diff --git a/a/ssl/ssl_locl.h b/b/ssl/ssl_locl.h
+index 96ce9a7..e485907 100644
+--- a/a/ssl/ssl_locl.h
++++ b/b/ssl/ssl_locl.h
+@@ -621,6 +621,8 @@ extern SSL3_ENC_METHOD TLSv1_enc_data;
+ extern SSL3_ENC_METHOD SSLv3_enc_data;
+ extern SSL3_ENC_METHOD DTLSv1_enc_data;
+ 
++#define SSL_IS_DTLS(s) (s->method->version == DTLS1_VERSION)
++
+ #define IMPLEMENT_tls_meth_func(version, func_name, s_accept, s_connect, \
+ 				s_get_meth) \
+ const SSL_METHOD *func_name(void)  \
+diff --git a/a/ssl/t1_enc.c b/b/ssl/t1_enc.c
+index 72015f5..56db834 100644
+--- a/a/ssl/t1_enc.c
++++ b/b/ssl/t1_enc.c
+@@ -414,15 +414,20 @@ int tls1_change_cipher_state(SSL *s, int which)
+ 			s->mac_flags |= SSL_MAC_FLAG_WRITE_MAC_STREAM;
+ 			else
+ 			s->mac_flags &= ~SSL_MAC_FLAG_WRITE_MAC_STREAM;
+-		if (s->enc_write_ctx != NULL)
++		if (s->enc_write_ctx != NULL && !SSL_IS_DTLS(s))
+ 			reuse_dd = 1;
+-		else if ((s->enc_write_ctx=OPENSSL_malloc(sizeof(EVP_CIPHER_CTX))) == NULL)
++		else if ((s->enc_write_ctx=EVP_CIPHER_CTX_new()) == NULL)
+ 			goto err;
+-		else
+-			/* make sure it's intialized in case we exit later with an error */
+-			EVP_CIPHER_CTX_init(s->enc_write_ctx);
+ 		dd= s->enc_write_ctx;
+-		mac_ctx = ssl_replace_hash(&s->write_hash,NULL);
++		if (SSL_IS_DTLS(s))
++			{
++			mac_ctx = EVP_MD_CTX_create();
++			if (!mac_ctx)
++				goto err;
++			s->write_hash = mac_ctx;
++			}
++		else
++			mac_ctx = ssl_replace_hash(&s->write_hash,NULL);
+ #ifndef OPENSSL_NO_COMP
+ 		if (s->compress != NULL)
+ 			{
+diff --git a/a/crypto/evp/digest.c b/b/crypto/evp/digest.c
+index 6fc469f..d14e8e4 100644
+--- a/a/crypto/evp/digest.c
++++ b/b/crypto/evp/digest.c
+@@ -366,8 +366,11 @@ int EVP_Digest(const void *data, size_t count,
+ 
+ void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx)
+ 	{
+-	EVP_MD_CTX_cleanup(ctx);
+-	OPENSSL_free(ctx);
++	if (ctx)
++		{
++		EVP_MD_CTX_cleanup(ctx);
++		OPENSSL_free(ctx);
++		}
+ 	}
+ 
+ /* This call frees resources associated with the context */
diff --git a/external/openssl/CVE-2014-0195.patch b/external/openssl/CVE-2014-0195.patch
new file mode 100644
index 0000000..d9aaa83
--- /dev/null
+++ b/external/openssl/CVE-2014-0195.patch
@@ -0,0 +1,36 @@
+commit 208d54db20d58c9a5e45e856a0650caadd7d9612
+Author: Dr. Stephen Henson <steve at openssl.org>
+Date:   Tue May 13 18:48:31 2014 +0100
+
+    Fix for CVE-2014-0195
+    
+    A buffer overrun attack can be triggered by sending invalid DTLS fragments
+    to an OpenSSL DTLS client or server. This is potentially exploitable to
+    run arbitrary code on a vulnerable client or server.
+    
+    Fixed by adding consistency check for DTLS fragments.
+    
+    Thanks to Jüri Aedla for reporting this issue.
+
+diff --git a/a/ssl/d1_both.c b/b/ssl/d1_both.c
+index 2e8cf68..07f67f8 100644
+--- a/a/ssl/d1_both.c
++++ b/b/ssl/d1_both.c
+@@ -627,7 +627,16 @@ dtls1_reassemble_fragment(SSL *s, struct hm_header_st* msg_hdr, int *ok)
+ 		frag->msg_header.frag_off = 0;
+ 		}
+ 	else
++		{
+ 		frag = (hm_fragment*) item->data;
++		if (frag->msg_header.msg_len != msg_hdr->msg_len)
++			{
++			item = NULL;
++			frag = NULL;
++			goto err;
++			}
++		}
++
+ 
+ 	/* If message is already reassembled, this must be a
+ 	 * retransmit and can be dropped.
+
diff --git a/external/openssl/CVE-2014-0198.patch b/external/openssl/CVE-2014-0198.patch
new file mode 100644
index 0000000..0cffb79
--- /dev/null
+++ b/external/openssl/CVE-2014-0198.patch
@@ -0,0 +1,33 @@
+From: Matt Caswell <matt at openssl.org>
+Date: Sun, 11 May 2014 23:38:37 +0000 (+0100)
+Subject: Fixed NULL pointer dereference. See PR#3321
+X-Git-Url: https://git.openssl.org/gitweb/b/?p=openssl.git;a=commitdiff_plain;h=b107586
+
+Fixed NULL pointer dereference. See PR#3321
+---
+
+diff --git a/a/ssl/s3_pkt.c b/b/ssl/s3_pkt.c
+index 40eb0dd..d961d12 100644
+--- a/a/ssl/s3_pkt.c
++++ b/b/ssl/s3_pkt.c
+@@ -657,9 +657,6 @@ static int do_ssl3_write(SSL *s, int type, const unsigned char *buf,
+ 	SSL3_BUFFER *wb=&(s->s3->wbuf);
+ 	SSL_SESSION *sess;
+ 
+- 	if (wb->buf == NULL)
+-		if (!ssl3_setup_write_buffer(s))
+-			return -1;
+ 
+ 	/* first check if there is a SSL3_BUFFER still being written
+ 	 * out.  This will happen with non blocking IO */
+@@ -675,6 +672,10 @@ static int do_ssl3_write(SSL *s, int type, const unsigned char *buf,
+ 		/* if it went, fall through and send more stuff */
+ 		}
+ 
++ 	if (wb->buf == NULL)
++		if (!ssl3_setup_write_buffer(s))
++			return -1;
++
+ 	if (len == 0 && !create_empty_fragment)
+ 		return 0;
+ 
diff --git a/external/openssl/CVE-2014-0221.patch b/external/openssl/CVE-2014-0221.patch
new file mode 100644
index 0000000..68186f7
--- /dev/null
+++ b/external/openssl/CVE-2014-0221.patch
@@ -0,0 +1,34 @@
+commit d30e582446b027868cdabd0994681643682045a4
+Author: Dr. Stephen Henson <steve at openssl.org>
+Date:   Fri May 16 13:00:45 2014 +0100
+
+    Fix CVE-2014-0221
+    
+    Unnecessary recursion when receiving a DTLS hello request can be used to
+    crash a DTLS client. Fixed by handling DTLS hello request without recursion.
+    
+    Thanks to Imre Rad (Search-Lab Ltd.) for discovering this issue.
+
+diff --git a/a/ssl/d1_both.c b/b/ssl/d1_both.c
+index 07f67f8..4c2fd03 100644
+--- a/a/ssl/d1_both.c
++++ b/b/ssl/d1_both.c
+@@ -793,6 +793,7 @@ dtls1_get_message_fragment(SSL *s, int st1, int stn, long max, int *ok)
+ 	int i,al;
+ 	struct hm_header_st msg_hdr;
+ 
++	redo:
+ 	/* see if we have the required fragment already */
+ 	if ((frag_len = dtls1_retrieve_buffered_fragment(s,max,ok)) || *ok)
+ 		{
+@@ -851,8 +852,7 @@ dtls1_get_message_fragment(SSL *s, int st1, int stn, long max, int *ok)
+ 					s->msg_callback_arg);
+ 			
+ 			s->init_num = 0;
+-			return dtls1_get_message_fragment(s, st1, stn,
+-				max, ok);
++			goto redo;
+ 			}
+ 		else /* Incorrectly formated Hello request */
+ 			{
+
diff --git a/external/openssl/CVE-2014-0224.patch b/external/openssl/CVE-2014-0224.patch
new file mode 100644
index 0000000..8a7aaa7
--- /dev/null
+++ b/external/openssl/CVE-2014-0224.patch
@@ -0,0 +1,88 @@
+diff -up openssl-1.0.1e/ssl/ssl3.h.keying-mitm openssl-1.0.1e/ssl/ssl3.h
+--- a/a/ssl/ssl3.h.keying-mitm	2014-06-02 19:48:04.518100562 +0200
+--- b/b/ssl/ssl3.h	2014-06-02 19:48:04.642103429 +0200
+@@ -388,6 +388,7 @@ typedef struct ssl3_buffer_st
+ #define TLS1_FLAGS_TLS_PADDING_BUG		0x0008
+ #define TLS1_FLAGS_SKIP_CERT_VERIFY		0x0010
+ #define TLS1_FLAGS_KEEP_HANDSHAKE		0x0020
++#define SSL3_FLAGS_CCS_OK			0x0080
+  
+ /* SSL3_FLAGS_SGC_RESTART_DONE is set when we
+  * restart a handshake because of MS SGC and so prevents us
+diff -up openssl-1.0.1e/ssl/s3_clnt.c.keying-mitm openssl-1.0.1e/ssl/s3_clnt.c
+--- a/a/ssl/s3_clnt.c.keying-mitm	2013-02-11 16:26:04.000000000 +0100
+--- b/b/ssl/s3_clnt.c	2014-06-02 19:49:57.042701985 +0200
+@@ -559,6 +559,7 @@ int ssl3_connect(SSL *s)
+ 		case SSL3_ST_CR_FINISHED_A:
+ 		case SSL3_ST_CR_FINISHED_B:
+ 
++			s->s3->flags |= SSL3_FLAGS_CCS_OK;
+ 			ret=ssl3_get_finished(s,SSL3_ST_CR_FINISHED_A,
+ 				SSL3_ST_CR_FINISHED_B);
+ 			if (ret <= 0) goto end;
+@@ -916,6 +917,7 @@ int ssl3_get_server_hello(SSL *s)
+ 		SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT);
+ 		goto f_err;
+ 		}
++	    s->s3->flags |= SSL3_FLAGS_CCS_OK;
+ 	    s->hit=1;
+ 	    }
+ 	else	/* a miss or crap from the other end */
+diff -up openssl-1.0.1e/ssl/s3_pkt.c.keying-mitm openssl-1.0.1e/ssl/s3_pkt.c
+--- a/a/ssl/s3_pkt.c.keying-mitm	2014-06-02 19:48:04.640103383 +0200
+--- b/b/ssl/s3_pkt.c	2014-06-02 19:48:04.643103452 +0200
+@@ -1298,6 +1298,15 @@ start:
+ 			goto f_err;
+ 			}
+ 
++		if (!(s->s3->flags & SSL3_FLAGS_CCS_OK))
++			{
++			al=SSL_AD_UNEXPECTED_MESSAGE;
++			SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_CCS_RECEIVED_EARLY);
++			goto f_err;
++			}
++
++		s->s3->flags &= ~SSL3_FLAGS_CCS_OK;
++
+ 		rr->length=0;
+ 
+ 		if (s->msg_callback)
+@@ -1432,7 +1441,7 @@ int ssl3_do_change_cipher_spec(SSL *s)
+ 
+ 	if (s->s3->tmp.key_block == NULL)
+ 		{
+-		if (s->session == NULL) 
++		if (s->session == NULL || s->session->master_key_length == 0)
+ 			{
+ 			/* might happen if dtls1_read_bytes() calls this */
+ 			SSLerr(SSL_F_SSL3_DO_CHANGE_CIPHER_SPEC,SSL_R_CCS_RECEIVED_EARLY);
+diff -up openssl-1.0.1e/ssl/s3_srvr.c.keying-mitm openssl-1.0.1e/ssl/s3_srvr.c
+--- a/a/ssl/s3_srvr.c.keying-mitm	2014-06-02 19:48:04.630103151 +0200
+--- b/b/ssl/s3_srvr.c	2014-06-02 19:48:04.643103452 +0200
+@@ -673,6 +673,7 @@ int ssl3_accept(SSL *s)
+ 		case SSL3_ST_SR_CERT_VRFY_A:
+ 		case SSL3_ST_SR_CERT_VRFY_B:
+ 
++			s->s3->flags |= SSL3_FLAGS_CCS_OK;
+ 			/* we should decide if we expected this one */
+ 			ret=ssl3_get_cert_verify(s);
+ 			if (ret <= 0) goto end;
+@@ -700,6 +701,7 @@ int ssl3_accept(SSL *s)
+ 
+ 		case SSL3_ST_SR_FINISHED_A:
+ 		case SSL3_ST_SR_FINISHED_B:
++			s->s3->flags |= SSL3_FLAGS_CCS_OK;
+ 			ret=ssl3_get_finished(s,SSL3_ST_SR_FINISHED_A,
+ 				SSL3_ST_SR_FINISHED_B);
+ 			if (ret <= 0) goto end;
+@@ -770,7 +772,10 @@ int ssl3_accept(SSL *s)
+ 				s->s3->tmp.next_state=SSL3_ST_SR_FINISHED_A;
+ #else
+ 				if (s->s3->next_proto_neg_seen)
++					{
++					s->s3->flags |= SSL3_FLAGS_CCS_OK;
+ 					s->s3->tmp.next_state=SSL3_ST_SR_NEXT_PROTO_A;
++					}
+ 				else
+ 					s->s3->tmp.next_state=SSL3_ST_SR_FINISHED_A;
+ #endif
diff --git a/external/openssl/CVE-2014-3470.patch b/external/openssl/CVE-2014-3470.patch
new file mode 100644
index 0000000..da123ee
--- /dev/null
+++ b/external/openssl/CVE-2014-3470.patch
@@ -0,0 +1,26 @@
+commit 4ad43d511f6cf064c66eb4bfd0fb0919b5dd8a86
+Author: Dr. Stephen Henson <steve at openssl.org>
+Date:   Thu May 29 15:00:05 2014 +0100
+
+    Fix CVE-2014-3470
+    
+    Check session_cert is not NULL before dereferencing it.
+
+diff --git a/a/ssl/s3_clnt.c b/b/ssl/s3_clnt.c
+index d35376d..4324f8d 100644
+--- a/a/ssl/s3_clnt.c
++++ b/b/ssl/s3_clnt.c
+@@ -2511,6 +2511,13 @@ int ssl3_send_client_key_exchange(SSL *s)
+ 			int ecdh_clnt_cert = 0;
+ 			int field_size = 0;
+ 
++			if (s->session->sess_cert == NULL) 
++				{
++				ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_UNEXPECTED_MESSAGE);
++				SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,SSL_R_UNEXPECTED_MESSAGE);
++				goto err;
++				}
++
+ 			/* Did we send out the client's
+ 			 * ECDH share for use in premaster
+ 			 * computation as part of client certificate?
diff --git a/external/openssl/UnpackedTarball_openssl.mk b/external/openssl/UnpackedTarball_openssl.mk
index 869a74e..07a775e 100644
--- a/external/openssl/UnpackedTarball_openssl.mk
+++ b/external/openssl/UnpackedTarball_openssl.mk
@@ -91,7 +91,16 @@ $(eval $(call gb_UnpackedTarball_fix_end_of_line,openssl,\
 ))
 
 $(eval $(call gb_UnpackedTarball_add_patches,openssl,\
+	external/openssl/CVE-2013-6449.patch \
+	external/openssl/CVE-2013-6450.patch \
+	external/openssl/CVE-2013-4353.patch \
 	external/openssl/CVE-2014-0160.patch \
+	external/openssl/CVE-2010-5298.patch \
+	external/openssl/CVE-2014-0195.patch \
+	external/openssl/CVE-2014-0198.patch \
+	external/openssl/CVE-2014-0221.patch \
+	external/openssl/CVE-2014-0224.patch \
+	external/openssl/CVE-2014-3470.patch \
 	$(if $(filter LINUX FREEBSD ANDROID,$(OS)),external/openssl/openssllnx.patch) \
 	$(if $(filter WNTGCC,$(OS)$(COM)),external/openssl/opensslmingw.patch) \
 	$(if $(filter MSC,$(COM)),external/openssl/opensslwnt.patch) \
commit 139c19320881d79c4493112c3dd9813104af8e80
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Jun 5 13:49:14 2014 +0100

    Resolves: rhbz#1096747 crash/hang on format-page on html document
    
    Change-Id: I9a989620375eb210e553b84b7a642a0360c8f03f
    (cherry picked from commit 655377e90c57bb68e5000f06f76531baf9eeaa37)
    (cherry picked from commit 829aa9e03ae570e15af1f754b292709f38f643ea)
    Reviewed-on: https://gerrit.libreoffice.org/9650
    Tested-by: Michael Stahl <mstahl at redhat.com>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>

diff --git a/sw/source/ui/fmtui/tmpdlg.cxx b/sw/source/ui/fmtui/tmpdlg.cxx
index bc224b7..7645249 100644
--- a/sw/source/ui/fmtui/tmpdlg.cxx
+++ b/sw/source/ui/fmtui/tmpdlg.cxx
@@ -290,6 +290,13 @@ SwTemplateDlg::SwTemplateDlg(Window* pParent,
                 if(!aCJKOptions.IsAsianTypographyEnabled())
                     RemoveTabPage("textgrid");
             }
+            else
+            {
+                RemoveTabPage("borders");
+                RemoveTabPage("columns");
+                RemoveTabPage("footnotes");
+                RemoveTabPage("textgrid");
+            }
         }
         break;
         // numbering styles
commit 4b3760b3c535fcb5e596cf4fd50f3924523689b5
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sat Mar 15 13:49:20 2014 +0000

    Resolves: rhbz#1104068 crash converting fontwork to curve
    
    via metafile, i.e. take fontwork example 11, convert
    to metafile and convert that to curve
    
    was coverity#1019335 Dereference after null check
    
    (cherry picked from commit d77cc9d2cdc702f2b2016498df107f4120d27690)
    
    Change-Id: I309e0c3f8a0630991e2aad64f995567e0920be3b
    Reviewed-on: https://gerrit.libreoffice.org/9649
    Tested-by: Michael Stahl <mstahl at redhat.com>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>

diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index 0a672d3..0446977 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -1011,7 +1011,7 @@ void SdrGrafObj::SetPage( SdrPage* pNewPage )
             ImpLinkAbmeldung();
     }
 
-    if(!pModel && !GetStyleSheet() && pNewPage->GetModel())
+    if(!pModel && !GetStyleSheet() && pNewPage && pNewPage->GetModel())
     {
         // #i119287# Set default StyleSheet for SdrGrafObj here, it is different from 'Default'. This
         // needs to be done before the style 'Default' is set from the :SetModel() call which is triggered
commit f9eda88435919ef9d407d93c9ebba651f10d8edf
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri May 30 13:09:28 2014 +0100

    coverity#736074 Missing break in switch
    
    (cherry picked from commit 87574542fc953a60bc2bafe8ed725500f9322521)
    (cherry picked from commit 035c802fa170af9fec84b2d9a6621043915accb2)
    
    Conflicts:
    	sw/source/core/uibase/uno/SwXDocumentSettings.cxx
    
    Change-Id: Ie60f70e992323b9841c854edc083f686bbeda1f5
    Reviewed-on: https://gerrit.libreoffice.org/9652
    Tested-by: Michael Stahl <mstahl at redhat.com>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>

diff --git a/sw/source/ui/uno/SwXDocumentSettings.cxx b/sw/source/ui/uno/SwXDocumentSettings.cxx
index 8a218a1..cf47b1c 100644
--- a/sw/source/ui/uno/SwXDocumentSettings.cxx
+++ b/sw/source/ui/uno/SwXDocumentSettings.cxx
@@ -781,6 +781,7 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf
             sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
             mpDoc->set(IDocumentSettingAccess::EMBED_FONTS, bTmp);
         }
+        break;
         case HANDLE_EMBED_SYSTEM_FONTS:
         {
             sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
commit de2aa2b992ad9d03eaa1abf0373c8d5c63038bef
Author: Armin Le Grand <alg at apache.org>
Date:   Fri Feb 28 02:15:29 2014 +0000

    Resolves: fdo#78953 secured usage of LayerTabBar in Draw...
    
    was #i87182# secured usage of LayerTabBar in Draw...
    
    ensured initialization when used as OLE
    
    (cherry picked from commit 903afaa8ea0766e01ba41a227d2794c2c40b129a)
    
    Conflicts:
    	sd/source/ui/accessibility/AccessibleDocumentViewBase.cxx
    	sd/source/ui/view/drviews3.cxx
    	sd/source/ui/view/drviews7.cxx
    	sd/source/ui/view/drviewsb.cxx
    
    (cherry picked from commit b1cf64fe51fd0bb1e9bc8c3bb38d5cc7254d8d5f)
    
    Conflicts:
    	sd/source/ui/accessibility/AccessibleDocumentViewBase.cxx
    	sd/source/ui/view/drviews3.cxx
    	sd/source/ui/view/drviews7.cxx
    
    Change-Id: I86bb17bf422356247a319f89e54d1ead97b368b8
    Reviewed-on: https://gerrit.libreoffice.org/9654
    Tested-by: Michael Stahl <mstahl at redhat.com>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>

diff --git a/sd/source/ui/view/drviews1.cxx b/sd/source/ui/view/drviews1.cxx
index 2df556d..bffde5d 100644
--- a/sd/source/ui/view/drviews1.cxx
+++ b/sd/source/ui/view/drviews1.cxx
@@ -352,7 +352,13 @@ void DrawViewShell::ChangeEditMode(EditMode eEMode, bool bIsLayerModeActive)
         GetViewShellBase().GetDrawController().BroadcastContextChange();
 
         meEditMode = eEMode;
-        mbIsLayerModeActive = bIsLayerModeActive;
+
+        if(pLayerBar)
+        {
+            // #i87182# only switch activation mode of LayerTabBar when there is one,
+            // else it will not get initialized with the current set of Layers as needed
+            mbIsLayerModeActive = bIsLayerModeActive;
+        }
 
         // Determine whether to show the master view toolbar.  The master
         // page mode has to be active and the shell must not be a handout
@@ -601,7 +607,11 @@ IMPL_LINK( DrawViewShell, TabSplitHdl, TabBar *, pTab )
     aTabSize.Width() = std::min(pTab->GetSplitSize(), (long)(nMax-1));
 
     maTabControl.SetSizePixel(aTabSize);
-    GetLayerTabControl()->SetSizePixel(aTabSize);
+
+    if(GetLayerTabControl()) // #i87182#
+    {
+        GetLayerTabControl()->SetSizePixel(aTabSize);
+    }
 
     Point aPos = maTabControl.GetPosPixel();
     aPos.X() += aTabSize.Width();
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
index 003835e..a81e2ff 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -1538,6 +1538,14 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
 
         case SID_MODIFYLAYER:
         {
+            if(!GetLayerTabControl()) // #i87182#
+            {
+                OSL_ENSURE(false, "No LayerTabBar (!)");
+                Cancel();
+                rReq.Ignore();
+                break;
+            }
+
             if ( mpDrawView->IsTextEdit() )
             {
                 mpDrawView->SdrEndTextEdit();
@@ -1694,8 +1702,14 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
                 mpDrawView->SdrEndTextEdit();
             }
 
-            GetLayerTabControl()->StartEditMode(
-                GetLayerTabControl()->GetCurPageId() );
+            if(GetLayerTabControl()) // #i87182#
+            {
+                GetLayerTabControl()->StartEditMode(GetLayerTabControl()->GetCurPageId());
+            }
+            else
+            {
+                OSL_ENSURE(false, "No LayerTabBar (!)");
+            }
 
             Cancel();
             rReq.Ignore ();
diff --git a/sd/source/ui/view/drviews3.cxx b/sd/source/ui/view/drviews3.cxx
index 31e89a4..f292942 100644
--- a/sd/source/ui/view/drviews3.cxx
+++ b/sd/source/ui/view/drviews3.cxx
@@ -199,17 +199,34 @@ void  DrawViewShell::ExecCtrl(SfxRequest& rReq)
         case SID_SWITCHLAYER:  // BASIC
         {
             const SfxItemSet *pArgs = rReq.GetArgs ();
-            sal_uInt16 nCurPage = GetLayerTabControl()->GetCurPageId ();
 
-            if( pArgs && pArgs->Count () == 1)
+            // #i87182#
+            bool bCurPageValid(false);
+            sal_uInt16 nCurPage(0);
+
+            if(GetLayerTabControl())
+            {
+                nCurPage = GetLayerTabControl()->GetCurPageId();
+                bCurPageValid = true;
+            }
+
+            if(pArgs && 1 == pArgs->Count())
             {
                 SFX_REQUEST_ARG (rReq, pWhatLayer, SfxUInt32Item, ID_VAL_WHATLAYER, sal_False);
-                if( pWhatLayer )
-                    nCurPage = (short) pWhatLayer->GetValue ();
+
+                if(pWhatLayer)
+                {
+                    nCurPage = (short)pWhatLayer->GetValue();
+                    bCurPageValid = true;
+                }
+            }
+
+            if(bCurPageValid)
+            {
+                mpDrawView->SetActiveLayer( GetLayerTabControl()->GetPageText(nCurPage) );
+                Invalidate();
             }
 
-            mpDrawView->SetActiveLayer( GetLayerTabControl()->GetPageText(nCurPage) );
-            Invalidate();
             rReq.Done ();
 
             break;
diff --git a/sd/source/ui/view/drviews4.cxx b/sd/source/ui/view/drviews4.cxx
index eff3e14..a79c8c3 100644
--- a/sd/source/ui/view/drviews4.cxx
+++ b/sd/source/ui/view/drviews4.cxx
@@ -95,6 +95,12 @@ void DrawViewShell::DeleteActualPage()
 
 void DrawViewShell::DeleteActualLayer()
 {
+    if(!GetLayerTabControl()) // #i87182#
+    {
+        OSL_ENSURE(false, "No LayerTabBar (!)");
+        return;
+    }
+
     SdrLayerAdmin& rAdmin = GetDoc()->GetLayerAdmin();
     const OUString& rName = GetLayerTabControl()->GetPageText(GetLayerTabControl()->GetCurPageId());
     OUString aString(SD_RESSTR(STR_ASK_DELETE_LAYER));
diff --git a/sd/source/ui/view/drviews7.cxx b/sd/source/ui/view/drviews7.cxx
index ee80d43..7987b7a 100644
--- a/sd/source/ui/view/drviews7.cxx
+++ b/sd/source/ui/view/drviews7.cxx
@@ -891,20 +891,27 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet )
     // is it allowed to delete the current layer?
     if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_DELETE_LAYER ) )
     {
-        sal_uInt16        nCurrentLayer = GetLayerTabControl()->GetCurPageId();
-        const OUString& rName = GetLayerTabControl()->GetPageText(nCurrentLayer);
+        if(GetLayerTabControl()) // #i87182#
+        {
+            sal_uInt16 nCurrentLayer = GetLayerTabControl()->GetCurPageId();
+            const OUString& rName = GetLayerTabControl()->GetPageText(nCurrentLayer);
 
-        sal_Bool bDisableIt = !IsLayerModeActive();
-        bDisableIt |= (rName == SD_RESSTR(STR_LAYER_LAYOUT));
-        bDisableIt |= (rName == SD_RESSTR(STR_LAYER_BCKGRND));
-        bDisableIt |= (rName == SD_RESSTR(STR_LAYER_BCKGRNDOBJ));
-        bDisableIt |= (rName == SD_RESSTR(STR_LAYER_CONTROLS));
-        bDisableIt |= (rName == SD_RESSTR(STR_LAYER_MEASURELINES));
+            sal_Bool bDisableIt = !IsLayerModeActive();
+            bDisableIt |= (rName == SD_RESSTR(STR_LAYER_LAYOUT));
+            bDisableIt |= (rName == SD_RESSTR(STR_LAYER_BCKGRND));
+            bDisableIt |= (rName == SD_RESSTR(STR_LAYER_BCKGRNDOBJ));
+            bDisableIt |= (rName == SD_RESSTR(STR_LAYER_CONTROLS));
+            bDisableIt |= (rName == SD_RESSTR(STR_LAYER_MEASURELINES));
 
-        if (bDisableIt)
+            if (bDisableIt)
+            {
+                rSet.DisableItem(SID_DELETE_LAYER);
+                rSet.DisableItem(SID_RENAMELAYER);
+            }
+        }
+        else
         {
-            rSet.DisableItem(SID_DELETE_LAYER);
-            rSet.DisableItem(SID_RENAMELAYER);
+            OSL_ENSURE(false, "No LayerTabBar (!)");
         }
     }
 
diff --git a/sd/source/ui/view/drviewsb.cxx b/sd/source/ui/view/drviewsb.cxx
index 26dc337..879e78f 100644
--- a/sd/source/ui/view/drviewsb.cxx
+++ b/sd/source/ui/view/drviewsb.cxx
@@ -166,6 +166,12 @@ void DrawViewShell::ModifyLayer (
     bool bIsLocked,
     bool bIsPrintable)
 {
+    if(!GetLayerTabControl()) // #i87182#
+    {
+        OSL_ENSURE(false, "No LayerTabBar (!)");
+        return;
+    }
+
     if( pLayer )
     {
         const sal_uInt16 nPageCount = GetLayerTabControl()->GetPageCount();
commit c1820243e9bbff8374481df32bd6952612267936
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Jun 4 16:17:28 2014 +0100

    Resolves: fdo#78477 ensure offset + sizeof(value) is in bounds
    
    a) ptr is just added to offset, so move addition into 2nd arg
    
    Change-Id: Ia3e8145c69324f19aeec8b0dd97284ec382d20d7
    (cherry picked from commit 57ef375bed4480bbedc799aca274a6bd26745008)
    
    b) sort in order of increasing offset
    
    Change-Id: I0d2c880438f47f4527037d7ffaf77cf142d24751
    (cherry picked from commit 95e92889d3fb0e8a85cefdeb07a02e57130a9799)
    
    c) fdo#78477 ensure offset + sizeof(value) is in bounds
    
    check that largest offset + value to read is inside available space
    
    Change-Id: I4feac37bdfbae5061b3b75ddf44bb20fc5904656
    (cherry picked from commit c888c211072f23cfb4cc488c641d8d822f930a33)
    (cherry picked from commit 891e0f76350890a4dd4331820bde8c118ac06ab0)
    Reviewed-on: https://gerrit.libreoffice.org/9641
    Tested-by: Michael Stahl <mstahl at redhat.com>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>

diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx
index 868e970..76f8abf 100644
--- a/vcl/source/fontsubset/sft.cxx
+++ b/vcl/source/fontsubset/sft.cxx
@@ -45,6 +45,7 @@
 #ifndef NO_TYPE3              /* include CreateT3FromTTGlyphs() */
 #include <rtl/crc.h>
 #endif
+#include <rtl/ustring.hxx>
 
 #include <osl/endian.h>
 #include <algorithm>
@@ -2649,12 +2650,22 @@ int GetTTNameRecords(TrueTypeFont *ttf, NameRecord **nr)
     NameRecord* rec = (NameRecord*)calloc(n, sizeof(NameRecord));
 
     for (i = 0; i < n; i++) {
-        int nStrOffset = GetUInt16(table + 6, 10 + 12 * i, 1);
-        rec[i].platformID = GetUInt16(table + 6, 12 * i, 1);
-        rec[i].encodingID = GetUInt16(table + 6, 2 + 12 * i, 1);
-        rec[i].languageID = GetUInt16(table + 6, 4 + 12 * i, 1);
-        rec[i].nameID = GetUInt16(table + 6, 6 + 12 * i, 1);
-        rec[i].slen = GetUInt16(table + 6, 8 + 12 * i, 1);
+        int nLargestFixedOffsetPos = 6 + 10 + 12 * i;
+        int nMinSize = nLargestFixedOffsetPos + sizeof(sal_uInt16);
+        if (nMinSize > nTableSize)
+        {
+            SAL_WARN( "vcl.fonts", "Font " << OUString::createFromAscii(ttf->fname) << " claimed to have "
+                << n << " name records, but only space for " << i);
+            n = i;
+            break;
+        }
+
+        rec[i].platformID = GetUInt16(table, 6 + 0 + 12 * i, 1);
+        rec[i].encodingID = GetUInt16(table, 6 + 2 + 12 * i, 1);
+        rec[i].languageID = GetUInt16(table, 6 + 4 + 12 * i, 1);
+        rec[i].nameID = GetUInt16(table, 6 + 6 + 12 * i, 1);
+        rec[i].slen = GetUInt16(table, 6 + 8 + 12 * i, 1);
+        int nStrOffset = GetUInt16(table, nLargestFixedOffsetPos, 1);
         if (rec[i].slen) {
             if( nStrBase+nStrOffset+rec[i].slen >= nTableSize ) {
                 rec[i].sptr = 0;
commit 9c4624f53961dc4f6822eb2dc2055dbefd7d1f4b
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Sun Jun 1 08:40:43 2014 +0100

    fdo79368 Don't process overflow menu items twice.
    
    We reuse the toolbox overflow menu for toolbarmanager's context
    menu -- toolbarmanger previously added its menu listener to the
    toolboxes menu permanently, meaning that it would try to handle
    overflow menu items (in addition to the context menu items which
    it should handle), instead we should only add the listener when
    we are actually using the menu as a context menu.
    
    Perhaps it would be better in the long run to actually use fully separate
    menus instead, and ask toolbox to specifically add its items to that
    rather than trying to hack the context menu on top of the overflow menu?
    
    Change-Id: Iecface2c6eae9ab79dbcdb25ffdbaf446e2885ea
    (cherry picked from commit 1ae89d189200c1e351a396a3f02612b84a69985f)
    Reviewed-on: https://gerrit.libreoffice.org/9602
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx
index 4137de3..98e0446 100644
--- a/framework/source/uielement/toolbarmanager.cxx
+++ b/framework/source/uielement/toolbarmanager.cxx
@@ -233,8 +233,6 @@ ToolBarManager::ToolBarManager( const Reference< XComponentContext >& rxContext,
     m_pToolBar->SetCommandHdl( LINK( this, ToolBarManager, Command ) );
     m_pToolBar->SetMenuType( nMenuType );
     m_pToolBar->SetMenuButtonHdl( LINK( this, ToolBarManager, MenuButton ) );
-    m_pToolBar->GetMenu()->SetSelectHdl( LINK( this, ToolBarManager, MenuSelect ) );
-    m_pToolBar->GetMenu()->SetDeactivateHdl( LINK( this, ToolBarManager, MenuDeactivate ) );
 
     // set name for testtool, the useful part is after the last '/'
     sal_Int32 idx = rResourceName.lastIndexOf('/');
@@ -1795,10 +1793,24 @@ IMPL_LINK( ToolBarManager, Command, CommandEvent*, pCmdEvt )
     ::PopupMenu * pMenu = GetToolBarCustomMenu(m_pToolBar);
     if (pMenu)
     {
+        // We only want to handle events for the context menu, but not events
+        // on the toolbars overflow menu, hence we should only receive events
+        // from the toolbox menu when we are actually showing it as our context
+        // menu (the same menu retrieved with  GetMenu() is reused for both the
+        // overflow and context menus). If we set these Hdls permanently rather
+        // than just when the context menu is showing, then events are duplicated
+        // when the menu is being used as an overflow menu.
+        m_pToolBar->GetMenu()->SetSelectHdl( LINK( this, ToolBarManager, MenuSelect ) );
+        m_pToolBar->GetMenu()->SetDeactivateHdl( LINK( this, ToolBarManager, MenuDeactivate ) );
+
         // make sure all disabled entries will be shown
         pMenu->SetMenuFlags( pMenu->GetMenuFlags() | MENU_FLAG_ALWAYSSHOWDISABLEDENTRIES );
         ::Point aPoint( pCmdEvt->GetMousePosPixel() );
         pMenu->Execute( m_pToolBar, aPoint );
+
+        // Unlink our listeners again -- see above for why.
+        m_pToolBar->GetMenu()->SetSelectHdl( Link() );
+        m_pToolBar->GetMenu()->SetDeactivateHdl( Link() );
     }
 
     return 0;
diff --git a/vcl/source/window/toolbox2.cxx b/vcl/source/window/toolbox2.cxx
index af7d38c..ba273c3 100644
--- a/vcl/source/window/toolbox2.cxx
+++ b/vcl/source/window/toolbox2.cxx
@@ -2185,7 +2185,13 @@ void ToolBox::ImplExecuteCustomMenu()
             // call button handler to allow for menu customization
             mpData->maMenuButtonHdl.Call( this );
 
-        // register handler
+        // We specifically only register this event listener when executing our
+        // overflow menu (and remove it directly afterwards), as the same menu
+        // is reused for both the overflow menu (as managed here in ToolBox),
+        // but also by ToolBarManager for its context menu. If we leave event
+        // listeners alive beyond when the menu is showing in the desired mode
+        // then duplicate events can happen as the context menu "duplicates"
+        // items from the overflow menu, which both listeners would then act on.
         GetMenu()->AddEventListener( LINK( this, ToolBox, ImplCustomMenuListener ) );
 
         // make sure all disabled entries will be shown
commit 283774b2cc515ba5fa65f924d460736b9a4151a4
Author: Noel Grandin <noel at peralex.com>
Date:   Fri May 30 13:02:20 2014 +0200

    deb#749592 mysql-connector doesn't work with remote connections
    
    and also
    fdo#77584 mysql-connector doesn't work over SSH tunnel
    
    Not sure exactly how this got broken, I suspect that the UI code
    has started unconditionally passing down the properties, just filling
    them with empty spaces for the unused ones.
    
    Anyhow, this appears to fix the problem.
    
    Cherry-picked from 6b50e21473e7d2b24b5c609d8a1c31f27644d842
    
    Change-Id: I7ac2a0d6bae610f47d2a28daa9beb3ef0e2dbb52
    Reviewed-on: https://gerrit.libreoffice.org/9565
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    Reviewed-on: https://gerrit.libreoffice.org/9643

diff --git a/mysqlc/source/mysqlc_connection.cxx b/mysqlc/source/mysqlc_connection.cxx
index 8816cb2..4a178b3 100644
--- a/mysqlc/source/mysqlc_connection.cxx
+++ b/mysqlc/source/mysqlc_connection.cxx
@@ -158,10 +158,10 @@ void OConnection::construct(const OUString& url, const Sequence< PropertyValue >
             OSL_VERIFY( pIter->Value >>= aPass );
         } else if (pIter->Name.equalsAscii("LocalSocket")) {
             OSL_VERIFY( pIter->Value >>= sUnixSocket );
-            unixSocketPassed = true;
+            unixSocketPassed = !sUnixSocket.isEmpty();
         } else if (pIter->Name.equalsAscii("NamedPipe")) {
             OSL_VERIFY( pIter->Value >>= sNamedPipe );
-            namedPipePassed = true;
+            namedPipePassed = !sNamedPipe.isEmpty();
         } else if ( pIter->Name.equalsAscii("PublicConnectionURL")) {
             OSL_VERIFY( pIter->Value >>= m_settings.connectionURL );
         } else if ( pIter->Name.equalsAscii("NewURL")) {    // legacy name for "PublicConnectionURL"
commit 306282690d67cf8b3d4114d70cf6c4e13886e54c
Author: Julien Nabet <serval2412 at yahoo.fr>
Date:   Thu Jun 5 07:28:32 2014 +0200

    Resolves fdo#75971 Crash when invoking "Insert > Names > Create"
    
    Cherry-pick 37d7d115dd346ba7a713a5a18d90fc48a0d35072
    + 4f24e3d480bb88a568de10b4d81116766b136c91
    
    Change-Id: Ieb3af12e120cd8f17ee659406d7d0e46f05fba7d
    Reviewed-on: https://gerrit.libreoffice.org/9645
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index b5510f6..c4e6c56 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -7801,7 +7801,7 @@ void ScInterpreter::ScLeft()
         if (nParamCount == 2)
         {
             double nVal = ::rtl::math::approxFloor(GetDouble());
-            if ( nVal < 0.0 || nVal > STRING_MAXLEN )
+            if ( rtl::math::isNan(nVal) || nVal < 0.0 || nVal > STRING_MAXLEN )
             {
                 PushIllegalArgument();
                 return ;
@@ -7909,7 +7909,7 @@ void ScInterpreter::ScRightB()
         if (nParamCount == 2)
         {
             double nVal = ::rtl::math::approxFloor(GetDouble());
-            if ( nVal < 0.0 || nVal > STRING_MAXLEN )
+            if ( rtl::math::isNan(nVal) || nVal < 0.0 || nVal > STRING_MAXLEN )
             {
                 PushIllegalArgument();
                 return ;
commit 33aefc7d578965a2a9366d4366c2e1f8dd2e5875
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Jun 3 20:18:59 2014 +0200

    RTF import: fix handling of \loch \hich \dbch \ltrch \rtlch
    
    The logic is not immediately obvious from the RTF spec; let's do what
    the editengine RTF import does, but without the unnecessary complexity.
    
    (cherry picked from commit 36246aa9fb57c9fe4e546c91a8274d8828b1424e)
    
    Conflicts:
    	writerfilter/source/rtftok/rtfdocumentimpl.cxx
    	writerfilter/source/rtftok/rtfdocumentimpl.hxx
    
    Change-Id: I60e69130e6e5aed1f5d237f64b1656c3141e402a
    Reviewed-on: https://gerrit.libreoffice.org/9634
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index f1ac1d1..920b19f 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -2626,8 +2626,10 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
             break;
         case RTF_LTRCH:
             // dmapper does not support this.
+            m_aStates.top().isRightToLeft = false;
             break;
         case RTF_RTLCH:
+            m_aStates.top().isRightToLeft = true;
             if (m_aDefaultState.nCurrentEncoding == RTL_TEXTENCODING_MS_1255)
                 m_aStates.top().nCurrentEncoding = m_aDefaultState.nCurrentEncoding;
             break;
@@ -3187,11 +3189,20 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
     {
         case RTF_F:
         case RTF_AF:
-            if (nKeyword == RTF_F)
-                nSprm = NS_sprm::LN_CRgFtc0;
+            if (m_aStates.top().isRightToLeft
+                || m_aStates.top().eRunType == RTFParserState::HICH)
+            {
+                nSprm = NS_sprm::LN_CRgFtc2;
+            }
+            else if (m_aStates.top().eRunType == RTFParserState::DBCH)
+            {
+                nSprm = NS_sprm::LN_CRgFtc1;
+            }
             else
-                nSprm = (m_aStates.top().eRunType == RTFParserState::HICH
-                    ? NS_sprm::LN_CRgFtc1 : NS_sprm::LN_CRgFtc2);
+            {
+                assert(m_aStates.top().eRunType == RTFParserState::LOCH);
+                nSprm = NS_sprm::LN_CRgFtc0;
+            }
             if (m_aStates.top().nDestinationState == DESTINATION_FONTTABLE || m_aStates.top().nDestinationState == DESTINATION_FONTENTRY)
             {
                 m_aFontIndexes.push_back(nParam);
@@ -3215,7 +3226,8 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
                 int nFontIndex = getFontIndex(nParam);
                 RTFValue::Pointer_t pValue(new RTFValue(nFontIndex));
                 m_aStates.top().aCharacterSprms.set(nSprm, pValue);
-                m_aStates.top().nCurrentEncoding = getEncoding(nFontIndex);
+                if (nKeyword == RTF_F)
+                    m_aStates.top().nCurrentEncoding = getEncoding(nFontIndex);
             }
             break;
         case RTF_RED:
@@ -5198,6 +5210,7 @@ RTFParserState::RTFParserState(RTFDocumentImpl *pDocumentImpl)
     aDrawingObject(),
     aFrame(this),
     eRunType(LOCH),
+    isRightToLeft(false),
     nYear(0),
     nMonth(0),
     nDay(0),
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index a6e4406..07571d2 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -255,6 +255,8 @@ namespace writerfilter {
 
                 /// CJK or CTL?
                 enum { LOCH, HICH, DBCH } eRunType;
+                /// ltrch or rtlch
+                bool isRightToLeft;
 
                 // Info group.
                 int nYear;
commit 99aaac23717ccddfae4e3917325a1464c152295d
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Jun 3 19:32:10 2014 +0200

    fdo#79384: replace the work-around with a different one
    
    Word will reject Shift-JIS following \loch, but apparently OOo could read
    and (worse) write such documents, so accept Shift-JIS regardless of run
    charset type.
    
    (cherry picked from commit d71387ca81b61416b9a7b82cd6cf67d496b81fc2)
    
    Conflicts:
    	writerfilter/source/rtftok/rtfdocumentimpl.cxx
    
    Change-Id: Ib181956e9f218548a52037dd76fa1d3ecdc006bd
    Reviewed-on: https://gerrit.libreoffice.org/9633
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/qa/core/data/rtf/pass/fdo79384.rtf b/sw/qa/core/data/rtf/pass/fdo79384.rtf
index 84875a9..c9d6b33 100644
--- a/sw/qa/core/data/rtf/pass/fdo79384.rtf
+++ b/sw/qa/core/data/rtf/pass/fdo79384.rtf
@@ -1,4 +1,5 @@
 {\rtf1
+{\fonttbl{\f5\fnil\fprq0\fcharset128 OpenSymbol;}}
 {\stylesheet
 {\*\cs35\snext35\hich\af5\dbch\af5\loch\f5 „M„p„‚„{„u„‚„ „ƒ„„y„ƒ„{„p;}
 }
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 9946de2..f1ac1d1 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -940,11 +940,8 @@ int RTFDocumentImpl::resolveChars(char ch)
     bool bUnicodeChecked = false;
     bool bSkipped = false;
 
-    // Workaround for buggy input: if we're inside a style entry, then ignore
-    // the fact that '{' without a matching '}' is invalid.
-    bool bStyleEntry = m_aStates.top().nDestinationState == DESTINATION_STYLEENTRY;
-
-    while(!Strm().IsEof() && (m_aStates.top().nInternalState == INTERNAL_HEX || ((ch != '{' || bStyleEntry) && ch != '}' && ch != '\\')))
+    while (!Strm().IsEof() && (m_aStates.top().nInternalState == INTERNAL_HEX
+                               || (ch != '{' && ch != '}' && ch != '\\')))
     {
         if (m_aStates.top().nInternalState == INTERNAL_HEX || (ch != 0x0d && ch != 0x0a))
         {
@@ -968,9 +965,12 @@ int RTFDocumentImpl::resolveChars(char ch)
         if (m_aStates.top().nInternalState == INTERNAL_HEX)
             break;
 
-        if (RTFParserState::DBCH == m_aStates.top().eRunType &&
-            RTL_TEXTENCODING_MS_932 == m_aStates.top().nCurrentEncoding)
+        if (RTL_TEXTENCODING_MS_932 == m_aStates.top().nCurrentEncoding)
         {
+            // fdo#79384: Word will reject Shift-JIS following \loch
+            // but apparently OOo could read and (worse) write such documents
+            SAL_INFO_IF(m_aStates.top().eRunType != RTFParserState::DBCH,
+                "writerfilter.rtftok", "invalid Shift-JIS without DBCH");
             unsigned char uch = ch;
             if ((uch >= 0x80 && uch <= 0x9F) || uch >= 0xE0)
             {
commit 0cadca7ebb99210adb11b4b8bb4d253ac83768cc
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Jun 2 23:57:13 2014 +0200

    fdo#79384: RTF import: fix literal Shift-JIS text
    
    This is a variable-length encoding, and the second byte may be a RTF
    syntax character like \, {, }.
    
    (cherry picked from commit 061190a62fcdbfb3a0b266d5afffbd257a3e692e)
    
    Conflicts:
    	writerfilter/source/rtftok/rtfdocumentimpl.cxx
    	writerfilter/source/rtftok/rtfdocumentimpl.hxx
    
    Change-Id: I813ccafda18388af3bf05eb7ce9a0253c627b1c4
    Reviewed-on: https://gerrit.libreoffice.org/9632
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/qa/extras/rtfimport/data/fdo79384.rtf b/sw/qa/extras/rtfimport/data/fdo79384.rtf
new file mode 100644
index 0000000..2a90085
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/fdo79384.rtf
@@ -0,0 +1,9 @@
+{\rtf1\ansi
+{\fonttbl{\f5\fnil\fprq0\fcharset128 OpenSymbol{\*\falt Arial Unicode MS};}}
+
+\pard\plain
+
+\dbch\f5 „M„p„‚„{„u„‚„ „ƒ„„y„ƒ„{„p
+„}„\
+
+\par }
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index a5c8ffd..345f205 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -286,6 +286,14 @@ DECLARE_RTFIMPORT_TEST(testN751020, "n751020.rtf")
     CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(200)), getProperty<sal_Int32>(xParaEnum->nextElement(), "ParaBottomMargin"));
 }
 
+DECLARE_RTFIMPORT_TEST(testFdo79384, "fdo79384.rtf")
+{
+    uno::Reference<text::XTextRange> xTextRange = getRun(getParagraph(1), 1);
+
+    CPPUNIT_ASSERT_EQUAL(OUString("Маркеры спискамЫ", 31, RTL_TEXTENCODING_UTF8),
+            xTextRange->getString());
+}
+
 DECLARE_RTFIMPORT_TEST(testFdo47326, "fdo47326.rtf")
 {
     // This was 15 only, as \super buffered text, then the contents of it got lost.
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index e8316ff..9946de2 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -963,9 +963,33 @@ int RTFDocumentImpl::resolveChars(char ch)
                 m_aStates.top().nCharsToSkip--;
             }
         }
+
         // read a single char if we're in hex mode
         if (m_aStates.top().nInternalState == INTERNAL_HEX)
             break;
+
+        if (RTFParserState::DBCH == m_aStates.top().eRunType &&
+            RTL_TEXTENCODING_MS_932 == m_aStates.top().nCurrentEncoding)
+        {
+            unsigned char uch = ch;
+            if ((uch >= 0x80 && uch <= 0x9F) || uch >= 0xE0)
+            {
+                // read second byte of 2-byte Shift-JIS - may be \ { }
+                Strm() >> ch;
+                if (m_aStates.top().nCharsToSkip == 0)
+                {
+                    assert(bUnicodeChecked);
+                    aBuf.append(ch);
+                }
+                else
+                {
+                    assert(bSkipped);
+                    // anybody who uses \ucN with Shift-JIS is insane
+                    m_aStates.top().nCharsToSkip--;
+                }
+            }
+        }
+
         Strm() >> ch;
     }
     if (m_aStates.top().nInternalState != INTERNAL_HEX && !Strm().IsEof())
@@ -2747,12 +2771,13 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
             break;
         case RTF_LOCH:
             // Noop, dmapper detects this automatically.
+            m_aStates.top().eRunType = RTFParserState::LOCH;
             break;
         case RTF_HICH:
-            m_aStates.top().bIsCjk = true;
+            m_aStates.top().eRunType = RTFParserState::HICH;
             break;
         case RTF_DBCH:
-            m_aStates.top().bIsCjk = false;
+            m_aStates.top().eRunType = RTFParserState::DBCH;
             break;
         case RTF_TITLEPG:
             {
@@ -3165,7 +3190,8 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
             if (nKeyword == RTF_F)
                 nSprm = NS_sprm::LN_CRgFtc0;
             else
-                nSprm = (m_aStates.top().bIsCjk ? NS_sprm::LN_CRgFtc1 : NS_sprm::LN_CRgFtc2);

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list