core.git: Branch 'distro/collabora/co-23.05' - desktop/source include/sfx2 sfx2/source
desktop/source/lib/init.cxx|3 ++- include/sfx2/lokhelper.hxx |2 ++ sfx2/source/view/frmload.cxx | 30 ++ sfx2/source/view/lokhelper.cxx | 15 +++ 4 files changed, 49 insertions(+), 1 deletion(-) New commits: commit 1d7ee6942f1f1ccdb8aeb253c1cf8ce0c5f63421 Author: Henry Castro AuthorDate: Tue Feb 20 16:09:13 2024 -0400 Commit: Caolán McNamara CommitDate: Fri Mar 22 10:29:55 2024 +0100 lok: add property descriptor "Theme" Add option to load the document with a "theme" property name. Format: "document:theme_name" Signed-off-by: Henry Castro Change-Id: Iaef3d2e8962af526496e5cc95021fa94dca17939 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163671 Tested-by: Jenkins CollaboraOffice Tested-by: Caolán McNamara Reviewed-by: Caolán McNamara diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 9288a67c2181..323d0751cb6d 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -2784,7 +2784,8 @@ static LibreOfficeKitDocument* lo_documentLoadWithOptions(LibreOfficeKit* pThis, comphelper::makePropertyValue("InteractionHandler", xInteraction), comphelper::makePropertyValue("MacroExecutionMode", nMacroExecMode), comphelper::makePropertyValue("AsTemplate", false), -comphelper::makePropertyValue("Silent", !aBatch.isEmpty()) +comphelper::makePropertyValue("Silent", !aBatch.isEmpty()), +comphelper::makePropertyValue("Theme", extractParameter(aOptions, u"Theme")) }; /* TODO diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx index e8904d013f75..35ed5109f5c0 100644 --- a/include/sfx2/lokhelper.hxx +++ b/include/sfx2/lokhelper.hxx @@ -131,6 +131,8 @@ public: static LOKDeviceFormFactor getDeviceFormFactor(); /// Set the device form factor that should be used for a new view. static void setDeviceFormFactor(std::u16string_view rDeviceFormFactor); +/// Get the document type +static OUString getDocumentType(const OUString& sDocumentService); /// Set timezone of the given view. /// @isSet true to use @rTimezone, even if it's empty. Otherwise, no timezone. diff --git a/sfx2/source/view/frmload.cxx b/sfx2/source/view/frmload.cxx index f03b08fe5886..e4acd00ffa37 100644 --- a/sfx2/source/view/frmload.cxx +++ b/sfx2/source/view/frmload.cxx @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -48,6 +49,7 @@ #include #include +#include #include #include #include @@ -57,6 +59,7 @@ #include #include #include +#include #include #include #include @@ -708,6 +711,7 @@ sal_Bool SAL_CALL SfxFrameLoader_Impl::load( const Sequence< PropertyValue >& rA const OUString sServiceName = aDescriptor.getOrDefault( "DocumentService", OUString() ); xModel.set( m_aContext->getServiceManager()->createInstanceWithContext(sServiceName, m_aContext), UNO_QUERY_THROW ); + // load resp. init it const Reference< XLoadable > xLoadable( xModel, UNO_QUERY_THROW ); if ( bInitNewModel ) @@ -766,6 +770,32 @@ sal_Bool SAL_CALL SfxFrameLoader_Impl::load( const Sequence< PropertyValue >& rA } bLoadSuccess = true; + +const OUString sThemes = aDescriptor.getOrDefault("Theme", OUString()); +if (comphelper::LibreOfficeKit::isActive() && !sThemes.isEmpty()) +{ +const OUString sServiceName = aDescriptor.getOrDefault("DocumentService", OUString()); +OUString sTheme, sType, sName; +sal_Int32 nTheme = 0, nIndex = 0; +do +{ +sTheme = sThemes.getToken(0, ';', nTheme); +sType = sTheme.getToken(0, ':', nIndex); +sName = sTheme.getToken(0, ':', nIndex); +if (sType == SfxLokHelper::getDocumentType(sServiceName)) +{ +svtools::EditableColorConfig aConfig; +if (aConfig.GetCurrentSchemeName() != sName) +{ +aConfig.LoadScheme(sName); +break; +} +} +nIndex = 0; + +} +while ( nTheme >= 0 ); +} } catch ( Exception& ) { diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index e6fc7e8c7114..b22d1e488283 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -388,6 +388,21 @@ void SfxLokHelper::setDeviceFormFactor(std::u16string_view rDeviceFormFactor) g_deviceFormFactor = LOKDeviceFormFactor::UNKNOWN; } +OUString SfxLokHelper::getDocumentType(const OUString& sDocumentService) +{ +if (sDocumentService == "com.sun.star.sheet.SpreadsheetDocument") +return "spreadsheet"; +
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - desktop/source include/sfx2 sfx2/source
desktop/source/lib/init.cxx| 87 + include/sfx2/viewsh.hxx|2 sfx2/source/view/lokhelper.cxx |3 - sfx2/source/view/viewsh.cxx| 34 +--- 4 files changed, 69 insertions(+), 57 deletions(-) New commits: commit fb1d24cbc66d37ac5f8217abe072a44a072af420 Author: Marco Cecchetti AuthorDate: Sun May 7 11:52:14 2023 +0200 Commit: Marco Cecchetti CommitDate: Sun May 7 20:31:01 2023 +0200 fixup! lok: accessibility event listener for focused paragraph It seems it was not a good idea using a unique_ptr as smart pointer for an instance of LOKDocumentFocusListener Change-Id: I8e6b0f48fee3c5db3c9b074a663f7f3fb96a601e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151459 Tested-by: Jenkins CollaboraOffice Reviewed-by: Marco Cecchetti diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 62d8a93733e4..2d1ad0e5a89c 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -1368,6 +1368,45 @@ vcl::Font FindFont_FallbackToDefault(std::u16string_view rFontName) return OutputDevice::GetDefaultFont(DefaultFontType::SANS_UNICODE, LANGUAGE_NONE, GetDefaultFontFlags::NONE); } + +static int getDocumentType (LibreOfficeKitDocument* pThis) +{ +SetLastExceptionMsg(); + +LibLODocument_Impl* pDocument = static_cast(pThis); + +try +{ +uno::Reference xDocument(pDocument->mxComponent, uno::UNO_QUERY_THROW); + +if (xDocument->supportsService("com.sun.star.sheet.SpreadsheetDocument")) +{ +return LOK_DOCTYPE_SPREADSHEET; +} +else if (xDocument->supportsService("com.sun.star.presentation.PresentationDocument")) +{ +return LOK_DOCTYPE_PRESENTATION; +} +else if (xDocument->supportsService("com.sun.star.drawing.DrawingDocument")) +{ +return LOK_DOCTYPE_DRAWING; +} +else if (xDocument->supportsService("com.sun.star.text.TextDocument") || xDocument->supportsService("com.sun.star.text.WebDocument")) +{ +return LOK_DOCTYPE_TEXT; +} +else +{ +SetLastExceptionMsg("unknown document type"); +} +} +catch (const uno::Exception& exception) +{ +SetLastExceptionMsg("exception: " + exception.Message); +} +return LOK_DOCTYPE_OTHER; +} + } // anonymous namespace LibLODocument_Impl::LibLODocument_Impl(uno::Reference xComponent, int nDocumentId) @@ -3634,40 +3673,7 @@ static int doc_getDocumentType (LibreOfficeKitDocument* pThis) comphelper::ProfileZone aZone("doc_getDocumentType"); SolarMutexGuard aGuard; -SetLastExceptionMsg(); - -LibLODocument_Impl* pDocument = static_cast(pThis); - -try -{ -uno::Reference xDocument(pDocument->mxComponent, uno::UNO_QUERY_THROW); - -if (xDocument->supportsService("com.sun.star.sheet.SpreadsheetDocument")) -{ -return LOK_DOCTYPE_SPREADSHEET; -} -else if (xDocument->supportsService("com.sun.star.presentation.PresentationDocument")) -{ -return LOK_DOCTYPE_PRESENTATION; -} -else if (xDocument->supportsService("com.sun.star.drawing.DrawingDocument")) -{ -return LOK_DOCTYPE_DRAWING; -} -else if (xDocument->supportsService("com.sun.star.text.TextDocument") || xDocument->supportsService("com.sun.star.text.WebDocument")) -{ -return LOK_DOCTYPE_TEXT; -} -else -{ -SetLastExceptionMsg("unknown document type"); -} -} -catch (const uno::Exception& exception) -{ -SetLastExceptionMsg("exception: " + exception.Message); -} -return LOK_DOCTYPE_OTHER; +return getDocumentType(pThis); } static int doc_getParts (LibreOfficeKitDocument* pThis) @@ -3792,7 +3798,7 @@ static char* doc_getPartPageRectangles(LibreOfficeKitDocument* pThis) static char* doc_getA11yFocusedParagraph(LibreOfficeKitDocument* pThis) { SolarMutexGuard aGuard; - +SetLastExceptionMsg(); ITiledRenderable* pDoc = getTiledRenderable(pThis); if (!pDoc) @@ -3812,7 +3818,7 @@ static char* doc_getA11yFocusedParagraph(LibreOfficeKitDocument* pThis) static int doc_getA11yCaretPosition(LibreOfficeKitDocument* pThis) { SolarMutexGuard aGuard; - +SetLastExceptionMsg(); ITiledRenderable* pDoc = getTiledRenderable(pThis); if (!pDoc) @@ -7002,14 +7008,13 @@ static void doc_setViewTimezone(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*p static void doc_setAccessibilityState(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* pThis, int nId, bool nEnabled) { -int nDocType = doc_getDocumentType(pThis); +SolarMutexGuard aGuard; +SetLastExceptionMsg(); + +int nDocType = getDocumentType(pThis); if (nDocType !=
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - desktop/source include/sfx2 sfx2/source
desktop/source/lib/init.cxx| 48 + include/sfx2/lokhelper.hxx |3 ++ sfx2/source/view/lokhelper.cxx |6 - 3 files changed, 56 insertions(+), 1 deletion(-) New commits: commit 3cdfcd4e2f350273ab1861abf6d6b7177fd0f215 Author: Gökay Şatır AuthorDate: Mon Feb 20 11:17:55 2023 +0300 Commit: Miklos Vajna CommitDate: Thu Mar 16 07:15:49 2023 + Preload the accelerator configurations when libreofficekit is active. Signed-off-by: Gökay Şatır Change-Id: I6fbc2e87b1e338b84c69b96768df0339f1a0abd0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147311 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148679 Tested-by: Miklos Vajna diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 07bb6be18fa0..480fc9952e6a 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -213,6 +213,10 @@ #include #include +#include +#include +#include + using namespace css; using namespace vcl; using namespace desktop; @@ -7180,6 +7184,47 @@ static void lo_status_indicator_callback(void *data, comphelper::LibreOfficeKit: } } +/// Used by preloadData (LibreOfficeKit) for providing different shortcuts for different languages. +void preLoadShortCutAccelerators() +{ +std::unordered_map>& acceleratorConfs = SfxLokHelper::getAcceleratorConfs(); +css::uno::Sequence installedLocales(officecfg::Setup::Office::InstalledLocales::get()->getElementNames()); +OUString actualLang = officecfg::Setup::L10N::ooLocale::get(); + +for (sal_Int32 i = 0; i < installedLocales.getLength(); i++) +{ +OUString language = LanguageTag(installedLocales[i]).getLocale().Language; + +if (!comphelper::LibreOfficeKit::isAllowlistedLanguage(language)) +{ +// Language is listed by COOL and also installed in core. We can create the short cut accelerator. + +// Set the UI language to current one, before creating the accelerator. +std::shared_ptr batch(comphelper::ConfigurationChanges::create()); +officecfg::Setup::L10N::ooLocale::set(installedLocales[i], batch); +batch->commit(); + +// Supported module names: Writer, Calc, Draw, Impress +std::vector supportedModuleNames = { "com.sun.star.text.TextDocument", "com.sun.star.sheet.SpreadsheetDocument", "com.sun.star.drawing.DrawingDocument", "com.sun.star.presentation.PresentationDocument" }; +// Create the accelerators. +for (std::size_t j = 0; j < supportedModuleNames.size(); j++) +{ +OUString key = supportedModuleNames[j] + installedLocales[i]; +acceleratorConfs[key] = svt::AcceleratorExecute::lok_createNewAcceleratorConfiguration(::comphelper::getProcessComponentContext(), supportedModuleNames[j]); +} +} +else +{ +std::cerr << "Language is installed in core but not in the list of COOL languages: " << language << "\n"; +} +} + +// Set the UI language back to default one. +std::shared_ptr batch(comphelper::ConfigurationChanges::create()); +officecfg::Setup::L10N::ooLocale::set(actualLang, batch); +batch->commit(); +} + /// Used only by LibreOfficeKit when used by Online to pre-initialize static void preloadData() { @@ -7243,6 +7288,9 @@ static void preloadData() ImageTree = ImageTree::get(); images.getImageUrl("forcefed.png", "style", "FO_oo"); +std::cerr << "Preload short cut accelerators\n"; +preLoadShortCutAccelerators(); + std::cerr << "Preload languages\n"; // force load language singleton diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx index d07e80071bd7..184f899880f7 100644 --- a/include/sfx2/lokhelper.hxx +++ b/include/sfx2/lokhelper.hxx @@ -23,6 +23,7 @@ #include #include #include +#include struct SFX2_DLLPUBLIC LokMouseEventData { @@ -51,6 +52,8 @@ namespace com::sun::star::ui { struct ContextChangeEventObject; }; class SFX2_DLLPUBLIC SfxLokHelper { public: +/// Gets the short cut accelerators. +static std::unordered_map>& getAcceleratorConfs(); /// Create a new view shell from the current view frame. /// This assumes a single document is ever loaded. static int createView(); diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index 2954f6006b69..bc33ad942382 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -110,6 +109,11 @@ int SfxLokHelper::createView() return createView(pViewShell->GetViewFrame(), pViewShell->GetDocId()); } +std::unordered_map>& SfxLokHelper::getAcceleratorConfs() +{ +return