Browse Source

Pull request #2379: REPORT-39601 在单元格中插入 富文本。 字体设置为14的时候,自动给我变成13了

Merge in DESIGN/design from ~KERRY/design_10.0:release/10.0 to release/10.0

* commit '6b70b8a239602313b1e0bb5230d9fe0e51292694':
  REPORT-39601 在单元格中插入 富文本。 字体设置为14的时候,自动给我变成13了
feature/big-screen
kerry 4 years ago
parent
commit
d83badb94c
  1. 5
      designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java
  2. 69
      designer-realize/src/test/java/com/fr/design/cell/editor/RichTextToolBarTest.java

5
designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java

@ -502,14 +502,15 @@ public class RichTextToolBar extends BasicPane{
//pt转为px =*4/3
private int scaleUp(int fontSize) {
return (int) FontTransformUtil.pt2px(fontSize);
return roundUp(FontTransformUtil.pt2px(fontSize));
}
//px转pt = *3/4
private int scaleDown(int fontSize) {
return (int) FontTransformUtil.px2pt(fontSize);
return roundUp(FontTransformUtil.px2pt(fontSize));
}
private DocumentListener inputListener = new DocumentListener() {
@Override

69
designer-realize/src/test/java/com/fr/design/cell/editor/RichTextToolBarTest.java

@ -0,0 +1,69 @@
package com.fr.design.cell.editor;
import com.fr.invoke.Reflect;
import org.easymock.EasyMock;
import org.junit.Assert;
import org.junit.Test;
/**
* Created by kerry on 2020-09-21
*/
public class RichTextToolBarTest {
@Test
public void testScaleUpAndDown() {
RichTextToolBar textToolBar = EasyMock.mock(RichTextToolBar.class);
int result = Reflect.on(textToolBar).call("scaleUp", 10).get();
Assert.assertEquals(13, result);
result = Reflect.on(textToolBar).call("scaleDown", 13).get();
Assert.assertEquals(10, result);
result = Reflect.on(textToolBar).call("scaleUp", 11).get();
Assert.assertEquals(15, result);
result = Reflect.on(textToolBar).call("scaleDown", 15).get();
Assert.assertEquals(11, result);
result = Reflect.on(textToolBar).call("scaleUp", 12).get();
Assert.assertEquals(16, result);
result = Reflect.on(textToolBar).call("scaleDown", 16).get();
Assert.assertEquals(12, result);
result = Reflect.on(textToolBar).call("scaleUp", 13).get();
Assert.assertEquals(17, result);
result = Reflect.on(textToolBar).call("scaleDown", 17).get();
Assert.assertEquals(13, result);
result = Reflect.on(textToolBar).call("scaleUp", 14).get();
Assert.assertEquals(19, result);
result = Reflect.on(textToolBar).call("scaleDown", 19).get();
Assert.assertEquals(14, result);
result = Reflect.on(textToolBar).call("scaleUp", 16).get();
Assert.assertEquals(21, result);
result = Reflect.on(textToolBar).call("scaleDown", 21).get();
Assert.assertEquals(16, result);
result = Reflect.on(textToolBar).call("scaleUp", 17).get();
Assert.assertEquals(23, result);
result = Reflect.on(textToolBar).call("scaleDown", 23).get();
Assert.assertEquals(17, result);
result = Reflect.on(textToolBar).call("scaleUp", 17).get();
Assert.assertEquals(23, result);
result = Reflect.on(textToolBar).call("scaleDown", 23).get();
Assert.assertEquals(17, result);
result = Reflect.on(textToolBar).call("scaleUp", 19).get();
Assert.assertEquals(25, result);
result = Reflect.on(textToolBar).call("scaleDown", 25).get();
Assert.assertEquals(19, result);
result = Reflect.on(textToolBar).call("scaleUp", 20).get();
Assert.assertEquals(27, result);
result = Reflect.on(textToolBar).call("scaleDown", 27).get();
Assert.assertEquals(20, result);
}
}
Loading…
Cancel
Save