void fp_AnnotationRun::_lookupProperties(const PP_AttrProp * pSpanAP, const PP_AttrProp * pBlockAP, const PP_AttrProp * pSectionAP, GR_Graphics * pG) { FL_DocLayout * pLayout = getBlock()->getDocLayout(); const GR_Font * pFont = pLayout->findFont(pSpanAP,pBlockAP,pSectionAP,pG); if(pFont == NULL) { pFont = pLayout->findFont(pSpanAP,pBlockAP,pSectionAP,getGraphics()); UT_ASSERT_HARMLESS(pFont); } if (pFont != _getFont()) { _setFont(pFont); _setAscent(getGraphics()->getFontAscent(pFont)); _setDescent(getGraphics()->getFontDescent(pFont)); _setHeight(getGraphics()->getFontHeight(pFont)); } }
void fp_EmbedRun::_lookupProperties(const PP_AttrProp * pSpanAP, const PP_AttrProp * /*pBlockAP*/, const PP_AttrProp * /*pSectionAP*/, GR_Graphics * pG) { UT_return_if_fail(pSpanAP != NULL); UT_DEBUGMSG(("fp_EmbedRun _lookupProperties span %p \n",pSpanAP)); m_pSpanAP = pSpanAP; m_bNeedsSnapshot = true; pSpanAP->getAttribute("dataid", m_pszDataID); const gchar * pszEmbedType = NULL; pSpanAP->getProperty("embed-type", pszEmbedType); UT_ASSERT(pszEmbedType); UT_DEBUGMSG(("Embed Type %s \n",pszEmbedType)); bool bFontChanged = false; // Load this into EmbedView // LUCA: chunk of code moved up here from the bottom of the method // 'cause we need to retrieve the font-size const PP_AttrProp * pBlockAP = NULL; const PP_AttrProp * pSectionAP = NULL; FL_DocLayout * pLayout = getBlock()->getDocLayout(); if(pG == NULL && pLayout->isQuickPrint() ) { pG = getGraphics(); if((m_iEmbedUID >= 0) && getEmbedManager()) { getEmbedManager()->releaseEmbedView(m_iEmbedUID); m_iEmbedUID = -1; } m_iEmbedUID = -1; } getBlockAP(pBlockAP); const GR_Font * pFont = pLayout->findFont(pSpanAP,pBlockAP,pSectionAP,pG); if(pLayout->isQuickPrint() && pG->queryProperties(GR_Graphics::DGP_PAPER)) { if(m_iEmbedUID >= 0 ) { getEmbedManager()->releaseEmbedView(m_iEmbedUID); m_iEmbedUID = -1; } m_iEmbedUID = - 1; m_pEmbedManager = m_pDocLayout->getQuickPrintEmbedManager(pszEmbedType); } else { m_pEmbedManager = m_pDocLayout->getEmbedManager(pszEmbedType); } if (pFont != _getFont()) { _setFont(pFont); bFontChanged = true; } if(pG == NULL) pG = getGraphics(); m_iPointHeight = pG->getFontAscent(pFont) + pG->getFontDescent(pFont); const char* pszSize = PP_evalProperty("font-size",pSpanAP,pBlockAP,pSectionAP, getBlock()->getDocument(), true); // LUCA: It is fundamental to do this before the EmbedView object // gets destroyed to avoid resuscitating it UT_sint32 iWidth,iAscent,iDescent=0; if(m_iEmbedUID < 0) { PD_Document * pDoc = getBlock()->getDocument(); m_iEmbedUID = getEmbedManager()->makeEmbedView(pDoc,m_iIndexAP,m_pszDataID); UT_DEBUGMSG((" EmbedRun %p UID is %d \n",this,m_iEmbedUID)); getEmbedManager()->initializeEmbedView(m_iEmbedUID); getEmbedManager()->setRun (m_iEmbedUID, this); getEmbedManager()->loadEmbedData(m_iEmbedUID); } getEmbedManager()->setDefaultFontSize(m_iEmbedUID,atoi(pszSize)); if (bFontChanged) bFontChanged = getEmbedManager()->setFont(m_iEmbedUID,pFont); if(getEmbedManager()->isDefault()) { iWidth = _getLayoutPropFromObject("width"); iAscent = _getLayoutPropFromObject("ascent"); iDescent = _getLayoutPropFromObject("descent"); } else { const char * pszHeight = NULL; bool bFoundHeight = pSpanAP->getProperty("height", pszHeight) && !bFontChanged; const char * pszWidth = NULL; bool bFoundWidth = pSpanAP->getProperty("width", pszWidth) && !bFontChanged; const char * pszAscent = NULL; bool bFoundAscent = pSpanAP->getProperty("ascent", pszAscent); if(!bFoundWidth || pszWidth == NULL) { iWidth = getEmbedManager()->getWidth(m_iEmbedUID); } else { iWidth = UT_convertToLogicalUnits(pszWidth); if(iWidth <= 0) { iWidth = getEmbedManager()->getWidth(m_iEmbedUID); } } if(!bFoundHeight || pszHeight == NULL || !bFoundAscent || pszAscent == NULL) { iAscent = getEmbedManager()->getAscent(m_iEmbedUID); iDescent = getEmbedManager()->getDescent(m_iEmbedUID); } else { iAscent = UT_convertToLogicalUnits(pszAscent); if(iAscent <= 0) { iAscent = getEmbedManager()->getAscent(m_iEmbedUID); iDescent = getEmbedManager()->getDescent(m_iEmbedUID); } else { UT_sint32 iHeight = UT_convertToLogicalUnits(pszHeight); const char * pszDescent = NULL; bool bFoundDescent = pSpanAP->getProperty("descent", pszDescent); if (bFoundDescent && pszDescent != NULL && iHeight >= 0) { iDescent = UT_convertToLogicalUnits(pszDescent); if (iHeight != iAscent + iDescent) iAscent = iHeight * iAscent / (iAscent + iDescent); } iDescent = (iHeight >= iAscent)? iHeight - iAscent: 0; } } } UT_DEBUGMSG(("Width = %d Ascent = %d Descent = %d \n",iWidth,iAscent,iDescent)); fl_DocSectionLayout * pDSL = getBlock()->getDocSectionLayout(); fp_Page * p = NULL; if(pDSL->getFirstContainer()) { p = pDSL->getFirstContainer()->getPage(); } else { p = pDSL->getDocLayout()->getNthPage(0); } UT_sint32 maxW = p->getWidth() - UT_convertToLogicalUnits("0.1in"); UT_sint32 maxH = p->getHeight() - UT_convertToLogicalUnits("0.1in"); maxW -= pDSL->getLeftMargin() + pDSL->getRightMargin(); maxH -= pDSL->getTopMargin() + pDSL->getBottomMargin(); markAsDirty(); if(getLine()) { getLine()->setNeedsRedraw(); } if(iAscent < 0) { iAscent = 0; } if(iDescent < 0) { iDescent = 0; } _setAscent(iAscent); _setDescent(iDescent); _setWidth(iWidth); _setHeight(iAscent+iDescent); _updatePropValuesIfNeeded(); }