incubator-odf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daisy Guo <daisy.yc...@gmail.com>
Subject Re: Visibility of Simple API Frame class initialization methods
Date Tue, 08 Nov 2011 02:03:51 GMT
Thank you for your explanation, Devin.

2011/11/7 Devin Han <devinhan@apache.org>:
> 2011/11/5 Oliver Rau <opensource@neomm.net>
>
>> Hi everybody,
>>
>> while continuing the development on my application I needed a way to
>> insert in image into an Document at any paragraph.
>>
>> According to the way how OOo does it, this is accomplished by adding a
>> draw:frame into the paragraph. That frame will then contain the
>> draw:image.
>>
>> Based on that assumption I stumbled upon the setImage method of the
>> Simple APIs Frame class (org.odftoolkit.simple.draw.Frame) which seems
>> to do exactly that.
>> The problem I'm facing now is that I'm not able to instantiate that
>> class due to it's visibility modifiers all being set to protected. The
>> only extending class is TextBox, which in my case doesn't seem to be
>> the right choice.
>>
>> Is there any reason why to keep the Frame class with an protected
>> modifier for the constructor and the getInstanceof / newFrame methods
>> rather than making them public?
>>
>
> For OpenOffice and Symphony, if there is nothing content in a Frame,
> e.g.image, text box, the Frame can't be seen by user.
> So, construct a single Frame object doesn't make sense. Simple ODF is a
> high level API, its end user no need to care it. That's why we set Frame
> class as protected.
>
In ODF specification, frame is described as below:
"A frame is a container for enhanced content like text boxes, images
or objects."
"A frame may contain multiple content elements, but shall contain at
least one content element. "

so that a single frame object is meaningless in ODF. That's why we
make the constructor of Frame as protected.
If you want to create an image or text box, you can use image or text
box constructor.

>
>> BTW: does the way I described above to add an image make sense or is
>> there a better way?
>>
>>
> Simple ODF can add image to text document, presentation and spreadsheet.
> For your application, please reference the following code:
>
>            // new image in text document
>            TextDocument doc = TextDocument.newTextDocument();
>            Paragraph para = doc.addParagraph("");
>            Image image = Image.newImage(para, "image_list_item.png");
>            image.setName("this image");
>            image.setHyperlink(new URI("http://odftoolkit.org"));
>            doc.save("imagetest.odt");
>
>            // new image in presentation
>            PresentationDocument pDoc =
> PresentationDocument.newPresentationDocument();
>            Slide slide = pDoc.newSlide(0, "test",
> SlideLayout.TITLE_OUTLINE);
>            Textbox box =
> slide.getTextboxByUsage(PresentationDocument.PresentationClass.TITLE).get(0);
>            box.setImage("image_list_item.png");
>            pDoc.save("imagep.odp");
>
>            // new image in a table
>            TextDocument sDoc = TextDocument.newTextDocument();
>            Table table1 = sDoc.addTable(2, 2);
>            Cell cell1 = table1.getCellByPosition(0, 0);
>            Image image3 = cell1.setImage("image_list_item.png");
>            image3.setHorizontalPosition(FrameHorizontalPosition.LEFT);
>            image3.setHyperlink(new URI("http://odftoolkit.org"));
>            sDoc.save("imges.odt");
>
>            SpreadsheetDocument sheet =
> SpreadsheetDocument.newSpreadsheetDocument();
>            Table table2 = sheet.getTableList().get(0);
>            Cell cell2 = table2.getCellByPosition(1, 1);
>            Image image4 = cell2.setImage("image_list_item.png");
>            sheet.save("imgesheet.ods");
>            Image aImage4 = cell2.getImage();
>
>>
>> Regards
>>
>> Oliver
>>
>
>
>
> --
> -Devin
>

Mime
View raw message