work on pspp-output modify command
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 27 Dec 2020 18:04:32 +0000 (10:04 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Sun, 27 Dec 2020 18:04:32 +0000 (10:04 -0800)
doc/pspp-output.texi
utilities/pspp-output.c

index f8b7931d735c20afb8979dd8850409867b4ad172..e6f6329a3049f5bb45c128c9ba9c3d346744760d 100644 (file)
@@ -46,6 +46,7 @@ developers may find useful for debugging.
 * The pspp-output detect Command::
 * The pspp-output dir Command::
 * The pspp-output convert Command::
+* The pspp-output modify Command::
 * The pspp-output get-table-look Command::
 * The pspp-output convert-table-look Command::
 * Input Selection Options::
@@ -123,6 +124,103 @@ output tables.  The file should be a TableLook @file{.stt} or
 @file{.tlo} file.
 @end table
 
+@node The pspp-output modify Command
+@section The @code{modify} Command
+
+@display
+@t{pspp-output} [@var{options}] @t{modify} @var{file} [@var{new-file}]
+@end display
+
+Reads SPV @var{file} and writes out a modified version.  Without
+@var{new-file}, the modified file replaces @var{file} in-place.  With
+@var{new-file}, @code{pspp-output} writes the modified version as
+@var{new-file}.  In the latter case, @code{pspp-output} by default
+infers the format of @var{new-file} the intended format for
+@var{destination} is inferred based on its extension, in the same way
+that the @command{pspp} program does for its output files.
+@xref{Invoking PSPP}, for details.
+
+The @code{modify} command includes all objects in @var{file} in its
+output, @strong{except} that it deletes objects in formats not yet
+understood by PSPP, such as charts.    @xref{Input Selection Options},
+for information on the options available to select a subset of objects
+to modify while copying them to the output.
+
+The following options specify modifications to be made:
+
+@table @option
+@item --set-visible=@var{bool}
+Makes the selected visible or invisible, according to @var{bool}.
+
+@item --set-label=@var{label}
+Set the selected objects' labels to @var{label}.  Labels appear in the
+outline in the PSPPIRE output viewer window and in the outline sidebar
+in PDF output.  The @var{label} may contain any of the following
+substitution variables:
+
+@table @code
+@item )DATE
+@itemx )ADATE
+@itemx )SDATE
+@itemx )EDATE
+The current date in format @code{DD-MMM-YYYY}, @code{MM/DD/YYYY},
+@code{YYYY/MM/DD}, or @code{DD.MM.YYYY}, respectively.
+
+@item )TIME
+@itemx )ETIME
+The current time in the format @code{hh:mm:ss}, using a 12-hour or
+24-hour clock, respectively.
+
+@item )INDEX
+The number of objects modified so far: 1 for the first object, 2 for
+the second, and so on.
+
+@item )LABEL
+The existing label text.
+@end table
+
+For example, to add an index at the beginning of each object's label,
+use @option{--set-label=')INDEX. )LABEL'}.
+
+@item --set-title=@var{title}
+Sets the titles of selected table objects to @var{title}, which
+supports the same substitution variables as @option{--set-label}.
+
+@item --transpose
+Transposes rows and columns of selected table objects.
+
+@item --table-look=@var{file}
+Reads a table style from @var{file} and applies it to selected table
+objects.  The file should be a TableLook @file{.stt} or @file{.tlo}
+file.
+
+@item --set-comment=@var{comment}
+Sets the comment on the selected table objects to @var{comment}.
+Comment text appears as a tooltip when the user hovers over the table
+in the PSPPIRE output viewer window or in exported HTML.
+@var{comment} supports the same substitution variables as
+@option{--set-label}, plus 
+
+
+@end table
+
+@table @option
+@item -O format=@var{format}
+Overrides the format inferred from the output file's extension.  Use
+@option{--help} to list the available formats.  @xref{Invoking PSPP},
+for details of the available output formats.
+
+@item -O @var{option}=@var{value}
+Sets an option for the output file format.  @xref{Invoking PSPP}, for
+details of the available output options.
+
+@item -F
+@itemx --force
+By default, if the source is corrupt or otherwise cannot be processed,
+the destination is not written.  With @option{-F} or @option{--force},
+the destination is written as best it can, even with errors.
+@end table
+
 @node The pspp-output get-table-look Command
 @section The @code{get-table-look} Command
 
index f9f149bd6360299567a559d99b26b613a6860cdc..2a8c83ffd502e711040e10ebbf07c2cef3e7a12a 100644 (file)
@@ -79,6 +79,9 @@ static bool force;
 /* --table-look: TableLook to replace table style for conversion. */
 static struct pivot_table_look *table_look;
 
+/* --set-label: New object label. */
+static char *set_label;
+
 /* Number of warnings issued. */
 static size_t n_warnings;
 
@@ -306,6 +309,14 @@ run_convert (int argc UNUSED, char **argv)
       struct spv_item *heading
         = items[i]->type == SPV_ITEM_HEADING ? items[i] : items[i]->parent;
       dump_heading_transition (prev_heading, heading);
+
+      if (set_label && spv_item_is_table (items[i]))
+        {
+          printf ("set label to %s\n", set_label);
+          free (items[i]->label);
+          items[i]->label = xstrdup (set_label);
+        }
+
       dump_item (items[i]);
       prev_heading = heading;
     }
@@ -966,6 +977,7 @@ parse_options (int argc, char *argv[])
           OPT_SORT,
           OPT_RAW,
           OPT_TABLE_LOOK,
+          OPT_SET_LABEL,
         };
       static const struct option long_options[] =
         {
@@ -987,6 +999,7 @@ parse_options (int argc, char *argv[])
           /* "convert" command options. */
           { "force", no_argument, NULL, 'f' },
           { "table-look", required_argument, NULL, OPT_TABLE_LOOK },
+          { "set-label", required_argument, NULL, OPT_SET_LABEL },
 
           /* "dump-light-table" command options. */
           { "sort", no_argument, NULL, OPT_SORT },
@@ -1066,6 +1079,10 @@ parse_options (int argc, char *argv[])
           parse_table_look (optarg);
           break;
 
+        case OPT_SET_LABEL:
+          set_label = optarg;
+          break;
+
         case 'f':
           force = true;
           break;