Looking for TextPortion, TextField clarifications
Michael Stahl
mstahl at redhat.com
Tue Nov 28 16:07:59 UTC 2017
On 18.11.2017 00:49, Jens Tröger wrote:
> Some clarification:
>
>> * It seems that reference strings have somewhat different spaces:
>> “_Ref498096146 “ and “ _Ref498096146” are the same reference
>> (space after, space before) I assume?
>
> The spacing seems to be inserted by calling getPresentation(). Using the
> SourceName and CurrentPresentation properties works ok.
probably this function; it's apparently possible to get 2 strings with a
hard-coded space in the middle, in your case sSetRefName is empty:
OUString SwGetRefField::GetFieldName() const
{
const OUString aName = GetTyp()->GetName();
if ( !aName.isEmpty() || !sSetRefName.isEmpty() )
{
return aName + " " + sSetRefName;
}
return Expand();
}
>> * In MS Word, a field’s “code” can be something like { PAGEREF
>> _Ref498098146\h} (or NOTEREF, or REF). How are these reference
>> kinds represented in the OO object model?
>
> I think a TextField’s GetReference service
> <https://www.openoffice.org/api/docs/common/ref/com/sun/star/text/textfield/GetReference.html>,
> if available, contains the appropriate reference field sources
> <https://www.openoffice.org/api/docs/common/ref/com/sun/star/text/ReferenceFieldSource.html>.
yes.
> Although I don’t quite understand the difference between “bookmark” and
> “reference mark”.
they are quite different internally; bookmarks are inserted via
Insert->Bookmark, they have a name and can span multiple paragraph
breaks; reference marks are inserted via Insert->Cross-reference->Set
Reference, and it's restricted to inside one paragraph.
>> * What about the TextPortion types “TextFieldStart”, “TextFieldEnd",
>> "TextFieldStartEnd"? I’ve seen them in documents, but can’t find
>> documentation on them.
this is the "field-marks" horror, which is an attempt to preserve
Word-like fields in Writer.
>> * Calling getString() on a “TextFieldStart” returns a ^G and for
>> “TextFieldEnd” a ^H. Their IsCollapsed property is False. What’s
>> with that?
this is a bug in the horrible field-marks code - this implementation
detail should never be visible in the API.
>> * Given the list of text field services
>> <https://wiki.openoffice.org/wiki/Documentation/DevGuide/Text/Text_Fields>,
>> how can I find of which “type” a TextField
>> <http://www.openoffice.org/api/docs/common/ref/com/sun/star/text/XTextField.html> object
>> is? Should I really iterate over all services and check if an object
>> implements one (or more) of the services?
use XServiceInfo::getSupportedServiceNames() - this should return
text.TextContent, plus 2 spellings of the specific field service name
(there was some problem with those names and the "old" name is still
returned here for compatibility).
More information about the LibreOffice
mailing list