同步操作将从 sulayman_tien/poco 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
//// Cell.cpp//#include "Poco/PDF/Cell.h"namespace Poco {namespace PDF {Cell::Cell(const AttributedString& content, const std::string& name, FontMapPtr pFontMap):_content(content),_name(name),_outline(OUTLINE_NONE),_lineWidth(1.0f),_encoding("UTF-8"),_trueType(true),_widthAsPct(-1){setFonts(pFontMap);}Cell::Cell(const AttributedString& content, FontMapPtr pFontMap, const std::string& encoding, bool trueType, int widthAsPct):_content(content),_outline(OUTLINE_NONE),_lineWidth(1.0f),_encoding(encoding),_trueType(trueType),_widthAsPct(widthAsPct){setFonts(pFontMap);}Cell::~Cell(){}void Cell::setFonts(FontMapPtr pFontMap){_pFontMap = pFontMap;poco_assert(!_pFontMap || (_pFontMap->size() == 4));}void Cell::borderTopBottom(bool show){borderTop(show);borderBottom(show);}void Cell::borderLeftRight(bool show){borderLeft(show);borderRight(show);}void Cell::borderAll(bool show){borderTop(show);borderBottom(show);borderLeft(show);borderRight(show);}void Cell::draw(Page& page, float x, float y, float width, float height){// uncomment to force showing of the cell outline regardless of settings//_outline = 15;if (_outline != OUTLINE_NONE){page.setLineWidth(_lineWidth);page.moveTo(x, y);if (_outline & OUTLINE_LEFT ) page.lineTo(x, y+height);page.moveTo(x, y+height);if (_outline & OUTLINE_TOP ) page.lineTo(x+width, y+height);page.moveTo(x+width, y+height);if (_outline & OUTLINE_RIGHT ) page.lineTo(x+width, y );page.moveTo(x+width, y);if (_outline & OUTLINE_BOTTOM) page.lineTo(x, y );page.stroke();}std::string text = _content;if (!text.empty()){Font originalFont = page.getFont();float originalSize = page.getFontSize();try{// font names hard coded here, needs more work on the library levelint fontStyle = _content.getAttribute(AttributedString::ATTR_STYLE);float fontSize = _content.getAttribute(AttributedString::ATTR_SIZE);if (fontStyle == AttributedString::STYLE_PLAIN){if (!_pFontMap) page.setFont("Helvetica", fontSize);else if (_trueType) page.setTTFont((*_pFontMap)[AttributedString::STYLE_PLAIN], fontSize, _encoding);else page.setFont((*_pFontMap)[AttributedString::STYLE_PLAIN], fontSize, _encoding);}else if (fontStyle & AttributedString::STYLE_BOLD){if (!_pFontMap) page.setFont("Helvetica-Bold", fontSize);else if (_trueType) page.setTTFont((*_pFontMap)[AttributedString::STYLE_BOLD], fontSize, _encoding);else page.setFont((*_pFontMap)[AttributedString::STYLE_BOLD], fontSize, _encoding);}else if (fontStyle & AttributedString::STYLE_ITALIC){if (!_pFontMap) page.setFont("Helvetica-Oblique", fontSize);else if (_trueType) page.setTTFont((*_pFontMap)[AttributedString::STYLE_ITALIC], fontSize, _encoding);else page.setFont((*_pFontMap)[AttributedString::STYLE_ITALIC], fontSize, _encoding);}else if ((fontStyle & AttributedString::STYLE_BOLD) && (fontStyle & AttributedString::STYLE_ITALIC)){if (!_pFontMap) page.setFont("Helvetica-BoldOblique", fontSize);else if (_trueType) page.setTTFont((*_pFontMap)[AttributedString::STYLE_BOLD | AttributedString::STYLE_ITALIC], fontSize, _encoding);else page.setFont((*_pFontMap)[AttributedString::STYLE_BOLD | AttributedString::STYLE_ITALIC], fontSize, _encoding);}else{throw NotFoundException(format("Unknown font style: %d", fontStyle));}float tw = page.textWidth(text);// trim text that does not fitwhile (tw > width && text.size()){text = text.substr(0, text.size() - 1);tw = page.textWidth(text);}float th = page.getFontSize();float yPos = (height <= th) ? y : y + (height - th) / 2;int align = _content.getAttribute(AttributedString::ATTR_ALIGN);switch (align){case AttributedString::ALIGN_LEFT:page.writeOnce(x + 5, yPos, text); break;case AttributedString::ALIGN_CENTER:page.writeOnce(x + (width - tw) / 2, yPos, text); break;break;case AttributedString::ALIGN_RIGHT:page.writeOnce(x + (width - tw), yPos, text); break;break;default:throw NotFoundException(format("Unknown alignment mode: %d", align));}}catch (Poco::Exception&){page.setFont(originalFont, originalSize);throw;}page.setFont(originalFont, originalSize);}}} } // namespace Poco::PDF
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。