ooo-build r12622 - in trunk: . patches/dev300



Author: jannieuw
Date: Wed May 21 14:38:10 2008
New Revision: 12622
URL: http://svn.gnome.org/viewvc/ooo-build?rev=12622&view=rev

Log:
2008-05-21  Jan Nieuwenhuizen  <janneke gnu org>

	* patches/dev300/layout-plugin-toolkit.diff: Regenerate.

	* patches/dev300/layout-tab-sfx2.diff:
	* patches/dev300/layout-tab-toolkit.diff: New file.  Share latest
	embedded layout tab efforts.  Not working yet, apart from
	UCB init disaster, manually apply to ooh-m12 to test.

	* patches/dev300/apply: Add them.


Added:
   trunk/patches/dev300/layout-tab-sfx2.diff
   trunk/patches/dev300/layout-tab-toolkit.diff
Modified:
   trunk/ChangeLog
   trunk/patches/dev300/apply
   trunk/patches/dev300/layout-plugin-toolkit.diff

Modified: trunk/patches/dev300/apply
==============================================================================
--- trunk/patches/dev300/apply	(original)
+++ trunk/patches/dev300/apply	Wed May 21 14:38:10 2008
@@ -1972,6 +1972,9 @@
 
 layout-plugin-toolkit.diff
 
+layout-tab-toolkit.diff
+layout-tab-sfx2.diff
+
 [ LocalizeLayout ]
 cws-layoutdialogs-toolkit-localize.diff
 

Modified: trunk/patches/dev300/layout-plugin-toolkit.diff
==============================================================================
--- trunk/patches/dev300/layout-plugin-toolkit.diff	(original)
+++ trunk/patches/dev300/layout-plugin-toolkit.diff	Wed May 21 14:38:10 2008
@@ -1,6 +1,6 @@
 diff --git a/inc/layout/layout-post.hxx b/inc/layout/layout-post.hxx
 index 3501e15..25e1cfc 100644
---- a/inc/layout/layout-post.hxx
+--- toolkit/inc/layout/layout-post.hxx
 +++ toolkit/inc/layout/layout-post.hxx
 @@ -39,33 +39,55 @@
  #if ENABLE_LAYOUT
@@ -62,7 +62,7 @@
  
 diff --git a/inc/layout/layout-pre.hxx b/inc/layout/layout-pre.hxx
 index 8d4983c..f1ff571 100644
---- a/inc/layout/layout-pre.hxx
+--- toolkit/inc/layout/layout-pre.hxx
 +++ toolkit/inc/layout/layout-pre.hxx
 @@ -49,63 +49,80 @@
  //typedef layout::FixedLine FixedLine;
@@ -168,7 +168,7 @@
  
 diff --git a/inc/layout/layout.hxx b/inc/layout/layout.hxx
 index e2d0403..ecbf73c 100644
---- a/inc/layout/layout.hxx
+--- toolkit/inc/layout/layout.hxx
 +++ toolkit/inc/layout/layout.hxx
 @@ -49,8 +49,9 @@
  
@@ -200,10 +200,10 @@
  
  #endif /* _LAYOUT_HXX */
 diff --git a/source/awt/makefile.mk b/source/awt/makefile.mk
-index 6b54bbb..f750218 100644
---- a/source/awt/makefile.mk
+index 3716956..a3798a5 100644
+--- toolkit/source/awt/makefile.mk
 +++ toolkit/source/awt/makefile.mk
-@@ -79,6 +79,7 @@ SLOFILES=   \
+@@ -75,6 +75,7 @@ SLOFILES=   \
  	$(SLO)/vclxbutton.obj\
  	$(SLO)/vclxdialog.obj\
  	$(SLO)/vclxfixedline.obj\
@@ -391,7 +391,7 @@
 +#endif /* LAYOUT_AWT_VCLXPLUGIN_HXX */
 diff --git a/source/layout/box.cxx b/source/layout/box.cxx
 index 50326f1..9b07939 100644
---- a/source/layout/box.cxx
+--- toolkit/source/layout/box.cxx
 +++ toolkit/source/layout/box.cxx
 @@ -47,17 +47,17 @@ namespace layoutimpl
  using namespace css;
@@ -421,7 +421,7 @@
      : Box_Base::ChildData( xChild )
 diff --git a/source/layout/dialogbuttonhbox.cxx b/source/layout/dialogbuttonhbox.cxx
 index 7d2a2bc..fff1bce 100644
---- a/source/layout/dialogbuttonhbox.cxx
+--- toolkit/source/layout/dialogbuttonhbox.cxx
 +++ toolkit/source/layout/dialogbuttonhbox.cxx
 @@ -43,7 +43,7 @@
  #include "proplist.hxx"
@@ -433,8 +433,8 @@
  #define DBG_ERROR printf
  #undef DBG_ERROR1
 diff --git a/source/layout/helper.cxx b/source/layout/helper.cxx
-index 5cfddf6..5aada5f 100644
---- a/source/layout/helper.cxx
+index 5cfddf6..76f4d2b 100644
+--- toolkit/source/layout/helper.cxx
 +++ toolkit/source/layout/helper.cxx
 @@ -46,7 +46,7 @@
  #include "layout/layoutcore.hxx"
@@ -486,7 +486,7 @@
      if ( WindowAttributes & awt::WindowAttribute::SHOW )
 diff --git a/source/layout/import.cxx b/source/layout/import.cxx
 index f177596..71e5a16 100644
---- a/source/layout/import.cxx
+--- toolkit/source/layout/import.cxx
 +++ toolkit/source/layout/import.cxx
 @@ -123,7 +123,7 @@ SAL_THROW (())
  
@@ -499,7 +499,7 @@
  #ifdef IMPORT_RADIOGROUP
 diff --git a/source/layout/import.hxx b/source/layout/import.hxx
 index 4974950..3026e15 100644
---- a/source/layout/import.hxx
+--- toolkit/source/layout/import.hxx
 +++ toolkit/source/layout/import.hxx
 @@ -38,6 +38,7 @@
  
@@ -511,7 +511,7 @@
  #include <com/sun/star/xml/input/XRoot.hpp>
 diff --git a/source/layout/proplist.cxx b/source/layout/proplist.cxx
 index 889dbac..3e85aee 100644
---- a/source/layout/proplist.cxx
+--- toolkit/source/layout/proplist.cxx
 +++ toolkit/source/layout/proplist.cxx
 @@ -46,7 +46,7 @@
  #include "layout/layoutcore.hxx"
@@ -524,7 +524,7 @@
  #undef DBG_ERROR1
 diff --git a/source/layout/root.cxx b/source/layout/root.cxx
 index 25c4463..3cec64e 100644
---- a/source/layout/root.cxx
+--- toolkit/source/layout/root.cxx
 +++ toolkit/source/layout/root.cxx
 @@ -35,8 +35,8 @@
  
@@ -550,7 +550,7 @@
          OUString c = OUString::createFromAscii( ":" );
 diff --git a/source/layout/root.hxx b/source/layout/root.hxx
 index e385256..61b0bee 100644
---- a/source/layout/root.hxx
+--- toolkit/source/layout/root.hxx
 +++ toolkit/source/layout/root.hxx
 @@ -36,6 +36,7 @@
  #ifndef CORE_ROOT_HXX
@@ -588,7 +588,7 @@
  
 diff --git a/source/layout/translate.cxx b/source/layout/translate.cxx
 index 7eac2ba..0f87022 100644
---- a/source/layout/translate.cxx
+--- toolkit/source/layout/translate.cxx
 +++ toolkit/source/layout/translate.cxx
 @@ -37,7 +37,7 @@
  
@@ -601,7 +601,7 @@
  #include <osl/process.h>
 diff --git a/source/vclcompat/wbutton.cxx b/source/vclcompat/wbutton.cxx
 index 5757ebc..17c2142 100644
---- a/source/vclcompat/wbutton.cxx
+--- toolkit/source/vclcompat/wbutton.cxx
 +++ toolkit/source/vclcompat/wbutton.cxx
 @@ -452,7 +452,7 @@ protected:
          parent->Invalidate( r, INVALIDATE_CHILDREN | INVALIDATE_NOCHILDREN );
@@ -613,8 +613,8 @@
  public:
      AdvancedButtonImpl( Context *pCtx, PeerHandle const& xPeer, Window *pWindow )
 diff --git a/source/vclcompat/wrapper.cxx b/source/vclcompat/wrapper.cxx
-index 20f961c..a078227 100644
---- a/source/vclcompat/wrapper.cxx
+index e88a2bb..6188ac1 100644
+--- toolkit/source/vclcompat/wrapper.cxx
 +++ toolkit/source/vclcompat/wrapper.cxx
 @@ -35,21 +35,22 @@
  
@@ -647,7 +647,7 @@
  
  using namespace ::com::sun::star;
  
-@@ -570,4 +571,36 @@ sal_Int32 ProgressBar::GetValue()
+@@ -571,4 +572,36 @@ sal_Int32 ProgressBar::GetValue()
      return getImpl().mxProgressBar->getValue();
  }
  
@@ -686,7 +686,7 @@
  } // namespace layout
 diff --git a/source/vclcompat/wrapper.hxx b/source/vclcompat/wrapper.hxx
 index b7569c7..f56bc0a 100644
---- a/source/vclcompat/wrapper.hxx
+--- toolkit/source/vclcompat/wrapper.hxx
 +++ toolkit/source/vclcompat/wrapper.hxx
 @@ -43,23 +43,23 @@
  
@@ -732,7 +732,7 @@
  inline WindowImpl &Window::getImpl() const
 diff --git a/workben/layout/editor.cxx b/workben/layout/editor.cxx
 index 1089288..a13030e 100644
---- a/workben/layout/editor.cxx
+--- toolkit/workben/layout/editor.cxx
 +++ toolkit/workben/layout/editor.cxx
 @@ -36,30 +36,28 @@
  #include "editor.hxx"
@@ -781,7 +781,7 @@
  
 diff --git a/workben/layout/makefile.mk b/workben/layout/makefile.mk
 index fc8fb2c..d7303af 100644
---- a/workben/layout/makefile.mk
+--- toolkit/workben/layout/makefile.mk
 +++ toolkit/workben/layout/makefile.mk
 @@ -59,6 +59,7 @@ CFLAGS+=-Wall -Wno-non-virtual-dtor
  
@@ -995,8 +995,8 @@
 +</modaldialog>
 +
 diff --git a/workben/layout/simple-paragraph.cxx b/workben/layout/simple-paragraph.cxx
-index 5a1de5d..206863d 100644
---- a/workben/layout/simple-paragraph.cxx
+index 0ac93c1..5551b61 100644
+--- toolkit/workben/layout/simple-paragraph.cxx
 +++ toolkit/workben/layout/simple-paragraph.cxx
 @@ -41,12 +41,12 @@
  
@@ -1015,7 +1015,7 @@
  #include <svx/paraprev.hxx>        // Preview
 diff --git a/workben/layout/test.cxx b/workben/layout/test.cxx
 index 5a059ee..4049e60 100644
---- a/workben/layout/test.cxx
+--- toolkit/workben/layout/test.cxx
 +++ toolkit/workben/layout/test.cxx
 @@ -60,6 +60,9 @@
  #include "zoom.hxx"
@@ -1050,7 +1050,7 @@
          SvxRecoverDialog recover ( 0 );
 diff --git a/workben/layout/uno.hxx b/workben/layout/uno.hxx
 index 6e1f837..63d170f 100644
---- a/workben/layout/uno.hxx
+--- toolkit/workben/layout/uno.hxx
 +++ toolkit/workben/layout/uno.hxx
 @@ -36,7 +36,7 @@
  #ifndef _LAYOUT_UNO_HXX
@@ -1062,10 +1062,10 @@
  #include <com/sun/star/lang/XInitialization.hpp>
  #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 diff --git a/workben/layout/zoom.cxx b/workben/layout/zoom.cxx
-index b3c8344..0ac57f2 100644
---- a/workben/layout/zoom.cxx
+index bbe4b2d..290a5ad 100644
+--- toolkit/workben/layout/zoom.cxx
 +++ toolkit/workben/layout/zoom.cxx
-@@ -66,9 +66,7 @@
+@@ -51,9 +51,7 @@
  #define _SVX_ZOOM_CXX
  
  #include <svx/dialogs.hrc>

Added: trunk/patches/dev300/layout-tab-sfx2.diff
==============================================================================
--- (empty file)
+++ trunk/patches/dev300/layout-tab-sfx2.diff	Wed May 21 14:38:10 2008
@@ -0,0 +1,142 @@
+diff --git a/inc/sfx2/macrconf.hxx b/inc/sfx2/macrconf.hxx
+index 94bbf4b..4155b05 100644
+--- sfx2/inc/sfx2/macrconf.hxx
++++ sfx2/inc/sfx2/macrconf.hxx
+@@ -141,7 +141,7 @@ public:
+ 	sal_uInt16					GetSlotId(SfxMacroInfoPtr);
+ 	void					ReleaseSlotId(sal_uInt16 nId);
+ 	void					RegisterSlotId(sal_uInt16 nId);
+-	const SfxMacroInfoPtr 	GetMacroInfo(sal_uInt16 nId) const;
++    SfxMacroInfoPtr GetMacroInfo(sal_uInt16 nId) const;
+ 	sal_Bool					ExecuteMacro(sal_uInt16 nId, const String& rArgs ) const;
+ 	sal_Bool					ExecuteMacro( SfxObjectShell*, const SvxMacro*, const String& ) const;
+ 	sal_Bool					CheckMacro(sal_uInt16 nId) const;
+@@ -149,7 +149,7 @@ public:
+ 
+ //#if 0 // _SOLAR__PRIVATE
+ 	SAL_DLLPRIVATE static void Release_Impl();
+-	SAL_DLLPRIVATE const SfxMacroInfoPtr GetMacroInfo_Impl( const SvxMacro *pMacro ) const;
++    SAL_DLLPRIVATE SfxMacroInfoPtr GetMacroInfo_Impl( const SvxMacro *pMacro ) const;
+ 	DECL_DLLPRIVATE_LINK( CallbackHdl_Impl, SfxMacroConfig*);
+ 	DECL_DLLPRIVATE_LINK( EventHdl_Impl, SfxMacroInfo*);
+ //#endif
+diff --git a/inc/sfx2/tabdlg.hxx b/inc/sfx2/tabdlg.hxx
+index d5b930e..4846f0b 100644
+--- sfx2/inc/sfx2/tabdlg.hxx
++++ sfx2/inc/sfx2/tabdlg.hxx
+@@ -43,6 +43,9 @@
+ #include <svtools/itemset.hxx>
+ #include <com/sun/star/frame/XFrame.hpp>
+ 
++#include <map>
++namespace layout { class TabPage; }
++
+ class SfxPoolItem;
+ class SfxTabDialog;
+ class SfxViewFrame;
+@@ -98,6 +101,7 @@ friend class SfxTabDialogController;
+ 	USHORT				nAppPageId;
+ 	BOOL				bItemsReset;
+ 	BOOL				bFmt;
++    std::map<int, layout::TabPage*> layoutPages;
+ 
+ //#if 0 // _SOLAR__PRIVATE
+ 	DECL_DLLPRIVATE_LINK( ActivatePageHdl, TabControl * );
+@@ -168,6 +172,7 @@ public:
+ 									BOOL bItemsOnDemand = FALSE,
+ 									USHORT nPos = TAB_APPEND);
+ 
++    void AddTabPage( int id, layout::TabPage* page );
+ 	void				RemoveTabPage( USHORT nId );
+ 
+ 	void				SetCurPageId( USHORT nId ) { nAppPageId = nId; }
+@@ -181,7 +186,7 @@ public:
+ 	const SfxItemSet*	GetOutputItemSet() const { return pOutSet; }
+ 	const SfxItemSet*	GetOutputItemSet( USHORT nId ) const;
+ 	int					FillOutputItemSet();
+-	const BOOL			IsFormat() const { return bFmt; }
++	BOOL IsFormat() const { return bFmt; }
+ 
+ 	const OKButton& 	GetOKButton() const { return aOKBtn; }
+ 	OKButton&			GetOKButton() { return aOKBtn; }
+diff --git a/source/control/macrconf.cxx b/source/control/macrconf.cxx
+index 0a2a595..1ab851b 100644
+--- sfx2/source/control/macrconf.cxx
++++ sfx2/source/control/macrconf.cxx
+@@ -662,7 +662,7 @@ void SfxMacroConfig::RegisterSlotId(sal_uInt16 nId)
+ 
+ //==========================================================================
+ 
+-const SfxMacroInfoPtr SfxMacroConfig::GetMacroInfo(sal_uInt16 nId) const
++SfxMacroInfoPtr SfxMacroConfig::GetMacroInfo(sal_uInt16 nId) const
+ {
+ 	sal_uInt16 nCount = pImp->aArr.Count();
+ 	for (sal_uInt16 i=0; i<nCount; i++)
+@@ -674,7 +674,7 @@ const SfxMacroInfoPtr SfxMacroConfig::GetMacroInfo(sal_uInt16 nId) const
+ 
+ //==========================================================================
+ 
+-const SfxMacroInfoPtr SfxMacroConfig::GetMacroInfo_Impl( const SvxMacro *pMacro ) const
++SfxMacroInfoPtr SfxMacroConfig::GetMacroInfo_Impl( const SvxMacro *pMacro ) const
+ {
+ 	sal_uInt16 nCount = pImp->aArr.Count();
+ 	for (sal_uInt16 i=0; i<nCount; i++)
+diff --git a/source/dialog/tabdlg.cxx b/source/dialog/tabdlg.cxx
+index 57a8e89..2133fda 100644
+--- sfx2/source/dialog/tabdlg.cxx
++++ sfx2/source/dialog/tabdlg.cxx
+@@ -56,6 +56,7 @@
+ #include <sfx2/bindings.hxx>
+ #include <sfx2/sfxdlg.hxx>
+ #include <sfx2/itemconnect.hxx>
++#include <layout/layout.hxx>
+ 
+ #include "dialog.hrc"
+ #include "helpid.hrc"
+@@ -922,6 +923,11 @@ void SfxTabDialog::AddTabPage
+ }
+ #endif
+ 
++void SfxTabDialog::AddTabPage( int id, layout::TabPage* page )
++{
++    layoutPages[id] = page;
++}
++
+ // -----------------------------------------------------------------------
+ 
+ void SfxTabDialog::RemoveTabPage( USHORT nId )
+@@ -1379,6 +1385,24 @@ IMPL_LINK( SfxTabDialog, ActivatePageHdl, TabControl *, pTabCtrl )
+ */
+ 
+ {
++    int newId = pTabCtrl->GetCurPageId();
++    if ( layout::TabPage* page = layoutPages[newId] )
++    {
++        TabPage *vclPage = page->GetTabPage();
++        TabControl *dialog = pTabCtrl;
++        dialog->SetTabPage( newId, vclPage );
++        //vclPage->ActivatePage();
++        page->ActivatePage();
++
++        Size tabSize = vclPage->GetSizePixel();
++        Size dialogSize = dialog->GetTabPageSizePixel();
++        if ( dialogSize.Width() < tabSize.Width()
++             || dialogSize.Height() < tabSize.Height() )
++            dialog->SetTabPageSizePixel( tabSize );
++
++        return 0;
++    }
++    
+ 	DBG_ASSERT( pImpl->pData->Count(), "keine Pages angemeldet" );
+ 	const USHORT nId = pTabCtrl->GetCurPageId();
+ 	SFX_APP();
+@@ -1455,6 +1479,9 @@ IMPL_LINK( SfxTabDialog, DeactivatePageHdl, TabControl *, pTabCtrl )
+ */
+ 
+ {
++    if ( layout::TabPage* p = layoutPages[pTabCtrl->GetCurPageId()] )
++        return SfxTabPage::LEAVE_PAGE;
++
+ 	USHORT nId = pTabCtrl->GetCurPageId();
+ 	SFX_APP();
+ 	SfxTabPage *pPage = (SfxTabPage*)pTabCtrl->GetTabPage( nId );

Added: trunk/patches/dev300/layout-tab-toolkit.diff
==============================================================================
--- (empty file)
+++ trunk/patches/dev300/layout-tab-toolkit.diff	Wed May 21 14:38:10 2008
@@ -0,0 +1,3874 @@
+diff --git a/doc/layout/README b/doc/layout/README
+index 1e3737f..a3bf2d2 100644
+--- toolkit/doc/layout/README
++++ toolkit/doc/layout/README
+@@ -2,19 +2,34 @@ Layout engine for OpenOffice.org  -  Work in Progress
+ 
+ Simple dialogs have been ported now: zoom and wordcount.
+ 
+-Code lives in "layout" CWS.
++New code lives in "layoutdialogs" CWS or ooo-build trunk.
+ 
+-* Ceckout layout cws.
++* Checkout layoutdialogs cws.
+ 
+ * Configure using --enable-layout.
+ 
+-* dmake all
++* [d]make all
+ 
+-* dmake install DESTDIR=$(pwd)/ooo-layout/
++* [d]make install DESTDIR=$(pwd)/ooo-layout/
+ 
+-* Source refresh in workben/layout, do something like
++* Compile test program in toolkit/workben/layout
+ 
+-    cd toolkit/workben/layout && . ./refresh --inst .../ooo-layout/
++  cd toolkit/workben/layout && dmake all
++
++| Currently broken on dev300 installation: m3 < dev300 <= m10.
++|
++| * Run it on any .xml file
++|
++|   ../../$INPATH/bin/test --inst .../ooo-layout/ zoom.xml
++|
++| * Run it for specific dialogs, see test.cxx
++|
++|   ../../$INPATH/bin/test --inst .../ooo-layout/ --test zoom
++|   ../../$INPATH/bin/test --inst .../ooo-layout/ --test wordcount
++|
++| * Or source refresh in workben/layout, do something like
++|
++|     cd toolkit/workben/layout && . ./refresh --inst .../ooo-layout/
+ 
+ Integration into OOo:
+ 
+diff --git a/inc/layout/layout-post.hxx b/inc/layout/layout-post.hxx
+index 25e1cfc..09f90bf 100644
+--- toolkit/inc/layout/layout-post.hxx
++++ toolkit/inc/layout/layout-post.hxx
+@@ -73,12 +73,16 @@
+ #undef RetryButton
+ #undef SpinField
+ #undef Table
++#undef TabPage
+ #undef VBox
+ #undef YesButton
+ 
+ #undef ModalDialog
+ #undef ModelessDialog
+ #undef SfxModalDialog
++#undef SfxTabPage
++
++#undef SvxLanguageBox
+ 
+ #undef Window
+ 
+diff --git a/inc/layout/layout-pre.hxx b/inc/layout/layout-pre.hxx
+index f1ff571..327da0b 100644
+--- toolkit/inc/layout/layout-pre.hxx
++++ toolkit/inc/layout/layout-pre.hxx
+@@ -83,12 +83,16 @@
+ #define RetryButton layout::RetryButton
+ #define SpinField layout::SpinField
+ #define Table layout::Table
++#define TabPage layout::TabPage
+ #define VBox layout::VBox
+ #define YesButton layout::YesButton
+ 
+ #define ModalDialog Dialog
+ #define ModelessDialog Dialog
+ #define SfxModalDialog Dialog
++#define SfxTabPage TabPage
++
++#define SvxLanguageBox ListBox
+ 
+ #define Window ::Window
+ 
+diff --git a/inc/layout/layout.hxx b/inc/layout/layout.hxx
+index ecbf73c..cf6390d 100644
+--- toolkit/inc/layout/layout.hxx
++++ toolkit/inc/layout/layout.hxx
+@@ -39,6 +39,8 @@
+ #include <com/sun/star/uno/XInterface.hpp>
+ #include <com/sun/star/awt/XLayoutContainer.hpp>
+ #include <com/sun/star/util/Color.hpp>
++#include <i18npool/lang.h>
++#include <tools/gen.hxx>
+ #include <tools/link.hxx>
+ #include <tools/string.hxx>
+ 
+@@ -51,7 +53,13 @@
+ 
+ class Control;
+ class Image;
++class SfxPoolItem;
++class SfxItemSet;
++class VCLXWindow;
+ class Window;
++class TabPage;
++
++namespace com { namespace sun { namespace star { namespace awt { class XWindow; } } } }
+ 
+ namespace layout
+ {
+@@ -94,12 +102,13 @@ protected:
+     static PeerHandle CreatePeer( Window *pParent, WinBits nStyle,
+                                   char const* pName);
+ public:
+-    PeerHandle GetPeer();
+-    Context *getContext();
+     DECL_GET_IMPL( Window );
+     explicit Window( WindowImpl *pImpl );
+     virtual ~Window();
+ 
++    PeerHandle GetPeer();
++    Context *getContext();
++
+     void Enable( bool bEnable = true );
+     inline void Disable() { Enable( false ); }
+     void Show( BOOL bVisible = TRUE );
+@@ -107,8 +116,17 @@ public:
+     void GrabFocus();
+     void FreeResource() {}
+ 
++    void SetParent( Window *pParent );
++    void SetParent( ::Window *pParent );
++
++    css::uno::Reference<css::awt::XWindow> GetRef();
++    VCLXWindow* GetVCLXWindow();
++    ::Window* GetWindow();
++    ::Window* GetParent();
++
+     WinBits GetStyle();
+     void SetStyle( WinBits nStyle );
++    void SetUpdateMode( bool /*bUpdate*/ ) { }
+ };
+ 
+ class ControlImpl;
+@@ -289,6 +307,7 @@ public:
+     void SetText( XubString const& rStr ) const;
+     XubString GetText() const;
+     void SetModifyHdl( Link const& rLink );
++    void SetSelection( Selection const& rSelection );
+ };
+ 
+ class MultiLineEditImpl;
+@@ -416,14 +435,25 @@ public:
+ 
+     void SetSelectHdl( Link const& rLink );
+     void SetClickHdl( Link const& rLink );
++
++    void SetEntryData( USHORT/*nPos*/, void*/*pNewData*/) { }
++    void* GetEntryData( USHORT/*nPos*/) const { return 0; } 
++
++    // SvxLanguageBox
++    void SetLanguageList( INT16/*nLangList*/, bool/*bHasLangNone*/, bool /*bLangNoneIsLangAll*/= false, bool /*bCheckSpellAvail*/= false ) { }
++
++    USHORT InsertLanguage( const LanguageType/*eLangType*/, USHORT/*nPos*/= LISTBOX_APPEND ) { return 0; }
++    USHORT InsertLanguage( const LanguageType/*eLangType*/, bool/*bCheckEntry*/, USHORT /*nPos*/= LISTBOX_APPEND ) { return 0; }
++    void RemoveLanguage( const LanguageType/*eLangType*/) { }
++    void SelectLanguage( const LanguageType/*eLangType*/, bool/*bSelect*/= true) { }
++    LanguageType GetSelectLanguage() const { return 0; }
++    bool IsLanguageSelected( const LanguageType/*eLangType*/) const { return true; }
+ };
+ 
+ class DialogImpl;
+ class TOOLKIT_DLLPUBLIC Dialog : public Context, public Window
+ {
+     DECL_GET_IMPL( Dialog );
+-    void SetParent( Window *pParent );
+-    void SetParent( ::Window *pParent );
+ public:
+     Dialog( Window *pOptParent, char const* pXMLPath, char const* pId, sal_uInt32 nId = 0 );
+     Dialog( ::Window *pOptParent, char const* pXMLPath, char const* pId, sal_uInt32 nId = 0 );
+@@ -432,6 +462,40 @@ public:
+     void SetText( String const& rStr );
+ };
+ 
++#define DECL_GET_WINDOW( cls ) ::cls* Get##cls()
++#define IMPL_GET_WINDOW( cls ) ::cls* cls::Get##cls() { return reinterpret_cast< ::cls*>( GetWindow() ); }
++class TabPageImpl;
++class TOOLKIT_DLLPUBLIC TabPage : public Context, public Window
++{
++    DECL_GET_IMPL( TabPage );
++public:
++    static ::Window* global_parent;
++    
++    TabPage( Window *pOptParent, char const* pXMLPath, char const* pId, sal_uInt32 nId = 0 );
++    TabPage( ::Window *pOptParent, char const* pXMLPath, char const* pId, sal_uInt32 nId = 0 );
++    //DECL_GET_WINDOW( TabPage );
++    ::TabPage* GetTabPage();
++    virtual void ActivatePage();
++    virtual void DeactivatePage();
++#if 0
++};
++
++//FIXME: move to sfx2 or svtools layout.hxx
++class TOOLKIT_DLLPUBLIC SfxTabPage : public TabPage
++{
++public:
++    SfxTabPage( Window *pOptParent, char const* pXMLPath, char const* pId, sal_uInt32 nId = 0 );
++    SfxTabPage( ::Window *pOptParent, char const* pXMLPath, char const* pId, sal_uInt32 nId = 0 );
++#endif
++    // SfxTabPage...
++	enum PageAction { KEEP_PAGE, LEAVE_PAGE, REFRESH_SET };
++
++    bool bHasExchangeSupport;
++    bool HasExchangeSupport() { return bHasExchangeSupport; }
++    void SetExchangeSupport( bool exchangeSupport = true ) { bHasExchangeSupport = exchangeSupport; }
++    //static const SfxPoolItem* GetItem( const SfxItemSet& rSet, USHORT nSlot );
++};
++
+ class ProgressBarImpl;
+ class TOOLKIT_DLLPUBLIC ProgressBar : public Control
+ {
+diff --git a/source/awt/makefile.mk b/source/awt/makefile.mk
+index a3798a5..8a851c5 100644
+--- toolkit/source/awt/makefile.mk
++++ toolkit/source/awt/makefile.mk
+@@ -78,7 +78,8 @@ SLOFILES=   \
+ 	$(SLO)/vclxplugin.obj\
+ 	$(SLO)/vclxscroller.obj\
+ 	$(SLO)/vclxsplitter.obj\
+-	$(SLO)/vclxtabcontrol.obj
++	$(SLO)/vclxtabcontrol.obj\
++	$(SLO)/vclxtabpage.obj
+ 
+ SRS1NAME=$(TARGET)
+ SRC1FILES=\
+diff --git a/source/awt/vclxbutton.cxx b/source/awt/vclxbutton.cxx
+index f49b6f0..48f6203 100644
+--- toolkit/source/awt/vclxbutton.cxx
++++ toolkit/source/awt/vclxbutton.cxx
+@@ -35,7 +35,7 @@
+ 
+ #include "vclxbutton.hxx"
+ 
+-#include "layout/layoutcore.hxx"
++#include <layout/layoutcore.hxx>
+ #include <com/sun/star/awt/ImagePosition.hpp>
+ #include <vcl/button.hxx>
+ 
+diff --git a/source/awt/vclxdialog.hxx b/source/awt/vclxdialog.hxx
+index 8c01a48..c270e63 100644
+--- toolkit/source/awt/vclxdialog.hxx
++++ toolkit/source/awt/vclxdialog.hxx
+@@ -65,7 +65,7 @@ protected:
+     Window* GetWindowImpl();
+     TopWindowListenerMultiplexer& GetTopWindowListenersImpl();
+ 
+-    ~VCLXDialog( );
++    ~VCLXDialog();
+ 
+     // XInterface
+     DECLARE_XINTERFACE()
+diff --git a/source/awt/vclxplugin.cxx b/source/awt/vclxplugin.cxx
+index 4c3091a..f17552a 100644
+--- toolkit/source/awt/vclxplugin.cxx
++++ toolkit/source/awt/vclxplugin.cxx
+@@ -36,10 +36,8 @@
+ #include "vclxplugin.hxx"
+ 
+ #include <com/sun/star/awt/PosSize.hpp>
++#include <toolkit/helper/convert.hxx>
+ #include <toolkit/helper/property.hxx>
+-
+-#include "forward.hxx"
+-
+ #include <vcl/ctrl.hxx>
+ 
+ namespace layoutimpl
+@@ -81,10 +79,7 @@ awt::Size SAL_CALL VCLXPlugin::getMinimumSize()
+ {
+     ::vos::OClearableGuard aGuard( GetMutex() );
+     if ( mpPlugin )
+-    {
+-        Size s = mpPlugin->GetSizePixel();
+-        return awt::Size( s.Width(), s.Height() );
+-    }
++        return AWTSize( mpPlugin->GetSizePixel() );
+     return awt::Size();
+ }
+ 
+diff --git a/source/awt/vclxtabpage.cxx b/source/awt/vclxtabpage.cxx
+new file mode 100644
+index 0000000..0cae64c
+--- /dev/null
++++ toolkit/source/awt/vclxtabpage.cxx
+@@ -0,0 +1,94 @@
++/*************************************************************************
++ *
++ *  OpenOffice.org - a multi-platform office productivity suite
++ *
++ *  $RCSfile$
++ *
++ *  $Revision$
++ *
++ *  last change: $Author$ $Date$
++ *
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
++ *
++ *
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library 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 for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 51 Franklin Street, 5th Floor, Boston,
++ *    MA  02110-1301  USA
++ *
++ ************************************************************************/
++
++#include "vclxtabpage.hxx"
++#include "forward.hxx"
++
++#include <toolkit/helper/convert.hxx>
++#include <vcl/tabpage.hxx>
++
++namespace layoutimpl
++{
++
++using namespace ::com::sun::star;
++
++// XInterface
++IMPLEMENT_FORWARD_XINTERFACE2( VCLXTabPage, VCLXWindow, Bin );
++
++// XTypeProvider
++IMPLEMENT_FORWARD_XTYPEPROVIDER1( VCLXTabPage, VCLXWindow );
++
++VCLXTabPage::VCLXTabPage( Window *p )
++    : VCLXWindow()
++    , Bin()
++{
++    /* FIXME: before Window is set, setLabel, setProperty->setImage
++     * are silent no-ops.  */
++    p->SetComponentInterface( this );
++}
++
++VCLXTabPage::~VCLXTabPage()
++{
++}
++
++void SAL_CALL VCLXTabPage::dispose() throw(uno::RuntimeException)
++{
++    {
++        ::vos::OGuard aGuard( GetMutex() );
++        
++        lang::EventObject aDisposeEvent;
++        aDisposeEvent.Source = *this;
++    }
++    
++    VCLXWindow::dispose();
++}
++
++void SAL_CALL VCLXTabPage::allocateArea( awt::Rectangle const& rArea )
++    throw (uno::RuntimeException)
++{
++    ::vos::OGuard aGuard( GetMutex() );
++
++    return Bin::allocateArea( rArea );
++}
++
++awt::Size SAL_CALL VCLXTabPage::getMinimumSize()
++    throw(uno::RuntimeException)
++{
++    ::vos::OGuard aGuard( GetMutex() );
++
++    return Bin::getMinimumSize();
++}
++
++} // namespace layoutimpl
+diff --git a/source/awt/vclxtabpage.hxx b/source/awt/vclxtabpage.hxx
+new file mode 100644
+index 0000000..7960b57
+--- /dev/null
++++ toolkit/source/awt/vclxtabpage.hxx
+@@ -0,0 +1,79 @@
++/*************************************************************************
++ *
++ *  OpenOffice.org - a multi-platform office productivity suite
++ *
++ *  $RCSfile$
++ *
++ *  $Revision$
++ *
++ *  last change: $Author$ $Date$
++ *
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
++ *
++ *
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library 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 for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 51 Franklin Street, 5th Floor, Boston,
++ *    MA  02110-1301  USA
++ *
++ ************************************************************************/
++
++#ifndef LAYOUT_AWT_VCLXTABPAGE_HXX
++#define LAYOUT_AWT_VCLXTABPAGE_HXX
++
++#include <toolkit/awt/vclxwindow.hxx>
++#include <layout/bin.hxx>
++#include <comphelper/uno3.hxx>
++
++namespace layoutimpl
++{
++
++namespace css = ::com::sun::star;
++
++class VCLXTabPage : public VCLXWindow
++                  , public Bin
++{
++public:
++    VCLXTabPage( Window *p );
++
++    // XInterface
++    DECLARE_XINTERFACE()
++    
++    // XTypeProvider
++    DECLARE_XTYPEPROVIDER()
++
++protected:
++    ~VCLXTabPage();
++
++    // XComponent
++    void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException);
++
++    // ::com::sun::star::awt::XLayoutContainer
++    virtual void SAL_CALL allocateArea( ::com::sun::star::awt::Rectangle const& rArea )
++        throw (::com::sun::star::uno::RuntimeException);
++    virtual ::com::sun::star::awt::Size SAL_CALL getMinimumSize()
++        throw(::com::sun::star::uno::RuntimeException);
++
++private:
++    VCLXTabPage( VCLXTabPage const & );
++    VCLXTabPage& operator=( VCLXTabPage const & );
++};
++
++} // namespace layoutimpl
++
++#endif /* LAYOUT_AWT_VCLXTABPAGE_HXX */
+diff --git a/source/awt/vclxwindow.cxx b/source/awt/vclxwindow.cxx
+index 44cb49f..47d2af3 100644
+--- toolkit/source/awt/vclxwindow.cxx
++++ toolkit/source/awt/vclxwindow.cxx
+@@ -2107,6 +2107,10 @@ void VCLXWindow::setProperty( const ::rtl::OUString& PropertyName, const ::com::
+ 				aProp <<= (sal_Bool) GetWindow()->IsVisible();
+ 			    break;
+ 
++			case BASEPROPERTY_VISIBLE:
++				aProp <<= (sal_Bool) GetWindow()->IsVisible();
++			    break;
++
+ 			case BASEPROPERTY_TEXT:
+ 			case BASEPROPERTY_LABEL:
+ 			case BASEPROPERTY_TITLE:
+diff --git a/source/layout/container.cxx b/source/layout/container.cxx
+index 22e3b08..b34bfe5 100644
+--- toolkit/source/layout/container.cxx
++++ toolkit/source/layout/container.cxx
+@@ -140,7 +140,7 @@ Container::getLabel()  // debug label
+ 
+             uno::Sequence< uno::Reference< awt::XLayoutConstrains > > aChildren;
+             aChildren = xParent->getChildren();
+-            for( node = 0; node < aChildren.getLength(); node++ )
++            for ( node = 0; node < aChildren.getLength(); node++ )
+                 if ( aChildren[ node ] == xContainer )
+                     break;
+         }
+diff --git a/source/layout/factory.cxx b/source/layout/factory.cxx
+index b83b706..a072b12 100644
+--- toolkit/source/layout/factory.cxx
++++ toolkit/source/layout/factory.cxx
+@@ -79,7 +79,7 @@ sal_Bool SAL_CALL comp_Layout_component_writeInfo( void * /*serviceManager*/, vo
+                                            ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "/UNO/SERVICES") )  );
+ 
+                 const uno::Sequence< ::rtl::OUString > aServices = LayoutFactory::impl_staticGetSupportedServiceNames();
+-                for( sal_Int32 i = 0; i < aServices.getLength(); i++ )
++                for ( sal_Int32 i = 0; i < aServices.getLength(); i++ )
+                     xNewKey->createKey( aServices.getConstArray()[i] );
+ 
+                 return sal_True;
+@@ -129,10 +129,10 @@ sal_Bool SAL_CALL LayoutFactory::supportsService( const ::rtl::OUString& Service
+     throw ( uno::RuntimeException )
+ {
+     uno::Sequence< ::rtl::OUString > aSeq = impl_staticGetSupportedServiceNames();
+-    for( sal_Int32 i = 0; i < aSeq.getLength(); i++ )
++    for ( sal_Int32 i = 0; i < aSeq.getLength(); i++ )
+         if ( ServiceName.compareTo( aSeq[i] ) == 0 )
+             return sal_True;
+-
++    
+     return sal_False;
+ }
+ 
+diff --git a/source/layout/flow.cxx b/source/layout/flow.cxx
+index a99ba70..13d90fe 100644
+--- toolkit/source/layout/flow.cxx
++++ toolkit/source/layout/flow.cxx
+@@ -79,8 +79,8 @@ void SAL_CALL
+ Flow::removeChild( const css::uno::Reference< css::awt::XLayoutConstrains >& xChild )
+     throw (css::uno::RuntimeException)
+ {
+-    for( std::list< ChildData * >::iterator it = maChildren.begin();
+-         it != maChildren.end(); it++ )
++    for ( std::list< ChildData * >::iterator it = maChildren.begin();
++          it != maChildren.end(); it++ )
+     {
+         if ( (*it)->xChild == xChild )
+         {
+@@ -100,8 +100,8 @@ Flow::getChildren()
+ {
+     uno::Sequence< uno::Reference< awt::XLayoutConstrains > > children( maChildren.size() );
+     unsigned int i = 0;
+-    for( std::list< ChildData * >::iterator it = maChildren.begin();
+-         it != maChildren.end(); it++, i++ )
++    for ( std::list< ChildData * >::iterator it = maChildren.begin();
++          it != maChildren.end(); it++, i++ )
+         children[i] = (*it)->xChild;
+ 
+     return children;
+diff --git a/source/layout/helper.cxx b/source/layout/helper.cxx
+index 76f4d2b..37aa5d2 100644
+--- toolkit/source/layout/helper.cxx
++++ toolkit/source/layout/helper.cxx
+@@ -254,7 +254,7 @@ PropHelper::getInfoHelper()
+     if ( ! pHelper )
+     {
+         uno::Sequence< beans::Property > aProps( maDetails.size() );
+-        for( unsigned int i = 0; i < maDetails.size(); i++)
++        for ( unsigned int i = 0; i < maDetails.size(); i++)
+         {
+             aProps[i].Name = maDetails[i].aName;
+             aProps[i].Type = maDetails[i].aType;
+@@ -349,10 +349,11 @@ PropHelper::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::
+ #include <awt/vclxbutton.hxx>
+ #include <awt/vclxdialog.hxx>
+ #include <awt/vclxfixedline.hxx>
++#include <awt/vclxplugin.hxx>
+ #include <awt/vclxscroller.hxx>
+ #include <awt/vclxsplitter.hxx>
+ #include <awt/vclxtabcontrol.hxx>
+-#include <awt/vclxplugin.hxx>
++#include <awt/vclxtabpage.hxx>
+ #include <toolkit/awt/vclxtoolkit.hxx>
+ #include <toolkit/awt/vclxwindow.hxx>
+ #include <vcl/button.hxx>
+@@ -366,6 +367,8 @@ PropHelper::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::
+ namespace layoutimpl
+ {
+ 
++TOOLKIT_DLLPUBLIC Window* global_parent;
++
+ uno::Reference< awt::XLayoutConstrains > ImplCreateWindow(
+     uno::Reference< uno::XInterface > xParent,
+     OUString aName, long WindowAttributes )
+@@ -488,6 +491,13 @@ uno::Reference< awt::XLayoutConstrains > ImplCreateWindow(
+         OSL_TRACE( "%s: parent=%p (%s)\n", __FUNCTION__, pParent, typeid( *pParent ).name() );
+         pNewComp = new layoutimpl::VCLXPlugin( pNewWindow, ImplGetWinBits( WindowAttributes, 0 ) );
+     }
++    else if ( aName.equalsAscii( "tabpage" ) )
++    {
++        if ( !pParent )
++            pParent = layout::TabPage::global_parent;
++        pNewWindow = new TabPage( pParent, ImplGetWinBits( WindowAttributes, 0 ) );
++        pNewComp = new VCLXTabPage( pNewWindow );
++    }
+ 
+     if ( !pNewWindow )
+         return xRef;
+diff --git a/source/layout/import.cxx b/source/layout/import.cxx
+index 71e5a16..87b3a32 100644
+--- toolkit/source/layout/import.cxx
++++ toolkit/source/layout/import.cxx
+@@ -243,7 +243,7 @@ uno::Reference< xml::input::XElement > ImportContext::startRootElement(
+     uno::Reference< xml::input::XAttributes > const & xAttributes )
+     throw (xml::sax::SAXException, uno::RuntimeException)
+ {
+-    if (XMLNS_LAYOUT_UID != nUid)
++    if ( XMLNS_LAYOUT_UID != nUid )
+         throw xml::sax::SAXException(
+             OUString( RTL_CONSTASCII_USTRINGPARAM( "invalid namespace!" ) ),
+             uno::Reference< uno::XInterface >(), uno::Any() );
+diff --git a/source/layout/proplist.cxx b/source/layout/proplist.cxx
+index 3e85aee..d1da2a4 100644
+--- toolkit/source/layout/proplist.cxx
++++ toolkit/source/layout/proplist.cxx
+@@ -200,8 +200,8 @@ uno::Any anyFromString( OUString const& value, uno::Type const& type )
+ 
+             uno::Sequence< OUString > seq( values.size() );
+             i = 0;
+-            for( std::list< OUString >::const_iterator it = values.begin();
+-                 it != values.end(); it++, i++ )
++            for ( std::list< OUString >::const_iterator it = values.begin();
++                  it != values.end(); it++, i++ )
+                 seq[ i ] = *it;
+ 
+             return uno::makeAny( seq );
+@@ -255,18 +255,17 @@ setProperties( uno::Reference< uno::XInterface > const& xPeer,
+     if ( !prophlp::canHandleProps( xPeer ) )
+     {
+         DBG_ERROR( "Error: setProperties - bad handle ignoring props:\n" );
+-        PropList::const_iterator cur;
+-        for( cur = rProps.begin(); cur != rProps.end(); cur++ )
+-        {
+-            OString attr = OUStringToOString( cur->first, RTL_TEXTENCODING_UTF8 );
+-            OString value = OUStringToOString( cur->second, RTL_TEXTENCODING_UTF8 );
+-        }
++         for ( PropList::const_iterator it = rProps.begin(); it != rProps.end();
++              it++ )
++         {
++             OSL_TRACE( "%s=%s\n", OUSTRING_CSTR( it->first ), OUSTRING_CSTR( it->second ) );
++         }
+         return;
+     }
+ 
+-    PropList::const_iterator cur;
+-    for( cur = rProps.begin(); cur != rProps.end(); cur++ )
+-        setProperty( xPeer, cur->first, cur->second );
++    for ( PropList::const_iterator it = rProps.begin(); it != rProps.end();
++          it++ )
++        setProperty( xPeer, it->first, it->second );
+ }
+ 
+ void
+@@ -354,7 +353,7 @@ static const AttributesMap attribsMap[] =
+     { "spin",         awt::VclWindowPeerAttribute::SPIN,         false },
+     { "vscroll",      awt::VclWindowPeerAttribute::VSCROLL,      false },
+ 
+-    // cutting on OK, YES_NO_CANCEL and related obscure attributes...
++    // cutting on OK, YES_NO_CANCEL and related obsite attributes...
+ };
+ static const int attribsMapLen = sizeof( attribsMap ) / sizeof( AttributesMap );
+ 
+@@ -386,10 +385,8 @@ long getAttribute( const OUString &rName, bool bTopWindow )
+ void propsFromAttributes( const uno::Reference<xml::input::XAttributes> & xAttributes,
+                           PropList &rProps, sal_Int32 nNamespace )
+ {
+-
+-
+     sal_Int32 nAttrs = xAttributes->getLength();
+-    for( sal_Int32 i = 0; i < nAttrs; i++ )
++    for ( sal_Int32 i = 0; i < nAttrs; i++ )
+     {
+         if ( nNamespace != xAttributes->getUidByIndex( i ) )
+             continue;
+@@ -406,15 +403,15 @@ void propsFromAttributes( const uno::Reference<xml::input::XAttributes> & xAttri
+ bool
+ findAndRemove( const char *pAttr, PropList &rProps, OUString &rValue )
+ {
+-    PropList::iterator cur;
++    PropList::iterator it;
+     OUString aName = OUString::createFromAscii( pAttr );
+ 
+-    for( cur = rProps.begin(); cur != rProps.end(); cur++ )
++    for ( it = rProps.begin(); it != rProps.end(); it++ )
+     {
+-        if ( cur->first.equalsIgnoreAsciiCase( aName ) )
++        if ( it->first.equalsIgnoreAsciiCase( aName ) )
+         {
+-            rValue = cur->second;
+-            rProps.erase( cur );
++            rValue = it->second;
++            rProps.erase( it );
+             return true;
+         }
+     }
+@@ -437,7 +434,7 @@ getAttributeProps( PropList &rProps )
+     else
+         nAttrs |= awt::WindowAttribute::SHOW;
+ 
+-    for( int i = 0; i < attribsMapLen; i++ )
++    for ( int i = 0; i < attribsMapLen; i++ )
+     {
+         if ( findAndRemove( attribsMap[i].name, rProps, aValue ) )
+         {
+diff --git a/source/layout/root.cxx b/source/layout/root.cxx
+index 3cec64e..906ceae 100644
+--- toolkit/source/layout/root.cxx
++++ toolkit/source/layout/root.cxx
+@@ -105,11 +105,12 @@ void ShowMessageBox( uno::Reference< lang::XMultiServiceFactory > const& xFactor
+         xMessageBox->execute();
+     //FIXME: exceptions not caught and printed at top level??
+     //else
+-    printf( "%s\n", OUSTRING_CSTR( aMessage ) );
++    //printf( "%s\n", OUSTRING_CSTR( aMessage ) );
+ }
+ 
+ void LayoutRoot::error( OUString const& message )
+ {
++    printf( "%s\n", OUSTRING_CSTR( message ) );
+     ShowMessageBox( mxFactory, mxToolkit,
+                     OUString::createFromAscii( "Fatal error" ),
+                     message );
+@@ -252,9 +253,9 @@ uno::Sequence< OUString > SAL_CALL LayoutRoot::getElementNames()
+     uno::Sequence< OUString > aNames( maItems.size() );
+     sal_Int32 nPos = 0;
+ 
+-    for( ItemHash::const_iterator i = maItems.begin();
+-         i != maItems.end(); i++ )
+-        aNames[ nPos++ ] = i->first;
++    for ( ItemHash::const_iterator it = maItems.begin();
++          it != maItems.end(); it++ )
++        aNames[ nPos++ ] = it->first;
+ 
+     return aNames;
+ }
+@@ -338,21 +339,21 @@ LayoutWidget *LayoutRoot::create( OUString id, const OUString unoName, long attr
+ }
+ 
+ #if 0
+-  uno::Reference< awt::XLayoutConstrains > LayoutRoot::getToplevel()
+-  {
+-  if ( mpToplevel )
+-  return mpToplevel->getPeer();
+-  return uno::Reference< awt::XLayoutConstrains > ();
+-  }
+-
+-  uno::Reference< awt::XLayoutConstrains > LayoutRoot::getById( OUString id )
+-  {
+-  uno::Reference< awt::XLayoutConstrains > rRef = 0;
+-  ItemHash::iterator i = maItems.find( id );
+-  if ( i != maItems.end() )
+-  rRef = i->second;
+-  return rRef;
+-  }
++uno::Reference< awt::XLayoutConstrains > LayoutRoot::getToplevel()
++{
++    if ( mpToplevel )
++        return mpToplevel->getPeer();
++    return uno::Reference< awt::XLayoutConstrains > ();
++}
++
++uno::Reference< awt::XLayoutConstrains > LayoutRoot::getById( OUString id )
++{
++    uno::Reference< awt::XLayoutConstrains > rRef = 0;
++    ItemHash::iterator it = maItems.find( id );
++    if ( it != maItems.end() )
++        rRef = it->second;
++    return rRef;
++}
+ #endif
+ 
+ LayoutWidget::LayoutWidget( uno::Reference< awt::XToolkit > xToolkit,
+diff --git a/source/layout/table.cxx b/source/layout/table.cxx
+index 658ef95..6df27c2 100644
+--- toolkit/source/layout/table.cxx
++++ toolkit/source/layout/table.cxx
+@@ -162,7 +162,7 @@ Table::getMinimumSize() throw( uno::RuntimeException )
+             unsigned int end =( child->mnRightCol-1 ) +( ( child->mnBottomRow-1 )*mnColsLen );
+             if ( aTable.size() < end+1 )
+                 aTable.resize( end+1, NULL );
+-            for( unsigned int i = start; i < end; i++ )
++            for ( unsigned int i = start; i < end; i++ )
+                 aTable[ i ] = child;
+ 
+             nRowsLen = SAL_MAX( nRowsLen, child->mnBottomRow );
+@@ -170,7 +170,7 @@ Table::getMinimumSize() throw( uno::RuntimeException )
+     }
+ 
+     // 2. calculate columns/rows sizes
+-    for( int g = 0; g < 2; g++ )
++    for ( int g = 0; g < 2; g++ )
+     {
+         std::vector< GroupData > &aGroup = g == 0 ? maCols : maRows;
+ 
+@@ -215,7 +215,7 @@ Table::getMinimumSize() throw( uno::RuntimeException )
+                 child->maRequisition = child->mxChild->getMinimumSize();
+                 int size = 0;
+                 int expandables = 0;
+-                for( int i = nFirstAttach; i < nLastAttach; i++ )
++                for ( int i = nFirstAttach; i < nLastAttach; i++ )
+                 {
+                     size += aGroup[ i ].mnSize;
+                     if ( aGroup[ i ].mbExpand )
+@@ -232,7 +232,7 @@ Table::getMinimumSize() throw( uno::RuntimeException )
+                     else
+                         extra /= nLastAttach - nFirstAttach;
+ 
+-                    for( int i = nFirstAttach; i < nLastAttach; i++ )
++                    for ( int i = nFirstAttach; i < nLastAttach; i++ )
+                         if ( expandables == 0 || aGroup[ i ].mbExpand )
+                             aGroup[ i ].mnSize += extra;
+                 }
+@@ -243,14 +243,14 @@ Table::getMinimumSize() throw( uno::RuntimeException )
+     // 3. Sum everything up
+     mnColExpandables =( mnRowExpandables = 0 );
+     maRequisition.Width =( maRequisition.Height = 0 );
+-    for( std::vector<GroupData>::iterator it = maCols.begin();
++    for ( std::vector<GroupData>::iterator it = maCols.begin();
+          it != maCols.end(); it++ )
+     {
+         maRequisition.Width += it->mnSize;
+         if ( it->mbExpand )
+             mnColExpandables++;
+     }
+-    for( std::vector<GroupData>::iterator it = maRows.begin();
++    for ( std::vector<GroupData>::iterator it = maRows.begin();
+          it != maRows.end(); it++ )
+     {
+         maRequisition.Height += it->mnSize;
+@@ -284,13 +284,13 @@ Table::allocateArea( const awt::Rectangle &rArea )
+ 
+         awt::Rectangle rChildArea( rArea.X, rArea.Y, 0, 0 );
+ 
+-        for( int g = 0; g < 2; g++ )
++        for ( int g = 0; g < 2; g++ )
+         {
+             std::vector< GroupData > &aGroup = g == 0 ? maCols : maRows;
+             const int nFirstAttach = g == 0 ? child->mnLeftCol : child->mnTopRow;
+             const int nLastAttach  = g == 0 ? child->mnRightCol : child->mnBottomRow;
+ 
+-            for( int i = 0; i < nFirstAttach; i++ )
++            for ( int i = 0; i < nFirstAttach; i++ )
+             {
+                 int gSize = aGroup[ i ].mnSize;
+                 if ( aGroup[ i ].mbExpand )
+@@ -300,7 +300,7 @@ Table::allocateArea( const awt::Rectangle &rArea )
+                 else
+                     rChildArea.Y += gSize;
+             }
+-            for( int i = nFirstAttach; i < nLastAttach; i++ )
++            for ( int i = nFirstAttach; i < nLastAttach; i++ )
+             {
+                 int gSize = aGroup[ i ].mnSize;
+                 if ( aGroup[ i ].mbExpand )
+diff --git a/source/layout/timer.cxx b/source/layout/timer.cxx
+index e36fedc..159acbe 100644
+--- toolkit/source/layout/timer.cxx
++++ toolkit/source/layout/timer.cxx
+@@ -104,12 +104,12 @@ public:
+         mxLastAdded = uno::Reference< awt::XLayoutContainer >();
+ 
+         // 1. remove duplications and children
+-        for( ContainerList::iterator it = mxContainers.begin();
++        for ( ContainerList::iterator it = mxContainers.begin();
+              it != mxContainers.end(); it++ )
+             eraseChildren( it, mxContainers );
+ 
+         // 2. check damage extent
+-        for( ContainerList::iterator it = mxContainers.begin();
++        for ( ContainerList::iterator it = mxContainers.begin();
+              it != mxContainers.end(); it++ )
+         {
+             uno::Reference< awt::XLayoutContainer > xContainer = *it;
+@@ -130,7 +130,7 @@ public:
+         }
+ 
+         // 3. force re-calculations
+-        for( ContainerList::iterator it = mxContainers.begin();
++        for ( ContainerList::iterator it = mxContainers.begin();
+              it != mxContainers.end(); it++ )
+             (*it)->allocateArea( (*it)->getAllocatedArea() );
+     }
+diff --git a/source/vclcompat/wbutton.cxx b/source/vclcompat/wbutton.cxx
+index 17c2142..118b241 100644
+--- toolkit/source/vclcompat/wbutton.cxx
++++ toolkit/source/vclcompat/wbutton.cxx
+@@ -168,8 +168,8 @@ void Button::Click()
+ {
+ }
+ 
+-DECL_GET_IMPL_IMPL( Button );
+-DECL_CONSTRUCTOR_IMPLS( Button, Control, "button" );
++IMPL_GET_IMPL( Button );
++IMPL_CONSTRUCTORS( Button, Control, "button" );
+ 
+ class PushButtonImpl : public ButtonImpl
+ {
+@@ -223,8 +223,8 @@ void PushButton::SetToggleHdl( const Link& rLink )
+     getImpl().SetToggleHdl( rLink );
+ }
+ 
+-DECL_GET_IMPL_IMPL( PushButton );
+-DECL_CONSTRUCTOR_IMPLS( PushButton, Button, "pushbutton" );
++IMPL_GET_IMPL( PushButton );
++IMPL_CONSTRUCTORS( PushButton, Button, "pushbutton" );
+ 
+  // HACK: put every radio button into a group :/
+ static std::list< RadioButtonImpl*> mpRadioGroup;
+@@ -320,9 +320,9 @@ void RadioButton::SetToggleHdl( const Link& rLink )
+     getImpl().SetToggleHdl( rLink );
+ }
+ 
+-DECL_GET_IMPL_IMPL( RadioButton );
++IMPL_GET_IMPL( RadioButton );
+ #if 1
+-DECL_CONSTRUCTOR_IMPLS( RadioButton, Button, "radiobutton" );
++IMPL_CONSTRUCTORS( RadioButton, Button, "radiobutton" );
+ #else //debugging aid
+ RadioButton::RadioButton( Context *pCtx, const char *pId, sal_uInt32 nId )
+     : Button( new RadioButtonImpl( pCtx, pCtx->GetPeerHandle( pId, nId ), this ) )
+@@ -373,8 +373,8 @@ void CheckBox::SetToggleHdl( const Link& rLink )
+     getImpl().SetToggleHdl( rLink );
+ }
+ 
+-DECL_GET_IMPL_IMPL( CheckBox );
+-DECL_CONSTRUCTOR_IMPLS( CheckBox, Button, "checkbox" );
++IMPL_GET_IMPL( CheckBox );
++IMPL_CONSTRUCTORS( CheckBox, Button, "checkbox" );
+ 
+ #define BUTTON_IMPL(t, parent, response) \
+     class t##Impl : public parent##Impl \
+@@ -410,15 +410,15 @@ BUTTON_IMPL( ResetButton, PushButton, BUTTONID_RESET );
+ BUTTON_IMPL( ApplyButton, PushButton, BUTTONID_APPLY ); /* Deprecated? */
+ BUTTON_IMPL( HelpButton, PushButton, BUTTONID_HELP );
+ 
+-DECL_CONSTRUCTOR_IMPLS( OKButton, PushButton, "okbutton" );
+-DECL_CONSTRUCTOR_IMPLS( CancelButton, PushButton, "cancelbutton" );
+-DECL_CONSTRUCTOR_IMPLS( YesButton, PushButton, "yesbutton" );
+-DECL_CONSTRUCTOR_IMPLS( NoButton, PushButton, "nobutton" );
+-DECL_CONSTRUCTOR_IMPLS( RetryButton, PushButton, "retrybutton" );
+-DECL_CONSTRUCTOR_IMPLS( IgnoreButton, PushButton, "ignorebutton" );
+-DECL_CONSTRUCTOR_IMPLS( ResetButton, PushButton, "resetbutton" );
+-DECL_CONSTRUCTOR_IMPLS( ApplyButton, PushButton, "applybutton" );  /* Deprecated? */
+-DECL_CONSTRUCTOR_IMPLS( HelpButton, PushButton, "helpbutton" );
++IMPL_CONSTRUCTORS( OKButton, PushButton, "okbutton" );
++IMPL_CONSTRUCTORS( CancelButton, PushButton, "cancelbutton" );
++IMPL_CONSTRUCTORS( YesButton, PushButton, "yesbutton" );
++IMPL_CONSTRUCTORS( NoButton, PushButton, "nobutton" );
++IMPL_CONSTRUCTORS( RetryButton, PushButton, "retrybutton" );
++IMPL_CONSTRUCTORS( IgnoreButton, PushButton, "ignorebutton" );
++IMPL_CONSTRUCTORS( ResetButton, PushButton, "resetbutton" );
++IMPL_CONSTRUCTORS( ApplyButton, PushButton, "applybutton" );  /* Deprecated? */
++IMPL_CONSTRUCTORS( HelpButton, PushButton, "helpbutton" );
+ 
+ class AdvancedButtonImpl : public PushButtonImpl
+ {
+@@ -551,8 +551,8 @@ void AdvancedButton::RemoveSimple( Window* w )
+     getImpl().RemoveSimple( w );
+ }
+ 
+-DECL_CONSTRUCTOR_IMPLS( AdvancedButton, PushButton, "advancedbutton" );
+-DECL_GET_IMPL_IMPL( AdvancedButton );
++IMPL_CONSTRUCTORS( AdvancedButton, PushButton, "advancedbutton" );
++IMPL_GET_IMPL( AdvancedButton );
+ 
+ 
+ class MoreButtonImpl : public AdvancedButtonImpl
+@@ -570,8 +570,8 @@ public:
+ 
+ // TODO
+ //BUTTON_IMPL( MoreButton, PushButton, 0 );
+-DECL_CONSTRUCTOR_IMPLS( MoreButton, AdvancedButton, "morebutton" );
+-DECL_GET_IMPL_IMPL( MoreButton );
++IMPL_CONSTRUCTORS( MoreButton, AdvancedButton, "morebutton" );
++IMPL_GET_IMPL( MoreButton );
+ 
+ void MoreButton::AddWindow( Window* w )
+ {
+diff --git a/source/vclcompat/wfield.cxx b/source/vclcompat/wfield.cxx
+index 7ceed85..2f99442 100644
+--- toolkit/source/vclcompat/wfield.cxx
++++ toolkit/source/vclcompat/wfield.cxx
+@@ -87,6 +87,13 @@ class EditImpl : public ControlImpl,
+     }
+ };
+ 
++void Edit::SetSelection( Selection const& rSelection )
++{
++    if ( !getImpl().mxEdit.is() )
++        return;
++    getImpl().mxEdit->setSelection( awt::Selection( rSelection.Min(), rSelection.Max() ) );
++}
++
+ void Edit::SetText( const XubString& rStr ) const
+ {
+     if ( !getImpl().mxEdit.is() )
+@@ -106,8 +113,8 @@ void Edit::SetModifyHdl( const Link& rLink )
+     getImpl().SetModifyHdl( rLink );
+ }
+ 
+-DECL_CONSTRUCTOR_IMPLS( Edit, Control, "edit" );
+-DECL_GET_IMPL_IMPL( Edit );
++IMPL_CONSTRUCTORS( Edit, Control, "edit" );
++IMPL_GET_IMPL( Edit );
+ 
+ // Window/Control/Edit/MultiLineEdit
+ class MultiLineEditImpl : public EditImpl
+@@ -119,8 +126,8 @@ public:
+     }
+ };
+ 
+-DECL_CONSTRUCTOR_IMPLS( MultiLineEdit, Edit, "multilineedit" );
+-DECL_GET_IMPL_IMPL( MultiLineEdit );
++IMPL_CONSTRUCTORS( MultiLineEdit, Edit, "multilineedit" );
++IMPL_GET_IMPL( MultiLineEdit );
+ 
+ // Window/Control/Edit/SpinField
+ class SpinFieldImpl : public EditImpl
+@@ -132,7 +139,7 @@ class SpinFieldImpl : public EditImpl
+     }
+ };
+ 
+-DECL_CONSTRUCTOR_IMPLS( SpinField, Edit, "spinfield" );
++IMPL_CONSTRUCTORS( SpinField, Edit, "spinfield" );
+ 
+ // Window/Control/Edit/SpinField/NumericField
+ class NumericFieldImpl : public SpinFieldImpl
+@@ -154,9 +161,9 @@ class MetricFieldImpl : public SpinFieldImpl
+     }
+ };
+ 
+-DECL_GET_IMPL_IMPL( SpinField );
+-DECL_GET_IMPL_IMPL( NumericField );
+-DECL_GET_IMPL_IMPL( MetricField );
++IMPL_GET_IMPL( SpinField );
++IMPL_GET_IMPL( NumericField );
++IMPL_GET_IMPL( MetricField );
+ 
+ // FormatterBase
+ class FormatterBaseImpl
+@@ -246,7 +253,7 @@ sal_Int64 NumericFormatter::GetValue() const
+ 
+ #undef SET_IMPL
+ 
+-DECL_CONSTRUCTOR_IMPLS_2( NumericField, SpinField, NumericFormatter, "numericfield" );
++IMPL_CONSTRUCTORS_2( NumericField, SpinField, NumericFormatter, "numericfield" );
+ 
+ // MetricFormatter
+ 
+@@ -289,7 +296,7 @@ sal_Int64 MetricFormatter::GetValue( FieldUnit nUnit ) const
+     return getFormatImpl().mxField->getValue( MetricUnitVclToUno( nUnit ) );
+ }
+ 
+-DECL_CONSTRUCTOR_IMPLS_2( MetricField, SpinField, MetricFormatter, "metricfield" );
++IMPL_CONSTRUCTORS_2( MetricField, SpinField, MetricFormatter, "metricfield" );
+ 
+ // Window/Control/Edit/ComboBox
+ class ComboBoxImpl : public EditImpl,
+@@ -430,8 +437,8 @@ void ComboBox::SetSelectHdl( const Link& rLink )
+     getImpl().SetSelectHdl( rLink );
+ }
+ 
+-DECL_CONSTRUCTOR_IMPLS( ComboBox, Edit, "combobox" );
+-DECL_GET_IMPL_IMPL( ComboBox );
++IMPL_CONSTRUCTORS( ComboBox, Edit, "combobox" );
++IMPL_GET_IMPL( ComboBox );
+ 
+ // Window/Control/ListBox
+ class ListBoxImpl : public ControlImpl,
+@@ -625,7 +632,7 @@ void ListBox::SetClickHdl( const Link& rLink )
+     getImpl().SetClickHdl( rLink );
+ }
+ 
+-DECL_CONSTRUCTOR_IMPLS( ListBox, Control, "listbox" );
+-DECL_GET_IMPL_IMPL( ListBox );
++IMPL_CONSTRUCTORS( ListBox, Control, "listbox" );
++IMPL_GET_IMPL( ListBox );
+ 
+ } // namespace layout
+diff --git a/source/vclcompat/wrapper.cxx b/source/vclcompat/wrapper.cxx
+index 6188ac1..94927bc 100644
+--- toolkit/source/vclcompat/wrapper.cxx
++++ toolkit/source/vclcompat/wrapper.cxx
+@@ -36,6 +36,7 @@
+ #include "wrapper.hxx"
+ 
+ #include <awt/vclxplugin.hxx>
++#include <com/sun/star/awt/PosSize.hpp>
+ #include <com/sun/star/awt/VclWindowPeerAttribute.hpp>
+ #include <com/sun/star/awt/WindowAttribute.hpp>
+ #include <com/sun/star/awt/XDialog2.hpp>
+@@ -43,15 +44,24 @@
+ #include <com/sun/star/awt/XProgressBar.hpp>
+ #include <com/sun/star/graphic/XGraphic.hpp>
+ #include <comphelper/processfactory.hxx>
++#include <cstdio>
+ #include <layout/factory.hxx>
+ #include <layout/layoutcore.hxx>
+ #include <layout/root.hxx>
+ #include <toolkit/awt/vclxwindow.hxx>
+ #include <vcl/ctrl.hxx>
+ #include <vcl/image.hxx>
+-#include <stdio.h>
++#include <vcl/tabpage.hxx>
+ #include <vcl/window.hxx>
+ 
++#if 0
++/* FIXME: move to sfx2 or svtools/layout.hxx */
++#include <svtools/itempool.hxx>
++#include <svtools/itemset.hxx>
++#include <svtools/poolitem.hxx>
++#endif
++
++
+ using namespace ::com::sun::star;
+ 
+ namespace layout
+@@ -144,24 +154,10 @@ PeerHandle Context::GetPeerHandle( const char *pId, sal_uInt32 nId ) const
+     return xHandle;
+ }
+ 
+-// Window/Dialog
+-class DialogImpl : public WindowImpl
+-{
+-public:
+-    uno::Reference< awt::XDialog2 > mxDialog;
+-    DialogImpl( Context *pCtx, const PeerHandle &xPeer, Window *pWindow )
+-        : WindowImpl( pCtx, xPeer, pWindow )
+-        , mxDialog( xPeer, uno::UNO_QUERY )
+-    {
+-    }
+-};
+-
+-// Accessors
+-DECL_GET_IMPL_IMPL( Control )
+-DECL_GET_IMPL_IMPL( Dialog )
++IMPL_GET_IMPL( Control );
+ 
+ Window::Window( WindowImpl *pImpl )
+-: mpImpl( pImpl )
++    : mpImpl( pImpl )
+ {
+ }
+ 
+@@ -172,6 +168,20 @@ Window::~Window()
+     mpImpl = NULL;
+ }
+ 
++void Window::SetParent( ::Window *pParent )
++{
++    uno::Reference <awt::XWindow> ref( GetPeer(), uno::UNO_QUERY );
++    ::Window *window = VCLXWindow::GetImplementation( ref )->GetWindow();
++    window->SetParent( pParent );
++}
++
++void Window::SetParent( Window *pParent )
++{
++    uno::Reference <awt::XWindow> parentRef( pParent->GetPeer(), uno::UNO_QUERY );
++    ::Window *parentWindow = VCLXWindow::GetImplementation( parentRef )->GetWindow();
++    SetParent( parentWindow );
++}
++
+ Context *Window::getContext()
+ {
+     return this && mpImpl ? mpImpl->mpCtx : NULL;
+@@ -179,11 +189,31 @@ Context *Window::getContext()
+ 
+ PeerHandle Window::GetPeer()
+ {
+-    if (!mpImpl)
++    if ( !mpImpl )
+         return PeerHandle();
+     return mpImpl->mxWindow;
+ }
+ 
++uno::Reference<awt::XWindow> Window::GetRef()
++{
++    return uno::Reference <awt::XWindow> ( GetPeer(), uno::UNO_QUERY );
++}
++
++VCLXWindow* Window::GetVCLXWindow()
++{
++    return VCLXWindow::GetImplementation( GetRef() );
++}
++
++::Window* Window::GetWindow()
++{
++    return GetVCLXWindow()->GetWindow();
++}
++
++::Window* Window::GetParent()
++{
++    return GetWindow()->GetParent();
++}
++
+ struct ToolkitVclPropsMap
+ {
+     WinBits vclStyle;
+@@ -347,6 +377,19 @@ void Window::GrabFocus()
+     getImpl().mxWindow->setFocus();
+ }
+ 
++class DialogImpl : public WindowImpl
++{
++public:
++    uno::Reference< awt::XDialog2 > mxDialog;
++    DialogImpl( Context *pCtx, const PeerHandle &xPeer, Window *pWindow )
++        : WindowImpl( pCtx, xPeer, pWindow )
++        , mxDialog( xPeer, uno::UNO_QUERY )
++    {
++    }
++};
++
++IMPL_GET_IMPL( Dialog )
++
+ Dialog::Dialog( Window *pParent, const char *pXMLPath, const char *pId, sal_uInt32 nId )
+     : Context( pXMLPath )
+     , Window( new DialogImpl( this, Context::GetPeerHandle( pId, nId ), this ) )
+@@ -363,20 +406,6 @@ Dialog::Dialog( ::Window *pParent, const char *pXMLPath, const char *pId, sal_uI
+         SetParent( pParent );
+ }
+ 
+-void Dialog::SetParent( ::Window *pParent )
+-{
+-    uno::Reference <awt::XWindow> ref( GetPeer(), uno::UNO_QUERY );
+-    ::Window *window = VCLXWindow::GetImplementation( ref )->GetWindow();
+-    window->SetParent( pParent );
+-}
+-
+-void Dialog::SetParent( Window *pParent )
+-{
+-    uno::Reference <awt::XWindow> parentRef( pParent->GetPeer(), uno::UNO_QUERY );
+-    ::Window *parentWindow = VCLXWindow::GetImplementation( parentRef )->GetWindow();
+-    SetParent( parentWindow );
+-}
+-
+ short Dialog::Execute()
+ {
+     if ( !getImpl().mxDialog.is() )
+@@ -398,6 +427,108 @@ void Dialog::SetText( const String& rStr )
+     getImpl().mxDialog->setTitle( rStr );
+ }
+ 
++class TabPageImpl : public WindowImpl
++{
++public:
++    uno::Reference< awt::XWindow > mxTabPage;
++    TabPageImpl( Context *pCtx, const PeerHandle &xPeer, Window *pWindow )
++        : WindowImpl( pCtx, xPeer, pWindow )
++        , mxTabPage( xPeer, uno::UNO_QUERY )
++    {
++    }
++    void redraw()
++    {
++        uno::Reference <awt::XWindow> ref( mxWindow, uno::UNO_QUERY );
++        ::Window* window = VCLXWindow::GetImplementation( ref )->GetWindow();
++        ::Window* parent = window->GetParent();
++
++        ::Rectangle r = Rectangle( parent->GetPosPixel(),
++                                   parent->GetSizePixel() );
++
++        parent->Invalidate( r, INVALIDATE_CHILDREN | INVALIDATE_NOCHILDREN );
++        parent->SetPosSizePixel( 0, 0, r.nRight - r.nLeft, r.nBottom - r.nTop,
++                                 awt::PosSize::SIZE );
++
++        r = Rectangle( window->GetPosPixel(),
++                       window->GetSizePixel() );
++
++        window->Invalidate( r, INVALIDATE_CHILDREN | INVALIDATE_NOCHILDREN );
++        window->SetPosSizePixel( 0, 0, r.nRight - r.nLeft, r.nBottom - r.nTop,
++                                 awt::PosSize::SIZE );
++    }
++};
++
++::Window* TabPage::global_parent = 0;
++
++IMPL_GET_IMPL( TabPage )
++
++TabPage::TabPage( Window *pParent, const char *pXMLPath, const char *pId, sal_uInt32 nId )
++    : Context( pXMLPath )
++    , Window( new TabPageImpl( this, Context::GetPeerHandle( pId, nId ), this ) )
++{
++    if ( pParent )
++        SetParent( pParent );
++
++//     GetTabPage()->EnableChildTransparentMode( false );
++//     GetTabPage()->SetPaintTransparent( false );
++}
++
++TabPage::TabPage( ::Window *pParent, const char *pXMLPath, const char *pId, sal_uInt32 nId )
++    : Context( pXMLPath )
++    , Window( new TabPageImpl( this, Context::GetPeerHandle( pId, nId ), this ) )
++{
++    if ( pParent )
++        SetParent( pParent );
++
++//     GetTabPage()->EnableChildTransparentMode( false );
++//     GetTabPage()->SetPaintTransparent( false );
++}
++
++IMPL_GET_WINDOW( TabPage );
++
++void TabPage::ActivatePage()
++{
++//     GetTabPage()->EnableChildTransparentMode( true );
++//     GetTabPage()->SetPaintTransparent( true );
++//     getImpl().redraw();
++}
++
++void TabPage::DeactivatePage()
++{
++//    GetTabPage()->Hide();
++}
++
++#if 0
++SfxTabPage::SfxTabPage( Window *pParent, const char *pXMLPath, const char *pId, sal_uInt32 nId )
++    : TabPage( pParent, pXMLPath, pId, nId )
++{
++}
++
++SfxTabPage::SfxTabPage( ::Window *pParent, const char *pXMLPath, const char *pId, sal_uInt32 nId )
++    : TabPage( pParent, pXMLPath, pId, nId )
++{
++}
++
++/* FIXME: static method, full c&p from sfx2/source/dialog/tabdlg.cxx */
++//const SfxPoolItem* TabPage::GetItem( const SfxItemSet& rSet, USHORT nSlot )
++const SfxPoolItem* SfxTabPage::GetItem( const SfxItemSet& rSet, USHORT nSlot )
++
++{
++	const SfxItemPool* pPool = rSet.GetPool();
++	USHORT nWh = pPool->GetWhich( nSlot );
++	const SfxPoolItem* pItem = 0;
++#ifdef DEBUG
++	SfxItemState eState;
++    eState =
++#endif
++			rSet.GetItemState( nWh, TRUE, &pItem );  // -Wall required??
++
++	if ( !pItem && nWh != nSlot )
++		pItem = &pPool->GetDefaultItem( nWh );
++	return pItem;
++}
++#endif
++
+ class FixedLineImpl : public ControlImpl
+ {
+ public:
+@@ -407,8 +538,8 @@ public:
+     }
+ };
+ 
+-DECL_CONSTRUCTOR_IMPLS( FixedLine, Control, "hfixedline" );
+-DECL_GET_IMPL_IMPL( FixedLine )
++IMPL_CONSTRUCTORS( FixedLine, Control, "hfixedline" );
++IMPL_GET_IMPL( FixedLine )
+ 
+ bool FixedLine::IsEnabled()
+ {
+@@ -433,8 +564,8 @@ public:
+     }
+ };
+ 
+-DECL_CONSTRUCTOR_IMPLS( FixedText, Control, "fixedtext" );
+-DECL_GET_IMPL_IMPL( FixedText )
++IMPL_CONSTRUCTORS( FixedText, Control, "fixedtext" );
++IMPL_GET_IMPL( FixedText )
+ 
+ void FixedText::SetText( const String& rStr )
+ {
+@@ -452,8 +583,8 @@ public:
+     }
+ };
+ 
+-DECL_CONSTRUCTOR_IMPLS( FixedInfo, FixedText, "fixedinfo" );
+-DECL_GET_IMPL_IMPL( FixedInfo );
++IMPL_CONSTRUCTORS( FixedInfo, FixedText, "fixedinfo" );
++IMPL_GET_IMPL( FixedInfo );
+ 
+ class ProgressBarImpl : public ControlImpl
+ {
+@@ -494,8 +625,8 @@ public:
+     }
+ };
+ 
+-DECL_CONSTRUCTOR_IMPLS( FixedImage, Control, "fixedimage" );
+-DECL_GET_IMPL_IMPL( FixedImage )
++IMPL_CONSTRUCTORS( FixedImage, Control, "fixedimage" );
++IMPL_GET_IMPL( FixedImage )
+ 
+ void FixedImage::setImage( ::Image const& i )
+ {
+@@ -521,7 +652,7 @@ FixedImage::~FixedImage()
+ #endif
+ 
+     
+-DECL_CONSTRUCTOR_IMPLS( ProgressBar, Control, "ProgressBar" );
++IMPL_CONSTRUCTORS( ProgressBar, Control, "ProgressBar" );
+ #if 0
+ ProgressBar::ProgressBar( Context *pCtx, const char *pId, sal_uInt32 nId )
+     : Control( new ProgressBarImpl( pCtx, pCtx->GetPeerHandle( pId, nId ), this ) )
+@@ -534,7 +665,7 @@ ProgressBar::ProgressBar( Window *pParent, WinBits nBits)
+ }
+ #endif
+ 
+-DECL_GET_IMPL_IMPL( ProgressBar )
++IMPL_GET_IMPL( ProgressBar )
+ 
+ 
+ void ProgressBar::SetForegroundColor( css::util::Color color )
+@@ -601,7 +732,7 @@ Plugin::Plugin( Context *pCtx, char const *pId, ::Control *plugin )
+ {
+ }
+ 
+-DECL_GET_IMPL_IMPL( Plugin )
++IMPL_GET_IMPL( Plugin )
+ 
+ 
+ } // namespace layout
+diff --git a/source/vclcompat/wrapper.hxx b/source/vclcompat/wrapper.hxx
+index f56bc0a..5df64bc 100644
+--- toolkit/source/vclcompat/wrapper.hxx
++++ toolkit/source/vclcompat/wrapper.hxx
+@@ -111,12 +111,12 @@ inline WindowImpl &Window::getImpl() const
+ 
+ // Helpers for defining boiler-plate constructors ...
+ // Could in-line in top-level but not with safe static_casts.
+-#define DECL_GET_IMPL_IMPL(t) \
++#define IMPL_GET_IMPL(t) \
+     inline t##Impl &t::getImpl() const \
+     { \
+         return *(static_cast<t##Impl *>(mpImpl)); \
+     }
+-#define DECL_CONSTRUCTOR_IMPLS(t,par,unoName) \
++#define IMPL_CONSTRUCTORS(t,par,unoName) \
+     t::t( Context *pCtx, const char *pId, sal_uInt32 nId ) \
+         : par( new t##Impl( pCtx, pCtx->GetPeerHandle( pId, nId ), this ) ) \
+     { \
+@@ -125,7 +125,7 @@ inline WindowImpl &Window::getImpl() const
+         : par( new t##Impl( pParent->getContext(), Window::CreatePeer( pParent, nBits, unoName ), this ) ) \
+     { \
+     }
+-#define DECL_CONSTRUCTOR_IMPLS_2(t,win_par,other_par,unoName) \
++#define IMPL_CONSTRUCTORS_2(t,win_par,other_par,unoName) \
+     t::t( Context *pCtx, const char *pId, sal_uInt32 nId ) \
+         : win_par( new t##Impl( pCtx, pCtx->GetPeerHandle( pId, nId ), this ) ) \
+         , other_par( new other_par##Impl( Window::GetPeer() ) ) \
+diff --git a/workben/layout/README b/workben/layout/README
+new file mode 100644
+index 0000000..1e02c46
+--- /dev/null
++++ toolkit/workben/layout/README
+@@ -0,0 +1,35 @@
++Testing workbench and editor for Layout engine.
++
++* Configure using --enable-layout.
++
++* [d]make all
++
++* [d]make install DESTDIR=$(pwd)/ooo-layout/
++
++* Compile test program in toolkit/workben/layout
++
++  cd toolkit/workben/layout && dmake all
++
++| Currently broken on dev300 installation: m3 < dev300 <= m10.
++|
++| * Run it on any .xml file
++|
++|   ../../$INPATH/bin/test --inst .../ooo-layout/ zoom.xml
++|
++| * Run it for specific dialogs, see test.cxx
++|
++|   ../../$INPATH/bin/test --inst .../ooo-layout/ --test zoom
++|   ../../$INPATH/bin/test --inst .../ooo-layout/ --test wordcount
++|
++| * Or source refresh in workben/layout, do something like
++|
++|     cd toolkit/workben/layout && . ./refresh --inst .../ooo-layout/
++
++Integration into OOo:
++
++* After instaling, run
++
++  cd ooo-cvs/program
++  ./soffice.bin
++
++  Start a [Writer] document and choose View/Zoom or Extra/Word count.
+diff --git a/workben/layout/makefile.mk b/workben/layout/makefile.mk
+index d7303af..b4d6a28 100644
+--- toolkit/workben/layout/makefile.mk
++++ toolkit/workben/layout/makefile.mk
+@@ -44,10 +44,11 @@ ENABLE_EXCEPTIONS=TRUE
+ 
+ .IF "$(ENABLE_LAYOUT)" == "TRUE"
+ 
+-CFLAGS += -I$(PRJ)/source/layout
++.INCLUDE :  minor.mk
++CFLAGS += -I$(PRJ)/source/layout -DRSCVERSION=$(RSCVERSION)
+ 
+ # Allow zoom and wordcount to be built without depending on svx,sv,sfx2
+-CFLAGS += -I../$(PRJ)/svx/inc -I../$(PRJ)/svtools/inc -I../$(PRJ)/sfx2/inc
++CFLAGS += -I../$(PRJ)/svx/inc -I../$(PRJ)/svtools/inc -I../$(PRJ)/sfx2/inc -I../$(PRJ)/sc/inc -I../$(PRJ)/sc/source/ui/inc
+ 
+ .INCLUDE : $(PRJ)$/util$/makefile.pmk
+ 
+@@ -70,6 +71,8 @@ OBJFILES=\
+ 	$(OBJ)$/plugin.obj \
+ 	$(OBJ)$/recover.obj \
+ 	$(OBJ)$/test.obj \
++	$(OBJ)$/tpsort.obj \
++	$(OBJ)$/sortdlg.obj \
+ 	$(OBJ)$/wordcountdialog.obj \
+ 	$(OBJ)$/zoom.obj
+ 
+@@ -84,7 +87,9 @@ APP1STDLIBS= \
+ 		$(SALLIB)			\
+ 		$(XMLSCRIPTLIB)			\
+ 		$(TKLIB) \
+-		$(SVXLIB)
++		$(SVXLIB) \
++		$(ISCLIB) \
++#
+ 
+ svtools = $(INCCOM)/svtools
+ all: $(svtools) ALLTAR
+diff --git a/workben/layout/sort-options.xml b/workben/layout/sort-options.xml
+new file mode 100644
+index 0000000..9a8053a
+--- /dev/null
++++ toolkit/workben/layout/sort-options.xml
+@@ -0,0 +1,34 @@
++<?xml version="1.0" encoding="UTF-8"?>
++<!-- This is a template.  i18n translation is not performed in-place;
++     i18n translated XML files are generated from this template by
++     transex3/layout/tralay.  !-->
++<!--
++<tabpage help-id="HID_SCPAGE_SORT_OPTIONS" hide="true" id="RID_SCPAGE_SORT_OPTIONS" sv-look="true" xmlns="http://openoffice.org/2007/layout"; xmlns:cnt="http://openoffice.org/2007/layout/container";>
++!-->
++
++<tabpage help-id="HID_SCPAGE_SORT_OPTIONS" id="RID_SCPAGE_SORT_OPTIONS" sv-look="true" xmlns="http://openoffice.org/2007/layout"; xmlns:cnt="http://openoffice.org/2007/layout/container"; width="640" height="480">
++    <vbox>
++        <checkbox id="BTN_CASESENSITIVE" tab-stop="true" text="Case ~sensitive"/>
++        <checkbox id="BTN_LABEL" tab-stop="true"/>
++        <checkbox id="BTN_FORMATS" tab-stop="true" text="Include ~formats"/>
++        <checkbox id="BTN_NATURALSORT" tab-stop="true" text=" "/>
++        <checkbox id="BTN_COPYRESULT" tab-stop="true" text="~Copy sort results to:"/>
++        <hbox>
++            <listbox has_border="true" drop-down="true" id="LB_OUTAREA" tab-stop="true"/>
++            <edit has_border="true" disable="true" id="ED_OUTAREA" tab-stop="true"/>
++        </hbox>
++        <checkbox id="BTN_SORT_USER" tab-stop="true" text="Custom sort ~order"/>
++        <listbox has_border="true" disable="true" drop-down="true" id="LB_SORT_USER" tab-stop="true"/>
++        <hbox>
++            <fixedtext id="FT_LANGUAGE" label="~Language"/>
++            <fixedtext id="FT_ALGORITHM" label="O~ptions"/>
++        </hbox>
++        <hbox>
++            <listbox has_border="true" drop-down="true" id="LB_LANGUAGE" sort="true" tab-stop="true"/>
++            <listbox has_border="true" drop-down="true" id="LB_ALGORITHM" tab-stop="true"/>
++        </hbox>
++        <fixedline id="FL_DIRECTION" text="Direction"/>
++        <radiobutton id="BTN_TOP_DOWN" tab-stop="true" label="~Top to bottom (sort rows)"/>
++        <radiobutton id="BTN_LEFT_RIGHT" tab-stop="true" label="L~eft to right (sort columns)"/>
++    </vbox>
++</tabpage>
+diff --git a/workben/layout/sortdlg.cxx b/workben/layout/sortdlg.cxx
+new file mode 100644
+index 0000000..7d91042
+--- /dev/null
++++ toolkit/workben/layout/sortdlg.cxx
+@@ -0,0 +1,75 @@
++/*************************************************************************
++ *
++ *  OpenOffice.org - a multi-platform office productivity suite
++ *
++ *  $RCSfile: sortdlg.cxx,v $
++ *
++ *  $Revision: 1.5 $
++ *
++ *  last change: $Author: kz $ $Date: 2006/07/21 13:29:10 $
++ *
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
++ *
++ *
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library 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 for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
++ *
++ ************************************************************************/
++
++#if !TEST_LAYOUT
++// MARKER(update_precomp.py): autogen include statement, do not remove
++#include "precompiled_sc.hxx"
++#endif /*! TEST_LAYOUT */
++
++#undef SC_DLLIMPLEMENTATION
++
++
++
++#include "tpsort.hxx"
++#include "sortdlg.hxx"
++#include "scresid.hxx"
++#include "sortdlg.hrc"
++
++
++//==================================================================
++
++ScSortDlg::ScSortDlg( Window*			pParent,
++					  const SfxItemSet* pArgSet ) :
++		SfxTabDialog( pParent,
++					  ScResId( RID_SCDLG_SORT ),
++					  pArgSet ),
++		bIsHeaders	( FALSE ),
++		bIsByRows	( FALSE )
++
++{
++	AddTabPage( TP_FIELDS,	ScTabPageSortFields::Create,  0 );
++#if !ENABLE_LAYOUT
++	AddTabPage( TP_OPTIONS,	ScTabPageSortOptions::Create,  0 );
++#else /* ENABLE_LAYOUT */
++    layout::TabPage::global_parent = this;
++	AddTabPage( TP_OPTIONS, new ScTabPageSortOptions( this, *pArgSet ) );
++#endif /* ENABLE_LAYOUT */
++	FreeResource();
++}
++
++__EXPORT ScSortDlg::~ScSortDlg()
++{
++}
++
+diff --git a/workben/layout/sortdlg.hrc b/workben/layout/sortdlg.hrc
+new file mode 100644
+index 0000000..d946f18
+--- /dev/null
++++ toolkit/workben/layout/sortdlg.hrc
+@@ -0,0 +1,91 @@
++/*************************************************************************
++ *
++ *  OpenOffice.org - a multi-platform office productivity suite
++ *
++ *  $RCSfile: sortdlg.hrc,v $
++ *
++ *  $Revision: 1.4 $
++ *
++ *  last change: $Author: rt $ $Date: 2005/09/08 21:51:32 $
++ *
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
++ *
++ *
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library 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 for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
++ *
++ ************************************************************************/
++
++
++#include "sc.hrc"   // -> RID_SCDLG_SORT
++					// -> RID_SCPAGE_SORT_FIELDS
++					// -> RID_SCPAGE_SORT_OPTIONS
++					// -> SCSTR_NONAME
++					// -> SCSTR_UNDEFINED
++					// -> SCSTR_FIELD
++
++/*
++#define RID_SCDLG_SORT			256
++#define RID_SCPAGE_SORT_FIELDS	257
++#define RID_SCPAGE_SORT_OPTIONS	258
++*/
++
++#define TP_FIELDS			1
++#define TP_OPTIONS			2
++
++// TP_SORT_FIELDS:
++#define FL_SORT1            1
++#define FL_SORT2            2
++#define FL_SORT3            3
++#define LB_SORT1			4
++#define LB_SORT2			5
++#define LB_SORT3			6
++#define BTN_UP1				7
++#define BTN_UP2				8
++#define BTN_UP3				9
++#define BTN_DOWN1			10
++#define BTN_DOWN2			11
++#define BTN_DOWN3			12
++
++// TP_SORT_OPTIONS:
++#define FL_DIRECTION		1
++#define LB_SORT_USER		2
++#define LB_OUTAREA			3
++#define ED_OUTAREA          4
++//#define FT_AREA_LABEL       5
++//#define FT_AREA             6
++#define BTN_SORT_USER       7
++#define BTN_CASESENSITIVE   8
++#define BTN_LABEL           9
++#define BTN_FORMATS         10
++#define BTN_COPYRESULT      11
++#define BTN_TOP_DOWN        12
++#define BTN_LEFT_RIGHT      13
++#define STR_COL_LABEL       14
++#define STR_ROW_LABEL       15
++#define FT_LANGUAGE         16
++#define LB_LANGUAGE         17
++#define FT_ALGORITHM        18
++#define LB_ALGORITHM        19
++#define	BTN_NATURALSORT		20
++
++
++
++
+diff --git a/workben/layout/sortdlg.hxx b/workben/layout/sortdlg.hxx
+new file mode 100644
+index 0000000..8c4459e
+--- /dev/null
++++ toolkit/workben/layout/sortdlg.hxx
+@@ -0,0 +1,74 @@
++/*************************************************************************
++ *
++ *  OpenOffice.org - a multi-platform office productivity suite
++ *
++ *  $RCSfile: sortdlg.hxx,v $
++ *
++ *  $Revision: 1.2 $
++ *
++ *  last change: $Author: rt $ $Date: 2005/09/08 21:51:47 $
++ *
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
++ *
++ *
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library 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 for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
++ *
++ ************************************************************************/
++
++#ifndef SC_SORTDLG_HXX
++#define SC_SORTDLG_HXX
++
++#ifndef _SFXTABDLG_HXX //autogen
++#include <sfx2/tabdlg.hxx>
++#endif
++
++#ifndef _SFX_HXX
++#endif
++
++//==================================================================
++
++class ScSortDlg : public SfxTabDialog
++{
++public:
++				ScSortDlg( Window*			 pParent,
++						   const SfxItemSet* pArgSet );
++				~ScSortDlg();
++
++	void	SetHeaders( BOOL bHeaders );
++	void	SetByRows ( BOOL bByRows );
++	BOOL	GetHeaders() const;
++	BOOL	GetByRows () const;
++
++
++private:
++	BOOL	bIsHeaders;
++	BOOL	bIsByRows;
++};
++
++inline void ScSortDlg::SetHeaders( BOOL bHeaders )	{ bIsHeaders = bHeaders; }
++inline void ScSortDlg::SetByRows ( BOOL bByRows  )	{ bIsByRows = bByRows; }
++inline BOOL ScSortDlg::GetHeaders() const 			{ return bIsHeaders; }
++inline BOOL ScSortDlg::GetByRows () const 			{ return bIsByRows; }
++
++
++#endif // SC_SORTDLG_HXX
++
++
+diff --git a/workben/layout/sortdlg.src b/workben/layout/sortdlg.src
+new file mode 100644
+index 0000000..e0d8496
+--- /dev/null
++++ toolkit/workben/layout/sortdlg.src
+@@ -0,0 +1,325 @@
++/*************************************************************************
++ *
++ *  OpenOffice.org - a multi-platform office productivity suite
++ *
++ *  $RCSfile: sortdlg.src,v $
++ *
++ *  $Revision: 1.41 $
++ *
++ *  last change: $Author: ihi $ $Date: 2007/04/19 16:48:19 $
++ *
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
++ *
++ *
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library 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 for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
++ *
++ ************************************************************************/
++#include "sortdlg.hrc"
++TabPage RID_SCPAGE_SORT_FIELDS
++{
++	Hide = TRUE ;
++	SVLook = TRUE ;
++	HelpId = HID_SCPAGE_SORT_FIELDS ;
++    Size = MAP_APPFONT ( 260 , 185 ) ;
++	ListBox LB_SORT1
++	{
++		Border = TRUE ;
++		Pos = MAP_APPFONT ( 12 , 19 ) ;
++        Size = MAP_APPFONT ( 154 , 90 ) ;
++		TabStop = TRUE ;
++		DropDown = TRUE ;
++	};
++	RadioButton BTN_UP1
++	{
++        Pos = MAP_APPFONT ( 172 , 14 ) ;
++        Size = MAP_APPFONT ( 79 , 10 ) ;
++		Text [ en-US ] = "~Ascending" ;
++		TabStop = TRUE ;
++	};
++	RadioButton BTN_DOWN1
++	{
++        Pos = MAP_APPFONT ( 172 , 28 ) ;
++        Size = MAP_APPFONT ( 79 , 10 ) ;
++		Text [ en-US ] = "~Descending" ;
++		TabStop = TRUE ;
++	};
++    FixedLine FL_SORT1
++	{
++		Pos = MAP_APPFONT ( 6 , 3 ) ;
++        Size = MAP_APPFONT ( 248 , 8 ) ;
++		Text [ en-US ] = "Sort ~by" ;
++	};
++	ListBox LB_SORT2
++	{
++		Border = TRUE ;
++        Pos = MAP_APPFONT ( 12 , 60 ) ;
++        Size = MAP_APPFONT ( 154 , 90 ) ;
++		TabStop = TRUE ;
++		DropDown = TRUE ;
++	};
++	RadioButton BTN_UP2
++	{
++        Pos = MAP_APPFONT ( 172 , 55 ) ;
++        Size = MAP_APPFONT ( 79 , 10 ) ;
++		Text [ en-US ] = "A~scending" ;
++		TabStop = TRUE ;
++	};
++	RadioButton BTN_DOWN2
++	{
++        Pos = MAP_APPFONT ( 172 , 69 ) ;
++        Size = MAP_APPFONT ( 79 , 10 ) ;
++		Text [ en-US ] = "D~escending" ;
++		TabStop = TRUE ;
++	};
++    FixedLine FL_SORT2
++	{
++        Pos = MAP_APPFONT ( 6 , 44 ) ;
++        Size = MAP_APPFONT ( 248 , 8 ) ;
++		Text [ en-US ] = "Then b~y" ;
++	};
++	ListBox LB_SORT3
++	{
++		Border = TRUE ;
++        Pos = MAP_APPFONT ( 12 , 101 ) ;
++        Size = MAP_APPFONT ( 154 , 90 ) ;
++		TabStop = TRUE ;
++		DropDown = TRUE ;
++	};
++	RadioButton BTN_UP3
++	{
++        Pos = MAP_APPFONT ( 172 , 96 ) ;
++        Size = MAP_APPFONT ( 79 , 10 ) ;
++		Text [ en-US ] = "As~cending" ;
++		TabStop = TRUE ;
++	};
++	RadioButton BTN_DOWN3
++	{
++        Pos = MAP_APPFONT ( 172 , 110 ) ;
++        Size = MAP_APPFONT ( 79 , 10 ) ;
++		Text [ en-US ] = "Desce~nding" ;
++		TabStop = TRUE ;
++	};
++    FixedLine FL_SORT3
++	{
++        Pos = MAP_APPFONT ( 6 , 85 ) ;
++        Size = MAP_APPFONT ( 248 , 8 ) ;
++		Text [ en-US ] = "T~hen by" ;
++	};
++};
++TabPage RID_SCPAGE_SORT_OPTIONS
++{
++	Hide = TRUE ;
++	SVLook = TRUE ;
++	HelpId = HID_SCPAGE_SORT_OPTIONS ;
++	Pos = MAP_APPFONT ( 0 , 0 ) ;
++    Size = MAP_APPFONT ( 260 , 185 ) ;
++	CheckBox BTN_CASESENSITIVE
++	{
++        Pos = MAP_APPFONT ( 12 , 6 ) ;
++        Size = MAP_APPFONT ( 242 , 10 ) ;
++		Text [ en-US ] = "Case ~sensitive" ;
++		TabStop = TRUE ;
++	};
++	CheckBox BTN_LABEL
++	{
++        Pos = MAP_APPFONT ( 12 , 20 ) ;
++        Size = MAP_APPFONT ( 242 , 10 ) ;
++		TabStop = TRUE ;
++	};
++	String STR_COL_LABEL
++	{
++		Text [ en-US ] = "Range contains column la~bels" ;
++	};
++	String STR_ROW_LABEL
++	{
++		Text [ en-US ] = "Range contains ~row labels" ;
++	};
++	CheckBox BTN_FORMATS
++	{
++        Pos = MAP_APPFONT ( 12 , 34 ) ;
++        Size = MAP_APPFONT ( 242 , 10 ) ;
++		Text [ en-US ] = "Include ~formats" ;
++		TabStop = TRUE ;
++	};
++	CheckBox BTN_NATURALSORT
++	{
++		Pos = MAP_APPFONT ( 12 , 48 ) ;
++		Size = MAP_APPFONT ( 242 , 10 ) ;
++		Text [ de ] = "Enable ~natural sort" ;
++		Text [ en-US ] = "Enable ~natural sort" ;
++		Text [ cs ] = "Aktivovat pÅirozenà tÅÃdÄnÃ" ;
++       Text [ sk ] = "AktivovaŠprirodzenà triedenie" ;
++		TabStop = TRUE ;
++		Text [ x-comment ] = " " ;
++	};
++	CheckBox BTN_COPYRESULT
++	{
++        Pos = MAP_APPFONT ( 12 , 62 ) ;
++        Size = MAP_APPFONT ( 242 , 10 ) ;
++		Text [ en-US ] = "~Copy sort results to:" ;
++		TabStop = TRUE ;
++	};
++	ListBox LB_OUTAREA
++	{
++		Border = TRUE ;
++        Pos = MAP_APPFONT ( 20 , 73 ) ;
++        Size = MAP_APPFONT ( 93 , 90 ) ;
++		TabStop = TRUE ;
++		DropDown = TRUE ;
++	};
++	Edit ED_OUTAREA
++	{
++		Disable = TRUE ;
++		Border = TRUE ;
++        Pos = MAP_APPFONT ( 119 , 73 ) ;
++        Size = MAP_APPFONT ( 132 , 12 ) ;
++		TabStop = TRUE ;
++	};
++	CheckBox BTN_SORT_USER
++	{
++        Pos = MAP_APPFONT ( 12 , 89 ) ;
++        Size = MAP_APPFONT ( 242 , 10 ) ;
++		Text [ en-US ] = "Custom sort ~order" ;
++		TabStop = TRUE ;
++	};
++	ListBox LB_SORT_USER
++	{
++		Disable = TRUE ;
++		Border = TRUE ;
++        Pos = MAP_APPFONT ( 20 , 100 ) ;
++        Size = MAP_APPFONT ( 231 , 90 ) ;
++		TabStop = TRUE ;
++		DropDown = TRUE ;
++	};
++    FixedText FT_LANGUAGE
++	{
++        Pos = MAP_APPFONT ( 12 , 118 ) ;
++        Size = MAP_APPFONT ( 101 , 8 ) ;
++		Text [ en-US ] = "~Language";
++	};
++	ListBox LB_LANGUAGE
++	{
++		Border = TRUE ;
++        Pos = MAP_APPFONT ( 12 , 129 ) ;
++        Size = MAP_APPFONT ( 101 , 90 ) ;
++		TabStop = TRUE ;
++		DropDown = TRUE ;
++		Sort = TRUE ;
++	};
++    FixedText FT_ALGORITHM
++	{
++        Pos = MAP_APPFONT ( 119 , 118 ) ;
++        Size = MAP_APPFONT ( 132 , 8 ) ;
++		Text [ en-US ] = "O~ptions";
++	};
++	ListBox LB_ALGORITHM
++	{
++		Border = TRUE ;
++        Pos = MAP_APPFONT ( 119 , 129 ) ;
++        Size = MAP_APPFONT ( 132 , 90 ) ;
++		TabStop = TRUE ;
++		DropDown = TRUE ;
++	};
++	FixedLine FL_DIRECTION
++	{
++        Pos = MAP_APPFONT ( 6 , 147 ) ;
++        Size = MAP_APPFONT ( 248 , 8 ) ;
++		Text [ en-US ] = "Direction" ;
++	};
++	RadioButton BTN_TOP_DOWN
++	{
++        Pos = MAP_APPFONT ( 12 , 158 ) ;
++        Size = MAP_APPFONT ( 242 , 10 ) ;
++		Text [ en-US ] = "~Top to bottom (sort rows)" ;
++		TabStop = TRUE ;
++	};
++	RadioButton BTN_LEFT_RIGHT
++	{
++        Pos = MAP_APPFONT ( 12 , 172 ) ;
++        Size = MAP_APPFONT ( 242 , 10 ) ;
++		Text [ en-US ] = "L~eft to right (sort columns)" ;
++		TabStop = TRUE ;
++	};
++/*
++	FixedText FT_AREA_LABEL
++	{
++        Pos = MAP_APPFONT ( 6 , 171 ) ;
++        Size = MAP_APPFONT ( 248 , 8 ) ;
++		Text [ en-US ] = "Data area:" ;
++	};
++*/
++};
++TabDialog RID_SCDLG_SORT
++{
++	OutputSize = TRUE ;
++	SVLook = TRUE ;
++	Size = MAP_APPFONT ( 220 , 175 ) ;
++	Text [ en-US ] = "Sort" ;
++	Moveable = TRUE ;
++	Closeable = FALSE ;
++	TabControl 1
++	{
++		OutputSize = TRUE ;
++		Pos = MAP_APPFONT ( 0 , 0 ) ;
++		Size = MAP_APPFONT ( 210 , 170 ) ;
++		PageList =
++		{
++			PageItem
++			{
++				Identifier = TP_FIELDS ;
++				PageResID = TP_FIELDS ;
++				Text [ en-US ] = "Sort Criteria" ;
++			};
++			PageItem
++			{
++				Identifier = TP_OPTIONS ;
++				PageResID = TP_OPTIONS ;
++				Text [ en-US ] = "Options" ;
++			};
++		};
++	};
++	OKButton 1
++	{
++		Pos = MAP_APPFONT ( 3 , 157 ) ;
++		Size = MAP_APPFONT ( 40 , 12 ) ;
++		TabStop = TRUE ;
++	};
++	CancelButton 1
++	{
++		Pos = MAP_APPFONT ( 49 , 157 ) ;
++		Size = MAP_APPFONT ( 40 , 12 ) ;
++		TabStop = TRUE ;
++	};
++	PushButton 1
++	{
++		Pos = MAP_APPFONT ( 137 , 157 ) ;
++		Size = MAP_APPFONT ( 40 , 12 ) ;
++		TabStop = TRUE ;
++	};
++	HelpButton 1
++	{
++		Pos = MAP_APPFONT ( 94 , 157 ) ;
++		Size = MAP_APPFONT ( 40 , 12 ) ;
++		TabStop = TRUE ;
++	};
++};
++
++
+diff --git a/workben/layout/sortdlg.xml b/workben/layout/sortdlg.xml
+new file mode 100644
+index 0000000..4fc23da
+--- /dev/null
++++ toolkit/workben/layout/sortdlg.xml
+@@ -0,0 +1,65 @@
++<?xml version="1.0" encoding="UTF-8"?>
++<!-- This is a template.  i18n translation is not performed in-place;
++     i18n translated XML files are generated from this template by
++     transex3/layout/tralay.  !-->
++
++<tabpage help-id="HID_SCPAGE_SORT_FIELDS" hide="true" id="RID_SCPAGE_SORT_FIELDS" sv-look="true" xmlns="http://openoffice.org/2007/layout"; xmlns:cnt="http://openoffice.org/2007/layout/container";>
++    <vbox>
++        <fixedline id="FL_SORT1" text="Sort ~by"/>
++        <radiobutton id="BTN_UP1" tab-stop="true" label="~Ascending"/>
++        <listbox has_border="true" drop-down="true" id="LB_SORT1" tab-stop="true"/>
++        <radiobutton id="BTN_DOWN1" tab-stop="true" label="~Descending"/>
++        <fixedline id="FL_SORT2" text="Then b~y"/>
++        <radiobutton id="BTN_UP2" tab-stop="true" label="A~scending"/>
++        <listbox has_border="true" drop-down="true" id="LB_SORT2" tab-stop="true"/>
++        <radiobutton id="BTN_DOWN2" tab-stop="true" label="D~escending"/>
++        <fixedline id="FL_SORT3" text="T~hen by"/>
++        <radiobutton id="BTN_UP3" tab-stop="true" label="As~cending"/>
++        <listbox has_border="true" drop-down="true" id="LB_SORT3" tab-stop="true"/>
++        <radiobutton id="BTN_DOWN3" tab-stop="true" label="Desce~nding"/>
++    </vbox>
++</tabpage>
++<tabpage help-id="HID_SCPAGE_SORT_OPTIONS" hide="true" id="RID_SCPAGE_SORT_OPTIONS" sv-look="true" xmlns="http://openoffice.org/2007/layout"; xmlns:cnt="http://openoffice.org/2007/layout/container";>
++    <string id="STR_COL_LABEL" text="Range contains column la~bels"/>
++    <string id="STR_ROW_LABEL" text="Range contains ~row labels"/>
++    <vbox>
++        <checkbox id="BTN_CASESENSITIVE" tab-stop="true" text="Case ~sensitive"/>
++        <checkbox id="BTN_LABEL" tab-stop="true"/>
++        <checkbox id="BTN_FORMATS" tab-stop="true" text="Include ~formats"/>
++        <checkbox id="BTN_NATURALSORT" tab-stop="true" text=" "/>
++        <checkbox id="BTN_COPYRESULT" tab-stop="true" text="~Copy sort results to:"/>
++        <hbox>
++            <listbox has_border="true" drop-down="true" id="LB_OUTAREA" tab-stop="true"/>
++            <edit has_border="true" disable="true" id="ED_OUTAREA" tab-stop="true"/>
++        </hbox>
++        <checkbox id="BTN_SORT_USER" tab-stop="true" text="Custom sort ~order"/>
++        <listbox has_border="true" disable="true" drop-down="true" id="LB_SORT_USER" tab-stop="true"/>
++        <hbox>
++            <fixedtext id="FT_LANGUAGE" label="~Language"/>
++            <fixedtext id="FT_ALGORITHM" label="O~ptions"/>
++        </hbox>
++        <hbox>
++            <listbox has_border="true" drop-down="true" id="LB_LANGUAGE" sort="true" tab-stop="true"/>
++            <listbox has_border="true" drop-down="true" id="LB_ALGORITHM" tab-stop="true"/>
++        </hbox>
++        <fixedline id="FL_DIRECTION" text="Direction"/>
++        <radiobutton id="BTN_TOP_DOWN" tab-stop="true" label="~Top to bottom (sort rows)"/>
++        <radiobutton id="BTN_LEFT_RIGHT" tab-stop="true" label="L~eft to right (sort columns)"/>
++    </vbox>
++</tabpage>
++<tabdialog closeable="false" moveable="true" output-size="true" id="RID_SCDLG_SORT" sv-look="true" text="Sort" xmlns="http://openoffice.org/2007/layout"; xmlns:cnt="http://openoffice.org/2007/layout/container";>
++    <vbox>
++        <tabcontrol output-size="true" id="1">
++            <pagelist>
++                <pageitem identifier="TP_FIELDS" page-res-id="TP_FIELDS" text="Sort Criteria"/>
++                <pageitem identifier="TP_OPTIONS" page-res-id="TP_OPTIONS" text="Options"/>
++            </pagelist>
++        </tabcontrol>
++        <hbox>
++            <okbutton id="1" tab-stop="true"/>
++            <cancelbutton id="1" tab-stop="true"/>
++            <helpbutton id="1" tab-stop="true"/>
++            <pushbutton id="1" tab-stop="true"/>
++        </hbox>
++    </vbox>
++</tabdialog>
+diff --git a/workben/layout/test.cxx b/workben/layout/test.cxx
+index 4049e60..2b7e1c3 100644
+--- toolkit/workben/layout/test.cxx
++++ toolkit/workben/layout/test.cxx
+@@ -53,20 +53,29 @@
+ #include <comphelper/processfactory.hxx>
+ #include <com/sun/star/xml/sax/SAXException.hpp>
+ 
++#include "dbcolect.hxx"
++#include <sfx2/shell.hxx>
++
++#include "scitems.hxx"
++#include "uiitems.hxx"
++
+ #include "editor.hxx"
+ 
+-#include "wordcountdialog.hxx"
++#include "plugin.hxx"
+ #undef _LAYOUT_POST_HXX
+-#include "zoom.hxx"
++
++#include "recover.hxx"
+ #undef _LAYOUT_POST_HXX
+ 
+-#include "plugin.hxx"
++//#include "sortdlg.hxx"
+ #undef _LAYOUT_POST_HXX
+ 
+-#include "recover.hxx"
++#include "wordcountdialog.hxx"
++#undef _LAYOUT_POST_HXX
++
++#include "zoom.hxx"
+ #undef _LAYOUT_POST_HXX
+ 
+-//#undef SW_WORDCOUNTDIALOG_HXX
+ #include <layout/layout-pre.hxx>
+ 
+ using namespace ::rtl;
+@@ -81,16 +90,34 @@ Reference< XComponentContext > createInitialComponentContext(
+     
+     try
+     {
++        OUString base = OUString::createFromAscii( SAL_CONFIGFILE( "uno" ) );
++            
++#if RSCVERSION < 300
++        OUString file_name = inst_dir 
++            + OUString::createFromAscii( "/program/" )
++            + base;
++#else
++        OUString file_name = inst_dir 
++            + OUString::createFromAscii( "/openoffice.org/basis3.0/program/" )
++            + base;
++#endif
++        if ( FILE* f = fopen( OUSTRING_CSTR( file_name ), "r" ) )
++        {
++            printf( "found %s: %s\n", OUSTRING_CSTR( base ),
++                    OUSTRING_CSTR( file_name ) );
++            fclose( f );
++        }
++        else
++            printf( "%s not found, no such file: %s\n",
++                    OUSTRING_CSTR( base ), OUSTRING_CSTR( file_name ) );
++        
+         OUString file_url;
+-        oslFileError rc = osl_getFileURLFromSystemPath(
+-            inst_dir.pData, &file_url.pData );
++        oslFileError rc = osl_getFileURLFromSystemPath( file_name.pData,
++                                                        &file_url.pData );
+         OSL_ASSERT( osl_File_E_None == rc );
+-        (void) rc;  // quiet warning
+-        
+-        OUString unorc = file_url + OUString(
+-            OUString::createFromAscii( "/program/" SAL_CONFIGFILE( "uno" )) );
++        ( void ) rc;
+         
+-        return defaultBootstrap_InitialComponentContext( unorc );
++        return defaultBootstrap_InitialComponentContext( file_url );
+     }
+     
+     catch( Exception& rExc )
+@@ -161,29 +188,75 @@ void LayoutTest::LoadFile( const OUString &aTestFile )
+     fprintf( stderr, "TEST: file loaded\n" );
+ }
+ 
++#include <vos/process.hxx>
++#include <rtl/ustrbuf.hxx>
++
+ // Nurgh ...
+ void LayoutTest::InitUCB()
+ {
++#if  RSCVERSION < 300
+     OUString aEmpty;
+-    Sequence< Any > aArgs(6);
++    Sequence< Any > aArgs( 6 );
+     aArgs[0]
+-        <<= OUString::createFromAscii(UCB_CONFIGURATION_KEY1_LOCAL);
++        <<= OUString::createFromAscii( UCB_CONFIGURATION_KEY1_LOCAL );
+     aArgs[1]
+-        <<= OUString::createFromAscii(UCB_CONFIGURATION_KEY2_OFFICE);
++        <<= OUString::createFromAscii( UCB_CONFIGURATION_KEY2_OFFICE );
+     aArgs[2] <<= OUString::createFromAscii( "PIPE" );
+     aArgs[3] <<= aEmpty;
+     aArgs[4] <<= OUString::createFromAscii( "PORTAL" );
+     aArgs[5] <<= aEmpty;
+ 
+-    if (! ::ucbhelper::ContentBroker::initialize( mxMSF, aArgs ) )
++    if ( !::ucbhelper::ContentBroker::initialize( mxMSF, aArgs ) )
++    {
++        fprintf( stderr, "Failed to init content broker\n" );
++        fprintf( stderr, "arg[0]: %s\n", UCB_CONFIGURATION_KEY1_LOCAL );
++        fprintf( stderr, "arg[1]: %s\n", UCB_CONFIGURATION_KEY2_OFFICE );
++    }
++#else
++    OUString rPortalConnect;
++    bool bServer = false;
++
++
++
++    OUString aPipe = OUString::createFromAscii( "1000" );
++    vos::OSecurity().getUserIdent( aPipe );
++ 
++    OUStringBuffer aPortal;
++    if ( rPortalConnect.getLength() != 0 )
++    {
++        aPortal.append( sal_Unicode( ',' ) );
++        aPortal.append( rPortalConnect );
++    }
++
++    Sequence< Any > aArgs(6);
++    aArgs[0]
++        <<= rtl::OUString::createFromAscii( bServer
++                                            ? UCB_CONFIGURATION_KEY1_SERVER
++                                            : UCB_CONFIGURATION_KEY1_LOCAL);
++    aArgs[1]
++        <<= rtl::OUString::createFromAscii(UCB_CONFIGURATION_KEY2_OFFICE);
++    aArgs[2] <<= rtl::OUString::createFromAscii("PIPE");
++    aArgs[3] <<= aPipe;
++    aArgs[4] <<= rtl::OUString::createFromAscii("PORTAL");
++    aArgs[5] <<= aPortal.makeStringAndClear();
++    
++    if ( !::ucbhelper::ContentBroker::initialize( mxMSF, aArgs ) )
++    {
+         fprintf( stderr, "Failed to init content broker\n" );
++        //fprintf( stderr, "arg[0]: %s\n", OUSTRING_CSTR( aArgs[0].get<OUString> ) );
++        //fprintf( stderr, "arg[1]: %s\n", OUSTRING_CSTR( OUString( aArgs[0] ) );
++    }
++#endif
+ }
+ 
++#if RSCVERSION < 300
++
+ #define INIT_ENV_VOODOO( installDir )                                   \
+     /* Unless you do this, obviously you don't deserve to have anything work */ \
+     OString aCfg = "CFG_INIFILE=file://"                                \
+                  + OUStringToOString( installDir, RTL_TEXTENCODING_UTF8 ) \
+-                 + "/program/configmgrrc";                              \
++                 + "/program/"                                          \
++                 + SAL_CONFIGFILE( "configmgr" );                       \
+     putenv( (char *)aCfg.getStr() );                                    \
+     /* Unless you do this, obviously you don't want your paths to be correct & \
+        hence no images.zip location is possible. */                     \
+@@ -191,6 +264,25 @@ void LayoutTest::InitUCB()
+                  + OUStringToOString( installDir, RTL_TEXTENCODING_UTF8 ); \
+     putenv( (char *)aBaseInst.getStr() );                               \
+ 
++#else
++
++#define INIT_ENV_VOODOO( installDir )                                   \
++    /* Unless you do this, obviously you don't deserve to have anything work */ \
++    OString aCfg = "CFG_INIFILE=file://"                                \
++                 + OUStringToOString( installDir, RTL_TEXTENCODING_UTF8 ) \
++                 + "/openoffice.org/basis3.0/program/"                  \
++                 + SAL_CONFIGFILE( "configmgr" );                       \
++    putenv( (char *)aCfg.getStr() );                                    \
++    /* Unless you do this, obviously you don't want your paths to be correct & \
++       hence no images.zip location is possible. */                     \
++    OString aBaseInst = "BaseInstallation=file://"                      \
++                 + OUStringToOString( installDir, RTL_TEXTENCODING_UTF8 ); \
++    putenv( (char *)aBaseInst.getStr() );                               \
++
++//                 + "/openoffice.org/basis3.0";                          \
++
++#endif
++
+ void LayoutTest::IInit()
+ {
+     INIT_ENV_VOODOO( mInstallDir );
+@@ -249,18 +341,48 @@ void RunDialog( Dialog& dialog )
+     fprintf( stderr, "2nd execute exited" );
+ }
+ 
+-void TestDialog( OUString const& name )
++#undef Dialog
++void RunDialog( ::Dialog& dialog )
+ {
+-    if ( name.equalsAscii( "zoom" ) )
+-    {
+-        SvxZoomDialog zoom( 0 );
+-        RunDialog( zoom );
+-    }
+-    else if ( name.equalsAscii( "wordcount" ) )
++    dialog.Show();
++    dialog.Execute();
++    fprintf( stderr, "1st execute exited" );
++    dialog.Execute();
++    fprintf( stderr, "2nd execute exited" );
++}
++
++#include <sfx2/sfxuno.hxx>
++static void get_factory( char const *service )
++{
++    uno::Reference< lang::XSingleServiceFactory > xFactory(
++        comphelper::createProcessComponent(
++            rtl::OUString::createFromAscii( service ) ), uno::UNO_QUERY );
++
++    if ( !xFactory.is() )
+     {
+-        SwWordCountDialog words ( 0 );
+-        RunDialog( words );
++        fprintf( stderr, "error loading: %s\n", service );
++#if 0
++        throw uno::RuntimeException(
++            rtl::OUString::createFromAscii( "error loading service: " )
++            + rtl::OUString::createFromAscii( service ) ),
++            uno::Reference< uno::XInterface >() );
++#endif
+     }
++}
++
++#define GET_FACTORY(x) get_factory( #x )
++    
++static void LoadSC()
++{
++    get_factory( "com.sun.star.comp.sfx2.DocumentTemplates" );
++    get_factory( "com.sun.star.comp.Calc.SpreadsheetDocument" );
++    GET_FACTORY( com.sun.star.i18n.Transliteration.l10n );
++}
++
++void TestDialog( OUString const& name )
++{
++    if ( 0 )
++        ;
+     else if ( name.equalsAscii( "plugin" ) )
+     {
+         PluginDialog plugin ( 0 );
+@@ -271,6 +393,24 @@ void TestDialog( OUString const& name )
+         SvxRecoverDialog recover ( 0 );
+         RunDialog( recover );
+     }
++#if 0
++    else if ( name.equalsAscii( "sort" ) )
++    {
++        LoadSC();
++        ScSortDlg sort ( 0, 0 );
++        RunDialog( sort );
++    }
++#endif
++    else if ( name.equalsAscii( "wordcount" ) )
++    {
++        SwWordCountDialog words ( 0 );
++        RunDialog( words );
++    }
++    else if ( name.equalsAscii( "zoom" ) )
++    {
++        SvxZoomDialog zoom( 0 );
++        RunDialog( zoom );
++    }
+ }
+ 
+ void LayoutTest::RunFiles()
+diff --git a/workben/layout/tpsort.cxx b/workben/layout/tpsort.cxx
+new file mode 100644
+index 0000000..9b669da
+--- /dev/null
++++ toolkit/workben/layout/tpsort.cxx
+@@ -0,0 +1,1113 @@
++/*************************************************************************
++ *
++ *  OpenOffice.org - a multi-platform office productivity suite
++ *
++ *  $RCSfile: tpsort.cxx,v $
++ *
++ *  $Revision: 1.12 $
++ *
++ *  last change: $Author: vg $ $Date: 2007/02/27 13:05:23 $
++ *
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
++ *
++ *
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library 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 for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
++ *
++ ************************************************************************/
++
++#if !TEST_LAYOUT
++// MARKER(update_precomp.py): autogen include statement, do not remove
++#include "precompiled_sc.hxx"
++#endif /*! TEST_LAYOUT */
++
++#undef SC_DLLIMPLEMENTATION
++
++
++
++#include <vcl/msgbox.hxx>
++#include <i18npool/mslangid.hxx>
++#include <svtools/collatorres.hxx>
++#include <unotools/collatorwrapper.hxx>
++#include <unotools/localedatawrapper.hxx>
++#include <comphelper/processfactory.hxx>
++
++#include "scitems.hxx"
++#include "uiitems.hxx"
++#include "viewdata.hxx"
++#include "document.hxx"
++#include "global.hxx"
++#include "dbcolect.hxx"
++#include "userlist.hxx"
++#include "rangeutl.hxx"
++#include "scresid.hxx"
++#include "sc.hrc"       // -> Slot IDs
++#include "globstr.hrc"
++
++#include "sortdlg.hxx"
++#include "sortdlg.hrc"
++
++#define _TPSORT_CXX
++#include "tpsort.hxx"
++#undef _TPSORT_CXX
++
++using namespace com::sun::star;
++
++// STATIC DATA -----------------------------------------------------------
++
++static USHORT pSortRanges[] =
++{
++	SID_SORT,
++	SID_SORT,
++	0
++};
++
++// -----------------------------------------------------------------------
++
++/*
++ * Da sich Einstellungen auf der zweiten TabPage (Optionen) auf
++ * die erste TabPage auswirken, muss es die Moeglichkeit geben,
++ * dies der jeweils anderen Seite mitzuteilen.
++ *
++ * Im Moment wird dieses Problem ueber zwei Datenmember des TabDialoges
++ * geloest. Wird eine Seite Aktiviert/Deaktiviert, so gleicht sie diese
++ * Datenmember mit dem eigenen Zustand ab (->Activate()/Deactivate()).
++ *
++ * 31.01.95:
++ * Die Klasse SfxTabPage bietet mittlerweile ein Verfahren an:
++ *
++ * virtual BOOL HasExchangeSupport() const; -> return TRUE;
++ * virtual void ActivatePage(const SfxItemSet &);
++ * virtual int	DeactivatePage(SfxItemSet * = 0);
++ *
++ * muss noch geaendert werden!
++ */
++
++//========================================================================
++//========================================================================
++// Sortierkriterien-Tabpage:
++
++ScTabPageSortFields::ScTabPageSortFields( Window*			pParent,
++										  const SfxItemSet& rArgSet )
++
++	:	SfxTabPage		( pParent,
++						  ScResId( RID_SCPAGE_SORT_FIELDS ),
++						  rArgSet ),
++		//
++        aFlSort1        ( this, ScResId( FL_SORT1  ) ),
++		aLbSort1		( this, ScResId( LB_SORT1  ) ),
++        aBtnUp1         ( this, ScResId( BTN_UP1   ) ),
++		aBtnDown1		( this, ScResId( BTN_DOWN1 ) ),
++		//
++        aFlSort2        ( this, ScResId( FL_SORT2  ) ),
++		aLbSort2		( this, ScResId( LB_SORT2  ) ),
++        aBtnUp2         ( this, ScResId( BTN_UP2   ) ),
++		aBtnDown2		( this, ScResId( BTN_DOWN2 ) ),
++		//
++        aFlSort3        ( this, ScResId( FL_SORT3  ) ),
++		aLbSort3		( this, ScResId( LB_SORT3  ) ),
++        aBtnUp3         ( this, ScResId( BTN_UP3   ) ),
++		aBtnDown3		( this, ScResId( BTN_DOWN3 ) ),
++		aStrUndefined	( ScResId( SCSTR_UNDEFINED ) ),
++		aStrColumn		( ScResId( SCSTR_COLUMN ) ),
++		aStrRow 		( ScResId( SCSTR_ROW ) ),
++		//
++#if !TEST_LAYOUT
++		nWhichSort		( rArgSet.GetPool()->GetWhich( SID_SORT ) ),
++#else /* TEST_LAYOUT */
++		nWhichSort		( 0 ),
++#endif /* TEST_LAYOUT */
++		pDlg			( (ScSortDlg*)(GetParent()->GetParent()) ),
++		pViewData		( NULL ),
++#if !TEST_LAYOUT
++		rSortData		( ((const ScSortItem&)
++						   rArgSet.Get( nWhichSort )).
++								GetSortData() ),
++#else /* TEST_LAYOUT */
++		rSortData		( *new ScSortParam() ),
++#endif /* TEST_LAYOUT */
++
++		nFieldCount 	( 0 ),
++		bHasHeader		( FALSE ),
++		bSortByRows 	( FALSE )
++{
++	Init();
++	FreeResource();
++	SetExchangeSupport();
++}
++
++// -----------------------------------------------------------------------
++
++__EXPORT ScTabPageSortFields::~ScTabPageSortFields()
++{
++}
++
++// -----------------------------------------------------------------------
++
++void ScTabPageSortFields::Init()
++{
++#if !TEST_LAYOUT
++	const ScSortItem& rSortItem = (const ScSortItem&)
++								  GetItemSet().Get( nWhichSort );
++
++	pViewData = rSortItem.GetViewData();
++
++	DBG_ASSERT( pViewData, "ViewData not found!" );
++#endif /* !TEST_LAYOUT */
++
++	nFieldArr[0] = 0;
++    nFirstCol = 0;
++    nFirstRow = 0;
++
++	aLbSort1.SetSelectHdl( LINK( this, ScTabPageSortFields, SelectHdl ) );
++	aLbSort2.SetSelectHdl( LINK( this, ScTabPageSortFields, SelectHdl ) );
++	aLbSort3.SetSelectHdl( LINK( this, ScTabPageSortFields, SelectHdl ) );
++	aLbSort1.Clear();
++	aLbSort2.Clear();
++	aLbSort3.Clear();
++
++	aSortLbArr[0]		= &aLbSort1;
++	aSortLbArr[1]		= &aLbSort2;
++	aSortLbArr[2]		= &aLbSort3;
++	aDirBtnArr[0][0]	= &aBtnUp1;
++	aDirBtnArr[0][1]	= &aBtnDown1;
++	aDirBtnArr[1][0]	= &aBtnUp2;
++	aDirBtnArr[1][1]	= &aBtnDown2;
++	aDirBtnArr[2][0]	= &aBtnUp3;
++	aDirBtnArr[2][1]	= &aBtnDown3;
++    aFlArr[0]           = &aFlSort1;
++    aFlArr[1]           = &aFlSort2;
++    aFlArr[2]           = &aFlSort3;
++}
++
++//------------------------------------------------------------------------
++
++USHORT* __EXPORT ScTabPageSortFields::GetRanges()
++{
++	return pSortRanges;
++}
++
++// -----------------------------------------------------------------------
++
++SfxTabPage* __EXPORT ScTabPageSortFields::Create( Window*	pParent,
++										 const SfxItemSet&	rArgSet )
++{
++	return ( new ScTabPageSortFields( pParent, rArgSet ) );
++}
++
++// -----------------------------------------------------------------------
++
++void __EXPORT ScTabPageSortFields::Reset( const SfxItemSet& /* rArgSet */ )
++{
++	bSortByRows = rSortData.bByRow;
++	bHasHeader	= rSortData.bHasHeader;
++
++	if ( aLbSort1.GetEntryCount() == 0 )
++		FillFieldLists();
++
++	// Selektieren der ListBoxen:
++
++	if ( rSortData.bDoSort[0] )
++	{
++		for ( USHORT i=0; i<3; i++ )
++		{
++			if ( rSortData.bDoSort[i] )
++			{
++				aSortLbArr[i]->SelectEntryPos(
++					 GetFieldSelPos( rSortData.nField[i] ) );
++
++				(rSortData.bAscending[i])
++					? aDirBtnArr[i][0]->Check() 	// Up
++					: aDirBtnArr[i][1]->Check();	// Down
++			}
++			else
++			{
++				aSortLbArr[i]->SelectEntryPos( 0 ); // "keiner" selektieren
++				aDirBtnArr[i][0]->Check();			// Up
++			}
++		}
++
++		EnableField( 1 );
++		EnableField( 2 );
++		EnableField( 3 );
++		if ( aLbSort1.GetSelectEntryPos() == 0 )
++			DisableField( 2 );
++		if ( aLbSort2.GetSelectEntryPos() == 0 )
++			DisableField( 3 );
++	}
++	else
++	{
++		aLbSort1.SelectEntryPos( 1 );
++		aLbSort2.SelectEntryPos( 0 );
++		aLbSort3.SelectEntryPos( 0 );
++		aBtnUp1.Check();
++		aBtnUp2.Check();
++		aBtnUp3.Check();
++		EnableField ( 1 );
++		EnableField ( 2 );
++		DisableField( 3 );
++	}
++
++	if ( pDlg )
++	{
++		pDlg->SetByRows ( bSortByRows );
++		pDlg->SetHeaders( bHasHeader );
++	}
++}
++
++// -----------------------------------------------------------------------
++
++BOOL __EXPORT ScTabPageSortFields::FillItemSet( SfxItemSet& rArgSet )
++{
++	ScSortParam theSortData = rSortData;
++	if (pDlg)
++	{
++		const SfxItemSet* pExample = pDlg->GetExampleSet();
++		const SfxPoolItem* pItem;
++		if ( pExample && pExample->GetItemState( nWhichSort, TRUE, &pItem ) == SFX_ITEM_SET )
++			theSortData = ((const ScSortItem*)pItem)->GetSortData();
++	}
++
++	USHORT	nSort1Pos = aLbSort1.GetSelectEntryPos();
++	USHORT	nSort2Pos = aLbSort2.GetSelectEntryPos();
++	USHORT	nSort3Pos = aLbSort3.GetSelectEntryPos();
++
++	DBG_ASSERT(    (nSort1Pos <= SC_MAXFIELDS)
++				&& (nSort2Pos <= SC_MAXFIELDS)
++				&& (nSort3Pos <= SC_MAXFIELDS),
++				"Array-Range Fehler!" );
++
++	if ( nSort1Pos == LISTBOX_ENTRY_NOTFOUND ) nSort1Pos = 0;
++	if ( nSort2Pos == LISTBOX_ENTRY_NOTFOUND ) nSort2Pos = 0;
++	if ( nSort3Pos == LISTBOX_ENTRY_NOTFOUND ) nSort3Pos = 0;
++
++	if ( nSort1Pos > 0 )
++	{
++		theSortData.bDoSort[0] = (nSort1Pos > 0);
++		theSortData.bDoSort[1] = (nSort2Pos > 0);
++		theSortData.bDoSort[2] = (nSort3Pos > 0);
++
++		// wenn auf Optionen-Seite "OK" gewaehlt wurde und
++		// dabei die Sortierrichtung umgestellt wurde, so
++		// wird das erste Feld der jeweiligen Richtung als
++		// Sortierkriterium gewaehlt (steht in nFieldArr[0]):
++		if ( bSortByRows != pDlg->GetByRows() )
++		{
++			theSortData.nField[0] =
++			theSortData.nField[1] =
++            theSortData.nField[2] = ( bSortByRows ?
++                    static_cast<SCCOLROW>(nFirstRow) :
++                    static_cast<SCCOLROW>(nFirstCol) );
++		}
++		else
++		{
++			theSortData.nField[0] = nFieldArr[nSort1Pos];
++			theSortData.nField[1] = nFieldArr[nSort2Pos];
++			theSortData.nField[2] = nFieldArr[nSort3Pos];
++		}
++
++		theSortData.bAscending[0] = aBtnUp1.IsChecked();
++		theSortData.bAscending[1] = aBtnUp2.IsChecked();
++		theSortData.bAscending[2] = aBtnUp3.IsChecked();
++		//	bHasHeader ist in ScTabPageSortOptions::FillItemSet, wo es hingehoert
++	}
++	else
++	{
++		theSortData.bDoSort[0] =
++		theSortData.bDoSort[1] =
++		theSortData.bDoSort[2] = FALSE;
++	}
++
++	rArgSet.Put( ScSortItem( SCITEM_SORTDATA, NULL, &theSortData ) );
++
++	return TRUE;
++}
++
++// -----------------------------------------------------------------------
++
++// fuer Datenaustausch ohne Dialog-Umweg: (! noch zu tun !)
++// void ScTabPageSortFields::ActivatePage( const SfxItemSet& rSet )
++
++void __EXPORT ScTabPageSortFields::ActivatePage()
++{
++	if ( pDlg )
++	{
++		if (   bHasHeader  != pDlg->GetHeaders()
++			|| bSortByRows != pDlg->GetByRows()   )
++		{
++			USHORT	nCurSel1 = aLbSort1.GetSelectEntryPos();
++			USHORT	nCurSel2 = aLbSort2.GetSelectEntryPos();
++			USHORT	nCurSel3 = aLbSort3.GetSelectEntryPos();
++
++			bHasHeader	= pDlg->GetHeaders();
++			bSortByRows = pDlg->GetByRows();
++			FillFieldLists();
++			aLbSort1.SelectEntryPos( nCurSel1 );
++			aLbSort2.SelectEntryPos( nCurSel2 );
++			aLbSort3.SelectEntryPos( nCurSel3 );
++		}
++	}
++}
++
++// -----------------------------------------------------------------------
++
++int __EXPORT ScTabPageSortFields::DeactivatePage( SfxItemSet* pSetP )
++{
++	if ( pDlg )
++	{
++		if ( bHasHeader != pDlg->GetHeaders() )
++			pDlg->SetHeaders( bHasHeader );
++
++		if ( bSortByRows != pDlg->GetByRows() )
++			pDlg->SetByRows( bSortByRows );
++	}
++
++    if ( pSetP )
++        FillItemSet( *pSetP );
++
++	return SfxTabPage::LEAVE_PAGE;
++}
++
++// -----------------------------------------------------------------------
++
++void ScTabPageSortFields::DisableField( USHORT nField )
++{
++	nField--;
++
++    if ( nField<=2 )
++	{
++		aSortLbArr[nField]	 ->Disable();
++		aDirBtnArr[nField][0]->Disable();
++		aDirBtnArr[nField][1]->Disable();
++        aFlArr[nField]       ->Disable();
++	}
++}
++
++// -----------------------------------------------------------------------
++
++void ScTabPageSortFields::EnableField( USHORT nField )
++{
++	nField--;
++
++    if ( nField<=2 )
++	{
++		aSortLbArr[nField]	 ->Enable();
++		aDirBtnArr[nField][0]->Enable();
++		aDirBtnArr[nField][1]->Enable();
++        aFlArr[nField]       ->Enable();
++	}
++}
++
++// -----------------------------------------------------------------------
++
++void ScTabPageSortFields::FillFieldLists()
++{
++	if ( pViewData )
++	{
++		ScDocument* pDoc = pViewData->GetDocument();
++
++		if ( pDoc )
++		{
++			aLbSort1.Clear();
++			aLbSort2.Clear();
++			aLbSort3.Clear();
++			aLbSort1.InsertEntry( aStrUndefined, 0 );
++			aLbSort2.InsertEntry( aStrUndefined, 0 );
++			aLbSort3.InsertEntry( aStrUndefined, 0 );
++
++			SCCOL	nFirstSortCol	= rSortData.nCol1;
++			SCROW	nFirstSortRow	= rSortData.nRow1;
++			SCTAB	nTab		= pViewData->GetTabNo();
++			USHORT	i			= 1;
++
++			if ( bSortByRows )
++			{
++				String	aFieldName;
++				SCCOL	nMaxCol = rSortData.nCol2;
++				SCCOL	col;
++
++				for ( col=nFirstSortCol; col<=nMaxCol && i<SC_MAXFIELDS; col++ )
++				{
++					pDoc->GetString( col, nFirstSortRow, nTab, aFieldName );
++					if ( !bHasHeader || (aFieldName.Len() == 0) )
++					{
++						aFieldName	= aStrColumn;
++						aFieldName += ' ';
++						aFieldName += ColToAlpha( col );
++					}
++					nFieldArr[i] = col;
++					aLbSort1.InsertEntry( aFieldName, i );
++					aLbSort2.InsertEntry( aFieldName, i );
++					aLbSort3.InsertEntry( aFieldName, i );
++					i++;
++				}
++			}
++			else
++			{
++				String	aFieldName;
++				SCROW	nMaxRow = rSortData.nRow2;
++				SCROW	row;
++
++				for ( row=nFirstSortRow; row<=nMaxRow && i<SC_MAXFIELDS; row++ )
++				{
++					pDoc->GetString( nFirstSortCol, row, nTab, aFieldName );
++					if ( !bHasHeader || (aFieldName.Len() == 0) )
++					{
++						aFieldName	= aStrRow;
++						aFieldName += ' ';
++						aFieldName += String::CreateFromInt32( row+1 );
++					}
++					nFieldArr[i] = row;
++					aLbSort1.InsertEntry( aFieldName, i );
++					aLbSort2.InsertEntry( aFieldName, i );
++					aLbSort3.InsertEntry( aFieldName, i );
++					i++;
++				}
++			}
++			nFieldCount = i;
++		}
++	}
++}
++
++//------------------------------------------------------------------------
++
++USHORT ScTabPageSortFields::GetFieldSelPos( SCCOLROW nField )
++{
++	USHORT	nFieldPos	= 0;
++	BOOL	bFound		= FALSE;
++
++	for ( USHORT n=1; n<nFieldCount && !bFound; n++ )
++	{
++		if ( nFieldArr[n] == nField )
++		{
++			nFieldPos = n;
++			bFound = TRUE;
++		}
++	}
++
++	return nFieldPos;
++}
++
++// -----------------------------------------------------------------------
++// Handler:
++//---------
++
++IMPL_LINK( ScTabPageSortFields, SelectHdl, ListBox *, pLb )
++{
++	String aSelEntry = pLb->GetSelectEntry();
++
++	if ( pLb == &aLbSort1 )
++	{
++		if ( aSelEntry == aStrUndefined )
++		{
++			aLbSort2.SelectEntryPos( 0 );
++			aLbSort3.SelectEntryPos( 0 );
++
++            if ( aFlSort2.IsEnabled() )
++				DisableField( 2 );
++
++            if ( aFlSort3.IsEnabled() )
++				DisableField( 3 );
++		}
++		else
++		{
++            if ( !aFlSort2.IsEnabled() )
++				EnableField( 2 );
++		}
++	}
++	else if ( pLb == &aLbSort2 )
++	{
++		if ( aSelEntry == aStrUndefined )
++		{
++			aLbSort3.SelectEntryPos( 0 );
++            if ( aFlSort3.IsEnabled() )
++				DisableField( 3 );
++		}
++		else
++		{
++            if ( !aFlSort3.IsEnabled() )
++				EnableField( 3 );
++		}
++	}
++
++	return 0;
++}
++
++//========================================================================
++// Sortieroptionen-Tabpage:
++//========================================================================
++
++#include <layout/layout-pre.hxx>
++
++#if ENABLE_LAYOUT
++#undef ScResId
++#define ScResId(x) #x
++#undef SfxTabPage
++#define SfxTabPage( parent, id, args ) TabPage( parent, "sort-options.xml", id )
++#endif /* ENABLE_LAYOUT */
++
++ScTabPageSortOptions::ScTabPageSortOptions( Window* 			pParent,
++											const SfxItemSet&	rArgSet )
++
++	:	SfxTabPage		( pParent,
++						  ScResId( RID_SCPAGE_SORT_OPTIONS ),
++						  rArgSet ),
++		//
++		aBtnCase		( this, ScResId( BTN_CASESENSITIVE ) ),
++		aBtnHeader		( this, ScResId( BTN_LABEL ) ),
++		aBtnFormats 	( this, ScResId( BTN_FORMATS ) ),
++		aBtnCopyResult	( this, ScResId( BTN_COPYRESULT ) ),
++		aBtnNaturalSort	( this, ScResId( BTN_NATURALSORT ) ),
++		aLbOutPos		( this, ScResId( LB_OUTAREA ) ),
++		aEdOutPos		( this, ScResId( ED_OUTAREA ) ),
++		aBtnSortUser	( this, ScResId( BTN_SORT_USER ) ),
++		aLbSortUser 	( this, ScResId( LB_SORT_USER ) ),
++        aFtLanguage     ( this, ScResId( FT_LANGUAGE ) ),
++		aLbLanguage		( this, ScResId( LB_LANGUAGE ) ),
++        aFtAlgorithm    ( this, ScResId( FT_ALGORITHM ) ),
++		aLbAlgorithm	( this, ScResId( LB_ALGORITHM ) ),
++		aLineDirection	( this, ScResId( FL_DIRECTION ) ),
++		aBtnTopDown 	( this, ScResId( BTN_TOP_DOWN ) ),
++		aBtnLeftRight	( this, ScResId( BTN_LEFT_RIGHT ) ),
++// 		aFtAreaLabel	( this, ScResId( FT_AREA_LABEL ) ),
++//		aFtArea 		( this, ScResId( FT_AREA ) ),
++		//
++#undef ScResId
++		aStrRowLabel	( ScResId( STR_ROW_LABEL ) ),
++		aStrColLabel	( ScResId( STR_COL_LABEL ) ),
++		aStrUndefined	( ScResId( SCSTR_UNDEFINED ) ),
++		aStrNoName		( ScGlobal::GetRscString(STR_DB_NONAME) ),
++		//
++#if !TEST_LAYOUT
++		nWhichSort		( rArgSet.GetPool()->GetWhich( SID_SORT ) ),
++		rSortData		( ((const ScSortItem&)
++						  rArgSet.Get( nWhichSort )).GetSortData() ),
++#else /* TEST_LAYOUT */
++		nWhichSort		( 0 ),
++		rSortData		( *new ScSortParam() ),
++#endif /* TEST_LAYOUT */
++		pViewData		( NULL ),
++		pDoc			( NULL ),
++		pDlg			( (ScSortDlg*)(GetParent() ? GetParent()->GetParent() : 0 ) ),
++		pColRes			( NULL ),
++		pColWrap		( NULL )
++{
++#if TEST_LAYOUT
++    (void) rArgSet;
++#endif /* TEST_LAYOUT */
++	Init();
++	FreeResource();
++	SetExchangeSupport();
++}
++
++// -----------------------------------------------------------------------
++
++__EXPORT ScTabPageSortOptions::~ScTabPageSortOptions()
++{
++#if !ENABLE_LAYOUT
++	USHORT nEntries = aLbOutPos.GetEntryCount();
++
++	for ( USHORT i=1; i<nEntries; i++ )
++		delete (String*)aLbOutPos.GetEntryData( i );
++#endif /* !ENABLE_LAYOUT */
++
++	delete pColRes;
++	delete pColWrap;		//! not if from document
++}
++
++// -----------------------------------------------------------------------
++
++void ScTabPageSortOptions::Init()
++{
++// 	aStrAreaLabel = aFtAreaLabel.GetText();
++// 	aStrAreaLabel.Append( (sal_Unicode) ' ' );
++
++	//	CollatorRessource has user-visible names for sort algorithms
++	pColRes = new CollatorRessource();
++
++	//!	use CollatorWrapper from document?
++	pColWrap = new CollatorWrapper( comphelper::getProcessServiceFactory() );
++
++#if !ENABLE_LAYOUT
++	const ScSortItem&	rSortItem = (const ScSortItem&)
++									GetItemSet().Get( nWhichSort );
++#endif /* !ENABLE_LAYOUT */
++
++	aLbOutPos.SetSelectHdl	  ( LINK( this, ScTabPageSortOptions, SelOutPosHdl ) );
++	aBtnCopyResult.SetClickHdl( LINK( this, ScTabPageSortOptions, EnableHdl ) );
++	aBtnSortUser.SetClickHdl  ( LINK( this, ScTabPageSortOptions, EnableHdl ) );
++	aBtnTopDown.SetClickHdl	  ( LINK( this, ScTabPageSortOptions, SortDirHdl ) );
++	aBtnLeftRight.SetClickHdl ( LINK( this, ScTabPageSortOptions, SortDirHdl ) );
++	aLbLanguage.SetSelectHdl  ( LINK( this, ScTabPageSortOptions, FillAlgorHdl ) );
++
++#if !ENABLE_LAYOUT
++	pViewData = rSortItem.GetViewData();
++#endif /* ENABLE_LAYOUT */
++	pDoc	  = pViewData ? pViewData->GetDocument() : NULL;
++
++	DBG_ASSERT( pViewData, "ViewData not found! :-/" );
++
++	if ( pViewData && pDoc )
++	{
++		String			theArea;
++		ScDBCollection* pDBColl 	= pDoc->GetDBCollection();
++		String			theDbArea;
++		String			theDbName	= aStrNoName;
++		const SCTAB	nCurTab		= pViewData->GetTabNo();
++        const ScAddress::Convention eConv = pDoc->GetAddressConvention();
++
++		aLbOutPos.Clear();
++		aLbOutPos.InsertEntry( aStrUndefined, 0 );
++		aLbOutPos.Disable();
++
++		ScAreaNameIterator aIter( pDoc );
++		String aName;
++		ScRange aRange;
++		String aRefStr;
++		while ( aIter.Next( aName, aRange ) )
++		{
++			USHORT nInsert = aLbOutPos.InsertEntry( aName );
++
++			aRange.aStart.Format( aRefStr, SCA_ABS_3D, pDoc, eConv );
++			aLbOutPos.SetEntryData( nInsert, new String( aRefStr ) );
++		}
++
++		aLbOutPos.SelectEntryPos( 0 );
++		aEdOutPos.SetText( EMPTY_STRING );
++
++		/*
++		 * Ueberpruefen, ob es sich bei dem uebergebenen
++		 * Bereich um einen Datenbankbereich handelt:
++		 */
++
++#if 1//!TEST_LAYOUT
++		ScAddress aScAddress( rSortData.nCol1, rSortData.nRow1, nCurTab );
++		ScRange( aScAddress,
++				 ScAddress( rSortData.nCol2, rSortData.nRow2, nCurTab )
++			   ).Format( theArea, SCR_ABS, pDoc, eConv );
++		if ( pDBColl )
++		{
++			ScDBData* pDBData
++					= pDBColl->GetDBAtArea( nCurTab,
++											rSortData.nCol1, rSortData.nRow1,
++											rSortData.nCol2, rSortData.nRow2 );
++			if ( pDBData )
++			{
++				pDBData->GetName( theDbName );
++				aBtnHeader.Check( pDBData->HasHeader() );
++			}
++		}
++#endif /* !TEST_LAYOUT */
++
++		theArea.AppendAscii(RTL_CONSTASCII_STRINGPARAM(" ("));
++		theArea += theDbName;
++		theArea += ')';
++
++		//aFtArea.SetText( theArea );
++		//theArea.Insert( aStrAreaLabel, 0 );
++		//aFtAreaLabel.SetText( theArea );
++
++		aBtnHeader.SetText( aStrColLabel );
++	}
++
++	FillUserSortListBox();
++
++	//	get available languages
++
++    aLbLanguage.SetLanguageList( LANG_LIST_ALL | LANG_LIST_ONLY_KNOWN, FALSE );
++	aLbLanguage.InsertLanguage( LANGUAGE_SYSTEM );
++}
++
++//------------------------------------------------------------------------
++
++USHORT* __EXPORT ScTabPageSortOptions::GetRanges()
++{
++	return pSortRanges;
++}
++
++// -----------------------------------------------------------------------
++
++#if ENABLE_LAYOUT
++#undef SfxTabPage
++#define SfxTabPage TabPage
++#endif /* ENABLE_LAYOUT */
++SfxTabPage* __EXPORT ScTabPageSortOptions::Create(
++											Window*				pParent,
++											const SfxItemSet&	rArgSet )
++{
++	return ( new ScTabPageSortOptions( pParent, rArgSet ) );
++}
++
++// -----------------------------------------------------------------------
++
++void __EXPORT ScTabPageSortOptions::Reset( const SfxItemSet& /* rArgSet */ )
++{
++	if ( rSortData.bUserDef )
++	{
++		aBtnSortUser.Check( TRUE );
++		aLbSortUser.Enable();
++		aLbSortUser.SelectEntryPos( rSortData.nUserIndex );
++	}
++	else
++	{
++		aBtnSortUser.Check( FALSE );
++		aLbSortUser.Disable();
++		aLbSortUser.SelectEntryPos( 0 );
++	}
++
++	aBtnCase.Check			( rSortData.bCaseSens );
++	aBtnFormats.Check		( rSortData.bIncludePattern );
++	aBtnHeader.Check		( rSortData.bHasHeader );
++	aBtnNaturalSort.Check	( rSortData.bNaturalSort );
++
++	if ( rSortData.bByRow )
++	{
++		aBtnTopDown.Check();
++		aBtnHeader.SetText( aStrColLabel );
++	}
++	else
++	{
++		aBtnLeftRight.Check();
++		aBtnHeader.SetText( aStrRowLabel );
++	}
++
++	LanguageType eLang = MsLangId::convertLocaleToLanguage( rSortData.aCollatorLocale );
++	if ( eLang == LANGUAGE_DONTKNOW )
++		eLang = LANGUAGE_SYSTEM;
++	aLbLanguage.SelectLanguage( eLang );
++	FillAlgorHdl( &aLbLanguage );				// get algorithms, select default
++
++	if ( rSortData.aCollatorAlgorithm.Len() )
++		aLbAlgorithm.SelectEntry( pColRes->GetTranslation( rSortData.aCollatorAlgorithm ) );
++
++	if ( pDoc && !rSortData.bInplace )
++	{
++		String aStr;
++		USHORT nFormat = (rSortData.nDestTab != pViewData->GetTabNo())
++							? SCR_ABS_3D
++							: SCR_ABS;
++
++		theOutPos.Set( rSortData.nDestCol,
++					   rSortData.nDestRow,
++					   rSortData.nDestTab );
++
++		theOutPos.Format( aStr, nFormat, pDoc, pDoc->GetAddressConvention() );
++		aBtnCopyResult.Check();
++		aLbOutPos.Enable();
++		aEdOutPos.Enable();
++		aEdOutPos.SetText( aStr );
++		EdOutPosModHdl( &aEdOutPos );
++		aEdOutPos.GrabFocus();
++		aEdOutPos.SetSelection( Selection( 0, SELECTION_MAX ) );
++	}
++	else
++	{
++		aBtnCopyResult.Check( FALSE );
++		aLbOutPos.Disable();
++		aEdOutPos.Disable();
++		aEdOutPos.SetText( EMPTY_STRING );
++	}
++}
++
++// -----------------------------------------------------------------------
++
++BOOL __EXPORT ScTabPageSortOptions::FillItemSet( SfxItemSet& rArgSet )
++{
++	ScSortParam theSortData = rSortData;
++	if (pDlg)
++	{
++		const SfxItemSet* pExample = pDlg->GetExampleSet();
++		const SfxPoolItem* pItem;
++		if ( pExample && pExample->GetItemState( nWhichSort, TRUE, &pItem ) == SFX_ITEM_SET )
++			theSortData = ((const ScSortItem*)pItem)->GetSortData();
++	}
++
++	theSortData.bByRow			= aBtnTopDown.IsChecked();
++	theSortData.bHasHeader		= aBtnHeader.IsChecked();
++	theSortData.bCaseSens		= aBtnCase.IsChecked();
++	theSortData.bNaturalSort	= aBtnNaturalSort.IsChecked();
++	theSortData.bIncludePattern = aBtnFormats.IsChecked();
++	theSortData.bInplace		= !aBtnCopyResult.IsChecked();
++	theSortData.nDestCol		= theOutPos.Col();
++	theSortData.nDestRow		= theOutPos.Row();
++	theSortData.nDestTab		= theOutPos.Tab();
++	theSortData.bUserDef		= aBtnSortUser.IsChecked();
++	theSortData.nUserIndex		= (aBtnSortUser.IsChecked())
++									? aLbSortUser.GetSelectEntryPos()
++									: 0;
++
++	// get locale
++	LanguageType eLang = aLbLanguage.GetSelectLanguage();
++    theSortData.aCollatorLocale = MsLangId::convertLanguageToLocale( eLang, false );
++
++	// get algorithm
++	String sAlg;
++	if ( eLang != LANGUAGE_SYSTEM )
++	{
++        uno::Sequence<rtl::OUString> aAlgos = pColWrap->listCollatorAlgorithms(
++                theSortData.aCollatorLocale );
++		USHORT nSel = aLbAlgorithm.GetSelectEntryPos();
++		if ( nSel < aAlgos.getLength() )
++			sAlg = aAlgos[nSel];
++	}
++	theSortData.aCollatorAlgorithm = sAlg;
++
++	rArgSet.Put( ScSortItem( SCITEM_SORTDATA, &theSortData ) );
++
++	return TRUE;
++}
++
++// -----------------------------------------------------------------------
++
++// fuer Datenaustausch ohne Dialog-Umweg: (! noch zu tun !)
++// void ScTabPageSortOptions::ActivatePage( const SfxItemSet& rSet )
++void __EXPORT ScTabPageSortOptions::ActivatePage()
++{
++	if ( pDlg )
++	{
++		if ( aBtnHeader.IsChecked() != pDlg->GetHeaders() )
++		{
++			aBtnHeader.Check( pDlg->GetHeaders() );
++		}
++
++		if ( aBtnTopDown.IsChecked() != pDlg->GetByRows() )
++		{
++			aBtnTopDown.Check( pDlg->GetByRows() );
++			aBtnLeftRight.Check( !pDlg->GetByRows() );
++		}
++
++		aBtnHeader.SetText( (pDlg->GetByRows())
++							? aStrColLabel
++							: aStrRowLabel );
++	}
++}
++
++// -----------------------------------------------------------------------
++
++int __EXPORT ScTabPageSortOptions::DeactivatePage( SfxItemSet* pSetP )
++{
++    (void) pSetP;
++	BOOL bPosInputOk = TRUE;
++
++	if ( aBtnCopyResult.IsChecked() )
++	{
++		String		thePosStr = aEdOutPos.GetText();
++		ScAddress	thePos;
++		xub_StrLen	nColonPos = thePosStr.Search( ':' );
++
++		if ( STRING_NOTFOUND != nColonPos )
++			thePosStr.Erase( nColonPos );
++
++		if ( pViewData )
++		{
++			//	visible table is default for input without table
++			//	must be changed to GetRefTabNo when sorting has RefInput!
++			thePos.SetTab( pViewData->GetTabNo() );
++		}
++
++		USHORT nResult = thePos.Parse( thePosStr, pDoc, pDoc->GetAddressConvention() );
++
++		bPosInputOk = ( SCA_VALID == (nResult & SCA_VALID) );
++
++		if ( !bPosInputOk )
++		{
++#if !ENABLE_LAYOUT
++			ErrorBox( this, WinBits( WB_OK | WB_DEF_OK ),
++					 ScGlobal::GetRscString( STR_INVALID_TABREF )
++					).Execute();
++#endif /* ENABLE_LAYOUT */
++			aEdOutPos.GrabFocus();
++			aEdOutPos.SetSelection( Selection( 0, SELECTION_MAX ) );
++			theOutPos.Set(0,0,0);
++		}
++		else
++		{
++			aEdOutPos.SetText( thePosStr );
++			theOutPos = thePos;
++		}
++	}
++
++	if ( pDlg && bPosInputOk )
++	{
++		pDlg->SetHeaders( aBtnHeader.IsChecked() );
++		pDlg->SetByRows ( aBtnTopDown.IsChecked() );
++	}
++
++    if ( pSetP && bPosInputOk )
++        FillItemSet( *pSetP );
++
++	return bPosInputOk ? SfxTabPage::LEAVE_PAGE : SfxTabPage::KEEP_PAGE;
++}
++
++// -----------------------------------------------------------------------
++
++void ScTabPageSortOptions::FillUserSortListBox()
++{
++
++	ScUserList* pUserLists = ScGlobal::GetUserList();
++
++	aLbSortUser.Clear();
++	if ( pUserLists )
++	{
++		USHORT nCount = pUserLists->GetCount();
++		if ( nCount > 0 )
++			for ( USHORT i=0; i<nCount; i++ )
++				aLbSortUser.InsertEntry( (*pUserLists)[i]->GetString() );
++	}
++}
++
++// -----------------------------------------------------------------------
++// Handler:
++
++IMPL_LINK( ScTabPageSortOptions, EnableHdl, CheckBox *, pBox )
++{
++	if ( pBox == &aBtnCopyResult )
++	{
++		if ( pBox->IsChecked() )
++		{
++			aLbOutPos.Enable();
++			aEdOutPos.Enable();
++			aEdOutPos.GrabFocus();
++		}
++		else
++		{
++			aLbOutPos.Disable();
++			aEdOutPos.Disable();
++		}
++	}
++	else if ( pBox == &aBtnSortUser )
++	{
++		if ( pBox->IsChecked() )
++		{
++			aLbSortUser.Enable();
++			aLbSortUser.GrabFocus();
++		}
++		else
++			aLbSortUser.Disable();
++	}
++	return 0;
++}
++
++// -----------------------------------------------------------------------
++
++IMPL_LINK( ScTabPageSortOptions, SelOutPosHdl, ListBox *, pLb )
++{
++	if ( pLb == &aLbOutPos )
++	{
++		String	aString;
++		USHORT	nSelPos = aLbOutPos.GetSelectEntryPos();
++
++		if ( nSelPos > 0 )
++			aString = *(String*)aLbOutPos.GetEntryData( nSelPos );
++
++		aEdOutPos.SetText( aString );
++	}
++	return 0;
++}
++
++// -----------------------------------------------------------------------
++
++IMPL_LINK( ScTabPageSortOptions, SortDirHdl, RadioButton *, pBtn )
++{
++    (void) pBtn;
++
++	if ( pBtn == &aBtnTopDown )
++	{
++		aBtnHeader.SetText( aStrColLabel );
++	}
++	else if ( pBtn == &aBtnLeftRight )
++	{
++		aBtnHeader.SetText( aStrRowLabel );
++	}
++
++	return 0;
++}
++
++// -----------------------------------------------------------------------
++
++void __EXPORT ScTabPageSortOptions::EdOutPosModHdl( Edit* pEd )
++{
++    (void) pEd;
++	if ( pEd == &aEdOutPos )
++	{
++		String	theCurPosStr = aEdOutPos.GetText();
++		USHORT	nResult = ScAddress().Parse( theCurPosStr, pDoc, pDoc->GetAddressConvention() );
++
++		if ( SCA_VALID == (nResult & SCA_VALID) )
++		{
++			String*	pStr	= NULL;
++			BOOL	bFound	= FALSE;
++			USHORT	i		= 0;
++			USHORT	nCount	= aLbOutPos.GetEntryCount();
++
++			for ( i=2; i<nCount && !bFound; i++ )
++			{
++				pStr = (String*)aLbOutPos.GetEntryData( i );
++				bFound = (theCurPosStr == *pStr);
++			}
++
++			if ( bFound )
++				aLbOutPos.SelectEntryPos( --i );
++			else
++				aLbOutPos.SelectEntryPos( 0 );
++		}
++	}
++}
++
++// -----------------------------------------------------------------------
++
++IMPL_LINK( ScTabPageSortOptions, FillAlgorHdl, void *, EMPTYARG )
++{
++	aLbAlgorithm.SetUpdateMode( FALSE );
++	aLbAlgorithm.Clear();
++
++	LanguageType eLang = aLbLanguage.GetSelectLanguage();
++	if ( eLang == LANGUAGE_SYSTEM )
++	{
++		//	for LANGUAGE_SYSTEM no algorithm can be selected because
++		//	it wouldn't necessarily exist for other languages
++		//	-> leave list box empty if LANGUAGE_SYSTEM is selected
++        aFtAlgorithm.Enable( FALSE );           // nothing to select
++		aLbAlgorithm.Enable( FALSE );			// nothing to select
++	}
++	else
++	{
++		lang::Locale aLocale( MsLangId::convertLanguageToLocale( eLang ));
++		uno::Sequence<rtl::OUString> aAlgos = pColWrap->listCollatorAlgorithms( aLocale );
++
++		long nCount = aAlgos.getLength();
++		const rtl::OUString* pArray = aAlgos.getConstArray();
++		for (long i=0; i<nCount; i++)
++		{
++			String sAlg = pArray[i];
++			String sUser = pColRes->GetTranslation( sAlg );
++			aLbAlgorithm.InsertEntry( sUser, LISTBOX_APPEND );
++		}
++		aLbAlgorithm.SelectEntryPos( 0 );		// first entry is default
++        aFtAlgorithm.Enable( nCount > 1 );      // enable only if there is a choice
++		aLbAlgorithm.Enable( nCount > 1 );		// enable only if there is a choice
++	}
++
++	aLbAlgorithm.SetUpdateMode( TRUE );
++
++	return 0;
++}
++
++
+diff --git a/workben/layout/tpsort.hxx b/workben/layout/tpsort.hxx
+new file mode 100644
+index 0000000..f957dc7
+--- /dev/null
++++ toolkit/workben/layout/tpsort.hxx
+@@ -0,0 +1,243 @@
++/*************************************************************************
++ *
++ *  OpenOffice.org - a multi-platform office productivity suite
++ *
++ *  $RCSfile: tpsort.hxx,v $
++ *
++ *  $Revision: 1.7.248.1 $
++ *
++ *  last change: $Author: kz $ $Date: 2008/01/18 11:56:00 $
++ *
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
++ *
++ *
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library 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 for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
++ *
++ ************************************************************************/
++
++#ifndef SC_TPSORT_HXX
++#define SC_TPSORT_HXX
++
++
++#ifndef _SFXTABDLG_HXX //autogen
++#include <sfx2/tabdlg.hxx>
++#endif
++
++#ifndef _SV_EDIT_HXX //autogen
++#include <vcl/edit.hxx>
++#endif
++
++#ifndef _SV_FIXED_HXX //autogen
++#include <vcl/fixed.hxx>
++#endif
++
++#ifndef _SV_LSTBOX_HXX //autogen
++#include <vcl/lstbox.hxx>
++#endif
++
++#ifndef _STDCTRL_HXX //autogen
++#include <svtools/stdctrl.hxx>
++#endif
++
++#ifndef _SVX_LANGBOX_HXX
++#include <svx/langbox.hxx>
++#endif
++
++#ifndef SC_SCGLOB_HXX
++#include "global.hxx"
++#endif
++
++#ifndef SC_ADDRESS_HXX
++#include "address.hxx"
++#endif
++//------------------------------------------------------------------------
++
++// +1 because one field is reserved for the "- undefined -" entry
++#define SC_MAXFIELDS	MAXCOLCOUNT+1
++
++class ScViewData;
++class ScSortDlg;
++struct ScSortParam;
++
++//========================================================================
++// Kriterien (Sort Criteria)
++
++class ScTabPageSortFields : public SfxTabPage
++{
++public:
++				ScTabPageSortFields( Window*			 pParent,
++									 const SfxItemSet&	 rArgSet );
++				~ScTabPageSortFields();
++
++	static	SfxTabPage*	Create		( Window*				pParent,
++									  const SfxItemSet& 	rArgSet );
++	static	USHORT*		GetRanges	();
++	virtual	BOOL		FillItemSet	( SfxItemSet& rArgSet );
++	virtual	void		Reset		( const SfxItemSet& rArgSet );
++
++protected:
++// fuer Datenaustausch (sollte noch umgestellt werden!)
++//	virtual void		ActivatePage	( const SfxItemSet& rSet );
++    using SfxTabPage::ActivatePage;
++    using SfxTabPage::DeactivatePage;
++	virtual void		ActivatePage	();
++	virtual int			DeactivatePage	( SfxItemSet* pSet = 0);
++
++private:
++    FixedLine       aFlSort1;
++	ListBox			aLbSort1;
++	RadioButton		aBtnUp1;
++	RadioButton 	aBtnDown1;
++
++    FixedLine       aFlSort2;
++	ListBox			aLbSort2;
++	RadioButton		aBtnUp2;
++	RadioButton 	aBtnDown2;
++
++    FixedLine       aFlSort3;
++	ListBox			aLbSort3;
++	RadioButton		aBtnUp3;
++	RadioButton 	aBtnDown3;
++
++	String			aStrUndefined;
++	String			aStrColumn;
++	String			aStrRow;
++
++	const USHORT		nWhichSort;
++	ScSortDlg*			pDlg;
++	ScViewData*			pViewData;
++	const ScSortParam&	rSortData;
++	SCCOLROW			nFieldArr[SC_MAXFIELDS];
++	USHORT				nFieldCount;
++	SCCOL				nFirstCol;
++	SCROW				nFirstRow;
++	BOOL				bHasHeader;
++	BOOL				bSortByRows;
++
++	ListBox*			aSortLbArr[3];
++	RadioButton*		aDirBtnArr[3][2];
++    FixedLine*          aFlArr[3];
++
++#ifdef _TPSORT_CXX
++private:
++	void	Init			();
++	void	DisableField	( USHORT nField );
++	void	EnableField		( USHORT nField );
++	void	FillFieldLists	();
++	USHORT	GetFieldSelPos	( SCCOLROW nField );
++
++	// Handler ------------------------
++	DECL_LINK( SelectHdl, ListBox * );
++#endif
++};
++
++//========================================================================
++// Sortieroptionen (Sort Options)
++
++class ScDocument;
++class ScRangeData;
++class CollatorRessource;
++class CollatorWrapper;
++
++#include <layout/layout.hxx>
++#include <layout/layout-pre.hxx>
++
++class ScTabPageSortOptions : public SfxTabPage
++{
++public:
++				ScTabPageSortOptions( Window*			 pParent,
++									  const SfxItemSet&	 rArgSet );
++				~ScTabPageSortOptions();
++
++	static	SfxTabPage*	Create		( Window*				pParent,
++									  const SfxItemSet& 	rArgSet );
++	static	USHORT*		GetRanges	();
++	virtual	BOOL		FillItemSet	( SfxItemSet& rArgSet );
++	virtual	void		Reset		( const SfxItemSet& rArgSet );
++
++protected:
++// fuer Datenaustausch (sollte noch umgestellt werden!)
++//	virtual void		ActivatePage	( const SfxItemSet& rSet );
++    using SfxTabPage::ActivatePage;
++    using SfxTabPage::DeactivatePage;
++	virtual void		ActivatePage	();
++	virtual int			DeactivatePage	( SfxItemSet* pSet = 0);
++
++private:
++
++    CheckBox            aBtnCase;
++    CheckBox            aBtnHeader;
++    CheckBox            aBtnFormats;
++    CheckBox            aBtnCopyResult;
++
++	CheckBox			aBtnNaturalSort;
++    ListBox             aLbOutPos;
++    Edit                aEdOutPos;
++
++    CheckBox            aBtnSortUser;
++    ListBox             aLbSortUser;
++
++    FixedText           aFtLanguage;
++    SvxLanguageBox      aLbLanguage;
++    FixedText           aFtAlgorithm;
++    ListBox             aLbAlgorithm;
++
++    FixedLine           aLineDirection;
++    RadioButton         aBtnTopDown;
++    RadioButton         aBtnLeftRight;
++
++//     FixedText           aFtAreaLabel;
++//  FixedInfo           aFtArea;
++    String              aStrRowLabel;
++    String              aStrColLabel;
++    String              aStrUndefined;
++    String              aStrNoName;
++    String              aStrAreaLabel;
++
++	const USHORT		nWhichSort;
++	const ScSortParam&	rSortData;
++	ScViewData*			pViewData;
++	ScDocument*			pDoc;
++	ScSortDlg*			pDlg;
++	ScAddress			theOutPos;
++
++	CollatorRessource*	pColRes;
++	CollatorWrapper*	pColWrap;
++
++#ifdef _TPSORT_CXX
++private:
++	void Init					();
++	void FillUserSortListBox	();
++	void FillOutPosList 		();
++
++	// Handler ------------------------
++	DECL_LINK( EnableHdl, CheckBox * );
++	DECL_LINK( SelOutPosHdl, ListBox * );
++	void EdOutPosModHdl	( Edit* pEd );
++	DECL_LINK( SortDirHdl, RadioButton * );
++	DECL_LINK( FillAlgorHdl, void * );
++#endif
++};
++
++#include <layout/layout-post.hxx>
++
++#endif // SC_TPSORT_HXX
++



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]