summaryrefslogtreecommitdiff
path: root/vcl/os2/source/gdi/salprn.cxx
blob: a31a4bb779f861cff1e2e222fe8f218421f27bec (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
ef='#n67'>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 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836
/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2008 by Sun Microsystems, Inc.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * $RCSfile: salprn.cxx,v $
 * $Revision: 1.6 $
 *
 * 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.
 *
 ************************************************************************/

// use this define to disable the DJP support
// #define NO_DJP

#define INCL_DOSMODULEMGR
#define INCL_DEV
#define INCL_SPL
#define INCL_SPLERRORS
#define INCL_SPLDOSPRINT
#define INCL_DEVDJP

#define INCL_GPI
#define INCL_DOSSEMAPHORES
#define INCL_PM
#include <svpm.h>
#include <pmdjp.h>

#include <string.h>

#define _SV_SALPRN_CXX
#include <tools/debug.hxx>
#include <saldata.hxx>
#include <salinst.h>
#include <salgdi.h>
#include <salframe.h>
#include <vcl/salptype.hxx>
#include <salprn.h>
#include <vcl/print.h>
#include <vcl/jobset.h>

#ifndef __H_FT2LIB
#include <wingdi.h>
#include <ft2lib.h>
#endif

// =======================================================================

// -----------------------
// - struct ImplFormInfo -
// -----------------------

struct ImplFormInfo
{
    long                    mnPaperWidth;
    long                    mnPaperHeight;
#ifndef NO_DJP
    DJPT_PAPERSIZE          mnId;
#endif
};

// =======================================================================

// -----------------------
// - struct ImplTrayInfo -
// -----------------------

struct ImplTrayInfo
{
    CHAR            maName[32];
    CHAR            maDisplayName[64];
    DJPT_TRAYTYPE   mnId;

    ImplTrayInfo( const char* pTrayName,
                  const char* pTrayDisplayName )
    {
        strcpy( maName, pTrayName);
        strcpy( maDisplayName, pTrayDisplayName);
    }
};

// =======================================================================

struct ImplQueueSalSysData
{
    ByteString      maPrinterName;          // pszPrinters
    ByteString      maName;                 // pszName bzw. LogAddress
    ByteString      maOrgDriverName;        // pszDriverName (maDriverName.maDeviceName)
    ByteString      maDriverName;           // pszDriverName bis .
    ByteString      maDeviceName;           // pszDriverName nach .
    PDRIVDATA       mpDrivData;

                    ImplQueueSalSysData( const ByteString& rPrinterName,
                                         const ByteString& rName,
                                         const ByteString& rDriverName,
                                         const ByteString& rDeviceName,
                                         const ByteString& rOrgDriverName,
                                         PDRIVDATA pDrivData  );
                    ~ImplQueueSalSysData();
};

// -----------------------------------------------------------------------

ImplQueueSalSysData::ImplQueueSalSysData( const ByteString& rPrinterName,
                                          const ByteString& rName,
                                          const ByteString& rOrgDriverName,
                                          const ByteString& rDriverName,
                                          const ByteString& rDeviceName,
                                          PDRIVDATA pDrivData ) :
    maPrinterName( rPrinterName ),
    maName( rName ),
    maOrgDriverName( rName ),
    maDriverName( rDriverName ),
    maDeviceName( rDeviceName )
{
    if ( pDrivData )
    {
        mpDrivData = (PDRIVDATA)new BYTE[pDrivData->cb];
        memcpy( mpDrivData, pDrivData, pDrivData->cb );
    }
    else
        mpDrivData = NULL;
}

// -----------------------------------------------------------------------

ImplQueueSalSysData::~ImplQueueSalSysData()
{
    delete mpDrivData;
}

// =======================================================================

static ULONG ImplPMQueueStatusToSal( USHORT nPMStatus )
{
    ULONG nStatus = 0;
    if ( nPMStatus & PRQ3_PAUSED )
        nStatus |= QUEUE_STATUS_PAUSED;
    if ( nPMStatus & PRQ3_PENDING )
        nStatus |= QUEUE_STATUS_PENDING_DELETION;
    if ( !nStatus )
        nStatus |= QUEUE_STATUS_READY;
    return nStatus;
}

// -----------------------------------------------------------------------

void Os2SalInstance::GetPrinterQueueInfo( ImplPrnQueueList* pList )
{
    APIRET rc;
    ULONG  nNeeded;
    ULONG  nReturned;
    ULONG  nTotal;

    // query needed size of the buffer for the QueueInfo
    rc = SplEnumQueue( (PSZ)NULL, 3, NULL, 0, &nReturned, &nTotal, &nNeeded, NULL );
    if( nNeeded == 0 )
        return;

    // create the buffer for the QueueInfo
    PCHAR pQueueData = new CHAR[nNeeded];

    // query QueueInfos
    rc = SplEnumQueue( (PSZ)NULL, 3, pQueueData, nNeeded, &nReturned, &nTotal, &nNeeded, NULL );

    PPRQINFO3 pPrqInfo = (PPRQINFO3)pQueueData;
    for ( int i = 0; i < nReturned; i++ )
    {
        // create entry for the QueueInfo array
        SalPrinterQueueInfo* pInfo = new SalPrinterQueueInfo;

        ByteString aOrgDriverName( pPrqInfo->pszDriverName);
        ByteString aName( pPrqInfo->pszName);
        pInfo->maDriver      = ::rtl::OStringToOUString (aOrgDriverName, gsl_getSystemTextEncoding());
        pInfo->maPrinterName = ::rtl::OStringToOUString (pPrqInfo->pszComment, gsl_getSystemTextEncoding());
        pInfo->maLocation    = ::rtl::OStringToOUString (aName, gsl_getSystemTextEncoding());
        pInfo->mnStatus      = ImplPMQueueStatusToSal( pPrqInfo->fsStatus );
        pInfo->mnJobs        = pPrqInfo->cJobs;
        // pInfo->maComment = !!!

        // Feststellen, ob Name doppelt
        PPRQINFO3 pTempPrqInfo = (PPRQINFO3)pQueueData;
        for ( int j = 0; j < nReturned; j++ )
        {
            // Wenn Name doppelt, erweitern wir diesen um die Location
            if ( (j != i) &&
                 (strcmp( pPrqInfo->pszComment, pTempPrqInfo->pszComment ) == 0) )
            {
                pInfo->maPrinterName += ';';
                pInfo->maPrinterName += pInfo->maLocation;
            }
            pTempPrqInfo++;
        }

        // pszDriver in DriverName (bis .) und DeviceName (nach .) aufsplitten
        PSZ pDriverName;
        PSZ pDeviceName;
        if ( (pDriverName = strchr( pPrqInfo->pszDriverName, '.' )) != 0 )
        {
           *pDriverName = 0;
           pDeviceName  = pDriverName + 1;
        }
        else
            pDeviceName = NULL;

        // Alle Bytes hinter dem DeviceNamen auf 0 initialisieren, damit
        // ein memcmp vom JobSetup auch funktioniert
        if ( pPrqInfo->pDriverData &&
             (pPrqInfo->pDriverData->cb >= sizeof( pPrqInfo->pDriverData )) )
        {
            int nDeviceNameLen = strlen( pPrqInfo->pDriverData->szDeviceName );
            memset( pPrqInfo->pDriverData->szDeviceName+nDeviceNameLen,
                    0,
                    sizeof( pPrqInfo->pDriverData->szDeviceName )-nDeviceNameLen );
        }

        // save driver data and driver names
        ByteString aPrinterName( pPrqInfo->pszPrinters);
        ByteString aDriverName( pPrqInfo->pszDriverName);
        ByteString aDeviceName;
        if ( pDeviceName )
            aDeviceName = pDeviceName;
        pInfo->mpSysData = new ImplQueueSalSysData( aPrinterName, aName,
                                                    aOrgDriverName,
                                                    aDriverName, aDeviceName,
                                                    pPrqInfo->pDriverData );

        // add queue to the list
        pList->Add( pInfo );

        // increment to next element of the QueueInfo array
        pPrqInfo++;
    }

    delete [] pQueueData;
}

// -----------------------------------------------------------------------

void Os2SalInstance::GetPrinterQueueState( SalPrinterQueueInfo* pInfo )
{
    APIRET rc;
    ULONG  nNeeded;
    ULONG  nReturned;
    ULONG  nTotal;

    // query needed size of the buffer for the QueueInfo
    rc = SplEnumQueue( (PSZ)NULL, 3, NULL, 0, &nReturned, &nTotal, &nNeeded, NULL );
    if( nNeeded == 0 )
        return;

    // create the buffer for the QueueInfo
    PCHAR pQueueData = new CHAR[nNeeded];

    // query QueueInfos
    rc = SplEnumQueue( (PSZ)NULL, 3, pQueueData, nNeeded, &nReturned, &nTotal, &nNeeded, NULL );

    PPRQINFO3 pPrqInfo = (PPRQINFO3)pQueueData;
    for ( int i = 0; i < nReturned; i++ )
    {
        ImplQueueSalSysData* pSysData = (ImplQueueSalSysData*)(pInfo->mpSysData);
        if ( pSysData->maPrinterName.Equals( pPrqInfo->pszPrinters ) &&
             pSysData->maName.Equals( pPrqInfo->pszName ) &&
             pSysData->maOrgDriverName.Equals( pPrqInfo->pszDriverName ) )
        {
            pInfo->mnStatus = ImplPMQueueStatusToSal( pPrqInfo->fsStatus );
            pInfo->mnJobs   = pPrqInfo->cJobs;
            break;
        }

        // increment to next element of the QueueInfo array
        pPrqInfo++;
    }

    delete [] pQueueData;
}

// -----------------------------------------------------------------------

void Os2SalInstance::DeletePrinterQueueInfo( SalPrinterQueueInfo* pInfo )
{
    delete ((ImplQueueSalSysData*)(pInfo->mpSysData));
    delete pInfo;
}

// -----------------------------------------------------------------------

XubString Os2SalInstance::GetDefaultPrinter()
{
    APIRET      rc;
    ULONG       nNeeded;
    ULONG       nReturned;
    ULONG       nTotal;
    char        szQueueName[255];
    XubString   aDefaultName;

    // query default queue
    if ( !PrfQueryProfileString( HINI_PROFILE, SPL_INI_SPOOLER, "QUEUE", 0, szQueueName, sizeof( szQueueName ) ) )
        return aDefaultName;

    // extract first queue name
    PSZ pStr;
    if ( (pStr = strchr( szQueueName, ';' )) != 0 )
        *pStr = 0;

    // query needed size of the buffer for the QueueInfo
    rc = SplEnumQueue( (PSZ)NULL, 3, NULL, 0, &nReturned, &nTotal, &nNeeded, NULL );
    if ( nNeeded == 0 )
        return aDefaultName;

    // create the buffer for the QueueInfo
    PCHAR pQueueData = new CHAR[ nNeeded ];

    // query QueueInfos
    rc = SplEnumQueue ((PSZ)NULL, 3, pQueueData, nNeeded, &nReturned, &nTotal, &nNeeded, NULL );

    // find printer name for default queue
    PPRQINFO3 pPrqInfo = (PPRQINFO3) pQueueData;
    for ( int i = 0; i < nReturned; i++ )
    {
        if ( strcmp( pPrqInfo->pszName, szQueueName ) == 0 )
        {
            aDefaultName = ::rtl::OStringToOUString (pPrqInfo->pszComment, gsl_getSystemTextEncoding());

            // Feststellen, ob Name doppelt
            PPRQINFO3 pTempPrqInfo = (PPRQINFO3)pQueueData;
            for ( int j = 0; j < nReturned; j++ )
            {
                // Wenn Name doppelt, erweitern wir diesen um die Location
                if ( (j != i) &&
                     (strcmp( pPrqInfo->pszComment, pTempPrqInfo->pszComment ) == 0) )
                {
                    String pszName( ::rtl::OStringToOUString (pPrqInfo->pszName, gsl_getSystemTextEncoding()));
                    aDefaultName += ';';
                    aDefaultName += pszName;
                }
                pTempPrqInfo++;
            }
            break;
        }

        // increment to next element of the QueueInfo array
        pPrqInfo++;
    }

    delete [] pQueueData;

    return aDefaultName;
}

// =======================================================================

static void* ImplAllocPrnMemory( size_t n )
{
    return calloc( n, 1);
}

// -----------------------------------------------------------------------

inline void ImplFreePrnMemory( void* p )
{
    free( p );
}

// -----------------------------------------------------------------------

static PDRIVDATA ImplPrnDrivData( const ImplJobSetup* pSetupData )
{
    // Diese Funktion wird eingesetzt, damit Druckertreiber nicht auf
    // unseren Daten arbeiten, da es durch Konfigurationsprobleme
    // sein kann, das der Druckertreiber bei uns Daten ueberschreibt.
    // Durch diese vorgehensweise werden einige Abstuerze vermieden, bzw.
    // sind dadurch leichter zu finden

    if ( !pSetupData->mpDriverData )
        return NULL;

    DBG_ASSERT( ((PDRIVDATA)(pSetupData->mpDriverData))->cb == pSetupData->mnDriverDataLen,
                "ImplPrnDrivData() - SetupDataLen != DriverDataLen" );

    PDRIVDATA pDrivData = (PDRIVDATA)ImplAllocPrnMemory( pSetupData->mnDriverDataLen );
    memcpy( pDrivData, pSetupData->mpDriverData, pSetupData->mnDriverDataLen );
    return pDrivData;
}

// -----------------------------------------------------------------------

static void ImplUpdateSetupData( const PDRIVDATA pDrivData, ImplJobSetup* pSetupData )
{
    // Diese Funktion wird eingesetzt, damit Druckertreiber nicht auf
    // unseren Daten arbeiten, da es durch Konfigurationsprobleme
    // sein kann, das der Druckertreiber bei uns Daten ueberschreibt.
    // Durch diese vorgehensweise werden einige Abstuerze vermieden, bzw.
    // sind dadurch leichter zu finden

    if ( !pDrivData || !pDrivData->cb )
    {
        if ( pSetupData->mpDriverData )
            rtl_freeMemory( pSetupData->mpDriverData );
        pSetupData->mpDriverData = NULL;
        pSetupData->mnDriverDataLen = 0;
    }
    else
    {
        // Alle Bytes hinter dem DeviceNamen auf 0 initialisieren, damit
        // ein memcmp vom JobSetup auch funktioniert
        if ( pDrivData->cb >= sizeof( pDrivData ) )
        {
            int nDeviceNameLen = strlen( pDrivData->szDeviceName );
            memset( pDrivData->szDeviceName+nDeviceNameLen,
                    0,
                    sizeof( pDrivData->szDeviceName )-nDeviceNameLen );
        }

        if ( pSetupData->mpDriverData )
        {
            if ( pSetupData->mnDriverDataLen != pDrivData->cb )
                rtl_freeMemory( pSetupData->mpDriverData );
            pSetupData->mpDriverData = (BYTE*)rtl_allocateMemory( pDrivData->cb);
        }
        else
            pSetupData->mpDriverData = (BYTE*)rtl_allocateMemory( pDrivData->cb);
        pSetupData->mnDriverDataLen = pDrivData->cb;
        memcpy( pSetupData->mpDriverData, pDrivData, pDrivData->cb );
    }

    if ( pDrivData )
        ImplFreePrnMemory( pDrivData );
}

// -----------------------------------------------------------------------

static BOOL ImplPaperSizeEqual( long nPaperWidth1, long nPaperHeight1,
                                long nPaperWidth2, long nPaperHeight2 )
{
    return (((nPaperWidth1 >= nPaperWidth2-1) && (nPaperWidth1 <= nPaperWidth2+1)) &&
            ((nPaperHeight1 >= nPaperHeight2-1) && (nPaperHeight1 <= nPaperHeight2+1)));
}

// -----------------------------------------------------------------------

static BOOL ImplIsDriverDJPEnabled( HDC hDC )
{
#ifdef NO_DJP
    return FALSE;
#else
    // Ueber OS2-Ini kann DJP disablte werden
    if ( !PrfQueryProfileInt( HINI_PROFILE, SAL_PROFILE_APPNAME, SAL_PROFILE_USEDJP, 1 ) )
        return FALSE;

    // Testen, ob DJP-Interface am Drucker vorhanden
    LONG   lQuery;
    APIRET rc;

    lQuery = DEVESC_QUERYSIZE;
    rc = DevEscape( hDC,
                    DEVESC_QUERYESCSUPPORT,
                    sizeof( lQuery ),
                    (PBYTE)&lQuery,
                    0,
                    (PBYTE)NULL );
    if ( DEV_OK != rc )
        return FALSE;

    lQuery = DEVESC_QUERYJOBPROPERTIES;
    rc = DevEscape( hDC,
                    DEVESC_QUERYESCSUPPORT,
                    sizeof( lQuery ),
                    (PBYTE)&lQuery,
                    0,
                    (PBYTE)NULL );
    if ( DEV_OK != rc )
        return FALSE;

    lQuery = DEVESC_SETJOBPROPERTIES;
    rc = DevEscape( hDC,
                    DEVESC_QUERYESCSUPPORT,
                    sizeof( lQuery ),
                    (PBYTE)&lQuery,
                    0,
                    (PBYTE)NULL );
    if ( DEV_OK != rc )
        return FALSE;

    return TRUE;
#endif
}

// -----------------------------------------------------------------------

static void ImplFormatInputList( PDJP_ITEM pDJP, PQUERYTUPLE pTuple )
{
   // Loop through the query elements
   BOOL fContinue = TRUE;
   do
   {
      pDJP->cb            = sizeof (DJP_ITEM);
      pDJP->ulProperty    = pTuple->ulProperty;
      pDJP->lType         = pTuple->lType;
      pDJP->ulNumReturned = 0;
      pDJP->ulValue       = DJP_NONE;

      // at EOL?
      fContinue = DJP_NONE != pTuple->ulProperty;

      // Move to next item structure and tuplet
      pDJP++;
      pTuple++;
   }
   while ( fContinue );
}

// -----------------------------------------------------------------------

static void ImplFreeFormAndTrayList( Os2SalInfoPrinter* pOs2SalInfoPrinter )
{
    if ( pOs2SalInfoPrinter->mnFormCount )
    {
        for ( USHORT i = 0; i < pOs2SalInfoPrinter->mnFormCount; i++ )
            delete pOs2SalInfoPrinter->mpFormArray[i];
        delete [] pOs2SalInfoPrinter->mpFormArray;
        pOs2SalInfoPrinter->mnFormCount = 0;
    }

    if ( pOs2SalInfoPrinter->mnTrayCount )
    {
        for ( USHORT i = 0; i < pOs2SalInfoPrinter->mnTrayCount; i++ )
            delete pOs2SalInfoPrinter->mpTrayArray[i];
        delete [] pOs2SalInfoPrinter->mpTrayArray;
        pOs2SalInfoPrinter->mnTrayCount = 0;
    }
}

// -----------------------------------------------------------------------

static void ImplGetFormAndTrayList( Os2SalInfoPrinter* pOs2SalInfoPrinter, const ImplJobSetup* pSetupData )
{
    ImplFreeFormAndTrayList( pOs2SalInfoPrinter );

    LONG alQuery[] =
    {
        0,                  0,              // First two members of QUERYSIZE
        DJP_CJ_FORM,        DJP_ALL,
        DJP_CJ_TRAYNAME,    DJP_ALL,
        DJP_NONE,           DJP_NONE        // EOL marker
    };

    APIRET      rc;
    PQUERYSIZE  pQuerySize          = (PQUERYSIZE)alQuery;
    PBYTE       pBuffer             = NULL;
    LONG        nAlloc              = 0;
    PDRIVDATA   pCopyDrivData       = ImplPrnDrivData( pSetupData );
    LONG        nDrivDataSize       = pCopyDrivData->cb;
    PBYTE       pDrivData           = (PBYTE)pCopyDrivData;

    // find out how many bytes to allocate
    pQuerySize->cb = sizeof( alQuery );
    rc = DevEscape( pOs2SalInfoPrinter->mhDC,
                    DEVESC_QUERYSIZE,
                    sizeof( alQuery ),
                    (PBYTE)pQuerySize,
                    &nDrivDataSize,
                    pDrivData );
    if ( DEV_OK != rc )
    {
        ImplFreePrnMemory( pCopyDrivData );
        return;
    }

    // allocate the memory
    nAlloc = pQuerySize->ulSizeNeeded;
    pBuffer = (PBYTE)new BYTE[nAlloc];

    // set up the input
    PDJP_ITEM pDJP = (PDJP_ITEM)pBuffer;
    ImplFormatInputList( pDJP, pQuerySize->aTuples );

    // do it!
    rc = DevEscape( pOs2SalInfoPrinter->mhDC,
                    DEVESC_QUERYJOBPROPERTIES,
                    nAlloc,
                    pBuffer,
                    &nDrivDataSize,
                    pDrivData );
    ImplFreePrnMemory( pCopyDrivData );

    if ( (DEV_OK == rc) || (DEV_WARNING == rc) )
    {
        // Loop through the query elements
        PQUERYTUPLE pTuple = pQuerySize->aTuples;
        while ( DJP_NONE != pTuple->ulProperty )
        {
            if ( pDJP->ulProperty == DJP_CJ_FORM )
            {
                if ( pDJP->ulNumReturned )
                {
                    PDJPT_FORM pElm = DJP_ELEMENTP( *pDJP, DJPT_FORM );

                    pOs2SalInfoPrinter->mnFormCount = pDJP->ulNumReturned;
                    pOs2SalInfoPrinter->mpFormArray = new PIMPLFORMINFO[pOs2SalInfoPrinter->mnFormCount];
                    for( int i = 0; i < pDJP->ulNumReturned; i++, pElm++ )
                    {
                        ImplFormInfo* pInfo     = new ImplFormInfo;
                        pInfo->mnPaperWidth     = pElm->hcInfo.cx;
                        pInfo->mnPaperHeight    = pElm->hcInfo.cy;
                        pInfo->mnId             = pElm->djppsFormID;
                        pOs2SalInfoPrinter->mpFormArray[i] = pInfo;
                    }
                }
            }
            else if ( pDJP->ulProperty == DJP_CJ_TRAYNAME )
            {
                if ( pDJP->ulNumReturned )
                {
                    PDJPT_TRAYNAME pElm = DJP_ELEMENTP( *pDJP, DJPT_TRAYNAME );

                    pOs2SalInfoPrinter->mnTrayCount = pDJP->ulNumReturned;
                    pOs2SalInfoPrinter->mpTrayArray = new PIMPLTRAYINFO[pOs2SalInfoPrinter->mnTrayCount];
                    for( int i = 0; i < pDJP->ulNumReturned; i++, pElm++ )
                    {
                        ImplTrayInfo* pInfo     = new ImplTrayInfo( pElm->szTrayname, pElm->szDisplayTrayname );
                        pInfo->mnId             = pElm->djpttTrayID;
                        pOs2SalInfoPrinter->mpTrayArray[i] = pInfo;
                    }
                }
            }

            pDJP = DJP_NEXT_STRUCTP( pDJP );
            pTuple++;
        }
    }

    delete [] pBuffer;
}

// -----------------------------------------------------------------------

static BOOL ImplGetCurrentSettings( Os2SalInfoPrinter* pOs2SalInfoPrinter, ImplJobSetup* pSetupData )
{
    // Um den aktuellen Tray zu ermitteln, brauchen wir auch die Listen dazu
    if ( !pOs2SalInfoPrinter->mnFormCount )
        ImplGetFormAndTrayList( pOs2SalInfoPrinter, pSetupData );

    LONG alQuery[] =
    {
        0,                      0,              // First two members of QUERYSIZE
        DJP_SJ_ORIENTATION,     DJP_CURRENT,
        DJP_CJ_FORM,            DJP_CURRENT,
        DJP_NONE,               DJP_NONE        // EOL marker
    };

    APIRET      rc;
    PQUERYSIZE  pQuerySize          = (PQUERYSIZE)alQuery;
    PBYTE       pBuffer             = NULL;
    LONG        nAlloc              = 0;
    PDRIVDATA   pCopyDrivData       = ImplPrnDrivData( pSetupData );
    LONG        nDrivDataSize       = pCopyDrivData->cb;
    PBYTE       pDrivData           = (PBYTE)pCopyDrivData;
    BOOL        bResult;

    // find out how many bytes to allocate
    pQuerySize->cb = sizeof( alQuery );
    rc = DevEscape( pOs2SalInfoPrinter->mhDC,
                    DEVESC_QUERYSIZE,
                    sizeof( alQuery ),
                    (PBYTE)pQuerySize,
                    &nDrivDataSize,
                    pDrivData );
    if ( DEV_OK != rc )
    {
        ImplFreePrnMemory( pCopyDrivData );
        return FALSE;
    }

    // allocate the memory
    nAlloc = pQuerySize->ulSizeNeeded;
    pBuffer = (PBYTE)new BYTE[nAlloc];

    // set up the input
    PDJP_ITEM pDJP = (PDJP_ITEM)pBuffer;
    ImplFormatInputList( pDJP, pQuerySize->aTuples );

    rc = DevEscape( pOs2SalInfoPrinter->mhDC,
                    DEVESC_QUERYJOBPROPERTIES,
                    nAlloc,
                    pBuffer,
                    &nDrivDataSize,
                    pDrivData );
    if ( (DEV_OK == rc) || (DEV_WARNING == rc) )
    {
        // aktuelle Setup-Daten uebernehmen
        ImplUpdateSetupData( pCopyDrivData, pSetupData );

        // Loop through the query elements
        PQUERYTUPLE pTuple = pQuerySize->aTuples;
        while ( DJP_NONE != pTuple->ulProperty )
        {
            if ( pDJP->ulProperty == DJP_SJ_ORIENTATION )
            {
                if ( pDJP->ulNumReturned )
                {
                    PDJPT_ORIENTATION pElm = DJP_ELEMENTP( *pDJP, DJPT_ORIENTATION );
                    if ( (DJP_ORI_PORTRAIT == *pElm) || (DJP_ORI_REV_PORTRAIT == *pElm) )
                        pSetupData->meOrientation = ORIENTATION_PORTRAIT;
                    else
                        pSetupData->meOrientation = ORIENTATION_LANDSCAPE;
                }
            }
            else if ( pDJP->ulProperty == DJP_CJ_FORM )
            {
                if ( pDJP->ulNumReturned )
                {
                    PDJPT_FORM pElm = DJP_ELEMENTP( *pDJP, DJPT_FORM );

                    pSetupData->mnPaperWidth  = pElm->hcInfo.cx*100;
                    pSetupData->mnPaperHeight = pElm->hcInfo.cy*100;
                    switch( pElm->djppsFormID )
                    {
                        case DJP_PSI_A3:
                            pSetupData->mePaperFormat = PAPER_A3;
                            break;

                        case DJP_PSI_A4:
                            pSetupData->mePaperFormat = PAPER_A4;
                            break;

                        case DJP_PSI_A5:
                            pSetupData->mePaperFormat = PAPER_A5;
                            break;

                        case DJP_PSI_B4:
                            pSetupData->mePaperFormat = PAPER_B4;
                            break;

                        case DJP_PSI_B5:
                            pSetupData->mePaperFormat = PAPER_B5;
                            break;

                        case DJP_PSI_LETTER:
                            pSetupData->mePaperFormat = PAPER_LETTER;
                            break;

                        case DJP_PSI_LEGAL:
                            pSetupData->mePaperFormat = PAPER_LEGAL;
                            break;

                        case DJP_PSI_TABLOID:
                            pSetupData->mePaperFormat = PAPER_TABLOID;
                            break;

                        default:
                            pSetupData->mePaperFormat = PAPER_USER;
                            break;
                    }

                    // Wir suchen zuerst ueber den Namen/Id und dann ueber die Id
                    BOOL    bTrayFound = FALSE;
                    USHORT  j;
                    for ( j = 0; j < pOs2SalInfoPrinter->mnTrayCount; j++ )
                    {
                        if ( (pOs2SalInfoPrinter->mpTrayArray[j]->mnId == pElm->djpttTrayID) &&
                             (pOs2SalInfoPrinter->mpTrayArray[j]->maName == pElm->szTrayname) )
                        {
                            pSetupData->mnPaperBin = j;
                            bTrayFound = TRUE;
                            break;
                        }
                    }
                    if ( !bTrayFound )
                    {
                        for ( j = 0; j < pOs2SalInfoPrinter->mnTrayCount; j++ )
                        {
                            if ( pOs2SalInfoPrinter->mpTrayArray[j]->mnId == pElm->djpttTrayID )
                            {
                                pSetupData->mnPaperBin = j;
                                bTrayFound = TRUE;
                                break;
                            }
                        }
                    }
                    // Wenn wir Ihn immer noch nicht gefunden haben, setzen
                    // wir ihn auf DontKnow
                    if ( !bTrayFound )
                        pSetupData->mnPaperBin = 0xFFFF;
                }
            }

            pDJP = DJP_NEXT_STRUCTP( pDJP );
            pTuple++;
        }

        bResult = TRUE;
    }
    else
    {
        ImplFreePrnMemory( pCopyDrivData );
        bResult = FALSE;
    }

    delete [] pBuffer;

    return bResult;
}

// -----------------------------------------------------------------------

static BOOL ImplSetOrientation( HDC hPrinterDC, PDRIVDATA pDriverData,
                                Orientation eOrientation )
{
    LONG alQuery[] =
    {
        0,                      0,              // First two members of QUERYSIZE
        DJP_SJ_ORIENTATION,     DJP_CURRENT,
        DJP_NONE,               DJP_NONE        // EOL marker
    };

    APIRET      rc;
    PQUERYSIZE  pQuerySize      = (PQUERYSIZE)alQuery;
    PBYTE       pBuffer         = NULL;
    LONG        nAlloc          = 0;
    LONG        nDrivDataSize   = pDriverData->cb;

    // find out how many bytes to allocate
    pQuerySize->cb = sizeof( alQuery );
    rc = DevEscape( hPrinterDC,
                    DEVESC_QUERYSIZE,
                    sizeof( alQuery ),
                    (PBYTE)pQuerySize,
                    &nDrivDataSize,
                    (PBYTE)pDriverData );
    if ( DEV_OK != rc )
        return FALSE;

    // allocate the memory
    nAlloc = pQuerySize->ulSizeNeeded;
    pBuffer = (PBYTE)new BYTE[nAlloc];

    // set up the input
    PDJP_ITEM pDJP = (PDJP_ITEM)pBuffer;
    ImplFormatInputList( pDJP, pQuerySize->aTuples );

    pDJP->cb         = sizeof( DJP_ITEM );
    pDJP->ulProperty = DJP_SJ_ORIENTATION;
    pDJP->lType      = DJP_CURRENT;
    pDJP->ulValue    = (eOrientation == ORIENTATION_PORTRAIT)
                           ? DJP_ORI_PORTRAIT
                           : DJP_ORI_LANDSCAPE;

    // do it!
    rc = DevEscape( hPrinterDC,
                    DEVESC_SETJOBPROPERTIES,
                    nAlloc,
                    pBuffer,
                    &nDrivDataSize,
                    (PBYTE)pDriverData );

    delete [] pBuffer;

    return ((DEV_OK == rc) || (DEV_WARNING == rc));
}

// -----------------------------------------------------------------------

static BOOL ImplSetPaperSize( HDC hPrinterDC, PDRIVDATA pDriverData,
                              DJPT_PAPERSIZE nOS2PaperFormat )
{
    LONG alQuery[] =
    {
        0,                      0,              // First two members of QUERYSIZE
        DJP_SJ_PAPERSIZE,       DJP_CURRENT,
        DJP_NONE,               DJP_NONE        // EOL marker
    };

    APIRET      rc;
    PQUERYSIZE  pQuerySize      = (PQUERYSIZE)alQuery;
    PBYTE       pBuffer         = NULL;
    LONG        nAlloc          = 0;
    LONG        nDrivDataSize   = pDriverData->cb;

    // find out how many bytes to allocate
    pQuerySize->cb = sizeof( alQuery );
    rc = DevEscape( hPrinterDC,
                    DEVESC_QUERYSIZE,
                    sizeof( alQuery ),
                    (PBYTE)pQuerySize,
                    &nDrivDataSize,
                    (PBYTE)pDriverData );
    if ( DEV_OK != rc )
        return FALSE;

    // allocate the memory
    nAlloc = pQuerySize->ulSizeNeeded;
    pBuffer = (PBYTE)new BYTE[nAlloc];

    // set up the input
    PDJP_ITEM pDJP = (PDJP_ITEM)pBuffer;
    PDJP_ITEM pStartDJP = pDJP;
    ImplFormatInputList( pDJP, pQuerySize->aTuples );

    // Neue Daten zuweisen
    pDJP->cb         = sizeof( DJP_ITEM );
    pDJP->ulProperty = DJP_SJ_PAPERSIZE;
    pDJP->lType      = DJP_CURRENT;
    pDJP->ulValue    = nOS2PaperFormat;

    // und setzen
    rc = DevEscape( hPrinterDC,
                    DEVESC_SETJOBPROPERTIES,
                    nAlloc,
                    pBuffer,
                    &nDrivDataSize,
                    (PBYTE)pDriverData );

    delete [] pBuffer;

    return ((DEV_OK == rc) || (DEV_WARNING == rc));
}

// -----------------------------------------------------------------------

static BOOL ImplSetPaperBin( HDC hPrinterDC, PDRIVDATA pDriverData,
                             ImplTrayInfo* pTrayInfo )
{
    LONG alQuery[] =
    {
        0,                      0,              // First two members of QUERYSIZE
        DJP_SJ_TRAYTYPE,        DJP_CURRENT,
        DJP_NONE,               DJP_NONE        // EOL marker
    };

    APIRET      rc;
    PQUERYSIZE  pQuerySize      = (PQUERYSIZE)alQuery;
    PBYTE       pBuffer         = NULL;
    LONG        nAlloc          = 0;
    LONG        nDrivDataSize   = pDriverData->cb;

    // find out how many bytes to allocate
    pQuerySize->cb = sizeof( alQuery );
    rc = DevEscape( hPrinterDC,
                    DEVESC_QUERYSIZE,
                    sizeof( alQuery ),
                    (PBYTE)pQuerySize,
                    &nDrivDataSize,
                    (PBYTE)pDriverData );
    if ( DEV_OK != rc )
        return FALSE;

    // allocate the memory
    nAlloc = pQuerySize->ulSizeNeeded;
    pBuffer = (PBYTE)new BYTE[nAlloc];

    // set up the input
    PDJP_ITEM pDJP = (PDJP_ITEM)pBuffer;
    ImplFormatInputList( pDJP, pQuerySize->aTuples );

    // Neue Daten zuweisen
    pDJP->cb         = sizeof( DJP_ITEM );
    pDJP->ulProperty = DJP_SJ_TRAYTYPE;
    pDJP->lType      = DJP_CURRENT;
    pDJP->ulValue    = pTrayInfo->mnId;

    // und setzen
    rc = DevEscape( hPrinterDC,
                    DEVESC_SETJOBPROPERTIES,
                    nAlloc,
                    pBuffer,
                    &nDrivDataSize,
                    (PBYTE)pDriverData );

    delete [] pBuffer;

    return ((DEV_OK == rc) || (DEV_WARNING == rc));
}

// =======================================================================

static BOOL ImplSalCreateInfoPrn( Os2SalInfoPrinter* pPrinter, PDRIVDATA pDriverData,
                                  HDC& rDC, HPS& rPS )
{
    SalData* pSalData = GetSalData();

    // create info context
    DEVOPENSTRUC  devOpenStruc;
    memset( &devOpenStruc, 0, sizeof( devOpenStruc ) );
    devOpenStruc.pszLogAddress      = (char*)pPrinter->maName.GetBuffer();
    devOpenStruc.pszDriverName      = (char*)pPrinter->maDriverName.GetBuffer();
    devOpenStruc.pdriv              = pDriverData;
    devOpenStruc.pszDataType        = "PM_Q_STD";

    HDC hDC = DevOpenDC( pSalData->mhAB, OD_INFO, "*",
                         4, (PDEVOPENDATA)&devOpenStruc, (HDC)NULL);
    if ( !hDC )
        return FALSE;

    // create presentation space
    SIZEL sizel;
    sizel.cx = 0;
    sizel.cy = 0;
    HPS hPS = Ft2CreatePS( pSalData->mhAB, hDC, &sizel, GPIA_ASSOC | GPIT_MICRO | PU_PELS );
    if ( !hPS )
    {
        DevCloseDC( hDC );
        return FALSE;
    }

    rDC = hDC;
    rPS = hPS;
    return TRUE;
}

// -----------------------------------------------------------------------

static void ImplSalDestroyInfoPrn( Os2SalInfoPrinter* pPrinter )
{
    ImplSalDeInitGraphics( pPrinter->mpGraphics);
    Ft2Associate( pPrinter->mhPS, 0 );
    Ft2DestroyPS( pPrinter->mhPS );
    DevCloseDC( pPrinter->mhDC );
}

// =======================================================================

SalInfoPrinter* Os2SalInstance::CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo,
                                                ImplJobSetup* pSetupData )
{
    ImplQueueSalSysData* pSysQueueData = (ImplQueueSalSysData*)(pQueueInfo->mpSysData);
    Os2SalInfoPrinter* pPrinter = new Os2SalInfoPrinter;
    pPrinter->maPrinterName = pSysQueueData->maPrinterName;
    pPrinter->maName            = pSysQueueData->maName;
    pPrinter->maDriverName  = pSysQueueData->maDriverName;
    pPrinter->maDeviceName  = pSysQueueData->maDeviceName;

    // Nur Setup-Daten uebernehmen, wenn Treiber und Laenge der Treiberdaten
    // uebereinstimmt
    PDRIVDATA   pDriverData;
    BOOL        bUpdateDriverData;
    if ( pSetupData->mpDriverData && pSysQueueData->mpDrivData &&
         (pSetupData->mnSystem == JOBSETUP_SYSTEM_OS2) &&
         (pSetupData->mnDriverDataLen == pSysQueueData->mpDrivData->cb) &&
         (strcmp( ((PDRIVDATA)pSetupData->mpDriverData)->szDeviceName,
                  pSysQueueData->mpDrivData->szDeviceName ) == 0) )
    {
        pDriverData = PDRIVDATA( pSetupData->mpDriverData );
        bUpdateDriverData = FALSE;
    }
    else
    {
        pDriverData = pSysQueueData->mpDrivData;
        bUpdateDriverData = TRUE;
    }
    if ( pDriverData )
        pPrinter->maJobSetupDeviceName = pDriverData->szDeviceName;

    if ( !ImplSalCreateInfoPrn( pPrinter, pDriverData,
                                pPrinter->mhDC,
                                pPrinter->mhPS ) )
    {
        delete pPrinter;
        return NULL;
    }

    // create graphics object for output
    Os2SalGraphics* pGraphics = new Os2SalGraphics;
    pGraphics->mhDC             = pPrinter->mhDC;
    pGraphics->mhPS             = pPrinter->mhPS;
    pGraphics->mhWnd            = 0;
    pGraphics->mbPrinter        = TRUE;
    pGraphics->mbVirDev         = FALSE;
    pGraphics->mbWindow         = FALSE;
    pGraphics->mbScreen         = FALSE;

    ImplSalInitGraphics( pGraphics );
    pPrinter->mpGraphics            = pGraphics;

    // check printer driver for DJP support
    pPrinter->mbDJPSupported = ImplIsDriverDJPEnabled( pPrinter->mhDC );

    if ( bUpdateDriverData )
    {
        if ( pSetupData->mpDriverData )
            rtl_freeMemory( pSetupData->mpDriverData);
        pSetupData->mpDriverData = (BYTE*)rtl_allocateMemory( pDriverData->cb);
        memcpy( pSetupData->mpDriverData, pDriverData, pDriverData->cb );
        pSetupData->mnDriverDataLen = pDriverData->cb;
    }

    // retrieve current settings from printer driver and store them to system independend data!
    if ( pPrinter->mbDJPSupported )
        ImplGetCurrentSettings( pPrinter, pSetupData );
    pSetupData->mnSystem = JOBSETUP_SYSTEM_OS2;

    return pPrinter;
}

// -----------------------------------------------------------------------

void Os2SalInstance::DestroyInfoPrinter( SalInfoPrinter* pPrinter )
{
    delete pPrinter;
}

// =======================================================================

Os2SalInfoPrinter::Os2SalInfoPrinter()
{
    mhDC                    = 0;
    mhPS                    = 0;
    mpGraphics          = NULL;
    mbGraphics          = FALSE;
    mbDJPSupported      = FALSE;
    mnFormCount         = 0;
    mpFormArray         = NULL;
    mnTrayCount         = 0;
    mpTrayArray         = NULL;
}

// -----------------------------------------------------------------------

Os2SalInfoPrinter::~Os2SalInfoPrinter()
{
    if ( mpGraphics )
    {
        ImplSalDestroyInfoPrn( this );
        delete mpGraphics;
    }

    ImplFreeFormAndTrayList( this );
}

// -----------------------------------------------------------------------

SalGraphics* Os2SalInfoPrinter::GetGraphics()
{
    if ( mbGraphics )
        return NULL;

    if ( mpGraphics )
        mbGraphics = TRUE;

    return mpGraphics;
}

// -----------------------------------------------------------------------

void Os2SalInfoPrinter::ReleaseGraphics( SalGraphics* )
{
    mbGraphics = FALSE;
}

// -----------------------------------------------------------------------

BOOL Os2SalInfoPrinter::Setup( SalFrame* pFrame, ImplJobSetup* pSetupData )
{
    PDRIVDATA pDrivData = ImplPrnDrivData( pSetupData );
    if ( !pDrivData )
        return FALSE;

    APIRET rc = DevPostDeviceModes( GetSalData()->mhAB, pDrivData,
                                    maDriverName.GetBuffer(),
                                    maDeviceName.GetBuffer(),
                                    maPrinterName.GetBuffer(),
                                    DPDM_POSTJOBPROP );
    if ( rc == DEV_OK )
    {
        ImplUpdateSetupData( pDrivData, pSetupData );

        // update DC and PS
        HDC hDC;
        HPS hPS;
        if ( !ImplSalCreateInfoPrn( this, (PDRIVDATA)(pSetupData->mpDriverData), hDC, hPS ) )
            return FALSE;

        // Alten Printer DC/PS zerstoeren
        ImplSalDestroyInfoPrn( this );

        // Neue Daten setzen und initialisieren
        mhDC = hDC;
        mhPS = hPS;
        mpGraphics->mhDC = mhDC;
        mpGraphics->mhPS = mhPS;
        ImplSalInitGraphics( mpGraphics );

        // retrieve current settings from printer driver and store them to system independend data!
        ImplFreeFormAndTrayList( this );
        if ( mbDJPSupported )
            ImplGetCurrentSettings( this, pSetupData );

        return TRUE;
    }
    else
    {
        ImplFreePrnMemory( pDrivData );
        return FALSE;
    }
}

// -----------------------------------------------------------------------

BOOL Os2SalInfoPrinter::SetPrinterData( ImplJobSetup* pSetupData )
{
    // Wir koennen nur Treiberdaten von OS2 setzen
    if ( pSetupData->mnSystem != JOBSETUP_SYSTEM_OS2 )
        return FALSE;

    PDRIVDATA pNewDrivData = (PDRIVDATA)(pSetupData->mpDriverData);
    if ( !pNewDrivData )
        return FALSE;

    // Testen, ob Printerdaten fuer den gleichen Printer uebergeben werden,
    // da einige Treiber zu Abstuerzen neigen, wenn Daten von einem anderen
    // Printer gesetzt werden
    if ( !maJobSetupDeviceName.Equals( pNewDrivData->szDeviceName ))
        return FALSE;

    // update DC and PS
    HDC hDC;
    HPS hPS;
    if ( !ImplSalCreateInfoPrn( this, pNewDrivData, hDC, hPS ) )
        return FALSE;

    // Alten Printer DC/PS zerstoeren
    ImplSalDestroyInfoPrn( this );

    // Neue Daten setzen und initialisieren
    mhDC = hDC;
    mhPS = hPS;
    mpGraphics->mhDC = mhDC;
    mpGraphics->mhPS = mhPS;
    ImplSalInitGraphics( mpGraphics );

    // retrieve current settings from printer driver and store them to system independend data!
    ImplFreeFormAndTrayList( this );
    if ( mbDJPSupported )
        ImplGetCurrentSettings( this, pSetupData );

    return TRUE;
}

// -----------------------------------------------------------------------

BOOL Os2SalInfoPrinter::SetData( ULONG nFlags, ImplJobSetup* pSetupData )
{
    // needs DJP support
    if ( !mbDJPSupported )
        return FALSE;

    PDRIVDATA pDrivData = ImplPrnDrivData( pSetupData );

    if ( !pDrivData )
        return FALSE;

    BOOL bOK = FALSE;

    // set orientation
    if ( nFlags & SAL_JOBSET_ORIENTATION )
    {
        if ( ImplSetOrientation( mhDC, pDrivData, pSetupData->meOrientation ) )
            bOK = TRUE;
    }

    // set paper size
    if ( nFlags & SAL_JOBSET_PAPERSIZE )
    {
        // Papierformat ermitteln
        DJPT_PAPERSIZE nOS2PaperFormat;
        switch ( pSetupData->mePaperFormat )
        {
            case PAPER_A3:
                nOS2PaperFormat = DJP_PSI_A3;
                break;

            case PAPER_A4:
                nOS2PaperFormat = DJP_PSI_A4;
                break;

            case PAPER_A5:
                nOS2PaperFormat = DJP_PSI_A5;
                break;

            case PAPER_B4:
                nOS2PaperFormat = DJP_PSI_B4;
                break;

            case PAPER_B5:
                nOS2PaperFormat = DJP_PSI_B5;
                break;

            case PAPER_LETTER:
                nOS2PaperFormat = DJP_PSI_LETTER;
                break;

            case PAPER_LEGAL:
                nOS2PaperFormat = DJP_PSI_LEGAL;
                break;

            case PAPER_TABLOID:
                nOS2PaperFormat = DJP_PSI_TABLOID;
                break;

            default:
                {
                nOS2PaperFormat = DJP_PSI_NONE;
                // OS2 rechnet in Millimetern
                long nPaperWidth     = pSetupData->mnPaperWidth  / 100;
                long nPaperHeight    = pSetupData->mnPaperHeight / 100;
                // Ansonsten ueber die Papiergroesse suchen
                for( int i = 0; i < mnFormCount; i++ )
                {
                    ImplFormInfo* pFormInfo = mpFormArray[i];
                    if ( ImplPaperSizeEqual( nPaperWidth, nPaperHeight,
                                             pFormInfo->mnPaperWidth, pFormInfo->mnPaperHeight ) )
                    {
                        nOS2PaperFormat = pFormInfo->mnId;
                        break;
                    }
                }
                }
                break;
        }

        if ( nOS2PaperFormat != DJP_PSI_NONE )
        {
            if ( ImplSetPaperSize( mhDC, pDrivData, nOS2PaperFormat ) )
                bOK = TRUE;
        }
    }

    // set paper tray
    if ( (nFlags & SAL_JOBSET_PAPERBIN) && (pSetupData->mnPaperBin < mnTrayCount) )
    {
        if ( ImplSetPaperBin( mhDC, pDrivData,
                              mpTrayArray[pSetupData->mnPaperBin] ) )
            bOK = TRUE;
    }

    if ( bOK )
    {
        ImplUpdateSetupData( pDrivData, pSetupData );

        // query current driver settings
        ImplFreeFormAndTrayList( this );
        if ( ImplGetCurrentSettings( this, pSetupData ) )
        {
            // update DC and PS
            HDC hDC;
            HPS hPS;
            if ( ImplSalCreateInfoPrn( this, (PDRIVDATA)(pSetupData->mpDriverData), hDC, hPS ) )
            {
                // Alten Printer DC/PS zerstoeren
                ImplSalDestroyInfoPrn( this );

                // Neue Daten setzen und initialisieren
                mhDC = hDC;
                mhPS = hPS;
                mpGraphics->mhDC = mhDC;
                mpGraphics->mhPS = mhPS;
                ImplSalInitGraphics( mpGraphics );
            }
            else
                bOK = FALSE;
        }
        else
            bOK = FALSE;
    }

    return bOK;
}

// -----------------------------------------------------------------------

ULONG Os2SalInfoPrinter::GetPaperBinCount( const ImplJobSetup* pJobSetup )
{
    if ( !mbDJPSupported )
        return 1;

    // init paperbinlist if empty
    if ( !mnTrayCount )
        ImplGetFormAndTrayList( this, pJobSetup );

    // Wir haben immer einen PaperTray und wenn, das eben einen ohne
    // Namen
    if ( !mnTrayCount )
        return 1;
    else
        return mnTrayCount;
}

// -----------------------------------------------------------------------

XubString Os2SalInfoPrinter::GetPaperBinName( const ImplJobSetup* pJobSetup,
                                          ULONG nPaperBin )
{
    XubString aPaperBinName;

    if ( mbDJPSupported )
    {
        // init paperbinlist if empty
        if ( !mnTrayCount )
            ImplGetFormAndTrayList( this, pJobSetup );

        if ( nPaperBin < mnTrayCount )
            aPaperBinName = ::rtl::OStringToOUString (mpTrayArray[nPaperBin]->maDisplayName, gsl_getSystemTextEncoding());
    }

    return aPaperBinName;
}

// -----------------------------------------------------------------------

ULONG Os2SalInfoPrinter::GetCapabilities( const ImplJobSetup*, USHORT nType )
{
    switch ( nType )
    {
        case PRINTER_CAPABILITIES_SUPPORTDIALOG:
            return TRUE;
        case PRINTER_CAPABILITIES_COPIES:
            return 0xFFFF;
        case PRINTER_CAPABILITIES_COLLATECOPIES:
            return 0;
        case PRINTER_CAPABILITIES_SETORIENTATION:
        case PRINTER_CAPABILITIES_SETPAPERBIN:
        case PRINTER_CAPABILITIES_SETPAPERSIZE:
        case PRINTER_CAPABILITIES_SETPAPER:
            return mbDJPSupported;
    }

    return 0;
}

// -----------------------------------------------------------------------

void Os2SalInfoPrinter::GetPageInfo( const ImplJobSetup*,
                                  long& rOutWidth, long& rOutHeight,
                                  long& rPageOffX, long& rPageOffY,
                                  long& rPageWidth, long& rPageHeight )
{
    HDC hDC = mhDC;

    // search current form
    HCINFO  aInfo;
    int nForms = DevQueryHardcopyCaps( hDC, 0, 0, &aInfo );
    for( int i = 0; i < nForms; i++ )
    {
        if ( DevQueryHardcopyCaps( hDC, i, 1, &aInfo ) >= 0 )
        {
            if ( aInfo.flAttributes & HCAPS_CURRENT )
            {
                // query resolution
                long nXResolution;
                long nYResolution;
                DevQueryCaps( hDC, CAPS_HORIZONTAL_RESOLUTION, 1, &nXResolution );
                DevQueryCaps( hDC, CAPS_VERTICAL_RESOLUTION, 1, &nYResolution );
                rPageOffX   = aInfo.xLeftClip * nXResolution / 1000;
                rPageOffY   = (aInfo.cy-aInfo.yTopClip) * nYResolution / 1000;
                rPageWidth  = aInfo.cx * nXResolution / 1000;
                rPageHeight = aInfo.cy * nYResolution / 1000;
                rOutWidth   = aInfo.xPels;
                rOutHeight  = aInfo.yPels;
                return;
            }
        }
    }

    // use device caps if no form selected/found
    long lCapsWidth = 0;
    long lCapsHeight = 0;
    DevQueryCaps( hDC, CAPS_WIDTH, 1L, &lCapsWidth );
    DevQueryCaps( hDC, CAPS_HEIGHT, 1L, &lCapsHeight );
    rPageOffX    = 0;
    rPageOffY    = 0;
    rOutWidth    = lCapsWidth;
    rOutHeight   = lCapsHeight;
    rPageWidth   = rOutWidth;
    rPageHeight  = rOutHeight;
}

// =======================================================================

static BOOL ImplIsDriverPrintDJPEnabled( HDC hDC )
{
#ifdef NO_DJP
    return FALSE;
#else
    // Ueber OS2-Ini kann DJP disablte werden
    if ( !PrfQueryProfileInt( HINI_PROFILE, SAL_PROFILE_APPNAME, SAL_PROFILE_PRINTDJP, 1 ) )
        return FALSE;

    // Testen, ob DJP-Interface am Drucker vorhanden
    LONG   lQuery;
    APIRET rc;

    lQuery = DEVESC_QUERYSIZE;
    rc = DevEscape( hDC,
                    DEVESC_QUERYESCSUPPORT,
                    sizeof( lQuery ),
                    (PBYTE)&lQuery,
                    0,
                    (PBYTE)NULL );
    if ( DEV_OK != rc )
        return FALSE;

    return TRUE;
#endif
}

// =======================================================================

SalPrinter* Os2SalInstance::CreatePrinter( SalInfoPrinter* pInfoPrinter )
{
    Os2SalPrinter* pPrinter = new Os2SalPrinter;
    pPrinter->mpInfoPrinter = static_cast<Os2SalInfoPrinter*>(pInfoPrinter);
    return pPrinter;
}

// -----------------------------------------------------------------------

void Os2SalInstance::DestroyPrinter( SalPrinter* pPrinter )
{
    delete pPrinter;
}

// =======================================================================

Os2SalPrinter::Os2SalPrinter()
{
    mhDC                    = 0;
    mhPS                    = 0;
    mpGraphics          = NULL;
    mbAbort             = FALSE;
    mbPrintDJPSupported = FALSE;
}

// -----------------------------------------------------------------------

Os2SalPrinter::~Os2SalPrinter()
{
}

// -----------------------------------------------------------------------

BOOL Os2SalPrinter::StartJob( const XubString* pFileName,
                           const XubString& rJobName,
                           const XubString& rAppName,
                           ULONG nCopies,
                           bool bCollate,
                           bool bDirect,
                           ImplJobSetup* pSetupData )
{
    DEVOPENSTRUC    aDevOpenStruc;
    LONG            lType;
    APIRET          rc;

    // prepare queue information
    memset( &aDevOpenStruc, 0, sizeof( aDevOpenStruc ) );
    aDevOpenStruc.pszDriverName = (PSZ)(mpInfoPrinter->maDriverName.GetBuffer());

    // print into file?
    if ( pFileName )
    {
        aDevOpenStruc.pszLogAddress = (PSZ)pFileName->GetBuffer();
        aDevOpenStruc.pszDataType = "PM_Q_RAW";
        lType = OD_DIRECT;
    }
    else
    {
        aDevOpenStruc.pszLogAddress = (PSZ)(mpInfoPrinter->maName.GetBuffer());
        if ( PrfQueryProfileInt( HINI_PROFILE, SAL_PROFILE_APPNAME, SAL_PROFILE_PRINTRAW, 0 ) )
            aDevOpenStruc.pszDataType = "PM_Q_RAW";
        else
            aDevOpenStruc.pszDataType = "PM_Q_STD";
        lType = OD_QUEUED;
    }

#if 0 // YD FIXME
    // Set comment (AppName nur bis zum 1. Space-Zeichen nehmen)
    const xub_Unicode*  pComment = rAppName;
    USHORT          nCommentLen = 0;
    memset( maCommentBuf, 0, sizeof( maCommentBuf ) );
    while ( (nCommentLen < 32) &&
            (((*pComment >= 'a') && (*pComment <= 'z')) ||
             ((*pComment >= 'A') && (*pComment <= 'Z')) ||
             ((*pComment >= '0') && (*pComment <= '9')) ||
             (*pComment == '-')))
    {
        maCommentBuf[nCommentLen] = (char)(*pComment);
        nCommentLen++;
        pComment++;
    }
    aDevOpenStruc.pszComment = (PSZ)maCommentBuf;
#endif
    ByteString jobName( rJobName, gsl_getSystemTextEncoding());
    aDevOpenStruc.pszComment = (PSZ)jobName.GetBuffer();

    // Kopien
    if ( nCopies > 1 )
    {
        // OS2 kann maximal 999 Kopien
        if ( nCopies > 999 )
            nCopies = 999;
        sprintf( maCopyBuf, "COP=%d", nCopies);
        aDevOpenStruc.pszQueueProcParams = (PSZ)maCopyBuf;
    }

    // open device context
    SalData*    pSalData = GetSalData();
    HAB         hAB = pSalData->mhAB;
    aDevOpenStruc.pdriv = (PDRIVDATA)pSetupData->mpDriverData;
    mhDC = DevOpenDC( hAB,
                                    lType,
                                    "*",
                                    7,
                                    (PDEVOPENDATA)&aDevOpenStruc,
                                    0 );
    if ( mhDC == 0 )
    {
        ERRORID nLastError = WinGetLastError( hAB );
        if ( (nLastError & 0xFFFF) == PMERR_SPL_PRINT_ABORT )
            mnError = SAL_PRINTER_ERROR_ABORT;
        else
            mnError = SAL_PRINTER_ERROR_GENERALERROR;
        return FALSE;
    }

    // open presentation space
    SIZEL sizel;
    sizel.cx = 0;
    sizel.cy = 0;
    mhPS = Ft2CreatePS( hAB, mhDC, &sizel, GPIA_ASSOC | GPIT_MICRO | PU_PELS );
    if ( !mhPS )
    {
        DevCloseDC( mhDC );
        mnError = SAL_PRINTER_ERROR_GENERALERROR;
        return NULL;
    }

    // Can we print with DJP
    mbPrintDJPSupported = ImplIsDriverPrintDJPEnabled( mhDC );

    // JobName ermitteln und Job starten
    PSZ pszJobName = NULL;
    int nJobNameLen = 0;
    if ( jobName.Len() > 0 )
    {
        pszJobName = (PSZ)jobName.GetBuffer();
        nJobNameLen = jobName.Len();
    }
    rc = DevEscape( mhDC,
                    DEVESC_STARTDOC,
                    nJobNameLen, (PBYTE)pszJobName,
                    0, (PBYTE)NULL );

    if ( rc != DEV_OK )
    {
        ERRORID nLastError = WinGetLastError( hAB );
        if ( (nLastError & 0xFFFF) == PMERR_SPL_PRINT_ABORT )
            mnError = SAL_PRINTER_ERROR_ABORT;
        else
            mnError = SAL_PRINTER_ERROR_GENERALERROR;
        Ft2Associate( mhPS, NULL );
        Ft2DestroyPS( mhPS );
        DevCloseDC( mhDC );
        return FALSE;
    }

    // init for first page
    mbFirstPage = TRUE;
    mnError = 0;

    return TRUE;
}

// -----------------------------------------------------------------------

BOOL Os2SalPrinter::EndJob()
{
    APIRET rc;
    rc = DevEscape( mhDC,
                    DEVESC_ENDDOC,
                    0, NULL,
                    0, NULL);

    // destroy presentation space and device context
    Ft2Associate( mhPS, NULL );
    Ft2DestroyPS( mhPS );
    DevCloseDC( mhDC );
    return TRUE;
}

// -----------------------------------------------------------------------

BOOL Os2SalPrinter::AbortJob()
{
    APIRET rc;

    rc = DevEscape( mhDC,
                    DEVESC_ABORTDOC,
                    0, NULL,
                    0, NULL );

    // destroy SalGraphics
    if ( mpGraphics )
    {
        ImplSalDeInitGraphics( mpGraphics );
        delete mpGraphics;
        mpGraphics = NULL;
    }

    // destroy presentation space and device context
    Ft2Associate( mhPS, NULL );
    Ft2DestroyPS( mhPS );
    DevCloseDC( mhDC );
    return TRUE;
}

// -----------------------------------------------------------------------

SalGraphics* Os2SalPrinter::StartPage( ImplJobSetup* pSetupData, BOOL bNewJobSetup )
{
    APIRET rc;

    if ( mbFirstPage )
        mbFirstPage = FALSE;
    else
    {
        PBYTE   pJobData;
        LONG    nJobDataSize;
        LONG    nEscape;
        if ( mbPrintDJPSupported && bNewJobSetup )
        {
            nEscape         = DEVESC_NEWFRAME_WPROP;
            nJobDataSize    = ((PDRIVDATA)(pSetupData->mpDriverData))->cb;
            pJobData        = (PBYTE)(pSetupData->mpDriverData);
        }
        else
        {
            nEscape         = DEVESC_NEWFRAME;
            nJobDataSize    = 0;
            pJobData        = NULL;
        }
        rc = DevEscape( mhDC,
                        nEscape,
                        0, NULL,
                        &nJobDataSize, pJobData );

        if ( rc != DEV_OK )
        {
            DevEscape( mhDC, DEVESC_ENDDOC, 0, NULL, 0, NULL);
            Ft2Associate( mhPS, NULL );
            Ft2DestroyPS( mhPS );
            DevCloseDC( mhDC );
            mnError = SAL_PRINTER_ERROR_GENERALERROR;
            return NULL;
        }
    }

    // create SalGraphics with copy of hPS
    Os2SalGraphics* pGraphics = new Os2SalGraphics;
    pGraphics->mhDC             = mhDC;
    pGraphics->mhPS             = mhPS;
    pGraphics->mhWnd            = 0;
    pGraphics->mbPrinter        = TRUE;
    pGraphics->mbVirDev         = FALSE;
    pGraphics->mbWindow         = FALSE;
    pGraphics->mbScreen         = FALSE;
    pGraphics->mnHeight         = 0;
    // search current form for actual page height
    HCINFO  aInfo;
    int     nForms = DevQueryHardcopyCaps( mhDC, 0, 0, &aInfo );
    for( int i = 0; i < nForms; i++ )
    {
        if ( DevQueryHardcopyCaps( mhDC, i, 1, &aInfo ) >= 0 )
        {
            if ( aInfo.flAttributes & HCAPS_CURRENT )
                pGraphics->mnHeight = aInfo.yPels;
        }
    }
    // use device caps if no form selected/found
    if ( !pGraphics->mnHeight )
        DevQueryCaps( mhDC, CAPS_HEIGHT, 1L, &pGraphics->mnHeight );

    ImplSalInitGraphics( pGraphics );
    mpGraphics = pGraphics;

    return pGraphics;
}

// -----------------------------------------------------------------------

BOOL Os2SalPrinter::EndPage()
{
    if ( mpGraphics )
    {
        // destroy SalGraphics
        ImplSalDeInitGraphics( mpGraphics );
        delete mpGraphics;
        mpGraphics = NULL;
    }

    return TRUE;
}

// -----------------------------------------------------------------------

ULONG Os2SalPrinter::GetErrorCode()
{
    return mnError;
}

void Os2SalInfoPrinter::InitPaperFormats( const ImplJobSetup* pSetupData )
{
    printf("Os2SalInfoPrinter::InitPaperFormats\n");
}
int Os2SalInfoPrinter::GetLandscapeAngle( const ImplJobSetup* pSetupData )
{
    printf("Os2SalInfoPrinter::GetLandscapeAngle\n");
    return 0;
}