OOFILE  1.9
oofrep3.cpp
Go to the documentation of this file.
1 // COPYRIGHT 1996 A.D. Software, All rights reserved
2 
3 // report-writer layer of OOFILE database
4 
5 #include "oofpch_r.h" // for precompilation of report files
6 
7 #ifndef H_OOF3
8  #include "oof3.h"
9 #endif
10 #ifndef H_OOFREP
11  #include "oofrep.h"
12 #endif
13 #ifndef _STRING
14  #include <string.h>
15 #endif
16 #ifndef H_OOFGRPHS
17  #include "oofGrphs.h"
18 #endif
19 #ifndef H_OOFIOS
20  #include "oofios.h"
21 #endif
22 #ifndef H_OOFREPREND
23  #include "oofreprn.h" // abstract renderers
24 #endif
25 #ifndef H_OOFREPEDITOR
26  #include "oofrepeditor.h"
27 #endif
28 
29 #ifdef OOF_MEM_DEBUG_LAST_INCLUDE
30  #include OOF_MEM_DEBUG_LAST_INCLUDE
31 #endif
32 
33 #ifndef OOF_NO_STDLIB
34  #ifndef std
35  using namespace std;
36  #endif
37 #endif
38 
39 
40 #ifdef OOF_READ_XML
41 // 990529 HACK - this must precede the oofRepDefaultSettings ctor
43 #endif
44 
45 oofRepSettings* oofRepDefaultSettings::sDefaultSettings;
46 oofRepDefaultSettings oofRepDefaultSettings::sDefaultSettingsFactory; // the Singleton
47 
48 
49 // -------------------------------------------------------
50 // o o f R e p D e f a u l t S e t t i n g s
51 // -------------------------------------------------------
53 {
54  if (sDefaultSettings==0) {
55  sDefaultSettings = new oofRepSettings;
56  /* Note that at this point we must provide default values
57  for any states which the oofRepSettings object tracks, or else
58  we get serious problems. Beware.
59  */
60 // all figures in points unless otherwise noted
61  sDefaultSettings->lineThickness(2);
62  sDefaultSettings->pageHeight(792); // GUI calculates from PREC, default to 11" for RTF
63  sDefaultSettings->pageWidth(576); // GUI calculates from PREC, default to 8" for RTF
64  sDefaultSettings->borderType(0);
65  sDefaultSettings->bandIndenting(0);
66  sDefaultSettings->leftMargin(72);
67  sDefaultSettings->rightMargin(72);
68  sDefaultSettings->topMargin(36);
69  sDefaultSettings->bottomMargin(36);
70  sDefaultSettings->colSepWidth(20);
71  sDefaultSettings->blockVertSep(20);
72  sDefaultSettings->defaultTextStyle(new oofRepTextStyle("Helvetica", 10));
73  sDefaultSettings->defaultPageHeaders(new oofRepBandList);
74  sDefaultSettings->defaultPageFooters(new oofRepBandList);
75  sDefaultSettings->drawHeadingsDownToLevel(1);
76  sDefaultSettings->printGraphsInMono(true);
77  sDefaultSettings->modalPreviewWindow(false);
78  sDefaultSettings->graphBandMinSizePercent(50); // percentage
79  sDefaultSettings->XMLsettings(new oofRepXMLsettings);
80  // sDefaultSettings->reportEditor(new oofRepEditor); // left at null - reports not editable by default
81 
82 // other init stuff - register default serializable classes
86  }
87 }
88 
89 
91 {
92  if (--sDefaultSettings->refcount()==0)
93  delete sDefaultSettings;
94 }
95 
96 
97 // -------------------------------------------------------
98 // o o f R e p S e t t i n g s
99 // -------------------------------------------------------
101  mRefCount(1),
102  mLineThickness(0),
103  mPageHeight(0),
104  mPageWidth(0),
105  mBorderType(0),
106  mBandIndenting(0),
107  mLeftMargin(0),
108  mRightMargin(0),
109  mTopMargin(0),
110  mBottomMargin(0),
111  mColSepWidth(0),
112  mBlockVertSep(0),
113  mDefaultTextStyle(0),
114  mDefaultPageHeaders(0),
115  mDefaultPageFooters(0),
116  mDrawHeadingsDownToLevel(0),
117  mPrintGraphsInMono(0),
118  mModalPreviewWindow(0),
119  mGraphBandMinSizePercent(0),
120  mXMLsettings(0),
121  mRepEditor(0)
122 {
123 // zero all the pointers to settings above
124 }
125 
126 
128  mRefCount(1),
129  mLineThickness(0),
130  mPageHeight(0),
131  mPageWidth(0),
132  mBorderType(0),
133  mBandIndenting(0),
134  mLeftMargin(0),
135  mRightMargin(0),
136  mTopMargin(0),
137  mBottomMargin(0),
138  mColSepWidth(0),
139  mBlockVertSep(0),
140  mDefaultTextStyle(0),
141  mDefaultPageHeaders(0),
142  mDefaultPageFooters(0),
143  mDrawHeadingsDownToLevel(0),
144  mPrintGraphsInMono(0),
145  mModalPreviewWindow(0),
146  mGraphBandMinSizePercent(0),
147  mXMLsettings(0),
148  mRepEditor(0)
149 {
150  if (rhs->mLineThickness)
151  lineThickness(*rhs->mLineThickness);
152 
153  if (rhs->mPageHeight)
154  pageHeight(*rhs->mPageHeight);
155 
156  if (rhs->mPageWidth)
157  pageWidth(*rhs->mPageWidth);
158 
159  if (rhs->mBorderType)
160  borderType(*rhs->mBorderType);
161 
162  if (rhs->mBandIndenting)
163  bandIndenting(*rhs->mBandIndenting);
164 
165  if (rhs->mLeftMargin)
166  leftMargin(*rhs->mLeftMargin);
167 
168  if (rhs->mRightMargin)
169  rightMargin(*rhs->mRightMargin);
170 
171  if (rhs->mTopMargin)
172  topMargin(*rhs->mTopMargin);
173 
174  if (rhs->mBottomMargin)
175  bottomMargin(*rhs->mBottomMargin);
176 
177  if (rhs->mColSepWidth)
178  colSepWidth(*rhs->mColSepWidth);
179 
180  if (rhs->mBlockVertSep)
181  blockVertSep(*rhs->mBlockVertSep);
182 
183  if (rhs->mDefaultTextStyle)
184  defaultTextStyle(rhs->mDefaultTextStyle->clone());
185 
186  if (rhs->mDefaultPageHeaders)
187  defaultPageHeaders(rhs->mDefaultPageHeaders->clone());
188 
189  if (rhs->mDefaultPageFooters)
190  defaultPageFooters(rhs->mDefaultPageFooters->clone());
191 
192  if (rhs->mDrawHeadingsDownToLevel)
193  drawHeadingsDownToLevel(*rhs->mDrawHeadingsDownToLevel);
194 
195  if (rhs->mPrintGraphsInMono)
196  printGraphsInMono(*rhs->mPrintGraphsInMono);
197 
198  if (rhs->mModalPreviewWindow)
199  modalPreviewWindow(*rhs->mModalPreviewWindow);
200 
201  if (rhs->mGraphBandMinSizePercent)
202  graphBandMinSizePercent(*rhs->mGraphBandMinSizePercent);
203 
204  if (rhs->mXMLsettings)
205  XMLsettings(rhs->mXMLsettings->clone());
206 #ifndef OOF_REP_NO_GUI
207 
208  if (rhs->mRepEditor)
209  reportEditor(rhs->mRepEditor->clone());
210 #endif
211 }
212 
213 
215 {
216  if (mRefCount <= 1) {
217  delete mLineThickness;
218  delete mPageHeight;
219  delete mPageWidth;
220  delete mBorderType;
221  delete mBandIndenting;
222  delete mLeftMargin;
223  delete mRightMargin;
224  delete mTopMargin;
225  delete mBottomMargin;
226  delete mColSepWidth;
227  delete mBlockVertSep;
228  delete mDefaultTextStyle;
229  delete mDefaultPageHeaders;
230  delete mDefaultPageFooters;
231  delete mDrawHeadingsDownToLevel;
232  delete mPrintGraphsInMono;
233  delete mModalPreviewWindow;
234  delete mGraphBandMinSizePercent;
235  delete mXMLsettings;
236  delete mRepEditor;
237  }
238  else
239  --mRefCount;
240 }
241 
242 
243 unsigned short&
245 {
246  return mRefCount;
247 }
248 
249 
250 unsigned short
252 {
253  if (mLineThickness)
254  return *mLineThickness;
255  else
257 }
258 
259 
260 void
262 {
263  if (mLineThickness)
264  *mLineThickness = n;
265  else
266  mLineThickness = new unsigned short(n);
267 }
268 
269 unsigned short
271 {
272  if (mPageHeight)
273  return *mPageHeight;
274  else
276 }
277 
278 
279 void
280 oofRepSettings::pageHeight(unsigned short n)
281 {
282  if (mPageHeight)
283  *mPageHeight = n;
284  else
285  mPageHeight = new unsigned short(n);
286 }
287 
288 unsigned short
290 {
291  if (mPageWidth)
292  return *mPageWidth;
293  else
295 }
296 
297 
298 void
299 oofRepSettings::pageWidth(unsigned short n)
300 {
301  if (mPageWidth)
302  *mPageWidth = n;
303  else
304  mPageWidth = new unsigned short(n);
305 }
306 
307 unsigned short
309 {
310  if (mBorderType)
311  return *mBorderType;
312  else
314 }
315 
316 void
317 oofRepSettings::borderType(unsigned short n)
318 {
319  if (mBorderType)
320  *mBorderType = n;
321  else
322  mBorderType = new unsigned short(n);
323 }
324 
325 unsigned short
327 {
328  if (mBandIndenting)
329  return *mBandIndenting;
330  else
332 }
333 
334 void
336 {
337  if (mBandIndenting)
338  *mBandIndenting = n;
339  else
340  mBandIndenting = new unsigned short(n);
341 }
342 
343 unsigned short
345 {
346  if (mLeftMargin)
347  return *mLeftMargin;
348  else
350 }
351 
352 
353 void
354 oofRepSettings::leftMargin(unsigned short n)
355 {
356  if (mLeftMargin)
357  *mLeftMargin = n;
358  else
359  mLeftMargin = new unsigned short(n);
360 }
361 
362 unsigned short
364 {
365  if (mRightMargin)
366  return *mRightMargin;
367  else
369 }
370 
371 
372 void
374 {
375  if (mRightMargin)
376  *mRightMargin = n;
377  else
378  mRightMargin = new unsigned short(n);
379 }
380 
381 unsigned short
383 {
384  if (mTopMargin)
385  return *mTopMargin;
386  else
388 }
389 
390 
391 void
392 oofRepSettings::topMargin(unsigned short n)
393 {
394  if (mTopMargin)
395  *mTopMargin = n;
396  else
397  mTopMargin = new unsigned short(n);
398 }
399 
400 unsigned short
402 {
403  if (mBottomMargin)
404  return *mBottomMargin;
405  else
407 }
408 
409 
410 void
412 {
413  if (mBottomMargin)
414  *mBottomMargin = n;
415  else
416  mBottomMargin = new unsigned short(n);
417 }
418 
419 
420 unsigned short
422 {
423  if (mColSepWidth)
424  return *mColSepWidth;
425  else
427 }
428 
429 
430 void
432 {
433  if (mColSepWidth)
434  *mColSepWidth = n;
435  else
436  mColSepWidth = new unsigned short(n);
437 }
438 
441 {
442  if (mDefaultPageHeaders)
443  return *mDefaultPageHeaders;
444  else
446 }
447 
448 
449 void
451 {
452  delete mDefaultPageHeaders;
453  mDefaultPageHeaders = adoptedList;
454 }
455 
456 
459 {
460  if (mDefaultPageFooters)
461  return *mDefaultPageFooters;
462  else
464 }
465 
466 
467 void
469 {
470  delete mDefaultPageFooters;
471  mDefaultPageFooters = adoptedList;
472 }
473 
474 
475 unsigned short
477 {
478  if (mBlockVertSep)
479  return *mBlockVertSep;
480  else
482 }
483 
484 
485 void
487 {
488  if (mBlockVertSep)
489  *mBlockVertSep = n;
490  else
491  mBlockVertSep = new unsigned short(n);
492 }
493 
494 
495 
498 {
499  if (mDefaultTextStyle)
500  return mDefaultTextStyle;
501  else
503 }
504 
505 
506 void
508 {
509  delete mDefaultTextStyle;
510  mDefaultTextStyle = adoptedStyle;
511 }
512 
513 
514 unsigned short
516 {
517  if (mDrawHeadingsDownToLevel)
518  return *mDrawHeadingsDownToLevel;
519  else
521 }
522 
523 
524 void
526 {
527  if (mDrawHeadingsDownToLevel)
528  *mDrawHeadingsDownToLevel = n;
529  else
530  mDrawHeadingsDownToLevel = new unsigned short(n);
531 }
532 
533 
534 bool
536 {
537  if (mPrintGraphsInMono)
538  return *mPrintGraphsInMono;
539  else
541 }
542 
543 
544 void
546 {
547  if (mPrintGraphsInMono)
548  *mPrintGraphsInMono = b;
549  else
550  mPrintGraphsInMono = new bool(b);
551 }
552 
553 
554 bool
556 {
557  if (mModalPreviewWindow)
558  return *mModalPreviewWindow;
559  else
561 }
562 
563 
564 void
566 {
567  if (mModalPreviewWindow)
568  *mModalPreviewWindow = b;
569  else
570  mModalPreviewWindow = new bool(b);
571 }
572 
573 
574 unsigned short
576 {
577  if (mGraphBandMinSizePercent)
578  return *mGraphBandMinSizePercent;
579  else
581 }
582 
583 
584 void
586 {
587  if (mGraphBandMinSizePercent)
588  *mGraphBandMinSizePercent = n;
589  else
590  mGraphBandMinSizePercent = new unsigned short(n);
591 }
592 
593 
596 {
597  if (mXMLsettings)
598  return mXMLsettings;
599  else
601 }
602 
603 
604 void
606 {
607  delete mXMLsettings;
608  mXMLsettings = adoptedSettings;
609 }
610 
611 
612 void
614 os << "----------ofrepsettings state-----------" << endl;
615 
616  os << "lineThickness: " << lineThickness() << endl
617  << "pageHeight: " << pageHeight() << endl
618  << "pageWidth: " << pageWidth() << endl
619  << "borderType: " << borderType() << endl
620  << "bandIndenting: " << bandIndenting() << endl
621  << "leftMargin: " << leftMargin() << endl
622  << "rightMargin: " << rightMargin() << endl
623  << "topMargin: " << topMargin() << endl
624  << "bottomMargin: " << bottomMargin() << endl
625  << "colSepWidth: " << colSepWidth() << endl
626  << "blockVertSep: " << blockVertSep() << endl;
627  os << "defaultTextStyle: "; defaultTextStyle()->extract(os);
628  //os << "defaultPageHeaders: "; defaultPageHeaders()->describe(os);
629  //os << "defaultPageFooters: ";defaultPageFooters()->describe(os);
630  os << "drawHeadingsDownToLevel" << drawHeadingsDownToLevel() << endl
631  << "printGraphsInMono";( printGraphsInMono()? (os << "true"):(os << "false"));
632  os << endl
633  << "modalPreviewWindow: ";
634  (modalPreviewWindow() ? os << "true":os << "false");
635  os << endl
636  << "graphBandMinSizePercent: " << graphBandMinSizePercent() << endl;
637 
638 
639 
640  os << "----------End ofrepsettings state-----------" << endl;
641 
642 }
643 
644 
645 oofRepEditor*
647 {
648  if (mRepEditor)
649  return mRepEditor;
650  else {
652  if (this==defSettings)
653  return NULL; // cope with default being left at NULL!
654  else
655  return defSettings->reportEditor(); // may still be null
656  }
657 }
658 
659 
660 void
662 {
663  delete mRepEditor;
664  mRepEditor = adoptedEditor;
665 }
oofRepBandList * clone()
Definition: oofrep1.cpp:1894
unsigned short drawHeadingsDownToLevel() const
Definition: oofrep3.cpp:515
Singleton used to initialise oofRepSettings.
Definition: oofrep.h:276
static void registerSerializable()
Definition: oofadorn.cpp:262
oofRepEditor * reportEditor() const
Definition: oofrep3.cpp:646
bool modalPreviewWindow() const
Definition: oofrep3.cpp:555
Tries to hide the different platforms and version issues with standard IO.
unsigned short borderType() const
Definition: oofrep3.cpp:308
void extract(std::ostream &) const
Definition: oofrep1.cpp:1765
unsigned short graphBandMinSizePercent() const
Definition: oofrep3.cpp:575
unsigned short bottomMargin() const
Definition: oofrep3.cpp:401
static void registerSerializable()
Definition: oofadorn.cpp:330
unsigned short lineThickness() const
Definition: oofrep3.cpp:251
unsigned short & refcount()
Definition: oofrep3.cpp:244
GUI report-writer layer of OOFILE database.
List of bands attached to report or other bands, eg: page headers.
Definition: oofrep.h:292
unsigned short topMargin() const
Definition: oofrep3.cpp:382
unsigned short bandIndenting() const
Definition: oofrep3.cpp:326
virtual oofRepTextStyle * clone() const
Definition: oofrep1.cpp:1733
static void registerSerializable()
Definition: oofadorn.cpp:394
unsigned short rightMargin() const
Definition: oofrep3.cpp:363
static OOF_Dictionary sFactories
Definition: oofxmldb.h:157
virtual oofRepXMLsettings * clone()
Definition: oofrpXML.cpp:683
static oofRepSettings * settings()
Definition: oofrep.h:2530
oofRepEditor encapsulates the factories for all the roles in editing reports and provides a single po...
Definition: oofrepeditor.h:38
Settings object for overriding behaviours of an instance of oofRep.
Definition: oofrep.h:173
oofRepBandList & defaultPageHeaders() const
Definition: oofrep3.cpp:440
Cross-platform specification of text style.
Definition: oofrep.h:732
unsigned short colSepWidth() const
Definition: oofrep3.cpp:421
oofRepBandList & defaultPageFooters() const
Definition: oofrep3.cpp:458
Creates XML environment and encapsulates other settings.
Definition: oofrep.h:150
unsigned short pageWidth() const
Definition: oofrep3.cpp:289
unsigned short leftMargin() const
Definition: oofrep3.cpp:344
oofRepTextStyle * defaultTextStyle() const
Definition: oofrep3.cpp:497
virtual oofRepEditor * clone() const
Definition: oofrepedit.cpp:699
unsigned short pageHeight() const
Definition: oofrep3.cpp:270
oofRepXMLsettings * XMLsettings() const
Definition: oofrep3.cpp:595
bool printGraphsInMono() const
Definition: oofrep3.cpp:535
unsigned short blockVertSep() const
Definition: oofrep3.cpp:476
Abstract base classes for report renderers.
void describe(std::ostream &)
Definition: oofrep3.cpp:613
Provides searchable dictionary of common OOFILE classes like dbTable.
Definition: oof1.h:159