offapi/com/sun/star/text/IllustrationsIndex.idl | 7 +++ offapi/com/sun/star/text/ObjectIndex.idl | 26 ++++++------- offapi/com/sun/star/text/TableIndex.idl | 8 +++- offapi/type_reference/offapi.idl | 1 sw/inc/unomap.hxx | 1 sw/inc/unoprnms.hxx | 1 sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx | 13 ++++++ sw/source/core/unocore/unoidx.cxx | 41 ++++++++++++++++++++++ sw/source/core/unocore/unomap.cxx | 3 + sw/source/filter/ww8/ww8atr.cxx | 10 +++++ writerfilter/source/dmapper/DomainMapper_Impl.cxx | 6 +++ 11 files changed, 99 insertions(+), 18 deletions(-)
New commits: commit b706b04110d9305b319689a5577746fac3e0e4c3 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Fri Jan 20 18:27:28 2023 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Mon Jan 23 10:12:15 2023 +0000 [API CHANGE] offapi: clean up these index services IDL files CreateFromStarImage isn't implemented, having been removed in 2000. Change-Id: Ic0e90eaf760374df69f8d8779c37819d4943a063 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145911 Tested-by: Michael Stahl <michael.st...@allotropia.de> Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/offapi/com/sun/star/text/IllustrationsIndex.idl b/offapi/com/sun/star/text/IllustrationsIndex.idl index d58392ded2bc..9c0ad89c955b 100644 --- a/offapi/com/sun/star/text/IllustrationsIndex.idl +++ b/offapi/com/sun/star/text/IllustrationsIndex.idl @@ -44,7 +44,6 @@ published service IllustrationsIndex [optional, property, maybevoid] string CreateFromParagraphStyle; }; - }; }; }; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/offapi/com/sun/star/text/ObjectIndex.idl b/offapi/com/sun/star/text/ObjectIndex.idl index 3df13f2abd63..8273d1ee9ee8 100644 --- a/offapi/com/sun/star/text/ObjectIndex.idl +++ b/offapi/com/sun/star/text/ObjectIndex.idl @@ -21,28 +21,26 @@ module com { module sun { module star { module text { -/** specifies service of object indexes within a document.@see com::sun::star::text::BaseIndex +/** specifies service of object indexes within a document. + @see com::sun::star::text::BaseIndex */ published service ObjectIndex { service com::sun::star::text::BaseIndex; - /** Determines if star office math objects are included in the office. + /** Determines if LibreOffice Math objects are included in the index. */ [optional, property] boolean CreateFromStarMath;//objects - /** Determines if star office image objects are included in the office. - */ - [optional, property] boolean CreateFromStarImage;//objects - /** Determines if star office chart objects are included in the office. + /** Determines if LibreOffice Chart objects are included in the index. */ [optional, property] boolean CreateFromStarChart;//objects - /** Determines if star office calc objects are included in the office. + /** Determines if LibreOffice Calc objects are included in the index. */ [optional, property] boolean CreateFromStarCalc;//objects - /** Determines if star office draw objects are included in the office. + /** Determines if LibreOffice Draw objects are included in the index. */ [optional, property] boolean CreateFromStarDraw;//objects - /** Determines if external embedded objects are included in the office. + /** Determines if external embedded objects are included in the index. */ [optional, property] boolean CreateFromOtherEmbeddedObjects;//objects @@ -53,10 +51,6 @@ published service ObjectIndex [optional, property, maybevoid] string CreateFromParagraphStyle; }; - }; }; }; }; - - - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/offapi/com/sun/star/text/TableIndex.idl b/offapi/com/sun/star/text/TableIndex.idl index e65f86233111..24d282f215b4 100644 --- a/offapi/com/sun/star/text/TableIndex.idl +++ b/offapi/com/sun/star/text/TableIndex.idl @@ -50,8 +50,6 @@ published service TableIndex [optional, property, maybevoid] string CreateFromParagraphStyle; }; - }; }; }; }; - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/offapi/type_reference/offapi.idl b/offapi/type_reference/offapi.idl index 3a54a0ebe134..027af1657732 100644 --- a/offapi/type_reference/offapi.idl +++ b/offapi/type_reference/offapi.idl @@ -14519,7 +14519,6 @@ module com { published service ObjectIndex { service ::com::sun::star::text::BaseIndex; [property, optional] boolean CreateFromStarMath; - [property, optional] boolean CreateFromStarImage; [property, optional] boolean CreateFromStarChart; [property, optional] boolean CreateFromStarCalc; [property, optional] boolean CreateFromStarDraw; commit 5ef8d07fe04717dc4a5b8846a3b324381b2c8efd Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Fri Jan 20 15:15:32 2023 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Mon Jan 23 10:12:05 2023 +0000 tdf#153090 writerfilter,sw: DOCX/RTF import/export of TOC \c \t This is for Table of Figures/Objects/Tables. The core will happily generate entries from paragraph styles by simply setting the Template flag and adding the style name. In Word, this feature differs from ToC in that only a single paragraph style is allowed, and there is only one level to assign to so that is omitted and \t is simply the style name (presumably suffering the usual i18n disaster, see tdf#153083). So implement it with the same limitations, not reusing the CreateFromLevelParagraphStyles property on SwXDocumentIndex but instead add new property CreateFromParagraphStyle. Change-Id: Ic8ab1fa9e81bdc85cc932f6bba8724d560e0fbc1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145904 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/offapi/com/sun/star/text/IllustrationsIndex.idl b/offapi/com/sun/star/text/IllustrationsIndex.idl index 433d1503bd9b..d58392ded2bc 100644 --- a/offapi/com/sun/star/text/IllustrationsIndex.idl +++ b/offapi/com/sun/star/text/IllustrationsIndex.idl @@ -36,6 +36,12 @@ published service IllustrationsIndex /* determines the way the paragraph containing a label is included in the index. @see ChapterFormat*/ [optional, property] short LabelDisplayType;//tables, illustrations + + /** determines if paragraphs with one particular style applied are + included in the index. + @since LibreOffice 7.6 + */ + [optional, property, maybevoid] string CreateFromParagraphStyle; }; diff --git a/offapi/com/sun/star/text/ObjectIndex.idl b/offapi/com/sun/star/text/ObjectIndex.idl index 2aea50204be2..3df13f2abd63 100644 --- a/offapi/com/sun/star/text/ObjectIndex.idl +++ b/offapi/com/sun/star/text/ObjectIndex.idl @@ -45,6 +45,12 @@ published service ObjectIndex /** Determines if external embedded objects are included in the office. */ [optional, property] boolean CreateFromOtherEmbeddedObjects;//objects + + /** determines if paragraphs with one particular style applied are + included in the index. + @since LibreOffice 7.6 + */ + [optional, property, maybevoid] string CreateFromParagraphStyle; }; diff --git a/offapi/com/sun/star/text/TableIndex.idl b/offapi/com/sun/star/text/TableIndex.idl index 166748573370..e65f86233111 100644 --- a/offapi/com/sun/star/text/TableIndex.idl +++ b/offapi/com/sun/star/text/TableIndex.idl @@ -42,6 +42,12 @@ published service TableIndex ONLY_CAPTION */ [optional, property] short LabelDisplayType;//tables, illustrations + + /** determines if paragraphs with one particular style applied are + included in the index. + @since LibreOffice 7.6 + */ + [optional, property, maybevoid] string CreateFromParagraphStyle; }; diff --git a/sw/inc/unomap.hxx b/sw/inc/unomap.hxx index d3cfcb862937..689fa87063a1 100644 --- a/sw/inc/unomap.hxx +++ b/sw/inc/unomap.hxx @@ -226,6 +226,7 @@ class SfxItemPropertySet; #define WID_TOC_BOOKMARK 1061 #define WID_TOC_NEWLINE 1062 #define WID_TOC_PARAGRAPH_OUTLINE_LEVEL 1063 +#define WID_CREATE_FROM_PARAGRAPH_STYLE 1064 // Text document #define WID_DOC_CHAR_COUNT 1000 diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx index eb70f1d79d8d..dc30938eff21 100644 --- a/sw/inc/unoprnms.hxx +++ b/sw/inc/unoprnms.hxx @@ -471,6 +471,7 @@ inline constexpr OUStringLiteral UNO_NAME_CREATE_FROM_OTHER_EMBEDDED_OBJECTS inline constexpr OUStringLiteral UNO_NAME_INDEX_AUTO_MARK_FILE_U_R_L = u"IndexAutoMarkFileURL"; inline constexpr OUStringLiteral UNO_NAME_IS_COMMA_SEPARATED = u"IsCommaSeparated"; inline constexpr OUStringLiteral UNO_NAME_IS_RELATIVE_TABSTOPS = u"IsRelativeTabstops"; +inline constexpr OUStringLiteral UNO_NAME_CREATE_FROM_PARAGRAPH_STYLE = u"CreateFromParagraphStyle"; inline constexpr OUStringLiteral UNO_NAME_CREATE_FROM_LEVEL_PARAGRAPH_STYLES = u"CreateFromLevelParagraphStyles"; inline constexpr OUStringLiteral UNO_NAME_SHOW_CHANGES = u"ShowChanges"; diff --git a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx index 32c4839e0882..c0578ad31a16 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx @@ -9,6 +9,7 @@ #include <swmodeltestbase.hxx> +#include <com/sun/star/text/XDocumentIndex.hpp> #include <com/sun/star/text/XTextFieldsSupplier.hpp> #include <com/sun/star/text/XTextField.hpp> #include <com/sun/star/text/XTextTable.hpp> @@ -165,7 +166,17 @@ CPPUNIT_TEST_FIXTURE(Test, testFDO77715) loadAndReload("FDO77715.docx"); xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); - assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[3]/w:r[2]/w:instrText[1]", " TOC \\c \\h "); + // tdf#153090 check that para style is preserved + assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[3]/w:r[2]/w:instrText[1]", " TOC \\c \\h \\t \"Block Header\" "); + + uno::Reference<text::XDocumentIndexesSupplier> xIndexSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xIndexes = xIndexSupplier->getDocumentIndexes(); + uno::Reference<text::XDocumentIndex> xTOC(xIndexes->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("Block Header"), getProperty<OUString>(xTOC, "CreateFromParagraphStyle")); + // tdf#153090 check that update uses the style + xTOC->update(); + OUString const tocContent(xTOC->getAnchor()->getString()); + CPPUNIT_ASSERT(tocContent.startsWith("National Infrastructure Bank Aff/Neg Index")); } CPPUNIT_TEST_FIXTURE(Test, testTOCFlag_u) diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index dd123d618267..5e98a98a45cc 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -780,6 +780,30 @@ SwXDocumentIndex::setPropertyValue( case WID_CREATE_FROM_PARAGRAPH_STYLES: lcl_AnyToBitMask(rValue, nCreate, SwTOXElement::Template); break; + case WID_CREATE_FROM_PARAGRAPH_STYLE: + { + OUString style; + if (rValue >>= style) + { + if (style.indexOf(TOX_STYLE_DELIMITER) != -1) + { + throw lang::IllegalArgumentException(); + } + lcl_AnyToBitMask(uno::Any(true), nCreate, SwTOXElement::Template); + OUString uiStyle; + SwStyleNameMapper::FillUIName(style, uiStyle, SwGetPoolIdFromName::TxtColl); + rTOXBase.SetStyleNames(uiStyle, 0); + } + else if (!rValue.hasValue()) + { + lcl_AnyToBitMask(uno::Any(false), nCreate, SwTOXElement::Template); + } + else + { + throw lang::IllegalArgumentException(); + } + } + break; case WID_PARA_LEV1: case WID_PARA_LEV2: @@ -1089,6 +1113,23 @@ SwXDocumentIndex::getPropertyValue(const OUString& rPropertyName) case WID_CREATE_FROM_PARAGRAPH_STYLES: lcl_BitMaskToAny(aRet, nCreate, SwTOXElement::Template); break; + case WID_CREATE_FROM_PARAGRAPH_STYLE: + { + if (nCreate & SwTOXElement::Template) + { // there is only one style, at top level + OUString const& rStyle(pTOXBase->GetStyleNames(0)); + if (!rStyle.isEmpty()) + { + assert(rStyle.indexOf(TOX_STYLE_DELIMITER) == -1); + OUString ret; + SwStyleNameMapper::FillProgName(rStyle, ret, + SwGetPoolIdFromName::TxtColl); + aRet <<= ret; + } + } + } + break; + case WID_PARA_HEAD: { //Header is at position 0 diff --git a/sw/source/core/unocore/unomap.cxx b/sw/source/core/unocore/unomap.cxx index 92f0d8aea861..f6765dadd4b9 100644 --- a/sw/source/core/unocore/unomap.cxx +++ b/sw/source/core/unocore/unomap.cxx @@ -443,6 +443,7 @@ o3tl::span<const SfxItemPropertyMapEntry> SwUnoPropertyMapProvider::GetPropertyM BASE_INDEX_PROPERTIES_ { UNO_NAME_CREATE_FROM_CHAPTER, WID_CREATE_FROM_CHAPTER , cppu::UnoType<bool>::get() , PROPERTY_NONE, 0}, { UNO_NAME_CREATE_FROM_LABELS, WID_CREATE_FROM_LABELS , cppu::UnoType<bool>::get() , PROPERTY_NONE, 0}, + { UNO_NAME_CREATE_FROM_PARAGRAPH_STYLE, WID_CREATE_FROM_PARAGRAPH_STYLE, cppu::UnoType<OUString>::get(), PropertyAttribute::MAYBEVOID, 0}, { UNO_NAME_IS_PROTECTED, WID_PROTECTED , cppu::UnoType<bool>::get() , PROPERTY_NONE, 0}, { UNO_NAME_LABEL_CATEGORY, WID_LABEL_CATEGORY , cppu::UnoType<OUString>::get() , PROPERTY_NONE, 0}, { UNO_NAME_LABEL_DISPLAY_TYPE, WID_LABEL_DISPLAY_TYPE , cppu::UnoType<sal_Int16>::get() , PROPERTY_NONE, 0}, @@ -475,6 +476,7 @@ o3tl::span<const SfxItemPropertyMapEntry> SwUnoPropertyMapProvider::GetPropertyM { UNO_NAME_CREATE_FROM_STAR_CALC, WID_CREATE_FROM_STAR_CALC , cppu::UnoType<bool>::get() , PROPERTY_NONE, 0}, { UNO_NAME_CREATE_FROM_STAR_DRAW, WID_CREATE_FROM_STAR_DRAW , cppu::UnoType<bool>::get() , PROPERTY_NONE, 0}, { UNO_NAME_CREATE_FROM_OTHER_EMBEDDED_OBJECTS, WID_CREATE_FROM_OTHER_EMBEDDED_OBJECTS , cppu::UnoType<bool>::get() , PROPERTY_NONE, 0}, + { UNO_NAME_CREATE_FROM_PARAGRAPH_STYLE, WID_CREATE_FROM_PARAGRAPH_STYLE, cppu::UnoType<OUString>::get(), PropertyAttribute::MAYBEVOID, 0}, { UNO_NAME_TEXT_COLUMNS, RES_COL, cppu::UnoType<css::text::XTextColumns>::get(), PROPERTY_NONE, MID_COLUMNS}, { UNO_NAME_BACK_GRAPHIC_URL, RES_BACKGROUND, cppu::UnoType<OUString>::get(), PROPERTY_NONE ,MID_GRAPHIC_URL }, { UNO_NAME_BACK_GRAPHIC, RES_BACKGROUND, cppu::UnoType<graphic::XGraphic>::get(), PROPERTY_NONE, MID_GRAPHIC }, @@ -496,6 +498,7 @@ o3tl::span<const SfxItemPropertyMapEntry> SwUnoPropertyMapProvider::GetPropertyM BASE_INDEX_PROPERTIES_ { UNO_NAME_CREATE_FROM_CHAPTER, WID_CREATE_FROM_CHAPTER , cppu::UnoType<bool>::get() , PROPERTY_NONE, 0}, { UNO_NAME_CREATE_FROM_LABELS, WID_CREATE_FROM_LABELS , cppu::UnoType<bool>::get() , PROPERTY_NONE, 0}, + { UNO_NAME_CREATE_FROM_PARAGRAPH_STYLE, WID_CREATE_FROM_PARAGRAPH_STYLE, cppu::UnoType<OUString>::get(), PropertyAttribute::MAYBEVOID, 0}, { UNO_NAME_IS_PROTECTED, WID_PROTECTED , cppu::UnoType<bool>::get() , PROPERTY_NONE, 0}, { UNO_NAME_USE_ALPHABETICAL_SEPARATORS, WID_USE_ALPHABETICAL_SEPARATORS , cppu::UnoType<bool>::get() , PROPERTY_NONE, 0}, { UNO_NAME_LABEL_CATEGORY, WID_LABEL_CATEGORY , cppu::UnoType<OUString>::get() , PROPERTY_NONE, 0}, diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 49ffa1eb1a98..68fb57f4ce26 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -2368,6 +2368,16 @@ void AttributeOutputBase::StartTOX( const SwSection& rSect ) { sStr += "\\h "; } + if (pTOX->GetCreateType() & SwTOXElement::Template) + { + OUString const& rStyle(pTOX->GetStyleNames(0)); + assert(rStyle.indexOf(TOX_STYLE_DELIMITER) == -1); + SwTextFormatColl const*const pColl = GetExport().m_rDoc.FindTextFormatCollByName(rStyle); + if (pColl) + { + sStr += "\\t \"" + rStyle + sEntryEnd; + } + } break; case TOX_AUTHORITIES: diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index b849f453034c..604e067aab8e 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -6342,6 +6342,12 @@ void DomainMapper_Impl::handleToc xTOC->setPropertyValue(getPropertyName(PROP_LABEL_CATEGORY), uno::Any(sFigureSequence)); + if (!sTemplate.isEmpty()) + { + OUString const sConvertedStyleName(GetStyleSheetTable()->ConvertStyleName(sTemplate, true)); + xTOC->setPropertyValue("CreateFromParagraphStyle", uno::Any(sConvertedStyleName)); + } + if ( bHyperlinks ) { uno::Reference< container::XIndexReplace> xLevelFormats;