Add strikethrough support to the style modifier and restore the button

in simpleStyles.
Also add special CSS handling for it in Style2CSS
This commit is contained in:
Aditya Bhatt
2013-02-20 13:35:47 +05:30
parent ede48f84bb
commit 3c1ce46dac
4 changed files with 35 additions and 4 deletions
+1
View File
@@ -70,6 +70,7 @@ define({
bold: "Bold",
italic: "Italic",
underline: "Underline",
strikethrough: "Strikethrough",
font: "Font",
family: "Family",
size: "Size",
+22 -2
View File
@@ -99,9 +99,27 @@ define("webodf/editor/widgets/simpleStyles", [], function () {
}
}
});
strikethroughButton = new ToggleButton({
label: document.translator('strikethrough'),
showLabel: false,
checked: false,
iconClass: "dijitEditorIcon dijitEditorIconStrikethrough",
onChange: function (checked) {
var currentStyleName = editorSession.getCurrentParagraphStyle();
if (checked) {
editorSession.updateParagraphStyle(currentStyleName, {
textProperties: { strikethrough: 'solid' }
});
} else {
editorSession.updateParagraphStyle(currentStyleName, {
textProperties: { strikethrough: 'none' }
});
}
}
});
editorSession.subscribe('paragraphChanged', function (info) {
var currentStyleName, fontWeight, fontStyle, underline, textProperties;
var currentStyleName, fontWeight, fontStyle, underline, strikethrough, textProperties;
if (info.type === 'style') {
currentStyleName = editorSession.getCurrentParagraphStyle();
textProperties = editorSession.getParagraphStyleAttributes(currentStyleName)['style:text-properties'];
@@ -109,14 +127,16 @@ define("webodf/editor/widgets/simpleStyles", [], function () {
fontWeight = textProperties['fo:font-weight'];
fontStyle = textProperties['fo:font-style'];
underline = textProperties['style:text-underline-style'];
strikethrough = textProperties['style:text-line-through-style'];
boldButton.set('checked', fontWeight === 'bold' ? true : false);
italicButton.set('checked', fontStyle === 'italic' ? true : false);
underlineButton.set('checked', underline === 'solid' ? true : false);
strikethroughButton.set('checked', strikethrough === 'solid' ? true : false);
}
});
widget.children = [boldButton, italicButton, underlineButton];
widget.children = [boldButton, italicButton, underlineButton, strikethroughButton];
widget.startup = function () {
widget.children.forEach(function (element) {
element.startup();
+10 -2
View File
@@ -426,12 +426,20 @@ odf.Style2CSS = function Style2CSS() {
* @return {!string}
*/
function getTextProperties(props) {
var rule = '', value;
var rule = '', value, textDecoration = 'text-decoration:';
rule += applySimpleMapping(props, textPropertySimpleMapping);
value = props.getAttributeNS(stylens, 'text-underline-style');
if (value === 'solid') {
rule += 'text-decoration: underline;';
textDecoration += ' underline';
}
value = props.getAttributeNS(stylens, 'text-line-through-style');
if (value === 'solid') {
textDecoration += ' line-through';
}
textDecoration += ';';
rule += textDecoration;
value = props.getAttributeNS(stylens, 'font-name');
if (value) {
value = getFontDeclaration(value);
+2
View File
@@ -488,6 +488,8 @@ runtime.log("Setting paragraph style:" + domPosition + " -- " + position + " " +
'fo:font-style', info.textProperties.fontStyle);
setRealAttributeNS(textPropertiesNode, stylens,
'style:text-underline-style', info.textProperties.underline);
setRealAttributeNS(textPropertiesNode, stylens,
'style:text-line-through-style', info.textProperties.strikethrough);
}
odfCanvas.refreshCSS();