It is possible using macros. The following is a solution
where macros are attached to a new user-defined toolbar. The
items in the toolbar can be used to incrementally change the
values of red, green and blue for the font colour.
It would also be possible to type in values by using
InputBox in the macros instead of incrementally change the
values.
Installation instructions follows. It is advisable to follow
them strictly as the way to define/work with macros in
OpenOffice is not very intuitive.
Start Impress. Create an empty presentation or open
some existing presentation.
Copy the code at the end of this answer to the clipboard.
Create a macro for increasing the value of Red by 20:
menu Tools/Macros/Organise Macros/OpenOffice.org Basic/.
Then expand to "My Macros/Standard/" so that "Standard" is selected.
Press button "New".
Right click on the tab in the lower left and select "Rename" and type "RedUp".
Click in the edit area (to set the focus there),
select all (Ctrl + A) and paste in the code.
Change the line with changeValue(0, 0, 0) to changeValue(20, 0, 0). This
is for increasing the value of Red by 20.
Right click on the tab in the lower left and select: Insert/BASIC Module.
Repeat step 3 five times so that there are 6 modules in all:
Module name changeValue line
----------------------------------------------
RedUp changeValue( 20, 0, 0)
RedDown changeValue( -20, 0, 0)
GreenUp changeValue( 0, 20, 0)
GreenDown changeValue( 0, -20, 0)
BlueUp changeValue( 0, 0, 20)
BlueDown changeValue( 0, 0, -20)
Create new toolbar: menu Tools/Customise/tab Toolbars/press button New/<name it "Colour Toolbar">/OK
Then
Add/OpenOffice.org Macros/My Macros/Standard/RedUp/<select "Main">/Add/Close/Modify/Rename/Red Up/OK.
(Note: if "Main" is not selected then a script error will happen later because "changeValue" is selected by default.)
Repeat for the 5 others. Rearrange the order of the items in the toolbar so the same
order is maintained as in the table above.
Finally press OK to close the dialog.
Now the foreground colour of the selected text can be
changed and the result be seen almost immediately! (the
selection must be cleared as it inverts the colour.)
If you want to apply the current colour to some other text
then add a 7th item to the toolbar where the changeValue line
is: changeValue(0, 0, 0). Or alternatively press an Up and a
Down for a colour (that is not too close to 0 or 255.)
The current colour is also remembered across program
restarts as the RGB value is stored in a settings file. A
sample path to the settings file is:
C:\Documents and Settings\peterm\Application Data\OpenOffice.org\3\user\prefs\settings.ini
If something goes wrong then settings.ini can just be
deleted. It will be recreated the next time this feature is
used.
I have tested it with OpenOffice 3.2.0, en-GB, but I expect it
to work with OpenOffice 3.1.
The code (the line with changeValue(0, 0, 0) needs to be changed):
REM ***** OOoBasic. <http://en.wikipedia.org/wiki/StarOffice_Basic> *****
Global RedDecimal as Long
Global BlueDecimal as Long
Global GreenDecimal as Long
Sub Main
rem Default values if settings have not been stored yet.
RedDecimal = 210
GreenDecimal = 100
BlueDecimal = 40
changeValue(0, 0, 0)
End Sub
sub changeValue(aRedChange, aGreenChange, aBlueChange)
ReadSettings
RedDecimal = newChannelValue(RedDecimal, aRedChange)
GreenDecimal = newChannelValue(GreenDecimal, aGreenChange)
BlueDecimal = newChannelValue(BlueDecimal, aBlueChange)
WriteSettings
dim document as object
document = ThisComponent.CurrentController.Frame
dim dispatcher as object
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem Set font (foreground) colour. Note that lines for background colour
rem are outcommented - it does not work in Impress, but it does work
rem in Calc.
dim args3(0) as new com.sun.star.beans.PropertyValue
rem args3(0).Name = "BackgroundColor"
args3(0).Name = "Color"
args3(0).Value = RedDecimal * 256 * 256 + GreenDecimal * 256 + BlueDecimal
rem dispatcher.executeDispatch(document, ".uno:BackgroundColor", "", 0, args3())
dispatcher.executeDispatch(document, ".uno:Color", "", 0, args3())
End Sub
rem *************************************************************************
Function newChannelValue(aStartValue as Long, aChange as Long) as Long
Dim toReturn as Long
toReturn = aStartValue + aChange
If toReturn > 255 Then
toReturn = 255
End If
If toReturn < 0 Then
toReturn = 0
End If
newChannelValue = toReturn
End Function
rem *************************************************************************
Sub WriteSettings
SubstService = CreateUnoService("com.sun.star.util.PathSubstitution")
UserPath = SubstService.substituteVariables("$(user)", true)
PrefFile = UserPath + "/prefs/settings.ini"
f1 = FreeFile()
Open PrefFile for output as #f1
Print #f1, RedDecimal
Print #f1, GreenDecimal
Print #f1, BlueDecimal
Close #f1
End Sub
rem *************************************************************************
Sub ReadSettings
SubstService = CreateUnoService("com.sun.star.util.PathSubstitution")
UserPath = SubstService.substituteVariables("$(user)", true)
PrefFile = UserPath + "/prefs/settings.ini"
If FileExists(PrefFile) Then
f1 = FreeFile()
Open PrefFile for Input as #f1
dim redStr as String
dim greenStr as String
dim blueStr as String
Line Input #f1, redStr
Line Input #f1, greenStr
Line Input #f1, blueStr
Close #f1
RedDecimal = CInt(redStr)
GreenDecimal = CInt(greenStr)
BlueDecimal = CInt(blueStr)
Else
WriteSettings
End If
End Sub