LCOV - code coverage report
Current view: top level - libreoffice/padmin/source - prtsetup.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 406 0.0 %
Date: 2012-12-17 Functions: 0 50 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "prtsetup.hxx"
      21             : #include "helper.hxx" // for PaResId
      22             : #include "rtsetup.hrc"
      23             : #include "cmddlg.hxx"
      24             : 
      25             : #include "vcl/fontmanager.hxx"
      26             : 
      27             : #include "osl/thread.h"
      28             : 
      29             : #include <officecfg/Office/Common.hxx>
      30             : 
      31             : #define LSCAPE_STRING String( RTL_CONSTASCII_USTRINGPARAM( "Landscape" ) )
      32             : #define PORTRAIT_STRING String( RTL_CONSTASCII_USTRINGPARAM( "Portrait" ) )
      33             : 
      34             : using namespace psp;
      35             : using namespace padmin;
      36             : 
      37             : using ::rtl::OUString;
      38             : using ::rtl::OUStringHash;
      39             : using ::rtl::OString;
      40             : 
      41           0 : void RTSDialog::insertAllPPDValues( ListBox& rBox, const PPDParser* pParser, const PPDKey* pKey )
      42             : {
      43           0 :     if( ! pKey || ! pParser )
      44           0 :         return;
      45             : 
      46           0 :     const PPDValue* pValue = NULL;
      47           0 :     sal_uInt16 nPos = 0;
      48           0 :     String aOptionText;
      49             : 
      50           0 :     for( int i = 0; i < pKey->countValues(); i++ )
      51             :     {
      52           0 :         pValue = pKey->getValue( i );
      53           0 :         aOptionText = pParser->translateOption( pKey->getKey(), pValue->m_aOption) ;
      54             : 
      55           0 :         if( m_aJobData.m_aContext.checkConstraints( pKey, pValue ) )
      56             :         {
      57           0 :             if( rBox.GetEntryPos( (void*)pValue ) == LISTBOX_ENTRY_NOTFOUND )
      58             :             {
      59           0 :                 nPos = rBox.InsertEntry( aOptionText, LISTBOX_APPEND );
      60           0 :                     rBox.SetEntryData( nPos, (void*)pValue );
      61             :             }
      62             :         }
      63             :         else
      64             :         {
      65           0 :             if( ( nPos = rBox.GetEntryPos( (void*)pValue ) ) != LISTBOX_ENTRY_NOTFOUND )
      66           0 :                 rBox.RemoveEntry( nPos );
      67             :         }
      68             :     }
      69           0 :     pValue = m_aJobData.m_aContext.getValue( pKey );
      70           0 :     if( pValue )
      71             :     {
      72           0 :         if( ( nPos = rBox.GetEntryPos( (void*)pValue ) ) != LISTBOX_ENTRY_NOTFOUND )
      73           0 :             rBox.SelectEntryPos( nPos );
      74             :     }
      75             :     else
      76           0 :         rBox.SelectEntry( m_aInvalidString );
      77             : }
      78             : 
      79             : // --------------------------------------------------------------------------
      80             : 
      81             : /*
      82             :  * RTSDialog
      83             :  */
      84             : 
      85           0 : RTSDialog::RTSDialog( const PrinterInfo& rJobData, const String& rPrinter, bool bAllPages, Window* pParent ) :
      86             :         TabDialog(  pParent, PaResId( RID_RTS_RTSDIALOG ) ),
      87             :         m_aJobData( rJobData ),
      88             :         m_aPrinter( rPrinter ),
      89             :         m_aTabControl( this, PaResId( RID_RTS_RTSDIALOG_TABCONTROL ) ),
      90             :         m_aOKButton( this ),
      91             :         m_aCancelButton( this ),
      92             :         m_pPaperPage( NULL ),
      93             :         m_pDevicePage( NULL ),
      94             :         m_pOtherPage( NULL ),
      95             :         m_pFontSubstPage( NULL ),
      96             :         m_pCommandPage( NULL ),
      97           0 :         m_aInvalidString( PaResId( RID_RTS_RTSDIALOG_INVALID_TXT ) )
      98             : {
      99           0 :     FreeResource();
     100             : 
     101           0 :     String aTitle( GetText() );
     102           0 :     aTitle.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "%s" ) ), m_aJobData.m_aPrinterName );
     103           0 :     SetText( aTitle );
     104             : 
     105           0 :     if( ! bAllPages )
     106             :     {
     107           0 :         m_aTabControl.RemovePage( RID_RTS_OTHERPAGE );
     108           0 :         m_aTabControl.RemovePage( RID_RTS_FONTSUBSTPAGE );
     109           0 :         m_aTabControl.RemovePage( RID_RTS_COMMANDPAGE );
     110             :     }
     111           0 :     else if( m_aJobData.m_aDriverName.compareToAscii( "CUPS:", 5 ) == 0 && ! PrinterInfoManager::get().isCUPSDisabled() )
     112             :     {
     113             :         // command page makes no sense for CUPS printers
     114           0 :         m_aTabControl.RemovePage( RID_RTS_COMMANDPAGE );
     115             :     }
     116             : 
     117           0 :     m_aTabControl.SetActivatePageHdl( LINK( this, RTSDialog, ActivatePage ) );
     118           0 :     m_aOKButton.SetClickHdl( LINK( this, RTSDialog, ClickButton ) );
     119           0 :     m_aCancelButton.SetClickHdl( LINK( this, RTSDialog, ClickButton ) );
     120           0 :     ActivatePage( &m_aTabControl );
     121             : 
     122           0 :     m_aOKButton.Show();
     123           0 :     m_aCancelButton.Show();
     124           0 : }
     125             : 
     126             : // --------------------------------------------------------------------------
     127             : 
     128           0 : RTSDialog::~RTSDialog()
     129             : {
     130           0 :     if( m_pPaperPage )
     131           0 :         delete m_pPaperPage;
     132           0 :     if( m_pDevicePage )
     133           0 :         delete m_pDevicePage;
     134           0 :     if( m_pOtherPage )
     135           0 :         delete m_pOtherPage;
     136           0 :     if( m_pFontSubstPage )
     137           0 :         delete m_pFontSubstPage;
     138           0 :     if( m_pCommandPage )
     139           0 :         delete m_pCommandPage;
     140           0 : }
     141             : 
     142             : // --------------------------------------------------------------------------
     143             : 
     144           0 : IMPL_LINK( RTSDialog, ActivatePage, TabControl*, pTabCtrl )
     145             : {
     146           0 :     if( pTabCtrl != &m_aTabControl )
     147           0 :         return 0;
     148             : 
     149           0 :     sal_uInt16 nId = m_aTabControl.GetCurPageId();
     150             : 
     151           0 :     if ( ! m_aTabControl.GetTabPage( nId ) )
     152             :     {
     153           0 :         TabPage *pPage = NULL;
     154           0 :         if( nId == RID_RTS_PAPERPAGE )
     155           0 :             pPage = m_pPaperPage = new RTSPaperPage( this );
     156           0 :         else if( nId == RID_RTS_DEVICEPAGE )
     157           0 :             pPage = m_pDevicePage = new RTSDevicePage( this );
     158           0 :         else if( nId == RID_RTS_OTHERPAGE )
     159           0 :             pPage = m_pOtherPage = new RTSOtherPage( this );
     160           0 :         else if( nId == RID_RTS_FONTSUBSTPAGE )
     161           0 :             pPage = m_pFontSubstPage = new RTSFontSubstPage( this );
     162           0 :         else if( nId == RID_RTS_COMMANDPAGE )
     163           0 :             pPage = m_pCommandPage = new RTSCommandPage( this );
     164           0 :         if( pPage )
     165           0 :             m_aTabControl.SetTabPage( nId, pPage );
     166             :     }
     167             :     else
     168             :     {
     169           0 :         switch( nId )
     170             :         {
     171           0 :             case RID_RTS_PAPERPAGE:     m_pPaperPage->update();break;
     172           0 :             case RID_RTS_DEVICEPAGE:    m_pDevicePage->update();break;
     173           0 :             default: break;
     174             :         }
     175             :     }
     176             : 
     177           0 :     return 0;
     178             : }
     179             : 
     180             : // --------------------------------------------------------------------------
     181             : 
     182           0 : IMPL_LINK( RTSDialog, ClickButton, Button*, pButton )
     183             : {
     184           0 :     if( pButton == &m_aOKButton )
     185             :     {
     186             :         // refresh the changed values
     187           0 :         if( m_pPaperPage )
     188             :         {
     189             :             // orientation
     190           0 :             m_aJobData.m_eOrientation = m_pPaperPage->getOrientation().Equals( LSCAPE_STRING ) ? orientation::Landscape : orientation::Portrait;
     191             :         }
     192           0 :         if( m_pDevicePage )
     193             :         {
     194           0 :             m_aJobData.m_nColorDepth    = m_pDevicePage->getDepth();
     195           0 :             m_aJobData.m_nColorDevice   = m_pDevicePage->getColorDevice();
     196           0 :             m_aJobData.m_nPSLevel       = m_pDevicePage->getLevel();
     197           0 :             m_aJobData.m_nPDFDevice     = m_pDevicePage->getPDFDevice();
     198             :         }
     199           0 :         if( m_pOtherPage )
     200             :             // write other settings
     201           0 :             m_pOtherPage->save();
     202           0 :         if( m_pCommandPage )
     203             :             // write command settings
     204           0 :             m_pCommandPage->save();
     205             : 
     206           0 :         EndDialog( 1 );
     207             :     }
     208           0 :     else if( pButton == &m_aCancelButton )
     209           0 :         EndDialog( 0 );
     210             : 
     211           0 :     return 0;
     212             : }
     213             : 
     214             : // --------------------------------------------------------------------------
     215             : 
     216             : /*
     217             :  * RTSPaperPage
     218             :  */
     219             : 
     220           0 : RTSPaperPage::RTSPaperPage( RTSDialog* pParent ) :
     221             :         TabPage( & pParent->m_aTabControl, PaResId( RID_RTS_PAPERPAGE ) ),
     222             : 
     223             :         m_pParent( pParent ),
     224             : 
     225             :         m_aPaperText( this, PaResId( RID_RTS_PAPER_PAPER_TXT ) ),
     226             :         m_aPaperBox( this, PaResId( RID_RTS_PAPER_PAPER_BOX ) ),
     227             :         m_aOrientText( this, PaResId( RID_RTS_PAPER_ORIENTATION_TXT ) ),
     228             :         m_aOrientBox( this, PaResId( RID_RTS_PAPER_ORIENTATION_BOX ) ),
     229             :         m_aDuplexText( this, PaResId( RID_RTS_PAPER_DUPLEX_TXT ) ),
     230             :         m_aDuplexBox( this, PaResId( RID_RTS_PAPER_DUPLEX_BOX ) ),
     231             :         m_aSlotText( this, PaResId( RID_RTS_PAPER_SLOT_TXT ) ),
     232           0 :         m_aSlotBox( this, PaResId( RID_RTS_PAPER_SLOT_BOX ) )
     233             : {
     234           0 :     m_aPaperBox.SetSelectHdl( LINK( this, RTSPaperPage, SelectHdl ) );
     235           0 :     m_aOrientBox.SetSelectHdl( LINK( this, RTSPaperPage, SelectHdl ) );
     236           0 :     m_aDuplexBox.SetSelectHdl( LINK( this, RTSPaperPage, SelectHdl ) );
     237           0 :     m_aSlotBox.SetSelectHdl( LINK( this, RTSPaperPage, SelectHdl ) );
     238             : 
     239           0 :     FreeResource();
     240             : 
     241           0 :     sal_uInt16 nPos = 0;
     242             : 
     243           0 :     m_aOrientBox.InsertEntry( PORTRAIT_STRING );
     244           0 :     m_aOrientBox.InsertEntry( LSCAPE_STRING );
     245             :     // duplex
     246           0 :     nPos = m_aDuplexBox.InsertEntry( m_pParent->m_aInvalidString );
     247           0 :     m_aDuplexBox.SetEntryData( nPos, NULL );
     248             : 
     249             :     // paper does not have an invalid entry
     250             : 
     251             :     // input slots
     252           0 :     nPos = m_aSlotBox.InsertEntry( m_pParent->m_aInvalidString );
     253           0 :     m_aSlotBox.SetEntryData( nPos, NULL );
     254             : 
     255           0 :     update();
     256           0 : }
     257             : 
     258             : // --------------------------------------------------------------------------
     259             : 
     260           0 : RTSPaperPage::~RTSPaperPage()
     261             : {
     262           0 : }
     263             : 
     264             : // --------------------------------------------------------------------------
     265             : 
     266           0 : void RTSPaperPage::update()
     267             : {
     268           0 :     const PPDKey* pKey      = NULL;
     269             : 
     270             :     // orientation
     271             :     m_aOrientBox.SelectEntry(
     272             :         m_pParent->m_aJobData.m_eOrientation == orientation::Landscape
     273           0 :         ? LSCAPE_STRING : PORTRAIT_STRING );
     274             : 
     275             :     // duplex
     276           0 :     if( m_pParent->m_aJobData.m_pParser &&
     277           0 :         (pKey = m_pParent->m_aJobData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "Duplex" ) ) )) )
     278             :     {
     279           0 :         m_pParent->insertAllPPDValues( m_aDuplexBox, m_pParent->m_aJobData.m_pParser, pKey );
     280             :     }
     281             :     else
     282             :     {
     283           0 :         m_aDuplexText.Enable( sal_False );
     284           0 :         m_aDuplexBox.Enable( sal_False );
     285             :     }
     286             : 
     287             :     // paper
     288           0 :     if( m_pParent->m_aJobData.m_pParser &&
     289           0 :         (pKey = m_pParent->m_aJobData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) ) )) )
     290             :     {
     291           0 :         m_pParent->insertAllPPDValues( m_aPaperBox, m_pParent->m_aJobData.m_pParser, pKey );
     292             :     }
     293             :     else
     294             :     {
     295           0 :         m_aPaperText.Enable( sal_False );
     296           0 :         m_aPaperBox.Enable( sal_False );
     297             :     }
     298             : 
     299             :     // input slots
     300           0 :     if( m_pParent->m_aJobData.m_pParser &&
     301           0 :         (pKey = m_pParent->m_aJobData.m_pParser->getKey( rtl::OUString("InputSlot") )) )
     302             :     {
     303           0 :         m_pParent->insertAllPPDValues( m_aSlotBox, m_pParent->m_aJobData.m_pParser, pKey );
     304             :     }
     305             :     else
     306             :     {
     307           0 :         m_aSlotText.Enable( sal_False );
     308           0 :         m_aSlotBox.Enable( sal_False );
     309             :     }
     310           0 : }
     311             : 
     312             : // --------------------------------------------------------------------------
     313             : 
     314           0 : IMPL_LINK( RTSPaperPage, SelectHdl, ListBox*, pBox )
     315             : {
     316           0 :     const PPDKey* pKey = NULL;
     317           0 :     if( pBox == &m_aPaperBox )
     318             :     {
     319           0 :         if( m_pParent->m_aJobData.m_pParser )
     320           0 :             pKey = m_pParent->m_aJobData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) ) );
     321             :     }
     322           0 :     else if( pBox == &m_aDuplexBox )
     323             :     {
     324           0 :         if( m_pParent->m_aJobData.m_pParser )
     325           0 :             pKey = m_pParent->m_aJobData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "Duplex" ) ) );
     326             :     }
     327           0 :     else if( pBox == &m_aSlotBox )
     328             :     {
     329           0 :         if( m_pParent->m_aJobData.m_pParser )
     330           0 :             pKey = m_pParent->m_aJobData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "InputSlot" ) ) );
     331             :     }
     332           0 :     else if( pBox == &m_aOrientBox )
     333             :     {
     334           0 :         m_pParent->m_aJobData.m_eOrientation = m_aOrientBox.GetSelectEntry().Equals( LSCAPE_STRING ) ? orientation::Landscape : orientation::Portrait;
     335             :     }
     336           0 :     if( pKey )
     337             :     {
     338             :         PPDValue* pValue =
     339           0 :             (PPDValue*)pBox->GetEntryData( pBox->GetSelectEntryPos() );
     340           0 :         m_pParent->m_aJobData.m_aContext.setValue( pKey, pValue );
     341           0 :         update();
     342             :     }
     343           0 :     return 0;
     344             : }
     345             : 
     346             : // --------------------------------------------------------------------------
     347             : 
     348             : /*
     349             :  * RTSDevicePage
     350             :  */
     351             : 
     352           0 : RTSDevicePage::RTSDevicePage( RTSDialog* pParent )
     353             :     : TabPage(&pParent->m_aTabControl, "PrinterDevicePage", "spa/ui/printerdevicepage.ui" )
     354           0 :     , m_pParent( pParent )
     355             : {
     356           0 :     get(m_pPPDKeyBox, "options");
     357           0 :     get(m_pPPDValueBox, "values");
     358             : 
     359           0 :     m_pPPDKeyBox->SetDropDownLineCount(12);
     360           0 :     m_pPPDValueBox->SetDropDownLineCount(12);
     361             : 
     362           0 :     get(m_pLevelBox, "level");
     363           0 :     get(m_pSpaceBox, "colorspace");
     364           0 :     get(m_pDepthBox, "colordepth");
     365             : 
     366           0 :     m_pPPDKeyBox->SetSelectHdl( LINK( this, RTSDevicePage, SelectHdl ) );
     367           0 :     m_pPPDValueBox->SetSelectHdl( LINK( this, RTSDevicePage, SelectHdl ) );
     368             : 
     369           0 :     switch( m_pParent->m_aJobData.m_nColorDevice )
     370             :     {
     371           0 :         case  0: m_pSpaceBox->SelectEntryPos(0);break;
     372           0 :         case  1: m_pSpaceBox->SelectEntryPos(1);break;
     373           0 :         case -1: m_pSpaceBox->SelectEntryPos(2);break;
     374             :     }
     375             : 
     376           0 :     sal_uLong nLevelEntryData = 0; //automatic
     377           0 :     if( m_pParent->m_aJobData.m_nPDFDevice == 2 ) //explicitly PDF
     378           0 :         nLevelEntryData = 10;
     379           0 :     else if (m_pParent->m_aJobData.m_nPSLevel > 0) //explicit PS Level
     380           0 :         nLevelEntryData = m_pParent->m_aJobData.m_nPSLevel+1;
     381           0 :     else if (m_pParent->m_aJobData.m_nPDFDevice == 1) //automatically PDF
     382           0 :         nLevelEntryData = 0;
     383           0 :     else if (m_pParent->m_aJobData.m_nPDFDevice == -1) //explicitly PS from driver
     384           0 :         nLevelEntryData = 1;
     385             : 
     386             :     bool bAutoIsPDF = officecfg::Office::Common::Print::Option::Printer::PDFAsStandardPrintJobFormat::get();
     387             : 
     388             :     assert(nLevelEntryData != 0 || bAutoIsPDF == m_pParent->m_aJobData.m_nPDFDevice);
     389             : 
     390           0 :     OUString sStr = m_pLevelBox->GetEntry(0);
     391           0 :     m_pLevelBox->InsertEntry(sStr.replaceAll("%s", bAutoIsPDF ? m_pLevelBox->GetEntry(5) : m_pLevelBox->GetEntry(1)), 0);
     392           0 :     m_pLevelBox->SetEntryData(0, m_pLevelBox->GetEntryData(1));
     393           0 :     m_pLevelBox->RemoveEntry(1);
     394             : 
     395           0 :     for( sal_uInt16 i = 0; i < m_pLevelBox->GetEntryCount(); i++ )
     396             :     {
     397           0 :         if( (sal_uLong)m_pLevelBox->GetEntryData( i ) == nLevelEntryData )
     398             :         {
     399           0 :             m_pLevelBox->SelectEntryPos( i );
     400           0 :             break;
     401             :         }
     402             :     }
     403             : 
     404           0 :     if (m_pParent->m_aJobData.m_nColorDepth == 8)
     405           0 :         m_pDepthBox->SelectEntryPos(0);
     406           0 :     else if (m_pParent->m_aJobData.m_nColorDepth == 24)
     407           0 :         m_pDepthBox->SelectEntryPos(1);
     408             : 
     409             :     // fill ppd boxes
     410           0 :     if( m_pParent->m_aJobData.m_pParser )
     411             :     {
     412           0 :         for( int i = 0; i < m_pParent->m_aJobData.m_pParser->getKeys(); i++ )
     413             :         {
     414           0 :             const PPDKey* pKey = m_pParent->m_aJobData.m_pParser->getKey( i );
     415           0 :             if( pKey->isUIKey()                                 &&
     416           0 :                 ! pKey->getKey().EqualsAscii( "PageSize" )      &&
     417           0 :                 ! pKey->getKey().EqualsAscii( "InputSlot" )     &&
     418           0 :                 ! pKey->getKey().EqualsAscii( "PageRegion" )    &&
     419           0 :                 ! pKey->getKey().EqualsAscii( "Duplex" )
     420             :                 )
     421             :             {
     422           0 :                 String aEntry( m_pParent->m_aJobData.m_pParser->translateKey( pKey->getKey() ) );
     423           0 :                 sal_uInt16 nPos = m_pPPDKeyBox->InsertEntry( aEntry );
     424           0 :                 m_pPPDKeyBox->SetEntryData( nPos, (void*)pKey );
     425             :             }
     426             :         }
     427           0 :     }
     428           0 : }
     429             : 
     430             : // --------------------------------------------------------------------------
     431             : 
     432           0 : RTSDevicePage::~RTSDevicePage()
     433             : {
     434           0 : }
     435             : 
     436             : // --------------------------------------------------------------------------
     437             : 
     438           0 : void RTSDevicePage::update()
     439             : {
     440           0 : }
     441             : 
     442           0 : sal_uLong RTSDevicePage::getDepth()
     443             : {
     444           0 :     sal_uInt16 nSelectPos = m_pDepthBox->GetSelectEntryPos();
     445           0 :     if (nSelectPos == 0)
     446           0 :         return 8;
     447             :     else
     448           0 :         return 24;
     449             : }
     450             : 
     451           0 : sal_uLong RTSDevicePage::getColorDevice()
     452             : {
     453           0 :     sal_uInt16 nSelectPos = m_pSpaceBox->GetSelectEntryPos();
     454           0 :     switch (nSelectPos)
     455             :     {
     456             :         case 0:
     457           0 :             return 0;
     458             :         case 1:
     459           0 :             return 1;
     460             :         case 2:
     461           0 :             return -1;
     462             :     }
     463           0 :     return 0;
     464             : }
     465             : 
     466             : // ------------------------------------------------------------------
     467             : 
     468           0 : sal_uLong RTSDevicePage::getLevel()
     469             : {
     470           0 :     sal_uLong nLevel = (sal_uLong)m_pLevelBox->GetEntryData( m_pLevelBox->GetSelectEntryPos() );
     471           0 :     if (nLevel == 0)
     472           0 :         return 0;   //automatic
     473           0 :     return nLevel < 10 ? nLevel-1 : 0;
     474             : }
     475             : 
     476             : // ------------------------------------------------------------------
     477             : 
     478           0 : sal_uLong RTSDevicePage::getPDFDevice()
     479             : {
     480           0 :     sal_uLong nLevel = (sal_uLong)m_pLevelBox->GetEntryData( m_pLevelBox->GetSelectEntryPos() );
     481           0 :     if (nLevel > 9)
     482           0 :         return 2;   //explictly PDF
     483           0 :     else if (nLevel == 0)
     484           0 :         return 0;   //automatic
     485           0 :     return -1;      //explicitly PS
     486             : }
     487             : 
     488             : // ------------------------------------------------------------------
     489             : 
     490           0 : IMPL_LINK( RTSDevicePage, SelectHdl, ListBox*, pBox )
     491             : {
     492           0 :     if( pBox == m_pPPDKeyBox )
     493             :     {
     494           0 :         const PPDKey* pKey = (PPDKey*)m_pPPDKeyBox->GetEntryData( m_pPPDKeyBox->GetSelectEntryPos() );
     495           0 :         FillValueBox( pKey );
     496             :     }
     497           0 :     else if( pBox == m_pPPDValueBox )
     498             :     {
     499           0 :         const PPDKey* pKey = (PPDKey*)m_pPPDKeyBox->GetEntryData( m_pPPDKeyBox->GetSelectEntryPos() );
     500           0 :         const PPDValue* pValue = (PPDValue*)m_pPPDValueBox->GetEntryData( m_pPPDValueBox->GetSelectEntryPos() );
     501           0 :         if( pKey && pValue )
     502             :         {
     503           0 :             m_pParent->m_aJobData.m_aContext.setValue( pKey, pValue );
     504           0 :             FillValueBox( pKey );
     505             :         }
     506             :     }
     507           0 :     return 0;
     508             : }
     509             : 
     510             : // ------------------------------------------------------------------
     511             : 
     512           0 : void RTSDevicePage::FillValueBox( const PPDKey* pKey )
     513             : {
     514           0 :     m_pPPDValueBox->Clear();
     515             : 
     516           0 :     if( ! pKey )
     517           0 :         return;
     518             : 
     519           0 :     const PPDValue* pValue = NULL;
     520           0 :     for( int i = 0; i < pKey->countValues(); i++ )
     521             :     {
     522           0 :         pValue = pKey->getValue( i );
     523           0 :         if( m_pParent->m_aJobData.m_aContext.checkConstraints( pKey, pValue ) &&
     524             :             m_pParent->m_aJobData.m_pParser )
     525             :         {
     526           0 :             String aEntry( m_pParent->m_aJobData.m_pParser->translateOption( pKey->getKey(), pValue->m_aOption ) );
     527           0 :             sal_uInt16 nPos = m_pPPDValueBox->InsertEntry( aEntry );
     528           0 :             m_pPPDValueBox->SetEntryData( nPos, (void*)pValue );
     529             :         }
     530             :     }
     531           0 :     pValue = m_pParent->m_aJobData.m_aContext.getValue( pKey );
     532           0 :     m_pPPDValueBox->SelectEntryPos( m_pPPDValueBox->GetEntryPos( (void*)pValue ) );
     533             : }
     534             : 
     535             : // --------------------------------------------------------------------------
     536             : 
     537             : /*
     538             :  * RTSOtherPage
     539             :  */
     540             : 
     541           0 : RTSOtherPage::RTSOtherPage( RTSDialog* pParent ) :
     542             :         TabPage( &pParent->m_aTabControl, PaResId( RID_RTS_OTHERPAGE ) ),
     543             :         m_pParent( pParent ),
     544             :         m_aLeftTxt( this, PaResId( RID_RTS_OTHER_LEFTMARGIN_TXT ) ),
     545             :         m_aLeftLB( this, PaResId( RID_RTS_OTHER_LEFTMARGIN_BOX ) ),
     546             :         m_aTopTxt( this, PaResId( RID_RTS_OTHER_TOPMARGIN_TXT ) ),
     547             :         m_aTopLB( this, PaResId( RID_RTS_OTHER_TOPMARGIN_BOX ) ),
     548             :         m_aRightTxt( this, PaResId( RID_RTS_OTHER_RIGHTMARGIN_TXT ) ),
     549             :         m_aRightLB( this, PaResId( RID_RTS_OTHER_RIGHTMARGIN_BOX ) ),
     550             :         m_aBottomTxt( this, PaResId( RID_RTS_OTHER_BOTTOMMARGIN_TXT ) ),
     551             :         m_aBottomLB( this, PaResId( RID_RTS_OTHER_BOTTOMMARGIN_BOX ) ),
     552             :         m_aCommentTxt( this, PaResId( RID_RTS_OTHER_COMMENT_TXT ) ),
     553             :         m_aCommentEdt( this, PaResId( RID_RTS_OTHER_COMMENT_EDT ) ),
     554           0 :         m_aDefaultBtn( this, PaResId( RID_RTS_OTHER_DEFAULT_BTN ) )
     555             : {
     556           0 :     FreeResource();
     557             : 
     558           0 :     m_aTopLB.EnableEmptyFieldValue( sal_True );
     559           0 :     m_aBottomLB.EnableEmptyFieldValue( sal_True );
     560           0 :     m_aLeftLB.EnableEmptyFieldValue( sal_True );
     561           0 :     m_aRightLB.EnableEmptyFieldValue( sal_True );
     562             : 
     563           0 :     m_aDefaultBtn.SetClickHdl( LINK( this, RTSOtherPage, ClickBtnHdl ) );
     564             : 
     565           0 :     initValues();
     566           0 : }
     567             : 
     568             : // ------------------------------------------------------------------
     569             : 
     570           0 : RTSOtherPage::~RTSOtherPage()
     571             : {
     572           0 : }
     573             : 
     574             : // ------------------------------------------------------------------
     575             : 
     576           0 : void RTSOtherPage::initValues()
     577             : {
     578           0 :     int nMarginLeft = 0;
     579           0 :     int nMarginTop = 0;
     580           0 :     int nMarginRight = 0;
     581           0 :     int nMarginBottom = 0;
     582             : 
     583           0 :     if( m_pParent->m_aJobData.m_pParser )
     584             :     {
     585             :         m_pParent->m_aJobData.m_pParser->
     586             :             getMargins( m_pParent->m_aJobData.m_pParser->getDefaultPaperDimension(),
     587             :                         nMarginLeft,
     588             :                         nMarginRight,
     589             :                         nMarginTop,
     590           0 :                         nMarginBottom );
     591             :     }
     592             : 
     593           0 :     nMarginLeft     += m_pParent->m_aJobData.m_nLeftMarginAdjust;
     594           0 :     nMarginRight    += m_pParent->m_aJobData.m_nRightMarginAdjust;
     595           0 :     nMarginTop      += m_pParent->m_aJobData.m_nTopMarginAdjust;
     596           0 :     nMarginBottom   += m_pParent->m_aJobData.m_nBottomMarginAdjust;
     597             : 
     598           0 :     m_aLeftLB.SetValue( nMarginLeft, FUNIT_POINT );
     599           0 :     m_aRightLB.SetValue( nMarginRight, FUNIT_POINT );
     600           0 :     m_aTopLB.SetValue( nMarginTop, FUNIT_POINT );
     601           0 :     m_aBottomLB.SetValue( nMarginBottom, FUNIT_POINT );
     602           0 :     m_aCommentEdt.SetText( m_pParent->m_aJobData.m_aComment );
     603           0 : }
     604             : 
     605             : // ------------------------------------------------------------------
     606             : 
     607           0 : void RTSOtherPage::save()
     608             : {
     609           0 :     int nMarginLeft = 0;
     610           0 :     int nMarginTop = 0;
     611           0 :     int nMarginRight = 0;
     612           0 :     int nMarginBottom = 0;
     613             : 
     614           0 :     if( m_pParent->m_aJobData.m_pParser )
     615             :     {
     616             :         m_pParent->m_aJobData.m_pParser->
     617             :             getMargins( m_pParent->m_aJobData.m_pParser->getDefaultPaperDimension(),
     618             :                         nMarginLeft,
     619             :                         nMarginRight,
     620             :                         nMarginTop,
     621           0 :                         nMarginBottom );
     622             :     }
     623             : 
     624           0 :     m_pParent->m_aJobData.m_nLeftMarginAdjust   = m_aLeftLB.GetValue( FUNIT_POINT ) - nMarginLeft;
     625           0 :     m_pParent->m_aJobData.m_nRightMarginAdjust  = m_aRightLB.GetValue( FUNIT_POINT ) - nMarginRight;
     626           0 :     m_pParent->m_aJobData.m_nTopMarginAdjust    = m_aTopLB.GetValue( FUNIT_POINT ) - nMarginTop;
     627           0 :     m_pParent->m_aJobData.m_nBottomMarginAdjust = m_aBottomLB.GetValue( FUNIT_POINT ) - nMarginBottom;
     628           0 :     m_pParent->m_aJobData.m_aComment = m_aCommentEdt.GetText();
     629           0 : }
     630             : 
     631             : // ------------------------------------------------------------------
     632             : 
     633           0 : IMPL_LINK( RTSOtherPage, ClickBtnHdl, Button*, pButton )
     634             : {
     635           0 :     if( pButton == &m_aDefaultBtn )
     636             :     {
     637             :         m_pParent->m_aJobData.m_nLeftMarginAdjust =
     638             :             m_pParent->m_aJobData.m_nRightMarginAdjust =
     639             :             m_pParent->m_aJobData.m_nTopMarginAdjust =
     640           0 :             m_pParent->m_aJobData.m_nBottomMarginAdjust = 0;
     641             : 
     642           0 :         initValues();
     643             :     }
     644           0 :     return 0;
     645             : }
     646             : 
     647             : // ------------------------------------------------------------------
     648             : 
     649             : /*
     650             :  *  RTSFontSubstPage
     651             :  */
     652             : 
     653           0 : RTSFontSubstPage::RTSFontSubstPage( RTSDialog* pParent ) :
     654             :         TabPage( &pParent->m_aTabControl, PaResId( RID_RTS_FONTSUBSTPAGE ) ),
     655             :         m_pParent( pParent ),
     656             :         m_aSubstitutionsText( this, PaResId( RID_RTS_FS_SUBST_TXT ) ),
     657             :         m_aSubstitutionsBox( this, PaResId( RID_RTS_FS_SUBST_BOX ) ),
     658             :         m_aFromFontText( this, PaResId( RID_RTS_FS_FROM_TXT ) ),
     659             :         m_aFromFontBox( this, PaResId( RID_RTS_FS_FROM_BOX ) ),
     660             :         m_aToFontText( this, PaResId( RID_RTS_FS_TO_TXT ) ),
     661             :         m_aToFontBox( this, PaResId( RID_RTS_FS_TO_BOX ) ),
     662             :         m_aAddButton( this, PaResId( RID_RTS_FS_ADD_BTN ) ),
     663             :         m_aRemoveButton( this, PaResId( RID_RTS_FS_REMOVE_BTN ) ),
     664           0 :         m_aEnableBox( this, PaResId( RID_RTS_FS_ENABLE_BTN ) )
     665             : {
     666           0 :     FreeResource();
     667             : 
     668             :     // fill to box
     669           0 :     PrintFontManager& rFontManager = PrintFontManager::get();
     670           0 :     ::std::list< FastPrintFontInfo > aFonts;
     671           0 :     rFontManager.getFontListWithFastInfo( aFonts, m_pParent->m_aJobData.m_pParser, false );
     672           0 :     ::std::list< FastPrintFontInfo >::const_iterator it;
     673           0 :     ::boost::unordered_map< OUString, int, OUStringHash > aToMap, aFromMap;
     674           0 :     for( it = aFonts.begin(); it != aFonts.end(); ++it )
     675             :     {
     676           0 :         if( it->m_eType == fonttype::Builtin )
     677             :         {
     678           0 :             if( aToMap.find( it->m_aFamilyName ) == aToMap.end() )
     679             :             {
     680           0 :                 m_aToFontBox.InsertEntry( it->m_aFamilyName );
     681           0 :                 aToMap[ it->m_aFamilyName ] = 1;
     682             :             }
     683             :         }
     684             :         else
     685             :         {
     686           0 :             if( aFromMap.find( it->m_aFamilyName ) == aFromMap.end() )
     687             :             {
     688           0 :                 m_aFromFontBox.InsertEntry( it->m_aFamilyName );
     689           0 :                 aFromMap[ it->m_aFamilyName ] = 1;
     690             :             }
     691             :         }
     692             :     }
     693             : 
     694           0 :     m_aEnableBox.Check( m_pParent->m_aJobData.m_bPerformFontSubstitution );
     695           0 :     m_aRemoveButton.Enable( sal_False );
     696           0 :     if( ! m_pParent->m_aJobData.m_bPerformFontSubstitution )
     697             :     {
     698           0 :         m_aSubstitutionsBox.Enable( sal_False );
     699           0 :         m_aSubstitutionsText.Enable( sal_False );
     700           0 :         m_aAddButton.Enable( sal_False );
     701           0 :         m_aToFontBox.Enable( sal_False );
     702           0 :         m_aToFontText.Enable( sal_False );
     703           0 :         m_aFromFontBox.Enable( sal_False );
     704           0 :         m_aFromFontText.Enable( sal_False );
     705             :     }
     706             : 
     707           0 :     update();
     708             : 
     709           0 :     m_aAddButton.SetClickHdl( LINK( this, RTSFontSubstPage, ClickBtnHdl ) );
     710           0 :     m_aRemoveButton.SetClickHdl( LINK( this, RTSFontSubstPage, ClickBtnHdl ) );
     711           0 :     m_aEnableBox.SetClickHdl( LINK( this, RTSFontSubstPage, ClickBtnHdl ) );
     712           0 :     m_aSubstitutionsBox.SetSelectHdl( LINK( this, RTSFontSubstPage, SelectHdl ) );
     713           0 :     m_aSubstitutionsBox.setDelPressedLink( LINK( this, RTSFontSubstPage, DelPressedHdl ) );
     714           0 : }
     715             : 
     716           0 : RTSFontSubstPage::~RTSFontSubstPage()
     717             : {
     718           0 : }
     719             : 
     720           0 : void RTSFontSubstPage::update()
     721             : {
     722           0 :     m_aSubstitutionsBox.Clear();
     723           0 :     m_aRemoveButton.Enable( sal_False );
     724             :     // fill substitutions box
     725           0 :     ::boost::unordered_map< OUString, OUString, OUStringHash >::const_iterator it;
     726           0 :     for( it = m_pParent->m_aJobData.m_aFontSubstitutes.begin();
     727           0 :          it != m_pParent->m_aJobData.m_aFontSubstitutes.end(); ++it )
     728             :     {
     729           0 :         String aEntry( it->first );
     730           0 :         aEntry.AppendAscii( " -> " );
     731           0 :         aEntry.Append( String( it->second ) );
     732           0 :         m_aSubstitutionsBox.InsertEntry( aEntry );
     733           0 :     }
     734           0 : }
     735             : 
     736           0 : IMPL_LINK( RTSFontSubstPage, DelPressedHdl, ListBox*, pBox )
     737             : {
     738           0 :     if( pBox == &m_aSubstitutionsBox &&
     739           0 :         m_aRemoveButton.IsEnabled() )
     740           0 :         ClickBtnHdl( &m_aRemoveButton );
     741           0 :     return 0;
     742             : }
     743             : 
     744           0 : IMPL_LINK( RTSFontSubstPage, SelectHdl, ListBox*, pBox )
     745             : {
     746           0 :     if( pBox == &m_aSubstitutionsBox )
     747             :     {
     748           0 :         m_aRemoveButton.Enable( m_aSubstitutionsBox.GetSelectEntryCount() && m_pParent->m_aJobData.m_bPerformFontSubstitution );
     749             :     }
     750           0 :     return 0;
     751             : }
     752             : 
     753           0 : IMPL_LINK( RTSFontSubstPage, ClickBtnHdl, Button*, pButton )
     754             : {
     755           0 :     if( pButton == &m_aAddButton )
     756             :     {
     757           0 :         m_pParent->m_aJobData.m_aFontSubstitutes[ m_aFromFontBox.GetText() ] = m_aToFontBox.GetSelectEntry();
     758           0 :         update();
     759             :     }
     760           0 :     else if( pButton == &m_aRemoveButton )
     761             :     {
     762           0 :         for( int i = 0; i < m_aSubstitutionsBox.GetSelectEntryCount(); i++ )
     763             :         {
     764           0 :             String aEntry( m_aSubstitutionsBox.GetSelectEntry( i ) );
     765           0 :             sal_uInt16 nPos = aEntry.SearchAscii( " -> " );
     766           0 :             aEntry.Erase( nPos );
     767           0 :             m_pParent->m_aJobData.m_aFontSubstitutes.erase( aEntry );
     768           0 :         }
     769           0 :         update();
     770             :     }
     771           0 :     else if( pButton == &m_aEnableBox )
     772             :     {
     773           0 :         m_pParent->m_aJobData.m_bPerformFontSubstitution = m_aEnableBox.IsChecked() ? true : false;
     774           0 :         m_aSubstitutionsBox.Enable( m_pParent->m_aJobData.m_bPerformFontSubstitution );
     775           0 :         m_aSubstitutionsText.Enable( m_pParent->m_aJobData.m_bPerformFontSubstitution );
     776           0 :         m_aAddButton.Enable( m_pParent->m_aJobData.m_bPerformFontSubstitution );
     777           0 :         m_aRemoveButton.Enable( m_aSubstitutionsBox.GetSelectEntryCount() && m_pParent->m_aJobData.m_bPerformFontSubstitution );
     778           0 :         m_aToFontBox.Enable( m_pParent->m_aJobData.m_bPerformFontSubstitution );
     779           0 :         m_aToFontText.Enable( m_pParent->m_aJobData.m_bPerformFontSubstitution );
     780           0 :         m_aFromFontBox.Enable( m_pParent->m_aJobData.m_bPerformFontSubstitution );
     781           0 :         m_aFromFontText.Enable( m_pParent->m_aJobData.m_bPerformFontSubstitution );
     782             :     }
     783           0 :     return 0;
     784             : }
     785             : 
     786             : 
     787             : class RTSPWDialog : public ModalDialog
     788             : {
     789             :     FixedText       m_aText;
     790             :     FixedText       m_aUserText;
     791             :     Edit            m_aUserEdit;
     792             :     FixedText       m_aPassText;
     793             :     Edit            m_aPassEdit;
     794             : 
     795             :     OKButton        m_aOKButton;
     796             :     CancelButton    m_aCancelButton;
     797             : public:
     798             :     RTSPWDialog( const OString& rServer, const OString& rUserName, Window* pParent );
     799             :     ~RTSPWDialog();
     800             : 
     801             :     OString getUserName() const;
     802             :     OString getPassword() const;
     803             : };
     804             : 
     805           0 : RTSPWDialog::RTSPWDialog( const OString& rServer, const OString& rUserName, Window* pParent )
     806             :         :
     807             :         ModalDialog( pParent, PaResId( RID_RTS_PWDIALOG ) ),
     808             :         m_aText( this, PaResId( RID_RTS_PWDIALOG_TXT ) ),
     809             :         m_aUserText( this, PaResId( RID_RTS_PWDIALOG_USER_TXT ) ),
     810             :         m_aUserEdit( this, PaResId( RID_RTS_PWDIALOG_USER_EDT ) ),
     811             :         m_aPassText( this, PaResId( RID_RTS_PWDIALOG_PASS_TXT ) ),
     812             :         m_aPassEdit( this, PaResId( RID_RTS_PWDIALOG_PASS_EDT ) ),
     813             :         m_aOKButton( this, PaResId( RID_RTS_PWDIALOG_OK_BTN ) ),
     814           0 :         m_aCancelButton( this, PaResId( RID_RTS_PWDIALOG_CANCEL_BTN ) )
     815             : {
     816           0 :     FreeResource();
     817           0 :     String aText( m_aText.GetText() );
     818           0 :     aText.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "%s" ) ), OStringToOUString( rServer, osl_getThreadTextEncoding() ) );
     819           0 :     m_aText.SetText( aText );
     820           0 :     m_aUserEdit.SetText( OStringToOUString( rUserName, osl_getThreadTextEncoding() ) );
     821           0 : }
     822             : 
     823           0 : RTSPWDialog::~RTSPWDialog()
     824             : {
     825           0 : }
     826             : 
     827           0 : OString RTSPWDialog::getUserName() const
     828             : {
     829           0 :     return rtl::OUStringToOString( m_aUserEdit.GetText(), osl_getThreadTextEncoding() );
     830             : }
     831             : 
     832           0 : OString RTSPWDialog::getPassword() const
     833             : {
     834           0 :     return rtl::OUStringToOString( m_aPassEdit.GetText(), osl_getThreadTextEncoding() );
     835             : }
     836             : 
     837             : extern "C" {
     838             : 
     839           0 :     int SPA_DLLPUBLIC Sal_SetupPrinterDriver( ::psp::PrinterInfo& rJobData )
     840             :     {
     841           0 :         int nRet = 0;
     842           0 :         RTSDialog aDialog( rJobData, rJobData.m_aPrinterName, false );
     843             : 
     844           0 :         if( aDialog.Execute() )
     845             :         {
     846           0 :             rJobData = aDialog.getSetup();
     847           0 :             nRet = 1;
     848             :         }
     849             : 
     850           0 :         return nRet;
     851             :     }
     852             : 
     853           0 :     int SPA_DLLPUBLIC Sal_queryFaxNumber( String& rNumber )
     854             :     {
     855           0 :         String aTmpString( PaResId( RID_TXT_QUERYFAXNUMBER ) );
     856           0 :         QueryString aQuery( NULL, aTmpString, rNumber );
     857           0 :         return aQuery.Execute();
     858             :     }
     859             : 
     860           0 :     bool SPA_DLLPUBLIC Sal_authenticateQuery( const OString& rServer, OString& rUserName, OString& rPassword )
     861             :     {
     862           0 :         bool bRet = false;
     863             : 
     864           0 :         RTSPWDialog aDialog( rServer, rUserName, NULL );
     865           0 :         if( aDialog.Execute() )
     866             :         {
     867           0 :             rUserName = aDialog.getUserName();
     868           0 :             rPassword = aDialog.getPassword();
     869           0 :             bRet = true;
     870             :         }
     871           0 :         return bRet;
     872             :     }
     873             : 
     874             : } // extern "C"
     875             : 
     876             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10