dtmail: resolve coverity warnings related to uninitialised members in C++ classes
[oweals/cde.git] / cde / programs / dtmail / dtmail / DmxPrintOptions.C
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $TOG: DmxPrintOptions.C /main/8 1997/04/30 09:44:12 mgreess $ */
24
25 /*
26  *+SNOTICE
27  *
28  *      RESTRICTED CONFIDENTIAL INFORMATION:
29  *      
30  *      The information in this document is subject to special
31  *      restrictions in a confidential disclosure agreement between
32  *      HP, IBM, Sun, USL, SCO and Univel.  Do not distribute this
33  *      document outside HP, IBM, Sun, USL, SCO, or Univel without
34  *      Sun's specific written approval.  This document and all copies
35  *      and derivative works thereof must be returned or destroyed at
36  *      Sun's request.
37  *
38  *      Copyright 1994 Sun Microsystems, Inc.  All rights reserved.
39  *
40  *+ENOTICE
41  */
42 /*
43  *                   Common Desktop Environment
44  *
45  *   (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
46  *   (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
47  *   (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
48  *   (c) Copyright 1993, 1994, 1995 Novell, Inc.
49  *   (c) Copyright 1995 Digital Equipment Corp.
50  *   (c) Copyright 1995 Fujitsu Limited
51  *   (c) Copyright 1995 Hitachi, Ltd.
52  *                                                                   
53  *
54  *                     RESTRICTED RIGHTS LEGEND                              
55  *
56  *Use, duplication, or disclosure by the U.S. Government is subject to
57  *restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
58  *Technical Data and Computer Software clause in DFARS 252.227-7013.  Rights
59  *for non-DOD U.S. Government Departments and Agencies are as set forth in
60  *FAR 52.227-19(c)(1,2).
61
62  *Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
63  *International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A. 
64  *Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
65  *Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
66  *Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
67  *Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
68  *Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
69  */
70
71
72 #include <stdio.h>
73 #include <stdint.h>
74 #include <X11/Intrinsic.h>
75 #include <Xm/Xm.h>
76 #include <Xm/DialogS.h>
77 #include <Xm/Form.h>
78 #include <Xm/ToggleB.h>
79 #include <Dt/PrintOptionsP.h>
80
81 #include "Dmx.h"
82 #include "DmxPrintOptions.h"
83 #include "DtMail.hh"
84 #include "DtMailError.hh"
85 #include "dtmailopts.h"
86 #include "IndexedOptionMenuUiItem.hh"
87 #include "MailMsg.h"
88 #include "RoamApp.h"
89 #include "TextFieldUiItem.hh"
90
91 #define DMX_ARRAY_SIZE(ary)     (sizeof((ary))/sizeof((ary)[0]))
92
93 static DmxpoPropKey hdrftr_keys[] =
94 {
95     { (int) DTPRINT_OPTION_HEADER_LEFT,
96       DMX_PROPKEY_HEADER_LEFT,
97       DMX_PROPVAL_SUBJECT_HEADER
98     },
99     { (int) DTPRINT_OPTION_HEADER_RIGHT,
100       DMX_PROPKEY_HEADER_RIGHT,
101       DMX_PROPVAL_EMPTY
102     },
103     { (int) DTPRINT_OPTION_FOOTER_LEFT,
104       DMX_PROPKEY_FOOTER_LEFT,
105       DMX_PROPVAL_USER_NAME
106     },
107     { (int) DTPRINT_OPTION_FOOTER_RIGHT,
108       DMX_PROPKEY_FOOTER_RIGHT,
109       DMX_PROPVAL_PAGE_NUMBER
110     }
111 };
112
113 static DmxpoPropKey margin_keys[] =
114 {
115     { (int) DTPRINT_OPTION_MARGIN_TOP,
116       DMX_PROPKEY_MARGIN_TOP,
117       DMX_PROPVAL_DFLT_MARGIN
118     },
119     { (int) DTPRINT_OPTION_MARGIN_LEFT,
120       DMX_PROPKEY_MARGIN_LEFT,
121       DMX_PROPVAL_DFLT_MARGIN
122     },
123     { (int) DTPRINT_OPTION_MARGIN_BOTTOM,
124       DMX_PROPKEY_MARGIN_BOTTOM,
125       DMX_PROPVAL_DFLT_MARGIN
126     },
127     { (int) DTPRINT_OPTION_MARGIN_RIGHT,
128       DMX_PROPKEY_MARGIN_RIGHT,
129       DMX_PROPVAL_DFLT_MARGIN
130     }
131 };
132
133 static DmxpoPropValue hdrftr_values[] =
134 {
135     { (int) DMX_NONE_STRING,
136       DMX_PROPVAL_EMPTY,
137       22, 1, "Empty"
138     },
139     { (int) DMX_CC_HEADER_STRING,
140       DMX_PROPVAL_CC_HEADER,
141       22, 2, "CC Header"
142     },
143     { (int) DMX_DATE_HEADER_STRING,
144       DMX_PROPVAL_DATE_HEADER,
145       22, 3, "Date Header"
146     },
147     { (int) DMX_FROM_HEADER_STRING,
148       DMX_PROPVAL_FROM_HEADER,
149       22, 4, "From Header"
150     },
151     { (int) DMX_SUBJECT_HEADER_STRING,
152       DMX_PROPVAL_SUBJECT_HEADER,
153       22, 5, "Subject Header"
154     },
155     { (int) DMX_TO_HEADER_STRING,
156       DMX_PROPVAL_TO_HEADER,
157       22, 6, "To Header"
158     },
159     { (int) DMX_PAGE_NUMBER_STRING,
160       DMX_PROPVAL_PAGE_NUMBER,
161       22, 7, "Page Number"
162     },
163     { (int) DMX_USER_NAME_STRING,
164       DMX_PROPVAL_USER_NAME,
165       22, 8, "User Name"
166     }
167 };
168                                     
169 static DmxpoPropValue prthdr_values[] =
170 {
171     { (int) DMX_PRINT_HEADERS_NONE,
172       DMX_PROPVAL_NONE,
173       23, 1, "None" },
174     { (int) DMX_PRINT_HEADERS_STANDARD,
175       DMX_PROPVAL_STANDARD,
176       23, 2, "Standard" },
177     { (int) DMX_PRINT_HEADERS_ABBREV,
178       DMX_PROPVAL_ABBREVIATED,
179       23, 3, "Abbreviated" },
180     { (int) DMX_PRINT_HEADERS_ALL,
181       DMX_PROPVAL_ALL,
182       23, 4, "All" }
183 };
184                                     
185 static DmxpoPropValue msgsep_values[] =
186 {
187     { (int) DMX_SEPARATOR_NEW_LINE,
188       DMX_PROPVAL_NEW_LINE,
189       24, 1, "New Line" },
190     { (int) DMX_SEPARATOR_BLANK_LINE,
191       DMX_PROPVAL_BLANK_LINE,
192       24, 2, "Blank Line" },
193     { (int) DMX_SEPARATOR_CHARACTER_LINE,
194       DMX_PROPVAL_CHARACTER_LINE,
195       24, 3, "Character Line" },
196     { (int) DMX_SEPARATOR_PAGE_BREAK,
197       DMX_PROPVAL_PAGE_BREAK,
198       24, 4, "New Page" }
199 };
200                                     
201
202
203 DmxPrintOptions::DmxPrintOptions (
204                                 Widget parent
205                                 ) : UIComponent( "PrintOptions" )
206 {
207     IndexedOptionMenu   *iom = (IndexedOptionMenu *) NULL;
208     PropUiItem          *pui = (PropUiItem  *) NULL;
209     Widget              *menu_buttons, w;
210     int                 nitems;
211     char                **strings;
212     void                **data;
213     XmString            xms;
214     int                 i, j, nhdrftrs;
215
216     _iom_array = new DtVirtArray<IndexedOptionMenu *>(10);
217     _propui_array = new DtVirtArray<PropUiItem *>(10);
218     _propui_array_iterator = 0;
219     _parent = parent;
220     _prop_source = NULL;
221
222     //
223     //  Create form to hold the printing options
224     //
225     _form = XtVaCreateWidget(
226                                 "PrintingOptionsPane",
227                                 xmFormWidgetClass,
228                                 _parent,
229                                 XmNbottomAttachment, XmATTACH_FORM,
230                                 XmNrightAttachment, XmATTACH_FORM,
231                                 XmNleftAttachment, XmATTACH_FORM,
232                                 XmNtopAttachment, XmATTACH_FORM,
233                                 XmNresizePolicy, XmRESIZE_ANY,
234                                 NULL
235                                 );
236     if (_form == (Widget) NULL) return;
237     _w = _form;
238     installDestroyHandler();
239
240     //
241     //  Create GUI for the Header/Footer options
242     //
243     nitems = DMX_ARRAY_SIZE(hdrftr_values);;
244     strings = (char **) XtMalloc( nitems * sizeof(char*) );
245     data = (void **) XtMalloc( nitems * sizeof(void*) );
246     for (i=0; i<nitems; i++)
247     {
248         data[i] = (void*) hdrftr_values[i].prop_string;
249         strings[i] = GETMSG(
250                         DT_catd, 
251                         hdrftr_values[i].set_id, 
252                         hdrftr_values[i].msg_id,
253                         hdrftr_values[i].dflt_string
254                         );
255     }
256
257     _hdrftr_frame = _DtPrintCreateHdrFtrFrame( _form, nitems, strings, data);
258     XtVaSetValues(
259                 _hdrftr_frame,
260                 XmNtopAttachment, XmATTACH_FORM,
261                 XmNleftAttachment, XmATTACH_FORM,
262                 NULL
263                 );
264     XtManageChild(_hdrftr_frame);
265
266     //
267     //  Create PropUiItem's for the Header/Footer options
268     //
269     menu_buttons = NULL;
270     _DtPrintHdrFtrFrameMenuWidgets( _hdrftr_frame, NULL, NULL, &menu_buttons);
271     for (j=0, nhdrftrs=DMX_ARRAY_SIZE(hdrftr_keys); j<nhdrftrs; j++)
272     {
273         w = _DtPrintHdrFtrFrameEnumToWidget(
274                                 _hdrftr_frame,
275                                 (_DtPrintHdrFtrEnum) hdrftr_keys[j].which
276                                 );
277         iom =
278           new IndexedOptionMenu(w, nitems, (char**)strings, data, menu_buttons);
279         iom->manage();
280         _iom_array->append(iom);
281
282         pui = (PropUiItem *) new IndexedOptionMenuUiItem(
283                                                         iom,
284                                                         _FROM_MAILRC,
285                                                         hdrftr_keys[j].key
286                                                         );
287         _propui_array->append(pui);
288     }
289     XtFree((char*) menu_buttons);
290     XtFree((char*) data);
291     XtFree((char*) strings);
292
293
294     //
295     //  Create GUI for the Margin options
296     //
297     _margin_frame = _DtPrintCreateMarginFrame(_form);
298     XtVaSetValues(
299                 _margin_frame,
300                 XmNtopAttachment, XmATTACH_WIDGET,
301                 XmNtopWidget, _hdrftr_frame,
302                 XmNleftAttachment, XmATTACH_FORM,
303                 NULL
304                 );
305     XtManageChild(_margin_frame);
306
307     //
308     //  Create PropUiItem's for the Margin options
309     //
310     nitems = DMX_ARRAY_SIZE(margin_keys);
311     for (j=0; j<nitems; j++)
312     {
313         w = _DtPrintMarginFrameEnumToWidget(
314                                 _margin_frame,
315                                 (_DtPrintMarginEnum) margin_keys[j].which
316                                 );
317         pui = (PropUiItem *) new TextFieldUiItem(
318                                         w,
319                                         _FROM_MAILRC,
320                                         margin_keys[j].key,
321                                         DmxPrintOptions::isValidMarginSpec,
322                                         (void*) (intptr_t) margin_keys[j].which);
323         _propui_array->append(pui);
324     }
325
326
327     //
328     //  Create GUI for the Printed Headers option
329     //
330     nitems = DMX_ARRAY_SIZE(prthdr_values);;
331     strings = (char **) XtMalloc( nitems * sizeof(char*) );
332     data = (void **) XtMalloc( nitems * sizeof(void*) );
333     for (i=0; i<nitems; i++)
334     {
335         data[i] = (void*) prthdr_values[i].prop_string;
336         strings[i] = GETMSG(
337                         DT_catd, 
338                         prthdr_values[i].set_id, 
339                         prthdr_values[i].msg_id,
340                         prthdr_values[i].dflt_string
341                         );
342     }
343
344     iom = new IndexedOptionMenu(_form, nitems, (char**) strings, data);
345     xms = XmStringCreateLocalized(
346                 GETMSG(DT_catd, 25, 1, "Printed Message Headers:  ")
347                 );
348     XtVaSetValues(
349                 iom->baseWidget(),
350                 XmNlabelString, xms,
351                 XmNtopAttachment, XmATTACH_WIDGET,
352                 XmNtopWidget, _margin_frame,
353                 XmNrightAttachment, XmATTACH_FORM,
354                 XmNleftAttachment, XmATTACH_FORM,
355                 NULL
356                 );
357     iom->manage();
358     _prthdr_iom = iom;
359     _iom_array->append(iom);
360
361     XmStringFree(xms);
362     XtFree((char*) strings);
363     XtFree((char*) data);
364
365     //
366     //  Create PropUiItem for the Printed Headers option
367     //
368     pui = (PropUiItem *) new IndexedOptionMenuUiItem(
369                                                 iom,
370                                                 _FROM_MAILRC,
371                                                 DMX_PROPKEY_PRINT_HEADERS
372                                                 );
373     _propui_array->append(pui);
374
375
376     //
377     //  Create GUI for the Message Separator option
378     //
379     nitems = DMX_ARRAY_SIZE(msgsep_values);;
380     strings = (char **) XtMalloc( nitems * sizeof(char*) );
381     data = (void **) XtMalloc( nitems * sizeof(void*) );
382     for (i=0; i<nitems; i++)
383     {
384         data[i] = (void*) msgsep_values[i].prop_string;
385         strings[i] = GETMSG(
386                         DT_catd, 
387                         msgsep_values[i].set_id, 
388                         msgsep_values[i].msg_id,
389                         msgsep_values[i].dflt_string
390                         );
391     }
392
393     iom = new IndexedOptionMenu(_form, nitems, (char**) strings, data);
394     xms = XmStringCreateLocalized(
395                 GETMSG( DT_catd, 25, 2, "Separate Multiple Messages With:  ")
396                 );
397     XtVaSetValues(
398                 iom->baseWidget(),
399                 XmNlabelString, xms,
400                 XmNtopAttachment, XmATTACH_WIDGET,
401                 XmNtopWidget, _prthdr_iom->baseWidget(),
402                 XmNrightAttachment, XmATTACH_FORM,
403                 XmNleftAttachment, XmATTACH_FORM,
404                 XmNbottomAttachment, XmATTACH_FORM,
405                 NULL
406                 );
407     iom->manage();
408     _iom_array->append(iom);
409     _msgsep_iom = iom;
410
411     XmStringFree(xms);
412     XtFree((char*) strings);
413     XtFree((char*) data);
414
415     //
416     //  Create PropUiItem for the Message Separator option
417     //
418     pui = (PropUiItem *) new IndexedOptionMenuUiItem(
419                                                 iom,
420                                                 _FROM_MAILRC,
421                                                 DMX_PROPKEY_MESSAGE_SEPARATOR);
422     _propui_array->append(pui);
423
424     //XtRealizeWidget(_w);
425     //XtManageChild(_w);
426 }
427
428
429 DmxPrintOptions::~DmxPrintOptions (void)
430 {
431     int i;
432     PropUiItem          *pui;;
433     IndexedOptionMenu   *iom;
434
435     if (_propui_array)
436       for (i=0; i<_propui_array->length(); i++)
437       {
438           pui = (*_propui_array)[i];
439           delete pui;
440       }
441
442     if (_iom_array)
443       for (i=0; i<_iom_array->length(); i++)
444       {
445           iom = (*_iom_array)[i];
446           delete iom;
447       }
448
449     if (_w)
450       XtDestroyWidget(_w);
451 }
452
453 PropUiItem *
454 DmxPrintOptions::getFirstProp(void)
455 {
456     _propui_array_iterator = 0;
457     return getNextProp();
458 }
459
460 PropUiItem *
461 DmxPrintOptions::getNextProp(void)
462 {
463     PropUiItem  *pui = (PropUiItem  *) NULL;
464
465     if (_propui_array_iterator < _propui_array->length())
466     {
467         pui = (*_propui_array)[_propui_array_iterator];
468         _propui_array_iterator++;
469     }
470     return pui;
471 }
472
473 int
474 DmxPrintOptions::getNumProps(void)
475 {
476     return _propui_array->length();
477 }
478
479 const char *
480 DmxPrintOptions::getSeparatorString(void)
481 {
482     DtMail::Session     *d_session = NULL;
483     DtMail::MailRc      *m_rc = NULL;
484     DtMailEnv           error;
485     const char          *string = NULL;
486     char                *dflt = "-";
487
488     d_session = theRoamApp.session()->session();
489     m_rc = d_session->mailRc(error);
490
491     m_rc->getValue(error, DMX_PROPKEY_SEPARATOR_STRING, &string);
492     if (string == NULL || error.isSet())
493       return strdup(dflt);
494
495     return string;
496 }
497
498 DmxStringTypeEnum
499 DmxPrintOptions::getHdrFtrSpec(_DtPrintHdrFtrEnum which)
500 {
501     DtMail::Session     *d_session = NULL;
502     DtMail::MailRc      *m_rc = NULL;
503     DtMailEnv           error;
504     DmxpoPropKey        *key;
505     const char          *string = NULL;
506     DmxpoPropValue      *value = NULL;
507     DmxStringTypeEnum   rtn = DMX_NONE_STRING;
508
509     d_session = theRoamApp.session()->session();
510     m_rc = d_session->mailRc(error);
511
512     key = DmxPrintOptions::enumToPropKey(
513                                 which,
514                                 DMX_ARRAY_SIZE(hdrftr_keys),
515                                 hdrftr_keys
516                                 );
517
518     if (key != NULL)
519     {
520         m_rc->getValue(error, key->key , &string);
521         if (string == NULL || error.isSet())
522           string = strdup(key->dflt_prop_string);
523     }
524     else
525       return rtn;
526
527     value = stringToPropValue(
528                         string,
529                         DMX_ARRAY_SIZE(hdrftr_values),
530                         hdrftr_values);
531     if (value != NULL)
532       rtn = (DmxStringTypeEnum) value->which;
533
534     if (NULL != string)
535       free((void*) string);
536
537     return rtn;
538 }
539
540 const char *
541 DmxPrintOptions::getMarginSpec(_DtPrintMarginEnum which)
542 {
543     DtMail::Session     *d_session = NULL;
544     DtMail::MailRc      *m_rc = NULL;
545     DtMailEnv           error;
546     DmxpoPropKey        *key;
547     const char          *string = NULL;
548
549     d_session = theRoamApp.session()->session();
550     m_rc = d_session->mailRc(error);
551
552     key = DmxPrintOptions::enumToPropKey(
553                                 which,
554                                 DMX_ARRAY_SIZE(margin_keys),
555                                 margin_keys
556                                 );
557
558     if (key == NULL)
559       return DMX_PROPVAL_DFLT_MARGIN;
560
561     m_rc->getValue(error, key->key , &string);
562     if (string == NULL || error.isSet())
563       string = strdup(key->dflt_prop_string);
564
565     return string;
566 }
567
568 DmxMsgSeparatorEnum
569 DmxPrintOptions::getMessageSeparator(void)
570 {
571     DtMail::Session     *d_session = NULL;
572     DtMail::MailRc      *m_rc = NULL;
573     DtMailEnv           error;
574     const char          *string = NULL;
575     DmxpoPropValue      *value = NULL;
576     DmxMsgSeparatorEnum rtn = DMX_SEPARATOR_PAGE_BREAK;
577
578     d_session = theRoamApp.session()->session();
579     m_rc = d_session->mailRc(error);
580
581     m_rc->getValue(error, DMX_PROPKEY_MESSAGE_SEPARATOR , &string);
582     if (string == NULL || error.isSet())
583       return rtn;
584
585     value = stringToPropValue(
586                         string,
587                         DMX_ARRAY_SIZE(msgsep_values),
588                         msgsep_values);
589     if (value != NULL)
590       rtn = (DmxMsgSeparatorEnum) value->which;
591
592     if (NULL != string)
593       free((void*) string);
594
595     return rtn;
596 }
597
598 DmxPrintHeadersEnum
599 DmxPrintOptions::getPrintedHeaders(void)
600 {
601     DtMail::Session     *d_session = NULL;
602     DtMail::MailRc      *m_rc = NULL;
603     DtMailEnv           error;
604     const char          *string = NULL;
605     DmxpoPropValue      *value = NULL;
606     DmxPrintHeadersEnum rtn = DMX_PRINT_HEADERS_STANDARD;
607
608     d_session = theRoamApp.session()->session();
609     m_rc = d_session->mailRc(error);
610
611     m_rc->getValue(error, DMX_PROPKEY_PRINT_HEADERS , &string);
612     if (string == NULL || error.isSet())
613       return rtn;
614
615     value = stringToPropValue(
616                         string,
617                         DMX_ARRAY_SIZE(prthdr_values),
618                         prthdr_values);
619     if (value != NULL)
620       rtn = (DmxPrintHeadersEnum) value->which;
621
622     if (NULL != string)
623       free((void*) string);
624
625     return rtn;
626 }
627
628 DmxpoPropKey *
629 DmxPrintOptions::enumToPropKey(int which, int nkeys, DmxpoPropKey *keys)
630 {
631     for (int i=0; i<nkeys; i++)
632       if (keys[i].which == which)
633         return &(keys[i]);
634     
635     return NULL;
636 }
637
638 PropUiItem *
639 DmxPrintOptions::propKeyToPropItem(char *key)
640 {
641     for (int i=0; i<_propui_array->length(); i++)
642     {
643         PropUiItem      *pui;
644         char            *puikey;
645
646         pui = (*_propui_array)[i];
647         puikey = pui->getKey();
648         if (strcmp(puikey, key) == 0)
649           return pui;
650     }
651     
652     return NULL;
653 }
654
655 DmxpoPropValue *
656 DmxPrintOptions::stringToPropValue(
657                                 const char *string,
658                                 int nvalues,
659                                 DmxpoPropValue *values
660                                 )
661 {
662     for (int i=0; i<nvalues; i++)
663       if (strcmp(values[i].prop_string, string) == 0)
664         return &(values[i]);
665     
666     return NULL;
667 }
668
669 char *
670 DmxPrintOptions::isValidMarginSpec(PropUiItem* pui, void* data)
671 {
672     char        *i18nMsg;
673     char        *errMsg = NULL;
674     char        *marginSpec = NULL;
675     XtEnum      parseError;
676     Widget      text;
677
678     _DtPrintMarginEnum which = (_DtPrintMarginEnum)(long)data;
679
680     text = pui->getWidget();
681     if (text)
682       marginSpec = _DtPrintGetMarginSpec(text);
683
684     parseError = FALSE;
685     if (marginSpec == NULL || strcmp("", marginSpec) == 0)
686       parseError = TRUE;
687     else 
688       (void) XmConvertStringToUnits(
689                                 XtScreenOfObject(text),
690                                 marginSpec,
691                                 XmVERTICAL,
692                                 XmPIXELS,
693                                 &parseError);
694  
695     if (! parseError) return NULL;
696  
697     switch (which)
698     {
699       case DTPRINT_OPTION_MARGIN_TOP:
700         i18nMsg =
701           GETMSG(DT_catd, 26, 1, "Top Margin specifier is invalid:  ");
702         break;
703       case DTPRINT_OPTION_MARGIN_RIGHT:
704         i18nMsg =
705           GETMSG(DT_catd, 26, 2, "Right Margin specifier is invalid:  ");
706         break;
707       case DTPRINT_OPTION_MARGIN_BOTTOM:
708         i18nMsg =
709           GETMSG(DT_catd, 26, 3, "Bottom Margin specifier is invalid:  ");
710         break;
711       case DTPRINT_OPTION_MARGIN_LEFT:
712         i18nMsg =
713           GETMSG(DT_catd, 26, 4, "Left Margin specifier is invalid:  ");
714         break;
715     }
716     errMsg = (char*) XtMalloc(strlen(i18nMsg) + strlen(marginSpec) + 1);
717     sprintf(errMsg, "%s%s", i18nMsg, marginSpec);
718     
719     return errMsg;
720 }