Package org.odftoolkit.simple.text

Examples of org.odftoolkit.simple.text.Paragraph


  @Test
  public void testHorizontalRelative() throws Exception{
      String content = "This is a text box";
    try {
      TextDocument textDoc = TextDocument.newTextDocument();
      Paragraph p = textDoc.addParagraph("paragraph");
      FrameRectangle frameR = new FrameRectangle(4.21, 1.32, 4.41, 3.92, SupportedLinearMeasure.IN);
     
      Textbox box = p.addTextbox(frameR);
      box.setName("tbox name");
      box.setTextContent(content);
     
      FrameStyleHandler frameStyleHandler = new FrameStyleHandler(box);
      frameStyleHandler.setBackgroundColor(Color.YELLOW);
View Full Code Here


      // radiobox 1
      RadioButton radiobutton = (RadioButton) form.createRadioButton(doc,
          radioRtg, "RadioGroup1", "RadioButton 1", "1");

      // radiobutton 2
      Paragraph para = doc
          .addParagraph("RadioButton2 anchor to heading.");
      para.applyHeading();
      form.createRadioButton(para, radioRtg, "RadioGroup1",
          "RadioButton 2", "2");

      // radiobutton 3
      para = doc.addParagraph("Insert radiobutton3 here, as_char.");
View Full Code Here

    try {
      TextDocument doc = TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream(TEST_DOCUMENT));

      // declare simple variable
      VariableField simpleVariableField = Fields.createSimpleVariableField(doc, "test_con_variable");
      Paragraph varParagraph = doc.addParagraph("test_con_variable:");
      simpleVariableField.updateField("true", varParagraph.getOdfElement());

      // test condition field
      Paragraph newParagraph = doc.addParagraph("Condition Field Test:");
      ConditionField conditionField = Fields.createConditionField(newParagraph.getOdfElement(), "test_con_variable == \"true\"",
          "trueText", "falseText");
      Assert.assertNotNull(conditionField);
      conditionField.updateCondition("test_con_variable == \"false\"");
      TextConditionalTextElement textCondEle = (TextConditionalTextElement) conditionField.getOdfElement();
      Assert.assertEquals("ooow:test_con_variable == \"false\"", textCondEle.getTextConditionAttribute());
View Full Code Here

    try {
      TextDocument doc = TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream(TEST_DOCUMENT));

      // declare simple variable
      VariableField simpleVariableField = Fields.createSimpleVariableField(doc, "test_con_variable");
      Paragraph varParagraph = doc.addParagraph("test_con_variable:");
      simpleVariableField.updateField("true", varParagraph.getOdfElement());

      // test condition field
      Paragraph newParagraph = doc.addParagraph("Condition Field Test:");
      ConditionField conditionField = Fields.createConditionField(newParagraph.getOdfElement(), "test_con_variable == \"true\"",
          "trueText", "falseText");
      Assert.assertNotNull(conditionField);
      conditionField.updateTrueText("trueTextUpdate");
     
      //validate
View Full Code Here

    try {
      TextDocument doc = TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream(TEST_DOCUMENT));

      // declare simple variable
      VariableField simpleVariableField = Fields.createSimpleVariableField(doc, "test_con_variable");
      Paragraph varParagraph = doc.addParagraph("test_con_variable:");
      simpleVariableField.updateField("true", varParagraph.getOdfElement());

      // test condition field
      Paragraph newParagraph = doc.addParagraph("Condition Field Test:");
      ConditionField conditionField = Fields.createConditionField(newParagraph.getOdfElement(), "test_con_variable == \"true\"",
          "trueText", "falseText");
      Assert.assertNotNull(conditionField);
     
      conditionField.updateCondition("test_con_variable == \"false\"");
      conditionField.updateFalseText("falseTextUpdate");
View Full Code Here

    try {
      TextDocument doc = TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream(TEST_DOCUMENT));

      // declare simple variable
      VariableField simpleVariableField = Fields.createSimpleVariableField(doc, "test_con_variable");
      Paragraph varParagraph = doc.addParagraph("test_con_variable:");
      simpleVariableField.updateField("true", varParagraph.getOdfElement());

      // test condition field
      Paragraph newParagraph = doc.addParagraph("Condition Field Test:");
      ConditionField conditionField = Fields.createConditionField(newParagraph.getOdfElement(), "test_con_variable == \"true\"",
          "trueText", "falseText");
      Assert.assertNotNull(conditionField);

      // validate
      TextConditionalTextElement conditionalTextElement = (TextConditionalTextElement) conditionField.getOdfElement();
View Full Code Here

    try {
      TextDocument doc = TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream(TEST_DOCUMENT));

      // declare simple variable
      VariableField simpleVariableField = Fields.createSimpleVariableField(doc, "test_con_variable");
      Paragraph varParagraph = doc.addParagraph("test_con_variable:");
      simpleVariableField.updateField("true", varParagraph.getOdfElement());

      // test condition field
      Paragraph newParagraph = doc.addParagraph("Condition Field Test:");
      ConditionField conditionField = Fields.createConditionField(newParagraph.getOdfElement(), "test_con_variable == \"true\"",
          "trueText", "falseText");
      Assert.assertNotNull(conditionField);
     
      FieldType fieldType = conditionField.getFieldType();
      Assert.assertEquals(FieldType.CONDITION_FIELD, fieldType);

      // test hide field
      newParagraph = doc.addParagraph("Hide Text Field Test:");
      conditionField = Fields.createHiddenTextField(newParagraph.getOdfElement(), "test_con_variable == \"true\"", "hiddenText");
      FieldType fieldType1 = conditionField.getFieldType();
      Assert.assertEquals(FieldType.HIDDEN_TEXT_FIELD, fieldType1);
    } catch (Exception e) {
      Logger.getLogger(ConditionFieldTest.class.getName()).log(Level.SEVERE, null, e);
      Assert.fail(e.getMessage());
View Full Code Here

  @Test
  public void testGetSetBorder() {
    try {
      TextDocument doc = TextDocument.newTextDocument();
      Paragraph paragraph1 = doc.addParagraph("paragraph1");
     
      paragraph1.setHorizontalAlignment(HorizontalAlignmentType.JUSTIFY);
      HorizontalAlignmentType align = paragraph1.getHorizontalAlignment();
      Assert.assertEquals(HorizontalAlignmentType.JUSTIFY, align);

      paragraph1.setHorizontalAlignment(HorizontalAlignmentType.LEFT);
      align = paragraph1.getHorizontalAlignment();
      Assert.assertEquals(HorizontalAlignmentType.LEFT, align);

      paragraph1.setHorizontalAlignment(HorizontalAlignmentType.RIGHT);
      align = paragraph1.getHorizontalAlignment();
      Assert.assertEquals(HorizontalAlignmentType.RIGHT, align);

      doc.save(ResourceUtilities.newTestOutputFile("TestParagraphPropertiesSetGetHoriAlignment.odt"));
    } catch (Exception e) {
      LOGGER.log(Level.SEVERE, e.getMessage(), e);
View Full Code Here

      Form form = doc.createForm("Test Form");

      Paragraph.newParagraph(doc);
      Paragraph.newParagraph(doc);
      Paragraph.newParagraph(doc);
      Paragraph para = Paragraph.newParagraph(doc);
      FormControl dateField = form.createDateField(para, fieldRtg,
          "DateField", "20120715");
      ((DateField) dateField).setSpinButonVisible(true);
      ((DateField) dateField).setDropDownVisible(true);
      ((DateField) dateField).formatDate("yy/MM/dd", Locale.US);

      Paragraph.newParagraph(doc);
      Paragraph.newParagraph(doc);
      Paragraph.newParagraph(doc);
      para = Paragraph.newParagraph(doc);
      FormControl timeField = form.createTimeField(para, fieldRtg,
          "TimeField", "15234000");
      ((TimeField) timeField).setSpinButonVisible(true);
      ((TimeField) timeField).formatTime("HH:mm a", Locale.US);

      Paragraph.newParagraph(doc);
      Paragraph.newParagraph(doc);
      Paragraph.newParagraph(doc);
      para = Paragraph.newParagraph(doc);
      FormControl numericField = form.createNumericField(para, fieldRtg,
          "NumericField", "-154.3567");
      ((NumericField) numericField).setDecimalAccuracy(3);
      ((NumericField) numericField).setSpinButonVisible(true);

      Paragraph.newParagraph(doc);
      Paragraph.newParagraph(doc);
      Paragraph.newParagraph(doc);
      para = Paragraph.newParagraph(doc);
      FormControl patternField = form.createPatternField(para, fieldRtg,
          "PatternField", "12345");
      ((PatternField) patternField).setLiteralMask("###");
      ((PatternField) patternField).setEditMask("abc");
      ((PatternField) patternField).setSpinButonVisible(true);

      Paragraph.newParagraph(doc);
      Paragraph.newParagraph(doc);
      Paragraph.newParagraph(doc);
      para = Paragraph.newParagraph(doc);
      para.appendTextContent("insert currency field here:");
      FormControl currencyField = form.createCurrencyField(para,
          fieldRtg, "CurrencyField", "135.467");
      ((CurrencyField) currencyField).setCurrencySymbol("CNY");
      ((CurrencyField) currencyField).setDecimalAccuracy(4);
      ((CurrencyField) currencyField).setSpinButonVisible(true);
View Full Code Here

    try {
      TextDocument doc = TextDocument.newTextDocument();
      Form form1 = doc.createForm("Form1");
      form1.createButton(doc, btnRtg, "Button", "Push Button");

      Paragraph para = doc.addParagraph("Insert a Label here.");
      Form form2 = doc.createForm("Form2");
      form2.createLabel(para, btnRtg, "Label", "Label");

      Form form3 = doc.createForm("Form3");
      Table table1 = Table.newTable(doc, 2, 2);
View Full Code Here

TOP

Related Classes of org.odftoolkit.simple.text.Paragraph

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.