'encoding UTF-8 Do not remove or change this line! '************************************************************** ' ' Licensed to the Apache Software Foundation (ASF) under one ' or more contributor license agreements. See the NOTICE file ' distributed with this work for additional information ' regarding copyright ownership. The ASF licenses this file ' to you under the Apache License, Version 2.0 (the ' "License"); you may not use this file except in compliance ' with the License. You may obtain a copy of the License at ' ' http://www.apache.org/licenses/LICENSE-2.0 ' ' Unless required by applicable law or agreed to in writing, ' software distributed under the License is distributed on an ' "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ' KIND, either express or implied. See the License for the ' specific language governing permissions and limitations ' under the License. ' '************************************************************** '* '* short description : misc functions to handle documents '* '\****************************************************************************** function hUseImpressAutopilot( bEnable as boolean ) as boolean '///

Enable/disable the Impress Autopilot in Tools/Options

'///Starting point: Any plain document '/// end function '******************************************************************************* function hNumericDocType( doctype as integer ) as string '///

Convert a numeric expression to a gApplication

'///BEWARE: This is a core function used by many testcases!
'///Using file: global/input/applications.txt as reference '/// end function '******************************************************************************* function hChangeDoc() as string '///

Function to modify all documenttypes to set the "changed" flag

'///Starting point: Any plain document
'///Input: '///
    '///+
  1. Nothing
  2. '///
'///Returns: '///
    '///+
  1. String, ready to use in printlog
  2. '/// '///
'///Description: '/// end function '******************************************************************************* function hIdentifyWriterDoc( cString as string, bWarn as boolean ) as boolean '///

Function to validate that the expected WRITER doc has the focus

'///Starting point: Any WRITER document containing some text '/// end function '******************************************************************************* function hCreateDocument() as boolean '///

Create anew document, extends hNewDocument() by providing a returnvalue

' TRUE = New document created, FALSE = Failed to create a new document ' const CFN = "global::tools::includes::optional::t_docfuncs.inc::hCreateDocument::" dim iDocCountBefore as integer dim iDocCountAfter as integer iDocCountBefore = getDocumentCount if ( GVERBOSE ) then printlog( CFN & "Number of open documents before: " & iDocCountBefore ) if ( gApplication = "BACKGROUND" ) then hFileCloseAll() hCreateDocument() = true else call hNewDocument() iDocCountAfter = getDocumentCount() if ( iDocCountAfter = ( iDocCountBefore + 1 ) ) then hCreateDocument() = true else hCreateDocument() = false endif endif if ( GVERBOSE ) then printlog( CFN & "New document created. Open: " & iDocCountAfter ) '/// end function '******************************************************************************* function hDocumentTypeKeys( cString as string ) as boolean '///

Type a string to a document

'///The documenttype is determined by gApplication.
'///See hNumericDocType for details and number/gApplication matching

'///Input: '///
    '///+
  1. Keystrokes to be sent to the document (string), e.g.
  2. '/// '///
'///Returns: '///
    '///+
  1. Errorstatus (boolean)
  2. '/// '///
'///Description: '/// end function '******************************************************************************* function hDestroyDocument() as boolean const CFN = "global::tools::includes::optional::t_docfuncs.inc::hDestroyDocument: " dim iDocCount as integer : iDocCount = getDocumentCount() hDestroyDocument() = false dim method( 3 ) as string method( 1 ) = "no,optional" method( 2 ) = "202,optional" method( 3 ) = "ok,optional" ' This could be a File I/O error dim iCurrentMethod as integer dim bDialogClosed as boolean if ( iDocCount = 0 ) then exit function if ( GVERBOSE ) then printlog( CFN & "In.: Open: " & iDocCount ) hUseAsyncSlot( "FileClose" ) for iCurrentMethod = 1 to 3 bDialogClosed = false Kontext "Active" if ( Active.exists( 1 ) ) then printlog( CFN & "Msgbox: " & Active.getText() ) if ( GVERBOSE ) then printlog( CFN & "Method: " & method( iCurrentMethod ) ) bDialogClosed = hCloseDialog( Active, method( iCurrentMethod ) ) else exit for endif if ( iCurrentMethod = 3 and bDialogClosed ) then warnlog( "Unexpected messagebox was handled" ) endif next iCurrentMethod if ( getDocumentCount() = iDocCount ) then hCloseDocument() if ( getDocumentCount() = iDocCount - 1 ) then hDestroyDocument() = true if ( GVERBOSE ) then printlog( CFN & "Out: Open: " & getDocumentCount() ) end function '******************************************************************************* function hInitSingleDoc() as boolean hFileCloseAll() hCreateDocument() if ( GVERBOSE ) then printlog( "hInitSingleDoc(): Opening document: " & gApplication ) if ( getDocumentCount = 1 ) then hInitSingleDoc() = true else hInitSingleDoc() = false endif end function '*******************************************************************************'******************************************************************************* function hInitWriteDocIdentifier( cString as string ) as boolean '///

Write a specific string to an open writer document

'///This function verifies that exactly one document is open, that this is a '///+ Writer document and writes the string to the document

'///Parameter(s):
'///
    '///+
  1. A free form string (String) which serves as identifier for the document
  2. '/// '///
'///Returns:
'///
    '///+
  1. Errorcondition (Boolean)
  2. '/// '///
const CFN = "global::tools::includes::optional::t_docfuncs.inc::hInitWriteDocIdentifier::" const RC_TIMEOUT = -1 if ( getDocumentCount = 1 and gApplication = "WRITER" ) then kontext "DocumentWriter" DocumentWriter.typeKeys( "" ) DocumentWriter.typeKeys( "" ) DocumentWriter.typeKeys( "" ) DocumentWriter.typekeys( cString ) DocumentWriter.typeKeys( "" ) DocumentWriter.typeKeys( "" ) if ( hUseAsyncSlot( "EditCopy" ) <> RC_TIMEOUT ) then if ( getClipboardText = cString ) then printlog( CFN & "Writer document has been successfully modified." ) hInitWriteDocIdentifier() = true else warnlog( CFN & "Could not verify document identification string" ) hInitWriteDocIdentifier() = false endif else warnlog( CFN & "Unable to copy text to clipboard using " ) hInitWriteDocIdentifier() = false endif else warnlog ( CFN & "Only one single writer document may be open" ) printlog( CFN & "Number of documents: " & getDocumentCount ) printlog( CFN & "Application........: " & gApplication ) hInitWriteDocIdentifier() = false endif end function