[649] | 1 |
|
---|
[208] | 2 | /**********************************************************************
|
---|
| 3 | *
|
---|
| 4 | * browsetools.cpp --
|
---|
| 5 | * Copyright (C) 1999 The New Zealand Digital Library Project
|
---|
| 6 | *
|
---|
[533] | 7 | * A component of the Greenstone digital library software
|
---|
| 8 | * from the New Zealand Digital Library Project at the
|
---|
| 9 | * University of Waikato, New Zealand.
|
---|
[208] | 10 | *
|
---|
[533] | 11 | * This program is free software; you can redistribute it and/or modify
|
---|
| 12 | * it under the terms of the GNU General Public License as published by
|
---|
| 13 | * the Free Software Foundation; either version 2 of the License, or
|
---|
| 14 | * (at your option) any later version.
|
---|
| 15 | *
|
---|
| 16 | * This program is distributed in the hope that it will be useful,
|
---|
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 19 | * GNU General Public License for more details.
|
---|
| 20 | *
|
---|
| 21 | * You should have received a copy of the GNU General Public License
|
---|
| 22 | * along with this program; if not, write to the Free Software
|
---|
| 23 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
| 24 | *
|
---|
[1860] | 25 | * $Id: browsetools.cpp 4983 2003-07-18 17:34:48Z sjboddie $
|
---|
| 26 | *
|
---|
[208] | 27 | *********************************************************************/
|
---|
| 28 |
|
---|
| 29 | #include "browsetools.h"
|
---|
[213] | 30 | #include "OIDtools.h"
|
---|
[4972] | 31 | #include "gsdlunicode.h"
|
---|
[208] | 32 |
|
---|
[4972] | 33 | #include <sstream>
|
---|
| 34 |
|
---|
| 35 |
|
---|
[1079] | 36 | // output_controls displays the detach, expand/contract contents,
|
---|
| 37 | // expand/contract text and highlighting/no highlighting buttons
|
---|
| 38 |
|
---|
| 39 | void output_controls (cgiargsclass &args, const text_tarray &ibuttons,
|
---|
| 40 | recptproto * /*collectproto*/, displayclass &disp,
|
---|
| 41 | outconvertclass &outconvert, ostream &textout,
|
---|
| 42 | ostream &/*logout*/) {
|
---|
| 43 |
|
---|
| 44 | if (args["u"] != "1") {
|
---|
| 45 |
|
---|
| 46 | FilterResponse_t response;
|
---|
| 47 | text_tarray metadata;
|
---|
| 48 | text_tarray buttons;
|
---|
| 49 |
|
---|
| 50 | text_tarray::const_iterator here = ibuttons.begin();
|
---|
| 51 | text_tarray::const_iterator end = ibuttons.end();
|
---|
| 52 |
|
---|
| 53 | while (here != end) {
|
---|
| 54 |
|
---|
| 55 | if (*here == "Detach")
|
---|
| 56 | buttons.push_back ("_document:imagedetach_");
|
---|
| 57 | else if (*here == "Highlight") {
|
---|
| 58 | if (args["hl"] == "1")
|
---|
| 59 | buttons.push_back ("_document:imagenohighlight_");
|
---|
| 60 | else
|
---|
| 61 | buttons.push_back ("_document:imagehighlight_");
|
---|
| 62 | } else if (*here == "Expand Contents") {
|
---|
| 63 | if (args["gc"] == "1")
|
---|
| 64 | buttons.push_back ("_document:imagecontracttoc_");
|
---|
| 65 | else
|
---|
| 66 | buttons.push_back ("_document:imageexpandtoc_");
|
---|
| 67 | } else if (*here == "Expand Text") {
|
---|
| 68 | if (args.getintarg("gt"))
|
---|
| 69 | buttons.push_back ("_document:imagecontracttext_");
|
---|
| 70 | else
|
---|
| 71 | buttons.push_back ("_document:imageexpandtext_");
|
---|
| 72 | }
|
---|
| 73 | here ++;
|
---|
| 74 | }
|
---|
| 75 |
|
---|
| 76 | here = buttons.begin();
|
---|
| 77 | end = buttons.end();
|
---|
| 78 | int count = 0;
|
---|
| 79 | while (here != end) {
|
---|
[3666] | 80 | if ((count != 0) && ((count % 2) == 0)) textout<< outconvert << "<br>\n";
|
---|
[1079] | 81 | textout << outconvert << disp << *here;
|
---|
| 82 | count ++;
|
---|
| 83 | here ++;
|
---|
| 84 | }
|
---|
| 85 | }
|
---|
| 86 | }
|
---|
| 87 |
|
---|
[4936] | 88 | text_t get_cover_image () {
|
---|
| 89 | return "_httpcollimg_/{Or}{[parent(Top):archivedir],[archivedir]}/cover.jpg";
|
---|
| 90 | }
|
---|
[1079] | 91 |
|
---|
| 92 | // at the moment this just writes out the html to display
|
---|
| 93 | // the cover image (assuming it's called cover.jpg)
|
---|
| 94 | // this whole thing should be done with a call to the collection
|
---|
| 95 | // server which would send a link to the cover image if there
|
---|
| 96 | // was one otherwise send title, author and stuff
|
---|
| 97 | void output_cover_image (cgiargsclass &args, recptproto * /*collectproto*/,
|
---|
| 98 | displayclass &disp, outconvertclass &outconvert,
|
---|
| 99 | ostream &textout, ostream &/*logout*/) {
|
---|
| 100 |
|
---|
| 101 | if (args["d"].empty()) return;
|
---|
| 102 |
|
---|
[4968] | 103 | textout << outconvert << disp << "<img src=\"_httpcollimg_/_thisOID_/cover.jpg\"><br>\n";
|
---|
[1079] | 104 | }
|
---|
| 105 |
|
---|
| 106 | void output_titles (cgiargsclass &args, recptproto *collectproto,
|
---|
[4972] | 107 | browsermapclass *browsermap, formatinfo_t &formatinfo,
|
---|
| 108 | displayclass &disp, outconvertclass &outconvert,
|
---|
| 109 | ostream &textout, ostream &logout) {
|
---|
[1079] | 110 |
|
---|
| 111 | if (args["d"].empty()) return;
|
---|
| 112 |
|
---|
| 113 | text_tset metadata;
|
---|
| 114 | bool getParents;
|
---|
| 115 | FilterResponse_t response;
|
---|
| 116 |
|
---|
| 117 | format_t *formatlistptr = new format_t();
|
---|
| 118 | parse_formatstring (formatinfo.DocumentHeading, formatlistptr, metadata, getParents);
|
---|
| 119 |
|
---|
| 120 | if (!get_info (args["d"], args["c"], metadata, getParents, collectproto, response, logout))
|
---|
| 121 | return;
|
---|
| 122 |
|
---|
[4972] | 123 | text_tmap options;
|
---|
| 124 | if (formatinfo.AllowExtendedOptions) {
|
---|
| 125 | load_extended_options(options, args, browsermap, formatinfo,
|
---|
| 126 | collectproto, disp, outconvert, logout);
|
---|
| 127 | }
|
---|
[1443] | 128 | textout << outconvert << disp
|
---|
[4906] | 129 | << get_formatted_string (args["c"],collectproto, response.docInfo[0], disp,
|
---|
| 130 | formatlistptr, options, logout);
|
---|
[1079] | 131 | }
|
---|
| 132 |
|
---|
[1941] | 133 | //this function outputs the related documents in the format specified
|
---|
| 134 | //in the collection configuration file if the collection preferences
|
---|
| 135 | //indicate they wish related documents to be displayed.
|
---|
| 136 | void output_related_docs (cgiargsclass &args, recptproto *collectproto,
|
---|
| 137 | formatinfo_t &formatinfo, displayclass &disp,
|
---|
| 138 | outconvertclass &outconvert, ostream &textout,
|
---|
| 139 | ostream &logout) {
|
---|
[1079] | 140 |
|
---|
[1941] | 141 | if (args["d"].empty()) return; //if no OID
|
---|
| 142 | if (args["rd"] != "1") return; //if preferences say no related documents
|
---|
| 143 |
|
---|
| 144 | text_tset metadata;
|
---|
| 145 | bool getParents;
|
---|
| 146 | FilterResponse_t response;
|
---|
| 147 |
|
---|
| 148 | //create new format pointer and parse the related doc format
|
---|
| 149 | //string specified in the collection config file
|
---|
| 150 | format_t *formatlistptr = new format_t();
|
---|
| 151 | parse_formatstring (formatinfo.RelatedDocuments, formatlistptr, metadata, getParents);
|
---|
| 152 |
|
---|
| 153 | if (!get_info (args["d"], args["c"], metadata, getParents, collectproto, response, logout))
|
---|
| 154 | return;
|
---|
| 155 |
|
---|
| 156 | //get the format string from formattools.cpp
|
---|
[4906] | 157 | text_tmap options; // no options
|
---|
[1941] | 158 | text_t relateddocs = get_formatted_string (args["c"],collectproto, response.docInfo[0],
|
---|
[4906] | 159 | disp, formatlistptr, options, logout);
|
---|
[1941] | 160 | //output the related documents
|
---|
| 161 | textout << outconvert << disp << relateddocs;
|
---|
| 162 | }
|
---|
| 163 |
|
---|
| 164 |
|
---|
| 165 |
|
---|
[737] | 166 | static void recurse_contents (ResultDocInfo_t §ion, cgiargsclass &args, bool fulltoc,
|
---|
[649] | 167 | browserclass *bptr, text_tset &metadata, bool &getParents,
|
---|
| 168 | format_t *formatlistptr, format_tmap &formatlistmap,
|
---|
[1079] | 169 | formatinfo_t &formatinfo, browsermapclass *browsermap,
|
---|
[737] | 170 | int tabcount, recptproto *collectproto, displayclass &disp,
|
---|
[649] | 171 | outconvertclass &outconvert, ostream &textout, ostream &logout) {
|
---|
| 172 | text_t formatstring;
|
---|
[419] | 173 |
|
---|
[649] | 174 | bool is_classify = false;
|
---|
[737] | 175 | if (args["d"].empty() || fulltoc) is_classify = true;
|
---|
[404] | 176 |
|
---|
[649] | 177 | // output this section
|
---|
| 178 | bool use_table = is_table_content (formatlistptr);
|
---|
[4867] | 179 | tabcount += bptr->output_section_group (section, args, args["c"], tabcount, formatlistptr, use_table,
|
---|
[737] | 180 | metadata, getParents, collectproto, disp, outconvert,
|
---|
| 181 | textout, logout);
|
---|
[404] | 182 |
|
---|
[649] | 183 | text_t classification;
|
---|
| 184 | if (!is_classify) classification = "Document";
|
---|
[737] | 185 | else get_top (args["cl"], classification);
|
---|
[404] | 186 |
|
---|
[649] | 187 | int haschildren = section.metadata["haschildren"].values[0].getint();
|
---|
| 188 | const text_t &doctype = section.metadata["doctype"].values[0];
|
---|
[730] | 189 | text_t classifytype = section.metadata["childtype"].values[0];
|
---|
[737] | 190 | // HLists and DateLists are displayed as VLists when contents
|
---|
| 191 | // are expanded, Paged documents are displayed as HLists
|
---|
| 192 | if (classifytype == "HList" || classifytype == "DateList") classifytype = "VList";
|
---|
[667] | 193 | if (classifytype == "Paged") classifytype = "HList";
|
---|
[404] | 194 |
|
---|
[649] | 195 | // recurse through children
|
---|
[737] | 196 | if ((haschildren == 1) && (!is_classify || fulltoc || doctype == "classify")) {
|
---|
[404] | 197 |
|
---|
[649] | 198 | // get browser for displaying children
|
---|
| 199 | bptr = browsermap->getbrowser (classifytype);
|
---|
| 200 | bptr->load_metadata_defaults (metadata);
|
---|
[404] | 201 |
|
---|
[649] | 202 | // get the formatstring if there is one
|
---|
[1079] | 203 | if (!get_formatstring (classification, classifytype,
|
---|
| 204 | formatinfo.formatstrings, formatstring))
|
---|
[649] | 205 | formatstring = bptr->get_default_formatstring();
|
---|
[404] | 206 |
|
---|
[649] | 207 | format_tmap::const_iterator it = formatlistmap.find (formatstring);
|
---|
| 208 | // check if formatlistptr is cached
|
---|
| 209 | if (it != formatlistmap.end()) formatlistptr = (*it).second;
|
---|
| 210 | else {
|
---|
| 211 | formatlistptr = new format_t();
|
---|
| 212 | parse_formatstring (formatstring, formatlistptr, metadata, getParents);
|
---|
| 213 | formatlistmap[formatstring] = formatlistptr;
|
---|
[469] | 214 | }
|
---|
[213] | 215 |
|
---|
[649] | 216 | FilterResponse_t tmp;
|
---|
| 217 | get_children (section.OID, args["c"], metadata, getParents, collectproto, tmp, logout);
|
---|
| 218 | ResultDocInfo_tarray::iterator thisdoc = tmp.docInfo.begin();
|
---|
| 219 | ResultDocInfo_tarray::iterator lastdoc = tmp.docInfo.end();
|
---|
[444] | 220 |
|
---|
[649] | 221 | while (thisdoc != lastdoc) {
|
---|
[737] | 222 | recurse_contents (*thisdoc, args, fulltoc, bptr, metadata, getParents,
|
---|
[1079] | 223 | formatlistptr, formatlistmap, formatinfo, browsermap,
|
---|
[737] | 224 | tabcount, collectproto, disp, outconvert, textout, logout);
|
---|
[649] | 225 | thisdoc ++;
|
---|
[213] | 226 | }
|
---|
| 227 | }
|
---|
| 228 | }
|
---|
| 229 |
|
---|
[257] | 230 |
|
---|
[649] | 231 | // expanded_contents recurses through all contents. there's a special case
|
---|
| 232 | // for an HList when contents are expanded (i.e. it's displayed as a VList)
|
---|
| 233 | //
|
---|
| 234 | // if we're inside a document we expand all contents from the top,
|
---|
| 235 | // if we're at classification level we'll just expand out those contents below
|
---|
| 236 | // the current one
|
---|
[344] | 237 |
|
---|
[1079] | 238 | void expanded_contents (cgiargsclass &args, int tabcount, bool fulltoc,
|
---|
| 239 | browsermapclass *browsermap, formatinfo_t &formatinfo,
|
---|
| 240 | recptproto *collectproto, displayclass &disp,
|
---|
| 241 | outconvertclass &outconvert, ostream &textout,
|
---|
| 242 | ostream &logout) {
|
---|
[248] | 243 |
|
---|
[649] | 244 | if (args["d"].empty() && args["cl"].empty()) return;
|
---|
| 245 | text_t OID;
|
---|
| 246 |
|
---|
| 247 | FilterResponse_t response;
|
---|
[404] | 248 | bool getParents = false;
|
---|
[649] | 249 | text_tset metadata;
|
---|
| 250 | text_t classifytype, classification, formatstring;
|
---|
[213] | 251 |
|
---|
[649] | 252 | if (!args["d"].empty()) {
|
---|
[737] | 253 | // document level
|
---|
| 254 | if (fulltoc) {
|
---|
| 255 | get_top (args["cl"], OID);
|
---|
| 256 | classification = OID;
|
---|
| 257 | }
|
---|
| 258 | else {
|
---|
| 259 | // always expand document level from top
|
---|
| 260 | get_top (args["d"], OID);
|
---|
| 261 | classification = "Document";
|
---|
| 262 | }
|
---|
[649] | 263 | } else {
|
---|
| 264 | // classification level
|
---|
| 265 | OID = args["cl"];
|
---|
| 266 | get_top (args["cl"], classification);
|
---|
[624] | 267 | }
|
---|
| 268 |
|
---|
[649] | 269 | // get classifytype of this level
|
---|
| 270 | text_t tOID;
|
---|
| 271 | if (is_top(OID)) {
|
---|
| 272 | classifytype = "thistype";
|
---|
| 273 | tOID = OID;
|
---|
[419] | 274 | } else {
|
---|
[649] | 275 | classifytype = "childtype";
|
---|
| 276 | tOID = get_parent (OID);
|
---|
[419] | 277 | }
|
---|
[649] | 278 | metadata.insert (classifytype);
|
---|
[344] | 279 |
|
---|
[649] | 280 | if (!get_info (tOID, args["c"], metadata, getParents, collectproto, response, logout))
|
---|
| 281 | return;
|
---|
| 282 | classifytype = response.docInfo[0].metadata[classifytype].values[0];
|
---|
| 283 | // if we still don't have a classifytype we'll use the default
|
---|
| 284 | if (classifytype.empty()) {
|
---|
| 285 | browserclass *bptr = browsermap->get_default_browser ();
|
---|
| 286 | classifytype = bptr->get_browser_name ();
|
---|
[257] | 287 | }
|
---|
| 288 |
|
---|
[649] | 289 | // HLists are displayed as VLists when contents are expanded,
|
---|
[730] | 290 | // Paged documents are displayed as HLists
|
---|
[778] | 291 | if (classifytype == "HList") {
|
---|
| 292 | classifytype = "VList";
|
---|
| 293 | text_t pOID = get_parent (OID);
|
---|
| 294 | if (!pOID.empty()) {
|
---|
| 295 | OID = pOID;
|
---|
| 296 | // this is assuming that top levels are always 'Invisible' !!!
|
---|
| 297 | if (is_top (OID)) classifytype = "Invisible";
|
---|
| 298 | }
|
---|
| 299 | }
|
---|
[730] | 300 | if (classifytype == "Paged") classifytype = "HList";
|
---|
[213] | 301 |
|
---|
[649] | 302 | metadata.erase (metadata.begin(), metadata.end());
|
---|
| 303 |
|
---|
| 304 | // metadata elements needed by recurse_contents
|
---|
[730] | 305 | metadata.insert ("childtype");
|
---|
[649] | 306 | metadata.insert ("doctype");
|
---|
| 307 | metadata.insert ("haschildren");
|
---|
[419] | 308 |
|
---|
[649] | 309 | // load up metadata array with browser defaults
|
---|
| 310 | browserclass *bptr = browsermap->getbrowser (classifytype);
|
---|
| 311 | bptr->load_metadata_defaults (metadata);
|
---|
[624] | 312 |
|
---|
[649] | 313 | // get the formatstring if there is one or use the browsers default
|
---|
[1079] | 314 | if (!get_formatstring (classification, classifytype,
|
---|
| 315 | formatinfo.formatstrings, formatstring))
|
---|
[649] | 316 | formatstring = bptr->get_default_formatstring();
|
---|
[419] | 317 |
|
---|
[649] | 318 | format_t *formatlistptr = new format_t();
|
---|
| 319 | parse_formatstring (formatstring, formatlistptr, metadata, getParents);
|
---|
[624] | 320 |
|
---|
[649] | 321 | // protocol call
|
---|
| 322 | if (!get_info (OID, args["c"], metadata, getParents, collectproto, response, logout))
|
---|
| 323 | return;
|
---|
[624] | 324 |
|
---|
[649] | 325 | format_tmap formatlistmap;
|
---|
| 326 | formatlistmap[formatstring] = formatlistptr;
|
---|
[624] | 327 |
|
---|
[737] | 328 | recurse_contents (response.docInfo[0], args, fulltoc, bptr, metadata,
|
---|
[1079] | 329 | getParents, formatlistptr, formatlistmap, formatinfo, browsermap,
|
---|
[737] | 330 | tabcount, collectproto, disp, outconvert, textout, logout);
|
---|
[624] | 331 |
|
---|
[649] | 332 | // clean up format list pointers
|
---|
| 333 | format_tmap::const_iterator here = formatlistmap.begin();
|
---|
| 334 | format_tmap::const_iterator end = formatlistmap.end();
|
---|
| 335 | while (here != end) {
|
---|
| 336 | delete (*here).second;
|
---|
| 337 | here ++;
|
---|
[419] | 338 | }
|
---|
| 339 | }
|
---|
| 340 |
|
---|
[667] | 341 |
|
---|
[649] | 342 | static void load_formatstring (const text_t &classifytype, text_tset &metadata,
|
---|
| 343 | bool &getParents, const text_t &classification,
|
---|
[1079] | 344 | browsermapclass *browsermap, formatinfo_t &formatinfo,
|
---|
[649] | 345 | format_tmap &formatlistmap) {
|
---|
| 346 | text_t formatstring;
|
---|
[419] | 347 |
|
---|
[649] | 348 | // load up metadata array with browser defaults
|
---|
| 349 | browserclass *bptr = browsermap->getbrowser (classifytype);
|
---|
| 350 | bptr->load_metadata_defaults (metadata);
|
---|
[419] | 351 |
|
---|
[649] | 352 | // get the formatstring if there is one or use the browsers default
|
---|
[1079] | 353 | if (!get_formatstring (classification, classifytype,
|
---|
| 354 | formatinfo.formatstrings, formatstring))
|
---|
[649] | 355 | formatstring = bptr->get_default_formatstring();
|
---|
[419] | 356 |
|
---|
[649] | 357 | // see if it's cached
|
---|
| 358 | format_tmap::const_iterator it = formatlistmap.find (formatstring);
|
---|
| 359 | if (it == formatlistmap.end()) {
|
---|
| 360 | format_t *formatlistptr = new format_t();
|
---|
| 361 | parse_formatstring (formatstring, formatlistptr, metadata, getParents);
|
---|
| 362 | formatlistmap[formatstring] = formatlistptr;
|
---|
[419] | 363 | }
|
---|
[208] | 364 | }
|
---|
[213] | 365 |
|
---|
[649] | 366 | static void load_formatstrings (FilterResponse_t &response, text_tset &metadata,
|
---|
| 367 | bool &getParents, const text_t &classification,
|
---|
[1079] | 368 | browsermapclass *browsermap, formatinfo_t &formatinfo,
|
---|
[649] | 369 | format_tmap &formatlistmap) {
|
---|
[213] | 370 |
|
---|
[649] | 371 | text_tset cache;
|
---|
[419] | 372 |
|
---|
[649] | 373 | ResultDocInfo_tarray::iterator thisdoc = response.docInfo.begin();
|
---|
| 374 | ResultDocInfo_tarray::iterator lastdoc = response.docInfo.end();
|
---|
[419] | 375 |
|
---|
[649] | 376 | while (thisdoc != lastdoc) {
|
---|
[667] | 377 |
|
---|
| 378 | if (is_top ((*thisdoc).OID))
|
---|
| 379 | load_formatstring ((*thisdoc).metadata["thistype"].values[0], metadata,
|
---|
[1079] | 380 | getParents, classification, browsermap, formatinfo,
|
---|
[667] | 381 | formatlistmap);
|
---|
| 382 |
|
---|
[649] | 383 | text_t &childtype = (*thisdoc).metadata["childtype"].values[0];
|
---|
| 384 | text_tset::const_iterator it = cache.find (childtype);
|
---|
| 385 | if (it == cache.end()) {
|
---|
[667] | 386 | load_formatstring (childtype, metadata, getParents, classification,
|
---|
[1079] | 387 | browsermap, formatinfo, formatlistmap);
|
---|
[667] | 388 | cache.insert (childtype);
|
---|
[649] | 389 | }
|
---|
| 390 | thisdoc ++;
|
---|
[419] | 391 | }
|
---|
| 392 | }
|
---|
| 393 |
|
---|
[667] | 394 | static void output_parents (FilterResponse_t &response, cgiargsclass &args,
|
---|
[1079] | 395 | browsermapclass *browsermap, formatinfo_t &formatinfo,
|
---|
[667] | 396 | format_tmap &formatlistmap, const text_t &classification,
|
---|
[737] | 397 | int &tabcount, text_tset &metadata, bool &getParents,
|
---|
[667] | 398 | recptproto *collectproto, displayclass &disp,
|
---|
[688] | 399 | outconvertclass &outconvert, ostream &textout,
|
---|
[667] | 400 | ostream &logout) {
|
---|
[419] | 401 |
|
---|
[667] | 402 | format_t *formatlistptr = NULL;
|
---|
| 403 | text_t classifytype, formatstring;
|
---|
| 404 | bool use_table, first = true;
|
---|
| 405 | ResultDocInfo_tarray::iterator thisparent = response.docInfo.begin();
|
---|
| 406 | ResultDocInfo_tarray::iterator lastparent = response.docInfo.end();
|
---|
| 407 | while (thisparent != lastparent) {
|
---|
| 408 |
|
---|
| 409 | // get classifytype of this level
|
---|
| 410 | if (is_top ((*thisparent).OID)) classifytype = (*thisparent).metadata["thistype"].values[0];
|
---|
| 411 | else if (!first) classifytype = (*(thisparent-1)).metadata["childtype"].values[0];
|
---|
| 412 |
|
---|
| 413 | // if we still don't have a classifytype we'll use the default
|
---|
| 414 | if (classifytype.empty()) {
|
---|
| 415 | browserclass *bptr = browsermap->get_default_browser ();
|
---|
| 416 | classifytype = bptr->get_browser_name ();
|
---|
| 417 | }
|
---|
| 418 |
|
---|
| 419 | browserclass *bptr = browsermap->getbrowser (classifytype);
|
---|
| 420 |
|
---|
| 421 | // get the formatstring if there is one or use the browsers default
|
---|
[1079] | 422 | if (!get_formatstring (classification, classifytype,
|
---|
| 423 | formatinfo.formatstrings, formatstring))
|
---|
[667] | 424 | formatstring = bptr->get_default_formatstring();
|
---|
| 425 |
|
---|
| 426 | // see if it's cached
|
---|
| 427 | format_tmap::const_iterator it = formatlistmap.find (formatstring);
|
---|
| 428 | if (it != formatlistmap.end()) formatlistptr = (*it).second;
|
---|
| 429 | else {
|
---|
| 430 | logout << "browsetools error\n";
|
---|
| 431 | return;
|
---|
| 432 | }
|
---|
| 433 |
|
---|
| 434 | use_table = is_table_content (formatlistptr);
|
---|
[748] | 435 | tabcount += bptr->output_section_group (*thisparent, args, "", tabcount, formatlistptr,
|
---|
[737] | 436 | use_table, metadata, getParents, collectproto,
|
---|
| 437 | disp, outconvert, textout, logout);
|
---|
[667] | 438 | first = false;
|
---|
| 439 | thisparent ++;
|
---|
| 440 | }
|
---|
| 441 | }
|
---|
| 442 |
|
---|
[1079] | 443 | void contracted_contents (cgiargsclass &args, int tabcount, bool fulltoc,
|
---|
| 444 | browsermapclass *browsermap, formatinfo_t &formatinfo,
|
---|
| 445 | recptproto *collectproto, displayclass &disp,
|
---|
| 446 | outconvertclass &outconvert, ostream &textout,
|
---|
| 447 | ostream &logout) {
|
---|
[914] | 448 |
|
---|
[257] | 449 | FilterResponse_t response;
|
---|
[649] | 450 | text_tset metadata;
|
---|
| 451 | bool getParents = false;
|
---|
[667] | 452 | text_t formatstring;
|
---|
[649] | 453 | text_tarray parents;
|
---|
| 454 | text_t OID = args["d"];
|
---|
| 455 | text_t classification = "Document";
|
---|
[1860] | 456 |
|
---|
| 457 | // if we're not outputting the TOC for a valid OID, then we should be giving
|
---|
| 458 | // the TOC of a classification
|
---|
[667] | 459 | if (OID.empty()) {
|
---|
| 460 | OID = args["cl"];
|
---|
| 461 | get_top (OID, classification);
|
---|
[1860] | 462 | }
|
---|
| 463 | // if we're to give the full TOC of a document, get the parent for the whole
|
---|
| 464 | // document now
|
---|
| 465 | else if (fulltoc)
|
---|
[737] | 466 | get_top (args["cl"], classification);
|
---|
[257] | 467 |
|
---|
[649] | 468 | bool haschildren = has_children (OID, args["c"], collectproto, logout);
|
---|
[257] | 469 |
|
---|
[737] | 470 | if ((!args["d"].empty()) && fulltoc)
|
---|
| 471 | get_parents_array (args["cl"] + ".fc", parents);
|
---|
[649] | 472 | if (haschildren) get_parents_array (OID + ".fc", parents);
|
---|
| 473 | else get_parents_array (OID, parents);
|
---|
[279] | 474 |
|
---|
[667] | 475 | if (!parents.empty()) {
|
---|
| 476 | // get classifytypes of each parent
|
---|
| 477 | metadata.insert ("thistype");
|
---|
| 478 | metadata.insert ("childtype");
|
---|
| 479 |
|
---|
| 480 | if (!get_info (parents, args["c"], metadata, getParents, collectproto, response, logout))
|
---|
| 481 | return;
|
---|
| 482 |
|
---|
| 483 | // get formatstrings for all parents
|
---|
| 484 | format_tmap formatlistmap;
|
---|
| 485 | load_formatstrings (response, metadata, getParents, classification,
|
---|
[1079] | 486 | browsermap, formatinfo, formatlistmap);
|
---|
[213] | 487 |
|
---|
[667] | 488 | if (!get_info (parents, args["c"], metadata, getParents, collectproto, response, logout))
|
---|
| 489 | return;
|
---|
| 490 |
|
---|
| 491 | // display each parent
|
---|
[1079] | 492 | output_parents (response, args, browsermap, formatinfo, formatlistmap,
|
---|
[737] | 493 | classification, tabcount, metadata, getParents,
|
---|
[667] | 494 | collectproto, disp, outconvert, textout, logout);
|
---|
| 495 |
|
---|
| 496 | metadata.erase (metadata.begin(), metadata.end());
|
---|
| 497 |
|
---|
| 498 | // clean up cached format list pointers
|
---|
| 499 | format_tmap::const_iterator here = formatlistmap.begin();
|
---|
| 500 | format_tmap::const_iterator end = formatlistmap.end();
|
---|
| 501 | while (here != end) {
|
---|
| 502 | delete (*here).second;
|
---|
| 503 | here ++;
|
---|
| 504 | }
|
---|
| 505 | }
|
---|
[257] | 506 |
|
---|
[667] | 507 | // get childrens classifytype
|
---|
| 508 | text_t classifytype;
|
---|
| 509 | int numparents = response.docInfo.size();
|
---|
| 510 | if (!parents.empty())
|
---|
| 511 | classifytype = response.docInfo[numparents-1].metadata["childtype"].values[0];
|
---|
| 512 | else {
|
---|
| 513 | // use the default
|
---|
| 514 | browserclass *bptr = browsermap->get_default_browser ();
|
---|
| 515 | classifytype = bptr->get_browser_name ();
|
---|
| 516 | }
|
---|
| 517 |
|
---|
| 518 | // load up metadata array with browser defaults
|
---|
| 519 | browserclass *bptr = browsermap->getbrowser (classifytype);
|
---|
| 520 | bptr->load_metadata_defaults (metadata);
|
---|
[213] | 521 |
|
---|
[667] | 522 | // get the formatstring if there is one or use the browsers default
|
---|
[1079] | 523 | if (!get_formatstring (classification, classifytype,
|
---|
| 524 | formatinfo.formatstrings, formatstring))
|
---|
[667] | 525 | formatstring = bptr->get_default_formatstring();
|
---|
| 526 |
|
---|
| 527 | format_t *formatlistptr = new format_t();
|
---|
| 528 | parse_formatstring (formatstring, formatlistptr, metadata, getParents);
|
---|
| 529 |
|
---|
| 530 | if (haschildren)
|
---|
| 531 | get_children (OID, args["c"], metadata, getParents,
|
---|
| 532 | collectproto, response, logout);
|
---|
[941] | 533 | else if (!is_top(OID)) {
|
---|
[667] | 534 | get_children (OID + ".pr", args["c"], metadata, getParents,
|
---|
| 535 | collectproto, response, logout);
|
---|
[941] | 536 | haschildren = true;
|
---|
| 537 | }
|
---|
[667] | 538 |
|
---|
| 539 | // display children
|
---|
[941] | 540 | if (haschildren) {
|
---|
| 541 | bool use_table = is_table_content (formatlistptr);
|
---|
[1443] | 542 | bptr->output_section_group (response, args, args["c"], tabcount, formatlistptr, use_table,
|
---|
[941] | 543 | metadata, getParents, collectproto, disp, outconvert,
|
---|
| 544 | textout, logout);
|
---|
| 545 | }
|
---|
[667] | 546 | delete formatlistptr;
|
---|
[213] | 547 | }
|
---|
| 548 |
|
---|
[1860] | 549 | /**
|
---|
[2805] | 550 | * This function outputs contents of a classifier to the reader
|
---|
| 551 | * including parent levels
|
---|
| 552 | */
|
---|
| 553 | void expand_show_contents (cgiargsclass &args, int tabcount, bool fulltoc,
|
---|
| 554 | browsermapclass *browsermap, formatinfo_t &formatinfo,
|
---|
| 555 | recptproto *collectproto, displayclass &disp,
|
---|
| 556 | outconvertclass &outconvert, ostream &textout,
|
---|
| 557 | ostream &logout)
|
---|
| 558 | {
|
---|
| 559 |
|
---|
| 560 | int coloffset = 0;
|
---|
| 561 | text_tarray parents;
|
---|
| 562 | FilterResponse_t response;
|
---|
| 563 | text_t OID = args["d"];
|
---|
| 564 | if (OID.empty()) OID = args["cl"];
|
---|
| 565 |
|
---|
| 566 | bool haschildren = has_children (OID, args["c"], collectproto, logout);
|
---|
| 567 |
|
---|
| 568 | // get parents list
|
---|
| 569 | if (!is_top(OID)) get_parents_array (OID, parents);
|
---|
| 570 | if (args["d"].empty() || haschildren || parents.empty())
|
---|
| 571 | parents.push_back(OID);
|
---|
| 572 |
|
---|
| 573 | // if inside a book top title is needed
|
---|
| 574 | if (!args["d"].empty()) {
|
---|
| 575 |
|
---|
| 576 | coloffset = 1;
|
---|
| 577 | text_t classification, classifytype, formatstring, topOID = parents[0];
|
---|
| 578 | text_tset metadata;
|
---|
| 579 | format_t *formatlistptr = new format_t();
|
---|
| 580 | bool use_table, getParents = false;
|
---|
| 581 |
|
---|
| 582 | get_top (args["cl"], classification);
|
---|
| 583 |
|
---|
| 584 | // getting information about top OID
|
---|
| 585 | metadata.insert ("thistype");
|
---|
| 586 |
|
---|
| 587 | get_info ( topOID, args["c"], metadata, getParents, collectproto, response, logout);
|
---|
| 588 | if (!response.docInfo[0].metadata["thistype"].values.empty())
|
---|
| 589 | classifytype = response.docInfo[0].metadata["thistype"].values[0];
|
---|
| 590 |
|
---|
| 591 | browserclass *bptr = browsermap->getbrowser (classifytype);
|
---|
| 592 |
|
---|
| 593 | if (classifytype.empty()) {
|
---|
| 594 | bptr = browsermap->get_default_browser();
|
---|
| 595 | }
|
---|
| 596 |
|
---|
| 597 | // get the formatstring if there is one or use the browsers default
|
---|
| 598 | if (!get_formatstring (classification, classifytype,
|
---|
| 599 | formatinfo.formatstrings, formatstring))
|
---|
| 600 | formatstring = bptr->get_default_formatstring();
|
---|
| 601 |
|
---|
| 602 | parse_formatstring (formatstring, formatlistptr, metadata, getParents);
|
---|
| 603 |
|
---|
| 604 | metadata.insert ("doctype");
|
---|
| 605 | metadata.insert ("haschildren");
|
---|
| 606 |
|
---|
| 607 | get_info (topOID, args["c"], metadata, getParents, collectproto, response, logout);
|
---|
| 608 |
|
---|
| 609 | // ouput top OID section
|
---|
| 610 | use_table = is_table_content (formatlistptr);
|
---|
| 611 | bptr->output_section_group (response.docInfo[0], args, "", tabcount, formatlistptr, use_table,
|
---|
| 612 | metadata, getParents, collectproto, disp, outconvert, textout, logout);
|
---|
| 613 |
|
---|
| 614 | }
|
---|
| 615 |
|
---|
| 616 | recurse_contents_levels (parents, args, coloffset, tabcount, fulltoc, browsermap,
|
---|
| 617 | formatinfo, collectproto, disp, outconvert, textout, logout);
|
---|
| 618 |
|
---|
[3666] | 619 | textout << outconvert << "</table></td></tr></table>\n";
|
---|
[2805] | 620 | }
|
---|
| 621 |
|
---|
| 622 | void recurse_contents_levels (text_tarray &parents,
|
---|
| 623 | cgiargsclass &args, int coloffset, int tabcount, bool fulltoc,
|
---|
| 624 | browsermapclass *browsermap, formatinfo_t &formatinfo,
|
---|
| 625 | recptproto *collectproto, displayclass &disp,
|
---|
| 626 | outconvertclass &outconvert, ostream &textout,
|
---|
| 627 | ostream &logout)
|
---|
| 628 | {
|
---|
| 629 | FilterResponse_t response;
|
---|
| 630 | text_tset metadata;
|
---|
| 631 | text_t OID, formatstring, classification, classifytype;;
|
---|
| 632 | bool use_table, getParents = false;
|
---|
| 633 | int haschildren = 0;
|
---|
| 634 | format_t *formatlistptr = new format_t();
|
---|
| 635 |
|
---|
| 636 | // display children for last level
|
---|
| 637 | if (tabcount == (parents.size() - 1)) {
|
---|
| 638 |
|
---|
| 639 | logout << "@@@lastlevel@@@\n";
|
---|
| 640 | // setting metadata fields
|
---|
| 641 | metadata.insert ("thistype");
|
---|
| 642 | metadata.insert ("childtype");
|
---|
| 643 | metadata.insert ("haschildren");
|
---|
| 644 |
|
---|
| 645 | OID = parents[tabcount];
|
---|
| 646 | get_info (OID, args["c"], metadata, getParents, collectproto, response, logout);
|
---|
| 647 | get_top (OID, classification);
|
---|
| 648 |
|
---|
| 649 | if (!response.docInfo.empty())
|
---|
| 650 | haschildren = response.docInfo[0].metadata["haschildren"].values[0].getint();
|
---|
| 651 |
|
---|
| 652 | // get childrens classifytype
|
---|
| 653 | if (!response.docInfo.empty())
|
---|
| 654 | classifytype = response.docInfo[0].metadata["childtype"].values[0];
|
---|
| 655 | else {
|
---|
| 656 | // use the default
|
---|
| 657 | browserclass *bptr = browsermap->get_default_browser ();
|
---|
| 658 | classifytype = bptr->get_browser_name ();
|
---|
| 659 | }
|
---|
| 660 |
|
---|
| 661 | // load up metadata array with browser defaults
|
---|
| 662 | browserclass *bptr = browsermap->getbrowser (classifytype);
|
---|
| 663 | bptr->load_metadata_defaults (metadata);
|
---|
| 664 |
|
---|
| 665 | // get the formatstring if there is one or use the browsers default
|
---|
| 666 | if (!get_formatstring (classification, classifytype,
|
---|
| 667 | formatinfo.formatstrings, formatstring))
|
---|
| 668 | formatstring = bptr->get_default_formatstring();
|
---|
| 669 |
|
---|
| 670 | parse_formatstring (formatstring, formatlistptr, metadata, getParents);
|
---|
| 671 |
|
---|
| 672 | if (haschildren)
|
---|
| 673 | get_children (OID, args["c"], metadata, getParents,
|
---|
| 674 | collectproto, response, logout);
|
---|
| 675 | else if (!is_top(OID)) {
|
---|
| 676 | get_children (OID + ".pr", args["c"], metadata, getParents,
|
---|
| 677 | collectproto, response, logout);
|
---|
| 678 | haschildren = true;
|
---|
| 679 | }
|
---|
| 680 |
|
---|
| 681 | // display children
|
---|
| 682 | if (haschildren) {
|
---|
| 683 | use_table = is_table_content (formatlistptr);
|
---|
| 684 | bptr->output_section_group (response, args, args["c"], coloffset + tabcount, formatlistptr, use_table,
|
---|
| 685 | metadata, getParents, collectproto, disp, outconvert,
|
---|
| 686 | textout, logout);
|
---|
| 687 | }
|
---|
| 688 |
|
---|
| 689 | } else {
|
---|
| 690 |
|
---|
| 691 | text_t pOID;
|
---|
| 692 | OID = parents[tabcount];
|
---|
| 693 | get_top (OID, classification);
|
---|
| 694 |
|
---|
| 695 | // load metadata fields
|
---|
| 696 | metadata.insert ("thistype");
|
---|
| 697 | metadata.insert ("childtype");
|
---|
| 698 | metadata.insert ("haschildren");
|
---|
| 699 | metadata.insert ("doctype");
|
---|
| 700 |
|
---|
| 701 | if (tabcount) pOID = parents[tabcount-1];
|
---|
| 702 | else pOID = OID;
|
---|
| 703 | get_info (pOID, args["c"], metadata, getParents, collectproto, response, logout);
|
---|
| 704 |
|
---|
| 705 | // get classifytype of this level
|
---|
| 706 | if (is_top (pOID)) classifytype = response.docInfo[0].metadata["childtype"].values[0];
|
---|
| 707 | else classifytype = response.docInfo[0].metadata["thistype"].values[0];
|
---|
| 708 |
|
---|
| 709 | // if we still don't have a classifytype we'll use the default
|
---|
| 710 | if (classifytype.empty()) {
|
---|
| 711 | browserclass *bptr = browsermap->get_default_browser ();
|
---|
| 712 | classifytype = bptr->get_browser_name ();
|
---|
| 713 | }
|
---|
| 714 |
|
---|
| 715 | browserclass *bptr = browsermap->getbrowser (classifytype);
|
---|
| 716 |
|
---|
| 717 | // get the formatstring if there is one or use the browsers default
|
---|
| 718 | if (!get_formatstring (classification, classifytype,
|
---|
| 719 | formatinfo.formatstrings, formatstring))
|
---|
| 720 | formatstring = bptr->get_default_formatstring();
|
---|
| 721 |
|
---|
| 722 |
|
---|
| 723 | // parse format string
|
---|
| 724 | parse_formatstring (formatstring, formatlistptr, metadata, getParents);
|
---|
| 725 |
|
---|
| 726 | use_table = is_table_content (formatlistptr);
|
---|
| 727 |
|
---|
| 728 | get_children (OID, args["c"], metadata, getParents, collectproto, response, logout);
|
---|
| 729 |
|
---|
| 730 | ResultDocInfo_tarray::iterator thissibling = response.docInfo.begin();
|
---|
| 731 | ResultDocInfo_tarray::iterator lastsibling = response.docInfo.end();
|
---|
| 732 |
|
---|
| 733 | while (thissibling != lastsibling) {
|
---|
| 734 |
|
---|
| 735 | logout << "@@@level:@@@" << tabcount << "\n";
|
---|
| 736 |
|
---|
| 737 | bptr->output_section_group (*thissibling, args, args["c"], coloffset + tabcount, formatlistptr,
|
---|
| 738 | use_table, metadata, getParents, collectproto,
|
---|
| 739 | disp, outconvert, textout, logout);
|
---|
| 740 |
|
---|
| 741 | if ((*thissibling).OID == parents[tabcount+1]) {
|
---|
| 742 | recurse_contents_levels (parents, args, coloffset, tabcount+1, fulltoc, browsermap,
|
---|
| 743 | formatinfo, collectproto, disp, outconvert,textout, logout);
|
---|
| 744 | }
|
---|
| 745 |
|
---|
| 746 | thissibling ++;
|
---|
| 747 | }
|
---|
| 748 | }
|
---|
| 749 | delete formatlistptr;
|
---|
| 750 | }
|
---|
| 751 |
|
---|
| 752 | /**
|
---|
[1860] | 753 | * This function outputs the contents of a classifier list to the reader -
|
---|
| 754 | * the document will in fact be empty, so this does the "real" output
|
---|
| 755 | */
|
---|
[649] | 756 | void output_toc (cgiargsclass &args, browsermapclass *browsermap,
|
---|
[1079] | 757 | formatinfo_t &formatinfo, recptproto *collectproto,
|
---|
[649] | 758 | displayclass &disp, outconvertclass &outconvert,
|
---|
| 759 | ostream &textout, ostream &logout) {
|
---|
[344] | 760 |
|
---|
[4983] | 761 | if (!args["d"].empty() && formatinfo.AllowExtendedOptions) {
|
---|
| 762 | // If AllowExtendedOptions is set and we're viewing a document,
|
---|
| 763 | // DocumentButtons, DocumentContent, and DocumentImages are effectively
|
---|
| 764 | // disabled. We just output the DocumentHeading format string and
|
---|
| 765 | // return
|
---|
[4972] | 766 | output_titles (args, collectproto, browsermap, formatinfo, disp, outconvert, textout, logout);
|
---|
| 767 | return;
|
---|
| 768 | }
|
---|
| 769 |
|
---|
[737] | 770 | int tabcount = 0;
|
---|
[1079] | 771 | bool havecontrols = false;
|
---|
[737] | 772 | bool fulltoc = false;
|
---|
| 773 |
|
---|
| 774 | if (args["cl"] != "search") {
|
---|
| 775 | // see if there's a FullTOC string
|
---|
| 776 | text_t cl_top, full_toc;
|
---|
| 777 | get_top (args["cl"], cl_top);
|
---|
[1079] | 778 | if (get_formatstring (cl_top, "FullTOC", formatinfo.formatstrings, full_toc))
|
---|
[737] | 779 | if (full_toc == "true") fulltoc = true;
|
---|
| 780 | }
|
---|
[1079] | 781 |
|
---|
| 782 | // get the cover image (if there is one) and the control buttons
|
---|
| 783 | // if we're inside a book
|
---|
| 784 | if ((!fulltoc) && (!args["d"].empty())) {
|
---|
[3666] | 785 | textout << outconvert << "<center>\n";
|
---|
[1606] | 786 | textout << outconvert << disp << "<p><table width=_pagewidth_ cellpadding=0 cellspacing=0><tr>\n";
|
---|
[3666] | 787 | textout << outconvert << "<td valign=top align=left";
|
---|
| 788 | if (formatinfo.DocumentContents) textout << outconvert << " width=200>\n";
|
---|
| 789 | else textout << outconvert << " width=\"100%\">\n";
|
---|
[1079] | 790 | if (formatinfo.DocumentImages)
|
---|
| 791 | output_cover_image (args, collectproto, disp, outconvert, textout, logout);
|
---|
| 792 | else if (formatinfo.DocumentTitles)
|
---|
[4972] | 793 | output_titles (args, collectproto, browsermap, formatinfo, disp, outconvert, textout, logout);
|
---|
[2664] | 794 | if (args["u"] != "1") {
|
---|
| 795 | output_controls (args, formatinfo.DocumentButtons, collectproto, disp,
|
---|
| 796 | outconvert, textout, logout);
|
---|
| 797 | }
|
---|
[3666] | 798 | textout << outconvert << "</td><td valign=\"top\">\n";
|
---|
[1079] | 799 | havecontrols = true;
|
---|
| 800 | }
|
---|
[248] | 801 |
|
---|
[1079] | 802 | if (formatinfo.DocumentContents || args["d"].empty()) {
|
---|
| 803 | if (args.getintarg("gc") == 1) {
|
---|
[667] | 804 |
|
---|
[1079] | 805 | // expanded table of contents
|
---|
| 806 | expanded_contents (args, tabcount, fulltoc, browsermap, formatinfo,
|
---|
| 807 | collectproto, disp, outconvert, textout, logout);
|
---|
[2805] | 808 | } else if (args.getintarg("gc") == 2) {
|
---|
| 809 |
|
---|
| 810 | // expand visible levels of table of contents
|
---|
| 811 | expand_show_contents(args, tabcount, fulltoc, browsermap, formatinfo,
|
---|
| 812 | collectproto, disp, outconvert, textout, logout);
|
---|
| 813 | } else {
|
---|
[1059] | 814 |
|
---|
[1079] | 815 | // contracted table of contents
|
---|
| 816 | contracted_contents (args, tabcount, fulltoc, browsermap, formatinfo,
|
---|
| 817 | collectproto, disp, outconvert, textout, logout);
|
---|
| 818 | }
|
---|
[667] | 819 | }
|
---|
[1079] | 820 |
|
---|
[3666] | 821 | if (havecontrols) textout << outconvert << "</td></tr></table></center>\n";
|
---|
[1941] | 822 |
|
---|
| 823 | //if there is a format specified in the config file then
|
---|
| 824 | //try to display the related documents (may not be displayed
|
---|
| 825 | //if preference file does not indicate a wish to display
|
---|
| 826 | //related documents.
|
---|
| 827 | if (!formatinfo.RelatedDocuments.empty())
|
---|
| 828 | output_related_docs(args, collectproto, formatinfo, disp, outconvert, textout, logout);
|
---|
| 829 |
|
---|
[248] | 830 | }
|
---|
[1941] | 831 |
|
---|
[4972] | 832 | void load_extended_options(text_tmap &options, cgiargsclass &args, browsermapclass *browsers,
|
---|
| 833 | formatinfo_t &formatinfo, recptproto *collectproto,
|
---|
| 834 | displayclass &disp, outconvertclass &outconvert, ostream &logout) {
|
---|
| 835 |
|
---|
| 836 | options["DocImage"] = get_cover_image();
|
---|
| 837 |
|
---|
| 838 | ostringstream tmpstr(ostringstream::binary);
|
---|
| 839 | if (args["gc"] == "1") {
|
---|
| 840 | expanded_contents (args, 0, false, browsers, formatinfo,
|
---|
| 841 | collectproto, disp, outconvert, tmpstr,
|
---|
| 842 | logout);
|
---|
| 843 | } else {
|
---|
| 844 | contracted_contents (args, 0, false, browsers, formatinfo,
|
---|
| 845 | collectproto, disp, outconvert, tmpstr, logout);
|
---|
| 846 | }
|
---|
| 847 | text_t tmp = (char *)(tmpstr.str().c_str());
|
---|
| 848 | int len = tmp.size();
|
---|
| 849 | char *ctmp = tmp.getcstr();
|
---|
| 850 | utf8inconvertclass utf82text_t;
|
---|
| 851 | utf82text_t.setinput(ctmp, len);
|
---|
| 852 | convertclass::status_t status;
|
---|
| 853 | utf82text_t.convert(tmp, status);
|
---|
| 854 | options["DocTOC"] = tmp;
|
---|
| 855 | delete ctmp;
|
---|
| 856 |
|
---|
| 857 | options["DocumentButtonDetach"] = "_document:imagedetach_";
|
---|
| 858 | if (args["hl"] == "1") {
|
---|
| 859 | options["DocumentButtonHighlight"] = "_document:imagenohighlight_";
|
---|
| 860 | } else {
|
---|
| 861 | options["DocumentButtonHighlight"] = "_document:imagehighlight_";
|
---|
| 862 | }
|
---|
| 863 | if (args["gc"] == "1") {
|
---|
| 864 | options["DocumentButtonExpandContents"] = "_document:imagecontracttoc_";
|
---|
| 865 | } else {
|
---|
| 866 | options["DocumentButtonExpandContents"] = "_document:imageexpandtoc_";
|
---|
| 867 | }
|
---|
| 868 | if (args["gt"] == "1") {
|
---|
| 869 | options["DocumentButtonExpandText"] = "_document:imagecontracttext_";
|
---|
| 870 | } else {
|
---|
| 871 | options["DocumentButtonExpandText"] = "_document:imageexpandtext_";
|
---|
| 872 | }
|
---|
| 873 | }
|
---|