void fl_FootnoteLayout::_insertFootnoteContainer(fp_Container * pNewFC) { UT_DEBUGMSG(("inserting footnote container into container list\n")); fl_ContainerLayout * pUPCL = myContainingLayout(); fl_ContainerLayout * pPrevL = static_cast<fl_ContainerLayout *>(m_pLayout->findBlockAtPosition(getDocPosition()-1)); fp_Container * pPrevCon = NULL; fp_Container * pUpCon = NULL; fp_Page * pPage = NULL; // get the owning container if(pPrevL != NULL) { pPrevCon = pPrevL->getLastContainer(); if(pPrevL->getContainerType() == FL_CONTAINER_BLOCK) { // // Code to find the Line that contains the footnote reference // PT_DocPosition posFL = getDocPosition() - 1; UT_ASSERT(pPrevL->getContainerType() == FL_CONTAINER_BLOCK); fl_BlockLayout * pBL = static_cast<fl_BlockLayout *>(pPrevL); fp_Run * pRun = pBL->getFirstRun(); PT_DocPosition posBL = pBL->getPosition(); while(pRun && ((posBL + pRun->getBlockOffset() + pRun->getLength()) < posFL)) { pRun = pRun->getNextRun(); } if(pRun && pRun->getLine()) { pPrevCon = static_cast<fp_Container *>(pRun->getLine()); } } if(pPrevCon == NULL) { pPrevCon = pPrevL->getLastContainer(); } pUpCon = pPrevCon->getContainer(); } else { pUpCon = pUPCL->getLastContainer(); } if(pPrevCon) { pPage = pPrevCon->getPage(); } else { pPage = pUpCon->getPage(); } pNewFC->setContainer(NULL); // need to put onto page as well, in the appropriate place. // UT_ASSERT(pPage); if(pPage) { pPage->insertFootnoteContainer(static_cast<fp_FootnoteContainer*>(pNewFC)); m_bIsOnPage = true; } }
/*! * This method returns the length of the footnote. This is such that * getDocPosition() + getLength() is one value beyond the the EndFootnote * strux */ UT_uint32 fl_EmbedLayout::getLength(void) { UT_return_val_if_fail( m_pLayout, 0 ); PT_DocPosition startPos = getDocPosition(); pf_Frag_Strux* sdhEnd = NULL; pf_Frag_Strux* sdhStart = getStruxDocHandle(); UT_DebugOnly<bool> bres; if(getContainerType() == FL_CONTAINER_FOOTNOTE) { bres = m_pLayout->getDocument()->getNextStruxOfType(sdhStart,PTX_EndFootnote,&sdhEnd); UT_ASSERT(bres); } else if(getContainerType() == FL_CONTAINER_ENDNOTE) { bres = m_pLayout->getDocument()->getNextStruxOfType(sdhStart,PTX_EndEndnote,&sdhEnd); UT_ASSERT(bres); } else if(getContainerType() == FL_CONTAINER_ANNOTATION) { bres = m_pLayout->getDocument()->getNextStruxOfType(sdhStart,PTX_EndAnnotation,&sdhEnd); UT_ASSERT(bres); } else { UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN); return 0; } UT_ASSERT(bres && sdhEnd); PT_DocPosition endPos = m_pLayout->getDocument()->getStruxPosition(sdhEnd); UT_uint32 length = static_cast<UT_uint32>(endPos - startPos + 1); return length; }
/*! * Return the block that contains this Embedded layout */ fl_BlockLayout * fl_EmbedLayout::getContainingBlock(void) { fl_ContainerLayout * pCL = getPrev(); while(pCL && pCL->getContainerType() != FL_CONTAINER_BLOCK) { pCL = pCL->getPrev(); } if(pCL == NULL) return NULL; fl_BlockLayout * pBL = static_cast<fl_BlockLayout *>(pCL); while(pBL && pBL->getPosition(true) > getDocPosition()) pBL = pBL->getPrevBlockInDocument(); return pBL; }
/*! * This method returns the length of the Frame. This is such that * getDocPosition() + getLength() is one value beyond the the EndFrame * strux */ UT_uint32 fl_FrameLayout::getLength(void) { PT_DocPosition startPos = getDocPosition(); PL_StruxDocHandle sdhEnd = NULL; PL_StruxDocHandle sdhStart = getStruxDocHandle(); bool bres; bres = m_pLayout->getDocument()->getNextStruxOfType(sdhStart,PTX_EndFrame,&sdhEnd); UT_ASSERT(bres && sdhEnd); if(sdhEnd == NULL) { return 1; } PT_DocPosition endPos = m_pLayout->getDocument()->getStruxPosition(sdhEnd); UT_uint32 length = static_cast<UT_uint32>(endPos - startPos + 1); return length; }
fp_AnnotationRun * fl_AnnotationLayout::getAnnotationRun(void) { PT_DocPosition posFL = getDocPosition() - 1; fl_ContainerLayout * pPrevL = static_cast<fl_ContainerLayout *>(m_pLayout->findBlockAtPosition(posFL)); // get the owning container if(pPrevL != NULL) { if(pPrevL->getContainerType() == FL_CONTAINER_BLOCK) { // // Code to find the Line that contains the Annotation reference // UT_ASSERT(pPrevL->getContainerType() == FL_CONTAINER_BLOCK); fl_BlockLayout * pBL = static_cast<fl_BlockLayout *>(pPrevL); fp_Run * pRun = pBL->getFirstRun(); PT_DocPosition posBL = pBL->getPosition(); while(pRun && ((posBL + pRun->getBlockOffset() + pRun->getLength()) <= posFL)) { pRun = pRun->getNextRun(); } if(pRun && (pRun->getType() == FPRUN_HYPERLINK)) { fp_HyperlinkRun * pHRun = static_cast<fp_HyperlinkRun *>(pRun); if(pHRun->getHyperlinkType() == HYPERLINK_ANNOTATION) { fp_AnnotationRun * pARun = static_cast<fp_AnnotationRun * >(pHRun); if(pARun->getPID() == getAnnotationPID()) { return pARun; } } } else { return NULL; } } else { return NULL; } } return NULL; }