On Mar 28, 12:42 pm, Eli Friedman <[EMAIL PROTECTED]> wrote:
> krithika wrote:
> > Hi,
>
> > Iam a newbie w.r.t Gecko code hacking.Iam trying to identify the exact
> > position (dom element) at which page break occured.
>
> > I looked at nsSimplePageSequenceFrame , nsPageContentFrame.
>
> > Can someone tell me where exactly
>
> > 1. I can get the dom element at which page break occurs.
> > 2. The offset left and top in the document at which page break occurs.
>
> > for instance if I can print page 1 occurs at offsetTop and offsetLet
> > so and so.From which I can take the dom element.
>
> > Thanks in Advance,
> > Krithika
>
> You should be able to get the print preview PresShell from a
> DocumentViewer if it is in print preview mode. You can use that to get
> at the frame tree using GetPrimaryFrameFor or simply starting at the
> root using GetRootFrame.  Each page has its own frame, so you should be
> able to figure out what page an element starts on pretty easily.  Use
> GetNextContinuation, and you can find the page an element ends on.  Use
> GetOffsetToExternal, and you can find the coordinates of a frame
> relative to another frame, for example a page frame.  It's a little
> confusing, but you should be able to get any rendering information you need.
>
> Of course, this is only accessible from C++, and nsIPresShell and
> nsIFrame can and will change frequently between releases.  That said, it
> should work.
>
> For 1.9, I'm planning some changes that'll make it easier to get at the
> print presentation; that's still in the early planning stages, though.
>
> -Eli

Hi,

Thanks for your inputs.We are modifying cpp sources.I tried the
same .I do a PrintPreview from my embedding code and
DocumentViewerImpl printpreview gets called and I obtained nsPresShell
and rootframe as shown below.

I need to know.

1. Is this the right place to get nsPresShell ?
2. if Yes I am not clear about how to get dom element where page
breaks from this.

Need your help.

Thanks in Advance,
Krithika

NS_IMETHODIMP
DocumentViewerImpl::PrintPreviewNavigate(PRInt16 aType, PRInt32
aPageNum)
{

  printf("DocumentViewerImpl preview navigate to page : %d
\n",aPageNum);

  nsIPresShell* presShell;
  nsresult result = NS_OK;
  result=GetPresShell(&presShell);
  if(NS_SUCCEEDED(result))
  {
    if(presShell)
    {
      printf("nsPresShell from DocumentViewerImpl %p\n",presShell);
      printf("nsFrameManager from presShell %p\n",presShell-
>FrameManager());
      nsIFrame* rootFrame = presShell->GetRootFrame();
      // came up to this point
      printf("nsIFrame root frame %p\n",rootFrame);
     // not sure how to get element where page ends and starts

    }
    else printf("nsPresShell from DocumentViewerImpl is null\n");
  }
  else printf("nsPreShell from DocumentViewerImpl Failed\n");
.....


}

_______________________________________________
dev-tech-layout mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-layout

Reply via email to