Hi Georg,
On Tue, Nov 3, 2015 at 8:10 AM, Georg Füchsle <[email protected]>
wrote:
> Hallo Svante,
>
> thank you for Your answer.
>
> I won't dare to change the odf Simple Api. But with Your help I now can get
> a OPDFSimple Paragraph from a ListItem and then use the ODFSimple
> formatting functions:
>
>
> public static org.odftoolkit.simple.text.Paragraph
> getParagraphFromListItem(org.odftoolkit.simple.text.list.ListItem listItem)
> {
> if (listItem != null &&
> listItem.getOdfElement().getElementsByTagName("text:p") != null &&
> listItem.getOdfElement().getElementsByTagName("text:p").getLength() > 0)
> {
> TextPElement textP = (TextPElement)
> listItem.getOdfElement().getElementsByTagName("text:p").item(0);
> Paragraph ps = Paragraph.getInstanceof((TextPElement) textP);
> return ps;
> }
> else
> {
> return null;
> }
> }
>
>
> Looks great!
> I also studied your link to the OASIS ODF working group. In this example
> you create a formatted odf-document from json-imput. Thats great. Even if i
> don't understand the concrete syntax.
>
> I understood, that you were working on a browser html-component that
> displays an enables manipulation of odf-documents. That sounds really very
> interesting. Is there an example in the web, where I can have a glance at
> it?
>
>
The open-xchange web office is part of their larger suite including mail,
calendar, messenger et alias.
Their marketing page:
https://www.open-xchange.com/en/ox-documents
As their main customer are telcos the main customer use case is editing a
mail attachment, which not involving real-time editing. Therefore the
collaboration feature is up to now with a pessimistic lock, only one at the
time can edit the document.
Kind of funny, as the operation approach was designed to deal with the
optimistic approach in the first place.
Other advantages in the end of the PDF (525kb)
<https://dl.dropboxusercontent.com/u/49473263/ACM-WorkInProgress-Interoperable-Document-Collaboration%20-%20withLicense.pdf>
.
If you want to see it work you might want to get in touch with them, there
are binaries and some installation page:
https://oxpedia.org/wiki/index.php?title=AppSuite:Open-Xchange_Installation_Guide_for_Debian_7.0
The source code for the front-end is creative common none commercial, see
http://oxpedia.org/wiki/index.php?title=SourceCodeAccess
There are two other open-source rich text HTML editor I have stumbled over
recently, but which AFAIK are not supporting office formats, but might be
worth mentioning:
http://prosemirror.net/
http://quilljs.com/
as I am currently looking deeper into them and trying to persuade them to
join the operation camp ;)
They seem related to this approach
https://github.com/ottypes/rich-text
using implicit positions, while the explicit positioning seems easier for
the user (or using applications) to deal with merges.
Enjoy your day, Georg!
Svante
Best regards,
>
> Georg
>
>
> 2015-10-30 18:00 GMT+01:00 Georg Füchsle <[email protected]>:
>
> > Hallo Svante,
> > Thanks for Your answer!
> > I had a lot of trouble today. I will try it on Monday!
> > Have a nice weekend!
> > Georg
> >
> > 2015-10-30 12:23 GMT+01:00 Svante Schubert <[email protected]>:
> >
> >> A small typo, as I have not reloaded my XML my addition was missing:
> >>
> >> <text:section text:display="true" text:name="myTest"
> >> text:style-name="ac3c190">
> >> <text:p>This is a paragraph...</text:p>
> >> <text:list text:style-name="l6a4c3d" xml:id="list73387982">
> >> <text:list-item>
> >> <text:p text:style-name="ae1b664">this is the first item</text:p>
> >> </text:list-item>
> >> <text:list-item>
> >> <text:p text:style-name="ae1b664">this is the second item</text:p>
> >> </text:list-item>
> >> <text:list-item>
> >> <text:p text:style-name="P4">this is the third item More
> >> content!<text:span
> >> text:style-name="Text"> More Span!</text:span>
> >> </text:p>
> >> </text:list-item>
> >> </text:list>
> >> </text:section>
> >>
> >> On Fri, Oct 30, 2015 at 12:22 PM, Svante Schubert <
> >> [email protected]
> >> > wrote:
> >>
> >> > Hi Georg,
> >> >
> >> > I never worked on or with the simple API, which was once donated by
> IBM
> >> to
> >> > the toolkit, but I took a quick look into your problem.
> >> > As usual I have pasted your code example into one of the existing
> tests,
> >> > in this case in the simple API list regression tests of package
> >> > org.odftoolkit.simple.text.list
> >> >
> >> > The short answer, there is no high level (simple) API for format of
> list
> >> > items aside of their numbering style. You need to add it to the simple
> >> API
> >> > or go back to the lower level ODFDOM API. To go lower you go back to
> the
> >> > XML level, you receive on the simple API list item its XML
> >> representation
> >> > via
> >> > item.getOdfElement()
> >> >
> >> > and receive its paragraph children via
> >> > NodeList nodeList =
> item.getOdfElement().getElementsByTagName("text:p");
> >> >
> >> > during creation of the typed XML DOM tree their is still the high
> level
> >> > ODFDOM paragraph class being used
> >> > org.odftoolkit.odfdom.doc.text.OdfTextParagraph
> >> > which you might want to use, but there should be other ways for
> instance
> >> > to enhance Simple API..
> >> >
> >> > What it is in general missing in the current ODF Toolkit version but
> was
> >> > added by the open-xchange fork, are high level positions of user
> objects
> >> > within the document. Allowing not only to append some styles or search
> >> for
> >> > some special content string, but point to a position to format. See an
> >> > example of an ODF document with its representation as a list of
> changes
> >> (in
> >> > JSON) in my mail to the OASIS ODF working group -
> >> >
> >>
> https://lists.oasis-open.org/archives/office-collab/201507/msg00003.html
> >> >
> >> >
> >> >
> >> > Your example in full within the test of :
> >> > org.odftoolkit.simple.text.list.ListItemTest
> >> >
> >> > @Test
> >> > public void testFormatTextContent() {
> >> > try {
> >> > TextDocument odtdoc = (TextDocument)
> >> > TextDocument.loadDocument(ResourceUtilities
> >> > .getTestResourceAsStream(SAMPLE_LIST_DOCUMENT));
> >> >
> >> > Section s1 = odtdoc.appendSection("myTest");
> >> > Paragraph p2 = s1.addParagraph("This is a paragraph...");
> >> >
> >> > List list = s1.addList();
> >> > list.setDecorator(new NumberDecorator(odtdoc));
> >> > ListItem item = list.addItem("this is the first item");
> >> > item = list.addItem("this is the second item");
> >> > item = list.addItem("this is the third item");
> >> > NodeList nodeList =
> item.getOdfElement().getElementsByTagName("text:p");
> >> > if(nodeList.getLength() > 0){
> >> > TextPElement textP = (TextPElement) nodeList.item(0);
> >> > if(textP instanceof OdfTextParagraph){
> >> > String styleName = "P4";
> >> > String content = " More content!";
> >> > String spanStyleName = "Text";
> >> > String spanContent = " More Span!";
> >> > ((OdfTextParagraph) textP).addStyledContent(styleName,
> >> > content).addStyledSpan(
> >> > spanStyleName, spanContent);
> >> > }
> >> > }
> >> >
> >> >
> >> >
> >>
> odtdoc.save(ResourceUtilities.getTestOutputFolder().concat("myExampleList.odt"));
> >> >
> >> > }
> >> >
> >> > The new XML being generated:
> >> >
> >> > <text:section text:display="true" text:name="myTest"
> >> > text:style-name="a9a60a2">
> >> > <text:p>This is a paragraph...</text:p>
> >> > <text:list text:style-name="l4bd2d4" xml:id="list65104419">
> >> > <text:list-item>
> >> > <text:p text:style-name="a7af3c1">this is the first item</text:p>
> >> > </text:list-item>
> >> > <text:list-item>
> >> > <text:p text:style-name="a7af3c1">this is the second item</text:p>
> >> > </text:list-item>
> >> > <text:list-item>
> >> > <text:p text:style-name="a7af3c1">this is the third item</text:p>
> >> > </text:list-item>
> >> > </text:list>
> >> > </text:section>
> >> >
> >> > For the XML handling of ODF, I usually like to use JEdit application
> on
> >> > desktop with the Archive extension allowing to open the content.xml
> >> within
> >> > the ODT file and to edit and save it back (strangely works not for MS
> >> > Office created ODT) and the XML JEdit extension to indent the XML with
> >> some
> >> > key shortcut..
> >> >
> >> > Hope it helps,
> >> > Svante
> >> >
> >> >
> >> > On Thu, Oct 29, 2015 at 11:07 AM, Georg Füchsle <
> >> [email protected]>
> >> > wrote:
> >> >
> >> >> Hallo,
> >> >>
> >> >> I create list Items by:
> >> >>
> >> >> Paragraph p2 = s1.addParagraph("This is a paragraph...");
> >> >>
> >> >> List list = s1.addList();
> >> >> list.setDecorator(new NumberDecorator(target));
> >> >> ListItem item = list.addItem("this is the first item");
> >> >> item = list.addItem("this is the second item");
> >> >> item = list.addItem("this is the third item");
> >> >>
> >> >> How can I format the content of a list item? I tried to retieve a
> >> >> TextSelection of the list item but i did not succeed.
> >> >>
> >> >> Thanks in advance.
> >> >>
> >> >> Gio
> >> >>
> >> >
> >> >
> >>
> >
> >
>