public void setUserAgentCallback(UserAgentCallback userAgentCallback) { _uac = userAgentCallback; _stylesheetFactory.setUserAgentCallback(userAgentCallback); }
public void setSupportCMYKColors(boolean b) { _stylesheetFactory.setSupportCMYKColors(b); } }
public StyleReference(UserAgentCallback userAgent) { _uac = userAgent; _stylesheetFactory = new StylesheetFactoryImpl(userAgent); }
/** * Returns a cached sheet by its key; loads and caches it if not in cache; * null if not able to load * * @param info The StylesheetInfo for this sheet * @return The stylesheet */ //TODO: this looks a bit odd public Stylesheet getStylesheet(StylesheetInfo info) { XRLog.load("Requesting stylesheet: " + info.getUri()); Stylesheet s = getCachedStylesheet(info.getUri()); if (s == null && !containsStylesheet(info.getUri())) { s = parse(info); putStylesheet(info.getUri(), s); } return s; }
/** * Sets the documentContext attribute of the StyleReference object * * @param context The new documentContext value * @param nsh The new documentContext value * @param doc The new documentContext value * @param ui */ public void setDocumentContext(SharedContext context, NamespaceHandler nsh, Document doc, UserInterface ui) { _context = context; _nsh = nsh; _doc = doc; AttributeResolver attRes = new StandardAttributeResolver(_nsh, _uac, ui); List<StylesheetInfo> infos = getStylesheets(); XRLog.match("media = " + _context.getMedia()); _matcher = new com.openhtmltopdf.css.newmatch.Matcher( new DOMTreeResolver(), attRes, _stylesheetFactory, readAndParseAll(infos, _context.getMedia()), _context.getMedia()); }
/** * Constructor for the Context object * @deprecated This stuff should go in the renderers of a specific device. */ @Deprecated public SharedContext(UserAgentCallback uac, FontResolver fr, ReplacedElementFactory ref, TextRenderer tr, float dpi) { fontResolver = fr; replacedElementFactory = ref; setMedia("screen"); this.uac = uac; setCss(new StyleReference(uac)); XRLog.render("Using CSS implementation from: " + getCss().getClass().getName()); setTextRenderer(tr); setDPI(dpi); }
private List<Stylesheet> readAndParseAll(List<StylesheetInfo> infos, String medium) { List<Stylesheet> result = new ArrayList<Stylesheet>(infos.size() + 15); for (StylesheetInfo info : infos) { if (info.appliesToMedia(medium)) { Stylesheet sheet = info.getStylesheet(); if (sheet == null) { sheet = _stylesheetFactory.getStylesheet(info); } if (sheet != null) { if (sheet.getImportRules().size() > 0) { result.addAll(readAndParseAll(sheet.getImportRules(), medium)); } result.add(sheet); } else { XRLog.load(Level.WARNING, "Unable to load CSS from "+info.getUri()); } } } return result; }
/** * Flushes any stylesheet associated with this stylereference (based on the user agent callback) that are in cache. * Deprecated for now, until we fix caching, use a new <code>StylesheetFactory</code> each run. */ @Deprecated public void flushStyleSheets() { String uri = _uac.getBaseURL(); StylesheetInfo info = new StylesheetInfo(); info.setUri(uri); info.setOrigin(StylesheetInfo.AUTHOR); if (_stylesheetFactory.containsStylesheet(uri)) { _stylesheetFactory.removeCachedStylesheet(uri); XRLog.cssParse("Removing stylesheet '" + uri + "' from cache by request."); } else { XRLog.cssParse("Requested removing stylesheet '" + uri + "', but it's not in cache."); } }
public void setSharedContext(SharedContext sharedContext) { _sharedContext = sharedContext; sharedContext.getCss().setSupportCMYKColors(true); }
@Deprecated public void flushAllStyleSheets() { _stylesheetFactory.flushCachedStylesheets(); }
public void setUserAgentCallback(UserAgentCallback userAgentCallback) { StyleReference styleReference = getCss(); if (styleReference != null) { styleReference.setUserAgentCallback(userAgentCallback); } uac = userAgentCallback; }
public boolean canHandle(LayoutContext c, FSFunction function) { return c.isPrint() && isCounter(function, "pages"); } }
public boolean canHandle(LayoutContext c, FSFunction function) { return c.isPrint() && isCounter(function, "page"); } }
/** * Description of the Method * * @param node PARAM * @return Returns * @throws Exception Throws */ private TableModel tableModel(Node node) { if (node.getNodeType() != Node.ELEMENT_NODE) { Toolkit.getDefaultToolkit().beep(); return _defaultTableModel; } Map props = _sr.getCascadedPropertiesMap((Element) node); return new PropertiesTableModel(props); }
/** * Gets the visited attribute of the StandardAttributeResolver object * * @param e PARAM * @return The visited value */ public boolean isVisited(Object e) { return isLink(e) && uac.isVisited(nsh.getLinkUri((Element) e)); }
public String calculate(RenderingContext c, FSFunction function, InlineText text) { int value = c.getRootLayer().getRelativePageCount(c); return CounterFunction.createCounterText(getListStyleType(function), value); }
public String calculate(RenderingContext c, FSFunction function, InlineText text) { int value = c.getRootLayer().getRelativePageNo(c) + 1; return CounterFunction.createCounterText(getListStyleType(function), value); }
public void setSharedContext(SharedContext sharedContext) { _sharedContext = sharedContext; sharedContext.getCss().setSupportCMYKColors(true); }
public void setSharedContext(SharedContext sharedContext) { _sharedContext = sharedContext; sharedContext.getCss().setSupportCMYKColors(true); }
public void setSharedContext(SharedContext sharedContext) { _sharedContext = sharedContext; sharedContext.getCss().setSupportCMYKColors(true); }