pengda
2 years ago
36 changed files with 801 additions and 334 deletions
@ -1,30 +0,0 @@
|
||||
package com.fr.design.update.actions; |
||||
|
||||
|
||||
import com.fr.design.utils.BrowseUtils; |
||||
import com.fr.general.CloudCenter; |
||||
import com.fr.log.FineLoggerFactory; |
||||
|
||||
import java.awt.Desktop; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.net.URI; |
||||
|
||||
|
||||
/** |
||||
* 帮助-更新升级 |
||||
* 点击查看新特性 |
||||
* */ |
||||
public class NewFeatureAction implements ActionListener { |
||||
|
||||
private String url = CloudCenter.getInstance().acquireConf("fr.latest.update.detail", "https://help.fanruan.com/finereport/doc-view-4699.html"); |
||||
|
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
try { |
||||
BrowseUtils.browser(url); |
||||
} catch (Exception ex) { |
||||
FineLoggerFactory.getLogger().error(ex.getMessage()); |
||||
} |
||||
} |
||||
} |
After Width: | Height: | Size: 688 B |
@ -0,0 +1,42 @@
|
||||
package com.fr.design.form.util; |
||||
|
||||
import com.fr.base.Style; |
||||
import com.fr.general.FRFont; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import java.util.regex.Matcher; |
||||
import java.util.regex.Pattern; |
||||
|
||||
/** |
||||
* 富文本导出工具栏 |
||||
* |
||||
* @author hades |
||||
* @version 11.0 |
||||
* Created by hades on 2022/5/19 |
||||
*/ |
||||
public class HtmlPaintUtils { |
||||
|
||||
|
||||
private static final Pattern FONT_SIZE_PATTERN = Pattern.compile(Pattern.quote("font-size:") + "(.*?)" + Pattern.quote("px")); |
||||
|
||||
/** |
||||
* 设置单元格字体为富文本中的最大字体 |
||||
* |
||||
* @param style |
||||
*/ |
||||
public static Style deriveMaxFontFromRichChar(Style style, String html) { |
||||
int maxSize = style.getFRFont().getSize(); |
||||
Matcher matcher = FONT_SIZE_PATTERN.matcher(html); |
||||
while (matcher.find()) { |
||||
String value = matcher.group(1); |
||||
try { |
||||
double pxSize = Double.parseDouble(value); |
||||
int ptSize = FontTransformUtil.roundUp(FontTransformUtil.px2pt(pxSize)); |
||||
maxSize = Math.max(maxSize, ptSize); |
||||
} catch (Throwable e) { |
||||
FineLoggerFactory.getLogger().debug(e.getMessage(), e); |
||||
} |
||||
} |
||||
FRFont cellFont = style.getFRFont(); |
||||
return style.deriveFRFont(cellFont.applySize(maxSize)); |
||||
} |
||||
} |
@ -0,0 +1,49 @@
|
||||
package com.fr.design.form.util; |
||||
|
||||
import com.fr.base.Style; |
||||
import junit.framework.TestCase; |
||||
import org.junit.Assert; |
||||
|
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 11.0 |
||||
* Created by hades on 2022/5/25 |
||||
*/ |
||||
public class HtmlPaintUtilsTest extends TestCase { |
||||
|
||||
public void testDeriveMaxFontFromRichChar() { |
||||
// 富文本字体size更大
|
||||
String testHtml0 = "<span style=\"font-size:21px;font-family:'宋体';\">这是一条测试数据</span>"; |
||||
Style style0 = Style.DEFAULT_STYLE; |
||||
Assert.assertEquals(16, HtmlPaintUtils.deriveMaxFontFromRichChar(style0, testHtml0).getFRFont().getSize()); |
||||
|
||||
// 单元格字体size更大
|
||||
String testHtml1 = "<span style=\"font-size:7px;font-family:'宋体';\">这是一条测试数据</span>"; |
||||
Style style1 = Style.DEFAULT_STYLE; |
||||
int oldFontSize = style1.getFRFont().getSize(); |
||||
Assert.assertEquals(oldFontSize, HtmlPaintUtils.deriveMaxFontFromRichChar(style1, testHtml1).getFRFont().getSize()); |
||||
|
||||
// 富文本字体size更大 不同文本 有不同size
|
||||
String testHtml2 = "<span style=\"font-size:21px;font-family:'宋体';\">这是一条测</span><span style=\"font-size:31px;font-family:'宋体';\">试数</span><span style=\"font-size:21px;font-family:'宋体';\">据</span>"; |
||||
Style style2 = Style.DEFAULT_STYLE; |
||||
Assert.assertEquals(23, HtmlPaintUtils.deriveMaxFontFromRichChar(style2, testHtml2).getFRFont().getSize()); |
||||
|
||||
|
||||
// 异常场景1
|
||||
String testHtml3 = "xxxx奇怪的格式xxxx"; |
||||
Style style3 = Style.DEFAULT_STYLE; |
||||
oldFontSize = style1.getFRFont().getSize(); |
||||
Assert.assertEquals(oldFontSize, HtmlPaintUtils.deriveMaxFontFromRichChar(style3, testHtml3).getFRFont().getSize()); |
||||
|
||||
// 异常场景2
|
||||
String testHtml4 = "<span style=\"font-size:xxxxpx;font-family:'宋体';\">这是一条测试数据</span>"; |
||||
Style style4 = Style.DEFAULT_STYLE; |
||||
oldFontSize = style1.getFRFont().getSize(); |
||||
Assert.assertEquals(oldFontSize, HtmlPaintUtils.deriveMaxFontFromRichChar(style4, testHtml4).getFRFont().getSize()); |
||||
|
||||
|
||||
} |
||||
|
||||
|
||||
} |
Loading…
Reference in new issue