Files
libreoffice/automation/source/server/sta_list.cxx

1189 lines
36 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2002-11-18 14:29:33 +00:00
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2002-11-18 14:29:33 +00:00
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
2002-11-18 14:29:33 +00:00
*
* OpenOffice.org - a multi-platform office productivity suite
2002-11-18 14:29:33 +00:00
*
* This file is part of OpenOffice.org.
2002-11-18 14:29:33 +00:00
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
2002-11-18 14:29:33 +00:00
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
2002-11-18 14:29:33 +00:00
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
2002-11-18 14:29:33 +00:00
*
************************************************************************/
#include <tools/time.hxx>
#include <vcl/splitwin.hxx>
#include <vcl/wrkwin.hxx>
#include <basic/ttstrhlp.hxx>
#include "statemnt.hxx"
#include "retstrm.hxx"
#include "rcontrol.hxx"
#if OSL_DEBUG_LEVEL > 1
2002-11-18 14:29:33 +00:00
#include "editwin.hxx"
#endif
#include "profiler.hxx"
#include <vcl/floatwin.hxx>
#include <vcl/toolbox.hxx>
// only needed for dynamic_cast in wintree
#include <svtools/editbrowsebox.hxx>
#include <svtools/valueset.hxx>
#include <svtools/roadmap.hxx>
#include <svtools/extensionlistbox.hxx>
#include <svtools/table/tablecontrol.hxx>
2002-11-18 14:29:33 +00:00
#define WINDOW_ANYTYPE WINDOW_BASE
TTProfiler *StatementList::pProfiler = NULL;
StatementList *StatementList::pFirst = NULL;
sal_Bool StatementList::bReadingCommands = sal_False;
sal_Bool StatementList::bIsInReschedule = sal_False;
sal_uInt16 StatementList::nModalCount = 0;
2002-11-18 14:29:33 +00:00
Window *StatementList::pLastFocusWindow = NULL;
sal_Bool StatementList::bWasDragManager = sal_False;
sal_Bool StatementList::bWasPopupMenu = sal_False;
sal_Bool StatementList::bBasicWasRunning = sal_False;
2002-11-18 14:29:33 +00:00
RetStream *StatementList::pRet = NULL;
sal_Bool StatementList::IsError = sal_False;
sal_Bool StatementList::bDying = sal_False;
sal_Bool StatementList::bExecuting = sal_False;
2002-11-18 14:29:33 +00:00
StatementList *StatementList::pCurrentProfileStatement = NULL;
sal_Bool StatementList::bUsePostEvents = sal_True;
#if OSL_DEBUG_LEVEL > 1
2002-11-18 14:29:33 +00:00
EditWindow *StatementList::m_pDbgWin;
#endif
rtl::OString StatementList::aWindowWaitUId = rtl::OString();
2002-11-18 14:29:33 +00:00
Window *StatementList::pWindowWaitPointer = NULL;
rtl::OString StatementList::aWindowWaitOldHelpId = rtl::OString();
rtl::OString StatementList::aWindowWaitOldUniqueId = rtl::OString();
sal_uInt16 StatementList::nUseBindings = 0;
2002-11-18 14:29:33 +00:00
sal_uInt16 StatementList::aSubMenuId1 = 0;
sal_uInt16 StatementList::aSubMenuId2 = 0;
sal_uInt16 StatementList::aSubMenuId3 = 0;
2002-11-18 14:29:33 +00:00
SystemWindow *StatementList::pMenuWindow = NULL;
TTProperties *StatementList::pTTProperties = NULL;
sal_uInt16 StatementList::nMinTypeKeysDelay = 0;
sal_uInt16 StatementList::nMaxTypeKeysDelay = 0;
sal_Bool StatementList::bDoTypeKeysDelay = sal_False;
2002-11-18 14:29:33 +00:00
Window* StatementList::pFirstDocFrame = NULL;
2002-11-18 14:29:33 +00:00
sal_Bool StatementList::bIsSlotInExecute = sal_False;
sal_Bool StatementList::bCatchGPF = sal_True;
static TTSettings* pTTSettings = NULL;
TTSettings* GetTTSettings()
{
if ( !pTTSettings )
{
pTTSettings = new TTSettings;
// DisplayHID
pTTSettings->pDisplayInstance = NULL;
pTTSettings->pDisplayHidWin = NULL;
pTTSettings->Old = NULL;
pTTSettings->Act = NULL;
pTTSettings->aOriginalCaption.Erase();
// Translate
pTTSettings->pTranslateWin = NULL;
pTTSettings->bToTop = sal_True;
}
return pTTSettings;
}
// FIXME: HELPID
#define IS_WINP_CLOSING(pWin) \
(pWin->GetHelpId().equalsL(RTL_CONSTASCII_STRINGPARAM("TT_Win_is_closing_HID")) && \
pWin->GetUniqueId().equalsL(RTL_CONSTASCII_STRINGPARAM("TT_Win_is_closing_UID")))
2002-11-18 14:29:33 +00:00
StatementList::StatementList()
: nRetryCount(MAX_RETRIES)
, bStatementInQue(sal_False)
2002-11-18 14:29:33 +00:00
{
if (!pRet)
pRet = new RetStream; // as late as possible but still central and at any rate early enough because pRet is private
2002-11-18 14:29:33 +00:00
}
void StatementList::InitProfile()
{
if ( pProfiler )
{
if ( pProfiler->IsProfilingPerCommand() || pProfiler->IsPartitioning() )
pProfiler->StartProfileInterval( pCurrentProfileStatement != this );
#if OSL_DEBUG_LEVEL > 1
2002-11-18 14:29:33 +00:00
if ( pCurrentProfileStatement != NULL && pCurrentProfileStatement != this )
pRet->GenReturn( RET_ProfileInfo, 0, CUniString("InitProfile von anderem Statement gerufen ohne SendProfile\n") );
2002-11-18 14:29:33 +00:00
#endif
pCurrentProfileStatement = this;
}
}
void StatementList::SendProfile( String aText )
{
if ( pProfiler )
{
if ( pCurrentProfileStatement == this )
{
if ( pProfiler->IsProfilingPerCommand() || pProfiler->IsPartitioning() )
pProfiler->EndProfileInterval();
if ( pProfiler->IsProfilingPerCommand() )
pRet->GenReturn( RET_ProfileInfo, 0, pProfiler->GetProfileLine( aText ) );
2002-11-18 14:29:33 +00:00
if ( pProfiler->IsPartitioning() )
2010-06-04 20:07:26 +02:00
// FIXME: HELPID
pRet->GenReturn( RET_ProfileInfo, S_ProfileTime, static_cast<comm_UINT32>(pProfiler->GetPartitioningTime()) ); // GetPartitioningTime() sal_uLong != comm_UINT32 on 64bit
2002-11-18 14:29:33 +00:00
}
if ( pProfiler->IsAutoProfiling() )
pRet->GenReturn( RET_ProfileInfo, 0, pProfiler->GetAutoProfiling() );
2002-11-18 14:29:33 +00:00
#if OSL_DEBUG_LEVEL > 1
2002-11-18 14:29:33 +00:00
if ( pCurrentProfileStatement == NULL )
pRet->GenReturn( RET_ProfileInfo, 0, CUniString("SendProfile ohne InitProfile\n") );
2002-11-18 14:29:33 +00:00
#endif
pCurrentProfileStatement = NULL;
}
}
void StatementList::QueStatement(StatementList *pAfterThis)
{
Merge commit 'ooo/DEV300_m101' into integration/dev300_m101 * commit 'ooo/DEV300_m101': (185 commits) masterfix DEV300: #i10000# usage of L10N build_type masterfix: #i10000# INT16 -> sal_Int16 fixed compile errors after resync to m100, part2 gridsort: post-rebase fixes CWS gnumake3: found another tools integer type removetooltypes01: Fix build problems after rebase to DEV300m99 in basctl, cui, reportdesign, sw native359: #i114398# changing mac langpack icon native359: #i115669# fixing package description for solaris packages gnumake3: remove comphelper version; fix including extract.hxx locales34: #i106785# add Haitian_Haiti [ht-HT] to language list and locale data; locale data contributed by <jcpoulard> sb138: #i116659# timely termination of OnLogRotateThread accfixes: removed include of obsolete header file accfixes: removed obsolete file removetooltypes01: #i112600# Fix build problems on non-pro accfixes: moved some shared strings to svx part2 accfixes: moved some shared strings to svx accfixes: added more accessibility information and fixed tab orders in multiple dialogs (cui module) removetooltypes01: #i112600# Remove tools types for Mac specific parts fixed tab order in BasicIDE, Library dialog tab page added some accessible names in BasicIDE ... Conflicts: UnoControls/source/base/registercontrols.cxx accessibility/inc/accessibility/standard/vclxaccessiblelistboxlist.hxx automation/inc/automation/communi.hxx automation/inc/automation/simplecm.hxx automation/source/communi/communi.cxx automation/source/inc/rcontrol.hxx automation/source/miniapp/servuid.hxx automation/source/server/XMLParser.cxx automation/source/server/cmdbasestream.cxx automation/source/server/profiler.hxx automation/source/server/recorder.cxx automation/source/server/retstrm.hxx automation/source/server/server.cxx automation/source/server/sta_list.cxx automation/source/server/statemnt.cxx automation/source/server/statemnt.hxx automation/source/simplecm/packethandler.cxx automation/source/simplecm/simplecm.cxx automation/source/simplecm/tcpio.cxx automation/source/simplecm/tcpio.hxx automation/source/testtool/comm_bas.hxx automation/source/testtool/cretstrm.hxx automation/source/testtool/httprequest.cxx automation/source/testtool/httprequest.hxx automation/source/testtool/objtest.cxx automation/source/testtool/objtest.hxx basctl/source/basicide/baside2.cxx basctl/source/basicide/baside2.hxx basctl/source/basicide/baside2b.cxx basctl/source/basicide/baside3.cxx basctl/source/basicide/basides1.cxx basctl/source/basicide/basides2.cxx basctl/source/basicide/basidesh.cxx basctl/source/basicide/basidesh.src basctl/source/basicide/basobj3.cxx basctl/source/basicide/bastype2.cxx basctl/source/basicide/bastype3.cxx basctl/source/basicide/bastypes.cxx basctl/source/basicide/brkdlg.cxx basctl/source/basicide/iderdll.cxx basctl/source/basicide/macrodlg.cxx basctl/source/basicide/moduldl2.cxx basctl/source/basicide/moduldlg.cxx basctl/source/basicide/objdlg.cxx basctl/source/basicide/scriptdocument.cxx basctl/source/basicide/tbxctl.cxx basctl/source/basicide/tbxctl.hxx basctl/source/basicide/tbxctl.src basctl/source/dlged/dlged.cxx basctl/source/dlged/dlgedfunc.cxx basctl/source/dlged/dlgedobj.cxx basctl/source/inc/basidesh.hxx basctl/source/inc/bastypes.hxx basctl/source/inc/dlgedmod.hxx basctl/source/inc/dlgedpage.hxx crashrep/prj/build.lst cui/inc/pch/precompiled_cui.hxx cui/source/customize/acccfg.cxx cui/source/customize/acccfg.hrc cui/source/customize/acccfg.src cui/source/customize/cfg.cxx cui/source/customize/cfgutil.cxx cui/source/customize/macropg.cxx cui/source/customize/macropg.src cui/source/customize/selector.cxx cui/source/dialogs/SpellDialog.cxx cui/source/dialogs/commonlingui.cxx cui/source/dialogs/cuicharmap.cxx cui/source/dialogs/cuifmsearch.cxx cui/source/dialogs/cuigaldlg.cxx cui/source/dialogs/cuigrfflt.cxx cui/source/dialogs/hldocntp.cxx cui/source/dialogs/hldoctp.cxx cui/source/dialogs/hlinettp.cxx cui/source/dialogs/hlmailtp.cxx cui/source/dialogs/hlmarkwn.cxx cui/source/dialogs/hlmarkwn.src cui/source/dialogs/hltpbase.cxx cui/source/dialogs/iconcdlg.cxx cui/source/dialogs/passwdomdlg.cxx cui/source/dialogs/pastedlg.cxx cui/source/dialogs/scriptdlg.cxx cui/source/dialogs/thesdlg.cxx cui/source/dialogs/zoom.cxx cui/source/factory/dlgfact.hxx cui/source/inc/SpellDialog.hxx cui/source/inc/autocdlg.hxx cui/source/inc/backgrnd.hxx cui/source/inc/bbdlg.hxx cui/source/inc/cfg.hxx cui/source/inc/cfgutil.hxx cui/source/inc/cuigaldlg.hxx cui/source/inc/cuigrfflt.hxx cui/source/inc/cuitabarea.hxx cui/source/inc/cuitabline.hxx cui/source/inc/hldocntp.hxx cui/source/inc/hltpbase.hxx cui/source/inc/iconcdlg.hxx cui/source/inc/numpages.hxx cui/source/inc/page.hxx cui/source/inc/postdlg.hxx cui/source/inc/scriptdlg.hxx cui/source/inc/transfrm.hxx cui/source/inc/zoom.hxx cui/source/options/cfgchart.cxx cui/source/options/cuisrchdlg.cxx cui/source/options/dbregister.cxx cui/source/options/dbregister.src cui/source/options/fontsubs.cxx cui/source/options/internationaloptions.cxx cui/source/options/optasian.cxx cui/source/options/optchart.cxx cui/source/options/optcolor.cxx cui/source/options/optcolor.src cui/source/options/optfltr.cxx cui/source/options/optfltr.src cui/source/options/optgdlg.cxx cui/source/options/optgdlg.src cui/source/options/optgenrl.cxx cui/source/options/opthtml.cxx cui/source/options/optimprove.cxx cui/source/options/optinet2.cxx cui/source/options/optinet2.hxx cui/source/options/optjava.cxx cui/source/options/optlingu.cxx cui/source/options/optsave.cxx cui/source/options/optsave.hxx cui/source/options/treeopt.cxx cui/source/options/webconninfo.cxx cui/source/tabpages/autocdlg.cxx cui/source/tabpages/backgrnd.cxx cui/source/tabpages/border.cxx cui/source/tabpages/chardlg.cxx cui/source/tabpages/dstribut.cxx cui/source/tabpages/grfpage.cxx cui/source/tabpages/macroass.cxx cui/source/tabpages/measure.cxx cui/source/tabpages/numfmt.cxx cui/source/tabpages/numpages.cxx cui/source/tabpages/page.cxx cui/source/tabpages/paragrph.cxx cui/source/tabpages/swpossizetabpage.cxx cui/source/tabpages/tabarea.src cui/source/tabpages/textanim.cxx cui/source/tabpages/textattr.cxx cui/source/tabpages/tparea.cxx cui/source/tabpages/tpbitmap.cxx cui/source/tabpages/tpcolor.cxx cui/source/tabpages/tpgradnt.cxx cui/source/tabpages/tphatch.cxx cui/source/tabpages/tpline.cxx cui/source/tabpages/tplnedef.cxx cui/source/tabpages/tplneend.cxx cui/source/tabpages/tpshadow.cxx cui/source/tabpages/transfrm.cxx embedserv/source/embed/register.cxx extensions/inc/pch/precompiled_extensions.hxx extensions/inc/propctrlr.hrc extensions/source/abpilot/abpservices.cxx extensions/source/bibliography/bibload.cxx extensions/source/bibliography/datman.cxx extensions/source/bibliography/general.cxx extensions/source/dbpilots/dbpservices.cxx extensions/source/inc/componentmodule.cxx extensions/source/nsplugin/source/so_env.cxx extensions/source/ole/oleobjw.cxx extensions/source/ole/oleobjw.hxx extensions/source/oooimprovement/invite_job.cxx extensions/source/oooimprovement/onlogrotate_job.cxx extensions/source/plugin/base/service.cxx extensions/source/plugin/inc/plugin/unx/mediator.hxx extensions/source/plugin/inc/plugin/unx/plugcon.hxx extensions/source/plugin/unx/mediator.cxx extensions/source/plugin/unx/nppapi.cxx extensions/source/plugin/unx/plugcon.cxx extensions/source/preload/services.cxx extensions/source/propctrlr/formmetadata.cxx extensions/source/propctrlr/pcrservices.cxx extensions/source/resource/resource.cxx extensions/source/scanner/sane.hxx extensions/source/scanner/sanedlg.cxx extensions/source/scanner/scanunx.cxx extensions/source/scanner/scanwin.cxx extensions/source/scanner/twain.cxx extensions/source/scanner/twain.hxx extensions/source/update/check/updatecheckconfig.cxx extensions/test/stm/datatest.cxx extensions/test/stm/marktest.cxx extensions/test/stm/pipetest.cxx extensions/test/stm/testfactreg.cxx extensions/workben/testpgp.cxx forms/qa/complex/forms/CheckOGroupBoxModel.java forms/qa/makefile.mk forms/source/component/Button.cxx forms/source/component/Button.hxx forms/source/component/ListBox.cxx forms/source/inc/forms_module_impl.hxx forms/source/misc/services.cxx forms/source/solar/control/navtoolbar.cxx javainstaller2/prj/build.lst javainstaller2/src/JavaSetup/org/openoffice/setup/Util/ModuleCtrl.java lingucomponent/prj/build.lst lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.cxx lingucomponent/source/spellcheck/spell/sreg.cxx lingucomponent/source/spellcheck/spell/sspellimp.cxx package/source/manifest/ManifestExport.cxx package/source/manifest/UnoRegister.cxx package/source/xstor/owriteablestream.cxx package/source/xstor/owriteablestream.hxx package/source/xstor/xstorage.hxx package/source/zippackage/ZipPackageFolder.cxx package/source/zippackage/ZipPackageStream.cxx setup_native/source/mac/ooo/DS_Store setup_native/source/win32/customactions/shellextensions/registerextensions.cxx xmlsecurity/prj/build.lst xmlsecurity/source/component/registerservices.cxx xmlsecurity/source/dialogs/stbcontrl.cxx xmlsecurity/source/framework/xsec_framework.cxx xmlsecurity/source/xmlsec/xsec_xmlsec.cxx xmlsecurity/tools/demo/util.hxx xmlsecurity/workben/signaturetest.cxx
2011-03-09 16:20:50 -06:00
DBG_ASSERT(!bStatementInQue,"QueStatement f<>r bereits eingetragenes Statement -> Abgebrochen");
2002-11-18 14:29:33 +00:00
if ( bStatementInQue )
return;
bStatementInQue = sal_True;
2002-11-18 14:29:33 +00:00
if ( pAfterThis )
{
if ( pAfterThis->bStatementInQue )
{
pNext = pAfterThis->pNext;
pAfterThis->pNext = this;
}
else
{ // pAfterThis not in que -> already dequed -> add to front of list
pNext = pFirst;
pFirst = this;
}
2002-11-18 14:29:33 +00:00
}
else // insert at the end
2002-11-18 14:29:33 +00:00
{
pNext = NULL;
if( !pFirst )
pFirst = this;
else
{
StatementList *pList;
pList = pFirst;
while( pList->pNext )
pList = pList->pNext;
pList->pNext = this;
2002-11-18 14:29:33 +00:00
}
}
}
void StatementList::Advance()
{ // pFirst ist static!
pFirst = pNext;
bStatementInQue = sal_False;
2002-11-18 14:29:33 +00:00
pNext = NULL;
}
StatementList::~StatementList()
{
#if OSL_DEBUG_LEVEL > 1
2002-11-18 14:29:33 +00:00
m_pDbgWin->AddText( "Deleting \n" );
#endif
DBG_ASSERT(!bReadingCommands,"Deleting commands while reading them!");
}
Window* StatementList::GetDocWin( sal_uInt16 nNr )
2002-11-18 14:29:33 +00:00
{
Window* pBase = Application::GetFirstTopLevelWindow();
while ( pBase )
{
if ( IsDocWin( pBase ) )
{
if ( !nNr )
return pBase;
nNr--;
}
pBase = Application::GetNextTopLevelWindow( pBase );
}
return NULL;
}
sal_uInt16 StatementList::GetDocFrameCount()
{
Window* pBase = Application::GetFirstTopLevelWindow();
sal_uInt16 nCount = 0;
while ( pBase )
{
if ( IsDocFrame( pBase ) )
nCount++;
pBase = Application::GetNextTopLevelWindow( pBase );
}
return nCount;
}
sal_uInt16 StatementList::GetDocWinCount()
2002-11-18 14:29:33 +00:00
{
Window* pBase = Application::GetFirstTopLevelWindow();
sal_uInt16 nCount = 0;
2002-11-18 14:29:33 +00:00
while ( pBase )
{
if ( IsDocWin( pBase ) )
nCount++;
pBase = Application::GetNextTopLevelWindow( pBase );
}
return nCount;
}
Window* StatementList::SearchAllWin( Window *pBase, Search &aSearch, sal_Bool MaybeBase )
2002-11-18 14:29:33 +00:00
{
if ( !pBase && !aSearch.HasSearchFlag( SEARCH_NO_TOPLEVEL_WIN ) )
{
sal_Bool bSearchFocusFirst = aSearch.HasSearchFlag( SEARCH_FOCUS_FIRST );
2002-11-18 14:29:33 +00:00
Window *pControl = NULL;
if ( bSearchFocusFirst )
{
// first test Parent of Focus Window
pBase = Application::GetFocusWindow();
if ( pBase )
{
DBG_ASSERT( WinPtrValid( pBase ), "GetFocusWindow is no valid WindowPointer" );
2002-11-18 14:29:33 +00:00
Window *pPParent = pBase;
while ( pPParent->GET_REAL_PARENT() )
pPParent = pPParent->GET_REAL_PARENT();
2002-11-18 14:29:33 +00:00
// get overlap window. Will be dialog else document itself
pBase = pBase->GetWindow( WINDOW_OVERLAP );
// set flag to find disabled elements.
// This is better than an enabled one on another Window
aSearch.AddSearchFlags( SEARCH_FIND_DISABLED );
// search on current Dialog first
pControl = SearchAllWin( pBase, aSearch );
// search on current Document
if ( !pControl && pBase != pPParent )
pControl = SearchAllWin( pPParent, aSearch );
aSearch.RemoveSearchFlags( SEARCH_FIND_DISABLED );
if ( pControl )
return pControl;
}
}
pBase = Application::GetFirstTopLevelWindow();
while ( pBase )
{
pControl = SearchAllWin( pBase, aSearch );
if ( pControl )
return pControl;
pBase = Application::GetNextTopLevelWindow( pBase );
}
return NULL;
}
Window *pResult = NULL;
pResult = SearchClientWin( pBase, aSearch, MaybeBase );
if ( pResult )
return pResult;
if ( !aSearch.HasSearchFlag( SEARCH_NOOVERLAP ) )
{
if ( pBase->GetWindow( WINDOW_FIRSTOVERLAP ) )
pResult = SearchAllWin( pBase->GetWindow( WINDOW_FIRSTOVERLAP ), aSearch );
if ( !pResult && pBase->GetWindow( WINDOW_NEXT ) )
pResult = SearchAllWin( pBase->GetWindow( WINDOW_NEXT ), aSearch );
}
return pResult;
}
Window* StatementList::SearchClientWin( Window *pBase, Search &aSearch, sal_Bool MaybeBase )
2002-11-18 14:29:33 +00:00
{
if ( !pBase )
return NULL;
if ( MaybeBase && aSearch.IsWinOK( pBase ) )
return pBase;
Window *pResult = NULL;
sal_uInt16 i;
2002-11-18 14:29:33 +00:00
for( i = 0 ; i < pBase->GetChildCount() && !pResult; i++ )
pResult = SearchClientWin( pBase->GetChild(i), aSearch );
return pResult;
}
sal_Bool SearchUID::IsWinOK( Window *pWin )
2002-11-18 14:29:33 +00:00
{
if ( aUId.equals( pWin->GetUniqueOrHelpId() ) )
2002-11-18 14:29:33 +00:00
{
if ( ( pWin->IsEnabled() || HasSearchFlag( SEARCH_FIND_DISABLED ) ) && pWin->IsVisible() )
return sal_True;
2002-11-18 14:29:33 +00:00
else
{
if ( !pMaybeResult )
pMaybeResult = pWin;
return sal_False;
2002-11-18 14:29:33 +00:00
}
}
else if ( pWin->GetType() == WINDOW_TOOLBOX ) // Buttons and Controls on ToolBox.
2002-11-18 14:29:33 +00:00
{
ToolBox *pTB = ((ToolBox*)pWin);
sal_uInt16 i;
2002-11-18 14:29:33 +00:00
for ( i = 0; i < pTB->GetItemCount() ; i++ )
{
if ( aUId.equals( Str2Id( pTB->GetItemCommand(pTB->GetItemId( i )) ) ) || aUId.equals( pTB->GetHelpId(pTB->GetItemId( i )) ) )
{ // ID matches.
2002-11-18 14:29:33 +00:00
Window *pItemWin;
pItemWin = pTB->GetItemWindow( pTB->GetItemId( i ) );
if ( bSearchButtonOnToolbox && pTB->GetItemType( i ) == TOOLBOXITEM_BUTTON && !pItemWin )
{ // We got a Control, see if its valid also.
// Same as above.
2002-11-18 14:29:33 +00:00
if ( ( pTB->IsEnabled() || HasSearchFlag( SEARCH_FIND_DISABLED ) ) && pTB->IsVisible() )
{ // We got a Button, see if its valid also.
2002-11-18 14:29:33 +00:00
if ( ( pTB->IsItemEnabled(pTB->GetItemId(i)) || HasSearchFlag( SEARCH_FIND_DISABLED ) )
&& pTB->IsItemVisible(pTB->GetItemId(i)) )
return sal_True; // We got a Button.
2002-11-18 14:29:33 +00:00
else
{ // better a disabled Button on a valid ToolBox than an invalid ToolBox as below
2002-11-18 14:29:33 +00:00
pMaybeResult = pTB;
return sal_False;
2002-11-18 14:29:33 +00:00
}
}
else if ( !pMaybeResult )
{ // invalid ToolBox
2002-11-18 14:29:33 +00:00
pMaybeResult = pTB;
return sal_False;
2002-11-18 14:29:33 +00:00
}
}
if ( pItemWin )
{ // We got a Control, see if its valid also.
// Same as above.
2002-11-18 14:29:33 +00:00
if ( ( pItemWin->IsEnabled() || HasSearchFlag( SEARCH_FIND_DISABLED ) ) && pItemWin->IsVisible() )
{
if ( !pAlternateResult ) // only take the first found ItemWindow #i35365
pAlternateResult = pItemWin; // since we cannot return a Window here
return sal_False; // continue searching to prefer a window with the right ID #i32292
2002-11-18 14:29:33 +00:00
}
else if ( !pMaybeResult )
{
pMaybeResult = pItemWin;
return sal_False;
2002-11-18 14:29:33 +00:00
}
}
}
}
return sal_False;
2002-11-18 14:29:33 +00:00
}
else
return sal_False;
2002-11-18 14:29:33 +00:00
}
Window* StatementList::SearchTree( rtl::OString aUId ,sal_Bool bSearchButtonOnToolbox )
2002-11-18 14:29:33 +00:00
{
SearchUID aSearch(aUId,bSearchButtonOnToolbox);
2002-11-18 14:29:33 +00:00
Window *pResult = SearchAllWin( NULL, aSearch );
if ( pResult )
return pResult;
else if ( aSearch.GetAlternateResultWin() )
return aSearch.GetAlternateResultWin();
2002-11-18 14:29:33 +00:00
else
return aSearch.GetMaybeWin();
2002-11-18 14:29:33 +00:00
}
sal_Bool SearchWinPtr::IsWinOK( Window *pWin )
2002-11-18 14:29:33 +00:00
{
return pWin == pTest;
}
sal_Bool StatementList::WinPtrValid(Window *pTest)
2002-11-18 14:29:33 +00:00
{
SearchWinPtr aSearch( pTest );
return SearchAllWin( NULL, aSearch ) != NULL;
}
sal_Bool SearchRT::IsWinOK( Window *pWin )
2002-11-18 14:29:33 +00:00
{
if ( pWin->IsVisible() && pWin->GetType() == mnRT )
{
mnCount++;
if ( mnSkip )
{
mnSkip--;
return sal_False;
2002-11-18 14:29:33 +00:00
}
else
return sal_True;
2002-11-18 14:29:33 +00:00
}
return sal_False;
2002-11-18 14:29:33 +00:00
}
Window* StatementList::GetWinByRT( Window *pBase, WindowType nRT, sal_Bool MaybeBase, sal_uInt16 nSkip, sal_Bool bSearchAll )
2002-11-18 14:29:33 +00:00
{
SearchRT aSearch( nRT, 0, nSkip );
if ( bSearchAll )
aSearch.AddSearchFlags( SEARCH_FOCUS_FIRST | SEARCH_FIND_DISABLED );
else
aSearch.AddSearchFlags( SEARCH_NOOVERLAP | SEARCH_NO_TOPLEVEL_WIN );
2002-11-18 14:29:33 +00:00
return SearchAllWin( pBase, aSearch, MaybeBase );
}
sal_uInt16 StatementList::CountWinByRT( Window *pBase, WindowType nRT, sal_Bool MaybeBase )
2002-11-18 14:29:33 +00:00
{
SearchRT aSearch( nRT, SEARCH_NOOVERLAP | SEARCH_NO_TOPLEVEL_WIN, 0xFFFF );
SearchAllWin( pBase, aSearch, MaybeBase );
return aSearch.GetCount();
}
sal_Bool SearchScroll::IsWinOK( Window *pWin )
2002-11-18 14:29:33 +00:00
{
if ( SearchRT::IsWinOK( pWin ) )
{
DBG_ASSERT( pWin->GetStyle() & ( WB_HORZ | WB_VERT ), "Nither WB_HORZ nor WB_VERT set on ScrollBar");
return (( pWin->GetStyle() & WB_HORZ ) && ( nDirection == CONST_ALIGN_BOTTOM ))
|| (( pWin->GetStyle() & WB_VERT ) && ( nDirection == CONST_ALIGN_RIGHT ));
}
return sal_False;
2002-11-18 14:29:33 +00:00
}
ScrollBar* StatementList::GetScrollBar( Window *pBase, sal_uInt16 nDirection, sal_Bool MaybeBase )
2002-11-18 14:29:33 +00:00
{
SearchScroll aSearch( nDirection, SEARCH_NOOVERLAP | SEARCH_NO_TOPLEVEL_WIN );
return (ScrollBar*)SearchAllWin( pBase, aSearch, MaybeBase );
}
sal_Bool SearchPopupFloatingWin::IsWinOK( Window *pWin )
2002-11-18 14:29:33 +00:00
{
return pWin->IsVisible() && pWin->GetType() == WINDOW_FLOATINGWINDOW && ((FloatingWindow*)pWin)->IsInPopupMode();
}
Window* StatementList::GetPopupFloatingWin( sal_Bool MaybeBase )
2002-11-18 14:29:33 +00:00
{
SearchPopupFloatingWin aSearch;
return SearchAllWin( NULL, aSearch, MaybeBase );
}
Menu* StatementList::GetMatchingMenu( Window* pWin, Menu* pBaseMenu )
{
if ( pBaseMenu )
{
if ( pBaseMenu->GetWindow() == pWin )
return pBaseMenu;
sal_uInt16 i;
i = 0;
while ( i < pBaseMenu->GetItemCount() )
{
PopupMenu* pPopup = pBaseMenu->GetPopupMenu( pBaseMenu->GetItemId( i ) );
if ( pPopup && pPopup->GetWindow() )
{
if ( pPopup->GetWindow() == pWin )
return pPopup;
else
{
pBaseMenu = pPopup;
i = 0;
}
}
else
i++;
}
}
else
{
if ( PopupMenu::GetActivePopupMenu() )
{
Menu* pMenu = GetMatchingMenu( pWin, PopupMenu::GetActivePopupMenu() );
if ( pMenu )
return pMenu;
}
sal_uInt16 nSkip = 0;
Window* pMenuBarWin = NULL;
while ( (pMenuBarWin = GetWinByRT( NULL, WINDOW_MENUBARWINDOW, sal_True, nSkip++, sal_True )) != NULL )
{
Window* pParent = pMenuBarWin->GET_REAL_PARENT();
if ( pParent && pParent->GetType() == WINDOW_BORDERWINDOW && pParent->IsVisible() )
{
Menu* pMenu = NULL;
// find Menu of MenuBarWindow
sal_uInt16 nCount;
for ( nCount = 0 ; nCount < pParent->GetChildCount() ; nCount++ )
{
if ( pParent->GetChild( nCount )->GetType() == WINDOW_WORKWINDOW )
pMenu = ((WorkWindow*)(pParent->GetChild( nCount )))->GetMenuBar();
}
if ( pMenu )
{
// check for menu bar in Task Window
if ( pMenuBarWin == pWin )
return pMenu;
// search submenues
pMenu = GetMatchingMenu( pWin, pMenu );
if ( pMenu )
return pMenu;
}
}
}
}
return NULL;
2002-11-18 14:29:33 +00:00
}
sal_Bool SearchActive::IsWinOK( Window *pWin )
2002-11-18 14:29:33 +00:00
{
// only matches ResID due to problems with UNIX Window Managers
return pWin->IsVisible() && ( (nRT == WINDOW_ANYTYPE && IsDialog(pWin) ) || pWin->GetType() == nRT );
}
Window* StatementList::GetActive( WindowType nRT, sal_Bool MaybeBase )
2002-11-18 14:29:33 +00:00
{
SearchActive aSearch( nRT );
return SearchAllWin( NULL, aSearch, MaybeBase );
}
sal_Bool SearchFadeSplitWin::IsWinOK( Window *pWin )
2002-11-18 14:29:33 +00:00
{
#if OSL_DEBUG_LEVEL > 1
2002-11-18 14:29:33 +00:00
if ( pWin->GetType() == WINDOW_SPLITWINDOW )
{
sal_Bool bResult;
2002-11-18 14:29:33 +00:00
WindowAlign aAlign;
bResult = pWin->IsVisible();
bResult = ((SplitWindow*)pWin)->IsFadeInButtonVisible();
bResult = ((SplitWindow*)pWin)->IsFadeOutButtonVisible();
bResult = ((SplitWindow*)pWin)->IsAutoHideButtonVisible();
aAlign = ((SplitWindow*)pWin)->GetAlign();
}
#endif
return pWin->IsVisible() && ( pWin->GetType() == WINDOW_SPLITWINDOW )
&& (((SplitWindow*)pWin)->IsFadeInButtonVisible() || ((SplitWindow*)pWin)->IsFadeOutButtonVisible() )
/*&& ((SplitWindow*)pWin)->IsAutoHideButtonVisible()*/ && ((SplitWindow*)pWin)->GetAlign() == nAlign;
2002-11-18 14:29:33 +00:00
}
Window* StatementList::GetFadeSplitWin( Window *pBase, WindowAlign nAlign, sal_Bool MaybeBase )
2002-11-18 14:29:33 +00:00
{
SearchFadeSplitWin aSearch( nAlign );
if ( GetpApp()->GetAppWindow() == pBase && pBase->GetType() != WINDOW_BORDERWINDOW )
pBase = pBase->GetWindow( WINDOW_OVERLAP );
return SearchAllWin( pBase, aSearch, MaybeBase );
}
Window* StatementList::GetMouseWin()
{
Window *pBase = Application::GetFirstTopLevelWindow();
Window *pControl = NULL;
while ( pBase )
{
Window *pBaseFrame = pBase->GetWindow( WINDOW_OVERLAP );
Point aP = pBaseFrame->GetPointerPosPixel();
pControl = pBaseFrame->FindWindow( aP );
if ( pControl )
return pControl;
pBase = Application::GetNextTopLevelWindow( pBase );
}
return NULL;
}
Window* StatementList::GetFocus( WindowType nRT, sal_Bool MaybeBase )
2002-11-18 14:29:33 +00:00
{
if ( nRT == WINDOW_TABCONTROL )
{
Window *pResult = GetActive( WINDOW_TABDIALOG, MaybeBase);
for( sal_uInt16 i = 0 ; pResult && i < pResult->GetChildCount(); i++ )
2002-11-18 14:29:33 +00:00
if ( pResult->GetChild(i)->GetType() == nRT )
return pResult->GetChild(i);
}
return NULL;
}
Window* StatementList::GetAnyActive( sal_Bool MaybeBase )
2002-11-18 14:29:33 +00:00
{
Window *pControl;
pControl = GetActive( WINDOW_MESSBOX, MaybeBase);
if ( !pControl )
{
pControl = GetActive( WINDOW_INFOBOX, MaybeBase);
}
if ( !pControl )
{
pControl = GetActive( WINDOW_WARNINGBOX, MaybeBase);
}
if ( !pControl )
{
pControl = GetActive( WINDOW_ERRORBOX, MaybeBase);
}
if ( !pControl )
{
pControl = GetActive( WINDOW_QUERYBOX, MaybeBase);
}
if ( !pControl )
{
pControl = GetActive( WINDOW_BUTTONDIALOG, MaybeBase);
}
if ( !pControl )
{
pControl = GetActive( WINDOW_FILEDIALOG, MaybeBase);
}
if ( !pControl )
{
pControl = GetActive( WINDOW_PATHDIALOG, MaybeBase);
}
if ( !pControl )
{
pControl = GetActive( WINDOW_PRINTDIALOG, MaybeBase);
}
if ( !pControl )
{
pControl = GetActive( WINDOW_PRINTERSETUPDIALOG, MaybeBase);
}
if ( !pControl )
{
pControl = GetActive( WINDOW_COLORDIALOG, MaybeBase);
}
if ( !pControl )
{
pControl = GetFocus( WINDOW_TABCONTROL, MaybeBase);
2002-11-18 14:29:33 +00:00
}
return pControl;
}
void StatementList::SetFirstDocFrame( Window* pWin )
2002-11-18 14:29:33 +00:00
{
DBG_ASSERT( IsDocFrame( pWin ), "Non Document Frame set as first Document Frame" );
pFirstDocFrame = pWin;
2002-11-18 14:29:33 +00:00
}
Window* StatementList::GetFirstDocFrame()
2002-11-18 14:29:33 +00:00
{
if ( pFirstDocFrame && !WinPtrValid( pFirstDocFrame ) )
pFirstDocFrame = NULL;
if ( pFirstDocFrame && !pFirstDocFrame->IsVisible() )
pFirstDocFrame = NULL;
if ( pFirstDocFrame && !IsDocFrame( pFirstDocFrame ) )
pFirstDocFrame = NULL;
if ( !pFirstDocFrame )
2002-11-18 14:29:33 +00:00
{
Window* pBase = Application::GetFirstTopLevelWindow();
while ( pBase && !IsDocFrame( pBase ) )
2002-11-18 14:29:33 +00:00
pBase = Application::GetNextTopLevelWindow( pBase );
if ( pBase )
SetFirstDocFrame( pBase );
2002-11-18 14:29:33 +00:00
if ( !pBase ) // find just something
{
pBase = Application::GetFirstTopLevelWindow();
while ( pBase && !pBase->IsVisible() )
pBase = Application::GetNextTopLevelWindow( pBase );
return pBase; // just for now, later we will hopefully have a Window
}
}
return pFirstDocFrame;
2002-11-18 14:29:33 +00:00
}
sal_Bool StatementList::IsFirstDocFrame( Window* pWin )
2002-11-18 14:29:33 +00:00
{
return pWin && ( pWin == GetFirstDocFrame() || ( GetFirstDocFrame() && pWin == GetFirstDocFrame()->GetWindow( WINDOW_CLIENT ) ) ) && ( GetFirstDocFrame() && IsDocFrame( GetFirstDocFrame() ) );
2002-11-18 14:29:33 +00:00
}
MenuBar* StatementList::GetDocFrameMenuBar( Window* pWin )
{
if ( pWin && pWin->IsVisible() && pWin->GetType() == WINDOW_BORDERWINDOW )
{
sal_uInt16 nCount;
for ( nCount = 0 ; nCount < pWin->GetChildCount() ; nCount++ )
{
if ( pWin->GetChild( nCount )->GetType() == WINDOW_WORKWINDOW )
return ((WorkWindow*)(pWin->GetChild( nCount )))->GetMenuBar();
}
}
return NULL;
}
// a Doc Frame is a Document or the Backing Window
sal_Bool StatementList::IsDocFrame( Window* pWin )
2002-11-18 14:29:33 +00:00
{
if ( pWin && pWin->IsVisible() && pWin->GetType() == WINDOW_BORDERWINDOW )
{
sal_uInt16 nCount;
sal_Bool bHasWorkWindow = sal_False;
sal_Bool bHasMenuBar = sal_False;
2002-11-18 14:29:33 +00:00
// #91724# it is now necessary to sort out the IME WIndow in Solaris as well.
// so now we check for existence of WINDOW_WORKWINDOW and newly for
// WINDOW_MENUBARWINDOW which contains the Menu and the close/min/max buttons
for ( nCount = 0 ; nCount < pWin->GetChildCount() ; nCount++ )
{
if ( pWin->GetChild( nCount )->GetType() == WINDOW_WORKWINDOW )
bHasWorkWindow = sal_True;
2002-11-18 14:29:33 +00:00
if ( pWin->GetChild( nCount )->GetType() == WINDOW_MENUBARWINDOW )
bHasMenuBar = sal_True;
2002-11-18 14:29:33 +00:00
}
return bHasWorkWindow && bHasMenuBar;
}
return sal_False;
2002-11-18 14:29:33 +00:00
}
// a Doc Win is a real document (not the Backing Window)
sal_Bool StatementList::IsDocWin( Window* pWin )
{
if ( pWin && IsDocFrame( pWin ) )
{
if ( GetDocFrameCount() != 1 )
return sal_True;
else
{
// check for the close button to see if we are the last one or only the backing Window
if ( GetDocFrameMenuBar( pWin ) )
return GetDocFrameMenuBar( pWin )->HasCloser();
}
}
return sal_False;
}
sal_Bool StatementList::IsIMEWin( Window* pWin ) // Input Window for CJK under Solaris
2002-11-18 14:29:33 +00:00
{
if ( pWin && pWin->IsVisible() && pWin->GetType() == WINDOW_BORDERWINDOW )
{
sal_uInt16 nCount;
sal_Bool bHasWorkWindow = sal_False;
sal_Bool bHasWindow = sal_False;
2002-11-18 14:29:33 +00:00
// #91724# it is now necessary to sort out the IME WIndow in Solaris as well.
// so now we check for existence of WINDOW_WORKWINDOW and newly for
// WINDOW_WINDOW which contains the Menu and the close/min/max buttons
for ( nCount = 0 ; nCount < pWin->GetChildCount() ; nCount++ )
if ( pWin->GetChild( nCount )->GetType() == WINDOW_WORKWINDOW )
bHasWorkWindow = sal_True;
2002-11-18 14:29:33 +00:00
for ( nCount = 0 ; nCount < pWin->GetChildCount() ; nCount++ )
if ( pWin->GetChild( nCount )->GetType() == WINDOW_WINDOW )
bHasWindow = sal_True;
2002-11-18 14:29:33 +00:00
return bHasWorkWindow && !bHasWindow;
}
return sal_False;
2002-11-18 14:29:33 +00:00
}
UniString StatementList::Tree(Window *pBase, int Indent)
{
String aReturn, aSep;
if ( !pBase )
{
aSep.AssignAscii("============================\n");
aSep.ConvertLineEnd();
pBase = Application::GetFirstTopLevelWindow();
while ( pBase )
{
Window *pBaseFrame = pBase->GetWindow( WINDOW_OVERLAP );
aReturn += aSep;
aReturn += Tree( pBaseFrame, Indent+1 );
pBase = Application::GetNextTopLevelWindow( pBase );
}
return aReturn;
}
aSep.AssignAscii("----------------------------\n");
aSep.ConvertLineEnd();
aReturn += ClientTree( pBase, Indent );
if ( pBase->GetWindow( WINDOW_FIRSTOVERLAP ) )
{
aReturn += aSep;
aReturn += Tree( pBase->GetWindow( WINDOW_FIRSTOVERLAP ), Indent+1 );
}
if ( pBase->GetWindow( WINDOW_NEXT ) )
{
aReturn += aSep;
aReturn += Tree( pBase->GetWindow( WINDOW_NEXT ), Indent );
}
return aReturn;
}
String StatementList::ClientTree(Window *pBase, int Indent)
{
#if OSL_DEBUG_LEVEL > 1
#define WRITE(Text) { m_pDbgWin->AddText(Text); aReturn += Text; }
#define WRITEc(Text) { m_pDbgWin->AddText(Text); aReturn.AppendAscii(Text); }
2002-11-18 14:29:33 +00:00
#else
#define WRITE(Text) { aReturn += Text; }
#define WRITEc(Text) { aReturn.AppendAscii(Text); }
2002-11-18 14:29:33 +00:00
#endif
String sIndent,aText,aReturn;
sIndent.Expand(sal::static_int_cast< xub_StrLen >(2*Indent));
2002-11-18 14:29:33 +00:00
aText = pBase->GetText();
UniString t1,t2;t1 = CUniString("\n"); t2 = CUniString("\\n");
aText.SearchAndReplaceAll(t1,t2 );
WRITE(sIndent);
if (pBase->IsDialog())
{
WRITEc("*(Dialog(TH))");
}
if (IsDialog( pBase ))
{
WRITEc("*(Dialog(GH))");
}
if (pBase->HasFocus())
{
WRITEc("*(Focus)");
}
if (!pBase->IsEnabled())
{
WRITEc("*(Disab)");
}
if (pBase->IsVisible())
{
WRITEc("*(Visible)");
}
if ( IsDialog(pBase) && ((SystemWindow*)pBase)->IsActive() )
{
WRITEc("*(Active)");
}
if ( pBase->GetStyle() & WB_CLOSEABLE )
{
WRITEc("*(Closable)");
}
if ( pBase->GetType() == WINDOW_DOCKINGWINDOW &&
((((DockingWindow*)pBase)->GetFloatStyle()) & WB_CLOSEABLE) )
{
WRITEc("*(Closable Docking in Floatingstyle)");
}
if ( pBase->GetStyle() & WB_DOCKABLE )
{
WRITEc("*(Dockable)");
}
if ( pBase->GetType() == WINDOW_SPLITWINDOW &&
(((SplitWindow*)pBase)->IsFadeInButtonVisible() || ((SplitWindow*)pBase)->IsFadeOutButtonVisible()) )
{
WRITEc("*(FadeIn/Out)");
}
WRITEc("Text: ");
WRITE(aText);
WRITEc("\n");
WRITE(sIndent);
WRITEc("UId : ");
WRITE(Id2Str(pBase->GetUniqueOrHelpId()));
WRITEc(":0x");
WRITE(
String::CreateFromInt64(
sal::static_int_cast< sal_Int64 >(
reinterpret_cast< sal_IntPtr >(pBase)),
16 ));
2002-11-18 14:29:33 +00:00
WRITEc(":");
WRITE(pBase->GetQuickHelpText());
WRITEc(":");
WRITE(pBase->GetHelpText());
WRITEc("\n");
WRITE(sIndent);
WRITEc("RTyp: ");
WRITE(MakeStringNumber(TypeKenn,pBase->GetType()));
if ( pBase->GetType() == WINDOW_CONTROL )
{
if ( dynamic_cast< svt::EditBrowseBox* >(pBase) )
WRITEc("/BrowseBox")
else if ( dynamic_cast< ValueSet* >(pBase) )
WRITEc("/ValueSet")
else if ( dynamic_cast< svt::ORoadmap* >(pBase) )
WRITEc("/RoadMap")
else if ( dynamic_cast< svt::IExtensionListBox* >(pBase) )
WRITEc("/ExtensionListBox")
else if ( dynamic_cast< svt::table::TableControl* >(pBase) )
WRITEc("/TableControl")
else
WRITEc("/Unknown")
}
2002-11-18 14:29:33 +00:00
WRITEc("\n");
aReturn.ConvertLineEnd();
sal_uInt16 i;
2002-11-18 14:29:33 +00:00
for (i = 0 ; i < pBase->GetChildCount() ; i++)
{
aReturn += ClientTree(pBase->GetChild(i),Indent+1);
}
return aReturn;
}
sal_Bool StatementList::CheckWindowWait()
2002-11-18 14:29:33 +00:00
{
static Time StartTime = Time(0L); // cancel if window doesn't want to close at all
2002-11-18 14:29:33 +00:00
if ( StartTime == Time(0L) )
StartTime = Time();
if ( pWindowWaitPointer )
{
#if OSL_DEBUG_LEVEL > 1
2002-11-18 14:29:33 +00:00
m_pDbgWin->AddText( "Waiting for Window to close ... " );
#endif
if ( WinPtrValid(pWindowWaitPointer) && IS_WINP_CLOSING(pWindowWaitPointer) )
{
#if OSL_DEBUG_LEVEL > 1
m_pDbgWin->AddText( Id2Str(aWindowWaitUId).AppendAscii(" Still Open. RType=") );
2002-11-18 14:29:33 +00:00
m_pDbgWin->AddText( String::CreateFromInt32( pWindowWaitPointer->GetType() ).AppendAscii("\n") );
#endif
if ( StartTime + Time(0,0,10) < Time() )
2002-11-18 14:29:33 +00:00
{
#if OSL_DEBUG_LEVEL > 1
2002-11-18 14:29:33 +00:00
m_pDbgWin->AddText( "Close timed out. Going on!! " );
#endif
pWindowWaitPointer->SetHelpId(aWindowWaitOldHelpId);
pWindowWaitPointer->SetUniqueId(aWindowWaitOldUniqueId);
2002-11-18 14:29:33 +00:00
aWindowWaitUId = rtl::OString();
2002-11-18 14:29:33 +00:00
pWindowWaitPointer = NULL;
StartTime = Time(0L);
return sal_True;
2002-11-18 14:29:33 +00:00
}
return sal_False;
2002-11-18 14:29:33 +00:00
}
pWindowWaitPointer = NULL;
aWindowWaitUId = rtl::OString();
#if OSL_DEBUG_LEVEL > 1
2002-11-18 14:29:33 +00:00
m_pDbgWin->AddText( "Closed, Going on.\n" );
#endif
}
StartTime = Time(0L);
return sal_True;
2002-11-18 14:29:33 +00:00
}
void StatementList::ReportError(String aMessage)
{
ReportError ( rtl::OString(), aMessage );
2002-11-18 14:29:33 +00:00
}
void StatementList::ReportError(rtl::OString aUId, String aMessage)
2002-11-18 14:29:33 +00:00
{
pRet->GenError ( aUId, aMessage );
IsError = sal_True;
2002-11-18 14:29:33 +00:00
}
void StatementList::ReportError(String aMessage, sal_uLong nWhatever)
2002-11-18 14:29:33 +00:00
{
ReportError ( aMessage.AppendAscii(" ").Append(UniString::CreateFromInt32(nWhatever)));
2002-11-18 14:29:33 +00:00
}
void StatementList::DirectLog( sal_uLong nType, String aMessage )
2002-11-18 14:29:33 +00:00
{
if ( pRet )
pRet->GenReturn( RET_DirectLoging, (sal_uInt16) nType, aMessage );
2002-11-18 14:29:33 +00:00
}
#define CALL_EVENT_WITH_NOTIFY( EventType, Event, WinP, Method ) \
{ \
if ( StatementList::WinPtrValid( WinP ) ) \
{ \
NotifyEvent aNEvt( EventType, WinP, &Event ); \
if ( !WinP->PreNotify( aNEvt ) ) \
WinP->Method( Event ); \
} \
2002-11-18 14:29:33 +00:00
}
void ImplKeyInput( Window* pWin, KeyEvent &aKEvnt, sal_Bool bForceDirect )
2002-11-18 14:29:33 +00:00
{
if ( StatementList::bUsePostEvents && !bForceDirect )
{
if ( StatementList::WinPtrValid( pWin ) )
{
sal_uLong nID1;
sal_uLong nID2;
nID1 = Application::PostKeyEvent( VCLEVENT_WINDOW_KEYINPUT, pWin, &aKEvnt );
nID2 = Application::PostKeyEvent( VCLEVENT_WINDOW_KEYUP, pWin, &aKEvnt );
// wait after posting both events so deleting pWin will remove the second event also
ImplEventWait( nID1 );
ImplEventWait( nID2 );
}
}
else
{
if ( !Application::CallAccel( aKEvnt.GetKeyCode() ) )
{
CALL_EVENT_WITH_NOTIFY( EVENT_KEYINPUT, aKEvnt, pWin, KeyInput )
KeyCode aCode = aKEvnt.GetKeyCode();
if ( (aCode.GetCode() == KEY_CONTEXTMENU) || ((aCode.GetCode() == KEY_F10) && aCode.IsShift()) )
{
if ( StatementList::WinPtrValid( pWin ) )
{
Point aPos;
// simulate mouseposition at center of window
Size aSize = pWin->GetOutputSize();
aPos = Point( aSize.getWidth()/2, aSize.getHeight()/2 );
CommandEvent aEvent( aPos, COMMAND_CONTEXTMENU, sal_False );
ImplCommand( pWin, aEvent );
}
}
}
CALL_EVENT_WITH_NOTIFY( EVENT_KEYUP, aKEvnt, pWin, KeyUp )
}
2002-11-18 14:29:33 +00:00
};
void ImplMouseMove( Window* pWin, MouseEvent &aMEvnt, sal_Bool bForceDirect )
2002-11-18 14:29:33 +00:00
{
if ( StatementList::bUsePostEvents && !bForceDirect )
2002-11-18 14:29:33 +00:00
{
if ( StatementList::WinPtrValid( pWin ) )
{
sal_uLong nID;
nID = Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEMOVE, pWin, &aMEvnt );
ImplEventWait( nID );
}
2002-11-18 14:29:33 +00:00
}
else
{
if ( pWin->IsTracking() )
{
TrackingEvent aTEvt( aMEvnt );
pWin->Tracking( aTEvt );
}
else
CALL_EVENT_WITH_NOTIFY( EVENT_MOUSEMOVE, aMEvnt, pWin, MouseMove )
}
2002-11-18 14:29:33 +00:00
};
void ImplMouseButtonDown( Window* pWin, MouseEvent &aMEvnt, sal_Bool bForceDirect )
2002-11-18 14:29:33 +00:00
{
if ( StatementList::bUsePostEvents && !bForceDirect )
{
if ( StatementList::WinPtrValid( pWin ) )
{
sal_uLong nID;
nID = Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, pWin, &aMEvnt );
ImplEventWait( nID );
}
}
else
{
CALL_EVENT_WITH_NOTIFY( EVENT_MOUSEBUTTONDOWN, aMEvnt, pWin, MouseButtonDown )
}
2002-11-18 14:29:33 +00:00
};
void ImplMouseButtonUp( Window* pWin, MouseEvent &aMEvnt, sal_Bool bForceDirect )
2002-11-18 14:29:33 +00:00
{
if ( StatementList::bUsePostEvents && !bForceDirect )
2002-11-18 14:29:33 +00:00
{
if ( StatementList::WinPtrValid( pWin ) )
{
sal_uLong nID;
nID = Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEBUTTONUP, pWin, &aMEvnt );
ImplEventWait( nID );
}
2002-11-18 14:29:33 +00:00
}
else
{
if ( pWin->IsTracking() )
{
// look at #64693 the position is relevant to the toolboxes
// #60020 hopefully no more GPF now
// stop tracking at first without event
pWin->EndTracking( ENDTRACK_DONTCALLHDL );
// then send own event with correct mouse event
TrackingEvent aTEvt( aMEvnt, ENDTRACK_END );
pWin->Tracking( aTEvt );
}
else
CALL_EVENT_WITH_NOTIFY( EVENT_MOUSEBUTTONUP, aMEvnt, pWin, MouseButtonUp )
}
2002-11-18 14:29:33 +00:00
};
void ImplEventWait( sal_uLong nID )
{
while ( !Application::IsProcessedMouseOrKeyEvent( nID ) )
Application::Yield();
}
2002-11-18 14:29:33 +00:00
void ImplCommand( Window* pWin, CommandEvent &aCmdEvnt )
{
CALL_EVENT_WITH_NOTIFY( EVENT_COMMAND, aCmdEvnt, pWin, Command )
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */