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; }
void fp_FrameContainer::setHeight(UT_sint32 iY) { if(iY != getFullHeight()) { xxx_UT_DEBUGMSG((" SetHeight Frame iY %d Fullheight %d Height %d \n",iY,getFullHeight(),getHeight())); clearScreen(); fp_VerticalContainer::setHeight(iY); fp_Page * pPage = getPage(); getDocSectionLayout()->setNeedsSectionBreak(true,pPage); } }
/*! * Draw the frame handles */ void fp_FrameContainer::drawHandles(dg_DrawArgs * pDA) { if(getView() == NULL) { getSectionLayout()->format(); getSectionLayout()->setNeedsReformat(getSectionLayout()); } if(getView() == NULL) { return; } if(!getPage()) { return; } // // Only fill to the bottom of the viewed page. // GR_Graphics * pG = pDA->pG; UT_sint32 iFullHeight = getFullHeight(); fl_DocSectionLayout * pDSL = getDocSectionLayout(); UT_sint32 iMaxHeight = 0; if(!pG->queryProperties(GR_Graphics::DGP_PAPER) && (getView()->getViewMode() != VIEW_PRINT)) { iMaxHeight = pDSL->getActualColumnHeight(); } else { iMaxHeight = getPage()->getHeight(); } UT_sint32 iBot = getFullY()+iFullHeight; if(iBot > iMaxHeight) { iFullHeight = iFullHeight - (iBot-iMaxHeight); } UT_sint32 iXlow = pDA->xoff - m_iXpad; UT_sint32 iYlow = pDA->yoff - m_iYpad; UT_Rect box(iXlow + pDA->pG->tlu(2), iYlow + pDA->pG->tlu(2), getFullWidth() - pDA->pG->tlu(4), iFullHeight - pDA->pG->tlu(4)); getPage()->expandDamageRect(box.left,box.top,box.width,box.height); getView()->drawSelectionBox(box, true); }
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()); }
/*! * Draw the frame boundaries */ void fp_FrameContainer::drawBoundaries(dg_DrawArgs * pDA) { UT_sint32 iXlow = pDA->xoff - m_iXpad; UT_sint32 iXhigh = iXlow + getFullWidth() ; UT_sint32 iYlow = pDA->yoff - m_iYpad; UT_sint32 iYhigh = iYlow + getFullHeight(); GR_Graphics * pG = pDA->pG; if(getPage()) { getPage()->expandDamageRect(iXlow,iYlow,getFullWidth(),getFullHeight()); // // Only fill to the bottom of the viewed page. // UT_sint32 iFullHeight = getFullHeight(); fl_DocSectionLayout * pDSL = getDocSectionLayout(); UT_sint32 iMaxHeight = 0; if(!pG->queryProperties(GR_Graphics::DGP_PAPER) && (getView()->getViewMode() != VIEW_PRINT)) { iMaxHeight = pDSL->getActualColumnHeight(); } else { iMaxHeight = getPage()->getHeight(); } UT_sint32 iBot = getFullY()+iFullHeight; if(iBot > iMaxHeight) { iFullHeight = iFullHeight - (iBot-iMaxHeight); iYhigh = iFullHeight; } } _drawLine(m_lineTop,iXlow,iYlow,iXhigh,iYlow,pDA->pG); // top _drawLine(m_lineRight,iXhigh,iYlow,iXhigh,iYhigh,pDA->pG); // right _drawLine(m_lineBottom,iXlow,iYhigh,iXhigh,iYhigh,pDA->pG); // bottom _drawLine(m_lineLeft,iXlow,iYlow,iXlow,iYhigh,pDA->pG); // left }
void fp_AnnotationContainer::layout(void) { _setMaxContainerHeight(0); UT_sint32 iY = 0, iPrevY = 0; iY= 0; fl_DocSectionLayout * pDSL = getDocSectionLayout(); UT_sint32 iMaxFootHeight = 0; iMaxFootHeight = pDSL->getActualColumnHeight(); iMaxFootHeight -= getGraphics()->tlu(20)*3; UT_uint32 iCountContainers = countCons(); fp_Container *pContainer, *pPrevContainer = NULL; for (UT_uint32 i=0; i < iCountContainers; i++) { pContainer = static_cast<fp_Container*>(getNthCon(i)); // // This is to speedup redraws. // if(pContainer->getHeight() > _getMaxContainerHeight()) _setMaxContainerHeight(pContainer->getHeight()); if(pContainer->getY() != iY) { pContainer->clearScreen(); } pContainer->setY(iY); UT_sint32 iContainerHeight = pContainer->getHeight(); UT_sint32 iContainerMarginAfter = pContainer->getMarginAfter(); iY += iContainerHeight; iY += iContainerMarginAfter; //iY += 0.5; if(iY > iMaxFootHeight) { iY = iMaxFootHeight; } else { if (pPrevContainer) { pPrevContainer->setAssignedScreenHeight(iY - iPrevY); } } pPrevContainer = pContainer; iPrevY = iY; } // Correct height position of the last line if (pPrevContainer) { pPrevContainer->setAssignedScreenHeight(iY - iPrevY + 1); } if (getHeight() == iY) { return; } setHeight(iY); // UT_ASSERT(pPage); fp_Page * pPage = getPage(); if(pPage) { pPage->annotationHeightChanged(); } }
/*! Draw container content \param pDA Draw arguments */ void fp_FootnoteContainer::draw(dg_DrawArgs* pDA) { if(getPage() == NULL) { return; } UT_sint32 pos = getPage()->findFootnoteContainer(this); fl_DocSectionLayout * pDSL2 = getDocSectionLayout(); UT_sint32 iMaxFootHeight = pDSL2->getActualColumnHeight(); iMaxFootHeight -= pDA->pG->tlu(20)*3; xxx_UT_DEBUGMSG(("fp_Footnote:draw: pos %d \n",pos)); if(pos == 0) { UT_RGBColor black(0,0,0); fl_DocSectionLayout * pDSL = getPage()->getOwningSection(); UT_sint32 iLeftMargin = pDSL->getLeftMargin(); UT_sint32 iRightMargin = pDSL->getRightMargin(); // UT_sint32 diff = getPage()->getWidth()/10; UT_sint32 diff = 0; // FIXME make a property UT_sint32 xoffStart = pDA->xoff + diff; UT_sint32 width = (getPage()->getWidth() - iLeftMargin -iRightMargin)/3; UT_sint32 xoffEnd = pDA->xoff + width; UT_sint32 yline = pDA->yoff; pDA->pG->setColor(black); pDA->pG->setLineProperties(pDA->pG->tlu(1), GR_Graphics::JOIN_MITER, GR_Graphics::CAP_PROJECTING, GR_Graphics::LINE_SOLID); UT_sint32 iLineThick = pDSL->getFootnoteLineThickness(); iLineThick = UT_MAX(1,iLineThick); pDA->pG->setLineWidth(iLineThick); yline = yline - iLineThick - 3; // FIXME This should not be a magic numer! xxx_UT_DEBUGMSG(("Drawline form (%d,%d) to (%d,%d) \n",xoffStart,yline,xoffEnd,yline)); GR_Painter painter (pDA->pG); painter.drawLine(xoffStart, yline, xoffEnd, yline); } xxx_UT_DEBUGMSG(("Footnote: Drawing unbroken footnote %x x %d, y %d width %d height %d \n",this,getX(),getY(),getWidth(),getHeight())); // // Only draw the lines in the clipping region. // dg_DrawArgs da = *pDA; UT_uint32 count = countCons(); UT_sint32 iTotHeight = 0; for (UT_uint32 i = 0; i<count; i++) { fp_Container* pContainer = static_cast<fp_Container *>(getNthCon(i)); da.xoff = pDA->xoff + pContainer->getX(); da.yoff = pDA->yoff + pContainer->getY(); pContainer->draw(&da); iTotHeight += pContainer->getHeight(); iTotHeight += pContainer->getMarginAfter(); if(iTotHeight > iMaxFootHeight) break; } _drawBoundaries(pDA); }
/*! * Create a new containerLayout and insert it into the linked list of * layouts held by this class. * Returns a pointer to the generated ContainerLayout class. */ fl_ContainerLayout * fl_ContainerLayout::insert(pf_Frag_Strux* sdh, fl_ContainerLayout * pPrev, PT_AttrPropIndex indexAP,fl_ContainerType iType) { fl_ContainerLayout* pL=NULL; switch (iType) { case FL_CONTAINER_BLOCK: // we have a problem here -- the block needs to be in the list before the consturction is completed if(getContainerType() == FL_CONTAINER_HDRFTR) { pL = static_cast<fl_ContainerLayout *>(new fl_BlockLayout(sdh, pPrev, static_cast<fl_SectionLayout *>(this), indexAP,true)); } else if ((pPrev!= NULL) && (pPrev->getContainerType() == FL_CONTAINER_TABLE)) { pL = static_cast<fl_ContainerLayout *>(new fl_BlockLayout(sdh,pPrev, static_cast<fl_SectionLayout *>(pPrev->myContainingLayout()), indexAP)); } else if ((pPrev!= NULL) && (pPrev->getContainerType() == FL_CONTAINER_ANNOTATION)) { pL = static_cast<fl_ContainerLayout *>(new fl_BlockLayout(sdh,pPrev, static_cast<fl_SectionLayout *>(this), indexAP)); fp_Container * pFirstC = pL->getFirstContainer(); // // This sets indent for a annotation label. // if(pFirstC) pFirstC->recalcMaxWidth(true); } else if ((pPrev!= NULL) && (pPrev->getContainerType() == FL_CONTAINER_RDFANCHOR)) { pL = static_cast<fl_ContainerLayout *>(new fl_BlockLayout(sdh,pPrev, static_cast<fl_SectionLayout *>(this), indexAP)); } else { pL = static_cast<fl_ContainerLayout *>(new fl_BlockLayout(sdh, static_cast<fl_BlockLayout *>(pPrev), static_cast<fl_SectionLayout *>(this), indexAP)); } break; case FL_CONTAINER_TABLE: pL = static_cast<fl_ContainerLayout *>(new fl_TableLayout(getDocLayout(),sdh, indexAP, this)); if(pPrev && (pPrev == this)) { fl_ContainerLayout * pOldFirst = pPrev->getFirstLayout(); pPrev->setFirstLayout(pL); pL->setNext(pOldFirst); if(pOldFirst) { pOldFirst->setPrev(pL); } if(pPrev->getLastLayout() == NULL) { pPrev->setLastLayout(pL); } } else if (pPrev) { pPrev->_insertIntoList(pL); } // // Now put the Physical Container into the vertical container that contains it. // { fp_TableContainer * pTab = static_cast<fp_TableContainer *>(static_cast<fl_TableLayout *>(pL)->getLastContainer()); static_cast<fl_TableLayout *>(pL)->insertTableContainer(static_cast<fp_TableContainer *>(pTab)); } if(getContainerType() == FL_CONTAINER_CELL) { fl_CellLayout * pCell = static_cast<fl_CellLayout *>(this); pCell->incNumNestedTables(); fl_TableLayout * pTab = static_cast<fl_TableLayout *>(pCell->myContainingLayout()); pTab->incNumNestedTables(); } break; case FL_CONTAINER_CELL: pL = static_cast<fl_ContainerLayout *>(new fl_CellLayout(getDocLayout(),sdh, indexAP, this)); if (pPrev) { pPrev->_insertIntoList(pL); } else { _insertFirst(pL); } break; case FL_CONTAINER_FRAME: { pL = static_cast<fl_ContainerLayout *> (new fl_FrameLayout(getDocLayout(), sdh, indexAP, this)); if (pPrev) { while(pPrev && pPrev->getContainerType() != FL_CONTAINER_BLOCK) { pPrev = pPrev->getPrev(); } // // Add the frame to the list in te previous block. // if(pPrev) { pPrev->_insertIntoList(pL); pPrev->addFrame(static_cast<fl_FrameLayout *>(pL)); } } break; } case FL_CONTAINER_FOOTNOTE: { fl_DocSectionLayout * pDSL = getDocSectionLayout(); pL = static_cast<fl_ContainerLayout *>(new fl_FootnoteLayout(getDocLayout(), pDSL, sdh, indexAP, this)); if (pPrev) pPrev->_insertIntoList(pL); break; } case FL_CONTAINER_ANNOTATION: { fl_DocSectionLayout * pDSL = getDocSectionLayout(); pL = static_cast<fl_ContainerLayout *>(new fl_AnnotationLayout(getDocLayout(), pDSL, sdh, indexAP, this)); if (pPrev) pPrev->_insertIntoList(pL); break; } case FL_CONTAINER_TOC: { fl_DocSectionLayout * pDSL = getDocSectionLayout(); pL = static_cast<fl_ContainerLayout *>(new fl_TOCLayout(getDocLayout(), pDSL, sdh, indexAP, this)); if (pPrev) pPrev->_insertIntoList(pL); static_cast<fl_TOCLayout *>(pL)->getNewContainer(NULL); break; } case FL_CONTAINER_ENDNOTE: { fl_DocSectionLayout * pDSL = getDocSectionLayout(); pL = static_cast<fl_ContainerLayout *>(new fl_EndnoteLayout(getDocLayout(), pDSL, sdh, indexAP, this)); if (pPrev) pPrev->_insertIntoList(pL); break; } default: UT_ASSERT(UT_SHOULD_NOT_HAPPEN); break; } if (pL == NULL) { return pL; } if (!m_pLastL) { UT_ASSERT(!m_pFirstL); m_pFirstL = pL; m_pLastL = pL; } else if (m_pLastL == pPrev) { m_pLastL = pL; } else if (!pPrev) { m_pFirstL = pL; } if(getContainerType() == FL_CONTAINER_CELL) { static_cast<fl_TableLayout *>(myContainingLayout())->setDirty(); } return pL; }
/*! Draw container content \param pDA Draw arguments */ void fp_FrameContainer::draw(dg_DrawArgs* pDA) { FV_View * pView = getView(); UT_return_if_fail( pView); xxx_UT_DEBUGMSG(("FrameContainer %x called, page %x \n",this,getPage())); if(getPage() == NULL) { getSectionLayout()->format(); getSectionLayout()->setNeedsReformat(getSectionLayout()); if(getPage() == NULL) { return; } } if(pView) { if(pView->getFrameEdit()->getFrameEditMode() == FV_FrameEdit_DRAG_EXISTING) { if((pView->getFrameEdit()->getFrameContainer() == this)) { return; } } } // // Only draw the lines in the clipping region. // /* [Somewhere down here is where the logic to only draw the region of the frame which is within the complement of the union of all higher frames needs to be. We need to draw the applicable region of the rectangle we're on, then unify it with (if applicable) the higher union.] <-- Possibly obsolete comment, not sure. I think I might have landed on an alternative solution involving more rearranging of the storage of the FrameContainers, based on their z-index. Not sure how far I got with that or if it worked either. See also abi bug 7664 and the original discussions about defining the undefinedness of layered frame behaviour. */ if(m_bOverWrote) { pDA->bDirtyRunsOnly = false; } dg_DrawArgs da = *pDA; GR_Graphics * pG = da.pG; UT_return_if_fail( pG); UT_sint32 x = pDA->xoff - m_iXpad; UT_sint32 y = pDA->yoff - m_iYpad; getPage()->expandDamageRect(x,y,getFullWidth(),getFullHeight()); if(!pDA->bDirtyRunsOnly || m_bNeverDrawn) { if(m_bNeverDrawn) { pDA->bDirtyRunsOnly= false; } UT_sint32 srcX,srcY; getSectionLayout()->checkGraphicTick(pG); srcX = -m_iXpad; srcY = -m_iYpad; // // Only fill to the bottom of the viewed page. // UT_sint32 iFullHeight = getFullHeight(); fl_DocSectionLayout * pDSL = getDocSectionLayout(); UT_sint32 iMaxHeight = 0; if(!pG->queryProperties(GR_Graphics::DGP_PAPER) && (pView->getViewMode() != VIEW_PRINT)) { iMaxHeight = pDSL->getActualColumnHeight(); } else { iMaxHeight = getPage()->getHeight(); } UT_sint32 iBot = getFullY()+iFullHeight; if(iBot > iMaxHeight) { iFullHeight = iFullHeight - (iBot-iMaxHeight); } getFillType()->Fill(pG,srcX,srcY,x,y,getFullWidth(),iFullHeight); m_bNeverDrawn = false; } UT_uint32 count = countCons(); UT_DEBUGMSG(("Number of containers in frame %d \n",count)); const UT_Rect * pPrevRect = pDA->pG->getClipRect(); UT_Rect * pRect = getScreenRect(); UT_Rect newRect; bool bRemoveRectAfter = false; bool bSetOrigClip = false; bool bSkip = false; if((pPrevRect == NULL) && pG->queryProperties(GR_Graphics::DGP_SCREEN)) { pDA->pG->setClipRect(pRect); UT_DEBUGMSG(("Clip bottom is %d \n",pRect->top + pRect->height)); bRemoveRectAfter = true; } else if(pPrevRect && !pRect->intersectsRect(pPrevRect)) { bSkip = true; xxx_UT_DEBUGMSG(("External Clip bottom is %d \n",pRect->top + pRect->height)); } else if(pPrevRect) { newRect.top = UT_MAX(pPrevRect->top,pRect->top); UT_sint32 iBotPrev = pPrevRect->height + pPrevRect->top; UT_sint32 iBot = pRect->height + pRect->top; newRect.height = UT_MIN(iBotPrev,iBot) - newRect.top; newRect.width = pPrevRect->width; newRect.left = pPrevRect->left; if((newRect.height > 0) && pDA->pG->queryProperties(GR_Graphics::DGP_SCREEN)) { pDA->pG->setClipRect(&newRect); bSetOrigClip = true; } else { bSkip = true; } } if(!bSkip) { for (UT_uint32 i = 0; i<count; i++) { fp_ContainerObject* pContainer = static_cast<fp_ContainerObject*>(getNthCon(i)); da.xoff = pDA->xoff + pContainer->getX(); da.yoff = pDA->yoff + pContainer->getY(); pContainer->draw(&da); } } m_bNeverDrawn = false; m_bOverWrote = false; if(bRemoveRectAfter) { pDA->pG->setClipRect(NULL); } if(bSetOrigClip) { pDA->pG->setClipRect(pPrevRect); } delete pRect; drawBoundaries(pDA); }
/*! this function is only to be called by fl_ContainerLayout::lookupProperties() all other code must call lookupProperties() instead */ void fl_FrameLayout::_lookupProperties(const PP_AttrProp* pSectionAP) { UT_return_if_fail(pSectionAP); FV_View * pView = getDocLayout()->getView(); GR_Graphics * pG = getDocLayout()->getGraphics(); UT_return_if_fail( pView && pG ); const gchar *pszFrameType = NULL; const gchar *pszPositionTo = NULL; const gchar *pszWrapMode = NULL; const gchar *pszXpos = NULL; const gchar *pszYpos = NULL; const gchar *pszColXpos = NULL; const gchar *pszColYpos = NULL; const gchar *pszPageXpos = NULL; const gchar *pszPageYpos = NULL; const gchar *pszWidth = NULL; const gchar *pszHeight = NULL; const gchar *pszXpad = NULL; const gchar *pszYpad = NULL; const gchar * pszColor = NULL; const gchar * pszBorderColor = NULL; const gchar * pszBorderStyle = NULL; const gchar * pszBorderWidth = NULL; const gchar * pszBoundingSpace = NULL; const gchar * pszTightWrapped = NULL; const gchar * pszPrefPage = NULL; const gchar * pszExpandHeight = NULL; const gchar * pszPercentWidth = NULL; const gchar * pszMinHeight = NULL; // Frame Type if(!pSectionAP || !pSectionAP->getProperty("frame-type",pszFrameType)) { m_iFrameType = FL_FRAME_TEXTBOX_TYPE; } else if(strcmp(pszFrameType,"textbox") == 0) { m_iFrameType = FL_FRAME_TEXTBOX_TYPE; } else if(strcmp(pszFrameType,"image") == 0) { m_iFrameType = FL_FRAME_WRAPPER_IMAGE; } else { UT_DEBUGMSG(("Unknown Frame Type %s \n",pszFrameType)); UT_ASSERT(UT_SHOULD_NOT_HAPPEN); m_iFrameType = FL_FRAME_TEXTBOX_TYPE; } // Position-to if((!pSectionAP || !pSectionAP->getProperty("position-to",pszPositionTo))) { m_iFramePositionTo = FL_FRAME_POSITIONED_TO_BLOCK; } else if(strcmp(pszPositionTo,"block-above-text") == 0) { m_iFramePositionTo = FL_FRAME_POSITIONED_TO_BLOCK; } else if(strcmp(pszPositionTo,"column-above-text") == 0) { m_iFramePositionTo = FL_FRAME_POSITIONED_TO_COLUMN; } else if(strcmp(pszPositionTo,"page-above-text") == 0) { m_iFramePositionTo = FL_FRAME_POSITIONED_TO_PAGE; } else { UT_DEBUGMSG(("Unknown Position to %s \n",pszPositionTo)); UT_ASSERT(UT_SHOULD_NOT_HAPPEN); m_iFramePositionTo = FL_FRAME_POSITIONED_TO_BLOCK; } // wrap-mode if(!pSectionAP || !pSectionAP->getProperty("wrap-mode",pszWrapMode)) { m_iFrameWrapMode = FL_FRAME_ABOVE_TEXT; } else if(strcmp(pszWrapMode,"above-text") == 0) { m_iFrameWrapMode = FL_FRAME_ABOVE_TEXT; } else if(strcmp(pszWrapMode,"below-text") == 0) { m_iFrameWrapMode = FL_FRAME_BELOW_TEXT; } else if(strcmp(pszWrapMode,"wrapped-to-right") == 0) { m_iFrameWrapMode = FL_FRAME_WRAPPED_TO_RIGHT; } else if(strcmp(pszWrapMode,"wrapped-to-left") == 0) { m_iFrameWrapMode = FL_FRAME_WRAPPED_TO_LEFT; } else if(strcmp(pszWrapMode,"wrapped-both") == 0) { m_iFrameWrapMode = FL_FRAME_WRAPPED_BOTH_SIDES; } else if(strcmp(pszWrapMode,"wrapped-topbot") == 0) { m_iFrameWrapMode = FL_FRAME_WRAPPED_TOPBOT; } else { UT_DEBUGMSG(("Unknown wrap-mode %s \n",pszWrapMode)); UT_ASSERT(UT_SHOULD_NOT_HAPPEN); m_iFrameWrapMode = FL_FRAME_ABOVE_TEXT; } // // Wrap type // if(!pSectionAP || !pSectionAP->getProperty("tight-wrap",pszTightWrapped)) { m_bIsTightWrap = false; } else if(strcmp(pszTightWrapped,"1") == 0) { m_bIsTightWrap = true; } else { m_bIsTightWrap = false; } // // Should be relocated before final placement // if(!pSectionAP || !pSectionAP->getProperty("relocate",pszTightWrapped)) { m_bRelocate = false; } else if(strcmp(pszTightWrapped,"1") == 0) { m_bRelocate = true; } else { m_bRelocate = false; } // Xpos if(!pSectionAP || !pSectionAP->getProperty("xpos",pszXpos)) { m_iXpos = 0; } else { m_iXpos = UT_convertToLogicalUnits(pszXpos); } UT_DEBUGMSG(("xpos for frame is %s \n",pszXpos)); // Ypos if(!pSectionAP || !pSectionAP->getProperty("ypos",pszYpos)) { m_iYpos = 0; } else { m_iYpos = UT_convertToLogicalUnits(pszYpos); } UT_DEBUGMSG(("ypos for frame is %s \n",pszYpos)); // ColXpos if(!pSectionAP || !pSectionAP->getProperty("frame-col-xpos",pszColXpos)) { m_iXColumn = 0; } else { m_iXColumn = UT_convertToLogicalUnits(pszColXpos); } UT_DEBUGMSG(("ColXpos for frame is %s \n",pszColXpos)); // colYpos if(!pSectionAP || !pSectionAP->getProperty("frame-col-ypos",pszColYpos)) { m_iYColumn = 0; } else { m_iYColumn = UT_convertToLogicalUnits(pszColYpos); } UT_DEBUGMSG(("ColYpos for frame is %s units %d \n",pszColYpos,m_iYColumn)); // PageXpos if(!pSectionAP || !pSectionAP->getProperty("frame-page-xpos",pszPageXpos)) { m_iXPage = 0; } else { m_iXPage = UT_convertToLogicalUnits(pszPageXpos); } UT_DEBUGMSG(("PageXpos for frame is %s units %d \n",pszPageXpos,m_iXPage)); // PageYpos if(!pSectionAP || !pSectionAP->getProperty("frame-page-ypos",pszPageYpos)) { m_iYPage = 0; } else { m_iYPage = UT_convertToLogicalUnits(pszPageYpos); } UT_DEBUGMSG(("PageYpos for frame is %s units %d \n",pszPageYpos,m_iYPage)); // Width if(!pSectionAP || !pSectionAP->getProperty("frame-width",pszWidth)) { m_iWidth = UT_convertToLogicalUnits("1.0in"); } else { m_iWidth = UT_convertToLogicalUnits(pszWidth); } if(m_iWidth < m_pLayout->getGraphics()->tlu(2)) { m_iWidth = m_pLayout->getGraphics()->tlu(2); } UT_DEBUGMSG(("Width %s \n",pszWidth)); // Height if(!pSectionAP || !pSectionAP->getProperty("frame-height",pszHeight)) { m_iHeight = UT_convertToLogicalUnits("1.0in"); } else { m_iHeight = UT_convertToLogicalUnits(pszHeight); } if(m_iHeight < m_pLayout->getGraphics()->tlu(2)) { m_iHeight = m_pLayout->getGraphics()->tlu(2); } m_iMinHeight = m_iHeight; UT_DEBUGMSG(("Height %s \n",pszHeight)); // Xpadding if(!pSectionAP || !pSectionAP->getProperty("xpad",pszXpad)) { m_iXpad = UT_convertToLogicalUnits("0.03in"); } else { m_iXpad = UT_convertToLogicalUnits(pszXpad); } // Ypadding if(!pSectionAP || !pSectionAP->getProperty("ypad",pszYpad)) { m_iYpad = UT_convertToLogicalUnits("0.03in"); } else { m_iYpad = UT_convertToLogicalUnits(pszYpad); } /* Frame-border properties: */ pSectionAP->getProperty ("color", pszColor); pSectionAP->getProperty ("bot-color",pszBorderColor); pSectionAP->getProperty ("bot-style",pszBorderStyle); pSectionAP->getProperty ("bot-thickness",pszBorderWidth); s_border_properties (pszBorderColor, pszBorderStyle, pszBorderWidth, pszColor, m_lineBottom); pszBorderColor = NULL; pszBorderStyle = NULL; pszBorderWidth = NULL; pSectionAP->getProperty ("left-color", pszBorderColor); pSectionAP->getProperty ("left-style", pszBorderStyle); pSectionAP->getProperty ("left-thickness", pszBorderWidth); s_border_properties (pszBorderColor, pszBorderStyle, pszBorderWidth, pszColor, m_lineLeft); pszBorderColor = NULL; pszBorderStyle = NULL; pszBorderWidth = NULL; pSectionAP->getProperty ("right-color",pszBorderColor); pSectionAP->getProperty ("right-style",pszBorderStyle); pSectionAP->getProperty ("right-thickness", pszBorderWidth); s_border_properties (pszBorderColor, pszBorderStyle, pszBorderWidth, pszColor, m_lineRight); pszBorderColor = NULL; pszBorderStyle = NULL; pszBorderWidth = NULL; pSectionAP->getProperty ("top-color", pszBorderColor); pSectionAP->getProperty ("top-style", pszBorderStyle); pSectionAP->getProperty ("top-thickness",pszBorderWidth); s_border_properties (pszBorderColor, pszBorderStyle, pszBorderWidth, pszColor, m_lineTop); /* Frame fill */ m_background.reset (); const gchar * pszBgStyle = NULL; const gchar * pszBgColor = NULL; const gchar * pszBackgroundColor = NULL; pSectionAP->getProperty ("bg-style", pszBgStyle); pSectionAP->getProperty ("bgcolor", pszBgColor); pSectionAP->getProperty ("background-color", pszBackgroundColor); s_background_properties (pszBgStyle, pszBgColor, pszBackgroundColor, m_background); // // Bounding Space // if(!pSectionAP || !pSectionAP->getProperty("bounding-space",pszBoundingSpace)) { m_iBoundingSpace = UT_convertToLogicalUnits("0.05in"); } else { m_iBoundingSpace = UT_convertToLogicalUnits(pszBoundingSpace); } // // Preferred Page // if(!pSectionAP || !pSectionAP->getProperty("pref-page",pszPrefPage)) { m_iPrefPage = -1; } else { if(pszPrefPage && *pszPrefPage != 0) m_iPrefPage = atoi(pszPrefPage); else m_iPrefPage = -1; } // // Percent Width // if(pSectionAP && pSectionAP->getProperty("frame-rel-width",pszPercentWidth)) { if(pszPercentWidth && (m_iWidth <= (m_pLayout->getGraphics()->tlu(2)+3))) { double frac_width = UT_convertFraction(pszPercentWidth); fl_DocSectionLayout * pDSL = getDocSectionLayout(); m_iWidth = frac_width*pDSL->getActualColumnWidth(); } } // // Min Height // if(pSectionAP && pSectionAP->getProperty("frame-min-height",pszMinHeight)) { if(pszMinHeight) { m_iMinHeight = UT_convertToLogicalUnits(pszMinHeight); m_bExpandHeight = true; } } // // Expandable Height // if(pSectionAP && pSectionAP->getProperty("frame-expand-height",pszExpandHeight)) { m_iMinHeight = m_iHeight; m_bExpandHeight = true; } // // left/right aligned // const char * pszAlign = NULL; if(pSectionAP && pSectionAP->getProperty("frame-horiz-align",pszAlign)) { if(pszAlign && (strcmp(pszAlign,"right") == 0) && (m_iXpos == 0)) { fl_DocSectionLayout * pDSL = getDocSectionLayout(); m_iXpos = pDSL->getActualColumnWidth() - m_iWidth; } } }
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()); } } }