title_block_shapes_gost.cpp 39.6 KB
Newer Older
1
/**
2
 * @file title_block_shape_gost.h
3 4 5 6 7
 * @brief description of graphic items and texts to build a title block
 * using GOST standard
 */

/*
8
 * This file creates a lot of structures to define the shape of a title block
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
 * and frame references
 */

/*
 * This program source code file is part of KiCad, a free EDA CAD application.
 *
 * Copyright (C) 1992-2013 KiCad Developers, see change_log.txt for contributors.
 *
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, you may find one here:
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * or you may search the http://www.gnu.org website for the version 2 license,
 * or you may write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 */

36 37 38 39 40 41 42 43
#include <fctsys.h>
#include <drawtxt.h>
#include <appl_wxstruct.h>
#include <worksheet.h>
#include <class_title_block.h>
#include <build_version.h>
#include <worksheet_shape_builder.h>

44
#define TEXTSIZE        100             // worksheet text size
45

46 47 48 49 50 51 52 53 54 55 56
struct Ki_WorkSheetData
{
public:
    int               m_Type;
    Ki_WorkSheetData* Pnext;
    int               m_Posx, m_Posy;
    int               m_Endx, m_Endy;
    const wxChar*     m_TextBase;
    int               m_Flags;
};

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
// Work sheet structure type definitions.
enum TypeKi_WorkSheetData {
    WS_OSN,
    WS_TONK,
    WS_TEXT,
    WS_TEXTL
};

extern Ki_WorkSheetData WS_Osn1_Line1;
extern Ki_WorkSheetData WS_Osn1_Line2;
extern Ki_WorkSheetData WS_Osn1_Line3;
extern Ki_WorkSheetData WS_Osn1_Line4;
extern Ki_WorkSheetData WS_Osn1_Line5;
extern Ki_WorkSheetData WS_Osn1_Line6;
extern Ki_WorkSheetData WS_Osn1_Line7;
extern Ki_WorkSheetData WS_Osn1_Line8;
extern Ki_WorkSheetData WS_Osn1_Line9;
extern Ki_WorkSheetData WS_Osn1_Line10;
extern Ki_WorkSheetData WS_Osn1_Line11;
extern Ki_WorkSheetData WS_Osn1_Line12;
extern Ki_WorkSheetData WS_Osn1_Line13;
extern Ki_WorkSheetData WS_Osn1_Line14;
extern Ki_WorkSheetData WS_Osn1_Line15;
extern Ki_WorkSheetData WS_Osn1_Line16;
extern Ki_WorkSheetData WS_Osn1_Line17;
extern Ki_WorkSheetData WS_Osn1_Line18;
extern Ki_WorkSheetData WS_Osn1_Line19;
extern Ki_WorkSheetData WS_Osn1_Line20;
extern Ki_WorkSheetData WS_Osn1_Line21;
extern Ki_WorkSheetData WS_Osn1_Line22;
extern Ki_WorkSheetData WS_Osn1_Line23;
extern Ki_WorkSheetData WS_Osn1_Line24;
extern Ki_WorkSheetData WS_Osn1_Line25;
extern Ki_WorkSheetData WS_Osn1_Line26;
extern Ki_WorkSheetData WS_Osn1_Line27;

extern Ki_WorkSheetData WS_Osn1_Text1;
extern Ki_WorkSheetData WS_Osn1_Text2;
extern Ki_WorkSheetData WS_Osn1_Text3;
extern Ki_WorkSheetData WS_Osn1_Text4;
extern Ki_WorkSheetData WS_Osn1_Text5;
extern Ki_WorkSheetData WS_Osn1_Text6;
extern Ki_WorkSheetData WS_Osn1_Text7;
extern Ki_WorkSheetData WS_Osn1_Text8;
extern Ki_WorkSheetData WS_Osn1_Text9;
extern Ki_WorkSheetData WS_Osn1_Text10;
extern Ki_WorkSheetData WS_Osn1_Text11;
extern Ki_WorkSheetData WS_Osn1_Text12;
extern Ki_WorkSheetData WS_Osn1_Text13;
extern Ki_WorkSheetData WS_Osn1_Text14;
extern Ki_WorkSheetData WS_Osn1_Text15;
extern Ki_WorkSheetData WS_Osn1_Text16;
extern Ki_WorkSheetData WS_Osn1_Text17;

extern Ki_WorkSheetData WS_Osn2a_Line1;
extern Ki_WorkSheetData WS_Osn2a_Line2;
extern Ki_WorkSheetData WS_Osn2a_Line3;
extern Ki_WorkSheetData WS_Osn2a_Line4;
extern Ki_WorkSheetData WS_Osn2a_Line5;
extern Ki_WorkSheetData WS_Osn2a_Line6;
extern Ki_WorkSheetData WS_Osn2a_Line7;
extern Ki_WorkSheetData WS_Osn2a_Line8;
extern Ki_WorkSheetData WS_Osn2a_Line9;
extern Ki_WorkSheetData WS_Osn2a_Line10;
extern Ki_WorkSheetData WS_Osn2a_Line11;

extern Ki_WorkSheetData WS_Osn2a_Text1;
extern Ki_WorkSheetData WS_Osn2a_Text2;
extern Ki_WorkSheetData WS_Osn2a_Text3;
extern Ki_WorkSheetData WS_Osn2a_Text4;
extern Ki_WorkSheetData WS_Osn2a_Text5;
extern Ki_WorkSheetData WS_Osn2a_Text6;
extern Ki_WorkSheetData WS_Osn2a_Text7;
extern Ki_WorkSheetData WS_Osn2a_Text8;

extern Ki_WorkSheetData WS_DopLeft_Line1;
extern Ki_WorkSheetData WS_DopLeft_Line2;
extern Ki_WorkSheetData WS_DopLeft_Line3;
extern Ki_WorkSheetData WS_DopLeft_Line4;
extern Ki_WorkSheetData WS_DopLeft_Line5;
extern Ki_WorkSheetData WS_DopLeft_Line6;
extern Ki_WorkSheetData WS_DopLeft_Line7;
extern Ki_WorkSheetData WS_DopLeft_Line8;
extern Ki_WorkSheetData WS_DopLeft_Line9;
extern Ki_WorkSheetData WS_DopLeft_Line10;
extern Ki_WorkSheetData WS_DopLeft_Line11;
extern Ki_WorkSheetData WS_DopLeft_Line12;
extern Ki_WorkSheetData WS_DopLeft_Line13;
extern Ki_WorkSheetData WS_DopLeft_Line14;

extern Ki_WorkSheetData WS_DopLeft_Text1;
extern Ki_WorkSheetData WS_DopLeft_Text2;
extern Ki_WorkSheetData WS_DopLeft_Text3;
extern Ki_WorkSheetData WS_DopLeft_Text4;
extern Ki_WorkSheetData WS_DopLeft_Text5;
extern Ki_WorkSheetData WS_DopLeft_Text6;
extern Ki_WorkSheetData WS_DopLeft_Text7;

extern Ki_WorkSheetData WS_DopTop_Line1;
extern Ki_WorkSheetData WS_DopTop_Line2;
extern Ki_WorkSheetData WS_DopTop_Line3;
extern Ki_WorkSheetData WS_DopTop_Line4;
extern Ki_WorkSheetData WS_DopTop_Line5;
extern Ki_WorkSheetData WS_DopTop_Line6;
161

162 163 164

// Center - right bottom corner
Ki_WorkSheetData    WS_Osn1_Line1 =
165 166 167
{
    WS_OSN,
    &WS_Osn1_Line2,
168 169
    Mm2mils( 185 ),Mm2mils( 55 ),
    0,             Mm2mils( 55 ),
170
    NULL
171 172
};

173
Ki_WorkSheetData    WS_Osn1_Line2 =
174 175 176
{
    WS_OSN,
    &WS_Osn1_Line3,
177 178
    Mm2mils( 120 ),Mm2mils( 40 ),
    0,             Mm2mils( 40 ),
179
    NULL
180 181
};

182
Ki_WorkSheetData    WS_Osn1_Line3 =
183 184 185
{
    WS_OSN,
    &WS_Osn1_Line4,
186 187
    Mm2mils( 185 ),Mm2mils( 35 ),
    Mm2mils( 120 ),Mm2mils( 35 ),
188
    NULL
189 190
};

191
Ki_WorkSheetData    WS_Osn1_Line4 =
192 193 194
{
    WS_OSN,
    &WS_Osn1_Line5,
195 196
    Mm2mils( 50 ), Mm2mils( 35 ),
    0,             Mm2mils( 35 ),
197
    NULL
198 199
};

200
Ki_WorkSheetData    WS_Osn1_Line5 =
201 202 203
{
    WS_OSN,
    &WS_Osn1_Line6,
204 205
    Mm2mils( 185 ),Mm2mils( 30 ),
    Mm2mils( 120 ),Mm2mils( 30 ),
206
    NULL
207 208
};

209
Ki_WorkSheetData    WS_Osn1_Line6 =
210 211 212
{
    WS_OSN,
    &WS_Osn1_Line7,
213 214
    Mm2mils( 50 ), Mm2mils( 20 ),
    0,             Mm2mils( 20 ),
215
    NULL
216 217
};

218
Ki_WorkSheetData    WS_Osn1_Line7 =
219 220 221
{
    WS_OSN,
    &WS_Osn1_Line8,
222 223
    Mm2mils( 120 ),Mm2mils( 15 ),
    0,             Mm2mils( 15 ),
224
    NULL
225 226
};

227
Ki_WorkSheetData    WS_Osn1_Line8 =
228 229 230
{
    WS_OSN,
    &WS_Osn1_Line9,
231 232
    Mm2mils( 185 ),Mm2mils( 55 ),
    Mm2mils( 185 ),             0,
233
    NULL
234 235
};

236
Ki_WorkSheetData    WS_Osn1_Line9 =
237 238 239 240 241
{
    WS_OSN,
    &WS_Osn1_Line10,
    Mm2mils( 178 ), Mm2mils( 55 ),
    Mm2mils( 178 ), Mm2mils( 30 ),
242
    NULL
243 244
};

245
Ki_WorkSheetData    WS_Osn1_Line10 =
246 247 248 249
{
    WS_OSN,
    &WS_Osn1_Line11,
    Mm2mils( 168 ), Mm2mils( 55 ),
250
    Mm2mils( 168 ),             0,
251
    NULL
252 253
};

254
Ki_WorkSheetData    WS_Osn1_Line11 =
255 256 257 258
{
    WS_OSN,
    &WS_Osn1_Line12,
    Mm2mils( 145 ), Mm2mils( 55 ),
259
    Mm2mils( 145 ),             0,
260
    NULL
261 262
};

263
Ki_WorkSheetData    WS_Osn1_Line12 =
264 265 266 267
{
    WS_OSN,
    &WS_Osn1_Line13,
    Mm2mils( 130 ), Mm2mils( 55 ),
268
    Mm2mils( 130 ),             0,
269
    NULL
270 271
};

272
Ki_WorkSheetData    WS_Osn1_Line13 =
273 274 275 276
{
    WS_OSN,
    &WS_Osn1_Line14,
    Mm2mils( 120 ), Mm2mils( 55 ),
277
    Mm2mils( 120 ),             0,
278
    NULL
279 280
};

281
Ki_WorkSheetData    WS_Osn1_Line14 =
282 283 284 285
{
    WS_OSN,
    &WS_Osn1_Line15,
    Mm2mils( 50 ),  Mm2mils( 40 ),
286
    Mm2mils( 50 ),             0,
287
    NULL
288 289
};

290
Ki_WorkSheetData    WS_Osn1_Line15 =
291 292 293 294 295
{
    WS_OSN,
    &WS_Osn1_Line16,
    Mm2mils( 35 ),  Mm2mils( 40 ),
    Mm2mils( 35 ),  Mm2mils( 20 ),
296
    NULL
297 298
};

299
Ki_WorkSheetData    WS_Osn1_Line16 =
300 301 302 303 304
{
    WS_OSN,
    &WS_Osn1_Line17,
    Mm2mils( 30 ),  Mm2mils( 20 ),
    Mm2mils( 30 ),  Mm2mils( 15 ),
305
    NULL
306 307
};

308
Ki_WorkSheetData    WS_Osn1_Line17 =
309 310 311 312 313
{
    WS_OSN,
    &WS_Osn1_Line18,
    Mm2mils( 18 ),  Mm2mils( 40 ),
    Mm2mils( 18 ),  Mm2mils( 20 ),
314
    NULL
315 316
};

317
Ki_WorkSheetData    WS_Osn1_Line18 =
318 319 320 321 322
{
    WS_TONK,
    &WS_Osn1_Line19,
    Mm2mils( 185 ), Mm2mils( 50 ),
    Mm2mils( 120 ), Mm2mils( 50 ),
323
    NULL
324 325
};

326
Ki_WorkSheetData    WS_Osn1_Line19 =
327 328 329 330 331
{
    WS_TONK,
    &WS_Osn1_Line20,
    Mm2mils( 185 ), Mm2mils( 45 ),
    Mm2mils( 120 ), Mm2mils( 45 ),
332
    NULL
333 334
};

335
Ki_WorkSheetData    WS_Osn1_Line20 =
336 337 338 339 340
{
    WS_TONK,
    &WS_Osn1_Line21,
    Mm2mils( 185 ), Mm2mils( 40 ),
    Mm2mils( 120 ), Mm2mils( 40 ),
341
    NULL
342 343
};

344
Ki_WorkSheetData    WS_Osn1_Line21 =
345 346 347 348 349
{
    WS_TONK,
    &WS_Osn1_Line22,
    Mm2mils( 185 ), Mm2mils( 25 ),
    Mm2mils( 120 ), Mm2mils( 25 ),
350
    NULL
351 352
};

353
Ki_WorkSheetData    WS_Osn1_Line22 =
354 355 356 357 358
{
    WS_TONK,
    &WS_Osn1_Line23,
    Mm2mils( 185 ), Mm2mils( 20 ),
    Mm2mils( 120 ), Mm2mils( 20 ),
359
    NULL
360 361
};

362
Ki_WorkSheetData    WS_Osn1_Line23 =
363 364 365 366 367
{
    WS_TONK,
    &WS_Osn1_Line24,
    Mm2mils( 185 ), Mm2mils( 15 ),
    Mm2mils( 120 ), Mm2mils( 15 ),
368
    NULL
369 370
};

371
Ki_WorkSheetData    WS_Osn1_Line24 =
372 373 374 375 376
{
    WS_TONK,
    &WS_Osn1_Line25,
    Mm2mils( 185 ), Mm2mils( 10 ),
    Mm2mils( 120 ), Mm2mils( 10 ),
377
    NULL
378 379
};

380
Ki_WorkSheetData    WS_Osn1_Line25 =
381 382 383 384 385
{
    WS_TONK,
    &WS_Osn1_Line26,
    Mm2mils( 185 ), Mm2mils( 5 ),
    Mm2mils( 120 ), Mm2mils( 5 ),
386
    NULL
387 388
};

389
Ki_WorkSheetData    WS_Osn1_Line26 =
390 391 392 393 394
{
    WS_TONK,
    &WS_Osn1_Line27,
    Mm2mils( 45 ),  Mm2mils( 35 ),
    Mm2mils( 45 ),  Mm2mils( 20 ),
395
    NULL
396 397
};

398
Ki_WorkSheetData    WS_Osn1_Line27 =
399 400 401
{
    WS_TONK,
    &WS_Osn1_Text1,
402 403
    Mm2mils( 40 ), Mm2mils( 35 ),
    Mm2mils( 40 ), Mm2mils( 20 ),
404
    NULL
405 406
};

407
Ki_WorkSheetData    WS_Osn1_Text1 =
408 409 410
{
    WS_TEXT,
    &WS_Osn1_Text2,
411 412
    Mm2mils( 181.5 ),Mm2mils( 32.5 ),
    0,                              0,
413
    wxT( "Изм." )
414 415
};

416
Ki_WorkSheetData    WS_Osn1_Text2 =
417 418 419
{
    WS_TEXTL,
    &WS_Osn1_Text3,
420 421
    Mm2mils( 184 ),  Mm2mils( 27.5 ),
    0,                              0,
422
    wxT( "Разраб." )
423 424
};

425
Ki_WorkSheetData    WS_Osn1_Text3 =
426 427 428
{
    WS_TEXTL,
    &WS_Osn1_Text4,
429 430
    Mm2mils( 184 ),Mm2mils( 22.5 ),
    0,                            0,
431
    wxT( "Пров." )
432 433
};

434
Ki_WorkSheetData    WS_Osn1_Text4 =
435 436 437
{
    WS_TEXTL,
    &WS_Osn1_Text5,
438 439
    Mm2mils( 184 ),   Mm2mils( 17.5 ),
    0,                               0,
440
    wxT( "Т.контр." )
441 442
};

443
Ki_WorkSheetData    WS_Osn1_Text5 =
444 445 446
{
    WS_TEXTL,
    &WS_Osn1_Text6,
447 448
    Mm2mils( 184 ),   Mm2mils( 7.5 ),
    0,                              0,
449
    wxT( "Н.контр." )
450 451
};

452
Ki_WorkSheetData    WS_Osn1_Text6 =
453 454 455
{
    WS_TEXTL,
    &WS_Osn1_Text7,
456 457
    Mm2mils( 184 ),Mm2mils( 2.5 ),
    0,                           0,
458
    wxT( "Утв." )
459 460
};

461
Ki_WorkSheetData    WS_Osn1_Text7 =
462 463 464
{
    WS_TEXT,
    &WS_Osn1_Text8,
465 466
    Mm2mils( 173 ),Mm2mils( 32.5 ),
    0,                            0,
467
    wxT( "Лист" )
468 469
};

470
Ki_WorkSheetData    WS_Osn1_Text8 =
471 472 473
{
    WS_TEXT,
    &WS_Osn1_Text9,
474 475
    Mm2mils( 156.5 ), Mm2mils( 32.5 ),
    0,                               0,
476
    wxT( "N докум." )
477 478
};

479
Ki_WorkSheetData    WS_Osn1_Text9 =
480 481 482
{
    WS_TEXT,
    &WS_Osn1_Text10,
483 484
    Mm2mils( 137.5 ),Mm2mils( 32.5 ),
    0,                              0,
485
    wxT( "Подп." )
486 487
};

488
Ki_WorkSheetData    WS_Osn1_Text10 =
489 490 491
{
    WS_TEXT,
    &WS_Osn1_Text11,
492 493
    Mm2mils( 125 ), Mm2mils( 32.5 ),
    0,                            0,
494
    wxT( "Дата" )
495 496
};

497
Ki_WorkSheetData    WS_Osn1_Text11 =
498 499 500
{
    WS_TEXT,
    &WS_Osn1_Text12,
501 502
    Mm2mils( 42.5 ),Mm2mils( 37.5 ),
    0,                             0,
503
    wxT( "Лит." )
504 505
};

506
Ki_WorkSheetData    WS_Osn1_Text12 =
507 508 509
{
    WS_TEXT,
    &WS_Osn1_Text13,
510 511
    Mm2mils( 26.5 ),Mm2mils( 37.5 ),
    0,                             0,
512
    wxT( "Масса" )
513 514
};

515
Ki_WorkSheetData    WS_Osn1_Text13 =
516 517 518
{
    WS_TEXT,
    &WS_Osn1_Text14,
519 520
    Mm2mils( 9 ),    Mm2mils( 37.5 ),
    0,                           0,
521
    wxT( "Масштаб" )
522 523
};

524
Ki_WorkSheetData    WS_Osn1_Text14 =
525 526 527
{
    WS_TEXTL,
    &WS_Osn1_Text15,
528 529
    Mm2mils( 49 ),  Mm2mils( 17.5 ),
    0,                           0,
530
    wxT( "Лист" )
531 532
};

533
Ki_WorkSheetData    WS_Osn1_Text15 =
534 535 536
{
    WS_TEXTL,
    &WS_Osn1_Text16,
537 538
    Mm2mils( 29 ),  Mm2mils( 17.5 ),
    0,                           0,
539
    wxT( "Листов" )
540 541
};

542
Ki_WorkSheetData    WS_Osn1_Text16 =
543 544 545
{
    WS_TEXTL,
    &WS_Osn1_Text17,
546 547
    Mm2mils( 40 ), -Mm2mils( 2.5 ),
    0,                           0,
548
    wxT( "Формат" )
549 550
};

551
Ki_WorkSheetData    WS_Osn1_Text17 =
552 553 554
{
    WS_TEXTL,
    NULL,
555 556
    Mm2mils( 110 ),     -Mm2mils( 2.5 ),
    0,                                0,
557
    wxT( "Копировал" )
558 559
};

560
Ki_WorkSheetData    WS_Osn2a_Line1 =
561 562 563 564 565
{
    WS_OSN,
    &WS_Osn2a_Line2,
    Mm2mils( 185 ), Mm2mils( 15 ),
    0,              Mm2mils( 15 ),
566
    NULL
567 568
};

569
Ki_WorkSheetData    WS_Osn2a_Line2 =
570 571 572 573 574
{
    WS_OSN,
    &WS_Osn2a_Line3,
    Mm2mils( 185 ), Mm2mils( 5 ),
    Mm2mils( 120 ), Mm2mils( 5 ),
575
    NULL
576 577
};

578
Ki_WorkSheetData    WS_Osn2a_Line3 =
579 580 581 582 583
{
    WS_OSN,
    &WS_Osn2a_Line4,
    Mm2mils( 10 ),  Mm2mils( 8 ),
    0,              Mm2mils( 8 ),
584
    NULL
585 586
};

587
Ki_WorkSheetData    WS_Osn2a_Line4 =
588 589 590 591
{
    WS_OSN,
    &WS_Osn2a_Line5,
    Mm2mils( 185 ), Mm2mils( 15 ),
592
    Mm2mils( 185 ),             0,
593
    NULL
594 595
};

596
Ki_WorkSheetData    WS_Osn2a_Line5 =
597 598 599 600
{
    WS_OSN,
    &WS_Osn2a_Line6,
    Mm2mils( 178 ), Mm2mils( 15 ),
601
    Mm2mils( 178 ),             0,
602
    NULL
603 604
};

605
Ki_WorkSheetData    WS_Osn2a_Line6 =
606 607 608 609
{
    WS_OSN,
    &WS_Osn2a_Line7,
    Mm2mils( 168 ), Mm2mils( 15 ),
610
    Mm2mils( 168 ),             0,
611
    NULL
612 613
};

614
Ki_WorkSheetData    WS_Osn2a_Line7 =
615 616 617 618
{
    WS_OSN,
    &WS_Osn2a_Line8,
    Mm2mils( 145 ), Mm2mils( 15 ),
619
    Mm2mils( 145 ),             0,
620
    NULL
621 622
};

623
Ki_WorkSheetData    WS_Osn2a_Line8 =
624 625 626 627
{
    WS_OSN,
    &WS_Osn2a_Line9,
    Mm2mils( 130 ), Mm2mils( 15 ),
628
    Mm2mils( 130 ),             0,
629
    NULL
630 631
};

632
Ki_WorkSheetData    WS_Osn2a_Line9 =
633 634 635
{
    WS_OSN,
    &WS_Osn2a_Line10,
636 637
    Mm2mils( 120 ),  Mm2mils( 15 ),
    Mm2mils( 120 ),             0,
638
    NULL
639 640
};

641
Ki_WorkSheetData    WS_Osn2a_Line10 =
642 643 644
{
    WS_OSN,
    &WS_Osn2a_Line11,
645 646
    Mm2mils( 10 ),   Mm2mils( 15 ),
    Mm2mils( 10 ),             0,
647
    NULL
648 649
};

650
Ki_WorkSheetData    WS_Osn2a_Line11 =
651 652 653 654 655
{
    WS_TONK,
    &WS_Osn2a_Text1,
    Mm2mils( 185 ), Mm2mils( 10 ),
    Mm2mils( 120 ), Mm2mils( 10 ),
656
    NULL
657 658
};

659
Ki_WorkSheetData    WS_Osn2a_Text1 =
660 661 662
{
    WS_TEXT,
    &WS_Osn2a_Text2,
663 664
    Mm2mils( 181.5 ),Mm2mils( 2.5 ),
    0,                             0,
665
    wxT( "Изм." )
666 667
};

668
Ki_WorkSheetData    WS_Osn2a_Text2 =
669 670 671
{
    WS_TEXT,
    &WS_Osn2a_Text3,
672 673
    Mm2mils( 173 ), Mm2mils( 2.5 ),
    0,                           0,
674
    wxT( "Лист" )
675 676
};

677
Ki_WorkSheetData    WS_Osn2a_Text3 =
678 679 680
{
    WS_TEXT,
    &WS_Osn2a_Text4,
681 682
    Mm2mils( 156.5 ), Mm2mils( 2.5 ),
    0,                              0,
683
    wxT( "N докум." )
684 685
};

686
Ki_WorkSheetData    WS_Osn2a_Text4 =
687 688 689
{
    WS_TEXT,
    &WS_Osn2a_Text5,
690 691
    Mm2mils( 137.5 ),Mm2mils( 2.5 ),
    0,                             0,
692
    wxT( "Подп." )
693 694
};

695
Ki_WorkSheetData    WS_Osn2a_Text5 =
696 697 698
{
    WS_TEXT,
    &WS_Osn2a_Text6,
699 700
    Mm2mils( 125 ), Mm2mils( 2.5 ),
    0,                           0,
701
    wxT( "Дата" )
702 703
};

704
Ki_WorkSheetData    WS_Osn2a_Text6 =
705 706 707
{
    WS_TEXT,
    &WS_Osn2a_Text7,
708 709
    Mm2mils( 5 ),   Mm2mils( 11.5 ),
    0,                          0,
710
    wxT( "Лист" )
711 712
};

713
Ki_WorkSheetData    WS_Osn2a_Text7 =
714 715 716
{
    WS_TEXTL,
    &WS_Osn2a_Text8,
717 718
    Mm2mils( 40 ), -Mm2mils( 2.5 ),
    0,                           0,
719
    wxT( "Формат" )
720 721
};

722
Ki_WorkSheetData    WS_Osn2a_Text8 =
723 724 725
{
    WS_TEXTL,
    NULL,
726 727
    Mm2mils( 110 ),     -Mm2mils( 2.5 ),
    0,                                0,
728
    wxT( "Копировал" )
729 730 731 732
};

// Center - left bottom corner

733
Ki_WorkSheetData    WS_DopLeft_Line1 =
734 735 736
{
    WS_OSN,
    &WS_DopLeft_Line2,
737 738
    Mm2mils( 12 ),    Mm2mils( 145 ),
    0,                Mm2mils( 145 ),
739
    NULL
740 741
};

742
Ki_WorkSheetData    WS_DopLeft_Line2 =
743 744 745
{
    WS_OSN,
    &WS_DopLeft_Line3,
746 747
    Mm2mils( 12 ),    Mm2mils( 110 ),
    0,                Mm2mils( 110 ),
748
    NULL
749 750
};

751
Ki_WorkSheetData    WS_DopLeft_Line3 =
752 753 754
{
    WS_OSN,
    &WS_DopLeft_Line4,
755 756
    Mm2mils( 12 ),    Mm2mils( 85 ),
    0,                Mm2mils( 85 ),
757
    NULL
758 759
};

760
Ki_WorkSheetData    WS_DopLeft_Line4 =
761 762 763
{
    WS_OSN,
    &WS_DopLeft_Line5,
764 765
    Mm2mils( 12 ),    Mm2mils( 60 ),
    0,                Mm2mils( 60 ),
766
    NULL
767 768
};

769
Ki_WorkSheetData    WS_DopLeft_Line5 =
770 771 772
{
    WS_OSN,
    &WS_DopLeft_Line6,
773 774
    Mm2mils( 12 ),    Mm2mils( 25 ),
    0,                Mm2mils( 25 ),
775
    NULL
776 777
};

778
Ki_WorkSheetData    WS_DopLeft_Line6 =
779 780 781
{
    WS_OSN,
    &WS_DopLeft_Line7,
782 783
    Mm2mils( 12 ),     0,
    0,                 0,
784
    NULL
785 786
};

787
Ki_WorkSheetData    WS_DopLeft_Line7 =
788 789 790
{
    WS_OSN,
    &WS_DopLeft_Line8,
791 792
    Mm2mils( 12 ),    Mm2mils( 145 ),
    Mm2mils( 12 ),              0,
793
    NULL
794 795
};

796
Ki_WorkSheetData    WS_DopLeft_Line8 =
797 798 799
{
    WS_OSN,
    &WS_DopLeft_Text1,
800 801
    Mm2mils( 7 ),     Mm2mils( 145 ),
    Mm2mils( 7 ),              0,
802
    NULL
803 804
};

805
Ki_WorkSheetData    WS_DopLeft_Text1 =
806 807 808
{
    WS_TEXT,
    &WS_DopLeft_Text2,
809 810
    Mm2mils( 9.5 ),      Mm2mils( 12.5 ),
    0,                               0,
811
    wxT( "Инв.N подл." )
812 813
};

814
Ki_WorkSheetData    WS_DopLeft_Text2 =
815 816 817
{
    WS_TEXT,
    &WS_DopLeft_Text3,
818 819
    Mm2mils( 9.5 ),       Mm2mils( 42.5 ),
    0,                                0,
820
    wxT( "Подп. и дата" )
821 822
};

823
Ki_WorkSheetData    WS_DopLeft_Text3 =
824 825 826
{
    WS_TEXT,
    &WS_DopLeft_Text4,
827 828
    Mm2mils( 9.5 ),     Mm2mils( 72.5 ),
    0,                              0,
829
    wxT( "Взам.инв.N" )
830 831
};

832
Ki_WorkSheetData    WS_DopLeft_Text4 =
833 834 835
{
    WS_TEXT,
    &WS_DopLeft_Text5,
836 837
    Mm2mils( 9.5 ),      Mm2mils( 97.5 ),
    0,                               0,
838
    wxT( "Инв.N дубл." )
839 840
};

841
Ki_WorkSheetData    WS_DopLeft_Text5 =
842 843 844
{
    WS_TEXT,
    &WS_DopLeft_Line9,
845 846
    Mm2mils( 9.5 ),       Mm2mils( 127.5 ),
    0,                                 0,
847
    wxT( "Подп. и дата" )
848 849
};

850
Ki_WorkSheetData    WS_DopLeft_Line9 =
851 852 853
{
    WS_OSN,
    &WS_DopLeft_Line10,
854 855
    Mm2mils( 7 ),      Mm2mils( 287 ),
    Mm2mils( 7 ),      Mm2mils( 167 ),
856
    NULL
857 858
};

859
Ki_WorkSheetData    WS_DopLeft_Line10 =
860 861 862
{
    WS_OSN,
    &WS_DopLeft_Line11,
863 864
    Mm2mils( 12 ),     Mm2mils( 287 ),
    Mm2mils( 12 ),     Mm2mils( 167 ),
865
    NULL
866 867
};

868
Ki_WorkSheetData    WS_DopLeft_Line11 =
869 870 871
{
    WS_OSN,
    &WS_DopLeft_Line12,
872 873
    Mm2mils( 12 ),     Mm2mils( 287 ),
    Mm2mils( 12 ),     Mm2mils( 167 ),
874
    NULL
875 876
};

877
Ki_WorkSheetData    WS_DopLeft_Line12 =
878 879 880
{
    WS_OSN,
    &WS_DopLeft_Line13,
881 882
    Mm2mils( 12 ),     Mm2mils( 167 ),
    0,                 Mm2mils( 167 ),
883
    NULL
884 885
};

886
Ki_WorkSheetData    WS_DopLeft_Line13 =
887 888 889
{
    WS_OSN,
    &WS_DopLeft_Line14,
890 891
    Mm2mils( 12 ),     Mm2mils( 227 ),
    0,                 Mm2mils( 227 ),
892
    NULL
893 894
};

895
Ki_WorkSheetData    WS_DopLeft_Line14 =
896 897 898
{
    WS_OSN,
    &WS_DopLeft_Text6,
899 900
    Mm2mils( 12 ),    Mm2mils( 287 ),
    0,                Mm2mils( 287 ),
901
    NULL
902 903
};

904
Ki_WorkSheetData    WS_DopLeft_Text6 =
905 906 907
{
    WS_TEXT,
    &WS_DopLeft_Text7,
908 909
    Mm2mils( 9.5 ),   Mm2mils( 197 ),
    0,                           0,
910
    wxT( "Справ. N" )
911 912
};

913
Ki_WorkSheetData    WS_DopLeft_Text7 =
914 915 916
{
    WS_TEXT,
    NULL,
917 918
    Mm2mils( 9.5 ),        Mm2mils( 257 ),
    0,                                   0,
919
    wxT( "Перв. примен." )
920 921 922 923
};

// Center - left top corner

924
Ki_WorkSheetData    WS_DopTop_Line1 =
925 926 927
{
    WS_OSN,
    &WS_DopTop_Line2,
928 929
    Mm2mils( 70 ),                0,
    Mm2mils( 70 ),   Mm2mils( 14 ),
930
    NULL
931 932
};

933
Ki_WorkSheetData    WS_DopTop_Line2 =
934 935 936
{
    WS_OSN,
    &WS_DopTop_Line3,
937 938
    Mm2mils( 70 ),   Mm2mils( 14 ),
    0,               Mm2mils( 14 ),
939
    NULL
940 941
};

942
Ki_WorkSheetData    WS_DopTop_Line3 =
943 944 945
{
    WS_OSN,
    &WS_DopTop_Line4,
946 947
    Mm2mils( 70 ),   Mm2mils( 14 ),
    Mm2mils( 137 ),  Mm2mils( 14 ),
948
    NULL
949 950
};

951
Ki_WorkSheetData    WS_DopTop_Line4 =
952 953 954
{
    WS_OSN,
    &WS_DopTop_Line5,
955 956
    Mm2mils( 84 ),   Mm2mils( 7 ),
    Mm2mils( 137 ),  Mm2mils( 7 ),
957
    NULL
958 959
};

960
Ki_WorkSheetData    WS_DopTop_Line5 =
961 962 963
{
    WS_OSN,
    &WS_DopTop_Line6,
964 965
    Mm2mils( 84 ),   Mm2mils( 14 ),
    Mm2mils( 84 ),             0,
966
    NULL
967 968
};

969
Ki_WorkSheetData    WS_DopTop_Line6 =
970 971 972
{
    WS_OSN,
    NULL,
973 974
    Mm2mils( 137 ),Mm2mils( 14 ),
    Mm2mils( 137 ),             0,
975
    NULL
976 977 978 979
};

#include <worksheet_shape_builder.h>

980 981 982 983 984 985 986 987 988 989
class WS_DRAW_ITEM_LIST_GOST : public WS_DRAW_ITEM_LIST
{
public:
    void BuildWorkSheetGraphicListGOST(
                           const PAGE_INFO& aPageInfo,
                           const TITLE_BLOCK& aTitleBlock,
                           EDA_COLOR_T aLineColor, EDA_COLOR_T aTextColor );
};

void WS_DRAW_ITEM_LIST_GOST::BuildWorkSheetGraphicListGOST(
990
                           const PAGE_INFO& aPageInfo,
991 992 993 994 995 996 997
                           const TITLE_BLOCK& aTitleBlock,
                           EDA_COLOR_T aLineColor, EDA_COLOR_T aTextColor )
{
    wxPoint             pos;
    wxPoint             end;
    int                 refx, refy;
    Ki_WorkSheetData*   WsItem;
998
    wxSize              size( TEXTSIZE * m_milsToIu, TEXTSIZE * m_milsToIu );
999
    wxString            msg;
1000
    wxString            paperFormat = aPageInfo.GetType();
1001
    WS_DRAW_ITEM_TEXT*  gtext;
1002

1003 1004
    wxPoint LTmargin( Mm2mils( 20 ), Mm2mils( 5 ) );
    wxPoint RBmargin( Mm2mils( 5 ), Mm2mils( 5 ) );
1005 1006 1007
    SetMargins( LTmargin, RBmargin );
    SetPageSize( aPageInfo.GetSizeMils() );

1008
    // Upper left corner
1009 1010
    refx    = m_LTmargin.x;
    refy    = m_LTmargin.y;
1011 1012 1013

    // lower right corner
    int xg, yg;
1014 1015
    xg  = m_pageSize.x - m_RBmargin.x;
    yg  = m_pageSize.y - m_RBmargin.y;
1016 1017

    int     lnMsg, ln;
1018 1019
    int     lnWosn  = m_penSize * 2;
    int     lnWtonk = m_penSize;
1020
    wxSize  sz;
1021 1022 1023 1024
    wxSize  size0_8( TEXTSIZE * m_milsToIu * 0.8, TEXTSIZE * m_milsToIu * 1 );
    wxSize  size1_5( TEXTSIZE * m_milsToIu * 1.5, TEXTSIZE * m_milsToIu * 1.5 );
    wxSize  size2( TEXTSIZE * m_milsToIu * 2, TEXTSIZE * m_milsToIu * 2 );
    wxSize  size3( TEXTSIZE * m_milsToIu * 3, TEXTSIZE * m_milsToIu * 3 );
1025 1026

    // Draw the border.
1027
    Append( new WS_DRAW_ITEM_RECT( NULL,
1028 1029
                wxPoint( refx * m_milsToIu, refy * m_milsToIu ),
                wxPoint( xg * m_milsToIu, yg * m_milsToIu ),
1030
                lnWosn, aLineColor ) );
1031 1032

    // Center - right bottom corner
1033 1034
    refx    = m_pageSize.x - m_RBmargin.x;
    refy    = m_pageSize.y - m_RBmargin.y;
1035 1036

    // First page
1037
    if( m_sheetNumber == 1 )
1038 1039 1040
    {
        for( WsItem = &WS_Osn1_Line1; WsItem != NULL; WsItem = WsItem->Pnext )
        {
1041 1042 1043 1044
            pos.x   = (refx - WsItem->m_Posx) * m_milsToIu;
            pos.y   = (refy - WsItem->m_Posy) * m_milsToIu;
            end.x   = (refx - WsItem->m_Endx) * m_milsToIu;
            end.y   = (refy - WsItem->m_Endy) * m_milsToIu;
1045
            msg     = WsItem->m_TextBase;
1046

1047 1048 1049
            switch( WsItem->m_Type )
            {
            case WS_OSN:
1050
                Append( new WS_DRAW_ITEM_LINE( NULL, pos, end,
1051
                                               lnWosn, aLineColor ) );
1052 1053 1054
                break;

            case WS_TONK:
1055
                Append( new WS_DRAW_ITEM_LINE( NULL, pos, end,
1056
                                               lnWtonk, aLineColor ) );
1057 1058 1059
                break;

            case WS_TEXT:
1060

1061 1062 1063
                if( !msg.IsEmpty() )
                {
                    if( WsItem == &WS_Osn1_Text1 )
1064
                        Append( new WS_DRAW_ITEM_TEXT( NULL, msg, pos,
1065
                                                       size0_8, m_penSize,
1066
                                                       aLineColor ) );
1067
                    else
1068
                        Append( new WS_DRAW_ITEM_TEXT( NULL, msg, pos,
1069
                                                       size, m_penSize, aLineColor ) );
1070
                }
1071

1072 1073 1074
                break;

            case WS_TEXTL:
1075

1076
                if( !msg.IsEmpty() )
1077
                {
1078
                    Append( gtext = new WS_DRAW_ITEM_TEXT( NULL, msg, pos,
1079
                                                           size, m_penSize, aLineColor ) );
1080 1081
                    gtext->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
                }
1082

1083
                break;
1084 1085 1086 1087
            }
        }

        // Sheet number
1088
        if( m_sheetCount > 1 )
1089
        {
1090 1091
            pos.x   = ( refx - Mm2mils( 36 ) ) * m_milsToIu;
            pos.y   = ( refy - Mm2mils( 17.5 ) ) * m_milsToIu;
1092
            msg.Empty();
1093
            msg << m_sheetNumber;
1094
            Append( new WS_DRAW_ITEM_TEXT( NULL, msg, pos,
1095
                                           size, m_penSize, aLineColor ) );
1096 1097 1098
        }

        // Count of sheets
1099 1100
        pos.x   = ( refx - Mm2mils( 10 ) ) * m_milsToIu;
        pos.y   = ( refy - Mm2mils( 17.5 ) ) * m_milsToIu;
1101
        msg.Empty();
1102
        msg << m_sheetCount;
1103
        Append( gtext = new WS_DRAW_ITEM_TEXT( NULL, msg, pos,
1104
                                               size, m_penSize, aLineColor ) );
1105
        gtext->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
1106 1107 1108

        // Company name
        msg = aTitleBlock.GetCompany();
1109

1110 1111
        if( !msg.IsEmpty() )
        {
1112
            sz      = size1_5;
1113
            lnMsg   = ReturnGraphicTextWidth( msg, sz.x, false, false ) / m_milsToIu;
1114 1115
            ln      = Mm2mils( 49 );

1116
            if( lnMsg > ln )
1117 1118
                sz.x *= float(ln) / lnMsg;

1119 1120
            pos.x   = ( refx - Mm2mils( 25 ) ) * m_milsToIu;
            pos.y   = ( refy - Mm2mils( 7.5 ) ) * m_milsToIu;
1121
            Append( new WS_DRAW_ITEM_TEXT( NULL, msg, pos,
1122
                                           sz, m_penSize, aLineColor ) );
1123 1124 1125 1126
        }

        // Title
        msg = aTitleBlock.GetTitle();
1127

1128 1129 1130
        if( !msg.IsEmpty() )
        {
            sz = size1_5;
1131 1132
            wxArrayString   lines;
            int             titleWidth          = 0;
1133
            int             titleHeight         = (sz.y + sz.y * 0.5) / m_milsToIu;
1134 1135 1136 1137 1138
            int             titleFieldWidth     = Mm2mils( 69 );
            int             titleFieldHeight    = Mm2mils( 24 );
            int             index   = 0;
            wxString        fullMsg = msg;

1139
            while( 1 )      // Reduce the height of wrapped title until the fit
1140
            {
1141
                 while( 1 ) // Wrap the title
1142
                {
1143
                    titleWidth = ReturnGraphicTextWidth( msg, sz.x, false, false ) / m_milsToIu;
1144

1145 1146 1147
                    if( titleWidth > titleFieldWidth )
                    {
                        index = 0;
1148

1149
                        while( 1 )
1150 1151
                        {
                            msg = msg.Left( msg.Length() - 1 );
1152

1153 1154 1155
                            if( msg.Length() == 0 )
                            {
                                lines.Clear();
1156
                                msg     = fullMsg;
1157
                                sz.x    -= m_milsToIu;
1158 1159 1160 1161 1162
                                break;
                            }
                            else
                            {
                                index++;
1163
                                titleWidth =
1164
                                    ReturnGraphicTextWidth( msg, sz.x, false, false ) / m_milsToIu;
1165 1166

                                wxString ch = wxString( msg.Last() );
1167

1168 1169 1170 1171
                                if( titleWidth < titleFieldWidth && ch == wxT( " " ) )
                                {
                                    // New sentence on a new line
                                    int dot = msg.Index( wxT( ". " ) );
1172

1173 1174
                                    if( dot != wxNOT_FOUND )
                                    {
1175 1176
                                        index   += msg.Length() - dot - 2;
                                        msg     = msg.Left( dot + 1 );
1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189
                                        lines.Add( msg );
                                        msg = fullMsg.Right( index );
                                        break;
                                    }
                                    else
                                    {
                                        msg = msg.Left( msg.Length() - 1 );
                                        lines.Add( msg );
                                        msg = fullMsg.Right( index );
                                        break;
                                    }
                                }
                            }
1190
                        }
1191 1192 1193 1194 1195
                    }
                    else
                    {
                        // New sentence on a new line
                        int dot = msg.Index( wxT( ". " ) );
1196

1197 1198 1199 1200 1201 1202 1203
                        if( dot != wxNOT_FOUND )
                        {
                            lines.Add( msg.Left( dot + 1 ) );
                            lines.Add( fullMsg.Right( msg.Length() - dot - 2 ) );
                        }
                        else
                            lines.Add( msg );
1204

1205 1206
                        break;
                    }
1207
                }
1208

1209
                if( titleFieldHeight < (int) ( titleHeight * lines.Count() ) )
1210
                {
1211 1212
                    sz.y    -= m_milsToIu;
                    sz.x    -= m_milsToIu;
1213
                    msg     = fullMsg;
1214 1215 1216 1217
                    lines.Clear();
                }
                else
                    break;
1218
            }
1219

1220
            pos.x   = ( refx - Mm2mils( 85 ) ) * m_milsToIu;
1221
            pos.y   =
1222
                ( refy - Mm2mils( 27.5 ) - (titleHeight * (lines.Count() - 1) / 2) ) * m_milsToIu;
1223

1224
            for( unsigned curLn = 0; curLn < lines.Count(); curLn++ )
1225 1226
            {
                msg = lines[curLn];
1227
                Append( new WS_DRAW_ITEM_TEXT( NULL, msg, pos,
1228 1229
                                               sz, m_penSize, aTextColor ) );
                pos.y += titleHeight * m_milsToIu;
1230 1231 1232 1233 1234
            }
        }

        // Decimal number
        msg = aTitleBlock.GetComment1();
1235

1236 1237
        if( !msg.IsEmpty() )
        {
1238
            sz      = size3;
1239
            lnMsg   = ReturnGraphicTextWidth( msg, sz.x, false, false ) / m_milsToIu;
1240 1241
            ln      = Mm2mils( 119 );

1242
            if( lnMsg > ln )
1243 1244
                sz.x *= float(ln) / lnMsg;

1245 1246
            pos.x   = ( refx - Mm2mils( 60 ) ) * m_milsToIu;
            pos.y   = ( refy - Mm2mils( 47.5 ) ) * m_milsToIu;
1247
            Append( new WS_DRAW_ITEM_TEXT(NULL,  msg, pos,
1248
                                           sz, m_penSize, aTextColor ) );
1249 1250 1251 1252
        }

        // Developer
        msg = aTitleBlock.GetComment2();
1253

1254 1255
        if( !msg.IsEmpty() )
        {
1256
            sz      = size;
1257
            lnMsg   = ReturnGraphicTextWidth( msg, sz.x, false, false ) / m_milsToIu;
1258 1259
            ln      = Mm2mils( 22 );

1260
            if( lnMsg > ln )
1261 1262
                sz.x *= float(ln) / lnMsg;

1263 1264
            pos.x   = ( refx - Mm2mils( 167.5 ) ) * m_milsToIu;
            pos.y   = ( refy - Mm2mils( 27.5 ) ) * m_milsToIu;
1265
            Append( gtext = new WS_DRAW_ITEM_TEXT( NULL, msg, pos,
1266
                                                   sz, m_penSize, aTextColor ) );
1267
            gtext->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
1268 1269 1270 1271
        }

        // Verifier
        msg = aTitleBlock.GetComment3();
1272

1273 1274
        if( !msg.IsEmpty() )
        {
1275
            sz      = size;
1276
            lnMsg   = ReturnGraphicTextWidth( msg, sz.x, false, false ) / m_milsToIu;
1277 1278
            ln      = Mm2mils( 22 );

1279
            if( lnMsg > ln )
1280 1281
                sz.x *= float(ln) / lnMsg;

1282 1283
            pos.x   = ( refx - Mm2mils( 167 ) ) * m_milsToIu;
            pos.y   = ( refy - Mm2mils( 22.5 ) ) * m_milsToIu;
1284
            Append( gtext = new WS_DRAW_ITEM_TEXT( NULL, msg, pos,
1285
                                                   sz, m_penSize, aTextColor ) );
1286
            gtext->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
1287 1288 1289 1290
        }

        // Approver
        msg = aTitleBlock.GetComment4();
1291

1292 1293
        if( !msg.IsEmpty() )
        {
1294
            sz      = size;
1295
            lnMsg   = ReturnGraphicTextWidth( msg, sz.x, false, false ) / m_milsToIu;
1296 1297
            ln      = Mm2mils( 22 );

1298
            if( lnMsg > ln )
1299 1300
                sz.x *= float(ln) / lnMsg;

1301 1302
            pos.x   = ( refx - Mm2mils( 167 ) ) * m_milsToIu;
            pos.y   = ( refy - Mm2mils( 2.5 ) ) * m_milsToIu;
1303
            Append( gtext = new WS_DRAW_ITEM_TEXT( NULL, msg, pos,
1304
                                                   sz, m_penSize, aTextColor ) );
1305
            gtext->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
1306 1307
        }
    }
1308
    else    // other pages
1309 1310 1311
    {
        for( WsItem = &WS_Osn2a_Line1; WsItem != NULL; WsItem = WsItem->Pnext )
        {
1312 1313 1314 1315
            pos.x   = (refx - WsItem->m_Posx) * m_milsToIu;
            pos.y   = (refy - WsItem->m_Posy) * m_milsToIu;
            end.x   = (refx - WsItem->m_Endx) * m_milsToIu;
            end.y   = (refy - WsItem->m_Endy) * m_milsToIu;
1316
            msg     = WsItem->m_TextBase;
1317

1318 1319 1320
            switch( WsItem->m_Type )
            {
            case WS_OSN:
1321
                Append( new WS_DRAW_ITEM_LINE( NULL, pos, end,
1322
                                               lnWosn, aLineColor ) );
1323 1324 1325
                break;

            case WS_TONK:
1326
                Append( new WS_DRAW_ITEM_LINE( NULL, pos, end,
1327
                                               lnWtonk, aLineColor ) );
1328 1329 1330
                break;

            case WS_TEXT:
1331

1332 1333 1334
                if( !msg.IsEmpty() )
                {
                    if( WsItem == &WS_Osn2a_Text1 )
1335
                        Append( new WS_DRAW_ITEM_TEXT( NULL, msg, pos,
1336
                                                       size0_8, m_penSize,
1337
                                                       aLineColor ) );
1338
                    else
1339
                        Append( new WS_DRAW_ITEM_TEXT( NULL, msg, pos,
1340
                                                       size, m_penSize, aLineColor ) );
1341
                }
1342

1343 1344 1345
                break;

            case WS_TEXTL:
1346

1347
                if( !msg.IsEmpty() )
1348
                {
1349
                    Append( gtext = new WS_DRAW_ITEM_TEXT( NULL, msg, pos,
1350
                                                           size, m_penSize,
1351 1352 1353 1354
                                                           aLineColor ) );
                    gtext->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
                }

1355 1356 1357 1358 1359
                break;
            }
        }

        // Sheet number
1360 1361
        pos.x   = ( refx - Mm2mils( 5 ) ) * m_milsToIu;
        pos.y   = ( refy - Mm2mils( 4 ) ) * m_milsToIu;
1362
        msg.Empty();
1363
        msg << m_sheetNumber;
1364
        Append( gtext = new WS_DRAW_ITEM_TEXT( NULL, msg, pos,
1365
                                               size, m_penSize, aLineColor ) );
1366 1367 1368

        // Decimal number
        msg = aTitleBlock.GetComment1();
1369

1370 1371
        if( !msg.IsEmpty() )
        {
1372
            sz      = size3;
1373
            lnMsg   = ReturnGraphicTextWidth( msg, sz.x, false, false ) / m_milsToIu;
1374 1375
            ln      = Mm2mils( 109 );

1376
            if( lnMsg > ln )
1377 1378
                sz.x *= float(ln) / lnMsg;

1379 1380
            pos.x   = ( refx - Mm2mils( 65 ) ) * m_milsToIu;
            pos.y   = ( refy - Mm2mils( 7.5 ) ) * m_milsToIu;
1381
            Append( new WS_DRAW_ITEM_TEXT( NULL, msg, pos,
1382
                                           sz, m_penSize, aTextColor ) );
1383 1384 1385 1386
        }
    }

    // Format
1387 1388
    pos.x   = ( refx - Mm2mils( 23 ) ) * m_milsToIu;
    pos.y   = ( refy + Mm2mils( 2.5 ) ) * m_milsToIu;
1389
    msg.Empty();
1390 1391
    msg << paperFormat;
    Append( gtext = new WS_DRAW_ITEM_TEXT( NULL, msg, pos,
1392
                                           size, m_penSize, aLineColor ) );
1393
    gtext->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
1394 1395

    // Center - left bottom corner
1396 1397
    refx    = m_LTmargin.x;
    refy    = m_pageSize.y - m_RBmargin.y;
1398

1399 1400
    for( WsItem = &WS_DopLeft_Line1; WsItem != NULL; WsItem = WsItem->Pnext )
    {
1401
        if( m_sheetNumber > 1 && WsItem == &WS_DopLeft_Line9 ) // Some fields for first page only
1402 1403
            break;

1404 1405 1406 1407
        pos.x   = (refx - WsItem->m_Posx) * m_milsToIu;
        pos.y   = (refy - WsItem->m_Posy) * m_milsToIu;
        end.x   = (refx - WsItem->m_Endx) * m_milsToIu;
        end.y   = (refy - WsItem->m_Endy) * m_milsToIu;
1408
        msg     = WsItem->m_TextBase;
1409

1410 1411 1412
        switch( WsItem->m_Type )
        {
        case WS_OSN:
1413
            Append( new WS_DRAW_ITEM_LINE( NULL, pos, end,
1414
                                           lnWosn, aLineColor ) );
1415 1416 1417
            break;

        case WS_TEXT:
1418

1419
            if( !msg.IsEmpty() )
1420
            {
1421
                Append( gtext = new WS_DRAW_ITEM_TEXT( NULL, msg, pos,
1422
                                                       size, m_penSize, aLineColor ) );
1423 1424 1425
                gtext->SetOrientation( TEXT_ORIENT_VERT );
            }

1426 1427 1428 1429
            break;
        }
    }

1430
    if( paperFormat == PAGE_INFO::A4 || m_pageSize.x > m_pageSize.y )    // A4 or Landscape
1431 1432
    {
        // Center - left top corner
1433 1434
        refx    = m_LTmargin.x;
        refy    = m_LTmargin.y;
1435

1436 1437
        for( WsItem = &WS_DopTop_Line1; WsItem != NULL; WsItem = WsItem->Pnext )
        {
1438
            if( m_sheetNumber > 1 && WsItem == &WS_DopTop_Line3 ) // Some fields for first page only
1439 1440
                break;

1441 1442 1443 1444
            pos.x   = (refx + WsItem->m_Posx) * m_milsToIu;
            pos.y   = (refy + WsItem->m_Posy) * m_milsToIu;
            end.x   = (refx + WsItem->m_Endx) * m_milsToIu;
            end.y   = (refy + WsItem->m_Endy) * m_milsToIu;
1445
            msg     = WsItem->m_TextBase;
1446

1447 1448 1449
            switch( WsItem->m_Type )
            {
            case WS_OSN:
1450
                Append( new WS_DRAW_ITEM_LINE( NULL, pos, end,
1451
                                               lnWosn, aLineColor ) );
1452 1453 1454
                break;

            case WS_TONK:
1455
                Append( new WS_DRAW_ITEM_LINE( NULL, pos, end,
1456
                                               lnWtonk, aLineColor ) );
1457 1458 1459 1460 1461 1462
                break;
            }
        }

        // Decimal number
        msg = aTitleBlock.GetComment1();
1463

1464 1465
        if( !msg.IsEmpty() )
        {
1466
            sz      = size2;
1467
            lnMsg   = ReturnGraphicTextWidth( msg, sz.x, false, false ) / m_milsToIu;
1468 1469
            ln      = Mm2mils( 69 );

1470
            if( lnMsg > ln )
1471 1472
                sz.x *= float(ln) / lnMsg;

1473 1474
            pos.x   = ( refx + Mm2mils( 35 ) ) * m_milsToIu;
            pos.y   = ( refy + Mm2mils( 7 ) ) * m_milsToIu;
1475
            Append( gtext = new WS_DRAW_ITEM_TEXT( NULL, msg, pos,
1476
                                                   sz, m_penSize, aTextColor ) );
1477
            gtext->SetOrientation( 1800.0 );
1478 1479
        }
    }
1480
    else    // Portrait
1481 1482 1483
    {
        // Center - right top corner
        // Lines are used from the upper left corner by the change of coordinates
1484 1485
        refx    = m_pageSize.x - m_RBmargin.x;
        refy    = m_LTmargin.y;
1486

1487 1488
        for( WsItem = &WS_DopTop_Line1; WsItem != NULL; WsItem = WsItem->Pnext )
        {
1489
            if( m_sheetNumber > 1 && WsItem == &WS_DopTop_Line3 ) // Some fields for first page only
1490 1491
                break;

1492 1493 1494 1495
            pos.x   = (refx - WsItem->m_Posy) * m_milsToIu;
            pos.y   = (refy + WsItem->m_Posx) * m_milsToIu;
            end.x   = (refx - WsItem->m_Endy) * m_milsToIu;
            end.y   = (refy + WsItem->m_Endx) * m_milsToIu;
1496
            msg     = WsItem->m_TextBase;
1497

1498 1499 1500
            switch( WsItem->m_Type )
            {
            case WS_OSN:
1501
                Append( new WS_DRAW_ITEM_LINE( NULL, pos, end,
1502
                                               lnWosn, aLineColor ) );
1503 1504 1505
                break;

            case WS_TONK:
1506
                Append( new WS_DRAW_ITEM_LINE( NULL, pos, end,
1507
                                               lnWtonk, aLineColor ) );
1508 1509 1510 1511 1512 1513
                break;
            }
        }

        // Decimal number
        msg = aTitleBlock.GetComment1();
1514

1515 1516
        if( !msg.IsEmpty() )
        {
1517
            sz      = size2;
1518
            lnMsg   = ReturnGraphicTextWidth( msg, sz.x, false, false ) / m_milsToIu;
1519 1520
            ln      = Mm2mils( 69 );

1521
            if( lnMsg > ln )
1522 1523
                sz.x *= float(ln) / lnMsg;

1524 1525
            pos.x   = ( refx - Mm2mils( 7 ) ) * m_milsToIu;
            pos.y   = ( refy + Mm2mils( 35 ) ) * m_milsToIu;
1526
            Append( gtext = new WS_DRAW_ITEM_TEXT( NULL, msg, pos,
1527
                                                   sz, m_penSize, aTextColor ) );
1528
            gtext->SetOrientation( TEXT_ORIENT_VERT );
1529 1530 1531
        }
    }
}