Shaded boxes reversion.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36071 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2010-11-04 16:14:17 +00:00
parent fecc3b8305
commit 890b4b419a

View File

@ -1225,37 +1225,20 @@ def revert_fontcolor(document):
def revert_shadedboxcolor(document): def revert_shadedboxcolor(document):
" Reverts shaded box color to preamble code " " Reverts shaded box color to preamble code "
i = 0 i = find_token(document.header, "\\boxbgcolor", 0)
colorcode = "" if i == -1:
while True: return
i = find_token(document.header, "\\boxbgcolor", i) colorcode = get_value(document.header, '\\boxbgcolor', i)
if i == -1: del document.header[i]
return # the color code is in the form #rrggbb
colorcode = get_value(document.header, '\\boxbgcolor', 0) red = hex2ratio(colorcode[1:3])
del document.header[i] 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 increment here ['% Commands inserted by lyx2lyx to set the color of boxes with shaded background',
if red != 0: '\\@ifundefined{definecolor}{\\usepackage{color}}{}',
red = red + 1 "\\definecolor{shadecolor}{rgb}{%s,%s,%s}" % (red, green, blue)])
redout = float(red) / 256
green = string.atoi(colorcode[3:5],16)
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 color\n'
'% of boxes with shaded background\n'
+ '\\@ifundefined{definecolor}{\\usepackage{color}}{}\n'
+ '\\definecolor{shadecolor}{rgb}{'
+ str(redout) + ', ' + str(greenout)
+ ', ' + str(blueout) + '}\n')
def revert_lyx_version(document): def revert_lyx_version(document):