LibreOffice API Development (v): processing paragraphs

Source: Internet
Author: User

In fact, UNO programming is a routine that gets an instance through a document factory and then looks at the functions of the instance's class member functions and sets the available properties. Of course, if it involves interacting with other components or instances, you need to study them carefully.

The code that handles the paragraph is simple and is posted directly.

void Manipulateparagraph (Reference <XTextDocument> xtextdocument) {Reference <XText> XText = xtextdocumen
    T->gettext ();
    Reference<xtextcursor> xtextcursor (Xtext->createtextcursorbyrange (Xtext->getend ()), UNO_QUERY);


    Reference <XPropertySet> Xprops (xtextcursor,uno_query);
    Set the left and right spacing sal_int32 margin;
    margin = 3000;
    any any_margin;
    Any_margin <<= margin;


    Xprops->setpropertyvalue ("Paraleftmargin", Any_margin);
    Set font any fontname;
    FontName <<= oustring::createfromascii ("Arial");

    Xprops->setpropertyvalue ("Charfontname", FontName);
    Set Font color Sal_int32 charcolor = 0x000099;
    any any_charcolor;
    Any_charcolor <<= CharColor;

    Xprops->setpropertyvalue ("CharColor", Any_charcolor);
    Set bold any fontweight;
    FontWeight <<=::com::sun::star::awt::FontWeight::BOLD;

    Xprops->setpropertyvalue ("Charweight", fontweight); Set Font size Sal_int32 Height;
    height = 20;
    any any_height;
    Any_height <<= height;
    Xprops->setpropertyvalue ("Charheight", any_height); Xtext->insertstring (Xtext->getend (), "This is a paragraph." We write words here and set paragraph style later. The effect is easy to have.

    Some atrributes are setted! ", false);
    Center Display Sal_int16 Adjust =:: Com::sun::star::style::P aragraphadjust::P aragraphadjust_center;
    any any_adjust;

    Any_adjust <<= adjust;
    
    Xprops->setpropertyvalue ("Paraadjust", any_adjust); Xtext->insertcontrolcharacter (Xtext->getend (),:: Com::sun::star::text::controlcharacter::P aragraph_break,
   
  
FALSE); }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.