1 '**************************************************************************
2 '* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 '* Copyright 2008 by Sun Microsystems, Inc.
6 '* OpenOffice.org - a multi-platform office productivity suite
8 '* $RCSfile: clipbrd_func.inc,v $
12 '* last change: $Author: vg $ $Date: 2008-08-18 12:24:28 $
14 '* This file is part of OpenOffice.org.
16 '* OpenOffice.org is free software: you can redistribute it and/or modify
17 '* it under the terms of the GNU Lesser General Public License version 3
18 '* only, as published by the Free Software Foundation.
20 '* OpenOffice.org is distributed in the hope that it will be useful,
21 '* but WITHOUT ANY WARRANTY; without even the implied warranty of
22 '* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 '* GNU Lesser General Public License version 3 for more details
24 '* (a copy is included in the LICENSE file that accompanied this code).
26 '* You should have received a copy of the GNU Lesser General Public License
27 '* version 3 along with OpenOffice.org. If not, see
28 '* <http://www.openoffice.org/license.html>
29 '* for a copy of the LGPLv3 License.
31 '/************************************************************************
33 '* owner : helge.delfs@sun.com
35 '* short description : Functions for HTML-Test
37 '************************************************************************
39 ' #0 wPasteAvailableClipboardFormats(TheNumber as integer
40 ' #0 wSetClipboardtestDefaults(ForWhat as string) as boolean
41 ' #0 wInsertNewCalcSheet(SheetName as string) as booloean
42 ' #0 wRenameCalcSheet(NewName as string) as boolean
43 ' #0 wFilterSpecialCharacters(ToFilter as string) as string
44 ' #0 ReplaceCharacter(stringToChange$
45 ' #0 wChangeHTMLCompatibility ( optional RecentCompatibility as integer ) as integer
47 '\***********************************************************************
49 function wPasteAvailableClipboardFormats(TheNumber as integer, CheckWhat as String )
50 Dim i as integer, ClipboardFormat as string
51 For i = 1 to TheNumber
55 if i <= TheNumber then
56 QAErrorlog "Number of clipboard formats seems to be changed!"
60 ClipboardFormat = Auswahl.GetSeltext
61 printlog "- Paste as: " + ClipboardFormat
64 if lcase(gPlatform) = "sol" and lcase(ClipboardFormat) = "bitmap" then
65 QAErrorlog "#i49505#Paste drawing object as bitmap crashes office"
76 Select Case gApplication
79 if TextImport.Exists then TextImport.Ok
84 QAErrorlog " - " + Active.Gettext + "->Bug#110181"
88 Call wTypeKeys "<Escape>",2
89 Select Case gApplication
90 Case "WRITER","MASTERDOCUMENT","HTML"
92 Case "text","field","table"
93 Call wTypeKeys "<Down><End><Return>"
94 Call wTypeKeys "(" + Clipboardformat + ")"
95 Call wTypeKeys "<End><Return>",2
96 Case "frame", "DRAW", "graphicL", "graphicE", "ole", "control", "ctext"
97 'Call gMouseClick (50,100)
98 Call wTypeKeys ("<Escape>")
99 Call wTypeKeys "(" + Clipboardformat + ")"
100 if i < TheNumber Then
101 if gApplication <> "HTML" then
103 Kontext "UmbruchEinfuegen"
107 Call wTypeKeys ("<Return>" , 2)
111 EditPasteSpecialWriter
113 Case "IMPRESS","DRAW"
114 Call gMouseClick(7,7)
115 Call wRenameImpressSlide(ClipboardFormat)
116 if i < TheNumber Then
117 Call wInsertNewImpressSlide
121 printlog " Rename first sheet"
122 if wRenameCalcSheet(Clipboardformat) = False then
123 Warnlog "Unable to rename Sheet Name !"
125 if i < TheNumber Then
126 if wInsertNewCalcSheet(Clipboardformat) = False then
127 Warnlog "Unable to set Sheetname : " + Clipboardformat
134 Kontext "InhaltEinfuegen"
136 kontext "NavigatorDraw"
137 if NavigatorDraw.Exists then NavigatorDraw.Close
139 if Navigator.Exists then Navigator.Close
141 kontext "InhaltEinfuegen"
143 if InhaltEinfuegen.Exists then InhaltEinfuegen.Cancel
146 ' ---------------------------------------------------------------------------------
148 function wSetClipboardtestDefaults(ForWhat as string) as boolean
149 printlog " Points cursor to beginning of document "
150 Call hFileOpen (gtesttoolpath & "writer\optional\input\clipboard\writer.sxw")
151 Call sMakeReadOnlyDocumentEditable
152 Kontext "DocumentWriter"
153 printlog " Jump to beginning of document "
154 Call wTypeKeys "<Mod1 Home>"
155 printlog " Check if beginning of document reached "
156 Call wTypeKeys "<Mod1 Shift Right>"
161 '"+ Select first paragraph "
162 Call wTypeKeys "<Shift End>"
163 Call wTypeKeys "<Shift Down>"
164 '"+ Copy selected text "
167 '"+ Select paragraph with 'Date Field' "
168 Call wTypeKeys "<Down>",3
169 Call wTypeKeys "<Home><Shift End>"
170 '"+ Copy selected text "
173 '"+ Select paragraph with 'Table' "
174 Call wNavigatorAuswahl(2,1)
175 'Call wTypeKeys "<Down>",6
176 Call wTypeKeys "<Mod1 A>",2
177 '"+ Copy selected table "
181 Call wTypeKeys ( "<Shift F4>" )
182 '"+ Copy selected frame "
185 '"+ Select 'Drawing Object' "
186 Call wTypeKeys ( "<Shift F4>" )
187 Call wTypeKeys "<Tab>"
188 '"+ Copy selected Drawing Object "
191 '"+ Select 'Linked Graphic' "
192 Call wTypeKeys ( "<Shift F4>" )
193 Call wTypeKeys "<Tab>",2
194 '"+ Copy selected Linked Graphic "
197 '"+ Select 'Embedded Graphic' "
198 Call wTypeKeys ( "<Shift F4>" )
199 Call wTypeKeys "<Tab>",3
200 '"+ Copy selected Embedded Graphic "
203 '"+ Select 'OLE Object' "
204 Call wTypeKeys ( "<Shift F4>" )
205 Call wTypeKeys "<Tab>",4
206 '"+ Copy selected OLE Object "
209 '"+ Select 'Control' "
210 Call wTypeKeys ( "<Shift F4>" )
211 Call wTypeKeys "<Tab>",5
212 '"+ Copy selected Control "
215 Warnlog "Unknown object!"
220 EditCopy 'and a second time to make sure..
221 wSetClipboardtestDefaults = True
223 QAErrorlog "Error jump to beginning of document!"
224 wSetClipboardtestDefaults = False
227 ' Because of Clipboard bug set
228 wSetClipboardtestDefaults = True
231 ' ---------------------------------------------------------------------------------
233 function wInsertNewCalcSheet(SheetName as string) as boolean
234 SheetName= wFilterSpecialCharacters(SheetName)
235 printlog " Inserts a new shett and sets the name for it "
237 Kontext "TabelleEinfuegenCalc"
238 if TabelleEinfuegenCalc.Exists then
240 printlog " Check 'After current sheet' "
242 printlog " Check 'New Sheet' "
243 'Tabellenname.Settext SheetName
244 printlog " Set Name of sheet "
245 TabelleEinfuegenCalc.Ok
246 printlog " Unable to set name of Sheet ? "
248 if Active.Exists then
249 if Active.GetRT = 304 then
250 Warnlog Active.Gettext
252 Kontext "TabelleEinfuegenCalc"
253 if TabelleEinfuegenCalc.Exists then TabelleEinfuegenCalc.Cancel
254 wInsertNewCalcSheet = False
256 wInsertNewCalcSheet = True
259 wInsertNewCalcSheet = True
262 Warnlog "Dialog 'Insert Sheet' not up!"
263 wInsertNewCalcSheet = False
267 ' ---------------------------------------------------------------------------------
269 function wRenameCalcSheet(NewName as string) as boolean
270 printlog " Renames an existing sheet in calc "
272 Kontext "TabelleUmbenennen"
273 if TabelleUmbenennen.Exists then
274 TabellenName.Settext wFilterSpecialCharacters(NewName)
277 if Active.Exists then
278 if Active.GetRT = 304 then
280 Kontext "TabelleUmbenennen"
281 if TabelleUmbenennen.Exists then TabelleUmbenennen.Cancel
282 wRenameCalcSheet = False
284 wRenameCalcSheet = True
287 wRenameCalcSheet = True
290 wRenameCalcSheet = False
294 ' ---------------------------------------------------------------------------------
296 sub wInsertNewImpressSlide()
300 ' ---------------------------------------------------------------------------------
302 sub wRenameImpressSlide(NewName as string)
303 printlog " Edit->Layer->Rename "'
306 Kontext "NameDlgPage"
307 if NameDlgPage.Exists then
308 NameField.Settext NewName
312 Kontext "DocumentDrawImpress"
313 TabBar.TypeKeys NewName + "<Return>" , true
315 Warnlog "Unable to rename Slide (No access to to Tab-Bar!)"
319 Warnlog "Unable to rename Slide!"
324 ' ---------------------------------------------------------------------------------
326 function wFilterSpecialCharacters(ToFilter as string) as string
327 Dim i as integer, SpecialCharacters as string
328 SpecialCharacters = "!
\x15$%&/()=?\}][{*+~'#;,:.-"
329 printlog " Replace SpecialCharacters in SheetName with an underscore (_) "
330 For i = 1 to len(SpecialCharacters)
331 ToFilter = ReplaceCharacter(ToFilter,Mid$(SpecialCharacters,i,1),"_")
333 wFilterSpecialCharacters = ToFilter
336 ' ---------------------------------------------------------------------------------
338 function ReplaceCharacter(stringToChange$, charToReplace$, replaceWith$) As String
340 'Replaces a specified character in a string with another character that you specify
343 Dim NextLetter As String
344 Dim FinalString As String
348 txt = stringToChange$ 'store all arguments in
349 char = charToReplace$ 'new variables
354 For n = 1 To ln Step 1
355 NextLetter = Mid(txt, n, 1)
356 If NextLetter = char Then
359 FinalString = FinalString & NextLetter
361 ReplaceCharacter = FinalString
365 ' ---------------------------------------------------------------------------------
367 Sub wDisableImpressAutopilot()
369 gApplication = "IMPRESS"
372 Call hToolsOptions ("IMPRESS","General")
373 MitAutopilotStarten.UnCheck
374 Kontext "ExtrasOptionenDlg"
380 function wChangeHTMLCompatibility ( optional RecentCompatibility as integer ) as integer
382 Dim CurrentCharSet as String
383 Dim RecentCharSet as integer
384 Dim CharsetFound as boolean
385 printlog " This function sets the charset in options to UTF-8 "
386 printlog " Giving a parameter a special charset will be chosen "
390 Call hToolsOptions("LOADSAVE", "HTMLCOMPATIBILITY")
391 if IsMissing(RecentCompatibility) = True then
392 RecentCharSet = Zeichensatz.GetSelIndex
393 For i = 1 to Zeichensatz.GetItemCount
395 CurrentCharset = Zeichensatz.GetSelText
396 if Instr(Ucase(CurrentCharset), "UTF-8") then
397 i = Zeichensatz.GetItemCount + 1
403 RecentCharSet = RecentCompatibility
404 Zeichensatz.Select RecentCompatibility
406 if CharsetFound = True then
407 printlog "Charset has been changed!"
409 Warnlog "Couldn't set Charset to UTF-8!"
411 Kontext "ExtrasOptionenDlg"
413 wChangeHTMLCompatibility = RecentCharset
417 ' ---------------------------------------------------------------------------------
419 function wChangeHTMLCompatibilityExport ( optional wExport as integer ) as integer
421 Dim CurrentExportSet as String
422 Dim RecentExportSet as integer
423 Dim ExportFound as boolean
424 printlog " This function sets the export in options to 'StarOffice Writer' "
425 printlog " Giving a parameter a special export will be chosen "
429 Call hToolsOptions("LOADSAVE", "HTMLCOMPATIBILITY")
430 if IsMissing ( wExport ) = True then
431 RecentExportSet = Export.GetSelIndex
432 For i = 1 to Export.GetItemCount
434 CurrentExportset = Export.GetSelText
435 if Instr(Ucase(CurrentExportset), "STAROFFICE WRITER") then
436 i = Export.GetItemCount + 1
442 RecentExportSet = wExport
443 Export.Select RecentExportSet
445 if ExportFound = True then
446 printlog "Export has been changed!"
448 Warnlog "Couldn't set Export to StarOffice Writer!"
450 Kontext "ExtrasOptionenDlg"
452 wChangeHTMLCompatibilityExport = RecentExportSet