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); } } }
bool fl_ContainerLayout::canContainPoint() const { if(isCollapsed()) return false; FV_View* pView = getDocLayout()->getView(); bool bShowHidden = 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; if(!_canContainPoint()) return false; // see if we are not inside a containing layout that cannot contain point fl_ContainerLayout * pMyLayout = myContainingLayout(); if(!pMyLayout || pMyLayout->getContainerType() == FL_CONTAINER_DOCSECTION) return true; return pMyLayout->canContainPoint(); }
bool fl_FrameLayout::recalculateFields(UT_uint32 iUpdateCount) { // ingnore frames in normal view mode FV_View * pView = getDocLayout()->getView(); GR_Graphics * pG = getDocLayout()->getGraphics(); UT_return_val_if_fail( pView && pG, false ); bool bResult = false; fl_ContainerLayout* pBL = getFirstLayout(); while (pBL) { bResult = pBL->recalculateFields(iUpdateCount) || bResult; pBL = pBL->getNext(); } return bResult; }
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; }
/*! Get Container's position in document \param bActualContainerPos When true return block's position. When false return position of first run in block \return Position of Container (or first run in block) \fixme Split in two functions if called most often with FALSE */ UT_uint32 fl_ContainerLayout::getPosition(bool bActualBlockPos) const { const fl_ContainerLayout * pL = this; if(!bActualBlockPos && (getContainerType() != FL_CONTAINER_TOC)) { pL = static_cast<fl_ContainerLayout *>(getNextBlockInDocument()); if(pL == NULL) { PT_DocPosition pos = getDocLayout()->getDocument()->getStruxPosition(getStruxDocHandle()); return pos; } if(pL->getContainerType() == FL_CONTAINER_BLOCK) { const fl_BlockLayout * pBL = static_cast<const fl_BlockLayout *>(pL); return pBL->getPosition(bActualBlockPos); } return 0; } PT_DocPosition pos = getDocLayout()->getDocument()->getStruxPosition(getStruxDocHandle()); return pos; }
void fl_ContainerLayout::getSpanAP(UT_uint32 blockPos, bool bLeft, const PP_AttrProp * &pSpanAP) const { //first we need to ascertain if this revision is visible FL_DocLayout* pDL = getDocLayout(); UT_return_if_fail(pDL); FV_View* pView = pDL->getView(); UT_return_if_fail(pView); UT_uint32 iId = pView->getRevisionLevel(); bool bShow = pView->isShowRevisions(); bool bHiddenRevision = false; getSpanAttrProp(blockPos, bLeft, &pSpanAP,NULL,bShow,iId,bHiddenRevision); }
void fl_FrameLayout::updateLayout(bool /*bDoAll*/) { // 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(("UpdsateLayout in in framelayout \n")); if(needsReformat()) { format(); } m_vecFormatLayout.clear(); fl_ContainerLayout* pBL = getFirstLayout(); while (pBL) { if (pBL->needsReformat()) { pBL->format(); } pBL = pBL->getNext(); } }
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); }
/*! retrieves AP associated with this layout, corretly processing any revision information; /return return value indicates whether the layout is hidden due to current revision settings or not */ FPVisibility fl_ContainerLayout::getAP(const PP_AttrProp *& pAP)const { FL_DocLayout* pDL = getDocLayout(); UT_return_val_if_fail(pDL,FP_VISIBLE); FV_View* pView = pDL->getView(); UT_return_val_if_fail(pView,FP_VISIBLE); UT_uint32 iId = pView->getRevisionLevel(); bool bShow = pView->isShowRevisions(); bool bHiddenRevision = false; getAttrProp(&pAP,NULL,bShow,iId,bHiddenRevision); if(bHiddenRevision) { return FP_HIDDEN_REVISION; } else { return FP_VISIBLE; } }
/*! * 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; }
/*! * Return the nested List level of this structure. */ UT_sint32 fl_ContainerLayout::getLevelInList(void) { fl_BlockLayout * pBList = NULL; if(getContainerType() == FL_CONTAINER_BLOCK) { pBList = static_cast<fl_BlockLayout * >(this); } else { pBList = getPrevBlockInDocument(); } UT_sint32 iLevel = 0; bool bLoop = true; while(pBList && bLoop) { while(pBList && !pBList->isListItem()) { pBList = pBList->getPrevBlockInDocument(); } if(pBList == NULL) { bLoop = false; break; } const PP_AttrProp * pAP = NULL; pBList->getAP(pAP); const gchar * szLid=NULL; UT_uint32 id=0; if (!pAP || !pAP->getAttribute(PT_LISTID_ATTRIBUTE_NAME, szLid)) szLid = NULL; if (szLid) { id = atoi(szLid); } else { id = 0; } if(id == 0) { bLoop = false; break; } PD_Document * pDoc = getDocLayout()->getDocument(); fl_AutoNum * pAuto = pDoc->getListByID( id); if(pAuto->getLastItem() == pBList->getStruxDocHandle()) { if(pAuto->getLastItem() == getStruxDocHandle()) { iLevel = pAuto->getLevel(); bLoop = false; break; } iLevel = pAuto->getLevel() -1; if(iLevel < 0) { iLevel = 0; } } else { if(pBList == this) { iLevel = pAuto->getLevel(); } else { iLevel = pAuto->getLevel() + 1; } } bLoop = false; break; } return iLevel; }
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; }
/*! 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()); } } }
/*! * This loads all the properties of the container found in the piecetable * into the physical frame container */ void fl_FrameLayout::setContainerProperties(void) { fp_FrameContainer * pFrame = static_cast<fp_FrameContainer *>(getLastContainer()); if(pFrame == NULL) { UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN); return; } pFrame->setBackground(m_background ); pFrame->setBottomStyle(m_lineBottom ); pFrame->setTopStyle(m_lineTop ); pFrame->setLeftStyle(m_lineLeft ); pFrame->setRightStyle(m_lineRight ); pFrame->setXpad(m_iXpad); pFrame->setYpad(m_iYpad); pFrame->setTightWrapping(m_bIsTightWrap); if(FL_FRAME_BELOW_TEXT == m_iFrameWrapMode) { pFrame->setAbove(false); } else if(FL_FRAME_WRAPPED_TO_RIGHT == m_iFrameWrapMode) { pFrame->setRightWrapped(true); } else if(FL_FRAME_WRAPPED_TO_LEFT == m_iFrameWrapMode) { pFrame->setLeftWrapped(true); } else if(FL_FRAME_WRAPPED_TOPBOT == m_iFrameWrapMode) { pFrame->setTopBot(true); } // // Now do the image for this frame. // if(m_pGraphicImage) { if(m_pImageImage == NULL) { const PP_AttrProp * pAP = NULL; getAP(pAP); GR_Graphics * pG = getDocLayout()->getGraphics(); UT_sint32 iWidth = pG->tlu(100); UT_sint32 iHeight = pG->tlu(100); if(m_pGraphicImage->getType() == FGT_Raster) { iWidth = pG->tlu(m_pGraphicImage->getWidth()); iHeight = pG->tlu(m_pGraphicImage->getHeight()); } GR_Image * pImage = m_pGraphicImage->generateImage(pG,pAP,iWidth,iHeight); m_iDocImageWidth = pFrame->getFullWidth(); m_iDocImageHeight = pFrame->getFullHeight(); m_iGraphicTick = getDocLayout()->getGraphicTick(); UT_Rect rec(0,0,pFrame->getFullWidth(),pFrame->getFullHeight()); if(rec.width < pG->tlu(3)) { rec.width = pG->tlu(3); } if(rec.height < pG->tlu(3)) { rec.height = pG->tlu(3); } if(pImage) { pImage->scaleImageTo(pG,rec); } m_pImageImage = pImage; } pFrame->getFillType()->setImagePointer(&m_pGraphicImage,&m_pImageImage); } if(m_iFrameWrapMode >= FL_FRAME_WRAPPED_TO_RIGHT) { // // Set text wrapping around frame // pFrame->setWrapping(true); } pFrame->setPreferedPageNo(m_iPrefPage); }
void fl_FrameLayout::_lookupMarginProperties(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 ); UT_sint32 iFramePositionTo = m_iFramePositionTo; FL_FrameWrapMode iFrameWrapMode = m_iFrameWrapMode; bool bIsTightWrap = m_bIsTightWrap; UT_sint32 iXpos = m_iXpos; UT_sint32 iYpos = m_iYpos; UT_sint32 iXColumn = m_iXColumn; UT_sint32 iYColumn = m_iYColumn; UT_sint32 iXPage = m_iXPage; UT_sint32 iYPage = m_iYPage; if(pView->getViewMode() == VIEW_NORMAL && !pG->queryProperties(GR_Graphics::DGP_PAPER)) { m_iFramePositionTo = FL_FRAME_POSITIONED_TO_BLOCK; m_iFrameWrapMode = FL_FRAME_WRAPPED_TO_RIGHT; m_bIsTightWrap = false; m_iXpos = 0; m_iYpos = 0; m_iXColumn = 0; m_iYColumn = 0; m_iXPage = 0; m_iYPage = 0; } else { 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 * pszTightWrapped = NULL; // 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; } // 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 \n",pszPageXpos)); // 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",pszColYpos,m_iYPage)); } fl_ContainerLayout* pCL = getFirstLayout(); while (pCL) { pCL->lookupMarginProperties(); pCL = pCL->getNext(); } if(iFramePositionTo != m_iFramePositionTo || iFrameWrapMode != m_iFrameWrapMode || bIsTightWrap != m_bIsTightWrap || iXpos != m_iXpos || iYpos != m_iYpos || iXColumn != m_iXColumn || iYColumn != m_iYColumn || iXPage != m_iXPage || iYPage != m_iYPage) { collapse(); } }