Issue 97957 - Change in he properties for the numbering style
Summary: Change in he properties for the numbering style
Alias: None
Product: Writer
Classification: Application
Component: code (show other issues)
Version: OOo 3.0
Hardware: Unknown All
: P3 Trivial (vote)
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
Depends on:
Reported: 2009-01-12 01:47 UTC by linda_octa
Modified: 2017-05-20 11:18 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---

This is taken from OO2.4 (16.90 KB, image/png)
2009-01-12 01:48 UTC, linda_octa
no flags Details
This is taken from OO3 (20.58 KB, image/png)
2009-01-12 01:49 UTC, linda_octa
no flags Details
adjusted macro (1.45 KB, text/plain)
2009-01-22 14:39 UTC, Oliver-Rainer Wittmann
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description linda_octa 2009-01-12 01:47:15 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.
Comment 1 linda_octa 2009-01-12 01:48:58 UTC
Created attachment 59298 [details]
This is taken from OO2.4
Comment 2 linda_octa 2009-01-12 01:49:19 UTC
Created attachment 59299 [details]
This is taken from OO3
Comment 3 michael.ruess 2009-01-12 14:49:30 UTC
Yes, the list style attributes have changed for OOo 3.0. See the spec 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"?
Comment 4 michael.ruess 2009-01-15 16:00:47 UTC
MRU->OD: However, I think that the API should recognize, if a macro is referred
to "old" or "new" list attributes.
Comment 5 scarlettulip13 2009-01-16 04:10:39 UTC
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: .

Comment 6 Oliver-Rainer Wittmann 2009-01-16 07:35:32 UTC
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.
Comment 7 scarlettulip13 2009-01-19 00:38:31 UTC
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("")
		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
		'xray oNumRules.getByIndex(0)
		oStyle.NumberingRules = oNumRules
		msgbox "style created"
	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
End Function

Comment 8 Oliver-Rainer Wittmann 2009-01-22 14:39:40 UTC
Created attachment 59596 [details]
adjusted macro
Comment 9 Oliver-Rainer Wittmann 2009-01-22 15:12:18 UTC
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
Comment 10 Oliver-Rainer Wittmann 2009-01-22 15:18:24 UTC
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.
Comment 11 Marcus 2017-05-20 11:18:07 UTC
Reset assigne to the default "".