diff options
author | Martin Hollmichel <mh@openoffice.org> | 2002-11-18 14:29:33 +0000 |
---|---|---|
committer | Martin Hollmichel <mh@openoffice.org> | 2002-11-18 14:29:33 +0000 |
commit | 4c7c7dc4716363014dc2dcad679df44dfabe24b4 (patch) | |
tree | 5685259311bbd28aca667bb475f51ec192a76f6f /automation | |
parent | 02f4ad619774297658085bb84fcb5d009dbfe715 (diff) |
add: testtool, #104916#
Diffstat (limited to 'automation')
21 files changed, 12589 insertions, 0 deletions
diff --git a/automation/source/server/XMLParser.cxx b/automation/source/server/XMLParser.cxx new file mode 100644 index 000000000000..a09a32deeec2 --- /dev/null +++ b/automation/source/server/XMLParser.cxx @@ -0,0 +1,730 @@ +/************************************************************************* + * + * $RCSfile: XMLParser.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: mh $ $Date: 2002-11-18 15:27:24 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2002 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2002 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2002 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _STREAM_HXX +#include <tools/stream.hxx> +#endif +#include "statemnt.hxx" +#include "rcontrol.hxx" +#include "retstrm.hxx" +#include <svtools/svtmsg.hrc> + +#ifndef _BASIC_TTRESHLP_HXX +#include <basic/ttstrhlp.hxx> +#endif + +#include <com/sun/star/xml/sax/XParser.hpp> +#include <com/sun/star/xml/sax/SAXException.hpp> +#include <com/sun/star/io/XInputStream.hpp> +#include <com/sun/star/io/XInputStream.hpp> +#include <com/sun/star/util/XCloneable.hpp> +#ifndef _COMPHELPER_PROCESSFACTORY_HXX_ +#include <comphelper/processfactory.hxx> +#endif +#ifndef _CPPUHELPER_IMPLBASE2_HXX_ +#include <cppuhelper/implbase2.hxx> +#endif +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> +#endif +#include <com/sun/star/xml/sax/SAXParseException.hpp> + +using namespace com::sun::star::xml::sax; +using namespace com::sun::star::io; +using namespace com::sun::star::uno; +using namespace com::sun::star::util; +using namespace rtl; + +class SVInputStream : public cppu::WeakImplHelper1< XInputStream > +{ + SvStream* pStream; +public: + SVInputStream( SvStream* pSt ):pStream( pSt ){}; + ~SVInputStream(){ delete pStream; pStream=NULL; } + + // Methods XInputStream + virtual sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL available( ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL closeInput( ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); +}; + + +sal_Int32 SAL_CALL SVInputStream::readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) +{ + aData.realloc( nBytesToRead ); + sal_Int32 nRead = pStream->Read( aData.getArray(), nBytesToRead ); + aData.realloc( nRead ); + return nRead; +} + +sal_Int32 SAL_CALL SVInputStream::readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) +{ + return readBytes( aData, nMaxBytesToRead ); +} + +void SAL_CALL SVInputStream::skipBytes( sal_Int32 nBytesToSkip ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) +{ + if ( nBytesToSkip > 0 ) + pStream->SeekRel( nBytesToSkip ); +} + +sal_Int32 SAL_CALL SVInputStream::available( ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) +{ + ULONG nCurrent = pStream->Tell(); + ULONG nSize = pStream->Seek( STREAM_SEEK_TO_END ); + ULONG nAvailable = nSize - nCurrent; + pStream->Seek( nCurrent ); + return nAvailable; +} + +void SAL_CALL SVInputStream::closeInput( ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) +{ +// pStream->Close(); // automatically done in destructor + delete pStream; + pStream = NULL; +} + +class Node; +SV_DECL_REF(Node) + +enum NodeType { NODE_CHARACTER = CONST_NodeTypeCharacter, + NODE_ELEMENT = CONST_NodeTypeElement, + NODE_COMMENT = CONST_NodeTypeComment }; + +class Node : public SvRefBase +{ + NodeType aNodeType; + Node* pParent; // Use pointer to prevent cyclic references resulting in undeleted objects + +protected: + Node( NodeType aType ): aNodeType( aType ), pParent( NULL ){}; + virtual ~Node(); + +public: + NodeType GetNodeType() { return aNodeType; } + void SetParent( NodeRef xNewParent ); + NodeRef GetParent(); +}; + +SV_IMPL_REF(Node) +// generate NodeRefMemberList +SV_DECL_IMPL_REF_LIST( NodeRef, Node* ) + +Node::~Node() +{ +} + +void Node::SetParent( NodeRef xNewParent ) +{ + pParent = &xNewParent; +} + +NodeRef Node::GetParent() +{ + return NodeRef( pParent ); +} + +class CharacterNode : public Node +{ + String aCharacters; +public: + CharacterNode( const String& aChars ): Node( NODE_CHARACTER ), aCharacters( aChars ){}; + + String GetCharacters() { return aCharacters; } +}; + +class ElementNode : public Node +{ + String aNodeName; + Reference < XAttributeList > xAttributeList; + NodeRefMemberList aDocumentNodeList; +public: + ElementNode( const String& aName, Reference < XAttributeList > xAttributes ); + void AppendNode( NodeRef xNewNode ); + USHORT GetChildCount(){ return aDocumentNodeList.Count(); } + NodeRef GetChild( USHORT nIndex ){ return aDocumentNodeList.GetObject( nIndex ); } + Reference < XAttributeList > GetAttributes(){ return xAttributeList; } + + String GetNodeName() { return aNodeName; } +}; + +ElementNode::ElementNode( const String& aName, Reference < XAttributeList > xAttributes ) +: Node( NODE_ELEMENT ) +, aNodeName( aName ) +{ + if ( xAttributes.is() ) + { + Reference < XCloneable > xAttributeCloner( xAttributes, UNO_QUERY ); + if ( xAttributeCloner.is() ) + xAttributeList = Reference < XAttributeList > ( xAttributeCloner->createClone() , UNO_QUERY ); + else + { + DBG_ERROR("Unable to clone AttributeList") + } + } +}; + +void ElementNode::AppendNode( NodeRef xNewNode ) +{ + aDocumentNodeList.Insert ( xNewNode, LIST_APPEND ); + xNewNode->SetParent( this ); +} + +// XIndexAccess + + + + + +enum ParseAction { COLLECT_DATA, COLLECT_DATA_IGNORE_WHITESPACE, PARSE_ONLY }; + +class SAXParser : public cppu::WeakImplHelper2< XErrorHandler, XDocumentHandler > +{ + String aFilename; + Reference < XParser > xParser; + + // XErrorHandler + void AddToList( sal_Char* cuType, const ::com::sun::star::uno::Any& aSAXParseException ); + String aErrors; + + NodeRef xTreeRoot; + NodeRef xCurrentNode; + ULONG nTimestamp; + ParseAction aAction; + +public: + SAXParser( const String &rFilename ); + ~SAXParser(); + + // Access Methods + NodeRef GetCurrentNode(){ return xCurrentNode; } + void SetCurrentNode( NodeRef xCurrent ){ xCurrentNode = xCurrent; } + NodeRef GetRootNode(){ return xTreeRoot; } + ULONG GetTimestamp(){ return nTimestamp; } + void Touch(){ nTimestamp = Time::GetSystemTicks(); } + + // Methods SAXParser + BOOL Parse( ParseAction aAct ); + String GetErrors(){ return aErrors; } + + // Methods XErrorHandler + virtual void SAL_CALL error( const ::com::sun::star::uno::Any& aSAXParseException ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL fatalError( const ::com::sun::star::uno::Any& aSAXParseException ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL warning( const ::com::sun::star::uno::Any& aSAXParseException ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + + // Methods XDocumentHandler + virtual void SAL_CALL startDocument( ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL endDocument( ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL startElement( const ::rtl::OUString& aName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL endElement( const ::rtl::OUString& aName ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL characters( const ::rtl::OUString& aChars ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL ignorableWhitespace( const ::rtl::OUString& aWhitespaces ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL processingInstruction( const ::rtl::OUString& aTarget, const ::rtl::OUString& aData ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDocumentLocator( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator >& xLocator ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); +}; + + +SAXParser::SAXParser( const String &rFilename ) +: aFilename( rFilename ) +{ + Touch(); +} + +SAXParser::~SAXParser() +{ + xParser.clear(); +} + +BOOL SAXParser::Parse( ParseAction aAct ) +{ + aAction = aAct; + Touch(); + SvStream* pStream = new SvFileStream( aFilename, STREAM_STD_READ ); + if ( pStream->GetError() ) + return FALSE; + + InputSource sSource; + sSource.aInputStream = new SVInputStream( pStream ); // is refcounted and hence deletet appropriately + sSource.sPublicId = OUString( aFilename ); + + xParser = Reference < XParser > ( ::comphelper::getProcessServiceFactory()->createInstance( CUniString("com.sun.star.xml.sax.Parser") ), UNO_QUERY ); + if ( xParser.is() ) + { + xParser->setErrorHandler( ( XErrorHandler*) this ); + if ( aAction == COLLECT_DATA || aAction == COLLECT_DATA_IGNORE_WHITESPACE ) + xParser->setDocumentHandler( ( XDocumentHandler*) this ); + + try + { + xParser->parseStream ( sSource ); + } + catch( class SAXParseException & rPEx) + { +#ifdef DBG_ERROR + String aMemo( rPEx.Message ); + aMemo = String( aMemo ); +#endif + } + catch( class Exception & rEx) + { +#ifdef DBG_ERROR + String aMemo( rEx.Message ); + aMemo = String( aMemo ); +#endif + } + xParser->setErrorHandler( NULL ); // otherwile Object holds itself + if ( aAction == COLLECT_DATA || aAction == COLLECT_DATA_IGNORE_WHITESPACE ) + xParser->setDocumentHandler( NULL ); // otherwile Object holds itself + } + else + return FALSE; + return TRUE; +} + + +// Helper Methods XErrorHandler +void SAXParser::AddToList( sal_Char* cuType, const ::com::sun::star::uno::Any& aSAXParseException ) +{ + SAXParseException aException; + aSAXParseException >>= aException; + + aErrors.Append( String( aException.PublicId ) ); + aErrors.AppendAscii( "(" ); + aErrors.Append( String::CreateFromInt64( aException.LineNumber ) ); + aErrors.AppendAscii( ":" ); + aErrors.Append( String::CreateFromInt64( aException.ColumnNumber ) ); + aErrors.AppendAscii( ") : " ); + aErrors.AppendAscii( cuType ); + aErrors.AppendAscii( ": " ); + aErrors.Append( String( aException.Message ) ); + aErrors.AppendAscii( "\n" ); +} + +// Methods XErrorHandler +void SAL_CALL SAXParser::error( const ::com::sun::star::uno::Any& aSAXParseException ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException) +{ + AddToList( "error", aSAXParseException ); +} + +void SAL_CALL SAXParser::fatalError( const ::com::sun::star::uno::Any& aSAXParseException ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException) +{ + AddToList( "fatal error", aSAXParseException ); +} + +void SAL_CALL SAXParser::warning( const ::com::sun::star::uno::Any& aSAXParseException ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException) +{ + AddToList( "warning", aSAXParseException ); +} + + +// Methods XDocumentHandler +void SAXParser::startDocument( ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException) +{ + xTreeRoot = new ElementNode( CUniString("/"), Reference < XAttributeList > (NULL) ); + xCurrentNode = xTreeRoot; + Touch(); +} + +void SAXParser::endDocument( ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException) +{ +} + +void SAXParser::startElement( const ::rtl::OUString& aName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException) +{ + NodeRef xNewNode = new ElementNode ( String(aName), xAttribs ); + ((ElementNode*)(&xCurrentNode))->AppendNode( xNewNode ); + xCurrentNode = xNewNode; +} + +void SAXParser::endElement( const ::rtl::OUString& aName ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException) +{ + xCurrentNode = xCurrentNode->GetParent(); +} + +void SAXParser::characters( const ::rtl::OUString& aChars ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException) +{ + if ( aAction == COLLECT_DATA_IGNORE_WHITESPACE ) + { // check for whitespace + BOOL bAllWhitespace = TRUE; + for ( int i = 0 ; bAllWhitespace && i < aChars.getLength() ; i++ ) + if ( aChars[i] != 10 // LF + && aChars[i] != 13 // CR + && aChars[i] != ' ' // Blank + && aChars[i] != '\t' ) // Tab + bAllWhitespace = FALSE; + if ( bAllWhitespace ) + return; + } + NodeRef xNewNode = new CharacterNode ( String(aChars) ); + ((ElementNode*)(&xCurrentNode))->AppendNode( xNewNode ); +} + +void SAXParser::ignorableWhitespace( const ::rtl::OUString& aWhitespaces ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException) +{ +} + +void SAXParser::processingInstruction( const ::rtl::OUString& aTarget, const ::rtl::OUString& aData ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException) +{ +} + +void SAXParser::setDocumentLocator( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator >& xLocator ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException) +{ +#ifdef DEBUG + ::rtl::OUString aTester; + aTester = xLocator->getPublicId(); + aTester = xLocator->getSystemId(); +#endif +} + + + + +void StatementCommand::HandleSAXParser() +{ + static Reference < XReference > xParserKeepaliveReference; // this is to keep the Object alive only + static SAXParser* pSAXParser; + + // We need spechial prerequisites for these! + + ElementNode* pElementNode = NULL; + switch ( nMethodId ) + { + case RC_SAXGetNodeType: + case RC_SAXGetAttributeCount: + case RC_SAXGetAttributeName: + case RC_SAXGetAttributeValue: + case RC_SAXGetChildCount: + case RC_SAXGetElementName: + case RC_SAXGetChars: + + case RC_SAXSeekElement: + case RC_SAXHasElement: + case RC_SAXGetElementPath: + { + if ( xParserKeepaliveReference.is() && pSAXParser->GetCurrentNode().Is() ) + { + if ( pSAXParser->GetCurrentNode()->GetNodeType() == NODE_ELEMENT ) + { + NodeRef xNode=pSAXParser->GetCurrentNode(); + pElementNode = (ElementNode*)(&xNode); + } + } + else + { + ReportError( GEN_RES_STR1( S_NO_SAX_PARSER, RcString( nMethodId ) ) ); + return; + } + + } + } + + switch ( nMethodId ) + { + case RC_SAXCheckWellformed: + { + if( (nParams & PARAM_STR_1) ) + { + xParserKeepaliveReference.clear(); + pSAXParser = new SAXParser( aString1 ); + xParserKeepaliveReference = ( XReference* )pSAXParser; + if ( !xParserKeepaliveReference.is() ) + ReportError( GEN_RES_STR1( S_NO_SAX_PARSER, RcString( nMethodId ) ) ); + else + { + if ( !pSAXParser->Parse( PARSE_ONLY ) ) + ReportError( GEN_RES_STR1( S_NO_SAX_PARSER, RcString( nMethodId ) ) ); + pRet->GenReturn ( RET_Value, nMethodId, pSAXParser->GetErrors() ); + } + + xParserKeepaliveReference.clear(); + } + else + ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) ); + } + break; + + case RC_SAXReadFile: + { + if( (nParams & PARAM_STR_1) ) + { + ParseAction aAction; + if( (nParams & PARAM_BOOL_1) && bBool1 ) + aAction = COLLECT_DATA; + else + aAction = COLLECT_DATA_IGNORE_WHITESPACE; + + xParserKeepaliveReference.clear(); + pSAXParser = new SAXParser( aString1 ); + xParserKeepaliveReference = ( XReference* )pSAXParser; + if ( !xParserKeepaliveReference.is() ) + ReportError( GEN_RES_STR1( S_NO_SAX_PARSER, RcString( nMethodId ) ) ); + else + { + + if ( !pSAXParser->Parse( aAction ) ) + ReportError( GEN_RES_STR1( S_NO_SAX_PARSER, RcString( nMethodId ) ) ); + pRet->GenReturn ( RET_Value, nMethodId, pSAXParser->GetErrors() ); + } + } + else + ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) ); + } + break; + case RC_SAXGetNodeType: + { + pRet->GenReturn ( RET_Value, nMethodId, (ULONG)pSAXParser->GetCurrentNode()->GetNodeType() ); + } + break; + case RC_SAXGetAttributeCount: + case RC_SAXGetAttributeName: + case RC_SAXGetAttributeValue: + case RC_SAXGetChildCount: + case RC_SAXGetElementName: + { + if ( pElementNode ) + { + Reference < XAttributeList > xAttributeList = pElementNode->GetAttributes(); + switch ( nMethodId ) + { + case RC_SAXGetElementName: + pRet->GenReturn ( RET_Value, nMethodId, pElementNode->GetNodeName() ); + break; + case RC_SAXGetChildCount: + pRet->GenReturn ( RET_Value, nMethodId, (ULONG)pElementNode->GetChildCount() ); + break; + case RC_SAXGetAttributeCount: + if ( xAttributeList.is() ) + pRet->GenReturn ( RET_Value, nMethodId, (ULONG)xAttributeList->getLength() ); + else + pRet->GenReturn ( RET_Value, nMethodId, (ULONG)0 ); + break; + case RC_SAXGetAttributeName: + { + if( (nParams & PARAM_USHORT_1) && ValueOK( 0, RcString( nMethodId ), nNr1, xAttributeList.is()?xAttributeList->getLength():0 ) ) + { + String aRet( xAttributeList->getNameByIndex( nNr1-1 ) ); + pRet->GenReturn ( RET_Value, nMethodId, aRet ); + } + else + ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) ); + } + break; + case RC_SAXGetAttributeValue: + // Number or String + { + if( (nParams & PARAM_USHORT_1) && ValueOK( 0, RcString( nMethodId ), nNr1, xAttributeList.is()?xAttributeList->getLength():0 ) ) + { + String aRet( xAttributeList->getValueByIndex( nNr1-1 ) ); + pRet->GenReturn ( RET_Value, nMethodId, aRet ); + } + else if( (nParams & PARAM_STR_1) && xAttributeList.is() ) + { + String aRet( xAttributeList->getValueByName( aString1 ) ); + pRet->GenReturn ( RET_Value, nMethodId, aRet ); + } + else + ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) ); + } + break; + + default: + ReportError( GEN_RES_STR1( S_INTERNAL_ERROR, RcString( nMethodId ) ) ); + } + } + else + ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) ); + } + break; + case RC_SAXGetChars: + { + if ( pSAXParser->GetCurrentNode()->GetNodeType() == NODE_CHARACTER ) + { + NodeRef xNode=pSAXParser->GetCurrentNode(); + CharacterNode* aCharacterNode = (CharacterNode*)(&xNode); + pRet->GenReturn ( RET_Value, nMethodId, aCharacterNode->GetCharacters() ); + } + else + ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) ); + } + break; + + case RC_SAXSeekElement: + case RC_SAXHasElement: + // Number or String + { + BOOL bCheckOnly = nMethodId == RC_SAXHasElement; + + if( (nParams & PARAM_USHORT_1) && !(nParams & PARAM_STR_1) ) + { + if ( nNr1 == 0 ) + { + if ( bCheckOnly ) + pRet->GenReturn ( RET_Value, nMethodId, pSAXParser->GetCurrentNode()->GetParent().Is() ); + else if ( pSAXParser->GetCurrentNode()->GetParent().Is() ) + pSAXParser->SetCurrentNode( pSAXParser->GetCurrentNode()->GetParent() ); + } + else if ( !pElementNode ) + ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) ); + else if ( bCheckOnly ) + pRet->GenReturn ( RET_Value, nMethodId, ValueOK( 0, String(), nNr1, pElementNode->GetChildCount() ) ); + else if ( ValueOK( 0, RcString( nMethodId ), nNr1, pElementNode->GetChildCount() ) ) + pSAXParser->SetCurrentNode( pElementNode->GetChild( nNr1-1 ) ); + } + else if( (nParams & PARAM_STR_1) ) + { + if ( aString1.EqualsAscii( "/" ) ) + { + if ( bCheckOnly ) + pRet->GenReturn ( RET_Value, nMethodId, (BOOL)TRUE ); + else + pSAXParser->SetCurrentNode( pSAXParser->GetRootNode() ); + } + else if ( aString1.Copy(0,2).EqualsAscii( "*:" ) ) + { + ULONG nTimestamp = (ULONG)aString1.GetToken( 1, ':' ).ToInt64(); + ULONG nPointer = (ULONG)aString1.GetToken( 2, ':' ).ToInt64(); + if ( bCheckOnly ) + pRet->GenReturn ( RET_Value, nMethodId, (BOOL)(pSAXParser->GetTimestamp() == nTimestamp) ); + else + if ( pSAXParser->GetTimestamp() == nTimestamp ) + { + { + Node* pNode = (Node*)nPointer; + pSAXParser->SetCurrentNode( NodeRef( pNode ) ); + } + } + else + ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) ); + } + else if ( pElementNode ) + { + USHORT nNthOccurance; + if( (nParams & PARAM_USHORT_1) ) + nNthOccurance = nNr1; + else + nNthOccurance = 1; + + USHORT i; + NodeRef xNew; + for ( i = 0 ; i < pElementNode->GetChildCount() && !xNew.Is() ; i++ ) + { + xNew = pElementNode->GetChild( i ); + if ( xNew->GetNodeType() == NODE_ELEMENT ) + { + ElementNode* pNewElement = (ElementNode*)(&xNew); + if ( aString1.Equals( pNewElement->GetNodeName() ) ) + { + if ( nNthOccurance > 1 ) + { + xNew.Clear(); + nNthOccurance--; + } + } + else + xNew.Clear(); + } + else + xNew.Clear(); + } + if ( bCheckOnly ) + pRet->GenReturn ( RET_Value, nMethodId, xNew.Is() ); + else + if ( xNew.Is() ) + pSAXParser->SetCurrentNode( xNew ); + else + ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) ); + } + else + if ( bCheckOnly ) + pRet->GenReturn ( RET_Value, nMethodId, (BOOL)FALSE ); + else + ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) ); + } + else + ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) ); + } + break; + case RC_SAXGetElementPath: + { + DBG_ASSERT( sizeof( ULONG ) == sizeof ( void* ), "Pointertype has different size than ULONG") + String aPath; + aPath.AppendAscii( "*:" ); + aPath.Append( String::CreateFromInt64( pSAXParser->GetTimestamp() ) ); + aPath.AppendAscii( ":" ); + NodeRef xNode=pSAXParser->GetCurrentNode(); + Node* pNode = (Node*)(&xNode); + aPath.Append( String::CreateFromInt64( (ULONG)pNode ) ); + pRet->GenReturn ( RET_Value, nMethodId, aPath ); + } + break; + + case RC_SAXRelease: + { + xParserKeepaliveReference.clear(); + } + break; + default: + ReportError( GEN_RES_STR1( S_INTERNAL_ERROR, RcString( nMethodId ) ) ); + } +} + diff --git a/automation/source/server/cmdbasestream.cxx b/automation/source/server/cmdbasestream.cxx new file mode 100644 index 000000000000..106970c09aba --- /dev/null +++ b/automation/source/server/cmdbasestream.cxx @@ -0,0 +1,326 @@ +/************************************************************************* + * + * $RCSfile: cmdbasestream.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: mh $ $Date: 2002-11-18 15:27:30 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2002 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2002 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2002 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +/************************************************************************* + * + * ATTENTION + * This file is intended to work inside and outside the StarOffice environment. + * Only adaption of file commtypes.hxx should be necessary. Else it is a bug! + * + ************************************************************************/ + + +#include "cmdbasestream.hxx" +#include "rcontrol.hxx" + +CmdBaseStream::CmdBaseStream() +: pCommStream( NULL ) +{ +} + +CmdBaseStream::~CmdBaseStream() +{ +} + +void CmdBaseStream::GenError (comm_ULONG nError, const comm_UniChar* aString, comm_USHORT nLenInChars ) +{ + Write(comm_USHORT(SIReturnError)); + Write(nError); + Write(aString, nLenInChars); +} + +void CmdBaseStream::GenReturn (comm_USHORT nRet, comm_ULONG nUId ) +{ + Write(comm_USHORT(SIReturn)); + Write(nRet); + Write(nUId); + Write(comm_USHORT(PARAM_NONE)); // Typ der folgenden Parameter +} + +void CmdBaseStream::GenReturn (comm_USHORT nRet, comm_ULONG nUId, comm_ULONG nNr ) +{ + Write(comm_USHORT(SIReturn)); + Write(nRet); + Write(nUId); + Write(comm_USHORT(PARAM_ULONG_1)); // Typ der folgenden Parameter + Write(nNr); +} + +void CmdBaseStream::GenReturn (comm_USHORT nRet, comm_ULONG nUId, const comm_UniChar* aString, comm_USHORT nLenInChars ) +{ + Write(comm_USHORT(SIReturn)); + Write(nRet); + Write(nUId); + Write(comm_USHORT(PARAM_STR_1)); // Typ der folgenden Parameter + Write(aString, nLenInChars); +} + +void CmdBaseStream::GenReturn (comm_USHORT nRet, comm_ULONG nUId, comm_BOOL bBool ) +{ + Write(comm_USHORT(SIReturn)); + Write(nRet); + Write(nUId); + Write(comm_USHORT(PARAM_BOOL_1)); // Typ der folgenden Parameter + Write(bBool); +} + +void CmdBaseStream::GenReturn (comm_USHORT nRet, comm_ULONG nUId, comm_ULONG nNr, const comm_UniChar* aString, comm_USHORT nLenInChars, comm_BOOL bBool ) +{ + Write(comm_USHORT(SIReturn)); + Write(nRet); + Write(nUId); + Write(comm_USHORT(PARAM_ULONG_1|PARAM_STR_1|PARAM_BOOL_1)); // Typ der folgenden Parameter + Write(nNr); + Write(aString, nLenInChars); + Write(bBool); +} + +// MacroRecorder +void CmdBaseStream::GenReturn( comm_USHORT nRet, comm_ULONG nUId, comm_USHORT nMethod ) +{ + Write(comm_USHORT(SIReturn)); + Write(nRet); + Write(nUId); + Write(comm_USHORT(PARAM_USHORT_1)); // Typ der folgenden Parameter + Write(nMethod); +} + +void CmdBaseStream::GenReturn( comm_USHORT nRet, comm_ULONG nUId, comm_USHORT nMethod, const comm_UniChar* aString, comm_USHORT nLenInChars ) +{ + Write(comm_USHORT(SIReturn)); + Write(nRet); + Write(nUId); + Write(comm_USHORT(PARAM_USHORT_1|PARAM_STR_1)); // Typ der folgenden Parameter + Write(nMethod); + Write(aString, nLenInChars); +} + +void CmdBaseStream::GenReturn( comm_USHORT nRet, comm_ULONG nUId, comm_USHORT nMethod, const comm_UniChar* aString, comm_USHORT nLenInChars, comm_BOOL bBool ) +{ + Write(comm_USHORT(SIReturn)); + Write(nRet); + Write(nUId); + Write(comm_USHORT(PARAM_USHORT_1|PARAM_STR_1|PARAM_BOOL_1)); // Typ der folgenden Parameter + Write(nMethod); + Write(aString, nLenInChars); + Write(bBool); +} + +void CmdBaseStream::GenReturn( comm_USHORT nRet, comm_ULONG nUId, comm_USHORT nMethod, comm_BOOL bBool ) +{ + Write(comm_USHORT(SIReturn)); + Write(nRet); + Write(nUId); + Write(comm_USHORT(PARAM_USHORT_1|PARAM_BOOL_1)); // Typ der folgenden Parameter + Write(nMethod); + Write(bBool); +} + +void CmdBaseStream::GenReturn( comm_USHORT nRet, comm_ULONG nUId, comm_USHORT nMethod, comm_ULONG nNr ) +{ + Write(comm_USHORT(SIReturn)); + Write(nRet); + Write(nUId); + Write(comm_USHORT(PARAM_USHORT_1|PARAM_ULONG_1)); // Typ der folgenden Parameter + Write(nMethod); + Write(nNr); +} + + + + +// StringID +void CmdBaseStream::GenReturn( comm_USHORT nRet, const comm_UniChar* aUId, comm_USHORT nUIdLenInChars ) +{ + Write(comm_USHORT(SIReturn)); + Write(nRet); + Write(aUId, nUIdLenInChars); + Write(comm_USHORT(PARAM_NONE)); // Typ der folgenden Parameter +} + +void CmdBaseStream::GenReturn( comm_USHORT nRet, const comm_UniChar* aUId, comm_USHORT nUIdLenInChars, comm_ULONG nNr ) +{ + Write(comm_USHORT(SIReturn)); + Write(nRet); + Write(aUId, nUIdLenInChars); + Write(comm_USHORT(PARAM_ULONG_1)); // Typ der folgenden Parameter + Write(nNr); +} + +void CmdBaseStream::GenReturn( comm_USHORT nRet, const comm_UniChar* aUId, comm_USHORT nUIdLenInChars, const comm_UniChar* aString, comm_USHORT nLenInChars ) +{ + Write(comm_USHORT(SIReturn)); + Write(nRet); + Write(aUId, nUIdLenInChars); + Write(comm_USHORT(PARAM_STR_1)); // Typ der folgenden Parameter + Write(aString, nLenInChars); +} + +void CmdBaseStream::GenReturn( comm_USHORT nRet, const comm_UniChar* aUId, comm_USHORT nUIdLenInChars, comm_BOOL bBool ) +{ + Write(comm_USHORT(SIReturn)); + Write(nRet); + Write(aUId, nUIdLenInChars); + Write(comm_USHORT(PARAM_BOOL_1)); // Typ der folgenden Parameter + Write(bBool); +} + +void CmdBaseStream::GenReturn( comm_USHORT nRet, const comm_UniChar* aUId, comm_USHORT nUIdLenInChars, comm_ULONG nNr, const comm_UniChar* aString, comm_USHORT nLenInChars, comm_BOOL bBool ) +{ + Write(comm_USHORT(SIReturn)); + Write(nRet); + Write(aUId, nUIdLenInChars); + Write(comm_USHORT(PARAM_ULONG_1|PARAM_STR_1|PARAM_BOOL_1)); // Typ der folgenden Parameter + Write(nNr); + Write(aString, nLenInChars); + Write(bBool); +} + + +void CmdBaseStream::Read (comm_USHORT &nNr) +{ + comm_USHORT nId; + *pCommStream >> nId; + if (pCommStream->IsEof()) return; + if (nId != BinUSHORT) DBG_ERROR1( "Falscher Typ im Stream: Erwartet USHORT, gefunden :%hu", nId ); + *pCommStream >> nNr; +} + +void CmdBaseStream::Read (comm_ULONG &nNr) +{ + comm_USHORT nId; + *pCommStream >> nId; + if (pCommStream->IsEof()) return; + if (nId != BinULONG) DBG_ERROR1( "Falscher Typ im Stream: Erwartet ULONG, gefunden :%hu", nId ); + *pCommStream >> nNr; +} + +void CmdBaseStream::Read (comm_UniChar* &aString, comm_USHORT &nLenInChars ) +{ + comm_USHORT nId; + *pCommStream >> nId; + if (nId != BinString) DBG_ERROR1( "Falscher Typ im Stream: Erwartet String, gefunden :%hu", nId ); + + *pCommStream >> nLenInChars; + + aString = new comm_UniChar [nLenInChars]; + pCommStream->Read( aString, ((comm_ULONG)nLenInChars) * sizeof( comm_UniChar ) ); +#ifdef __BIGENDIAN + // we have to change the byteorder + comm_USHORT n; + for ( n = 0 ; n < nLenInChars ; n++ ) + aString[ n ] = aString[ n ] >> 8 | aString[ n ] << 8; +#endif +} + +void CmdBaseStream::Read (comm_BOOL &bBool) +{ + comm_USHORT nId; + *pCommStream >> nId; + if (nId != BinBool) DBG_ERROR1( "Falscher Typ im Stream: Erwartet BOOL, gefunden :%hu", nId ); + *pCommStream >> bBool; +} + +comm_USHORT CmdBaseStream::GetNextType() +{ + comm_USHORT nId; + *pCommStream >> nId; + pCommStream->SeekRel(-2); + return nId; +} + + +void CmdBaseStream::Write( comm_USHORT nNr ) +{ + *pCommStream << comm_USHORT( BinUSHORT ); + *pCommStream << nNr; +} + +void CmdBaseStream::Write( comm_ULONG nNr ) +{ + *pCommStream << comm_USHORT( BinULONG ); + *pCommStream << nNr; +} + +void CmdBaseStream::Write( const comm_UniChar* aString, comm_USHORT nLenInChars ) +{ + *pCommStream << comm_USHORT(BinString); + *pCommStream << nLenInChars; +#ifdef __BIGENDIAN + // we have to change the byteorder + comm_UniChar* aNewString; + aNewString = new comm_UniChar [nLenInChars]; + comm_USHORT n; + for ( n = 0 ; n < nLenInChars ; n++ ) + aNewString[ n ] = aString[ n ] >> 8 | aString[ n ] << 8; + pCommStream->Write( aNewString, ((comm_ULONG)nLenInChars) * sizeof( comm_UniChar ) ); + delete [] aNewString; +#else + pCommStream->Write( aString, ((comm_ULONG)nLenInChars) * sizeof( comm_UniChar ) ); +#endif +} + +void CmdBaseStream::Write( comm_BOOL bBool ) +{ + *pCommStream << comm_USHORT( BinBool ); + *pCommStream << bBool; +} + diff --git a/automation/source/server/editwin.cxx b/automation/source/server/editwin.cxx new file mode 100644 index 000000000000..cb5976981134 --- /dev/null +++ b/automation/source/server/editwin.cxx @@ -0,0 +1,201 @@ +/************************************************************************* + * + * $RCSfile: editwin.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: mh $ $Date: 2002-11-18 15:27:36 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2002 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2002 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2002 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef DEBUG + +#ifndef _SV_SVAPP_HXX //autogen +#include <vcl/svapp.hxx> +#endif + +#ifndef _EDITWIN_HXX +#include "editwin.hxx" +#endif + + +class ImpWorkWindow : public WorkWindow +{ +public: + MultiLineEdit m_aInhalt; + ImpWorkWindow( WorkWindow *pParent, const UniString &rName, WinBits ); + ~ImpWorkWindow(); + void Resize(); +}; + +ImpWorkWindow::ImpWorkWindow( WorkWindow *pParent, const String &rName, WinBits iWstyle ) +: WorkWindow( pParent , WB_SIZEMOVE ) +, m_aInhalt( this, iWstyle ) +{ + m_aInhalt.Show(); + SetText(rName); + SetPosSizePixel( Point( 1,40 ), Size(500,150) ); + Resize(); +} + +ImpWorkWindow::~ImpWorkWindow() +{ + Hide(); +} + +void ImpWorkWindow::Resize() +{ + m_aInhalt.SetPosSizePixel( Point(), GetOutputSizePixel() ); +} + +BOOL EditWindow::Close() +{ + if ( pImpWorkWindow ) + { + delete pImpWorkWindow; + pImpWorkWindow = NULL; + } + return TRUE; +} + +void EditWindow::Show() +{ + if ( Check() ) + pImpWorkWindow->Show(); + else + bShowWin = TRUE; +} + +void EditWindow::Hide() +{ + if ( Check() ) + pImpWorkWindow->Hide(); + else + bShowWin = FALSE; +} + +EditWindow::EditWindow( WorkWindow *pParent, const String &rName, WinBits iWstyle ) +: pMemParent(pParent) +, aMemName(rName) +, iMemWstyle(iWstyle) +, bQuiet(FALSE) +, pImpWorkWindow(NULL) +, nTextLen(0) +{ +} + +EditWindow::~EditWindow() +{ + Close(); +} + +BOOL EditWindow::Check() +{ + if ( ! pImpWorkWindow && Application::IsInExecute() ) + { + pImpWorkWindow = new ImpWorkWindow( pMemParent, aMemName, iMemWstyle ); + pImpWorkWindow->m_aInhalt.SetText( aMemPreWinText ); + nTextLen = aMemPreWinText.Len(); + aMemPreWinText.Erase(); + if ( bShowWin ) + pImpWorkWindow->Show(); + return TRUE; + } + return pImpWorkWindow != NULL; +} + +void EditWindow::Clear() +{ + if ( Check() ) + { + pImpWorkWindow->m_aInhalt.SetText( String() ); + nTextLen = 0; + } + aMemPreWinText.Erase(); +} + +void EditWindow::AddText( const sal_Char* rNew ) +{ + AddText( UniString::CreateFromAscii( rNew ) ); +} + +void EditWindow::AddText( const String &rNew ) +{ + if ( bQuiet ) return; + + String aText = rNew; + aText.ConvertLineEnd(); + + if ( Check() ) + { + if ( nTextLen > 5000 ) + { + pImpWorkWindow->m_aInhalt.SetText( pImpWorkWindow->m_aInhalt.GetText().Erase(0,1000) ); + nTextLen = pImpWorkWindow->m_aInhalt.GetText().Len(); // Absolut, um Fehler sonstwo auszubügeln + } + + + pImpWorkWindow->m_aInhalt.SetSelection( Selection( SELECTION_MAX, SELECTION_MAX ) ); + pImpWorkWindow->m_aInhalt.ReplaceSelected( aText ); + nTextLen += aText.Len(); + pImpWorkWindow->m_aInhalt.SetSelection( Selection( SELECTION_MAX, SELECTION_MAX ) ); + } + else + { + aMemPreWinText += aText; + } +} + +#endif + diff --git a/automation/source/server/editwin.hxx b/automation/source/server/editwin.hxx new file mode 100644 index 000000000000..01644d381e6d --- /dev/null +++ b/automation/source/server/editwin.hxx @@ -0,0 +1,108 @@ +/************************************************************************* + * + * $RCSfile: editwin.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: mh $ $Date: 2002-11-18 15:27:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2002 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2002 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2002 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _EDITWIN_HXX +#define _EDITWIN_HXX + +#ifdef DEBUG + +#ifndef _WRKWIN_HXX //autogen +#include <vcl/wrkwin.hxx> +#endif + +#ifndef _EDIT_HXX //autogen +#include <svtools/svmedit.hxx> +#endif + +class ImpWorkWindow; + +class EditWindow +{ +protected: + ImpWorkWindow *pImpWorkWindow; + BOOL check(); + + WorkWindow *pMemParent; + String aMemName; + WinBits iMemWstyle; + + String aMemPreWinText; + BOOL bShowWin; + + xub_StrLen nTextLen; // aus Performanzgründen eigene Länge mitführen + +public: + EditWindow( WorkWindow *pParent, const UniString &rName = UniString( RTL_CONSTASCII_USTRINGPARAM ( "Debug" ) ), WinBits iWstyle = WB_HSCROLL | WB_VSCROLL ); + ~EditWindow(); + + void Clear(); + void Show(); + void Hide(); + void AddText( const String &rNew ); + void AddText( const sal_Char* rNew ); + + virtual BOOL Close(); // derived + BOOL bQuiet; + BOOL Check(); +}; + +#endif +#endif + diff --git a/automation/source/server/makefile.mk b/automation/source/server/makefile.mk new file mode 100644 index 000000000000..e90ec469ad95 --- /dev/null +++ b/automation/source/server/makefile.mk @@ -0,0 +1,105 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1 $ +# +# last change: $Author: mh $ $Date: 2002-11-18 15:27:48 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2002 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2002 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (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.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc.. +# +# Copyright: 2002 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* +PRJ=..$/.. + +PRJNAME=AUTOMATION +TARGET=server + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +# --- Files -------------------------------------------------------- + +SLOFILES = \ + $(SLO)$/XMLParser.obj \ + $(SLO)$/recorder.obj \ + $(SLO)$/svcommstream.obj \ + $(SLO)$/cmdbasestream.obj \ + $(SLO)$/scmdstrm.obj \ + $(SLO)$/statemnt.obj \ + $(SLO)$/sta_list.obj \ + $(SLO)$/editwin.obj \ + $(SLO)$/server.obj \ + $(SLO)$/retstrm.obj \ + $(SLO)$/profiler.obj + + +OBJFILES = \ + $(OBJ)$/cmdbasestream.obj \ + $(OBJ)$/svcommstream.obj + +EXCEPTIONSFILES = \ + $(SLO)$/server.obj \ + $(SLO)$/XMLParser.obj + +NOOPTFILES = $(SLO)$/statemnt.obj + +.IF "$(OS)"=="SOLARIS" +SLOFILES += $(SLO)$/prof_usl.obj +.ELSE +SLOFILES += $(SLO)$/prof_nul.obj +.ENDIF + +# --- Tagets ------------------------------------------------------- + +.INCLUDE : target.mk diff --git a/automation/source/server/prof_nul.cxx b/automation/source/server/prof_nul.cxx new file mode 100644 index 000000000000..49c5a2609dcd --- /dev/null +++ b/automation/source/server/prof_nul.cxx @@ -0,0 +1,127 @@ +/************************************************************************* + * + * $RCSfile: prof_nul.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: mh $ $Date: 2002-11-18 15:27:54 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2002 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2002 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2002 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +#include "profiler.hxx" +#include "rcontrol.hxx" +#include <basic/ttstrhlp.hxx> + +struct SysdepProfileSnapshot +{ + // Hier stehen alle Felder zum Speichern eines Snapshot +}; + + +struct SysdepStaticData +{ + // Hier steht alles, was während des Profiles ständig gebraucht wird +}; + + +void TTProfiler::InitSysdepProfiler() +{ + if ( !pSysDepStatic ) // Sollte immer so sein!! + pSysDepStatic = new SysdepStaticData; + // Hier initialisieren + +}; + +void TTProfiler::DeinitSysdepProfiler() +{ + if ( pSysDepStatic ) // Sollte immer so sein!! + { + // Hier aufräumen und eventuell Speicher freigeben + + delete pSysDepStatic; + } +}; + +SysdepProfileSnapshot *TTProfiler::NewSysdepSnapshotData() +{ + return new SysdepProfileSnapshot; +}; + +void TTProfiler::DeleteSysdepSnapshotData( SysdepProfileSnapshot *pSysdepProfileSnapshot ) +{ + delete pSysdepProfileSnapshot; +}; + + +// Titelzeile für Logdatei +String TTProfiler::GetSysdepProfileHeader() +{ + return String(CUniString("(noch) keine weiteren Daten Implementiert")); +}; + + +// Zustand merken +void TTProfiler::GetSysdepProfileSnapshot( SysdepProfileSnapshot *pSysdepProfileSnapshot, USHORT nMode ) +{}; + + +// Informationszeile zusammenbauen +String TTProfiler::GetSysdepProfileLine( SysdepProfileSnapshot *pStart, SysdepProfileSnapshot *pStop ) +{ + return String(); +}; + + + diff --git a/automation/source/server/prof_usl.cxx b/automation/source/server/prof_usl.cxx new file mode 100644 index 000000000000..de5b400c8b12 --- /dev/null +++ b/automation/source/server/prof_usl.cxx @@ -0,0 +1,167 @@ +/************************************************************************* + * + * $RCSfile: prof_usl.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: mh $ $Date: 2002-11-18 15:27:59 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2002 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2002 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2002 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +#include <procfs.h> +#include <tools/stream.hxx> +#include "profiler.hxx" + + +struct SysdepProfileSnapshot +{ + pstatus mpstatus; + psinfo mpsinfo; + prusage mprusage; +}; + + +struct SysdepStaticData +{ + // Hier steht alles, was während des Profiles ständig gebraucht wird +}; + + +void TTProfiler::InitSysdepProfiler() +{ + if ( !pSysDepStatic ) // Sollte immer so sein!! + pSysDepStatic = new SysdepStaticData; + // Hier initialisieren + +}; + +void TTProfiler::DeinitSysdepProfiler() +{ + if ( pSysDepStatic ) // Sollte immer so sein!! + { + // Hier aufräumen und eventuell Speicher freigeben + + delete pSysDepStatic; + } +}; + +SysdepProfileSnapshot *TTProfiler::NewSysdepSnapshotData() +{ + return new SysdepProfileSnapshot; +}; + +void TTProfiler::DeleteSysdepSnapshotData( SysdepProfileSnapshot *pSysdepProfileSnapshot ) +{ + delete pSysdepProfileSnapshot; +}; + + +// Titelzeile für Logdatei +String TTProfiler::GetSysdepProfileHeader() +{ + return String::CreateFromAscii(" Size(Kb) ResidentSZ rtime ktime utime total"); +}; + + +// Zustand merken +void TTProfiler::GetSysdepProfileSnapshot( SysdepProfileSnapshot *pSysdepProfileSnapshot, USHORT nMode ) +{ + SvFileStream aStream( String::CreateFromAscii("/proc/self/psinfo"), STREAM_READ ); // Das ist ein expliziter Pfad für UNXSOL! + if ( aStream.IsOpen() ) + { + aStream.Read( &(pSysdepProfileSnapshot->mpsinfo), sizeof( psinfo ) ); + aStream.Close(); + } + SvFileStream anotherStream( String::CreateFromAscii("/proc/self/status"), STREAM_READ ); // Das ist ein expliziter Pfad für UNXSOL! + if ( anotherStream.IsOpen() ) + { + anotherStream.Read( &(pSysdepProfileSnapshot->mpstatus), sizeof( pstatus ) ); + anotherStream.Close(); + } + SvFileStream YetAnotherStream( String::CreateFromAscii("/proc/self/usage"), STREAM_READ ); // Das ist ein expliziter Pfad für UNXSOL! + if ( YetAnotherStream.IsOpen() ) + { + YetAnotherStream.Read( &(pSysdepProfileSnapshot->mprusage), sizeof( prusage ) ); + YetAnotherStream.Close(); + } +}; + +#define DIFF2( aFirst, aSecond, Membername ) ( aSecond.Membername - aFirst.Membername ) +#define CALC_MS( nSec, nNSec ) ( nSec * 1000 + (nNSec+500000) / 1000000 ) +#define DIFF_MS( pStart, pEnd, Member ) ( CALC_MS( DIFF2( pStart->Member, pEnd->Member, tv_sec ), DIFF2( pStart->Member, pEnd->Member, tv_nsec ) ) ) +// Informationszeile zusammenbauen +String TTProfiler::GetSysdepProfileLine( SysdepProfileSnapshot *pStart, SysdepProfileSnapshot *pStop ) +{ + String aProfile; + + aProfile += Pad( pStop->mpsinfo.pr_size, 9); + aProfile += Pad( pStop->mpsinfo.pr_rssize, 11); + + + aProfile += Pad( DIFF_MS( pStart, pStop, mprusage.pr_rtime ) / AVER( pStart, pStop, mprusage.pr_count ), 7 ); + + + ULONG d_utime = DIFF_MS( pStart, pStop, mpstatus.pr_utime ) + DIFF_MS( pStart, pStop, mpstatus.pr_cutime ); + ULONG d_stime = DIFF_MS( pStart, pStop, mpstatus.pr_stime ) + DIFF_MS( pStart, pStop, mpstatus.pr_cstime ); + + aProfile += Pad( d_utime, 7 ); + aProfile += Pad( d_stime, 7 ); + aProfile += Pad( d_utime + d_stime, 7 ); + + return aProfile; +}; + + + diff --git a/automation/source/server/profiler.cxx b/automation/source/server/profiler.cxx new file mode 100644 index 000000000000..b84dbaef42f5 --- /dev/null +++ b/automation/source/server/profiler.cxx @@ -0,0 +1,303 @@ +/************************************************************************* + * + * $RCSfile: profiler.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: mh $ $Date: 2002-11-18 15:28:05 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2002 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2002 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2002 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +#ifndef _TIME_HXX //autogen +#include <tools/time.hxx> +#endif +#ifndef _STRING_HXX //autogen +#include <tools/string.hxx> +#endif +#ifndef _SV_SVAPP_HXX //autogen +#include <vcl/svapp.hxx> +#endif +#ifndef _INTN_HXX //autogen +#include <tools/intn.hxx> +#endif +#ifndef _BASIC_TTRESHLP_HXX +#include <basic/ttstrhlp.hxx> +#endif + + +#include "profiler.hxx" + + +TTProfiler::TTProfiler() +: pStart( NULL ) +, pEnd( NULL ) +, bIsProfileIntervalStarted( FALSE ) +, bIsProfilingPerCommand( FALSE ) +, bIsPartitioning( FALSE ) +, bIsAutoProfiling( FALSE ) +, pSysDepStatic( NULL ) +{ + InitSysdepProfiler(); + pStart = new ProfileSnapshot; + pStart->pSysdepProfileSnapshot = NewSysdepSnapshotData(); + pEnd = new ProfileSnapshot; + pEnd->pSysdepProfileSnapshot = NewSysdepSnapshotData(); + StartProfileInterval(); +} + +TTProfiler::~TTProfiler() +{ + if ( IsAutoProfiling() ) + StopAutoProfiling(); + if ( pStart ) + { + if ( pStart->pSysdepProfileSnapshot ) + DeleteSysdepSnapshotData( pStart->pSysdepProfileSnapshot ); + delete pStart; + pStart = NULL; + } + if ( pEnd ) + { + if ( pEnd->pSysdepProfileSnapshot ) + DeleteSysdepSnapshotData( pEnd->pSysdepProfileSnapshot ); + delete pEnd; + pEnd = NULL; + } + DeinitSysdepProfiler(); +} + + +String TTProfiler::GetProfileHeader() +{ + UniString aReturn; + aReturn += '\n'; + if ( !IsAutoProfiling() ) + aReturn.AppendAscii("Befehl").Append(TabString(36)); + + aReturn.AppendAscii(" Zeitdauer"); + aReturn.AppendAscii(" Ticks in %"); + aReturn.Append( GetSysdepProfileHeader() ); + aReturn.AppendAscii("\n"); + return aReturn; +} + + +void TTProfiler::StartProfileInterval( BOOL bReadAnyway ) +{ + if ( !bIsProfileIntervalStarted || bReadAnyway ) + { + GetProfileSnapshot( pStart ); + GetSysdepProfileSnapshot( pStart->pSysdepProfileSnapshot, PROFILE_START ); + bIsProfileIntervalStarted = TRUE; + } +} + +String TTProfiler::GetProfileLine( ProfileSnapshot *pStart, ProfileSnapshot *pEnd ) +{ + String aProfileString; + + aProfileString += Pad(GetpApp()->GetAppInternational().GetDuration( DIFF( pStart, pEnd, aTime) , TRUE, TRUE ), 12); + + ULONG nProcessTicks = DIFF( pStart, pEnd, nProcessTicks ); + ULONG nSystemTicks = DIFF( pStart, pEnd, nSystemTicks ); + if ( nSystemTicks ) + { + aProfileString += Pad(UniString::CreateFromInt32( (100 * nProcessTicks) / nSystemTicks ), 11); + aProfileString += '%'; + } + else + aProfileString += Pad(CUniString("?? "), 12); + + return aProfileString; +} + + +String TTProfiler::GetProfileLine( String &aPrefix ) +{ + String aProfileString; + if ( IsProfilingPerCommand() || IsAutoProfiling() ) + { + aProfileString = aPrefix; + aProfileString += TabString(35); + + + aProfileString += GetProfileLine( pStart, pEnd ); + aProfileString += GetSysdepProfileLine( pStart->pSysdepProfileSnapshot, pEnd->pSysdepProfileSnapshot ); + aProfileString += '\n'; + } + + return aProfileString; +} + + +void TTProfiler::EndProfileInterval() +{ + GetProfileSnapshot( pEnd ); + GetSysdepProfileSnapshot( pEnd->pSysdepProfileSnapshot, PROFILE_END ); + bIsProfileIntervalStarted = FALSE; +} + + +void TTProfiler::GetProfileSnapshot( ProfileSnapshot *pProfileSnapshot ) +{ + pProfileSnapshot->aTime = Time(); + pProfileSnapshot->nProcessTicks = Time::GetProcessTicks(); + pProfileSnapshot->nSystemTicks = Time::GetSystemTicks(); +} + + +void TTProfiler::StartProfilingPerCommand() // Jeden Befehl mitschneiden +{ + bIsProfilingPerCommand = TRUE; +} + +void TTProfiler::StopProfilingPerCommand() +{ + bIsProfilingPerCommand = FALSE; +} + +void TTProfiler::StartPartitioning() +{ + bIsPartitioning = TRUE; +} + +void TTProfiler::StopPartitioning() +{ + bIsPartitioning = TRUE; +} + +ULONG TTProfiler::GetPartitioningTime() +{ + return DIFF( pStart, pEnd, nSystemTicks ); +} + + + +void TTProfiler::StartAutoProfiling( ULONG nMSec ) +{ + if ( !bIsAutoProfiling ) + { + pAutoStart = new ProfileSnapshot; + pAutoStart->pSysdepProfileSnapshot = NewSysdepSnapshotData(); + pAutoEnd = new ProfileSnapshot; + pAutoEnd->pSysdepProfileSnapshot = NewSysdepSnapshotData(); + GetProfileSnapshot( pAutoStart ); + GetSysdepProfileSnapshot( pAutoStart->pSysdepProfileSnapshot, PROFILE_START ); + SetTimeout( nMSec ); + bIsAutoProfiling = TRUE; + Start(); + } + +} + +void TTProfiler::Timeout() +{ + GetProfileSnapshot( pAutoEnd ); + GetSysdepProfileSnapshot( pAutoEnd->pSysdepProfileSnapshot, PROFILE_END ); + String aLine; + + aLine += GetProfileLine( pAutoStart, pAutoEnd ); + aLine += GetSysdepProfileLine( pAutoStart->pSysdepProfileSnapshot, pAutoEnd->pSysdepProfileSnapshot ); + aLine += '\n'; + + aAutoProfileBuffer += aLine; + + ProfileSnapshot *pTemp = pAutoStart; // Tauschen, so daß jetziges Ende nächsten Start wird + pAutoStart = pAutoEnd; + pAutoEnd = pTemp; + + Start(); // Timer neu starten +} + +String TTProfiler::GetAutoProfiling() +{ + String aTemp(aAutoProfileBuffer); + aAutoProfileBuffer.Erase(); + return aTemp; +} + +void TTProfiler::StopAutoProfiling() +{ + if ( bIsAutoProfiling ) + { + Stop(); + bIsAutoProfiling = FALSE; + } +} + + + +//String TTProfiler::Hex( ULONG nNr ) +String TTProfiler::Dec( ULONG nNr ) +{ + String aRet(UniString::CreateFromInt32(nNr)); + if ( nNr < 100 ) + { + aRet = Pad( aRet, 3); + aRet.SearchAndReplaceAll(' ','0'); + } + aRet.Insert( ',', aRet.Len() - 2 ); + return aRet; +} + +String TTProfiler::Pad( const String aS, xub_StrLen nLen ) +{ + if ( nLen > aS.Len() ) + return UniString().Fill( nLen - aS.Len() ).Append( aS ); + else + return CUniString(" ").Append( aS ); +} + + diff --git a/automation/source/server/profiler.hxx b/automation/source/server/profiler.hxx new file mode 100644 index 000000000000..46d8db545349 --- /dev/null +++ b/automation/source/server/profiler.hxx @@ -0,0 +1,177 @@ +/************************************************************************* + * + * $RCSfile: profiler.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: mh $ $Date: 2002-11-18 15:28:11 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2002 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2002 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2002 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + + +#define AVER( pFirst, pSecond, Membername ) (( pFirst->Membername + pSecond->Membername ) / 2 ) +#define DIFF( pFirst, pSecond, Membername ) ( pSecond->Membername - pFirst->Membername ) +#define S_SAFEDIV( a,b ) ((b)==0?CUniString("#DIV"):UniString::CreateFromInt32( (ULONG) ((a)/(b)))) +#define S_SAFEDIV_DEC( a,b ) ((b)==0?CUniString("#DIV"):Dec((ULONG) ((a)/(b)))) + +#ifndef _TIME_HXX //autogen +#include <tools/time.hxx> +#endif +#ifndef _STRING_HXX //autogen +#include <tools/string.hxx> +#endif +#ifndef _SV_TIMER_HXX //autogen +#include <vcl/timer.hxx> +#endif + +#define PROFILE_START 0x01 +#define PROFILE_END 0x02 + + +struct SysdepProfileSnapshot; +struct SysdepStaticData; // Nicht wirklich statisch, sondern statisch über mehrere Snapshots + +struct ProfileSnapshot +{ + Time aTime; + SysdepProfileSnapshot *pSysdepProfileSnapshot; + ULONG nProcessTicks; + ULONG nSystemTicks; +}; + + +class TTProfiler : private Timer +{ +public: + TTProfiler(); + ~TTProfiler(); + + String GetProfileHeader(); // Titelzeile für Logdatei + void StartProfileInterval( BOOL bReadAnyway = FALSE ); // Zustand merken + void EndProfileInterval(); // Informationszeile zusammenbauen + String GetProfileLine( String &aPrefix ); + + + void StartProfilingPerCommand(); // Jeden Befehl mitschneiden + void StopProfilingPerCommand(); + BOOL IsProfilingPerCommand() { return bIsProfilingPerCommand; } + + void StartPartitioning(); + void StopPartitioning(); + BOOL IsPartitioning() { return bIsPartitioning; } + ULONG GetPartitioningTime(); + + void StartAutoProfiling( ULONG nMSec ); // Automatisch alle nMSec Milisekunden sampeln + String GetAutoProfiling(); // Aktuelle `Sammlung` abholen + void StopAutoProfiling(); // Sampeln beenden + BOOL IsAutoProfiling() { return bIsAutoProfiling; } + +private: + + void GetProfileSnapshot( ProfileSnapshot *pProfileSnapshot ); + + // Informationszeile zusammenbauen + String GetProfileLine( ProfileSnapshot *pStart, ProfileSnapshot *pStop ); + + + ProfileSnapshot *pStart; + ProfileSnapshot *pEnd; + BOOL bIsProfileIntervalStarted; + + + +// + BOOL bIsProfilingPerCommand; + BOOL bIsPartitioning; + + +// Für das Automatische Profiling in festen Intervallen + + ProfileSnapshot *pAutoStart; + ProfileSnapshot *pAutoEnd; + BOOL bIsAutoProfiling; + String aAutoProfileBuffer; + + virtual void Timeout(); + + +// Einige Hilfsfunktionen + +// String Hex( ULONG nNr ); + String Dec( ULONG nNr ); // Ergebnis = nNr / 100 mit 2 Dezimalen + String Pad( const String aS, xub_StrLen nLen ); // Fügt blanks links an den String an + +/* Ab hier werden die Methoden Systemabhängig in den entsprechenden cxx implementiert + Sie werden von den oberen Methoden gerufen. +*/ + + SysdepStaticData *pSysDepStatic; + + void InitSysdepProfiler(); + void DeinitSysdepProfiler(); + + SysdepProfileSnapshot *NewSysdepSnapshotData(); + void DeleteSysdepSnapshotData( SysdepProfileSnapshot *pSysdepProfileSnapshot ); + + // Titelzeile für Logdatei + String GetSysdepProfileHeader(); + + // Zustand merken + void GetSysdepProfileSnapshot( SysdepProfileSnapshot *pSysdepProfileSnapshot, USHORT nMode = PROFILE_START | PROFILE_END ); + + // Informationszeile zusammenbauen + String GetSysdepProfileLine( SysdepProfileSnapshot *pStart, SysdepProfileSnapshot *pStop ); +}; + diff --git a/automation/source/server/recorder.cxx b/automation/source/server/recorder.cxx new file mode 100644 index 000000000000..c4c1ba36ac07 --- /dev/null +++ b/automation/source/server/recorder.cxx @@ -0,0 +1,1038 @@ +/************************************************************************* + * + * $RCSfile: recorder.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: mh $ $Date: 2002-11-18 15:28:17 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2002 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2002 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2002 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SV_WINDOW_HXX +#include <vcl/window.hxx> +#endif +#ifndef _VCL_VCLEVENT_HXX +#include <vcl/vclevent.hxx> +#endif +#ifndef _SV_BUTTON_HXX +#include <vcl/button.hxx> +#endif +#ifndef _SV_EDIT_HXX +#include <vcl/edit.hxx> +#endif +#ifndef _SV_SPINFLD_HXX +#include <vcl/spinfld.hxx> +#endif +#ifndef _SV_MSGBOX_HXX +#include <vcl/msgbox.hxx> +#endif +#ifndef _SV_TOOLBOX_HXX +#include <vcl/toolbox.hxx> +#endif +#ifndef _SV_LSTBOX_HXX +#include <vcl/lstbox.hxx> +#endif +#ifndef _SV_SOUND_HXX +#include <vcl/sound.hxx> +#endif +#ifndef _SV_COMBOBOX_HXX +#include <vcl/combobox.hxx> +#endif +#ifndef _SV_FLOATWIN_HXX +#include <vcl/floatwin.hxx> +#endif +#include "statemnt.hxx" +#include "retstrm.hxx" +#include "rcontrol.hxx" + +class MacroRecorder +{ +private: + Window* GetParentWithID( Window* pThis ); + + Link aEventListenerHdl; + DECL_LINK( EventListener, VclSimpleEvent* ); + + Window* pLastWin; + Window* pEditModify; + String aEditModifyString; + + ToolBox *pActionParent; // toolbox from which a tearoff or OpenMenu might happen + + // record keys + String aKeyString; + ULONG aKeyUniqueID; // has to be remembert seperately since Window might be gone when needed + Window* pKeyWin; + BOOL bKeyFollowFocus; + + AutoTimer aHookRefresh; + void AddEventHooks(); + void RemoveEventHooks(); + DECL_LINK( HookRefreskHdl, void* ); + +public: + + MacroRecorder(); + ~MacroRecorder(); +}; + + +MacroRecorder::MacroRecorder() +: pLastWin( NULL ) +, pEditModify( NULL ) +, pActionParent( NULL ) +, aKeyUniqueID( 0 ) +, pKeyWin( NULL ) +, bKeyFollowFocus( FALSE ) +{ + aHookRefresh.SetTimeout( 500 ); + aHookRefresh.SetTimeoutHdl( LINK( this, MacroRecorder, HookRefreskHdl) ); + aHookRefresh.Start(); + aEventListenerHdl = LINK( this, MacroRecorder, EventListener ); + AddEventHooks(); +} + +MacroRecorder::~MacroRecorder() +{ + aHookRefresh.Stop(); + RemoveEventHooks(); +} + +void MacroRecorder::AddEventHooks() +{ + Window *pTopLevel = Application::GetFirstTopLevelWindow(); + while ( pTopLevel ) + { + Window *pParent = pTopLevel; + while ( pParent->GetParent() ) + pParent = pParent->GetParent(); + + pParent->RemoveChildEventListener( aEventListenerHdl ); // might be instrumented already + pParent->AddChildEventListener( aEventListenerHdl ); + + pTopLevel = Application::GetNextTopLevelWindow( pTopLevel ); + } +} + +void MacroRecorder::RemoveEventHooks() +{ + Window *pTopLevel = Application::GetFirstTopLevelWindow(); + while ( pTopLevel ) + { + pTopLevel->RemoveChildEventListener( aEventListenerHdl ); + pTopLevel = Application::GetNextTopLevelWindow( pTopLevel ); + } +} + +IMPL_LINK( MacroRecorder, HookRefreskHdl, void*, EMPTYARG ) +{ + AddEventHooks(); + return 0; +} + + +Window* MacroRecorder::GetParentWithID( Window* pThis ) +{ + Window *pOverlap = pThis->GetWindow( WINDOW_OVERLAP ); + while ( pOverlap != pThis && pThis->GetUniqueOrHelpId() == 0 && pThis->GET_REAL_PARENT() ) + pThis = pThis->GET_REAL_PARENT(); + return pThis; +} + +IMPL_LINK( MacroRecorder, EventListener, VclSimpleEvent*, pEvent ) +{ + BOOL bSendData = FALSE; + + if ( pEvent->ISA( VclWindowEvent ) ) + { + VclWindowEvent* pWinEvent = ( VclWindowEvent* ) pEvent; + Window* pWin = pWinEvent->GetWindow(); + ULONG nEventID = pWinEvent->GetId(); +#ifdef DEBUG + if ( nEventID >= 1001 && nEventID != VCLEVENT_WINDOW_KEYUP ) + nEventID = pWinEvent->GetId(); // Just something to set a breakpoint + else + return 0; +#endif + +// check for different action after collecting keys + // send if there_is_something_to_send + // and eather event_is_not_of_interest + // or ( new_window and new_window_is_interesting ) ( ignore interesting events to uninteresting window ) + + if ( aKeyString.Len() + && ( ( nEventID != VCLEVENT_WINDOW_KEYINPUT && nEventID != VCLEVENT_WINDOW_MOUSEMOVE ) + || ( pKeyWin != pWin + && ( pWin->GetType() == WINDOW_CONTROL || pWin->GetType() == WINDOW_WINDOW ) + ) + ) + ) + { + // we cannot access pKeyWin since it might have dissapeared + if ( bKeyFollowFocus ) + StatementList::pRet->GenReturn( RET_MacroRecorder, aKeyUniqueID, (USHORT)M_TypeKeys, aKeyString, bKeyFollowFocus ); + else + StatementList::pRet->GenReturn( RET_MacroRecorder, aKeyUniqueID, (USHORT)M_TypeKeys, aKeyString ); + bSendData = TRUE; + // cleanup + aKeyString.Erase(); + pKeyWin = NULL; + bKeyFollowFocus = FALSE; + } + + switch ( pWin->GetType() ) + { + case WINDOW_TABPAGE: + switch( nEventID ) + { + case VCLEVENT_WINDOW_ACTIVATE: + StatementList::pRet->GenReturn( RET_MacroRecorder, 0, (USHORT)(M_SetPage|M_RET_NUM_CONTROL), pWin->GetUniqueOrHelpId() ); + bSendData = TRUE; + break; + } + break; + case WINDOW_RADIOBUTTON: + case WINDOW_IMAGERADIOBUTTON: + switch( nEventID ) + { + case VCLEVENT_BUTTON_CLICK: // VCLEVENT_RADIOBUTTON_TOGGLE + { + if ( ((RadioButton*)pWin)->IsChecked() ) + { + StatementList::pRet->GenReturn( RET_MacroRecorder, pWin->GetUniqueOrHelpId(), (USHORT)M_Check ); + bSendData = TRUE; + } + } + break; + } + break; + case WINDOW_CHECKBOX: + case WINDOW_TRISTATEBOX: + switch( nEventID ) + { + case VCLEVENT_BUTTON_CLICK: //VCLEVENT_CHECKBOX_TOGGLE: + { + USHORT nMethod; + switch ( ((TriStateBox*)pWin)->GetState() ) + { + case STATE_CHECK: nMethod = M_Check; break; + case STATE_NOCHECK: nMethod = M_UnCheck; break; + case STATE_DONTKNOW: nMethod = M_TriState; break; + } + StatementList::pRet->GenReturn( RET_MacroRecorder, pWin->GetUniqueOrHelpId(), nMethod ); + bSendData = TRUE; + } + break; + } + break; + case WINDOW_EDIT: + case WINDOW_MULTILINEEDIT: + switch( nEventID ) + { + case VCLEVENT_EDIT_MODIFY: + pEditModify = pWin; + aEditModifyString = ((Edit*)pWin)->GetText(); + break; + } + break; + case WINDOW_MULTILISTBOX: + switch( nEventID ) + { + case VCLEVENT_LISTBOX_SELECT: + Sound::Beep(); + } + case WINDOW_LISTBOX: + switch( nEventID ) + { +// case VCLEVENT_LISTBOX_DOUBLECLICK: + case VCLEVENT_LISTBOX_SELECT: + StatementList::pRet->GenReturn( RET_MacroRecorder, pWin->GetUniqueOrHelpId(), (USHORT)M_Select, ULONG( ((ListBox*)pWin)->GetSelectEntryPos() +1 ) ); + bSendData = TRUE; + break; + } + break; + case WINDOW_COMBOBOX: + case WINDOW_PATTERNBOX: + case WINDOW_NUMERICBOX: + case WINDOW_METRICBOX: + case WINDOW_CURRENCYBOX: + case WINDOW_DATEBOX: + case WINDOW_TIMEBOX: + switch( nEventID ) + { + case VCLEVENT_EDIT_MODIFY: + pEditModify = pWin; + aEditModifyString = ((Edit*)pWin)->GetText(); + break; + case VCLEVENT_COMBOBOX_SELECT: + { + pEditModify = NULL; + aEditModifyString.Erase(); + + USHORT nPos = ((ComboBox*)pWin)->GetEntryPos(((ComboBox*)pWin)->GetText()); + if ( nPos == COMBOBOX_ENTRY_NOTFOUND ) + Sound::Beep(); + else + { + StatementList::pRet->GenReturn( RET_MacroRecorder, pWin->GetUniqueOrHelpId(), (USHORT)M_Select, (ULONG) nPos+1 ); + bSendData = TRUE; + } + } + } + break; + case WINDOW_PUSHBUTTON: + case WINDOW_OKBUTTON: + case WINDOW_CANCELBUTTON: + case WINDOW_IMAGEBUTTON: + case WINDOW_MOREBUTTON: + case WINDOW_HELPBUTTON: + switch( nEventID ) + { + case VCLEVENT_BUTTON_CLICK: + Window* pParent = pWin->GetParent(); + if ( pParent->IsDialog() && pWin->GetUniqueOrHelpId() == 0 ) + { + switch ( pParent->GetType() ) + { + case WINDOW_MESSBOX: + case WINDOW_INFOBOX: + case WINDOW_WARNINGBOX: + case WINDOW_ERRORBOX: + case WINDOW_QUERYBOX: + case WINDOW_BUTTONDIALOG: + { + USHORT nMethod; + ButtonDialog* pBD = (ButtonDialog*)pParent; + + // we have to find the current Button ID ourselves since it is not generated at this point :-( + USHORT nCurrentButtonId = 99999; // Some wild value to wak up people + int i; + for ( i = 0; i < pBD->GetButtonCount() ; i++ ) + { + if ( pBD->GetPushButton( pBD->GetButtonId(i) ) == pWin ) + { + nCurrentButtonId = pBD->GetButtonId(i); + break; + } + } + + switch ( nCurrentButtonId ) + { + case BUTTONID_OK: nMethod = M_OK; break; + case BUTTONID_CANCEL: nMethod = M_Cancel; break; + case BUTTONID_YES: nMethod = M_Yes; break; + case BUTTONID_NO: nMethod = M_No; break; + case BUTTONID_RETRY: nMethod = M_Repeat; break; + case BUTTONID_HELP: nMethod = M_Help; break; + default: nMethod = M_Click; + } + if ( nMethod != M_Click ) + StatementList::pRet->GenReturn( RET_MacroRecorder, (USHORT)0, nMethod ); + else + StatementList::pRet->GenReturn( RET_MacroRecorder, (USHORT)0, nMethod, (ULONG)nCurrentButtonId ); + bSendData = TRUE; + } + break; + default: + { + USHORT nMethod; + switch ( pWin->GetType() ) + { + case WINDOW_OKBUTTON: nMethod = M_OK; break; + case WINDOW_CANCELBUTTON: nMethod = M_Cancel; break; + case WINDOW_HELPBUTTON: nMethod = M_Help; break; + default: Sound::Beep(); + } + StatementList::pRet->GenReturn( RET_MacroRecorder, pParent->GetUniqueOrHelpId(), nMethod ); + bSendData = TRUE; + } + break; + } + } + if ( !bSendData && pWin->GetUniqueOrHelpId() ) + { + StatementList::pRet->GenReturn( RET_MacroRecorder, pWin->GetUniqueOrHelpId(), (USHORT)M_Click ); + bSendData = TRUE; + } + } + break; +/* case C_MoreButton: + switch( nEventID ) + { + case M_IsOpen : + pRet->GenReturn ( RET_Value, nUId, ((MoreButton*)pControl)->GetState()); + break; + case M_Click : + ((MoreButton*)pControl)->Click(); + break; + case M_Open : + ((MoreButton*)pControl)->SetState(TRUE); + break; + case M_Close : + ((MoreButton*)pControl)->SetState(FALSE); + break; + default: + ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "MoreButton" ) ); + break; + } + break;*/ + case WINDOW_SPINFIELD: + case WINDOW_PATTERNFIELD: + case WINDOW_NUMERICFIELD: + case WINDOW_METRICFIELD: + case WINDOW_CURRENCYFIELD: + case WINDOW_DATEFIELD: + case WINDOW_TIMEFIELD: + switch( nEventID ) + { + case VCLEVENT_SPINFIELD_UP: + case VCLEVENT_SPINFIELD_DOWN: + case VCLEVENT_SPINFIELD_FIRST: + case VCLEVENT_SPINFIELD_LAST: + { + pEditModify = NULL; + aEditModifyString.Erase(); + + USHORT nMethod; + switch ( nEventID ) + { + case VCLEVENT_SPINFIELD_UP: nMethod = M_More; break; + case VCLEVENT_SPINFIELD_DOWN: nMethod = M_Less; break; + case VCLEVENT_SPINFIELD_FIRST: nMethod = M_ToMin; break; + case VCLEVENT_SPINFIELD_LAST: nMethod = M_ToMax; break; + } + StatementList::pRet->GenReturn( RET_MacroRecorder, pWin->GetUniqueOrHelpId(), nMethod ); + bSendData = TRUE; + } + break; + case VCLEVENT_EDIT_MODIFY: + pEditModify = pWin; + aEditModifyString = ((SpinField*)pWin)->GetText(); + break; + } + break; + + case WINDOW_MENUBUTTON: + switch( nEventID ) + { + case VCLEVENT_BUTTON_CLICK: + StatementList::pRet->GenReturn( RET_MacroRecorder, pWin->GetUniqueOrHelpId(), (USHORT)M_Click ); + bSendData = TRUE; + break; +/* Keyevent or Timeout + case M_Open : + { + MouseEvent aMEvnt; + Point aPt( pControl->GetSizePixel().Width() / 2, pControl->GetSizePixel().Height() / 2 ); + aMEvnt = MouseEvent( aPt,1,MOUSE_SIMPLECLICK,MOUSE_LEFT ); + ImplMouseButtonDown( pControl, aMEvnt ); + + ULONG nStart = Time::GetSystemTicks(); + ULONG nDelay = pControl->GetSettings().GetMouseSettings().GetActionDelay(); + while ( ( Time::GetSystemTicks() - nStart ) < nDelay + 100 ) + SafeReschedule(); + + ImplMouseButtonUp ( pControl, aMEvnt ); + } + break;*/ + } + break; + case WINDOW_TOOLBOX: + { + ToolBox *pTB = ((ToolBox*)pWin); + switch( nEventID ) + { + case VCLEVENT_TOOLBOX_SELECT: + { // a Button has been clicked + // so this cannot be a tearoff or OpenMenu anymore + pActionParent = NULL; + // compare to 1 for floating ToolBoxes + if ( ( pWin->GetUniqueOrHelpId() == 0 || pWin->GetUniqueOrHelpId() == 1 ) ) + // generate direct Button access + StatementList::pRet->GenReturn( RET_MacroRecorder, pTB->GetHelpId( pTB->GetCurItemId() ), (USHORT)(M_Click) ); + else + // access via Toolbox + StatementList::pRet->GenReturn( RET_MacroRecorder, pTB->GetUniqueOrHelpId(), (USHORT)(M_Click|M_RET_NUM_CONTROL), pTB->GetHelpId( pTB->GetCurItemId() ) ); + bSendData = TRUE; + } + break; + case VCLEVENT_TOOLBOX_CLICK: + pActionParent = pTB; + break; + case VCLEVENT_WINDOW_SHOW: + if ( pActionParent ) + { // a new toolbox opens up, might be a tearoff + if ( pActionParent != pWin ) + { // it IS a tearoff not an undock + // compare to 1 for floating ToolBoxes + if ( ( pActionParent->GetUniqueOrHelpId() == 0 || pActionParent->GetUniqueOrHelpId() == 1 ) ) + // generate direct Button access + StatementList::pRet->GenReturn( RET_MacroRecorder, pActionParent->GetHelpId( pActionParent->GetCurItemId() ), (USHORT)(M_TearOff) ); + else + // access via Toolbox + StatementList::pRet->GenReturn( RET_MacroRecorder, pActionParent->GetUniqueOrHelpId(), (USHORT)(M_TearOff|M_RET_NUM_CONTROL), pActionParent->GetHelpId( pActionParent->GetCurItemId() ) ); + bSendData = TRUE; + } + pActionParent = NULL; + } + break; + case VCLEVENT_TOOLBOX_DEACTIVATE: + pActionParent = NULL; + break; + } + } + break; +/* ToolBox *pTB = ((ToolBox*)pControl); + if ( pTB->GetUniqueOrHelpId() != nUId ) // Also Button auf der ToolBox gefunden + { + if ( nParams == PARAM_NONE ) + { // Wir fälschen einen Parameter + nParams = PARAM_USHORT_1; + nNr1 = nUId; + } + else + ReportError( nUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) ); + } + +#define FIND_HELP\ +{\ + if( nParams == PARAM_USHORT_1 )\ + nLNr1 = nNr1;\ + for ( nNr1 = 0; nNr1 < pTB->GetItemCount() && nLNr1 != pTB->GetHelpId(pTB->GetItemId(nNr1)) ; nNr1++ ) {}\ + bBool1 = nLNr1 == pTB->GetHelpId(pTB->GetItemId(nNr1));\ + if ( !bBool1 )\ + ReportError( nUId, GEN_RES_STR1( S_HELPID_ON_TOOLBOX_NOT_FOUND, MethodString( nMethodId ) ) );\ + else\ + {\ + if ( !pTB->IsItemEnabled( pTB->GetItemId(nNr1) ) && nMethodId != _M_IsEnabled )\ + {\ + ReportError( nUId, GEN_RES_STR1( S_BUTTON_DISABLED_ON_TOOLBOX, MethodString( nMethodId ) ) );\ + bBool1 = FALSE;\ + }\ + else if ( !pTB->IsItemVisible( pTB->GetItemId(nNr1) ) )\ + {\ + ReportError( nUId, GEN_RES_STR1( S_BUTTON_HIDDEN_ON_TOOLBOX, MethodString( nMethodId ) ) );\ + bBool1 = FALSE;\ + }\ + else\ + {\ + if ( pTB->GetItemRect(pTB->GetItemId(nNr1)).IsEmpty() )\ + {\ + USHORT nLine = pTB->GetCurLine();\ + do\ + {\ + pTB->ShowLine( FALSE );\ + for ( int i = 1 ; i < 30 ; i++ )\ + SafeReschedule();\ + }\ + while ( pTB->GetCurLine() != nLine && pTB->GetItemRect(pTB->GetItemId(nNr1)).IsEmpty() );\ + pTB->Invalidate( pTB->GetScrollRect() );\ + }\ + if ( pTB->GetItemRect(pTB->GetItemId(nNr1)).IsEmpty() )\ + {\ + ReportError( nUId, GEN_RES_STR1( S_CANNOT_MAKE_BUTTON_VISIBLE_IN_TOOLBOX, MethodString( nMethodId ) ) );\ + bBool1 = FALSE;\ + }\ + }\ + }\ +}\ + + switch( nEventID ) + { + case M_SetNextToolBox : + if ( (nParams & PARAM_STR_1) ) + pTB->SetNextToolBox( aString1 ); + else + pTB->SetNextToolBox( pTB->GetNextToolBox() ); + pTB->NextToolBox(); + break; + case M_GetNextToolBox : + pRet->GenReturn ( RET_Value, nUId, (String)pTB->GetNextToolBox()); + break; + default: + ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "ToolBox" ) ); + break; + } + } + break; +*/ + case WINDOW_CONTROL: + case WINDOW_WINDOW: + switch( nEventID ) + { + case VCLEVENT_WINDOW_COMMAND: + break; + case VCLEVENT_WINDOW_KEYINPUT: + { + const KeyEvent *pKeyEvent = ((KeyEvent*)pWinEvent->GetData()); + const KeyCode aKeyCode = pKeyEvent->GetKeyCode(); + if ( pKeyEvent ) + { + if ( ( !aKeyCode.IsMod1() && !aKeyCode.IsMod2() ) && + (( aKeyCode.GetGroup() == KEYGROUP_NUM) || + ( aKeyCode.GetGroup() == KEYGROUP_ALPHA) || + ( aKeyCode.GetCode() == KEY_SPACE) || + ( aKeyCode.GetCode() == KEY_ADD) || + ( aKeyCode.GetCode() == KEY_SUBTRACT) || + ( aKeyCode.GetCode() == KEY_MULTIPLY) || + ( aKeyCode.GetCode() == KEY_DIVIDE) || + ( aKeyCode.GetCode() == KEY_POINT) || + ( aKeyCode.GetCode() == KEY_COMMA) || + ( aKeyCode.GetCode() == KEY_EQUAL) || + ( aKeyCode.GetCode() == 0) ) ) + { + DBG_ASSERT( pKeyEvent->GetCharCode(), "no charcode found" ) + aKeyString += pKeyEvent->GetCharCode(); + } + else + { // not a regular key, transfer KeyCode + aKeyString += 1; // mask it + // extra for '>' which is coded as <SHIFT LESS> + if ( pKeyEvent->GetCharCode() == '>' ) + aKeyString += ( KEY_GREATER | aKeyCode.GetAllModifier() & ~KEY_SHIFT ); + else + aKeyString += ( aKeyCode.GetCode() | aKeyCode.GetAllModifier() ); + } + pKeyWin = pWin; + Window *pIdWin = pWin; + while ( pIdWin->GetParent() && !pIdWin->GetUniqueOrHelpId() ) + { + pIdWin = pIdWin->GetParent(); + bKeyFollowFocus = TRUE; + } + aKeyUniqueID = pIdWin->GetUniqueOrHelpId(); + } + } + break; + + case VCLEVENT_WINDOW_MOUSEMOVE: + case VCLEVENT_WINDOW_MOUSEBUTTONDOWN: + case VCLEVENT_WINDOW_MOUSEBUTTONUP: + { + } + break; + + + } + break; + case WINDOW_DOCKINGWINDOW: +// switch( nEventID ) + { +// case 1 .. 0xffff: + DBG_TRACE3( "TT_VCLMessage %u %u %X",nEventID, pWin->GetType(), pWin ); + BOOL bx = ((DockingWindow*)pWin)->IsFloatingMode(); +// break; +/* case M_Dock : + if ( ((DockingWindow*)pControl)->IsFloatingMode() ) + ((DockingWindow*)pControl)->SetFloatingMode(FALSE); + else + ReportError( nUId, GEN_RES_STR1( S_ALLOWED_ONLY_IN_FLOATING_MODE, MethodString( nMethodId ) ) ); + break; + case M_Undock : + if ( !((DockingWindow*)pControl)->IsFloatingMode() ) + ((DockingWindow*)pControl)->SetFloatingMode(TRUE); + else + ReportError( nUId, GEN_RES_STR1( S_ALLOWED_ONLY_IN_FLOATING_MODE, MethodString( nMethodId ) ) ); + break; + case M_IsDocked : + pRet->GenReturn ( RET_Value, nUId, (BOOL) !((DockingWindow*)pControl)->IsFloatingMode()); + break; + case M_Close: + //nWindowWaitUId = nUId; + DBG_ASSERT( nUId == pControl->GetUniqueOrHelpId(), "nUID != UniqueOrHelpId"); + SET_WINP_CLOSING(pControl); + ((DockingWindow*)pControl)->Close(); + break; + case M_Size: + case M_Move: + case M_IsMax : + case M_Minimize : + case M_Maximize : + if ( ((DockingWindow*)pControl)->IsFloatingMode() ) + { + pControl = ((DockingWindow*)pControl)->GetFloatingWindow(); + goto FloatWin; + } + else + ReportError( nUId, GEN_RES_STR1( S_ALLOWED_ONLY_IN_DOCKING_MODE, MethodString( nMethodId ) ) ); + break; + case M_Help: // Alles was unten weiterbehandelt werden soll + goto MoreDialog; + + default: + ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "DockingWindow" ) ); + break;*/ + } + break; + + + + + + + case WINDOW_FLOATINGWINDOW: + { + DBG_TRACE3( "TT_VCLMessage %u %u %X",nEventID, pWin->GetType(), pWin ); + FloatingWindow *pFW = ((FloatingWindow*)pWin); + switch( nEventID ) + { +/* +// M_OpenMenu an einem ToolboxButton + case VCLEVENT_WINDOW_SHOW: + if ( pActionParent ) + { // a new FloatingWindow opens up, so we assume an OpenMenu + // compare to 1 for floating ToolBoxes + if ( ( pActionParent->GetUniqueOrHelpId() == 0 || pActionParent->GetUniqueOrHelpId() == 1 ) ) + // generate direct Button access + StatementList::pRet->GenReturn( RET_MacroRecorder, pActionParent->GetHelpId( pActionParent->GetCurItemId() ), (USHORT)(M_OpenMenu) ); + else + // access via Toolbox + StatementList::pRet->GenReturn( RET_MacroRecorder, pActionParent->GetUniqueOrHelpId(), (USHORT)(M_OpenMenu|M_RET_NUM_CONTROL), pActionParent->GetHelpId( pActionParent->GetCurItemId() ) ); + bSendData = TRUE; + } + break; + */ + } + } + break; +/* + case M_AnimateMouse : + AnimateMouse( pControl, MitteOben); + break; + case M_IsMax : + pRet->GenReturn ( RET_Value, nUId, (BOOL)!((FloatingWindow*)pControl)->IsRollUp()); + break; + case M_Minimize : + ((FloatingWindow*)pControl)->RollUp(); + break; + case M_Maximize : + ((FloatingWindow*)pControl)->RollDown(); + break; + case M_Size: + { + if ( pControl->GetStyle() & WB_SIZEABLE ) + { + pControl->SetSizePixel(Size(nNr1,nNr2)); + pControl->Resize(); + } + else + ReportError( nUId, GEN_RES_STR1( S_SIZE_NOT_CHANGEABLE, MethodString( nMethodId ) ) ); + break; + } + case M_Close: + DBG_ASSERT( nUId == pControl->GetUniqueOrHelpId(), "nUID != UniqueOrHelpId"); + SET_WINP_CLOSING(pControl); + ((FloatingWindow*)pControl)->Close(); + break; + case M_Help: // Alles was unten weiterbehandelt werden soll + case M_Move: + goto MoreDialog; + default: + ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "FloatingWin" ) ); + break; + } + break;*/ + + + + + + + + +/* + case C_ModelessDlg: + case C_Dlg: + case C_TabDlg: + MoreDialog: + switch( nEventID ) + { + + // (Rect GetRect) + + case M_AnimateMouse : + AnimateMouse( pControl, MitteOben); + break; + case M_Close: + DBG_ASSERT( nUId == pControl->GetUniqueOrHelpId(), "nUID != UniqueOrHelpId"); + SET_WINP_CLOSING(pControl); + ((SystemWindow*)pControl)->Close(); + break; + case M_Move: + { + pControl->SetPosPixel(Point(nNr1,nNr2)); + break; + } + default: + ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "Dialog" ) ); + break; + } + break;*/ + + + + + + + + + + + + + +/* + case C_WorkWin: + switch( nEventID ) + { + case M_Close: + DBG_ASSERT( nUId == pControl->GetUniqueOrHelpId(), "nUID != UniqueOrHelpId"); + SET_WINP_CLOSING(pControl); + ((WorkWindow*)pControl)->Close(); + break; + case M_Size: + case M_Move: + goto FloatWin; + break; + case M_Help: // Alles was unten weiterbehandelt werden soll + goto MoreDialog; + default: + ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "WorkWindow" ) ); + break; + } + break; + */ + + +/* case C_TabPage: + switch( nEventID ) + { + } + break;*/ + + + + + + + + + + + + + +/* + case C_MessBox: + case C_InfoBox: + case C_WarningBox: + case C_ErrorBox: + case C_QueryBox: + { + BOOL bDone = TRUE; + MessBox* pMB = (MessBox*)pControl; + switch( nEventID ) + { +#if SUPD > 631 + case M_GetCheckBoxText: + pRet->GenReturn ( RET_Value, nUId, pMB->GetCheckBoxText() ); + break; + case M_IsChecked : + pRet->GenReturn ( RET_Value, nUId, BOOL( pMB->GetCheckBoxState() == STATE_CHECK) ); + break; + case M_GetState : + pRet->GenReturn ( RET_Value, nUId, ULONG( pMB->GetCheckBoxState() )); + break; + case M_Check : + pMB->SetCheckBoxState( STATE_CHECK ); + break; + case M_UnCheck : + pMB->SetCheckBoxState( STATE_NOCHECK ); + break; +#endif + case M_GetText : + pRet->GenReturn ( RET_Value, nUId, pMB->GetMessText()); + break; + + default: + bDone = FALSE; + break; + } + if ( bDone ) + break; // break the case here else continue at C_ButtonDialog + } + case C_ButtonDialog: + { + ButtonDialog* pBD = (ButtonDialog*)pControl; +#ifdef DEBUG + m_pDbgWin->AddText( "Working MessBox: " ); + if (pControl->IsVisible()) + m_pDbgWin->AddText("*(Visible)\n"); + else + m_pDbgWin->AddText("*(nicht Visible)\n"); +#endif + switch( nEventID ) + { + case M_GetText : + pRet->GenReturn ( RET_Value, nUId, pControl->GetText()); + break; + case M_Click: + if ( nParams & PARAM_USHORT_1 ) + { + if ( pBD->GetPushButton( nNr1 ) ) + { + if ( nNr1 != BUTTONID_HELP ) + { + SET_WINP_CLOSING(pControl); + } + pBD->GetPushButton( nNr1 )->Click(); + } + else + ReportError( nUId, GEN_RES_STR2( S_NO_DEFAULT_BUTTON, UniString::CreateFromInt32( nNr1 ), MethodString( nMethodId ) ) ); + } + else + ReportError( nUId, GEN_RES_STR1( S_BUTTONID_REQUIRED, MethodString( nMethodId ) ) ); + break; + case M_GetButtonCount : + pRet->GenReturn ( RET_Value, nUId, ULONG(pBD->GetButtonCount())); + break; + case M_GetButtonId : + if ( ValueOK(nUId, MethodString( nMethodId ),nNr1,pBD->GetButtonCount()) ) + pRet->GenReturn ( RET_Value, nUId, ULONG(pBD->GetButtonId(nNr1-1))); + break; + default: + ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "MessageBox" ) ); + break; + } + break; + + + */ + + + + + + + + + + + + + + + + + + + + + + + + + + + } + + + switch( nEventID ) + { + case VCLEVENT_CONTROL_LOSEFOCUS: + if ( pEditModify == pWin ) + { + StatementList::pRet->GenReturn( RET_MacroRecorder, pWin->GetUniqueOrHelpId(), M_SetText, aEditModifyString ); + bSendData = TRUE; + pEditModify = NULL; + aEditModifyString.Erase(); //could be somewhat lengthy + } + break; + } + + pLastWin = pWin; + + } // if + else if ( pEvent->ISA( VclMenuEvent ) ) + { + VclMenuEvent* pMenuEvent = ( VclMenuEvent* ) pEvent; + } + + + if ( bSendData ) + new StatementFlow( NULL, F_EndCommandBlock ); // Kommando zum Senden erzeugen und in que eintragen + + return 0; +} + + +void StatementCommand::HandleMacroRecorder() +{ + static MacroRecorder *pMacroRecorder = NULL; + + if ( ! (nParams & PARAM_BOOL_1) ) + bBool1 = TRUE; + + if ( bBool1 ) + { + if ( !pMacroRecorder ) + pMacroRecorder = new MacroRecorder; + } + else + { + delete pMacroRecorder; + pMacroRecorder = NULL; + } +} + diff --git a/automation/source/server/retstrm.cxx b/automation/source/server/retstrm.cxx new file mode 100644 index 000000000000..6d384c0e19da --- /dev/null +++ b/automation/source/server/retstrm.cxx @@ -0,0 +1,143 @@ +/************************************************************************* + * + * $RCSfile: retstrm.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: mh $ $Date: 2002-11-18 15:28:24 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2002 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2002 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2002 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _STREAM_HXX //autogen +#include <tools/stream.hxx> +#endif + +#include "retstrm.hxx" +#include "rcontrol.hxx" +#include "svcommstream.hxx" + + +RetStream::RetStream() +{ + pSammel = new SvMemoryStream(); + pCommStream = new SvCommStream( pSammel ); +// SetCommStream( pCommStream ); +} + +RetStream::~RetStream() +{ + delete pCommStream; + delete pSammel; +} + +void RetStream::GenError ( ULONG nError, String aString ) +{ + CmdBaseStream::GenError ( nError, aString.GetBuffer(), aString.Len() ); +} + +void RetStream::GenReturn ( USHORT nRet, ULONG nUId, String aString ) +{ + CmdBaseStream::GenReturn ( nRet, nUId, aString.GetBuffer(), aString.Len() ); +} + +void RetStream::GenReturn ( USHORT nRet, ULONG nUId, SbxValue &aValue ) +{ + Write(USHORT(SIReturn)); + Write(nRet); + Write(nUId); + Write(USHORT(PARAM_SBXVALUE_1)); // Typ der folgenden Parameter + Write(aValue); +} + +void RetStream::GenReturn ( USHORT nRet, ULONG nUId, ULONG nNr, String aString, BOOL bBool ) +{ + CmdBaseStream::GenReturn ( nRet, nUId, nNr, aString.GetBuffer(), aString.Len(), bBool ); +} + +void RetStream::GenReturn( USHORT nRet, ULONG nUId, USHORT nMethod, String aString ) +{ + CmdBaseStream::GenReturn ( nRet, nUId, nMethod, aString.GetBuffer(), aString.Len() ); +} + +void RetStream::GenReturn( USHORT nRet, ULONG nUId, USHORT nMethod, String aString, BOOL bBool ) +{ + CmdBaseStream::GenReturn ( nRet, nUId, nMethod, aString.GetBuffer(), aString.Len(), bBool ); +} + + +void RetStream::Write( String aString ) +{ + CmdBaseStream::Write( aString.GetBuffer(), aString.Len() ); +} + +void RetStream::Write( SbxValue &aValue ) +{ + *pSammel << USHORT( BinSbxValue ); + aValue.Store( *pSammel ); +} + +SvStream* RetStream::GetStream() +{ + return pSammel; +} + +void RetStream::Reset () +{ + delete pCommStream; + delete pSammel; + pSammel = new SvMemoryStream(); + pCommStream = new SvCommStream( pSammel ); +// SetCommStream( pCommStream ); +} + diff --git a/automation/source/server/retstrm.hxx b/automation/source/server/retstrm.hxx new file mode 100644 index 000000000000..697a86e712d3 --- /dev/null +++ b/automation/source/server/retstrm.hxx @@ -0,0 +1,120 @@ +/************************************************************************* + * + * $RCSfile: retstrm.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: mh $ $Date: 2002-11-18 15:28:29 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2002 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2002 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2002 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _RETSTRM_HXX +#define _RETSTRM_HXX + +#ifndef _SBXVAR_HXX //autogen +#include <svtools/sbxvar.hxx> +#endif +#include "cmdbasestream.hxx" + +class SvStream; + +class RetStream: public CmdBaseStream +{ + +public: + RetStream(); + ~RetStream(); + +// CmdBaseStream::GenError; +// void GenError( comm_ULONG nError, const comm_UniChar* aString, comm_USHORT nLenInChars ){CmdBaseStream::GenError( nError, aString, nLenInChars );} +// new + void GenError( ULONG nError, String aString ); + +// CmdBaseStream::GenReturn; + void GenReturn( comm_USHORT nRet, comm_ULONG nNr ){CmdBaseStream::GenReturn( nRet, nNr );} + void GenReturn( comm_USHORT nRet, comm_ULONG nUId, comm_ULONG nNr ){CmdBaseStream::GenReturn( nRet, nUId, nNr );} +// void GenReturn( comm_USHORT nRet, comm_ULONG nUId, const comm_UniChar* aString, comm_USHORT nLenInChars ){CmdBaseStream::GenReturn( nRet, nUId, aString, nLenInChars );} + void GenReturn( comm_USHORT nRet, comm_ULONG nUId, comm_BOOL bBool ){CmdBaseStream::GenReturn( nRet, nUId, bBool );} +// void GenReturn( comm_USHORT nRet, comm_ULONG nUId, comm_ULONG nNr, const comm_UniChar* aString, comm_USHORT nLenInChars, comm_BOOL bBool ){CmdBaseStream::GenReturn( nRet, nUId, nNr, aString, nLenInChars, bBool );} +// MacroRecorder + void GenReturn( comm_USHORT nRet, comm_ULONG nUId, comm_USHORT nMethod ){CmdBaseStream::GenReturn( nRet, nUId, nMethod );} +// void GenReturn( comm_USHORT nRet, comm_ULONG nUId, comm_USHORT nMethod, const comm_UniChar* aString, comm_USHORT nLenInChars ){CmdBaseStream::GenReturn( nRet, nUId, nMethod, aString, nLenInChars );} +// void GenReturn( comm_USHORT nRet, comm_ULONG nUId, comm_USHORT nMethod, const comm_UniChar* aString, comm_USHORT nLenInChars, comm_BOOL bBool ){CmdBaseStream::GenReturn( nRet, nUId, nMethod, aString, nLenInChars, bBool );} + void GenReturn( comm_USHORT nRet, comm_ULONG nUId, comm_USHORT nMethod, comm_BOOL bBool ){CmdBaseStream::GenReturn( nRet, nUId, nMethod, bBool );} + void GenReturn( comm_USHORT nRet, comm_ULONG nUId, comm_USHORT nMethod, comm_ULONG nNr ){CmdBaseStream::GenReturn( nRet, nUId, nMethod, nNr );} + +// new + void GenReturn( USHORT nRet, ULONG nUId, String aString ); + void GenReturn( USHORT nRet, ULONG nUId, SbxValue &aValue ); + void GenReturn( USHORT nRet, ULONG nUId, ULONG nNr, String aString, BOOL bBool ); +// MacroRecorder + void GenReturn( USHORT nRet, ULONG nUId, USHORT nMethod, String aString ); + void GenReturn( USHORT nRet, ULONG nUId, USHORT nMethod, String aString, BOOL bBool ); + + void Reset(); + SvStream* GetStream(); + + +// CmdBaseStream::Write; + void Write( comm_USHORT nNr ){CmdBaseStream::Write( nNr );} + void Write( comm_ULONG nNr ){CmdBaseStream::Write( nNr );} +// void Write( const comm_UniChar* aString, comm_USHORT nLenInChars ){CmdBaseStream::Write( aString, nLenInChars );} + void Write( comm_BOOL bBool ){CmdBaseStream::Write( bBool );} +// new + void Write( String aString ); + void Write( SbxValue &aValue ); + + SvStream *pSammel; +}; + +#endif diff --git a/automation/source/server/scmdstrm.cxx b/automation/source/server/scmdstrm.cxx new file mode 100644 index 000000000000..5adfef89e145 --- /dev/null +++ b/automation/source/server/scmdstrm.cxx @@ -0,0 +1,245 @@ +/************************************************************************* + * + * $RCSfile: scmdstrm.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: mh $ $Date: 2002-11-18 15:28:35 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2002 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2002 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2002 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _SFXINTITEM_HXX //autogen +#include <svtools/intitem.hxx> +#endif +#ifndef _SFXSTRITEM_HXX //autogen +#include <svtools/stritem.hxx> +#endif +#ifndef _SFXENUMITEM_HXX //autogen +#include <svtools/eitem.hxx> +#endif + +#ifndef _SCMDSTRM_HXX +#include "scmdstrm.hxx" +#endif +#include "svcommstream.hxx" +#include "rcontrol.hxx" + +#ifdef DEBUG +#ifndef _EDITWIN_HXX +#include "editwin.hxx" +#endif +#include "statemnt.hxx" +#endif + +SCmdStream::SCmdStream(SvStream *pIn) +{ + pSammel = pIn; + pCommStream = new SvCommStream( pSammel ); +// SetCommStream( pCommStream ); +} + +SCmdStream::~SCmdStream() +{ + delete pCommStream; +} + +void SCmdStream::Read (String &aString) +{ + comm_UniChar* pStr; + USHORT nLenInChars; + Read( pStr, nLenInChars ); + + aString = String( pStr, nLenInChars ); + delete [] pStr; +} + +void SCmdStream::Read ( SfxPoolItem *&pItem ) +{ + USHORT nType; + USHORT nId; + Read(nId); +#ifdef DEBUG + StatementList::m_pDbgWin->AddText( "Parameter: " ); + StatementList::m_pDbgWin->AddText( String::CreateFromInt32( nId ) ); + StatementList::m_pDbgWin->AddText( " " ); +#endif + Read( nType ); + switch (nType) + { + case BinUSHORT: + { + USHORT nNr; + Read (nNr ); + pItem = new SfxUInt16Item(nId,nNr); +#ifdef DEBUG + StatementList::m_pDbgWin->AddText( "USHORT:" ); + StatementList::m_pDbgWin->AddText( String::CreateFromInt32( nNr ) ); +#endif + } + break; + case BinULONG: + { + ULONG nNr; + Read (nNr ); + pItem = new SfxUInt32Item(nId,nNr); +#ifdef DEBUG + StatementList::m_pDbgWin->AddText( "ULONG:" ); + StatementList::m_pDbgWin->AddText( String::CreateFromInt64( nNr ) ); +#endif + } + break; + case BinString: + { + String aString; + Read (aString); + + pItem = new SfxStringItem(nId,aString); +#ifdef DEBUG + StatementList::m_pDbgWin->AddText( "String:" ); + StatementList::m_pDbgWin->AddText( aString ); +#endif + } + break; + case BinBool: + { + BOOL bBool; + Read (bBool); + pItem = new SfxBoolItem(nId,bBool); +#ifdef DEBUG + StatementList::m_pDbgWin->AddText( "BOOL:" ); + StatementList::m_pDbgWin->AddText( bBool ? "TRUE" : "FALSE" ); +#endif + } + break; + default: + DBG_ERROR1( "Ungültiger Typ im Stream:%hu", nType ); +#ifdef DEBUG + StatementList::m_pDbgWin->AddText( "Ungültiger Typ !!!! " ); +#endif + break; + } +#ifdef DEBUG + StatementList::m_pDbgWin->AddText( "\n" ); +#endif +} + +void SCmdStream::Read ( ::com::sun::star::beans::PropertyValue &rItem ) +{ + USHORT nType; + String aId; + Read(aId); + rItem.Name = rtl::OUString( aId ); +#ifdef DEBUG + StatementList::m_pDbgWin->AddText( "Parameter: " ); + StatementList::m_pDbgWin->AddText( aId ); + StatementList::m_pDbgWin->AddText( " " ); +#endif + nType = GetNextType(); + switch (nType) + { + case BinUSHORT: + { + USHORT nNr; + Read (nNr ); + rItem.Value <<= nNr; +#ifdef DEBUG + StatementList::m_pDbgWin->AddText( "USHORT:" ); + StatementList::m_pDbgWin->AddText( String::CreateFromInt32( nNr ) ); +#endif + } + break; + case BinULONG: + { + ULONG nNr; + Read (nNr ); + rItem.Value <<= nNr; +#ifdef DEBUG + StatementList::m_pDbgWin->AddText( "ULONG:" ); + StatementList::m_pDbgWin->AddText( String::CreateFromInt64( nNr ) ); +#endif + } + break; + case BinString: + { + String aString; + Read (aString); + rItem.Value <<= ::rtl::OUString( aString ); +#ifdef DEBUG + StatementList::m_pDbgWin->AddText( "String:" ); + StatementList::m_pDbgWin->AddText( aString ); +#endif + } + break; + case BinBool: + { + BOOL bBool; + Read (bBool); + rItem.Value <<= bBool; +#ifdef DEBUG + StatementList::m_pDbgWin->AddText( "BOOL:" ); + StatementList::m_pDbgWin->AddText( bBool ? "TRUE" : "FALSE" ); +#endif + } + break; + default: + DBG_ERROR1( "Ungültiger Typ im Stream:%hu", nType ); +#ifdef DEBUG + StatementList::m_pDbgWin->AddText( "Ungültiger Typ !!!! " ); +#endif + break; + } +#ifdef DEBUG + StatementList::m_pDbgWin->AddText( "\n" ); +#endif +} + diff --git a/automation/source/server/scmdstrm.hxx b/automation/source/server/scmdstrm.hxx new file mode 100644 index 000000000000..657b79d7b8cf --- /dev/null +++ b/automation/source/server/scmdstrm.hxx @@ -0,0 +1,97 @@ +/************************************************************************* + * + * $RCSfile: scmdstrm.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: mh $ $Date: 2002-11-18 15:28:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2002 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2002 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2002 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _SCMDSTRM_HXX +#define _SCMDSTRM_HXX + +#ifndef _SOLAR_H +#include <tools/solar.h> +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_ +#include <com/sun/star/beans/PropertyValue.hpp> +#endif + +#include "cmdbasestream.hxx" + +class SvStream; +class SfxPoolItem; +class String; +class ICommStream; + +class SCmdStream: public CmdBaseStream +{ + SvStream *pSammel; + +public: + SCmdStream( SvStream *pIn ); + ~SCmdStream(); + +// CmdBaseStream::Read; + void Read ( comm_USHORT &nNr ){CmdBaseStream::Read ( nNr );} + void Read ( comm_ULONG &nNr ){CmdBaseStream::Read ( nNr );} + void Read ( comm_UniChar* &aString, comm_USHORT &nLenInChars ){CmdBaseStream::Read ( aString, nLenInChars );} + void Read ( comm_BOOL &bBool ){CmdBaseStream::Read ( bBool );} +// new + void Read ( String &aString ); + void Read ( SfxPoolItem *&pItem ); + void Read ( ::com::sun::star::beans::PropertyValue &rItem ); +}; + +#endif diff --git a/automation/source/server/server.cxx b/automation/source/server/server.cxx new file mode 100644 index 000000000000..b2f79ee52f8d --- /dev/null +++ b/automation/source/server/server.cxx @@ -0,0 +1,985 @@ +/************************************************************************* + * + * $RCSfile: server.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: mh $ $Date: 2002-11-18 15:28:47 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2002 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2002 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2002 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifdef DEBUG + #if defined(WNT) || defined(WNT) +// #define CPP_EXCEPTIONS + #endif +#else + #if defined(WNT) || defined(WNT) + #define CPP_EXCEPTIONS + #endif +#endif + +#define NO_JPEG + +#ifndef NO_JPEG +#include <svtools/jpeg.hxx> +#endif +#ifndef _SV_TIMER_HXX +#include <vcl/timer.hxx> +#endif + +#ifndef _SV_WRKWIN_HXX +#include <vcl/wrkwin.hxx> +#endif +#ifndef _OSL_DIAGNOSE_H_ //handmade +#include <osl/diagnose.h> +#endif +#ifndef _OSL_MUTEX_HXX_ +#include <osl/mutex.hxx> +#endif + +#ifndef _DIALOG_HXX //autogen +#include <vcl/dialog.hxx> +#endif +#ifndef _STREAM_HXX //autogen +#include <tools/stream.hxx> +#endif + +#ifndef _SV_CONFIG_HXX //autogen +#include <vcl/config.hxx> +#endif +#include <vos/socket.hxx> + +#if 1 +#ifndef _SVTOOLS_TTPROPS_HXX // handmade +#include <svtools/ttprops.hxx> +#endif +#ifndef _BASIC_TTSTRHLP_HXX +#include <basic/ttstrhlp.hxx> +#endif +#ifndef _SFXSTRITEM_HXX //autogen +#include <svtools/stritem.hxx> +#endif +#ifndef _SVTOOLS_STRINGTRANSFER_HXX_ +#include <svtools/stringtransfer.hxx> +#endif +#ifndef _SV_SOUND_HXX //autogen +#include <vcl/sound.hxx> +#endif +#include "testtool.hrc" +#ifndef _SV_BITMAP_HXX //autogen +#include <vcl/bitmap.hxx> +#endif +// Hat keinen Includeschutz +#include <svtools/svtdata.hxx> +//#ifndef _DTRANS_HXX //autogen +//#include <so2/dtrans.hxx> +//#endif +#endif // 1 + +#ifndef _RTL_TEXTENC_H +#include <rtl/textenc.h> +#endif +#ifndef _RTL_URI_H_ +#include <rtl/uri.h> +#endif +#ifndef _RTL_URI_HXX_ +#include <rtl/uri.hxx> +#endif + +#ifndef _STATEMNT_HXX +#include "statemnt.hxx" +#endif +#ifndef _SCMDSTRM_HXX +#include "scmdstrm.hxx" +#endif +#include "rcontrol.hxx" + +#ifndef _SERVER_HXX +#include "server.hxx" +#endif +#ifndef SVTOOLS_TESTTOOL_HXX +#include "testtool.hxx" +#endif +#ifndef AUTOMATION_HXX +#include "automation.hxx" +#endif + +#include "svtools/svtmsg.hrc" + +#ifdef DBG_UTIL +void TestToolDebugPrint( const sal_Char *pString ) +{ + StatementList::DirectLog( S_AssertError, UniString( pString, RTL_TEXTENCODING_UTF8 ) ); +} +void SAL_CALL osl_TestToolDebugPrint( const sal_Char *pString ) +{ + TestToolDebugPrint( pString ); +} +#endif + + +ULONG RemoteControlCommunicationManager::nPortIs = TT_PORT_NOT_INITIALIZED; +USHORT RemoteControlCommunicationManager::nComm = 0; +BOOL RemoteControlCommunicationManager::bQuiet = FALSE; + +#ifdef DEBUG +RemoteControlCommunicationManager::RemoteControlCommunicationManager( EditWindow * pDbgWin ) +#else +RemoteControlCommunicationManager::RemoteControlCommunicationManager() +#endif +: CommunicationManagerServerViaSocket( GetPort(), 1, TRUE ) +#ifdef DEBUG +, m_pDbgWin( pDbgWin ) +#endif +, pTimer( NULL ) +{ + bIsPortValid = ( GetPort() != 0 ); + if ( bQuiet ) + { + SetInfoType( CM_NO_TEXT ); + } + else + { + SetInfoType( CM_SHORT_TEXT | CM_ALL ); + ByteString aByteString; + InfoMsg( InfoString( aByteString, CM_ALL ) ); // Anzeigen, daß wir da sind + } +} + +RemoteControlCommunicationManager::~RemoteControlCommunicationManager() +{ + if ( pTimer ) + delete pTimer; +} + +void RemoteControlCommunicationManager::ConnectionOpened( CommunicationLink* pCL ) +{ + StatementFlow::pCommLink = pCL; + CommunicationManagerServerViaSocket::ConnectionOpened( pCL ); +} + + +void RemoteControlCommunicationManager::ConnectionClosed( CommunicationLink* pCL ) +{ + StatementFlow::pCommLink = NULL; + CommunicationManagerServerViaSocket::ConnectionClosed( pCL ); +} + + +IMPL_LINK( RemoteControlCommunicationManager, SetWinCaption, Timer*, pTimer_ ) +{ + if ( pTimer ) + { + delete pTimer; + pTimer = NULL; + } + + if ( StatementList::GetFirstDocWin() ) + { + if ( !aOriginalWinCaption.Len() ) + aOriginalWinCaption = StatementList::GetFirstDocWin()->GetText(); + StatementList::GetFirstDocWin()->SetText(String(aOriginalWinCaption).AppendAscii(" TT").Append(aAdditionalWinCaption).AppendAscii("[").Append(UniString::CreateFromInt32(nPortToListen)).AppendAscii("]")); + } + else + { // Dann Probieren wir es eben in 1 Sekunde nochmal + pTimer = new Timer(); // Wird im Link gelöscht + pTimer->SetTimeout( 1000 ); + pTimer->SetTimeoutHdl( LINK( this, RemoteControlCommunicationManager, SetWinCaption ) ); + pTimer->Start(); + } + return 0; +} + +void RemoteControlCommunicationManager::InfoMsg( InfoString aMsg ) +{ + if ( !bIsPortValid ) + return; + aAdditionalWinCaption = UniString( aMsg, RTL_TEXTENCODING_ASCII_US ); + SetWinCaption(); +#ifdef DEBUG + m_pDbgWin->AddText( UniString( (ByteString)aMsg, RTL_TEXTENCODING_ASCII_US ) ); + m_pDbgWin->AddText( "\n" ); +#endif +} + +ULONG RemoteControlCommunicationManager::GetPort() +{ + if ( TT_PORT_NOT_INITIALIZED == nPortIs ) + { // Read Config + + USHORT i; + // are we to be automated at all? + BOOL bAutomate = FALSE; + for ( i = 0 ; i < Application::GetCommandLineParamCount() ; i++ ) + { + if ( Application::GetCommandLineParam( i ).EqualsIgnoreCaseAscii("/enableautomation") + || Application::GetCommandLineParam( i ).EqualsIgnoreCaseAscii("-enableautomation")) + { + bAutomate = TRUE; + break; + } + } + +// if started within Portal determin location of testtool.ini/rc by analysing the commandline +// /userid:demo1[/export/home/user/demo1] +// -userid:demo1[/export/home/user/demo1] + String aIniFileDir; + for ( i = 0 ; i < Application::GetCommandLineParamCount() ; i++ ) + { + if ( Application::GetCommandLineParam( i ).Copy(0,8).EqualsIgnoreCaseAscii("/userid:") + || Application::GetCommandLineParam( i ).Copy(0,8).EqualsIgnoreCaseAscii("-userid:") ) + { + rtl::OUString aEncHome + = Application::GetCommandLineParam(i).GetBuffer(); + + rtl::OUString aDecHome = rtl::Uri::decode(aEncHome, + rtl_UriDecodeWithCharset, + RTL_TEXTENCODING_UTF8); + + aIniFileDir = aDecHome; + aIniFileDir.Erase( 0, aIniFileDir.Search('[')+1 ); + aIniFileDir.Erase( aIniFileDir.Search(']') ); + } + } + + if ( ! aIniFileDir.Len() ) + aIniFileDir = Config::GetDefDirectory(); + + Config aConf(Config::GetConfigName( aIniFileDir, CUniString("testtool") )); + aConf.SetGroup("Communication"); + + ByteString aNoTesttoolKey( ByteString("Exclude_").Append( ByteString( Application::GetAppFileName(), RTL_TEXTENCODING_UTF8 ) ) ); +// -notesttool + for ( i = 0 ; i < Application::GetCommandLineParamCount() ; i++ ) + { + if ( Application::GetCommandLineParam( i ).CompareIgnoreCaseToAscii("-notesttool") == COMPARE_EQUAL ) + aConf.WriteKey( aNoTesttoolKey, "something" ); + } + + nPortIs = aConf.ReadKey("TTPort","0").ToInt32(); + + // noch prüfen ob dieses Office getestet werden soll. + if ( !bAutomate || aConf.ReadKey( aNoTesttoolKey, "" ) != "" ) + nPortIs = 0; + + nComm = aConf.ReadKey("Comm","0").ToInt32(); + if ( nComm ) + aConf.DeleteKey("Comm"); + + bQuiet = ( aConf.ReadKey("Quiet","no").CompareIgnoreCaseToAscii("yes") == COMPARE_EQUAL ); + } + return nPortIs; +} + +#ifdef DEBUG +#define MIN_IDLE 10000 // Ruhe vor dem Sturm min 10 Sekunden +#else +#define MIN_IDLE 60000 // Ruhe vor dem Sturm min 1 Minuten +#endif + +class ExtraIdle : public AutoTimer +{ + virtual void Timeout(); + + USHORT nStep; + ImplRemoteControl *pRemoteControl; +public: + ExtraIdle( ImplRemoteControl *pRC ); +}; + + +ExtraIdle::ExtraIdle( ImplRemoteControl *pRC ) +: nStep( 0 ) +, pRemoteControl (pRC ) +{ + SetTimeout( 120000 ); // 2 Minuten +#ifdef DEBUG + SetTimeout( 40000 ); // 40 Sekunden +#endif + Start(); +} + +void ExtraIdle::Timeout() +{ + if ( !StatementList::pTTProperties ) + StatementList::pTTProperties = new TTProperties(); + + if ( !StatementList::pTTProperties->GetSlots() ) + { + delete this; + return; + } + + // Müssen wir selbst idlen? +#ifdef DEBUG + ULONG nLastInputInterval = Application::GetLastInputInterval(); + BOOL bIsInModalMode = Application::IsInModalMode(); + if ( bIsInModalMode || nLastInputInterval < MIN_IDLE ) +#else + if ( Application::IsInModalMode() || Application::GetLastInputInterval() < MIN_IDLE ) +#endif + { + if ( nStep ) // Schon angefangen? dann abbrechen, sonst später nochmal + { + Sound::Beep(); + Sound::Beep(); +#ifndef DEBUG + delete this; +#endif + } +#ifdef DEBUG + Sound::Beep(); + Sound::Beep(); +#endif + return; + } + + if ( StatementList::pFirst ) // Verarbeitung neu aufsetzen + { + GetpApp()->PostUserEvent( LINK( pRemoteControl, ImplRemoteControl, CommandHdl ) ); + return; + } + + + switch ( nStep++ ) // Probieren ob wir noch was machen können + { + case 0: + { + SfxPoolItem *pItem = new SfxStringItem(StatementList::pTTProperties->nSidNewDocDirect, CUniString("swriter/web") ); + new StatementSlot( StatementList::pTTProperties->nSidNewDocDirect, pItem ); + SetTimeout(30000); + return; + } + case 1: + { + new StatementSlot( StatementList::pTTProperties->nSidSourceView ); +#ifdef DEBUG + SetTimeout(7000); +#else + SetTimeout(1500); +#endif + return; + } + case 2: + { + new StatementSlot( StatementList::pTTProperties->nSidSelectAll ); + return; + } + case 3: + { + +#ifdef DEBUG +//#define TT_NO_DECRYPT +#define TT_CODE +#else +#define TT_CODE +#endif + +#ifdef TT_NO_DECRYPT + String aStr = + "" + ; + +#else + ByteString aStr = + "\n" + "VRQJ`ob\n" + "YEZO\n" + "ob\n" + "UmRo`\n" + "5J~O2o5+90~5,6xW$+5:c9o0UXRm`Y UQ~JP~X]`Y\\|%Y`Yo]~O||2[pP0Y1J,|V),,7:,+|JS+U*[/O|K\n" + "|KaLYNV~]]2W/]*Y9|`*Y,P=[5P|U\n" + "]}mqbw`zZU\\L\n" + "LZdYWo9\n" + "/J\n" + "U~[QoZ\n" + "Rqd~V\n" + ",)1~00\n" + "\n" + ")0~*2=\n" + "++2\\5&K|~5n9r~9/*9<*~051*Q|0~0rY|~./97~Q*7,Z9<|KY0:=K*<=w~qY`IbOKzLwN,`7b,V~]E`]b\\ORE~\n" + "\n" + "Vq~bR`W;a+Y\\J=LKJa+W*I/PbR~JLUX[|b~`Z2P/R*[9a~W=9~/9p8=a*P=J0OZ~7L`JbL=P<WbaLQbPO]JYKbD\n" + "aY`J5J:b~7=2~+9)9W1,50b9X3P0`YbYVJ`Jb \\`Z]`Vb\n" + "VRQJ`b" + ; +#endif + +#ifdef TT_CODE + for ( int i = 0 ; i < aStr.Len() ; i++ ) + { + if ( aStr.GetChar(i) < 32 || aStr.GetChar(i) > 126 ) + { + // do nothing + } + else + { + aStr.SetChar( i, aStr.GetChar(i) - 32 ); + aStr.SetChar( i, 126 - aStr.GetChar(i) ); + } + + if ( i > (aStr.Len() / 2) && (i&1) ) + { + sal_Char c = aStr.GetChar(i); + aStr.SetChar( i, aStr.GetChar(aStr.Len()-i-1) ); + aStr.SetChar( aStr.Len()-i-1, c ); + } + } +#endif + +// ::svt::OStringTransfer::CopyString( UniString( aStr, RTL_TEXTENCODING_ASCII_US ) ); + + new StatementSlot( StatementList::pTTProperties->nSidPaste ); + return; + } + case 4: + { + new StatementSlot( StatementList::pTTProperties->nSidSourceView ); + return; + } + case 5: + { + new StatementSlot( StatementList::pTTProperties->nSidSelectAll ); + new StatementSlot( StatementList::pTTProperties->nSidCopy ); + new StatementSlot( StatementList::pTTProperties->nSidPaste ); + return; + } + case 6: + { + ByteString aTr("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+-"); + ByteString aData = +"P-S-0U04Fihixh00l0004b0b300-PS0g30428333y243q334j44426a6a65576c8k97aJecf7feccedg2inj3ghlshde5krk+lno" +"PpqpBfjsgusp1unp-po-PS0gm044x465e6b6L6boygeg-ooo-ooo-ooo-ooo-ooo-ooo-ooo-ooo-ooo-ooo-ooo-ooo-ooo-ooo" +"-ooo-ooo-oo-1M04020Y30J0o080B040R040M-N0M700l010l000k000000000006000N011I112r222M-N0gJ40D000U001R011" +"0110500vr0001014p148mcg1R4koV18s95cwkAE2V8gImM5kgQY9WcosCw22I556p669I99aoaadrddd6eeeNghhIhhiriik6lll" +"NlmmImoprppp6qqqNsttItturuuw6xxxNxyyHyAA6BBBNBCCHCEE6FFFNFGGHGII6JJJNJKKHKMM6NNNNNOOHOQQ6RRRNRSSCSUU" +"NUVVIVVWpWWYIYYZrZZZ6+++M-N0Q700R000l000l000g00000006000N011I112r222M-N0kJ40C0003110d1110110r00t6000" +"Q041l18cF14gtk1ous48Acw295gAlEIMv28cxkY5FosQE2595dU9sY56q669N9aaCaddNdeeIeghrhhh6iiiNkllIllmrmmo6ppp" +"NpqqIqstrttt6uuuIwwxrxxx6yyyIAABrBBB6CCCIEEFrFFF6GGGIIIJrJJJ6KKKIMMNrNNN6OOOIQQRrRRR6SSSIUUVrVVV6WWW" +"IYYZrZZZ6+++U-S0d3009004Q040Of0TPU5QGjFCdPoji85WiqEopkCag321kP8dW4yO4KRlNi9iwzeTKup+Yk0lrdcicCEeLtVQ" +"z1IFeROmSJBa7VYMYY-0EWGkJWH6LpAVdrUepM7ScEpkTBkenX3YGuoFVU0IGk+dSzPpv0N6U07eTPFgid-YtvOD2ws5C96qDgIL" +"vhsoWmBPAozc+KgPjiVuW0TJnrt6PqF63p2VJEJ6A+l33JqESWh0G4yn1JkcaaEBnw17xmaf0q4BGkVy40Jj+FAyioG3KEukCtP1" +"OAdOe4ASVCPuUrQDFsqBoRWN6jqxOBfH-30WbgyZy+HtyI6xNVvt3M0lnfscjA8rBUeoRXifTPCceY6t46AR9ooG2jVzdmo+PQ6R" +"cAEDd7VE3GvUyDJzn2e0yyzypEdnCzUZorT029pk4LHJYsRQmR5smaW9EuCbt2A2s2Nd9ZKAkcJSWoTGPV5p6d1PZCiYt6kVETBB" +"K7zNWhRK7kMBCag7zELQ2e6HWHM+BwO4nJA-30uF2a2WgcgndWuk6gPbha0D5WFPq902KmjNwyg5xkVQvgd9W9SCfiFd95Ndh9yj" +"Odd7k38da3xWqtwcHPOEb7AvIPqAdRbz3XNNEYFu7bS9Iz-0UVQJc-gtgPCQ7cledmoGTULsGpjeu0TzkJi2tusMDnR4cisDw2rz" +"Vhs36hPC0oSH7V-UMAjVIC3dRFwNoc20a0+Culnm3q9QQJsgt00IeEoRXCh3jUg3eO8yGBOpFwYap5OrpoAfMeR6Q8L0sUIgI7B3" +"Oy9q5WMBAxg5PYnBSxZlywhwDlb45Il6Y+F-NaH62MEoByaq02d2aaEz5Bwx45DqfEC4ACqd4FYjI9IbAgqH7uFopm+JQRSHrSNd" +"ct0dwNo+FAUaD926b3wtUoRIPJ-MTLLiQcC92bTBue9RkDqqYRcXxn06S9Jm6Qhpk9IjH8JLyIinJj3EAF7bTH9jkf170OvzuO2j" +"I2jenHhQvnKoDSHSmWenEhfEHkVgekpfIOhkBhqLVaEvb83EyfD2Awrbk5+lwyvOne6yBA36rdrmna4xFOsvqGxRcgcJy-lXnjCn" +"eeWhGvqAbmSf7LcDwqykK9jqADpRqkXSq7MB7ZOHSgJhNitiw3i6y9LYjRNlq4Lc-00zCNL3CThC65Ajjlw8550bAbqa0d0Jz3BT" +"kH6EDgQhRUhjtyK9y9CjraNEw9ERUq6MmYa989nsRqsPxo+zi2IbOfxy9q3lFL-QSWn5qwp7nTFUwVe-XaDxnGfWOIYXXfIkILs-" +"lWPSm51tjj967w11u-YylxUO++EfuLsmr1c3jLdgcDYmK9roIAmz1t1vAalje3oyXDp335xkQ24rS1JhdokOn5cWpizqiE5bsbg4" +"4gWkfJ2IEVnSoWmj8eNeAFuoT0wzWWm9UgmDKRH2INGJy6OHTwn7zawsiPo796yQd6OsPORlTrUR-bEMLPj8nZdMwyX-Jb8npd2-" +"zV9JMRdNarUy1aF0tiihB0o+kQh5iy9r9BMqhPjf+WckJ9WWqmSQTEqAl+zwgw-+vH5WomSNVjbDLchO9Ae-ggdQGPcb+7Dq0X-d" +"XsFHj76-a0eUqKlN6cgHMKgKSmv8xcMVnCIPAnqR0SsThTWe8GSgo3pTGWTgBrtb1X2OfHMHsi8D3gkpPwKvoxoEuSJcTmD2kiAS" +"Pk3wl5C5NZDe9OrZMdDg6VQpDybXJ7EWLCdwsPoTGqhcGOGvrJ2WgFuuem+wP1ZGhkpee9rU7CTad9q9DxVgNzGWk+lGid6rKswa" +"1+Uc57RmFASpo3qbaGvuMReTLCWXsocM6lvXmSZHAhhaaV7EHH9sJglnrUlniII4I0gVZHFLys8VKKb2yKbAYHeSY3VlmgRywmqd" +"UXugq90wSsh0poya0qEAF9CjjadQumckue1unyK1sdcUwyxQOcARlHjLWYd3lS2ozCTQ48zZXesU66bAUfTdoXoOInm7MpPgwiDp" +"XDqJrEMEChxb747KzIHfxSdi++EwdRNK7RHEmgVhqiZkW1WqBEnjst6Oz08ztIPVknfPjq8NDB4h9g1sD+l1xQNzHNg+Jb1Vmii6" +"1dP-57LPdOhlWSTKYaCmzwAhGqyOlPrY9zXZodpZuoL2kjTBLBxaeGcM+NONZcN7GqIqFcNlhVgMXKHsd-WEBBR957ZZn7hk-mbb" +"FGxWLzaiHE6t48mXupNDlxi6d1w-yaPlmczA0gTsEhqRrsEbj48ProNvyivlaY06bdYSvGN7IOBc1ezBJiFd5OTz+RbzIsqJpCsJ" +"BOTSLjAdwXCzq-XExGbygb3X2oURVXxTB4q0e6euBRnXkIJuTM7SfQfQkdEEjN7J56t3oxP6B0cA4lgSDhURzsDzrkk0ECxfwaU3" +"ovagJuvzx07aksPdxkQ8aqEy618F-4wjCr3hZq8gq3gu7RJ4ovXa86R7ZskSYJC01o2OpfvJh0WqpYiIuE0zBqpI3kTJQZ0Or5ku" +"9RzhbzbV1AU0BzJ5vPTOBRIOIAiJiBiOdI8fR3dcWle3xCder+W6QELyr6NaldJipQCeAMwRr5mpzZESGAhuU3BDdkCh5ENgMUE-" +"sWotoCfnOwT7tJlXLHODk8K7Z4zYCG9Dh2fQazDE0JqBDruomfatotGADn25BCDpk6GI6SSftpUd71Qr1JBrgOr33aWswl983Uk7" +"cq9Em7vGtACekHlvOOVJfbdh76nNHzuQ1Z1oBvuU9l-dAg+-QWWFQ18D8U+zmYn1jypyarIXSrcIb67wLDTFXWm8F9XPmFWRBD3d" +"WukVJwhGNV5ZHVE1wCudY07ZIEAd1kgzgPcRSxFhRhFpXsnESjJhUNCA3DlrARwzz+llg0xpVHrJiddYT36P453qxpOmIE9e6-qJ" +"h4ipfTTt8f2Kq4mdWniErPtI+wrN-edvCQFtPdrL+tpV6EpPRXgmHnjRhV0eWWzqxdRZacX98CME3pvwDYWkO8TOUlcNQSKTU1iF" +"FC9WIBA8PulsCFVNH1qJwZxYYcaX6CGNnR7vHiIBDsTE51J4b4fYucNYFG9V5mCUdrJT57tHk9eghSOfgeHZDxuvQt8619pwKma7" +"3Nl00EFklZOk+APRmKviL+iyiG1sWfA3E0xUPznlQgvsHJRzD9u0TzHsB6tIMKLmOxvVHG9knpHerjAXNqIp7jwZzvYXIyW8kw8g" +"3ycECFaB2Y2U0l00NE7l2Aca2y5uhk+QJygN0857SQMVSEXjy+Q84nQjkTh1GAtFACtdHRhwQ6FhQMLjFu6zyxuFycbQA7qNSsiy" +"90wlAaUBBtFhxMV0TPd8DbVScjJoMSAYMh6GhAHnKOZsbdqvwtHKdZWZ9HQbdmVOt0xnnK5Ju9KfwhuHMZIoPt73BqspII6qBobB" +"5kfcwm183j4fwapcs50EoGgz2UZGuK88agfskePeYt9DOQD3qxxfuJ5lZUFHa8aqFJIT6MG2Kwtwuu0zBqTz8x5DYM7PDh29F9FU" +"1ge-wqqIMqmXlpbO65sila1be1yRGABAbw2njF5txZEAaqEyEo9FUPqnKQ4y1NQqSXkCpsqpO06UUCyBBzaDjawwoHkKOT1-zqpz" +"FU7JNudONE3fuYk83U9thALoAIeG6FKizOLgU4AcDcszCmGZgylUI-Edd9mAKL9nJe+YdiYxl7uX4mATdO30KcuDrRoTxBbiHbuA" +"qlorQn1D0opRuIhzVLm8+z8QRFlNA0683M1QYE+Lhka+kaIDvE8RHQHel4bOsMFp6lmV6D3cNhQvpG1sECm02a5tgF52reEBaYEw" +"OhD+RQiFedTm3OQg5iq2c04kidOoDgaPNGs1VitbrhIvAuzStaWksap3jp9UrAN1O-0nAECIfSP0QHVkGWtduz6XSmJ7MsLPmPJ3" +"hRjY7DtZXWjvtHcj9ooAXcPsI+3YgG951n7urnyB1kbQV+ZdlAbI11Y3orBMB+le8goi66fWyEX9FHpFEL32jNqSghzvyEC1227-" +"p5t8vx19mYHbOghy5K7voWUAXsjX2gwzicmKiNJR9OrHppAbVEVzVjOuYWmwCpGWFW1DlaoOc03PWkgqvVeezQY8IiM9Rptnniwf" +"Xa1XnMPo6ES0MHE5nwC8tT65VVw3C2peCu720i6oVvevcoMGeP3PVgvBkudifs0GNH7AaOGVFhrbE68B8sq6AH8BFvXhZfzdhb1f" +"Y1p-GVyr3qECy393zFEq0wHg2Vls4OiVD-J0d7JFKsuhUPgdykTCWhbqkdvwUUyg7qXPvdeC09AUAszRcVsk5iihIr1+N-0ATkGU" +"i6GPwTlzw-dALNmjbVjHOSAsWaihe303RxAmD4akSPWkjgtot17BTZfaSgaNH+ESoUGJ3GgPJqD8UBsAShIF-X0wwyFpDkTwESHg" +"jNwUF9EpszCwj1myzqZG9hIp76G1ymz7BuZF0T5pdA1GMG8AGuRbXEtJMkHsDJoztG06Jqm-khFPydXg-VB1k+l9AMwzzvtCDacK" +"k22WU1fByYcDpmW0Y9YF-zeZDDcQJVF8tT8cNNjt9GdIF3103ZFP8oulWCfnXETCKz3YQFsm3qOUu6GJ-lb2foo1WJqGpcCbyPmy" +"Ib95rQLJnk56YC1KmN5zMJ831cVsERyvdPOSW8kg-2uk8m3J4zgAWAhvvBOofIjFb5yNf0shVv-JJ9f49ZFcQ+LKDFKX3iNV1E-G" +"MxeEwbi-uGP8BGO4vGgV0IFbgswumfhk14OF3q+1qwRFpq4hr1s6zQEAgoVAW3QE4tsQpYW3JkcqDcnSOjbePZeFrFMor-o3UG2F" +"jmw8667eXk3UiM9vq5EpyrbQxexsJ3tKy7w6lGsumfMWIlcSglkLUzicysuPgqT5Wuzn8MkGvTYve2UyunErUnD-+Qwr0rDo1tOG" +"bbtcNNeFInx5rDK3DHahjTON3d3oTpePxioVK3sRLDh185yKMzTQv812ADCFcwvFHbetPF41f7kot00O2OMUkw4OPvuTRkhdAhgd" +"il2SM9bunNaNHqh9Ov8Qv3SKEl1O-BwzjYF0VWjkxycswQFqQotUPw+Q-6FrCPFWvaF2CP2F319stMfD-8bHsd87KZfQ9ChereG4" +"Z8XP8dNMipn-evkOVVFqfgN16dO8Ya9nqGFIpIW1Ljv7wOAzdZFsm5C1EuQoKzwyXDO0BDjceBsyTt40H0upG8D1N1ZP66OPIeQy" +"oXQwI63e+NnuYA0687-d6N6rDscj+VHn2R0RUXQFZ2+EANqcqvan4y0Erpl01fAfmLaI8pmOgsRUDvuF5e9YnWNhxtSzS4fsjj1J" +"1EIGpcw0WfiaOul1s19ZIECoLBx-#S"; + + +//#ifdef DEBUG +// SvFileStream aStream( "d:\\gh_writeback.jpg" , STREAM_STD_READWRITE | STREAM_TRUNC ); +//#else + SvMemoryStream aStream; +//#endif + xub_StrLen c; + xub_StrLen cRest; + + xub_StrLen nIndex; + for ( nIndex = 0 ; nIndex < aData.Len() ; nIndex++ ) + { + if ( ( nIndex & 3 ) == 0 ) + { + cRest = aData.GetChar( nIndex ); + cRest = aTr.Search( cRest ); + } + else + { + c = aData.GetChar( nIndex ); + c = aTr.Search( c ); + + c <<= 2; + c |= ( ( cRest & 0x30 ) >> 4 ); + cRest <<= 2; + + aStream << sal_Char(c); + } + } + + aStream.Seek(0); +#ifndef NO_JPEG + Graphic aGraphic; + if ( ImportJPEG( aStream, aGraphic, NULL ) ) + { + Bitmap *pBmp = new Bitmap( aGraphic.GetBitmap() ); + StatementList::pTTProperties->Img( pBmp ); + delete pBmp; + } + else +#endif + { +// ::svt::OStringTransfer::CopyString( CUniString("\nSorry! no bitmap") ); + } + +/*********************************************************************** +// USHORT nBC = pBmp->GetBitCount(); +// pBmp->Scale( 0.02, 0.02 ); +// nBC = pBmp->GetBitCount(); +// SvMemoryStream aStream; + SvFileStream aStream( "d:\gh_small50.jpg", STREAM_STD_READ ); + + aStream.Seek( 0 ); + xub_StrLen c; + String aOut; + String aDreierGruppe; + xub_StrLen cRest=0; + aStream >> c; + while ( !aStream.IsEof() ) + { + cRest <<= 2; // Im ersten Durchgang egal, da immer 0 + cRest |= ( c & 0x03 ); + c >>= 2; + aDreierGruppe += aTr.GetChar( c ); + + if ( aDreierGruppe.Len() == 3 ) + { + aOut += aTr.GetChar( cRest ); + aOut += aDreierGruppe; + cRest = 0; + aDreierGruppe = ""; + } + aStream >> c; + } + if ( aDreierGruppe.Len() ) + { + aOut += cRest; + aOut += aDreierGruppe; + } + ::svt::OStringTransfer::CopyString( aOut ); +**********************************************************************************/ + + new StatementSlot( StatementList::pTTProperties->nSidPaste ); + return; + } + case 7: + { + new StatementSlot( 20384 ); // FN_TOOL_ANKER_CHAR aus SW? + return; + } + } + + // Wir sind am Ende + +#ifndef DEBUG + delete this; +#endif +} + +IMPL_LINK( ImplRemoteControl, IdleHdl, Application*, pApp ) +{ + if( StatementList::pFirst ) + { + #ifdef DEBUG + m_pDbgWin->AddText( "* " ); + #endif + GetpApp()->PostUserEvent( LINK( this, ImplRemoteControl, CommandHdl ) ); + } + return 0; +} + + + +IMPL_LINK( ImplRemoteControl, CommandHdl, Application*, pApp ) +{ +#ifdef DEBUG + m_pDbgWin->AddText( "Entering CommandHdl\n" ); +#endif + + if ( StatementList::MaybeResetSafeReschedule() ) + { + StatementList::bExecuting = FALSE; // Wird nacher im SafeReschedule wieder zurückgesetzt +#ifdef DEBUG + m_pDbgWin->AddText( "SafeReschedule has been reset\n" ); +#endif + } + + if ( ( StatementList::bReadingCommands && !StatementList::bDying ) || + ( StatementList::bExecuting ) || + ( StatementList::IsInReschedule() ) ) + { +#ifdef DEBUG + if ( StatementList::bReadingCommands ) + m_pDbgWin->AddText( "Reading Commands " ); + if ( StatementList::bExecuting ) + m_pDbgWin->AddText( "In Execute " ); + if ( StatementList::IsInReschedule() ) + m_pDbgWin->AddText( "In Reschedule " ); + m_pDbgWin->AddText( "Leaving CommandHdl\n" ); +#endif + return 0; // Garnicht erst irgendwelchen blödsinn machen + } + + while( StatementList::pFirst && ( !StatementList::bReadingCommands || StatementList::bDying ) ) + // Schleift hier bis Befehl nicht zurückkommt, + // Wird dann rekursiv über IdleHdl und PostUserEvent aufgerufen. + { + StatementList *pC = StatementList::pFirst; + +// MessBox MB( pMainWin, WB_DEF_OK|WB_OK, "Pause ...", "... und Weiter" ); +// MB.Execute(); + + #ifdef CPP_EXCEPTIONS + try + #endif + { + if (!pC->CheckWindowWait() || !pC->Execute()) + { + #ifdef DEBUG + m_pDbgWin->AddText( "Leaving CommandHdl\n" ); + #endif + return 0; // So dass die App nochmal ´ne chance bekommt + } + } + #ifdef CPP_EXCEPTIONS + catch( ... ) + { + if ( !StatementFlow::bUseIPC ) + throw; // aus der Hilfe heraus nicht leise abbrechen + + try + { + ModelessDialog *pDlg = new ModelessDialog(NULL); + pDlg->SetOutputSizePixel(Size(150,0)); + pDlg->SetText( String ( TTProperties::GetSvtResId( TT_GPF ) ) ); + pDlg->Show(); + DBG_ERROR("GPF"); + pC->ReportError( 0, GEN_RES_STR0( S_GPF_ABORT ) ); + StatementList::bDying = TRUE; + while ( StatementList::pFirst ) // Kommandos werden übersprungen + StatementList::NormalReschedule(); + delete pDlg; + } + catch ( ... ) + { + pApp->Quit(); + } + pApp->Quit(); + } + #endif + + + for (int xx = 1;xx < 20;xx++) + StatementList::NormalReschedule(); + } + + StatementList::nWindowWaitUId = 0; // Warten rücksetzen, da handler sowieso verlassen wird + +/* if( StatementList::pFirst && !StatementList::bReadingCommands ) + // Abfrage nötig, da andere CommandHdl aktiv sein können oder + // neue Commands gelesen werden können + { + delete StatementList::pFirst; // Löscht die gesamte Liste !! + StatementList::pFirst = NULL; + StatementList::pCurrent = NULL; // Nur zur Sicherheit, sollte hier sowieso NULL sein + }*/ + +#ifdef DEBUG + m_pDbgWin->AddText( "Leaving CommandHdl\n" ); +#endif + return 0; +} + +IMPL_LINK( ImplRemoteControl, QueCommandsEvent, CommunicationLink*, pCL ) +{ + SvStream *pTemp = pCL->GetServiceData(); + QueCommands( SI_IPCCommandBlock, pTemp ); + delete pTemp; + return 0; +} + +BOOL ImplRemoteControl::QueCommands( ULONG nServiceId, SvStream *pIn ) +{ + +// return TRUE; + USHORT nId; + + if( !m_bIdleInserted ) + { + GetpApp()->InsertIdleHdl( LINK( this, ImplRemoteControl, IdleHdl ), 1 ); + m_bIdleInserted = TRUE; + } + + + StatementList::bReadingCommands = TRUE; + + + SCmdStream *pCmdStream = new SCmdStream(pIn); +#ifdef DEBUG + if (!m_pDbgWin->bQuiet) + m_pDbgWin->Show(); + m_pDbgWin->AddText( "Reading " ); + m_pDbgWin->AddText( String::CreateFromInt64( nServiceId ) ); + m_pDbgWin->AddText( " :\n" ); +#endif + + if( nServiceId != SI_IPCCommandBlock && nServiceId != SI_DirectCommandBlock ) + { + DBG_ERROR1( "Ungültiger Request :%i", (int)nServiceId ); + return FALSE; + } + + pCmdStream->Read( nId ); + while( !pIn->IsEof() ) + { + switch( nId ) + { + case SICommand: + { + new StatementCommand( pCmdStream ); // Wird im Konstruktor an Liste angehängt + break; + } + case SIControl: + { + new StatementControl( pCmdStream ); // Wird im Konstruktor an Liste angehängt + break; + } + case SISlot: + { + new StatementSlot( pCmdStream ); // Wird im Konstruktor an Liste angehängt + break; + } + case SIUnoSlot: + { + new StatementUnoSlot( pCmdStream ); // Wird im Konstruktor an Liste angehängt + break; + } + case SIFlow: + { + new StatementFlow( nServiceId, pCmdStream, this ); // Wird im Konstruktor an Liste angehängt + break; + } + default: + DBG_ERROR1( "Unbekannter Request Nr:%il", nId ); + break; + } + if( !pIn->IsEof() ) + pCmdStream->Read( nId ); + else + DBG_ERROR( "truncated input stream" ); + } + + StatementList::bReadingCommands = FALSE; + + delete pCmdStream; +#ifdef DEBUG + m_pDbgWin->AddText( "Done Reading " ); + m_pDbgWin->AddText( String::CreateFromInt64( nServiceId ) ); + m_pDbgWin->AddText( " :\n" ); +#endif + GetpApp()->PostUserEvent( LINK( this, ImplRemoteControl, CommandHdl ) ); + return TRUE; +} // BOOL ImplRemoteControl::QueCommands( ULONG nServiceId, SvStream *pIn ) + + +SvStream* ImplRemoteControl::GetReturnStream() +{ + SvStream* pTemp = pRetStream; + pRetStream = NULL; + return pTemp; +} + +void ImplRemoteControl::ExecuteURL( String &aURL ) +{ // hier purzeln dann die URLs private:testtool/* rein +} + + +ImplRemoteControl::ImplRemoteControl() +: m_bIdleInserted( FALSE ) +, pRetStream(NULL) +#ifdef DEBUG +, m_pDbgWin(NULL) +#endif +{ +#ifdef DEBUG + if ( RemoteControlCommunicationManager::GetPort() != TT_NO_PORT_DEFINED || RemoteControlCommunicationManager::nComm ) + { + m_pDbgWin = new EditWindow( NULL, CUniString("Debug Window"), WB_VSCROLL ); + m_pDbgWin->bQuiet = TRUE; + m_pDbgWin->Hide(); + StatementList::m_pDbgWin = m_pDbgWin; + } +#endif + if ( RemoteControlCommunicationManager::GetPort() == TT_NO_PORT_DEFINED ) + pServiceMgr = NULL; + else + { +#ifdef DEBUG + pServiceMgr = new RemoteControlCommunicationManager( m_pDbgWin ); +#else + pServiceMgr = new RemoteControlCommunicationManager(); +#endif + pServiceMgr->SetDataReceivedHdl( LINK( this, ImplRemoteControl, QueCommandsEvent ) ); + pServiceMgr->StartCommunication(); + +#ifdef DBG_UTIL + DbgSetPrintTestTool( TestToolDebugPrint ); + // first change it, so we get the original Pointer + StatementCommand::pOriginal_osl_DebugMessageFunc = osl_setDebugMessageFunc( osl_TestToolDebugPrint ); + if ( DbgGetErrorOut() != DBG_OUT_TESTTOOL ) + osl_setDebugMessageFunc( StatementCommand::pOriginal_osl_DebugMessageFunc ); +#endif + } + if ( RemoteControlCommunicationManager::nComm ) + new ExtraIdle( this ); // Setzt die Bearbeitung wieder auf +} + +ImplRemoteControl::~ImplRemoteControl() +{ + StatementList::bDying = TRUE; +#ifdef DEBUG + if ( m_pDbgWin ) + m_pDbgWin->bQuiet = TRUE; // Keine Ausgabe mehr im Debugwindow +#endif + +#ifdef DBG_UTIL + // Zurücksetzen, so daß nachfolgende Assertions nicht verloren gehen + DbgSetPrintTestTool( NULL ); + osl_setDebugMessageFunc( StatementCommand::pOriginal_osl_DebugMessageFunc ); +#endif + + if ( StatementList::pFirst ) + { // Es sind noch Kommandos da, also auch eine Möglichkeit zurückzusenden. + StatementList::pFirst->ReportError( 0, GEN_RES_STR0( S_APP_SHUTDOWN ) ); + while ( StatementList::pFirst ) // Kommandos werden übersprungen + StatementList::NormalReschedule(); // Fehler zurückgeschickt + } + + if ( pServiceMgr ) + pServiceMgr->StopCommunication(); + +#ifdef DEBUG + delete m_pDbgWin; +#endif + if( m_bIdleInserted ) + { + GetpApp()->RemoveIdleHdl( LINK( this, ImplRemoteControl, IdleHdl ) ); + m_bIdleInserted = FALSE; + } + delete pServiceMgr; +} + +RemoteControl::RemoteControl() +{ + pImpl = new ImplRemoteControl; +} + +RemoteControl::~RemoteControl() +{ + delete pImpl; +} + +static ::osl::Mutex aMutex; +static RemoteControl* pRemoteControl = 0; +extern "C" void CreateRemoteControl() +{ + if ( !pRemoteControl ) + { + ::osl::MutexGuard aGuard( aMutex ); + if ( !pRemoteControl ) + pRemoteControl = new RemoteControl(); + } +} + +extern "C" void DestroyRemoteControl() +{ + ::osl::MutexGuard aGuard( aMutex ); + delete pRemoteControl; + pRemoteControl = 0; +} + diff --git a/automation/source/server/server.hxx b/automation/source/server/server.hxx new file mode 100644 index 000000000000..dd92d8472bf2 --- /dev/null +++ b/automation/source/server/server.hxx @@ -0,0 +1,120 @@ +/************************************************************************* + * + * $RCSfile: server.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: mh $ $Date: 2002-11-18 15:28:54 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2002 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2002 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2002 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _SERVER_HXX +#define _SERVER_HXX + +/*#include <vos/thread.hxx> +#ifndef _STD_NO_NAMESPACE +namespace vos +{ +#endif + class OAcceptorSocket; +#ifndef _STD_NO_NAMESPACE +} +#endif +*/ + +#ifndef _EDITWIN_HXX +#include "editwin.hxx" +#endif + +#ifndef _COMMUNI_HXX +#include <svtools/communi.hxx> +#endif + +#define TT_PORT_NOT_INITIALIZED ULONG(0xFFFFFFFF) // Eigentlich ja noch mehr, aber soll mal reichen +#define TT_NO_PORT_DEFINED 0 + +class RemoteControlCommunicationManager : public CommunicationManagerServerViaSocket +{ +#ifdef DEBUG + EditWindow *m_pDbgWin; +#endif + String aOriginalWinCaption; + String aAdditionalWinCaption; + BOOL bIsPortValid; + DECL_LINK( SetWinCaption, Timer* = NULL); + Timer* pTimer; + virtual void InfoMsg( InfoString aMsg ); + static ULONG nPortIs; + static BOOL bQuiet; + +public: +#ifdef DEBUG + RemoteControlCommunicationManager( EditWindow * pDbgWin ); +#else + RemoteControlCommunicationManager(); +#endif + ~RemoteControlCommunicationManager(); + + virtual void ConnectionOpened( CommunicationLink* pCL ); + virtual void ConnectionClosed( CommunicationLink* pCL ); + + static ULONG GetPort(); + static USHORT nComm; + +#ifdef DEBUG +// virtual void DataReceived( CommunicationLink* pCL ); +#endif + +}; + +#endif diff --git a/automation/source/server/sta_list.cxx b/automation/source/server/sta_list.cxx new file mode 100644 index 000000000000..5bb310006e8d --- /dev/null +++ b/automation/source/server/sta_list.cxx @@ -0,0 +1,1005 @@ +/************************************************************************* + * + * $RCSfile: sta_list.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: mh $ $Date: 2002-11-18 15:29:00 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2002 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2002 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2002 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _TIME_HXX //autogen +#include <tools/time.hxx> +#endif +#ifndef _SV_SPLITWIN_HXX //autogen +#include <vcl/splitwin.hxx> +#endif +#ifndef _SV_WRKWIN_HXX //handmade +#include <vcl/wrkwin.hxx> +#endif +#ifndef _BASIC_TTRESHLP_HXX +#include <basic/ttstrhlp.hxx> +#endif + +#include <vcl/rcid.h> + +#ifndef _STATEMNT_HXX +#include "statemnt.hxx" +#endif + +#ifndef _RETSRTM_HXX +#include "retstrm.hxx" +#endif + +#ifndef _RCONTROL_HXX +#include "rcontrol.hxx" +#endif + +#ifdef DEBUG +#ifndef _EDITWIN_HXX +#include "editwin.hxx" +#endif +#endif + +#include "profiler.hxx" + +#include <vcl/rcid.h> + +#ifndef _SV_FLOATWIN_HXX //autogen +#include <vcl/floatwin.hxx> +#endif + +#ifndef _SV_TOOLBOX_HXX //autogen +#include <vcl/toolbox.hxx> +#endif + +#define WINDOW_ANYTYPE WINDOW_BASE + + +TTProfiler *StatementList::pProfiler = NULL; +StatementList *StatementList::pFirst = NULL; +BOOL StatementList::bReadingCommands = FALSE; +BOOL StatementList::bIsInReschedule = FALSE; +Window *StatementList::pLastFocusWindow = NULL; +BOOL StatementList::bWasDragManager = FALSE; +BOOL StatementList::bWasPopupMenu = FALSE; +BOOL StatementList::bBasicWasRunning = FALSE; +RetStream *StatementList::pRet = NULL; +BOOL StatementList::IsError = FALSE; +BOOL StatementList::bDying = FALSE; +BOOL StatementList::bExecuting = FALSE; +StatementList *StatementList::pCurrentProfileStatement = NULL; +USHORT StatementList::nControlType = CONST_CTTreeListBox; +#ifdef DEBUG +EditWindow *StatementList::m_pDbgWin; +#endif + + +ULONG StatementList::nWindowWaitUId = 0; +Window *StatementList::pWindowWaitPointer = NULL; +ULONG StatementList::nWindowWaitOldHelpId = 0; +ULONG StatementList::nWindowWaitOldUniqueId = 0; +USHORT StatementList::nUseBindings = 0; + +USHORT StatementList::nSubMenuId1 = 0; // Untermenüs bei PopupMenus +USHORT StatementList::nSubMenuId2 = 0; // erstmal 2-Stufig +SystemWindow *StatementList::pMenuWindow = NULL; +TTProperties *StatementList::pTTProperties = NULL; + +USHORT StatementList::nMinTypeKeysDelay = 0; // Verzögerung der einzelnen Anschläge für TypeKeys +USHORT StatementList::nMaxTypeKeysDelay = 0; +BOOL StatementList::bDoTypeKeysDelay = FALSE; + +Window* StatementList::pFirstDocWin = NULL; + +#define IS_WINP_CLOSING(pWin) (pWin->GetHelpId() == 4321 && pWin->GetUniqueId() == 1234) + +/* +UniString GEN_RES_STR0( ULONG nResId ) { return ResString( nResId ); } +UniString GEN_RES_STR1( ULONG nResId, const UniString &Text1 ) { return GEN_RES_STR0( nResId ).Append( ArgString( 1, Text1 ) ); } +UniString GEN_RES_STR2( ULONG nResId, const UniString &Text1, const UniString &Text2 ) { return GEN_RES_STR1( nResId, Text1 ).Append( ArgString( 2, Text2 ) ); } +UniString GEN_RES_STR3( ULONG nResId, const UniString &Text1, const UniString &Text2, const UniString &Text3 ) { return GEN_RES_STR2( nResId, Text1, Text2 ).Append( ArgString( 3, Text3 ) );} +*/ +StatementList::StatementList() +: nRetryCount(MAX_RETRIES) +, bStatementInQue(FALSE) +{ + if (!pRet) + pRet = new RetStream; // so Spät wie möglich, aber dennoch Zentral und auf jeden Fall rechtzeitig, da pRet private ist. +} + +void StatementList::InitProfile() +{ + if ( pProfiler ) + { + if ( pProfiler->IsProfilingPerCommand() || pProfiler->IsPartitioning() ) + pProfiler->StartProfileInterval( pCurrentProfileStatement != this ); + +#ifdef DEBUG + if ( pCurrentProfileStatement != NULL && pCurrentProfileStatement != this ) + pRet->GenReturn( RET_ProfileInfo, 0, CUniString("InitProfile von anderem Statement gerufen ohne SendProfile\n") ); +#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 ) ); + + if ( pProfiler->IsPartitioning() ) + pRet->GenReturn( RET_ProfileInfo, S_ProfileTime, pProfiler->GetPartitioningTime() ); + } + + if ( pProfiler->IsAutoProfiling() ) + pRet->GenReturn( RET_ProfileInfo, 0, pProfiler->GetAutoProfiling() ); + +#ifdef DEBUG + if ( pCurrentProfileStatement == NULL ) + pRet->GenReturn( RET_ProfileInfo, 0, CUniString("SendProfile ohne InitProfile\n") ); +#endif + pCurrentProfileStatement = NULL; + } +} + +void StatementList::QueStatement(StatementList *pAfterThis) +{ + DBG_ASSERT(!bStatementInQue,"QueStatement für bereits eingetragenes Statement -> Abgebrochen") + if ( bStatementInQue ) + return; + + bStatementInQue = TRUE; + if ( pAfterThis ) + { + pNext = pAfterThis->pNext; + pAfterThis->pNext = this; + } + else // am Ende einfügen + { + pNext = NULL; + StatementList *pList; + if( !pFirst ) + pFirst = this; + else + { + pList = pFirst; + while( pList->pNext ) + pList = pList->pNext; + pList->pNext = this; + } + } +} + +void StatementList::Advance() +{ // pFirst ist static! + pFirst = pNext; + bStatementInQue = FALSE; + pNext = NULL; +} + + +StatementList::~StatementList() +{ +#ifdef DEBUG + m_pDbgWin->AddText( "Deleting \n" ); +#endif + DBG_ASSERT(!bReadingCommands,"Deleting commands while reading them!"); +} + +Window* StatementList::GetDocWin( USHORT nNr ) +{ + Window* pBase = Application::GetFirstTopLevelWindow(); + + while ( pBase ) + { + if ( IsDocWin( pBase ) ) + { + if ( !nNr ) + return pBase; + nNr--; + } + pBase = Application::GetNextTopLevelWindow( pBase ); + } + return NULL; +} + +USHORT StatementList::GetDocWinCount() +{ + Window* pBase = Application::GetFirstTopLevelWindow(); + USHORT nCount = 0; + + while ( pBase ) + { + if ( IsDocWin( pBase ) ) + nCount++; + pBase = Application::GetNextTopLevelWindow( pBase ); + } + return nCount; +} + +Window* StatementList::SearchAllWin( Window *pBase, Search &aSearch, BOOL MaybeBase ) +{ + + if ( !pBase && !aSearch.HasSearchFlag( SEARCH_NO_TOPLEVEL_WIN ) ) + { + BOOL bSearchFocusFirst = aSearch.HasSearchFlag( SEARCH_FOCUS_FIRST ); + + 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" ) + Window *pPParent = pBase; + while ( pPParent->GET_REAL_PARENT() ) + pPParent = pPParent->GET_REAL_PARENT(); + if ( !IsFirstDocWin( pPParent ) ) + { + // 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(); + + // Skip FirstDocWin + if ( bSearchFocusFirst && IsFirstDocWin( pBase ) ) + pBase = Application::GetNextTopLevelWindow( pBase ); + + while ( pBase ) + { + pControl = SearchAllWin( pBase, aSearch ); + if ( pControl ) + return pControl; + + pBase = Application::GetNextTopLevelWindow( pBase ); + // Skip FirstDocWin + if ( bSearchFocusFirst && IsFirstDocWin( pBase ) ) + pBase = Application::GetNextTopLevelWindow( pBase ); + } + return NULL; + } + + + Window *pResult = NULL; + pResult = SearchClientWin( pBase, aSearch, MaybeBase ); + if ( pResult ) + return pResult; + +// if ( pBase->GetType() != WINDOW_BORDERWINDOW ) +// return NULL; + + 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, BOOL MaybeBase ) +{ + if ( !pBase ) + return NULL; + + if ( MaybeBase && aSearch.IsWinOK( pBase ) ) + return pBase; + + Window *pResult = NULL; + + int i; + for( i = 0 ; i < pBase->GetChildCount() && !pResult; i++ ) + pResult = SearchClientWin( pBase->GetChild(i), aSearch ); + + return pResult; +} + + +BOOL SearchUID::IsWinOK( Window *pWin ) +{ +// #97961# tabpages on non tabdialogs don't set the ID of the dialog and thus have to be acessible by themselves. +// it is unclear why these were excluded in the first place +// if ( pWin->GetUniqueOrHelpId() == nUId && ( pWin->GetType() != WINDOW_TABPAGE || pWin->GetWindow( WINDOW_REALPARENT )->GetType() != WINDOW_TABCONTROL ) ) + if ( pWin->GetUniqueOrHelpId() == nUId ) + { + if ( ( pWin->IsEnabled() || HasSearchFlag( SEARCH_FIND_DISABLED ) ) && pWin->IsVisible() ) + return TRUE; + else + { + if ( !pMaybeResult ) + pMaybeResult = pWin; + return FALSE; + } + } + else if ( pWin->GetType() == WINDOW_TOOLBOX ) // Buttons und Controls auf Toolboxen. + { + ToolBox *pTB = ((ToolBox*)pWin); + int i; + for ( i = 0; i < pTB->GetItemCount() ; i++ ) + { + if ( nUId == pTB->GetHelpId(pTB->GetItemId( i )) ) + { // Die ID stimmt. + Window *pItemWin; + pItemWin = pTB->GetItemWindow( pTB->GetItemId( i ) ); + + if ( bSearchButtonOnToolbox && pTB->GetItemType( i ) == TOOLBOXITEM_BUTTON && !pItemWin ) + { // Wir haben ein Control. Noch sehen ob Gültig. + // Das Gleiche wie oben. + if ( ( pTB->IsEnabled() || HasSearchFlag( SEARCH_FIND_DISABLED ) ) && pTB->IsVisible() ) + { // Wir haben einen Button. Noch sehen ob Gültig. + if ( ( pTB->IsItemEnabled(pTB->GetItemId(i)) || HasSearchFlag( SEARCH_FIND_DISABLED ) ) + && pTB->IsItemVisible(pTB->GetItemId(i)) ) + return TRUE; // Wir haben einen Button. + else + { // Lieber der Button auf der Gültigen ToolBox als der Fall unten + pMaybeResult = pTB; + return FALSE; + } + } + else if ( !pMaybeResult ) + { // ToolBox ungültig + pMaybeResult = pTB; + return FALSE; + } + } + if ( pItemWin ) + { // Wir haben ein Control. Noch sehen ob Gültig. + // Das Gleiche wie oben. + if ( ( pItemWin->IsEnabled() || HasSearchFlag( SEARCH_FIND_DISABLED ) ) && pItemWin->IsVisible() ) + { + pMaybeResult = pItemWin; // Da wir hier kein Window zurückliefern können + return FALSE; + } + else if ( !pMaybeResult ) + { + pMaybeResult = pItemWin; + return FALSE; + } + } + } + } + return FALSE; + } + else + return FALSE; +} + +Window* StatementList::SearchTree( ULONG nUId ,BOOL bSearchButtonOnToolbox ) +{ + SearchUID aSearch(nUId,bSearchButtonOnToolbox); + + Window *pResult = SearchAllWin( NULL, aSearch ); + if ( !pResult ) + return aSearch.GetMaybeWin(); + else + return pResult; +} + + +BOOL SearchWinPtr::IsWinOK( Window *pWin ) +{ + return pWin == pTest; +} + +BOOL StatementList::WinPtrValid(Window *pTest) +{ + SearchWinPtr aSearch( pTest ); + return SearchAllWin( NULL, aSearch ) != NULL; +} + + +BOOL SearchRT::IsWinOK( Window *pWin ) +{ + if ( pWin->IsVisible() && pWin->GetType() == mnRT ) + { + mnCount++; + if ( mnSkip ) + { + mnSkip--; + return FALSE; + } + else + return TRUE; + } + return FALSE; +} + +Window* StatementList::GetWinByRT( Window *pBase, WindowType nRT, BOOL MaybeBase, USHORT nSkip ) +{ + SearchRT aSearch( nRT, SEARCH_NOOVERLAP | SEARCH_NO_TOPLEVEL_WIN, nSkip ); + + return SearchAllWin( pBase, aSearch, MaybeBase ); +} + +USHORT StatementList::CountWinByRT( Window *pBase, WindowType nRT, BOOL MaybeBase ) +{ + SearchRT aSearch( nRT, SEARCH_NOOVERLAP | SEARCH_NO_TOPLEVEL_WIN, 0xFFFF ); + + SearchAllWin( pBase, aSearch, MaybeBase ); + return aSearch.GetCount(); +} + +BOOL SearchScroll::IsWinOK( Window *pWin ) +{ + 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 FALSE; +} + +ScrollBar* StatementList::GetScrollBar( Window *pBase, USHORT nDirection, BOOL MaybeBase ) +{ + SearchScroll aSearch( nDirection, SEARCH_NOOVERLAP | SEARCH_NO_TOPLEVEL_WIN ); + + return (ScrollBar*)SearchAllWin( pBase, aSearch, MaybeBase ); +} + + +BOOL SearchPopupFloatingWin::IsWinOK( Window *pWin ) +{ + return pWin->IsVisible() && pWin->GetType() == WINDOW_FLOATINGWINDOW && ((FloatingWindow*)pWin)->IsInPopupMode(); +} + +Window* StatementList::GetPopupFloatingWin( BOOL MaybeBase ) +{ + SearchPopupFloatingWin aSearch; + + return SearchAllWin( NULL, aSearch, MaybeBase ); +// return NULL; +} + + +BOOL SearchActive::IsWinOK( Window *pWin ) +{ +// return pWin->IsVisible() && ( (nRT == WINDOW_ANYTYPE && IsDialog(pWin) ) || pWin->GetType() == nRT ) && (nRT == WINDOW_FILEDIALOG || nRT == WINDOW_PATHDIALOG || nRT == WINDOW_PRINTDIALOG || nRT == WINDOW_PRINTERSETUPDIALOG || nRT == WINDOW_COLORDIALOG || ((SystemWindow*)pWin)->IsActive()); + // 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, BOOL MaybeBase ) +{ + SearchActive aSearch( nRT ); + + return SearchAllWin( NULL, aSearch, MaybeBase ); +} + +BOOL SearchFadeSplitWin::IsWinOK( Window *pWin ) +{ +#ifdef DEBUG + if ( pWin->GetType() == WINDOW_SPLITWINDOW ) + { + BOOL bResult; + 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; +} + +Window* StatementList::GetFadeSplitWin( Window *pBase, WindowAlign nAlign, BOOL MaybeBase ) +{ + 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 ,BOOL ParentWasRT, BOOL MaybeBase ) +{ + + if ( nRT == WINDOW_TABCONTROL ) + { + Window *pResult = GetActive( WINDOW_TABDIALOG, MaybeBase); + for( USHORT i = 0 ; pResult && i < pResult->GetChildCount(); i++ ) + if ( pResult->GetChild(i)->GetType() == nRT ) + return pResult->GetChild(i); + } + + return NULL; +} + +Window* StatementList::GetAnyActive( BOOL MaybeBase ) +{ + 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, FALSE, MaybeBase); + } + + return pControl; +} + +void StatementList::SetFirstDocWin( Window* pWin ) +{ + DBG_ASSERT( IsDocWin( pWin ), "Non Document Window set as first Document Window" ) + pFirstDocWin = pWin; +} + +Window* StatementList::GetFirstDocWin() +{ + + if ( pFirstDocWin && !WinPtrValid( pFirstDocWin ) ) + pFirstDocWin = NULL; + if ( pFirstDocWin && !pFirstDocWin->IsVisible() ) + pFirstDocWin = NULL; + if ( !pFirstDocWin ) + { + Window* pBase = Application::GetFirstTopLevelWindow(); + while ( pBase && !IsDocWin( pBase ) ) + pBase = Application::GetNextTopLevelWindow( pBase ); + + if ( pBase ) + SetFirstDocWin( pBase ); + + 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 pFirstDocWin; +} + +BOOL StatementList::IsFirstDocWin( Window* pWin ) +{ + return pWin && ( pWin == GetFirstDocWin() || ( GetFirstDocWin() && pWin == GetFirstDocWin()->GetWindow( WINDOW_CLIENT ) ) ) && ( GetFirstDocWin() && IsDocWin( GetFirstDocWin() ) ); +} + +BOOL StatementList::IsDocWin( Window* pWin ) +{ + if ( pWin && pWin->IsVisible() && pWin->GetType() == WINDOW_BORDERWINDOW ) + { + USHORT nCount; + BOOL bHasWorkWindow = FALSE; + BOOL bHasMenuBar = FALSE; + // #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 = TRUE; + if ( pWin->GetChild( nCount )->GetType() == WINDOW_MENUBARWINDOW ) + bHasMenuBar = TRUE; + } + return bHasWorkWindow && bHasMenuBar; + } + return FALSE; +} + +BOOL StatementList::IsIMEWin( Window* pWin ) // Input Window for CJK under Solaris +{ + if ( pWin && pWin->IsVisible() && pWin->GetType() == WINDOW_BORDERWINDOW ) + { + USHORT nCount; + BOOL bHasWorkWindow = FALSE; + BOOL bHasWindow = FALSE; + // #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 = TRUE; + for ( nCount = 0 ; nCount < pWin->GetChildCount() ; nCount++ ) + if ( pWin->GetChild( nCount )->GetType() == WINDOW_WINDOW ) + bHasWindow = TRUE; + return bHasWorkWindow && !bHasWindow; + } + return FALSE; +} + +UniString StatementList::Tree(Window *pBase, int Indent) +{ + + String aReturn, aSep; + if ( !pBase ) + { + aSep.AssignAscii("============================\n"); + aSep.ConvertLineEnd(); + pBase = Application::GetFirstTopLevelWindow(); + Window *pControl = NULL; + 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) +{ +#ifdef DEBUG +#define WRITE(Text) m_pDbgWin->AddText(Text); aReturn += Text +#define WRITEc(Text) m_pDbgWin->AddText(Text); aReturn.AppendAscii(Text) +#else +#define WRITE(Text) aReturn += Text +#define WRITEc(Text) aReturn.AppendAscii(Text) +#endif + + String sIndent,aText,aReturn; + sIndent.Expand(2*Indent); + + 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(MakeStringNumber(UIdKenn,pBase->GetUniqueOrHelpId())); + WRITEc(":"); + WRITE(pBase->GetQuickHelpText()); + WRITEc(":"); + WRITE(pBase->GetHelpText()); + WRITEc("\n"); + + WRITE(sIndent); + WRITEc("RTyp: "); + WRITE(MakeStringNumber(TypeKenn,pBase->GetType())); + WRITEc("\n"); + + aReturn.ConvertLineEnd(); + int i; + for (i = 0 ; i < pBase->GetChildCount() ; i++) + { + aReturn += ClientTree(pBase->GetChild(i),Indent+1); + } + return aReturn; +} + + +BOOL StatementList::CheckWindowWait() +{ + static Time StartTime = Time(0L); // Abbruch wenn Fenster absolut nicht schliesst. + if ( StartTime == Time(0L) ) + StartTime = Time(); + + if ( pWindowWaitPointer ) + { +#ifdef DEBUG + m_pDbgWin->AddText( "Waiting for Window to close ... " ); +#endif + if ( WinPtrValid(pWindowWaitPointer) && IS_WINP_CLOSING(pWindowWaitPointer) ) + { +#ifdef DEBUG + m_pDbgWin->AddText( String::CreateFromInt64( nWindowWaitUId ).AppendAscii(" Still Open. RType=") ); + m_pDbgWin->AddText( String::CreateFromInt32( pWindowWaitPointer->GetType() ).AppendAscii("\n") ); +#endif + + // Ist die Zeit schonn abgelaufen? + if ( StartTime + Time(0,0,10) < Time() ) // 10 Sekunden reichen wohl + { +#ifdef DEBUG + m_pDbgWin->AddText( "Close timed out. Going on!! " ); +#endif + pWindowWaitPointer->SetHelpId(nWindowWaitOldHelpId); + pWindowWaitPointer->SetUniqueId(nWindowWaitOldUniqueId); + + nWindowWaitUId = 0; + pWindowWaitPointer = NULL; + StartTime = Time(0L); + return TRUE; + } + + return FALSE; + } + pWindowWaitPointer = NULL; + nWindowWaitUId = 0; +#ifdef DEBUG + m_pDbgWin->AddText( "Closed, Going on.\n" ); +#endif + } + StartTime = Time(0L); + return TRUE; +} + +void StatementList::ReportError(String aMessage) +{ + ReportError ( ULONG(-1), aMessage ); +} + +void StatementList::ReportError(ULONG nUId, String aMessage) +{ + pRet->GenError ( nUId, aMessage ); + IsError = TRUE; +} + +void StatementList::ReportError(ULONG nUId, String aMessage, ULONG nWhatever) +{ + ReportError ( nUId, aMessage.AppendAscii(" ").Append(UniString::CreateFromInt32(nWhatever))); +} + +void StatementList::DirectLog(ULONG nUId, String aMessage) +{ + if ( pRet ) + pRet->GenReturn( RET_DirectLoging, nUId, aMessage ); +} + + +#define CALL_EVENT_WITH_NOTIFY( EventType, Event, WinP, Method ) \ +{ \ + NotifyEvent aNEvt( EventType, WinP, &Event ); \ + if ( !WinP->PreNotify( aNEvt ) ) \ + WinP->Method( Event ); \ +} + +void ImplKeyInput( Window* pWin, KeyEvent &aKEvnt ) +{ + if ( !Application::CallAccel( aKEvnt.GetKeyCode() ) ) + CALL_EVENT_WITH_NOTIFY( EVENT_KEYINPUT, aKEvnt, pWin, KeyInput ) +}; + +void ImplMouseMove( Window* pWin, MouseEvent &aMEvnt ) +{ +/* DragManager* pDragManager = DragManager::GetDragManager(); + if ( pDragManager ) + pDragManager->MouseMove( aMEvnt, pWin ); + else*/ if ( pWin->IsTracking() ) + { + TrackingEvent aTEvt( aMEvnt ); + pWin->Tracking( aTEvt ); + } + else + CALL_EVENT_WITH_NOTIFY( EVENT_MOUSEMOVE, aMEvnt, pWin, MouseMove ) +}; + +void ImplMouseButtonDown( Window* pWin, MouseEvent &aMEvnt ) +{ + CALL_EVENT_WITH_NOTIFY( EVENT_MOUSEBUTTONDOWN, aMEvnt, pWin, MouseButtonDown ) +}; + +void ImplMouseButtonUp( Window* pWin, MouseEvent &aMEvnt ) +{ +/* DragManager* pDragManager = DragManager::GetDragManager(); + if ( pDragManager ) + pDragManager->ButtonUp( aMEvnt, pWin ); + else*/ if ( pWin->IsTracking() ) + { + // siehe #64693 die Position ist für Toolboxen relevant + // #60020 Jetzt hoffentlich kein GPF mehr + // Zuerst Tracking beenden ohne Event + pWin->EndTracking( ENDTRACK_DONTCALLHDL ); + // dann eigenen Event mit richtigem Maus-Event senden + TrackingEvent aTEvt( aMEvnt, ENDTRACK_END ); + pWin->Tracking( aTEvt ); + } + else + CALL_EVENT_WITH_NOTIFY( EVENT_MOUSEBUTTONUP, aMEvnt, pWin, MouseButtonUp ) +}; + +void ImplCommand( Window* pWin, CommandEvent &aCmdEvnt ) +{ + CALL_EVENT_WITH_NOTIFY( EVENT_COMMAND, aCmdEvnt, pWin, Command ) +}; + diff --git a/automation/source/server/statemnt.cxx b/automation/source/server/statemnt.cxx new file mode 100644 index 000000000000..60b4fcac9c5d --- /dev/null +++ b/automation/source/server/statemnt.cxx @@ -0,0 +1,5928 @@ +/************************************************************************* + * + * $RCSfile: statemnt.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: mh $ $Date: 2002-11-18 15:29:08 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2002 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2002 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2002 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _COM_SUN_STAR_FRAME_XFRAMESSUPPLIER_HPP_ +#include <com/sun/star/frame/XFramesSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_XDISPATCH_HPP_ +#include <com/sun/star/frame/XDispatch.hpp> +#endif +#ifndef _COM_SUN_STAR_FRAME_XDISPATCHPROVIDER_HPP_ +#include <com/sun/star/frame/XDispatchProvider.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XURLTRANSFORMER_HPP_ +#include <com/sun/star/util/XURLTransformer.hpp> +#endif +#ifndef _COMPHELPER_PROCESSFACTORY_HXX_ +#include <comphelper/processfactory.hxx> +#endif + +#ifndef _DIALOG_HXX //autogen +#include <vcl/dialog.hxx> +#endif +#ifndef _BUTTON_HXX //autogen +#include <vcl/button.hxx> +#endif +#ifndef _SV_MENUBTN_HXX //autogen +#include <vcl/menubtn.hxx> +#endif +#ifndef _SVTREEBOX_HXX //autogen +#include <svtools/svtreebx.hxx> +#endif +#ifndef _SVX_BRWBOX_HXX //autogen +#include <svtools/brwbox.hxx> +#endif +#ifndef _MSGBOX_HXX //autogen +#include <vcl/msgbox.hxx> +#endif +#ifndef _DOCKWIN_HXX //autogen +#include <vcl/dockwin.hxx> +#endif +#ifndef _FLOATWIN_HXX //autogen +#include <vcl/floatwin.hxx> +#endif +#ifndef _LSTBOX_HXX //autogen +#include <vcl/lstbox.hxx> +#endif +#ifndef _COMBOBOX_HXX //autogen +#include <vcl/combobox.hxx> +#endif +#ifndef _MOREBTN_HXX //autogen +#include <vcl/morebtn.hxx> +#endif +#ifndef _FIELD_HXX //autogen +#include <vcl/field.hxx> +#endif +#ifndef _TOOLBOX_HXX //autogen +#include <vcl/toolbox.hxx> +#endif +#ifndef _SV_TABCTRL_HXX //autogen +#include <vcl/tabctrl.hxx> +#endif +#ifndef _SV_TABPAGE_HXX //autogen +#include <vcl/tabpage.hxx> +#endif +#ifndef _SV_MENU_HXX //autogen +#include <vcl/menu.hxx> +#endif +#ifndef _SV_STATUS_HXX //autogen +#include <vcl/status.hxx> +#endif +#ifndef _PRGSBAR_HXX +#include <svtools/prgsbar.hxx> +#endif +#ifndef _SVTOOLS_EDITBROWSEBOX_HXX_ +#include <svtools/editbrowsebox.hxx> +#endif +#ifndef _SV_SPLITWIN_HXX //autogen +#include <vcl/splitwin.hxx> +#endif +#ifndef _SV_GROUP_HXX //autogen +#include <vcl/group.hxx> +#endif +#ifndef _SV_FIXED_HXX //autogen +#include <vcl/fixed.hxx> +#endif +#ifndef _SV_WRKWIN_HXX //handmade +#include <vcl/wrkwin.hxx> +#endif +#ifndef _OSL_DIAGNOSE_H_ //handmade +#include <osl/diagnose.h> +#endif + +#ifndef _SV_WINTYPES_HXX //autogen +#include <vcl/wintypes.hxx> +#endif +#ifndef _VALUESET_HXX //autogen +#include <svtools/valueset.hxx> +#endif +#ifndef _SFXPOOLITEM_HXX //autogen +#include <svtools/poolitem.hxx> +#endif +// Hat keinen Includeschutz +#include <svtools/svtdata.hxx> + +#ifndef _TIME_HXX //autogen +#include <tools/time.hxx> +#endif +#ifndef _SVTOOLS_STRINGTRANSFER_HXX_ +#include <svtools/stringtransfer.hxx> +#endif +#ifndef _PRINT_HXX //autogen +#include <vcl/print.hxx> +#endif +#ifndef _PRNDLG_HXX //autogen +#include <vcl/prndlg.hxx> +#endif +#ifndef _STREAM_HXX //autogen +#include <tools/stream.hxx> +#endif +#ifndef _SV_DRAG_HXX //autogen +//#include <vcl/drag.hxx> +#endif +#ifndef _FSYS_HXX //autogen +#include <tools/fsys.hxx> +#endif +#ifndef _SFXSTRITEM_HXX //autogen +#include <svtools/stritem.hxx> +#endif +#ifndef _SVTOOLS_TTPROPS_HXX // handmade +#include <svtools/ttprops.hxx> +#endif +#ifndef _BASIC_TTRESHLP_HXX +#include <basic/ttstrhlp.hxx> +#endif +#ifndef _BASIC_DISPDEFS_HXX +#include <basic/dispdefs.hxx> +#endif +#include <vos/socket.hxx> +#include <svtools/pickerhistory.hxx> +#include <com/sun/star/util/XCancellable.hpp> + +#include <sot/storage.hxx> +#include <sot/storinfo.hxx> + +#ifndef _STATEMNT_HXX +#include "statemnt.hxx" +#endif + +#ifndef _SCMDSTRM_HXX +#include "scmdstrm.hxx" +#endif + +#ifndef _RETSRTM_HXX +#include "retstrm.hxx" +#endif + +#ifdef DEBUG +#ifndef _EDITWIN_HXX +#include "editwin.hxx" +#endif +#endif + +#ifndef _RCONTROL_HXX +#include "rcontrol.hxx" +#endif + +#ifndef _COMMUNI_HXX +#include <svtools/communi.hxx> +#endif + +#ifndef SVTOOLS_TESTTOOL_HXX +#include "testtool.hxx" +#endif + +#include "profiler.hxx" + +#include "testtool.hrc" +#include "svtools/svtmsg.hrc" + +#include <algorithm> + + +using namespace com::sun::star::frame; +using namespace com::sun::star::uno; +using namespace com::sun::star::util; +using namespace com::sun::star::beans; +using namespace svt; + + +#ifndef SBX_VALUE_DECL_DEFINED +#define SBX_VALUE_DECL_DEFINED +SV_DECL_REF(SbxValue) +#endif +SV_IMPL_REF(SbxValue) + +CommunicationLink *StatementFlow::pCommLink = NULL; +BOOL StatementFlow::bUseIPC = TRUE; +BOOL StatementFlow::bSending = FALSE; +ImplRemoteControl *StatementFlow::pRemoteControl = NULL; + +USHORT StatementCommand::nDirPos = 0; +Dir *StatementCommand::pDir = NULL; +pfunc_osl_printDebugMessage StatementCommand::pOriginal_osl_DebugMessageFunc = NULL; + + + +#define SET_WINP_CLOSING(pWin) \ + pWindowWaitPointer = pWin; \ + nWindowWaitUId = pControl->GetUniqueOrHelpId(); \ + nWindowWaitOldHelpId = pWin->GetHelpId(); \ + nWindowWaitOldUniqueId = pWin->GetUniqueId(); \ + pWin->SetHelpId(4321); \ + pWin->SetUniqueId(1234); + +// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +StatementFlow::StatementFlow( StatementList *pAfterThis, USHORT nArtP ) +: bBool1(FALSE) +, nArt(nArtP) +, nParams(0) +, aString1() +{ + QueStatement( pAfterThis ); +} + +StatementFlow::StatementFlow( ULONG nServiceId, SCmdStream *pCmdIn, ImplRemoteControl *pRC ) +: bBool1(FALSE) +{ + QueStatement( NULL ); + bUseIPC = (nServiceId == SI_IPCCommandBlock); + pRemoteControl = pRC; + pCmdIn->Read( nArt ); + pCmdIn->Read( nParams ); + + if( nParams & PARAM_USHORT_1 ) pCmdIn->Read( nSNr1 ); + if( nParams & PARAM_ULONG_1 ) pCmdIn->Read( nLNr1 ); + if( nParams & PARAM_STR_1 ) pCmdIn->Read( aString1 ); + if( nParams & PARAM_BOOL_1 ) pCmdIn->Read( bBool1 ); // sollte nie auftreten!! + +#ifdef DEBUG + m_pDbgWin->AddText( "Reading FlowControl: " ); + m_pDbgWin->AddText( String::CreateFromInt32( nArt ) ); + m_pDbgWin->AddText( " Params:" ); + if( nParams & PARAM_USHORT_1 ) {m_pDbgWin->AddText( " n1:" );m_pDbgWin->AddText( String::CreateFromInt32( nSNr1 ) );} + if( nParams & PARAM_ULONG_1 ) {m_pDbgWin->AddText( " l1:" );m_pDbgWin->AddText( String::CreateFromInt64( nLNr1 ) );} + if( nParams & PARAM_STR_1 ) {m_pDbgWin->AddText( " s1:" );m_pDbgWin->AddText( aString1 );} + if( nParams & PARAM_BOOL_1 ) {m_pDbgWin->AddText( " b2:" );m_pDbgWin->AddText( bBool1 ? "TRUE" : "FALSE" );} + m_pDbgWin->AddText( "\n" ); +#endif +} + +void StatementFlow::SendViaSocket() +{ + if ( bSending ) + { +#ifdef DEBUG + m_pDbgWin->AddText( "SendViaSocket rekursiv aufgerufen. Abgebrochen!!!\n" ); +#endif + DBG_ERROR("SendViaSocket rekursiv aufgerufen. Abgebrochen!!!"); + return; + } + bSending = TRUE; + if ( pCommLink ) + { + if ( !pCommLink->TransferDataStream( pRet->GetStream() ) ) // tritt ein Fehler auf, so wird sofort gelöscht ... + pCommLink = NULL; + } + else + { + // Macht nix. Wenn das Basic nicht mehr da ist, ist sowiso alles egal + DBG_ERROR("Rückmeldung an Basic Fehlgeschlagen") + } + + pRet->Reset(); + bSending = FALSE; + IsError = FALSE; +} + +BOOL StatementFlow::Execute() +{ +#ifdef DEBUG + m_pDbgWin->AddText( "Executing Flow: " ); + m_pDbgWin->AddText( String::CreateFromInt32( nArt ) ); + m_pDbgWin->AddText( "\n" ); +#endif + switch ( nArt ) + { + case F_EndCommandBlock: + { + + if ( !bUseIPC ) + { + // bBool1 wurde im CTOR auf FALSE initialisiert + if ( !bBool1 ) // also erster Durchlauf + { + pRemoteControl->pRetStream = pRet->GetStream(); + bBool1 = TRUE; // wurde im CTOR auf FALSE initialisiert + nRetryCount = nRetryCount * 4; + } + if ( pRemoteControl->pRetStream && (nRetryCount--) ) // also solange nicht abgeholt + { + return FALSE; // Bitte einmal vom Callstack runter + } + } + + } + break; + } + + Advance(); + switch ( nArt ) + { + case F_EndCommandBlock: + if ( !bUseIPC ) + { // wird oben abgehandelt + pRet->Reset(); + IsError = FALSE; + } + else + SendViaSocket(); + + break; + + case F_Sequence: + + pRet->GenReturn(RET_Sequence,nLNr1); + #ifdef DEBUG + m_pDbgWin->AddText( "Sending Sequence Nr: " ); + m_pDbgWin->AddText( String::CreateFromInt64( nLNr1 ) ); + m_pDbgWin->AddText( "\n" ); + #endif + + break; +// case RET_: + default: + DBG_ERROR( "Unbekannter Flowcontrol" ); + break; + } + + delete this; + return TRUE; +} + +// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +// neue Hilfsfunktion, die stetig erweitert werden muss +static short ImpGetRType( Window *pWin, ULONG nUId ) +{ + // GGGg gggg::gggg gggg::ggLL LLLl::llll llll + DBG_ASSERT( pWin, "missing Parameter" ); + short nRT; + if( (nUId & 0xE0000000) == 0 ) // keine auto ID + nRT = C_NoType; + else { +// if( (nUId & 0x1F) == 0 ) // globale Resource + if( (nUId & 0x1FF) == 0 ) // globale Resource GH: soweit ich das verstanden habe 1FF + nRT = (short)(C_TabPage - 1 + (nUId >> 29)); + else + nRT = (short)((nUId & 0x00003E00) >> 9); + if ( nRT == C_TabPage ) // wegen TabDialog.UId = TabPage.UId + nRT = C_NoType; + else + { +#ifndef DBG_UTIL + return nRT; +#endif + } + } + +#ifdef DBG_UTIL + short n = nRT; +#endif + WindowType eRT = pWin->GetType(); + switch( eRT ) { + case WINDOW_WINDOW: nRT = C_Window ; break; + + case WINDOW_TABCONTROL: nRT = C_TabControl ; break; + case WINDOW_RADIOBUTTON: nRT = C_RadioButton ; break; + case WINDOW_CHECKBOX: nRT = C_CheckBox ; break; + case WINDOW_TRISTATEBOX: nRT = C_TriStateBox ; break; + case WINDOW_EDIT: nRT = C_Edit ; break; + case WINDOW_MULTILINEEDIT: nRT = C_MultiLineEdit ; break; + case WINDOW_MULTILISTBOX: nRT = C_MultiListBox ; break; + case WINDOW_LISTBOX: nRT = C_ListBox ; break; + case WINDOW_COMBOBOX: nRT = C_ComboBox ; break; + case WINDOW_PUSHBUTTON: nRT = C_PushButton ; break; + case WINDOW_SPINFIELD: nRT = C_SpinField ; break; + case WINDOW_PATTERNFIELD: nRT = C_PatternField ; break; + case WINDOW_NUMERICFIELD: nRT = C_NumericField ; break; + case WINDOW_METRICFIELD: nRT = C_MetricField ; break; + case WINDOW_CURRENCYFIELD: nRT = C_CurrencyField ; break; + case WINDOW_DATEFIELD: nRT = C_DateField ; break; + case WINDOW_TIMEFIELD: nRT = C_TimeField ; break; + case WINDOW_IMAGERADIOBUTTON: nRT = C_ImageRadioButton ; break; + case WINDOW_NUMERICBOX: nRT = C_NumericBox ; break; + case WINDOW_METRICBOX: nRT = C_MetricBox ; break; + case WINDOW_CURRENCYBOX: nRT = C_CurrencyBox ; break; + case WINDOW_DATEBOX: nRT = C_DateBox ; break; + case WINDOW_TIMEBOX: nRT = C_TimeBox ; break; + case WINDOW_IMAGEBUTTON: nRT = C_ImageButton ; break; + case WINDOW_MENUBUTTON: nRT = C_MenuButton ; break; + case WINDOW_MOREBUTTON: nRT = C_MoreButton ; break; + + + case WINDOW_TABPAGE: nRT = C_TabPage; break; + case WINDOW_MODALDIALOG: nRT = C_Dlg; break; + case WINDOW_FLOATINGWINDOW: nRT = C_FloatWin; break; + case WINDOW_MODELESSDIALOG: nRT = C_ModelessDlg; break; + case WINDOW_WORKWINDOW: nRT = C_WorkWin; break; + case WINDOW_DOCKINGWINDOW: nRT = C_DockingWin; break; + + case WINDOW_MESSBOX: nRT = C_MessBox; break; + case WINDOW_INFOBOX: nRT = C_InfoBox; break; + case WINDOW_WARNINGBOX: nRT = C_WarningBox; break; + case WINDOW_ERRORBOX: nRT = C_ErrorBox; break; + case WINDOW_QUERYBOX: nRT = C_QueryBox; break; +#if 0 //ifndef VCL + case WINDOW_FILEDIALOG: nRT = C_FileDlg; break; + case WINDOW_PATHDIALOG: nRT = C_PathDlg; break; + case WINDOW_PRINTDIALOG: nRT = C_PrintDlg; break; + case WINDOW_PRINTERSETUPDIALOG: nRT = C_PrinterSetupDlg;break; + case WINDOW_COLORDIALOG: nRT = C_ColorDlg; break; +#endif + case WINDOW_TABDIALOG: nRT = C_TabDlg; break; +// case WINDOW_TABDIALOG: nRT = C_SingleTabDlg; break; + + case WINDOW_PATTERNBOX: nRT = C_PatternBox; break; + case WINDOW_TOOLBOX: nRT = C_ToolBox; break; +// Gibts nicht case WINDOW_VALUESET: nRT = C_ValueSet; break; + case WINDOW_CONTROL: nRT = C_Control; break; + case WINDOW_OKBUTTON: nRT = C_OkButton; break; + case WINDOW_CANCELBUTTON: nRT = C_CancelButton; break; + case WINDOW_BUTTONDIALOG: nRT = C_ButtonDialog; break; + } +#ifdef DBG_UTIL + // Die Werte n sind bei den WindowTypen nicht mehr vergeben, werden aber in der AutoID noch verwendet + // Sie werden jetzt durch den Typ nRT implementiert. + DBG_ASSERT( n == C_NoType || n == nRT + || ( n == C_ImageButton && nRT == C_PushButton ) + || ( n == C_TriStateBox && nRT == C_CheckBox ) + || ( n == C_ImageRadioButton && nRT == C_RadioButton ) + , "error in algorithm" ); +#endif + return nRT; +} + +// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +StatementSlot::StatementSlot( SCmdStream *pCmdIn ) +: pItemArr(NULL) +{ + QueStatement( NULL ); + pCmdIn->Read( nFunctionId ); +#ifdef DEBUG + m_pDbgWin->AddText( "Reading Slot: " ); + m_pDbgWin->AddText( String::CreateFromInt32( nFunctionId ) ); + m_pDbgWin->AddText( "\n" ); +#endif + pCmdIn->Read( nAnzahl ); + if ( nAnzahl ) + { + switch ( pCmdIn->GetNextType() ) + { + case BinUSHORT: // use old calling method + { + nAnzahl++; + pItemArr = new SfxPoolItem*[nAnzahl]; + for (USHORT i = 0 ; i+1 < nAnzahl ; i++) + pCmdIn->Read( pItemArr[i] ); + pItemArr[nAnzahl-1] = NULL; + } + break; + case BinString: // new Method + { + nAnzahl++; + aArgs.realloc(nAnzahl); + PropertyValue* pArg = aArgs.getArray(); + for (USHORT i = 0 ; i+1 < nAnzahl ; i++) + pCmdIn->Read( pArg[i] ); + pArg[nAnzahl-1].Name = rtl::OUString::createFromAscii("Referer"); + pArg[nAnzahl-1].Value <<= ::rtl::OUString::createFromAscii("private:user"); + } + break; + } + } +} + +StatementSlot::StatementSlot( ULONG nSlot, SfxPoolItem* pItem ) +: pItemArr(NULL) +{ + QueStatement( NULL ); + nFunctionId = nSlot; +#ifdef DEBUG + m_pDbgWin->AddText( "Reading Slot: " ); + m_pDbgWin->AddText( String::CreateFromInt32( nFunctionId ) ); + m_pDbgWin->AddText( "\n" ); +#endif + if ( pItem ) + { + nAnzahl = 2; + pItemArr = new SfxPoolItem*[2]; + pItemArr[0] = pItem; + pItemArr[1] = NULL; + } + else + nAnzahl = 0; +} + +StatementSlot::~StatementSlot() +{ + if (nAnzahl) + { + if ( pItemArr ) + { + for (USHORT i = 0 ; i+1 < nAnzahl ; i++) + delete pItemArr[i]; + __DELETE(nAnzahl) pItemArr; + } + + aArgs.realloc( 0 ); + } +} + +class SlotStatusListener : public cppu::WeakImplHelper1< XStatusListener > +{ +public: + SlotStatusListener(); + + // XStatusListener + virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + // XEventListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); + + // local Members + BOOL bDisposed; + BOOL bEnabled; +}; +/* +struct FeatureStateEvent : public ::com::sun::star::lang::EventObject + ::com::sun::star::util::URL FeatureURL; + ::rtl::OUString FeatureDescriptor; + sal_Bool IsEnabled; + sal_Bool Requery; + ::com::sun::star::uno::Any State; + + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > Source; +*/ + +SlotStatusListener::SlotStatusListener() +: bDisposed( FALSE ) +, bEnabled( FALSE ) +{} + +// XStatusListener +void SAL_CALL SlotStatusListener::statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) +{ +// DBG_ERROR1("FeatureURL: %s", ByteString( String( Event.FeatureURL.Complete ), RTL_TEXTENCODING_UTF8 ).GetBuffer() ) +// DBG_ERROR1("FeatureDescriptor: %s", ByteString( String( Event.FeatureDescriptor ), RTL_TEXTENCODING_UTF8 ).GetBuffer() ) + bEnabled = Event.IsEnabled; +// DBG_ASSERT( Event.IsEnabled, "Not enabled" ) +// DBG_ASSERT( !Event.Requery, "Requery" ) +} + +// XEventListener +void SAL_CALL SlotStatusListener::disposing( const ::com::sun::star::lang::EventObject& Source ) +{ + bDisposed = TRUE; +} + +BOOL StatementSlot::Execute() +{ + if ( IsError ) + { + #ifdef DEBUG + m_pDbgWin->AddText( "Skipping Slot: " ); + m_pDbgWin->AddText( String::CreateFromInt32( nFunctionId ) ); + m_pDbgWin->AddText( "\n" ); + #endif + + Advance(); + delete this; + return TRUE; + } + + InitProfile(); +#ifdef DEBUG + m_pDbgWin->AddText( "Executing Slot: " ); + m_pDbgWin->AddText( String::CreateFromInt32( nFunctionId ) ); + m_pDbgWin->AddText( "\n" ); +#endif + + Advance(); + + if ( !IsError ) + { + if ( ( nAnzahl == 0 && !getenv("OLDSLOTHANDLING") ) || aArgs.hasElements() ) + { // trying to call slots via uno + URL aTargetURL; + aTargetURL.Complete = CUniString("slot:").Append( String::CreateFromInt64( nFunctionId ) ); + Reference < XFramesSupplier > xDesktop = Reference < XFramesSupplier >( ::comphelper::getProcessServiceFactory()->createInstance( CUniString("com.sun.star.frame.Desktop") ), UNO_QUERY ); + Reference < XFrame > xFrame; + + if ( xDesktop.is() ) + { + xFrame = xDesktop->getActiveFrame(); + if ( !xFrame.is() ) + { + Reference < XFrames > xFrames; + xFrames = xDesktop->getFrames(); + if ( xFrames.is() && xFrames->getCount() > 0 ) + { + Any aFrame = xFrames->getByIndex( xFrames->getCount() -1 ); + aFrame >>= xFrame; + } + } + if ( !xFrame.is() ) + { + if ( GetFirstDocWin() ) + GetFirstDocWin()->ToTop(); + xFrame = xDesktop->getActiveFrame(); + } + } + + if ( xFrame.is() ) + xDesktop = Reference < XFramesSupplier >( xFrame, UNO_QUERY ); + else + xDesktop.clear(); + + while ( xDesktop.is() && xDesktop->getActiveFrame().is() ) + { + xFrame = xDesktop->getActiveFrame(); +#ifdef DEBUG + ::rtl::OUString aName; + if ( xFrame.is() ) + aName = xFrame->getName(); +#endif + xDesktop = Reference < XFramesSupplier >( xFrame, UNO_QUERY ); + } + + if ( !xFrame.is() ) + ReportError( GEN_RES_STR1( S_UNO_URL_EXECUTE_FAILED_NO_FRAME, aTargetURL.Complete ) ); + else + { + Reference < XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance( CUniString("com.sun.star.util.URLTransformer" )), UNO_QUERY ); + xTrans->parseStrict( aTargetURL ); + + Reference < XDispatchProvider > xProv( xFrame, UNO_QUERY ); + Reference < XDispatch > xDisp; + while ( xProv.is() && !xDisp.is() ) + { + xDisp = xProv->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); + if ( !xDisp.is() ) + { + xFrame = Reference < XFrame > ( xFrame->getCreator(), UNO_QUERY ); + xProv = Reference < XDispatchProvider > ( xFrame, UNO_QUERY ); + } + } + + if ( xDisp.is() ) + { + Reference < XStatusListener > xListener = ( XStatusListener* )new SlotStatusListener; + xDisp->addStatusListener( xListener, aTargetURL ); + if ( ((SlotStatusListener*)xListener.get())->bEnabled ) + xDisp->dispatch( aTargetURL, aArgs ); + else + ReportError( GEN_RES_STR1( S_UNO_URL_EXECUTE_FAILED_DISABLED, aTargetURL.Complete ) ); + xDisp->removeStatusListener( xListener, aTargetURL ); + } + else + ReportError( GEN_RES_STR1( S_UNO_URL_EXECUTE_FAILED_NO_DISPATCHER, aTargetURL.Complete ) ); + } + } + else + { + if ( !pTTProperties ) + pTTProperties = new TTProperties(); + + switch ( pTTProperties->ExecuteFunction( nFunctionId, pItemArr, EXECUTEMODE_DIALOGASYNCHRON | nUseBindings ) ) + { + case TT_PR_ERR_NODISPATCHER: + { + ReportError(nFunctionId, GEN_RES_STR0( S_SID_EXECUTE_FAILED_NO_DISPATCHER ) ); + } + break; + case TT_PR_ERR_NOEXECUTE: + { + ReportError(nFunctionId, GEN_RES_STR0( S_SID_EXECUTE_FAILED ) ); + } + break; + } + } + } + + +/* Neues Verfahren ab 334! + Neue Methode zum einstellen, daß Modale Dialoge immer Asynchron aufgerufen werden + und echter Returnwert, ob Slot geklappt hat + und Testen ob Slot überhaupt durch UI aufgerufen werden kann */ + + + SendProfile( SlotString( nFunctionId ) ); + delete this; + return TRUE; +} + +// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +StatementUnoSlot::StatementUnoSlot(SCmdStream *pIn) +{ + QueStatement( NULL ); + + pIn->Read( aUnoUrl ); + +/* if ( !pTTProperties ) + pTTProperties = new TTProperties(); + if ( !pTTProperties->GetSlots() ) + { + ReportError( GEN_RES_STR0( S_UNO_PROPERTY_NITIALIZE_FAILED ) ); + } + nFunctionId = pTTProperties->nSidOpenUrl; + + nAnzahl = 3; + pItemArr = new SfxPoolItem*[nAnzahl]; + + pItemArr[0] = new SfxStringItem( pTTProperties->nSidFileName, aUnoUrl ); + pItemArr[1] = new SfxStringItem( pTTProperties->nSidReferer, CUniString("private:testtool/") ); + pItemArr[2] = NULL; + + */ +#ifdef DEBUG + StatementList::m_pDbgWin->AddText( "UnoUrl:" ); + StatementList::m_pDbgWin->AddText( aUnoUrl ); + StatementList::m_pDbgWin->AddText( "\n" ); +#endif + +} + +BOOL StatementUnoSlot::Execute() +{ + if ( IsError ) + { + #ifdef DEBUG + m_pDbgWin->AddText( "Skipping UnoSlot: " ); + m_pDbgWin->AddText( aUnoUrl ); + m_pDbgWin->AddText( "\n" ); + #endif + + Advance(); + delete this; + return TRUE; + } + + InitProfile(); +#ifdef DEBUG + m_pDbgWin->AddText( "Executing UnoSlot: " ); + m_pDbgWin->AddText( aUnoUrl ); + m_pDbgWin->AddText( "\n" ); +#endif + + Advance(); + + if ( !IsError ) + { + Reference < XFramesSupplier > xDesktop = Reference < XFramesSupplier >( ::comphelper::getProcessServiceFactory()->createInstance( CUniString("com.sun.star.frame.Desktop") ), UNO_QUERY ); + Reference < XFrame > xFrame( xDesktop->getActiveFrame() ); + if ( !xFrame.is() ) + { + ReportError( GEN_RES_STR1( S_UNO_URL_EXECUTE_FAILED_NO_FRAME, aUnoUrl ) ); + DBG_ERROR("Where's my task?!"); + } + else + { + + URL aTargetURL; + aTargetURL.Complete = aUnoUrl; + Reference < XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance( CUniString("com.sun.star.util.URLTransformer" )), UNO_QUERY ); + xTrans->parseStrict( aTargetURL ); + + Reference < XDispatchProvider > xProv( xFrame, UNO_QUERY ); + Reference < XDispatch > xDisp; + /* + addStatusListener ( XStatusListener, URL ); + callback und dann testen ob disabled + */ + if ( xProv.is() ) + xDisp = xProv->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); + if ( xDisp.is() ) + { + Sequence<PropertyValue> aArgs(1); + PropertyValue* pArg = aArgs.getArray(); + pArg[0].Name = rtl::OUString::createFromAscii("Referer"); + pArg[0].Value <<= ::rtl::OUString::createFromAscii("private:user"); + xDisp->dispatch( aTargetURL, aArgs ); + } + else + ReportError( GEN_RES_STR1( S_UNO_URL_EXECUTE_FAILED_NO_DISPATCHER, aUnoUrl ) ); + } + } + + SendProfile( aUnoUrl ); + delete this; + return TRUE; +} + +// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +StatementCommand::StatementCommand( SCmdStream *pCmdIn ) +: bBool1(FALSE) +, bBool2(FALSE) +, nLNr1(0) +{ + QueStatement( NULL ); + pCmdIn->Read( nMethodId ); + pCmdIn->Read( nParams ); + + if( nParams & PARAM_USHORT_1 ) pCmdIn->Read( nNr1 ); + if( nParams & PARAM_USHORT_2 ) pCmdIn->Read( nNr2 ); + if( nParams & PARAM_USHORT_3 ) pCmdIn->Read( nNr3 ); + if( nParams & PARAM_USHORT_4 ) pCmdIn->Read( nNr4 ); + if( nParams & PARAM_ULONG_1 ) pCmdIn->Read( nLNr1 ); + if( nParams & PARAM_STR_1 ) pCmdIn->Read( aString1 ); + if( nParams & PARAM_STR_2 ) pCmdIn->Read( aString2 ); + if( nParams & PARAM_BOOL_1 ) pCmdIn->Read( bBool1 ); + if( nParams & PARAM_BOOL_2 ) pCmdIn->Read( bBool2 ); + +#ifdef DEBUG + m_pDbgWin->AddText( "Reading Conmmand:" ); + m_pDbgWin->AddText( " Methode: " ); + m_pDbgWin->AddText( String::CreateFromInt32( nMethodId ) ); + m_pDbgWin->AddText( " Params:" ); + if( nParams & PARAM_USHORT_1 ) {m_pDbgWin->AddText( " n1:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr1 ) );} + if( nParams & PARAM_USHORT_2 ) {m_pDbgWin->AddText( " n2:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr2 ) );} + if( nParams & PARAM_USHORT_3 ) {m_pDbgWin->AddText( " n3:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr3 ) );} + if( nParams & PARAM_USHORT_4 ) {m_pDbgWin->AddText( " n4:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr4 ) );} + if( nParams & PARAM_ULONG_1 ) {m_pDbgWin->AddText( " nl1:" );m_pDbgWin->AddText( String::CreateFromInt64( nLNr1 ) );} + if( nParams & PARAM_STR_1 ) {m_pDbgWin->AddText( " s1:" );m_pDbgWin->AddText( aString1 );} + if( nParams & PARAM_STR_2 ) {m_pDbgWin->AddText( " s2:" );m_pDbgWin->AddText( aString2 );} + if( nParams & PARAM_BOOL_1 ) {m_pDbgWin->AddText( " b1:" );m_pDbgWin->AddText( bBool1 ? "TRUE" : "FALSE" );} + if( nParams & PARAM_BOOL_2 ) {m_pDbgWin->AddText( " b2:" );m_pDbgWin->AddText( bBool2 ? "TRUE" : "FALSE" );} + m_pDbgWin->AddText( "\n" ); +#endif + + if ( nMethodId == RC_AppAbort ) + { + #ifdef DEBUG + m_pDbgWin->AddText( "*Deleting all Commands:\n" ); + #endif + bReadingCommands = FALSE; + while ( StatementList::pFirst != this ) // Alles Löschen außer mich selbst + { + StatementList *pDeQue = StatementList::pFirst; + pDeQue->Advance(); + delete pDeQue; + } + bReadingCommands = TRUE; + #ifdef DEBUG + m_pDbgWin->AddText( "*Done deleting all Commands:\n" ); + #endif + } + +} + +void StatementCommand::WriteControlData( Window *pBase, ULONG nConf, BOOL bFirst ) +{ + + if ( IsDialog(pBase) && !bFirst ) + return; + + if ( bFirst ) + pRet->GenReturn ( RET_WinInfo, nConf | DH_MODE_DATA_VALID, (ULONG)0, UniString(), TRUE ); + + { // Klammerung, so daß der String nicht während der Rekursion bestehen bleibt + String aName; + BOOL bSkip = FALSE; + + switch ( pBase->GetType() ) + { + case WINDOW_RADIOBUTTON: + case WINDOW_CHECKBOX: + case WINDOW_TRISTATEBOX: + case WINDOW_PUSHBUTTON: + case WINDOW_OKBUTTON: + case WINDOW_CANCELBUTTON: + case WINDOW_IMAGERADIOBUTTON: + case WINDOW_IMAGEBUTTON: + case WINDOW_MENUBUTTON: + case WINDOW_MOREBUTTON: + case WINDOW_TABPAGE: + case WINDOW_MODALDIALOG: + case WINDOW_FLOATINGWINDOW: + case WINDOW_MODELESSDIALOG: + case WINDOW_WORKWINDOW: + case WINDOW_DOCKINGWINDOW: + case WINDOW_CONTROL: + + case WINDOW_FILEDIALOG: + case WINDOW_PATHDIALOG: + case WINDOW_PRINTDIALOG: + case WINDOW_PRINTERSETUPDIALOG: + case WINDOW_COLORDIALOG: + case WINDOW_TABDIALOG: + + case WINDOW_BUTTONDIALOG: + aName = pBase->GetText().EraseAllChars('~'); + break; + + case WINDOW_EDIT: + case WINDOW_MULTILINEEDIT: + case WINDOW_MULTILISTBOX: + case WINDOW_LISTBOX: + case WINDOW_COMBOBOX: + case WINDOW_SPINFIELD: + case WINDOW_PATTERNFIELD: + case WINDOW_NUMERICFIELD: + case WINDOW_METRICFIELD: + case WINDOW_CURRENCYFIELD: + case WINDOW_DATEFIELD: + case WINDOW_TIMEFIELD: + case WINDOW_NUMERICBOX: + case WINDOW_METRICBOX: + case WINDOW_CURRENCYBOX: + case WINDOW_DATEBOX: + case WINDOW_TIMEBOX: + case WINDOW_PATTERNBOX: + case WINDOW_TOOLBOX: + aName = pBase->GetQuickHelpText(); + break; + + case WINDOW_MESSBOX: + case WINDOW_INFOBOX: + case WINDOW_WARNINGBOX: + case WINDOW_ERRORBOX: + case WINDOW_QUERYBOX: + aName = ((MessBox*)pBase)->GetMessText(); + break; + + default: + if ( pBase->GetUniqueOrHelpId() == 0 && !( nConf & DH_MODE_ALLWIN ) ) + bSkip = TRUE; + } + + if ( !bSkip ) + { + if ( aName.Len() == 0 ) + aName = pBase->GetQuickHelpText(); + if ( aName.Len() == 0 ) + aName = pBase->GetHelpText(); + if ( aName.Len() == 0 ) + aName = pBase->GetText(); + + pRet->GenReturn ( RET_WinInfo, pBase->GetUniqueOrHelpId(), (ULONG)pBase->GetType(), + TypeString(pBase->GetType()).AppendAscii(": ").Append(aName), FALSE ); + + + + + + if ( pBase->GetType() == WINDOW_TOOLBOX ) // Buttons und Controls auf Toolboxen. + { + ToolBox *pTB = ((ToolBox*)pBase); + int i; + for ( i = 0; i < pTB->GetItemCount() ; i++ ) + { + aName = String(); +// if ( aName.Len() == 0 ) +// aName = pTB->GetQuickHelpText(); + if ( aName.Len() == 0 ) + aName = pTB->GetHelpText( pTB->GetItemId( i ) ); + if ( aName.Len() == 0 ) + aName = pTB->GetItemText( pTB->GetItemId( i ) ); + + Window *pItemWin; + pItemWin = pTB->GetItemWindow( pTB->GetItemId( i ) ); + if ( pTB->GetItemType( i ) == TOOLBOXITEM_BUTTON && ( !pItemWin || !pItemWin->IsVisible() ) ) + { + pRet->GenReturn ( RET_WinInfo, pTB->GetHelpId(pTB->GetItemId( i )), (ULONG)WINDOW_BUTTON, + TypeString(WINDOW_BUTTON).AppendAscii(": ").Append(aName), FALSE ); + } + else + { + if ( pItemWin ) + { + pRet->GenReturn ( RET_WinInfo, pTB->GetHelpId(pTB->GetItemId( i )), (ULONG)pItemWin->GetType(), + TypeString(pItemWin->GetType()).AppendAscii(": ").Append(aName), FALSE ); + for( int i = 0 ; i < pItemWin->GetChildCount(); i++ ) + WriteControlData( pItemWin->GetChild(i), nConf, FALSE ); + } + else + { + if ( nConf & DH_MODE_ALLWIN ) + { + String aToolBoxItemType; + switch ( pTB->GetItemType( i ) ) + { + case TOOLBOXITEM_DONTKNOW: + aToolBoxItemType.AssignAscii("TOOLBOXITEM_DONTKNOW"); + break; + case TOOLBOXITEM_BUTTON: + aToolBoxItemType.AssignAscii("TOOLBOXITEM_BUTTON"); + break; + case TOOLBOXITEM_SPACE: + aToolBoxItemType.AssignAscii("TOOLBOXITEM_SPACE"); + break; + case TOOLBOXITEM_SEPARATOR: + aToolBoxItemType.AssignAscii("TOOLBOXITEM_SEPARATOR"); + break; + case TOOLBOXITEM_BREAK: + aToolBoxItemType.AssignAscii("TOOLBOXITEM_BREAK"); + break; + default: + DBG_ERROR1( "Unknown TOOLBOXITEM %i", pTB->GetItemType( i ) ); + } + pRet->GenReturn ( RET_WinInfo, pTB->GetHelpId(pTB->GetItemId( i )), (ULONG)WINDOW_BASE, + aToolBoxItemType.AppendAscii(": ").Append(aName), FALSE ); + } + } + } + } + + return; // ToolBox ist hier schon komplett abgehandelt. + } + + + if ( pBase->GetType() == WINDOW_BUTTONDIALOG // Buttons auf Buttondialogen mit ID + || pBase->GetType() == WINDOW_MESSBOX + || pBase->GetType() == WINDOW_INFOBOX + || pBase->GetType() == WINDOW_WARNINGBOX + || pBase->GetType() == WINDOW_ERRORBOX + || pBase->GetType() == WINDOW_QUERYBOX ) + { + ButtonDialog *pBD = ((ButtonDialog*)pBase); + int i; + for ( i = 0; i < pBD->GetButtonCount() ; i++ ) + { + aName = String(); + if ( aName.Len() == 0 ) + aName = pBD->GetPushButton( pBD->GetButtonId(i) )->GetText(); + String aID; + switch ( pBD->GetButtonId(i) ) + { + case BUTTONID_OK: + aID.AssignAscii("Ok"); + break; + case BUTTONID_CANCEL: + aID.AssignAscii("Cancel"); + break; + case BUTTONID_YES: + aID.AssignAscii("Yes"); + break; + case BUTTONID_NO: + aID.AssignAscii("No"); + break; + case BUTTONID_RETRY: + aID.AssignAscii("Retry"); + break; + case BUTTONID_HELP: + aID.AssignAscii("Help"); + break; + default: + aID = UniString::CreateFromInt32( pBD->GetButtonId(i) ); + break; + } + + pRet->GenReturn ( RET_WinInfo, 1, (ULONG)pBD->GetPushButton( pBD->GetButtonId(i) )->GetType(), // So daß der Text angezeigt wird! + TypeString(pBD->GetPushButton( pBD->GetButtonId(i) )->GetType()).AppendAscii(": ").Append(aName) + .AppendAscii(" ButtonId = ").Append(aID), FALSE ); + } + + return; // ButtonDialog ist hier schon komplett abgehandelt. + } + } + } + + for( int i = 0 ; i < pBase->GetChildCount(); i++ ) + WriteControlData( pBase->GetChild(i), nConf, FALSE ); +} + +class SysWinContainer : public WorkWindow +{ +private: + ToolBox *pClientWin; + DockingWindow *pDock; +public: + SysWinContainer( ToolBox *pClient ); + ~SysWinContainer(); + virtual void Resize(); + virtual void Resizing( Size& rSize ); +}; + +SysWinContainer::SysWinContainer( ToolBox *pClient ) +: WorkWindow( NULL, WB_BORDER | WB_SIZEMOVE | WB_CLOSEABLE ) +, pClientWin( pClient ) +{ + pDock = new DockingWindow( this ); + pClientWin->SetParent( pDock ); + pClientWin->SetFloatingMode( FALSE ); + SetText( pClient->GetText() ); + SetPosPixel( Point( 1,40 ) ); + Resize(); + pDock->Show(); + EnableAlwaysOnTop(); + Show(); +} + +SysWinContainer::~SysWinContainer() +{ + delete pDock; +} + +void SysWinContainer::Resize() +{ + Size aSize( GetOutputSizePixel() ); + Resizing( aSize ); +// aSize = pClientWin->GetSizePixel(); +// aSize = pClientWin->CalcWindowSizePixel(); + if ( aSize != GetSizePixel() ) + { + SetOutputSizePixel( aSize ); + pDock->SetSizePixel( aSize ); + pClientWin->SetSizePixel( aSize ); + } +} + +void SysWinContainer::Resizing( Size& rSize ) +{ + Size aSize; + Size aBestSize; + int i; + BOOL bHasValue = FALSE; + ULONG nBestValue; + ULONG nThisValue; + for ( i=1 ; i<=1 ; i++ ) + { + aSize = pClientWin->CalcWindowSizePixel( i ); + nThisValue = Abs( aSize.Width() - rSize.Width() ) + Abs( aSize.Height() - rSize.Height() ); + if ( !bHasValue || ( nThisValue < nBestValue ) ) + { + nBestValue = nThisValue; + aBestSize = aSize; + bHasValue = TRUE; + } + } + rSize = aBestSize; +} + + +class DisplayHidWin : public ToolBox +{ + Edit *pEdit; + Size aMinEditSize; + USHORT nLastItemID; + BOOL bIsDraging; + BOOL bIsPermanentDraging; + void SetDraging( BOOL bNewDraging ); + Image *pShow, *pShow2; + BOOL bConfigChanged; + void EnableButtons( ULONG nConf ); + + // aborting by pressing shist twice + BOOL bOldShift; + Time aLatest; + USHORT nShiftCount; + + ULONG nEventHookID; + static long stub_VCLEventHookProc( NotifyEvent& rEvt, void* pData ) + { + return ((DisplayHidWin*)pData)->VCLEventHook( rEvt ); + } + + long VCLEventHook( NotifyEvent& rEvt ); + Window *pLastMouseMoveWin; + + SysWinContainer *pContainer; + +public: + DisplayHidWin(); + ~DisplayHidWin(); + + virtual void Tracking( const TrackingEvent& rTEvt ); + virtual void Click(); + virtual void Select(); + virtual void SetText( const XubString& rStr ); + + void SetDisplayText( const String &aNewText ){ pEdit->SetText(aNewText); } + const String GetDisplayText(){ return pEdit->GetText(); } + const BOOL IsDisplayTextModified(){ return pEdit->IsModified(); } + const void ClearDisplayTextModified(){ pEdit->ClearModifyFlag(); } + + void SetConfig( ULONG nConf ); + ULONG GetConfig(); + + BOOL IsConfigChanged() { return bConfigChanged; } + void ConfigSent() { bConfigChanged = FALSE; } + + BOOL IsSendData() { return GetItemState( TT_SEND_DATA ) == STATE_CHECK; } +// BOOL IsAllWin() { return GetItemState( TT_ALLWIN ) == STATE_CHECK; } + + BOOL IsDraging() { return bIsDraging; } + + Window* LastMouseMoveWin() { return pLastMouseMoveWin; } +}; + +DisplayHidWin::DisplayHidWin() +: ToolBox( StatementList::GetFirstDocWin(), TTProperties::GetSvtResId(DisplayHidToolBox) ) +, bIsDraging( FALSE ) +, bIsPermanentDraging( FALSE ) +, pShow( NULL ) +, pShow2( NULL ) +, pLastMouseMoveWin( NULL ) +, bOldShift( 0 ) +, nShiftCount( 0 ) +{ + SetOutStyle( TOOLBOX_STYLE_HANDPOINTER | TOOLBOX_STYLE_FLAT ); + pEdit = new Edit( this, WB_CENTER | WB_BORDER ); + aMinEditSize = GetItemRect( TT_OUTPUT ).GetSize(); +/**/ aMinEditSize=Size(20,20); + aMinEditSize.Width() *= 12; + pEdit->SetSizePixel( aMinEditSize ); + pEdit->Show(); + SetItemWindow( TT_OUTPUT, pEdit ); + Resize(); + pContainer = new SysWinContainer( this ); + nEventHookID = Application::AddEventHook( stub_VCLEventHookProc, this ); +} + +DisplayHidWin::~DisplayHidWin() +{ + Application::RemoveEventHook( nEventHookID ); + Hide(); // so GetFirstDocWin won't return ourselves (needed for SOPlayer) + SetParent( StatementList::GetFirstDocWin() ); + delete pContainer; + delete pEdit; +} + +void DisplayHidWin::SetDraging( BOOL bNewDraging ) +{ + if ( !pShow ) + pShow = new Image( GetItemImage( TT_SHOW ) ); + if ( !pShow2 ) + pShow2 = new Image( Bitmap( TTProperties::GetSvtResId( TT_SHOW2 ) ) ); + + if ( bNewDraging ) + SetItemImage( TT_SHOW, *pShow2 ); + else + SetItemImage( TT_SHOW, *pShow ); + + bIsDraging = bNewDraging; +} + +void DisplayHidWin::EnableButtons( ULONG nConf ) +{ + BOOL bSend = nConf & DH_MODE_SEND_DATA; + EnableItem( TT_ALLWIN, bSend ); + EnableItem( TT_KURZNAME, bSend ); + EnableItem( TT_LANGNAME, bSend ); +} + +void DisplayHidWin::Tracking( const TrackingEvent& rTEvt ) +{ +// if ( nLastItemID == TT_SHOW && GetItemState( TT_SHOW ) == STATE_NOCHECK && ( rTEvt.IsTrackingEnded() || rTEvt.IsTrackingCanceled() ) ) +// SetDraging( FALSE ); + if ( nLastItemID == TT_SHOW && GetItemState( TT_SHOW ) == STATE_NOCHECK ) + EndTracking( ENDTRACK_CANCEL ); + ToolBox::Tracking( rTEvt); +} + +void DisplayHidWin::Click() +{ + nLastItemID = GetCurItemId(); + if ( nLastItemID == TT_SHOW ) + { + SetDraging( TRUE ); + } + ToolBox::Click(); +} + +void DisplayHidWin::Select() +{ + if ( GetItemState( GetCurItemId() ) == STATE_NOCHECK ) + { + SetItemState( GetCurItemId(), STATE_CHECK ); + if ( GetCurItemId() == TT_SHOW ) + { + bIsPermanentDraging = TRUE; + SetDraging( TRUE ); + } + } + else + { + SetItemState( GetCurItemId(), STATE_NOCHECK ); + if ( GetCurItemId() == TT_SHOW ) + { + bIsPermanentDraging = FALSE; + SetDraging( FALSE ); + } + } + if ( GetCurItemId() == TT_SEND_DATA ) + { + EnableButtons( GetConfig() ); + } +} + +void DisplayHidWin::SetConfig( ULONG nConf ) +{ + SetItemState( TT_KURZNAME, ( nConf & DH_MODE_KURZNAME ) ? STATE_CHECK : STATE_NOCHECK ); + SetItemState( TT_LANGNAME, ( nConf & DH_MODE_LANGNAME ) ? STATE_CHECK : STATE_NOCHECK ); + SetItemState( TT_ALLWIN, ( nConf & DH_MODE_ALLWIN ) ? STATE_CHECK : STATE_NOCHECK ); + SetItemState( TT_SEND_DATA, ( nConf & DH_MODE_SEND_DATA ) ? STATE_CHECK : STATE_NOCHECK ); + EnableButtons( nConf ); +} + +ULONG DisplayHidWin::GetConfig() +{ + ULONG nConf = 0; + if ( GetItemState( TT_KURZNAME ) == STATE_CHECK ) + nConf |= DH_MODE_KURZNAME; + if ( GetItemState( TT_LANGNAME ) == STATE_CHECK ) + nConf |= DH_MODE_LANGNAME; + if ( GetItemState( TT_ALLWIN ) == STATE_CHECK ) + nConf |= DH_MODE_ALLWIN; + if ( IsSendData() ) + nConf |= DH_MODE_SEND_DATA; + + return nConf; +} + +void DisplayHidWin::SetText( const XubString& rStr ) +{ + pContainer->SetText( rStr ); +} + +long DisplayHidWin::VCLEventHook( NotifyEvent& rEvt ) +{ + if ( EVENT_MOUSEMOVE == rEvt.GetType() ) + { + pLastMouseMoveWin = rEvt.GetWindow(); + + // check if abort with pressing shift twice + MouseEvent* pMEvt = (MouseEvent*)rEvt.GetMouseEvent(); + + if ( ( pMEvt->IsShift() && !bOldShift ) ) // Shift pressed + { + if ( aLatest < Time() ) + { + nShiftCount = 0; + aLatest = Time()+Time( 0, 0, 0, 50 ); + } + nShiftCount++; + } + if ( ( !pMEvt->IsShift() && bOldShift ) ) // Shift released + { + nShiftCount++; + if ( nShiftCount == 4 && aLatest > Time() ) + { + bIsPermanentDraging = FALSE; + SetDraging( FALSE ); + SetItemState( TT_SHOW, STATE_NOCHECK ); + } + } + bOldShift = pMEvt->IsShift(); + } + if ( ( EVENT_MOUSEBUTTONUP == rEvt.GetType() || ( EVENT_MOUSEMOVE == rEvt.GetType() && !rEvt.GetMouseEvent()->GetButtons() ) ) + && IsDraging() && !bIsPermanentDraging ) + SetDraging( FALSE ); + return 0; +} + + +BOOL StatementCommand::DisplayHID() +{ + // Return TRUE = + static StatementCommand *pDisplayInstance = NULL; + static DisplayHidWin *pDisplayHidWin; + static Window *Old = NULL, *Act = NULL; + static String aOriginalCaption; + + if ( !bBool2 ) // Wird auf FALSE initialisiert + { + bBool2 = TRUE; // Wir sind initialisiert. + pDisplayInstance = this; // Und haben die Macht (Alle anderen beenden sich) + + if ( !(nParams & PARAM_ULONG_1) ) + { + if( pDisplayHidWin ) // Nichts verändern + nLNr1 = pDisplayHidWin->GetConfig(); + else // Beim ersten Aufruf wollen wir alles richtig einstellen + nLNr1 = DH_MODE_KURZNAME | DH_MODE_LANGNAME; + + if( ((nParams & PARAM_BOOL_1) && bBool1) ) + nLNr1 |= DH_MODE_SEND_DATA; + else + nLNr1 &= ( ~DH_MODE_SEND_DATA ); + } + + if ( pDisplayHidWin ) + pDisplayHidWin->SetConfig( nLNr1 ); + } + + if ( pDisplayInstance && pDisplayInstance != this ) + { + DBG_WARNING("Mehrere DisplayHID am laufen"); + return FALSE; // Noch eine andere Instanz macht das gleiche! + } + + if ( !pDisplayHidWin ) + { + pDisplayHidWin = new DisplayHidWin(); + aOriginalCaption = pDisplayHidWin->GetText(); + pDisplayHidWin->Show(); + if ( bBool1 ) + nLNr1 |= DH_MODE_SEND_DATA; + pDisplayHidWin->SetConfig( nLNr1 ); + + Old = NULL; + Act = NULL; + pDisplayInstance = this; + } + else + { + pDisplayHidWin->GetWindow( WINDOW_OVERLAP )->Enable( TRUE, TRUE ); + pDisplayHidWin->GetWindow( WINDOW_OVERLAP )->EnableInput( TRUE, TRUE ); + } + + + if ( pDisplayHidWin->IsVisible() && !bDying ) + { + + if ( pDisplayHidWin->IsDraging() ) + { + + +#define HIGHLIGHT_WIN( WinPtr ) \ + { \ + Color aLineColMem = WinPtr->GetLineColor(); \ + WinPtr->SetLineColor( Color( COL_WHITE ) ); \ + Color aFillColMem = WinPtr->GetFillColor(); \ + WinPtr->SetFillColor( Color( COL_LIGHTRED ) ); \ + RasterOp aROp = WinPtr->GetRasterOp(); \ + WinPtr->SetRasterOp( ROP_XOR ); \ + Size aSz = WinPtr->PixelToLogic( WinPtr->GetSizePixel() );\ + ULONG nMaxCornerRadius = WinPtr->PixelToLogic( Point( 80, 0 ) ).X();\ + USHORT iCorner = std::max ((ULONG) 8, (ULONG) std::min( nMaxCornerRadius, (ULONG) std::min((ULONG) (aSz.Width() / 6), (ULONG)(aSz.Height() / 6))));\ + WinPtr->DrawRect(Rectangle(Point(),aSz), iCorner, iCorner);\ + WinPtr->SetLineColor( aLineColMem ); \ + WinPtr->SetFillColor( aFillColMem ); \ + WinPtr->SetRasterOp( aROp ); \ + } + + +#define SET_WIN( WinPtr ) \ + if ( StatementList::WinPtrValid(WinPtr) ) \ + { \ + HIGHLIGHT_WIN ( WinPtr ); \ + } + +#define RESET_WIN( WinPtr ) \ + if ( StatementList::WinPtrValid(WinPtr) ) \ + { \ + WinPtr->Invalidate( INVALIDATE_NOTRANSPARENT ); \ + WinPtr->Update(); \ + } + + + Old = Act; +// Act = GetMouseWin(); + Act = pDisplayHidWin->LastMouseMoveWin(); + + if ( Act && Act->GetType() == WINDOW_BORDERWINDOW ) + Act = Act->GetWindow( WINDOW_CLIENT ); + + if ( Act != Old ) + { + if ( Old ) + { + RESET_WIN(Old); + } + if ( Act ) + { + SET_WIN(Act); + pDisplayHidWin->SetDisplayText(UniString::CreateFromInt64(Act->GetUniqueOrHelpId()).AppendAscii(" WinType: ") + .Append(UniString::CreateFromInt64(Act->GetType())).AppendAscii(" ").Append(Act->GetText())); + if ( Act && Act->GetUniqueId() != Act->GetHelpId() ) + pDisplayHidWin->SetText(UniString( TTProperties::GetSvtResId( TT_ALTERNATE_CAPTION ) ).Append(UniString::CreateFromInt64(Act->GetHelpId()))); + else + pDisplayHidWin->SetText( aOriginalCaption ); + } + else + pDisplayHidWin->SetDisplayText(CUniString("Kein Window/Control gefunden")); + } + else if ( Act ) + { +// SET_WIN(Act); + if ( pDisplayHidWin->IsDisplayTextModified() && pDisplayHidWin->GetDisplayText().Len() > 0 ) + { + Act->SetUniqueId( pDisplayHidWin->GetDisplayText().ToInt32() ); + pDisplayHidWin->ClearDisplayTextModified(); + } + } +/* if ( Application::GetLastInputInterval() > 5000 ) // 5 Sekunden lang nix geschehen + { + pDisplayHidWin->ToTop( TOTOP_NOGRABFOCUS ); + } +*/ + if ( pDisplayHidWin->IsSendData() /*&& bBool2*/ && Act ) + { + if ( !StatementFlow::bSending ) + { // Normalerweise syncronisierung über Protokoll. Hier ist das aber asyncron!!! + WriteControlData( Act, pDisplayHidWin->GetConfig() ); + new StatementFlow( this, F_EndCommandBlock ); // Kommando zum Senden erzeugen und in que eintragen + } + } + } //if ( pDisplayHidWin->IsDraging() ) + else + { + if ( Act ) + { + RESET_WIN(Act); + Act = NULL; + } + } + + if ( pFirst == this ) // Sollte immer so sein, aber besser isses + if ( pNext ) // Befehle warten auf Ausführung + { // An Ende neu einsortieren + Advance(); + QueStatement( NULL ); + } +// { // Ersten und 2. austauschen. +// pFirst = pNext; +// pNext = pNext->pNext; +// pFirst->pNext = this; +// } + + } + else + { + delete pDisplayHidWin; + pDisplayHidWin = NULL; + pDisplayInstance = NULL; + } + + return pDisplayHidWin != NULL; +} + +class TranslateWin : public WorkWindow +{ +private: + DECL_LINK( DoAccept, PushButton* ); + DECL_LINK( DoNext, PushButton* ); + DECL_LINK( DoSelect, PushButton* ); + DECL_LINK( DoRestore, PushButton* ); + DECL_LINK( TranslationChanged, Edit* ); + DECL_LINK( ShowInplace, Timer* ); + + Timer InplaceTimer; + + BOOL bAvailable; + BOOL bNext; + +// virtual void MouseButtonUp( const MouseEvent& rMEvt ); +// virtual void MouseMove( const MouseEvent& rMEvt ); + + PushButton PushButtonTT_PB_NEXT; + GroupBox GroupBoxTT_GB_TRANSLATION; + Edit EditTT_E_NEW; + GroupBox GroupBoxTT_GB_COMMENT; + Edit EditTT_E_COMMENT; + PushButton PushButtonTT_PB_ACCEPT; + FixedText FixedTextTT_FT_OLD; + PushButton PushButtonTT_PB_SELECT; + PushButton PushButtonTT_PB_RESTORE; + + Window *Old; + Window *Act; + Window *pTranslateWin; + BOOL bSelecting; + + BOOL TestChangedDataSaved(); + + + ULONG nEventHookID; + static long stub_VCLEventHookProc( NotifyEvent& rEvt, void* pData ) + { + return ((TranslateWin*)pData)->VCLEventHook( rEvt ); + } + + long VCLEventHook( NotifyEvent& rEvt ); + +public: + TranslateWin(); + ~TranslateWin(); + + static String MarkShortcutErrors( Window* pBase, BOOL bMark ); + + BOOL IsTranslationAvailable(){ return bAvailable; } + BOOL IsNextDialog(){ return bNext; } + void ResetNextDialog(){ bNext = FALSE; } + + Window* GetTranslationWindow(){ return pTranslateWin; } + String GetOriginalText(){ return FixedTextTT_FT_OLD.GetText(); } + String GetTranslationText(){ return EditTT_E_NEW.GetText(); } + String GetComment(){ return EditTT_E_COMMENT.GetText(); } + + void EnableTranslation(); +}; + +TranslateWin::TranslateWin() +: WorkWindow( NULL, TTProperties::GetSvtResId( TT_INLINE_TRANSLATION ) ) +, PushButtonTT_PB_NEXT( this, TTProperties::GetSvtResId( TT_PB_NEXT ) ) +, GroupBoxTT_GB_TRANSLATION( this, TTProperties::GetSvtResId( TT_GB_TRANSLATION ) ) +, EditTT_E_NEW( this, TTProperties::GetSvtResId( TT_E_NEW ) ) +, GroupBoxTT_GB_COMMENT( this, TTProperties::GetSvtResId( TT_GB_COMMENT ) ) +, EditTT_E_COMMENT( this, TTProperties::GetSvtResId( TT_E_COMMENT ) ) +, PushButtonTT_PB_ACCEPT( this, TTProperties::GetSvtResId( TT_PB_ACCEPT ) ) +, FixedTextTT_FT_OLD( this, TTProperties::GetSvtResId( TT_FT_OLD ) ) +, PushButtonTT_PB_SELECT( this, TTProperties::GetSvtResId( TT_PB_SELECT ) ) +, PushButtonTT_PB_RESTORE( this, TTProperties::GetSvtResId( TT_PB_RESTORE ) ) +, Old( NULL ) +, Act( NULL ) +, bSelecting( FALSE ) +, bAvailable( FALSE ) +, bNext( FALSE ) +, pTranslateWin( NULL ) +{ + FreeResource(); + PushButtonTT_PB_NEXT.SetClickHdl( LINK( this, TranslateWin, DoNext ) ); + PushButtonTT_PB_ACCEPT.SetClickHdl( LINK( this, TranslateWin, DoAccept ) ); + PushButtonTT_PB_SELECT.SetClickHdl( LINK( this, TranslateWin, DoSelect ) ); + PushButtonTT_PB_RESTORE.SetClickHdl( LINK( this, TranslateWin, DoRestore ) ); + EditTT_E_NEW.SetModifyHdl( LINK( this, TranslateWin, TranslationChanged ) ); + InplaceTimer.SetTimeout( 250 ); + InplaceTimer.SetTimeoutHdl( LINK( this, TranslateWin, ShowInplace ) ); + EnableAlwaysOnTop(); + nEventHookID = Application::AddEventHook( stub_VCLEventHookProc, this ); +} + +TranslateWin::~TranslateWin() +{ + Application::RemoveEventHook( nEventHookID ); +} + +BOOL TranslateWin::TestChangedDataSaved() +{ + if ( ( EditTT_E_NEW.GetText().CompareTo( FixedTextTT_FT_OLD.GetText() ) != COMPARE_EQUAL + || EditTT_E_COMMENT.GetText().Len() ) + && PushButtonTT_PB_ACCEPT.IsEnabled() ) + { + return MessBox( this, TTProperties::GetSvtResId( TT_DISCARD_CHANGED_DATA ) ).Execute() == RET_YES; + } + else + return TRUE; +} + +IMPL_LINK( TranslateWin, DoAccept, PushButton*, EMPTYARG ) +{ + PushButtonTT_PB_SELECT.Disable(); + PushButtonTT_PB_NEXT.Disable(); + PushButtonTT_PB_RESTORE.Disable(); + EditTT_E_NEW.Disable(); + EditTT_E_COMMENT.Disable(); + PushButtonTT_PB_ACCEPT.Disable(); + bAvailable = TRUE; + return 0; +} + +IMPL_LINK( TranslateWin, DoNext, PushButton*, EMPTYARG ) +{ + if ( TestChangedDataSaved() ) + { + PushButtonTT_PB_SELECT.Disable(); + PushButtonTT_PB_NEXT.Disable(); + PushButtonTT_PB_RESTORE.Disable(); + EditTT_E_NEW.Disable(); + EditTT_E_COMMENT.Disable(); + PushButtonTT_PB_ACCEPT.Disable(); + bNext = TRUE; + } + return 0; +} + +IMPL_LINK( TranslateWin, DoSelect, PushButton*, EMPTYARG ) +{ + if ( bSelecting ) + { +// ReleaseMouse(); + bSelecting = FALSE; + } + else + { + if ( TestChangedDataSaved() ) + { + PushButtonTT_PB_RESTORE.Disable(); +// CaptureMouse(); + bSelecting = TRUE; + } + } + return 0; +} + +IMPL_LINK( TranslateWin, DoRestore, PushButton*, EMPTYARG ) +{ + String sTT_E_OLD( FixedTextTT_FT_OLD.GetText()); + sTT_E_OLD.SearchAndReplaceAll( CUniString("\\n"), CUniString("\n") ); + sTT_E_OLD.SearchAndReplaceAll( CUniString("\\t"), CUniString("\t") ); + + String sTT_E_NEW( EditTT_E_NEW.GetText()); + sTT_E_NEW.SearchAndReplaceAll( CUniString("\\n"), CUniString("\n") ); + sTT_E_NEW.SearchAndReplaceAll( CUniString("\\t"), CUniString("\t") ); + + if ( StatementList::WinPtrValid( pTranslateWin ) && pTranslateWin->GetText().CompareTo( sTT_E_NEW ) == COMPARE_EQUAL ) + { // Im ersten schritt nur in der UI zurück + pTranslateWin->SetText( sTT_E_OLD ); + } + else + { // Im zweite Schritt auch den eingegebenen Text + EditTT_E_NEW.SetText( FixedTextTT_FT_OLD.GetText() ); + PushButtonTT_PB_RESTORE.Disable(); + } + if ( StatementList::WinPtrValid( pTranslateWin ) ) + MarkShortcutErrors( pTranslateWin->GetWindow( WINDOW_OVERLAP ), TRUE ); + return 0; +} + +IMPL_LINK( TranslateWin, TranslationChanged, Edit*, pEdit ) +{ + PushButtonTT_PB_RESTORE.Enable(); + InplaceTimer.Start(); + return 0; +} + +IMPL_LINK( TranslateWin, ShowInplace, Timer*, EMPTYARG ) +{ + PushButtonTT_PB_RESTORE.Enable(); + if ( StatementList::WinPtrValid( pTranslateWin ) ) + { + String sTT_E_NEW( EditTT_E_NEW.GetText()); + // alle CRs UnQuoten + sTT_E_NEW.SearchAndReplaceAll( CUniString("\\n"), CUniString("\n") ); + // alle TABSs UnQuoten + sTT_E_NEW.SearchAndReplaceAll( CUniString("\\t"), CUniString("\t") ); + pTranslateWin->SetText( sTT_E_NEW ); + + MarkShortcutErrors( pTranslateWin->GetWindow( WINDOW_OVERLAP ), TRUE ); + } + return 0; +} + +long TranslateWin::VCLEventHook( NotifyEvent& rEvt ) +{ + if ( EVENT_MOUSEMOVE == rEvt.GetType() ) + { + if ( bSelecting ) + { + const MouseEvent *pMEvt = rEvt.GetMouseEvent(); + Old = Act; + Act = rEvt.GetWindow(); + + if ( Act ) + { + Window *pWin = Act; + USHORT i; + for ( i = 0 ; i < Act->GetChildCount() ; i++ ) + { + pWin = Act->GetChild(i); + Rectangle aWinPosSize( pWin->GetPosPixel(), pWin->GetSizePixel() ); + + if ( ( pWin->IsMouseTransparent() || !pWin->IsEnabled() ) && aWinPosSize.IsInside( pMEvt->GetPosPixel() ) ) + { + Act = pWin; + break; + } + } + } + + + if ( Act != Old ) + { + if ( Old ) + { + Window *pWin; + if ( Old->IsMouseTransparent() && Old->GET_REAL_PARENT() ) + pWin = Old->GET_REAL_PARENT(); + else + pWin = Old; + RESET_WIN(pWin); + } + if ( Act ) + { + SET_WIN(Act); + FixedTextTT_FT_OLD.SetText( Act->GetText() ); + } + else + FixedTextTT_FT_OLD.SetText( String() ); + } + else if ( Act ) + { + // SET_WIN(Act); + } + /* if ( Application::GetLastInputInterval() > 5000 ) // 5 Sekunden lang nix geschehen + { + ToTop(); + } + */ + } //if ( bSelecting ) + else + { + if ( Act ) + { + if ( Act->IsMouseTransparent() && Act->GET_REAL_PARENT() ) + Act = Act->GET_REAL_PARENT(); + RESET_WIN(Act); + Act = NULL; + } + } + } + else if ( EVENT_MOUSEBUTTONUP == rEvt.GetType() ) + { + if ( bSelecting ) + { + pTranslateWin = Act; + if ( pTranslateWin ) + { + MarkShortcutErrors( pTranslateWin->GetWindow( WINDOW_OVERLAP ), TRUE ); + // alle CRs quoten (NF) + String sTT_E_NEW( pTranslateWin->GetText()); + sTT_E_NEW.SearchAndReplaceAll( CUniString("\n"), CUniString("\\n") ); + // alle TABSs quoten () + sTT_E_NEW.SearchAndReplaceAll( CUniString("\t"), CUniString("\\t") ); + + FixedTextTT_FT_OLD.SetText( sTT_E_NEW ); + EditTT_E_NEW.SetText( sTT_E_NEW ); + EditTT_E_NEW.Enable(); + EditTT_E_NEW.GrabFocus(); + EditTT_E_COMMENT.SetText( String() ); + EditTT_E_COMMENT.Enable(); + PushButtonTT_PB_ACCEPT.Enable(); + } + // ReleaseMouse(); + bSelecting = FALSE; + } + } + + return 0; +} + +#define FDS_ACTION_COLLECT 1 +#define FDS_ACTION_MARK 2 +#define FDS_ACTION_UNMARK 3 + +class FindShortcutErrors: public Search +{ + String aShortcuts,aDoubleShortcuts; + USHORT nAction; +public: + FindShortcutErrors(); + virtual BOOL IsWinOK( Window *pWin ); + void SetAction( USHORT nA ); + String GetDoubleShortcuts() { return aDoubleShortcuts; } +}; + +FindShortcutErrors::FindShortcutErrors() +: Search( SEARCH_NOOVERLAP | SEARCH_NO_TOPLEVEL_WIN ) +{ + SetAction( FDS_ACTION_COLLECT ); // Wir fange immer mit sammeln an, ODER?? +} + +void FindShortcutErrors::SetAction( USHORT nA ) +{ + nAction = nA; + if ( FDS_ACTION_COLLECT == nAction ) + { + aShortcuts = UniString(); + aDoubleShortcuts = UniString(); + } +} + +BOOL FindShortcutErrors::IsWinOK( Window *pWin ) +{ + if ( pWin->IsReallyVisible() ) + { + String aText = pWin->GetText(); + xub_StrLen nPos = aText.Search('~'); + String aShortcut; + BOOL bHasAccel = FALSE; + if ( nPos != STRING_NOTFOUND ) + { + aShortcut = aText.Copy( nPos+1, 1 ); + aShortcut.ToLowerAscii(); + bHasAccel = aShortcut.Len() == 1; + } + + switch ( nAction ) + { + case FDS_ACTION_COLLECT: + { + if ( aShortcuts.Search( aShortcut ) != STRING_NOTFOUND ) + aDoubleShortcuts += aShortcut; + else + aShortcuts += aShortcut; + } + break; + case FDS_ACTION_MARK: + { + BOOL bMissing = FALSE; + if ( !bHasAccel && aText.Len() ) // should there be an accelarator defined + { + + Window* pChild; + pChild = pWin->GetWindow( WINDOW_CLIENT ); + + if ( (pChild->GetType() == WINDOW_RADIOBUTTON) || + (pChild->GetType() == WINDOW_IMAGERADIOBUTTON) || + (pChild->GetType() == WINDOW_CHECKBOX) || + (pChild->GetType() == WINDOW_TRISTATEBOX) || + (pChild->GetType() == WINDOW_PUSHBUTTON) ) + { + if ( !pChild->GetText().EqualsAscii( "..." ) ) + bMissing = TRUE; + } + + if ( pChild->GetType() == WINDOW_FIXEDTEXT ) + { + Window* pTempChild = pWin->GetWindow( WINDOW_NEXT ); + if ( pTempChild ) + pTempChild = pTempChild->GetWindow( WINDOW_CLIENT ); + + if ( pTempChild && pChild->GetText().Len() ) + { + if ( (pTempChild->GetType() == WINDOW_EDIT) || + (pTempChild->GetType() == WINDOW_MULTILINEEDIT) || + (pTempChild->GetType() == WINDOW_SPINFIELD) || + (pTempChild->GetType() == WINDOW_PATTERNFIELD) || + (pTempChild->GetType() == WINDOW_NUMERICFIELD) || + (pTempChild->GetType() == WINDOW_METRICFIELD) || + (pTempChild->GetType() == WINDOW_CURRENCYFIELD) || + (pTempChild->GetType() == WINDOW_DATEFIELD) || + (pTempChild->GetType() == WINDOW_TIMEFIELD) || + (pTempChild->GetType() == WINDOW_LISTBOX) || + (pTempChild->GetType() == WINDOW_MULTILISTBOX) || + (pTempChild->GetType() == WINDOW_COMBOBOX) || + (pTempChild->GetType() == WINDOW_PATTERNBOX) || + (pTempChild->GetType() == WINDOW_NUMERICBOX) || + (pTempChild->GetType() == WINDOW_METRICBOX) || + (pTempChild->GetType() == WINDOW_CURRENCYBOX) || + (pTempChild->GetType() == WINDOW_DATEBOX) || + (pTempChild->GetType() == WINDOW_TIMEBOX) ) + { + bMissing = TRUE; + } + } + } + } + + if ( bHasAccel && aDoubleShortcuts.Search( aShortcut ) != STRING_NOTFOUND ) + { + if ( pWin->GetType() == WINDOW_GROUPBOX ) + pWin->SetControlForeground( Color( COL_LIGHTRED ) ); + else + { + pWin->SetControlBackground(); + Color aCol(COL_GRAY); + aCol.SetRed( 0xff ); + pWin->SetControlBackground( aCol ); + } + } + else if ( bMissing ) + { + pWin->SetControlBackground(); + Color aCol(COL_GRAY); + aCol.SetRed( 0xff ); + aCol.SetGreen( 0xff ); + pWin->SetControlBackground( aCol ); + } + else + { + pWin->SetControlForeground(); + pWin->SetControlBackground(); + } + } + break; + case FDS_ACTION_UNMARK: + { + pWin->SetControlForeground(); + pWin->SetControlBackground(); + } + break; + } + } + else + if ( FDS_ACTION_MARK == nAction || FDS_ACTION_UNMARK == nAction ) + { + pWin->SetControlForeground(); + pWin->SetControlBackground(); + } + + return FALSE; +} + +String TranslateWin::MarkShortcutErrors( Window* pBase, BOOL bMark ) +{ + if ( pBase ) + { + FindShortcutErrors aFinder; + if ( bMark ) + { + StatementList::SearchAllWin( pBase, aFinder, TRUE ); // collect Shortcuts first + aFinder.SetAction( FDS_ACTION_MARK ); + } + else + aFinder.SetAction( FDS_ACTION_UNMARK ); + StatementList::SearchAllWin( pBase, aFinder, TRUE ); + return aFinder.GetDoubleShortcuts(); + } + return UniString(); +} + +void TranslateWin::EnableTranslation() +{ + PushButtonTT_PB_SELECT.Enable(); + PushButtonTT_PB_NEXT.Enable(); + bAvailable = FALSE; + bNext = FALSE; +} + +void StatementCommand::Translate() +{ + static TranslateWin *pTranslateWin = NULL; + static BOOL bToTop = TRUE; + + // Es wurde eine initale UniqueId mitgegeben. Dann nur die dopelten Shortcuts liefern + if( (nParams & PARAM_ULONG_1) && nLNr1 ) + { + String aDouble; + Window *pWin = SearchTree( nLNr1 ,FALSE ); + if ( pWin ) + { + pWin = pWin->GetWindow( WINDOW_OVERLAP ); + aDouble = TranslateWin::MarkShortcutErrors( pWin, TRUE ); + } + pRet->GenReturn ( RET_Value, RC_Translate, aDouble ); + return; + } + + if ( !pTranslateWin ) + { + pTranslateWin = new TranslateWin; + bToTop = TRUE; + } + + pTranslateWin->Show(); + if ( bToTop ) + { + pTranslateWin->ToTop(); + bToTop = FALSE; + } + +// pTranslateWin->GetWindow( WINDOW_OVERLAP )->Enable( TRUE, TRUE ); + pTranslateWin->GetWindow( WINDOW_OVERLAP )->EnableInput( TRUE, TRUE ); + + if ( pTranslateWin->IsTranslationAvailable() ) + { + String aTranslation; + Window* pTranslationWindow = pTranslateWin->GetTranslationWindow(); + + DBG_ASSERT( pTranslationWindow, "Kein Translation Window" ); + + if ( WinPtrValid( pTranslationWindow ) ) + { + if ( pTranslationWindow->GetType() == WINDOW_BORDERWINDOW && pTranslationWindow->GetWindow( WINDOW_CLIENT ) ) + { + Window* pNew = pTranslationWindow->GetWindow( WINDOW_CLIENT ); + // Bei Dockingwindoes das kanze Geraffel von Docking Floating überspringen + while ( IsDialog( pNew ) && !pNew->GetUniqueOrHelpId() && pNew->GetChildCount() == 1 ) + pNew = pNew->GetChild( 0 ); + pTranslationWindow = pNew; + } + + aTranslation = CUniString("0;"); + + aTranslation += UniString::CreateFromInt64( pTranslationWindow->GetUniqueOrHelpId() ); + aTranslation += ';'; + + aTranslation += TypeString( pTranslationWindow->GetType() ); + aTranslation += ';'; + + Window* pParentDialog = pTranslationWindow; + while ( pParentDialog && !IsDialog( pParentDialog ) ) + { + pParentDialog = pParentDialog->GET_REAL_PARENT(); + } + + if ( pParentDialog ) + { + aTranslation += UniString::CreateFromInt64( pParentDialog->GetUniqueOrHelpId() ); + aTranslation += ';'; + aTranslation += TypeString( pParentDialog->GetType() ); + } + else + aTranslation.AppendAscii( "0;" ); // Zahl + leerer String + aTranslation += ';'; + + aTranslation += '\"'; + aTranslation += pTranslateWin->GetOriginalText(); + aTranslation += '\"'; + + aTranslation += ';'; + + aTranslation += '\"'; + aTranslation += pTranslateWin->GetTranslationText(); + aTranslation += '\"'; + + aTranslation += ';'; + + aTranslation += '\"'; + aTranslation += pTranslateWin->GetComment(); + aTranslation += '\"'; + + // alle CRs quoten (NF) + aTranslation.SearchAndReplaceAll( CUniString("\n"), CUniString("\\n") ); + // alle TABSs quoten () + aTranslation.SearchAndReplaceAll( CUniString("\t"), CUniString("\\t") ); + + pRet->GenReturn ( RET_Value, RC_Translate, aTranslation ); + pTranslateWin->EnableTranslation(); + bToTop = TRUE; + } + else + { + pRet->GenReturn ( RET_Value, RC_Translate, String() ); + pTranslateWin->EnableTranslation(); + ErrorBox( pTranslateWin, TTProperties::GetSvtResId( TT_NO_CONTROL ) ).Execute(); + bToTop = TRUE; + } + + } + else if ( pTranslateWin->IsNextDialog() ) + { + pRet->GenReturn ( RET_Value, RC_Translate, CUniString("1") ); + pTranslateWin->ResetNextDialog(); + pTranslateWin->LoseFocus(); + bToTop = TRUE; + } + else + { + pTranslateWin->EnableTranslation(); + pRet->GenReturn ( RET_Value, RC_Translate, String() ); + } +} + +Window* StatementCommand::GetNextOverlap( Window* pBase ) +{ // Findet irgendwelche Overlap-Fenster, die schließbar aussehen + // Eventuell muß noch die Auswahl verfeinert werden. + + if ( pBase->GetType() != WINDOW_BORDERWINDOW ) + pBase = pBase->GetWindow( WINDOW_OVERLAP ); + + Window *pControl = NULL; + if ( pBase->GetWindow( WINDOW_FIRSTOVERLAP ) ) + { + pControl = GetNextOverlap( pBase->GetWindow( WINDOW_FIRSTOVERLAP ) ); + } + + if ( !pControl && pBase->GetWindow( WINDOW_NEXT ) ) + { + pControl = GetNextOverlap( pBase->GetWindow( WINDOW_NEXT ) ); + } + + if ( !pControl ) + { + Window *pTest = pBase->GetWindow( WINDOW_CLIENT ); + if ( IsAccessable (pTest) + && pTest->IsEnabled() + && pTest->IsVisible() + && ((pTest->GetStyle() & WB_CLOSEABLE ) || (pBase->GetStyle() & WB_CLOSEABLE )) ) + return pTest; + else + return NULL; + } + else + return pControl; +} + +Window* StatementCommand::GetNextRecoverWin() +{ + // über die TopLevelWindows der App iterieren + Window* pBase = Application::GetFirstTopLevelWindow(); + Window *pControl = NULL; + while ( pBase ) + { + // zuerst weitere Fenster auf dem Fenster suchen und schliessen + pControl = GetNextOverlap( pBase ); + if ( pControl && !IsFirstDocWin( pControl ) && !IsIMEWin( pControl ) ) + { +/* Window *pDock = GetWinByRT( pControl, WINDOW_DOCKINGWINDOW, FALSE ); + if ( pDock ) + return pDock; + else*/ + return pControl; + } + + // dann das Fenster selbst Schliessen + // erstes DocWin überspringen + // Assumption that Doc Windows are Borderwindows and ButtonDialog and such are not + if ( !IsFirstDocWin( pBase ) && pBase->GetType() != WINDOW_BORDERWINDOW && !IsIMEWin( pBase ) ) + return pBase; + + pBase = Application::GetNextTopLevelWindow( pBase ); + } + return NULL; +} + +BOOL StatementCommand::Execute() +{ + if ( IsError ) + { +#ifdef DEBUG + m_pDbgWin->AddText( "Skipping Command: " ); + m_pDbgWin->AddText( String::CreateFromInt32( nMethodId ) ); + m_pDbgWin->AddText( "\n" ); + #endif + + Advance(); + delete this; + return TRUE; + } + + InitProfile(); +#ifdef DEBUG + m_pDbgWin->AddText( "Executing Command: " ); + m_pDbgWin->AddText( String::CreateFromInt32( nMethodId ) ); + m_pDbgWin->AddText( "\n" ); +#endif + + + + + +#ifdef DEBUG +#define REPORT_WIN_CLOSED(pControl, aInfo) \ + _REPORT_WIN_CLOSED(pControl, aInfo) \ + m_pDbgWin->AddText( aInfo.AppendAscii(" \"").Append( pControl->GetText() ).AppendAscii("\" geschlossen, RType = ").Append( TypeString(pControl->GetType()) ).AppendAscii(", UId = ").Append( UIdString(pControl->GetUniqueOrHelpId()) ) ); +#else +#define REPORT_WIN_CLOSED(pControl, aInfo) _REPORT_WIN_CLOSED(pControl, aInfo) +#endif + +#define REPORT_WIN_CLOSEDc(pControl, aInfo ) \ + REPORT_WIN_CLOSED(pControl, CUniString(aInfo) ) + +#define _REPORT_WIN_CLOSED(pControl, aInfo) \ + if ( aString1.Len() ) \ + aString1 += '\n'; \ + aString1 += aInfo; \ + aString1.AppendAscii(" \""); \ + aString1 += pControl->GetText(); \ + aString1.AppendAscii("\" geschlossen, RType = ");\ + aString1 += TypeString(pControl->GetType()); \ + aString1.AppendAscii(", UId = "); \ + aString1 += UIdString(pControl->GetUniqueOrHelpId()); + + + switch ( nMethodId ) + { + case RC_AppDelay: + if ( !bBool1 ) + { + nLNr1 = Time().GetTime() + nNr1/10; + bBool1 = TRUE; + } + if ( Time().GetTime() < nLNr1 ) // Aktuelle Zeit kleiner Endzeit + return FALSE; + break; + case RC_DisplayHid: + if ( DisplayHID() ) + return FALSE; + break; + case RC_ResetApplication: + { + if ( !bBool1 ) + { + nRetryCount = 150; // das sollte reichen. + bBool1 = TRUE; // Nur beim ersten mal! + nNr1 = 1; // Welcher Button ist dran? + nLNr1 = 0; // Speichern des AppWin + aString1 = UniString(); // Liste der geschlossenen Fenster + + // So daß nacher auch wieder alles auf Default steht + nUseBindings = 0; + nControlType = CONST_CTTreeListBox; + } + if ( !nRetryCount ) + ReportError( GEN_RES_STR0( S_RESETAPPLICATION_FAILED_COMPLEX ) ); + + bBool2 = FALSE; // no document found + Window *pControl = GetNextRecoverWin(); + + if ( pControl ) + { + pControl->GrabFocus(); + + if ( pControl->GetType() != WINDOW_DOCKINGWINDOW + && pControl->GetType() != WINDOW_FLOATINGWINDOW + && pControl->GetType() != WINDOW_MODELESSDIALOG + && pControl->GetType() != WINDOW_WORKWINDOW + && pControl->GetType() != WINDOW_TOOLBOX + && nRetryCount-- ) + { + short nRT = ImpGetRType( pControl, pControl->GetUniqueOrHelpId() ); + + if ( nRT == C_TabControl && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_TABDIALOG ) + { // Bei Tabcontrol den zugehörigen Tabdialog nehmen + pControl = pControl->GET_REAL_PARENT(); + nRT = ImpGetRType( pControl, pControl->GetUniqueOrHelpId() ); + } + + switch( nRT ) + { + case C_Dlg: + case C_TabDlg: + REPORT_WIN_CLOSEDc(pControl, "Dialog"); + SET_WINP_CLOSING(pControl); + ((SystemWindow*)pControl)->Close(); + break; + case C_WorkWin: + break; + case C_MessBox: + case C_InfoBox: + case C_WarningBox: + case C_ErrorBox: + case C_QueryBox: + case C_ButtonDialog: + { + ButtonDialog* pBD = (ButtonDialog*)pControl; + // nNr1 >= 10 bedeutet (Custom)-Buttons durchgehen + if ( nNr1 >= 10+pBD->GetButtonCount() ) nNr1 = 1; + switch( nNr1 ) + { + case 5: + if ( pBD->GetPushButton( BUTTONID_OK ) ) + { + REPORT_WIN_CLOSEDc(pControl, "Message Box (OK)"); + SET_WINP_CLOSING(pControl); + pBD->EndDialog(RET_OK); + } + nNr1 = 10; // Nochmal alle Buttons der Reihe nach + break; + case 4: + if ( pBD->GetPushButton( BUTTONID_CANCEL ) ) + { + REPORT_WIN_CLOSEDc(pControl, "Message Box (Cancel)"); + SET_WINP_CLOSING(pControl); + pBD->EndDialog(RET_CANCEL); + } + nNr1++; + break; + case 3: + if ( pBD->GetPushButton( BUTTONID_YES ) ) + { + REPORT_WIN_CLOSEDc(pControl, "Message Box (Yes)"); + SET_WINP_CLOSING(pControl); + pBD->EndDialog(RET_YES); + } + nNr1++; + break; + case 2: // BUG 48239 + case 1: + if ( pBD->GetPushButton( BUTTONID_NO ) ) + { + REPORT_WIN_CLOSEDc(pControl, "Message Box (No)"); + SET_WINP_CLOSING(pControl); + pBD->EndDialog(RET_NO); + } + nNr1++; + break; + default: + { + USHORT nID = pBD->GetButtonId( nNr1-10 ); + if ( nID != BUTTONID_HELP ) + { + REPORT_WIN_CLOSED(pControl, CUniString("Message Box (").Append( UniString::CreateFromInt32(nID) ).AppendAscii(")")); + SET_WINP_CLOSING(pControl); + pBD->EndDialog(nID); + } + nNr1++; + } + } + break; + } + default: + DBG_ERROR( "Unbekannter Fenstertyp" ); + REPORT_WIN_CLOSEDc(pControl, "Unbekannter Fenstertyp"); + ReportError( 0, GEN_RES_STR0( S_RESETAPPLICATION_FAILED_UNKNOWN ), pControl->GetType() ); + #ifdef DEBUG + m_pDbgWin->AddText( " Unbekannter Objekttyp aus UId" ); + #endif + break; + } + return FALSE; + } + else + { + if ( (pControl->GetType() == WINDOW_DOCKINGWINDOW || pControl->GetType() == WINDOW_TOOLBOX) && nRetryCount-- ) + { + if ( (((DockingWindow*)pControl)->GetStyle() | ((DockingWindow*)pControl)->GetFloatStyle()) & WB_CLOSEABLE ) + { + REPORT_WIN_CLOSEDc(pControl, "DockingWindow"); + SET_WINP_CLOSING(pControl); + ((DockingWindow*)pControl)->Close(); + + // Eigentlich nur bei TaskWindows! Hoffen wir mal, daß keine anderen DockingWindows dazwischen hauen. + if ( (Window*)nLNr1 != pControl ) + nNr1 = 1; // Zum durchprobieren der Buttons beim Schließen + nLNr1 = (ULONG)pControl; + + return FALSE; + } + } + if ( nRetryCount-- + && ( (pControl->GetType() == WINDOW_FLOATINGWINDOW) + || (pControl->GetType() == WINDOW_MODELESSDIALOG) + || (pControl->GetType() == WINDOW_WORKWINDOW) ) ) + { + // if ( pControl->GetStyle() & WB_CLOSEABLE ) + { + REPORT_WIN_CLOSED( pControl, TypeString(pControl->GetType())); + SET_WINP_CLOSING(pControl); + ((SystemWindow*)pControl)->Close(); + + // Eigentlich nur bei TaskWindows! + if ( (Window*)nLNr1 != pControl ) + nNr1 = 1; // Zum durchprobieren der Buttons beim Schließen + nLNr1 = (ULONG)pControl; + + return FALSE; + } + } + } + } + pRet->GenReturn ( RET_Value, nMethodId, aString1); + } + + } + + + Advance(); + + + switch ( nMethodId ) + { + case RC_AppDelay: // Diese Befehle werden anderswo behandelt + case RC_DisplayHid: + case RC_ResetApplication: + case RC_AppAbort: // Sofortiges Löschen aller Befehle + break; + case RC_Assert: + { + ByteString aAssertion( "Diese Assertion wurde vom Testtool per Befehl ausgelöst" ); + aAssertion = ByteString( String( aAssertion, RTL_TEXTENCODING_MS_1252 ), RTL_TEXTENCODING_UTF8 ); + DBG_ASSERT( !aString1.Len(), ByteString( aString1, RTL_TEXTENCODING_UTF8 ).GetBuffer() ) + DBG_ASSERT( aString1.Len(), aAssertion.GetBuffer() ) + OSL_ENSURE( !aString1.Len(), ByteString( aString1, RTL_TEXTENCODING_UTF8 ).GetBuffer() ); + OSL_ENSURE( aString1.Len(), aAssertion.GetBuffer() ); + } + break; + case RC_CaptureAssertions: +#ifdef DBG_UTIL + if( !(nParams & PARAM_BOOL_1) || bBool1 ) + { + DBG_INSTOUTERROR( DBG_OUT_TESTTOOL ) + osl_setDebugMessageFunc( osl_TestToolDebugPrint ); + } + else + { + DBG_INSTOUTERROR( DBG_OUT_MSGBOX ) + osl_setDebugMessageFunc( pOriginal_osl_DebugMessageFunc ); + } +#endif + break; + case RC_Translate: + Translate(); + break; + case RC_ApplicationBusy: + { + BOOL bWait = FALSE; + ReportError( GEN_RES_STR0( S_NO_ACTIVE_WINDOW ) ); +// if ( Application::GetAppWindow() ) +// bWait = Application::GetAppWindow()->IsWait(); + pRet->GenReturn ( RET_Value, nMethodId, bWait ); + break; + } + case RC_GetClipboard: + { + ::rtl::OUString aTemp; + ::svt::OStringTransfer::PasteString( aTemp, GetFirstDocWin() ); + pRet->GenReturn ( RET_Value, nMethodId, String( aTemp ) ); + } + break; + case RC_SetClipboard: + ::svt::OStringTransfer::CopyString(aString1,GetFirstDocWin()); + break; + case RC_WinTree: + pRet->GenReturn ( RET_Value, nMethodId, Tree( NULL, 0)); + break; + #ifdef DEBUG + case RC_NoDebug: + m_pDbgWin->bQuiet = TRUE; + m_pDbgWin->Hide(); + m_pDbgWin->Clear(); + break; + case RC_Debug: + m_pDbgWin->bQuiet = FALSE; + m_pDbgWin->Show(); + break; + #endif + case RC_GPF: + ((TabControl*)NULL)->SetCurPageId( 12345 ); + break; + case RC_GetNextCloseWindow: + { + Window *pWin = GetActive( WINDOW_BASE ); // WINDOW_ANYTYPE + if ( !pWin ) + ReportError( GEN_RES_STR0( S_NO_ACTIVE_WINDOW ) ); + else if ( !IsDialog(pWin) ) + ReportError( GEN_RES_STR0( S_NO_DIALOG_IN_GETACTIVE ) ); + else + pRet->GenReturn( RET_Value, nMethodId, (ULONG)pWin->GetUniqueOrHelpId()); + } + break; + case RC_UseBindings: + if( !(nParams & PARAM_BOOL_1) || bBool1 ) + nUseBindings = SFX_USE_BINDINGS; + else + nUseBindings = 0; + break; + case RC_Profile: + // Bei folgenden Parametern passiert folgendes: + // ein boolean=false Alles Profiling stoppen (Ergebnisse liefern) + // ein boolean=true, 1-4 ints Einteilung der Zeiten in Kästchen + // kein! boolean keine ints loggen jeden Befehls + // kein! boolean 1 int loggen alle int Millisekunden + // ein String wird in das Logfile übernommen(sonst passiert nichts) + if( !(nParams & PARAM_BOOL_1) || bBool1 ) + { + if ( !pProfiler ) + { + pProfiler = new TTProfiler; + InitProfile(); + } + + if( !(nParams & PARAM_BOOL_1) && (nParams & PARAM_USHORT_1) ) + { // Autoprofiling: Profile nNr + if ( pProfiler->IsProfilingPerCommand() ) + { + pProfiler->StopProfilingPerCommand(); + } + pProfiler->StartAutoProfiling( nNr1 ); + + // Der Header ist abhängig vom Modus + pRet->GenReturn( RET_ProfileInfo, 0, pProfiler->GetProfileHeader() ); + } + else if ( nParams & PARAM_USHORT_1 ) + { // Partitioning initialisieren: Profile true [,nNr][,nNr][,nNr][,nNr] + ULONG nAnzahl=0; + if ( nParams & PARAM_USHORT_1 ) { nAnzahl++; }; + if ( nParams & PARAM_USHORT_2 ) { nAnzahl++; }; + if ( nParams & PARAM_USHORT_3 ) { nAnzahl++; }; + if ( nParams & PARAM_USHORT_4 ) { nAnzahl++; }; + + // Hier werden die Parameter ans Testtool zurück übertragen. + // Das ist zwar etwas eigenartig, aber ansonsten müsste man im Testtool + // die einfache Struktur der Remotebefehle aufbrechen. + pRet->GenReturn( RET_ProfileInfo, S_ProfileReset, nAnzahl ); + + // Und die einzelnen Grenzen + if ( nParams & PARAM_USHORT_1 ) { pRet->GenReturn( RET_ProfileInfo, S_ProfileBorder1, (ULONG)nNr1 ); }; + if ( nParams & PARAM_USHORT_2 ) { pRet->GenReturn( RET_ProfileInfo, S_ProfileBorder2, (ULONG)nNr2 ); }; + if ( nParams & PARAM_USHORT_3 ) { pRet->GenReturn( RET_ProfileInfo, S_ProfileBorder3, (ULONG)nNr3 ); }; + if ( nParams & PARAM_USHORT_4 ) { pRet->GenReturn( RET_ProfileInfo, S_ProfileBorder4, (ULONG)nNr4 ); }; + + pProfiler->StartPartitioning(); + } + else if( nParams == PARAM_STR_1 ) // Genau ein String! + { // Nur einen String ins Profiling aufnehmen + aString1 += '\n'; + pRet->GenReturn( RET_ProfileInfo, 0, aString1 ); + } + else + { // Normales Profiling je Kommando: profile + if ( pProfiler->IsAutoProfiling() ) + { + pRet->GenReturn( RET_ProfileInfo, 0, pProfiler->GetAutoProfiling() ); + pProfiler->StopAutoProfiling(); + } + pProfiler->StartProfilingPerCommand(); + + // Der Header ist abhängig vom Modus + pRet->GenReturn( RET_ProfileInfo, 0, pProfiler->GetProfileHeader() ); + } + } + else // Profiling wieder ausschalten: Profile false + if ( pProfiler ) + { + if ( pProfiler->IsProfilingPerCommand() ) + pProfiler->StopProfilingPerCommand(); + + if ( pProfiler->IsAutoProfiling() ) + { + pRet->GenReturn( RET_ProfileInfo, 0, pProfiler->GetAutoProfiling() ); + pProfiler->StopAutoProfiling(); + } + + if ( pProfiler->IsPartitioning() ) + { + pRet->GenReturn( RET_ProfileInfo, S_ProfileDump, (ULONG)0 ); + pProfiler->StopPartitioning(); + } + + delete pProfiler; + pProfiler = NULL; + } + break; + case RC_MenuGetItemCount: + case RC_MenuGetItemId: + case RC_MenuGetItemPos: + case RC_MenuIsSeperator: + case RC_MenuIsItemChecked: + case RC_MenuIsItemEnabled: + case RC_MenuGetItemText: + case RC_MenuGetItemCommand: + case RC_MenuSelect: + { + PopupMenu *pPopup = NULL; + MenuBar *pMenuBar = NULL; + Menu *pMenu; + + if ( WinPtrValid( pMenuWindow ) ) + pMenuBar = pMenuWindow->GetMenuBar(); + + if ( pMenuBar ) // use MenuBar as base + pMenu = pMenuBar; + else // use contextmenu as base + { + pMenu = PopupMenu::GetActivePopupMenu(); + pPopup = PopupMenu::GetActivePopupMenu(); + } + + if ( !pMenu ) + { + ReportError( GEN_RES_STR0( S_NO_POPUP ) ); + break; + } + + if ( nSubMenuId1 ) + { + pPopup = pMenu->GetPopupMenu(nSubMenuId1); + pMenu = pPopup; + } + + if ( pMenu && nSubMenuId2 ) + { + pPopup = pMenu->GetPopupMenu(nSubMenuId2); + pMenu = pPopup; + } + + if ( !pMenu ) + { + ReportError( GEN_RES_STR0( S_NO_SUBMENU ) ); + break; + } + + + USHORT nItemCount = 0; + switch ( nMethodId ) + { + case RC_MenuGetItemCount: + case RC_MenuGetItemId: + case RC_MenuIsSeperator: + { + nItemCount = pMenu->GetItemCount(); + if ( pMenu->GetMenuFlags() & MENU_FLAG_HIDEDISABLEDENTRIES ) + { // jep, we have to adjust the count + BOOL bLastWasSeperator = TRUE; // TRUE for Separator at the top + for ( USHORT i = 0 ; i < pMenu->GetItemCount() ; i++ ) + { + if ( !pMenu->IsItemEnabled( pMenu->GetItemId( i ) ) ) + nItemCount--; + else + { + if ( pMenu->GetItemType( i ) == MENUITEM_SEPARATOR && bLastWasSeperator ) + nItemCount--; + bLastWasSeperator = pMenu->GetItemType( i ) == MENUITEM_SEPARATOR; + } + } + if ( bLastWasSeperator ) // Separator at bottom + nItemCount--; + } + } + break; + } + + // for certain methods calculate the physical index (reinserting the hidden entries) + USHORT nPhysicalIndex = 0; + switch ( nMethodId ) + { + case RC_MenuGetItemId: + case RC_MenuIsSeperator: + { + nPhysicalIndex = nNr1; + if ( pMenu->GetMenuFlags() & MENU_FLAG_HIDEDISABLEDENTRIES ) + { // jep, we have to adjust the position + BOOL bLastWasSeperator = TRUE; // TRUE for Separator at the top + USHORT nVisibleCount = 0; + for ( USHORT i = 0 ; i < pMenu->GetItemCount() && nVisibleCount < nNr1 ; i++ ) + { + if ( pMenu->IsItemEnabled( pMenu->GetItemId( i ) ) + && !( pMenu->GetItemType( i ) == MENUITEM_SEPARATOR && bLastWasSeperator ) ) + { + nVisibleCount++; + bLastWasSeperator = pMenu->GetItemType( i ) == MENUITEM_SEPARATOR; + } + else + nPhysicalIndex++; + } + DBG_ASSERT( nVisibleCount == nNr1, "Adaption of Index failed: nVisibleCount != nNr1" ) + } + } + break; + } + + + + switch ( nMethodId ) + { + case RC_MenuGetItemCount: + { + pRet->GenReturn ( RET_Value, nMethodId, (ULONG)nItemCount ); + } + break; + case RC_MenuGetItemId: + { + if ( ValueOK(nMethodId, RcString( nMethodId ),nNr1,nItemCount) ) + pRet->GenReturn ( RET_Value, nMethodId, (ULONG)pMenu->GetItemId(nPhysicalIndex-1) ); + } + break; + case RC_MenuGetItemPos: + { + USHORT nLogicalPos = pMenu->GetItemPos(nNr1); + if ( MENU_ITEM_NOTFOUND != nLogicalPos && pMenu->GetMenuFlags() & MENU_FLAG_HIDEDISABLEDENTRIES ) + { // jep, we have to adjust the position + if ( !pMenu->IsItemEnabled( nNr1 ) ) + nLogicalPos = MENU_ITEM_NOTFOUND; + else + { + BOOL bLastWasSeperator = FALSE; + for ( int i = nLogicalPos ; i >= 0 ; i-- ) + { + if ( !pMenu->IsItemEnabled( pMenu->GetItemId( i ) ) || + ( pMenu->GetItemType( i ) == MENUITEM_SEPARATOR && bLastWasSeperator ) ) + nLogicalPos--; + bLastWasSeperator = pMenu->GetItemType( i ) == MENUITEM_SEPARATOR; + } + } + } + pRet->GenReturn ( RET_Value, nMethodId, (ULONG)(nLogicalPos+1) ); + } + break; + case RC_MenuIsSeperator: + { + if ( ValueOK(nMethodId, RcString( nMethodId ),nNr1,nItemCount) ) + pRet->GenReturn ( RET_Value, nMethodId, (BOOL)(pMenu->GetItemType(nPhysicalIndex-1) == MENUITEM_SEPARATOR) ); + } + break; + case RC_MenuIsItemChecked: + { + pRet->GenReturn ( RET_Value, nMethodId, (BOOL)pMenu->IsItemChecked(nNr1) ); + } + break; + case RC_MenuIsItemEnabled: + { + pRet->GenReturn ( RET_Value, nMethodId, (BOOL)pMenu->IsItemEnabled(nNr1) ); + } + break; + case RC_MenuGetItemText: + { + pRet->GenReturn ( RET_Value, nMethodId, (String)pMenu->GetItemText(nNr1) ); + } + break; + case RC_MenuGetItemCommand: + { + pRet->GenReturn ( RET_Value, nMethodId, (String)pMenu->GetItemCommand(nNr1) ); + } + break; + case RC_MenuSelect: + { + if ( pMenu->GetPopupMenu(nNr1) ) + { + if ( !nSubMenuId1 ) + nSubMenuId1 = nNr1; + else if ( !nSubMenuId2 ) + nSubMenuId2 = nNr1; + + if ( pPopup ) + pPopup->SelectEntry(nNr1); + else + pMenuBar->SelectEntry(nNr1); + } + else + { + if ( pPopup ) + { + pPopup->EndExecute(nNr1); + nSubMenuId1 = 0; + nSubMenuId2 = 0; + } + else + pMenuBar->SelectEntry(nNr1); + } + } + break; + } + } + break; + case RC_SetControlType: + { + switch ( nNr1 ) + { + case CONST_CTTreeListBox: + case CONST_CTBrowseBox: + case CONST_CTProgressBar: + nControlType = nNr1; + break; + default: + ReportError( 0, GEN_RES_STR1( S_CONTROLTYPE_NOT_SUPPORTED , UniString::CreateFromInt32( nNr1 ) ) ); + } + + } + break; + case RC_Kill: + case RC_RmDir: + case RC_MkDir: + case RC_FileCopy: + case RC_Name: + case RC_Dir: + case RC_FileLen: + case RC_FileDateTime: + { + long nErrorcode = FSYS_ERR_OK; + switch ( nMethodId ) + { + case RC_Kill: + { + DirEntry aFile( aString1 ); + nErrorcode = aFile.GetError(); + if ( FSYS_ERR_OK == nErrorcode && FileStat( aFile ).IsKind( FSYS_KIND_FILE ) ) + nErrorcode = aFile.Kill(); + else + nErrorcode = FSYS_ERR_NOTAFILE; + } + break; + case RC_RmDir: + { + DirEntry aDir( aString1 ); + nErrorcode = aDir.GetError(); + if ( FSYS_ERR_OK == nErrorcode && FileStat( aDir ).IsKind( FSYS_KIND_DIR ) ) + nErrorcode = aDir.Kill(); + else + nErrorcode = FSYS_ERR_NOTADIRECTORY; + } + break; + case RC_MkDir: + { + DirEntry aDir( aString1 ); + nErrorcode = aDir.GetError(); + if ( !nErrorcode && !aDir.MakeDir() ) + nErrorcode = FSYS_ERR_UNKNOWN; +// Workaround für Bug 60693 +// nErrorcode = aDir.GetError(); + } + break; + case RC_FileCopy: + { + nErrorcode = DirEntry( aString1 ).CopyTo( DirEntry( aString2 ), FSYS_ACTION_COPYFILE ); + } + break; + case RC_Name: + { + nErrorcode = DirEntry( aString1 ).MoveTo( DirEntry( aString2 ) ); + } + break; + case RC_Dir: + { + // neues Verzeichnis einlesen + if ( (nParams & PARAM_STR_1) ) + { + if ( pDir ) + { + delete pDir; + pDir = NULL; + } + DirEntryKind aDirEntryKind = FSYS_KIND_FILE | FSYS_KIND_DIR; + if ( (nParams & PARAM_USHORT_1) && nNr1 ) + { + if ( nNr1 & 16 ) + aDirEntryKind = FSYS_KIND_DIR; + else + ReportError( GEN_RES_STR0( S_SELECTION_BY_ATTRIBUTE_ONLY_DIRECTORIES ) ); + } + + DirEntry aEntry( aString1 ); + nErrorcode = aEntry.GetError(); + if ( !nErrorcode ) + { + nDirPos = 0; + FileStat aFS( aEntry ); + if ( !aFS.IsKind( FSYS_KIND_WILD ) && !aFS.IsKind( FSYS_KIND_DIR ) && aEntry.Exists() ) + { // Sonderbehandlung für genau einen Eintrag + if ( !aFS.IsKind( FSYS_KIND_DIR ) && ( aDirEntryKind == FSYS_KIND_DIR ) ) + pRet->GenReturn ( RET_Value, nMethodId, String() ); + else + pRet->GenReturn ( RET_Value, nMethodId, (String)(aEntry.GetName()) ); + + break; + } + else + { + pDir = new Dir( aEntry, aDirEntryKind ); + nErrorcode = pDir->GetError(); + } + } + } + + if ( !pDir ) + pDir = new Dir; + + if ( !nErrorcode && ValueOK( nMethodId, GEN_RES_STR0( S_NO_MORE_FILES ), nDirPos+1, pDir->Count()+1 ) ) + { + if ( nDirPos == pDir->Count() ) + pRet->GenReturn ( RET_Value, nMethodId, String() ); + else + pRet->GenReturn ( RET_Value, nMethodId, (String)((*pDir)[ nDirPos ].GetName()) ); + nDirPos++; + } + } + break; + case RC_FileLen: + { + DirEntry aFile( aString1 ); + nErrorcode = aFile.GetError(); + if ( FSYS_ERR_OK == nErrorcode ) + { + FileStat aFS( aFile ); + pRet->GenReturn ( RET_Value, nMethodId, aFS.GetSize() ); + nErrorcode = aFS.GetError(); + } + } + break; + case RC_FileDateTime: + { + DirEntry aFile( aString1 ); + nErrorcode = aFile.GetError(); + if ( FSYS_ERR_OK == nErrorcode ) + { + FileStat aStat( aFile ); + Time aTime( aStat.TimeModified() ); + Date aDate( aStat.DateModified() ); + nErrorcode = aStat.GetError(); + + double fSerial = (double)( aDate - Date(30,12,1899) ); + long nSeconds = aTime.GetHour(); + nSeconds *= 3600; + nSeconds += aTime.GetMin() * 60; + nSeconds += aTime.GetSec(); + double nDays = ((double)nSeconds) / (double)(24.0*3600.0); + fSerial += nDays; + + SbxValueRef xValue = new SbxValue( SbxDATE ); + xValue->PutDate( fSerial ); + + pRet->GenReturn ( RET_Value, nMethodId, *xValue ); + } + } + break; + } + switch ( nErrorcode ) + { + case FSYS_ERR_OK: + break; + case FSYS_ERR_MISPLACEDCHAR: + { + ReportError( CUniString("MISPLACEDCHAR") ); + } + break; + case FSYS_ERR_INVALIDCHAR: + { + ReportError( CUniString("INVALIDCHAR") ); + } + break; + case FSYS_ERR_NOTEXISTS: + { + ReportError( CUniString("NOTEXISTS") ); + } + break; + case FSYS_ERR_ALREADYEXISTS: + { + ReportError( CUniString("ALREADYEXISTS") ); + } + break; + case FSYS_ERR_NOTADIRECTORY: + { + ReportError( CUniString("NOTADIRECTORY") ); + } + break; + case FSYS_ERR_NOTAFILE: + { + ReportError( CUniString("NOTAFILE") ); + } + break; + case FSYS_ERR_INVALIDDEVICE: + { + ReportError( CUniString("INVALIDDEVICE") ); + } + break; + case FSYS_ERR_ACCESSDENIED: + { + ReportError( CUniString("ACCESSDENIED") ); + } + break; + case FSYS_ERR_LOCKVIOLATION: + { + ReportError( CUniString("LOCKVIOLATION") ); + } + break; + case FSYS_ERR_VOLUMEFULL: + { + ReportError( CUniString("VOLUMEFULL") ); + } + break; + case FSYS_ERR_ISWILDCARD: + { + ReportError( CUniString("ISWILDCARD") ); + } + break; + case FSYS_ERR_NOTSUPPORTED: + { + ReportError( CUniString("NOTSUPPORTED") ); + } + break; + case FSYS_ERR_UNKNOWN: + { + ReportError( CUniString("UNKNOWN") ); + } + break; + default: + { + ReportError( CUniString("Not an FSYS Error") ); + } + } + + } + break; + case RC_TypeKeysDelay: + { + if( (nParams & PARAM_BOOL_1) ) + { + bDoTypeKeysDelay = bBool1; + } + else if( nParams & PARAM_USHORT_1 ) + { + nMinTypeKeysDelay = nNr1; + if( nParams & PARAM_USHORT_2 ) + nMaxTypeKeysDelay = nNr2; + else + nMaxTypeKeysDelay = nMinTypeKeysDelay; + } + else + ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) ); + } + break; + case RC_GetMouseStyle: + { + Pointer aPointer; +// if ( DragManager::GetDragManager() ) +// aPointer = DragManager::GetDragManager()->GetDragPointer(); +// else + { + Window *pActualWin = GetMouseWin(); + if ( pActualWin ) + aPointer = pActualWin->GetPointer(); + else + { + ReportError( 0, GEN_RES_STR1( S_POINTER_OUTSIDE_APPWIN, RcString( nMethodId ) ) ); + aPointer = Pointer( POINTER_NULL ); + } + } + pRet->GenReturn ( RET_Value, nMethodId, (ULONG)aPointer.GetStyle() ); + } + break; + case RC_UnpackStorage: + { + if( (nParams & PARAM_STR_1) ) + { + String aFileName( aString1 ); + DirEntry aDestPath; + if( (nParams & PARAM_STR_2) ) + aDestPath = DirEntry( aString2 ); + else + { + aDestPath = DirEntry( aFileName ); + aDestPath.SetExtension( CUniString( "plaintext" ) ); + } + +#ifdef DEBUG + USHORT nEntries = Dir( aDestPath, FSYS_KIND_FILE | FSYS_KIND_DIR ).Count(); +#endif + // The Count is only larger than 2 is the path is a directory which is not empty + // the Count of 2 results from the "." and ".." directory + if ( Dir( aDestPath, FSYS_KIND_FILE | FSYS_KIND_DIR ).Count() <= 2 ) + { + SotStorageRef xStorage = new SotStorage( aFileName, STREAM_STD_READ ); + if ( xStorage->GetError() ) + ReportError( GEN_RES_STR2(S_UNPACKING_STORAGE_FAILED, aFileName, aDestPath.GetFull()) ); + else + UnpackStorage( xStorage, aDestPath ); + } + else + ReportError( GEN_RES_STR1( S_DIRECTORY_NOT_EMPTY, aDestPath.GetFull() ) ); + } + else + ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) ); + } + break; + case RC_CloseSysDialog: + case RC_ExistsSysDialog: + { + if( (nParams & PARAM_USHORT_1) ) + { + Reference < XCancellable > xPicker; + switch( nNr1 ) + { + case CONST_FilePicker: + { + xPicker.set( Reference < XCancellable >( svt::GetTopMostFilePicker(), UNO_QUERY ) ); + } + break; + case CONST_FolderPicker: + { + xPicker.set( Reference < XCancellable >( svt::GetTopMostFolderPicker(), UNO_QUERY ) ); + } + break; + default: + ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) ); + } + switch( nMethodId ) + { + case RC_CloseSysDialog: + { + if ( xPicker.is() ) + xPicker->cancel(); + else + ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) ); + } + break; + case RC_ExistsSysDialog: + { + pRet->GenReturn ( RET_Value, nMethodId, (BOOL)xPicker.is() ); + } + break; + default: + ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) ); + } + } + else + ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) ); + } + break; + case RC_SAXCheckWellformed: + case RC_SAXReadFile: + + case RC_SAXGetNodeType: + case RC_SAXGetAttributeCount: + case RC_SAXGetAttributeName: + case RC_SAXGetAttributeValue: + case RC_SAXGetChildCount: + case RC_SAXGetElementName: + case RC_SAXGetChars: + + case RC_SAXSeekElement: + case RC_SAXHasElement: + case RC_SAXGetElementPath: + + case RC_SAXRelease: + { + HandleSAXParser(); + } + break; + case RC_RecordMacro: + { + HandleMacroRecorder(); + } + break; + case RC_GetDocumentCount : + { + pRet->GenReturn ( RET_Value, nMethodId, (USHORT)GetDocWinCount() ); + } + break; + case RC_ActivateDocument : + { + if( nParams & PARAM_USHORT_1 ) + { + if ( ValueOK(nMethodId, RcString( nMethodId ), nNr1, GetDocWinCount() ) ) + { + Window* pWin = GetDocWin( nNr1-1 ); + if ( pWin ) + { + pWin->ToTop(); + pWin->GrabFocus(); + } + } + } + else + ReportError( GEN_RES_STR0( S_INVALID_PARAMETERS ) ); + } + break; + default: + ReportError( 0, GEN_RES_STR1( S_UNKNOWN_COMMAND, RcString( nMethodId ) ) ); + } + SendProfile( RcString(nMethodId) ); + delete this; + return TRUE; +} + + +BOOL StatementCommand::UnpackStorage( SotStorageRef xStorage, DirEntry &aBaseDir ) +{ + SvStorageInfoList aList; + xStorage->FillInfoList( &aList ); + + for( USHORT i = 0; i < aList.Count(); i++ ) + { + SvStorageInfo& rInfo = aList.GetObject( i ); + String aName = rInfo.GetName(); + DirEntry aPath ( aBaseDir ); + aPath += DirEntry( aName ); + BOOL bIsStorage = xStorage->IsStorage( aName ); + if ( bIsStorage ) + { + SotStorageRef xSubStorage = xStorage->OpenSotStorage( aName, STREAM_STD_READ ); + if ( xSubStorage->GetError() ) + { + ReportError( GEN_RES_STR2(S_UNPACKING_STORAGE_FAILED, aName, aPath.GetFull()) ); + return FALSE; + } + UnpackStorage( xSubStorage, aPath ); + } + else + { + if ( !aPath.MakeDir( TRUE ) ) + { + ReportError( GEN_RES_STR1(S_CANNOT_CREATE_DIRECTORY, aPath.GetFull()) ); + return FALSE; + } + SotStorageStreamRef xStream = xStorage->OpenSotStream( aName, STREAM_STD_READ ); + SvFileStream aDestination( aPath.GetFull(), STREAM_STD_READWRITE | STREAM_TRUNC ); + (*xStream) >> aDestination; + if ( aDestination.GetError() != ERRCODE_NONE ) + { + ReportError( GEN_RES_STR2(S_UNPACKING_STORAGE_FAILED, aName, aPath.GetFull()) ); + return FALSE; + } + aDestination.Close(); + } + } + return TRUE; +} + + +// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +StatementControl::StatementControl( SCmdStream *pCmdIn ) +: StatementList() +, bBool1(FALSE) +, bBool2(FALSE) +{ + QueStatement( NULL ); + pCmdIn->Read( nUId ); + pCmdIn->Read( nMethodId ); + pCmdIn->Read( nParams ); + + if( nParams & PARAM_USHORT_1 ) pCmdIn->Read( nNr1 ); + if( nParams & PARAM_USHORT_2 ) pCmdIn->Read( nNr2 ); + if( nParams & PARAM_USHORT_3 ) pCmdIn->Read( nNr3 ); + if( nParams & PARAM_USHORT_4 ) pCmdIn->Read( nNr4 ); + if( nParams & PARAM_ULONG_1 ) pCmdIn->Read( nLNr1 ); + if( nParams & PARAM_STR_1 ) pCmdIn->Read( aString1 ); + if( nParams & PARAM_STR_2 ) pCmdIn->Read( aString2 ); + if( nParams & PARAM_BOOL_1 ) pCmdIn->Read( bBool1 ); + if( nParams & PARAM_BOOL_2 ) pCmdIn->Read( bBool2 ); + +#ifdef DEBUG + m_pDbgWin->AddText( "Reading Control: UId: " ); + m_pDbgWin->AddText( String::CreateFromInt64( nUId ) ); + m_pDbgWin->AddText( " Methode: " ); + m_pDbgWin->AddText( String::CreateFromInt32( nMethodId ) ); + m_pDbgWin->AddText( " Params:" ); + if( nParams & PARAM_USHORT_1 ) {m_pDbgWin->AddText( " n1:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr1 ) );} + if( nParams & PARAM_USHORT_2 ) {m_pDbgWin->AddText( " n2:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr2 ) );} + if( nParams & PARAM_USHORT_3 ) {m_pDbgWin->AddText( " n3:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr3 ) );} + if( nParams & PARAM_USHORT_4 ) {m_pDbgWin->AddText( " n4:" );m_pDbgWin->AddText( String::CreateFromInt32( nNr4 ) );} + if( nParams & PARAM_ULONG_1 ) {m_pDbgWin->AddText( " nl1:" );m_pDbgWin->AddText( String::CreateFromInt64( nLNr1 ) );} + if( nParams & PARAM_STR_1 ) {m_pDbgWin->AddText( " s1:" );m_pDbgWin->AddText( aString1 );} + if( nParams & PARAM_STR_2 ) {m_pDbgWin->AddText( " s2:" );m_pDbgWin->AddText( aString2 );} +/* if( nParams & PARAM_BOOL_1 ) pCmdIn->Read( bBool1 ); + if( nParams & PARAM_BOOL_2 ) pCmdIn->Read( bBool2 );*/ + m_pDbgWin->AddText( "\n" ); +#endif +} + +BOOL IsDialog(Window *pWin) +{ // Alles was von SystemWindow abgeleitet ist + if ( !pWin ) + return FALSE; + + switch (pWin->GetType()) + { + case WINDOW_FLOATINGWINDOW: + case WINDOW_DOCKINGWINDOW: + case WINDOW_MODELESSDIALOG: + case WINDOW_MODALDIALOG: + case WINDOW_WORKWINDOW: + case WINDOW_TABDIALOG: + + case WINDOW_MESSBOX: + case WINDOW_INFOBOX: + case WINDOW_WARNINGBOX: + case WINDOW_ERRORBOX: + case WINDOW_QUERYBOX: + case WINDOW_BUTTONDIALOG: + case WINDOW_FILEDIALOG: + case WINDOW_PRINTDIALOG: + case WINDOW_PRINTERSETUPDIALOG: + +// ab hier nicht ansprechbar (da nicht implementiert) + case WINDOW_SYSWINDOW: + case WINDOW_DIALOG: + case WINDOW_SYSTEMDIALOG: + case WINDOW_COLORDIALOG: + case WINDOW_FONTDIALOG: + case WINDOW_PATHDIALOG: + + + return TRUE; + break; + default: + return FALSE; + break; + } +} + + +BOOL IsAccessable(Window *pWin) +{ + if ( pWin == NULL ) + return FALSE; + + return pWin->IsEnabled() && pWin->IsInputEnabled(); +} + + + +// neue Hilfsfunktion +static Window*ImpGetButton( Window *pBase, WinBits nMask, WinBits nWinBits ) +{ + USHORT n = pBase->GetChildCount(); + for( int i = 0 ; i < n; i++ ) { + Window *pChild = pBase->GetChild(i); + if( pChild->GetType() == WINDOW_OKBUTTON + || pChild->GetType() == WINDOW_CANCELBUTTON + || pChild->GetType() == WINDOW_HELPBUTTON + || pChild->GetType() == WINDOW_PUSHBUTTON ) + if( !nMask || ( pChild->GetStyle() & nMask ) == nWinBits ) + return pChild; + } + return NULL; +} + +BOOL StatementControl::ControlOK( Window *pControl, const sal_Char* cBezeichnung ) +{ + if ( pControl && ( ( ( IsAccessable(pControl) || (nMethodId & M_WITH_RETURN) ) && + pControl->IsVisible() ) || + (nUId == UID_ACTIVE) ) ) + return TRUE; + else + { + UniString aBezeichnung( cBezeichnung, RTL_TEXTENCODING_ASCII_US ); + if ( aBezeichnung.Len() > 0 ) + { + if (!pControl) + ReportError( nUId, GEN_RES_STR1( S_WIN_NOT_FOUND, aBezeichnung ) ); + else if ( !pControl->IsVisible() ) + ReportError( nUId, GEN_RES_STR1( S_WIN_INVISIBLE, aBezeichnung ) ); + else + ReportError( nUId, GEN_RES_STR1( S_WIN_DISABLED, aBezeichnung ) ); + } + #ifdef DEBUG + m_pDbgWin->AddText( aBezeichnung.AppendAscii(" NotFound or Disabled or Invisible") ); + #endif + + return FALSE; + } +} + + +BOOL StatementList::ValueOK(ULONG nId, String aBezeichnung, ULONG nValue, ULONG nMax) +{ + + if ( nMax < nValue ) + { + if ( aBezeichnung.Len() > 0 ) + ReportError( nId, GEN_RES_STR3( S_NUMBER_TOO_BIG, aBezeichnung, UniString::CreateFromInt32( nValue ), UniString::CreateFromInt32( nMax ) ) ); + return FALSE; + } + if ( nValue < 1 ) + { + if ( aBezeichnung.Len() > 0 ) + ReportError( nId, GEN_RES_STR3c3( S_NUMBER_TOO_SMALL, aBezeichnung, UniString::CreateFromInt32( nValue ), "1" ) ); + return FALSE; + } + return TRUE; +} + + +void StatementControl::AnimateMouse( Window *pControl, TTHotSpots aWohin ) +{ + Point aZiel; + + switch (aWohin) + { + case MitteLinks: + { + long nHeight = pControl->GetSizePixel().Height(); + aZiel.X() += 5; + aZiel.Y() += nHeight / 2; + } + break; + case Mitte: + { + Size aSize = pControl->GetOutputSizePixel(); + aZiel.Move( aSize.Width() / 2, aSize.Height() / 2 ); + } + break; + case MitteOben: + { + long nWidth = pControl->GetSizePixel().Width(); + aZiel.X() += nWidth / 2; + aZiel.Y() += 5; + } + break; + } + AnimateMouse( pControl, aZiel ); +} + + +void StatementControl::AnimateMouse( Window *pControl, Point aWohin ) +{ + Point aAkt = pControl->GetPointerPosPixel(); + Point aZiel = aWohin; + + USHORT nSteps; + Point aDiff = aAkt - aZiel; + + if ( Abs(aDiff.X()) < Abs(aDiff.Y()) ) + nSteps = Abs(aDiff.Y()) / 5; + else + nSteps = Abs(aDiff.X()) / 5; + if ( nSteps == 0 ) + return; + + aDiff *= 1000; + aDiff /= nSteps; + + StatementList::bExecuting = TRUE; // Bah ist das ein ekliger Hack + // Das verhindert, daß schon der nächste Befehl ausgeführt wird. + + for ( ; nSteps ; nSteps-- ) + { + if ( Abs((aAkt - pControl->GetPointerPosPixel()).X()) > 5 || + Abs((aAkt - pControl->GetPointerPosPixel()).Y()) > 5 ) + nSteps = 1; + aAkt = aZiel + aDiff * nSteps / 1000; + pControl->SetPointerPosPixel(aAkt); + SafeReschedule(); + } + pControl->SetPointerPosPixel(aZiel); + StatementList::bExecuting = FALSE; // Bah ist das ein ekliger Hack +} + + +BOOL StatementControl::MaybeDoTypeKeysDelay( Window *pTestWindow ) +{ + if ( bDoTypeKeysDelay ) + { + ULONG nTimeWait = nMinTypeKeysDelay; + if ( nMaxTypeKeysDelay != nMinTypeKeysDelay ) + nTimeWait += Time::GetSystemTicks() % ( nMaxTypeKeysDelay - nMinTypeKeysDelay ); + Timer aTimer; + aTimer.SetTimeout( nTimeWait ); + aTimer.Start(); + StatementList::bExecuting = TRUE; // Bah ist das ein ekliger Hack + // Das verhindert, daß schon der nächste Befehl ausgeführt wird. + while ( aTimer.IsActive() ) + { + SafeReschedule( TRUE ); + } + StatementList::bExecuting = FALSE; // Bah ist das ein ekliger Hack + if ( !WinPtrValid(pTestWindow ) ) + { + ReportError( nUId, GEN_RES_STR1( S_WINDOW_DISAPPEARED, MethodString( nMethodId ) ) ); + return FALSE; + } + } + return TRUE; +} + +BOOL StatementControl::HandleVisibleControls( Window *pControl ) +{ + if( pControl ) // Also auch bei Disabled nicht jedoch bei Invisible + { + switch( nMethodId ) + { + case M_IsEnabled: + pRet->GenReturn ( RET_Value, nUId, IsAccessable(pControl) ); + break; + case M_IsVisible: + pRet->GenReturn ( RET_Value, nUId, pControl->IsVisible() ); + break; + case M_GetPosX: + if ( pControl->GetType() == WINDOW_DOCKINGWINDOW && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_FLOATINGWINDOW ) + pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für FloatingWindows + if ( pControl->GetType() == WINDOW_TABCONTROL && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_TABDIALOG ) + pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für TabDialoge + if ( pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_BORDERWINDOW ) + pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für Border + if ( (nParams & PARAM_BOOL_1) && bBool1 ) + pControl = pControl->GetWindow( WINDOW_OVERLAP ); + + if ( pControl->GetType() == WINDOW_DOCKINGWINDOW && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_SPLITWINDOW ) + { + Point aPos = pControl->GetPosPixel(); + aPos = pControl->GET_REAL_PARENT()->OutputToScreenPixel( aPos ); + pRet->GenReturn ( RET_Value, nUId, (ULONG)aPos.X() ); + } + else + pRet->GenReturn ( RET_Value, nUId, (ULONG)pControl->GetPosPixel().X() ); + break; + case M_GetPosY: + if ( pControl->GetType() == WINDOW_DOCKINGWINDOW && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_FLOATINGWINDOW ) + pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für FloatingWindows + if ( pControl->GetType() == WINDOW_TABCONTROL && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_TABDIALOG ) + pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für TabDialoge + if ( pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_BORDERWINDOW ) + pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für Border + if ( (nParams & PARAM_BOOL_1) && bBool1 ) + pControl = pControl->GetWindow( WINDOW_OVERLAP ); + + if ( pControl->GetType() == WINDOW_DOCKINGWINDOW && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_SPLITWINDOW ) + { + Point aPos = pControl->GetPosPixel(); + aPos = pControl->GET_REAL_PARENT()->OutputToScreenPixel( aPos ); + pRet->GenReturn ( RET_Value, nUId, (ULONG)aPos.Y() ); + } + else + pRet->GenReturn ( RET_Value, nUId, (ULONG)pControl->GetPosPixel().Y() ); + break; + case M_GetSizeX: + if ( pControl->GetType() == WINDOW_DOCKINGWINDOW && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_FLOATINGWINDOW ) + pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für FloatingWindows + if ( pControl->GetType() == WINDOW_TABCONTROL && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_TABDIALOG ) + pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für TabDialoge + if ( pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_BORDERWINDOW ) + pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für Border + if ( (nParams & PARAM_BOOL_1) && bBool1 ) + pControl = pControl->GetWindow( WINDOW_OVERLAP ); + + pRet->GenReturn ( RET_Value, nUId, (ULONG)pControl->GetSizePixel().Width() ); + break; + case M_GetSizeY: + if ( pControl->GetType() == WINDOW_DOCKINGWINDOW && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_FLOATINGWINDOW ) + pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für FloatingWindows + if ( pControl->GetType() == WINDOW_TABCONTROL && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_TABDIALOG ) + pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für TabDialoge + if ( pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_BORDERWINDOW ) + pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für Border + if ( (nParams & PARAM_BOOL_1) && bBool1 ) + pControl = pControl->GetWindow( WINDOW_OVERLAP ); + + pRet->GenReturn ( RET_Value, nUId, (ULONG)pControl->GetSizePixel().Height() ); + break; + case M_SnapShot: + { + if ( pControl->GetType() == WINDOW_DOCKINGWINDOW && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_FLOATINGWINDOW ) + pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für FloatingWindows + if ( pControl->GetType() == WINDOW_TABCONTROL && pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_TABDIALOG ) + pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für TabDialoge + if ( pControl->GET_REAL_PARENT() && pControl->GET_REAL_PARENT()->GetType() == WINDOW_BORDERWINDOW ) + pControl = pControl->GET_REAL_PARENT(); // Sonderbehandlung für Border + if ( (nParams & PARAM_BOOL_1) && bBool1 ) + pControl = pControl->GetWindow( WINDOW_OVERLAP ); + + Bitmap aBmp = pControl->SnapShot(); + if ( pControl->GetType() == WINDOW_WORKWINDOW ) + { + Point aStart = pControl->GetPosPixel(); + if ( !(nParams & PARAM_USHORT_4) ) + { + nParams |= PARAM_USHORT_1; + nParams |= PARAM_USHORT_2; + nParams |= PARAM_USHORT_3; + nParams |= PARAM_USHORT_4; + nNr1 = (USHORT)-aStart.X(); + nNr2 = (USHORT)-aStart.Y(); + nNr3 = pControl->GetSizePixel().Width() + 2*(USHORT)aStart.X(); + nNr4 = pControl->GetSizePixel().Height() + 2*(USHORT)aStart.Y(); + } + nNr1 = std::max((USHORT)-aStart.X(),nNr1); + nNr2 = std::max((USHORT)-aStart.Y(),nNr2); + nNr3 = std::min((USHORT)(pControl->GetSizePixel().Width() + 2*(USHORT)aStart.X()),nNr3); + nNr4 = std::min((USHORT)(pControl->GetSizePixel().Height() + 2*(USHORT)aStart.Y()),nNr4); + } + if( nParams & PARAM_USHORT_4 ) + { // Zuschneiden + Point aPt(-nNr1,-nNr2); + Size aSz(nNr3,nNr4); + VirtualDevice aVDev( *pControl ); + + aVDev.SetOutputSizePixel( aSz ); + aVDev.DrawBitmap( aPt, aBmp ); + aBmp = aVDev.GetBitmap( Point(), aSz ); + } + + SvFileStream fOut; + fOut.Open(aString1,STREAM_STD_WRITE); + aBmp.Write(fOut); + if ( fOut.GetError() ) + ReportError( nUId, GEN_RES_STR1( S_ERROR_SAVING_IMAGE, UniString::CreateFromInt32( fOut.GetError() ) ) ); + fOut.Close(); + } + break; + case M_GetFixedTextCount: + { + pRet->GenReturn ( RET_Value, nUId, CountWinByRT( pControl, WINDOW_FIXEDTEXT, TRUE ) ); + } + break; + case M_GetFixedText: + { + if( ( nParams & PARAM_USHORT_1 ) == 0 ) + nNr1 = 1; + + FixedText* pFixedText = (FixedText*)GetWinByRT( pControl, WINDOW_FIXEDTEXT, TRUE, nNr1-1 ); + if ( pFixedText ) + pRet->GenReturn ( RET_Value, nUId, pFixedText->GetText() ); + else + ValueOK(nUId, MethodString( nMethodId ),nNr1,CountWinByRT( pControl, WINDOW_FIXEDTEXT, TRUE ) ); + } + break; + default: + return FALSE; + } + SendProfile( UIdString( nUId ).Append('.').Append( MethodString( nMethodId ) ) ); + return TRUE; + } + return FALSE; +} + +BOOL StatementControl::HandleCommonMethods( Window *pControl ) +{ + switch( nMethodId ) // Diese können an jedem Window ausgeführt werden + { + case M_Exists: // Oben schon Behandelt. Unterdrückt hier nur Fehler + case M_NotExists: + case M_IsEnabled: + case M_IsVisible: + case M_SnapShot: + break; + case M_Caption : + { + pRet->GenReturn ( RET_Value, nUId, pControl->GetText()); + } + break; + case M_GetRT: + { + pRet->GenReturn ( RET_Value, nUId, (ULONG)pControl->GetType() ); + } + break; + case M_TypeKeys: + { + if( !(nParams & PARAM_USHORT_1) ) // Anzahl wiederholungen + nNr1 = 1; + if( !(nParams & PARAM_BOOL_1) ) // Follow Focus + bBool1 = FALSE; // so bleibt das bisherige Verhalten + + if ( !bBool1 ) // Altes Verhalten + pControl->GrabFocus(); + + if ( pControl->GetType() == WINDOW_COMBOBOX ) + { // Bei COMBOBOX an das Edit direkt liefern + Window *pTemp = NULL; + for ( int i = 0 ; i < pControl->GetChildCount() && !pTemp ; i++ ) + if ( pControl->GetChild( i )->GetType() == WINDOW_EDIT ) + pTemp = pControl->GetChild( i ); + if ( pTemp ) + pControl = pTemp; + } + + Window *pDeliverHere = pControl; + for (int j = 0; j < nNr1; j++) + for (xub_StrLen i = 0; i < aString1.Len(); i++) + { + if ( bBool1 ) // Jedesmal das FocusWindow finden + { + Window *pFocus = GetpApp()->GetFocusWindow(); + if ( pFocus && pControl->IsWindowOrChild( pFocus, TRUE ) ) + pDeliverHere = pFocus; + else // sonst fallback auf das Basisfenster + pDeliverHere = pControl; + } + KeyEvent aEvent; + if ( ((USHORT)aString1.GetChar(i)) <= 7 ) + { + USHORT nVal; + switch (aString1.GetChar(i)) + { + case 1: nVal = aString1.GetChar(i+1) + (aString1.GetChar(i+2) << 8); + i += 2; + break; + case 3: nVal = (aString1.GetChar(i+1) << 8); + i++; + break; + case 5: nVal = aString1.GetChar(i+1); + i++; + break; + case 7: nVal = 0; + break; + } + aEvent = KeyEvent(0,KeyCode(nVal & 0xFFF,nVal & 0xF000)); + } + else + { + sal_Unicode aCh = aString1.GetChar(i); + String aPrintableMisc = CUniString("xxxx xx+-*/.,<>="); + if ( aCh >= 'a' && aCh <= 'z' ) + aEvent = KeyEvent(aCh, KeyCode(KEYGROUP_ALPHA + aCh-'a', 0)); + else if ( aCh >= 'A' && aCh <= 'Z' ) + aEvent = KeyEvent(aCh, KeyCode(KEYGROUP_ALPHA + aCh-'a', KEY_SHIFT)); + else if ( aCh >= '0' && aCh <= '9' ) + aEvent = KeyEvent(aCh, KeyCode(KEYGROUP_NUM + aCh-'0', 0)); + else if ( aPrintableMisc.Search(aCh) != STRING_NOTFOUND ) + aEvent = KeyEvent(aCh, KeyCode(KEYGROUP_MISC + (USHORT)aPrintableMisc.Search(aCh), 0)); + else // Sollte eigentlich nicht auftreten + aEvent = KeyEvent(aCh, KeyCode()); + } + ImplKeyInput( pDeliverHere, aEvent ); + if ( !MaybeDoTypeKeysDelay( pControl ) ) + break; + else + SafeReschedule();SafeReschedule();SafeReschedule(); + } + } + break; + +#define CalcMouseButton\ + USHORT nButton = MOUSE_LEFT;\ + if ( (nParams & PARAM_USHORT_3) )\ + {\ + switch ( nNr3 )\ + {\ + case 1: nButton = MOUSE_LEFT; break;\ + case 2: nButton = MOUSE_MIDDLE; break;\ + case 3: nButton = MOUSE_RIGHT; break;\ + }\ + }\ + + case M_MouseDown: + { + CalcMouseButton; + Size aS = pControl->GetOutputSizePixel(); + Point aPos = Point(aS.Width() * nNr1 / 100,aS.Height() * nNr2 / 100); + Window *pActualWin = pControl->FindWindow( aPos ); +// AnimateMouse( pControl, aPos ); + + if ( pActualWin ) + aPos = pActualWin->AbsoluteScreenToOutputPixel( pControl->OutputToAbsoluteScreenPixel ( aPos ) ); +// aPos = pActualWin->ScreenToOutputPixel( pControl->OutputToScreenPixel ( aPos ) ); + else + pActualWin = pControl; + + AnimateMouse( pActualWin, aPos ); + pActualWin->GrabFocus(); + MouseEvent aMEvnt(aPos,1,MOUSE_SIMPLECLICK|MOUSE_SELECT,nButton); + ImplMouseButtonDown( pActualWin, aMEvnt ); + } + break; + case M_MouseUp: + { + CalcMouseButton; + Size aS = pControl->GetOutputSizePixel(); + Point aPos = Point(aS.Width() * nNr1 / 100,aS.Height() * nNr2 / 100); + Window *pActualWin = pControl->FindWindow( aPos ); + + if ( pActualWin ) + aPos = pActualWin->AbsoluteScreenToOutputPixel( pControl->OutputToAbsoluteScreenPixel ( aPos ) ); +// aPos = pActualWin->ScreenToOutputPixel( pControl->OutputToScreenPixel ( aPos ) ); + else + pActualWin = pControl; + + AnimateMouse( pActualWin, aPos ); +// pActualWin->GrabFocus(); + MouseEvent aMEvt( aPos, 1, MOUSE_SIMPLECLICK|MOUSE_SELECT, nButton ); + ImplMouseButtonUp( pActualWin, aMEvt ); + } + break; + case M_MouseMove: + { + CalcMouseButton; + Size aS = pControl->GetOutputSizePixel(); + Point aPos = Point(aS.Width() * nNr1 / 100,aS.Height() * nNr2 / 100); + Window *pActualWin = pControl->FindWindow( aPos ); + + if ( pActualWin ) + { + aPos = pActualWin->AbsoluteScreenToOutputPixel( pControl->OutputToAbsoluteScreenPixel ( aPos ) ); +// aPos = pActualWin->ScreenToOutputPixel( pControl->OutputToScreenPixel ( aPos ) ); + } + else + pActualWin = pControl; + + AnimateMouse( pActualWin, aPos ); +// pActualWin->GrabFocus(); + MouseEvent aMEvt( aPos, 0, MOUSE_SIMPLEMOVE|MOUSE_DRAGMOVE, nButton ); + ImplMouseMove( pActualWin, aMEvt ); + } + break; + case M_MouseDoubleClick: + { + CalcMouseButton; + Size aS = pControl->GetOutputSizePixel(); + Point aPos = Point(aS.Width() * nNr1 / 100,aS.Height() * nNr2 / 100); + Window *pActualWin = pControl->FindWindow( aPos ); + + if ( pActualWin ) + { + aPos = pActualWin->AbsoluteScreenToOutputPixel( pControl->OutputToAbsoluteScreenPixel ( aPos ) ); +// aPos = pActualWin->ScreenToOutputPixel( pControl->OutputToScreenPixel ( aPos ) ); + } + else + pActualWin = pControl; + + AnimateMouse( pActualWin, aPos ); + pActualWin->GrabFocus(); + MouseEvent aMEvnt; + aMEvnt = MouseEvent(aPos,1,MOUSE_SIMPLECLICK|MOUSE_SELECT,nButton); + ImplMouseButtonDown( pActualWin, aMEvnt ); + ImplMouseButtonUp ( pActualWin, aMEvnt ); + aMEvnt = MouseEvent(aPos,2,MOUSE_SIMPLECLICK|MOUSE_SELECT,nButton); + ImplMouseButtonDown( pActualWin, aMEvnt ); + ImplMouseButtonUp ( pActualWin, aMEvnt ); + } + break; + case M_DisplayPercent: + { + ModelessDialog *pDlg = new ModelessDialog(NULL); + pDlg->SetOutputSizePixel(Size(100,30)); + + Edit *pMyEd = new Edit(pDlg,WB_CENTER | WB_BORDER ); + pMyEd->SetSizePixel(Size(100,30)); + pDlg->SetText(CUniString("Schließen")); + pDlg->Show(); + pMyEd->Show(); + ULONG nTime = Time().GetTime(); + + while (pDlg->IsVisible()) + { + pDlg->ToTop(); + for (int i = 1 ; i<10 ; i++) + SafeReschedule(); + Point Pos = pControl->GetPointerPosPixel(); + Size Siz=pControl->GetOutputSizePixel(); + if ( Time().GetTime() - nTime > 10 ) + { + nTime = Time().GetTime(); + pMyEd->SetText(UniString::CreateFromInt32(Pos.X()*100/Siz.Width()).AppendAscii("%x").Append( UniString::CreateFromInt32(Pos.Y()*100/Siz.Height()) ).Append('%')); + } + } + + delete pMyEd; + delete pDlg; + } + break; + case M_OpenContextMenu: + { + nSubMenuId1 = 0; + nSubMenuId2 = 0; + pMenuWindow = NULL; + Point aPos; + BOOL bAtMousePos = ( nParams & PARAM_BOOL_1 ) && bBool1; + if ( bAtMousePos ) + { + aPos = pControl->GetPointerPosPixel(); + Window *pActualWin = pControl->FindWindow( aPos ); + + if ( pActualWin ) + { + aPos = pActualWin->AbsoluteScreenToOutputPixel( pControl->OutputToAbsoluteScreenPixel ( aPos ) ); +// aPos = pActualWin->ScreenToOutputPixel( pControl->OutputToScreenPixel ( aPos ) ); + pControl = pActualWin; + } + } + CommandEvent aEvent( aPos, COMMAND_CONTEXTMENU, bAtMousePos ); + ImplCommand( pControl, aEvent ); + } + break; + case M_UseMenu: + { + nSubMenuId1 = 0; + nSubMenuId2 = 0; + pMenuWindow = NULL; + + while ( pControl && !( ( pControl->GetType() == WINDOW_SYSWINDOW || pControl->GetType() == WINDOW_WORKWINDOW ) && ControlOK( pControl, "" ) ) ) + pControl = pControl->GET_REAL_PARENT(); + + if ( pControl && ((SystemWindow*)pControl)->GetMenuBar() ) + pMenuWindow = ((SystemWindow*)pControl); + else + ReportError( GEN_RES_STR1( S_NO_MENU, MethodString( nMethodId ) ) ); + } + break; + case M_FadeIn: + case M_FadeOut: + case M_Pin: + case M_IsFadeIn: + case M_IsPin: + { + WindowAlign aWindowAlign; + if ( (nParams & PARAM_USHORT_1) ) + { + switch ( nNr1 ) + { + case CONST_ALIGN_LEFT: + aWindowAlign = WINDOWALIGN_LEFT; + break; + case CONST_ALIGN_TOP: + aWindowAlign = WINDOWALIGN_TOP; + break; + case CONST_ALIGN_RIGHT: + aWindowAlign = WINDOWALIGN_RIGHT; + break; + case CONST_ALIGN_BOTTOM: + aWindowAlign = WINDOWALIGN_BOTTOM; + break; + default: + ReportError( nUId, GEN_RES_STR1( S_INVALID_POSITION, MethodString( nMethodId ) ) ); + } + } + else + aWindowAlign = WINDOWALIGN_LEFT; + + + Window* pTemp = NULL; + while ( !pTemp && pControl ) + { + pTemp = GetFadeSplitWin( pControl, aWindowAlign ); + pControl = pControl->GET_REAL_PARENT(); + } + + if ( !pTemp ) + { + ReportError( nUId, GEN_RES_STR1( S_SPLITWIN_NOT_FOUND, MethodString( nMethodId ) ) ); + break; + } + + pControl = pTemp; // So daß wir unten ohne Fehler durchkommen + SplitWindow *pSW = (SplitWindow*) pTemp; + +// Rectangle GetAutoHideRect() const; +// Rectangle GetFadeInRect() const; +// Rectangle GetFadeOutRect() const; + + switch( nMethodId ) + { + case M_FadeIn: + if ( pSW->IsFadeInButtonVisible() ) + pSW->FadeIn(); + break; + case M_FadeOut: + if ( pSW->IsFadeOutButtonVisible() ) + pSW->FadeOut(); + break; + case M_Pin: + if ( ( pSW->GetAutoHideState() && bBool1 ) + || ( !pSW->GetAutoHideState() && !bBool1 ) ) + { + MouseEvent aMEvnt; + Point aPt( pSW->GetAutoHideRect().Center() ); + aMEvnt = MouseEvent( aPt,1,MOUSE_SIMPLECLICK,MOUSE_LEFT ); + ImplMouseButtonDown( pControl, aMEvnt ); + ImplMouseButtonUp ( pControl, aMEvnt ); + } +// pSW->AutoHide(); + break; + case M_IsFadeIn: + pRet->GenReturn ( RET_Value, nUId, pSW->IsFadeOutButtonVisible() ); + break; + case M_IsPin: + pRet->GenReturn ( RET_Value, nUId, (BOOL)!pSW->GetAutoHideState() ); + break; + default: + ReportError( nUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) ); + } + SendProfile( UIdString( nUId ).Append('.').Append( MethodString( nMethodId ) ) ); + } + break; + case M_StatusGetText: + case M_StatusIsProgress: + case M_StatusGetItemCount: + case M_StatusGetItemId: + { + StatusBar *pStatus = NULL; + while ( !pStatus && pControl ) + { + pStatus = (StatusBar*)GetWinByRT( pControl, WINDOW_STATUSBAR, TRUE ); + pControl = pControl->GET_REAL_PARENT(); + } + + if ( !pStatus ) + { + ReportError( nUId, GEN_RES_STR1( S_NO_STATUSBAR, MethodString( nMethodId ) ) ); + break; + } + + switch ( nMethodId ) + { + case M_StatusGetText: + { + if ( (nParams & PARAM_USHORT_1) ) + { + if ( pStatus->AreItemsVisible() ) + pRet->GenReturn ( RET_Value, nUId, String(pStatus->GetItemText(nNr1))); + else + ReportError( nUId, GEN_RES_STR1( S_ITEMS_INVISIBLE, MethodString( nMethodId ) ) ); + } + else + { + if ( pStatus->AreItemsVisible() ) + { + if ( pStatus->GetItemCount() == 1 ) + { + pRet->GenReturn ( RET_Value, nUId, pStatus->GetItemText( pStatus->GetItemId(0) )); + } + else + { + pRet->GenReturn ( RET_Value, nUId, String() ); + } + } + else + pRet->GenReturn ( RET_Value, nUId, (String)pStatus->GetText() ); + } + } + break; + case M_StatusIsProgress: + { + pRet->GenReturn ( RET_Value, nUId, (BOOL)pStatus->IsProgressMode() ); + } + break; + case M_StatusGetItemCount: + if ( pStatus->AreItemsVisible() ) + pRet->GenReturn ( RET_Value, nUId, ULONG(pStatus->GetItemCount())); + else + pRet->GenReturn ( RET_Value, nUId, ULONG(0)); + break; + case M_StatusGetItemId: + if ( ValueOK(nUId, MethodString( nMethodId ),nNr1,pStatus->GetItemCount()) ) + pRet->GenReturn ( RET_Value, nUId, ULONG(pStatus->GetItemId(nNr1-1))); + break; + } + } + break; + case M_HasScrollBar: + case M_IsScrollBarEnabled: + { + if ( (nParams | PARAM_USHORT_1) != PARAM_USHORT_1 ) // so there are other params + { + ReportError( nUId, GEN_RES_STR0( S_INVALID_PARAMETERS ) ); + break; + } + + if( !(nParams & PARAM_USHORT_1) ) + nNr1 = CONST_ALIGN_RIGHT; // default is right Scrollbar(vertical) + + if ( (nNr1 != CONST_ALIGN_RIGHT) && (nNr1 != CONST_ALIGN_BOTTOM) ) + { + ReportError( nUId, GEN_RES_STR1( S_INVALID_POSITION, MethodString( nMethodId ) ) ); + break; + } + + ScrollBar *pScroll = NULL; + + USHORT nSteps = 2; + while ( !pScroll && pControl && nSteps-- ) + { + pScroll = GetScrollBar( pControl, nNr1, TRUE ); + pControl = pControl->GET_REAL_PARENT(); + } + + switch ( nMethodId ) + { + case M_HasScrollBar: + { + if ( pScroll ) + pRet->GenReturn ( RET_Value, nUId, (BOOL)TRUE ); + else + pRet->GenReturn ( RET_Value, nUId, (BOOL)FALSE ); + } + break; + case M_IsScrollBarEnabled: + { + if ( !pScroll ) + { + ReportError( nUId, GEN_RES_STR1( S_NO_SCROLLBAR, MethodString( nMethodId ) ) ); + break; + } + pRet->GenReturn ( RET_Value, nUId, pScroll->IsEnabled() ); + } + break; + } + } + break; + default: + return FALSE; + } + return TRUE; +} + + +BOOL StatementControl::Execute() +{ + Window *pControl; + BOOL bNormalWeiter = TRUE; + + if ( IsError ) + { + #ifdef DEBUG + m_pDbgWin->AddText( "Skipping Window: " ); + m_pDbgWin->AddText( String::CreateFromInt64( nUId ) ); + m_pDbgWin->AddText( " Method: " ); + m_pDbgWin->AddText( String::CreateFromInt32( nMethodId ) ); + m_pDbgWin->AddText( "\n" ); + #endif + Advance(); + delete this; + return TRUE; + } + + InitProfile(); +#ifdef DEBUG + m_pDbgWin->AddText( "Executing Window: " ); + m_pDbgWin->AddText( String::CreateFromInt64( nUId ) ); + m_pDbgWin->AddText( " Method: " ); + m_pDbgWin->AddText( String::CreateFromInt32( nMethodId ) ); + m_pDbgWin->AddText( "\n" ); +#endif + + + if (nUId == UID_ACTIVE) + pControl = GetAnyActive(); + else + { + BOOL bSearchButtonOnToolbox = (nParams == PARAM_NONE) && ((M_Click == nMethodId) || (M_TearOff == nMethodId) || (M_IsEnabled == nMethodId) || (M_OpenMenu == nMethodId)); + if ( nMethodId == M_TypeKeys || nMethodId == M_MouseDown + || nMethodId == M_MouseUp || nMethodId == M_MouseMove + || nMethodId == M_SnapShot ) + { + pControl = NULL; + if ( /*(nMethodId == M_SnapShot || nMethodId == M_TypeKeys) &&*/ !pControl ) + pControl = SearchTree( nUId ,bSearchButtonOnToolbox ); + } + else + pControl = SearchTree( nUId ,bSearchButtonOnToolbox ); + } + + + if ( pControl && pControl->GetType() == WINDOW_TOOLBOX && pControl->GetUniqueOrHelpId() != nUId ) + { // Also wenn wir irgendwas auf einer Toolbox gefunden haben + switch ( nMethodId ) + { + case M_Click: + case M_TearOff: + case M_OpenMenu: + break; + case M_IsEnabled: + nMethodId = _M_IsEnabled; // Umlabeln, da die Behandlung essentiell anders ist! + break; + default: + pControl = NULL; + } + } + + + switch ( nMethodId ) + { + case M_Exists: + case M_NotExists: + Time aT; + USHORT aSeconds = aT.GetMin()*60+aT.GetSec(); + if ( !bBool2 ) // wurde im Konstruktor auf FALSE gesetzt + { + bBool2 = TRUE; + nNr2 = aSeconds; + if( !(nParams & PARAM_USHORT_1) ) + nNr1 = 0; // defaultmäßig sofort zurück + } + if ( aSeconds < nNr2 ) // Falls die Stunde umgesprungen ist + aSeconds += 60*60; + + if ( /* !IsAccessable(pControl)#87019# */ !pControl || !pControl->IsVisible() ) + pControl = NULL; + if ( ((nMethodId == M_Exists) && pControl) || + ((nMethodId == M_NotExists) && !pControl) ) + { // Wenn Bedingung erfüllt + pRet->GenReturn ( RET_Value, nUId, (BOOL)TRUE ); + } + else + if ( aSeconds <= nNr2 + nNr1 ) // Zeit ist noch nicht abgelaufen + return FALSE; + else + pRet->GenReturn ( RET_Value, nUId, (BOOL)FALSE ); + + Advance(); + delete this; + return TRUE; + break; + } + + + short nRT = 0; + + if( pControl ) // Das Fenster Existiert irgendwo, kann aber auch hidden sein! + { + nRT = ImpGetRType( pControl, nUId ); +#ifdef DEBUG + m_pDbgWin->AddText( "Type is: " ); + m_pDbgWin->AddText( String::CreateFromInt32( nRT ) ); + m_pDbgWin->AddText( "\n" ); +#endif + } + + + + + if ( (!ControlOK( pControl, "" )) && ( nMethodId != M_SnapShot ) && (nRetryCount--)) + { +#ifdef DEBUG + m_pDbgWin->AddText( CUniString("Reschedule command (").Append( UniString::CreateFromInt32(nRetryCount) ).AppendAscii(")\n") ); +#endif + return FALSE; + } + + if( ControlOK( pControl, "" ) ) + { + if ( nMethodId == M_OpenContextMenu && !bBool2 ) + { + pControl->GrabFocus(); // to get asyncron focus on unix + bBool2 = TRUE; + return FALSE; + } + } + + Advance(); + + if ( HandleVisibleControls( pControl ) ) + { + delete this; + return TRUE; + } + if( ControlOK( pControl, "Window/Control" ) ) + { + if ((( nRT < C_TabPage && nRT > C_TabControl ) +// || nMethodId == M_TypeKeys // TypeKeys macht das selbst, falls eigenes Focushandling gewünscht +// || nMethodId == M_MouseDown +// || nMethodId == M_MouseUp +// || nMethodId == M_MouseMove +// || nMethodId == M_MouseDoubleClick + || nMethodId == M_OpenContextMenu ) + && nMethodId != M_TypeKeys // TypeKeys macht das selbst, falls eigenes Focushandling gewünscht + && nMethodId != M_MouseDown + && nMethodId != M_MouseUp + && nMethodId != M_MouseMove + /*&& nMethodId != M_MouseDoubleClick*/ ) + pControl->GrabFocus(); + + if ( bDoTypeKeysDelay && nMethodId == M_SetText && ( nParams & PARAM_STR_1 ) ) + { // Hier wird das Statement auf ein TypeKeys umgebogen + nMethodId = M_TypeKeys; + nParams = PARAM_BOOL_1 | PARAM_STR_1; + bBool1 = TRUE; + pControl->GrabFocus(); + } + + if ( !HandleCommonMethods( pControl ) ) + { + switch( nRT ) + { + case C_TabControl: + switch( nMethodId ) + { + case M_GetPageId: + if ( (nParams & PARAM_USHORT_1) ) + { + if ( ValueOK(nUId, MethodString( nMethodId ),nNr1,((TabControl*)pControl)->GetPageCount() ) ) + pRet->GenReturn ( RET_Value, nUId, (ULONG)((TabControl*)pControl)->GetPageId(nNr1-1)); + } + else + pRet->GenReturn ( RET_Value, nUId, (ULONG)((TabControl*)pControl)->GetCurPageId()); + break; + case M_GetPageCount: + pRet->GenReturn ( RET_Value, nUId, (ULONG)((TabControl*)pControl)->GetPageCount()); + break; + case M_SetPageId: + if (((TabControl*)pControl)->GetCurPageId()) + ((TabControl*)pControl)->DeactivatePage(); + ((TabControl*)pControl)->SetCurPageId( nNr1 ); + ((TabControl*)pControl)->ActivatePage(); + break; + case M_SetPageNr: + if ( ValueOK(nUId, MethodString( nMethodId ),nNr1,((TabControl*)pControl)->GetPageCount() ) ) + { + if (((TabControl*)pControl)->GetCurPageId()) + ((TabControl*)pControl)->DeactivatePage(); + ((TabControl*)pControl)->SetCurPageId( ((TabControl*)pControl)->GetPageId( nNr1-1 ) ); + ((TabControl*)pControl)->ActivatePage(); + } + break; + case M_GetPage: + pRet->GenReturn ( RET_Value, nUId, ((TabControl*)pControl)->GetTabPage(((TabControl*)pControl)->GetCurPageId())->GetUniqueOrHelpId()); + break; + case M_SetPage : + { // Wegen lokaler Variablen + TabControl *pTControl = ((TabControl*)pControl); + USHORT nActive = pTControl->GetCurPageId(); + USHORT i,anz; + ULONG nID = 0; + i = pTControl->GetPagePos( pTControl->GetCurPageId() ); + for ( anz=0 ; anz < pTControl->GetPageCount() && nID != nLNr1 ; anz++ ) + { + pTControl->SelectTabPage( pTControl->GetPageId(i) ); + /*if (pTControl->GetCurPageId()) + pTControl->DeactivatePage(); + pTControl->SetCurPageId( pTControl->GetPageId(i) ); + pTControl->ActivatePage();*/ + nID = pTControl->GetTabPage(pTControl->GetCurPageId())->GetUniqueOrHelpId(); + i++; + if ( i >= pTControl->GetPageCount() ) + i = 0; + if ( !MaybeDoTypeKeysDelay( pTControl ) || !MaybeDoTypeKeysDelay( pTControl ) || !MaybeDoTypeKeysDelay( pTControl ) ) // 3 Mal aufrufen + break; + } + if ( nID != nLNr1 ) + { + pTControl->SelectTabPage( nActive ); + /*if (pTControl->GetCurPageId()) + pTControl->DeactivatePage(); + pTControl->SetCurPageId( nActive ); + pTControl->ActivatePage();*/ + ReportError( nLNr1, GEN_RES_STR1( S_TABPAGE_NOT_FOUND, MethodString( nMethodId ) ) ); + } + } + break; + default: + ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "TabControl" ) ); + break; + } + break; + case C_RadioButton: + case C_ImageRadioButton: + switch( nMethodId ) + { + case M_AnimateMouse : + AnimateMouse( pControl, MitteLinks); + break; + case M_IsChecked : + pRet->GenReturn ( RET_Value, nUId, ((RadioButton*)pControl)->IsChecked()); + break; + case M_Check : + ((RadioButton*)pControl)->Check(); + ((RadioButton*)pControl)->Click(); + break; + default: + ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "RadioButton" ) ); + break; + } + break; + case C_CheckBox: + case C_TriStateBox: + switch( nMethodId ) + { + case M_AnimateMouse : + AnimateMouse( pControl, MitteLinks); + break; + case M_IsChecked : + pRet->GenReturn ( RET_Value, nUId, BOOL( ((TriStateBox*)pControl)->GetState() == STATE_CHECK) ); + break; + case M_IsTristate : + pRet->GenReturn ( RET_Value, nUId, BOOL( ((TriStateBox*)pControl)->GetState() == STATE_DONTKNOW) ); + break; + case M_GetState : + pRet->GenReturn ( RET_Value, nUId, ULONG(((TriStateBox*)pControl)->GetState())); + break; + case M_Check : + ((TriStateBox*)pControl)->SetState( STATE_CHECK ); + ((TriStateBox*)pControl)->Click(); + break; + case M_UnCheck : + ((TriStateBox*)pControl)->SetState( STATE_NOCHECK ); + ((TriStateBox*)pControl)->Click(); + break; + case M_TriState : + if ( ((TriStateBox*)pControl)->IsTriStateEnabled() ) + { + ((TriStateBox*)pControl)->SetState( STATE_DONTKNOW ); + ((TriStateBox*)pControl)->Click(); + } + else + { + ReportError( nUId, GEN_RES_STR0( S_TRISTATE_NOT_ALLOWED ) ); + } + break; + case M_Click : + { + TriStateBox *pTB = ((TriStateBox*)pControl); + if ( pTB->GetState() == STATE_NOCHECK ) + pTB->SetState( STATE_CHECK ); + else if ( pTB->GetState() == STATE_CHECK ) + { + if ( pTB->IsTriStateEnabled() ) + pTB->SetState( STATE_DONTKNOW ); + else + pTB->SetState( STATE_NOCHECK ); + } + else + pTB->SetState( STATE_NOCHECK ); + pTB->Click(); + } + break; + default: + ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "TriStateBox" ) ); + break; + } + break; + case C_Edit: + case C_MultiLineEdit: + switch( nMethodId ) + { + case M_AnimateMouse : + AnimateMouse( pControl, Mitte); + break; + case M_GetText : + pRet->GenReturn ( RET_Value, nUId, ((Edit*)pControl)->GetText()); + break; + case M_IsWritable: + pRet->GenReturn ( RET_Value, nUId, (BOOL) !((Edit*)pControl)->IsReadOnly() ); + break; + default: + if ( ! ((Edit*)pControl)->IsReadOnly() ) + { + switch( nMethodId ) + { + case M_SetText : + ((Edit*)pControl)->SetText( aString1 ); + ((Edit*)pControl)->SetModifyFlag(); + ((Edit*)pControl)->Modify(); + if ( ((Edit*)pControl)->GetText().CompareTo(aString1) != COMPARE_EQUAL ) + ReportError( nUId, GEN_RES_STR1( S_ERROR_IN_SET_TEXT, MethodString( nMethodId ) ) ); + break; + default: + ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "(MultiLine)Edit" ) ); + break; + } + } + else + ReportError( nUId, GEN_RES_STR1c( S_ATTEMPT_TO_WRITE_READONLY, "(MultiLine)Edit" ) ); + } + break; + case C_MultiListBox: + case C_ListBox: + switch( nMethodId ) + { + case M_AnimateMouse : + AnimateMouse( pControl, MitteOben); + break; + case M_GetSelCount : + pRet->GenReturn ( RET_Value, nUId, ULONG(((ListBox*)pControl)->GetSelectEntryCount())); + break; + case M_GetSelIndex : + if ( ! (nParams & PARAM_USHORT_1) ) + { + if ( ((ListBox*)pControl)->GetSelectEntryCount() == 0 ) + { + pRet->GenReturn ( RET_Value, nUId, ULONG(0)); + break; + } + nNr1 = 1; + } + ValueOK(nUId, MethodString( nMethodId ),nNr1,((ListBox*)pControl)->GetSelectEntryCount()); + pRet->GenReturn ( RET_Value, nUId, ULONG(((ListBox*)pControl)->GetSelectEntryPos(nNr1-1)) +1); + break; + case M_GetSelText : + if ( ! (nParams & PARAM_USHORT_1) ) + nNr1 = 1; + pRet->GenReturn ( RET_Value, nUId, ((ListBox*)pControl)->GetSelectEntry(nNr1-1)); + break; + case M_GetItemCount : + pRet->GenReturn ( RET_Value, nUId, ULONG(((ListBox*)pControl)->GetEntryCount())); + break; + case M_GetItemText : + pRet->GenReturn ( RET_Value, nUId, ((ListBox*)pControl)->GetEntry(nNr1-1)); + break; + case M_Select: + case M_MultiSelect: + { + BOOL bUnselectBeforeSelect = ( nMethodId == M_Select ); + BOOL bFehler = FALSE; + if ( ! (nParams & PARAM_BOOL_1) ) + bBool1 = TRUE; + + if ( nMethodId == M_MultiSelect && nRT == C_ListBox ) + { + ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "ListBox" ) ); + bFehler = TRUE; + } + + if ( !bBool1 && nMethodId == M_Select ) + { + ReportError( nUId, GEN_RES_STR1( S_NO_SELECT_FALSE, MethodString( nMethodId ) ) ); + bFehler = TRUE; + } + + if ( !bFehler ) + { + if( nParams & PARAM_STR_1 ) + { + ListBox *pLB = ((ListBox*)pControl); + USHORT nPos; + if ( (nPos = pLB->GetEntryPos( aString1 )) == LISTBOX_ENTRY_NOTFOUND ) + ReportError( nUId, GEN_RES_STR2( S_ENTRY_NOT_FOUND, MethodString( nMethodId ), aString1 ) ); + else + { + if ( bUnselectBeforeSelect ) + pLB->SetNoSelection(); + pLB->SelectEntryPos( nPos, bBool1 ); + if ( pLB->IsEntryPosSelected( nPos ) ? !bBool1 : bBool1 ) // XOR rein mit BOOL + ReportError( nUId, GEN_RES_STR2( S_METHOD_FAILED, MethodString( nMethodId ), aString1 ) ); + } + } + else + { + ListBox *pLB = ((ListBox*)pControl); + if ( ValueOK(nUId, MethodString( nMethodId ),nNr1,pLB->GetEntryCount()) ) + { + if ( bUnselectBeforeSelect ) + pLB->SetNoSelection(); + pLB->SelectEntryPos( nNr1-1, bBool1 ); + if ( pLB->IsEntryPosSelected( nNr1-1 ) ? !bBool1 : bBool1 ) // XOR rein mit BOOL + ReportError( nUId, GEN_RES_STR2( S_METHOD_FAILED, MethodString( nMethodId ), UniString::CreateFromInt32( nNr1 ) ) ); + } + } + ((ListBox*)pControl)->Select(); + } + } + break; + case M_SetNoSelection : + ((ListBox*)pControl)->SetNoSelection(); + ((ListBox*)pControl)->Select(); + break; + default: + ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "(Multi)ListBox" ) ); + break; + } + break; + case C_ComboBox: + case C_PatternBox: + case C_NumericBox: + case C_MetricBox: + case C_CurrencyBox: + case C_DateBox: + case C_TimeBox: + switch( nMethodId ) + { + case M_AnimateMouse : + AnimateMouse( pControl, MitteOben); + break; + case M_GetSelText : + pRet->GenReturn ( RET_Value, nUId, ((ComboBox*)pControl)->GetText()); + break; + case M_GetSelIndex : + { + USHORT nPos = ((ComboBox*)pControl)->GetEntryPos(((ComboBox*)pControl)->GetText()); + if ( nPos == COMBOBOX_ENTRY_NOTFOUND ) + nPos = 0; + else + nPos++; + pRet->GenReturn ( RET_Value, nUId, (ULONG) nPos); + } + break; + case M_GetItemCount : + pRet->GenReturn ( RET_Value, nUId, ULONG(((ComboBox*)pControl)->GetEntryCount())); + break; + case M_GetItemText : + pRet->GenReturn ( RET_Value, nUId, ((ComboBox*)pControl)->GetEntry(nNr1-1)); + break; + case M_IsWritable: + pRet->GenReturn ( RET_Value, nUId, (BOOL) !((ComboBox*)pControl)->IsReadOnly() ); + break; + case M_Select : + if( nParams & PARAM_USHORT_1 ) + { + if ( !ValueOK(nUId, MethodString( nMethodId ),nNr1,((ComboBox*)pControl)->GetEntryCount()) ) + break; + aString1 = ((ComboBox*)pControl)->GetEntry(nNr1-1); + } + else + { + if ( ((ComboBox*)pControl)->GetEntryPos( aString1 ) == COMBOBOX_ENTRY_NOTFOUND ) + { + ReportError( nUId, GEN_RES_STR2( S_ENTRY_NOT_FOUND, MethodString( nMethodId ), aString1 ) ); + break; + } + } + + + ((ComboBox*)pControl)->SetText( aString1 ); + ((ComboBox*)pControl)->SetModifyFlag(); + ((ComboBox*)pControl)->Modify(); + break; + case M_SetText : + if ( ! ((ComboBox*)pControl)->IsReadOnly() ) + { + if ( ! (nParams & PARAM_STR_1) ) + aString1 = String(); + ((ComboBox*)pControl)->SetText( aString1 ); + ((ComboBox*)pControl)->SetModifyFlag(); + ((ComboBox*)pControl)->Modify(); + } + else + ReportError( nUId, GEN_RES_STR1c( S_ATTEMPT_TO_WRITE_READONLY, "ComboBox" ) ); + break; + default: + ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "ComboBox" ) ); + break; + } + break; + case C_PushButton: + case C_OkButton: + case C_CancelButton: + case C_ImageButton: + switch( nMethodId ) + { + case M_AnimateMouse : + AnimateMouse( pControl, Mitte); + break; + case M_Click : + ((PushButton*)pControl)->Click(); + break; + default: + ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "PushButton" ) ); + break; + } + break; + case C_MoreButton: + switch( nMethodId ) + { + case M_AnimateMouse : + AnimateMouse( pControl, Mitte); + break; + case M_IsOpen : + pRet->GenReturn ( RET_Value, nUId, ((MoreButton*)pControl)->GetState()); + break; + case M_Click : + ((MoreButton*)pControl)->Click(); + break; + case M_Open : + ((MoreButton*)pControl)->SetState(TRUE); + break; + case M_Close : + ((MoreButton*)pControl)->SetState(FALSE); + break; + default: + ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "MoreButton" ) ); + break; + } + break; + case C_SpinField: + case C_PatternField: + case C_NumericField: + case C_MetricField: + case C_CurrencyField: + case C_DateField: + case C_TimeField: + switch( nMethodId ) + { + case M_AnimateMouse : + AnimateMouse( pControl, Mitte); + break; + case M_GetText : + pRet->GenReturn ( RET_Value, nUId, ((SpinField*)pControl)->GetText()); + break; + case M_IsWritable: + pRet->GenReturn ( RET_Value, nUId, (BOOL) !((SpinField*)pControl)->IsReadOnly() ); + break; + case M_SetText : + if ( ! ((SpinField*)pControl)->IsReadOnly() ) + { + ((SpinField*)pControl)->SetText( aString1 ); + ((SpinField*)pControl)->SetModifyFlag(); + ((SpinField*)pControl)->Modify(); + } + else + ReportError( nUId, GEN_RES_STR1c( S_ATTEMPT_TO_WRITE_READONLY, "SpinField" ) ); + break; + case M_More : + { + if ( !(nParams & PARAM_USHORT_1) ) + nNr1 = 1; + for (int i = 1; i<= nNr1; i++) + { + ((SpinField*)pControl)->Up(); + ((SpinField*)pControl)->SetModifyFlag(); + ((SpinField*)pControl)->Modify(); + } + } + break; + case M_Less : + { + if ( !(nParams & PARAM_USHORT_1) ) + nNr1 = 1; + for (int i = 1; i<= nNr1; i++) + { + ((SpinField*)pControl)->Down(); + ((SpinField*)pControl)->SetModifyFlag(); + ((SpinField*)pControl)->Modify(); + } + } + break; + case M_ToMin : + ((SpinField*)pControl)->First(); + ((SpinField*)pControl)->SetModifyFlag(); + ((SpinField*)pControl)->Modify(); + break; + case M_ToMax : + ((SpinField*)pControl)->Last(); + ((SpinField*)pControl)->SetModifyFlag(); + ((SpinField*)pControl)->Modify(); + break; + default: + ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "SpinField" ) ); + break; + } + break; + + case C_MenuButton: + switch( nMethodId ) + { + case M_AnimateMouse : + AnimateMouse( pControl, Mitte); + break; + case M_Click : + { + MouseEvent aMEvnt; + Point aPt( pControl->GetSizePixel().Width() / 2, pControl->GetSizePixel().Height() / 2 ); + aMEvnt = MouseEvent( aPt,1,MOUSE_SIMPLECLICK,MOUSE_LEFT ); + ImplMouseButtonDown( pControl, aMEvnt ); + ImplMouseButtonUp ( pControl, aMEvnt ); + } + break; + case M_Open : + case M_OpenMenu : + { + MouseEvent aMEvnt; + Point aPt( pControl->GetSizePixel().Width() / 2, pControl->GetSizePixel().Height() / 2 ); + aMEvnt = MouseEvent( aPt,1,MOUSE_SIMPLECLICK,MOUSE_LEFT ); + ImplMouseButtonDown( pControl, aMEvnt ); + + ULONG nStart = Time::GetSystemTicks(); + ULONG nDelay = pControl->GetSettings().GetMouseSettings().GetActionDelay(); + while ( ( Time::GetSystemTicks() - nStart ) < nDelay + 100 ) + SafeReschedule(); + + ImplMouseButtonUp ( pControl, aMEvnt ); + + nSubMenuId1 = 0; + nSubMenuId2 = 0; + pMenuWindow = NULL; + } + break; + default: + ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "MenuButton" ) ); + break; + } + break; + case C_ToolBox: + { + ToolBox *pTB = ((ToolBox*)pControl); + if ( pTB->GetUniqueOrHelpId() != nUId ) // Also Button auf der ToolBox gefunden + { + if ( nParams == PARAM_NONE ) + { // Wir fälschen einen Parameter + nParams = PARAM_USHORT_1; + nNr1 = nUId; + } + else + ReportError( nUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) ); + } + +#define FIND_HELP\ + {\ + if( nParams == PARAM_USHORT_1 )\ + nLNr1 = nNr1;\ + for ( nNr1 = 0; nNr1 < pTB->GetItemCount() && nLNr1 != pTB->GetHelpId(pTB->GetItemId(nNr1)) ; nNr1++ ) {}\ + bBool1 = nLNr1 == pTB->GetHelpId(pTB->GetItemId(nNr1));\ + if ( !bBool1 )\ + ReportError( nUId, GEN_RES_STR1( S_HELPID_ON_TOOLBOX_NOT_FOUND, MethodString( nMethodId ) ) );\ + else\ + {\ + if ( !pTB->IsItemEnabled( pTB->GetItemId(nNr1) ) && nMethodId != _M_IsEnabled )\ + {\ + ReportError( nUId, GEN_RES_STR1( S_BUTTON_DISABLED_ON_TOOLBOX, MethodString( nMethodId ) ) );\ + bBool1 = FALSE;\ + }\ + else if ( !pTB->IsItemVisible( pTB->GetItemId(nNr1) ) )\ + {\ + ReportError( nUId, GEN_RES_STR1( S_BUTTON_HIDDEN_ON_TOOLBOX, MethodString( nMethodId ) ) );\ + bBool1 = FALSE;\ + }\ + else\ + {\ + if ( pTB->GetItemRect(pTB->GetItemId(nNr1)).IsEmpty() )\ + {\ + USHORT nLine = pTB->GetCurLine();\ + do\ + {\ + pTB->ShowLine( FALSE );\ + for ( int i = 1 ; i < 30 ; i++ )\ + SafeReschedule();\ + }\ + while ( pTB->GetCurLine() != nLine && pTB->GetItemRect(pTB->GetItemId(nNr1)).IsEmpty() );\ + pTB->Invalidate( pTB->GetScrollRect() );\ + }\ + if ( pTB->GetItemRect(pTB->GetItemId(nNr1)).IsEmpty() )\ + {\ + ReportError( nUId, GEN_RES_STR1( S_CANNOT_MAKE_BUTTON_VISIBLE_IN_TOOLBOX, MethodString( nMethodId ) ) );\ + bBool1 = FALSE;\ + }\ + }\ + }\ + }\ + + switch( nMethodId ) + { + case M_AnimateMouse : + AnimateMouse( pControl, MitteLinks); + break; + case M_Click : + { + FIND_HELP; + if ( bBool1 ) // FIND_HELP Erfolgreich + { + Rectangle aRect = pTB->GetItemRect(pTB->GetItemId(nNr1)); + MouseEvent aMEvnt; + aMEvnt = MouseEvent(aRect.Center(),1,MOUSE_SIMPLECLICK,MOUSE_LEFT); + ImplMouseButtonDown( pTB, aMEvnt ); + ImplMouseButtonUp ( pTB, aMEvnt ); + } + } + break; + case M_TearOff : + { + FIND_HELP; + if ( bBool1 ) // FIND_HELP Erfolgreich + { + Rectangle aRect = pTB->GetItemRect(pTB->GetItemId(nNr1)); + AnimateMouse( pControl, aRect.Center() ); + MouseEvent aMEvnt(aRect.Center(),1,MOUSE_SIMPLECLICK,MOUSE_LEFT); + ImplMouseButtonDown( pTB, aMEvnt ); + + Window *pWin = NULL; + StatementList::bExecuting = TRUE; // Bah ist das ein ekliger Hack + { // Das verhindert, daß schon der nächste Befehl ausgeführt wird. + ULONG nStart = Time::GetSystemTicks(); + ULONG nDelay = pControl->GetSettings().GetMouseSettings().GetActionDelay(); + while ( !(pWin = GetPopupFloatingWin()) && ( Time::GetSystemTicks() - nStart ) < nDelay + 100 ) + SafeReschedule(); + } + StatementList::bExecuting = FALSE; // Bah ist das ein ekliger Hack + + // Das Fenster ist offen. + StatementList::bExecuting = TRUE; // Bah ist das ein ekliger Hack + { // Das verhindert, daß schon der nächste Befehl ausgeführt wird. + Time aDelay; + while ( !pWin && !(pWin = GetPopupFloatingWin()) && ( Time() - aDelay ).GetSec() < 15 ) + SafeReschedule(); + } + StatementList::bExecuting = FALSE; // Bah ist das ein ekliger Hack + + if ( pWin ) + { + MouseEvent aMEvnt(aRect.Center(),1,MOUSE_SIMPLECLICK,MOUSE_LEFT); + ImplMouseButtonUp( pTB, aMEvnt ); + ((FloatingWindow*)pWin)->EndPopupMode( FLOATWIN_POPUPMODEEND_TEAROFF ); + } + else + { + MouseEvent aMEvnt(Point(1,-10), 1, MOUSE_SIMPLECLICK,MOUSE_LEFT); + ImplMouseButtonUp( pTB, aMEvnt ); + ReportError( nUId, GEN_RES_STR1( S_TEAROFF_FAILED, MethodString( nMethodId ) ) ); + } + } + } + break; + case M_OpenMenu : + { + FIND_HELP; + if ( bBool1 ) // FIND_HELP Erfolgreich + { + Rectangle aRect = pTB->GetItemRect(pTB->GetItemId(nNr1)); + AnimateMouse( pControl, aRect.Center() ); + MouseEvent aMEvnt(aRect.Center(),1,MOUSE_SIMPLECLICK,MOUSE_LEFT); + ImplMouseButtonDown( pTB, aMEvnt ); + + StatementList::bExecuting = TRUE; // Bah ist das ein ekliger Hack + { // Das verhindert, daß schon der nächste Befehl ausgeführt wird. + ULONG nStart = Time::GetSystemTicks(); + ULONG nDelay = pControl->GetSettings().GetMouseSettings().GetActionDelay(); + while ( ( Time::GetSystemTicks() - nStart ) < nDelay + 100 ) + SafeReschedule(); + } + StatementList::bExecuting = FALSE; // Bah ist das ein ekliger Hack + + // Das Fenster ist offen. + nSubMenuId1 = 0; + nSubMenuId2 = 0; + pMenuWindow = NULL; + } + } + break; + case _M_IsEnabled: + { + FIND_HELP; + if ( bBool1 ) // FIND_HELP Erfolgreich + { + pRet->GenReturn ( RET_Value, nUId, pTB->IsItemEnabled( pTB->GetItemId(nNr1) ) ); + } + } + break; + case M_GetState : + if ( !ValueOK(nUId, CUniString("GetState"),nNr1,pTB->GetItemCount()) ) + break; + switch (nNr2) + { + case 0: + pRet->GenReturn ( RET_Value, nUId, (ULONG)pTB->GetHelpId(pTB->GetItemId(nNr1-1))); + break; + case 1: + pRet->GenReturn ( RET_Value, nUId, (ULONG)pTB->GetItemType(nNr1-1)); + break; + case 2: + pRet->GenReturn ( RET_Value, nUId, (ULONG)pTB->GetItemState(pTB->GetItemId(nNr1-1))); + break; + case 3: + pRet->GenReturn ( RET_Value, nUId, (ULONG)pTB->GetItemId(nNr1-1)); + break; + default: + pRet->GenReturn ( RET_Value, nUId, ULONG(0)); + break; + } + break; + case M_GetItemText : + if ( ValueOK(nUId, CUniString("GetItemText"),nNr1,pTB->GetItemCount()) ) + pRet->GenReturn ( RET_Value, nUId, (String)pTB->GetItemText(nNr1-1)); + break; + case M_GetText : + pRet->GenReturn ( RET_Value, nUId, (String)pTB->GetText()); + break; + case M_GetItemCount : + pRet->GenReturn ( RET_Value, nUId, (ULONG)pTB->GetItemCount()); + break; + case M_SetNextToolBox : + if ( (nParams & PARAM_STR_1) ) + pTB->SetNextToolBox( aString1 ); + else + pTB->SetNextToolBox( pTB->GetNextToolBox() ); + pTB->NextToolBox(); + break; + case M_GetNextToolBox : + pRet->GenReturn ( RET_Value, nUId, (String)pTB->GetNextToolBox()); + break; + default: + ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "ToolBox" ) ); + break; + } + } + break; + + + case C_ValueSet: + switch( nMethodId ) + { + case M_AnimateMouse : + AnimateMouse( pControl, Mitte); + break; + case M_Select : + ((ValueSet*)pControl)->SelectItem( nNr1 ); + break; + case M_SetNoSelection : + ((ValueSet*)pControl)->SetNoSelection(); + break; + default: + ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "ValueSet" ) ); + break; + } + break; + case C_Control: + switch( nMethodId ) + { + case M_AnimateMouse : + AnimateMouse( pControl, MitteOben); + break; + default: + switch( nControlType ) + { + case CONST_CTTreeListBox: + switch( nMethodId ) + { + + + + +#define COUNT_LBOX( First, Next, Anzahl) \ + SvLBoxEntry *pThisEntry = ((SvTreeListBox*)pControl)->First(); \ + { \ + int niTemp = Anzahl; \ + while ( Anzahl-- ) \ + { \ + pThisEntry = ((SvTreeListBox*)pControl)->Next( pThisEntry ); \ + } \ + } + +#define FIND_LBOX( First, Next, Cond) \ + SvLBoxEntry *pFindEntry = (SvLBoxEntry*)((SvTreeListBox*)pControl)->First(); \ + { \ + while ( pFindEntry && !(Cond) ) \ + { \ + pFindEntry = (SvLBoxEntry*)((SvTreeListBox*)pControl)->Next( pFindEntry ); \ + } \ + } + +#define GetFirstValidTextItem( pThisEntry, nNr )\ +SvLBoxString* pItem = NULL;\ +USHORT nValidTextItemCount = 0;\ +{\ + USHORT nIndex = 0;\ + SvLBoxItem *pMyItem;\ + while ( ( nValidTextItemCount < nNr ) && nIndex < pThisEntry->ItemCount() )\ + {\ + pMyItem = pThisEntry->GetItem( nIndex );\ + if ( pMyItem->IsA() == SV_ITEM_ID_LBOXSTRING )\ + if ( ((SvLBoxString*)pMyItem)->GetText().Len() )\ + {\ + pItem = (SvLBoxString*)pMyItem;\ + nValidTextItemCount++;\ + }\ + nIndex++;\ + }\ +} + + case M_GetText : // TreeListBox wird angenommen! (Das kann ja nur schief gehen) + // aber WP hat gesagt! + { + SvTreeListBox *pTree = (SvTreeListBox*)pControl; + SvLBoxEntry *pThisEntry = pTree->GetCurEntry(); + if ( ! (nParams & PARAM_USHORT_1) ) + nNr1 = 1; + if ( pThisEntry ) + { + GetFirstValidTextItem( pThisEntry, nNr1 ); + if ( ValueOK( nUId, CUniString("GetText"), nNr1, nValidTextItemCount ) ) + pRet->GenReturn ( RET_Value, nUId, pItem->GetText() ); + } + else + ReportError( nUId, GEN_RES_STR2c2( S_NO_SELECTED_ENTRY, MethodString( nMethodId ), "TreeListBox" ) ); + } + break; + case M_GetSelCount : // TreeListBox wird angenommen! (Das kann ja nur schief gehen) + // aber WP hat gesagt! + pRet->GenReturn ( RET_Value, nUId, ULONG(((SvLBox*)pControl)->GetSelectionCount())); + break; + case M_GetSelIndex : // TreeListBox wird angenommen! (Das kann ja nur schief gehen) + // aber WP hat gesagt! + if ( ! (nParams & PARAM_USHORT_1) ) + nNr1 = 1; + if ( ValueOK(nUId, CUniString("GetSelIndex"),nNr1,((SvLBox*)pControl)->GetSelectionCount()) ) + { + nNr1--; + COUNT_LBOX( FirstSelected, NextSelected, nNr1); + pRet->GenReturn ( RET_Value, nUId, ULONG( ((SvTreeListBox*)pControl)->GetVisiblePos( pThisEntry )) +1 ); + } + break; + case M_GetSelText : // TreeListBox wird angenommen! (Das kann ja nur schief gehen) + // aber WP hat gesagt! + if ( ! (nParams & PARAM_USHORT_1) ) + nNr1 = 1; + if ( ! (nParams & PARAM_USHORT_2) ) + nNr2 = 1; + if ( ValueOK(nUId, CUniString("GetSelText"),nNr1,((SvLBox*)pControl)->GetSelectionCount()) ) + { + nNr1--; + COUNT_LBOX( FirstSelected, NextSelected, nNr1); + GetFirstValidTextItem( pThisEntry, nNr2 ); + if ( ValueOK( nUId, CUniString("GetSelText"), nNr2, nValidTextItemCount ) ) + pRet->GenReturn ( RET_Value, nUId, pItem->GetText() ); + } + break; + case M_GetItemCount : // TreeListBox wird angenommen! (Das kann ja nur schief gehen) + // aber WP hat gesagt! + pRet->GenReturn ( RET_Value, nUId, ULONG(((SvLBox*)pControl)->GetVisibleCount()) ); + break; + case M_GetItemText : // TreeListBox wird angenommen! (Das kann ja nur schief gehen) + // aber WP hat gesagt! + if ( ValueOK(nUId, MethodString( nMethodId ),nNr1,((SvLBox*)pControl)->GetVisibleCount()) ) + { + SvLBoxEntry *pEntry = (SvLBoxEntry*)((SvTreeListBox*)pControl)->GetEntryAtVisPos( nNr1-1 ); + if ( ! (nParams & PARAM_USHORT_2) ) + nNr2 = 1; + GetFirstValidTextItem( pEntry, nNr2 ); + if ( ValueOK( nUId, CUniString("GetItemText"), nNr2, nValidTextItemCount ) ) + pRet->GenReturn ( RET_Value, nUId, pItem->GetText() ); + } + break; + case M_Select : // TreeListBox wird angenommen! (Das kann ja nur schief gehen) + // aber WP hat gesagt! + if ( ! (nParams & PARAM_BOOL_1) ) + bBool1 = TRUE; + if( nParams & PARAM_STR_1 ) + { + /* ListBox *pLB = ((ListBox*)pControl); + if ( pLB->GetEntryPos( aString1 ) == LISTBOX_ENTRY_NOTFOUND ) + ReportError( nUId, GEN_RES_STR2( S_ENTRY_NOT_FOUND, MethodString( nMethodId ), aString1 ) ); + else + { + pLB->SelectEntry( aString1, bBool1 ); + if ( pLB->IsEntrySelected( aString1 ) ? !bBool1 : bBool1 ) // XOR rein mit BOOL + ReportError( nUId, GEN_RES_STR2( S_METHOD_FAILED, MethodString( nMethodId ), aString1 ) ); + } + */ ReportError( nUId, GEN_RES_STR1( S_SELECT_DESELECT_VIA_STRING_NOT_IMPLEMENTED, MethodString( nMethodId ) ) ); + } + else + { + if ( ValueOK(nUId, MethodString( nMethodId ),nNr1,((SvLBox*)pControl)->GetVisibleCount()) ) + { + SvLBoxEntry *pEntry = (SvLBoxEntry*)((SvTreeListBox*)pControl)->GetEntryAtVisPos( nNr1-1 ); + ((SvTreeListBox*)pControl)->Select ( pEntry, bBool1 ); + } + } + break; + case M_IsChecked : // TreeListBox wird angenommen! (Das kann ja nur schief gehen) + case M_IsTristate : // TreeListBox wird angenommen! (Das kann ja nur schief gehen) + case M_GetState : + case M_Check : // TreeListBox wird angenommen! (Das kann ja nur schief gehen) + case M_UnCheck : // TreeListBox wird angenommen! (Das kann ja nur schief gehen) + case M_TriState : // TreeListBox wird angenommen! (Das kann ja nur schief gehen) + // aber WP hat gesagt! + { + SvTreeListBox *pTree = (SvTreeListBox*)pControl; + SvLBoxEntry *pThisEntry = pTree->GetCurEntry(); + if ( !pThisEntry ) + ReportError( nUId, GEN_RES_STR2c2( S_NO_SELECTED_ENTRY, MethodString( nMethodId ), "TreeListBox" ) ); + else + { + SvLBoxButton* pItem = (SvLBoxButton*)(pThisEntry->GetFirstItem(SV_ITEM_ID_LBOXBUTTON)); + if(!pItem) + ReportError( nUId, GEN_RES_STR1( S_NO_LIST_BOX_BUTTON, MethodString( nMethodId ) ) ); + else + switch( nMethodId ) + { + case M_IsChecked : // TreeListBox wird angenommen! (Das kann ja nur schief gehen) + // aber WP hat gesagt! + pRet->GenReturn ( RET_Value, nUId, BOOL( pItem->IsStateChecked() ) ); + break; + case M_IsTristate : // TreeListBox wird angenommen! (Das kann ja nur schief gehen) + // aber WP hat gesagt! + pRet->GenReturn ( RET_Value, nUId, BOOL( pItem->IsStateTristate() ) ); + break; + case M_GetState : + pRet->GenReturn ( RET_Value, nUId, ULONG( pItem->GetButtonFlags() & ~SV_STATE_MASK )); + break; + case M_Check : // TreeListBox wird angenommen! (Das kann ja nur schief gehen) + // aber WP hat gesagt! + pItem->SetStateChecked(); + pTree->InvalidateEntry( pThisEntry ); + break; + case M_UnCheck : // TreeListBox wird angenommen! (Das kann ja nur schief gehen) + // aber WP hat gesagt! + pItem->SetStateUnchecked(); + pTree->InvalidateEntry( pThisEntry ); + break; + case M_TriState : // TreeListBox wird angenommen! (Das kann ja nur schief gehen) + // aber WP hat gesagt! + pItem->SetStateTristate(); + pTree->InvalidateEntry( pThisEntry ); + break; + default: + ReportError( nUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) ); + break; + } + } + } + break; + default: + ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "TreeListBox" ) ); + break; + } + break; + case CONST_CTBrowseBox: + + switch( nMethodId ) + { + +/* + + +BOOL MakeFieldVisible( long nRow, USHORT nColId, BOOL bComplete = FALSE ); +// access to dynamic values of cursor row +String GetColumnTitle( USHORT nColumnId ) const; +USHORT GetColumnId( USHORT nPos ) const; +USHORT GetColumnPos( USHORT nColumnId ) const; +// access and movement of cursor +long GetCurRow() const { return nCurRow; } +USHORT GetCurColumnId() const { return nCurColId; } +BOOL GoToRow( long nRow ); +BOOL GoToRowAndDoNotModifySelection( long nRow ); +BOOL GoToColumnId( USHORT nColId ); +BOOL GoToRowColumnId( long nRow, USHORT nColId ); +// selections +void SetNoSelection(); +void SelectAll(); +void SelectRow( long nRow, BOOL bSelect = TRUE, BOOL bExpand = TRUE ); +void SelectColumnPos( USHORT nCol, BOOL bSelect = TRUE ) + { SelectColumnPos( nCol, bSelect, TRUE); } +void SelectColumnId( USHORT nColId, BOOL bSelect = TRUE ) + { SelectColumnPos( GetColumnPos(nColId), bSelect, TRUE); } +long GetSelectRowCount() const; +USHORT GetSelectColumnCount() const; +BOOL IsRowSelected( long nRow ) const; +BOOL IsColumnSelected( USHORT nColumnId ) const; +long FirstSelectedRow( BOOL bInverse = FALSE ); +long LastSelectedRow( BOOL bInverse = FALSE ); +long PrevSelectedRow(); +long NextSelectedRow(); +const MultiSelection* GetSelection() const + { return bMultiSelection ? uRow.pSel : 0; } +void SetSelection( const MultiSelection &rSelection ); + + + + EditBrowseBox + + sal_Bool IsEditing() const {return aController.Is();} + void InvalidateStatusCell(long nRow) {RowModified(nRow, 0);} + void InvalidateHandleColumn(); + + CellControllerRef Controller() const { return aController; } + sal_Int32 GetBrowserFlags() const { return m_nBrowserFlags; } + + virtual void ActivateCell(long nRow, sal_uInt16 nCol, sal_Bool bSetCellFocus = sal_True); + virtual void DeactivateCell(sal_Bool bUpdate = sal_True); + + + + + + + + +#define COUNT_LBOX( First, Next, Anzahl) \ + SvLBoxEntry *pThisEntry = ((SvTreeListBox*)pControl)->First(); \ + { \ + int niTemp = Anzahl; \ + while ( Anzahl-- ) \ + { \ + pThisEntry = ((SvTreeListBox*)pControl)->Next( pThisEntry ); \ + } \ + } + +#define FIND_LBOX( First, Next, Cond) \ + SvLBoxEntry *pFindEntry = (SvLBoxEntry*)((SvTreeListBox*)pControl)->First(); \ + { \ + while ( pFindEntry && !(Cond) ) \ + { \ + pFindEntry = (SvLBoxEntry*)((SvTreeListBox*)pControl)->Next( pFindEntry ); \ + } \ + } + +#define GetFirstValidTextItem( pThisEntry )\ +SvLBoxString* pItem = NULL;\ +{\ + USHORT nIndex = 0;\ + SvLBoxItem *pMyItem;\ + while ( nIndex < pThisEntry->ItemCount() )\ + {\ + pMyItem = pThisEntry->GetItem( nIndex );\ + if ( pMyItem->IsA() == SV_ITEM_ID_LBOXSTRING )\ + if ( ((SvLBoxString*)pMyItem)->GetText().Len() )\ + pItem = (SvLBoxString*)pMyItem;\ + nIndex++;\ + }\ +} +*/ + case M_GetSelText : // EditBrowseBox wird angenommen! (Das kann ja nur schief gehen) + { + CellControllerRef aControler; + aControler = ((EditBrowseBox*)pControl)->Controller(); + if ( aControler.Is() ) + { + Window& aWin = aControler->GetWindow(); + pRet->GenReturn ( RET_Value, nUId, aControler->GetWindow().GetText() ); + } + else + ReportError( nUId, GEN_RES_STR2c2( S_NO_SELECTED_ENTRY, MethodString( nMethodId ), "BrowseBox" ) ); + } + break;/* + case M_GetSelCount : // EditBrowseBox wird angenommen! (Das kann ja nur schief gehen) + pRet->GenReturn ( RET_Value, nUId, ULONG(((SvLBox*)pControl)->GetSelectionCount())); + break; + case M_GetSelIndex : // EditBrowseBox wird angenommen! (Das kann ja nur schief gehen) + if ( ! (nParams & PARAM_USHORT_1) ) + nNr1 = 1; + if ( ValueOK(nUId, CUniString("GetSelIndex"),nNr1,((SvLBox*)pControl)->GetSelectionCount()) ) + { + nNr1--; + COUNT_LBOX( FirstSelected, NextSelected, nNr1); + pRet->GenReturn ( RET_Value, nUId, ULONG( ((SvTreeListBox*)pControl)->GetVisiblePos( pThisEntry )) +1 ); + } + break; + case M_GetSelText : // EditBrowseBox wird angenommen! (Das kann ja nur schief gehen) + if ( ! (nParams & PARAM_USHORT_1) ) + nNr1 = 1; + if ( ValueOK(nUId, CUniString("GetSelText"),nNr1,((SvLBox*)pControl)->GetSelectionCount()) ) + { + nNr1--; + COUNT_LBOX( FirstSelected, NextSelected, nNr1); + GetFirstValidTextItem( pThisEntry ); + pRet->GenReturn ( RET_Value, nUId, pItem->GetText() ); + } + break; + case M_GetItemCount : // EditBrowseBox wird angenommen! (Das kann ja nur schief gehen) + pRet->GenReturn ( RET_Value, nUId, ULONG(((SvLBox*)pControl)->GetVisibleCount()) ); + break; + case M_GetItemText : // EditBrowseBox wird angenommen! (Das kann ja nur schief gehen) + if ( ValueOK(nUId, MethodString( nMethodId ),nNr1,((SvLBox*)pControl)->GetVisibleCount()) ) + { + SvLBoxEntry *pEntry = (SvLBoxEntry*)((SvTreeListBox*)pControl)->GetEntryAtVisPos( nNr1-1 ); + GetFirstValidTextItem( pEntry ); + pRet->GenReturn ( RET_Value, nUId, pItem->GetText() ); + } + break; + case M_Select : // EditBrowseBox wird angenommen! (Das kann ja nur schief gehen) + if ( ! (nParams & PARAM_BOOL_1) ) + bBool1 = TRUE; + if( nParams & PARAM_STR_1 ) + { + /* ListBox *pLB = ((ListBox*)pControl); + if ( pLB->GetEntryPos( aString1 ) == LISTBOX_ENTRY_NOTFOUND ) + ReportError( nUId, GEN_RES_STR2( S_ENTRY_NOT_FOUND, MethodString( nMethodId ), aString1 ) ); + else + { + pLB->SelectEntry( aString1, bBool1 ); + if ( pLB->IsEntrySelected( aString1 ) ? !bBool1 : bBool1 ) // XOR rein mit BOOL + ReportError( nUId, GEN_RES_STR2( S_METHOD_FAILED, MethodString( nMethodId ), aString1 ) ); + } + * / ReportError( nUId, GEN_RES_STR1( S_SELECT_DESELECT_VIA_STRING_NOT_IMPLEMENTED, MethodString( nMethodId ) ) ); + } + else + { + if ( ValueOK(nUId, MethodString( nMethodId ),nNr1,((SvLBox*)pControl)->GetVisibleCount()) ) + { + SvLBoxEntry *pEntry = (SvLBoxEntry*)((SvTreeListBox*)pControl)->GetEntryAtVisPos( nNr1-1 ); + ((SvTreeListBox*)pControl)->Select ( pEntry, bBool1 ); + } + } + break; + case M_IsChecked : // EditBrowseBox wird angenommen! (Das kann ja nur schief gehen) + case M_IsTristate : // EditBrowseBox wird angenommen! (Das kann ja nur schief gehen) + case M_GetState : + case M_Check : // EditBrowseBox wird angenommen! (Das kann ja nur schief gehen) + case M_UnCheck : // EditBrowseBox wird angenommen! (Das kann ja nur schief gehen) + case M_TriState : // EditBrowseBox wird angenommen! (Das kann ja nur schief gehen) + { + SvTreeListBox *pTree = (SvTreeListBox*)pControl; + SvLBoxEntry *pThisEntry = pTree->GetCurEntry(); + if ( !pThisEntry ) + ReportError( nUId, GEN_RES_STR2c2( S_NO_SELECTED_ENTRY, MethodString( nMethodId ), "BrowseBox" ) ); + else + { + SvLBoxButton* pItem = (SvLBoxButton*)(pThisEntry->GetFirstItem(SV_ITEM_ID_LBOXBUTTON)); + if(!pItem) + ReportError( nUId, GEN_RES_STR1( S_NO_LIST_BOX_BUTTON, MethodString( nMethodId ) ) ); + else + switch( nMethodId ) + { + case M_IsChecked : // EditBrowseBox wird angenommen! (Das kann ja nur schief gehen) + pRet->GenReturn ( RET_Value, nUId, BOOL( pItem->IsStateChecked() ) ); + break; + case M_IsTristate : // EditBrowseBox wird angenommen! (Das kann ja nur schief gehen) + pRet->GenReturn ( RET_Value, nUId, BOOL( pItem->IsStateTristate() ) ); + break; + case M_GetState : + pRet->GenReturn ( RET_Value, nUId, ULONG( pItem->GetButtonFlags() & ~SV_STATE_MASK )); + break; + case M_Check : // EditBrowseBox wird angenommen! (Das kann ja nur schief gehen) + pItem->SetStateChecked(); + pTree->InvalidateEntry( pThisEntry ); + break; + case M_UnCheck : // EditBrowseBox wird angenommen! (Das kann ja nur schief gehen) + pItem->SetStateUnchecked(); + pTree->InvalidateEntry( pThisEntry ); + break; + case M_TriState : // EditBrowseBox wird angenommen! (Das kann ja nur schief gehen) + pItem->SetStateTristate(); + pTree->InvalidateEntry( pThisEntry ); + break; + default: + ReportError( nUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) ); + break; + } + } + } + break;*/ + default: + ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "EditBrowseBox" ) ); + break; + } + break; + + + case CONST_CTProgressBar: + ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "Control" ) ); + break; + default: + ReportError( nUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) ); + break; + } + } + break; + case C_Window: + switch( nMethodId ) + { + case M_AnimateMouse : + AnimateMouse( pControl, MitteOben); + break; + default: + switch( nControlType ) + { + case CONST_CTProgressBar: + switch ( nMethodId ) + { + // Erstmal nichts, da sowiso nur Prozente abgefragt werden k"onnten + default: + ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "ProgressBar" ) ); + break; + } + break; + case CONST_CTTreeListBox: + case CONST_CTBrowseBox: + ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "Window" ) ); + break; + default: + ReportError( nUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) ); + break; + } + ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "Window" ) ); + break; + } + break; + + case C_DockingWin: + switch( nMethodId ) + { + case M_AnimateMouse : + AnimateMouse( pControl, MitteOben); + break; + case M_Dock : + if ( ((DockingWindow*)pControl)->IsFloatingMode() ) + ((DockingWindow*)pControl)->SetFloatingMode(FALSE); + else + ReportError( nUId, GEN_RES_STR1( S_ALLOWED_ONLY_IN_FLOATING_MODE, MethodString( nMethodId ) ) ); + break; + case M_Undock : + if ( !((DockingWindow*)pControl)->IsFloatingMode() ) + ((DockingWindow*)pControl)->SetFloatingMode(TRUE); + else + ReportError( nUId, GEN_RES_STR1( S_ALLOWED_ONLY_IN_FLOATING_MODE, MethodString( nMethodId ) ) ); + break; + case M_IsDocked : + pRet->GenReturn ( RET_Value, nUId, (BOOL) !((DockingWindow*)pControl)->IsFloatingMode()); + break; + case M_Close: + //nWindowWaitUId = nUId; + DBG_ASSERT( nUId == pControl->GetUniqueOrHelpId(), "nUID != UniqueOrHelpId"); + SET_WINP_CLOSING(pControl); + ((DockingWindow*)pControl)->Close(); + break; + case M_Size: + case M_Move: + case M_IsMax : + case M_Minimize : + case M_Maximize : + if ( ((DockingWindow*)pControl)->IsFloatingMode() ) + { + pControl = ((DockingWindow*)pControl)->GetFloatingWindow(); + goto FloatWin; + } + else + ReportError( nUId, GEN_RES_STR1( S_ALLOWED_ONLY_IN_DOCKING_MODE, MethodString( nMethodId ) ) ); + break; + case M_Help: // Alles was unten weiterbehandelt werden soll + goto MoreDialog; + + default: + ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "DockingWindow" ) ); + break; + } + break; + case C_FloatWin: + FloatWin: + switch( nMethodId ) + { + case M_AnimateMouse : + AnimateMouse( pControl, MitteOben); + break; + case M_IsMax : + pRet->GenReturn ( RET_Value, nUId, (BOOL)!((FloatingWindow*)pControl)->IsRollUp()); + break; + case M_Minimize : + ((FloatingWindow*)pControl)->RollUp(); + break; + case M_Maximize : + ((FloatingWindow*)pControl)->RollDown(); + break; + case M_Size: + { + if ( pControl->GetStyle() & WB_SIZEABLE ) + { + pControl->SetSizePixel(Size(nNr1,nNr2)); + pControl->Resize(); + } + else + ReportError( nUId, GEN_RES_STR1( S_SIZE_NOT_CHANGEABLE, MethodString( nMethodId ) ) ); + break; + } + case M_Close: + DBG_ASSERT( nUId == pControl->GetUniqueOrHelpId(), "nUID != UniqueOrHelpId"); + SET_WINP_CLOSING(pControl); + ((FloatingWindow*)pControl)->Close(); + break; + case M_Help: // Alles was unten weiterbehandelt werden soll + case M_Move: + goto MoreDialog; + default: + ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "FloatingWin" ) ); + break; + } + break; + case C_ModelessDlg: + case C_Dlg: + case C_TabDlg: + MoreDialog: + switch( nMethodId ) + { + + // (Rect GetRect) + + case M_AnimateMouse : + AnimateMouse( pControl, MitteOben); + break; + case M_Close: + DBG_ASSERT( nUId == pControl->GetUniqueOrHelpId(), "nUID != UniqueOrHelpId"); + SET_WINP_CLOSING(pControl); + ((SystemWindow*)pControl)->Close(); + break; + case M_OK: + { + USHORT ntRT = pControl->GetType(); + Window *pChild = GetWinByRT( pControl, WINDOW_OKBUTTON ); + if( ControlOK( pChild, "OK Button" ) ) + { + DBG_ASSERT( nUId == pControl->GetUniqueOrHelpId(), "nUID != UniqueOrHelpId"); + SET_WINP_CLOSING(pControl); + ((Button*)pChild)->Click(); + } + break; + } + case M_Cancel: + { +// Window *pChild = ImpGetChild( pControl, WINDOW_CANCELBUTTON ); + Window *pChild = GetWinByRT( pControl, WINDOW_CANCELBUTTON ); + if( ControlOK( pChild, "Cancel Button" ) ) + { + DBG_ASSERT( nUId == pControl->GetUniqueOrHelpId(), "nUID != UniqueOrHelpId"); + SET_WINP_CLOSING(pControl); + ((Button*)pChild)->Click(); + } + break; + } + case M_Help: + { + Window *pChild = GetWinByRT( pControl, WINDOW_HELPBUTTON ); + if( ControlOK( pChild, "Help Button" ) ) + ((Button*)pChild)->Click(); + break; + } + case M_Default: + { + Window *pChild = ImpGetButton( pControl, WB_DEFBUTTON, WB_DEFBUTTON ); + if( ControlOK( pChild, "Default Button" ) ) + ((Button*)pChild)->Click(); + break; + } + case M_Move: + { + pControl->SetPosPixel(Point(nNr1,nNr2)); + break; + } + default: + ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "Dialog" ) ); + break; + } + break; + case C_WorkWin: + switch( nMethodId ) + { + case M_AnimateMouse : + AnimateMouse( pControl, MitteOben); + break; + case M_Close: + DBG_ASSERT( nUId == pControl->GetUniqueOrHelpId(), "nUID != UniqueOrHelpId"); + SET_WINP_CLOSING(pControl); + ((WorkWindow*)pControl)->Close(); + break; + case M_Size: + case M_Move: + goto FloatWin; + break; + case M_Help: // Alles was unten weiterbehandelt werden soll + goto MoreDialog; + default: + ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "WorkWindow" ) ); + break; + } + break; + case C_TabPage: + switch( nMethodId ) + { + } + break; + case C_MessBox: + case C_InfoBox: + case C_WarningBox: + case C_ErrorBox: + case C_QueryBox: + { + BOOL bDone = TRUE; + MessBox* pMB = (MessBox*)pControl; + switch( nMethodId ) + { +#if SUPD > 631 + case M_GetCheckBoxText: + pRet->GenReturn ( RET_Value, nUId, pMB->GetCheckBoxText() ); + break; + case M_IsChecked : + pRet->GenReturn ( RET_Value, nUId, BOOL( pMB->GetCheckBoxState() == STATE_CHECK) ); + break; + case M_GetState : + pRet->GenReturn ( RET_Value, nUId, ULONG( pMB->GetCheckBoxState() )); + break; + case M_Check : + pMB->SetCheckBoxState( STATE_CHECK ); + break; + case M_UnCheck : + pMB->SetCheckBoxState( STATE_NOCHECK ); + break; +#endif + case M_GetText : + pRet->GenReturn ( RET_Value, nUId, pMB->GetMessText()); + break; + + default: + bDone = FALSE; + break; + } + if ( bDone ) + break; // break the case here else continue at C_ButtonDialog + } + case C_ButtonDialog: + { + ButtonDialog* pBD = (ButtonDialog*)pControl; +#ifdef DEBUG + m_pDbgWin->AddText( "Working MessBox: " ); + if (pControl->IsVisible()) + m_pDbgWin->AddText("*(Visible)\n"); + else + m_pDbgWin->AddText("*(nicht Visible)\n"); +#endif + switch( nMethodId ) + { + case M_AnimateMouse : + AnimateMouse( pControl, Mitte); + break; + case M_OK: +#if ( BUTTONID_OK != RET_OK ) +#error BUTTONID_OK != RET_OK +#endif + if ( pBD->GetPushButton( BUTTONID_OK ) ) + { + SET_WINP_CLOSING(pControl); + pBD->EndDialog(RET_OK); + } + else + ReportError( nUId, GEN_RES_STR1( S_NO_OK_BUTTON, MethodString( nMethodId ) ) ); + break; + case M_Cancel: + if ( pBD->GetPushButton( BUTTONID_CANCEL ) ) + { + SET_WINP_CLOSING(pControl); + pBD->EndDialog(RET_CANCEL); + } + else + ReportError( nUId, GEN_RES_STR1( S_NO_CANCEL_BUTTON, MethodString( nMethodId ) ) ); + break; + case M_Yes: + if ( pBD->GetPushButton( BUTTONID_YES ) ) + { + SET_WINP_CLOSING(pControl); + pBD->EndDialog(RET_YES); + } + else + ReportError( nUId, GEN_RES_STR1( S_NO_YES_BUTTON, MethodString( nMethodId ) ) ); + break; + case M_No: + if ( pBD->GetPushButton( BUTTONID_NO ) ) + { + SET_WINP_CLOSING(pControl); + pBD->EndDialog(RET_NO); + } + else + ReportError( nUId, GEN_RES_STR1( S_NO_NO_BUTTON, MethodString( nMethodId ) ) ); + break; + case M_Repeat: + if ( pBD->GetPushButton( BUTTONID_RETRY ) ) + { + SET_WINP_CLOSING(pControl); + pBD->EndDialog(RET_RETRY); + } + else + ReportError( nUId, GEN_RES_STR1( S_NO_RETRY_BUTTON, MethodString( nMethodId ) ) ); + break; + case M_Help: + if ( pBD->GetPushButton( BUTTONID_HELP ) ) + { + SET_WINP_CLOSING(pControl); + pBD->EndDialog(BUTTONID_HELP); + } + else + ReportError( nUId, GEN_RES_STR1( S_NO_HELP_BUTTON, MethodString( nMethodId ) ) ); + break; + case M_Default: + { + USHORT Style = pControl->GetStyle(); + if ( Style & WB_DEF_OK ) + { + SET_WINP_CLOSING(pControl); + pBD->EndDialog(RET_OK); + } + else if ( Style & WB_DEF_CANCEL ) + { + SET_WINP_CLOSING(pControl); + pBD->EndDialog(RET_CANCEL); + } + else if ( Style & WB_DEF_YES ) + { + SET_WINP_CLOSING(pControl); + pBD->EndDialog(RET_YES); + } + else if ( Style & WB_DEF_NO ) + { + SET_WINP_CLOSING(pControl); + pBD->EndDialog(RET_NO); + } + else if ( Style & WB_DEF_RETRY ) + { + SET_WINP_CLOSING(pControl); + pBD->EndDialog(RET_RETRY); + } + else + ReportError( nUId, GEN_RES_STR1( S_NO_DEFAULT_BUTTON, MethodString( nMethodId ) ) ); + } + break; + case M_GetText : + pRet->GenReturn ( RET_Value, nUId, pControl->GetText()); + break; + case M_Click: + if ( nParams & PARAM_USHORT_1 ) + { + if ( pBD->GetPushButton( nNr1 ) ) + { + if ( nNr1 != BUTTONID_HELP ) + { + SET_WINP_CLOSING(pControl); + } + pBD->GetPushButton( nNr1 )->Click(); + } + else + ReportError( nUId, GEN_RES_STR2( S_NO_DEFAULT_BUTTON, UniString::CreateFromInt32( nNr1 ), MethodString( nMethodId ) ) ); + } + else + ReportError( nUId, GEN_RES_STR1( S_BUTTONID_REQUIRED, MethodString( nMethodId ) ) ); + break; + case M_GetButtonCount : + pRet->GenReturn ( RET_Value, nUId, ULONG(pBD->GetButtonCount())); + break; + case M_GetButtonId : + if ( ValueOK(nUId, MethodString( nMethodId ),nNr1,pBD->GetButtonCount()) ) + pRet->GenReturn ( RET_Value, nUId, ULONG(pBD->GetButtonId(nNr1-1))); + break; + default: + ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "MessageBox" ) ); + break; + } + break; + } + default: + DBG_ERROR( "Unbekannter Objekttyp aus UId oder Methode nicht unterstützt" ); + ReportError( nUId, GEN_RES_STR2( S_UNKNOWN_TYPE, UniString::CreateFromInt32( nRT ), MethodString(nMethodId) ) ); +#ifdef DEBUG + m_pDbgWin->AddText( " Unbekannter Objekttyp aus UId" ); +#endif + break; + } + } + for( int i = 0; i < 32; i++ ) + SafeReschedule(); + } +#ifdef DEBUG + m_pDbgWin->AddText( "\n" ); +#endif + if (bNormalWeiter) + { + SendProfile( UIdString( nUId ).Append('.').Append( MethodString( nMethodId ) ) ); + delete this; + } + return bNormalWeiter; + +#define FINISH_NEXT +#define FINISH_SAME + +} diff --git a/automation/source/server/statemnt.hxx b/automation/source/server/statemnt.hxx new file mode 100644 index 000000000000..c25584bf9f60 --- /dev/null +++ b/automation/source/server/statemnt.hxx @@ -0,0 +1,496 @@ +/************************************************************************* + * + * $RCSfile: statemnt.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: mh $ $Date: 2002-11-18 15:29:21 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2002 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2002 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2002 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +/*************************************************************************** +** +** Von StatementList werden alle Statements abgeleitet. +** Es gibt immer nur eine Statementliste, die verpointert ist. +** jederzeit kann das der Anfang der Kette abgefragt werden. +** +** +** +** +** +** +** +***************************************************************************/ +#ifndef _STATEMNT_HXX +#define _STATEMNT_HXX + +#ifndef _SV_WINTYPES_HXX //autogen +#include <vcl/wintypes.hxx> +#endif +#ifndef _STRING_HXX //autogen +#include <tools/string.hxx> +#endif +#ifndef _DEBUG_HXX //autogen +#include <tools/debug.hxx> +#endif +#ifndef _TIME_HXX //autogen +#include <tools/time.hxx> +#endif +#ifndef _SV_DRAG_HXX //autogen +//#include <vcl/drag.hxx> +#endif +#ifndef _SV_MENU_HXX //autogen +#include <vcl/menu.hxx> +#endif +#ifndef _SV_SVAPP_HXX //autogen +#include <vcl/svapp.hxx> +#endif +#ifndef _FSYS_HXX +#include <tools/fsys.hxx> +#endif +#ifndef _SOT_STORAGE_HXX +#include <sot/storage.hxx> +#endif +#ifndef _SB_SBSTAR_HXX +#include <basic/sbstar.hxx> +#endif +#include <vcl/event.hxx> + +#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_ +#include <com/sun/star/beans/PropertyValue.hpp> +#endif + +class Window; +class Point; +class SfxPoolItem; + +class ScrollBar; + +class SCmdStream; +class RetStream; +class ImplRemoteControl; + +class TTProfiler; +class TTProperties; + +class Dir; + +class CommunicationLink; + +#ifdef DEBUG +class EditWindow; +#endif + +void SAL_CALL osl_TestToolDebugPrint( const sal_Char *pString ); + +typedef USHORT SearchFlags; +#define SEARCH_NOOVERLAP ((SearchFlags) 0x0001) +#define SEARCH_NO_TOPLEVEL_WIN ((SearchFlags) 0x0002) +#define SEARCH_FOCUS_FIRST ((SearchFlags) 0x0004) +#define SEARCH_FIND_DISABLED ((SearchFlags) 0x0008) + +#define IsVisible IsReallyVisible +#define GET_REAL_PARENT() GetWindow( WINDOW_REALPARENT ) + +class Search +{ + SearchFlags nSearchFlags; +public: + Search( SearchFlags nPSearchFlags = 0): nSearchFlags(nPSearchFlags) {} + virtual ~Search() {} + + virtual BOOL IsWinOK( Window *pWin ) = 0; + SearchFlags GetSearchFlags() { return nSearchFlags; } + void AddSearchFlags( SearchFlags aNewFlags ) { nSearchFlags |= aNewFlags; } + void RemoveSearchFlags( SearchFlags aRemoveFlags ) { nSearchFlags &= ( ~aRemoveFlags ); } + BOOL HasSearchFlag( SearchFlags aQueryFlag ) { return (nSearchFlags & aQueryFlag) == aQueryFlag; } +}; + +BOOL IsDialog(Window *pWin); // Ist *pWin von SystemWindow abgeleitet (Kann es Active sein) +BOOL IsAccessable(Window *pWin); // Ist *pWin Zugreifbar (über IsEnabled und Parents geprüft) + + +//class SafePointer : CriticalSection +class SafePointer +{ + SafePointer *pSelf; +public: + SafePointer() { pSelf = this; } + virtual ~SafePointer() { DBG_ASSERT(pSelf==this,"Destructor von Nicht existierendem Objekt aufgerufen"); + pSelf = NULL; } +// static BOOL IsValid( SafePointer *pThis ) { return pThis == pThis->pSelf; } +// virtual operator -> (); { DBG_ASSERT(pMyself == this,"-> von Nicht existierendem Objekt aufgerufen"); } +}; + + +#define MAX_RETRIES 9 +class StatementList : public SafePointer +{ +protected: + StatementList(); + USHORT nRetryCount; + void QueStatement(StatementList *pAfterThis); + BOOL bStatementInQue; + static USHORT nUseBindings; + + static TTProfiler *pProfiler; + void InitProfile(); + void SendProfile( String aText ); + static StatementList *pCurrentProfileStatement; + + static BOOL bIsInReschedule; + static Window *pLastFocusWindow; // Wenn dieses sich ändert wird Safe Reschedule abgebrochen + static BOOL bWasDragManager; // Wenn dieses sich ändert wird Safe Reschedule abgebrochen + static BOOL bWasPopupMenu; // Wenn dieses sich ändert wird Safe Reschedule abgebrochen + static BOOL bBasicWasRunning; + + static USHORT nControlType; // Auf diesen Typ werden Controls gecastst + + static USHORT nMinTypeKeysDelay; /// Verzögerung der einzelnen Anschläge für TypeKeys + static USHORT nMaxTypeKeysDelay; + static BOOL bDoTypeKeysDelay; + + static Window* pFirstDocWin; + +public: + static BOOL IsInReschedule() { return bIsInReschedule; } + void SafeReschedule( BOOL bYield = FALSE ) // Setzt Flag, so daß nicht schon der nächste Befehl ausgeführt wird + { + bIsInReschedule = TRUE; + pLastFocusWindow = GetpApp()->GetFocusWindow(); + bWasDragManager = NULL /*!= DragManager::GetDragManager()*/; + bWasPopupMenu = NULL != PopupMenu::GetActivePopupMenu(); + bBasicWasRunning = StarBASIC::IsRunning(); + bWasExecuting = bExecuting; + if ( bYield ) + GetpApp()->Yield(); + else + GetpApp()->Reschedule(); + bExecuting = bWasExecuting; + bBasicWasRunning = FALSE; + bWasPopupMenu = FALSE; + bWasDragManager = FALSE; + pLastFocusWindow = NULL; + bIsInReschedule = FALSE; + } + static BOOL MaybeResetSafeReschedule() + { // Implementierung muß hier zwar nicht sein, ist aber übersichtlicher so + if ( !bIsInReschedule ) + return FALSE; + + if ( pLastFocusWindow != GetpApp()->GetFocusWindow() +// || ( DragManager::GetDragManager() && !bWasDragManager ) + || ( PopupMenu::GetActivePopupMenu() && !bWasPopupMenu ) + || ( StarBASIC::IsRunning() && !bBasicWasRunning ) ) + { + bIsInReschedule = FALSE; + pLastFocusWindow = NULL; + return TRUE; + } + else + return FALSE; + } + static void NormalReschedule() // Setzt das flag nicht + { + GetpApp()->Reschedule(); + } +#define Reschedule RescheduleNichtBenutzen_StattdessenSafeRescheduleAnStatementList + + static Window* GetMouseWin(); + static BOOL WinPtrValid(Window *pTest); + static Window* SearchAllWin( Window *pBase, Search &aSearch, BOOL MaybeBase = TRUE ); +protected: + static Window* SearchClientWin( Window *pBase, Search &aSearch, BOOL MaybeBase = TRUE ); + + Window* SearchTree( ULONG nUId, BOOL bSearchButtonOnToolbox = FALSE ); + Window* GetActive( WindowType nRT, BOOL MaybeBase = TRUE ); + Window* GetFocus( WindowType nRT ,BOOL ParentWasRT = FALSE, BOOL MaybeBase = TRUE ); + Window* GetAnyActive( BOOL MaybeBase = TRUE ); + ScrollBar* GetScrollBar( Window *pBase, USHORT nDirection, BOOL MaybeBase = TRUE ); + Window* GetPopupFloatingWin( BOOL MaybeBase = TRUE ); + Window* GetWinByRT( Window *pBase, WindowType nRT, BOOL MaybeBase = TRUE, USHORT nSkip = 0 ); + USHORT CountWinByRT( Window *pBase, WindowType nRT, BOOL MaybeBase = TRUE ); + Window* GetDocWin( USHORT nNr ); + USHORT GetDocWinCount(); + Window* GetFadeSplitWin( Window *pBase, WindowAlign nAlign, BOOL MaybeBase = TRUE ); + BOOL ValueOK(ULONG nId, String aBezeichnung, ULONG nValue, ULONG nMax); + +public: +// void AddStatement( StatementList *pNewStatement ); + + virtual ~StatementList(); + void Advance(); + virtual BOOL Execute() = 0; +/*************************************************************************** +** Bestimmt erst den nächsten Befehl, setzt Current +** und führt dann aus. +** Returnwert gibt an, ob Befehl nochmal ausgeführt +** werden soll. Dann muß auch der UserEvent verlassen werden, um der Applikation +** normales Arbeiten zu ermöglichen (Dialog schliessen) +** TRUE bedeutet, dass alles klar gegangen ist +** FALSE bedeutet nochmal Bitte +***************************************************************************/ + + void ReportError(String aMessage); + void ReportError(ULONG nUId, String aMessage); + void ReportError(ULONG nUId, String aMessage, ULONG nWhatever); + + static void DirectLog( ULONG nUId, String aString ); + + String Tree(Window *pBase, int Indent); + String ClientTree(Window *pBase, int Indent); + + StatementList *pNext; + static StatementList /**pCurrent,*/ *pFirst; + static BOOL bReadingCommands; + static ULONG nWindowWaitUId; + static Window *pWindowWaitPointer; + static ULONG nWindowWaitOldHelpId; + static ULONG nWindowWaitOldUniqueId; + static RetStream *pRet; + static BOOL IsError; + static BOOL bDying; + static BOOL bExecuting; // Gesetzt, wenn ein Befehl rescheduled ohne einen neuen Befehl zu erlauben + BOOL bWasExecuting; // Wurde bei einem MaybeResetSafeReschedule resettet, so wird der Zustand danach wiederhergestellt + static USHORT nSubMenuId1; // Untermenüs bei PopupMenus + static USHORT nSubMenuId2; // erstmal 2-Stufig + static SystemWindow *pMenuWindow; // when using MenuBar as base for MenuCommands + static TTProperties *pTTProperties; // Hier stehen die SlotIDs aus dem SFX drin + + BOOL CheckWindowWait(); //True heisst, dass Window noch existiert + //False -> Window weg; + static void SetFirstDocWin( Window* pWin ); + static Window* GetFirstDocWin(); + static BOOL IsFirstDocWin( Window* pWin ); + static BOOL IsDocWin( Window* pWin ); + static BOOL IsIMEWin( Window* pWin ); // Input Window for CJK under Solaris + + +#ifdef DEBUG + static EditWindow *m_pDbgWin; +#endif +}; + +class StatementSlot : public StatementList //Slots aufrufen +{ +protected: + USHORT nAnzahl; + SfxPoolItem **pItemArr; + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue> aArgs; + USHORT nFunctionId; +public: + StatementSlot( SCmdStream *pIn ); + StatementSlot( ULONG nSlot, SfxPoolItem* pItem = NULL ); + virtual ~StatementSlot(); + virtual BOOL Execute(); +}; + +class StatementUnoSlot : public StatementList //Uno Slots aufrufen +{ +protected: + String aUnoUrl; +public: + StatementUnoSlot(SCmdStream *pIn); + virtual BOOL Execute(); +}; + +class StatementCommand : public StatementList // Befehl ausführen (wintree, resetaplication ...) +{ + friend ImplRemoteControl; +protected: + USHORT nMethodId; + USHORT nParams; + USHORT nNr1,nNr2,nNr3,nNr4; + ULONG nLNr1; + String aString1,aString2; + BOOL bBool1,bBool2; + + Window* GetNextOverlap( Window* pBase ); + Window* GetNextRecoverWin(); + + static USHORT nDirPos; + static Dir *pDir; + static pfunc_osl_printDebugMessage pOriginal_osl_DebugMessageFunc; + + + BOOL UnpackStorage( SotStorageRef xStorage, DirEntry &aBaseDir ); + + void HandleSAXParser(); + + void HandleMacroRecorder(); + +public: + StatementCommand (SCmdStream *pIn); + virtual BOOL Execute(); + BOOL DisplayHID(); + void Translate(); + void WriteControlData( Window *pBase, ULONG nConf, BOOL bFirst = TRUE ); + +}; + + +enum TTHotSpots { MitteLinks, Mitte, MitteOben }; + +class StatementControl : public StatementList +{ +protected: + ULONG nUId; + USHORT nMethodId; + USHORT nParams; + USHORT nNr1,nNr2,nNr3,nNr4; + ULONG nLNr1; + String aString1,aString2; + BOOL bBool1,bBool2; + BOOL ControlOK( Window *pControl, const sal_Char* aBezeichnung ); + void AnimateMouse( Window *pControl, TTHotSpots aWohin ); + void AnimateMouse( Window *pControl, Point aWohin ); + + BOOL MaybeDoTypeKeysDelay( Window *pTestWindow ); + + BOOL HandleVisibleControls( Window *pControl ); + BOOL HandleCommonMethods( Window *pControl ); + +public: + StatementControl (SCmdStream *pIn); + virtual BOOL Execute(); + +}; + +class StatementFlow : StatementList // Kommunikation mit Sequence +{ + USHORT nArt; + + USHORT nParams; + USHORT nSNr1; + ULONG nLNr1; + String aString1; + BOOL bBool1; + + +public: + StatementFlow (ULONG nServiceId, SCmdStream *pIn, ImplRemoteControl *pRC ); + StatementFlow( StatementList *pAfterThis, USHORT nArtP ); + virtual BOOL Execute(); + static CommunicationLink *pCommLink; + static BOOL bSending; + + static BOOL bUseIPC; // Soll zur rückmeldung IPC verwendet werden? + static ImplRemoteControl *pRemoteControl; // Static für 2. Constructor + +private: + void SendViaSocket(); +}; + +class SearchUID : public Search +{ + Window *pMaybeResult; + ULONG nUId; + BOOL bSearchButtonOnToolbox; +public: + SearchUID( ULONG nUIdP, BOOL bSearchButtonOnToolboxP ): Search( SEARCH_FOCUS_FIRST ), pMaybeResult(NULL), nUId(nUIdP), bSearchButtonOnToolbox(bSearchButtonOnToolboxP) {} + virtual BOOL IsWinOK( Window *pWin ); + Window* GetMaybeWin() { return pMaybeResult; } +}; +class SearchActive : public Search +{ + WindowType nRT; +public: + SearchActive( WindowType nRTP ): nRT(nRTP) {} + virtual BOOL IsWinOK( Window *pWin ); +}; +class SearchPopupFloatingWin : public Search +{ +public: + SearchPopupFloatingWin(): Search( SEARCH_FOCUS_FIRST ) {} + virtual BOOL IsWinOK( Window *pWin ); +}; +class SearchRT : public Search +{ + WindowType mnRT; + USHORT mnSkip; + USHORT mnCount; +public: + SearchRT( WindowType nRTP, SearchFlags nSearchFlags, USHORT nSkip = 0 ): Search(nSearchFlags), mnRT(nRTP), mnSkip( nSkip ), mnCount( 0 ) {} + virtual BOOL IsWinOK( Window *pWin ); + USHORT GetCount(){ return mnCount; } +}; +class SearchScroll : public SearchRT +{ + USHORT nDirection; +public: + SearchScroll( USHORT nDir, SearchFlags nSearchFlags ): SearchRT(WINDOW_SCROLLBAR, nSearchFlags), nDirection(nDir) {} + virtual BOOL IsWinOK( Window *pWin ); +}; +class SearchWinPtr : public Search +{ + Window *pTest; +public: + SearchWinPtr( Window *pTestP ): pTest(pTestP) {} + virtual BOOL IsWinOK( Window *pWin ); +}; +class SearchFadeSplitWin : public Search +{ + WindowAlign nAlign; +public: + SearchFadeSplitWin( WindowAlign nAlignP ): nAlign(nAlignP) {} + virtual BOOL IsWinOK( Window *pWin ); +}; + + +void ImplKeyInput( Window* pWin, KeyEvent &aKEvnt ); +void ImplMouseMove( Window* pWin, MouseEvent &aMEvnt ); +void ImplMouseButtonDown( Window* pWin, MouseEvent &aMEvnt ); +void ImplMouseButtonUp( Window* pWin, MouseEvent &aMEvnt ); +void ImplCommand( Window* pWin, CommandEvent &aCmdEvnt ); + +#endif diff --git a/automation/source/server/svcommstream.cxx b/automation/source/server/svcommstream.cxx new file mode 100644 index 000000000000..7f4f97f4d53a --- /dev/null +++ b/automation/source/server/svcommstream.cxx @@ -0,0 +1,79 @@ +/************************************************************************* + * + * $RCSfile: svcommstream.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: mh $ $Date: 2002-11-18 15:29:27 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2002 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2002 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2002 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "svcommstream.hxx" + +SvCommStream::SvCommStream( SvStream* pIO ) { pStream = pIO; } +SvCommStream::~SvCommStream() {} + +ICommStream& SvCommStream::operator>>( USHORT& rUShort ) { *pStream >> rUShort; return *this; } +ICommStream& SvCommStream::operator>>( ULONG& rULong ) { *pStream >> rULong; return *this; } +ICommStream& SvCommStream::operator>>( unsigned char& rChar ) { *pStream >> rChar; return *this; } + +ICommStream& SvCommStream::operator<<( USHORT nUShort ) { *pStream << nUShort; return *this; } +ICommStream& SvCommStream::operator<<( ULONG nULong ) { *pStream << nULong; return *this; } +ICommStream& SvCommStream::operator<<( unsigned char nChar ) { *pStream << nChar; return *this; } + +ULONG SvCommStream::Read( void* pData, ULONG nSize ) { return pStream->Read( pData, nSize ); } +ULONG SvCommStream::Write( const void* pData, ULONG nSize ) { return pStream->Write( pData, nSize ); } + +BOOL SvCommStream::IsEof() const { return pStream->IsEof(); } +ULONG SvCommStream::SeekRel( long nPos ) { return pStream->SeekRel( nPos ); } diff --git a/automation/source/server/testtool.hrc b/automation/source/server/testtool.hrc new file mode 100644 index 000000000000..1c368ec3399d --- /dev/null +++ b/automation/source/server/testtool.hrc @@ -0,0 +1,89 @@ +/************************************************************************* + * + * $RCSfile: testtool.hrc,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: mh $ $Date: 2002-11-18 15:29:33 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2002 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2002 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2002 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#define TTSTART 12345 + +#define DisplayHidToolBox ( TTSTART + 0 ) +#define TT_SHOW 1 +#define TT_SHOW2 ( TTSTART + 1 ) +#define TT_OUTPUT 3 +#define TT_SEND_DATA 4 +#define TT_ALLWIN 5 +#define TT_KURZNAME 6 +#define TT_LANGNAME 7 +#define TT_ALTERNATE_CAPTION ( TTSTART + 2 ) + +#define TT_INLINE_TRANSLATION ( TTSTART + 3) +#define TT_GB_TRANSLATION 1 +#define TT_E_NEW 2 +#define TT_FT_OLD 3 +#define TT_GB_COMMENT 4 +#define TT_E_COMMENT 5 + +#define TT_PB_SELECT 6 +#define TT_PB_RESTORE 7 +#define TT_PB_ACCEPT 8 +#define TT_PB_NEXT 9 + +#define TT_DISCARD_CHANGED_DATA ( TTSTART + 4 ) +#define TT_NO_CONTROL ( TTSTART + 5 ) + + +#define TT_GPF ( TTSTART + 6 ) |