time | Calls | line |
---|
| | 1 | function pj = validate( pj )
|
| | 2 | %VALIDATE Method to check state of PrintJob object.
|
| | 3 | % Values of PrintJob object class variables are checked for consistency.
|
| | 4 | % Errors out if it finds bad combinations. Fills in missing data with
|
| | 5 | % defaults.
|
| | 6 | %
|
| | 7 | % Ex:
|
| | 8 | % pj = VALIDATE( pj );
|
| | 9 | %
|
| | 10 | % See also PRINT, PRINTOPT, INPUTCHECK.
|
| | 11 |
|
| | 12 | % Copyright 1984-2016 The MathWorks, Inc.
|
| | 13 |
|
< 0.001 | 1 | 14 | pj.Validated = 1;
|
| | 15 |
|
| | 16 | %If no window requested, and none to act as default, error out.
|
0.003 | 1 | 17 | pj = validateHandleToPrint(pj);
|
| | 18 |
|
< 0.001 | 1 | 19 | if ~pj.UseOriginalHGPrinting
|
| | 20 | % for future use
|
< 0.001 | 1 | 21 | if pj.RGBImage
|
| | 22 | if ~isempty(pj.Driver)
|
| | 23 | error(message('MATLAB:print:IncompatibleRGBImageOptionNoDriver', pj.Driver));
|
| | 24 | end
|
| | 25 |
|
| | 26 | if ~isempty(pj.FileName)
|
| | 27 | error(message('MATLAB:print:IncompatibleRGBImageOptionFilename'));
|
| | 28 | end
|
| | 29 |
|
| | 30 | if ~isempty(pj.PrinterName)
|
| | 31 | error(message('MATLAB:print:IncompatibleRGBImageOptionPrinter'));
|
| | 32 | end
|
| | 33 | end
|
| | 34 |
|
< 0.001 | 1 | 35 | if pj.ClipboardOption
|
| | 36 | if ~isempty(pj.FileName)
|
| | 37 | error(message('MATLAB:print:IncompatibleClipboardOptionFilename'));
|
| | 38 | end
|
| | 39 |
|
| | 40 | if ~isempty(pj.PrinterName)
|
| | 41 | error(message('MATLAB:print:IncompatibleClipboardOptionPrinter'));
|
| | 42 | end
|
| | 43 |
|
| | 44 | if isempty(pj.Driver)
|
| | 45 | error(message('MATLAB:print:IncompatibleClipboardOptionNoDriver'));
|
| | 46 | end
|
| | 47 |
|
| | 48 | if ~pj.DriverClipboard %driver doesn't support clipboard
|
| | 49 | error(message('MATLAB:print:IncompatibleClipboardOptionDriver', pj.Driver));
|
| | 50 | end
|
| | 51 |
|
| | 52 | end
|
< 0.001 | 1 | 53 | end
|
| | 54 |
|
< 0.001 | 1 | 55 | if pj.PostScriptPreview && ~strcmp(pj.DriverClass,'EP')
|
| | 56 | error(message('MATLAB:print:ValidateTiffPreviewOnlyWithEPS'))
|
| | 57 | end
|
| | 58 |
|
| | 59 | %If no device given, use default from PRINTOPT
|
< 0.001 | 1 | 60 | if ~pj.RGBImage && isempty( pj.Driver )
|
| | 61 | %Use method to validate default and set related class variables
|
| | 62 | wasError = 0;
|
| | 63 | try
|
| | 64 | pj = inputcheck( pj, pj.DefaultDevice );
|
| | 65 | pj.DriverColorSet = 0;
|
| | 66 | catch ex %#ok<NASGU>
|
| | 67 | wasError = 1;
|
| | 68 | end
|
| | 69 | if wasError || isempty( pj.Driver )
|
| | 70 | error(message('MATLAB:print:ValidateUnknownDeviceType', pj.DefaultDevice));
|
| | 71 | end
|
| | 72 | end
|
| | 73 |
|
< 0.001 | 1 | 74 | if strcmp(pj.DriverClass, 'MW' )
|
| | 75 | if isunix
|
| | 76 | error(message('MATLAB:print:ValidateUseWindowsDriver', pj.Driver));
|
| | 77 | end
|
| | 78 |
|
| | 79 | % If user specifies a filename while device is -dwin
|
| | 80 | % or -dwinc, either because the user gave that device or, more
|
| | 81 | % likely, it's the default, and since the filename is useless
|
| | 82 | % with Windows driver anyway, we'll assume the user really wants
|
| | 83 | % a PostScript file. This is because 'print foo' is easier
|
| | 84 | % to type then 'print -dps foo' and probably more commonly
|
| | 85 | % meant if a filename is given. Unless of course the user asked
|
| | 86 | % for the Print Dialog with the -v flag, then s/he really meant it.
|
| | 87 | if (~isempty(pj.FileName) && ~pj.Verbose ) ...
|
| | 88 | && ( strcmp(pj.Driver, 'win') || strcmp(pj.Driver, 'winc') )
|
| | 89 | if pj.DriverColor
|
| | 90 | pj.Driver = 'psc';
|
| | 91 | else
|
| | 92 | pj.Driver = 'ps';
|
| | 93 | end
|
| | 94 | pj.DriverExt = 'ps';
|
| | 95 | pj.DriverClass = 'PS';
|
| | 96 | end
|
| | 97 | end
|
| | 98 |
|
| | 99 | %TIFF previews imply -loose, historically because ZBuffer TIFF was always "loose".
|
< 0.001 | 1 | 100 | if pj.PostScriptPreview == pj.TiffPreview
|
| | 101 | pj.PostScriptTightBBox = 0;
|
| | 102 | end
|
| | 103 |
|
< 0.001 | 1 | 104 | h = pj.Handles{1}(1);
|
| | 105 |
|
| | 106 | % Validate use of fillpage/bestfit options
|
| | 107 | % can't do -fillpage and -bestfit at same time
|
| | 108 | % must be with a page format (PS, PDF, or Printer)
|
| | 109 | % must be with a figure (not SL or SF)
|
< 0.001 | 1 | 110 | isfig = isfigure(h);
|
0.001 | 1 | 111 | isPage = locIsPageFormatOrPrinter(pj);
|
< 0.001 | 1 | 112 | isAuto = strcmp(get(h, 'PaperPositionMode'), 'auto');
|
< 0.001 | 1 | 113 | if pj.FillPage || pj.BestFit
|
| | 114 | if pj.FillPage
|
| | 115 | option = 'fillpage';
|
| | 116 | else
|
| | 117 | option = 'bestfit';
|
| | 118 | end
|
| | 119 | % must be with figure (not SL/SF)
|
| | 120 | % can't do -fillpage and -bestfit at same time
|
| | 121 | % must be with a page format (PS, PDF, or Printer)
|
| | 122 | if ~isfig
|
| | 123 | error(message('MATLAB:print:OptionOnlyValidForFigures', option));
|
| | 124 | end
|
| | 125 |
|
| | 126 | if pj.FillPage && pj.BestFit
|
| | 127 | error(message('MATLAB:print:FillPageBestFitExclusive'));
|
| | 128 | end
|
| | 129 |
|
| | 130 | if ~isPage
|
| | 131 | error(message('MATLAB:print:OptionOnlyValidForPageFormats', option));
|
| | 132 | end
|
| | 133 |
|
| | 134 | end
|
< 0.001 | 1 | 135 | if isfig
|
| | 136 | % if printing to page format in 'auto' mode (and user hasn't specified either
|
| | 137 | % -bestfit or -fillpage), warn the user and offer suggestions if the output will get
|
| | 138 | % cropped (because figure is too large to fit on the page)
|
< 0.001 | 1 | 139 | if isPage && isAuto && ~(pj.FillPage || pj.BestFit)
|
| | 140 | paperPos = get(h, 'PaperPosition');
|
| | 141 | if any(paperPos(1:2) < 0)
|
| | 142 | warning(message('MATLAB:print:FigureTooLargeForPage'));
|
| | 143 | end
|
| | 144 | end
|
| | 145 | %Fill renderer and -noui from the printtemplate (if it exists) if
|
| | 146 | %the user didn't specify these options on the command line
|
< 0.001 | 1 | 147 | pt = getprinttemplate(h);
|
< 0.001 | 1 | 148 | if ~isempty(pt)
|
| | 149 | if ~pj.nouiOption
|
| | 150 | pj.PrintUI = pt.PrintUI;
|
| | 151 | end
|
| | 152 | if ~pj.rendererOption && ~strcmp( pt.Renderer, 'auto' )
|
| | 153 | pj.Renderer = pt.Renderer;
|
| | 154 | pj.rendererOption = 1; % overriding figure renderer
|
| | 155 | end
|
| | 156 | end
|
| | 157 |
|
< 0.001 | 1 | 158 | if ~pj.UseOriginalHGPrinting && (isfield(pj.temp, 'isFigureShowEnabled') && ...
|
| 1 | 159 | ~pj.temp.isFigureShowEnabled)
|
| | 160 | %If user did not specify -noui and there are visible uicontrols, error now
|
| | 161 | if ~pj.nouiOption && ~isempty(validateFindControls(h))
|
| | 162 | error(message('MATLAB:prepareui:UnsupportedPlatform'));
|
| | 163 | end
|
| | 164 | end
|
< 0.001 | 1 | 165 | end
|
Other subfunctions in this file are not included in this listing.