%%IncludeFeature: functionality not working correctly #2831

Closed
michaelrsweet opened this Issue May 22, 2008 · 6 comments

Comments

Projects
None yet
1 participant
Collaborator

michaelrsweet commented May 22, 2008

Version: 1.3.7
CUPS.org User: sbalneav

Per OpenOffice bug #65491:
http://www.openoffice.org/issues/show_bug.cgi?id=65491

OpenOffice moved from a %%BeginFeature/%%EndFeature to an %%IncludeFeature style for selecting features to include. Notibly (in my case) selecting InputSlots for multibin printing (we work in an office environment, and it's quite common to have a document that has the first page pulling letterhead from bin 2, plain from bin 3, and an envelope from the envelope feeder)

I think I've found 2 problems with the pstops filter:

  1. doc_setup was being called before the search for IncludeFeatures was being run. Therefore, options that were added after the doc_setup weren't being cupsMark'd and ppdEmit'd Fixed this by moving the doc_setup call to after the search and insert_feature calls.
  2. No search for IncludeFeatures was being done in the %%BeginPageSetup/%%EndPageSetup region. So, if the input tray was changed for one page, it wasn't being picked up at all. Fixed this by moving the search code earlier, and adding a check for %%IncludeFeature

I've attached a patch.

Oh, BTW, tell Till Scott says Hi! :)

Cheers!
Scott

Collaborator

michaelrsweet commented May 22, 2008

CUPS.org User: mike

Will look at your patch.

BTW, Till doesn't work on and isn't affiliated with the CUPS project.

Collaborator

michaelrsweet commented May 23, 2008

CUPS.org User: sbalneav

Oh! Man, sorry, thought he was, heh!

Thanks for looking at the patch. Let me know if you need examples of the postscript that OO.o spits out.

Cheers!

Scott

Collaborator

michaelrsweet commented Jun 11, 2008

CUPS.org User: mike

OK, the patch has some problems in that it doesn't copy the page setup commands if this isn't the first page of an N-up sheet.

Working on a variation that doesn't have this problem...

Collaborator

michaelrsweet commented Jun 11, 2008

CUPS.org User: mike

Fixed in Subversion repository.

Updated patch is attached.

Collaborator

michaelrsweet commented Jun 11, 2008

"pstops.patch":

--- cupsys-1.3.7/filter/pstops.c 2008-01-14 16:12:58.000000000 -0600
+++ cupsys-1.3.7-sbalneav/filter/pstops.c 2008-05-22 14:41:47.000000000 -0500
@@ -1512,6 +1512,54 @@

 doc_puts(doc, "%%BeginPageSetup\n");
  • /*
  • \* Copy page setup commands as needed...
    
  • */
    
  • if (!strncmp(line, "%%BeginPageSetup", 16))
  • {
  •  int  feature = 0;        /\* In a Begin/EndFeature block? */
    
  •  while ((linelen = cupsFileGetLine(fp, line, linesize)) > 0)
    
  •  {
    
  •    if (!strncmp(line, "%%EndPageSetup", 14))
    
  •      break;
    
  •    else if (!strncmp(line, "%%BeginFeature:", 15))
    
  •    {
    
  •      feature = 1;
    
  • if (doc->number_up > 1 || doc->fitplot)
    
  •   continue;
    
  •    }
    
  •    else if (!strncmp(line, "%%EndFeature", 12))
    
  •    {
    
  •      feature = 0;
    
  • if (doc->number_up > 1 || doc->fitplot)
    
  •   continue;
    
  •    }
    
  •    else if (!strncmp(line, "%%IncludeFeature:", 17))
    
  •    {
    
  • pageinfo->num_options = include_feature(ppd, line,
    
  •                                         pageinfo->num_options,
    
  •                                         &(pageinfo->options));
    
  •      continue;
    
  •    }
    
  •    else if (!strncmp(line, "%%Include", 9))
    
  •      continue;
    
  •    if (!feature || (doc->number_up == 1 && !doc->fitplot))
    
  • doc_write(doc, line, linelen);
    
  •  }
    
  • /*
    
  •  \* Skip %%EndPageSetup...
    
  •  */
    
  •  if (linelen > 0)
    
  •    linelen = cupsFileGetLine(fp, line, linesize);
    
  • }

if (pageinfo->num_options > 0)
{
int i; /* Looping var */
@@ -1581,48 +1629,6 @@
start_nup(doc, number, 1, bounding_box);

/*

  • * Copy page setup commands as needed...

- */

  • if (!strncmp(line, "%%BeginPageSetup", 16))
  • {

- int feature = 0; /* In a Begin/EndFeature block? */

  • while ((linelen = cupsFileGetLine(fp, line, linesize)) > 0)
  • {
  •  if (!strncmp(line, "%%EndPageSetup", 14))
    
  •    break;
    
  •  else if (!strncmp(line, "%%BeginFeature:", 15))
    
  •  {
    

- feature = 1;

  • if (doc->number_up > 1 || doc->fitplot)
  • continue;
    
  •  }
    
  •  else if (!strncmp(line, "%%EndFeature", 12))
    
  •  {
    

- feature = 0;

  • if (doc->number_up > 1 || doc->fitplot)
  • continue;
    
  •  }
    
  •  else if (!strncmp(line, "%%Include", 9))
    

- continue;

  •  if (!feature || (doc->number_up == 1 && !doc->fitplot))
    
  • doc_write(doc, line, linelen);

- }

  • /*
  • * Skip %%EndPageSetup...

- */

  • if (linelen > 0)
  •  linelen = cupsFileGetLine(fp, line, linesize);
    

- }

  • /*
    • Finish the PageSetup section as needed...
      */

@@ -1789,8 +1795,6 @@

doc_puts(doc, "%%BeginSetup\n");

- do_setup(doc, ppd);

if (!strncmp(line, "%%BeginSetup", 12))
{
while (strncmp(line, "%%EndSetup", 10))
@@ -1820,6 +1824,8 @@
fputs(_("ERROR: Missing %%EndSetup!\n"), stderr);
}

  • do_setup(doc, ppd);

doc_puts(doc, "%%EndSetup\n");

return (linelen);

Collaborator

michaelrsweet commented Jun 11, 2008

"str2831.patch":

Index: filter/pstops.c

--- filter/pstops.c (revision 7636)
+++ filter/pstops.c (working copy)
@@ -1506,12 +1506,57 @@
*/

if (first_page)

  • doc_puts(doc, "%%BeginPageSetup\n");
  • if (!strncmp(line, "%%BeginPageSetup", 16))
    {
  • int feature = 0; /* In a Begin/EndFeature block? */
  • while ((linelen = cupsFileGetLine(fp, line, linesize)) > 0)
  • {
  •  if (!strncmp(line, "%%EndPageSetup", 14))
    
  • break;
  •  else if (!strncmp(line, "%%BeginFeature:", 15))
    
  •  {
    
  • feature = 1;
  • if (doc->number_up > 1 || doc->fitplot)
  • continue;
    
  •  }
    
  •  else if (!strncmp(line, "%%EndFeature", 12))
    
  •  {
    
  • feature = 0;
  • if (doc->number_up > 1 || doc->fitplot)
  • continue;
    
  •  }
    
  •  else if (!strncmp(line, "%%IncludeFeature:", 17))
    
  •  {
    
  • pageinfo->num_options = include_feature(ppd, line,
  •                   pageinfo->num_options,
    
  •                   &(pageinfo->options));
    
  • continue;
  •  }
    
  •  else if (!strncmp(line, "%%Include", 9))
    
  • continue;
  •  if (!feature || (doc->number_up == 1 && !doc->fitplot))
    
  • doc_write(doc, line, linelen);
  • }
  • /*
  • * Skip %%EndPageSetup...
  • */
  • if (linelen > 0)
  •  linelen = cupsFileGetLine(fp, line, linesize);
    
  • }
  • if (first_page)
  • {
    char page_setup; / PageSetup commands to send */

- doc_puts(doc, "%%BeginPageSetup\n");

 if (pageinfo->num_options > 0)
 {
   int      i;      /* Looping var */

@@ -1581,48 +1626,6 @@
start_nup(doc, number, 1, bounding_box);

/*

  • * Copy page setup commands as needed...

- */

  • if (!strncmp(line, "%%BeginPageSetup", 16))
  • {

- int feature = 0; /* In a Begin/EndFeature block? */

  • while ((linelen = cupsFileGetLine(fp, line, linesize)) > 0)
  • {
  •  if (!strncmp(line, "%%EndPageSetup", 14))
    
  •    break;
    
  •  else if (!strncmp(line, "%%BeginFeature:", 15))
    
  •  {
    

- feature = 1;

  • if (doc->number_up > 1 || doc->fitplot)
  • continue;
    
  •  }
    
  •  else if (!strncmp(line, "%%EndFeature", 12))
    
  •  {
    

- feature = 0;

  • if (doc->number_up > 1 || doc->fitplot)
  • continue;
    
  •  }
    
  •  else if (!strncmp(line, "%%Include", 9))
    

- continue;

  •  if (!feature || (doc->number_up == 1 && !doc->fitplot))
    
  • doc_write(doc, line, linelen);

- }

  • /*
  • * Skip %%EndPageSetup...

- */

  • if (linelen > 0)
  •  linelen = cupsFileGetLine(fp, line, linesize);
    

- }

  • /*
    • Finish the PageSetup section as needed...
      */

@@ -1789,8 +1792,6 @@

doc_puts(doc, "%%BeginSetup\n");

- do_setup(doc, ppd);

if (!strncmp(line, "%%BeginSetup", 12))
{
while (strncmp(line, "%%EndSetup", 10))
@@ -1820,6 +1821,8 @@
fputs(_("ERROR: Missing %%EndSetup!\n"), stderr);
}

  • do_setup(doc, ppd);

doc_puts(doc, "%%EndSetup\n");

return (linelen);

@michaelrsweet michaelrsweet added this to the Stable milestone Mar 17, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment