[Solved] Personalization of text added by insertString() method

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Makmilan
Posts: 6
Joined: Wed Mar 16, 2022 12:26 am

[Solved] Personalization of text added by insertString() method

Post by Makmilan »

Hello
I would like to know how to do more personalization of a text added by the command

Code: Select all

myText.insertString(myCursor, Sting1, False) 
I found these commands for Color and Bold

Code: Select all

myCursor.CharColor = OOoRGB(0, 0, 200)
        myCursor.CharWeight = OOOawtFontWeightBOLD


but I am looking to change the font family
and as well as the font size and also the center in a text
I program in VB.net

thank you to anyone who can help me
any examples are welcome
Last edited by MrProgrammer on Wed Sep 21, 2022 9:18 pm, edited 1 time in total.
Reason: Tagged ✓ [Solved] -- MrProgrammer, forum moderator
OpenOffice 4.1.11 On Windows 8.1
FJCC
Moderator
Posts: 9248
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: personalization of a text added by the command in VB.net

Post by FJCC »

Here are the properties of a text cursor, obtained with the MRI extension. Using MRI or Xray is essential for writing macros and not going insane.

Code: Select all

(Name)                           (Value Type)               (Value)                       (Info.)   (Attr.)              (Handle)  
AvailableServiceNames            []string                   -Sequence-                    Pseud     Read_Only                 
BorderDistance                   long                       0                                       Maybevoid            100  
BottomBorder                     .table.BorderLine          -STRUCT-                                Maybevoid            100  
BottomBorderDistance             long                       0                                       Maybevoid            100  
BreakType                        .style.BreakType           NONE                                    Maybevoid             88  
Cell                             .table.XCell               -void-                                  Read_Only,Maybevoid  22220  
CharAutoEscapement               boolean                    False                                   Maybevoid              6  
CharAutoKerning                  boolean                    True                                    Maybevoid             17  
CharAutoStyleName                string                     0                                       Maybevoid             47  
CharBackColor                    long                       -1                                      Maybevoid             21  
CharBackTransparent              boolean                    True                                    Maybevoid             21  
CharCaseMap                      short                      0                                       Maybevoid              1  
CharColor                        long                       -1                                      Maybevoid              3  
CharCombineIsOn                  boolean                    False                                   Maybevoid             34  
CharCombinePrefix                string                     ""                                      Maybevoid             34  
CharCombineSuffix                string                     ""                                      Maybevoid             34  
CharContoured                    boolean                    False                                   Maybevoid              4  
CharCrossedOut                   boolean                    False                                   Maybevoid              5  
CharEmphasis                     short                      0                                       Maybevoid             33  
CharEscapement                   short                      0                                       Maybevoid              6  
CharEscapementHeight             byte                       100                                     Maybevoid              6  
CharFlash                        boolean                    False                                   Maybevoid             18  
CharFontCharSet                  short                      1                                       Maybevoid              7  
CharFontCharSetAsian             short                      1                                       Maybevoid             22  
CharFontCharSetComplex           short                      1                                       Maybevoid             27  
CharFontFamily                   short                      3                                       Maybevoid              7  
CharFontFamilyAsian              short                      6                                       Maybevoid             22  
CharFontFamilyComplex            short                      6                                       Maybevoid             27  
CharFontName                     string                     Times New Roman                         Maybevoid              7  
CharFontNameAsian                string                     SimSun                                  Maybevoid             22  
CharFontNameComplex              string                     Arial                                   Maybevoid             27  
CharFontPitch                    short                      2                                       Maybevoid              7  
CharFontPitchAsian               short                      2                                       Maybevoid             22  
CharFontPitchComplex             short                      2                                       Maybevoid             27  
CharFontStyleName                string                     ""                                      Maybevoid              7  
CharFontStyleNameAsian           string                     ""                                      Maybevoid             22  
CharFontStyleNameComplex         string                     ""                                      Maybevoid             27  
CharHeight                       float                      12.0                                    Maybevoid              8  
CharHeightAsian                  float                      12.0                                    Maybevoid             23  
CharHeightComplex                float                      12.0                                    Maybevoid             28  
CharHidden                       boolean                    False                                   Maybevoid             37  
CharKerning                      short                      0                                       Maybevoid              9  
CharLocale                       .lang.Locale               -STRUCT-                                Maybevoid             10  
CharLocaleAsian                  .lang.Locale               -STRUCT-                                Maybevoid             24  
CharLocaleComplex                .lang.Locale               -STRUCT-                                Maybevoid             29  
CharNoHyphenation                boolean                    True                                    Maybevoid             19  
CharOverline                     short                      0                                       Maybevoid             38  
CharOverlineColor                long                       -1                                      Maybevoid             38  
CharOverlineHasColor             boolean                    False                                   Maybevoid             38  
CharPosture                      .awt.FontSlant             NONE                                    Maybevoid             11  
CharPostureAsian                 .awt.FontSlant             NONE                                    Maybevoid             25  
CharPostureComplex               .awt.FontSlant             NONE                                    Maybevoid             30  
CharRelief                       short                      0                                       Maybevoid             36  
CharRotation                     short                      0                                       Maybevoid             32  
CharRotationIsFitToLine          boolean                    False                                   Maybevoid             32  
CharScaleWidth                   short                      100                                     Maybevoid             35  
CharShadowed                     boolean                    False                                   Maybevoid             13  
CharStrikeout                    short                      0                                       Maybevoid              5  
CharStyleName                    string                     ""                                      Maybevoid             49  
CharStyleNames                   []string                   -void-                                  Maybevoid            22294  
CharUnderline                    short                      0                                       Maybevoid             14  
CharUnderlineColor               long                       -1                                      Maybevoid             14  
CharUnderlineHasColor            boolean                    False                                   Maybevoid             14  
CharWeight                       float                      100.0                                   Maybevoid             15  
CharWeightAsian                  float                      100.0                                   Maybevoid             26  
CharWeightComplex                float                      100.0                                   Maybevoid             31  
CharWordMode                     boolean                    False                                   Maybevoid             16  
ContinueingPreviousSubTree       boolean                    False                                   Read_Only            22309  
DocumentIndex                    .text.XDocumentIndex       -void-                                  Read_Only,Maybevoid  22217  
DocumentIndexMark                .text.XDocumentIndexMark   -void-                                  Read_Only,Maybevoid  22216  
DropCapCharStyleName             string                     ""                                      Maybevoid             67  
DropCapFormat                    .style.DropCapFormat       -STRUCT-                                Maybevoid             67  
DropCapWholeWord                 boolean                    False                                   Maybevoid             67  
ElementType                      type                       com.sun.star.text.XTextRange  Pseud     Read_Only                 
End                              .text.XTextRange           -INTERFACE-                   Pseud     Read_Only                 
Endnote                          .text.XFootnote            -void-                                  Read_Only,Maybevoid  22225  
Footnote                         .text.XFootnote            -void-                                  Read_Only,Maybevoid  22224  
HyperLinkEvents                  .container.XNameReplace    -INTERFACE-                             Maybevoid             48  
HyperLinkName                    string                     ""                                      Maybevoid             48  
HyperLinkTarget                  string                     ""                                      Maybevoid             48  
HyperLinkURL                     string                     ""                                      Maybevoid             48  
ImplementationId                 []byte                     -SEQUENCE-                    Pseud     Read_Only                 
ImplementationName               string                     SwXTextCursor                 Pseud     Read_Only                 
IsSkipHiddenText                 boolean                    False                                                        22272  
IsSkipProtectedText              boolean                    False                                                        22273  
LeftBorder                       .table.BorderLine          -STRUCT-                                Maybevoid            100  
LeftBorderDistance               long                       0                                       Maybevoid            100  
ListId                           string                     ""                                      Maybevoid            22307  
ListLabelString                  string                     ""                                      Read_Only            22310  
NestedTextContent                .text.XTextContent         -void-                                  Read_Only,Maybevoid  22313  
NumberingIsNumber                boolean                    False                                   Maybevoid            22269  
NumberingLevel                   short                                                    Ignored   Maybevoid                 
NumberingRules                   .container.XIndexReplace   -void-                                  Maybevoid            22215  
NumberingStartValue              short                                                    Ignored   Maybevoid                 
NumberingStyleName               string                     ""                                      Maybevoid             69  
OutlineLevel                     short                      0                                       Maybevoid             76  
PageDescName                     string                     -void-                                  Maybevoid             87  
PageNumberOffset                 short                      0                                       Maybevoid             87  
PageStyleName                    string                     Standard                                Read_Only,Maybevoid  22210  
ParaAdjust                       short                      0                                       Maybevoid             61  
ParaAutoStyleName                string                     0                                       Maybevoid            120  
ParaBackColor                    long                       -1                                      Maybevoid             99  
ParaBackGraphicFilter            string                     ""                                      Maybevoid             99  
ParaBackGraphicLocation          .style.GraphicLocation     NONE                                    Maybevoid             99  
ParaBackGraphicURL               string                     ""                                      Maybevoid             99  
ParaBackTransparent              boolean                    True                                    Maybevoid             99  
ParaBottomMargin                 long                       0                                       Maybevoid             86  
ParaChapterNumberingLevel        byte                       -Error-                                                           
ParaConditionalStyleName         string                     Standard                                Read_Only            22267  
ParaExpandSingleWord             boolean                    False                                   Maybevoid             61  
ParaFirstLineIndent              long                       0                                       Maybevoid             85  
ParaHyphenationMaxHyphens        short                      0                                       Maybevoid             66  
ParaHyphenationMaxLeadingChars   short                      2                                       Maybevoid             66  
ParaHyphenationMaxTrailingChars  short                      2                                       Maybevoid             66  
ParaIsAutoFirstLineIndent        boolean                    False                                   Maybevoid             85  
ParaIsCharacterDistance          boolean                    True                                    Maybevoid             70  
ParaIsConnectBorder              boolean                    True                                    Maybevoid             75  
ParaIsForbiddenRules             boolean                    True                                    Maybevoid             72  
ParaIsHangingPunctuation         boolean                    True                                    Maybevoid             71  
ParaIsHyphenation                boolean                    False                                   Maybevoid             66  
ParaIsNumberingRestart           boolean                                                  Ignored   Maybevoid                 
ParaKeepTogether                 boolean                    False                                   Maybevoid            104  
ParaLastLineAdjust               short                      0                                       Maybevoid             61  
ParaLeftMargin                   long                       0                                       Maybevoid             85  
ParaLineNumberCount              boolean                    True                                    Maybevoid            110  
ParaLineNumberStartValue         long                       0                                       Maybevoid            110  
ParaLineSpacing                  .style.LineSpacing         -STRUCT-                                Maybevoid             60  
ParaOrphans                      byte                       0                                       Maybevoid             63  
ParaRegisterModeActive           boolean                    False                                   Maybevoid             68  
ParaRightMargin                  long                       0                                       Maybevoid             85  
ParaShadowFormat                 .table.ShadowFormat        -STRUCT-                                                     101  
ParaSplit                        boolean                    True                                    Maybevoid             62  
ParaStyleName                    string                     Standard                                Maybevoid            22209  
ParaTabStops                     [].style.TabStop           -Sequence-                              Maybevoid             65  
ParaTopMargin                    long                       0                                       Maybevoid             86  
ParaUserDefinedAttributes        .container.XNameContainer  -INTERFACE-                             Maybevoid            143  
ParaVertAlignment                short                      0                                       Maybevoid             73  
ParaWidows                       byte                       0                                       Maybevoid             64  
PropertiesToDefault              []string                                                 Pseud     WriteOnly                 
PropertySetInfo                  .beans.XPropertySetInfo    -INTERFACE-                   Pseud     Read_Only                 
PropertyToDefault                string                                                   Ignored                             
ReferenceMark                    .text.XTextContent         -void-                                  Read_Only,Maybevoid  22222  
RightBorder                      .table.BorderLine          -STRUCT-                                Maybevoid            100  
RightBorderDistance              long                       0                                       Maybevoid            100  
RubyAdjust                       short                      0                                       Maybevoid             50  
RubyCharStyleName                string                     ""                                      Maybevoid             50  
RubyIsAbove                      boolean                    True                                    Maybevoid             50  
RubyText                         string                     ""                                      Maybevoid             50  
SnapToGrid                       boolean                    True                                    Maybevoid             74  
Start                            .text.XTextRange           -INTERFACE-                   Pseud     Read_Only                 
String                           string                     ""                            Pseud                               
SupportedServiceNames            []string                   -Sequence-                    Pseud     Read_Only                 
Text                             .text.XText                -INTERFACE-                   Pseud     Read_Only                 
TextField                        .text.XTextField           -void-                                  Read_Only,Maybevoid  22218  
TextFrame                        .text.XTextFrame           -void-                                  Read_Only,Maybevoid  22221  
TextSection                      .text.XTextSection         -void-                                  Read_Only,Maybevoid  22223  
TextTable                        .text.XTextTable           -void-                                  Read_Only,Maybevoid  22219  
TextUserDefinedAttributes        .container.XNameContainer  -INTERFACE-                             Maybevoid             51  
TopBorder                        .table.BorderLine          -STRUCT-                                Maybevoid            100  
TopBorderDistance                long                       0                                       Maybevoid            100  
Types                            []type                     -Sequence-                    Pseud     Read_Only                 
UnvisitedCharStyleName           string                     Internet link                           Maybevoid             48  
VisitedCharStyleName             string                     Visited Interne...                      Maybevoid             48  
WritingMode                      short                      4                                                            114  
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Makmilan
Posts: 6
Joined: Wed Mar 16, 2022 12:26 am

Re: personalization of a text added by the command in VB.net

Post by Makmilan »

I did not find the function to center text
as well as the function to change the font size
OpenOffice 4.1.11 On Windows 8.1
FJCC
Moderator
Posts: 9248
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Personalization of text added by the command in VB.net

Post by FJCC »

The alignment of the paragraph is set through the ParaAdjust property. The documentation for that is here and the values it can take are listed in the com.sun.star.style.ParagraphAdjust Enum The value of CENTER is 3, though it is clearer to spell out the enum.
The font height is set through the CharHeight property.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
User avatar
Zizi64
Volunteer
Posts: 11353
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Personalization of text added by the command in VB.net

Post by Zizi64 »

It is better to use Styles instead of the direct (manual) formatting properties even you do it by macros. You can use predefined Paragraph styles, Character styles in your user template, or you can create, adjust and apply your own new Styles by the macro.

Andrew Pitonyak' free macro books is will help you to study the API functions. (API: Application Programming Interface).
https://www.pitonyak.org/oo.php
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Post Reply