Class JsonOperationProducer

java.lang.Object
org.odftoolkit.odfdom.changes.JsonOperationProducer

public class JsonOperationProducer extends Object
ToDo: Is it more flexible to build a different queue for OperationQueue and create an JSON exporter? Can a JSONArray / JSONObject be initialized with an existing queue?
Author:
svante.schubertATgmail.com
  • Constructor Details

    • JsonOperationProducer

      public JsonOperationProducer()
  • Method Details

    • getDocumentOperations

      public org.json.JSONObject getDocumentOperations()
    • getCurrentOperationIndex

      public int getCurrentOperationIndex()
      Used for repeated elements, repeats a set of operations
    • add

      public void add(String componentType, List<Integer> start, Map<String,Object> formattingProperties, String context)
    • addAnnotation

      public void addAnnotation(List<Integer> start, String id, String author, String date, String context)
    • addRange

      public void addRange(List<Integer> start, String id, String context)
    • formatColumns

      public void formatColumns(List<Integer> start, Map<String,Object> formattingProperties, Integer firstColumn, Integer lastColumn, String context)
      Parameters:
      start - : An array, that contains the number of that paragraph, before which the new paragraph shall be inserted. Has the last paragraph the number 2, so causes para=3, that the new paragraph will be inserted at the end. para=4 is not allowed in this case.
    • formatRows

      public void formatRows(List<Integer> start, Map<String,Object> formattingProperties, Integer firstRow, Integer lastRow, Integer previousRowRepeated, String context)
      Parameters:
      start - : An array, that contains the number of that paragraph, before which the new paragraph shall be inserted. Has the last paragraph the number 2, so causes para=3, that the new paragraph will be inserted at the end. para=4 is not allowed in this case.
    • mergeCells

      public void mergeCells(List<Integer> position, int columns, int rows)
    • addText

      public void addText(List<Integer> start, String text, String context)
      Parameters:
      text - : text to be inserted into the specified paragraph at the specified position
      start - : an array that contains the position, where the new text shall be inserted.
    • format

      public void format(List<Integer> start, List<Integer> end, Map<String,Object> attrs, String context)
    • addImage

      public void addImage(List<Integer> start, Map<String,Object> hardFormatations, String context)
    • addShape

      public void addShape(List<Integer> start, Map<String,Object> hardFormatations, String context, boolean isGroup)
    • addTable

      public void addTable(List<Integer> start, Map<String,Object> hardFormatations, List<Integer> tableGrid, String tableName, String context)
    • addExceededTable

      public void addExceededTable(List<Integer> start, int columns, int rows, List<Integer> tableGrid, String context)
    • addField

      public void addField(List<Integer> start, String fieldType, String fieldContent, Map<String,Object> fieldAttributes, String context)
    • addStyleSheet

      public void addStyleSheet(String styleId, String familyID, String displayName, Map<String,Object> componentProps, String parentStyle, String nextStyleId, Integer outlineLevel, boolean isDefaultStyle, boolean isHidden, String custom)
      * addStylesheet name: 'addStylesheet' type: "table" styleId: The identifier of this stylesheet (unique for the corresponding type). stylename: The readable name of this style sheet. attrs: JSONObject, contains formatting attributes as nested JSON objects, keyed by attribute family, as well as other properties specific to a family. Must support the attributes of the main attribute family, may support attributes of other families. See chapter "Style Sheet Properties" below for a list of supported values. parent: (string, optional) The identifier of the parent style sheet that derives formatting attributes to this style sheet (default: no parent). hidden: (boolean, optional) Whether the style sheet is hidden in the user interface (default: false). uipriority: (integer, optional) The priority of the style sheet used to order style sheet in the user interface. The lower the value the higher the priority (default: 0). default: (boolean, optional) Whether this style sheet is the default style sheet of the family. Only one style sheet per family can be the default style sheet (default: false). pooldefault: (boolean, optional) Whether this style sheet is the pool default style sheet. (default: false). OOXML may have on the table default style properties for table Object { type: table properties } '' row Object { type: row properties } '' cell Object { type: cell properties } '' paragraph Object { type: paragraph properties } '' character Object { type: character properties } We need to split this table style into an additional row and cell style and addChild it as parent for those.
    • addFontData

      public void addFontData(String fontName, String[] altNames, String family, String familyGeneric, String pitch, String panose1)
    • addDocumentData

      public void addDocumentData(org.json.JSONObject componentProps)
      Parameters:
      componentProps - is a JSONObject that has the family ID as key (e.g 'page') and the properties as JSON object as value
    • getListStyle

      public static String getListStyle(ArrayDeque<ParagraphListProperties> listStyleStack, TextParagraphElementBase p)
      ODF List Style inheritance will be resolved:
      1. The paragraph/heading's list style reference from its closest text:list or text:list-item ancestor is taken. text:list uses the attribute
    • getHardStyles

      public Map<String,Object> getHardStyles(OdfStylableElement styleElement)
      Maps the styles of the given stylable ODF element to operations. In case the ODF element uses automatic styles, all styles will be returned as property map. In case the ODF element uses template styles, an operation for each style is being triggered, which not have been triggered by now.
      Returns:
      the mapped automatic style grouped by property set
    • addListStyle

      public void addListStyle(OdfSchemaDocument doc, Map<String,TextListStyleElement> autoListStyles, String styleId)
      Creates the operation to insert a list style. All template list styles should be already set during initialization.
    • addListStyle

      public void addListStyle(TextListStyleElement listStyle)
      After checking if the given list style was not declared before as operation call. A new list style will be mapped to an operation.

      The <text:list-style> element has the following attributes: style:display-name, style:name and text:consecutive-numbering.

    • triggerStyleHierarchyOps

      public Integer triggerStyleHierarchyOps(OdfOfficeStyles officeStyles, OdfStyleFamily styleFamily, OdfStyleBase style)
    • triggerDefaultStyleOp

      public Integer triggerDefaultStyleOp(OdfStyleFamily styleFamily, OdfStyleBase style)
      Tests first if the default style was already added to the document, than triggers a addStylesheet operation
    • addPageProperties

      public org.json.JSONObject addPageProperties(OdfStylesDom stylesDom)
      trigger pageStyle operations, only the "standard" page style will be returned
    • addDocumentProperties

      public void addDocumentProperties(OdfStylesDom stylesDom, Integer defaultTabStopWidth, org.json.JSONObject defaultPageStyles)
    • addHeaderFooter

      public void addHeaderFooter(String contextName, PageArea pageArea, org.json.JSONObject attrs)
      Adding a default footer style operation
    • calculateCrops

      public static void calculateCrops(OdfElement image, String href, org.json.JSONObject imageProps)
      LO/AO does not interpret clipping as in FO/CSS http://www.w3.org/TR/CSS2/visufx.html#propdef-clip Instead the clip values measure the distance from each border to the start of the viewed area. The clip vales are taking measure from the original size, which is not part of the OFD XML, therefore the image have to be loaded for receiving the size.