summaryrefslogtreecommitdiff
path: root/src/lib/preprocess/VsdElementListPreprocessor.h
blob: b07d8c0283a63136c5068688cad17769b6bb3de5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef _VSD_ELEMENT_LIST_PREPROCESSOR_H_INCLUDED_
#define _VSD_ELEMENT_LIST_PREPROCESSOR_H_INCLUDED_

#include "SvgSpan.h"
#include "VSDOutputElementList.h"

#include <vector>


class SvgDC;
class SvgTextObjectC;

namespace libvisio
{
class VSDStyleOutputElement;
class VSDPathOutputElement;
}

/**
 * Pre-processes a specified list of VSD output elements before they are rendered to the output
 * SVG document. The purpose is to calculate additional data related to the elements and make it
 * available to the renderer, so that the resulting SVG is the closest possible match of the
 * original. In particular, text aligment and wrapping within parent text boxes are addressed here.
 * Preprocessing produces a new element list, which in comparison to the input one may add new
 * elements, remove existing ones, or add or modify properties of other elements.
 */
class VsdElementListPreprocessorC
{
public:
  typedef std::vector<libvisio::VSDOutputElement *> ElementListTp;
  typedef ElementListTp::iterator ElementListItTp;
  typedef ElementListTp::const_iterator ElementListConstItTp;

  void Process(const ElementListTp &elements, ElementListTp &outElements);

private:
  ElementListConstItTp ProcessTextObject(
    ElementListConstItTp startIt, ElementListConstItTp endIt, ElementListTp &outElements,
    SvgDC &dc);

  ElementListConstItTp ProcessTextObjectOnePass(
    ElementListConstItTp startIt, ElementListConstItTp endIt,
    ElementListTp &outElements, SvgTextObjectC *pTextObject);

  ElementListConstItTp ProcessParagraph(
    ElementListConstItTp startIt, ElementListConstItTp endIt,
    ElementListTp &outElements, SvgTextObjectC *pTextObject);

  ElementListConstItTp ProcessUnorderedList(
    ElementListConstItTp startIt, ElementListConstItTp endIt,
    ElementListTp &outElements, SvgTextObjectC *pTextObject);

  ElementListConstItTp ProcessListElement(
    ElementListConstItTp startIt, ElementListConstItTp endIt,
    ElementListTp &outElements, SvgTextObjectC *pTextObject);

  ElementListConstItTp ProcessSpan(
    ElementListConstItTp startIt, ElementListConstItTp endIt,
    ElementListTp &outElements, SvgTextObjectC *pTextObject);

  void GenerateSpans(
    const SpansTp &spans, ElementListTp &outElements, SvgTextObjectC *pTextObject);

  libvisio::VSDStyleOutputElement *CreateStyleOutput(const std::string &fillColor);

  libvisio::VSDPathOutputElement *CreateRectPathOutput(
    double x1Inch, double y1Inch, double x2Inch, double y2Inch);
};


#endif // _VSD_ELEMENT_LIST_PREPROCESSOR_H_INCLUDED_