Package fr.sewatech.sewatoool.impress.helper

Examples of fr.sewatech.sewatoool.impress.helper.BundleHelper


   *
   * @throws Exception
   */
  public void generateToc(ImpressDocument document, boolean longTOC,
      boolean shortTOC) throws Exception {
    BundleHelper bundle = BundleHelper.getInstance();
    TocDesc toc = new TocDesc(document.listPages(), bundle.getTocTitle());
    toc.purge();

    TocDesc shortToc = new TocDesc(toc);

    if (longTOC) {
      logger.info("Génération de la table des matières complète");
      int slideNumber = document.findPageByName(bundle.getTocPageName());

      int tocPageNumber = document.countPages();

      if (slideNumber == 0) {
        slideNumber = tocPageNumber;
        document.addSlide(tocPageNumber, toc.getTitle(), bundle
            .getTocPageStyle());
      }

      document.writeTOC(slideNumber, toc);

      if (toc.getAllSlides().size() > 0) {
        document.addSlide(slideNumber + 1, toc.getTitle() + "1", bundle
            .getTocPageStyle());
        toc.setTocIndex(1);
        document.writeTOC(slideNumber + 1, toc);
      }
    }

    if (shortTOC) {
      logger.info("Génération de la table des matières simplifiée");
      int shortTocNumber = document.findPageByName(bundle
          .getShortTocPageName());
      if (shortTocNumber > 0) {
        document.writeShortTOC(shortTocNumber, shortToc);
      }
    }
View Full Code Here


   *            Table des matieres
   * @throws ImpressException
   */
  public void writeTOC(int sommaireIndex, TocDesc toc)
      throws ImpressException {
    BundleHelper bundle = BundleHelper.getInstance();

    XDrawPage notesPage = findNotesPageByIndex(sommaireIndex);

    // Suppression du shape principal
    notesPage.remove(findShapeByType(notesPage, SHAPE_TYPE_PAGE));
    // Mise en forme du shape de notes
    XShape notesShape = findShapeByType(notesPage, SHAPE_TYPE_NOTES);
    int xmargin = bundle.getTocXMargin() * 100;
    int ymargin = bundle.getTocYMargin() * 100;
    try {
      notesShape.setPosition(new Point(xmargin, ymargin));
      notesShape.setSize(new Size(21000 - 2 * xmargin,
          29700 - 2 * ymargin));
      XPropertySet xNotesShapeProps = unoCast(XPropertySet.class,
          notesShape);
      xNotesShapeProps.setPropertyValue("FillStyle", StyleHelper
          .getFillStyle(bundle.getTocFillStyle()));
      xNotesShapeProps.setPropertyValue("FillColor", bundle
          .getTocFillColor());
      xNotesShapeProps.setPropertyValue("ZOrder", 999);

    } catch (Exception e) {
      logger.warn("Probleme non prévu, mais pas forcément grace", e);
    }

    if (logger.isTraceEnabled()) {
      traceShapes(notesPage);
    }

    // Zone de texte des notes
    XText xNoteText = unoCast(XText.class, notesShape);
    XTextCursor cursor = xNoteText.createTextCursor();
    cursor.getStart();

    XPropertySet xCursorProps = unoCast(XPropertySet.class, cursor);
    tabStops = new TabStop[2];
    tabStops[0] = new TabStop(xmargin, TabAlign.LEFT, ',', ' ');
    tabStops[1] = new TabStop(21000 - 2 * xmargin - 2000, TabAlign.RIGHT,
        ',', '.');
    // Remarque : je ne sais plus comment ça marche...

    // Titre de la table de matieres
    try {
      applyTextStyle(xCursorProps, "preference.toc.notes.title");
      xNoteText.insertString(cursor, toc.getTitle(), true);
      xNoteText.insertControlCharacter(cursor,
          ControlCharacter.PARAGRAPH_BREAK, false);
    } catch (Exception e) {
      e.printStackTrace();
    }

    Iterator<SlideDesc> iter = toc.getAllSlides().iterator();
    int maxSize = (29700 - 2 * ymargin) / 40 - 18; // en nombre de points
    int[] heights = bundle.getTocFontHeight();
    int textSize = 2 * bundle.getTocTitleHeight();

    while (iter.hasNext() && (textSize < maxSize)) {
      SlideDesc slide = (SlideDesc) iter.next();
      textSize += heights[slide.getLevel() - 1];
      addContentEntry(xNoteText, cursor, slide);
View Full Code Here

   */
  public void writeShortTOC(int planIndex, TocDesc toc)
      throws ImpressException {

    try {
      BundleHelper bundle = BundleHelper.getInstance();

      XDrawPage planPage = findPageByIndex(planIndex);

      // Shape de titre
      XShape titleShape = findShapeByType(planPage, SHAPE_TYPE_TITLETEXT);
      if (titleShape != null) {
        XSimpleText titleText = unoCast(XSimpleText.class, titleShape);
        titleText.setString(bundle.getShortTocTitle());
      }

      // Shape principal
      XShape mainShape = findShapeByType(planPage, SHAPE_TYPE_OUTLINER);
      if (mainShape != null) {
        XSimpleText mainText = unoCast(XSimpleText.class, mainShape);

        XTextCursor cursor = mainText.createTextCursor();
        cursor.getStart();

        XPropertySet xCursorProps = unoCast(XPropertySet.class, cursor);
        TabStop[] tabStops = new TabStop[1];
        tabStops[0] = new TabStop(bundle.getShortTocTabulation(),
            TabAlign.RIGHT, ',', '.');
        xCursorProps.setPropertyValue("ParaTabStops", tabStops);

        StringBuilder planBuilder = new StringBuilder();
        String newLine = "";
        for (SlideDesc slide : toc.getAllSlides()) {
          if (slide.getLevel() == 1) {
            planBuilder.append(newLine);
            planBuilder.append(slide.getTitle());
            planBuilder.append("\t");
            planBuilder.append(slide.getPage());
            newLine = "\n";
          }
        }
        mainText.setString(planBuilder.toString());

      }

      // Shape de notes
      XPresentationPage xPresentationPage = unoCast(
          XPresentationPage.class, planPage);
      XDrawPage planNotesPage = xPresentationPage.getNotesPage();
      XShape notesShape = findShapeByType(planNotesPage, SHAPE_TYPE_NOTES);
      if (notesShape != null) {
        XSimpleText notesText = unoCast(XSimpleText.class, notesShape);
        notesText.setString(bundle.getShortTocNotesText());
      }

    } catch (Exception e) {
      throw new ImpressException(e);
    }
View Full Code Here

   * @throws Exception
   */
  private void applyTextStyle(XPropertySet xCursorProps, String prefix)
      throws ImpressException {
    try {
      BundleHelper bundle = BundleHelper.getInstance();
      xCursorProps.setPropertyValue("CharFontName", bundle
          .getFont(prefix));
      xCursorProps.setPropertyValue("CharHeight", bundle
          .getCharHeight(prefix));
      xCursorProps.setPropertyValue("CharColor", bundle
          .getCharColor(prefix));
      xCursorProps.setPropertyValue("CharPosture", StyleHelper
          .getFontPosture(bundle.getCharPosture(prefix)));
      xCursorProps.setPropertyValue("CharWeight", StyleHelper
          .getFontWeight(bundle.getCharWeight(prefix)));
    } catch (Exception e) {
      throw new ImpressException(e);
    }
  }
View Full Code Here

TOP

Related Classes of fr.sewatech.sewatoool.impress.helper.BundleHelper

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.