mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-29 13:04:58 +00:00
Fix up fontcolor reversion, and also fix a problem with the note color
reversion. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36070 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
2287446d04
commit
fecc3b8305
@ -1157,6 +1157,13 @@ def revert_notefontcolor(document):
|
|||||||
i = find_token(document.header, "\\notefontcolor", 0)
|
i = find_token(document.header, "\\notefontcolor", 0)
|
||||||
if i == -1:
|
if i == -1:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# are there any grey notes?
|
||||||
|
if find_token(document.body, "\\begin_inset Note Greyedout", 0) == -1:
|
||||||
|
# no need to do anything, and \renewcommand will throw an error
|
||||||
|
# since lyxgreyedout will not exist.
|
||||||
|
return
|
||||||
|
|
||||||
colorcode = get_value(document.header, '\\notefontcolor', i)
|
colorcode = get_value(document.header, '\\notefontcolor', i)
|
||||||
del document.header[i]
|
del document.header[i]
|
||||||
# the color code is in the form #rrggbb where every character denotes a hex number
|
# the color code is in the form #rrggbb where every character denotes a hex number
|
||||||
@ -1195,40 +1202,26 @@ def revert_turkmen(document):
|
|||||||
|
|
||||||
def revert_fontcolor(document):
|
def revert_fontcolor(document):
|
||||||
" Reverts font color to preamble code "
|
" Reverts font color to preamble code "
|
||||||
i = 0
|
i = find_token(document.header, "\\fontcolor", 0)
|
||||||
colorcode = ""
|
if i == -1:
|
||||||
while True:
|
return
|
||||||
i = find_token(document.header, "\\fontcolor", i)
|
colorcode = get_value(document.header, '\\fontcolor', i)
|
||||||
if i == -1:
|
del document.header[i]
|
||||||
return
|
# don't clutter the preamble if font color is not set
|
||||||
colorcode = get_value(document.header, '\\fontcolor', 0)
|
if colorcode == "#000000":
|
||||||
del document.header[i]
|
return
|
||||||
# don't clutter the preamble if backgroundcolor is not set
|
# the color code is in the form #rrggbb where every character denotes a hex number
|
||||||
if colorcode == "#000000":
|
red = hex2ratio(colorcode[1:3])
|
||||||
continue
|
green = hex2ratio(colorcode[3:5])
|
||||||
# the color code is in the form #rrggbb where every character denotes a hex number
|
blue = hex2ratio(colorcode[5:7])
|
||||||
# convert the string to an int
|
# write the preamble
|
||||||
red = string.atoi(colorcode[1:3],16)
|
insert_to_preamble(0, document,
|
||||||
# we want the output "0.5" for the value "127" therefore add here
|
['% Commands inserted by lyx2lyx to set the font color',
|
||||||
if red != 0:
|
'\\@ifundefined{definecolor}{\\usepackage{color}}{}',
|
||||||
red = red + 1
|
'\\definecolor{document_fontcolor}{rgb}{'
|
||||||
redout = float(red) / 256
|
+ str(red) + ', ' + str(green) + ', ' + str(blue) + '}',
|
||||||
green = string.atoi(colorcode[3:5],16)
|
'\\color{document_fontcolor}'])
|
||||||
if green != 0:
|
|
||||||
green = green + 1
|
|
||||||
greenout = float(green) / 256
|
|
||||||
blue = string.atoi(colorcode[5:7],16)
|
|
||||||
if blue != 0:
|
|
||||||
blue = blue + 1
|
|
||||||
blueout = float(blue) / 256
|
|
||||||
# write the preamble
|
|
||||||
insert_to_preamble(0, document,
|
|
||||||
'% Commands inserted by lyx2lyx to set the font color\n'
|
|
||||||
+ '\\@ifundefined{definecolor}{\\usepackage{color}}{}\n'
|
|
||||||
+ '\\definecolor{document_fontcolor}{rgb}{'
|
|
||||||
+ str(redout) + ', ' + str(greenout)
|
|
||||||
+ ', ' + str(blueout) + '}\n'
|
|
||||||
+ '\\color{document_fontcolor}\n')
|
|
||||||
|
|
||||||
def revert_shadedboxcolor(document):
|
def revert_shadedboxcolor(document):
|
||||||
" Reverts shaded box color to preamble code "
|
" Reverts shaded box color to preamble code "
|
||||||
|
Loading…
Reference in New Issue
Block a user