void Print(Draw& w, const RichText& text, const Rect& page, const Vector<int>& pg) { LLOG("Print"); int lpage = text.GetHeight(page).page; PrintPageDraw pw(w); Size sz = w.GetPageMMs(); Size pgsz = page.Size(); int x = (6000 * sz.cx / 254 - pgsz.cx) / 2; int y = (6000 * sz.cy / 254 - pgsz.cy) / 2; for(int pi = 0; pi < pg.GetCount(); pi++) { int i = pg[pi]; w.StartPage(); w.Offset(x, y); pw.SetPage(i); PaintInfo paintinfo; paintinfo.top = PageY(i, 0); paintinfo.bottom = PageY(i + 1, 0); paintinfo.indexentry = Null; if(text.IsPrintNoLinks()) paintinfo.hyperlink = Null; text.Paint(pw, page, paintinfo); w.End(); String footer = text.GetFooter(); if(!IsNull(footer) && lpage) { String n = Format(footer, i + 1, lpage + 1); Size nsz = GetTextSize(n, Arial(90).Italic()); pw.Page(i).DrawText( x + pgsz.cx - nsz.cx, y + pgsz.cy + 100, n, Arial(90).Italic()); } w.EndPage(); } }
void RichTextView::Paint(Draw& w) { Size sz = GetSize(); w.DrawRect(sz, background); sz.cx -= margin.left + margin.right; sz.cy -= margin.top + margin.bottom; w.Clipoff(margin.left, margin.top, sz.cx, sz.cy); PaintInfo pi; if(!hldec) pi.hyperlink = Null; if(sell < selh) { pi.sell = sell; pi.selh = selh; } pi.indexentry = Null; pi.highlightpara = highlight; pi.zoom = GetZoom(); int q = sb * pi.zoom; scroller.Set(q); w.Offset(0, -q); SimplePageDraw pw(w); pi.top = PageY(0, sb); pi.bottom = PageY(0, sb + sz.cy / pi.zoom); pi.usecache = true; pi.sizetracking = sizetracking; pi.shrink_oversized_objects = shrink_oversized_objects; Color c = SColorPaper(); if(Grayscale(c) < 100) pi.coloroverride = true; text.Paint(pw, GetPage(), pi); w.End(); w.End(); }
void RichText::Paint(Draw& w, int x, int y, int cx, const PaintInfo& pinit) const { Mutex::Lock __(mutex); SimplePageDraw pw(w); PaintInfo pi(pinit); pi.top = PageY(0, 0); pi.bottom = PageY(0, INT_MAX); pi.usecache = true; pi.sizetracking = false; pi.highlight = Null; w.Offset(x, y); Paint(pw, Size(cx / pi.zoom, INT_MAX), pi); w.End(); }
Array<Drawing> RenderPages(const RichText& txt, Size pagesize) { DrawingPageDraw__ pd; pd.size = pagesize; PageY py(0, 0); PaintInfo paintinfo; paintinfo.top = PageY(0, 0); paintinfo.bottom = PageY(INT_MAX, INT_MAX); paintinfo.indexentry = Null; paintinfo.hyperlink = Null; txt.Paint(pd, PageY(0, 0), pagesize, paintinfo); pd.Flush(); return pd.page; }
Vector<RichValPos> RichText::GetValPos(const Rect& page, int type) const { Mutex::Lock __(mutex); Vector<RichValPos> f; GatherValPos(f, Context(page, PageY(0, 0)), 0, type); return f; }
void Report::Put(const RichText& txt, void *context) { PageY py(pagei, y); LLOG("Put RichText, py: " << py << ", pagerect: " << GetPageRect()); PaintInfo paintinfo; paintinfo.top = PageY(0, 0); paintinfo.bottom = PageY(INT_MAX, INT_MAX); paintinfo.indexentry = Null; paintinfo.hyperlink = Null; paintinfo.context = context; txt.Paint(*this, py, GetPageRect(), paintinfo); py = txt.GetHeight(py, GetPageRect()); LLOG("Final pos: " << py); Page(py.page); y = py.y; }
NS_IMETHODIMP UIEvent::GetPageY(int32_t* aPageY) { NS_ENSURE_ARG_POINTER(aPageY); *aPageY = PageY(); return NS_OK; }
RichHotPos RichText::GetHotPos(int x, PageY y, int tolerance, const Rect& page) const { Mutex::Lock __(mutex); RichHotPos p = RichTxt::GetHotPos(x, y, tolerance, Context(page, PageY(0, 0))); if(p.column < -2) p.table = 0; return p; }
void RichText::Paint(PageDraw& w, const Rect& page, const PaintInfo& pi) const { Mutex::Lock __(mutex); RichContext ctx = Context(page, PageY(0, 0)); int from_page = ctx.py.page; RichTxt::Paint(w, ctx, pi); PaintHeaderFooter(w, page, pi, from_page, ctx.py.page); }
PaintInfo::PaintInfo() { sell = selh = 0; tablesel = 0; top = PageY(0, 0); bottom = PageY(INT_MAX, INT_MAX); hyperlink = SColorMark(); usecache = false; sizetracking = false; showcodes = Null; spellingchecker = NULL; highlightpara = -1; highlight = Yellow(); indexentry = LtGreen(); coloroverride = false; context = NULL; showlabels = false; shrink_oversized_objects = false; }
int RichTextView::GetPointPos(Point p) const { Size sz = GetSize(); sz.cx -= margin.left + margin.right; sz.cy -= margin.top + margin.bottom; p -= margin.TopLeft(); Zoom zoom = GetZoom(); p.y += sb * zoom; return text.GetPos(p.x / zoom, PageY(0, p.y / zoom), GetPage()); }
void PutQTF(DocReport& r, const char *qtf) { RichText text; text = ParseQTF(qtf); Size sz = r.GetPageSize(); Size pgsz = r.GetSize(); PageY end = text.GetHeight(pgsz); int lastpage = end.page; int x = (sz.cx - pgsz.cx) / 2; int y = (sz.cy - pgsz.cy) / 2; for(int i = 0; i <= lastpage; i++) { if(i) r.Page(); PrintPageDraw pw(r); pw.SetPage(i); PaintInfo paintinfo; paintinfo.top = PageY(i, 0); paintinfo.bottom = PageY(i + 1, 0); text.Paint(pw, Rect(Point(x, y), pgsz), paintinfo); } r.SetYPos(end.y); }
bool RichText::GetInvalid(PageY& top, PageY& bottom, const Rect& page, int sell, int selh, int osell, int oselh) const { Mutex::Lock __(mutex); int spi = 0; int rtype = r_type; if(sell != selh || osell != oselh) { if(sell != osell) { if(rtype == NONE) { spi = FindPart(sell); rtype = spi == FindPart(osell) ? SPARA : ALL; } else rtype = ALL; } if(selh != oselh) { if(rtype == NONE) { spi = FindPart(selh); rtype = spi == FindPart(oselh) ? SPARA : ALL; } else rtype = ALL; } } bottom = top = PageY(0, page.top); if(rtype == NONE) { bottom = top; return false; } if(rtype == ALL) { bottom = GetHeight(page); return true; } #if 0 RichContext rc = Context(page, PageY(0, 0)); if(rtype == SPARA) { rc.py = top = GetPartPageY(spi, rc); bottom = GetNextPageY(spi, rc); return true; } #endif RichContext begin; if(rtype == SPARA) { // selection changed within single paragraph RichContext rc = GetPartContext(spi, Context(page)); top = rc.py; bottom = GetAdvanced(spi, rc, begin).py; return true; } RichContext rc = GetPartContext(r_parti, Context(page)); top = rc.py; if(rtype == PARA) { if(IsTable(r_parti)) switch(GetTable(r_parti).GetInvalid(top, bottom, rc)) { case -1: return false; case 0: return true; default: bottom = GetHeight(page); return true; } else { Sync(r_parti, rc); const Para& pp = part[r_parti].Get<Para>(); if(r_paraocx == pp.ccx && r_paraocy == Sum(pp.linecy, 0) + pp.ruler + pp.before + pp.after && r_keep == pp.keep && r_keepnext == pp.keepnext && r_newpage == pp.newpage) { bottom = GetAdvanced(r_parti, rc, begin).py; return true; } } } bottom = GetHeight(page); return true; }
PageY RichText::GetHeight(const Rect& page) const { Mutex::Lock __(mutex); return RichTxt::GetHeight(Context(page, PageY(0, 0))); }
NS_IMETHODIMP Touch::GetPageY(int32_t* aPageY) { *aPageY = PageY(); return NS_OK; }
RichCaret RichText::GetCaret(int pos, const Rect& page) const { Mutex::Lock __(mutex); return RichTxt::GetCaret(pos, Context(page, PageY(0, 0))); }
int RichText::GetPos(int x, PageY y, const Rect& page) const { Mutex::Lock __(mutex); return RichTxt::GetPos(x, y, Context(page, PageY(0, 0))); }
int RichText::GetVertMove(int pos, int gx, const Rect& page, int dir) const { Mutex::Lock __(mutex); return RichTxt::GetVertMove(pos, gx, Context(page, PageY(0, 0)), dir); }