Creating singleton UNO components in C++
sbergman at redhat.com
Tue Nov 1 17:27:17 UTC 2016
On 11/01/2016 04:49 PM, Dennis Francis wrote:
> I tried creating a very simple singleton UNO component which just
> gets/sets a boolean value. The code is hosted
> at https://github.com/niocs/SingletonComponent . This was created based
> on http://opengrok.libreoffice.org/xref/core/framework/source/jobs/jobexecutor.cxx#66
> . The component is packaged as an extension and unopkg was used to
> install it. The oxt file is also provided in the repo for easy testing.
> I tried to instantiate this singleton using macro sub named
> "TestSingleton" inside the document TestSingleton.ods provided in the
> same repo. The vba code is also provided in the file TestSingleton.vba
> for convenience. When the macro is executed, it shows a msgbox with the
> string "com.sun.star.uno.RuntimeExceptioncannot get environments".
For one, the SingletonComponent.components contained an unexpanded
attribute. Replace "@CPPU_ENV@" with the actual environment name
("gcc3" for GCC-based Linux/macOS/etc., "msci" for 32-bit Windows/MSVC,
"mscx" for 64-bit Windows/MSVC; see gb_CPPU_ENV in solenv/gbuild/platform/).
For another, note that specifying the environment in the .component file
is a LibreOffice-internal optimization (that may change again in the
future and should not be used in extensions; see
"Allow setting environment value directly in .component files").
Extensions must instead export a C function
component_getImplementationEnvironment, see e.g.
More information about the LibreOffice