filter/source/msfilter/util.cxx | 7 -- include/svx/sidebar/AreaPropertyPanelBase.hxx | 3 - include/vcl/EnumContext.hxx | 1 svx/source/sidebar/area/AreaPropertyPanel.cxx | 11 +++ svx/source/sidebar/area/AreaPropertyPanel.hxx | 2 sw/qa/extras/ooxmlexport/data/StyleRef-DE.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport17.cxx | 12 +++- sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx | 2 sw/source/core/doc/doctxm.cxx | 3 - sw/source/core/fields/reffld.cxx | 66 ++++++++++++++-------- sw/uiconfig/swriter/ui/fldvarpage.ui | 17 ++++- writerfilter/source/dmapper/DomainMapper.cxx | 4 - writerfilter/source/dmapper/DomainMapper_Impl.cxx | 46 +++------------ writerfilter/source/dmapper/StyleSheetTable.cxx | 56 ++++++++++++++---- writerfilter/source/dmapper/StyleSheetTable.hxx | 3 - 15 files changed, 146 insertions(+), 87 deletions(-)
New commits: commit cdf35d5e6a5104a125eb49f28d7bcfe8effb7390 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Fri May 3 17:33:56 2024 +0200 Commit: Thorsten Behrens <thorsten.behr...@allotropia.de> CommitDate: Tue May 7 19:14:26 2024 +0200 tdf#40142 sw: only check level for table of contents Only Table of Contents has level settings, the level is always 0 for the other ToX types, which erroneously excludes nodes (as can be seen with testFDO77715 failing with upcoming tdf#160402 bugfix). (regression from commit 5c04c4474236cc50009aea6d89f7c443c861af19) Change-Id: Iec1c2b8eaba0ad20b2ad7d8c6b20603315a7a83d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167096 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> (cherry picked from commit 7178d6197b892e456a8db8a3d085a24bfd52cf32) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167212 Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com> diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx index d29223050b6a..f9533b37f647 100644 --- a/sw/source/core/doc/doctxm.cxx +++ b/sw/source/core/doc/doctxm.cxx @@ -1375,7 +1375,8 @@ void SwTOXBaseSection::UpdateTemplate(const SwTextNode* pOwnChapterNode, pTextNd->getLayoutFrame(pLayout) && pTextNd->GetNodes().IsDocNodes() && // tdf#40142 - consider level settings of the various text nodes - o3tl::make_unsigned(pTextNd->GetAttrOutlineLevel()) <= GetLevel() && + (TOX_CONTENT != SwTOXBase::GetType() || + o3tl::make_unsigned(pTextNd->GetAttrOutlineLevel()) <= GetLevel()) && (!pLayout || !pLayout->HasMergedParas() || static_cast<SwTextFrame*>(pTextNd->getLayoutFrame(pLayout))->GetTextNodeForParaProps() == pTextNd) && (!IsFromChapter() || IsHeadingContained(pOwnChapterNode, *pTextNd))) commit 44bd68e8e03528078c50c3220bd99d8d7f82de5f Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Fri May 3 19:31:20 2024 +0200 Commit: Thorsten Behrens <thorsten.behr...@allotropia.de> CommitDate: Tue May 7 19:14:26 2024 +0200 tdf#160402 writerfilter,sw: STYLEREF field can refer to character style Adapt SwGetRefFieldType::FindAnchor() to search for SwTextCharFormat, and ApplyClonedTOCStylesToXText() to replace "CharStyleName". Works for the "Intensive Hervorhebung" field in bugdoc. Change-Id: Iee126eeb4cc2ff1c570941e3beefd93527c56fee Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167098 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> Tested-by: Jenkins (cherry picked from commit d4fdafa103bfea94a279d7069ddc50ba92f67d01) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167244 Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com> diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx index f0d5004f73b5..dee26b595c08 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx @@ -746,9 +746,9 @@ DECLARE_OOXMLEXPORT_TEST(testTdf160402, "StyleRef-DE.docx") xmlDocUniquePtr pLayout = parseLayoutDump(); assertXPath(pLayout, "/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion"_ostr, "expand"_ostr, "Heading 1"); assertXPath(pLayout, "/root/page[2]/header/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion"_ostr, "expand"_ostr, "Nunc viverra imperdiet enim. Fusce est. Vivamus a tellus."); - assertXPath(pLayout, "/root/page[3]/header/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion"_ostr, "expand"_ostr, "Error: Reference source not found"); // TODO + assertXPath(pLayout, "/root/page[3]/header/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion"_ostr, "expand"_ostr, "Cras faucibus condimentum odio. Sed ac ligula. Aliquam at eros."); assertXPath(pLayout, "/root/page[4]/header/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion"_ostr, "expand"_ostr, "Nunc viverra imperdiet enim. Fusce est. Vivamus a tellus."); - assertXPath(pLayout, "/root/page[5]/header/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion"_ostr, "expand"_ostr, "Error: Reference source not found"); // TODO + assertXPath(pLayout, "/root/page[5]/header/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion"_ostr, "expand"_ostr, "Aenean nec lorem. In porttitor. Donec laoreet nonummy augue."); } DECLARE_OOXMLEXPORT_TEST(testTdf142407, "tdf142407.docx") diff --git a/sw/source/core/fields/reffld.cxx b/sw/source/core/fields/reffld.cxx index 0ee26771bb2c..85a18c78927f 100644 --- a/sw/source/core/fields/reffld.cxx +++ b/sw/source/core/fields/reffld.cxx @@ -1220,7 +1220,9 @@ namespace /// Picks the first text node with a matching style from a double ended queue, starting at the front /// This allows us to use the deque either as a stack or as a queue depending on whether we want to search up or down SwTextNode* SearchForStyleAnchor(SwTextNode* pSelf, const std::deque<SwNode*>& pToSearch, - std::u16string_view rStyleName, bool bCaseSensitive = true) + std::u16string_view rStyleName, + sal_Int32 *const pStart, sal_Int32 *const pEnd, + bool bCaseSensitive = true) { std::deque<SwNode*> pSearching(pToSearch); while (!pSearching.empty()) @@ -1235,15 +1237,38 @@ namespace if (!pTextNode) continue; - if (bCaseSensitive) + if (bCaseSensitive + ? pTextNode->GetFormatColl()->GetName() == rStyleName + : pTextNode->GetFormatColl()->GetName().equalsIgnoreAsciiCase(rStyleName)) { - if (pTextNode->GetFormatColl()->GetName() == rStyleName) - return pTextNode; + *pStart = 0; + if (pEnd) + { + *pEnd = pTextNode->GetText().getLength(); + } + return pTextNode; } - else + + if (auto const pHints = pTextNode->GetpSwpHints()) { - if (pTextNode->GetFormatColl()->GetName().equalsIgnoreAsciiCase(rStyleName)) - return pTextNode; + for (size_t i = 0; i < pHints->Count(); ++i) + { + auto const*const pHint(pHints->Get(i)); + if (pHint->Which() == RES_TXTATR_CHARFMT) + { + if (bCaseSensitive + ? pHint->GetCharFormat().GetCharFormat()->HasName(rStyleName) + : pHint->GetCharFormat().GetCharFormat()->GetName().equalsIgnoreAsciiCase(rStyleName)) + { + *pStart = pHint->GetStart(); + if (pEnd) + { + *pEnd = *pHint->End(); + } + return pTextNode; + } + } + } } } @@ -1505,21 +1530,21 @@ SwTextNode* SwGetRefFieldType::FindAnchor(SwDoc* pDoc, const OUString& rRefMark, pSearchThird.push_back(nodes[n]); } - pTextNd = SearchForStyleAnchor(pSelf, pInPage, rRefMark); + pTextNd = SearchForStyleAnchor(pSelf, pInPage, rRefMark, pStt, pEnd); if (pTextNd) { break; } // 2. Search up from the top of the page - pTextNd = SearchForStyleAnchor(pSelf, pSearchSecond, rRefMark); + pTextNd = SearchForStyleAnchor(pSelf, pSearchSecond, rRefMark, pStt, pEnd); if (pTextNd) { break; } // 3. Search down from the bottom of the page - pTextNd = SearchForStyleAnchor(pSelf, pSearchThird, rRefMark); + pTextNd = SearchForStyleAnchor(pSelf, pSearchThird, rRefMark, pStt, pEnd); if (pTextNd) { break; @@ -1528,21 +1553,21 @@ SwTextNode* SwGetRefFieldType::FindAnchor(SwDoc* pDoc, const OUString& rRefMark, // Word has case insensitive styles. LO has case sensitive styles. If we didn't find // it yet, maybe we could with a case insensitive search. Let's do that - pTextNd = SearchForStyleAnchor(pSelf, pInPage, rRefMark, + pTextNd = SearchForStyleAnchor(pSelf, pInPage, rRefMark, pStt, pEnd, false /* bCaseSensitive */); if (pTextNd) { break; } - pTextNd = SearchForStyleAnchor(pSelf, pSearchSecond, rRefMark, + pTextNd = SearchForStyleAnchor(pSelf, pSearchSecond, rRefMark, pStt, pEnd, false /* bCaseSensitive */); if (pTextNd) { break; } - pTextNd = SearchForStyleAnchor(pSelf, pSearchThird, rRefMark, + pTextNd = SearchForStyleAnchor(pSelf, pSearchThird, rRefMark, pStt, pEnd, false /* bCaseSensitive */); break; } @@ -1574,7 +1599,7 @@ SwTextNode* SwGetRefFieldType::FindAnchor(SwDoc* pDoc, const OUString& rRefMark, // 1. Search up until we hit the top of the document - pTextNd = SearchForStyleAnchor(pSelf, pSearchFirst, rRefMark); + pTextNd = SearchForStyleAnchor(pSelf, pSearchFirst, rRefMark, pStt, pEnd); if (pTextNd) { break; @@ -1582,7 +1607,7 @@ SwTextNode* SwGetRefFieldType::FindAnchor(SwDoc* pDoc, const OUString& rRefMark, // 2. Search down until we hit the bottom of the document - pTextNd = SearchForStyleAnchor(pSelf, pSearchSecond, rRefMark); + pTextNd = SearchForStyleAnchor(pSelf, pSearchSecond, rRefMark, pStt, pEnd); if (pTextNd) { break; @@ -1590,14 +1615,14 @@ SwTextNode* SwGetRefFieldType::FindAnchor(SwDoc* pDoc, const OUString& rRefMark, // Again, we need to remember that Word styles are not case sensitive - pTextNd = SearchForStyleAnchor(pSelf, pSearchFirst, rRefMark, + pTextNd = SearchForStyleAnchor(pSelf, pSearchFirst, rRefMark, pStt, pEnd, false /* bCaseSensitive */); if (pTextNd) { break; } - pTextNd = SearchForStyleAnchor(pSelf, pSearchSecond, rRefMark, + pTextNd = SearchForStyleAnchor(pSelf, pSearchSecond, rRefMark, pStt, pEnd, false /* bCaseSensitive */); break; } @@ -1605,13 +1630,6 @@ SwTextNode* SwGetRefFieldType::FindAnchor(SwDoc* pDoc, const OUString& rRefMark, OSL_FAIL("<SwGetRefFieldType::FindAnchor(..)> - unknown getref element type"); } - if (pTextNd) - { - *pStt = 0; - if (pEnd) - *pEnd = pTextNd->GetText().getLength(); - } - break; } diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx index f5c348d64fc3..6b1a79e66c04 100644 --- a/writerfilter/source/dmapper/StyleSheetTable.cxx +++ b/writerfilter/source/dmapper/StyleSheetTable.cxx @@ -1030,6 +1030,20 @@ void StyleSheetTable_Impl::ApplyClonedTOCStylesToXText(uno::Reference<text::XTex xPara->setPropertyValue(u"ParaStyleName"_ustr, uno::Any(it->second)); } } + uno::Reference<container::XEnumerationAccess> const xParaEA{xPara, uno::UNO_QUERY_THROW}; + uno::Reference<container::XEnumeration> const xEnum{xParaEA->createEnumeration()}; + while (xEnum->hasMoreElements()) + { + uno::Reference<beans::XPropertySet> const xPortion{xEnum->nextElement(), uno::UNO_QUERY_THROW}; + if (xPortion->getPropertyValue(u"CharStyleName"_ustr) >>= styleName) + { + auto const it{m_ClonedTOCStylesMap.find(styleName)}; + if (it != m_ClonedTOCStylesMap.end()) + { + xPortion->setPropertyValue(u"CharStyleName"_ustr, uno::Any(it->second)); + } + } + } } else if (xElem->supportsService(u"com.sun.star.text.TextTable"_ustr)) { commit cc8b9e4881eec9c66911db0ee47ae5bfb6f7383b Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Fri May 3 12:12:24 2024 +0200 Commit: Thorsten Behrens <thorsten.behr...@allotropia.de> CommitDate: Tue May 7 19:14:26 2024 +0200 tdf#160402 filter,writerfilter: import locale-dependent STYLEREF names * Handle STYLEREF style the same way as TOC style on import. * Word 2013 does not uppercase the first letter ("Überschrift 1" -> "berschrift1") and there doesn't appear to be any justification why the code does that. * The style that's applied is actually the display style name so convert from source's m_sConvertedStyleName. * Change the logic in DomainMapper_Impl::ConvertTOCStyleName() to explicitly check and clone only known built-in Word styles, which are the ones that are translated. * This requires some refactoring, and to add the built-in styles in the bugdoc to the "StyleNameMap", which is probably still incomplete... * Exporting to DOCX appears to work without changes. * Somehow this causes the testFDO77715 to have an outlinelevel of 1 on the TOC paragraphs now, but that turns out to be a bugfix. Change-Id: I73bc1d1819e5cecbba2fef9cd6d290682a02a638 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167097 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> Tested-by: Jenkins (cherry picked from commit ab1697cb4c17fd7a2fbf8d374ac95fc03b4d00be) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167243 Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com> diff --git a/filter/source/msfilter/util.cxx b/filter/source/msfilter/util.cxx index 4c9a065841b8..4e37947abe61 100644 --- a/filter/source/msfilter/util.cxx +++ b/filter/source/msfilter/util.cxx @@ -320,11 +320,8 @@ OUString CreateDOCXStyleId(std::u16string_view const aName) sal_Unicode nChar = aName[i]; if (rtl::isAsciiAlphanumeric(nChar) || nChar == '-') { - // first letter should be uppercase - if (aStyleIdBuf.isEmpty()) - aStyleIdBuf.append(char(rtl::toAsciiUpperCase(nChar))); - else - aStyleIdBuf.append(char(nChar)); + // do not uppercase first letter + aStyleIdBuf.append(char(nChar)); } } return aStyleIdBuf.makeStringAndClear(); diff --git a/sw/qa/extras/ooxmlexport/data/StyleRef-DE.docx b/sw/qa/extras/ooxmlexport/data/StyleRef-DE.docx new file mode 100644 index 000000000000..800ef6413fe6 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/StyleRef-DE.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx index 49d974b01159..f0d5004f73b5 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx @@ -229,7 +229,7 @@ CPPUNIT_TEST_FIXTURE(Test, testParaStyleNumLevel) // - Expected: 1 // - Actual : 0 // i.e. a custom list level in a para style was lost on import+export. - assertXPath(pXmlDoc, "/w:styles/w:style[@w:styleId='Mystyle']/w:pPr/w:numPr/w:ilvl"_ostr, "val"_ostr, "1"); + assertXPath(pXmlDoc, "/w:styles/w:style[@w:styleId='mystyle']/w:pPr/w:numPr/w:ilvl"_ostr, "val"_ostr, "1"); } CPPUNIT_TEST_FIXTURE(Test, testClearingBreak) @@ -741,6 +741,16 @@ DECLARE_OOXMLEXPORT_TEST(testTdf153082_comma, "custom-styles-TOC-comma.docx") CPPUNIT_ASSERT(tocContent.indexOf("Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.") != -1); } +DECLARE_OOXMLEXPORT_TEST(testTdf160402, "StyleRef-DE.docx") +{ + xmlDocUniquePtr pLayout = parseLayoutDump(); + assertXPath(pLayout, "/root/page[1]/header/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion"_ostr, "expand"_ostr, "Heading 1"); + assertXPath(pLayout, "/root/page[2]/header/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion"_ostr, "expand"_ostr, "Nunc viverra imperdiet enim. Fusce est. Vivamus a tellus."); + assertXPath(pLayout, "/root/page[3]/header/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion"_ostr, "expand"_ostr, "Error: Reference source not found"); // TODO + assertXPath(pLayout, "/root/page[4]/header/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion"_ostr, "expand"_ostr, "Nunc viverra imperdiet enim. Fusce est. Vivamus a tellus."); + assertXPath(pLayout, "/root/page[5]/header/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion"_ostr, "expand"_ostr, "Error: Reference source not found"); // TODO +} + DECLARE_OOXMLEXPORT_TEST(testTdf142407, "tdf142407.docx") { uno::Reference<container::XNameAccess> xPageStyles = getStyles("PageStyles"); diff --git a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx index a97d8e8b841c..66faba5f3e59 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx @@ -177,6 +177,8 @@ CPPUNIT_TEST_FIXTURE(Test, testFDO77715) xTOC->update(); OUString const tocContent(xTOC->getAnchor()->getString()); CPPUNIT_ASSERT(tocContent.startsWith("National Infrastructure Bank Aff/Neg Index")); + // check that 1st paragraph has outline level 1 + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty<sal_Int32>(getParagraph(1), "OutlineLevel")); } CPPUNIT_TEST_FIXTURE(Test, testTOCFlag_u) diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index 7e4eeda7d3d9..344a36cf9520 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -2601,7 +2601,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext ) case NS_ooxml::LN_CT_PPrBase_pStyle: { StyleSheetTablePtr pStyleTable = m_pImpl->GetStyleSheetTable(); - const OUString sConvertedStyleName = pStyleTable->ConvertStyleName( sStringValue, true ); + const OUString sConvertedStyleName = pStyleTable->ConvertStyleNameExt(sStringValue); m_pImpl->SetCurrentParaStyleName( sConvertedStyleName ); if (m_pImpl->GetTopContext() && m_pImpl->GetTopContextType() != CONTEXT_SECTION) m_pImpl->GetTopContext()->Insert( PROP_PARA_STYLE_NAME, uno::Any( sConvertedStyleName )); @@ -2609,7 +2609,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext ) break; case NS_ooxml::LN_EG_RPrBase_rStyle: { - OUString sConvertedName( m_pImpl->GetStyleSheetTable()->ConvertStyleName( sStringValue, true ) ); + OUString const sConvertedName(m_pImpl->GetStyleSheetTable()->ConvertStyleNameExt(sStringValue)); if (m_pImpl->CheckFootnoteStyle() && m_pImpl->GetFootnoteContext()) m_pImpl->SetHasFootnoteStyle(m_pImpl->GetFootnoteContext()->GetFootnoteStyle() == sConvertedName); diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 028b4b4c9aee..20aa003b4101 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -6908,21 +6908,18 @@ static OUString UnquoteFieldText(std::u16string_view s) OUString DomainMapper_Impl::ConvertTOCStyleName(OUString const& rTOCStyleName) { assert(!rTOCStyleName.isEmpty()); - if (auto const pStyle = GetStyleSheetTable()->FindStyleSheetByISTD(rTOCStyleName)) - { // theoretical case: what OOXML says - return pStyle->m_sStyleName; - } - auto const pStyle = GetStyleSheetTable()->FindStyleSheetByISTD(FilterChars(rTOCStyleName)); - if (pStyle && m_bIsNewDoc) - { // practical case: Word wrote i18n name to TOC field, but it doesn't - // exist in styles.xml; tdf#153083 clone it for best roundtrip - SAL_INFO("writerfilter.dmapper", "cloning TOC paragraph style (presumed built-in) " << rTOCStyleName << " from " << pStyle->m_sStyleName); - return GetStyleSheetTable()->CloneTOCStyle(GetFontTable(), pStyle, rTOCStyleName); - } - else + if (auto const pStyle = GetStyleSheetTable()->FindStyleSheetByISTD(FilterChars(rTOCStyleName))) { - return GetStyleSheetTable()->ConvertStyleName(rTOCStyleName); + auto const [convertedStyleName, isBuiltIn] = StyleSheetTable::ConvertStyleName(pStyle->m_sStyleName); + if (isBuiltIn && m_bIsNewDoc) + { // practical case: Word wrote i18n name to TOC field, but it doesn't + // exist in styles.xml; tdf#153083 clone it for best roundtrip + assert(convertedStyleName == pStyle->m_sConvertedStyleName); + return GetStyleSheetTable()->CloneTOCStyle(GetFontTable(), pStyle, rTOCStyleName); + } } + // theoretical case: what OOXML says + return StyleSheetTable::ConvertStyleName(rTOCStyleName).first; } void DomainMapper_Impl::handleToc @@ -7992,29 +7989,8 @@ void DomainMapper_Impl::CloseFieldCommand() getPropertyName(PROP_REFERENCE_FIELD_SOURCE), uno::Any(sal_Int16(text::ReferenceFieldSource::STYLE))); - OUString sStyleSheetName - = GetStyleSheetTable()->ConvertStyleName(sFirstParam, true); - uno::Any aStyleDisplayName; - - uno::Reference<style::XStyleFamiliesSupplier> xStylesSupplier( - GetTextDocument(), uno::UNO_QUERY_THROW); - uno::Reference<container::XNameAccess> xStyleFamilies - = xStylesSupplier->getStyleFamilies(); - uno::Reference<container::XNameAccess> xStyles; - xStyleFamilies->getByName(getPropertyName(PROP_PARAGRAPH_STYLES)) - >>= xStyles; - uno::Reference<css::beans::XPropertySet> xStyle; - - try - { - xStyles->getByName(sStyleSheetName) >>= xStyle; - aStyleDisplayName = xStyle->getPropertyValue("DisplayName"); - } - catch (css::container::NoSuchElementException) - { - aStyleDisplayName <<= sStyleSheetName; - } + aStyleDisplayName <<= ConvertTOCStyleName(sFirstParam); xFieldProperties->setPropertyValue( getPropertyName(PROP_SOURCE_NAME), aStyleDisplayName); diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx index 711a90290f4c..f5c348d64fc3 100644 --- a/writerfilter/source/dmapper/StyleSheetTable.cxx +++ b/writerfilter/source/dmapper/StyleSheetTable.cxx @@ -813,7 +813,7 @@ void StyleSheetTable::lcl_entry(writerfilter::Reference<Properties>::Pointer_t r m_pImpl->m_rDMapper.PopStyleSheetProperties(); if( !m_pImpl->m_rDMapper.IsOOXMLImport() || !m_pImpl->m_pCurrentEntry->m_sStyleName.isEmpty()) { - m_pImpl->m_pCurrentEntry->m_sConvertedStyleName = ConvertStyleName( m_pImpl->m_pCurrentEntry->m_sStyleName ); + m_pImpl->m_pCurrentEntry->m_sConvertedStyleName = ConvertStyleName(m_pImpl->m_pCurrentEntry->m_sStyleName).first; m_pImpl->m_aStyleSheetEntries.push_back( m_pImpl->m_pCurrentEntry ); m_pImpl->m_aStyleSheetEntriesMap.emplace( m_pImpl->m_pCurrentEntry->m_sStyleIdentifierD, m_pImpl->m_pCurrentEntry ); } @@ -922,7 +922,7 @@ void StyleSheetTable::ApplyNumberingStyleNameToParaStyles() if (pStyleSheetProperties->props().GetListId() > -1) { uno::Reference< style::XStyle > xStyle; - xParaStyles->getByName( ConvertStyleName(pEntry->m_sStyleName) ) >>= xStyle; + xParaStyles->getByName(ConvertStyleName(pEntry->m_sStyleName).first) >>= xStyle; if ( !xStyle.is() ) break; @@ -1076,14 +1076,19 @@ void StyleSheetTable::ApplyClonedTOCStyles() OUString StyleSheetTable::CloneTOCStyle(FontTablePtr const& rFontTable, StyleSheetEntryPtr const pStyle, OUString const& rNewName) { + auto const it = m_pImpl->m_ClonedTOCStylesMap.find(pStyle->m_sConvertedStyleName); + if (it != m_pImpl->m_ClonedTOCStylesMap.end()) + { + return it->second; + } + SAL_INFO("writerfilter.dmapper", "cloning TOC paragraph style (presumed built-in) " << rNewName << " from " << pStyle->m_sStyleName); StyleSheetEntryPtr const pClone(new StyleSheetEntry(*pStyle)); pClone->m_sStyleIdentifierD = rNewName; pClone->m_sStyleName = rNewName; - pClone->m_sConvertedStyleName = ConvertStyleName(rNewName); + pClone->m_sConvertedStyleName = ConvertStyleName(rNewName).first; m_pImpl->m_aStyleSheetEntries.push_back(pClone); - // add it so it will be found if referenced from another TOC - m_pImpl->m_aStyleSheetEntriesMap.emplace(rNewName, pClone); - m_pImpl->m_ClonedTOCStylesMap.emplace(pStyle->m_sStyleName, pClone->m_sConvertedStyleName); + // the old converted name is what is applied to paragraphs + m_pImpl->m_ClonedTOCStylesMap.emplace(pStyle->m_sConvertedStyleName, pClone->m_sConvertedStyleName); std::vector<StyleSheetEntryPtr> const styles{ pClone }; ApplyStyleSheetsImpl(rFontTable, styles); return pClone->m_sConvertedStyleName; @@ -1127,7 +1132,7 @@ void StyleSheetTable::ApplyStyleSheetsImpl(const FontTablePtr& rFontTable, std:: bool bInsert = false; uno::Reference< container::XNameContainer > xStyles = bParaStyle ? xParaStyles : (bListStyle ? xNumberingStyles : xCharStyles); uno::Reference< style::XStyle > xStyle; - const OUString sConvertedStyleName = ConvertStyleName( pEntry->m_sStyleName ); + const OUString sConvertedStyleName(ConvertStyleName(pEntry->m_sStyleName).first); if(xStyles->hasByName( sConvertedStyleName )) { @@ -1194,7 +1199,7 @@ void StyleSheetTable::ApplyStyleSheetsImpl(const FontTablePtr& rFontTable, std:: // Writer core doesn't support numbering styles having a parent style, it seems if (pParent && !bListStyle) { - const OUString sParentStyleName = ConvertStyleName( pParent->m_sStyleName ); + const OUString sParentStyleName(ConvertStyleName(pParent->m_sStyleName).first); if ( !sParentStyleName.isEmpty() && !xStyles->hasByName( sParentStyleName ) ) aMissingParent.emplace_back( sParentStyleName, xStyle ); else @@ -1254,7 +1259,7 @@ void StyleSheetTable::ApplyStyleSheetsImpl(const FontTablePtr& rFontTable, std:: StyleSheetEntryPtr pLinkStyle = FindStyleSheetByISTD(pEntry->m_sLinkStyleIdentifier); if (pLinkStyle && !pLinkStyle->m_sStyleName.isEmpty()) - aMissingLink.emplace_back(ConvertStyleName(pLinkStyle->m_sStyleName), + aMissingLink.emplace_back(ConvertStyleName(pLinkStyle->m_sStyleName).first, xStyle); } } @@ -1266,7 +1271,7 @@ void StyleSheetTable::ApplyStyleSheetsImpl(const FontTablePtr& rFontTable, std:: { StyleSheetEntryPtr pFollowStyle = FindStyleSheetByISTD( pEntry->m_sNextStyleIdentifier ); if ( pFollowStyle && !pFollowStyle->m_sStyleName.isEmpty() ) - aMissingFollow.emplace_back( ConvertStyleName( pFollowStyle->m_sStyleName ), xStyle ); + aMissingFollow.emplace_back(ConvertStyleName(pFollowStyle->m_sStyleName).first, xStyle); } // Set the outline levels @@ -1514,10 +1519,9 @@ const StyleSheetEntryPtr & StyleSheetTable::GetCurrentEntry() const return m_pImpl->m_pCurrentEntry; } -OUString StyleSheetTable::ConvertStyleName( const OUString& rWWName, bool bExtendedSearch) +OUString StyleSheetTable::ConvertStyleNameExt(const OUString& rWWName) { OUString sRet( rWWName ); - if( bExtendedSearch ) { //search for the rWWName in the IdentifierD of the existing styles and convert the sStyleName member auto findIt = m_pImpl->m_aStyleSheetEntriesMap.find(rWWName); @@ -1529,6 +1533,14 @@ OUString StyleSheetTable::ConvertStyleName( const OUString& rWWName, bool bExten } } + return ConvertStyleName(sRet).first; +} + +std::pair<OUString, bool> +StyleSheetTable::ConvertStyleName(const OUString& rWWName) +{ + OUString sRet(rWWName); + // create a map only once // This maps Word's special style manes to Writer's (the opposite to what MSWordStyles::GetWWId // and ww::GetEnglishNameFromSti do on export). The mapping gives a Writer's style name, which @@ -1656,6 +1668,7 @@ OUString StyleSheetTable::ConvertStyleName( const OUString& rWWName, bool bExten // { "Message Header", "" }, { "Subtitle", "Subtitle" }, // RES_POOLCOLL_DOC_SUBTITLE { "Salutation", "Salutation" }, // RES_POOLCOLL_GREETING + { "Intense Quote", "Intense Quote" }, // N/A // { "Date", "" }, { "Body Text First Indent", "First line indent" }, // RES_POOLCOLL_TEXT_IDENT // { "Body Text First Indent 2", "" }, @@ -1667,6 +1680,7 @@ OUString StyleSheetTable::ConvertStyleName( const OUString& rWWName, bool bExten // { "Block Text", "" }, { "Hyperlink", "Internet link" }, // RES_POOLCHR_INET_NORMAL { "FollowedHyperlink", "Visited Internet Link" }, // RES_POOLCHR_INET_VISIT + { "Intense Emphasis", "Intense Emphasis" }, // N/A { "Strong", "Strong Emphasis" }, // RES_POOLCHR_HTML_STRONG { "Emphasis", "Emphasis" }, // RES_POOLCHR_HTML_EMPHASIS // { "Document Map", "" }, @@ -1683,6 +1697,7 @@ OUString StyleSheetTable::ConvertStyleName( const OUString& rWWName, bool bExten if (const auto aIt = StyleNameMap.find(sRet); aIt != StyleNameMap.end()) { sRet = aIt->second; + return { sRet, true }; } else { @@ -1704,9 +1719,8 @@ OUString StyleSheetTable::ConvertStyleName( const OUString& rWWName, bool bExten // the UI names of built-in styles. if (ReservedStyleNames.find(sRet) != ReservedStyleNames.end() || sRet.endsWith(" (WW)")) sRet += " (WW)"; + return { sRet, false }; } - - return sRet; } void StyleSheetTable::applyDefaults(bool bParaProperties) diff --git a/writerfilter/source/dmapper/StyleSheetTable.hxx b/writerfilter/source/dmapper/StyleSheetTable.hxx index 5cffd7d9d2a5..92024d80071f 100644 --- a/writerfilter/source/dmapper/StyleSheetTable.hxx +++ b/writerfilter/source/dmapper/StyleSheetTable.hxx @@ -98,7 +98,8 @@ public: StyleSheetEntryPtr FindStyleSheetByConvertedStyleName(std::u16string_view rIndex); StyleSheetEntryPtr FindDefaultParaStyle(); - OUString ConvertStyleName( const OUString& rWWName, bool bExtendedSearch = false ); + OUString ConvertStyleNameExt(const OUString& rWWName); + static std::pair<OUString, bool> ConvertStyleName(const OUString& rWWName); OUString CloneTOCStyle(FontTablePtr const& rFontTable, StyleSheetEntryPtr const pStyle, OUString const& rName); void ApplyClonedTOCStyles(); commit 0dab1219a49f156645c4ed78478ee2f6ba168a99 Author: Oliver Specht <oliver.spe...@cib.de> AuthorDate: Tue May 7 14:33:10 2024 +0200 Commit: Thorsten Behrens <thorsten.behr...@allotropia.de> CommitDate: Tue May 7 19:14:26 2024 +0200 Design change in variable page of the field dialog in Writer Improves the commit 8e86df886f84fe69f13cfc367a5dd843e6ea917c Change-Id: I69bc7a8ddcc9593e1e0deb26311c31032f3f9ae8 diff --git a/sw/uiconfig/swriter/ui/fldvarpage.ui b/sw/uiconfig/swriter/ui/fldvarpage.ui index 9fd8c8f8a306..5a4e42081221 100644 --- a/sw/uiconfig/swriter/ui/fldvarpage.ui +++ b/sw/uiconfig/swriter/ui/fldvarpage.ui @@ -195,9 +195,9 @@ </child> </object> <packing> - <property name="left-attach">1</property> + <property name="left-attach">0</property> <property name="top-attach">1</property> - <property name="width">2</property> + <property name="width">3</property> </packing> </child> <child> @@ -227,6 +227,9 @@ <property name="headers-clickable">False</property> <property name="search-column">0</property> <property name="show-expanders">False</property> + <child internal-child="selection"> + <object class="GtkTreeSelection"/> + </child> <child> <object class="GtkTreeViewColumn" id="treeviewcolumn1"> <child> @@ -262,7 +265,6 @@ <packing> <property name="left-attach">0</property> <property name="top-attach">0</property> - <property name="height">2</property> </packing> </child> <child> @@ -292,6 +294,9 @@ <property name="headers-clickable">False</property> <property name="search-column">0</property> <property name="show-expanders">False</property> + <child internal-child="selection"> + <object class="GtkTreeSelection"/> + </child> <child> <object class="GtkTreeViewColumn" id="treeviewcolumn2"> <child> @@ -364,6 +369,9 @@ <property name="headers-clickable">False</property> <property name="search-column">0</property> <property name="show-expanders">False</property> + <child internal-child="selection"> + <object class="GtkTreeSelection"/> + </child> <child> <object class="GtkTreeViewColumn" id="treeviewcolumn3"> <child> @@ -406,6 +414,9 @@ <property name="headers-clickable">False</property> <property name="search-column">0</property> <property name="show-expanders">False</property> + <child internal-child="selection"> + <object class="GtkTreeSelection"/> + </child> <child> <object class="GtkTreeViewColumn" id="treeviewcolumn4"> <child> commit baa95d2795a0252d99c1d053ac29a9e350b240f6 Author: Oliver Specht <oliver.spe...@cib.de> AuthorDate: Thu May 2 08:39:14 2024 +0200 Commit: Thorsten Behrens <thorsten.behr...@allotropia.de> CommitDate: Tue May 7 19:14:02 2024 +0200 Sidebar: Direct update of FillStyle FillStyle is directly updated to prevent deferred resize when additional controls are created. Change-Id: I48ed987971cf6c711af31d552e8d64fa9982a416 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165993 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de> diff --git a/include/svx/sidebar/AreaPropertyPanelBase.hxx b/include/svx/sidebar/AreaPropertyPanelBase.hxx index 07a5873acf53..d11013275a60 100644 --- a/include/svx/sidebar/AreaPropertyPanelBase.hxx +++ b/include/svx/sidebar/AreaPropertyPanelBase.hxx @@ -102,7 +102,6 @@ public: private: void Initialize(); - virtual void HandleContextChange(const vcl::EnumContext& rContext) override; protected: const css::uno::Reference<css::frame::XFrame>& mxFrame; @@ -177,6 +176,8 @@ protected: // MCGR: Preserve ColorStops until we have a UI to edit these basegfx::BColorStops createColorStops(); + + virtual void HandleContextChange(const vcl::EnumContext& rContext) override; }; } // end of namespace svx::sidebar diff --git a/include/vcl/EnumContext.hxx b/include/vcl/EnumContext.hxx index b8e02efd1f68..1a3e3427ef74 100644 --- a/include/vcl/EnumContext.hxx +++ b/include/vcl/EnumContext.hxx @@ -130,6 +130,7 @@ public: Application GetApplication() const; Application GetApplication_DI() const; + Context GetContext() const {return meContext;} bool operator == (const EnumContext& rOther) const; bool operator != (const EnumContext& rOther) const; diff --git a/svx/source/sidebar/area/AreaPropertyPanel.cxx b/svx/source/sidebar/area/AreaPropertyPanel.cxx index 951028d61f32..1a5c02909c02 100644 --- a/svx/source/sidebar/area/AreaPropertyPanel.cxx +++ b/svx/source/sidebar/area/AreaPropertyPanel.cxx @@ -154,6 +154,17 @@ void AreaPropertyPanel::setFillStyleAndBitmap(const XFillStyleItem* pStyleItem, : std::initializer_list<SfxPoolItem const*>{ &rBitmapItem }); } +void AreaPropertyPanel::HandleContextChange(const vcl::EnumContext& rContext) +{ + AreaPropertyPanelBase::HandleContextChange(rContext); + if (rContext.GetContext() != vcl::EnumContext::Context::Default) + { + std::unique_ptr<SfxPoolItem> pFillState; + SfxItemState eState = mpBindings->QueryState( SID_ATTR_FILL_STYLE, pFillState ); + NotifyItemUpdate(SID_ATTR_FILL_STYLE, eState, pFillState.get()); + } +} + } // end of namespace svx::sidebar /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sidebar/area/AreaPropertyPanel.hxx b/svx/source/sidebar/area/AreaPropertyPanel.hxx index 6c398e6ac077..dc5b9d0194d2 100644 --- a/svx/source/sidebar/area/AreaPropertyPanel.hxx +++ b/svx/source/sidebar/area/AreaPropertyPanel.hxx @@ -83,6 +83,8 @@ private: ::sfx2::sidebar::ControllerItem maFillUseSlideBackgroundController; SfxBindings* mpBindings; + virtual void HandleContextChange(const vcl::EnumContext& rContext) override; + };