Files
loongoffice/offapi/com/sun/star/text/ReferenceFieldSource.idl
Skyler Grey 32c588dd11 tdf#86790: Add support for a word-style styleref
STYLEREF is a field type in Word which changes its content based on
nearby paragraphs. For example, upon creating a styleref referencing
"Heading 1" you will see the text of the nearest "Heading 1"-styled
paragraph that is above the field.

This patch implements STYLEREF in Writer as a cross-reference. By using
"insert>cross-reference>styles" you'll be presented with a list of
styles. Selecting one and clicking "insert" will create a field which
has text from the "most relevant" instance of the style. To find the
most relevant instance we first search up for paragraphs with the style,
and if there are any we take the closest. If there weren't any, we
search down for paragraphs with the style.

This patch also updates our use of STYLEREF for chapters exported to
docx by using it for all chapters not only those in headers and footers.
This allows us to approximate more chapter field functionality even when
moving between Writer and Word.

Finally, this patch adds some tests for STYLEREF:
- testTdf86790 tests that the "sample file with STYLEREF" document from
  tdf#86790 has the correct fields
- testStyleRefSearchUp tests that the STYLEREF searches up when there
  are bits of text both above and below it
- testStyleRefSearchDown tests that the STYLEREF searches down when
  there are bits of text below it only
- testMarginalStyleRef tests that the STYLEREF searches from the page
  top when it is placed in a footer
- testFootnotetyleRef tests that the STYLEREF searches from the
  reference mark when it is placed in a footnote

Still TODO:
- [  ] Update documentation
- [  ] Implement reverse-searching (\l) and nondelimiter
       suppression (\t)
       - Probably these 2 will be in a followup patch

Change-Id: I25dd7a6940abee5651a784b9059fe23b32547d6c
Signed-off-by: Skyler Grey <skyler.grey@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157456
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2023-10-20 08:53:34 +02:00

58 lines
1.6 KiB
Plaintext

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
module com { module sun { module star { module text {
/** These constants define the type of the source of a reference field.
*/
published constants ReferenceFieldSource
{
/** The source is a reference mark.
*/
const short REFERENCE_MARK = 0;
/** The source is a number sequence field.
*/
const short SEQUENCE_FIELD = 1;
/** The source is a bookmark.
*/
const short BOOKMARK = 2;
/** The source is a footnote.
*/
const short FOOTNOTE = 3;
/** The source is an endnote.
*/
const short ENDNOTE = 4;
/** The source is a style.
@since LibreOffice 24.2
*/
const short STYLE = 5;
};
}; }; }; };
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */