[Solved] Complete the code, please

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
no_such_UNO
Posts: 15
Joined: Sat Jun 24, 2023 2:42 pm

[Solved] Complete the code, please

Post by no_such_UNO »

"StarOffice programmer's tutorial" shows the following code example of how to get access to the ColorTable,

Dim oColorTable As Object
oColorTable=createUnoService("com.sun.star.drawing.ColorTable")

and to complete the idea there must be some code running which one will clearly see what exactly table is accessed. Can someone complete the code to see the idea clearly, please?
LibreOffice 7.2.7.3 on LinuxMint 21.1
User avatar
Zizi64
Volunteer
Posts: 11364
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Complete the code, please

Post by Zizi64 »

OpenOffice 2.4 on Ubuntu 9.04

OpenOffice has one Palette only (as I remember it).

Are you using LibreOffice really?

Then, please update your signature in this Forum.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
JeJe
Volunteer
Posts: 2785
Joined: Wed Mar 09, 2016 2:40 pm

Re: Complete the code, please

Post by JeJe »

Just as with your other thread the answer can be found with MRI

Code: Select all

Dim oColorTable As Object
oColorTable=createUnoService("com.sun.star.drawing.ColorTable")
mri oColorTable
MRI result - properties
(Name) (Value Type) (Value) (Info.) (Attr.) (Handle)
ElementNames []string -Sequence- Pseud Read_Only
ElementType type long Pseud Read_Only
ImplementationId []byte -SEQUENCE- Pseud Read_Only
ImplementationName string SvxUnoColorTable Pseud Read_Only
SupportedServiceNames []string -Sequence- Pseud Read_Only
Types []type -Sequence- Pseud Read_Only
ElementNames:
(000) = White
(001) = Grey 1
(002) = Grey 2
(003) = Grey 3
(004) = Grey 4
(005) = Grey 5
(006) = Grey 6
(007) = Grey 7
(008) = Grey 8
(009) = Grey 9
(010) = Grey 10
(011) = Black
(012) = Yellow
(013) = Orange
(014) = Red
(015) = Pink
(016) = Magenta
(017) = Purple
(018) = Blue
(019) = Sky blue
(020) = Cyan
(021) = Turquoise
(022) = Green
(023) = Yellow green
(024) = Yellow 1
(025) = Orange 1
(026) = Red 1
(027) = Pink 1
(028) = Magenta 1
(029) = Purple 1
(030) = Blue 1
(031) = Sky blue 1
(032) = Cyan 1
(033) = Turquoise 1
(034) = Green 1
(035) = Yellow green 1
(036) = Yellow 2
(037) = Orange 2
(038) = Red 2
(039) = Pink 2
(040) = Magenta 2
(041) = Purple 2
(042) = Blue 2
(043) = Sky blue 2
(044) = Cyan 2
(045) = Turquoise 2
(046) = Green 2
(047) = Yellow green 2
(048) = Yellow 3
(049) = Orange 3
(050) = Red 3
(051) = Pink 3
(052) = Magenta 3
(053) = Purple 3
(054) = Blue 3
(055) = Sky blue 3
(056) = Cyan 3
(057) = Turquoise 3
(058) = Green 3
(059) = Yellow green 3
(060) = Yellow 4
(061) = Orange 4
(062) = Red 4
(063) = Pink 4
(064) = Magenta 4
(065) = Purple 4
(066) = Blue 4
(067) = Sky blue 4
(068) = Cyan 4
(069) = Turquoise 4
(070) = Green 4
(071) = Yellow green 4
(072) = Yellow 5
(073) = Orange 5
(074) = Red 5
(075) = Pink 5
(076) = Magenta 5
(077) = Purple 5
(078) = Blue 5
(079) = Sky blue 5
(080) = Cyan 5
(081) = Turquoise 5
(082) = Green 5
(083) = Yellow green 5
(084) = Yellow 6
(085) = Orange 6
(086) = Red 6
(087) = Pink 6
(088) = Magenta 6
(089) = Purple 6
(090) = Blue 6
(091) = Sky blue 6
(092) = Cyan 6
(093) = Turquoise 6
(094) = Green 6
(095) = Yellow green 6
(096) = Yellow 7
(097) = Orange 7
(098) = Red 7
(099) = Pink 7
(100) = Magenta 7
(101) = Purple 7
(102) = Blue 7
(103) = Sky blue 7
(104) = Cyan 7
(105) = Turquoise 7
(106) = Green 7
(107) = Yellow green 7
(108) = Yellow 8
(109) = Orange 8
(110) = Red 8
(111) = Pink 8
(112) = Magenta 8
(113) = Purple 8
(114) = Blue 8
(115) = Sky blue 8
(116) = Cyan 8
(117) = Turquoise 8
(118) = Green 8
(119) = Yellow green 8
(120) = Yellow 9
(121) = Orange 9
(122) = Red 9
(123) = Pink 9
(124) = Magenta 9
(125) = Purple 9
(126) = Blue 9
(127) = Sky blue 9
(128) = Cyan 9
(129) = Turquoise 9
(130) = Green 9
(131) = Yellow green 9
(132) = Yellow 10
(133) = Orange 10
(134) = Red 10
(135) = Pink 10
(136) = Magenta 10
(137) = Purple 10
(138) = Blue 10
(139) = Sky blue 10
(140) = Cyan 10
(141) = Turquoise 10
(142) = Green 10
(143) = Yellow green 10
(144) = Blue grey
(145) = Blue classic
(146) = Violet
(147) = Bordeaux
(148) = Pale yellow
(149) = Pale green
(150) = Dark violet
(151) = Salmon
(152) = Sea blue
(153) = Chart 1
(154) = Chart 2
(155) = Chart 3
(156) = Chart 4
(157) = Chart 5
(158) = Chart 6
(159) = Chart 7
(160) = Chart 8
(161) = Chart 9
(162) = Chart 10
(163) = Chart 11
(164) = Chart 12
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
no_such_UNO
Posts: 15
Joined: Sat Jun 24, 2023 2:42 pm

Re: Complete the code, please

Post by no_such_UNO »

JeJe wrote: Sat Jun 24, 2023 6:43 pm Just as with your other thread the answer can be found with MRI

Code: Select all

Dim oColorTable As Object
oColorTable=createUnoService("com.sun.star.drawing.ColorTable")
mri oColorTable
Not enough stack memory, that's what I have.
LibreOffice 7.2.7.3 on LinuxMint 21.1
no_such_UNO
Posts: 15
Joined: Sat Jun 24, 2023 2:42 pm

Re: Complete the code, please

Post by no_such_UNO »

Zizi64 I have no idea, right now. how to update my signature in this Forum.
LibreOffice 7.2.7.3 on LinuxMint 21.1
JeJe
Volunteer
Posts: 2785
Joined: Wed Mar 09, 2016 2:40 pm

Re: Complete the code, please

Post by JeJe »

no_such_UNO wrote: Sat Jun 24, 2023 7:17 pm
JeJe wrote: Sat Jun 24, 2023 6:43 pm Just as with your other thread the answer can be found with MRI

Code: Select all

Dim oColorTable As Object
oColorTable=createUnoService("com.sun.star.drawing.ColorTable")
mri oColorTable
Not enough stack memory, that's what I have.

You put that code in a separate module, the one you're writing, not in the MRI library. You have to make sure the MRI library is loaded then you call it using MRI and the object name from wherever.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
no_such_UNO
Posts: 15
Joined: Sat Jun 24, 2023 2:42 pm

Re: Complete the code, please

Post by no_such_UNO »

Well, it is there in separate module. I did not put the code in MRI library on my own for sure.
LibreOffice 7.2.7.3 on LinuxMint 21.1
no_such_UNO
Posts: 15
Joined: Sat Jun 24, 2023 2:42 pm

Re: Complete the code, please

Post by no_such_UNO »

Sub m
Dim oColorTable As Object
oColorTable=createUnoService("com.sun.star.drawing.ColorTable")
mri oColorTable -> this procedure is not defined, sure I do something wrong for sure
End Sub
LibreOffice 7.2.7.3 on LinuxMint 21.1
JeJe
Volunteer
Posts: 2785
Joined: Wed Mar 09, 2016 2:40 pm

Re: Complete the code, please

Post by JeJe »

Go to the MRILib library and run either of the subs to load the library - then you can use it.

Or you can put this in your code to make sure its loaded.

Code: Select all

with globalscope.basiclibraries
if not .islibraryloaded("MRILib") then .loadlibrary("MRILib")
end with
Villeroy posted a link in one of your threads on how to use MRI - if you read that, it will help.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
no_such_UNO
Posts: 15
Joined: Sat Jun 24, 2023 2:42 pm

Re: Complete the code, please

Post by no_such_UNO »

Code: Select all

Sub m
with globalscope.basiclibraries
if not .islibraryloaded("MRILib") then .loadlibrary("MRILib")
end with
Dim oColorTable As Object
oColorTable=createUnoService("com.sun.star.drawing.ColorTable")
mri oColorTable
End Sub

results are
Properties
(Name) (Value Type) (Value) (Info.) (Attr.) (Handle)
ElementNames []string -Sequence- Pseud Read_Only
ElementType type long Pseud Read_Only
ImplementationId []byte -SEQUENCE- Pseud Read_Only
ImplementationName string com.sun.star.dr... Pseud Read_Only
SupportedServiceNames []string -Sequence- Pseud Read_Only
Types []type -Sequence- Pseud Read_Only
Methods
(Name) (Arguments) (Return Type) (DeclaringClass) (Exceptions)
acquire () void .uno.XInterface
getByName ( [in] string aName ) any .container.XNameAccess .container.NoSuchElementException, .lang.WrappedTargetException, .uno.RuntimeException
getElementNames () []string .container.XNameAccess .uno.RuntimeException
getElementType () type .container.XElementAccess .uno.RuntimeException
getImplementationId () []byte .lang.XTypeProvider .uno.RuntimeException
getImplementationName () string .lang.XServiceInfo .uno.RuntimeException
getSupportedServiceNames () []string .lang.XServiceInfo .uno.RuntimeException
getTypes () []type .lang.XTypeProvider .uno.RuntimeException
hasByName ( [in] string aName ) boolean .container.XNameAccess .uno.RuntimeException
hasElements () boolean .container.XElementAccess .uno.RuntimeException
insertByName ( [in] string aName, [in] any aElement ) void .container.XNameContainer .lang.IllegalArgumentException, .container.ElementExistException, .lang.WrappedTargetException, .uno.RuntimeException
queryAdapter () .uno.XAdapter .uno.XWeak .uno.RuntimeException
queryInterface ( [in] type aType ) any .uno.XInterface .uno.RuntimeException
release () void .uno.XInterface
removeByName ( [in] string Name ) void .container.XNameContainer .container.NoSuchElementException, .lang.WrappedTargetException, .uno.RuntimeException
replaceByName ( [in] string aName, [in] any aElement ) void .container.XNameReplace .lang.IllegalArgumentException, .container.NoSuchElementException, .lang.WrappedTargetException, .uno.RuntimeException
supportsService ( [in] string ServiceName ) boolean .lang.XServiceInfo .uno.RuntimeException
Interfaces
(Interfaces)
com.sun.star.container.XElementAccess
com.sun.star.container.XNameAccess
com.sun.star.container.XNameContainer
com.sun.star.container.XNameReplace
com.sun.star.lang.XServiceInfo
com.sun.star.lang.XTypeProvider
com.sun.star.uno.XInterface
com.sun.star.uno.XWeak

(Listeners)
Services
(Supported Service Names)
com.sun.star.drawing.ColorTable

All of it looks very nice I hope I will figure the rest of it, though it is not a point for you to relax. I am happy today!
LibreOffice 7.2.7.3 on LinuxMint 21.1
Post Reply