OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Change Font type and color for Text field that supports

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
lord.breetai
General User
General User


Joined: 22 Feb 2007
Posts: 8
Location: cbba - bolivia

PostPosted: Fri Mar 30, 2007 1:46 pm    Post subject: Change Font type and color for Text field that supports Reply with quote

Hello
I trying format text field (change font type, color, apply bold italic, etc) element in writer document using starBasic macro
my text fields supports com.sun.star.text.TextField.Database

I have looked for in the forum and I do not have idea of like doing it

how write macro
it is possible to be done?

pleace help me
thanks
_________________
Lord Breetai
----------------
Back to top
View user's profile Send private message
pitonyak
Administrator
Administrator


Joined: 09 Mar 2004
Posts: 3618
Location: Columbus, Ohio, USA

PostPosted: Sat Mar 31, 2007 1:25 am    Post subject: Reply with quote

Are you able to make the changes using the GUI?
_________________
--
Andrew Pitonyak
http://www.pitonyak.org/oo.php
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
lord.breetai
General User
General User


Joined: 22 Feb 2007
Posts: 8
Location: cbba - bolivia

PostPosted: Sun Apr 01, 2007 8:29 am    Post subject: Reply with quote

pitonyak wrote:
Are you able to make the changes using the GUI?

yes, but I need change all Text fields on the writer document, when user pressing some button in my custom toolbar, because need iterate over all text fields "com.sun.star.text.TextField.Database " and change font style and font type.

for this reason I must use a macro, which looks for all text fields of type "com.sun.star.text.TextField.Database " and once found, to change to them to the font type and font color


pleace help me
thanks
_________________
Lord Breetai
----------------
Back to top
View user's profile Send private message
pitonyak
Administrator
Administrator


Joined: 09 Mar 2004
Posts: 3618
Location: Columbus, Ohio, USA

PostPosted: Sun Apr 01, 2007 3:42 pm    Post subject: Reply with quote

Quote:
yes, but I need change all Text fields on the writer document, when user pressing some button in my custom toolbar, because need iterate over all text fields "com.sun.star.text.TextField.Database " and change font style and font type.

I think that you do not understand why I asked. If you said "no, you can not do it with the GUI", then I would have then asked how you knew that it could be done with a macro. The fact that it can be done from the GUI, means that you can likely do it with a macro.

I would not have spent any time worrying about this if you said that it could not be done in the GUI. I might spend time on it since it can be done using the GUI.

You said that this is a database text field. I have never manipulated a database text field on purpose.

I do NOT have a document with this type of field, so I can not test this. I did open a database form, and then I found the following properties with fields of type

com.sun.star.form.component.DatabaseTextField

Code:

INTEGER/void  Align = 0
LONG/void  BackgroundColor = 14540253
INTEGER  Border = 1
LONG/void  BorderColor = Empty
OBJECT  BoundField = [Can not convert Object to a string]
BOOL  CharAutoKerning = False
LONG  CharColor = -1
BOOL  CharContoured = False
BOOL  CharCrossedOut = False
INTEGER  CharEmphasis = 0
INTEGER  CharEscapement = 0
INTEGER  CharEscapementHeight = 100
INTEGER  CharFontCharSet = 0
INTEGER  CharFontCharSetAsian = 76
INTEGER  CharFontCharSetComplex = 76
INTEGER  CharFontFamily = 3
INTEGER  CharFontFamilyAsian = 6
INTEGER  CharFontFamilyComplex = 6
STRING  CharFontName = Times New Roman
STRING  CharFontNameAsian = Tahoma
STRING  CharFontNameComplex = Tahoma
INTEGER  CharFontPitch = 2
INTEGER  CharFontPitchAsian = 2
INTEGER  CharFontPitchComplex = 2
STRING  CharFontStyleName =
STRING  CharFontStyleNameAsian =
STRING  CharFontStyleNameComplex =
SINGLE  CharHeight = 12
SINGLE  CharHeightAsian = 12
SINGLE  CharHeightComplex = 12
INTEGER  CharKerning = 0
OBJECT  CharLocale = [Can not convert Object to a string]
OBJECT  CharLocaleAsian = [Can not convert Object to a string]
OBJECT  CharLocaleComplex = [Can not convert Object to a string]
LONG  CharPosture = 0
LONG  CharPostureAsian = 0
LONG  CharPostureComplex = 0
INTEGER  CharRelief = 0
INTEGER  CharScaleWidth = 100
BOOL  CharShadowed = False
INTEGER  CharStrikeout = 0
INTEGER  CharUnderline = 0
LONG  CharUnderlineColor = -1
BOOL  CharUnderlineHasColor = False
SINGLE  CharWeight = 100
SINGLE  CharWeightAsian = 100
SINGLE  CharWeightComplex = 100
BOOL  CharWordMode = False
INTEGER  ClassId = 9
BOOL  ConvertEmptyToNull = True
EMPTY  CurrentValue
STRING  DataField = MAKE
STRING  DataFieldProperty = Text
STRING  Dbg_Methods
STRING  Dbg_Properties
STRING  Dbg_SupportedInterfaces
STRING  DefaultControl = com.sun.star.form.control.TextField
STRING  DefaultText =
OBJECT  Delegator
INTEGER  EchoChar = 0
OBJECT  ElementType
BOOL  Enabled = True
OBJECT  End
SINGLE  FontCharWidth = Empty
INTEGER  FontCharset = 0
OBJECT  FontDescriptor = [Can not convert Object to a string]
INTEGER  FontEmphasisMark = 0
INTEGER  FontFamily = 0
SINGLE  FontHeight = 0
BOOL  FontKerning = Empty
STRING  FontName =
SINGLE  FontOrientation = Empty
INTEGER  FontPitch = Empty
INTEGER  FontRelief = 0
INTEGER  FontSlant = 0
INTEGER  FontStrikeout = 0
STRING  FontStyleName =
INTEGER  FontType = Empty
INTEGER  FontUnderline = 0
SINGLE  FontWeight = 0
INTEGER  FontWidth = Empty
BOOL  FontWordLineMode = False
BOOL  HScroll = False
BOOL  HardLineBreaks = False
STRING  HelpText =
STRING  HelpURL =
BOOL  HideInactiveSelection = True
ARRAY  ImplementationId
STRING  ImplementationName
OBJECT/void  LabelControl = [Can not convert Object to a string]
INTEGER  LineEndFormat = 1
INTEGER  MaxTextLen = 0
BOOL  MultiLine = False
STRING  Name = txtMAKE
BOOL  NativeWidgetLook = False
INTEGER  ParaAdjust = 0
LONG  ParaBottomMargin = 0
LONG  ParaFirstLineIndent = 0
BOOL  ParaIsCharacterDistance = True
BOOL  ParaIsForbiddenRules = True
BOOL  ParaIsHangingPunctuation = False
BOOL  ParaIsHyphenation = False
INTEGER  ParaLastLineAdjust = 0
LONG  ParaLeftMargin = 0
OBJECT  ParaLineSpacing = [Can not convert Object to a string]
LONG  ParaRightMargin = 0
ARRAY  ParaTabStops = [Can not convert Object() to a string]
LONG  ParaTopMargin = 0
OBJECT  ParaUserDefinedAttributes = [Can not convert Object to a string]
OBJECT  Parent
INTEGER  PersistenceMaxTextLength = 0
BOOL  Printable = True
OBJECT  PropertySetInfo
STRING  PropertyToDefault
BOOL  ReadOnly = False
OBJECT  ReferenceDevice = [Can not convert Object to a string]
BOOL  RichText = False
STRING  ServiceName
OBJECT  Start
STRING  String
ARRAY  SupportedServiceNames
INTEGER  TabIndex = 0
BOOL/void  Tabstop = Empty
STRING  Tag =
STRING  Text =
LONG/void  TextColor = 0
LONG/void  TextLineColor = Empty
OBJECT  TextUserDefinedAttributes = [Can not convert Object to a string]
ARRAY  Types
BOOL  UseFilterValueProposal = False
BOOL  VScroll = False
OBJECT  Validator
OBJECT  ValueBinding
INTEGER  WritingMode = 0


Code:
REM oObj can be a generic draw page, a form components object, a
REM form, or a Write document. The lead name usually starts as "".
Function getControlNames(oObj, ByVal sLeadName$) As String
  Dim sForm$    : sForm    = "com.sun.star.form.component.Form"
  Dim sForms$   : sForms   = "com.sun.star.form.FormComponents"
  Dim sControl$ : sControl = "com.sun.star.form.FormControlModel"
  Dim s$
  Dim i%
  Dim x

  REM Extract the forms from a generic draw page.
  If oObj.supportsService("com.sun.star.drawing.GenericDrawPage") Then
    getControlNames() = getControlNames(oObj.getForms(), sLeadName)
    Exit Function
  End If

  REM If the object is an office document, assume that it is a Write
  REM document. If this is a Calc document, then the object has more
  REM than one draw page. I am too lazy to worry about this now.
  If oObj.supportsService("com.sun.star.document.OfficeDocument") Then
    Dim oForms : oForms = oObj.getDrawPage().getForms()
    s = getControlNames(oForms, sLeadName)
    getControlNames() = s
    Exit Function
  End If

  REM Add the current form name to the lead name if, and only if,
  REM the argument is a form.
  If oObj.supportsService(sForm) Then
    sLeadName = sLeadName & oObj.getName()
  ElseIf NOT oObj.supportsService(sForms) Then
    getControlNames() = ""
    Exit Function
  End If

  REM Enumerate forms and controls.
  For i = 0 To oObj.getCount()-1
    x = oObj.getByIndex(i)
    If x.supportsService(sControl) Then
      if (x.supportsService("com.sun.star.form.component.DatabaseTextField")) Then
        s = s & sLeadName & " : " & x.getName() & " : Database " & CHR$(10)
      Else
        s = s & sLeadName & " : " & x.getName() & CHR$(10)
      End If
      'if (x.getName() = "txtMAKE") Then
      '  Inspect(x)
      'End If
    ElseIf x.supportsService(sForms) Then
      If sLeadName = "" Then
        s = s & getControlNames(x, sLeadName)
      Else
        s = s & getControlNames(x, sLeadName & ".")
      End If
    End If
  Next
  getControlNames() = s
End Function


Your fields, if you konw how to find them (can you simply enumerate the fields? My guess is yes) probably support similar properties.
_________________
--
Andrew Pitonyak
http://www.pitonyak.org/oo.php
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
pitonyak
Administrator
Administrator


Joined: 09 Mar 2004
Posts: 3618
Location: Columbus, Ohio, USA

PostPosted: Sun Apr 01, 2007 3:43 pm    Post subject: Reply with quote

Side note, this is how I call the macro:

Code:
MsgBox getControlNames(ThisComponent, "")

_________________
--
Andrew Pitonyak
http://www.pitonyak.org/oo.php
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group