[Libreoffice-commits] .: 4 commits - filter/inc filter/source oox/inc oox/prj oox/source

Noel Power noelp at kemper.freedesktop.org
Fri Nov 5 09:47:08 PDT 2010


 filter/inc/filter/msfilter/msocximex.hxx |  379 +----
 filter/source/msfilter/msocximex.cxx     | 2251 +++++++++++++++----------------
 filter/source/msfilter/msvbahelper.cxx   |   15 
 oox/inc/oox/helper/containerhelper.hxx   |   14 
 oox/inc/oox/ole/axcontrol.hxx            |   16 
 oox/inc/oox/ole/vbacontrol.hxx           |   24 
 oox/inc/oox/ole/vbahelper.hxx            |    1 
 oox/inc/oox/ole/vbamodule.hxx            |   25 
 oox/inc/oox/ole/vbaproject.hxx           |   32 
 oox/inc/oox/ole/vbaprojectfilter.hxx     |   71 
 oox/inc/oox/xls/drawingfragment.hxx      |    5 
 oox/inc/oox/xls/excelfilter.hxx          |   15 
 oox/prj/d.lst                            |    1 
 oox/source/core/facreg.cxx               |    6 
 oox/source/ole/axcontrol.cxx             |  201 ++
 oox/source/ole/makefile.mk               |    3 
 oox/source/ole/vbacontrol.cxx            |  362 ++--
 oox/source/ole/vbamodule.cxx             |  189 ++
 oox/source/ole/vbaproject.cxx            |   69 
 oox/source/ole/vbaprojectfilter.cxx      |  104 +
 oox/source/token/properties.txt          |    3 
 oox/source/token/tokenmap.cxx            |    2 
 oox/source/vml/vmldrawing.cxx            |    2 
 oox/source/xls/drawingfragment.cxx       |  111 -
 oox/source/xls/excelfilter.cxx           |   92 +
 oox/source/xls/workbookhelper.cxx        |    1 
 26 files changed, 2233 insertions(+), 1761 deletions(-)

New commits:
commit a01b7cce9d815be3a4f1ec62476c70100f058320
Merge: 8539348... fe3420c...
Author: Noel Power <noel.power at novell.com>
Date:   Fri Nov 5 11:38:42 2010 +0000

    Merge branch 'master' of ssh://git.freedesktop.org/git/libreoffice/filters

commit 8539348693db0bde980d0ce5f91256da38487824
Author: Noel Power <noel.power at novell.com>
Date:   Wed Nov 3 12:48:37 2010 +0000

    tweak after rebase from master

diff --git a/filter/source/msfilter/msocximex.cxx b/filter/source/msfilter/msocximex.cxx
index ecf63c7..1118363 100644
--- a/filter/source/msfilter/msocximex.cxx
+++ b/filter/source/msfilter/msocximex.cxx
@@ -5082,12 +5082,6 @@ sal_Bool HTML_TextBox::ReadFontData(SotStorageStream * /*pS*/)
   return sal_True;
 }
 
-sal_Bool HTML_TextBox::ReadFontData(SotStorageStream *pS)
-{
-  return sal_True;
-}
-
-
 // Doesn't really read anything but just skips the
 // record.
 sal_Bool OCX_TabStrip::Read(SotStorageStream *pS)
commit 08ef348255c391069bfc6cae377b877c337b48bb
Author: Noel Power <noel.power at novell.com>
Date:   Tue Nov 2 16:56:11 2010 +0000

    add new uno based filter service for vba project

diff --git a/oox/inc/oox/ole/vbaprojectfilter.hxx b/oox/inc/oox/ole/vbaprojectfilter.hxx
new file mode 100644
index 0000000..6ccd498
--- /dev/null
+++ b/oox/inc/oox/ole/vbaprojectfilter.hxx
@@ -0,0 +1,71 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org.  If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef OOX_OLE_VBAPROJECTFILTER_HXX
+#define OOX_OLE_VBAPROJECTFILTER_HXX
+
+#include "oox/core/binaryfilterbase.hxx"
+
+namespace oox {
+namespace ole {
+
+// ============================================================================
+
+class VbaProjectFilterBase : public ::oox::core::BinaryFilterBase
+{
+public:
+    explicit            VbaProjectFilterBase(
+                            const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxGlobalFactory,
+                            const ::rtl::OUString& rAppName,
+                            const ::rtl::OUString& rStorageName );
+
+    virtual bool        importDocument() throw();
+    virtual bool        exportDocument() throw();
+
+private:
+    ::rtl::OUString     maAppName;
+    ::rtl::OUString     maStorageName;
+};
+
+// ============================================================================
+
+class WordVbaProjectFilter : public VbaProjectFilterBase
+{
+public:
+    explicit            WordVbaProjectFilter(
+                            const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxGlobalFactory );
+
+private:
+    virtual ::rtl::OUString implGetImplementationName() const;
+};
+
+// ============================================================================
+
+} // namespace ole
+} // namespace oox
+
+#endif
diff --git a/oox/source/ole/vbaprojectfilter.cxx b/oox/source/ole/vbaprojectfilter.cxx
new file mode 100644
index 0000000..82cba31
--- /dev/null
+++ b/oox/source/ole/vbaprojectfilter.cxx
@@ -0,0 +1,104 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org.  If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "oox/ole/vbaprojectfilter.hxx"
+
+#include "oox/ole/vbaproject.hxx"
+
+namespace oox {
+namespace ole {
+
+// ============================================================================
+
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::uno;
+
+using ::rtl::OUString;
+
+// ============================================================================
+
+VbaProjectFilterBase::VbaProjectFilterBase( const Reference< XMultiServiceFactory >& rxGlobalFactory,
+        const OUString& rAppName, const OUString& rStorageName ) :
+    BinaryFilterBase( rxGlobalFactory ),
+    maAppName( rAppName ),
+    maStorageName( rStorageName )
+{
+}
+
+bool VbaProjectFilterBase::importDocument() throw()
+{
+    StorageRef xVbaPrjStrg = openSubStorage( maStorageName, false );
+    if( xVbaPrjStrg.get() && xVbaPrjStrg->isStorage() )
+    {
+        VbaProject aVbaProject( getGlobalFactory(), getModel(), maAppName );
+        aVbaProject.importVbaProject( *xVbaPrjStrg, getGraphicHelper() );
+        return true;
+    }
+    return false;
+}
+
+bool VbaProjectFilterBase::exportDocument() throw()
+{
+    return false;
+}
+
+// ============================================================================
+
+OUString SAL_CALL WordVbaProjectFilter_getImplementationName() throw()
+{
+    return CREATE_OUSTRING( "com.sun.star.comp.oox.WordVbaProjectFilter" );
+}
+
+Sequence< OUString > SAL_CALL WordVbaProjectFilter_getSupportedServiceNames() throw()
+{
+    Sequence< OUString > aSeq( 1 );
+    aSeq[ 0 ] = CREATE_OUSTRING( "com.sun.star.comp.oox.WordVBAProjectFilter" );
+    return aSeq;
+}
+
+Reference< XInterface > SAL_CALL WordVbaProjectFilter_createInstance(
+        const Reference< XMultiServiceFactory >& rxGlobalFactory ) throw( Exception )
+{
+    return static_cast< ::cppu::OWeakObject* >( new WordVbaProjectFilter( rxGlobalFactory ) );
+}
+
+// ----------------------------------------------------------------------------
+
+WordVbaProjectFilter::WordVbaProjectFilter( const Reference< XMultiServiceFactory >& rxGlobalFactory ) :
+    VbaProjectFilterBase( rxGlobalFactory, CREATE_OUSTRING( "Writer" ), CREATE_OUSTRING( "Macros" ) )
+{
+}
+
+OUString WordVbaProjectFilter::implGetImplementationName() const
+{
+    return WordVbaProjectFilter_getImplementationName();
+}
+
+// ============================================================================
+
+} // namespace ole
+} // namespace oox
commit c6f02f19a0ee610143710b4527565e3ff16e6d15
Author: Noel Power <noel.power at novell.com>
Date:   Tue Nov 2 15:59:53 2010 +0000

    initial import of latest cws container_controls

diff --git a/filter/inc/filter/msfilter/msocximex.hxx b/filter/inc/filter/msfilter/msocximex.hxx
index 1d2be8b..4f08006 100644
--- a/filter/inc/filter/msfilter/msocximex.hxx
+++ b/filter/inc/filter/msfilter/msocximex.hxx
@@ -2,7 +2,7 @@
 /*************************************************************************
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * Copyright 2000, 2010 Oracle and/or its affiliates.
  *
  * OpenOffice.org - a multi-platform office productivity suite
@@ -294,6 +294,8 @@ public:
     rtl::OUString msCtrlSource;
     rtl::OUString msRowSource;
         SfxObjectShell *pDocSh;
+    ::rtl::OUString sImageUrl;
+    com::sun::star::uno::Reference< com::sun::star::graphic::XGraphicObject> mxGrfObj;
 protected:
 
     sal_uInt32 ImportColor(sal_uInt32 nColorCode) const;
@@ -416,22 +418,23 @@ public:
 
     sal_uInt8 pPictureHeader[20];
     sal_uInt32 nPictureLen;
-    ::rtl::OUString sImageUrl;
-	com::sun::star::uno::Reference< com::sun::star::graphic::XGraphicObject> mxGrfObj;
 
 };
 
 class OCX_TabStrip : public OCX_Control
 {
 public:
-    OCX_TabStrip() : OCX_Control( rtl::OUString::createFromAscii("TabStrip")) {}
+    OCX_TabStrip() : OCX_Control( rtl::OUString::createFromAscii("TabStrip")), nIdentifier(0), nFixedAreaLen(0), nNumTabs(0), bHasTabs(true) {}
+
         virtual sal_Bool ReadFontData(SotStorageStream *pS);
         virtual sal_Bool Read(SotStorageStream *pS);
 
+    std::vector< rtl::OUString > msItems;
     sal_uInt16	nIdentifier;
     sal_uInt16	nFixedAreaLen;
     sal_uInt8	pBlockFlags[4];
-    sal_uInt16	nNumTabs;
+    sal_Int32	nNumTabs;
+    bool        bHasTabs;
 };
 
 class OCX_Image : public OCX_Control
@@ -465,8 +468,6 @@ public:
     sal_uInt8	nSpecialEffect;
 
         bool bAutoSize;
-        ::rtl::OUString sImageUrl;
-		com::sun::star::uno::Reference< com::sun::star::graphic::XGraphicObject> mxGrfObj;
         sal_Bool Read(SotStorageStream *pS);
 
     using OCX_Control::Import; // to not hide the other two import methods
@@ -487,8 +488,7 @@ public:
 };
 struct ContainerRecord
 {
-    ContainerRecord():nTop(0), nLeft(0), nSubStorageId(0), nSubStreamLen(0), nTabPos(0), nTypeIdent(0), bVisible( true ) {}
-
+    ContainerRecord():nTop(0), nLeft(0), nSubStorageId(0), nSubStreamLen(0), nTabPos(0), nTypeIdent(0), bVisible( true ), bTabStop( true ) {}
     ::rtl::OUString cName;
     ::rtl::OUString controlTip;
     ::rtl::OUString sCtrlSource;
@@ -501,6 +501,7 @@ struct ContainerRecord
     sal_uInt16  nTabPos;
     sal_uInt16 nTypeIdent;
     bool bVisible;
+    bool bTabStop;
 };
 
 typedef std::vector<OCX_Control*>::iterator CtrlIterator;
@@ -509,44 +510,32 @@ typedef std::vector<OCX_Control*>  CtrlList;
 
 class OCX_OptionButton;
 
-class OCX_ContainerControl : public OCX_Control
+class OCX_ParentControl : public OCX_Control
 {
 public:
-    virtual ~OCX_ContainerControl();
-        // sub class will process the control specific information
-        // e.g frame or userform ( maybe tab, mulipage in the future )
-        // Base (this) class will process the container specific information
-        // e.g. the controls contained by this container
-        // will
-        // a) create the controls
-        // b) read the controls
-        // c) store these controls in a list for post processing
-        //     e.g. import
-        //
     virtual sal_Bool Read(SvStorageStream *pS);
-        // No Font record
     virtual sal_Bool ReadFontData(SvStorageStream* /*pS*/) { return sal_True; }
 
     using OCX_Control::Import; // to not hide the other two import methods
+
     virtual sal_Bool Import(com::sun::star::uno::Reference<
         com::sun::star::beans::XPropertySet> &rPropSet);
 
         SotStorageStreamRef getContainerStream() { return mContainerStream; }
 
+        SotStorageStreamRef getOStream() { return mContainedControlsStream; }
         virtual void ProcessControl( OCX_Control* pControl, SvStorageStream* pS, ContainerRecord& rec );
-        bool createFromContainerRecord( ContainerRecord& record,
+        bool createFromContainerRecord( const ContainerRecord& record,
             OCX_Control*& );
         SotStorageStreamRef getContainedControlsStream(){ return mContainedControlsStream; }
 protected:
-        // This class not meant to be instantiated
-        // needs to be subclassed
-    OCX_ContainerControl( SotStorageRef& parent,
+    OCX_ParentControl( SotStorageRef& parent,
             const ::rtl::OUString& storageName,
             const ::rtl::OUString& sN,
             const com::sun::star::uno::Reference<
-                com::sun::star::container::XNameContainer >  &rParent,
+            com::sun::star::container::XNameContainer >  &rDialog,
             OCX_Control* pParent = NULL );
-        rtl::OUString createSubStreamName( const sal_uInt32& subStorageID );
+    ~OCX_ParentControl();
 
         com::sun::star::uno::Reference<
                 com::sun::star::container::XNameContainer > mxParent;
@@ -555,84 +544,56 @@ protected:
         SotStorageRef mContainerStorage;
         SotStorageStreamRef mContainerStream;
         SotStorageStreamRef mContainedControlsStream;
-    sal_uInt32 nNoRecords;
-    sal_uInt32 nTotalLen;
-        sal_uInt32 containerType;
-
-private:
-        OCX_ContainerControl(); // not implemented
-        OCX_ContainerControl(const OCX_ContainerControl&); // not implemented
-};
-
-
-class OCX_MultiPage : public OCX_ContainerControl
-{
-public:
-    OCX_MultiPage( SotStorageRef& parent,
-            const ::rtl::OUString& storageName,
-            const ::rtl::OUString& sN,
-            const com::sun::star::uno::Reference<
-                com::sun::star::container::XNameContainer >  &rDialog, OCX_Control* pParent = NULL);
-    virtual ~OCX_MultiPage()
-    {
-        delete[] pCaption;
-        delete[] pIcon;
-        delete[] pPicture;
-    }
-    virtual sal_Bool Read(SvStorageStream *pS);
-
-    using OCX_ContainerControl::Import; // to not hide the other two import methods
-    virtual sal_Bool Import(com::sun::star::uno::Reference<
-        com::sun::star::beans::XPropertySet> &rPropSet);
-    virtual sal_Bool Import(com::sun::star::uno::Reference<
-        com::sun::star::container::XNameContainer>
-        &rDialog);
-        virtual void ProcessControl( OCX_Control* pControl, SvStorageStream* pS, ContainerRecord& rec );
-    /*sal_uInt8 for sal_uInt8 Word Struct*/
     sal_uInt16 nIdentifier;
     sal_uInt16 nFixedAreaLen;
     sal_uInt8	pBlockFlags[4];
 
-    sal_uInt32  fUnknown1;
+    sal_uInt32  nChildrenA;
+    sal_uInt32  nNextAvailableID;
+    sal_uInt32  nBooleanProperties;
+    sal_uInt32  nGroupCnt;
+    sal_uInt32  nZoom;
 
-    sal_uInt8	fUnknown2:1;
+    sal_uInt8	fUnknown1:1;
     sal_uInt8	fEnabled:1;
     sal_uInt8	fLocked:1;
     sal_uInt8	fBackStyle:1;
-    sal_uInt8	fUnknown3:4;
+    sal_uInt8	fUnknown2:4;
 
-    sal_uInt8	fUnknown4:8;
+    sal_uInt8	fUnknown3:8;
 
-    sal_uInt8	fUnknown5:7;
+    sal_uInt8	fUnknown4:7;
     sal_uInt8	fWordWrap:1;
 
-    sal_uInt8	fUnknown6:4;
+    sal_uInt8	fUnknown5:4;
     sal_uInt8	fAutoSize:1;
-    sal_uInt8	fUnknown7:3;
+    sal_uInt8	fUnknown6:3;
 
     sal_uInt32	nCaptionLen;
     sal_uInt16  nVertPos;
     sal_uInt16  nHorzPos;
-    sal_uInt8 	nMousePointer;
     sal_uInt32	nBorderColor;
-    sal_uInt32  fUnknown8;
-    sal_uInt32  fUnknown9;
+    sal_uInt32  nDrawBuffer;
+    sal_uInt32  nShapeCookie;
     sal_uInt8   nKeepScrollBarsVisible;
     sal_uInt8   nCycle;
-    sal_uInt16	nBorderStyle;
-    sal_uInt16	nSpecialEffect;
+    sal_uInt8	nBorderStyle;
+    sal_uInt8	nMousePointer;
+    sal_uInt8	nSpecialEffect;
     sal_uInt16	nPicture;
     sal_uInt8   nPictureAlignment;
     sal_uInt8   nPictureSizeMode;
     bool        bPictureTiling;
     sal_uInt16	nAccelerator;
     sal_uInt16	nIcon;
+    sal_uInt16	fUnknown7;
 
     char *pCaption;
 
     sal_uInt32 	nScrollWidth;
     sal_uInt32 	nScrollHeight;
-
+    sal_uInt32 	nScrollLeft;
+    sal_uInt32 	nScrollTop;
 
     sal_uInt8 pIconHeader[20];
     sal_uInt32  nIconLen;
@@ -640,253 +601,91 @@ public:
 
     sal_uInt8 pPictureHeader[20];
     sal_uInt32  nPictureLen;
-    sal_uInt8 *pPicture;
 private:
-        sal_Int32 mnCurrentPageStep;
-};
-
+     OCX_ParentControl(); // not implemented
+     OCX_ParentControl(const OCX_ParentControl&); // not implemented
 
+};
 
-class OCX_Page : public OCX_ContainerControl
+class OCX_Page;
+class OCX_MultiPage : public OCX_ParentControl
 {
 public:
-    OCX_Page( SotStorageRef& parentStorage,
+    OCX_MultiPage( SotStorageRef& parent,
             const ::rtl::OUString& storageName,
             const ::rtl::OUString& sN,
             const com::sun::star::uno::Reference<
-                com::sun::star::container::XNameContainer >  &rDialog, OCX_Control* parent = NULL);
-    virtual ~OCX_Page()
-    {
-        delete[] pCaption;
-        delete[] pIcon;
-        delete[] pPicture;
-    }
+                com::sun::star::container::XNameContainer >  &rDialog, OCX_Control* pParent = NULL);
+
     virtual sal_Bool Read(SvStorageStream *pS);
 
-    using OCX_ContainerControl::Import; // to not hide the other two import methods
+    using OCX_ParentControl::Import; // to not hide the other two import methods
     virtual sal_Bool Import(com::sun::star::uno::Reference<
-        com::sun::star::container::XNameContainer>
-        &rDialog);
-/*	virtual sal_Bool Import(com::sun::star::uno::Reference<
         com::sun::star::beans::XPropertySet> &rPropSet);
-*/
-    /*sal_uInt8 for sal_uInt8 Word Struct*/
-    sal_uInt16 nIdentifier;
-    sal_uInt16 nFixedAreaLen;
-    sal_uInt8	pBlockFlags[4];
-
-    sal_uInt32  fUnknown1;
-
-    sal_uInt8	fUnknown2:1;
-    sal_uInt8	fEnabled:1;
-    sal_uInt8	fLocked:1;
-    sal_uInt8	fBackStyle:1;
-    sal_uInt8	fUnknown3:4;
-
-    sal_uInt8	fUnknown4:8;
-
-    sal_uInt8	fUnknown5:7;
-    sal_uInt8	fWordWrap:1;
-
-    sal_uInt8	fUnknown6:4;
-    sal_uInt8	fAutoSize:1;
-    sal_uInt8	fUnknown7:3;
-
-    sal_uInt32	nCaptionLen;
-    sal_uInt16  nVertPos;
-    sal_uInt16  nHorzPos;
-    sal_uInt8 	nMousePointer;
-    sal_uInt32	nBorderColor;
-    sal_uInt32  fUnknown8;
-    sal_uInt32  fUnknown9;
-    sal_uInt8   nKeepScrollBarsVisible;
-    sal_uInt8   nCycle;
-    sal_uInt16	nBorderStyle;
-    sal_uInt16	nSpecialEffect;
-    sal_uInt16	nPicture;
-    sal_uInt8   nPictureAlignment;
-    sal_uInt8   nPictureSizeMode;
-    bool        bPictureTiling;
-    sal_uInt16	nAccelerator;
-    sal_uInt16	nIcon;
-
-    char *pCaption;
-
-    sal_uInt32 	nScrollWidth;
-    sal_uInt32 	nScrollHeight;
+    virtual void ProcessControl( OCX_Control* pControl, SvStorageStream* pS, ContainerRecord& rec );
+private:
+    sal_Int32 nActiveTab;
+    SotStorageStreamRef mXStream;
+    bool bHasTabs;
+    std::vector< rtl::OUString > sCaptions;
+    // order of Ids corrosponds to the order of captions above
+    std::vector< sal_Int32 > mPageIds;
+    std::hash_map< sal_Int32, OCX_Page* > idToPage;
+};
 
 
-    sal_uInt8 pIconHeader[20];
-    sal_uInt32  nIconLen;
-    sal_uInt8 *pIcon;
+class OCX_Page : public OCX_ParentControl
+{
+public:
+    OCX_Page( SotStorageRef& parentStorage,
+        sal_Int32 nID,
+        const ::rtl::OUString& sN,
+        const com::sun::star::uno::Reference<
+        com::sun::star::container::XNameContainer >  &rDialog, OCX_Control* parent = NULL);
+    virtual sal_Bool Read(SvStorageStream *pS);
 
-    sal_uInt8 pPictureHeader[20];
-    sal_uInt32  nPictureLen;
-    sal_uInt8 *pPicture;
+    using OCX_ParentControl::Import; // to not hide the other two import methods
+    virtual sal_Bool Import(com::sun::star::uno::Reference<
+        com::sun::star::beans::XPropertySet> &rPropSet);
+    rtl::OUString msTitle; // #FIXME we should use the existing caption
+    sal_Int32 mnID;
 private:
 };
 
 
-class OCX_Frame : public OCX_ContainerControl
+class OCX_Frame : public OCX_ParentControl
 {
 public:
     OCX_Frame( SotStorageRef& parent,
-            const ::rtl::OUString& storageName,
-            const ::rtl::OUString& sN,
-            const com::sun::star::uno::Reference<
-                com::sun::star::container::XNameContainer >  &rDialog, OCX_Control* pParent = NULL);
-    virtual ~OCX_Frame()
-    {
-        delete[] pCaption;
-        delete[] pIcon;
-        delete[] pPicture;
-    }
+        const ::rtl::OUString& storageName,
+        const ::rtl::OUString& sN,
+        const com::sun::star::uno::Reference<
+        com::sun::star::container::XNameContainer >  &rDialog, OCX_Control* pParent = NULL);
     virtual sal_Bool Read(SvStorageStream *pS);
 
-    using OCX_ContainerControl::Import; // to not hide the other two import methods
+    using OCX_ParentControl::Import; // to not hide the other two import methods
     virtual sal_Bool Import(com::sun::star::uno::Reference<
         com::sun::star::beans::XPropertySet> &rPropSet);
-
-    /*sal_uInt8 for sal_uInt8 Word Struct*/
-    sal_uInt16 nIdentifier;
-    sal_uInt16 nFixedAreaLen;
-    sal_uInt8	pBlockFlags[4];
-
-    sal_uInt32  fUnknown1;
-
-    sal_uInt8	fUnknown2:1;
-    sal_uInt8	fEnabled:1;
-    sal_uInt8	fLocked:1;
-    sal_uInt8	fBackStyle:1;
-    sal_uInt8	fUnknown3:4;
-
-    sal_uInt8	fUnknown4:8;
-
-    sal_uInt8	fUnknown5:7;
-    sal_uInt8	fWordWrap:1;
-
-    sal_uInt8	fUnknown6:4;
-    sal_uInt8	fAutoSize:1;
-    sal_uInt8	fUnknown7:3;
-
-    sal_uInt32	nCaptionLen;
-    sal_uInt16  nVertPos;
-    sal_uInt16  nHorzPos;
-    sal_uInt8 	nMousePointer;
-    sal_uInt32	nBorderColor;
-    sal_uInt32  fUnknown8;
-    sal_uInt32  fUnknown9;
-    sal_uInt8   nKeepScrollBarsVisible;
-    sal_uInt8   nCycle;
-    sal_uInt16	nBorderStyle;
-    sal_uInt16	nSpecialEffect;
-    sal_uInt16	nPicture;
-    sal_uInt8   nPictureAlignment;
-    sal_uInt8   nPictureSizeMode;
-    bool        bPictureTiling;
-    sal_uInt16	nAccelerator;
-    sal_uInt16	nIcon;
-
-    char *pCaption;
-
-    sal_uInt32 	nScrollWidth;
-    sal_uInt32 	nScrollHeight;
-    sal_uInt32 	nScrollLeft;
-    sal_uInt32 	nScrollTop;
-
-
-    sal_uInt8 pIconHeader[20];
-    sal_uInt32  nIconLen;
-    sal_uInt8 *pIcon;
-
-    sal_uInt8 pPictureHeader[20];
-    sal_uInt32  nPictureLen;
-    sal_uInt8 *pPicture;
-private:
 };
 
-class OCX_UserForm : public OCX_ContainerControl
+
+class OCX_UserForm : public OCX_ParentControl
 {
 public:
     OCX_UserForm( SotStorageRef& parent,
-            const ::rtl::OUString& storageName,
-            const ::rtl::OUString& sN,
-            const com::sun::star::uno::Reference<
-                com::sun::star::container::XNameContainer >  &rDialog,
-            const com::sun::star::uno::Reference<
-                com::sun::star::lang::XMultiServiceFactory >& rMsf);
-    ~OCX_UserForm()
-    {
-        delete[] pCaption;
-        delete[] pIcon;
-    }
-
-    virtual sal_Bool Read(SvStorageStream *pS);
-
-    using OCX_ContainerControl::Import; // to not hide the other two import methods
+        const ::rtl::OUString& storageName,
+        const ::rtl::OUString& sN,
+        const com::sun::star::uno::Reference<
+        com::sun::star::container::XNameContainer >  &rDialog,
+        const com::sun::star::uno::Reference<
+        com::sun::star::lang::XMultiServiceFactory >& rMsf);
+    using OCX_ParentControl::Import; // to not hide the other two import methods
     virtual sal_Bool Import( com::sun::star::uno::Reference<
         com::sun::star::container::XNameContainer>
         &rDialog);
-
-    /*sal_uInt8 for sal_uInt8 Word Struct*/
-    sal_uInt16 nIdentifier;
-    sal_uInt16 nFixedAreaLen;
-    sal_uInt8	pBlockFlags[4];
-
-    sal_uInt32  nChildrenA;
-
-    sal_uInt8	fUnknown1:1;
-    sal_uInt8	fEnabled:1;
-    sal_uInt8	fLocked:1;
-    sal_uInt8	fBackStyle:1;
-    sal_uInt8	fUnknown2:4;
-
-    sal_uInt8	fUnknown3:8;
-
-    sal_uInt8	fUnknown4:7;
-    sal_uInt8	fWordWrap:1;
-
-    sal_uInt8	fUnknown5:4;
-    sal_uInt8	fAutoSize:1;
-    sal_uInt8	fUnknown6:3;
-
-    sal_uInt32	nCaptionLen;
-    sal_uInt16  nVertPos;
-    sal_uInt16  nHorzPos;
-    sal_uInt8 	nMousePointer;
-    sal_uInt32	nBorderColor;
-    sal_uInt32  nDrawBuffer;
-    sal_uInt32  nChildrenB;
-    sal_uInt8   nKeepScrollBarsVisible;
-    sal_uInt8   nCycle;
-    sal_uInt16	nBorderStyle;
-    sal_uInt8	nSpecialEffect;
-    sal_uInt16	nPicture;
-    sal_uInt8   nPictureAlignment;
-    sal_uInt8   nPictureSizeMode;
-    bool        bPictureTiling;
-    sal_uInt16	nAccelerator;
-    sal_uInt16	nIcon;
-    sal_uInt16	fUnknown7;
-
-    char *pCaption;
-
-    sal_uInt32 	nScrollWidth;
-    sal_uInt32 	nScrollHeight;
-    sal_uInt32 	nScrollLeft;
-    sal_uInt32 	nScrollTop;
-
-    sal_uInt8 pIconHeader[20];
-    sal_uInt32  nIconLen;
-    sal_uInt8 *pIcon;
-
-    sal_uInt8 pPictureHeader[20];
-    sal_uInt32  nPictureLen;
-    ::rtl::OUString sImageUrl;
-	com::sun::star::uno::Reference< com::sun::star::graphic::XGraphicObject> mxGrfObj;
 private:
-        com::sun::star::uno::Reference<
-                com::sun::star::uno::XComponentContext> mxCtx;
+    com::sun::star::uno::Reference<
+        com::sun::star::uno::XComponentContext> mxCtx;
 };
 
 
@@ -1131,8 +930,6 @@ public:
 
     sal_uInt8 pPictureHeader[20];
     sal_uInt32  nPictureLen;
-    ::rtl::OUString sImageUrl;
-	com::sun::star::uno::Reference< com::sun::star::graphic::XGraphicObject> mxGrfObj;
 
     bool        mbTakeFocus;
 
@@ -1194,7 +991,7 @@ public:
     fAutoSize(0),nCaptionLen(0),nVertPos(1),nHorzPos(7),nMousePointer(0),
     nBorderColor(0x80000006),nBorderStyle(0),nSpecialEffect(0),
     nPicture(0),nAccelerator(0),nIcon(0),pCaption(0),nIconLen(0),pIcon(0),
-    nPictureLen(0),pPicture(0)
+    nPictureLen(0)
     {
         msFormType = rtl::OUString::createFromAscii("com.sun.star.form.component.FixedText");
         msDialogType = rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlFixedTextModel");
@@ -1206,7 +1003,6 @@ public:
     ~OCX_Label() {
         if (pCaption) delete[] pCaption;
         if (pIcon) delete[] pIcon;
-        if (pPicture) delete[] pPicture;
     }
     sal_Bool Read(SotStorageStream *pS);
 
@@ -1250,7 +1046,6 @@ public:
 
     sal_uInt8 pPictureHeader[20];
     sal_uInt32  nPictureLen;
- 	sal_uInt8 *pPicture;
 
     static OCX_Control *Create() { return new OCX_Label;}
 
diff --git a/filter/source/msfilter/msocximex.cxx b/filter/source/msfilter/msocximex.cxx
index e9032c2..ecf63c7 100644
--- a/filter/source/msfilter/msocximex.cxx
+++ b/filter/source/msfilter/msocximex.cxx
@@ -521,7 +521,6 @@ void lclReadCharArray( SvStorageStream& rStrm, char*& rpcCharArr, sal_uInt32 nLe
     }
 }
 
-
 /** Creates an OUString from a character array created with lclReadCharArray().
 
     The passed parameters must match, that means the length field must be the
@@ -549,6 +548,39 @@ OUString lclCreateOUString( const char* pcCharArr, sal_uInt32 nLenFld )
     return svt::BinFilterUtils::CreateOUStringFromUniStringArray( pcCharArr, nBufSize );
 }
 
+void readArrayString( SotStorageStream *pS, std::vector< rtl::OUString >& sStringsOut, sal_Int32 nSize, long nStart )
+{
+    unsigned long nFinish = pS->Tell() + nSize;
+    while ( pS->Tell() < nFinish )
+    {
+        sal_Int32 nStringLen = 0;
+        *pS >> nStringLen;
+        sal_uInt32 nStringSize = lclGetBufferSize( nStringLen );
+        sal_Char* pString = new sal_Char[ nStringSize ];
+        pS->Read( pString, nStringSize );
+        rtl::OUString sString = lclCreateOUString( pString, nStringLen );
+        delete[] pString;
+        sStringsOut.push_back( sString );
+        ReadAlign(pS, pS->Tell() - nStart, 4);
+    }
+}
+
+OUString createSubStreamName( const sal_uInt32& subStorageId )
+{
+    static OUString sI = OUString::createFromAscii("i");
+    static OUString sZero = OUString::createFromAscii( "0" );
+    OUStringBuffer buf( 6 );
+    buf.append( sI );
+    // for subStorage id < 10 stream name has leading '0'
+    // eg "i07"
+    if ( subStorageId < 10 )
+    {
+        buf.append( sZero );
+    }
+    buf.append( OUString::valueOf( (sal_Int32)subStorageId ) );
+    return buf.makeStringAndClear();
+}
+
 // export ---------------------------------------------------------------------
 
 /** This class implements writing a character array from a Unicode string.
@@ -641,6 +673,44 @@ void SvxOcxString::WriteCharArray( SvStorageStream& rStrm ) const
     }
 }
 
+class MultiPageProps
+{
+public:
+    sal_uInt16  nIdentifier; // major & minor version
+    sal_uInt16  nFixedAreaLen; // size of record
+    sal_uInt8   pBlockFlags[4]; // size of record
+    sal_Int32   mnPageCount;
+    sal_Int32   mnID;
+    bool        mbEnabled;
+    std::vector< sal_Int32 > mnIDs;
+
+    MultiPageProps();
+    bool Read(SotStorageStream *pS);
+};
+
+MultiPageProps::MultiPageProps() : nIdentifier(0), nFixedAreaLen(0), mnPageCount(0), mnID(0), mbEnabled( true )
+{
+}
+
+bool MultiPageProps::Read(SotStorageStream *pS)
+{
+    *pS >> nIdentifier >> nFixedAreaLen;
+    pS->Read( pBlockFlags, sizeof( pBlockFlags ) );
+    if ( pBlockFlags[ 0 ] & 0x02 )
+        *pS >> mnPageCount;
+    if ( pBlockFlags[ 0 ] & 0x04 )
+        *pS >> mnID;
+    if ( pBlockFlags[ 0 ] & 0x08 )
+        mbEnabled = false;
+    for ( sal_Int32 i=0; i<mnPageCount; ++i )
+    {
+        sal_Int32 nID(0);
+        *pS >> nID;
+        mnIDs.push_back( nID );
+    }
+    return true;
+}
+
 const sal_uInt16 USERFORM = (sal_uInt16)0xFF;
 const sal_uInt16 STDCONTAINER = (sal_uInt16)0xFE;
 
@@ -666,48 +736,42 @@ const sal_uInt16 TOGGLEBUTTON = (sal_uInt16)0x1C;
 const sal_uInt16 SCROLLBAR = (sal_uInt16)0x2F;
 
 const sal_uInt16 MULTIPAGE = (sal_uInt16)0x39;
-// The IDs with bit 0x8000 set appear to be generated.
-// It looks like these ID's are used with the non-toolbox [1]
-// ActiveX controls that can be present in a Userform
-// ( note: RefEdit seems to be an exception )
-// In UserForm::Read just before the Container record starts
-// you will notice there can be sometimes trailing records,
-// it seems that these records have a 1:1 relationship with the non-toolbox
-// controls present in the Userform. An id in the trailing record
-// seems to identify the specific ActiveX control and an artificial nTypeIdent
-// e.g. 0x8000, 0x8001 etc. is created so as to be able to associate
-// the ActiveX control when referenced later
-// [1] Such ActiveX controls are added via Tools/AddionalControls
-// menu
-
-// create a fixed set of those special id(s)
-// ahem, we can only read one Progress bars at the moment so....
+
+const sal_uInt16 UNKNOWNCTRL = (sal_uInt16)0x7FFF;
 const sal_uInt16 PROGRESSBAR = (sal_uInt16)0x8000;
 
-// A set of IDs from the trailing records mentioned above that seem to
-// identify the following ActiveX controls
+// following ActiveX controls are just for reference ( are NOT supported )
+const sal_uInt16 REFEDIT = (sal_uInt16)0x8001;
+const sal_uInt16 CALENDAR = (sal_uInt16)0x8002;
+const sal_uInt16 IMAGECOMBO = (sal_uInt16)0x8003;
+const sal_uInt16 IMAGELIST = (sal_uInt16)0x8004;
+const sal_uInt16 SLIDER = (sal_uInt16)0x8005;
+const sal_uInt16 STATUSBAR = (sal_uInt16)0x8006;
+const sal_uInt16 CHARTSPACE = (sal_uInt16)0x8007;
+
+// A set of common CLSIDs
+// there are to identify the following ActiveX controls ( that appear in the ClassTable records )
 // Currently we only can process ( in a limited way ) the ProgressBar
 // the other ID's are for reference ( & future )
 
-// RefEdit control {00024512-0000-0000-c000-000000000046}
-const sal_uInt8 aRefEditID[] =
-{
-0x12, 0x45, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46,
-};
-
 // Microsoft ProgressBar Control, version 6.0 {35053A22-8589-11D1-B16A-00C0F0283628}
 const sal_uInt8 aProgressID[] =
 {
 0x22, 0x3a, 0x05, 0x35, 0x89, 0x85, 0xd1, 0x11,  0xb1, 0x6a, 0x00, 0xc0, 0xf0, 0x28, 0x36, 0x28,
 };
 
+// RefEdit control {00024512-0000-0000-c000-000000000046}
+const sal_uInt8 aRefEditID[] =
+{
+0x12, 0x45, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46,
+};
+
 // Calendar Control 10.0
 const sal_uInt8 aCalendarID[] =
 {
 0x2b, 0xc9, 0x27, 0x8e, 0x64, 0x12, 0x1c, 0x10, 0x8a, 0x2f, 0x04, 0x02, 0x24, 0x00, 0x9c, 0x02,
 };
 
-
 // Microsoft ImageComboxBox Control, version 6.0 {DD9DA666-8594-11D1-B16A-00C0F0283628}
 const sal_uInt8 aImageComboID[] =
 {
@@ -738,238 +802,364 @@ const sal_uInt8 aChartSpaceID[] =
 0x46, 0xe5, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46,
 };
 
-const sal_Int16 ActiveXIDLen = 0x10; // CLSID len
-const sal_Int16 ActiveXIDBlockLen = 0x30; // the block len that contains the CLSID
+const sal_uInt8 nSizeOfClsid = sizeof( aProgressID );
 
-bool lcl_handleActiveXControl(  SvStorageStream *pS, sal_uInt16& nTypeID )
+struct ClsIdTypeIDPair
 {
-    nTypeID = 0; // Illegal ActiveX ID
-    bool bRes = false;
-    sal_uInt16 nIdentifier, nFixedAreaLen;
-    *pS >> nIdentifier;
-    *pS >> nFixedAreaLen;
-    pS->SeekRel( ( nFixedAreaLen - ActiveXIDBlockLen ) );
-    sal_uInt8 aID[ ActiveXIDLen ];
-    if ( !pS->IsEof() )
-    {
-        pS->Read( aID, ActiveXIDLen );
-        pS->SeekRel( ActiveXIDBlockLen - ActiveXIDLen ); // read remainer of record
-        if ( memcmp( aID, aProgressID, ActiveXIDLen ) == 0 )
+//    ClsIdTypeIDPair() : pClsID( NULL ), nTypeID( UNKNOWNCTRL ) {}
+    const sal_uInt8* pClsID;
+    const sal_uInt16 nTypeID;
+};
+
+ClsIdTypeIDPair ClsidList[] = { { aProgressID, PROGRESSBAR },
+// unsupported common activex controls
+#ifdef DEBUG
+                                 { aRefEditID, REFEDIT },
+                                 { aCalendarID, CALENDAR },
+                                 { aImageComboID, IMAGECOMBO },
+                                 { aImageListID, IMAGELIST },
+                                 { aSliderID, SLIDER },
+                                 { aStatusBarID, STATUSBAR },
+                                 { aChartSpaceID, CHARTSPACE },
+#endif
+};
+
+typedef std::vector< ContainerRecord > ContainerRecordList;
+
+class FormObjectDepthTypeCount
+{
+    public:
+    sal_uInt8 depth;
+    sal_uInt8 TypeOrCount;
+    std::auto_ptr< sal_uInt8 > OptionalType;
+    FormObjectDepthTypeCount() : depth(0), TypeOrCount(0) {}
+    bool Read( SvStorageStream* pS )
+    {
+        *pS >> depth >> TypeOrCount;
+        if ( TypeOrCount &  0x80 )
         {
-            nTypeID = PROGRESSBAR;
-            OSL_TRACE("Found supported ***PROGRESSBAR*** ActiveX control");
-            bRes = true;
+            OptionalType.reset( new sal_uInt8 );
+            *pS >> *OptionalType;
         }
-#if (OSL_DEBUG_LEVEL > 0)
-        // If we really want to process these more controls we should put them in
-        // a list or array and have a single loop testing each id. For the moment
-        // as we only can process PROGRESSBAR, not much point doing that until
-        // we add support for at least another activex control
-
-        else if ( memcmp( aID, aCalendarID, ActiveXIDLen ) == 0 )
-            OSL_TRACE("Found unsupported ***CALENDAR*** ActiveX control");
-        else if ( memcmp( aID, aRefEditID, ActiveXIDLen ) == 0 )
-            OSL_TRACE("Found unsupported ***REFEDIT*** ActiveX control");
-        else if ( memcmp( aID, aImageComboID, ActiveXIDLen ) == 0 )
-            OSL_TRACE("Found unsupported ***IMAGECOMBO*** ActiveX control");
-        else if ( memcmp( aID, aImageListID, ActiveXIDLen ) == 0 )
-            OSL_TRACE("Found unsupported ***IMAGELIST*** ActiveX control");
-        else if ( memcmp( aID, aChartSpaceID, ActiveXIDLen ) == 0 )
-            OSL_TRACE("Found unsupported ***CHARTSPACE*** ActiveX control");
-        else if ( memcmp( aID, aSliderID, ActiveXIDLen ) == 0 )
-            OSL_TRACE("Found unsupported ***SLIDER*** ActiveX control");
-        else if ( memcmp( aID, aStatusBarID, ActiveXIDLen ) == 0 )
-            OSL_TRACE("Found unsupported ***STATUSBAR*** ActiveX control");
-#endif
-        else
+        TypeOrCount = ( TypeOrCount >> 1 );
+        return true;
+    }
+};
+
+class ClassTable
+{
+    sal_uInt16 nIdentifier;
+    sal_uInt16 nFixedAreaLen;
+    sal_uInt32 nContentFlags;
+    sal_uInt16 nClassTableFlags;
+    sal_uInt16 nVarFlags;
+    sal_Int32 nCountOfMethods;
+    sal_Int32 nDispidBind;
+    sal_uInt16 nGetBindIndex;
+    sal_uInt16 nPutBindIndex;
+    sal_uInt16 nBindType;
+    sal_uInt16 nGetValueIndex;
+    sal_uInt16 nPutValueIndex;
+    sal_uInt16 nValueType;
+    sal_uInt32 nDisidRowset;
+    sal_uInt16 nSetRowset;
+    sal_uInt8 pClsId[16];
+    sal_uInt8 pDispEvent[16];
+    sal_uInt8 pDefaultProg[16];
+    sal_uInt16 nTypeId;
+public:
+    ClassTable() :  nIdentifier( 0 )
+                   ,nFixedAreaLen( 0 )
+                   ,nContentFlags(0)
+                   ,nClassTableFlags(0)
+                   ,nVarFlags(0)
+                   ,nCountOfMethods(0)
+                   ,nDispidBind(0)
+                   ,nGetBindIndex(0)
+                   ,nPutBindIndex(0)
+                   ,nBindType(0)
+                   ,nGetValueIndex(0)
+                   ,nPutValueIndex(0)
+                   ,nValueType(0)
+                   ,nDisidRowset(0)
+                   ,nSetRowset(0)
+                   ,nTypeId(UNKNOWNCTRL)
+
+    {
+        memset( pClsId, 0, sizeof( pClsId ) );
+        memset( pDispEvent, 0, sizeof( pDispEvent ) );
+        memset( pDefaultProg, 0, sizeof( pDefaultProg ) );
+    }
+    bool Read(  SvStorageStream* pS )
+    {
+        long nStartPos = pS->Tell();
+        *pS >> nIdentifier >> nFixedAreaLen >> nContentFlags;
+        bool bClsID( false );
+        bool bDispEvent( false );
+        bool bDefaultProg( false );
+        if (  nContentFlags & 0x00000001 )
+            bClsID = true;
+        if (  nContentFlags & 0x00000002 )
+            bDispEvent = true;
+//        if (  nContentFlags & 0x00000004 ) ' not set should be 0
+        if (  nContentFlags & 0x00000008 )
+            bDefaultProg = true;
+        if (  nContentFlags & 0x00000010 )
+            *pS >> nClassTableFlags >> nVarFlags;
+        if (  nContentFlags & 0x00000020 )
+            *pS >> nCountOfMethods;
+        if (  nContentFlags & 0x00000040 )
+            *pS >> nDispidBind;
+        if (  nContentFlags & 0x00000080 )
+            *pS >> nGetBindIndex;
+        if (  nContentFlags & 0x00000100 )
+            *pS >> nPutBindIndex;
+        if (  nContentFlags & 0x00000200 )
+            *pS >> nBindType;
+        if (  nContentFlags & 0x00000400 )
+            *pS >> nGetValueIndex;
+        if (  nContentFlags & 0x00000800 )
+            *pS >> nPutValueIndex;
+        if (  nContentFlags & 0x00001000 )
+            *pS >> nValueType;
+        if (  nContentFlags & 0x00002000 )
+        {
+            ReadAlign( pS, pS->Tell() - nStartPos, 4 );
+            *pS >> nDisidRowset;
+        }
+        if (  nContentFlags & 0x00004000 )
+            *pS >> nSetRowset;
+        ReadAlign( pS, pS->Tell() - nStartPos, 4 );
+        // Extra Block
+        if ( bClsID )
+            pS->Read( pClsId, sizeof( pClsId ) );
+        if ( bDispEvent )
+            pS->Read( pDispEvent, sizeof( pDispEvent ) );
+        if ( bDefaultProg )
+            pS->Read( pDefaultProg, sizeof( pDefaultProg ) );
+
+        sal_Int32 nNumIds =  sizeof( ClsidList ) / sizeof( ClsidList[0] );
+
+        if ( bClsID )
         {
-            OSL_TRACE("Unknown activeX ID !");
+            for ( sal_Int32 index = 0; index < nNumIds; ++index )
+            {
+                if ( memcmp( pClsId, ClsidList[ index ].pClsID, nSizeOfClsid ) == 0 )
+                {
+                    nTypeId = ClsidList[ index ].nTypeID;
+                    OSL_TRACE( "... found activex control ClsidList[ %d ] and have given it TypeIdent 0x%x", index, nTypeId );
+                }
+            }
         }
+        ReadAlign( pS, pS->Tell() - nStartPos, 4 );
+        return true;
     }
-    return bRes;
-}
 
-typedef std::vector< ContainerRecord > ContainerRecordList;
+    sal_uInt16 getTypeId() { return nTypeId; }
+};
 
-class ContainerRecReader
+class OleSiteConcreteControl
 {
-    public:
+    sal_uInt16 nIdentifier;
+    sal_uInt16 nFixedAreaLen;
+    sal_uInt32 nContentFlags;
+public:
+    OleSiteConcreteControl() :  nIdentifier( 0 ), nFixedAreaLen( 0 ), nContentFlags(0) {}
+    bool Read( ContainerRecord& rec, SvStorageStream* pS )
+    {
+        long nStartPos = pS->Tell();
+        *pS >> nIdentifier >> nFixedAreaLen >> nContentFlags;
+
+        bool bPosition( false );
+
+        sal_uInt32 nNameLen = 0;
+        // length of control name
+        if ( nContentFlags & 0x00000001 )
+            *pS >> nNameLen;
+        // length of control tag
+        sal_uInt32 nTagLen = 0;
+        if( nContentFlags & 0x00000002 )
+            *pS >> nTagLen;
+        // substorage id for frames
+        if( nContentFlags & 0x00000004 )
+            *pS >> rec.nSubStorageId;
+        // help-context id
+        if( nContentFlags & 0x00000008 )
+            pS->SeekRel( 4 );
+        // option flags
+        if( nContentFlags & 0x00000010 )
+        {
+            sal_uInt32 nBitFlags = 0;
+            *pS >> nBitFlags;
+            rec.bVisible = ( nBitFlags & 0x02 );
+            rec.bTabStop = ( nBitFlags & 0x01 );
+        }
+        // substream size
+        if( nContentFlags & 0x00000020 )
+            *pS >> rec.nSubStreamLen;
+        // tabstop position
+        if( nContentFlags & 0x00000040 )
+        {
+            ReadAlign( pS, pS->Tell() - nStartPos, 2 );
+            *pS >> rec.nTabPos;
+        }
+        // control type
+        if( nContentFlags & 0x00000080 )
+        {
+            ReadAlign( pS, pS->Tell() - nStartPos, 2 );
+            *pS >> rec.nTypeIdent;
+        }
+        if( nContentFlags & 0x00000100 )
+            bPosition = true;
+        sal_Int16 nGroupId = 0;
+        if( nContentFlags & 0x00000200 )
+        {
+            ReadAlign( pS, pS->Tell() - nStartPos, 2 );
+            *pS >> nGroupId;
+        }
 
-    virtual ~ContainerRecReader() {}
+        // length of infotip
+        sal_uInt32 nTipLen = 0;
+        if( nContentFlags & 0x00000800 )
+        {
+            ReadAlign( pS, pS->Tell() - nStartPos, 4 );
+            *pS >> nTipLen;
+        }
+        sal_uInt32 nCntrlIdLen = 0;
+        if( nContentFlags & 0x00001000 )
+        {
+            ReadAlign( pS, pS->Tell() - nStartPos, 4 );
+            *pS >> nCntrlIdLen;
+        }
 
-    virtual bool Read( OCX_ContainerControl* pContainerControl, SvStorageStream *pS)
-    {
-        *pS >> nNoRecords;
-        *pS >> nTotalLen;
+        // length of control source name
+        sal_uInt32 nCtrlSrcLen = 0;
+        if( nContentFlags & 0x00002000 )
+        {
+            ReadAlign( pS, pS->Tell() - nStartPos, 4 );
+            *pS >> nCtrlSrcLen;
+        }
 
-        if ( isMultiPage )
+        // length of row source name
+        sal_uInt32 nRowSrcLen = 0;
+        if( nContentFlags & 0x00004000 )
         {
-            if ( !handleMultiPageHdr( pS ) )
-            {
-                return false;
-            }
+            ReadAlign( pS, pS->Tell() - nStartPos, 4 );
+            *pS >> nRowSrcLen;
         }
-        else
+
+        ReadAlign( pS, pS->Tell() - nStartPos, 4 );
+        // control name
+        sal_Char* pName = 0;
+        sal_uInt32 nNameBufSize = lclGetBufferSize( nNameLen );
+        if( nNameBufSize > 0 )
         {
-            if ( !handleStandardHdr( pS ) )
-            {
-                return false;
-            }
+            ReadAlign( pS, pS->Tell() - nStartPos, 4 );
+            pName = new char[ nNameBufSize ];
+            pS->Read( pName, nNameBufSize );
+        }
+        // control tag
+        sal_uInt32 nTagBufSize = lclGetBufferSize( nTagLen );
+        if( nTagBufSize > 0 )
+        {
+            ReadAlign( pS, pS->Tell() - nStartPos, 4 );
+            pS->SeekRel( nTagBufSize );
         }
 
-        records.clear();
-        for (sal_uInt32 nRecord = 0; nRecord < nNoRecords; ++nRecord)
+        // control position
+        if( bPosition )
         {
-            // DR #134146# redo loading of FrameChild data
+            ReadAlign( pS, pS->Tell() - nStartPos, 4 );
+            *pS >> rec.nLeft >> rec.nTop;
+        }
 
-            ContainerRecord rec;
+        // control infotip
+        sal_uInt32 nTipBufSize = lclGetBufferSize( nTipLen );
+        if( nTipBufSize > 0 )
+        {
+            ReadAlign( pS, pS->Tell() - nStartPos, 4 );
+            std::auto_ptr< sal_Char > pTipName;
+            pTipName.reset( new sal_Char[ nTipBufSize ] );
+            pS->Read( pTipName.get(), nTipBufSize );
+            rec.controlTip = lclCreateOUString( pTipName.get(), nTipLen );
+        }
+        // control id
+        sal_uInt32 nCntrlIdSize = lclGetBufferSize( nCntrlIdLen );
+        if( nCntrlIdSize > 0 )
+        {
+            ReadAlign( pS, pS->Tell() - nStartPos, 4 );
+            pS->SeekRel( nCntrlIdSize );
+        }
+        // control source name
+        sal_uInt32 nCtrlSrcBufSize = lclGetBufferSize( nCtrlSrcLen );
+        if( nCtrlSrcBufSize > 0 )
+        {
+            ReadAlign( pS, pS->Tell() - nStartPos, 4 );
+            std::vector< sal_Char > pCtrlSrcName( nCtrlSrcBufSize );
+            pS->Read( &pCtrlSrcName[0], nCtrlSrcBufSize );
+            rec.sCtrlSource = lclCreateOUString( &pCtrlSrcName[0], nCtrlSrcLen );
+            OSL_TRACE("*** *** *** ControlSourceName -> %s ", rtl::OUStringToOString( rec.sCtrlSource, RTL_TEXTENCODING_UTF8 ).getStr() );
+        }
+        // row source name
+        sal_uInt32 nRowSrcBufSize = lclGetBufferSize( nRowSrcLen );
+        if( nRowSrcBufSize > 0 )
+        {
+            ReadAlign( pS, pS->Tell() - nStartPos, 4 );
+            std::vector< sal_Char > pRowSrcName( nRowSrcBufSize );
+            pS->Read( &pRowSrcName[0], nRowSrcBufSize );
+            rec.sRowSource =  lclCreateOUString( &pRowSrcName[0], nRowSrcLen );
+            OSL_TRACE("*** *** *** RowSourceName -> %s ", rtl::OUStringToOString( rec.sRowSource, RTL_TEXTENCODING_UTF8 ).getStr() );
+        }
 
-            // record header
-            sal_uInt16 nId, nSize;
-            *pS >> nId >> nSize;
-            sal_Size nStartPos = pS->Tell();
-
-            // content flags
-            sal_uInt32 nContentFlags;
-            *pS >> nContentFlags;
-
-            // length of control name
-            sal_uInt32 nNameLen = 0;
-            if( nContentFlags & 0x00000001 )
-                *pS >> nNameLen;
-            // length of control tag
-            sal_uInt32 nTagLen = 0;
-            if( nContentFlags & 0x00000002 )
-                *pS >> nTagLen;
-            // substorage id for frames
-            if( nContentFlags & 0x00000004 )
-                *pS >> rec.nSubStorageId;
-            // help-context id
-            if( nContentFlags & 0x00000008 )
-                pS->SeekRel( 4 );
-            // option flags
-            if( nContentFlags & 0x00000010 )
-            {
-                sal_uInt32 nBitFlags = 0;
-                *pS >> nBitFlags;
-                rec.bVisible = ( ( nBitFlags & 0x02 ) == 0x02 );
-            }
-            // substream size
-            if( nContentFlags & 0x00000020 )
-                *pS >> rec.nSubStreamLen;
-            // tabstop position
-            if( nContentFlags & 0x00000040 )
-                *pS >> rec.nTabPos;
-            // control type
-            if( nContentFlags & 0x00000080 )
-                *pS >> rec.nTypeIdent;
-            if( nContentFlags & 0x00000200 )
-                pS->SeekRel( 4 ); // Grouping?
-            // length of infotip
-            sal_uInt32 nTipLen = 0;
-            if( nContentFlags & 0x00000800 )
-            {
-                ReadAlign( pS, pS->Tell() - nStartPos, 4 );
-                *pS >> nTipLen;
-            }
+        ReadAlign( pS, pS->Tell() - nStartPos, 4 );
+        rec.cName = lclCreateOUString(pName, nNameLen);
+        delete[] pName;
+        return true;
+    }
+};
 
-            sal_uInt32 nCntrlIdLen = 0;
-            if( nContentFlags & 0x00001000 )
-                *pS >> nCntrlIdLen;
+class ContainerRecReader
+{
+    public:
 
-            // length of control source name
-            sal_uInt32 nCtrlSrcLen = 0;
-            if( nContentFlags & 0x00002000 )
-            {
-                ReadAlign( pS, pS->Tell() - nStartPos, 4 );
-                *pS >> nCtrlSrcLen;
-            }
+    virtual ~ContainerRecReader() {}
 
-            // length of row source name
-            sal_uInt32 nRowSrcLen = 0;
-            if( nContentFlags & 0x00004000 )
-            {
-                ReadAlign( pS, pS->Tell() - nStartPos, 4 );
-                *pS >> nRowSrcLen;
-            }
+    virtual bool Read( OCX_ParentControl* pContainerControl, SvStorageStream *pS, std::vector< ClassTable >& rSiteClassInfo )
+    {
+        *pS >> nNoRecords;
+        *pS >> nTotalLen;
+        long nStart = pS->Tell();
+        for ( sal_uInt32 nSite = 0; nSite < nNoRecords; )
+        {
+            FormObjectDepthTypeCount siteAndDepth;
+            siteAndDepth.Read( pS );
+            nSite += ( siteAndDepth.OptionalType.get() ? siteAndDepth.TypeOrCount : 1 );
+        }
 
-            // control name
-            sal_Char* pName = 0;
-            sal_uInt32 nNameBufSize = lclGetBufferSize( nNameLen );
-            if( nNameBufSize > 0 )
-            {
-                pName = new char[ nNameBufSize ];
-                ReadAlign( pS, pS->Tell() - nStartPos, 4 );
-                pS->Read( pName, nNameBufSize );
-            }
-            // control tag
-            sal_uInt32 nTagBufSize = lclGetBufferSize( nTagLen );
-            if( nTagBufSize > 0 )
-            {
-                ReadAlign( pS, pS->Tell() - nStartPos, 4 );
-                pS->SeekRel( nTagBufSize );
-            }
+        ReadAlign(pS, pS->Tell() - nStart, 4);
 
-            // control position
-            if( nContentFlags & 0x00000100 )
-            {
-                ReadAlign( pS, pS->Tell() - nStartPos, 4 );
-                *pS >> rec.nLeft >> rec.nTop;
-            }
+        for (sal_uInt32 nRecord = 0; nRecord < nNoRecords; ++nRecord)
+        {
 
-            // control infotip
-            sal_uInt32 nTipBufSize = lclGetBufferSize( nTipLen );
-            if( nTipBufSize > 0 )
-            {
-                std::auto_ptr< sal_Char > pTipName;
-                pTipName.reset( new sal_Char[ nTipBufSize ] );
-                ReadAlign( pS, pS->Tell() - nStartPos, 4 );
-                pS->Read( pTipName.get(), nTipBufSize );
-                rec.controlTip = lclCreateOUString( pTipName.get(), nTipLen );
-            }
-            // control id
-            sal_uInt32 nCntrlIdSize = lclGetBufferSize( nCntrlIdLen );
-            if( nCntrlIdSize > 0 )
-            {
-                ReadAlign( pS, pS->Tell() - nStartPos, 4 );
-                pS->SeekRel( nCntrlIdSize );
-            }
-            // control source name
-            sal_uInt32 nCtrlSrcBufSize = lclGetBufferSize( nCtrlSrcLen );
-            if( nCtrlSrcBufSize > 0 )
-            {
-                ReadAlign( pS, pS->Tell() - nStartPos, 4 );
-                std::auto_ptr< sal_Char > pCtrlSrcName;
-                pCtrlSrcName.reset( new sal_Char[ nCtrlSrcBufSize ] );
-                pS->Read( pCtrlSrcName.get(), nCtrlSrcBufSize );
-                rec.sCtrlSource = lclCreateOUString( pCtrlSrcName.get(), nCtrlSrcLen );
-                OSL_TRACE("*** *** *** ControlSourceName -> %s ", rtl::OUStringToOString( rec.sCtrlSource, RTL_TEXTENCODING_UTF8 ).getStr() );
-            }
-            // row source name
-            sal_uInt32 nRowSrcBufSize = lclGetBufferSize( nRowSrcLen );
-            if( nRowSrcBufSize > 0 )
+            ContainerRecord rec;
+
+            OleSiteConcreteControl site;
+            site.Read( rec, pS );
+            if ( rec.nTypeIdent >= ( UNKNOWNCTRL + 1 ) )
             {
-                ReadAlign( pS, pS->Tell() - nStartPos, 4 );
-                std::auto_ptr< sal_Char > pRowSrcName;
-                pRowSrcName.reset( new sal_Char[ nRowSrcBufSize ] );
-                pS->Read( pRowSrcName.get(), nRowSrcBufSize );
-                rec.sRowSource =  lclCreateOUString( pRowSrcName.get(), nRowSrcLen );
-                OSL_TRACE("*** *** *** RowSourceName -> %s ", rtl::OUStringToOString( rec.sRowSource, RTL_TEXTENCODING_UTF8 ).getStr() );
+                sal_uInt16 nIndex = rec.nTypeIdent - ( UNKNOWNCTRL + 1 );
+                if ( nIndex <  rSiteClassInfo.size() )
+                    rec.nTypeIdent = rSiteClassInfo[ nIndex ].getTypeId();
             }
-
-            // seek to end of data
-            pS->Seek( nStartPos + nSize );
-
-            rec.cName = lclCreateOUString(pName, nNameLen);
-            delete[] pName;
-
             OCX_Control* pControl = NULL;
+            OSL_TRACE("** About to create control of type 0x%x with name %s from rec", rec.nTypeIdent, rtl::OUStringToOString( rec.cName, RTL_TEXTENCODING_UTF8 ).getStr() );
             if( pContainerControl->createFromContainerRecord( rec, pControl ) &&
                 pControl )
             {
                 // propagate doc shell from parent
                 pControl->pDocSh = pContainerControl->pDocSh;
                 pContainerControl->ProcessControl( pControl, pS, rec );
+
             }
             else if ( rec.nTypeIdent & 0x8000 )
             {
@@ -987,90 +1177,12 @@ class ContainerRecReader
         return true;
     }
 
+    ContainerRecReader():nNoRecords(0), nTotalLen(0){}
     protected:
-    ContainerRecReader() : isMultiPage(false){}
-    bool isMultiPage;
     sal_uInt32 nNoRecords;
     sal_uInt32 nTotalLen;
 
     private:
-    bool handleStandardHdr( SvStorageStream* pS )
-    {
-        sal_uInt8 aUnknown11[4];
-        pS->Read(aUnknown11, sizeof(aUnknown11));
-        // discovered a dialog with value of 0xFF for aUnknown11
-        // needed an extra 4 bytes to offset correctly  into the control
-        // records. Valid test or coincidence ?
-        if ( aUnknown11[1] == 0xFF )
-           pS->Read( aUnknown11, sizeof(aUnknown11));
-        return true;
-    }
-
-    bool handleMultiPageHdr( SvStorageStream* pS )
-    {
-        sal_uInt32 nUnknown_32b; // unknown 32 bit structure, flags ?
-        sal_uInt16 nUnknown_16b; // unknown 16 bit structure
-        sal_uInt16 nMysteryLen; // lenght of unknown sub record
-
-        *pS >> nUnknown_32b;
-        *pS >> nUnknown_16b;
-        *pS >> nMysteryLen;
-
-        pS->SeekRel( nMysteryLen );
-        return true;
-    }
-    ContainerRecordList records;
-};
-
-class StdContainerRecReader : public ContainerRecReader
-{
-    public:
-    StdContainerRecReader(){}
-};
-
-class MultiPageContainerRecReader : public ContainerRecReader
-{
-    public:
-    MultiPageContainerRecReader()
-    {
-        // NP ( 27-01-05 )
-        // Strictly speaking this approach shouldn't be necessary.
-        // It should be possible to have a common routine read the
-        // container record array and by examining the flags present in
-        // the record to determine we expect to read or not.
-        // In this case for a MultPage control there is no Top or Left
-        // values in the control record array, however time contraints
-        // and associated risk prevent further investigation of this
-        // at the moment.
-        // similar situation exists for the start of the container record
-        // which in the case of the MultiPage is different from
-        // UserForm & Frame ( the other containers )
-
-        isMultiPage = true; // tell the base class skip
-    }
-};
-
-class ContainerRecordReaderFac
-{
-    public:
-    static ContainerRecReader* instance( sal_uInt32 containerType )
-    {
-        switch( containerType )
-        {
-            case PAGE:
-            case FRAME:
-            case USERFORM:
-            case STDCONTAINER:
-                return new StdContainerRecReader();
-            case MULTIPAGE:
-                return new MultiPageContainerRecReader();
-            default:
-                DBG_ERROR("Illegal container type for factory");
-                return NULL;
-        }
-    }
-    private:
-    ContainerRecordReaderFac();
 };
 
 } // namespace
@@ -1273,6 +1385,7 @@ sal_Bool OCX_Control::Import(uno::Reference<container::XNameContainer> &rDialog
     }
 
     uno::Reference<beans::XPropertySet> xPropSet(xCreate, uno::UNO_QUERY);
+
     if (!xPropSet.is())
         return sal_False;
 
@@ -2202,6 +2315,12 @@ sal_Bool OCX_TextBox::Import(com::sun::star::uno::Reference<
         }
     }
 
+    if ( sImageUrl.getLength() )
+    {
+        aTmp <<= sImageUrl;
+        rPropSet->setPropertyValue( WW8_ASCII2STR("ImageURL"), aTmp);
+    }
+
     aFontData.Import(rPropSet);
     return sal_True;
 }
@@ -3648,8 +3767,15 @@ sal_Bool OCX_Label::Read(SvStorageStream *pS)
     {
         pS->Read(pPictureHeader,20);
         *pS >> nPictureLen;
-        pPicture = new sal_uInt8[nPictureLen];
-        pS->Read(pPicture,nPictureLen);
+        long imagePos = pS->Tell();
+        mxGrfObj = lcl_readGraphicObject( pS );
+        if( mxGrfObj.is() )
+        {
+            sImageUrl = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( GRAPHOBJ_URLPREFIX ) );
+            sImageUrl = sImageUrl + mxGrfObj->getUniqueID();
+        }
+        // make sure the stream position should be pointing after the image
+        pS->Seek( imagePos + nPictureLen );
     }
     if (nIcon)
     {
@@ -3669,325 +3795,61 @@ TypeName::TypeName(sal_Char *pName, sal_uInt32 nStoreId, sal_uInt32 nLen, sal_uI
 {
 }
 
-OCX_ContainerControl::OCX_ContainerControl( SotStorageRef& parent,
-            const ::rtl::OUString& storageName,
-            const ::rtl::OUString& sN,
-            const uno::Reference< container::XNameContainer >  &rParent,
-            OCX_Control* pParent ) :
-                OCX_Control(sN, pParent), mxParent(rParent), nNoRecords(0), nTotalLen(0), containerType( STDCONTAINER )
-{
-
-    mContainerStorage = parent->OpenSotStorage(storageName,
-        STREAM_READWRITE |
-        STREAM_NOCREATE |
-        STREAM_SHARE_DENYALL);
-    mContainerStream = mContainerStorage->OpenSotStream(
-        String(RTL_CONSTASCII_STRINGPARAM("f"),
-        RTL_TEXTENCODING_MS_1252),
-        STREAM_STD_READ | STREAM_NOCREATE);
-    mContainedControlsStream = mContainerStorage->OpenSotStream( String(RTL_CONSTASCII_STRINGPARAM("o"),
-        RTL_TEXTENCODING_MS_1252),
-        STREAM_STD_READ | STREAM_NOCREATE);
-}
-OCX_ContainerControl::~OCX_ContainerControl()
-{
-    CtrlIterator aEnd = mpControls.end();
-    for (CtrlIterator aIter = mpControls.begin(); aIter != aEnd; ++ aIter )
-    {
-        delete *aIter;
-    }
-}
-
-// Really import should receive the parent e.g. a Userform, Frame or Multi Page
-// and call import on its containees with itself  ( up-called from
-// the base class ) but... the reality is we have no containment model
-// so we make sure rPropSet is always the parent Dialog
-
-sal_Bool OCX_ContainerControl::Import(uno::Reference<beans::XPropertySet>& /* rProps */ )
-{
-    if ( !mxParent.is() )
-    {
-        return sal_False;
-    }
-    CtrlIterator aEnd = mpControls.end();
-//    int count = 0;
-    for (CtrlIterator aIter = mpControls.begin(); aIter != aEnd; ++ aIter )
-    {
-        if ( !(*aIter)->Import( mxParent ) )
-        {
-            return sal_False;
-        }
-    }
-    return sal_True;
-}
-
-OUString OCX_ContainerControl::createSubStreamName( const sal_uInt32& subStorageId )
-{
-    static OUString sI = OUString::createFromAscii("i");
-    static OUString sZero = OUString::createFromAscii( "0" );
-    OUStringBuffer buf( 6 );
-    buf.append( sI );
-    // for subStorage id < 10 stream name has leading '0'
-    // eg "i07"
-    if ( subStorageId < 10 )
-    {
-        buf.append( sZero );
-    }
-    buf.append( OUString::valueOf( (sal_Int32)subStorageId ) );
-    return buf.makeStringAndClear();
-}
-
-
-bool OCX_ContainerControl::createFromContainerRecord( ContainerRecord& record, OCX_Control*& pControl )
-{
-    pControl = NULL;
-    if (  record.nTypeIdent & 0x8000 )
-    {
-        std::hash_map<sal_uInt16, sal_uInt16>::iterator it = mActiveXIDMap.find( record.nTypeIdent );
-        if ( it == mActiveXIDMap.end() )
-            return false;
-        // replace the generated id with our hardcoded one
-        record.nTypeIdent = it->second;
-    }
-    switch ( record.nTypeIdent)
-        {
-            case CMDBUTTON:
-                pControl = new OCX_CommandButton;
-                break;
-            case LABEL:
-                pControl = new OCX_UserFormLabel(this);
-                break;
-            case TEXTBOX:
-                pControl = new OCX_TextBox;
-                break;
-            case LISTBOX:
-                pControl = new OCX_ListBox;
-                break;
-            case COMBOBOX:
-                pControl = new OCX_ComboBox;
-                break;
-            case CHECKBOX:
-                pControl =  new OCX_CheckBox;
-                break;
-            case OPTIONBUTTON:
-                pControl = new OCX_OptionButton;
-                break;
-            case TOGGLEBUTTON:
-                pControl = new OCX_ToggleButton;
-                break;
-            case IMAGE: //Image
-            {
-                pControl = new OCX_Image;
-                break;
-            }
-            case PAGE: // Page
-            {
-                OUString sMSStore = createSubStreamName( record.nSubStorageId );
-                pControl = new OCX_Page(mContainerStorage, sMSStore,
-                    record.cName, mxParent, this);
-                break;
-            }
-            case MULTIPAGE: // MultiPage
-            {
-                OUString sMSStore = createSubStreamName( record.nSubStorageId );
-                pControl = new OCX_MultiPage( mContainerStorage, sMSStore,
-                    record.cName, mxParent, this);
-                break;
-            }
-            case FRAME:  //Frame
-            {
-                OUString sFrameStore = createSubStreamName( record.nSubStorageId );
-                pControl = new OCX_Frame(mContainerStorage, sFrameStore,
-                    record.cName, mxParent, this);
-
-                break;
-            }
-            case SPINBUTTON: //SpinButton
-            {
-                pControl = new OCX_SpinButton;
-                break;
-            }
-            case TABSTRIP: //TabStrip
-            {
-                pControl = new OCX_TabStrip;
-                break;
-            }
-            case SCROLLBAR: //ScrollBar
-                pControl = new OCX_ScrollBar;
-                break;
-            case PROGRESSBAR: //ProgressBar Active X control
-                pControl = new OCX_ProgressBar;
-                break;
-            default:
-                OSL_TRACE( "**** Unknown control 0x%x", record.nTypeIdent );
-                DBG_ERROR( "Unknown control");
-                return false;
-        }
-        pControl->sName = record.cName;
-        return true;
-}
-
-
-void addSeperator( std::vector< OCX_Control* >& dest )
-{
-    OCX_Control* seperator = new OCX_CommandButton;
-    seperator->SetInDialog(true);
-    seperator->sName = C2S("GroupSeperator");
-    dest.push_back( seperator );
-}
-
-void addRButtons( std::vector< OCX_Control* >& src,
-                  std::vector< OCX_Control* >& dest,
-                  bool addGroupSeperator )
-{
-    if ( addGroupSeperator )
-    {
-        addSeperator( dest );
-    }
-
-    for ( CtrlIterator rbIter = src.begin(); rbIter != src.end(); ++rbIter )
-    {
-        dest.push_back( *rbIter );
-    }
-}
-
-void OCX_ContainerControl::ProcessControl(OCX_Control* pControl,SvStorageStream* /* pS */,  ContainerRecord& rec )
-{
-    SotStorageStreamRef oStream = mContainedControlsStream;
-
-    // can insert into OO Dialog (e.g is this a supported dialog control)??
-    if ( rec.nTypeIdent == TABSTRIP )
-    {
-        // skip the record in the stream, discard the control
-        oStream->SeekRel( rec.nSubStreamLen );
-        delete pControl;
-    }
-    else
-    {
-        // A container control needs to read the f stream in
-        // the folder ( substorage ) associated with this control
-        switch ( rec.nTypeIdent )
-        {
-            case FRAME:
-            case MULTIPAGE:
-            case PAGE:
-                {
-                    OCX_ContainerControl* pContainer =
-                        static_cast< OCX_ContainerControl* >( pControl );
-                    oStream = pContainer->getContainerStream();
-                    break;
-                }
-            case LISTBOX:
-            case OPTIONBUTTON:
-            case COMBOBOX:
-            case SPINBUTTON:
-            case SCROLLBAR:
-                {
-                    pControl->msCtrlSource = rec.sCtrlSource;
-                    pControl->msRowSource = rec.sRowSource;
-                }
-        }
-        pControl->sName = rec.cName;
-        pControl->msToolTip = rec.controlTip;
-        // Position of controls is relative to the container
-        pControl->mnTop = rec.nTop + mnTop;
-        pControl->mnLeft = rec.nLeft + mnLeft;
-        // MS tabIndex, pretty useless in OpenOffice land
-        // as tab indexes in MS are relative to parent container.
-        // However we need this value in order to set
-        // OpenOffice tab indices in a sensible way to
-        // reflect the ms tabbing from orig MS UserForm, see below
-        pControl->mnTabPos = rec.nTabPos;
-        pControl->SetInDialog(true);
-        pControl->mbVisible = rec.bVisible;
-        if ( mnStep )
-        {
-            // If the container has a step then it should be
-            // applied to all containees
-            pControl->mnStep = mnStep;
-        }
-        pControl->msParentName = sName;
-
-        // #117490# DR: container records provide size of substream, use it here...
-
-        // remember initial position to set correct stream position
-        ULONG nStrmPos = oStream->Tell();
-        // import control, may return with invalid stream position
-        pControl->FullRead(oStream);
-        // set stream to position behind substream of this control
-        oStream->Seek( nStrmPos + rec.nSubStreamLen );
-
-        mpControls.push_back( pControl );
-    }
-}
-
-sal_Bool OCX_ContainerControl::Read(SvStorageStream *pS)
-{
-
-    if ( mpParent )
-    {
-        mnBackColor = mpParent->mnBackColor;
-    }
-
-    std::auto_ptr< ContainerRecReader > reader (
-        ContainerRecordReaderFac::instance( containerType ) );
-
-    reader->Read( this, pS );
-    // Need to honour the MS Tab Indexes. However MS tab indexes are
-    // relative to parent, this hack sorts the controls in each container
-    // based on the ms tab indexes. When import is called we create the
-    // controls in Open/Star office based on the order of the tab indexes,
-    // this ensures that the default tab index created by Star/Open office
-    // reflects the "flattened" ms tab order.
-    ::std::sort( mpControls.begin(), mpControls.end(), SortOrderByTabPos() );
-    return true;
-}
-
 OCX_MultiPage::OCX_MultiPage( SotStorageRef& parent,
             const ::rtl::OUString& storageName,
             const ::rtl::OUString& sN,
             const uno::Reference< container::XNameContainer >  &rDialog,
             OCX_Control* pParent):
-        OCX_ContainerControl(parent, storageName, sN, rDialog, pParent ), fUnknown1(0), fEnabled(1),
-        fLocked(0), fBackStyle(1), fWordWrap(1), fAutoSize(0), nCaptionLen(0),
-        nVertPos(1), nHorzPos(7), nMousePointer(0), nBorderColor(0x80000012),
-        nKeepScrollBarsVisible(3), nCycle(0), nBorderStyle(0), nSpecialEffect(0),
-        nPicture(0), nPictureAlignment(2), nPictureSizeMode(0),
-        bPictureTiling(FALSE), nAccelerator(0), nIcon(0), pCaption(0),
-        nScrollWidth(0), nScrollHeight(0), nIconLen(0), pIcon(0), nPictureLen(0),
-        pPicture(0)
-{
-    //msDialogType = C2U("NotSupported");
+                OCX_ParentControl(parent, storageName, sN, rDialog, pParent ), bHasTabs( true )
+
+{
     msDialogType = C2U("com.sun.star.awt.UnoMultiPageModel");
     mnForeColor = 0x80000012L,
     mnBackColor = 0x8000000FL;
     bSetInDialog = true;// UserForm control only
     aFontData.SetHasAlign(TRUE);
-    containerType = MULTIPAGE;
-    mnCurrentPageStep = 0;
+    nActiveTab = 0;
+    // open up the 'x' stream
+    mXStream = mContainerStorage->OpenSotStream(
+        String(RTL_CONSTASCII_STRINGPARAM("x"),
+        RTL_TEXTENCODING_MS_1252),
+        STREAM_STD_READ | STREAM_NOCREATE);
 }
 
 void OCX_MultiPage::ProcessControl(OCX_Control* pControl, SvStorageStream* /* pS */,  ContainerRecord& rec )
 {
     SotStorageStreamRef oStream = mContainedControlsStream;
 
-    OCX_Page *pPage = NULL;
-    if ( rec.nTypeIdent == PAGE )
-        pPage = static_cast< OCX_Page* >( pControl );
-    if ( pPage != NULL )
+    if ( rec.nTypeIdent == TABSTRIP )
     {
-        pPage->mnStep = ++mnCurrentPageStep;
-
-        pPage->mnTop =  mnTop;// move these to Page::import ?
-        pPage->mnLeft = mnLeft;
-        pPage->mnBackColor = mnBackColor;
-
-        oStream = pPage->getContainerStream();;
-        // Position of controls is relative to pos of this MuliPage
-        // Control
-        pPage->FullRead( oStream );
+        // TabStrip reads the 'o' stream
+        OCX_TabStrip oTabStrip;
+        oTabStrip.sName = C2S("FromMultiPage-o");
+        oTabStrip.Read( mContainedControlsStream );
+        sCaptions = oTabStrip.msItems;
+        bHasTabs = oTabStrip.bHasTabs;
+        nHeight = oTabStrip.nHeight;
+        nWidth = oTabStrip.nWidth;
+    }
+    else if ( rec.nTypeIdent == PAGE )
+    {
+        OCX_Page *pPage = NULL;
+        pPage = static_cast< OCX_Page* >( pControl );
+        if ( pPage != NULL )
+        {
+            oStream = pPage->getContainerStream();;
+            // Position of controls is relative to pos of this MuliPage
+            // Control
+            pPage->FullRead( oStream );
+            // nWidth & nHeight seem to screw up multipage control
+            pPage->nWidth = 0;
+            pPage->nHeight = 0;
+            pPage->mnBackColor = mnBackColor;
+
+            mpControls.push_back( pPage );
+            idToPage[ pPage->mnID ] = pPage;
+        }
 
-        mpControls.push_back( pPage );
     }
     else
     {
@@ -4001,110 +3863,78 @@ sal_Bool OCX_MultiPage::Read(SvStorageStream *pS)
 {
     // Unlike the other containers e.g. UserForm & Frame
     // the o stream is does not contain info for the contained controls
-    // ( e.g. the pages themselves ) but seems to be for the MultiPage
-    // itself - need to check this in more detail
-
-    // For the moment skip read of the MultiPage specific properties
-    // not much point reading these as we can't display the multi page
-    // control or in fact any sort of tabbed layout, best we can do is
-    // import just the contained controls of the individual pages
-    // Note: the record skipped below ( does not contain the expected
-    // info on this control, that seems to be contained in the o stream,
-    // see comment above)
+    // 'o' stream contains a tabstrip control
+    // 'f' stream as usual ( info about the containees )
+    // '01..09' ( etc. ) these streams contain the page controls
+    // 'x' stream, this contains an array of properties for each page followed
+    //    by a set of properties for the multipage control itself
+
+    // read the 'f' stream
+    OCX_ParentControl::Read(pS);
+
+    // Read the 'x' stream
+    // consists of
+    //   a) nTabs + 1 PageProperties ( which are little use to us )
+    //      => skip
+    //   b) a MutliPageProperty ( which contains at least the page count and
+    //       IDs of the pages ( and order ) - useful for associating correct page
+    //       with correct tab
+
+
     OCX_Control skip(C2S("Dummy"));
-    skip.Read( pS );
-    mnCurrentPageStep = mnStep; //( set step of of pages relative to step
-                                //of this MultiPage ( e.g. emulate containment )
-    return OCX_ContainerControl::Read(pS);
+    sal_Int32 nPagePropsToRead = sCaptions.size() + 1;
+    for ( sal_Int32 page = 0; page < nPagePropsToRead; ++page )
+        skip.Read( mXStream );
+    MultiPageProps multiPage;
+    multiPage.Read( mXStream );
+    mPageIds = multiPage.mnIDs;
+    return true;
 }
 
 
 sal_Bool OCX_MultiPage::Import(com::sun::star::uno::Reference<
     com::sun::star::beans::XPropertySet> &rPropSet)
 {
-    OCX_ContainerControl::Import( rPropSet );
-    return sal_True;
-}
-
-sal_Bool OCX_MultiPage::Import(com::sun::star::uno::Reference<
-        com::sun::star::container::XNameContainer>
-        &rDialog)
-{
-    uno::Reference<beans::XPropertySet> xPropSet( rDialog, uno::UNO_QUERY );
-
-    // Although MultiPage is not represeted by a "real" control we still
-    // need to propagate the backcolor of this logical parent
-    // ( the dialog or Frame or whatever ) to the children of this control.
-    // For example the controls contained in the Page of a
-    // MultiPage control use the parents backcolor ( e,g,
-    // Pages backcolor ) when trying to fake transparency
-    mnBackColor = mpParent->mnBackColor;
-
-    if ( xPropSet.is() )
-    {
-        uno::Reference<lang::XMultiServiceFactory>
-            xFactory(rDialog, uno::UNO_QUERY);
-    OSL_TRACE("** MultiPage creating control %s", rtl::OUStringToOString( msDialogType, RTL_TEXTENCODING_UTF8 ).getStr() );
-    uno::Reference<uno::XInterface> xCreate = xFactory->createInstance(msDialogType);
-    if (!xCreate.is())
-        return sal_False;
-
-    uno::Reference<awt::XControlModel> xModel(xCreate, uno::UNO_QUERY);
-    if (!xModel.is())
-        return sal_False;
-
-        try
+    uno::Any aTmp(&sName,getCppuType((OUString *)0));
+    rPropSet->setPropertyValue(
+        OUString(RTL_CONSTASCII_USTRINGPARAM("Name")), aTmp);
+    if ( !bHasTabs )
+        rPropSet->setPropertyValue(
+            OUString(RTL_CONSTASCII_USTRINGPARAM("Decoration")), uno::makeAny( sal_False ) );
+    aTmp <<= ImportColor(mnBackColor);
+    rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
+    // apply caption/titles to pages
+    std::vector<sal_Int32>::iterator itCtrlId = mPageIds.begin();
+    std::vector<sal_Int32>::iterator itCtrlId_end = mPageIds.end();
+    std::vector< rtl::OUString >::iterator  itCaption = sCaptions.begin();
+    mpControls.clear();
+    // need to sort the controls according to the order of the ids
+    for ( sal_Int32 index = 1 ; ( sCaptions.size() == idToPage.size() ) && itCtrlId != itCtrlId_end; ++itCtrlId, ++itCaption, ++index )
+    {
+        std::hash_map< sal_Int32, OCX_Page* >::iterator it = idToPage.find( *itCtrlId );
+        if ( it != idToPage.end() )
         {
-        // we should just call MultiPage::Import( XPropertySet )
-    		OSL_TRACE("********* MULTIPAGE cName %s", rtl::OUStringToOString( sName, RTL_TEXTENCODING_UTF8 ).getStr() );
-        uno::Any aTmp(&sName,getCppuType((OUString *)0));
-        uno::Reference<beans::XPropertySet> xPrps(xModel, uno::UNO_QUERY);
-        xPrps->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );
-        aTmp = uno::makeAny( mnCurrentPageStep );
-        xPrps->setPropertyValue( WW8_ASCII2STR("ProgressValueMax"), aTmp );
-        // default current page to 0 ( #FIXME, we need to read this value )
-        aTmp = uno::makeAny( sal_Int32(0) );
-        xPrps->setPropertyValue( WW8_ASCII2STR("ProgressValue"), aTmp );
-    		OSL_TRACE("********* MULTIPAGE vomitted out properties");
+            it->second->msTitle = *itCaption;
+            if ( it->second->mbVisible )
+                nActiveTab = index;
+            mpControls.push_back( it->second );
 
-    // Calls import on contained controls
-            rDialog->insertByName(sName, uno::makeAny(xModel));
-            OSL_TRACE("*** inserted ***");
         }
-        catch( uno::Exception& )
-        {
-            DBG_ERRORFILE(
-                ByteString( "OCX_Control::Import - cannot insert control \"" ).
-                Append( ByteString( sName, RTL_TEXTENCODING_UTF8 ) ).
-                Append( '"' ).GetBuffer() );
-        }
-
-        // Calls import on contained pages
-        return OCX_ContainerControl::Import( xPropSet );
     }
-    OSL_TRACE("*** Major problem, no dialog to add controls to ");
-    DBG_ERROR(" Major problem, no dialog to add controls to ");
-    return false;
-}
-
 
+    OCX_ParentControl::Import( rPropSet );
+    rPropSet->setPropertyValue( WW8_ASCII2STR("MultiPageValue"), uno::makeAny( nActiveTab ));
+    return sal_True;
+}
 
 OCX_Page::OCX_Page( SotStorageRef& parent,
-            const ::rtl::OUString& storageName,
+            sal_Int32 nId,
             const ::rtl::OUString& sN,
             const uno::Reference< container::XNameContainer >  &rDialog,
             OCX_Control* pParent):
-        OCX_ContainerControl(parent, storageName, sN, rDialog, pParent ),
-        fUnknown1(0), fEnabled(1), fLocked(0),
-        fBackStyle(1), fWordWrap(1), fAutoSize(0), nCaptionLen(0), nVertPos(1),
-        nHorzPos(7), nMousePointer(0), nBorderColor(0x80000012),
-        nKeepScrollBarsVisible(3), nCycle(0), nBorderStyle(0), nSpecialEffect(0),
-        nPicture(0), nPictureAlignment(2), nPictureSizeMode(0),
-        bPictureTiling(FALSE), nAccelerator(0), nIcon(0), pCaption(0),
-        nScrollWidth(0), nScrollHeight(0), nIconLen(0), pIcon(0), nPictureLen(0),
-        pPicture(0)
-{
-    msDialogType = C2U("NotSupported");
+                OCX_ParentControl(parent, createSubStreamName( nId ), sN, rDialog, pParent ), mnID( nId )
+{
+    msDialogType = C2U("com.sun.star.awt.UnoPageModel");
     mnForeColor = 0x80000012,
     mnBackColor = 0x8000000F,
     bSetInDialog = true;// UserForm control only
@@ -4114,65 +3944,35 @@ OCX_Page::OCX_Page( SotStorageRef& parent,
 
 sal_Bool OCX_Page::Read(SvStorageStream *pS)
 {
-    long nStart = pS->Tell();
-    *pS >> nIdentifier;
-    DBG_ASSERT(0x400==nIdentifier,
-            "A control that has a different identifier");
-    *pS >> nFixedAreaLen;
-    pS->Read(pBlockFlags,4);
-
-    pS->SeekRel( nFixedAreaLen - sizeof( pBlockFlags ) );
-
-    ReadAlign( pS, pS->Tell() - nStart, 4);
-
-    if (pBlockFlags[2] & 0x10)
-    {
-        //Font Stuff..
-        pS->SeekRel(0x1a);
-        sal_uInt8 nFontLen;
-        *pS >> nFontLen;
-        pS->SeekRel(nFontLen);
-    }
-    return OCX_ContainerControl::Read(pS);
-
+    return OCX_ParentControl::Read(pS);
 }
 
 sal_Bool OCX_Page::Import(com::sun::star::uno::Reference<
-        com::sun::star::container::XNameContainer>
-        &rDialog)
+    com::sun::star::beans::XPropertySet>
+    &rPropSet)
 {
+    uno::Any aTmp(&sName,getCppuType((OUString *)0));
+    rPropSet->setPropertyValue(
+        OUString(RTL_CONSTASCII_USTRINGPARAM("Name")), aTmp);
+
+    if (msTitle.getLength())
+        rPropSet->setPropertyValue( WW8_ASCII2STR("Title"), uno::makeAny( msTitle ) );
+
+    aTmp <<= ImportColor(mnBackColor);
+    rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
+
+    // Calls import on contained controls
+    OCX_ParentControl::Import( rPropSet );
+    return sal_True;
 
-    uno::Reference<beans::XPropertySet> xPropSet( rDialog, uno::UNO_QUERY );
-    if ( xPropSet.is() )
-    {
-        // apply Step to contained controls
-        CtrlIterator aEnd = mpControls.end();
-        for (CtrlIterator aIter = mpControls.begin(); aIter != aEnd; ++ aIter )
-        {
-            (*aIter)->mnStep = mnStep;
-        }
-        // Calls import on contained pages
-        return OCX_ContainerControl::Import( xPropSet );
-    }
-    OSL_TRACE("*** Major problem, no dialog to add controls to ");
-    DBG_ERROR("*** Major problem, no dialog to add controls to ");
-    return sal_False;
 }
 
 OCX_Frame::OCX_Frame( SotStorageRef& parent,
             const ::rtl::OUString& storageName,
             const ::rtl::OUString& sN,
-            const uno::Reference< container::XNameContainer >  &rDialog, OCX_Control* pParent):
-        OCX_ContainerControl(parent, storageName, sN, rDialog, pParent ),fUnknown1(0),fEnabled(1), fLocked(0),
-        fBackStyle(1), fWordWrap(1), fAutoSize(0), nCaptionLen(0), nVertPos(1),
-        nHorzPos(7), nMousePointer(0), nBorderColor(0x80000012),
-        nKeepScrollBarsVisible(3), nCycle(0), nBorderStyle(0), nSpecialEffect(0),
-        nPicture(0), nPictureAlignment(2), nPictureSizeMode(0),
-        bPictureTiling(FALSE), nAccelerator(0), nIcon(0), pCaption(0),
-        nScrollWidth(0), nScrollHeight(0), nScrollLeft(0), nScrollTop(0), nIconLen(0), pIcon(0), nPictureLen(0),
-        pPicture(0)
-{
-    msDialogType = C2U("com.sun.star.awt.UnoControlGroupBoxModel");
+            const uno::Reference< container::XNameContainer >  &rDialog, OCX_Control* pParent): OCX_ParentControl(parent, storageName, sN, rDialog, pParent )
+{
+    msDialogType = C2U("com.sun.star.awt.UnoFrameModel");
     mnForeColor = 0x80000012;
     mnBackColor = 0x8000000F;
     bSetInDialog = true;// UserForm control only
@@ -4182,159 +3982,7 @@ OCX_Frame::OCX_Frame( SotStorageRef& parent,
 
 sal_Bool OCX_Frame::Read(SvStorageStream *pS)
 {
-    long nStart = pS->Tell();
-    *pS >> nIdentifier;
-    DBG_ASSERT(0x400==nIdentifier,
-            "A control that has a different identifier");
-    *pS >> nFixedAreaLen;
-    pS->Read(pBlockFlags,4);
-
-    if (pBlockFlags[0] & 0x01)
-    {
-            DBG_ASSERT(!this, "ARSE");
-    }
-    if (pBlockFlags[0] & 0x02)
-            *pS >> mnBackColor;
-    if (pBlockFlags[0] & 0x04)
-            *pS >> mnForeColor;
-    if (pBlockFlags[0] & 0x08)
-        *pS >> fUnknown1;
-    if (pBlockFlags[0] & 0x40)
-    {
-        sal_uInt8 nTemp;
-        *pS >> nTemp;
-        fEnabled = (nTemp&0x04)>>2;
-        fBackStyle = (nTemp&0x08)>>3;
-        *pS >> nTemp;
-        *pS >> nTemp;
-        fWordWrap = (nTemp&0x80)>>7;
-        *pS >> nTemp;
-        fAutoSize = (nTemp&0x10)>>4;
-    }
-    if (pBlockFlags[0] & 0x80)
-    {
-        *pS >> nBorderStyle;
-    }
-
-    ReadAlign(pS, pS->Tell() - nStart, 4);
-
-    if (pBlockFlags[1] & 0x01)
-        *pS >> nMousePointer;
-    if (pBlockFlags[1] & 0x02)
-        *pS >> nKeepScrollBarsVisible;
-    if (pBlockFlags[1] & 0x20)
-        *pS >> fUnknown1; // another unknown 32 bit ( or is 8 or 16 bit with padding ? )
-
-    if (pBlockFlags[1] & 0x80)
-    {
-        ReadAlign(pS, pS->Tell() - nStart, 2);
-        *pS >> nIcon;
-        DBG_ASSERT(nIcon == 0xFFFF, "Unexpected nIcon");
-    }
-
-    bool bCaption = false;
-
-    if (pBlockFlags[2] & 0x01)
-        *pS >> nCycle;
-    if (pBlockFlags[2] & 0x02)
-        *pS >> nSpecialEffect;
-
-    if (pBlockFlags[2] & 0x04)
-    {
-        ReadAlign(pS, pS->Tell() - nStart, 4);
-        *pS >> nBorderColor;
-    }
-
-    if (pBlockFlags[2] & 0x08)
-    {
-        ReadAlign(pS, pS->Tell() - nStart, 4);
-        *pS >> nCaptionLen;
-        bCaption = true;
-    }
-
-    if (pBlockFlags[2] & 0x10)
-    {
-        ReadAlign(pS, pS->Tell() - nStart, 2);
-        sal_uInt16 nNoIdea;
-        *pS >> nNoIdea;
-        DBG_ASSERT(nNoIdea == 0xFFFF, "Expected 0xFFFF, (related to font ?)");
-    }
-
-    if (pBlockFlags[2] & 0x20)
-    {
-        ReadAlign(pS, pS->Tell() - nStart, 2);
-        *pS >> nPicture;
-        DBG_ASSERT(nPicture == 0xFFFF, "Unexpected nIcon");
-    }
-
-    if (pBlockFlags[2] & 0x80)
-        *pS >> nPictureAlignment;
-
-    if (pBlockFlags[3] & 0x01)
-        bPictureTiling = true;
-
-    if (pBlockFlags[3] & 0x02)
-        *pS >> nPictureSizeMode;
-
-    if (pBlockFlags[3] & 0x04)
-    {
-        ReadAlign(pS, pS->Tell() - nStart, 4);
-        *pS >> fUnknown8;
-    }
-
-    if (pBlockFlags[3] & 0x08)
-    {
-        ReadAlign(pS, pS->Tell() - nStart, 4);
-        *pS >> fUnknown9;
-    }
-
-    ReadAlign(pS, pS->Tell() - nStart, 4);
-    *pS >> nWidth;
-    *pS >> nHeight;
-    *pS >> nScrollWidth;
-    *pS >> nScrollHeight;
-
-    if (pBlockFlags[1] & 0x10)
-    {
-        *pS >> nScrollLeft;
-        *pS >> nScrollTop;
-    }
-
-    if ( bCaption )
-    {
-        lclReadCharArray( *pS, pCaption, nCaptionLen, pS->Tell() - nStart);
-    }
-
-    OUString tempCaption =  lclCreateOUString( pCaption, nCaptionLen );
-
-    if (nIcon)
-    {
-        pS->Read(pIconHeader,20);
-        *pS >> nIconLen;
-        pIcon = new sal_uInt8[nIconLen];
-        pS->Read(pIcon,nIconLen);
-    }
-
-    if (nPicture)
-    {
-        pS->Read(pPictureHeader,20);
-        *pS >> nPictureLen;
-        pPicture = new sal_uInt8[nPictureLen];
-        pS->Read(pPicture,nPictureLen);
-    }
-
-    ReadAlign( pS, pS->Tell() - nStart, 4);
-
-    if (pBlockFlags[2] & 0x10)
-    {
-        //Font Stuff..
-        pS->SeekRel(0x1a);
-        sal_uInt8 nFontLen;
-        *pS >> nFontLen;
-        pS->SeekRel(nFontLen);
-    }
-
-    return OCX_ContainerControl::Read( pS );
+    return OCX_ParentControl::Read( pS );
 }
 
 sal_Bool OCX_Frame::Import(com::sun::star::uno::Reference<
@@ -4349,195 +3997,26 @@ sal_Bool OCX_Frame::Import(com::sun::star::uno::Reference<
         rPropSet->setPropertyValue( WW8_ASCII2STR("Label"), aTmp);
     }
 
+    aTmp <<= ImportColor(mnBackColor);
+    rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
+
     // Calls import on contained controls
-    OCX_ContainerControl::Import( rPropSet );
+    OCX_ParentControl::Import( rPropSet );
     return sal_True;
 }
+
 OCX_UserForm::OCX_UserForm( SotStorageRef& parent,
             const OUString& storageName,
             const OUString& sN,
             const ::uno::Reference< container::XNameContainer >  &rDialog,
             const ::uno::Reference< lang::XMultiServiceFactory >& rMsf):
-        OCX_ContainerControl(parent, storageName, sN, rDialog),
-        nChildrenA(0), fEnabled(1), fLocked(0),
-        fBackStyle(1), fWordWrap(1), fAutoSize(0), nCaptionLen(0), nVertPos(1),
-        nHorzPos(7), nMousePointer(0), nBorderColor(0x80000012), nChildrenB(0),
-        nKeepScrollBarsVisible(3), nCycle(0), nBorderStyle(0), nSpecialEffect(0),
-        nPicture(0), nPictureAlignment(2), nPictureSizeMode(0),
-        bPictureTiling(FALSE), nAccelerator(0), nIcon(0), pCaption(0),
-        nScrollWidth(0), nScrollHeight(0), nScrollLeft(0), nScrollTop(0), nIconLen(0), pIcon(0), nPictureLen(0)
-    {
-            mnForeColor = 0x80000012;
-            mnBackColor = 0x8000000F;
-            uno::Reference< beans::XPropertySet> xProps( rMsf, uno::UNO_QUERY);
-            if ( xProps.is() )
-            {
-                xProps->getPropertyValue(C2S("DefaultContext"))  >>= mxCtx;
-            }
-            aFontData.SetHasAlign(TRUE);
-        }
-sal_Bool OCX_UserForm::Read(SvStorageStream *pS)
-{
-    long nStart = pS->Tell();
-    *pS >> nIdentifier;
-    DBG_ASSERT(0x400==nIdentifier,
-            "A control that has a different identifier");
-    *pS >> nFixedAreaLen;
-    pS->Read(pBlockFlags,4);
-
-    if (pBlockFlags[0] & 0x01)
+            OCX_ParentControl(parent, storageName, sN, rDialog )
     {
-            DBG_ASSERT(!this, "ARSE");
-    }
-    if (pBlockFlags[0] & 0x02)
-        *pS >> mnBackColor;
-    if (pBlockFlags[0] & 0x04)
-        *pS >> mnForeColor;
-    if (pBlockFlags[0] & 0x08)
-        *pS >> nChildrenA;
-    if (pBlockFlags[0] & 0x40)
-    {
-        sal_uInt8 nTemp;
-        *pS >> nTemp;
-        fEnabled = (nTemp&0x04)>>2;
-        fBackStyle = (nTemp&0x08)>>3;
-        *pS >> nTemp;
-        *pS >> nTemp;
-        fWordWrap = (nTemp&0x80)>>7;
-        *pS >> nTemp;
-        fAutoSize = (nTemp&0x10)>>4;
-    }
-    if (pBlockFlags[0] & 0x80)
-    {
-        ReadAlign(pS, pS->Tell() - nStart, 4);
-        *pS >> nBorderStyle;
-    }
-#if 0
-        sal_uInt16 nFixedOrAlign;
-        *pS >> nFixedOrAlign;
-#endif
-    if (pBlockFlags[1] & 0x01)
-        *pS >> nMousePointer;
-    if (pBlockFlags[1] & 0x02)
-        *pS >> nKeepScrollBarsVisible;
-    if (pBlockFlags[1] & 0x20)
+    uno::Reference< beans::XPropertySet> xProps( rMsf, uno::UNO_QUERY);
+    if ( xProps.is() )
     {
-        sal_uInt32 nUnknown32;
-        *pS >> nUnknown32;
+        xProps->getPropertyValue(C2S("DefaultContext"))  >>= mxCtx;
     }
-    if (pBlockFlags[1] & 0x80)
-    {
-        ReadAlign(pS, pS->Tell() - nStart, 2);
-        *pS >> nIcon;
-        DBG_ASSERT(nIcon == 0xFFFF, "Unexpected nIcon");
-    }
-    if (pBlockFlags[2] & 0x01)
-        *pS >> nCycle;
-    if (pBlockFlags[2] & 0x02)
-        *pS >> nSpecialEffect;
-
-    if (pBlockFlags[2] & 0x04)
-    {
-        ReadAlign(pS, pS->Tell() - nStart, 4);
-        *pS >> nBorderColor;
-    }
-
-    if (pBlockFlags[2] & 0x10)
-    {
-        ReadAlign(pS, pS->Tell() - nStart, 2);
-        sal_uInt16 nNoIdea;
-        *pS >> nNoIdea;
-        DBG_ASSERT(nNoIdea == 0xFFFF, "Expected 0xFFFF, (related to font ?)");
-    }
-
-    if (pBlockFlags[2] & 0x20)
-    {
-        ReadAlign(pS, pS->Tell() - nStart, 2);
-        *pS >> nPicture;
-        DBG_ASSERT(nPicture == 0xFFFF, "Unexpected nIcon");
-    }
-
-    if (pBlockFlags[2] & 0x80)
-        *pS >> nPictureAlignment;
-
-    if (pBlockFlags[3] & 0x01)
-        bPictureTiling = true;
-
-    if (pBlockFlags[3] & 0x02)
-        *pS >> nPictureSizeMode;
-
-    if (pBlockFlags[3] & 0x04)
-    {
-        ReadAlign(pS, pS->Tell() - nStart, 4);
-        *pS >> nChildrenB;
-    }
-
-    ReadAlign(pS, pS->Tell() - nStart, 4);
-    *pS >> nDrawBuffer;
-
-    ReadAlign(pS, pS->Tell() - nStart, 4);
-    *pS >> nWidth;
-    *pS >> nHeight;
-    *pS >> nScrollWidth;
-    *pS >> nScrollHeight;
-
-    if (pBlockFlags[1] & 0x10)
-    {
-        *pS >> nScrollLeft;
-        *pS >> nScrollTop;
-    }
-
-    if (nIcon)
-    {
-        pS->Read(pIconHeader,20);
-        *pS >> nIconLen;
-        pIcon = new sal_uInt8[nIconLen];
-        pS->Read(pIcon,nIconLen);
-    }
-
-    ReadAlign( pS, pS->Tell() - nStart, 4);
-    if (pBlockFlags[2] & 0x10)
-    {
-        //Font Stuff..
-        pS->SeekRel(0x1a);
-        sal_uInt8 nFontLen;
-        *pS >> nFontLen;
-        pS->SeekRel(nFontLen);
-    }
-    if (nPicture)
-    {
-        pS->Read(pPictureHeader,20);
-        *pS >> nPictureLen;
-        long imagePos = pS->Tell();
-        // great embedded object
-        mxGrfObj = lcl_readGraphicObject( pS );
-        if( mxGrfObj.is() )
-        {
-            sImageUrl = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( GRAPHOBJ_URLPREFIX ) );
-            sImageUrl = sImageUrl + mxGrfObj->getUniqueID();
-        }
-        // make sure the stream position should be pointing after the image.
-        pS->Seek( imagePos + nPictureLen );
-    }
-
-    sal_Int16 numTrailingRecs = 0;
-    *pS >> numTrailingRecs;
-    // seems to be no. of trailing records,
-    // before container record starts proper
-    // ( unknown what these trailing records are for)
-    if ( numTrailingRecs )
-    {
-        for ( sal_Int16 i = 0 ; numTrailingRecs ; --numTrailingRecs, ++i )
-        {
-            sal_uInt16 nTypeID = 0;
-            if ( lcl_handleActiveXControl( pS, nTypeID ) )
-            {
-                if ( nTypeID & 0x8000 ) // valid ActiveXID
-                    mActiveXIDMap[ ( i | 0x8000 ) ] = nTypeID;
-            }
-        }
-    }
-    return OCX_ContainerControl::Read( pS );
 }
 
 sal_Bool OCX_UserForm::Import(
@@ -4563,9 +4042,15 @@ sal_Bool OCX_UserForm::Import(
     aTmp <<= sal_Int32( aAppFontSize.Height ); //100th mm
     xDialogPropSet->setPropertyValue(WW8_ASCII2STR("Height"), aTmp);
 
+    if ( sImageUrl.getLength() )
+    {
+        aTmp <<= sImageUrl;
+        xDialogPropSet->setPropertyValue( WW8_ASCII2STR("ImageURL"), aTmp);
+    }
 
     uno::Reference<beans::XPropertySet> xPropSet( mxParent, uno::UNO_QUERY );
-    OCX_ContainerControl::Import( xPropSet );
+    OCX_ParentControl::Import( xPropSet );
+    uno::Reference< frame::XModel > xModel(  pDocSh ? pDocSh->GetModel() : NULL );
 
     uno::Reference<io::XInputStreamProvider> xSource =
         xmlscript::exportDialogModel(mxParent, mxCtx, pDocSh->GetModel() );
@@ -5133,6 +4618,11 @@ sal_Bool OCX_CheckBox::Import(com::sun::star::uno::Reference<
     rPropSet->setPropertyValue( WW8_ASCII2STR("VerticalAlign"), aTmp );
 
     aFontData.Import(rPropSet);
+    if ( sImageUrl.getLength() )
+    {
+        aTmp <<= sImageUrl;
+        rPropSet->setPropertyValue( WW8_ASCII2STR("ImageURL"), aTmp);
+    }
     return(sal_True);
 }
 
@@ -5592,38 +5082,248 @@ sal_Bool HTML_TextBox::ReadFontData(SotStorageStream * /*pS*/)
   return sal_True;
 }
 
+sal_Bool HTML_TextBox::ReadFontData(SotStorageStream *pS)
+{
+  return sal_True;
+}
+
 
 // Doesn't really read anything but just skips the
 // record.
 sal_Bool OCX_TabStrip::Read(SotStorageStream *pS)
 {
-    const long skipLen = 0x18;
+    long nStart = pS->Tell();
     *pS >> nIdentifier;
     DBG_ASSERT(nStandardId==nIdentifier,
         "A control that has a different identifier");
     *pS >> nFixedAreaLen;
 
     pS->Read(pBlockFlags, sizeof(pBlockFlags));
-    pS->SeekRel(skipLen);
-    *pS >> nNumTabs;
-    // skip to end of control
-    pS->SeekRel(nFixedAreaLen - sizeof(pBlockFlags) - sizeof(nNumTabs) - skipLen );
-    return sal_True;
-}
 
-sal_Bool OCX_TabStrip::ReadFontData(SotStorageStream *pS)
-{
-    // Seems like there is a real font record followed by
-    // a number of blank records ( e.g. nFixedAreaLen = 0 )
-    // The number of trailing blank records is equal to the number of tabs
-    OCX_Control::ReadFontData(pS);
-    for ( sal_uInt16 index = 0; index < nNumTabs; index++ )
+    bool bSize = false;
+    bool bMultiRow = false;
+    bool bTooltips = true;
+    bool hasEmbeddedImage = false;
+    sal_Int32 nameSize = 0;
+    sal_Int32 tipStringSize = 0;
+    sal_Int32 nAcceleratorSize = 0;
+    sal_Int32 nItemSize = 0;
+    sal_Int32 nTagSize = 0;
+    if ( pBlockFlags[ 0 ] & 0x01 )
+    {
+        //List index
+        ReadAlign(pS, pS->Tell() - nStart, 4);
+        sal_Int32 nOptional32 = 0; //
+        *pS >> nOptional32;
+    }
+    if (pBlockFlags[0] & 0x02)
+    {
+        ReadAlign(pS, pS->Tell() - nStart, 4);
+        *pS >> mnBackColor;
+    }
+    if (pBlockFlags[0] & 0x04)
+    {
+        ReadAlign(pS, pS->Tell() - nStart, 4);
+        *pS >> mnForeColor;
+    }
+    if (pBlockFlags[0] & 0x10)
+         bSize = true;
+    if (pBlockFlags[0] & 0x20)
+    {
+        ReadAlign(pS, pS->Tell() - nStart, 4);
+        *pS >> nItemSize;
+    }
+    if (pBlockFlags[0] & 0x40)
+    {
+        sal_Int8 nOptional8 = 0; // mouse pointer
+        *pS >> nOptional8;
+    }
+    if (pBlockFlags[1] & 0x01)
+    {
+        ReadAlign(pS, pS->Tell() - nStart, 4);
+        sal_Int32 nOptional32 = 0; // taborientation
+        *pS >> nOptional32;
+    }
+    if (pBlockFlags[1] & 0x02)
+    {
+        ReadAlign(pS, pS->Tell() - nStart, 4);
+        sal_Int32 nOptional32 = 0; // tabstyle
+        *pS >> nOptional32;
+        if ( nOptional32 == 2 )
+            bHasTabs =false;
+    }
+    if (pBlockFlags[1] & 0x04)
+        bMultiRow = true;
+    if (pBlockFlags[1] & 0x08)
+    {
+        ReadAlign(pS, pS->Tell() - nStart, 4);
+        sal_Int32 nOptional32 = 0; // tabfixedwidth
+        *pS >> nOptional32;
+    }
+    if (pBlockFlags[1] & 0x10)
+    {
+        ReadAlign(pS, pS->Tell() - nStart, 4);
+        sal_Int32 nOptional32 = 0; // tabfixedheight
+        *pS >> nOptional32;
+    }
+    if (pBlockFlags[1] & 0x20)
+        bTooltips = false;
+
+    if (pBlockFlags[1] & 0x80)
+    {
+        ReadAlign(pS, pS->Tell() - nStart, 4);
+        *pS >> tipStringSize;
+    }
+
+    if (pBlockFlags[2] & 0x02)
+    {
+        ReadAlign(pS, pS->Tell() - nStart, 4);
+        *pS >> nameSize;
+    }
+
+    if (pBlockFlags[2] & 0x04)
+    {
+        ReadAlign(pS, pS->Tell() - nStart, 4);
+        sal_Int32 nOptional32 = 0; // variouspropertybits
+        *pS >> nOptional32;
+    }
+
+    if (pBlockFlags[2] & 0x10)
+    {
+        ReadAlign(pS, pS->Tell() - nStart, 4);
+        sal_Int32 nOptional32 = 0; // tabsallocated
+        *pS >> nOptional32;
+    }
+
+    if (pBlockFlags[2] & 0x20)
+    {
+        ReadAlign(pS, pS->Tell() - nStart, 4);
+        *pS >> nTagSize;
+    }
+
+    if (pBlockFlags[2] & 0x40)
+    {
+        ReadAlign(pS, pS->Tell() - nStart, 4);
+        *pS >> nNumTabs;
+    }
+
+    if (pBlockFlags[2] & 0x80)
+    {
+        ReadAlign(pS, pS->Tell() - nStart, 4);
+        *pS >> nAcceleratorSize;
+    }
+
+    if (pBlockFlags[3] & 0x01)
+    {
+        ReadAlign(pS, pS->Tell() - nStart, 2);
+        sal_Int16 nOptional16 = 0; //  Mouse Icon
+        *pS >> nOptional16;
+        hasEmbeddedImage = true;
+    }
+
+    // Extra block
+    if ( bSize )
+    {
+        ReadAlign(pS, pS->Tell() - nStart, 4);
+        *pS >> nWidth;
+        *pS >> nHeight;
+    }
+    if ( nItemSize )
+    {
+        ReadAlign(pS, pS->Tell() - nStart, 4);
+        // read the caption for each tab
+        readArrayString( pS, msItems, nItemSize, nStart );
+        std::vector< rtl::OUString >::iterator it = msItems.begin();
+        std::vector< rtl::OUString >::iterator it_end = msItems.end();
+        for ( sal_Int32 i=0; it != it_end; ++i, ++it )
+            OSL_TRACE(" Caption [ %d ] is %s", i, rtl::OUStringToOString( *it, RTL_TEXTENCODING_UTF8 ).getStr() );
+    }
+
+    if ( tipStringSize )
+    {
+        ReadAlign(pS, pS->Tell() - nStart, 4);
+        // read the tip for each tab
+        std::vector< rtl::OUString > sTips;
+        readArrayString( pS, sTips, tipStringSize, nStart );
+        std::vector< rtl::OUString >::iterator it = sTips.begin();
+        std::vector< rtl::OUString >::iterator it_end = sTips.end();
+        for ( sal_Int32 i=0; it != it_end; ++i, ++it )
+            OSL_TRACE(" Tip [ %d ] is %s", i, rtl::OUStringToOString( *it, RTL_TEXTENCODING_UTF8 ).getStr() );
+    }
+
+    if ( nameSize )
     {
-        OCX_Control::Read(pS); // read trailing records
+        ReadAlign(pS, pS->Tell() - nStart, 4);
+        // read the name for each tab
+        std::vector< rtl::OUString > sNames;
+        readArrayString( pS, sNames, nameSize, nStart );
+        std::vector< rtl::OUString >::iterator it = sNames.begin();
+        std::vector< rtl::OUString >::iterator it_end = sNames.end();
+        for ( sal_Int32 i=0; it != it_end; ++i, ++it )
+            OSL_TRACE(" Name [ %d ] is %s", i, rtl::OUStringToOString( *it, RTL_TEXTENCODING_UTF8 ).getStr() );
+    }
+
+    if ( nTagSize )
+    {
+        ReadAlign(pS, pS->Tell() - nStart, 4);
+        // read the name for each tab
+        std::vector< rtl::OUString > sTags;
+        readArrayString( pS, sTags, nTagSize, nStart );
+        std::vector< rtl::OUString >::iterator it = sTags.begin();
+        std::vector< rtl::OUString >::iterator it_end = sTags.end();
+        for ( sal_Int32 i=0; it != it_end; ++i, ++it )
+            OSL_TRACE(" Tag [ %d ] is %s", i, rtl::OUStringToOString( *it, RTL_TEXTENCODING_UTF8 ).getStr() );
+    }
+
+    if ( nAcceleratorSize )
+    {
+        ReadAlign(pS, pS->Tell() - nStart, 4);
+        // read the name for each tab
+        std::vector< rtl::OUString > sAccelerators;
+        readArrayString( pS, sAccelerators, nAcceleratorSize, nStart );
+        std::vector< rtl::OUString >::iterator it = sAccelerators.begin();
+        std::vector< rtl::OUString >::iterator it_end = sAccelerators.end();
+        for ( sal_Int32 i=0; it != it_end; ++i, ++it )
+            OSL_TRACE(" Accelerator [ %d ] is %s", i, rtl::OUStringToOString( *it, RTL_TEXTENCODING_UTF8 ).getStr() );
+    }
+
+    // Stream data
+    if ( hasEmbeddedImage )
+    {
+        ReadAlign(pS, pS->Tell() - nStart, 4);
+        sal_uInt8 pPictureHeader[20];
+        sal_uInt32 nPictureLen(0);
+        pS->Read(pPictureHeader,20);
+        *pS >> nPictureLen;
+        long imagePos = pS->Tell();

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list