void InitParamsServlet::service(servlet::HttpServletRequest& req, servlet::HttpServletResponse& resp) { std::ostream &out=resp.getOutputStream(); renderHeader(out); testInitParams(req,resp); renderFooter(out); }
QString reports::ReportTable::renderHTML(QWidget* widget, const QByteArray& encoding, const QString& title, bool includeCSS) { m_encoding = encoding; //this render the HEAD tag and sets the correct css file QString html = renderHeader(title, includeCSS); try { //this method is implemented by each concrete class html += renderBody(); } catch (const MyMoneyException &e) { kDebug(2) << "reports::ReportTable::renderHTML(): ERROR " << e.what(); QString error = i18n("There was an error creating your report: \"%1\".\nPlease report this error to the developer's list: [email protected]", e.what()); KMessageBox::error(widget, error, i18n("Critical Error")); html += "<h1>" + i18n("Unable to generate report") + "</h1><p>" + error + "</p>"; } //this renders a common footer html += renderFooter(); return html; }
void FileUploadServlet::service(servlet::HttpServletRequest& req, servlet::HttpServletResponse& resp) { std::ostream &out=resp.getOutputStream(); servlet::UploadedFile* file=req.getUploadedFile("theFile"); renderHeader(out); if(!req.getParameter("moo").empty()) out<<"Something was submitted: "<<req.getParameter("moo")<<std::endl; if(!file) renderForm(req, out); else renderFile(out, file); renderFooter(out); }
void AttributesServlet::service(servlet::HttpServletRequest& req, servlet::HttpServletResponse& resp) { std::ostream &out = resp.getOutputStream(); renderHeader(out); out<<"<PRE>"; out<<"\nRequest URI: "<<req.getRequestURI(); out<<"\nRequest URL: "<<req.getRequestURL(); out<<"\nContext Path: "<<req.getContextPath(); out<<"\nServletPath: "<<req.getServletPath(); out<<"\nQuery String: "<<req.getQueryString(); out<<"\nPath info: "<<req.getPathInfo(); out<<"\nLocal Address:"<<req.getLocalAddr(); out<<"\nRemote Address:"<<req.getRemoteAddr(); out<<"\nLocal Name :"<<req.getLocalName(); out<<"\nRemote Host :"<<req.getRemoteHost(); out<<"\nServlet Name :"<<getServletName(); out<<"\nPathInfo Translated: "<<req.getPathTranslated(); out<<"\nMIME type (text): "<<getServletContext().getMimeType("tests/attributes/attributes.cpp"); out<<"\nMIME type (html): "<<getServletContext().getMimeType("tests/multiple/multiple.csp"); out<<"\n</PRE>"; renderFooter(out); }
/*! Paint the contents of a QwtPlot instance into a given rectangle. \param plot Plot to be rendered \param painter Painter \param plotRect Bounding rectangle \sa renderDocument(), renderTo(), QwtPainter::setRoundingAlignment() */ void QwtPlotRenderer::render( QwtPlot *plot, QPainter *painter, const QRectF &plotRect ) const { if ( painter == 0 || !painter->isActive() || !plotRect.isValid() || plot->size().isNull() ) { return; } if ( !( d_data->discardFlags & DiscardBackground ) ) QwtPainter::drawBackgound( painter, plotRect, plot ); /* The layout engine uses the same methods as they are used by the Qt layout system. Therefore we need to calculate the layout in screen coordinates and paint with a scaled painter. */ QTransform transform; transform.scale( double( painter->device()->logicalDpiX() ) / plot->logicalDpiX(), double( painter->device()->logicalDpiY() ) / plot->logicalDpiY() ); QRectF layoutRect = transform.inverted().mapRect( plotRect ); if ( !( d_data->discardFlags & DiscardBackground ) ) { // subtract the contents margins int left, top, right, bottom; plot->getContentsMargins( &left, &top, &right, &bottom ); layoutRect.adjust( left, top, -right, -bottom ); } QwtPlotLayout *layout = plot->plotLayout(); int baseLineDists[QwtAxis::PosCount]; int canvasMargins[QwtAxis::PosCount]; for ( int axisPos = 0; axisPos < QwtAxis::PosCount; axisPos++ ) { canvasMargins[ axisPos ] = layout->canvasMargin( axisPos ); if ( d_data->layoutFlags & FrameWithScales ) { const QwtAxisId axisId( axisPos, QWT_DUMMY_ID ); QwtScaleWidget *scaleWidget = plot->axisWidget( axisId ); if ( scaleWidget ) { baseLineDists[ axisPos ] = scaleWidget->margin(); scaleWidget->setMargin( 0 ); } if ( !plot->isAxisVisible( axisId ) ) { int left = 0; int right = 0; int top = 0; int bottom = 0; // When we have a scale the frame is painted on // the position of the backbone - otherwise we // need to introduce a margin around the canvas switch( axisPos ) { case QwtAxis::yLeft: layoutRect.adjust( 1, 0, 0, 0 ); break; case QwtAxis::yRight: layoutRect.adjust( 0, 0, -1, 0 ); break; case QwtAxis::xTop: layoutRect.adjust( 0, 1, 0, 0 ); break; case QwtAxis::xBottom: layoutRect.adjust( 0, 0, 0, -1 ); break; } layoutRect.adjust( left, top, right, bottom ); } } } // Calculate the layout for the document. QwtPlotLayout::Options layoutOptions = QwtPlotLayout::IgnoreScrollbars; if ( ( d_data->layoutFlags & FrameWithScales ) || ( d_data->discardFlags & DiscardCanvasFrame ) ) { layoutOptions |= QwtPlotLayout::IgnoreFrames; } if ( d_data->discardFlags & DiscardLegend ) layoutOptions |= QwtPlotLayout::IgnoreLegend; if ( d_data->discardFlags & DiscardTitle ) layoutOptions |= QwtPlotLayout::IgnoreTitle; if ( d_data->discardFlags & DiscardFooter ) layoutOptions |= QwtPlotLayout::IgnoreFooter; layout->update( plot, layoutRect, layoutOptions ); // canvas QwtScaleMapTable mapTable = buildCanvasMaps( plot, layout->canvasRect() ); if ( updateCanvasMargins( plot, layout->canvasRect(), mapTable ) ) { // recalculate maps and layout, when the margins // have been changed layout->update( plot, layoutRect, layoutOptions ); mapTable = buildCanvasMaps( plot, layout->canvasRect() ); } // now start painting painter->save(); painter->setWorldTransform( transform, true ); renderCanvas( plot, painter, layout->canvasRect(), mapTable ); if ( !( d_data->discardFlags & DiscardTitle ) && ( !plot->titleLabel()->text().isEmpty() ) ) { renderTitle( plot, painter, layout->titleRect() ); } if ( !( d_data->discardFlags & DiscardFooter ) && ( !plot->footerLabel()->text().isEmpty() ) ) { renderFooter( plot, painter, layout->footerRect() ); } if ( !( d_data->discardFlags & DiscardLegend ) && plot->legend() && !plot->legend()->isEmpty() ) { renderLegend( plot, painter, layout->legendRect() ); } for ( int axisPos = 0; axisPos < QwtAxis::PosCount; axisPos++ ) { for ( int i = 0; i < plot->axesCount( i ); i++ ) { const QwtAxisId axisId( axisPos, i ); QwtScaleWidget *scaleWidget = plot->axisWidget( axisId ); if ( scaleWidget ) { int baseDist = scaleWidget->margin(); int startDist, endDist; scaleWidget->getBorderDistHint( startDist, endDist ); renderScale( plot, painter, axisId, startDist, endDist, baseDist, layout->scaleRect( axisId ) ); } } } painter->restore(); // restore all setting to their original attributes. for ( int axisPos = 0; axisPos < QwtAxis::PosCount; axisPos++ ) { if ( d_data->layoutFlags & FrameWithScales ) { const QwtAxisId axisId( axisPos, QWT_DUMMY_ID ); QwtScaleWidget *scaleWidget = plot->axisWidget( axisId ); if ( scaleWidget ) scaleWidget->setMargin( baseLineDists[axisPos] ); } layout->setCanvasMargin( canvasMargins[axisPos] ); } layout->invalidate(); }