Object Catalog in Dialog Editor

Change-Id: Ia74faa1452a4200c28fbd7c63130700df0a70b24

Object Catalog in Dialog Editor

Change-Id: I97f2e0497b0e87cf630bba16dd98f9f7d0bb86e7
diff --git a/basctl/Library_basctl.mk b/basctl/Library_basctl.mk
index c2d23f6..3e7db4c 100644
--- a/basctl/Library_basctl.mk
+++ b/basctl/Library_basctl.mk
@@ -88,6 +88,7 @@ $(eval $(call gb_Library_add_exception_objects,basctl,\
	basctl/source/basicide/docsignature \
	basctl/source/basicide/documentenumeration \
	basctl/source/basicide/iderdll \
	basctl/source/basicide/layout \
	basctl/source/basicide/linenumberwindow \
	basctl/source/basicide/localizationmgr \
	basctl/source/basicide/macrodlg \
diff --git a/basctl/source/accessibility/accessibledialogcontrolshape.cxx b/basctl/source/accessibility/accessibledialogcontrolshape.cxx
index 4b8f05d..ccfd4af 100644
--- a/basctl/source/accessibility/accessibledialogcontrolshape.cxx
+++ b/basctl/source/accessibility/accessibledialogcontrolshape.cxx
@@ -45,7 +45,7 @@ using namespace ::comphelper;
// class AccessibleDialogControlShape
// -----------------------------------------------------------------------------

AccessibleDialogControlShape::AccessibleDialogControlShape( DialogWindow* pDialogWindow, DlgEdObj* pDlgEdObj )
AccessibleDialogControlShape::AccessibleDialogControlShape (basctl::DialogWindow* pDialogWindow, DlgEdObj* pDlgEdObj)
    :AccessibleExtendedComponentHelper_BASE( new VCLExternalSolarLock() )
    ,m_pDialogWindow( pDialogWindow )
    ,m_pDlgEdObj( pDlgEdObj )
diff --git a/basctl/source/accessibility/accessibledialogwindow.cxx b/basctl/source/accessibility/accessibledialogwindow.cxx
index 4621e7e..a36c5b2 100644
--- a/basctl/source/accessibility/accessibledialogwindow.cxx
+++ b/basctl/source/accessibility/accessibledialogwindow.cxx
@@ -105,7 +105,7 @@ bool AccessibleDialogWindow::ChildDescriptor::operator<( const ChildDescriptor& 
// class AccessibleDialogWindow
// -----------------------------------------------------------------------------

AccessibleDialogWindow::AccessibleDialogWindow( DialogWindow* pDialogWindow )
AccessibleDialogWindow::AccessibleDialogWindow (basctl::DialogWindow* pDialogWindow)
    :AccessibleExtendedComponentHelper_BASE( new VCLExternalSolarLock() )
    ,m_pDialogWindow( pDialogWindow )
{
diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx
index 3d2bfd8..fbda06a 100644
--- a/basctl/source/basicide/baside2.cxx
+++ b/basctl/source/basicide/baside2.cxx
@@ -22,7 +22,10 @@
#include "iderdll.hxx"
#include "iderdll2.hxx"
#include "objdlg.hxx"
#include "moduldlg.hxx"
#include "docsignature.hxx"

#include "helpid.hrc"
#include "baside2.hrc"

#include <basic/basmgr.hxx>
@@ -41,13 +44,15 @@
#include <sfx2/request.hxx>
#include <svl/aeitem.hxx>
#include <svl/srchitem.hxx>
#include <svl/visitem.hxx>
#include <svl/whiter.hxx>
#include <vcl/xtextedt.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <vcl/msgbox.hxx>
#include <cassert>

using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
namespace basctl
{

#define LMARGPRN        1700
#define RMARGPRN         900
@@ -74,6 +79,9 @@ DBG_NAME( ModulWindow )

TYPEINIT1( ModulWindow , IDEBaseWindow );

namespace
{

void lcl_PrintHeader( Printer* pPrinter, sal_uInt16 nPages, sal_uInt16 nCurPage, const ::rtl::OUString& rTitle, bool bOutput )
{
    short nLeftMargin   = LMARGPRN;
@@ -160,17 +168,31 @@ void lcl_ConvertTabsToSpaces( String& rLine )
    }
}

ModulWindow::ModulWindow( ModulWindowLayout* pParent, const ScriptDocument& rDocument, ::rtl::OUString aLibName,
                          ::rtl::OUString aName, ::rtl::OUString& aModule )
        :IDEBaseWindow( pParent, rDocument, aLibName, aName )
        ,aXEditorWindow( this )
        ,m_aModule( aModule )
// until we have some configuration lets just keep
// persist this value for the process lifetime
bool bSourceLinesEnabled = false;

} // namespace


//
// ModulWindow
// ===========
//

ModulWindow::ModulWindow (
    ModulWindowLayout* pParent,
    ScriptDocument const& rDocument,
    rtl::OUString aLibName, rtl::OUString aName, rtl::OUString& aModule
) :
    IDEBaseWindow(pParent, rDocument, aLibName, aName),
    rLayout(*pParent),
    nValid(VALIDWINDOW),
    aXEditorWindow(this),
    m_aModule(aModule)
{
    DBG_CTOR( ModulWindow, 0 );
    nValid = VALIDWINDOW;
    pLayout = pParent;
    aXEditorWindow.Show();

    SetBackground();
}

@@ -514,8 +536,13 @@ bool ModulWindow::SaveBasicSource()
    return bDone;
}

} // namespace basctl

bool implImportDialog( Window* pWin, const ::rtl::OUString& rCurPath, const ScriptDocument& rDocument, const ::rtl::OUString& aLibName );

namespace basctl
{

bool ModulWindow::ImportDialog()
{
    const ScriptDocument& rDocument = GetDocument();
@@ -664,7 +691,7 @@ long ModulWindow::BasicErrorHdl( StarBASIC * pBasic )
        aErrorTextPrefixBuf.append(IDE_RESSTR(RID_STR_RUNTIMEERROR));
        aErrorTextPrefixBuf.append(StarBASIC::GetVBErrorCode(pBasic->GetErrorCode()));
        aErrorTextPrefixBuf.append(' ');
        pLayout->GetStackWindow().UpdateCalls();
        rLayout.UpdateDebug();
    }
    ::rtl::OUString aErrorTextPrefix(aErrorTextPrefixBuf.makeStringAndClear());
    // if other basic, the IDE should try to display the correct module
@@ -712,8 +739,7 @@ long ModulWindow::BasicBreakHdl( StarBASIC* pBasic )
    GetEditView()->SetSelection( TextSelection( TextPaM( nErrorLine, 0 ), TextPaM( nErrorLine, 0 ) ) );
    aXEditorWindow.GetBrkWindow().SetMarkerPos( nErrorLine );

    pLayout->GetWatchWindow().UpdateWatches();
    pLayout->GetStackWindow().UpdateCalls();
    rLayout.UpdateDebug();

    aStatus.bIsInReschedule = true;
    aStatus.bIsRunning = true;
@@ -755,24 +781,13 @@ void ModulWindow::BasicAddWatch()
    if ( bAdd )
    {
        TextSelection aSel = GetEditView()->GetSelection();
        if ( aSel.GetStart().GetPara() == aSel.GetEnd().GetPara() )
        {
            aWatchStr = GetEditView()->GetSelected();
            pLayout->GetWatchWindow().AddWatch( aWatchStr );
            pLayout->GetWatchWindow().UpdateWatches();
        }
        if ( aSel.GetStart().GetPara() == aSel.GetEnd().GetPara() ) // single line selection
            rLayout.BasicAddWatch(GetEditView()->GetSelected());
    }
}



void ModulWindow::BasicRemoveWatch()
{
    DBG_CHKTHIS( ModulWindow, 0 );
    pLayout->GetWatchWindow().RemoveSelectedWatch();
}


void ModulWindow::EditMacro( const String& rMacroName )
{
    DBG_CHKTHIS( ModulWindow, 0 );
@@ -941,12 +956,11 @@ sal_Int32 ModulWindow::FormatAndPrint( Printer* pPrinter, sal_Int32 nPrintPage )
}


void ModulWindow::ExecuteCommand( SfxRequest& rReq )
void ModulWindow::ExecuteCommand (SfxRequest& rReq)
{
    DBG_CHKTHIS( ModulWindow, 0 );
    AssertValidEditEngine();
    sal_uInt16 nSlot = rReq.GetSlot();
    switch ( nSlot )
    switch (rReq.GetSlot())
    {
        case SID_DELETE:
        {
@@ -1024,7 +1038,7 @@ void ModulWindow::ExecuteCommand( SfxRequest& rReq )
        break;
        case SID_BASICIDE_REMOVEWATCH:
        {
            BasicRemoveWatch();
            rLayout.BasicRemoveWatch();
        }
        break;
        case SID_CUT:
@@ -1032,8 +1046,7 @@ void ModulWindow::ExecuteCommand( SfxRequest& rReq )
            if ( !IsReadOnly() )
            {
                GetEditView()->Cut();
                SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
                if ( pBindings )
                if (SfxBindings* pBindings = BasicIDE::GetBindingsPtr())
                    pBindings->Invalidate( SID_DOC_MODIFIED );
            }
        }
@@ -1048,8 +1061,7 @@ void ModulWindow::ExecuteCommand( SfxRequest& rReq )
            if ( !IsReadOnly() )
            {
                GetEditView()->Paste();
                SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
                if ( pBindings )
                if (SfxBindings* pBindings = BasicIDE::GetBindingsPtr())
                    pBindings->Invalidate( SID_DOC_MODIFIED );
            }
        }
@@ -1059,6 +1071,52 @@ void ModulWindow::ExecuteCommand( SfxRequest& rReq )
            GetBreakPointWindow().Invalidate();
        }
        break;
        case SID_SHOWLINES:
        {
            SFX_REQUEST_ARG(rReq, pItem, SfxBoolItem, rReq.GetSlot(), false);
            bSourceLinesEnabled = pItem && pItem->GetValue();
            aXEditorWindow.SetLineNumberDisplay(bSourceLinesEnabled);
        }
        break;
        case SID_BASICIDE_DELETECURRENT:
        {
            if (QueryDelModule(m_aName, this))
                if (m_aDocument.removeModule(m_aLibName, m_aName))
                    BasicIDE::MarkDocumentModified(m_aDocument);
        }
        break;
        case FID_SEARCH_OFF:
            GrabFocus();
            break;
        case SID_GOTOLINE:
        {
            GotoLineDialog aGotoDlg(this);
            if (aGotoDlg.Execute())
                if (sal_Int32 const nLine = aGotoDlg.GetLineNumber())
                {
                    TextSelection const aSel(TextPaM(nLine - 1, 0), TextPaM(nLine - 1, 0));
                    GetEditView()->SetSelection(aSel);
                }
            break;
        }
    }
}

void ModulWindow::ExecuteGlobal (SfxRequest& rReq)
{
    switch (rReq.GetSlot())
    {
        case SID_SIGNATURE:
        {
            basctl::DocumentSignature aSignature(m_aDocument);
            if (aSignature.supportsSignatures())
            {
                aSignature.signScriptingContent();
                if (SfxBindings* pBindings = BasicIDE::GetBindingsPtr())
                    pBindings->Invalidate(SID_SIGNATURE);
            }
        }
        break;
    }
}

@@ -1124,6 +1182,11 @@ void ModulWindow::GetState( SfxItemSet &rSet )
                }
            }
            break;
            case SID_SHOWLINES:
            {
                rSet.Put(SfxBoolItem(nWh, bSourceLinesEnabled));
                break;
            }
        }
    }
}
@@ -1191,25 +1254,30 @@ void ModulWindow::ShowCursor( bool bOn )
}


Window* ModulWindow::GetLayoutWindow()
{
    return pLayout;
}

void ModulWindow::AssertValidEditEngine()
{
    if ( !GetEditEngine() )
        GetEditorWindow().CreateEditEngine();
}

void ModulWindow::Activating ()
{
    aXEditorWindow.SetLineNumberDisplay(bSourceLinesEnabled);
    Show();
}

void ModulWindow::Deactivating()
{
    Hide();
    if ( GetEditView() )
        GetEditView()->EraseVirtualDevice();
}

sal_uInt16 ModulWindow::StartSearchAndReplace( const SvxSearchItem& rSearchItem, bool bFromStart )
{
    if (IsSuspended())
        return 0;

    // one could also relinquish syntaxhighlighting/formatting instead of the stupid replace-everything...
    AssertValidEditEngine();
    ExtTextView* pView = GetEditView();
@@ -1354,11 +1422,6 @@ void ModulWindow::SetLineNumberDisplay(bool b)
    aXEditorWindow.SetLineNumberDisplay(b);
}

void ModulWindow::SetObjectCatalogDisplay(bool b)
{
    aXEditorWindow.SetObjectCatalogDisplay(b);
}

bool ModulWindow::IsPasteAllowed()
{
    bool bPaste = false;
@@ -1383,374 +1446,207 @@ bool ModulWindow::IsPasteAllowed()
    return bPaste;
}

ModulWindowLayout::ModulWindowLayout( Window* pParent ) :
    Window(pParent, WB_CLIPCHILDREN),
    bFirstArrange(true),
    aLeftSplit(this, WB_HSCROLL),
    aBottomSplit(this, WB_VSCROLL),
    aVertSplit(this, WB_HSCROLL),
    aObjectCatalog(this),
void ModulWindow::OnNewDocument ()
{
    aXEditorWindow.SetLineNumberDisplay(bSourceLinesEnabled);
}

char const* ModulWindow::GetHid () const
{
    return HID_BASICIDE_MODULWINDOW;
}
BasicIDEType ModulWindow::GetType () const
{
    return BASICIDE_TYPE_MODULE;
}

bool ModulWindow::HasActiveEditor () const
{
    return !IsSuspended();
}


void ModulWindow::UpdateModule ()
{
    rtl::OUString const aModule = getTextEngineText(GetEditEngine());

    // update module in basic
    assert(xModule);

    // update module in module window
    SetModule(aModule);

    // update module in library
    OSL_VERIFY(m_aDocument.updateModule(m_aLibName, m_aName, aModule));

    GetEditEngine()->SetModified(false);
    BasicIDE::MarkDocumentModified(m_aDocument);
}


//
// ModulWindowLayout
// =================
//

ModulWindowLayout::ModulWindowLayout (Window* pParent, ObjectCatalog& rObjectCatalog_) :
    Layout(pParent),
    pChild(0),
    aWatchWindow(this),
    aStackWindow(this),
    m_pModulWindow(0),
    m_aImagesNormal(IDEResId(RID_IMGLST_LAYOUT))
    rObjectCatalog(rObjectCatalog_)
{ }

void ModulWindowLayout::UpdateDebug (bool bBasicStopped)
{
    SetBackground(GetSettings().GetStyleSettings().GetWindowColor());
    aWatchWindow.UpdateWatches(bBasicStopped);
    aStackWindow.UpdateCalls();
}

    Color splitterColor(GetSettings().GetStyleSettings().GetShadowColor());
void ModulWindowLayout::Paint (Rectangle const&)
{
    DrawText(Point(), String(IDEResId(RID_STR_NOMODULE)));
}

    aLeftSplit.SetLineColor(splitterColor);
    aLeftSplit.SetFillColor(splitterColor);
    aBottomSplit.SetLineColor(splitterColor);
    aBottomSplit.SetFillColor(splitterColor);
    aVertSplit.SetLineColor(splitterColor);
    aVertSplit.SetFillColor(splitterColor);
// virtual
void ModulWindowLayout::DataChanged (DataChangedEvent const& rDCEvt)
{
    Layout::DataChanged(rDCEvt);
    if (rDCEvt.GetType() == DATACHANGED_SETTINGS && (rDCEvt.GetFlags() & SETTINGS_STYLE))
        aSyntaxColors.SettingsChanged();
}

    aLeftSplit.Show();
    aBottomSplit.Show();
    aVertSplit.Show();
    aLeftSplit.SetSplitHdl( LINK(this, ModulWindowLayout, SplitHdl) );
    aBottomSplit.SetSplitHdl( LINK(this, ModulWindowLayout, SplitHdl) );
    aVertSplit.SetSplitHdl( LINK(this, ModulWindowLayout, SplitHdl) );

void ModulWindowLayout::Activating (IDEBaseWindow& rChild)
{
    assert(dynamic_cast<ModulWindow*>(&rChild));
    pChild = &static_cast<ModulWindow&>(rChild);
    aWatchWindow.Show();
    aStackWindow.Show();
    aObjectCatalog.Show();

    Color aColor(GetSettings().GetStyleSettings().GetFieldTextColor());
    m_aSyntaxColors[TT_UNKNOWN] = aColor;
    m_aSyntaxColors[TT_WHITESPACE] = aColor;
    m_aSyntaxColors[TT_EOL] = aColor;
    m_aColorConfig.AddListener(this);
    m_aSyntaxColors[TT_IDENTIFIER]
        = Color(m_aColorConfig.GetColorValue(svtools::BASICIDENTIFIER).nColor);
    m_aSyntaxColors[TT_NUMBER]
        = Color(m_aColorConfig.GetColorValue(svtools::BASICNUMBER).nColor);
    m_aSyntaxColors[TT_STRING]
        = Color(m_aColorConfig.GetColorValue(svtools::BASICSTRING).nColor);
    m_aSyntaxColors[TT_COMMENT]
        = Color(m_aColorConfig.GetColorValue(svtools::BASICCOMMENT).nColor);
    m_aSyntaxColors[TT_ERROR]
        = Color(m_aColorConfig.GetColorValue(svtools::BASICERROR).nColor);
    m_aSyntaxColors[TT_OPERATOR]
        = Color(m_aColorConfig.GetColorValue(svtools::BASICOPERATOR).nColor);
    m_aSyntaxColors[TT_KEYWORDS]
        = Color(m_aColorConfig.GetColorValue(svtools::BASICKEYWORD).nColor);

    Font aFont( GetFont() );
    Size aSz( aFont.GetSize() );
    aSz.Height() *= 3;
    aSz.Height() /= 2;
    aFont.SetSize( aSz );
    aFont.SetWeight( WEIGHT_BOLD );
    aFont.SetColor(GetSettings().GetStyleSettings().GetWindowTextColor());
    SetFont( aFont );
    rObjectCatalog.Show();
    rObjectCatalog.SetLayoutWindow(this);
    rObjectCatalog.UpdateEntries();
    Layout::Activating(rChild);
    aSyntaxColors.SetActiveEditor(&pChild->GetEditorWindow());
}

ModulWindowLayout::~ModulWindowLayout()
void ModulWindowLayout::Deactivating ()
{
    m_aColorConfig.RemoveListener(this);
    aSyntaxColors.SetActiveEditor(0);
    Layout::Deactivating();
    aWatchWindow.Hide();
    aStackWindow.Hide();
    rObjectCatalog.Hide();
    pChild = 0;
}

void ModulWindowLayout::Resize()
void ModulWindowLayout::GetState (SfxItemSet &rSet, unsigned nWhich)
{
    // ScrollBars, etc. happens in BasicIDEShell:Adjust...
    ArrangeWindows();
    switch (nWhich)
    {
        case SID_BASICIDE_CHOOSEMACRO:
            rSet.Put(SfxVisibilityItem(nWhich, true));
            break;
    }
}

void ModulWindowLayout::Paint( const Rectangle& )
void ModulWindowLayout::BasicAddWatch (String const& rWatchStr)
{
    DrawText( Point(), String( IDEResId( RID_STR_NOMODULE ) ) );
    aWatchWindow.AddWatch(rWatchStr);
}


void ModulWindowLayout::ArrangeWindows()
void ModulWindowLayout::BasicRemoveWatch ()
{
    static long const nSplitThickness = 2;
    static double const
        fDefaultLeftSplit = 0.2,
        fDefaultBottomSplit = 0.75,
        fDefaultVertSplit = 0.67;

    Size const aSize = GetOutputSizePixel();
    long const nWidth = aSize.Width(), nHeight = aSize.Height();
    if (!nWidth || !nHeight) // empty size
        return;

    // When ArrangeWindows() is called first,
    // the initial positions of the splitter lines are set.
    if (bFirstArrange)
    {
        aLeftSplit.SetSplitPosPixel(aSize.Width()  * fDefaultLeftSplit);
        aBottomSplit.SetSplitPosPixel(aSize.Height() * fDefaultBottomSplit);
        aVertSplit.SetSplitPosPixel(aSize.Width()  * fDefaultVertSplit);
        bFirstArrange = false;
    }

    // resizing windows to the splitting lines
    long const nLeftSplitPos = aLeftSplit.GetSplitPosPixel();
    long const nBottomSplitPos = aBottomSplit.GetSplitPosPixel();
    long const nVertSplitPos = aVertSplit.GetSplitPosPixel();
    // which window is docked?
    bool const bObjCat = !aObjectCatalog.IsFloatingMode() && aObjectCatalog.IsVisible();
    bool const bWatchWin = !aWatchWindow.IsFloatingMode() && aWatchWindow.IsVisible();
    bool const bStackWin = !aStackWindow.IsFloatingMode() && aStackWindow.IsVisible();
    long const nBottom = bStackWin || bWatchWin ? nBottomSplitPos : nHeight;
    // left splitting line
    if (bObjCat)
    {
        aLeftSplit.SetDragRectPixel(Rectangle(Point(0, 0), Size(nWidth, nBottom)));
        aLeftSplit.SetPosPixel(Point(nLeftSplitPos, 0));
        aLeftSplit.SetSizePixel(Size(nSplitThickness, nBottom));
        aLeftSplit.Show();
    }
    else
        aLeftSplit.Hide();
    // bottom splitting line
    if (bWatchWin || bStackWin)
    {
        aBottomSplit.SetDragRectPixel(Rectangle(Point(0, 0), aSize));
        aBottomSplit.SetPosPixel(Point(0, nBottomSplitPos));
        aBottomSplit.SetSizePixel(Size(nWidth, nSplitThickness));
        aBottomSplit.Show();
    }
    else
        aBottomSplit.Hide();
    // vertical (bottom) splitting line
    if (bWatchWin || bStackWin)
    {
        Point const aPos(nVertSplitPos, nBottomSplitPos + nSplitThickness);
        aVertSplit.SetDragRectPixel(Rectangle(Point(0, aPos.Y()), Size(nWidth, nHeight - aPos.Y())));
        aVertSplit.SetPosSizePixel(aPos, Size(nSplitThickness, nHeight - aPos.Y()));
        aVertSplit.Show();
    }
    else
        aVertSplit.Hide();
    // editor window
    if (m_pModulWindow)
    {
        DBG_CHKOBJ(m_pModulWindow, ModulWindow, 0);
        long const nLeft = bObjCat ? nLeftSplitPos + nSplitThickness : 0;
        m_pModulWindow->SetPosSizePixel(
            Point(nLeft, 0),
            Size(nWidth - nLeft, nBottom)
        );
    }
    // object catalog (left)
    if (bObjCat)
    {
        aObjectCatalog.SetPosPixel(Point(0, 0));
        aObjectCatalog.SetSizePixel(Size(nLeftSplitPos, nBottom));
    }
    // watch (bottom left)
    if (bWatchWin)
    {
        Point const aPos(0, nBottomSplitPos + nSplitThickness);
        aWatchWindow.SetPosPixel(aPos);
        aWatchWindow.SetSizePixel(Size(nVertSplitPos, nHeight - aPos.Y()));
    }
    // call stack (bottom right)
    if (bStackWin)
    {
        Point const aPos(nVertSplitPos + nSplitThickness, nBottomSplitPos + nSplitThickness);
        aStackWindow.SetPosPixel(aPos);
        aStackWindow.SetSizePixel(Size(nWidth - aPos.X(), nHeight - aPos.Y()));
    }
    DBG_CHKTHIS( ModulWindow, 0 );
    aWatchWindow.RemoveSelectedWatch();
}

IMPL_LINK( ModulWindowLayout, SplitHdl, Splitter *, pSplitter )
void ModulWindowLayout::OnFirstSize (int const nWidth, int const nHeight)
{
    // The split line cannot be closer to the edges than nMargin pixels.
    static long const nMargin = 16;
    // Checking margins:
    if (long const nSize = pSplitter->IsHorizontal() ?
        GetOutputSizePixel().Width() :
        GetOutputSizePixel().Height()
    ) {
        long const nPos = pSplitter->GetSplitPosPixel();
        if (nPos < nMargin)
            pSplitter->SetSplitPosPixel(nMargin);
        if (nPos > nSize - nMargin)
            pSplitter->SetSplitPosPixel(nSize - nMargin);
    }
    ArrangeWindows();
    return 0;
    AddToLeft(&rObjectCatalog, Size(nWidth * 0.20, nHeight * 0.75));
    AddToBottom(&aWatchWindow, Size(nWidth * 0.67, nHeight * 0.25));
    AddToBottom(&aStackWindow, Size(nWidth * 0.33, nHeight * 0.25));
}


//
// IsToBeDocked() -- test whether dock or child:
// true:  Floating
// false: Child
// SyntaxColors
// ============
//
bool ModulWindowLayout::IsToBeDocked (
    DockingWindow* pDockingWindow, Point const& rPos, Rectangle& rRect
) {
    Point const aPos = ScreenToOutputPixel(rPos);
    Size const aSize = GetOutputSizePixel();
    long const nWidth = aSize.Width(), nHeight = aSize.Height();

    if (aPos.X() > 0 && aPos.X() < nWidth && aPos.Y() > 0 && aPos.Y() < nHeight)
ModulWindowLayout::SyntaxColors::SyntaxColors () :
    pEditor(0)
{
    aConfig.AddListener(this);

    aColors[TT_UNKNOWN] =
    aColors[TT_WHITESPACE] =
    aColors[TT_EOL] =
        Application::GetSettings().GetStyleSettings().GetFieldTextColor();

    NewConfig(true);
}

ModulWindowLayout::SyntaxColors::~SyntaxColors ()
{
    aConfig.RemoveListener(this);
}

void ModulWindowLayout::SyntaxColors::SettingsChanged ()
{
    Color const aColor = Application::GetSettings().GetStyleSettings().GetFieldTextColor();
    if (aColor != aColors[TT_UNKNOWN])
    {
        long const nLeftSplit = aLeftSplit.GetSplitPosPixel();
        long const nBottomSplit = aBottomSplit.GetSplitPosPixel();
        long const nVertSplit = aVertSplit.GetSplitPosPixel();
        if (pDockingWindow == &aObjectCatalog)
        {
            if (aPos.Y() < nBottomSplit && aPos.X() < nLeftSplit)
            {
                rRect = Rectangle(
                    OutputToScreenPixel(Point(0, 0)),
                    Size(nLeftSplit, nBottomSplit)
                );
                return true;
            }
        }
        else if (pDockingWindow == &aWatchWindow)
        {
            if (aPos.Y() > nBottomSplit && aPos.X() < nVertSplit)
            {
                rRect = Rectangle(
                    OutputToScreenPixel(Point(0, nBottomSplit)),
                    Size(nVertSplit, nHeight - nBottomSplit)
                );
                return true;
            }
        }
        else if (pDockingWindow == &aStackWindow)
        {
            if (aPos.Y() > nBottomSplit && aPos.X() > nVertSplit)
            {
                rRect = Rectangle(
                    OutputToScreenPixel(Point(nVertSplit, nBottomSplit)),
                    Size(nWidth - nVertSplit, nHeight - nBottomSplit)
                );
                return true;
            }
        }
    }
    return false;
}

void ModulWindowLayout::DockaWindow (DockingWindow*)
{
    ArrangeWindows();
}

void ModulWindowLayout::SetModulWindow (ModulWindow* pModulWindow)
{
    m_pModulWindow = pModulWindow;
    ArrangeWindows();
}

// virtual
void ModulWindowLayout::DataChanged(DataChangedEvent const & rDCEvt)
{
    Window::DataChanged(rDCEvt);
    if (rDCEvt.GetType() == DATACHANGED_SETTINGS
        && (rDCEvt.GetFlags() & SETTINGS_STYLE) != 0)
    {
        bool bInvalidate = false;
        Color aColor(GetSettings().GetStyleSettings().GetWindowColor());
        if (aColor
            != rDCEvt.GetOldSettings()->GetStyleSettings().GetWindowColor())
        {
            SetBackground(Wallpaper(aColor));
            bInvalidate = true;
        }
        aColor = GetSettings().GetStyleSettings().GetWindowTextColor();
        if (aColor != rDCEvt.GetOldSettings()->
            GetStyleSettings().GetWindowTextColor())
        {
            Font aFont(GetFont());
            aFont.SetColor(aColor);
            SetFont(aFont);
            bInvalidate = true;
        }
        if (bInvalidate)
            Invalidate();
        aColor = GetSettings().GetStyleSettings().GetFieldTextColor();
        if (aColor != m_aSyntaxColors[TT_UNKNOWN])
        {
            m_aSyntaxColors[TT_UNKNOWN] = aColor;
            m_aSyntaxColors[TT_WHITESPACE] = aColor;
            m_aSyntaxColors[TT_EOL] = aColor;
            updateSyntaxHighlighting();
        }
        aColors[TT_UNKNOWN] =
        aColors[TT_WHITESPACE] =
        aColors[TT_EOL] =
            aColor;
        if (pEditor)
            pEditor->UpdateSyntaxHighlighting();
    }
}

// virtual
void ModulWindowLayout::ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 )
void ModulWindowLayout::SyntaxColors::ConfigurationChanged (utl::ConfigurationBroadcaster*, sal_uInt32)
{
    NewConfig(false);
}

// when a new configuration has to be set
void ModulWindowLayout::SyntaxColors::NewConfig (bool bFirst)
{
    static struct
    {
        Color aColor(m_aColorConfig.GetColorValue(svtools::BASICIDENTIFIER).
                     nColor);
        bool bChanged = aColor != m_aSyntaxColors[TT_IDENTIFIER];
        m_aSyntaxColors[TT_IDENTIFIER] = aColor;
        aColor = Color(m_aColorConfig.GetColorValue(svtools::BASICNUMBER).nColor);
    if (bChanged || aColor != m_aSyntaxColors[TT_NUMBER])
            bChanged = true;
        m_aSyntaxColors[TT_NUMBER] = aColor;
        aColor = Color(m_aColorConfig.GetColorValue(svtools::BASICSTRING).nColor);
        if (bChanged || aColor != m_aSyntaxColors[TT_STRING])
            bChanged = true;
        m_aSyntaxColors[TT_STRING] = aColor;
        aColor = Color(m_aColorConfig.GetColorValue(svtools::BASICCOMMENT).
                       nColor);
        if (bChanged || aColor != m_aSyntaxColors[TT_COMMENT])
            bChanged = true;
        m_aSyntaxColors[TT_COMMENT] = aColor;
        aColor = Color(m_aColorConfig.GetColorValue(svtools::BASICERROR).nColor);
        if (bChanged || aColor != m_aSyntaxColors[TT_ERROR])
            bChanged = true;
        m_aSyntaxColors[TT_ERROR] = aColor;
        aColor = Color(m_aColorConfig.GetColorValue(svtools::BASICOPERATOR).
                       nColor);
        if (bChanged || aColor != m_aSyntaxColors[TT_OPERATOR])
            bChanged = true;
        m_aSyntaxColors[TT_OPERATOR] = aColor;
        aColor = Color(m_aColorConfig.GetColorValue(svtools::BASICKEYWORD).
                       nColor);
        if (bChanged || aColor != m_aSyntaxColors[TT_KEYWORDS])
            bChanged = true;
        m_aSyntaxColors[TT_KEYWORDS] = aColor;
        if (bChanged)
            updateSyntaxHighlighting();
        TokenTypes eTokenType;
        svtools::ColorConfigEntry eEntry;
    }
}

void ModulWindowLayout::updateSyntaxHighlighting()
{
    if (m_pModulWindow != 0)
    const vIds[] =
    {
        EditorWindow & rEditor = m_pModulWindow->GetEditorWindow();
        sal_uLong nCount = rEditor.GetEditEngine()->GetParagraphCount();
        for (sal_uLong i = 0; i < nCount; ++i)
            rEditor.DoDelayedSyntaxHighlight(i);
        { TT_IDENTIFIER,  svtools::BASICIDENTIFIER },
        { TT_NUMBER,      svtools::BASICNUMBER },
        { TT_STRING,      svtools::BASICSTRING },
        { TT_COMMENT,     svtools::BASICCOMMENT },
        { TT_ERROR,       svtools::BASICERROR },
        { TT_OPERATOR,    svtools::BASICOPERATOR },
        { TT_KEYWORDS,    svtools::BASICKEYWORD },
    };

    bool bChanged = false;
    for (unsigned i = 0; i != sizeof vIds / sizeof vIds[0]; ++i)
    {
        Color const aColor = aConfig.GetColorValue(vIds[i].eEntry).nColor;
        Color& rMyColor = aColors[vIds[i].eTokenType];
        if (bFirst || aColor != rMyColor)
        {
            rMyColor = aColor;
            bChanged = true;
        }
    }
    if (bChanged && !bFirst && pEditor)
        pEditor->UpdateSyntaxHighlighting();
}

Image ModulWindowLayout::getImage(sal_uInt16 nId) const
{
    return m_aImagesNormal.GetImage(nId);
}

// shows or hides the Object Catalog window (depending on its state)
void ModulWindowLayout::ToggleObjectCatalog ()
{
    // show or hide?
    bool const bShow = !aObjectCatalog.IsVisible();
    bShow ? aObjectCatalog.Show() : aObjectCatalog.Hide();
    if (m_pModulWindow)
        m_pModulWindow->SetObjectCatalogDisplay(bShow);
    // refreshing
    ArrangeWindows();
}

// Updates the Object Catalog window.
void ModulWindowLayout::UpdateObjectCatalog ()
{
    aObjectCatalog.UpdateEntries();
}
} // namespace basctl

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx
index e3aeeed..e1e6392 100644
--- a/basctl/source/basicide/baside2.hxx
+++ b/basctl/source/basicide/baside2.hxx
@@ -20,12 +20,13 @@
#ifndef BASCTL_BASIDE2_HXX
#define BASCTL_BASIDE2_HXX

#include <svheader.hxx>

#include "layout.hxx"
#include <bastypes.hxx>
#include <bastype3.hxx>
#include <basidesh.hxx>

#include <svheader.hxx>

class ExtTextEngine;
class ExtTextView;
class SvxSearchItem;
@@ -40,22 +41,25 @@ class SvxSearchItem;
#include <svtools/colorcfg.hxx>

#include <sfx2/progress.hxx>
#include <svtools/syntaxhighlight.hxx>
#include <unotools/options.hxx>

#include "breakpoint.hxx"
#include "linenumberwindow.hxx"
#include "objdlg.hxx"
#include <set>

DBG_NAMEEX( ModulWindow )

#define MARKER_NOMARKER 0xFFFF

namespace com { namespace sun { namespace star { namespace beans {
    class XMultiPropertySet;
} } } }

namespace basctl
{

class ObjectCatalog;

DBG_NAMEEX( ModulWindow )

// #108672 Helper functions to get/set text in TextEngine
// using the stream interface (get/setText() only supports
// tools Strings limited to 64K).
@@ -90,10 +94,10 @@ class EditorWindow : public Window, public SfxListener
{
private:
    class ChangesListener;
    friend class ChangesListener;

    ExtTextView*    pEditView;
    ExtTextEngine*  pEditEngine;
    ModulWindow&    rModulWindow;

    rtl::Reference< ChangesListener > listener_;
    osl::Mutex mutex_;
@@ -107,7 +111,6 @@ private:
    SyntaxLineSet   aSyntaxLineTable;
    DECL_LINK(SyntaxTimerHdl, void *);
    ProgressInfo*   pProgress;
    ModulWindow*    pModulWindow;

    virtual void DataChanged(DataChangedEvent const & rDCEvt);

@@ -141,7 +144,7 @@ protected:
    bool            ImpCanModify();

public:
                    EditorWindow( Window* pParent );
                    EditorWindow (Window* pParent, ModulWindow*);
                    ~EditorWindow();

    ExtTextEngine*  GetEditEngine() const   { return pEditEngine; }
@@ -157,23 +160,23 @@ public:
    void            CreateEditEngine();
    void            SetScrollBarRanges();
    void            InitScrollBars();
    void            SetModulWindow( ModulWindow* pWin )
                        { pModulWindow = pWin; }

    void            ForceSyntaxTimeout();
    bool            SetSourceInBasic();

    bool            CanModify() { return ImpCanModify(); }

    void            UpdateSyntaxHighlighting ();
};


class BreakPointWindow : public Window
{
private:
    ModulWindow&    rModulWindow;
    long            nCurYOffset;
    sal_uInt16          nMarkerPos;
    sal_uInt16      nMarkerPos;
    BreakPointList  aBreakPointList;
    ModulWindow*    pModulWindow;
    bool            bErrorMarker;

    virtual void DataChanged(DataChangedEvent const & rDCEvt);
@@ -191,12 +194,9 @@ protected:
    bool            SyncYOffset();

public:
                    BreakPointWindow( Window* pParent );
                    BreakPointWindow (Window* pParent, ModulWindow*);
                    ~BreakPointWindow();

    void            SetModulWindow( ModulWindow* pWin )
                        { pModulWindow = pWin; }

    void            SetMarkerPos( sal_uInt16 nLine, bool bErrorMarker = false );

    void            DoScroll( long nHorzScroll, long nVertScroll );
@@ -249,7 +249,7 @@ protected:


public:
                    WatchWindow( Window* pParent );
                    WatchWindow (Layout* pParent);
                    ~WatchWindow();

    void            AddWatch( const String& rVName );
@@ -271,7 +271,7 @@ protected:
    virtual void    Paint( const Rectangle& rRect );

public:
                    StackWindow( Window* pParent );
                    StackWindow (Layout* pParent);
                    ~StackWindow();

    void            UpdateCalls();
@@ -285,8 +285,6 @@ private:
    LineNumberWindow    aLineNumberWindow;
    EditorWindow        aEdtWindow;
    ScrollBar           aEWVScrollBar;
    bool                bLineNumberDisplay;
    bool                bObjectCatalogDisplay;

    virtual void DataChanged(DataChangedEvent const & rDCEvt);

@@ -303,32 +301,25 @@ public:
    ScrollBar&          GetEWVScrollBar()   { return aEWVScrollBar; }

    void SetLineNumberDisplay(bool b);
    void SetObjectCatalogDisplay(bool b);
};


class ModulWindow: public IDEBaseWindow
{
    friend class BasicIDEShell;

private:
    ModulWindowLayout&  rLayout;
    StarBASICRef        xBasic;
    short               nValid;
    ComplexEditorWindow aXEditorWindow;
    BasicStatus         aStatus;
    SbModuleRef         xModule;
    ModulWindowLayout*  pLayout;
    ::rtl::OUString     aCurPath;
    ::rtl::OUString     m_aModule;

    long                BasicErrorHdl( StarBASIC* pBasic );
    long                BasicBreakHdl( StarBASIC* pBasic );

    void                CheckCompileBasic();
    bool                BasicExecute();

    void                GoOnTop();
    void                AssertValidEditEngine();

    sal_Int32           FormatAndPrint( Printer* pPrinter, sal_Int32 nPage = -1 );
    SbModuleRef         XModule();
@@ -336,7 +327,6 @@ protected:
    virtual void    Resize();
    virtual void    GetFocus();
    virtual void    Paint( const Rectangle& );
    virtual void    Deactivating();
    virtual void    DoInit();
    virtual void    DoScroll( ScrollBar* pCurScrollBar );

@@ -347,7 +337,8 @@ public:

                    ~ModulWindow();

    virtual void    ExecuteCommand( SfxRequest& rReq );
    virtual void    ExecuteCommand (SfxRequest& rReq);
    virtual void    ExecuteGlobal (SfxRequest& rReq);
    virtual void    GetState( SfxItemSet& );
    virtual void    StoreData();
    virtual void    UpdateData();
@@ -363,7 +354,6 @@ public:
    virtual bool    IsReadOnly();

    void SetLineNumberDisplay(bool);
    void SetObjectCatalogDisplay(bool);

    StarBASIC*      GetBasic() { XModule(); return xBasic; }

@@ -384,6 +374,10 @@ public:
    void            BasicAddWatch();
    void            BasicRemoveWatch();

    long            BasicErrorHdl( StarBASIC* pBasic );
    long            BasicBreakHdl( StarBASIC* pBasic );
    void            AssertValidEditEngine();

    bool            LoadBasic();
    bool            SaveBasicSource();
    bool            ImportDialog();
@@ -401,9 +395,7 @@ public:
    void            ShowCursor( bool bOn );

    virtual sal_uInt16  GetSearchOptions();
    sal_uInt16          StartSearchAndReplace( const SvxSearchItem& rSearchItem, bool bFromStart = false );

    virtual Window* GetLayoutWindow();
    virtual sal_uInt16  StartSearchAndReplace (SvxSearchItem const&, bool bFromStart = false);

    EditorWindow&       GetEditorWindow()       { return aXEditorWindow.GetEdtWindow(); }
    BreakPointWindow&   GetBreakPointWindow()   { return aXEditorWindow.GetBrkWindow(); }
@@ -412,7 +404,7 @@ public:
    ExtTextEngine*      GetEditEngine()         { return GetEditorWindow().GetEditEngine(); }
    ExtTextView*        GetEditView()           { return GetEditorWindow().GetEditView(); }
    BreakPointList&     GetBreakPoints()        { return GetBreakPointWindow().GetBreakPoints(); }
    ModulWindowLayout*  GetLayout() const       { return pLayout; }
    ModulWindowLayout&  GetLayout ()            { return rLayout; }

    virtual void        BasicStarted();
    virtual void        BasicStopped();
@@ -422,67 +414,78 @@ public:

    const ::rtl::OUString&  GetModule() const { return m_aModule; }
    void                    SetModule( const ::rtl::OUString& aModule ) { m_aModule = aModule; }

    virtual void Activating ();
    virtual void Deactivating ();

    virtual void OnNewDocument ();
    virtual char const* GetHid () const;
    virtual BasicIDEType GetType () const;
    virtual bool HasActiveEditor () const;

    void UpdateModule ();
};

class ModulWindowLayout: public Window, public utl::ConfigurationListener
class ModulWindowLayout: public Layout
{
private:
    // is ArrangeWindows() called first in this object?
    bool bFirstArrange;

    // splitter lines
    Splitter aLeftSplit, aBottomSplit, aVertSplit;

    // dockable windows
    ObjectCatalog aObjectCatalog;
    WatchWindow aWatchWindow;
    StackWindow aStackWindow;

    ModulWindow* m_pModulWindow;

    Color m_aSyntaxColors[TT_KEYWORDS + 1];
    svtools::ColorConfig m_aColorConfig;

    ImageList m_aImagesNormal;

    virtual void DataChanged(DataChangedEvent const & rDCEvt);

    virtual void ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 );

    void updateSyntaxHighlighting();

    DECL_LINK( SplitHdl, Splitter * );

    void            ArrangeWindows();
public:
    ModulWindowLayout (Window* pParent, ObjectCatalog&);
public:
    // Layout:
    virtual void Activating (IDEBaseWindow&);
    virtual void Deactivating ();
    virtual void GetState (SfxItemSet&, unsigned nWhich);
    virtual void UpdateDebug (bool bBasicStopped = false);
public:
    void BasicAddWatch (String const&);
    void BasicRemoveWatch ();
    Color GetSyntaxColor (TokenTypes eType) const { return aSyntaxColors.GetColor(eType); }

protected:
    virtual void    Resize();
    virtual void    Paint( const Rectangle& rRect );
    // Window:
    virtual void Paint (const Rectangle& rRect);
    // Layout:
    virtual void OnFirstSize (int nWidth, int nHeight);

public:
                    ModulWindowLayout( Window* pParent );
                    ~ModulWindowLayout();
private:
    // main child window
    ModulWindow* pChild;
    // dockable windows
    WatchWindow aWatchWindow;
    StackWindow aStackWindow;
    ObjectCatalog& rObjectCatalog;
private:
    virtual void DataChanged (DataChangedEvent const& rDCEvt);
private:
    // SyntaxColors -- stores Basic syntax highlighting colors
    class SyntaxColors : public utl::ConfigurationListener
    {
    public:
        SyntaxColors ();
        ~SyntaxColors ();
    public:
        void SetActiveEditor (EditorWindow* pEditor_) { pEditor = pEditor_; }
        void SettingsChanged ();
    public:
        Color GetColor (TokenTypes eType) const { return aColors[eType]; }

    void            DockaWindow( DockingWindow* pDockingWin );
    bool            IsToBeDocked( DockingWindow* pDockingWin, const Point& rPos, Rectangle& rRect );
    private:
        virtual void ConfigurationChanged (utl::ConfigurationBroadcaster*, sal_uInt32);
        void NewConfig (bool bFirst);

    void            SetModulWindow( ModulWindow* pModWin );
    ModulWindow*    GetModulWindow() const { return m_pModulWindow; }
    private:
        // the color values (the indexes are TokenTypes, see svtools/syntaxhighlight.hxx)
        Color aColors[TT_KEYWORDS + 1];
        // the configuration
        svtools::ColorConfig aConfig;
        // the active editor
        EditorWindow* pEditor;

    WatchWindow&    GetWatchWindow()    { return aWatchWindow; }
    StackWindow&    GetStackWindow()    { return aStackWindow; }
    ObjectCatalog&  GetObjectCatalog()  { return aObjectCatalog; }

    Image getImage(sal_uInt16 nId) const;

    inline Color const & getSyntaxColor(TokenTypes eType) const
    { return m_aSyntaxColors[eType]; }

    void ToggleObjectCatalog ();
    bool HasObjectCatalog () const { return aObjectCatalog.IsVisible(); }
    void UpdateObjectCatalog ();
    } aSyntaxColors;
};

} // namespace basctl

#endif // BASCTL_BASIDE2_HXX

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index dd6337e..a784d4d 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -41,9 +41,13 @@
#include <vcl/xtextedt.hxx>
#include <vcl/txtattr.hxx>
#include <svtools/textwindowpeer.hxx>
#include <svtools/syntaxhighlight.hxx>
#include <vcl/taskpanelist.hxx>
#include <vcl/help.hxx>

namespace basctl
{

using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;

@@ -62,6 +66,12 @@ SbxVariable* IsSbxVariable (SbxBase* pBase)
    return 0;
}

Image GetImage (unsigned nId)
{
    static ImageList const aImagesNormal(IDEResId(RID_IMGLST_LAYOUT));
    return aImagesNormal.GetImage(nId);
}

} // namespace

#define SCROLL_LINE     12
@@ -99,7 +109,7 @@ void setTextEngineText( ExtTextEngine* pEngine, const ::rtl::OUString aStr )
    pEngine->Read( aMemStream );
}

void lcl_DrawIDEWindowFrame( DockingWindow* pWin )
void lcl_DrawIDEWindowFrame( BasicDockingWindow* pWin )
{
    if ( pWin->IsFloatingMode() )
        return;
@@ -147,6 +157,12 @@ void lcl_SeparateNameAndIndex( const String& rVName, String& rVar, String& rInde
    }
}


//
// EditorWindow
// ============
//

class EditorWindow::ChangesListener:
    public cppu::WeakImplHelper1< beans::XPropertiesChangeListener >
{
@@ -172,25 +188,21 @@ private:
    EditorWindow & editor_;
};

EditorWindow::EditorWindow( Window* pParent ) :
    Window( pParent, WB_BORDER )
EditorWindow::EditorWindow (Window* pParent, ModulWindow* pModulWindow) :
    Window(pParent, WB_BORDER),
    pEditView(0),
    pEditEngine(0),
    rModulWindow(*pModulWindow),
    nCurTextWidth(0),
    pProgress(0),
    bHighlightning(false),
    bDoSyntaxHighlight(true),
    bDelayHighlight(true)
{
    bDoSyntaxHighlight = true;
    bDelayHighlight = true;
    pModulWindow = 0;
    pEditView = 0;
    pEditEngine = 0;
    bHighlightning = false;
    pProgress = 0;
    nCurTextWidth = 0;
    SetBackground(
        Wallpaper(GetSettings().GetStyleSettings().GetFieldColor()));
    SetBackground(Wallpaper(GetSettings().GetStyleSettings().GetFieldColor()));
    SetPointer( Pointer( POINTER_TEXT ) );

    SetHelpId( HID_BASICIDE_EDITORWINDOW );

    // Using "this" in ctor is a little fishy, but should work here at least as
    // long as there are no derivations:
    listener_ = new ChangesListener(*this);
    Reference< beans::XMultiPropertySet > n(
        officecfg::Office::Common::Font::SourceViewFont::get(),
@@ -206,7 +218,6 @@ EditorWindow::EditorWindow( Window* pParent ) :
}



EditorWindow::~EditorWindow()
{
    Reference< beans::XMultiPropertySet > n;
@@ -364,8 +375,8 @@ void EditorWindow::Resize()
            aStartDocPos.Y() = nMaxVisAreaStart;
            pEditView->SetStartDocPos( aStartDocPos );
            pEditView->ShowCursor();
            pModulWindow->GetBreakPointWindow().GetCurYOffset() = aStartDocPos.Y();
            pModulWindow->GetLineNumberWindow().GetCurYOffset() = aStartDocPos.Y();
            rModulWindow.GetBreakPointWindow().GetCurYOffset() = aStartDocPos.Y();
            rModulWindow.GetLineNumberWindow().GetCurYOffset() = aStartDocPos.Y();
        }
        InitScrollBars();
        if ( nVisY != pEditView->GetStartDocPos().Y() )
@@ -410,7 +421,7 @@ void EditorWindow::Command( const CommandEvent& rCEvt )
             ( rCEvt.GetCommand() == COMMAND_STARTAUTOSCROLL ) ||
             ( rCEvt.GetCommand() == COMMAND_AUTOSCROLL ) )
        {
            HandleScrollCommand( rCEvt, pModulWindow->GetHScrollBar(), &pModulWindow->GetEditVScrollBar() );
            HandleScrollCommand( rCEvt, rModulWindow.GetHScrollBar(), &rModulWindow.GetEditVScrollBar() );
        }
    }
}
@@ -424,7 +435,7 @@ bool EditorWindow::ImpCanModify()
        // Remove markers in the modules in Notify at Basic::Stoped
        if ( QueryBox( 0, WB_OK_CANCEL, String( IDEResId( RID_STR_WILLSTOPPRG ) ) ).Execute() == RET_OK )
        {
            pModulWindow->GetBasicStatus().bIsRunning = false;
            rModulWindow.GetBasicStatus().bIsRunning = false;
            BasicIDE::StopBasic();
        }
        else
@@ -439,11 +450,11 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
        return;

#if OSL_DEBUG_LEVEL > 1
    Range aRange = pModulWindow->GetHScrollBar()->GetRange(); (void)aRange;
    long nVisSz = pModulWindow->GetHScrollBar()->GetVisibleSize(); (void)nVisSz;
    long nPapSz = pModulWindow->GetHScrollBar()->GetPageSize(); (void)nPapSz;
    long nLinSz = pModulWindow->GetHScrollBar()->GetLineSize(); (void)nLinSz;
    long nThumb = pModulWindow->GetHScrollBar()->GetThumbPos(); (void)nThumb;
    Range aRange = rModulWindow.GetHScrollBar()->GetRange(); (void)aRange;
    long nVisSz = rModulWindow.GetHScrollBar()->GetVisibleSize(); (void)nVisSz;
    long nPapSz = rModulWindow.GetHScrollBar()->GetPageSize(); (void)nPapSz;
    long nLinSz = rModulWindow.GetHScrollBar()->GetLineSize(); (void)nLinSz;
    long nThumb = rModulWindow.GetHScrollBar()->GetThumbPos(); (void)nThumb;
#endif
    bool const bWasModified = pEditEngine->IsModified();
    // see if there is an accelerator to be processed first
@@ -521,31 +532,14 @@ bool EditorWindow::SetSourceInBasic()
    {
        if ( !StarBASIC::IsRunning() ) // Not at runtime!
        {
            ::rtl::OUString aModule = getTextEngineText( pEditEngine );

            // update module in basic
#ifdef DBG_UTIL
            SbModule* pModule = pModulWindow->GetSbModule();
#endif
            DBG_ASSERT(pModule, "EditorWindow::SetSourceInBasic: No Module found!");

            // update module in module window
            pModulWindow->SetModule( aModule );

            // update module in library
            ScriptDocument aDocument( pModulWindow->GetDocument() );
            String aLibName = pModulWindow->GetLibName();
            String aName = pModulWindow->GetName();
            OSL_VERIFY( aDocument.updateModule( aLibName, aName, aModule ) );

            pEditEngine->SetModified(false);
            BasicIDE::MarkDocumentModified( aDocument );
            rModulWindow.UpdateModule();
            bChanged = true;
        }
    }
    return bChanged;
}

} // namespace basctl

// Returns the position of the last character of any of the following
// EOL char combinations: CR, CR/LF, LF, return -1 if no EOL is found
@@ -566,6 +560,9 @@ sal_Int32 searchEOL( const ::rtl::OUString& rStr, sal_Int32 fromIndex )
}


namespace basctl
{

void EditorWindow::CreateEditEngine()
{
    if ( pEditEngine )
@@ -586,7 +583,7 @@ void EditorWindow::CreateEditEngine()

    bool bWasDoSyntaxHighlight = bDoSyntaxHighlight;
    bDoSyntaxHighlight = false; // too slow for large texts...
    ::rtl::OUString aOUSource( pModulWindow->GetModule() );
    rtl::OUString aOUSource(rModulWindow.GetModule());
    sal_Int32 nLines = 0;
    sal_Int32 nIndex = -1;
    do
@@ -604,15 +601,10 @@ void EditorWindow::CreateEditEngine()

    pEditView->SetStartDocPos( Point( 0, 0 ) );
    pEditView->SetSelection( TextSelection() );
    pModulWindow->GetBreakPointWindow().GetCurYOffset() = 0;
    pModulWindow->GetLineNumberWindow().GetCurYOffset() = 0;
    rModulWindow.GetBreakPointWindow().GetCurYOffset() = 0;
    rModulWindow.GetLineNumberWindow().GetCurYOffset() = 0;
    pEditEngine->SetUpdateMode(true);
    Update();   // has only been invalidated at UpdateMode = true

    pModulWindow->GetLayout()->GetWatchWindow().Update();
    pModulWindow->GetLayout()->GetStackWindow().Update();
    pModulWindow->GetBreakPointWindow().Update();
    pModulWindow->GetLineNumberWindow().Update();
    rModulWindow.Update();   // has only been invalidated at UpdateMode = true

    pEditView->ShowCursor( true, true );

@@ -638,19 +630,19 @@ void EditorWindow::CreateEditEngine()
    if ( pBindings )
        pBindings->Invalidate( SID_BASICIDE_STAT_POS );

    DBG_ASSERT( pModulWindow->GetBreakPointWindow().GetCurYOffset() == 0, "CreateEditEngine: Brechpunkte verschoben?" );
    DBG_ASSERT( rModulWindow.GetBreakPointWindow().GetCurYOffset() == 0, "CreateEditEngine: Brechpunkte verschoben?" );

    // set readonly mode for readonly libraries
    ScriptDocument aDocument( pModulWindow->GetDocument() );
    ::rtl::OUString aOULibName( pModulWindow->GetLibName() );
    ScriptDocument aDocument(rModulWindow.GetDocument());
    rtl::OUString aOULibName(rModulWindow.GetLibName());
    Reference< script::XLibraryContainer2 > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
    if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && xModLibContainer->isLibraryReadOnly( aOULibName ) )
    {
        pModulWindow->SetReadOnly(true);
        rModulWindow.SetReadOnly(true);
    }

    if ( aDocument.isDocument() && aDocument.isReadOnly() )
        pModulWindow->SetReadOnly(true);
        rModulWindow.SetReadOnly(true);
}

// virtual
@@ -688,13 +680,13 @@ void EditorWindow::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
        TextHint const& rTextHint = *pTextHint;
        if( rTextHint.GetId() == TEXT_HINT_VIEWSCROLLED )
        {
            if ( pModulWindow->GetHScrollBar() )
                pModulWindow->GetHScrollBar()->SetThumbPos( pEditView->GetStartDocPos().X() );
            pModulWindow->GetEditVScrollBar().SetThumbPos( pEditView->GetStartDocPos().Y() );
            pModulWindow->GetBreakPointWindow().DoScroll
                ( 0, pModulWindow->GetBreakPointWindow().GetCurYOffset() - pEditView->GetStartDocPos().Y() );
            pModulWindow->GetLineNumberWindow().DoScroll
                ( 0, pModulWindow->GetLineNumberWindow().GetCurYOffset() - pEditView->GetStartDocPos().Y() );
            if ( rModulWindow.GetHScrollBar() )
                rModulWindow.GetHScrollBar()->SetThumbPos( pEditView->GetStartDocPos().X() );
            rModulWindow.GetEditVScrollBar().SetThumbPos( pEditView->GetStartDocPos().Y() );
            rModulWindow.GetBreakPointWindow().DoScroll
                ( 0, rModulWindow.GetBreakPointWindow().GetCurYOffset() - pEditView->GetStartDocPos().Y() );
            rModulWindow.GetLineNumberWindow().DoScroll
                ( 0, rModulWindow.GetLineNumberWindow().GetCurYOffset() - pEditView->GetStartDocPos().Y() );
        }
        else if( rTextHint.GetId() == TEXT_HINT_TEXTHEIGHTCHANGED )
        {
@@ -705,21 +697,21 @@ void EditorWindow::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
                if ( nTextHeight < nOutHeight )
                    pEditView->Scroll( 0, pEditView->GetStartDocPos().Y() );

                pModulWindow->GetLineNumberWindow().Invalidate();
                rModulWindow.GetLineNumberWindow().Invalidate();
            }

            SetScrollBarRanges();
        }
        else if( rTextHint.GetId() == TEXT_HINT_TEXTFORMATTED )
        {
            if ( pModulWindow->GetHScrollBar() )
            if ( rModulWindow.GetHScrollBar() )
            {
                sal_uLong nWidth = pEditEngine->CalcTextWidth();
                if ( (long)nWidth != nCurTextWidth )
                {
                    nCurTextWidth = nWidth;
                    pModulWindow->GetHScrollBar()->SetRange( Range( 0, (long)nCurTextWidth-1) );
                    pModulWindow->GetHScrollBar()->SetThumbPos( pEditView->GetStartDocPos().X() );
                    rModulWindow.GetHScrollBar()->SetRange( Range( 0, (long)nCurTextWidth-1) );
                    rModulWindow.GetHScrollBar()->SetThumbPos( pEditView->GetStartDocPos().X() );
                }
            }
            long nPrevTextWidth = nCurTextWidth;
@@ -749,10 +741,10 @@ void EditorWindow::SetScrollBarRanges()
    if ( !pEditEngine )
        return;

    if ( pModulWindow->GetHScrollBar() )
        pModulWindow->GetHScrollBar()->SetRange( Range( 0, nCurTextWidth-1 ) );
    if ( rModulWindow.GetHScrollBar() )
        rModulWindow.GetHScrollBar()->SetRange( Range( 0, nCurTextWidth-1 ) );

    pModulWindow->GetEditVScrollBar().SetRange( Range( 0, pEditEngine->GetTextHeight()-1 ) );
    rModulWindow.GetEditVScrollBar().SetRange( Range( 0, pEditEngine->GetTextHeight()-1 ) );
}

void EditorWindow::InitScrollBars()
@@ -762,19 +754,19 @@ void EditorWindow::InitScrollBars()

    SetScrollBarRanges();
    Size aOutSz( GetOutputSizePixel() );
    pModulWindow->GetEditVScrollBar().SetVisibleSize( aOutSz.Height() );
    pModulWindow->GetEditVScrollBar().SetPageSize( aOutSz.Height() * 8 / 10 );
    pModulWindow->GetEditVScrollBar().SetLineSize( GetTextHeight() );
    pModulWindow->GetEditVScrollBar().SetThumbPos( pEditView->GetStartDocPos().Y() );
    pModulWindow->GetEditVScrollBar().Show();
    rModulWindow.GetEditVScrollBar().SetVisibleSize( aOutSz.Height() );
    rModulWindow.GetEditVScrollBar().SetPageSize( aOutSz.Height() * 8 / 10 );
    rModulWindow.GetEditVScrollBar().SetLineSize( GetTextHeight() );
    rModulWindow.GetEditVScrollBar().SetThumbPos( pEditView->GetStartDocPos().Y() );
    rModulWindow.GetEditVScrollBar().Show();

    if ( pModulWindow->GetHScrollBar() )
    if ( rModulWindow.GetHScrollBar() )
    {
        pModulWindow->GetHScrollBar()->SetVisibleSize( aOutSz.Width() );
        pModulWindow->GetHScrollBar()->SetPageSize( aOutSz.Width() * 8 / 10 );
        pModulWindow->GetHScrollBar()->SetLineSize( GetTextWidth( rtl::OUString('x') ) );
        pModulWindow->GetHScrollBar()->SetThumbPos( pEditView->GetStartDocPos().X() );
        pModulWindow->GetHScrollBar()->Show();
        rModulWindow.GetHScrollBar()->SetVisibleSize( aOutSz.Width() );
        rModulWindow.GetHScrollBar()->SetPageSize( aOutSz.Width() * 8 / 10 );
        rModulWindow.GetHScrollBar()->SetLineSize( GetTextWidth( rtl::OUString('x') ) );
        rModulWindow.GetHScrollBar()->SetThumbPos( pEditView->GetStartDocPos().X() );
        rModulWindow.GetHScrollBar()->Show();
    }
}

@@ -799,14 +791,21 @@ void EditorWindow::ImpDoHighlight( sal_uLong nLine )
        for ( size_t i = 0; i < aPortions.size(); i++ )
        {
            HighlightPortion& r = aPortions[i];
            const Color& rColor = dynamic_cast<ModulWindowLayout*>(pModulWindow->GetLayoutWindow())->getSyntaxColor(r.tokenType);
            pEditEngine->SetAttrib( TextAttribFontColor( rColor ), nLine, r.nBegin, r.nEnd, true );
            Color const aColor = rModulWindow.GetLayout().GetSyntaxColor(r.tokenType);
            pEditEngine->SetAttrib( TextAttribFontColor(aColor), nLine, r.nBegin, r.nEnd, true );
        }

        pEditEngine->SetModified( bWasModified );
    }
}

void EditorWindow::UpdateSyntaxHighlighting ()
{
    unsigned nCount = pEditEngine->GetParagraphCount();
    for (unsigned i = 0; i < nCount; ++i)
        DoDelayedSyntaxHighlight(i);
}

void EditorWindow::ImplSetFont()
{
    rtl::OUString sFontName(
@@ -817,18 +816,14 @@ void EditorWindow::ImplSetFont()
        Font aTmpFont( OutputDevice::GetDefaultFont( DEFAULTFONT_FIXED, Application::GetSettings().GetUILanguage(), 0 , this ) );
        sFontName = aTmpFont.GetName();
    }
    Size aFontSize(
        0, officecfg::Office::Common::Font::SourceViewFont::FontHeight::get() );
    Size aFontSize(0, officecfg::Office::Common::Font::SourceViewFont::FontHeight::get());
    Font aFont( sFontName, aFontSize );
    aFont.SetColor( GetSettings().GetStyleSettings().GetFieldTextColor() );
    SetPointFont( aFont );
    aFont = GetFont();

    if ( pModulWindow )
    {
        pModulWindow->GetBreakPointWindow().SetFont( aFont );
        pModulWindow->GetLineNumberWindow().SetFont( aFont );
    }
    rModulWindow.GetBreakPointWindow().SetFont( aFont );
    rModulWindow.GetLineNumberWindow().SetFont( aFont );

    if ( pEditEngine )
    {
@@ -904,26 +899,26 @@ void EditorWindow::ParagraphInsertedDeleted( sal_uLong nPara, bool bInserted )

    if ( !bInserted && ( nPara == TEXT_PARA_ALL ) )
    {
        pModulWindow->GetBreakPoints().reset();
        pModulWindow->GetBreakPointWindow().Invalidate();
        pModulWindow->GetLineNumberWindow().Invalidate();
        rModulWindow.GetBreakPoints().reset();
        rModulWindow.GetBreakPointWindow().Invalidate();
        rModulWindow.GetLineNumberWindow().Invalidate();
        aHighlighter.initialize( HIGHLIGHT_BASIC );
    }
    else
    {
        pModulWindow->GetBreakPoints().AdjustBreakPoints( (sal_uInt16)nPara+1, bInserted );
        rModulWindow.GetBreakPoints().AdjustBreakPoints( (sal_uInt16)nPara+1, bInserted );

        long nLineHeight = GetTextHeight();
        Size aSz = pModulWindow->GetBreakPointWindow().GetOutputSize();
        Size aSz = rModulWindow.GetBreakPointWindow().GetOutputSize();
        Rectangle aInvRec( Point( 0, 0 ), aSz );
        long nY = nPara*nLineHeight - pModulWindow->GetBreakPointWindow().GetCurYOffset();
        long nY = nPara*nLineHeight - rModulWindow.GetBreakPointWindow().GetCurYOffset();
        aInvRec.Top() = nY;
        pModulWindow->GetBreakPointWindow().Invalidate( aInvRec );
        rModulWindow.GetBreakPointWindow().Invalidate( aInvRec );

        Size aLnSz(pModulWindow->GetLineNumberWindow().GetWidth(),
        Size aLnSz(rModulWindow.GetLineNumberWindow().GetWidth(),
                   GetOutputSizePixel().Height() - 2 * DWBORDER);
        pModulWindow->GetLineNumberWindow().SetPosSizePixel(Point(DWBORDER + 19, DWBORDER), aLnSz);
        pModulWindow->GetLineNumberWindow().Invalidate();
        rModulWindow.GetLineNumberWindow().SetPosSizePixel(Point(DWBORDER + 19, DWBORDER), aLnSz);
        rModulWindow.GetLineNumberWindow().Invalidate();

        if ( bDoSyntaxHighlight )
        {
@@ -951,22 +946,21 @@ void EditorWindow::ForceSyntaxTimeout()
}


//
// BreakPointWindow
// ================
//

BreakPointWindow::BreakPointWindow( Window* pParent ) :
    Window( pParent, WB_BORDER )
BreakPointWindow::BreakPointWindow (Window* pParent, ModulWindow* pModulWindow) :
    Window(pParent, WB_BORDER),
    rModulWindow(*pModulWindow),
    nCurYOffset(0), // memorize nCurYOffset and not take it from EditEngine
    nMarkerPos(MARKER_NOMARKER)
{
    pModulWindow = 0;
    nCurYOffset = 0;
    setBackgroundColor(GetSettings().GetStyleSettings().GetFieldColor());
    nMarkerPos = MARKER_NOMARKER;

    // memorize nCurYOffset and not take it from EditEngine

    SetHelpId( HID_BASICIDE_BREAKPOINTWINDOW );
    SetHelpId(HID_BASICIDE_BREAKPOINTWINDOW);
}



BreakPointWindow::~BreakPointWindow()
{
}
@@ -985,27 +979,24 @@ void BreakPointWindow::Paint( const Rectangle& )
    if ( SyncYOffset() )
        return;

    Size aOutSz( GetOutputSize() );
    long nLineHeight = GetTextHeight();
    Size const aOutSz = GetOutputSize();
    long const nLineHeight = GetTextHeight();

    ModulWindowLayout* pModulWindowLayout = dynamic_cast<ModulWindowLayout*>(pModulWindow->GetLayoutWindow());
    Image const aBrk[2] = { GetImage(IMGID_BRKDISABLED), GetImage(IMGID_BRKENABLED) };
    Size const aBmpSz = PixelToLogic(aBrk[1].GetSizePixel());
    Point const aBmpOff(
        (aOutSz.Width() - aBmpSz.Width()) / 2,
        (nLineHeight - aBmpSz.Height()) / 2
    );

    Image aBrk1(pModulWindowLayout->getImage(IMGID_BRKENABLED));
    Image aBrk0(pModulWindowLayout->getImage(IMGID_BRKDISABLED));
    Size aBmpSz( aBrk1.GetSizePixel() );
    aBmpSz = PixelToLogic( aBmpSz );
    Point aBmpOff( 0, 0 );
    aBmpOff.X() = ( aOutSz.Width() - aBmpSz.Width() ) / 2;
    aBmpOff.Y() = ( nLineHeight - aBmpSz.Height() ) / 2;

    for ( size_t i = 0, n = GetBreakPoints().size(); i < n ; ++i )
    for (size_t i = 0, n = GetBreakPoints().size(); i < n; ++i)
    {
        BreakPoint* pBrk = GetBreakPoints().at( i );
        size_t nLine = pBrk->nLine-1;
        size_t nY = nLine*nLineHeight - nCurYOffset;
        DrawImage( Point( 0, nY ) + aBmpOff, pBrk->bEnabled ? aBrk1 : aBrk0 );
        BreakPoint& rBrk = *GetBreakPoints().at(i);
        size_t const nLine = rBrk.nLine - 1;
        size_t const nY = nLine*nLineHeight - nCurYOffset;
        DrawImage(Point(0, nY) + aBmpOff, aBrk[rBrk.bEnabled]);
    }
    ShowMarker( true );
    ShowMarker(true);
}


@@ -1034,11 +1025,10 @@ void BreakPointWindow::ShowMarker( bool bShow )
    if ( nMarkerPos == MARKER_NOMARKER )
        return;

    Size aOutSz( GetOutputSize() );
    long nLineHeight = GetTextHeight();
    Size const aOutSz = GetOutputSize();
    long const nLineHeight = GetTextHeight();

    ModulWindowLayout* pModulWindowLayout = dynamic_cast<ModulWindowLayout*>(pModulWindow->GetLayoutWindow());
    Image aMarker(pModulWindowLayout->getImage(bErrorMarker ? IMGID_ERRORMARKER : IMGID_STEPMARKER));
    Image aMarker = GetImage(bErrorMarker ? IMGID_ERRORMARKER : IMGID_STEPMARKER);

    Size aMarkerSz( aMarker.GetSizePixel() );
    aMarkerSz = PixelToLogic( aMarkerSz );
@@ -1082,7 +1072,7 @@ void BreakPointWindow::MouseButtonDown( const MouseEvent& rMEvt )
        long nLineHeight = GetTextHeight();
        long nYPos = aMousePos.Y() + nCurYOffset;
        long nLine = nYPos / nLineHeight + 1;
        pModulWindow->ToggleBreakPoint( (sal_uLong)nLine );
        rModulWindow.ToggleBreakPoint( (sal_uLong)nLine );
        Invalidate();
    }
}
@@ -1106,7 +1096,7 @@ void BreakPointWindow::Command( const CommandEvent& rCEvt )
                case RID_ACTIV:
                {
                    pBrk->bEnabled = !pBrk->bEnabled;
                    pModulWindow->UpdateBreakPoint( *pBrk );
                    rModulWindow.UpdateBreakPoint( *pBrk );
                    Invalidate();
                }
                break;
@@ -1139,7 +1129,7 @@ void BreakPointWindow::Command( const CommandEvent& rCEvt )

bool BreakPointWindow::SyncYOffset()
{
    TextView* pView = pModulWindow->GetEditView();
    TextView* pView = rModulWindow.GetEditView();
    if ( pView )
    {
        long nViewYOffset = pView->GetStartDocPos().Y();
@@ -1176,12 +1166,20 @@ void BreakPointWindow::setBackgroundColor(Color aColor)
}


const sal_uInt16 ITEM_ID_VARIABLE = 1;
const sal_uInt16 ITEM_ID_VALUE = 2;
const sal_uInt16 ITEM_ID_TYPE = 3;
//
// WatchWindow
// ===========
//

WatchWindow::WatchWindow( Window* pParent ) :
    BasicDockingWindow( pParent ),
namespace
{
    const sal_uInt16 ITEM_ID_VARIABLE = 1;
    const sal_uInt16 ITEM_ID_VALUE = 2;
    const sal_uInt16 ITEM_ID_TYPE = 3;
}

WatchWindow::WatchWindow (Layout* pParent) :
    BasicDockingWindow(pParent),
    aWatchStr( IDEResId( RID_STR_REMOVEWATCH ) ),
    aXEdit( this, IDEResId( RID_EDT_WATCHEDIT ) ),
    aRemoveWatchButton( this, IDEResId( RID_IMGBTN_REMOVEWATCH ) ),
@@ -1406,6 +1404,8 @@ void WatchWindow::AddWatch( const String& rVName )
    aTreeListBox.Select(pNewEntry, true);
    aTreeListBox.MakeVisible(pNewEntry);
    aRemoveWatchButton.Enable();

    UpdateWatches();
}

bool WatchWindow::RemoveSelectedWatch()
@@ -1503,7 +1503,6 @@ IMPL_LINK( WatchWindow, EditAccHdl, Accelerator *, pAcc )
            {
                AddWatch( aCurText );
                aXEdit.SetSelection( Selection( 0, 0xFFFF ) );
                UpdateWatches();
            }
        }
        break;
@@ -1523,8 +1522,13 @@ void WatchWindow::UpdateWatches( bool bBasicStopped )
}


StackWindow::StackWindow( Window* pParent ) :
    BasicDockingWindow( pParent ),
//
// StackWindow
// ===========
//

StackWindow::StackWindow (Layout* pParent) :
    BasicDockingWindow(pParent),
    aTreeListBox( this, WB_BORDER | WB_3DLOOK | WB_HSCROLL | WB_TABSTOP ),
    aStackStr( IDEResId( RID_STR_STACK ) )
{
@@ -1642,17 +1646,19 @@ void StackWindow::UpdateCalls()
    aTreeListBox.SetUpdateMode(true);
}


//
// ComplexEditorWindow
// ===================
//

ComplexEditorWindow::ComplexEditorWindow( ModulWindow* pParent ) :
    Window( pParent, WB_3DLOOK | WB_CLIPCHILDREN ),
    aBrkWindow( this ),
    aLineNumberWindow( this, pParent ),
    aEdtWindow( this ),
    aEWVScrollBar( this, WB_VSCROLL | WB_DRAG ),
    bLineNumberDisplay(false),
    bObjectCatalogDisplay(true)
    aBrkWindow(this, pParent),
    aLineNumberWindow(this, pParent),
    aEdtWindow(this, pParent),
    aEWVScrollBar( this, WB_VSCROLL | WB_DRAG )
{
    aEdtWindow.SetModulWindow( pParent );
    aBrkWindow.SetModulWindow( pParent );
    aEdtWindow.Show();
    aBrkWindow.Show();

@@ -1675,7 +1681,7 @@ void ComplexEditorWindow::Resize()

    Size aLnSz(aLineNumberWindow.GetWidth(), aSz.Height());

    if(bLineNumberDisplay)
    if (aLineNumberWindow.IsVisible())
    {
        aBrkWindow.SetPosSizePixel( Point( DWBORDER, DWBORDER ), aBrkSz );
        aLineNumberWindow.SetPosSizePixel(Point(DWBORDER + aBrkSz.Width() - 1, DWBORDER), aLnSz);
@@ -1726,18 +1732,7 @@ void ComplexEditorWindow::DataChanged(DataChangedEvent const & rDCEvt)

void ComplexEditorWindow::SetLineNumberDisplay(bool b)
{
    bLineNumberDisplay = b;
    Resize();

    if(b)
        aLineNumberWindow.Show();
    else
        aLineNumberWindow.Hide();
}

void ComplexEditorWindow::SetObjectCatalogDisplay(bool b)
{
    bObjectCatalogDisplay = b;
    aLineNumberWindow.Show(b);
    Resize();
}

@@ -1758,6 +1753,12 @@ EditorWindow::GetComponentInterface(sal_Bool bCreate)
    return xPeer;
}


//
// WatchTreeListBox
// ================
//

WatchTreeListBox::WatchTreeListBox( Window* pParent, WinBits nWinBits )
    : SvHeaderTabListBox( pParent, nWinBits )
{}
@@ -2251,4 +2252,7 @@ void WatchTreeListBox::UpdateWatches( bool bBasicStopped )
    setBasicWatchMode( false );
}


} // namespace basctl

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/baside3.cxx b/basctl/source/basicide/baside3.cxx
index adf4581..951b5be 100644
--- a/basctl/source/basicide/baside3.cxx
+++ b/basctl/source/basicide/baside3.cxx
@@ -32,6 +32,7 @@
#include "idetemp.hxx"
#include "localizationmgr.hxx"
#include "propbrw.hxx"
#include "objdlg.hxx"

#include <basic/basmgr.hxx>
#include <com/sun/star/resource/StringResourceWithLocation.hpp>
@@ -46,6 +47,7 @@
#include <sfx2/dispatch.hxx>
#include <sfx2/request.hxx>
#include <svl/aeitem.hxx>
#include <svl/visitem.hxx>
#include <svl/whiter.hxx>
#include <tools/diagnose_ex.h>
#include <tools/urlobj.hxx>
@@ -59,6 +61,9 @@ using namespace ::com::sun::star::io;
using namespace ::com::sun::star::resource;
using namespace ::com::sun::star::ui::dialogs;

namespace basctl
{

#if defined(UNX)
#define FILTERMASK_ALL "*"
#else
@@ -69,10 +74,15 @@ DBG_NAME( DialogWindow )

TYPEINIT1( DialogWindow, IDEBaseWindow );

DialogWindow::DialogWindow( Window* pParent, const ScriptDocument& rDocument, ::rtl::OUString aLibName, ::rtl::OUString aName,
    const com::sun::star::uno::Reference< com::sun::star::container::XNameContainer >& xDialogModel )
        :IDEBaseWindow( pParent, rDocument, aLibName, aName )
        ,pUndoMgr(NULL)
DialogWindow::DialogWindow (
    DialogWindowLayout* pParent,
    ScriptDocument const& rDocument,
    rtl::OUString aLibName, rtl::OUString aName,
    com::sun::star::uno::Reference<com::sun::star::container::XNameContainer> const& xDialogModel
) :
    IDEBaseWindow(pParent, rDocument, aLibName, aName),
    rLayout(*pParent),
    pUndoMgr(0)
{
    InitSettings( true, true, true );

@@ -395,12 +405,19 @@ void DialogWindow::GetState( SfxItemSet& rSet )
                    rSet.DisableItem( nWh );
            }
            break;
            case SID_SHOWLINES:
            {
                // if this is not a module window hide the
                // setting, doesn't make sense for example if the
                // dialog editor is open
                rSet.DisableItem(nWh);
                rSet.Put(SfxVisibilityItem(nWh, false));
                break;
            }
        }
    }
}



void DialogWindow::ExecuteCommand( SfxRequest& rReq )
{
    switch ( rReq.GetSlot() )
@@ -647,6 +664,17 @@ void DialogWindow::ExecuteCommand( SfxRequest& rReq )
        case SID_IMPORT_DIALOG:
            ImportDialog();
            break;

        case SID_BASICIDE_DELETECURRENT:
            if (QueryDelDialog(m_aName, this))
            {
                if (BasicIDE::RemoveDialog(m_aDocument, m_aLibName, m_aName))
                {
                    BasicIDE::MarkDocumentModified(m_aDocument);
                    BasicIDEGlobals::GetShell()->RemoveWindow(this, true);
                }
            }
            break;
    }

    rReq.Done();
@@ -865,6 +893,9 @@ bool DialogWindow::SaveDialog()
    return bDone;
}

} // namespace basctl


extern bool localesAreEqual( const ::com::sun::star::lang::Locale& rLocaleLeft,
                             const ::com::sun::star::lang::Locale& rLocaleRight );

@@ -952,6 +983,7 @@ LanguageMismatchQueryBox::LanguageMismatchQueryBox( Window* pParent,
    SetImage( QueryBox::GetStandardImage() );
}


bool implImportDialog( Window* pWin, const ::rtl::OUString& rCurPath, const ScriptDocument& rDocument, const ::rtl::OUString& aLibName )
{
    bool bDone = false;
@@ -1239,7 +1271,7 @@ bool implImportDialog( Window* pWin, const ::rtl::OUString& rCurPath, const Scri
            bool bSuccess = rDocument.insertDialog( aLibName, aNewDlgName, xISP );
            if( bSuccess )
            {
                DialogWindow* pNewDlgWin = pIDEShell->CreateDlgWin( rDocument, aLibName, aNewDlgName );
                basctl::DialogWindow* pNewDlgWin = pIDEShell->CreateDlgWin( rDocument, aLibName, aNewDlgName );
                pIDEShell->SetCurWindow( pNewDlgWin, true );
            }

@@ -1252,6 +1284,10 @@ bool implImportDialog( Window* pWin, const ::rtl::OUString& rCurPath, const Scri
    return bDone;
}


namespace basctl
{

bool DialogWindow::ImportDialog()
{
    DBG_CHKTHIS( DialogWindow, 0 );
@@ -1348,10 +1384,18 @@ void DialogWindow::StoreData()
    }
}

void DialogWindow::Activating ()
{
    UpdateBrowser();
    Show();
}

void DialogWindow::Deactivating()
{
    Hide();
    if ( IsModified() )
        BasicIDE::MarkDocumentModified( GetDocument() );
    DisableBrowser();
}

sal_Int32 DialogWindow::countPages( Printer* pPrinter )
@@ -1400,4 +1444,60 @@ void DialogWindow::InitSettings(bool bFont, bool bForeground, bool bBackground)
    return (::com::sun::star::accessibility::XAccessible*) new AccessibleDialogWindow( this );
}

char const* DialogWindow::GetHid () const
{
    return HID_BASICIDE_DIALOGWINDOW;
}
BasicIDEType DialogWindow::GetType () const
{
    return BASICIDE_TYPE_DIALOG;
}


//
// DialogWindowLayout
// ==================
//

DialogWindowLayout::DialogWindowLayout (Window* pParent, ObjectCatalog& rObjectCatalog_) :
    Layout(pParent),
    pChild(0),
    rObjectCatalog(rObjectCatalog_)
{ }

void DialogWindowLayout::Activating (IDEBaseWindow& rChild)
{
    assert(dynamic_cast<DialogWindow*>(&rChild));
    pChild = &static_cast<DialogWindow&>(rChild);
    rObjectCatalog.SetLayoutWindow(this);
    rObjectCatalog.UpdateEntries();
    rObjectCatalog.Show();
    Layout::Activating(rChild);
}

void DialogWindowLayout::Deactivating ()
{
    Layout::Deactivating();
    rObjectCatalog.Hide();
    pChild = 0;
}

void DialogWindowLayout::GetState (SfxItemSet& rSet, unsigned nWhich)
{
    switch (nWhich)
    {
        case SID_BASICIDE_CHOOSEMACRO:
            rSet.Put(SfxVisibilityItem(nWhich, false));
            break;
    }
}

void DialogWindowLayout::OnFirstSize (int const nWidth, int const nHeight)
{
    AddToLeft(&rObjectCatalog, Size(nWidth * 0.2, nHeight));
}


} // namespace basctl

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/basides1.cxx b/basctl/source/basicide/basides1.cxx
index 97447f4..841c4bc 100644
--- a/basctl/source/basicide/basides1.cxx
+++ b/basctl/source/basicide/basides1.cxx
@@ -30,7 +30,6 @@
#include "iderdll2.hxx"
#include "localizationmgr.hxx"
#include "managelang.hxx"
#include "moduldlg.hxx"

#include <basic/basmgr.hxx>
#include <basic/sbmeth.hxx>
@@ -57,18 +56,10 @@ using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::frame;

// until we have some configuration lets just keep
// persist this value for the process lifetime
bool& lcl_GetSourceLinesEnabledValue()
{
    static bool bSourceLinesEnabled(false);
    return bSourceLinesEnabled;
}

bool  BasicIDEShell::SourceLinesDisplayed()
{
    return lcl_GetSourceLinesEnabledValue();
}
using basctl::ModulWindow;
using basctl::ModulWindowLayout;
using basctl::DialogWindow;
using basctl::DialogWindowLayout;

void BasicIDEShell::ExecuteCurrent( SfxRequest& rReq )
{
@@ -77,51 +68,12 @@ void BasicIDEShell::ExecuteCurrent( SfxRequest& rReq )

    switch ( rReq.GetSlot() )
    {
        case SID_SHOWLINES:
        {
            SFX_REQUEST_ARG(rReq, pItem, SfxBoolItem, rReq.GetSlot(), false);
            bool const bValue = pItem && pItem->GetValue();
            lcl_GetSourceLinesEnabledValue() = bValue;
            if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin))
                pMCurWin->SetLineNumberDisplay(bValue);
        }
        break;

        case SID_BASICIDE_HIDECURPAGE:
        {
            pCurWin->StoreData();
            RemoveWindow( pCurWin, false );
        }
        break;
        case SID_BASICIDE_DELETECURRENT:
        {
            ScriptDocument aDocument( pCurWin->GetDocument() );
            ::rtl::OUString aLibName = pCurWin->GetLibName();
            ::rtl::OUString aName = pCurWin->GetName();

            if (dynamic_cast<ModulWindow*>(pCurWin))
            {
                if ( QueryDelModule( aName, pCurWin ) )
                {
                    if ( aDocument.removeModule( aLibName, aName ) )
                    {
                        BasicIDE::MarkDocumentModified( aDocument );
                    }
                }
            }
            else
            {
                if ( QueryDelDialog( aName, pCurWin ) )
                {
                    if ( BasicIDE::RemoveDialog( aDocument, aLibName, aName ) )
                    {
                        RemoveWindow( pCurWin, true );
                        BasicIDE::MarkDocumentModified( aDocument );
                    }
                }
            }
        }
        break;
        case SID_BASICIDE_RENAMECURRENT:
        {
            pTabBar->StartEditMode( pTabBar->GetCurPageId() );
@@ -129,162 +81,122 @@ void BasicIDEShell::ExecuteCurrent( SfxRequest& rReq )
        break;
        case FID_SEARCH_NOW:
        {
            if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin))
            if (!pCurWin->HasActiveEditor())
                break;
            DBG_ASSERT( rReq.GetArgs(), "arguments expected" );
            SfxItemSet const& rArgs = *rReq.GetArgs();
            // unfortunately I don't know the ID:
            sal_uInt16 nWhich = rArgs.GetWhichByPos( 0 );
            DBG_ASSERT( nWhich, "Wich fuer SearchItem ?" );
            SfxPoolItem const& rItem = rArgs.Get(nWhich);
            DBG_ASSERT(dynamic_cast<SvxSearchItem const*>(&rItem), "no searchitem!");
            SvxSearchItem const& rSearchItem = static_cast<SvxSearchItem const&>(rItem);
            // memorize item because of the adjustments...
            BasicIDEGlobals::GetExtraData()->SetSearchItem(rSearchItem);
            sal_Int32 nFound = 0;
            bool bCanceled = false;
            if (rSearchItem.GetCommand() == SVX_SEARCHCMD_REPLACE_ALL)
            {
                DBG_ASSERT( rReq.GetArgs(), "arguments expected" );
                const SfxItemSet* pArgs = rReq.GetArgs();
                // unfortunately I don't know the ID:
                sal_uInt16 nWhich = pArgs->GetWhichByPos( 0 );
                DBG_ASSERT( nWhich, "Wich fuer SearchItem ?" );
                const SfxPoolItem& rItem = pArgs->Get( nWhich );
                IDEWindowTable::const_iterator it;
                if (SvxSearchItem const* pSearchItem = dynamic_cast<SvxSearchItem const*>(&rItem))
                sal_uInt16 nActModWindows = 0;
                for (WindowTableIt it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it)
                {
                    // memorize item because of the adjustments...
                    BasicIDEGlobals::GetExtraData()->SetSearchItem(*pSearchItem);
                    sal_Int32 nFound = 0;
                    bool bCanceled = false;
                    if (pSearchItem->GetCommand() == SVX_SEARCHCMD_REPLACE_ALL)
                    IDEBaseWindow* pWin = it->second;
                    if (pWin->HasActiveEditor())
                        nActModWindows++;
                }

                if ( nActModWindows <= 1 || ( !rSearchItem.GetSelection() && QueryBox( pCurWin, WB_YES_NO|WB_DEF_YES, String(IDEResId(RID_STR_SEARCHALLMODULES)) ).Execute() == RET_YES ) )
                {
                    for (WindowTableIt it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it)
                    {
                        sal_uInt16 nActModWindows = 0;
                        for( it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it )
                        {
                            IDEBaseWindow* pWin = it->second;
                            if (!pWin->IsSuspended() && dynamic_cast<ModulWindow*>(pWin))
                                nActModWindows++;
                        }

                        if ( ( nActModWindows <= 1 ) || ( !pSearchItem->GetSelection() && QueryBox( pCurWin, WB_YES_NO|WB_DEF_YES, String( IDEResId( RID_STR_SEARCHALLMODULES ) ) ).Execute() == RET_YES ) )
                        {
                            for( it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it )
                            {
                                IDEBaseWindow* pWin = it->second;
                                if (!pWin->IsSuspended())
                                    if (ModulWindow* pMWin = dynamic_cast<ModulWindow*>(pWin))
                                        nFound += pMWin->StartSearchAndReplace(*pSearchItem);
                            }
                        }
                        else
                            nFound = pMCurWin->StartSearchAndReplace(*pSearchItem);

                        ::rtl::OUString aReplStr(IDE_RESSTR(RID_STR_SEARCHREPLACES));
                        aReplStr = aReplStr.replaceAll("XX", rtl::OUString::valueOf(nFound));
                        InfoBox( pCurWin, aReplStr ).Execute();
                        IDEBaseWindow* pWin = it->second;
                        nFound += pWin->StartSearchAndReplace(rSearchItem);
                    }
                    else
                    {
                        nFound = pMCurWin->StartSearchAndReplace(*pSearchItem);
                        if ( !nFound && !pSearchItem->GetSelection() )
                        {
                            // search other modules...
                            bool bChangeCurWindow = false;
                            for( it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it )
                                if ( it->second == pCurWin)
                                    break;
                            if ( it != aIDEWindowTable.end() )
                                ++it;
                            IDEBaseWindow* pWin = NULL;
                            if ( it != aIDEWindowTable.end() )
                                pWin = it->second;

                            bool bSearchedFromStart = false;
                            while ( !nFound && !bCanceled && ( pWin || !bSearchedFromStart ) )
                            {
                                if ( !pWin )
                                {
                                    SfxViewFrame* pViewFrame = GetViewFrame();
                                    SfxChildWindow* pChildWin = pViewFrame ? pViewFrame->GetChildWindow( SID_SEARCH_DLG ) : NULL;
                                    Window* pParent = pChildWin ? pChildWin->GetWindow() : NULL;
                                    QueryBox aQuery(pParent, WB_YES_NO|WB_DEF_YES, IDE_RESSTR(RID_STR_SEARCHFROMSTART));
                                    if ( aQuery.Execute() == RET_YES )
                                    {
                                        it = aIDEWindowTable.begin();
                                        if ( it != aIDEWindowTable.end() )
                                            pWin = it->second;
                                        bSearchedFromStart = true;
                                    }
                                    else
                                        bCanceled = true;
                                }

                                if (ModulWindow* pMWin = dynamic_cast<ModulWindow*>(pWin))
                                    if (!pWin->IsSuspended())
                                    {
                                        if ( pWin != pCurWin )
                                        {
                                            if ( pCurWin )
                                                pWin->SetSizePixel( pCurWin->GetSizePixel() );
                                            nFound = pMWin->StartSearchAndReplace(*pSearchItem, true);
                                        }
                                        if ( nFound )
                                        {
                                            bChangeCurWindow = true;
                                            break;
                                        }
                                    }
                                if ( pWin && ( pWin != pCurWin ) )
                                {
                                    if ( it != aIDEWindowTable.end() )
                                        ++it;
                                    if ( it != aIDEWindowTable.end() )
                                        pWin = it->second;
                                    else
                                        pWin = 0;
                                }
                                else
                                    pWin = 0;
                            }
                            if ( !nFound && bSearchedFromStart )
                                nFound = pMCurWin->StartSearchAndReplace(*pSearchItem, true);
                            if ( bChangeCurWindow )
                                SetCurWindow( pWin, true );
                        }
                        if ( !nFound && !bCanceled )
                            InfoBox( pCurWin, String( IDEResId( RID_STR_SEARCHNOTFOUND ) ) ).Execute();
                    }

                    rReq.Done();
                }
                else
                    DBG_ASSERT(false, "no searchitem!");
                    nFound = pCurWin->StartSearchAndReplace(rSearchItem);

                rtl::OUString aReplStr(IDE_RESSTR(RID_STR_SEARCHREPLACES));
                aReplStr = aReplStr.replaceAll("XX", rtl::OUString::valueOf(nFound));
                InfoBox( pCurWin, aReplStr ).Execute();
            }
        }
        break;
        case FID_SEARCH_OFF:
        {
            if (dynamic_cast<ModulWindow*>(pCurWin))
                pCurWin->GrabFocus();
            else
            {
                nFound = pCurWin->StartSearchAndReplace(rSearchItem);
                if ( !nFound && !rSearchItem.GetSelection() )
                {
                    // search other modules...
                    bool bChangeCurWindow = false;
                    WindowTableIt it;
                    for (it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it)
                        if (it->second == pCurWin)
                            break;
                    if (it != aIDEWindowTable.end())
                        ++it;
                    IDEBaseWindow* pWin = it != aIDEWindowTable.end() ? it->second : 0;

                    bool bSearchedFromStart = false;
                    while ( !nFound && !bCanceled && ( pWin || !bSearchedFromStart ) )
                    {
                        if ( !pWin )
                        {
                            SfxViewFrame* pViewFrame = GetViewFrame();
                            SfxChildWindow* pChildWin = pViewFrame ? pViewFrame->GetChildWindow( SID_SEARCH_DLG ) : NULL;
                            Window* pParent = pChildWin ? pChildWin->GetWindow() : NULL;
                            QueryBox aQuery(pParent, WB_YES_NO|WB_DEF_YES, IDE_RESSTR(RID_STR_SEARCHFROMSTART));
                            if ( aQuery.Execute() == RET_YES )
                            {
                                it = aIDEWindowTable.begin();
                                if ( it != aIDEWindowTable.end() )
                                    pWin = it->second;
                                bSearchedFromStart = true;
                            }
                            else
                                bCanceled = true;
                        }

                        if (pWin && pWin->HasActiveEditor())
                        {
                            if ( pWin != pCurWin )
                            {
                                if ( pCurWin )
                                    pWin->SetSizePixel( pCurWin->GetSizePixel() );
                                nFound = pWin->StartSearchAndReplace(rSearchItem, true);
                            }
                            if ( nFound )
                            {
                                bChangeCurWindow = true;
                                break;
                            }
                        }
                        if ( pWin && ( pWin != pCurWin ) )
                        {
                            if ( it != aIDEWindowTable.end() )
                                ++it;
                            pWin = it != aIDEWindowTable.end() ? it->second : 0;
                        }
                        else
                            pWin = 0;
                    }
                    if ( !nFound && bSearchedFromStart )
                        nFound = pCurWin->StartSearchAndReplace(rSearchItem, true);
                    if ( bChangeCurWindow )
                        SetCurWindow( pWin, true );
                }
                if ( !nFound && !bCanceled )
                    InfoBox( pCurWin, String(IDEResId(RID_STR_SEARCHNOTFOUND)) ).Execute();
            }

            rReq.Done();
        }
        break;
        case SID_UNDO:
        case SID_REDO:
        {
            if ( GetUndoManager() && pCurWin->AllowUndo() )
            {
                GetViewFrame()->ExecuteSlot( rReq );
            }
        }
        break;
        case SID_GOTOLINE:
        {
            if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin))
            {
                std::auto_ptr< GotoLineDialog > xGotoDlg( new GotoLineDialog( pCurWin ) );
                if ( xGotoDlg->Execute() )
                {
                    rtl::OUString sText =  xGotoDlg->GetText();

                    sal_Int32 nLine = xGotoDlg->GetLineNumber();

                    if ( nLine )
                        pMCurWin->GetEditView()->SetSelection( TextSelection( TextPaM( nLine - 1 , 0 ), TextPaM( nLine - 1, 0 ) ) );
                }
            }
        }
            break;
        default:
        {
            pCurWin->ExecuteCommand( rReq );
        }
    }
}

@@ -350,22 +262,6 @@ void BasicIDEShell::ExecuteGlobal( SfxRequest& rReq )
            }
        }
        break;
        case SID_SIGNATURE:
        {
            if ( pCurWin )
            {
                ::basctl::DocumentSignature aSignature( pCurWin->GetDocument() );
                if ( aSignature.supportsSignatures() )
                {
                    aSignature.signScriptingContent();
                    SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
                    if ( pBindings )
                        pBindings->Invalidate( SID_SIGNATURE );
                }
            }
        }
        break;

        case SID_BASICIDE_MODULEDLG:
        {
            if ( rReq.GetArgs() )
@@ -441,10 +337,13 @@ void BasicIDEShell::ExecuteGlobal( SfxRequest& rReq )
        break;

        case SID_BASICIDE_OBJCAT:
            pModulLayout->ToggleObjectCatalog();
            // toggling object catalog
            aObjectCatalog.Show(!aObjectCatalog.IsVisible());
            if (pLayout)
                pLayout->ArrangeWindows();
            // refresh the button state
            if (SfxBindings* pBindings = BasicIDE::GetBindingsPtr())
                pBindings->Invalidate(nSlot);
                pBindings->Invalidate(SID_BASICIDE_OBJCAT);
            break;

        case SID_BASICIDE_NAMECHANGEDONTAB:
@@ -519,7 +418,7 @@ void BasicIDEShell::ExecuteGlobal( SfxRequest& rReq )
        case SID_BASICIDE_STOREALLMODULESOURCES:
        case SID_BASICIDE_UPDATEALLMODULESOURCES:
        {
            for( IDEWindowTable::const_iterator it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it )
            for (WindowTableIt it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it)
            {
                IDEBaseWindow* pWin = it->second;
                if (!pWin->IsSuspended() && dynamic_cast<ModulWindow*>(pWin))
@@ -793,11 +692,18 @@ void BasicIDEShell::ExecuteGlobal( SfxRequest& rReq )

        case SID_BASICIDE_MANAGE_LANG:
        {
            ManageLanguageDialog aDlg( GetCurWindow(), GetCurLocalizationMgr() );
            ManageLanguageDialog aDlg(pCurWin, m_pCurLocalizationMgr);
            aDlg.Execute();
            rReq.Done();
        }
        break;

        default:
            if (pLayout)
                pLayout->ExecuteGlobal(rReq);
            if (pCurWin)
                pCurWin->ExecuteGlobal(rReq);
            break;
    }
}

@@ -808,20 +714,6 @@ void BasicIDEShell::GetState(SfxItemSet &rSet)
    {
        switch ( nWh )
        {
            case SID_SHOWLINES:
            {
                // if this is not a module window hide the
                // setting, doesn't make sense for example if the
                // dialog editor is open
                if(pCurWin && !dynamic_cast<ModulWindow*>(pCurWin))
                {
                    rSet.DisableItem( nWh );
                    rSet.Put(SfxVisibilityItem(nWh, false));
                }
                else
                    rSet.Put( SfxBoolItem( nWh, lcl_GetSourceLinesEnabledValue() ) );
                break;
            }
            case SID_DOCINFO:
            {
                rSet.DisableItem( nWh );
@@ -872,25 +764,12 @@ void BasicIDEShell::GetState(SfxItemSet &rSet)
                    rSet.DisableItem( nWh );
            }
            break;
            case SID_BASICIDE_CHOOSEMACRO:
            case SID_BASICIDE_OBJCAT:
            {
                // FIXME: hide Object Catalog icon from the toolbar,
                // when window type is not macro editor.
                if(pCurWin && !dynamic_cast<ModulWindow*>(pCurWin))
                {
                    rSet.DisableItem( nWh );
                    rSet.Put(SfxVisibilityItem(nWh, false));
                }
                if (pLayout)
                    rSet.Put(SfxBoolItem(nWh, aObjectCatalog.IsVisible()));
                else
                {
                    if (nWh == SID_BASICIDE_OBJCAT)
                        rSet.Put(SfxBoolItem(nWh, pModulLayout && pModulLayout->HasObjectCatalog()));
                    else
                        rSet.Put(SfxVisibilityItem(nWh, true));
                }
                    rSet.Put(SfxVisibilityItem(nWh, false));
                break;
            }
            case SID_BASICIDE_SHOWSBX:
            case SID_BASICIDE_CREATEMACRO:
            case SID_BASICIDE_EDITMACRO:
@@ -1098,6 +977,9 @@ void BasicIDEShell::GetState(SfxItemSet &rSet)
                }
                break;
            }
            default:
                if (pLayout)
                    pLayout->GetState(rSet, nWh);
        }
    }
    if ( pCurWin )
@@ -1120,67 +1002,25 @@ sal_Bool BasicIDEShell::HasUIFeature( sal_uInt32 nFeature )

void BasicIDEShell::SetCurWindow( IDEBaseWindow* pNewWin, bool bUpdateTabBar, bool bRememberAsCurrent )
{
    // an EditWindow must be set at Sfx for resizing...
    if ( !pNewWin && ( GetWindow() != pModulLayout ) )
    {
        pModulLayout->Show();
        AdjustPosSizePixel( Point( 0, 0 ), GetViewFrame()->GetWindow().GetOutputSizePixel() );
        SetWindow( pModulLayout );
        EnableScrollbars( false );
        aVScrollBar.Hide();
    }

    if ( pNewWin != pCurWin )
    {
        IDEBaseWindow* pPrevCurWin = pCurWin;
        pCurWin = pNewWin;
        if ( pPrevCurWin )
        if (pLayout)
            pLayout->Deactivating();
        if (pCurWin)
        {
            pPrevCurWin->Hide();
            pPrevCurWin->Deactivating();
//          pPrevCurWin->GetLayoutWindow()->Hide();
            if (DialogWindow* pDialogWin = dynamic_cast<DialogWindow*>(pPrevCurWin))
            {
                pDialogWin->DisableBrowser();
            }
            if (pCurWin->GetType() == BASICIDE_TYPE_MODULE)
                pLayout = pModulLayout.get();
            else
            {
                pModulLayout->SetModulWindow( NULL );
            }
        }
        if ( pCurWin )
        {
            AdjustPosSizePixel( Point( 0, 0 ), GetViewFrame()->GetWindow().GetOutputSizePixel() );
            if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin))
            {
                pMCurWin->SetLineNumberDisplay(SourceLinesDisplayed());
                GetViewFrame()->GetWindow().SetHelpId( HID_BASICIDE_MODULWINDOW );
                pModulLayout->SetModulWindow(pMCurWin);
                pModulLayout->Show();
            }
            else
            {
                pModulLayout->Hide();
                GetViewFrame()->GetWindow().SetHelpId( HID_BASICIDE_DIALOGWINDOW );
            }

            if ( bRememberAsCurrent )
            {
                BasicIDEData* pData = BasicIDEGlobals::GetExtraData();
                if ( pData )
                {
                    sal_uInt16 nCurrentType = dynamic_cast<ModulWindow*>(pCurWin) ?
                        BASICIDE_TYPE_MODULE : BASICIDE_TYPE_DIALOG;
                    LibInfoItem* pLibInfoItem = new LibInfoItem( pCurWin->GetDocument(), pCurWin->GetLibName(), pCurWin->GetName(), nCurrentType );
                    pData->GetLibInfos().InsertInfo( pLibInfoItem );
                }
            }

            if ( GetViewFrame()->GetWindow().IsVisible() ) // SFX will do it later otherwise
                pLayout = pDialogLayout.get();
            AdjustPosSizePixel(Point(0, 0), GetViewFrame()->GetWindow().GetOutputSizePixel());
            pLayout->Activating(*pCurWin);
            GetViewFrame()->GetWindow().SetHelpId(pCurWin->GetHid());
            if (bRememberAsCurrent)
                pCurWin->InsertLibInfo();
            if (GetViewFrame()->GetWindow().IsVisible()) // SFX will do it later otherwise
                pCurWin->Show();

            pCurWin->Init();

            if ( !BasicIDEGlobals::GetExtraData()->ShellInCriticalSection() )
            {
                Window* pFrameWindow = &GetViewFrame()->GetWindow();
@@ -1190,9 +1030,9 @@ void BasicIDEShell::SetCurWindow( IDEBaseWindow* pNewWin, bool bUpdateTabBar, bo
                if ( pFocusWindow ) // Focus in BasicIDE
                    pNewWin->GrabFocus();
            }
            if (DialogWindow* pDCurWin = dynamic_cast<DialogWindow*>(pCurWin))
                pDCurWin->UpdateBrowser();
        }
        else
            pLayout = 0;
        if ( bUpdateTabBar )
        {
            sal_uLong nKey = GetIDEWindowId( pCurWin );
@@ -1208,16 +1048,16 @@ void BasicIDEShell::SetCurWindow( IDEBaseWindow* pNewWin, bool bUpdateTabBar, bo
            if ( pCurWin->GetDocument().isDocument() )
                SfxObjectShell::SetCurrentComponent( pCurWin->GetDocument().getDocument() );
        }
        else
        else if (pLayout)
        {
            SetWindow( pModulLayout );
            SetWindow(pLayout);
            GetViewFrame()->GetWindow().SetHelpId( HID_BASICIDE_MODULWINDOW );
            SfxObjectShell::SetCurrentComponent( NULL );
            SfxObjectShell::SetCurrentComponent(0);
        }
        pModulLayout->GetObjectCatalog().SetCurrentEntry(pCurWin);
        aObjectCatalog.SetCurrentEntry(pCurWin);
        SetUndoManager( pCurWin ? pCurWin->GetUndoManager() : 0 );
        InvalidateBasicIDESlots();
        EnableScrollbars( pCurWin ? true : false );
        EnableScrollbars(pCurWin != 0);

        if ( m_pCurLocalizationMgr )
            m_pCurLocalizationMgr->handleTranslationbar();
@@ -1277,25 +1117,17 @@ IDEBaseWindow* BasicIDEShell::FindApplicationWindow()
    return FindWindow( ScriptDocument::getApplicationScriptDocument() );
}

IDEBaseWindow* BasicIDEShell::FindWindow( const ScriptDocument& rDocument, const ::rtl::OUString& rLibName, const ::rtl::OUString& rName, BasicIDEType nType, bool bFindSuspended )
IDEBaseWindow* BasicIDEShell::FindWindow(
    ScriptDocument const& rDocument,
    rtl::OUString const& rLibName, rtl::OUString const& rName,
    BasicIDEType eType, bool bFindSuspended
)
{
    for( IDEWindowTable::const_iterator it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it )
    for (WindowTableIt it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it)
    {
        IDEBaseWindow* pWin = it->second;
        if ( !pWin->IsSuspended() || bFindSuspended )
        {
            if ( rLibName.isEmpty() || rName.isEmpty() || nType == BASICIDE_TYPE_UNKNOWN )
            {
                // return any non-suspended window
                return pWin;
            }
            else if ( pWin->IsDocument( rDocument ) && pWin->GetLibName() == rLibName && pWin->GetName() == rName &&
                      ( ( dynamic_cast<ModulWindow*>(pWin)  && nType == BASICIDE_TYPE_MODULE ) ||
                        ( dynamic_cast<DialogWindow*>(pWin) && nType == BASICIDE_TYPE_DIALOG ) ) )
            {
                return pWin;
            }
        }
        IDEBaseWindow* const pWin = it->second;
        if (pWin->Is(rDocument, rLibName, rName, eType, bFindSuspended))
            return pWin;
    }
    return 0;
}
@@ -1406,8 +1238,8 @@ void BasicIDEShell::AdjustPosSizePixel( const Point &rPos, const Size &rSize )
        pTabBar->SetPosSizePixel( Point( rPos.X(), rPos.Y()+aSz.Height() ), Size( aSz.Width()/2, aScrollBarBoxSz.Height() ) );
    }

    if (Window* pEdtWin = pCurWin ? pCurWin->GetLayoutWindow() : pModulLayout)
        pEdtWin->SetPosSizePixel(rPos, dynamic_cast<DialogWindow*>(pCurWin) ? aSz : aOutSz);
    if (pLayout)
        pLayout->SetPosSizePixel(rPos, dynamic_cast<DialogWindow*>(pCurWin) ? aSz : aOutSz);
}

Reference< XModel > BasicIDEShell::GetCurrentDocument() const
@@ -1444,7 +1276,7 @@ void BasicIDEShell::Deactivate( sal_Bool bMDI )

        // test CanClose to also test during deactivating the BasicIDE whether
        // the sourcecode is too large in one of the modules...
        for( IDEWindowTable::const_iterator it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it )
        for (WindowTableIt it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it)
        {
            IDEBaseWindow* pWin = it->second;
            if ( /* !pWin->IsSuspended() && */ !pWin->CanClose() )
diff --git a/basctl/source/basicide/basides2.cxx b/basctl/source/basicide/basides2.cxx
index e30ec19..6a1a5b4 100644
--- a/basctl/source/basicide/basides2.cxx
+++ b/basctl/source/basicide/basides2.cxx
@@ -45,6 +45,9 @@ using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
namespace css = ::com::sun::star;

using basctl::ModulWindow;
using basctl::ModulWindowLayout;

Reference< view::XRenderable > BasicIDEShell::GetRenderable()
{
    return Reference< view::XRenderable >( new basicide::BasicRenderable( pCurWin ) );
@@ -142,27 +145,6 @@ void BasicIDEShell::SetMDITitle()
    }
}

void BasicIDEShell::DestroyModulWindowLayout()
{
    delete pModulLayout;
    pModulLayout = 0;
}


void BasicIDEShell::UpdateModulWindowLayout( bool bBasicStopped )
{
    if ( pModulLayout )
    {
        pModulLayout->GetStackWindow().UpdateCalls();
        pModulLayout->GetWatchWindow().UpdateWatches( bBasicStopped );
    }
}

void BasicIDEShell::CreateModulWindowLayout()
{
    pModulLayout = new ModulWindowLayout( &GetViewFrame()->GetWindow() );
}

ModulWindow* BasicIDEShell::CreateBasWin( const ScriptDocument& rDocument, const ::rtl::OUString& rLibName, const ::rtl::OUString& rModName )
{
    bCreatingWindow = true;
@@ -199,7 +181,9 @@ ModulWindow* BasicIDEShell::CreateBasWin( const ScriptDocument& rDocument, const
            if( !pWin )
            {
                // new module window
                pWin = new ModulWindow( pModulLayout, rDocument, aLibName, aModName, aModule );
                if (!pModulLayout)
                    pModulLayout.reset(new ModulWindowLayout(&GetViewFrame()->GetWindow(), aObjectCatalog));
                pWin = new ModulWindow(pModulLayout.get(), rDocument, aLibName, aModName, aModule);
                nKey = InsertWindowInTable( pWin );
            }
            else // we've gotten called recursively ( via listener from createModule above ), get outta here
@@ -238,20 +222,15 @@ ModulWindow* BasicIDEShell::CreateBasWin( const ScriptDocument& rDocument, const
    return pWin;
}

ModulWindow* BasicIDEShell::FindBasWin( const ScriptDocument& rDocument, const ::rtl::OUString& rLibName, const ::rtl::OUString& rModName, bool bCreateIfNotExist, bool bFindSuspended )
ModulWindow* BasicIDEShell::FindBasWin (
    ScriptDocument const& rDocument,
    rtl::OUString const& rLibName, rtl::OUString const& rName,
    bool bCreateIfNotExist, bool bFindSuspended
)
{
    for( IDEWindowTable::const_iterator it = aIDEWindowTable.begin();
         it != aIDEWindowTable.end(); ++it )
    {
        IDEBaseWindow* pWin = it->second;
        if (!pWin->IsSuspended() || bFindSuspended)
            if (rLibName.isEmpty() || (pWin->IsDocument(rDocument) && pWin->GetLibName() == rLibName && pWin->GetName() == rModName))
            {
                if (ModulWindow* pModWin = dynamic_cast<ModulWindow*>(pWin))
                    return pModWin;
            }
    }
    return bCreateIfNotExist ? CreateBasWin(rDocument, rLibName, rModName) : 0;
    if (IDEBaseWindow* pWin = FindWindow(rDocument, rLibName, rName, BASICIDE_TYPE_MODULE, bFindSuspended))
        return static_cast<ModulWindow*>(pWin);
    return bCreateIfNotExist ? CreateBasWin(rDocument, rLibName, rName) : 0;
}

void BasicIDEShell::Move()
@@ -272,13 +251,12 @@ sal_Int32 getBasicIDEShellCount( void );
// only if basic window above:
void BasicIDEShell::ExecuteBasic( SfxRequest& rReq )
{
    if (!dynamic_cast<ModulWindow*>(pCurWin))
        return;

    pCurWin->ExecuteCommand( rReq );
    sal_Int32 nCount = getBasicIDEShellCount();
    if( nCount )
        CheckWindows();
    if (dynamic_cast<ModulWindow*>(pCurWin))
    {
        pCurWin->ExecuteCommand( rReq );
        if (getBasicIDEShellCount())
            CheckWindows();
    }
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/basides3.cxx b/basctl/source/basicide/basides3.cxx
index 17bbddb..ed0af7e 100644
--- a/basctl/source/basicide/basides3.cxx
+++ b/basctl/source/basicide/basides3.cxx
@@ -41,6 +41,9 @@ using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::io;

using basctl::DialogWindow;
using basctl::DialogWindowLayout;

DialogWindow* BasicIDEShell::CreateDlgWin( const ScriptDocument& rDocument, const ::rtl::OUString& rLibName, const ::rtl::OUString& rDlgName )
{
    bCreatingWindow = true;
@@ -86,7 +89,9 @@ DialogWindow* BasicIDEShell::CreateDlgWin( const ScriptDocument& rDocument, cons
                LocalizationMgr::setStringResourceAtDialog( rDocument, rLibName, aDlgName, xDialogModel );

                // new dialog window
                pWin = new DialogWindow( &GetViewFrame()->GetWindow(), rDocument, aLibName, aDlgName, xDialogModel );
                if (!pDialogLayout)
                    pDialogLayout.reset(new DialogWindowLayout(&GetViewFrame()->GetWindow(), aObjectCatalog));
                pWin = new DialogWindow(pDialogLayout.get(), rDocument, aLibName, aDlgName, xDialogModel);
                nKey = InsertWindowInTable( pWin );
            }
        }
@@ -115,22 +120,20 @@ DialogWindow* BasicIDEShell::CreateDlgWin( const ScriptDocument& rDocument, cons
    return pWin;
}

DialogWindow* BasicIDEShell::FindDlgWin( const ScriptDocument& rDocument, const ::rtl::OUString& rLibName, const ::rtl::OUString& rDlgName, bool bCreateIfNotExist, bool bFindSuspended )
DialogWindow* BasicIDEShell::FindDlgWin (
    ScriptDocument const& rDocument,
    rtl::OUString const& rLibName, rtl::OUString const& rName,
    bool bCreateIfNotExist, bool bFindSuspended
)
{
    for( IDEWindowTable::const_iterator it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it )
    {
        IDEBaseWindow* pWin = it->second;
        if (!pWin->IsSuspended() || bFindSuspended)
            if (rLibName.isEmpty() || (pWin->IsDocument(rDocument) && pWin->GetLibName() == rLibName && pWin->GetName() == rDlgName))
                if (DialogWindow* pDlgWin = dynamic_cast<DialogWindow*>(pWin))
                    return pDlgWin;
    }
    return bCreateIfNotExist ? CreateDlgWin(rDocument, rLibName, rDlgName) : 0;
    if (IDEBaseWindow* pWin = FindWindow(rDocument, rLibName, rName, BASICIDE_TYPE_DIALOG, bFindSuspended))
        return static_cast<DialogWindow*>(pWin);
    return bCreateIfNotExist ? CreateDlgWin(rDocument, rLibName, rName) : 0;
}

sal_uInt16 BasicIDEShell::GetIDEWindowId(const IDEBaseWindow* pWin) const
{
    for( IDEWindowTable::const_iterator it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it )
    for (WindowTableIt it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it)
        if ( it->second == pWin )
            return it->first;
    return 0;
@@ -147,11 +150,8 @@ SdrView* BasicIDEShell::GetCurDlgView() const
// only if dialogue window above:
void BasicIDEShell::ExecuteDialog( SfxRequest& rReq )
{
    if (pCurWin && (dynamic_cast<DialogWindow*>(pCurWin) ||
        (rReq.GetSlot() == SID_IMPORT_DIALOG && dynamic_cast<ModulWindow*>(pCurWin))))
    {
        pCurWin->ExecuteCommand( rReq );
    }
    if (pCurWin && (dynamic_cast<DialogWindow*>(pCurWin) || rReq.GetSlot() == SID_IMPORT_DIALOG))
        pCurWin->ExecuteCommand(rReq);
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/basidesh.cxx b/basctl/source/basicide/basidesh.cxx
index b271811..c1b7dfe 100644
--- a/basctl/source/basicide/basidesh.cxx
+++ b/basctl/source/basicide/basidesh.cxx
@@ -24,7 +24,8 @@
#include <tools/diagnose_ex.h>
#include <basic/basmgr.hxx>
#include <basidesh.hrc>
#include <baside2.hxx>
#include "baside2.hxx"
#include "baside3.hxx"
#include <basdoc.hxx>
#include <basicbox.hxx>
#include <editeng/sizeitem.hxx>
@@ -68,7 +69,7 @@ class ContainerListenerImpl : public ContainerListenerBASE
    BasicIDEShell* mpShell;
public:

    ContainerListenerImpl( BasicIDEShell* pShell ) : mpShell( pShell ) {}
    ContainerListenerImpl (BasicIDEShell* pShell) : mpShell(pShell) { }

    ~ContainerListenerImpl()
    {
@@ -117,7 +118,7 @@ public:
        rtl::OUString sModuleName;
        if( mpShell  && ( Event.Accessor >>= sModuleName ) )
        {
            IDEBaseWindow* pWin = mpShell->FindWindow( mpShell->m_aCurDocument, mpShell->m_aCurLibName, sModuleName, BASICIDE_TYPE_MODULE, true );
            basctl::ModulWindow* pWin = mpShell->FindBasWin(mpShell->m_aCurDocument, mpShell->m_aCurLibName, sModuleName, false, true);
            if( pWin )
                mpShell->RemoveWindow( pWin, true, true );
        }
@@ -150,13 +151,15 @@ sal_Int32 getBasicIDEShellCount( void )
    { return GnBasicIDEShellCount; }

BasicIDEShell::BasicIDEShell( SfxViewFrame* pFrame_, SfxViewShell* /* pOldShell */ ) :
        SfxViewShell( pFrame_, IDE_VIEWSHELL_FLAGS ),
        m_aCurDocument( ScriptDocument::getApplicationScriptDocument() ),
        aHScrollBar( &GetViewFrame()->GetWindow(), WinBits( WB_HSCROLL | WB_DRAG ) ),
        aVScrollBar( &GetViewFrame()->GetWindow(), WinBits( WB_VSCROLL | WB_DRAG ) ),
        aScrollBarBox( &GetViewFrame()->GetWindow(), WinBits( WB_SIZEABLE ) ),
        m_bAppBasicModified( false ),
        m_aNotifier( *this )
    SfxViewShell( pFrame_, IDE_VIEWSHELL_FLAGS ),
    m_aCurDocument( ScriptDocument::getApplicationScriptDocument() ),
    aHScrollBar( &GetViewFrame()->GetWindow(), WinBits( WB_HSCROLL | WB_DRAG ) ),
    aVScrollBar( &GetViewFrame()->GetWindow(), WinBits( WB_VSCROLL | WB_DRAG ) ),
    aScrollBarBox( &GetViewFrame()->GetWindow(), WinBits( WB_SIZEABLE ) ),
    pLayout(0),
    aObjectCatalog(&GetViewFrame()->GetWindow()),
    m_bAppBasicModified( false ),
    m_aNotifier( *this )
{
    m_xLibListener = new ContainerListenerImpl( this );
    Init();
@@ -184,9 +187,9 @@ void BasicIDEShell::Init()
    LibBoxControl::RegisterControl( SID_BASICIDE_LIBSELECTOR );
    LanguageBoxControl::RegisterControl( SID_BASICIDE_CURRENT_LANG );

    CreateModulWindowLayout();

    GetViewFrame()->GetWindow().SetBackground();
    GetViewFrame()->GetWindow().SetBackground(
        GetViewFrame()->GetWindow().GetSettings().GetStyleSettings().GetWindowColor()
    );

    pCurWin = 0;
    m_aCurDocument = ScriptDocument::getApplicationScriptDocument();
@@ -229,7 +232,7 @@ BasicIDEShell::~BasicIDEShell()
    SetWindow( 0 );
    SetCurWindow( 0 );

    for( IDEWindowTable::const_iterator it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it )
    for (WindowTableIt it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it )
    {
        // no store; does already happen when the BasicManagers are destroyed
        delete it->second;
@@ -237,12 +240,10 @@ BasicIDEShell::~BasicIDEShell()

    aIDEWindowTable.clear();
    delete pTabBar;
    DestroyModulWindowLayout();

        ContainerListenerImpl* pListener = static_cast< ContainerListenerImpl* >( m_xLibListener.get() );
        // Destroy all ContainerListeners for Basic Container.
        if ( pListener )
            pListener->removeContainerListener( m_aCurDocument, m_aCurLibName );
    // Destroy all ContainerListeners for Basic Container.
    if (ContainerListenerImpl* pListener = static_cast<ContainerListenerImpl*>(m_xLibListener.get()))
        pListener->removeContainerListener(m_aCurDocument, m_aCurLibName);

    BasicIDEGlobals::GetExtraData()->ShellInCriticalSection() = false;

@@ -251,15 +252,15 @@ BasicIDEShell::~BasicIDEShell()

void BasicIDEShell::onDocumentCreated( const ScriptDocument& /*_rDocument*/ )
{
    if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin))
        pMCurWin->SetLineNumberDisplay(SourceLinesDisplayed());
    if (pCurWin)
        pCurWin->OnNewDocument();
    UpdateWindows();
}

void BasicIDEShell::onDocumentOpened( const ScriptDocument& /*_rDocument*/ )
{
    if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin))
        pMCurWin->SetLineNumberDisplay(SourceLinesDisplayed());
    if (pCurWin)
        pCurWin->OnNewDocument();
    UpdateWindows();
}

@@ -296,7 +297,7 @@ void BasicIDEShell::onDocumentClosed( const ScriptDocument& _rDocument )
    std::vector<IDEBaseWindow*> aDeleteVec;

    // remove all windows which belong to this document
    for( IDEWindowTable::const_iterator it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it )
    for (WindowTableIt it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it )
    {
        IDEBaseWindow* pWin = it->second;
        if ( pWin->IsDocument( _rDocument ) )
@@ -344,7 +345,7 @@ void BasicIDEShell::onDocumentTitleChanged( const ScriptDocument& /*_rDocument*/

void BasicIDEShell::onDocumentModeChanged( const ScriptDocument& _rDocument )
{
    for( IDEWindowTable::const_iterator it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it )
    for (WindowTableIt it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it )
    {
        IDEBaseWindow* pWin = it->second;
        if ( pWin->IsDocument( _rDocument ) && _rDocument.isDocument() )
@@ -354,7 +355,7 @@ void BasicIDEShell::onDocumentModeChanged( const ScriptDocument& _rDocument )

void BasicIDEShell::StoreAllWindowData( bool bPersistent )
{
    for( IDEWindowTable::const_iterator it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it )
    for (WindowTableIt it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it )
    {
        IDEBaseWindow* pWin = it->second;
        DBG_ASSERT( pWin, "PrepareClose: NULL-Pointer in Table?" );
@@ -396,7 +397,7 @@ sal_uInt16 BasicIDEShell::PrepareClose( sal_Bool bUI, sal_Bool bForBrowsing )
    else
    {
        bool bCanClose = true;
        for (IDEWindowTable::const_iterator it = aIDEWindowTable.begin(); bCanClose && (it != aIDEWindowTable.end()); ++it)
        for (WindowTableIt it = aIDEWindowTable.begin(); bCanClose && (it != aIDEWindowTable.end()); ++it)
        {
            IDEBaseWindow* pWin = it->second;
            if ( !pWin->CanClose() )
@@ -537,7 +538,7 @@ void BasicIDEShell::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId&,
                case SFX_HINT_DYING:
                {
                    EndListening( rBC, true /* log off all */ );
                    UpdateObjectCatalog();
                    aObjectCatalog.UpdateEntries();
                }
                break;
            }
@@ -577,7 +578,8 @@ void BasicIDEShell::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId&,
                        // not only at error/break or explicit stoppage,
                        // if the update is turned off due to a programming bug
                        BasicIDE::BasicStopped();
                        UpdateModulWindowLayout( true );    // clear...
                        if (pLayout)
                            pLayout->UpdateDebug(true); // clear...
                        if( m_pCurLocalizationMgr )
                            m_pCurLocalizationMgr->handleBasicStopped();
                    }
@@ -586,8 +588,7 @@ void BasicIDEShell::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId&,
                        m_pCurLocalizationMgr->handleBasicStarted();
                    }

                    for( IDEWindowTable::const_iterator it = aIDEWindowTable.begin();
                         it != aIDEWindowTable.end(); ++it )
                    for (WindowTableIt it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it)
                    {
                        IDEBaseWindow* pWin = it->second;
                        if ( nHintId == SBX_HINT_BASICSTART )
@@ -607,7 +608,7 @@ void BasicIDEShell::CheckWindows()
{
    bool bSetCurWindow = false;
    std::vector<IDEBaseWindow*> aDeleteVec;
    for( IDEWindowTable::const_iterator it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it )
    for (WindowTableIt it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it)
    {
        IDEBaseWindow* pWin = it->second;
        if ( pWin->GetStatus() & BASWIN_TOBEKILLED )
@@ -631,7 +632,7 @@ void BasicIDEShell::RemoveWindows( const ScriptDocument& rDocument, const ::rtl:
{
    bool bChangeCurWindow = pCurWin ? false : true;
    std::vector<IDEBaseWindow*> aDeleteVec;
    for( IDEWindowTable::const_iterator it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it )
    for (WindowTableIt it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it)
    {
        IDEBaseWindow* pWin = it->second;
        if ( pWin->IsDocument( rDocument ) && pWin->GetLibName() == rLibName )
@@ -658,7 +659,7 @@ void BasicIDEShell::UpdateWindows()
    if ( !m_aCurLibName.isEmpty() )
    {
        std::vector<IDEBaseWindow*> aDeleteVec;
        for( IDEWindowTable::const_iterator it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it )
        for (WindowTableIt it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it)
        {
            IDEBaseWindow* pWin = it->second;
            if ( !pWin->IsDocument( m_aCurDocument ) || pWin->GetLibName() != m_aCurLibName )
@@ -739,7 +740,7 @@ void BasicIDEShell::UpdateWindows()
                            for ( sal_Int32 j = 0 ; j < nModCount ; j++ )
                            {
                                ::rtl::OUString aModName = pModNames[ j ];
                                ModulWindow* pWin = FindBasWin( *doc, aLibName, aModName, false );
                                basctl::ModulWindow* pWin = FindBasWin( *doc, aLibName, aModName, false );
                                if ( !pWin )
                                    pWin = CreateBasWin( *doc, aLibName, aModName );
                                if ( !pNextActiveWindow && pLibInfoItem && pLibInfoItem->GetCurrentName() == aModName &&
@@ -770,7 +771,7 @@ void BasicIDEShell::UpdateWindows()
                                ::rtl::OUString aDlgName = pDlgNames[ j ];
                                // this find only looks for non-suspended windows;
                                // suspended windows are handled in CreateDlgWin
                                DialogWindow* pWin = FindDlgWin( *doc, aLibName, aDlgName, false );
                                basctl::DialogWindow* pWin = FindDlgWin( *doc, aLibName, aDlgName, false );
                                if ( !pWin )
                                    pWin = CreateDlgWin( *doc, aLibName, aDlgName );
                                if ( !pNextActiveWindow && pLibInfoItem && pLibInfoItem->GetCurrentName() == aDlgName &&
@@ -842,7 +843,6 @@ void BasicIDEShell::RemoveWindow( IDEBaseWindow* pWindow_, bool bDestroy, bool b
    }
    else
    {
        pWindow_->Hide();
        pWindow_->AddStatus( BASWIN_SUSPENDED );
        pWindow_->Deactivating();
        aIDEWindowTable[ nKey ] = pWindow_;   // jump in again
@@ -975,10 +975,4 @@ void BasicIDEShell::ImplStartListening( StarBASIC* pBasic )
    StartListening( pBasic->GetBroadcaster(), true /* log on only once */ );
}

// Updates the "Object Catalog" window.
void BasicIDEShell::UpdateObjectCatalog ()
{
    pModulLayout->UpdateObjectCatalog();
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/basobj2.cxx b/basctl/source/basicide/basobj2.cxx
index 01df2ea..ab9d9a08 100644
--- a/basctl/source/basicide/basobj2.cxx
+++ b/basctl/source/basicide/basobj2.cxx
@@ -186,18 +186,15 @@ bool RenameModule( Window* pErrorParent, const ScriptDocument& rDocument, const 
    if ( !rDocument.renameModule( rLibName, rOldName, rNewName ) )
        return false;

    BasicIDEShell* pIDEShell = BasicIDEGlobals::GetShell();
    if ( pIDEShell )
    if (BasicIDEShell* pIDEShell = BasicIDEGlobals::GetShell())
    {
        IDEBaseWindow* pWin = pIDEShell->FindWindow( rDocument, rLibName, rNewName, BASICIDE_TYPE_MODULE, true );
        if ( pWin )
        if (basctl::ModulWindow* pWin = pIDEShell->FindBasWin(rDocument, rLibName, rNewName, false, true))
        {
            // set new name in window
            pWin->SetName( rNewName );

            // set new module in module window
            ModulWindow* pModWin = dynamic_cast<ModulWindow*>(pWin);
            pModWin->SetSbModule( (SbModule*)pModWin->GetBasic()->FindModule( rNewName ) );
            pWin->SetSbModule( (SbModule*)pWin->GetBasic()->FindModule( rNewName ) );

            // update tabwriter
            sal_uInt16 nId = pIDEShell->GetIDEWindowId( pWin );
diff --git a/basctl/source/basicide/basobj3.cxx b/basctl/source/basicide/basobj3.cxx
index 7325904..731d402 100644
--- a/basctl/source/basicide/basobj3.cxx
+++ b/basctl/source/basicide/basobj3.cxx
@@ -189,10 +189,10 @@ bool RenameDialog( Window* pErrorParent, const ScriptDocument& rDocument, const 
    }

    BasicIDEShell* pIDEShell = BasicIDEGlobals::GetShell();
    IDEBaseWindow* pWin = pIDEShell ? pIDEShell->FindWindow( rDocument, rLibName, rOldName, BASICIDE_TYPE_DIALOG, false ) : NULL;
    basctl::DialogWindow* pWin = pIDEShell ? pIDEShell->FindDlgWin(rDocument, rLibName, rOldName) : 0;
    Reference< XNameContainer > xExistingDialog;
    if ( pWin )
        xExistingDialog = ((DialogWindow*)pWin)->GetEditor()->GetDialog();
        xExistingDialog = pWin->GetEditor()->GetDialog();

    if ( xExistingDialog.is() )
        LocalizationMgr::renameStringResourceIDs( rDocument, rLibName, rNewName, xExistingDialog );
@@ -206,7 +206,7 @@ bool RenameDialog( Window* pErrorParent, const ScriptDocument& rDocument, const 
        pWin->SetName( rNewName );

        // update property browser
        ((DialogWindow*)pWin)->UpdateBrowser();
        pWin->UpdateBrowser();

        // update tabwriter
        sal_uInt16 nId = pIDEShell->GetIDEWindowId( pWin );
@@ -229,8 +229,7 @@ bool RemoveDialog( const ScriptDocument& rDocument, const ::rtl::OUString& rLibN
    BasicIDEShell* pIDEShell = BasicIDEGlobals::GetShell();
    if ( pIDEShell )
    {
        DialogWindow* pDlgWin = pIDEShell->FindDlgWin( rDocument, rLibName, rDlgName, false );
        if( pDlgWin )
        if (basctl::DialogWindow* pDlgWin = pIDEShell->FindDlgWin(rDocument, rLibName, rDlgName))
        {
            Reference< container::XNameContainer > xDialogModel = pDlgWin->GetDialog();
            LocalizationMgr::removeResourceForDialog( rDocument, rLibName, rDlgName, xDialogModel );
@@ -286,9 +285,11 @@ void MarkDocumentModified( const ScriptDocument& rDocument )
    // does not have to come from a document...
    if ( rDocument.isApplication() )
    {
        BasicIDEShell* pIDEShell = BasicIDEGlobals::GetShell();
        if ( pIDEShell )
        if (BasicIDEShell* pIDEShell = BasicIDEGlobals::GetShell())
        {
            pIDEShell->SetAppBasicModified();
            pIDEShell->UpdateObjectCatalog();
        }
    }
    else
    {
@@ -302,10 +303,6 @@ void MarkDocumentModified( const ScriptDocument& rDocument )
        pBindings->Invalidate( SID_SAVEDOC );
        pBindings->Update( SID_SAVEDOC );
    }

    // updating the Object Catalog
    if (BasicIDEShell* pIdeShell = BasicIDEGlobals::GetShell())
        pIdeShell->UpdateObjectCatalog();
}

//----------------------------------------------------------------------------
@@ -499,6 +496,5 @@ SfxBindings* GetBindingsPtr()

} //namespace BasicIDE

//----------------------------------------------------------------------------

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/bastype2.hxx b/basctl/source/basicide/bastype2.hxx
index efcaa4f..397be35 100644
--- a/basctl/source/basicide/bastype2.hxx
+++ b/basctl/source/basicide/bastype2.hxx
@@ -30,7 +30,19 @@
#include <sbxitem.hxx>
#include "basobj.hxx"

enum BasicEntryType { OBJ_TYPE_UNKNOWN, OBJ_TYPE_DOCUMENT, OBJ_TYPE_LIBRARY, OBJ_TYPE_MODULE, OBJ_TYPE_DIALOG, OBJ_TYPE_METHOD, OBJ_TYPE_DOCUMENT_OBJECTS, OBJ_TYPE_USERFORMS, OBJ_TYPE_NORMAL_MODULES, OBJ_TYPE_CLASS_MODULES };
enum BasicEntryType
{
    OBJ_TYPE_UNKNOWN,
    OBJ_TYPE_DOCUMENT,
    OBJ_TYPE_LIBRARY,
    OBJ_TYPE_MODULE,
    OBJ_TYPE_DIALOG,
    OBJ_TYPE_METHOD,
    OBJ_TYPE_DOCUMENT_OBJECTS,
    OBJ_TYPE_USERFORMS,
    OBJ_TYPE_NORMAL_MODULES,
    OBJ_TYPE_CLASS_MODULES
};

#define BROWSEMODE_MODULES      0x01
#define BROWSEMODE_SUBS         0x02
diff --git a/basctl/source/basicide/bastypes.cxx b/basctl/source/basicide/bastypes.cxx
index 3aa29e6..616f281 100644
--- a/basctl/source/basicide/bastypes.cxx
+++ b/basctl/source/basicide/bastypes.cxx
@@ -25,6 +25,7 @@
#include "baside3.hxx"
#include "basobj.hxx"
#include "iderdll.hxx"
#include "iderdll2.hxx"

#include <basic/basmgr.hxx>
#include <com/sun/star/script/ModuleType.hpp>
@@ -40,6 +41,7 @@ using namespace ::com::sun::star::uno;
using namespace ::com::sun::star;

using ::std::vector;
using basctl::Layout;

DBG_NAME( IDEBaseWindow )

@@ -106,18 +108,11 @@ IMPL_LINK_INLINE_START( IDEBaseWindow, ScrollHdl, ScrollBar *, pCurScrollBar )
IMPL_LINK_INLINE_END( IDEBaseWindow, ScrollHdl, ScrollBar *, pCurScrollBar )


void IDEBaseWindow::ExecuteCommand (SfxRequest&)
{ }

void IDEBaseWindow::ExecuteCommand( SfxRequest& )
{
    DBG_CHKTHIS( IDEBaseWindow, 0 );
}



void IDEBaseWindow::GetState( SfxItemSet& )
{
    DBG_CHKTHIS( IDEBaseWindow, 0 );
}
void IDEBaseWindow::ExecuteGlobal (SfxRequest&)
{ }


long IDEBaseWindow::Notify( NotifyEvent& rNEvt )
@@ -225,52 +220,144 @@ bool IDEBaseWindow::IsPasteAllowed ()
    return false;
}

Window* IDEBaseWindow::GetLayoutWindow()
{
    return this;
}

::svl::IUndoManager* IDEBaseWindow::GetUndoManager()
{
    return NULL;
}

void IDEBaseWindow::Deactivating()
{
}

sal_uInt16 IDEBaseWindow::GetSearchOptions()
{
    return 0;
}


BasicDockingWindow::BasicDockingWindow( Window* pParent ) :
    DockingWindow( pParent, WB_BORDER | WB_3DLOOK | WB_DOCKABLE | WB_MOVEABLE |
                            WB_SIZEABLE | WB_ROLLABLE |
                            WB_DOCKABLE | WB_CLIPCHILDREN )
sal_uInt16 IDEBaseWindow::StartSearchAndReplace (SvxSearchItem const&, bool bFromStart)
{
    static_cast<void>(bFromStart);
    return 0;
}

void IDEBaseWindow::OnNewDocument ()
{ }

void IDEBaseWindow::InsertLibInfo () const
{
    if (BasicIDEData* pData = BasicIDEGlobals::GetExtraData())
    {
        pData->GetLibInfos().InsertInfo(
            new LibInfoItem(m_aDocument, m_aLibName, m_aName, GetType())
        );
    }
}

bool IDEBaseWindow::Is (
    ScriptDocument const& rDocument,
    rtl::OUString const& rLibName, rtl::OUString const& rName,
    BasicIDEType eType, bool bFindSuspended
)
{
    if (bFindSuspended || !IsSuspended())
    {
        // any non-suspended window is ok
        if (rLibName.isEmpty() || rName.isEmpty() || eType == BASICIDE_TYPE_UNKNOWN)
            return true;
        // ok if the parameters match
        if (m_aDocument == rDocument && m_aLibName == rLibName && m_aName == rName && GetType() == eType)
            return true;
    }
    return false;
}

bool IDEBaseWindow::HasActiveEditor () const
{
    return false;
}


//
// BasicDockingWindow
// ==================
//

// style bits for BasicDockingWindow
WinBits const BasicDockingWindow::StyleBits =
    WB_BORDER | WB_3DLOOK | WB_CLIPCHILDREN |
    WB_MOVEABLE | WB_SIZEABLE | WB_ROLLABLE | WB_DOCKABLE;

BasicDockingWindow::BasicDockingWindow (Window* pParent) :
    DockingWindow(pParent, StyleBits),
    pLayout(0),
    nShowCount(0)
{ }

BasicDockingWindow::BasicDockingWindow (Layout* pParent) :
    DockingWindow(pParent, StyleBits),
    pLayout(pParent),
    nShowCount(0)
{ }

// Sets the position and the size of the docking window. This property is saved
// when the window is floating. Called by Layout.
void BasicDockingWindow::ResizeIfDocking (Point const& rPos, Size const& rSize)
{
    Rectangle const rRect(rPos, rSize);
    if (rRect != aDockingRect)
    {
        // saving the position and the size
        aDockingRect = rRect;
        // resizing if actually docking
        if (!IsFloatingMode())
            SetPosSizePixel(rPos, rSize);
    }
}

// Sets the parent Layout window.
// The physical parent is set only when the window is docking.
void BasicDockingWindow::SetLayoutWindow (Layout* pLayout_)
{
    pLayout = pLayout_;
    if (!IsFloatingMode())
        SetParent(pLayout);

}

// Increases the "show" reference count.
// The window is shown when the reference count is positive.
void BasicDockingWindow::Show (bool bShow) // = true
{
    if (bShow)
    {
        if (++nShowCount == 1)
            DockingWindow::Show();
    }
    else
    {
        if (--nShowCount == 0)
            DockingWindow::Hide();
    }
}

// Decreases the "show" reference count.
// The window is hidden when the reference count reaches zero.
void BasicDockingWindow::Hide ()
{
    Show(false);
}

sal_Bool BasicDockingWindow::Docking( const Point& rPos, Rectangle& rRect )
{
    ModulWindowLayout* pLayout = (ModulWindowLayout*)GetParent();
    Rectangle aTmpRec( rRect );
    bool const bDock = !IsDockingPrevented() && pLayout->IsToBeDocked( this, rPos, aTmpRec );
    if ( bDock )
    if (!IsDockingPrevented() && aDockingRect.IsInside(rPos))
    {
        rRect.SetSize( aTmpRec.GetSize() );
        rRect.SetSize(aDockingRect.GetSize());
        return false; // dock
    }
    else    // adjust old size
    else // adjust old size
    {
        if ( !aFloatingPosAndSize.IsEmpty() )
            rRect.SetSize( aFloatingPosAndSize.GetSize() );
        if (!aFloatingRect.IsEmpty())
            rRect.SetSize(aFloatingRect.GetSize());
        return true; // float
    }
    return !bDock;  // bFloat
}



void BasicDockingWindow::EndDocking( const Rectangle& rRect, sal_Bool bFloatMode )
{
    if ( bFloatMode )
@@ -278,50 +365,71 @@ void BasicDockingWindow::EndDocking( const Rectangle& rRect, sal_Bool bFloatMode
    else
    {
        SetFloatingMode(false);
        ModulWindowLayout* pLayout = (ModulWindowLayout*)GetParent();
        pLayout->DockaWindow( this );
        DockThis();
    }
}



void BasicDockingWindow::ToggleFloatingMode()
{
    ModulWindowLayout* pLayout = (ModulWindowLayout*)GetParent();
    if ( IsFloatingMode() )
    if (IsFloatingMode())
    {
        if ( !aFloatingPosAndSize.IsEmpty() )
            SetPosSizePixel( GetParent()->ScreenToOutputPixel( aFloatingPosAndSize.TopLeft() ),
                aFloatingPosAndSize.GetSize() );
        if (!aFloatingRect.IsEmpty())
            SetPosSizePixel(
                GetParent()->ScreenToOutputPixel(aFloatingRect.TopLeft()),
                aFloatingRect.GetSize()
            );
    }
    pLayout->DockaWindow( this );
    DockThis();
}



sal_Bool BasicDockingWindow::PrepareToggleFloatingMode()
{
    if ( IsFloatingMode() )
    if (IsFloatingMode())
    {
        // memorize position and size on the desktop...
        aFloatingPosAndSize.SetPos( GetParent()->OutputToScreenPixel( GetPosPixel() ) );
        aFloatingPosAndSize.SetSize( GetSizePixel() );
        aFloatingRect = Rectangle(
            GetParent()->OutputToScreenPixel(GetPosPixel()),
            GetSizePixel()
        );
    }
    return true;
}



void BasicDockingWindow::StartDocking()
{
    if ( IsFloatingMode() )
    if (IsFloatingMode())
    {
        aFloatingPosAndSize.SetPos( GetParent()->OutputToScreenPixel( GetPosPixel() ) );
        aFloatingPosAndSize.SetSize( GetSizePixel() );
        aFloatingRect = Rectangle(
            GetParent()->OutputToScreenPixel(GetPosPixel()),
            GetSizePixel()
        );
    }
}

void BasicDockingWindow::DockThis ()
{
    // resizing when floating -> docking
    if (!IsFloatingMode())
    {
        Point const aPos = aDockingRect.TopLeft();
        Size const aSize = aDockingRect.GetSize();
        if (aSize != GetSizePixel() || aPos != GetPosPixel())
            SetPosSizePixel(aPos, aSize);
    }

    if (pLayout)
    {
        if (!IsFloatingMode() && GetParent() != pLayout)
            SetParent(pLayout);
        pLayout->DockaWindow(this);
    }
}


//
// ExtendedEdit
// ============
//

ExtendedEdit::ExtendedEdit( Window* pParent, IDEResId nRes ) :
    Edit( pParent, nRes )
@@ -442,7 +550,7 @@ void BasicIDETabBar::Command( const CommandEvent& rCEvt )
                    {
                        IDEWindowTable& aIDEWindowTable = pIDEShell->GetIDEWindowTable();
                        IDEWindowTable::const_iterator it = aIDEWindowTable.find( GetCurPageId() );
                        if (it != aIDEWindowTable.end() && dynamic_cast<ModulWindow*>(it->second))
                        if (it != aIDEWindowTable.end() && dynamic_cast<basctl::ModulWindow*>(it->second))
                        {
                            SbModule* pActiveModule = (SbModule*)pBasic->FindModule( it->second->GetName() );
                            if( pActiveModule && ( pActiveModule->GetModuleType() == script::ModuleType::DOCUMENT ) )
@@ -493,6 +601,23 @@ void BasicIDETabBar::EndRenaming()
}


namespace
{

// helper class for sorting TabBar
struct TabBarSortHelper
{
    sal_uInt16      nPageId;
    String          aPageText;

    bool operator < (TabBarSortHelper const& rComp) const
    {
        return aPageText.CompareIgnoreCaseToAscii(rComp.aPageText) == COMPARE_LESS;
    }
};

} // namespace

void BasicIDETabBar::Sort()
{
    BasicIDEShell* pIDEShell = BasicIDEGlobals::GetShell();
@@ -513,11 +638,11 @@ void BasicIDETabBar::Sort()
            aTabBarSortHelper.aPageText = GetPageText( nId );
            IDEBaseWindow* pWin = aIDEWindowTable[ nId ];

            if (dynamic_cast<ModulWindow*>(pWin))
            if (dynamic_cast<basctl::ModulWindow*>(pWin))
            {
                aModuleList.push_back( aTabBarSortHelper );
            }
            else if (dynamic_cast<DialogWindow*>(pWin))
            else if (dynamic_cast<basctl::DialogWindow*>(pWin))
            {
                aDialogList.push_back( aTabBarSortHelper );
            }
@@ -628,19 +753,6 @@ LibInfoKey::~LibInfoKey()
{
}

LibInfoKey::LibInfoKey( const LibInfoKey& rKey )
    :m_aDocument( rKey.m_aDocument )
    ,m_aLibName( rKey.m_aLibName )
{
}

LibInfoKey& LibInfoKey::operator=( const LibInfoKey& rKey )
{
    m_aDocument = rKey.m_aDocument;
    m_aLibName = rKey.m_aLibName;
    return *this;
}

bool LibInfoKey::operator==( const LibInfoKey& rKey ) const
{
    bool bRet = false;
diff --git a/basctl/source/basicide/layout.cxx b/basctl/source/basicide/layout.cxx
new file mode 100644
index 0000000..7fd33d7
--- /dev/null
+++ b/basctl/source/basicide/layout.cxx
@@ -0,0 +1,362 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */

#include "layout.hxx"

#include "bastypes.hxx"

#include <boost/make_shared.hpp>

namespace basctl
{

namespace
{
// the thickness of the splitting lines
static int const nSplitThickness = 3;
} // namespace

// ctor for derived classes
// pParent: the parent window (BasicIDEShell)
Layout::Layout (Window* pParent) :
    Window(pParent, WB_CLIPCHILDREN),
    pChild(0),
    bFirstSize(true),
    aLeftSide(this, SplittedSide::Left),
    aBottomSide(this, SplittedSide::Bottom)
{
    SetBackground(GetSettings().GetStyleSettings().GetWindowColor());

    Font aFont = GetFont();
    Size aSz = aFont.GetSize();
    aSz.Height() *= 1.5;
    aFont.SetSize(aSz);
    aFont.SetWeight(WEIGHT_BOLD);
    aFont.SetColor(GetSettings().GetStyleSettings().GetWindowTextColor());
    SetFont(aFont);
}

// virtual dtor
Layout::~Layout()
{ }

// called by Window when resized
void Layout::Resize()
{
    if (IsVisible())
        ArrangeWindows();
}

// ArrangeWindows() -- arranges the child windows
void Layout::ArrangeWindows ()
{
    Size const aSize = GetOutputSizePixel();
    int const nWidth = aSize.Width(), nHeight = aSize.Height();
    if (!nWidth || !nHeight) // empty size
        return;
    if (bFirstSize)
    {
        this->OnFirstSize(nWidth, nHeight); // virtual
        bFirstSize = false;
    }

    // sides
    aBottomSide.ArrangeIn(Rectangle(Point(0, 0), aSize));
    aLeftSide.ArrangeIn(Rectangle(Point(0, 0), Size(nWidth, nHeight - aBottomSide.GetSize())));
    // child in the middle
    pChild->SetPosSizePixel(
        Point(aLeftSide.GetSize(), 0),
        Size(nWidth - aLeftSide.GetSize(), nHeight - aBottomSide.GetSize())
    );
}

void Layout::DockaWindow (DockingWindow*)
{
    ArrangeWindows();
}

void Layout::Activating (IDEBaseWindow& rIdeWindow)
{
    // first activation
    pChild = &rIdeWindow;
    ArrangeWindows();
    Show();
    pChild->Activating();
}

void Layout::Deactivating ()
{
    if (pChild)
        pChild->Deactivating();
    Hide();
    pChild = 0;
}

void Layout::ExecuteGlobal (SfxRequest&)
{ }

void Layout::GetState (SfxItemSet&, unsigned /*nWhich*/)
{ }

void Layout::UpdateDebug (bool bBasicStopped)
{
    static_cast<void>(bBasicStopped);
}

// virtual
void Layout::DataChanged (DataChangedEvent const& rDCEvt)
{
    Window::DataChanged(rDCEvt);
    if (rDCEvt.GetType() == DATACHANGED_SETTINGS && (rDCEvt.GetFlags() & SETTINGS_STYLE))
    {
        bool bInvalidate = false;
        Color aColor = GetSettings().GetStyleSettings().GetWindowColor();
        if (aColor != rDCEvt.GetOldSettings()->GetStyleSettings().GetWindowColor())
        {
            SetBackground(Wallpaper(aColor));
            bInvalidate = true;
        }
        aColor = GetSettings().GetStyleSettings().GetWindowTextColor();
        if (aColor != rDCEvt.GetOldSettings()->GetStyleSettings().GetWindowTextColor())
        {
            Font aFont(GetFont());
            aFont.SetColor(aColor);
            SetFont(aFont);
            bInvalidate = true;
        }
        if (bInvalidate)
            Invalidate();
    }
}

// virtual
void Layout::ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 )
{ }

// This virtual function is called the first time when the Layout has nonzero size.
// The overrider can initialize the docking windows.
void Layout::OnFirstSize (int, int)
{ }


//
// SplittedSide
// ============
//

// ctor
Layout::SplittedSide::SplittedSide (Layout* pParent, Side eSide) :
    rLayout(*pParent),
    bFirstArrange(true),
    bVertical(eSide == Left || eSide == Right),
    bLower(eSide == Left || eSide == Top),
    nSize(0),
    nLastPos(0),
    aSplitter(pParent, bVertical ? WB_HSCROLL : WB_VSCROLL)
{
    InitSplitter(aSplitter);
}


// Add() -- adds a new window to the side (after construction)
void Layout::SplittedSide::Add (BasicDockingWindow* pWin, Size const& rSize)
{
    int const nSize1 = (bVertical ? rSize.Width() : rSize.Height()) + nSplitThickness;
    int const nSize2 = bVertical ? rSize.Height() : rSize.Width();
    // nSize
    if (nSize1 > nSize)
        nSize = nSize1;
    // window
    vWindows.push_back(pWin);
    // split line
    if (vWindows.size() > 1)
    {
        vSplitters.push_back(boost::make_shared<Splitter>(
            &rLayout, bVertical ? WB_VSCROLL : WB_HSCROLL
        ));
        Splitter& rSplitter = *vSplitters.back();
        rSplitter.SetSplitPosPixel(nLastPos - nSplitThickness);
        InitSplitter(rSplitter);
    }
    // nLastPos
    nLastPos += nSize2 + nSplitThickness;
}

// creating a Point or a Size object
// The coordinate order depends on bVertical (reversed if true).
inline Size Layout::SplittedSide::MakeSize (int A, int B) const
{
    return bVertical ? Size(B, A) : Size(A, B);
}
inline Point Layout::SplittedSide::MakePoint (int A, int B) const
{
    return bVertical ? Point(B, A) : Point(A, B);
}

// IsEmpty() -- are there no windows docked in this strip?
bool Layout::SplittedSide::IsEmpty () const
{
    for (unsigned i = 0; i != vWindows.size(); ++i)
        if (vWindows[i]->IsVisible() && !vWindows[i]->IsFloatingMode())
            return false;
    return true;
}

// GetSize() -- returns the width or height of the strip (depending on the direction)
int Layout::SplittedSide::GetSize () const
{
    return IsEmpty() ? 0 : nSize;
}

// Arrange() -- arranges the docking windows
// rRect: the available space
void Layout::SplittedSide::ArrangeIn (Rectangle const& rRect)
{
    // saving the rectangle
    aRect = rRect;

    // the length of the side
    int const nLength = bVertical ? aRect.GetSize().Height() : aRect.GetSize().Width();
    int const nOtherSize = bVertical ? aRect.GetSize().Width() : aRect.GetSize().Height();
    // bVertical ? horizontal pozition : vertical pozition
    int const nPos1 = (bVertical ? aRect.Left() : aRect.Top()) +
        (bLower ? 0 : nOtherSize - (nSize - nSplitThickness));
    // bVertical ? vertical position : horizontal position
    int const nPos2 = bVertical ? aRect.Top() : aRect.Left();

    // main line
    {
        // shown if any of the windows is docked
        if (!IsEmpty())
        {
            aSplitter.Show();
            // split position
            aSplitter.SetSplitPosPixel((bLower ? nSize : nPos1) - nSplitThickness);
            // the actual position and size
            aSplitter.SetPosSizePixel(
                MakePoint(nPos2, aSplitter.GetSplitPosPixel()),
                MakeSize(nLength, nSplitThickness)
            );
            // dragging rectangle
            aSplitter.SetDragRectPixel(aRect);
        }
        else
            aSplitter.Hide();
    }

    // positioning separator lines and windows
    bool bPrevDocked; // is the previous window docked?
    int nStartPos = nPos2; // window position in the strip
    for (unsigned i = 0; i != vWindows.size(); ++i)
    {
        // window
        BasicDockingWindow& rWin = *vWindows[i];
        bool const bDocked = rWin.IsVisible() && !rWin.IsFloatingMode();
        // The window is docked between nStartPos and nEndPos along.
        int const nEndPos = i == vWindows.size() - 1 ?
            nPos2 + nLength : vSplitters[i]->GetSplitPosPixel();
        rWin.ResizeIfDocking(
            MakePoint(nStartPos, nPos1),
            MakeSize(nEndPos - nStartPos, nSize - nSplitThickness)
        );
        // splitting line before the window
        if (i > 0)
        {
            Splitter& rSplit = *vSplitters[i - 1];
            // If neither of two adjacent windows are docked,
            // the splitting line is hidden.
            if (bDocked || bPrevDocked)
            {
                rSplit.Show();
                // the actual pozition and size of the line
                rSplit.SetPosSizePixel(
                    MakePoint(nStartPos - nSplitThickness, nPos1),
                    MakeSize(nSplitThickness, nSize - nSplitThickness)
                );
                // the dragging rectangle
                rSplit.SetDragRectPixel(Rectangle(
                    MakePoint(bVertical ? aRect.Top() : aRect.Left(), nPos1),
                    MakeSize(nLength, nSize - nSplitThickness)
                ));
            }
            else
                rSplit.Hide();
        }
        // next
        bPrevDocked = bDocked;
        nStartPos = nEndPos + nSplitThickness;
    }

    // first arrange
    bFirstArrange = false;
}

IMPL_LINK(Layout::SplittedSide, SplitHdl, Splitter*, pSplitter)
{
    // checking margins
    CheckMarginsFor(pSplitter);
    // nSize has to be changed?
    if (pSplitter == &aSplitter)
    {
        if (bLower)
            nSize = pSplitter->GetSplitPosPixel();
        else
            nSize = (bVertical ? aRect.Right() : aRect.Bottom()) + 1 - pSplitter->GetSplitPosPixel();
    }
    // arranging windows
    rLayout.ArrangeWindows();

    return 0;
}

void Layout::SplittedSide::CheckMarginsFor (Splitter* pSplitter)
{
    // The splitter line cannot be closer to the edges than nMargin pixels.
    static int const nMargin = 16;
    // Checking margins:
    if (int const nLength = pSplitter->IsHorizontal() ?
        aRect.GetWidth() : aRect.GetHeight()
    ) {
        // bounds
        int const nLower = (pSplitter->IsHorizontal() ? aRect.Left() : aRect.Top()) + nMargin;
        int const nUpper = nLower + nLength - 2*nMargin;
        // split position
        int const nPos = pSplitter->GetSplitPosPixel();
        // checking bounds
        if (nPos < nLower)
            pSplitter->SetSplitPosPixel(nLower);
        if (nPos > nUpper)
            pSplitter->SetSplitPosPixel(nUpper);
    }
}

void Layout::SplittedSide::InitSplitter (Splitter& rSplitter)
{
    // link
    rSplitter.SetSplitHdl(LINK(this, SplittedSide, SplitHdl));
    // color
    Color aColor = rLayout.GetSettings().GetStyleSettings().GetShadowColor();
    rSplitter.SetLineColor(aColor);
    rSplitter.SetFillColor(aColor);
}


} // namespace basctl

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/layout.hxx b/basctl/source/basicide/layout.hxx
new file mode 100644
index 0000000..eca1b98
--- /dev/null
+++ b/basctl/source/basicide/layout.hxx
@@ -0,0 +1,125 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */

#ifndef BASCTL_LAYOUT_HXX
#define BASCTL_LAYOUT_HXX

#include <vcl/window.hxx>
#include <vcl/split.hxx>
#include <unotools/options.hxx>

#include <vector>
#include <boost/shared_ptr.hpp>

class DockingWindow;
class BasicDockingWindow;
class IDEBaseWindow;
class SfxRequest;
class SfxItemSet;

namespace basctl
{

//
// Layout -- the common base of ModulLayout and DialogLayout.
// Handles the splitting lines and the dockable windows.
//
class Layout: public Window, public utl::ConfigurationListener
{
public:
    void DockaWindow (DockingWindow*);
    void ArrangeWindows ();

    virtual void Activating (IDEBaseWindow&);
    virtual void Deactivating ();
    virtual void ExecuteGlobal (SfxRequest&);
    virtual void GetState (SfxItemSet&, unsigned nWhich);
    virtual void UpdateDebug (bool bBasicStopped = false);

protected:
    Layout (Window* pParent);
    virtual ~Layout ();

    void AddToLeft   (BasicDockingWindow* pWin, Size const& rSize) { aLeftSide.Add(pWin, rSize); }
    void AddToBottom (BasicDockingWindow* pWin, Size const& rSize) { aBottomSide.Add(pWin, rSize); }

protected:
    // Window:
    virtual void Resize ();
    virtual void DataChanged (DataChangedEvent const& rDCEvt);
    // ConfigurationListener:
    virtual void ConfigurationChanged (utl::ConfigurationBroadcaster*, sal_uInt32);
    // new:
    virtual void OnFirstSize (int nWidth, int nHeight);

private:
    // the main child window (either ModulWindow or DialogWindow)
    IDEBaseWindow* pChild;

    // when this window has at first (nonempty) size
    bool bFirstSize;

    // horizontal or vertical splitted strip
    class SplittedSide
    {
    public:
        enum Side {Right, Top, Left, Bottom};
        SplittedSide (Layout*, Side);
        void Add (BasicDockingWindow*, Size const&);
        bool IsEmpty () const;
        int  GetSize () const;
        void ArrangeIn (Rectangle const&);

    private:
        // the layout window
        Layout& rLayout;
        // ArrangeIn() is called at first time?
        bool bFirstArrange;
        // horizontal or vertical strip?
        bool bVertical;
        // lower (top or left) or higher (bottom or right) strip?
        bool bLower;
        // rectangle to move in
        Rectangle aRect;
        // size (width or height)
        int nSize;
        // last position (between Add()s)
        int nLastPos;
        // the main splitting line
        Splitter aSplitter;
        // the dockable windows
        std::vector<BasicDockingWindow*> vWindows;
        // splitting lines between the docking windows (vWindows.size() - 1)
        std::vector<boost::shared_ptr<Splitter> > vSplitters;

    private:
        Point MakePoint (int, int) const;
        Size MakeSize (int, int) const;
    private:
        DECL_LINK(SplitHdl, Splitter*);
        void CheckMarginsFor (Splitter*);
        void InitSplitter (Splitter&);
    } aLeftSide, aBottomSide;
};

} // namespace basctl

#endif // BASCTL_LAYOUT_HXX

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/linenumberwindow.cxx b/basctl/source/basicide/linenumberwindow.cxx
index b6d5223..40093ed 100644
--- a/basctl/source/basicide/linenumberwindow.cxx
+++ b/basctl/source/basicide/linenumberwindow.cxx
@@ -32,9 +32,9 @@
#include <vcl/xtextedt.hxx>
#include <vcl/textview.hxx>

LineNumberWindow::LineNumberWindow( Window* pParent, ModulWindow* pModulWin ) :
    Window( pParent, WB_BORDER ),
    m_pModulWindow(pModulWin),
LineNumberWindow::LineNumberWindow (Window* pParent, basctl::ModulWindow* pModulWindow) :
    Window(pParent, WB_BORDER),
    m_pModulWindow(pModulWindow),
    m_nCurYOffset(0)
{
    SetBackground(Wallpaper(GetSettings().GetStyleSettings().GetFieldColor()));
diff --git a/basctl/source/basicide/linenumberwindow.hxx b/basctl/source/basicide/linenumberwindow.hxx
index 48c2414..7c8f717 100644
--- a/basctl/source/basicide/linenumberwindow.hxx
+++ b/basctl/source/basicide/linenumberwindow.hxx
@@ -30,12 +30,15 @@

#include <vcl/window.hxx>

class ModulWindow;
namespace basctl
{
    class ModulWindow;
}

class LineNumberWindow : public Window
{
private:
    ModulWindow* m_pModulWindow;
    basctl::ModulWindow* m_pModulWindow;
    int m_nWidth;
    long m_nCurYOffset;
    int m_nBaseWidth;
@@ -45,7 +48,7 @@ protected:
    virtual void Paint( const Rectangle& );

public:
    LineNumberWindow( Window* pParent, ModulWindow* pModulWin );
    LineNumberWindow (Window* pParent, basctl::ModulWindow* pModulWin);
    ~LineNumberWindow();

    void DoScroll( long nHorzScroll, long nVertScroll );
diff --git a/basctl/source/basicide/localizationmgr.cxx b/basctl/source/basicide/localizationmgr.cxx
index ea43931..8df518b 100644
--- a/basctl/source/basicide/localizationmgr.cxx
+++ b/basctl/source/basicide/localizationmgr.cxx
@@ -17,12 +17,14 @@
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */

#include <basidesh.hxx>
#include <baside3.hxx>
#include <basobj.hxx>
#include <iderdll.hxx>
#include "localizationmgr.hxx"

#include "basidesh.hxx"
#include "baside3.hxx"
#include "basobj.hxx"
#include "iderdll.hxx"
#include "dlged.hxx"
#include <localizationmgr.hxx>

#include <com/sun/star/resource/XStringResourceSupplier.hpp>
#include <com/sun/star/frame/XLayoutManager.hpp>
#include <sfx2/dispatch.hxx>
@@ -33,6 +35,9 @@ using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::resource;

using basctl::DialogWindow;
using basctl::ModulWindow;

static ::rtl::OUString aDot( RTL_CONSTASCII_USTRINGPARAM( "." ));
static ::rtl::OUString aEsc( RTL_CONSTASCII_USTRINGPARAM( "&" ));
static ::rtl::OUString aSemi( RTL_CONSTASCII_USTRINGPARAM( ";" ));
@@ -134,10 +139,9 @@ void LocalizationMgr::implEnableDisableResourceForAllLibraryDialogs( HandleResou
    for( sal_Int32 i = 0 ; i < nDlgCount ; i++ )
    {
        String aDlgName = pDlgNames[ i ];
        DialogWindow* pWin = m_pIDEShell->FindDlgWin( m_aDocument, m_aLibName, aDlgName, false );
        if (DialogWindow* pDialogWin = dynamic_cast<DialogWindow*>(pWin))
        if (DialogWindow* pWin = m_pIDEShell->FindDlgWin(m_aDocument, m_aLibName, aDlgName))
        {
            Reference< container::XNameContainer > xDialog = pDialogWin->GetDialog();
            Reference< container::XNameContainer > xDialog = pWin->GetDialog();
            if( xDialog.is() )
            {
                // Handle dialog itself as control
diff --git a/basctl/source/basicide/objdlg.cxx b/basctl/source/basicide/objdlg.cxx
index 00fc82c..3780039 100644
--- a/basctl/source/basicide/objdlg.cxx
+++ b/basctl/source/basicide/objdlg.cxx
@@ -24,7 +24,7 @@
#include "iderdll.hxx"
#include "iderdll2.hxx"
#include "objdlg.hxx"
#include <helpid.hrc>
#include "helpid.hrc"

#include <sfx2/app.hxx>
#include <sfx2/dispatch.hxx>
@@ -34,6 +34,9 @@
#include <vcl/msgbox.hxx>
#include <vcl/taskpanelist.hxx>

namespace basctl
{

ObjectCatalog::ObjectCatalog (Window* pParent) :
    BasicDockingWindow(pParent),
    aTitle(this),
@@ -137,4 +140,7 @@ void ObjectCatalog::SetCurrentEntry (IDEBaseWindow* pCurWin)
    aTree.SetCurrentEntry(aDescriptor);
}


} // namespace basctl

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/objdlg.hxx b/basctl/source/basicide/objdlg.hxx
index 91a4b77..d4477212 100644
--- a/basctl/source/basicide/objdlg.hxx
+++ b/basctl/source/basicide/objdlg.hxx
@@ -20,13 +20,17 @@
#ifndef BASCTL_OBJDLG_HXX
#define BASCTL_OBJDLG_HXX

#include "bastype2.hxx"
#include "bastypes.hxx"

#include <svheader.hxx>
#include <vcl/floatwin.hxx>
#include <vcl/toolbox.hxx>
#include <vcl/fixed.hxx>
#include <vcl/image.hxx>

#include <bastype2.hxx>
namespace basctl
{

//
// ObjectCatalog -- a docking window that contains the currently loaded macros
@@ -53,6 +57,8 @@ private:
    void ArrangeWindows ();
};

} // namespace basctl

#endif // BASCTL_OBJDLG_HXX

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/inc/accessibledialogcontrolshape.hxx b/basctl/source/inc/accessibledialogcontrolshape.hxx
index 0d5e512..eae49f2 100644
--- a/basctl/source/inc/accessibledialogcontrolshape.hxx
+++ b/basctl/source/inc/accessibledialogcontrolshape.hxx
@@ -26,9 +26,12 @@
#include <cppuhelper/implbase3.hxx>

class Window;
class DialogWindow;
class DlgEdObj;
class VCLExternalSolarLock;
namespace basctl
{
    class DialogWindow;
}

namespace utl {
class AccessibleStateSetHelper;
@@ -52,7 +55,7 @@ class AccessibleDialogControlShape :    public AccessibleExtendedComponentHelper

private:
    VCLExternalSolarLock*   m_pExternalLock;
    DialogWindow*           m_pDialogWindow;
    basctl::DialogWindow*   m_pDialogWindow;
    DlgEdObj*               m_pDlgEdObj;
    bool                    m_bFocused;
    bool                    m_bSelected;
@@ -83,7 +86,7 @@ protected:
    virtual void SAL_CALL   disposing();

public:
    AccessibleDialogControlShape( DialogWindow* pDialogWindow, DlgEdObj* pDlgEdObj );
    AccessibleDialogControlShape (basctl::DialogWindow*, DlgEdObj*);
    virtual ~AccessibleDialogControlShape();

    // XInterface
diff --git a/basctl/source/inc/accessibledialogwindow.hxx b/basctl/source/inc/accessibledialogwindow.hxx
index e3fd973..b763b29 100644
--- a/basctl/source/inc/accessibledialogwindow.hxx
+++ b/basctl/source/inc/accessibledialogwindow.hxx
@@ -27,7 +27,6 @@
#include <svl/lstner.hxx>
#include <tools/link.hxx>

class DialogWindow;
class DlgEditor;
class DlgEdModel;
class DlgEdObj;
@@ -35,6 +34,10 @@ class VCLExternalSolarLock;
class VclSimpleEvent;
class VclWindowEvent;

namespace basctl
{
    class DialogWindow;
}
namespace utl {
class AccessibleStateSetHelper;
}
@@ -77,7 +80,7 @@ private:

    AccessibleChildren      m_aAccessibleChildren;
    VCLExternalSolarLock*   m_pExternalLock;
    DialogWindow*           m_pDialogWindow;
    basctl::DialogWindow*   m_pDialogWindow;
    DlgEditor*              m_pDlgEditor;
    DlgEdModel*             m_pDlgEdModel;

@@ -106,7 +109,7 @@ protected:
    virtual void SAL_CALL   disposing();

public:
    AccessibleDialogWindow( DialogWindow* pDialogWindow );
    AccessibleDialogWindow (basctl::DialogWindow*);
    ~AccessibleDialogWindow();

    // SfxListener
diff --git a/basctl/source/inc/baside3.hxx b/basctl/source/inc/baside3.hxx
index f2560e3..f54e9ade 100644
--- a/basctl/source/inc/baside3.hxx
+++ b/basctl/source/inc/baside3.hxx
@@ -17,9 +17,10 @@
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */

#ifndef _BASIDE3_HXX
#define _BASIDE3_HXX
#ifndef BASCTL_BASIDE3_HXX
#define BASCTL_BASIDE3_HXX

#include "../basicide/layout.hxx"
#include <bastypes.hxx>
#include <svl/undo.hxx>
#include <vcl/dialog.hxx>
@@ -38,9 +39,16 @@ class DlgEdPage;
class DlgEdView;
class SfxUndoManager;

namespace basctl
{

class DialogWindowLayout;
class ObjectCatalog;

class DialogWindow: public IDEBaseWindow
{
private:
    DialogWindowLayout& rLayout;
    DlgEditor*          pEditor;
    SfxUndoManager*     pUndoMgr;
    Link                aOldNotifyUndoActionHdl;
@@ -65,8 +73,7 @@ protected:

public:
                        TYPEINFO();
    DialogWindow( Window* pParent, const ScriptDocument& rDocument, ::rtl::OUString aLibName, ::rtl::OUString aName,
                            const com::sun::star::uno::Reference< com::sun::star::container::XNameContainer >& xDialogModel );
    DialogWindow (DialogWindowLayout* pParent, ScriptDocument const& rDocument, rtl::OUString aLibName, rtl::OUString aName, com::sun::star::uno::Reference<com::sun::star::container::XNameContainer> const& xDialogModel);
                        DialogWindow( DialogWindow* pCurView ); // never implemented
                        ~DialogWindow();

@@ -97,12 +104,45 @@ public:
    // return number of pages to be printed
    virtual sal_Int32 countPages( Printer* pPrinter );
    // print page
    virtual void printPage( sal_Int32 nPage, Printer* pPrinter );
    virtual void        Deactivating();
    virtual void        printPage (sal_Int32 nPage, Printer*);

    virtual void        Activating ();
    virtual void        Deactivating ();

    virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();

    virtual char const* GetHid () const;
    virtual BasicIDEType GetType () const;
};

#endif  // _BASIDE3_HXX
//
// DialogWindowLayout
//
class DialogWindowLayout : public Layout
{
public:
    DialogWindowLayout (Window* pParent, ObjectCatalog&);
public:
    // Layout:
    virtual void Activating (IDEBaseWindow&);
    virtual void Deactivating ();
    virtual void GetState (SfxItemSet&, unsigned nWhich);

protected:
    // Layout:
    virtual void OnFirstSize (int nWidth, int nHeight);

private:
    // child window
    DialogWindow* pChild;
    // dockable windows
    ObjectCatalog& rObjectCatalog;
    // TODO property browser
};


} // namespace basctl

#endif  // BASCTL_BASIDE3_HXX

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/inc/basidesh.hxx b/basctl/source/inc/basidesh.hxx
index 70cf669..69862ce 100644
--- a/basctl/source/inc/basidesh.hxx
+++ b/basctl/source/inc/basidesh.hxx
@@ -16,17 +16,19 @@
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */
#ifndef _BASIDESH_HXX
#define _BASIDESH_HXX
#ifndef BASCTL_BASIDESH_HXX
#define BASCTL_BASIDESH_HXX

#include "doceventnotifier.hxx"
#include "sbxitem.hxx"
#include "../basicide/objdlg.hxx"

#include <com/sun/star/container/XContainerListener.hpp>
#include <sfx2/viewsh.hxx>
#include <svx/ifaceids.hxx>
#include <vcl/scrbar.hxx>
#include <map>
#include <boost/scoped_ptr.hpp>

class SfxViewFactory;

@@ -36,9 +38,14 @@ const sal_uLong BASICIDE_UI_FEATURE_SHOW_BROWSER = 0x00000001;

//----------------------------------------------------------------------------

class ModulWindow;
class ModulWindowLayout;
class DialogWindow;
namespace basctl
{
    class Layout;
    class ModulWindow;
    class ModulWindowLayout;
    class DialogWindow;
    class DialogWindowLayout;
}
class SdrView;
class BasicIDETabBar;
class TabBar;
@@ -59,15 +66,21 @@ namespace BasicIDE
    bool RemoveDialog( const ScriptDocument& rDocument, const ::rtl::OUString& rLibName, const ::rtl::OUString& rDlgName );
}

class BasicIDEShell :public SfxViewShell
                    ,public ::basctl::DocumentEventListener
class BasicIDEShell :
    public SfxViewShell,
    public basctl::DocumentEventListener
{
friend class LocalizationMgr;
    typedef basctl::DialogWindow DialogWindow;
    typedef basctl::ModulWindow ModulWindow;

    friend class JavaDebuggingListenerImpl;
    friend class LocalizationMgr;
    friend bool implImportDialog( Window* pWin, const ::rtl::OUString& rCurPath, const ScriptDocument& rDocument, const ::rtl::OUString& aLibName );
    friend bool BasicIDE::RemoveDialog( const ScriptDocument& rDocument, const ::rtl::OUString& rLibName, const ::rtl::OUString& rDlgName );

    typedef IDEWindowTable::const_iterator WindowTableIt;

    IDEWindowTable      aIDEWindowTable;
    sal_uInt16              nCurKey;
    sal_uInt16          nCurKey;
    IDEBaseWindow*      pCurWin;
    ScriptDocument      m_aCurDocument;
    ::rtl::OUString     m_aCurLibName;
@@ -79,11 +92,18 @@ friend class LocalizationMgr;
    BasicIDETabBar*     pTabBar;
    bool                bTabBarSplitted;
    bool                bCreatingWindow;
    ModulWindowLayout*  pModulLayout;
    // layout windows
    boost::scoped_ptr<basctl::ModulWindowLayout> pModulLayout;
    boost::scoped_ptr<basctl::DialogWindowLayout> pDialogLayout;
    // the active layout window
    basctl::Layout* pLayout;
    // common object catalog window
    basctl::ObjectCatalog aObjectCatalog;

    bool                m_bAppBasicModified;
    ::basctl::DocumentEventNotifier
                        m_aNotifier;
friend class ContainerListenerImpl;
    friend class ContainerListenerImpl;
    ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener > m_xLibListener;

#if _SOLAR__PRIVATE
@@ -115,13 +135,11 @@ protected:

    void                SetCurWindow( IDEBaseWindow* pNewWin, bool bUpdateTabBar = false, bool bRememberAsCurrent = true );
    void                ManageToolbars();
    void                RemoveWindow( IDEBaseWindow* pWindow, bool bDestroy, bool bAllowChangeCurWindow = true );
    void                ArrangeTabBar();

    ModulWindow*        CreateBasWin( const ScriptDocument& rDocument, const ::rtl::OUString& rLibName, const ::rtl::OUString& rModName );
    DialogWindow*       CreateDlgWin( const ScriptDocument& rDocument, const ::rtl::OUString& rLibName, const ::rtl::OUString& rDlgName );

    ModulWindow*        FindBasWin( const ScriptDocument& rDocument, const ::rtl::OUString& rLibName, const ::rtl::OUString& rModName, bool bCreateIfNotExist, bool bFindSuspended = false );
    ModulWindow*        ShowActiveModuleWindow( StarBASIC* pBasic );

    virtual void        SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
@@ -133,10 +151,6 @@ protected:
    virtual void        Move();
    virtual void        ShowCursor( bool bOn = true );

    void                CreateModulWindowLayout();
    void                DestroyModulWindowLayout();
    void                UpdateModulWindowLayout( bool bBasicStopped );

    // DocumentEventListener
    virtual void onDocumentCreated( const ScriptDocument& _rDocument );
    virtual void onDocumentOpened( const ScriptDocument& _rDocument );
@@ -178,9 +192,9 @@ public:

    // virtual sal_uInt16           Print( SfxProgress &rProgress, sal_Bool bIsAPI, PrintDialog *pPrintDialog = 0 );
    virtual SfxPrinter*     GetPrinter( sal_Bool bCreate );
    virtual sal_uInt16          SetPrinter( SfxPrinter *pNewPrinter, sal_uInt16 nDiffFlags = SFX_PRINTER_ALL, bool bIsAPI=false );
    virtual sal_uInt16      SetPrinter( SfxPrinter *pNewPrinter, sal_uInt16 nDiffFlags = SFX_PRINTER_ALL, bool bIsAPI=false );
    virtual String          GetSelectionText( sal_Bool bCompleteWords );
    virtual sal_Bool            HasSelection( sal_Bool bText ) const;
    virtual sal_Bool        HasSelection( sal_Bool bText ) const;

    void                GetState( SfxItemSet& );
    void                ExecuteGlobal( SfxRequest& rReq );
@@ -193,10 +207,9 @@ public:
    long                CallBasicErrorHdl( StarBASIC* pBasic );
    long                CallBasicBreakHdl( StarBASIC* pBasic );

    ModulWindowLayout*  GetLayoutWindow() const { return pModulLayout; }

    IDEBaseWindow*      FindWindow( const ScriptDocument& rDocument, const ::rtl::OUString& rLibName = ::rtl::OUString(), const ::rtl::OUString& rName = ::rtl::OUString(), BasicIDEType nType = BASICIDE_TYPE_UNKNOWN, bool bFindSuspended = false );
    DialogWindow*       FindDlgWin( const ScriptDocument& rDocument, const ::rtl::OUString& rLibName, const ::rtl::OUString& rDlgName, bool bCreateIfNotExist, bool bFindSuspended = false );
    DialogWindow*       FindDlgWin( const ScriptDocument& rDocument, const ::rtl::OUString& rLibName, const ::rtl::OUString& rName, bool bCreateIfNotExist = false, bool bFindSuspended = false );
    ModulWindow*        FindBasWin( const ScriptDocument& rDocument, const ::rtl::OUString& rLibName, const ::rtl::OUString& rModName, bool bCreateIfNotExist = false, bool bFindSuspended = false );
    IDEBaseWindow*      FindApplicationWindow();
    bool                NextPage( bool bPrev = false );

@@ -211,12 +224,12 @@ public:

    virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >
                        GetCurrentDocument() const;
    bool SourceLinesDisplayed();

    void UpdateObjectCatalog ();
    void UpdateObjectCatalog () { aObjectCatalog.UpdateEntries(); }

    void RemoveWindow (IDEBaseWindow* pWindow, bool bDestroy, bool bAllowChangeCurWindow = true);
};

#endif // _BASIDESH_HXX
#endif // BASCTL_BASIDESH_HXX

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/inc/bastypes.hxx b/basctl/source/inc/bastypes.hxx
index 90541a5..ca5b49a 100644
--- a/basctl/source/inc/bastypes.hxx
+++ b/basctl/source/inc/bastypes.hxx
@@ -16,11 +16,12 @@
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */
#ifndef _BASTYPES_HXX
#define _BASTYPES_HXX
#ifndef BASCTL_BASTYPES_HXX
#define BASCTL_BASTYPES_HXX

#include "scriptdocument.hxx"

#include <sbxitem.hxx>
#include <iderid.hxx>
#include <svtools/tabbar.hxx>
#include <vcl/toolbox.hxx>
@@ -30,6 +31,14 @@
class SbModule;
class SfxItemSet;
class SfxRequest;
class SvxSearchItem;

namespace basctl
{
    class Layout;
    class ModulWindow;
    class DialogWindow;
}

#define LINE_SEP_CR     0x0D
#define LINE_SEP        0x0A
@@ -58,27 +67,37 @@ struct BasicStatus

class BasicDockingWindow : public DockingWindow
{
    Rectangle       aFloatingPosAndSize;
public:
    BasicDockingWindow (Window* pParent);
    BasicDockingWindow (basctl::Layout* pParent);
public:
    void ResizeIfDocking (Point const&, Size const&);
    void SetLayoutWindow (basctl::Layout*);
public:
    void Show (bool = true);
    void Hide ();

protected:
    virtual sal_Bool    Docking( const Point& rPos, Rectangle& rRect );
    virtual void    EndDocking( const Rectangle& rRect, sal_Bool bFloatMode );
    virtual void    ToggleFloatingMode();
    virtual sal_Bool    PrepareToggleFloatingMode();
    virtual void    StartDocking();
    virtual sal_Bool Docking( const Point& rPos, Rectangle& rRect );
    virtual void     EndDocking( const Rectangle& rRect, sal_Bool bFloatMode );
    virtual void     ToggleFloatingMode();
    virtual sal_Bool PrepareToggleFloatingMode();
    virtual void     StartDocking();

public:
    BasicDockingWindow( Window* pParent );
};
private:
    // the position and the size of the floating window
    Rectangle aFloatingRect;
    // the position and the size of the docking window
    Rectangle aDockingRect;
    // the parent layout window (only when docking)
    basctl::Layout* pLayout;
    // > 0: shown, <= 0: hidden, ++ by Show() and -- by Hide()
    int nShowCount;

// helper class for sorting TabBar
class TabBarSortHelper
{
public:
    sal_uInt16          nPageId;
    String          aPageText;
    static WinBits const StyleBits;

    bool operator<(const TabBarSortHelper& rComp) const { return (aPageText.CompareIgnoreCaseToAscii( rComp.aPageText ) == COMPARE_LESS); }
private:
    void DockThis ();
};

class BasicIDETabBar : public TabBar
@@ -113,6 +132,9 @@ namespace svl
    class IUndoManager;
}

//
// IDEBaseWindow -- the base of both ModulWindow and DialogWindow.
//
class IDEBaseWindow : public Window
{
private:
@@ -126,6 +148,9 @@ private:
    ::rtl::OUString     m_aLibName;
    ::rtl::OUString     m_aName;

    friend class basctl::ModulWindow;
    friend class basctl::DialogWindow;

protected:
    virtual void    DoScroll( ScrollBar* pCurScrollBar );

@@ -136,14 +161,16 @@ public:

    void            Init();
    virtual void    DoInit();
    virtual void    Deactivating();
    virtual void    Activating () = 0;
    virtual void    Deactivating () = 0;
    void            GrabScrollBars( ScrollBar* pHScroll, ScrollBar* pVScroll );

    ScrollBar*      GetHScrollBar() const { return pShellHScrollBar; }
    ScrollBar*      GetVScrollBar() const { return pShellVScrollBar; }

    virtual void    ExecuteCommand( SfxRequest& rReq );
    virtual void    GetState( SfxItemSet& );
    virtual void    ExecuteCommand (SfxRequest&);
    virtual void    ExecuteGlobal (SfxRequest&);
    virtual void    GetState (SfxItemSet&) = 0;
    virtual long    Notify( NotifyEvent& rNEvt );

    virtual void    StoreData();
@@ -172,18 +199,16 @@ public:
    void AddStatus(int n) { nStatus |= n; }
    void ClearStatus(int n) { nStatus &= ~n; }

    virtual Window* GetLayoutWindow();

    virtual ::svl::IUndoManager*
                    GetUndoManager();

    virtual sal_uInt16  GetSearchOptions();
    virtual sal_uInt16  StartSearchAndReplace (SvxSearchItem const&, bool bFromStart = false);

    virtual void    BasicStarted();
    virtual void    BasicStopped();

    bool            IsSuspended() const
                        { return ( nStatus & BASWIN_SUSPENDED ) ? true : false; }
    bool            IsSuspended() const { return nStatus & BASWIN_SUSPENDED; }

    const ScriptDocument&
                    GetDocument() const { return m_aDocument; }
@@ -193,21 +218,25 @@ public:
    void            SetLibName( const ::rtl::OUString& aLibName ) { m_aLibName = aLibName; }
    const ::rtl::OUString&   GetName() const { return m_aName; }
    void            SetName( const ::rtl::OUString& aName ) { m_aName = aName; }

    virtual void OnNewDocument ();
    virtual char const* GetHid () const = 0;
    virtual BasicIDEType GetType () const = 0;
    void InsertLibInfo () const;
    bool Is (ScriptDocument const&, rtl::OUString const&, rtl::OUString const&, BasicIDEType, bool bFindSuspended);
    virtual bool HasActiveEditor () const;
};

class LibInfoKey
{
private:
    ScriptDocument      m_aDocument;
    ScriptDocument  m_aDocument;
    ::rtl::OUString m_aLibName;

public:
    LibInfoKey( const ScriptDocument& rDocument, const ::rtl::OUString& rLibName );
    ~LibInfoKey();

    LibInfoKey( const LibInfoKey& rKey );
    LibInfoKey& operator=( const LibInfoKey& rKey );

    bool operator==( const LibInfoKey& rKey ) const;

    const ScriptDocument&
@@ -218,10 +247,10 @@ public:
class LibInfoItem
{
private:
    ScriptDocument      m_aDocument;
    ScriptDocument  m_aDocument;
    ::rtl::OUString m_aLibName;
    ::rtl::OUString m_aCurrentName;
    sal_uInt16              m_nCurrentType;
    sal_uInt16      m_nCurrentType;

public:
    LibInfoItem( const ScriptDocument& rDocument, const ::rtl::OUString& rLibName, const ::rtl::OUString& rCurrentName, sal_uInt16 nCurrentType );
@@ -230,11 +259,10 @@ public:
    LibInfoItem( const LibInfoItem& rItem );
    LibInfoItem& operator=( const LibInfoItem& rItem );

    const ScriptDocument&
                    GetDocument() const { return m_aDocument; }
    const ::rtl::OUString& GetLibName() const { return m_aLibName; }
    const ScriptDocument&  GetDocument()    const { return m_aDocument; }
    const ::rtl::OUString& GetLibName()     const { return m_aLibName; }
    const ::rtl::OUString& GetCurrentName() const { return m_aCurrentName; }
    sal_uInt16          GetCurrentType() const { return m_nCurrentType; }
    sal_uInt16             GetCurrentType() const { return m_nCurrentType; }
};

class LibInfos
@@ -284,6 +312,7 @@ public:
    static void getObjectName( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rLib, const ::rtl::OUString& rModName, ::rtl::OUString& rObjName );
    static sal_Int32 getModuleType(  const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rLib, const ::rtl::OUString& rModName );
};
#endif  // _BASTYPES_HXX

#endif  // BASCTL_BASTYPES_HXX

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */