 Okay this is supposed to be the content controls in writer talk. Hello to those who don't know me, I'm Miklos, I'm from Hungary, I'm hacking on LibreOffice for a while now, and this talk will be about content controls also known as structured document tags from the OXMAS specification and how they are used to be handled in a writer and how that got improved and so on. So what's the feature? What we try to support here is form filling and when you fill in some form like you need to specify your name and your birth date and your favorite color and so on. When you type in some tags then what would it be nice that writer has all these three text formatting like you can mark parts of the text as board and custom font size and font size and whatnot and all this is not possible with writer fields because that's really just a dummy character and then we have some string stored somewhere about what the field is expanding to and wouldn't it be nice if this would be rather annotation on writer tags so that you could have the full formatting and you can have like images and code there and more of these usual things that you know from writer. And for additional trouble we started supporting this in like 2007 and for all of those documents in case there was rich formatting there then we could not import that to writer perfectly. So given that it can have character formatting inside that means that we prayed that into multiple text portions in writer and so on like fields which are always some static tags with no custom formatting this can be multiple portions although at least for this inline content controls it's always inside a single program so if you would like to model that with bookmarks that would not be perfect either because bookmarks can be starting at random positions and ending at other random position. A bookmark may start inside the table and finish outside the table or at least in multiple paragraphs and that's you know. An additional trouble is that content controls support nesting similar to the meta text attributes we already had in writer so if we model this with fields which will be another candidate then we have the trouble that you can't nest fields inside each other in writer because fields are modeled with a dummy character and you can't really hide a dummy character inside the dummy character. So it seems what is perhaps the closest is like this meta like text attributes and that can be used to enforce that the content control stays inside a single program it supports full writer formatting and it supports nesting. So and then there are multiple types of of these content controls when we don't specify the type explicitly then this it means this rich text so that's what you can see at the bottom like the content control may break to multiple layout lines and even inside one layout line it might have multiple portions and there is this shading to signal that you are interacting with the content control and there is also a border around the bounding box of the multiple portions. Note that you are done with the rich text it's more interesting in case we cannot like more specific control to the different types so you can have a checkbox. Again this is like writer text this is not a control shape that you need to manually position and pray that the text around is not getting a real layout and then it will not look like the way you want. And also you don't need to like manually search for these characters like what is the checkbox and what is the unchecked checkbox and so on because when you insert this in writer then it will set it for you and if you want something else like let's say a cross mark or a check mark then you can customize them but you get something same by the form. This was a trouble with with the field mark based approach which also had checkboxes but you we have no UI to insert this so it's some functionality which is kind of there it's nice it's not in the UI users don't find it so you don't get bug reports but it's it's not really useful because you can't really create or modify this. And this is also working I should not touch this button I will turn it this way at perhaps at house. At least you can watch my fingers. So this also works nicely with accessibility you can navigate with the cursor to the control and press space to toggle the checkbox somewhat similar is the drop down one this one it will be a little bit uncomfortable to stay in this but I can still move. Now this will be a little bit more like a lecture which is not nice but at least you can hear me that's the point. So to drop down content controls this has a number of additional complexities so what you can see on the screen is if you navigate with your cursor inside that drop down content control then we also draw an additional drop down button at least something that looks like a button. And you can click on that and you get a list of you get these list items and then you can choose let's say your favorite color. One constraint there is that for drop down there is no free form user input so it's enforced that what goes into that content control is one of these list items and also we have we have a display name and the value for each of these items so this can be nice in case you have some human readable name and also you have a programmatic name for that and later for example with data buy things you can read the programmatic name and you don't have to worry if got per the display name was translated or something then you don't have to adjust your parsing script. And one additional complexity here is that for checkbox you can kind of survive by initially just hard coding your unique code values for was the toggled and untoggled in unique code character for the checkbox but for a drop down you really need to provide some UI to create, show, modify and delete those list items so an additional content control properties dialog is now provided which initially just had one single checkbox to track if this content control is currently a placeholder or not because you want to provide if you are in EVR in case it's a placeholder and you click into that then we pre-select the text so it's easy to type it over but if you already feel there's something valuable and doing the same would be a bit inconvenient and then this dialog gets extended depending on the type of the content control. So for drop downs you get this additional grid where you can specify the items and do the usual operations on them you can also order all these items. The next one is picture content control. So imagine that you are preparing some CV template and there is a position where you would like to have some picture for the applicant and you want to do pre-formatting of this image so you decide where it will be inserted what will be the size perhaps specify some good looking border there and so on. You can do this with the placeholder and then you mark it as a placeholder picture and when you click on that or you go there and press space in the keyboard case then the normal insert image picture is showing up and you can replace the placeholder with an actual image retaining the original format. So again the focus is on somebody with a good taste and can do all the tricky formatting to make it nice looking and for the end user they just need to insert the image and not bother with how it looks good. Next one is date content control that's somewhat similar to the drop down because again we show some additional VCO widgets when you navigate into the content control and you get this date picker. It has some last visible features like you can specify the language that's used for formatting like you get the timestamp from the date picker and you need to present that somehow we need to turn it into some string and then you format the date we can have a date format and also we can specify a language. So in general LibreOffice has a pretty good knowledge about how to do these things it's more like hooking up this date content control to do the usual date formatting. Then you have the plain text one like this is odd like we did this much work to have rich text inside the content control and of course now you want the opposite like let's have one type which is which locks it all down and make sure that it's plain text. This only makes sense in case your document is already like full of content controls for all the inputs and then it would be odd to have something completely different just like an input field just for one type. So in this case what you can do is like if imagine that what's visible here is it would be some normal non-boil text you make a selection and you made just that single board and then due to this constraint the entire content control will be marked as one. So what else we have combo box this is I think this is the most recent type this is pretty similar to drop down what this one is allowing free form user input. So far about like what you can see about content controls as a user perhaps like this is supposed to be the development tracks perhaps you are also interested in like how this is implemented so I will say a few words about that as well. So when it comes to the document model it's very similar to these meta text attributes which are also like a UI but otherwise the idea would be that you can mark a span inside the program and you can put some attributes or like semantic notation and whatnot on that. And the idea is that there is a content control class which is actually storing all these properties like the type and what are the list items of a drop box drop down and what is the language of the date formatting and so on. And once you have the core content control you need to have some kind of pull item subclass because that's how we work like whenever we insert formatting to write our text we work with pull items like we have a pull item for a ball text or underlying and so on so we have a pull item subclass that is format content control to be able to insert content control around some existing text. And then you need to somehow track when this content control is starting and ending and if we are expanding that at the end of the program and stuff like that so you need a text attribute subclass for that so text content control is doing that. And initially I only added a dummy character at the start so that it was a property of this text content control when it ends. This means that when you travel with your cursor then you can explicitly decide when you enter the content control. So if you add the very start then you can decide if you are typing right before the content control or at the start of the content control but inside because it's a different character position. Initially I did not have a dummy character at the end but that turned out to be annoying. If you have some content control at the end of the program then whatever you do somebody will be unhappy. Either you go to the end and you start typing and you wanted to add some content like outside and you are unhappy because you are typing inside or the other way around like you wanted to add something at the end and you can't really type at the very end of the content control inside so this is also by having a dummy character at the end as well. Thanks a lot. I don't know it's uncomfortable to sit down and not having the ability to walk. One additional benefit is that we have these problems for example with bookmarks that the bookmarks are just referring to document model position so in case you have two bookmarks starting at the same position then it's not really clear what's the ordering. In case we have a dummy character at the start and also at the end then you just avoid this problem because there is a different document model position if you let's say anchor some image right before the content control or inside but at its start. Then for the Uno API that's needed because the whole ODT import and export is mostly working with that so it's necessary to expose that somehow with Uno API. We have a content control class wrapping the core implementation also it has a text class which is giving you a virtual text object which is just the piece inside the program which is the content control. So let's say you have like three words in a program and the middle word is the content control that you get a virtual text object which looks like containing just that word even in practice that's one full paragraph and it has other content. Then for the layout it always works by creating this layout portions so you know there is a content control portion and that's similar to the text normal text portion and that's how the layout knows how to do this shading and border around the content control and so on. The border is quite similar to input fields so that can be as they are overlay and similar to selections or or commands on text ranges. For the pop-ups you need a control subclass similar to the page break editing widget because that knows how to travel with the document when you scroll up and down and we have two of these. We have a drop-down one for drop-downs and also for combo boxes and we have another one for the date people. Then perhaps you want to save this and load it back. This is as mentioned this whole content control concept was introduced in the works amount times so you can ignore doc and RTF and other legacy formats just make sure that you fall back to plain text but otherwise you don't need to bother with the formatting. DocX has this SDT marker for this which is like our document model was intentionally created in a way that it's more or less one-to-one mapping from that marker to this. Still there are complexities at loading and saving when it comes to data-widening and that was already there because like a year ago was he was working on that and imagine that the next talk we are going to specifics regarding this and it's nice that the old filter which could be left unchanged so what he was doing at filter level is still useful today because just the core writer implementation got swapped but the API is still the same. Then for ODDT I had to introduce some new skin bits so that you can describe all these content control types and the properties and whatnot and in the PDF case that's most recent thing we export these as fillable forms which is nice because in most cases for all these content controls it's something that's a single line and it's something that you can model with the rectangle and then it fits nicely to the PDF form filling concept and the word is just exporting this as plain text so we can do better. Then we have some UI for this so I already showed you how the content control properties dialogs look like in the drop-down case so this is what you can you get in the checkbox case you can define like what are the two unique code characters that you get when you interact with the checkbox content control. So we have menu items and in the online case we have the new bar buttons to insert this for the modification we have a dialog and if you want to modify the actual content then you can just type it as normal writer text there is no explicit UI for this and similarly deletion by just selecting the entire content control and you can delete it as similar to normal writer text. So this all looks good how do we test this? I was worried that if I leave testing to the very end then there is no time for the last few items of the planned work so I rather did this long list of tasks as working through the various features so there are cursor tasks, document model tasks, layout tasks, loading and saving tasks, PDF export tasks, UI tasks and so on. So hopefully it's not the trivia to break this feature without breaking some tasks at the same time. We also have some ODF proposal so that ideally if I bring enough cakes to Regina then the next ODF version perhaps will contain something for this content control. We have some documentation for the UNAPI and also two help pages for these two dialogues for the content control properties and there is one inner dialogue for the list items. So it's mostly it thanks to mostly NGI for funding this feature. It was possible to do this because they were allocating resources to do this and that's mostly it. So content control is like just one more way to create reliable forms in writer. If for users coming from the world side this should be much more familiar because that's one of the features that they know from that word and no ODF can support this. We can export to PDF and you have this number of types of content controls enforcing different behavior based on what type you specify that in their time. So I think that's it. Thanks. Any questions? Regina? Last time I tested the Combo Box didn't work. Is it in the mean time in the daily and second question may I assign back reports directly to you. I'm just not sorry for the sake of the stream. So Combo Box is a quite recent addition. I don't remember exactly but I would claim it was done in the like two or three weeks ago something like this. It's a combo box and the PDF export is very recent. So that was not working like if you tested it like two months ago. What was the other question? Sorry. May I assign back reports directly to you? Free free to CC me and I will see how I can find time to look at that. That's always the way I'm aware of things and and directly assigning is considered not as friendly so please don't do that but CC is fine. I have also two questions. You said that it exports to PDF as a phone and as far as I remember the text box in PDF has fixed size and do you reflow the text? Do you recalculate the inside the PDF how it's done or is it going to leave some space between words? Yeah so the PDF model is working with fixed sizes like that's PDF that's why we like it because it's very hard to break it because it's low-level. So in case you design your document so that it looks good at PDF export time then you need to fill the content control with some placeholder so that it has enough text. So that's something you need to watch out for. The second is can I make a suggestion the checkbox dialogue. Can we write instead of checkbox and colon checkbox character and then below just check it and uncheck it. You mean the checkbox frame or the one after? The label checkbox which is bold we put checkbox character and just below check it. Yep I will show you the UI file and you can do it yourself once you know where is the UI file because you are just tweaking the labels and that's fine like if this dialogue looks like made by a developer and it is made by a developer so such improvements are always welcome. I guess that's all so thanks again.