desktop/source/lib/init.cxx | 29 ++- include/sfx2/StylePreviewRenderer.hxx | 2 include/svl/style.hxx | 3 include/svx/svxids.hrc | 2 officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu | 5 sfx2/source/dialog/StyleList.cxx | 91 ++++++---- sfx2/source/doc/objserv.cxx | 21 +- svl/source/items/style.cxx | 5 svx/sdi/svx.sdi | 17 + sw/inc/docstyle.hxx | 2 sw/inc/modcfg.hxx | 2 sw/inc/rdfhelper.hxx | 2 sw/inc/view.hxx | 4 sw/sdi/_textsh.sdi | 6 sw/source/core/doc/rdfhelper.cxx | 27 +- sw/source/core/layout/paintfrm.cxx | 40 +++- sw/source/core/text/inftxt.cxx | 37 ++-- sw/source/core/unocore/unoobj2.cxx | 2 sw/source/filter/ww8/docxattributeoutput.cxx | 7 sw/source/filter/ww8/docxexport.cxx | 15 - sw/source/uibase/app/docstyle.cxx | 19 ++ sw/source/uibase/config/modcfg.cxx | 46 +++-- sw/source/uibase/config/usrpref.cxx | 42 ++-- sw/source/uibase/docvw/edtwin2.cxx | 8 sw/source/uibase/lingu/olmenu.cxx | 43 ++-- sw/source/uibase/shells/textsh1.cxx | 53 ++++- sw/source/uibase/uiview/view0.cxx | 30 ++- sw/source/uibase/uno/unotxdoc.cxx | 9 28 files changed, 395 insertions(+), 174 deletions(-)
New commits: commit c90b82892ea22d67c28e5d40a086b914c496f62c Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Tue Jan 28 20:53:29 2025 +0000 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Tue Feb 11 14:51:32 2025 +0000 xml::sax::XWriter is a xml::sax::XDocumentHandler Change-Id: I492bff5580b61c222a7e9b84d49ba70a5dc318b9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180865 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index 5472a0de8460..ffeb0b85a099 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -1582,8 +1582,7 @@ void DocxExport::WriteGlossary() uno::Reference< xml::sax::XSAXSerializable > serializer( glossaryDocDom, uno::UNO_QUERY ); uno::Reference< xml::sax::XWriter > writer = xml::sax::Writer::create( comphelper::getProcessComponentContext() ); writer->setOutputStream( xOutputStream ); - serializer->serialize( uno::Reference< xml::sax::XDocumentHandler >( writer, uno::UNO_QUERY_THROW ), - uno::Sequence< beans::StringPair >() ); + serializer->serialize(writer, uno::Sequence< beans::StringPair >()); for (const uno::Sequence<beans::NamedValue>& glossaryElement : glossaryDomList) { @@ -1624,8 +1623,7 @@ void DocxExport::WriteGlossary() continue; // External relation, no stream to write uno::Reference< xml::sax::XSAXSerializable > gserializer( xDom, uno::UNO_QUERY ); writer->setOutputStream(GetFilter().openFragmentStream( "word/glossary/" + gTarget, contentType ) ); - gserializer->serialize( uno::Reference< xml::sax::XDocumentHandler >( writer, uno::UNO_QUERY_THROW ), - uno::Sequence< beans::StringPair >() ); + gserializer->serialize(writer, uno::Sequence< beans::StringPair >()); } } @@ -1747,8 +1745,7 @@ void DocxExport::WriteCustomXml() writer->setOutputStream(xMemStream->getOutputStream()); - serializer->serialize(uno::Reference< xml::sax::XDocumentHandler >(writer, uno::UNO_QUERY_THROW), - uno::Sequence< beans::StringPair >()); + serializer->serialize(writer, uno::Sequence< beans::StringPair >()); uno::Reference< io::XStream > xXSLTInStream = xMemStream; uno::Reference< io::XStream > xXSLTOutStream; @@ -1779,8 +1776,7 @@ void DocxExport::WriteCustomXml() { writer->setOutputStream(xOutStream); - serializer->serialize(uno::Reference< xml::sax::XDocumentHandler >(writer, uno::UNO_QUERY_THROW), - uno::Sequence< beans::StringPair >()); + serializer->serialize(writer, uno::Sequence< beans::StringPair >()); } } @@ -1790,8 +1786,7 @@ void DocxExport::WriteCustomXml() uno::Reference< xml::sax::XWriter > writer = xml::sax::Writer::create( comphelper::getProcessComponentContext() ); writer->setOutputStream( GetFilter().openFragmentStream( "customXml/itemProps"+OUString::number(j+1)+".xml", u"application/vnd.openxmlformats-officedocument.customXmlProperties+xml"_ustr ) ); - serializer->serialize( uno::Reference< xml::sax::XDocumentHandler >( writer, uno::UNO_QUERY_THROW ), - uno::Sequence< beans::StringPair >() ); + serializer->serialize(writer, uno::Sequence< beans::StringPair >()); // Adding itemprops's relationship entry to item.xml.rels file m_rFilter.addRelation( GetFilter().openFragmentStream( "customXml/item"+OUString::number(j+1)+".xml", commit 758e6ea2292249bb70c8708730af72217f6332f5 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Wed Jan 29 10:28:18 2025 +0100 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Tue Feb 11 14:51:32 2025 +0000 Speed up the iteration further ... after commit 1a938482fbe10065d670e05257a62d8fcfff3793 (use getFastAttributeTokens and getValueByIndex, 2025-01-29), which has avoided Sequence construction overhead. This avoids conversion of value strings from UTF-8 to UTF-16 and back. Change-Id: Ie832002c5ef4fb6e5390e4b17b752714c09cf471 diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 4f66adfff1cf..bb252ea81660 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -792,11 +792,9 @@ void SdtBlockHelper::WriteSdtBlock(const ::sax_fastparser::FSHelperPtr& pSeriali } if (m_nSdtPrToken == FSNS(XML_w, XML_date) || m_nSdtPrToken == FSNS(XML_w, XML_docPartObj) || m_nSdtPrToken == FSNS(XML_w, XML_docPartList) || m_nSdtPrToken == FSNS(XML_w14, XML_checkbox)) { - const std::vector<sal_Int32>& rAttributeTokens = m_pTokenChildren->getFastAttributeTokens(); - for (size_t i = 0, n = rAttributeTokens.size(); i < n; ++i) + for (auto& it : *m_pTokenChildren) { - pSerializer->singleElement(rAttributeTokens[i], FSNS(XML_w, XML_val), - m_pTokenChildren->getValueByIndex(i)); + pSerializer->singleElement(it.getToken(), FSNS(XML_w, XML_val), it.toCString()); } } commit a04dcf277d83742d6a51a8e6ec435d79a6468110 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Tue Jan 28 21:30:43 2025 +0000 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Tue Feb 11 14:51:32 2025 +0000 use getFastAttributeTokens and getValueByIndex instead of getFastAttributes Change-Id: I011f0fd8bfd615ff9ee89dd7755c536740463f70 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180866 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 222ac359e906..4f66adfff1cf 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -792,9 +792,12 @@ void SdtBlockHelper::WriteSdtBlock(const ::sax_fastparser::FSHelperPtr& pSeriali } if (m_nSdtPrToken == FSNS(XML_w, XML_date) || m_nSdtPrToken == FSNS(XML_w, XML_docPartObj) || m_nSdtPrToken == FSNS(XML_w, XML_docPartList) || m_nSdtPrToken == FSNS(XML_w14, XML_checkbox)) { - const uno::Sequence<xml::FastAttribute> aChildren = m_pTokenChildren->getFastAttributes(); - for (const auto& rChild : aChildren) - pSerializer->singleElement(rChild.Token, FSNS(XML_w, XML_val), rChild.Value); + const std::vector<sal_Int32>& rAttributeTokens = m_pTokenChildren->getFastAttributeTokens(); + for (size_t i = 0, n = rAttributeTokens.size(); i < n; ++i) + { + pSerializer->singleElement(rAttributeTokens[i], FSNS(XML_w, XML_val), + m_pTokenChildren->getValueByIndex(i)); + } } pSerializer->endElement(m_nSdtPrToken); commit 16c644cd6c9428f33938c1d75cd91617b57a5ad5 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Tue Jan 28 17:00:19 2025 +0000 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Tue Feb 11 14:51:32 2025 +0000 We already have a SwXTextDocument, don't need to cast to XDocumentMetadataAccess, it's already available Change-Id: I35965afafb4080a2315862739d602677b966245a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180853 Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> Tested-by: Jenkins Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sw/inc/rdfhelper.hxx b/sw/inc/rdfhelper.hxx index 8152ef6765c5..dd7267758846 100644 --- a/sw/inc/rdfhelper.hxx +++ b/sw/inc/rdfhelper.hxx @@ -39,7 +39,7 @@ class SW_DLLPUBLIC SwRDFHelper public: /// Gets all graph-names in RDF of a given type. static css::uno::Sequence<css::uno::Reference<css::rdf::XURI>> - getGraphNames(const css::uno::Reference<css::rdf::XDocumentMetadataAccess>& xDocumentMetadataAccess, + getGraphNames(const rtl::Reference<SwXTextDocument>& xModel, const css::uno::Reference<css::rdf::XURI>& xType); /// Gets all graph-names in RDF of a given type. diff --git a/sw/source/core/doc/rdfhelper.cxx b/sw/source/core/doc/rdfhelper.cxx index c5374b7b24a6..aad999761445 100644 --- a/sw/source/core/doc/rdfhelper.cxx +++ b/sw/source/core/doc/rdfhelper.cxx @@ -27,12 +27,12 @@ using namespace com::sun::star; css::uno::Sequence<css::uno::Reference<css::rdf::XURI>> SwRDFHelper::getGraphNames( - const css::uno::Reference<rdf::XDocumentMetadataAccess>& xDocumentMetadataAccess, + const rtl::Reference<SwXTextDocument>& xModel, const css::uno::Reference<rdf::XURI>& xType) { try { - return xDocumentMetadataAccess->getMetadataGraphsWithType(xType); + return xModel->getMetadataGraphsWithType(xType); } catch (const uno::RuntimeException&) { @@ -103,8 +103,7 @@ void SwRDFHelper::addStatement(const rtl::Reference<SwXTextDocument>& xModel, { const uno::Reference<uno::XComponentContext>& xComponentContext(comphelper::getProcessComponentContext()); uno::Reference<rdf::XURI> xType = rdf::URI::create(xComponentContext, rType); - uno::Reference<rdf::XDocumentMetadataAccess> xDocumentMetadataAccess(xModel); - const uno::Sequence< uno::Reference<rdf::XURI> > aGraphNames = getGraphNames(xDocumentMetadataAccess, xType); + const uno::Sequence< uno::Reference<rdf::XURI> > aGraphNames = getGraphNames(xModel, xType); uno::Reference<rdf::XURI> xGraphName; if (aGraphNames.hasElements()) xGraphName = aGraphNames[0]; @@ -123,8 +122,7 @@ bool SwRDFHelper::hasMetadataGraph(const rtl::Reference<SwXTextDocument>& xModel { const uno::Reference<uno::XComponentContext>& xComponentContext(comphelper::getProcessComponentContext()); uno::Reference<rdf::XURI> xType = rdf::URI::create(xComponentContext, rType); - uno::Reference<rdf::XDocumentMetadataAccess> xDocumentMetadataAccess(xModel); - return getGraphNames(xDocumentMetadataAccess, xType).hasElements(); + return getGraphNames(xModel, xType).hasElements(); } void SwRDFHelper::removeStatement(const rtl::Reference<SwXTextDocument>& xModel, @@ -134,12 +132,11 @@ void SwRDFHelper::removeStatement(const rtl::Reference<SwXTextDocument>& xModel, { const uno::Reference<uno::XComponentContext>& xComponentContext(comphelper::getProcessComponentContext()); uno::Reference<rdf::XURI> xType = rdf::URI::create(xComponentContext, rType); - uno::Reference<rdf::XDocumentMetadataAccess> xDocumentMetadataAccess(xModel); - const uno::Sequence< uno::Reference<rdf::XURI> > aGraphNames = getGraphNames(xDocumentMetadataAccess, xType); + const uno::Sequence< uno::Reference<rdf::XURI> > aGraphNames = getGraphNames(xModel, xType); if (!aGraphNames.hasElements()) return; - uno::Reference<rdf::XNamedGraph> xGraph = xDocumentMetadataAccess->getRDFRepository()->getGraph(aGraphNames[0]); + uno::Reference<rdf::XNamedGraph> xGraph = xModel->getRDFRepository()->getGraph(aGraphNames[0]); uno::Reference<rdf::XURI> xKey = rdf::URI::create(xComponentContext, rKey); uno::Reference<rdf::XLiteral> xValue = rdf::Literal::create(xComponentContext, rValue); xGraph->removeStatements(xSubject, xKey, xValue); @@ -195,13 +192,12 @@ void SwRDFHelper::removeTextNodeStatement(const OUString& rType, SwTextNode& rTe if (!pShell) return; rtl::Reference<SwXTextDocument> xModel(pShell->GetBaseModel()); - uno::Reference<rdf::XDocumentMetadataAccess> xDocumentMetadataAccess(xModel); - const uno::Sequence< uno::Reference<rdf::XURI> > aGraphNames = getGraphNames(xDocumentMetadataAccess, xType); + const uno::Sequence< uno::Reference<rdf::XURI> > aGraphNames = getGraphNames(xModel, xType); if (!aGraphNames.hasElements()) return; const uno::Reference<rdf::XURI>& xGraphName = aGraphNames[0]; - uno::Reference<rdf::XNamedGraph> xGraph = xDocumentMetadataAccess->getRDFRepository()->getGraph(xGraphName); + uno::Reference<rdf::XNamedGraph> xGraph = xModel->getRDFRepository()->getGraph(xGraphName); uno::Reference<rdf::XResource> xSubject(SwXParagraph::CreateXParagraph(rTextNode.GetDoc(), &rTextNode, nullptr)); uno::Reference<rdf::XURI> xKey = rdf::URI::create(xComponentContext, rKey); uno::Reference<rdf::XLiteral> xValue = rdf::Literal::create(xComponentContext, rValue); @@ -216,8 +212,7 @@ void SwRDFHelper::updateTextNodeStatement(const OUString& rType, const OUString& if (!pShell) return; rtl::Reference<SwXTextDocument> xModel(pShell->GetBaseModel()); - uno::Reference<rdf::XDocumentMetadataAccess> xDocumentMetadataAccess(xModel); - const uno::Sequence< uno::Reference<rdf::XURI> > aGraphNames = getGraphNames(xDocumentMetadataAccess, xType); + const uno::Sequence< uno::Reference<rdf::XURI> > aGraphNames = getGraphNames(xModel, xType); uno::Reference<rdf::XURI> xGraphName; if (aGraphNames.hasElements()) { @@ -226,10 +221,10 @@ void SwRDFHelper::updateTextNodeStatement(const OUString& rType, const OUString& else { uno::Sequence< uno::Reference<rdf::XURI> > xTypes = { xType }; - xGraphName = xDocumentMetadataAccess->addMetadataFile(rPath, xTypes); + xGraphName = xModel->addMetadataFile(rPath, xTypes); } - uno::Reference<rdf::XNamedGraph> xGraph = xDocumentMetadataAccess->getRDFRepository()->getGraph(xGraphName); + uno::Reference<rdf::XNamedGraph> xGraph = xModel->getRDFRepository()->getGraph(xGraphName); uno::Reference<rdf::XResource> xSubject(SwXParagraph::CreateXParagraph(rTextNode.GetDoc(), &rTextNode, nullptr)); uno::Reference<rdf::XURI> xKey = rdf::URI::create(xComponentContext, rKey); commit d999bdc7bfad240a8e652ca5702dd3d18b2310ef Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Tue Jan 28 19:56:25 2025 +0000 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Tue Feb 11 14:51:32 2025 +0000 SwXTextDocument::getBodyText can be used instead of getText here and that's already a rtl::Reference to SwXBodyText which is derived from SwXText Change-Id: I071c0711fef911deec4258ef9e6719b721a39de2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180859 Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> Tested-by: Jenkins diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 56de1e9911f0..3c9f91eff0ac 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -1386,7 +1386,7 @@ CreateParentXText(SwDoc & rDoc, const SwPosition& rPos) { // then it is the body text const rtl::Reference<SwXTextDocument> xModel = pDocSh->GetBaseModel(); - xParentText = dynamic_cast<SwXText*>(xModel->getText().get()); + xParentText = xModel->getBodyText(); } } } commit b63e1a9009d02fbb270df416f13f252c19a037bf Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Mon Jan 27 12:56:26 2025 +0000 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Tue Feb 11 14:51:32 2025 +0000 allow zero or more xcu files to be installed Change-Id: Ibcca052697c391794b636606cf590549568821be Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180782 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> (cherry picked from commit e3b6888f9071011fd69e1d15aa8adb0eae5e658c) diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 1d6fbc1be272..14f260a0e52e 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -5011,15 +5011,13 @@ static void lo_sendDialogEvent(LibreOfficeKit* /*pThis*/, unsigned long long int static void updateConfig(const OUString& rConfigPath) { osl::Directory aScanRootDir(rConfigPath); - osl::FileBase::RC nRetCode = aScanRootDir.open(); - if (nRetCode != osl::Directory::E_None) + if (aScanRootDir.open() != osl::Directory::E_None) { SAL_WARN("lok", "Failed to open config URL: " << rConfigPath); return; } osl::DirectoryItem item; - osl::File::RC errorNext = osl::File::E_None; - while ((errorNext = aScanRootDir.getNextItem(item)) == ::osl::File::E_None) + while (aScanRootDir.getNextItem(item) == ::osl::File::E_None) { osl::FileStatus stat(osl_FileStatus_Mask_FileName | osl_FileStatus_Mask_FileURL); if (item.getFileStatus(stat) != osl::FileBase::E_None) @@ -5031,9 +5029,28 @@ static void updateConfig(const OUString& rConfigPath) OUString sFileName = stat.getFileName(); if (sFileName == "xcu") { - OUString aXcuPath(stat.getFileURL() + "/config.xcu"); + osl::Directory aXCURootDir(stat.getFileURL()); + if (aXCURootDir.open() != osl::Directory::E_None) + { + SAL_WARN("lok", "Failed to open XCU URL: " << stat.getFileURL()); + continue; + } + auto xUpdate(css::configuration::Update::get(comphelper::getProcessComponentContext())); - xUpdate->insertModificationXcuFile(aXcuPath, { u"/"_ustr }, {}); + + osl::DirectoryItem xcu; + while (aXCURootDir.getNextItem(xcu) == ::osl::File::E_None) + { + osl::FileStatus xcustat(osl_FileStatus_Mask_FileName | osl_FileStatus_Mask_FileURL); + if (xcu.getFileStatus(xcustat) != osl::FileBase::E_None) + { + SAL_WARN("lok", "Failed to get xcu item info"); + continue; + } + + SAL_INFO("lok", "Installing XCU Item: " << xcustat.getFileName()); + xUpdate->insertModificationXcuFile(xcustat.getFileURL(), { u"/"_ustr }, {}); + } } } } commit aa2cf5a677ef1e114375c9e31fd6d773bd618ecf Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Wed Jan 22 17:31:25 2025 +0000 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Tue Feb 11 14:51:32 2025 +0000 defer finding dialog parent until we need it which might be never for the typical save Change-Id: I2989f2e9629ce13c8b301a6b85707443ddc4954a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180606 Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> Tested-by: Jenkins diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index dd289052e2af..c18da34283ef 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -579,24 +579,30 @@ void SfxObjectShell::AfterSignContent(bool bHaveWeSigned, weld::Window* pDialogP } } -void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) +static weld::Window* GetReqDialogParent(SfxRequest &rReq, SfxObjectShell& rShell) { weld::Window* pDialogParent = rReq.GetFrameWeld(); if (!pDialogParent) { - SfxViewFrame* pFrame = GetFrame(); + SfxViewFrame* pFrame = rShell.GetFrame(); if (!pFrame) - pFrame = SfxViewFrame::GetFirst(this); + pFrame = SfxViewFrame::GetFirst(&rShell); if (pFrame) pDialogParent = pFrame->GetFrameWeld(); } + return pDialogParent; +} +void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) +{ sal_uInt16 nId = rReq.GetSlot(); bool bHaveWeSigned = false; if( SID_SIGNATURE == nId || SID_MACRO_SIGNATURE == nId ) { + weld::Window* pDialogParent = GetReqDialogParent(rReq, *this); + QueryHiddenInformation(HiddenWarningFact::WhenSigning); if (SID_SIGNATURE == nId) @@ -721,6 +727,7 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) if ( !IsOwnStorageFormat( *GetMedium() ) ) return; + weld::Window* pDialogParent = GetReqDialogParent(rReq, *this); SfxVersionDialog aDlg(pDialogParent, pFrame, IsSaveVersionOnClose()); aDlg.run(); SetSaveVersionOnClose(aDlg.IsSaveVersionOnClose()); @@ -829,6 +836,8 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) case SID_AUTOREDACTDOC: { + weld::Window* pDialogParent = GetReqDialogParent(rReq, *this); + // Actual redaction takes place on a newly generated Draw document if (!SvtModuleOptions().IsDrawInstalled()) { @@ -868,6 +877,7 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) // Actual redaction takes place on a newly generated Draw document if (!SvtModuleOptions().IsDrawInstalled()) { + weld::Window* pDialogParent = GetReqDialogParent(rReq, *this); std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog( pDialogParent, VclMessageType::Warning, VclButtonsType::Ok, SfxResId(STR_REDACTION_NO_DRAW_WARNING))); @@ -1244,6 +1254,7 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) else { SfxErrorContext aEc(ERRCTX_SFX_SAVEASDOC,GetTitle()); + weld::Window* pDialogParent = GetReqDialogParent(rReq, *this); ErrorHandler::HandleError(lErr, pDialogParent); } } @@ -1417,7 +1428,10 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) if (comphelper::LibreOfficeKit::isActive()) sendErrorToLOK(lErr); else + { + weld::Window* pDialogParent = GetReqDialogParent(rReq, *this); ErrorHandler::HandleError(lErr, pDialogParent); + } rReq.SetReturnValue( SfxBoolItem(0, true) ); rReq.Done(); @@ -1430,6 +1444,7 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) case SID_DOCTEMPLATE: { // save as document templates + weld::Window* pDialogParent = GetReqDialogParent(rReq, *this); SfxSaveAsTemplateDialog aDlg(pDialogParent, GetModel()); (void)aDlg.run(); break; commit 0a42af3f43e3fa61704fe07cf5796dc84a67f8c3 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Fri Dec 20 12:52:57 2024 +0000 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Tue Feb 11 14:51:32 2025 +0000 expose Add to Dictionary menu entries to kit Change-Id: If9a072afef339110a4d44366b1f2e515e6feb55a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178917 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> (cherry picked from commit 2ce644117859138121869ff6146822c153ea60f0) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180692 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sw/source/uibase/lingu/olmenu.cxx b/sw/source/uibase/lingu/olmenu.cxx index acf36d89a113..b501bd45fc14 100644 --- a/sw/source/uibase/lingu/olmenu.cxx +++ b/sw/source/uibase/lingu/olmenu.cxx @@ -361,6 +361,7 @@ SwSpellPopup::SwSpellPopup( } } } + m_xPopupMenu->EnableItem(m_nAddMenuId, (nItemId - MN_DICTIONARIES_START) > 1); m_xPopupMenu->EnableItem(m_nAddId, (nItemId - MN_DICTIONARIES_START) == 1); @@ -595,9 +596,8 @@ void SwSpellPopup::InitItemCommands(const css::uno::Sequence< OUString >& aSugge m_xPopupMenu->SetItemCommand(nItemId, sCommandString); } - PopupMenu *pMenu = m_xPopupMenu->GetPopupMenu(m_nLangSelectionMenuId); m_xPopupMenu->SetItemCommand(m_nLangSelectionMenuId, u".uno:SetSelectionLanguageMenu"_ustr); - if(pMenu) + if (PopupMenu *pMenu = m_xPopupMenu->GetPopupMenu(m_nLangSelectionMenuId)) { for (const auto& item : m_aLangTable_Text) { @@ -610,9 +610,8 @@ void SwSpellPopup::InitItemCommands(const css::uno::Sequence< OUString >& aSugge pMenu->SetItemCommand(MN_SET_SELECTION_MORE, u".uno:FontDialog?Page:string=font"_ustr); } - pMenu = m_xPopupMenu->GetPopupMenu(m_nLangParaMenuId); m_xPopupMenu->SetItemCommand(m_nLangParaMenuId, u".uno:SetParagraphLanguageMenu"_ustr); - if(pMenu) + if (PopupMenu* pMenu = m_xPopupMenu->GetPopupMenu(m_nLangParaMenuId)) { for (const auto& item : m_aLangTable_Paragraph) { @@ -624,6 +623,20 @@ void SwSpellPopup::InitItemCommands(const css::uno::Sequence< OUString >& aSugge pMenu->SetItemCommand(MN_SET_PARA_RESET, u".uno:LanguageStatus?Language:string=Paragraph_RESET_LANGUAGES"_ustr); pMenu->SetItemCommand(MN_SET_PARA_MORE, u".uno:FontDialogForParagraph"_ustr); } + + OUString sCommandString = ".uno:AddToWordbook?Wordbook:string=" + m_aDicNameSingle; + m_xPopupMenu->SetItemCommand(m_nAddId, sCommandString); + m_xPopupMenu->SetItemCommand(m_nAddMenuId, sCommandString); + if (PopupMenu *pMenu = m_xPopupMenu->GetPopupMenu(m_nAddMenuId)) + { + for (sal_uInt16 i = 0, nItemCount = pMenu->GetItemCount(); i < nItemCount; ++i) + { + sal_uInt16 nItemId = pMenu->GetItemId(i); + OUString sDict = pMenu->GetItemText(nItemId); + sCommandString = ".uno:AddToWordbook?Wordbook:string=" + sDict; + pMenu->SetItemCommand(nItemId, sCommandString); + } + } } void SwSpellPopup::checkRedline() commit 05c4c0c7f98c5337744b9fe7ae4dde27dd4c8e37 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Fri Dec 20 14:26:22 2024 +0000 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Tue Feb 11 14:51:32 2025 +0000 make modcfg ConfigItems listen to the config changes. Change-Id: I9ba49ff8df463519631e698ce5916f0126c5d7b5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178934 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sw/inc/modcfg.hxx b/sw/inc/modcfg.hxx index 1c7e5cac0a78..3be2fba4903a 100644 --- a/sw/inc/modcfg.hxx +++ b/sw/inc/modcfg.hxx @@ -110,7 +110,7 @@ public: SwCompareConfig(); virtual ~SwCompareConfig() override; - virtual void Notify( const css::uno::Sequence< OUString >& ) override { }; + virtual void Notify( const css::uno::Sequence< OUString >& ) override; void Load(); using ConfigItem::SetModified; }; diff --git a/sw/source/uibase/config/modcfg.cxx b/sw/source/uibase/config/modcfg.cxx index 8fe3bca246d2..0eb74b0a0688 100644 --- a/sw/source/uibase/config/modcfg.cxx +++ b/sw/source/uibase/config/modcfg.cxx @@ -230,7 +230,7 @@ const Sequence<OUString>& SwRevisionConfig::GetPropertyNames() } SwRevisionConfig::SwRevisionConfig() - : ConfigItem(u"Office.Writer/Revision"_ustr, ConfigItemMode::ReleaseTree) + : ConfigItem(u"Office.Writer/Revision"_ustr) , m_nMarkAlign(0) { m_aInsertAttr.m_nItemId = SID_ATTR_CHAR_UNDERLINE; @@ -245,6 +245,7 @@ SwRevisionConfig::SwRevisionConfig() m_aFormatAttr.m_nAttr = WEIGHT_BOLD; m_aFormatAttr.m_nColor = COL_BLACK; Load(); + EnableNotification(GetPropertyNames()); } SwRevisionConfig::~SwRevisionConfig() @@ -277,7 +278,10 @@ static sal_Int32 lcl_ConvertAttrToCfg(const AuthorCharAttr& rAttr) return nRet; } -void SwRevisionConfig::Notify( const css::uno::Sequence< OUString >& ) {} +void SwRevisionConfig::Notify(const css::uno::Sequence<OUString>&) +{ + Load(); +} void SwRevisionConfig::ImplCommit() { @@ -561,8 +565,7 @@ const Sequence<OUString>& SwInsertConfig::GetPropertyNames() const } SwInsertConfig::SwInsertConfig(bool bWeb) : - ConfigItem(bWeb ? u"Office.WriterWeb/Insert"_ustr : u"Office.Writer/Insert"_ustr, - ConfigItemMode::ReleaseTree), + ConfigItem(bWeb ? u"Office.WriterWeb/Insert"_ustr : u"Office.Writer/Insert"_ustr), m_bInsWithCaption( false ), m_bCaptionOrderNumberingFirst( false ), m_aInsTableOpts(SwInsertTableFlags::NONE,0), @@ -577,6 +580,7 @@ SwInsertConfig::SwInsertConfig(bool bWeb) : m_pCapOptions.reset(new InsCaptionOptArr); Load(); + EnableNotification(GetPropertyNames()); } SwInsertConfig::~SwInsertConfig() @@ -602,7 +606,10 @@ static void lcl_WriteOpt(const InsCaptionOpt& rOpt, Any* pValues, sal_Int32 nPro } } -void SwInsertConfig::Notify( const css::uno::Sequence< OUString >& ) {} +void SwInsertConfig::Notify(const css::uno::Sequence<OUString>&) +{ + Load(); +} void SwInsertConfig::ImplCommit() { @@ -1083,8 +1090,7 @@ const Sequence<OUString>& SwTableConfig::GetPropertyNames() } SwTableConfig::SwTableConfig(bool bWeb) - : ConfigItem(bWeb ? u"Office.WriterWeb/Table"_ustr : u"Office.Writer/Table"_ustr, - ConfigItemMode::ReleaseTree) + : ConfigItem(bWeb ? u"Office.WriterWeb/Table"_ustr : u"Office.Writer/Table"_ustr) , m_nTableHMove(0) , m_nTableVMove(0) , m_nTableHInsert(0) @@ -1096,13 +1102,17 @@ SwTableConfig::SwTableConfig(bool bWeb) , m_bSplitVerticalByDefault(false) { Load(); + EnableNotification(GetPropertyNames()); } SwTableConfig::~SwTableConfig() { } -void SwTableConfig::Notify( const css::uno::Sequence< OUString >& ) {} +void SwTableConfig::Notify(const css::uno::Sequence<OUString>&) +{ + Load(); +} void SwTableConfig::ImplCommit() { @@ -1156,7 +1166,7 @@ void SwTableConfig::Load() } SwMiscConfig::SwMiscConfig() : - ConfigItem(u"Office.Writer"_ustr, ConfigItemMode::ReleaseTree), + ConfigItem(u"Office.Writer"_ustr), m_bDefaultFontsInCurrDocOnly(false), m_bShowIndexPreview(false), m_bGrfToGalleryAsLnk(true), @@ -1167,6 +1177,7 @@ SwMiscConfig::SwMiscConfig() : m_nMailingFormats(MailTextFormats::NONE) { Load(); + EnableNotification(GetPropertyNames()); } SwMiscConfig::~SwMiscConfig() @@ -1194,7 +1205,10 @@ const Sequence<OUString>& SwMiscConfig::GetPropertyNames() return aNames; } -void SwMiscConfig::Notify( const css::uno::Sequence< OUString >& ) {} +void SwMiscConfig::Notify(const css::uno::Sequence<OUString>&) +{ + EnableNotification(GetPropertyNames()); +} void SwMiscConfig::ImplCommit() { @@ -1273,9 +1287,9 @@ const Sequence<OUString>& SwCompareConfig::GetPropertyNames() return aNames; } -SwCompareConfig::SwCompareConfig() : - ConfigItem(u"Office.Writer/Comparison"_ustr, ConfigItemMode::ReleaseTree) - ,m_bStoreRsid(true) +SwCompareConfig::SwCompareConfig() + : ConfigItem(u"Office.Writer/Comparison"_ustr) + , m_bStoreRsid(true) { m_eCmpMode = SwCompareMode::Auto; m_bUseRsid = false; @@ -1283,6 +1297,7 @@ SwCompareConfig::SwCompareConfig() : m_nPieceLen = 1; Load(); + EnableNotification(GetPropertyNames()); } SwCompareConfig::~SwCompareConfig() @@ -1329,4 +1344,9 @@ void SwCompareConfig::Load() } } +void SwCompareConfig::Notify(const css::uno::Sequence<OUString>&) +{ + Load(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit ee824fdc6eccbedb49575f65eda720ac5a8f74d8 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Fri Dec 20 13:59:24 2024 +0000 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Tue Feb 11 14:51:32 2025 +0000 make SwWebColorConfig ConfigItem listen to the config changes. Change-Id: I5190155eb0edb4639b09983cc58101a5a8c82f31 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178929 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sw/source/uibase/config/usrpref.cxx b/sw/source/uibase/config/usrpref.cxx index 5ab5d91e2b5b..7f79d17306f7 100644 --- a/sw/source/uibase/config/usrpref.cxx +++ b/sw/source/uibase/config/usrpref.cxx @@ -82,8 +82,6 @@ SwMasterUsrPref::SwMasterUsrPref(bool bWeb) : return; } - if(m_pWebColorConfig) - m_pWebColorConfig->Load(); m_aFmtAidsAutoComplConfig.Load(); } @@ -704,12 +702,14 @@ void SwFmtAidsAutoComplConfig::Load() void SwFmtAidsAutoComplConfig::Notify(const css::uno::Sequence<OUString>&) {} -SwWebColorConfig::SwWebColorConfig(SwMasterUsrPref& rPar) : - ConfigItem(u"Office.WriterWeb/Background"_ustr, ConfigItemMode::ReleaseTree), - m_rParent(rPar), - m_aPropNames(1) +SwWebColorConfig::SwWebColorConfig(SwMasterUsrPref& rPar) + : ConfigItem(u"Office.WriterWeb/Background"_ustr) + , m_rParent(rPar) + , m_aPropNames(1) { m_aPropNames.getArray()[0] = "Color"; + Load(); + EnableNotification(m_aPropNames); } SwWebColorConfig::~SwWebColorConfig() @@ -730,7 +730,10 @@ void SwWebColorConfig::ImplCommit() PutProperties(m_aPropNames, aValues); } -void SwWebColorConfig::Notify( const css::uno::Sequence< OUString >& ) {} +void SwWebColorConfig::Notify(const css::uno::Sequence<OUString>&) +{ + Load(); +} void SwWebColorConfig::Load() { commit ef81159ad25a4f8c41acf2f0b0d3dc8eecf0510c Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Fri Dec 20 13:49:43 2024 +0000 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Tue Feb 11 14:51:32 2025 +0000 make SwLayoutViewConfig ConfigItem listen to the config changes. Change-Id: Id86edc48c304d2ab35a5cb01a20d9dac20e04280 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178925 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sw/source/uibase/config/usrpref.cxx b/sw/source/uibase/config/usrpref.cxx index a32b82dfc4af..5ab5d91e2b5b 100644 --- a/sw/source/uibase/config/usrpref.cxx +++ b/sw/source/uibase/config/usrpref.cxx @@ -82,7 +82,6 @@ SwMasterUsrPref::SwMasterUsrPref(bool bWeb) : return; } - m_aLayoutConfig.Load(); if(m_pWebColorConfig) m_pWebColorConfig->Load(); m_aFmtAidsAutoComplConfig.Load(); @@ -342,11 +341,12 @@ Sequence<OUString> SwLayoutViewConfig::GetPropertyNames() const } SwLayoutViewConfig::SwLayoutViewConfig(bool bIsWeb, SwMasterUsrPref& rPar) : - ConfigItem(bIsWeb ? u"Office.WriterWeb/Layout"_ustr : u"Office.Writer/Layout"_ustr, - ConfigItemMode::ReleaseTree), + ConfigItem(bIsWeb ? u"Office.WriterWeb/Layout"_ustr : u"Office.Writer/Layout"_ustr), m_rParent(rPar), m_bWeb(bIsWeb) { + Load(); + EnableNotification(GetPropertyNames()); } SwLayoutViewConfig::~SwLayoutViewConfig() @@ -453,7 +453,10 @@ void SwLayoutViewConfig::Load() } } -void SwLayoutViewConfig::Notify( const css::uno::Sequence< OUString >& ) {} +void SwLayoutViewConfig::Notify(const css::uno::Sequence<OUString>&) +{ + Load(); +} Sequence<OUString> SwGridConfig::GetPropertyNames() { commit 54b1845e02ae1f1197532bc14e591b36b5bbf9bb Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Fri Dec 20 13:44:17 2024 +0000 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Tue Feb 11 14:51:31 2025 +0000 make SwCursorConfig ConfigItem listen to the config changes. Change-Id: Ia653759378913758f0b2750c9d072b76523fa034 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178924 Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> Tested-by: Jenkins diff --git a/sw/source/uibase/config/usrpref.cxx b/sw/source/uibase/config/usrpref.cxx index 212b7fa02832..a32b82dfc4af 100644 --- a/sw/source/uibase/config/usrpref.cxx +++ b/sw/source/uibase/config/usrpref.cxx @@ -83,7 +83,6 @@ SwMasterUsrPref::SwMasterUsrPref(bool bWeb) : } m_aLayoutConfig.Load(); - m_aCursorConfig.Load(); if(m_pWebColorConfig) m_pWebColorConfig->Load(); m_aFmtAidsAutoComplConfig.Load(); @@ -567,10 +566,12 @@ Sequence<OUString> SwCursorConfig::GetPropertyNames() return aNames; } -SwCursorConfig::SwCursorConfig(SwMasterUsrPref& rPar) : - ConfigItem(u"Office.Writer/Cursor"_ustr, ConfigItemMode::ReleaseTree), - m_rParent(rPar) +SwCursorConfig::SwCursorConfig(SwMasterUsrPref& rPar) + : ConfigItem(u"Office.Writer/Cursor"_ustr) + , m_rParent(rPar) { + Load(); + EnableNotification(GetPropertyNames()); } SwCursorConfig::~SwCursorConfig() @@ -626,7 +627,10 @@ void SwCursorConfig::Load() } } -void SwCursorConfig::Notify( const css::uno::Sequence< OUString >& ) {} +void SwCursorConfig::Notify(const css::uno::Sequence<OUString>& ) +{ + Load(); +} Sequence<OUString> SwFmtAidsAutoComplConfig::GetPropertyNames() { commit 032af0fda82296ddbfd2326402300bf5e080a660 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Fri Dec 20 12:46:36 2024 +0000 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Tue Feb 11 14:51:31 2025 +0000 add uno:AddToWordbook for adding word to user dictionary Change-Id: I1c679f62f554bfa112c505a545ceb8b5e31ef453 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178921 Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> Tested-by: Jenkins diff --git a/include/svx/svxids.hrc b/include/svx/svxids.hrc index ebfc2d1582cf..cf2b984ca936 100644 --- a/include/svx/svxids.hrc +++ b/include/svx/svxids.hrc @@ -460,7 +460,7 @@ class XFillGradientItem; #define SID_ATTR_TEXTCOLUMNS_SPACING ( SID_SVX_START + 341 ) #define SID_SET_SMALL_CAPS ( SID_SVX_START + 342 ) -// FREE ( SID_SVX_START + 343 ) +#define SID_ADD_TO_WORDBOOK ( SID_SVX_START + 343 ) // FREE ( SID_SVX_START + 344 ) // FREE ( SID_SVX_START + 345 ) diff --git a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu index 9ee22b041fc4..0ec0712557da 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu @@ -7212,6 +7212,11 @@ bit 3 (0x8): #define UICOMMANDDESCRIPTION_PROPERTIES_TOGGLEBUTTON 8 <value xml:lang="en-US">Language for All Text</value> </prop> </node> + <node oor:name=".uno:AddToWordbook" oor:op="replace"> + <prop oor:name="Label" oor:type="xs:string"> + <value xml:lang="en-US">Add To Dictionary</value> + </prop> + </node> <node oor:name=".uno:MoreDictionaries" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> <value xml:lang="en-US">More Dictionaries Online...</value> diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi index e62ad2ef9655..449cd55d36d9 100644 --- a/svx/sdi/svx.sdi +++ b/svx/sdi/svx.sdi @@ -12586,6 +12586,23 @@ SfxVoidItem SpellCheckIgnoreAll SID_SPELLCHECK_IGNORE_ALL GroupId = SfxGroupId::Format; ] +SfxVoidItem AddToWordbook SID_ADD_TO_WORDBOOK +(SfxStringItem Wordbook FN_PARAM_1) +[ + AutoUpdate = FALSE, + FastCall = TRUE, + ReadOnlyDoc = FALSE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + + AccelConfig = FALSE, + MenuConfig = FALSE, + ToolBoxConfig = FALSE, + GroupId = SfxGroupId::Format; +] + SfxVoidItem SpellCheckApplySuggestion SID_SPELLCHECK_APPLY_SUGGESTION (SfxStringItem ApplyRule FN_PARAM_1) [ diff --git a/sw/sdi/_textsh.sdi b/sw/sdi/_textsh.sdi index b0dd57ed8b3a..612f3d1955a9 100644 --- a/sw/sdi/_textsh.sdi +++ b/sw/sdi/_textsh.sdi @@ -1915,6 +1915,12 @@ interface BaseText StateMethod = GetState ; ] + SID_ADD_TO_WORDBOOK + [ + ExecMethod = Execute ; + StateMethod = GetState ; + ] + SID_SPELLCHECK_APPLY_SUGGESTION [ ExecMethod = Execute ; diff --git a/sw/source/uibase/lingu/olmenu.cxx b/sw/source/uibase/lingu/olmenu.cxx index e2a992e841c7..acf36d89a113 100644 --- a/sw/source/uibase/lingu/olmenu.cxx +++ b/sw/source/uibase/lingu/olmenu.cxx @@ -771,9 +771,7 @@ void SwSpellPopup::Execute( sal_uInt16 nId ) } else if ((MN_DICTIONARIES_START <= nId && nId <= MN_DICTIONARIES_END) || nId == m_nAddId) { - OUString sWord( m_xSpellAlt->getWord() ); OUString aDicName; - if (MN_DICTIONARIES_START <= nId && nId <= MN_DICTIONARIES_END) { PopupMenu *pMenu = m_xPopupMenu->GetPopupMenu(m_nAddMenuId); @@ -782,24 +780,8 @@ void SwSpellPopup::Execute( sal_uInt16 nId ) else aDicName = m_aDicNameSingle; - uno::Reference< linguistic2::XDictionary > xDic; - uno::Reference< linguistic2::XSearchableDictionaryList > xDicList( LinguMgr::GetDictionaryList() ); - if (xDicList.is()) - xDic = xDicList->getDictionaryByName( aDicName ); - - if (xDic.is()) - { - linguistic::DictionaryError nAddRes = linguistic::AddEntryToDic(xDic, sWord, false, OUString()); - // save modified user-dictionary if it is persistent - uno::Reference< frame::XStorable > xSavDic( xDic, uno::UNO_QUERY ); - if (xSavDic.is()) - xSavDic->store(); - - if (linguistic::DictionaryError::NONE != nAddRes && !xDic->getEntry(sWord).is()) - { - SvxDicError(m_pSh->GetView().GetFrameWeld(), nAddRes); - } - } + SfxStringItem aDictString(FN_PARAM_1, aDicName); + m_pSh->GetView().GetViewFrame().GetDispatcher()->ExecuteList(SID_ADD_TO_WORDBOOK, SfxCallMode::SYNCHRON, { &aDictString }); } else if ( nId == MN_EXPLANATION_LINK && !m_sExplanationLink.isEmpty() ) { diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx index 87865564da1b..01eb735e2aa3 100644 --- a/sw/source/uibase/shells/textsh1.cxx +++ b/sw/source/uibase/shells/textsh1.cxx @@ -22,6 +22,8 @@ #include <config_features.h> #include <com/sun/star/i18n/WordType.hpp> +#include <com/sun/star/frame/XStorable.hpp> +#include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp> #include <com/sun/star/linguistic2/XThesaurus.hpp> #include <com/sun/star/text/XContentControlsSupplier.hpp> @@ -924,6 +926,26 @@ bool lcl_DeleteChartColumns(const uno::Reference<chart2::XChartDocument>& xChart } } +static bool AddWordToWordbook(const uno::Reference<linguistic2::XDictionary>& xDictionary, SwWrtShell &rWrtSh) +{ + if (!xDictionary) + return false; + + SwRect aToFill; + uno::Reference<linguistic2::XSpellAlternatives> xSpellAlt(rWrtSh.GetCorrection(nullptr, aToFill)); + if (!xSpellAlt.is()) + return false; + + OUString sWord = xSpellAlt->getWord(); + linguistic::DictionaryError nAddRes = linguistic::AddEntryToDic(xDictionary, sWord, false, OUString()); + if (linguistic::DictionaryError::NONE != nAddRes && xDictionary.is() && !xDictionary->getEntry(sWord).is()) + { + SvxDicError(rWrtSh.GetView().GetFrameWeld(), nAddRes); + return false; + } + return true; +} + void SwTextShell::Execute(SfxRequest &rReq) { bool bUseDialog = true; @@ -2316,19 +2338,26 @@ void SwTextShell::Execute(SfxRequest &rReq) } else if (sApplyText == "Spelling") { - SwRect aToFill; - uno::Reference<linguistic2::XSpellAlternatives> xSpellAlt(rWrtSh.GetCorrection(nullptr, aToFill)); - if (!xSpellAlt.is()) - return; - uno::Reference< linguistic2::XDictionary > xDictionary = LinguMgr::GetIgnoreAllList(); - OUString sWord(xSpellAlt->getWord()); - linguistic::DictionaryError nAddRes = linguistic::AddEntryToDic( xDictionary, - sWord, false, OUString() ); - if (linguistic::DictionaryError::NONE != nAddRes && xDictionary.is() && !xDictionary->getEntry(sWord).is()) - { - SvxDicError(rWrtSh.GetView().GetFrameWeld(), nAddRes); - } + AddWordToWordbook(LinguMgr::GetIgnoreAllList(), rWrtSh); + } + } + break; + case SID_ADD_TO_WORDBOOK: + { + OUString aDicName; + if (const SfxStringItem* pItem1 = rReq.GetArg<SfxStringItem>(FN_PARAM_1)) + aDicName = pItem1->GetValue(); + + uno::Reference<linguistic2::XSearchableDictionaryList> xDicList(LinguMgr::GetDictionaryList()); + uno::Reference<linguistic2::XDictionary> xDic = xDicList.is() ? xDicList->getDictionaryByName(aDicName) : nullptr; + if (AddWordToWordbook(xDic, rWrtSh)) + { + // save modified user-dictionary if it is persistent + uno::Reference<frame::XStorable> xSavDic(xDic, uno::UNO_QUERY); + if (xSavDic.is()) + xSavDic->store(); } + break; } break; case SID_SPELLCHECK_APPLY_SUGGESTION: commit 3e2d265a1c501605dee2a8108b1ca0e9e47b920c Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Thu Dec 12 21:09:15 2024 +0000 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Tue Feb 11 14:51:31 2025 +0000 enable spotlight subset in kit mode Use the index of the style within the list of writer's instantiated styles as the indicator number to use, so this is stable regardless of what particular mode the style dialog/panel is using. Unused styles don't get a number indicator, but do have a (stable) color until they are used in the document. For kit, Para/Char style mode renders all styles, not just the subset selected in the style dialog/panel, when Para/Char spotlight is enabled. Change-Id: I513e4a676a7c4f7f542c016afa5a79d158778210 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178481 Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Michael Meeks <michael.me...@collabora.com> (cherry picked from commit e5eec842b0c61c9c91a8f836661d6885c9c236a8) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180768 Tested-by: Jenkins diff --git a/include/sfx2/StylePreviewRenderer.hxx b/include/sfx2/StylePreviewRenderer.hxx index 1692182bd113..33ed26c793e7 100644 --- a/include/sfx2/StylePreviewRenderer.hxx +++ b/include/sfx2/StylePreviewRenderer.hxx @@ -52,6 +52,8 @@ public: } // end namespace sfx2 +SFX2_DLLPUBLIC Color ColorHash(std::u16string_view rString); + #endif // INCLUDED_SVX_STYLEPREVIEWRENDERER_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/style.hxx b/include/svl/style.hxx index 1882a1a2f5e8..216aef4a1ad7 100644 --- a/include/svl/style.hxx +++ b/include/svl/style.hxx @@ -173,6 +173,9 @@ public: virtual sal_uInt32 GetHelpId( OUString& rFile ); virtual void SetHelpId( const OUString& r, sal_uInt32 nId ); + // Spotlight Id, @return -1 for style not in use + virtual sal_Int32 GetSpotlightId(); + virtual SfxItemSet& GetItemSet(); /// Due to writer's usual lack of sanity this is a separate function for /// preview only; it shall not create the style in case it does not exist. diff --git a/sfx2/source/dialog/StyleList.cxx b/sfx2/source/dialog/StyleList.cxx index 82bb545f668b..3c8b78f862d1 100644 --- a/sfx2/source/dialog/StyleList.cxx +++ b/sfx2/source/dialog/StyleList.cxx @@ -34,6 +34,7 @@ #include <svl/intitem.hxx> #include <svl/style.hxx> #include <svl/itemset.hxx> +#include <comphelper/lok.hxx> #include <comphelper/processfactory.hxx> #include <officecfg/Office/Common.hxx> @@ -95,8 +96,6 @@ public: } }; -namespace -{ Color ColorHash(std::u16string_view rString) { static constexpr auto aSaturationArray = std::to_array<sal_uInt16>({ 90, 75, 60 }); @@ -129,6 +128,8 @@ Color ColorHash(std::u16string_view rString) return aColor; } +namespace +{ // used to disallow the default character style in the styles highlighter character styles color map std::optional<OUString> sDefaultCharStyleUIName; } @@ -630,20 +631,23 @@ class StyleTree_Impl private: OUString aName; OUString aParent; + sal_Int32 nSpotlightId; StyleTreeArr_Impl pChildren; public: bool HasParent() const { return !aParent.isEmpty(); } - StyleTree_Impl(OUString _aName, OUString _aParent) + StyleTree_Impl(OUString _aName, OUString _aParent, sal_Int32 _nSpotlightId) : aName(std::move(_aName)) , aParent(std::move(_aParent)) + , nSpotlightId(_nSpotlightId) , pChildren(0) { } const OUString& getName() const { return aName; } const OUString& getParent() const { return aParent; } + sal_Int32 getSpotlightId() const { return nSpotlightId; } StyleTreeArr_Impl& getChildren() { return pChildren; } }; } @@ -707,25 +711,30 @@ static bool IsExpanded_Impl(const std::vector<OUString>& rEntries, std::u16strin return false; } -static void lcl_Update(weld::TreeView& rTreeView, weld::TreeIter& rIter, const OUString& rName, - SfxStyleFamily eFam, SfxViewShell* pViewSh) +static void lcl_Update(weld::TreeView& rTreeView, weld::TreeIter& rIter, + const StyleTree_Impl& rEntry, SfxStyleFamily eFam, SfxViewShell* pViewSh) { + const OUString& rName = rEntry.getName(); + Color aColor = ColorHash(rName); - int nColor; - if (eFam == SfxStyleFamily::Para) + // For kit keep the id used for spotlight/number-image for a style stable + // regardless of the selection mode of the style panel, so multiple views + // on a document all share the same id for a style. + sal_Int32 nSpotlightId; + if (comphelper::LibreOfficeKit::isActive()) + nSpotlightId = rEntry.getSpotlightId(); + else { - StylesHighlighterColorMap& rParaStylesColorMap - = pViewSh->GetStylesHighlighterParaColorMap(); - nColor = rParaStylesColorMap.size(); - rParaStylesColorMap[rName] = std::pair(aColor, nColor); + StylesHighlighterColorMap& rColorMap = (eFam == SfxStyleFamily::Para) + ? pViewSh->GetStylesHighlighterParaColorMap() + : pViewSh->GetStylesHighlighterCharColorMap(); + nSpotlightId = rColorMap.size(); + rColorMap[rName] = std::pair(aColor, nSpotlightId); } - else + + if (eFam == SfxStyleFamily::Char) { - StylesHighlighterColorMap& rCharStylesColorMap - = pViewSh->GetStylesHighlighterCharColorMap(); - nColor = rCharStylesColorMap.size(); - rCharStylesColorMap[rName] = std::pair(aColor, nColor); // don't show a color or number for default character style 'No Character Style' entry if (rName == sDefaultCharStyleUIName.value() /*"No Character Style"*/) { @@ -743,9 +752,13 @@ static void lcl_Update(weld::TreeView& rTreeView, weld::TreeIter& rIter, const O xDevice->SetFillColor(aColor); const tools::Rectangle aRect(Point(0, 0), aImageSize); xDevice->DrawRect(aRect); - xDevice->SetTextColor(COL_BLACK); - xDevice->DrawText(aRect, OUString::number(nColor), - DrawTextFlags::Center | DrawTextFlags::VCenter); + // In kit mode, unused styles are -1, so we can just skip the number image for those + if (nSpotlightId != -1) + { + xDevice->SetTextColor(COL_BLACK); + xDevice->DrawText(aRect, OUString::number(nSpotlightId), + DrawTextFlags::Center | DrawTextFlags::VCenter); + } rTreeView.set_id(rIter, rName); rTreeView.set_text(rIter, rName); @@ -770,7 +783,7 @@ static void FillBox_Impl(weld::TreeView& rBox, StyleTreeArr_Impl& rTreeArray, if (pStyleSheetPool) pStyle = pStyleSheetPool->Find(rChildName, eStyleFamily); if (pStyle && pStyle->IsUsed()) - lcl_Update(rBox, rIter, rChildName, eStyleFamily, + lcl_Update(rBox, rIter, *pChildEntry, eStyleFamily, pViewShell); else { @@ -1075,7 +1088,8 @@ void StyleList::FillTreeBox(SfxStyleFamily eFam) ; else { - StyleTree_Impl* pNew = new StyleTree_Impl(pStyle->GetName(), pStyle->GetParent()); + StyleTree_Impl* pNew = new StyleTree_Impl(pStyle->GetName(), pStyle->GetParent(), + pStyle->GetSpotlightId()); aArr.emplace_back(pNew); } pStyle = m_pStyleSheetPool->Next(); @@ -1255,7 +1269,7 @@ void StyleList::UpdateStyles(StyleFlags nFlags) SfxStyleSheetBase* pStyle = m_pStyleSheetPool->First(eFam, nFilter); std::unique_ptr<weld::TreeIter> xEntry = m_xFmtLb->make_iterator(); - std::vector<OUString> aStrings; + std::vector<StyleTree_Impl> aStyles; comphelper::string::NaturalStringSorter aSorter( ::comphelper::getProcessComponentContext(), @@ -1263,7 +1277,7 @@ void StyleList::UpdateStyles(StyleFlags nFlags) while (pStyle) { - aStrings.push_back(pStyle->GetName()); + aStyles.emplace_back(pStyle->GetName(), pStyle->GetParent(), pStyle->GetSpotlightId()); pStyle = m_pStyleSheetPool->Next(); } OUString aUIName = getDefaultStyleName(eFam); @@ -1272,9 +1286,14 @@ void StyleList::UpdateStyles(StyleFlags nFlags) // sorting twice is faster than sorting once. // The first sort has a cheap comparator, and gets the list into mostly-sorted order. // Then the second sort needs to call its (much more expensive) comparator less often. - std::sort(aStrings.begin(), aStrings.end()); - std::sort(aStrings.begin(), aStrings.end(), - [&aSorter, &aUIName](const OUString& rLHS, const OUString& rRHS) { + std::sort(aStyles.begin(), aStyles.end(), + [](const StyleTree_Impl& rLHS, const StyleTree_Impl& rRHS) { + return rLHS.getName() < rRHS.getName(); + }); + std::sort(aStyles.begin(), aStyles.end(), + [&aSorter, &aUIName](const StyleTree_Impl& rLHSS, const StyleTree_Impl& rRHSS) { + const OUString& rLHS = rLHSS.getName(); + const OUString& rRHS = rRHSS.getName(); if (rRHS == aUIName) return false; if (rLHS == aUIName) @@ -1303,7 +1322,7 @@ void StyleList::UpdateStyles(StyleFlags nFlags) pHighlighterColorMap->clear(); } - size_t nCount = aStrings.size(); + size_t nCount = aStyles.size(); if (pViewShell && m_bModuleHasStylesHighlighterFeature && ((eFam == SfxStyleFamily::Para && m_bHighlightParaStyles) @@ -1311,14 +1330,15 @@ void StyleList::UpdateStyles(StyleFlags nFlags) { m_xFmtLb->bulk_insert_for_each( nCount, - [this, &aStrings, eFam, pViewShell](weld::TreeIter& rIter, int nIdx) { - auto pChildStyle = m_pStyleSheetPool->Find(aStrings[nIdx], eFam); + [this, &aStyles, eFam, pViewShell](weld::TreeIter& rIter, int nIdx) { + const OUString& rName = aStyles[nIdx].getName(); + auto pChildStyle = m_pStyleSheetPool->Find(rName, eFam); if (pChildStyle && pChildStyle->IsUsed()) - lcl_Update(*m_xFmtLb, rIter, aStrings[nIdx], eFam, pViewShell); + lcl_Update(*m_xFmtLb, rIter, aStyles[nIdx], eFam, pViewShell); else { - m_xFmtLb->set_id(rIter, aStrings[nIdx]); - m_xFmtLb->set_text(rIter, aStrings[nIdx]); + m_xFmtLb->set_id(rIter, rName); + m_xFmtLb->set_text(rIter, rName); } }, nullptr, nullptr, /*bGoingToSetText*/ true); @@ -1326,9 +1346,10 @@ void StyleList::UpdateStyles(StyleFlags nFlags) else { m_xFmtLb->bulk_insert_for_each(nCount, - [this, &aStrings](weld::TreeIter& rIter, int nIdx) { - m_xFmtLb->set_id(rIter, aStrings[nIdx]); - m_xFmtLb->set_text(rIter, aStrings[nIdx]); + [this, &aStyles](weld::TreeIter& rIter, int nIdx) { + const OUString& rName = aStyles[nIdx].getName(); + m_xFmtLb->set_id(rIter, rName); + m_xFmtLb->set_text(rIter, rName); }, nullptr, nullptr, /*bGoingToSetText*/ true); } diff --git a/svl/source/items/style.cxx b/svl/source/items/style.cxx index 54b9e227ebce..a5144962632e 100644 --- a/svl/source/items/style.cxx +++ b/svl/source/items/style.cxx @@ -284,6 +284,11 @@ void SfxStyleSheetBase::SetHelpId( const OUString& rFile, sal_uInt32 nId ) nHelpId = nId; } +sal_Int32 SfxStyleSheetBase::GetSpotlightId() +{ + return -1; +} + /** * Next style possible? * Default: Yes diff --git a/sw/inc/docstyle.hxx b/sw/inc/docstyle.hxx index e45c599d2a0b..f5a7a70a350f 100644 --- a/sw/inc/docstyle.hxx +++ b/sw/inc/docstyle.hxx @@ -113,6 +113,8 @@ public: virtual sal_uInt32 GetHelpId( OUString& rFile ) override; virtual void SetHelpId( const OUString& r, sal_uInt32 nId ) override; + virtual sal_Int32 GetSpotlightId() override; + /** Preset the members without physical access. Used by StyleSheetPool. */ void PresetName(const OUString& rName) { aName = rName; } diff --git a/sw/inc/view.hxx b/sw/inc/view.hxx index 3eba3163d333..4429382416a4 100644 --- a/sw/inc/view.hxx +++ b/sw/inc/view.hxx @@ -726,7 +726,9 @@ public: virtual void flushPendingLOKInvalidateTiles() override; virtual std::optional<OString> getLOKPayload(int nType, int nViewId) const override; - bool IsHighlightCharDF() { return m_bIsHighlightCharDF; } + bool IsHighlightCharDF() const { return m_bIsHighlightCharDF; } + bool IsSpotlightParaStyles() const { return m_bIsSpotlightParaStyles; } + bool IsSpotlightCharStyles() const { return m_bIsSpotlightCharStyles; } private: AutoTimer m_aBringToAttentionBlinkTimer; diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index a24963e7afca..46b09f5b6b2b 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -23,6 +23,7 @@ #include <sfx2/docfile.hxx> #include <sfx2/printer.hxx> #include <sfx2/progress.hxx> +#include <sfx2/StylePreviewRenderer.hxx> #include <editeng/brushitem.hxx> #include <editeng/prntitem.hxx> #include <editeng/boxitem.hxx> @@ -4536,19 +4537,43 @@ void SwTextFrame::PaintParagraphStylesHighlighting() const if (!pWrtSh) return; + if (!pWrtSh->GetView().IsSpotlightParaStyles()) + return; + vcl::RenderContext* pRenderContext = pWrtSh->GetOut(); if (!pRenderContext) return; - StylesHighlighterColorMap& rParaStylesColorMap - = pWrtSh->GetView().GetStylesHighlighterParaColorMap(); + const SwTextFormatColl* pColl = GetTextNodeFirst()->GetTextColl(); + OUString sStyleName = pColl->GetName(); - if (rParaStylesColorMap.empty()) - return; + Color nStyleColor; + int nStyleNumber(-1); + + bool bSpotlightStyle; + if (comphelper::LibreOfficeKit::isActive()) + { + // For simplicity in kit mode, we render in the document "all styles" + bSpotlightStyle = true; + // Do this so these are stable across views regardless of an individual + // user's selection mode in the style panel. + nStyleNumber = pWrtSh->GetDoc()->GetTextFormatColls()->GetPos(pColl); + nStyleColor = ColorHash(sStyleName); + } + else + { + StylesHighlighterColorMap& rParaStylesColorMap + = pWrtSh->GetView().GetStylesHighlighterParaColorMap(); + bSpotlightStyle = rParaStylesColorMap.contains(sStyleName); + if (bSpotlightStyle) + { + nStyleNumber = rParaStylesColorMap[sStyleName].second; + nStyleColor = rParaStylesColorMap[sStyleName].first; + } + } // draw styles highlighter - OUString sStyleName = GetTextNodeFirst()->GetTextColl()->GetName(); - if (rParaStylesColorMap.contains(sStyleName)) + if (bSpotlightStyle) { SwRect aFrameAreaRect(getFrameArea()); @@ -4576,9 +4601,6 @@ void SwTextFrame::PaintParagraphStylesHighlighting() const pRenderContext->Push(vcl::PushFlags::ALL); - Color nStyleColor = rParaStylesColorMap[sStyleName].first; - int nStyleNumber = rParaStylesColorMap[sStyleName].second; - pRenderContext->SetFillColor(nStyleColor); pRenderContext->SetLineColor(nStyleColor); diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx index 1583881c7736..a00a9d563d7c 100644 --- a/sw/source/core/text/inftxt.cxx +++ b/sw/source/core/text/inftxt.cxx @@ -19,6 +19,7 @@ #include <com/sun/star/linguistic2/XHyphenator.hpp> +#include <comphelper/lok.hxx> #include <unotools/linguprops.hxx> #include <unotools/lingucfg.hxx> #include <fmtinfmt.hxx> @@ -27,6 +28,7 @@ #include <svl/ctloptions.hxx> #include <sfx2/infobar.hxx> #include <sfx2/printer.hxx> +#include <sfx2/StylePreviewRenderer.hxx> #include <sal/log.hxx> #include <editeng/hyphenzoneitem.hxx> #include <editeng/hngpnctitem.hxx> @@ -1323,9 +1325,7 @@ void SwTextPaintInfo::DrawCSDFHighlighting(const SwLinePortion &rPor) const if (!pView) return; - StylesHighlighterColorMap& rCharStylesColorMap = pView->GetStylesHighlighterCharColorMap(); - - if (rCharStylesColorMap.empty() && !pView->IsHighlightCharDF()) + if (!pView->IsSpotlightCharStyles() && !pView->IsHighlightCharDF()) return; SwRect aRect; @@ -1352,17 +1352,30 @@ void SwTextPaintInfo::DrawCSDFHighlighting(const SwLinePortion &rPor) const // check for CS formatting, if not CS formatted check for direct character formatting if (!sCurrentCharStyle.isEmpty()) { - if (!rCharStylesColorMap.empty()) + OUString sCharStyleDisplayName = SwStyleNameMapper::GetUIName(sCurrentCharStyle, + SwGetPoolIdFromName::ChrFmt); + if (comphelper::LibreOfficeKit::isActive()) + { + // For simplicity in kit mode, we render in the document "all styles" that exist + if (const SwCharFormat* pCharFormat = pFrame->GetDoc().FindCharFormatByName(sCharStyleDisplayName)) + { + // Do this so these are stable across views regardless of an individual + // user's selection mode in the style panel. + sCSNumberOrDF = OUString::number(pFrame->GetDoc().GetCharFormats()->GetPos(pCharFormat)); + aFillColor = ColorHash(sCharStyleDisplayName); + } + } + else { - OUString sCharStyleDisplayName; - sCharStyleDisplayName = SwStyleNameMapper::GetUIName(sCurrentCharStyle, - SwGetPoolIdFromName::ChrFmt); - if (!sCharStyleDisplayName.isEmpty() - && rCharStylesColorMap.find(sCharStyleDisplayName) - != rCharStylesColorMap.end()) + if (!sCharStyleDisplayName.isEmpty()) { - aFillColor = rCharStylesColorMap[sCharStyleDisplayName].first; - sCSNumberOrDF = OUString::number(rCharStylesColorMap[sCharStyleDisplayName].second); + StylesHighlighterColorMap& rCharStylesColorMap = pView->GetStylesHighlighterCharColorMap(); + auto it = rCharStylesColorMap.find(sCharStyleDisplayName); + if (it != rCharStylesColorMap.end()) + { + sCSNumberOrDF = OUString::number(it->second.second); + aFillColor = it->second.first; + } } } } diff --git a/sw/source/uibase/app/docstyle.cxx b/sw/source/uibase/app/docstyle.cxx index 31e7b14ab127..ca81fb5b740a 100644 --- a/sw/source/uibase/app/docstyle.cxx +++ b/sw/source/uibase/app/docstyle.cxx @@ -2620,6 +2620,25 @@ void SwDocStyleSheet::SetHelpId( const OUString& r, sal_uInt32 nId ) } } +sal_Int32 SwDocStyleSheet::GetSpotlightId() +{ + if (nFamily == SfxStyleFamily::Para) + { + SwTextFormatColl* pColl = m_pColl ? + m_pColl : m_rDoc.FindTextFormatCollByName(aName); + return pColl ? m_rDoc.GetTextFormatColls()->GetPos(pColl) : -1; + } + + if (nFamily == SfxStyleFamily::Char) + { + SwCharFormat* pCharFormat = m_pCharFormat + ? m_pCharFormat : m_rDoc.FindCharFormatByName(aName); + return pCharFormat ? m_rDoc.GetCharFormats()->GetPos(pCharFormat) : -1; + } + + return SfxStyleSheetBase::GetSpotlightId(); +} + // methods for DocStyleSheetPool SwDocStyleSheetPool::SwDocStyleSheetPool( SwDoc& rDocument, bool bOrg ) : SfxStyleSheetBasePool(rDocument.GetAttrPool()) diff --git a/sw/source/uibase/docvw/edtwin2.cxx b/sw/source/uibase/docvw/edtwin2.cxx index 11b3b3d4d9d1..2d98854ee4a3 100644 --- a/sw/source/uibase/docvw/edtwin2.cxx +++ b/sw/source/uibase/docvw/edtwin2.cxx @@ -102,8 +102,8 @@ bool PSCSDFPropsQuickHelp(const HelpEvent &rEvt, SwWrtShell& rSh) OUString sText; SwView& rView = rSh.GetView(); - if (rView.IsHighlightCharDF() || rView.GetStylesHighlighterParaColorMap().size() - || rView.GetStylesHighlighterCharColorMap().size()) + if (rView.IsHighlightCharDF() || rView.IsSpotlightParaStyles() + || rView.IsSpotlightCharStyles()) { SwPosition aPos(rSh.GetDoc()->GetNodes()); Point aPt(rSh.GetWin()->PixelToLogic( @@ -138,7 +138,7 @@ bool PSCSDFPropsQuickHelp(const HelpEvent &rEvt, SwWrtShell& rSh) if (bContainsPt) { - if (rView.GetStylesHighlighterCharColorMap().size()) + if (rView.IsSpotlightCharStyles()) { // check if in CS formatting highlighted area OUString sCharStyle; @@ -196,7 +196,7 @@ bool PSCSDFPropsQuickHelp(const HelpEvent &rEvt, SwWrtShell& rSh) } } } - else if (rView.GetStylesHighlighterParaColorMap().size()) + else if (rView.IsSpotlightParaStyles()) { // check if in paragraph style formatting highlighted area pContentFrame = aPos.GetContentNode()->GetTextNode()->getLayoutFrame( diff --git a/sw/source/uibase/uiview/view0.cxx b/sw/source/uibase/uiview/view0.cxx index e4e89e76c1eb..0a9ad80195b6 100644 --- a/sw/source/uibase/uiview/view0.cxx +++ b/sw/source/uibase/uiview/view0.cxx @@ -29,6 +29,7 @@ #include <viewopt.hxx> #include <globals.h> #include <sfx2/infobar.hxx> +#include <sfx2/lokhelper.hxx> #include <sfx2/request.hxx> #include <svl/whiter.hxx> #include <svx/srchdlg.hxx> @@ -37,9 +38,12 @@ #include <sfx2/dispatch.hxx> #include <sfx2/sidebar/SidebarChildWindow.hxx> #include <uivwimp.hxx> +#include <unotxdoc.hxx> #include <avmedia/mediaplayer.hxx> #include <swmodule.hxx> #include <com/sun/star/linguistic2/XLinguProperties.hpp> +#include <comphelper/lok.hxx> +#include <comphelper/servicehelper.hxx> #include <osl/diagnose.h> #include <sfx2/objface.hxx> @@ -570,10 +574,13 @@ void SwView::ExecViewOptions(SfxRequest &rReq) break; case SID_SPOTLIGHT_PARASTYLES: - if (!pArgs || (pArgs && !pArgs->HasItem(FN_PARAM_1))) + if (!comphelper::LibreOfficeKit::isActive()) { - const SfxStringItem sDeckName(SID_SIDEBAR_DECK, u"StyleListDeck"_ustr); - GetDispatcher().ExecuteList(SID_SIDEBAR_DECK, SfxCallMode::SYNCHRON, { &sDeckName }); + if (!pArgs || !pArgs->HasItem(FN_PARAM_1)) + { + const SfxStringItem sDeckName(SID_SIDEBAR_DECK, u"StyleListDeck"_ustr); + GetDispatcher().ExecuteList(SID_SIDEBAR_DECK, SfxCallMode::SYNCHRON, { &sDeckName }); + } } if (STATE_TOGGLE == eState) bFlag = !m_bIsSpotlightParaStyles; @@ -581,10 +588,13 @@ void SwView::ExecViewOptions(SfxRequest &rReq) break; case SID_SPOTLIGHT_CHARSTYLES: - if (!pArgs || (pArgs && !pArgs->HasItem(FN_PARAM_1))) + if (!comphelper::LibreOfficeKit::isActive()) { - const SfxStringItem sDeckName(SID_SIDEBAR_DECK, u"StyleListDeck"_ustr); - GetDispatcher().ExecuteList(SID_SIDEBAR_DECK, SfxCallMode::SYNCHRON, { &sDeckName }); + if (!pArgs || !pArgs->HasItem(FN_PARAM_1)) + { + const SfxStringItem sDeckName(SID_SIDEBAR_DECK, u"StyleListDeck"_ustr); + GetDispatcher().ExecuteList(SID_SIDEBAR_DECK, SfxCallMode::SYNCHRON, { &sDeckName }); + } } if (STATE_TOGGLE == eState) bFlag = !m_bIsSpotlightCharStyles; @@ -755,6 +765,14 @@ void SwView::ExecViewOptions(SfxRequest &rReq) pModule->ApplyUsrPref( *pOpt, this, bWebView ? SvViewOpt::DestWeb : SvViewOpt::DestText ); + if (nSlot == SID_SPOTLIGHT_CHARSTYLES || nSlot == SID_SPOTLIGHT_PARASTYLES) + { + SwXTextDocument* pModel = comphelper::getFromUnoTunnel<SwXTextDocument>(GetCurrentDocument()); + SfxLokHelper::notifyViewRenderState(this, pModel); + if (vcl::Window *pMyWin = rSh.GetWin()) + pMyWin->Invalidate(); + } + // #i6193# let postits know about new spellcheck setting if ( nSlot == SID_AUTOSPELL_CHECK ) GetPostItMgr()->SetSpellChecking(); diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 6f9bbd2a10cd..553188bbefa8 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -3627,6 +3627,15 @@ OString SwXTextDocument::getViewRenderState(SfxViewShell* pViewShell) if (pVOpt->GetDocColor() == svtools::ColorConfig::GetDefaultColor(svtools::DOCCOLOR, 1)) aState.append('D'); + if (pView->IsSpotlightParaStyles() || pView->IsSpotlightCharStyles()) + { + aState.append('H'); + if (pView->IsSpotlightParaStyles()) + aState.append('P'); + if (pView->IsSpotlightCharStyles()) + aState.append('C'); + } + aState.append(';'); OString aThemeName = OUStringToOString(pVOpt->GetThemeName(), RTL_TEXTENCODING_UTF8);