summaryrefslogtreecommitdiff
path: root/testautomation/spreadsheet/optional/includes/printscale/c_print_scale.inc
blob: e4429e0154942601f7fb31fb1779bf948ca9c465 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
'encoding UTF-8  Do not remove or change this line!
'**************************************************************************
' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
'
' Copyright 2000, 2010 Oracle and/or its affiliates.
'
' OpenOffice.org - a multi-platform office productivity suite
'
' This file is part of OpenOffice.org.
'
' OpenOffice.org is free software: you can redistribute it and/or modify
' it under the terms of the GNU Lesser General Public License version 3
' only, as published by the Free Software Foundation.
'
' OpenOffice.org is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
' GNU Lesser General Public License version 3 for more details
' (a copy is included in the LICENSE file that accompanied this code).
'
' You should have received a copy of the GNU Lesser General Public License
' version 3 along with OpenOffice.org.  If not, see
' <http://www.openoffice.org/license.html>
' for a copy of the LGPLv3 License.
'
'/************************************************************************
'*
'* owner : oliver.craemer@sun.com
'*
'* short description : Check correct print scaling settings
'*
'*************************************************************************************************
'*
' #1 subPrintScaling
' #1 tPrintScaling
'*
'\*************************************************************************************************
sub subPrintScaling
  printLog Chr(13) + "---------  Print scaling settings  ----------"

     call tPrintScaling

end sub
'*************************************************************************************************
testcase tPrintScaling
printlog "Check correct print scaling settings"
printlog " "

dim iIndex as INTEGER

dim sOutputFile as STRING
    sOutputFile = gOfficePath & ConvertPath( "user\work\printScaling.ods" )
    
dim sNameSheet1 as STRING
    sNameSheet1 = "Ten"
dim sNameSheet2 as STRING
    sNameSheet2 = "Moves"
dim sNameSheet3 as STRING
    sNameSheet3 = "Ahead"
    
dim sNameStyle1 as STRING
    sNameStyle1 = "1stStyle"
dim sNameStyle2 as STRING
    sNameStyle2 = "2ndStyle"
dim sNameStyle3 as STRING
    sNameStyle3 = "3rdStyle"
    
dim sPagesToPrint as STRING

    printlog "Open test document"
    Call hNewDocument
    sleep(2)
    
    printlog "Add minimal content to all sheets"
    for iIndex = 1 to 3
        Kontext "RechenleisteCalc"
        if not RechenleisteCalc.isvisible then
            ViewToolbarsFormulaBar
        end if
        sleep(1)
        printlog "* Create simple data area on sheet" & iIndex
        Kontext "RechenleisteCalc"
        Bereich.TypeKeys "<MOD1 A>"
        if iIndex = 1 then
            Bereich.TypeKeys "A1:B2"
            printlog "* Type 'A1:B2' in Name Box to select area"
        else
            Bereich.TypeKeys "A1:AF400"
            printlog "* Type 'A1:AF400' in Name Box to select area"
        end if
        sleep(1)
        printlog "* Press <RETURN>"
        Bereich.TypeKeys "<RETURN>"
        Kontext "DocumentCalc"
        printlog "* Fill area with '13' by typing 13<SHIFT MOD1 RETURN>"
        DocumentCalc.TypeKeys "=13<SHIFT MOD1 RETURN>"
        sleep(1)
        printlog "* Assign specific name for sheet to avoid language dependencies by Format - Sheet - Rename"
        FormatSheetRename
        Kontext "TabelleUmbenennen"
        select case iIndex
               case 1 : Tabellenname.SetText sNameSheet1
               case 2 : Tabellenname.SetText sNameSheet2
               case 3 : Tabellenname.SetText sNameSheet3
        end select
        TabelleUmbenennen.OK
        sleep(1)

        printlog "* Switch to next sheet by Edit - Sheet - Select"
        EditSheetSelect
        Kontext "SelectSheets"
        if iIndex = 3 then
            printlog "* At the end return to the first sheet"
            SheetSelectionBox.Select sNameSheet1
        else
            SheetSelectionBox.Select ( iIndex + 1 )
        end if
        SelectSheets.OK
        sleep(1)
    next iIndex
    
    printlog "Invoke Style catalog"
    FormatStylesCatalog
    Kontext "Vorlagenkatalog"
    printlog "Switch to Pagestyles"
    Vorlagen.select ( 2 )
    sleep(1)
    printlog "Create three styles using different page scaling features"
    for iIndex = 1 to 3
        Kontext "Vorlagenkatalog"
        printlog "* Click new"
        Neu.Click
        Kontext
        printlog "* (Page format dialog should appear)"
        printlog "* Select Page 'Organizer'"
        active.SetPage TabVerwalten
        printlog "* Close MsgBox when appeared"
        if Active.Exists(2) then
            if Active.GetRT = 304 then
                Printlog Active.GetText
                Active.Yes
            end if
        end if
        Kontext "TabVerwalten"
        printlog "* Assign name for each style"
        select case iIndex
               case 1 : VorlagenName.setText sNameStyle1
               case 2 : VorlagenName.setText sNameStyle2
               case 3 : VorlagenName.setText sNameStyle3
        end select
        Kontext
        printlog "* Select Page 'Sheet'"
        active.SetPage TabTabelleCalc
        Kontext "TabTabelleCalc"
        printlog "* For all three styles use different page scaling features"
        scalingMode.Select ( iIndex )
        select case iIndex
               case 1 : SkalierungProzent.setText "444%"
                        printlog "* Scale size to 444%"
                        printlog "* NOTE: Maximum scale is 400%! Entering 444% should be decreased to 400%."
               case 2 : ScalePageWidth.setText "3"
                        ScalePageHeight.setText "3"
                        printlog "* Scale output to 3 pages wide and 3 pages high"
               case 3 : AnzahlMaxSeiten.setText "4"
                        printlog "* Scale output to a total of 4 pages"
        end select
        printlog "* Leave page format dialog using OK"
        TabTabelleCalc.OK
    next iIndex
    printlog "Close style catalog using OK"
    Kontext "Vorlagenkatalog"
    Vorlagenkatalog.OK
    sleep(2)
    printlog "Assign the three styles created to the three sheets in document"
    for iIndex = 1 to 3
        printlog "* Select sheet" & iIndex & " by Edit - Sheet - Select"
        EditSheetSelect
        Kontext "SelectSheets"
        SheetSelectionBox.Select ( iIndex  )
        SelectSheets.OK
        sleep(1)
        printlog "* Open the stylist if it is not opened"
        Kontext "Gestalter"
        if NOT Gestalter.exists(2) then
            FormatStylist
        end if
        printlog "* Assign style" & iIndex & " using the stylist"
        Kontext "Gestalter"
        Seitenvorlagen.Click
        Kontext "Vorlagenliste"
        Vorlagenliste.TypeKeys "<HOME>"
        sleep (2)
        Vorlagenliste.Select ( iIndex )
        Vorlagenliste.TypeKeys "<RETURN>"
    next iIndex
    printlog "Close stylist"
    Kontext "Gestalter"
    if Gestalter.exists(2) then
        FormatStylist
    end if
        
    printlog "Save in current default format"
    if hFileSaveAsWithFilterKill ( sOutputFile , "calc8" ) = FALSE then
        warnlog "Saving " & sOutputFile & " failed! -> Exiting test!"
        call hCloseDocument
    else
        printlog "... and close"
        call hCloseDocument
        sleep(2)
        printlog "Reopen document"
        call hFileOpen ( sOutputFile )
        sleep(2)
        printlog "Invoke File - Print"
        FilePrint
        Kontext "Active"
        Sleep 1
        printlog "Check if a MsgBox pops up due to misconfigured printer settings"
        if Active.Exists(2) then
            if Active.GetRT = 304 then  
                qaErrorlog "OOPS, are you sure that a printer is configured at all?"
                try
                   Active.Ok
                catch
                   Active.Yes
                endcatch
            end if
        end if
        printlog "Check if print dialog exists"
        Kontext "Printing"
        if Printing.Exists(2) then
            Kontext "TabPrintGeneral"
            PrintPages.check
            printlog "Check for string '1-4' in pages textbox"
            sPagesToPrint = PageRange.getText
            if sPagesToPrint = "1-4" then
                printlog "    OK, expected number of pages for output"
            else
                warnlog "Unexpected number of pages for print output: " & sPagesToPrint & " -> Check this out!"
            end if
            Kontext "Printing"
            Printing.Cancel
        else
            qaErrorlog "OOPS, are you sure that a printer is configured at all?"
        end if
        printlog "For all sheets ..."
        for iIndex = 1 to 3
            printlog "* ... select currently desired one"
            EditSheetSelect
            Kontext "SelectSheets"
            SheetSelectionBox.Select ( iIndex  )
            SelectSheets.OK
            sleep(1)
            printlog "* Invoke Format - Page..."
            FormatPageCalc
            Kontext
            printlog "* Select Page 'Sheet'"
            active.SetPage TabTabelleCalc
            printlog "* Close MsgBox when appeared"
            if Active.Exists(2) then
                if Active.GetRT = 304 then
                    Printlog Active.GetText
                    Active.Yes
                end if
            end if
            Kontext "TabTabelleCalc"
            if scalingMode.GetSelIndex = iIndex then
                printlog "* Check if styles for print scaling have be appropriately assign"
                select case iIndex
                       case 1 
                           if SkalierungProzent.GetText <> "400%" then
                               warnlog "Unexpected scaling factor detected -> Check this out!"
                           end if
                           printlog "* Correct scaling mode selected"
                       case 2
                           if ScalePageWidth.GetText <> "3" then
                               warnlog "Unexpected page width detected -> Check this out!"
                           end if
                           if ScalePageHeight.GetText <> "3" then
                               warnlog "Unexpected page height detected -> Check this out!"
                           end if
                           printlog "* Correct scaling mode selected"
                       case 3 
                           if AnzahlMaxSeiten.GetText <> "4" then
                               warnlog "Unexpected page height detected -> Check this out!"
                           end if
                           printlog "* Correct scaling mode selected"
                end select
            else
                warnlog "Unexpected scaling mode found -> Check this out!"
            end if
            printlog "* Quit dialog"
            TabTabelleCalc.Cancel
        next iIndex
        printlog "Close document"
        call hCloseDocument
       
    end if
endcase