Issue 127050 - I use API to generate a .ods file with chart, but the "LineDash" propert setting doesn't work
Summary: I use API to generate a .ods file with chart, but the "LineDash" propert sett...
Status: CONFIRMED
Alias: None
Product: Calc
Classification: Application
Component: programming (show other issues)
Version: 4.1.2
Hardware: PC Linux, all
: P5 (lowest) Normal (vote)
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-07-20 07:11 UTC by kevinzhang
Modified: 2016-07-28 08:33 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description kevinzhang 2016-07-20 07:11:50 UTC
I am a Java application developer, and use OpenOffice API (some jar
package, like juh.jar  jurt.jar ridl.jar unoil.jar unoload.jar) to generate
a .ods file with chart in it. And I want change the dash style of each line
in the chart, so I use API function setPropertyValue("LineDash", myDash) to
set the "LineDash" property. But it doesn't work, the dash style in the
chart keep unchange after my setting.

my code is as following:

        aseriespro = xDiagram.getDataRowProperties(kk);
        aseriespro.setPropertyValue("LineStyle", LineStyle.DASH);
        LineDash  aDash = new LineDash();
        aDash.Style = DashStyle.ROUND;
        aDash.Dots = 2;
        aDash.DotLen = 100;
        aDash.Dashes = 1;
        aDash.DashLen =200;
        aDash.Distance =100;	
        aseriespro.setPropertyValue("LineDash", aDash);

And I have checked that:
1>  the data of aDash have been set successfully, because I use API
function getPropertyValue("LineDash") to check it
2>  The other properties can be set successfully, and works well, like
"LineColor" "LineWidth".

Seems only the "LineDash" doesn't work.   Thanks for your help in advance. 
Look forward to your reply.
Comment 1 hanya 2016-07-20 08:01:22 UTC
It looks LineDash property is not working. Try LineDashName property to set the line dash style, leave LineDash property void.
Comment 2 kevinzhang 2016-07-20 08:39:11 UTC
hi Hanya,

    Many thanks for your quickly reply, and I have a try with your suggestion, using LineDashName, it works well. Thanks a lot!

    Actually, I have an other issue when I use API function to change the line property in chart. The issue is it failed randomly when I set the properties, like I set the "LineColor" "LineWidth" "SymbolStyle" etc. 

     that is very weird, because the properties setting failed randomly. And I figure out a workaround to fixed this issue, but I think that is not a good idea.

     My workaround code is as following: (I keep setting until the property be set successfully ): 

        for (;;) {
        	Integer color = 1973940;
        	aseriespro = xDiagram.getDataRowProperties(1);

        	aseriespro.setPropertyValue("LineColor", (color));
        	KEY = color.equals((Integer)aseriespro.getPropertyValue("LineColor"));
        	if (KEY) {
        		break;   	
        	}
        }
        aseriespro.setPropertyValue("LineStyle", LineStyle.DASH);
        .....
        .....

Would you please help to have a look? why I met that issue? and How can I avoid this issue?

( If the funciton getDataRowProperties() is wrong usage)

Many Thanks,

Yaokai
Comment 3 hanya 2016-07-20 12:01:08 UTC
I could observe the problem that the LineColor is not changed sometimes in the specific situation. 
When I execute Basic macro did not change the line color after return back from the edit mode of the chart in the sheet of the calc document. But not every time.
I have no idea how to avoid such problem.

Here is the code which I tried.
Sub Snippet2
  oSheets = ThisComponent.getSheets()
  oObj1 = oSheets.getByIndex(0)
  oCharts = oObj1.getCharts()
  oObj2 = oCharts.getByIndex(0)
  
  oEmbeddedObject = oObj2.getEmbeddedObject()
  oDiagram = oEmbeddedObject.getDiagram()
  
  oDataRowProperties = oDiagram.getDataRowProperties(0)
  'msgbox oDataRowProperties.LineColor
  if oDataRowProperties.LineColor <> 1973940 then
    oDataRowProperties.LineColor = 1973940
  else
    oDataRowProperties.LineColor = 15000000
  end if
end sub
Comment 4 kevinzhang 2016-07-21 07:49:14 UTC
Hi Hanya,

     Many thanks for your handly explain. Since we all met this random issue, I want to know if the SDK develop group have a plan to fix this defect?

     Now I have a walkaround solution, which is showed in my last comment. For now, this method can help implement my expected feature.

Thanks 

KevinZhang(Yaokai)
Comment 5 orcmid 2016-07-22 19:18:41 UTC
(In reply to kevinzhang from comment #4)
> Hi Hanya,
I want to know if the SDK develop group have a plan to fix this
> defect?

There is no SDK development group, as such, any longer.

It is likely that there will be no fix.  Thanks for your workaround.
Comment 6 kevinzhang 2016-07-28 08:33:51 UTC
Hi Hanya,

      Sorry to bother you again.

      I met a new issue: I use the method below to creat a chart, aAddresses have 4 colums, so I got 3 line in chart, the leftmost colum is the X axis. And I want change the P-axis name, if there is another method to help realize it.

aChartCollection.addNewByName("chart0", aRect, aAddresses, true, false);

And the Forth arg is help to  "if set to true, the topmost row of the source data will be used to set labels for the category axis or the legend"

Thanks,

Yaokai