Apache OpenOffice (AOO) Bugzilla – Issue 97957
Change in he properties for the numbering style
Last modified: 2017-05-20 11:18:07 UTC
The property for numbering style changed from OO2.4 to OO3. This issue cause the function "replaceByIndex" is not working when the property value need to be changed in OO3.
Created attachment 59298 [details] This is taken from OO2.4
Created attachment 59299 [details] This is taken from OO3
Yes, the list style attributes have changed for OOo 3.0. See the spec http://specs.openoffice.org/writer/numbering/NewListLevelAttrs.odt for more detailed information. When using a document with "old" attributes (created by OOo 2.x), the "replaceByIndex" should work correctly with your macros. Could you please describe, what exactly does not work when using "replaceByIndex"?
MRU->OD: However, I think that the API should recognize, if a macro is referred to "old" or "new" list attributes.
No. The API is not recognizing the old attributes. Please see issue 97788. We have used replaceByIndex to set LeftMargin attribute. The different attribute name has caused the following error. --------error message--------------- BASIC runtime error. An exception occurred Type: com.sun.start.lang.IllegalArgumentException Message: .
The former attributes should be still supported by the UNO-API. I think certain adjustment of the UNO-API is needed to make with work - I will take care for it. OD->linda-octa: For convenience it would be cool, if you could attach your extension/macro or an example to assure that your issue is fully address. Thanks in advance.
The macro: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Sub createNumberingStyle Dim oStyles as Object, OStyle as Object Dim oNumRules, mSetOfRules Dim mArgArray oStyles = thisComponent.styleFamilies.getByName("NumberingStyles") mArgArray(0) = "LeftMargin" mArgArray(1) = 600 mArgArray(2) = "NumberingType" mArgArray(3) = 6 If Not oStyles.hasByName("myBullet") Then oStyle = thisComponent.createInstance("com.sun.star.style.NumberingStyle") oStyles.insertByName("myBullet", oStyle) oNumRules = oStyle.NumberingRules For i = 0 To 3 Step 2 For j = 0 To (oNumRules.getCount - 1 ) Set mSetOfRules = oNumRules.getByIndex(i) nRuleIndex = fnFindPropertyIndex(mSetOfRules, mArgArray(i)) If nRuleIndex = -1 Then Exit Sub End If mSetOfRules(nRuleIndex).value = mArgArray(i + 1) oNumRules.replaceByIndex(j, mSetOfRules) 'this either gives the error or not setting the properties at all Next Next 'xray oNumRules.getByIndex(0) oStyle.NumberingRules = oNumRules msgbox "style created" Else oStyles.removeByName("myBullet") end If End Sub Function fnFindPropertyIndex(aArrayOfProperties, cPropName As String) As Long For i = LBound(aArrayOfProperties) To UBound(aArrayOfProperties) oProp = aArrayOfProperties(i) If oProp.Name = cPropName Then fnFindPropertyIndex() = i Exit Function End If Next End Function >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Created attachment 59596 [details] adjusted macro
OD->scarlettulip13: Thanks for the macro. Unfortunately your macro has some defects and does not show the described defect. - variable "mArgArray" is not declared as an array. This "mArgArray(i)" for whatever value of "i" equals "6" - function fnFindPropertyIndex does not return anything, when the property is not found in the array of properties. I adjusted the macro - see my attachment. This the adjustment the created list style, named "myBullet" is not changed, because the macro exits in the first i-iteration and the first j-iteration, because property "LeftMargin" is not found in the current array of properties. A look in the UNO-API reveals that properties "LeftMargin" and "FirstLineOffset" must exist in the property array. This is a defect, which needs to be fixed. When this is fixed the adjusted macro would run and change at each list level the properties "LeftMargin" and "Adjust". But, due to the introduction of the new list level attributes - see above mentioned specification, the "LeftMargin" property will not be evaluated, because the "PositionAndSpaceMode" property value equals constant com::sun::star::text::PositionAndSpaceMode::LABEL_ALIGNMENT
OD->linda-octa: Do you have a macro, which demonstrates your problem more precisely. When your (linda-octa's one and scarlettulip13's one) are better understood, we can decide, if it makes sense to automatically switch the PositionAndSpaceMode, when properties from the currently not applied PositionAndSpaceMode are set.
Reset assigne to the default "issues@openoffice.apache.org".