void fl_AnnotationLayout::format(void) { UT_DEBUGMSG(("SEVIOR: Formatting Annotations first container is %p\n", getFirstContainer())); if(getFirstContainer() == NULL) { getNewContainer(); } if(!m_bIsOnPage) { _insertAnnotationContainer(getFirstContainer()); } fl_ContainerLayout* pBL = getFirstLayout(); while (pBL) { pBL->format(); UT_sint32 count = 0; while(pBL->getLastContainer() == NULL || pBL->getFirstContainer()==NULL) { UT_DEBUGMSG(("Error formatting a block try again \n")); count = count + 1; pBL->format(); if(count > 3) { UT_DEBUGMSG(("Give up trying to format. Hope for the best :-( \n")); break; } } pBL = pBL->getNext(); } static_cast<fp_AnnotationContainer *>(getFirstContainer())->layout(); m_bNeedsFormat = false; m_bNeedsReformat = false; }
bool fl_FrameLayout::doclistener_changeStrux(const PX_ChangeRecord_StruxChange * pcrxc) { UT_ASSERT(pcrxc->getType()==PX_ChangeRecord::PXT_ChangeStrux); fp_FrameContainer * pFrameC = static_cast<fp_FrameContainer *>(getFirstContainer()); UT_GenericVector<fl_ContainerLayout *> AllLayouts; AllLayouts.clear(); fp_Page * pPage = NULL; UT_sint32 i = 0; if(pFrameC) { pPage = pFrameC->getPage(); UT_return_val_if_fail(pPage, false); pPage->getAllLayouts(AllLayouts); for(i=0; i< AllLayouts.getItemCount();i++) { fl_ContainerLayout * pCL = AllLayouts.getNthItem(i); pCL->collapse(); } } setAttrPropIndex(pcrxc->getIndexAP()); collapse(); lookupProperties(); format(); for(i=0; i< AllLayouts.getItemCount();i++) { fl_ContainerLayout * pCL = AllLayouts.getNthItem(i); pCL->format(); xxx_UT_DEBUGMSG(("Format block %x \n",pBL)); pCL->markAllRunsDirty(); } getDocSectionLayout()->markAllRunsDirty(); return true; }
fl_FrameLayout::~fl_FrameLayout() { // NB: be careful about the order of these UT_DEBUGMSG(("Deleting Framelayout %p \n",this)); _purgeLayout(); fp_FrameContainer * pFC = static_cast<fp_FrameContainer *>(getFirstContainer()); while(pFC) { fp_FrameContainer * pNext = static_cast<fp_FrameContainer *>(pFC->getNext()); if(pFC == static_cast<fp_FrameContainer *>(getLastContainer())) { pNext = NULL; } delete pFC; pFC = pNext; } setFirstContainer(NULL); setLastContainer(NULL); // // Remove pointers to this if they exist // if(getDocLayout() && getDocLayout()->getView()) { FV_FrameEdit * pFE = getDocLayout()->getView()->getFrameEdit(); if(pFE->getFrameLayout() == this) { pFE->setMode(FV_FrameEdit_NOT_ACTIVE); } } }
void fl_EndnoteLayout::collapse(void) { UT_DEBUGMSG(("Collapsing Endnote %p \n",this)); _localCollapse(); fp_EndnoteContainer *pFC = static_cast<fp_EndnoteContainer *>(getFirstContainer()); while(pFC) { fp_EndnoteContainer *pNext = static_cast<fp_EndnoteContainer *>(pFC->getLocalNext()); m_pLayout->removeEndnoteContainer(pFC); fp_EndnoteContainer * pPrev = static_cast<fp_EndnoteContainer *>(pFC->getPrev()); if(pPrev) { pPrev->setNext(pFC->getNext()); } if(pFC->getNext()) { pFC->getNext()->setPrev(pPrev); } delete pFC; pFC = pNext; } setFirstContainer(NULL); setLastContainer(NULL); m_bIsOnPage = false; }
void fl_AnnotationLayout::collapse(void) { _localCollapse(); fp_AnnotationContainer *pAC = static_cast<fp_AnnotationContainer *>(getFirstContainer()); if (pAC) { // // Remove it from the page. // if(pAC->getPage()) { pAC->getPage()->removeAnnotationContainer(pAC); pAC->setPage(NULL); } // // remove it from the linked list. // fp_AnnotationContainer * pPrev = static_cast<fp_AnnotationContainer *>(pAC->getPrev()); if(pPrev) { pPrev->setNext(pAC->getNext()); } if(pAC->getNext()) { pAC->getNext()->setPrev(pPrev); } delete pAC; } setFirstContainer(NULL); setLastContainer(NULL); m_bIsOnPage = false; }
void fl_FootnoteLayout::collapse(void) { _localCollapse(); fp_FootnoteContainer *pFC = static_cast<fp_FootnoteContainer *>(getFirstContainer()); if (pFC) { // // Remove it from the page. // if(pFC->getPage()) { pFC->getPage()->removeFootnoteContainer(pFC); pFC->setPage(NULL); } // // remove it from the linked list. // fp_FootnoteContainer * pPrev = static_cast<fp_FootnoteContainer *>(pFC->getPrev()); if(pPrev) { pPrev->setNext(pFC->getNext()); } if(pFC->getNext()) { pFC->getNext()->setPrev(pPrev); } delete pFC; } setFirstContainer(NULL); setLastContainer(NULL); }
void fl_FrameLayout::localCollapse(void) { // ClearScreen on our Cell. One Cell per layout. fp_FrameContainer *pFC = static_cast<fp_FrameContainer *>(getFirstContainer()); if (pFC) { pFC->clearScreen(); } // get rid of all the layout information for every containerLayout fl_ContainerLayout* pCL = getFirstLayout(); while (pCL) { pCL->collapse(); pCL = pCL->getNext(); } m_bNeedsReformat = true; }
void fl_FrameLayout::miniFormat(void) { // ingnore frames in normal view mode FV_View * pView = getDocLayout()->getView(); GR_Graphics * pG = getDocLayout()->getGraphics(); UT_return_if_fail( pView && pG ); fl_ContainerLayout* pBL = getFirstLayout(); while (pBL) { pBL->format(); pBL = pBL->getNext(); } fp_FrameContainer * pFrame = static_cast<fp_FrameContainer *>(getFirstContainer()); pFrame->layout(); pFrame->getFillType()->setWidthHeight(getDocLayout()->getGraphics(),pFrame->getFullWidth(),pFrame->getFullHeight(),false); m_bNeedsFormat = false; m_bNeedsReformat = false; }
void fl_FrameLayout::collapse(void) { FV_View * pView = getDocLayout()->getView(); if(pView) { if(pView->getFrameEdit()->getFrameLayout() == this) { pView->getFrameEdit()->setMode(FV_FrameEdit_NOT_ACTIVE); } } localCollapse(); fp_FrameContainer *pFC = static_cast<fp_FrameContainer *>(getFirstContainer()); if (pFC) { // // Remove it from the page. // if(pFC->getPage()) { pFC->getPage()->removeFrameContainer(pFC); pFC->setPage(NULL); } // // remove it from the linked list. // fp_FrameContainer * pPrev = static_cast<fp_FrameContainer *>(pFC->getPrev()); if(pPrev) { pPrev->setNext(pFC->getNext()); } if(pFC->getNext()) { pFC->getNext()->setPrev(pPrev); } delete pFC; } setFirstContainer(NULL); setLastContainer(NULL); }
fl_EndnoteLayout::~fl_EndnoteLayout() { // NB: be careful about the order of these xxx_UT_DEBUGMSG(("Deleting Endlayout %x \n",this)); _purgeLayout(); fp_EndnoteContainer * pEC = static_cast<fp_EndnoteContainer *>(getFirstContainer()); while(pEC) { fp_EndnoteContainer * pNext = static_cast<fp_EndnoteContainer *>(pEC->getNext()); if(pEC == static_cast<fp_EndnoteContainer *>(getLastContainer())) { pNext = NULL; } m_pLayout->removeEndnoteContainer(pEC); delete pEC; pEC = pNext; } setFirstContainer(NULL); setLastContainer(NULL); m_pLayout->removeEndnote(this); }
fl_AnnotationLayout::~fl_AnnotationLayout() { // NB: be careful about the order of these UT_DEBUGMSG(("Deleting Annotationlayout %p \n",this)); _purgeLayout(); fp_AnnotationContainer * pAC = static_cast<fp_AnnotationContainer *>(getFirstContainer()); while(pAC) { fp_AnnotationContainer * pNext = static_cast<fp_AnnotationContainer *>(pAC->getNext()); if(pAC == static_cast<fp_AnnotationContainer *>(getLastContainer())) { pNext = NULL; } delete pAC; pAC = pNext; } setFirstContainer(NULL); setLastContainer(NULL); UT_return_if_fail( m_pLayout ); m_pLayout->removeAnnotation(this); }
fl_FootnoteLayout::~fl_FootnoteLayout() { // NB: be careful about the order of these xxx_UT_DEBUGMSG(("Deleting Footlayout %x \n",this)); _purgeLayout(); fp_FootnoteContainer * pFC = static_cast<fp_FootnoteContainer *>(getFirstContainer()); while(pFC) { fp_FootnoteContainer * pNext = static_cast<fp_FootnoteContainer *>(pFC->getNext()); if(pFC == static_cast<fp_FootnoteContainer *>(getLastContainer())) { pNext = NULL; } delete pFC; pFC = pNext; } setFirstContainer(NULL); setLastContainer(NULL); UT_return_if_fail( m_pLayout ); m_pLayout->removeFootnote(this); }
void fl_EndnoteLayout::format(void) { UT_DEBUGMSG(("SEVIOR: Formatting Endnote first container is %p \n",getFirstContainer())); if(getFirstContainer() == NULL) { getNewContainer(); } if(!m_bIsOnPage) { _insertEndnoteContainer(getFirstContainer()); } fl_ContainerLayout* pBL = getFirstLayout(); while (pBL) { pBL->format(); UT_sint32 count = 0; while(pBL->getLastContainer() == NULL || pBL->getFirstContainer()==NULL) { UT_DEBUGMSG(("Error formatting a block try again \n")); count = count + 1; pBL->format(); if(count > 3) { UT_DEBUGMSG(("Give up trying to format. Hope for the best :-( \n")); break; } } pBL = pBL->getNext(); } static_cast<fp_EndnoteContainer *>(getFirstContainer())->layout(); m_bNeedsFormat = false; m_bNeedsReformat = false; bool bOnPage = (getFirstContainer()->getPage() != NULL); FV_View * pView = NULL; if(m_pLayout) pView = m_pLayout->getView(); if(bOnPage && pView && !pView->isLayoutFilling()) { getDocSectionLayout()->setNeedsSectionBreak(true,NULL); } UT_ASSERT(getFirstContainer()->getPage()); }
bool fl_ContainerLayout::isOnScreen() const { // we check if any of our containers is on screen // however, we will not call fp_Container::isOnScreen() to avoid // unnecessary overhead if(isCollapsed()) return false; UT_return_val_if_fail(getDocLayout(),false); FV_View *pView = getDocLayout()->getView(); bool bShowHidden = pView && pView->getShowPara(); bool bHidden = ((m_eHidden == FP_HIDDEN_TEXT && !bShowHidden) || m_eHidden == FP_HIDDEN_REVISION || m_eHidden == FP_HIDDEN_REVISION_AND_TEXT); if(bHidden) return false; UT_GenericVector<UT_Rect*> vRect; UT_GenericVector<fp_Page*> vPages; pView->getVisibleDocumentPagesAndRectangles(vRect, vPages); UT_uint32 iCount = vPages.getItemCount(); if(!iCount) return false; bool bRet = false; fp_Container * pC = getFirstContainer(); if(!pC) return false; fp_Container *pCEnd = getLastContainer(); while(pC) { fp_Page * pMyPage = pC->getPage(); if(pMyPage) { for(UT_uint32 i = 0; i < iCount; i++) { fp_Page * pPage = vPages.getNthItem(i); if(pPage == pMyPage) { UT_Rect r; UT_Rect *pR = vRect.getNthItem(i); if(!pC->getPageRelativeOffsets(r)) break; bRet = r.intersectsRect(pR); break; } } } if(bRet || pC == pCEnd) break; pC = static_cast<fp_Container*>(pC->getNext()); } UT_VECTOR_PURGEALL(UT_Rect*,vRect); return bRet; }
void fl_FrameLayout::format(void) { // ingnore frames in normal view mode FV_View * pView = getDocLayout()->getView(); GR_Graphics * pG = getDocLayout()->getGraphics(); UT_return_if_fail( pView && pG ); xxx_UT_DEBUGMSG(("SEVIOR: Formatting first container is %x \n",getFirstContainer())); if(isHidden() > FP_VISIBLE) { xxx_UT_DEBUGMSG(("Don't format FRAME coz I'm hidden! \n")); return; } if(getFirstContainer() == NULL) { getNewContainer(); } fl_ContainerLayout* pBL2 = getFirstLayout(); while (pBL2) { pBL2->format(); UT_sint32 count = 0; while(pBL2->getLastContainer() == NULL || pBL2->getFirstContainer()==NULL) { UT_DEBUGMSG(("Error formatting a block try again \n")); count = count + 1; pBL2->format(); if(count > 3) { UT_DEBUGMSG(("Give up trying to format. Hope for the best :-( \n")); break; } } pBL2 = pBL2->getNext(); } static_cast<fp_FrameContainer *>(getFirstContainer())->layout(); bool bPlacedOnPage = false; if(!m_bIsOnPage) { // // Place it on the correct page. // fl_ContainerLayout * pCL = getPrev(); while(pCL && ((pCL->getContainerType() == FL_CONTAINER_ENDNOTE) || (pCL->getContainerType() == FL_CONTAINER_FOOTNOTE) || (pCL->getContainerType() == FL_CONTAINER_TOC) || (pCL->getContainerType() == FL_CONTAINER_FRAME) )) { pCL = pCL->getPrev(); } if(pCL == NULL) { UT_DEBUGMSG(("No BlockLayout before this frame! \n")); UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN); return; } fl_BlockLayout * pBL = NULL; if(pCL->getContainerType() != FL_CONTAINER_BLOCK) { pCL = pCL->getPrevBlockInDocument(); pBL = static_cast<fl_BlockLayout *>(pCL); } else { pBL = static_cast<fl_BlockLayout *>(pCL); } UT_return_if_fail(pBL); UT_sint32 count = pBL->getNumFrames(); if(count == 0) { UT_DEBUGMSG(("BlockLayout does not contain this frame! \n")); UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN); return; } UT_sint32 i =0; for(i=0; i<count; i++) { fl_FrameLayout * pFL = pBL->getNthFrameLayout(i); if(pFL == this) { break; } } if(count == i) { UT_DEBUGMSG(("BlockLayout does not contain this frame! \n")); UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN); return; } if(!pBL->isCollapsed()) { m_bIsOnPage = pBL->setFramesOnPage(NULL); if(!m_bIsOnPage) { setNeedsReformat(this); } } if(m_bIsOnPage) bPlacedOnPage = true; } m_bNeedsFormat = m_bIsOnPage; m_bNeedsReformat = m_bIsOnPage; if(!m_bIsOnPage) { setNeedsReformat(this); } if(!m_bIsOnPage) { return; } if(bPlacedOnPage) { fl_DocSectionLayout * pDSL = getDocSectionLayout(); fp_FrameContainer * pFC = static_cast<fp_FrameContainer *>(getFirstContainer()); if(pFC) { pDSL->setNeedsSectionBreak(true,pFC->getPage()); } } }
bool fl_FrameLayout::doclistener_deleteStrux(const PX_ChangeRecord_Strux * pcrx) { UT_UNUSED(pcrx); UT_ASSERT(pcrx->getType()==PX_ChangeRecord::PXT_DeleteStrux); #if 0 fp_FrameContainer * pFrameC = getFirstContainer(); if(pFrameC && pFrameC->getPage()) { pFrameC->getPage()->markDirtyOverlappingRuns(pFrameC); } #endif fp_FrameContainer * pFrameC = static_cast<fp_FrameContainer *>(getFirstContainer()); UT_GenericVector<fl_BlockLayout *> vecBlocks; pFrameC->getBlocksAroundFrame(vecBlocks); UT_sint32 i = 0; for(i=0; i< vecBlocks.getItemCount();i++) { fl_BlockLayout * pBL = vecBlocks.getNthItem(i); pBL->collapse(); xxx_UT_DEBUGMSG(("Collapse block %x \n",pBL)); } // // Remove all remaining structures // collapse(); // UT_ASSERT(pcrx->getStruxType()== PTX_SectionFrame); // fl_ContainerLayout * pCL = getPrev(); myContainingLayout()->remove(this); UT_DEBUGMSG(("Unlinking frame Layout %p \n",this)); // // Remove from the list of frames in the previous block // while(pCL && pCL->getContainerType() != FL_CONTAINER_BLOCK) { pCL = pCL->getPrev(); } if(pCL == NULL) { UT_DEBUGMSG(("No BlockLayout before this frame! \n")); return false; } fl_BlockLayout * pBL = static_cast<fl_BlockLayout *>(pCL); bool bFound = false; for(i=0; i<pBL->getNumFrames() && !bFound;i++) { fl_FrameLayout * pF = pBL->getNthFrameLayout(i); if(pF == this) { bFound = true; } } if(bFound) { pBL->removeFrame(this); } else { UT_DEBUGMSG(("Whoops! not Frame found. Try ahead \n")); pCL = this; while(pCL && pCL->getContainerType() != FL_CONTAINER_BLOCK) { pCL = pCL->getNext(); } if(pCL == NULL) { UT_DEBUGMSG(("No BlockLayout before this frame! \n")); return false; } pBL = static_cast<fl_BlockLayout *>(pCL); pBL->removeFrame(this); } for(i=0; i< vecBlocks.getItemCount();i++) { pBL = vecBlocks.getNthItem(i); pBL->format(); xxx_UT_DEBUGMSG(("format block %x \n",pBL)); } delete this; // TODO whoa! this construct is VERY dangerous. return true; }