/** {@inheritDoc} */ @Override protected final synchronized void onOpen() { final ITextOutput out; StreamEncoding<?, ?> e; String s; super.onOpen(); this.getFileCollector().addFile(this.getDocumentPath(), XHTML.XHTML_1_0); out = this.getTextOutput(); out.append(_XHTML10Document.XML_HEADER_BEGIN); e = StreamEncoding.getStreamEncoding(out); if ((e == null) || (e == StreamEncoding.TEXT) || (e == StreamEncoding.BINARY)) { e = StreamEncoding.getDefaultTextEncoding(); } s = e.name(); out.append(s); out.append(_XHTML10Document.XML_HEADER_END); out.appendLineBreak(); out.append(_XHTML10Document.DOC_TYPE); out.appendLineBreak(); out.append(_XHTML10Document.HTML_BEGIN); out.append(_XHTML10Document.HEAD_BEGIN); out.append(_XHTML10Document.META_CHARSET_BEGIN); out.append(s); out.append(XHTML10Driver.EMPTY_ATTRIB_TAG_END); out.append(_XHTML10Document.META_STYLE_TYPE); out.append(_XHTML10Document.DEFAULT_CSS_LINK); out.append(_XHTML10Document.CSS_DEFAULT); out.append(XHTML10Driver.EMPTY_ATTRIB_TAG_END); out.append(_XHTML10Document.PRINT_CSS_LINK); out.append(_XHTML10Document.CSS_PRINT); out.append(XHTML10Driver.EMPTY_ATTRIB_TAG_END); }
/** {@inheritDoc} */ @Override protected void postProcess( final Set<IStyle> usedStyles, final ArrayListView<ImmutableAssociation<Path, IFileType>> paths) { Path path; String s; char ch; int i; try { for (final String name : new String[] {_XHTML10Document.CSS_DEFAULT, _XHTML10Document.CSS_PRINT}) { path = PathUtils.normalize(this.getDocumentFolder().resolve(name)); try (final OutputStream os = PathUtils.openOutputStream(path)) { try (final OutputStreamWriter osw = new OutputStreamWriter(os)) { try (final BufferedWriter bw = new BufferedWriter(osw)) { this.__createStyles(bw, usedStyles); try (final InputStream is = _XHTML10Document.class.getResourceAsStream(name)) { try (final InputStreamReader isr = new InputStreamReader(is)) { try (final BufferedReader br = new BufferedReader(isr)) { while ((s = br.readLine()) != null) { s = TextUtils.prepare(s); if (s != null) { i = s.indexOf(':'); if (i > 0) { ch = ':'; } else { i = s.indexOf('{'); if (i > 0) { ch = '{'; } else { i = s.indexOf('}'); if (i > 0) { ch = '}'; } else { ch = 0; } } } if (i > 0) { bw.write(s.substring(0, i).trim()); bw.write(ch); bw.write(s.substring(i + 1).trim()); } else { bw.write(s); } } } } } } } } } catch (final Throwable t) { ErrorUtils.logError( this.getLogger(), // "Error while building Cascading Style Sheet (CSS) for XHTML 1.0 Document. This will make the document look odd.", //$NON-NLS-1$ t, true, RethrowMode.AS_RUNTIME_EXCEPTION); } this.getFileCollector().addFile(path, EWebFileTypes.CSS); } } finally { super.postProcess(usedStyles, paths); } }