I'm discovering that what should be a simple task actually isn't. How
do I copy a PageStyle? The following attempt to create a PageStyle
"foo" with the same properties as "Standard" does NOT work:

  newStyle = doc.createInstance("com.sun.star.style.PageStyle")
  pagestyles = doc.StyleFamilies.getByName("PageStyles")
  pagestyles.insertByName("foo", newStyle)

  standard = pagestyles.getByName("Standard")
  props = standard.getPropertySetInfo().getProperties()
  ReDim propNames()
  n = 0
  for i = LBound(props) to UBound(props)
    if props(i).Name <> "GridLines" then
    if (props(i).Attributes AND
com.sun.star.beans.PropertyAttribute.READONLY) = 0 then
      u = UBound(propNames) + 1
      ReDim Preserve propNames(0 to u)
      propNames(n) = props(i).Name
      n = n + 1
    end if
    end if
  next i


  propVals = standard.getPropertyValues(propNames)
  newStyle.setPropertyValues(propNames, propVals)

BTW, if you're wondering about the "GridLines" exception:
setPropertyValues() throws an exception if that is included. Is that a
bug?

Matthias

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to